@namzu/sdk 31.1.0 → 33.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 (355) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/dist/agents/ReactiveAgent.d.ts.map +1 -1
  3. package/dist/agents/ReactiveAgent.js +4 -0
  4. package/dist/agents/ReactiveAgent.js.map +1 -1
  5. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  6. package/dist/agents/SupervisorAgent.js +4 -0
  7. package/dist/agents/SupervisorAgent.js.map +1 -1
  8. package/dist/agents/runAgent.d.ts +4 -0
  9. package/dist/agents/runAgent.d.ts.map +1 -1
  10. package/dist/agents/runAgent.js +4 -0
  11. package/dist/agents/runAgent.js.map +1 -1
  12. package/dist/authorization/gate.d.ts +1 -1
  13. package/dist/authorization/gate.js +1 -1
  14. package/dist/connector/index.d.ts +1 -1
  15. package/dist/connector/index.d.ts.map +1 -1
  16. package/dist/connector/index.js +1 -1
  17. package/dist/connector/index.js.map +1 -1
  18. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  19. package/dist/connector/mcp/adapter.js +71 -16
  20. package/dist/connector/mcp/adapter.js.map +1 -1
  21. package/dist/connector/mcp/client.d.ts.map +1 -1
  22. package/dist/connector/mcp/client.js +3 -2
  23. package/dist/connector/mcp/client.js.map +1 -1
  24. package/dist/connector/mcp/http-redirect.d.ts +17 -0
  25. package/dist/connector/mcp/http-redirect.d.ts.map +1 -0
  26. package/dist/connector/mcp/http-redirect.js +31 -0
  27. package/dist/connector/mcp/http-redirect.js.map +1 -0
  28. package/dist/connector/mcp/http-sse.d.ts.map +1 -1
  29. package/dist/connector/mcp/http-sse.js +5 -0
  30. package/dist/connector/mcp/http-sse.js.map +1 -1
  31. package/dist/connector/mcp/image-admission.d.ts +16 -0
  32. package/dist/connector/mcp/image-admission.d.ts.map +1 -0
  33. package/dist/connector/mcp/image-admission.js +288 -0
  34. package/dist/connector/mcp/image-admission.js.map +1 -0
  35. package/dist/connector/mcp/stdio.d.ts +13 -0
  36. package/dist/connector/mcp/stdio.d.ts.map +1 -1
  37. package/dist/connector/mcp/stdio.js +66 -23
  38. package/dist/connector/mcp/stdio.js.map +1 -1
  39. package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
  40. package/dist/connector/mcp/streamable-http.js +3 -0
  41. package/dist/connector/mcp/streamable-http.js.map +1 -1
  42. package/dist/constants/tools/index.js +1 -1
  43. package/dist/constants/tools/index.js.map +1 -1
  44. package/dist/directory/derive-supervisor.d.ts.map +1 -1
  45. package/dist/directory/derive-supervisor.js +5 -0
  46. package/dist/directory/derive-supervisor.js.map +1 -1
  47. package/dist/directory/derive.d.ts.map +1 -1
  48. package/dist/directory/derive.js +5 -0
  49. package/dist/directory/derive.js.map +1 -1
  50. package/dist/directory/load.d.ts.map +1 -1
  51. package/dist/directory/load.js +1 -0
  52. package/dist/directory/load.js.map +1 -1
  53. package/dist/directory/types.d.ts +2 -0
  54. package/dist/directory/types.d.ts.map +1 -1
  55. package/dist/execution/base.d.ts +13 -0
  56. package/dist/execution/base.d.ts.map +1 -1
  57. package/dist/execution/base.js +103 -8
  58. package/dist/execution/base.js.map +1 -1
  59. package/dist/execution/code-runtime/types.d.ts +11 -1
  60. package/dist/execution/code-runtime/types.d.ts.map +1 -1
  61. package/dist/execution/code-runtime/types.js.map +1 -1
  62. package/dist/execution/code-runtime/worker.d.ts.map +1 -1
  63. package/dist/execution/code-runtime/worker.js +67 -9
  64. package/dist/execution/code-runtime/worker.js.map +1 -1
  65. package/dist/execution/errors.d.ts +12 -0
  66. package/dist/execution/errors.d.ts.map +1 -0
  67. package/dist/execution/errors.js +21 -0
  68. package/dist/execution/errors.js.map +1 -0
  69. package/dist/execution/factory.d.ts.map +1 -1
  70. package/dist/execution/factory.js +1 -0
  71. package/dist/execution/factory.js.map +1 -1
  72. package/dist/execution/hybrid.d.ts +5 -0
  73. package/dist/execution/hybrid.d.ts.map +1 -1
  74. package/dist/execution/hybrid.js +36 -16
  75. package/dist/execution/hybrid.js.map +1 -1
  76. package/dist/execution/index.d.ts +1 -0
  77. package/dist/execution/index.d.ts.map +1 -1
  78. package/dist/execution/index.js +1 -0
  79. package/dist/execution/index.js.map +1 -1
  80. package/dist/execution/local.d.ts +13 -0
  81. package/dist/execution/local.d.ts.map +1 -1
  82. package/dist/execution/local.js +145 -19
  83. package/dist/execution/local.js.map +1 -1
  84. package/dist/execution/output.d.ts +27 -0
  85. package/dist/execution/output.d.ts.map +1 -0
  86. package/dist/execution/output.js +105 -0
  87. package/dist/execution/output.js.map +1 -0
  88. package/dist/execution/remote.d.ts +26 -2
  89. package/dist/execution/remote.d.ts.map +1 -1
  90. package/dist/execution/remote.js +86 -15
  91. package/dist/execution/remote.js.map +1 -1
  92. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  93. package/dist/manager/agent/lifecycle.js +1 -0
  94. package/dist/manager/agent/lifecycle.js.map +1 -1
  95. package/dist/plugin/lifecycle.d.ts.map +1 -1
  96. package/dist/plugin/lifecycle.js +9 -3
  97. package/dist/plugin/lifecycle.js.map +1 -1
  98. package/dist/process/kill-tree.d.ts +11 -13
  99. package/dist/process/kill-tree.d.ts.map +1 -1
  100. package/dist/process/kill-tree.js +11 -13
  101. package/dist/process/kill-tree.js.map +1 -1
  102. package/dist/provider/errors.d.ts +1 -0
  103. package/dist/provider/errors.d.ts.map +1 -1
  104. package/dist/provider/errors.js +39 -1
  105. package/dist/provider/errors.js.map +1 -1
  106. package/dist/provider/fallback.d.ts.map +1 -1
  107. package/dist/provider/fallback.js +31 -0
  108. package/dist/provider/fallback.js.map +1 -1
  109. package/dist/provider/idle-timeout.d.ts.map +1 -1
  110. package/dist/provider/idle-timeout.js +5 -0
  111. package/dist/provider/idle-timeout.js.map +1 -1
  112. package/dist/provider/retry.d.ts.map +1 -1
  113. package/dist/provider/retry.js +5 -0
  114. package/dist/provider/retry.js.map +1 -1
  115. package/dist/public-runtime.d.ts +7 -5
  116. package/dist/public-runtime.d.ts.map +1 -1
  117. package/dist/public-runtime.js +9 -4
  118. package/dist/public-runtime.js.map +1 -1
  119. package/dist/public-types.d.ts +2 -1
  120. package/dist/public-types.d.ts.map +1 -1
  121. package/dist/registry/tool/execute.d.ts +7 -1
  122. package/dist/registry/tool/execute.d.ts.map +1 -1
  123. package/dist/registry/tool/execute.js +201 -54
  124. package/dist/registry/tool/execute.js.map +1 -1
  125. package/dist/run/command-gate.d.ts.map +1 -1
  126. package/dist/run/command-gate.js +11 -0
  127. package/dist/run/command-gate.js.map +1 -1
  128. package/dist/run/reporter.d.ts.map +1 -1
  129. package/dist/run/reporter.js +6 -1
  130. package/dist/run/reporter.js.map +1 -1
  131. package/dist/run/workspace-fingerprint.d.ts +4 -4
  132. package/dist/run/workspace-fingerprint.d.ts.map +1 -1
  133. package/dist/run/workspace-fingerprint.js +6 -4
  134. package/dist/run/workspace-fingerprint.js.map +1 -1
  135. package/dist/runtime/bidi/index.d.ts +1 -1
  136. package/dist/runtime/bidi/index.d.ts.map +1 -1
  137. package/dist/runtime/bidi/index.js +1 -1
  138. package/dist/runtime/bidi/index.js.map +1 -1
  139. package/dist/runtime/bidi/session.d.ts +19 -0
  140. package/dist/runtime/bidi/session.d.ts.map +1 -1
  141. package/dist/runtime/bidi/session.js +150 -26
  142. package/dist/runtime/bidi/session.js.map +1 -1
  143. package/dist/runtime/query/executor.d.ts +43 -1
  144. package/dist/runtime/query/executor.d.ts.map +1 -1
  145. package/dist/runtime/query/executor.js +824 -174
  146. package/dist/runtime/query/executor.js.map +1 -1
  147. package/dist/runtime/query/index.d.ts +5 -0
  148. package/dist/runtime/query/index.d.ts.map +1 -1
  149. package/dist/runtime/query/index.js +47 -4
  150. package/dist/runtime/query/index.js.map +1 -1
  151. package/dist/runtime/query/iteration/index.d.ts +1 -0
  152. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  153. package/dist/runtime/query/iteration/index.js +34 -14
  154. package/dist/runtime/query/iteration/index.js.map +1 -1
  155. package/dist/runtime/query/iteration/phases/advisory.js +2 -2
  156. package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
  157. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  158. package/dist/runtime/query/iteration/phases/tool-review.js +84 -22
  159. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  160. package/dist/runtime/query/iteration/provider-rejected-image.d.ts +13 -0
  161. package/dist/runtime/query/iteration/provider-rejected-image.d.ts.map +1 -0
  162. package/dist/runtime/query/iteration/provider-rejected-image.js +91 -0
  163. package/dist/runtime/query/iteration/provider-rejected-image.js.map +1 -0
  164. package/dist/runtime/query/iteration/stream-turn.d.ts +4 -1
  165. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  166. package/dist/runtime/query/iteration/stream-turn.js +7 -3
  167. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  168. package/dist/runtime/query/request-rich-content.d.ts +13 -0
  169. package/dist/runtime/query/request-rich-content.d.ts.map +1 -1
  170. package/dist/runtime/query/request-rich-content.js +173 -17
  171. package/dist/runtime/query/request-rich-content.js.map +1 -1
  172. package/dist/runtime/query/result.d.ts.map +1 -1
  173. package/dist/runtime/query/result.js +1 -0
  174. package/dist/runtime/query/result.js.map +1 -1
  175. package/dist/runtime/query/resume-pending.d.ts +5 -1
  176. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  177. package/dist/runtime/query/resume-pending.js +66 -1
  178. package/dist/runtime/query/resume-pending.js.map +1 -1
  179. package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
  180. package/dist/runtime/query/tool-output-budget.js +45 -16
  181. package/dist/runtime/query/tool-output-budget.js.map +1 -1
  182. package/dist/runtime/query/tooling.d.ts +6 -0
  183. package/dist/runtime/query/tooling.d.ts.map +1 -1
  184. package/dist/runtime/query/tooling.js +4 -0
  185. package/dist/runtime/query/tooling.js.map +1 -1
  186. package/dist/sandbox/provider/local.d.ts.map +1 -1
  187. package/dist/sandbox/provider/local.js +193 -41
  188. package/dist/sandbox/provider/local.js.map +1 -1
  189. package/dist/scheduler/delegating.d.ts +2 -1
  190. package/dist/scheduler/delegating.d.ts.map +1 -1
  191. package/dist/scheduler/delegating.js +6 -5
  192. package/dist/scheduler/delegating.js.map +1 -1
  193. package/dist/scheduler/local.d.ts +2 -1
  194. package/dist/scheduler/local.d.ts.map +1 -1
  195. package/dist/scheduler/local.js +2 -2
  196. package/dist/scheduler/local.js.map +1 -1
  197. package/dist/session/workspace/driver.d.ts +12 -4
  198. package/dist/session/workspace/driver.d.ts.map +1 -1
  199. package/dist/session/workspace/git-worktree.d.ts +17 -3
  200. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  201. package/dist/session/workspace/git-worktree.js +153 -34
  202. package/dist/session/workspace/git-worktree.js.map +1 -1
  203. package/dist/skills/registry.d.ts +15 -0
  204. package/dist/skills/registry.d.ts.map +1 -1
  205. package/dist/skills/registry.js +33 -0
  206. package/dist/skills/registry.js.map +1 -1
  207. package/dist/store/attachment/index.d.ts +24 -2
  208. package/dist/store/attachment/index.d.ts.map +1 -1
  209. package/dist/store/attachment/index.js +52 -5
  210. package/dist/store/attachment/index.js.map +1 -1
  211. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  212. package/dist/tools/builtins/computer-use.js +39 -2
  213. package/dist/tools/builtins/computer-use.js.map +1 -1
  214. package/dist/tools/builtins/lsp.d.ts +1 -1
  215. package/dist/tools/builtins/run-code.d.ts.map +1 -1
  216. package/dist/tools/builtins/run-code.js +24 -16
  217. package/dist/tools/builtins/run-code.js.map +1 -1
  218. package/dist/tools/builtins/skill.d.ts +2 -1
  219. package/dist/tools/builtins/skill.d.ts.map +1 -1
  220. package/dist/tools/builtins/skill.js +250 -6
  221. package/dist/tools/builtins/skill.js.map +1 -1
  222. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  223. package/dist/tools/coordinator/agent.js +100 -30
  224. package/dist/tools/coordinator/agent.js.map +1 -1
  225. package/dist/types/agent/base.d.ts +4 -0
  226. package/dist/types/agent/base.d.ts.map +1 -1
  227. package/dist/types/agent/factory.d.ts +1 -0
  228. package/dist/types/agent/factory.d.ts.map +1 -1
  229. package/dist/types/agent/manager.d.ts +1 -1
  230. package/dist/types/agent/manager.d.ts.map +1 -1
  231. package/dist/types/agent/scheduler.d.ts +10 -1
  232. package/dist/types/agent/scheduler.d.ts.map +1 -1
  233. package/dist/types/authorization/index.d.ts +12 -12
  234. package/dist/types/bidi/index.d.ts +19 -2
  235. package/dist/types/bidi/index.d.ts.map +1 -1
  236. package/dist/types/computer-use/index.d.ts +18 -0
  237. package/dist/types/computer-use/index.d.ts.map +1 -1
  238. package/dist/types/connector/execution-context.d.ts +3 -1
  239. package/dist/types/connector/execution-context.d.ts.map +1 -1
  240. package/dist/types/execution/index.d.ts +43 -1
  241. package/dist/types/execution/index.d.ts.map +1 -1
  242. package/dist/types/hitl/index.d.ts +11 -0
  243. package/dist/types/hitl/index.d.ts.map +1 -1
  244. package/dist/types/hitl/index.js.map +1 -1
  245. package/dist/types/message/index.d.ts +31 -1
  246. package/dist/types/message/index.d.ts.map +1 -1
  247. package/dist/types/message/index.js +43 -0
  248. package/dist/types/message/index.js.map +1 -1
  249. package/dist/types/plugin/index.d.ts +14 -1
  250. package/dist/types/plugin/index.d.ts.map +1 -1
  251. package/dist/types/plugin/index.js +1 -0
  252. package/dist/types/plugin/index.js.map +1 -1
  253. package/dist/types/provider/error.d.ts +4 -1
  254. package/dist/types/provider/error.d.ts.map +1 -1
  255. package/dist/types/provider/interface.d.ts +14 -0
  256. package/dist/types/provider/interface.d.ts.map +1 -1
  257. package/dist/types/run/events.d.ts +10 -2
  258. package/dist/types/run/events.d.ts.map +1 -1
  259. package/dist/types/run/events.js.map +1 -1
  260. package/dist/types/sandbox/index.d.ts +15 -10
  261. package/dist/types/sandbox/index.d.ts.map +1 -1
  262. package/dist/types/sandbox/index.js.map +1 -1
  263. package/dist/types/tool/index.d.ts +129 -12
  264. package/dist/types/tool/index.d.ts.map +1 -1
  265. package/dist/types/tool/index.js.map +1 -1
  266. package/dist/types/workspace/ref.d.ts +5 -0
  267. package/dist/types/workspace/ref.d.ts.map +1 -1
  268. package/dist/utils/abort.d.ts +8 -0
  269. package/dist/utils/abort.d.ts.map +1 -1
  270. package/dist/utils/abort.js +16 -0
  271. package/dist/utils/abort.js.map +1 -1
  272. package/package.json +4 -4
  273. package/src/agents/ReactiveAgent.ts +4 -0
  274. package/src/agents/SupervisorAgent.ts +4 -0
  275. package/src/agents/runAgent.ts +8 -0
  276. package/src/authorization/gate.ts +1 -1
  277. package/src/connector/index.ts +2 -0
  278. package/src/connector/mcp/adapter.ts +82 -21
  279. package/src/connector/mcp/client.ts +2 -1
  280. package/src/connector/mcp/http-redirect.ts +32 -0
  281. package/src/connector/mcp/http-sse.ts +5 -0
  282. package/src/connector/mcp/image-admission.ts +272 -0
  283. package/src/connector/mcp/stdio.ts +63 -21
  284. package/src/connector/mcp/streamable-http.ts +3 -0
  285. package/src/constants/tools/index.ts +1 -1
  286. package/src/directory/derive-supervisor.ts +5 -0
  287. package/src/directory/derive.ts +5 -0
  288. package/src/directory/load.ts +1 -0
  289. package/src/directory/types.ts +2 -0
  290. package/src/execution/base.ts +124 -7
  291. package/src/execution/code-runtime/types.ts +15 -1
  292. package/src/execution/code-runtime/worker.ts +72 -9
  293. package/src/execution/errors.ts +24 -0
  294. package/src/execution/factory.ts +1 -0
  295. package/src/execution/hybrid.ts +47 -16
  296. package/src/execution/index.ts +1 -0
  297. package/src/execution/local.ts +164 -19
  298. package/src/execution/output.ts +104 -0
  299. package/src/execution/remote.ts +122 -17
  300. package/src/manager/agent/lifecycle.ts +1 -0
  301. package/src/plugin/lifecycle.ts +9 -3
  302. package/src/process/kill-tree.ts +11 -13
  303. package/src/provider/errors.ts +40 -1
  304. package/src/provider/fallback.ts +39 -0
  305. package/src/provider/idle-timeout.ts +8 -0
  306. package/src/provider/retry.ts +8 -0
  307. package/src/public-runtime.ts +23 -2
  308. package/src/public-types.ts +11 -0
  309. package/src/registry/tool/execute.ts +230 -64
  310. package/src/run/command-gate.ts +12 -0
  311. package/src/run/reporter.ts +7 -1
  312. package/src/run/workspace-fingerprint.ts +5 -4
  313. package/src/runtime/bidi/index.ts +1 -1
  314. package/src/runtime/bidi/session.ts +177 -28
  315. package/src/runtime/query/executor.ts +987 -172
  316. package/src/runtime/query/index.ts +59 -6
  317. package/src/runtime/query/iteration/index.ts +69 -29
  318. package/src/runtime/query/iteration/phases/advisory.ts +2 -2
  319. package/src/runtime/query/iteration/phases/tool-review.ts +87 -23
  320. package/src/runtime/query/iteration/provider-rejected-image.ts +106 -0
  321. package/src/runtime/query/iteration/stream-turn.ts +12 -2
  322. package/src/runtime/query/request-rich-content.ts +213 -15
  323. package/src/runtime/query/result.ts +1 -0
  324. package/src/runtime/query/resume-pending.ts +83 -1
  325. package/src/runtime/query/tool-output-budget.ts +52 -17
  326. package/src/runtime/query/tooling.ts +10 -0
  327. package/src/sandbox/provider/local.ts +213 -45
  328. package/src/scheduler/delegating.ts +6 -5
  329. package/src/scheduler/local.ts +3 -2
  330. package/src/session/workspace/driver.ts +12 -4
  331. package/src/session/workspace/git-worktree.ts +173 -34
  332. package/src/skills/registry.ts +47 -0
  333. package/src/store/attachment/index.ts +100 -15
  334. package/src/tools/builtins/computer-use.ts +45 -2
  335. package/src/tools/builtins/run-code.ts +24 -16
  336. package/src/tools/builtins/skill.ts +325 -7
  337. package/src/tools/coordinator/agent.ts +108 -33
  338. package/src/types/agent/base.ts +4 -0
  339. package/src/types/agent/factory.ts +1 -0
  340. package/src/types/agent/manager.ts +1 -1
  341. package/src/types/agent/scheduler.ts +10 -1
  342. package/src/types/bidi/index.ts +19 -2
  343. package/src/types/computer-use/index.ts +19 -0
  344. package/src/types/connector/execution-context.ts +3 -0
  345. package/src/types/execution/index.ts +46 -1
  346. package/src/types/hitl/index.ts +11 -0
  347. package/src/types/message/index.ts +78 -1
  348. package/src/types/plugin/index.ts +15 -0
  349. package/src/types/provider/error.ts +4 -1
  350. package/src/types/provider/interface.ts +18 -0
  351. package/src/types/run/events.ts +18 -4
  352. package/src/types/sandbox/index.ts +15 -10
  353. package/src/types/tool/index.ts +159 -15
  354. package/src/types/workspace/ref.ts +5 -0
  355. package/src/utils/abort.ts +18 -0
@@ -109,6 +109,25 @@ export type ComputerUseResult =
109
109
  | { readonly type: 'cursor_position'; readonly point: Point }
110
110
  | { readonly type: 'ok' }
111
111
 
112
+ /**
113
+ * A state-changing desktop action started, but its subprocess did not report
114
+ * a clean completion. The desktop may already have changed, so treating this
115
+ * as an ordinary failure and automatically replaying the action is unsafe.
116
+ *
117
+ * Host packages throw an error carrying this shape. The SDK recognises it
118
+ * structurally so separately installed host and SDK versions do not need to
119
+ * share an error constructor identity.
120
+ */
121
+ export interface ComputerUseOutcomeUnknown {
122
+ readonly code: 'computer_use_outcome_unknown'
123
+ readonly action: ComputerUseAction['type']
124
+ readonly outcome: 'unknown'
125
+ readonly retrySafety: 'unsafe'
126
+ readonly timedOut: boolean
127
+ readonly exitCode: number
128
+ readonly message: string
129
+ }
130
+
112
131
  // ---------------------------------------------------------------------------
113
132
  // Host interface — the core abstraction. Mirrors Sandbox/SandboxProvider shape.
114
133
  // Implementations live outside @namzu/sdk (e.g. @namzu/computer-use).
@@ -13,6 +13,7 @@ export type {
13
13
  export type {
14
14
  CommandOptions,
15
15
  CommandResult,
16
+ CommandTermination,
16
17
  CommandExecutor,
17
18
  RemoteCommandHandler,
18
19
  } from '../execution/index.js'
@@ -33,6 +34,8 @@ export interface LocalExecutionContextConfig extends ExecutionContextBase {
33
34
  fsAccess: boolean
34
35
  envVars?: Record<string, string>
35
36
  shell?: string
37
+ /** Retained bytes per stdout/stderr stream. Defaults to 4 MiB; maximum 64 MiB. */
38
+ maxOutputBytes?: number
36
39
  }
37
40
 
38
41
  export interface RemoteExecutionContextConfig extends ExecutionContextBase {
@@ -5,22 +5,67 @@ export type ExecutionCapability = 'filesystem' | 'process' | 'network' | 'shell'
5
5
  export interface CommandOptions {
6
6
  cwd?: string
7
7
  env?: Record<string, string>
8
+ /**
9
+ * Caller-owned cancellation for this command.
10
+ *
11
+ * A compliant executor may accept this only when it can prove that command
12
+ * admission never happened or that admitted work reached quiescence before
13
+ * settling. `LocalExecutionContext` owns that guarantee for its process
14
+ * group. `RemoteExecutionContext` refuses this option because its generic
15
+ * executor seam has no reservation and terminal-acknowledgement protocol;
16
+ * use the `Sandbox.exec()` contract for cancellable remote execution.
17
+ */
18
+ signal?: AbortSignal
19
+ /**
20
+ * Command deadline in milliseconds; `0` disables the deadline.
21
+ *
22
+ * `LocalExecutionContext` owns its spawned process group through stdio
23
+ * close, first requesting termination and then forcing it after a bounded
24
+ * grace period. Remote handlers define how this option is enforced at their
25
+ * own execution boundary.
26
+ */
8
27
  timeoutMs?: number
9
28
  shell?: string | boolean
10
29
  }
11
30
 
31
+ export type CommandTermination =
32
+ | {
33
+ /** Caller cancellation was already present, so no process was admitted. */
34
+ origin: 'caller'
35
+ admitted: false
36
+ }
37
+ | {
38
+ /** The first Namzu-owned cause that requested termination. */
39
+ origin: 'caller' | 'timeout' | 'teardown'
40
+ admitted: true
41
+ /** The direct child's actual close signal, when Node reported one. */
42
+ signal?: string
43
+ }
44
+
12
45
  export interface CommandResult {
13
- exitCode: number
46
+ /** Numeric process exit, or `null` when no numeric exit exists. */
47
+ exitCode: number | null
14
48
  stdout: string
15
49
  stderr: string
50
+ /** Whether the executor retained only part of stdout. Absent means unknown. */
51
+ stdoutTruncated?: boolean
52
+ /** Whether the executor retained only part of stderr. Absent means unknown. */
53
+ stderrTruncated?: boolean
16
54
  durationMs: number
55
+ /** Present only when Namzu requested termination or refused pre-aborted admission. */
56
+ termination?: CommandTermination
17
57
  }
18
58
 
19
59
  export interface CommandExecutor {
20
60
  executeCommand(command: string, args?: string[], options?: CommandOptions): Promise<CommandResult>
21
61
  }
22
62
 
63
+ /**
64
+ * @deprecated Use `CommandExecutor` so command arguments retain their
65
+ * boundaries at the remote execution seam.
66
+ */
23
67
  export interface RemoteCommandHandler {
68
+ /** @deprecated Use `CommandExecutor.executeCommand()`. */
24
69
  executeRemote(command: string, options?: CommandOptions): Promise<CommandResult>
25
70
  }
26
71
 
@@ -71,6 +71,17 @@ export interface ToolCallSummary {
71
71
  name: string
72
72
  input: unknown
73
73
  isDestructive: boolean
74
+ /**
75
+ * Operator-policy verdict attached to the exact input shown for review.
76
+ *
77
+ * Persisted with a durable review so a later process cannot treat a call
78
+ * the gate denied as approved merely because the human approved a mixed
79
+ * batch. Absent only on checkpoints written before this field existed.
80
+ */
81
+ authorization?: {
82
+ decision: 'allow' | 'deny' | 'review'
83
+ reason?: string
84
+ }
74
85
  }
75
86
 
76
87
  export interface ToolModification {
@@ -4,6 +4,22 @@ export type MessageRole = 'system' | 'user' | 'assistant' | 'tool'
4
4
 
5
5
  export type CacheHint = 'cache' | 'ephemeral' | 'none'
6
6
 
7
+ /** Why durable rich content must not be sent to a model again. */
8
+ export interface ModelContentOmission {
9
+ readonly reason: 'provider-rejected' | 'invalid-image'
10
+ }
11
+
12
+ /** Runtime validation for persisted model-delivery metadata. */
13
+ export function isModelContentOmission(value: unknown): value is ModelContentOmission {
14
+ return (
15
+ typeof value === 'object' &&
16
+ value !== null &&
17
+ !Array.isArray(value) &&
18
+ ((value as { readonly reason?: unknown }).reason === 'provider-rejected' ||
19
+ (value as { readonly reason?: unknown }).reason === 'invalid-image')
20
+ )
21
+ }
22
+
7
23
  /**
8
24
  * An image attached to a user message (vision input). Drivers that declare
9
25
  * vision support emit it alongside the text. A shipped driver that cannot
@@ -22,6 +38,8 @@ export interface ImageAttachment {
22
38
  readonly data: string
23
39
  /** IANA media type, e.g. `image/png`, `image/jpeg`, `image/webp`. */
24
40
  readonly mediaType: string
41
+ /** Durable delivery state; the original image bytes remain in history. */
42
+ readonly modelOmission?: ModelContentOmission
25
43
  }
26
44
 
27
45
  /**
@@ -212,7 +230,38 @@ export interface ProjectInstructionMessageSource {
212
230
  readonly files: readonly string[]
213
231
  }
214
232
 
215
- export type UserMessageSource = GoalRoundMessageSource | ProjectInstructionMessageSource
233
+ /**
234
+ * Why the runtime, rather than the operator, inserted one user-role message.
235
+ *
236
+ * Providers require several pieces of host context to occupy the `user` role:
237
+ * a continuation after an output ceiling, reviewer feedback, task completion
238
+ * notices, and similar prompts. Role alone therefore cannot answer who wrote a
239
+ * durable message. Keeping that provenance on the message prevents a resumed
240
+ * transcript, export, or previous-prompt editor from presenting kernel context
241
+ * as something the operator typed.
242
+ */
243
+ export const RUNTIME_CONTEXT_MESSAGE_KINDS = [
244
+ 'advisory',
245
+ 'answer-review',
246
+ 'auto-continuation',
247
+ 'limit-finalization',
248
+ 'steering',
249
+ 'structured-output',
250
+ 'task-completion',
251
+ ] as const
252
+
253
+ export type RuntimeContextMessageKind = (typeof RUNTIME_CONTEXT_MESSAGE_KINDS)[number]
254
+
255
+ /** Host-generated context carried in the provider's required user role. */
256
+ export interface RuntimeContextMessageSource {
257
+ readonly type: 'runtime-context'
258
+ readonly kind: RuntimeContextMessageKind
259
+ }
260
+
261
+ export type UserMessageSource =
262
+ | GoalRoundMessageSource
263
+ | ProjectInstructionMessageSource
264
+ | RuntimeContextMessageSource
216
265
 
217
266
  /** A bounded source list keeps untrusted persisted metadata cheap to validate. */
218
267
  export const MAX_PROJECT_INSTRUCTION_SOURCE_FILES = 256
@@ -254,6 +303,22 @@ export function isProjectInstructionMessageSource(
254
303
  return true
255
304
  }
256
305
 
306
+ /** Runtime validation for durable host-generated user-message provenance. */
307
+ export function isRuntimeContextMessageSource(
308
+ value: unknown,
309
+ ): value is RuntimeContextMessageSource {
310
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) return false
311
+ const candidate = value as {
312
+ readonly type?: unknown
313
+ readonly kind?: unknown
314
+ }
315
+ return (
316
+ candidate.type === 'runtime-context' &&
317
+ typeof candidate.kind === 'string' &&
318
+ (RUNTIME_CONTEXT_MESSAGE_KINDS as readonly string[]).includes(candidate.kind)
319
+ )
320
+ }
321
+
257
322
  /**
258
323
  * The configured model route that produced or is about to receive a message.
259
324
  *
@@ -349,6 +414,7 @@ export type ToolResultBlock =
349
414
  readonly type: 'image'
350
415
  readonly data: string
351
416
  readonly mediaType: string
417
+ readonly modelOmission?: ModelContentOmission
352
418
  }
353
419
  | DocumentAttachment
354
420
 
@@ -401,6 +467,17 @@ export function createUserMessage(
401
467
  }
402
468
  }
403
469
 
470
+ /** Build provider-visible context that no operator authored. */
471
+ export function createRuntimeContextMessage(
472
+ content: string,
473
+ kind: RuntimeContextMessageKind,
474
+ ): UserMessage {
475
+ return createUserMessage(content, undefined, {
476
+ type: 'runtime-context',
477
+ kind,
478
+ })
479
+ }
480
+
404
481
  /** Build the retained user-context message that carries live project policy. */
405
482
  export function createProjectInstructionMessage(
406
483
  content: string,
@@ -10,6 +10,7 @@ import {
10
10
  } from '../../constants/plugin/index.js'
11
11
  import type { PluginId, RunId } from '../ids/index.js'
12
12
  import type { Message, ToolResultContent } from '../message/index.js'
13
+ import type { CancelCause } from '../run/cancel-cause.js'
13
14
  import type { ToolResult } from '../tool/index.js'
14
15
 
15
16
  // ---------------------------------------------------------------------------
@@ -85,6 +86,7 @@ export function assertPluginContributionType(type: PluginContributionType): void
85
86
  export type PluginHookEvent =
86
87
  | 'run_start'
87
88
  | 'run_end'
89
+ | 'run_interrupt'
88
90
  | 'pre_tool_use'
89
91
  | 'post_tool_use'
90
92
  | 'pre_llm_call'
@@ -96,6 +98,7 @@ export function assertPluginHookEvent(event: PluginHookEvent): void {
96
98
  switch (event) {
97
99
  case 'run_start':
98
100
  case 'run_end':
101
+ case 'run_interrupt':
99
102
  case 'pre_tool_use':
100
103
  case 'post_tool_use':
101
104
  case 'pre_llm_call':
@@ -147,6 +150,15 @@ export interface PluginHookContext {
147
150
  readonly toolInput?: unknown
148
151
  readonly toolResult?: ToolResult
149
152
  readonly iteration?: number
153
+ /**
154
+ * Why the run was stopped, on `run_interrupt`.
155
+ *
156
+ * That hook is emitted only for a root run carrying the explicit `user`
157
+ * cause. Keeping the field typed as the complete cause vocabulary lets a
158
+ * host narrow normally and leaves room for a future, deliberate expansion
159
+ * without overloading `event` or an error sentence.
160
+ */
161
+ readonly cancelCause?: CancelCause
150
162
 
151
163
  /**
152
164
  * The request about to be sent, on `pre_llm_call`.
@@ -176,6 +188,9 @@ export interface PluginHookContext {
176
188
  readonly response?: Readonly<PluginModelResponse>
177
189
  /**
178
190
  * Aborts when this hook's run is cancelled or its deadline expires.
191
+ * `run_interrupt` is the exception: the run is already cancelled, so its
192
+ * handler receives a fresh signal that represents only the bounded cleanup
193
+ * deadline. The original verdict is available as `cancelCause`.
179
194
  *
180
195
  * The runtime stops waiting on a slow hook either way, but in-process
181
196
  * JavaScript cannot be forcibly stopped. Without a signal the hook itself
@@ -11,11 +11,14 @@ export type ProviderErrorKind =
11
11
  * Serializable provider-failure metadata carried by failed runs and events.
12
12
  *
13
13
  * No response body, URL, or `cause` belongs here. `detail` is the one thing
14
- * the provider itself said, and it arrives scrubbed see below.
14
+ * the provider itself said, and it arrives scrubbed. `providerCode` preserves
15
+ * a bounded machine identifier independently of wording — see below.
15
16
  */
16
17
  export interface ProviderErrorInfo {
17
18
  readonly kind: ProviderErrorKind
18
19
  readonly providerId: string
20
+ /** Provider-defined machine code, preserved only when it is a bounded safe token. */
21
+ readonly providerCode?: string
19
22
  readonly status?: number
20
23
  readonly retryAfterMs?: number
21
24
  /**
@@ -163,6 +163,24 @@ export interface LLMProvider {
163
163
  thinking?: import('./chat.js').ThinkingConfig,
164
164
  ): readonly import('./chat.js').ReasoningEffort[] | undefined
165
165
 
166
+ /**
167
+ * The effort a model uses when a request omits an explicit level.
168
+ *
169
+ * A directional control cannot infer this from the menu: a model may start
170
+ * anywhere in its advertised order, so treating "default" as an item before
171
+ * the first level can make an increase lower the effective effort. The
172
+ * method is optional because many drivers cannot establish a model-owned
173
+ * default. A present method returning `undefined` means this particular
174
+ * model is unknown.
175
+ *
176
+ * When both this and {@link LLMProvider.reasoningEffortLevelsFor} return an
177
+ * exact value, the default must be a member of that menu.
178
+ */
179
+ reasoningEffortDefaultFor?(
180
+ model: string,
181
+ thinking?: import('./chat.js').ThinkingConfig,
182
+ ): import('./chat.js').ReasoningEffort | undefined
183
+
166
184
  /**
167
185
  * Legacy effort menu which cannot distinguish an unknown model from a model
168
186
  * with no effort support.
@@ -320,7 +320,12 @@ type CoreRunEvent =
320
320
  * draws eleven siblings where there is one call with eleven
321
321
  * children.
322
322
  */
323
- via?: { readonly tool: string; readonly toolUseId: ToolUseId }
323
+ via?: {
324
+ readonly tool: string
325
+ readonly toolUseId: ToolUseId
326
+ /** The code runtime's request id, when that was the dispatch source. */
327
+ readonly runtimeToolCallId?: string
328
+ }
324
329
  }
325
330
  /**
326
331
  * A tool saying how far along it is.
@@ -334,7 +339,10 @@ type CoreRunEvent =
334
339
  * duration: the host could show that a tool had started and then nothing
335
340
  * at all until it either finished or timed out. The model never sees
336
341
  * these; they answer "is it still working?", which is a question only a
337
- * human asks.
342
+ * human asks. It is latest state rather than a lossless log: the executor
343
+ * bounds each UTF-8 message and coalesces intermediate updates when the
344
+ * live consumer falls behind. Complete output belongs to the terminal
345
+ * `tool_completed` result.
338
346
  */
339
347
  | {
340
348
  type: 'tool_progress'
@@ -412,7 +420,11 @@ type CoreRunEvent =
412
420
  isError: boolean
413
421
  /** See {@link tool_executing}'s `via`. Carried on both, so a
414
422
  * consumer can pair them without holding the start event. */
415
- via?: { readonly tool: string; readonly toolUseId: ToolUseId }
423
+ via?: {
424
+ readonly tool: string
425
+ readonly toolUseId: ToolUseId
426
+ readonly runtimeToolCallId?: string
427
+ }
416
428
  /**
417
429
  * Wall-clock the tool took. Computed since the first version of
418
430
  * the executor but only ever logged; a host asking "which tool
@@ -603,10 +615,12 @@ type CoreRunEvent =
603
615
  | {
604
616
  type: 'message_history_repaired'
605
617
  runId: RunId
606
- source: 'fresh-history' | 'abandoned-checkpoint'
618
+ source: 'fresh-history' | 'abandoned-checkpoint' | 'provider-rejected-image'
607
619
  duplicateToolResultsRemoved: number
608
620
  orphanedToolResultsRemoved: number
609
621
  syntheticToolResultsInserted: number
622
+ /** Exact number of durable image occurrences withheld from later requests. */
623
+ providerRejectedImagesSuppressed?: number
610
624
  }
611
625
  | {
612
626
  type: 'token_usage_updated'
@@ -141,22 +141,27 @@ export interface SandboxExecOptions {
141
141
  readonly data: string
142
142
  }) => void
143
143
  /**
144
- * Cancellation for the command. A backend that honours it kills the
145
- * process; one that does not simply ignores it, so this is additive.
144
+ * Cancellation for the command. A backend that accepts it must terminate
145
+ * the owned process or prove that admission never happened. A backend that
146
+ * cannot make that guarantee must refuse before admission; silently
147
+ * ignoring the signal is not a compliant implementation.
146
148
  *
147
149
  * Without it a Stop (or a per-tool deadline) could only ever abandon
148
150
  * the *wait* — the sandboxed process kept running after the host
149
151
  * believed the run had been cancelled.
150
152
  *
151
- * **Who honours it.** The in-process local sandbox does: the signal is
152
- * merged with the call's own deadline and reaches `spawn`, so the child
153
- * dies. The remote backends do not, and deliberately: their wire has no
154
- * cancel op, so aborting the request would abandon the wait and leave the
155
- * command running the failure above, wearing the appearance of a fix.
156
- * They will honour it when their protocols carry a cancel.
153
+ * **Who honours it.** The in-process local sandbox does: the run owns a
154
+ * listener until the process group's shared stdio closes, and terminates
155
+ * that group directly. The HTTP-container backends in `@namzu/sandbox` also
156
+ * do: a
157
+ * current peer reserves an execution before admission and confirms its
158
+ * cancellation over a separate control request. Older worker and microVM
159
+ * images are refused when this option is present, because aborting only the HTTP
160
+ * or framed data request would abandon the wait and leave the command
161
+ * running.
157
162
  *
158
- * Passing it is therefore always safe and never harmful; whether it takes
159
- * effect depends on the backend.
163
+ * Every backend shipped by Namzu therefore either enforces the signal or
164
+ * returns an explicit unsupported error before running the command.
160
165
  */
161
166
  readonly signal?: AbortSignal
162
167
  }