@parcha/agentrun-harness-codex 0.1.0-beta.35 → 0.1.0-beta.37
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 +28 -0
- package/README.md +7 -2
- package/dist/adapter.js +9 -4
- package/dist/code-mode.d.ts +26 -8
- package/dist/code-mode.js +50 -12
- package/dist/harness.d.ts +1 -1
- package/dist/harness.js +1 -1
- package/dist/host/machine.d.ts +3 -0
- package/dist/host/machine.js +1 -1
- package/dist/host/policy.d.ts +5 -0
- package/dist/host/policy.js +59 -42
- package/dist/host/process.d.ts +12 -7
- package/dist/host/process.js +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/rollout.d.ts +0 -8
- package/dist/rollout.js +0 -16
- package/dist/scripts.d.ts +2 -1
- package/dist/scripts.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.37 (2026-11-13)
|
|
6
|
+
|
|
7
|
+
- Every harness sees a desktop or a phone through one surface: the tools `computer_observe`, `computer_act`, `computer_screenshot` and `computer_script`, the same answers from a script, an MCP client or a tool call. Breaking: the `desktop_*` and `phone_*` tools are gone, replaced by the `computer_*` tools (a desktop's and a phone's alike, held to the `desktop` or `phone` setting), and the script API's `apps.open(id)` returns nothing; bind the app with `computer.app(id)`.
|
|
8
|
+
- `computer_script` runs JavaScript in an isolate in serve whose only binding is `computer` (no network, no keys, no timers); its types are `spec/computer/computer.d.ts`, generated with the tools' schemas by `scripts/generate-computer-surface.mjs` (`--check` in CI). A model reads them compactly (no comments, one line a declaration); `computer_act`'s schema types its steps with no words, and its description declares them as TypeScript.
|
|
9
|
+
- A script's `computer.shell` and `computer.files` are held to the run's tool settings as the `bash`, `write` and `read` tools are (a deny or a read-only bash policy refuses inside the script; a setting that asks refuses, since a script can't wait for a person), and a refused step throws in the script, so the steps after it never run. Without the ui group a scroll goes as wheel clicks (about 120 pixels each), which every driver takes.
|
|
10
|
+
- pi offers its code mode (`codemode`) beside its tools with a desktop or a phone, `computer` bound in its scripts; the call is held to the computer kind's setting.
|
|
11
|
+
- In Codex's code mode a script's call of a computer tool answers the tool's value as JSON, its images' data in it; any other tool answers its words and a line saying its images were not sent (in code mode an image reaches a script only as text). A call a script repeats after a restart, of a computer tool that completed, gets that same JSON again.
|
|
12
|
+
- agentrun-serve's `computerMcp` serves a run's computer tools to an MCP client, each answer with `structuredContent`.
|
|
13
|
+
- The desktop-computer and phone-computer skills teach the route: observe, act by ref, check, and one script for steps already known.
|
|
14
|
+
- A web search on a GPT-6 model (gpt-6-luna, gpt-6.1-sol, gpt-6.1-terra) is booked at OpenAI's $0.01 a call, as on GPT-5. Before, its search had no known price. A pi run's native web_search on a GPT-6 model under any spend cap was refused before it was sent ("the size of the next model request's input is unknown, so the run's cap cannot be kept"). A Codex run with `webSearch: "live"`, or an uncapped pi run, booked an unknown cost for any response that searched.
|
|
15
|
+
- A web_search setting of deny or ask now applies to a Claude Code or Codex run's own web search at its next search, including a run that started while it was allow. Before, the setting was read only when the run started, so a run that started with native search kept searching after the setting changed.
|
|
16
|
+
- Claude Code: each WebSearch asks the run's gate before it runs, as a host tool's call does. A deny refuses it in the gate's words. An ask parks the run on the person with nothing searched; once they allow it, the model's next search with the same query runs once, with no second card.
|
|
17
|
+
- Codex: its search runs inside the provider's model request, so its proxy reads web_search's setting before each request and offers the provider its search only while the setting is allow. A failed read offers no search.
|
|
18
|
+
- `SessionIO.permission(tool)` (agentrun-kernel) is the host's setting for a harness's own tool at the time of the read. The runner reads it from the store each time. `ProviderPolicy.apply` may return a promise.
|
|
19
|
+
- A runner run whose plane resolves web_search to native now gets the harness's own search (#2458). The runner had built the run's environment without its plane, so Claude Code and Codex runs on a runner never had it on.
|
|
20
|
+
- A web_search that resolves to the model provider's own search works again on the runner for pi (#2458). It used to answer "web_search has no model to search on" every time:
|
|
21
|
+
- A pi run's own web_search on an Anthropic or OpenAI model. That is what `auto` picks for pi, and `native` too. Each search now goes through the run's model proxy with the provider's search tool, and its searches are booked at the provider's price on top of its tokens.
|
|
22
|
+
- A learned workflow's call node whose web_search resolves native, on any harness.
|
|
23
|
+
|
|
24
|
+
Each run's search uses that run's own model route, never one shared by the whole process. Hand-written workflow agents were not affected: their web_search never resolves native. Both harness packages now export their `withWebSearches` price wrapper, and the Codex one its `webSearchUsd`. A claude-agent or codex run's own search is not switched on by this change.
|
|
25
|
+
|
|
26
|
+
A capped run holds a hosted search's fees with its tokens before the request is sent, at the most searches the request allows, so the fees can't pass the cap. The kernel's model proxy takes a policy's `feeMaxUsd(body)` and holds it as the request's `feeUsd`; a fee it can't bound leaves the request unmeasured. The proxy also hands `usageOf` the sent body as a second argument, so a pi request on OpenAI's Responses that offered no search reads 0 searches from its body, even when its answer names a search call.
|
|
27
|
+
|
|
28
|
+
## 0.1.0-beta.36 (2026-11-13)
|
|
29
|
+
|
|
30
|
+
- Model defaults move to the current models. The OpenAI default (and OpenRouter's, for pi, codex and opencode) is now gpt-6.1-sol, where OpenRouter's was gpt-6-sol. The Claude Agent adapter's default is now claude-sonnet-5-5 (was claude-sonnet-4-5) and the Codex adapter's is openai/gpt-6-luna (was openai/gpt-5.4-mini). A host that relied on a default names its model; the READMEs' examples name the current ones.
|
|
31
|
+
- The two harness adapters list `@parcha/agentrun-dsl` as a dev dependency, since only their tests import it, and serve's package keywords drop the retired `pi-durable`.
|
|
32
|
+
|
|
5
33
|
## 0.1.0-beta.35 (2026-11-11)
|
|
6
34
|
|
|
7
35
|
- A capped run that reads screenshots is no longer refused at its cap after the first one. A model request's input bound counted an image's base64 as one token per byte, and then the image's billed maximum on top. A 1280x720 screenshot (about a megabyte of base64) read as some 1.3 million input tokens, so a Sonnet step under a $1.50 cap "needed at least $4.83" when Claude bills it a few cents.
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ import { codexAdapter } from "@parcha/agentrun-harness-codex";
|
|
|
9
9
|
|
|
10
10
|
const runNode = createHarnessRunner(
|
|
11
11
|
codexAdapter({
|
|
12
|
-
model: "gpt-
|
|
12
|
+
model: "gpt-6-luna",
|
|
13
13
|
provider: { origin: "https://api.openai.com", credential: () => process.env.OPENAI_API_KEY! },
|
|
14
14
|
sessionsDir: "/var/lib/my-host/codex-sessions",
|
|
15
15
|
}),
|
|
@@ -22,7 +22,12 @@ const runNode = createHarnessRunner(
|
|
|
22
22
|
is not sent, so the model is never told its files are read-only while the host's tools write them
|
|
23
23
|
(`test/developer-messages.test.mjs`). A classic model is offered exactly the host's tools (and the runner's
|
|
24
24
|
`submit`); a code-mode model is offered code mode's `exec` and `wait`, whose runtime has no Node modules, no process and no network, and
|
|
25
|
-
reaches the host's tools by their own names, as nested calls of the script it writes.
|
|
25
|
+
reaches the host's tools by their own names, as nested calls of the script it writes. A nested call of a computer tool
|
|
26
|
+
answers the tool's value as JSON text, its images' data in it, for the script to `JSON.parse`; any other tool answers
|
|
27
|
+
its words and a line saying how many images it returned were not sent, since in code mode an image reaches a script only
|
|
28
|
+
as text (`test/code-mode-images-taken.test.mjs`). Codex's runtime takes no
|
|
29
|
+
binding of ours, so a script that wants the `computer` object itself calls `computer_script`, which runs in the host's
|
|
30
|
+
isolate with `computer` bound. The proxy passes `exec` and
|
|
26
31
|
`wait` and drops the sub-agent and user-input tools Codex lists beside them; it keeps parallel tool calls off for a
|
|
27
32
|
code-mode request, and offers no `exec` while a script that yielded still runs, so one script is live at a time. A
|
|
28
33
|
nested call has an id of Codex's own (`exec-<uuid>`) that no line of the rollout carries and that names no `exec`, so
|
package/dist/adapter.js
CHANGED
|
@@ -59,14 +59,16 @@ export function kernelTool(tool) {
|
|
|
59
59
|
await markParked(io.ctx, callId);
|
|
60
60
|
if (result.isError)
|
|
61
61
|
throw new Error(result.text);
|
|
62
|
+
// A computer tool's value, recorded with the outcome: a script's nested call is answered it (code-mode.ts scriptAnswer).
|
|
63
|
+
const structured = result.structured !== undefined ? { structured: result.structured } : {};
|
|
62
64
|
if (!result.images?.length)
|
|
63
|
-
return result.text;
|
|
65
|
+
return result.structured === undefined ? result.text : { text: result.text, ...structured };
|
|
64
66
|
// An image the model can't be sent is the call's error, by the tool's name and the image, not a request refused later.
|
|
65
67
|
const wrong = toolImageProblems(tool.name, result.images);
|
|
66
68
|
if (wrong)
|
|
67
69
|
throw new Error(wrong);
|
|
68
70
|
// With its images, recorded with the outcome: the answer to Codex carries them after the text (code-mode.ts withImages).
|
|
69
|
-
return { text: result.text, images: result.images.map((image) => ({ mimeType: image.mimeType, data: image.data })) };
|
|
71
|
+
return { text: result.text, images: result.images.map((image) => ({ mimeType: image.mimeType, data: image.data })), ...structured };
|
|
70
72
|
},
|
|
71
73
|
};
|
|
72
74
|
}
|
|
@@ -161,6 +163,9 @@ export function codexAdapter(options) {
|
|
|
161
163
|
// With skills the model also reads their files (read_skill_file), from the session's own copy of them.
|
|
162
164
|
const tools = skills.length ? [...spec.tools, hostedTool(io, readSkillFileTool(join(sessionDir(dir, "codex-home"), SKILLS_DIR), skills.map((skill) => ({ name: skill.name, files: Object.keys(skill.files) }))))] : spec.tools;
|
|
163
165
|
const effort = spec.effort ?? spec.thinking;
|
|
166
|
+
// The live search runs inside a model request, where no call reaches the gate: it is offered only while the host's
|
|
167
|
+
// web_search setting allows it, read before each request (a deny or ask set mid-run drops it from the next one).
|
|
168
|
+
const searchAllowed = options.webSearch && io.permission ? async () => (await io.permission("web_search")) === "allow" : undefined;
|
|
164
169
|
const harnessOptions = {
|
|
165
170
|
tools: tools.map(kernelTool),
|
|
166
171
|
// The host's gate, asked about each host-tool call before its intent is written.
|
|
@@ -192,7 +197,7 @@ export function codexAdapter(options) {
|
|
|
192
197
|
// The built-ins are off: Codex's own apply_patch, with no environment to run in, is offered to no model
|
|
193
198
|
// (catalog.ts). A stand-in runs no Codex, so it has no catalog to read.
|
|
194
199
|
...(checked !== undefined ? { catalog: { command: checked, ...(options.log ? { log: options.log } : {}) } } : {}),
|
|
195
|
-
...(options.webSearch ? { webSearch: options.webSearch } : {}),
|
|
200
|
+
...(options.webSearch ? { webSearch: options.webSearch, ...(searchAllowed ? { searchAllowed } : {}) } : {}),
|
|
196
201
|
// A granted MCP server's tools: Codex's own MCP client calls them at the proxy (mcp.ts).
|
|
197
202
|
...(spec.mcp?.servers.length ? { mcp: spec.mcp } : {}),
|
|
198
203
|
proxy: {
|
|
@@ -275,7 +280,7 @@ export function codexAdapter(options) {
|
|
|
275
280
|
// Started once the session's drive is open, the last step that can fail: an open that fails leaves no listener.
|
|
276
281
|
const search = options.webSearch === "live";
|
|
277
282
|
const hostPort = await startModelProxy({
|
|
278
|
-
policy: codexPolicy({ model: modelFor(spec), tools: [], ...(options.maxOutputTokens ? { maxOutputTokens: options.maxOutputTokens } : {}), ...(search ? { webSearch: "live" } : {}) }),
|
|
283
|
+
policy: codexPolicy({ model: modelFor(spec), tools: [], ...(options.maxOutputTokens ? { maxOutputTokens: options.maxOutputTokens } : {}), ...(search ? { webSearch: "live", ...(searchAllowed ? { searchAllowed } : {}) } : {}) }),
|
|
279
284
|
hooks: io.models,
|
|
280
285
|
model: modelFor(spec),
|
|
281
286
|
origin: options.provider.origin,
|
package/dist/code-mode.d.ts
CHANGED
|
@@ -20,16 +20,19 @@ export interface CodeModeDeps {
|
|
|
20
20
|
logged: Set<string>;
|
|
21
21
|
/** Drain the rollout's tail into the log. */
|
|
22
22
|
synced(): Promise<void>;
|
|
23
|
-
/** The tool bridge; `
|
|
23
|
+
/** The tool bridge; `take` gives a call's images and value once (host/process.ts), for the answer to Codex. */
|
|
24
24
|
bridge: {
|
|
25
25
|
get(name: string): {
|
|
26
26
|
name: string;
|
|
27
27
|
replay: string;
|
|
28
28
|
} | undefined;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
take?(callId: string): {
|
|
30
|
+
images?: readonly {
|
|
31
|
+
mimeType: string;
|
|
32
|
+
data: string;
|
|
33
|
+
}[];
|
|
34
|
+
structured?: unknown;
|
|
35
|
+
} | undefined;
|
|
33
36
|
};
|
|
34
37
|
log(message: string, fields?: Record<string, unknown>): void;
|
|
35
38
|
/** The rollout lines restored from the log. */
|
|
@@ -63,10 +66,25 @@ export declare const waitStoppedText: (cell: string) => string;
|
|
|
63
66
|
/** A recorded result that held images (kernelTool's `{ text, images }`) as its text and a line saying how many, which are not
|
|
64
67
|
* shown again after the interruption; undefined for a result with none, whose repaired output stays as it is. */
|
|
65
68
|
export declare function imagesNoted(output: unknown): string | undefined;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
type Image = {
|
|
70
|
+
mimeType: string;
|
|
71
|
+
data: string;
|
|
72
|
+
};
|
|
73
|
+
/** `value` with `images`' data put back, in order, into its image objects (`{ type: "image", mimeType }` with no data,
|
|
74
|
+
* as a computer tool's value leaves them): the value whole, as serve's own script isolate gives a script. */
|
|
75
|
+
export declare function withImageData(value: unknown, images: readonly Image[]): unknown;
|
|
76
|
+
/** A nested call's answer from a tool with no value: its items, then a line saying how many images the tool returned,
|
|
77
|
+
* which are not sent (Codex gives a script an image as its data: URL in the result's text, so a script that prints the
|
|
78
|
+
* result would send the model the base64 as words); an answer of any other shape, or no images, as it is. */
|
|
69
79
|
export declare function withImagesHeld(answer: unknown, images: readonly unknown[] | undefined): unknown;
|
|
80
|
+
/** A code-mode script's nested call's answer. A tool with a value (a computer tool's) answers the value as JSON text,
|
|
81
|
+
* its images' data back in it, so the script reads it with JSON.parse and holds each image whole, to compute on or
|
|
82
|
+
* pass on; any other tool answers its words and a line on its images, which are not sent (`withImagesHeld`). A failed
|
|
83
|
+
* call's answer, or one of any other shape, as it is. */
|
|
84
|
+
export declare function scriptAnswer(answer: unknown, extras: {
|
|
85
|
+
images?: readonly Image[];
|
|
86
|
+
structured?: unknown;
|
|
87
|
+
} | undefined): unknown;
|
|
70
88
|
/** A dynamic tool call's answer with `images` after its items, each `{ type: "inputImage", imageUrl }` with a data: URL
|
|
71
89
|
* (Codex 0.164's DynamicToolCallOutputContentItem); an answer of any other shape, or no images, as it is. */
|
|
72
90
|
export declare function withImages(answer: unknown, images: readonly {
|
package/dist/code-mode.js
CHANGED
|
@@ -27,13 +27,21 @@ function endedTurnSince(state) {
|
|
|
27
27
|
export const waitStoppedText = (cell) => `The session stopped while waiting on cell ${cell}; that cell's script was cut off, and nothing was run again. Check the actual state before relying on it.`;
|
|
28
28
|
/** What the log holds of one nested call: the session's record, the rollout's completion line, and what the turn's recovery note
|
|
29
29
|
* calls it (`told`, by call id). */
|
|
30
|
+
/** What a script's nested call of a tool with a value was sent (scriptAnswer's text), from the tool's stored answer: the rollout
|
|
31
|
+
* holds that text, not the words the store keeps, so recovery compares the two. None for a tool with no value. */
|
|
32
|
+
function sentOf(output) {
|
|
33
|
+
const kept = output;
|
|
34
|
+
if (kept === null || typeof kept !== "object" || kept.structured === undefined)
|
|
35
|
+
return {};
|
|
36
|
+
return { sent: JSON.stringify(withImageData(kept.structured, kept.images ?? [])) };
|
|
37
|
+
}
|
|
30
38
|
function factOf(state, rolled, tie, told = new Map()) {
|
|
31
39
|
const e = state.effects.get(toolKey(tie.callId));
|
|
32
40
|
const status = told.get(tie.callId);
|
|
33
41
|
return {
|
|
34
42
|
callId: tie.callId,
|
|
35
43
|
tool: e ? e.name.replace(/^tool\./, "") : (rolled.get(tie.callId)?.tool ?? "a tool"),
|
|
36
|
-
...(e ? { store: { status: e.status === "completed" ? "completed" : e.status === "failed" ? "failed" : "started", text: e.status === "failed" ? (e.error?.message ?? "") : outputTextOf(e.output), ...(e.error?.interrupted ? { interrupted: true } : {}) } } : {}),
|
|
44
|
+
...(e ? { store: { status: e.status === "completed" ? "completed" : e.status === "failed" ? "failed" : "started", text: e.status === "failed" ? (e.error?.message ?? "") : outputTextOf(e.output), ...(e.status === "completed" ? sentOf(e.output) : {}), ...(e.error?.interrupted ? { interrupted: true } : {}) } } : {}),
|
|
37
45
|
...(rolled.has(tie.callId) ? { rollout: rolled.get(tie.callId) } : {}),
|
|
38
46
|
...(status ? { told: status } : {}),
|
|
39
47
|
...(state.effects.get(parkedKey(tie.callId))?.status === "completed" ? { parked: true } : {}),
|
|
@@ -48,9 +56,25 @@ export function imagesNoted(output) {
|
|
|
48
56
|
return undefined;
|
|
49
57
|
return `${outputTextOf(output)}\n\nIt also returned ${count} image${count === 1 ? "" : "s"} (not shown again after the interruption).`;
|
|
50
58
|
}
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
|
|
59
|
+
/** `value` with `images`' data put back, in order, into its image objects (`{ type: "image", mimeType }` with no data,
|
|
60
|
+
* as a computer tool's value leaves them): the value whole, as serve's own script isolate gives a script. */
|
|
61
|
+
export function withImageData(value, images) {
|
|
62
|
+
let next = 0;
|
|
63
|
+
const fill = (part) => {
|
|
64
|
+
if (Array.isArray(part))
|
|
65
|
+
return part.map(fill);
|
|
66
|
+
if (part === null || typeof part !== "object")
|
|
67
|
+
return part;
|
|
68
|
+
const record = part;
|
|
69
|
+
if (record.type === "image" && record.data === undefined && next < images.length)
|
|
70
|
+
return { ...record, data: images[next++].data };
|
|
71
|
+
return Object.fromEntries(Object.entries(record).map(([key, entry]) => [key, fill(entry)]));
|
|
72
|
+
};
|
|
73
|
+
return fill(value);
|
|
74
|
+
}
|
|
75
|
+
/** A nested call's answer from a tool with no value: its items, then a line saying how many images the tool returned,
|
|
76
|
+
* which are not sent (Codex gives a script an image as its data: URL in the result's text, so a script that prints the
|
|
77
|
+
* result would send the model the base64 as words); an answer of any other shape, or no images, as it is. */
|
|
54
78
|
export function withImagesHeld(answer, images) {
|
|
55
79
|
const items = answer?.contentItems;
|
|
56
80
|
if (!images?.length || !Array.isArray(items))
|
|
@@ -58,6 +82,16 @@ export function withImagesHeld(answer, images) {
|
|
|
58
82
|
const count = images.length;
|
|
59
83
|
return { ...answer, contentItems: [...items, { type: "inputText", text: `${count} image${count === 1 ? "" : "s"} it returned ${count === 1 ? "was" : "were"} not sent: in code mode a tool's image reaches the script only as text.` }] };
|
|
60
84
|
}
|
|
85
|
+
/** A code-mode script's nested call's answer. A tool with a value (a computer tool's) answers the value as JSON text,
|
|
86
|
+
* its images' data back in it, so the script reads it with JSON.parse and holds each image whole, to compute on or
|
|
87
|
+
* pass on; any other tool answers its words and a line on its images, which are not sent (`withImagesHeld`). A failed
|
|
88
|
+
* call's answer, or one of any other shape, as it is. */
|
|
89
|
+
export function scriptAnswer(answer, extras) {
|
|
90
|
+
const shaped = answer;
|
|
91
|
+
if (extras?.structured === undefined || !Array.isArray(shaped?.contentItems) || shaped.success === false)
|
|
92
|
+
return withImagesHeld(answer, extras?.images);
|
|
93
|
+
return { ...shaped, contentItems: [{ type: "inputText", text: JSON.stringify(withImageData(extras.structured, extras.images ?? [])) }] };
|
|
94
|
+
}
|
|
61
95
|
/** A dynamic tool call's answer with `images` after its items, each `{ type: "inputImage", imageUrl }` with a data: URL
|
|
62
96
|
* (Codex 0.164's DynamicToolCallOutputContentItem); an answer of any other shape, or no images, as it is. */
|
|
63
97
|
export function withImages(answer, images) {
|
|
@@ -141,7 +175,7 @@ export function codeMode(deps) {
|
|
|
141
175
|
if (settled.kind !== "completed")
|
|
142
176
|
continue;
|
|
143
177
|
const key = callKey(fact.tool, e.input);
|
|
144
|
-
recovered.set(key, [...(recovered.get(key) ?? []), { tool: fact.tool, text: settled.text }]);
|
|
178
|
+
recovered.set(key, [...(recovered.get(key) ?? []), { tool: fact.tool, text: settled.text, ...(fact.store?.sent !== undefined ? { sent: fact.store.sent } : {}) }]);
|
|
145
179
|
}
|
|
146
180
|
};
|
|
147
181
|
/** A `never` call the log holds a completed outcome for, re-issued after a recovery: its answer from the log, taken once. Held
|
|
@@ -151,6 +185,10 @@ export function codeMode(deps) {
|
|
|
151
185
|
if (!again)
|
|
152
186
|
return undefined;
|
|
153
187
|
deps.log("codex: answered a never call from the log: it completed before the interruption", { ...(callId ? { callId } : {}), tool: again.tool });
|
|
188
|
+
// A script's call of a tool with a value gets that value's JSON again, as the first call did (scriptAnswer): the script
|
|
189
|
+
// parses it, so no words go before it.
|
|
190
|
+
if (callId !== undefined && NESTED_CALL.test(callId) && again.sent !== undefined)
|
|
191
|
+
return again.sent;
|
|
154
192
|
return boundResult(`Recorded earlier in this turn, not run again: ${again.text}`).text;
|
|
155
193
|
}
|
|
156
194
|
/** The cell a dangling call waited on, when it is code mode's `wait` (a function call named `wait` with a `cell_id`, and no host tool of
|
|
@@ -198,19 +236,19 @@ export function codeMode(deps) {
|
|
|
198
236
|
}
|
|
199
237
|
// The harness answers with the result's text; its images follow as `inputImage` items, which Codex 0.164's
|
|
200
238
|
// dynamic tool output takes (DynamicToolCallResponse.contentItems, its app-server schema), each a data: URL.
|
|
201
|
-
// The call runs first (`next`): its images are kept by the bridge as it answers, and taken after,
|
|
202
|
-
// the answer was built, so a call whose answer throws leaves none in the bridge for the session's life.
|
|
203
|
-
let
|
|
239
|
+
// The call runs first (`next`): its images and value are kept by the bridge as it answers, and taken after,
|
|
240
|
+
// whether or not the answer was built, so a call whose answer throws leaves none in the bridge for the session's life.
|
|
241
|
+
let extras;
|
|
204
242
|
let answer;
|
|
205
243
|
try {
|
|
206
244
|
answer = await next(req);
|
|
207
245
|
}
|
|
208
246
|
finally {
|
|
209
|
-
|
|
247
|
+
extras = deps.bridge.take?.(callId);
|
|
210
248
|
}
|
|
211
|
-
// A script's nested call
|
|
212
|
-
//
|
|
213
|
-
return NESTED_CALL.test(callId) ?
|
|
249
|
+
// A script's nested call gets the tool's value, images and all, to compute on (scriptAnswer); the model's own
|
|
250
|
+
// call gets the words and the images to look at.
|
|
251
|
+
return NESTED_CALL.test(callId) ? scriptAnswer(answer, extras) : withImages(answer, extras?.images);
|
|
214
252
|
}
|
|
215
253
|
return next(req);
|
|
216
254
|
};
|
package/dist/harness.d.ts
CHANGED
|
@@ -144,7 +144,7 @@ export interface CodexMachine {
|
|
|
144
144
|
/** `sandbox({ commandTimeoutMs })`: a built-in command's longest run, within the time left in the invocation. */
|
|
145
145
|
commandTimeoutMs?: number;
|
|
146
146
|
}
|
|
147
|
-
export declare const DEFAULT_MODEL = "openai/gpt-
|
|
147
|
+
export declare const DEFAULT_MODEL = "openai/gpt-6-luna";
|
|
148
148
|
/** A Codex item's replay policy: a command whose every action reads is `safe`; any other command, and every patch, `never`. */
|
|
149
149
|
export declare function codexItemReplay(item: {
|
|
150
150
|
type?: string;
|
package/dist/harness.js
CHANGED
|
@@ -10,7 +10,7 @@ import { codeMode } from './code-mode.js';
|
|
|
10
10
|
import { danglingCalls, settleCall } from './transcript.js';
|
|
11
11
|
import { BUILTINS_ON, checkConfig, codexConfig, toToml } from './config.js';
|
|
12
12
|
import { callIdOf, endsTurn, isRolloutPath, isSessionMeta, rolloutPathIn, rolloutStream, rolloutText, summarizeRollout, THREAD_STREAM, } from './rollout.js';
|
|
13
|
-
export const DEFAULT_MODEL = 'openai/gpt-
|
|
13
|
+
export const DEFAULT_MODEL = 'openai/gpt-6-luna';
|
|
14
14
|
const SANDBOX_MODES = new Set(['read-only', 'workspace-write', 'danger-full-access']);
|
|
15
15
|
/** Codex's command actions that only read: a command made of these alone is `safe` (the note says "safe to repeat"). */
|
|
16
16
|
const READ_ACTIONS = new Set(['read', 'listFiles', 'search']);
|
package/dist/host/machine.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export interface LocalMachineOptions {
|
|
|
25
25
|
/** Codex's own web search, live: Codex's config says `web_search = "live"` (`configure`), and the proxy admits the tool
|
|
26
26
|
* Codex then sends and adds each search to the price. Default off. */
|
|
27
27
|
webSearch?: "live";
|
|
28
|
+
/** With `webSearch`: whether the host lets the session search now, asked before each request that offers it
|
|
29
|
+
* (CodexPolicyOptions.searchAllowed). */
|
|
30
|
+
searchAllowed?: () => Promise<boolean>;
|
|
28
31
|
/** The model proxy: the runner's hooks, the provider's price, and the session's tools and limits; its route comes
|
|
29
32
|
* from the harness. */
|
|
30
33
|
proxy: {
|
package/dist/host/machine.js
CHANGED
|
@@ -217,7 +217,7 @@ export function localMachine(options) {
|
|
|
217
217
|
tools: options.proxy.tools,
|
|
218
218
|
...(options.mcp ? { mcpTools: options.mcp.servers.flatMap((server) => server.tools.map((tool) => `mcp__${server.name}__${tool.name}`)) } : {}),
|
|
219
219
|
...(options.proxy.maxOutputTokens ? { maxOutputTokens: options.proxy.maxOutputTokens } : {}),
|
|
220
|
-
...(search ? { webSearch: "live" } : {}),
|
|
220
|
+
...(search ? { webSearch: "live", ...(options.searchAllowed ? { searchAllowed: options.searchAllowed } : {}) } : {}),
|
|
221
221
|
announce: {
|
|
222
222
|
// The cost is liveness, not safety: after an overlap a never call is declined until the next single answer, which the model's
|
|
223
223
|
// next wait or exec gives.
|
package/dist/host/policy.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export interface CodexPolicyOptions {
|
|
|
23
23
|
/** Codex's own web search, live: the live search tool the pinned CLI sends passes, and a `tool_choice` naming it. Each
|
|
24
24
|
* response's usage then carries the searches it ran (`webSearches`), which `withWebSearches` prices. Default off. */
|
|
25
25
|
webSearch?: "live";
|
|
26
|
+
/** With `webSearch`: whether the host lets the session search now (its web_search setting, SessionIO.permission), asked
|
|
27
|
+
* before each request that offers the live search. The provider runs a search inside the request, where no gate sees
|
|
28
|
+
* it, so a request sent while this is false (or throws) offers no search, as a session without one sends it; a
|
|
29
|
+
* `tool_choice` naming the search is then refused. Absent: the live search is offered whenever `webSearch` is on. */
|
|
30
|
+
searchAllowed?: () => Promise<boolean>;
|
|
26
31
|
/** Told, before Codex has the piece of an answer, what the answer carries: `response()` when an answer starts, and
|
|
27
32
|
* `exec(callId)` for each code-mode `exec` call it holds. The session ties a script's nested calls to the `exec` of the
|
|
28
33
|
* latest answer, which is known here before Codex can run anything of it. */
|
package/dist/host/policy.js
CHANGED
|
@@ -26,11 +26,12 @@ const isLiveSearch = (tool) => Object.keys(tool).length === Object.keys(LIVE_SEA
|
|
|
26
26
|
/**
|
|
27
27
|
* OpenAI's price of one web search call by model: "Web search (all models)", $10.00 / 1k calls, with its search content
|
|
28
28
|
* tokens billed at the model's rates in the response's own usage (https://developers.openai.com/api/docs/pricing, Tools).
|
|
29
|
+
* The GPT-6 family (gpt-6-luna, gpt-6.1-sol, gpt-6.1-terra, ...) is among "all models", as GPT-5 is.
|
|
29
30
|
* gpt-4o-mini and gpt-4.1-mini bill each call's search content as a fixed block of 8,000 input tokens instead, so they are
|
|
30
31
|
* not listed: their searches, like any model's not listed here (a gateway's own id, say), are an unknown cost, never $0.
|
|
31
32
|
*/
|
|
32
33
|
const WEB_SEARCH_USD = [
|
|
33
|
-
[/^(?:gpt-5|o3|o4-mini)(?:[-.][a-z0-9.-]+)?$/, 0.01],
|
|
34
|
+
[/^(?:gpt-6|gpt-5|o3|o4-mini)(?:[-.][a-z0-9.-]+)?$/, 0.01],
|
|
34
35
|
[/^gpt-4(?:o|\.1)(?:-\d{4}-\d{2}-\d{2})?$/, 0.01],
|
|
35
36
|
];
|
|
36
37
|
/** The price of one web search call on `model`, or undefined when it is not known. */
|
|
@@ -581,49 +582,21 @@ export function codexPolicy(options) {
|
|
|
581
582
|
},
|
|
582
583
|
authHeaders: (credential) => ({ authorization: `Bearer ${credential}` }),
|
|
583
584
|
apply(body, _route, context) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
for (const [key, value] of Object.entries(body)) {
|
|
591
|
-
if (DROPPED_KEYS.has(key))
|
|
592
|
-
continue;
|
|
593
|
-
if (!BODY_KEYS.has(key) && !(context?.host !== undefined && SIDE_KEYS.has(key)))
|
|
594
|
-
throw new ProxyRefusal(400, "the body has a field the Codex policy does not allow");
|
|
595
|
-
out[key] = value;
|
|
596
|
-
}
|
|
597
|
-
if (out.include !== undefined && (!Array.isArray(out.include) || !out.include.every((item) => typeof item === "string" && (INCLUDE.has(item) || (context?.host !== undefined && SIDE_INCLUDE.has(item)))))) {
|
|
598
|
-
throw new ProxyRefusal(400, "include asks for an item the Codex policy does not allow");
|
|
599
|
-
}
|
|
600
|
-
if (out.stream !== undefined && typeof out.stream !== "boolean")
|
|
601
|
-
throw new ProxyRefusal(400, "stream is not a boolean");
|
|
602
|
-
if (out.reasoning !== undefined && !isPlain(out.reasoning))
|
|
603
|
-
throw new ProxyRefusal(400, "reasoning is not an object");
|
|
604
|
-
if (out.text !== undefined)
|
|
605
|
-
out.text = textOptions(out.text);
|
|
606
|
-
if (out.tools !== undefined)
|
|
607
|
-
out.tools = ownTools(out.tools, own, search, mcp);
|
|
608
|
-
if (out.tool_choice !== undefined)
|
|
609
|
-
out.tool_choice = toolChoice(out.tool_choice, own, search);
|
|
610
|
-
if (Array.isArray(out.input) && out.input.some((item) => isPlain(item) && item.type === "additional_tools")) {
|
|
611
|
-
// While a script that yielded still runs, the model is offered `wait` and not `exec`: one script is live at a time.
|
|
612
|
-
const offerExec = !cellRunning(out.input);
|
|
613
|
-
out.input = out.input.map((item) => codeModeCarrier(item, offerExec));
|
|
614
|
-
// One `exec` is open at a time (the session's barrier for a code-mode call rests on it): a code-mode request that allows
|
|
615
|
-
// parallel calls is refused, and one that says nothing is sent with them off. A classic request is as the CLI sent it.
|
|
616
|
-
if (out.parallel_tool_calls !== undefined && typeof out.parallel_tool_calls !== "boolean")
|
|
617
|
-
throw new ProxyRefusal(400, "parallel_tool_calls is not a boolean");
|
|
618
|
-
if (out.parallel_tool_calls === true)
|
|
619
|
-
throw new ProxyRefusal(400, "parallel tool calls are not allowed in code mode: the model writes one exec at a time");
|
|
620
|
-
out.parallel_tool_calls = false;
|
|
621
|
-
}
|
|
622
|
-
const asked = typeof out.max_output_tokens === "number" && out.max_output_tokens > 0 ? out.max_output_tokens : maxOutputTokens;
|
|
623
|
-
return { ...out, model: options.model, store: false, max_output_tokens: Math.min(asked, maxOutputTokens) };
|
|
585
|
+
// The live search, offered by the request, goes only while the host says web_search may run now: read before this
|
|
586
|
+
// request is shaped, never once for the session. A read that fails offers none.
|
|
587
|
+
const asking = search && options.searchAllowed && isPlain(body) && Array.isArray(body.tools) && body.tools.some((tool) => isPlain(tool) && tool.type === "web_search");
|
|
588
|
+
if (!asking)
|
|
589
|
+
return shaped(body, context, search);
|
|
590
|
+
return options.searchAllowed().then((now) => shaped(body, context, now === true), () => shaped(body, context, false));
|
|
624
591
|
},
|
|
625
|
-
usageOf: search ? (text) => {
|
|
592
|
+
usageOf: search ? (text, body) => {
|
|
626
593
|
const usage = usageOf(text);
|
|
594
|
+
// A request that offered no search (`body`, the one it was sent with: a host's side request through the session's
|
|
595
|
+
// port, a learned workflow's node that offers only `submit`) ran none: 0, read from the request, never an unknown
|
|
596
|
+
// count that would make its whole known cost unknown (withWebSearches). One that offered it reads its answer.
|
|
597
|
+
const offered = Array.isArray(body?.tools) && body.tools.some((tool) => typeof tool === "object" && tool !== null && isLiveSearch(tool));
|
|
598
|
+
if (usage && body && !offered)
|
|
599
|
+
return { ...usage, webSearches: 0 };
|
|
627
600
|
return usage && { ...usage, webSearches: webSearchesOf(text) ?? null };
|
|
628
601
|
} : usageOf,
|
|
629
602
|
filtered,
|
|
@@ -645,4 +618,48 @@ export function codexPolicy(options) {
|
|
|
645
618
|
return responsesServerInputOverhead(body);
|
|
646
619
|
} : responsesServerInputOverhead,
|
|
647
620
|
};
|
|
621
|
+
/** The body the provider gets, the live search offered only when `searchNow`. */
|
|
622
|
+
function shaped(body, context, searchNow) {
|
|
623
|
+
if (!isPlain(body))
|
|
624
|
+
throw new ProxyRefusal(400, "the body is not a JSON object");
|
|
625
|
+
// The host's own request beside Codex's (ProxyRequestContext.host) offers its own client tools (a learned workflow
|
|
626
|
+
// node's `submit`); every other rule is the session's, a provider-hosted tool refused as ever.
|
|
627
|
+
const own = context?.host !== undefined ? sideToolNames(body.tools) : allowed;
|
|
628
|
+
const out = {};
|
|
629
|
+
for (const [key, value] of Object.entries(body)) {
|
|
630
|
+
if (DROPPED_KEYS.has(key))
|
|
631
|
+
continue;
|
|
632
|
+
if (!BODY_KEYS.has(key) && !(context?.host !== undefined && SIDE_KEYS.has(key)))
|
|
633
|
+
throw new ProxyRefusal(400, "the body has a field the Codex policy does not allow");
|
|
634
|
+
out[key] = value;
|
|
635
|
+
}
|
|
636
|
+
if (out.include !== undefined && (!Array.isArray(out.include) || !out.include.every((item) => typeof item === "string" && (INCLUDE.has(item) || (context?.host !== undefined && SIDE_INCLUDE.has(item)))))) {
|
|
637
|
+
throw new ProxyRefusal(400, "include asks for an item the Codex policy does not allow");
|
|
638
|
+
}
|
|
639
|
+
if (out.stream !== undefined && typeof out.stream !== "boolean")
|
|
640
|
+
throw new ProxyRefusal(400, "stream is not a boolean");
|
|
641
|
+
if (out.reasoning !== undefined && !isPlain(out.reasoning))
|
|
642
|
+
throw new ProxyRefusal(400, "reasoning is not an object");
|
|
643
|
+
if (out.text !== undefined)
|
|
644
|
+
out.text = textOptions(out.text);
|
|
645
|
+
// Without the search now, its tool is dropped as a session without one drops it (DROPPED_TOOLS).
|
|
646
|
+
if (out.tools !== undefined)
|
|
647
|
+
out.tools = ownTools(out.tools, own, searchNow, mcp);
|
|
648
|
+
if (out.tool_choice !== undefined)
|
|
649
|
+
out.tool_choice = toolChoice(out.tool_choice, own, searchNow);
|
|
650
|
+
if (Array.isArray(out.input) && out.input.some((item) => isPlain(item) && item.type === "additional_tools")) {
|
|
651
|
+
// While a script that yielded still runs, the model is offered `wait` and not `exec`: one script is live at a time.
|
|
652
|
+
const offerExec = !cellRunning(out.input);
|
|
653
|
+
out.input = out.input.map((item) => codeModeCarrier(item, offerExec));
|
|
654
|
+
// One `exec` is open at a time (the session's barrier for a code-mode call rests on it): a code-mode request that allows
|
|
655
|
+
// parallel calls is refused, and one that says nothing is sent with them off. A classic request is as the CLI sent it.
|
|
656
|
+
if (out.parallel_tool_calls !== undefined && typeof out.parallel_tool_calls !== "boolean")
|
|
657
|
+
throw new ProxyRefusal(400, "parallel_tool_calls is not a boolean");
|
|
658
|
+
if (out.parallel_tool_calls === true)
|
|
659
|
+
throw new ProxyRefusal(400, "parallel tool calls are not allowed in code mode: the model writes one exec at a time");
|
|
660
|
+
out.parallel_tool_calls = false;
|
|
661
|
+
}
|
|
662
|
+
const asked = typeof out.max_output_tokens === "number" && out.max_output_tokens > 0 ? out.max_output_tokens : maxOutputTokens;
|
|
663
|
+
return { ...out, model: options.model, store: false, max_output_tokens: Math.min(asked, maxOutputTokens) };
|
|
664
|
+
}
|
|
648
665
|
}
|
package/dist/host/process.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { toolBridge as kernelToolBridge, type ToolBridge, type ToolBridgeOptions } from "@parcha/agentrun-kernel/process";
|
|
2
|
-
import type { ToolImage } from "@parcha/agentrun-kernel";
|
|
2
|
+
import type { JsonValue, ToolImage } from "@parcha/agentrun-kernel";
|
|
3
3
|
import type { TomlValue } from "../config.js";
|
|
4
4
|
import type { DriveContext } from "./kernel.js";
|
|
5
5
|
export { boundResult, BuiltinCalls, failureText, Mutex, NativeJournal, openTurn, placeSubmissions, recoveryNote, recoverySystemNote, recoveryUserTurn, restartEvent, resumeUnstartedCalls, toolKey, transcriptOf, } from "@parcha/agentrun-kernel/process";
|
|
6
6
|
export type { BuiltinStart, ToolResult, TranscriptEntry } from "@parcha/agentrun-kernel/process";
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/** What a call answered beside its text: its images, and its value (a computer tool's, its images' data left out). */
|
|
8
|
+
export type CallExtras = {
|
|
9
|
+
readonly images?: readonly ToolImage[];
|
|
10
|
+
readonly structured?: JsonValue;
|
|
11
|
+
};
|
|
12
|
+
/** The kernel's tool bridge, keeping each call's images and value by its call id until the answer to Codex takes them
|
|
13
|
+
* (`take`, code-mode.ts): the harness answers Codex with a result's text, and code mode's request handler adds the
|
|
14
|
+
* images as `inputImage` items, or, for a script's nested call of a tool with a value, answers the value. */
|
|
15
|
+
export interface ExtrasBridge extends ToolBridge {
|
|
16
|
+
take(callId: string): CallExtras | undefined;
|
|
12
17
|
}
|
|
13
|
-
export declare function toolBridge(ctx: Parameters<typeof kernelToolBridge>[0], tools: Parameters<typeof kernelToolBridge>[1], options?: ToolBridgeOptions):
|
|
18
|
+
export declare function toolBridge(ctx: Parameters<typeof kernelToolBridge>[0], tools: Parameters<typeof kernelToolBridge>[1], options?: ToolBridgeOptions): ExtrasBridge;
|
|
14
19
|
/** A child's line protocol: one JSON value per line out, lines in. */
|
|
15
20
|
export interface LineChannel {
|
|
16
21
|
send(line: unknown): boolean;
|
package/dist/host/process.js
CHANGED
|
@@ -5,18 +5,18 @@ import { toolBridge as kernelToolBridge } from "@parcha/agentrun-kernel/process"
|
|
|
5
5
|
export { boundResult, BuiltinCalls, failureText, Mutex, NativeJournal, openTurn, placeSubmissions, recoveryNote, recoverySystemNote, recoveryUserTurn, restartEvent, resumeUnstartedCalls, toolKey, transcriptOf, } from "@parcha/agentrun-kernel/process";
|
|
6
6
|
export function toolBridge(ctx, tools, options) {
|
|
7
7
|
const bridge = kernelToolBridge(ctx, tools, options);
|
|
8
|
-
const
|
|
8
|
+
const extras = new Map();
|
|
9
9
|
return {
|
|
10
10
|
...bridge,
|
|
11
11
|
call: async (name, args, callId, signal) => {
|
|
12
12
|
const result = await bridge.call(name, args, callId, signal);
|
|
13
|
-
if (callId && result.images?.length)
|
|
14
|
-
|
|
13
|
+
if (callId && (result.images?.length || result.structured !== undefined))
|
|
14
|
+
extras.set(callId, { ...(result.images?.length ? { images: result.images } : {}), ...(result.structured !== undefined ? { structured: result.structured } : {}) });
|
|
15
15
|
return result;
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
const taken =
|
|
19
|
-
|
|
17
|
+
take: (callId) => {
|
|
18
|
+
const taken = extras.get(callId);
|
|
19
|
+
extras.delete(callId);
|
|
20
20
|
return taken;
|
|
21
21
|
},
|
|
22
22
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CODEX_TOOL_OUTPUT_TOKENS, codexAdapter } from "./adapter.js";
|
|
2
2
|
/** The policy a Codex session's model proxy applies, for a host that serves the same route itself (a faux harness's). */
|
|
3
|
-
export { codexPolicy } from "./host/policy.js";
|
|
3
|
+
export { codexPolicy, webSearchUsd, withWebSearches } from "./host/policy.js";
|
|
4
4
|
/** The check the adapter runs on the host's skills when it is made: @parcha/agentrun-kernel' own, as the Claude adapter's. */
|
|
5
5
|
export { skillProblems } from "@parcha/agentrun-kernel";
|
|
6
6
|
export type { HostSkill } from "@parcha/agentrun-kernel";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { CODEX_TOOL_OUTPUT_TOKENS, codexAdapter } from "./adapter.js";
|
|
2
2
|
/** The policy a Codex session's model proxy applies, for a host that serves the same route itself (a faux harness's). */
|
|
3
|
-
export { codexPolicy } from "./host/policy.js";
|
|
3
|
+
export { codexPolicy, webSearchUsd, withWebSearches } from "./host/policy.js";
|
|
4
4
|
/** The check the adapter runs on the host's skills when it is made: @parcha/agentrun-kernel' own, as the Claude adapter's. */
|
|
5
5
|
export { skillProblems } from "@parcha/agentrun-kernel";
|
|
6
6
|
export { CODEX_VERSION, codexBinary, codexTarget } from "./binary.js";
|
package/dist/rollout.d.ts
CHANGED
|
@@ -81,14 +81,6 @@ export declare function hasCall(lines: readonly string[], callId: string): boole
|
|
|
81
81
|
export declare function endsTurn(line: string): boolean;
|
|
82
82
|
/** The file a set of mirrored lines restores to: each line and its newline. */
|
|
83
83
|
export declare function rolloutText(lines: readonly string[]): string;
|
|
84
|
-
/**
|
|
85
|
-
* The rollout path relative to `CODEX_HOME`, from the absolute path
|
|
86
|
-
* app-server reports. Codex resumes a thread only from a file with its
|
|
87
|
-
* canonical name, `rollout-<YYYY-MM-DDTHH-MM-SS>-<threadId>.jsonl` (any
|
|
88
|
-
* directory under `sessions/`, any timestamp): anything else is "no rollout
|
|
89
|
-
* found" or "not a canonical rollout filename".
|
|
90
|
-
*/
|
|
91
|
-
export declare function relativeRolloutPath(absolute: string, threadId: string): string;
|
|
92
84
|
/** Whether `rel` is a rollout path the driver itself would derive for `threadId`: `sessions/[YYYY/MM/DD/]rollout-<ts>-<threadId>.jsonl`, nothing else. */
|
|
93
85
|
export declare function isRolloutPath(rel: string, threadId: string): boolean;
|
|
94
86
|
/**
|
package/dist/rollout.js
CHANGED
|
@@ -139,22 +139,6 @@ export function rolloutText(lines) {
|
|
|
139
139
|
out += `${l}\n`;
|
|
140
140
|
return out;
|
|
141
141
|
}
|
|
142
|
-
/**
|
|
143
|
-
* The rollout path relative to `CODEX_HOME`, from the absolute path
|
|
144
|
-
* app-server reports. Codex resumes a thread only from a file with its
|
|
145
|
-
* canonical name, `rollout-<YYYY-MM-DDTHH-MM-SS>-<threadId>.jsonl` (any
|
|
146
|
-
* directory under `sessions/`, any timestamp): anything else is "no rollout
|
|
147
|
-
* found" or "not a canonical rollout filename".
|
|
148
|
-
*/
|
|
149
|
-
export function relativeRolloutPath(absolute, threadId) {
|
|
150
|
-
const at = absolute.lastIndexOf('/sessions/');
|
|
151
|
-
const rel = at >= 0 ? absolute.slice(at + 1) : '';
|
|
152
|
-
const name = rel.slice(rel.lastIndexOf('/') + 1);
|
|
153
|
-
if (rel.includes('..') || !/^rollout-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-/.test(name) || name !== `${name.slice(0, 28)}${threadId}.jsonl`) {
|
|
154
|
-
return `sessions/rollout-1970-01-01T00-00-00-${threadId}.jsonl`;
|
|
155
|
-
}
|
|
156
|
-
return rel;
|
|
157
|
-
}
|
|
158
142
|
/** A thread id as the harness accepts it from app-server (untrusted: it names a file to tail). */
|
|
159
143
|
const THREAD_ID = /^[0-9A-Za-z-]{8,64}$/;
|
|
160
144
|
/** Whether `rel` is a rollout path the driver itself would derive for `threadId`: `sessions/[YYYY/MM/DD/]rollout-<ts>-<threadId>.jsonl`, nothing else. */
|
package/dist/scripts.d.ts
CHANGED
|
@@ -49,7 +49,8 @@ export interface NestedFact {
|
|
|
49
49
|
store?: {
|
|
50
50
|
status: "completed" | "failed" | "started";
|
|
51
51
|
text?: string;
|
|
52
|
-
interrupted?: boolean;
|
|
52
|
+
interrupted?: boolean; /** What a script's nested call was sent for a tool with a value (scriptAnswer: the value as JSON, its images' data in it), which the rollout holds instead of `text`. */
|
|
53
|
+
sent?: string;
|
|
53
54
|
};
|
|
54
55
|
/** What the harness's recovery note of the same turn calls it (the kernel's one rule, process/recovery.ts): `retryable` is a
|
|
55
56
|
* safe tool's call that a crash cut off, which the note tells the model is safe to repeat. */
|
package/dist/scripts.js
CHANGED
|
@@ -106,7 +106,7 @@ export function settle(fact) {
|
|
|
106
106
|
const stored = store?.status === "completed" ? { kind: "completed", text: store.text ?? "" } : store?.status === "failed" && !store.interrupted ? { kind: "failed", text: store.text ?? "" } : undefined;
|
|
107
107
|
const rolled = rollout ? { kind: rollout.ok ? "completed" : "failed", text: rollout.text } : undefined;
|
|
108
108
|
if (stored && rolled)
|
|
109
|
-
return stored.kind === rolled.kind && (rolled.text === stored.text || rolled.text === boundResult(stored.text).text) ? stored : { kind: "interrupted" };
|
|
109
|
+
return stored.kind === rolled.kind && (rolled.text === stored.text || rolled.text === boundResult(stored.text).text || (store?.sent !== undefined && rolled.text === store.sent)) ? stored : { kind: "interrupted" };
|
|
110
110
|
return stored ?? rolled ?? { kind: "interrupted" };
|
|
111
111
|
}
|
|
112
112
|
const quoted = (text) => JSON.stringify(text.length > 2000 ? `${text.slice(0, 2000)}… [${text.length - 2000} more characters]` : text);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-harness-codex",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.37",
|
|
4
4
|
"description": "Codex as an AgentRun harness: a tool-less Codex app-server behind a loopback model proxy, durable in AgentRun's own store, with the host's tools as its only tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
"test": "node --test --test-concurrency=8 'test/*.test.mjs'"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@parcha/agentrun-
|
|
48
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.35"
|
|
47
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.37"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
50
|
"@openai/codex": "0.164.0"
|
|
@@ -56,7 +55,8 @@
|
|
|
56
55
|
}
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
|
-
"@openai/codex": "0.164.0"
|
|
58
|
+
"@openai/codex": "0.164.0",
|
|
59
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.37"
|
|
60
60
|
},
|
|
61
61
|
"repository": {
|
|
62
62
|
"type": "git",
|