19 lines
749 B
JavaScript
19 lines
749 B
JavaScript
/**
|
||
* Builds the tool ctx object from environment variables.
|
||
* Used by companion-stdio.js when a tool call arrives, so each call reads
|
||
* fresh env values (useful if the process restarts or env is injected at launch).
|
||
*
|
||
* Environment variables:
|
||
* VOID_AGENT_JSON – JSON-serialised agent actor object (required for most tools)
|
||
* VOID_SPACE_ID – UUID of the active space
|
||
* VOID_VIEW_JSON – JSON-serialised view object (optional)
|
||
*/
|
||
export function buildCtxFromEnv(env = process.env) {
|
||
return {
|
||
agent: env.VOID_AGENT_JSON ? JSON.parse(env.VOID_AGENT_JSON) : null,
|
||
space_id: env.VOID_SPACE_ID || null,
|
||
view: env.VOID_VIEW_JSON ? JSON.parse(env.VOID_VIEW_JSON) : null,
|
||
actor: { kind: 'user', id: null }
|
||
};
|
||
}
|