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

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 (350) hide show
  1. package/CHANGELOG.md +148 -5
  2. package/README.md +385 -305
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +62 -19
  28. package/dist/composio-preset.js +69 -7
  29. package/dist/composio-triggers.d.ts +14 -0
  30. package/dist/composio-triggers.js +79 -15
  31. package/dist/computer-attach.d.ts +40 -5
  32. package/dist/computer-attach.js +130 -15
  33. package/dist/computer-keys.d.ts +3 -0
  34. package/dist/computer-keys.js +7 -1
  35. package/dist/computer-live.js +3 -2
  36. package/dist/computers.d.ts +21 -10
  37. package/dist/computers.js +39 -28
  38. package/dist/console/assets/index-C2MYaUBa.css +1 -0
  39. package/dist/console/assets/index-CZZeCReB.js +701 -0
  40. package/dist/console/index.html +2 -2
  41. package/dist/decisions.d.ts +1 -1
  42. package/dist/dial-relay.d.ts +29 -0
  43. package/dist/dial-relay.js +94 -0
  44. package/dist/email/tools.js +10 -5
  45. package/dist/env-proxy.d.ts +2 -0
  46. package/dist/env-proxy.js +35 -0
  47. package/dist/errors.d.ts +3 -1
  48. package/dist/errors.js +7 -4
  49. package/dist/faux-computers.d.ts +8 -2
  50. package/dist/faux-computers.js +83 -6
  51. package/dist/harness-archive.d.ts +67 -0
  52. package/dist/harness-archive.js +177 -0
  53. package/dist/harness-goose.d.ts +34 -0
  54. package/dist/harness-goose.js +87 -0
  55. package/dist/harness-install.d.ts +21 -0
  56. package/dist/harness-install.js +24 -11
  57. package/dist/harness-opencode/adapter.js +1 -1
  58. package/dist/harness-table.d.ts +9 -1
  59. package/dist/harness-table.js +20 -3
  60. package/dist/harness.d.ts +1 -2
  61. package/dist/harness.js +3 -4
  62. package/dist/host.js +2 -1
  63. package/dist/import.d.ts +10 -0
  64. package/dist/import.js +28 -8
  65. package/dist/key-check.js +3 -0
  66. package/dist/learn/audit.d.ts +6 -6
  67. package/dist/learn/audit.js +3 -7
  68. package/dist/learn/check.d.ts +23 -89
  69. package/dist/learn/check.js +57 -335
  70. package/dist/learn/commit.d.ts +63 -90
  71. package/dist/learn/commit.js +124 -316
  72. package/dist/learn/compile.d.ts +53 -50
  73. package/dist/learn/compile.js +89 -104
  74. package/dist/learn/corrections.d.ts +13 -0
  75. package/dist/learn/corrections.js +23 -0
  76. package/dist/learn/delete.d.ts +5 -5
  77. package/dist/learn/delete.js +8 -10
  78. package/dist/learn/folder.d.ts +35 -47
  79. package/dist/learn/folder.js +118 -134
  80. package/dist/learn/index.d.ts +3 -5
  81. package/dist/learn/index.js +6 -9
  82. package/dist/learn/learning.sh +45 -15
  83. package/dist/learn/promote.d.ts +23 -5
  84. package/dist/learn/promote.js +40 -2
  85. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
  86. package/dist/learn/{skills.js → workflow-draft.js} +48 -58
  87. package/dist/learn/workflow-nodes.js +1 -1
  88. package/dist/learned-workflow.js +2 -2
  89. package/dist/learning-cost.d.ts +38 -24
  90. package/dist/learning-cost.js +41 -24
  91. package/dist/learning-routes.d.ts +91 -170
  92. package/dist/learning-routes.js +183 -421
  93. package/dist/learning-run.d.ts +19 -40
  94. package/dist/learning-run.js +23 -93
  95. package/dist/learning-setting.d.ts +21 -10
  96. package/dist/learning-setting.js +47 -11
  97. package/dist/learning-words.d.ts +28 -74
  98. package/dist/learning-words.js +64 -162
  99. package/dist/learning.d.ts +61 -392
  100. package/dist/learning.js +101 -651
  101. package/dist/live-reach.d.ts +25 -2
  102. package/dist/live-reach.js +46 -4
  103. package/dist/llms.txt +1 -1
  104. package/dist/local-models.d.ts +3 -11
  105. package/dist/local-models.js +5 -6
  106. package/dist/mcp-servers-store.d.ts +4 -4
  107. package/dist/model-form.js +6 -5
  108. package/dist/model.d.ts +4 -0
  109. package/dist/model.js +26 -9
  110. package/dist/native/binding.js +1 -1
  111. package/dist/native/connection.js +1 -1
  112. package/dist/native/discovery.js +1 -1
  113. package/dist/native/instructions.d.ts +3 -0
  114. package/dist/native/instructions.js +5 -3
  115. package/dist/native/remote-worker-bridge.js +9 -43
  116. package/dist/native/remote.d.ts +8 -15
  117. package/dist/native/remote.js +3 -3
  118. package/dist/native/schema.js +1 -1
  119. package/dist/native/types.d.ts +2 -2
  120. package/dist/openapi.js +273 -319
  121. package/dist/paid-calls.d.ts +8 -0
  122. package/dist/paid-calls.js +20 -0
  123. package/dist/particle-provider.d.ts +11 -0
  124. package/dist/particle-provider.js +135 -0
  125. package/dist/port-models.d.ts +12 -4
  126. package/dist/port-models.js +28 -11
  127. package/dist/print.d.ts +27 -0
  128. package/dist/print.js +21 -0
  129. package/dist/provider.d.ts +7 -0
  130. package/dist/provider.js +15 -1
  131. package/dist/reflect-range.js +2 -3
  132. package/dist/run-launch.d.ts +14 -28
  133. package/dist/run-launch.js +9 -12
  134. package/dist/run-learning-served.d.ts +15 -89
  135. package/dist/run-listing.d.ts +34 -0
  136. package/dist/run-listing.js +128 -0
  137. package/dist/run-model-key.js +1 -1
  138. package/dist/run-timeline-served.js +5 -3
  139. package/dist/run-trace.d.ts +97 -0
  140. package/dist/run-trace.js +253 -0
  141. package/dist/run-view.d.ts +15 -0
  142. package/dist/run-view.js +9 -0
  143. package/dist/runnable.js +2 -1
  144. package/dist/runner/adapter-loop.d.ts +8 -6
  145. package/dist/runner/adapter-loop.js +16 -12
  146. package/dist/runner/adapter-run-spec.d.ts +16 -4
  147. package/dist/runner/adapter-run-spec.js +64 -58
  148. package/dist/runner/adapters/index.js +22 -0
  149. package/dist/runner/adapters/pi.d.ts +4 -12
  150. package/dist/runner/adapters/pi.js +2 -2
  151. package/dist/runner/audit.d.ts +1 -1
  152. package/dist/runner/audit.js +30 -13
  153. package/dist/runner/beside.d.ts +6 -2
  154. package/dist/runner/beside.js +38 -9
  155. package/dist/runner/claim-secrets.d.ts +18 -2
  156. package/dist/runner/claim-secrets.js +42 -18
  157. package/dist/runner/cli-run-spec.js +55 -51
  158. package/dist/runner/conformance/harness.d.ts +6 -0
  159. package/dist/runner/conformance/harness.js +35 -13
  160. package/dist/runner/conformance/subject.d.ts +6 -0
  161. package/dist/runner/dispatch.d.ts +2 -2
  162. package/dist/runner/end-of-run.d.ts +6 -14
  163. package/dist/runner/end-of-run.js +8 -33
  164. package/dist/runner/feedback-round.d.ts +2 -2
  165. package/dist/runner/feedback-round.js +7 -7
  166. package/dist/runner/github-app.js +3 -1
  167. package/dist/runner/harness-loops.d.ts +0 -8
  168. package/dist/runner/harness-loops.js +11 -59
  169. package/dist/runner/held.d.ts +170 -0
  170. package/dist/runner/held.js +57 -0
  171. package/dist/runner/journal-kinds.d.ts +2 -3
  172. package/dist/runner/journal-kinds.js +2 -3
  173. package/dist/runner/learned-first.d.ts +40 -0
  174. package/dist/runner/learned-first.js +32 -0
  175. package/dist/runner/learning-end.d.ts +77 -69
  176. package/dist/runner/learning-end.js +250 -303
  177. package/dist/runner/learning-seed.d.ts +15 -33
  178. package/dist/runner/learning-seed.js +24 -45
  179. package/dist/runner/loop-contract.d.ts +2 -3
  180. package/dist/runner/main.d.ts +17 -9
  181. package/dist/runner/main.js +82 -20
  182. package/dist/runner/mcp-run.d.ts +11 -0
  183. package/dist/runner/mcp-run.js +67 -0
  184. package/dist/runner/memory-claim.d.ts +10 -5
  185. package/dist/runner/memory-claim.js +12 -6
  186. package/dist/runner/model-route.d.ts +7 -4
  187. package/dist/runner/model-route.js +22 -10
  188. package/dist/runner/native-loop.d.ts +0 -7
  189. package/dist/runner/native-loop.js +9 -101
  190. package/dist/runner/promotion.d.ts +12 -8
  191. package/dist/runner/promotion.js +37 -28
  192. package/dist/runner/reflect-hook.d.ts +64 -95
  193. package/dist/runner/reflect-hook.js +112 -225
  194. package/dist/runner/run-channel.d.ts +43 -0
  195. package/dist/runner/run-channel.js +467 -0
  196. package/dist/runner/run-child-host.d.ts +169 -0
  197. package/dist/runner/run-child-host.js +1230 -0
  198. package/dist/runner/run-child.d.ts +1 -0
  199. package/dist/runner/run-child.js +254 -0
  200. package/dist/runner/run-errors.d.ts +2 -0
  201. package/dist/runner/run-errors.js +20 -0
  202. package/dist/runner/runner.js +1 -5
  203. package/dist/runner/sdk-ask.d.ts +78 -0
  204. package/dist/runner/sdk-ask.js +158 -0
  205. package/dist/runner/sdk-loop.d.ts +2 -4
  206. package/dist/runner/sdk-loop.js +29 -49
  207. package/dist/runner/store-secrets.d.ts +5 -3
  208. package/dist/runner/store-secrets.js +5 -1
  209. package/dist/runner/workflow-first.d.ts +5 -0
  210. package/dist/runner/workflow-first.js +4 -0
  211. package/dist/runner/workflow-spec.js +7 -2
  212. package/dist/runs-over-store.d.ts +16 -28
  213. package/dist/runs-over-store.js +31 -38
  214. package/dist/sdk/runs.d.ts +6 -11
  215. package/dist/sdk/runs.js +20 -41
  216. package/dist/sdk/schema.js +3 -4
  217. package/dist/seal-key.d.ts +5 -0
  218. package/dist/seal-key.js +7 -0
  219. package/dist/secrets.d.ts +3 -0
  220. package/dist/secrets.js +16 -3
  221. package/dist/server.d.ts +55 -33
  222. package/dist/server.js +689 -322
  223. package/dist/sign-ins-store.d.ts +8 -0
  224. package/dist/sign-ins-store.js +36 -1
  225. package/dist/skills.js +1 -1
  226. package/dist/store/index.d.ts +2 -2
  227. package/dist/store/index.js +1 -1
  228. package/dist/store/journal/storage.js +3 -0
  229. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  230. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  231. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  232. package/dist/store/schema.d.ts +53 -4
  233. package/dist/store/schema.js +137 -6
  234. package/dist/store/sqlite/connection.d.ts +2 -0
  235. package/dist/store/sqlite/connection.js +3 -1
  236. package/dist/store/sqlite/run-patch.d.ts +0 -17
  237. package/dist/store/sqlite/run-patch.js +4 -33
  238. package/dist/store/sqlite/store.js +246 -63
  239. package/dist/store/sqlite/worker.js +25 -0
  240. package/dist/store/store.d.ts +193 -36
  241. package/dist/store/store.js +25 -3
  242. package/dist/store-reads/learning.d.ts +102 -204
  243. package/dist/store-reads/learning.js +159 -321
  244. package/dist/store-reads/loop.d.ts +0 -1
  245. package/dist/store-reads/loop.js +1 -1
  246. package/dist/store-view.d.ts +29 -1
  247. package/dist/store-view.js +97 -31
  248. package/dist/template-eval.d.ts +3 -6
  249. package/dist/template-eval.js +22 -36
  250. package/dist/templates.d.ts +8 -4
  251. package/dist/templates.js +44 -6
  252. package/dist/timeline/index.d.ts +1 -1
  253. package/dist/timeline/index.js +1 -1
  254. package/dist/timeline/timeline.d.ts +5 -1
  255. package/dist/timeline/timeline.js +16 -0
  256. package/dist/tool-gate.d.ts +0 -7
  257. package/dist/tool-gate.js +1 -15
  258. package/dist/tool-keys-store.d.ts +1 -1
  259. package/dist/tool-keys.d.ts +6 -4
  260. package/dist/tool-keys.js +12 -6
  261. package/dist/tools.d.ts +2 -2
  262. package/dist/tools.js +11 -4
  263. package/dist/triggers.d.ts +65 -6
  264. package/dist/triggers.js +125 -19
  265. package/dist/validate.js +1 -1
  266. package/dist/webhooks.d.ts +7 -2
  267. package/dist/webhooks.js +12 -5
  268. package/dist/workspace/agent-computer.d.ts +2 -0
  269. package/dist/workspace/agent-computer.js +2 -0
  270. package/dist/workspace/archil-claim.d.ts +7 -0
  271. package/dist/workspace/archil-claim.js +29 -0
  272. package/dist/workspace/archil.d.ts +9 -1
  273. package/dist/workspace/archil.js +165 -3
  274. package/dist/workspace/attach.d.ts +3 -1
  275. package/dist/workspace/attach.js +2 -0
  276. package/dist/workspace/attached-computers.d.ts +16 -5
  277. package/dist/workspace/attached-computers.js +25 -9
  278. package/dist/workspace/computer-deps.js +1 -1
  279. package/dist/workspace/computer-for-claim.d.ts +7 -3
  280. package/dist/workspace/computer-for-claim.js +119 -22
  281. package/dist/workspace/computer-hold.js +2 -1
  282. package/dist/workspace/computer-kept.d.ts +11 -1
  283. package/dist/workspace/computer-kept.js +24 -3
  284. package/dist/workspace/resolve-computer.d.ts +33 -19
  285. package/dist/workspace/resolve-computer.js +172 -64
  286. package/dist/workspace/revision-skills.d.ts +1 -2
  287. package/dist/workspace/revision-skills.js +3 -4
  288. package/dist/workspace/run-workspace.d.ts +1 -1
  289. package/dist/workspace/run-workspace.js +5 -0
  290. package/dist/workspace/synced-folder.d.ts +85 -0
  291. package/dist/workspace/synced-folder.js +230 -0
  292. package/dist/workspace/workspace.d.ts +4 -0
  293. package/launcher/agentrun-serve +1 -1
  294. package/package.json +10 -10
  295. package/templates/README.md +8 -8
  296. package/templates/inbound-lead/agent.md +5 -4
  297. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  298. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  299. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  300. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  301. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  302. package/templates/inbound-lead/lead.schema.json +6 -5
  303. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  304. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  305. package/templates/kyb/agent.md +2 -1
  306. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  307. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  308. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  309. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  310. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  311. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  312. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  313. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  314. package/dist/console/assets/index-BUktRvS-.css +0 -1
  315. package/dist/console/assets/index-nB9kTfIN.js +0 -711
  316. package/dist/learn/grade.d.ts +0 -138
  317. package/dist/learn/grade.js +0 -682
  318. package/dist/learn/notes.d.ts +0 -81
  319. package/dist/learn/notes.js +0 -178
  320. package/dist/learn/reflect.d.ts +0 -77
  321. package/dist/learn/reflect.js +0 -228
  322. package/dist/learn/relevance.d.ts +0 -24
  323. package/dist/learn/relevance.js +0 -91
  324. package/dist/learn/seed-check.d.ts +0 -74
  325. package/dist/learn/seed-check.js +0 -103
  326. package/dist/learning-batch.d.ts +0 -291
  327. package/dist/learning-batch.js +0 -600
  328. package/dist/learning-evals.d.ts +0 -35
  329. package/dist/learning-evals.js +0 -99
  330. package/dist/native/context.d.ts +0 -6
  331. package/dist/native/context.js +0 -22
  332. package/dist/propose.d.ts +0 -52
  333. package/dist/propose.js +0 -224
  334. package/dist/runner/learning-ask.d.ts +0 -47
  335. package/dist/runner/learning-ask.js +0 -128
  336. package/dist/runner/learning-dispatch.d.ts +0 -45
  337. package/dist/runner/learning-dispatch.js +0 -99
  338. package/dist/runner/learning-factory.d.ts +0 -16
  339. package/dist/runner/learning-factory.js +0 -50
  340. package/dist/runner/learning-loop.d.ts +0 -273
  341. package/dist/runner/learning-loop.js +0 -521
  342. package/dist/usage.d.ts +0 -11
  343. package/dist/usage.js +0 -11
  344. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  345. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  346. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  347. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  348. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  349. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  350. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -103,12 +103,14 @@ export interface AuditHold {
103
103
  readonly disagreements: readonly AuditDisagreement[];
104
104
  readonly stopped?: true;
105
105
  }
106
- /** The bar a compiled draft's check was started with: the agent definition's loop numbers then (learning-setting.ts), and
107
- * which check of the compile it is (`attempt`: 1, the first draft's; 2, the one recompile's, after which it stops). */
106
+ /** The bar a compiled draft's check was started with: the agent definition's loop numbers then (learning-setting.ts), the
107
+ * answer paths it compares on (`agree_on`, the definition's; absent, the whole answer), and which check of the compile
108
+ * it is (`attempt`: 1, the first draft's; 2, the one recompile's, after which it stops). */
108
109
  export interface CheckBar {
109
110
  readonly compile_after: number;
110
111
  readonly agree_min: number;
111
112
  readonly alone_min: number;
113
+ readonly agree_on?: readonly string[];
112
114
  readonly attempt: 1 | 2;
113
115
  }
114
116
  /** One input a check's draft did not agree on: the agent's run (`run`) and its input, the agent's recorded answer
@@ -212,6 +214,18 @@ export declare function servingOf(records: readonly PromotionRecord[]): {
212
214
  digest: string | null;
213
215
  replaying: string | null;
214
216
  }[];
217
+ /** Where a learned workflow stands, the one word both the promotions read (`serving[].state`) and the learning view
218
+ * (`workflows[].status`, a draft neither pending nor retired) say: `checking`, its newest record is a check at work, or
219
+ * it has no record yet (the first claim that lays it and takes its input starts its check; an older revision that
220
+ * serves keeps serving meanwhile, else the agent takes the runs); `serving`, a revision serves (championOf) and the
221
+ * money rule lets it run first; `stopped`, the money rule stopped its champion running first (`costStop`, at the
222
+ * champion's digest: no record says so, the agent takes its runs), or none serves and its newest record is a hold that
223
+ * stops it (a recompile's check, a second audit hold, nothing to check it on); `held`, else. */
224
+ export type ServingState = "serving" | "checking" | "held" | "stopped";
225
+ /** Whether the money rule stops `workflow` at `digest` from running first: runner/workflow-first.ts costStopOf over the
226
+ * agent's runs, the decision a run's claim reads (workflowFirstOf). */
227
+ export type CostStop = (workflow: string, digest: string) => boolean;
228
+ export declare function servingStateOf(records: readonly PromotionRecord[], workflow: string, costStop: CostStop): ServingState;
215
229
  /** The promotions list as it leaves (GET /agents/{id}/learning/promotions): the records and what serves (servingOf), every
216
230
  * text in them cut by `shown` (learning.ts secretsShown, as the other learning reads cut theirs), at any depth and under
217
231
  * any field, so a field added later is cut too: a workflow's name whole (`shown.name`), any other text of its part
@@ -251,8 +265,12 @@ export declare function trimPromotions(items: readonly PromotionRecord[]): Promo
251
265
  /** How many of a replay's own runs ended each way (a run not ended past its deadline is failed): what each run did. A
252
266
  * check record keeps them as it was decided on. */
253
267
  export type ReplayOutcomes = Readonly<Record<ReplayOutcome, number>>;
254
- /** Whether two answers say the same: equal as JSON values, else as trimmed text. */
255
- export declare const sameAnswer: (a: string | null, b: string | null) => boolean;
268
+ /** Whether two answers say the same: equal as JSON values, else as trimmed text. On `on` (the revision's agree_on,
269
+ * dotted paths into the answer's JSON object): each path resolves in both answers to equal values; a path that does
270
+ * not resolve in either (a key missing, a segment through an array, text or null) disagrees, on both sides too. */
271
+ export declare function sameAnswer(a: string | null, b: string | null, on?: readonly string[]): boolean;
272
+ /** The fields a check or an audit compared on, in words: "mcc", "mcc and riskTier", "mcc, riskTier and siteStatus". */
273
+ export declare const fieldsWords: (on: readonly string[]) => string;
256
274
  /** A grade as the API answers it (PUT /runs/{id}/grade; GET /runs/{id}/learning's `graded`, without `expected`). */
257
275
  export declare const gradeView: (grade: Grade) => {
258
276
  source: "feedback" | "eval";
@@ -260,7 +278,7 @@ export declare const gradeView: (grade: Grade) => {
260
278
  path: "agent" | "workflow" | "replay" | "handed_back" | "audit";
261
279
  workflow: string | null;
262
280
  workflow_digest: string | null;
263
- feedback: "look_back" | null;
281
+ feedback: "correction" | null;
264
282
  expected?: Readonly<Record<string, unknown>> | undefined;
265
283
  run_id: string;
266
284
  correct: boolean;
@@ -1,4 +1,5 @@
1
1
  import { answerJson } from "../answer-json.js";
2
+ import { pathSegments } from "../learning-setting.js";
2
3
  /** How many grades, and how many promotion records, an agent keeps (newest kept). */
3
4
  export const GRADES_KEPT = 500;
4
5
  export const PROMOTIONS_KEPT = 200;
@@ -131,6 +132,15 @@ export function servingOf(records) {
131
132
  return { workflow, digest, replaying: replayingOf(records, workflow, digest)[0]?.digest ?? null };
132
133
  });
133
134
  }
135
+ export function servingStateOf(records, workflow, costStop) {
136
+ const newest = records.findLast((one) => one.workflow === workflow);
137
+ if (newest === undefined || newest.decided === "replaying")
138
+ return "checking";
139
+ const champion = championOf(records, workflow);
140
+ if (champion)
141
+ return costStop(workflow, champion.digest) ? "stopped" : "serving";
142
+ return newest.decided === "hold" && (newest.check?.stopped || newest.audit?.stopped) ? "stopped" : "held";
143
+ }
134
144
  /** The promotions list as it leaves (GET /agents/{id}/learning/promotions): the records and what serves (servingOf), every
135
145
  * text in them cut by `shown` (learning.ts secretsShown, as the other learning reads cut theirs), at any depth and under
136
146
  * any field, so a field added later is cut too: a workflow's name whole (`shown.name`), any other text of its part
@@ -218,8 +228,36 @@ function same(a, b) {
218
228
  const [ka, kb] = [Object.keys(a), Object.keys(b)];
219
229
  return ka.length === kb.length && ka.every((key) => same(a[key], b[key]));
220
230
  }
221
- /** Whether two answers say the same: equal as JSON values, else as trimmed text. */
222
- export const sameAnswer = (a, b) => a !== null && b !== null && same(valueOf(a), valueOf(b));
231
+ const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
232
+ /** Not there: a path of agree_on that does not resolve in an answer. */
233
+ const MISSING = Symbol("missing");
234
+ /** The value at a dotted path (learning-setting.ts pathSegments) of a JSON value: each segment an own key of an object
235
+ * (never an array's index, never through text or null); MISSING when one is not. */
236
+ function valueAt(value, path) {
237
+ let here = value;
238
+ for (const segment of pathSegments(path)) {
239
+ if (!isObject(here) || !Object.hasOwn(here, segment))
240
+ return MISSING;
241
+ here = here[segment];
242
+ }
243
+ return here;
244
+ }
245
+ /** Whether two answers say the same: equal as JSON values, else as trimmed text. On `on` (the revision's agree_on,
246
+ * dotted paths into the answer's JSON object): each path resolves in both answers to equal values; a path that does
247
+ * not resolve in either (a key missing, a segment through an array, text or null) disagrees, on both sides too. */
248
+ export function sameAnswer(a, b, on) {
249
+ if (a === null || b === null)
250
+ return false;
251
+ const [va, vb] = [valueOf(a), valueOf(b)];
252
+ if (!on?.length)
253
+ return same(va, vb);
254
+ return on.every((path) => {
255
+ const [x, y] = [valueAt(va, path), valueAt(vb, path)];
256
+ return x !== MISSING && y !== MISSING && same(x, y);
257
+ });
258
+ }
259
+ /** The fields a check or an audit compared on, in words: "mcc", "mcc and riskTier", "mcc, riskTier and siteStatus". */
260
+ export const fieldsWords = (on) => (on.length < 2 ? on.join("") : `${on.slice(0, -1).join(", ")} and ${on.at(-1)}`);
223
261
  /** A grade as the API answers it (PUT /runs/{id}/grade; GET /runs/{id}/learning's `graded`, without `expected`). */
224
262
  export const gradeView = (grade) => ({
225
263
  run_id: grade.run, correct: grade.correct, ...(grade.expected ? { expected: grade.expected } : {}), source: grade.source, graded_at: grade.at,
@@ -1,24 +1,19 @@
1
1
  import type { assertWorkflowCapabilities, desugarWorkflow, dryRunWorkflow, inspectWorkflow, resolveSchemaForWorkflow, validateWorkflow } from "@parcha/agentrun-dsl";
2
- /** Where a skill and a workflow draft live in the folder. */
3
- export declare const SKILLS_DIR = "skills";
2
+ /** Where a workflow draft lives in the folder. */
4
3
  export declare const WORKFLOWS_DIR = "workflows";
5
- /** The shared skills convention's name: lowercase letters, digits and single dashes, at most 64. */
6
- export declare const SKILL_NAME: RegExp;
7
4
  /** A workflow's name: lowercase letters, digits, dashes and underscores, at most 64, starting with a letter or digit. */
8
5
  export declare const WORKFLOW_NAME: RegExp;
9
- /** A skill's `SKILL.md`, a workflow's `workflow.json` or its `README.md`, by the folder it names. */
6
+ /** A workflow's `workflow.json` or its `README.md`, by the folder it names. */
10
7
  export type LearnedPlace = {
11
- readonly kind: "skill" | "workflow" | "readme";
8
+ readonly kind: "workflow" | "readme";
12
9
  readonly name: string;
13
10
  };
14
- /** Where `path` sits among the skills and workflows, its folder's name as written (unchecked); undefined when it is
15
- * not a skill's or a workflow's file. */
11
+ /** Where `path` sits among the workflows, its folder's name as written (unchecked); undefined when it is not a
12
+ * workflow's file. */
16
13
  export declare function learnedPlace(path: string): LearnedPlace | undefined;
17
- /** Whether `name` is a good name for a folder of `kind`. */
18
- export declare const learnedName: (kind: LearnedPlace["kind"], name: string) => boolean;
19
14
  /** Why a front matter does not read one way, by frontMatter: the words a refusal says. */
20
15
  export declare const UNCLEAR_FRONT = "its front matter does not read one way: each line a `key: value` at its left edge, a comment, or a line of the value above it";
21
- /** A SKILL.md's or a draft README's front matter, read one way, as the one reader of what it says of itself (its keys,
16
+ /** A draft README's front matter, read one way, as the one reader of what it says of itself (its keys,
22
17
  * its name, its description, its status): each key to its value in order, or undefined when it does not read one way,
23
18
  * since another reader (a harness's YAML) could then read a key, a status among them, this one does not. It reads one
24
19
  * way when it starts the text (`---`), closes on a `---` line (the last line or not), and each line between is blank,
@@ -30,33 +25,30 @@ export declare const UNCLEAR_FRONT = "its front matter does not read one way: ea
30
25
  * `key:` under a value, a list at the left edge, a key set twice, a YAML explicit key `? key`, which every writer here
31
26
  * would have to edit in its own form) reads no way. */
32
27
  export declare function frontMatter(text: string): ReadonlyMap<string, string> | undefined;
33
- /** Every value a SKILL.md's or a draft README's front matter holds, as YAML reads it (frontMatter: escapes decoded):
28
+ /** Every value a draft README's front matter holds, as YAML reads it (frontMatter: escapes decoded):
34
29
  * what a check for secrets reads beside the text as stored, since the decoded value is the one a harness is served
35
30
  * (servedSkill). None for a text whose front matter does not read one way. */
36
31
  export declare function frontValues(text: string): string[];
37
- /** The keys a SKILL.md's or a draft README's front matter sets, in order (frontMatter's); undefined for a text whose
32
+ /** The keys a draft README's front matter sets, in order (frontMatter's); undefined for a text whose
38
33
  * front matter does not read one way. */
39
34
  export declare function frontKeys(text: string): string[] | undefined;
40
- /** The front matter keys a learned skill or draft README may hold: what a skill is (its name and when to use it). Claude
35
+ /** The front matter keys a draft README may hold: its name and when to use it. Claude
41
36
  * Code reads directives from more (hooks, allowed-tools, context, agent, model, ...): a hook is a shell command its CLI
42
37
  * runs. `status` is the host's (a held one). */
43
38
  export declare const LEARNED_KEYS: readonly string[];
44
- /** `text`, a learned skill's SKILL.md, as a run is given it: front matter with its name and its description alone, as
45
- * the one reader reads them (frontMatter), each quoted as JSON writes it, which every YAML reads back as that very
46
- * string (never null, a boolean, a number or a date), written again whatever else its file holds (servedSkill is the
47
- * one door a learned skill reaches a harness by), then its body as it is. A text with no front matter, or one whose front
48
- * matter reads no way, is as it is: never served with its fields emptied. A learned one of those is never active, so
49
- * never given; a revision's own is the harness's to check, as its author wrote it. */
39
+ /** Why a draft's `README.md` for the workflow `name` is out of shape; empty when it is not. Its front matter names the
40
+ * folder's name and a description. */
41
+ export declare function readmeProblems(text: string, name: string): string[];
42
+ /** `text`, a revision's SKILL.md, as OpenCode is handed it: front matter with its name and its description alone, as the
43
+ * one reader reads them (frontMatter), each quoted as JSON writes it, which every YAML reads back as that very string,
44
+ * then its body as it is. A text with no front matter, or one whose front matter reads no way, is as it is: the
45
+ * harness's to check, as its author wrote it. */
50
46
  export declare function servedSkill(text: string): string;
51
- /** Skills as a harness that loads them through servedSkill is handed them (OpenCode, adapters.ts opencodeOf): each
52
- * SKILL.md as servedSkill writes it, its other files as they are. Its table entry's check and the learned skills' room
53
- * (learning.ts chooseSkills) read this same form, so a set the check takes is never one that grew past its limit after. */
47
+ /** Skills as OpenCode is handed them (adapters.ts opencodeOf): each SKILL.md as servedSkill writes it, its other files as
48
+ * they are. Its table entry's check reads this same form. */
54
49
  export declare const servedSkills: <T extends {
55
50
  files: Record<string, string>;
56
51
  }>(skills: readonly T[]) => T[];
57
- /** Why a `SKILL.md` for the skill `name`, or a draft's `README.md` for the workflow `name`, is out of shape; empty when
58
- * it is not. Its front matter names the folder's name and a description. */
59
- export declare function skillProblems(text: string, name: string): string[];
60
52
  /** A SKILL.md's or a draft README's front matter as a reader shows it (frontMatter): its name, description and status,
61
53
  * each absent when it is not there; undefined for a text whose front matter does not read one way. */
62
54
  export declare function learnedFront(text: string): {
@@ -64,10 +56,10 @@ export declare function learnedFront(text: string): {
64
56
  description?: string;
65
57
  status?: string;
66
58
  } | undefined;
67
- /** Whether a SKILL.md or a draft's README.md sets `status`, which only the host does (`held`) (frontMatter). */
59
+ /** Whether a draft's README.md sets `status`, which only the host does (`held`) (frontMatter). */
68
60
  export declare const setsStatus: (text: string) => boolean;
69
- /** A skill or a draft the grader held for its owner's OK: its SKILL.md, or its draft's README.md, says `status:
70
- * pending` (learnedStatus). No run is given a held skill or workflow until a person approves it. */
61
+ /** A draft held for its owner's OK: its README.md says `status: pending` (learnedStatus). No run is given a held
62
+ * workflow until a person approves it. */
71
63
  export declare const isHeld: (text: string) => boolean;
72
64
  /** Whether `text`'s status, when it sets one, is one plain line, `status: <value>` with nothing of it on the lines after
73
65
  * (no quoted value that runs on, no block, no wrapped line): the only status the host's writers (released,
@@ -75,27 +67,27 @@ export declare const isHeld: (text: string) => boolean;
75
67
  * retired), never held or active, and no writer edits it, so a write never leaves part of it behind. The host writes
76
68
  * only one-line statuses (held, retiredLearned). */
77
69
  export declare const statusOnOneLine: (text: string) => boolean;
78
- /** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
70
+ /** `text`, a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
79
71
  * pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
80
72
  * passes. */
81
73
  export declare function held(text: string): string;
82
- /** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
74
+ /** `text`, a held draft README.md, as the host leaves it when its owner approves it: its front matter with
83
75
  * no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
84
76
  export declare function released(text: string): string;
85
- /** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
77
+ /** The status a retired draft README.md goes back to when a person restores it (`retired_from`, which its
86
78
  * retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
87
79
  * `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
88
- * them (fail closed: only an approval makes a skill or a draft active). */
80
+ * them (fail closed: only an approval makes a draft active). */
89
81
  export declare function retiredFrom(text: string): "active" | "pending";
90
- /** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
82
+ /** Whether a retired draft README.md can be restored by the host's writer: its front matter reads one way
91
83
  * (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
92
84
  * One that is not is refused until it is written so (a restore never edits half a value). */
93
85
  export declare const restorable: (text: string) => boolean;
94
- /** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
86
+ /** `text`, a retired draft README.md, as the host leaves it when a person restores it: back in the status its
95
87
  * retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
96
88
  * one way, or whose status is not one plain line (released). */
97
89
  export declare const restoredLearned: (text: string) => string;
98
- /** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
90
+ /** What a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
99
91
  * the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
100
92
  * it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
101
93
  * of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
@@ -105,7 +97,7 @@ export declare function learnedStatus(text: string): "active" | "pending" | "ret
105
97
  * is not one plain line, or its status is none the host writes. No one retired it: a view says the host could not read
106
98
  * it, never that a run or a person retired it. */
107
99
  export declare function unclearFront(text: string): boolean;
108
- /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
100
+ /** `text`, a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
109
101
  * status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
110
102
  * them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
111
103
  * matter. */
@@ -173,7 +165,7 @@ export declare function synthesisProblems(doc: unknown, dsl: SchemaResolver): st
173
165
  /** A draft's workflow.json `json` dry-run by the workflow DSL (dryRunWorkflow) on `example` (its block's `example:`
174
166
  * line, one JSON object), else on an input synthesized from its input schema. Every model, Jev and tool-call answer is
175
167
  * synthesized from the node's output schema: no request is sent, nothing is paid, no tool runs, and no code it holds
176
- * runs in this process (refuseCode). Only a draft the static checks pass is dry-run (propose.ts). It checks the wiring
168
+ * runs in this process (refuseCode). Only a draft the static checks pass is dry-run (runner/reflect-hook.ts). It checks the wiring
177
169
  * at run time (the state each step reads, its output's path and schema), never the answers. With `outputSchema` (the
178
170
  * agent's), the output of a run that passed is held to it as a run serving the draft serves it (answer-json.ts
179
171
  * answerAsServed over the tool's text, learned-workflow.ts learnedOutput) as far as its placeholders can decide: its
@@ -1,22 +1,18 @@
1
- // What a run may propose beside its notes: one skill, `skills/<name>/SKILL.md`, and workflow drafts,
2
- // `workflows/<name>/workflow.json` with its `README.md`. Their places in the learning folder and the shape each file must
3
- // have. check.ts checks them; nothing here reads a file, runs a draft or calls a model.
1
+ // A learned workflow draft: `workflows/<name>/workflow.json` with its `README.md`, their place in the learning folder, the
2
+ // shape each file must have, and what its dry run reads. check.ts checks a draft; nothing here reads a file, runs a draft
3
+ // or calls a model.
4
4
  import { mcpNameOf } from "../tool-names.js";
5
5
  import { repeatedLabels, workflowNodes } from "./workflow-nodes.js";
6
- /** Where a skill and a workflow draft live in the folder. */
7
- export const SKILLS_DIR = "skills";
6
+ /** Where a workflow draft lives in the folder. */
8
7
  export const WORKFLOWS_DIR = "workflows";
9
- /** The shared skills convention's name: lowercase letters, digits and single dashes, at most 64. */
10
- export const SKILL_NAME = /^(?=.{1,64}$)[a-z0-9]+(?:-[a-z0-9]+)*$/;
11
8
  /** A workflow's name: lowercase letters, digits, dashes and underscores, at most 64, starting with a letter or digit. */
12
9
  export const WORKFLOW_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
13
10
  const PLACES = [
14
- [/^skills\/([^/]+)\/SKILL\.md$/, "skill"],
15
11
  [/^workflows\/([^/]+)\/workflow\.json$/, "workflow"],
16
12
  [/^workflows\/([^/]+)\/README\.md$/, "readme"],
17
13
  ];
18
- /** Where `path` sits among the skills and workflows, its folder's name as written (unchecked); undefined when it is
19
- * not a skill's or a workflow's file. */
14
+ /** Where `path` sits among the workflows, its folder's name as written (unchecked); undefined when it is not a
15
+ * workflow's file. */
20
16
  export function learnedPlace(path) {
21
17
  for (const [pattern, kind] of PLACES) {
22
18
  const name = pattern.exec(path)?.[1];
@@ -25,9 +21,7 @@ export function learnedPlace(path) {
25
21
  }
26
22
  return undefined;
27
23
  }
28
- /** Whether `name` is a good name for a folder of `kind`. */
29
- export const learnedName = (kind, name) => (kind === "skill" ? SKILL_NAME : WORKFLOW_NAME).test(name);
30
- /** Where a SKILL.md's or a draft README's front matter closes in `lf` (its text with LF line ends): the index of the
24
+ /** Where a draft README's front matter closes in `lf` (its text with LF line ends): the index of the
31
25
  * `\n` before its closing `---` line, the last line or not; -1 when it has none. */
32
26
  const closeOf = (lf) => {
33
27
  const close = /\n---(?:\n|$)/.exec(lf.slice(3));
@@ -35,10 +29,9 @@ const closeOf = (lf) => {
35
29
  };
36
30
  /** YAML's double-quoted escapes, each to what it reads as (`\\x`, `\\u` and `\\U` take hex digits apart). */
37
31
  const ESCAPES = { "0": "\0", a: "\x07", b: "\b", t: "\t", "\t": "\t", n: "\n", v: "\v", f: "\f", r: "\r", e: "\x1b", " ": " ", '"': '"', "/": "/", "\\": "\\", N: "\u0085", _: "\u00a0", L: "\u2028", P: "\u2029" };
38
- /** A scalar's value as YAML reads it: a double-quoted one with its escapes decoded (JSON's, which servedSkill writes,
39
- * and YAML's own), a single-quoted one with each `''` one `'`, a plain one as it is. So reading what servedSkill wrote
40
- * gives back the very value it quoted, and serving a skill again writes the same text (OpenCode serves a laid skill
41
- * again): never an escape quoted twice. Undefined, never a throw, for a double-quoted value with an escape that does
32
+ /** A scalar's value as YAML reads it: a double-quoted one with its escapes decoded (JSON's, which frontLine writes,
33
+ * and YAML's own), a single-quoted one with each `''` one `'`, a plain one as it is. So reading what frontLine wrote
34
+ * gives back the very value it quoted: never an escape quoted twice. Undefined, never a throw, for a double-quoted value with an escape that does
42
35
  * not decode cleanly (one YAML has not, a code point past U+10FFFF, a `\\` that ends it): what another reader makes of
43
36
  * it is not known, so its front matter reads no way. The decoded value is the one every check reads (frontValues). */
44
37
  function unquote(raw) {
@@ -62,7 +55,7 @@ function unquote(raw) {
62
55
  });
63
56
  return clean ? decoded : undefined;
64
57
  }
65
- /** A SKILL.md's or a draft README's front matter, as the host edits it: its lines, where it closes (closeOf, in `lf`,
58
+ /** A draft README's front matter, as the host edits it: its lines, where it closes (closeOf, in `lf`,
66
59
  * the text with LF line ends) and each key's value, a folded or literal block value read as one line. A string is why
67
60
  * there is none. What it says of itself (its keys, its status) is frontMatter's to read, never this. */
68
61
  function frontOf(text) {
@@ -100,7 +93,7 @@ function frontOf(text) {
100
93
  }
101
94
  /** Why a front matter does not read one way, by frontMatter: the words a refusal says. */
102
95
  export const UNCLEAR_FRONT = "its front matter does not read one way: each line a `key: value` at its left edge, a comment, or a line of the value above it";
103
- /** A SKILL.md's or a draft README's front matter, read one way, as the one reader of what it says of itself (its keys,
96
+ /** A draft README's front matter, read one way, as the one reader of what it says of itself (its keys,
104
97
  * its name, its description, its status): each key to its value in order, or undefined when it does not read one way,
105
98
  * since another reader (a harness's YAML) could then read a key, a status among them, this one does not. It reads one
106
99
  * way when it starts the text (`---`), closes on a `---` line (the last line or not), and each line between is blank,
@@ -219,45 +212,25 @@ function foldQuoted(lines) {
219
212
  }
220
213
  return out;
221
214
  }
222
- /** Every value a SKILL.md's or a draft README's front matter holds, as YAML reads it (frontMatter: escapes decoded):
215
+ /** Every value a draft README's front matter holds, as YAML reads it (frontMatter: escapes decoded):
223
216
  * what a check for secrets reads beside the text as stored, since the decoded value is the one a harness is served
224
217
  * (servedSkill). None for a text whose front matter does not read one way. */
225
218
  export function frontValues(text) {
226
219
  return [...(frontMatter(text)?.values() ?? [])];
227
220
  }
228
- /** The keys a SKILL.md's or a draft README's front matter sets, in order (frontMatter's); undefined for a text whose
221
+ /** The keys a draft README's front matter sets, in order (frontMatter's); undefined for a text whose
229
222
  * front matter does not read one way. */
230
223
  export function frontKeys(text) {
231
224
  const front = frontMatter(text);
232
225
  return front ? [...front.keys()] : undefined;
233
226
  }
234
- /** The front matter keys a learned skill or draft README may hold: what a skill is (its name and when to use it). Claude
227
+ /** The front matter keys a draft README may hold: its name and when to use it. Claude
235
228
  * Code reads directives from more (hooks, allowed-tools, context, agent, model, ...): a hook is a shell command its CLI
236
229
  * runs. `status` is the host's (a held one). */
237
230
  export const LEARNED_KEYS = ["name", "description"];
238
- /** `text`, a learned skill's SKILL.md, as a run is given it: front matter with its name and its description alone, as
239
- * the one reader reads them (frontMatter), each quoted as JSON writes it, which every YAML reads back as that very
240
- * string (never null, a boolean, a number or a date), written again whatever else its file holds (servedSkill is the
241
- * one door a learned skill reaches a harness by), then its body as it is. A text with no front matter, or one whose front
242
- * matter reads no way, is as it is: never served with its fields emptied. A learned one of those is never active, so
243
- * never given; a revision's own is the harness's to check, as its author wrote it. */
244
- export function servedSkill(text) {
245
- const opened = frontOf(text);
246
- if (typeof opened === "string")
247
- return text;
248
- const front = frontMatter(text);
249
- if (!front)
250
- return text;
251
- const lines = [`name: ${JSON.stringify(front.get("name") ?? "")}`, `description: ${JSON.stringify(front.get("description") ?? "")}`];
252
- return `---\n${lines.join("\n")}\n---\n${opened.lf.slice(opened.end + 5)}`;
253
- }
254
- /** Skills as a harness that loads them through servedSkill is handed them (OpenCode, adapters.ts opencodeOf): each
255
- * SKILL.md as servedSkill writes it, its other files as they are. Its table entry's check and the learned skills' room
256
- * (learning.ts chooseSkills) read this same form, so a set the check takes is never one that grew past its limit after. */
257
- export const servedSkills = (skills) => skills.map((skill) => ({ ...skill, files: { ...skill.files, ...(skill.files["SKILL.md"] === undefined ? {} : { "SKILL.md": servedSkill(skill.files["SKILL.md"]) }) } }));
258
- /** Why a `SKILL.md` for the skill `name`, or a draft's `README.md` for the workflow `name`, is out of shape; empty when
259
- * it is not. Its front matter names the folder's name and a description. */
260
- export function skillProblems(text, name) {
231
+ /** Why a draft's `README.md` for the workflow `name` is out of shape; empty when it is not. Its front matter names the
232
+ * folder's name and a description. */
233
+ export function readmeProblems(text, name) {
261
234
  const opened = frontOf(text);
262
235
  if (typeof opened === "string")
263
236
  return [opened];
@@ -271,6 +244,23 @@ export function skillProblems(text, name) {
271
244
  out.push("description is missing or empty");
272
245
  return out;
273
246
  }
247
+ /** `text`, a revision's SKILL.md, as OpenCode is handed it: front matter with its name and its description alone, as the
248
+ * one reader reads them (frontMatter), each quoted as JSON writes it, which every YAML reads back as that very string,
249
+ * then its body as it is. A text with no front matter, or one whose front matter reads no way, is as it is: the
250
+ * harness's to check, as its author wrote it. */
251
+ export function servedSkill(text) {
252
+ const opened = frontOf(text);
253
+ if (typeof opened === "string")
254
+ return text;
255
+ const front = frontMatter(text);
256
+ if (!front)
257
+ return text;
258
+ const lines = [`name: ${JSON.stringify(front.get("name") ?? "")}`, `description: ${JSON.stringify(front.get("description") ?? "")}`];
259
+ return `---\n${lines.join("\n")}\n---\n${opened.lf.slice(opened.end + 5)}`;
260
+ }
261
+ /** Skills as OpenCode is handed them (adapters.ts opencodeOf): each SKILL.md as servedSkill writes it, its other files as
262
+ * they are. Its table entry's check reads this same form. */
263
+ export const servedSkills = (skills) => skills.map((skill) => ({ ...skill, files: { ...skill.files, ...(skill.files["SKILL.md"] === undefined ? {} : { "SKILL.md": servedSkill(skill.files["SKILL.md"]) }) } }));
274
264
  /** A SKILL.md's or a draft README's front matter as a reader shows it (frontMatter): its name, description and status,
275
265
  * each absent when it is not there; undefined for a text whose front matter does not read one way. */
276
266
  export function learnedFront(text) {
@@ -280,10 +270,10 @@ export function learnedFront(text) {
280
270
  const [name, description, status] = ["name", "description", "status"].map((key) => front.get(key));
281
271
  return { ...(name === undefined ? {} : { name }), ...(description === undefined ? {} : { description }), ...(status === undefined ? {} : { status }) };
282
272
  }
283
- /** Whether a SKILL.md or a draft's README.md sets `status`, which only the host does (`held`) (frontMatter). */
273
+ /** Whether a draft's README.md sets `status`, which only the host does (`held`) (frontMatter). */
284
274
  export const setsStatus = (text) => frontMatter(text)?.has("status") ?? false;
285
- /** A skill or a draft the grader held for its owner's OK: its SKILL.md, or its draft's README.md, says `status:
286
- * pending` (learnedStatus). No run is given a held skill or workflow until a person approves it. */
275
+ /** A draft held for its owner's OK: its README.md says `status: pending` (learnedStatus). No run is given a held
276
+ * workflow until a person approves it. */
287
277
  export const isHeld = (text) => learnedStatus(text) === "pending";
288
278
  /** Whether `text`'s status, when it sets one, is one plain line, `status: <value>` with nothing of it on the lines after
289
279
  * (no quoted value that runs on, no block, no wrapped line): the only status the host's writers (released,
@@ -304,7 +294,7 @@ function onOneLine(text, key) {
304
294
  // A plain value that wraps onto the next lines reads longer than its own line.
305
295
  return unquote(own) === front.get(key);
306
296
  }
307
- /** `text`, a SKILL.md or a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
297
+ /** `text`, a draft's README.md, as the host merges one the grader held for its owner's OK: `status:
308
298
  * pending` last in its front matter, with LF line ends. Throws on a text with no front matter, which the checker never
309
299
  * passes. */
310
300
  export function held(text) {
@@ -313,14 +303,14 @@ export function held(text) {
313
303
  throw new Error(`it cannot be held: ${front}`);
314
304
  return `${front.lf.slice(0, front.end)}\nstatus: pending${front.lf.slice(front.end)}`;
315
305
  }
316
- /** `text`, a held SKILL.md or draft README.md, as the host leaves it when its owner approves it: its front matter with
306
+ /** `text`, a held draft README.md, as the host leaves it when its owner approves it: its front matter with
317
307
  * no `status` or `retired_from` line, so it is given to every later run. Throws on a text with no front matter. */
318
308
  export function released(text) {
319
309
  const front = frontOf(text);
320
310
  if (typeof front === "string")
321
311
  throw new Error(`it cannot be approved: ${front}`);
322
312
  // Its status and retired_from are taken out whole, so each must be one plain line; what is left reads back active, or
323
- // the write fails: never an OK over a skill no run is given.
313
+ // the write fails: never an OK over a workflow no run is given.
324
314
  if (!statusOnOneLine(text) || !onOneLine(text, "retired_from"))
325
315
  throw new Error("it cannot be approved: its status is not one plain line");
326
316
  const kept = front.lf.slice(4, front.end).split("\n").filter((line) => !line.startsWith("status:") && !line.startsWith("retired_from:"));
@@ -329,22 +319,22 @@ export function released(text) {
329
319
  throw new Error(`it cannot be approved: its status would read ${learnedStatus(out)}`);
330
320
  return out;
331
321
  }
332
- /** The status a retired SKILL.md or draft README.md goes back to when a person restores it (`retired_from`, which its
322
+ /** The status a retired draft README.md goes back to when a person restores it (`retired_from`, which its
333
323
  * retire recorded), read by the one reader (frontMatter: its quoting, its one-line rule): `active` only when it reads
334
324
  * `active` one way, on one plain line; `pending` otherwise, a retire that recorded none or one that reads unclear among
335
- * them (fail closed: only an approval makes a skill or a draft active). */
325
+ * them (fail closed: only an approval makes a draft active). */
336
326
  export function retiredFrom(text) {
337
327
  return onOneLine(text, "retired_from") && frontMatter(text)?.get("retired_from") === "active" ? "active" : "pending";
338
328
  }
339
- /** Whether a retired SKILL.md or draft README.md can be restored by the host's writer: its front matter reads one way
329
+ /** Whether a retired draft README.md can be restored by the host's writer: its front matter reads one way
340
330
  * (frontMatter), and its `status` and `retired_from` are each one plain line, the only ones the writer takes out whole.
341
331
  * One that is not is refused until it is written so (a restore never edits half a value). */
342
332
  export const restorable = (text) => frontMatter(text) !== undefined && statusOnOneLine(text) && onOneLine(text, "retired_from");
343
- /** `text`, a retired SKILL.md or draft README.md, as the host leaves it when a person restores it: back in the status its
333
+ /** `text`, a retired draft README.md, as the host leaves it when a person restores it: back in the status its
344
334
  * retire recorded (retiredFrom), active, or waiting for its owner's OK. Throws on a text whose front matter does not read
345
335
  * one way, or whose status is not one plain line (released). */
346
336
  export const restoredLearned = (text) => (retiredFrom(text) === "active" ? released(text) : held(released(text)));
347
- /** What a SKILL.md or a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
337
+ /** What a draft's README.md says of itself, the one reader of it (frontMatter), the server's and, through
348
338
  * the folder's snapshot, the console's: `pending` while it waits for its owner's OK, `retired` once a person retired
349
339
  * it, `active` when it sets no status or `active`. A front matter that does not read one way, or a status that is none
350
340
  * of these, is `retired`: never active, since another reader could read it as held or retired; no run is given it, and
@@ -365,7 +355,7 @@ export function unclearFront(text) {
365
355
  const front = frontMatter(text);
366
356
  return !front || !statusOnOneLine(text) || !["active", "pending", "retired"].includes(front.get("status") ?? "active");
367
357
  }
368
- /** `text`, a SKILL.md or a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
358
+ /** `text`, a draft's README.md, as a person's retire leaves it: `status: retired` and `retired_from`, the
369
359
  * status it had (active, or pending while it waited for its owner's OK), last in its front matter (any such lines before
370
360
  * them dropped), so no later run is given it and its restore gives that status back. Throws on a text with no front
371
361
  * matter. */
@@ -699,7 +689,7 @@ const valueAt = (value, path) => path === "" ? value : path.split("/").slice(1).
699
689
  /** A draft's workflow.json `json` dry-run by the workflow DSL (dryRunWorkflow) on `example` (its block's `example:`
700
690
  * line, one JSON object), else on an input synthesized from its input schema. Every model, Jev and tool-call answer is
701
691
  * synthesized from the node's output schema: no request is sent, nothing is paid, no tool runs, and no code it holds
702
- * runs in this process (refuseCode). Only a draft the static checks pass is dry-run (propose.ts). It checks the wiring
692
+ * runs in this process (refuseCode). Only a draft the static checks pass is dry-run (runner/reflect-hook.ts). It checks the wiring
703
693
  * at run time (the state each step reads, its output's path and schema), never the answers. With `outputSchema` (the
704
694
  * agent's), the output of a run that passed is held to it as a run serving the draft serves it (answer-json.ts
705
695
  * answerAsServed over the tool's text, learned-workflow.ts learnedOutput) as far as its placeholders can decide: its
@@ -1,4 +1,4 @@
1
- // The one walk over a learned workflow's nodes (learn/skills.ts callNodes): only the
1
+ // The one walk over a learned workflow's nodes (learn/workflow-draft.ts callNodes): only the
2
2
  // workflow's node positions, never an object in a call's args, a schema or any other data, however it is shaped.
3
3
  import { TIERED_KINDS } from "./check.js";
4
4
  const join = (path, key) => (path ? `${path}.${key}` : key);
@@ -33,7 +33,7 @@ import { defineTool, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
33
33
  import { registerLabel, registerOutcome } from "./timeline/index.js";
34
34
  import { LEARNED_NODES, LEARNED_NODES_MAX } from "./learned-nodes.js";
35
35
  import { draftProblems, LEARNED_MAX_TURNS } from "./learn/index.js";
36
- import { decisionsAsked, deniedDecisionWords } from "./learn/skills.js";
36
+ import { decisionsAsked, deniedDecisionWords } from "./learn/workflow-draft.js";
37
37
  import { DEFAULT_DECISION_PROVIDER } from "./decisions.js";
38
38
  import { workflowLine } from "./learning.js";
39
39
  import { ledgerOf } from "./paid-calls.js";
@@ -478,7 +478,7 @@ export async function runLearned(run, flow, input, signal, ledger, nodes = [], n
478
478
  * other node shares. Only letters, digits, `_` and `-`, so a `/` of its path never reads as another level of nesting
479
479
  * and its call id passes whole through a URL (an approval's). */
480
480
  const nestedKey = (label, executionPath, item) => `${label.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 40)}-${createHash("sha256").update(JSON.stringify([label, executionPath ?? "", item?.index ?? null])).digest("hex").slice(0, 16)}`;
481
- /** The draft check's decisions for `run` (learn/skills.ts DraftDecisions): its providers, and the gate's setting of each
481
+ /** The draft check's decisions for `run` (learn/workflow-draft.ts DraftDecisions): its providers, and the gate's setting of each
482
482
  * provider `text` asks (its bare id as the settings key) where it is not allow, with where a deny was set. A run handed
483
483
  * no decisions (its claim was handed no key: none named, or each denied) has no provider, so a decision node is refused
484
484
  * in the gate's words when its provider is denied, else as one the host does not have; never asked. */