( packageIdentifiers: PackageIdentifier[], ide: IDE, registryClient: RegistryClient, )
| 12 | // 1. creates an assistant out of all local blocks |
| 13 | // 2. unrolls it like a local assistant |
| 14 | export async function unrollLocalYamlBlocks( |
| 15 | packageIdentifiers: PackageIdentifier[], |
| 16 | ide: IDE, |
| 17 | registryClient: RegistryClient, |
| 18 | ): Promise<ConfigResult<AssistantUnrolled>> { |
| 19 | try { |
| 20 | const unrollResult = await unrollAssistantFromContent( |
| 21 | { |
| 22 | uriType: "file", |
| 23 | fileUri: "", |
| 24 | }, |
| 25 | "name: FILLER\nschema: v1\nversion: 0.0.1", |
| 26 | registryClient, |
| 27 | { |
| 28 | currentUserSlug: "", |
| 29 | platformClient: new LocalPlatformClient(ide), |
| 30 | renderSecrets: true, |
| 31 | injectBlocks: packageIdentifiers, |
| 32 | }, |
| 33 | ); |
| 34 | const config = |
| 35 | "config" in unrollResult ? unrollResult.config : unrollResult; |
| 36 | const errors = "errors" in unrollResult ? unrollResult.errors : []; |
| 37 | return { |
| 38 | config, |
| 39 | errors, |
| 40 | configLoadInterrupted: false, |
| 41 | }; |
| 42 | } catch (error) { |
| 43 | let message = "An unknown error occurred while loading local YAML blocks"; |
| 44 | if (error instanceof Error) { |
| 45 | message += ": " + error.message; |
| 46 | } |
| 47 | return { |
| 48 | config: undefined, |
| 49 | errors: [{ message, fatal: false }], |
| 50 | configLoadInterrupted: false, |
| 51 | }; |
| 52 | } |
| 53 | } |
no test coverage detected