@namzu/sdk 65.3.0 → 68.0.0

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 (638) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/dist/account/lock.d.ts +4 -12
  3. package/dist/account/lock.d.ts.map +1 -1
  4. package/dist/account/lock.js +5 -140
  5. package/dist/account/lock.js.map +1 -1
  6. package/dist/account/registry.d.ts.map +1 -1
  7. package/dist/account/registry.js +50 -6
  8. package/dist/account/registry.js.map +1 -1
  9. package/dist/account/types.d.ts +7 -5
  10. package/dist/account/types.d.ts.map +1 -1
  11. package/dist/account/types.js +6 -7
  12. package/dist/account/types.js.map +1 -1
  13. package/dist/authorization/dangerous-commands.d.ts +64 -0
  14. package/dist/authorization/dangerous-commands.d.ts.map +1 -0
  15. package/dist/authorization/dangerous-commands.js +479 -0
  16. package/dist/authorization/dangerous-commands.js.map +1 -0
  17. package/dist/authorization/gate.d.ts.map +1 -1
  18. package/dist/authorization/gate.js +19 -5
  19. package/dist/authorization/gate.js.map +1 -1
  20. package/dist/authorization/protected-paths.d.ts +11 -6
  21. package/dist/authorization/protected-paths.d.ts.map +1 -1
  22. package/dist/authorization/protected-paths.js +13 -8
  23. package/dist/authorization/protected-paths.js.map +1 -1
  24. package/dist/authorization/readonly-commands.d.ts +6 -1
  25. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  26. package/dist/authorization/readonly-commands.js +35 -1
  27. package/dist/authorization/readonly-commands.js.map +1 -1
  28. package/dist/authorization/removal.d.ts +10 -0
  29. package/dist/authorization/removal.d.ts.map +1 -1
  30. package/dist/authorization/removal.js +7 -7
  31. package/dist/authorization/removal.js.map +1 -1
  32. package/dist/authorization/rules.d.ts +10 -0
  33. package/dist/authorization/rules.d.ts.map +1 -1
  34. package/dist/authorization/rules.js +60 -14
  35. package/dist/authorization/rules.js.map +1 -1
  36. package/dist/authorization/shell-lexer.d.ts +10 -0
  37. package/dist/authorization/shell-lexer.d.ts.map +1 -1
  38. package/dist/authorization/shell-lexer.js +15 -0
  39. package/dist/authorization/shell-lexer.js.map +1 -1
  40. package/dist/bridge/acp/permission.d.ts +5 -0
  41. package/dist/bridge/acp/permission.d.ts.map +1 -1
  42. package/dist/bridge/acp/permission.js.map +1 -1
  43. package/dist/bridge/acp/server.d.ts +8 -1
  44. package/dist/bridge/acp/server.d.ts.map +1 -1
  45. package/dist/bridge/acp/server.js +48 -6
  46. package/dist/bridge/acp/server.js.map +1 -1
  47. package/dist/compaction/context-breakdown.d.ts +25 -6
  48. package/dist/compaction/context-breakdown.d.ts.map +1 -1
  49. package/dist/compaction/context-breakdown.js +27 -7
  50. package/dist/compaction/context-breakdown.js.map +1 -1
  51. package/dist/compaction/dangling.d.ts.map +1 -1
  52. package/dist/compaction/dangling.js +2 -0
  53. package/dist/compaction/dangling.js.map +1 -1
  54. package/dist/compaction/extractor.d.ts +7 -1
  55. package/dist/compaction/extractor.d.ts.map +1 -1
  56. package/dist/compaction/extractor.js +8 -1
  57. package/dist/compaction/extractor.js.map +1 -1
  58. package/dist/compaction/index.d.ts +1 -1
  59. package/dist/compaction/index.d.ts.map +1 -1
  60. package/dist/compaction/index.js +1 -1
  61. package/dist/compaction/index.js.map +1 -1
  62. package/dist/compaction/managers/structured.js +2 -2
  63. package/dist/compaction/managers/structured.js.map +1 -1
  64. package/dist/compaction/manual.d.ts.map +1 -1
  65. package/dist/compaction/manual.js +11 -6
  66. package/dist/compaction/manual.js.map +1 -1
  67. package/dist/compaction/model-summary.d.ts.map +1 -1
  68. package/dist/compaction/model-summary.js +7 -1
  69. package/dist/compaction/model-summary.js.map +1 -1
  70. package/dist/compaction/summary.d.ts +13 -2
  71. package/dist/compaction/summary.d.ts.map +1 -1
  72. package/dist/compaction/summary.js +46 -3
  73. package/dist/compaction/summary.js.map +1 -1
  74. package/dist/constants/tools/index.d.ts +18 -1
  75. package/dist/constants/tools/index.d.ts.map +1 -1
  76. package/dist/constants/tools/index.js +28 -16
  77. package/dist/constants/tools/index.js.map +1 -1
  78. package/dist/manager/session/turn-recorder.d.ts +6 -0
  79. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  80. package/dist/manager/session/turn-recorder.js +29 -1
  81. package/dist/manager/session/turn-recorder.js.map +1 -1
  82. package/dist/network/audit.d.ts +49 -0
  83. package/dist/network/audit.d.ts.map +1 -0
  84. package/dist/network/audit.js +84 -0
  85. package/dist/network/audit.js.map +1 -0
  86. package/dist/network/clock.d.ts +21 -0
  87. package/dist/network/clock.d.ts.map +1 -0
  88. package/dist/network/clock.js +51 -0
  89. package/dist/network/clock.js.map +1 -0
  90. package/dist/network/discovery-mdns.d.ts +120 -0
  91. package/dist/network/discovery-mdns.d.ts.map +1 -0
  92. package/dist/network/discovery-mdns.js +442 -0
  93. package/dist/network/discovery-mdns.js.map +1 -0
  94. package/dist/network/discovery.d.ts +63 -0
  95. package/dist/network/discovery.d.ts.map +1 -0
  96. package/dist/network/discovery.js +163 -0
  97. package/dist/network/discovery.js.map +1 -0
  98. package/dist/network/fingerprint.d.ts +73 -0
  99. package/dist/network/fingerprint.d.ts.map +1 -0
  100. package/dist/network/fingerprint.js +208 -0
  101. package/dist/network/fingerprint.js.map +1 -0
  102. package/dist/network/identity.d.ts +38 -0
  103. package/dist/network/identity.d.ts.map +1 -0
  104. package/dist/network/identity.js +71 -0
  105. package/dist/network/identity.js.map +1 -0
  106. package/dist/network/index.d.ts +39 -0
  107. package/dist/network/index.d.ts.map +1 -0
  108. package/dist/network/index.js +25 -0
  109. package/dist/network/index.js.map +1 -0
  110. package/dist/network/join.d.ts +69 -0
  111. package/dist/network/join.d.ts.map +1 -0
  112. package/dist/network/join.js +136 -0
  113. package/dist/network/join.js.map +1 -0
  114. package/dist/network/mail-policy.d.ts +97 -0
  115. package/dist/network/mail-policy.d.ts.map +1 -0
  116. package/dist/network/mail-policy.js +147 -0
  117. package/dist/network/mail-policy.js.map +1 -0
  118. package/dist/network/membership.d.ts +76 -0
  119. package/dist/network/membership.d.ts.map +1 -0
  120. package/dist/network/membership.js +225 -0
  121. package/dist/network/membership.js.map +1 -0
  122. package/dist/network/roster.d.ts +59 -0
  123. package/dist/network/roster.d.ts.map +1 -0
  124. package/dist/network/roster.js +120 -0
  125. package/dist/network/roster.js.map +1 -0
  126. package/dist/network/service.d.ts +303 -0
  127. package/dist/network/service.d.ts.map +1 -0
  128. package/dist/network/service.js +1891 -0
  129. package/dist/network/service.js.map +1 -0
  130. package/dist/network/store.d.ts +141 -0
  131. package/dist/network/store.d.ts.map +1 -0
  132. package/dist/network/store.js +198 -0
  133. package/dist/network/store.js.map +1 -0
  134. package/dist/network/transport.d.ts +96 -0
  135. package/dist/network/transport.d.ts.map +1 -0
  136. package/dist/network/transport.js +342 -0
  137. package/dist/network/transport.js.map +1 -0
  138. package/dist/network/wire.d.ts +345 -0
  139. package/dist/network/wire.d.ts.map +1 -0
  140. package/dist/network/wire.js +212 -0
  141. package/dist/network/wire.js.map +1 -0
  142. package/dist/network/x509.d.ts +28 -0
  143. package/dist/network/x509.d.ts.map +1 -0
  144. package/dist/network/x509.js +84 -0
  145. package/dist/network/x509.js.map +1 -0
  146. package/dist/pals/activity/causality.d.ts.map +1 -1
  147. package/dist/pals/activity/causality.js +14 -2
  148. package/dist/pals/activity/causality.js.map +1 -1
  149. package/dist/peers/endpoint.d.ts.map +1 -1
  150. package/dist/peers/endpoint.js +6 -0
  151. package/dist/peers/endpoint.js.map +1 -1
  152. package/dist/peers/envelope.d.ts +18 -0
  153. package/dist/peers/envelope.d.ts.map +1 -1
  154. package/dist/peers/envelope.js +68 -5
  155. package/dist/peers/envelope.js.map +1 -1
  156. package/dist/peers/index.d.ts +5 -4
  157. package/dist/peers/index.d.ts.map +1 -1
  158. package/dist/peers/index.js +3 -2
  159. package/dist/peers/index.js.map +1 -1
  160. package/dist/peers/mode-word.d.ts +10 -0
  161. package/dist/peers/mode-word.d.ts.map +1 -0
  162. package/dist/peers/mode-word.js +19 -0
  163. package/dist/peers/mode-word.js.map +1 -0
  164. package/dist/peers/protocol.d.ts +42 -0
  165. package/dist/peers/protocol.d.ts.map +1 -1
  166. package/dist/peers/protocol.js +22 -1
  167. package/dist/peers/protocol.js.map +1 -1
  168. package/dist/peers/record.d.ts +8 -0
  169. package/dist/peers/record.d.ts.map +1 -1
  170. package/dist/peers/record.js +5 -0
  171. package/dist/peers/record.js.map +1 -1
  172. package/dist/plugin/session-hook-env.d.ts.map +1 -1
  173. package/dist/plugin/session-hook-env.js +22 -2
  174. package/dist/plugin/session-hook-env.js.map +1 -1
  175. package/dist/plugin/shell-hook.d.ts +16 -2
  176. package/dist/plugin/shell-hook.d.ts.map +1 -1
  177. package/dist/plugin/shell-hook.js +183 -14
  178. package/dist/plugin/shell-hook.js.map +1 -1
  179. package/dist/pricing/catalogue.generated.d.ts.map +1 -1
  180. package/dist/pricing/catalogue.generated.js +6 -0
  181. package/dist/pricing/catalogue.generated.js.map +1 -1
  182. package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
  183. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  184. package/dist/prompt/coding-agent-doctrine.js +33 -38
  185. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  186. package/dist/provider/fallback.d.ts.map +1 -1
  187. package/dist/provider/fallback.js +12 -0
  188. package/dist/provider/fallback.js.map +1 -1
  189. package/dist/provider/idle-timeout.d.ts.map +1 -1
  190. package/dist/provider/idle-timeout.js +5 -0
  191. package/dist/provider/idle-timeout.js.map +1 -1
  192. package/dist/provider/model-window-suffix.d.ts.map +1 -1
  193. package/dist/provider/model-window-suffix.js +1 -0
  194. package/dist/provider/model-window-suffix.js.map +1 -1
  195. package/dist/provider/retry.d.ts.map +1 -1
  196. package/dist/provider/retry.js +5 -0
  197. package/dist/provider/retry.js.map +1 -1
  198. package/dist/public-runtime.d.ts +16 -8
  199. package/dist/public-runtime.d.ts.map +1 -1
  200. package/dist/public-runtime.js +24 -7
  201. package/dist/public-runtime.js.map +1 -1
  202. package/dist/public-tools.d.ts +3 -2
  203. package/dist/public-tools.d.ts.map +1 -1
  204. package/dist/public-tools.js +2 -2
  205. package/dist/public-tools.js.map +1 -1
  206. package/dist/public-types.d.ts +10 -5
  207. package/dist/public-types.d.ts.map +1 -1
  208. package/dist/registry/command/kernel-commands.d.ts +11 -1
  209. package/dist/registry/command/kernel-commands.d.ts.map +1 -1
  210. package/dist/registry/command/kernel-commands.js +114 -46
  211. package/dist/registry/command/kernel-commands.js.map +1 -1
  212. package/dist/runtime/jobs/registry.d.ts +29 -1
  213. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  214. package/dist/runtime/jobs/registry.js +64 -0
  215. package/dist/runtime/jobs/registry.js.map +1 -1
  216. package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
  217. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  218. package/dist/runtime/query/auto-review/classifier.js +40 -12
  219. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  220. package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
  221. package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
  222. package/dist/runtime/query/auto-review/feedback.js +45 -0
  223. package/dist/runtime/query/auto-review/feedback.js.map +1 -0
  224. package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
  225. package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
  226. package/dist/runtime/query/auto-review/git-status.js +379 -0
  227. package/dist/runtime/query/auto-review/git-status.js.map +1 -0
  228. package/dist/runtime/query/auto-review/index.d.ts +3 -3
  229. package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
  230. package/dist/runtime/query/auto-review/index.js +2 -2
  231. package/dist/runtime/query/auto-review/index.js.map +1 -1
  232. package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
  233. package/dist/runtime/query/auto-review/prompt.js +6 -1
  234. package/dist/runtime/query/auto-review/prompt.js.map +1 -1
  235. package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
  236. package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
  237. package/dist/runtime/query/auto-review/transcript.js +48 -2
  238. package/dist/runtime/query/auto-review/transcript.js.map +1 -1
  239. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  240. package/dist/runtime/query/executor/tool-call-admission.js +40 -3
  241. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  242. package/dist/runtime/query/executor.d.ts +32 -10
  243. package/dist/runtime/query/executor.d.ts.map +1 -1
  244. package/dist/runtime/query/executor.js +78 -17
  245. package/dist/runtime/query/executor.js.map +1 -1
  246. package/dist/runtime/query/index.d.ts +9 -0
  247. package/dist/runtime/query/index.d.ts.map +1 -1
  248. package/dist/runtime/query/index.js +54 -17
  249. package/dist/runtime/query/index.js.map +1 -1
  250. package/dist/runtime/query/iteration/index.d.ts +1 -1
  251. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  252. package/dist/runtime/query/iteration/index.js +20 -6
  253. package/dist/runtime/query/iteration/index.js.map +1 -1
  254. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  255. package/dist/runtime/query/iteration/phases/compaction.js +5 -2
  256. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  257. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  258. package/dist/runtime/query/iteration/phases/context.js +5 -0
  259. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  260. package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
  261. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  262. package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
  263. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  264. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  265. package/dist/runtime/query/iteration/phases/tool-review.js +6 -1
  266. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  267. package/dist/runtime/query/pasted-frames.d.ts +34 -0
  268. package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
  269. package/dist/runtime/query/pasted-frames.js +108 -0
  270. package/dist/runtime/query/pasted-frames.js.map +1 -0
  271. package/dist/runtime/query/path-escalation.d.ts +6 -0
  272. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  273. package/dist/runtime/query/path-escalation.js +15 -3
  274. package/dist/runtime/query/path-escalation.js.map +1 -1
  275. package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
  276. package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
  277. package/dist/runtime/query/request-interrupted-turns.js +43 -0
  278. package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
  279. package/dist/runtime/query/review-policy.d.ts +16 -6
  280. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  281. package/dist/runtime/query/review-policy.js +111 -15
  282. package/dist/runtime/query/review-policy.js.map +1 -1
  283. package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
  284. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  285. package/dist/runtime/query/turn/outcome-ledger.js +94 -6
  286. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  287. package/dist/runtime/query/unanswered.d.ts +19 -0
  288. package/dist/runtime/query/unanswered.d.ts.map +1 -0
  289. package/dist/runtime/query/unanswered.js +25 -0
  290. package/dist/runtime/query/unanswered.js.map +1 -0
  291. package/dist/runtime/system-events.d.ts +4 -4
  292. package/dist/runtime/system-events.d.ts.map +1 -1
  293. package/dist/runtime/system-events.js +2 -0
  294. package/dist/runtime/system-events.js.map +1 -1
  295. package/dist/session/workspace/git-worktree.d.ts +8 -0
  296. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  297. package/dist/session/workspace/git-worktree.js +21 -3
  298. package/dist/session/workspace/git-worktree.js.map +1 -1
  299. package/dist/store/evidence/source-kind.d.ts +1 -1
  300. package/dist/store/evidence/source-kind.d.ts.map +1 -1
  301. package/dist/store/evidence/source-kind.js +1 -1
  302. package/dist/store/evidence/source-kind.js.map +1 -1
  303. package/dist/store/goal/index.d.ts +53 -3
  304. package/dist/store/goal/index.d.ts.map +1 -1
  305. package/dist/store/goal/index.js +245 -9
  306. package/dist/store/goal/index.js.map +1 -1
  307. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  308. package/dist/store/session-index/sqlite.js +42 -3
  309. package/dist/store/session-index/sqlite.js.map +1 -1
  310. package/dist/store/session-log/disk.js +1 -1
  311. package/dist/store/session-log/disk.js.map +1 -1
  312. package/dist/store/session-log/lease.d.ts.map +1 -1
  313. package/dist/store/session-log/lease.js +3 -2
  314. package/dist/store/session-log/lease.js.map +1 -1
  315. package/dist/tools/admit-facts.d.ts.map +1 -1
  316. package/dist/tools/admit-facts.js +2 -0
  317. package/dist/tools/admit-facts.js.map +1 -1
  318. package/dist/tools/builtins/bash.d.ts +10 -2
  319. package/dist/tools/builtins/bash.d.ts.map +1 -1
  320. package/dist/tools/builtins/bash.js +56 -17
  321. package/dist/tools/builtins/bash.js.map +1 -1
  322. package/dist/tools/builtins/browser-local.d.ts +117 -0
  323. package/dist/tools/builtins/browser-local.d.ts.map +1 -0
  324. package/dist/tools/builtins/browser-local.js +437 -0
  325. package/dist/tools/builtins/browser-local.js.map +1 -0
  326. package/dist/tools/builtins/browser.d.ts +18 -1
  327. package/dist/tools/builtins/browser.d.ts.map +1 -1
  328. package/dist/tools/builtins/browser.js +84 -6
  329. package/dist/tools/builtins/browser.js.map +1 -1
  330. package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
  331. package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
  332. package/dist/tools/builtins/computer-use-window-id.js +52 -0
  333. package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
  334. package/dist/tools/builtins/computer-use.d.ts +65 -7
  335. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  336. package/dist/tools/builtins/computer-use.js +384 -71
  337. package/dist/tools/builtins/computer-use.js.map +1 -1
  338. package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
  339. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  340. package/dist/tools/builtins/content-fingerprint.js +7 -1
  341. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  342. package/dist/tools/builtins/edit.d.ts.map +1 -1
  343. package/dist/tools/builtins/edit.js +89 -7
  344. package/dist/tools/builtins/edit.js.map +1 -1
  345. package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
  346. package/dist/tools/builtins/file-write-result.js +2 -1
  347. package/dist/tools/builtins/file-write-result.js.map +1 -1
  348. package/dist/tools/builtins/grep.js +1 -1
  349. package/dist/tools/builtins/grep.js.map +1 -1
  350. package/dist/tools/builtins/job.d.ts.map +1 -1
  351. package/dist/tools/builtins/job.js +4 -2
  352. package/dist/tools/builtins/job.js.map +1 -1
  353. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  354. package/dist/tools/builtins/monitor.js +6 -1
  355. package/dist/tools/builtins/monitor.js.map +1 -1
  356. package/dist/tools/builtins/search-tools.d.ts +12 -1
  357. package/dist/tools/builtins/search-tools.d.ts.map +1 -1
  358. package/dist/tools/builtins/search-tools.js +166 -20
  359. package/dist/tools/builtins/search-tools.js.map +1 -1
  360. package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
  361. package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
  362. package/dist/tools/builtins/shell-read-credit.js +95 -27
  363. package/dist/tools/builtins/shell-read-credit.js.map +1 -1
  364. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  365. package/dist/tools/builtins/wait-for-job.js +14 -3
  366. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  367. package/dist/tools/builtins/web-guidance.d.ts +6 -0
  368. package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
  369. package/dist/tools/builtins/web-guidance.js +6 -0
  370. package/dist/tools/builtins/web-guidance.js.map +1 -1
  371. package/dist/tools/builtins/web.d.ts.map +1 -1
  372. package/dist/tools/builtins/web.js +2 -1
  373. package/dist/tools/builtins/web.js.map +1 -1
  374. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  375. package/dist/tools/builtins/write-file.js +32 -2
  376. package/dist/tools/builtins/write-file.js.map +1 -1
  377. package/dist/tools/command-shell.d.ts +1 -1
  378. package/dist/tools/command-shell.d.ts.map +1 -1
  379. package/dist/tools/command-shell.js +6 -8
  380. package/dist/tools/command-shell.js.map +1 -1
  381. package/dist/tools/defineTool.d.ts +2 -0
  382. package/dist/tools/defineTool.d.ts.map +1 -1
  383. package/dist/tools/defineTool.js +17 -1
  384. package/dist/tools/defineTool.js.map +1 -1
  385. package/dist/tools/goal/confirmation.d.ts +82 -1
  386. package/dist/tools/goal/confirmation.d.ts.map +1 -1
  387. package/dist/tools/goal/confirmation.js +153 -3
  388. package/dist/tools/goal/confirmation.js.map +1 -1
  389. package/dist/tools/goal/index.d.ts.map +1 -1
  390. package/dist/tools/goal/index.js +34 -3
  391. package/dist/tools/goal/index.js.map +1 -1
  392. package/dist/tools/schedules/index.d.ts +1 -0
  393. package/dist/tools/schedules/index.d.ts.map +1 -1
  394. package/dist/tools/schedules/index.js +1 -0
  395. package/dist/tools/schedules/index.js.map +1 -1
  396. package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
  397. package/dist/tools/schedules/loop-tool.js +8 -6
  398. package/dist/tools/schedules/loop-tool.js.map +1 -1
  399. package/dist/tools/schedules/present.js +1 -1
  400. package/dist/tools/schedules/present.js.map +1 -1
  401. package/dist/tools/schedules/timer-tools.d.ts +36 -0
  402. package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
  403. package/dist/tools/schedules/timer-tools.js +234 -0
  404. package/dist/tools/schedules/timer-tools.js.map +1 -0
  405. package/dist/tools/schedules/types.d.ts +68 -3
  406. package/dist/tools/schedules/types.d.ts.map +1 -1
  407. package/dist/tools/task/create.d.ts.map +1 -1
  408. package/dist/tools/task/create.js +2 -0
  409. package/dist/tools/task/create.js.map +1 -1
  410. package/dist/toolsets/manager.d.ts +49 -7
  411. package/dist/toolsets/manager.d.ts.map +1 -1
  412. package/dist/toolsets/manager.js +239 -40
  413. package/dist/toolsets/manager.js.map +1 -1
  414. package/dist/turn/evidence-query.d.ts +18 -1
  415. package/dist/turn/evidence-query.d.ts.map +1 -1
  416. package/dist/turn/evidence-query.js +177 -35
  417. package/dist/turn/evidence-query.js.map +1 -1
  418. package/dist/turn/evidence-recall.d.ts +8 -1
  419. package/dist/turn/evidence-recall.d.ts.map +1 -1
  420. package/dist/turn/evidence-recall.js +82 -22
  421. package/dist/turn/evidence-recall.js.map +1 -1
  422. package/dist/turn/history-shed.d.ts +15 -0
  423. package/dist/turn/history-shed.d.ts.map +1 -0
  424. package/dist/turn/history-shed.js +23 -0
  425. package/dist/turn/history-shed.js.map +1 -0
  426. package/dist/types/acp/index.d.ts +26 -0
  427. package/dist/types/acp/index.d.ts.map +1 -1
  428. package/dist/types/authorization/index.d.ts +9 -1
  429. package/dist/types/authorization/index.d.ts.map +1 -1
  430. package/dist/types/authorization/index.js +11 -2
  431. package/dist/types/authorization/index.js.map +1 -1
  432. package/dist/types/command/index.d.ts +26 -2
  433. package/dist/types/command/index.d.ts.map +1 -1
  434. package/dist/types/command/index.js +5 -2
  435. package/dist/types/command/index.js.map +1 -1
  436. package/dist/types/common/index.d.ts +4 -2
  437. package/dist/types/common/index.d.ts.map +1 -1
  438. package/dist/types/common/index.js.map +1 -1
  439. package/dist/types/goal/index.d.ts +59 -0
  440. package/dist/types/goal/index.d.ts.map +1 -1
  441. package/dist/types/hitl/index.d.ts +10 -0
  442. package/dist/types/hitl/index.d.ts.map +1 -1
  443. package/dist/types/hitl/index.js.map +1 -1
  444. package/dist/types/message/index.d.ts +56 -1
  445. package/dist/types/message/index.d.ts.map +1 -1
  446. package/dist/types/message/index.js +2 -1
  447. package/dist/types/message/index.js.map +1 -1
  448. package/dist/types/permission/index.d.ts +14 -0
  449. package/dist/types/permission/index.d.ts.map +1 -1
  450. package/dist/types/permission/index.js +14 -0
  451. package/dist/types/permission/index.js.map +1 -1
  452. package/dist/types/plugin/index.d.ts +148 -1
  453. package/dist/types/plugin/index.d.ts.map +1 -1
  454. package/dist/types/plugin/index.js +9 -0
  455. package/dist/types/plugin/index.js.map +1 -1
  456. package/dist/types/provider/chat.d.ts +10 -5
  457. package/dist/types/provider/chat.d.ts.map +1 -1
  458. package/dist/types/provider/index.d.ts +1 -0
  459. package/dist/types/provider/index.d.ts.map +1 -1
  460. package/dist/types/provider/interface.d.ts +19 -0
  461. package/dist/types/provider/interface.d.ts.map +1 -1
  462. package/dist/types/provider/limits.d.ts +33 -0
  463. package/dist/types/provider/limits.d.ts.map +1 -0
  464. package/dist/types/provider/limits.js +7 -0
  465. package/dist/types/provider/limits.js.map +1 -0
  466. package/dist/types/provider/model.d.ts +5 -0
  467. package/dist/types/provider/model.d.ts.map +1 -1
  468. package/dist/types/session/config.d.ts +2 -2
  469. package/dist/types/session/outcome.d.ts +5 -2
  470. package/dist/types/session/outcome.d.ts.map +1 -1
  471. package/dist/types/session/outcome.js.map +1 -1
  472. package/dist/types/tool/index.d.ts +30 -0
  473. package/dist/types/tool/index.d.ts.map +1 -1
  474. package/dist/types/tool/index.js.map +1 -1
  475. package/dist/types/tool/presentation.d.ts +4 -0
  476. package/dist/types/tool/presentation.d.ts.map +1 -1
  477. package/dist/utils/cost.d.ts +1 -1
  478. package/dist/utils/cost.d.ts.map +1 -1
  479. package/dist/utils/cost.js +14 -5
  480. package/dist/utils/cost.js.map +1 -1
  481. package/dist/utils/file-lock.d.ts +88 -0
  482. package/dist/utils/file-lock.d.ts.map +1 -0
  483. package/dist/utils/file-lock.js +281 -0
  484. package/dist/utils/file-lock.js.map +1 -0
  485. package/dist/utils/state-backup.d.ts +87 -0
  486. package/dist/utils/state-backup.d.ts.map +1 -0
  487. package/dist/utils/state-backup.js +272 -0
  488. package/dist/utils/state-backup.js.map +1 -0
  489. package/dist/utils/temp-sweep.d.ts +66 -0
  490. package/dist/utils/temp-sweep.d.ts.map +1 -0
  491. package/dist/utils/temp-sweep.js +311 -0
  492. package/dist/utils/temp-sweep.js.map +1 -0
  493. package/dist/utils/temp.d.ts +14 -0
  494. package/dist/utils/temp.d.ts.map +1 -1
  495. package/dist/utils/temp.js +70 -2
  496. package/dist/utils/temp.js.map +1 -1
  497. package/package.json +1 -1
  498. package/src/account/lock.ts +13 -133
  499. package/src/account/registry.ts +75 -21
  500. package/src/account/types.ts +8 -9
  501. package/src/authorization/dangerous-commands.ts +542 -0
  502. package/src/authorization/gate.ts +19 -5
  503. package/src/authorization/protected-paths.ts +13 -8
  504. package/src/authorization/readonly-commands.ts +35 -1
  505. package/src/authorization/removal.ts +7 -7
  506. package/src/authorization/rules.ts +75 -15
  507. package/src/authorization/shell-lexer.ts +19 -0
  508. package/src/bridge/acp/permission.ts +2 -0
  509. package/src/bridge/acp/server.ts +66 -6
  510. package/src/compaction/context-breakdown.ts +53 -11
  511. package/src/compaction/dangling.ts +2 -0
  512. package/src/compaction/extractor.ts +9 -1
  513. package/src/compaction/index.ts +1 -0
  514. package/src/compaction/managers/structured.ts +2 -2
  515. package/src/compaction/manual.ts +11 -3
  516. package/src/compaction/model-summary.ts +8 -1
  517. package/src/compaction/summary.ts +54 -7
  518. package/src/constants/tools/index.ts +30 -16
  519. package/src/manager/session/turn-recorder.ts +37 -1
  520. package/src/network/audit.ts +113 -0
  521. package/src/network/clock.ts +62 -0
  522. package/src/network/discovery-mdns.ts +485 -0
  523. package/src/network/discovery.ts +210 -0
  524. package/src/network/fingerprint.ts +241 -0
  525. package/src/network/identity.ts +98 -0
  526. package/src/network/index.ts +134 -0
  527. package/src/network/join.ts +177 -0
  528. package/src/network/mail-policy.ts +199 -0
  529. package/src/network/membership.ts +290 -0
  530. package/src/network/roster.ts +165 -0
  531. package/src/network/service.ts +2304 -0
  532. package/src/network/store.ts +261 -0
  533. package/src/network/transport.ts +445 -0
  534. package/src/network/wire.ts +250 -0
  535. package/src/network/x509.ts +114 -0
  536. package/src/pals/activity/causality.ts +16 -2
  537. package/src/peers/endpoint.ts +6 -0
  538. package/src/peers/envelope.ts +82 -5
  539. package/src/peers/index.ts +10 -2
  540. package/src/peers/mode-word.ts +18 -0
  541. package/src/peers/protocol.ts +24 -1
  542. package/src/peers/record.ts +5 -0
  543. package/src/plugin/session-hook-env.ts +25 -2
  544. package/src/plugin/shell-hook.ts +208 -14
  545. package/src/pricing/catalogue.generated.ts +6 -0
  546. package/src/pricing/rates.source.json +13 -7
  547. package/src/prompt/coding-agent-doctrine.ts +33 -38
  548. package/src/provider/fallback.ts +11 -0
  549. package/src/provider/idle-timeout.ts +5 -0
  550. package/src/provider/model-window-suffix.ts +1 -0
  551. package/src/provider/retry.ts +5 -0
  552. package/src/public-runtime.ts +116 -1
  553. package/src/public-tools.ts +11 -0
  554. package/src/public-types.ts +74 -1
  555. package/src/registry/command/kernel-commands.ts +136 -49
  556. package/src/runtime/jobs/registry.ts +93 -3
  557. package/src/runtime/query/auto-review/classifier.ts +76 -14
  558. package/src/runtime/query/auto-review/feedback.ts +50 -0
  559. package/src/runtime/query/auto-review/git-status.ts +437 -0
  560. package/src/runtime/query/auto-review/index.ts +7 -2
  561. package/src/runtime/query/auto-review/prompt.ts +6 -1
  562. package/src/runtime/query/auto-review/transcript.ts +67 -4
  563. package/src/runtime/query/executor/tool-call-admission.ts +49 -3
  564. package/src/runtime/query/executor.ts +104 -21
  565. package/src/runtime/query/index.ts +66 -17
  566. package/src/runtime/query/iteration/index.ts +33 -9
  567. package/src/runtime/query/iteration/phases/compaction.ts +4 -0
  568. package/src/runtime/query/iteration/phases/context.ts +5 -0
  569. package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
  570. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  571. package/src/runtime/query/pasted-frames.ts +119 -0
  572. package/src/runtime/query/path-escalation.ts +27 -3
  573. package/src/runtime/query/request-interrupted-turns.ts +47 -0
  574. package/src/runtime/query/review-policy.ts +125 -22
  575. package/src/runtime/query/turn/outcome-ledger.ts +99 -6
  576. package/src/runtime/query/unanswered.ts +35 -0
  577. package/src/runtime/system-events.ts +2 -0
  578. package/src/session/workspace/git-worktree.ts +34 -3
  579. package/src/store/evidence/source-kind.ts +1 -1
  580. package/src/store/goal/index.ts +320 -21
  581. package/src/store/session-index/sqlite.ts +40 -3
  582. package/src/store/session-log/disk.ts +1 -1
  583. package/src/store/session-log/lease.ts +3 -2
  584. package/src/tools/admit-facts.ts +2 -0
  585. package/src/tools/builtins/bash.ts +62 -19
  586. package/src/tools/builtins/browser-local.ts +504 -0
  587. package/src/tools/builtins/browser.ts +108 -6
  588. package/src/tools/builtins/computer-use-window-id.ts +50 -0
  589. package/src/tools/builtins/computer-use.ts +460 -68
  590. package/src/tools/builtins/content-fingerprint.ts +8 -1
  591. package/src/tools/builtins/edit.ts +93 -7
  592. package/src/tools/builtins/file-write-result.ts +2 -1
  593. package/src/tools/builtins/grep.ts +1 -1
  594. package/src/tools/builtins/job.ts +4 -2
  595. package/src/tools/builtins/monitor.ts +6 -1
  596. package/src/tools/builtins/search-tools.ts +196 -21
  597. package/src/tools/builtins/shell-read-credit.ts +97 -33
  598. package/src/tools/builtins/wait-for-job.ts +13 -3
  599. package/src/tools/builtins/web-guidance.ts +6 -0
  600. package/src/tools/builtins/web.ts +2 -1
  601. package/src/tools/builtins/write-file.ts +31 -3
  602. package/src/tools/command-shell.ts +6 -8
  603. package/src/tools/defineTool.ts +20 -1
  604. package/src/tools/goal/confirmation.ts +227 -3
  605. package/src/tools/goal/index.ts +40 -4
  606. package/src/tools/schedules/index.ts +11 -0
  607. package/src/tools/schedules/loop-tool.ts +10 -6
  608. package/src/tools/schedules/present.ts +1 -1
  609. package/src/tools/schedules/timer-tools.ts +258 -0
  610. package/src/tools/schedules/types.ts +72 -3
  611. package/src/tools/task/create.ts +2 -0
  612. package/src/toolsets/manager.ts +262 -46
  613. package/src/turn/evidence-query.ts +183 -42
  614. package/src/turn/evidence-recall.ts +96 -19
  615. package/src/turn/history-shed.ts +30 -0
  616. package/src/types/acp/index.ts +24 -0
  617. package/src/types/authorization/index.ts +20 -3
  618. package/src/types/command/index.ts +27 -2
  619. package/src/types/common/index.ts +4 -2
  620. package/src/types/goal/index.ts +61 -0
  621. package/src/types/hitl/index.ts +10 -0
  622. package/src/types/message/index.ts +65 -0
  623. package/src/types/permission/index.ts +18 -0
  624. package/src/types/plugin/index.ts +205 -26
  625. package/src/types/provider/chat.ts +10 -5
  626. package/src/types/provider/index.ts +1 -0
  627. package/src/types/provider/interface.ts +21 -0
  628. package/src/types/provider/limits.ts +35 -0
  629. package/src/types/provider/model.ts +5 -0
  630. package/src/types/session/config.ts +2 -2
  631. package/src/types/session/outcome.ts +3 -1
  632. package/src/types/tool/index.ts +30 -2
  633. package/src/types/tool/presentation.ts +4 -0
  634. package/src/utils/cost.ts +15 -6
  635. package/src/utils/file-lock.ts +328 -0
  636. package/src/utils/state-backup.ts +318 -0
  637. package/src/utils/temp-sweep.ts +327 -0
  638. package/src/utils/temp.ts +73 -2
@@ -6,9 +6,11 @@ import {
6
6
  GoalTransitionError,
7
7
  type SessionGoalStore,
8
8
  StaleGoalError,
9
+ goalCostText,
10
+ goalTokensText,
9
11
  } from '../../store/goal/index.js'
10
12
  import type { HostCommandDescriptor } from '../../types/command/index.js'
11
- import type { GoalConfirmedBy, GoalRef, SessionGoal } from '../../types/goal/index.js'
13
+ import type { GoalConfirmedBy, GoalGuards, GoalRef, SessionGoal } from '../../types/goal/index.js'
12
14
  import type { SessionId, TenantId } from '../../types/ids/index.js'
13
15
  import type { Skill } from '../../types/skills/index.js'
14
16
  import { isInvocableBy, skillInvocation } from '../../types/skills/index.js'
@@ -50,10 +52,21 @@ export interface GoalCommandScope {
50
52
  readonly activation?: SessionGoalActivation
51
53
  /** What a goal that does not choose is confirmed by; shown by `/goal status`. Default `model`. */
52
54
  readonly defaultConfirmedBy?: GoalConfirmedBy
55
+ /**
56
+ * What a goal created here gets when the command does not say: the round cap
57
+ * and the stop rules the host applies. Absent leaves the kernel's own cap and
58
+ * no stop rules.
59
+ */
60
+ readonly defaults?: GoalCommandDefaults
61
+ }
62
+
63
+ export interface GoalCommandDefaults {
64
+ readonly maxGoalRounds?: number
65
+ readonly guards?: GoalGuards
53
66
  }
54
67
 
55
68
  const GOAL_ARGUMENTS =
56
- '[status|set [--confirmed-by record|model] <objective>|<objective>|edit <objective>|pause|resume|clear]'
69
+ '[status|set [--confirmed-by record|model] [--token-budget <n>] [--max-rounds <n>] <objective>|<objective>|edit <objective>|pause|resume|clear]'
57
70
  const GOAL_USAGE = `Usage: /goal ${GOAL_ARGUMENTS}`
58
71
 
59
72
  type ParsedGoalCommand =
@@ -81,58 +94,85 @@ function parseGoalCommand(args: readonly string[]): ParsedGoalCommand {
81
94
  return { kind: 'create', objective: input }
82
95
  }
83
96
 
84
- type ConfirmedByFlag =
85
- | {
86
- readonly kind: 'ok'
87
- readonly args: readonly string[]
88
- readonly confirmedBy?: GoalConfirmedBy
89
- }
90
- | { readonly kind: 'invalid' }
97
+ interface GoalFlags {
98
+ readonly confirmedBy?: GoalConfirmedBy
99
+ readonly tokenBudget?: number
100
+ readonly maxRounds?: number
101
+ }
102
+
103
+ type TakenFlags =
104
+ | { readonly kind: 'ok'; readonly args: readonly string[]; readonly flags: GoalFlags }
105
+ | { readonly kind: 'invalid'; readonly flag: string }
106
+
107
+ const GOAL_FLAG_NAMES = ['--confirmed-by', '--token-budget', '--max-rounds'] as const
108
+ type GoalFlagName = (typeof GOAL_FLAG_NAMES)[number]
109
+
110
+ /** `--name value` or `--name=value` at `args[i]`; the flag, its value and how many words it took. */
111
+ function flagAt(
112
+ args: readonly string[],
113
+ i: number,
114
+ ): { readonly name: GoalFlagName; readonly value: string; readonly width: number } | undefined {
115
+ const arg = args[i] ?? ''
116
+ for (const name of GOAL_FLAG_NAMES) {
117
+ if (arg === name) return { name, value: args[i + 1] ?? '', width: 2 }
118
+ if (arg.startsWith(`${name}=`)) return { name, value: arg.slice(name.length + 1), width: 1 }
119
+ }
120
+ return undefined
121
+ }
122
+
123
+ function applyFlag(flags: GoalFlags, name: GoalFlagName, value: string): GoalFlags | undefined {
124
+ if (name === '--confirmed-by') {
125
+ return value === 'model' || value === 'record' ? { ...flags, confirmedBy: value } : undefined
126
+ }
127
+ if (!/^[1-9][0-9]{0,15}$/u.test(value)) return undefined
128
+ const n = Number(value)
129
+ if (!Number.isSafeInteger(n)) return undefined
130
+ return name === '--token-budget' ? { ...flags, tokenBudget: n } : { ...flags, maxRounds: n }
131
+ }
91
132
 
92
133
  /**
93
- * Takes `--confirmed-by <model|record>` (or `=`) out of the arguments, but only
94
- * where a flag stands: at the front, right after `set`, or closing the command. In the middle the words
95
- * belong to the objective, so a goal about the flag itself keeps its text.
134
+ * Takes `--confirmed-by <model|record>`, `--token-budget <n>` and `--max-rounds
135
+ * <n>` (or `=`) out of the arguments, but only where a flag stands: at the
136
+ * front, right after `set`, or closing the command. In the middle the words
137
+ * belong to the objective, so a goal about a flag itself keeps its text.
96
138
  */
97
- function takeConfirmedBy(args: readonly string[]): ConfirmedByFlag {
139
+ function takeGoalFlags(args: readonly string[]): TakenFlags {
98
140
  const head: string[] = []
99
141
  let i = 0
100
142
  if ((args[0] ?? '').toLowerCase() === 'set') {
101
143
  head.push(args[0] ?? '')
102
144
  i = 1
103
145
  }
104
- let found: GoalConfirmedBy | undefined
105
- for (; i < args.length; i++) {
106
- const arg = args[i] ?? ''
107
- let value: string
108
- if (arg === '--confirmed-by') {
109
- value = args[i + 1] ?? ''
110
- i++
111
- } else if (arg.startsWith('--confirmed-by=')) {
112
- value = arg.slice('--confirmed-by='.length)
146
+ let flags: GoalFlags = {}
147
+ for (;;) {
148
+ const found = flagAt(args, i)
149
+ if (!found) break
150
+ const next = applyFlag(flags, found.name, found.value)
151
+ if (!next) return { kind: 'invalid', flag: found.name }
152
+ flags = next
153
+ i += found.width
154
+ }
155
+ let tail = args.slice(i)
156
+ // Flags may also close the command; in the middle their words are the objective's.
157
+ for (;;) {
158
+ const last = tail.length - 1
159
+ const one = flagAt(tail, last)
160
+ const two = last >= 1 ? flagAt(tail, last - 1) : undefined
161
+ if (one && one.width === 1) {
162
+ const next = applyFlag(flags, one.name, one.value)
163
+ if (!next) return { kind: 'invalid', flag: one.name }
164
+ flags = next
165
+ tail = tail.slice(0, -1)
166
+ } else if (two && two.width === 2) {
167
+ const next = applyFlag(flags, two.name, two.value)
168
+ if (!next) return { kind: 'invalid', flag: two.name }
169
+ flags = next
170
+ tail = tail.slice(0, -2)
113
171
  } else {
114
172
  break
115
173
  }
116
- if (value !== 'model' && value !== 'record') return { kind: 'invalid' }
117
- found = value
118
- }
119
- let tail = args.slice(i)
120
- // A flag may also close the command; in the middle its words are the objective's.
121
- const last = tail[tail.length - 1] ?? ''
122
- const beforeLast = tail[tail.length - 2] ?? ''
123
- let closing: string | undefined
124
- if (last.startsWith('--confirmed-by=')) {
125
- closing = last.slice('--confirmed-by='.length)
126
- tail = tail.slice(0, -1)
127
- } else if (beforeLast === '--confirmed-by') {
128
- closing = last
129
- tail = tail.slice(0, -2)
130
- }
131
- if (closing !== undefined) {
132
- if (closing !== 'model' && closing !== 'record') return { kind: 'invalid' }
133
- found = closing
134
174
  }
135
- return { kind: 'ok', args: [...head, ...tail], ...(found ? { confirmedBy: found } : {}) }
175
+ return { kind: 'ok', args: [...head, ...tail], flags }
136
176
  }
137
177
 
138
178
  function goalRef(goal: SessionGoal): GoalRef {
@@ -163,10 +203,22 @@ function renderGoal(
163
203
  ? ['Confirmed by: the record of the work']
164
204
  : []),
165
205
  `Automatic continuation: ${armed ? 'enabled' : 'paused'}`,
166
- `Automatic turns: ${goal.roundsAdmitted} / ${goal.maxGoalRounds}`,
206
+ `Automatic turns: ${goal.roundsAdmitted}, up to ${goal.maxGoalRounds}`,
207
+ `Tokens: ${goalTokensText(goal)}`,
208
+ `Cost: ${goalCostText(goal)}`,
209
+ ...(goal.guards?.tokenBudget !== undefined
210
+ ? [`Token budget: ${goal.guards.tokenBudget.toLocaleString('en-US')}`]
211
+ : []),
212
+ ...(goal.guards?.checkInEvery
213
+ ? [`Check-in: every ${goal.guards.checkInEvery} automatic turns`]
214
+ : []),
215
+ ...(goal.pauseReason ? [`Paused: ${goal.pauseReason.message}`] : []),
167
216
  ...(goal.blockedReason
168
217
  ? [`Blocker: ${goal.blockedReason.code}: ${goal.blockedReason.message}`]
169
218
  : []),
219
+ ...(goal.missing && goal.missing.length > 0
220
+ ? [`Still missing: ${goal.missing.join('; ')}`]
221
+ : []),
170
222
  `Objective: ${goal.objective}`,
171
223
  '',
172
224
  `Commands: ${goalCommands(goal, armed)}`,
@@ -196,18 +248,22 @@ async function runGoalCommand(scope: GoalCommandScope | undefined, args: readonl
196
248
  reason: 'Goals need a durable session. This host did not supply one for the current command.',
197
249
  }
198
250
  }
199
- const flag = takeConfirmedBy(args)
200
- if (flag.kind === 'invalid') {
251
+ const taken = takeGoalFlags(args)
252
+ if (taken.kind === 'invalid') {
201
253
  return {
202
254
  kind: 'refused' as const,
203
- reason: `--confirmed-by takes record or model.\n${GOAL_USAGE}`,
255
+ reason:
256
+ taken.flag === '--confirmed-by'
257
+ ? `--confirmed-by takes record or model.\n${GOAL_USAGE}`
258
+ : `${taken.flag} takes a whole number of at least 1.\n${GOAL_USAGE}`,
204
259
  }
205
260
  }
206
- const command = parseGoalCommand(flag.args)
207
- if (flag.confirmedBy !== undefined && command.kind !== 'create') {
261
+ const flag = taken.flags
262
+ const command = parseGoalCommand(taken.args)
263
+ if (Object.keys(flag).length > 0 && command.kind !== 'create') {
208
264
  return {
209
265
  kind: 'refused' as const,
210
- reason: `--confirmed-by is chosen when a goal is set.\n${GOAL_USAGE}`,
266
+ reason: `Flags such as --confirmed-by, --token-budget and --max-rounds are chosen when a goal is set.\n${GOAL_USAGE}`,
211
267
  }
212
268
  }
213
269
  try {
@@ -237,10 +293,18 @@ async function runGoalCommand(scope: GoalCommandScope | undefined, args: readonl
237
293
  reason: `A goal is already ${current.phase}. Use /goal edit <objective> to change it or /goal clear before replacing it.`,
238
294
  }
239
295
  }
296
+ const defaults = scope.defaults
297
+ const guards: GoalGuards = {
298
+ ...defaults?.guards,
299
+ ...(flag.tokenBudget !== undefined ? { tokenBudget: flag.tokenBudget } : {}),
300
+ }
301
+ const maxGoalRounds = flag.maxRounds ?? defaults?.maxGoalRounds
240
302
  const created = await scope.store.createGoal(
241
303
  {
242
304
  sessionId: scope.sessionId,
243
305
  objective: command.objective,
306
+ ...(maxGoalRounds !== undefined ? { maxGoalRounds } : {}),
307
+ ...(Object.keys(guards).length > 0 ? { guards } : {}),
244
308
  ...(flag.confirmedBy !== undefined ? { confirmedBy: flag.confirmedBy } : {}),
245
309
  },
246
310
  scope.tenantId,
@@ -255,7 +319,14 @@ async function runGoalCommand(scope: GoalCommandScope | undefined, args: readonl
255
319
  if (!current) return missingGoal('edit')
256
320
  if (current.phase === 'complete') {
257
321
  const replacement = await scope.store.createGoal(
258
- { sessionId: scope.sessionId, objective: command.objective },
322
+ {
323
+ sessionId: scope.sessionId,
324
+ objective: command.objective,
325
+ ...(scope.defaults?.maxGoalRounds !== undefined
326
+ ? { maxGoalRounds: scope.defaults.maxGoalRounds }
327
+ : {}),
328
+ ...(scope.defaults?.guards ? { guards: scope.defaults.guards } : {}),
329
+ },
259
330
  scope.tenantId,
260
331
  )
261
332
  scope.activation?.arm(replacement)
@@ -299,10 +370,20 @@ async function runGoalCommand(scope: GoalCommandScope | undefined, args: readonl
299
370
  message: renderScopedGoal('Goal resumed', current, scope),
300
371
  }
301
372
  }
373
+ // A goal stopped by a limit goes on when the setting now allows more.
302
374
  const resumed = await scope.store.resumeGoal(
303
375
  scope.sessionId,
304
376
  scope.tenantId,
305
377
  goalRef(current),
378
+ {
379
+ ...(scope.defaults?.maxGoalRounds !== undefined
380
+ ? { maxGoalRounds: scope.defaults.maxGoalRounds }
381
+ : {}),
382
+ ...(scope.defaults?.guards?.tokenBudget !== undefined
383
+ ? { tokenBudget: scope.defaults.guards.tokenBudget }
384
+ : {}),
385
+ ...(scope.defaults?.guards ? { guards: scope.defaults.guards } : {}),
386
+ },
306
387
  )
307
388
  scope.activation?.arm(resumed)
308
389
  return {
@@ -346,12 +427,17 @@ export function kernelHostCommands(options: KernelCommandOptions): HostCommandDe
346
427
  name: 'goal',
347
428
  description: 'Persist or inspect a completion goal for this conversation.',
348
429
  hint: GOAL_ARGUMENTS,
430
+ // Setting, editing, pausing, resuming and clearing change what the
431
+ // conversation does next; only reading the goal runs unasked.
432
+ modelRun: 'confirm',
433
+ modelRunReads: ['', 'status'],
349
434
  handler: async ({ args }) => await runGoalCommand(options.goal, args),
350
435
  },
351
436
  {
352
437
  name: 'skills',
353
438
  description: 'List the skills an operator may invoke.',
354
439
  hint: 'name, description and policy for every operator-invocable skill',
440
+ modelRun: 'run',
355
441
  handler() {
356
442
  // Operator-invocable only, which is the point of the split: the
357
443
  // model's manifest and the operator's menu are different lists
@@ -381,6 +467,7 @@ export function kernelHostCommands(options: KernelCommandOptions): HostCommandDe
381
467
  name: 'agents',
382
468
  description: 'List the agents this turn may delegate to.',
383
469
  hint: 'the roster, as the delegation tools see it',
470
+ modelRun: 'run',
384
471
  handler() {
385
472
  // An empty roster IS the answer here, unlike the store above: the
386
473
  // question is "who may I call", and "nobody" is a complete and
@@ -1,4 +1,6 @@
1
1
  import type { spawn } from 'node:child_process'
2
+ import { closeSync, mkdirSync, openSync, writeSync } from 'node:fs'
3
+ import { join as joinPath } from 'node:path'
2
4
 
3
5
  import { SANDBOX_KILL_GRACE_MS } from '../../constants/sandbox/index.js'
4
6
  import { isSignalablePid, killTree } from '../../process/kill-tree.js'
@@ -78,7 +80,10 @@ export interface BackgroundJob {
78
80
  * other job.
79
81
  */
80
82
  readonly kind?: 'monitor'
81
- /** What the monitor watches, in the model's words; shown with every event. */
83
+ /**
84
+ * What the job is for, in the model's words. For a monitor, what it watches
85
+ * (shown with every event); for a command started with a label, that label.
86
+ */
82
87
  readonly description?: string
83
88
  /** When the monitor will be stopped if the command has not ended first (epoch ms). */
84
89
  readonly expiresAt?: number
@@ -98,8 +103,18 @@ export interface BackgroundJob {
98
103
  /** The close code and reason the server ended a WebSocket connection with, if it did. */
99
104
  readonly closeCode?: number
100
105
  readonly closeReason?: string
106
+ /**
107
+ * The file the job's whole output is also written to (stdout and stderr, in
108
+ * the order they arrived), when the host gave the registry a folder for it.
109
+ * The in-memory tail is capped; this file is not, up to
110
+ * {@link JOB_OUTPUT_FILE_MAX_BYTES}.
111
+ */
112
+ readonly outputFile?: string
101
113
  }
102
114
 
115
+ /** The most one job writes to its output file; the file says so when it stops. */
116
+ export const JOB_OUTPUT_FILE_MAX_BYTES = 256 * 1024 * 1024
117
+
103
118
  /**
104
119
  * One thing a monitor has to say: a batch of its stdout lines, or a notice
105
120
  * from the monitor itself (events suppressed, stopped, expired).
@@ -202,6 +217,8 @@ export interface JobProcess {
202
217
  export interface StartJobParams {
203
218
  readonly owner: string
204
219
  readonly command: string
220
+ /** A short label for a command that is not a monitor; see {@link BackgroundJob.description}. */
221
+ readonly description?: string
205
222
  readonly workingDirectory: string
206
223
  readonly env?: Readonly<Record<string, string>>
207
224
  /**
@@ -226,6 +243,13 @@ export interface StartJobParams {
226
243
  * decoded the way a foreground command's are, not as a Linux guest's.
227
244
  */
228
245
  readonly hostOutput?: boolean
246
+ /**
247
+ * A folder (made if it is missing, owner-only) for a file named after the
248
+ * job that receives everything the job writes. Absent, the output lives in
249
+ * memory only. A folder that cannot be made leaves the job without a file;
250
+ * the job still runs.
251
+ */
252
+ readonly outputDirectory?: string
229
253
  /**
230
254
  * Run the command as a monitor: stdout is split into lines and delivered
231
255
  * to `onMonitorEvent` listeners in batches, and the job is stopped at
@@ -661,6 +685,32 @@ export class BackgroundJobRegistry {
661
685
  }
662
686
 
663
687
  const id = createBackgroundJobId((candidate) => this.jobs.has(candidate))
688
+ // The job's output file, when the host named a folder for it. A file that
689
+ // cannot be opened is not a reason to refuse the job: the in-memory tail
690
+ // is still there, and the model is simply not told a path.
691
+ let outputFile: string | undefined
692
+ let outputFd: number | undefined
693
+ let outputWritten = 0
694
+ if (params.outputDirectory !== undefined) {
695
+ try {
696
+ mkdirSync(params.outputDirectory, { recursive: true, mode: 0o700 })
697
+ const file = joinPath(params.outputDirectory, `${id}.log`)
698
+ outputFd = openSync(file, 'a', 0o600)
699
+ outputFile = file
700
+ } catch {
701
+ outputFd = undefined
702
+ }
703
+ }
704
+ const closeOutputFile = (): void => {
705
+ if (outputFd === undefined) return
706
+ const fd = outputFd
707
+ outputFd = undefined
708
+ try {
709
+ closeSync(fd)
710
+ } catch {
711
+ // Nothing is left to flush: every write above was synchronous.
712
+ }
713
+ }
664
714
  // Same scrub as the foreground path: inheritance is implicit, so the
665
715
  // operator's provider credentials do not travel into a command nobody
666
716
  // decided should see them. A background job outlives the call that
@@ -747,6 +797,10 @@ export class BackgroundJobRegistry {
747
797
  command: params.command,
748
798
  status: 'running',
749
799
  startedAt,
800
+ ...(outputFile !== undefined ? { outputFile } : {}),
801
+ ...(!monitor && params.description !== undefined
802
+ ? { description: params.description }
803
+ : {}),
750
804
  ...(monitor
751
805
  ? {
752
806
  kind: 'monitor' as const,
@@ -772,6 +826,7 @@ export class BackgroundJobRegistry {
772
826
  const finalize = (code: number | null, signal: NodeJS.Signals | null): void => {
773
827
  if (finalized) return
774
828
  finalized = true
829
+ closeOutputFile()
775
830
  untrackAtHostExit()
776
831
  entry.record = {
777
832
  ...entry.record,
@@ -867,6 +922,23 @@ export class BackgroundJobRegistry {
867
922
  const chunk: OutputChunk = { stream, offset: entry.produced, bytes: Buffer.from(text) }
868
923
  if (chunk.bytes.length === 0) return
869
924
  entry.produced += chunk.bytes.length
925
+ if (outputFd !== undefined) {
926
+ try {
927
+ if (outputWritten + chunk.bytes.length <= JOB_OUTPUT_FILE_MAX_BYTES) {
928
+ writeSync(outputFd, chunk.bytes)
929
+ outputWritten += chunk.bytes.length
930
+ } else {
931
+ writeSync(
932
+ outputFd,
933
+ `\n[the output file stopped at ${JOB_OUTPUT_FILE_MAX_BYTES} bytes; the job kept running]\n`,
934
+ )
935
+ closeOutputFile()
936
+ }
937
+ } catch {
938
+ // A full disk must not take the job's live output with it.
939
+ closeOutputFile()
940
+ }
941
+ }
870
942
  const line = lastLineOf(text)
871
943
  entry.record = {
872
944
  ...entry.record,
@@ -1366,23 +1438,35 @@ export function bindOwner(
1366
1438
  * reported, because the host wakes on its events.
1367
1439
  */
1368
1440
  readonly onMonitorStarted?: (id: string) => void
1441
+ /**
1442
+ * Where each job's output file goes; see {@link StartJobParams.outputDirectory}.
1443
+ * A function, so the folder is asked for when a job starts.
1444
+ */
1445
+ readonly outputDirectory?: string | (() => string | undefined)
1369
1446
  } = {},
1370
1447
  ) {
1448
+ const outputDirectory = (): string | undefined =>
1449
+ typeof defaults.outputDirectory === 'function'
1450
+ ? defaults.outputDirectory()
1451
+ : defaults.outputDirectory
1371
1452
  const mine = (id: string): BackgroundJob => {
1372
1453
  const job = registry.get(id)
1373
1454
  if (job.owner !== owner) throw new UnknownBackgroundJobError({ id })
1374
1455
  return job
1375
1456
  }
1376
1457
  const launch = (
1377
- params: { command: string; workingDirectory?: string },
1458
+ params: { command: string; workingDirectory?: string; description?: string },
1378
1459
  monitor?: StartJobParams['monitor'],
1379
1460
  ): BackgroundJob => {
1380
1461
  const workingDirectory = params.workingDirectory ?? defaults.workingDirectory ?? process.cwd()
1381
1462
  const spawnHost = defaults.spawn
1463
+ const jobsFolder = outputDirectory()
1382
1464
  return registry.start({
1383
1465
  owner,
1384
1466
  command: params.command,
1385
1467
  workingDirectory,
1468
+ ...(!monitor && params.description !== undefined ? { description: params.description } : {}),
1469
+ ...(jobsFolder !== undefined ? { outputDirectory: jobsFolder } : {}),
1386
1470
  ...(defaults.env ? { env: defaults.env } : {}),
1387
1471
  ...(spawnHost
1388
1472
  ? {
@@ -1400,7 +1484,8 @@ export function bindOwner(
1400
1484
  const clampMonitorTimeout = (requested: number): number =>
1401
1485
  Math.min(requested, defaults.monitorTimeoutCapMs ?? MONITOR_TIMEOUT_CAP_MS)
1402
1486
  return {
1403
- start: (params: { command: string; workingDirectory?: string }) => launch(params),
1487
+ start: (params: { command: string; workingDirectory?: string; description?: string }) =>
1488
+ launch(params),
1404
1489
  // The same spawn, owner and cap as `start`, plus a deadline. The timeout
1405
1490
  // is clamped to the host's ceiling and the clamped value is returned, so
1406
1491
  // the number the model is told is the number that will fire.
@@ -1444,6 +1529,7 @@ export function bindOwner(
1444
1529
  // running, with what it has written so far.
1445
1530
  adopt: (params: {
1446
1531
  command: string
1532
+ description?: string
1447
1533
  child: ReturnType<typeof spawn>
1448
1534
  workingDirectory?: string
1449
1535
  initialOutput?: StartJobParams['initialOutput']
@@ -1451,9 +1537,13 @@ export function bindOwner(
1451
1537
  registry.start({
1452
1538
  owner,
1453
1539
  command: params.command,
1540
+ ...(params.description !== undefined ? { description: params.description } : {}),
1454
1541
  workingDirectory: params.workingDirectory ?? defaults.workingDirectory ?? process.cwd(),
1455
1542
  spawn: () => ({ child: params.child }),
1456
1543
  hostOutput: true,
1544
+ ...(outputDirectory() !== undefined
1545
+ ? { outputDirectory: outputDirectory() as string }
1546
+ : {}),
1457
1547
  ...(params.initialOutput ? { initialOutput: params.initialOutput } : {}),
1458
1548
  }),
1459
1549
  // The owner is bound here, so a tool can offer its own waiting command and