@parcha/agentrun-kernel 0.1.0-beta.64 → 0.1.0-beta.66

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.66 (2026-11-27)
6
+
7
+ - A runner's graceful `close()` now resolves only after each live run's tool hosts have let go of what they hold, and their charges are booked under the claim the runner still holds. Before, the shutdown sealed the run's journal and aborted its ledger first, so a browser session's release charge was refused ("a tool host's beforeRelease failed: the loop stopped (shutdown)") and a priced computer's last stretch went unbooked. A shutdown's seal now lets the release hooks' commits through until they return; the claim's fence still refuses them once the claim is lost. On the run's cap, money already owed (a computer's time, a browser session's release) is booked after the run's stop, since nothing starts with it; every other step is still refused after a stop. <!-- changes/close-books-release.md -->
8
+
9
+ The wait is bounded, and the close's window now runs from its start:
10
+ - A run's release waits for its tool hosts up to a computer provider's cleanup bound (`cleanupMs`, 30 s by default) and a 5 s margin, never past the close's window. A host still going then is cut: each open browser session's time up to the cut is charged (pi-browser's `charge` handle), and the run's root records an `agentrun.release.cut` entry with the bound, the time taken and how many hosts finished. The session's release, when it lands (on this claim or the next one's), bills only the time after that charge. If the charge went past the release's own time, the release bills 0 s, and its `agentrun.browser_charged` entry carries `overbooked_s`. A reserve the cut claim left held is given back at the next claim's reopen. The cut reaches every conversation of the run, its subagents' included. pi-browser's `charge` now skips a session already charged through now, so a cut books no $0 charge under it.
11
+ - A lost create's recovery under way in the process (`recoveriesInFlight()`, new in `@parcha/agentrun-computer`, with `recoverCreate` now exported) is waited for at the close: each up to its own bound, or the drain, and the margin. A run's own process (`run-child`) waits for its own recoveries before it exits, and its runner gives that exit the release's bound.
12
+ - A person's stop gives a run's own process the release's bound and 5 s for the cut's booking on top of its 30 s stop, so a release that never answers is cut, charged and recorded before the process is ended. A release already under way when a shutdown arrives follows it: its cut is moved to the close's window, and the shutdown's seal lets the release's commits through. A run a person's stop already stops when the runner closes keeps that stop as its end, and its release is cut by the close's window too, in the runner's process or its own, so its cut is charged and recorded before the close ends.
13
+ - The close is now the drain plus the lease less its margin (31 s with the image's 6 s drain), or the cleanup bound and 10 s of margins from the close's start, whichever is longer: 40 s by default. Claims are renewed until the close returns. `startRunner` takes `cleanupMs` for a runner whose providers use a longer one.
14
+ - The deploy templates give a runner more time to stop: 45 s in `deploy/compose.yaml`, the Helm chart (`terminationGracePeriodSeconds`), Coolify and Dokploy, 45 s of Railway draining (`RAILWAY_DEPLOYMENT_DRAINING_SECONDS`), and 50 s on Fly (`kill_timeout`). A deployment of its own gives a runner at least 45 s, and at least `cleanupMs` + 15 s with a longer cleanup bound.
15
+
16
+ ## 0.1.0-beta.65 (2026-11-27)
17
+
18
+ - A pi session opened again in a turn now reads the turn back from its conversation before a call the model made runs, not after: a pi-native tool (bash, web_fetch, a subagent) whose read fails is blocked before it does anything, where before it ran and its result was replaced by an error, inviting the model to run it again. <!-- changes/turn-budget-read-before-call.md -->
19
+ - A session that read its own answer never reads the turn back, so a store that cannot read blocks none of its calls.
20
+ - A call pi reruns after a crash (its intent stored, so the read happens after it) keeps what it did when the read fails, held to the window's bound alone, instead of an error.
21
+ - The words a call gets when its turn could not be read are plain: the store's own error is no longer in the model's transcript. A host tool's call pi runs again after a crash, whose read fails before it runs, says an earlier attempt of it may already have taken effect, never that nothing was done.
22
+ - A tool that nests calls (a code-mode script) whose result's length the session's journal could not keep halts its drive, as an effect's failure does, so the harness is never handed that result.
23
+
5
24
  ## 0.1.0-beta.64 (2026-11-26)
6
25
 
7
26
  - On a Linux desktop, the check of whether computerd's own user could change an app's desktop file asks the kernel too (`faccessat2` as the effective user, no link followed) for each folder on the way and for the file, beside the mode bits, so an ACL entry or a FUSE file system's own rule that lets the user write is seen. `apps.launch` names a refused desktop file from that one check, by the id asked for, and no longer opens every desktop file again to find it: that open followed links and waited forever on a named pipe called `*.desktop`. A refused file is never read, so the name or program it gives finds no app: asked by that name, `apps.launch` answers `not_found`, and by its id, `denied`. `apps.terminate` ends an app this computerd launched though its desktop file is refused now, as when a file of its id was written ahead of it since; before, it answered `denied` and the app ran on to the computer's end. The computer wire spec says that `apps.launch` answers `denied` for such an app and that `apps.list` leaves it out. A correction to the previous release's note on desktop files: refusing an app whose desktop file computerd's own user could change closes the desktop-file route only, not `write` plus apps as a whole. An app reads its config from the user's home, which `write` reaches, so an agent given both can still reach a shell through an app it opens, and the remedy stays granting no apps on such a desktop. The words every offer of a computer's ops carries (`GUI_REACH`), the serve README and the desktop kind skill say that where `write` is granted, `apps.open` reaches what a shell does with or without a URL or a path, since an app reads its config from the user's home. <!-- changes/apps-launch-refusal-kernel-check.md -->
@@ -179,6 +179,17 @@ export function toolBridge(ctx, tools, options = {}) {
179
179
  }
180
180
  if (live)
181
181
  ctx.live({ type: 'tool_start', name: tool.name, args, callId });
182
+ // Its result as the harness gets it (deliver): one that cannot be handed (its length not kept) halts the drive, as an
183
+ // effect's failure does, so the harness is never handed it.
184
+ const handed = async (whole, error) => {
185
+ try {
186
+ return await deliver(callId, whole, nested, error);
187
+ }
188
+ catch (err) {
189
+ ctx.halt?.(err);
190
+ throw err;
191
+ }
192
+ };
182
193
  let output;
183
194
  try {
184
195
  output = await tool.execute(args, { signal: aborted, progress: () => { }, ctx, stepId: `${toolKey(callId)}#0`, nested: nestedIn(callId, aborted) });
@@ -188,13 +199,13 @@ export function toolBridge(ctx, tools, options = {}) {
188
199
  ctx.halt?.(err);
189
200
  throw err;
190
201
  }
191
- const { text, truncated } = await deliver(callId, err instanceof Error ? err.message : String(err), nested, true);
202
+ const { text, truncated } = await handed(err instanceof Error ? err.message : String(err), true);
192
203
  if (live)
193
204
  ctx.live({ type: 'tool_end', name: tool.name, callId, isError: true, result: text, ...(truncated ? { truncated } : {}) });
194
205
  return { text, isError: true, ...(truncated ? { truncated } : {}) };
195
206
  }
196
207
  const { text: whole, images, structured } = typeof output === 'object' && output !== null ? output : { text: String(output), images: undefined, structured: undefined };
197
- const { text, truncated } = await deliver(callId, String(whole), nested);
208
+ const { text, truncated } = await handed(String(whole));
198
209
  if (live)
199
210
  ctx.live({ type: 'tool_end', name: tool.name, callId, result: text, ...(truncated ? { truncated } : {}) });
200
211
  return { text, isError: false, ...(images?.length ? { images } : {}), ...(structured !== undefined ? { structured } : {}), ...(truncated ? { truncated } : {}) };
@@ -14,7 +14,8 @@ export interface RunBookingOptions {
14
14
  parked?(): boolean;
15
15
  /** How long a waiter waits with none of the steps it waits on settling before it is refused (default WAIT_STALL_MS). */
16
16
  stallMs?: number;
17
- /** The run's stop (a stop, a cancel, a lost claim): every waiter leaves the line at it, admitted for nothing. */
17
+ /** The run's stop (a stop, a cancel, a lost claim): every waiter but an owed step leaves the line at it, admitted for
18
+ * nothing. */
18
19
  stopped?: AbortSignal;
19
20
  }
20
21
  /** How soon a waiter reads the run's records again, first and at the slowest (it doubles between them). */
@@ -45,7 +45,8 @@
45
45
  // cancel, a lost claim), when the run stops (`stopped`, for a paid call or a decision too), when its booking stops (`halted`: thrown, as a stop that came during the check), or when the
46
46
  // run parks meanwhile (`parked`: refused in its own words, so nothing more is sent until a raise).
47
47
  // - Nothing is admitted once its signal is aborted: a step that comes, or reaches its turn, after its client went or the
48
- // run stopped is refused with the signal's reason, before any read, so no call starts or is charged after a stop.
48
+ // run stopped is refused with the signal's reason, before any read, so no call starts or is charged after a stop. Money
49
+ // already owed (`paid.owed`) is the run's stop's exception: nothing starts with it, and the run books it as it lets go.
49
50
  import { sessionSpendOf } from "./runner.js";
50
51
  import { freeRequestsIn, localRequestsIn } from "./kernel/cap/free.js";
51
52
  /** How soon a waiter reads the run's records again, first and at the slowest (it doubles between them). */
@@ -209,8 +210,10 @@ export function runBooking(sessions, before, options = {}) {
209
210
  };
210
211
  return async (request) => {
211
212
  // What ends its wait: its own client's going (a model request's), or the run's stop (any step's: a paid call's or a
212
- // decision's has no client of its own here).
213
- const signal = request.signal && options.stopped ? AbortSignal.any([request.signal, options.stopped]) : (request.signal ?? options.stopped);
213
+ // decision's has no client of its own here), but for money already owed: nothing starts with it, so the stop never
214
+ // refuses it (a computer's last stretch, a session's release, booked as the run lets go of them after its stop).
215
+ const stopped = request.paid?.owed ? undefined : options.stopped;
216
+ const signal = request.signal && stopped ? AbortSignal.any([request.signal, stopped]) : (request.signal ?? stopped);
214
217
  // Every step joins the line as it comes, before its first ask, and asks only once it is first: steps that come together
215
218
  // are asked in the order they came, so one behind a step that must wait never goes ahead of it. The first leaving
216
219
  // (admitted, refused or gone) wakes the next at once. A paid call whose own session has a request in flight goes ahead
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-kernel",
3
- "version": "0.1.0-beta.64",
3
+ "version": "0.1.0-beta.66",
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.64",
65
+ "@parcha/agentrun-dsl": "0.1.0-beta.66",
66
66
  "ajv": "8.18.0",
67
67
  "typebox": "1.3.27"
68
68
  },