@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.53

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 (322) hide show
  1. package/CHANGELOG.md +160 -1
  2. package/README.md +306 -36
  3. package/dist/adapters.js +1 -1
  4. package/dist/agent-delete.d.ts +14 -4
  5. package/dist/agent-delete.js +30 -58
  6. package/dist/agent-package.d.ts +71 -0
  7. package/dist/agent-package.js +345 -0
  8. package/dist/agents-store.d.ts +28 -18
  9. package/dist/agents-store.js +48 -34
  10. package/dist/api-only.d.ts +30 -8
  11. package/dist/api-only.js +40 -16
  12. package/dist/archil-routes.d.ts +1 -0
  13. package/dist/archil-routes.js +28 -2
  14. package/dist/claude-login.d.ts +1 -0
  15. package/dist/claude-login.js +1 -1
  16. package/dist/cli-learning/cli.d.ts +3 -0
  17. package/dist/cli-learning/cli.js +17 -3
  18. package/dist/cli-learning/connections.js +3 -2
  19. package/dist/cli-learning/schema.js +2 -1
  20. package/dist/cli.js +70 -7
  21. package/dist/composio-preset.d.ts +2 -1
  22. package/dist/composio-preset.js +4 -3
  23. package/dist/composio-triggers.d.ts +4 -0
  24. package/dist/composio-triggers.js +4 -1
  25. package/dist/computer-needs.d.ts +32 -0
  26. package/dist/computer-needs.js +80 -0
  27. package/dist/computer-setting.d.ts +9 -0
  28. package/dist/computer-setting.js +19 -1
  29. package/dist/computers.d.ts +6 -2
  30. package/dist/computers.js +2 -2
  31. package/dist/console/assets/index-BFgyZzF_.js +734 -0
  32. package/dist/console/assets/index-DbilxljH.css +1 -0
  33. package/dist/console/index.html +2 -2
  34. package/dist/console-links.d.ts +1 -0
  35. package/dist/console-links.js +2 -0
  36. package/dist/env-switch.d.ts +14 -0
  37. package/dist/env-switch.js +23 -0
  38. package/dist/errors.d.ts +1 -0
  39. package/dist/errors.js +3 -0
  40. package/dist/eval-previous.js +4 -3
  41. package/dist/fal-price.d.ts +76 -0
  42. package/dist/fal-price.js +365 -0
  43. package/dist/handed-secret.d.ts +4 -0
  44. package/dist/handed-secret.js +10 -0
  45. package/dist/harness-archive.d.ts +15 -5
  46. package/dist/harness-archive.js +71 -34
  47. package/dist/harness-check.d.ts +2 -1
  48. package/dist/harness-check.js +36 -95
  49. package/dist/harness-egress.d.ts +23 -0
  50. package/dist/harness-egress.js +69 -0
  51. package/dist/harness-recipe-entry.d.ts +71 -0
  52. package/dist/harness-recipe-entry.js +184 -0
  53. package/dist/harness-recipe.d.ts +73 -6
  54. package/dist/harness-recipe.js +185 -31
  55. package/dist/harness-sign-in.d.ts +29 -0
  56. package/dist/harness-sign-in.js +122 -0
  57. package/dist/harness-table.d.ts +21 -0
  58. package/dist/harness-table.js +58 -3
  59. package/dist/harness-zip.d.ts +6 -0
  60. package/dist/harness-zip.js +203 -0
  61. package/dist/ids.d.ts +11 -0
  62. package/dist/ids.js +36 -0
  63. package/dist/learn/commit.d.ts +19 -1
  64. package/dist/learn/commit.js +160 -2
  65. package/dist/learn/compile.d.ts +13 -5
  66. package/dist/learn/compile.js +46 -15
  67. package/dist/learn/delete.d.ts +12 -6
  68. package/dist/learn/delete.js +17 -11
  69. package/dist/learn/folder.d.ts +16 -0
  70. package/dist/learn/folder.js +30 -4
  71. package/dist/learn/learning-of.d.ts +8 -0
  72. package/dist/learn/learning-of.js +8 -0
  73. package/dist/learn/learning.sh +29 -4
  74. package/dist/learn/promote.d.ts +51 -7
  75. package/dist/learn/promote.js +51 -8
  76. package/dist/learn/secrets.js +30 -7
  77. package/dist/learning-reset.d.ts +18 -0
  78. package/dist/learning-reset.js +115 -0
  79. package/dist/learning-routes.d.ts +23 -11
  80. package/dist/learning-routes.js +110 -20
  81. package/dist/learning-words.d.ts +5 -0
  82. package/dist/learning-words.js +5 -0
  83. package/dist/learning.d.ts +15 -10
  84. package/dist/learning.js +14 -8
  85. package/dist/llms.txt +1 -0
  86. package/dist/mcp-gateway.d.ts +39 -2
  87. package/dist/mcp-gateway.js +56 -12
  88. package/dist/mcp-pin-first.js +1 -1
  89. package/dist/mcp-probe.d.ts +3 -0
  90. package/dist/mcp-probe.js +7 -2
  91. package/dist/mcp-resources.d.ts +44 -0
  92. package/dist/mcp-resources.js +100 -0
  93. package/dist/mcp-servers-store.d.ts +17 -12
  94. package/dist/mcp-servers-store.js +2 -1
  95. package/dist/media-duration.d.ts +2 -0
  96. package/dist/media-duration.js +136 -0
  97. package/dist/model.d.ts +4 -4
  98. package/dist/model.js +6 -6
  99. package/dist/native/cli.js +9 -2
  100. package/dist/native/connection.d.ts +2 -2
  101. package/dist/native/connection.js +5 -2
  102. package/dist/native/discovery.d.ts +2 -0
  103. package/dist/native/discovery.js +10 -6
  104. package/dist/native/remote-worker-bridge.js +36 -4
  105. package/dist/native/remote.d.ts +18 -1
  106. package/dist/native/remote.js +126 -37
  107. package/dist/native/schema.d.ts +6 -0
  108. package/dist/native/schema.js +31 -6
  109. package/dist/native/source-account.d.ts +13 -0
  110. package/dist/native/source-account.js +114 -0
  111. package/dist/native/source-capture-hooks.d.ts +5 -0
  112. package/dist/native/source-capture-hooks.js +102 -0
  113. package/dist/native/source-mcp-selection.d.ts +13 -0
  114. package/dist/native/source-mcp-selection.js +72 -0
  115. package/dist/native/source-runtime-tools.d.ts +19 -0
  116. package/dist/native/source-runtime-tools.js +103 -0
  117. package/dist/native/source-snapshot-types.d.ts +138 -0
  118. package/dist/native/source-snapshot-types.js +12 -0
  119. package/dist/native/source-snapshot.d.ts +8 -0
  120. package/dist/native/source-snapshot.js +1201 -0
  121. package/dist/observation/learning.js +3 -2
  122. package/dist/openapi.js +211 -47
  123. package/dist/print.js +1 -1
  124. package/dist/provider.d.ts +8 -0
  125. package/dist/provider.js +14 -2
  126. package/dist/purged-workflow.d.ts +12 -0
  127. package/dist/purged-workflow.js +43 -0
  128. package/dist/refusal-words.d.ts +0 -3
  129. package/dist/refusal-words.js +0 -3
  130. package/dist/request-metadata.d.ts +20 -0
  131. package/dist/request-metadata.js +24 -0
  132. package/dist/run-keys.d.ts +46 -0
  133. package/dist/run-keys.js +109 -0
  134. package/dist/run-launch.d.ts +29 -5
  135. package/dist/run-launch.js +44 -4
  136. package/dist/run-learning-served.d.ts +2 -2
  137. package/dist/run-model-key.d.ts +2 -2
  138. package/dist/run-model-key.js +5 -5
  139. package/dist/run-secrets.d.ts +2 -0
  140. package/dist/run-secrets.js +7 -4
  141. package/dist/run-usage.d.ts +48 -4
  142. package/dist/run-usage.js +156 -39
  143. package/dist/run-view.d.ts +18 -1
  144. package/dist/run-view.js +28 -8
  145. package/dist/runner/adapter-loop.d.ts +14 -4
  146. package/dist/runner/adapter-loop.js +150 -31
  147. package/dist/runner/adapter-run-spec.d.ts +1 -1
  148. package/dist/runner/adapter-run-spec.js +35 -22
  149. package/dist/runner/audit.d.ts +10 -3
  150. package/dist/runner/audit.js +30 -7
  151. package/dist/runner/beside.js +2 -1
  152. package/dist/runner/claim-secrets.d.ts +31 -4
  153. package/dist/runner/claim-secrets.js +43 -7
  154. package/dist/runner/cli-run-spec.d.ts +1 -1
  155. package/dist/runner/cli-run-spec.js +32 -20
  156. package/dist/runner/conformance/harness.js +4 -2
  157. package/dist/runner/dispatch.js +4 -2
  158. package/dist/runner/harness-loops.d.ts +6 -0
  159. package/dist/runner/harness-loops.js +16 -3
  160. package/dist/runner/held.d.ts +4 -0
  161. package/dist/runner/journal-kinds.d.ts +5 -0
  162. package/dist/runner/learned-first.d.ts +2 -0
  163. package/dist/runner/learned-first.js +1 -1
  164. package/dist/runner/learning-end.d.ts +9 -3
  165. package/dist/runner/learning-end.js +66 -29
  166. package/dist/runner/learning-seed.d.ts +9 -3
  167. package/dist/runner/learning-seed.js +2 -2
  168. package/dist/runner/main.d.ts +1 -0
  169. package/dist/runner/main.js +20 -13
  170. package/dist/runner/mcp-claim.js +7 -2
  171. package/dist/runner/mcp-run.d.ts +12 -0
  172. package/dist/runner/mcp-run.js +14 -1
  173. package/dist/runner/model-route.js +7 -4
  174. package/dist/runner/monid-run.js +9 -11
  175. package/dist/runner/project-checkpoint.d.ts +35 -0
  176. package/dist/runner/project-checkpoint.js +116 -0
  177. package/dist/runner/project-drain.d.ts +8 -0
  178. package/dist/runner/project-drain.js +25 -0
  179. package/dist/runner/project-host.d.ts +10 -0
  180. package/dist/runner/project-host.js +52 -0
  181. package/dist/runner/promotion.d.ts +51 -24
  182. package/dist/runner/promotion.js +206 -78
  183. package/dist/runner/redact.d.ts +13 -0
  184. package/dist/runner/redact.js +67 -1
  185. package/dist/runner/run-channel.d.ts +9 -0
  186. package/dist/runner/run-channel.js +15 -2
  187. package/dist/runner/run-child-host.d.ts +8 -4
  188. package/dist/runner/run-child-host.js +174 -42
  189. package/dist/runner/run-errors.js +2 -2
  190. package/dist/runner/runner-check.js +5 -2
  191. package/dist/runner/runner.js +41 -12
  192. package/dist/runner/sdk-loop.d.ts +2 -2
  193. package/dist/runner/sdk-loop.js +3 -3
  194. package/dist/runner/store-port.d.ts +3 -0
  195. package/dist/runner/store-secrets.js +7 -3
  196. package/dist/runner/workflow-first.d.ts +4 -0
  197. package/dist/runner/workflow-first.js +13 -0
  198. package/dist/runner/workflow-loop.d.ts +2 -1
  199. package/dist/runner/workflow-loop.js +2 -1
  200. package/dist/runner/workflow-spec.js +4 -4
  201. package/dist/runs-over-store.d.ts +39 -8
  202. package/dist/runs-over-store.js +147 -32
  203. package/dist/sdk/check.d.ts +6 -5
  204. package/dist/sdk/check.js +17 -16
  205. package/dist/sdk/runs.d.ts +11 -1
  206. package/dist/sdk/runs.js +185 -78
  207. package/dist/sdk/schema.js +12 -2
  208. package/dist/sdk/workflows.d.ts +1 -1
  209. package/dist/server.d.ts +68 -32
  210. package/dist/server.js +678 -124
  211. package/dist/skills/agentrun-serve/SKILL.md +2 -1
  212. package/dist/source-sync/adoption.d.ts +15 -0
  213. package/dist/source-sync/adoption.js +36 -0
  214. package/dist/source-sync/auxiliary.d.ts +23 -0
  215. package/dist/source-sync/auxiliary.js +64 -0
  216. package/dist/source-sync/capture-git.d.ts +5 -0
  217. package/dist/source-sync/capture-git.js +272 -0
  218. package/dist/source-sync/capture-project.d.ts +53 -0
  219. package/dist/source-sync/capture-project.js +206 -0
  220. package/dist/source-sync/capture-refusal.d.ts +7 -0
  221. package/dist/source-sync/capture-refusal.js +16 -0
  222. package/dist/source-sync/capture.d.ts +11 -0
  223. package/dist/source-sync/capture.js +22 -0
  224. package/dist/source-sync/checkpoint-gate.d.ts +21 -0
  225. package/dist/source-sync/checkpoint-gate.js +52 -0
  226. package/dist/source-sync/checkpoints.d.ts +66 -0
  227. package/dist/source-sync/checkpoints.js +168 -0
  228. package/dist/source-sync/claim.d.ts +11 -0
  229. package/dist/source-sync/claim.js +48 -0
  230. package/dist/source-sync/destination.d.ts +47 -0
  231. package/dist/source-sync/destination.js +239 -0
  232. package/dist/source-sync/io.d.ts +15 -0
  233. package/dist/source-sync/io.js +52 -0
  234. package/dist/source-sync/local.d.ts +43 -0
  235. package/dist/source-sync/local.js +229 -0
  236. package/dist/source-sync/prepare.d.ts +59 -0
  237. package/dist/source-sync/prepare.js +93 -0
  238. package/dist/source-sync/projects.d.ts +61 -0
  239. package/dist/source-sync/projects.js +130 -0
  240. package/dist/source-sync/registry.d.ts +95 -0
  241. package/dist/source-sync/registry.js +226 -0
  242. package/dist/source-sync/service.d.ts +33 -0
  243. package/dist/source-sync/service.js +118 -0
  244. package/dist/source-sync/skill-edits.d.ts +12 -0
  245. package/dist/source-sync/skill-edits.js +122 -0
  246. package/dist/source-sync/snapshots.d.ts +48 -0
  247. package/dist/source-sync/snapshots.js +448 -0
  248. package/dist/source-sync/types.d.ts +9 -0
  249. package/dist/source-sync/types.js +14 -0
  250. package/dist/source-sync/workspace.d.ts +66 -0
  251. package/dist/source-sync/workspace.js +273 -0
  252. package/dist/store/agent-body.d.ts +8 -0
  253. package/dist/store/agent-body.js +20 -6
  254. package/dist/store/index.d.ts +2 -2
  255. package/dist/store/index.js +1 -1
  256. package/dist/store/journal/storage.d.ts +2 -0
  257. package/dist/store/journal/storage.js +2 -1
  258. package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
  259. package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
  260. package/dist/store/schema.d.ts +15 -1
  261. package/dist/store/schema.js +43 -4
  262. package/dist/store/seal.d.ts +5 -1
  263. package/dist/store/seal.js +12 -3
  264. package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
  265. package/dist/store/sqlite/project-checkpoints.js +70 -0
  266. package/dist/store/sqlite/run-launch.d.ts +14 -0
  267. package/dist/store/sqlite/run-launch.js +58 -7
  268. package/dist/store/sqlite/run-patch.d.ts +2 -1
  269. package/dist/store/sqlite/run-patch.js +4 -3
  270. package/dist/store/sqlite/store.js +319 -153
  271. package/dist/store/store-schema.js +2 -2
  272. package/dist/store/store.d.ts +173 -33
  273. package/dist/store/store.js +14 -1
  274. package/dist/store-reads/learning.d.ts +12 -8
  275. package/dist/store-reads/learning.js +33 -24
  276. package/dist/store-reads/loop.d.ts +4 -3
  277. package/dist/store-reads/loop.js +7 -5
  278. package/dist/store-view.d.ts +3 -1
  279. package/dist/store-view.js +17 -5
  280. package/dist/template-eval.js +4 -4
  281. package/dist/template-import.d.ts +10 -2
  282. package/dist/template-import.js +116 -13
  283. package/dist/templates.d.ts +29 -5
  284. package/dist/templates.js +68 -14
  285. package/dist/timeline/index.d.ts +1 -1
  286. package/dist/timeline/index.js +1 -1
  287. package/dist/timeline/labels.js +1 -1
  288. package/dist/timeline/timeline.d.ts +5 -0
  289. package/dist/timeline/timeline.js +8 -0
  290. package/dist/tool-plane.d.ts +12 -12
  291. package/dist/tools.d.ts +8 -8
  292. package/dist/tools.js +1 -1
  293. package/dist/trigger-launch-hook.d.ts +47 -0
  294. package/dist/trigger-launch-hook.js +90 -0
  295. package/dist/trigger-targets.d.ts +14 -1
  296. package/dist/trigger-targets.js +20 -0
  297. package/dist/triggers.d.ts +54 -5
  298. package/dist/triggers.js +143 -8
  299. package/dist/uploads-archil.js +2 -1
  300. package/dist/uploads.d.ts +0 -3
  301. package/dist/uploads.js +2 -11
  302. package/dist/validate.js +4 -1
  303. package/dist/web-save.d.ts +3 -0
  304. package/dist/web-save.js +17 -2
  305. package/dist/workspace/archil-exec.js +1 -1
  306. package/dist/workspace/archil.js +1 -1
  307. package/dist/workspace/computer-for-claim.d.ts +2 -0
  308. package/dist/workspace/computer-for-claim.js +43 -0
  309. package/dist/workspace/paths.d.ts +6 -0
  310. package/dist/workspace/paths.js +6 -0
  311. package/dist/workspace/resolve-computer.d.ts +1 -0
  312. package/dist/workspace/revision-skills.js +24 -11
  313. package/dist/workspace/run-tools.d.ts +2 -0
  314. package/dist/workspace/run-tools.js +8 -0
  315. package/dist/workspace/synced-folder.d.ts +3 -3
  316. package/dist/workspace/synced-folder.js +7 -6
  317. package/launcher/agentrun-serve +1 -1
  318. package/package.json +10 -10
  319. package/skills/agentrun-serve/SKILL.md +2 -1
  320. package/templates/README.md +5 -2
  321. package/dist/console/assets/index-Bt1B51b7.js +0 -733
  322. package/dist/console/assets/index-sVftE9Ht.css +0 -1
@@ -1,3 +1,5 @@
1
+ import { reconcileProjectCheckpoints } from "./source-sync/checkpoints.js";
2
+ import { requireSavedProject } from "./source-sync/checkpoint-gate.js";
1
3
  import { NATIVE_RUN_OVERRIDES_UNSUPPORTED, nativeOf, nativeRunOverrides } from "./native/binding.js";
2
4
  import { launchNative } from "./native/connection.js";
3
5
  // The write half of the run's server cut (design 2.1, "the runner takes every run"): the functions the v2 routes call to
@@ -12,28 +14,32 @@ import { launchNative } from "./native/connection.js";
12
14
  // is the run view's to read from the journal (the server's view layer, run-view.ts). These writers take it as `RunMoment`
13
15
  // and never recompute it; the coarse facts a row already holds (its state, its launch cap) they read from the store.
14
16
  import { randomBytes } from "node:crypto";
15
- import { externalKey, getAgent } from "./agents-store.js";
17
+ import { externalKey, getAgent, ownedElsewhere } from "./agents-store.js";
16
18
  import { CAP_TOLERANCE, money } from "./cap.js";
17
19
  import { holdOf } from "./computer-held.js";
18
20
  import { computerOfPlace, settingOfDefinition } from "./computer-setting.js";
19
21
  import { ApiError, invalid, unsupported } from "./errors.js";
20
22
  import { labelsOf } from "./run-labels.js";
21
23
  import { harnessOfBody } from "./harness.js";
24
+ import { uuidv7 } from "./ids.js";
22
25
  import { redacted, redactedOutput } from "./key-refusal.js";
23
26
  import { chooseWorkflows, learnedSection, learnsOf, RUN_LEARNING_USE } from "./learning.js";
24
27
  import { thinkingLevel } from "./model.js";
25
28
  import { resolvePlace } from "./place.js";
26
29
  import { githubTargetOf } from "./github.js";
27
30
  import { repoOf } from "./run-repo.js";
28
- import { launchBody } from "./run-launch.js";
31
+ import { launchBody, sourceProjectOf } from "./run-launch.js";
32
+ import { learningDiskOf } from "./learn/learning-of.js";
29
33
  import { modelKeyRequired, serverKeyMissing } from "./run-model-key.js";
30
34
  import { raiseFollowUpId } from "./run-view.js";
31
35
  import { sendCommand } from "./runner/commands.js";
32
36
  import { refuseWhileNoRunner } from "./runner/presence.js";
33
- import { AgentDeleting, AnswerTaken, ExternalBodyConflict, RunFinal, StoreConstraint, StoreLaunchMissing } from "./store/index.js";
37
+ import { RevisionMoved, AgentDeleting, AgentPurged, AgentArchived, AnswerTaken, ExternalBodyConflict, RunFinal, StoreConstraint, StoreLaunchMissing } from "./store/index.js";
34
38
  import { canonical } from "./store/agent-body.js";
39
+ import { sourceSyncOf } from "./source-sync/types.js";
35
40
  import { toolingOf } from "./tools.js";
36
41
  import { planeFor } from "./tool-plane.js";
42
+ import { declaredKeys, undeclaredKeys, withCarried } from "./run-keys.js";
37
43
  import { clip } from "./web-fetch-direct.js";
38
44
  import { isObject } from "./validate.js";
39
45
  /** Why a message that may not answer a person's question is not sent (runs.ts WAITS_ON_A_PERSON). */
@@ -174,7 +180,8 @@ export async function message(store, moment, content, { requestId, answers = tru
174
180
  throw new ApiError("input_invalid", "Native jobs do not support in-session steering or follow-up messages. Start a new native run.");
175
181
  // Archiving closes a run: it, or a run of its archived agent, takes no message, said as archived (never as finished). Another
176
182
  // system's agent is archived only by its delete: said so, as every run of it is refused (AgentDeleting).
177
- if (moment.archived === "agent" && (await store.agents.get(moment.agentId))?.externalRef != null)
183
+ const archivedAgent = moment.archived === "agent" ? await store.agents.get(moment.agentId) : null;
184
+ if (archivedAgent && ownedElsewhere(archivedAgent))
178
185
  throw new AgentDeleting(moment.agentId);
179
186
  if (moment.archived !== undefined)
180
187
  throw archivedRefusal(moment);
@@ -396,16 +403,6 @@ export async function approve(store, moment, id, decision, note, confirmed = fal
396
403
  throw alreadyAnswered(id, end.decision);
397
404
  }
398
405
  }
399
- // ---- start -----------------------------------------------------------------------------------------------------------
400
- /** A UUIDv7 run id: time-ordered, so a listing by start time is stable, and unique per run. */
401
- export function uuidv7(now = Date.now()) {
402
- const bytes = randomBytes(16);
403
- bytes.writeUIntBE(now, 0, 6);
404
- bytes[6] = (bytes[6] & 0x0f) | 0x70;
405
- bytes[8] = (bytes[8] & 0x3f) | 0x80;
406
- const hex = bytes.toString("hex");
407
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
408
- }
409
406
  /** A no-op redactor, when the server gives none: no secret is cut (the switch wires the real shown for a learning run). */
410
407
  const noShown = { text: (text) => text, name: (name) => name, holds: () => false };
411
408
  /** The run's learning start: undefined when the run does not learn (the server's learning off, a workflow revision, or
@@ -414,8 +411,10 @@ const noShown = { text: (text) => text, name: (name) => name, holds: () => false
414
411
  * null when its seed cannot be read (a learning fault never refuses a run). `use`: the run's start said `learning:
415
412
  * "use"`, so it starts from what its agent learned, its revision's own learning aside, and keeps nothing. `noWorkflows`:
416
413
  * a run never answered by a learned workflow nor asked to draft one (a native run's, an SDK run's with no workflow
417
- * binding). `model`: an SDK run's compile model. */
418
- export async function learningStartFor(deps, entry, revision, rbody, { use = false, noWorkflows = false, model } = {}) {
414
+ * binding). `model`: an SDK run's compile model. `disk`: the disk the run's launch names as its own (learn/learning-of.ts
415
+ * learningDiskOf), null for the default disk: a run on a named disk learns nothing, so it is never started from the
416
+ * folder seedFor reads (seedFailed `other_disk`: it starts with nothing learned). */
417
+ export async function learningStartFor(deps, entry, revision, rbody, { use = false, noWorkflows = false, model, disk }) {
419
418
  // A run started with `learning: "use"` starts from what its agent learned whatever its revision says, and keeps
420
419
  // nothing; the server's learning off still gives it nothing.
421
420
  const learns = deps.learning !== undefined && deps.learning !== "off" && revision.kind === "agentic" && (learnsOf(rbody.learning) || use);
@@ -423,6 +422,9 @@ export async function learningStartFor(deps, entry, revision, rbody, { use = fal
423
422
  return undefined;
424
423
  const flows = noWorkflows || nativeOf(revision.body) ? { noWorkflows: true } : {};
425
424
  const own = { ...flows, ...(use ? { use: true } : {}), ...(model ? { model } : {}) };
425
+ // Another disk's learning is never read for it: not its corrections, not its workflows.
426
+ if (disk !== null)
427
+ return { seed: null, section: "", seedFailed: "other_disk", ...own };
426
428
  const seeded = await deps.seedFor(entry.agent.id);
427
429
  // The folder could not be read (main's STOPPED.unreadable), or what it read could not be made into the start (main's
428
430
  // copy that threw, STOPPED.notCopied): the run starts with nothing learned, and its learning end says which.
@@ -431,7 +433,7 @@ export async function learningStartFor(deps, entry, revision, rbody, { use = fal
431
433
  try {
432
434
  const shown = deps.shown ? deps.shown() : noShown;
433
435
  const workflows = flows.noWorkflows ? [] : chooseWorkflows(seeded.seed, shown).flows.map(({ name }) => name);
434
- return { seed: seeded.seed.sha, section: learnedSection(seeded.seed, shown), ...(workflows.length ? { workflows } : {}), ...own };
436
+ return { seed: seeded.seed.sha, section: learnedSection(seeded.seed, shown), ...(workflows.length ? { workflows } : {}), ...(seeded.seed.at !== undefined ? { seededAt: seeded.seed.at } : {}), ...own };
435
437
  }
436
438
  catch {
437
439
  return { seed: null, section: "", seedFailed: "not_copied", ...own };
@@ -442,19 +444,37 @@ export async function learningStartFor(deps, entry, revision, rbody, { use = fal
442
444
  * (store.runs.create), which a runner reads at its claim. No process, no door, no setup file: where the run runs is the
443
445
  * runner's. Under `origin`, a key that already started a run gets that run (the store's one-run-per-key), so a retry never
444
446
  * starts a second. */
445
- export async function startRun(store, deps, entry, body, { trigger, origin, capped = false, from, title, sealed } = {}) {
447
+ export async function startRun(store, deps, entry, body, { trigger, origin, capped = false, from, title, sealed, keys } = {}) {
448
+ if (sourceSyncOf(entry.revision?.body)) {
449
+ // Re-delivery of a firing that already admitted a run is not a new start and needs no new project preparation.
450
+ if (origin) {
451
+ const found = await store.runOfOrigin(origin.key);
452
+ const existing = found && found.fingerprint === (origin.fingerprint ?? null) ? await store.runs.get(found.runId) : undefined;
453
+ if (existing?.agentId === entry.agent.id)
454
+ return existing;
455
+ }
456
+ await reconcileProjectCheckpoints(store, entry.agent.id);
457
+ const current = await getAgent(store, entry.agent.id);
458
+ if (!current)
459
+ throw new ApiError("not_found", "The agent no longer exists.");
460
+ // The body still pins any explicitly requested revision; refresh the current pointer used by admission's CAS.
461
+ entry = current;
462
+ await requireSavedProject(store, entry.agent.id);
463
+ }
446
464
  if (entry.revision?.body?.cli_learning)
447
465
  throw new ApiError("agent_not_runnable", "Start the next prompt in your existing CLI session. AgentRun records its learning; it does not launch this connection.");
448
466
  if (entry.revision?.body?.sdk)
449
467
  throw new ApiError("agent_not_runnable", "This agent runs in your backend SDK. Start it through its SDK learning wrapper; AgentRun does not launch its tools or credentials.");
450
- const { launch, revision } = await prepareLaunch(deps, entry, body, { ...(trigger ? { trigger } : {}), capped, ...(from ? { from } : {}), ...(title !== undefined ? { title } : {}) });
468
+ const { launch, revision } = await prepareLaunch(deps, entry, body, { ...(trigger ? { trigger } : {}), capped, ...(from ? { from } : {}), ...(title !== undefined ? { title } : {}), ...(keys ? { keys } : {}) });
451
469
  keyedOrRefused(deps, launch, revision.kind, sealed);
452
470
  const runId = (deps.newRunId ?? uuidv7)();
453
471
  try {
454
472
  const labels = labelsOf(body.labels);
455
- return await withHeldFiles(deps, runId, entry.agent.id, launch, (launch) => store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(origin ? { origin } : {}), ...(labels ? { labels } : {}) }, { body: launchBody(launch), ...(sealed ? { sealed: sealed(runId, launch, revision.kind) } : {}) }));
473
+ return await withHeldFiles(store, deps, runId, entry.agent.id, revision, launch, (launch) => store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, expectedCurrent: entry.agent.currentRevision, ...(origin ? { origin } : {}), ...(labels ? { labels } : {}) }, { body: launchBody(launch), ...(sealed ? { sealed: sealed(runId, launch, revision.kind) } : {}) }));
456
474
  }
457
475
  catch (error) {
476
+ if (error instanceof RevisionMoved)
477
+ throw new ApiError("precondition_failed", "The agent changed while this run was prepared. Start again using its current setup.");
458
478
  // Only another writer of the store got here first under the same origin key: its run is the one asked for.
459
479
  if (origin && error instanceof StoreConstraint) {
460
480
  const existing = await store.runOfOrigin(origin.key);
@@ -476,7 +496,95 @@ function keyedOrRefused(deps, launch, kind, sealed) {
476
496
  * hold that fails part way, a write that fails, or one that answers another run (an origin key's run started before),
477
497
  * lets go of the hold. In Mode 2 they are placed in the run's folder instead (StartDeps.files.place), and the run is
478
498
  * written with the launch that says so; the same failures undo the placing. */
479
- async function withHeldFiles(deps, runId, agentId, launch, write) {
499
+ export async function withHeldFiles(store, deps, runId, agentId, revision, launch, write) {
500
+ const source = sourceSyncOf(revision.body);
501
+ if (!source)
502
+ return withUploads(deps, runId, agentId, launch, write);
503
+ if (!deps.project)
504
+ throw new ApiError("agent_not_runnable", "This project must be prepared before its run can start.");
505
+ const ownership = await deps.project.hold?.({ runId, agentId });
506
+ let projectSettled = false;
507
+ const preparationOwnership = ownership ? { settled: async () => { projectSettled = true; } } : undefined;
508
+ const undos = [];
509
+ const undo = async (settled = false) => {
510
+ let complete = true;
511
+ for (const release of [...undos].reverse())
512
+ try {
513
+ await release();
514
+ }
515
+ catch {
516
+ complete = false;
517
+ }
518
+ if ((settled || projectSettled) && complete)
519
+ await ownership?.settled();
520
+ };
521
+ let prepared = launch, admitted;
522
+ try {
523
+ const ids = launch.files ?? [];
524
+ if (ids.length && deps.files) {
525
+ const uploaded = await deps.files.place?.(runId, agentId, prepared);
526
+ if (uploaded) {
527
+ prepared = uploaded.launch;
528
+ undos.push(() => uploaded.undo());
529
+ }
530
+ else {
531
+ undos.push(() => deps.files.release(runId));
532
+ await deps.files.hold(runId, ids);
533
+ }
534
+ }
535
+ const placed = await deps.project.place({ runId, agentId, revision, launch: prepared, ...(preparationOwnership ? { hold: preparationOwnership } : {}) });
536
+ if (!placed)
537
+ throw new ApiError("agent_not_runnable", "This project has no completed placement for its run.");
538
+ undos.push(() => placed.undo());
539
+ admitted = placed.admitted;
540
+ prepared = placed.launch;
541
+ const receipt = sourceProjectOf(prepared.sourceProject);
542
+ if (!receipt || receipt.sourceId !== source.id || receipt.digest !== source.project || receipt.baselineRevision !== revision.id)
543
+ throw new ApiError("agent_not_runnable", "The prepared project does not match this run's pinned revision.");
544
+ }
545
+ catch (error) {
546
+ await undo();
547
+ throw error;
548
+ }
549
+ try {
550
+ const row = await write(prepared);
551
+ if (row.id !== runId)
552
+ await undo(true);
553
+ else {
554
+ if (ownership)
555
+ await ownership.settled();
556
+ else
557
+ await admitted?.();
558
+ }
559
+ return row;
560
+ }
561
+ catch (error) {
562
+ // A transport/COMMIT answer can be lost after admission. Never erase a runner's files on that evidence. Even a
563
+ // successful absent-row read does not prove an in-flight commit cannot land later: unknown admissions stay retained.
564
+ let knownAbsent = false;
565
+ try {
566
+ const row = await store.runs.get(runId);
567
+ if (row) {
568
+ const kept = await store.runs.launch(runId);
569
+ if (row.agentId === agentId && row.revisionId === revision.id && kept && canonical(kept.body) === canonical(launchBody(prepared))) {
570
+ if (ownership)
571
+ await ownership.settled();
572
+ else
573
+ await admitted?.();
574
+ return row;
575
+ }
576
+ }
577
+ else
578
+ knownAbsent = true;
579
+ }
580
+ catch { /* preserve preparation until the admission can be resolved */ }
581
+ if (knownAbsent && (error instanceof StoreConstraint || error instanceof RevisionMoved || error instanceof AgentDeleting
582
+ || error instanceof AgentPurged || error instanceof AgentArchived || error instanceof ExternalBodyConflict || error instanceof ApiError))
583
+ await undo(true);
584
+ throw error;
585
+ }
586
+ }
587
+ async function withUploads(deps, runId, agentId, launch, write) {
480
588
  const ids = launch.files ?? [];
481
589
  if (!ids.length || !deps.files)
482
590
  return await write(launch);
@@ -540,7 +648,7 @@ export async function startInline(store, deps, inline, body, options = {}) {
540
648
  }
541
649
  /** The agent id each reference's first starts in progress share, and a failed first start's kept (startInline). */
542
650
  const tentativeAgents = new Map();
543
- async function startInlineOnce(store, deps, inline, body, { origin, sealed }, newAgentId) {
651
+ async function startInlineOnce(store, deps, inline, body, { origin, sealed, keys }, newAgentId) {
544
652
  const { external, revision, stored: storedRevision } = inline;
545
653
  const ref = externalKey(external);
546
654
  // A version's body never changes here: a different one is refused before anything else is read or written.
@@ -564,12 +672,12 @@ async function startInlineOnce(store, deps, inline, body, { origin, sealed }, ne
564
672
  };
565
673
  // A store revision is the revision the run path reads as a pi Revision (its body is the revision body), as pinnedOf hands
566
674
  // one across.
567
- const { launch } = await prepareLaunch(deps, entry, body, { revision: (storedRevision ?? revision) });
675
+ const { launch } = await prepareLaunch(deps, entry, body, { revision: (storedRevision ?? revision), ...(keys ? { keys } : {}) });
568
676
  keyedOrRefused(deps, launch, (storedRevision ?? revision).kind, sealed);
569
677
  const runId = (deps.newRunId ?? uuidv7)();
570
678
  const labels = labelsOf(body.labels);
571
679
  try {
572
- return await withHeldFiles(deps, runId, entry.agent.id, launch, (launch) => store.runs.createInline({
680
+ return await withHeldFiles(store, deps, runId, entry.agent.id, revision, launch, (launch) => store.runs.createInline({
573
681
  agent: { id: entry.agent.id, name: inline.name, description: inline.description, ref },
574
682
  revision: { id: revision.id, version: external.version, kind: revision.kind, body: revision.body, skills: revision.skills, ...(revision.note !== undefined ? { note: revision.note } : {}), ...(revision.mcpPin !== undefined ? { mcpPin: revision.mcpPin } : {}), ...(revision.monidPin !== undefined ? { monidPin: revision.monidPin } : {}) },
575
683
  run: { id: runId, ...(origin ? { origin } : {}), ...(labels ? { labels } : {}) },
@@ -594,7 +702,7 @@ async function startInlineOnce(store, deps, inline, body, { origin, sealed }, ne
594
702
  * caller INSERTs the run with it (startRun; an inline agent's run, which writes its agent and revision in the same
595
703
  * transaction). `revision`: the revision the run starts on, given (an inline agent's, not yet stored), in place of the
596
704
  * one the body pins or the agent's current (deps.pinnedOf). */
597
- export async function prepareLaunch(deps, entry, body, { trigger, capped = false, from, title: given, revision: onRevision } = {}) {
705
+ export async function prepareLaunch(deps, entry, body, { trigger, capped = false, from, title: given, revision: onRevision, keys } = {}) {
598
706
  const pinnedOf = onRevision ? async () => ({ revision: onRevision, version: entry.version }) : () => deps.pinnedOf(entry, body);
599
707
  const issues = deps.runBodyIssues(body);
600
708
  if (issues.length) {
@@ -624,6 +732,11 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
624
732
  const wrong = await deps.inputIssuesOf(revision, input);
625
733
  if (wrong.length)
626
734
  throw deps.told(invalid(await deps.explainRun(wrong, body, revision)));
735
+ // The tool keys the run carries (run-keys.ts), by name: each one a tool of its revision reads, or its template declared.
736
+ const carried = keys ?? [];
737
+ const undeclared = carried.length ? undeclaredKeys(carried, await declaredKeys(revision)) : [];
738
+ if (undeclared.length)
739
+ throw invalid(undeclared);
627
740
  // The run's own cap, else the agent's default: the caller chose its own.
628
741
  const cap = typeof body.max_cost_usd === "number" ? body.max_cost_usd : rbody.maxCostUsd;
629
742
  if (capped && cap === undefined)
@@ -636,7 +749,7 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
636
749
  const place = resolvePlace(rbody.place, deps.fallbackPlace(revision.kind, revision.kind === "agentic" ? (rbody.tools ?? []) : []));
637
750
  // Checked as pinned: an earlier revision with no pin is pinned now, once (StartDeps.pinFirst); one that could not be, as
638
751
  // its server could not be listed, is refused with the rest (runnable).
639
- await deps.runnable(deps.pinFirst ? await deps.pinFirst(revision) : revision, place, { capped: cap !== undefined });
752
+ await deps.runnable(deps.pinFirst ? await deps.pinFirst(revision) : revision, place, { capped: cap !== undefined, carried });
640
753
  // A held computer (computer-held.ts): only one that speaks the protocol, its kind as the claim reads it (the
641
754
  // revision's computer, else its place's).
642
755
  const hold = holdOf(body, (settingOfDefinition(rbody)?.computer ?? computerOfPlace(place)).kind);
@@ -651,21 +764,23 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
651
764
  // A starter's title (a trigger's "<Source> <name>") is shown words too: cut as the input is, then as every title is below.
652
765
  const title = given !== undefined ? String(redactedOutput(given, deps.serverSecrets())) : revision.kind === "workflow" ? deps.workflowTitle(entry.agent.name || entry.agent.id, isObject(shown) ? shown : {}) : typeof input.content === "string" ? input.content : (Object.values(input).find((v) => typeof v === "string") ?? JSON.stringify(input));
653
766
  // Its tools' providers, resolved before the run exists (tool-plane.ts) and kept in its launch body, so a claim reads them
654
- // back, never the settings of that moment. (The old start wrote them to serve.json; now they ride the launch row.)
767
+ // back, never the settings of that moment. (The old start wrote them to serve.json; now they ride the launch row.) A key
768
+ // the run carries resolves a tool as one the host holds would.
655
769
  const tooling = await toolingOf(revision);
656
- const plane = tooling ? planeFor(deps.planeEnv(), tooling, deps.toolSettings(), { capped: cap !== undefined, run: true }) : {};
770
+ const plane = tooling ? planeFor(withCarried(deps.planeEnv(), carried), tooling, deps.toolSettings(), { capped: cap !== undefined, run: true }) : {};
657
771
  // The run's model, resolved once, at start (the runner reads launch.model only).
658
772
  const model = await deps.modelOf(entry, revision);
659
- // The run's learning start, decided here: a run learns when the server's learning is on and its revision says so; then
660
- // its seed is read now and its # Learned text pinned in the launch for the runner to put in the prompt. A seed that
661
- // cannot be read starts it with nothing (seed null); the end state is the runner's.
662
- const learning = await learningStartFor(deps, entry, revision, rbody, { use: body.learning === RUN_LEARNING_USE });
663
773
  // The run's Archil disk, chosen now and kept in its launch (run-launch.ts archilDisk): the one the body names (a disk per
664
774
  // customer), else its agent's when it has one; with neither, its claim makes the agent's.
665
775
  const named = isObject(body.archil_disk) && typeof body.archil_disk.disk_id === "string" ? body.archil_disk.disk_id : undefined;
666
776
  if (named !== undefined && !deps.launchDiskOf)
667
777
  throw invalid([{ field: "archil_disk", reason: "not_allowed", message: "This server keeps no run on an Archil disk." }]);
668
778
  const archilDisk = deps.launchDiskOf ? await deps.launchDiskOf(entry.agent.id, named) : undefined;
779
+ // The run's learning start, decided here: a run learns when the server's learning is on and its revision says so; then
780
+ // its seed is read now and its # Learned text pinned in the launch for the runner to put in the prompt. A seed that
781
+ // cannot be read starts it with nothing (seed null); the end state is the runner's. Its learning is its disk's: a run on
782
+ // a disk its launch names is never started from the default disk's.
783
+ const learning = await learningStartFor(deps, entry, revision, rbody, { use: body.learning === RUN_LEARNING_USE, disk: archilDisk ? learningDiskOf({ archilDisk }) : null });
669
784
  // The run's effort: its own, else its revision's saved thinking, else the host's AGENT_THINKING (each a thinking level,
670
785
  // else none). Nothing set: none, so the run gets no effort note and its harness's own default. Kept in its launch, so
671
786
  // its harness's thinking, its guidance and its metrics all read the one value.
@@ -16,11 +16,12 @@ export type SdkWorkflowCheckEvent = {
16
16
  /** Fresh read-only calls the shadow made where the native recording had no result (the client's shadowReadFallback). */
17
17
  fresh_reads?: number;
18
18
  };
19
- /** Settles a connected agent's check at its run's end. The client reports execution, never its own verdict, and the
20
- * immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of the
21
- * check (decideCheck); any other turn is given back (releaseSdkCheck) and the check waits for the next turn; a turn the
22
- * backend never completed before its inbox expired is one failed row (sdkCheckDeadline). Exact retries and reclaims
23
- * compete on the reservation. */
19
+ /** Settles a connected agent's reserved turn at its run's end. The client reports execution, never its own verdict, and
20
+ * the immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of
21
+ * the check (sdkCheckTurn: kept until the check holds compile_after rows, the one that makes compile_after deciding on
22
+ * them all); any other turn is given back (releaseSdkCheck) and the check waits for the next turn; a turn the backend
23
+ * never completed before its inbox expired is one failed row (sdkCheckDeadline). Exact retries and reclaims compete on
24
+ * the reservation. */
24
25
  export declare function settleSdkCheck(deps: {
25
26
  store: Store;
26
27
  agentId: string;
package/dist/sdk/check.js CHANGED
@@ -1,4 +1,4 @@
1
- import { decideCheck, releaseSdkCheck, sdkCheckDeadline, sdkInputText } from "../runner/promotion.js";
1
+ import { releaseSdkCheck, sdkCheckDeadline, sdkCheckTurn, sdkInputText } from "../runner/promotion.js";
2
2
  import { promotionOf, promotionsOf } from "../learn/promote.js";
3
3
  /** Why a completed inbox's native turn cannot be its check's baseline, or undefined when it can: a completed turn with
4
4
  * complete, unredacted evidence and no learned workflow or nested call in it, whose shadow answered or handed back. */
@@ -20,11 +20,12 @@ function notBaseline(inbox, reported) {
20
20
  return `its shadow stopped at a write the native turn did not make (${reported.skipped?.tool ?? "a tool"})`;
21
21
  return undefined;
22
22
  }
23
- /** Settles a connected agent's check at its run's end. The client reports execution, never its own verdict, and the
24
- * immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of the
25
- * check (decideCheck); any other turn is given back (releaseSdkCheck) and the check waits for the next turn; a turn the
26
- * backend never completed before its inbox expired is one failed row (sdkCheckDeadline). Exact retries and reclaims
27
- * compete on the reservation. */
23
+ /** Settles a connected agent's reserved turn at its run's end. The client reports execution, never its own verdict, and
24
+ * the immutable completion is the baseline. A shadow that answered or handed back on a valid native turn is one row of
25
+ * the check (sdkCheckTurn: kept until the check holds compile_after rows, the one that makes compile_after deciding on
26
+ * them all); any other turn is given back (releaseSdkCheck) and the check waits for the next turn; a turn the backend
27
+ * never completed before its inbox expired is one failed row (sdkCheckDeadline). Exact retries and reclaims compete on
28
+ * the reservation. */
28
29
  export async function settleSdkCheck(deps) {
29
30
  const { inbox } = deps;
30
31
  const check = inbox.learning_check;
@@ -37,22 +38,22 @@ export async function settleSdkCheck(deps) {
37
38
  if (!completion) {
38
39
  if (inbox.closed === "expired")
39
40
  return sdkCheckDeadline(deps, record);
41
+ // A cancel is a person's choice, not the integration failing to give a baseline: given back uncounted.
40
42
  if (inbox.closed)
41
- return releaseSdkCheck(deps, record, inbox.closed === "cancelled" ? "its native turn was stopped before the backend completed it" : "its native turn ended before the backend completed it");
43
+ return releaseSdkCheck(deps, record, inbox.closed === "cancelled" ? "its native turn was stopped before the backend completed it" : "its native turn ended before the backend completed it", inbox.closed !== "cancelled");
42
44
  return;
43
45
  }
44
46
  const reported = inbox.batches.flatMap((batch) => batch.events)
45
47
  .find((event) => event.type === "workflow_check" && event.id === check.id && event.digest === check.digest);
46
48
  const cause = notBaseline({ ...inbox, completion }, reported);
47
49
  if (cause !== undefined || !reported)
48
- return releaseSdkCheck(deps, record, cause ?? "the connected agent reported no shadow check");
49
- const outcomes = { answered: 0, handed_back: 0, failed: 0, skipped_write: 0 };
50
- outcomes[reported.outcome]++;
51
- return decideCheck(deps, check.workflow.name, check.digest, record.check, {
52
- rows: [{ of: inbox.run_id, input: sdkInputText(deps.launch), agent: completion.answer, outcome: reported.outcome,
53
- answer: reported.outcome === "answered" ? reported.answer ?? null : null,
54
- ...(reported.outcome === "handed_back" ? { escalated: reported.reason ?? "The shadow workflow handed the task back." } : {}),
55
- }], cost: null, outcomes, unstarted: 0, ...(reported.fresh_reads ? { fresh_reads: reported.fresh_reads } : {}),
50
+ return releaseSdkCheck(deps, record, cause ?? "the connected agent reported no shadow check", completion.status !== "cancelled");
51
+ return sdkCheckTurn(deps, { ...record, check: record.check }, {
52
+ of: inbox.run_id, input: sdkInputText(deps.launch), agent: completion.answer, outcome: reported.outcome,
53
+ answer: reported.outcome === "answered" ? reported.answer ?? null : null,
54
+ ...(reported.outcome === "handed_back" ? { escalated: reported.reason ?? "The shadow workflow handed the task back." } : {}),
55
+ }, (was) => was?.decided === "replaying" && was.replay_id === check.id, {
56
+ ...(reported.fresh_reads ? { fresh_reads: reported.fresh_reads } : {}),
56
57
  exactMismatchReason: "its answer did not match the native answer exactly; connected SDK checks do not use a semantic grader, so name the fields that carry the decision (learning.agree_on) when whole-answer equality is not the intended check",
57
- }, (was) => was?.decided === "replaying" && was.replay_id === check.id, { via: "sdk", runs: record.runs, replay_id: check.id, commit: check.revision });
58
+ });
58
59
  }
@@ -64,6 +64,9 @@ export type SdkInbox = {
64
64
  }[];
65
65
  /** Exact promoted executable workflows delivered by the start receipt. */
66
66
  learning_workflows?: LearnedWorkflow[];
67
+ /** The learning commit each of learning_workflows was read at, by name (its seed's, or its champion record's): where
68
+ * the receipt asks whether a purged run wrote it (receipt). */
69
+ learning_commits?: Record<string, string>;
67
70
  /** A compiled draft reserved for a shadow check, never supplied to the native agent. */
68
71
  learning_check?: SdkWorkflowCheck;
69
72
  /** Server cleaning changed evidence: two different secret-bearing answers must never agree by their placeholder. */
@@ -76,10 +79,12 @@ export type SdkInbox = {
76
79
  };
77
80
  /** The settings key an SDK run's record is kept under (the run's delete with its agent's: agent-delete.ts). */
78
81
  export declare const sdkRunKey: (id: string) => string;
82
+ export declare const SDK_MAX_OPEN_MS = 86400000;
79
83
  export declare const sdkOf: (body: unknown) => SdkBinding | undefined;
80
84
  export declare function sdkInbox(store: Pick<Store, "settings">, runId: string): Promise<SdkInbox>;
81
85
  /** Completion and closure compete on the same inbox. A stale runner cannot close it, and a completion that won
82
- * remains available to the next claim even if this one cannot read or journal it. No external SDK call is replayed. */
86
+ * remains available to the next claim even if this one cannot read or journal it. No external SDK call is replayed.
87
+ * An expiry is checked against the row it replaces: an events batch that moved the deadline keeps the inbox open. */
83
88
  export declare function closeSdkInbox(store: Pick<Store, "settings">, claim: Claim, reason: NonNullable<SdkInbox["closed"]>): Promise<SdkInbox>;
84
89
  /** The key a server signs its SDK runs' credentials with: derived from its seal key (seal-key.ts), which stays the
85
90
  * store's for its life, so adding, reordering or removing an API token (api-token.ts) never changes a run's credential. */
@@ -126,6 +131,11 @@ export declare class SdkRuns {
126
131
  workflows: LearnedWorkflow[];
127
132
  };
128
133
  }>;
134
+ /** The purged run (purged-workflow.ts) that wrote a workflow of `pinned`, each read at the learning commit a start took
135
+ * its text from. One read-only exec per commit. */
136
+ private purgedPinned;
137
+ /** The workflows a start delivers and the learning commit each was read at (`commits`: the seed's, or its champion
138
+ * record's), and the drafts a check may take. */
129
139
  private selectedWorkflows;
130
140
  private modify;
131
141
  private writable;