@namzu/sdk 59.0.0 → 60.1.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 (370) hide show
  1. package/CHANGELOG.md +120 -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/bridge/a2a/mapper.d.ts.map +1 -1
  6. package/dist/bridge/a2a/mapper.js +16 -0
  7. package/dist/bridge/a2a/mapper.js.map +1 -1
  8. package/dist/bridge/acp/update.d.ts.map +1 -1
  9. package/dist/bridge/acp/update.js +1 -0
  10. package/dist/bridge/acp/update.js.map +1 -1
  11. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  12. package/dist/bridge/sse/mapper.js +12 -0
  13. package/dist/bridge/sse/mapper.js.map +1 -1
  14. package/dist/compaction/context-window.d.ts +53 -0
  15. package/dist/compaction/context-window.d.ts.map +1 -1
  16. package/dist/compaction/context-window.js +141 -2
  17. package/dist/compaction/context-window.js.map +1 -1
  18. package/dist/constants/continuation.d.ts +9 -0
  19. package/dist/constants/continuation.d.ts.map +1 -1
  20. package/dist/constants/continuation.js +9 -0
  21. package/dist/constants/continuation.js.map +1 -1
  22. package/dist/contracts/session/api.d.ts +7 -1
  23. package/dist/contracts/session/api.d.ts.map +1 -1
  24. package/dist/execution/workflow/index.d.ts +3 -1
  25. package/dist/execution/workflow/index.d.ts.map +1 -1
  26. package/dist/execution/workflow/index.js +2 -1
  27. package/dist/execution/workflow/index.js.map +1 -1
  28. package/dist/execution/workflow/journal.d.ts +24 -4
  29. package/dist/execution/workflow/journal.d.ts.map +1 -1
  30. package/dist/execution/workflow/journal.js +131 -9
  31. package/dist/execution/workflow/journal.js.map +1 -1
  32. package/dist/execution/workflow/prelude.d.ts +2 -0
  33. package/dist/execution/workflow/prelude.d.ts.map +1 -1
  34. package/dist/execution/workflow/prelude.js +49 -8
  35. package/dist/execution/workflow/prelude.js.map +1 -1
  36. package/dist/execution/workflow/resume.d.ts +59 -0
  37. package/dist/execution/workflow/resume.d.ts.map +1 -0
  38. package/dist/execution/workflow/resume.js +273 -0
  39. package/dist/execution/workflow/resume.js.map +1 -0
  40. package/dist/execution/workflow/runtime.d.ts.map +1 -1
  41. package/dist/execution/workflow/runtime.js +112 -8
  42. package/dist/execution/workflow/runtime.js.map +1 -1
  43. package/dist/execution/workflow/types.d.ts +105 -1
  44. package/dist/execution/workflow/types.d.ts.map +1 -1
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +4 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  50. package/dist/manager/session/turn-recorder.js +1 -0
  51. package/dist/manager/session/turn-recorder.js.map +1 -1
  52. package/dist/plugin/compat.d.ts +24 -0
  53. package/dist/plugin/compat.d.ts.map +1 -0
  54. package/dist/plugin/compat.js +149 -0
  55. package/dist/plugin/compat.js.map +1 -0
  56. package/dist/plugin/loader.d.ts +2 -1
  57. package/dist/plugin/loader.d.ts.map +1 -1
  58. package/dist/plugin/loader.js +6 -0
  59. package/dist/plugin/loader.js.map +1 -1
  60. package/dist/pricing/index.d.ts.map +1 -1
  61. package/dist/pricing/index.js +2 -1
  62. package/dist/pricing/index.js.map +1 -1
  63. package/dist/process/kill-tree.d.ts +44 -0
  64. package/dist/process/kill-tree.d.ts.map +1 -1
  65. package/dist/process/kill-tree.js +102 -4
  66. package/dist/process/kill-tree.js.map +1 -1
  67. package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
  68. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  69. package/dist/prompt/coding-agent-doctrine.js +9 -1
  70. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  71. package/dist/provider/collect-chat-completion.d.ts.map +1 -1
  72. package/dist/provider/collect-chat-completion.js +4 -0
  73. package/dist/provider/collect-chat-completion.js.map +1 -1
  74. package/dist/provider/fallback.d.ts.map +1 -1
  75. package/dist/provider/fallback.js +11 -0
  76. package/dist/provider/fallback.js.map +1 -1
  77. package/dist/provider/idle-timeout.d.ts.map +1 -1
  78. package/dist/provider/idle-timeout.js +5 -0
  79. package/dist/provider/idle-timeout.js.map +1 -1
  80. package/dist/provider/mock.d.ts +2 -0
  81. package/dist/provider/mock.d.ts.map +1 -1
  82. package/dist/provider/mock.js +16 -8
  83. package/dist/provider/mock.js.map +1 -1
  84. package/dist/provider/model-window-suffix.d.ts +18 -0
  85. package/dist/provider/model-window-suffix.d.ts.map +1 -0
  86. package/dist/provider/model-window-suffix.js +78 -0
  87. package/dist/provider/model-window-suffix.js.map +1 -0
  88. package/dist/provider/retry.d.ts.map +1 -1
  89. package/dist/provider/retry.js +5 -0
  90. package/dist/provider/retry.js.map +1 -1
  91. package/dist/public-runtime.d.ts +5 -3
  92. package/dist/public-runtime.d.ts.map +1 -1
  93. package/dist/public-runtime.js +5 -4
  94. package/dist/public-runtime.js.map +1 -1
  95. package/dist/public-types.d.ts +1 -0
  96. package/dist/public-types.d.ts.map +1 -1
  97. package/dist/registry/command/kernel-commands.d.ts +1 -4
  98. package/dist/registry/command/kernel-commands.d.ts.map +1 -1
  99. package/dist/registry/command/kernel-commands.js +0 -28
  100. package/dist/registry/command/kernel-commands.js.map +1 -1
  101. package/dist/runtime/jobs/awaited-jobs.d.ts +6 -0
  102. package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
  103. package/dist/runtime/jobs/awaited-jobs.js +11 -0
  104. package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
  105. package/dist/runtime/jobs/host-exit-finalizer.d.ts +20 -0
  106. package/dist/runtime/jobs/host-exit-finalizer.d.ts.map +1 -0
  107. package/dist/runtime/jobs/host-exit-finalizer.js +57 -0
  108. package/dist/runtime/jobs/host-exit-finalizer.js.map +1 -0
  109. package/dist/runtime/jobs/liveness.d.ts +67 -0
  110. package/dist/runtime/jobs/liveness.d.ts.map +1 -0
  111. package/dist/runtime/jobs/liveness.js +94 -0
  112. package/dist/runtime/jobs/liveness.js.map +1 -0
  113. package/dist/runtime/jobs/registry.d.ts +21 -0
  114. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  115. package/dist/runtime/jobs/registry.js +104 -2
  116. package/dist/runtime/jobs/registry.js.map +1 -1
  117. package/dist/runtime/jobs/wake-budget.d.ts +35 -0
  118. package/dist/runtime/jobs/wake-budget.d.ts.map +1 -0
  119. package/dist/runtime/jobs/wake-budget.js +48 -0
  120. package/dist/runtime/jobs/wake-budget.js.map +1 -0
  121. package/dist/runtime/query/detached-calls.d.ts +65 -0
  122. package/dist/runtime/query/detached-calls.d.ts.map +1 -0
  123. package/dist/runtime/query/detached-calls.js +116 -0
  124. package/dist/runtime/query/detached-calls.js.map +1 -0
  125. package/dist/runtime/query/executor.d.ts +4 -1
  126. package/dist/runtime/query/executor.d.ts.map +1 -1
  127. package/dist/runtime/query/executor.js +90 -6
  128. package/dist/runtime/query/executor.js.map +1 -1
  129. package/dist/runtime/query/index.d.ts +34 -0
  130. package/dist/runtime/query/index.d.ts.map +1 -1
  131. package/dist/runtime/query/index.js +32 -5
  132. package/dist/runtime/query/index.js.map +1 -1
  133. package/dist/runtime/query/iteration/effort-clamp.d.ts +13 -0
  134. package/dist/runtime/query/iteration/effort-clamp.d.ts.map +1 -0
  135. package/dist/runtime/query/iteration/effort-clamp.js +42 -0
  136. package/dist/runtime/query/iteration/effort-clamp.js.map +1 -0
  137. package/dist/runtime/query/iteration/index.d.ts +34 -0
  138. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  139. package/dist/runtime/query/iteration/index.js +199 -6
  140. package/dist/runtime/query/iteration/index.js.map +1 -1
  141. package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
  142. package/dist/runtime/query/iteration/outstanding-work.js +11 -3
  143. package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
  144. package/dist/runtime/query/iteration/phases/context.d.ts +9 -0
  145. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  146. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  147. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  148. package/dist/runtime/query/iteration/phases/tool-review.js +63 -1
  149. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  150. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  151. package/dist/runtime/query/iteration/stream-turn.js +6 -0
  152. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  153. package/dist/runtime/query/session-storage.d.ts.map +1 -1
  154. package/dist/runtime/query/session-storage.js +8 -3
  155. package/dist/runtime/query/session-storage.js.map +1 -1
  156. package/dist/runtime/query/steering.d.ts +29 -3
  157. package/dist/runtime/query/steering.d.ts.map +1 -1
  158. package/dist/runtime/query/steering.js +58 -3
  159. package/dist/runtime/query/steering.js.map +1 -1
  160. package/dist/runtime/query/tooling.d.ts +1 -0
  161. package/dist/runtime/query/tooling.d.ts.map +1 -1
  162. package/dist/runtime/query/tooling.js +1 -0
  163. package/dist/runtime/query/tooling.js.map +1 -1
  164. package/dist/runtime/system-events.d.ts +5 -0
  165. package/dist/runtime/system-events.d.ts.map +1 -1
  166. package/dist/runtime/system-events.js +7 -1
  167. package/dist/runtime/system-events.js.map +1 -1
  168. package/dist/sandbox/denial.d.ts +11 -0
  169. package/dist/sandbox/denial.d.ts.map +1 -0
  170. package/dist/sandbox/denial.js +61 -0
  171. package/dist/sandbox/denial.js.map +1 -0
  172. package/dist/sandbox/file-walk-program.d.ts.map +1 -1
  173. package/dist/sandbox/file-walk-program.js +31 -13
  174. package/dist/sandbox/file-walk-program.js.map +1 -1
  175. package/dist/sandbox/file-walk.d.ts +2 -0
  176. package/dist/sandbox/file-walk.d.ts.map +1 -1
  177. package/dist/sandbox/file-walk.js +64 -13
  178. package/dist/sandbox/file-walk.js.map +1 -1
  179. package/dist/sandbox/ignore-matcher.d.ts +30 -0
  180. package/dist/sandbox/ignore-matcher.d.ts.map +1 -0
  181. package/dist/sandbox/ignore-matcher.js +11 -0
  182. package/dist/sandbox/ignore-matcher.js.map +1 -0
  183. package/dist/sandbox/ignore-source.d.ts +26 -0
  184. package/dist/sandbox/ignore-source.d.ts.map +1 -0
  185. package/dist/sandbox/ignore-source.js +221 -0
  186. package/dist/sandbox/ignore-source.js.map +1 -0
  187. package/dist/sandbox/provider/local.d.ts.map +1 -1
  188. package/dist/sandbox/provider/local.js +11 -1
  189. package/dist/sandbox/provider/local.js.map +1 -1
  190. package/dist/scheduler/completion-inbox.d.ts.map +1 -1
  191. package/dist/scheduler/completion-inbox.js +1 -0
  192. package/dist/scheduler/completion-inbox.js.map +1 -1
  193. package/dist/session/log-hash.d.ts.map +1 -1
  194. package/dist/session/log-hash.js +18 -1
  195. package/dist/session/log-hash.js.map +1 -1
  196. package/dist/store/memory/disk.d.ts.map +1 -1
  197. package/dist/store/memory/disk.js +1 -1
  198. package/dist/store/memory/disk.js.map +1 -1
  199. package/dist/store/memory/markdown.d.ts.map +1 -1
  200. package/dist/store/memory/markdown.js +1 -1
  201. package/dist/store/memory/markdown.js.map +1 -1
  202. package/dist/store/memory/operation-lock.d.ts +20 -4
  203. package/dist/store/memory/operation-lock.d.ts.map +1 -1
  204. package/dist/store/memory/operation-lock.js +235 -58
  205. package/dist/store/memory/operation-lock.js.map +1 -1
  206. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  207. package/dist/store/session-index/sqlite.js +169 -16
  208. package/dist/store/session-index/sqlite.js.map +1 -1
  209. package/dist/tools/builtins/bash.d.ts.map +1 -1
  210. package/dist/tools/builtins/bash.js +10 -4
  211. package/dist/tools/builtins/bash.js.map +1 -1
  212. package/dist/tools/builtins/computer-use.d.ts +35 -0
  213. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  214. package/dist/tools/builtins/computer-use.js +512 -67
  215. package/dist/tools/builtins/computer-use.js.map +1 -1
  216. package/dist/tools/builtins/glob.d.ts +1 -0
  217. package/dist/tools/builtins/glob.d.ts.map +1 -1
  218. package/dist/tools/builtins/glob.js +65 -28
  219. package/dist/tools/builtins/glob.js.map +1 -1
  220. package/dist/tools/builtins/grep.d.ts +2 -0
  221. package/dist/tools/builtins/grep.d.ts.map +1 -1
  222. package/dist/tools/builtins/grep.js +94 -40
  223. package/dist/tools/builtins/grep.js.map +1 -1
  224. package/dist/tools/builtins/job.d.ts +1 -1
  225. package/dist/tools/builtins/job.d.ts.map +1 -1
  226. package/dist/tools/builtins/job.js +34 -7
  227. package/dist/tools/builtins/job.js.map +1 -1
  228. package/dist/tools/builtins/search-support.d.ts +44 -0
  229. package/dist/tools/builtins/search-support.d.ts.map +1 -0
  230. package/dist/tools/builtins/search-support.js +89 -0
  231. package/dist/tools/builtins/search-support.js.map +1 -0
  232. package/dist/tools/builtins/wait-for-job-bounds.d.ts +2 -0
  233. package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
  234. package/dist/tools/builtins/wait-for-job-bounds.js +3 -1
  235. package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
  236. package/dist/tools/builtins/wait-for-job.d.ts +1 -1
  237. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  238. package/dist/tools/builtins/wait-for-job.js +13 -2
  239. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  240. package/dist/tools/command-shell.d.ts.map +1 -1
  241. package/dist/tools/command-shell.js +14 -5
  242. package/dist/tools/command-shell.js.map +1 -1
  243. package/dist/turn/reporter.d.ts.map +1 -1
  244. package/dist/turn/reporter.js +11 -0
  245. package/dist/turn/reporter.js.map +1 -1
  246. package/dist/types/agent/query.d.ts +2 -0
  247. package/dist/types/agent/query.d.ts.map +1 -1
  248. package/dist/types/computer-use/index.d.ts +129 -13
  249. package/dist/types/computer-use/index.d.ts.map +1 -1
  250. package/dist/types/computer-use/index.js.map +1 -1
  251. package/dist/types/message/index.d.ts +1 -1
  252. package/dist/types/message/index.d.ts.map +1 -1
  253. package/dist/types/message/index.js +1 -0
  254. package/dist/types/message/index.js.map +1 -1
  255. package/dist/types/plugin/index.d.ts +24 -0
  256. package/dist/types/plugin/index.d.ts.map +1 -1
  257. package/dist/types/plugin/index.js +4 -0
  258. package/dist/types/plugin/index.js.map +1 -1
  259. package/dist/types/provider/chat.d.ts +19 -0
  260. package/dist/types/provider/chat.d.ts.map +1 -1
  261. package/dist/types/provider/config.d.ts +7 -0
  262. package/dist/types/provider/config.d.ts.map +1 -1
  263. package/dist/types/provider/index.d.ts +1 -1
  264. package/dist/types/provider/index.d.ts.map +1 -1
  265. package/dist/types/provider/interface.d.ts +15 -0
  266. package/dist/types/provider/interface.d.ts.map +1 -1
  267. package/dist/types/provider/stream.d.ts +6 -0
  268. package/dist/types/provider/stream.d.ts.map +1 -1
  269. package/dist/types/sandbox/index.d.ts +38 -1
  270. package/dist/types/sandbox/index.d.ts.map +1 -1
  271. package/dist/types/sandbox/index.js.map +1 -1
  272. package/dist/types/session/events.d.ts +34 -0
  273. package/dist/types/session/events.d.ts.map +1 -1
  274. package/dist/types/session/events.js.map +1 -1
  275. package/dist/types/session/records.d.ts +298 -34
  276. package/dist/types/session/records.d.ts.map +1 -1
  277. package/dist/types/session/records.js +35 -1
  278. package/dist/types/session/records.js.map +1 -1
  279. package/dist/types/session/stop-reason.d.ts +11 -0
  280. package/dist/types/session/stop-reason.d.ts.map +1 -1
  281. package/dist/types/tool/index.d.ts +30 -0
  282. package/dist/types/tool/index.d.ts.map +1 -1
  283. package/dist/types/tool/index.js.map +1 -1
  284. package/dist/types/tool/presentation.d.ts +8 -0
  285. package/dist/types/tool/presentation.d.ts.map +1 -1
  286. package/package.json +1 -1
  287. package/src/agents/QueryAgent.ts +1 -0
  288. package/src/bridge/a2a/mapper.ts +19 -0
  289. package/src/bridge/acp/update.ts +6 -1
  290. package/src/bridge/sse/mapper.ts +13 -0
  291. package/src/compaction/context-window.ts +163 -2
  292. package/src/constants/continuation.ts +13 -0
  293. package/src/contracts/session/api.ts +6 -0
  294. package/src/execution/workflow/index.ts +14 -1
  295. package/src/execution/workflow/journal.ts +161 -11
  296. package/src/execution/workflow/prelude.ts +51 -8
  297. package/src/execution/workflow/resume.ts +313 -0
  298. package/src/execution/workflow/runtime.ts +127 -9
  299. package/src/execution/workflow/types.ts +109 -1
  300. package/src/index.ts +17 -0
  301. package/src/manager/session/turn-recorder.ts +1 -0
  302. package/src/plugin/compat.ts +173 -0
  303. package/src/plugin/loader.ts +7 -1
  304. package/src/pricing/index.ts +2 -1
  305. package/src/process/kill-tree.ts +106 -4
  306. package/src/prompt/coding-agent-doctrine.ts +9 -1
  307. package/src/provider/collect-chat-completion.ts +3 -0
  308. package/src/provider/fallback.ts +17 -0
  309. package/src/provider/idle-timeout.ts +9 -0
  310. package/src/provider/mock.ts +19 -9
  311. package/src/provider/model-window-suffix.ts +85 -0
  312. package/src/provider/retry.ts +9 -0
  313. package/src/public-runtime.ts +21 -2
  314. package/src/public-types.ts +1 -0
  315. package/src/registry/command/kernel-commands.ts +1 -32
  316. package/src/runtime/jobs/awaited-jobs.ts +11 -0
  317. package/src/runtime/jobs/host-exit-finalizer.ts +67 -0
  318. package/src/runtime/jobs/liveness.ts +144 -0
  319. package/src/runtime/jobs/registry.ts +114 -2
  320. package/src/runtime/jobs/wake-budget.ts +55 -0
  321. package/src/runtime/query/detached-calls.ts +135 -0
  322. package/src/runtime/query/executor.ts +92 -10
  323. package/src/runtime/query/index.ts +65 -7
  324. package/src/runtime/query/iteration/effort-clamp.ts +46 -0
  325. package/src/runtime/query/iteration/index.ts +260 -6
  326. package/src/runtime/query/iteration/outstanding-work.ts +12 -3
  327. package/src/runtime/query/iteration/phases/context.ts +9 -0
  328. package/src/runtime/query/iteration/phases/tool-review.ts +73 -8
  329. package/src/runtime/query/iteration/stream-turn.ts +5 -0
  330. package/src/runtime/query/session-storage.ts +8 -3
  331. package/src/runtime/query/steering.ts +77 -6
  332. package/src/runtime/query/tooling.ts +2 -0
  333. package/src/runtime/system-events.ts +12 -1
  334. package/src/sandbox/denial.ts +79 -0
  335. package/src/sandbox/file-walk-program.ts +32 -13
  336. package/src/sandbox/file-walk.ts +75 -12
  337. package/src/sandbox/ignore-matcher.ts +46 -0
  338. package/src/sandbox/ignore-source.ts +220 -0
  339. package/src/sandbox/provider/local.ts +11 -1
  340. package/src/scheduler/completion-inbox.ts +1 -0
  341. package/src/session/log-hash.ts +21 -0
  342. package/src/store/memory/disk.ts +1 -0
  343. package/src/store/memory/markdown.ts +1 -0
  344. package/src/store/memory/operation-lock.ts +288 -57
  345. package/src/store/session-index/sqlite.ts +171 -16
  346. package/src/tools/builtins/bash.ts +11 -4
  347. package/src/tools/builtins/computer-use.ts +593 -68
  348. package/src/tools/builtins/glob.ts +79 -32
  349. package/src/tools/builtins/grep.ts +107 -43
  350. package/src/tools/builtins/job.ts +42 -12
  351. package/src/tools/builtins/search-support.ts +107 -0
  352. package/src/tools/builtins/wait-for-job-bounds.ts +5 -1
  353. package/src/tools/builtins/wait-for-job.ts +14 -2
  354. package/src/tools/command-shell.ts +13 -5
  355. package/src/turn/reporter.ts +12 -0
  356. package/src/types/agent/query.ts +2 -0
  357. package/src/types/computer-use/index.ts +157 -15
  358. package/src/types/message/index.ts +5 -3
  359. package/src/types/plugin/index.ts +8 -0
  360. package/src/types/provider/chat.ts +20 -0
  361. package/src/types/provider/config.ts +7 -0
  362. package/src/types/provider/index.ts +1 -0
  363. package/src/types/provider/interface.ts +20 -0
  364. package/src/types/provider/stream.ts +6 -0
  365. package/src/types/sandbox/index.ts +40 -1
  366. package/src/types/session/events.ts +65 -5
  367. package/src/types/session/records.ts +39 -2
  368. package/src/types/session/stop-reason.ts +11 -0
  369. package/src/types/tool/index.ts +30 -0
  370. package/src/types/tool/presentation.ts +8 -0
@@ -102,7 +102,12 @@ type CoreSessionEvent =
102
102
  /** The token ledger this turn spends from, keyed by the root turn. */
103
103
  budget?: TurnBudgetBinding
104
104
  }
105
- | { type: 'iteration_started'; sessionId: SessionId; turnId: TurnId; iteration: number }
105
+ | {
106
+ type: 'iteration_started'
107
+ sessionId: SessionId
108
+ turnId: TurnId
109
+ iteration: number
110
+ }
106
111
  /**
107
112
  * Who answers when this turn asks a human, changed mid-turn.
108
113
  *
@@ -454,6 +459,40 @@ type CoreSessionEvent =
454
459
  */
455
460
  restart?: boolean
456
461
  }
462
+ /**
463
+ * The model declined to answer, and what the turn did about it.
464
+ *
465
+ * The provider finished a reply as a refusal or a safety block. The refused
466
+ * reply is kept out of the history sent next. `outcome` says what followed:
467
+ *
468
+ * - `'fallback'`: the request is being re-run on `fallbackModel`, which the
469
+ * rest of the turn keeps. A host that owns the session's model is expected
470
+ * to keep it for later turns too and to say so.
471
+ * - `'retry'`: no other model was available and the refused reply had
472
+ * partial output, so the request is being re-run once on the same model
473
+ * with a note that the previous reply was stopped.
474
+ * - `'declined'`: nothing recovered it. The turn settles with stop reason
475
+ * `'refused'`.
476
+ *
477
+ * Like `provider_fallback`, this is the feature's honesty: a swapped model
478
+ * must be shown, not logged. It is emitted before the re-run starts.
479
+ */
480
+ | {
481
+ type: 'model_refusal'
482
+ sessionId: SessionId
483
+ turnId: TurnId
484
+ iteration: number
485
+ /** The model that declined. */
486
+ model: string
487
+ providerId: string
488
+ outcome: 'fallback' | 'retry' | 'declined'
489
+ /** The model the request moves to. Set only with `outcome: 'fallback'`. */
490
+ fallbackModel?: string
491
+ /** The provider's own classification, when it gave one. */
492
+ category?: string
493
+ /** The provider's own sentence, when it gave one. Show it; do not parse it. */
494
+ explanation?: string
495
+ }
457
496
  | {
458
497
  type: 'tool_completed'
459
498
  /** Bounded result view; omitted when output was overridden or truncated. */
@@ -892,7 +931,12 @@ type CoreSessionEvent =
892
931
  steps: PlanStep[]
893
932
  summary?: string
894
933
  }
895
- | { type: 'plan_approved'; sessionId: SessionId; turnId: TurnId; planId: PlanId }
934
+ | {
935
+ type: 'plan_approved'
936
+ sessionId: SessionId
937
+ turnId: TurnId
938
+ planId: PlanId
939
+ }
896
940
  | {
897
941
  type: 'plan_rejected'
898
942
  sessionId: SessionId
@@ -923,7 +967,12 @@ type CoreSessionEvent =
923
967
  * through `onContextCreated`, so they proved the plan settled without ever
924
968
  * asking whether a consumer of the EVENT STREAM could see it.
925
969
  */
926
- | { type: 'plan_completed'; sessionId: SessionId; turnId: TurnId; planId: PlanId }
970
+ | {
971
+ type: 'plan_completed'
972
+ sessionId: SessionId
973
+ turnId: TurnId
974
+ planId: PlanId
975
+ }
927
976
  /**
928
977
  * The plan is over and it did not finish.
929
978
  *
@@ -931,7 +980,13 @@ type CoreSessionEvent =
931
980
  * an event that says "failed" without saying why puts the reader back
932
981
  * where the missing event did.
933
982
  */
934
- | { type: 'plan_failed'; sessionId: SessionId; turnId: TurnId; planId: PlanId; reason?: string }
983
+ | {
984
+ type: 'plan_failed'
985
+ sessionId: SessionId
986
+ turnId: TurnId
987
+ planId: PlanId
988
+ reason?: string
989
+ }
935
990
  | {
936
991
  type: 'agent_pending'
937
992
  sessionId: SessionId
@@ -1103,7 +1158,12 @@ type CoreSessionEvent =
1103
1158
  exitCode: number
1104
1159
  durationMs: number
1105
1160
  }
1106
- | { type: 'sandbox_destroyed'; sessionId: SessionId; turnId?: TurnId; sandboxId: SandboxId }
1161
+ | {
1162
+ type: 'sandbox_destroyed'
1163
+ sessionId: SessionId
1164
+ turnId?: TurnId
1165
+ sandboxId: SandboxId
1166
+ }
1107
1167
  // ─────────────────────────────────────────────────────────────────────
1108
1168
  // v3 message + tool-input lifecycle (additive 2026-05; see
1109
1169
  // ses_001-tool-stream-events). These are not yet emitted by the
@@ -236,6 +236,7 @@ const stopReason = z.enum([
236
236
  'step_refused',
237
237
  'structured_output_failed',
238
238
  'output_limit',
239
+ 'refused',
239
240
  'answer_rejected',
240
241
  'input_guardrail',
241
242
  'output_guardrail',
@@ -278,7 +279,9 @@ export const TurnSettlementSchema = z
278
279
  const completedSettlement = TurnSettlementSchema.extend({
279
280
  status: z.enum(['completed', 'cancelled']),
280
281
  })
281
- const failedSettlement = TurnSettlementSchema.extend({ status: z.literal('failed') })
282
+ const failedSettlement = TurnSettlementSchema.extend({
283
+ status: z.literal('failed'),
284
+ })
282
285
 
283
286
  /** A body too large for one record, written (and fsynced) to `tool-results/` before the record. */
284
287
  const spill = z
@@ -653,6 +656,7 @@ const SESSION_EVENT_TYPE_TABLE: Record<SessionEventType, true> = {
653
656
  hosted_tool: true,
654
657
  provider_retry: true,
655
658
  provider_fallback: true,
659
+ model_refusal: true,
656
660
  tool_completed: true,
657
661
  user_question_asked: true,
658
662
  user_question_answered: true,
@@ -747,6 +751,7 @@ const TURN_BOUND_OTHER_TYPE_LIST = [
747
751
  'hosted_tool',
748
752
  'provider_retry',
749
753
  'provider_fallback',
754
+ 'model_refusal',
750
755
  'tool_completed',
751
756
  'user_question_asked',
752
757
  'user_question_answered',
@@ -798,6 +803,36 @@ const RECORD_OPTIONS = [
798
803
  ...z.ZodDiscriminatedUnionOption<'type'>[],
799
804
  ]
800
805
 
806
+ /**
807
+ * A record of a type this reader does not know, written by a newer writer
808
+ * that flagged it `ignorable: true`: a promise that no reader needs it to
809
+ * rebuild the conversation. It is kept in the hash chain and verified like any
810
+ * other record, but never moves the fold. A known type never qualifies (its
811
+ * own schema decides), and an unknown type without the flag is still refused,
812
+ * so a record that does move the fold fails loudly on an older reader.
813
+ */
814
+ export const IgnorableRecordSchema = z
815
+ .object({
816
+ ...envelopeShape,
817
+ type: z
818
+ .string()
819
+ .min(1)
820
+ .refine((type) => !(SESSION_RECORD_TYPES as readonly string[]).includes(type), {
821
+ message: 'a type this reader knows is validated by its own schema',
822
+ }),
823
+ ignorable: z.literal(true),
824
+ })
825
+ .passthrough()
826
+ .superRefine((record, context) => {
827
+ if (record.seq === 1 || record.prev === null) {
828
+ context.addIssue({
829
+ code: z.ZodIssueCode.custom,
830
+ path: ['type'],
831
+ message: 'session_started is the first record of a session log, and only the first',
832
+ })
833
+ }
834
+ })
835
+
801
836
  /** Validates one session record: envelope, discriminant, and every specified payload. */
802
837
  export const SessionRecordSchema = z
803
838
  .discriminatedUnion('type', RECORD_OPTIONS)
@@ -973,7 +1008,9 @@ export type SessionEventRecord<T extends PersistedSessionEventType = PersistedSe
973
1008
  ? Omit<EventOf<T>, 'sessionId' | 'turnId' | 'lineage' | 'v' | 'seq' | 'generation'> &
974
1009
  RecordEnvelope &
975
1010
  (T extends 'tool_completed'
976
- ? { readonly structuredResultSpill?: z.infer<typeof structuredResultSpill> }
1011
+ ? {
1012
+ readonly structuredResultSpill?: z.infer<typeof structuredResultSpill>
1013
+ }
977
1014
  : T extends 'turn_completed'
978
1015
  ? {
979
1016
  readonly resultSpill?: z.infer<typeof spill>
@@ -53,6 +53,17 @@ export type StopReason =
53
53
  * looking for a loop instead of at the reviewer.
54
54
  */
55
55
  | 'answer_rejected'
56
+ /**
57
+ * The model declined to answer and nothing recovered it.
58
+ *
59
+ * Its provider finished the reply as a refusal or a safety block, and the
60
+ * one automatic retry this turn allows was not available or was refused
61
+ * too. Distinct from `end_turn` so a host never reads a declined request
62
+ * as a finished one, and from `error` because nothing failed: the model
63
+ * answered, and the answer was no. The refused reply is not in the
64
+ * history; a `model_refusal` event carries what the provider said.
65
+ */
66
+ | 'refused'
56
67
  /** An input guardrail refused the turn before it started. */
57
68
  | 'input_guardrail'
58
69
  /** An output guardrail refused the produced result. */
@@ -173,6 +173,8 @@ export interface BackgroundJobRegistryRef {
173
173
  status: string
174
174
  exitCode?: number
175
175
  error?: string
176
+ /** When it last wrote output (epoch ms); absent until it has. */
177
+ lastOutputAt?: number
176
178
  }
177
179
  /**
178
180
  * Take over a process the caller already started and is waiting on, so a
@@ -224,7 +226,19 @@ export interface BackgroundJobRegistryRef {
224
226
  kind?: 'monitor'
225
227
  /** What a monitor watches. */
226
228
  description?: string
229
+ /** When the job started (epoch ms). Optional for hosts that do not keep it. */
230
+ startedAt?: number
231
+ /** When it last wrote output (epoch ms); absent until it has. */
232
+ lastOutputAt?: number
233
+ /** Its last non-empty output line, flattened and clipped. */
234
+ lastOutputLine?: string
227
235
  }[]
236
+ /**
237
+ * Whether the job's process is still there, asked of the system rather than
238
+ * taken from the record. Optional: a host that cannot probe omits it, and a
239
+ * running job is then reported as alive on the registry's word.
240
+ */
241
+ isAlive?(id: string): boolean
228
242
  /**
229
243
  * Await this job's exit instead of reading it in a loop; resolves at
230
244
  * once for a job that has already stopped. Optional, and added after
@@ -259,6 +273,13 @@ export interface BackgroundJobRegistryRef {
259
273
  * intent, and then there is simply no hold.
260
274
  */
261
275
  markAwaited?(id: string): void
276
+ /**
277
+ * Say that this job's exit and output have just been handed to the model by
278
+ * a tool result (`wait_for_job` returning the exit, `job` read of a stopped
279
+ * job), so the exit notice that would announce the same exit is withdrawn
280
+ * instead of repeating it. Optional for the reason `markAwaited` is.
281
+ */
282
+ markCollected?(id: string): void
262
283
  }
263
284
 
264
285
  /**
@@ -514,6 +535,15 @@ export interface ToolContext {
514
535
  * directory; an absolute path inside any of these is accepted.
515
536
  */
516
537
  additionalDirectories?: readonly string[]
538
+ /**
539
+ * Whether the session's read rules deny an absolute path. The search tools
540
+ * (`grep`, `glob`) call it for every file they would list or open and skip
541
+ * a denied one, so a search over a folder holding a denied file succeeds
542
+ * without showing or reading it. The executor supplies it from the turn's
543
+ * authorization gate (what the `read` tool would be told for that path);
544
+ * absent, no rules apply.
545
+ */
546
+ readDenied?: (absolutePath: string) => boolean
517
547
  /**
518
548
  * Absolute path of the directory holding THIS session's retained tool
519
549
  * output (the files an oversized result was saved to). The `read` tool may
@@ -175,6 +175,10 @@ export type ToolFacts =
175
175
  readonly filesMatched?: number
176
176
  readonly filesSearched?: number
177
177
  readonly truncated?: boolean
178
+ /** A page or result cap cut the list; more results exist. */
179
+ readonly limited?: boolean
180
+ /** The search stopped before every file was examined. */
181
+ readonly incomplete?: boolean
178
182
  }
179
183
  | {
180
184
  readonly kind: 'list'
@@ -182,6 +186,10 @@ export type ToolFacts =
182
186
  readonly path?: string
183
187
  readonly count?: number
184
188
  readonly truncated?: boolean
189
+ /** A result cap cut the list; more files match. */
190
+ readonly limited?: boolean
191
+ /** The search stopped before every file was examined. */
192
+ readonly incomplete?: boolean
185
193
  }
186
194
  | {
187
195
  readonly kind: 'edit'