From 1dddae2381cb320fa5f0d3d05d96328057a90c79 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 6 Jun 2025 14:04:57 -0700 Subject: [PATCH] lazily unroll local assistant --- core/config/yaml/loadYaml.ts | 68 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 29c6cc5dd..5a0bc99ba 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -117,45 +117,49 @@ async function loadConfigYaml(options: { // `Loading config.yaml from ${JSON.stringify(packageIdentifier)} with root path ${rootPath}`, // ); - // This is how we allow use of blocks locally - const unrollResult = await unrollAssistant( - packageIdentifier, - new RegistryClient({ - accessToken: await controlPlaneClient.getAccessToken(), - apiBase: getControlPlaneEnvSync(ideSettings.continueTestEnvironment) - .CONTROL_PLANE_URL, - rootPath, - }), - { - currentUserSlug: "", - onPremProxyUrl: null, - orgScopeId, - platformClient: new LocalPlatformClient( - orgScopeId, - controlPlaneClient, - ide, - ), - renderSecrets: true, - injectBlocks: allLocalBlocks, - asConfigResult: true, - }, - ); - const errors: ConfigValidationError[] = []; - const config = overrideConfigYaml ?? unrollResult.config; + let config: AssistantUnrolled | undefined; + + if (overrideConfigYaml) { + config = overrideConfigYaml; + } else { + // This is how we allow use of blocks locally + const unrollResult = await unrollAssistant( + packageIdentifier, + new RegistryClient({ + accessToken: await controlPlaneClient.getAccessToken(), + apiBase: getControlPlaneEnvSync(ideSettings.continueTestEnvironment) + .CONTROL_PLANE_URL, + rootPath, + }), + { + currentUserSlug: "", + onPremProxyUrl: null, + orgScopeId, + platformClient: new LocalPlatformClient( + orgScopeId, + controlPlaneClient, + ide, + ), + renderSecrets: true, + injectBlocks: allLocalBlocks, + asConfigResult: true, + }, + ); + config = unrollResult.config; + if (unrollResult.errors) { + errors.push(...unrollResult.errors); + } + } if (config) { isAssistantUnrolledNonNullable(config) ? errors.push(...validateConfigYaml(config)) : errors.push({ - fatal: true, - message: "Assistant includes blocks that don't exist", - }); - } - - if (unrollResult.errors) { - errors.push(...unrollResult.errors); + fatal: true, + message: "Assistant includes blocks that don't exist", + }); } if (errors?.some((error) => error.fatal)) {