@namzu/sdk 71.1.0 → 73.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 (380) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +1 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -1
  6. package/dist/agents/examples/SupervisorAgent.js +5 -0
  7. package/dist/agents/examples/SupervisorAgent.js.map +1 -1
  8. package/dist/authorization/protected-paths.d.ts.map +1 -1
  9. package/dist/authorization/protected-paths.js +4 -0
  10. package/dist/authorization/protected-paths.js.map +1 -1
  11. package/dist/compaction/index.d.ts +1 -1
  12. package/dist/compaction/index.d.ts.map +1 -1
  13. package/dist/compaction/index.js +1 -1
  14. package/dist/compaction/index.js.map +1 -1
  15. package/dist/compaction/manual.d.ts +24 -1
  16. package/dist/compaction/manual.d.ts.map +1 -1
  17. package/dist/compaction/manual.js +80 -21
  18. package/dist/compaction/manual.js.map +1 -1
  19. package/dist/compaction/model-summary.d.ts +24 -6
  20. package/dist/compaction/model-summary.d.ts.map +1 -1
  21. package/dist/compaction/model-summary.js +108 -23
  22. package/dist/compaction/model-summary.js.map +1 -1
  23. package/dist/compaction/precompute.d.ts +179 -0
  24. package/dist/compaction/precompute.d.ts.map +1 -0
  25. package/dist/compaction/precompute.js +274 -0
  26. package/dist/compaction/precompute.js.map +1 -0
  27. package/dist/compaction/restore.d.ts +23 -0
  28. package/dist/compaction/restore.d.ts.map +1 -1
  29. package/dist/compaction/restore.js +59 -1
  30. package/dist/compaction/restore.js.map +1 -1
  31. package/dist/compaction/summary.d.ts +37 -2
  32. package/dist/compaction/summary.d.ts.map +1 -1
  33. package/dist/compaction/summary.js +46 -6
  34. package/dist/compaction/summary.js.map +1 -1
  35. package/dist/config/runtime.d.ts +4 -0
  36. package/dist/config/runtime.d.ts.map +1 -1
  37. package/dist/config/runtime.js +20 -3
  38. package/dist/config/runtime.js.map +1 -1
  39. package/dist/connector/index.d.ts +2 -2
  40. package/dist/connector/index.d.ts.map +1 -1
  41. package/dist/connector/index.js +1 -1
  42. package/dist/connector/index.js.map +1 -1
  43. package/dist/connector/mcp/client.d.ts +26 -6
  44. package/dist/connector/mcp/client.d.ts.map +1 -1
  45. package/dist/connector/mcp/client.js +49 -7
  46. package/dist/connector/mcp/client.js.map +1 -1
  47. package/dist/connector/mcp/index.d.ts +2 -0
  48. package/dist/connector/mcp/index.d.ts.map +1 -1
  49. package/dist/connector/mcp/index.js +1 -0
  50. package/dist/connector/mcp/index.js.map +1 -1
  51. package/dist/connector/mcp/sandbox-stdio.d.ts +67 -0
  52. package/dist/connector/mcp/sandbox-stdio.d.ts.map +1 -0
  53. package/dist/connector/mcp/sandbox-stdio.js +178 -0
  54. package/dist/connector/mcp/sandbox-stdio.js.map +1 -0
  55. package/dist/connector/mcp/stdio-program.d.ts +34 -0
  56. package/dist/connector/mcp/stdio-program.d.ts.map +1 -0
  57. package/dist/connector/mcp/stdio-program.js +47 -0
  58. package/dist/connector/mcp/stdio-program.js.map +1 -0
  59. package/dist/connector/mcp/stdio.d.ts.map +1 -1
  60. package/dist/connector/mcp/stdio.js +5 -2
  61. package/dist/connector/mcp/stdio.js.map +1 -1
  62. package/dist/connector/web/guarded-fetch.d.ts +51 -2
  63. package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
  64. package/dist/connector/web/guarded-fetch.js +140 -19
  65. package/dist/connector/web/guarded-fetch.js.map +1 -1
  66. package/dist/connector/web/index.d.ts +2 -2
  67. package/dist/connector/web/index.d.ts.map +1 -1
  68. package/dist/connector/web/index.js +1 -1
  69. package/dist/connector/web/index.js.map +1 -1
  70. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  71. package/dist/manager/agent/lifecycle.js +9 -1
  72. package/dist/manager/agent/lifecycle.js.map +1 -1
  73. package/dist/manager/session/turn-recorder.d.ts +26 -0
  74. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  75. package/dist/manager/session/turn-recorder.js +72 -5
  76. package/dist/manager/session/turn-recorder.js.map +1 -1
  77. package/dist/peers/protocol.d.ts +9 -0
  78. package/dist/peers/protocol.d.ts.map +1 -1
  79. package/dist/peers/protocol.js +4 -0
  80. package/dist/peers/protocol.js.map +1 -1
  81. package/dist/peers/record.d.ts +6 -0
  82. package/dist/peers/record.d.ts.map +1 -1
  83. package/dist/peers/record.js +4 -0
  84. package/dist/peers/record.js.map +1 -1
  85. package/dist/plugin/hook-module/capabilities.d.ts.map +1 -1
  86. package/dist/plugin/hook-module/capabilities.js +24 -13
  87. package/dist/plugin/hook-module/capabilities.js.map +1 -1
  88. package/dist/plugin/hook-module/host.d.ts +31 -0
  89. package/dist/plugin/hook-module/host.d.ts.map +1 -1
  90. package/dist/plugin/hook-module/host.js +56 -13
  91. package/dist/plugin/hook-module/host.js.map +1 -1
  92. package/dist/plugin/hook-module/index.d.ts +3 -2
  93. package/dist/plugin/hook-module/index.d.ts.map +1 -1
  94. package/dist/plugin/hook-module/index.js +2 -1
  95. package/dist/plugin/hook-module/index.js.map +1 -1
  96. package/dist/plugin/index.d.ts +3 -2
  97. package/dist/plugin/index.d.ts.map +1 -1
  98. package/dist/plugin/index.js +2 -1
  99. package/dist/plugin/index.js.map +1 -1
  100. package/dist/plugin/shell-hook-execute.d.ts +55 -0
  101. package/dist/plugin/shell-hook-execute.d.ts.map +1 -0
  102. package/dist/plugin/shell-hook-execute.js +73 -0
  103. package/dist/plugin/shell-hook-execute.js.map +1 -0
  104. package/dist/plugin/shell-hook-restrict.d.ts +31 -0
  105. package/dist/plugin/shell-hook-restrict.d.ts.map +1 -0
  106. package/dist/plugin/shell-hook-restrict.js +69 -0
  107. package/dist/plugin/shell-hook-restrict.js.map +1 -0
  108. package/dist/plugin/shell-hook.d.ts +59 -2
  109. package/dist/plugin/shell-hook.d.ts.map +1 -1
  110. package/dist/plugin/shell-hook.js +79 -12
  111. package/dist/plugin/shell-hook.js.map +1 -1
  112. package/dist/public-runtime.d.ts +11 -7
  113. package/dist/public-runtime.d.ts.map +1 -1
  114. package/dist/public-runtime.js +9 -6
  115. package/dist/public-runtime.js.map +1 -1
  116. package/dist/public-tools.d.ts +1 -1
  117. package/dist/public-tools.d.ts.map +1 -1
  118. package/dist/public-tools.js +1 -1
  119. package/dist/public-tools.js.map +1 -1
  120. package/dist/public-types.d.ts +5 -2
  121. package/dist/public-types.d.ts.map +1 -1
  122. package/dist/registry/command/kernel-commands.d.ts +7 -1
  123. package/dist/registry/command/kernel-commands.d.ts.map +1 -1
  124. package/dist/registry/command/kernel-commands.js +40 -2
  125. package/dist/registry/command/kernel-commands.js.map +1 -1
  126. package/dist/registry/tool/execute.d.ts +8 -0
  127. package/dist/registry/tool/execute.d.ts.map +1 -1
  128. package/dist/registry/tool/execute.js +12 -0
  129. package/dist/registry/tool/execute.js.map +1 -1
  130. package/dist/runtime/jobs/websocket-source.d.ts +2 -22
  131. package/dist/runtime/jobs/websocket-source.d.ts.map +1 -1
  132. package/dist/runtime/jobs/websocket-source.js +2 -33
  133. package/dist/runtime/jobs/websocket-source.js.map +1 -1
  134. package/dist/runtime/query/budget-nudge.d.ts +27 -0
  135. package/dist/runtime/query/budget-nudge.d.ts.map +1 -0
  136. package/dist/runtime/query/budget-nudge.js +66 -0
  137. package/dist/runtime/query/budget-nudge.js.map +1 -0
  138. package/dist/runtime/query/compact-session.d.ts +9 -0
  139. package/dist/runtime/query/compact-session.d.ts.map +1 -1
  140. package/dist/runtime/query/compact-session.js +158 -76
  141. package/dist/runtime/query/compact-session.js.map +1 -1
  142. package/dist/runtime/query/events.d.ts +7 -0
  143. package/dist/runtime/query/events.d.ts.map +1 -1
  144. package/dist/runtime/query/events.js +29 -11
  145. package/dist/runtime/query/events.js.map +1 -1
  146. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  147. package/dist/runtime/query/executor/tool-call-admission.js +51 -10
  148. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  149. package/dist/runtime/query/guard.d.ts +8 -0
  150. package/dist/runtime/query/guard.d.ts.map +1 -1
  151. package/dist/runtime/query/guard.js +20 -0
  152. package/dist/runtime/query/guard.js.map +1 -1
  153. package/dist/runtime/query/index.d.ts +6 -0
  154. package/dist/runtime/query/index.d.ts.map +1 -1
  155. package/dist/runtime/query/index.js +3 -0
  156. package/dist/runtime/query/index.js.map +1 -1
  157. package/dist/runtime/query/iteration/index.d.ts +2 -0
  158. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  159. package/dist/runtime/query/iteration/index.js +27 -1
  160. package/dist/runtime/query/iteration/index.js.map +1 -1
  161. package/dist/runtime/query/iteration/phases/compaction.d.ts +1 -0
  162. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  163. package/dist/runtime/query/iteration/phases/compaction.js +164 -43
  164. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  165. package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
  166. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  167. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  168. package/dist/runtime/query/iteration/phases/precompute.d.ts +60 -0
  169. package/dist/runtime/query/iteration/phases/precompute.d.ts.map +1 -0
  170. package/dist/runtime/query/iteration/phases/precompute.js +240 -0
  171. package/dist/runtime/query/iteration/phases/precompute.js.map +1 -0
  172. package/dist/runtime/query/turn/outcome-ledger.d.ts +14 -0
  173. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  174. package/dist/runtime/query/turn/outcome-ledger.js +28 -0
  175. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  176. package/dist/scheduler/completion-inbox.d.ts.map +1 -1
  177. package/dist/scheduler/completion-inbox.js +15 -0
  178. package/dist/scheduler/completion-inbox.js.map +1 -1
  179. package/dist/store/goal/gates.d.ts +53 -0
  180. package/dist/store/goal/gates.d.ts.map +1 -0
  181. package/dist/store/goal/gates.js +664 -0
  182. package/dist/store/goal/gates.js.map +1 -0
  183. package/dist/store/goal/index.d.ts +16 -1
  184. package/dist/store/goal/index.d.ts.map +1 -1
  185. package/dist/store/goal/index.js +74 -0
  186. package/dist/store/goal/index.js.map +1 -1
  187. package/dist/store/session-index/index.d.ts +13 -0
  188. package/dist/store/session-index/index.d.ts.map +1 -1
  189. package/dist/store/session-index/index.js +1 -0
  190. package/dist/store/session-index/index.js.map +1 -1
  191. package/dist/store/session-index/rebuild.d.ts +12 -0
  192. package/dist/store/session-index/rebuild.d.ts.map +1 -1
  193. package/dist/store/session-index/rebuild.js +20 -4
  194. package/dist/store/session-index/rebuild.js.map +1 -1
  195. package/dist/store/session-index/sqlite.d.ts +20 -0
  196. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  197. package/dist/store/session-index/sqlite.js +50 -12
  198. package/dist/store/session-index/sqlite.js.map +1 -1
  199. package/dist/tools/admit-facts.d.ts.map +1 -1
  200. package/dist/tools/admit-facts.js +59 -0
  201. package/dist/tools/admit-facts.js.map +1 -1
  202. package/dist/tools/builtins/bash.js +1 -1
  203. package/dist/tools/builtins/bash.js.map +1 -1
  204. package/dist/tools/builtins/browser.d.ts.map +1 -1
  205. package/dist/tools/builtins/browser.js +2 -0
  206. package/dist/tools/builtins/browser.js.map +1 -1
  207. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  208. package/dist/tools/builtins/monitor.js +1 -0
  209. package/dist/tools/builtins/monitor.js.map +1 -1
  210. package/dist/tools/builtins/search-tools.js +2 -2
  211. package/dist/tools/builtins/search-tools.js.map +1 -1
  212. package/dist/tools/builtins/sleep-guard.js +1 -1
  213. package/dist/tools/builtins/sleep-guard.js.map +1 -1
  214. package/dist/tools/builtins/wait-for-job.js +1 -1
  215. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  216. package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
  217. package/dist/tools/coordinator/ask-user-question.js +92 -3
  218. package/dist/tools/coordinator/ask-user-question.js.map +1 -1
  219. package/dist/tools/coordinator/index.d.ts.map +1 -1
  220. package/dist/tools/coordinator/index.js +3 -0
  221. package/dist/tools/coordinator/index.js.map +1 -1
  222. package/dist/tools/defineTool.d.ts +2 -0
  223. package/dist/tools/defineTool.d.ts.map +1 -1
  224. package/dist/tools/defineTool.js +3 -0
  225. package/dist/tools/defineTool.js.map +1 -1
  226. package/dist/tools/goal/confirmation.d.ts +40 -2
  227. package/dist/tools/goal/confirmation.d.ts.map +1 -1
  228. package/dist/tools/goal/confirmation.js +117 -0
  229. package/dist/tools/goal/confirmation.js.map +1 -1
  230. package/dist/tools/goal/index.d.ts.map +1 -1
  231. package/dist/tools/goal/index.js +14 -2
  232. package/dist/tools/goal/index.js.map +1 -1
  233. package/dist/tools/memory/save.d.ts.map +1 -1
  234. package/dist/tools/memory/save.js +1 -0
  235. package/dist/tools/memory/save.js.map +1 -1
  236. package/dist/tools/schedules/index.d.ts +1 -0
  237. package/dist/tools/schedules/index.d.ts.map +1 -1
  238. package/dist/tools/schedules/index.js +1 -0
  239. package/dist/tools/schedules/index.js.map +1 -1
  240. package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
  241. package/dist/tools/schedules/loop-tool.js +1 -0
  242. package/dist/tools/schedules/loop-tool.js.map +1 -1
  243. package/dist/tools/schedules/present.d.ts.map +1 -1
  244. package/dist/tools/schedules/present.js +2 -0
  245. package/dist/tools/schedules/present.js.map +1 -1
  246. package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
  247. package/dist/tools/schedules/schedule-tool.js +79 -9
  248. package/dist/tools/schedules/schedule-tool.js.map +1 -1
  249. package/dist/tools/schedules/self-tool.d.ts +16 -0
  250. package/dist/tools/schedules/self-tool.d.ts.map +1 -0
  251. package/dist/tools/schedules/self-tool.js +140 -0
  252. package/dist/tools/schedules/self-tool.js.map +1 -0
  253. package/dist/tools/schedules/timer-tools.d.ts.map +1 -1
  254. package/dist/tools/schedules/timer-tools.js +1 -0
  255. package/dist/tools/schedules/timer-tools.js.map +1 -1
  256. package/dist/tools/schedules/types.d.ts +63 -0
  257. package/dist/tools/schedules/types.d.ts.map +1 -1
  258. package/dist/toolsets/manager.d.ts +10 -0
  259. package/dist/toolsets/manager.d.ts.map +1 -1
  260. package/dist/toolsets/manager.js +56 -7
  261. package/dist/toolsets/manager.js.map +1 -1
  262. package/dist/turn/memory-promoter.d.ts.map +1 -1
  263. package/dist/turn/memory-promoter.js +20 -4
  264. package/dist/turn/memory-promoter.js.map +1 -1
  265. package/dist/types/agent/base.d.ts +6 -0
  266. package/dist/types/agent/base.d.ts.map +1 -1
  267. package/dist/types/agent/supervisor.d.ts +10 -0
  268. package/dist/types/agent/supervisor.d.ts.map +1 -1
  269. package/dist/types/agent/task.d.ts +11 -0
  270. package/dist/types/agent/task.d.ts.map +1 -1
  271. package/dist/types/agent/task.js.map +1 -1
  272. package/dist/types/goal/index.d.ts +66 -0
  273. package/dist/types/goal/index.d.ts.map +1 -1
  274. package/dist/types/hitl/index.d.ts +8 -0
  275. package/dist/types/hitl/index.d.ts.map +1 -1
  276. package/dist/types/hitl/index.js.map +1 -1
  277. package/dist/types/message/index.d.ts +7 -0
  278. package/dist/types/message/index.d.ts.map +1 -1
  279. package/dist/types/message/index.js.map +1 -1
  280. package/dist/types/session/events.d.ts +7 -0
  281. package/dist/types/session/events.d.ts.map +1 -1
  282. package/dist/types/session/events.js.map +1 -1
  283. package/dist/types/session/outcome.d.ts +12 -0
  284. package/dist/types/session/outcome.d.ts.map +1 -1
  285. package/dist/types/session/outcome.js.map +1 -1
  286. package/dist/types/session/records.d.ts +79 -1
  287. package/dist/types/session/records.d.ts.map +1 -1
  288. package/dist/types/session/records.js +24 -0
  289. package/dist/types/session/records.js.map +1 -1
  290. package/dist/types/tool/index.d.ts +7 -0
  291. package/dist/types/tool/index.d.ts.map +1 -1
  292. package/dist/types/tool/index.js.map +1 -1
  293. package/dist/types/tool/presentation.d.ts +21 -0
  294. package/dist/types/tool/presentation.d.ts.map +1 -1
  295. package/package.json +6 -6
  296. package/src/agents/QueryAgent.ts +1 -0
  297. package/src/agents/examples/SupervisorAgent.ts +5 -0
  298. package/src/authorization/protected-paths.ts +4 -0
  299. package/src/compaction/index.ts +1 -0
  300. package/src/compaction/manual.ts +130 -23
  301. package/src/compaction/model-summary.ts +118 -23
  302. package/src/compaction/precompute.ts +390 -0
  303. package/src/compaction/restore.ts +74 -1
  304. package/src/compaction/summary.ts +69 -3
  305. package/src/config/runtime.ts +20 -3
  306. package/src/connector/index.ts +3 -0
  307. package/src/connector/mcp/client.ts +49 -7
  308. package/src/connector/mcp/index.ts +5 -0
  309. package/src/connector/mcp/sandbox-stdio.ts +214 -0
  310. package/src/connector/mcp/stdio-program.ts +68 -0
  311. package/src/connector/mcp/stdio.ts +5 -2
  312. package/src/connector/web/guarded-fetch.ts +197 -30
  313. package/src/connector/web/index.ts +4 -1
  314. package/src/manager/agent/lifecycle.ts +10 -1
  315. package/src/manager/session/turn-recorder.ts +92 -5
  316. package/src/peers/protocol.ts +4 -0
  317. package/src/peers/record.ts +4 -0
  318. package/src/plugin/hook-module/capabilities.ts +36 -14
  319. package/src/plugin/hook-module/host.ts +86 -13
  320. package/src/plugin/hook-module/index.ts +3 -0
  321. package/src/plugin/index.ts +3 -0
  322. package/src/plugin/shell-hook-execute.ts +126 -0
  323. package/src/plugin/shell-hook-restrict.ts +66 -0
  324. package/src/plugin/shell-hook.ts +138 -10
  325. package/src/public-runtime.ts +41 -0
  326. package/src/public-tools.ts +2 -0
  327. package/src/public-types.ts +21 -0
  328. package/src/registry/command/kernel-commands.ts +62 -3
  329. package/src/registry/tool/execute.ts +14 -0
  330. package/src/runtime/jobs/websocket-source.ts +2 -46
  331. package/src/runtime/query/budget-nudge.ts +92 -0
  332. package/src/runtime/query/compact-session.ts +195 -70
  333. package/src/runtime/query/events.ts +29 -11
  334. package/src/runtime/query/executor/tool-call-admission.ts +62 -17
  335. package/src/runtime/query/guard.ts +22 -0
  336. package/src/runtime/query/index.ts +10 -0
  337. package/src/runtime/query/iteration/index.ts +26 -1
  338. package/src/runtime/query/iteration/phases/compaction.ts +173 -43
  339. package/src/runtime/query/iteration/phases/context.ts +6 -0
  340. package/src/runtime/query/iteration/phases/precompute.ts +277 -0
  341. package/src/runtime/query/turn/outcome-ledger.ts +34 -0
  342. package/src/scheduler/completion-inbox.ts +14 -0
  343. package/src/store/goal/gates.ts +738 -0
  344. package/src/store/goal/index.ts +109 -0
  345. package/src/store/session-index/index.ts +14 -0
  346. package/src/store/session-index/rebuild.ts +22 -4
  347. package/src/store/session-index/sqlite.ts +63 -14
  348. package/src/tools/admit-facts.ts +64 -0
  349. package/src/tools/builtins/bash.ts +1 -1
  350. package/src/tools/builtins/browser.ts +4 -0
  351. package/src/tools/builtins/monitor.ts +2 -0
  352. package/src/tools/builtins/search-tools.ts +2 -2
  353. package/src/tools/builtins/sleep-guard.ts +1 -1
  354. package/src/tools/builtins/wait-for-job.ts +1 -1
  355. package/src/tools/coordinator/ask-user-question.ts +124 -13
  356. package/src/tools/coordinator/index.ts +3 -0
  357. package/src/tools/defineTool.ts +5 -0
  358. package/src/tools/goal/confirmation.ts +171 -3
  359. package/src/tools/goal/index.ts +15 -3
  360. package/src/tools/memory/save.ts +2 -0
  361. package/src/tools/schedules/index.ts +1 -0
  362. package/src/tools/schedules/loop-tool.ts +2 -0
  363. package/src/tools/schedules/present.ts +2 -0
  364. package/src/tools/schedules/schedule-tool.ts +84 -9
  365. package/src/tools/schedules/self-tool.ts +152 -0
  366. package/src/tools/schedules/timer-tools.ts +2 -0
  367. package/src/tools/schedules/types.ts +62 -0
  368. package/src/toolsets/manager.ts +55 -8
  369. package/src/turn/memory-promoter.ts +24 -3
  370. package/src/types/agent/base.ts +7 -0
  371. package/src/types/agent/supervisor.ts +11 -0
  372. package/src/types/agent/task.ts +12 -0
  373. package/src/types/goal/index.ts +72 -0
  374. package/src/types/hitl/index.ts +8 -0
  375. package/src/types/message/index.ts +7 -0
  376. package/src/types/session/events.ts +7 -0
  377. package/src/types/session/outcome.ts +16 -1
  378. package/src/types/session/records.ts +27 -0
  379. package/src/types/tool/index.ts +7 -0
  380. package/src/types/tool/presentation.ts +22 -0
@@ -288,6 +288,26 @@ export { DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES } from './runtime/query/request-
288
288
  export { DEFAULT_SANDBOX_TEARDOWN_TIMEOUT_MS } from './runtime/query/sandbox-lifecycle.js'
289
289
 
290
290
  export { isTrustedReadOnly } from './tools/trusted-read-only.js'
291
+ export {
292
+ GOAL_GATES_BLOCK_CODE,
293
+ GOAL_GATE_DEFAULT_MAX_FAILING_ROUNDS,
294
+ GOAL_GATE_DEFAULT_TIMEOUT_MS,
295
+ GOAL_GATE_MAX_ARGS,
296
+ GOAL_GATE_MAX_ARG_CHARS,
297
+ GOAL_GATE_MAX_CWD_CHARS,
298
+ GOAL_GATE_MAX_ENTRIES,
299
+ GOAL_GATE_MAX_NAME_CHARS,
300
+ GOAL_GATE_MAX_TAIL_CHARS,
301
+ GOAL_GATE_MAX_TIMEOUT_MS,
302
+ GOAL_GATE_MIN_TIMEOUT_MS,
303
+ goalGateCommandText,
304
+ goalGateFailedNames,
305
+ goalGatePassed,
306
+ goalGateTail,
307
+ goalGatesBlockSentence,
308
+ goalGatesFrom,
309
+ parseGoalGateEntry,
310
+ } from './store/goal/gates.js'
291
311
  export {
292
312
  GoalRoundAuthorityError,
293
313
  MIN_GOAL_BLOCK_ROUND,
@@ -301,6 +321,7 @@ export {
301
321
  NO_CHECK_REASON_CODE,
302
322
  decideGoalConfirmation,
303
323
  describeGoalEnding,
324
+ gateFailureNote,
304
325
  parseGoalEvidence,
305
326
  recordSentence,
306
327
  } from './tools/goal/confirmation.js'
@@ -344,6 +365,7 @@ export {
344
365
  withFileLock,
345
366
  withFileLockSync,
346
367
  } from './utils/file-lock.js'
368
+ export { temporaryPathFor } from './utils/atomic-write.js'
347
369
  export {
348
370
  STATE_BACKUPS_DIR,
349
371
  STATE_BACKUP_KEEP,
@@ -487,6 +509,10 @@ export type { AbandonTurnOptions, SessionLocatorOptions } from './runtime/query/
487
509
  export { CacheClock } from './runtime/cache-clock.js'
488
510
  export type { CacheClockState } from './runtime/cache-clock.js'
489
511
  export { compactSession, compactSessionRange } from './runtime/query/compact-session.js'
512
+ export {
513
+ type PreparedSpend,
514
+ releasePreparedSummary,
515
+ } from './compaction/precompute.js'
490
516
  export type {
491
517
  CompactSessionParams,
492
518
  CompactSessionRangeParams,
@@ -808,6 +834,7 @@ export {
808
834
  MAX_COMPACTION_SUMMARY_HOOK_CHARS,
809
835
  MAX_LAST_MESSAGE_HOOK_CHARS,
810
836
  createShellHook,
837
+ shellHookEntryLimitProblem,
811
838
  DEFAULT_SHELL_HOOK_TIMEOUT_MS,
812
839
  definePlugin,
813
840
  frameOperatorHookContext,
@@ -875,6 +902,11 @@ export {
875
902
  scanHookModule,
876
903
  startHookModule,
877
904
  summarizeHookModule,
905
+ HOOK_WORKER_SOURCE,
906
+ HOST_REACHING_CAPABILITIES,
907
+ createCapabilityBridge,
908
+ workerTransport,
909
+ restrictHookVerdict,
878
910
  } from './plugin/index.js'
879
911
  export type {
880
912
  CommonLayoutOptions,
@@ -1142,6 +1174,7 @@ export {
1142
1174
  // The only transport in the tree that can RUN an `MCPServer`. It reached
1143
1175
  // `connector/mcp/index.ts` and stopped there, so the server was public
1144
1176
  // with no public way to serve it.
1177
+ SandboxStdioTransport,
1145
1178
  ServerStdioTransport,
1146
1179
  StdioTransport,
1147
1180
  StreamableHttpTransport,
@@ -1167,6 +1200,8 @@ export type {
1167
1200
  McpSkillsClient,
1168
1201
  McpSkillsRefresh,
1169
1202
  McpSkillsRefreshStatus,
1203
+ SandboxStdioReplyVerdict,
1204
+ SandboxStdioTransportOptions,
1170
1205
  McpEnvelope,
1171
1206
  McpEnvelopeInput,
1172
1207
  McpEraProbe,
@@ -1580,6 +1615,7 @@ export {
1580
1615
  COMPACTION_HEADER,
1581
1616
  COMPACTION_RECOVERY_NOTE,
1582
1617
  COMPACTION_RESUME_NOTE,
1618
+ COMPACTION_RESUME_NOTE_MAY_ASK,
1583
1619
  isCompactionMessage,
1584
1620
  } from './compaction/summary.js'
1585
1621
  export {
@@ -1896,10 +1932,14 @@ export {
1896
1932
  export {
1897
1933
  GuardedFetchProvider,
1898
1934
  WebFetchRefusedError,
1935
+ checkedAddresses,
1899
1936
  isPrivateAddress,
1937
+ pinnedFetch,
1938
+ pinnedLookup,
1900
1939
  privateAddressProblem,
1901
1940
  proxyConfigured,
1902
1941
  } from './connector/web/index.js'
1942
+ export type { AddressCheckOptions, PinnedRequest } from './connector/web/index.js'
1903
1943
 
1904
1944
  // Where an attachment's bytes live when the message does not carry them.
1905
1945
  // Inline base64 lands in the transcript, in every checkpoint, and on the
@@ -2109,6 +2149,7 @@ export {
2109
2149
  export {
2110
2150
  ChildOutcomeRecordedRecordSchema,
2111
2151
  ChildSessionMetaSchema,
2152
+ CompactionMeasuredRecordSchema,
2112
2153
  CompactionRecordSchema,
2113
2154
  ExternalRefSchema,
2114
2155
  IgnorableRecordSchema,
@@ -286,6 +286,7 @@ export { buildAgentTool, type AgentToolOptions } from './tools/coordinator/agent
286
286
  // jobs, draws the confirmation and computes every field it shows. Register
287
287
  // only where a person can confirm (never headless, scheduled or delegated).
288
288
  export {
289
+ buildScheduleSelfTool,
289
290
  buildScheduleTools,
290
291
  buildSessionLoopTools,
291
292
  buildSessionTimerTools,
@@ -293,6 +294,7 @@ export {
293
294
  clampWakeUpDelay,
294
295
  revealHiddenCharacters,
295
296
  scanSchedulePrompt,
297
+ SCHEDULE_SELF_TOOL_NAME,
296
298
  SCHEDULE_TOOL_NAME,
297
299
  SESSION_LOOP_TOOL_NAME,
298
300
  TIMER_CANCEL_TOOL_NAME,
@@ -254,12 +254,26 @@ export type {
254
254
  ShellHookOnFailure,
255
255
  ShellHookCall,
256
256
  ShellHookInput,
257
+ ShellHookHandlerType,
257
258
  ShellHookOptions,
258
259
  ShellHookPathFilter,
259
260
  ShellHookOutcome,
260
261
  ShellHooksConfig,
261
262
  } from './plugin/shell-hook.js'
262
263
  export type { ShellHookToolNames } from './plugin/shell-hook-tool-names.js'
264
+ export type {
265
+ ShellHookExecRequest,
266
+ ShellHookExecResult,
267
+ ShellHookExecutor,
268
+ } from './plugin/shell-hook-execute.js'
269
+ export type {
270
+ CapabilityBridge,
271
+ CapabilityBridgeOptions,
272
+ HookModuleCapability,
273
+ HookModuleClock,
274
+ HookModuleTransport,
275
+ HookModuleTransportFactory,
276
+ } from './plugin/hook-module/index.js'
263
277
  export type { HookEnvEvent, SessionHookEnvOptions } from './plugin/session-hook-env.js'
264
278
  export type {
265
279
  FileChange,
@@ -451,6 +465,10 @@ export type {
451
465
  SessionGoalStore,
452
466
  } from './store/goal/index.js'
453
467
  export type { ResolveGoalRoundAuthority } from './tools/goal/index.js'
468
+ export type {
469
+ GoalGateHost,
470
+ GoalGateRunInput,
471
+ } from './tools/goal/confirmation.js'
454
472
  export type {
455
473
  GoalConfirmationOptions,
456
474
  GoalDecision,
@@ -741,7 +759,10 @@ export type {
741
759
  ScheduleJobPreview,
742
760
  ScheduleJobSummary,
743
761
  ScheduleJobUpdateProposal,
762
+ ScheduleNoteSummary,
744
763
  ScheduleRuleEffect,
764
+ ScheduleSelfChanges,
765
+ ScheduleSelfHost,
745
766
  ScheduleToolHost,
746
767
  ScheduleUpdateRequest,
747
768
  SelfPacedHost,
@@ -1,4 +1,5 @@
1
1
  import type { SessionGoalActivation } from '../../manager/goal/activation.js'
2
+ import { goalGateCommandText } from '../../store/goal/gates.js'
2
3
  import {
3
4
  GoalExistsError,
4
5
  GoalNotFoundError,
@@ -10,7 +11,15 @@ import {
10
11
  goalTokensText,
11
12
  } from '../../store/goal/index.js'
12
13
  import type { HostCommandDescriptor } from '../../types/command/index.js'
13
- import type { GoalConfirmedBy, GoalGuards, GoalRef, SessionGoal } from '../../types/goal/index.js'
14
+ import type {
15
+ GoalConfirmedBy,
16
+ GoalGateResult,
17
+ GoalGates,
18
+ GoalGatesSpec,
19
+ GoalGuards,
20
+ GoalRef,
21
+ SessionGoal,
22
+ } from '../../types/goal/index.js'
14
23
  import type { SessionId, TenantId } from '../../types/ids/index.js'
15
24
  import type { Skill } from '../../types/skills/index.js'
16
25
  import { isInvocableBy, skillInvocation } from '../../types/skills/index.js'
@@ -63,6 +72,10 @@ export interface GoalCommandScope {
63
72
  export interface GoalCommandDefaults {
64
73
  readonly maxGoalRounds?: number
65
74
  readonly guards?: GoalGuards
75
+ /** Completion gates a goal created here carries, shown when it starts. */
76
+ readonly gates?: GoalGatesSpec
77
+ /** A sentence added to a new goal's answer, for example why configured gates were left off. */
78
+ readonly gatesNotice?: string
66
79
  }
67
80
 
68
81
  const GOAL_ARGUMENTS =
@@ -189,6 +202,42 @@ function goalCommands(goal: SessionGoal, armed: boolean): string {
189
202
  return '/goal set <objective>, /goal clear'
190
203
  }
191
204
 
205
+ function gateResultText(result: GoalGateResult | undefined): string {
206
+ if (result === undefined) return 'not run yet'
207
+ const when = new Date(result.at).toISOString().replace('T', ' ').slice(0, 19)
208
+ switch (result.status) {
209
+ case 'passed':
210
+ return `passed (${when} UTC)${result.notRerun ? ', files unchanged since' : ''}`
211
+ case 'failed':
212
+ return `failed${result.exitCode !== undefined ? `, exit ${result.exitCode}` : ''} (${when} UTC)${result.notRerun ? ', not run again: files unchanged since' : ''}`
213
+ case 'timed-out':
214
+ return `timed out (${when} UTC)${result.notRerun ? ', not run again: files unchanged since' : ''}`
215
+ case 'refused':
216
+ return `not run: ${result.reason ?? 'refused'} (${when} UTC)`
217
+ }
218
+ }
219
+
220
+ /** The gates a goal carries and what they last showed, as lines of the status. */
221
+ export function renderGoalGates(gates: GoalGates | undefined): string[] {
222
+ if (gates === undefined || gates.entries.length === 0) return []
223
+ const lines = [
224
+ 'Completion gates (run by Namzu when each round ends; the goal is complete only when every one passes on the files as they are):',
225
+ ]
226
+ for (const [index, entry] of gates.entries.entries()) {
227
+ const result = gates.results.find((candidate) => candidate.name === entry.name)
228
+ const where = entry.cwd !== undefined ? ` in ${entry.cwd}` : ''
229
+ const limit =
230
+ entry.timeoutMs !== undefined ? `, limit ${Math.round(entry.timeoutMs / 1000)} s` : ''
231
+ lines.push(
232
+ ` ${index + 1}. ${entry.name}: ${goalGateCommandText(entry.command)}${where}${limit} - ${gateResultText(result)}`,
233
+ )
234
+ }
235
+ lines.push(
236
+ ` Failing rounds in a row: ${gates.failingRounds} of ${gates.maxFailingRounds}; the goal stops at ${gates.maxFailingRounds}.`,
237
+ )
238
+ return lines
239
+ }
240
+
192
241
  function renderGoal(
193
242
  title: string,
194
243
  goal: SessionGoal,
@@ -219,12 +268,17 @@ function renderGoal(
219
268
  ...(goal.missing && goal.missing.length > 0
220
269
  ? [`Still missing: ${goal.missing.join('; ')}`]
221
270
  : []),
271
+ ...renderGoalGates(goal.gates),
222
272
  `Objective: ${goal.objective}`,
223
273
  '',
224
274
  `Commands: ${goalCommands(goal, armed)}`,
225
275
  ].join('\n')
226
276
  }
227
277
 
278
+ function withGatesNotice(message: string, defaults: GoalCommandDefaults | undefined): string {
279
+ return defaults?.gatesNotice ? `${message}\n${defaults.gatesNotice}` : message
280
+ }
281
+
228
282
  function renderScopedGoal(title: string, goal: SessionGoal, scope: GoalCommandScope): string {
229
283
  return renderGoal(
230
284
  title,
@@ -306,13 +360,14 @@ async function runGoalCommand(scope: GoalCommandScope | undefined, args: readonl
306
360
  ...(maxGoalRounds !== undefined ? { maxGoalRounds } : {}),
307
361
  ...(Object.keys(guards).length > 0 ? { guards } : {}),
308
362
  ...(flag.confirmedBy !== undefined ? { confirmedBy: flag.confirmedBy } : {}),
363
+ ...(defaults?.gates ? { gates: defaults.gates } : {}),
309
364
  },
310
365
  scope.tenantId,
311
366
  )
312
367
  scope.activation?.arm(created)
313
368
  return {
314
369
  kind: 'ack' as const,
315
- message: renderScopedGoal('Goal created', created, scope),
370
+ message: withGatesNotice(renderScopedGoal('Goal created', created, scope), defaults),
316
371
  }
317
372
  }
318
373
  case 'edit': {
@@ -326,13 +381,17 @@ async function runGoalCommand(scope: GoalCommandScope | undefined, args: readonl
326
381
  ? { maxGoalRounds: scope.defaults.maxGoalRounds }
327
382
  : {}),
328
383
  ...(scope.defaults?.guards ? { guards: scope.defaults.guards } : {}),
384
+ ...(scope.defaults?.gates ? { gates: scope.defaults.gates } : {}),
329
385
  },
330
386
  scope.tenantId,
331
387
  )
332
388
  scope.activation?.arm(replacement)
333
389
  return {
334
390
  kind: 'ack' as const,
335
- message: renderScopedGoal('Goal created', replacement, scope),
391
+ message: withGatesNotice(
392
+ renderScopedGoal('Goal created', replacement, scope),
393
+ scope.defaults,
394
+ ),
336
395
  }
337
396
  }
338
397
  const wasArmed = scope.activation?.isArmed(scope.sessionId, current) ?? false
@@ -107,3 +107,17 @@ export function toolDiscoveryHint(description: string, maxLength = 100): string
107
107
  if (sentence.length <= maxLength) return sentence
108
108
  return `${sentence.slice(0, maxLength - 1).trimEnd()}…`
109
109
  }
110
+
111
+ /**
112
+ * The catalogue line of a deferred tool: its explicit `discoveryHint` when it
113
+ * has one, else the first-sentence rule of {@link toolDiscoveryHint}.
114
+ */
115
+ export function toolCatalogueHint(
116
+ tool: { readonly description: string; readonly discoveryHint?: string },
117
+ maxLength = 100,
118
+ ): string {
119
+ const explicit = tool.discoveryHint?.trim().replace(/\s+/g, ' ') ?? ''
120
+ if (explicit.length === 0) return toolDiscoveryHint(tool.description, maxLength)
121
+ if (explicit.length <= maxLength) return explicit
122
+ return `${explicit.slice(0, maxLength - 1).trimEnd()}…`
123
+ }
@@ -4,7 +4,7 @@ import { isIP } from 'node:net'
4
4
 
5
5
  import type { WebSocket as WebSocketClient } from 'ws'
6
6
 
7
- import { isPrivateAddress } from '../../connector/web/guarded-fetch.js'
7
+ import { isPrivateAddress, pinnedLookup } from '../../connector/web/guarded-fetch.js'
8
8
  import { isolationOf } from '../../sandbox/isolation.js'
9
9
  import type { Sandbox } from '../../types/sandbox/index.js'
10
10
  import type { MonitorWebSocketTarget } from '../../types/tool/index.js'
@@ -170,51 +170,7 @@ export async function vetWebSocketTarget(
170
170
  return addresses.map((address) => ({ address, family: isIP(address) === 6 ? 6 : 4 }))
171
171
  }
172
172
 
173
- /**
174
- * A `lookup` for the socket that answers with the addresses that were checked
175
- * and nothing else.
176
- *
177
- * This is what closes the gap `web_fetch` documents: there the address is
178
- * checked, then the platform `fetch` resolves the name AGAIN, so a name that
179
- * answers publicly the first time and privately the second (DNS rebinding)
180
- * gets through. Here the connection never asks DNS: it is handed the checked
181
- * addresses, so there is no second answer to differ. The URL still names the
182
- * host, so TLS keeps its SNI and its certificate check on the hostname and not
183
- * on an address.
184
- */
185
- export function pinnedLookup(
186
- addresses: readonly { readonly address: string; readonly family: 4 | 6 }[],
187
- ) {
188
- return (
189
- _hostname: string,
190
- options: { all?: boolean; family?: number | string } | undefined,
191
- callback: (
192
- error: NodeJS.ErrnoException | null,
193
- address: string | { address: string; family: number }[],
194
- family?: number,
195
- ) => void,
196
- ): void => {
197
- // A caller that wants one family gets that family's addresses; asking for
198
- // one we hold none of is an error rather than a fall back to DNS.
199
- const wanted = options?.family === 4 || options?.family === 6 ? options.family : undefined
200
- const usable = wanted === undefined ? addresses : addresses.filter((a) => a.family === wanted)
201
- const first = usable[0]
202
- if (first === undefined) {
203
- const error: NodeJS.ErrnoException = new Error('no vetted address of that family')
204
- error.code = 'ENOTFOUND'
205
- callback(error, '', 0)
206
- return
207
- }
208
- if (options?.all === true) {
209
- callback(
210
- null,
211
- usable.map((a) => ({ address: a.address, family: a.family })),
212
- )
213
- return
214
- }
215
- callback(null, first.address, first.family)
216
- }
217
- }
173
+ export { pinnedLookup }
218
174
 
219
175
  /** `api.example.com` is that host; `.example.com` is the domain and its subdomains. */
220
176
  export function hostMatchesPolicy(hostname: string, allowedHosts: readonly string[]): boolean {
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The line a run reads shortly before one of its own limits ends it.
3
+ *
4
+ * Without it the iteration cap and the time limit cut a run off between two
5
+ * calls with no word to the model, which is the moment it most needs to leave
6
+ * its work in a state someone can pick up. The line is a request, never a
7
+ * change of limit: nothing here moves the cap or the clock.
8
+ */
9
+
10
+ /** Where the line is due: first when the remaining share is small, again when it is smaller. */
11
+ export type BudgetNudgeStage = 0 | 1 | 2
12
+
13
+ export interface BudgetLeft {
14
+ /** Calls left before the iteration cap, counting the one being prepared. */
15
+ iterations?: { left: number; total: number }
16
+ /** Milliseconds left before the time limit. */
17
+ timeMs?: { left: number; total: number }
18
+ }
19
+
20
+ const FIRST_ITERATION_FLOOR = 5
21
+ const SECOND_ITERATION_FLOOR = 2
22
+ const FIRST_TIME_FLOOR_MS = 2 * 60_000
23
+ const SECOND_TIME_FLOOR_MS = 30_000
24
+ const FIRST_SHARE = 0.1
25
+ const SECOND_SHARE = 0.03
26
+
27
+ /**
28
+ * The larger of the fixed floor and the share, held to half of what the
29
+ * stage before it allowed so a short budget is not nagged from its first
30
+ * call: a ten-call run is told at four calls left, never at the start.
31
+ */
32
+ function threshold(total: number, floor: number, share: number, ceiling: number): number {
33
+ return Math.min(Math.max(floor, total * share), ceiling)
34
+ }
35
+
36
+ function reached(left: number, total: number, floors: [number, number], shares: [number, number]) {
37
+ const first = threshold(total, floors[0], shares[0], total / 2)
38
+ const second = threshold(total, floors[1], shares[1], first / 2)
39
+ if (left <= second) return 2
40
+ if (left <= first) return 1
41
+ return 0
42
+ }
43
+
44
+ /** The stage the remaining budget has reached; 0 when no limit is near or none is set. */
45
+ export function budgetNudgeStage(left: BudgetLeft): BudgetNudgeStage {
46
+ let stage: BudgetNudgeStage = 0
47
+ if (left.iterations && left.iterations.total > 0) {
48
+ stage = Math.max(
49
+ stage,
50
+ reached(
51
+ left.iterations.left,
52
+ left.iterations.total,
53
+ [FIRST_ITERATION_FLOOR, SECOND_ITERATION_FLOOR],
54
+ [FIRST_SHARE, SECOND_SHARE],
55
+ ),
56
+ ) as BudgetNudgeStage
57
+ }
58
+ if (left.timeMs && Number.isFinite(left.timeMs.total) && left.timeMs.total > 0) {
59
+ stage = Math.max(
60
+ stage,
61
+ reached(
62
+ left.timeMs.left,
63
+ left.timeMs.total,
64
+ [FIRST_TIME_FLOOR_MS, SECOND_TIME_FLOOR_MS],
65
+ [FIRST_SHARE, SECOND_SHARE],
66
+ ),
67
+ ) as BudgetNudgeStage
68
+ }
69
+ return stage
70
+ }
71
+
72
+ function duration(ms: number): string {
73
+ const seconds = Math.max(0, Math.round(ms / 1000))
74
+ if (seconds < 90) return `${seconds} seconds`
75
+ return `${Math.round(seconds / 60)} minutes`
76
+ }
77
+
78
+ /** The one line: how much is left, and what to do with it. */
79
+ export function budgetNudgeText(left: BudgetLeft, stage: BudgetNudgeStage): string | null {
80
+ if (stage === 0) return null
81
+ const parts: string[] = []
82
+ if (left.iterations && left.iterations.total > 0) {
83
+ const n = Math.max(0, left.iterations.left)
84
+ parts.push(`${n} more ${n === 1 ? 'step' : 'steps'}`)
85
+ }
86
+ if (left.timeMs && Number.isFinite(left.timeMs.total) && left.timeMs.total > 0) {
87
+ parts.push(`about ${duration(left.timeMs.left)}`)
88
+ }
89
+ if (parts.length === 0) return null
90
+ const urgency = stage === 2 ? 'Very little is left' : 'This run is nearing its limit'
91
+ return `${urgency}: ${parts.join(' and ')} before it is stopped. Leave the work in a working state, write down what is unfinished, then finish. The limit does not move.`
92
+ }