@@ -19,11 +19,20 @@ interface WebRoute {
1919 path : string
2020 handler : ( req : IncomingMessage , res : ServerResponse ) => void | Promise < void >
2121}
22+ /** Shell-environment registration shape (declared inline to avoid a host-package dependency). */
23+ interface ShellEnvRegistration {
24+ name : string
25+ variables : Record < string , { description : string } >
26+ resolve : ( ) => Record < string , string | undefined >
27+ }
2228declare module '@deepseek-ai/cordis' {
2329 interface Context {
2430 webServer : {
2531 register ( route : WebRoute ) : ( ) => void
2632 }
33+ shellEnv : {
34+ register ( registration : ShellEnvRegistration ) : void
35+ }
2736 }
2837}
2938
@@ -184,6 +193,25 @@ export function apply(ctx: Context, config: Config): void {
184193 }
185194 registerSkill ( ctx )
186195
196+ // Export the resolved workspace id as a shell environment variable so
197+ // management CLI commands (`bl knowledge list`, `kscli kb list`, etc.)
198+ // running in bash can see the value the settings service resolved.
199+ // Without this, the settings.yaml value is invisible to child processes.
200+ ctx . inject ( [ 'shellEnv' ] , ( envCtx ) => {
201+ envCtx . shellEnv . register ( {
202+ name : 'bailian-kb' ,
203+ variables : {
204+ BAILIAN_WORKSPACE_ID : {
205+ description : 'Bailian workspace id resolved from settings (Settings → 百炼知识库) or credentials.' ,
206+ } ,
207+ } ,
208+ resolve : ( ) => {
209+ const wsId = current ( ) . workspaceId
210+ return wsId ? { BAILIAN_WORKSPACE_ID : wsId } : { }
211+ } ,
212+ } )
213+ } )
214+
187215 // Bridge routes let the browser settings page read and write the resolved
188216 // section without riding the settings wire (which requires an apiproxy
189217 // allowlist entry the composition does not grant out-of-tree namespaces).
0 commit comments