@code-yeongyu/senpi 2026.9.4 → 2026.9.5

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 (1010) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/README.md +5 -4
  3. package/dist/cli/startup-ui.d.ts.map +1 -1
  4. package/dist/cli/startup-ui.js +2 -1
  5. package/dist/cli/startup-ui.js.map +1 -1
  6. package/dist/core/agent-session-runtime.js +2 -2
  7. package/dist/core/agent-session-runtime.js.map +1 -1
  8. package/dist/core/agent-session.d.ts +17 -1
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +86 -3
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/auth-storage.d.ts.map +1 -1
  13. package/dist/core/auth-storage.js +31 -41
  14. package/dist/core/auth-storage.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +16 -7
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/credential-pool/state-store.d.ts +1 -0
  19. package/dist/core/credential-pool/state-store.d.ts.map +1 -1
  20. package/dist/core/credential-pool/state-store.js +22 -2
  21. package/dist/core/credential-pool/state-store.js.map +1 -1
  22. package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
  23. package/dist/core/extensions/builtin/bash-timeout/index.js +1 -5
  24. package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
  25. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts +0 -2
  26. package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
  27. package/dist/core/extensions/builtin/bash-timeout/timeout.js +3 -4
  28. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  29. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +5 -0
  30. package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -1
  31. package/dist/core/extensions/builtin/compaction/model-usability-budget.js +11 -4
  32. package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -1
  33. package/dist/core/extensions/builtin/goal/prompt.d.ts.map +1 -1
  34. package/dist/core/extensions/builtin/goal/prompt.js +1 -3
  35. package/dist/core/extensions/builtin/goal/prompt.js.map +1 -1
  36. package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
  37. package/dist/core/extensions/builtin/goal/store.js +8 -20
  38. package/dist/core/extensions/builtin/goal/store.js.map +1 -1
  39. package/dist/core/extensions/builtin/goal/tool-registration.js +1 -1
  40. package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
  41. package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
  42. package/dist/core/extensions/builtin/hooks/trust-storage.js +3 -1
  43. package/dist/core/extensions/builtin/hooks/trust-storage.js.map +1 -1
  44. package/dist/core/extensions/builtin/imagegen/auth.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/imagegen/auth.js +10 -2
  46. package/dist/core/extensions/builtin/imagegen/auth.js.map +1 -1
  47. package/dist/core/extensions/builtin/loop/index.d.ts.map +1 -1
  48. package/dist/core/extensions/builtin/loop/index.js +20 -1
  49. package/dist/core/extensions/builtin/loop/index.js.map +1 -1
  50. package/dist/core/extensions/builtin/loop/store.d.ts +8 -6
  51. package/dist/core/extensions/builtin/loop/store.d.ts.map +1 -1
  52. package/dist/core/extensions/builtin/loop/store.js +54 -88
  53. package/dist/core/extensions/builtin/loop/store.js.map +1 -1
  54. package/dist/core/extensions/builtin/loop/tools.d.ts +6 -1
  55. package/dist/core/extensions/builtin/loop/tools.d.ts.map +1 -1
  56. package/dist/core/extensions/builtin/loop/tools.js +8 -1
  57. package/dist/core/extensions/builtin/loop/tools.js.map +1 -1
  58. package/dist/core/extensions/builtin/monitor-state-event.d.ts +2 -0
  59. package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
  60. package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
  61. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +9 -5
  62. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
  63. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +20 -11
  64. package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
  65. package/dist/core/extensions/builtin/recommended-models/index.d.ts +1 -1
  66. package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
  67. package/dist/core/extensions/builtin/recommended-models/index.js +1 -0
  68. package/dist/core/extensions/builtin/recommended-models/index.js.map +1 -1
  69. package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
  70. package/dist/core/extensions/builtin/service-tier.js +12 -4
  71. package/dist/core/extensions/builtin/service-tier.js.map +1 -1
  72. package/dist/core/extensions/builtin/terminal/durable-command.d.ts +31 -0
  73. package/dist/core/extensions/builtin/terminal/durable-command.d.ts.map +1 -0
  74. package/dist/core/extensions/builtin/terminal/durable-command.js +96 -0
  75. package/dist/core/extensions/builtin/terminal/durable-command.js.map +1 -0
  76. package/dist/core/extensions/builtin/terminal/durable-file.d.ts +42 -0
  77. package/dist/core/extensions/builtin/terminal/durable-file.d.ts.map +1 -0
  78. package/dist/core/extensions/builtin/terminal/durable-file.js +102 -0
  79. package/dist/core/extensions/builtin/terminal/durable-file.js.map +1 -0
  80. package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
  81. package/dist/core/extensions/builtin/terminal/extension.js +226 -3
  82. package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
  83. package/dist/core/extensions/builtin/terminal/manager.d.ts +10 -0
  84. package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
  85. package/dist/core/extensions/builtin/terminal/manager.js +21 -0
  86. package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
  87. package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts +24 -0
  88. package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts.map +1 -0
  89. package/dist/core/extensions/builtin/terminal/manifest-lease.js +105 -0
  90. package/dist/core/extensions/builtin/terminal/manifest-lease.js.map +1 -0
  91. package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
  92. package/dist/core/extensions/builtin/terminal/monitor-notify.js +5 -1
  93. package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
  94. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +42 -2
  95. package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
  96. package/dist/core/extensions/builtin/terminal/monitor-registry.js +73 -2
  97. package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
  98. package/dist/core/extensions/builtin/terminal/monitor-status.d.ts.map +1 -1
  99. package/dist/core/extensions/builtin/terminal/monitor-status.js +21 -1
  100. package/dist/core/extensions/builtin/terminal/monitor-status.js.map +1 -1
  101. package/dist/core/extensions/builtin/terminal/prompt.d.ts.map +1 -1
  102. package/dist/core/extensions/builtin/terminal/prompt.js +9 -5
  103. package/dist/core/extensions/builtin/terminal/prompt.js.map +1 -1
  104. package/dist/core/extensions/builtin/terminal/restore.d.ts +56 -0
  105. package/dist/core/extensions/builtin/terminal/restore.d.ts.map +1 -0
  106. package/dist/core/extensions/builtin/terminal/restore.js +177 -0
  107. package/dist/core/extensions/builtin/terminal/restore.js.map +1 -0
  108. package/dist/core/extensions/builtin/terminal/shared.d.ts +25 -0
  109. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  110. package/dist/core/extensions/builtin/terminal/shared.js +25 -0
  111. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  112. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts +91 -0
  113. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts.map +1 -0
  114. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js +14 -0
  115. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js.map +1 -0
  116. package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts +62 -0
  117. package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts.map +1 -0
  118. package/dist/core/extensions/builtin/terminal/terminal-manifest.js +204 -0
  119. package/dist/core/extensions/builtin/terminal/terminal-manifest.js.map +1 -0
  120. package/dist/core/extensions/builtin/terminal/tools/bash-input.d.ts.map +1 -1
  121. package/dist/core/extensions/builtin/terminal/tools/bash-input.js +3 -2
  122. package/dist/core/extensions/builtin/terminal/tools/bash-input.js.map +1 -1
  123. package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
  124. package/dist/core/extensions/builtin/terminal/tools/bash-output.js +5 -4
  125. package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
  126. package/dist/core/extensions/builtin/terminal/tools/bash-resize.d.ts.map +1 -1
  127. package/dist/core/extensions/builtin/terminal/tools/bash-resize.js +3 -2
  128. package/dist/core/extensions/builtin/terminal/tools/bash-resize.js.map +1 -1
  129. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +8 -0
  130. package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
  131. package/dist/core/extensions/builtin/terminal/tools/context.js +10 -0
  132. package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
  133. package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
  134. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +5 -4
  135. package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
  136. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +4 -1
  137. package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
  138. package/dist/core/extensions/builtin/terminal/tools/monitor.js +114 -22
  139. package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
  140. package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -2
  141. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  142. package/dist/core/extensions/builtin/todotools/prompt.js +3 -6
  143. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  144. package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -1
  145. package/dist/core/extensions/builtin/tool-search/index.js +1 -1
  146. package/dist/core/extensions/builtin/tool-search/index.js.map +1 -1
  147. package/dist/core/extensions/builtin/tool-search/native-search.d.ts +9 -4
  148. package/dist/core/extensions/builtin/tool-search/native-search.d.ts.map +1 -1
  149. package/dist/core/extensions/builtin/tool-search/native-search.js +11 -6
  150. package/dist/core/extensions/builtin/tool-search/native-search.js.map +1 -1
  151. package/dist/core/extensions/builtin/tool-search/native-support.d.ts +13 -0
  152. package/dist/core/extensions/builtin/tool-search/native-support.d.ts.map +1 -0
  153. package/dist/core/extensions/builtin/tool-search/native-support.js +45 -0
  154. package/dist/core/extensions/builtin/tool-search/native-support.js.map +1 -0
  155. package/dist/core/extensions/index.d.ts +1 -1
  156. package/dist/core/extensions/index.d.ts.map +1 -1
  157. package/dist/core/extensions/index.js.map +1 -1
  158. package/dist/core/extensions/runner.d.ts +5 -0
  159. package/dist/core/extensions/runner.d.ts.map +1 -1
  160. package/dist/core/extensions/runner.js +44 -1
  161. package/dist/core/extensions/runner.js.map +1 -1
  162. package/dist/core/extensions/types.d.ts +26 -3
  163. package/dist/core/extensions/types.d.ts.map +1 -1
  164. package/dist/core/extensions/types.js.map +1 -1
  165. package/dist/core/footer-data-provider.d.ts.map +1 -1
  166. package/dist/core/footer-data-provider.js +18 -1
  167. package/dist/core/footer-data-provider.js.map +1 -1
  168. package/dist/core/http-dispatcher.d.ts.map +1 -1
  169. package/dist/core/http-dispatcher.js +2 -0
  170. package/dist/core/http-dispatcher.js.map +1 -1
  171. package/dist/core/lockfile-policy.d.ts +11 -0
  172. package/dist/core/lockfile-policy.d.ts.map +1 -1
  173. package/dist/core/lockfile-policy.js +19 -0
  174. package/dist/core/lockfile-policy.js.map +1 -1
  175. package/dist/core/manual-continue.d.ts +13 -0
  176. package/dist/core/manual-continue.d.ts.map +1 -0
  177. package/dist/core/manual-continue.js +19 -0
  178. package/dist/core/manual-continue.js.map +1 -0
  179. package/dist/core/messages.d.ts.map +1 -1
  180. package/dist/core/messages.js +8 -2
  181. package/dist/core/messages.js.map +1 -1
  182. package/dist/core/model-config.d.ts.map +1 -1
  183. package/dist/core/model-config.js +3 -0
  184. package/dist/core/model-config.js.map +1 -1
  185. package/dist/core/provider-composer.d.ts.map +1 -1
  186. package/dist/core/provider-composer.js +13 -2
  187. package/dist/core/provider-composer.js.map +1 -1
  188. package/dist/core/retry-fallback/chains.d.ts +1 -13
  189. package/dist/core/retry-fallback/chains.d.ts.map +1 -1
  190. package/dist/core/retry-fallback/chains.js +3 -49
  191. package/dist/core/retry-fallback/chains.js.map +1 -1
  192. package/dist/core/retry-fallback/controller.d.ts.map +1 -1
  193. package/dist/core/retry-fallback/controller.js +4 -9
  194. package/dist/core/retry-fallback/controller.js.map +1 -1
  195. package/dist/core/retry-fallback/expansion.js +1 -1
  196. package/dist/core/retry-fallback/expansion.js.map +1 -1
  197. package/dist/core/retry-fallback/settings.d.ts +2 -4
  198. package/dist/core/retry-fallback/settings.d.ts.map +1 -1
  199. package/dist/core/retry-fallback/settings.js +7 -36
  200. package/dist/core/retry-fallback/settings.js.map +1 -1
  201. package/dist/core/sdk.d.ts.map +1 -1
  202. package/dist/core/sdk.js +1 -1
  203. package/dist/core/sdk.js.map +1 -1
  204. package/dist/core/session-manager.d.ts.map +1 -1
  205. package/dist/core/session-manager.js +10 -3
  206. package/dist/core/session-manager.js.map +1 -1
  207. package/dist/core/session-sidecar-store.d.ts +62 -0
  208. package/dist/core/session-sidecar-store.d.ts.map +1 -0
  209. package/dist/core/session-sidecar-store.js +149 -0
  210. package/dist/core/session-sidecar-store.js.map +1 -0
  211. package/dist/core/settings-manager.d.ts +5 -1
  212. package/dist/core/settings-manager.d.ts.map +1 -1
  213. package/dist/core/settings-manager.js +45 -15
  214. package/dist/core/settings-manager.js.map +1 -1
  215. package/dist/core/skills.d.ts.map +1 -1
  216. package/dist/core/skills.js +19 -2
  217. package/dist/core/skills.js.map +1 -1
  218. package/dist/core/terminal-settings.d.ts +3 -0
  219. package/dist/core/terminal-settings.d.ts.map +1 -1
  220. package/dist/core/terminal-settings.js.map +1 -1
  221. package/dist/core/tools/bash.d.ts.map +1 -1
  222. package/dist/core/tools/bash.js +1 -1
  223. package/dist/core/tools/bash.js.map +1 -1
  224. package/dist/core/tools/edit.d.ts.map +1 -1
  225. package/dist/core/tools/edit.js +2 -2
  226. package/dist/core/tools/edit.js.map +1 -1
  227. package/dist/core/tools/find.d.ts.map +1 -1
  228. package/dist/core/tools/find.js +2 -2
  229. package/dist/core/tools/find.js.map +1 -1
  230. package/dist/core/tools/grep.d.ts.map +1 -1
  231. package/dist/core/tools/grep.js +2 -2
  232. package/dist/core/tools/grep.js.map +1 -1
  233. package/dist/core/tools/ls.d.ts.map +1 -1
  234. package/dist/core/tools/ls.js +2 -2
  235. package/dist/core/tools/ls.js.map +1 -1
  236. package/dist/core/tools/read.d.ts.map +1 -1
  237. package/dist/core/tools/read.js +1 -1
  238. package/dist/core/tools/read.js.map +1 -1
  239. package/dist/core/tools/write.d.ts.map +1 -1
  240. package/dist/core/tools/write.js +3 -3
  241. package/dist/core/tools/write.js.map +1 -1
  242. package/dist/index.d.ts +1 -1
  243. package/dist/index.d.ts.map +1 -1
  244. package/dist/index.js.map +1 -1
  245. package/dist/main.d.ts.map +1 -1
  246. package/dist/main.js +2 -0
  247. package/dist/main.js.map +1 -1
  248. package/dist/modes/app-server/daemon/process.d.ts +33 -3
  249. package/dist/modes/app-server/daemon/process.d.ts.map +1 -1
  250. package/dist/modes/app-server/daemon/process.js +57 -6
  251. package/dist/modes/app-server/daemon/process.js.map +1 -1
  252. package/dist/modes/app-server/daemon.js +9 -1
  253. package/dist/modes/app-server/daemon.js.map +1 -1
  254. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  255. package/dist/modes/interactive/components/scoped-models-selector.js +5 -11
  256. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  257. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  258. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  259. package/dist/modes/interactive/components/settings-selector.js +21 -8
  260. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  261. package/dist/modes/interactive/components/thinking-selector.js +2 -2
  262. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  263. package/dist/modes/interactive/components/trust-selector.js +2 -2
  264. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  265. package/dist/modes/interactive/grok/welcome-card.d.ts.map +1 -1
  266. package/dist/modes/interactive/grok/welcome-card.js +5 -2
  267. package/dist/modes/interactive/grok/welcome-card.js.map +1 -1
  268. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  269. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  270. package/dist/modes/interactive/interactive-mode.js +83 -14
  271. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  272. package/dist/modes/interactive/version-label.d.ts +7 -0
  273. package/dist/modes/interactive/version-label.d.ts.map +1 -0
  274. package/dist/modes/interactive/version-label.js +9 -0
  275. package/dist/modes/interactive/version-label.js.map +1 -0
  276. package/dist/modes/rpc/host-ensure.d.ts +2 -0
  277. package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
  278. package/dist/modes/rpc/host-ensure.js +77 -18
  279. package/dist/modes/rpc/host-ensure.js.map +1 -1
  280. package/dist/utils/version-check.d.ts.map +1 -1
  281. package/dist/utils/version-check.js +3 -4
  282. package/dist/utils/version-check.js.map +1 -1
  283. package/docs/compaction.md +2 -0
  284. package/docs/environment-variables.md +5 -0
  285. package/docs/extensions.md +22 -2
  286. package/docs/keybindings.md +1 -1
  287. package/docs/models.md +3 -0
  288. package/docs/quickstart.md +1 -1
  289. package/docs/rpc.md +1 -1
  290. package/docs/settings.md +13 -5
  291. package/docs/terminal-setup.md +27 -0
  292. package/docs/terminal-tools.md +35 -4
  293. package/docs/usage.md +5 -3
  294. package/node_modules/@anthropic-ai/sdk/CHANGELOG.md +96 -0
  295. package/node_modules/@anthropic-ai/sdk/README.md +1 -1
  296. package/node_modules/@anthropic-ai/sdk/core/credentials.d.mts.map +1 -1
  297. package/node_modules/@anthropic-ai/sdk/core/credentials.d.ts.map +1 -1
  298. package/node_modules/@anthropic-ai/sdk/core/credentials.js +5 -7
  299. package/node_modules/@anthropic-ai/sdk/core/credentials.js.map +1 -1
  300. package/node_modules/@anthropic-ai/sdk/core/credentials.mjs +5 -7
  301. package/node_modules/@anthropic-ai/sdk/core/credentials.mjs.map +1 -1
  302. package/node_modules/@anthropic-ai/sdk/core/middleware.d.mts.map +1 -1
  303. package/node_modules/@anthropic-ai/sdk/core/middleware.d.ts.map +1 -1
  304. package/node_modules/@anthropic-ai/sdk/core/middleware.js +4 -4
  305. package/node_modules/@anthropic-ai/sdk/core/middleware.js.map +1 -1
  306. package/node_modules/@anthropic-ai/sdk/core/middleware.mjs +4 -4
  307. package/node_modules/@anthropic-ai/sdk/core/middleware.mjs.map +1 -1
  308. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.mts +45 -0
  309. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.mts.map +1 -0
  310. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.ts +45 -0
  311. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.ts.map +1 -0
  312. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.js +58 -0
  313. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.js.map +1 -0
  314. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.mjs +54 -0
  315. package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.mjs.map +1 -0
  316. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.js +1 -1
  317. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.js.map +1 -1
  318. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.mjs +1 -1
  319. package/node_modules/@anthropic-ai/sdk/internal/detect-platform.mjs.map +1 -1
  320. package/node_modules/@anthropic-ai/sdk/internal/errors.d.mts.map +1 -1
  321. package/node_modules/@anthropic-ai/sdk/internal/errors.d.ts.map +1 -1
  322. package/node_modules/@anthropic-ai/sdk/internal/errors.js +3 -1
  323. package/node_modules/@anthropic-ai/sdk/internal/errors.js.map +1 -1
  324. package/node_modules/@anthropic-ai/sdk/internal/errors.mjs +3 -1
  325. package/node_modules/@anthropic-ai/sdk/internal/errors.mjs.map +1 -1
  326. package/node_modules/@anthropic-ai/sdk/internal/file-store.d.mts.map +1 -1
  327. package/node_modules/@anthropic-ai/sdk/internal/file-store.d.ts.map +1 -1
  328. package/node_modules/@anthropic-ai/sdk/internal/file-store.js +23 -25
  329. package/node_modules/@anthropic-ai/sdk/internal/file-store.js.map +1 -1
  330. package/node_modules/@anthropic-ai/sdk/internal/file-store.mjs +5 -6
  331. package/node_modules/@anthropic-ai/sdk/internal/file-store.mjs.map +1 -1
  332. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.mts +9 -0
  333. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.mts.map +1 -0
  334. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.ts +9 -0
  335. package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.ts.map +1 -0
  336. package/node_modules/@anthropic-ai/sdk/internal/node.browser.js +22 -0
  337. package/node_modules/@anthropic-ai/sdk/internal/node.browser.js.map +1 -0
  338. package/node_modules/@anthropic-ai/sdk/internal/node.browser.mjs +19 -0
  339. package/node_modules/@anthropic-ai/sdk/internal/node.browser.mjs.map +1 -0
  340. package/node_modules/@anthropic-ai/sdk/internal/node.d.mts +14 -0
  341. package/node_modules/@anthropic-ai/sdk/internal/node.d.mts.map +1 -0
  342. package/node_modules/@anthropic-ai/sdk/internal/node.d.ts +14 -0
  343. package/node_modules/@anthropic-ai/sdk/internal/node.d.ts.map +1 -0
  344. package/node_modules/@anthropic-ai/sdk/internal/node.js +24 -0
  345. package/node_modules/@anthropic-ai/sdk/internal/node.js.map +1 -0
  346. package/node_modules/@anthropic-ai/sdk/internal/node.mjs +14 -0
  347. package/node_modules/@anthropic-ai/sdk/internal/node.mjs.map +1 -0
  348. package/node_modules/@anthropic-ai/sdk/internal/parse.js +1 -1
  349. package/node_modules/@anthropic-ai/sdk/internal/parse.js.map +1 -1
  350. package/node_modules/@anthropic-ai/sdk/internal/parse.mjs +1 -1
  351. package/node_modules/@anthropic-ai/sdk/internal/parse.mjs.map +1 -1
  352. package/node_modules/@anthropic-ai/sdk/internal/uploads.js +10 -6
  353. package/node_modules/@anthropic-ai/sdk/internal/uploads.js.map +1 -1
  354. package/node_modules/@anthropic-ai/sdk/internal/uploads.mjs +10 -6
  355. package/node_modules/@anthropic-ai/sdk/internal/uploads.mjs.map +1 -1
  356. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.mts +6 -0
  357. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.mts.map +1 -1
  358. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.ts +6 -0
  359. package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.ts.map +1 -1
  360. package/node_modules/@anthropic-ai/sdk/internal/utils/values.js +7 -0
  361. package/node_modules/@anthropic-ai/sdk/internal/utils/values.js.map +1 -1
  362. package/node_modules/@anthropic-ai/sdk/internal/utils/values.mjs +6 -0
  363. package/node_modules/@anthropic-ai/sdk/internal/utils/values.mjs.map +1 -1
  364. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.d.mts.map +1 -1
  365. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.d.ts.map +1 -1
  366. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js +6 -4
  367. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js.map +1 -1
  368. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs +4 -2
  369. package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs.map +1 -1
  370. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.mts.map +1 -1
  371. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts.map +1 -1
  372. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.js +3 -4
  373. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.js.map +1 -1
  374. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs +1 -2
  375. package/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs.map +1 -1
  376. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.js +1 -1
  377. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.js.map +1 -1
  378. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.mjs +1 -1
  379. package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.mjs.map +1 -1
  380. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.js +1 -1
  381. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.js.map +1 -1
  382. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs +1 -1
  383. package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs.map +1 -1
  384. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.d.mts.map +1 -1
  385. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.d.ts.map +1 -1
  386. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.js +2 -3
  387. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.js.map +1 -1
  388. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.mjs +2 -3
  389. package/node_modules/@anthropic-ai/sdk/lib/credentials/types.mjs.map +1 -1
  390. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.js +1 -1
  391. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.js.map +1 -1
  392. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs +1 -1
  393. package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs.map +1 -1
  394. package/node_modules/@anthropic-ai/sdk/lib/middleware.d.mts.map +1 -1
  395. package/node_modules/@anthropic-ai/sdk/lib/middleware.d.ts.map +1 -1
  396. package/node_modules/@anthropic-ai/sdk/lib/middleware.js +30 -7
  397. package/node_modules/@anthropic-ai/sdk/lib/middleware.js.map +1 -1
  398. package/node_modules/@anthropic-ai/sdk/lib/middleware.mjs +30 -7
  399. package/node_modules/@anthropic-ai/sdk/lib/middleware.mjs.map +1 -1
  400. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.mts +3 -2
  401. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.mts.map +1 -1
  402. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.ts +3 -2
  403. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.ts.map +1 -1
  404. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.js +3 -46
  405. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.js.map +1 -1
  406. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.mjs +3 -46
  407. package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.mjs.map +1 -1
  408. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.mts +131 -0
  409. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.mts.map +1 -0
  410. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.ts +131 -0
  411. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.ts.map +1 -0
  412. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.js +45 -0
  413. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.js.map +1 -0
  414. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.mjs +41 -0
  415. package/node_modules/@anthropic-ai/sdk/lib/standard-schema.mjs.map +1 -0
  416. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.d.mts.map +1 -1
  417. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.d.ts.map +1 -1
  418. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.js +35 -6
  419. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.js.map +1 -1
  420. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs +35 -6
  421. package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs.map +1 -1
  422. package/node_modules/@anthropic-ai/sdk/package.json +4 -11
  423. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.mts +1 -1
  424. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.mts.map +1 -1
  425. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.ts +1 -1
  426. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.ts.map +1 -1
  427. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.js.map +1 -1
  428. package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.mjs.map +1 -1
  429. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.mts +13 -9
  430. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.mts.map +1 -1
  431. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts +13 -9
  432. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts.map +1 -1
  433. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +4 -0
  434. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js.map +1 -1
  435. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs +4 -0
  436. package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs.map +1 -1
  437. package/node_modules/@anthropic-ai/sdk/resources/beta/deployment-runs.d.mts +6 -6
  438. package/node_modules/@anthropic-ai/sdk/resources/beta/deployment-runs.d.ts +6 -6
  439. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.mts +3 -2
  440. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.mts.map +1 -1
  441. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.ts +3 -2
  442. package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.ts.map +1 -1
  443. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.mts +28 -1
  444. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.mts.map +1 -1
  445. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.ts +28 -1
  446. package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.ts.map +1 -1
  447. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.mts +8 -1
  448. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.mts.map +1 -1
  449. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.ts +8 -1
  450. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.ts.map +1 -1
  451. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.js.map +1 -1
  452. package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.mjs.map +1 -1
  453. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.mts +25 -5
  454. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.mts.map +1 -1
  455. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.ts +25 -5
  456. package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.ts.map +1 -1
  457. package/node_modules/@anthropic-ai/sdk/resources/beta/files.js +6 -6
  458. package/node_modules/@anthropic-ai/sdk/resources/beta/files.js.map +1 -1
  459. package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs +7 -7
  460. package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs.map +1 -1
  461. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.mts +5 -4
  462. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.mts.map +1 -1
  463. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts +5 -4
  464. package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts.map +1 -1
  465. package/node_modules/@anthropic-ai/sdk/resources/beta/index.js +11 -9
  466. package/node_modules/@anthropic-ai/sdk/resources/beta/index.js.map +1 -1
  467. package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs +1 -0
  468. package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs.map +1 -1
  469. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.mts +12 -9
  470. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.mts.map +1 -1
  471. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.ts +12 -9
  472. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.ts.map +1 -1
  473. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.mts +8 -5
  474. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
  475. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.ts +8 -5
  476. package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
  477. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.mts +1 -1
  478. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.mts.map +1 -1
  479. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.ts +1 -1
  480. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.ts.map +1 -1
  481. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.js.map +1 -1
  482. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.mjs.map +1 -1
  483. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.mts +198 -29
  484. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.mts.map +1 -1
  485. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts +198 -29
  486. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts.map +1 -1
  487. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.js.map +1 -1
  488. package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.mjs.map +1 -1
  489. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.mts +177 -0
  490. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.mts.map +1 -0
  491. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.ts +177 -0
  492. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.ts.map +1 -0
  493. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.js +56 -0
  494. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.js.map +1 -0
  495. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.mjs +52 -0
  496. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.mjs.map +1 -0
  497. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.mts +74 -0
  498. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.mts.map +1 -0
  499. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.ts +74 -0
  500. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.ts.map +1 -0
  501. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.js +52 -0
  502. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.js.map +1 -0
  503. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.mjs +48 -0
  504. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.mjs.map +1 -0
  505. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.mts +272 -0
  506. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.mts.map +1 -0
  507. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.ts +272 -0
  508. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.ts.map +1 -0
  509. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.js +119 -0
  510. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.js.map +1 -0
  511. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.mjs +115 -0
  512. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.mjs.map +1 -0
  513. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.mts +14 -0
  514. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.mts.map +1 -0
  515. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.ts +14 -0
  516. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.ts.map +1 -0
  517. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.js +21 -0
  518. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.js.map +1 -0
  519. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.mjs +16 -0
  520. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.mjs.map +1 -0
  521. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.mts +4 -0
  522. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.mts.map +1 -0
  523. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.ts +4 -0
  524. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.ts.map +1 -0
  525. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.js +11 -0
  526. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.js.map +1 -0
  527. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.mjs +5 -0
  528. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.mjs.map +1 -0
  529. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.mts +353 -0
  530. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.mts.map +1 -0
  531. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.ts +353 -0
  532. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.ts.map +1 -0
  533. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.js +169 -0
  534. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.js.map +1 -0
  535. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.mjs +165 -0
  536. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.mjs.map +1 -0
  537. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.mts +3 -0
  538. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.mts.map +1 -0
  539. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.ts +3 -0
  540. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.ts.map +1 -0
  541. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.js +9 -0
  542. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.js.map +1 -0
  543. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.mjs +4 -0
  544. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.mjs.map +1 -0
  545. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.mts +468 -0
  546. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.mts.map +1 -0
  547. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.ts +468 -0
  548. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.ts.map +1 -0
  549. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.js +198 -0
  550. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.js.map +1 -0
  551. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.mjs +193 -0
  552. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.mjs.map +1 -0
  553. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.mts +124 -0
  554. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.mts.map +1 -0
  555. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.ts +124 -0
  556. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.ts.map +1 -0
  557. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.js +114 -0
  558. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.js.map +1 -0
  559. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.mjs +110 -0
  560. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.mjs.map +1 -0
  561. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.mts +2 -0
  562. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.mts.map +1 -0
  563. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.ts +2 -0
  564. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.ts.map +1 -0
  565. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.js +6 -0
  566. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.js.map +1 -0
  567. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.mjs +3 -0
  568. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.mjs.map +1 -0
  569. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.mts +2 -0
  570. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.mts.map +1 -0
  571. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.ts +2 -0
  572. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.ts.map +1 -0
  573. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.js +6 -0
  574. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.js.map +1 -0
  575. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.mjs +3 -0
  576. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.mjs.map +1 -0
  577. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.mts +11 -0
  578. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.mts.map +1 -0
  579. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.ts +11 -0
  580. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.ts.map +1 -0
  581. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.js +25 -0
  582. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.js.map +1 -0
  583. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.mjs +12 -0
  584. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.mjs.map +1 -0
  585. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.mts +162 -0
  586. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.mts.map +1 -0
  587. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.ts +162 -0
  588. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.ts.map +1 -0
  589. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.js +76 -0
  590. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.js.map +1 -0
  591. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.mjs +72 -0
  592. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.mjs.map +1 -0
  593. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.mts +73 -0
  594. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.mts.map +1 -0
  595. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.ts +73 -0
  596. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.ts.map +1 -0
  597. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.js +62 -0
  598. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.js.map +1 -0
  599. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.mjs +57 -0
  600. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.mjs.map +1 -0
  601. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.mts +77 -0
  602. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.mts.map +1 -0
  603. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.ts +77 -0
  604. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.ts.map +1 -0
  605. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.js +31 -0
  606. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.js.map +1 -0
  607. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.mjs +27 -0
  608. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.mjs.map +1 -0
  609. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.mts +3 -0
  610. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.mts.map +1 -0
  611. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.ts +3 -0
  612. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.ts.map +1 -0
  613. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.js +9 -0
  614. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.js.map +1 -0
  615. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.mjs +4 -0
  616. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.mjs.map +1 -0
  617. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.mts +258 -0
  618. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.mts.map +1 -0
  619. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.ts +258 -0
  620. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.ts.map +1 -0
  621. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.js +174 -0
  622. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.js.map +1 -0
  623. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.mjs +169 -0
  624. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -0
  625. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.mts +141 -0
  626. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.mts.map +1 -0
  627. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.ts +141 -0
  628. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.ts.map +1 -0
  629. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.js +125 -0
  630. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.js.map +1 -0
  631. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.mjs +121 -0
  632. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.mjs.map +1 -0
  633. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.mts +2 -0
  634. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.mts.map +1 -0
  635. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.ts +2 -0
  636. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.ts.map +1 -0
  637. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.js +6 -0
  638. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.js.map +1 -0
  639. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.mjs +3 -0
  640. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.mjs.map +1 -0
  641. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.mts +124 -0
  642. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.mts.map +1 -0
  643. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.ts +124 -0
  644. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.ts.map +1 -0
  645. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.js +67 -0
  646. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.js.map +1 -0
  647. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.mjs +63 -0
  648. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.mjs.map +1 -0
  649. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.mts +5 -0
  650. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.mts.map +1 -0
  651. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.ts +5 -0
  652. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.ts.map +1 -0
  653. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.js +13 -0
  654. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.js.map +1 -0
  655. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.mjs +6 -0
  656. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.mjs.map +1 -0
  657. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.mts +135 -0
  658. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.mts.map +1 -0
  659. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.ts +135 -0
  660. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.ts.map +1 -0
  661. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.js +102 -0
  662. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.js.map +1 -0
  663. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.mjs +98 -0
  664. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.mjs.map +1 -0
  665. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.mts +83 -0
  666. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -0
  667. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.ts +83 -0
  668. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -0
  669. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.js +34 -0
  670. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.js.map +1 -0
  671. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.mjs +30 -0
  672. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -0
  673. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.mts +210 -0
  674. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.mts.map +1 -0
  675. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.ts +210 -0
  676. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.ts.map +1 -0
  677. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.js +189 -0
  678. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.js.map +1 -0
  679. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.mjs +185 -0
  680. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.mjs.map +1 -0
  681. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.mts +303 -0
  682. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -0
  683. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.ts +303 -0
  684. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -0
  685. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.js +112 -0
  686. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.js.map +1 -0
  687. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.mjs +107 -0
  688. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.mjs.map +1 -0
  689. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.mts +2 -0
  690. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.mts.map +1 -0
  691. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.ts +2 -0
  692. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.ts.map +1 -0
  693. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.js +6 -0
  694. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.js.map +1 -0
  695. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.mjs +3 -0
  696. package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.mjs.map +1 -0
  697. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.mts +2 -0
  698. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.mts.map +1 -0
  699. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.ts +2 -0
  700. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.ts.map +1 -0
  701. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.js +6 -0
  702. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.js.map +1 -0
  703. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.mjs +3 -0
  704. package/node_modules/@anthropic-ai/sdk/resources/beta/organization.mjs.map +1 -0
  705. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.d.mts +1 -1
  706. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.d.ts +1 -1
  707. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/sessions.d.mts +10 -10
  708. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/sessions.d.ts +10 -10
  709. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.mts +2 -1
  710. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.mts.map +1 -1
  711. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.ts +2 -1
  712. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.ts.map +1 -1
  713. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.js.map +1 -1
  714. package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.mjs.map +1 -1
  715. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.mts +2 -2
  716. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.mts.map +1 -1
  717. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.ts +2 -2
  718. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.ts.map +1 -1
  719. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.js.map +1 -1
  720. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.mjs.map +1 -1
  721. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.mts +48 -120
  722. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.mts.map +1 -1
  723. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.ts +48 -120
  724. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.ts.map +1 -1
  725. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.js +12 -8
  726. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.js.map +1 -1
  727. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.mjs +12 -8
  728. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.mjs.map +1 -1
  729. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.mts +35 -138
  730. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.mts.map +1 -1
  731. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.ts +35 -138
  732. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.ts.map +1 -1
  733. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.js +18 -18
  734. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.js.map +1 -1
  735. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs +18 -18
  736. package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs.map +1 -1
  737. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.mts +21 -25
  738. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.mts.map +1 -1
  739. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.ts +21 -25
  740. package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.ts.map +1 -1
  741. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.mts +16 -17
  742. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.mts.map +1 -1
  743. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.ts +16 -17
  744. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.ts.map +1 -1
  745. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.js +21 -8
  746. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.js.map +1 -1
  747. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.mjs +21 -8
  748. package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.mjs.map +1 -1
  749. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.mts +1 -3
  750. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.mts.map +1 -1
  751. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.ts +1 -3
  752. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.ts.map +1 -1
  753. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.js.map +1 -1
  754. package/node_modules/@anthropic-ai/sdk/resources/messages/messages.mjs.map +1 -1
  755. package/node_modules/@anthropic-ai/sdk/src/core/credentials.ts +5 -7
  756. package/node_modules/@anthropic-ai/sdk/src/core/middleware.ts +4 -3
  757. package/node_modules/@anthropic-ai/sdk/src/helpers/beta/standard-schema.ts +99 -0
  758. package/node_modules/@anthropic-ai/sdk/src/internal/detect-platform.ts +1 -1
  759. package/node_modules/@anthropic-ai/sdk/src/internal/errors.ts +3 -1
  760. package/node_modules/@anthropic-ai/sdk/src/internal/file-store.ts +11 -10
  761. package/node_modules/@anthropic-ai/sdk/src/internal/node.browser.ts +22 -0
  762. package/node_modules/@anthropic-ai/sdk/src/internal/node.ts +14 -0
  763. package/node_modules/@anthropic-ai/sdk/src/internal/parse.ts +1 -1
  764. package/node_modules/@anthropic-ai/sdk/src/internal/uploads.ts +10 -7
  765. package/node_modules/@anthropic-ai/sdk/src/internal/utils/values.ts +7 -0
  766. package/node_modules/@anthropic-ai/sdk/src/lib/BetaMessageStream.ts +5 -3
  767. package/node_modules/@anthropic-ai/sdk/src/lib/MessageStream.ts +1 -3
  768. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/credential-chain.ts +1 -1
  769. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/identity-token.ts +1 -1
  770. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/types.ts +2 -3
  771. package/node_modules/@anthropic-ai/sdk/src/lib/credentials/user-oauth.ts +1 -1
  772. package/node_modules/@anthropic-ai/sdk/src/lib/middleware.ts +33 -9
  773. package/node_modules/@anthropic-ai/sdk/src/lib/sessions/accumulate.ts +7 -49
  774. package/node_modules/@anthropic-ai/sdk/src/lib/standard-schema.ts +209 -0
  775. package/node_modules/@anthropic-ai/sdk/src/lib/tools/BetaToolRunner.ts +38 -6
  776. package/node_modules/@anthropic-ai/sdk/src/resources/beta/agents/agents.ts +1 -0
  777. package/node_modules/@anthropic-ai/sdk/src/resources/beta/beta.ts +45 -15
  778. package/node_modules/@anthropic-ai/sdk/src/resources/beta/deployment-runs.ts +6 -6
  779. package/node_modules/@anthropic-ai/sdk/src/resources/beta/deployments.ts +3 -2
  780. package/node_modules/@anthropic-ai/sdk/src/resources/beta/dreams.ts +42 -0
  781. package/node_modules/@anthropic-ai/sdk/src/resources/beta/environments/environments.ts +8 -1
  782. package/node_modules/@anthropic-ai/sdk/src/resources/beta/files.ts +34 -11
  783. package/node_modules/@anthropic-ai/sdk/src/resources/beta/index.ts +13 -7
  784. package/node_modules/@anthropic-ai/sdk/src/resources/beta/memory-stores/memories.ts +12 -9
  785. package/node_modules/@anthropic-ai/sdk/src/resources/beta/memory-stores/memory-versions.ts +8 -5
  786. package/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/index.ts +5 -1
  787. package/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/messages.ts +221 -38
  788. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/api-keys.ts +231 -0
  789. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/compliance-settings.ts +96 -0
  790. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/external-keys.ts +365 -0
  791. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/federation.ts +71 -0
  792. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/index.ts +31 -0
  793. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/issuers.ts +486 -0
  794. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/index.ts +23 -0
  795. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/rules.ts +624 -0
  796. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/workspaces.ts +196 -0
  797. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules.ts +3 -0
  798. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation.ts +3 -0
  799. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/index.ts +92 -0
  800. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/invites.ts +207 -0
  801. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/organization.ts +269 -0
  802. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/rate-limits.ts +104 -0
  803. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/index.ts +21 -0
  804. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/service-accounts.ts +389 -0
  805. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/workspaces.ts +217 -0
  806. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts.ts +3 -0
  807. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/users.ts +163 -0
  808. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/index.ts +43 -0
  809. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/members.ts +209 -0
  810. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/rate-limits.ts +113 -0
  811. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/service-accounts.ts +325 -0
  812. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/workspaces.ts +450 -0
  813. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces.ts +3 -0
  814. package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization.ts +3 -0
  815. package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/events.ts +1 -1
  816. package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/sessions.ts +10 -10
  817. package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/threads/threads.ts +2 -1
  818. package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/index.ts +7 -10
  819. package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/skills.ts +60 -150
  820. package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/versions.ts +43 -166
  821. package/node_modules/@anthropic-ai/sdk/src/resources/beta/user-profiles.ts +24 -27
  822. package/node_modules/@anthropic-ai/sdk/src/resources/beta/webhooks.ts +25 -29
  823. package/node_modules/@anthropic-ai/sdk/src/resources/messages/messages.ts +2 -8
  824. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/fs-util.ts +6 -5
  825. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/memories.ts +5 -3
  826. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/node.browser.ts +1 -5
  827. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/node.ts +122 -17
  828. package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/skills.ts +10 -43
  829. package/node_modules/@anthropic-ai/sdk/src/version.ts +1 -1
  830. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.d.mts.map +1 -1
  831. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.d.ts.map +1 -1
  832. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.js +13 -15
  833. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.js.map +1 -1
  834. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs +3 -4
  835. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs.map +1 -1
  836. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.d.mts.map +1 -1
  837. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.d.ts.map +1 -1
  838. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.js +6 -4
  839. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.js.map +1 -1
  840. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.mjs +5 -3
  841. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.mjs.map +1 -1
  842. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.mts +1 -2
  843. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.mts.map +1 -1
  844. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.ts +1 -2
  845. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.ts.map +1 -1
  846. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.js +0 -4
  847. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.js.map +1 -1
  848. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.mjs +0 -3
  849. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.mjs.map +1 -1
  850. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.mts +11 -9
  851. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.mts.map +1 -1
  852. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.ts +11 -9
  853. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.ts.map +1 -1
  854. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.js +96 -8
  855. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.js.map +1 -1
  856. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs +96 -7
  857. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs.map +1 -1
  858. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.mts +0 -8
  859. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.mts.map +1 -1
  860. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.ts +0 -8
  861. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.ts.map +1 -1
  862. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.js +20 -46
  863. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.js.map +1 -1
  864. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs +9 -33
  865. package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs.map +1 -1
  866. package/node_modules/@anthropic-ai/sdk/version.d.mts +1 -1
  867. package/node_modules/@anthropic-ai/sdk/version.d.ts +1 -1
  868. package/node_modules/@anthropic-ai/sdk/version.js +1 -1
  869. package/node_modules/@anthropic-ai/sdk/version.mjs +1 -1
  870. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +45 -0
  871. package/node_modules/@code-yeongyu/senpi-codemode/README.md +4 -2
  872. package/node_modules/@code-yeongyu/senpi-codemode/package.json +5 -5
  873. package/node_modules/@code-yeongyu/senpi-codemode/src/config/settings.ts +29 -0
  874. package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +8 -4
  875. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +3 -1
  876. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/display-image.js +162 -0
  877. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/prelude.ts +2 -2
  878. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-runtime.js +29 -60
  879. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +66 -1
  880. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +28 -94
  881. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-execution.ts +7 -0
  882. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +6 -0
  883. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +14 -2
  884. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +12 -7
  885. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  886. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +58 -64
  887. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  888. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  889. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +16 -6
  890. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  891. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +1 -1
  892. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
  893. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +6 -1
  894. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
  895. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +1 -1
  896. package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js.map +1 -1
  897. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +2 -0
  898. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  899. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +40 -10
  900. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  901. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +6 -2
  902. package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
  903. package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
  904. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  905. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +1 -1
  906. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  907. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +130 -15
  908. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  909. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +4 -4
  910. package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
  911. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +1 -1
  912. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
  913. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +1 -1
  914. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  915. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +3 -1
  916. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  917. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  918. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +30 -10
  919. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  920. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +3 -3
  921. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  922. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  923. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +1 -1
  924. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  925. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +8 -5
  926. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  927. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
  928. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
  929. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +6 -0
  930. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
  931. package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js +1 -1
  932. package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js.map +1 -1
  933. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
  934. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  935. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +30 -0
  936. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  937. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
  938. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  939. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  940. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  941. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +3 -1
  942. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  943. package/node_modules/@earendil-works/pi-ai/dist/models.js +27 -3
  944. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  945. package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts +2 -0
  946. package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts.map +1 -1
  947. package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.js.map +1 -1
  948. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  949. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  950. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
  951. package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  952. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  953. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  954. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  955. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  956. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  957. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  958. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  959. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  960. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  961. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts +1 -1
  962. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
  963. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +8 -1
  964. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
  965. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +14 -1
  966. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  967. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  968. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.d.ts +23 -0
  969. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.d.ts.map +1 -0
  970. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.js +58 -0
  971. package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.js.map +1 -0
  972. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -1
  973. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js +53 -12
  974. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -1
  975. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts +4 -2
  976. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
  977. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +3 -0
  978. package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
  979. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  980. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +3 -0
  981. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  982. package/node_modules/@earendil-works/pi-ai/package.json +3 -3
  983. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  984. package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  985. package/node_modules/@earendil-works/pi-tui/README.md +1 -1
  986. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +1 -0
  987. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  988. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +36 -3
  989. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  990. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  991. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  992. package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  993. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  994. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +2 -0
  995. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
  996. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +106 -6
  997. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
  998. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +6 -0
  999. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  1000. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +17 -4
  1001. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  1002. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +11 -0
  1003. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
  1004. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +57 -15
  1005. package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
  1006. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  1007. package/node_modules/@earendil-works/pi-tui/dist/tui.js +22 -7
  1008. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  1009. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  1010. package/package.json +8 -8
@@ -1,9 +1,10 @@
1
+ import { resolve } from "node:path";
1
2
  import { StringEnum } from "@earendil-works/pi-ai";
2
3
  import { Type } from "typebox";
3
4
  import { APPROVED_MONITOR_PARENT } from "../monitor-permission.js";
4
5
  import { MonitorRegistry } from "../monitor-registry.js";
5
- import { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from "../shared.js";
6
- import { errorResult, textResult } from "./context.js";
6
+ import { DEFAULT_COLS, DEFAULT_ROWS, DURABLE_MONITOR_EXPIRY_MS, MAX_DURABLE_MONITORS, TERMINAL_MONITOR_TOOL, } from "../shared.js";
7
+ import { errorResult, resolveTerminalId, textResult, } from "./context.js";
7
8
  import { renderMonitorCall } from "./render.js";
8
9
  import { spawnCommandSession } from "./spawn.js";
9
10
  export const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;
@@ -28,7 +29,7 @@ export const monitorSchema = Type.Object({
28
29
  })),
29
30
  path: Type.Optional(Type.String({
30
31
  minLength: 1,
31
- description: "Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter and no persistent.",
32
+ description: "Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter.",
32
33
  })),
33
34
  event: Type.Optional(StringEnum(["create", "modify"], {
34
35
  description: "File branch only: which file event fires the watch (defaults to create).",
@@ -37,10 +38,12 @@ export const monitorSchema = Type.Object({
37
38
  timeout_ms: Type.Optional(Type.Number({
38
39
  minimum: 1,
39
40
  maximum: MAX_MONITOR_TIMEOUT_MS,
40
- description: "Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).",
41
+ description: "Watcher deadline in milliseconds (default 300000; ignored when persistent).",
41
42
  })),
42
- persistent: Type.Optional(Type.Boolean({ description: "Keep watching until the command exits or kill_bash stops its bash_id." })),
43
- bash_id: Type.Optional(Type.String({ description: "Rearm: paused monitor bash_id to resume; omit to resume all paused monitors." })),
43
+ persistent: Type.Optional(Type.Boolean({
44
+ description: "Standing watch: no deadline, and it survives a session restart (command re-run once, file rescanned and any detached change reported). Expires 7 days after creation; max 5 per session; stop one with kill_bash.",
45
+ })),
46
+ bash_id: Type.Optional(Type.String({ description: "Rearm: paused monitor id (mon_ or bash_id) to resume; omit for all paused." })),
44
47
  });
45
48
  function isFileCreateInput(input) {
46
49
  return (typeof input.description === "string" &&
@@ -76,18 +79,83 @@ async function createMonitor(ctx, registry, input, execCtx) {
76
79
  catch {
77
80
  return errorResult(`Invalid monitor filter regex: ${input.filter}`);
78
81
  }
82
+ // Durability needs an absolute directory: a restore runs in a different process whose
83
+ // process cwd is unrelated, so the spec must carry the resolved path the spawn used.
84
+ const cwd = resolve(execCtx?.cwd ?? ctx.cwd);
79
85
  const { id, runtime } = await spawnCommandSession(ctx, {
80
86
  command: input.command,
81
87
  cols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),
82
88
  rows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),
83
- cwd: execCtx?.cwd,
89
+ cwd,
84
90
  ...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),
85
91
  });
86
92
  ctx.onMonitorRearmed?.(id);
87
- registry.register({ id, description: input.description, runtime, filter });
88
- return textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });
93
+ const monitorId = registry.register({
94
+ id,
95
+ description: input.description,
96
+ runtime,
97
+ filter,
98
+ // Only persistent command watches are restartable-command durable: those carry the fire budget.
99
+ durabilityClass: input.persistent === true ? "restartable-command" : "ephemeral",
100
+ // Same deadline the manifest writer persists, so the footer warns off the live record too.
101
+ ...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),
102
+ });
103
+ ctx.manager.bindMonitorId(monitorId, id);
104
+ // The tool call site is the only place the branch inputs (command, persistent, filter)
105
+ // live; hand the captured spec to the session's manifest writer for durable recording.
106
+ handMonitorSpec(manifestSessionKey(ctx), {
107
+ monitorId,
108
+ spec: {
109
+ kind: "command",
110
+ description: input.description,
111
+ command: input.command,
112
+ filter: input.filter,
113
+ cwd,
114
+ persistent: input.persistent === true,
115
+ },
116
+ });
117
+ return textResult(`Monitor started with ID: ${monitorId}`, {
118
+ details: { monitor_id: monitorId, bash_id: id, monitor: true },
119
+ });
89
120
  }
90
121
  /** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */
122
+ const manifestWriters = new Map();
123
+ /** Bind the session's manifest writer so monitor tool calls can hand it specs captured at the call site. */
124
+ export function bindTerminalManifestWriter(sessionId, writer) {
125
+ manifestWriters.set(sessionId, writer);
126
+ }
127
+ export function unbindTerminalManifestWriter(sessionId) {
128
+ manifestWriters.delete(sessionId);
129
+ }
130
+ /** The durability session key for a tool context: the agent session id, when the context carries one. */
131
+ function manifestSessionKey(ctx) {
132
+ return ctx.getSessionContext?.()?.sessionManager?.getSessionId?.();
133
+ }
134
+ /** Hand a spec captured at the monitor tool call site to the session's bound writer, if any. */
135
+ function handMonitorSpec(sessionKey, registration) {
136
+ const writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);
137
+ void writer?.recordRegister(registration);
138
+ }
139
+ /** Persist a durable file watch's baseline checkpoint through the writer's debounced path. */
140
+ function handFileCheckpoint(sessionKey, monitorId, registry, runtimeId) {
141
+ const writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);
142
+ const checkpoint = registry.fileCheckpoint(runtimeId);
143
+ if (writer && checkpoint)
144
+ writer.scheduleCheckpoint(monitorId, checkpoint);
145
+ }
146
+ /**
147
+ * Admission control for a durable create: refuse once the session already holds
148
+ * MAX_DURABLE_MONITORS restart-surviving monitors. Checked BEFORE any spawn or registry
149
+ * registration so a refused call leaves no PTY and no manifest entry behind. A context
150
+ * with no bound writer persists nothing, so it has no durable population to cap.
151
+ */
152
+ function durableAdmissionError(ctx) {
153
+ const sessionKey = manifestSessionKey(ctx);
154
+ const writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);
155
+ if (writer === undefined || writer.durableCount() < MAX_DURABLE_MONITORS)
156
+ return undefined;
157
+ return errorResult(`Cannot start another persistent monitor: this session already holds ${MAX_DURABLE_MONITORS} durable monitors (the maximum). Stop one with kill_bash first.`);
158
+ }
91
159
  export function createMonitorTool(ctx) {
92
160
  let fallbackRegistry;
93
161
  const getRegistry = () => {
@@ -100,7 +168,7 @@ export function createMonitorTool(ctx) {
100
168
  return {
101
169
  name: TERMINAL_MONITOR_TOOL,
102
170
  label: "monitor",
103
- description: "Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, where newline-terminated output lines (stderr merged) that match filter arrive as injected events while you keep working and command exit always delivers a summary event; path natively watches one file and fires once: create (the default) fires only when the file appears after registration, so watch a file that already exists with event modify. The path branch takes no filter and no persistent. Identical consecutive line-only update batches are deduped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.",
171
+ description: "Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, injecting matching newline-terminated output lines (stderr merged) plus an exit summary; path natively watches one file and fires once, where create (the default) fires only when the file appears after registration, so use event modify for an existing file, and filter is rejected. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.",
104
172
  promptSnippet: "Subscribe to a command's output or a file's create/modify event as injected events instead of polling",
105
173
  promptGuidelines: [
106
174
  "Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.",
@@ -113,8 +181,7 @@ export function createMonitorTool(ctx) {
113
181
  async execute(_toolCallId, input, _signal, _onUpdate, execCtx) {
114
182
  const registry = getRegistry();
115
183
  if (input.action === "rearm") {
116
- const bashId = input.bash_id;
117
- if (bashId === undefined || bashId.length === 0) {
184
+ if (input.bash_id === undefined || input.bash_id.length === 0) {
118
185
  const resumed = registry.resume();
119
186
  if (resumed.length === 0)
120
187
  return textResult("No paused monitors to re-arm.");
@@ -124,6 +191,7 @@ export function createMonitorTool(ctx) {
124
191
  ? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`
125
192
  : `Re-armed ${resumed.length} paused monitor(s).`);
126
193
  }
194
+ const bashId = resolveTerminalId(ctx.manager, input.bash_id);
127
195
  const dropped = registry.mutedDropped(bashId);
128
196
  const outcome = registry.rearm(bashId);
129
197
  if (outcome === "not_found")
@@ -139,26 +207,50 @@ export function createMonitorTool(ctx) {
139
207
  const commandInput = isCreateInput(input);
140
208
  if (fileInput && commandInput)
141
209
  return errorResult("monitor accepts either command or path, not both.");
210
+ // Admission runs before either create branch touches a PTY or the registry.
211
+ if (input.persistent === true && (fileInput || commandInput)) {
212
+ const refused = durableAdmissionError(ctx);
213
+ if (refused)
214
+ return refused;
215
+ }
142
216
  if (fileInput) {
143
- if (input.filter !== undefined || input.persistent)
144
- return errorResult("Native file monitors do not support filter or persistent.");
217
+ if (input.filter !== undefined)
218
+ return errorResult("Native file monitors do not support filter.");
145
219
  if (!ctx.monitorRegistry)
146
220
  return errorResult("Native file monitors require a lifecycle-owned monitor registry.");
147
221
  try {
148
- const id = await ctx.monitorRegistry.registerFile({
222
+ const approvedParent = input[APPROVED_MONITOR_PARENT];
223
+ const { id, monitorId } = await ctx.monitorRegistry.registerFile({
149
224
  description: input.description,
150
225
  path: input.path,
151
226
  event: input.event ?? "create",
152
227
  timeoutMs: resolveTimeoutMs(input.timeout_ms),
153
228
  cwd: execCtx?.cwd ?? ctx.cwd,
154
- ...(input[APPROVED_MONITOR_PARENT] !== undefined
155
- ? {
156
- approvedParent: input[APPROVED_MONITOR_PARENT],
157
- }
158
- : {}),
229
+ ...(approvedParent !== undefined ? { approvedParent } : {}),
230
+ ...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),
231
+ });
232
+ ctx.manager.bindMonitorId(monitorId, id);
233
+ // Same spec capture as the command branch: durability inputs live only here.
234
+ const sessionKey = manifestSessionKey(ctx);
235
+ handMonitorSpec(sessionKey, {
236
+ monitorId,
237
+ spec: {
238
+ kind: "file",
239
+ description: input.description,
240
+ path: input.path,
241
+ event: input.event ?? "create",
242
+ timeoutMs: resolveTimeoutMs(input.timeout_ms),
243
+ cwd: execCtx?.cwd ?? ctx.cwd,
244
+ persistent: input.persistent === true,
245
+ ...(approvedParent !== undefined ? { approvedParent } : {}),
246
+ },
159
247
  });
160
- return textResult(`Monitor started with ID: ${id}`, {
161
- details: { bash_id: id, watch_id: id, monitor: true },
248
+ // A durable watch checkpoints the registry's own identity tuple straight away, so a
249
+ // restart before the first change still has a baseline (digest included) to compare to.
250
+ if (input.persistent === true)
251
+ handFileCheckpoint(sessionKey, monitorId, ctx.monitorRegistry, id);
252
+ return textResult(`Monitor started with ID: ${monitorId}`, {
253
+ details: { monitor_id: monitorId, bash_id: id, monitor: true },
162
254
  });
163
255
  }
164
256
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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ACF,CAAC;YACD,IAAI,CAAC,YAAY;gBAAE,OAAO,WAAW,CAAC,sEAAsE,CAAC,CAAC;YAC9G,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { APPROVED_MONITOR_PARENT } from \"../monitor-permission.ts\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Create, command branch (XOR path): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tpath: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t\"Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter and no persistent.\",\n\t\t}),\n\t),\n\tevent: Type.Optional(\n\t\tStringEnum([\"create\", \"modify\"] as const, {\n\t\t\tdescription: \"File branch only: which file event fires the watch (defaults to create).\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(\n\t\tType.String({ description: \"Only PTY output lines matching this regex become monitor events.\" }),\n\t),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n\tbash_id: Type.Optional(\n\t\tType.String({ description: \"Rearm: paused monitor bash_id to resume; omit to resume all paused monitors.\" }),\n\t),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\ntype FileMonitorCreateInput = MonitorInput & { description: string; path: string };\n\nfunction isFileCreateInput(input: MonitorInput): input is FileMonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.path === \"string\" &&\n\t\tinput.path.length > 0\n\t);\n}\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, where newline-terminated output lines (stderr merged) that match filter arrive as injected events while you keep working and command exit always delivers a summary event; path natively watches one file and fires once: create (the default) fires only when the file appears after registration, so watch a file that already exists with event modify. The path branch takes no filter and no persistent. Identical consecutive line-only update batches are deduped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet:\n\t\t\t\"Subscribe to a command's output or a file's create/modify event as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.\",\n\t\t\t'Waiting for one file to appear or change is the path branch: `monitor({ description, path, event? })` beats wrapping `test -f` in a shell poll loop; a file that already exists needs `event: \"modify\"`, since `create` only fires on appearance, and registration needs the parent directory to exist already — when the run creates that directory too, use the `command` branch instead.',\n\t\t\t\"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.\",\n\t\t\t\"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst bashId = input.bash_id;\n\t\t\t\tif (bashId === undefined || bashId.length === 0) {\n\t\t\t\t\tconst resumed = registry.resume();\n\t\t\t\t\tif (resumed.length === 0) return textResult(\"No paused monitors to re-arm.\");\n\t\t\t\t\tctx.onMonitorsResumed?.(resumed.map((monitor) => monitor.id));\n\t\t\t\t\tconst total = resumed.reduce((sum, monitor) => sum + monitor.mutedDropped, 0);\n\t\t\t\t\treturn textResult(\n\t\t\t\t\t\ttotal > 0\n\t\t\t\t\t\t\t? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`\n\t\t\t\t\t\t\t: `Re-armed ${resumed.length} paused monitor(s).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst dropped = registry.mutedDropped(bashId);\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(\n\t\t\t\t\tdropped > 0\n\t\t\t\t\t\t? `Monitor ${bashId} re-armed (${dropped} line(s) dropped while muted).`\n\t\t\t\t\t\t: `Monitor ${bashId} re-armed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fileInput = isFileCreateInput(input);\n\t\t\tconst commandInput = isCreateInput(input);\n\t\t\tif (fileInput && commandInput) return errorResult(\"monitor accepts either command or path, not both.\");\n\t\t\tif (fileInput) {\n\t\t\t\tif (input.filter !== undefined || input.persistent)\n\t\t\t\t\treturn errorResult(\"Native file monitors do not support filter or persistent.\");\n\t\t\t\tif (!ctx.monitorRegistry)\n\t\t\t\t\treturn errorResult(\"Native file monitors require a lifecycle-owned monitor registry.\");\n\t\t\t\ttry {\n\t\t\t\t\tconst id = await ctx.monitorRegistry.registerFile({\n\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t...((input as Record<string | symbol, unknown>)[APPROVED_MONITOR_PARENT] !== undefined\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tapprovedParent: (input as Record<string | symbol, unknown>)[\n\t\t\t\t\t\t\t\t\t\tAPPROVED_MONITOR_PARENT\n\t\t\t\t\t\t\t\t\t] as string,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t});\n\t\t\t\t\treturn textResult(`Monitor started with ID: ${id}`, {\n\t\t\t\t\t\tdetails: { bash_id: id, watch_id: id, monitor: true },\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn errorResult(error instanceof Error ? error.message : String(error));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!commandInput) return errorResult(\"monitor requires description and command or path to start a watcher.\");\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,WAAW,EACX,iBAAiB,EAGjB,UAAU,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,UAAU,CAAC,CAAC,QAAQ,EAAE,OAAO,CA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,EAAE,SAAS,EAAE,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;oBAClG,OAAO,UAAU,CAAC,4BAA4B,SAAS,EAAE,EAAE;wBAC1D,OAAO,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;qBAC9D,CAAC,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,OAAO,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5E,CAAC;YACF,CAAC;YACD,IAAI,CAAC,YAAY;gBAAE,OAAO,WAAW,CAAC,sEAAsE,CAAC,CAAC;YAC9G,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { resolve } from \"node:path\";\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { APPROVED_MONITOR_PARENT } from \"../monitor-permission.ts\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport {\n\tDEFAULT_COLS,\n\tDEFAULT_ROWS,\n\tDURABLE_MONITOR_EXPIRY_MS,\n\tMAX_DURABLE_MONITORS,\n\tTERMINAL_MONITOR_TOOL,\n} from \"../shared.ts\";\nimport type { MonitorRegistration, TerminalManifestWriter } from \"../terminal-manifest.ts\";\nimport {\n\terrorResult,\n\tresolveTerminalId,\n\ttype TerminalToolContext,\n\ttype TerminalToolResult,\n\ttextResult,\n} from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Create, command branch (XOR path): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tpath: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t\"Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter.\",\n\t\t}),\n\t),\n\tevent: Type.Optional(\n\t\tStringEnum([\"create\", \"modify\"] as const, {\n\t\t\tdescription: \"File branch only: which file event fires the watch (defaults to create).\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(\n\t\tType.String({ description: \"Only PTY output lines matching this regex become monitor events.\" }),\n\t),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored when persistent).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Standing watch: no deadline, and it survives a session restart (command re-run once, file rescanned and any detached change reported). Expires 7 days after creation; max 5 per session; stop one with kill_bash.\",\n\t\t}),\n\t),\n\tbash_id: Type.Optional(\n\t\tType.String({ description: \"Rearm: paused monitor id (mon_ or bash_id) to resume; omit for all paused.\" }),\n\t),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\ntype FileMonitorCreateInput = MonitorInput & { description: string; path: string };\n\nfunction isFileCreateInput(input: MonitorInput): input is FileMonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.path === \"string\" &&\n\t\tinput.path.length > 0\n\t);\n}\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\t// Durability needs an absolute directory: a restore runs in a different process whose\n\t// process cwd is unrelated, so the spec must carry the resolved path the spawn used.\n\tconst cwd = resolve(execCtx?.cwd ?? ctx.cwd);\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tconst monitorId = registry.register({\n\t\tid,\n\t\tdescription: input.description,\n\t\truntime,\n\t\tfilter,\n\t\t// Only persistent command watches are restartable-command durable: those carry the fire budget.\n\t\tdurabilityClass: input.persistent === true ? \"restartable-command\" : \"ephemeral\",\n\t\t// Same deadline the manifest writer persists, so the footer warns off the live record too.\n\t\t...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),\n\t});\n\tctx.manager.bindMonitorId(monitorId, id);\n\t// The tool call site is the only place the branch inputs (command, persistent, filter)\n\t// live; hand the captured spec to the session's manifest writer for durable recording.\n\thandMonitorSpec(manifestSessionKey(ctx), {\n\t\tmonitorId,\n\t\tspec: {\n\t\t\tkind: \"command\",\n\t\t\tdescription: input.description,\n\t\t\tcommand: input.command,\n\t\t\tfilter: input.filter,\n\t\t\tcwd,\n\t\t\tpersistent: input.persistent === true,\n\t\t},\n\t});\n\treturn textResult(`Monitor started with ID: ${monitorId}`, {\n\t\tdetails: { monitor_id: monitorId, bash_id: id, monitor: true },\n\t});\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nconst manifestWriters = new Map<string, TerminalManifestWriter>();\n\n/** Bind the session's manifest writer so monitor tool calls can hand it specs captured at the call site. */\nexport function bindTerminalManifestWriter(sessionId: string, writer: TerminalManifestWriter): void {\n\tmanifestWriters.set(sessionId, writer);\n}\n\nexport function unbindTerminalManifestWriter(sessionId: string): void {\n\tmanifestWriters.delete(sessionId);\n}\n\n/** The durability session key for a tool context: the agent session id, when the context carries one. */\nfunction manifestSessionKey(ctx: TerminalToolContext): string | undefined {\n\treturn ctx.getSessionContext?.()?.sessionManager?.getSessionId?.();\n}\n\n/** Hand a spec captured at the monitor tool call site to the session's bound writer, if any. */\nfunction handMonitorSpec(sessionKey: string | undefined, registration: MonitorRegistration): void {\n\tconst writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);\n\tvoid writer?.recordRegister(registration);\n}\n\n/** Persist a durable file watch's baseline checkpoint through the writer's debounced path. */\nfunction handFileCheckpoint(\n\tsessionKey: string | undefined,\n\tmonitorId: string,\n\tregistry: MonitorRegistry,\n\truntimeId: string,\n): void {\n\tconst writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);\n\tconst checkpoint = registry.fileCheckpoint(runtimeId);\n\tif (writer && checkpoint) writer.scheduleCheckpoint(monitorId, checkpoint);\n}\n\n/**\n * Admission control for a durable create: refuse once the session already holds\n * MAX_DURABLE_MONITORS restart-surviving monitors. Checked BEFORE any spawn or registry\n * registration so a refused call leaves no PTY and no manifest entry behind. A context\n * with no bound writer persists nothing, so it has no durable population to cap.\n */\nfunction durableAdmissionError(ctx: TerminalToolContext): TerminalToolResult | undefined {\n\tconst sessionKey = manifestSessionKey(ctx);\n\tconst writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);\n\tif (writer === undefined || writer.durableCount() < MAX_DURABLE_MONITORS) return undefined;\n\treturn errorResult(\n\t\t`Cannot start another persistent monitor: this session already holds ${MAX_DURABLE_MONITORS} durable monitors (the maximum). Stop one with kill_bash first.`,\n\t);\n}\n\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, injecting matching newline-terminated output lines (stderr merged) plus an exit summary; path natively watches one file and fires once, where create (the default) fires only when the file appears after registration, so use event modify for an existing file, and filter is rejected. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet:\n\t\t\t\"Subscribe to a command's output or a file's create/modify event as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.\",\n\t\t\t'Waiting for one file to appear or change is the path branch: `monitor({ description, path, event? })` beats wrapping `test -f` in a shell poll loop; a file that already exists needs `event: \"modify\"`, since `create` only fires on appearance, and registration needs the parent directory to exist already — when the run creates that directory too, use the `command` branch instead.',\n\t\t\t\"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.\",\n\t\t\t\"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tif (input.bash_id === undefined || input.bash_id.length === 0) {\n\t\t\t\t\tconst resumed = registry.resume();\n\t\t\t\t\tif (resumed.length === 0) return textResult(\"No paused monitors to re-arm.\");\n\t\t\t\t\tctx.onMonitorsResumed?.(resumed.map((monitor) => monitor.id));\n\t\t\t\t\tconst total = resumed.reduce((sum, monitor) => sum + monitor.mutedDropped, 0);\n\t\t\t\t\treturn textResult(\n\t\t\t\t\t\ttotal > 0\n\t\t\t\t\t\t\t? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`\n\t\t\t\t\t\t\t: `Re-armed ${resumed.length} paused monitor(s).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst bashId = resolveTerminalId(ctx.manager, input.bash_id);\n\t\t\t\tconst dropped = registry.mutedDropped(bashId);\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(\n\t\t\t\t\tdropped > 0\n\t\t\t\t\t\t? `Monitor ${bashId} re-armed (${dropped} line(s) dropped while muted).`\n\t\t\t\t\t\t: `Monitor ${bashId} re-armed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fileInput = isFileCreateInput(input);\n\t\t\tconst commandInput = isCreateInput(input);\n\t\t\tif (fileInput && commandInput) return errorResult(\"monitor accepts either command or path, not both.\");\n\t\t\t// Admission runs before either create branch touches a PTY or the registry.\n\t\t\tif (input.persistent === true && (fileInput || commandInput)) {\n\t\t\t\tconst refused = durableAdmissionError(ctx);\n\t\t\t\tif (refused) return refused;\n\t\t\t}\n\t\t\tif (fileInput) {\n\t\t\t\tif (input.filter !== undefined) return errorResult(\"Native file monitors do not support filter.\");\n\t\t\t\tif (!ctx.monitorRegistry)\n\t\t\t\t\treturn errorResult(\"Native file monitors require a lifecycle-owned monitor registry.\");\n\t\t\t\ttry {\n\t\t\t\t\tconst approvedParent = (input as Record<string | symbol, unknown>)[APPROVED_MONITOR_PARENT] as\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tconst { id, monitorId } = await ctx.monitorRegistry.registerFile({\n\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t...(approvedParent !== undefined ? { approvedParent } : {}),\n\t\t\t\t\t\t...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tctx.manager.bindMonitorId(monitorId, id);\n\t\t\t\t\t// Same spec capture as the command branch: durability inputs live only here.\n\t\t\t\t\tconst sessionKey = manifestSessionKey(ctx);\n\t\t\t\t\thandMonitorSpec(sessionKey, {\n\t\t\t\t\t\tmonitorId,\n\t\t\t\t\t\tspec: {\n\t\t\t\t\t\t\tkind: \"file\",\n\t\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t\tpersistent: input.persistent === true,\n\t\t\t\t\t\t\t...(approvedParent !== undefined ? { approvedParent } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\t// A durable watch checkpoints the registry's own identity tuple straight away, so a\n\t\t\t\t\t// restart before the first change still has a baseline (digest included) to compare to.\n\t\t\t\t\tif (input.persistent === true) handFileCheckpoint(sessionKey, monitorId, ctx.monitorRegistry, id);\n\t\t\t\t\treturn textResult(`Monitor started with ID: ${monitorId}`, {\n\t\t\t\t\t\tdetails: { monitor_id: monitorId, bash_id: id, monitor: true },\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn errorResult(error instanceof Error ? error.message : String(error));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!commandInput) return errorResult(\"monitor requires description and command or path to start a watcher.\");\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
@@ -1,3 +1,3 @@
1
- export declare const TODO_TOOL_DESCRIPTION = "**Tasks referenced by verbatim content string, NEVER an auto-generated ID \u2014 no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase \u2014 expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | \u2014 | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5\u201310 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call \u2014 batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced.\n- Lost the exact task text? view echoes the list \u2014 NEVER guess from memory. done/start/drop take the task's EXACT text \u2014 copy it verbatim from the latest todo result, never re-type from memory.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task \u2014 reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan \u2014 phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>";
2
- export declare const TASK_MANAGEMENT_SECTION = "\n<Task_Management>\n## Todo Management (CRITICAL)\n\nUse the todo tool for multi-step work. It is one operation at a time: initialize a phased list, then start, complete, abandon, append, remove, or view tasks by their exact content. The earliest open task auto-promotes after each completion.\n\n**Tasks referenced by verbatim content string, NEVER an auto-generated ID \u2014 no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase \u2014 expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | \u2014 | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5\u201310 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call \u2014 batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced.\n- Lost the exact task text? view echoes the list \u2014 NEVER guess from memory. done/start/drop take the task's EXACT text \u2014 copy it verbatim from the latest todo result, never re-type from memory.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task \u2014 reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan \u2014 phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>\n\n## Evidence\n- File edit: inspect the changed files and diagnostics.\n- Build command: require exit code 0.\n- Test run: require passing output, or state the pre-existing failure.\n</Task_Management>\n";
1
+ export declare const TODO_TOOL_DESCRIPTION = "**Tasks referenced by verbatim content string, NEVER an auto-generated ID \u2014 no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase \u2014 expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | \u2014 | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5\u201310 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call \u2014 batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced. done/start/drop take the task's EXACT text \u2014 copy it verbatim from the latest todo result; when it is lost, view echoes the list.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task \u2014 reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan \u2014 phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>";
2
+ export declare const TASK_MANAGEMENT_SECTION = "\n<Task_Management>\n## Todo Management\n\nUse the todo tool for multi-step work; its description carries the operations, anatomy, and rules. Mark each item done the moment it finishes and reconcile the list against the newest user message before ending a turn.\n\n## Evidence\n- File edit: inspect the changed files and diagnostics.\n- Build command: require exit code 0.\n- Test run: require passing output, or state the pre-existing failure.\n</Task_Management>\n";
3
3
  //# sourceMappingURL=prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,mgFAyCtB,CAAC;AAEb,eAAO,MAAM,uBAAuB,0/FAanC,CAAC"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,67EAwCtB,CAAC;AAEb,eAAO,MAAM,uBAAuB,udAWnC,CAAC"}
@@ -30,8 +30,7 @@ Example: {"op":"init","list":[{"phase":"Setup","items":["Survey code","Write tes
30
30
  - Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.
31
31
  - NEVER make a todo call your turn's only tool call — batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.
32
32
  - Blocked? append a task to the active phase, or drop.
33
- - Keep task/phase strings stable once introduced.
34
- - Lost the exact task text? view echoes the list — NEVER guess from memory. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result, never re-type from memory.
33
+ - Keep task/phase strings stable once introduced. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result; when it is lost, view echoes the list.
35
34
 
36
35
  ## When to create a list
37
36
  - Task requires 3+ distinct steps
@@ -46,11 +45,9 @@ User hands you a multi-step plan — phased todo, numbered/bulleted checklist, o
46
45
  </critical>`;
47
46
  export const TASK_MANAGEMENT_SECTION = `
48
47
  <Task_Management>
49
- ## Todo Management (CRITICAL)
48
+ ## Todo Management
50
49
 
51
- Use the todo tool for multi-step work. It is one operation at a time: initialize a phased list, then start, complete, abandon, append, remove, or view tasks by their exact content. The earliest open task auto-promotes after each completion.
52
-
53
- ${TODO_TOOL_DESCRIPTION}
50
+ Use the todo tool for multi-step work; its description carries the operations, anatomy, and rules. Mark each item done the moment it finishes and reconcile the list against the newest user message before ending a turn.
54
51
 
55
52
  ## Evidence
56
53
  - File edit: inspect the changed files and diagnostics.
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,mCAAmC;AACnC,oCAAoC;AACpC,sCAAsC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAyCzB,CAAC;AAEb,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;EAMrC,qBAAqB;;;;;;;CAOtB,CAAC","sourcesContent":["// Adapted from oh-my-pi's todo prompt (MIT License).\n// Copyright (c) 2025 Mario Zechner\n// Copyright (c) 2025-2026 Can Bölük\n// https://github.com/can1357/oh-my-pi\n\nexport const TODO_TOOL_DESCRIPTION = `**Tasks referenced by verbatim content string, NEVER an auto-generated ID — no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase — expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | — | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5–10 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call — batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced.\n- Lost the exact task text? view echoes the list — NEVER guess from memory. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result, never re-type from memory.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task — reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan — phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>`;\n\nexport const TASK_MANAGEMENT_SECTION = `\n<Task_Management>\n## Todo Management (CRITICAL)\n\nUse the todo tool for multi-step work. It is one operation at a time: initialize a phased list, then start, complete, abandon, append, remove, or view tasks by their exact content. The earliest open task auto-promotes after each completion.\n\n${TODO_TOOL_DESCRIPTION}\n\n## Evidence\n- File edit: inspect the changed files and diagnostics.\n- Build command: require exit code 0.\n- Test run: require passing output, or state the pre-existing failure.\n</Task_Management>\n`;\n"]}
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,mCAAmC;AACnC,oCAAoC;AACpC,sCAAsC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAwCzB,CAAC;AAEb,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;CAWtC,CAAC","sourcesContent":["// Adapted from oh-my-pi's todo prompt (MIT License).\n// Copyright (c) 2025 Mario Zechner\n// Copyright (c) 2025-2026 Can Bölük\n// https://github.com/can1357/oh-my-pi\n\nexport const TODO_TOOL_DESCRIPTION = `**Tasks referenced by verbatim content string, NEVER an auto-generated ID — no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase — expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | — | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5–10 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call — batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result; when it is lost, view echoes the list.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task — reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan — phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>`;\n\nexport const TASK_MANAGEMENT_SECTION = `\n<Task_Management>\n## Todo Management\n\nUse the todo tool for multi-step work; its description carries the operations, anatomy, and rules. Mark each item done the moment it finishes and reconcile the list against the newest user message before ending a turn.\n\n## Evidence\n- File edit: inspect the changed files and diagnostics.\n- Build command: require exit code 0.\n- Test run: require passing output, or state the pre-existing failure.\n</Task_Management>\n`;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAwD,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CA6CtF;AAWD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlF;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAwD,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CA+CtF;AAWD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlF;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
@@ -41,7 +41,7 @@ export function createToolSearchExtension(service) {
41
41
  },
42
42
  searchToolName: TOOL_SEARCH_TOOL_NAME,
43
43
  });
44
- pi.on("before_provider_request", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model?.api, event.payload));
44
+ pi.on("before_provider_request", (event, ctx) => nativeAdapter.applyBeforeRequest(event.model ?? ctx.model, event.payload));
45
45
  pi.on("after_provider_response", (event) => nativeAdapter.noteResponseStatus(event.status));
46
46
  };
47
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAExE,MAAM,UAAU,yBAAyB,CAAC,OAA0B;IACnE,OAAO,CAAC,EAAgB,EAAQ,EAAE;QACjC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAExB,EAAE,CAA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ACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAgB;IAC3D,MAAM,OAAO,GAAG;QACf,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE;QACnC,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE;QACzC,cAAc,EAAE,CAAC,KAAwB,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;KAC3E,CAAC;IACF,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9F,IAAI,YAAY;QAAE,8BAA8B,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["import { bindToProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { ExtensionAPI, ExtensionFactory } from \"../../types.ts\";\nimport { AnthropicNativeToolSearchAdapter, isMcpNativeToolSearchEnabled } from \"./native-search.ts\";\nimport { getToolSearchService, installScopedToolSearchService, ToolSearchService } from \"./service.ts\";\nimport { createToolSearchTool, TOOL_SEARCH_TOOL_NAME } from \"./tool.ts\";\n\nexport function createToolSearchExtension(service: ToolSearchService): ExtensionFactory {\n\treturn (pi: ExtensionAPI): void => {\n\t\tservice.bindRuntime(pi);\n\n\t\tpi.on(\"session_start\", (_event, ctx) => {\n\t\t\tservice.beginSession();\n\t\t\tservice.maybeRehydrateFromHistory(ctx.sessionManager.getEntries());\n\t\t});\n\t\tpi.on(\"context\", (event) => {\n\t\t\tservice.maybeRehydrateFromHistory(event.messages);\n\t\t});\n\t\tpi.registerLazyToolActivator((toolName) => service.activateTool(toolName));\n\t\tlet toolRegistered = false;\n\t\tservice.bindToolRegistrar(() => {\n\t\t\tif (toolRegistered) return;\n\t\t\ttoolRegistered = true;\n\t\t\tpi.registerTool(createToolSearchTool(service));\n\t\t});\n\n\t\tconst nativeAdapter = new AnthropicNativeToolSearchAdapter({\n\t\t\tenabled: () => {\n\t\t\t\tconst active = new Set(pi.getActiveTools());\n\t\t\t\treturn service\n\t\t\t\t\t.getCatalog()\n\t\t\t\t\t.some(\n\t\t\t\t\t\t(doc) =>\n\t\t\t\t\t\t\t(doc.source === \"extension\" && !active.has(doc.name)) ||\n\t\t\t\t\t\t\t(doc.source === \"mcp\" && isMcpNativeToolSearchEnabled()),\n\t\t\t\t\t);\n\t\t\t},\n\t\t\tgetCatalog: () => service.getCatalog(),\n\t\t\tgetToolDefinition: (name) => {\n\t\t\t\tconst tool = pi.getAllTools().find((candidate) => candidate.name === name);\n\t\t\t\treturn tool === undefined ? undefined : { description: tool.description, parameters: tool.parameters };\n\t\t\t},\n\t\t\tisDeferrable: (name) => {\n\t\t\t\tconst doc = service.getCatalog().find((candidate) => candidate.name === name);\n\t\t\t\tif (doc?.source === \"mcp\") return isMcpNativeToolSearchEnabled();\n\t\t\t\treturn doc?.source === \"extension\" && !pi.getActiveTools().includes(name);\n\t\t\t},\n\t\t\tsearchToolName: TOOL_SEARCH_TOOL_NAME,\n\t\t});\n\t\tpi.on(\"before_provider_request\", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model?.api, event.payload));\n\t\tpi.on(\"after_provider_response\", (event) => nativeAdapter.noteResponseStatus(event.status));\n\t};\n}\n\nfunction hasProviderScope(): boolean {\n\ttry {\n\t\tbindToProviderScope(() => undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport default function toolSearchExtension(pi: ExtensionAPI): void | Promise<void> {\n\tconst runtime = {\n\t\tgetAllTools: () => pi.getAllTools(),\n\t\tgetActiveTools: () => pi.getActiveTools(),\n\t\tsetActiveTools: (names: readonly string[]) => pi.setActiveTools([...names]),\n\t};\n\tconst sessionOwned = hasProviderScope();\n\tconst service = sessionOwned ? new ToolSearchService(runtime) : getToolSearchService(runtime);\n\tif (sessionOwned) installScopedToolSearchService(service);\n\treturn createToolSearchExtension(service)(pi);\n}\n\nexport { getToolSearchService, ToolSearchService } from \"./service.ts\";\nexport { createToolSearchTool, TOOL_SEARCH_TOOL_NAME } from \"./tool.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAEhF,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAExE,MAAM,UAAU,yBAAyB,CAAC,OAA0B;IACnE,OAAO,CAAC,EAAgB,EAAQ,EAAE;QACjC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAExB,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;YACtC,OAAO,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,CAAC,yBAAyB,CAAC,GAAG,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,OAAO,CAAC,yBAAyB,CAAC,KAAK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wB,EAAE,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;KAC3E,CAAC;IACF,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9F,IAAI,YAAY;QAAE,8BAA8B,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["import { bindToProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { ExtensionAPI, ExtensionFactory } from \"../../types.ts\";\nimport { AnthropicNativeToolSearchAdapter, isMcpNativeToolSearchEnabled } from \"./native-search.ts\";\nimport { getToolSearchService, installScopedToolSearchService, ToolSearchService } from \"./service.ts\";\nimport { createToolSearchTool, TOOL_SEARCH_TOOL_NAME } from \"./tool.ts\";\n\nexport function createToolSearchExtension(service: ToolSearchService): ExtensionFactory {\n\treturn (pi: ExtensionAPI): void => {\n\t\tservice.bindRuntime(pi);\n\n\t\tpi.on(\"session_start\", (_event, ctx) => {\n\t\t\tservice.beginSession();\n\t\t\tservice.maybeRehydrateFromHistory(ctx.sessionManager.getEntries());\n\t\t});\n\t\tpi.on(\"context\", (event) => {\n\t\t\tservice.maybeRehydrateFromHistory(event.messages);\n\t\t});\n\t\tpi.registerLazyToolActivator((toolName) => service.activateTool(toolName));\n\t\tlet toolRegistered = false;\n\t\tservice.bindToolRegistrar(() => {\n\t\t\tif (toolRegistered) return;\n\t\t\ttoolRegistered = true;\n\t\t\tpi.registerTool(createToolSearchTool(service));\n\t\t});\n\n\t\tconst nativeAdapter = new AnthropicNativeToolSearchAdapter({\n\t\t\tenabled: () => {\n\t\t\t\tconst active = new Set(pi.getActiveTools());\n\t\t\t\treturn service\n\t\t\t\t\t.getCatalog()\n\t\t\t\t\t.some(\n\t\t\t\t\t\t(doc) =>\n\t\t\t\t\t\t\t(doc.source === \"extension\" && !active.has(doc.name)) ||\n\t\t\t\t\t\t\t(doc.source === \"mcp\" && isMcpNativeToolSearchEnabled()),\n\t\t\t\t\t);\n\t\t\t},\n\t\t\tgetCatalog: () => service.getCatalog(),\n\t\t\tgetToolDefinition: (name) => {\n\t\t\t\tconst tool = pi.getAllTools().find((candidate) => candidate.name === name);\n\t\t\t\treturn tool === undefined ? undefined : { description: tool.description, parameters: tool.parameters };\n\t\t\t},\n\t\t\tisDeferrable: (name) => {\n\t\t\t\tconst doc = service.getCatalog().find((candidate) => candidate.name === name);\n\t\t\t\tif (doc?.source === \"mcp\") return isMcpNativeToolSearchEnabled();\n\t\t\t\treturn doc?.source === \"extension\" && !pi.getActiveTools().includes(name);\n\t\t\t},\n\t\t\tsearchToolName: TOOL_SEARCH_TOOL_NAME,\n\t\t});\n\t\tpi.on(\"before_provider_request\", (event, ctx) =>\n\t\t\tnativeAdapter.applyBeforeRequest(event.model ?? ctx.model, event.payload),\n\t\t);\n\t\tpi.on(\"after_provider_response\", (event) => nativeAdapter.noteResponseStatus(event.status));\n\t};\n}\n\nfunction hasProviderScope(): boolean {\n\ttry {\n\t\tbindToProviderScope(() => undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport default function toolSearchExtension(pi: ExtensionAPI): void | Promise<void> {\n\tconst runtime = {\n\t\tgetAllTools: () => pi.getAllTools(),\n\t\tgetActiveTools: () => pi.getActiveTools(),\n\t\tsetActiveTools: (names: readonly string[]) => pi.setActiveTools([...names]),\n\t};\n\tconst sessionOwned = hasProviderScope();\n\tconst service = sessionOwned ? new ToolSearchService(runtime) : getToolSearchService(runtime);\n\tif (sessionOwned) installScopedToolSearchService(service);\n\treturn createToolSearchExtension(service)(pi);\n}\n\nexport { getToolSearchService, ToolSearchService } from \"./service.ts\";\nexport { createToolSearchTool, TOOL_SEARCH_TOOL_NAME } from \"./tool.ts\";\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { ToolSearchDocument } from "./engine/document.ts";
2
+ import { type AnthropicToolSearchTarget } from "./native-support.ts";
2
3
  export declare const ANTHROPIC_TOOL_SEARCH_TYPE = "tool_search_tool_bm25_20251119";
3
4
  export declare const ANTHROPIC_TOOL_SEARCH_NAME = "tool_search_tool_bm25";
4
5
  /** Anthropic caps a request at 10k tools; beyond that native search is invalid. */
@@ -27,11 +28,15 @@ export interface AnthropicNativeInjectionConfig {
27
28
  * local search tool, never combine defer_loading with cache_control, keep at
28
29
  * least one non-deferred tool, and skip entirely above the 10k tool cap.
29
30
  */
30
- export declare function addAnthropicNativeToolSearch(api: string | undefined, payload: unknown, config: AnthropicNativeInjectionConfig): unknown;
31
- /** `tool_reference` blocks emitted inside a tool_result so the API expands the referenced tools. */
31
+ export declare function addAnthropicNativeToolSearch(target: AnthropicToolSearchTarget, payload: unknown, config: AnthropicNativeInjectionConfig): unknown;
32
+ /**
33
+ * `tool_reference` blocks emitted inside a tool_result so the API expands the
34
+ * referenced tools. Anthropic names the target through `tool_name`; a block
35
+ * carrying `name` is rejected as a malformed content block.
36
+ */
32
37
  export declare function buildToolReferenceBlocks(names: readonly string[]): {
33
38
  type: "tool_reference";
34
- name: string;
39
+ tool_name: string;
35
40
  }[];
36
41
  export interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {
37
42
  /** Resolved provider/config gate. */
@@ -43,7 +48,7 @@ export interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConf
43
48
  export declare class AnthropicNativeToolSearchAdapter {
44
49
  #private;
45
50
  constructor(deps: AnthropicNativeAdapterDeps);
46
- applyBeforeRequest(api: string | undefined, payload: unknown): unknown;
51
+ applyBeforeRequest(target: AnthropicToolSearchTarget, payload: unknown): unknown;
47
52
  noteResponseStatus(status: number): void;
48
53
  get disabled(): boolean;
49
54
  get fallbackReason(): string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM/D,eAAO,MAAM,0BAA0B,mCAAmC,CAAC;AAC3E,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAClE,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,KAAK,uBAAuB,GAAG,MAAM,OAAO,CAAC;AAK7C,gGAAgG;AAChG,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAGlF;AAED,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,8BAA8B;IAC9C,gFAAgF;IAChF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,gFAAgF;IAChF,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACrD,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,SAAS,kBAAkB,EAAE,CAAC;IAC1D,iFAAiF;IACjF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,oBAAoB,GAAG,SAAS,CAAC;CACpF;AAMD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,8BAA8B,GACpC,OAAO,CAYT;AAkCD,oGAAoG;AACpG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAE7G;AAED,MAAM,WAAW,0BAA2B,SAAQ,8BAA8B;IACjF,qCAAqC;IACrC,OAAO,IAAI,OAAO,CAAC;IACnB,gEAAgE;IAChE,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,mFAAmF;AACnF,qBAAa,gCAAgC;;gBAMhC,IAAI,EAAE,0BAA0B;IAI5C,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAQtE,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQxC,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;CACD"}
1
+ {"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,KAAK,yBAAyB,EAAqC,MAAM,qBAAqB,CAAC;AAMxG,eAAO,MAAM,0BAA0B,mCAAmC,CAAC;AAC3E,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAClE,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,KAAK,uBAAuB,GAAG,MAAM,OAAO,CAAC;AAK7C,gGAAgG;AAChG,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAGlF;AAED,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QA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ooks";
2
+ import { supportsAnthropicNativeToolSearch } from "./native-support.js";
2
3
  // Anthropic Messages supports native BM25 tool search through request payload
3
4
  // injection alone. OpenAI native client-mode search remains intentionally out of
4
5
  // scope because it requires a provider-layer seam.
@@ -25,8 +26,8 @@ function isRecord(value) {
25
26
  * local search tool, never combine defer_loading with cache_control, keep at
26
27
  * least one non-deferred tool, and skip entirely above the 10k tool cap.
27
28
  */
28
- export function addAnthropicNativeToolSearch(api, payload, config) {
29
- if (api !== "anthropic-messages" || !isRecord(payload))
29
+ export function addAnthropicNativeToolSearch(target, payload, config) {
30
+ if (!supportsAnthropicNativeToolSearch(target) || !isRecord(payload))
30
31
  return payload;
31
32
  const tools = Array.isArray(payload.tools) ? payload.tools : [];
32
33
  const injected = injectInactiveCatalogTools(tools, config);
@@ -77,9 +78,13 @@ function maybeDefer(tool, config) {
77
78
  return tool;
78
79
  return { ...tool, defer_loading: true };
79
80
  }
80
- /** `tool_reference` blocks emitted inside a tool_result so the API expands the referenced tools. */
81
+ /**
82
+ * `tool_reference` blocks emitted inside a tool_result so the API expands the
83
+ * referenced tools. Anthropic names the target through `tool_name`; a block
84
+ * carrying `name` is rejected as a malformed content block.
85
+ */
81
86
  export function buildToolReferenceBlocks(names) {
82
- return names.map((name) => ({ type: "tool_reference", name }));
87
+ return names.map((name) => ({ type: "tool_reference", tool_name: name }));
83
88
  }
84
89
  /** Session-scoped request injector with permanent 400 fallback for the session. */
85
90
  export class AnthropicNativeToolSearchAdapter {
@@ -90,11 +95,11 @@ export class AnthropicNativeToolSearchAdapter {
90
95
  constructor(deps) {
91
96
  this.#deps = deps;
92
97
  }
93
- applyBeforeRequest(api, payload) {
98
+ applyBeforeRequest(target, payload) {
94
99
  this.#injectedLastRequest = false;
95
100
  if (this.#disabled || !this.#deps.enabled())
96
101
  return payload;
97
- const next = addAnthropicNativeToolSearch(api, payload, this.#deps);
102
+ const next = addAnthropicNativeToolSearch(target, payload, this.#deps);
98
103
  this.#injectedLastRequest = next !== payload;
99
104
  return next;
100
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"native-search.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,8EAA8E;AAC9E,iFAAiF;AACjF,mDAAmD;AAEnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAIzC,MAAM,6BAA6B,GAAG,IAAI,iBAAiB,EAA2B,CAAC;AACvF,IAAI,uBAAuB,GAA4B,GAAG,EAAE,CAAC,KAAK,CAAC;AAEnE,gGAAgG;AAChG,MAAM,UAAU,8BAA8B,CAAC,IAA6B;IAC3E,uBAAuB,GAAG,IAAI,CAAC;IAC/B,6BAA6B,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC3C,OAAO,CAAC,6BAA6B,CAAC,QAAQ,EAAE,IAAI,uBAAuB,CAAC,EAAE,CAAC;AAChF,CAAC;AAkBD,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC3C,GAAuB,EACvB,OAAgB,EAChB,MAAsC;IAEtC,IAAI,GAAG,KAAK,oBAAoB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IACvE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,MAAM,QAAQ,GAAG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;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { ToolSearchDocument } from \"./engine/document.ts\";\n\n// Anthropic Messages supports native BM25 tool search through request payload\n// injection alone. OpenAI native client-mode search remains intentionally out of\n// scope because it requires a provider-layer seam.\n\nexport const ANTHROPIC_TOOL_SEARCH_TYPE = \"tool_search_tool_bm25_20251119\";\nexport const ANTHROPIC_TOOL_SEARCH_NAME = \"tool_search_tool_bm25\";\n/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */\nexport const ANTHROPIC_MAX_TOOLS = 10000;\n\ntype McpNativeToolSearchGate = () => boolean;\n\nconst scopedMcpNativeToolSearchGate = new AsyncLocalStorage<McpNativeToolSearchGate>();\nlet mcpNativeToolSearchGate: McpNativeToolSearchGate = () => false;\n\n/** Bind the MCP-owned user setting without moving MCP configuration into the shared builtin. */\nexport function installMcpNativeToolSearchGate(gate: McpNativeToolSearchGate): void {\n\tmcpNativeToolSearchGate = gate;\n\tscopedMcpNativeToolSearchGate.enterWith(gate);\n}\n\nexport function isMcpNativeToolSearchEnabled(): boolean {\n\treturn (scopedMcpNativeToolSearchGate.getStore() ?? mcpNativeToolSearchGate)();\n}\n\nexport interface NativeToolDefinition {\n\treadonly description?: string;\n\treadonly parameters?: unknown;\n}\n\nexport interface AnthropicNativeInjectionConfig {\n\t/** Never defer this tool (our custom tool_search), and it is non-deferrable. */\n\treadonly searchToolName?: string;\n\t/** True only for catalog tools eligible for native deferral in this request. */\n\treadonly isDeferrable: (toolName: string) => boolean;\n\t/** Current searchable catalog. Omit when only transforming resident tools. */\n\treadonly getCatalog?: () => readonly ToolSearchDocument[];\n\t/** Resolve the winning registered definition used to inject inactive schemas. */\n\treadonly getToolDefinition?: (toolName: string) => NativeToolDefinition | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Pure payload transform. Injects eligible inactive catalog schemas, adds exactly\n * one native search tool, and enforces Anthropic's HARD RULES: never defer the\n * local search tool, never combine defer_loading with cache_control, keep at\n * least one non-deferred tool, and skip entirely above the 10k tool cap.\n */\nexport function addAnthropicNativeToolSearch(\n\tapi: string | undefined,\n\tpayload: unknown,\n\tconfig: AnthropicNativeInjectionConfig,\n): unknown {\n\tif (api !== \"anthropic-messages\" || !isRecord(payload)) return payload;\n\tconst tools = Array.isArray(payload.tools) ? payload.tools : [];\n\tconst injected = injectInactiveCatalogTools(tools, config);\n\tif (injected.length > ANTHROPIC_MAX_TOOLS) return payload;\n\tconst deferred = injected.map((tool) => maybeDefer(tool, config));\n\tconst hasSearchTool = deferred.some((tool) => isRecord(tool) && tool.type === ANTHROPIC_TOOL_SEARCH_TYPE);\n\tconst nextTools = hasSearchTool\n\t\t? deferred\n\t\t: [...deferred, { type: ANTHROPIC_TOOL_SEARCH_TYPE, name: ANTHROPIC_TOOL_SEARCH_NAME }];\n\tif (nextTools.length > ANTHROPIC_MAX_TOOLS) return payload;\n\treturn { ...payload, tools: nextTools };\n}\n\nfunction injectInactiveCatalogTools(tools: readonly unknown[], config: AnthropicNativeInjectionConfig): unknown[] {\n\tconst catalog = config.getCatalog?.() ?? [];\n\tconst residentNames = new Set(\n\t\ttools.flatMap((tool) => (isRecord(tool) && typeof tool.name === \"string\" ? [tool.name] : [])),\n\t);\n\tconst injected: unknown[] = [...tools];\n\tfor (const doc of catalog) {\n\t\tif (doc.name === config.searchToolName || residentNames.has(doc.name) || !config.isDeferrable(doc.name)) continue;\n\t\tconst definition = config.getToolDefinition?.(doc.name);\n\t\tif (definition?.parameters === undefined) continue;\n\t\tinjected.push({\n\t\t\tname: doc.name,\n\t\t\tdescription: definition.description ?? doc.description ?? doc.label,\n\t\t\tinput_schema: definition.parameters,\n\t\t\tdefer_loading: true,\n\t\t});\n\t\tresidentNames.add(doc.name);\n\t}\n\treturn injected;\n}\n\nfunction maybeDefer(tool: unknown, config: AnthropicNativeInjectionConfig): unknown {\n\tif (!isRecord(tool)) return tool;\n\tconst name = typeof tool.name === \"string\" ? tool.name : undefined;\n\tif (name === undefined) return tool;\n\tif (name === config.searchToolName) return tool;\n\tif (!config.isDeferrable(name)) return tool;\n\tif (\"cache_control\" in tool) return tool;\n\tif (tool.defer_loading === true) return tool;\n\treturn { ...tool, defer_loading: true };\n}\n\n/** `tool_reference` blocks emitted inside a tool_result so the API expands the referenced tools. */\nexport function buildToolReferenceBlocks(names: readonly string[]): { type: \"tool_reference\"; name: string }[] {\n\treturn names.map((name) => ({ type: \"tool_reference\", name }));\n}\n\nexport interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {\n\t/** Resolved provider/config gate. */\n\tenabled(): boolean;\n\t/** Invoked once when a 400 forces the local-search fallback. */\n\tonFallback?(reason: string): void;\n}\n\n/** Session-scoped request injector with permanent 400 fallback for the session. */\nexport class AnthropicNativeToolSearchAdapter {\n\t#disabled = false;\n\t#injectedLastRequest = false;\n\t#fallbackReason: string | null = null;\n\treadonly #deps: AnthropicNativeAdapterDeps;\n\n\tconstructor(deps: AnthropicNativeAdapterDeps) {\n\t\tthis.#deps = deps;\n\t}\n\n\tapplyBeforeRequest(api: string | undefined, payload: unknown): unknown {\n\t\tthis.#injectedLastRequest = false;\n\t\tif (this.#disabled || !this.#deps.enabled()) return payload;\n\t\tconst next = addAnthropicNativeToolSearch(api, payload, this.#deps);\n\t\tthis.#injectedLastRequest = next !== payload;\n\t\treturn next;\n\t}\n\n\tnoteResponseStatus(status: number): void {\n\t\tif (status !== 400 || !this.#injectedLastRequest || this.#disabled) return;\n\t\tthis.#disabled = true;\n\t\tthis.#fallbackReason =\n\t\t\t\"Anthropic returned 400 for native tool-search; disabled it and fell back to local tool_search for this session.\";\n\t\tthis.#deps.onFallback?.(this.#fallbackReason);\n\t}\n\n\tget disabled(): boolean {\n\t\treturn this.#disabled;\n\t}\n\n\tget fallbackReason(): string | null {\n\t\treturn this.#fallbackReason;\n\t}\n}\n"]}
1
+ {"version":3,"file":"native-search.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAkC,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAExG,8EAA8E;AAC9E,iFAAiF;AACjF,mDAAmD;AAEnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAIzC,MAAM,6BAA6B,GAAG,IAAI,iBAAiB,EAA2B,CAAC;AACvF,IAAI,uBAAuB,GAA4B,GAAG,EAAE,CAAC,KAAK,CAAC;AAEnE,gGAAgG;AAChG,MAAM,UAAU,8BAA8B,CAAC,IAA6B;IAC3E,uBAAuB,GAAG,IAAI,CAAC;IAC/B,6BAA6B,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC3C,OAAO,CAAC,6BAA6B,CAAC,QAAQ,EAAE,IAAI,uBAAuB,CAAC,EAAE,CAAC;AAChF,CAAC;AAkBD,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC3C,MAAiC,EACjC,OAAgB,EAChB,MAAsC;IAEtC,IAAI,CAAC,iCAAiC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IACrF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAA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AAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,cAAc;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { ToolSearchDocument } from \"./engine/document.ts\";\nimport { type AnthropicToolSearchTarget, supportsAnthropicNativeToolSearch } from \"./native-support.ts\";\n\n// Anthropic Messages supports native BM25 tool search through request payload\n// injection alone. OpenAI native client-mode search remains intentionally out of\n// scope because it requires a provider-layer seam.\n\nexport const ANTHROPIC_TOOL_SEARCH_TYPE = \"tool_search_tool_bm25_20251119\";\nexport const ANTHROPIC_TOOL_SEARCH_NAME = \"tool_search_tool_bm25\";\n/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */\nexport const ANTHROPIC_MAX_TOOLS = 10000;\n\ntype McpNativeToolSearchGate = () => boolean;\n\nconst scopedMcpNativeToolSearchGate = new AsyncLocalStorage<McpNativeToolSearchGate>();\nlet mcpNativeToolSearchGate: McpNativeToolSearchGate = () => false;\n\n/** Bind the MCP-owned user setting without moving MCP configuration into the shared builtin. */\nexport function installMcpNativeToolSearchGate(gate: McpNativeToolSearchGate): void {\n\tmcpNativeToolSearchGate = gate;\n\tscopedMcpNativeToolSearchGate.enterWith(gate);\n}\n\nexport function isMcpNativeToolSearchEnabled(): boolean {\n\treturn (scopedMcpNativeToolSearchGate.getStore() ?? mcpNativeToolSearchGate)();\n}\n\nexport interface NativeToolDefinition {\n\treadonly description?: string;\n\treadonly parameters?: unknown;\n}\n\nexport interface AnthropicNativeInjectionConfig {\n\t/** Never defer this tool (our custom tool_search), and it is non-deferrable. */\n\treadonly searchToolName?: string;\n\t/** True only for catalog tools eligible for native deferral in this request. */\n\treadonly isDeferrable: (toolName: string) => boolean;\n\t/** Current searchable catalog. Omit when only transforming resident tools. */\n\treadonly getCatalog?: () => readonly ToolSearchDocument[];\n\t/** Resolve the winning registered definition used to inject inactive schemas. */\n\treadonly getToolDefinition?: (toolName: string) => NativeToolDefinition | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Pure payload transform. Injects eligible inactive catalog schemas, adds exactly\n * one native search tool, and enforces Anthropic's HARD RULES: never defer the\n * local search tool, never combine defer_loading with cache_control, keep at\n * least one non-deferred tool, and skip entirely above the 10k tool cap.\n */\nexport function addAnthropicNativeToolSearch(\n\ttarget: AnthropicToolSearchTarget,\n\tpayload: unknown,\n\tconfig: AnthropicNativeInjectionConfig,\n): unknown {\n\tif (!supportsAnthropicNativeToolSearch(target) || !isRecord(payload)) return payload;\n\tconst tools = Array.isArray(payload.tools) ? payload.tools : [];\n\tconst injected = injectInactiveCatalogTools(tools, config);\n\tif (injected.length > ANTHROPIC_MAX_TOOLS) return payload;\n\tconst deferred = injected.map((tool) => maybeDefer(tool, config));\n\tconst hasSearchTool = deferred.some((tool) => isRecord(tool) && tool.type === ANTHROPIC_TOOL_SEARCH_TYPE);\n\tconst nextTools = hasSearchTool\n\t\t? deferred\n\t\t: [...deferred, { type: ANTHROPIC_TOOL_SEARCH_TYPE, name: ANTHROPIC_TOOL_SEARCH_NAME }];\n\tif (nextTools.length > ANTHROPIC_MAX_TOOLS) return payload;\n\treturn { ...payload, tools: nextTools };\n}\n\nfunction injectInactiveCatalogTools(tools: readonly unknown[], config: AnthropicNativeInjectionConfig): unknown[] {\n\tconst catalog = config.getCatalog?.() ?? [];\n\tconst residentNames = new Set(\n\t\ttools.flatMap((tool) => (isRecord(tool) && typeof tool.name === \"string\" ? [tool.name] : [])),\n\t);\n\tconst injected: unknown[] = [...tools];\n\tfor (const doc of catalog) {\n\t\tif (doc.name === config.searchToolName || residentNames.has(doc.name) || !config.isDeferrable(doc.name)) continue;\n\t\tconst definition = config.getToolDefinition?.(doc.name);\n\t\tif (definition?.parameters === undefined) continue;\n\t\tinjected.push({\n\t\t\tname: doc.name,\n\t\t\tdescription: definition.description ?? doc.description ?? doc.label,\n\t\t\tinput_schema: definition.parameters,\n\t\t\tdefer_loading: true,\n\t\t});\n\t\tresidentNames.add(doc.name);\n\t}\n\treturn injected;\n}\n\nfunction maybeDefer(tool: unknown, config: AnthropicNativeInjectionConfig): unknown {\n\tif (!isRecord(tool)) return tool;\n\tconst name = typeof tool.name === \"string\" ? tool.name : undefined;\n\tif (name === undefined) return tool;\n\tif (name === config.searchToolName) return tool;\n\tif (!config.isDeferrable(name)) return tool;\n\tif (\"cache_control\" in tool) return tool;\n\tif (tool.defer_loading === true) return tool;\n\treturn { ...tool, defer_loading: true };\n}\n\n/**\n * `tool_reference` blocks emitted inside a tool_result so the API expands the\n * referenced tools. Anthropic names the target through `tool_name`; a block\n * carrying `name` is rejected as a malformed content block.\n */\nexport function buildToolReferenceBlocks(names: readonly string[]): { type: \"tool_reference\"; tool_name: string }[] {\n\treturn names.map((name) => ({ type: \"tool_reference\", tool_name: name }));\n}\n\nexport interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {\n\t/** Resolved provider/config gate. */\n\tenabled(): boolean;\n\t/** Invoked once when a 400 forces the local-search fallback. */\n\tonFallback?(reason: string): void;\n}\n\n/** Session-scoped request injector with permanent 400 fallback for the session. */\nexport class AnthropicNativeToolSearchAdapter {\n\t#disabled = false;\n\t#injectedLastRequest = false;\n\t#fallbackReason: string | null = null;\n\treadonly #deps: AnthropicNativeAdapterDeps;\n\n\tconstructor(deps: AnthropicNativeAdapterDeps) {\n\t\tthis.#deps = deps;\n\t}\n\n\tapplyBeforeRequest(target: AnthropicToolSearchTarget, payload: unknown): unknown {\n\t\tthis.#injectedLastRequest = false;\n\t\tif (this.#disabled || !this.#deps.enabled()) return payload;\n\t\tconst next = addAnthropicNativeToolSearch(target, payload, this.#deps);\n\t\tthis.#injectedLastRequest = next !== payload;\n\t\treturn next;\n\t}\n\n\tnoteResponseStatus(status: number): void {\n\t\tif (status !== 400 || !this.#injectedLastRequest || this.#disabled) return;\n\t\tthis.#disabled = true;\n\t\tthis.#fallbackReason =\n\t\t\t\"Anthropic returned 400 for native tool-search; disabled it and fell back to local tool_search for this session.\";\n\t\tthis.#deps.onFallback?.(this.#fallbackReason);\n\t}\n\n\tget disabled(): boolean {\n\t\treturn this.#disabled;\n\t}\n\n\tget fallbackReason(): string | null {\n\t\treturn this.#fallbackReason;\n\t}\n}\n"]}