@parcha/agentrun-harness-codex 0.1.0-beta.33 → 0.1.0-beta.35

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 CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.35 (2026-11-11)
6
+
7
+ - 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.
8
+
9
+ Each image, in every turn, now counts at what the routed model's provider can bill it as, in place of its data's bytes, whatever API carries it. The size comes from the image's own header (PNG, JPEG, GIF or WebP):
10
+ - Anthropic: its 28-pixel patches or its area at 750 pixels a token, whichever is more, at most 4,784.
11
+ - OpenAI: its 512-pixel tiles after resizing (85 + 170 each; 85 at detail low), or for a patch-billed mini or nano model its 32-pixel patches at that model's multiplier when more, at most 73,800.
12
+ - Google: 258 per 768-pixel tile, at least 1,120.
13
+ - Any other provider: the most of the three.
14
+ An image whose size can't be read counts at its provider's per-image maximum, never at its bytes. An image-shaped object outside where the API reads images (a tool call's arguments) is counted at its bytes, as text.
15
+
16
+ `InputShape.images` (the kernel host's `providerInputOverhead`) is now a list of images, each with the bytes its data takes and its size when known; `InputShape.model` names the routed model; the figure can be below 0, and so can a policy's `serverInputOverhead`, never past the body's bytes. Upgrading: pass `images: [{ bytes, width?, height? }]`, built with `imageInputOf`, `messagesImagesIn` or `responsesImagesIn`, and the model, in place of a count.
17
+
18
+ ## 0.1.0-beta.34 (2026-11-11)
19
+
20
+ - The server checks a harness's pinned binary (claude-agent's CLI, Codex, OpenCode: its sha256, then the version it reports) without holding its event loop, so requests, timers and store answers go on while a binary of hundreds of MiB is hashed and run. Before, the first check in a process held every request for one to several seconds (GET /v2/capabilities, a server's start, an adapter made for a run). The binary is now hashed off the loop a chunk at a time and run as a child the loop does not wait on. A pass is kept for the adapter's own check, which then reads nothing, and two checks of one binary at once read it once. New: `checkedOnceAsync` and `sha256OfFileAsync` (kernel host), `verifyClaudeAgentCliAsync` (claude-agent), and `verifyCodexAsync` and `verifyCodexBinaryAsync` (Codex). Who breaks: a program that calls the kernel's `checkedOnce` with its own check. A check is now a `BinaryCheck`, a generator that yields each probe (`{ kind: "sha256", path }` or `{ kind: "run", path, args, env, timeoutMs }`) and is given back its answer, so one check runs either way.
21
+ - A codex, opencode or claude-agent run that reads one of its skills' files (`read_skill_file`) now shows the call and its result on the run's Timeline, as pi's tool calls are shown. On the runner, the adapter's own skill reader ran outside the run's record, so the Timeline had no row for it. The read now goes through the host's tool path (the record, the rule before a side effect, the host's hooks on its result); a new `SessionIO.hostTool` hands an adapter's own tool to the host, and the kernel's `hostedTool(io, tool)` applies it.
22
+ - Upgrading: nothing to change.
23
+
5
24
  ## 0.1.0-beta.32 (2026-11-10)
6
25
 
7
26
  - The code copied from the upstream durable harness is now AgentRun's own: the port froze, and the pristine upstream copies, the named patches, the import tables, `scripts/port-durable-harness.mjs` and `npm run verify:port` are gone. `vendor/durable-harness/UPSTREAM.json` still records where each copy came from, and each copy keeps its header and NOTICE its attribution. With it go the kernel's paths that never run:
package/dist/adapter.js CHANGED
@@ -11,7 +11,7 @@
11
11
  // skills turned off. With no shell, the model reads a skill's files with `read_skill_file`.
12
12
  import { createHash, randomBytes, randomUUID } from "node:crypto";
13
13
  import { join } from "node:path";
14
- import { HOST_RESULT_MAX_CHARS, READ_SKILL_FILE, readSkillFileTool, skillProblems, toolSchemaProblems } from "@parcha/agentrun-kernel";
14
+ import { HOST_RESULT_MAX_CHARS, READ_SKILL_FILE, hostedTool, readSkillFileTool, skillProblems, toolSchemaProblems } from "@parcha/agentrun-kernel";
15
15
  import { abortedOutcome, openDrive, SessionHalt } from "@parcha/agentrun-kernel/kernel";
16
16
  import { pendingSubmissions } from "@parcha/agentrun-kernel/kernel";
17
17
  import { NativeJournal, recoveryNote, settleTurn, transcriptOf } from "@parcha/agentrun-kernel/process";
@@ -159,7 +159,7 @@ export function codexAdapter(options) {
159
159
  if (!dir)
160
160
  throw new Error("agentrun-harness-codex: a session needs a private directory: the host lends one (io.dir), or pass sessionsDir");
161
161
  // With skills the model also reads their files (read_skill_file), from the session's own copy of them.
162
- const tools = skills.length ? [...spec.tools, readSkillFileTool(join(sessionDir(dir, "codex-home"), SKILLS_DIR), skills.map((skill) => ({ name: skill.name, files: Object.keys(skill.files) })))] : spec.tools;
162
+ 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
163
  const effort = spec.effort ?? spec.thinking;
164
164
  const harnessOptions = {
165
165
  tools: tools.map(kernelTool),
@@ -68,7 +68,7 @@ export declare function webSearchesOf(text: string): number | undefined;
68
68
  * Responses API documents no prompt of its own that it adds on these routes (no hosted tool passes the policy but a
69
69
  * session's live web search, below), and the framing it puts around each input item and tool definition is a few tokens
70
70
  * each, fewer than the bytes of the JSON keys that item already spends in the body. An image is billed by its area, not
71
- * its bytes: each adds the most it can be billed as. A file input (a PDF, billed by its pages) has no stated bound, so a
71
+ * its bytes: each counts at the most it can be billed as, in place of the bytes its data URL takes in the body. A file input (a PDF, billed by its pages) has no stated bound, so a
72
72
  * body with one cannot be measured: this throws, and the request's input is unknown.
73
73
  */
74
74
  export declare function responsesServerInputOverhead(body: Record<string, unknown>): number;
@@ -1,4 +1,4 @@
1
- import { providerInputOverhead, ProxyRefusal } from "@parcha/agentrun-kernel/host";
1
+ import { providerInputOverhead, ProxyRefusal, responsesImagesIn } from "@parcha/agentrun-kernel/host";
2
2
  export const CODEX_RESPONSES_ROUTES = Object.freeze([
3
3
  { method: "GET", path: "/", local: 404 },
4
4
  { method: "POST", path: "/v1/responses", headers: ["accept"] },
@@ -359,13 +359,13 @@ function itemsIn(value, type) {
359
359
  * Responses API documents no prompt of its own that it adds on these routes (no hosted tool passes the policy but a
360
360
  * session's live web search, below), and the framing it puts around each input item and tool definition is a few tokens
361
361
  * each, fewer than the bytes of the JSON keys that item already spends in the body. An image is billed by its area, not
362
- * its bytes: each adds the most it can be billed as. A file input (a PDF, billed by its pages) has no stated bound, so a
362
+ * its bytes: each counts at the most it can be billed as, in place of the bytes its data URL takes in the body. A file input (a PDF, billed by its pages) has no stated bound, so a
363
363
  * body with one cannot be measured: this throws, and the request's input is unknown.
364
364
  */
365
365
  export function responsesServerInputOverhead(body) {
366
366
  if (itemsIn(body.input, "input_file") > 0)
367
367
  throw new Error("a file input's billed size has no stated bound");
368
- return providerInputOverhead("openai-responses", { tools: Array.isArray(body.tools) && body.tools.length > 0, images: itemsIn(body.input, "input_image") });
368
+ return providerInputOverhead("openai-responses", { tools: Array.isArray(body.tools) && body.tools.length > 0, images: responsesImagesIn(body.input), ...(typeof body.model === "string" ? { model: body.model } : {}) });
369
369
  }
370
370
  /** The text of a tool output item: a string, or the text of each of its parts. */
371
371
  /** Codex's status header of a tool output: the text it starts with (its first part), never what the script printed after it. */
package/dist/index.d.ts CHANGED
@@ -9,5 +9,5 @@ export type { ChildCommand, ConfineChild } from "./host/machine.js";
9
9
  export { CODEX_VERSION, codexBinary, codexTarget } from "./binary.js";
10
10
  /** The shapes of a tool's schema Codex 0.164 drops or retypes (schema.ts): a host may refuse them sooner (an MCP grant, at its save). */
11
11
  export { codexSchemaProblems } from "./schema.js";
12
- export { verifyCodex, verifyCodexBinary } from "./verify.js";
12
+ export { verifyCodex, verifyCodexAsync, verifyCodexBinary, verifyCodexBinaryAsync } from "./verify.js";
13
13
  export { CODEX_BINARY_SHA256, CODEX_INSTALL, CODEX_NPM_INTEGRITY, CodexNotInstalled, CodexPinMismatch } from "./versions.js";
package/dist/index.js CHANGED
@@ -6,5 +6,5 @@ export { skillProblems } from "@parcha/agentrun-kernel";
6
6
  export { CODEX_VERSION, codexBinary, codexTarget } from "./binary.js";
7
7
  /** The shapes of a tool's schema Codex 0.164 drops or retypes (schema.ts): a host may refuse them sooner (an MCP grant, at its save). */
8
8
  export { codexSchemaProblems } from "./schema.js";
9
- export { verifyCodex, verifyCodexBinary } from "./verify.js";
9
+ export { verifyCodex, verifyCodexAsync, verifyCodexBinary, verifyCodexBinaryAsync } from "./verify.js";
10
10
  export { CODEX_BINARY_SHA256, CODEX_INSTALL, CODEX_NPM_INTEGRITY, CodexNotInstalled, CodexPinMismatch } from "./versions.js";
package/dist/verify.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare function codexPins(target?: {
20
20
  * from its own directory, where a relative `CODEX_BIN` names nothing. The sha256 is read a chunk at a time, never the
21
21
  * whole binary in memory, and a check that passed holds for this process while the binary stays the same file, unchanged
22
22
  * (the kernel's checkedOnce): a host that checks it for each model it resolves, and a run's process that makes its
23
- * adapter, check it once.
23
+ * adapter, check it once. Its reads hold the event loop: a host checks with verifyCodexBinaryAsync first.
24
24
  */
25
25
  export declare function verifyCodexBinary(found: {
26
26
  path: string;
@@ -28,6 +28,13 @@ export declare function verifyCodexBinary(found: {
28
28
  } | undefined, pins?: CodexPins): {
29
29
  path: string;
30
30
  } | CodexPinMismatch | CodexNotInstalled;
31
+ /** verifyCodexBinary without holding the event loop (the kernel's checkedOnceAsync), its pass kept for it too. */
32
+ export declare function verifyCodexBinaryAsync(found: {
33
+ path: string;
34
+ packageVersion?: string;
35
+ } | undefined, pins?: CodexPins): Promise<{
36
+ path: string;
37
+ } | CodexPinMismatch | CodexNotInstalled>;
31
38
  /** This machine's Codex checked against the pins: its path, or the typed error thrown. */
32
39
  export declare function verifyCodex(found?: {
33
40
  path: string;
@@ -35,3 +42,11 @@ export declare function verifyCodex(found?: {
35
42
  } | undefined, pins?: CodexPins): {
36
43
  path: string;
37
44
  };
45
+ /** verifyCodex without holding the event loop: what a host awaits before it makes the adapter, whose own check then
46
+ * answers from what this kept. */
47
+ export declare function verifyCodexAsync(found?: {
48
+ path: string;
49
+ packageVersion?: string;
50
+ } | undefined, pins?: CodexPins): Promise<{
51
+ path: string;
52
+ }>;
package/dist/verify.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // The installed Codex checked against the pins (src/versions.ts) before anything runs, with the typed errors a host maps
2
2
  // to a run's failure line. Written for AgentRun.
3
- import { execFileSync } from "node:child_process";
4
3
  import { existsSync } from "node:fs";
5
4
  import { resolve } from "node:path";
6
5
  import { env } from "node:process";
7
- import { checkedOnce, sha256OfFile } from "@parcha/agentrun-kernel/host";
6
+ import { checkedOnce, checkedOnceAsync } from "@parcha/agentrun-kernel/host";
8
7
  import { codexTarget, findCodex } from "./binary.js";
9
8
  import { CODEX_BINARY_SHA256, CODEX_VERSION, CodexNotInstalled, CodexPinMismatch } from "./versions.js";
10
9
  /** The pins for this platform's binary. */
@@ -19,9 +18,20 @@ export function codexPins(target = codexTarget()) {
19
18
  * from its own directory, where a relative `CODEX_BIN` names nothing. The sha256 is read a chunk at a time, never the
20
19
  * whole binary in memory, and a check that passed holds for this process while the binary stays the same file, unchanged
21
20
  * (the kernel's checkedOnce): a host that checks it for each model it resolves, and a run's process that makes its
22
- * adapter, check it once.
21
+ * adapter, check it once. Its reads hold the event loop: a host checks with verifyCodexBinaryAsync first.
23
22
  */
24
23
  export function verifyCodexBinary(found, pins = codexPins()) {
24
+ const at = located(found, pins);
25
+ return at instanceof Error ? at : checkedOnce(at.path, JSON.stringify(pins), () => checkBinary(at.path, pins), passed);
26
+ }
27
+ /** verifyCodexBinary without holding the event loop (the kernel's checkedOnceAsync), its pass kept for it too. */
28
+ export async function verifyCodexBinaryAsync(found, pins = codexPins()) {
29
+ const at = located(found, pins);
30
+ return at instanceof Error ? at : checkedOnceAsync(at.path, JSON.stringify(pins), () => checkBinary(at.path, pins), passed);
31
+ }
32
+ const passed = (result) => !(result instanceof Error);
33
+ /** The absolute path of `found`, there and of the pinned package's version; or why not. */
34
+ function located(found, pins) {
25
35
  if (!found)
26
36
  return new CodexNotInstalled("no Codex binary found for this platform, and CODEX_BIN is not set");
27
37
  const path = resolve(found.path);
@@ -30,15 +40,15 @@ export function verifyCodexBinary(found, pins = codexPins()) {
30
40
  if (pins.packageVersion && found.packageVersion !== undefined && found.packageVersion !== pins.packageVersion) {
31
41
  return new CodexPinMismatch("package_version", pins.packageVersion, found.packageVersion, path);
32
42
  }
33
- // Hashed a chunk at a time, and once per binary in this process while it stays the same file.
34
- return checkedOnce(path, JSON.stringify(pins), () => checkBinary(path, pins), (result) => !(result instanceof Error));
43
+ return { path };
35
44
  }
36
- /** The binary at `path` (absolute, there) against `pins`' sha256 and version. */
37
- function checkBinary(path, pins) {
45
+ /** The binary at `path` (absolute, there) against `pins`' sha256 and version, as the steps it reads (the kernel's
46
+ * BinaryCheck). */
47
+ function* checkBinary(path, pins) {
38
48
  if (pins.sha256) {
39
49
  let sha256;
40
50
  try {
41
- sha256 = sha256OfFile(path);
51
+ sha256 = yield { kind: "sha256", path };
42
52
  }
43
53
  catch (error) {
44
54
  return new CodexNotInstalled(`${path} could not be read: ${String(error?.message ?? error).slice(0, 120)}`);
@@ -48,7 +58,7 @@ function checkBinary(path, pins) {
48
58
  }
49
59
  let reported;
50
60
  try {
51
- reported = execFileSync(path, ["--version"], { env: { PATH: env.PATH ?? "/usr/bin:/bin" }, encoding: "utf8", timeout: 10_000 }).trim();
61
+ reported = (yield { kind: "run", path, args: ["--version"], env: { PATH: env.PATH ?? "/usr/bin:/bin" }, timeoutMs: 10_000 }).trim();
52
62
  }
53
63
  catch (error) {
54
64
  return new CodexNotInstalled(`${path} could not be run: ${String(error?.message ?? error).slice(0, 120)}`);
@@ -65,3 +75,11 @@ export function verifyCodex(found = findCodex(), pins = codexPins()) {
65
75
  throw result;
66
76
  return result;
67
77
  }
78
+ /** verifyCodex without holding the event loop: what a host awaits before it makes the adapter, whose own check then
79
+ * answers from what this kept. */
80
+ export async function verifyCodexAsync(found = findCodex(), pins = codexPins()) {
81
+ const result = await verifyCodexBinaryAsync(found, pins);
82
+ if (result instanceof Error)
83
+ throw result;
84
+ return result;
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-harness-codex",
3
- "version": "0.1.0-beta.33",
3
+ "version": "0.1.0-beta.35",
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",
@@ -13,7 +13,7 @@
13
13
  "license": "Apache-2.0",
14
14
  "author": "Parcha Labs, Inc.",
15
15
  "engines": {
16
- "node": ">=24.11.0"
16
+ "node": ">=24.22.3"
17
17
  },
18
18
  "main": "./dist/index.js",
19
19
  "types": "./dist/index.d.ts",
@@ -44,8 +44,8 @@
44
44
  "test": "node --test --test-concurrency=8 'test/*.test.mjs'"
45
45
  },
46
46
  "dependencies": {
47
- "@parcha/agentrun-dsl": "0.1.0-beta.33",
48
- "@parcha/agentrun-kernel": "0.1.0-beta.33"
47
+ "@parcha/agentrun-dsl": "0.1.0-beta.35",
48
+ "@parcha/agentrun-kernel": "0.1.0-beta.35"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@openai/codex": "0.164.0"