@oathe/oathe 0.4.4 → 0.4.6
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 +6 -3
- package/bin/oathe.mjs +199 -35
- 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 +5 -4
- 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 +18 -0
- package/src/context.mjs +1 -1
- package/src/device.mjs +106 -0
- package/src/doctor.mjs +101 -6
- 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 +106 -19
- 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 +34 -68
- 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 +35 -7
- 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
|
@@ -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
|
}
|
|
@@ -202,27 +261,55 @@ export class CodexHarness extends Harness {
|
|
|
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()) {
|
package/src/harnesses/cursor.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { Harness, HarnessOnboardError } from './harness.mjs';
|
|
|
18
18
|
import { workspaceRootsDialect } from './dialects.mjs';
|
|
19
19
|
import { JsonArrayEntries, JsonEntries } from '../blocks.mjs';
|
|
20
20
|
import { sha256Hex } from '../manifest.mjs';
|
|
21
|
+
import { shimPath } from '../shim.mjs';
|
|
21
22
|
|
|
22
23
|
const HOOK_EVENTS = Object.freeze([
|
|
23
24
|
{ event: 'sessionStart', script: 'render-board' },
|
|
@@ -48,9 +49,15 @@ export class CursorHarness extends Harness {
|
|
|
48
49
|
ownsExec: (exec) => exec.includes(`${path.sep}Cursor.app${path.sep}`)
|
|
49
50
|
|| CursorHarness.cliExecutables.includes(path.basename(exec)),
|
|
50
51
|
name: () => 'cursor',
|
|
52
|
+
display: Object.freeze({ cursor: 'Cursor' }),
|
|
53
|
+
resumable: Object.freeze([]), // a folder's session — the folder is the place
|
|
51
54
|
});
|
|
52
55
|
// cursor/cli-installation.md:10 (pinned 2026-08-29).
|
|
53
|
-
static
|
|
56
|
+
static attestation = Object.freeze({ cursor: 'hooks' });
|
|
57
|
+
// Cursor's pinned MCP docs (cursor/mcp.md, cli-mcp.md) document no per-tool timeout, so
|
|
58
|
+
// there is nothing to write — a stated limitation, not a guess; a live probe is owed.
|
|
59
|
+
static mcpToolTimeout = null;
|
|
60
|
+
static install = Object.freeze({ installer: 'curl https://cursor.com/install -fsS | bash', bin: 'agent', versionArgs: ['--version'], update: null }); // no in-place updater documented
|
|
54
61
|
// Headless: `agent -p --output-format json` → {type:"result", result} (cursor/cli-output-format.md);
|
|
55
62
|
// CI auth CURSOR_API_KEY (cursor/cli-authentication.md:24-37, cli-github-actions.md:17). A fresh
|
|
56
63
|
// project dir is untrusted — the CLI refuses to run there without --trust (observed live 2026-08-29).
|
|
@@ -58,6 +65,7 @@ export class CursorHarness extends Harness {
|
|
|
58
65
|
auth: ['CURSOR_API_KEY'],
|
|
59
66
|
command: (prompt, model = null) => ['agent', ['-p', prompt, '--trust', '--output-format', 'json', ...(model ? ['--model', model] : [])]],
|
|
60
67
|
extract: (stdout) => CursorHarness.extractJsonResult(stdout),
|
|
68
|
+
diagnose: () => null, // unmeasured — stated
|
|
61
69
|
});
|
|
62
70
|
static traces = null; // Cursor keeps no session store we read; its hook payload carries transcript_path: null
|
|
63
71
|
static docs = Object.freeze([
|
|
@@ -90,21 +98,17 @@ export class CursorHarness extends Harness {
|
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
/**
|
|
93
|
-
* The absolute oathe address
|
|
94
|
-
* (npm shims ride `#!/usr/bin/env node`, and a GUI-launched Cursor may not carry node's dir
|
|
95
|
-
* on PATH — the fallback names the runtime explicitly).
|
|
101
|
+
* The absolute oathe address for every cursor-owned entry.
|
|
96
102
|
* @returns {{command: string, args: string[], hookPrefix: string}}
|
|
97
103
|
*/
|
|
98
104
|
#oatheAddress() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
const binPath = path.join(this.paths.packageRoot, 'bin/oathe.mjs');
|
|
107
|
-
return { command: process.execPath, args: [binPath], hookPrefix: `${process.execPath} ${binPath}` };
|
|
105
|
+
// The ONE durable address (connection-lane plan, 2026-09-04): the shim init materializes
|
|
106
|
+
// under the oathe home. The old PATH scan answered differently per environment — the
|
|
107
|
+
// exact class that stranded GUI sessions — and a raw node path was stranded by the next
|
|
108
|
+
// nvm switch. Deterministic from home alone; init writes the shim before any adapter.
|
|
109
|
+
// The hook prefix is QUOTED (review F7): a HOME with a space must not break one dialect.
|
|
110
|
+
const shim = shimPath(this.home);
|
|
111
|
+
return { command: shim, args: [], hookPrefix: `"${shim}"` };
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
#hookEntries(hookPrefix) {
|
|
@@ -113,7 +117,10 @@ export class CursorHarness extends Harness {
|
|
|
113
117
|
return {
|
|
114
118
|
path: ['hooks', event],
|
|
115
119
|
element: { command },
|
|
116
|
-
|
|
120
|
+
// Ownership is the SCHEMA, not this vintage's exact address (review F2): any entry
|
|
121
|
+
// driving `… hook <script>` is ours — an old-address entry converges instead of
|
|
122
|
+
// pairing up with the new one and running every hook twice through a dead path.
|
|
123
|
+
owns: (el) => typeof el?.command === 'string' && el.command.endsWith(` hook ${script}`),
|
|
117
124
|
match: command,
|
|
118
125
|
};
|
|
119
126
|
});
|
|
@@ -154,9 +161,12 @@ export class CursorHarness extends Harness {
|
|
|
154
161
|
const hooksAbsentBefore = !fs.existsSync(this.hooksConfigPath);
|
|
155
162
|
// Version ownership is decided ONCE (the file we created carries our version key) and then
|
|
156
163
|
// carried forward — a re-run must upsert the SAME row identity, never mint a sibling.
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
const priorRow = manifest.rows.find((r) => r.harness === this.name && r.file === this.hooksConfigPath && r.kind === 'json-array');
|
|
165
|
+
if (priorRow && typeof priorRow.detail?.owns_version !== 'boolean') {
|
|
166
|
+
throw new HarnessOnboardError('CURSOR_MANIFEST_ROW_MALFORMED',
|
|
167
|
+
`the recorded ${this.hooksConfigPath} row carries no owns_version — not a row this oathe writes; uninstall with the oathe that wrote it, then run oathe init`, { row: priorRow });
|
|
168
|
+
}
|
|
169
|
+
const ownsVersion = hooksAbsentBefore || (priorRow ? priorRow.detail.owns_version : false);
|
|
160
170
|
|
|
161
171
|
manifest.backupOnce(this.mcpConfigPath);
|
|
162
172
|
const mcpBefore = fs.existsSync(this.mcpConfigPath) ? fs.readFileSync(this.mcpConfigPath, 'utf8') : '';
|
|
@@ -190,6 +200,9 @@ export class CursorHarness extends Harness {
|
|
|
190
200
|
verify: (doc) => hookEntries.every((e) => (doc?.hooks?.[e.path[1]] ?? []).some((el) => el?.command === e.match)),
|
|
191
201
|
refuseDetail: 'the three owned oathe hook entries',
|
|
192
202
|
});
|
|
203
|
+
// ONE row per file (review F1-class): the detail carries the vintage's match strings, so
|
|
204
|
+
// an address change would otherwise mint a second row beside the stale one.
|
|
205
|
+
manifest.removeWhere((r) => r.harness === this.name && r.file === this.hooksConfigPath && r.kind === 'json-array');
|
|
193
206
|
manifest.upsert({
|
|
194
207
|
harness: this.name,
|
|
195
208
|
file: this.hooksConfigPath,
|
|
@@ -209,7 +222,7 @@ export class CursorHarness extends Harness {
|
|
|
209
222
|
}
|
|
210
223
|
|
|
211
224
|
offboard({ manifest }) {
|
|
212
|
-
const rows =
|
|
225
|
+
const rows = this.takeWiringRows(manifest);
|
|
213
226
|
const actions = [];
|
|
214
227
|
for (const row of rows) {
|
|
215
228
|
if (!fs.existsSync(row.file)) {
|