@namzu/sdk 65.3.0 → 67.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 (568) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/dist/account/lock.d.ts +4 -12
  3. package/dist/account/lock.d.ts.map +1 -1
  4. package/dist/account/lock.js +5 -140
  5. package/dist/account/lock.js.map +1 -1
  6. package/dist/account/registry.d.ts.map +1 -1
  7. package/dist/account/registry.js +50 -6
  8. package/dist/account/registry.js.map +1 -1
  9. package/dist/account/types.d.ts +7 -5
  10. package/dist/account/types.d.ts.map +1 -1
  11. package/dist/account/types.js +6 -7
  12. package/dist/account/types.js.map +1 -1
  13. package/dist/authorization/dangerous-commands.d.ts +64 -0
  14. package/dist/authorization/dangerous-commands.d.ts.map +1 -0
  15. package/dist/authorization/dangerous-commands.js +479 -0
  16. package/dist/authorization/dangerous-commands.js.map +1 -0
  17. package/dist/authorization/gate.d.ts.map +1 -1
  18. package/dist/authorization/gate.js +19 -5
  19. package/dist/authorization/gate.js.map +1 -1
  20. package/dist/authorization/protected-paths.d.ts +11 -6
  21. package/dist/authorization/protected-paths.d.ts.map +1 -1
  22. package/dist/authorization/protected-paths.js +13 -8
  23. package/dist/authorization/protected-paths.js.map +1 -1
  24. package/dist/authorization/readonly-commands.d.ts +6 -1
  25. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  26. package/dist/authorization/readonly-commands.js +35 -1
  27. package/dist/authorization/readonly-commands.js.map +1 -1
  28. package/dist/authorization/removal.d.ts +10 -0
  29. package/dist/authorization/removal.d.ts.map +1 -1
  30. package/dist/authorization/removal.js +7 -7
  31. package/dist/authorization/removal.js.map +1 -1
  32. package/dist/authorization/rules.d.ts +10 -0
  33. package/dist/authorization/rules.d.ts.map +1 -1
  34. package/dist/authorization/rules.js +60 -14
  35. package/dist/authorization/rules.js.map +1 -1
  36. package/dist/authorization/shell-lexer.d.ts +10 -0
  37. package/dist/authorization/shell-lexer.d.ts.map +1 -1
  38. package/dist/authorization/shell-lexer.js +15 -0
  39. package/dist/authorization/shell-lexer.js.map +1 -1
  40. package/dist/bridge/acp/permission.d.ts +5 -0
  41. package/dist/bridge/acp/permission.d.ts.map +1 -1
  42. package/dist/bridge/acp/permission.js.map +1 -1
  43. package/dist/bridge/acp/server.d.ts +8 -1
  44. package/dist/bridge/acp/server.d.ts.map +1 -1
  45. package/dist/bridge/acp/server.js +48 -6
  46. package/dist/bridge/acp/server.js.map +1 -1
  47. package/dist/compaction/context-breakdown.d.ts +25 -6
  48. package/dist/compaction/context-breakdown.d.ts.map +1 -1
  49. package/dist/compaction/context-breakdown.js +27 -7
  50. package/dist/compaction/context-breakdown.js.map +1 -1
  51. package/dist/compaction/dangling.d.ts.map +1 -1
  52. package/dist/compaction/dangling.js +2 -0
  53. package/dist/compaction/dangling.js.map +1 -1
  54. package/dist/compaction/extractor.d.ts +7 -1
  55. package/dist/compaction/extractor.d.ts.map +1 -1
  56. package/dist/compaction/extractor.js +8 -1
  57. package/dist/compaction/extractor.js.map +1 -1
  58. package/dist/compaction/index.d.ts +1 -1
  59. package/dist/compaction/index.d.ts.map +1 -1
  60. package/dist/compaction/index.js +1 -1
  61. package/dist/compaction/index.js.map +1 -1
  62. package/dist/compaction/managers/structured.js +2 -2
  63. package/dist/compaction/managers/structured.js.map +1 -1
  64. package/dist/compaction/manual.d.ts.map +1 -1
  65. package/dist/compaction/manual.js +11 -6
  66. package/dist/compaction/manual.js.map +1 -1
  67. package/dist/compaction/model-summary.d.ts.map +1 -1
  68. package/dist/compaction/model-summary.js +7 -1
  69. package/dist/compaction/model-summary.js.map +1 -1
  70. package/dist/compaction/summary.d.ts +13 -2
  71. package/dist/compaction/summary.d.ts.map +1 -1
  72. package/dist/compaction/summary.js +46 -3
  73. package/dist/compaction/summary.js.map +1 -1
  74. package/dist/constants/tools/index.d.ts +18 -1
  75. package/dist/constants/tools/index.d.ts.map +1 -1
  76. package/dist/constants/tools/index.js +28 -16
  77. package/dist/constants/tools/index.js.map +1 -1
  78. package/dist/manager/session/turn-recorder.d.ts +6 -0
  79. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  80. package/dist/manager/session/turn-recorder.js +29 -1
  81. package/dist/manager/session/turn-recorder.js.map +1 -1
  82. package/dist/network/audit.d.ts +49 -0
  83. package/dist/network/audit.d.ts.map +1 -0
  84. package/dist/network/audit.js +84 -0
  85. package/dist/network/audit.js.map +1 -0
  86. package/dist/network/clock.d.ts +21 -0
  87. package/dist/network/clock.d.ts.map +1 -0
  88. package/dist/network/clock.js +51 -0
  89. package/dist/network/clock.js.map +1 -0
  90. package/dist/network/discovery-mdns.d.ts +120 -0
  91. package/dist/network/discovery-mdns.d.ts.map +1 -0
  92. package/dist/network/discovery-mdns.js +442 -0
  93. package/dist/network/discovery-mdns.js.map +1 -0
  94. package/dist/network/discovery.d.ts +63 -0
  95. package/dist/network/discovery.d.ts.map +1 -0
  96. package/dist/network/discovery.js +163 -0
  97. package/dist/network/discovery.js.map +1 -0
  98. package/dist/network/fingerprint.d.ts +73 -0
  99. package/dist/network/fingerprint.d.ts.map +1 -0
  100. package/dist/network/fingerprint.js +208 -0
  101. package/dist/network/fingerprint.js.map +1 -0
  102. package/dist/network/identity.d.ts +38 -0
  103. package/dist/network/identity.d.ts.map +1 -0
  104. package/dist/network/identity.js +71 -0
  105. package/dist/network/identity.js.map +1 -0
  106. package/dist/network/index.d.ts +39 -0
  107. package/dist/network/index.d.ts.map +1 -0
  108. package/dist/network/index.js +25 -0
  109. package/dist/network/index.js.map +1 -0
  110. package/dist/network/join.d.ts +69 -0
  111. package/dist/network/join.d.ts.map +1 -0
  112. package/dist/network/join.js +136 -0
  113. package/dist/network/join.js.map +1 -0
  114. package/dist/network/mail-policy.d.ts +97 -0
  115. package/dist/network/mail-policy.d.ts.map +1 -0
  116. package/dist/network/mail-policy.js +147 -0
  117. package/dist/network/mail-policy.js.map +1 -0
  118. package/dist/network/membership.d.ts +76 -0
  119. package/dist/network/membership.d.ts.map +1 -0
  120. package/dist/network/membership.js +225 -0
  121. package/dist/network/membership.js.map +1 -0
  122. package/dist/network/roster.d.ts +59 -0
  123. package/dist/network/roster.d.ts.map +1 -0
  124. package/dist/network/roster.js +120 -0
  125. package/dist/network/roster.js.map +1 -0
  126. package/dist/network/service.d.ts +303 -0
  127. package/dist/network/service.d.ts.map +1 -0
  128. package/dist/network/service.js +1891 -0
  129. package/dist/network/service.js.map +1 -0
  130. package/dist/network/store.d.ts +141 -0
  131. package/dist/network/store.d.ts.map +1 -0
  132. package/dist/network/store.js +198 -0
  133. package/dist/network/store.js.map +1 -0
  134. package/dist/network/transport.d.ts +96 -0
  135. package/dist/network/transport.d.ts.map +1 -0
  136. package/dist/network/transport.js +342 -0
  137. package/dist/network/transport.js.map +1 -0
  138. package/dist/network/wire.d.ts +345 -0
  139. package/dist/network/wire.d.ts.map +1 -0
  140. package/dist/network/wire.js +212 -0
  141. package/dist/network/wire.js.map +1 -0
  142. package/dist/network/x509.d.ts +28 -0
  143. package/dist/network/x509.d.ts.map +1 -0
  144. package/dist/network/x509.js +84 -0
  145. package/dist/network/x509.js.map +1 -0
  146. package/dist/pals/activity/causality.d.ts.map +1 -1
  147. package/dist/pals/activity/causality.js +14 -2
  148. package/dist/pals/activity/causality.js.map +1 -1
  149. package/dist/peers/endpoint.d.ts.map +1 -1
  150. package/dist/peers/endpoint.js +6 -0
  151. package/dist/peers/endpoint.js.map +1 -1
  152. package/dist/peers/envelope.d.ts +18 -0
  153. package/dist/peers/envelope.d.ts.map +1 -1
  154. package/dist/peers/envelope.js +68 -5
  155. package/dist/peers/envelope.js.map +1 -1
  156. package/dist/peers/index.d.ts +5 -4
  157. package/dist/peers/index.d.ts.map +1 -1
  158. package/dist/peers/index.js +3 -2
  159. package/dist/peers/index.js.map +1 -1
  160. package/dist/peers/mode-word.d.ts +10 -0
  161. package/dist/peers/mode-word.d.ts.map +1 -0
  162. package/dist/peers/mode-word.js +19 -0
  163. package/dist/peers/mode-word.js.map +1 -0
  164. package/dist/peers/protocol.d.ts +42 -0
  165. package/dist/peers/protocol.d.ts.map +1 -1
  166. package/dist/peers/protocol.js +22 -1
  167. package/dist/peers/protocol.js.map +1 -1
  168. package/dist/peers/record.d.ts +8 -0
  169. package/dist/peers/record.d.ts.map +1 -1
  170. package/dist/peers/record.js +5 -0
  171. package/dist/peers/record.js.map +1 -1
  172. package/dist/plugin/session-hook-env.d.ts.map +1 -1
  173. package/dist/plugin/session-hook-env.js +22 -2
  174. package/dist/plugin/session-hook-env.js.map +1 -1
  175. package/dist/plugin/shell-hook.d.ts +16 -2
  176. package/dist/plugin/shell-hook.d.ts.map +1 -1
  177. package/dist/plugin/shell-hook.js +183 -14
  178. package/dist/plugin/shell-hook.js.map +1 -1
  179. package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
  180. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  181. package/dist/prompt/coding-agent-doctrine.js +33 -38
  182. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  183. package/dist/public-runtime.d.ts +14 -6
  184. package/dist/public-runtime.d.ts.map +1 -1
  185. package/dist/public-runtime.js +22 -5
  186. package/dist/public-runtime.js.map +1 -1
  187. package/dist/public-tools.d.ts +3 -2
  188. package/dist/public-tools.d.ts.map +1 -1
  189. package/dist/public-tools.js +2 -2
  190. package/dist/public-tools.js.map +1 -1
  191. package/dist/public-types.d.ts +7 -2
  192. package/dist/public-types.d.ts.map +1 -1
  193. package/dist/runtime/jobs/registry.d.ts +29 -1
  194. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  195. package/dist/runtime/jobs/registry.js +64 -0
  196. package/dist/runtime/jobs/registry.js.map +1 -1
  197. package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
  198. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  199. package/dist/runtime/query/auto-review/classifier.js +40 -12
  200. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  201. package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
  202. package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
  203. package/dist/runtime/query/auto-review/feedback.js +45 -0
  204. package/dist/runtime/query/auto-review/feedback.js.map +1 -0
  205. package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
  206. package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
  207. package/dist/runtime/query/auto-review/git-status.js +379 -0
  208. package/dist/runtime/query/auto-review/git-status.js.map +1 -0
  209. package/dist/runtime/query/auto-review/index.d.ts +3 -3
  210. package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
  211. package/dist/runtime/query/auto-review/index.js +2 -2
  212. package/dist/runtime/query/auto-review/index.js.map +1 -1
  213. package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
  214. package/dist/runtime/query/auto-review/prompt.js +6 -1
  215. package/dist/runtime/query/auto-review/prompt.js.map +1 -1
  216. package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
  217. package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
  218. package/dist/runtime/query/auto-review/transcript.js +48 -2
  219. package/dist/runtime/query/auto-review/transcript.js.map +1 -1
  220. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  221. package/dist/runtime/query/executor/tool-call-admission.js +40 -3
  222. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  223. package/dist/runtime/query/executor.d.ts +32 -10
  224. package/dist/runtime/query/executor.d.ts.map +1 -1
  225. package/dist/runtime/query/executor.js +78 -17
  226. package/dist/runtime/query/executor.js.map +1 -1
  227. package/dist/runtime/query/index.d.ts +9 -0
  228. package/dist/runtime/query/index.d.ts.map +1 -1
  229. package/dist/runtime/query/index.js +54 -17
  230. package/dist/runtime/query/index.js.map +1 -1
  231. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  232. package/dist/runtime/query/iteration/index.js +17 -3
  233. package/dist/runtime/query/iteration/index.js.map +1 -1
  234. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  235. package/dist/runtime/query/iteration/phases/compaction.js +5 -2
  236. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  237. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  238. package/dist/runtime/query/iteration/phases/context.js +5 -0
  239. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  240. package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
  241. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  242. package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
  243. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  244. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  245. package/dist/runtime/query/iteration/phases/tool-review.js +6 -1
  246. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  247. package/dist/runtime/query/pasted-frames.d.ts +34 -0
  248. package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
  249. package/dist/runtime/query/pasted-frames.js +108 -0
  250. package/dist/runtime/query/pasted-frames.js.map +1 -0
  251. package/dist/runtime/query/path-escalation.d.ts +6 -0
  252. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  253. package/dist/runtime/query/path-escalation.js +15 -3
  254. package/dist/runtime/query/path-escalation.js.map +1 -1
  255. package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
  256. package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
  257. package/dist/runtime/query/request-interrupted-turns.js +43 -0
  258. package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
  259. package/dist/runtime/query/review-policy.d.ts +16 -6
  260. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  261. package/dist/runtime/query/review-policy.js +111 -15
  262. package/dist/runtime/query/review-policy.js.map +1 -1
  263. package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
  264. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  265. package/dist/runtime/query/turn/outcome-ledger.js +94 -6
  266. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  267. package/dist/runtime/query/unanswered.d.ts +19 -0
  268. package/dist/runtime/query/unanswered.d.ts.map +1 -0
  269. package/dist/runtime/query/unanswered.js +25 -0
  270. package/dist/runtime/query/unanswered.js.map +1 -0
  271. package/dist/runtime/system-events.d.ts +4 -4
  272. package/dist/runtime/system-events.d.ts.map +1 -1
  273. package/dist/runtime/system-events.js +2 -0
  274. package/dist/runtime/system-events.js.map +1 -1
  275. package/dist/session/workspace/git-worktree.d.ts +8 -0
  276. package/dist/session/workspace/git-worktree.d.ts.map +1 -1
  277. package/dist/session/workspace/git-worktree.js +21 -3
  278. package/dist/session/workspace/git-worktree.js.map +1 -1
  279. package/dist/store/evidence/source-kind.d.ts +1 -1
  280. package/dist/store/evidence/source-kind.d.ts.map +1 -1
  281. package/dist/store/evidence/source-kind.js +1 -1
  282. package/dist/store/evidence/source-kind.js.map +1 -1
  283. package/dist/store/session-index/sqlite.d.ts.map +1 -1
  284. package/dist/store/session-index/sqlite.js +42 -3
  285. package/dist/store/session-index/sqlite.js.map +1 -1
  286. package/dist/store/session-log/disk.js +1 -1
  287. package/dist/store/session-log/disk.js.map +1 -1
  288. package/dist/store/session-log/lease.d.ts.map +1 -1
  289. package/dist/store/session-log/lease.js +3 -2
  290. package/dist/store/session-log/lease.js.map +1 -1
  291. package/dist/tools/admit-facts.d.ts.map +1 -1
  292. package/dist/tools/admit-facts.js +2 -0
  293. package/dist/tools/admit-facts.js.map +1 -1
  294. package/dist/tools/builtins/bash.d.ts +10 -2
  295. package/dist/tools/builtins/bash.d.ts.map +1 -1
  296. package/dist/tools/builtins/bash.js +56 -17
  297. package/dist/tools/builtins/bash.js.map +1 -1
  298. package/dist/tools/builtins/browser-local.d.ts +117 -0
  299. package/dist/tools/builtins/browser-local.d.ts.map +1 -0
  300. package/dist/tools/builtins/browser-local.js +437 -0
  301. package/dist/tools/builtins/browser-local.js.map +1 -0
  302. package/dist/tools/builtins/browser.d.ts +18 -1
  303. package/dist/tools/builtins/browser.d.ts.map +1 -1
  304. package/dist/tools/builtins/browser.js +84 -6
  305. package/dist/tools/builtins/browser.js.map +1 -1
  306. package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
  307. package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
  308. package/dist/tools/builtins/computer-use-window-id.js +52 -0
  309. package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
  310. package/dist/tools/builtins/computer-use.d.ts +65 -7
  311. package/dist/tools/builtins/computer-use.d.ts.map +1 -1
  312. package/dist/tools/builtins/computer-use.js +384 -71
  313. package/dist/tools/builtins/computer-use.js.map +1 -1
  314. package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
  315. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  316. package/dist/tools/builtins/content-fingerprint.js +7 -1
  317. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  318. package/dist/tools/builtins/edit.d.ts.map +1 -1
  319. package/dist/tools/builtins/edit.js +89 -7
  320. package/dist/tools/builtins/edit.js.map +1 -1
  321. package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
  322. package/dist/tools/builtins/file-write-result.js +2 -1
  323. package/dist/tools/builtins/file-write-result.js.map +1 -1
  324. package/dist/tools/builtins/grep.js +1 -1
  325. package/dist/tools/builtins/grep.js.map +1 -1
  326. package/dist/tools/builtins/job.d.ts.map +1 -1
  327. package/dist/tools/builtins/job.js +4 -2
  328. package/dist/tools/builtins/job.js.map +1 -1
  329. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  330. package/dist/tools/builtins/monitor.js +6 -1
  331. package/dist/tools/builtins/monitor.js.map +1 -1
  332. package/dist/tools/builtins/search-tools.d.ts +12 -1
  333. package/dist/tools/builtins/search-tools.d.ts.map +1 -1
  334. package/dist/tools/builtins/search-tools.js +166 -20
  335. package/dist/tools/builtins/search-tools.js.map +1 -1
  336. package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
  337. package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
  338. package/dist/tools/builtins/shell-read-credit.js +95 -27
  339. package/dist/tools/builtins/shell-read-credit.js.map +1 -1
  340. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  341. package/dist/tools/builtins/wait-for-job.js +14 -3
  342. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  343. package/dist/tools/builtins/web-guidance.d.ts +6 -0
  344. package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
  345. package/dist/tools/builtins/web-guidance.js +6 -0
  346. package/dist/tools/builtins/web-guidance.js.map +1 -1
  347. package/dist/tools/builtins/web.d.ts.map +1 -1
  348. package/dist/tools/builtins/web.js +2 -1
  349. package/dist/tools/builtins/web.js.map +1 -1
  350. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  351. package/dist/tools/builtins/write-file.js +32 -2
  352. package/dist/tools/builtins/write-file.js.map +1 -1
  353. package/dist/tools/command-shell.d.ts +1 -1
  354. package/dist/tools/command-shell.d.ts.map +1 -1
  355. package/dist/tools/command-shell.js +6 -8
  356. package/dist/tools/command-shell.js.map +1 -1
  357. package/dist/tools/defineTool.d.ts +2 -0
  358. package/dist/tools/defineTool.d.ts.map +1 -1
  359. package/dist/tools/defineTool.js +17 -1
  360. package/dist/tools/defineTool.js.map +1 -1
  361. package/dist/tools/schedules/index.d.ts +1 -0
  362. package/dist/tools/schedules/index.d.ts.map +1 -1
  363. package/dist/tools/schedules/index.js +1 -0
  364. package/dist/tools/schedules/index.js.map +1 -1
  365. package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
  366. package/dist/tools/schedules/loop-tool.js +8 -6
  367. package/dist/tools/schedules/loop-tool.js.map +1 -1
  368. package/dist/tools/schedules/present.js +1 -1
  369. package/dist/tools/schedules/present.js.map +1 -1
  370. package/dist/tools/schedules/timer-tools.d.ts +36 -0
  371. package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
  372. package/dist/tools/schedules/timer-tools.js +234 -0
  373. package/dist/tools/schedules/timer-tools.js.map +1 -0
  374. package/dist/tools/schedules/types.d.ts +68 -3
  375. package/dist/tools/schedules/types.d.ts.map +1 -1
  376. package/dist/tools/task/create.d.ts.map +1 -1
  377. package/dist/tools/task/create.js +2 -0
  378. package/dist/tools/task/create.js.map +1 -1
  379. package/dist/toolsets/manager.d.ts +49 -7
  380. package/dist/toolsets/manager.d.ts.map +1 -1
  381. package/dist/toolsets/manager.js +239 -40
  382. package/dist/toolsets/manager.js.map +1 -1
  383. package/dist/turn/evidence-query.d.ts +18 -1
  384. package/dist/turn/evidence-query.d.ts.map +1 -1
  385. package/dist/turn/evidence-query.js +177 -35
  386. package/dist/turn/evidence-query.js.map +1 -1
  387. package/dist/turn/evidence-recall.d.ts +8 -1
  388. package/dist/turn/evidence-recall.d.ts.map +1 -1
  389. package/dist/turn/evidence-recall.js +82 -22
  390. package/dist/turn/evidence-recall.js.map +1 -1
  391. package/dist/turn/history-shed.d.ts +15 -0
  392. package/dist/turn/history-shed.d.ts.map +1 -0
  393. package/dist/turn/history-shed.js +23 -0
  394. package/dist/turn/history-shed.js.map +1 -0
  395. package/dist/types/acp/index.d.ts +26 -0
  396. package/dist/types/acp/index.d.ts.map +1 -1
  397. package/dist/types/authorization/index.d.ts +9 -1
  398. package/dist/types/authorization/index.d.ts.map +1 -1
  399. package/dist/types/authorization/index.js +11 -2
  400. package/dist/types/authorization/index.js.map +1 -1
  401. package/dist/types/hitl/index.d.ts +10 -0
  402. package/dist/types/hitl/index.d.ts.map +1 -1
  403. package/dist/types/hitl/index.js.map +1 -1
  404. package/dist/types/message/index.d.ts +56 -1
  405. package/dist/types/message/index.d.ts.map +1 -1
  406. package/dist/types/message/index.js +2 -1
  407. package/dist/types/message/index.js.map +1 -1
  408. package/dist/types/permission/index.d.ts +14 -0
  409. package/dist/types/permission/index.d.ts.map +1 -1
  410. package/dist/types/permission/index.js +14 -0
  411. package/dist/types/permission/index.js.map +1 -1
  412. package/dist/types/plugin/index.d.ts +148 -1
  413. package/dist/types/plugin/index.d.ts.map +1 -1
  414. package/dist/types/plugin/index.js +9 -0
  415. package/dist/types/plugin/index.js.map +1 -1
  416. package/dist/types/provider/index.d.ts +1 -0
  417. package/dist/types/provider/index.d.ts.map +1 -1
  418. package/dist/types/provider/interface.d.ts +12 -0
  419. package/dist/types/provider/interface.d.ts.map +1 -1
  420. package/dist/types/provider/limits.d.ts +33 -0
  421. package/dist/types/provider/limits.d.ts.map +1 -0
  422. package/dist/types/provider/limits.js +7 -0
  423. package/dist/types/provider/limits.js.map +1 -0
  424. package/dist/types/tool/index.d.ts +30 -0
  425. package/dist/types/tool/index.d.ts.map +1 -1
  426. package/dist/types/tool/index.js.map +1 -1
  427. package/dist/types/tool/presentation.d.ts +4 -0
  428. package/dist/types/tool/presentation.d.ts.map +1 -1
  429. package/dist/utils/file-lock.d.ts +88 -0
  430. package/dist/utils/file-lock.d.ts.map +1 -0
  431. package/dist/utils/file-lock.js +281 -0
  432. package/dist/utils/file-lock.js.map +1 -0
  433. package/dist/utils/state-backup.d.ts +87 -0
  434. package/dist/utils/state-backup.d.ts.map +1 -0
  435. package/dist/utils/state-backup.js +272 -0
  436. package/dist/utils/state-backup.js.map +1 -0
  437. package/dist/utils/temp-sweep.d.ts +66 -0
  438. package/dist/utils/temp-sweep.d.ts.map +1 -0
  439. package/dist/utils/temp-sweep.js +311 -0
  440. package/dist/utils/temp-sweep.js.map +1 -0
  441. package/dist/utils/temp.d.ts +14 -0
  442. package/dist/utils/temp.d.ts.map +1 -1
  443. package/dist/utils/temp.js +70 -2
  444. package/dist/utils/temp.js.map +1 -1
  445. package/package.json +1 -1
  446. package/src/account/lock.ts +13 -133
  447. package/src/account/registry.ts +75 -21
  448. package/src/account/types.ts +8 -9
  449. package/src/authorization/dangerous-commands.ts +542 -0
  450. package/src/authorization/gate.ts +19 -5
  451. package/src/authorization/protected-paths.ts +13 -8
  452. package/src/authorization/readonly-commands.ts +35 -1
  453. package/src/authorization/removal.ts +7 -7
  454. package/src/authorization/rules.ts +75 -15
  455. package/src/authorization/shell-lexer.ts +19 -0
  456. package/src/bridge/acp/permission.ts +2 -0
  457. package/src/bridge/acp/server.ts +66 -6
  458. package/src/compaction/context-breakdown.ts +53 -11
  459. package/src/compaction/dangling.ts +2 -0
  460. package/src/compaction/extractor.ts +9 -1
  461. package/src/compaction/index.ts +1 -0
  462. package/src/compaction/managers/structured.ts +2 -2
  463. package/src/compaction/manual.ts +11 -3
  464. package/src/compaction/model-summary.ts +8 -1
  465. package/src/compaction/summary.ts +54 -7
  466. package/src/constants/tools/index.ts +30 -16
  467. package/src/manager/session/turn-recorder.ts +37 -1
  468. package/src/network/audit.ts +113 -0
  469. package/src/network/clock.ts +62 -0
  470. package/src/network/discovery-mdns.ts +485 -0
  471. package/src/network/discovery.ts +210 -0
  472. package/src/network/fingerprint.ts +241 -0
  473. package/src/network/identity.ts +98 -0
  474. package/src/network/index.ts +134 -0
  475. package/src/network/join.ts +177 -0
  476. package/src/network/mail-policy.ts +199 -0
  477. package/src/network/membership.ts +290 -0
  478. package/src/network/roster.ts +165 -0
  479. package/src/network/service.ts +2304 -0
  480. package/src/network/store.ts +261 -0
  481. package/src/network/transport.ts +445 -0
  482. package/src/network/wire.ts +250 -0
  483. package/src/network/x509.ts +114 -0
  484. package/src/pals/activity/causality.ts +16 -2
  485. package/src/peers/endpoint.ts +6 -0
  486. package/src/peers/envelope.ts +82 -5
  487. package/src/peers/index.ts +10 -2
  488. package/src/peers/mode-word.ts +18 -0
  489. package/src/peers/protocol.ts +24 -1
  490. package/src/peers/record.ts +5 -0
  491. package/src/plugin/session-hook-env.ts +25 -2
  492. package/src/plugin/shell-hook.ts +208 -14
  493. package/src/prompt/coding-agent-doctrine.ts +33 -38
  494. package/src/public-runtime.ts +107 -1
  495. package/src/public-tools.ts +11 -0
  496. package/src/public-types.ts +67 -1
  497. package/src/runtime/jobs/registry.ts +93 -3
  498. package/src/runtime/query/auto-review/classifier.ts +76 -14
  499. package/src/runtime/query/auto-review/feedback.ts +50 -0
  500. package/src/runtime/query/auto-review/git-status.ts +437 -0
  501. package/src/runtime/query/auto-review/index.ts +7 -2
  502. package/src/runtime/query/auto-review/prompt.ts +6 -1
  503. package/src/runtime/query/auto-review/transcript.ts +67 -4
  504. package/src/runtime/query/executor/tool-call-admission.ts +49 -3
  505. package/src/runtime/query/executor.ts +104 -21
  506. package/src/runtime/query/index.ts +66 -17
  507. package/src/runtime/query/iteration/index.ts +24 -3
  508. package/src/runtime/query/iteration/phases/compaction.ts +4 -0
  509. package/src/runtime/query/iteration/phases/context.ts +5 -0
  510. package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
  511. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  512. package/src/runtime/query/pasted-frames.ts +119 -0
  513. package/src/runtime/query/path-escalation.ts +27 -3
  514. package/src/runtime/query/request-interrupted-turns.ts +47 -0
  515. package/src/runtime/query/review-policy.ts +125 -22
  516. package/src/runtime/query/turn/outcome-ledger.ts +99 -6
  517. package/src/runtime/query/unanswered.ts +35 -0
  518. package/src/runtime/system-events.ts +2 -0
  519. package/src/session/workspace/git-worktree.ts +34 -3
  520. package/src/store/evidence/source-kind.ts +1 -1
  521. package/src/store/session-index/sqlite.ts +40 -3
  522. package/src/store/session-log/disk.ts +1 -1
  523. package/src/store/session-log/lease.ts +3 -2
  524. package/src/tools/admit-facts.ts +2 -0
  525. package/src/tools/builtins/bash.ts +62 -19
  526. package/src/tools/builtins/browser-local.ts +504 -0
  527. package/src/tools/builtins/browser.ts +108 -6
  528. package/src/tools/builtins/computer-use-window-id.ts +50 -0
  529. package/src/tools/builtins/computer-use.ts +460 -68
  530. package/src/tools/builtins/content-fingerprint.ts +8 -1
  531. package/src/tools/builtins/edit.ts +93 -7
  532. package/src/tools/builtins/file-write-result.ts +2 -1
  533. package/src/tools/builtins/grep.ts +1 -1
  534. package/src/tools/builtins/job.ts +4 -2
  535. package/src/tools/builtins/monitor.ts +6 -1
  536. package/src/tools/builtins/search-tools.ts +196 -21
  537. package/src/tools/builtins/shell-read-credit.ts +97 -33
  538. package/src/tools/builtins/wait-for-job.ts +13 -3
  539. package/src/tools/builtins/web-guidance.ts +6 -0
  540. package/src/tools/builtins/web.ts +2 -1
  541. package/src/tools/builtins/write-file.ts +31 -3
  542. package/src/tools/command-shell.ts +6 -8
  543. package/src/tools/defineTool.ts +20 -1
  544. package/src/tools/schedules/index.ts +11 -0
  545. package/src/tools/schedules/loop-tool.ts +10 -6
  546. package/src/tools/schedules/present.ts +1 -1
  547. package/src/tools/schedules/timer-tools.ts +258 -0
  548. package/src/tools/schedules/types.ts +72 -3
  549. package/src/tools/task/create.ts +2 -0
  550. package/src/toolsets/manager.ts +262 -46
  551. package/src/turn/evidence-query.ts +183 -42
  552. package/src/turn/evidence-recall.ts +96 -19
  553. package/src/turn/history-shed.ts +30 -0
  554. package/src/types/acp/index.ts +24 -0
  555. package/src/types/authorization/index.ts +20 -3
  556. package/src/types/hitl/index.ts +10 -0
  557. package/src/types/message/index.ts +65 -0
  558. package/src/types/permission/index.ts +18 -0
  559. package/src/types/plugin/index.ts +205 -26
  560. package/src/types/provider/index.ts +1 -0
  561. package/src/types/provider/interface.ts +13 -0
  562. package/src/types/provider/limits.ts +35 -0
  563. package/src/types/tool/index.ts +30 -2
  564. package/src/types/tool/presentation.ts +4 -0
  565. package/src/utils/file-lock.ts +328 -0
  566. package/src/utils/state-backup.ts +318 -0
  567. package/src/utils/temp-sweep.ts +327 -0
  568. package/src/utils/temp.ts +73 -2
@@ -5,6 +5,7 @@ import { defineTool } from '../defineTool.js';
5
5
  import { neutralizeEnvelopeDelimiter, wrapUntrusted } from '../untrusted-envelope.js';
6
6
  import { ScreenshotFrames, assumedDisplay, desktopRectOnImage, pointOnImage, toDisplayPoint, toDisplayRect, toImagePoint, toWindowPoint, } from './computer-use-coordinates.js';
7
7
  import { STANDARD_SCREENSHOT_LIMITS, cropAndFitPng, fitPng, pngSize, } from './computer-use-image.js';
8
+ import { coerceWindowId, windowKey } from './computer-use-window-id.js';
8
9
  export { HIGH_RES_SCREENSHOT_LIMITS, STANDARD_SCREENSHOT_LIMITS, screenshotTargetSize, } from './computer-use-image.js';
9
10
  export const COMPUTER_USE_TOOL_NAME = 'computer_use';
10
11
  const DEFAULT_SETTLE_MS = 500;
@@ -42,6 +43,15 @@ const ADVICE_MIN_CONFIDENCE = 0.85;
42
43
  const ADVICE_MIN_MARGIN = 0.4;
43
44
  /** The most controls an advisor is asked about at once. */
44
45
  const MAX_ADVISED_CANDIDATES = 255;
46
+ /** How an application name is compared: trimmed, lower case, without a trailing `.exe`. */
47
+ function deniedAppKey(app) {
48
+ return app
49
+ .trim()
50
+ .toLowerCase()
51
+ .replace(/\.exe$/, '');
52
+ }
53
+ /** The longest edge, in pixels, of the picture {@link ComputerUseToolOptions.onObservation} gets. */
54
+ export const OBSERVATION_LONG_EDGE = 720;
45
55
  /**
46
56
  * Why `provider` cannot drive `computer_use`, or undefined when it can.
47
57
  *
@@ -123,6 +133,7 @@ const keySchema = z.object({
123
133
  at: pointSchema.optional(),
124
134
  delivery_mode: z.enum(['background', 'foreground']).optional(),
125
135
  });
136
+ const windowIdSchema = z.preprocess(coerceWindowId, z.string().min(1));
126
137
  const waitSchema = z.object({
127
138
  type: z.literal('wait'),
128
139
  ms: z.number().int().nonnegative(),
@@ -130,7 +141,7 @@ const waitSchema = z.object({
130
141
  const listWindowsSchema = z.object({ type: z.literal('list_windows') });
131
142
  const focusWindowSchema = z.object({
132
143
  type: z.literal('focus_window'),
133
- window_id: z.string().min(1),
144
+ window_id: windowIdSchema,
134
145
  });
135
146
  const UI_ACTIONS = [
136
147
  'invoke',
@@ -144,7 +155,7 @@ const UI_ACTIONS = [
144
155
  ];
145
156
  const uiSnapshotSchema = z.object({
146
157
  type: z.literal('ui_snapshot'),
147
- window_id: z.string().min(1).optional(),
158
+ window_id: windowIdSchema.optional(),
148
159
  /** A ref shown by an earlier ui_snapshot: read only that region or control. */
149
160
  root: z.string().min(1).optional(),
150
161
  /** With root: skip this many of the region's children (the next page of a long region). */
@@ -167,7 +178,7 @@ const waitForSchema = z.object({
167
178
  match: z.string().min(1),
168
179
  /** Narrows element_* to controls of this role, such as Button. */
169
180
  role: z.string().min(1).optional(),
170
- window_id: z.string().min(1).optional(),
181
+ window_id: windowIdSchema.optional(),
171
182
  timeout_ms: z.number().int().positive().optional(),
172
183
  });
173
184
  const uiActSchema = z.object({
@@ -184,7 +195,7 @@ const uiDoSchema = z.object({
184
195
  target: z.string().min(1).max(200),
185
196
  action: z.enum(UI_ACTIONS),
186
197
  value: z.string().optional(),
187
- window_id: z.string().min(1).optional(),
198
+ window_id: windowIdSchema.optional(),
188
199
  });
189
200
  /** What a batch may carry: everything but the image-returning actions and another batch. */
190
201
  const batchItemSchema = z.discriminatedUnion('type', [
@@ -201,11 +212,21 @@ const batchItemSchema = z.discriminatedUnion('type', [
201
212
  uiActSchema,
202
213
  uiDoSchema,
203
214
  ]);
215
+ /** The actions that read a place or a window off the latest screenshot. */
216
+ const NEEDS_FRAME = new Set([
217
+ 'cursor_position',
218
+ 'mouse_move',
219
+ 'mouse_click',
220
+ 'mouse_drag',
221
+ 'scroll',
222
+ 'type_text',
223
+ 'key',
224
+ ]);
204
225
  const withFrame = { screenshot_id: screenshotIdSchema };
205
226
  const actionSchema = z.discriminatedUnion('type', [
206
227
  z.object({
207
228
  type: z.literal('screenshot'),
208
- window_id: z.string().min(1).optional(),
229
+ window_id: windowIdSchema.optional(),
209
230
  }),
210
231
  z.object({ type: z.literal('zoom'), region: regionSchema, ...withFrame }),
211
232
  cursorPositionSchema.extend(withFrame),
@@ -437,6 +458,8 @@ function buildDescription(host, caps, settings, advisor) {
437
458
  ? `Offers the available computer controls on a ${caps.displayServer} host.`
438
459
  : `Computer control is unavailable on this ${caps.displayServer} host; this tool reports the limitation.`;
439
460
  const lines = [intro, `Available actions: ${available.join('; ') || 'none'}.`];
461
+ if (available.length > 0)
462
+ lines.push('When the person asks you to use an application on the screen ("open the text editor and type …", "click …"), do it here, on the screen, so they watch it happen (start the program from the shell if it is not open, then work in its window with the actions below): a script that writes the file or runs the program is a different way of getting the result, and is fine only when the result is all they asked for. Say in your reply which way you did the work, and never say you typed or clicked in an application when you wrote a file or ran a command instead.');
440
463
  if (unavailable.length > 0) {
441
464
  lines.push(caps.unavailableReason
442
465
  ? `Unavailable on this host: ${unavailable.join(', ')} — ${caps.unavailableReason} Do not retry; tell the user.`
@@ -971,6 +994,19 @@ function hostOutcome(verdict) {
971
994
  throw deliveryFailure(verdict);
972
995
  return deliveryOutcome(verdict);
973
996
  }
997
+ const CONSEQUENTIAL_KEYS = /(^|\+)(alt\+f4|ctrl\+q|cmd\+q|super\+q|ctrl\+w|ctrl\+shift\+delete|shift\+delete|ctrl\+enter|cmd\+enter|delete)$/i;
998
+ const CONSEQUENTIAL_WORDS = /(?<!\p{L})(delete|remove|erase|discard|don'?t save|do not save|close|quit|exit|send|submit|pay|purchase|buy|order|sign out|log ?out|empty|format|uninstall|kaydetme|sil|gönder|kapat|çık|çıkış|satın al|öde)(?!\p{L})/iu;
999
+ /** An application as a person reads it: no `.exe`, and a lowercase process name starts with a capital. */
1000
+ function applicationName(name) {
1001
+ const bare = name.trim().replace(/\.exe$/i, '');
1002
+ return bare && bare === bare.toLowerCase()
1003
+ ? `${bare.charAt(0).toUpperCase()}${bare.slice(1)}`
1004
+ : bare;
1005
+ }
1006
+ /** Words that make a control's name or an intent one a person should answer for. */
1007
+ function consequentialWords(text) {
1008
+ return text !== undefined && CONSEQUENTIAL_WORDS.test(text);
1009
+ }
974
1010
  /** Whether a call sends the screen to the provider (see `ToolDefinition.capturesScreen`). */
975
1011
  function capturesScreenInput(input, screenshotAfterActions) {
976
1012
  const items = batchActions(input) ?? [input];
@@ -1090,7 +1126,7 @@ export function createComputerUseTool(host, options = {}) {
1090
1126
  const label = (input) => itemLabel(input, describeUiRef);
1091
1127
  /** The controls of a window's latest reading that offer an action (any, when none is named), as an advisor is shown them. */
1092
1128
  const advisedCandidates = (windowId, action) => {
1093
- const shown = shownRefs.get(windowId ?? '');
1129
+ const shown = shownRefs.get(windowKey(windowId));
1094
1130
  const out = [];
1095
1131
  if (!shown)
1096
1132
  return out;
@@ -1523,12 +1559,12 @@ export function createComputerUseTool(host, options = {}) {
1523
1559
  }
1524
1560
  uiSnapshotWindowId = snapshot.windowId ?? requestedWindowId;
1525
1561
  {
1526
- const key = uiSnapshotWindowId ?? '';
1562
+ const key = windowKey(uiSnapshotWindowId);
1527
1563
  const now = new Set(refs.keys());
1528
1564
  shownRefs.set(key, snapshot.region ? new Set([...(shownRefs.get(key) ?? []), ...now]) : now);
1529
1565
  }
1530
1566
  if (uiSnapshotWindowId !== undefined)
1531
- treeUsable.set(uiSnapshotWindowId, refs.size > 0);
1567
+ treeUsable.set(windowKey(uiSnapshotWindowId), refs.size > 0);
1532
1568
  uiSnapshotFrame = frames.latest();
1533
1569
  const window = snapshot.windowId && /^[\w.:-]{1,64}$/.test(snapshot.windowId) ? snapshot.windowId : undefined;
1534
1570
  const opened = openedRef !== undefined && /^e\d{1,6}$/.test(openedRef) ? openedRef : undefined;
@@ -1661,7 +1697,7 @@ export function createComputerUseTool(host, options = {}) {
1661
1697
  throw new StepFailure('cancelled');
1662
1698
  try {
1663
1699
  if (windowCondition) {
1664
- const windows = await host.listWindows(callSignal);
1700
+ const windows = rememberWindows(await host.listWindows(callSignal));
1665
1701
  const open = windows.some((window) => window.title.toLowerCase().includes(needle));
1666
1702
  if (open === input.until.endsWith('appears')) {
1667
1703
  const seconds = ((Date.now() - started) / 1000).toFixed(1);
@@ -1707,7 +1743,7 @@ export function createComputerUseTool(host, options = {}) {
1707
1743
  const coordinateNudge = (frame) => {
1708
1744
  if (!frame.window || !available.has('ui_snapshot'))
1709
1745
  return undefined;
1710
- const id = frame.window.window.id;
1746
+ const id = windowKey(frame.window.window.id);
1711
1747
  if (nudgedWindows.has(id))
1712
1748
  return undefined;
1713
1749
  const usable = treeUsable.get(id);
@@ -1732,7 +1768,7 @@ export function createComputerUseTool(host, options = {}) {
1732
1768
  return;
1733
1769
  let windows;
1734
1770
  try {
1735
- windows = await host.listWindows(callSignal);
1771
+ windows = rememberWindows(await host.listWindows(callSignal));
1736
1772
  }
1737
1773
  catch (error) {
1738
1774
  throw new StepFailure(`the window in front could not be read, so nothing was typed: ${errorText(error)}`);
@@ -1744,7 +1780,7 @@ export function createComputerUseTool(host, options = {}) {
1744
1780
  const listWindows = async () => {
1745
1781
  let windows;
1746
1782
  try {
1747
- windows = await host.listWindows(callSignal);
1783
+ windows = rememberWindows(await host.listWindows(callSignal));
1748
1784
  }
1749
1785
  catch (error) {
1750
1786
  throw new StepFailure(errorText(error));
@@ -1940,6 +1976,17 @@ export function createComputerUseTool(host, options = {}) {
1940
1976
  // the screenshot in step 5 should not arrive after steps 1–4 changed
1941
1977
  // the desktop.
1942
1978
  const planned = [];
1979
+ // An input that reads its place off a screenshot, when none was ever taken: it is not sent. The
1980
+ // tool takes the display screenshot and returns it, so the model chooses its target on a frame it
1981
+ // has seen. Actions before that input still run; it and everything after it do not.
1982
+ const blockedAt = frameId === undefined &&
1983
+ !frames.latest() &&
1984
+ available.has('screenshot') &&
1985
+ hostActionAvailable(caps, 'screenshot')
1986
+ ? items.findIndex((item) => NEEDS_FRAME.has(item.type))
1987
+ : -1;
1988
+ const unsent = blockedAt >= 0 ? items.slice(blockedAt) : [];
1989
+ const toPlan = blockedAt >= 0 ? items.slice(0, blockedAt) : items;
1943
1990
  const actionFrame = frameId ? frames.get(frameId) : frames.latest();
1944
1991
  const explicitDisplayFrame = frameId !== undefined && actionFrame !== undefined && !actionFrame.window;
1945
1992
  if (actionFrame?.window &&
@@ -1954,7 +2001,7 @@ export function createComputerUseTool(host, options = {}) {
1954
2001
  };
1955
2002
  let postWindowId = actionFrame?.window?.window.id ??
1956
2003
  (!hostActionAvailable(caps, 'screenshot') ? uiSnapshotWindowId : undefined);
1957
- for (const [index, item] of items.entries()) {
2004
+ for (const [index, item] of toPlan.entries()) {
1958
2005
  try {
1959
2006
  planned.push(plan(item, frameId));
1960
2007
  }
@@ -2041,14 +2088,44 @@ export function createComputerUseTool(host, options = {}) {
2041
2088
  }
2042
2089
  for (const step of planned.slice(records.length))
2043
2090
  records.push({ label: step.label, status: 'not run' });
2091
+ for (const item of unsent)
2092
+ records.push({ label: label(item), status: 'not run' });
2093
+ const total = planned.length + unsent.length;
2094
+ // The frame the unsent input needed, taken after the actions that did run.
2095
+ let framePrelude;
2096
+ let frameShot;
2097
+ if (unsent.length > 0 && !failure && !signal?.aborted) {
2098
+ try {
2099
+ if (changed)
2100
+ await settleAfterActions(host, undefined, settings.settleMs, signal);
2101
+ frameShot = await capture();
2102
+ const before = single
2103
+ ? ''
2104
+ : planned.length === 0
2105
+ ? ' Nothing in the batch ran.'
2106
+ : ` Actions 1-${planned.length} ran; action ${planned.length + 1}${unsent.length > 1 ? ' and the ones after it' : ''} did not.`;
2107
+ framePrelude = `No screenshot had been taken yet, so nothing was clicked or typed: the ${single ? 'action' : 'input'} was not sent.${before} The display screenshot follows (${frameShot.frame.id}, ${frameShot.frame.imageWidth}x${frameShot.frame.imageHeight}); choose the target on it and send the action again.`;
2108
+ }
2109
+ catch (error) {
2110
+ const why = signal?.aborted ? 'cancelled' : errorText(error);
2111
+ const reason = `no screenshot has been taken yet, so nothing was clicked or typed, and the display screenshot could not be taken: ${why}`;
2112
+ failure = { index: planned.length, error: reason };
2113
+ records[planned.length] = {
2114
+ label: records[planned.length]?.label ?? '',
2115
+ status: 'failed',
2116
+ error: reason,
2117
+ };
2118
+ }
2119
+ }
2044
2120
  // The screen after the batch: after anything that may have changed it,
2045
2121
  // and after a wait, whose whole point is to look again.
2046
2122
  const looks = settings.screenshotAfterActions &&
2047
2123
  available.has('screenshot') &&
2048
2124
  (hostActionAvailable(caps, 'screenshot') || postWindowId !== undefined) &&
2049
2125
  (changed || planned.some((step) => step.item.type === 'wait')) &&
2126
+ unsent.length === 0 &&
2050
2127
  !signal?.aborted;
2051
- let shot;
2128
+ let shot = frameShot;
2052
2129
  let shotError;
2053
2130
  if (looks) {
2054
2131
  try {
@@ -2070,13 +2147,18 @@ export function createComputerUseTool(host, options = {}) {
2070
2147
  return `${n}${record.label}: not run`;
2071
2148
  }
2072
2149
  };
2073
- const header = single
2074
- ? []
2075
- : failure
2076
- ? [
2077
- `Batch stopped at action ${failure.index + 1} of ${planned.length}; ${planned.length - failure.index - 1} not run.`,
2078
- ]
2079
- : [`Batch: all ${planned.length} actions done.`];
2150
+ const header = [
2151
+ ...(framePrelude ? [framePrelude] : []),
2152
+ ...(single
2153
+ ? []
2154
+ : failure
2155
+ ? [
2156
+ `Batch stopped at action ${failure.index + 1} of ${total}; ${total - failure.index - 1} not run.`,
2157
+ ]
2158
+ : unsent.length > 0
2159
+ ? []
2160
+ : [`Batch: all ${total} actions done.`]),
2161
+ ];
2080
2162
  const stepLines = records.map(summary);
2081
2163
  const shotLines = shot
2082
2164
  ? [describeFrame(shot.frame)]
@@ -2137,7 +2219,7 @@ export function createComputerUseTool(host, options = {}) {
2137
2219
  ? failure.unknown.message
2138
2220
  : single
2139
2221
  ? `computer_use failed: ${failure.error}`
2140
- : `Batch stopped at action ${failure.index + 1} of ${planned.length} (${planned[failure.index]?.label}): ${failure.error}`;
2222
+ : `Batch stopped at action ${failure.index + 1} of ${total} (${planned[failure.index]?.label}): ${failure.error}`;
2141
2223
  return result;
2142
2224
  };
2143
2225
  // Whether a call sends the screen to the provider: an observation, or an
@@ -2145,6 +2227,258 @@ export function createComputerUseTool(host, options = {}) {
2145
2227
  // reach nothing captures nothing.
2146
2228
  const observes = available.has('screenshot') || available.has('list_windows') || available.has('ui_snapshot');
2147
2229
  const capturesScreen = (input) => observes && capturesScreenInput(input, settings.screenshotAfterActions);
2230
+ /** The newest window list this tool read, so naming an application costs the host no call of its own. */
2231
+ let knownWindows = [];
2232
+ function rememberWindows(listed) {
2233
+ knownWindows = listed;
2234
+ return listed;
2235
+ }
2236
+ /**
2237
+ * The application a call works on, from what is already known: the window a call names, the
2238
+ * window a window screenshot is bound to, and on a display screenshot the window under the
2239
+ * click or the one in front, as the newest list this tool read has them.
2240
+ */
2241
+ /** A tree read or a wait on a control or text with no window named: it reads a window the tool already bound, or else the one in front. */
2242
+ const readsFrontWindow = (item) => item.type === 'ui_snapshot' ||
2243
+ (item.type === 'wait_for' && !String(item.until ?? '').startsWith('window_'));
2244
+ /** The window such a call is bound to by a ref or an earlier tree read, when it names none. */
2245
+ const boundWindowId = (item) => {
2246
+ if (typeof item.window_id === 'string')
2247
+ return item.window_id;
2248
+ if (item.type === 'ui_snapshot' && typeof item.root === 'string')
2249
+ return uiRefs.get(item.root)?.windowId;
2250
+ if (item.type === 'wait_for' && readsFrontWindow(item))
2251
+ return uiSnapshotWindowId;
2252
+ return undefined;
2253
+ };
2254
+ const appsKnown = (input, namedOnly = false) => {
2255
+ const found = [];
2256
+ const add = (app) => {
2257
+ if (app && !found.includes(app))
2258
+ found.push(app);
2259
+ };
2260
+ const items = batchActions(input) ?? [input];
2261
+ for (const item of items) {
2262
+ if (!isRecord(item))
2263
+ continue;
2264
+ if (typeof item.window_id === 'string') {
2265
+ add(knownWindows.find((window) => window.id === item.window_id)?.app);
2266
+ continue;
2267
+ }
2268
+ const bound = boundWindowId(item);
2269
+ if (bound !== undefined) {
2270
+ add(knownWindows.find((window) => window.id === bound)?.app);
2271
+ continue;
2272
+ }
2273
+ if (readsFrontWindow(item)) {
2274
+ add(knownWindows.find((window) => window.focused && !window.minimized)?.app);
2275
+ continue;
2276
+ }
2277
+ const shotId = typeof item.screenshot_id === 'string'
2278
+ ? item.screenshot_id
2279
+ : isRecord(input) && typeof input.screenshot_id === 'string'
2280
+ ? input.screenshot_id
2281
+ : undefined;
2282
+ const frame = shotId ? frames.get(shotId) : frames.latest();
2283
+ if (frame?.window) {
2284
+ add(frame.window.window.app);
2285
+ continue;
2286
+ }
2287
+ // A look at the whole display names no application.
2288
+ if (namedOnly)
2289
+ continue;
2290
+ const listed = knownWindows.filter((window) => !window.minimized);
2291
+ const at = isRecord(item.at) ? item.at : undefined;
2292
+ if (frame && at && typeof at.x === 'number' && typeof at.y === 'number') {
2293
+ const point = toDisplayPoint(frame, { x: at.x, y: at.y });
2294
+ const x = frame.display.x + point.x;
2295
+ const y = frame.display.y + point.y;
2296
+ const hit = listed.filter((window) => x >= window.bounds.x &&
2297
+ y >= window.bounds.y &&
2298
+ x < window.bounds.x + window.bounds.width &&
2299
+ y < window.bounds.y + window.bounds.height);
2300
+ const best = hit.find((window) => window.focused) ?? hit[0];
2301
+ if (best) {
2302
+ add(best.app);
2303
+ continue;
2304
+ }
2305
+ }
2306
+ add(listed.find((window) => window.focused)?.app);
2307
+ }
2308
+ return found;
2309
+ };
2310
+ /** The first application a call works on; see {@link appsKnown} for every one. */
2311
+ const appKnown = (input) => appsKnown(input)[0];
2312
+ /**
2313
+ * The application a call works on, before it runs. It reads the windows afresh when the host can
2314
+ * list them, so a review screen names the application as it is now.
2315
+ */
2316
+ const appsOf = async (input) => {
2317
+ if (typeof host.listWindows === 'function') {
2318
+ try {
2319
+ rememberWindows(await host.listWindows(callSignal));
2320
+ }
2321
+ catch {
2322
+ /* The application is a nicety; a host that cannot list windows says nothing. */
2323
+ }
2324
+ }
2325
+ return appsKnown(input);
2326
+ };
2327
+ const appOf = async (input) => (await appsOf(input))[0];
2328
+ /** Why one call must be answered for even in an allowed application; see {@link ComputerUseTool.consequence}. */
2329
+ const consequence = (input) => {
2330
+ const items = batchActions(input) ?? [input];
2331
+ for (const item of items) {
2332
+ if (!isRecord(item))
2333
+ continue;
2334
+ if (item.type === 'key' &&
2335
+ typeof item.keys === 'string' &&
2336
+ CONSEQUENTIAL_KEYS.test(item.keys.trim()))
2337
+ return `presses ${item.keys}`;
2338
+ if (item.type === 'ui_act' || item.type === 'ui_do') {
2339
+ const named = typeof item.ref === 'string'
2340
+ ? describeUiRef(item.ref)
2341
+ : typeof item.target === 'string'
2342
+ ? item.target
2343
+ : undefined;
2344
+ const intent = typeof item.intent === 'string' ? item.intent : undefined;
2345
+ if (consequentialWords(named) || consequentialWords(intent))
2346
+ return `acts on ${named ?? intent}`;
2347
+ }
2348
+ }
2349
+ return undefined;
2350
+ };
2351
+ // The applications this conversation's calls have worked on, so the first use of each is listed.
2352
+ const appsUsed = new Set();
2353
+ /** What the person gets of the picture the model received: small, with where a click landed. */
2354
+ const observe = async (input, before, result, toolUseId, app) => {
2355
+ if (!options.onObservation)
2356
+ return;
2357
+ try {
2358
+ const data = result.data;
2359
+ const image = Array.isArray(result.content)
2360
+ ? result.content.find((block) => block.type === 'image')
2361
+ : undefined;
2362
+ const frameId = data?.screenshot?.id;
2363
+ if (!image || image.type !== 'image' || typeof frameId !== 'string')
2364
+ return;
2365
+ const small = await fitPng(Buffer.from(image.data, 'base64'), {
2366
+ maxLongEdge: OBSERVATION_LONG_EDGE,
2367
+ maxTiles: 600,
2368
+ });
2369
+ const items = batchActions(input) ?? [input];
2370
+ const click = [...items]
2371
+ .reverse()
2372
+ .find((item) => isRecord(item) && item.type === 'mouse_click' && isRecord(item.at));
2373
+ const at = isRecord(click) && isRecord(click.at) ? click.at : undefined;
2374
+ const point = before && at && typeof at.x === 'number' && typeof at.y === 'number'
2375
+ ? {
2376
+ x: Math.min(1, Math.max(0, at.x / Math.max(1, before.imageWidth))),
2377
+ y: Math.min(1, Math.max(0, at.y / Math.max(1, before.imageHeight))),
2378
+ }
2379
+ : undefined;
2380
+ options.onObservation({
2381
+ ...(toolUseId ? { toolUseId } : {}),
2382
+ frameId,
2383
+ action: label(input),
2384
+ ...(app ? { app } : {}),
2385
+ mimeType: 'image/png',
2386
+ data: small.data.toString('base64'),
2387
+ width: small.width,
2388
+ height: small.height,
2389
+ ...(point ? { point } : {}),
2390
+ });
2391
+ }
2392
+ catch {
2393
+ /* What the person is shown never changes what the model gets. */
2394
+ }
2395
+ };
2396
+ const deniedKeys = new Set((options.deniedApps ?? []).map(deniedAppKey).filter((key) => key !== ''));
2397
+ /**
2398
+ * Why this call may not run because of the denied-application list, or undefined. Checked
2399
+ * before the host is touched, so no look, click or key reaches a window of a listed application.
2400
+ */
2401
+ const deniedAppRefusal = async (input, context) => {
2402
+ if (deniedKeys.size === 0)
2403
+ return undefined;
2404
+ const readOnly = isReadOnlyInput(input);
2405
+ let refreshFailed = false;
2406
+ if (typeof host.listWindows === 'function') {
2407
+ try {
2408
+ rememberWindows(await host.listWindows(context.abortSignal));
2409
+ }
2410
+ catch (error) {
2411
+ refreshFailed = true;
2412
+ if (!readOnly)
2413
+ return `computer_use could not read which application this would act in (${errorText(error)}), and some applications are off limits, so nothing was done.`;
2414
+ }
2415
+ }
2416
+ else if (!readOnly) {
2417
+ return 'computer_use cannot tell which application this would act in on this computer, and some applications are off limits, so nothing was done.';
2418
+ }
2419
+ // A window the list cannot place may belong to a listed application: refuse it.
2420
+ const stale = refreshFailed;
2421
+ for (const item of batchActions(input) ?? [input]) {
2422
+ if (!isRecord(item))
2423
+ continue;
2424
+ const id = boundWindowId(item);
2425
+ const placeable = id === undefined || knownWindows.some((window) => window.id === id);
2426
+ if (!placeable || (stale && (id !== undefined || readsFrontWindow(item))))
2427
+ return 'computer_use cannot tell which application that window belongs to, and some applications are off limits, so nothing was done.';
2428
+ }
2429
+ const app = appsKnown(input, readOnly).find((name) => deniedKeys.has(deniedAppKey(name)));
2430
+ if (app === undefined)
2431
+ return undefined;
2432
+ return `computer_use does not act in ${applicationName(app)}: the person put it off limits. Nothing was done. Use another application, or tell the person you need it and let them change the list.`;
2433
+ };
2434
+ const runAction = async (input, context) => {
2435
+ const denied = refusal(input.type);
2436
+ if (denied)
2437
+ return { success: false, output: '', error: denied };
2438
+ // The host keeps per-turn state (an Escape stop, refused permissions); it
2439
+ // is told which turn this is and released when the turn is cut short.
2440
+ host.beginTurn?.(context.turnId);
2441
+ callSignal = context.abortSignal;
2442
+ if (host.endTurn) {
2443
+ const release = () => void Promise.resolve(host.endTurn?.()).catch(() => undefined);
2444
+ if (context.abortSignal.aborted)
2445
+ release();
2446
+ else
2447
+ context.abortSignal.addEventListener('abort', release, {
2448
+ once: true,
2449
+ });
2450
+ }
2451
+ try {
2452
+ switch (input.type) {
2453
+ case 'screenshot':
2454
+ return screenshotResult(await capture(input.window_id));
2455
+ case 'zoom':
2456
+ return await zoom(input);
2457
+ case 'ui_snapshot':
2458
+ return await uiSnapshot(input);
2459
+ case 'wait_for':
2460
+ return await waitFor(input, context);
2461
+ case 'batch':
2462
+ return await runSteps(input.actions, input.screenshot_id, context, false);
2463
+ default: {
2464
+ const { screenshot_id: frameId, ...item } = input;
2465
+ return await runSteps([item], frameId, context, true);
2466
+ }
2467
+ }
2468
+ }
2469
+ catch (error) {
2470
+ if (error instanceof StepFailure)
2471
+ return {
2472
+ success: false,
2473
+ output: '',
2474
+ error: `computer_use failed: ${error.message}`,
2475
+ };
2476
+ throw error;
2477
+ }
2478
+ finally {
2479
+ callSignal = undefined;
2480
+ }
2481
+ };
2148
2482
  const tool = defineTool({
2149
2483
  name: COMPUTER_USE_TOOL_NAME,
2150
2484
  description: buildDescription(host, caps, settings, options.advisor),
@@ -2166,58 +2500,37 @@ export function createComputerUseTool(host, options = {}) {
2166
2500
  // without its input (the CLI passes `{}`). An action that only reports
2167
2501
  // "done" — and the screenshot that followed it, which is for the model —
2168
2502
  // adds nothing to the call row; observations, batches and failures do.
2169
- presentResult: (_input, result) => result.success && ACKNOWLEDGEMENT.test(result.output)
2170
- ? { kind: 'generic', label: result.output, visibility: 'hidden' }
2171
- : undefined,
2503
+ presentResult: (_input, result) => {
2504
+ // The first call to work on an application says so, so a person reading the
2505
+ // conversation can see which applications this conversation has used.
2506
+ const first = isRecord(result.data) ? result.data.firstUseOf : undefined;
2507
+ if (result.success && typeof first === 'string')
2508
+ return {
2509
+ kind: 'generic',
2510
+ label: `Using ${applicationName(first)}`,
2511
+ presentation: 'activity',
2512
+ };
2513
+ return result.success && ACKNOWLEDGEMENT.test(result.output)
2514
+ ? { kind: 'generic', label: result.output, visibility: 'hidden' }
2515
+ : undefined;
2516
+ },
2172
2517
  async execute(input, context) {
2173
- const denied = refusal(input.type);
2174
- if (denied)
2175
- return { success: false, output: '', error: denied };
2176
- // The host keeps per-turn state (an Escape stop, refused permissions); it
2177
- // is told which turn this is and released when the turn is cut short.
2178
- host.beginTurn?.(context.turnId);
2179
- callSignal = context.abortSignal;
2180
- if (host.endTurn) {
2181
- const release = () => void Promise.resolve(host.endTurn?.()).catch(() => undefined);
2182
- if (context.abortSignal.aborted)
2183
- release();
2184
- else
2185
- context.abortSignal.addEventListener('abort', release, {
2186
- once: true,
2187
- });
2188
- }
2189
- try {
2190
- switch (input.type) {
2191
- case 'screenshot':
2192
- return screenshotResult(await capture(input.window_id));
2193
- case 'zoom':
2194
- return await zoom(input);
2195
- case 'ui_snapshot':
2196
- return await uiSnapshot(input);
2197
- case 'wait_for':
2198
- return await waitFor(input, context);
2199
- case 'batch':
2200
- return await runSteps(input.actions, input.screenshot_id, context, false);
2201
- default: {
2202
- const { screenshot_id: frameId, ...item } = input;
2203
- return await runSteps([item], frameId, context, true);
2204
- }
2205
- }
2206
- }
2207
- catch (error) {
2208
- if (error instanceof StepFailure)
2209
- return {
2210
- success: false,
2211
- output: '',
2212
- error: `computer_use failed: ${error.message}`,
2213
- };
2214
- throw error;
2215
- }
2216
- finally {
2217
- callSignal = undefined;
2518
+ const keptOut = await deniedAppRefusal(input, context);
2519
+ if (keptOut)
2520
+ return { success: false, output: '', error: keptOut };
2521
+ const shotId = 'screenshot_id' in input ? input.screenshot_id : undefined;
2522
+ const before = shotId ? frames.get(shotId) : frames.latest();
2523
+ // Only what is already known: acting must not cost the host a call it would not make.
2524
+ const app = appKnown(input);
2525
+ const result = await runAction(input, context);
2526
+ if (app && result.success !== false && !appsUsed.has(app) && !isReadOnlyInput(input)) {
2527
+ appsUsed.add(app);
2528
+ result.data = { ...(isRecord(result.data) ? result.data : {}), firstUseOf: app };
2218
2529
  }
2530
+ await observe(input, before, result, context.toolUseId, app);
2531
+ return result;
2219
2532
  },
2220
2533
  });
2221
- return Object.assign(tool, { describeUiRef });
2534
+ return Object.assign(tool, { describeUiRef, appOf, appsOf, consequence });
2222
2535
  }
2223
2536
  //# sourceMappingURL=computer-use.js.map