@namzu/sdk 49.0.0 → 50.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 (737) hide show
  1. package/CHANGELOG.md +507 -0
  2. package/README.md +137 -125
  3. package/dist/agents/QueryAgent.d.ts.map +1 -1
  4. package/dist/agents/QueryAgent.js +1 -0
  5. package/dist/agents/QueryAgent.js.map +1 -1
  6. package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -1
  7. package/dist/agents/examples/SupervisorAgent.js +1 -0
  8. package/dist/agents/examples/SupervisorAgent.js.map +1 -1
  9. package/dist/agents/runAgent.d.ts +2 -0
  10. package/dist/agents/runAgent.d.ts.map +1 -1
  11. package/dist/agents/runAgent.js +1 -0
  12. package/dist/agents/runAgent.js.map +1 -1
  13. package/dist/authorization/shell-lexer.d.ts.map +1 -1
  14. package/dist/authorization/shell-lexer.js +16 -1
  15. package/dist/authorization/shell-lexer.js.map +1 -1
  16. package/dist/bridge/acp/permission.d.ts +8 -2
  17. package/dist/bridge/acp/permission.d.ts.map +1 -1
  18. package/dist/bridge/acp/permission.js +1 -0
  19. package/dist/bridge/acp/permission.js.map +1 -1
  20. package/dist/bridge/acp/server.d.ts +25 -1
  21. package/dist/bridge/acp/server.d.ts.map +1 -1
  22. package/dist/bridge/acp/server.js +205 -21
  23. package/dist/bridge/acp/server.js.map +1 -1
  24. package/dist/bridge/acp/tasks.d.ts +5 -0
  25. package/dist/bridge/acp/tasks.d.ts.map +1 -0
  26. package/dist/bridge/acp/tasks.js +19 -0
  27. package/dist/bridge/acp/tasks.js.map +1 -0
  28. package/dist/bridge/acp/update.d.ts.map +1 -1
  29. package/dist/bridge/acp/update.js +148 -13
  30. package/dist/bridge/acp/update.js.map +1 -1
  31. package/dist/config/runtime.d.ts +31 -31
  32. package/dist/connector/mcp/adapter.d.ts.map +1 -1
  33. package/dist/connector/mcp/adapter.js +11 -4
  34. package/dist/connector/mcp/adapter.js.map +1 -1
  35. package/dist/connector/mcp/client.d.ts.map +1 -1
  36. package/dist/connector/mcp/client.js +6 -3
  37. package/dist/connector/mcp/client.js.map +1 -1
  38. package/dist/constants/acp/index.d.ts +3 -0
  39. package/dist/constants/acp/index.d.ts.map +1 -1
  40. package/dist/constants/acp/index.js +3 -0
  41. package/dist/constants/acp/index.js.map +1 -1
  42. package/dist/contracts/a2a.d.ts +80 -80
  43. package/dist/contracts/schemas.d.ts +2 -2
  44. package/dist/contracts/session/schemas.d.ts +10 -10
  45. package/dist/manager/agent/lifecycle.d.ts +11 -0
  46. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  47. package/dist/manager/agent/lifecycle.js +178 -3
  48. package/dist/manager/agent/lifecycle.js.map +1 -1
  49. package/dist/manager/plan/lifecycle.d.ts +7 -8
  50. package/dist/manager/plan/lifecycle.d.ts.map +1 -1
  51. package/dist/manager/plan/lifecycle.js +7 -8
  52. package/dist/manager/plan/lifecycle.js.map +1 -1
  53. package/dist/manager/resident/consumption.d.ts +8 -8
  54. package/dist/manager/resident/learning-cycle.d.ts +2 -2
  55. package/dist/manager/resident/learning-observation.d.ts +12 -12
  56. package/dist/manager/resident/learning.d.ts +82 -82
  57. package/dist/manager/resident/outbox.d.ts +8 -8
  58. package/dist/manager/resident/proposal.d.ts +2 -2
  59. package/dist/manager/resident/store.d.ts +10 -10
  60. package/dist/manager/session/attribution.d.ts +1 -0
  61. package/dist/manager/session/attribution.d.ts.map +1 -1
  62. package/dist/manager/session/attribution.js +9 -1
  63. package/dist/manager/session/attribution.js.map +1 -1
  64. package/dist/manager/session/streamed-message-identity.d.ts +6 -0
  65. package/dist/manager/session/streamed-message-identity.d.ts.map +1 -0
  66. package/dist/manager/session/streamed-message-identity.js +14 -0
  67. package/dist/manager/session/streamed-message-identity.js.map +1 -0
  68. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  69. package/dist/manager/session/turn-recorder.js +4 -3
  70. package/dist/manager/session/turn-recorder.js.map +1 -1
  71. package/dist/pals/activity/causality.d.ts +23 -0
  72. package/dist/pals/activity/causality.d.ts.map +1 -0
  73. package/dist/pals/activity/causality.js +205 -0
  74. package/dist/pals/activity/causality.js.map +1 -0
  75. package/dist/pals/activity/projection.d.ts +5 -0
  76. package/dist/pals/activity/projection.d.ts.map +1 -0
  77. package/dist/pals/activity/projection.js +79 -0
  78. package/dist/pals/activity/projection.js.map +1 -0
  79. package/dist/pals/activity/source.d.ts +16 -0
  80. package/dist/pals/activity/source.d.ts.map +1 -0
  81. package/dist/pals/activity/source.js +235 -0
  82. package/dist/pals/activity/source.js.map +1 -0
  83. package/dist/pals/activity/subscription-policy.d.ts +38 -0
  84. package/dist/pals/activity/subscription-policy.d.ts.map +1 -0
  85. package/dist/pals/activity/subscription-policy.js +183 -0
  86. package/dist/pals/activity/subscription-policy.js.map +1 -0
  87. package/dist/pals/activity/subscription-schema.d.ts +353 -0
  88. package/dist/pals/activity/subscription-schema.d.ts.map +1 -0
  89. package/dist/pals/activity/subscription-schema.js +24 -0
  90. package/dist/pals/activity/subscription-schema.js.map +1 -0
  91. package/dist/pals/activity/subscription-store.d.ts +25 -0
  92. package/dist/pals/activity/subscription-store.d.ts.map +1 -0
  93. package/dist/pals/activity/subscription-store.js +152 -0
  94. package/dist/pals/activity/subscription-store.js.map +1 -0
  95. package/dist/pals/activity/subscription-types.d.ts +42 -0
  96. package/dist/pals/activity/subscription-types.d.ts.map +1 -0
  97. package/dist/pals/activity/subscription-types.js +2 -0
  98. package/dist/pals/activity/subscription-types.js.map +1 -0
  99. package/dist/pals/activity/subscriptions.d.ts +32 -0
  100. package/dist/pals/activity/subscriptions.d.ts.map +1 -0
  101. package/dist/pals/activity/subscriptions.js +151 -0
  102. package/dist/pals/activity/subscriptions.js.map +1 -0
  103. package/dist/pals/activity/types.d.ts +77 -0
  104. package/dist/pals/activity/types.d.ts.map +1 -0
  105. package/dist/pals/activity/types.js +2 -0
  106. package/dist/pals/activity/types.js.map +1 -0
  107. package/dist/pals/channels/ingress.d.ts +9 -0
  108. package/dist/pals/channels/ingress.d.ts.map +1 -0
  109. package/dist/pals/channels/ingress.js +131 -0
  110. package/dist/pals/channels/ingress.js.map +1 -0
  111. package/dist/pals/channels/routes.d.ts +20 -0
  112. package/dist/pals/channels/routes.d.ts.map +1 -0
  113. package/dist/pals/channels/routes.js +111 -0
  114. package/dist/pals/channels/routes.js.map +1 -0
  115. package/dist/pals/channels/routing.d.ts +37 -0
  116. package/dist/pals/channels/routing.d.ts.map +1 -0
  117. package/dist/pals/channels/routing.js +150 -0
  118. package/dist/pals/channels/routing.js.map +1 -0
  119. package/dist/pals/channels/schema.d.ts +234 -0
  120. package/dist/pals/channels/schema.d.ts.map +1 -0
  121. package/dist/pals/channels/schema.js +94 -0
  122. package/dist/pals/channels/schema.js.map +1 -0
  123. package/dist/pals/channels/types.d.ts +115 -0
  124. package/dist/pals/channels/types.d.ts.map +1 -0
  125. package/dist/pals/channels/types.js +2 -0
  126. package/dist/pals/channels/types.js.map +1 -0
  127. package/dist/pals/communication/broker.d.ts +8 -0
  128. package/dist/pals/communication/broker.d.ts.map +1 -0
  129. package/dist/pals/communication/broker.js +121 -0
  130. package/dist/pals/communication/broker.js.map +1 -0
  131. package/dist/pals/communication/dispatch.d.ts +4 -0
  132. package/dist/pals/communication/dispatch.d.ts.map +1 -0
  133. package/dist/pals/communication/dispatch.js +57 -0
  134. package/dist/pals/communication/dispatch.js.map +1 -0
  135. package/dist/pals/communication/inbound.d.ts +9 -0
  136. package/dist/pals/communication/inbound.d.ts.map +1 -0
  137. package/dist/pals/communication/inbound.js +155 -0
  138. package/dist/pals/communication/inbound.js.map +1 -0
  139. package/dist/pals/communication/ingress-dispatch.d.ts +5 -0
  140. package/dist/pals/communication/ingress-dispatch.d.ts.map +1 -0
  141. package/dist/pals/communication/ingress-dispatch.js +51 -0
  142. package/dist/pals/communication/ingress-dispatch.js.map +1 -0
  143. package/dist/pals/communication/ingress-inbound.d.ts +9 -0
  144. package/dist/pals/communication/ingress-inbound.d.ts.map +1 -0
  145. package/dist/pals/communication/ingress-inbound.js +222 -0
  146. package/dist/pals/communication/ingress-inbound.js.map +1 -0
  147. package/dist/pals/communication/ingress-schema.d.ts +7829 -0
  148. package/dist/pals/communication/ingress-schema.d.ts.map +1 -0
  149. package/dist/pals/communication/ingress-schema.js +479 -0
  150. package/dist/pals/communication/ingress-schema.js.map +1 -0
  151. package/dist/pals/communication/ingress-types.d.ts +187 -0
  152. package/dist/pals/communication/ingress-types.d.ts.map +1 -0
  153. package/dist/pals/communication/ingress-types.js +73 -0
  154. package/dist/pals/communication/ingress-types.js.map +1 -0
  155. package/dist/pals/communication/operator.d.ts +75 -0
  156. package/dist/pals/communication/operator.d.ts.map +1 -0
  157. package/dist/pals/communication/operator.js +217 -0
  158. package/dist/pals/communication/operator.js.map +1 -0
  159. package/dist/pals/communication/policy.d.ts +41 -0
  160. package/dist/pals/communication/policy.d.ts.map +1 -0
  161. package/dist/pals/communication/policy.js +138 -0
  162. package/dist/pals/communication/policy.js.map +1 -0
  163. package/dist/pals/communication/schema.d.ts +2000 -0
  164. package/dist/pals/communication/schema.d.ts.map +1 -0
  165. package/dist/pals/communication/schema.js +170 -0
  166. package/dist/pals/communication/schema.js.map +1 -0
  167. package/dist/pals/communication/store.d.ts +61 -0
  168. package/dist/pals/communication/store.d.ts.map +1 -0
  169. package/dist/pals/communication/store.js +450 -0
  170. package/dist/pals/communication/store.js.map +1 -0
  171. package/dist/pals/communication/tools.d.ts +23 -0
  172. package/dist/pals/communication/tools.d.ts.map +1 -0
  173. package/dist/pals/communication/tools.js +107 -0
  174. package/dist/pals/communication/tools.js.map +1 -0
  175. package/dist/pals/communication/types.d.ts +168 -0
  176. package/dist/pals/communication/types.d.ts.map +1 -0
  177. package/dist/pals/communication/types.js +24 -0
  178. package/dist/pals/communication/types.js.map +1 -0
  179. package/dist/pals/communication/verify.d.ts +22 -0
  180. package/dist/pals/communication/verify.d.ts.map +1 -0
  181. package/dist/pals/communication/verify.js +142 -0
  182. package/dist/pals/communication/verify.js.map +1 -0
  183. package/dist/pals/lifecycle.d.ts +37 -0
  184. package/dist/pals/lifecycle.d.ts.map +1 -0
  185. package/dist/pals/lifecycle.js +22 -0
  186. package/dist/pals/lifecycle.js.map +1 -0
  187. package/dist/pals/prompt.d.ts +30 -0
  188. package/dist/pals/prompt.d.ts.map +1 -0
  189. package/dist/pals/prompt.js +65 -0
  190. package/dist/pals/prompt.js.map +1 -0
  191. package/dist/pals/reference-images.d.ts +44 -0
  192. package/dist/pals/reference-images.d.ts.map +1 -0
  193. package/dist/pals/reference-images.js +248 -0
  194. package/dist/pals/reference-images.js.map +1 -0
  195. package/dist/pals/runtime.d.ts +46 -0
  196. package/dist/pals/runtime.d.ts.map +1 -0
  197. package/dist/pals/runtime.js +624 -0
  198. package/dist/pals/runtime.js.map +1 -0
  199. package/dist/pals/store.d.ts +26 -0
  200. package/dist/pals/store.d.ts.map +1 -0
  201. package/dist/pals/store.js +334 -0
  202. package/dist/pals/store.js.map +1 -0
  203. package/dist/pals/types.d.ts +145 -0
  204. package/dist/pals/types.d.ts.map +1 -0
  205. package/dist/pals/types.js +2 -0
  206. package/dist/pals/types.js.map +1 -0
  207. package/dist/peers/envelope.js +1 -1
  208. package/dist/peers/envelope.js.map +1 -1
  209. package/dist/peers/protocol.d.ts +83 -83
  210. package/dist/peers/record.d.ts +10 -10
  211. package/dist/plugin/shell-hook.d.ts.map +1 -1
  212. package/dist/plugin/shell-hook.js +7 -2
  213. package/dist/plugin/shell-hook.js.map +1 -1
  214. package/dist/process/kill-tree.d.ts.map +1 -1
  215. package/dist/process/kill-tree.js +9 -1
  216. package/dist/process/kill-tree.js.map +1 -1
  217. package/dist/provider/errors.d.ts +19 -0
  218. package/dist/provider/errors.d.ts.map +1 -1
  219. package/dist/provider/errors.js +123 -2
  220. package/dist/provider/errors.js.map +1 -1
  221. package/dist/public-runtime.d.ts +41 -13
  222. package/dist/public-runtime.d.ts.map +1 -1
  223. package/dist/public-runtime.js +35 -7
  224. package/dist/public-runtime.js.map +1 -1
  225. package/dist/public-tools.d.ts +8 -3
  226. package/dist/public-tools.d.ts.map +1 -1
  227. package/dist/public-tools.js +8 -3
  228. package/dist/public-tools.js.map +1 -1
  229. package/dist/public-types.d.ts +27 -7
  230. package/dist/public-types.d.ts.map +1 -1
  231. package/dist/registry/tool/presentation.d.ts +1 -0
  232. package/dist/registry/tool/presentation.d.ts.map +1 -1
  233. package/dist/registry/tool/presentation.js +9 -7
  234. package/dist/registry/tool/presentation.js.map +1 -1
  235. package/dist/runtime/harness-session/index.d.ts +5 -0
  236. package/dist/runtime/harness-session/index.d.ts.map +1 -0
  237. package/dist/runtime/harness-session/index.js +928 -0
  238. package/dist/runtime/harness-session/index.js.map +1 -0
  239. package/dist/runtime/harness-session/journal.d.ts +37 -0
  240. package/dist/runtime/harness-session/journal.d.ts.map +1 -0
  241. package/dist/runtime/harness-session/journal.js +177 -0
  242. package/dist/runtime/harness-session/journal.js.map +1 -0
  243. package/dist/runtime/harness-session/saved-view.d.ts +8 -0
  244. package/dist/runtime/harness-session/saved-view.d.ts.map +1 -0
  245. package/dist/runtime/harness-session/saved-view.js +112 -0
  246. package/dist/runtime/harness-session/saved-view.js.map +1 -0
  247. package/dist/runtime/jobs/awaited-jobs.d.ts +2 -1
  248. package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
  249. package/dist/runtime/jobs/awaited-jobs.js +2 -1
  250. package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
  251. package/dist/runtime/jobs/registry.d.ts +56 -1
  252. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  253. package/dist/runtime/jobs/registry.js +351 -34
  254. package/dist/runtime/jobs/registry.js.map +1 -1
  255. package/dist/runtime/query/abandon-turn.d.ts +12 -1
  256. package/dist/runtime/query/abandon-turn.d.ts.map +1 -1
  257. package/dist/runtime/query/abandon-turn.js +3 -1
  258. package/dist/runtime/query/abandon-turn.js.map +1 -1
  259. package/dist/runtime/query/checkpoint.d.ts +4 -0
  260. package/dist/runtime/query/checkpoint.d.ts.map +1 -1
  261. package/dist/runtime/query/checkpoint.js +10 -0
  262. package/dist/runtime/query/checkpoint.js.map +1 -1
  263. package/dist/runtime/query/durable-inbound.d.ts +5 -0
  264. package/dist/runtime/query/durable-inbound.d.ts.map +1 -0
  265. package/dist/runtime/query/durable-inbound.js +89 -0
  266. package/dist/runtime/query/durable-inbound.js.map +1 -0
  267. package/dist/runtime/query/events.d.ts +4 -0
  268. package/dist/runtime/query/events.d.ts.map +1 -1
  269. package/dist/runtime/query/events.js +22 -5
  270. package/dist/runtime/query/events.js.map +1 -1
  271. package/dist/runtime/query/executor/tool-call-admission.d.ts +5 -1
  272. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  273. package/dist/runtime/query/executor/tool-call-admission.js +85 -13
  274. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  275. package/dist/runtime/query/executor.d.ts +41 -18
  276. package/dist/runtime/query/executor.d.ts.map +1 -1
  277. package/dist/runtime/query/executor.js +227 -114
  278. package/dist/runtime/query/executor.js.map +1 -1
  279. package/dist/runtime/query/index.d.ts +3 -0
  280. package/dist/runtime/query/index.d.ts.map +1 -1
  281. package/dist/runtime/query/index.js +21 -4
  282. package/dist/runtime/query/index.js.map +1 -1
  283. package/dist/runtime/query/iteration/index.d.ts +18 -6
  284. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  285. package/dist/runtime/query/iteration/index.js +144 -67
  286. package/dist/runtime/query/iteration/index.js.map +1 -1
  287. package/dist/runtime/query/iteration/outstanding-work.d.ts +9 -5
  288. package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
  289. package/dist/runtime/query/iteration/outstanding-work.js +61 -6
  290. package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
  291. package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
  292. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  293. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  294. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  295. package/dist/runtime/query/iteration/phases/tool-review.js +99 -16
  296. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  297. package/dist/runtime/query/observation-context.d.ts +2 -2
  298. package/dist/runtime/query/observation-context.d.ts.map +1 -1
  299. package/dist/runtime/query/observation-context.js +20 -13
  300. package/dist/runtime/query/observation-context.js.map +1 -1
  301. package/dist/runtime/query/prepare-turn.js +2 -2
  302. package/dist/runtime/query/prepare-turn.js.map +1 -1
  303. package/dist/runtime/query/prompt-cache.d.ts +1 -0
  304. package/dist/runtime/query/prompt-cache.d.ts.map +1 -1
  305. package/dist/runtime/query/prompt-cache.js +2 -0
  306. package/dist/runtime/query/prompt-cache.js.map +1 -1
  307. package/dist/runtime/query/prompt.d.ts +2 -0
  308. package/dist/runtime/query/prompt.d.ts.map +1 -1
  309. package/dist/runtime/query/prompt.js +23 -1
  310. package/dist/runtime/query/prompt.js.map +1 -1
  311. package/dist/runtime/query/repeat-call.d.ts +12 -3
  312. package/dist/runtime/query/repeat-call.d.ts.map +1 -1
  313. package/dist/runtime/query/repeat-call.js +33 -10
  314. package/dist/runtime/query/repeat-call.js.map +1 -1
  315. package/dist/runtime/query/resume-pending.d.ts +5 -6
  316. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  317. package/dist/runtime/query/resume-pending.js +30 -3
  318. package/dist/runtime/query/resume-pending.js.map +1 -1
  319. package/dist/runtime/query/resume-session.js +1 -1
  320. package/dist/runtime/query/resume-session.js.map +1 -1
  321. package/dist/runtime/query/review-policy.d.ts +8 -1
  322. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  323. package/dist/runtime/query/review-policy.js +6 -0
  324. package/dist/runtime/query/review-policy.js.map +1 -1
  325. package/dist/runtime/query/saved-presentation.d.ts +13 -0
  326. package/dist/runtime/query/saved-presentation.d.ts.map +1 -0
  327. package/dist/runtime/query/saved-presentation.js +63 -0
  328. package/dist/runtime/query/saved-presentation.js.map +1 -0
  329. package/dist/runtime/query/steering.d.ts +6 -9
  330. package/dist/runtime/query/steering.d.ts.map +1 -1
  331. package/dist/runtime/query/steering.js.map +1 -1
  332. package/dist/runtime/query/tool-executions.d.ts +7 -3
  333. package/dist/runtime/query/tool-executions.d.ts.map +1 -1
  334. package/dist/runtime/query/tool-executions.js +89 -9
  335. package/dist/runtime/query/tool-executions.js.map +1 -1
  336. package/dist/runtime/query/tooling.d.ts +3 -1
  337. package/dist/runtime/query/tooling.d.ts.map +1 -1
  338. package/dist/runtime/query/tooling.js +3 -0
  339. package/dist/runtime/query/tooling.js.map +1 -1
  340. package/dist/scheduler/completion-inbox.d.ts +25 -1
  341. package/dist/scheduler/completion-inbox.d.ts.map +1 -1
  342. package/dist/scheduler/completion-inbox.js +102 -8
  343. package/dist/scheduler/completion-inbox.js.map +1 -1
  344. package/dist/scheduler/delegating.d.ts.map +1 -1
  345. package/dist/scheduler/delegating.js +5 -0
  346. package/dist/scheduler/delegating.js.map +1 -1
  347. package/dist/scheduler/local.d.ts.map +1 -1
  348. package/dist/scheduler/local.js +2 -0
  349. package/dist/scheduler/local.js.map +1 -1
  350. package/dist/session/summary/materialize.d.ts +10 -6
  351. package/dist/session/summary/materialize.d.ts.map +1 -1
  352. package/dist/session/summary/materialize.js +41 -8
  353. package/dist/session/summary/materialize.js.map +1 -1
  354. package/dist/store/budget/ledger.d.ts +9 -0
  355. package/dist/store/budget/ledger.d.ts.map +1 -1
  356. package/dist/store/budget/ledger.js +58 -6
  357. package/dist/store/budget/ledger.js.map +1 -1
  358. package/dist/store/evidence/index-page.d.ts +12 -12
  359. package/dist/store/evidence/source-text.d.ts +4 -4
  360. package/dist/store/session/disk.d.ts +9 -4
  361. package/dist/store/session/disk.d.ts.map +1 -1
  362. package/dist/store/session/disk.js +57 -11
  363. package/dist/store/session/disk.js.map +1 -1
  364. package/dist/store/session/memory.d.ts +5 -3
  365. package/dist/store/session/memory.d.ts.map +1 -1
  366. package/dist/store/session/memory.js +24 -7
  367. package/dist/store/session/memory.js.map +1 -1
  368. package/dist/store/session-log/core.d.ts +26 -6
  369. package/dist/store/session-log/core.d.ts.map +1 -1
  370. package/dist/store/session-log/core.js +61 -8
  371. package/dist/store/session-log/core.js.map +1 -1
  372. package/dist/store/session-log/disk.d.ts +2 -2
  373. package/dist/store/session-log/disk.d.ts.map +1 -1
  374. package/dist/store/session-log/disk.js +1 -0
  375. package/dist/store/session-log/disk.js.map +1 -1
  376. package/dist/store/session-log/fold.d.ts +7 -0
  377. package/dist/store/session-log/fold.d.ts.map +1 -1
  378. package/dist/store/session-log/fold.js +21 -0
  379. package/dist/store/session-log/fold.js.map +1 -1
  380. package/dist/store/session-log/index.d.ts +5 -3
  381. package/dist/store/session-log/index.d.ts.map +1 -1
  382. package/dist/store/session-log/index.js +3 -1
  383. package/dist/store/session-log/index.js.map +1 -1
  384. package/dist/store/session-log/memory.d.ts +1 -1
  385. package/dist/store/session-log/memory.d.ts.map +1 -1
  386. package/dist/store/session-log/memory.js +1 -0
  387. package/dist/store/session-log/memory.js.map +1 -1
  388. package/dist/store/session-log/spill.d.ts +10 -3
  389. package/dist/store/session-log/spill.d.ts.map +1 -1
  390. package/dist/store/session-log/spill.js +70 -5
  391. package/dist/store/session-log/spill.js.map +1 -1
  392. package/dist/store/session-log/structured-result.d.ts +21 -0
  393. package/dist/store/session-log/structured-result.d.ts.map +1 -0
  394. package/dist/store/session-log/structured-result.js +67 -0
  395. package/dist/store/session-log/structured-result.js.map +1 -0
  396. package/dist/store/task/disk.d.ts +11 -0
  397. package/dist/store/task/disk.d.ts.map +1 -1
  398. package/dist/store/task/disk.js +41 -2
  399. package/dist/store/task/disk.js.map +1 -1
  400. package/dist/store/task/memory.d.ts.map +1 -1
  401. package/dist/store/task/memory.js +15 -3
  402. package/dist/store/task/memory.js.map +1 -1
  403. package/dist/tools/admit-facts.d.ts +13 -0
  404. package/dist/tools/admit-facts.d.ts.map +1 -0
  405. package/dist/tools/admit-facts.js +142 -0
  406. package/dist/tools/admit-facts.js.map +1 -0
  407. package/dist/tools/builtins/bash.d.ts +4 -1
  408. package/dist/tools/builtins/bash.d.ts.map +1 -1
  409. package/dist/tools/builtins/bash.js +108 -22
  410. package/dist/tools/builtins/bash.js.map +1 -1
  411. package/dist/tools/builtins/browser.d.ts +10 -10
  412. package/dist/tools/builtins/computer-use.d.ts +90 -90
  413. package/dist/tools/builtins/edit.d.ts +17 -0
  414. package/dist/tools/builtins/edit.d.ts.map +1 -1
  415. package/dist/tools/builtins/edit.js +34 -0
  416. package/dist/tools/builtins/edit.js.map +1 -1
  417. package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
  418. package/dist/tools/builtins/file-write-result.js +13 -0
  419. package/dist/tools/builtins/file-write-result.js.map +1 -1
  420. package/dist/tools/builtins/glob.d.ts.map +1 -1
  421. package/dist/tools/builtins/glob.js +12 -0
  422. package/dist/tools/builtins/glob.js.map +1 -1
  423. package/dist/tools/builtins/grep.d.ts.map +1 -1
  424. package/dist/tools/builtins/grep.js +14 -0
  425. package/dist/tools/builtins/grep.js.map +1 -1
  426. package/dist/tools/builtins/index.d.ts +2 -0
  427. package/dist/tools/builtins/index.d.ts.map +1 -1
  428. package/dist/tools/builtins/index.js +1 -0
  429. package/dist/tools/builtins/index.js.map +1 -1
  430. package/dist/tools/builtins/job.d.ts.map +1 -1
  431. package/dist/tools/builtins/job.js +4 -1
  432. package/dist/tools/builtins/job.js.map +1 -1
  433. package/dist/tools/builtins/lsp.d.ts +2 -2
  434. package/dist/tools/builtins/read-file.d.ts.map +1 -1
  435. package/dist/tools/builtins/read-file.js +49 -0
  436. package/dist/tools/builtins/read-file.js.map +1 -1
  437. package/dist/tools/builtins/view-image.d.ts +24 -0
  438. package/dist/tools/builtins/view-image.d.ts.map +1 -0
  439. package/dist/tools/builtins/view-image.js +385 -0
  440. package/dist/tools/builtins/view-image.js.map +1 -0
  441. package/dist/tools/builtins/wait-for-job-bounds.d.ts +2 -0
  442. package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
  443. package/dist/tools/builtins/wait-for-job-bounds.js +1 -0
  444. package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
  445. package/dist/tools/builtins/wait-for-job.d.ts +2 -0
  446. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  447. package/dist/tools/builtins/wait-for-job.js +104 -6
  448. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  449. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  450. package/dist/tools/builtins/write-file.js +1 -0
  451. package/dist/tools/builtins/write-file.js.map +1 -1
  452. package/dist/tools/command-shell.d.ts +37 -2
  453. package/dist/tools/command-shell.d.ts.map +1 -1
  454. package/dist/tools/command-shell.js +100 -3
  455. package/dist/tools/command-shell.js.map +1 -1
  456. package/dist/tools/coordinator/agent.d.ts +9 -19
  457. package/dist/tools/coordinator/agent.d.ts.map +1 -1
  458. package/dist/tools/coordinator/agent.js.map +1 -1
  459. package/dist/tools/coordinator/index.d.ts.map +1 -1
  460. package/dist/tools/coordinator/index.js +127 -67
  461. package/dist/tools/coordinator/index.js.map +1 -1
  462. package/dist/tools/coordinator/wait-with-idle-bound.d.ts +2 -0
  463. package/dist/tools/coordinator/wait-with-idle-bound.d.ts.map +1 -1
  464. package/dist/tools/coordinator/wait-with-idle-bound.js +1 -1
  465. package/dist/tools/coordinator/wait-with-idle-bound.js.map +1 -1
  466. package/dist/tools/defineTool.d.ts.map +1 -1
  467. package/dist/tools/defineTool.js +4 -0
  468. package/dist/tools/defineTool.js.map +1 -1
  469. package/dist/tools/failure-facts.d.ts +8 -0
  470. package/dist/tools/failure-facts.d.ts.map +1 -0
  471. package/dist/tools/failure-facts.js +24 -0
  472. package/dist/tools/failure-facts.js.map +1 -0
  473. package/dist/tools/host-output.d.ts +24 -0
  474. package/dist/tools/host-output.d.ts.map +1 -0
  475. package/dist/tools/host-output.js +117 -0
  476. package/dist/tools/host-output.js.map +1 -0
  477. package/dist/tools/oem-code-pages.d.ts +8 -0
  478. package/dist/tools/oem-code-pages.d.ts.map +1 -0
  479. package/dist/tools/oem-code-pages.js +23 -0
  480. package/dist/tools/oem-code-pages.js.map +1 -0
  481. package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
  482. package/dist/tools/schedules/schedule-tool.js +35 -6
  483. package/dist/tools/schedules/schedule-tool.js.map +1 -1
  484. package/dist/tools/schedules/types.d.ts +23 -3
  485. package/dist/tools/schedules/types.d.ts.map +1 -1
  486. package/dist/tools/task/list.d.ts.map +1 -1
  487. package/dist/tools/task/list.js +14 -6
  488. package/dist/tools/task/list.js.map +1 -1
  489. package/dist/tools/task/present.d.ts.map +1 -1
  490. package/dist/tools/task/present.js +26 -6
  491. package/dist/tools/task/present.js.map +1 -1
  492. package/dist/tools/task/update.d.ts.map +1 -1
  493. package/dist/tools/task/update.js +12 -5
  494. package/dist/tools/task/update.js.map +1 -1
  495. package/dist/tools/text-window.d.ts +19 -0
  496. package/dist/tools/text-window.d.ts.map +1 -0
  497. package/dist/tools/text-window.js +83 -0
  498. package/dist/tools/text-window.js.map +1 -0
  499. package/dist/toolsets/manager.d.ts +11 -0
  500. package/dist/toolsets/manager.d.ts.map +1 -1
  501. package/dist/toolsets/manager.js +45 -1
  502. package/dist/toolsets/manager.js.map +1 -1
  503. package/dist/types/acp/index.d.ts +137 -1
  504. package/dist/types/acp/index.d.ts.map +1 -1
  505. package/dist/types/agent/base.d.ts +3 -0
  506. package/dist/types/agent/base.d.ts.map +1 -1
  507. package/dist/types/agent/manager.d.ts +8 -23
  508. package/dist/types/agent/manager.d.ts.map +1 -1
  509. package/dist/types/agent/scheduler.d.ts +10 -1
  510. package/dist/types/agent/scheduler.d.ts.map +1 -1
  511. package/dist/types/agent/task.d.ts +4 -0
  512. package/dist/types/agent/task.d.ts.map +1 -1
  513. package/dist/types/authorization/index.d.ts +30 -30
  514. package/dist/types/connector/mcp.d.ts +7 -0
  515. package/dist/types/connector/mcp.d.ts.map +1 -1
  516. package/dist/types/errors/catalog.d.ts.map +1 -1
  517. package/dist/types/errors/catalog.js +4 -2
  518. package/dist/types/errors/catalog.js.map +1 -1
  519. package/dist/types/harness/schema.d.ts +354 -0
  520. package/dist/types/harness/schema.d.ts.map +1 -0
  521. package/dist/types/harness/schema.js +203 -0
  522. package/dist/types/harness/schema.js.map +1 -0
  523. package/dist/types/harness/session.d.ts +278 -0
  524. package/dist/types/harness/session.d.ts.map +1 -0
  525. package/dist/types/harness/session.js +2 -0
  526. package/dist/types/harness/session.js.map +1 -0
  527. package/dist/types/hitl/index.d.ts +12 -0
  528. package/dist/types/hitl/index.d.ts.map +1 -1
  529. package/dist/types/hitl/index.js.map +1 -1
  530. package/dist/types/job/index.d.ts +47 -0
  531. package/dist/types/job/index.d.ts.map +1 -0
  532. package/dist/types/job/index.js +2 -0
  533. package/dist/types/job/index.js.map +1 -0
  534. package/dist/types/message/inbound-delivery.d.ts +44 -0
  535. package/dist/types/message/inbound-delivery.d.ts.map +1 -0
  536. package/dist/types/message/inbound-delivery.js +14 -0
  537. package/dist/types/message/inbound-delivery.js.map +1 -0
  538. package/dist/types/message/index.d.ts +4 -1
  539. package/dist/types/message/index.d.ts.map +1 -1
  540. package/dist/types/message/index.js +5 -1
  541. package/dist/types/message/index.js.map +1 -1
  542. package/dist/types/plugin/index.d.ts +6 -6
  543. package/dist/types/sandbox/index.d.ts +39 -2
  544. package/dist/types/sandbox/index.d.ts.map +1 -1
  545. package/dist/types/sandbox/index.js.map +1 -1
  546. package/dist/types/session/checkpoint.d.ts +24 -17
  547. package/dist/types/session/checkpoint.d.ts.map +1 -1
  548. package/dist/types/session/checkpoint.js +1 -0
  549. package/dist/types/session/checkpoint.js.map +1 -1
  550. package/dist/types/session/events.d.ts +23 -1
  551. package/dist/types/session/events.d.ts.map +1 -1
  552. package/dist/types/session/events.js.map +1 -1
  553. package/dist/types/session/records.d.ts +1514 -565
  554. package/dist/types/session/records.d.ts.map +1 -1
  555. package/dist/types/session/records.js +89 -1
  556. package/dist/types/session/records.js.map +1 -1
  557. package/dist/types/session/step.d.ts +2 -0
  558. package/dist/types/session/step.d.ts.map +1 -1
  559. package/dist/types/session/step.js.map +1 -1
  560. package/dist/types/session/store.d.ts +19 -10
  561. package/dist/types/session/store.d.ts.map +1 -1
  562. package/dist/types/session/tool-execution.d.ts +6 -0
  563. package/dist/types/session/tool-execution.d.ts.map +1 -1
  564. package/dist/types/structured-output/index.d.ts +12 -2
  565. package/dist/types/structured-output/index.d.ts.map +1 -1
  566. package/dist/types/summary/ref.d.ts +3 -1
  567. package/dist/types/summary/ref.d.ts.map +1 -1
  568. package/dist/types/tool/index.d.ts +32 -4
  569. package/dist/types/tool/index.d.ts.map +1 -1
  570. package/dist/types/tool/index.js.map +1 -1
  571. package/dist/types/tool/presentation.d.ts +106 -0
  572. package/dist/types/tool/presentation.d.ts.map +1 -1
  573. package/dist/utils/json-snapshot.d.ts +6 -2
  574. package/dist/utils/json-snapshot.d.ts.map +1 -1
  575. package/dist/utils/json-snapshot.js +19 -9
  576. package/dist/utils/json-snapshot.js.map +1 -1
  577. package/dist/utils/structured-result-json.d.ts +5 -0
  578. package/dist/utils/structured-result-json.d.ts.map +1 -0
  579. package/dist/utils/structured-result-json.js +10 -0
  580. package/dist/utils/structured-result-json.js.map +1 -0
  581. package/package.json +1 -1
  582. package/src/agents/QueryAgent.ts +1 -0
  583. package/src/agents/examples/SupervisorAgent.ts +1 -0
  584. package/src/agents/runAgent.ts +3 -0
  585. package/src/authorization/shell-lexer.ts +16 -1
  586. package/src/bridge/acp/permission.ts +17 -3
  587. package/src/bridge/acp/server.ts +271 -25
  588. package/src/bridge/acp/tasks.ts +23 -0
  589. package/src/bridge/acp/update.ts +167 -13
  590. package/src/connector/mcp/adapter.ts +16 -4
  591. package/src/connector/mcp/client.ts +6 -2
  592. package/src/constants/acp/index.ts +4 -0
  593. package/src/manager/agent/lifecycle.ts +230 -3
  594. package/src/manager/plan/lifecycle.ts +11 -9
  595. package/src/manager/session/attribution.ts +12 -2
  596. package/src/manager/session/streamed-message-identity.ts +21 -0
  597. package/src/manager/session/turn-recorder.ts +4 -3
  598. package/src/pals/activity/causality.ts +261 -0
  599. package/src/pals/activity/projection.ts +89 -0
  600. package/src/pals/activity/source.ts +240 -0
  601. package/src/pals/activity/subscription-policy.ts +230 -0
  602. package/src/pals/activity/subscription-schema.ts +27 -0
  603. package/src/pals/activity/subscription-store.ts +172 -0
  604. package/src/pals/activity/subscription-types.ts +48 -0
  605. package/src/pals/activity/subscriptions.ts +209 -0
  606. package/src/pals/activity/types.ts +108 -0
  607. package/src/pals/channels/ingress.ts +153 -0
  608. package/src/pals/channels/routes.ts +118 -0
  609. package/src/pals/channels/routing.ts +197 -0
  610. package/src/pals/channels/schema.ts +108 -0
  611. package/src/pals/channels/types.ts +156 -0
  612. package/src/pals/communication/broker.ts +131 -0
  613. package/src/pals/communication/dispatch.ts +66 -0
  614. package/src/pals/communication/inbound.ts +193 -0
  615. package/src/pals/communication/ingress-dispatch.ts +63 -0
  616. package/src/pals/communication/ingress-inbound.ts +269 -0
  617. package/src/pals/communication/ingress-schema.ts +526 -0
  618. package/src/pals/communication/ingress-types.ts +336 -0
  619. package/src/pals/communication/operator.ts +315 -0
  620. package/src/pals/communication/policy.ts +174 -0
  621. package/src/pals/communication/schema.ts +173 -0
  622. package/src/pals/communication/store.ts +577 -0
  623. package/src/pals/communication/tools.ts +139 -0
  624. package/src/pals/communication/types.ts +227 -0
  625. package/src/pals/communication/verify.ts +220 -0
  626. package/src/pals/lifecycle.ts +54 -0
  627. package/src/pals/prompt.ts +101 -0
  628. package/src/pals/reference-images.ts +322 -0
  629. package/src/pals/runtime.ts +670 -0
  630. package/src/pals/store.ts +369 -0
  631. package/src/pals/types.ts +157 -0
  632. package/src/peers/envelope.ts +1 -1
  633. package/src/plugin/shell-hook.ts +8 -2
  634. package/src/process/kill-tree.ts +10 -1
  635. package/src/provider/errors.ts +135 -2
  636. package/src/public-runtime.ts +117 -12
  637. package/src/public-tools.ts +13 -1
  638. package/src/public-types.ts +69 -7
  639. package/src/registry/tool/presentation.ts +9 -4
  640. package/src/runtime/harness-session/index.ts +1125 -0
  641. package/src/runtime/harness-session/journal.ts +209 -0
  642. package/src/runtime/harness-session/saved-view.ts +122 -0
  643. package/src/runtime/jobs/awaited-jobs.ts +2 -1
  644. package/src/runtime/jobs/registry.ts +397 -41
  645. package/src/runtime/query/abandon-turn.ts +18 -2
  646. package/src/runtime/query/checkpoint.ts +11 -0
  647. package/src/runtime/query/durable-inbound.ts +101 -0
  648. package/src/runtime/query/events.ts +22 -5
  649. package/src/runtime/query/executor/tool-call-admission.ts +125 -32
  650. package/src/runtime/query/executor.ts +316 -130
  651. package/src/runtime/query/index.ts +24 -4
  652. package/src/runtime/query/iteration/index.ts +218 -104
  653. package/src/runtime/query/iteration/outstanding-work.ts +55 -7
  654. package/src/runtime/query/iteration/phases/context.ts +4 -0
  655. package/src/runtime/query/iteration/phases/tool-review.ts +118 -21
  656. package/src/runtime/query/observation-context.ts +22 -16
  657. package/src/runtime/query/prepare-turn.ts +2 -2
  658. package/src/runtime/query/prompt-cache.ts +3 -0
  659. package/src/runtime/query/prompt.ts +32 -1
  660. package/src/runtime/query/repeat-call.ts +40 -10
  661. package/src/runtime/query/resume-pending.ts +60 -7
  662. package/src/runtime/query/resume-session.ts +1 -1
  663. package/src/runtime/query/review-policy.ts +23 -2
  664. package/src/runtime/query/saved-presentation.ts +70 -0
  665. package/src/runtime/query/steering.ts +6 -9
  666. package/src/runtime/query/tool-executions.ts +108 -9
  667. package/src/runtime/query/tooling.ts +6 -1
  668. package/src/scheduler/completion-inbox.ts +108 -7
  669. package/src/scheduler/delegating.ts +5 -0
  670. package/src/scheduler/local.ts +2 -0
  671. package/src/session/summary/materialize.ts +51 -9
  672. package/src/store/budget/ledger.ts +60 -5
  673. package/src/store/session/disk.ts +77 -10
  674. package/src/store/session/memory.ts +32 -7
  675. package/src/store/session-log/core.ts +118 -11
  676. package/src/store/session-log/disk.ts +9 -2
  677. package/src/store/session-log/fold.ts +22 -0
  678. package/src/store/session-log/index.ts +5 -0
  679. package/src/store/session-log/memory.ts +2 -1
  680. package/src/store/session-log/spill.ts +89 -6
  681. package/src/store/session-log/structured-result.ts +96 -0
  682. package/src/store/task/disk.ts +46 -2
  683. package/src/store/task/memory.ts +13 -3
  684. package/src/tools/admit-facts.ts +145 -0
  685. package/src/tools/builtins/bash.ts +132 -24
  686. package/src/tools/builtins/edit.ts +42 -0
  687. package/src/tools/builtins/file-write-result.ts +14 -0
  688. package/src/tools/builtins/glob.ts +12 -0
  689. package/src/tools/builtins/grep.ts +14 -0
  690. package/src/tools/builtins/index.ts +2 -0
  691. package/src/tools/builtins/job.ts +4 -1
  692. package/src/tools/builtins/read-file.ts +57 -0
  693. package/src/tools/builtins/view-image.ts +409 -0
  694. package/src/tools/builtins/wait-for-job-bounds.ts +3 -0
  695. package/src/tools/builtins/wait-for-job.ts +141 -32
  696. package/src/tools/builtins/write-file.ts +4 -2
  697. package/src/tools/command-shell.ts +132 -5
  698. package/src/tools/coordinator/agent.ts +9 -19
  699. package/src/tools/coordinator/index.ts +150 -75
  700. package/src/tools/coordinator/wait-with-idle-bound.ts +3 -1
  701. package/src/tools/defineTool.ts +4 -0
  702. package/src/tools/failure-facts.ts +24 -0
  703. package/src/tools/host-output.ts +136 -0
  704. package/src/tools/oem-code-pages.ts +22 -0
  705. package/src/tools/schedules/schedule-tool.ts +38 -5
  706. package/src/tools/schedules/types.ts +23 -3
  707. package/src/tools/task/list.ts +15 -7
  708. package/src/tools/task/present.ts +37 -7
  709. package/src/tools/task/update.ts +12 -5
  710. package/src/tools/text-window.ts +87 -0
  711. package/src/toolsets/manager.ts +58 -1
  712. package/src/types/acp/index.ts +150 -4
  713. package/src/types/agent/base.ts +3 -0
  714. package/src/types/agent/manager.ts +8 -23
  715. package/src/types/agent/scheduler.ts +10 -1
  716. package/src/types/agent/task.ts +4 -0
  717. package/src/types/connector/mcp.ts +7 -0
  718. package/src/types/errors/catalog.ts +4 -2
  719. package/src/types/harness/schema.ts +203 -0
  720. package/src/types/harness/session.ts +306 -0
  721. package/src/types/hitl/index.ts +17 -1
  722. package/src/types/job/index.ts +42 -0
  723. package/src/types/message/inbound-delivery.ts +63 -0
  724. package/src/types/message/index.ts +8 -1
  725. package/src/types/sandbox/index.ts +46 -0
  726. package/src/types/session/checkpoint.ts +4 -1
  727. package/src/types/session/events.ts +23 -1
  728. package/src/types/session/records.ts +114 -2
  729. package/src/types/session/step.ts +2 -0
  730. package/src/types/session/store.ts +23 -9
  731. package/src/types/session/tool-execution.ts +6 -0
  732. package/src/types/structured-output/index.ts +13 -2
  733. package/src/types/summary/ref.ts +3 -1
  734. package/src/types/tool/index.ts +39 -5
  735. package/src/types/tool/presentation.ts +121 -0
  736. package/src/utils/json-snapshot.ts +26 -9
  737. package/src/utils/structured-result-json.ts +10 -0
@@ -54,6 +54,12 @@ const inputSchema = z.object({
54
54
  body: z.string().min(1).describe('The exact script text, run verbatim once confirmed'),
55
55
  shell: z.enum(['bash', 'sh']).describe('Which shell reads it; no default'),
56
56
  timeoutMs: z.number().int().positive().optional().describe('The script’s own wall clock'),
57
+ report: z
58
+ .literal('json-v1')
59
+ .optional()
60
+ .describe(
61
+ 'Pure script only: stdout must be exactly one JSON object line, {"v":1,"state":"quiet"} or {"v":1,"state":"changed","summary":"..."}, with optional nextState. Quiet runs report no result; changed runs deliver the summary. The scheduler owns nextState. Omit for ordinary stdout.',
62
+ ),
57
63
  })
58
64
  .optional()
59
65
  .describe(
@@ -75,7 +81,13 @@ const inputSchema = z.object({
75
81
  .string()
76
82
  .optional()
77
83
  .describe(
78
- "create: existing working directory for the job; leave unset for the session's folder when valid. The file system root, the operator's home directory, NAMZU_HOME and a folder containing NAMZU_HOME are refused. If this session is in one of those, choose an existing project subfolder and set folder explicitly",
84
+ "create/update: existing project directory for the job; leave unset to use this session's project folder. Root, the operator's home directory, NAMZU_HOME and a folder containing NAMZU_HOME are refused. For a project-free pure script use workspace: 'none' and omit folder; do not make a visible folder merely to satisfy validation",
85
+ ),
86
+ workspace: z
87
+ .literal('none')
88
+ .optional()
89
+ .describe(
90
+ 'create/update: pure script only. Run in a private scheduler workspace with no project; omit folder. The script still runs as your user on this machine, so this is not a sandbox or a write boundary.',
79
91
  ),
80
92
  tz: z
81
93
  .string()
@@ -143,10 +155,10 @@ const inputSchema = z.object({
143
155
  tokenBudget: z
144
156
  .number()
145
157
  .int()
146
- .positive()
158
+ .nonnegative()
147
159
  .optional()
148
160
  .describe(
149
- 'Tokens one run may spend in total. Every model call resends the whole prompt (often 10,000-30,000 tokens each), so a run needs far more than its answer; omit for the default.',
161
+ 'Tokens one run may spend in total; 0 means no token limit. Every model call resends the whole prompt (often 10,000-30,000 tokens each), so a finite budget needs far more than its answer; omit to inherit the host default.',
150
162
  ),
151
163
  timeoutMs: z
152
164
  .number()
@@ -299,6 +311,12 @@ async function create(
299
311
  if (runKind === 'agent' && input.script !== undefined) {
300
312
  return refuse('an agent job has no script; omit kind (or set it to agent) to use one')
301
313
  }
314
+ if (input.workspace === 'none' && runKind !== 'script')
315
+ return refuse("workspace: 'none' is only for a pure script job")
316
+ if (input.workspace === 'none' && input.folder !== undefined)
317
+ return refuse("workspace: 'none' cannot be combined with folder; omit folder")
318
+ if (input.script?.report !== undefined && runKind !== 'script')
319
+ return refuse('script.report is only for a pure script job')
302
320
  if (runKind === 'script' && input.prompt !== undefined)
303
321
  return refuse('a pure script job has no prompt; remove prompt')
304
322
  if (runKind === 'script' && input.budget !== undefined) {
@@ -318,6 +336,7 @@ async function create(
318
336
  ...(input.script ? { script: input.script } : {}),
319
337
  ...(input.prompt !== undefined ? { prompt: input.prompt } : {}),
320
338
  ...(input.folder !== undefined ? { folder: input.folder } : {}),
339
+ ...(input.workspace !== undefined ? { workspace: input.workspace } : {}),
321
340
  ...(input.tz !== undefined ? { tz: input.tz } : {}),
322
341
  ...(input.notifyOnFinish !== undefined ? { notifyOnFinish: input.notifyOnFinish } : {}),
323
342
  permissions,
@@ -389,6 +408,7 @@ const CHANGEABLE = [
389
408
  'prompt',
390
409
  'when',
391
410
  'folder',
411
+ 'workspace',
392
412
  'tz',
393
413
  'notifyOnFinish',
394
414
  'permissions',
@@ -422,6 +442,12 @@ async function update(
422
442
  'update cannot set kind to agent while also giving a script; drop script to make it an agent job, or leave kind unset (or as script/script+agent) to keep one.',
423
443
  )
424
444
  }
445
+ if (input.workspace === 'none' && input.folder !== undefined)
446
+ return refuse("workspace: 'none' cannot be combined with folder; omit folder")
447
+ if (input.workspace === 'none' && input.kind !== undefined && input.kind !== 'script')
448
+ return refuse("workspace: 'none' is only for a pure script job")
449
+ if (input.script?.report !== undefined && input.kind !== undefined && input.kind !== 'script')
450
+ return refuse('script.report is only for a pure script job')
425
451
  let permissions: ScheduleJobDraft['permissions'] | undefined
426
452
  if (input.permissions) {
427
453
  const checked = checkPermissions(host, input.permissions)
@@ -448,6 +474,7 @@ async function update(
448
474
  ...(input.prompt !== undefined ? { prompt: input.prompt } : {}),
449
475
  ...(input.when !== undefined ? { when: input.when } : {}),
450
476
  ...(input.folder !== undefined ? { folder: input.folder } : {}),
477
+ ...(input.workspace !== undefined ? { workspace: input.workspace } : {}),
451
478
  ...(input.tz !== undefined ? { tz: input.tz } : {}),
452
479
  ...(input.notifyOnFinish !== undefined ? { notifyOnFinish: input.notifyOnFinish } : {}),
453
480
  ...(permissions ? { permissions } : {}),
@@ -532,7 +559,13 @@ async function lifecycle(
532
559
  }
533
560
  if (action === 'pause') await host.pause(job.name)
534
561
  else if (action === 'resume') await host.resume(job.name)
535
- else await host.delete(job.name)
562
+ else {
563
+ try {
564
+ await host.delete(job.name)
565
+ } catch (error) {
566
+ return refuse(error instanceof Error ? error.message : String(error))
567
+ }
568
+ }
536
569
  const verb = action === 'pause' ? 'paused' : action === 'resume' ? 'resumed' : 'deleted'
537
570
  return { success: true, output: `Job "${job.name}" ${verb}.`, data: { name: job.name, action } }
538
571
  }
@@ -554,7 +587,7 @@ export function buildScheduleTools(host: ScheduleToolHost): ToolDefinition[] {
554
587
  defineTool({
555
588
  name: SCHEDULE_TOOL_NAME,
556
589
  description:
557
- "Manage the operator's scheduled jobs: model prompts or fixed scripts that run later in a folder, with nobody watching, under an explicit permission set. Use it only when the user asks for something to happen on a schedule. create, update, resume and delete are confirmed by the operator; pause is not. A job needs name, when and permissions (unmatched: park or deny, plus a preset, rules or a browser grant). agent and script+agent also need prompt; script and script+agent also need script. For a pure script, use permissions {rules:{},unmatched:'deny'} without a preset unless you intend deny rules: read-only denies bash and blocks every script. A pure script has no prompt, model, agent budget, browser grant or session; set script.timeoutMs to limit it. To change a job, update it with job and only the fields that change; do not delete and recreate it. Leave folder unset when the session folder is valid; home, root and NAMZU_HOME are invalid, so choose an existing project subfolder there. Leave tz, execution, budget and headed unset unless the user asked for them: the defaults are the operator's, and the confirmation marks each value you chose. Scheduled runs cannot ask questions.",
590
+ "Manage durable jobs that run later, including while Namzu is closed when its scheduler is installed. For repetition in this open conversation while the TUI is open, use session_loop (/loop); a loop is not a background service. Use schedule only when the user asks for durable scheduled work. create, update, resume and delete ask the operator; pause does not. A job needs name, when and explicit permissions. agent and script+agent need prompt; script and script+agent need script. For a pure script, use permissions {rules:{},unmatched:'deny'} without a preset unless you intend deny rules: read-only denies bash and blocks every script. A pure script has no prompt, model, agent budget, browser grant or run session; set script.timeoutMs to limit it. A pure script may opt into script.report:'json-v1': one JSON stdout line says quiet or changed with a summary and optional scheduler-owned nextState. For a project-free pure script set workspace:'none' and omit folder; its private scheduler workspace is not a sandbox, and its shell still has host authority. For project work, use the actual existing project folder; home, root and NAMZU_HOME are invalid. Do not create a visible folder merely to satisfy validation. The requesting conversation can receive important results separately from the run workspace. To change a job, update it with job and only the fields that change; do not delete and recreate it. Leave tz, execution, budget and headed unset unless requested: defaults are the operator's. Scheduled runs cannot ask questions.",
558
591
  inputSchema,
559
592
  category: 'custom',
560
593
  permissions: [],
@@ -33,11 +33,15 @@ export interface ScheduleJobDraft {
33
33
  readonly body: string
34
34
  readonly shell: 'bash' | 'sh'
35
35
  readonly timeoutMs?: number
36
+ /** Pure scripts only: one JSON v1 report line on stdout per run. */
37
+ readonly report?: 'json-v1'
36
38
  }
37
39
  /** Schedule words: `every 30m`, `0 9 * * 1-5`, `at 09:00`, `in 2h`. */
38
40
  readonly when: string
39
- /** Folder the job runs in. Absent: the session's working directory. */
41
+ /** Project folder the job runs in. Absent: the session's folder, unless `workspace` is `'none'`. */
40
42
  readonly folder?: string
43
+ /** A private scheduler workspace for a pure script; omit `folder` when set. */
44
+ readonly workspace?: 'none'
41
45
  /** IANA zone for a cron expression or a local time. Absent: the host's. */
42
46
  readonly tz?: string
43
47
  /** Enable routine completion notices. Absent: the host's usual setting. */
@@ -65,6 +69,7 @@ export interface ScheduleJobDraft {
65
69
  }
66
70
  readonly budget?: {
67
71
  readonly maxIterations?: number
72
+ /** Total model tokens per agent phase; zero means no token limit. Omit to inherit the host default. */
68
73
  readonly tokenBudget?: number
69
74
  readonly timeoutMs?: number
70
75
  }
@@ -95,8 +100,18 @@ export interface ScheduleBrowserGrant {
95
100
  /** What the person confirming is shown. Every field is the host's own computation. */
96
101
  export interface ScheduleJobPreview {
97
102
  readonly name: string
98
- /** The canonical folder the job would run in. */
103
+ /** The canonical working directory, including the private planned path for `workspace: 'none'`. */
99
104
  readonly folder: string
105
+ /** The private scheduler workspace is used instead of a project folder. */
106
+ readonly workspace?: 'none'
107
+ /** Host-bound source conversation that receives results; absent for older hosts. */
108
+ readonly delivery?: {
109
+ readonly kind: 'source-conversation'
110
+ readonly sessionId: string
111
+ readonly projectSlug: string
112
+ readonly projectId: string
113
+ readonly tenantId: string
114
+ }
100
115
  /** True when `folder` is outside the session's working directory and added directories. */
101
116
  readonly outsideSessionRoots: boolean
102
117
  /** Empty for a pure `'script'` job, whose prompt is unused. */
@@ -108,6 +123,7 @@ export interface ScheduleJobPreview {
108
123
  readonly body: string
109
124
  readonly shell: 'bash' | 'sh'
110
125
  readonly timeoutMs: number
126
+ readonly report?: 'json-v1'
111
127
  }
112
128
  /** The schedule in words, with its zone. */
113
129
  readonly schedule: string
@@ -126,10 +142,11 @@ export interface ScheduleJobPreview {
126
142
  /** Effective run limits. A pure script has zero model iterations/tokens and its script timeout. */
127
143
  readonly budget: {
128
144
  readonly maxIterations: number
145
+ /** Zero means no token limit for an agent phase, or no model use for a pure script. */
129
146
  readonly tokenBudget: number
130
147
  readonly timeoutMs: number
131
148
  }
132
- /** Runs per day at most, times the token budget. Absent for a one-shot. */
149
+ /** Runs per day at most, times a finite token budget. Absent for a one-shot, an unlimited agent phase, or a pure script. */
133
150
  readonly dailyTokenCeiling?: number
134
151
  /** Provider and model the agent phase is pinned to. Absent for a pure script job. */
135
152
  readonly model?: string
@@ -142,6 +159,7 @@ export interface ScheduleJobPreview {
142
159
  /** A job as the `list` action reports it. */
143
160
  export interface ScheduleJobSummary {
144
161
  readonly name: string
162
+ /** Canonical project path, or a host-provided label for a private workspace. */
145
163
  readonly folder: string
146
164
  readonly state: string
147
165
  readonly schedule: string
@@ -167,6 +185,8 @@ export interface ScheduleJobChanges {
167
185
  readonly prompt?: string
168
186
  readonly when?: string
169
187
  readonly folder?: string
188
+ /** Switch a pure script to a private scheduler workspace; omit `folder` when set. */
189
+ readonly workspace?: 'none'
170
190
  readonly tz?: string
171
191
  /** Whether routine Namzu desktop completion notices are enabled. */
172
192
  readonly notifyOnFinish?: boolean
@@ -13,7 +13,7 @@ export function buildTaskListTool(
13
13
  return defineTool({
14
14
  name: 'task_list',
15
15
  description:
16
- 'List planning items for this session: every open one, and those closed during the current turn. Not delegated agent invocations. Use agent_task_list, when available, to inspect agent execution. Shows subject, status, owner, and unresolved blockers. Use this to review your plan and decide what to work on next.',
16
+ 'List planning items for this session: every open one, and those closed during the current turn. Earlier completed or failed items remain stored but are omitted; returned tasks and stats count only this current-turn view, not the full stored history. Not delegated agent invocations. Use agent_task_list, when available, to inspect agent execution. Shows subject, status, owner, and unresolved blockers. Use this to review your plan and decide what to work on next.',
17
17
  inputSchema: z.object({}),
18
18
  category: 'custom',
19
19
  permissions: [],
@@ -26,13 +26,13 @@ export function buildTaskListTool(
26
26
  const all = await taskStore.list({ sessionId: scope.sessionId })
27
27
  // Blockers resolve against every task of the session, shown or not: a
28
28
  // blocker closed in an earlier turn is resolved, not unknown.
29
- const completedIds = new Set(
29
+ const terminalIds = new Set(
30
30
  all.filter((t) => isTerminalTaskStatus(t.status)).map((t) => t.id),
31
31
  )
32
32
  const tasks = selectTaskContext(all, scope)
33
33
 
34
34
  const summary = tasks.map((task) => {
35
- const unresolvedBlockers = task.blockedBy.filter((bid) => !completedIds.has(bid))
35
+ const unresolvedBlockers = task.blockedBy.filter((bid) => !terminalIds.has(bid))
36
36
 
37
37
  return {
38
38
  id: task.id,
@@ -49,14 +49,22 @@ export function buildTaskListTool(
49
49
  pending: tasks.filter((t) => t.status === 'pending').length,
50
50
  in_progress: tasks.filter((t) => t.status === 'in_progress').length,
51
51
  completed: tasks.filter((t) => t.status === 'completed').length,
52
+ failed: tasks.filter((t) => t.status === 'failed').length,
52
53
  }
54
+ const omitted = all.length - tasks.length
55
+ const history = omitted
56
+ ? ` ${countTasks(omitted)} closed in earlier turns ${omitted === 1 ? 'remains' : 'remain'} stored and ${omitted === 1 ? 'is' : 'are'} omitted from this view.`
57
+ : ''
58
+ const output =
59
+ all.length === 0
60
+ ? 'No planning tasks found for this session. This list does not report delegated agent status; use agent_task_list when available.'
61
+ : tasks.length === 0
62
+ ? `No open or current-turn planning tasks.${history}`
63
+ : `Current-turn view: ${countTasks(stats.total)}: ${stats.completed} completed, ${stats.in_progress} in progress, ${stats.pending} pending${stats.failed ? `, ${stats.failed} failed` : ''}.${history}`
53
64
 
54
65
  return {
55
66
  success: true,
56
- output:
57
- tasks.length === 0
58
- ? 'No planning tasks yet. This list does not report delegated agent status; use agent_task_list when available.'
59
- : `${countTasks(stats.total)}: ${stats.completed} completed, ${stats.in_progress} in progress, ${stats.pending} pending.`,
67
+ output,
60
68
  data: { tasks: summary, stats },
61
69
  }
62
70
  },
@@ -28,7 +28,11 @@ function activity(label: string): ToolCallView {
28
28
  }
29
29
 
30
30
  /** A successful receipt: the call row already said it. */
31
- const HIDDEN_RESULT: ToolResultView = { kind: 'generic', label: '', visibility: 'hidden' }
31
+ const HIDDEN_RESULT: ToolResultView = {
32
+ kind: 'generic',
33
+ label: '',
34
+ visibility: 'hidden',
35
+ }
32
36
 
33
37
  /** `N task` / `N tasks`. */
34
38
  export function countTasks(count: number): string {
@@ -44,7 +48,9 @@ function failure(result: ToolResult, fallback: string): ToolResultView {
44
48
  }
45
49
  }
46
50
 
47
- export function presentTaskCreateCall(input: { readonly subject?: unknown }): ToolCallView {
51
+ export function presentTaskCreateCall(input: {
52
+ readonly subject?: unknown
53
+ }): ToolCallView {
48
54
  const subject = typeof input.subject === 'string' ? oneLine(input.subject) : ''
49
55
  return activity(subject ? `Add task · ${subject}` : 'Add task')
50
56
  }
@@ -61,10 +67,12 @@ export function taskUpdateVerb(status: unknown): string {
61
67
  return 'Start task'
62
68
  case 'completed':
63
69
  return 'Complete task'
70
+ case 'failed':
71
+ return 'Fail task'
64
72
  case 'deleted':
65
73
  return 'Remove task'
66
74
  case 'pending':
67
- return 'Reopen task'
75
+ return 'Set task pending'
68
76
  default:
69
77
  return 'Update task'
70
78
  }
@@ -80,7 +88,22 @@ export function presentTaskUpdateCall(input: {
80
88
  }
81
89
 
82
90
  export function presentTaskUpdateResult(_input: unknown, result: ToolResult): ToolResultView {
83
- if (!result.success) return failure(result, 'The task was not changed')
91
+ if (!result.success) {
92
+ const data = result.data as { status?: unknown; requestedStatus?: unknown } | undefined
93
+ if (
94
+ typeof data?.requestedStatus === 'string' &&
95
+ data.requestedStatus !== data.status &&
96
+ (data.status === 'pending' ||
97
+ data.status === 'in_progress' ||
98
+ data.status === 'completed' ||
99
+ data.status === 'failed')
100
+ )
101
+ return {
102
+ kind: 'generic',
103
+ label: `Task remains ${data.status.replace('_', ' ')}; other edits may have applied`,
104
+ }
105
+ return failure(result, 'The task was not changed')
106
+ }
84
107
  return HIDDEN_RESULT
85
108
  }
86
109
 
@@ -90,13 +113,20 @@ export function presentTaskListCall(): ToolCallView {
90
113
 
91
114
  export function presentTaskListResult(_input: unknown, result: ToolResult): ToolResultView {
92
115
  if (!result.success) return { kind: 'generic', label: 'The task list could not be read' }
93
- const stats = (result.data as { stats?: { total?: unknown; completed?: unknown } } | undefined)
94
- ?.stats
116
+ const stats = (
117
+ result.data as
118
+ | { stats?: { total?: unknown; completed?: unknown; failed?: unknown } }
119
+ | undefined
120
+ )?.stats
95
121
  const total = typeof stats?.total === 'number' ? stats.total : undefined
96
122
  const completed = typeof stats?.completed === 'number' ? stats.completed : undefined
123
+ const failed = typeof stats?.failed === 'number' ? stats.failed : 0
97
124
  if (total === undefined || completed === undefined) return HIDDEN_RESULT
98
125
  return {
99
126
  kind: 'generic',
100
- label: total === 0 ? 'No tasks yet' : `Tasks · ${completed}/${total} done`,
127
+ label:
128
+ total === 0
129
+ ? 'No open or current-turn tasks'
130
+ : `Current-turn task view · ${completed}/${total} done${failed ? ` · ${failed} failed` : ''}`,
101
131
  }
102
132
  }
@@ -9,14 +9,14 @@ export function buildTaskUpdateTool(taskStore: TaskStore): ToolDefinition {
9
9
  return defineTool({
10
10
  name: 'task_update',
11
11
  description:
12
- 'Update an existing task. Change its status (pending → in_progress → completed), edit its description, transfer ownership, or manage dependencies. Use status "deleted" to remove a task entirely.',
12
+ 'Update task fields, owner or dependencies. Built-in statuses move forward only; completed/failed are terminal. Create follow-up tasks instead of reopening. Record failures as failed. An unconfirmed status may leave other edits applied. Outcomes are reported, not verified. Use "deleted" to remove a task.',
13
13
  inputSchema: z.object({
14
14
  id: z.string().describe('Task ID (e.g. "task_abc123")'),
15
15
  subject: z.string().optional().describe('Updated title'),
16
16
  description: z.string().optional().describe('Updated description'),
17
17
  activeForm: z.string().optional().describe('Updated present continuous form'),
18
18
  status: z
19
- .enum(['pending', 'in_progress', 'completed', 'deleted'])
19
+ .enum(['pending', 'in_progress', 'completed', 'failed', 'deleted'])
20
20
  .optional()
21
21
  .describe('New status'),
22
22
  owner: z.string().optional().describe('Agent name to assign ownership'),
@@ -76,7 +76,7 @@ export function buildTaskUpdateTool(taskStore: TaskStore): ToolDefinition {
76
76
  subject,
77
77
  description,
78
78
  activeForm,
79
- status: status as 'pending' | 'in_progress' | 'completed' | undefined,
79
+ status,
80
80
  owner,
81
81
  metadata,
82
82
  })
@@ -85,14 +85,21 @@ export function buildTaskUpdateTool(taskStore: TaskStore): ToolDefinition {
85
85
  return { success: false, output: `Task ${id} not found` }
86
86
  }
87
87
 
88
+ // Stores can retain the old status while applying other edits. The
89
+ // receipt describes the returned state; it cannot prove whether the
90
+ // request was refused or a concurrent writer advanced it again.
91
+ const statusApplied = status === undefined || updated.status === status
88
92
  return {
89
- success: true,
90
- output: `Task ${id} updated — status: ${updated.status}`,
93
+ success: statusApplied,
94
+ output: statusApplied
95
+ ? `Task ${id} updated — status: ${updated.status}`
96
+ : `Task ${id} requested status "${status}" could not be confirmed; returned status is "${updated.status}". Other requested edits may have applied. Inspect the task and create a new task for follow-up work.`,
91
97
  data: {
92
98
  id: updated.id,
93
99
  subject: updated.subject,
94
100
  status: updated.status,
95
101
  owner: updated.owner,
102
+ ...(statusApplied ? {} : { requestedStatus: status }),
96
103
  },
97
104
  }
98
105
  },
@@ -0,0 +1,87 @@
1
+ import type { ToolTextWindow } from '../types/tool/presentation.js'
2
+
3
+ /** Lines kept from the start and from the end of a long text. */
4
+ export const WINDOW_HEAD_LINES = 80
5
+ export const WINDOW_TAIL_LINES = 40
6
+ /** A window never holds more than this many characters in either half. */
7
+ export const WINDOW_HALF_CHARS = 6_000
8
+
9
+ function clipHead(text: string, max: number): string {
10
+ if (text.length <= max) return text
11
+ // By code point so a surrogate pair is never cut in two.
12
+ let end = max
13
+ const last = text.charCodeAt(end - 1)
14
+ if (last >= 0xd800 && last <= 0xdbff) end -= 1
15
+ return `${text.slice(0, end)}…`
16
+ }
17
+
18
+ function clipTail(text: string, max: number): string {
19
+ if (text.length <= max) return text
20
+ let start = text.length - max
21
+ const first = text.charCodeAt(start)
22
+ if (first >= 0xdc00 && first <= 0xdfff) start += 1
23
+ return `…${text.slice(start)}`
24
+ }
25
+
26
+ /**
27
+ * A bounded window onto `text` for the person's view: everything when it is
28
+ * short, otherwise the first and last lines with a count of what lay between.
29
+ * The model's own text is not touched; this is built beside it.
30
+ */
31
+ export function windowText(
32
+ text: string,
33
+ totalBytes = Buffer.byteLength(text, 'utf8'),
34
+ ): ToolTextWindow {
35
+ const body = text.endsWith('\n') ? text.slice(0, -1) : text
36
+ const lines = body.length === 0 ? [] : body.split('\n')
37
+ const totalLines = lines.length
38
+ if (totalLines <= WINDOW_HEAD_LINES + WINDOW_TAIL_LINES && body.length <= WINDOW_HALF_CHARS * 2) {
39
+ return { head: body, totalLines, totalBytes }
40
+ }
41
+ const headLines = lines.slice(0, WINDOW_HEAD_LINES)
42
+ const tailLines =
43
+ totalLines > WINDOW_HEAD_LINES
44
+ ? lines.slice(Math.max(WINDOW_HEAD_LINES, totalLines - WINDOW_TAIL_LINES))
45
+ : []
46
+ const head = clipHead(headLines.join('\n'), WINDOW_HALF_CHARS)
47
+ const tail = clipTail(tailLines.join('\n'), WINDOW_HALF_CHARS)
48
+ const omittedLines = totalLines - headLines.length - tailLines.length
49
+ return {
50
+ head,
51
+ ...(tail ? { tail } : {}),
52
+ ...(omittedLines > 0 ? { omittedLines } : {}),
53
+ totalLines,
54
+ totalBytes,
55
+ }
56
+ }
57
+
58
+ const SAMPLE_CHARS = 8_000
59
+
60
+ /**
61
+ * Whether decoded output is a stream of bytes and not text: a NUL, or a
62
+ * noticeable share of control characters and replacement characters that no
63
+ * terminal prints. ANSI escapes, tabs, backspaces and line ends are text.
64
+ */
65
+ export function looksBinary(text: string): boolean {
66
+ const sample = text.length > SAMPLE_CHARS ? text.slice(0, SAMPLE_CHARS) : text
67
+ if (sample.length === 0) return false
68
+ let odd = 0
69
+ for (let i = 0; i < sample.length; i++) {
70
+ const code = sample.charCodeAt(i)
71
+ if (code === 0) return true
72
+ if (code === 0xfffd) odd++
73
+ else if (
74
+ code < 0x20 &&
75
+ code !== 9 &&
76
+ code !== 10 &&
77
+ code !== 13 &&
78
+ code !== 27 &&
79
+ code !== 8 &&
80
+ code !== 7 &&
81
+ code !== 12
82
+ )
83
+ odd++
84
+ else if (code === 0x7f) odd++
85
+ }
86
+ return odd / sample.length > 0.02
87
+ }
@@ -8,6 +8,7 @@ import { ToolResultHalted, screenToolResult } from '../registry/tool/screen.js'
8
8
  import { GENAI, NAMZU, toolSpanName } from '../telemetry/attributes.js'
9
9
  import { recordToolCall } from '../telemetry/metrics.js'
10
10
  import { getTracer } from '../telemetry/runtime-accessors.js'
11
+ import { failureFactsFromError } from '../tools/failure-facts.js'
11
12
  import { isTrustedReadOnly } from '../tools/trusted-read-only.js'
12
13
  import { wrapUntrusted } from '../tools/untrusted-envelope.js'
13
14
  import type { ToolResultGuardrailSpec } from '../types/guardrail/index.js'
@@ -25,6 +26,8 @@ import type {
25
26
  ToolTierConfig,
26
27
  ToolsView,
27
28
  } from '../types/tool/index.js'
29
+ import type { ToolFacts } from '../types/tool/presentation.js'
30
+ import { awaitWithAbort } from '../utils/await-with-abort.js'
28
31
  import { toErrorMessage } from '../utils/error.js'
29
32
  import { cloneJsonValue as clonePreparedInput } from '../utils/json-snapshot.js'
30
33
  import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
@@ -670,10 +673,55 @@ Executable tool names, descriptions, and JSON input schemas are attached through
670
673
  prepareExecution(toolName: string, rawInput: unknown): ToolPreparationResult {
671
674
  const tool = this.getOrThrow(toolName)
672
675
  const parseResult = tool.inputSchema.safeParse(rawInput)
676
+ return this.finalizePreparation(tool, rawInput, parseResult)
677
+ }
678
+
679
+ /**
680
+ * Decode an input once, including asynchronous schema refinements and transforms.
681
+ * JSON-compatible raw values are detached synchronously before validation can
682
+ * yield. Non-JSON host values retain the schema's input semantics; callers must
683
+ * not mutate them while preparation is pending. The prepared output must still
684
+ * be immutable JSON, as with `prepareExecution`.
685
+ * Cancellation stops waiting and prevents publication, but cannot stop schema
686
+ * work that does not cooperate with cancellation.
687
+ */
688
+ async prepareExecutionAsync(
689
+ toolName: string,
690
+ rawInput: unknown,
691
+ signal?: AbortSignal,
692
+ ): Promise<ToolPreparationResult> {
693
+ signal?.throwIfAborted()
694
+ const tool = this.getOrThrow(toolName)
695
+ let validationInput = rawInput
696
+ try {
697
+ validationInput = clonePreparedInput(rawInput, false, '$', true)
698
+ } catch {
699
+ // A schema may normalize a Date or another host value into JSON.
700
+ // Raw input safety must not narrow that existing normalization domain.
701
+ }
702
+ signal?.throwIfAborted()
703
+ const asyncParse = tool.inputSchema.safeParseAsync
704
+ const operation =
705
+ typeof asyncParse === 'function'
706
+ ? asyncParse.call(tool.inputSchema, validationInput)
707
+ : Promise.resolve(tool.inputSchema.safeParse(validationInput))
708
+ const parseResult = await awaitWithAbort(operation, signal)
709
+ signal?.throwIfAborted()
710
+ return this.finalizePreparation(tool, validationInput, parseResult, signal)
711
+ }
712
+
713
+ private finalizePreparation(
714
+ tool: ToolDefinition,
715
+ rawInput: unknown,
716
+ parseResult: ReturnType<ToolDefinition['inputSchema']['safeParse']>,
717
+ signal?: AbortSignal,
718
+ ): ToolPreparationResult {
719
+ const toolName = tool.name
673
720
  if (!parseResult.success) {
674
721
  return {
675
722
  success: false,
676
723
  result: this.validationFailure(tool, rawInput, parseResult.error),
724
+ inputFailure: 'schema_validation',
677
725
  }
678
726
  }
679
727
 
@@ -683,6 +731,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
683
731
  retainedInput = clonePreparedInput(parseResult.data, false)
684
732
  reviewInput = clonePreparedInput(retainedInput, true)
685
733
  } catch (err) {
734
+ signal?.throwIfAborted()
686
735
  const message = `Tool "${toolName}" produced an input that cannot be safely prepared for review and execution: ${toErrorMessage(err)}`
687
736
  this.log.error('Prepared tool input could not be detached for review and execution', {
688
737
  'namzu.tool.name': toolName,
@@ -694,6 +743,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
694
743
  }
695
744
  }
696
745
 
746
+ signal?.throwIfAborted()
697
747
  const prepared = Object.freeze({ toolName, input: reviewInput })
698
748
  this.preparations.set(prepared, { tool, input: retainedInput })
699
749
  return { success: true, prepared }
@@ -728,7 +778,8 @@ Executable tool names, descriptions, and JSON input schemas are attached through
728
778
  ): Promise<ToolExecutionResult> {
729
779
  let preparation: ToolPreparationResult
730
780
  try {
731
- preparation = this.prepareExecution(toolName, rawInput)
781
+ preparation = await this.prepareExecutionAsync(toolName, rawInput, context.abortSignal)
782
+ context.abortSignal?.throwIfAborted()
732
783
  } catch (err) {
733
784
  return this.rejectPreparationWithClosedSpan(toolName, context, err)
734
785
  }
@@ -921,6 +972,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
921
972
  success: false,
922
973
  output: '',
923
974
  error: `Tool "${toolName}" execution failed: ${errorMessage}`,
975
+ ...failureFactsField(err),
924
976
  }
925
977
  }
926
978
  } finally {
@@ -1067,3 +1119,8 @@ function describeRequiredInput(schema: { _def?: unknown }): string {
1067
1119
  return 'Could not introspect required parameters.'
1068
1120
  }
1069
1121
  }
1122
+
1123
+ function failureFactsField(err: unknown): { facts?: ToolFacts } {
1124
+ const facts = failureFactsFromError(err)
1125
+ return facts ? { facts } : {}
1126
+ }