/** * Keep each Codex agent's shell commands in that agent's own process. * * Codex 0.157+ runs the TUI against one shared background app server * (`codex app-server --listen unix:// --managed-daemon`), started by whichever * Codex session on the machine starts first — usually the orchestrator. Tool * and shell commands run inside that daemon, so they inherit ITS environment: * every Codex agent's skills sent `X-Agent-Session: crewly-orc` and acted as * the orchestrator (steamfun-ops, 2026-09-30: Avery's reply-channel 404'd * because the orc was not in the room, and her answer was lost). * * `codex --no-daemon` runs the app server inside the TUI process instead, so * commands inherit the PTY's spawn env (CREWLY_SESSION_NAME, CREWLY_ROLE, the * API keys …). Login is untouched: every session still reads the same * `$CODEX_HOME/auth.json`. * * @module services/agent/codex-daemon.utils */ import type { RunCommand } from '../harness/harness.types.js'; /** * Add `--no-daemon` to a Codex launch command (`codex …` or `codex resume …`). * A command that does not run codex, or already picks its app server * (`--no-daemon`, `--remote`), is returned unchanged. * * @param command - One launch command line * @returns The command with the flag right after `codex` / `codex resume` * * @example * withCodexNoDaemon('codex -a never -s danger-full-access') * // => 'codex --no-daemon -a never -s danger-full-access' */ export declare function withCodexNoDaemon(command: string): string; /** Injectable pieces of the capability check (tests). */ export interface CodexNoDaemonProbeDeps { run?: RunCommand; /** Finds the codex binary the agent shell would run */ resolveCodex?: () => string | null; env?: NodeJS.ProcessEnv; now?: () => number; } /** * Whether the installed Codex has `--no-daemon`. Passing the flag to a Codex * that lacks it would stop the agent from starting (clap rejects unknown * arguments), so the flag is only added once `codex --help` lists it. A yes is * kept for the life of the process; a no is re-checked after * NO_DAEMON_PROBE_RETRY_MS in case Codex was upgraded meanwhile. * * Never throws: a missing or broken codex counts as "no". * * @param deps - Injectable dependencies * @returns True when `codex --help` mentions `--no-daemon` */ export declare function codexSupportsNoDaemon(deps?: CodexNoDaemonProbeDeps): Promise; /** Forget the cached capability check (tests). */ export declare function resetCodexNoDaemonProbe(): void; /** * Whether the codex binary the agent shell would run lists `flag` in its * `--help`. A positive answer is cached for the process; a negative one is * re-checked after NO_DAEMON_PROBE_RETRY_MS (an upgrade may add the flag). * * Used for `--dangerously-bypass-hook-trust`, which the credential guard * needs (specs/2026-10-04-agent-credential-isolation.md): a Codex too old to * know it would refuse to start if it were passed. * * @param flag - Flag to look for * @param deps - Same injectables as {@link codexSupportsNoDaemon} * @returns True when listed */ export declare function codexSupportsFlag(flag: string, deps?: CodexNoDaemonProbeDeps): Promise; /** Forget every {@link codexSupportsFlag} result (tests). */ export declare function resetCodexFlagProbes(): void; //# sourceMappingURL=codex-daemon.utils.d.ts.map