@parcha/agentrun-serve 0.1.0-beta.49 → 0.1.0-beta.50

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +26 -9
  2. package/README.md +104 -22
  3. package/dist/agent-delete.d.ts +3 -2
  4. package/dist/agent-delete.js +29 -4
  5. package/dist/api-only.d.ts +7 -10
  6. package/dist/api-only.js +9 -11
  7. package/dist/compute-cost.d.ts +101 -0
  8. package/dist/compute-cost.js +250 -0
  9. package/dist/console/assets/{index-CR2ZGei1.css → index-D0mr9wfZ.css} +1 -1
  10. package/dist/console/assets/index-D7G6o-1E.js +720 -0
  11. package/dist/console/index.html +2 -2
  12. package/dist/eval-previous.d.ts +52 -0
  13. package/dist/eval-previous.js +164 -0
  14. package/dist/file-types.d.ts +2 -0
  15. package/dist/file-types.js +3 -1
  16. package/dist/harness.js +2 -1
  17. package/dist/learn/check.d.ts +8 -5
  18. package/dist/learn/check.js +25 -24
  19. package/dist/learn/repick.d.ts +22 -13
  20. package/dist/learn/repick.js +57 -56
  21. package/dist/learn/workflow-draft.d.ts +4 -0
  22. package/dist/learn/workflow-draft.js +10 -7
  23. package/dist/learned-workflow.js +8 -8
  24. package/dist/learning-setting.js +2 -2
  25. package/dist/openapi.js +25 -17
  26. package/dist/paid-calls.d.ts +13 -6
  27. package/dist/paid-calls.js +14 -8
  28. package/dist/run-launch.d.ts +2 -2
  29. package/dist/run-launch.js +2 -1
  30. package/dist/run-timeline-served.js +5 -3
  31. package/dist/run-usage.d.ts +23 -8
  32. package/dist/run-usage.js +100 -18
  33. package/dist/runner/adapter-loop.d.ts +4 -0
  34. package/dist/runner/adapter-loop.js +15 -1
  35. package/dist/runner/adapter-run-spec.d.ts +8 -3
  36. package/dist/runner/adapter-run-spec.js +13 -6
  37. package/dist/runner/big-writes.d.ts +33 -0
  38. package/dist/runner/big-writes.js +105 -0
  39. package/dist/runner/cli-run-spec.js +14 -6
  40. package/dist/runner/held.d.ts +4 -1
  41. package/dist/runner/learning-end.js +9 -4
  42. package/dist/runner/metrics.d.ts +4 -0
  43. package/dist/runner/metrics.js +9 -0
  44. package/dist/runner/run-child-host.d.ts +15 -2
  45. package/dist/runner/run-child-host.js +24 -8
  46. package/dist/runner/run-child.js +3 -0
  47. package/dist/runner/save-slots.d.ts +9 -0
  48. package/dist/runner/save-slots.js +91 -0
  49. package/dist/sdk/runs.d.ts +3 -4
  50. package/dist/sdk/runs.js +10 -7
  51. package/dist/sdk/runtimes.d.ts +19 -0
  52. package/dist/sdk/runtimes.js +23 -0
  53. package/dist/sdk/schema.d.ts +14 -8
  54. package/dist/sdk/schema.js +18 -6
  55. package/dist/server.d.ts +4 -0
  56. package/dist/server.js +3 -3
  57. package/dist/store/agent-body.d.ts +2 -3
  58. package/dist/store/agent-body.js +3 -2
  59. package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
  60. package/dist/store/schema.d.ts +8 -3
  61. package/dist/store/schema.js +12 -2
  62. package/dist/store/sqlite/connection.d.ts +3 -3
  63. package/dist/store/sqlite/connection.js +3 -3
  64. package/dist/store/sqlite/store.d.ts +2 -4
  65. package/dist/store/sqlite/store.js +95 -85
  66. package/dist/store/store.d.ts +8 -1
  67. package/dist/store-reads/cap.d.ts +9 -5
  68. package/dist/store-reads/cap.js +28 -2
  69. package/dist/store-reads/decisions.d.ts +21 -0
  70. package/dist/store-reads/decisions.js +22 -0
  71. package/dist/store-reads/journal.d.ts +8 -2
  72. package/dist/store-reads/journal.js +27 -8
  73. package/dist/store-view.d.ts +5 -1
  74. package/dist/store-view.js +37 -18
  75. package/dist/template-eval.d.ts +15 -1
  76. package/dist/template-eval.js +92 -13
  77. package/dist/templates.d.ts +1 -1
  78. package/dist/templates.js +4 -3
  79. package/dist/timeline/labels.js +17 -0
  80. package/dist/tool-list.js +1 -0
  81. package/dist/tools.d.ts +6 -2
  82. package/dist/tools.js +13 -1
  83. package/dist/trigger-targets.d.ts +21 -5
  84. package/dist/trigger-targets.js +13 -10
  85. package/dist/web-fake.d.ts +25 -0
  86. package/dist/web-fake.js +38 -1
  87. package/dist/web-save.d.ts +75 -0
  88. package/dist/web-save.js +235 -0
  89. package/dist/workspace/archil-claim.d.ts +5 -2
  90. package/dist/workspace/archil-claim.js +5 -2
  91. package/dist/workspace/archil-disk.d.ts +10 -1
  92. package/dist/workspace/archil-disk.js +19 -1
  93. package/dist/workspace/archil.d.ts +3 -0
  94. package/dist/workspace/archil.js +101 -16
  95. package/dist/workspace/computer-for-claim.d.ts +14 -0
  96. package/dist/workspace/computer-for-claim.js +46 -7
  97. package/dist/workspace/computer-intervals.d.ts +9 -3
  98. package/dist/workspace/computer-intervals.js +17 -8
  99. package/dist/workspace/pieced.d.ts +14 -0
  100. package/dist/workspace/pieced.js +23 -0
  101. package/dist/workspace/run-disk.js +32 -12
  102. package/dist/workspace/run-workspace.d.ts +1 -1
  103. package/dist/workspace/run-workspace.js +11 -6
  104. package/package.json +10 -10
  105. package/templates/README.md +36 -7
  106. package/dist/console/assets/index-Bzn4eUYF.js +0 -715
@@ -342,10 +342,11 @@ async function cliSpec(launch, run, deps, claim, holds) {
342
342
  ? undefined
343
343
  // The run's mount credential, minted per run (account key from the server's environment first, then the sealed row),
344
344
  // named for the run and this claim's epoch; revoke at the run's end (below). mountControl (a test's loopback control-plane
345
- // fake) is spread into the mount, so no test reaches the real control plane. TODO(k2 lazy mint): the mint moves into
345
+ // fake) is the claim's control, so no test reaches the real control plane. TODO(k2 lazy mint): the mint moves into
346
346
  // computerForClaim (a mounting computer only), with the ttl the run's lifetime bound (not this fixed figure). As pi does.
347
- // The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one.
348
- : await archilWhereHeld({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
347
+ // The disk is the run's (run-disk.ts): its launch record's, else its agent's, made on its first run that needs one,
348
+ // and read at Archil at every claim.
349
+ : await archilWhereHeld({ settings: archilSettings, keys: deps.store.sealedKeys, sealKey: deps.sealKey, signal: run.signal ?? new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS }, ...(deps.mountControl ? { control: deps.mountControl } : {}), run: { agentId: runRow.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store: deps.store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
349
350
  // Each resource is held the moment it exists (spec-holds.ts): a throw after it lets it go. The claim's Archil keys go
350
351
  // from memory last, once nothing more reads the disk.
351
352
  holds.hold({ archil, keys: archil });
@@ -389,7 +390,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
389
390
  // Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer), as the pi
390
391
  // spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount). Its
391
392
  // screen's recording (computer.record) goes in the run's recordings folder, as the pi spec's does.
392
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
393
+ { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
393
394
  holds.hold({ computer });
394
395
  const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
395
396
  const heldComputer = heldSpecOf(launch, loopComputer);
@@ -573,6 +574,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
573
574
  let learnedTool;
574
575
  let webTools = [];
575
576
  let life;
577
+ // The claim's computers' time booked up to now before the run's end or park is written (compute-cost.ts), so the end's
578
+ // cost holds it: the release that deletes them comes after the end.
579
+ const settleComputers = computer.settle;
580
+ if (settleComputers) {
581
+ life = hostLifecycle();
582
+ life.register.beforeRelease(() => settleComputers());
583
+ }
576
584
  // The keys the claim hands the run (its web tools and its learned workflow's call nodes run on them): never learned
577
585
  // (learningEndOfRun).
578
586
  let handedKeys = [];
@@ -620,9 +628,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
620
628
  if (launch.plane && Object.keys(launch.plane).length)
621
629
  toolEnv[TOOL_PLANE_ENV] = JSON.stringify(launch.plane);
622
630
  if (webNames.length) {
623
- life = hostLifecycle();
631
+ life ??= hostLifecycle();
624
632
  const liveAt = await claimLiveAt(deps, claim.runId);
625
- const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach, ...(liveAt ? { liveAt } : {}) });
633
+ const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach, ...(liveAt ? { liveAt } : {}), ...(deps.saveSlots ? { saveSlots: deps.saveSlots } : {}) });
626
634
  gate.askedOn(host);
627
635
  webTools = await webHostTools(host, granted, ctx);
628
636
  }
@@ -7,6 +7,7 @@ import type { ApprovalPrice, ToolEffect } from "../tool-gate.js";
7
7
  import type { OpenedAccount } from "../email/account.js";
8
8
  import type { SavedCalendar } from "../calendar/address.js";
9
9
  import type { Workspace } from "../workspace/workspace.js";
10
+ import type { Pieces } from "../workspace/pieced.js";
10
11
  import type { GithubAppAccessAt } from "./github-app.js";
11
12
  import type { HarnessInstallEntry, HarnessPins } from "../harness-install.js";
12
13
  import type { RunModelKey } from "../store/seal.js";
@@ -111,9 +112,11 @@ export interface Held {
111
112
  install(name: string, signal?: AbortSignal): Promise<void>;
112
113
  /** The claim's computer (workspace/computer-for-claim.ts), made and held by the runner. */
113
114
  computer(ask: HeldComputerAsk): Promise<unknown>;
114
- /** A Mode 2 claim: the run's folder on its Archil disk, as the runner opens it; its mount credential's revoke. */
115
+ /** A Mode 2 claim: the run's folder on its Archil disk, as the runner opens it; its mount credential's revoke. `pieces`:
116
+ * the runner's pieced write on that Workspace (big-writes.ts), what a write bigger than a piece goes through. */
115
117
  archil(): Promise<{
116
118
  readonly workspace: Workspace;
119
+ readonly pieces?: Pieces;
117
120
  revoke(): Promise<void>;
118
121
  inherit(): Promise<void>;
119
122
  release(): Promise<void>;
@@ -23,7 +23,8 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
23
23
  import { isMessageRow } from "../timeline/index.js";
24
24
  import { correctionRefused, learningCommit } from "../learn/commit.js";
25
25
  import { CAPS, checkDraft, problemWords, unstorable } from "../learn/index.js";
26
- import { repickRewrite } from "../learn/repick.js";
26
+ import { repickSiteOf } from "../learn/check.js";
27
+ import { repickLabelOf, repickRewrite } from "../learn/repick.js";
27
28
  import { folderAt, readLearning, readSnapshot, runMergeOf, snapshotAt, textsAt } from "../learn/folder.js";
28
29
  import { completedRun, compileStoppedOf, lastOwnRuns, compileDue, compilePrompt, compileReference, COMPILE_TRACES, DRAFT_FAILED, heldNamesOf, newCompileAttempt } from "../learn/compile.js";
29
30
  import { loopOf, repickOf } from "../learning-setting.js";
@@ -379,10 +380,14 @@ export async function checkDraftOf(deps, input) {
379
380
  return refused(problems);
380
381
  // With learning.repick on, what is committed is the draft with its answer's re-pick reading the run's pages on its
381
382
  // second pass (learn/repick.ts), through the same checks and dry run, so the digest that serves is the doc the
382
- // promotion check replays. A rewrite they refuse (one past CAPS.file even on one line) leaves the draft as compiled,
383
- // which the log says by rule alone.
383
+ // promotion check replays. A re-pick the rewrite does not reach, or a rewrite they refuse (one past CAPS.file even on
384
+ // one line), leaves the draft as compiled, which the log says (the latter by rule alone).
384
385
  let text = json;
385
- const rewritten = repick?.repick ? repickRewrite(JSON.parse(json), repick.repick_max_chars) : undefined;
386
+ const doc = repick?.repick ? JSON.parse(json) : undefined;
387
+ const site = repickSiteOf(doc);
388
+ const rewritten = repick?.repick ? repickRewrite(doc, site, repick.repick_max_chars) : undefined;
389
+ if (site && repick?.repick && !rewritten)
390
+ deps.log?.(`learning.repick: workflow ${name} is kept as compiled: its re-pick ${JSON.stringify(repickLabelOf(site))} is not one the rewrite reaches`);
386
391
  if (rewritten) {
387
392
  const marked = workflowText(rewritten);
388
393
  const again = marked === json ? [] : await checked(marked);
@@ -61,6 +61,10 @@ export declare function storedBasisOf(metrics: unknown, usd: number | null | und
61
61
  * booking's. `side`: of the model requests, those booked as side calls (another model than the session's, or the host's
62
62
  * own, as a learned workflow's node is: the proxy's `side`/`host`), which no answer of a pi run carries. */
63
63
  export declare function bookedSpend(entries: readonly EntryLike[], which: "model" | "paid" | "decisions" | "side"): BookedSpend;
64
+ /** The run's decisions whose ids are in `ids` (each booked as `decision:<id>`), as bookedSpend reads its decisions, with
65
+ * every other decision left out: the ones a vendor charged as a paid call (store-reads/decisions.ts
66
+ * parallelChargedDecisions), which the run's tools figures count beside its paid tool calls. */
67
+ export declare function bookedDecisionsOf(entries: readonly EntryLike[], ids: ReadonlySet<string>): BookedSpend;
64
68
  /** A cost of charges as a usage row or a run's cost block says it (costsofar/1, cutathold/1), by the kernel's one rule
65
69
  * (costOfParts) over `parts`, its float noise rounded off (floatNoiseOff): `usd` their sum, `upper_bound` when it counts
66
70
  * a cut request at its hold, with `so_far_usd` the charges' own figures alone and `unpriced` how many it counts at their
@@ -148,6 +148,15 @@ export function bookedSpend(entries, which) {
148
148
  }
149
149
  return { usd: unpriced ? null : known + bounded, known, bounded, unpriced, atMost, requests, unmetered, models, tokens, priced: { reported, estimated }, ...(requests > 0 && free === requests ? { free: true } : {}) };
150
150
  }
151
+ /** The run's decisions whose ids are in `ids` (each booked as `decision:<id>`), as bookedSpend reads its decisions, with
152
+ * every other decision left out: the ones a vendor charged as a paid call (store-reads/decisions.ts
153
+ * parallelChargedDecisions), which the run's tools figures count beside its paid tool calls. */
154
+ export function bookedDecisionsOf(entries, ids) {
155
+ const turnOf = (e) => `${String(e.conversationId)}:${String(e.data?.turn)}`;
156
+ const named = (e) => e.data?.model;
157
+ const kept = new Set(entries.filter((e) => e.kind === RUNNER_RECORDS.request && typeof named(e) === "string" && named(e).startsWith("decision:") && ids.has(named(e).slice("decision:".length))).map(turnOf));
158
+ return bookedSpend(entries.filter((e) => !(e.kind === RUNNER_RECORDS.request || e.kind === RUNNER_RECORDS.turn) || kept.has(turnOf(e))), "decisions");
159
+ }
151
160
  /** A sum of charges with its float noise rounded off, nothing more (as the decisions row rounds, decision-rows.ts): a
152
161
  * decision costs millionths of a dollar, so a sum rounded to the millionth would lose it. */
153
162
  const floatNoiseOff = (usd) => Math.round(usd * 1e12) / 1e12;
@@ -1,8 +1,12 @@
1
1
  import { type Stats } from "node:fs";
2
+ import type { Duplex } from "node:stream";
2
3
  import type { Workspace } from "../workspace/workspace.js";
3
4
  import { type AdapterSpecDeps } from "./adapter-run-spec.js";
4
5
  import type { Held } from "./held.js";
5
6
  import { type Claim, type LoopFactory } from "./loop-contract.js";
7
+ import { Channel } from "./run-channel.js";
8
+ import { type RunBigWrites } from "./big-writes.js";
9
+ import { type SaveSlots } from "../web-save.js";
6
10
  import { type RunLaunch } from "../run-launch.js";
7
11
  /** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
8
12
  export declare const RUNAS_HELPER = "/usr/local/bin/agentrun-runas";
@@ -118,10 +122,11 @@ interface ClaimReads {
118
122
  readonly claimed: NodeJS.ProcessEnv;
119
123
  }
120
124
  /** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
121
- * runner's own reads of the claim; every argument from the run's process is checked or ignored. */
125
+ * runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
126
+ * writes (big-writes.ts), let go at the claim's release and, by the caller, when the run's channel ends. */
122
127
  export declare function heldFor(deps: AdapterSpecDeps & {
123
128
  readonly sealKey: Buffer;
124
- }, reads: ClaimReads, cut: (text: string) => string, log: (line: string) => void): {
129
+ }, reads: ClaimReads, cut: (text: string) => string, log: (line: string) => void, bigs?: RunBigWrites): {
125
130
  held: Held;
126
131
  inputs(): Promise<void>;
127
132
  release(): Promise<void>;
@@ -166,4 +171,12 @@ export declare function staysInRunner(deps: Pick<AdapterSpecDeps, "store" | "dat
166
171
  /** The runner's loop factory where each run is a process of its own: a ChildLoop per claim, but for a run that stays in
167
172
  * the runner (staysInRunner). */
168
173
  export declare function childLoops(options: ChildLoopsOptions): LoopFactory;
174
+ /** The runner's side of a run's channel over `socket`. Each call of the run's process runs inside the ledger of the tool
175
+ * call it was made in (paid-calls.ts). web_save's slots are `gate`, this runner's one (save-slots.ts); the channel's end
176
+ * (the run's end, or its process gone) gives back every slot the run held or waited for, and lets go of every pieced write
177
+ * of the run's `bigs` (big-writes.ts), held or waiting. `maxFrame`: the channel's (a test's), default MAX_FRAME. */
178
+ export declare function runChannel(socket: Duplex, onClose: (why: Error) => void, gate?: SaveSlots, more?: {
179
+ readonly bigs?: RunBigWrites;
180
+ readonly maxFrame?: number;
181
+ }): Channel;
169
182
  export {};
@@ -66,6 +66,9 @@ import { heardComputerHold } from "./computer-journal.js";
66
66
  import { ClaimRefused } from "./loop-contract.js";
67
67
  import { Channel, ChannelClosed } from "./run-channel.js";
68
68
  import { registerRunErrors } from "./run-errors.js";
69
+ import { exposeSaveSlots } from "./save-slots.js";
70
+ import { runBigWrites } from "./big-writes.js";
71
+ import { SERVER_SLOTS } from "../web-save.js";
69
72
  import { readLaunchBody } from "../run-launch.js";
70
73
  import { SUBAGENT_TOOL } from "./subagent.js";
71
74
  /** The image's helper that starts a run's process as its slot's uid (packages/serve/runas). */
@@ -627,14 +630,15 @@ async function readOf(reads, method, args) {
627
630
  /** The email tools a revision may grant. */
628
631
  const grantsEmail = (granted) => granted.some((tool) => tool.startsWith("email_"));
629
632
  /** Held (held.ts) for one claim, on the runner: each answer the claim's own, read with the runner's seal key from the
630
- * runner's own reads of the claim; every argument from the run's process is checked or ignored. */
631
- export function heldFor(deps, reads, cut, log) {
633
+ * runner's own reads of the claim; every argument from the run's process is checked or ignored. `bigs`: the run's pieced
634
+ * writes (big-writes.ts), let go at the claim's release and, by the caller, when the run's channel ends. */
635
+ export function heldFor(deps, reads, cut, log, bigs = runBigWrites()) {
632
636
  const { claim, run, launch, revision, claimed } = reads;
633
637
  const sealKey = deps.sealKey;
634
638
  const store = deps.store;
635
639
  const granted = revision.body.tools ?? [];
636
640
  const keys = { store, sealKey, env: deps.env };
637
- const releases = [];
641
+ const releases = [() => bigs.close()];
638
642
  const fromGitHub = launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github";
639
643
  const github = () => githubAppAccess(store, sealKey, launch.input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) });
640
644
  /** Mode 2's Archil claim, made once for the claim on the runner, its folder the run's. */
@@ -643,7 +647,7 @@ export function heldFor(deps, reads, cut, log) {
643
647
  const settings = await loadArchilSettings(store, deps.env);
644
648
  if (settings === undefined)
645
649
  return undefined;
646
- const made = await archilClaim({ settings, keys: store.sealedKeys, sealKey, signal: new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS, ...(deps.mountControl ?? {}) }, run: { agentId: run.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
650
+ const made = await archilClaim({ settings, keys: store.sealedKeys, sealKey, signal: new AbortController().signal, env: deps.env, mount: { runId: claim.runId, epoch: claim.epoch, ttlMs: MOUNT_TTL_MS }, ...(deps.mountControl ? { control: deps.mountControl } : {}), run: { agentId: run.agentId, ...(launch.archilDisk ? { launch: launch.archilDisk } : {}), store }, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) });
647
651
  releases.push(() => made.release());
648
652
  return made;
649
653
  })());
@@ -798,7 +802,8 @@ export function heldFor(deps, reads, cut, log) {
798
802
  return undefined;
799
803
  const ws = await openRunWorkspace({ mode: 2, agentId: run.agentId, runId: claim.runId, archil: made, log });
800
804
  releases.push(() => ws.end());
801
- return { workspace: ws.workspace, revoke: () => made.revoke(), inherit: async () => made.inherit(), release: async () => { } };
805
+ // A write bigger than the channel's frame is pulled in pieces and written here, on this Workspace (big-writes.ts).
806
+ return { workspace: ws.workspace, pieces: bigs.pieces(ws.workspace), revoke: () => made.revoke(), inherit: async () => made.inherit(), release: async () => { } };
802
807
  },
803
808
  endOfRun: async (input) => {
804
809
  // The step as the run's spec builds it in a runner (adapter-run-spec.ts), over the runner's reads of the claim: what
@@ -1009,6 +1014,16 @@ function childEnv(base, keys, extra) {
1009
1014
  delete env[name];
1010
1015
  return { ...env, ...extra, [SECRETS_FD_ENV]: "3", [SECRETS_LEN_ENV]: String(keys.length) };
1011
1016
  }
1017
+ /** The runner's side of a run's channel over `socket`. Each call of the run's process runs inside the ledger of the tool
1018
+ * call it was made in (paid-calls.ts). web_save's slots are `gate`, this runner's one (save-slots.ts); the channel's end
1019
+ * (the run's end, or its process gone) gives back every slot the run held or waited for, and lets go of every pieced write
1020
+ * of the run's `bigs` (big-writes.ts), held or waiting. `maxFrame`: the channel's (a test's), default MAX_FRAME. */
1021
+ export function runChannel(socket, onClose, gate = SERVER_SLOTS, more = {}) {
1022
+ let saves;
1023
+ const channel = new Channel(socket, { onClose: (why) => { onClose(why); saves?.(); more.bigs?.close(); }, within: withinCarried, ...(more.maxFrame ? { maxFrame: more.maxFrame } : {}) });
1024
+ saves = exposeSaveSlots(channel, gate);
1025
+ return channel;
1026
+ }
1012
1027
  function childLoop(options, slots, loopDeps) {
1013
1028
  const { deps, isolation } = options;
1014
1029
  const cut = loopDeps.redact ?? ((text) => text);
@@ -1120,7 +1135,9 @@ function childLoop(options, slots, loopDeps) {
1120
1135
  if (isolation.kind === "uid" && slot !== undefined)
1121
1136
  hold = new SlotHold(slot, isolation.helper, log);
1122
1137
  const tops = runTops(deps.data, runRow.agentId, claim.runId);
1123
- const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed }, cut, log);
1138
+ // The run's pieced writes (big-writes.ts): let go when its channel ends, or at the claim's release.
1139
+ const bigs = runBigWrites();
1140
+ const heldSide = heldFor({ ...deps, env: claimEnv }, { claim, run: runRow, launch, revision, claimed: gatewayKey ? withGatewayKey(claimed, gatewayKey) : claimed }, cut, log, bigs);
1124
1141
  try {
1125
1142
  let extra = {};
1126
1143
  let argv = [...(options.argv ?? childArgv())];
@@ -1151,8 +1168,7 @@ function childLoop(options, slots, loopDeps) {
1151
1168
  keyPipe.end(keys);
1152
1169
  const socket = child.stdio[4];
1153
1170
  let broke;
1154
- // Each call of the run's process runs inside the ledger of the tool call it was made in (paid-calls.ts).
1155
- channel = new Channel(socket, { onClose: (why) => void (broke ??= why), within: withinCarried });
1171
+ channel = runChannel(socket, (why) => void (broke ??= why), SERVER_SLOTS, { bigs });
1156
1172
  const bound = { claim, agentId: runRow.agentId, revisionId: runRow.revisionId };
1157
1173
  channel.expose("store", (method, args) => storeCall(deps.store, method, args, bound, log));
1158
1174
  channel.expose("journal", journalTarget(loopDeps.journal(claim), cut));
@@ -16,6 +16,7 @@ import { routeOf } from "./model-route.js";
16
16
  import { heldRedactor, processSecretRedactor } from "./redact.js";
17
17
  import { Channel } from "./run-channel.js";
18
18
  import { registerRunErrors } from "./run-errors.js";
19
+ import { remoteSaveSlots } from "./save-slots.js";
19
20
  import { runEnv } from "./main.js";
20
21
  import { carriedLedger } from "../paid-calls.js";
21
22
  import { heldHands } from "../workspace/computer-hold.js";
@@ -179,6 +180,8 @@ function childDeps(init, store, journal, held) {
179
180
  computerForClaim,
180
181
  computerDeps: {},
181
182
  installForClaim: heldInstall,
183
+ // web_save's download slots are the runner's, shared by all its runs (save-slots.ts).
184
+ saveSlots: remoteSaveSlots(channel),
182
185
  ...(init.githubApi ? { githubApi: init.githubApi } : {}),
183
186
  ...(init.githubWeb ? { githubWeb: init.githubWeb } : {}),
184
187
  ...(init.githubMcpOrigin ? { githubMcpOrigin: init.githubMcpOrigin } : {}),
@@ -0,0 +1,9 @@
1
+ import { type Channel } from "./run-channel.js";
2
+ import { type SaveSlots } from "../web-save.js";
3
+ /** The most takes one run may have held or waiting at once: a run's waiters live in the runner, so a run may not queue
4
+ * without bound. */
5
+ export declare const SAVE_SLOTS_PER_RUN = 16;
6
+ /** Exposes `gate` on the runner's side of a run's `channel`. Answers what the runner calls when that channel ends. */
7
+ export declare function exposeSaveSlots(channel: Pick<Channel, "expose">, gate: SaveSlots): () => void;
8
+ /** A run process's web_save slots: its runner's gate, taken over `channel`. */
9
+ export declare function remoteSaveSlots(channel: Pick<Channel, "call">): SaveSlots;
@@ -0,0 +1,91 @@
1
+ // web_save's download slots (web-save.ts saveSlots) across a runner's runs. Each run runs in a process of its own
2
+ // (run-child-host.ts), so a gate in that process would be one per run. The bound is per runner, the process that holds
3
+ // the claims: its one gate (web-save.ts SERVER_SLOTS) is exposed on each run's channel, and a run's web_save takes its
4
+ // slots there. The run's process is untrusted: a release frees only its own take's slot, once, and every slot a run
5
+ // holds or waits for is let go when its channel ends (its process crashed, was killed, or its run ended).
6
+ import { ClaimRefused } from "./loop-contract.js";
7
+ import { ChannelClosed } from "./run-channel.js";
8
+ import { SAVE_CONCURRENCY } from "../web-save.js";
9
+ const TARGET = "saves";
10
+ /** The most takes one run may have held or waiting at once: a run's waiters live in the runner, so a run may not queue
11
+ * without bound. */
12
+ export const SAVE_SLOTS_PER_RUN = 16;
13
+ /** Exposes `gate` on the runner's side of a run's `channel`. Answers what the runner calls when that channel ends. */
14
+ export function exposeSaveSlots(channel, gate) {
15
+ const held = new Set();
16
+ const waits = new Set();
17
+ let closed = false;
18
+ channel.expose(TARGET, async (method, args) => {
19
+ if (method !== "take")
20
+ throw new ClaimRefused(`the runner has no ${method} for a run's download slots`);
21
+ const [signal] = args;
22
+ if (!(signal instanceof AbortSignal))
23
+ throw new TypeError("a download slot is taken under the call's signal");
24
+ if (closed)
25
+ throw new ChannelClosed("the run's channel ended");
26
+ if (held.size + waits.size >= SAVE_SLOTS_PER_RUN)
27
+ throw new ClaimRefused(`this run already has ${SAVE_SLOTS_PER_RUN} web_save downloads held or waiting`);
28
+ const left = new AbortController();
29
+ waits.add(left);
30
+ let release;
31
+ try {
32
+ release = await gate.take(AbortSignal.any([signal, left.signal]));
33
+ }
34
+ finally {
35
+ waits.delete(left);
36
+ }
37
+ // Granted as the channel ended: no answer reaches the run, so the slot goes back now.
38
+ if (closed) {
39
+ release();
40
+ throw new ChannelClosed("the run's channel ended");
41
+ }
42
+ held.add(release);
43
+ // The gate's release is once only: a second call frees nothing.
44
+ return () => {
45
+ held.delete(release);
46
+ release();
47
+ };
48
+ });
49
+ return () => {
50
+ if (closed)
51
+ return;
52
+ closed = true;
53
+ for (const wait of waits)
54
+ wait.abort(new ChannelClosed("the run's channel ended"));
55
+ for (const release of held)
56
+ release();
57
+ held.clear();
58
+ };
59
+ }
60
+ /** A run process's web_save slots: its runner's gate, taken over `channel`. */
61
+ export function remoteSaveSlots(channel) {
62
+ let busy = 0;
63
+ let waiting = 0;
64
+ return {
65
+ size: SAVE_CONCURRENCY,
66
+ get busy() { return busy; },
67
+ get waiting() { return waiting; },
68
+ async take(signal) {
69
+ waiting++;
70
+ let release;
71
+ try {
72
+ release = await channel.call(TARGET, "take", [signal]);
73
+ }
74
+ finally {
75
+ waiting--;
76
+ }
77
+ if (typeof release !== "function")
78
+ throw new TypeError("the runner answered no release for a download slot");
79
+ busy++;
80
+ let done = false;
81
+ return () => {
82
+ if (done)
83
+ return;
84
+ done = true;
85
+ busy--;
86
+ // A release that cannot cross (the channel ended) is no loss: the runner frees the slot when the channel ends.
87
+ Promise.resolve(release()).catch(() => { });
88
+ };
89
+ },
90
+ };
91
+ }
@@ -4,7 +4,8 @@ import { type StartDeps } from "../runs-over-store.js";
4
4
  import { type LearnedWorkflow } from "../learning.js";
5
5
  import type { SdkWorkflowCheckEvent } from "./check.js";
6
6
  import { type SdkWorkflowCheck } from "../runner/promotion.js";
7
- export type SdkRuntime = "claude-agent-sdk" | "codex-sdk" | "eve";
7
+ import { type SdkBinding } from "./runtimes.js";
8
+ export { SDK_RUNTIMES, isSdkRuntime, type SdkRuntime } from "./runtimes.js";
8
9
  export type SdkUsage = {
9
10
  input_tokens: number | null;
10
11
  output_tokens: number | null;
@@ -56,9 +57,7 @@ export type SdkInbox = {
56
57
  };
57
58
  /** The settings key an SDK run's record is kept under (the run's delete with its agent's: agent-delete.ts). */
58
59
  export declare const sdkRunKey: (id: string) => string;
59
- export declare const sdkOf: (body: unknown) => {
60
- runtime: SdkRuntime;
61
- } | undefined;
60
+ export declare const sdkOf: (body: unknown) => SdkBinding | undefined;
62
61
  export declare function sdkInbox(store: Pick<Store, "settings">, runId: string): Promise<SdkInbox>;
63
62
  /** Completion and closure compete on the same inbox. A stale runner cannot close it, and a completion that won
64
63
  * remains available to the next claim even if this one cannot read or journal it. No external SDK call is replayed. */
package/dist/sdk/runs.js CHANGED
@@ -17,6 +17,8 @@ import { sdkWorkflowManifest, sdkDraftTools } from "./workflows.js";
17
17
  import { promotionOf, promotionsOf } from "../learn/promote.js";
18
18
  import { championTextOf, releaseSdkCheck, reserveSdkCheck } from "../runner/promotion.js";
19
19
  import { fits, workflowDigest } from "../runner/workflow-first.js";
20
+ import { SDK_WORKFLOW_RUNTIMES, sdkBindingOf } from "./runtimes.js";
21
+ export { SDK_RUNTIMES, isSdkRuntime } from "./runtimes.js";
20
22
  const keyOf = (id) => `sdk-run:${id}`;
21
23
  /** The settings key an SDK run's record is kept under (the run's delete with its agent's: agent-delete.ts). */
22
24
  export const sdkRunKey = keyOf;
@@ -51,9 +53,7 @@ const usageOf = (value) => {
51
53
  }
52
54
  return result;
53
55
  };
54
- export const sdkOf = (body) => isObject(body) && isObject(body.sdk) && (body.sdk.runtime === "claude-agent-sdk" || body.sdk.runtime === "codex-sdk" || body.sdk.runtime === "eve")
55
- ? { runtime: body.sdk.runtime }
56
- : undefined;
56
+ export const sdkOf = (body) => isObject(body) ? sdkBindingOf(body.sdk) : undefined;
57
57
  export async function sdkInbox(store, runId) {
58
58
  const row = await store.settings.get(keyOf(runId));
59
59
  if (!isObject(row))
@@ -163,7 +163,10 @@ export class SdkRuns {
163
163
  return redactedOutput(body, redact.heldValues?.() ?? []);
164
164
  }
165
165
  async start(entry, body, deps, origin, compile, consoleOrigin) {
166
- only(body, ["runtime", "input", "instructions", "model", "workflow_tools", "workflow_adapters"]);
166
+ only(body, ["runtime", "platform", "input", "instructions", "model", "workflow_tools", "workflow_adapters"]);
167
+ const source = sdkBindingOf(body) ?? refuse("The SDK source needs a supported runtime; external requires a platform label of 1–80 characters without surrounding whitespace, controls or lone surrogates. Other runtimes do not take platform.");
168
+ if (!SDK_WORKFLOW_RUNTIMES.includes(source.runtime) && (body.workflow_tools !== undefined || body.workflow_adapters !== undefined))
169
+ refuse("External runs receive owner corrections; workflow_tools and workflow_adapters require a backend workflow bridge.");
167
170
  const workflow = sdkWorkflowManifest(body.workflow_tools, body.workflow_adapters);
168
171
  if (workflow && canonical(this.clean(workflow)) !== canonical(workflow))
169
172
  refuse("The workflow manifest contains a protected value; keep credentials in the backend.");
@@ -172,8 +175,8 @@ export class SdkRuns {
172
175
  throw new ApiError("agent_not_runnable", "This agent is not registered as a backend SDK agent.");
173
176
  if (entry.agent.archivedAt !== null)
174
177
  throw new ApiError("agent_archived", "This SDK agent is archived.");
175
- if (body.runtime !== binding.runtime)
176
- refuse("The SDK runtime must match the registered agent.");
178
+ if (source.runtime !== binding.runtime || source.platform !== binding.platform)
179
+ refuse("The SDK runtime and platform must match the registered agent.");
177
180
  const input = text(body.input, "input"), instructions = text(body.instructions, "instructions");
178
181
  const model = body.model === undefined ? undefined : text(body.model, "model", 256);
179
182
  if (origin) {
@@ -231,7 +234,7 @@ export class SdkRuns {
231
234
  place: { mode: "runner" },
232
235
  harness: "sdk",
233
236
  sdk: {
234
- runtime: binding.runtime,
237
+ ...binding,
235
238
  ...workflow,
236
239
  instructions: cleaned.instructions,
237
240
  ...(cleaned.model ? { model: cleaned.model } : {}),
@@ -0,0 +1,19 @@
1
+ /** Execution stays with the caller. External platforms report through the same API without becoming a managed
2
+ * harness or acquiring a workflow bridge. Their platform is a display label, never a capability selector. */
3
+ export declare const SDK_RUNTIMES: readonly ["claude-agent-sdk", "codex-sdk", "eve", "external"];
4
+ export type SdkRuntime = (typeof SDK_RUNTIMES)[number];
5
+ export type SdkBinding = {
6
+ runtime: Exclude<SdkRuntime, "external">;
7
+ platform?: never;
8
+ } | {
9
+ runtime: "external";
10
+ platform: string;
11
+ };
12
+ /** Only these integrations supply a backend workflow bridge. */
13
+ export declare const SDK_WORKFLOW_RUNTIMES: readonly SdkRuntime[];
14
+ export declare const isSdkRuntime: (value: unknown) => value is SdkRuntime;
15
+ export declare const SDK_PLATFORM_MAX_LENGTH = 80;
16
+ export declare const SDK_PLATFORM_PATTERN = "^(?!\\s)(?![\\s\\S]*\\s$)[^\\u0000-\\u001f\\u007f-\\u009f\\ud800-\\udfff]+$";
17
+ export declare const isSdkPlatform: (value: unknown) => value is string;
18
+ /** Read just the source identity from a binding, start body or persisted launch. Callers check their own extra keys. */
19
+ export declare function sdkBindingOf(value: unknown): SdkBinding | undefined;
@@ -0,0 +1,23 @@
1
+ /** Execution stays with the caller. External platforms report through the same API without becoming a managed
2
+ * harness or acquiring a workflow bridge. Their platform is a display label, never a capability selector. */
3
+ export const SDK_RUNTIMES = ["claude-agent-sdk", "codex-sdk", "eve", "external"];
4
+ /** Only these integrations supply a backend workflow bridge. */
5
+ export const SDK_WORKFLOW_RUNTIMES = ["claude-agent-sdk", "codex-sdk", "eve"];
6
+ export const isSdkRuntime = (value) => typeof value === "string" && SDK_RUNTIMES.includes(value);
7
+ export const SDK_PLATFORM_MAX_LENGTH = 80;
8
+ // Unicode mode treats a surrogate pair as one character; the range rejects only a lone half. Keep the schema and
9
+ // runtime check identical, including the refusal to trim a label that participates in an agent's identity.
10
+ export const SDK_PLATFORM_PATTERN = "^(?!\\s)(?![\\s\\S]*\\s$)[^\\u0000-\\u001f\\u007f-\\u009f\\ud800-\\udfff]+$";
11
+ const platformPattern = new RegExp(SDK_PLATFORM_PATTERN, "u");
12
+ export const isSdkPlatform = (value) => typeof value === "string" && [...value].length <= SDK_PLATFORM_MAX_LENGTH && platformPattern.test(value);
13
+ /** Read just the source identity from a binding, start body or persisted launch. Callers check their own extra keys. */
14
+ export function sdkBindingOf(value) {
15
+ if (!value || typeof value !== "object" || Array.isArray(value))
16
+ return undefined;
17
+ const { runtime, platform } = value;
18
+ if (!isSdkRuntime(runtime))
19
+ return undefined;
20
+ if (runtime === "external")
21
+ return isSdkPlatform(platform) ? { runtime, platform } : undefined;
22
+ return platform === undefined ? { runtime } : undefined;
23
+ }
@@ -1,15 +1,21 @@
1
1
  export declare const SDK_BINDING: {
2
- type: string;
3
- additionalProperties: boolean;
4
- properties: Record<string, unknown>;
5
- required: string[];
2
+ "x-agentrun-python-preserve-object": boolean;
3
+ oneOf: {
4
+ type: string;
5
+ additionalProperties: boolean;
6
+ properties: Record<string, unknown>;
7
+ required: string[];
8
+ }[];
6
9
  };
7
10
  export declare const SDK_RUN: {
8
11
  "x-agentrun-serve": string;
9
- type: string;
10
- additionalProperties: boolean;
11
- properties: Record<string, unknown>;
12
- required: string[];
12
+ "x-agentrun-python-preserve-object": boolean;
13
+ oneOf: {
14
+ type: string;
15
+ additionalProperties: boolean;
16
+ properties: Record<string, unknown>;
17
+ required: string[];
18
+ }[];
13
19
  };
14
20
  export declare const SDK_PATHS: {
15
21
  "/agents/{agent_id}/sdk-runs": {
@@ -1,4 +1,5 @@
1
1
  import { MCP_TOOL_KEY_PATTERN } from "../tool-names.js";
2
+ import { SDK_RUNTIMES, SDK_PLATFORM_MAX_LENGTH, SDK_PLATFORM_PATTERN } from "./runtimes.js";
2
3
  const text = { type: "string" };
3
4
  const object = (properties, required = Object.keys(properties)) => ({
4
5
  type: "object",
@@ -6,14 +7,26 @@ const object = (properties, required = Object.keys(properties)) => ({
6
7
  properties,
7
8
  required,
8
9
  });
9
- export const SDK_BINDING = object({ runtime: { enum: ["claude-agent-sdk", "codex-sdk", "eve"] } });
10
+ const platform = {
11
+ ...text, minLength: 1, maxLength: SDK_PLATFORM_MAX_LENGTH, pattern: SDK_PLATFORM_PATTERN,
12
+ description: "External source's display label, such as openclaw or capy. Preserved exactly; no surrounding whitespace, controls or lone surrogates. Never selects a managed harness or workflow capability.",
13
+ };
14
+ /** Closed alternatives keep platform required only for external sources in every generated client. External starts
15
+ * do not accept bridge fields, even an empty catalog: a platform name never confers an integration's capabilities. */
16
+ const sdkObject = (properties = {}, required = Object.keys(properties)) => ({
17
+ "x-agentrun-python-preserve-object": true,
18
+ oneOf: [
19
+ object({ runtime: { enum: SDK_RUNTIMES.filter(runtime => runtime !== "external") }, ...properties }, ["runtime", ...required]),
20
+ object({ runtime: { const: "external" }, platform, ...Object.fromEntries(Object.entries(properties).filter(([key]) => key !== "workflow_tools" && key !== "workflow_adapters")) }, ["runtime", "platform", ...required]),
21
+ ],
22
+ });
23
+ export const SDK_BINDING = sdkObject();
10
24
  const usage = object(Object.fromEntries(["input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "cost_usd"].map((key) => [
11
25
  key,
12
26
  { type: [key === "cost_usd" ? "number" : "integer", "null"], minimum: 0 },
13
27
  ])), []);
14
28
  export const SDK_RUN = {
15
- ...object({
16
- runtime: SDK_BINDING.properties.runtime,
29
+ ...sdkObject({
17
30
  model: { type: ["string", "null"] },
18
31
  session_id: { type: ["string", "null"] },
19
32
  learning_revision: { type: ["string", "null"] },
@@ -67,8 +80,7 @@ export const SDK_PATHS = {
67
80
  summary: "Register a task executed by an existing backend SDK",
68
81
  description: "Requires an SDK agent definition. Captures the actual original policy and input, pins promoted workflows and any compiled shadow-check candidate separately, and returns a credential scoped to this run. The backend retains all model/tool/auth settings. Learning requires a configured server reflection/grading model; learning Off needs no server model key.",
69
82
  parameters: [id("agent_id"), { ...key, required: true }],
70
- requestBody: body(object({
71
- runtime: SDK_BINDING.properties.runtime,
83
+ requestBody: body(sdkObject({
72
84
  input: { ...text, maxLength: 128000 },
73
85
  instructions: { ...text, maxLength: 128000 },
74
86
  model: { ...text, maxLength: 256 },
@@ -81,7 +93,7 @@ export const SDK_PATHS = {
81
93
  price_usd: { type: "number", minimum: 0 },
82
94
  }, ["name", "description", "input_schema", "permission"]) },
83
95
  workflow_adapters: { type: "array", maxItems: 2, uniqueItems: true, items: { enum: ["runNode", "runJudge"] }, description: "Optional backend callbacks available for workflow model and decision nodes. Default empty; requires workflow_tools." },
84
- }, ["runtime", "input", "instructions"])),
96
+ }, ["input", "instructions"])),
85
97
  responses: {
86
98
  201: response(object({
87
99
  run_id: text,
package/dist/server.d.ts CHANGED
@@ -211,6 +211,10 @@ export type ServeOptions = {
211
211
  /** A test's seam: awaited at each step's point of DELETE /agents/{id} and DELETE /runs/{id} (agent-delete.ts
212
212
  * AgentDeleteStep), with the agent's id or the run's, so a throw there stops the delete as a crash would. */
213
213
  agentDeleteAt?: (step: AgentDeleteStep, id: string) => void | Promise<void>;
214
+ /** A test's seam: told each time a request waits in an agent's delete turn behind another (agent-delete.ts oneAtATime),
215
+ * with the agent's id and how many of its requests wait there now, so a test knows a write sent while a DELETE is
216
+ * held is queued behind it before it lets the DELETE go. */
217
+ deleteTurnQueued?: (agentId: string, waiting: number) => void;
214
218
  /** A test's seam: awaited with a request's path and answer once its work under an Idempotency-Key is done, before the
215
219
  * answer is kept, so a test can hold a request there while a DELETE /agents/{id} runs. */
216
220
  beforeKeep?: (path: string, answer: unknown) => void | Promise<void>;