@oathe/oathe 0.4.3 → 0.4.5
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.
- package/.claude-plugin/marketplace.json +18 -2
- package/README.md +4 -1
- package/bin/oathe.mjs +206 -34
- package/docs/PRIVACY.md +26 -4
- package/notch/Oathe Notch.app/Contents/Info.plist +1 -1
- package/notch/Oathe Notch.app/Contents/MacOS/OatheNotch +0 -0
- package/notch/README.md +4 -3
- package/package.json +3 -3
- package/plugin/.claude-plugin/plugin.json +21 -3
- package/plugin/.cursor-plugin/plugin.json +2 -2
- package/plugin/hooks/hooks.json +4 -4
- package/plugin/hooks/lib.mjs +9 -0
- package/plugin/hooks/render-board.mjs +4 -2
- package/src/blocks.mjs +10 -1
- package/src/board-render.mjs +7 -4
- package/src/breach-digest.mjs +75 -10
- package/src/config.mjs +24 -0
- package/src/context.mjs +1 -1
- package/src/device.mjs +106 -0
- package/src/doctor.mjs +110 -9
- package/src/engine-update.mjs +170 -0
- package/src/evidence-discovery.mjs +170 -0
- package/src/fence.mjs +3 -3
- package/src/harnesses/catalog.mjs +46 -4
- package/src/harnesses/claude.mjs +56 -4
- package/src/harnesses/codex-rollout.mjs +110 -21
- package/src/harnesses/codex.mjs +107 -20
- package/src/harnesses/cursor.mjs +31 -18
- package/src/harnesses/harness.mjs +82 -13
- package/src/harnesses/surfaces.mjs +2 -2
- package/src/home.mjs +174 -52
- package/src/init.mjs +27 -2
- package/src/launch.mjs +7 -9
- package/src/launchd.mjs +100 -0
- package/src/manifest.mjs +48 -6
- package/src/mcp/connection.mjs +73 -7
- package/src/mcp/daemon.mjs +123 -0
- package/src/mcp/forwarder.mjs +99 -0
- package/src/mcp/oathe-tools.mjs +392 -145
- package/src/notch-frame.mjs +118 -42
- package/src/notch.mjs +44 -41
- package/src/oathe-annotator.mjs +10 -10
- package/src/pager.mjs +144 -40
- package/src/paths.mjs +1 -0
- package/src/plans.mjs +44 -5
- package/src/registry.mjs +10 -2
- package/src/serve.mjs +82 -0
- package/src/session-host.mjs +1 -1
- package/src/sessions.mjs +39 -8
- package/src/shim.mjs +110 -0
- package/src/speaker.mjs +24 -5
- package/src/statements.mjs +116 -2
- package/src/traces.mjs +61 -19
- package/src/uninstall.mjs +20 -3
- package/src/update.mjs +48 -4
- package/src/verifier.mjs +215 -105
- package/src/verify-dispatch.mjs +86 -32
- package/src/wire.mjs +7 -1
- package/plugin/.mcp.json +0 -10
package/src/harnesses/claude.mjs
CHANGED
|
@@ -18,6 +18,7 @@ const claudeToolUses = (entries) => entries
|
|
|
18
18
|
.flatMap((r) => r.message.content.filter((p) => p.type === 'tool_use'));
|
|
19
19
|
import { JsonEntries } from '../blocks.mjs';
|
|
20
20
|
import { sha256Hex } from '../manifest.mjs';
|
|
21
|
+
import { shimPath } from '../shim.mjs';
|
|
21
22
|
|
|
22
23
|
export class ClaudeHarness extends Harness {
|
|
23
24
|
static harnessName = 'claude';
|
|
@@ -37,13 +38,24 @@ export class ClaudeHarness extends Harness {
|
|
|
37
38
|
static surfaces = Object.freeze({
|
|
38
39
|
ownsExec: (exec) => path.basename(exec) === 'claude',
|
|
39
40
|
name: () => 'claude',
|
|
41
|
+
display: Object.freeze({ claude: 'Claude Code' }),
|
|
42
|
+
resumable: Object.freeze([]), // a folder's session — the folder is the place, never the terminal
|
|
40
43
|
});
|
|
41
|
-
static
|
|
44
|
+
static attestation = Object.freeze({ claude: 'hooks' });
|
|
45
|
+
// The blocking exchange needs no budget written here: Claude Code's per-tool wall clock
|
|
46
|
+
// defaults to about 28 hours (claude-code/mcp.md, pinned) and a stdio call is only aborted
|
|
47
|
+
// after 30 idle minutes — the wait's progress ticks reset that clock. What Claude Code DOES
|
|
48
|
+
// do is move a call past two minutes to a background task and deliver the verdict as its
|
|
49
|
+
// notification; that is the client's behaviour, disclosed on oathe_done, not a knob here.
|
|
50
|
+
static mcpToolTimeout = null;
|
|
51
|
+
// `claude update` — Claude Code's own in-place updater (claude-code docs, pinned).
|
|
52
|
+
static install = Object.freeze({ npm: '@anthropic-ai/claude-code', bin: 'claude', versionArgs: ['--version'], update: (address) => [address, ['update']] });
|
|
42
53
|
// Non-interactive auth: ANTHROPIC_API_KEY (claude-code/headless.md, pinned 2026-08-29).
|
|
43
54
|
static headless = Object.freeze({
|
|
44
55
|
auth: ['ANTHROPIC_API_KEY'],
|
|
45
56
|
command: (prompt, model = null) => ['claude', ['-p', prompt, '--output-format', 'json', ...(model ? ['--model', model] : [])]],
|
|
46
57
|
extract: (stdout) => ClaudeHarness.extractJsonResult(stdout),
|
|
58
|
+
diagnose: () => null, // its failure words are unmeasured — stated; an unrecognized death stays a plain stall
|
|
47
59
|
});
|
|
48
60
|
static traces = Object.freeze({
|
|
49
61
|
store: ({ home } = {}) => new ClaudeTraceStore({ home, harness: this.harnessName }),
|
|
@@ -106,6 +118,11 @@ export class ClaudeHarness extends Harness {
|
|
|
106
118
|
];
|
|
107
119
|
}
|
|
108
120
|
|
|
121
|
+
/** Where the CLI's user scope lives — sign-in state, per-project state, and user MCP entries. */
|
|
122
|
+
get userConfigPath() {
|
|
123
|
+
return path.join(this.home, '.claude.json');
|
|
124
|
+
}
|
|
125
|
+
|
|
109
126
|
get registryDir() {
|
|
110
127
|
return path.join(this.configHome, 'plugins');
|
|
111
128
|
}
|
|
@@ -140,11 +157,17 @@ export class ClaudeHarness extends Harness {
|
|
|
140
157
|
return result;
|
|
141
158
|
}
|
|
142
159
|
|
|
160
|
+
/** The user-scope MCP entry as the CLI's file records it, or null. */
|
|
161
|
+
#mcpEntry() {
|
|
162
|
+
return this.#readRegistry(this.userConfigPath)?.mcpServers?.oathe ?? null;
|
|
163
|
+
}
|
|
164
|
+
|
|
143
165
|
/** What init writes — from the owned entries and the registry the CLI materializes into. */
|
|
144
166
|
describe() {
|
|
145
167
|
return [
|
|
146
168
|
`${this.settingsPath}: owns ${this.#ownedEntries().map((e) => e.path.join('.')).join(' and ')}`,
|
|
147
|
-
`\`claude plugin install oathe@oathe\` — the Oathe plugin (board at session start, auto-save hooks
|
|
169
|
+
`\`claude plugin install oathe@oathe\` — the Oathe plugin (board at session start, auto-save hooks), recorded in ${this.installedFile}`,
|
|
170
|
+
`${this.userConfigPath}: mcpServers.oathe → ${shimPath(this.home)} mcp (user scope, via \`claude mcp add\` — the oathe_* tools in every session, GUI-launched included)`,
|
|
148
171
|
];
|
|
149
172
|
}
|
|
150
173
|
|
|
@@ -198,20 +221,49 @@ export class ClaudeHarness extends Harness {
|
|
|
198
221
|
kind: 'cli-managed',
|
|
199
222
|
detail: {
|
|
200
223
|
id: 'plugin-install',
|
|
201
|
-
|
|
224
|
+
proofs: ['oathe@oathe'],
|
|
202
225
|
undo: [['plugin', 'uninstall', 'oathe@oathe'], ['plugin', 'marketplace', 'remove', 'oathe']],
|
|
203
226
|
},
|
|
204
227
|
blockVersion: version,
|
|
205
228
|
sha256: sha256Hex('oathe@oathe'),
|
|
206
229
|
});
|
|
230
|
+
|
|
231
|
+
// THE CONNECTION IS AN ADDRESS, not plugin cargo (connection-lane plan, 2026-09-04): the
|
|
232
|
+
// plugin is cached by copy and can never carry a machine path, so its bare `oathe` server
|
|
233
|
+
// died on every GUI PATH. The user-scope entry the CLI writes into ~/.claude.json points
|
|
234
|
+
// at the shim; a stale entry (bare, or an older address) is removed and re-added.
|
|
235
|
+
const shim = shimPath(this.home);
|
|
236
|
+
const entry = this.#mcpEntry();
|
|
237
|
+
const mcpCurrent = entry !== null && entry.command === shim
|
|
238
|
+
&& JSON.stringify(entry.args ?? []) === JSON.stringify(['mcp']);
|
|
239
|
+
if (!mcpCurrent) {
|
|
240
|
+
manifest.backupOnce(this.userConfigPath);
|
|
241
|
+
if (entry !== null) this.#cli(['mcp', 'remove', 'oathe', '-s', 'user']);
|
|
242
|
+
this.#cli(['mcp', 'add', '-s', 'user', 'oathe', '--', shim, 'mcp']);
|
|
243
|
+
if (this.#mcpEntry()?.command !== shim) {
|
|
244
|
+
throw new HarnessOnboardError('CLAUDE_VERIFICATION_FAILED',
|
|
245
|
+
'verification failed: `claude mcp add` reported success but '
|
|
246
|
+
+ `${this.userConfigPath} does not carry the shim-addressed oathe entry — refusing `
|
|
247
|
+
+ 'to record an install that cannot be proven');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
manifest.upsert({
|
|
251
|
+
harness: this.name,
|
|
252
|
+
file: this.userConfigPath,
|
|
253
|
+
kind: 'cli-managed',
|
|
254
|
+
detail: { id: 'mcp-server', command: shim, undo: [['mcp', 'remove', 'oathe', '-s', 'user']] },
|
|
255
|
+
blockVersion: version,
|
|
256
|
+
sha256: sha256Hex(shim),
|
|
257
|
+
});
|
|
207
258
|
return [
|
|
208
259
|
{ action: 'settings-owned-paths', file: this.settingsPath, changed },
|
|
209
260
|
{ action: materialized ? 'plugin-installed' : 'plugin-already-current', file: this.installedFile },
|
|
261
|
+
{ action: mcpCurrent ? 'mcp-already-current' : 'mcp-user-entry', file: this.userConfigPath },
|
|
210
262
|
];
|
|
211
263
|
}
|
|
212
264
|
|
|
213
265
|
offboard({ manifest }) {
|
|
214
|
-
const rows =
|
|
266
|
+
const rows = this.takeWiringRows(manifest);
|
|
215
267
|
const actions = [];
|
|
216
268
|
for (const row of rows.filter((r) => r.kind === 'cli-managed')) {
|
|
217
269
|
for (const undo of row.detail?.undo ?? []) {
|
|
@@ -55,11 +55,47 @@ export class ExecCallReader {
|
|
|
55
55
|
while ((match = opener.exec(src))) {
|
|
56
56
|
const argText = this.#balanced(src, opener.lastIndex - 1);
|
|
57
57
|
if (argText === null) continue;
|
|
58
|
-
|
|
58
|
+
const args = this.#parseArgs(argText);
|
|
59
|
+
// A literal that is not pure data (a variable, a template) still STATES its string
|
|
60
|
+
// fields — task_id, proposition — and the record names them, never the rest.
|
|
61
|
+
calls.push({ tool: match[1], args, ...(args === null ? { literals: this.#literalFields(argText) } : {}) });
|
|
59
62
|
}
|
|
60
63
|
return calls;
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The top-level `key: "string"` fields of an object literal that is not pure data — the
|
|
68
|
+
* fields the source states outright. Nothing is invented: a value that is not a string
|
|
69
|
+
* literal (a variable, a call, a nested literal) is left out.
|
|
70
|
+
* @returns {object|null} the fields, or null when none are stated
|
|
71
|
+
*/
|
|
72
|
+
#literalFields(argText) {
|
|
73
|
+
const text = this.#quoteBareKeys(argText.trim());
|
|
74
|
+
const body = text.startsWith('{') && text.endsWith('}') ? text.slice(1, -1) : text;
|
|
75
|
+
const fields = {};
|
|
76
|
+
const pair = /"([^"\\]+)"\s*:\s*("(?:[^"\\]|\\.)*")/g;
|
|
77
|
+
let depth = 0;
|
|
78
|
+
let inString = null;
|
|
79
|
+
let from = 0;
|
|
80
|
+
const takePair = (chunk) => {
|
|
81
|
+
pair.lastIndex = 0;
|
|
82
|
+
const m = pair.exec(chunk.trim());
|
|
83
|
+
if (m && m.index === 0) {
|
|
84
|
+
try { fields[m[1]] = JSON.parse(m[2]); } catch { /* not a string literal after all */ }
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
for (let i = 0; i < body.length; i += 1) {
|
|
88
|
+
const ch = body[i];
|
|
89
|
+
if (inString) { if (ch === '\\') i += 1; else if (ch === inString) inString = null; continue; }
|
|
90
|
+
if (ch === '"' || ch === "'" || ch === '`') { inString = ch; continue; }
|
|
91
|
+
if (ch === '{' || ch === '[' || ch === '(') depth += 1;
|
|
92
|
+
else if (ch === '}' || ch === ']' || ch === ')') depth -= 1;
|
|
93
|
+
else if (ch === ',' && depth === 0) { takePair(body.slice(from, i)); from = i + 1; }
|
|
94
|
+
}
|
|
95
|
+
takePair(body.slice(from));
|
|
96
|
+
return Object.keys(fields).length > 0 ? fields : null;
|
|
97
|
+
}
|
|
98
|
+
|
|
63
99
|
/** The text between the paren at `openAt` and its balanced closer — string-aware. */
|
|
64
100
|
#balanced(src, openAt) {
|
|
65
101
|
let depth = 0;
|
|
@@ -117,6 +153,11 @@ export class ExecCallReader {
|
|
|
117
153
|
}
|
|
118
154
|
}
|
|
119
155
|
|
|
156
|
+
/** The inner tools whose item is a CommandExecution — what a ledger entry named `exec_command` completes to. */
|
|
157
|
+
const COMMAND_TOOLS = new Set(['exec_command', 'write_stdin']);
|
|
158
|
+
/** Code mode names an MCP act `mcp__<server>__<tool>` — the McpToolCall item completes it. */
|
|
159
|
+
const MCP_PREFIX = 'mcp__';
|
|
160
|
+
|
|
120
161
|
export class CodexAtifProjector extends AtifProjector {
|
|
121
162
|
#execReader = new ExecCallReader();
|
|
122
163
|
|
|
@@ -307,12 +348,25 @@ export class CodexAtifProjector extends AtifProjector {
|
|
|
307
348
|
* `inner` is how many calls an exec source names (the reader's count): one may be recovered
|
|
308
349
|
* from its item, several stay one exec whose record lists what ran inside.
|
|
309
350
|
*/
|
|
310
|
-
#pushCall(step, call, { inner = 1 } = {}) {
|
|
351
|
+
#pushCall(step, call, { inner = 1, executions = [] } = {}) {
|
|
311
352
|
step.tool_calls = [...(step.tool_calls ?? []), call];
|
|
312
|
-
|
|
353
|
+
const entry = { call, turn: this.turnId, inner, enrich: null, executions };
|
|
354
|
+
if (executions.length > 0) this.#ledger(entry);
|
|
355
|
+
this.awaiting.push(entry);
|
|
313
356
|
this.callsById.set(call.tool_call_id, call);
|
|
314
357
|
}
|
|
315
358
|
|
|
359
|
+
/**
|
|
360
|
+
* What ran INSIDE a call belongs to the call and is on the record the moment it is known
|
|
361
|
+
* (ruling 2026-09-04): the source names the inner calls at call-start; the items complete
|
|
362
|
+
* them. One array, shared by the entry and the call — a completion is visible at once, and
|
|
363
|
+
* a call whose cell is still running (a blocking done inside it) already shows its acts.
|
|
364
|
+
*/
|
|
365
|
+
#ledger(entry) {
|
|
366
|
+
entry.call.extra = { ...(entry.call.extra ?? {}), record: { ...(entry.call.extra?.record ?? {}), executions: entry.executions } };
|
|
367
|
+
return entry.executions;
|
|
368
|
+
}
|
|
369
|
+
|
|
316
370
|
/**
|
|
317
371
|
* The output answers the call; whatever the items decoded meanwhile rides the result
|
|
318
372
|
* (extra.record), and the call stays reachable for a command that outlives it.
|
|
@@ -337,16 +391,40 @@ export class CodexAtifProjector extends AtifProjector {
|
|
|
337
391
|
* Rebuilt whole each time, so a late completion never leaves a stale single exit code.
|
|
338
392
|
*/
|
|
339
393
|
#stampResult(entry) {
|
|
394
|
+
// Outcomes on the result: exactly one command → its exit_code, plus whatever an item
|
|
395
|
+
// enriched (files_changed). The ledger of what ran is the CALL's (#ledger).
|
|
340
396
|
const record = { ...(entry.enrich ?? {}) };
|
|
341
397
|
const [only] = entry.executions;
|
|
342
|
-
if (entry.executions.length === 1 && 'command' in only) {
|
|
343
|
-
|
|
344
|
-
} else if (entry.executions.length > 0) {
|
|
345
|
-
record.executions = entry.executions;
|
|
398
|
+
if (entry.executions.length === 1 && only && 'command' in only && Number.isInteger(only.exit_code)) {
|
|
399
|
+
record.exit_code = only.exit_code;
|
|
346
400
|
}
|
|
347
401
|
if (Object.keys(record).length > 0) entry.result.extra = { ...(entry.result.extra ?? {}), record };
|
|
348
402
|
}
|
|
349
403
|
|
|
404
|
+
/** The next ledger entry still awaiting its item that `accepts`, else null. */
|
|
405
|
+
#pending(entry, accepts) {
|
|
406
|
+
return entry.executions.find((ran) => ran.pending === true && accepts(ran)) ?? null;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Whether an item will complete an inner call's ledger entry: commands (CommandExecution) and MCP acts (McpToolCall). */
|
|
410
|
+
#expectsItem(tool) {
|
|
411
|
+
return COMMAND_TOOLS.has(tool) || tool.startsWith(MCP_PREFIX);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* An item completes the entry the source named for it — or, when the source named none, is
|
|
416
|
+
* appended. The ledger rides the call only when there is genuinely more than one thing inside
|
|
417
|
+
* it (the source names several, or the items reveal several): one command IS the call, and
|
|
418
|
+
* its exit code is the result's.
|
|
419
|
+
*/
|
|
420
|
+
#complete(entry, accepts, fields) {
|
|
421
|
+
const slot = this.#pending(entry, accepts);
|
|
422
|
+
const done = slot ? Object.assign(slot, fields) : { ...fields };
|
|
423
|
+
if (slot) delete slot.pending; else entry.executions.push(done);
|
|
424
|
+
if (entry.inner > 1 || entry.executions.length > 1) this.#ledger(entry);
|
|
425
|
+
return done;
|
|
426
|
+
}
|
|
427
|
+
|
|
350
428
|
/** The most recent call in the current turn still awaiting its output that `matches`. */
|
|
351
429
|
#completing(matches) {
|
|
352
430
|
for (let i = this.awaiting.length - 1; i >= 0; i -= 1) {
|
|
@@ -391,12 +469,13 @@ export class CodexAtifProjector extends AtifProjector {
|
|
|
391
469
|
const tail = Array.isArray(item.command) ? item.command.at(-1) : undefined;
|
|
392
470
|
const entry = this.#commandHome(tail);
|
|
393
471
|
if (!entry) return this.#uncorrelated(item);
|
|
394
|
-
entry
|
|
472
|
+
this.#complete(entry, (ran) => COMMAND_TOOLS.has(ran.tool),
|
|
473
|
+
{ command: tail, ...(Number.isInteger(item.exit_code) ? { exit_code: item.exit_code } : {}) });
|
|
395
474
|
if (entry.result) this.#stampResult(entry); // a late completion lands on the answered call
|
|
396
475
|
return;
|
|
397
476
|
}
|
|
398
477
|
case 'McpToolCall': {
|
|
399
|
-
const name =
|
|
478
|
+
const name = `${MCP_PREFIX}${item.server}__${item.tool}`;
|
|
400
479
|
const names = (call) => call.function_name === name
|
|
401
480
|
|| (typeof call.arguments?.input === 'string' && call.arguments.input.includes(`tools.${name}`));
|
|
402
481
|
// Awaiting first; an item can also complete after the output row (measured) — then it
|
|
@@ -405,17 +484,17 @@ export class CodexAtifProjector extends AtifProjector {
|
|
|
405
484
|
?? [...this.completed].reverse().find((e) => e.turn === this.turnId && names(e.call))
|
|
406
485
|
?? null;
|
|
407
486
|
if (!entry) return this.#uncorrelated(item);
|
|
408
|
-
if (entry.call.function_name === name) return; // the parsed call already IS this act
|
|
409
487
|
if (entry.inner === 1) {
|
|
410
|
-
// One inner call
|
|
411
|
-
//
|
|
488
|
+
// One inner call: the exec IS this act. The source named it at call-start (with the
|
|
489
|
+
// literal fields it stated); the item knows the whole argument set — the record ends
|
|
490
|
+
// complete, never {input: raw} when it knows better.
|
|
412
491
|
entry.call.function_name = name;
|
|
413
492
|
entry.call.arguments = item.arguments ?? {};
|
|
414
|
-
|
|
415
|
-
// Several inner calls: the exec stays one call; the record lists what ran inside.
|
|
416
|
-
entry.executions.push({ tool: name, arguments: item.arguments ?? {} });
|
|
417
|
-
if (entry.result) this.#stampResult(entry);
|
|
493
|
+
return;
|
|
418
494
|
}
|
|
495
|
+
// Several inner calls: the exec stays one call; the item completes the ledger entry
|
|
496
|
+
// the source named for it (or appends, when the source named none).
|
|
497
|
+
this.#complete(entry, (ran) => ran.tool === name, { tool: name, arguments: item.arguments ?? {}, status: item.status ?? 'completed' });
|
|
419
498
|
return;
|
|
420
499
|
}
|
|
421
500
|
case 'FileChange': {
|
|
@@ -551,15 +630,25 @@ export class CodexAtifProjector extends AtifProjector {
|
|
|
551
630
|
+ 'action this projector relies on is unreadable, not empty', { file, call_id: payload.call_id });
|
|
552
631
|
}
|
|
553
632
|
const inner = this.#execReader.read(payload.input);
|
|
554
|
-
// Exactly one inner call
|
|
555
|
-
// speech acts surface by their real names)
|
|
556
|
-
|
|
633
|
+
// Exactly one inner call → that call IS the action, named the moment the cell is
|
|
634
|
+
// written (oathe speech acts surface by their real names): data arguments ride whole;
|
|
635
|
+
// a literal that is not pure data rides the fields it states beside the raw source, and
|
|
636
|
+
// the item completes it. Several inner calls → the exec stays one call and its ledger
|
|
637
|
+
// names every inner call from the source, in dispatch order, for the items to complete.
|
|
638
|
+
const single = inner.length === 1 ? inner[0] : null;
|
|
557
639
|
const execStep = this.#agentStep(row);
|
|
558
640
|
this.#pushCall(execStep, this.buildToolCall({
|
|
559
641
|
id: payload.call_id,
|
|
560
642
|
name: single ? single.tool : (payload.name ?? payload.type),
|
|
561
|
-
args: single
|
|
562
|
-
|
|
643
|
+
args: single
|
|
644
|
+
? (single.args ?? { ...(single.literals ?? {}), input: payload.input })
|
|
645
|
+
: { input: payload.input },
|
|
646
|
+
}), {
|
|
647
|
+
inner: inner.length,
|
|
648
|
+
executions: inner.length > 1
|
|
649
|
+
? inner.map(({ tool, args, literals }) => ({ tool, ...((args ?? literals) ? { arguments: args ?? literals } : {}), ...(this.#expectsItem(tool) ? { pending: true } : {}) }))
|
|
650
|
+
: [],
|
|
651
|
+
});
|
|
563
652
|
this.landed(execStep, payload.id);
|
|
564
653
|
break;
|
|
565
654
|
}
|
package/src/harnesses/codex.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { cwdDialect } from './dialects.mjs';
|
|
|
13
13
|
import { CODEX_ROLLOUT_ROSTER, CODEX_CALL_TYPES, CORRELATABLE_ITEMS, CODEX_ROOT_AGENT_PATH, codexKindOf } from './codex-roster.mjs';
|
|
14
14
|
import { makeFidelity } from './fidelity.mjs';
|
|
15
15
|
import { CodexTraceStore } from '../traces.mjs';
|
|
16
|
+
import { shimPath } from '../shim.mjs';
|
|
16
17
|
|
|
17
18
|
/** The raw call payloads of a rollout — the fidelity extractors' one reading of actions. */
|
|
18
19
|
const codexRawCalls = (entries) => entries
|
|
@@ -47,34 +48,71 @@ export class CodexHarness extends Harness {
|
|
|
47
48
|
static surfaces = Object.freeze({
|
|
48
49
|
ownsExec: (exec) => path.basename(exec) === 'codex',
|
|
49
50
|
name: ({ appBundle }) => (appBundle !== null && path.basename(appBundle) === 'ChatGPT.app' ? 'chatgpt' : 'codex'),
|
|
51
|
+
// The word each surface wears where work lives, and which of them is an app the glass
|
|
52
|
+
// resumes INTO by opening it (ruling 2026-09-05): the desktop app has no folder — it IS
|
|
53
|
+
// the place; a codex terminal is a folder's session.
|
|
54
|
+
display: Object.freeze({ codex: 'Codex', chatgpt: 'ChatGPT' }),
|
|
55
|
+
resumable: Object.freeze(['chatgpt']),
|
|
50
56
|
});
|
|
51
57
|
// Codex reads its global instructions before any work, in EVERY session — the one channel
|
|
52
58
|
// that reaches a ChatGPT-desktop session, whose staging cwd carries no folder fence. Its
|
|
53
59
|
// rule (docs, agents-md): AGENTS.override.md if it exists, otherwise AGENTS.md.
|
|
54
60
|
static globalContextFiles = Object.freeze(['AGENTS.override.md', 'AGENTS.md']);
|
|
55
|
-
// The ChatGPT desktop app runs every conversation from a directory it stages
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
61
|
+
// The ChatGPT desktop app runs every conversation from a directory it stages — not a project
|
|
62
|
+
// folder — and it stages TWO ways (measured): a ChatGPT project under the config home
|
|
63
|
+
// (`.chatgpt-projects/g-p-<id>`), and a "Codex work" conversation (rollout originator
|
|
64
|
+
// codex_work_desktop, codex 0.153.4, 2026-09-06) under ~/Documents/Codex/<date>/<slug> with
|
|
65
|
+
// outputs/ and work/ inside. Sessions there serve the FULL board and are never activated
|
|
66
|
+
// (R-BOARD-SCOPE); these members are the only place the staging paths are spelled. A claim from
|
|
67
|
+
// one is picked up by the app and says so in its place statement (the dir rides as evidence).
|
|
68
|
+
// `originators` names the desktop in a rollout's session_meta so doctor can say when the app
|
|
69
|
+
// moves again (traces.stagingDrift) — the day this list is stale, doctor says DRIFT, not a
|
|
70
|
+
// claim silently picked up as a folder (B1, launch/2026-09-06-0.4.5-release-review.md).
|
|
71
|
+
static synthetic = Object.freeze({
|
|
72
|
+
dirs: (home) => [path.join(CodexHarness.configHomeFor(home), '.chatgpt-projects'), path.join(home, 'Documents', 'Codex')],
|
|
73
|
+
originators: Object.freeze(['codex_work_desktop']),
|
|
74
|
+
});
|
|
59
75
|
|
|
60
76
|
static isSyntheticWorkspaceDir({ dir, home }) {
|
|
61
|
-
const
|
|
62
|
-
return
|
|
77
|
+
const real = realpathOr(dir);
|
|
78
|
+
return this.synthetic.dirs(home).some((parent) => real.startsWith(`${realpathOr(parent)}${path.sep}`));
|
|
63
79
|
}
|
|
64
80
|
|
|
65
|
-
|
|
81
|
+
// The CLI registers through hooks; the ChatGPT desktop app embeds codex and runs NONE —
|
|
82
|
+
// its claims are admitted on discovery (the measured app bundle names the surface).
|
|
83
|
+
static attestation = Object.freeze({ codex: 'hooks', chatgpt: 'hookless' });
|
|
84
|
+
// The blocking exchange declared to the transport (ruling 2026-09-05): codex — and the
|
|
85
|
+
// ChatGPT desktop app, which reads this same config.toml — caps a tool call at
|
|
86
|
+
// `tool_timeout_sec` (default 60, codex/mcp.md:178; no documented maximum), and a `done`
|
|
87
|
+
// waits minutes for its verdict. `codex mcp add` has no timeout flag and a re-add drops a
|
|
88
|
+
// hand-written key (probed live, codex-cli 0.150.0), so onboard STAMPS the line into the
|
|
89
|
+
// stanza after every add and the proof carries it.
|
|
90
|
+
static mcpToolTimeout = Object.freeze({ key: 'tool_timeout_sec', unit: 'sec' });
|
|
91
|
+
// `codex update` — "Update Codex to the latest version" (codex --help, 0.150.0, 2026-09-05).
|
|
92
|
+
static install = Object.freeze({ npm: '@openai/codex', bin: 'codex', versionArgs: ['--version'], update: (address) => [address, ['update']] });
|
|
66
93
|
// Non-interactive auth: CODEX_API_KEY "provides an API key to a non-interactive Codex
|
|
67
94
|
// process" (codex/environment-variables.md:49, pinned 2026-08-29).
|
|
68
95
|
static headless = Object.freeze({
|
|
69
96
|
auth: ['CODEX_API_KEY'],
|
|
70
97
|
command: (prompt, model = null) => ['codex', ['exec', '--skip-git-repo-check', ...(model ? ['-m', model] : []), prompt]],
|
|
71
98
|
extract: (stdout) => stdout,
|
|
99
|
+
// Live 2026-09-05 (codex-cli 0.150.0): "The 'gpt-6-astra' model requires a newer version of
|
|
100
|
+
// Codex. Please upgrade to the latest app or CLI and try again." — the one cause we act on.
|
|
101
|
+
diagnose: (stderrTail) => (/requires a newer version of Codex/i.test(String(stderrTail ?? '')) ? 'outdated' : null),
|
|
72
102
|
});
|
|
73
103
|
static traces = Object.freeze({
|
|
74
104
|
store: ({ home } = {}) => new CodexTraceStore({ home, harness: this.harnessName }),
|
|
75
105
|
newest: (store) => store.newestRollout(),
|
|
76
106
|
projector: async ({ store }) => new (await import('./codex-rollout.mjs')).CodexAtifProjector({ store }),
|
|
77
107
|
ownsPath: (file) => String(file).includes(`${path.sep}.codex${path.sep}`),
|
|
108
|
+
// The gate on the staging convention: a desktop rollout (session_meta.originator names the
|
|
109
|
+
// desktop) that ran from a dir this adapter does not know as staging is DRIFT, named — read
|
|
110
|
+
// by doctor over the newest rollout. Null for a terminal session (it runs anywhere) or a
|
|
111
|
+
// known staging dir.
|
|
112
|
+
stagingDrift: (described, { home }) => (CodexHarness.synthetic.originators.includes(described.originator)
|
|
113
|
+
&& !CodexHarness.isSyntheticWorkspaceDir({ dir: described.cwd ?? '', home })
|
|
114
|
+
? `desktop rollout ${described.path} ran from ${described.cwd} — not a staging dir this adapter knows (synthetic.dirs): ChatGPT moved its staging convention; measure it and add it`
|
|
115
|
+
: null),
|
|
78
116
|
roster: CODEX_ROLLOUT_ROSTER,
|
|
79
117
|
kindOf: codexKindOf,
|
|
80
118
|
recent: (store, { days, maxFiles }) => store.recentRollouts({ days, maxFiles }),
|
|
@@ -151,28 +189,46 @@ export class CodexHarness extends Harness {
|
|
|
151
189
|
return path.join(this.configHome, 'config.toml');
|
|
152
190
|
}
|
|
153
191
|
|
|
192
|
+
/** The budget line the mcp stanza carries — valued from config, never a literal second. */
|
|
193
|
+
#timeoutLine() {
|
|
194
|
+
if (!this.config) {
|
|
195
|
+
throw new HarnessOnboardError('CODEX_CONFIG_REQUIRED',
|
|
196
|
+
`the codex MCP stanza carries ${this.constructor.mcpToolTimeout.key} from config (mcpToolTimeoutSec) — `
|
|
197
|
+
+ 'this adapter was built without one', {});
|
|
198
|
+
}
|
|
199
|
+
return `${this.constructor.mcpToolTimeout.key} = ${this.config.get('mcpToolTimeoutSec')}`;
|
|
200
|
+
}
|
|
201
|
+
|
|
154
202
|
/**
|
|
155
|
-
* The sanctioned registrations, each with the CLI that makes it, the config.toml
|
|
156
|
-
*
|
|
203
|
+
* The sanctioned registrations, each with the CLI that makes it, the config.toml lines that
|
|
204
|
+
* prove it landed (every one must be present — doctor checks each), the CLI that undoes it,
|
|
205
|
+
* and, for the MCP server, the line the adapter stamps after the CLI's write.
|
|
157
206
|
*/
|
|
158
207
|
#registrations() {
|
|
159
208
|
return [
|
|
160
209
|
{
|
|
161
210
|
id: 'marketplace',
|
|
162
211
|
add: ['plugin', 'marketplace', 'add', this.paths.packageRoot],
|
|
163
|
-
|
|
212
|
+
proofs: ['[marketplaces.oathe]'],
|
|
164
213
|
undo: ['plugin', 'marketplace', 'remove', 'oathe'],
|
|
165
214
|
},
|
|
166
215
|
{
|
|
167
216
|
id: 'plugin',
|
|
168
217
|
add: ['plugin', 'add', PLUGIN_ID],
|
|
169
|
-
|
|
218
|
+
proofs: [`[plugins."${PLUGIN_ID}"]`],
|
|
170
219
|
undo: ['plugin', 'remove', PLUGIN_ID],
|
|
171
220
|
},
|
|
172
221
|
{
|
|
173
222
|
id: 'mcp-server',
|
|
174
|
-
|
|
175
|
-
|
|
223
|
+
// The shim, literal: config.toml has no interpolation (codex/config-reference.md,
|
|
224
|
+
// pinned), and the ChatGPT desktop app reads this same config (codex/mcp.md) — one
|
|
225
|
+
// write serves both. A bare `oathe` died on every GUI PATH (2026-09-04). The proofs
|
|
226
|
+
// are the COMMAND LINE, not the stanza (review F3): a re-add that drops the address
|
|
227
|
+
// back to bare must read as drift in doctor, never as ok over a dead lane — and the
|
|
228
|
+
// timeout line, because a re-add drops it (2026-09-05).
|
|
229
|
+
add: ['mcp', 'add', 'oathe', '--', shimPath(this.home), 'mcp'],
|
|
230
|
+
proofs: [`command = "${shimPath(this.home)}"`, this.#timeoutLine()],
|
|
231
|
+
stamp: this.#timeoutLine(),
|
|
176
232
|
undo: ['mcp', 'remove', 'oathe'],
|
|
177
233
|
},
|
|
178
234
|
];
|
|
@@ -181,8 +237,11 @@ export class CodexHarness extends Harness {
|
|
|
181
237
|
/** What init writes — from the registrations the CLI makes and the global fence target. */
|
|
182
238
|
describe() {
|
|
183
239
|
const globals = this.constructor.globalContextFiles.map((f) => path.join(this.configHome, f)).join(' (or ');
|
|
240
|
+
const regs = this.#registrations();
|
|
241
|
+
const mcp = regs.find((r) => r.id === 'mcp-server');
|
|
184
242
|
return [
|
|
185
|
-
`${this.configPath}: ${
|
|
243
|
+
`${this.configPath}: ${regs.flatMap((r) => r.proofs).join(', ')} via the codex CLI (marketplace, plugin, MCP server → ${mcp.add.slice(mcp.add.indexOf('--') + 1).join(' ')}; `
|
|
244
|
+
+ `${mcp.stamp} stamped into the stanza — the budget a blocking done waits inside, config mcpToolTimeoutSec)`,
|
|
186
245
|
`${globals}${this.constructor.globalContextFiles.length > 1 ? ')' : ''}: the standing Oathe rule for every Codex session — ChatGPT desktop reads it too`,
|
|
187
246
|
];
|
|
188
247
|
}
|
|
@@ -195,34 +254,62 @@ export class CodexHarness extends Harness {
|
|
|
195
254
|
// marketplace "already added from a different source". Re-register from this root: the
|
|
196
255
|
// undo the manifest already records, then the add again, proof-checked below.
|
|
197
256
|
if (result.status !== 0 && /already added from a different source/.test(result.stderr)) {
|
|
198
|
-
this.exec.run('codex', reg.undo);
|
|
257
|
+
this.exec.run('codex', reg.undo); // result unread: the add that follows is the proof — its failure is the typed refusal below, and the config's proof string is checked after it
|
|
199
258
|
result = this.exec.run('codex', reg.add);
|
|
200
259
|
}
|
|
201
260
|
if (result.status !== 0) {
|
|
202
261
|
throw new HarnessOnboardError('CODEX_CLI_FAILED',
|
|
203
262
|
`codex ${reg.add.join(' ')} exited ${result.status}: ${result.stderr.trim()}`, { reg: reg.id });
|
|
204
263
|
}
|
|
264
|
+
if (reg.stamp) this.#stampInStanza('[mcp_servers.oathe]', reg.stamp);
|
|
205
265
|
const config = fs.existsSync(this.configPath) ? fs.readFileSync(this.configPath, 'utf8') : '';
|
|
206
|
-
|
|
266
|
+
const missing = reg.proofs.find((p) => !config.includes(p));
|
|
267
|
+
if (missing !== undefined) {
|
|
207
268
|
throw new HarnessOnboardError('CODEX_VERIFICATION_FAILED',
|
|
208
269
|
`verification failed: codex ${reg.add.join(' ')} reported success but ${this.configPath} `
|
|
209
|
-
+ `carries no ${
|
|
270
|
+
+ `carries no ${missing} line — refusing to record an install that cannot be proven`,
|
|
210
271
|
{ reg: reg.id });
|
|
211
272
|
}
|
|
212
273
|
manifest.upsert({
|
|
213
274
|
harness: this.name,
|
|
214
275
|
file: this.configPath,
|
|
215
276
|
kind: 'cli-managed',
|
|
216
|
-
detail: { id: reg.id,
|
|
277
|
+
detail: { id: reg.id, proofs: reg.proofs, undo: reg.undo },
|
|
217
278
|
blockVersion: version,
|
|
218
|
-
sha256: sha256Hex(reg.
|
|
279
|
+
sha256: sha256Hex(reg.proofs.join('\n')),
|
|
219
280
|
});
|
|
220
281
|
}
|
|
221
282
|
return this.#registrations().map((r) => ({ action: `codex-${r.id}` }));
|
|
222
283
|
}
|
|
223
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Converge ONE `key = value` line inside a stanza the CLI owns: replace the key's line if the
|
|
287
|
+
* stanza has one, else append it at the stanza's end; every other line stays byte-identical.
|
|
288
|
+
* The one hand-write on this file besides the hooks-state sweep, for the one key the CLI
|
|
289
|
+
* cannot be told and does not keep.
|
|
290
|
+
*/
|
|
291
|
+
#stampInStanza(header, line) {
|
|
292
|
+
const key = line.split('=')[0].trim();
|
|
293
|
+
const lines = fs.readFileSync(this.configPath, 'utf8').split('\n');
|
|
294
|
+
const start = lines.findIndex((l) => l.trim() === header);
|
|
295
|
+
if (start === -1) return; // no stanza: the proof check below names the failure
|
|
296
|
+
let end = lines.findIndex((l, i) => i > start && l.trimStart().startsWith('['));
|
|
297
|
+
if (end === -1) end = lines.length;
|
|
298
|
+
const existing = lines.findIndex((l, i) => i > start && i < end && l.split('=')[0].trim() === key);
|
|
299
|
+
if (existing !== -1) {
|
|
300
|
+
lines[existing] = line;
|
|
301
|
+
} else {
|
|
302
|
+
// Insert after the stanza's last non-blank line, keeping any trailing blank spacing.
|
|
303
|
+
let at = end;
|
|
304
|
+
while (at > start + 1 && lines[at - 1].trim() === '') at -= 1;
|
|
305
|
+
lines.splice(at, 0, line);
|
|
306
|
+
}
|
|
307
|
+
if (lines.at(-1) !== '') lines.push(''); // a toml file ends in a newline, whatever the CLI left
|
|
308
|
+
fs.writeFileSync(this.configPath, lines.join('\n'));
|
|
309
|
+
}
|
|
310
|
+
|
|
224
311
|
offboard({ manifest }) {
|
|
225
|
-
const rows =
|
|
312
|
+
const rows = this.takeWiringRows(manifest);
|
|
226
313
|
const actions = [];
|
|
227
314
|
// Undo in reverse install order, so the plugin is gone before its marketplace is.
|
|
228
315
|
for (const row of rows.reverse()) {
|