@parcha/agentrun-serve 0.1.0-beta.48 → 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 (170) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +236 -26
  3. package/dist/agent-delete.d.ts +36 -12
  4. package/dist/agent-delete.js +213 -30
  5. package/dist/agents-store.d.ts +6 -2
  6. package/dist/agents-store.js +18 -5
  7. package/dist/agents.d.ts +8 -1
  8. package/dist/agents.js +14 -4
  9. package/dist/answer-json.d.ts +2 -2
  10. package/dist/answer-json.js +3 -4
  11. package/dist/api-only.d.ts +7 -10
  12. package/dist/api-only.js +9 -11
  13. package/dist/archil-routes.d.ts +1 -1
  14. package/dist/archil-routes.js +4 -3
  15. package/dist/browser-sessions.d.ts +56 -0
  16. package/dist/browser-sessions.js +117 -0
  17. package/dist/compute-cost.d.ts +101 -0
  18. package/dist/compute-cost.js +250 -0
  19. package/dist/computer-routes.d.ts +4 -15
  20. package/dist/computer-routes.js +6 -10
  21. package/dist/console/assets/index-D0mr9wfZ.css +1 -0
  22. package/dist/console/assets/index-D7G6o-1E.js +720 -0
  23. package/dist/console/index.html +2 -2
  24. package/dist/errors.d.ts +4 -1
  25. package/dist/errors.js +15 -5
  26. package/dist/eval-previous.d.ts +52 -0
  27. package/dist/eval-previous.js +164 -0
  28. package/dist/file-types.d.ts +2 -0
  29. package/dist/file-types.js +3 -1
  30. package/dist/harness.js +2 -1
  31. package/dist/import.js +4 -3
  32. package/dist/learn/check.d.ts +16 -4
  33. package/dist/learn/check.js +30 -26
  34. package/dist/learn/promote.d.ts +7 -1
  35. package/dist/learn/promote.js +47 -0
  36. package/dist/learn/repick.d.ts +43 -0
  37. package/dist/learn/repick.js +202 -0
  38. package/dist/learn/workflow-draft.d.ts +4 -0
  39. package/dist/learn/workflow-draft.js +10 -7
  40. package/dist/learned-workflow.d.ts +2 -0
  41. package/dist/learned-workflow.js +19 -2
  42. package/dist/learning-setting.d.ts +13 -0
  43. package/dist/learning-setting.js +23 -1
  44. package/dist/llms.txt +1 -1
  45. package/dist/openapi.js +180 -14
  46. package/dist/paid-calls.d.ts +17 -7
  47. package/dist/paid-calls.js +15 -9
  48. package/dist/run-launch.d.ts +2 -2
  49. package/dist/run-launch.js +2 -1
  50. package/dist/run-learning-served.d.ts +1 -1
  51. package/dist/run-timeline-served.js +5 -3
  52. package/dist/run-usage.d.ts +125 -0
  53. package/dist/run-usage.js +394 -0
  54. package/dist/runner/adapter-loop.d.ts +4 -0
  55. package/dist/runner/adapter-loop.js +66 -21
  56. package/dist/runner/adapter-run-spec.d.ts +8 -3
  57. package/dist/runner/adapter-run-spec.js +13 -6
  58. package/dist/runner/big-writes.d.ts +33 -0
  59. package/dist/runner/big-writes.js +105 -0
  60. package/dist/runner/cli-run-spec.js +14 -6
  61. package/dist/runner/conformance/harness.d.ts +2 -0
  62. package/dist/runner/conformance/harness.js +18 -4
  63. package/dist/runner/feedback-round.d.ts +29 -1
  64. package/dist/runner/feedback-round.js +54 -3
  65. package/dist/runner/held.d.ts +4 -1
  66. package/dist/runner/journal-kinds.d.ts +3 -1
  67. package/dist/runner/learning-end.js +54 -18
  68. package/dist/runner/loop-contract.d.ts +3 -0
  69. package/dist/runner/metrics.d.ts +4 -0
  70. package/dist/runner/metrics.js +9 -0
  71. package/dist/runner/monid-run.js +2 -2
  72. package/dist/runner/promotion.js +8 -2
  73. package/dist/runner/reflect-hook.js +3 -2
  74. package/dist/runner/run-child-host.d.ts +15 -2
  75. package/dist/runner/run-child-host.js +24 -8
  76. package/dist/runner/run-child.js +3 -0
  77. package/dist/runner/save-slots.d.ts +9 -0
  78. package/dist/runner/save-slots.js +91 -0
  79. package/dist/runs-over-store.d.ts +3 -2
  80. package/dist/runs-over-store.js +9 -7
  81. package/dist/sdk/runs.d.ts +3 -4
  82. package/dist/sdk/runs.js +10 -7
  83. package/dist/sdk/runtimes.d.ts +19 -0
  84. package/dist/sdk/runtimes.js +23 -0
  85. package/dist/sdk/schema.d.ts +14 -8
  86. package/dist/sdk/schema.js +18 -6
  87. package/dist/server.d.ts +7 -3
  88. package/dist/server.js +223 -100
  89. package/dist/store/agent-body.d.ts +2 -3
  90. package/dist/store/agent-body.js +3 -2
  91. package/dist/store/index.d.ts +2 -2
  92. package/dist/store/index.js +1 -1
  93. package/dist/store/journal/storage.js +1 -1
  94. package/dist/store/open.d.ts +1 -1
  95. package/dist/store/open.js +1 -1
  96. package/dist/store/postgres/migrations/0021_purged.sql +13 -0
  97. package/dist/store/postgres/migrations/0022_computer_intervals.sql +27 -0
  98. package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
  99. package/dist/store/schema.d.ts +20 -1
  100. package/dist/store/schema.js +60 -5
  101. package/dist/store/sqlite/connection.d.ts +4 -1
  102. package/dist/store/sqlite/connection.js +5 -0
  103. package/dist/store/sqlite/run-patch.d.ts +8 -3
  104. package/dist/store/sqlite/run-patch.js +15 -7
  105. package/dist/store/sqlite/store.d.ts +2 -1
  106. package/dist/store/sqlite/store.js +279 -68
  107. package/dist/store/sqlite/worker.d.ts +9 -0
  108. package/dist/store/sqlite/worker.js +18 -1
  109. package/dist/store/store.d.ts +149 -9
  110. package/dist/store/store.js +63 -0
  111. package/dist/store-reads/analytics.js +2 -1
  112. package/dist/store-reads/cap.d.ts +17 -7
  113. package/dist/store-reads/cap.js +54 -4
  114. package/dist/store-reads/decisions.d.ts +21 -0
  115. package/dist/store-reads/decisions.js +22 -0
  116. package/dist/store-reads/journal.d.ts +8 -2
  117. package/dist/store-reads/journal.js +27 -8
  118. package/dist/store-reads/learning.d.ts +1 -1
  119. package/dist/store-reads/learning.js +5 -2
  120. package/dist/store-reads/runs.js +2 -0
  121. package/dist/store-reads/stats.js +4 -2
  122. package/dist/store-view.d.ts +12 -1
  123. package/dist/store-view.js +98 -38
  124. package/dist/template-eval.d.ts +15 -1
  125. package/dist/template-eval.js +92 -13
  126. package/dist/templates.d.ts +1 -1
  127. package/dist/templates.js +4 -3
  128. package/dist/timeline/labels.js +17 -0
  129. package/dist/tool-list.js +1 -0
  130. package/dist/tools.d.ts +6 -2
  131. package/dist/tools.js +22 -1
  132. package/dist/trigger-targets.d.ts +28 -9
  133. package/dist/trigger-targets.js +19 -16
  134. package/dist/triggers.d.ts +2 -1
  135. package/dist/triggers.js +5 -2
  136. package/dist/validate.d.ts +4 -2
  137. package/dist/validate.js +13 -3
  138. package/dist/viewer-credential.d.ts +3 -4
  139. package/dist/viewer-credential.js +6 -4
  140. package/dist/web-fake.d.ts +25 -0
  141. package/dist/web-fake.js +38 -1
  142. package/dist/web-save.d.ts +75 -0
  143. package/dist/web-save.js +235 -0
  144. package/dist/workspace/archil-claim.d.ts +5 -2
  145. package/dist/workspace/archil-claim.js +5 -2
  146. package/dist/workspace/archil-disk.d.ts +10 -1
  147. package/dist/workspace/archil-disk.js +19 -1
  148. package/dist/workspace/archil.d.ts +3 -0
  149. package/dist/workspace/archil.js +101 -16
  150. package/dist/workspace/computer-for-claim.d.ts +19 -1
  151. package/dist/workspace/computer-for-claim.js +88 -20
  152. package/dist/workspace/computer-intervals.d.ts +26 -0
  153. package/dist/workspace/computer-intervals.js +58 -0
  154. package/dist/workspace/computer-janitor.d.ts +7 -3
  155. package/dist/workspace/computer-janitor.js +14 -6
  156. package/dist/workspace/computer-kept.d.ts +7 -2
  157. package/dist/workspace/computer-kept.js +9 -2
  158. package/dist/workspace/pieced.d.ts +14 -0
  159. package/dist/workspace/pieced.js +23 -0
  160. package/dist/workspace/resolve-computer.d.ts +7 -4
  161. package/dist/workspace/resolve-computer.js +21 -32
  162. package/dist/workspace/run-disk.js +32 -12
  163. package/dist/workspace/run-end-computers.d.ts +1 -0
  164. package/dist/workspace/run-end-computers.js +4 -1
  165. package/dist/workspace/run-workspace.d.ts +1 -1
  166. package/dist/workspace/run-workspace.js +11 -6
  167. package/package.json +10 -10
  168. package/templates/README.md +36 -7
  169. package/dist/console/assets/index-CTGegcKt.css +0 -1
  170. package/dist/console/assets/index-D1Se6mgG.js +0 -715
@@ -35,6 +35,7 @@ import { deleteUnderHold, ownerGoneOf, serverIdOf, wantsOn } from "./agent-compu
35
35
  import { sweepKept } from "./computer-kept.js";
36
36
  import { storeLedger } from "./computer-ledger.js";
37
37
  import { providerKeys } from "./resolve-computer.js";
38
+ import { intervalWrites } from "./computer-intervals.js";
38
39
  /** How often the janitor sweeps after its first sweep at the runner's start. */
39
40
  export const JANITOR_EVERY_MS = 10 * 60_000;
40
41
  /** The longest close() waits for a sweep it cut: a vendor call that ignores the cut is left to finish on its own. */
@@ -78,7 +79,7 @@ async function sweepable(store, info, byHash, serverId) {
78
79
  * now: a server that stopped before its run's end let go of an earlier claim's computer (run-end-computers.ts) leaves
79
80
  * it for this sweep, never for its day-long deadline. Each call goes to the provider itself, so its own state is used
80
81
  * as it is. */
81
- function thisServers(provider, store, byHash, serverId, at) {
82
+ function thisServers(provider, store, byHash, serverId, at, ended) {
82
83
  // The agents' own computers the list kept, by id: their delete goes under the agent's hold (deleteUnderHold), which
83
84
  // also clears the agent's record of it, so its view no longer shows it deleting.
84
85
  const ownedBy = new Map();
@@ -92,10 +93,15 @@ function thisServers(provider, store, byHash, serverId, at) {
92
93
  attach: (target, context) => provider.attach(target, context),
93
94
  network: (ref, policy, context) => provider.network(ref, policy, context),
94
95
  connect: (ref) => provider.connect(ref),
95
- release(ref, how, context) {
96
+ async release(ref, how, context) {
96
97
  const agent = ownedBy.get(ref.id);
97
- if (how !== "delete" || agent === undefined || settings === undefined)
98
- return provider.release(ref, how, context);
98
+ if (how !== "delete" || agent === undefined || settings === undefined) {
99
+ const released = await provider.release(ref, how, context);
100
+ // A run's computer the sweep deleted: its interval ends (computer-intervals.ts), on the provider's ok alone.
101
+ if (released.ok && how === "delete")
102
+ await ended(ref.id);
103
+ return released;
104
+ }
99
105
  // Asked again under the hold: the agent may want it back since ownerGone was read (this server's owners carry no
100
106
  // idle TTL, so that is the one reason the sweep deletes one).
101
107
  const due = async () => !agents || !(await wantsOn({ agents }, agent, provider.id));
@@ -142,6 +148,7 @@ async function bounded(ms, signal, work) {
142
148
  * in its words; nothing throws. */
143
149
  export async function sweepServerComputers(deps, signal) {
144
150
  const { store, computers } = deps;
151
+ const writes = intervalWrites(store, deps.log, deps.now);
145
152
  const at = (deps.now ?? Date.now)();
146
153
  const keysOf = providerKeys(computers.kinds, computers.keyOf ?? (async () => undefined));
147
154
  const byHash = runsByHash(store);
@@ -166,7 +173,7 @@ export async function sweepServerComputers(deps, signal) {
166
173
  if (provider.capabilities().lifetime !== "janitor")
167
174
  continue;
168
175
  const ownerGone = serverId !== undefined && settings && agents ? ownerGoneOf({ agents, settings, runs: store.runs }, serverId, entry.id) : undefined;
169
- out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
176
+ out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at, (id) => writes.ended(entry.id, id)), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
170
177
  }
171
178
  catch (error) {
172
179
  out.push({ provider: entry.id, swept: { ok: false, error: { code: "refused", message: error instanceof Error ? error.message : String(error) } } });
@@ -179,6 +186,7 @@ export async function sweepServerComputers(deps, signal) {
179
186
  * hours away). Undefined without the store's settings, where none is kept. Never throws. */
180
187
  export async function sweepKeptComputers(deps) {
181
188
  const { store, computers } = deps;
189
+ const writes = intervalWrites(store, deps.log, deps.now);
182
190
  if (!store.settings)
183
191
  return undefined;
184
192
  const keysOf = providerKeys(computers.kinds, computers.keyOf ?? (async () => undefined));
@@ -189,7 +197,7 @@ export async function sweepKeptComputers(deps) {
189
197
  const options = providerOptions(id, await keysOf(id), computers.settings ?? {}, computers.keyTable ?? KEY_TABLE);
190
198
  return options.ok ? make(options.options, { ledger: storeLedger(store.computerLedger, id) }) : undefined;
191
199
  };
192
- return sweepKept({ settings: store.settings, runs: store.runs, now: (deps.now ?? Date.now)(), providerOf });
200
+ return sweepKept({ settings: store.settings, runs: store.runs, now: (deps.now ?? Date.now)(), providerOf, deleted: (provider, id) => writes.ended(provider, id) });
193
201
  }
194
202
  /** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
195
203
  * computer is due (sweepKeptComputers; each delete bounded, KEPT_DELETE_MS), so a park's keep ends on time though the
@@ -79,7 +79,12 @@ export declare function sweepKept(deps: {
79
79
  readonly now: number;
80
80
  readonly providerOf: (id: string) => Promise<ComputerProvider | undefined>;
81
81
  readonly deleteMs?: number;
82
+ /** Told of each kept computer whose delete answered ok, by its provider and id (its interval's end,
83
+ * computer-intervals.ts). Never throws. */
84
+ readonly deleted?: (provider: string, id: string) => Promise<void>;
82
85
  }): Promise<KeptSweep>;
83
86
  /** Deletes the kept computer through its provider; one already gone (its run's end let it go, run-end-computers.ts, or
84
- * its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. */
85
- export declare function deleteKept(provider: Pick<ComputerProvider, "release">, kept: Pick<Kept, "id" | "name">): Promise<void>;
87
+ * its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. True when the
88
+ * provider's delete answered ok, the one answer that proves its end now (its interval's, computer-intervals.ts); false
89
+ * for one already gone, whose end is not known. */
90
+ export declare function deleteKept(provider: Pick<ComputerProvider, "release">, kept: Pick<Kept, "id" | "name">): Promise<boolean>;
@@ -116,7 +116,11 @@ export async function sweepKept(deps) {
116
116
  failed.push(`${kept.name} of run ${runId}: this server can't reach ${kept.provider} to end it`);
117
117
  continue;
118
118
  }
119
- const deleted = await endKept(deps.settings, runId, kept, () => bounded(deps.deleteMs ?? KEPT_DELETE_MS, deleteKept(provider, kept)));
119
+ const proven = () => deleteKept(provider, kept).then(async (ok) => {
120
+ if (ok)
121
+ await deps.deleted?.(kept.provider, kept.id);
122
+ });
123
+ const deleted = await endKept(deps.settings, runId, kept, () => bounded(deps.deleteMs ?? KEPT_DELETE_MS, proven()));
120
124
  if (deleted)
121
125
  ended.push(kept.name);
122
126
  if (deleted && over)
@@ -129,11 +133,14 @@ export async function sweepKept(deps) {
129
133
  return { ended, failed, ...(next === undefined ? {} : { next }) };
130
134
  }
131
135
  /** Deletes the kept computer through its provider; one already gone (its run's end let it go, run-end-computers.ts, or
132
- * its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. */
136
+ * its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. True when the
137
+ * provider's delete answered ok, the one answer that proves its end now (its interval's, computer-intervals.ts); false
138
+ * for one already gone, whose end is not known. */
133
139
  export async function deleteKept(provider, kept) {
134
140
  const released = await provider.release({ id: kept.id, name: kept.name }, "delete");
135
141
  if (!released.ok && released.error.code !== "not_found" && released.error.code !== "gone")
136
142
  throw new Error(released.error.message);
143
+ return released.ok;
137
144
  }
138
145
  /** `work`, or its timeout in words after `ms`: a delete that hangs is left to finish on its own. */
139
146
  async function bounded(ms, work) {
@@ -0,0 +1,14 @@
1
+ import type { Workspace } from "./workspace.js";
2
+ /** The run's bytes from `offset`, `length` of them: what the runner pulls. */
3
+ export type PullPiece = (offset: number, length: number) => Promise<Uint8Array>;
4
+ /** A pieced write of `size` bytes at `path`, pulled through `pull`, under `signal`. */
5
+ export type WritePieces = (path: string, size: number, pull: PullPiece, signal?: AbortSignal) => Promise<void>;
6
+ /** What the runner hands beside a Workspace: its pieced write, and the piece size it pulls (a write of more is pieced). */
7
+ export type Pieces = {
8
+ readonly write: WritePieces;
9
+ readonly piece: number;
10
+ };
11
+ /** `remote` (a runner's Workspace held by handle in a run's process: a plain object of its stand-ins, as the channel
12
+ * decodes it) with a write of more than `pieces.piece` bytes made through `pieces.write`, under `signal`: the runner pulls
13
+ * it a piece at a time. A smaller write is one call, as before. No `pieces` (a runner that hands none): `remote` itself. */
14
+ export declare function piecedWorkspace(remote: Workspace, pieces: Pieces | undefined, signal?: AbortSignal): Workspace;
@@ -0,0 +1,23 @@
1
+ /** `remote` (a runner's Workspace held by handle in a run's process: a plain object of its stand-ins, as the channel
2
+ * decodes it) with a write of more than `pieces.piece` bytes made through `pieces.write`, under `signal`: the runner pulls
3
+ * it a piece at a time. A smaller write is one call, as before. No `pieces` (a runner that hands none): `remote` itself. */
4
+ export function piecedWorkspace(remote, pieces, signal) {
5
+ if (!pieces || typeof pieces.write !== "function" || !Number.isSafeInteger(pieces.piece) || pieces.piece < 1)
6
+ return remote;
7
+ const { write: writePieces, piece } = pieces;
8
+ return {
9
+ ...remote,
10
+ async write(path, data) {
11
+ const over = typeof data === "string" ? Buffer.byteLength(data, "utf8") > piece : data.length > piece;
12
+ if (!over)
13
+ return remote.write(path, data);
14
+ const bytes = typeof data === "string" ? Buffer.from(data, "utf8") : data;
15
+ const pull = async (offset, length) => {
16
+ if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(length) || offset < 0 || length < 0 || offset + length > bytes.length)
17
+ throw new RangeError("a piece past the write's bytes");
18
+ return bytes.subarray(offset, offset + length);
19
+ };
20
+ return writePieces(path, bytes.length, pull, signal);
21
+ },
22
+ };
23
+ }
@@ -1,5 +1,5 @@
1
1
  import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
2
- import { type BrowserFeatures, type BrowserFile, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountKind, type MountReadBack, type MountSpec, type ProviderEntry, type Result, type SettingKindSpec } from "@parcha/agentrun-computer";
2
+ import { type BrowserFeatures, type BrowserFile, type BrowserSessionUsage, type BrowserSpec, type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type HelloResult, type KindCapabilities, type MountKind, type MountReadBack, type MountSpec, type ProviderEntry, type Result, type SettingKindSpec } from "@parcha/agentrun-computer";
3
3
  import { type DockerDaemon } from "../docker-daemon.js";
4
4
  import type { Recording, RecordWatch } from "../computer-record.js";
5
5
  import type { MountCheck } from "./attach.js";
@@ -84,6 +84,10 @@ export type ClaimBrowser = {
84
84
  * view's, computer-record.ts browserWatch) until the caller stops it at the session's release, or the claim's release
85
85
  * stops it. Absent: nothing is recorded. */
86
86
  readonly record?: (id: string, watch: RecordWatch) => Recording;
87
+ /** The provider's own record of session `id` (BrowserComputerProvider.sessionUsage), read once as it is let go: when it
88
+ * says the session started and ended, and its proxy bytes, each null where it does not say; undefined for a session it
89
+ * does not know. Absent where the provider keeps no such record. A failed read throws. */
90
+ readonly usage?: (id: string, signal?: AbortSignal) => Promise<BrowserSessionUsage | undefined>;
87
91
  /** The files a session downloaded, kept by the provider: where its features declare downloads. */
88
92
  readonly downloads?: {
89
93
  list(id: string): Promise<BrowserFile[]>;
@@ -244,9 +248,8 @@ export type ResolvedComputer = {
244
248
  */
245
249
  export declare function shellPlaceOf(mounts: boolean, mode: 1 | 2): ShellPlace;
246
250
  /** The kind of the run's folder a run of an agent with computer `setting` holds in `mode`, read off the setting and the
247
- * kind registry before anything starts, as the claim picks it (resolveComputer: the configuration the setting selects,
248
- * settingFolderOf): a bind, an Archil mount or a synced folder, or undefined for none (kind none, a computer that holds
249
- * no folder, or a setting the claim refuses). `registry` is as this server has it (registryHere, entryHere). */
251
+ * kind registry before anything starts (selectedFor, settingFolderOf): a bind, an Archil mount or a synced folder, or
252
+ * undefined for none (kind none, a computer that holds no folder, or a setting the claim refuses). */
250
253
  export declare function runFolderOf(setting: ComputerSetting, mode: 1 | 2, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals" | "PROVIDERS">): MountKind | undefined;
251
254
  /**
252
255
  * Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
@@ -182,28 +182,27 @@ function folderOf(kind, entry, serving, mode, gpuMounts) {
182
182
  }
183
183
  /** The configurations of `entry` that serve `kind`. */
184
184
  const servingOf = (registry, entry, kind) => entry.capabilities.filter((one) => registry.servingRefusals(one, kind).length === 0);
185
- /** The one configuration of `serving` the setting selects (configurationOf), as a list: [] when its image names none. */
186
- const selectedOf = (serving, setting, entry, kind) => {
187
- const one = configurationOf(serving, setting.image, entry.defaultImage?.[kind]);
188
- return one ? [one] : [];
189
- };
185
+ /** What computer `setting` selects before anything starts, as the claim picks it (resolveComputer): its kind, its
186
+ * provider's entry, and the configuration serving the kind that its image names (configurationOf). Undefined for kind
187
+ * none, an unknown kind or provider, or no such configuration. `registry` is as this server has it (registryHere). */
188
+ function selectedFor(setting, registry) {
189
+ const kind = setting.kind;
190
+ if (kind === "none" || !Object.hasOwn(registry.SETTING_KINDS, kind))
191
+ return undefined;
192
+ const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
193
+ const configuration = entry && configurationOf(servingOf(registry, entry, kind), setting.image, entry.defaultImage?.[kind]);
194
+ return entry && configuration ? { kind, entry, configuration } : undefined;
195
+ }
190
196
  /** The kind of the run's folder a computer of `setting` on `entry`'s `configuration` holds in `mode` (folderOf), or
191
197
  * undefined for none: none where the agent runs no programs of its own; of the kinds its GPU computers take, where a
192
198
  * sandbox's setting asks for GPUs. resolveComputer's folder, and runFolderOf's. */
193
199
  const settingFolderOf = (setting, kind, entry, configuration, mode) => noPrograms(setting) ? undefined : folderOf(kind, entry, [configuration], mode, kind === "sandbox" && setting.gpu ? configuration.gpu?.mounts : undefined);
194
200
  /** The kind of the run's folder a run of an agent with computer `setting` holds in `mode`, read off the setting and the
195
- * kind registry before anything starts, as the claim picks it (resolveComputer: the configuration the setting selects,
196
- * settingFolderOf): a bind, an Archil mount or a synced folder, or undefined for none (kind none, a computer that holds
197
- * no folder, or a setting the claim refuses). `registry` is as this server has it (registryHere, entryHere). */
201
+ * kind registry before anything starts (selectedFor, settingFolderOf): a bind, an Archil mount or a synced folder, or
202
+ * undefined for none (kind none, a computer that holds no folder, or a setting the claim refuses). */
198
203
  export function runFolderOf(setting, mode, registry) {
199
- const kind = setting.kind;
200
- if (kind === "none" || !Object.hasOwn(registry.SETTING_KINDS, kind))
201
- return undefined;
202
- const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
203
- if (!entry)
204
- return undefined;
205
- const [configuration] = selectedOf(servingOf(registry, entry, kind), setting, entry, kind);
206
- return configuration ? settingFolderOf(setting, kind, entry, configuration, mode) : undefined;
204
+ const selected = selectedFor(setting, registry);
205
+ return selected && settingFolderOf(setting, selected.kind, selected.entry, selected.configuration, mode);
207
206
  }
208
207
  /**
209
208
  * Where a run of an agent with computer `setting` has its shell in `mode` (shellPlaceOf), read off the setting and the
@@ -214,24 +213,14 @@ export function runFolderOf(setting, mode, registry) {
214
213
  * runs nothing: "none". The setting is the agent's as saved; where it has none, the caller gives the server's default.
215
214
  */
216
215
  export function runShellOf(setting, mode, registry) {
217
- const kind = setting.kind;
218
- if (!Object.hasOwn(registry.SETTING_KINDS, kind))
219
- return "none";
220
- if (kind === "none")
216
+ if (setting.kind === "none")
221
217
  return shellPlaceOf(false, mode);
222
- if (!registry.PROVIDERS.some((one) => one.kinds.includes(kind)))
223
- return "none";
224
- const entry = registry.PROVIDERS.find((one) => one.id === setting.provider);
225
- if (!entry)
226
- return "none";
227
- const serving = selectedOf(servingOf(registry, entry, kind), setting, entry, kind);
228
- if (serving.length === 0)
229
- return "none";
218
+ const selected = selectedFor(setting, registry);
230
219
  // An agent whose computer runs no programs of its own has no shell anywhere: not its computer's, not Archil's exec.
231
- if (noPrograms(setting))
220
+ if (!selected || noPrograms(setting))
232
221
  return "none";
233
- const mounts = folderOf(kind, entry, serving, mode) !== undefined;
234
- if (kind === "sandbox" && !mounts)
222
+ const mounts = folderOf(selected.kind, selected.entry, [selected.configuration], mode) !== undefined;
223
+ if (selected.kind === "sandbox" && !mounts)
235
224
  return "none";
236
225
  return shellPlaceOf(mounts, mode);
237
226
  }
@@ -293,7 +282,7 @@ export async function resolveComputer(given, mode, registry, side) {
293
282
  }
294
283
  // The configuration the setting's image selects: one the provider does not offer for the kind is refused, naming those
295
284
  // it does.
296
- const [configuration] = selectedOf(serving, setting, entry, kind);
285
+ const configuration = configurationOf(serving, setting.image, entry.defaultImage?.[kind]);
297
286
  if (!configuration) {
298
287
  const images = imagesOf(serving, entry.defaultImage?.[kind]);
299
288
  const offers = images.length === 0 ? `offers no ${kind} image to choose: remove the image` : `offers the ${kind} image${images.length === 1 ? "" : "s"} ${images.join(", ")}: pick one`;
@@ -8,9 +8,11 @@
8
8
  // - The agent's disk is stored on the agent (archil-settings.ts agentDiskOf). An agent with none yet has it made now, on
9
9
  // its first run that uses it (never at the agent's creation: an agent whose runs all name a disk never has one), named
10
10
  // agentrun-<server id>-i-<agent id> (diskNameOf), idempotent by that name. The plan's disk limit refuses the run in words.
11
+ // One it has is read at Archil at every claim (one GET), as a launch's is: a disk Archil no longer has, or one in
12
+ // another region, refuses the run in words naming the disk, the region and the way out, before any call on the disk.
11
13
  import { agentDiskOf, diskNameOf, keepRunDisk, runDiskKept, serverIdOf, storeAgentDisk } from "../archil-settings.js";
12
14
  import { ArchilClaimRefused } from "./archil-claim.js";
13
- import { ArchilDiskLimit, availableDisk, ensureDisk, getDisk } from "./archil-disks.js";
15
+ import { ArchilDiskError, ArchilDiskLimit, availableDisk, ensureDisk, getDisk } from "./archil-disks.js";
14
16
  /** The words of the plan's disk limit, its number when Archil said it. */
15
17
  export const diskLimitWords = (limit) => limit === undefined ? "your Archil plan's disk limit is reached; upgrade or delete an agent" : `your Archil plan allows ${limit} disks; upgrade or delete an agent`;
16
18
  /** Why disk `diskId`, named by a launch, can't hold a run here, in words naming the region; undefined when it can. A call
@@ -38,16 +40,36 @@ export async function runDiskOf(options) {
38
40
  return { diskId: launch.diskId, kind: "launch" };
39
41
  }
40
42
  const stored = await agentDiskOf(options.store, options.agentId);
41
- /** Waits for a pending disk to read available, then clears its pending mark (unless it was removed or replaced meanwhile). */
42
- const ready = async (diskId) => {
43
- await availableDisk(control, diskId, { ...(options.availableMs !== undefined ? { timeoutMs: options.availableMs } : {}), ...(signal ? { signal } : {}) });
43
+ /** Waits for the disk to read available at Archil (one just made reads `creating` for a while; one made before reads
44
+ * available at once, one read), then clears a pending mark (unless it was removed or replaced meanwhile). */
45
+ const ready = async (diskId, pending) => {
46
+ const disk = await availableDisk(control, diskId, { ...(options.availableMs !== undefined ? { timeoutMs: options.availableMs } : {}), ...(signal ? { signal } : {}) });
47
+ if (!pending)
48
+ return disk;
44
49
  const now = await agentDiskOf(options.store, options.agentId);
45
50
  if (now?.diskId === diskId && !now.removing)
46
51
  await storeAgentDisk(options.store, options.agentId, { diskId });
52
+ return disk;
53
+ };
54
+ /** The agent's disk made at an earlier claim, read at Archil again at this one, as a launch's is: one Archil no longer
55
+ * has, or one in another region than the key's, refuses the run in words before any call on it. A disk that is gone is
56
+ * never made again in its place: the agent's learning and its runs' folders were on it, and a new empty disk would
57
+ * hide that they are lost. Its owner drops it, and the next run makes a new one. */
58
+ const readyReused = async (diskId, pending) => {
59
+ let disk;
60
+ try {
61
+ disk = await ready(diskId, pending);
62
+ }
63
+ catch (error) {
64
+ if (error instanceof ArchilDiskError && error.status === 404) {
65
+ const agent = options.agentId;
66
+ throw new ArchilClaimRefused(`This agent's Archil disk ${diskId} is gone: Archil has no disk ${diskId} in region ${region}. The agent's learning and its runs' folders were on it, so no new disk is made in its place. DELETE /v2/agents/${agent}/archil drops it (an agent made here is archived first, POST /v2/agents/${agent}/archive, and unarchived after), and the agent's next run makes a new one.`, { cause: error });
67
+ }
68
+ throw new ArchilClaimRefused(`This agent's Archil disk ${diskId} is not ready in region ${region}: ${error.message}`, { cause: error });
69
+ }
70
+ if (disk.region !== "" && disk.region !== region)
71
+ throw new ArchilClaimRefused(`This agent's Archil disk ${diskId} is in region ${disk.region}, and this server's Archil key is for region ${region}: a run's folder is only on a disk in the key's region.`);
47
72
  };
48
- const readyReused = (diskId) => ready(diskId).catch((error) => {
49
- throw new ArchilClaimRefused(`This agent's Archil disk ${diskId} is not ready in region ${region}: ${error.message}`, { cause: error });
50
- });
51
73
  // A launch that names no disk resolved to its agent's on its first claim, and that disk was kept for the run: a later
52
74
  // claim of the same run (a reopened one) mounts it or is refused, never another disk.
53
75
  const kept = launch === undefined && options.runId !== undefined ? await runDiskKept(options.store, options.runId) : undefined;
@@ -57,8 +79,7 @@ export async function runDiskOf(options) {
57
79
  if (bound !== undefined) {
58
80
  if (stored?.diskId !== bound || stored.removing)
59
81
  throw new ArchilClaimRefused(`This run's Archil disk ${bound} was its agent's, and it ${stored?.diskId === bound ? "is being" : "has been"} removed: start a new run, and it gets the agent's new disk.`);
60
- if (stored.pending)
61
- await readyReused(bound);
82
+ await readyReused(bound, stored.pending === true);
62
83
  return { diskId: bound, kind: "agent" };
63
84
  }
64
85
  const keep = async (diskId) => {
@@ -69,8 +90,7 @@ export async function runDiskOf(options) {
69
90
  if (stored?.removing)
70
91
  throw new ArchilClaimRefused(`This agent's Archil disk ${stored.diskId} is being removed: start a new run once that is done, and it gets a new disk.`);
71
92
  if (stored !== undefined) {
72
- if (stored.pending)
73
- await readyReused(stored.diskId);
93
+ await readyReused(stored.diskId, stored.pending === true);
74
94
  return keep(stored.diskId);
75
95
  }
76
96
  const name = diskNameOf(await serverIdOf(options.store), options.agentId);
@@ -80,7 +100,7 @@ export async function runDiskOf(options) {
80
100
  // Stored before the wait, as pending, so a disk that never becomes available is still the agent's (DELETE
81
101
  // /v2/agents/{id}/archil finds it, and the plan's slot it takes is never lost) and a claim that finds it waits.
82
102
  await storeAgentDisk(options.store, options.agentId, { diskId: id, pending: true });
83
- await ready(id);
103
+ await ready(id, true);
84
104
  }
85
105
  catch (error) {
86
106
  if (error instanceof ArchilDiskLimit)
@@ -10,6 +10,7 @@ export interface RunEndComputersDeps {
10
10
  * computer ledger, for a provider that keeps one. */
11
11
  readonly store: Pick<Store, "agents" | "computerLedger"> & {
12
12
  readonly runs: Pick<Store["runs"], "get" | "launch">;
13
+ readonly computerIntervals?: Store["computerIntervals"];
13
14
  };
14
15
  /** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
15
16
  * makers, the key reader, and --faux's launch with the providers it takes. */
@@ -21,6 +21,7 @@ import { readLaunchBody } from "../run-launch.js";
21
21
  import { settingOf } from "./computer-for-claim.js";
22
22
  import { storeLedger } from "./computer-ledger.js";
23
23
  import { providerKeys } from "./resolve-computer.js";
24
+ import { endingDeletes, intervalWrites } from "./computer-intervals.js";
24
25
  /** The longest a run's end may spend on its computers, every try with its pauses: past it the provider's calls are cut
25
26
  * (one that takes no signal, a release, left to finish on its own) and the run's end goes on, said in the log. */
26
27
  export const RUN_END_COMPUTERS_MS = 120_000;
@@ -50,6 +51,8 @@ const pause = (ms, signal) => new Promise((resolve) => {
50
51
  * is said in the log. */
51
52
  export function runEndComputers(deps) {
52
53
  const { store, computers, log } = deps;
54
+ /** Each computer let go here ends its interval (computer-intervals.ts), on its provider's ok alone. */
55
+ const writes = intervalWrites(store, log);
53
56
  /** The provider the run's computers are on, by the agent's setting; undefined where none of them is this end's to let
54
57
  * go (none, the agent's own, a paired computer, --faux's). */
55
58
  const providerOf = async (runId, epoch) => {
@@ -74,7 +77,7 @@ export function runEndComputers(deps) {
74
77
  if (!options.ok)
75
78
  throw new NoProviderHere(options.error.message);
76
79
  // A throw from here on is the vendor's or the daemon's (Docker's architecture asked): asked again.
77
- return make(options.options, { ledger: storeLedger(store.computerLedger, entry.id) });
80
+ return endingDeletes(await make(options.options, { ledger: storeLedger(store.computerLedger, entry.id) }), entry.id, writes);
78
81
  };
79
82
  return async ({ runId, epoch }) => {
80
83
  if (epoch <= 1)
@@ -1,5 +1,5 @@
1
1
  import { type ArchilClaim } from "./archil-claim.js";
2
- import type { Workspace } from "./workspace.js";
2
+ import { type Workspace } from "./workspace.js";
3
3
  export type RunWorkspaceOptions = {
4
4
  readonly agentId: string;
5
5
  readonly runId: string;
@@ -3,15 +3,18 @@
3
3
  // tools' own end.
4
4
  //
5
5
  // Mode 2: the run's folder on the claim's Archil disk (archil-claim.ts), at runKey, in the image the server's Archil
6
- // settings name. Its exec spill folder is swept when the run starts (what a killed exec, a crash or a failed cleanup left)
7
- // and again at its end. A cleanup that leaves spill files (onCleanupFailed), or a sweep that fails, goes to the run's
8
- // log in words and never fails the run: the next sweep takes what is left.
6
+ // settings name. The folder is made at the claim when it is not there yet; a folder that can't be made fails the claim
7
+ // in Archil's words, as everything the run does is in it. Its exec spill folder is swept when the run starts (what a
8
+ // killed exec, a crash or a failed cleanup left) and again at its end. A cleanup that leaves spill files
9
+ // (onCleanupFailed), or a sweep that fails, goes to the run's log in words and never fails the run: the spill folder is
10
+ // beside the run's folder, each exec's files are its own, and the next sweep takes what is left.
9
11
  // Mode 1: the run's local folder (runFolder). Its end does nothing here; the tools' end clears what they keep in it.
10
12
  import { mkdir } from "node:fs/promises";
11
13
  import { HELD_ARCHIL } from "./archil-claim.js";
12
14
  import { archilWorkspace } from "./archil.js";
13
15
  import { localWorkspace } from "./local.js";
14
16
  import { runFolder, runKey } from "./paths.js";
17
+ import { WorkspaceError } from "./workspace.js";
15
18
  /** The Workspace of run `runId` of agent `agentId` for this claim: Mode 2's spill folder swept first. */
16
19
  export async function openRunWorkspace(options) {
17
20
  const { agentId, runId, log } = options;
@@ -52,9 +55,11 @@ export async function openRunWorkspace(options) {
52
55
  say(`the run's exec spill folder could not be swept at the run's ${when} (the next sweep takes what is left): ${error?.message ?? error}`);
53
56
  }
54
57
  };
55
- // The run's folder on the disk (its run key), ensured at the claim as Mode 1's is: a fresh run has none yet. A write would
56
- // make its prefix anyway, so a failure here never fails the run; it is the next write's.
57
- await workspace.mkdir("").catch((error) => say(`the run's folder could not be made on the disk (a write will make it): ${error?.message ?? error}`));
58
+ // The run's folder on the disk (its run key), ensured at the claim as Mode 1's is: a fresh run has none yet. One already
59
+ // there (a later claim's, its kept computer perhaps holding it) is left as it is.
60
+ await workspace.ensureRoot().catch((error) => {
61
+ throw new WorkspaceError(error.code, `the run's folder on its Archil disk could not be made: ${error.message}`, { cause: error });
62
+ });
58
63
  await sweep("start");
59
64
  let ended;
60
65
  return { workspace, end: () => (ended ??= sweep("end")) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-serve",
3
- "version": "0.1.0-beta.48",
3
+ "version": "0.1.0-beta.50",
4
4
  "description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -62,15 +62,15 @@
62
62
  "@earendil-works/pi-coding-agent": "1.5.2",
63
63
  "@modelcontextprotocol/client": "2.4.0",
64
64
  "@modelcontextprotocol/server": "2.4.0",
65
- "@parcha/agentrun-computer": "0.1.0-beta.48",
66
- "@parcha/agentrun-decisions": "0.1.0-beta.48",
67
- "@parcha/agentrun-dsl": "0.1.0-beta.48",
68
- "@parcha/agentrun-harness-acp": "0.1.0-beta.48",
69
- "@parcha/agentrun-harness-claude": "0.1.0-beta.48",
70
- "@parcha/agentrun-harness-codex": "0.1.0-beta.48",
71
- "@parcha/agentrun-jev": "0.1.0-beta.48",
72
- "@parcha/agentrun-kernel": "0.1.0-beta.48",
73
- "@parcha/pi-browser": "0.1.0-beta.48",
65
+ "@parcha/agentrun-computer": "0.1.0-beta.50",
66
+ "@parcha/agentrun-decisions": "0.1.0-beta.50",
67
+ "@parcha/agentrun-dsl": "0.1.0-beta.50",
68
+ "@parcha/agentrun-harness-acp": "0.1.0-beta.50",
69
+ "@parcha/agentrun-harness-claude": "0.1.0-beta.50",
70
+ "@parcha/agentrun-harness-codex": "0.1.0-beta.50",
71
+ "@parcha/agentrun-jev": "0.1.0-beta.50",
72
+ "@parcha/agentrun-kernel": "0.1.0-beta.50",
73
+ "@parcha/pi-browser": "0.1.0-beta.50",
74
74
  "@secretlint/core": "13.1.0",
75
75
  "@secretlint/profiler": "13.1.0",
76
76
  "@secretlint/secretlint-rule-preset-recommend": "13.1.0",
@@ -14,7 +14,7 @@ code-review/
14
14
  skills/<name>/SKILL.md Agent Skills: front matter names the skill (= its folder) and describes it
15
15
  rules/*.md rules each skill reads: apply puts a copy beside each SKILL.md
16
16
  evals/<case>/prompt.md a case's run input (front matter: description, runs, max_cost_usd, ...)
17
- evals/<case>/graders/*.md front matter `type`: llm, regex, tool_used or file_exists
17
+ evals/<case>/graders/*.md front matter `type`: llm, regex, tool_used, file_exists, mailbox or handed
18
18
  evals/<case>/case.yaml, evals/<case>/fixtures/ optional
19
19
  skills/review/findings.schema.json any other file the manifest names (here the answer's schema, which the
20
20
  reviewers' guides beside it read too)
@@ -101,11 +101,12 @@ Each `evals/<case>/` is one test of the package's agent. No eval runs on the ser
101
101
  server writes them, under `Input:`; a body that holds its own `Input:` block is refused.
102
102
  - `case.yaml`, optional: `parameters` (the apply's parameters), `grants` (the gate names the apply grants, always a
103
103
  list), `mcp` (an `mcp` need's toolkit to a fixture file in the case that fakes it), `learning` (a file in the case holding
104
- the corrections the agent starts with, as its `corrections.md`: one line each), `web` (fakes `web_search` and `web_fetch` for the case's runs),
104
+ the corrections the agent starts with, as its `corrections.md`: one line each), `web` (fakes `web_search`, `web_fetch` and `web_save` for the case's runs),
105
105
  `monid` (fakes the package's monid endpoints for the case's runs), `now` (the case's clock), `email` (a fake mailbox
106
- for the case's runs), `calendar` (a fake calendar for the case's runs).
106
+ for the case's runs), `calendar` (a fake calendar for the case's runs), `feed` (fake feeds for the case's runs),
107
+ `previous` (the earlier results the schedule's run is handed).
107
108
  - `web: unavailable`: every `web_search` answers with the words a rate-limited free search answers with, and every
108
- `web_fetch` fails as a page that never answers does; no call reaches the network. `web:` a fixture file in the case
109
+ `web_fetch` and `web_save` fails as a host that never answers does; no call reaches the network. `web:` a fixture file in the case
109
110
  answers from that file instead:
110
111
  ```json
111
112
  { "search": { "answers": [ { "query": "robot", "results": [ { "url": "https://...", "title": "...", "snippet": "...", "published": "2026-11-10" } ] },
@@ -113,13 +114,17 @@ Each `evals/<case>/` is one test of the package's agent. No eval runs on the ser
113
114
  "default": { "results": [] } },
114
115
  "fetch": { "answers": [ { "url": "https://.../post", "title": "...", "text": "the page's text" },
115
116
  { "url": "https://.../gone", "status": 404, "text": "" } ],
116
- "default": { "error": "fetch failed" } } }
117
+ "default": { "error": "fetch failed" } },
118
+ "save": { "answers": [ { "url": "https://.../out.png", "content_type": "image/png", "base64": "iVBORw0KGgo..." },
119
+ { "url": "https://.../gone.png", "error": "connect ETIMEDOUT" } ] } }
117
120
  ```
118
121
  A search answer's `query` is a regular expression over the call's query (case-insensitive), a fetch answer's `url`
119
122
  the exact URL; the first answer that matches is taken, else `default`. A `status` of 400 or more fails the fetch as
120
- that answer would. The calls show in the run's timeline as any other, so a `tool_used` grader counts them. Each
123
+ that answer would. `save` is optional: each `web_save` file is the answer for exactly its URL (its body as `text` or
124
+ `base64`, with `content_type` and `status` optional), else `save.default` where there is one, else a refused
125
+ connection; the file goes through `web_save`'s own checks (its type against its bytes, the path, the cap). The calls show in the run's timeline as any other, so a `tool_used` grader counts them. Each
121
126
  harness gets the same fake: on claude-agent and codex their own web search is never offered to a `web:` case's runs.
122
- The package's `tools` must name `web_search` or `web_fetch`. Only the eval's own server honours `web`, so a case with
127
+ The package's `tools` must name `web_search`, `web_fetch` or `web_save`. Only the eval's own server honours `web`, so a case with
123
128
  it refuses to run with `--server`.
124
129
  - `monid: unavailable`: every call of a monid endpoint the package grants answers as it does when monid can't be
125
130
  reached (`... was not sent: monid's price for it could not be read before the call (monid could not be reached: fetch
@@ -199,6 +204,26 @@ Each `evals/<case>/` is one test of the package's agent. No eval runs on the ser
199
204
  `prompt.md` holds `description` and `runs` alone: the run's input and cap are the trigger's, and its graders' task is
200
205
  that input, the item's payload in its tag. Only the eval's own server honours `feed`, so a case with it refuses
201
206
  `--server`.
207
+ - `previous: fixtures/previous.json`, a fixture file in the case: the earlier completed results of the package's
208
+ schedule trigger, which its next run is handed after its message. The fixture:
209
+ ```json
210
+ { "description": "Last week's digest listed two jobs; this week's leaves them out.",
211
+ "results": [ { "output": { "items": ["https://jobs.example.com/1"] } },
212
+ { "output": { "items": ["https://jobs.example.com/2", "https://jobs.example.com/3"] },
213
+ "output_schema": { "type": "object", "x-carried": ["items"], "properties": { "items": { "type": "array" } } } } ],
214
+ "trigger": "Weekly" }
215
+ ```
216
+ `results` are oldest first, at least one; each `output` is that run's `result.output`, checked when the case is read
217
+ against its own `output_schema` (the schema the run that made it had, `x-carried` included), else the package's
218
+ `output` schema. Each run's agent gets them written in the server's store as completed runs of that agent, a day
219
+ apart, each started by a firing of the trigger; then the trigger fires on the eval's clock, as a schedule does, and the
220
+ run is handed what a scheduled run is handed: the last result whole up to 32 KiB, else the fields its run's schema
221
+ names in `x-carried` (the first entries of the largest carried array dropped until they fit, and how many said), else
222
+ nothing, said so. `trigger` names the trigger when the package has more than one schedule. The case's `prompt.md`
223
+ holds `description` and `runs` alone; `previous` goes with neither `email` nor `feed`. What the run was handed is on
224
+ its report as `handed_previous` (`kind`: `whole`, `carried`, `too_large` or `none`; `text`, as handed; `run_id`; and
225
+ for carried fields, `fields` and `dropped`, the count each carried array gave up, 0 for none). Only the eval's own server honours
226
+ `previous`, so a case with it refuses `--server`.
202
227
  - A fake MCP server's fixture, one shape for every package:
203
228
  ```json
204
229
  { "server": "github", "description": "what the fake holds",
@@ -224,6 +249,10 @@ Each `evals/<case>/` is one test of the package's agent. No eval runs on the ser
224
249
  - `mailbox`, on an `email` case: `message_id` is `in` a mailbox (or, on gmail, under a label) after the run, and in
225
250
  none of `not_in` (a list); `INBOX`, `Drafts` and `Sent` name the account's own on either layout. `in: INBOX` is
226
251
  the check that a message stayed in the inbox on both layouts: a gmail label keeps it there, a folders move does not.
252
+ - `handed`, on a `previous` case: the run was handed its trigger's last result as `expect` says (`whole`, `carried`,
253
+ `too_large` or `none`), and, with `expect: carried`, `dropped` (`{items: 192}`) is how many first entries each
254
+ named carried array gave up (0 for none); a name that is no carried array the run was handed (a typo, a scalar)
255
+ fails the grader.
227
256
 
228
257
  On an `email` case any grader may say `layouts` (`[gmail]`, `[folders]`): it grades the runs of those layouts alone,
229
258
  where a package's right behaviour differs by server (on folders, `tool_used` `email_file` `not_called`; on gmail,