diff --git a/packages/tool-bailian-kb/src/index.ts b/packages/tool-bailian-kb/src/index.ts index c9c8eb5..912acdd 100644 --- a/packages/tool-bailian-kb/src/index.ts +++ b/packages/tool-bailian-kb/src/index.ts @@ -19,11 +19,20 @@ interface WebRoute { path: string handler: (req: IncomingMessage, res: ServerResponse) => void | Promise } +/** Shell-environment registration shape (declared inline to avoid a host-package dependency). */ +interface ShellEnvRegistration { + name: string + variables: Record + resolve: () => Record +} declare module '@deepseek-ai/cordis' { interface Context { webServer: { register(route: WebRoute): () => void } + shellEnv: { + register(registration: ShellEnvRegistration): void + } } } @@ -184,6 +193,25 @@ export function apply(ctx: Context, config: Config): void { } registerSkill(ctx) + // Export the resolved workspace id as a shell environment variable so + // management CLI commands (`bl knowledge list`, `kscli kb list`, etc.) + // running in bash can see the value the settings service resolved. + // Without this, the settings.yaml value is invisible to child processes. + ctx.inject(['shellEnv'], (envCtx) => { + envCtx.shellEnv.register({ + name: 'bailian-kb', + variables: { + BAILIAN_WORKSPACE_ID: { + description: 'Bailian workspace id resolved from settings (Settings → 百炼知识库) or credentials.', + }, + }, + resolve: () => { + const wsId = current().workspaceId + return wsId ? { BAILIAN_WORKSPACE_ID: wsId } : {} + }, + }) + }) + // Bridge routes let the browser settings page read and write the resolved // section without riding the settings wire (which requires an apiproxy // allowlist entry the composition does not grant out-of-tree namespaces).