@memnexus-ai/mx-agent-cli 0.1.245 → 0.1.247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/__tests__/codex-agent-gate.test.d.ts +2 -0
  2. package/dist/__tests__/codex-agent-gate.test.d.ts.map +1 -0
  3. package/dist/__tests__/codex-agent-gate.test.js +182 -0
  4. package/dist/__tests__/codex-agent-gate.test.js.map +1 -0
  5. package/dist/__tests__/runtime-claude-adapter.test.d.ts +2 -0
  6. package/dist/__tests__/runtime-claude-adapter.test.d.ts.map +1 -0
  7. package/dist/__tests__/runtime-claude-adapter.test.js +70 -0
  8. package/dist/__tests__/runtime-claude-adapter.test.js.map +1 -0
  9. package/dist/__tests__/runtime-codex-adapter.test.d.ts +2 -0
  10. package/dist/__tests__/runtime-codex-adapter.test.d.ts.map +1 -0
  11. package/dist/__tests__/runtime-codex-adapter.test.js +475 -0
  12. package/dist/__tests__/runtime-codex-adapter.test.js.map +1 -0
  13. package/dist/__tests__/runtime-codex-config.test.d.ts +2 -0
  14. package/dist/__tests__/runtime-codex-config.test.d.ts.map +1 -0
  15. package/dist/__tests__/runtime-codex-config.test.js +523 -0
  16. package/dist/__tests__/runtime-codex-config.test.js.map +1 -0
  17. package/dist/__tests__/runtime-codex-version-pin.test.d.ts +2 -0
  18. package/dist/__tests__/runtime-codex-version-pin.test.d.ts.map +1 -0
  19. package/dist/__tests__/runtime-codex-version-pin.test.js +69 -0
  20. package/dist/__tests__/runtime-codex-version-pin.test.js.map +1 -0
  21. package/dist/__tests__/runtime-resolve.test.d.ts +2 -0
  22. package/dist/__tests__/runtime-resolve.test.d.ts.map +1 -0
  23. package/dist/__tests__/runtime-resolve.test.js +172 -0
  24. package/dist/__tests__/runtime-resolve.test.js.map +1 -0
  25. package/dist/__tests__/start-rebase-never-ran.test.d.ts +25 -0
  26. package/dist/__tests__/start-rebase-never-ran.test.d.ts.map +1 -0
  27. package/dist/__tests__/start-rebase-never-ran.test.js +227 -0
  28. package/dist/__tests__/start-rebase-never-ran.test.js.map +1 -0
  29. package/dist/__tests__/start-runtime-wiring.test.d.ts +31 -0
  30. package/dist/__tests__/start-runtime-wiring.test.d.ts.map +1 -0
  31. package/dist/__tests__/start-runtime-wiring.test.js +498 -0
  32. package/dist/__tests__/start-runtime-wiring.test.js.map +1 -0
  33. package/dist/agent-config/hooks/deploy-verification-reminder.sh +143 -12
  34. package/dist/agent-config/hooks/memory-checkpoint-reminder.sh +20 -2
  35. package/dist/commands/codex-agent-gate.d.ts +23 -0
  36. package/dist/commands/codex-agent-gate.d.ts.map +1 -0
  37. package/dist/commands/codex-agent-gate.js +139 -0
  38. package/dist/commands/codex-agent-gate.js.map +1 -0
  39. package/dist/commands/start.d.ts +21 -0
  40. package/dist/commands/start.d.ts.map +1 -1
  41. package/dist/commands/start.js +190 -25
  42. package/dist/commands/start.js.map +1 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +23 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/lib/claude.d.ts +72 -10
  47. package/dist/lib/claude.d.ts.map +1 -1
  48. package/dist/lib/claude.js +71 -32
  49. package/dist/lib/claude.js.map +1 -1
  50. package/dist/lib/runtime/claude-adapter.d.ts +16 -0
  51. package/dist/lib/runtime/claude-adapter.d.ts.map +1 -0
  52. package/dist/lib/runtime/claude-adapter.js +43 -0
  53. package/dist/lib/runtime/claude-adapter.js.map +1 -0
  54. package/dist/lib/runtime/codex-adapter.d.ts +90 -0
  55. package/dist/lib/runtime/codex-adapter.d.ts.map +1 -0
  56. package/dist/lib/runtime/codex-adapter.js +357 -0
  57. package/dist/lib/runtime/codex-adapter.js.map +1 -0
  58. package/dist/lib/runtime/codex-config.d.ts +254 -0
  59. package/dist/lib/runtime/codex-config.d.ts.map +1 -0
  60. package/dist/lib/runtime/codex-config.js +620 -0
  61. package/dist/lib/runtime/codex-config.js.map +1 -0
  62. package/dist/lib/runtime/resolve.d.ts +46 -0
  63. package/dist/lib/runtime/resolve.d.ts.map +1 -0
  64. package/dist/lib/runtime/resolve.js +113 -0
  65. package/dist/lib/runtime/resolve.js.map +1 -0
  66. package/dist/lib/runtime/types.d.ts +81 -0
  67. package/dist/lib/runtime/types.d.ts.map +1 -0
  68. package/dist/lib/runtime/types.js +39 -0
  69. package/dist/lib/runtime/types.js.map +1 -0
  70. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ClaudeAdapter — the default runtime, wrapping today's launcher unchanged
3
+ * (#4227 Phase 1, task 1.1).
4
+ *
5
+ * DESIGN PRINCIPLE 1: `--runtime claude` must produce byte-identical behaviour to
6
+ * pre-#4227. So this adapter adds nothing: no preflight probe (a `claude`-missing
7
+ * check that did not exist before could refuse a start that used to work), no
8
+ * config deployment (start.ts already deploys `.claude/*`, `CLAUDE.md`,
9
+ * `AGENTS.md` and `CLAUDE.local.md` in its own steps), and `launch` forwards
10
+ * straight to `launchClaudeSession` with the same options.
11
+ */
12
+ import { launchClaudeSession } from '../claude.js';
13
+ export class ClaudeAdapter {
14
+ id = 'claude';
15
+ model;
16
+ constructor(opts) {
17
+ this.model = opts.sessionModel;
18
+ }
19
+ /** No-op by design — see the file header (no new refusal on the Claude path). */
20
+ preflight() {
21
+ /* intentionally empty */
22
+ }
23
+ /** Always allowed — Claude is the default runtime and is gated by nothing. */
24
+ assertLaunchAllowed(_ctx) {
25
+ /* intentionally empty */
26
+ }
27
+ /** No-op by design — start.ts owns `.claude/*` and instruction-file deployment. */
28
+ deployConfig(_ctx) {
29
+ /* intentionally empty */
30
+ }
31
+ async launch(ctx) {
32
+ await launchClaudeSession({
33
+ worktreePath: ctx.worktreePath,
34
+ worktreeName: ctx.worktreeName,
35
+ branch: ctx.branch,
36
+ slot: ctx.slot,
37
+ initialPrompt: ctx.initialPrompt,
38
+ teamName: ctx.teamName,
39
+ sessionModel: this.model,
40
+ });
41
+ }
42
+ }
43
+ //# sourceMappingURL=claude-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-adapter.js","sourceRoot":"","sources":["../../../src/lib/runtime/claude-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,OAAO,aAAa;IACf,EAAE,GAAc,QAAQ,CAAC;IACzB,KAAK,CAAS;IAEvB,YAAY,IAA8B;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;IACjC,CAAC;IAED,iFAAiF;IACjF,SAAS;QACP,yBAAyB;IAC3B,CAAC;IAED,8EAA8E;IAC9E,mBAAmB,CAAC,IAAyC;QAC3D,yBAAyB;IAC3B,CAAC;IAED,mFAAmF;IACnF,YAAY,CAAC,IAAmB;QAC9B,yBAAyB;IAC3B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAkB;QAC7B,MAAM,mBAAmB,CAAC;YACxB,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,YAAY,EAAE,IAAI,CAAC,KAAK;SACzB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,90 @@
1
+ import type { LaunchContext, RuntimeAdapter, RuntimeId } from './types.js';
2
+ /**
3
+ * Environment variable that permits a Codex launch while gate G-7 is unpassed.
4
+ * Platform-supervised, trusted-input development only — no guard hook is enforced
5
+ * on Codex in this state (PRD R-5 correction).
6
+ */
7
+ export declare const CODEX_PHASE1_DEV_ENV = "MX_AGENT_CODEX_PHASE1_DEV";
8
+ /** Hard-coded ineligible. Cannot be added to any allowlist by configuration (FR-14b). */
9
+ export declare const CODEX_HARD_INELIGIBLE_AGENTS: readonly ["security-reviewer"];
10
+ /**
11
+ * Review-gate agents whose Codex path is a separately-invoked wrapper, never an
12
+ * in-session persona injection (FR-14a). Refused here by design, not by omission.
13
+ */
14
+ export declare const CODEX_WRAPPER_ONLY_AGENTS: readonly ["bar-raiser", "red-team"];
15
+ /**
16
+ * Every agent whose safety-critical property is enforced by a HOOK rather than by
17
+ * tool typing, with the hook that enforces it. Transcribed from the PRD's
18
+ * per-agent safety mechanism table. For each of these, persona injection makes the
19
+ * agent functional, not safe — eligibility exists only once the named mechanism is
20
+ * ported AND verified firing (FR-15).
21
+ */
22
+ export declare const CODEX_HOOK_GATED_AGENTS: Readonly<Record<string, string>>;
23
+ export interface EligibilityResult {
24
+ eligible: boolean;
25
+ /** User-facing refusal naming the blocking mechanism. Absent when eligible. */
26
+ reason?: string;
27
+ }
28
+ /**
29
+ * Decide whether an agent may run under Codex.
30
+ *
31
+ * `provenGuards` is the set of guard mechanisms proven FIRING SELECTIVELY in a live
32
+ * Codex session — the G-7 artifact. It defaults to empty, so with G-7 unpassed the
33
+ * allowlist is empty for every Bash-holding agent, which is exactly what FR-15's
34
+ * test requires. Passing a guard name here is an assertion that the paired
35
+ * negative+positive proof exists for it; config inspection is not proof (FR-9).
36
+ */
37
+ export declare function checkCodexAgentEligibility(agent: string, opts?: {
38
+ provenGuards?: readonly string[];
39
+ }): EligibilityResult;
40
+ export interface CodexAdapterOptions {
41
+ projectRoot: string;
42
+ model?: string;
43
+ projectSlug?: string;
44
+ /** Guards proven firing selectively in a live Codex session (gate G-7). */
45
+ provenGuards?: readonly string[];
46
+ }
47
+ export declare class CodexAdapter implements RuntimeAdapter {
48
+ readonly id: RuntimeId;
49
+ readonly model: string;
50
+ private readonly projectRoot;
51
+ private readonly projectSlug?;
52
+ private readonly provenGuards;
53
+ constructor(opts: CodexAdapterOptions);
54
+ /** True once every Phase 1 containment guard has a paired live proof (gate G-7). */
55
+ get guardsProven(): boolean;
56
+ /**
57
+ * FR-8: refuse when the `codex` binary is missing, with an install hint and a
58
+ * non-zero exit — never a silent Claude fallback, which would hide which runtime
59
+ * actually ran. Also warns (never blocks) on a version the adapter's probes were
60
+ * not run against.
61
+ */
62
+ preflight(): void;
63
+ deployConfig(ctx: LaunchContext): void;
64
+ /**
65
+ * FR-6: spawn `codex exec -m <model> -C <worktree> <prompt>`.
66
+ *
67
+ * stdin is `'ignore'`, NOT `'inherit'`. `codex exec` waits for stdin EOF when it
68
+ * is not attached to a TTY — a 7m16s hang was reproduced on v0.144.5, and on
69
+ * 0.145.0 the process still prints "Reading additional input from stdin..." even
70
+ * when a prompt argument is present. Inheriting a non-TTY stdin reintroduces the
71
+ * hang, so this must never become `'inherit'`.
72
+ */
73
+ /**
74
+ * The Phase 1 gate, callable before any side effect (security review S7).
75
+ *
76
+ * `runStart` calls this after preflight and BEFORE it persists `.mx-runtime`, so a
77
+ * refused launch leaves no persisted runtime behind — otherwise the next flagless
78
+ * start would resolve `codex` from a file written by a start that never ran, and
79
+ * the operator would have to know to delete it. `launch` calls it again: the
80
+ * refusal must hold even if a future caller forgets this one.
81
+ */
82
+ assertLaunchAllowed(ctx: Pick<LaunchContext, 'worktreePath'>): void;
83
+ launch(ctx: LaunchContext): Promise<void>;
84
+ /**
85
+ * Lines the start banner must print for a Codex launch. Each states a declared
86
+ * degradation rather than leaving it implicit (FR-14b, FR-16, PRD Phase 1).
87
+ */
88
+ bannerNotices(ctx?: Pick<LaunchContext, 'worktreePath'>): string[];
89
+ }
90
+ //# sourceMappingURL=codex-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-adapter.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/codex-adapter.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAW3E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAIhE,yFAAyF;AACzF,eAAO,MAAM,4BAA4B,gCAAiC,CAAC;AAE3E;;;GAG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I,CAAC;IAmF/C;;;OAGG;IACH,aAAa,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,MAAM,EAAE;CA4BnE"}
@@ -0,0 +1,357 @@
1
+ /**
2
+ * CodexAdapter — launches a team session on OpenAI Codex (#4227 Phase 1,
3
+ * tasks 1.4, 1.8, 1.9).
4
+ *
5
+ * Mirrors `launchClaudeSession`'s process contract exactly: spawn, own the
6
+ * terminal, patch childPid into the already-claimed leader lock, propagate the
7
+ * child's exit code, remove the lock on the way out.
8
+ *
9
+ * THREE THINGS ARE DELIBERATELY CLOSED HERE:
10
+ *
11
+ * 1. THE OPT-IN IS GATED (PRD Phase 1 hard scope rule). Phase 1 cannot close and
12
+ * no non-platform team may opt in to `--runtime codex` until gate G-7 passes —
13
+ * both containment guards proven FIRING SELECTIVELY in a live Codex session
14
+ * (blocked destructive op AND a permitted op succeeding). Until that proof
15
+ * exists, `launch()` refuses. `MX_AGENT_CODEX_PHASE1_DEV=1` is the
16
+ * platform-supervised development escape hatch, and it says so in the refusal.
17
+ *
18
+ * 2. SECURITY-REVIEWER IS INELIGIBLE, HARD-CODED (FR-14b). Not a list entry a
19
+ * config can extend: its job requires Bash, and no proven Codex configuration
20
+ * supplies Bash + host-scoped read + write-deny simultaneously.
21
+ *
22
+ * 3. BAR-RAISER AND RED-TEAM ARE NOT PERSONA-INJECTED IN-SESSION (FR-14a). Their
23
+ * Codex path, if it lands, is a separately-invoked read-only wrapper process,
24
+ * not an in-session subagent.
25
+ */
26
+ import { spawn, spawnSync } from 'child_process';
27
+ import chalk from 'chalk';
28
+ import { sanitizeForMessage } from '../behavioral-injection.js';
29
+ import { removeLock, updateChildPid } from '../leader-lock.js';
30
+ import { CODEX_DEFAULT_MODEL, VERIFIED_CODEX_VERSION, codexHookTrustPreconditions, deployCodexConfig, } from './codex-config.js';
31
+ /** Signal name → number, for mapping a signal-kill to a 128+signum exit code. */
32
+ const SIGNAL_NUMBERS = {
33
+ SIGINT: 2,
34
+ SIGQUIT: 3,
35
+ SIGKILL: 9,
36
+ SIGTERM: 15,
37
+ SIGHUP: 1,
38
+ };
39
+ /**
40
+ * Environment variable that permits a Codex launch while gate G-7 is unpassed.
41
+ * Platform-supervised, trusted-input development only — no guard hook is enforced
42
+ * on Codex in this state (PRD R-5 correction).
43
+ */
44
+ export const CODEX_PHASE1_DEV_ENV = 'MX_AGENT_CODEX_PHASE1_DEV';
45
+ // ── FR-14b / FR-14a / FR-15: agent eligibility ────────────────────────────────
46
+ /** Hard-coded ineligible. Cannot be added to any allowlist by configuration (FR-14b). */
47
+ export const CODEX_HARD_INELIGIBLE_AGENTS = ['security-reviewer'];
48
+ /**
49
+ * Review-gate agents whose Codex path is a separately-invoked wrapper, never an
50
+ * in-session persona injection (FR-14a). Refused here by design, not by omission.
51
+ */
52
+ export const CODEX_WRAPPER_ONLY_AGENTS = ['bar-raiser', 'red-team'];
53
+ /**
54
+ * Every agent whose safety-critical property is enforced by a HOOK rather than by
55
+ * tool typing, with the hook that enforces it. Transcribed from the PRD's
56
+ * per-agent safety mechanism table. For each of these, persona injection makes the
57
+ * agent functional, not safe — eligibility exists only once the named mechanism is
58
+ * ported AND verified firing (FR-15).
59
+ */
60
+ export const CODEX_HOOK_GATED_AGENTS = {
61
+ 'git-expert': 'git-mutation-guard',
62
+ 'memory-creator': 'named-memory-write-guard',
63
+ 'dogfood-auditor': 'named-memory-write-guard',
64
+ 'prd-writer': 'worktree-guard',
65
+ };
66
+ /**
67
+ * Decide whether an agent may run under Codex.
68
+ *
69
+ * `provenGuards` is the set of guard mechanisms proven FIRING SELECTIVELY in a live
70
+ * Codex session — the G-7 artifact. It defaults to empty, so with G-7 unpassed the
71
+ * allowlist is empty for every Bash-holding agent, which is exactly what FR-15's
72
+ * test requires. Passing a guard name here is an assertion that the paired
73
+ * negative+positive proof exists for it; config inspection is not proof (FR-9).
74
+ */
75
+ export function checkCodexAgentEligibility(agent, opts = {}) {
76
+ const provenGuards = opts.provenGuards ?? [];
77
+ if (CODEX_HARD_INELIGIBLE_AGENTS.includes(agent)) {
78
+ return {
79
+ eligible: false,
80
+ reason: `${agent} is not available under codex: it requires Bash, and no proven Codex ` +
81
+ `configuration provides Bash, host-scoped read and write-deny at the same time. ` +
82
+ `Run security review in a Claude session.`,
83
+ };
84
+ }
85
+ if (CODEX_WRAPPER_ONLY_AGENTS.includes(agent)) {
86
+ return {
87
+ eligible: false,
88
+ reason: `${agent} is not persona-injected under codex: its Codex path is a separately-invoked ` +
89
+ `read-only wrapper process (FR-14a fast-follow), not an in-session subagent. ` +
90
+ `Run it in a Claude session.`,
91
+ };
92
+ }
93
+ const requiredGuard = CODEX_HOOK_GATED_AGENTS[agent];
94
+ if (requiredGuard) {
95
+ if (!provenGuards.includes(requiredGuard)) {
96
+ return {
97
+ eligible: false,
98
+ reason: `${agent} unavailable under codex: ${requiredGuard} not verified firing`,
99
+ };
100
+ }
101
+ return { eligible: true };
102
+ }
103
+ // Unknown agent → refuse. An agent whose enforcing mechanism nobody has
104
+ // classified cannot be asserted safe, and fail-open here would make the
105
+ // allowlist decorative.
106
+ return {
107
+ eligible: false,
108
+ reason: `${agent} unavailable under codex: no entry in the per-agent safety mechanism table, ` +
109
+ `so its enforcing mechanism is unknown`,
110
+ };
111
+ }
112
+ export class CodexAdapter {
113
+ id = 'codex';
114
+ model;
115
+ projectRoot;
116
+ projectSlug;
117
+ provenGuards;
118
+ constructor(opts) {
119
+ this.model = opts.model ?? CODEX_DEFAULT_MODEL;
120
+ this.projectRoot = opts.projectRoot;
121
+ if (opts.projectSlug)
122
+ this.projectSlug = opts.projectSlug;
123
+ this.provenGuards = opts.provenGuards ?? [];
124
+ }
125
+ /** True once every Phase 1 containment guard has a paired live proof (gate G-7). */
126
+ get guardsProven() {
127
+ return (this.provenGuards.includes('git-mutation-guard') &&
128
+ this.provenGuards.includes('named-memory-write-guard'));
129
+ }
130
+ /**
131
+ * FR-8: refuse when the `codex` binary is missing, with an install hint and a
132
+ * non-zero exit — never a silent Claude fallback, which would hide which runtime
133
+ * actually ran. Also warns (never blocks) on a version the adapter's probes were
134
+ * not run against.
135
+ */
136
+ preflight() {
137
+ const probe = spawnSync('codex', ['--version'], { stdio: 'pipe', encoding: 'utf-8' });
138
+ if (probe.error || probe.status !== 0) {
139
+ throw new Error('codex CLI not found — install via devcontainer or run: npm i -g @openai/codex');
140
+ }
141
+ const version = (probe.stdout || '').trim();
142
+ // EXACT token comparison, mirroring .devcontainer/post-start.sh
143
+ // (`codex --version | tr -d '\r' | awk '{print $NF}'` then `!=`). A substring
144
+ // test accepted every version that merely CONTAINS the pin — `0.145.0-rc1`,
145
+ // `0.145.01`, `10.145.0` — which is the one class of version most likely to
146
+ // differ in the sandbox behaviour the pin exists to fix (security review NEW-7).
147
+ const versionToken = version.replace(/\r/g, '').trim().split(/\s+/).pop() ?? '';
148
+ if (version && versionToken !== VERIFIED_CODEX_VERSION) {
149
+ // REFUSE, do not warn (security review MF3c). Every containment property this
150
+ // adapter relies on — the hooks.json schema, the hook payload shape, the hook
151
+ // trust requirement, the sandbox write boundary, the stdin behaviour — was
152
+ // established by probing ONE version. The 0.142.4 → 0.145.0 sandbox
153
+ // reimplementation is the precedent: it silently removed the containment
154
+ // codex-review.sh depended on, and a warning printed above a scrolling session
155
+ // banner is not a control. Once the guards have a paired live proof on a pinned
156
+ // version (gate G-7) this softens to a warning, because then there is at least
157
+ // a verified baseline to compare against.
158
+ const message = `refusing to launch --runtime codex: codex reports "${version}", but this adapter's ` +
159
+ `hook schema, hook-trust, sandbox and stdin behaviour were probed on ` +
160
+ `${VERIFIED_CODEX_VERSION}. Every guardrail rests on that one version's behaviour. ` +
161
+ `Install the pinned version (npm i -g @openai/codex@${VERIFIED_CODEX_VERSION}) or re-run ` +
162
+ `the probes and update VERIFIED_CODEX_VERSION.`;
163
+ if (!this.guardsProven)
164
+ throw new Error(message);
165
+ console.log(chalk.yellow(` ⚠ ${message}`));
166
+ }
167
+ }
168
+ deployConfig(ctx) {
169
+ const result = deployCodexConfig({
170
+ projectRoot: this.projectRoot,
171
+ worktreePath: ctx.worktreePath,
172
+ worktreeName: ctx.worktreeName,
173
+ branch: ctx.branch,
174
+ slot: ctx.slot,
175
+ teamSlug: ctx.teamName,
176
+ model: this.model,
177
+ provenGuards: this.provenGuards,
178
+ // #4707: the roleguide must be read from the same ref the Claude path uses.
179
+ baseBranch: ctx.baseBranch,
180
+ ...(this.projectSlug ? { projectSlug: this.projectSlug } : {}),
181
+ ...(ctx.gitRemote ? { gitRemote: ctx.gitRemote } : {}),
182
+ });
183
+ for (const file of result.written) {
184
+ console.log(chalk.dim(` Deployed ${file} (codex)`));
185
+ }
186
+ for (const warning of result.warnings) {
187
+ console.log(chalk.yellow(` ⚠ ${warning}`));
188
+ }
189
+ for (const precondition of result.trust) {
190
+ if (!precondition.satisfied) {
191
+ console.log(chalk.yellow(` ⚠ codex hook precondition unmet (${precondition.id}): ${precondition.detail}`));
192
+ }
193
+ }
194
+ // REFUSE over budget, do not warn (security review NEW-4, same reasoning as the
195
+ // version-mismatch refusal above). Codex truncates the instruction file silently
196
+ // at project_doc_max_bytes, so an over-budget session runs on instructions whose
197
+ // tail nobody can see — and the operator's only signal would be one warning line
198
+ // above a scrolling banner.
199
+ if (result.chain.overBudget) {
200
+ throw new Error(`refusing to launch --runtime codex: ${result.chain.readFile} is ${result.chain.bytes} bytes, ` +
201
+ `over the ${result.chain.cap}-byte project_doc_max_bytes. Codex truncates it SILENTLY, so the ` +
202
+ `session would run on instructions with an unknown tail missing. Shrink the instruction file ` +
203
+ `(AGENTS.md and the worktree-local override are folded into one file under codex), or run ` +
204
+ `this team on Claude with \`mx-agent start <team> --runtime claude\`.`);
205
+ }
206
+ }
207
+ /**
208
+ * FR-6: spawn `codex exec -m <model> -C <worktree> <prompt>`.
209
+ *
210
+ * stdin is `'ignore'`, NOT `'inherit'`. `codex exec` waits for stdin EOF when it
211
+ * is not attached to a TTY — a 7m16s hang was reproduced on v0.144.5, and on
212
+ * 0.145.0 the process still prints "Reading additional input from stdin..." even
213
+ * when a prompt argument is present. Inheriting a non-TTY stdin reintroduces the
214
+ * hang, so this must never become `'inherit'`.
215
+ */
216
+ /**
217
+ * The Phase 1 gate, callable before any side effect (security review S7).
218
+ *
219
+ * `runStart` calls this after preflight and BEFORE it persists `.mx-runtime`, so a
220
+ * refused launch leaves no persisted runtime behind — otherwise the next flagless
221
+ * start would resolve `codex` from a file written by a start that never ran, and
222
+ * the operator would have to know to delete it. `launch` calls it again: the
223
+ * refusal must hold even if a future caller forgets this one.
224
+ */
225
+ assertLaunchAllowed(ctx) {
226
+ // PROJECT TRUST FIRST, above the guardsProven early return (security review NEW-2).
227
+ // This refusal must hold post-G-7 too: proving the guards fire says nothing about
228
+ // whether Codex reads the file that registers them. On an untrusted project every
229
+ // project-local artifact this adapter writes is discarded, so the gate cannot sit
230
+ // behind a G-7 shortcut.
231
+ const projectTrust = codexHookTrustPreconditions({ worktreePath: ctx.worktreePath })
232
+ .find((p) => p.id === 'project-trust');
233
+ if (projectTrust && !projectTrust.satisfied) {
234
+ throw new Error('refusing to launch --runtime codex: this project directory is not trusted in the Codex ' +
235
+ 'config, so Codex IGNORES .codex/config.toml entirely. The declared sandbox_mode, the ' +
236
+ 'declared approval_policy and the MemNexus MCP server are NOT in effect, and ' +
237
+ '.codex/hooks.json is inert — the session would run with the operator\'s inherited ' +
238
+ 'settings and no containment guard. ' +
239
+ // The worktree path reaches this message from the filesystem, so it gets the
240
+ // same treatment claude.ts gives the same value (security review NEW-14):
241
+ // control characters in a path must not steer the terminal that prints them.
242
+ `Fix: add [projects."${sanitizeForMessage(ctx.worktreePath)}"] with a trust_level ` +
243
+ `of "trusted" to the Codex config. ` +
244
+ 'Fallback: run this team on Claude with `mx-agent start <team> --runtime claude`.');
245
+ }
246
+ if (this.guardsProven)
247
+ return;
248
+ // Exact string match (security review S1). `!process.env[X]` treated
249
+ // MX_AGENT_CODEX_PHASE1_DEV=0 and =false as "enabled", so an operator who
250
+ // deliberately turned the hatch OFF the obvious way turned it ON.
251
+ if (process.env[CODEX_PHASE1_DEV_ENV] === '1')
252
+ return;
253
+ throw new Error('refusing to launch --runtime codex: Phase 1 gate G-7 is unpassed. ' +
254
+ 'git-mutation-guard and named-memory-write-guard are not yet proven firing selectively ' +
255
+ 'in a live Codex session, so NO guard hook is enforced on Codex. ' +
256
+ `Platform-supervised development runs only: set ${CODEX_PHASE1_DEV_ENV}=1. ` +
257
+ 'To revert this worktree to Claude: `mx-agent start <team> --runtime claude`, ' +
258
+ 'or delete .mx-runtime.');
259
+ }
260
+ async launch(ctx) {
261
+ this.assertLaunchAllowed(ctx);
262
+ const env = {
263
+ ...process.env,
264
+ CLAUDE_WORKTREE_PATH: ctx.worktreePath,
265
+ CLAUDE_WORKTREE_NAME: ctx.worktreeName,
266
+ CLAUDE_WORKTREE_SLOT: String(ctx.slot),
267
+ CLAUDE_WORKTREE_BRANCH: ctx.branch || '',
268
+ CLAUDE_TEAM_NAME: ctx.teamName,
269
+ // Codex-side pointer to the same worktree. The guard scripts read
270
+ // CLAUDE_PROJECT_DIR; set it explicitly because Codex does not.
271
+ CLAUDE_PROJECT_DIR: ctx.worktreePath,
272
+ };
273
+ // The development hatch is NOT transitive (security review S2). Inherited through
274
+ // the spread, it would reach the session, its subagents, and any nested
275
+ // `mx-agent start` they run — so one supervised launch would silently authorize
276
+ // every unsupervised launch underneath it. The operator re-sets it per launch.
277
+ delete env[CODEX_PHASE1_DEV_ENV];
278
+ console.log();
279
+ console.log(chalk.bold(' Starting Codex...'));
280
+ console.log(chalk.dim(' Press Ctrl+C to exit'));
281
+ console.log();
282
+ // Keep the parent alive while the child owns the terminal — same rationale as
283
+ // launchClaudeSession: reproduce spawnSync's signal behaviour.
284
+ const noop = () => { };
285
+ process.on('SIGINT', noop);
286
+ process.on('SIGTERM', noop);
287
+ try {
288
+ const child = spawn('codex', ['exec', '-m', this.model, '-C', ctx.worktreePath, ctx.initialPrompt], {
289
+ cwd: ctx.worktreePath,
290
+ env,
291
+ // stdin ignored on purpose — see the method header (FR-6 stdin hang).
292
+ stdio: ['ignore', 'inherit', 'inherit'],
293
+ });
294
+ if (typeof child.pid === 'number') {
295
+ try {
296
+ updateChildPid(ctx.worktreePath, child.pid);
297
+ }
298
+ catch {
299
+ // Non-fatal — the wrapper pid alone still gates duplicate starts.
300
+ }
301
+ }
302
+ const { code, signal, error } = await new Promise((resolve) => {
303
+ child.once('error', (err) => resolve({ code: null, signal: null, error: err }));
304
+ child.once('exit', (exitCode, exitSignal) => resolve({ code: exitCode, signal: exitSignal }));
305
+ });
306
+ if (error) {
307
+ console.error(chalk.red(`Failed to launch codex: ${error.message}`));
308
+ removeLock(ctx.worktreePath); // process.exit skips finally — clean up explicitly.
309
+ process.exit(1);
310
+ }
311
+ if (signal) {
312
+ const signum = SIGNAL_NUMBERS[signal] ?? 0;
313
+ removeLock(ctx.worktreePath);
314
+ process.exit(signum ? 128 + signum : 1);
315
+ }
316
+ const exitCode = code ?? 0;
317
+ if (exitCode !== 0) {
318
+ removeLock(ctx.worktreePath);
319
+ process.exit(exitCode);
320
+ }
321
+ }
322
+ finally {
323
+ process.removeListener('SIGINT', noop);
324
+ process.removeListener('SIGTERM', noop);
325
+ removeLock(ctx.worktreePath);
326
+ }
327
+ }
328
+ /**
329
+ * Lines the start banner must print for a Codex launch. Each states a declared
330
+ * degradation rather than leaving it implicit (FR-14b, FR-16, PRD Phase 1).
331
+ */
332
+ bannerNotices(ctx) {
333
+ const notices = [
334
+ 'Security review runs on Claude — security-reviewer is refused under codex (FR-14b).',
335
+ 'Bar-raiser and red-team run on Claude — not persona-injected in-session (FR-14a).',
336
+ 'Behavioral markers are session-start-only under codex, not per-turn (FR-16).',
337
+ ];
338
+ // The declared boundary is only a boundary if Codex reads the file declaring it
339
+ // (security review NEW-2). On an untrusted project it reads none of it.
340
+ if (ctx) {
341
+ const projectTrust = codexHookTrustPreconditions({ worktreePath: ctx.worktreePath })
342
+ .find((p) => p.id === 'project-trust');
343
+ if (projectTrust && !projectTrust.satisfied) {
344
+ notices.push(`This project (${sanitizeForMessage(ctx.worktreePath)}) is NOT trusted in the Codex ` +
345
+ 'config, so .codex/config.toml is ignored ' +
346
+ 'entirely: the declared sandbox_mode and approval_policy are NOT in effect, the MemNexus ' +
347
+ 'MCP server is not configured, and .codex/hooks.json is inert.');
348
+ }
349
+ }
350
+ if (!this.guardsProven) {
351
+ notices.push('NO guard hook is proven enforced under codex: git-mutation-guard and ' +
352
+ 'named-memory-write-guard await gate G-7. Trusted-input, platform-supervised work only.');
353
+ }
354
+ return notices;
355
+ }
356
+ }
357
+ //# sourceMappingURL=codex-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-adapter.js","sourceRoot":"","sources":["../../../src/lib/runtime/codex-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B,iFAAiF;AACjF,MAAM,cAAc,GAA4C;IAC9D,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,CAAC;CACV,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAEhE,iFAAiF;AAEjF,yFAAyF;AACzF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,mBAAmB,CAAU,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,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