Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions LifeOS/install/LIFEOS/TOOLS/AgentJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ function loadDotEnv(): Record<string, string> {

function jobEnv(job: Job, extra: Record<string, string> = {}): NodeJS.ProcessEnv {
const env: Record<string, string | undefined> = { ...loadDotEnv(), ...process.env };
delete env.CLAUDECODE; delete env.ANTHROPIC_API_KEY; delete env.ANTHROPIC_AUTH_TOKEN; delete env.ANTHROPIC_BASE_URL;
delete env.CLAUDECODE;
// A custom ANTHROPIC_BASE_URL is the principal's explicit carrier (local LLM
// proxy, gateway) and is kept; the key scrub only guards Anthropic billing,
// which is unreachable through a custom base URL.
if (!env.ANTHROPIC_BASE_URL) { delete env.ANTHROPIC_API_KEY; delete env.ANTHROPIC_AUTH_TOKEN; }
env.LIFEOS_NOTIFICATION_CHANNEL = "headless";
env.LIFEOS_ROOT = LIFEOS_ROOT;
env.AGENTJOB_ID = job.id;
Expand Down Expand Up @@ -345,7 +349,7 @@ async function runDa(job: Job, prompt: string, env: NodeJS.ProcessEnv, timeoutMs
...claudeToolFlags(job, LIFEOS_ROOT, stateDir),
"--append-system-prompt", JOB_SOUL,
];
log(job.id, "spawn_env_scrubbed", { scrubbed: ["CLAUDECODE", "ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_BASE_URL"], channel: "headless", model: args[2] });
log(job.id, "spawn_env_scrubbed", { scrubbed: ["CLAUDECODE", ...(env.ANTHROPIC_BASE_URL ? [] : ["ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"])], channel: "headless", model: args[2] });
return await new Promise((resolve) => {
const proc = spawn(resolveClaudeBin(), args, { cwd: ensureJobCwd(), env, stdio: ["pipe", "pipe", "pipe"] });
let out = "", err = "";
Expand Down
14 changes: 10 additions & 4 deletions LifeOS/install/LIFEOS/TOOLS/CarrierProbe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,21 @@ function runChild(): Promise<{ envelope: Record<string, unknown> | null; raw: st
// Nested-session guard: hooks run inside Claude Code's environment.
delete env.CLAUDECODE;
// BILLING: subscription via OAuth — both keys outrank the OAuth token in
// Anthropic's precedence chain, and bun auto-loads ~/.claude/.env. Scrub.
delete env.ANTHROPIC_API_KEY;
delete env.ANTHROPIC_AUTH_TOKEN;
// Anthropic's precedence chain, and bun auto-loads ~/.claude/.env. Scrub,
// but only against the default Anthropic API: a configured
// ANTHROPIC_BASE_URL is the principal's explicit carrier (local LLM proxy,
// gateway), and scrubbing it strands the child on api.anthropic.com 401s.
if (!env.ANTHROPIC_BASE_URL) {
delete env.ANTHROPIC_API_KEY;
delete env.ANTHROPIC_AUTH_TOKEN;
}
// Headless subprocess: never the desktop voice channel (2026-08-14 leak).
// Unset AND `desktop` collapse to headless (public issue #1975, @emarcelcom).
env.LIFEOS_NOTIFICATION_CHANNEL = !env.LIFEOS_NOTIFICATION_CHANNEL || env.LIFEOS_NOTIFICATION_CHANNEL === 'desktop'
? 'headless'
: env.LIFEOS_NOTIFICATION_CHANNEL;
delete env.ANTHROPIC_BASE_URL;
// ANTHROPIC_BASE_URL is kept when set: the billing scrub above only runs
// against the default Anthropic API, where a stray key could bill per-token.

const prompt =
'Use your agent-dispatch tool (named Agent or Task) exactly once: ' +
Expand Down
20 changes: 13 additions & 7 deletions LifeOS/install/LIFEOS/TOOLS/Inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,17 @@ async function inferenceAttempt(options: InferenceOptions, modelOverride?: strin
// puts BOTH ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN above CLAUDE_CODE_OAUTH_TOKEN,
// so either one in env will silently override OAuth. Bun auto-loads ~/.claude/.env
// into child processes, and some MCP/plugin setups export ANTHROPIC_AUTH_TOKEN —
// either path leaks subscription work onto API-key billing. Scrub both.
delete env.ANTHROPIC_API_KEY;
delete env.ANTHROPIC_AUTH_TOKEN;
// either path leaks subscription work onto API-key billing. Scrub both, but
// only when the default Anthropic API is the target: a configured
// ANTHROPIC_BASE_URL is the principal's explicit carrier (local LLM proxy,
// gateway), no Anthropic billing is reachable from it, and scrubbing would
// strand the child on api.anthropic.com with no credentials — every nested
// call 401s and retries until timeout (2026-11-03 local-LLM install, memory
// reviewer parse-failed on api_error_status=401).
if (!env.ANTHROPIC_BASE_URL) {
delete env.ANTHROPIC_API_KEY;
delete env.ANTHROPIC_AUTH_TOKEN;
}
// Headless subprocess: never the desktop voice channel, even when spawned
// from a terminal session whose TERM the child would inherit. Explicit
// channels (imessage, ...) pass through. (2026-08-14 scheduled voice leak.)
Expand All @@ -472,10 +480,8 @@ async function inferenceAttempt(options: InferenceOptions, modelOverride?: strin
env.LIFEOS_NOTIFICATION_CHANNEL = !env.LIFEOS_NOTIFICATION_CHANNEL || env.LIFEOS_NOTIFICATION_CHANNEL === 'desktop'
? 'headless'
: env.LIFEOS_NOTIFICATION_CHANNEL;
// Also scrub ANTHROPIC_BASE_URL: a local proxy (e.g. a LiteLLM gateway) would
// still be targeted after the child loses its credentials above, so every
// nested call fails auth (401) and retries until timeout. Force real Anthropic API.
delete env.ANTHROPIC_BASE_URL;
// ANTHROPIC_BASE_URL is kept when set: the billing scrub above only runs
// against the default Anthropic API, where a stray key could bill per-token.
// The CLI finds its subscription login in the macOS Keychain by USER. A workflow step or launchd job may hand the
// child only PATH and HOME, and then every call answers "Not logged in" (a scheduled judge call
// can fail this way on its first run).
Expand Down