@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
package/dist/model.js CHANGED
@@ -8,22 +8,25 @@
8
8
  import { isRouter, withLocalModels } from "./local-models.js";
9
9
  import { pathToFileURL } from "node:url";
10
10
  import { DEFAULT_HARNESS, PLAN_HARNESSES } from "./harness.js";
11
- import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
12
- import { gatewayBase } from "./provider.js";
11
+ import { builtinHarness, HARNESS_MODULES_ENV, HARNESS_TABLE_ENV, harnessIds, harnessOf } from "./harness-table.js";
12
+ import { gatewayBase, modelGatewayBase } from "./provider.js";
13
13
  import { modelFormWhy } from "./model-form.js";
14
14
  // Leaves, which the key rows below read as this module loads, in any import order (wires.ts, adapter-facts.ts).
15
- import { ADAPTER_FACTS } from "./adapter-facts.js";
15
+ import { ADAPTER_FACTS, adapterFactsOf } from "./adapter-facts.js";
16
16
  import { WIRES } from "./wires.js";
17
17
  import { authContextOf } from "./secrets.js";
18
18
  import { EXPIRED, PLAN_DEFAULT_MODEL, PLAN_ORIGIN, PLAN_PROVIDER, planOf, signedIn, SIGNED_OUT } from "./chatgpt-plan.js";
19
+ import { LOGIN_DEFAULT_MODEL, onClaudeLogin } from "./claude-login.js";
19
20
  /** The child's environment names the faux module by absolute path. */
20
21
  export const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
21
22
  /** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
22
- * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name. */
23
+ * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
24
+ * (HARNESS_MODULES_ENV). */
23
25
  export const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
24
- /** `env` without a test hook's name: serve sets those from startServe's options alone, so a name the server's own
25
- * environment holds (an operator's export, a leftover) never gives its runs fake answers or loads a module. */
26
- export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV));
26
+ /** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
27
+ * alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
28
+ * answers or loads a module. */
29
+ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV && name !== HARNESS_MODULES_ENV));
27
30
  /** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
28
31
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
29
32
  * request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
@@ -57,16 +60,28 @@ export const MODEL_NODES = ["agent", "decide", "extract", "report"];
57
60
  export const MODEL_KEYS = Object.freeze([
58
61
  { id: "anthropic", label: "Anthropic", field: "ANTHROPIC_API_KEY", model: "anthropic/claude-sonnet-5-5", harnesses: onVendor("anthropic") },
59
62
  { id: "openai", label: "OpenAI", field: "OPENAI_API_KEY", model: "openai/gpt-6.1-sol", harnesses: onVendor("openai") },
63
+ // Particle's direct API is Chat Completions; the adapter harnesses need Messages or HTTP Responses.
64
+ { id: "particle", label: "Particle", field: "PARTICLE_API_KEY", model: "particle/particle-1", harnesses: [DEFAULT_HARNESS] },
60
65
  // OpenRouter serves both wires: every harness runs on its key, an adapter harness on its wire's vendor's model there.
61
66
  { id: "openrouter", label: "OpenRouter", field: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-6.1-sol", harnesses: [DEFAULT_HARNESS, ...ADAPTER_FACTS.map((facts) => facts.id)], byVendor: { anthropic: "anthropic/claude-sonnet-5.5", openai: "openai/gpt-6.1-sol" } },
62
67
  ]);
63
- /** pi, and the adapter harnesses whose wire (their facts') runs `vendor`'s models: those that talk to its own API. */
68
+ /** pi, and the built-in adapter harnesses whose wire (their facts') runs `vendor`'s models: those that talk to its own API. */
64
69
  function onVendor(vendor) {
65
70
  return [DEFAULT_HARNESS, ...ADAPTER_FACTS.filter((facts) => WIRES[facts.wire].vendor === vendor).map((facts) => facts.id)];
66
71
  }
72
+ /** The harnesses `row`'s key runs on `env`'s server: its own (`harnesses`), then each harness this server lists only once its
73
+ * owner installs it (Goose: harness-table.ts hidden, listed by harnessIds) whose wire runs the row's vendor's models, or
74
+ * any, on OpenRouter's. One not installed here is never named. */
75
+ export function keyHarnesses(row, env) {
76
+ const installed = harnessIds(env).filter((id) => !row.harnesses.includes(id) && builtinHarness(id)?.hidden !== undefined);
77
+ return [...row.harnesses, ...installed.filter((id) => {
78
+ const facts = adapterFactsOf(id);
79
+ return facts !== undefined && (row.id === "openrouter" || WIRES[facts.wire].vendor === row.id);
80
+ })];
81
+ }
67
82
  /** `row`'s default for `harness`: the one for its wire's vendor (`byVendor`, OpenRouter's), else the row's. */
68
83
  const rowModel = (row, harness) => {
69
- const facts = ADAPTER_FACTS.find((f) => f.id === harness);
84
+ const facts = adapterFactsOf(harness);
70
85
  return (facts && row.byVendor?.[WIRES[facts.wire].vendor]) ?? row.model;
71
86
  };
72
87
  /** What a person does when no model runs here: add a model provider's key in the console, or set one where AgentRun
@@ -110,7 +125,10 @@ export function hostModel(env, tier = "default", harness = DEFAULT_HARNESS) {
110
125
  // Signed in to a ChatGPT plan, codex and pi run on it by default: a key's model is then named (`openai/<id>`).
111
126
  if (PLAN_HARNESSES.includes(harness) && signedIn(env) && !env.AGENT_MODEL_BASE_URL)
112
127
  return `${PLAN_PROVIDER}/${planModel(env)}`;
113
- const row = MODEL_KEYS.find((row) => env[row.field] && row.harnesses.includes(harness));
128
+ // On Claude Code's login on this machine, claude-agent runs Anthropic's model on it by default (provider.ts).
129
+ if (onClaudeLogin(env, harness))
130
+ return LOGIN_DEFAULT_MODEL;
131
+ const row = MODEL_KEYS.find((row) => env[row.field] && (row.harnesses.includes(harness) || keyHarnesses(row, env).includes(harness)));
114
132
  return row ? rowModel(row, harness) : env[DEFAULT_MODEL_ENV] || undefined;
115
133
  }
116
134
  /** The plan's model a run that names none takes: GPT-6.1 Sol where the plan lists it, else the plan's first. */
@@ -194,7 +212,7 @@ export async function chooseModel(env, ref, tier = "default", harness = DEFAULT_
194
212
  // A gateway its key may not go to (the one base rule, gatewayBase) runs no model, in its words: capabilities read it
195
213
  // not ready, a save warns, and a run is refused before its process starts, so the key is never handed to one.
196
214
  try {
197
- gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL);
215
+ modelGatewayBase(env.AGENT_MODEL_BASE_URL);
198
216
  }
199
217
  catch (error) {
200
218
  return { why: error.message, host: true, needs: "key" };
@@ -255,7 +273,7 @@ async function pinnedChoice(env, { pinned, ref }, tier, harness) {
255
273
  return { why: "This run started on the model gateway, and AGENT_MODEL_BASE_URL names none here.", host: true, needs: "key" };
256
274
  // The one base rule (gatewayBase) holds for a pinned run as for any: its key never goes to a gateway it may not.
257
275
  try {
258
- gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL);
276
+ modelGatewayBase(env.AGENT_MODEL_BASE_URL);
259
277
  }
260
278
  catch (error) {
261
279
  return { why: error.message, host: true, needs: "key" };
@@ -299,6 +317,7 @@ export const PROVIDER_KEYS = {
299
317
  opencode: ["OPENCODE_API_KEY"],
300
318
  "opencode-go": ["OPENCODE_API_KEY"],
301
319
  openrouter: ["OPENROUTER_API_KEY"],
320
+ particle: ["PARTICLE_API_KEY"],
302
321
  "qwen-token-plan": ["QWEN_TOKEN_PLAN_API_KEY"],
303
322
  "qwen-token-plan-cn": ["QWEN_TOKEN_PLAN_CN_API_KEY"],
304
323
  "qwen-token-plan-individual": ["QWEN_TOKEN_PLAN_API_KEY"],
@@ -435,7 +454,7 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
435
454
  // One base rule for every harness (provider.ts' gatewayBase): one trailing /v1 off, then the API under <base>/v1, so
436
455
  // <gw>/api and <gw>/api/v1 both reach <gw>/api/v1/responses and <gw>/api/v1/messages, as OpenRouter serves them. pi-ai's
437
456
  // Responses client takes the base with its /v1, its Messages client adds /v1/messages itself.
438
- const base = gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL);
457
+ const base = modelGatewayBase(env.AGENT_MODEL_BASE_URL);
439
458
  const baseUrl = `${base}/v1`;
440
459
  const [{ openAIResponsesApi }, { anthropicMessagesApi }] = await Promise.all([import("@earendil-works/pi-ai/api/openai-responses.lazy"), import("@earendil-works/pi-ai/api/anthropic-messages.lazy")]);
441
460
  const catalog = await catalogPrices();
@@ -454,7 +473,8 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
454
473
  // the provider's client per wire, which pi-ai picks by the model's `api`.
455
474
  const gatewayModels = ids.map((id) => {
456
475
  const cost = priceOf(id);
457
- // The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none.
476
+ // The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none,
477
+ // and so does a model the catalog does not list.
458
478
  const thinking = catalogThinking(catalog, id, namedOf.get(id));
459
479
  const shared = { id, name: id, provider: MODEL_PROVIDER, reasoning: true, input: ["text", "image"], cost, contextWindow: 128_000, maxTokens: 32_000, ...(thinking ? { thinkingLevelMap: thinking } : {}) };
460
480
  return wireOf(id) === "anthropic-messages" ? { ...shared, api: "anthropic-messages", baseUrl: base } : { ...shared, api: "openai-responses", baseUrl, compat: { supportsDeveloperRole: false } };
@@ -712,12 +732,17 @@ export async function catalogPrices() {
712
732
  * version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
713
733
  * agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
714
734
  * pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
715
- * effort, as its catalog entries say (off: null), not the "none" it refuses. */
735
+ * effort, as its catalog entries say (off: null), not the "none" it refuses. A model the catalog does not list (a local
736
+ * model, a gateway's own alias) is never asked to stop reasoning either (off: null): pi then thinks at its lowest level,
737
+ * so a model that reasons anyway has its reasoning split out of the answer, never written into it. */
716
738
  export function catalogThinking(catalog, id, named) {
717
739
  const segments = id.split("/");
718
740
  const own = segments.at(-1);
719
741
  const vendor = segments.length > 1 ? segments.at(-2) : named;
720
- const saying = [own, ...flippedForms(own)].flatMap((form) => catalog.get(form) ?? []).flatMap((entry) => (entry.thinkingLevelMap ? [{ provider: entry.provider, map: entry.thinkingLevelMap }] : []));
742
+ const listed = [own, ...flippedForms(own)].flatMap((form) => catalog.get(form) ?? []);
743
+ if (!listed.length)
744
+ return { off: null };
745
+ const saying = listed.flatMap((entry) => (entry.thinkingLevelMap ? [{ provider: entry.provider, map: entry.thinkingLevelMap }] : []));
721
746
  const vendors = saying.find((entry) => entry.provider === vendor);
722
747
  if (vendors)
723
748
  return vendors.map;
@@ -49,7 +49,7 @@ export function nativeBindingOf(value) {
49
49
  if (!b || typeof b !== 'object' || !['claude-code', 'codex'].includes(b.runtime) || typeof b.project !== 'string' || !isAbsolute(b.project) || b.project.includes('\0') || typeof b.machine_id !== 'string' || !b.machine_id || !b.selector || !['project', 'agent', 'profile'].includes(b.selector.kind) || (b.selector.kind !== 'project' && (typeof b.selector.name !== 'string' || !/^[\w.@+-]{1,160}$/.test(b.selector.name))) || typeof b.connected !== 'boolean' || typeof b.fingerprint !== 'string' || !Array.isArray(b.configuration) || !Array.isArray(b.skills) || !Array.isArray(b.mcp_servers) || !Array.isArray(b.issues) || !b.capabilities)
50
50
  throw new Error('Invalid native connection: connect the source project using /native/connect.');
51
51
  // Keep the defined metadata only. Never persist arbitrary configuration, environment or credentials.
52
- return { runtime: b.runtime, project: b.project, selector: { kind: b.selector.kind, ...(b.selector.name ? { name: b.selector.name } : {}) }, machine_id: b.machine_id, version: typeof b.version === 'string' ? b.version : null, model: typeof b.model === 'string' ? b.model : null, fingerprint: b.fingerprint, configuration: b.configuration.map(c => ({ path: c.path, sha256: c.sha256 })), skills: b.skills.filter(x => typeof x === 'string'), mcp_servers: b.mcp_servers.filter(x => typeof x === 'string'), state: b.state, issues: b.issues.filter(x => typeof x === 'string'), capabilities: { launch: !!b.capabilities.launch, notes: !!b.capabilities.notes, skills: !!b.capabilities.skills, workflows: false, approval: b.capabilities.approval === 'native' ? 'native' : 'unavailable', usage: !!b.capabilities.usage }, connected: b.connected, ...(typeof b.verified_at === 'string' ? { verified_at: b.verified_at } : {}), ...(b.remote ? { remote: { connector_id: b.remote.connector_id, target_id: b.remote.target_id } } : {}) };
52
+ return { runtime: b.runtime, project: b.project, selector: { kind: b.selector.kind, ...(b.selector.name ? { name: b.selector.name } : {}) }, machine_id: b.machine_id, version: typeof b.version === 'string' ? b.version : null, model: typeof b.model === 'string' ? b.model : null, fingerprint: b.fingerprint, configuration: b.configuration.map(c => ({ path: c.path, sha256: c.sha256 })), skills: b.skills.filter(x => typeof x === 'string'), mcp_servers: b.mcp_servers.filter(x => typeof x === 'string'), state: b.state, issues: b.issues.filter(x => typeof x === 'string'), capabilities: { launch: !!b.capabilities.launch, learning: !!b.capabilities.learning, workflows: false, approval: b.capabilities.approval === 'native' ? 'native' : 'unavailable', usage: !!b.capabilities.usage }, connected: b.connected, ...(typeof b.verified_at === 'string' ? { verified_at: b.verified_at } : {}), ...(b.remote ? { remote: { connector_id: b.remote.connector_id, target_id: b.remote.target_id } } : {}) };
53
53
  }
54
54
  export function nativeOf(body) {
55
55
  const value = body?.native;
@@ -73,7 +73,7 @@ export async function verifyConnection(store, entry, env = nativeEnvironment())
73
73
  if (native.state === 'ready') {
74
74
  const snapshot = await snapshotNativeInstructions(native);
75
75
  if (snapshot.incomplete || snapshot.truncated) {
76
- native.capabilities = { ...native.capabilities, notes: false, skills: false };
76
+ native.capabilities = { ...native.capabilities, learning: false };
77
77
  native.issues.push(`Self-improvement is unavailable: ${snapshot.incomplete ?? 'the declared native instruction files exceed the 64 KiB grading evidence limit.'} Native jobs remain available; no incomplete policy is automatically graded.`);
78
78
  }
79
79
  }
@@ -371,7 +371,7 @@ export async function discoverNative(options) {
371
371
  const config = (NATIVE_RUNTIME_FACTS[runtime].protocol === "claude-json" ? [...configuration] : [...configuration].sort(([a], [b]) => a.localeCompare(b))).map(([path, sha256]) => ({ path, sha256 }));
372
372
  for (const selected of selectors) {
373
373
  const ownModel = policyUnresolved ? null : selected.model === "inherit" ? model : selected.model ?? model;
374
- const target = { runtime, project, selector: selected.selector, machine_id, version, model: ownModel, fingerprint: hash(JSON.stringify([runtime, version, selected.selector, config, ...(policyUnresolved ? [NATIVE_CLAUDE_POLICY_UNRESOLVED] : []), ...(additionalPolicyUnresolved ? [NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED] : [])])), configuration: config, skills: [...skills].sort(), mcp_servers: [...mcp].sort(), state: needsAttention ? "needs_attention" : "needs_verification", issues: [...issues], capabilities: { launch: supported, notes: supported && !policyUnresolved && !additionalPolicyUnresolved, skills: supported && !policyUnresolved && !additionalPolicyUnresolved, workflows: false, approval: "unavailable", usage: supported } };
374
+ const target = { runtime, project, selector: selected.selector, machine_id, version, model: ownModel, fingerprint: hash(JSON.stringify([runtime, version, selected.selector, config, ...(policyUnresolved ? [NATIVE_CLAUDE_POLICY_UNRESOLVED] : []), ...(additionalPolicyUnresolved ? [NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED] : [])])), configuration: config, skills: [...skills].sort(), mcp_servers: [...mcp].sort(), state: needsAttention ? "needs_attention" : "needs_verification", issues: [...issues], capabilities: { launch: supported, learning: supported && !policyUnresolved && !additionalPolicyUnresolved, workflows: false, approval: "unavailable", usage: supported } };
375
375
  targets.push(target);
376
376
  }
377
377
  }
@@ -1,4 +1,7 @@
1
1
  import type { NativeBinding, NativeTarget } from "./types.js";
2
+ /** The most bytes (UTF-8) of a native or SDK run's standing instructions kept as its learning's evidence: a source policy
3
+ * past it is cut, and learning is skipped for the run. */
4
+ export declare const INSTRUCTION_EVIDENCE_BYTES = 65536;
2
5
  export type NativeInstructionSnapshot = {
3
6
  text: string;
4
7
  files: {
@@ -2,8 +2,10 @@ import { readFile } from "node:fs/promises";
2
2
  import { createHash } from "node:crypto";
3
3
  import { basename, dirname, sep } from "node:path";
4
4
  import { parse as parseToml } from "smol-toml";
5
- import { NATIVE_GRADE_INSTRUCTION_BYTES } from "../learn/grade.js";
6
5
  import { NATIVE_RUNTIME_FACTS, NATIVE_CLAUDE_POLICY_UNRESOLVED, NATIVE_CLAUDE_ADDITIONAL_POLICY_UNRESOLVED } from './runtimes.js';
6
+ /** The most bytes (UTF-8) of a native or SDK run's standing instructions kept as its learning's evidence: a source policy
7
+ * past it is cut, and learning is skipped for the run. */
8
+ export const INSTRUCTION_EVIDENCE_BYTES = 65_536;
7
9
  const depth = (path) => path.split(sep).length;
8
10
  const scopeOf = (path) => basename(dirname(path)) === ".claude" ? dirname(dirname(path)) : dirname(path);
9
11
  /** Read-only, bounded policy evidence for grading. This text is never installed as grader runtime instructions. */
@@ -107,10 +109,10 @@ export function withSavedNativeInstructions(snapshot, instructions, redact) {
107
109
  }
108
110
  function boundedSnapshot(text, files, truncated, incomplete) {
109
111
  const bytes = Buffer.from(text, "utf8");
110
- if (bytes.length <= NATIVE_GRADE_INSTRUCTION_BYTES)
112
+ if (bytes.length <= INSTRUCTION_EVIDENCE_BYTES)
111
113
  return { text, files, truncated, ...(incomplete ? { incomplete } : {}) };
112
114
  const marker = "\n\n[Native instruction snapshot truncated: additional standing policy was omitted. Do not assume the excerpt is complete.]";
113
- let end = NATIVE_GRADE_INSTRUCTION_BYTES - Buffer.byteLength(marker, "utf8"), prefix = "";
115
+ let end = INSTRUCTION_EVIDENCE_BYTES - Buffer.byteLength(marker, "utf8"), prefix = "";
114
116
  const decoder = new TextDecoder("utf-8", { fatal: true });
115
117
  // A prefix must end on a whole UTF8 codepoint, including when a policy uses non-ASCII text.
116
118
  for (let trim = 0; trim < 4; trim++) {
@@ -5,13 +5,11 @@ import { createHash } from 'node:crypto';
5
5
  import { mkdir, mkdtemp, rm } from 'node:fs/promises';
6
6
  import { tmpdir } from 'node:os';
7
7
  import { join } from 'node:path';
8
- import { execFile } from 'node:child_process';
9
- import { promisify, types } from 'node:util';
8
+ import { types } from 'node:util';
10
9
  import { discoverNative, nativeIdentity, verifyNative } from './discovery.js';
11
10
  import { nativeEnvironment } from './environment.js';
12
11
  import { openNativeSession } from './runtime.js';
13
12
  import { snapshotNativeInstructions } from './instructions.js';
14
- import { nativeSkillContext } from './context.js';
15
13
  import { exportRemoteHistory } from '../import.js';
16
14
  import { runnerSecrets, secretRedactor } from '../runner/redact.js';
17
15
  import { redactedOutput } from '../key-refusal.js';
@@ -156,19 +154,19 @@ export async function runRemoteWorkerBridge(options = {}) {
156
154
  expireIdle(sessionKey);
157
155
  }
158
156
  }
159
- if (type !== 'open' && type !== 'grade')
157
+ if (type !== 'open')
160
158
  throw new Error('Unsupported remote operation.');
161
159
  const approved = await current(message.target), identity = nativeIdentity(approved);
162
- const sessionKey = type === 'grade' ? `grade-${key(message.id)}` : key(message.session_key);
160
+ const sessionKey = key(message.session_key);
163
161
  if (sessions.has(sessionKey) || sessions.size >= 8)
164
162
  throw new Error('The native session already exists or the source session limit was reached.');
165
163
  signal.throwIfAborted();
166
- if (type === 'open' && (typeof payload.expected_fingerprint !== 'string' || payload.expected_fingerprint !== approved.fingerprint))
164
+ if ((typeof payload.expected_fingerprint !== 'string' || payload.expected_fingerprint !== approved.fingerprint))
167
165
  throw new Error('The source configuration changed after preparation. Start a new run after reviewing it.');
168
166
  const root = await mkdtemp(join(tmpdir(), 'agentrun-remote-'));
169
167
  const locks = join(tmpdir(), `agentrun-native-locks-${process.getuid?.() ?? 'user'}`);
170
168
  await mkdir(locks, { mode: 0o700, recursive: true });
171
- const lock = join(locks, createHash('sha256').update(type === 'grade' ? root : approved.project).digest('hex'));
169
+ const lock = join(locks, createHash('sha256').update(approved.project).digest('hex'));
172
170
  try {
173
171
  await mkdir(lock, { mode: 0o700 });
174
172
  }
@@ -178,45 +176,13 @@ export async function runRemoteWorkerBridge(options = {}) {
178
176
  }
179
177
  let opened;
180
178
  try {
181
- let target = approved, context = payload.context === undefined ? '' : text(payload.context);
182
- if (type === 'grade') {
183
- await promisify(execFile)('git', ['init', '--quiet', root], { timeout: 10_000 });
184
- const report = await discoverNative({ project: root, runtime: approved.runtime, env });
185
- target = { ...report.targets.find(item => item.selector.kind === 'project'), connected: true };
186
- if (!target.runtime)
187
- throw new Error('The native grading runtime is unavailable.');
188
- context = '';
189
- }
190
- else if (payload.skills !== undefined) {
191
- if (!Array.isArray(payload.skills) || payload.skills.length > 64)
192
- throw new Error('Invalid learned skills.');
193
- const skills = payload.skills.map(value => {
194
- const skill = object(value), files = object(skill.files);
195
- if (Object.keys(files).length > 128)
196
- throw new Error('Too many learned skill resources.');
197
- const read = {};
198
- for (const [path, value] of Object.entries(files))
199
- read[path] = text(value);
200
- return { name: text(skill.name, 128), files: read };
201
- });
202
- if (Buffer.byteLength(JSON.stringify(skills)) > 2_000_000)
203
- throw new Error('Learned skills exceed the source limit.');
204
- context = [context, await nativeSkillContext(join(root, 'skills'), skills)].filter(Boolean).join('\n\n');
205
- }
179
+ const context = payload.context === undefined ? '' : text(payload.context);
206
180
  signal.throwIfAborted();
207
- const session = opened = await openNativeSession({ target, context, env, signal, onEvent: event => { output({ event, session_key: sessionKey }); } });
181
+ const session = opened = await openNativeSession({ target: approved, context, env, signal, onEvent: event => { output({ event, session_key: sessionKey }); } });
208
182
  signal.throwIfAborted();
209
183
  sessions.set(sessionKey, { session, root, lock, identity });
210
- if (type === 'open') {
211
- expireIdle(sessionKey);
212
- return {};
213
- }
214
- try {
215
- return await session.send(text(payload.prompt), { signal, reflection: true, timeoutMs: timeout(payload.timeout_ms) });
216
- }
217
- finally {
218
- await close(sessionKey);
219
- }
184
+ expireIdle(sessionKey);
185
+ return {};
220
186
  }
221
187
  catch (error) {
222
188
  try {
@@ -3,7 +3,7 @@ import type { Store } from '../store/store.js';
3
3
  import type { NativeBinding, NativeEvent, NativeResult, NativeSession } from './types.js';
4
4
  import type { NativeInstructionSnapshot } from './instructions.js';
5
5
  export declare const REMOTE_COMPLETION_BODY_BYTES = 4000000;
6
- export type RemoteCommandType = 'prepare' | 'open' | 'send' | 'close' | 'grade';
6
+ export type RemoteCommandType = 'prepare' | 'open' | 'send' | 'close';
7
7
  export declare class RemoteConnectors {
8
8
  readonly store: Store;
9
9
  readonly now: () => number;
@@ -31,12 +31,11 @@ export declare class RemoteConnectors {
31
31
  history_only: boolean;
32
32
  runtime: "codex" | "claude-code";
33
33
  machine_id: string;
34
- state: "needs_verification" | "needs_attention" | "ready";
34
+ state: "ready" | "needs_verification" | "needs_attention";
35
35
  issues: string[];
36
36
  capabilities: {
37
37
  launch: boolean;
38
- notes: boolean;
39
- skills: boolean;
38
+ learning: boolean;
40
39
  workflows: false;
41
40
  approval: "native" | "unavailable";
42
41
  usage: boolean;
@@ -69,12 +68,11 @@ export declare class RemoteConnectors {
69
68
  history_only: boolean;
70
69
  runtime: "codex" | "claude-code";
71
70
  machine_id: string;
72
- state: "needs_verification" | "needs_attention" | "ready";
71
+ state: "ready" | "needs_verification" | "needs_attention";
73
72
  issues: string[];
74
73
  capabilities: {
75
74
  launch: boolean;
76
- notes: boolean;
77
- skills: boolean;
75
+ learning: boolean;
78
76
  workflows: false;
79
77
  approval: "native" | "unavailable";
80
78
  usage: boolean;
@@ -105,12 +103,11 @@ export declare class RemoteConnectors {
105
103
  history_only: boolean;
106
104
  runtime: "codex" | "claude-code";
107
105
  machine_id: string;
108
- state: "needs_verification" | "needs_attention" | "ready";
106
+ state: "ready" | "needs_verification" | "needs_attention";
109
107
  issues: string[];
110
108
  capabilities: {
111
109
  launch: boolean;
112
- notes: boolean;
113
- skills: boolean;
110
+ learning: boolean;
114
111
  workflows: false;
115
112
  approval: "native" | "unavailable";
116
113
  usage: boolean;
@@ -174,14 +171,10 @@ export declare function checkedPrepared(before: NativeBinding, result: unknown):
174
171
  };
175
172
  export declare function remoteResult(value: unknown): NativeResult;
176
173
  export declare function verifyRemote(store: Store, entry: AgentEntry): Promise<AgentEntry>;
177
- /** A session transport only. Task/reflection/grading policy remains in the native loop and source runtime. */
174
+ /** A session transport only. Task and end-of-run policy remains in the native loop and source runtime. */
178
175
  export declare function openRemoteSession(broker: RemoteConnectors, target: NativeBinding, options: {
179
176
  signal?: AbortSignal;
180
177
  context?: string;
181
- skills?: readonly {
182
- name: string;
183
- files?: Record<string, string>;
184
- }[];
185
178
  runId: string;
186
179
  onEvent?: (event: NativeEvent) => Promise<void> | void;
187
180
  }): Promise<NativeSession>;
@@ -444,7 +444,7 @@ export function checkedPrepared(before, result) {
444
444
  if (unchecked && !instructions.incomplete)
445
445
  instructions = { ...instructions, incomplete: unchecked };
446
446
  if (instructions.incomplete || instructions.truncated)
447
- target = { ...target, capabilities: { ...target.capabilities, notes: false, skills: false }, issues: [...target.issues, `Self-improvement is unavailable: ${instructions.incomplete ?? 'the source instruction snapshot exceeds the grading evidence limit.'} Native jobs remain available; no incomplete policy is automatically graded.`] };
447
+ target = { ...target, capabilities: { ...target.capabilities, learning: false }, issues: [...target.issues, `Self-improvement is unavailable: ${instructions.incomplete ?? 'the source instruction snapshot exceeds the grading evidence limit.'} Native jobs remain available; no incomplete policy is automatically graded.`] };
448
448
  return { target, instructions };
449
449
  }
450
450
  function validUsage(value) {
@@ -478,10 +478,10 @@ export async function verifyRemote(store, entry) {
478
478
  const prepared = checkedPrepared(binding, await new RemoteConnectors(store).request(binding, 'prepare', {}, { timeoutMs: 30_000 }));
479
479
  return updateNative(store, entry, { ...prepared.target, connected: binding.connected });
480
480
  }
481
- /** A session transport only. Task/reflection/grading policy remains in the native loop and source runtime. */
481
+ /** A session transport only. Task and end-of-run policy remains in the native loop and source runtime. */
482
482
  export async function openRemoteSession(broker, target, options) {
483
483
  const sessionKey = opaque('session');
484
- await broker.request(target, 'open', { context: options.context ?? '', skills: options.skills ?? [], run_id: options.runId, expected_fingerprint: target.fingerprint }, { signal: options.signal, sessionKey, timeoutMs: 30_000 });
484
+ await broker.request(target, 'open', { context: options.context ?? '', run_id: options.runId, expected_fingerprint: target.fingerprint }, { signal: options.signal, sessionKey, timeoutMs: 30_000 });
485
485
  return {
486
486
  send: async (prompt, sendOptions = {}) => remoteResult(await broker.request(target, 'send', { prompt, reflection: sendOptions.reflection ?? false, timeout_ms: sendOptions.timeoutMs ?? 180_000 }, { signal: sendOptions.signal ?? options.signal, sessionKey, timeoutMs: (sendOptions.timeoutMs ?? 180_000) + 5000, onEvent: options.onEvent })),
487
487
  close: async () => { try {
@@ -4,7 +4,7 @@ const strings = { type: 'array', items: text };
4
4
  const object = (properties, required = Object.keys(properties)) => ({ type: 'object', additionalProperties: false, properties, required });
5
5
  export const NATIVE_SELECTOR = object({ kind: { enum: ['project', 'agent', 'profile'] }, name: text }, ['kind']);
6
6
  export const NATIVE_USAGE = object({ input_tokens: { type: ['integer', 'null'] }, output_tokens: { type: ['integer', 'null'] }, cache_read_tokens: { type: ['integer', 'null'] }, cache_write_tokens: { type: ['integer', 'null'] }, cost_usd: { type: ['number', 'null'] } });
7
- export const NATIVE_TARGET = object({ runtime: { enum: ['claude-code', 'codex'] }, project: text, selector: NATIVE_SELECTOR, machine_id: text, version: nullableText, model: nullableText, fingerprint: text, configuration: { type: 'array', items: object({ path: text, sha256: text }) }, skills: strings, mcp_servers: strings, state: { enum: ['needs_verification', 'needs_attention', 'ready'] }, issues: strings, capabilities: object({ launch: { type: 'boolean' }, notes: { type: 'boolean' }, skills: { type: 'boolean' }, workflows: { const: false }, approval: { enum: ['native', 'unavailable'] }, usage: { type: 'boolean' } }) });
7
+ export const NATIVE_TARGET = object({ runtime: { enum: ['claude-code', 'codex'] }, project: text, selector: NATIVE_SELECTOR, machine_id: text, version: nullableText, model: nullableText, fingerprint: text, configuration: { type: 'array', items: object({ path: text, sha256: text }) }, skills: strings, mcp_servers: strings, state: { enum: ['needs_verification', 'needs_attention', 'ready'] }, issues: strings, capabilities: object({ launch: { type: 'boolean' }, learning: { type: 'boolean' }, workflows: { const: false }, approval: { enum: ['native', 'unavailable'] }, usage: { type: 'boolean' } }) });
8
8
  export const NATIVE_BINDING = { ...NATIVE_TARGET, properties: { ...NATIVE_TARGET.properties, connected: { type: 'boolean' }, verified_at: text, remote: object({ connector_id: text, target_id: text }) }, required: [...NATIVE_TARGET.required, 'connected'], 'x-agentrun-serve': 'native/1' };
9
9
  export const NATIVE_RUN = { ...object({ runtime: text, project: text, selector: NATIVE_SELECTOR, machine_id: text, fingerprint: text, session_id: nullableText, model: nullableText, learning_revision: nullableText, usage: object({ task: { oneOf: [NATIVE_USAGE, { type: 'null' }] }, reflection: { type: 'array', items: NATIVE_USAGE } }), model_requests: { type: 'null' } }), 'x-agentrun-serve': 'native/1' };
10
10
  const response = (schema) => ({ description: 'Native connection on the source machine.', content: { 'application/json': { schema } } });
@@ -23,8 +23,8 @@ export type NativeTarget = {
23
23
  issues: string[];
24
24
  capabilities: {
25
25
  launch: boolean;
26
- notes: boolean;
27
- skills: boolean;
26
+ /** Whether its runs may learn: its owner's corrections reach it and its runs compile (no unresolved policy). */
27
+ learning: boolean;
28
28
  workflows: false;
29
29
  approval: "native" | "unavailable";
30
30
  usage: boolean;