@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.47

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 (247) hide show
  1. package/CHANGELOG.md +164 -1
  2. package/NOTICE +4 -0
  3. package/README.md +267 -40
  4. package/dist/acp-package.d.ts +35 -6
  5. package/dist/acp-package.js +3 -3
  6. package/dist/adapter-facts.d.ts +5 -2
  7. package/dist/adapter-facts.js +6 -3
  8. package/dist/adapters.d.ts +7 -0
  9. package/dist/adapters.js +39 -0
  10. package/dist/agents-store.d.ts +5 -3
  11. package/dist/agents-store.js +13 -8
  12. package/dist/api-only.d.ts +7 -10
  13. package/dist/api-only.js +7 -10
  14. package/dist/archil-routes.js +2 -1
  15. package/dist/cap.js +12 -2
  16. package/dist/chatgpt-plan.js +2 -1
  17. package/dist/cli.js +109 -41
  18. package/dist/composio-made.d.ts +19 -2
  19. package/dist/composio-made.js +17 -5
  20. package/dist/composio-preset.d.ts +42 -7
  21. package/dist/composio-preset.js +106 -70
  22. package/dist/composio-triggers.d.ts +9 -4
  23. package/dist/composio-triggers.js +20 -13
  24. package/dist/computer-attach.d.ts +11 -10
  25. package/dist/computer-attach.js +13 -14
  26. package/dist/computer-commands.d.ts +3 -0
  27. package/dist/computer-commands.js +3 -2
  28. package/dist/computer-lost.d.ts +4 -0
  29. package/dist/computer-lost.js +8 -3
  30. package/dist/computer-setting.d.ts +2 -0
  31. package/dist/computer-setting.js +2 -0
  32. package/dist/computers.d.ts +9 -75
  33. package/dist/computers.js +20 -66
  34. package/dist/console/assets/index-BBFzAxLB.js +715 -0
  35. package/dist/console/assets/index-BRi-Rgq6.css +1 -0
  36. package/dist/console/index.html +2 -2
  37. package/dist/cost-heal.d.ts +13 -0
  38. package/dist/cost-heal.js +27 -0
  39. package/dist/dial-relay.d.ts +6 -2
  40. package/dist/dial-relay.js +9 -12
  41. package/dist/email/routes.js +2 -1
  42. package/dist/errors.d.ts +2 -0
  43. package/dist/errors.js +5 -0
  44. package/dist/exa-keyless.d.ts +1 -1
  45. package/dist/exa-keyless.js +1 -1
  46. package/dist/faux-computers.d.ts +2 -3
  47. package/dist/faux-computers.js +9 -31
  48. package/dist/github-connection.js +2 -1
  49. package/dist/harness-archive.d.ts +19 -2
  50. package/dist/harness-archive.js +49 -15
  51. package/dist/harness-check.d.ts +73 -0
  52. package/dist/harness-check.js +489 -0
  53. package/dist/harness-cursor.d.ts +45 -0
  54. package/dist/harness-cursor.js +121 -0
  55. package/dist/harness-recipe.d.ts +127 -0
  56. package/dist/harness-recipe.js +357 -0
  57. package/dist/harness-table.d.ts +12 -0
  58. package/dist/harness-table.js +62 -2
  59. package/dist/harness.d.ts +2 -0
  60. package/dist/harness.js +3 -2
  61. package/dist/host-check.d.ts +6 -0
  62. package/dist/host-check.js +14 -0
  63. package/dist/host.d.ts +10 -3
  64. package/dist/host.js +17 -3
  65. package/dist/import-sources.d.ts +2 -0
  66. package/dist/import-sources.js +2 -0
  67. package/dist/import-summary.d.ts +15 -5
  68. package/dist/import-summary.js +24 -8
  69. package/dist/import.d.ts +24 -4
  70. package/dist/import.js +108 -26
  71. package/dist/key-refusal.d.ts +1 -0
  72. package/dist/key-refusal.js +8 -3
  73. package/dist/key-words.d.ts +1 -1
  74. package/dist/key-words.js +4 -4
  75. package/dist/learn/check.d.ts +3 -0
  76. package/dist/learn/check.js +31 -20
  77. package/dist/learn/compile.js +12 -5
  78. package/dist/learn/promote.d.ts +69 -2
  79. package/dist/learn/promote.js +95 -3
  80. package/dist/learned-nodes.d.ts +4 -3
  81. package/dist/learned-workflow.js +4 -1
  82. package/dist/learning-cost.d.ts +6 -16
  83. package/dist/learning-cost.js +6 -12
  84. package/dist/learning-words.d.ts +2 -0
  85. package/dist/learning-words.js +1 -1
  86. package/dist/listen-first.d.ts +10 -0
  87. package/dist/listen-first.js +25 -1
  88. package/dist/llms.txt +1 -1
  89. package/dist/mcp-gateway.d.ts +2 -1
  90. package/dist/mcp-gateway.js +31 -15
  91. package/dist/mcp-probe.d.ts +18 -6
  92. package/dist/mcp-probe.js +41 -8
  93. package/dist/mcp-secret-writes.d.ts +8 -0
  94. package/dist/mcp-secret-writes.js +104 -4
  95. package/dist/mcp-servers-store.d.ts +11 -5
  96. package/dist/mcp-servers-store.js +46 -20
  97. package/dist/model-form.d.ts +2 -1
  98. package/dist/model-form.js +22 -8
  99. package/dist/model-gateway.d.ts +113 -0
  100. package/dist/model-gateway.js +433 -0
  101. package/dist/model.d.ts +2 -1
  102. package/dist/model.js +9 -7
  103. package/dist/monid.js +1 -1
  104. package/dist/native/binding.d.ts +4 -0
  105. package/dist/native/binding.js +9 -0
  106. package/dist/native/cli.d.ts +3 -2
  107. package/dist/native/cli.js +6 -5
  108. package/dist/openapi.d.ts +2 -0
  109. package/dist/openapi.js +322 -39
  110. package/dist/owner.d.ts +4 -2
  111. package/dist/owner.js +10 -4
  112. package/dist/page.d.ts +8 -0
  113. package/dist/page.js +9 -1
  114. package/dist/port-models.js +17 -10
  115. package/dist/provider.d.ts +3 -3
  116. package/dist/provider.js +12 -3
  117. package/dist/public-address.d.ts +28 -0
  118. package/dist/public-address.js +62 -0
  119. package/dist/run-launch.d.ts +1 -1
  120. package/dist/run-launch.js +1 -1
  121. package/dist/run-secrets.d.ts +3 -2
  122. package/dist/run-secrets.js +6 -4
  123. package/dist/runner/adapter-loop.d.ts +10 -7
  124. package/dist/runner/adapter-loop.js +57 -22
  125. package/dist/runner/adapter-run-spec.d.ts +12 -0
  126. package/dist/runner/adapter-run-spec.js +40 -6
  127. package/dist/runner/adapters/index.js +16 -0
  128. package/dist/runner/adapters/pi.d.ts +5 -2
  129. package/dist/runner/adapters/pi.js +7 -4
  130. package/dist/runner/audit.d.ts +7 -0
  131. package/dist/runner/audit.js +15 -6
  132. package/dist/runner/claim-secrets.js +5 -1
  133. package/dist/runner/cli-run-spec.js +15 -7
  134. package/dist/runner/compare-end.d.ts +43 -0
  135. package/dist/runner/compare-end.js +95 -0
  136. package/dist/runner/computer-journal.d.ts +3 -0
  137. package/dist/runner/computer-journal.js +22 -2
  138. package/dist/runner/harness-loops.d.ts +6 -1
  139. package/dist/runner/harness-loops.js +94 -54
  140. package/dist/runner/held.d.ts +5 -4
  141. package/dist/runner/journal-kinds.d.ts +4 -1
  142. package/dist/runner/journal-kinds.js +3 -0
  143. package/dist/runner/loop-contract.d.ts +10 -0
  144. package/dist/runner/main.d.ts +5 -5
  145. package/dist/runner/main.js +62 -11
  146. package/dist/runner/mcp-claim.js +40 -12
  147. package/dist/runner/metrics.d.ts +26 -0
  148. package/dist/runner/metrics.js +44 -1
  149. package/dist/runner/presence.d.ts +41 -0
  150. package/dist/runner/presence.js +89 -0
  151. package/dist/runner/promotion.d.ts +9 -4
  152. package/dist/runner/promotion.js +33 -14
  153. package/dist/runner/run-child-host.js +40 -10
  154. package/dist/runner/runner.d.ts +5 -0
  155. package/dist/runner/runner.js +8 -0
  156. package/dist/runner/store-port.d.ts +3 -0
  157. package/dist/runner/store-secrets.js +19 -7
  158. package/dist/runner/workflow-first.d.ts +5 -2
  159. package/dist/runner/workflow-first.js +6 -3
  160. package/dist/runs-over-store.d.ts +6 -2
  161. package/dist/runs-over-store.js +14 -4
  162. package/dist/sdk/runs.d.ts +1 -1
  163. package/dist/sdk/runs.js +6 -1
  164. package/dist/sdk/schema.js +1 -1
  165. package/dist/secret-writes.d.ts +16 -3
  166. package/dist/secret-writes.js +28 -3
  167. package/dist/server-secrets-store.js +5 -0
  168. package/dist/server.d.ts +31 -2
  169. package/dist/server.js +322 -51
  170. package/dist/sign-ins-secrets.js +4 -1
  171. package/dist/skills/agentrun-serve/SKILL.md +11 -0
  172. package/dist/slack-url.d.ts +5 -0
  173. package/dist/slack-url.js +11 -0
  174. package/dist/slack.d.ts +107 -0
  175. package/dist/slack.js +292 -0
  176. package/dist/start-switches.d.ts +28 -0
  177. package/dist/start-switches.js +37 -0
  178. package/dist/stats.d.ts +1 -1
  179. package/dist/stats.js +2 -1
  180. package/dist/stop-signals.d.ts +11 -0
  181. package/dist/stop-signals.js +22 -0
  182. package/dist/store/agent-body.d.ts +1 -1
  183. package/dist/store/agent-body.js +2 -2
  184. package/dist/store/index.d.ts +3 -3
  185. package/dist/store/index.js +1 -1
  186. package/dist/store/postgres/migrations/0020_runners.sql +18 -0
  187. package/dist/store/postgres/store.d.ts +1 -1
  188. package/dist/store/postgres/store.js +4 -2
  189. package/dist/store/schema.d.ts +13 -5
  190. package/dist/store/schema.js +20 -11
  191. package/dist/store/seal.d.ts +16 -4
  192. package/dist/store/sqlite/store.d.ts +1 -1
  193. package/dist/store/sqlite/store.js +106 -27
  194. package/dist/store/store.d.ts +75 -23
  195. package/dist/store/store.js +11 -0
  196. package/dist/store-reads/analytics.js +3 -2
  197. package/dist/store-reads/cap.d.ts +7 -0
  198. package/dist/store-reads/cap.js +11 -1
  199. package/dist/store-reads/journal.js +27 -1
  200. package/dist/store-reads/learning.d.ts +23 -2
  201. package/dist/store-reads/learning.js +29 -8
  202. package/dist/store-reads/runs.d.ts +9 -0
  203. package/dist/store-reads/runs.js +19 -6
  204. package/dist/store-reads/stats.d.ts +4 -1
  205. package/dist/store-reads/stats.js +15 -6
  206. package/dist/store-view.d.ts +123 -14
  207. package/dist/store-view.js +154 -21
  208. package/dist/telemetry.d.ts +7 -7
  209. package/dist/telemetry.js +38 -15
  210. package/dist/timeline/timeline.js +18 -0
  211. package/dist/tool-keys-store.js +2 -2
  212. package/dist/tool-keys.js +2 -1
  213. package/dist/tool-plane.js +2 -2
  214. package/dist/trigger-adapter.d.ts +3 -4
  215. package/dist/trigger-adapter.js +2 -2
  216. package/dist/trigger-composio.js +3 -3
  217. package/dist/trigger-email.js +0 -2
  218. package/dist/trigger-feed.js +0 -2
  219. package/dist/trigger-schedule.js +3 -0
  220. package/dist/trigger-secrets-shown.d.ts +6 -3
  221. package/dist/trigger-secrets-shown.js +22 -13
  222. package/dist/trigger-targets.d.ts +1 -1
  223. package/dist/trigger-targets.js +19 -8
  224. package/dist/triggers.d.ts +2 -2
  225. package/dist/webhooks.d.ts +82 -8
  226. package/dist/webhooks.js +128 -45
  227. package/dist/wires.d.ts +6 -1
  228. package/dist/wires.js +5 -0
  229. package/dist/workspace/attach.d.ts +3 -2
  230. package/dist/workspace/attach.js +2 -1
  231. package/dist/workspace/attached-computers.d.ts +6 -8
  232. package/dist/workspace/attached-computers.js +27 -24
  233. package/dist/workspace/computer-deps.d.ts +2 -3
  234. package/dist/workspace/computer-deps.js +3 -6
  235. package/dist/workspace/computer-for-claim.js +72 -96
  236. package/dist/workspace/computer-kept.d.ts +0 -7
  237. package/dist/workspace/computer-kept.js +0 -17
  238. package/dist/workspace/resolve-computer.d.ts +18 -14
  239. package/dist/workspace/resolve-computer.js +47 -60
  240. package/dist/workspace/synced-folder.d.ts +20 -15
  241. package/dist/workspace/synced-folder.js +33 -43
  242. package/launcher/agentrun-serve +4 -1
  243. package/package.json +10 -10
  244. package/skills/agentrun-serve/SKILL.md +11 -0
  245. package/templates/README.md +1 -1
  246. package/dist/console/assets/index-C2MYaUBa.css +0 -1
  247. package/dist/console/assets/index-CZZeCReB.js +0 -701
@@ -3,7 +3,7 @@ import type { RunLaunch } from "../run-launch.js";
3
3
  import { COST_WINDOW, type RunPath } from "../learning-cost.js";
4
4
  export { COST_WINDOW };
5
5
  import { type LoopRow } from "../learned-nodes.js";
6
- import { type CostStop } from "../learn/promote.js";
6
+ import { type Compared, type CostStop } from "../learn/promote.js";
7
7
  import type { Skipped } from "../learn/replay-calls.js";
8
8
  /** The root entry a run served workflow-first keeps, once the workflow's call ended: which workflow, at which learned
9
9
  * revision, under which call, and how it ended. A later claim that finds it never runs the workflow again. */
@@ -187,13 +187,16 @@ export declare function pathMetrics(launch: RunLaunch, classified: {
187
187
  not_auditable?: true;
188
188
  loops?: LoopRow[];
189
189
  replay?: ReplayMetrics;
190
- audit?: NonNullable<RunLaunch["audit"]>;
190
+ audit?: NonNullable<RunLaunch["audit"]> & {
191
+ readonly compared?: Compared;
192
+ };
191
193
  };
192
194
  /** A replay run's record (metrics.replay): the graded run it replayed and how its workflow ended there. */
193
195
  export type ReplayMetrics = {
194
196
  readonly of: string;
195
197
  readonly outcome: ReplayOutcome;
196
198
  readonly skipped?: Skipped;
199
+ readonly compared?: Compared;
197
200
  };
198
201
  /** How a replay run's workflow ended on its input: `skipped_write`, stopped at a write the graded run's recording does not
199
202
  * have (learn/replay-calls.ts SKIPPED_WRITE), never run. */
@@ -32,7 +32,7 @@ export { COST_WINDOW };
32
32
  import { KINDS } from "./journal-kinds.js";
33
33
  import { inputIssues, isObject } from "../validate.js";
34
34
  import { endedIn, loopsOf, replaySkippedIn } from "../learned-nodes.js";
35
- import { sameAnswer } from "../learn/promote.js";
35
+ import { comparedOf, sameAnswer } from "../learn/promote.js";
36
36
  /** The root entry a run served workflow-first keeps, once the workflow's call ended: which workflow, at which learned
37
37
  * revision, under which call, and how it ended. A later claim that finds it never runs the workflow again. */
38
38
  export const WORKFLOW_FIRST = "agentrun.workflow_first";
@@ -231,9 +231,12 @@ export function servedOf(entries) {
231
231
  * each loop's exit (`loops`, loopsOf: a quote re-pick is a loop's second pass), when one ran. learning-cost reads path
232
232
  * and workflow from here. None for a run that does not learn. */
233
233
  export function pathMetrics(launch, classified, entries = []) {
234
+ // The grader's verdict its end-of-run step kept (runner/compare-end.ts), for a replay run and a shadow.
235
+ const compared = comparedOf(entries.findLast((entry) => entry.kind === KINDS.compared)?.data);
236
+ const verdict = compared ? { compared } : {};
234
237
  // A shadow run (runner/audit.ts): path `audit` and the run it audits, whatever it did: no learning, no money rule.
235
238
  if (launch.audit)
236
- return { path: "audit", audit: { of: launch.audit.of, workflow: launch.audit.workflow, digest: launch.audit.digest } };
239
+ return { path: "audit", audit: { of: launch.audit.of, workflow: launch.audit.workflow, digest: launch.audit.digest, ...verdict } };
237
240
  if (!launch.learning)
238
241
  return {};
239
242
  const { path, workflow, digest, promotion } = classified ?? { path: "agent", workflow: null };
@@ -249,7 +252,7 @@ export function pathMetrics(launch, classified, entries = []) {
249
252
  // evidence. Skipped when a write it needed is not in the graded run's recording (learn/replay-calls.ts): never run.
250
253
  const skipped = replaySkippedIn(entries);
251
254
  const outcome = skipped ? "skipped_write" : path === "workflow" && workflow === name ? "answered" : path === "handed_back" && workflow === name && endedIn(entries, name) === "escalated" ? "handed_back" : "failed";
252
- return { path: "replay", ...(launch.learning.seed ? { learned_revision: launch.learning.seed } : {}), workflow: name, workflow_digest: at, ...rows, replay: { of, outcome, ...(skipped ? { skipped } : {}) } };
255
+ return { path: "replay", ...(launch.learning.seed ? { learned_revision: launch.learning.seed } : {}), workflow: name, workflow_digest: at, ...rows, replay: { of, outcome, ...(skipped ? { skipped } : {}), ...verdict } };
253
256
  }
254
257
  // A served run a trigger started (learn/audit.ts auditableLaunch) is never audited: counted on the promotions read.
255
258
  const notAuditable = SERVED_PATHS.includes(path) && !auditableLaunch(launch);
@@ -51,8 +51,9 @@ export type MessageMode = "steer" | "answer" | "follow_up";
51
51
  * run's state. `answers: false` is a trigger's message, which never answers a person: refused while the run waits on one,
52
52
  * and never a deny of an approval. The mode is the label the v2 answer reports, from the run's moment. `queue`: the steer's
53
53
  * write when it is not this run's own (a trigger's: its firing marked with it, within its bound, store.triggers.message),
54
- * which may skip it, in words. */
55
- export declare function message(store: RunsStore & Pick<Store, "agents">, moment: RunMoment, content: string, { requestId, answers, origin, queue, launchSealed, beforeSubmit }?: {
54
+ * which may skip it, in words. A runner applies every message, so while every runner here refused to claim, any message
55
+ * (a person's or a trigger's) is refused in their words first, as a start is (prepareLaunch, runner/presence.ts). */
56
+ export declare function message(store: RunsStore & Pick<Store, "agents" | "runners">, moment: RunMoment, content: string, { requestId, answers, origin, queue, launchSealed, beforeSubmit }?: {
56
57
  requestId?: string;
57
58
  answers?: boolean;
58
59
  origin?: unknown;
@@ -105,6 +106,9 @@ type StartBody = {
105
106
  export interface StartDeps {
106
107
  /** A new run id; defaults to a UUIDv7. */
107
108
  readonly newRunId?: () => string;
109
+ /** Why no runner here can take a run, in their words, while every runner there refused to claim (runner/presence.ts
110
+ * runnersRefused); undefined while one can, or none is there yet. A start is refused with it (runner_refused). */
111
+ runnersRefused?(): Promise<string | undefined>;
108
112
  /** The create body's field issues, before the agent is read (server.ts runBodyIssues). */
109
113
  runBodyIssues(body: Json): InputIssue[];
110
114
  /** The revision a run starts on (server.ts pinnedOf): the body's pin, else the agent's current; undefined when none. */
@@ -1,4 +1,4 @@
1
- import { nativeOf } from "./native/binding.js";
1
+ import { NATIVE_RUN_OVERRIDES_UNSUPPORTED, nativeOf, nativeRunOverrides } from "./native/binding.js";
2
2
  import { launchNative } from "./native/connection.js";
3
3
  // The write half of the run's server cut (design 2.1, "the runner takes every run"): the functions the v2 routes call to
4
4
  // start a run and to act on one (message, stop, raise, approve, archive), over the one store (A). The old per-run-process
@@ -29,6 +29,7 @@ import { launchBody } from "./run-launch.js";
29
29
  import { modelKeyRequired, serverKeyMissing } from "./run-model-key.js";
30
30
  import { raiseFollowUpId } from "./run-view.js";
31
31
  import { sendCommand } from "./runner/commands.js";
32
+ import { runnersRefused } from "./runner/presence.js";
32
33
  import { AgentDeleting, AnswerTaken, ExternalBodyConflict, RunFinal, StoreConstraint, StoreLaunchMissing } from "./store/index.js";
33
34
  import { canonical } from "./store/agent-body.js";
34
35
  import { toolingOf } from "./tools.js";
@@ -154,8 +155,12 @@ export const resume = (store, moment) => pauseOrResume(store, moment, false);
154
155
  * run's state. `answers: false` is a trigger's message, which never answers a person: refused while the run waits on one,
155
156
  * and never a deny of an approval. The mode is the label the v2 answer reports, from the run's moment. `queue`: the steer's
156
157
  * write when it is not this run's own (a trigger's: its firing marked with it, within its bound, store.triggers.message),
157
- * which may skip it, in words. */
158
+ * which may skip it, in words. A runner applies every message, so while every runner here refused to claim, any message
159
+ * (a person's or a trigger's) is refused in their words first, as a start is (prepareLaunch, runner/presence.ts). */
158
160
  export async function message(store, moment, content, { requestId, answers = true, origin, queue, launchSealed, beforeSubmit } = {}) {
161
+ const refused = await runnersRefused(store.runners);
162
+ if (refused !== undefined)
163
+ throw new ApiError("runner_refused", refused);
159
164
  if (moment.importedSource !== undefined)
160
165
  throw importedRefusal(moment);
161
166
  const launchBody = await controlLaunchBody(store, moment.id);
@@ -562,8 +567,8 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
562
567
  const native = nativeOf(revision.body);
563
568
  if (native && !nativeOf(entry.revision?.body)?.connected)
564
569
  throw new ApiError("agent_not_runnable", "This native connection is disconnected. Reconnect its source project before starting any revision.");
565
- if (native && (body.effort !== undefined || fileIds.length || body.archil_disk !== undefined))
566
- throw new ApiError("input_invalid", "Native jobs use their original effort and project files. Run effort overrides, uploaded file_ids and Archil disks are unavailable; edit the native configuration or source project instead.");
570
+ if (native && nativeRunOverrides(body).length)
571
+ throw new ApiError("input_invalid", NATIVE_RUN_OVERRIDES_UNSUPPORTED);
567
572
  if (fileIds.length)
568
573
  await deps.readyFiles(fileIds);
569
574
  const rbody = revision.body;
@@ -575,6 +580,11 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
575
580
  const cap = typeof body.max_cost_usd === "number" ? body.max_cost_usd : rbody.maxCostUsd;
576
581
  if (capped && cap === undefined)
577
582
  throw invalid([{ field: "max_cost_usd", reason: "missing", message: "Every run a trigger starts is capped: give the trigger's target a max_cost_usd or set the agent's." }]);
583
+ // A run no runner here can claim is never taken to wait for good: refused in the runners' words, once the request reads
584
+ // right and before anything is pinned or made for it (runner/presence.ts).
585
+ const refused = await deps.runnersRefused?.();
586
+ if (refused !== undefined)
587
+ throw new ApiError("runner_refused", refused);
578
588
  const place = resolvePlace(rbody.place, deps.fallbackPlace(revision.kind, revision.kind === "agentic" ? (rbody.tools ?? []) : []));
579
589
  // Checked as pinned: an earlier revision with no pin is pinned now, once (StartDeps.pinFirst); one that could not be, as
580
590
  // its server could not be listed, is refused with the rest (runnable).
@@ -2,7 +2,7 @@ import type { Claim, RunOrigin, Store } from "../store/store.js";
2
2
  import type { AgentEntry } from "../agents-store.js";
3
3
  import { type StartDeps } from "../runs-over-store.js";
4
4
  import { type LearnedWorkflow } from "../learning.js";
5
- export type SdkRuntime = "claude-agent-sdk" | "codex-sdk";
5
+ export type SdkRuntime = "claude-agent-sdk" | "codex-sdk" | "eve";
6
6
  export type SdkUsage = {
7
7
  input_tokens: number | null;
8
8
  output_tokens: number | null;
package/dist/sdk/runs.js CHANGED
@@ -47,7 +47,7 @@ const usageOf = (value) => {
47
47
  }
48
48
  return result;
49
49
  };
50
- export const sdkOf = (body) => isObject(body) && isObject(body.sdk) && (body.sdk.runtime === "claude-agent-sdk" || body.sdk.runtime === "codex-sdk")
50
+ export const sdkOf = (body) => isObject(body) && isObject(body.sdk) && (body.sdk.runtime === "claude-agent-sdk" || body.sdk.runtime === "codex-sdk" || body.sdk.runtime === "eve")
51
51
  ? { runtime: body.sdk.runtime }
52
52
  : undefined;
53
53
  export async function sdkInbox(store, runId) {
@@ -187,6 +187,11 @@ export class SdkRuns {
187
187
  const revisionBody = entry.revision.body;
188
188
  if (revisionBody.maxCostUsd !== undefined)
189
189
  throw new ApiError("agent_not_runnable", "AgentRun cannot enforce a spend cap on an external SDK. Configure the budget in the backend SDK and remove this managed run cap.");
190
+ // A runner keeps an SDK run's evidence and ends it: while every runner here refused to claim, the start is refused in
191
+ // their words, as any start is (prepareLaunch), before the caller holds a receipt it would run on.
192
+ const refused = await deps.runnersRefused?.();
193
+ if (refused !== undefined)
194
+ throw new ApiError("runner_refused", refused);
190
195
  const learning = await learningStartFor(deps, entry, pinned.revision, revisionBody, {
191
196
  noWorkflows: !workflow,
192
197
  ...(compile.model ? { model: compile.model } : {}),
@@ -6,7 +6,7 @@ const object = (properties, required = Object.keys(properties)) => ({
6
6
  properties,
7
7
  required,
8
8
  });
9
- export const SDK_BINDING = object({ runtime: { enum: ["claude-agent-sdk", "codex-sdk"] } });
9
+ export const SDK_BINDING = object({ runtime: { enum: ["claude-agent-sdk", "codex-sdk", "eve"] } });
10
10
  const usage = object(Object.fromEntries(["input_tokens", "output_tokens", "cache_read_tokens", "cache_write_tokens", "cost_usd"].map((key) => [
11
11
  key,
12
12
  { type: [key === "cost_usd" ? "number" : "integer", "null"], minimum: 0 },
@@ -1,6 +1,9 @@
1
1
  import type { IncomingMessage } from "node:http";
2
2
  /** The one refusal a secret write from anything but the owner's session gets (403 forbidden). */
3
3
  export declare const SECRET_WRITE_REFUSAL = "Saving, replacing or removing a secret takes the owner's signed-in session in the console; the API token can't write secrets.";
4
+ /** The refusal's words with where to finish it: the one sentence, then "Finish it in the console: <link>" when the
5
+ * operation has a console page (registerSecretPage). The same link is the error's `details.console_url`. */
6
+ export declare const secretWriteRefusal: (link?: string) => string;
4
7
  /**
5
8
  * Whether the console a launcher opened on a loopback-bound server with no accounts (no password: the browser that
6
9
  * followed the launch link, `/?launch=<code>`, its cookie a session id made at random and kept by the server, never
@@ -89,13 +92,23 @@ export declare const writesSecret: (operationId: string, body: unknown) => boole
89
92
  /** Whether this request of `operationId` writes a secret: by its body, or by what it would drop or replace in the store
90
93
  * (its plane's stored predicate). The dispatch's one check asks this. */
91
94
  export declare function writesSecretFor(operationId: string, body: unknown, request: SecretRequest): Promise<boolean>;
95
+ /** An operation's console page: a fixed path, or one built from the request's non-secret fields. */
96
+ export type SecretPage = string | ((body: unknown, request: SecretRequest) => string | Promise<string>);
97
+ /** Where in the console the owner finishes `operationIds` (each a registered secret write). */
98
+ export declare function registerSecretPage(operationIds: string | readonly string[], page: SecretPage): void;
99
+ /** Whether `operationId` names its console page. */
100
+ export declare const hasSecretPage: (operationId: string) => boolean;
101
+ /** The console page that finishes this request of `operationId`, a path from the console's root; undefined when the
102
+ * console has none for it, or the page could not be built (then the refusal carries no link). */
103
+ export declare function secretPageFor(operationId: string, body: unknown, request: SecretRequest): Promise<string | undefined>;
92
104
  type Json = Record<string, unknown>;
93
105
  /** The operations of `doc` that write a secret: their request body marks a field `x-agentrun-secret`, or the operation is
94
106
  * marked whole (a removal, which has no body). The generated CLI leaves every one of them out. */
95
107
  export declare function markedOperations(doc: Json): string[];
96
- /** The marked operations of `doc` no plane registered a predicate for (`registered`): each a route a secret could take
97
- * past the dispatch check. Empty is the only passing answer. */
98
- export declare const unguardedOperations: (doc: Json, registered: readonly string[]) => string[];
108
+ /** The marked operations of `doc` no plane registered a predicate for nor said on purpose to write no secret
109
+ * (registerNotSecretWrite: a preview's marked fields are kept nowhere): each a route a secret could take past the
110
+ * dispatch check. Empty is the only passing answer. */
111
+ export declare const unguardedOperations: (doc: Json) => string[];
99
112
  /** Where a secret came from: the environment the server starts with (which always wins, by the same name), pasted in the
100
113
  * console, or obtained by a sign-in (OAuth, Connect); null when it is not set. */
101
114
  export type SecretSource = "env" | "console" | "sign-in";
@@ -1,6 +1,9 @@
1
1
  import { byConsoleSession, byOwnerSession } from "./page.js";
2
2
  /** The one refusal a secret write from anything but the owner's session gets (403 forbidden). */
3
3
  export const SECRET_WRITE_REFUSAL = "Saving, replacing or removing a secret takes the owner's signed-in session in the console; the API token can't write secrets.";
4
+ /** The refusal's words with where to finish it: the one sentence, then "Finish it in the console: <link>" when the
5
+ * operation has a console page (registerSecretPage). The same link is the error's `details.console_url`. */
6
+ export const secretWriteRefusal = (link) => (link ? `${SECRET_WRITE_REFUSAL} Finish it in the console: ${link}` : SECRET_WRITE_REFUSAL);
4
7
  // ---- who may write a secret ------------------------------------------------------------------------------------------
5
8
  /**
6
9
  * Whether the console a launcher opened on a loopback-bound server with no accounts (no password: the browser that
@@ -77,6 +80,27 @@ export async function writesSecretFor(operationId, body, request) {
77
80
  const stored = storedPredicates.get(operationId);
78
81
  return stored ? (await stored(body, request)) === true : false;
79
82
  }
83
+ const pages = new Map();
84
+ /** Where in the console the owner finishes `operationIds` (each a registered secret write). */
85
+ export function registerSecretPage(operationIds, page) {
86
+ for (const operationId of typeof operationIds === "string" ? [operationIds] : operationIds)
87
+ pages.set(operationId, page);
88
+ }
89
+ /** Whether `operationId` names its console page. */
90
+ export const hasSecretPage = (operationId) => pages.has(operationId);
91
+ /** The console page that finishes this request of `operationId`, a path from the console's root; undefined when the
92
+ * console has none for it, or the page could not be built (then the refusal carries no link). */
93
+ export async function secretPageFor(operationId, body, request) {
94
+ const page = pages.get(operationId);
95
+ if (typeof page !== "function")
96
+ return page;
97
+ try {
98
+ return await page(body, request);
99
+ }
100
+ catch {
101
+ return undefined;
102
+ }
103
+ }
80
104
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
81
105
  /** Whether `schema` (in `doc`, its $refs followed once each) marks any field `x-agentrun-secret: true`. */
82
106
  function marksSecret(doc, schema, seen = new Set()) {
@@ -113,9 +137,10 @@ export function markedOperations(doc) {
113
137
  }
114
138
  return out;
115
139
  }
116
- /** The marked operations of `doc` no plane registered a predicate for (`registered`): each a route a secret could take
117
- * past the dispatch check. Empty is the only passing answer. */
118
- export const unguardedOperations = (doc, registered) => markedOperations(doc).filter((operationId) => !registered.includes(operationId));
140
+ /** The marked operations of `doc` no plane registered a predicate for nor said on purpose to write no secret
141
+ * (registerNotSecretWrite: a preview's marked fields are kept nowhere): each a route a secret could take past the
142
+ * dispatch check. Empty is the only passing answer. */
143
+ export const unguardedOperations = (doc) => markedOperations(doc).filter((operationId) => !registry.has(operationId) && notSecretWriteReason(operationId) === undefined);
119
144
  /** A secret's name, "<plane>:<id>": the plane and each part of its id joined with ":" (secretName("computer", provider,
120
145
  * KEY) is "computer:<provider>:<KEY>", secretName("workspace", "archil") "workspace:archil"). */
121
146
  export function secretName(plane, ...id) {
@@ -6,6 +6,7 @@
6
6
  import { sealedSettingsOverStore } from "./sealed-settings-store.js";
7
7
  import { besideTheStore } from "./server-secrets.js";
8
8
  import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
9
+ import { SLACK_CHANNEL, SLACK_URL_SPEC, slackUrlForms } from "./slack.js";
9
10
  import { WEBHOOK_CHANNEL, WEBHOOK_SECRET_SPEC } from "./webhooks.js";
10
11
  /** The server's own secrets over the store: what it keeps beside the store (besideTheStore), the outbound webhook's
11
12
  * signing secret and each one it held before (adapter webhook-out, retired ones too, so a secret replaced or removed stays
@@ -23,6 +24,10 @@ export async function openServerSecretsOverStore(store, data, env, adapters, say
23
24
  const webhookSettings = sealedSettingsOverStore(store, WEBHOOK_CHANNEL, WEBHOOK_SECRET_SPEC, key, (fields) => fields.condition === "trigger_setting_unopened" ? say({ condition: "unreadable", name: SEAL_KEY_ENV, data, effect: "this server's webhook secret cannot be read under this seal key, so it is not cut" }) : say(fields));
24
25
  await webhookSettings.load();
25
26
  secrets.add("webhook", () => webhookSettings.values());
27
+ // Slack's incoming-webhook URL, and each it held before (slack.ts): the URL is the credential, cut as a secret is.
28
+ const slackSettings = sealedSettingsOverStore(store, SLACK_CHANNEL, SLACK_URL_SPEC, key, (fields) => fields.condition === "trigger_setting_unopened" ? say({ condition: "unreadable", name: SEAL_KEY_ENV, data, effect: "this server's Slack URL cannot be read under this seal key, so it is not cut" }) : say(fields));
29
+ await slackSettings.load();
30
+ secrets.add("slack", () => slackSettings.values().flatMap(slackUrlForms));
26
31
  const settings = new Map();
27
32
  for (const adapter of adapters) {
28
33
  if (!adapter.settings)
package/dist/server.d.ts CHANGED
@@ -232,6 +232,9 @@ export type ServeOptions = {
232
232
  * (webhooks.ts), in place of the system resolver's. A test's server answers its example hosts here, so no CI
233
233
  * runner's resolver decides what a test sees. */
234
234
  webhookLookup?: (host: string) => Promise<string[]>;
235
+ /** A test's seam: the origin Slack's messages are posted to in place of https://hooks.slack.com, each URL's path kept
236
+ * (slack.ts sendTo), so no test reaches Slack. */
237
+ slackTarget?: string;
235
238
  };
236
239
  /** The switches a run's process gets, each module path resolved: the owner's harness modules (harnessModules), and the test
237
240
  * switches, which are empty outside tests. A test's in-process runner takes the same (test/support.mjs
@@ -281,6 +284,10 @@ export type Serve = {
281
284
  };
282
285
  /** Resolves once every run's listing is current (run-listing.ts Lister.settled): for tests and benchmarks. */
283
286
  listingSettled(): Promise<void>;
287
+ /** Says in the store, until the stop, that the runner beside this server refused to claim any run, in `words` (its run
288
+ * isolation refused, cli.ts): while no runner that claims is there, a start is refused in them and the runs queued
289
+ * fail (runner/presence.ts). Once; a second call keeps the first. */
290
+ refuseRuns(words: string): void;
284
291
  };
285
292
  /** A route: `name` is its operationId in the OpenAPI document (openapi.ts); `capability`, when this server turns it off;
286
293
  * `raw`, a route whose body is bytes and not JSON, which the page's session may send with any content type, still only
@@ -345,6 +352,7 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
345
352
  reason?: string;
346
353
  default_model: string | null;
347
354
  installs?: "on_first_use";
355
+ card?: string;
348
356
  models: string[];
349
357
  free_models: {
350
358
  id: string;
@@ -458,6 +466,9 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
458
466
  available: boolean;
459
467
  harnesses: string[];
460
468
  })[];
469
+ /** The switches only the operator sets, in the server's environment at its start (start-switches.ts): each one's state,
470
+ * the value it read and what it allows. Never a secret's value. */
471
+ switches: Record<string, import("./start-switches.js").StartSwitch>;
461
472
  /** How this server holds its secrets (secrets.ts, the launcher), and what that does not cover. */
462
473
  secrets: {
463
474
  names: string[];
@@ -469,7 +480,7 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
469
480
  * `models.default`, `models.strong`) with the tools it names of `node_tools`; a node that names no thinking level
470
481
  * thinks at the run's effort, or medium. */
471
482
  workflows: {
472
- nodes: ("agent" | "extract" | "decide" | "report")[];
483
+ nodes: ("agent" | "report" | "extract" | "decide")[];
473
484
  node_tools: string[];
474
485
  adapters: string[];
475
486
  decisions: {
@@ -582,6 +593,13 @@ export declare function readingOf(base: NodeJS.ProcessEnv, maxRuns: number, stor
582
593
  signing: string;
583
594
  at_rest: string;
584
595
  };
596
+ /** /settings/slack: one Slack incoming-webhook URL each of `events` is posted to as a readable message (slack.ts); the
597
+ * URL kept sealed, never shown. */
598
+ slack: {
599
+ routes: boolean;
600
+ events: ("run.needs_input" | "run.ended" | "trigger.failed")[];
601
+ at_rest: string;
602
+ };
585
603
  /** /triggers: what starts an agent's capped runs with no caller (triggers.ts). */
586
604
  triggers: {
587
605
  routes: boolean;
@@ -654,6 +672,7 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
654
672
  reason?: string;
655
673
  default_model: string | null;
656
674
  installs?: "on_first_use";
675
+ card?: string;
657
676
  models: string[];
658
677
  free_models: {
659
678
  id: string;
@@ -767,6 +786,9 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
767
786
  available: boolean;
768
787
  harnesses: string[];
769
788
  })[];
789
+ /** The switches only the operator sets, in the server's environment at its start (start-switches.ts): each one's state,
790
+ * the value it read and what it allows. Never a secret's value. */
791
+ switches: Record<string, import("./start-switches.js").StartSwitch>;
770
792
  /** How this server holds its secrets (secrets.ts, the launcher), and what that does not cover. */
771
793
  secrets: {
772
794
  names: string[];
@@ -778,7 +800,7 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
778
800
  * `models.default`, `models.strong`) with the tools it names of `node_tools`; a node that names no thinking level
779
801
  * thinks at the run's effort, or medium. */
780
802
  workflows: {
781
- nodes: ("agent" | "extract" | "decide" | "report")[];
803
+ nodes: ("agent" | "report" | "extract" | "decide")[];
782
804
  node_tools: string[];
783
805
  adapters: string[];
784
806
  decisions: {
@@ -891,6 +913,13 @@ export declare function capabilities(env?: NodeJS.ProcessEnv, maxRuns?: number,
891
913
  signing: string;
892
914
  at_rest: string;
893
915
  };
916
+ /** /settings/slack: one Slack incoming-webhook URL each of `events` is posted to as a readable message (slack.ts); the
917
+ * URL kept sealed, never shown. */
918
+ slack: {
919
+ routes: boolean;
920
+ events: ("run.needs_input" | "run.ended" | "trigger.failed")[];
921
+ at_rest: string;
922
+ };
894
923
  /** /triggers: what starts an agent's capped runs with no caller (triggers.ts). */
895
924
  triggers: {
896
925
  routes: boolean;