@parcha/agentrun-serve 0.1.0-beta.43 → 0.1.0-beta.45

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 (388) hide show
  1. package/CHANGELOG.md +231 -0
  2. package/README.md +580 -320
  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 +92 -22
  28. package/dist/composio-preset.d.ts +4 -3
  29. package/dist/composio-preset.js +81 -11
  30. package/dist/composio-triggers.d.ts +34 -2
  31. package/dist/composio-triggers.js +261 -31
  32. package/dist/computer-attach.d.ts +40 -5
  33. package/dist/computer-attach.js +130 -15
  34. package/dist/computer-keys.d.ts +3 -0
  35. package/dist/computer-keys.js +7 -1
  36. package/dist/computer-live.js +3 -2
  37. package/dist/computer-lost.d.ts +11 -0
  38. package/dist/computer-lost.js +19 -0
  39. package/dist/computer-record.d.ts +10 -2
  40. package/dist/computer-record.js +50 -18
  41. package/dist/computer-setting.d.ts +1 -0
  42. package/dist/computer-setting.js +2 -2
  43. package/dist/computers.d.ts +21 -10
  44. package/dist/computers.js +39 -28
  45. package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
  46. package/dist/console/assets/index-DaFsZuzQ.css +1 -0
  47. package/dist/console/index.html +2 -2
  48. package/dist/decisions.d.ts +1 -1
  49. package/dist/dial-relay.d.ts +29 -0
  50. package/dist/dial-relay.js +94 -0
  51. package/dist/email/tools.js +10 -5
  52. package/dist/env-proxy.d.ts +2 -0
  53. package/dist/env-proxy.js +35 -0
  54. package/dist/errors.d.ts +4 -1
  55. package/dist/errors.js +10 -4
  56. package/dist/faux-computers.d.ts +8 -2
  57. package/dist/faux-computers.js +83 -6
  58. package/dist/harness-archive.d.ts +67 -0
  59. package/dist/harness-archive.js +177 -0
  60. package/dist/harness-goose.d.ts +34 -0
  61. package/dist/harness-goose.js +87 -0
  62. package/dist/harness-install.d.ts +21 -0
  63. package/dist/harness-install.js +24 -11
  64. package/dist/harness-opencode/adapter.js +1 -1
  65. package/dist/harness-table.d.ts +59 -3
  66. package/dist/harness-table.js +119 -14
  67. package/dist/harness.d.ts +17 -1
  68. package/dist/harness.js +22 -11
  69. package/dist/host.d.ts +12 -10
  70. package/dist/host.js +19 -16
  71. package/dist/import-worker.d.ts +3 -0
  72. package/dist/import-worker.js +7 -5
  73. package/dist/import.d.ts +22 -1
  74. package/dist/import.js +141 -28
  75. package/dist/key-check.js +3 -0
  76. package/dist/learn/audit.d.ts +6 -6
  77. package/dist/learn/audit.js +3 -7
  78. package/dist/learn/check.d.ts +26 -89
  79. package/dist/learn/check.js +58 -336
  80. package/dist/learn/commit.d.ts +63 -90
  81. package/dist/learn/commit.js +124 -316
  82. package/dist/learn/compile.d.ts +53 -50
  83. package/dist/learn/compile.js +88 -103
  84. package/dist/learn/corrections.d.ts +13 -0
  85. package/dist/learn/corrections.js +23 -0
  86. package/dist/learn/delete.d.ts +17 -0
  87. package/dist/learn/delete.js +42 -0
  88. package/dist/learn/folder.d.ts +35 -47
  89. package/dist/learn/folder.js +118 -134
  90. package/dist/learn/index.d.ts +3 -5
  91. package/dist/learn/index.js +6 -9
  92. package/dist/learn/learning.sh +45 -15
  93. package/dist/learn/promote.d.ts +20 -2
  94. package/dist/learn/promote.js +17 -4
  95. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +34 -38
  96. package/dist/learn/{skills.js → workflow-draft.js} +65 -59
  97. package/dist/learn/workflow-nodes.d.ts +22 -1
  98. package/dist/learn/workflow-nodes.js +29 -10
  99. package/dist/learned-workflow.js +2 -2
  100. package/dist/learning-cost.d.ts +127 -13
  101. package/dist/learning-cost.js +142 -10
  102. package/dist/learning-routes.d.ts +99 -170
  103. package/dist/learning-routes.js +199 -420
  104. package/dist/learning-run.d.ts +19 -40
  105. package/dist/learning-run.js +23 -93
  106. package/dist/learning-setting.d.ts +4 -4
  107. package/dist/learning-setting.js +6 -6
  108. package/dist/learning-words.d.ts +28 -74
  109. package/dist/learning-words.js +64 -162
  110. package/dist/learning.d.ts +62 -393
  111. package/dist/learning.js +101 -651
  112. package/dist/listen-first.d.ts +30 -0
  113. package/dist/listen-first.js +115 -0
  114. package/dist/live-reach.d.ts +25 -2
  115. package/dist/live-reach.js +46 -4
  116. package/dist/llms.txt +2 -1
  117. package/dist/local-models.d.ts +3 -11
  118. package/dist/local-models.js +5 -6
  119. package/dist/mcp-servers-store.d.ts +16 -16
  120. package/dist/model-form.js +6 -5
  121. package/dist/model.d.ts +12 -4
  122. package/dist/model.js +41 -16
  123. package/dist/native/binding.js +1 -1
  124. package/dist/native/connection.js +1 -1
  125. package/dist/native/discovery.js +1 -1
  126. package/dist/native/instructions.d.ts +3 -0
  127. package/dist/native/instructions.js +5 -3
  128. package/dist/native/remote-worker-bridge.js +9 -43
  129. package/dist/native/remote.d.ts +8 -15
  130. package/dist/native/remote.js +3 -3
  131. package/dist/native/schema.js +1 -1
  132. package/dist/native/types.d.ts +2 -2
  133. package/dist/openapi.js +375 -347
  134. package/dist/owner.d.ts +8 -0
  135. package/dist/owner.js +11 -0
  136. package/dist/paid-calls.d.ts +14 -0
  137. package/dist/paid-calls.js +31 -1
  138. package/dist/particle-provider.d.ts +11 -0
  139. package/dist/particle-provider.js +135 -0
  140. package/dist/place.d.ts +8 -3
  141. package/dist/place.js +13 -9
  142. package/dist/port-models.d.ts +12 -4
  143. package/dist/port-models.js +28 -11
  144. package/dist/print.d.ts +27 -0
  145. package/dist/print.js +21 -0
  146. package/dist/provider.d.ts +7 -0
  147. package/dist/provider.js +30 -2
  148. package/dist/reflect-range.js +2 -3
  149. package/dist/run-launch.d.ts +14 -28
  150. package/dist/run-launch.js +9 -12
  151. package/dist/run-learning-served.d.ts +16 -90
  152. package/dist/run-listing.d.ts +34 -0
  153. package/dist/run-listing.js +128 -0
  154. package/dist/run-model-key.d.ts +64 -0
  155. package/dist/run-model-key.js +147 -0
  156. package/dist/run-timeline-served.js +5 -3
  157. package/dist/run-trace.d.ts +97 -0
  158. package/dist/run-trace.js +253 -0
  159. package/dist/run-view.d.ts +15 -0
  160. package/dist/run-view.js +9 -0
  161. package/dist/runnable.js +2 -1
  162. package/dist/runner/adapter-loop.d.ts +14 -6
  163. package/dist/runner/adapter-loop.js +25 -14
  164. package/dist/runner/adapter-run-spec.d.ts +22 -7
  165. package/dist/runner/adapter-run-spec.js +130 -77
  166. package/dist/runner/adapters/index.d.ts +4 -2
  167. package/dist/runner/adapters/index.js +35 -4
  168. package/dist/runner/adapters/pi.d.ts +4 -12
  169. package/dist/runner/adapters/pi.js +2 -2
  170. package/dist/runner/audit.d.ts +5 -1
  171. package/dist/runner/audit.js +31 -12
  172. package/dist/runner/beside.d.ts +7 -2
  173. package/dist/runner/beside.js +41 -9
  174. package/dist/runner/claim-secrets.d.ts +66 -1
  175. package/dist/runner/claim-secrets.js +136 -3
  176. package/dist/runner/cli-run-spec.d.ts +2 -1
  177. package/dist/runner/cli-run-spec.js +82 -59
  178. package/dist/runner/commands.d.ts +3 -6
  179. package/dist/runner/conformance/harness.d.ts +6 -0
  180. package/dist/runner/conformance/harness.js +16 -5
  181. package/dist/runner/dispatch.d.ts +2 -2
  182. package/dist/runner/end-of-run.d.ts +6 -14
  183. package/dist/runner/end-of-run.js +8 -33
  184. package/dist/runner/feedback-round.d.ts +5 -4
  185. package/dist/runner/feedback-round.js +14 -10
  186. package/dist/runner/github-app.js +3 -1
  187. package/dist/runner/harness-loops.d.ts +0 -8
  188. package/dist/runner/harness-loops.js +30 -56
  189. package/dist/runner/held.d.ts +170 -0
  190. package/dist/runner/held.js +57 -0
  191. package/dist/runner/journal-kinds.d.ts +7 -3
  192. package/dist/runner/journal-kinds.js +2 -3
  193. package/dist/runner/learned-first.d.ts +40 -0
  194. package/dist/runner/learned-first.js +32 -0
  195. package/dist/runner/learning-end.d.ts +77 -66
  196. package/dist/runner/learning-end.js +250 -299
  197. package/dist/runner/learning-seed.d.ts +15 -33
  198. package/dist/runner/learning-seed.js +24 -45
  199. package/dist/runner/loop-contract.d.ts +8 -3
  200. package/dist/runner/loop-contract.js +4 -0
  201. package/dist/runner/loop.js +6 -2
  202. package/dist/runner/main.d.ts +18 -9
  203. package/dist/runner/main.js +82 -22
  204. package/dist/runner/mcp-run.d.ts +11 -0
  205. package/dist/runner/mcp-run.js +67 -0
  206. package/dist/runner/memory-claim.d.ts +14 -6
  207. package/dist/runner/memory-claim.js +18 -9
  208. package/dist/runner/model-route.d.ts +7 -4
  209. package/dist/runner/model-route.js +22 -10
  210. package/dist/runner/native-loop.d.ts +0 -7
  211. package/dist/runner/native-loop.js +9 -101
  212. package/dist/runner/promotion.d.ts +13 -6
  213. package/dist/runner/promotion.js +63 -17
  214. package/dist/runner/reflect-hook.d.ts +64 -91
  215. package/dist/runner/reflect-hook.js +112 -206
  216. package/dist/runner/run-channel.d.ts +43 -0
  217. package/dist/runner/run-channel.js +467 -0
  218. package/dist/runner/run-child-host.d.ts +169 -0
  219. package/dist/runner/run-child-host.js +1222 -0
  220. package/dist/runner/run-child.d.ts +1 -0
  221. package/dist/runner/run-child.js +254 -0
  222. package/dist/runner/run-errors.d.ts +2 -0
  223. package/dist/runner/run-errors.js +20 -0
  224. package/dist/runner/runner.js +58 -9
  225. package/dist/runner/sdk-ask.d.ts +78 -0
  226. package/dist/runner/sdk-ask.js +158 -0
  227. package/dist/runner/sdk-loop.d.ts +2 -4
  228. package/dist/runner/sdk-loop.js +29 -49
  229. package/dist/runner/store-secrets.d.ts +5 -3
  230. package/dist/runner/store-secrets.js +14 -6
  231. package/dist/runner/workflow-first.d.ts +5 -0
  232. package/dist/runner/workflow-first.js +4 -0
  233. package/dist/runner/workflow-spec.js +17 -4
  234. package/dist/runs-over-store.d.ts +21 -32
  235. package/dist/runs-over-store.js +44 -41
  236. package/dist/sdk/runs.d.ts +6 -11
  237. package/dist/sdk/runs.js +20 -41
  238. package/dist/sdk/schema.js +3 -4
  239. package/dist/sdk/workflows.d.ts +1 -1
  240. package/dist/seal-key.d.ts +5 -0
  241. package/dist/seal-key.js +7 -0
  242. package/dist/secrets.d.ts +3 -0
  243. package/dist/secrets.js +16 -3
  244. package/dist/server.d.ts +119 -83
  245. package/dist/server.js +1121 -419
  246. package/dist/sign-ins-store.d.ts +8 -0
  247. package/dist/sign-ins-store.js +36 -1
  248. package/dist/skills.js +1 -1
  249. package/dist/store/index.d.ts +3 -3
  250. package/dist/store/index.js +2 -2
  251. package/dist/store/journal/storage.js +3 -0
  252. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  253. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  254. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  255. package/dist/store/schema.d.ts +53 -4
  256. package/dist/store/schema.js +137 -6
  257. package/dist/store/seal.d.ts +20 -2
  258. package/dist/store/seal.js +24 -8
  259. package/dist/store/sqlite/connection.d.ts +2 -0
  260. package/dist/store/sqlite/connection.js +3 -1
  261. package/dist/store/sqlite/run-launch.d.ts +4 -1
  262. package/dist/store/sqlite/run-launch.js +12 -0
  263. package/dist/store/sqlite/run-patch.d.ts +0 -17
  264. package/dist/store/sqlite/run-patch.js +4 -33
  265. package/dist/store/sqlite/store.d.ts +3 -2
  266. package/dist/store/sqlite/store.js +360 -75
  267. package/dist/store/sqlite/worker.js +25 -0
  268. package/dist/store/store.d.ts +231 -39
  269. package/dist/store/store.js +25 -3
  270. package/dist/store-reads/analytics.js +11 -1
  271. package/dist/store-reads/learning.d.ts +131 -194
  272. package/dist/store-reads/learning.js +292 -301
  273. package/dist/store-reads/loop.d.ts +0 -1
  274. package/dist/store-reads/loop.js +1 -1
  275. package/dist/store-reads/stats.js +13 -3
  276. package/dist/store-view.d.ts +34 -2
  277. package/dist/store-view.js +108 -41
  278. package/dist/telemetry.d.ts +59 -0
  279. package/dist/telemetry.js +153 -0
  280. package/dist/template-eval.d.ts +3 -6
  281. package/dist/template-eval.js +22 -36
  282. package/dist/templates.d.ts +2 -1
  283. package/dist/templates.js +6 -3
  284. package/dist/timeline/index.d.ts +1 -1
  285. package/dist/timeline/index.js +1 -1
  286. package/dist/timeline/timeline.d.ts +5 -1
  287. package/dist/timeline/timeline.js +16 -0
  288. package/dist/tool-gate.d.ts +0 -7
  289. package/dist/tool-gate.js +1 -15
  290. package/dist/tool-keys-store.d.ts +1 -1
  291. package/dist/tool-keys.d.ts +6 -4
  292. package/dist/tool-keys.js +12 -6
  293. package/dist/tool-plane.d.ts +12 -12
  294. package/dist/tools.d.ts +13 -13
  295. package/dist/tools.js +29 -9
  296. package/dist/trigger-adapter.d.ts +3 -0
  297. package/dist/trigger-adapters.d.ts +4 -0
  298. package/dist/trigger-adapters.js +13 -0
  299. package/dist/trigger-composio.d.ts +58 -1
  300. package/dist/trigger-composio.js +160 -6
  301. package/dist/triggers.d.ts +64 -5
  302. package/dist/triggers.js +141 -17
  303. package/dist/validate.d.ts +11 -7
  304. package/dist/validate.js +9 -8
  305. package/dist/webhooks.d.ts +4 -1
  306. package/dist/webhooks.js +11 -4
  307. package/dist/workspace/agent-computer.d.ts +2 -0
  308. package/dist/workspace/agent-computer.js +2 -0
  309. package/dist/workspace/archil-claim.d.ts +7 -0
  310. package/dist/workspace/archil-claim.js +29 -0
  311. package/dist/workspace/archil.d.ts +9 -1
  312. package/dist/workspace/archil.js +165 -3
  313. package/dist/workspace/attach.d.ts +3 -1
  314. package/dist/workspace/attach.js +2 -0
  315. package/dist/workspace/attached-computers.d.ts +16 -5
  316. package/dist/workspace/attached-computers.js +25 -9
  317. package/dist/workspace/computer-deps.js +1 -1
  318. package/dist/workspace/computer-for-claim.d.ts +22 -8
  319. package/dist/workspace/computer-for-claim.js +339 -46
  320. package/dist/workspace/computer-hold.js +2 -1
  321. package/dist/workspace/computer-kept.d.ts +11 -1
  322. package/dist/workspace/computer-kept.js +24 -3
  323. package/dist/workspace/resolve-computer.d.ts +41 -21
  324. package/dist/workspace/resolve-computer.js +172 -64
  325. package/dist/workspace/revision-skills.d.ts +1 -2
  326. package/dist/workspace/revision-skills.js +3 -4
  327. package/dist/workspace/run-workspace.d.ts +1 -1
  328. package/dist/workspace/run-workspace.js +5 -0
  329. package/dist/workspace/synced-folder.d.ts +85 -0
  330. package/dist/workspace/synced-folder.js +230 -0
  331. package/dist/workspace/workspace.d.ts +4 -0
  332. package/launcher/agentrun-serve +1 -1
  333. package/package.json +10 -9
  334. package/templates/README.md +7 -7
  335. package/templates/inbound-lead/agent.md +3 -3
  336. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  337. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  338. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  339. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  340. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  341. package/templates/inbound-lead/lead.schema.json +6 -5
  342. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  343. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  344. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  345. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  346. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  347. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  348. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  349. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  350. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  351. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  352. package/dist/console/assets/index-BrcDSBD8.css +0 -1
  353. package/dist/console/assets/index-Bz6IWncl.js +0 -711
  354. package/dist/learn/grade.d.ts +0 -138
  355. package/dist/learn/grade.js +0 -682
  356. package/dist/learn/notes.d.ts +0 -81
  357. package/dist/learn/notes.js +0 -178
  358. package/dist/learn/reflect.d.ts +0 -77
  359. package/dist/learn/reflect.js +0 -228
  360. package/dist/learn/relevance.d.ts +0 -24
  361. package/dist/learn/relevance.js +0 -91
  362. package/dist/learn/seed-check.d.ts +0 -74
  363. package/dist/learn/seed-check.js +0 -103
  364. package/dist/learning-batch.d.ts +0 -291
  365. package/dist/learning-batch.js +0 -600
  366. package/dist/learning-evals.d.ts +0 -33
  367. package/dist/learning-evals.js +0 -98
  368. package/dist/native/context.d.ts +0 -6
  369. package/dist/native/context.js +0 -22
  370. package/dist/propose.d.ts +0 -52
  371. package/dist/propose.js +0 -224
  372. package/dist/runner/learning-ask.d.ts +0 -47
  373. package/dist/runner/learning-ask.js +0 -128
  374. package/dist/runner/learning-dispatch.d.ts +0 -45
  375. package/dist/runner/learning-dispatch.js +0 -99
  376. package/dist/runner/learning-factory.d.ts +0 -16
  377. package/dist/runner/learning-factory.js +0 -50
  378. package/dist/runner/learning-loop.d.ts +0 -273
  379. package/dist/runner/learning-loop.js +0 -521
  380. package/dist/usage.d.ts +0 -11
  381. package/dist/usage.js +0 -11
  382. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  383. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  384. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  385. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  386. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  387. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  388. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
@@ -1,20 +1,22 @@
1
1
  import { type EntryLike, type TimelineEvent } from "../timeline/index.js";
2
+ import { type LearningChange, type LearningCommitResult } from "../learn/commit.js";
2
3
  import { type LearningFolder } from "../learn/folder.js";
3
- import { type CompileAsk, type CompileTrace } from "../learn/compile.js";
4
+ import { type CompileAsk, type CompileTrace, type DraftChecked } from "../learn/compile.js";
4
5
  import type { RunPath } from "../learning-cost.js";
5
6
  import { type RunLaunch } from "../run-launch.js";
6
- import { type SignInReader } from "../run-view.js";
7
- import { type AlsoRow, type Store } from "../store/store.js";
7
+ import type { SignInReader } from "../run-view.js";
8
+ import { type Store } from "../store/store.js";
8
9
  import type { EndOfRunTurn } from "./loop-contract.js";
10
+ import { type DraftCommit } from "./reflect-hook.js";
9
11
  /** What the step reads: the run's store, the data directory (the server's tool settings a draft's tools are read with),
10
- * the agent's learning folder (where the run's place keeps it), the runner's environment (the host's secrets a
11
- * proposal is refused for; the grade model it names), and what the run was handed (its claim's keys, its sign-in's
12
- * pointers through `signIns`), which it never learns. */
12
+ * the agent's learning folder (where the run's place keeps it), the runner's environment (the host's secrets a draft or
13
+ * a correction is refused for), and what the run was handed (its claim's keys, its sign-in's pointers through
14
+ * `signIns`), which it never learns. */
13
15
  export interface LearningEndDeps {
14
16
  readonly store: Store;
15
17
  readonly data: string;
16
18
  /** Agent `agentId`'s learning folder, where the run's place keeps it: learningWorkspace({ mode: "local", agentId, data })
17
- * in Mode 1, { mode: "archil", agentId, archil } in Mode 2. Opened for each check, and ended after it. */
19
+ * in Mode 1, { mode: "archil", agentId, archil } in Mode 2. Opened for each read or write, and ended after it. */
18
20
  readonly learningFolder: (agentId: string) => LearningFolder;
19
21
  readonly env?: NodeJS.ProcessEnv;
20
22
  /** The agent's sign-ins, opened (sign-ins-store.ts signInReads over the store and the seal key): the pointers the run's
@@ -40,25 +42,20 @@ export interface LearningEndDeps {
40
42
  * does not learn is asked nothing and keeps nothing), else the reflect hook over the run's store. */
41
43
  export declare function learningEndOfRun(launch: RunLaunch, deps: LearningEndDeps): EndOfRunTurn | undefined;
42
44
  /** What every cap gate of run `runId` reads as spent beside it on its behalf (adapter-loop.ts RunCapConfig.beside): its
43
- * learning runs' grades and its audit's shadow run (besideOf), for a capped run with a learning start, the only run
44
- * whose ends queue them (one that only uses what its agent learned queues no grade, but may start a shadow); none for any
45
- * other, whose gates read only its own sessions. */
46
- export declare function spentBesideOf(launch: RunLaunch, store: Pick<Store, "learning" | "runs">, runId: string): (() => Promise<number | null>) | undefined;
47
- /** What was spent beside run `runId` on its behalf, the one figure its cap gates and its grades' caps read: its learning
48
- * runs' grades (Store.learning.spentBeside; `beforeRound`: its earlier rounds' alone) and its audit's shadow run
49
- * (runner/audit.ts, started at its end with what its cap left): the shadow at its cost once it ended, at its own cap while
50
- * it has not (the most it may take) or when it ended at a cost not known, 0 when none was started. Null: unknown. */
51
- export declare function besideOf(store: Pick<Store, "learning" | "runs">, runId: string, options?: {
52
- beforeRound?: number;
53
- }): Promise<number | null>;
45
+ * audit's shadow run (shadowBesideOf), for a capped run with a learning start, the only run whose end may start one;
46
+ * none for any other, whose gates read only its own sessions. */
47
+ export declare function spentBesideOf(launch: RunLaunch, store: Pick<Store, "runs">, runId: string): (() => Promise<number | null>) | undefined;
48
+ /** What run `runId`'s audit's shadow run took beside it (runner/audit.ts, started at its end with what its cap left): at
49
+ * its cost once it ended, at its own cap while it has not (the most it may take) or when it ended at a cost not known,
50
+ * 0 when none was started. Null: unknown. */
51
+ export declare function shadowBesideOf(store: Pick<Store, "runs">, runId: string): Promise<number | null>;
54
52
  /** What run `runId`'s cap leaves its audit's shadow run at its end (runner/audit.ts startAudit): the cap it is held to now
55
53
  * (capNowOf: its newest raise's, else `launchCapUsd`), less what it spent under it (capSpendOf over `entries`, its
56
- * journal: its job, its look-back, every grade an earlier round queued) and the cap of the grade this end queues
57
- * (`queued`, the end's rows: it is not in the store until the end commits). Null when that spend is unknown. */
58
- export declare function auditRoomOf(store: Pick<Store, "learning" | "runs">, runId: string, launchCapUsd: number, entries: readonly EntryLike[], queued: readonly AlsoRow[]): Promise<number | null>;
54
+ * journal: its job, its follow-ups, its compile turns). Null when that spend is unknown. */
55
+ export declare function auditRoomOf(store: Pick<Store, "runs">, runId: string, launchCapUsd: number, entries: readonly EntryLike[]): Promise<number | null>;
59
56
  /** What capped run `runId` has spent under its cap, as every gate of the run reads it: its sessions' booking as the kernel
60
- * cap counts it (metrics.ts bookedCapSpend over `entries`, its journal) and what was spent beside it on its behalf
61
- * (besideOf: its grades, `beforeRound` its earlier rounds' alone, and its audit's shadow). Null when either is unknown.
57
+ * cap counts it (metrics.ts bookedCapSpend over `entries`, its journal) and what its audit's shadow took beside it
58
+ * (shadowBesideOf). Null when either is unknown.
62
59
  *
63
60
  * The rule for a cost no one knows (a request answered with no price of its own, one cut short or lost): under a cap it
64
61
  * counts at the figure the cap held it at when it was admitted (its worst case at the model's price, and a lost one's
@@ -67,28 +64,25 @@ export declare function auditRoomOf(store: Pick<Store, "learning" | "runs">, run
67
64
  * unknown (a held figure is the cap's, never a charge). Only a request held at no figure (none is, under a cap) leaves
68
65
  * the spend itself unknown: then nothing more is sent under the cap, and the words say the spend is unknown, as the
69
66
  * kernel's unknownSpend refusal does, never "no room". */
70
- export declare function capSpendOf(store: Pick<Store, "learning" | "runs">, runId: string, entries: readonly EntryLike[], beforeRound?: number): Promise<number | null>;
71
- /** The cap the grade of round `round` of run `runId` runs under (its learning run's max_cost_usd), so the run's grades
72
- * never take it past its cap: the cap the run is held to now (capNowOf: its newest raise's, else `launchCapUsd`), less
73
- * what the run spent under it (its job, its follow-ups and every look-back) and what was spent beside it on its behalf by
74
- * its earlier rounds (capSpendOf: each earlier grade at its cost once it ended, at its own cap while it has not). Null
75
- * when that spend is unknown, or a read fails: the grade is then not run, said so (said.gradeUnknownSpend), never run
76
- * with a room nobody knows and never told it has none. */
77
- export declare function gradeCapOf(store: Store, runId: string, round: number, launchCapUsd: number): Promise<number | null>;
78
- /** A workflow text written straight onto the agent's learning folder as a merge by `runId`, from the claim's `seed`: the
79
- * one direct commit a runner makes outside a learning run (a compile turn's revision). A file changed on main since the
80
- * seed is a conflict, never written over. The learning commit it landed as, or null when it did not (the reason is
81
- * logged). The folder is always released. */
67
+ export declare function capSpendOf(store: Pick<Store, "runs">, runId: string, entries: readonly EntryLike[]): Promise<number | null>;
68
+ /**
69
+ * A run's merge on the agent's learning folder, written by the runner directly (learn/commit.ts learningCommit, one
70
+ * exec): its compiled draft's files and its owner's correction, committed by `change.runId` (its Run-Id trailer). A file
71
+ * changed on main since the run's seed (or a revision's `bases` commit) is a conflict, never written over; a correction
72
+ * that holds what must never be stored, or would take corrections.md past its cap, is refused (past the cap beside a
73
+ * draft, it is left out alone and the draft merges). Any failure is logged by its reason alone. The folder is always
74
+ * released.
75
+ */
82
76
  export declare function commitDirect(deps: {
83
77
  readonly folder: () => LearningFolder;
84
78
  readonly log: (line: string) => void;
85
- }, files: {
86
- path: string;
87
- text: string;
88
- }[], reason: string, runId: string, seed?: string): Promise<string | null>;
89
- /** The learning run of round `round` of run `runId`'s learning: `<runId>-learning` for its first, `<runId>-learning-<n>`
90
- * for each later one. */
91
- export declare const learningRunIdOf: (runId: string, round?: number) => string;
79
+ }, change: LearningChange): Promise<LearningCommitResult>;
80
+ /** What a run's owner said of it, in order, each a line for corrections.md: the grade's words its end closes (a feedback
81
+ * round, feedback-round.ts pendingFeedbackOf over its root `entries`), and each message a person sent in this round of
82
+ * its timeline `rows`: after the job's first on its first round, after its previous end on a later one (a follow-up
83
+ * opened it again). A grade's round's rows, the end-of-run turn's and a subagent's (a child conversation's rows carry
84
+ * its spawning call, parent_tool_use_id: its task prompt is the job's, not the owner's) are left out. */
85
+ export declare function ownerWords(entries: readonly EntryLike[], rows: readonly TimelineEvent[]): string[];
92
86
  /** learned_workflow by every name a harness calls it: its own, and claude-agent's host-tool alias (`mcp__hands__<name>`).
93
87
  * A harness that names it another way reads as another tool, so its run is asked as before. */
94
88
  export declare const LEARNED_NAMES: ReadonlySet<string>;
@@ -97,24 +91,14 @@ export declare const LEARNED_NAMES: ReadonlySet<string>;
97
91
  * subagent's row or a call another tool nested (a learned workflow's own). */
98
92
  export declare function modelsOwn(rows: readonly TimelineEvent[]): (row: TimelineEvent) => boolean;
99
93
  /** Whether a run's job, by its timeline `rows` (the end-of-run turn's own, labelled LEARNING_LABEL, left out), gave
100
- * nothing new to look back on: it called tools, every one of them learned_workflow (a workflow's own nested calls are
101
- * its), each answering; no tool result failed or was refused; no error, approval or wait; and one message, its first,
102
- * came in. Anything else is asked its end-of-run turn. Read on the job's turns (withoutFeedbackRounds): a grade's
103
- * feedback round is no message of the job's. */
94
+ * nothing new: it called tools, every one of them learned_workflow (a workflow's own nested calls are its), each
95
+ * answering; no tool result failed or was refused; no error, approval or wait; and one message, its first, came in.
96
+ * Read on the job's turns (withoutFeedbackRounds): a grade's feedback round is no message of the job's. */
104
97
  export declare function onlyLearnedWorkflows(rows: readonly TimelineEvent[]): boolean;
105
- /** Whether a run carries its owner's feedback, the only thing a run of a job that compiles workflows is looked back on
106
- * for: a grade's words its end closes (a feedback round, feedback-round.ts pendingFeedbackOf over its root `entries`),
107
- * or a person's message after its first in its timeline `rows` (a follow-up, or a word while it ran: traceFrom's
108
- * feedback), the end-of-run turn's own, a grade's round's and a subagent's (a child conversation's rows carry its
109
- * spawning call, parent_tool_use_id: its task prompt is the job's, not the owner's) rows left out. */
110
- export declare function ownerSaid(entries: readonly {
111
- readonly kind: string;
112
- readonly data?: unknown;
113
- }[], rows: readonly TimelineEvent[]): boolean;
114
98
  /** The path a run took (learning-cost.ts RunPath), by its timeline `rows` as runTimeline labels them (its end-of-run
115
99
  * turn's rows, LEARNING_LABEL, are the learning's and left out): `workflow` when its job did only what
116
- * onlyLearnedWorkflows asks of a run with nothing new to look back on, `handed_back` when it called a learned workflow
117
- * otherwise, `agent` when it called none. */
100
+ * onlyLearnedWorkflows asks of a run with nothing new, `handed_back` when it called a learned workflow otherwise,
101
+ * `agent` when it called none. */
118
102
  export declare function runPathOf(rows: readonly TimelineEvent[]): RunPath;
119
103
  /** The learned workflow a run's job called last by its call's `name` (callArgsOf's arguments, in the job's order: `calls`),
120
104
  * or null when it called none by a name. */
@@ -122,6 +106,31 @@ export declare function workflowNameOf(calls: readonly {
122
106
  tool: string;
123
107
  args: Record<string, unknown>;
124
108
  }[]): string | null;
109
+ /**
110
+ * One compile draft through the checks (the compile turn's `check`): its two files as the folder would hold them
111
+ * (workflow-draft.ts draftFiles: its workflow.json, and the README.md the host writes from its front matter), against
112
+ * `seed`, the commit the run started from (a revision of main's text, `revised`, against the commit it read that text
113
+ * at). In order: its example, the run's own input, refused for anything that must never be stored; the static checks
114
+ * (check.ts checkDraft: the DSL's validation, caps, the secret and hidden-character refusals, a file a person retired or
115
+ * holds for their OK); then its dry run (workflow-draft.ts draftDryRun: every model and tool answer synthesized, nothing
116
+ * sent, paid or run) and the checks again with it. Its errors, each naming its file; else what is committed: the files
117
+ * whole, the README held when a step calls an unpriced tool, the revision's base, and the workflow.json's digest. A
118
+ * draft that is the very text the commit holds passes nothing and keeps nothing.
119
+ */
120
+ export declare function checkDraftOf(deps: LearningEndDeps, input: {
121
+ runId: string;
122
+ agentId: string;
123
+ seed: string;
124
+ draft: {
125
+ name: string;
126
+ text: string;
127
+ };
128
+ refuse: readonly string[];
129
+ revised?: {
130
+ readonly workflow: string;
131
+ readonly base: string;
132
+ };
133
+ }): Promise<DraftChecked<DraftCommit>>;
125
134
  /** Compile once: run `runId`'s compile turn whose drafts all failed their checks is the compile's attempt, kept as a
126
135
  * promotion record of the shape a check's stop has (runner/promotion.ts stopUnchecked): a hold with nothing checked,
127
136
  * its reason (DRAFT_FAILED) naming the failed checks. A first compile's earns the one recompile, as a check's hold
@@ -151,20 +160,22 @@ export declare function traceFrom(timeline: readonly TimelineEvent[], refuse: re
151
160
  * it, with the check's numbers and the inputs it disagreed on, once per hold (none when any run since the hold compiled
152
161
  * it, read from the agent's kept learning; a stopped check's none); else, when the job is due (compileDue: the run
153
162
  * completed, the agent has no learned workflow active or waiting, and it has its definition's compile_after completed
154
- * agent runs), a new one, compiled once: none while the last compile's passing draft waits on its grade
155
- * (draftAwaitingGrade), one more after a first compile whose drafts all failed their checks, and none after a
156
- * recompile's (recordDraftFailed). Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's
157
- * stop are single runs, which the hold reads among many. Either way the
158
- * agent's active notes whole, the traces of its last COMPILE_TRACES completed runs before this one, the tools a call node
159
- * may run (draftTools) with what each takes and gives, its decision providers, the run's input (`input`, its fields for
160
- * the workflow's input schema), the agent's output schema when it has one (its final output's shape) and the DSL's
161
- * language with this host's addendum. Undefined when it compiles nothing, or
162
- * when the folder can't be read. */
163
+ * agent runs), a new one, compiled once: one more after a first compile whose drafts all failed their checks, and none
164
+ * after a recompile's (recordDraftFailed). A draft that passes is on main at once (a learned workflow then), so nothing
165
+ * waits on it. Nothing else asks one: a hand-back, a wrong grade of a served answer and the money rule's stop are single
166
+ * runs, which the hold reads among many. Either way the traces of the agent's last COMPILE_TRACES completed runs before
167
+ * this one, the tools a call node may run (draftTools) with what each takes and gives, its decision providers, the
168
+ * run's input (`input`, its fields for the workflow's input schema), the agent's output schema when it has one (its
169
+ * final output's shape) and the DSL's language with this host's addendum. An SDK run's compile, asked outside its
170
+ * session, also carries the owner's standing corrections it was laid with (`corrections`, its # Learned section), as an
171
+ * in-session compile reads them in its session. Undefined when it compiles nothing, or when the folder can't be read. */
163
172
  export declare function compileAskOf(deps: LearningEndDeps, input: {
164
173
  runId: string;
165
174
  agentId: string;
166
175
  outcome: "completed" | "failed";
167
176
  refuse: readonly string[];
177
+ round?: number;
168
178
  input?: unknown;
169
179
  seedWorkflows?: number;
180
+ corrections?: string;
170
181
  }): Promise<CompileAsk | undefined>;