@parcha/agentrun-harness-codex 0.0.0-stage → 0.1.0-beta.101
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/CHANGELOG.md +349 -0
- package/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +80 -2
- package/dist/adapter.d.ts +93 -0
- package/dist/adapter.js +375 -0
- package/dist/app-server.d.ts +53 -0
- package/dist/app-server.js +105 -0
- package/dist/binary.d.ts +31 -0
- package/dist/binary.js +74 -0
- package/dist/catalog.d.ts +35 -0
- package/dist/catalog.js +104 -0
- package/dist/code-mode.d.ts +171 -0
- package/dist/code-mode.js +514 -0
- package/dist/config.d.ts +84 -0
- package/dist/config.js +214 -0
- package/dist/facts.d.ts +2 -0
- package/dist/facts.js +40 -0
- package/dist/harness.d.ts +210 -0
- package/dist/harness.js +1112 -0
- package/dist/host/kernel.d.ts +20 -0
- package/dist/host/kernel.js +3 -0
- package/dist/host/machine.d.ts +81 -0
- package/dist/host/machine.js +355 -0
- package/dist/host/policy.d.ts +113 -0
- package/dist/host/policy.js +683 -0
- package/dist/host/process.d.ts +151 -0
- package/dist/host/process.js +50 -0
- package/dist/host/sandbox.d.ts +36 -0
- package/dist/host/sandbox.js +35 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +10 -0
- package/dist/rollout.d.ts +96 -0
- package/dist/rollout.js +170 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.js +178 -0
- package/dist/scripts.d.ts +218 -0
- package/dist/scripts.js +409 -0
- package/dist/tool-images.d.ts +7 -0
- package/dist/tool-images.js +18 -0
- package/dist/transcript.d.ts +20 -0
- package/dist/transcript.js +73 -0
- package/dist/verify.d.ts +62 -0
- package/dist/verify.js +155 -0
- package/dist/versions.d.ts +43 -0
- package/dist/versions.js +72 -0
- package/package.json +72 -4
- package/vendor/durable-harness/UPSTREAM.json +39 -0
package/dist/scripts.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// Which code-mode script a host tool's nested call belongs to. Written for AgentRun.
|
|
2
|
+
//
|
|
3
|
+
// A host tool a code-mode model's script calls arrives on the app-server's stream as a call under an id of Codex's own
|
|
4
|
+
// (`exec-<uuid>`) that carries no parent, no cell and no `exec` id, and the rollout holds no line for it until after it is
|
|
5
|
+
// answered. So the call is tied to the one script that can be running, and that is read from two places that cannot be
|
|
6
|
+
// ahead of Codex:
|
|
7
|
+
// - the rollout: an `exec` call line opens a script, and it stays open until an output says it finished: its own, or, when
|
|
8
|
+
// that says "Script running with cell ID N" (it yielded and went on), the output of the `wait` that finishes cell N;
|
|
9
|
+
// - the model proxy: the `exec` the latest answer carried, which it read before Codex had that part of the answer, so
|
|
10
|
+
// before the `exec`'s line could be in the rollout.
|
|
11
|
+
// The proxy offers no `exec` while a cell runs and no parallel calls, so one script is live at a time. A model that writes an
|
|
12
|
+
// `exec` anyway makes two live, and then a nested call cannot be told from the other's.
|
|
13
|
+
import { HOST_RESULT_MAX_CHARS } from "@parcha/agentrun-kernel";
|
|
14
|
+
import { boundResult, resultMaxChars } from "./host/process.js";
|
|
15
|
+
import { parseLine } from "./rollout.js";
|
|
16
|
+
/** The id Codex gives a host tool called from a code-mode script. */
|
|
17
|
+
export const NESTED_CALL = /^exec-[0-9a-f-]{36}$/;
|
|
18
|
+
/** What the session is told when the proxy could not watch an answer to its end: the answer may carry an `exec` it did not see, so
|
|
19
|
+
* no script can be told from it. It counts as a script of its own, one that is never in the log. */
|
|
20
|
+
export const UNWATCHED = "(unwatched answer)";
|
|
21
|
+
/** Codex's status header of an exec's or a wait's output: the text it starts with (its first part), never what the script printed after it. */
|
|
22
|
+
const statusOf = (output) => typeof output === "string" ? output : Array.isArray(output) && typeof output[0]?.text === "string" ? output[0].text : "";
|
|
23
|
+
/** A cell that yielded and still runs, as its status header says. */
|
|
24
|
+
const RUNNING = /^Script running with cell ID (\S+)/;
|
|
25
|
+
/** A script that failed (it threw, or its cell was gone), as its status header says. The rollout's output line has no
|
|
26
|
+
* status field of its own: this header is the only place Codex says how a script ended. */
|
|
27
|
+
const FAILED = /^Script failed\b/;
|
|
28
|
+
/**
|
|
29
|
+
* The status headers Codex 0.164.0 puts first on an exec's or a wait's output when its code-mode host ran the script and
|
|
30
|
+
* said how it went: it completed, failed (threw, or its cell was gone), was terminated (a `wait` with `terminate`), or still
|
|
31
|
+
* runs (RUNNING). Each is followed by a line of its own ("Wall time ..."). An output that starts with none of them is Codex's
|
|
32
|
+
* own words, not the script's: the host never ran it to an end it could report (it was not there, did not start, answered
|
|
33
|
+
* outside its protocol, or died with the script in it). Codex hands those words to the model and ends the turn completed; the
|
|
34
|
+
* session fails the turn instead (CodeModeDeps.hostFailed), a nested call of that script run first or not. Only the first text
|
|
35
|
+
* of an output is read: what a script prints comes after Codex's header, never before it. test/code-mode-host-down.test.mjs,
|
|
36
|
+
* which CI runs on the pinned binary under AGENTRUN_CODEX_REQUIRE_BINARY=1, finds each header in the pinned binary (Codex
|
|
37
|
+
* builds "Script failed" at run time: a real script that throws holds that one), so a release that rewords one fails there.
|
|
38
|
+
*/
|
|
39
|
+
export const SCRIPT_STATUS = Object.freeze(["Script completed", "Script failed", "Script terminated", "Script running with cell ID"]);
|
|
40
|
+
/**
|
|
41
|
+
* Codex's answers to an `exec` the model wrote wrong (no script, or a bad first-line pragma), each by its fixed part (the words
|
|
42
|
+
* before any detail Codex adds): the model's own mistake, which it reads and can put right in the same turn. No script status
|
|
43
|
+
* comes with them, and none is owed: Codex answers them from the exec's text alone, before it starts or asks the host, so
|
|
44
|
+
* they come back the same with no host beside Codex at all (the sweep and the live rows of test/code-mode-host-down.test.mjs).
|
|
45
|
+
* Each is in the pinned binary (the same test).
|
|
46
|
+
*/
|
|
47
|
+
export const EXEC_MISTAKES = Object.freeze([
|
|
48
|
+
"exec expects raw JavaScript source text",
|
|
49
|
+
"exec pragma must be valid JSON with supported fields `yield_time_ms` and `max_output_tokens`: ",
|
|
50
|
+
"exec pragma must be a JSON object with supported fields `yield_time_ms` and `max_output_tokens`",
|
|
51
|
+
"exec pragma must be followed by JavaScript source on subsequent lines",
|
|
52
|
+
"exec pragma only supports `yield_time_ms` and `max_output_tokens`; got `",
|
|
53
|
+
"exec pragma fields `yield_time_ms` and `max_output_tokens` must be non-negative safe integers: ",
|
|
54
|
+
"exec pragma field `yield_time_ms` must be a non-negative safe integer",
|
|
55
|
+
"exec pragma field `max_output_tokens` must be a non-negative safe integer",
|
|
56
|
+
]);
|
|
57
|
+
/** Whether an output's first text is a script status (a header, then its line's end) or Codex's answer to an exec the model
|
|
58
|
+
* wrote wrong: anything else, the host never reported the script. */
|
|
59
|
+
export const scriptStatusSaid = (status) => SCRIPT_STATUS.some((header) => status.startsWith(header) && /^(?:\s|$)/.test(status.slice(header.length))) || EXEC_MISTAKES.some((words) => status.startsWith(words));
|
|
60
|
+
/** How long Codex waits on an `exec` before it yields when the script's first-line pragma names no `yield_time_ms` (the pinned
|
|
61
|
+
* Codex's default: a script that never ends yields at about 30 s), and on a `wait` that names none (its tool's description:
|
|
62
|
+
* 10000 ms). */
|
|
63
|
+
export const EXEC_YIELD_MS = 30_000;
|
|
64
|
+
export const WAIT_YIELD_MS = 10_000;
|
|
65
|
+
/** The `yield_time_ms` an exec's first-line pragma (`// @exec: {...}`) names, if it names a valid one. */
|
|
66
|
+
export function execYieldMs(input) {
|
|
67
|
+
const pragma = /^\s*\/\/\s*@exec:(.*)$/.exec(input.split("\n", 1)[0] ?? "")?.[1];
|
|
68
|
+
try {
|
|
69
|
+
return pragma === undefined ? EXEC_YIELD_MS : yieldOf(JSON.parse(pragma), EXEC_YIELD_MS);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return EXEC_YIELD_MS;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const yieldOf = (args, fallback) => {
|
|
76
|
+
const ms = args?.yield_time_ms;
|
|
77
|
+
return typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 0 ? ms : fallback;
|
|
78
|
+
};
|
|
79
|
+
const textOf = (output) => typeof output === "string" ? output : Array.isArray(output) ? output.map((part) => (typeof part?.text === "string" ? part.text : "")).join("\n") : "";
|
|
80
|
+
export class Scripts {
|
|
81
|
+
open = [];
|
|
82
|
+
/** The `exec` calls whose script finished. */
|
|
83
|
+
done = new Set();
|
|
84
|
+
/** The cell each `wait` call in the rollout resumes. */
|
|
85
|
+
waitsOn = new Map();
|
|
86
|
+
/** Reads one rollout line: what it says of a script, if anything. A script opened (its `exec` line, with its input, the
|
|
87
|
+
* script) or finished (the output that ended it: its own, or the `wait`'s on its cell). */
|
|
88
|
+
note(line) {
|
|
89
|
+
if (!line.includes("call_id"))
|
|
90
|
+
return undefined;
|
|
91
|
+
const p = parseLine(line)?.payload;
|
|
92
|
+
if (!p || typeof p.call_id !== "string")
|
|
93
|
+
return undefined;
|
|
94
|
+
const id = p.call_id;
|
|
95
|
+
const running = RUNNING.exec(statusOf(p.output));
|
|
96
|
+
if (p.type === "custom_tool_call" && p.name === "exec") {
|
|
97
|
+
if (this.open.some((x) => x.exec === id))
|
|
98
|
+
return undefined;
|
|
99
|
+
const input = typeof p.input === "string" ? p.input : "";
|
|
100
|
+
this.open.push({ exec: id, input });
|
|
101
|
+
return { kind: "opened", exec: id, input, yieldMs: execYieldMs(input) };
|
|
102
|
+
}
|
|
103
|
+
else if (p.type === "custom_tool_call_output") {
|
|
104
|
+
const at = this.open.findIndex((x) => x.exec === id);
|
|
105
|
+
if (at < 0)
|
|
106
|
+
return undefined;
|
|
107
|
+
if (!running)
|
|
108
|
+
return this.finish(at, p.output);
|
|
109
|
+
this.open[at].cell = running[1];
|
|
110
|
+
return { kind: "yielded", exec: id, cell: running[1] };
|
|
111
|
+
}
|
|
112
|
+
else if (p.type === "function_call" && p.name === "wait") {
|
|
113
|
+
try {
|
|
114
|
+
const args = JSON.parse(String(p.arguments));
|
|
115
|
+
if (args?.cell_id === undefined)
|
|
116
|
+
return undefined;
|
|
117
|
+
const cell = String(args.cell_id);
|
|
118
|
+
this.waitsOn.set(id, cell);
|
|
119
|
+
const exec = this.execOn(cell);
|
|
120
|
+
if (exec !== undefined)
|
|
121
|
+
return { kind: "waiting", exec, cell, yieldMs: yieldOf(args, WAIT_YIELD_MS) };
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
124
|
+
}
|
|
125
|
+
else if (p.type === "function_call_output" && this.waitsOn.has(id)) {
|
|
126
|
+
const at = this.open.findIndex((x) => x.cell === this.waitsOn.get(id));
|
|
127
|
+
if (at < 0)
|
|
128
|
+
return undefined;
|
|
129
|
+
if (!running)
|
|
130
|
+
return this.finish(at, p.output);
|
|
131
|
+
this.open[at].cell = running[1];
|
|
132
|
+
return { kind: "yielded", exec: this.open[at].exec, cell: running[1] };
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
finish(at, output) {
|
|
137
|
+
const exec = this.open.splice(at, 1)[0].exec;
|
|
138
|
+
this.done.add(exec);
|
|
139
|
+
const status = statusOf(output);
|
|
140
|
+
return { kind: "finished", exec, output: textOf(output), failed: FAILED.test(status), ...(scriptStatusSaid(status) ? {} : { unrun: status }) };
|
|
141
|
+
}
|
|
142
|
+
/** The unfinished `exec` that yielded on cell `cell`, if any. */
|
|
143
|
+
execOn(cell) {
|
|
144
|
+
return this.open.find((x) => x.cell === cell)?.exec;
|
|
145
|
+
}
|
|
146
|
+
/** The script of an unfinished `exec` whose line the rollout holds; none for any other. */
|
|
147
|
+
inputOf(exec) {
|
|
148
|
+
return this.open.find((x) => x.exec === exec)?.input;
|
|
149
|
+
}
|
|
150
|
+
/** The scripts that may call a host tool now: the rollout's unfinished ones, and the `exec` the proxy's latest answer carried
|
|
151
|
+
* if it is not among them and has not finished (its line may not be in the rollout yet). */
|
|
152
|
+
live(announced) {
|
|
153
|
+
const live = this.open.map((x) => x.exec);
|
|
154
|
+
if (announced && !this.done.has(announced) && !live.includes(announced))
|
|
155
|
+
live.push(announced);
|
|
156
|
+
return live;
|
|
157
|
+
}
|
|
158
|
+
/** What to do with a nested call now, given the exec the proxy announced and whether a call id is in the rollout. */
|
|
159
|
+
tie(announced, logged) {
|
|
160
|
+
const live = this.live(announced);
|
|
161
|
+
if (live.length > 1)
|
|
162
|
+
return { kind: "ambiguous", live };
|
|
163
|
+
if (live.length === 0)
|
|
164
|
+
return { kind: "none" };
|
|
165
|
+
return logged(live[0]) ? { kind: "tied", exec: live[0] } : { kind: "held", exec: live[0] };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** The nested calls the rollout's lines hold a completion for, by their `exec-<uuid>` id. */
|
|
169
|
+
export function completedNested(lines) {
|
|
170
|
+
const out = new Map();
|
|
171
|
+
for (const raw of lines) {
|
|
172
|
+
if (!raw.includes("DynamicToolCall"))
|
|
173
|
+
continue;
|
|
174
|
+
const line = parseLine(raw);
|
|
175
|
+
const p = line?.payload;
|
|
176
|
+
const item = p?.item;
|
|
177
|
+
if (line?.type !== "event_msg" || p?.type !== "item_completed" || item?.type !== "DynamicToolCall" || typeof item.id !== "string")
|
|
178
|
+
continue;
|
|
179
|
+
if (item.status !== "completed" && item.status !== "failed")
|
|
180
|
+
continue;
|
|
181
|
+
out.set(item.id, { tool: String(item.tool ?? ""), ok: item.success !== false && item.status === "completed", text: textOf(item.content_items) });
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
/** The session's record that the host parked the call `callId` for a person's approval, so it did not run: what the call
|
|
186
|
+
* was answered (the host's waiting text) reads as its outcome, and is none. */
|
|
187
|
+
export const parkedKey = (callId) => `parked:${callId}`;
|
|
188
|
+
/** Records that the host parked `callId` (a host tool's or a remote MCP server's), before its answer is recorded: a parked
|
|
189
|
+
* call is never told as completed, after a crash either. */
|
|
190
|
+
export const markParked = (ctx, callId) => ctx.effect(parkedKey(callId), { name: "parked", replay: "safe", input: null }, async () => true);
|
|
191
|
+
/** What a nested call came to. A call the host parked is `parked`, whatever else holds: it never ran. Else the store's record first, the rollout's completion second: both complete and agreeing, or
|
|
192
|
+
* one of them, is that outcome; both complete and disagreeing, or a call that started and has no end in either, is
|
|
193
|
+
* interrupted (its effect is unknown), and a failure the store marks interrupted is interrupted. They agree when the
|
|
194
|
+
* rollout holds what the bridge handed Codex for the stored text: the stored text itself; or, where the bridge recorded
|
|
195
|
+
* its cut (`store.bound`), a text that starts with the stored text's kept characters, the stored text as long as the
|
|
196
|
+
* record says, compared on those lengths and never on the cut's note, whose words are free to change; or the stored
|
|
197
|
+
* text cut at the host's bound, as a session written before the record (a release before it) holds it. Any other cut
|
|
198
|
+
* with no record is no proof the two are one call's. */
|
|
199
|
+
export function settle(fact) {
|
|
200
|
+
if (fact.parked)
|
|
201
|
+
return { kind: "parked" };
|
|
202
|
+
const { store, rollout } = fact;
|
|
203
|
+
const stored = store?.status === "completed" ? { kind: "completed", text: store.text ?? "" } : store?.status === "failed" && !store.interrupted ? { kind: "failed", text: store.text ?? "" } : undefined;
|
|
204
|
+
const rolled = rollout ? { kind: rollout.ok ? "completed" : "failed", text: rollout.text } : undefined;
|
|
205
|
+
if (stored && rolled)
|
|
206
|
+
return stored.kind === rolled.kind && (rolled.text === stored.text || cutOf(rolled.text, stored.text, store?.bound) || rolled.text === boundResult(stored.text).text || (store?.sent !== undefined && rolled.text === store.sent)) ? stored : { kind: "interrupted" };
|
|
207
|
+
return stored ?? rolled ?? { kind: "interrupted" };
|
|
208
|
+
}
|
|
209
|
+
/** Whether `text` is the cut of `whole` the bridge recorded (`bound`): `whole` as long as the record says, and `text`
|
|
210
|
+
* starting with its kept characters. */
|
|
211
|
+
const cutOf = (text, whole, bound) => bound !== undefined && whole.length === bound.whole && bound.kept <= whole.length && text.startsWith(whole.slice(0, bound.kept));
|
|
212
|
+
/** The most a recovered script's output holds (a cut-off `exec`'s, or the `wait` on its cell): one result at the host's bound, as
|
|
213
|
+
* the script was handed it, and the words that tell each call's outcome around it. It stands in for the script's own output,
|
|
214
|
+
* which the model reads as one tool result. Past it, every result it quotes is cut to the same share, each keeping its start
|
|
215
|
+
* and its last line (a filed answer's says where the whole is) and saying where it was cut (`cut`): never silently, and every
|
|
216
|
+
* call's outcome is still told. Only when the lines alone pass it is the output itself cut, with its note: the calls past
|
|
217
|
+
* the cut are not in it, and the recovery note does not say they are (`Recovered.shown`). */
|
|
218
|
+
export const EXEC_RECOVERY_MAX_CHARS = HOST_RESULT_MAX_CHARS + 2_000;
|
|
219
|
+
/** The most a recovered output holds for a model of `budget` (the session's window): EXEC_RECOVERY_MAX_CHARS with none, or
|
|
220
|
+
* one too large to bind (as it always was); else the per-model bound itself (the kernel's resultMaxChars), words and all,
|
|
221
|
+
* since the output is one tool result the model reads. */
|
|
222
|
+
export function recoveryMaxChars(budget) {
|
|
223
|
+
const max = resultMaxChars(budget);
|
|
224
|
+
return max < HOST_RESULT_MAX_CHARS ? max : EXEC_RECOVERY_MAX_CHARS;
|
|
225
|
+
}
|
|
226
|
+
/** A last line longer than this is not kept when a result is cut: it is the result's own text, not a pointer to the rest. */
|
|
227
|
+
const LAST_LINE_MAX = 1_000;
|
|
228
|
+
/** `text` within `cap` characters: whole when it fits; else its start, a line saying where it was cut (as `boundResult`'s
|
|
229
|
+
* does), and its last line when that is short (a filed answer's, which says where the whole is), never splitting a
|
|
230
|
+
* character written as a surrogate pair. Whole, too, when the cut would be no shorter (a short result is never swapped
|
|
231
|
+
* for a longer line saying it was cut). `kept`: how much of the start of `text` is there. */
|
|
232
|
+
function cut(text, cap) {
|
|
233
|
+
if (text.length <= cap)
|
|
234
|
+
return { text, kept: text.length };
|
|
235
|
+
const at = text.lastIndexOf("\n");
|
|
236
|
+
const last = at >= 0 && text.length - at <= LAST_LINE_MAX ? text.slice(at) : "";
|
|
237
|
+
const note = (kept) => `\n[cut at ${kept} of ${text.length} characters]`;
|
|
238
|
+
let kept = Math.max(0, cap - note(cap).length - last.length);
|
|
239
|
+
if (kept > 0 && (text.charCodeAt(kept - 1) & 0xfc00) === 0xd800 && (text.charCodeAt(kept) & 0xfc00) === 0xdc00)
|
|
240
|
+
kept -= 1;
|
|
241
|
+
const short = `${text.slice(0, kept)}${note(kept)}${last}`;
|
|
242
|
+
return short.length < text.length ? { text: short, kept } : { text, kept: text.length };
|
|
243
|
+
}
|
|
244
|
+
/** A told call's line, the text it quotes held to `cap`. */
|
|
245
|
+
const lineOf = (told, cap) => (told.text === undefined ? `${told.head}${told.tail}` : `${told.head}${JSON.stringify(cut(told.text, cap).text)}${told.tail}`);
|
|
246
|
+
/** A recovered output built by `build` from its calls' lines (`told`, in the order `build` writes them) at a cap on each
|
|
247
|
+
* quoted text: whole when it fits in recoveryMaxChars(budget); else at the largest cap that fits (the same for every quoted
|
|
248
|
+
* text); else, the lines alone passing the bound, the output cut to the bound with its note, and the calls past the cut
|
|
249
|
+
* not in it. */
|
|
250
|
+
function fitted(told, build, budget) {
|
|
251
|
+
const max = recoveryMaxChars(budget);
|
|
252
|
+
const at = (cap, output, limit = output.length) => {
|
|
253
|
+
const shown = [];
|
|
254
|
+
let from = 0;
|
|
255
|
+
for (const t of told) {
|
|
256
|
+
const line = lineOf(t, cap);
|
|
257
|
+
const pos = output.indexOf(line, from);
|
|
258
|
+
if (pos < 0 || pos + line.length > limit)
|
|
259
|
+
break;
|
|
260
|
+
from = pos + line.length;
|
|
261
|
+
if (t.shows && t.callId !== undefined && (t.text === undefined || t.text === "" || cut(t.text, cap).kept > 0))
|
|
262
|
+
shown.push(t.callId);
|
|
263
|
+
}
|
|
264
|
+
return { output, shown };
|
|
265
|
+
};
|
|
266
|
+
const whole = build(Number.POSITIVE_INFINITY);
|
|
267
|
+
if (whole.length <= max)
|
|
268
|
+
return at(Number.POSITIVE_INFINITY, whole);
|
|
269
|
+
const least = build(0);
|
|
270
|
+
if (least.length > max) {
|
|
271
|
+
const { text, kept } = cut(least, max);
|
|
272
|
+
// A window too small for even the lines, where cut keeps a short last line past its cap: held to the kernel's bound
|
|
273
|
+
// (which refuses it in words), and then it tells no call's outcome. With no window binding this is never taken, and
|
|
274
|
+
// the output and the calls it tells are exactly as they always were.
|
|
275
|
+
if (max < EXEC_RECOVERY_MAX_CHARS && text.length > max)
|
|
276
|
+
return { output: boundResult(text, budget).text, shown: [] };
|
|
277
|
+
return at(0, text, kept);
|
|
278
|
+
}
|
|
279
|
+
let lo = 0;
|
|
280
|
+
let hi = whole.length;
|
|
281
|
+
while (lo < hi) {
|
|
282
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
283
|
+
if (build(mid).length <= max)
|
|
284
|
+
lo = mid;
|
|
285
|
+
else
|
|
286
|
+
hi = mid - 1;
|
|
287
|
+
}
|
|
288
|
+
return at(lo, build(lo));
|
|
289
|
+
}
|
|
290
|
+
/** The nested calls to list for each cut-off `exec` of the interrupted turn `since`: its own, in order; and the calls whose
|
|
291
|
+
* script could not be told, which ran in that turn, under the LAST cut-off exec only, apart from its own, so each is listed once. */
|
|
292
|
+
export function recoveryFacts(execs, ties, since, factOf) {
|
|
293
|
+
const out = new Map();
|
|
294
|
+
const last = execs.at(-1);
|
|
295
|
+
const loose = ties.filter((t) => t.exec === null && t.since === since).map(factOf);
|
|
296
|
+
for (const exec of execs)
|
|
297
|
+
out.set(exec, { own: ties.filter((t) => t.exec === exec).map(factOf), loose: exec === last ? loose : [] });
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
/** What a call of a recovered script came to, as its line tells it. A result or an error it quotes is the one the script was
|
|
301
|
+
* handed live: held to the bound for the session's model as the bridge holds it (`boundResult` at `budget`); the
|
|
302
|
+
* session's record keeps it whole. */
|
|
303
|
+
const describeCall = (fact, label, budget) => {
|
|
304
|
+
const settled = settle(fact);
|
|
305
|
+
const shows = outcomeShown(fact);
|
|
306
|
+
const told = (head, text, tail) => ({ head, text: boundResult(text, budget).text, tail, callId: fact.callId, shows });
|
|
307
|
+
if (settled.kind === "parked")
|
|
308
|
+
return { head: `${label} was waiting for a person's approval and did not run; it was not run again.`, tail: "" };
|
|
309
|
+
const again = fact.resumed;
|
|
310
|
+
if (again && !again.ran)
|
|
311
|
+
return told(`${label} waited for a person's approval, then: `, again.text, ". It did not run.");
|
|
312
|
+
if (again && again.isError)
|
|
313
|
+
return told(`${label} waited for a person's approval, then ran and failed: `, again.text, ". It was not run again.");
|
|
314
|
+
if (again)
|
|
315
|
+
return told(`${label} waited for a person's approval, then ran: `, again.text, ". Its effect is done; it was not run again.");
|
|
316
|
+
if (settled.kind === "completed")
|
|
317
|
+
return told(`${label} completed: `, settled.text, ". Its effect is done; it was not run again.");
|
|
318
|
+
if (settled.kind === "failed")
|
|
319
|
+
return told(`${label} failed: `, settled.text, ". It was not run again.");
|
|
320
|
+
// Told as the recovery note of the same turn tells it, which reaches the model with this output: a safe tool's call a crash cut off.
|
|
321
|
+
if (fact.told === "retryable")
|
|
322
|
+
return { head: `${label} was started and did not report a result. It is safe to repeat. It was not run again.`, tail: "" };
|
|
323
|
+
return { head: `${label} was started and did not report a result, so it may have taken effect: check before calling it again. It was not run again.`, tail: "" };
|
|
324
|
+
};
|
|
325
|
+
/** Whether a recovered script's output tells what the call came to, its result or its error (a call that waited for a person's
|
|
326
|
+
* approval, then was answered, included): the recovery note then says the outcome is there, not that it is not shown. */
|
|
327
|
+
export function outcomeShown(fact) {
|
|
328
|
+
if (fact.resumed)
|
|
329
|
+
return true;
|
|
330
|
+
const kind = settle(fact).kind;
|
|
331
|
+
return kind === "completed" || kind === "failed";
|
|
332
|
+
}
|
|
333
|
+
/** The output a cut-off `exec` is answered with: its nested calls, in order, each with what it came to, and that nothing was run
|
|
334
|
+
* again. A completed call's effect is done, a never tool's included; a call with no end is interrupted. `loose`: calls of this turn
|
|
335
|
+
* whose script could not be told (given to the last cut-off exec only), listed apart under their own heading. */
|
|
336
|
+
/** What a dangling `wait` on a yielded exec's cell is told when calls of that script that waited for a person's approval
|
|
337
|
+
* were answered on this resume (code-mode.ts recoverItems): each call's outcome, in order. */
|
|
338
|
+
export function waitResumedText(cell, resumed, budget) {
|
|
339
|
+
return waitResumed(cell, resumed, budget).output;
|
|
340
|
+
}
|
|
341
|
+
/** waitResumedText, and the calls whose outcome it tells. */
|
|
342
|
+
export function waitResumed(cell, resumed, budget) {
|
|
343
|
+
const told = resumed.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}`, budget));
|
|
344
|
+
return fitted(told, (cap) => `${waitCutOpener(cell)}${told.map((t) => lineOf(t, cap)).join("\n")}\nNothing else of the script was run again. Check the actual state before relying on it.${declinedTail(resumed)}`, budget);
|
|
345
|
+
}
|
|
346
|
+
/** What follows the outcomes when a person declined one of the calls: their answer, not a failure to work around. Without
|
|
347
|
+
* it, a model told its script was cut off read the refusal as the stop's and made the same call again, asking the person
|
|
348
|
+
* the same question until they cancelled. */
|
|
349
|
+
const DECLINED_TAIL = "\nA refused call (a person declined it, or a setting on this server denies it) is an answer, not a failure: don't make it again. Finish without it, or say what you needed it for.";
|
|
350
|
+
const declinedTail = (facts) => (facts.some((fact) => fact.resumed && !fact.resumed.ran) ? DECLINED_TAIL : "");
|
|
351
|
+
/** The words a resumed `wait`'s output opens with (waitResumed): the model is told its cell's script went with the session. */
|
|
352
|
+
const waitCutOpener = (cell) => `The session stopped while waiting on cell ${cell}; that cell's script was cut off. Its calls that waited for a person's approval were answered since, each once:\n`;
|
|
353
|
+
/** The words a cut-off `exec`'s output opens with when it lists its own calls (execRecovery). */
|
|
354
|
+
const EXEC_CUT_OPENER = "The exec was cut short after these calls (the session stopped), and nothing was run again. Their outcomes, in order:\n";
|
|
355
|
+
/** The words a recovered `exec`'s output opens with when the session stopped for a person's approval of one of its calls
|
|
356
|
+
* (a call of it was resumed): the stop was the wait for their answer, never a crash to retry past. */
|
|
357
|
+
const EXEC_ANSWERED_OPENER = "The exec stopped at a call that waited for a person's approval, and its script did not go on after their answer; nothing was run again. Its calls' outcomes, in order:\n";
|
|
358
|
+
/** What the host's row of an `exec` a recovery answered shows: the model is told its script was cut short, but on the record
|
|
359
|
+
* those words belong to an exec that failed (recoveredFailed). One that ended ok shows its calls' outcomes alone. */
|
|
360
|
+
export function recoveredRowText(output, failed) {
|
|
361
|
+
if (failed)
|
|
362
|
+
return output;
|
|
363
|
+
const cell = /^The session stopped while waiting on cell (\S+);/.exec(output)?.[1];
|
|
364
|
+
const openers = cell === undefined ? [EXEC_ANSWERED_OPENER, EXEC_CUT_OPENER] : [waitCutOpener(cell)];
|
|
365
|
+
const opener = openers.find((o) => output.startsWith(o));
|
|
366
|
+
return opener ? output.slice(opener.length) : output;
|
|
367
|
+
}
|
|
368
|
+
/** Whether a cut-off `exec` answered with its recovered output (execRecovery) failed, by the rule a codemode script stopped
|
|
369
|
+
* and run again follows on every other harness (serve's runner/meta-tools.ts endedWith): it failed when its last call did
|
|
370
|
+
* not run (a person refused it, or a park was never answered), was cut off before it reported, or failed; or when it made
|
|
371
|
+
* no call of its own. A script whose last call ran and answered (one that parked and was allowed, too) was stopped and
|
|
372
|
+
* resumed, not failed. `own`: its calls, in order. */
|
|
373
|
+
export function recoveredFailed(own) {
|
|
374
|
+
const last = own.at(-1);
|
|
375
|
+
if (!last)
|
|
376
|
+
return true;
|
|
377
|
+
if (last.resumed)
|
|
378
|
+
return !last.resumed.ran || last.resumed.isError;
|
|
379
|
+
return settle(last).kind !== "completed";
|
|
380
|
+
}
|
|
381
|
+
export function execRecoveryOutput(facts, loose = [], budget) {
|
|
382
|
+
return execRecovery(facts, loose, budget).output;
|
|
383
|
+
}
|
|
384
|
+
/** execRecoveryOutput, and the calls whose outcome it tells: only those the recovery note may say are above. */
|
|
385
|
+
export function execRecovery(facts, loose = [], budget) {
|
|
386
|
+
if (facts.length === 0 && loose.length === 0)
|
|
387
|
+
return { output: `The exec was cut short before any tool call of it was recorded; it ran none. Run it again if it is still needed.`, shown: [] };
|
|
388
|
+
const own = facts.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}`, budget));
|
|
389
|
+
const others = loose.map((fact, i) => describeCall(fact, `${i + 1}. ${fact.tool}`, budget));
|
|
390
|
+
return fitted([...own, ...others], (cap) => {
|
|
391
|
+
const apart = others.length
|
|
392
|
+
? `\n${others.length} ${others.length === 1 ? "call" : "calls"} ran whose script could not be told (an answer of the model's could not be read to its end):\n${others.map((t) => lineOf(t, cap)).join("\n")}`
|
|
393
|
+
: "";
|
|
394
|
+
if (own.length === 0)
|
|
395
|
+
return `The exec was cut short, and no call of its own was recorded; the calls below ran, though which script made them could not be told, so do not run it again to find out.${apart}${declinedTail(loose)}`;
|
|
396
|
+
return `${facts.some((fact) => fact.resumed) ? EXEC_ANSWERED_OPENER : EXEC_CUT_OPENER}${own.map((t) => lineOf(t, cap)).join("\n")}${apart}${declinedTail([...facts, ...loose])}`;
|
|
397
|
+
}, budget);
|
|
398
|
+
}
|
|
399
|
+
/** The text of a tool's recorded output (a string, or `{ text }` with images). */
|
|
400
|
+
export function outputTextOf(output) {
|
|
401
|
+
if (typeof output === "string")
|
|
402
|
+
return output;
|
|
403
|
+
if (output && typeof output === "object" && typeof output.text === "string")
|
|
404
|
+
return output.text;
|
|
405
|
+
return JSON.stringify(output ?? null);
|
|
406
|
+
}
|
|
407
|
+
const canonical = (value) => Array.isArray(value) ? value.map(canonical) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => (a < b ? -1 : 1)).map(([k, v]) => [k, canonical(v)])) : value;
|
|
408
|
+
/** A call by its tool and arguments, whatever the order of the arguments' keys: what a `never` tool's call is matched on. */
|
|
409
|
+
export const callKey = (tool, args) => `${tool}\0${JSON.stringify(canonical(args ?? {}))}`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** An image as a host tool returns it. */
|
|
2
|
+
export type ToolImageShape = {
|
|
3
|
+
readonly mimeType?: unknown;
|
|
4
|
+
readonly data?: unknown;
|
|
5
|
+
};
|
|
6
|
+
/** Why a tool's images can't be sent, naming the tool and the image, or undefined. */
|
|
7
|
+
export declare function toolImageProblems(tool: string, images: readonly ToolImageShape[]): string | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// A host tool's images, checked before Codex's model is sent them, by the rule claude-agent's adapter holds them to
|
|
2
|
+
// (toolImageProblems there): a type the model takes, written as image/<subtype> with no parameters, and base64. Pure and
|
|
3
|
+
// self-contained, so it can move to the kernel's tool answer unchanged.
|
|
4
|
+
/** image/<subtype>: no parameter (no ';'), nothing else. */
|
|
5
|
+
const IMAGE_TYPE = /^image\/[a-z0-9.+-]+$/i;
|
|
6
|
+
const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
7
|
+
/** Why a tool's images can't be sent, naming the tool and the image, or undefined. */
|
|
8
|
+
export function toolImageProblems(tool, images) {
|
|
9
|
+
for (const [i, image] of images.entries()) {
|
|
10
|
+
const at = `the tool ${tool}'s image ${i + 1}`;
|
|
11
|
+
const type = image?.mimeType;
|
|
12
|
+
if (typeof type !== "string" || !IMAGE_TYPE.test(type))
|
|
13
|
+
return `${at} is ${String(type).slice(0, 40)}, not an image type the model takes (image/<type>, no parameters)`;
|
|
14
|
+
if (typeof image.data !== "string" || !BASE64.test(image.data))
|
|
15
|
+
return `${at} is not base64`;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A call Codex made and never got an output for: its own call id, the host's tool name and the arguments the model gave. */
|
|
2
|
+
export type DanglingCall = {
|
|
3
|
+
readonly callId: string;
|
|
4
|
+
readonly tool: string;
|
|
5
|
+
readonly args: unknown;
|
|
6
|
+
};
|
|
7
|
+
/** The bridge's answer for a call: its text, and whether it failed (or was interrupted or refused). */
|
|
8
|
+
export type CallOutcome = {
|
|
9
|
+
readonly text: string;
|
|
10
|
+
readonly isError: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** The host's calls Codex made and never got an output for, in the order it made them. */
|
|
13
|
+
export declare function danglingCalls(lines: readonly string[]): DanglingCall[];
|
|
14
|
+
/** The next paginated record number. Old unnumbered journals keep their format; a partly numbered or invalid journal
|
|
15
|
+
* cannot establish append order and is refused, never repaired. Call before dispatching any resumed host effect too. */
|
|
16
|
+
export declare function nextRolloutOrdinal(lines: readonly string[]): number | undefined;
|
|
17
|
+
/** `lines` with the dangling call `callId` given `outcome`: one `function_call_output` line after the last, its output the
|
|
18
|
+
* bridge's text (Codex's rollout keeps no failure flag for a function's output: a failure or refusal is in its words).
|
|
19
|
+
* Throws when the call does not dangle: an answered call is never rewritten. */
|
|
20
|
+
export declare function settleCall(lines: readonly string[], callId: string, outcome: CallOutcome, now?: number): string[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Codex's transcript rewrite for a resumed run. Written for AgentRun.
|
|
2
|
+
//
|
|
3
|
+
// Codex's transcript is its thread's rollout, mirrored line by line into the session's records (rollout.ts) and written
|
|
4
|
+
// back into an empty CODEX_HOME when its next app-server starts, which resumes the thread from it. A call of the host's
|
|
5
|
+
// tools that Codex made and never got an output for is a dangling call. The resume's shared decision settles each one
|
|
6
|
+
// through the kernel's tool bridge first, under the call's own id: a call with no intent goes gate, intent, run, result;
|
|
7
|
+
// a call with an intent is never run again. This file only writes the outcome the bridge answered into the rollout, as
|
|
8
|
+
// Codex records a call's output itself: a `function_call_output` line, after the last; nothing before it changes. Codex
|
|
9
|
+
// then resumes the thread from the rewritten rollout, and the call reads as answered.
|
|
10
|
+
//
|
|
11
|
+
// Only the host's own tools: the session's dynamic tools, which the thread's `session_meta` lists. Codex's own calls
|
|
12
|
+
// (code mode's `exec`, its `apply_patch`, a built-in) never went through the bridge, and the harness's own recovery
|
|
13
|
+
// answers those.
|
|
14
|
+
import { parseLine } from './rollout.js';
|
|
15
|
+
const isPlain = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
+
/** The host's tool names the thread was started with (its `session_meta`'s dynamic tools); none with no `session_meta` first. */
|
|
17
|
+
function hostTools(lines) {
|
|
18
|
+
const first = lines[0] === undefined ? undefined : parseLine(lines[0]);
|
|
19
|
+
const tools = first?.type === 'session_meta' ? first.payload?.dynamic_tools : undefined;
|
|
20
|
+
return new Set(Array.isArray(tools) ? tools.flatMap((tool) => (isPlain(tool) && typeof tool.name === 'string' ? [tool.name] : [])) : []);
|
|
21
|
+
}
|
|
22
|
+
/** The host's calls Codex made and never got an output for, in the order it made them. */
|
|
23
|
+
export function danglingCalls(lines) {
|
|
24
|
+
const tools = hostTools(lines);
|
|
25
|
+
const calls = new Map();
|
|
26
|
+
for (const raw of lines) {
|
|
27
|
+
const line = parseLine(raw);
|
|
28
|
+
const p = line?.type === 'response_item' ? line.payload : undefined;
|
|
29
|
+
if (!p || typeof p.call_id !== 'string')
|
|
30
|
+
continue;
|
|
31
|
+
if (p.type === 'function_call' && typeof p.name === 'string' && tools.has(p.name)) {
|
|
32
|
+
let args = {};
|
|
33
|
+
try {
|
|
34
|
+
args = typeof p.arguments === 'string' && p.arguments ? JSON.parse(p.arguments) : {};
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
args = {};
|
|
38
|
+
}
|
|
39
|
+
calls.set(p.call_id, { callId: p.call_id, tool: p.name, args });
|
|
40
|
+
}
|
|
41
|
+
else if (p.type === 'function_call_output')
|
|
42
|
+
calls.delete(p.call_id);
|
|
43
|
+
}
|
|
44
|
+
return [...calls.values()];
|
|
45
|
+
}
|
|
46
|
+
/** The next paginated record number. Old unnumbered journals keep their format; a partly numbered or invalid journal
|
|
47
|
+
* cannot establish append order and is refused, never repaired. Call before dispatching any resumed host effect too. */
|
|
48
|
+
export function nextRolloutOrdinal(lines) {
|
|
49
|
+
const parsed = lines.map(parseLine);
|
|
50
|
+
if (!parsed.some((line) => line !== undefined && Object.hasOwn(line, 'ordinal')))
|
|
51
|
+
return undefined;
|
|
52
|
+
let previous = -1;
|
|
53
|
+
for (const line of parsed) {
|
|
54
|
+
const ordinal = line?.ordinal;
|
|
55
|
+
if (typeof ordinal !== 'number' || !Number.isSafeInteger(ordinal) || ordinal < 0 || ordinal <= previous) {
|
|
56
|
+
throw new Error('Codex rollout ordinal order is missing or invalid; retained records require review before resuming.');
|
|
57
|
+
}
|
|
58
|
+
previous = ordinal;
|
|
59
|
+
}
|
|
60
|
+
if (previous === Number.MAX_SAFE_INTEGER)
|
|
61
|
+
throw new Error('Codex rollout ordinal cannot be safely advanced; retained records require review before resuming.');
|
|
62
|
+
return previous + 1;
|
|
63
|
+
}
|
|
64
|
+
/** `lines` with the dangling call `callId` given `outcome`: one `function_call_output` line after the last, its output the
|
|
65
|
+
* bridge's text (Codex's rollout keeps no failure flag for a function's output: a failure or refusal is in its words).
|
|
66
|
+
* Throws when the call does not dangle: an answered call is never rewritten. */
|
|
67
|
+
export function settleCall(lines, callId, outcome, now = Date.now()) {
|
|
68
|
+
if (!danglingCalls(lines).some((call) => call.callId === callId))
|
|
69
|
+
throw new Error(`Codex's rollout has no call ${callId} of the host's that it made and never got an output for`);
|
|
70
|
+
const ordinal = nextRolloutOrdinal(lines);
|
|
71
|
+
const output = JSON.stringify({ timestamp: new Date(now).toISOString(), ...(ordinal === undefined ? {} : { ordinal }), type: 'response_item', payload: { type: 'function_call_output', call_id: callId, output: outcome.text } });
|
|
72
|
+
return [...lines, output];
|
|
73
|
+
}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CodexNotInstalled, CodexPinMismatch } from "./versions.js";
|
|
2
|
+
export interface CodexPins {
|
|
3
|
+
/** The release `codex --version` must report. */
|
|
4
|
+
version: string;
|
|
5
|
+
/** The binary's sha256; unchecked when undefined (a target the pins do not list). */
|
|
6
|
+
sha256?: string;
|
|
7
|
+
/** The platform package's version (`<version>-<platform>`), when the binary came from one. */
|
|
8
|
+
packageVersion?: string;
|
|
9
|
+
/** The code-mode host's sha256 (CODE_MODE_HOST_SHA256), checked wherever Codex finds it (codeModeHostOf). Undefined
|
|
10
|
+
* (a target the pins do not list) refuses the binary: no host Codex would run is unchecked. `null` leaves the host
|
|
11
|
+
* unchecked, for a caller that names its own pins and runs no code-mode model. */
|
|
12
|
+
hostSha256?: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** The pins for this platform's binary. */
|
|
15
|
+
export declare function codexPins(target?: {
|
|
16
|
+
target: string;
|
|
17
|
+
pkg: string;
|
|
18
|
+
} | undefined): CodexPins;
|
|
19
|
+
/** The code-mode host Codex at `codex` runs, as Codex finds it (codex-rs install-context, code_mode_host_program), from
|
|
20
|
+
* its own executable's real path: in its package's layout (a codex-package.json in the folder above its own), the
|
|
21
|
+
* package's `codex-resources/codex-code-mode-host` when that is a file; else, and with no codex-package.json, the
|
|
22
|
+
* `codex-code-mode-host` beside Codex. */
|
|
23
|
+
export declare function codeModeHostOf(codex: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* The binary at `found.path` checked against `pins`, in order: the platform package's version, the binary's sha256,
|
|
26
|
+
* the sha256 of each code-mode host it could run (codeModeHostOf, from its real path; none pinned for the platform is a
|
|
27
|
+
* refusal), then the version it reports. Returns the path, or the typed error (not thrown) naming the pin, what was expected and
|
|
28
|
+
* what was found. No path, or a binary that cannot be read or run, is `CodexNotInstalled`. The path is made absolute
|
|
29
|
+
* first, from this process's working directory, and that is the one checked and returned: a session starts the binary
|
|
30
|
+
* from its own directory, where a relative `CODEX_BIN` names nothing. The sha256 is read a chunk at a time, never the
|
|
31
|
+
* whole binary in memory, and a check that passed holds for this process while the binary and each code-mode host stay
|
|
32
|
+
* the same files, unchanged (the kernel's checkedOnce, keyed by the hosts too): a host that checks it for each model it resolves, and a run's process that makes its
|
|
33
|
+
* adapter, check it once. Its reads hold the event loop: a host checks with verifyCodexBinaryAsync first.
|
|
34
|
+
*/
|
|
35
|
+
export declare function verifyCodexBinary(found: {
|
|
36
|
+
path: string;
|
|
37
|
+
packageVersion?: string;
|
|
38
|
+
} | undefined, pins?: CodexPins): {
|
|
39
|
+
path: string;
|
|
40
|
+
} | CodexPinMismatch | CodexNotInstalled;
|
|
41
|
+
/** verifyCodexBinary without holding the event loop (the kernel's checkedOnceAsync), its pass kept for it too. */
|
|
42
|
+
export declare function verifyCodexBinaryAsync(found: {
|
|
43
|
+
path: string;
|
|
44
|
+
packageVersion?: string;
|
|
45
|
+
} | undefined, pins?: CodexPins): Promise<{
|
|
46
|
+
path: string;
|
|
47
|
+
} | CodexPinMismatch | CodexNotInstalled>;
|
|
48
|
+
/** This machine's Codex checked against the pins: its path, or the typed error thrown. */
|
|
49
|
+
export declare function verifyCodex(found?: {
|
|
50
|
+
path: string;
|
|
51
|
+
packageVersion?: string;
|
|
52
|
+
} | undefined, pins?: CodexPins): {
|
|
53
|
+
path: string;
|
|
54
|
+
};
|
|
55
|
+
/** verifyCodex without holding the event loop: what a host awaits before it makes the adapter, whose own check then
|
|
56
|
+
* answers from what this kept. */
|
|
57
|
+
export declare function verifyCodexAsync(found?: {
|
|
58
|
+
path: string;
|
|
59
|
+
packageVersion?: string;
|
|
60
|
+
} | undefined, pins?: CodexPins): Promise<{
|
|
61
|
+
path: string;
|
|
62
|
+
}>;
|