@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31

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 (172) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/README.md +739 -116
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +18 -7
  6. package/dist/agents.js +19 -10
  7. package/dist/app.js +101 -26
  8. package/dist/background.d.ts +29 -0
  9. package/dist/background.js +397 -0
  10. package/dist/box-egress-vm.d.ts +125 -0
  11. package/dist/box-egress-vm.js +350 -0
  12. package/dist/box-egress.d.ts +99 -0
  13. package/dist/box-egress.js +259 -0
  14. package/dist/box-image.d.ts +1 -1
  15. package/dist/box-image.js +9 -7
  16. package/dist/box-relay-vm.d.ts +84 -0
  17. package/dist/box-relay-vm.js +410 -0
  18. package/dist/box-relay.d.ts +8 -5
  19. package/dist/box-relay.js +14 -9
  20. package/dist/boxes.d.ts +28 -5
  21. package/dist/boxes.js +44 -18
  22. package/dist/browser-cost.d.ts +41 -0
  23. package/dist/browser-cost.js +158 -0
  24. package/dist/cap.d.ts +130 -21
  25. package/dist/cap.js +339 -67
  26. package/dist/cli.js +30 -4
  27. package/dist/coding-tools.d.ts +7 -3
  28. package/dist/coding-tools.js +16 -10
  29. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  30. package/dist/console/assets/index-CnJBf7Lc.js +486 -0
  31. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/content-filter.d.ts +7 -0
  34. package/dist/content-filter.js +23 -0
  35. package/dist/decision-rows.d.ts +11 -3
  36. package/dist/decision-rows.js +18 -11
  37. package/dist/decisions.d.ts +3 -3
  38. package/dist/decisions.js +4 -3
  39. package/dist/errors.d.ts +2 -0
  40. package/dist/errors.js +5 -2
  41. package/dist/files.d.ts +9 -1
  42. package/dist/files.js +10 -2
  43. package/dist/grade.d.ts +11 -11
  44. package/dist/grade.js +43 -55
  45. package/dist/graph-served.d.ts +23 -0
  46. package/dist/graph-served.js +75 -0
  47. package/dist/graph-view.d.ts +7 -5
  48. package/dist/graph-view.js +10 -3
  49. package/dist/harness-app.d.ts +4 -2
  50. package/dist/harness-app.js +110 -19
  51. package/dist/harness-opencode/adapter.d.ts +45 -0
  52. package/dist/harness-opencode/adapter.js +272 -0
  53. package/dist/harness-opencode/binary.d.ts +18 -0
  54. package/dist/harness-opencode/binary.js +87 -0
  55. package/dist/harness-opencode/config.d.ts +24 -0
  56. package/dist/harness-opencode/config.js +61 -0
  57. package/dist/harness-opencode/harness.d.ts +77 -0
  58. package/dist/harness-opencode/harness.js +620 -0
  59. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  60. package/dist/harness-opencode/host/mcp.js +208 -0
  61. package/dist/harness-opencode/host/policy.d.ts +71 -0
  62. package/dist/harness-opencode/host/policy.js +419 -0
  63. package/dist/harness-opencode/host/server.d.ts +55 -0
  64. package/dist/harness-opencode/host/server.js +165 -0
  65. package/dist/harness-opencode/index.d.ts +9 -0
  66. package/dist/harness-opencode/index.js +6 -0
  67. package/dist/harness-opencode/verify.d.ts +32 -0
  68. package/dist/harness-opencode/verify.js +75 -0
  69. package/dist/harness-opencode/versions.d.ts +33 -0
  70. package/dist/harness-opencode/versions.js +64 -0
  71. package/dist/harness.d.ts +4 -1
  72. package/dist/harness.js +5 -2
  73. package/dist/host-check.d.ts +12 -0
  74. package/dist/host-check.js +34 -0
  75. package/dist/host-tools.d.ts +12 -2
  76. package/dist/host-tools.js +26 -12
  77. package/dist/host.js +6 -2
  78. package/dist/hosted-search.js +5 -1
  79. package/dist/import.d.ts +2 -2
  80. package/dist/import.js +4 -3
  81. package/dist/key-check.d.ts +3 -2
  82. package/dist/key-check.js +7 -3
  83. package/dist/key-refusal.js +8 -4
  84. package/dist/key-words.d.ts +37 -0
  85. package/dist/key-words.js +40 -0
  86. package/dist/learn/check.d.ts +10 -1
  87. package/dist/learn/check.js +19 -1
  88. package/dist/learn/grade.d.ts +6 -2
  89. package/dist/learn/grade.js +28 -14
  90. package/dist/learn/index.d.ts +3 -3
  91. package/dist/learn/index.js +3 -3
  92. package/dist/learn/notes.js +2 -1
  93. package/dist/learn/reflect.d.ts +2 -2
  94. package/dist/learn/reflect.js +53 -5
  95. package/dist/learn/secrets.js +28 -8
  96. package/dist/learn/skills.d.ts +19 -4
  97. package/dist/learn/skills.js +95 -6
  98. package/dist/learned-workflow.d.ts +59 -0
  99. package/dist/learned-workflow.js +191 -0
  100. package/dist/learning-routes.d.ts +30 -1
  101. package/dist/learning-routes.js +173 -19
  102. package/dist/learning-run.d.ts +8 -6
  103. package/dist/learning-run.js +70 -27
  104. package/dist/learning-words.d.ts +12 -5
  105. package/dist/learning-words.js +34 -13
  106. package/dist/learning.d.ts +52 -3
  107. package/dist/learning.js +204 -4
  108. package/dist/mcp-gateway.d.ts +96 -0
  109. package/dist/mcp-gateway.js +408 -0
  110. package/dist/mcp-meta.d.ts +17 -0
  111. package/dist/mcp-meta.js +38 -0
  112. package/dist/mcp-servers.d.ts +33 -9
  113. package/dist/mcp-servers.js +58 -10
  114. package/dist/mcp.js +5 -5
  115. package/dist/model.d.ts +13 -11
  116. package/dist/model.js +11 -10
  117. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  118. package/dist/openapi.js +407 -54
  119. package/dist/page.d.ts +2 -0
  120. package/dist/page.js +3 -0
  121. package/dist/paid-calls.d.ts +5 -1
  122. package/dist/paid-calls.js +1 -1
  123. package/dist/pause.d.ts +2 -0
  124. package/dist/place.d.ts +29 -5
  125. package/dist/place.js +51 -11
  126. package/dist/print.d.ts +7 -0
  127. package/dist/print.js +13 -0
  128. package/dist/propose.d.ts +2 -0
  129. package/dist/propose.js +38 -8
  130. package/dist/request-start.d.ts +12 -4
  131. package/dist/request-start.js +139 -15
  132. package/dist/run-box.d.ts +56 -4
  133. package/dist/run-box.js +183 -23
  134. package/dist/runnable.d.ts +13 -3
  135. package/dist/runnable.js +63 -6
  136. package/dist/runs.d.ts +266 -37
  137. package/dist/runs.js +884 -90
  138. package/dist/secrets.d.ts +27 -0
  139. package/dist/secrets.js +38 -2
  140. package/dist/server.d.ts +141 -36
  141. package/dist/server.js +562 -118
  142. package/dist/sign-ins.d.ts +99 -0
  143. package/dist/sign-ins.js +288 -0
  144. package/dist/skills.d.ts +16 -4
  145. package/dist/skills.js +35 -7
  146. package/dist/stats.d.ts +7 -2
  147. package/dist/stats.js +28 -7
  148. package/dist/tool-gate.d.ts +281 -0
  149. package/dist/tool-gate.js +585 -0
  150. package/dist/tool-keys.d.ts +48 -11
  151. package/dist/tool-keys.js +46 -8
  152. package/dist/tool-plane.d.ts +116 -27
  153. package/dist/tool-plane.js +232 -50
  154. package/dist/tools.d.ts +69 -14
  155. package/dist/tools.js +148 -26
  156. package/dist/trigger-secrets.d.ts +32 -0
  157. package/dist/trigger-secrets.js +143 -0
  158. package/dist/triggers.d.ts +439 -0
  159. package/dist/triggers.js +863 -0
  160. package/dist/turn-end.d.ts +3 -2
  161. package/dist/turn-end.js +3 -2
  162. package/dist/usage-lines.d.ts +26 -0
  163. package/dist/usage-lines.js +28 -0
  164. package/dist/validate.d.ts +2 -0
  165. package/dist/validate.js +11 -2
  166. package/dist/web-fetch.js +3 -3
  167. package/dist/webhooks.d.ts +11 -4
  168. package/dist/webhooks.js +17 -1
  169. package/launcher/agentrun-serve +1 -1
  170. package/package.json +16 -14
  171. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  172. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -1,6 +1,7 @@
1
1
  /** `{ kind: TURN_END, data: TurnEndData }`: a turn of the session `key` is over. Written in the same commit as the turn's
2
- * last entries. #1424's first form held only `key` and `status`, and closes the message sent last before it. */
3
- export declare const TURN_END = "adapter.turn_end";
2
+ * last entries. #1424's first form held only `key` and `status`, and closes the message sent last before it. The
3
+ * timeline reads it too (the next message is not a steer), so the kind is the timeline's. */
4
+ export { TURN_END } from "@parcha/pi-durable-agent/timeline";
4
5
  /** The root's record of a message the door accepted (`{ key, id, content }`), and of its end (`{ key, id, sent }`):
5
6
  * `sent` to the session, or dropped by a stop. The bridge writes a TURN_END naming the message once its turn is over;
6
7
  * for a message an older bridge sent and wrote no end for, the run's next process writes it as it opens. */
package/dist/turn-end.js CHANGED
@@ -2,8 +2,9 @@
2
2
  // the root's records of the messages the turns take. Data entries: no model, so the timeline shows no row for them and
3
3
  // the meters do not count them.
4
4
  /** `{ kind: TURN_END, data: TurnEndData }`: a turn of the session `key` is over. Written in the same commit as the turn's
5
- * last entries. #1424's first form held only `key` and `status`, and closes the message sent last before it. */
6
- export const TURN_END = "adapter.turn_end";
5
+ * last entries. #1424's first form held only `key` and `status`, and closes the message sent last before it. The
6
+ * timeline reads it too (the next message is not a steer), so the kind is the timeline's. */
7
+ export { TURN_END } from "@parcha/pi-durable-agent/timeline";
7
8
  /** The root's record of a message the door accepted (`{ key, id, content }`), and of its end (`{ key, id, sent }`):
8
9
  * `sent` to the session, or dropped by a stop. The bridge writes a TURN_END naming the message once its turn is over;
9
10
  * for a message an older bridge sent and wrote no end for, the run's next process writes it as it opens. */
@@ -0,0 +1,26 @@
1
+ /** A run's meters, from its store (cap.ts metersIn) or its live rows: each null when one of its charges is unknown. */
2
+ export type RunMeters = {
3
+ tools: number | null;
4
+ tokens: number | null;
5
+ browser: {
6
+ usd: number | null;
7
+ };
8
+ others: number | null;
9
+ known?: {
10
+ tokens: number;
11
+ browser: number;
12
+ others: number;
13
+ };
14
+ };
15
+ /** One run's parts of /usage's lines. `usd`: its cost, null when unknown; `soFar`: what it is known to have spent then;
16
+ * `key`: its line when it has one alone (`tokens` by meter); `meters`: its meters, by meter only. */
17
+ export declare function runLines(run: {
18
+ usd: number | null;
19
+ soFar: number;
20
+ key: string;
21
+ meters?: RunMeters;
22
+ }): {
23
+ name: string;
24
+ usd: number;
25
+ unpriced: boolean;
26
+ }[];
@@ -0,0 +1,28 @@
1
+ // The lines one run adds to GET /usage: by meter its tokens, its paid tools and its browser time, else one line (by
2
+ // agent, by day). A part whose cost is unknown counts the run as unpriced on its line and adds what is known of it, so
3
+ // no sum is ever null and none passes an unknown cost as $0.
4
+ /** One run's parts of /usage's lines. `usd`: its cost, null when unknown; `soFar`: what it is known to have spent then;
5
+ * `key`: its line when it has one alone (`tokens` by meter); `meters`: its meters, by meter only. */
6
+ export function runLines(run) {
7
+ const { usd, soFar, key, meters } = run;
8
+ const tokens = meters && (usd !== null && meters.tools !== null ? usd - meters.tools : usd === null && meters.tools === null ? meters.tokens : null);
9
+ // Each meter's known dollars, whatever else of it is unknown: an unknown line's own, and on tokens what the run spent
10
+ // so far beside the other meters' known dollars, so no meter's dollars land on another's line, nor on none.
11
+ const known = meters?.known ?? { tokens: 0, browser: 0, others: 0 };
12
+ const knownOn = (name) => (name === "browser_time" ? known.browser : name === "tools" ? known.others : Math.max(0, soFar - known.browser - known.others));
13
+ // Each apart, an unknown one unknown (unpriced on its own line), never $0 nor the other's.
14
+ const browser = meters ? meters.browser.usd : 0;
15
+ const tools = meters?.others;
16
+ const parts = !meters ? [[key, usd]] : [[key, tokens ?? null], ...(tools !== 0 ? [["tools", tools ?? null]] : []), ...(browser !== 0 ? [["browser_time", browser]] : [])];
17
+ // Its known dollars when unknown: the whole of what it spent so far on a line of its own (by agent, by day), else its
18
+ // meter's own known dollars.
19
+ const lines = parts.map(([name, part]) => (part !== null ? { name, usd: part, unpriced: false } : { name, unpriced: true, usd: meters ? knownOn(name) : soFar }));
20
+ // What it spent so far beyond every line (an ended workflow's other conversations' model requests and its decisions'
21
+ // receipts, which its root store does not hold) is model and decision spend: on tokens, the meter of all but paid tools
22
+ // and browser time, never on tools or browser_time; so the lines sum to what it spent.
23
+ const beyond = usd === null && meters ? soFar - lines.reduce((sum, line) => sum + line.usd, 0) : 0;
24
+ const rest = beyond > 0 ? lines.find((line) => line.name === key) : undefined;
25
+ if (rest)
26
+ rest.usd += beyond;
27
+ return lines;
28
+ }
@@ -3,6 +3,8 @@ export declare const ID: RegExp;
3
3
  export type Json = Record<string, unknown>;
4
4
  export declare const isObject: (value: unknown) => value is Json;
5
5
  /** JSON with every object's keys sorted, so two equal values read the same. */
6
+ /** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
7
+ export declare const IDEMPOTENCY_TTL_S = 86400;
6
8
  export declare const stable: (value: unknown) => string;
7
9
  export declare const DEFINITION_FIELDS: string[];
8
10
  /** Why a field a definition may have elsewhere has no place in an agent store's revision. */
package/dist/validate.js CHANGED
@@ -8,13 +8,14 @@ export const ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
8
8
  const SKILL_PATH = /^(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?!.*\/\/)(?!.*\/$)[^/\\\u0000][^\\\u0000]*$/;
9
9
  export const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10
10
  /** JSON with every object's keys sorted, so two equal values read the same. */
11
+ /** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
12
+ export const IDEMPOTENCY_TTL_S = 86_400;
11
13
  export const stable = (value) => Array.isArray(value) ? `[${value.map(stable).join(",")}]` : isObject(value) ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stable(value[k])}`).join(",")}}` : JSON.stringify(value);
12
- export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "learning", "skills", "tools", "tool_settings"];
14
+ export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "thinking", "harness", "place", "learning", "skills", "tools", "tool_settings", "max_cost_usd"];
13
15
  /** Why a field a definition may have elsewhere has no place in an agent store's revision. */
14
16
  export const NOT_KEPT = {
15
17
  input_schema: "The agent store keeps no input_schema: an agentic run takes {content}, and a workflow checks its input against its own schema.",
16
18
  output_schema: "The agent store keeps no output_schema: a workflow run's output is its workflow's.",
17
- max_cost_usd: "The agent store keeps no max_cost_usd on a definition: give one with each run.",
18
19
  };
19
20
  /** `provider/model-id`. */
20
21
  export const MODEL_REF = /^[^/\s]+\/\S+$/;
@@ -92,6 +93,14 @@ export function definitionIssues(definition, { at = "definition", creating = tru
92
93
  // The agent's own tool settings, over the server's (tool-plane.ts); an edit that leaves them out keeps none.
93
94
  if (d.tool_settings !== undefined)
94
95
  out.push(...settingsIssues(d.tool_settings, `${at}.tool_settings`));
96
+ // The agent's default cap of each run started without one of its own: above 0 sets it, 0 clears it (no default), and
97
+ // an edit that leaves it out keeps the agent's (agents.ts), so leaving a field out never removes a spend limit.
98
+ if (d.max_cost_usd !== undefined) {
99
+ if (!(typeof d.max_cost_usd === "number" && Number.isFinite(d.max_cost_usd) && d.max_cost_usd >= 0))
100
+ out.push(issue(`${at}.max_cost_usd`, "wrong_type", `${at}.max_cost_usd is a number of at least 0, in US dollars: above 0 sets the agent's default cap, 0 clears it`));
101
+ else if (d.workflow !== undefined && d.max_cost_usd > 0)
102
+ out.push(issue(`${at}.max_cost_usd`, "not_allowed", "A workflow run's spend is not capped here, so a workflow revision keeps no max_cost_usd.", `Remove ${at}.max_cost_usd.`));
103
+ }
95
104
  return out;
96
105
  }
97
106
  /** The skill files a body names: an object of relative paths inside `.agents/skills/` to text. */
package/dist/web-fetch.js CHANGED
@@ -4,7 +4,7 @@ import { clip, fetchOptions, HTML_READ_CHARS, linksWithin, MAX_CHARS_MIN, PAGE_C
4
4
  import { FAUX_ENV } from "./model.js";
5
5
  import { PaidRefused, paidRequest, parallelFeeOf } from "./paid-calls.js";
6
6
  import { forModel } from "./result.js";
7
- import { isUnavailable, planeOf } from "./tool-plane.js";
7
+ import { isUnavailable, planeOf, whyUnavailable } from "./tool-plane.js";
8
8
  export const WEB_FETCH_TOOL = "web_fetch";
9
9
  export const PARALLEL_EXTRACT_URL = "https://api.parallel.ai/v1/extract";
10
10
  const PARALLEL_TIMEOUT_MS = 60_000;
@@ -203,7 +203,7 @@ export async function fetchFor(env, url, options = {}) {
203
203
  return { ok: false, url: typeof url === "string" ? clip(url, URL_MAX) : "", status: 0, title: "", text: "", links: [], error: problem };
204
204
  const resolved = planeOf(env).web_fetch;
205
205
  if (isUnavailable(resolved))
206
- return { ok: false, url: typeof url === "string" ? clip(url, URL_MAX) : "", status: 0, title: "", text: "", links: [], error: `web_fetch does not run here: ${resolved.slice("unavailable: ".length)}` };
206
+ return { ok: false, url: typeof url === "string" ? clip(url, URL_MAX) : "", status: 0, title: "", text: "", links: [], error: `web_fetch does not run here: ${whyUnavailable(resolved)}` };
207
207
  const extract = resolved === "parallel" ? parallelOf(env) : null;
208
208
  const page = await webFetch(url, { ...options, parallel: extract });
209
209
  return resolved === "parallel" && !extract ? { ...page, parallel: "not tried: this run holds no Parallel key" } : page;
@@ -250,7 +250,7 @@ export function webFetchTool(env, name = WEB_FETCH_TOOL) {
250
250
  parallelOf(env);
251
251
  return defineTool({
252
252
  name,
253
- description: `Read one web page from a public host, a part at a time. Answers JSON: ok, the final url, the HTTP status, the page's title, text (a part of its readable text as markdown: about max_chars characters from offset, ${PAGE_CHARS.toLocaleString("en-US")} by default, at least ${MAX_CHARS_MIN} and at most ${TEXT_CAP.toLocaleString("en-US")}) and chars (that part's length), the absolute links the page holds (with the part at offset 0; links_omitted counts those its caps left out), and via: parallel when Parallel's extract read it, direct when it was fetched from the host (with parallel saying why, where Parallel was picked and gave no page), stopped when the call was stopped before its page arrived. A part that is not the whole page says so: truncated is true while more follows, next_offset is where the rest begins, original_chars is the page's whole length where it is known, and a line after the JSON says which characters these are; call again with offset to read on. A page whose HTML is longer than ${HTML_READ_CHARS.toLocaleString("en-US")} characters (scripts and styles aside) is cut before it is read: html_chars gives its whole length on every part, its text is only the start of the page, and the last part's line says it was cut. converted is "text" when the text is the page's plain text, its conversion to markdown having run out of time. A page is read to its first ${PAGE_READ_MAX_CHARS.toLocaleString("en-US")} characters (beyond_read on the last part says it goes on). A page is fetched once a run, at its first call: its later parts come from that read, with no request (through Parallel, one billed extract a page). A private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused and never read (ok false, with refused saying why); so is a page fetched directly that is not text.`,
253
+ description: `Read one web page from a public host, a part at a time. It has no cookies, sign-ins or session: it reads one page cold, so a page behind a sign-in, or one that depends on an earlier page, needs the browser tool, where this run has it. Answers JSON: ok, the final url, the HTTP status, the page's title, text (a part of its readable text as markdown: about max_chars characters from offset, ${PAGE_CHARS.toLocaleString("en-US")} by default, at least ${MAX_CHARS_MIN} and at most ${TEXT_CAP.toLocaleString("en-US")}) and chars (that part's length), the absolute links the page holds (with the part at offset 0; links_omitted counts those its caps left out), and via: parallel when Parallel's extract read it, direct when it was fetched from the host (with parallel saying why, where Parallel was picked and gave no page), stopped when the call was stopped before its page arrived. A part that is not the whole page says so: truncated is true while more follows, next_offset is where the rest begins, original_chars is the page's whole length where it is known, and a line after the JSON says which characters these are; call again with offset to read on. A page whose HTML is longer than ${HTML_READ_CHARS.toLocaleString("en-US")} characters (scripts and styles aside) is cut before it is read: html_chars gives its whole length on every part, its text is only the start of the page, and the last part's line says it was cut. converted is "text" when the text is the page's plain text, its conversion to markdown having run out of time. A page is read to its first ${PAGE_READ_MAX_CHARS.toLocaleString("en-US")} characters (beyond_read on the last part says it goes on). A page is fetched once a run, at its first call: its later parts come from that read, with no request (through Parallel, one billed extract a page). A private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused and never read (ok false, with refused saying why); so is a page fetched directly that is not text.`,
254
254
  parameters: URL_PARAMETERS,
255
255
  replay: "safe",
256
256
  execute: async (args, _api, context) => {
@@ -1,6 +1,10 @@
1
- export declare const WEBHOOK_EVENTS: readonly ["run.needs_input", "run.ended"];
1
+ import type { TriggerFailed } from "./triggers.js";
2
+ /** A run's two notices, which runs.ts tells. */
3
+ export declare const RUN_EVENTS: readonly ["run.needs_input", "run.ended"];
4
+ /** Every message type a webhook is sent: a run's notices, and a trigger's failed firing (triggers.ts). */
5
+ export declare const WEBHOOK_EVENTS: readonly ["run.needs_input", "run.ended", "trigger.failed"];
2
6
  /** The message types: a run's two notices, and the test send's. */
3
- export declare const MESSAGE_TYPES: readonly ["run.needs_input", "run.ended", "webhook.test"];
7
+ export declare const MESSAGE_TYPES: readonly ["run.needs_input", "run.ended", "trigger.failed", "webhook.test"];
4
8
  type MessageType = (typeof MESSAGE_TYPES)[number];
5
9
  export declare const WEBHOOK_FILE = "webhook.json";
6
10
  export declare const OUTBOX_FILE = "webhook-outbox.json";
@@ -22,7 +26,7 @@ export type RunNotice = {
22
26
  status: string;
23
27
  title: string;
24
28
  pending?: {
25
- kind: "question" | "stopped";
29
+ kind: "question" | "approval" | "stopped" | "budget";
26
30
  };
27
31
  };
28
32
  type Config = {
@@ -125,7 +129,10 @@ export declare class Webhooks {
125
129
  * a webhook is set and on, and kept in the ledger in the same write. `marker` makes its webhook-id: the same moment,
126
130
  * seen again after a restart, has the same id, which is a receiver's idempotency key. An end before the ledger began,
127
131
  * before the webhook was set, or past the outbox's day counts as sent. */
128
- emit(type: (typeof WEBHOOK_EVENTS)[number], run: RunNotice, marker: string): Emitted;
132
+ emit(type: (typeof RUN_EVENTS)[number], run: RunNotice, marker: string): Emitted;
133
+ /** A trigger's failed firing (triggers.ts), queued once: its webhook-id is made from the firing's key, so the same
134
+ * failure told again, by a later server too, is the same message. Its trigger keeps whether it was queued. */
135
+ emitTrigger(failed: TriggerFailed, firingKey: string): Emitted;
129
136
  /** A start's catch-up, once its runs are read (`rows`, the agent store's: a row with no state is an ended one). First,
130
137
  * before anything is awaited, the ledger as the store now stands: a run the store no longer has goes, and a wait of a
131
138
  * run it holds as ended goes (an end the webhook was off for never moved it past). Then each end the store holds that
package/dist/webhooks.js CHANGED
@@ -18,7 +18,10 @@ import { ApiError, invalid } from "./errors.js";
18
18
  import { writeDurableSync } from "./files.js";
19
19
  import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
20
20
  import { isObject, unknownFields } from "./validate.js";
21
- export const WEBHOOK_EVENTS = ["run.needs_input", "run.ended"];
21
+ /** A run's two notices, which runs.ts tells. */
22
+ export const RUN_EVENTS = ["run.needs_input", "run.ended"];
23
+ /** Every message type a webhook is sent: a run's notices, and a trigger's failed firing (triggers.ts). */
24
+ export const WEBHOOK_EVENTS = [...RUN_EVENTS, "trigger.failed"];
22
25
  /** The message types: a run's two notices, and the test send's. */
23
26
  export const MESSAGE_TYPES = [...WEBHOOK_EVENTS, "webhook.test"];
24
27
  export const WEBHOOK_FILE = "webhook.json";
@@ -198,6 +201,19 @@ export class Webhooks {
198
201
  }
199
202
  return this.unsaved ? "unsaved" : "queued";
200
203
  }
204
+ /** A trigger's failed firing (triggers.ts), queued once: its webhook-id is made from the firing's key, so the same
205
+ * failure told again, by a later server too, is the same message. Its trigger keeps whether it was queued. */
206
+ emitTrigger(failed, firingKey) {
207
+ if (this.closed)
208
+ return "closed";
209
+ const config = this.config();
210
+ if (!config || config.disabled)
211
+ return "off";
212
+ const id = `msg_${createHash("sha256").update(`trigger.failed\n${firingKey}`).digest("hex").slice(0, 32)}`;
213
+ if (!this.messages.some((m) => m.id === id))
214
+ this.schedule(this.enqueue(id, "trigger.failed", failed), 0);
215
+ return this.unsaved ? "unsaved" : "queued";
216
+ }
201
217
  /** A start's catch-up, once its runs are read (`rows`, the agent store's: a row with no state is an ended one). First,
202
218
  * before anything is awaited, the ledger as the store now stands: a run the store no longer has goes, and a wait of a
203
219
  * run it holds as ended goes (an end the webhook was off for never moved it past). Then each end the store holds that
@@ -27,7 +27,7 @@
27
27
  # here. Any other variable named like a key (a KEY, TOKEN, SECRET, PASSWORD, PASSWD, PASS, PAT, CREDENTIAL, CREDENTIALS or
28
28
  # DSN segment, or a last PWD after another) stays in the server's environment, as this list does not take it, and in no
29
29
  # run's: name it here to keep it from the server's too.
30
- SECRETS='AGENTRUN_TOKEN AGENTRUN_API_KEY AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID OPENROUTER_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY AGENTRUN_SEAL_KEY DAYTONA_API_KEY MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
30
+ SECRETS='AGENTRUN_TOKEN AGENTRUN_API_KEY AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY AGENTRUN_SEAL_KEY DAYTONA_API_KEY MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
31
31
  set -eu
32
32
  # Each secret out of the environment and into an unexported variable of this shell (agentrun_secret_<NAME>).
33
33
  for name in $SECRETS; do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-serve",
3
- "version": "0.1.0-beta.29",
3
+ "version": "0.1.0-beta.31",
4
4
  "description": "The Agentrun v2 API on your own machine: an agent store's agents, revisions and runs, served on loopback.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -47,29 +47,31 @@
47
47
  "dependencies": {
48
48
  "@browserbasehq/sdk": ">=2.20.0 <3",
49
49
  "@modelcontextprotocol/client": "2.4.0",
50
- "@parcha/agentrun-decisions": "0.1.0-beta.29",
51
- "@parcha/agentrun-dsl": "0.1.0-beta.29",
52
- "@parcha/agentrun-harness-claude": "0.1.0-beta.29",
53
- "@parcha/agentrun-harness-codex": "0.1.0-beta.29",
54
- "@parcha/agentrun-jev": "0.1.0-beta.29",
55
- "@parcha/agentrun-kernel": "0.1.0-beta.29",
56
- "@parcha/agentrun-pi": "0.1.0-beta.29",
57
- "@parcha/pi-browser": "0.1.0-beta.29",
58
- "@parcha/pi-durable-agent": "0.1.0-beta.29",
59
- "@parcha/pi-durable-disk": "0.1.0-beta.29",
50
+ "@parcha/agentrun-decisions": "0.1.0-beta.31",
51
+ "@parcha/agentrun-dsl": "0.1.0-beta.31",
52
+ "@parcha/agentrun-harness-claude": "0.1.0-beta.31",
53
+ "@parcha/agentrun-harness-codex": "0.1.0-beta.31",
54
+ "@parcha/agentrun-jev": "0.1.0-beta.31",
55
+ "@parcha/agentrun-kernel": "0.1.0-beta.31",
56
+ "@parcha/agentrun-pi": "0.1.0-beta.31",
57
+ "@parcha/pi-browser": "0.1.0-beta.31",
58
+ "@parcha/pi-durable-agent": "0.1.0-beta.31",
59
+ "@parcha/pi-durable-disk": "0.1.0-beta.31",
60
+ "@parcha/pi-transport": "0.1.0-beta.31",
60
61
  "@secretlint/core": "13.1.0",
61
62
  "@secretlint/profiler": "13.1.0",
62
63
  "@secretlint/secretlint-rule-preset-recommend": "13.1.0",
64
+ "croner": "11.0.0",
63
65
  "undici": "^8.12.2"
64
66
  },
65
67
  "peerDependencies": {
66
68
  "@earendil-works/chord": ">=1.1.0 <1.4.0",
67
69
  "@earendil-works/pi-ai": "*",
68
70
  "@earendil-works/pi-durable": ">=1.1.0 <1.4.0",
69
- "@parcha/pi-transport": "0.1.0-beta.29"
71
+ "opencode-ai": "1.19.5"
70
72
  },
71
73
  "peerDependenciesMeta": {
72
- "@parcha/pi-transport": {
74
+ "opencode-ai": {
73
75
  "optional": true
74
76
  }
75
77
  },
@@ -78,7 +80,7 @@
78
80
  "@earendil-works/pi-ai": "1.1.0",
79
81
  "@earendil-works/pi-durable": "1.1.0",
80
82
  "@modelcontextprotocol/server": "2.4.0",
81
- "@parcha/pi-transport": "0.1.0-beta.29"
83
+ "opencode-ai": "1.19.5"
82
84
  },
83
85
  "repository": {
84
86
  "type": "git",