@parcha/agentrun-kernel 0.1.0-beta.44 → 0.1.0-beta.46

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,9 +2,23 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.45 (2026-11-18)
6
+
7
+ - Goose 1.59.2 runs as an AgentRun harness on the ACP adapter: `gooseAdapter({ binary, model, provider, price })` checks the binary's sha256 against its pin, starts `goose acp` from the shipped recipe (`recipes/goose.json`, loaded by `recipeFile` and `gooseRecipe`), and points each Goose process at a model proxy of its own (`gooseProxy`) on the session's booking, so the run's cap and books hold as they do for Claude Code. <!-- changes/acp-goose-harness.md -->
8
+ - The recipe turns every bundled Goose extension off, blocks Goose's model catalog download with a dead egress proxy, mirrors its sessions so another runner's Goose loads them, and leaves the model our MCP tools (`agentrun__<name>`) and Goose's `load_skill`.
9
+ - Goose's proxy forwards only `POST /v1/messages`, with the API's version and the one `anthropic-beta` value the pinned Goose sends (`GOOSE_BETAS`), never Goose's `agent-session-id`. It answers `GET /v1/models` itself with the run's model, and refuses any other model, tool, hosted tool or beta before the provider is asked.
10
+ - `GOOSE_PIN` records the release as the ACP registry listed it, with where and when it was read. `verifyPinnedBinary` refuses a binary whose sha256 differs (`ACP_BINARY_MISMATCH`), reading it and never running it. `gooseAdapter` checks it when the adapter is made and again before every Goose process starts (the adapter's new `beforeStart` option), so a binary replaced in between never runs unchecked. `verifyFirstSeen` records the first verified digest of an agent the registry lists without one, and refuses later drift (`ACP_BINARY_DRIFT`).
11
+ - The adapter's `proxy` option is now called with the session's booking, its tools' names and a halt of its drive (`AcpProxySession`).
12
+ - The kernel's model proxy can answer a local route with a fixed JSON body (`ProxyRoute.localJson`), only to the session's key or a side key.
13
+ - The runner now writes a warn line when a paid model request bills more input than the bound its spend-cap hold was priced on: the one way a cap can be passed, a hold that was too small. <!-- changes/cap-bound-warn.md -->
14
+
15
+ The line is `event=cap_hold_short`, in the same logfmt shape as the server's other log lines, written to stderr once for each such request as its answer is booked: by an agent's run, by a workflow run's model nodes (harness `workflow`), and for a request that answered after its run's claim was lost, by the booking that writes it later. It carries the run id, the request's session and turn, the harness, the model, the bound and the billed input in tokens (input, cache reads and cache writes together), and in USD what was held, what the answer billed and the shortfall (billed less held) when the answer was priced.
16
+
17
+ No line is written for a request billed at or under its bound, for one whose answer reported no usage, for one billed to a ChatGPT plan or on a free model (held at $0 whatever its input), or for one with no hold (no cap). The line carries ids and figures only: never any prompt or answer text, header, key or token. Billing, holds and refusals are unchanged.
18
+
5
19
  ## 0.1.0-beta.44 (2026-11-17)
6
20
 
7
- - A Codex run under a small spend cap no longer stops as early on a hold that overstated its next request.
21
+ - A Codex run under a small spend cap no longer stops as early on a hold that overstated its next request. <!-- changes/codex-cap-hold-billed-after.md -->
8
22
 
9
23
  A request that only adds items to the session's last billed request is now held at that bill plus the bytes of the items it adds, with the local count's margin. The bill is all of that request's `input_tokens`, cached tokens included. Any other difference falls back to the local count, as before: changed instructions, tools, reasoning or model, or an earlier item edited, removed or moved.
10
24
 
package/README.md CHANGED
@@ -49,8 +49,8 @@ harness adapter the way they run on Pi, durable in AgentRun's own store.
49
49
  `parkOf`, `checkRaise` and `followUpOf` decide what a refusal and a raise do to the run.
50
50
  - `./host` is the session's model proxy, provider-neutral: on the loopback interface, it admits only the session's key,
51
51
  only the routes a `ProviderPolicy` lists (by exact path text, with no query or one the route lists exactly; a route
52
- may also be answered by the proxy, or be free, like a token count), and strict JSON, has the policy shape or refuse the
53
- body, asks the runner's `beforeRequest` before each paid request, adds the provider's credential (which never reaches
52
+ may also be answered by the proxy, or be free, like a token count), and strict JSON that has the policy shape (it refuses any
53
+ other body), asks the runner's `beforeRequest` before each paid request, adds the provider's credential (which never reaches
54
54
  the harness), and reports each response's usage to `afterRequest`. Model spend is accounted only there, by the runner.
55
55
 
56
56
  The runner's own bounds (a turn limit, no progress, an unknown tool, a refused fork, the host's refusal) fail a node
@@ -11,6 +11,10 @@ export interface ProxyRoute {
11
11
  readonly headers?: readonly string[];
12
12
  /** Answered here with this status and an empty body, never forwarded (a client's connectivity check). */
13
13
  readonly local?: number;
14
+ /** With `local`: the JSON text it is answered with in place of an empty body (a client's list of models, answered
15
+ * with the session's own so the provider's list is never asked for), and then only to the session's key or a side
16
+ * key. */
17
+ readonly localJson?: string;
14
18
  /** Not a paid request (a token count): forwarded without asking the runner, and no usage is reported. */
15
19
  readonly free?: boolean;
16
20
  }
@@ -4,8 +4,8 @@
4
4
  // forward, where a response reports its usage). The core:
5
5
  // - admits a request only with the session's key (compared in constant time), on a route the policy lists, by exact
6
6
  // path text, with no query or one the route lists exactly: an absolute URL, `..`, `//` or `%` escapes never match. A
7
- // route may be answered here with a status alone, with no key (a client's connectivity check), or be free (a token
8
- // count, which the runner never pays);
7
+ // route may be answered here with a status alone, with no key (a client's connectivity check), or with a body the
8
+ // policy fixed, with the key (a client's list of models), or be free (a token count, which the runner never pays);
9
9
  // - parses the body strictly (one JSON value, no duplicate key at any depth, so a check on one `model` cannot pass while
10
10
  // the provider reads another), then has the policy shape it (or refuse it);
11
11
  // - asks the runner before every paid request (`beforeRequest`, where a turn cap or the host's budget refuses it) and
@@ -946,11 +946,19 @@ export async function startModelProxy(options, key) {
946
946
  const e = error;
947
947
  return refuse(res, e.status ?? 403, e.message, req);
948
948
  }
949
- // A local route forwards nothing and answers only a status, so it needs no key: a client's connectivity check
950
- // (the Claude Agent CLI's `HEAD /api/hello`) is sent without one.
949
+ // A local route forwards nothing. One that answers only a status needs no key: a client's connectivity check (the
950
+ // Claude Agent CLI's `HEAD /api/hello`) is sent without one. One that answers a body says something of the session
951
+ // (its model, to Goose's `GET /v1/models`), so it takes a key as every other route does.
951
952
  if (route.local !== undefined) {
952
- res.writeHead(route.local, { "content-length": "0" });
953
- return res.end();
953
+ if (route.localJson === undefined) {
954
+ res.writeHead(route.local, { "content-length": "0" });
955
+ return res.end();
956
+ }
957
+ const sent = policy.keyOf(req.headers);
958
+ if (!sameKey(sent, key) && sideOf(sent) === undefined)
959
+ return refuse(res, 401, "this session's key is required", req);
960
+ res.writeHead(route.local, { "content-type": "application/json", "content-length": String(Buffer.byteLength(route.localJson)) });
961
+ return res.end(route.localJson);
954
962
  }
955
963
  // The session's key (the harness's requests), or a side key the host holds (its own, labelled).
956
964
  const sentKey = policy.keyOf(req.headers);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { answeredUnpriced, costOfParts, createHarnessRunner, CUT_AT_HOLD, modelPortFor, rebooked, sessionSpendOf, SUBMIT_TOOL, RUNNER_RECORDS, turnCostOf } from "./runner.js";
2
2
  export { RECORD_WAIT_MS, runBooking, type RunBookingOptions, type RunSessions, WAIT_POLL_FIRST_MS, WAIT_POLL_MOST_MS, WAIT_STALL_MS } from "./run-booking.js";
3
- export type { Admission, BeforeRequest, Refusal, HarnessRunner, HarnessRunnerOptions, InFlight, ModelBooking, ModelPortEvent, ModelPortOptions, CostParts, SessionCost } from "./runner.js";
3
+ export type { Admission, BeforeRequest, Refusal, HarnessRunner, HarnessRunnerOptions, HoldShort, InFlight, ModelBooking, ModelPortEvent, ModelPortOptions, CostParts, SessionCost } from "./runner.js";
4
4
  export { HarnessRunError, SessionFenced, TurnParked } from "./errors.js";
5
5
  export { CODEMODE, DEFER_CATALOG_OVER, defersCatalog, isCatalogWire, META_TOOLS, TOOLS_CALL, TOOLS_SEARCH } from "./tool-deferral.js";
6
6
  export { toolSchemaProblems } from "./schema-check.js";
package/dist/runner.d.ts CHANGED
@@ -188,8 +188,19 @@ export interface HarnessRunnerOptions {
188
188
  * turn limit counts paid requests only, so without this bound a harness whose turns never reach its model (a cached or
189
189
  * refused answer, a misconfigured model) would be sent turns forever, on microtasks no timer can interrupt. */
190
190
  export declare const NO_PROGRESS_TURNS = 3;
191
+ /** A request whose answer billed more input than the bound its hold was priced on (InFlight.inputTokensMax): the cap's
192
+ * one failure that matters, a hold too small. Its model; that bound and what it billed (input, cache reads and cache
193
+ * writes together, as `inputAfter` reads a bill), in tokens; what was held for it and, when its answer was priced, what
194
+ * it billed, in USD. */
195
+ export type HoldShort = {
196
+ model: string;
197
+ boundTokens: number;
198
+ billedTokens: number;
199
+ heldUsd: number;
200
+ billedUsd?: number;
201
+ };
191
202
  /** What a paid request tells a host, beside its session's key and label. A `request_end` carries how its path saw the
192
- * request end (`ended`, booking.ts), when the path said. */
203
+ * request end (`ended`, booking.ts), when the path said, and `holdShort` when it billed past its hold's bound. */
193
204
  export type ModelPortEvent = {
194
205
  type: "request_start";
195
206
  turn: number;
@@ -201,6 +212,7 @@ export type ModelPortEvent = {
201
212
  usage: ModelUsage;
202
213
  host?: string;
203
214
  ended?: Ended;
215
+ holdShort?: HoldShort;
204
216
  };
205
217
  export interface ModelPortOptions {
206
218
  /** The session's key: what `beforeRequest` and every event carry. */
package/dist/runner.js CHANGED
@@ -36,6 +36,21 @@ const positive = (value, name) => {
36
36
  * turn limit counts paid requests only, so without this bound a harness whose turns never reach its model (a cached or
37
37
  * refused answer, a misconfigured model) would be sent turns forever, on microtasks no timer can interrupt. */
38
38
  export const NO_PROGRESS_TURNS = 3;
39
+ /** `usage` against the bound its request's hold was priced on (`flight`'s inputTokensMax; `hold`, what was held): a
40
+ * HoldShort when it billed more input than that bound. Undefined when it billed at or under it, or when there is nothing
41
+ * to compare: no bound, no hold (no cap priced it), a request held at $0 whatever its input (billed to a plan or on a
42
+ * free model, `unpriced`), or a usage with no input count (one cut, or one whose answer reported none). */
43
+ const holdShortOf = (usage, flight, hold, unpriced) => {
44
+ const count = (value) => (typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined);
45
+ const input = count(usage.input);
46
+ const bound = count(flight?.inputTokensMax);
47
+ if (!flight || bound === undefined || hold === undefined || unpriced || usage.billing === "plan" || usage.cut || usage.givenBack || input === undefined)
48
+ return undefined;
49
+ const billed = input + (count(usage.cacheRead) ?? 0) + (count(usage.cacheWrite) ?? 0);
50
+ if (billed <= bound)
51
+ return undefined;
52
+ return { model: flight.model, boundTokens: bound, billedTokens: billed, heldUsd: hold, ...(typeof usage.usd === "number" && Number.isFinite(usage.usd) ? { billedUsd: usage.usd } : {}) };
53
+ };
39
54
  /** The runner's booking of paid model requests, for a host that drives an adapter session itself (a chat run): the same
40
55
  * records (`runner.request` before a request leaves, `runner.turn` with its cost when it answers), the same turn limit
41
56
  * and `beforeRequest`, the same events. `createHarnessRunner` is built on it. */
@@ -395,6 +410,8 @@ function bookingFor(writer, options) {
395
410
  // The turn this request was admitted as (its ticket; without one, the earliest still in flight).
396
411
  const turn = ticket?.turn ?? open[0]?.turn ?? turns;
397
412
  const at = open.findIndex((f) => f.turn === turn);
413
+ // As it was admitted: the bound its hold was priced on (holdShortOf).
414
+ const flight = at >= 0 ? open[at] : undefined;
398
415
  if (at >= 0)
399
416
  open.splice(at, 1);
400
417
  // A cost that never came in (a response cut short): at what the host held for the request, else unknown. One its
@@ -432,6 +449,9 @@ function bookingFor(writer, options) {
432
449
  // Marked so, for a reader to say why it cost nothing (a run on free models: "$0 · free model").
433
450
  if (free)
434
451
  data.free = true;
452
+ // Billed past the bound its hold was priced on: told with its end, for the host's warn line, here or, its write
453
+ // refused, by the next booking that writes it (handoffs). Its booking is as above.
454
+ const holdShort = holdShortOf(usage, flight, hold, plan || free);
435
455
  try {
436
456
  // A runner.turn with the ids holds what a carried response record of this turn would: that one is dropped. A
437
457
  // stopped one keeps the figure it counts at (`heldUsd`), so a later process counts it the same.
@@ -443,7 +463,7 @@ function bookingFor(writer, options) {
443
463
  // Refused (its claim lost as it answered, say): the booking is handed to the session's next booking in this
444
464
  // process, which writes it at its bookCut, never cutting a request that answered (handoffs).
445
465
  if (scope !== undefined)
446
- handoffOf(scope).refused.set(turn, { data, usage, ...(ended ? { ended } : {}) });
466
+ handoffOf(scope).refused.set(turn, { data, usage, ...(ended ? { ended } : {}), ...(holdShort ? { holdShort } : {}) });
447
467
  settle?.();
448
468
  // A paid request whose cost can't be kept: the attempt stops, saying so, rather than spend on uncounted. Asked
449
469
  // with the request's own host label, as its admission was: a stop that holds only the harness's own requests (a
@@ -459,7 +479,7 @@ function bookingFor(writer, options) {
459
479
  const hosted = hosts.get(turn);
460
480
  // Awaited: a host that marks the request's end on its record writes it before the booking counts as settled, so a
461
481
  // run's end never lands ahead of the mark that says its request was cut.
462
- await emit({ type: "request_end", turn, usage, ...(hosted === undefined ? {} : { host: hosted }), ...(ended ? { ended } : {}) });
482
+ await emit({ type: "request_end", turn, usage, ...(hosted === undefined ? {} : { host: hosted }), ...(ended ? { ended } : {}), ...(holdShort ? { holdShort } : {}) });
463
483
  },
464
484
  };
465
485
  // One booking of the cut requests at a time: a call made while one is writing waits for it, never books them again.
@@ -517,7 +537,7 @@ function bookingFor(writer, options) {
517
537
  spentUsd = sessionSpendOf([...now, ...booked]).spentUsd;
518
538
  for (const one of taken) {
519
539
  const hosted = hosts.get(one.turn);
520
- await emit({ type: "request_end", turn: one.turn, usage: one.usage, ...(hosted === undefined ? {} : { host: hosted }), ...(one.ended ? { ended: one.ended } : {}) });
540
+ await emit({ type: "request_end", turn: one.turn, usage: one.usage, ...(hosted === undefined ? {} : { host: hosted }), ...(one.ended ? { ended: one.ended } : {}), ...(one.holdShort ? { holdShort: one.holdShort } : {}) });
521
541
  }
522
542
  }
523
543
  handoffDone(scope);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-kernel",
3
- "version": "0.1.0-beta.44",
3
+ "version": "0.1.0-beta.46",
4
4
  "description": "Agent harnesses other than Pi, starting with Codex, behind one seam: a DSL node's runNode and an AgentRun run on a harness adapter, durable in AgentRun's own store.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -62,7 +62,7 @@
62
62
  "test": "node --test --test-concurrency=8 'test/*.test.mjs'"
63
63
  },
64
64
  "dependencies": {
65
- "@parcha/agentrun-dsl": "0.1.0-beta.44",
65
+ "@parcha/agentrun-dsl": "0.1.0-beta.46",
66
66
  "ajv": "8.18.0",
67
67
  "typebox": "1.3.27"
68
68
  },