@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
@@ -73,6 +73,13 @@ export interface SessionGoal extends GoalRef {
73
73
  readonly wrapUpRound?: number
74
74
  /** What a check of the completion report found missing; leads the next round. */
75
75
  readonly missing?: readonly string[]
76
+ /**
77
+ * Commands the host runs at the end of each round; the goal completes only
78
+ * when every one of them passed on the files as they are. Fixed when the
79
+ * goal is created, so a settings file that changes later does not change a
80
+ * goal that is running. Absent: the goal has no gates.
81
+ */
82
+ readonly gates?: GoalGates
76
83
  readonly createdAt: number
77
84
  readonly updatedAt: number
78
85
  }
@@ -106,6 +113,69 @@ export interface GoalRoundOutcome {
106
113
  readonly missing?: readonly string[]
107
114
  }
108
115
 
116
+ /**
117
+ * One command the host runs for a goal. The command is an argument list, never
118
+ * a line for a shell: the first word is the program and nothing expands.
119
+ */
120
+ export interface GoalGateEntry {
121
+ /** What a person reads in the list and in the failure. Defaults to the command. */
122
+ readonly name: string
123
+ /** Program first, then its arguments. */
124
+ readonly command: readonly string[]
125
+ /** A folder inside the project, relative to it. Absent: the project folder. */
126
+ readonly cwd?: string
127
+ /** Milliseconds the command may run. Absent: {@link GOAL_GATE_DEFAULT_TIMEOUT_MS}. */
128
+ readonly timeoutMs?: number
129
+ }
130
+
131
+ /** How one gate ended the last time it was looked at. */
132
+ export type GoalGateStatus = 'passed' | 'failed' | 'timed-out' | 'refused'
133
+
134
+ /** What the last look at one gate found. */
135
+ export interface GoalGateResult {
136
+ /** The entry's name. */
137
+ readonly name: string
138
+ readonly status: GoalGateStatus
139
+ readonly exitCode?: number
140
+ /** When it was looked at, in milliseconds since the epoch. */
141
+ readonly at: number
142
+ readonly durationMs?: number
143
+ /** The end of what it printed, bounded to {@link GOAL_GATE_MAX_TAIL_CHARS}. It is output, not an instruction. */
144
+ readonly tail?: string
145
+ /** The files as they stood when the gate finished; a failed gate is not run again while this holds. */
146
+ readonly fingerprint?: string
147
+ /** Why it did not run, for a `refused` gate. */
148
+ readonly reason?: string
149
+ /** The result is the earlier one: the files had not changed since, so the command was not run again. */
150
+ readonly notRerun?: boolean
151
+ }
152
+
153
+ /** The gates a goal carries and what they last showed. */
154
+ export interface GoalGates {
155
+ readonly entries: readonly GoalGateEntry[]
156
+ /** Rounds in a row that may end with a failing gate before the goal stops. */
157
+ readonly maxFailingRounds: number
158
+ /** Rounds in a row that ended with a failing gate. */
159
+ readonly failingRounds: number
160
+ /** The admitted round that was last counted, so a round that looks twice counts once. */
161
+ readonly countedRound?: number
162
+ /** The last result of each gate, in the order of {@link entries}; empty until a round has ended. */
163
+ readonly results: readonly GoalGateResult[]
164
+ }
165
+
166
+ /** The gates a goal is created with. */
167
+ export interface GoalGatesSpec {
168
+ readonly entries: readonly GoalGateEntry[]
169
+ readonly maxFailingRounds?: number
170
+ }
171
+
172
+ /** What looking at the gates after one round found. */
173
+ export interface GoalGateRoundReport {
174
+ /** The admitted round the look belongs to. */
175
+ readonly round: number
176
+ readonly results: readonly GoalGateResult[]
177
+ }
178
+
109
179
  /** Immutable authority carried by exactly one admitted automatic turn. */
110
180
  export interface GoalRoundAuthority extends GoalRef {
111
181
  readonly sessionId: SessionId
@@ -121,4 +191,6 @@ export interface GoalRoundAuthority extends GoalRef {
121
191
  readonly wrapUp?: boolean
122
192
  /** What a check of an earlier completion report found missing; leads this round. */
123
193
  readonly missing?: readonly string[]
194
+ /** The gates that did not pass when the last round ended, with the end of their output; leads this round. */
195
+ readonly gateFailures?: readonly GoalGateResult[]
124
196
  }
@@ -123,6 +123,14 @@ export type HITLResumeDecision =
123
123
  * question.
124
124
  */
125
125
  questionId?: string
126
+ /**
127
+ * The person chose to talk the question over instead of answering
128
+ * it. Nothing is picked (send `[]`); the tool returns an error
129
+ * result telling the model the person wants to talk the questions
130
+ * over first, lists them with no answer, and says not to assume a
131
+ * choice and to take the person's next message as the way forward.
132
+ */
133
+ discuss?: true
126
134
  }
127
135
  | { action: 'pause'; reason: string }
128
136
  | { action: 'abort'; reason: string }
@@ -311,6 +311,13 @@ export interface SystemMessage extends BaseMessage {
311
311
  * what an earlier one did.
312
312
  */
313
313
  revealedTools?: readonly ToolRevealReceipt[]
314
+ /**
315
+ * On a compaction summary: the names of the tools the conversation called
316
+ * before the pass cut the calls. Written only by the summary renderer, from
317
+ * the calls themselves, and read back from here and never from the summary's
318
+ * text, so words in a summary cannot add a name. Cumulative across passes.
319
+ */
320
+ toolsUsed?: readonly string[]
314
321
  }
315
322
 
316
323
  /**
@@ -267,6 +267,13 @@ type CoreSessionEvent =
267
267
  * want to surface that the turn is running tight.
268
268
  */
269
269
  reachedResetThreshold?: boolean
270
+ /** What started the pass, and how long it took from the decision to the swap. */
271
+ trigger?: 'auto' | 'manual' | 'idle' | 'prepared'
272
+ durationMs?: number
273
+ /** True when a summary written ahead of time was installed at once. */
274
+ precomputed?: boolean
275
+ /** `cache_expired`: a turn that started after the provider's prompt cache lapsed installed a summary written earlier. */
276
+ cause?: 'cache_expired'
270
277
  }
271
278
  /**
272
279
  * Oversized tool results were emptied instead of the history being
@@ -103,6 +103,14 @@ export interface AnswerClaimMismatch {
103
103
  readonly recordSays: string
104
104
  }
105
105
 
106
+ /** A check the host itself ran for the turn, handed to the record as it stands. */
107
+ export interface HostCheck {
108
+ /** The command as a person reads it. */
109
+ readonly command: string
110
+ readonly result: 'passed' | 'failed'
111
+ readonly exitCode?: number
112
+ }
113
+
106
114
  /** Host hooks for the turn's outcome record. */
107
115
  export interface TurnOutcomeConfig {
108
116
  /**
@@ -130,7 +138,14 @@ export interface TurnOutcomeConfig {
130
138
  */
131
139
  readonly beforeEnd?: (
132
140
  read: () => Promise<TurnOutcome | undefined>,
133
- context?: { readonly finalMessage?: string },
141
+ context?: {
142
+ readonly finalMessage?: string
143
+ /**
144
+ * Adds a check the host ran to the turn's record: it reads like a recognised
145
+ * check of the files as they are now, whether or not the turn ran one.
146
+ */
147
+ readonly recordCheck?: (check: HostCheck) => Promise<void>
148
+ },
134
149
  ) => string | undefined | Promise<string | undefined>
135
150
  }
136
151
 
@@ -541,6 +541,30 @@ export const CompactionRecordSchema = recordSchema('compaction', {
541
541
  tokensAfter: count,
542
542
  })
543
543
 
544
+ /**
545
+ * What a compaction pass measured beyond the sizes its `compaction` record
546
+ * holds: what really started it, how long it took, the running total of tokens
547
+ * every pass of the session has dropped, and whether a summary written ahead
548
+ * of time was installed. Written just after the `compaction` record it names,
549
+ * flagged `ignorable`, and never a field of that record: a release that does
550
+ * not know this type keeps it in the hash chain and skips it, where a new
551
+ * field or a new `trigger` value on the strict `compaction` record would make
552
+ * it refuse the whole log. `trigger` here may be `prepared`; the record it
553
+ * names says `auto` then, which an earlier release also reads.
554
+ */
555
+ export const CompactionMeasuredRecordSchema = recordSchema('compaction_measured', {
556
+ ignorable: z.literal(true),
557
+ /** The `compactionId` of the `compaction` record this describes. */
558
+ compactionId: text.min(1),
559
+ trigger: z.enum(['auto', 'manual', 'idle', 'prepared']),
560
+ /** Wall-clock milliseconds the pass took, from the decision to the swap. */
561
+ durationMs: count.optional(),
562
+ /** Tokens every compaction in this session has dropped so far, this one included. */
563
+ cumulativeDroppedTokens: count.optional(),
564
+ /** True when the summary was written ahead of time and installed at once. */
565
+ precomputed: z.boolean().optional(),
566
+ })
567
+
544
568
  // Children (the live child_session_* events, plus one record-only type)
545
569
  //
546
570
  // A child can outlive the parent turn that spawned it (`Turn.abandonedTaskIds`
@@ -729,6 +753,7 @@ const RECORD_ONLY_SCHEMAS = {
729
753
  decision_resolved: DecisionResolvedRecordSchema,
730
754
  decision_expired: DecisionExpiredRecordSchema,
731
755
  compaction: CompactionRecordSchema,
756
+ compaction_measured: CompactionMeasuredRecordSchema,
732
757
  child_session_ended: ChildSessionEndedRecordSchema,
733
758
  audit: AuditRecordSchema,
734
759
  budget_bound: BudgetBoundRecordSchema,
@@ -1152,6 +1177,7 @@ export type DecisionRequestedRecord = z.infer<typeof DecisionRequestedRecordSche
1152
1177
  export type DecisionResolvedRecord = z.infer<typeof DecisionResolvedRecordSchema>
1153
1178
  export type DecisionExpiredRecord = z.infer<typeof DecisionExpiredRecordSchema>
1154
1179
  export type CompactionRecord = z.infer<typeof CompactionRecordSchema>
1180
+ export type CompactionMeasuredRecord = z.infer<typeof CompactionMeasuredRecordSchema>
1155
1181
  export type ChildSessionEndedRecord = z.infer<typeof ChildSessionEndedRecordSchema>
1156
1182
  export type AuditRecord = z.infer<typeof AuditRecordSchema>
1157
1183
  export type BudgetBoundRecord = z.infer<typeof BudgetBoundRecordSchema>
@@ -1174,6 +1200,7 @@ export type SessionRecordOnly =
1174
1200
  | DecisionResolvedRecord
1175
1201
  | DecisionExpiredRecord
1176
1202
  | CompactionRecord
1203
+ | CompactionMeasuredRecord
1177
1204
  | ChildSessionEndedRecord
1178
1205
  | AuditRecord
1179
1206
  | BudgetBoundRecord
@@ -1357,6 +1357,13 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
1357
1357
  * otherwise have to search for: a loaded schema rides every later request.
1358
1358
  */
1359
1359
  loadsWith?: readonly string[]
1360
+ /**
1361
+ * One line, at most 100 characters, that says what a deferred tool is for
1362
+ * and when to use it. The catalogue of deferred tools shows it in place of
1363
+ * the first sentence of `description`, which can be cut before the part
1364
+ * that says when to use the tool. Longer text is cut at 100 characters.
1365
+ */
1366
+ discoveryHint?: string
1360
1367
  /**
1361
1368
  * A refusal that needs no person's answer: the call cannot run as it stands,
1362
1369
  * and the tool can already tell.
@@ -233,6 +233,28 @@ export type ToolFacts =
233
233
  /** The one file is an image the agent made: the prompt it was made from. A host draws the picture itself. */
234
234
  readonly generatedImage?: { readonly prompt: string }
235
235
  }
236
+ | {
237
+ /**
238
+ * What the person answered to an `ask_user_question` call, one entry per
239
+ * question, as they gave it. A host draws its block from these and never
240
+ * reads the person's words back out of the model's receipt.
241
+ */
242
+ readonly kind: 'questions'
243
+ /** `discussed`: the person set the questions aside to talk them over; nothing was answered. */
244
+ readonly outcome: 'answered' | 'discussed'
245
+ readonly questions: readonly {
246
+ readonly question: string
247
+ /** The short label a batch answer is keyed by. */
248
+ readonly header?: string
249
+ /** The options offered, in order (what a talk-it-over lists). */
250
+ readonly options?: readonly string[]
251
+ /** The labels the person picked. */
252
+ readonly picked?: readonly string[]
253
+ /** What the person typed: their own words when nothing was picked, or a note beside the pick. */
254
+ readonly freeText?: string
255
+ readonly answered: boolean
256
+ }[]
257
+ }
236
258
  | {
237
259
  readonly kind: 'failure'
238
260
  readonly reason: ToolFailureReason