openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
29 lines (28 loc) • 973 B
JavaScript
//#region src/infra/openclaw-exec-env.ts
const OPENCLAW_CLI_ENV_VAR = "OPENCLAW_CLI";
/** Child-shell routing hint; it does not authenticate or authorize a Gateway caller. */
const SUBAGENT_EXEC_ENV_VAR = "OPENCLAW_SUBAGENT_EXEC";
const CLI_ENV_VALUE = "1";
function markOpenClawExecEnv(e) {
return {
...e,
[OPENCLAW_CLI_ENV_VAR]: CLI_ENV_VALUE
};
}
function ensureOpenClawExecMarkerOnProcess(e = process.env) {
e[OPENCLAW_CLI_ENV_VAR] = CLI_ENV_VALUE;
return e;
}
function buildExecRoutingEnv(e) {
const { senderId: t, chatId: n, subagent: r } = e ?? {};
if (!t && !n && !r) return;
return {
...t || n ? { OPENCLAW_CHANNEL_CONTEXT: JSON.stringify({
...t ? { sender: { id: t } } : {},
...n ? { chat: { id: n } } : {}
}) } : {},
...r ? { [SUBAGENT_EXEC_ENV_VAR]: "1" } : {}
};
}
//#endregion
export { markOpenClawExecEnv as a, ensureOpenClawExecMarkerOnProcess as i, SUBAGENT_EXEC_ENV_VAR as n, buildExecRoutingEnv as r, OPENCLAW_CLI_ENV_VAR as t };