@parcha/agentrun-serve 0.1.0-beta.34 → 0.1.0-beta.35

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 (227) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +84 -16
  3. package/dist/adapters.d.ts +3 -0
  4. package/dist/adapters.js +7 -0
  5. package/dist/agent-rows.d.ts +1 -0
  6. package/dist/agents-store.js +17 -2
  7. package/dist/archil-settings.d.ts +11 -1
  8. package/dist/archil-settings.js +10 -0
  9. package/dist/bash-read-only.d.ts +13 -0
  10. package/dist/bash-read-only.js +77 -0
  11. package/dist/browser-cost.d.ts +2 -2
  12. package/dist/browser-cost.js +6 -4
  13. package/dist/budget.d.ts +0 -5
  14. package/dist/budget.js +0 -5
  15. package/dist/cap.d.ts +6 -3
  16. package/dist/cap.js +7 -4
  17. package/dist/cli.js +32 -5
  18. package/dist/computer-keys.d.ts +20 -10
  19. package/dist/computer-keys.js +36 -57
  20. package/dist/computer-setting.d.ts +6 -5
  21. package/dist/computer-setting.js +54 -26
  22. package/dist/computers.d.ts +9 -4
  23. package/dist/computers.js +4 -2
  24. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  25. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  26. package/dist/console/index.html +2 -2
  27. package/dist/content-filter.d.ts +7 -0
  28. package/dist/content-filter.js +23 -0
  29. package/dist/decision-cap.d.ts +7 -29
  30. package/dist/decision-cap.js +3 -94
  31. package/dist/errors.d.ts +1 -0
  32. package/dist/errors.js +3 -0
  33. package/dist/explain.js +3 -1
  34. package/dist/github-connection.js +25 -7
  35. package/dist/github-faux.d.ts +26 -0
  36. package/dist/github-faux.js +76 -0
  37. package/dist/github.d.ts +6 -2
  38. package/dist/github.js +5 -3
  39. package/dist/graph-served.d.ts +5 -3
  40. package/dist/graph-served.js +14 -6
  41. package/dist/graph-view.js +5 -2
  42. package/dist/harness-opencode/harness.js +0 -1
  43. package/dist/harness-opencode/host/policy.js +2 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/learn/check.d.ts +3 -1
  47. package/dist/learn/check.js +3 -3
  48. package/dist/learn/folder.d.ts +6 -3
  49. package/dist/learn/folder.js +7 -16
  50. package/dist/learn/grade.d.ts +4 -1
  51. package/dist/learn/grade.js +43 -5
  52. package/dist/learn/index.d.ts +2 -2
  53. package/dist/learn/index.js +2 -2
  54. package/dist/learn/learning.sh +1 -14
  55. package/dist/learn/notes.d.ts +14 -3
  56. package/dist/learn/notes.js +16 -6
  57. package/dist/learn/reflect.js +5 -3
  58. package/dist/learn/skills.d.ts +48 -5
  59. package/dist/learn/skills.js +97 -21
  60. package/dist/learned-nodes.d.ts +14 -0
  61. package/dist/learned-nodes.js +8 -0
  62. package/dist/learned-workflow.d.ts +9 -5
  63. package/dist/learned-workflow.js +53 -9
  64. package/dist/learning-routes.d.ts +41 -0
  65. package/dist/learning-routes.js +94 -26
  66. package/dist/learning-run.d.ts +7 -5
  67. package/dist/learning-run.js +9 -6
  68. package/dist/learning.d.ts +0 -22
  69. package/dist/learning.js +0 -16
  70. package/dist/llm.d.ts +4 -1
  71. package/dist/llm.js +4 -2
  72. package/dist/mcp-gateway.d.ts +6 -0
  73. package/dist/mcp-gateway.js +11 -1
  74. package/dist/mcp-servers-store.d.ts +12 -12
  75. package/dist/model.d.ts +3 -0
  76. package/dist/model.js +8 -0
  77. package/dist/openapi.js +37 -13
  78. package/dist/paid-calls.js +1 -1
  79. package/dist/pause.d.ts +2 -19
  80. package/dist/pause.js +5 -74
  81. package/dist/port-models.d.ts +10 -3
  82. package/dist/port-models.js +26 -6
  83. package/dist/propose.d.ts +2 -0
  84. package/dist/propose.js +1 -10
  85. package/dist/run-launch.d.ts +5 -3
  86. package/dist/run-launch.js +6 -5
  87. package/dist/run-learning-served.d.ts +11 -0
  88. package/dist/run-reads-over-store.d.ts +4 -2
  89. package/dist/run-reads-over-store.js +10 -8
  90. package/dist/run-timeline-served.js +12 -2
  91. package/dist/run-view.d.ts +30 -14
  92. package/dist/run-view.js +60 -32
  93. package/dist/runnable.d.ts +4 -1
  94. package/dist/runnable.js +14 -2
  95. package/dist/runner/adapter-loop.d.ts +30 -4
  96. package/dist/runner/adapter-loop.js +253 -29
  97. package/dist/runner/adapter-run-spec.d.ts +21 -0
  98. package/dist/runner/adapter-run-spec.js +104 -28
  99. package/dist/runner/adapters/pi.d.ts +29 -1
  100. package/dist/runner/adapters/pi.js +95 -23
  101. package/dist/runner/beside.d.ts +8 -0
  102. package/dist/runner/beside.js +18 -0
  103. package/dist/runner/claim-secrets.d.ts +6 -0
  104. package/dist/runner/claim-secrets.js +15 -1
  105. package/dist/runner/cli-run-spec.d.ts +3 -0
  106. package/dist/runner/cli-run-spec.js +123 -34
  107. package/dist/runner/conformance/harness.d.ts +1 -0
  108. package/dist/runner/conformance/harness.js +5 -5
  109. package/dist/runner/github-app.d.ts +7 -2
  110. package/dist/runner/github-app.js +46 -15
  111. package/dist/runner/harness-loops.d.ts +6 -1
  112. package/dist/runner/harness-loops.js +23 -0
  113. package/dist/runner/journal-kinds.d.ts +38 -2
  114. package/dist/runner/journal-kinds.js +23 -0
  115. package/dist/runner/learning-end.js +88 -16
  116. package/dist/runner/learning-loop.d.ts +2 -0
  117. package/dist/runner/learning-loop.js +13 -5
  118. package/dist/runner/learning-seed.d.ts +6 -0
  119. package/dist/runner/learning-seed.js +6 -0
  120. package/dist/runner/loop-contract.d.ts +4 -0
  121. package/dist/runner/main.d.ts +9 -4
  122. package/dist/runner/main.js +26 -11
  123. package/dist/runner/mcp-claim.d.ts +3 -0
  124. package/dist/runner/mcp-claim.js +6 -1
  125. package/dist/runner/mcp-github.d.ts +11 -2
  126. package/dist/runner/mcp-github.js +55 -4
  127. package/dist/runner/mcp-run.js +1 -0
  128. package/dist/runner/metrics.d.ts +14 -1
  129. package/dist/runner/metrics.js +72 -1
  130. package/dist/runner/model-route.d.ts +3 -0
  131. package/dist/runner/model-route.js +1 -1
  132. package/dist/runner/runner.js +90 -8
  133. package/dist/runner/spec-holds.d.ts +7 -2
  134. package/dist/runner/spec-holds.js +4 -3
  135. package/dist/runner/workflow-host.d.ts +7 -2
  136. package/dist/runner/workflow-host.js +3 -1
  137. package/dist/runner/workflow-loop.d.ts +4 -1
  138. package/dist/runner/workflow-loop.js +8 -2
  139. package/dist/runner/workflow-spec.d.ts +3 -0
  140. package/dist/runner/workflow-spec.js +156 -78
  141. package/dist/runs-over-store.d.ts +7 -1
  142. package/dist/runs-over-store.js +42 -11
  143. package/dist/seal-key.d.ts +0 -2
  144. package/dist/seal-key.js +0 -2
  145. package/dist/server-lock.js +4 -5
  146. package/dist/server.d.ts +21 -18
  147. package/dist/server.js +183 -34
  148. package/dist/stop-signals.d.ts +4 -2
  149. package/dist/stop-signals.js +5 -3
  150. package/dist/store/agent-body.d.ts +5 -1
  151. package/dist/store/agent-body.js +11 -5
  152. package/dist/store/deadline.d.ts +18 -0
  153. package/dist/store/deadline.js +45 -0
  154. package/dist/store/postgres/connection.d.ts +4 -0
  155. package/dist/store/postgres/connection.js +55 -9
  156. package/dist/store/sqlite/connection.js +3 -38
  157. package/dist/store-reads/journal.js +39 -4
  158. package/dist/store-reads/learning.d.ts +58 -2
  159. package/dist/store-reads/learning.js +172 -7
  160. package/dist/store-view.d.ts +15 -1
  161. package/dist/store-view.js +45 -12
  162. package/dist/templates.d.ts +9 -4
  163. package/dist/templates.js +14 -9
  164. package/dist/timeline/timeline.d.ts +8 -0
  165. package/dist/tool-budget.d.ts +18 -0
  166. package/dist/tool-budget.js +50 -0
  167. package/dist/tool-gate.d.ts +6 -2
  168. package/dist/tool-gate.js +8 -5
  169. package/dist/tool-plane.d.ts +9 -10
  170. package/dist/tools.d.ts +37 -7
  171. package/dist/tools.js +73 -12
  172. package/dist/uploads.d.ts +28 -5
  173. package/dist/uploads.js +82 -9
  174. package/dist/usage.d.ts +1 -47
  175. package/dist/usage.js +3 -82
  176. package/dist/validate.d.ts +2 -0
  177. package/dist/validate.js +11 -1
  178. package/dist/workspace/archil-claim.d.ts +2 -2
  179. package/dist/workspace/archil-claim.js +4 -3
  180. package/dist/workspace/archil-disk.d.ts +10 -1
  181. package/dist/workspace/archil-disk.js +4 -0
  182. package/dist/workspace/archil-exec.d.ts +12 -2
  183. package/dist/workspace/archil-exec.js +16 -0
  184. package/dist/workspace/archil.d.ts +2 -2
  185. package/dist/workspace/archil.js +25 -5
  186. package/dist/workspace/attach.js +2 -0
  187. package/dist/workspace/computer-deps.d.ts +9 -10
  188. package/dist/workspace/computer-deps.js +53 -40
  189. package/dist/workspace/computer-for-claim.d.ts +5 -3
  190. package/dist/workspace/computer-for-claim.js +28 -16
  191. package/dist/workspace/computer-ledger.d.ts +1 -8
  192. package/dist/workspace/computer-ledger.js +0 -3
  193. package/dist/workspace/computer-providers.d.ts +5 -3
  194. package/dist/workspace/computer-providers.js +11 -9
  195. package/dist/workspace/hands.d.ts +5 -2
  196. package/dist/workspace/hands.js +4 -3
  197. package/dist/workspace/index.d.ts +3 -3
  198. package/dist/workspace/index.js +1 -1
  199. package/dist/workspace/local.d.ts +3 -0
  200. package/dist/workspace/local.js +9 -0
  201. package/dist/workspace/paths.js +3 -2
  202. package/dist/workspace/pi-env.d.ts +4 -0
  203. package/dist/workspace/pi-env.js +3 -2
  204. package/dist/workspace/resolve-computer.d.ts +8 -3
  205. package/dist/workspace/resolve-computer.js +28 -11
  206. package/dist/workspace/run-tools.d.ts +2 -0
  207. package/dist/workspace/run-tools.js +9 -3
  208. package/dist/workspace/workspace.d.ts +5 -0
  209. package/dist/workspace.d.ts +0 -3
  210. package/dist/workspace.js +1 -14
  211. package/package.json +14 -14
  212. package/skills/agentrun-serve/SKILL.md +1 -1
  213. package/templates/README.md +2 -2
  214. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  215. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  216. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  217. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  218. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  219. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  220. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  221. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  222. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  223. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  224. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  225. package/templates/release-notes/agent.md +11 -0
  226. package/dist/console/assets/index-RPHGlXmM.js +0 -540
  227. package/dist/console/assets/index-opTN5Naq.css +0 -1
@@ -6,8 +6,8 @@
6
6
  <meta name="color-scheme" content="light dark" />
7
7
  <title>AgentRun</title>
8
8
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%23ff8000'/%3E%3Cpath d='M12 9l11 7-11 7z' fill='%23000'/%3E%3C/svg%3E" />
9
- <script type="module" crossorigin src="./assets/index-RPHGlXmM.js"></script>
10
- <link rel="stylesheet" crossorigin href="./assets/index-opTN5Naq.css">
9
+ <script type="module" crossorigin src="./assets/index-CXZMgJE7.js"></script>
10
+ <link rel="stylesheet" crossorigin href="./assets/index-B7NKTU8E.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
@@ -0,0 +1,7 @@
1
+ /** The run error code (agentrun-v2's RunErrorCode). */
2
+ export declare const MODERATED = "moderated";
3
+ /** The run's error for it: what stopped the answer and what a person can do. */
4
+ export declare const CONTENT_FILTER_WORDS = "The model provider stopped this answer (its content filter). Rephrase the request, or try another model.";
5
+ /** Whether a run's end says the provider's content filter stopped its answer. A CLI harness's names its harness first
6
+ * (`<harness>: <the turn's error>`). */
7
+ export declare function contentFiltered(message: string): boolean;
@@ -0,0 +1,23 @@
1
+ // A provider's content filter stopping a run's answer, read the same way on every harness from the words the run ended
2
+ // with (its row's summary): on pi, the words pi-ai gives that stop on each API (its stop reason is only "error", so its
3
+ // fixed words are what is read); on claude-agent, codex and opencode, the adapters' CONTENT_FILTERED, which the harness
4
+ // halts the turn with once its model proxy reads the provider's stop (a refusal, an answer incomplete for
5
+ // content_filter), named after its harness. A run so ended fails `moderated` (the contract's own run error code) in words
6
+ // a person can act on; the Timeline's error row keeps the harness's words for the stop. A refusal whose provider gave
7
+ // its own explanation (pi on the Messages API) has no fixed words and stays run_failed.
8
+ import { CONTENT_FILTERED } from "@parcha/agentrun-kernel";
9
+ /** The run error code (agentrun-v2's RunErrorCode). */
10
+ export const MODERATED = "moderated";
11
+ /** The run's error for it: what stopped the answer and what a person can do. */
12
+ export const CONTENT_FILTER_WORDS = "The model provider stopped this answer (its content filter). Rephrase the request, or try another model.";
13
+ /** pi-ai's words for a provider's content-filter stop: the Responses API's answer incomplete for content_filter, Chat
14
+ * Completions' finish_reason, and the Messages API's refusal when the provider gave no explanation. */
15
+ const PI_AI_FILTERED = new Set(["Response incomplete: content_filter", "Provider finish_reason: content_filter", "The model refused to complete the request"]);
16
+ /** Whether a run's end says the provider's content filter stopped its answer. A CLI harness's names its harness first
17
+ * (`<harness>: <the turn's error>`). */
18
+ export function contentFiltered(message) {
19
+ if (PI_AI_FILTERED.has(message) || message === CONTENT_FILTERED)
20
+ return true;
21
+ const named = /^[a-z][a-z0-9-]*: ([\s\S]*)$/.exec(message);
22
+ return named !== null && named[1] === CONTENT_FILTERED;
23
+ }
@@ -1,6 +1,6 @@
1
1
  import type { DecisionProvider, WorkflowDeps } from "@parcha/agentrun-dsl";
2
+ import type { DecisionModelPrice } from "@parcha/agentrun-decisions";
2
3
  import { type CapMode } from "./cap.js";
3
- import type { BudgetWaits } from "./budget.js";
4
4
  type RunJudge = NonNullable<WorkflowDeps["runJudge"]>;
5
5
  type JudgeParams = Parameters<RunJudge>[0];
6
6
  /** An image's input allowance, in tokens: what a 1568 px square (Jev's longest side) reads as at 750 pixels a token. */
@@ -14,6 +14,12 @@ export declare const PARALLEL_DECISION_USD = 0.001;
14
14
  /** How many times a decision's price is read from OpenRouter's catalog before its request fails unsent, and the waits
15
15
  * between the reads, in ms. */
16
16
  export declare const CATALOG_TRIES = 3;
17
+ /** `model`'s price from `priced`'s catalog, read up to CATALOG_TRIES times: a catalog still down then fails the request
18
+ * unsent, as a connection error (DecisionProviderError "connection"), and the decision node fails (decision nodes have
19
+ * no attempts loop), as on any provider's outage: never a CapStop. */
20
+ export declare function catalogPrice(priced: {
21
+ priceOf(model: string): Promise<DecisionModelPrice | null>;
22
+ }, model: string, signal: AbortSignal | undefined): Promise<DecisionModelPrice | null>;
17
23
  /** Whether the durable driver answers `params`'s request from what it holds, sending nothing, so the request holds and
18
24
  * waits for nothing: a route it decided, or a request an earlier process admitted that did not fail (asked and never
19
25
  * answered: the driver escalates it unsent, dsl with-recovery). */
@@ -32,32 +38,4 @@ export type DecisionHold = {
32
38
  };
33
39
  /** The hold of `params`'s request to `provider`, under a cap of mode `mode`. */
34
40
  export declare function holdOf(provider: DecisionProvider, params: JudgeParams, mode: CapMode): Promise<DecisionHold>;
35
- /** The two halves of a workflow's capped decisions, over `providers` (the run's, decisions.ts), the run's `waits`
36
- * (budget.ts) and `book`, which writes a DECISION_COST entry to the run's store. */
37
- export declare function cappedDecisions({ providers, waits, mode, book, keep }: {
38
- providers: {
39
- providers: Readonly<Record<string, DecisionProvider>>;
40
- default: string;
41
- };
42
- waits: BudgetWaits;
43
- mode: CapMode;
44
- book: (data: {
45
- call: string;
46
- decision: string | null;
47
- usd: number;
48
- }) => Promise<void>;
49
- /** Keeps a request's hold in the run's store (a DECISION_HOLD entry), committed when it resolves; throws when it
50
- * cannot be kept. */
51
- keep: (data: {
52
- call: string;
53
- decision: string | null;
54
- usd: number;
55
- }) => Promise<void>;
56
- }): {
57
- /** Before the admission: the hold taken, or a wait for a raise, or the run stopped. `replayed` says whether the
58
- * driver answers this request from what it decided before (a route's), which sends nothing and holds nothing. */
59
- before(next: RunJudge, replayed: (params: JudgeParams) => boolean): RunJudge;
60
- /** The judge itself: asks, and settles the request's hold at what it charged. */
61
- settling(judge: RunJudge): RunJudge;
62
- };
63
41
  export {};
@@ -1,5 +1,5 @@
1
- import { chargedCost, DecisionProviderError } from "@parcha/agentrun-dsl";
2
- import { holdPaid, money, runCap } from "./cap.js";
1
+ import { DecisionProviderError } from "@parcha/agentrun-dsl";
2
+ import { money } from "./cap.js";
3
3
  /** An image's input allowance, in tokens: what a 1568 px square (Jev's longest side) reads as at 750 pixels a token. */
4
4
  export const DECISION_IMAGE_TOKENS = 3_300;
5
5
  /** The output an answer is expected to take, per question, where a Decisions model prices its output (expected mode). */
@@ -8,11 +8,6 @@ export const DECISION_OUTPUT_TOKENS = 256;
8
8
  export const JEV_INPUT_USD = 0.042 / 1e6;
9
9
  /** Parallel's list price for one decision request (USD; PARALLEL_LIST_PRICE_USD). */
10
10
  export const PARALLEL_DECISION_USD = 0.001;
11
- /** A provider's failures that say the request was never billed: refused before it was sent, or by the provider unbilled. */
12
- const UNBILLED = new Set(["configuration", "auth", "invalid_request", "rate_limited", "connection"]);
13
- const unbilled = (error) => error instanceof DecisionProviderError && (error.unsent === true || UNBILLED.has(error.code));
14
- /** How a provider is named in a refusal's words. */
15
- const providerName = (provider, model) => provider.id === "openrouter" ? (model ?? "OpenRouter") : provider.id === "jev" ? "Jev" : provider.id === "parallel" ? "Parallel" : provider.id;
16
11
  /** How many times a decision's price is read from OpenRouter's catalog before its request fails unsent, and the waits
17
12
  * between the reads, in ms. */
18
13
  export const CATALOG_TRIES = 3;
@@ -20,7 +15,7 @@ const CATALOG_RETRY_MS = [500, 1_500];
20
15
  /** `model`'s price from `priced`'s catalog, read up to CATALOG_TRIES times: a catalog still down then fails the request
21
16
  * unsent, as a connection error (DecisionProviderError "connection"), and the decision node fails (decision nodes have
22
17
  * no attempts loop), as on any provider's outage: never a CapStop. */
23
- async function catalogPrice(priced, model, signal) {
18
+ export async function catalogPrice(priced, model, signal) {
24
19
  for (let tries = 1;; tries += 1) {
25
20
  try {
26
21
  return await priced.priceOf(model);
@@ -75,89 +70,3 @@ export async function holdOf(provider, params, mode) {
75
70
  const usd = price.requestUsd + price.imageUsd * images + price.promptUsd * tokens + price.completionUsd * (output ?? 0);
76
71
  return { usd, basis: `${model}'s price in OpenRouter's catalog, for ${tokens} input tokens${price.completionUsd > 0 ? ` and ${output} output tokens` : ""} at most` };
77
72
  }
78
- /** The two halves of a workflow's capped decisions, over `providers` (the run's, decisions.ts), the run's `waits`
79
- * (budget.ts) and `book`, which writes a DECISION_COST entry to the run's store. */
80
- export function cappedDecisions({ providers, waits, mode, book, keep }) {
81
- /** Each request's hold, taken by `before` and settled by `settling`, by the params object both are handed. */
82
- const tickets = new WeakMap();
83
- const stepOf = (params) => ({ label: params.label, path: params.executionPath ?? null });
84
- return {
85
- /** Before the admission: the hold taken, or a wait for a raise, or the run stopped. `replayed` says whether the
86
- * driver answers this request from what it decided before (a route's), which sends nothing and holds nothing. */
87
- before(next, replayed) {
88
- return async (params) => {
89
- const cap = runCap();
90
- if (cap === undefined || replayed(params))
91
- return next(params);
92
- const id = params.provider ?? providers.default;
93
- const provider = Object.hasOwn(providers.providers, id) ? providers.providers[id] : undefined;
94
- // A provider the host lacks is refused by the judge as configuration, before anything is sent.
95
- if (!provider)
96
- return next(params);
97
- const name = `${params.label}'s decision on ${providerName(provider, params.model)}`;
98
- const hold = await holdOf(provider, params, mode);
99
- if ("unpriced" in hold) {
100
- const refusal = { words: `Not sent: ${name}: ${hold.unpriced}, so the run's cap of ${money(cap)} cannot be kept: the run is out of budget.`, room: false, capUsd: cap };
101
- return waits.stop(refusal, stepOf(params));
102
- }
103
- const held = await holdPaid(name, hold, params.signal);
104
- if ("refused" in held) {
105
- if (held.refused.room)
106
- throw params.signal?.reason ?? new Error(`${name} was not sent: its wait for a raise ended`);
107
- return waits.stop(held.refused, stepOf(params));
108
- }
109
- const call = `${params.label}@${params.executionPath ?? ""}${params.item ? `#${params.item.index}` : ""}`;
110
- tickets.set(params, { ticket: held.ticket, usd: hold.usd, call, decision: params.decisionId ?? null, name, settled: false });
111
- try {
112
- return await next(params);
113
- }
114
- finally {
115
- // A request the driver answered without asking (one asked by an earlier process escalates) sent nothing.
116
- held.ticket.drop();
117
- }
118
- };
119
- },
120
- /** The judge itself: asks, and settles the request's hold at what it charged. */
121
- settling(judge) {
122
- return async (params) => {
123
- const held = tickets.get(params);
124
- if (!held)
125
- return judge(params);
126
- // Here the driver has admitted the request (dsl with-recovery: committed and flushed before this judge is asked),
127
- // and nothing is sent yet: its hold is kept in the run's store, one awaited commit right before the send. A process
128
- // that dies from here, the request maybe out, leaves it counted at its hold by the next one (decisionSpentIn); one
129
- // that died before the admission kept none. A hold that cannot be kept sends nothing, and the driver marks the
130
- // request failed, so the next process asks it again.
131
- try {
132
- await keep({ call: held.call, decision: held.decision, usd: held.usd });
133
- }
134
- catch (cause) {
135
- throw new DecisionProviderError("connection", `${held.name} was not sent: its hold under the run's cap could not be kept in the run's store (${cause?.message ?? cause}).`, { unsent: true, cause });
136
- }
137
- const settle = async (usd) => {
138
- held.settled = true;
139
- held.ticket.settle(usd);
140
- await book({ call: held.call, decision: held.decision, usd: usd ?? held.usd }).catch(() => undefined);
141
- };
142
- try {
143
- const result = await judge(params);
144
- await settle(typeof result.cost_usd === "number" && Number.isFinite(result.cost_usd) ? result.cost_usd : null);
145
- return result;
146
- }
147
- catch (error) {
148
- // Sent and maybe billed (its outcome lost, its answer refused, cut in flight): at what it was charged, else at its
149
- // hold. One that failed before it was sent, or that its provider refused unbilled, charged nothing.
150
- const charged = chargedCost(error);
151
- if (charged !== undefined)
152
- await settle(charged);
153
- else if (!unbilled(error))
154
- await settle(null);
155
- // Unbilled, it charged nothing: booked at $0, so no later process counts its hold.
156
- else
157
- await book({ call: held.call, decision: held.decision, usd: 0 }).catch(() => undefined);
158
- throw error;
159
- }
160
- };
161
- },
162
- };
163
- }
package/dist/errors.d.ts CHANGED
@@ -47,6 +47,7 @@ export declare const ERROR_STATUS: {
47
47
  readonly github_wrong_origin: 409;
48
48
  readonly github_failed: 502;
49
49
  readonly external_body_conflict: 409;
50
+ readonly learned_not_active: 409;
50
51
  };
51
52
  export type ErrorCode = keyof typeof ERROR_STATUS;
52
53
  /** A field that is missing or wrong. `example`: a value the field accepts, read from the request body's schema (explain.ts). */
package/dist/errors.js CHANGED
@@ -60,6 +60,9 @@ export const ERROR_STATUS = {
60
60
  // A run of an agent given inline (POST /runs) under a version of its source already run here with another definition: a
61
61
  // version's definition never changes here, so the source publishes a new version.
62
62
  external_body_conflict: 409,
63
+ // A learned workflow made into an agent of its own while it waits for its owner's OK or is retired: only an active one
64
+ // is (learning-routes.ts promotable).
65
+ learned_not_active: 409,
63
66
  };
64
67
  const RETRYABLE = new Set(["home_busy", "idempotency_in_progress", "rate_limited", "internal", "unavailable", "github_failed"]);
65
68
  export class ApiError extends Error {
package/dist/explain.js CHANGED
@@ -177,7 +177,9 @@ export function explain(issues, root, schema, told = {}) {
177
177
  return issues.map((issue) => {
178
178
  if (issue.example !== undefined || typeof issue.field !== "string" || !schema)
179
179
  return issue;
180
- const path = issue.field.split(".");
180
+ // A field named with the schema path its problem is at (a workflow's input: `input at #/properties/question`, the
181
+ // DSL's schema path, never the data's) is told from the field it names: a whole value it takes.
182
+ const path = (/^(\S+) at #\//.exec(issue.field)?.[1] ?? issue.field).split(".");
181
183
  const key = path.at(-1);
182
184
  const parent = schemaAt(root, schema, path.slice(0, -1));
183
185
  if (issue.reason === "not_allowed") {
@@ -210,7 +210,9 @@ export class GitHubConnect {
210
210
  setup_on_update: true,
211
211
  public: false,
212
212
  default_permissions: { ...APP_PERMISSIONS },
213
- default_events: ["pull_request", "issue_comment"],
213
+ // The events the templates' github triggers take: code-review's pull requests and comments, release-notes'
214
+ // published releases. A trigger takes only what the App is subscribed to.
215
+ default_events: ["pull_request", "issue_comment", "release"],
214
216
  };
215
217
  // GitHub reads the state from the form's URL; the form posts only the manifest.
216
218
  return { action: `${page}?state=${encodeURIComponent(state)}`, manifest, state };
@@ -531,19 +533,35 @@ export class GitHubConnect {
531
533
  return { unusable: "The GitHub App is not installed anywhere yet: install it on an account, then save the server." };
532
534
  try {
533
535
  const jwt = appJwt(credentials.appId, credentials.pem, this.options.now?.() ?? Date.now());
536
+ // Each installation in turn, until one gives a token: one that refuses, covers no repository or that GitHub did not
537
+ // answer for leaves the next to try.
534
538
  const refusals = [];
539
+ // A refused narrowed mint: its installation covers a repository, so its refusal is the answer, never "none covers one".
540
+ let covered;
541
+ let unanswered;
535
542
  for (const installation of installations) {
536
543
  const refused = { unusable: `GitHub gave no token for the App's installation on ${installation.account}.` };
537
544
  const found = await this.firstRepository(installation.id, jwt, refused, signal);
538
- // GitHub that does not answer says nothing of the installations: tried again, never read as "no repository".
539
545
  if ("failed" in found)
540
- return found;
541
- if ("unusable" in found)
546
+ unanswered = found;
547
+ else if ("unusable" in found)
542
548
  refusals.push(found);
543
- // The least a listing needs: metadata read, of one repository; never the App's write permissions, never all of them.
544
- else if (found.repo !== undefined)
545
- return await this.mint(installation.id, jwt, [found.repo], refused, signal, { metadata: "read" });
549
+ else if (found.repo !== undefined) {
550
+ // The least a listing needs: metadata read, of one repository; never the App's write permissions, never all of them.
551
+ const minted = await this.mint(installation.id, jwt, [found.repo], refused, signal, { metadata: "read" });
552
+ if ("token" in minted)
553
+ return minted;
554
+ if ("failed" in minted)
555
+ unanswered = minted;
556
+ else
557
+ covered ??= minted;
558
+ }
546
559
  }
560
+ // GitHub that did not answer for one says nothing of it: tried again, never read as refused or as "no repository".
561
+ if (unanswered)
562
+ return unanswered;
563
+ if (covered)
564
+ return covered;
547
565
  if (refusals.length === installations.length)
548
566
  return refusals[0];
549
567
  return installations.length === 1
@@ -0,0 +1,26 @@
1
+ /** The file beside the data that tells a test the fake App's webhook secret, installation and repositories. */
2
+ export declare const FAUX_GITHUB_FILE = "faux-github.json";
3
+ /** The fake App's one installation and the repositories it covers. */
4
+ export declare const FAUX_GITHUB: {
5
+ appId: string;
6
+ slug: string;
7
+ installation: number;
8
+ account: string;
9
+ repositories: readonly string[];
10
+ };
11
+ export type FauxGitHub = {
12
+ /** Its API's base, which the server's Connect GitHub asks in place of GitHub's own; never a URL anyone gives. */
13
+ url: string;
14
+ /** The App as Connect GitHub keeps it (github-connection.ts GitHubConnection.save). */
15
+ app: {
16
+ id: string;
17
+ slug: string;
18
+ clientId: string;
19
+ pem: string;
20
+ webhookSecret: string;
21
+ settingsUrl: string;
22
+ };
23
+ close(): Promise<void>;
24
+ };
25
+ /** Starts the fake GitHub API on loopback, with its App. */
26
+ export declare function startFauxGitHub(): Promise<FauxGitHub>;
@@ -0,0 +1,76 @@
1
+ // A fake GitHub for a server started with --faux and --faux-github: an App already connected, served by GitHub's API as an
2
+ // in-process server on loopback, so the console's GitHub flows (Settings → GitHub connected, a github trigger made, a
3
+ // signed delivery fired) run in a real browser with nothing sent to GitHub. It answers the API calls the server makes of
4
+ // the App (github.ts, github-connection.ts): the App's installations, one installation's read, an installation token's
5
+ // mint narrowed to the repositories asked, that token's read of the repositories it covers and its revoke, and which
6
+ // installation covers a repository. The App, its private key and its webhook secret are made fresh at each start; a test
7
+ // signs a delivery with the webhook secret, kept beside the data (FAUX_GITHUB_FILE). Never on a server without --faux.
8
+ import { generateKeyPairSync, randomBytes } from "node:crypto";
9
+ import { createServer } from "node:http";
10
+ /** The file beside the data that tells a test the fake App's webhook secret, installation and repositories. */
11
+ export const FAUX_GITHUB_FILE = "faux-github.json";
12
+ /** The fake App's one installation and the repositories it covers. */
13
+ export const FAUX_GITHUB = { appId: "1", slug: "agentrun-faux", installation: 1, account: "faux-org", repositories: ["faux-org/demo"] };
14
+ const TOKEN_MS = 60 * 60_000;
15
+ /** Starts the fake GitHub API on loopback, with its App. */
16
+ export async function startFauxGitHub() {
17
+ const { privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048, privateKeyEncoding: { type: "pkcs1", format: "pem" }, publicKeyEncoding: { type: "spki", format: "pem" } });
18
+ const app = { id: FAUX_GITHUB.appId, slug: FAUX_GITHUB.slug, clientId: `Iv1.faux${randomBytes(6).toString("hex")}`, pem: privateKey, webhookSecret: randomBytes(24).toString("hex"), settingsUrl: `https://github.com/organizations/${FAUX_GITHUB.account}/settings/apps/${FAUX_GITHUB.slug}` };
19
+ const installation = { id: FAUX_GITHUB.installation, account: { login: FAUX_GITHUB.account, type: "Organization" }, app_id: Number(FAUX_GITHUB.appId), suspended_at: null };
20
+ /** Each token minted, by its value: the repositories it was narrowed to (by name), or every one the installation covers. */
21
+ const tokens = new Map();
22
+ const covered = (names) => FAUX_GITHUB.repositories.filter((full) => !names || names.includes(full.split("/")[1]));
23
+ const answer = (res, status, doc) => {
24
+ res.writeHead(status, doc === undefined ? {} : { "content-type": "application/json" });
25
+ res.end(doc === undefined ? undefined : JSON.stringify(doc));
26
+ };
27
+ const handle = (req, res, body) => {
28
+ const path = (req.url ?? "/").split("?")[0];
29
+ if (req.method === "GET" && path === "/app/installations")
30
+ return answer(res, 200, [installation]);
31
+ if (req.method === "GET" && path === `/app/installations/${installation.id}`)
32
+ return answer(res, 200, installation);
33
+ if (req.method === "POST" && path === `/app/installations/${installation.id}/access_tokens`) {
34
+ let asked = {};
35
+ try {
36
+ asked = JSON.parse(body || "{}");
37
+ }
38
+ catch {
39
+ return answer(res, 400, { message: "Problems parsing JSON" });
40
+ }
41
+ const names = Array.isArray(asked.repositories) ? asked.repositories.filter((name) => typeof name === "string") : undefined;
42
+ if (names && covered(names).length !== names.length)
43
+ return answer(res, 422, { message: "There is at least one repository that does not exist or is not accessible to the parent installation." });
44
+ const token = `faux-installation-token-${randomBytes(16).toString("hex")}`;
45
+ tokens.set(token, names);
46
+ return answer(res, 201, { token, expires_at: new Date(Date.now() + TOKEN_MS).toISOString(), permissions: { metadata: "read", contents: "read", pull_requests: "write", issues: "read" }, repository_selection: "selected" });
47
+ }
48
+ const bearer = String(req.headers.authorization ?? "").replace(/^Bearer /, "");
49
+ if (req.method === "GET" && path === "/installation/repositories") {
50
+ if (!tokens.has(bearer))
51
+ return answer(res, 401, { message: "Bad credentials" });
52
+ const full = covered(tokens.get(bearer));
53
+ return answer(res, 200, { total_count: full.length, repositories: full.map((name) => ({ name: name.split("/")[1], full_name: name })) });
54
+ }
55
+ if (req.method === "DELETE" && path === "/installation/token") {
56
+ if (!tokens.delete(bearer))
57
+ return answer(res, 401, { message: "Bad credentials" });
58
+ return answer(res, 204);
59
+ }
60
+ const repo = /^\/repos\/([^/]+)\/([^/]+)\/installation$/.exec(path);
61
+ if (req.method === "GET" && repo)
62
+ return FAUX_GITHUB.repositories.includes(`${repo[1]}/${repo[2]}`) ? answer(res, 200, installation) : answer(res, 404, { message: "Not Found" });
63
+ return answer(res, 404, { message: "Not Found" });
64
+ };
65
+ const server = createServer((req, res) => {
66
+ let body = "";
67
+ req.setEncoding("utf8").on("data", (chunk) => (body += chunk)).on("end", () => handle(req, res, body));
68
+ });
69
+ const host = "127.0.0.1";
70
+ await new Promise((resolve, reject) => server.once("error", reject).listen(0, host, () => resolve()));
71
+ return {
72
+ url: `http://${host}:${server.address().port}`,
73
+ app,
74
+ close: () => new Promise((resolve) => (server.close(() => resolve()), server.closeAllConnections())),
75
+ };
76
+ }
package/dist/github.d.ts CHANGED
@@ -57,8 +57,12 @@ export declare const GITHUB_FIELDS: {
57
57
  export declare const GITHUB_SCOPE = "server";
58
58
  /** The repository a run is about, from its first message: the GitHub event it was started for (the server's own payload
59
59
  * tag, the first one, with its installation and repository), else the first https://github.com/<owner>/<repo> its owner's
60
- * words name, before any payload (a sender's text is never read for it). Undefined when it names none. */
61
- export declare function githubTargetOf(content: unknown): {
60
+ * words name, before any payload (a sender's text is never read for it). Undefined when it names none. The tag is read only
61
+ * for a run a github trigger started (`payload`, from its launch's inputOrigin): anyone may write the tag's text into a
62
+ * run of their own, and it names an installation. */
63
+ export declare function githubTargetOf(content: unknown, { payload }?: {
64
+ payload?: boolean;
65
+ }): {
62
66
  installation?: number;
63
67
  repo: string;
64
68
  } | undefined;
package/dist/github.js CHANGED
@@ -101,12 +101,14 @@ const unescapeAttr = (value) => value.replace(/&quot;/g, '"').replace(/&lt;/g, "
101
101
  const REPO_URL = /https:\/\/github\.com\/([A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38})\/([A-Za-z0-9._-]{1,100})/;
102
102
  /** The repository a run is about, from its first message: the GitHub event it was started for (the server's own payload
103
103
  * tag, the first one, with its installation and repository), else the first https://github.com/<owner>/<repo> its owner's
104
- * words name, before any payload (a sender's text is never read for it). Undefined when it names none. */
105
- export function githubTargetOf(content) {
104
+ * words name, before any payload (a sender's text is never read for it). Undefined when it names none. The tag is read only
105
+ * for a run a github trigger started (`payload`, from its launch's inputOrigin): anyone may write the tag's text into a
106
+ * run of their own, and it names an installation. */
107
+ export function githubTargetOf(content, { payload = false } = {}) {
106
108
  if (typeof content !== "string")
107
109
  return undefined;
108
110
  const at = content.indexOf("<trigger-payload ");
109
- if (at >= 0) {
111
+ if (at >= 0 && payload) {
110
112
  const tag = content.slice(at, content.indexOf(">", at) + 1);
111
113
  const attrs = Object.fromEntries([...tag.matchAll(/ ([a-z][a-z0-9_-]*)="([^"]*)"/g)].map((m) => [m[1], unescapeAttr(m[2])]));
112
114
  if (attrs.source === "github" && typeof attrs.repo === "string" && /^[^/\s]+\/[^/\s]+$/.test(attrs.repo))
@@ -19,9 +19,11 @@ export declare const graphWalks: {
19
19
  * - its nodes, each decision and each call through servedPart (a map item's label and an error cut short after);
20
20
  * - every other top-level field (its run, its workflow, its structure `graph`, which echoes the workflow's nodes and their
21
21
  * words, its totals, and any field added later) through redactedOutput, each by itself, its keys included;
22
- * - `read_at`, which moves with every read, cut on its own each time, never kept.
23
- * Each part and each field is walked once per content and held set and kept in `cache`, so a poll that reads the same graph
24
- * with the same values walks nothing, and a key saved since makes a new set. What holds no held value (ids, times,
22
+ * - `read_at`, which moves with every read: the server's clock as toISOString writes it, served as it is, never kept;
23
+ * anything else under the name is cut each read.
24
+ * Each part and each field, its name and its value, scalar or not, is cut once per content and held set and kept in
25
+ * `cache` as cut (never as read), so a poll that reads the same graph with the same values cuts nothing again, and a key
26
+ * saved since makes a new set, cut on the next read. What holds no held value (ids, times,
25
27
  * statuses) comes through as it was. */
26
28
  export declare function servedGraphView<T extends {
27
29
  nodes: unknown;
@@ -38,14 +38,18 @@ export function servedPart(kind, value, values) {
38
38
  * nothing, with no clock. */
39
39
  export const graphWalks = { part: 0, rest: 0 };
40
40
  const isRecordOrArray = (value) => typeof value === "object" && value !== null;
41
+ /** A time as Date's toISOString writes it, and nothing else: digits, its fixed separators and Z. */
42
+ const ISO_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
41
43
  /** A graph view as GET /runs/{id}/graph serves it with `values` held, every field of it cut by the one rule (redactedOutput
42
44
  * over the same values), the parts by the file path's rule on top:
43
45
  * - its nodes, each decision and each call through servedPart (a map item's label and an error cut short after);
44
46
  * - every other top-level field (its run, its workflow, its structure `graph`, which echoes the workflow's nodes and their
45
47
  * words, its totals, and any field added later) through redactedOutput, each by itself, its keys included;
46
- * - `read_at`, which moves with every read, cut on its own each time, never kept.
47
- * Each part and each field is walked once per content and held set and kept in `cache`, so a poll that reads the same graph
48
- * with the same values walks nothing, and a key saved since makes a new set. What holds no held value (ids, times,
48
+ * - `read_at`, which moves with every read: the server's clock as toISOString writes it, served as it is, never kept;
49
+ * anything else under the name is cut each read.
50
+ * Each part and each field, its name and its value, scalar or not, is cut once per content and held set and kept in
51
+ * `cache` as cut (never as read), so a poll that reads the same graph with the same values cuts nothing again, and a key
52
+ * saved since makes a new set, cut on the next read. What holds no held value (ids, times,
49
53
  * statuses) comes through as it was. */
50
54
  export function servedGraphView(view, values, cache) {
51
55
  const digest = (value) => createHash("sha256").update(JSON.stringify(value) ?? "").digest("hex");
@@ -62,11 +66,15 @@ export function servedGraphView(view, values, cache) {
62
66
  const { nodes, decisions, effects, read_at: readAt, ...rest } = view;
63
67
  const fields = {};
64
68
  for (const [name, value] of Object.entries(rest)) {
65
- const cutName = redactedOutput(name, values);
66
- fields[cutName] = isRecordOrArray(value) ? kept(`field:${keys}:${name}:${digest(value)}`, () => (graphWalks.rest++, redactedOutput(value, values))) : redactedOutput(value, values);
69
+ // A field's name and its value, scalar or not, each cut once per content and held set: a poll walks none again.
70
+ // (graphWalks.rest counts the walks of a field that holds more than one value, as before.)
71
+ const cutName = kept(`name:${keys}:${digest(name)}`, () => redactedOutput(name, values));
72
+ fields[cutName] = kept(`field:${keys}:${digest(name)}:${digest(value)}`, () => (isRecordOrArray(value) && graphWalks.rest++, redactedOutput(value, values)));
67
73
  }
68
74
  return {
69
- ...(readAt === undefined ? {} : { read_at: redactedOutput(readAt, values) }),
75
+ // The read's own time, the server's clock as toISOString writes it, holds nothing of the run: served as it is. Any other
76
+ // value under the name is cut, each read, as before.
77
+ ...(readAt === undefined ? {} : { read_at: typeof readAt === "string" && ISO_TIME.test(readAt) ? readAt : redactedOutput(readAt, values) }),
70
78
  ...fields,
71
79
  nodes: part("nodes", nodes),
72
80
  decisions: decisions.map((value) => part("decision", value)),
@@ -1,4 +1,5 @@
1
- import { llmAnswers, readLiveView, readNodeLog } from "./pause.js";
1
+ import { llmAnswers, readLiveView } from "./pause.js";
2
+ import { KINDS } from "./runner/journal-kinds.js";
2
3
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
4
  const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
5
  const at = (state, path) => path.split(".").reduce((value, key) => (isObject(value) ? value[key] : undefined), state);
@@ -49,7 +50,9 @@ export async function runGraph(given) {
49
50
  readAt = live.at;
50
51
  view = { status: nodeStatus(graph, { pin: pin, result: null }) };
51
52
  }
52
- const lines = await readNodeLog(given.root);
53
+ // The call nodes' effects, as the runner logged each one's start and end on the run's journal (KINDS.nodeEffect).
54
+ const { runEntries } = await import("./store-reads/journal.js");
55
+ const lines = (await runEntries(given.store, id, given.context)).filter((entry) => entry.kind === KINDS.nodeEffect).map((entry) => entry.data);
53
56
  const nodeAt = (path) => (typeof path === "string" ? (graphNodeOf(graph, path)?.path ?? (graph.nodes.some((n) => n.path === path) ? path : undefined)) : undefined);
54
57
  const kinds = new Map(graph.nodes.map((node) => [node.path, node.kind]));
55
58
  // Each node's state, `not-run` read as pending until the run ends.
@@ -339,7 +339,6 @@ export function openCodeHarness(options, control) {
339
339
  }
340
340
  if (event.type === "session.error" && turn) {
341
341
  const error = isPlain(p.error) ? p.error : {};
342
- const data = isPlain(error.data) ? error.data : {};
343
342
  if (error.name === "MessageAbortedError")
344
343
  turn.error = undefined;
345
344
  else
@@ -1,4 +1,4 @@
1
- import { providerInputOverhead, ProxyRefusal } from "@parcha/agentrun-kernel/host";
1
+ import { providerInputOverhead, ProxyRefusal, responsesImagesIn } from "@parcha/agentrun-kernel/host";
2
2
  /** The prefix OpenCode gives the adapter's MCP tools: the server is `hands`. */
3
3
  export const TOOL_PREFIX = "hands_";
4
4
  export const OPENCODE_RESPONSES_ROUTES = Object.freeze([
@@ -229,7 +229,7 @@ function itemsIn(value, type) {
229
229
  export function responsesServerInputOverhead(body) {
230
230
  if (itemsIn(body.input, "input_file") > 0)
231
231
  throw new Error("a file input's billed size has no stated bound");
232
- return providerInputOverhead("openai-responses", { tools: Array.isArray(body.tools) && body.tools.length > 0, images: itemsIn(body.input, "input_image") });
232
+ return providerInputOverhead("openai-responses", { tools: Array.isArray(body.tools) && body.tools.length > 0, images: responsesImagesIn(body.input), ...(typeof body.model === "string" ? { model: body.model } : {}) });
233
233
  }
234
234
  /** An event that is not whole by this many characters is not read. */
235
235
  const EVENT_CAP = 4 * 1024 * 1024;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { capabilities, CONTRACT, DEFAULT_PORT, type Serve, type ServeOptions, startServe } from "./server.js";
2
+ export { serveWithRunner } from "./runner/beside.js";
2
3
  export { SERVER_LOCK, type ServerLock, ServerLockHeldError, takeServerLock } from "./server-lock.js";
3
4
  export { ApiError, ERROR_STATUS, type ErrorCode } from "./errors.js";
4
5
  export { defaultMaxRuns, type Health } from "./host.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { capabilities, CONTRACT, DEFAULT_PORT, startServe } from "./server.js";
2
+ export { serveWithRunner } from "./runner/beside.js";
2
3
  export { SERVER_LOCK, ServerLockHeldError, takeServerLock } from "./server-lock.js";
3
4
  export { ApiError, ERROR_STATUS } from "./errors.js";
4
5
  export { defaultMaxRuns } from "./host.js";
@@ -1,5 +1,5 @@
1
1
  import { type LearnedNote } from "./notes.js";
2
- import { type DraftDryRun, type DraftReader } from "./skills.js";
2
+ import { type DraftAsk, type DraftDryRun, type DraftReader } from "./skills.js";
3
3
  /** Byte caps (UTF-8) and counts. Over a cap is refused, never cut. */
4
4
  export declare const CAPS: Readonly<{
5
5
  /** One note's file. */
@@ -65,6 +65,8 @@ export type CheckInput = {
65
65
  /** The agent's granted tools the gate does not allow, with what each is set to (tools.ts learnedDraftTools): a draft
66
66
  * whose call node calls one is refused, in the words a workflow revision's is (learn/skills.ts gatedNodes). */
67
67
  readonly gated?: Readonly<Record<string, string>>;
68
+ /** The MCP tools set to ask a learned call would ask about, and the gate's card rule (skills.ts DraftAsk, #2424). */
69
+ readonly ask?: DraftAsk;
68
70
  /** Where each of `gated`'s denies was set (this agent's settings or this server's), for the refusal's words. */
69
71
  readonly deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
70
72
  /** The workflow DSL a draft is read with; a proposal that holds a draft is checked with it, never without. */
@@ -153,7 +153,7 @@ function learnedChecked(change, place, refused, input, add) {
153
153
  if (place.kind === "workflow") {
154
154
  if (!input.dsl)
155
155
  throw new TypeError(`${path}: a workflow draft is read with the workflow DSL, which was not given`);
156
- const problems = draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy);
156
+ const problems = draftProblems(input.dsl, text, input.tools, input.gated, input.deniedBy, input.ask);
157
157
  for (const { rule, detail } of problems)
158
158
  add(rule, detail, path);
159
159
  // A draft the checks pass whose dry run failed: its wiring breaks at run time, before any node is paid for.
@@ -256,8 +256,8 @@ export function checkProposal(input) {
256
256
  const note = textChecked(path, change.size ?? change.bytes?.length ?? 0, change.bytes, refused, add, true);
257
257
  if (!note)
258
258
  return;
259
- if (note.keys.includes("status") || note.keys.includes("superseded_by") || note.keys.includes("origin"))
260
- return add("status", "a run never sets status, superseded_by or origin: the host does, when it merges the note or a later one supersedes it", path);
259
+ if (["status", "superseded_by", "retired_from", "origin"].some((key) => note.keys.includes(key)))
260
+ return add("status", "a run never sets status, superseded_by, retired_from or origin: the host does, when it merges the note, a later one supersedes it or a person retires it", path);
261
261
  notes.push(note);
262
262
  };
263
263
  for (const change of changes)