@parcha/agentrun-serve 0.1.0-beta.52 → 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 (261) hide show
  1. package/CHANGELOG.md +122 -1
  2. package/README.md +213 -24
  3. package/dist/agent-delete.d.ts +5 -6
  4. package/dist/agent-delete.js +30 -67
  5. package/dist/agent-package.d.ts +71 -0
  6. package/dist/agent-package.js +345 -0
  7. package/dist/agents-store.d.ts +26 -20
  8. package/dist/agents-store.js +41 -33
  9. package/dist/api-only.d.ts +26 -6
  10. package/dist/api-only.js +35 -13
  11. package/dist/claude-login.d.ts +1 -0
  12. package/dist/claude-login.js +1 -1
  13. package/dist/cli-learning/cli.d.ts +3 -0
  14. package/dist/cli-learning/cli.js +17 -3
  15. package/dist/cli-learning/connections.js +3 -2
  16. package/dist/cli-learning/schema.js +2 -1
  17. package/dist/cli.js +70 -7
  18. package/dist/composio-preset.d.ts +2 -1
  19. package/dist/composio-preset.js +4 -3
  20. package/dist/composio-triggers.d.ts +4 -0
  21. package/dist/composio-triggers.js +4 -1
  22. package/dist/computer-needs.d.ts +32 -0
  23. package/dist/computer-needs.js +80 -0
  24. package/dist/computer-setting.d.ts +1 -0
  25. package/dist/computer-setting.js +8 -1
  26. package/dist/console/assets/index-BFgyZzF_.js +734 -0
  27. package/dist/console/assets/index-DbilxljH.css +1 -0
  28. package/dist/console/index.html +2 -2
  29. package/dist/console-links.d.ts +1 -0
  30. package/dist/console-links.js +2 -0
  31. package/dist/env-switch.d.ts +14 -0
  32. package/dist/env-switch.js +23 -0
  33. package/dist/errors.d.ts +1 -0
  34. package/dist/errors.js +3 -0
  35. package/dist/eval-previous.js +4 -3
  36. package/dist/fal-price.js +10 -13
  37. package/dist/handed-secret.d.ts +4 -0
  38. package/dist/handed-secret.js +10 -0
  39. package/dist/harness-archive.d.ts +15 -5
  40. package/dist/harness-archive.js +71 -34
  41. package/dist/harness-check.d.ts +2 -1
  42. package/dist/harness-check.js +36 -95
  43. package/dist/harness-egress.d.ts +23 -0
  44. package/dist/harness-egress.js +69 -0
  45. package/dist/harness-recipe-entry.d.ts +71 -0
  46. package/dist/harness-recipe-entry.js +184 -0
  47. package/dist/harness-recipe.d.ts +73 -6
  48. package/dist/harness-recipe.js +185 -31
  49. package/dist/harness-sign-in.d.ts +29 -0
  50. package/dist/harness-sign-in.js +122 -0
  51. package/dist/harness-table.d.ts +21 -0
  52. package/dist/harness-table.js +58 -3
  53. package/dist/harness-zip.d.ts +6 -0
  54. package/dist/harness-zip.js +203 -0
  55. package/dist/ids.d.ts +11 -0
  56. package/dist/ids.js +36 -0
  57. package/dist/learn/commit.d.ts +14 -1
  58. package/dist/learn/commit.js +156 -1
  59. package/dist/learn/compile.js +22 -8
  60. package/dist/learn/folder.d.ts +5 -0
  61. package/dist/learn/folder.js +10 -1
  62. package/dist/learn/learning.sh +15 -3
  63. package/dist/learn/promote.d.ts +2 -2
  64. package/dist/learn/secrets.js +30 -7
  65. package/dist/learning-routes.d.ts +23 -11
  66. package/dist/learning-routes.js +110 -20
  67. package/dist/learning.d.ts +9 -6
  68. package/dist/learning.js +9 -4
  69. package/dist/mcp-gateway.js +15 -2
  70. package/dist/mcp-probe.d.ts +3 -0
  71. package/dist/mcp-probe.js +7 -2
  72. package/dist/mcp-resources.d.ts +44 -0
  73. package/dist/mcp-resources.js +100 -0
  74. package/dist/mcp-servers-store.d.ts +16 -12
  75. package/dist/model.d.ts +4 -4
  76. package/dist/model.js +6 -6
  77. package/dist/native/cli.js +9 -2
  78. package/dist/native/connection.d.ts +2 -2
  79. package/dist/native/connection.js +5 -2
  80. package/dist/native/discovery.d.ts +2 -0
  81. package/dist/native/discovery.js +10 -6
  82. package/dist/native/remote-worker-bridge.js +36 -4
  83. package/dist/native/remote.d.ts +18 -1
  84. package/dist/native/remote.js +126 -37
  85. package/dist/native/schema.d.ts +6 -0
  86. package/dist/native/schema.js +31 -6
  87. package/dist/native/source-account.d.ts +13 -0
  88. package/dist/native/source-account.js +114 -0
  89. package/dist/native/source-capture-hooks.d.ts +5 -0
  90. package/dist/native/source-capture-hooks.js +102 -0
  91. package/dist/native/source-mcp-selection.d.ts +13 -0
  92. package/dist/native/source-mcp-selection.js +72 -0
  93. package/dist/native/source-runtime-tools.d.ts +19 -0
  94. package/dist/native/source-runtime-tools.js +103 -0
  95. package/dist/native/source-snapshot-types.d.ts +138 -0
  96. package/dist/native/source-snapshot-types.js +12 -0
  97. package/dist/native/source-snapshot.d.ts +8 -0
  98. package/dist/native/source-snapshot.js +1201 -0
  99. package/dist/observation/learning.js +3 -2
  100. package/dist/openapi.js +167 -36
  101. package/dist/print.js +1 -1
  102. package/dist/purged-workflow.d.ts +12 -0
  103. package/dist/purged-workflow.js +43 -0
  104. package/dist/run-keys.d.ts +46 -0
  105. package/dist/run-keys.js +109 -0
  106. package/dist/run-launch.d.ts +16 -1
  107. package/dist/run-launch.js +30 -1
  108. package/dist/run-learning-served.d.ts +2 -2
  109. package/dist/run-model-key.d.ts +2 -2
  110. package/dist/run-model-key.js +5 -5
  111. package/dist/run-secrets.d.ts +2 -0
  112. package/dist/run-secrets.js +7 -4
  113. package/dist/run-view.d.ts +17 -0
  114. package/dist/run-view.js +25 -1
  115. package/dist/runner/adapter-loop.d.ts +11 -3
  116. package/dist/runner/adapter-loop.js +138 -22
  117. package/dist/runner/adapter-run-spec.js +25 -12
  118. package/dist/runner/audit.d.ts +2 -0
  119. package/dist/runner/audit.js +9 -1
  120. package/dist/runner/beside.js +2 -1
  121. package/dist/runner/claim-secrets.d.ts +29 -3
  122. package/dist/runner/claim-secrets.js +38 -4
  123. package/dist/runner/cli-run-spec.js +23 -12
  124. package/dist/runner/harness-loops.d.ts +6 -0
  125. package/dist/runner/harness-loops.js +11 -1
  126. package/dist/runner/held.d.ts +4 -0
  127. package/dist/runner/journal-kinds.d.ts +2 -0
  128. package/dist/runner/learned-first.d.ts +2 -0
  129. package/dist/runner/learned-first.js +1 -1
  130. package/dist/runner/learning-end.d.ts +7 -2
  131. package/dist/runner/learning-end.js +22 -10
  132. package/dist/runner/learning-seed.d.ts +9 -3
  133. package/dist/runner/learning-seed.js +2 -2
  134. package/dist/runner/main.d.ts +1 -0
  135. package/dist/runner/main.js +20 -13
  136. package/dist/runner/mcp-claim.js +6 -1
  137. package/dist/runner/mcp-run.d.ts +10 -7
  138. package/dist/runner/mcp-run.js +3 -5
  139. package/dist/runner/monid-run.js +9 -11
  140. package/dist/runner/project-checkpoint.d.ts +35 -0
  141. package/dist/runner/project-checkpoint.js +116 -0
  142. package/dist/runner/project-drain.d.ts +8 -0
  143. package/dist/runner/project-drain.js +25 -0
  144. package/dist/runner/project-host.d.ts +10 -0
  145. package/dist/runner/project-host.js +52 -0
  146. package/dist/runner/promotion.d.ts +14 -6
  147. package/dist/runner/promotion.js +98 -41
  148. package/dist/runner/redact.d.ts +13 -0
  149. package/dist/runner/redact.js +67 -1
  150. package/dist/runner/run-channel.d.ts +9 -0
  151. package/dist/runner/run-channel.js +15 -2
  152. package/dist/runner/run-child-host.d.ts +8 -4
  153. package/dist/runner/run-child-host.js +171 -41
  154. package/dist/runner/run-errors.js +2 -2
  155. package/dist/runner/runner-check.js +5 -2
  156. package/dist/runner/runner.js +26 -9
  157. package/dist/runner/store-secrets.js +7 -3
  158. package/dist/runner/workflow-first.d.ts +4 -0
  159. package/dist/runner/workflow-first.js +13 -0
  160. package/dist/runner/workflow-loop.d.ts +2 -1
  161. package/dist/runner/workflow-loop.js +2 -1
  162. package/dist/runner/workflow-spec.js +1 -1
  163. package/dist/runs-over-store.d.ts +34 -6
  164. package/dist/runs-over-store.js +133 -25
  165. package/dist/sdk/runs.d.ts +11 -1
  166. package/dist/sdk/runs.js +117 -26
  167. package/dist/sdk/schema.js +12 -2
  168. package/dist/sdk/workflows.d.ts +1 -1
  169. package/dist/server.d.ts +68 -32
  170. package/dist/server.js +600 -110
  171. package/dist/skills/agentrun-serve/SKILL.md +2 -1
  172. package/dist/source-sync/adoption.d.ts +15 -0
  173. package/dist/source-sync/adoption.js +36 -0
  174. package/dist/source-sync/auxiliary.d.ts +23 -0
  175. package/dist/source-sync/auxiliary.js +64 -0
  176. package/dist/source-sync/capture-git.d.ts +5 -0
  177. package/dist/source-sync/capture-git.js +272 -0
  178. package/dist/source-sync/capture-project.d.ts +53 -0
  179. package/dist/source-sync/capture-project.js +206 -0
  180. package/dist/source-sync/capture-refusal.d.ts +7 -0
  181. package/dist/source-sync/capture-refusal.js +16 -0
  182. package/dist/source-sync/capture.d.ts +11 -0
  183. package/dist/source-sync/capture.js +22 -0
  184. package/dist/source-sync/checkpoint-gate.d.ts +21 -0
  185. package/dist/source-sync/checkpoint-gate.js +52 -0
  186. package/dist/source-sync/checkpoints.d.ts +66 -0
  187. package/dist/source-sync/checkpoints.js +168 -0
  188. package/dist/source-sync/claim.d.ts +11 -0
  189. package/dist/source-sync/claim.js +48 -0
  190. package/dist/source-sync/destination.d.ts +47 -0
  191. package/dist/source-sync/destination.js +239 -0
  192. package/dist/source-sync/io.d.ts +15 -0
  193. package/dist/source-sync/io.js +52 -0
  194. package/dist/source-sync/local.d.ts +43 -0
  195. package/dist/source-sync/local.js +229 -0
  196. package/dist/source-sync/prepare.d.ts +59 -0
  197. package/dist/source-sync/prepare.js +93 -0
  198. package/dist/source-sync/projects.d.ts +61 -0
  199. package/dist/source-sync/projects.js +130 -0
  200. package/dist/source-sync/registry.d.ts +95 -0
  201. package/dist/source-sync/registry.js +226 -0
  202. package/dist/source-sync/service.d.ts +33 -0
  203. package/dist/source-sync/service.js +118 -0
  204. package/dist/source-sync/skill-edits.d.ts +12 -0
  205. package/dist/source-sync/skill-edits.js +122 -0
  206. package/dist/source-sync/snapshots.d.ts +48 -0
  207. package/dist/source-sync/snapshots.js +448 -0
  208. package/dist/source-sync/types.d.ts +9 -0
  209. package/dist/source-sync/types.js +14 -0
  210. package/dist/source-sync/workspace.d.ts +66 -0
  211. package/dist/source-sync/workspace.js +273 -0
  212. package/dist/store/agent-body.d.ts +4 -0
  213. package/dist/store/agent-body.js +16 -5
  214. package/dist/store/index.d.ts +2 -2
  215. package/dist/store/index.js +1 -1
  216. package/dist/store/schema.d.ts +2 -1
  217. package/dist/store/schema.js +2 -1
  218. package/dist/store/seal.d.ts +5 -1
  219. package/dist/store/seal.js +12 -3
  220. package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
  221. package/dist/store/sqlite/project-checkpoints.js +70 -0
  222. package/dist/store/sqlite/run-launch.d.ts +4 -12
  223. package/dist/store/sqlite/run-launch.js +5 -19
  224. package/dist/store/sqlite/store.js +224 -170
  225. package/dist/store/store.d.ts +116 -39
  226. package/dist/store/store.js +14 -1
  227. package/dist/store-reads/learning.d.ts +2 -2
  228. package/dist/store-view.d.ts +3 -1
  229. package/dist/store-view.js +17 -5
  230. package/dist/template-import.d.ts +10 -2
  231. package/dist/template-import.js +116 -13
  232. package/dist/templates.d.ts +26 -5
  233. package/dist/templates.js +62 -10
  234. package/dist/timeline/index.d.ts +1 -1
  235. package/dist/timeline/index.js +1 -1
  236. package/dist/timeline/timeline.d.ts +5 -0
  237. package/dist/timeline/timeline.js +8 -0
  238. package/dist/tool-plane.d.ts +12 -12
  239. package/dist/tools.d.ts +8 -8
  240. package/dist/trigger-launch-hook.d.ts +47 -0
  241. package/dist/trigger-launch-hook.js +90 -0
  242. package/dist/trigger-targets.d.ts +14 -1
  243. package/dist/trigger-targets.js +20 -0
  244. package/dist/triggers.d.ts +54 -5
  245. package/dist/triggers.js +143 -8
  246. package/dist/uploads-archil.js +1 -1
  247. package/dist/uploads.js +1 -1
  248. package/dist/validate.js +1 -2
  249. package/dist/workspace/computer-for-claim.d.ts +2 -0
  250. package/dist/workspace/computer-for-claim.js +43 -0
  251. package/dist/workspace/paths.d.ts +6 -0
  252. package/dist/workspace/paths.js +6 -0
  253. package/dist/workspace/resolve-computer.d.ts +1 -0
  254. package/dist/workspace/run-tools.d.ts +2 -0
  255. package/dist/workspace/run-tools.js +8 -0
  256. package/launcher/agentrun-serve +1 -1
  257. package/package.json +10 -10
  258. package/skills/agentrun-serve/SKILL.md +2 -1
  259. package/templates/README.md +5 -2
  260. package/dist/console/assets/index-B-D0EM3j.js +0 -733
  261. package/dist/console/assets/index-DlQepP2J.css +0 -1
package/dist/sdk/runs.js CHANGED
@@ -1,12 +1,15 @@
1
1
  // Backend SDK calls remain in their application. This inbox only records their evidence and immutable completion;
2
2
  // the ordinary fenced runner owns journals, reflection, checking and learning commits.
3
+ import { cliCaptureOf } from "../source-sync/capture.js";
4
+ import { sourceKey } from "../source-sync/registry.js";
3
5
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
4
6
  import { inspectWorkflow, resolveSchemaForWorkflow } from "@parcha/agentrun-dsl";
5
- import { ApiError } from "../errors.js";
7
+ import { ApiError, invalid } from "../errors.js";
6
8
  import { canonical, isObject, cliLearningOf, learningSettingForBody } from "../store/agent-body.js";
7
- import { uuidv7 } from "../agents-store.js";
9
+ import { uuidv7 } from "../ids.js";
8
10
  import { launchBody } from "../run-launch.js";
9
11
  import { learningStartFor } from "../runs-over-store.js";
12
+ import { labelsIssues, labelsOf } from "../run-labels.js";
10
13
  import { chooseWorkflows, learningFolderOf, seedAt, secretsShown, withAgentRepo } from "../learning.js";
11
14
  import { INSTRUCTION_EVIDENCE_BYTES } from "../native/instructions.js";
12
15
  import { CLI_POLICY_BYTES } from "../cli-learning/policy.js";
@@ -14,10 +17,12 @@ import { refuseWhileNoRunner } from "../runner/presence.js";
14
17
  import { secretRedactor } from "../runner/redact.js";
15
18
  import { redactedOutput } from "../key-refusal.js";
16
19
  import { decodedStrings, draftProblems } from "../learn/workflow-draft.js";
20
+ import { snapshotAt } from "../learn/folder.js";
21
+ import { purgedRun, purgedWorkflows } from "../purged-workflow.js";
17
22
  import { sdkWorkflowManifest, sdkDraftTools } from "./workflows.js";
18
23
  import { promotionOf, promotionsOf, resetAtOf } from "../learn/promote.js";
19
24
  import { championTextOf, releaseSdkCheck, reserveSdkCheck } from "../runner/promotion.js";
20
- import { fits, workflowDigest } from "../runner/workflow-first.js";
25
+ import { sdkTakes, workflowDigest } from "../runner/workflow-first.js";
21
26
  import { SDK_WORKFLOW_RUNTIMES, sdkBindingOf } from "./runtimes.js";
22
27
  export { SDK_RUNTIMES, isSdkRuntime } from "./runtimes.js";
23
28
  /** Claude's begin snapshot is provisional; only its immutable same-window completion can establish policy. */
@@ -30,6 +35,13 @@ export function cliPolicyOf(launch, completion) {
30
35
  const keyOf = (id) => `sdk-run:${id}`;
31
36
  /** The settings key an SDK run's record is kept under (the run's delete with its agent's: agent-delete.ts). */
32
37
  export const sdkRunKey = keyOf;
38
+ /** An inbox takes evidence until an hour after its start or its latest events batch, and never past a day after its start. */
39
+ const SDK_OPEN_MS = 3_600_000;
40
+ export const SDK_MAX_OPEN_MS = 86_400_000;
41
+ /** A start's `started_at`: at most this far ahead of the server's clock, at most this far behind it. */
42
+ const STARTED_SKEW_MS = 60_000, STARTED_BACK_MS = 7 * 86_400_000;
43
+ const TITLE_LIMIT = 200;
44
+ const RFC3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(\.\d+)?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/;
33
45
  const TEXT_LIMIT = 128_000, BATCH_LIMIT = 256_000, TOTAL_LIMIT = 4_000_000;
34
46
  // Always leave enough room for bounded completion after an evidence upload reaches its limit.
35
47
  const EVIDENCE_LIMIT = TOTAL_LIMIT - 600_000;
@@ -61,6 +73,31 @@ const usageOf = (value) => {
61
73
  }
62
74
  return result;
63
75
  };
76
+ /** An RFC 3339 date-time as epoch ms, or undefined when it is not one (a field out of range included). */
77
+ function rfc3339(value) {
78
+ const m = RFC3339.exec(value);
79
+ if (!m)
80
+ return undefined;
81
+ const [y, mo, d, h, mi, s] = m.slice(1, 7).map(Number);
82
+ const day = new Date(Date.UTC(y, mo - 1, d));
83
+ if (day.getUTCFullYear() !== y || day.getUTCMonth() !== mo - 1 || day.getUTCDate() !== d || h > 23 || mi > 59 || s > 59)
84
+ return undefined;
85
+ if (m[8] && (Number(m[9]) > 23 || Number(m[10]) > 59))
86
+ return undefined;
87
+ const offset = m[8] ? (m[8] === "-" ? -1 : 1) * (Number(m[9]) * 60 + Number(m[10])) * 60_000 : 0;
88
+ return Date.UTC(y, mo - 1, d, h, mi, s, Math.floor(Number(`0${m[7] ?? ""}`) * 1000)) - offset;
89
+ }
90
+ /** A start's `started_at` as epoch ms: its form only, refused when it is not an RFC 3339 date-time. */
91
+ const rfc3339Of = (value) => (typeof value === "string" ? rfc3339(value) : undefined) ?? refuse("started_at must be an RFC 3339 date-time, such as 2026-01-02T03:04:05Z.");
92
+ /** A new start's `started_at` against the server's clock at `now`: when the backend began the task, if before this request.
93
+ * The run's `created_at` takes it. Never applied to a retry of a start already made (its receipt is returned first). */
94
+ const startedWithin = (at, now) => {
95
+ if (at > now + STARTED_SKEW_MS)
96
+ refuse("started_at must not be in the future.");
97
+ if (at < now - STARTED_BACK_MS)
98
+ refuse("started_at must be at most 7 days ago.");
99
+ return Math.min(at, now);
100
+ };
64
101
  export const sdkOf = (body) => isObject(body) ? sdkBindingOf(body.sdk) : undefined;
65
102
  export async function sdkInbox(store, runId) {
66
103
  const row = await store.settings.get(keyOf(runId));
@@ -69,12 +106,15 @@ export async function sdkInbox(store, runId) {
69
106
  return row;
70
107
  }
71
108
  /** Completion and closure compete on the same inbox. A stale runner cannot close it, and a completion that won
72
- * remains available to the next claim even if this one cannot read or journal it. No external SDK call is replayed. */
109
+ * remains available to the next claim even if this one cannot read or journal it. No external SDK call is replayed.
110
+ * An expiry is checked against the row it replaces: an events batch that moved the deadline keeps the inbox open. */
73
111
  export async function closeSdkInbox(store, claim, reason) {
74
112
  for (let retry = 0; retry < 20; retry++) {
75
113
  const row = await sdkInbox(store, claim.runId);
76
114
  if (row.completion || row.closed)
77
115
  return row;
116
+ if (reason === "expired" && row.expires_at >= Date.now())
117
+ return row;
78
118
  const next = { ...row, closed: reason };
79
119
  if (await store.settings.replaceIf(keyOf(claim.runId), row, next, claim))
80
120
  return next;
@@ -175,13 +215,22 @@ export class SdkRuns {
175
215
  async start(entry, body, deps, origin, compile, consoleOrigin, cli) {
176
216
  if (this.lane !== (cli ? "cli" : "sdk"))
177
217
  refuse("The run must use its enrolled credential lane.");
178
- only(body, cli ? ["runtime", "input", "instructions", "model"] : ["runtime", "platform", "input", "instructions", "model", "workflow_tools", "workflow_adapters"]);
218
+ only(body, cli ? ["runtime", "input", "instructions", "model"] : ["runtime", "platform", "input", "instructions", "model", "workflow_tools", "workflow_adapters", "started_at", "title", "labels"]);
179
219
  const source = cli ? undefined : sdkBindingOf(body) ?? refuse("The SDK source needs a supported runtime; external requires a platform label of 1–80 characters without surrounding whitespace, controls or lone surrogates. Other runtimes do not take platform.");
180
220
  if (source && !SDK_WORKFLOW_RUNTIMES.includes(source.runtime) && (body.workflow_tools !== undefined || body.workflow_adapters !== undefined))
181
221
  refuse("External runs receive owner corrections; workflow_tools and workflow_adapters require a backend workflow bridge.");
182
222
  const workflow = cli ? undefined : sdkWorkflowManifest(body.workflow_tools, body.workflow_adapters);
183
223
  if (workflow && canonical(this.clean(workflow)) !== canonical(workflow))
184
224
  refuse("The workflow manifest contains a protected value; keep credentials in the backend.");
225
+ const expectedCurrent = entry.agent.currentRevision;
226
+ const managedLearning = learningSettingForBody(entry.revision?.body);
227
+ const capture = cli ? await cliCaptureOf(this.store, entry) : undefined;
228
+ const sourceGuards = cli ? [{ key: `cli-learning-connection:${cli.connection_id}`, fields: { active: true, generation: cli.connection_generation, agent_id: entry.agent.id } }] : [];
229
+ if (capture) {
230
+ entry = { ...entry, revision: capture.revision };
231
+ if (capture.source)
232
+ sourceGuards.push({ key: sourceKey(entry.agent.id), fields: { id: capture.source.id, capture_revision: capture.source.capture_revision } });
233
+ }
185
234
  const binding = sdkOf(entry.revision?.body);
186
235
  if (cli) {
187
236
  if (cliLearningOf(entry.revision?.body)?.connection_id !== cli.connection_id)
@@ -198,6 +247,18 @@ export class SdkRuns {
198
247
  throw new ApiError("agent_archived", "This SDK agent is archived.");
199
248
  const input = text(body.input, "input"), instructions = text(body.instructions, "instructions", cli ? CLI_POLICY_BYTES : TEXT_LIMIT);
200
249
  const model = body.model === undefined ? undefined : text(body.model, "model", 256);
250
+ // Its form is checked now; its distance from the clock only for a new start, below: a retry of a start that was made
251
+ // (its origin and fingerprint kept) gets its receipt however late it comes.
252
+ const reportedAt = body.started_at === undefined ? undefined : rfc3339Of(body.started_at);
253
+ const title = body.title === undefined ? undefined : text(body.title, "title").trim().replace(/\s+/g, " ");
254
+ if (title !== undefined && ([...title].length < 1 || [...title].length > TITLE_LIMIT))
255
+ refuse(`title must be text of 1 to ${TITLE_LIMIT} characters.`);
256
+ const labelIssues = labelsIssues(body.labels);
257
+ if (labelIssues.length)
258
+ throw invalid(labelIssues);
259
+ const labels = labelsOf(body.labels);
260
+ if (labels && canonical(this.clean(labels)) !== canonical(labels))
261
+ refuse("A label contains a protected value; keep credentials in the backend.");
201
262
  if (origin) {
202
263
  const known = await this.store.runOfOrigin(origin.key);
203
264
  if (known) {
@@ -206,6 +267,7 @@ export class SdkRuns {
206
267
  return this.receipt(known.runId, consoleOrigin);
207
268
  }
208
269
  }
270
+ const startedAt = reportedAt === undefined ? undefined : startedWithin(reportedAt, Date.now());
209
271
  const cleanedInput = this.clean({ input }).input;
210
272
  const pinned = await deps.pinnedOf(entry, {});
211
273
  if (!pinned)
@@ -217,7 +279,7 @@ export class SdkRuns {
217
279
  // their words, as any start is (prepareLaunch), before the caller holds a receipt it would run on.
218
280
  await refuseWhileNoRunner(this.store.runners);
219
281
  // A connected agent's run names no disk.
220
- const learning = await learningStartFor(deps, entry, pinned.revision, { ...revisionBody, learning: learningSettingForBody(revisionBody) }, {
282
+ const learning = await learningStartFor(deps, entry, pinned.revision, { ...revisionBody, learning: cli ? managedLearning : learningSettingForBody(revisionBody) }, {
221
283
  disk: null,
222
284
  noWorkflows: !workflow,
223
285
  ...(compile.model ? { model: compile.model } : {}),
@@ -239,27 +301,20 @@ export class SdkRuns {
239
301
  const reset = learning ? await resetAtOf(this.store.settings, entry.agent.id) : undefined;
240
302
  if (learning && reset !== undefined && !(learning.seededAt !== undefined && learning.seededAt > reset))
241
303
  throw new ApiError("unavailable", "The agent's learning was reset while this run started: start it again.", { retry_after_ms: 1_000 });
242
- const selected = learning && !learning.noWorkflows && workflow ? await this.selectedWorkflows(entry.agent.id, learning.seed, workflow) : { workflows: [], candidates: [] };
304
+ const selected = learning && !learning.noWorkflows && workflow ? await this.selectedWorkflows(entry.agent.id, learning.seed, workflow) : { workflows: [], commits: {}, candidates: [] };
243
305
  const cleaned = this.clean({ instructions, ...(model ? { model } : {}) });
244
306
  const runId = uuidv7();
245
307
  const redacted = cleanedInput !== input || cleaned.instructions !== instructions;
246
- let task;
247
- try {
248
- task = JSON.parse(input);
249
- }
250
- catch { /* A prose task: the client resolves the draft's input from the turn. */ }
251
308
  // A turn is a check only when it can be one's baseline: no protected value in its task or policy, and an input the
252
- // draft takes. A JSON object task is the input, so it must fit (the managed check's own rule); a prose task's input
253
- // is resolved by the client from the turn's recorded tool inputs or the host's resolveCheckInput, and a turn it
254
- // cannot resolve is given back (releaseSdkCheck), never counted.
255
- const takes = (flow) => !redacted && (!isObject(task) || fits(flow, task, resolveSchemaForWorkflow));
309
+ // draft takes (sdkTakes). A prose turn whose input the client cannot resolve is given back (releaseSdkCheck).
310
+ const takes = (flow) => !redacted && sdkTakes(flow, input, resolveSchemaForWorkflow);
256
311
  const checkDeps = { store: this.store, agentId: entry.agent.id, log: () => { }, shown: async () => secretsShown(this.secrets(), { local: true }) };
257
312
  const check = learning ? await reserveSdkCheck(checkDeps, { runId, revision: learning.seed, learning: revisionBody.learning, flows: selected.candidates, takes }) : undefined;
258
313
  // A shadow check needs the original agent's own answer, not an answer produced by its existing champion.
259
314
  const workflows = check ? [] : selected.workflows;
260
315
  const launch = {
261
316
  input: { content: cleanedInput },
262
- title: cleanedInput.trim().replace(/\s+/g, " ").slice(0, 80),
317
+ title: title === undefined ? cleanedInput.trim().replace(/\s+/g, " ").slice(0, 80) : this.clean({ title }).title,
263
318
  place: { mode: "runner" },
264
319
  ...(cli ? {
265
320
  harness: "cli",
@@ -275,14 +330,15 @@ export class SdkRuns {
275
330
  await this.store.settings.put(keyOf(runId), {
276
331
  run_id: runId,
277
332
  created_at: now,
278
- expires_at: now + (cli ? 86_400_000 : 3_600_000),
333
+ expires_at: now + (cli ? SDK_MAX_OPEN_MS : SDK_OPEN_MS),
279
334
  batches: [],
280
335
  learning_workflows: workflows,
336
+ ...(workflows.length ? { learning_commits: selected.commits } : {}),
281
337
  ...(check ? { learning_check: check } : {}),
282
338
  ...(redacted ? { check_redacted: true } : {}),
283
339
  ...(cli && cleanedInput !== input ? { evidence_incomplete: true } : {}),
284
340
  });
285
- await this.store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(origin ? { origin } : {}) }, { body: launchBody(launch) });
341
+ await this.store.runs.create({ id: runId, agentId: entry.agent.id, revisionId: revision.id, ...(cli ? { expectedCurrent, settingsGuards: sourceGuards } : {}), ...(origin ? { origin } : {}), ...(labels ? { labels } : {}), ...(startedAt !== undefined ? { startedAt } : {}) }, { body: launchBody(launch) });
286
342
  }
287
343
  catch (error) {
288
344
  await this.store.settings.remove(keyOf(runId));
@@ -321,6 +377,15 @@ export class SdkRuns {
321
377
  const launch = (await this.store.runs.launch(runId)).body;
322
378
  const inbox = await sdkInbox(this.store, runId);
323
379
  const workflows = inbox.learning_workflows ?? [];
380
+ // A start sent again answers the receipt it pinned, never a workflow a purged run wrote: 410 purged, as its file read.
381
+ // Each is read at the commit it was taken from (learning_commits; the check's draft at the seed).
382
+ const seed = launch.learning?.seed ?? null;
383
+ const purged = seed === null ? undefined : await this.purgedPinned(run.agentId, [
384
+ ...workflows.map((flow) => [flow, inbox.learning_commits?.[flow.name] ?? seed]),
385
+ ...(inbox.learning_check ? [[inbox.learning_check.workflow, seed]] : []),
386
+ ]);
387
+ if (purged)
388
+ throw purgedRun(purged);
324
389
  const shown = secretsShown(this.secrets(), { local: true });
325
390
  if (shown.holds(launch.learning?.section ?? "") ||
326
391
  [...workflows, ...(inbox.learning_check ? [inbox.learning_check.workflow] : [])].some((flow) => {
@@ -342,10 +407,32 @@ export class SdkRuns {
342
407
  },
343
408
  };
344
409
  }
410
+ /** The purged run (purged-workflow.ts) that wrote a workflow of `pinned`, each read at the learning commit a start took
411
+ * its text from. One read-only exec per commit. */
412
+ async purgedPinned(agentId, pinned) {
413
+ if (pinned.length === 0)
414
+ return undefined;
415
+ const folder = learningFolderOf(this.data, agentId);
416
+ try {
417
+ const reads = new Map();
418
+ const at = (commit) => reads.get(commit) ?? reads.set(commit, snapshotAt(folder.workspace, commit).then((snapshot) => purgedWorkflows(snapshot, this.store))).get(commit);
419
+ for (const [flow, commit] of pinned) {
420
+ const row = (await at(commit)).get(flow.name);
421
+ if (row)
422
+ return row;
423
+ }
424
+ return undefined;
425
+ }
426
+ finally {
427
+ await folder.end();
428
+ }
429
+ }
430
+ /** The workflows a start delivers and the learning commit each was read at (`commits`: the seed's, or its champion
431
+ * record's), and the drafts a check may take. */
345
432
  async selectedWorkflows(agentId, revision, binding) {
346
433
  const folder = learningFolderOf(this.data, agentId);
347
434
  try {
348
- const seed = await seedAt(folder.workspace, revision);
435
+ const seed = await seedAt(folder.workspace, revision, this.store);
349
436
  const { flows } = chooseWorkflows(seed, secretsShown(this.secrets(), { local: true }));
350
437
  const dsl = await import("@parcha/agentrun-dsl");
351
438
  const { tools, gated, deniedBy } = sdkDraftTools(binding.workflow_tools);
@@ -358,16 +445,18 @@ export class SdkRuns {
358
445
  room -= bytes;
359
446
  return true;
360
447
  };
361
- const workflows = [], candidates = [];
362
- const atCommit = async (name, commit) => chooseWorkflows(await seedAt(folder.workspace, commit), secretsShown(this.secrets(), { local: true })).flows.find((one) => one.name === name);
448
+ const workflows = [], candidates = [], commits = {};
449
+ const atCommit = async (name, commit) => chooseWorkflows(await seedAt(folder.workspace, commit, this.store), secretsShown(this.secrets(), { local: true })).flows.find((one) => one.name === name);
363
450
  for (const flow of flows) {
364
- const { text: serving } = await championTextOf(records, flow, atCommit);
365
- if (serving && compatible(serving))
451
+ const { text: serving, champion } = await championTextOf(records, flow, atCommit);
452
+ if (serving && compatible(serving)) {
366
453
  workflows.push(serving);
454
+ commits[serving.name] = serving === flow ? seed.sha : champion.commit;
455
+ }
367
456
  if ((!serving || workflowDigest(serving) !== workflowDigest(flow)) && compatible(flow))
368
457
  candidates.push(flow);
369
458
  }
370
- return { workflows, candidates };
459
+ return { workflows, commits, candidates };
371
460
  }
372
461
  finally {
373
462
  await folder.end();
@@ -488,7 +577,9 @@ export class SdkRuns {
488
577
  for (const check of checks)
489
578
  if (!row.learning_check || check.id !== row.learning_check.id || check.digest !== row.learning_check.digest)
490
579
  refuse("The workflow check must name this SDK run's reserved candidate.");
491
- return { ...row, batches: [...row.batches, batch], ...(checkRedacted ? { check_redacted: true, ...(launch.cli_learning ? { evidence_incomplete: true } : {}) } : {}) };
580
+ // Every accepted batch, an empty one too, keeps the inbox open another hour, up to a day after its start.
581
+ const expires = Math.max(row.expires_at, Math.min(Date.now() + SDK_OPEN_MS, row.created_at + SDK_MAX_OPEN_MS));
582
+ return { ...row, batches: [...row.batches, batch], expires_at: expires, ...(checkRedacted ? { check_redacted: true, ...(launch.cli_learning ? { evidence_incomplete: true } : {}) } : {}) };
492
583
  }, EVIDENCE_LIMIT);
493
584
  return { accepted: true };
494
585
  }
@@ -1,3 +1,4 @@
1
+ import { LABEL_KEY, MAX_LABEL_VALUE, MAX_LABELS } from "../run-labels.js";
1
2
  import { MCP_TOOL_KEY_PATTERN } from "../tool-names.js";
2
3
  import { SDK_RUNTIMES, SDK_PLATFORM_MAX_LENGTH, SDK_PLATFORM_PATTERN } from "./runtimes.js";
3
4
  const text = { type: "string" };
@@ -78,7 +79,7 @@ export const SDK_PATHS = {
78
79
  ...mark,
79
80
  operationId: "startSdkRun",
80
81
  summary: "Register a task executed by an existing backend SDK",
81
- description: "Requires an SDK agent definition. Captures the actual original policy and input, pins promoted workflows and any compiled shadow-check candidate separately, and returns a credential scoped to this run. The backend retains all model/tool/auth settings. Learning requires a configured server reflection/grading model; learning Off needs no server model key.",
82
+ description: "Requires an SDK agent definition. Captures the actual original policy and input, pins promoted workflows and any compiled shadow-check candidate separately, and returns a credential scoped to this run. The backend retains all model/tool/auth settings. Learning requires a configured server reflection/grading model; learning Off needs no server model key. The run takes evidence until an hour after this request; each events batch moves that deadline to an hour after the batch, up to 24 hours after this request (capabilities.features.sdk_runs.max_open_s).",
82
83
  parameters: [id("agent_id"), { ...key, required: true }],
83
84
  requestBody: body(sdkObject({
84
85
  input: { ...text, maxLength: 128000 },
@@ -93,6 +94,15 @@ export const SDK_PATHS = {
93
94
  price_usd: { type: "number", minimum: 0 },
94
95
  }, ["name", "description", "input_schema", "permission"]) },
95
96
  workflow_adapters: { type: "array", maxItems: 2, uniqueItems: true, items: { enum: ["runNode", "runJudge"] }, description: "Optional backend callbacks available for workflow model and decision nodes. Default empty; requires workflow_tools." },
97
+ started_at: { ...text, format: "date-time", description: "When the backend began the task, as an RFC 3339 date-time: the run's created_at. At most 60 seconds ahead of the server's clock and at most 7 days behind it. Absent: now. The evidence deadline is still counted from this request." },
98
+ title: { ...text, minLength: 1, maxLength: 200, description: "The run's title, trimmed and with whitespace collapsed. Absent: the first 80 characters of input." },
99
+ labels: {
100
+ type: "object",
101
+ maxProperties: MAX_LABELS,
102
+ propertyNames: { pattern: LABEL_KEY.source },
103
+ additionalProperties: { type: "string", minLength: 1, maxLength: MAX_LABEL_VALUE },
104
+ description: "The caller's own labels for the run, under the same rules as RunCreate.labels: kept on the run, served on every read of it and matched by GET /runs' label. Put no secret in one: a label holding a server secret is refused.",
105
+ },
96
106
  }, ["input", "instructions"])),
97
107
  responses: {
98
108
  201: response(object({
@@ -129,7 +139,7 @@ export const SDK_PATHS = {
129
139
  ...mark,
130
140
  operationId: "sdkRunEvents",
131
141
  summary: "Record bounded SDK execution evidence",
132
- description: "Use the scoped run token. Batches are contiguous from sequence 1, at most 100 events and 256 KB each, 4 MB total per run. Exact retries are idempotent; conflicting retries and events after completion are refused. Tool start IDs are unique per run. A nested callback names an already open, pinned learned_workflow invocation in parent_tool_use_id, and its result keeps the original call name and parent. Evidence never authorizes or executes a tool.",
142
+ description: "Use the scoped run token. Batches are contiguous from sequence 1, at most 100 events and 256 KB each, 4 MB total per run. Each new batch, an empty one (events: []) included, moves the run's deadline to an hour after it, up to 24 hours after the start; a run past its deadline takes no more evidence or completion and ends with an unknown outcome. Exact retries are idempotent; conflicting retries and events after completion are refused. Tool start IDs are unique per run. A nested callback names an already open, pinned learned_workflow invocation in parent_tool_use_id, and its result keeps the original call name and parent. Evidence never authorizes or executes a tool.",
133
143
  parameters: [id("run_id"), key],
134
144
  requestBody: body(object({ sequence: { type: "integer", minimum: 1 }, events: { type: "array", maxItems: 100, items: event } })),
135
145
  responses: { 200: response(object({ accepted: { const: true } })), ...errors },
@@ -14,7 +14,7 @@ export declare function sdkWorkflowManifest(tools: unknown, adapters: unknown):
14
14
  export declare function sdkDraftTools(manifest: readonly SdkWorkflowTool[]): {
15
15
  tools: string[];
16
16
  gated: {
17
- [k: string]: "ask" | "allow" | "deny";
17
+ [k: string]: "ask" | "deny" | "allow";
18
18
  };
19
19
  deniedBy: {
20
20
  [k: string]: "agent";
package/dist/server.d.ts CHANGED
@@ -13,6 +13,7 @@ import { type StoredKeys } from "./secrets.js";
13
13
  import { type ComposioControl } from "./composio-preset.js";
14
14
  import type { TriggerAdapter } from "./trigger-adapter.js";
15
15
  import { type TriggerClock } from "./triggers.js";
16
+ import type { LaunchHook } from "./trigger-launch-hook.js";
16
17
  import { type ToolSettingsMap } from "./tool-plane.js";
17
18
  import { AttachHub, type HostedDial } from "@parcha/agentrun-computer";
18
19
  import { type AttachTiming } from "./computer-attach.js";
@@ -88,6 +89,12 @@ export type ServeOptions = {
88
89
  * (the console, sign-in, setup, settings, MCP, triggers, hooks, ...) with a 404 before anything reads the request.
89
90
  * It has no owner: accounts and open setup are off, there being no page to sign in to. */
90
91
  apiOnly?: boolean;
92
+ /** The launch hook (AGENTRUN_LAUNCH_HOOK_URL and _SECRET, trigger-launch-hook.ts): each trigger firing that would start
93
+ * a run is handed to the host instead, which starts it through the API. None, firings start their runs here. */
94
+ launchHook?: LaunchHook;
95
+ /** The run-keys setting (AGENTRUN_RUN_KEYS=1, run-keys.ts): a template's apply makes its agent though a tool key it
96
+ * declares is not set here, and a run of it that does not carry that key in `keys` is refused. */
97
+ runKeys?: boolean;
91
98
  /** Another Archil control plane than the key's region's, and its fetch, and another maker of a disk's file API: a
92
99
  * test's fakes, for the server's own Archil calls (a launch's disk read, the settings' test, an agent's disk removed,
93
100
  * a deleted agent's run folder removed from a disk its launch named). */
@@ -141,6 +148,12 @@ export type ServeOptions = {
141
148
  /** The owner's harness modules (harness-table.ts HARNESS_MODULES_ENV): packages or paths, each exporting a
142
149
  * HarnessTableModule whose entries add harnesses of their own, for this server and its runs. Never a built-in one. */
143
150
  harnessModules?: readonly string[];
151
+ /** The owner's harness recipes (harness-table.ts HARNESS_RECIPES_ENV): recipe files installed into `data`, each adding
152
+ * the harness it describes to this server and its runs once a harness-check of it passed there (HARNESS.md#a-recipe). */
153
+ harnessRecipes?: readonly string[];
154
+ /** The owner's say-so (--harness-sign-in) that a plan-billed recipe with a sign-in runs a person's runs on the owner's
155
+ * own sign-in: a start refuses it unless this server is one owner's own, on their own machine (harnessSignInRefusal). */
156
+ harnessSignIn?: boolean;
144
157
  /** With `faux` only: Docker answers, so docker is available, and nothing asks Docker (place-offers.ts). */
145
158
  fauxDocker?: boolean;
146
159
  /** For tests: the lock each harness's first use installs by (harness-install.ts), by harness, with the package.json it
@@ -404,13 +417,13 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
404
417
  providers?: string[] | undefined;
405
418
  provider?: string | undefined;
406
419
  default_provider?: string | undefined;
407
- resolves?: Record<"opencode" | "codex" | "claude-agent" | "pi", import("./tool-plane.js").Resolution> | undefined;
408
- why?: Record<"opencode" | "codex" | "claude-agent" | "pi", string> | undefined;
409
- default_permission: "ask" | "allow" | "deny";
410
- permissions: ("ask" | "allow" | "deny")[];
420
+ resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", import("./tool-plane.js").Resolution> | undefined;
421
+ why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
422
+ default_permission: "ask" | "deny" | "allow";
423
+ permissions: ("ask" | "deny" | "allow")[];
411
424
  fallback_allow_reads?: true | undefined;
412
425
  allow_reads?: true | undefined;
413
- permission: "ask" | "allow" | "deny";
426
+ permission: "ask" | "deny" | "allow";
414
427
  harnesses: string[];
415
428
  missing?: string[] | undefined;
416
429
  reason?: string | undefined;
@@ -423,11 +436,11 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
423
436
  name: string;
424
437
  summary: string;
425
438
  } | {
426
- default_permission: "ask" | "allow" | "deny";
427
- permissions: ("ask" | "allow" | "deny")[];
439
+ default_permission: "ask" | "deny" | "allow";
440
+ permissions: ("ask" | "deny" | "allow")[];
428
441
  fallback_allow_reads?: true | undefined;
429
442
  allow_reads?: true | undefined;
430
- permission: "ask" | "allow" | "deny";
443
+ permission: "ask" | "deny" | "allow";
431
444
  name: string;
432
445
  summary: string;
433
446
  blurb: string;
@@ -441,13 +454,13 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
441
454
  providers?: string[] | undefined;
442
455
  provider?: string | undefined;
443
456
  default_provider?: string | undefined;
444
- resolves?: Record<"opencode" | "codex" | "claude-agent" | "pi", import("./tool-plane.js").Resolution> | undefined;
445
- why?: Record<"opencode" | "codex" | "claude-agent" | "pi", string> | undefined;
446
- default_permission: "ask" | "allow" | "deny";
447
- permissions: ("ask" | "allow" | "deny")[];
457
+ resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", import("./tool-plane.js").Resolution> | undefined;
458
+ why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
459
+ default_permission: "ask" | "deny" | "allow";
460
+ permissions: ("ask" | "deny" | "allow")[];
448
461
  fallback_allow_reads?: true | undefined;
449
462
  allow_reads?: true | undefined;
450
- permission: "ask" | "allow" | "deny";
463
+ permission: "ask" | "deny" | "allow";
451
464
  harnesses: string[];
452
465
  missing?: string[] | undefined;
453
466
  reason?: string | undefined;
@@ -461,11 +474,11 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
461
474
  summary: string;
462
475
  } | {
463
476
  key: string | undefined;
464
- default_permission: "ask" | "allow" | "deny";
465
- permissions: ("ask" | "allow" | "deny")[];
477
+ default_permission: "ask" | "deny" | "allow";
478
+ permissions: ("ask" | "deny" | "allow")[];
466
479
  fallback_allow_reads?: true | undefined;
467
480
  allow_reads?: true | undefined;
468
- permission: "ask" | "allow" | "deny";
481
+ permission: "ask" | "deny" | "allow";
469
482
  name: string;
470
483
  summary: string;
471
484
  blurb: string;
@@ -610,6 +623,13 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
610
623
  at_rest: string;
611
624
  };
612
625
  /** /triggers: what starts an agent's capped runs with no caller (triggers.ts). */
626
+ /** A backend SDK run's start (sdk/runs.ts): the fields it takes, and the most seconds it stays open. */
627
+ sdk_runs: {
628
+ started_at: boolean;
629
+ title: boolean;
630
+ labels: boolean;
631
+ max_open_s: number;
632
+ };
613
633
  triggers: {
614
634
  routes: boolean;
615
635
  sources: string[];
@@ -725,13 +745,13 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
725
745
  providers?: string[] | undefined;
726
746
  provider?: string | undefined;
727
747
  default_provider?: string | undefined;
728
- resolves?: Record<"opencode" | "codex" | "claude-agent" | "pi", import("./tool-plane.js").Resolution> | undefined;
729
- why?: Record<"opencode" | "codex" | "claude-agent" | "pi", string> | undefined;
730
- default_permission: "ask" | "allow" | "deny";
731
- permissions: ("ask" | "allow" | "deny")[];
748
+ resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", import("./tool-plane.js").Resolution> | undefined;
749
+ why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
750
+ default_permission: "ask" | "deny" | "allow";
751
+ permissions: ("ask" | "deny" | "allow")[];
732
752
  fallback_allow_reads?: true | undefined;
733
753
  allow_reads?: true | undefined;
734
- permission: "ask" | "allow" | "deny";
754
+ permission: "ask" | "deny" | "allow";
735
755
  harnesses: string[];
736
756
  missing?: string[] | undefined;
737
757
  reason?: string | undefined;
@@ -744,11 +764,11 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
744
764
  name: string;
745
765
  summary: string;
746
766
  } | {
747
- default_permission: "ask" | "allow" | "deny";
748
- permissions: ("ask" | "allow" | "deny")[];
767
+ default_permission: "ask" | "deny" | "allow";
768
+ permissions: ("ask" | "deny" | "allow")[];
749
769
  fallback_allow_reads?: true | undefined;
750
770
  allow_reads?: true | undefined;
751
- permission: "ask" | "allow" | "deny";
771
+ permission: "ask" | "deny" | "allow";
752
772
  name: string;
753
773
  summary: string;
754
774
  blurb: string;
@@ -762,13 +782,13 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
762
782
  providers?: string[] | undefined;
763
783
  provider?: string | undefined;
764
784
  default_provider?: string | undefined;
765
- resolves?: Record<"opencode" | "codex" | "claude-agent" | "pi", import("./tool-plane.js").Resolution> | undefined;
766
- why?: Record<"opencode" | "codex" | "claude-agent" | "pi", string> | undefined;
767
- default_permission: "ask" | "allow" | "deny";
768
- permissions: ("ask" | "allow" | "deny")[];
785
+ resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", import("./tool-plane.js").Resolution> | undefined;
786
+ why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
787
+ default_permission: "ask" | "deny" | "allow";
788
+ permissions: ("ask" | "deny" | "allow")[];
769
789
  fallback_allow_reads?: true | undefined;
770
790
  allow_reads?: true | undefined;
771
- permission: "ask" | "allow" | "deny";
791
+ permission: "ask" | "deny" | "allow";
772
792
  harnesses: string[];
773
793
  missing?: string[] | undefined;
774
794
  reason?: string | undefined;
@@ -782,11 +802,11 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
782
802
  summary: string;
783
803
  } | {
784
804
  key: string | undefined;
785
- default_permission: "ask" | "allow" | "deny";
786
- permissions: ("ask" | "allow" | "deny")[];
805
+ default_permission: "ask" | "deny" | "allow";
806
+ permissions: ("ask" | "deny" | "allow")[];
787
807
  fallback_allow_reads?: true | undefined;
788
808
  allow_reads?: true | undefined;
789
- permission: "ask" | "allow" | "deny";
809
+ permission: "ask" | "deny" | "allow";
790
810
  name: string;
791
811
  summary: string;
792
812
  blurb: string;
@@ -931,6 +951,13 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
931
951
  at_rest: string;
932
952
  };
933
953
  /** /triggers: what starts an agent's capped runs with no caller (triggers.ts). */
954
+ /** A backend SDK run's start (sdk/runs.ts): the fields it takes, and the most seconds it stays open. */
955
+ sdk_runs: {
956
+ started_at: boolean;
957
+ title: boolean;
958
+ labels: boolean;
959
+ max_open_s: number;
960
+ };
934
961
  triggers: {
935
962
  routes: boolean;
936
963
  sources: string[];
@@ -983,4 +1010,13 @@ type LearningCaps = {
983
1010
  export declare function forCaller<T extends {
984
1011
  learning: LearningCaps;
985
1012
  }>(caps: T, ownerSession: boolean): T;
1013
+ /** A start with --harness-sign-in on a server that is not one owner's own, on their own machine. */
1014
+ export declare const HARNESS_SIGN_IN_NOT_LOCAL = "HARNESS_SIGN_IN_NOT_LOCAL";
1015
+ /** Why `options` on `data` may not run a recipe on its owner's own sign-in (--harness-sign-in), in words; undefined when
1016
+ * it may. One owner's own server on their own machine: it listens on loopback alone, with no public address; its store
1017
+ * is the SQLite one in its data directory (no AGENTRUN_STORE_URL, which servers elsewhere share); its runs run beside
1018
+ * it as its own user (`ownUser`: runIsolationOf's `process`), never under --no-runner or a user of their own; and one
1019
+ * person starts them, as Claude Code's login on this machine asks (claude-login.ts whyNotOneOwner): an owner, and one
1020
+ * API token. A check, a schedule and a shared server run on a key (HARNESS.md#sign-in). */
1021
+ export declare function harnessSignInRefusal(options: Pick<ServeOptions, "host" | "publicUrl" | "runnerApart" | "apiOnly" | "token" | "tokens">, data: string, ownUser: boolean): string | undefined;
986
1022
  export declare function startServe(options: ServeOptions): Promise<Serve>;