@memnexus-ai/mx-agent-cli 0.1.265 → 0.1.266

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 (33) hide show
  1. package/dist/__tests__/runtime-codex-adapter.test.js +18 -5
  2. package/dist/__tests__/runtime-codex-adapter.test.js.map +1 -1
  3. package/dist/__tests__/runtime-codex-config.test.js +133 -12
  4. package/dist/__tests__/runtime-codex-config.test.js.map +1 -1
  5. package/dist/__tests__/runtime-codex-guard-proof.test.d.ts +2 -0
  6. package/dist/__tests__/runtime-codex-guard-proof.test.d.ts.map +1 -0
  7. package/dist/__tests__/runtime-codex-guard-proof.test.js +747 -0
  8. package/dist/__tests__/runtime-codex-guard-proof.test.js.map +1 -0
  9. package/dist/__tests__/start-runtime-wiring.test.js +91 -2
  10. package/dist/__tests__/start-runtime-wiring.test.js.map +1 -1
  11. package/dist/commands/codex-prove-guards.d.ts +62 -0
  12. package/dist/commands/codex-prove-guards.d.ts.map +1 -0
  13. package/dist/commands/codex-prove-guards.js +353 -0
  14. package/dist/commands/codex-prove-guards.js.map +1 -0
  15. package/dist/commands/start.d.ts.map +1 -1
  16. package/dist/commands/start.js +27 -1
  17. package/dist/commands/start.js.map +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +33 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/lib/runtime/codex-adapter.d.ts +42 -2
  22. package/dist/lib/runtime/codex-adapter.d.ts.map +1 -1
  23. package/dist/lib/runtime/codex-adapter.js +81 -9
  24. package/dist/lib/runtime/codex-adapter.js.map +1 -1
  25. package/dist/lib/runtime/codex-config.d.ts +53 -4
  26. package/dist/lib/runtime/codex-config.d.ts.map +1 -1
  27. package/dist/lib/runtime/codex-config.js +164 -15
  28. package/dist/lib/runtime/codex-config.js.map +1 -1
  29. package/dist/lib/runtime/codex-guard-proof.d.ts +127 -0
  30. package/dist/lib/runtime/codex-guard-proof.d.ts.map +1 -0
  31. package/dist/lib/runtime/codex-guard-proof.js +372 -0
  32. package/dist/lib/runtime/codex-guard-proof.js.map +1 -0
  33. package/package.json +1 -1
@@ -0,0 +1,372 @@
1
+ /**
2
+ * The G-7 proof artifact — where an EXECUTED guard proof is recorded, and the only
3
+ * thing `CodexAdapter` will accept as evidence that a guard fires (#4864, #4851).
4
+ *
5
+ * ─── WHAT PROBLEM THIS SOLVES ──────────────────────────────────────────────────
6
+ * `commands/start.ts` constructed `CodexAdapter` with no `provenGuards`, so
7
+ * `guardsProven` was permanently false and the only launch path for any team was
8
+ * `MX_AGENT_CODEX_PHASE1_DEV=1` — which by definition enforces no guard hook. The
9
+ * fail-closed posture was right; there was simply no legitimate way out of it,
10
+ * because running the G-7 proofs produced nothing the CLI reads. This file is what
11
+ * the proof writes and what the launch gate reads.
12
+ *
13
+ * ─── THIS IS AN INTEGRITY-OF-PROCESS RECORD, NOT A SECURITY BOUNDARY ───────────
14
+ * Say this before anything else, because an earlier revision of this header did not
15
+ * and the claim it made instead was false. It said `.codex` is read-only-bound by
16
+ * codex-cli, so the contained agent cannot write the record of its own containment.
17
+ * The bind is real, but it does not make this a boundary:
18
+ *
19
+ * - The GUARD SCRIPTS live under `.claude/hooks/`, which is NOT bound. A session
20
+ * can neuter a guard to `exit 0` without touching anything under `.codex`. That
21
+ * is why every observation now carries the sha256 OF THE SCRIPT IT PROVED and the
22
+ * reader re-verifies all of them (#4864 review MF1) — a defence against drift and
23
+ * accident, not against an attacker who can also rewrite this file.
24
+ * - ANY process that can write the worktree from outside a session — the CLI
25
+ * itself, a hook, another agent, a human — can forge this file wholesale. The
26
+ * bind constrains one runtime's own file writes; it is not an access control.
27
+ *
28
+ * So what this buys is that a proof cannot go quietly out of date: change the hooks
29
+ * file, change a guard script, change the CLI, upgrade codex, or lose the trust grant,
30
+ * and the proof reads as void rather than as still-true. Treat it as a record of a
31
+ * process that was carried out, attributable and checkable, and never as evidence that
32
+ * a hostile party did not intervene. Text that reports it must ATTRIBUTE ("per
33
+ * guard-proof.json") rather than assert ("observed refusing"), because the reader of a
34
+ * banner cannot distinguish the two and the difference is the whole point.
35
+ *
36
+ * ─── WHY A FILE, AND WHY THIS FILE ─────────────────────────────────────────────
37
+ * It lives at `<worktree>/.codex/guard-proof.json`, next to the hooks file it is a
38
+ * statement about — the launch gate needs one place to look, and it should be the
39
+ * place the configuration it describes already lives.
40
+ *
41
+ * ─── EVERY WAY THIS READS AS "NOT PROVEN" ──────────────────────────────────────
42
+ * All of these produce an EMPTY proven set, which keeps the launch refusal exactly as
43
+ * it is today. A gate that cannot establish the proof refuses; it never assumes.
44
+ *
45
+ * - artifact absent, unreadable, or not JSON
46
+ * - artifact not an object, wrong `version`, or any field failing strict validation
47
+ * - the artifact, the hooks file, or a guard script is a SYMLINK or any other
48
+ * non-regular file (review SF2). A path that resolves elsewhere is not the file
49
+ * the proof is about, and following it silently is how a check reads the wrong
50
+ * bytes and reports on them as though they were the right ones.
51
+ * - `hooksPath` naming a file other than this worktree's `.codex/hooks.json`
52
+ * - the CURRENT hooks.json is absent or unreadable (nothing to compare against)
53
+ * - **`hooksSha256` not matching the CURRENT hooks.json** — a STALE proof. This is
54
+ * the property that stops a proof of the old configuration authorising the new
55
+ * one: change one byte of the guard wrappers, or of the spawn gate, and the proof
56
+ * is void until it is re-run.
57
+ * - **any `scriptSha256` not matching the guard script on disk** (review MF1). The
58
+ * hooks file only says which script to run; the BEHAVIOUR is in the script, and
59
+ * `.claude/hooks/` is writable from inside a session. Without this, neutering
60
+ * git-mutation-guard.sh to `exit 0` left the proof valid and the banner reporting
61
+ * a guard that no longer refuses anything — demonstrated, not hypothesised.
62
+ * - `codexVersion` other than the compiled pin, OR other than the LIVE
63
+ * `codex --version` the caller observed. A runtime upgrade voids the proof:
64
+ * every containment property here was established by probing one version.
65
+ * - `cliVersion` other than the running CLI (review SF4). The spawn gate's decision
66
+ * lives in the PATH-resolved `mx-agent` binary, not in hooks.json, so a CLI change
67
+ * can alter proven behaviour while every hash in the artifact still matches.
68
+ * - hook trust or project trust no longer satisfied for this worktree. The proof
69
+ * shows the guard command refuses when it is RUN; trust is what decides whether
70
+ * Codex runs it. A proof plus revoked trust is a guard that does not execute.
71
+ *
72
+ * ─── WHAT THE ARTIFACT DOES NOT PROVE ──────────────────────────────────────────
73
+ * Stated here rather than left to be inferred. The proof runs each guard's SHIPPED
74
+ * command out of session (see commands/codex-prove-guards.ts) and observes refusal.
75
+ * It does not observe Codex itself invoking the hook in a live session — that is what
76
+ * the trust preconditions above stand for, and what the manual G-7 run does. And there
77
+ * is deliberately NO expiry: a wall-clock age would need a clock in the reader and
78
+ * would invite treating "recent" as "still true". Binding to the hooks.json hash is
79
+ * the freshness mechanism; `provenAt` is for humans reading the file.
80
+ */
81
+ import { createHash } from 'crypto';
82
+ import { existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
83
+ import { createRequire } from 'module';
84
+ import { dirname, join } from 'path';
85
+ import { fileURLToPath } from 'url';
86
+ import { CODEX_DIR, CODEX_HOOKS_FILENAME, PHASE1_PORTED_GUARDS, VERIFIED_CODEX_VERSION, codexHookTrustPreconditions, } from './codex-config.js';
87
+ /** Location of the artifact, relative to the worktree root. */
88
+ export const GUARD_PROOF_FILENAME = join(CODEX_DIR, 'guard-proof.json');
89
+ /** Schema version. A different value is refused, never best-effort parsed. */
90
+ export const GUARD_PROOF_VERSION = 1;
91
+ /** Guard names the artifact may name — the guard script filenames, minus `.sh`. */
92
+ export const PROVABLE_GUARDS = PHASE1_PORTED_GUARDS.map((s) => s.replace(/\.sh$/, ''));
93
+ /** The running CLI's own version — what the artifact's `cliVersion` is compared against. */
94
+ export function runningCliVersion() {
95
+ try {
96
+ const require = createRequire(import.meta.url);
97
+ const here = dirname(fileURLToPath(import.meta.url));
98
+ const pkg = require(join(here, '..', '..', '..', 'package.json'));
99
+ return pkg.version;
100
+ }
101
+ catch {
102
+ return '0.0.0';
103
+ }
104
+ }
105
+ /**
106
+ * True when `path` is a REGULAR file — not a symlink, directory, fifo or device
107
+ * (review SF2).
108
+ *
109
+ * `lstat`, never `stat`: `stat` follows the link, so a symlinked artifact or hooks
110
+ * file would be hashed through to its target and reported on as though the path
111
+ * itself held those bytes. Every integrity check in this file reads a path it was
112
+ * told about and compares it to a value recorded earlier; if the path can be made to
113
+ * mean a different file between those two moments, the comparison stops meaning
114
+ * anything.
115
+ */
116
+ export function isRegularFile(path) {
117
+ try {
118
+ return lstatSync(path).isFile();
119
+ }
120
+ catch {
121
+ return false;
122
+ }
123
+ }
124
+ /** sha256 of a REGULAR file's bytes, or null when it is absent, non-regular or unreadable. */
125
+ export function fileSha256(path) {
126
+ if (!isRegularFile(path))
127
+ return null;
128
+ try {
129
+ return createHash('sha256').update(readFileSync(path)).digest('hex');
130
+ }
131
+ catch {
132
+ return null;
133
+ }
134
+ }
135
+ const HEX64 = /^[0-9a-f]{64}$/;
136
+ const ISO_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;
137
+ function isObject(value) {
138
+ return !!value && typeof value === 'object' && !Array.isArray(value);
139
+ }
140
+ function validObservation(value) {
141
+ if (!isObject(value))
142
+ return false;
143
+ const { guard, refusedStimulus, refusedExitCode, refusalAttribution, permittedStimulus, permittedExitCode, } = value;
144
+ if (typeof guard !== 'string' || !PROVABLE_GUARDS.includes(guard))
145
+ return false;
146
+ // The script path is DERIVED, not accepted: it must be exactly the guard's own
147
+ // script under `.claude/hooks/`. Accepting an arbitrary relative path would let an
148
+ // artifact point the integrity check at a file nobody runs — a hash that always
149
+ // matches and proves nothing — and an absolute or `..`-bearing path would let it
150
+ // point outside the worktree entirely.
151
+ if (value.scriptPath !== `.claude/hooks/${guard}.sh`)
152
+ return false;
153
+ if (typeof value.scriptSha256 !== 'string' || !HEX64.test(value.scriptSha256))
154
+ return false;
155
+ if (typeof refusedStimulus !== 'string' || refusedStimulus.trim() === '')
156
+ return false;
157
+ if (typeof permittedStimulus !== 'string' || permittedStimulus.trim() === '')
158
+ return false;
159
+ // The two halves of the pair, each pinned to the only value that means what it says.
160
+ // Exit 2 is Codex's block contract; exit 0 on the permitted op is what distinguishes a
161
+ // working guard from one that refuses everything (#4851: both halves are required).
162
+ if (refusedExitCode !== 2 || permittedExitCode !== 0)
163
+ return false;
164
+ if (typeof refusalAttribution !== 'string' || refusalAttribution.trim() === '')
165
+ return false;
166
+ if (value.stubbedDependency !== undefined &&
167
+ (typeof value.stubbedDependency !== 'string' || value.stubbedDependency.trim() === '')) {
168
+ return false;
169
+ }
170
+ return true;
171
+ }
172
+ function validSpawnGate(value) {
173
+ if (!isObject(value))
174
+ return false;
175
+ if (value.refusedExitCode !== 2)
176
+ return false;
177
+ if (value.unrelatedToolExitCode !== 0)
178
+ return false;
179
+ return typeof value.refusalAttribution === 'string' && value.refusalAttribution.trim() !== '';
180
+ }
181
+ /**
182
+ * Strictly validate a parsed artifact. Returns the reason it is invalid, or null when
183
+ * it is well-formed. Shape only — the hash and trust comparisons are the reader's.
184
+ */
185
+ export function validateGuardProofShape(value) {
186
+ if (!isObject(value))
187
+ return 'the artifact is not a JSON object';
188
+ if (value.version !== GUARD_PROOF_VERSION) {
189
+ return `unsupported version ${JSON.stringify(value.version)} (expected ${GUARD_PROOF_VERSION})`;
190
+ }
191
+ if (typeof value.hooksPath !== 'string' || value.hooksPath.trim() === '') {
192
+ return 'hooksPath is missing or not a string';
193
+ }
194
+ if (typeof value.hooksSha256 !== 'string' || !HEX64.test(value.hooksSha256)) {
195
+ return 'hooksSha256 is not a 64-character lowercase hex sha256';
196
+ }
197
+ if (typeof value.provenAt !== 'string' || !ISO_UTC.test(value.provenAt)) {
198
+ return 'provenAt is not an ISO-8601 UTC timestamp';
199
+ }
200
+ if (typeof value.codexVersion !== 'string' || value.codexVersion.trim() === '') {
201
+ return 'codexVersion is missing or not a string';
202
+ }
203
+ if (typeof value.cliVersion !== 'string' || value.cliVersion.trim() === '') {
204
+ return 'cliVersion is missing or not a string';
205
+ }
206
+ if (!Array.isArray(value.guards) || value.guards.length === 0) {
207
+ return 'guards is missing, not an array, or empty';
208
+ }
209
+ // Any malformed entry voids the WHOLE artifact rather than being skipped. Skipping
210
+ // would let a hand-edited file mix one real observation with junk and still be read
211
+ // as partially valid, which is how a strict schema becomes a permissive one.
212
+ for (const entry of value.guards) {
213
+ if (!validObservation(entry))
214
+ return 'a guards[] entry failed validation';
215
+ }
216
+ const names = value.guards.map((g) => g.guard);
217
+ if (new Set(names).size !== names.length)
218
+ return 'guards[] names are not unique';
219
+ if (!validSpawnGate(value.spawnGate))
220
+ return 'spawnGate is missing or failed validation';
221
+ return null;
222
+ }
223
+ /**
224
+ * Read the proof artifact for a worktree and report which guards it establishes NOW.
225
+ *
226
+ * Pure of side effects and of clocks. Every failure path returns an empty proven set —
227
+ * see the header for the list and why each one is fatal rather than advisory.
228
+ */
229
+ export function readGuardProof(opts) {
230
+ const none = (detail) => ({ provenGuards: [], valid: false, detail });
231
+ const artifactPath = join(opts.worktreePath, GUARD_PROOF_FILENAME);
232
+ const hooksPath = join(opts.worktreePath, CODEX_HOOKS_FILENAME);
233
+ if (existsSync(artifactPath) && !isRegularFile(artifactPath)) {
234
+ return none(`${GUARD_PROOF_FILENAME} is not a regular file (symlink, directory or device) — refusing ` +
235
+ 'to read a proof through a path that can be made to mean a different file.');
236
+ }
237
+ let raw;
238
+ try {
239
+ raw = readFileSync(artifactPath, 'utf-8');
240
+ }
241
+ catch {
242
+ return none(`No G-7 proof artifact at ${GUARD_PROOF_FILENAME} — no guard is proven. ` +
243
+ 'Run `mx-agent codex prove-guards` to produce one.');
244
+ }
245
+ let parsed;
246
+ try {
247
+ parsed = JSON.parse(raw);
248
+ }
249
+ catch {
250
+ return none(`${GUARD_PROOF_FILENAME} is not valid JSON — treated as no proof at all.`);
251
+ }
252
+ const shapeError = validateGuardProofShape(parsed);
253
+ if (shapeError)
254
+ return none(`${GUARD_PROOF_FILENAME} is malformed: ${shapeError}. No guard is proven.`);
255
+ const artifact = parsed;
256
+ if (artifact.hooksPath !== hooksPath) {
257
+ return none(`${GUARD_PROOF_FILENAME} records a proof of ${artifact.hooksPath}, not this worktree's ` +
258
+ `${hooksPath}. A proof of another worktree's hooks file proves nothing here.`);
259
+ }
260
+ const expectedVersion = opts.expectedCodexVersion ?? VERIFIED_CODEX_VERSION;
261
+ if (artifact.codexVersion !== expectedVersion) {
262
+ return none(`${GUARD_PROOF_FILENAME} was produced against codex ${artifact.codexVersion}, but this ` +
263
+ `adapter is pinned to ${expectedVersion}. Re-run \`mx-agent codex prove-guards\`.`);
264
+ }
265
+ // The LIVE token, not only the pin (review MF3). The pin can be right while the
266
+ // binary on this machine is a different build — which is the case the pin exists to
267
+ // catch, and the one a compile-time comparison cannot see.
268
+ if (opts.liveCodexVersion !== undefined && artifact.codexVersion !== opts.liveCodexVersion) {
269
+ return none(`${GUARD_PROOF_FILENAME} was produced against codex ${artifact.codexVersion}, but the ` +
270
+ `codex binary on PATH reports ${opts.liveCodexVersion}. Every containment property this ` +
271
+ 'proof rests on was established on the proven version. Re-run `mx-agent codex prove-guards`.');
272
+ }
273
+ const expectedCli = opts.expectedCliVersion ?? runningCliVersion();
274
+ if (artifact.cliVersion !== expectedCli) {
275
+ return none(`${GUARD_PROOF_FILENAME} was produced by mx-agent ${artifact.cliVersion}, but ${expectedCli} ` +
276
+ 'is running. The spawn gate\'s decision lives in the mx-agent binary rather than in ' +
277
+ `${CODEX_HOOKS_FILENAME}, so a CLI change can alter proven behaviour with every recorded ` +
278
+ 'hash still matching. Re-run `mx-agent codex prove-guards`.');
279
+ }
280
+ const currentSha = fileSha256(hooksPath);
281
+ if (currentSha === null) {
282
+ return none(`Cannot read ${CODEX_HOOKS_FILENAME} to compare against the proof — with nothing to ` +
283
+ 'compare, nothing is proven.');
284
+ }
285
+ if (currentSha !== artifact.hooksSha256) {
286
+ return none(`STALE PROOF: ${GUARD_PROOF_FILENAME} was proven against ${CODEX_HOOKS_FILENAME} ` +
287
+ `sha256 ${artifact.hooksSha256.slice(0, 12)}…, but the file on disk is ` +
288
+ `${currentSha.slice(0, 12)}…. The configuration changed after the proof, so the proof ` +
289
+ 'is void. Re-run `mx-agent codex prove-guards`.');
290
+ }
291
+ // ── THE GUARD SCRIPTS THEMSELVES (review MF1) ────────────────────────────────
292
+ // hooks.json names the script; the script is the behaviour. `.claude/hooks/` is
293
+ // writable from inside a Codex session — the runtime read-only-binds `.git`,
294
+ // `.agents` and `.codex`, and nothing else — so a session can rewrite a guard to
295
+ // `exit 0` without touching one byte of the file the hash above covers. Proven:
296
+ // neutering git-mutation-guard.sh left the proof valid and the banner still
297
+ // reporting a guard that refused nothing.
298
+ for (const observation of artifact.guards) {
299
+ const scriptPath = join(opts.worktreePath, observation.scriptPath);
300
+ const scriptSha = fileSha256(scriptPath);
301
+ if (scriptSha === null) {
302
+ return none(`STALE PROOF: the guard script ${observation.scriptPath} proven for ` +
303
+ `${observation.guard} is missing, unreadable, or not a regular file. A proof of a ` +
304
+ 'script that is not there is not a proof. Re-run `mx-agent codex prove-guards`.');
305
+ }
306
+ if (scriptSha !== observation.scriptSha256) {
307
+ return none(`STALE PROOF: the guard script ${observation.scriptPath} CHANGED since ` +
308
+ `${observation.guard} was proven (recorded ${observation.scriptSha256.slice(0, 12)}…, ` +
309
+ `on disk ${scriptSha.slice(0, 12)}…). The proof describes behaviour this script no ` +
310
+ 'longer necessarily has. Re-run `mx-agent codex prove-guards`.');
311
+ }
312
+ }
313
+ const trust = codexHookTrustPreconditions({
314
+ worktreePath: opts.worktreePath,
315
+ ...(opts.codexHome ? { codexHome: opts.codexHome } : {}),
316
+ });
317
+ const unmet = trust.filter((t) => !t.satisfied);
318
+ if (unmet.length > 0) {
319
+ return none(`The proof in ${GUARD_PROOF_FILENAME} is current, but Codex would not RUN these hooks: ` +
320
+ `${unmet.map((t) => t.id).join(', ')} unsatisfied. ${unmet.map((t) => t.detail).join(' ')}`);
321
+ }
322
+ const provenGuards = artifact.guards.map((g) => g.guard);
323
+ // ATTRIBUTED, NOT ASSERTED (review SF1). "observed refusing" reads as this process
324
+ // having watched the refusal; what this line can honestly say is that a file in the
325
+ // worktree records that observation and still matches everything it was bound to.
326
+ // Any process that can write the worktree can write that file, so the wording has to
327
+ // carry the source rather than swallow it.
328
+ const stubbed = artifact.guards.filter((g) => g.stubbedDependency);
329
+ const stubNote = stubbed.length
330
+ ? ` WEAKER PROOF for ${stubbed.map((g) => g.guard).join(', ')}: a live dependency was ` +
331
+ `replaced by a deterministic stand-in during the proof (${stubbed
332
+ .map((g) => `${g.guard} → ${g.stubbedDependency}`)
333
+ .join('; ')}).`
334
+ : '';
335
+ return {
336
+ provenGuards,
337
+ valid: true,
338
+ detail: `Per ${GUARD_PROOF_FILENAME} (an integrity-of-process record, not a security ` +
339
+ `boundary): ${provenGuards.join(', ')} were recorded refusing and allowing at ` +
340
+ `${artifact.provenAt}, and the record still matches ${CODEX_HOOKS_FILENAME} ` +
341
+ `sha256 ${artifact.hooksSha256.slice(0, 12)}…, each guard script, codex ` +
342
+ `${artifact.codexVersion} and mx-agent ${artifact.cliVersion}.${stubNote}`,
343
+ };
344
+ }
345
+ /** Serialize an artifact exactly as it is written to disk. */
346
+ export function serializeGuardProof(artifact) {
347
+ return `${JSON.stringify(artifact, null, 2)}\n`;
348
+ }
349
+ /**
350
+ * Write the artifact. Refuses to write anything that would not read back as valid —
351
+ * a writer that can emit an artifact its own reader rejects is a way to produce
352
+ * confusing failures later, and a way to smuggle a shape past validation now.
353
+ */
354
+ export function writeGuardProof(opts) {
355
+ const shapeError = validateGuardProofShape(opts.artifact);
356
+ if (shapeError) {
357
+ throw new Error(`refusing to write an invalid G-7 proof artifact: ${shapeError}`);
358
+ }
359
+ const path = join(opts.worktreePath, GUARD_PROOF_FILENAME);
360
+ // Never write THROUGH a symlink (review SF2): the reader refuses to read one, so
361
+ // writing one would produce an artifact that can never be read back, and writing to
362
+ // its target would put the proof somewhere nobody looks while reporting success.
363
+ if (existsSync(path) && !isRegularFile(path)) {
364
+ throw new Error(`refusing to write the G-7 proof artifact: ${GUARD_PROOF_FILENAME} exists and is not a ` +
365
+ 'regular file (symlink, directory or device).');
366
+ }
367
+ if (!existsSync(dirname(path)))
368
+ mkdirSync(dirname(path), { recursive: true });
369
+ writeFileSync(path, serializeGuardProof(opts.artifact));
370
+ return path;
371
+ }
372
+ //# sourceMappingURL=codex-guard-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-guard-proof.js","sourceRoot":"","sources":["../../../src/lib/runtime/codex-guard-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAExE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,mFAAmF;AACnF,MAAM,CAAC,MAAM,eAAe,GAAsB,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/E,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CACvB,CAAC;AAEF,4FAA4F;AAC5F,MAAM,UAAU,iBAAiB;IAC/B,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;AACJ,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,mBAAmB,CAAC,QAA4B;IAC9D,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAG/B;IACC,MAAM,UAAU,GAAG,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,oDAAoD,UAAU,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAC3D,iFAAiF;IACjF,oFAAoF;IACpF,iFAAiF;IACjF,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CACb,6CAA6C,oBAAoB,uBAAuB;YACxF,8CAA8C,CAC/C,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9E,aAAa,CAAC,IAAI,EAAE,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memnexus-ai/mx-agent-cli",
3
- "version": "0.1.265",
3
+ "version": "0.1.266",
4
4
  "description": "CLI for creating and managing AI agent teams",
5
5
  "type": "module",
6
6
  "bin": {