@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 +1 @@
1
- {"version":3,"file":"auth-storage.d.ts","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,gBAAgB,EAGhB,oBAAoB,EAEpB,UAAU,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAEN,KAAK,cAAc,EAKnB,MAAM,uCAAuC,CAAC;AAY/C,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,aAAa,G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OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAuBhG,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAIjE,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIjD,iBAAiB,IAAI,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAalD,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAe9E,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK9B,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB;CAgBzB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAyC,GACjD,UAAU,GAAG,SAAS,CAOxB"}
@@ -2,7 +2,6 @@
2
2
  * CredentialStore implementation backed by auth.json.
3
3
  * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.
4
4
  */
5
- import { setTimeout as sleep } from "node:timers/promises";
6
5
  import { findEnvKeys, getEnvApiKey } from "@earendil-works/pi-ai";
7
6
  import { appendLoginSlot, listSlots, removeSlot, upsertSlot, } from "@earendil-works/pi-ai/auth/pool/slots";
8
7
  import { builtinProviders } from "@earendil-works/pi-ai/providers/all";
@@ -13,7 +12,7 @@ import { getAgentDir } from "../config.js";
13
12
  import { raceWithAbortSignal } from "../utils/abort.js";
14
13
  import { getFileRevision, normalizePath } from "../utils/paths.js";
15
14
  import { stripBom } from "../utils/text.js";
16
- import { FILE_STORAGE_LOCK_OPTIONS } from "./lockfile-policy.js";
15
+ import { CredentialStoreBusyError, FILE_STORAGE_LOCK_OPTIONS, FILE_STORAGE_LOCK_RETRY_BUDGET_MS, FILE_STORAGE_LOCK_RETRY_MAX_DELAY_MS, FILE_STORAGE_LOCK_RETRY_MIN_DELAY_MS, FILE_STORAGE_SYNC_LOCK_BUDGET_MS, isLockError, } from "./lockfile-policy.js";
17
16
  import { isCommandConfigValue, resolveConfigValue } from "./resolve-config-value.js";
18
17
  // The mode applies only on creation so administrator-managed modes and ACLs remain intact.
19
18
  const AUTH_FILE_WRITE_OPTIONS = { encoding: "utf-8", mode: 0o600 };
@@ -34,29 +33,25 @@ export class FileAuthStorageBackend {
34
33
  }
35
34
  }
36
35
  acquireLockSyncWithRetry(path) {
37
- const maxAttempts = 10;
38
- const delayMs = 20;
39
- let lastError;
40
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
36
+ const startedAt = Date.now();
37
+ let attempt = 0;
38
+ while (true) {
41
39
  try {
42
- return lockfile.lockSync(path, { ...FILE_STORAGE_LOCK_OPTIONS });
40
+ return lockfile.lockSync(path, { ...FILE_STORAGE_LOCK_OPTIONS, retries: 0 });
43
41
  }
44
42
  catch (error) {
45
- const code = typeof error === "object" && error !== null && "code" in error
46
- ? String(error.code)
47
- : undefined;
48
- if (code !== "ELOCKED" || attempt === maxAttempts) {
43
+ if (!isLockError(error))
49
44
  throw error;
45
+ const waitedMs = Date.now() - startedAt;
46
+ if (waitedMs >= FILE_STORAGE_SYNC_LOCK_BUDGET_MS) {
47
+ throw new CredentialStoreBusyError(path, waitedMs, error);
50
48
  }
51
- lastError = error;
52
- // Atomics.wait sleeps the thread without spinning, so contended lock retries
53
- // no longer burn a CPU core per waiter (same root cause as the settings-lock
54
- // TUI freeze fixed in #1056). Stays synchronous to keep callers unchanged.
49
+ const delayMs = Math.min(FILE_STORAGE_LOCK_RETRY_MIN_DELAY_MS * 2 ** attempt, FILE_STORAGE_LOCK_RETRY_MAX_DELAY_MS, FILE_STORAGE_SYNC_LOCK_BUDGET_MS - waitedMs);
50
+ attempt++;
55
51
  const sleeper = new Int32Array(new SharedArrayBuffer(4));
56
52
  Atomics.wait(sleeper, 0, 0, delayMs);
57
53
  }
58
54
  }
59
- throw lastError ?? new Error("Failed to acquire auth storage lock");
60
55
  }
61
56
  withLock(fn) {
62
57
  this.ensureParentDir();
@@ -78,42 +73,37 @@ export class FileAuthStorageBackend {
78
73
  }
79
74
  }
80
75
  async acquireLockAsync(signal, onCompromised) {
81
- const staleMs = FILE_STORAGE_LOCK_OPTIONS.stale;
82
- const maxDelayMs = 2_000;
83
- const deadline = Date.now() + staleMs;
84
- let retry = 0;
76
+ signal?.throwIfAborted();
77
+ const startedAt = Date.now();
78
+ let attempt = 0;
79
+ // The retry loop stays here rather than delegating to proper-lockfile's own
80
+ // `retries`, so an abort is observed between attempts instead of after the
81
+ // whole budget, and `onCompromised` is rebound per attempt.
85
82
  while (true) {
86
- signal?.throwIfAborted();
87
- let release;
88
83
  try {
89
- release = await lockfile.lock(this.authPath, {
84
+ const release = await lockfile.lock(this.authPath, {
90
85
  ...FILE_STORAGE_LOCK_OPTIONS,
91
86
  retries: 0,
92
87
  onCompromised,
93
88
  });
89
+ if (signal?.aborted) {
90
+ await release();
91
+ signal.throwIfAborted();
92
+ }
93
+ return release;
94
94
  }
95
95
  catch (error) {
96
96
  signal?.throwIfAborted();
97
- const code = typeof error === "object" && error !== null && "code" in error
98
- ? String(error.code)
99
- : undefined;
100
- const remainingMs = deadline - Date.now();
101
- if (code !== "ELOCKED" || remainingMs <= 0)
97
+ if (!isLockError(error))
102
98
  throw error;
103
- const baseDelayMs = Math.min(10 * 2 ** retry, maxDelayMs / 2);
104
- retry++;
105
- const delayMs = Math.min(Math.round(baseDelayMs * (1 + Math.random())), remainingMs);
106
- if (signal)
107
- await sleep(delayMs, undefined, { signal });
108
- else
109
- await sleep(delayMs);
110
- continue;
111
- }
112
- if (signal?.aborted) {
113
- await release();
114
- signal.throwIfAborted();
99
+ const waitedMs = Date.now() - startedAt;
100
+ if (waitedMs >= FILE_STORAGE_LOCK_RETRY_BUDGET_MS) {
101
+ throw new CredentialStoreBusyError(this.authPath, waitedMs, error);
102
+ }
103
+ const delayMs = Math.min(FILE_STORAGE_LOCK_RETRY_MIN_DELAY_MS * 2 ** attempt, FILE_STORAGE_LOCK_RETRY_MAX_DELAY_MS, FILE_STORAGE_LOCK_RETRY_BUDGET_MS - waitedMs);
104
+ attempt++;
105
+ await raceWithAbortSignal(new Promise((resolve) => setTimeout(resolve, delayMs)), signal);
115
106
  }
116
- return release;
117
107
  }
118
108
  }
119
109
  async withLockAsync(fn, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAc3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EACN,eAAe,EAEf,SAAS,EAET,UAAU,EACV,UAAU,GACV,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAqBrF,2FAA2F;AAC3F,MAAM,uBAAuB,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,K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AAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * CredentialStore implementation backed by auth.json.\n * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.\n */\n\nimport { setTimeout as sleep } from \"node:timers/promises\";\nimport type {\n\tApiKeyCredential,\n\tAuthEvent,\n\tAuthInteraction,\n\tAuthOperationOptions,\n\tAuthPrompt,\n\tCredential,\n\tCredentialInfo,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tOAuthLoginCallbacks,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys, getEnvApiKey } from \"@earendil-works/pi-ai\";\nimport {\n\tappendLoginSlot,\n\ttype CredentialSlot,\n\tlistSlots,\n\ttype PooledCredential,\n\tremoveSlot,\n\tupsertSlot,\n} from \"@earendil-works/pi-ai/auth/pool/slots\";\nimport { builtinProviders } from \"@earendil-works/pi-ai/providers/all\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../config.ts\";\nimport { raceWithAbortSignal } from \"../utils/abort.ts\";\nimport { getFileRevision, normalizePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { FILE_STORAGE_LOCK_OPTIONS } from \"./lockfile-policy.ts\";\nimport { isCommandConfigValue, resolveConfigValue } from \"./resolve-config-value.ts\";\n\ntype AuthStorageData = Record<string, Credential>;\n\nexport type AuthCredential = Credential;\nexport type { ApiKeyCredential, OAuthCredential };\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport interface GetApiKeyOptions {\n\tincludeFallback?: boolean;\n}\n\ntype LockResult<T> = {\n\tresult: T;\n\tnext?: string;\n};\n\n// The mode applies only on creation so administrator-managed modes and ACLs remain intact.\nconst AUTH_FILE_WRITE_OPTIONS = { encoding: \"utf-8\", mode: 0o600 } as const;\n\ntype AuthFileReload = {\n\tcontroller: AbortController;\n\tpromise: Promise<AuthStorageData>;\n\treaders: number;\n};\n\ntype AuthFileReadState = {\n\tdata: AuthStorageData;\n\trevision?: string;\n\treload?: AuthFileReload;\n};\n\nlet sharedAuthFileReadState: { authPath: string; readState: AuthFileReadState } | undefined;\n\nexport interface AuthStorageBackend {\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T;\n\twithLockAsync<T>(\n\t\tfn: (current: string | undefined) => Promise<LockResult<T>>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<T>;\n}\n\nexport class FileAuthStorageBackend implements AuthStorageBackend {\n\tprivate authPath: string;\n\n\tconstructor(authPath: string = join(getAgentDir(), \"auth.json\")) {\n\t\tthis.authPath = normalizePath(authPath);\n\t}\n\n\tprivate ensureParentDir(): void {\n\t\tconst dir = dirname(this.authPath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t\t}\n\t}\n\n\tprivate ensureFileExists(): void {\n\t\tif (!existsSync(this.authPath)) {\n\t\t\twriteFileSync(this.authPath, \"{}\", AUTH_FILE_WRITE_OPTIONS);\n\t\t}\n\t}\n\n\tprivate acquireLockSyncWithRetry(path: string): () => void {\n\t\tconst maxAttempts = 10;\n\t\tconst delayMs = 20;\n\t\tlet lastError: unknown;\n\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn lockfile.lockSync(path, { ...FILE_STORAGE_LOCK_OPTIONS });\n\t\t\t} catch (error) {\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tlastError = error;\n\t\t\t\t// Atomics.wait sleeps the thread without spinning, so contended lock retries\n\t\t\t\t// no longer burn a CPU core per waiter (same root cause as the settings-lock\n\t\t\t\t// TUI freeze fixed in #1056). Stays synchronous to keep callers unchanged.\n\t\t\t\tconst sleeper = new Int32Array(new SharedArrayBuffer(4));\n\t\t\t\tAtomics.wait(sleeper, 0, 0, delayMs);\n\t\t\t}\n\t\t}\n\n\t\tthrow (lastError as Error) ?? new Error(\"Failed to acquire auth storage lock\");\n\t}\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => void) | undefined;\n\t\ttry {\n\t\t\trelease = this.acquireLockSyncWithRetry(this.authPath);\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = fn(current);\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t}\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\trelease();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async acquireLockAsync(\n\t\tsignal: AbortSignal | undefined,\n\t\tonCompromised: (error: Error) => void,\n\t): Promise<() => Promise<void>> {\n\t\tconst staleMs = FILE_STORAGE_LOCK_OPTIONS.stale;\n\t\tconst maxDelayMs = 2_000;\n\t\tconst deadline = Date.now() + staleMs;\n\t\tlet retry = 0;\n\t\twhile (true) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tlet release: (() => Promise<void>) | undefined;\n\t\t\ttry {\n\t\t\t\trelease = await lockfile.lock(this.authPath, {\n\t\t\t\t\t...FILE_STORAGE_LOCK_OPTIONS,\n\t\t\t\t\tretries: 0,\n\t\t\t\t\tonCompromised,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tconst code =\n\t\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t\t: undefined;\n\t\t\t\tconst remainingMs = deadline - Date.now();\n\t\t\t\tif (code !== \"ELOCKED\" || remainingMs <= 0) throw error;\n\t\t\t\tconst baseDelayMs = Math.min(10 * 2 ** retry, maxDelayMs / 2);\n\t\t\t\tretry++;\n\t\t\t\tconst delayMs = Math.min(Math.round(baseDelayMs * (1 + Math.random())), remainingMs);\n\t\t\t\tif (signal) await sleep(delayMs, undefined, { signal });\n\t\t\t\telse await sleep(delayMs);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (signal?.aborted) {\n\t\t\t\tawait release();\n\t\t\t\tsignal.throwIfAborted();\n\t\t\t}\n\t\t\treturn release;\n\t\t}\n\t}\n\n\tasync withLockAsync<T>(\n\t\tfn: (current: string | undefined) => Promise<LockResult<T>>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<T> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => Promise<void>) | undefined;\n\t\tlet lockCompromised = false;\n\t\tlet lockCompromisedError: Error | undefined;\n\t\tconst throwIfCompromised = () => {\n\t\t\tif (lockCompromised) {\n\t\t\t\tthrow lockCompromisedError ?? new Error(\"Auth storage lock was compromised\");\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\trelease = await this.acquireLockAsync(options?.signal, (error) => {\n\t\t\t\tlockCompromised = true;\n\t\t\t\tlockCompromisedError = error;\n\t\t\t});\n\n\t\t\tthrowIfCompromised();\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = await fn(current);\n\t\t\tthrowIfCompromised();\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t}\n\t\t\tthrowIfCompromised();\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\ttry {\n\t\t\t\t\tawait release();\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore unlock errors when lock is compromised.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class ReadOnlyAuthStorage implements CredentialStore {\n\tprivate readonly authPath: string;\n\tprivate data: AuthStorageData | undefined;\n\n\tconstructor(authPath: string = join(getAgentDir(), \"auth.json\")) {\n\t\tthis.authPath = normalizePath(authPath);\n\t}\n\n\tprivate load(): AuthStorageData {\n\t\tif (this.data) return this.data;\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripBom(readFileSync(this.authPath, \"utf-8\")));\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n\t\t\t\tthis.data = {};\n\t\t\t\treturn this.data;\n\t\t\t}\n\t\t\tthrow new Error(`Failed to read auth.json: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\t\tthrow new Error(\"Invalid auth.json: expected an object\");\n\t\t}\n\t\tfor (const [providerId, credential] of Object.entries(parsed)) {\n\t\t\tif (typeof credential !== \"object\" || credential === null || Array.isArray(credential)) {\n\t\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t\t}\n\t\t\tconst value = credential as Record<string, unknown>;\n\t\t\tif (value.type === \"api_key\") {\n\t\t\t\tconst validKey = value.key === undefined || typeof value.key === \"string\";\n\t\t\t\tconst validEnv =\n\t\t\t\t\tvalue.env === undefined ||\n\t\t\t\t\t(typeof value.env === \"object\" &&\n\t\t\t\t\t\tvalue.env !== null &&\n\t\t\t\t\t\t!Array.isArray(value.env) &&\n\t\t\t\t\t\tObject.values(value.env).every((entry) => typeof entry === \"string\"));\n\t\t\t\tif (validKey && validEnv) continue;\n\t\t\t} else if (\n\t\t\t\tvalue.type === \"oauth\" &&\n\t\t\t\ttypeof value.access === \"string\" &&\n\t\t\t\ttypeof value.refresh === \"string\" &&\n\t\t\t\ttypeof value.expires === \"number\" &&\n\t\t\t\tNumber.isFinite(value.expires)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t}\n\n\t\tthis.data = parsed as AuthStorageData;\n\t\treturn this.data;\n\t}\n\n\tasync read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credential = this.load()[providerId];\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!credential) return undefined;\n\t\tif (credential.type !== \"api_key\" || !credential.key || isCommandConfigValue(credential.key)) {\n\t\t\treturn structuredClone(credential);\n\t\t}\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credentials = Object.entries(this.load()).map(([providerId, credential]) => ({\n\t\t\tproviderId,\n\t\t\ttype: credential.type,\n\t\t}));\n\t\toptions?.signal?.throwIfAborted();\n\t\treturn credentials;\n\t}\n\n\tasync modify(\n\t\t_providerId: string,\n\t\t_fn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\t_options?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n\n\tasync delete(_providerId: string, _options?: AuthOperationOptions): Promise<void> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n}\n\nexport class InMemoryAuthStorageBackend implements AuthStorageBackend {\n\tprivate value: string | undefined;\n\tprivate asyncChain: Promise<unknown> = Promise.resolve();\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tconst { result, next } = fn(this.value);\n\t\tif (next !== undefined) {\n\t\t\tthis.value = next;\n\t\t}\n\t\treturn result;\n\t}\n\n\twithLockAsync<T>(\n\t\tfn: (current: string | undefined) => Promise<LockResult<T>>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<T> {\n\t\tconst previous = this.asyncChain;\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tconst { result, next } = await fn(this.value);\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.value = next;\n\t\t\t}\n\t\t\treturn result;\n\t\t})();\n\t\tthis.asyncChain = operation.catch(() => {});\n\t\treturn raceWithAbortSignal(operation, options?.signal);\n\t}\n}\n\n/**\n * Credential storage backed by a JSON file.\n */\nexport class AuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData = {};\n\tprivate readonly runtimeOverrides = new Map<string, string>();\n\tprivate readonly extensionOAuthProviders = new Map<string, OAuthAuth>();\n\tprivate errors: Error[] = [];\n\tprivate storage: AuthStorageBackend;\n\tprivate authPath: string | undefined;\n\tprivate readState: AuthFileReadState;\n\n\tprivate constructor(storage: AuthStorageBackend, authPath?: string) {\n\t\tthis.storage = storage;\n\t\tthis.authPath = authPath;\n\t\tthis.readState =\n\t\t\tauthPath && sharedAuthFileReadState?.authPath === authPath ? sharedAuthFileReadState.readState : { data: {} };\n\t\tif (authPath && !sharedAuthFileReadState) {\n\t\t\tsharedAuthFileReadState = { authPath, readState: this.readState };\n\t\t}\n\t\tif (authPath) {\n\t\t\tconst revision = getFileRevision(authPath);\n\t\t\tif (revision !== undefined && revision === this.readState.revision) return;\n\t\t}\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath: string = join(getAgentDir(), \"auth.json\")): AuthStorage {\n\t\tconst normalizedAuthPath = normalizePath(authPath);\n\t\treturn new AuthStorage(new FileAuthStorageBackend(normalizedAuthPath), normalizedAuthPath);\n\t}\n\n\tgetStoragePath(): string | undefined {\n\t\treturn this.authPath;\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn JSON.parse(stripBom(content)) as AuthStorageData;\n\t}\n\n\tprivate recordError(error: unknown): void {\n\t\tthis.errors.push(error instanceof Error ? error : new Error(String(error)));\n\t}\n\n\tprivate updateReadState(data: AuthStorageData, revision?: string): void {\n\t\tthis.data = data;\n\t\tthis.readState.data = data;\n\t\tthis.readState.revision = revision;\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\tlet content: string | undefined;\n\t\tlet revision: string | undefined;\n\t\ttry {\n\t\t\tthis.storage.withLock((current) => {\n\t\t\t\tcontent = current;\n\t\t\t\trevision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\t\treturn { result: undefined };\n\t\t\t});\n\t\t\tthis.updateReadState(this.parseStorageData(content), revision);\n\t\t} catch (error) {\n\t\t\t// Preserve the last valid in-memory snapshot.\n\t\t\tthis.recordError(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n\n\t/** Set a non-persistent API key used ahead of stored credentials. */\n\tsetRuntimeApiKey(provider: string, apiKey: string): void {\n\t\tthis.runtimeOverrides.set(provider, apiKey);\n\t}\n\n\tremoveRuntimeApiKey(provider: string): void {\n\t\tthis.runtimeOverrides.delete(provider);\n\t}\n\n\tget(provider: string): Credential | undefined {\n\t\treturn this.data[provider];\n\t}\n\n\tgetProviderEnv(provider: string): Record<string, string> | undefined {\n\t\tconst credential = this.data[provider];\n\t\treturn credential?.type === \"api_key\" && credential.env ? { ...credential.env } : undefined;\n\t}\n\n\tset(provider: string, credential: Credential): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = appendLoginSlot(currentData[provider], credential);\n\t\t\tconst nextData = { ...currentData, [provider]: next };\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tremove(provider: string): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst nextData = { ...this.parseStorageData(content) };\n\t\t\tdelete nextData[provider];\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tlistSlots(provider: string): CredentialSlot[] {\n\t\treturn listSlots(this.data[provider] as PooledCredential | undefined);\n\t}\n\n\tsetSlot(provider: string, slot: CredentialSlot): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = upsertSlot(currentData[provider] as PooledCredential | undefined, slot);\n\t\t\tconst nextData = { ...currentData, [provider]: next };\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tremoveSlot(provider: string, name: string): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = removeSlot(currentData[provider] as PooledCredential | undefined, name);\n\t\t\tconst nextData = { ...currentData };\n\t\t\tif (next === undefined) delete nextData[provider];\n\t\t\telse nextData[provider] = next;\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\thas(provider: string): boolean {\n\t\treturn provider in this.data;\n\t}\n\n\thasAuth(provider: string): boolean {\n\t\treturn this.runtimeOverrides.has(provider) || this.has(provider) || getEnvApiKey(provider) !== undefined;\n\t}\n\n\tgetAuthStatus(provider: string): AuthStatus {\n\t\tif (this.has(provider)) return { configured: true, source: \"stored\" };\n\t\tif (this.runtimeOverrides.has(provider)) return { configured: true, source: \"runtime\", label: \"--api-key\" };\n\t\tconst envName = findEnvKeys(provider)?.[0];\n\t\tif (envName && process.env[envName]) return { configured: true, source: \"environment\", label: envName };\n\t\treturn { configured: false };\n\t}\n\n\tgetAll(): AuthStorageData {\n\t\treturn { ...this.data };\n\t}\n\n\tdrainErrors(): Error[] {\n\t\tconst errors = this.errors;\n\t\tthis.errors = [];\n\t\treturn errors;\n\t}\n\n\tprivate async reloadFromStorageAsync(options?: AuthOperationOptions): Promise<AuthStorageData> {\n\t\treturn this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst revision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\tthis.updateReadState(currentData, revision);\n\t\t\treturn { result: currentData };\n\t\t}, options);\n\t}\n\n\tprivate async readLatestData(options?: AuthOperationOptions): Promise<AuthStorageData> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!this.authPath) {\n\t\t\ttry {\n\t\t\t\treturn await this.reloadFromStorageAsync(options);\n\t\t\t} catch (error) {\n\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\tthis.recordError(error);\n\t\t\t\treturn this.readState.data;\n\t\t\t}\n\t\t}\n\t\tconst revision = getFileRevision(this.authPath);\n\t\tif (revision !== undefined && revision === this.readState.revision) return this.readState.data;\n\t\tif (!this.readState.reload) {\n\t\t\tconst controller = new AbortController();\n\t\t\tconst reload: AuthFileReload = {\n\t\t\t\tcontroller,\n\t\t\t\tpromise: this.reloadFromStorageAsync({ signal: controller.signal }),\n\t\t\t\treaders: 0,\n\t\t\t};\n\t\t\tthis.readState.reload = reload;\n\t\t\tvoid reload.promise.then(\n\t\t\t\t() => {\n\t\t\t\t\tif (this.readState.reload === reload) this.readState.reload = undefined;\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tif (!controller.signal.aborted) this.recordError(error);\n\t\t\t\t\tif (this.readState.reload === reload) this.readState.reload = undefined;\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst reload = this.readState.reload;\n\t\treload.readers++;\n\t\ttry {\n\t\t\ttry {\n\t\t\t\treturn await raceWithAbortSignal(reload.promise, options?.signal);\n\t\t\t} catch {\n\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\treturn this.readState.data;\n\t\t\t}\n\t\t} finally {\n\t\t\treload.readers--;\n\t\t\tif (reload.readers === 0 && this.readState.reload === reload) {\n\t\t\t\tthis.readState.reload = undefined;\n\t\t\t\treload.controller.abort();\n\t\t\t}\n\t\t}\n\t}\n\n\tasync read(provider: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst runtimeKey = this.runtimeOverrides.get(provider);\n\t\tif (runtimeKey) return { type: \"api_key\", key: runtimeKey };\n\t\tconst credential = (await this.readLatestData(options))[provider];\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (credential?.type !== \"api_key\") return credential;\n\t\tif (credential.key === undefined) return credential;\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync modify(\n\t\tprovider: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tlet latestData = this.readState.data;\n\t\tlet revision: string | undefined;\n\t\tconst result = await this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = await fn(currentData[provider]);\n\t\t\tif (next === undefined) {\n\t\t\t\tlatestData = currentData;\n\t\t\t\trevision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\t\treturn { result: currentData[provider] };\n\t\t\t}\n\n\t\t\tconst merged: AuthStorageData = { ...currentData, [provider]: next };\n\t\t\tlatestData = merged;\n\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t}, options);\n\t\tthis.updateReadState(latestData, revision);\n\t\treturn result;\n\t}\n\n\tasync delete(provider: string, options?: AuthOperationOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.runtimeOverrides.delete(provider);\n\t\tlet latestData = this.readState.data;\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tdelete currentData[provider];\n\t\t\tlatestData = currentData;\n\t\t\treturn { result: undefined, next: JSON.stringify(currentData, null, 2) };\n\t\t}, options);\n\t\tthis.updateReadState(latestData);\n\t}\n\n\t/** List credential metadata without resolving configured key values. */\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\tconst entries = new Map(\n\t\t\tObject.entries(await this.readLatestData(options)).map(([providerId, credential]) => [\n\t\t\t\tproviderId,\n\t\t\t\t{ providerId, type: credential.type },\n\t\t\t]),\n\t\t);\n\t\toptions?.signal?.throwIfAborted();\n\t\tfor (const providerId of this.runtimeOverrides.keys()) {\n\t\t\tentries.set(providerId, { providerId, type: \"api_key\" });\n\t\t}\n\t\treturn [...entries.values()];\n\t}\n\n\tasync getApiKey(providerId: string, options: GetApiKeyOptions = {}): Promise<string | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(providerId);\n\t\tif (runtimeKey) return runtimeKey;\n\t\tconst credential = await this.read(providerId);\n\t\tif (credential?.type === \"api_key\") return credential.key;\n\t\tif (credential?.type === \"oauth\") {\n\t\t\tconst oauth = builtinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tlet current = credential;\n\t\t\tif (Date.now() >= current.expires) {\n\t\t\t\tconst refreshed = await this.modify(providerId, async (stored) => {\n\t\t\t\t\tif (stored?.type !== \"oauth\") return stored;\n\t\t\t\t\treturn Date.now() < stored.expires ? stored : oauth.refresh(stored, new AbortController().signal);\n\t\t\t\t});\n\t\t\t\tif (refreshed?.type !== \"oauth\") return undefined;\n\t\t\t\tcurrent = refreshed;\n\t\t\t}\n\t\t\treturn (await oauth.toAuth(current)).apiKey;\n\t\t}\n\t\tif (options.includeFallback === false) return undefined;\n\t\treturn getEnvApiKey(providerId);\n\t}\n\n\tregisterOAuthProvider(providerId: string, oauth: OAuthAuth): void {\n\t\tthis.extensionOAuthProviders.set(providerId, oauth);\n\t}\n\n\tunregisterOAuthProvider(providerId: string): void {\n\t\tthis.extensionOAuthProviders.delete(providerId);\n\t}\n\n\tgetOAuthProviders(): Array<{ id: string; name: string }> {\n\t\tconst dynamic = [...this.extensionOAuthProviders.entries()].map(([id, oauth]) => ({\n\t\t\tid,\n\t\t\tname: oauth.name,\n\t\t}));\n\t\tconst builtin = builtinProviders().flatMap((provider) =>\n\t\t\tprovider.auth.oauth && !this.extensionOAuthProviders.has(provider.id)\n\t\t\t\t? [{ id: provider.id, name: provider.auth.oauth.name }]\n\t\t\t\t: [],\n\t\t);\n\t\treturn [...dynamic, ...builtin];\n\t}\n\n\tasync login(providerId: string, callbacks: OAuthLoginCallbacks): Promise<void> {\n\t\tconst oauth =\n\t\t\tthis.extensionOAuthProviders.get(providerId) ??\n\t\t\tbuiltinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\tif (!oauth) throw new Error(`Unknown OAuth provider: ${providerId}`);\n\t\tconst signal = callbacks.signal ?? new AbortController().signal;\n\t\tconst interaction: AuthInteraction & { signal: AbortSignal } = {\n\t\t\tsignal,\n\t\t\tprompt: (prompt) => this.handleLegacyPrompt(prompt, callbacks),\n\t\t\tnotify: (event) => this.handleLegacyEvent(event, callbacks),\n\t\t};\n\t\tconst credential = await oauth.login(interaction);\n\t\tthis.set(providerId, credential);\n\t}\n\n\tlogout(provider: string): void {\n\t\tthis.removeRuntimeApiKey(provider);\n\t\tthis.remove(provider);\n\t}\n\n\tprivate handleLegacyPrompt(prompt: AuthPrompt, callbacks: OAuthLoginCallbacks): Promise<string> {\n\t\tswitch (prompt.type) {\n\t\t\tcase \"manual_code\":\n\t\t\t\treturn callbacks.onManualCodeInput?.() ?? callbacks.onPrompt(prompt);\n\t\t\tcase \"select\":\n\t\t\t\treturn callbacks.onSelect(prompt).then((value) => {\n\t\t\t\t\tif (value === undefined) throw new Error(\"Login cancelled\");\n\t\t\t\t\treturn value;\n\t\t\t\t});\n\t\t\tcase \"secret\":\n\t\t\tcase \"text\":\n\t\t\t\treturn callbacks.onPrompt(prompt);\n\t\t}\n\t}\n\n\tprivate handleLegacyEvent(event: AuthEvent, callbacks: OAuthLoginCallbacks): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"auth_url\":\n\t\t\t\tcallbacks.onAuth(event);\n\t\t\t\tbreak;\n\t\t\tcase \"device_code\":\n\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\tbreak;\n\t\t\tcase \"info\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t\tcase \"progress\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * One-off synchronous read of a stored credential from an auth.json file,\n * without instantiating a store or resolving configured key values.\n */\nexport function readStoredCredential(\n\tproviderId: string,\n\tauthPath: string = join(getAgentDir(), \"auth.json\"),\n): Credential | undefined {\n\ttry {\n\t\tconst data = JSON.parse(stripBom(readFileSync(normalizePath(authPath), \"utf-8\"))) as AuthStorageData;\n\t\treturn data[providerId];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EACN,eAAe,EAEf,SAAS,EAET,UAAU,EACV,UAAU,GACV,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,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B,CACnC,UAAkB,EAClB,WAAmB,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC;IAEnD,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAAoB,CAAC;QACrG,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * CredentialStore implementation backed by auth.json.\n * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.\n */\n\nimport type {\n\tApiKeyCredential,\n\tAuthEvent,\n\tAuthInteraction,\n\tAuthOperationOptions,\n\tAuthPrompt,\n\tCredential,\n\tCredentialInfo,\n\tCredentialStore,\n\tOAuthAuth,\n\tOAuthCredential,\n\tOAuthLoginCallbacks,\n} from \"@earendil-works/pi-ai\";\nimport { findEnvKeys, getEnvApiKey } from \"@earendil-works/pi-ai\";\nimport {\n\tappendLoginSlot,\n\ttype CredentialSlot,\n\tlistSlots,\n\ttype PooledCredential,\n\tremoveSlot,\n\tupsertSlot,\n} from \"@earendil-works/pi-ai/auth/pool/slots\";\nimport { builtinProviders } from \"@earendil-works/pi-ai/providers/all\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport lockfile from \"proper-lockfile\";\nimport { getAgentDir } from \"../config.ts\";\nimport { raceWithAbortSignal } from \"../utils/abort.ts\";\nimport { getFileRevision, normalizePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport {\n\tCredentialStoreBusyError,\n\tFILE_STORAGE_LOCK_OPTIONS,\n\tFILE_STORAGE_LOCK_RETRY_BUDGET_MS,\n\tFILE_STORAGE_LOCK_RETRY_MAX_DELAY_MS,\n\tFILE_STORAGE_LOCK_RETRY_MIN_DELAY_MS,\n\tFILE_STORAGE_SYNC_LOCK_BUDGET_MS,\n\tisLockError,\n} from \"./lockfile-policy.ts\";\nimport { isCommandConfigValue, resolveConfigValue } from \"./resolve-config-value.ts\";\n\ntype AuthStorageData = Record<string, Credential>;\n\nexport type AuthCredential = Credential;\nexport type { ApiKeyCredential, OAuthCredential };\nexport type AuthStatus = {\n\tconfigured: boolean;\n\tsource?: \"stored\" | \"runtime\" | \"environment\" | \"fallback\" | \"models_json_key\" | \"models_json_command\";\n\tlabel?: string;\n};\n\nexport interface GetApiKeyOptions {\n\tincludeFallback?: boolean;\n}\n\ntype LockResult<T> = {\n\tresult: T;\n\tnext?: string;\n};\n\n// The mode applies only on creation so administrator-managed modes and ACLs remain intact.\nconst AUTH_FILE_WRITE_OPTIONS = { encoding: \"utf-8\", mode: 0o600 } as const;\n\ntype AuthFileReload = {\n\tcontroller: AbortController;\n\tpromise: Promise<AuthStorageData>;\n\treaders: number;\n};\n\ntype AuthFileReadState = {\n\tdata: AuthStorageData;\n\trevision?: string;\n\treload?: AuthFileReload;\n};\n\nlet sharedAuthFileReadState: { authPath: string; readState: AuthFileReadState } | undefined;\n\nexport interface AuthStorageBackend {\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T;\n\twithLockAsync<T>(\n\t\tfn: (current: string | undefined) => Promise<LockResult<T>>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<T>;\n}\n\nexport class FileAuthStorageBackend implements AuthStorageBackend {\n\tprivate authPath: string;\n\n\tconstructor(authPath: string = join(getAgentDir(), \"auth.json\")) {\n\t\tthis.authPath = normalizePath(authPath);\n\t}\n\n\tprivate ensureParentDir(): void {\n\t\tconst dir = dirname(this.authPath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t\t}\n\t}\n\n\tprivate ensureFileExists(): void {\n\t\tif (!existsSync(this.authPath)) {\n\t\t\twriteFileSync(this.authPath, \"{}\", AUTH_FILE_WRITE_OPTIONS);\n\t\t}\n\t}\n\n\tprivate acquireLockSyncWithRetry(path: string): () => void {\n\t\tconst startedAt = Date.now();\n\t\tlet attempt = 0;\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\treturn lockfile.lockSync(path, { ...FILE_STORAGE_LOCK_OPTIONS, retries: 0 });\n\t\t\t} catch (error) {\n\t\t\t\tif (!isLockError(error)) throw error;\n\t\t\t\tconst waitedMs = Date.now() - startedAt;\n\t\t\t\tif (waitedMs >= FILE_STORAGE_SYNC_LOCK_BUDGET_MS) {\n\t\t\t\t\tthrow new CredentialStoreBusyError(path, waitedMs, error);\n\t\t\t\t}\n\t\t\t\tconst delayMs = Math.min(\n\t\t\t\t\tFILE_STORAGE_LOCK_RETRY_MIN_DELAY_MS * 2 ** attempt,\n\t\t\t\t\tFILE_STORAGE_LOCK_RETRY_MAX_DELAY_MS,\n\t\t\t\t\tFILE_STORAGE_SYNC_LOCK_BUDGET_MS - waitedMs,\n\t\t\t\t);\n\t\t\t\tattempt++;\n\t\t\t\tconst sleeper = new Int32Array(new SharedArrayBuffer(4));\n\t\t\t\tAtomics.wait(sleeper, 0, 0, delayMs);\n\t\t\t}\n\t\t}\n\t}\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => void) | undefined;\n\t\ttry {\n\t\t\trelease = this.acquireLockSyncWithRetry(this.authPath);\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = fn(current);\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t}\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\trelease();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async acquireLockAsync(\n\t\tsignal: AbortSignal | undefined,\n\t\tonCompromised: (error: Error) => void,\n\t): Promise<() => Promise<void>> {\n\t\tsignal?.throwIfAborted();\n\t\tconst startedAt = Date.now();\n\t\tlet attempt = 0;\n\t\t// The retry loop stays here rather than delegating to proper-lockfile's own\n\t\t// `retries`, so an abort is observed between attempts instead of after the\n\t\t// whole budget, and `onCompromised` is rebound per attempt.\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tconst release = await lockfile.lock(this.authPath, {\n\t\t\t\t\t...FILE_STORAGE_LOCK_OPTIONS,\n\t\t\t\t\tretries: 0,\n\t\t\t\t\tonCompromised,\n\t\t\t\t});\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tawait release();\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t}\n\t\t\t\treturn release;\n\t\t\t} catch (error) {\n\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\tif (!isLockError(error)) throw error;\n\t\t\t\tconst waitedMs = Date.now() - startedAt;\n\t\t\t\tif (waitedMs >= FILE_STORAGE_LOCK_RETRY_BUDGET_MS) {\n\t\t\t\t\tthrow new CredentialStoreBusyError(this.authPath, waitedMs, error);\n\t\t\t\t}\n\t\t\t\tconst delayMs = Math.min(\n\t\t\t\t\tFILE_STORAGE_LOCK_RETRY_MIN_DELAY_MS * 2 ** attempt,\n\t\t\t\t\tFILE_STORAGE_LOCK_RETRY_MAX_DELAY_MS,\n\t\t\t\t\tFILE_STORAGE_LOCK_RETRY_BUDGET_MS - waitedMs,\n\t\t\t\t);\n\t\t\t\tattempt++;\n\t\t\t\tawait raceWithAbortSignal(new Promise<void>((resolve) => setTimeout(resolve, delayMs)), signal);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync withLockAsync<T>(\n\t\tfn: (current: string | undefined) => Promise<LockResult<T>>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<T> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.ensureParentDir();\n\t\tthis.ensureFileExists();\n\n\t\tlet release: (() => Promise<void>) | undefined;\n\t\tlet lockCompromised = false;\n\t\tlet lockCompromisedError: Error | undefined;\n\t\tconst throwIfCompromised = () => {\n\t\t\tif (lockCompromised) {\n\t\t\t\tthrow lockCompromisedError ?? new Error(\"Auth storage lock was compromised\");\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\trelease = await this.acquireLockAsync(options?.signal, (error) => {\n\t\t\t\tlockCompromised = true;\n\t\t\t\tlockCompromisedError = error;\n\t\t\t});\n\n\t\t\tthrowIfCompromised();\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tconst current = existsSync(this.authPath) ? readFileSync(this.authPath, \"utf-8\") : undefined;\n\t\t\tconst { result, next } = await fn(current);\n\t\t\tthrowIfCompromised();\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tif (next !== undefined) {\n\t\t\t\twriteFileSync(this.authPath, next, AUTH_FILE_WRITE_OPTIONS);\n\t\t\t}\n\t\t\tthrowIfCompromised();\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tif (release) {\n\t\t\t\ttry {\n\t\t\t\t\tawait release();\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore unlock errors when lock is compromised.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class ReadOnlyAuthStorage implements CredentialStore {\n\tprivate readonly authPath: string;\n\tprivate data: AuthStorageData | undefined;\n\n\tconstructor(authPath: string = join(getAgentDir(), \"auth.json\")) {\n\t\tthis.authPath = normalizePath(authPath);\n\t}\n\n\tprivate load(): AuthStorageData {\n\t\tif (this.data) return this.data;\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripBom(readFileSync(this.authPath, \"utf-8\")));\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n\t\t\t\tthis.data = {};\n\t\t\t\treturn this.data;\n\t\t\t}\n\t\t\tthrow new Error(`Failed to read auth.json: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\t\tthrow new Error(\"Invalid auth.json: expected an object\");\n\t\t}\n\t\tfor (const [providerId, credential] of Object.entries(parsed)) {\n\t\t\tif (typeof credential !== \"object\" || credential === null || Array.isArray(credential)) {\n\t\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t\t}\n\t\t\tconst value = credential as Record<string, unknown>;\n\t\t\tif (value.type === \"api_key\") {\n\t\t\t\tconst validKey = value.key === undefined || typeof value.key === \"string\";\n\t\t\t\tconst validEnv =\n\t\t\t\t\tvalue.env === undefined ||\n\t\t\t\t\t(typeof value.env === \"object\" &&\n\t\t\t\t\t\tvalue.env !== null &&\n\t\t\t\t\t\t!Array.isArray(value.env) &&\n\t\t\t\t\t\tObject.values(value.env).every((entry) => typeof entry === \"string\"));\n\t\t\t\tif (validKey && validEnv) continue;\n\t\t\t} else if (\n\t\t\t\tvalue.type === \"oauth\" &&\n\t\t\t\ttypeof value.access === \"string\" &&\n\t\t\t\ttypeof value.refresh === \"string\" &&\n\t\t\t\ttypeof value.expires === \"number\" &&\n\t\t\t\tNumber.isFinite(value.expires)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t}\n\n\t\tthis.data = parsed as AuthStorageData;\n\t\treturn this.data;\n\t}\n\n\tasync read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credential = this.load()[providerId];\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!credential) return undefined;\n\t\tif (credential.type !== \"api_key\" || !credential.key || isCommandConfigValue(credential.key)) {\n\t\t\treturn structuredClone(credential);\n\t\t}\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credentials = Object.entries(this.load()).map(([providerId, credential]) => ({\n\t\t\tproviderId,\n\t\t\ttype: credential.type,\n\t\t}));\n\t\toptions?.signal?.throwIfAborted();\n\t\treturn credentials;\n\t}\n\n\tasync modify(\n\t\t_providerId: string,\n\t\t_fn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\t_options?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n\n\tasync delete(_providerId: string, _options?: AuthOperationOptions): Promise<void> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n}\n\nexport class InMemoryAuthStorageBackend implements AuthStorageBackend {\n\tprivate value: string | undefined;\n\tprivate asyncChain: Promise<unknown> = Promise.resolve();\n\n\twithLock<T>(fn: (current: string | undefined) => LockResult<T>): T {\n\t\tconst { result, next } = fn(this.value);\n\t\tif (next !== undefined) {\n\t\t\tthis.value = next;\n\t\t}\n\t\treturn result;\n\t}\n\n\twithLockAsync<T>(\n\t\tfn: (current: string | undefined) => Promise<LockResult<T>>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<T> {\n\t\tconst previous = this.asyncChain;\n\t\tconst operation = (async () => {\n\t\t\tawait previous.catch(() => {});\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tconst { result, next } = await fn(this.value);\n\t\t\toptions?.signal?.throwIfAborted();\n\t\t\tif (next !== undefined) {\n\t\t\t\tthis.value = next;\n\t\t\t}\n\t\t\treturn result;\n\t\t})();\n\t\tthis.asyncChain = operation.catch(() => {});\n\t\treturn raceWithAbortSignal(operation, options?.signal);\n\t}\n}\n\n/**\n * Credential storage backed by a JSON file.\n */\nexport class AuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData = {};\n\tprivate readonly runtimeOverrides = new Map<string, string>();\n\tprivate readonly extensionOAuthProviders = new Map<string, OAuthAuth>();\n\tprivate errors: Error[] = [];\n\tprivate storage: AuthStorageBackend;\n\tprivate authPath: string | undefined;\n\tprivate readState: AuthFileReadState;\n\n\tprivate constructor(storage: AuthStorageBackend, authPath?: string) {\n\t\tthis.storage = storage;\n\t\tthis.authPath = authPath;\n\t\tthis.readState =\n\t\t\tauthPath && sharedAuthFileReadState?.authPath === authPath ? sharedAuthFileReadState.readState : { data: {} };\n\t\tif (authPath && !sharedAuthFileReadState) {\n\t\t\tsharedAuthFileReadState = { authPath, readState: this.readState };\n\t\t}\n\t\tif (authPath) {\n\t\t\tconst revision = getFileRevision(authPath);\n\t\t\tif (revision !== undefined && revision === this.readState.revision) return;\n\t\t}\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath: string = join(getAgentDir(), \"auth.json\")): AuthStorage {\n\t\tconst normalizedAuthPath = normalizePath(authPath);\n\t\treturn new AuthStorage(new FileAuthStorageBackend(normalizedAuthPath), normalizedAuthPath);\n\t}\n\n\tgetStoragePath(): string | undefined {\n\t\treturn this.authPath;\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn JSON.parse(stripBom(content)) as AuthStorageData;\n\t}\n\n\tprivate recordError(error: unknown): void {\n\t\tthis.errors.push(error instanceof Error ? error : new Error(String(error)));\n\t}\n\n\tprivate updateReadState(data: AuthStorageData, revision?: string): void {\n\t\tthis.data = data;\n\t\tthis.readState.data = data;\n\t\tthis.readState.revision = revision;\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\tlet content: string | undefined;\n\t\tlet revision: string | undefined;\n\t\ttry {\n\t\t\tthis.storage.withLock((current) => {\n\t\t\t\tcontent = current;\n\t\t\t\trevision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\t\treturn { result: undefined };\n\t\t\t});\n\t\t\tthis.updateReadState(this.parseStorageData(content), revision);\n\t\t} catch (error) {\n\t\t\t// Preserve the last valid in-memory snapshot.\n\t\t\tthis.recordError(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n\n\t/** Set a non-persistent API key used ahead of stored credentials. */\n\tsetRuntimeApiKey(provider: string, apiKey: string): void {\n\t\tthis.runtimeOverrides.set(provider, apiKey);\n\t}\n\n\tremoveRuntimeApiKey(provider: string): void {\n\t\tthis.runtimeOverrides.delete(provider);\n\t}\n\n\tget(provider: string): Credential | undefined {\n\t\treturn this.data[provider];\n\t}\n\n\tgetProviderEnv(provider: string): Record<string, string> | undefined {\n\t\tconst credential = this.data[provider];\n\t\treturn credential?.type === \"api_key\" && credential.env ? { ...credential.env } : undefined;\n\t}\n\n\tset(provider: string, credential: Credential): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = appendLoginSlot(currentData[provider], credential);\n\t\t\tconst nextData = { ...currentData, [provider]: next };\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tremove(provider: string): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst nextData = { ...this.parseStorageData(content) };\n\t\t\tdelete nextData[provider];\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tlistSlots(provider: string): CredentialSlot[] {\n\t\treturn listSlots(this.data[provider] as PooledCredential | undefined);\n\t}\n\n\tsetSlot(provider: string, slot: CredentialSlot): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = upsertSlot(currentData[provider] as PooledCredential | undefined, slot);\n\t\t\tconst nextData = { ...currentData, [provider]: next };\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\tremoveSlot(provider: string, name: string): void {\n\t\tthis.storage.withLock((content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = removeSlot(currentData[provider] as PooledCredential | undefined, name);\n\t\t\tconst nextData = { ...currentData };\n\t\t\tif (next === undefined) delete nextData[provider];\n\t\t\telse nextData[provider] = next;\n\t\t\tthis.data = nextData;\n\t\t\treturn { result: undefined, next: JSON.stringify(nextData, null, 2) };\n\t\t});\n\t}\n\n\thas(provider: string): boolean {\n\t\treturn provider in this.data;\n\t}\n\n\thasAuth(provider: string): boolean {\n\t\treturn this.runtimeOverrides.has(provider) || this.has(provider) || getEnvApiKey(provider) !== undefined;\n\t}\n\n\tgetAuthStatus(provider: string): AuthStatus {\n\t\tif (this.has(provider)) return { configured: true, source: \"stored\" };\n\t\tif (this.runtimeOverrides.has(provider)) return { configured: true, source: \"runtime\", label: \"--api-key\" };\n\t\tconst envName = findEnvKeys(provider)?.[0];\n\t\tif (envName && process.env[envName]) return { configured: true, source: \"environment\", label: envName };\n\t\treturn { configured: false };\n\t}\n\n\tgetAll(): AuthStorageData {\n\t\treturn { ...this.data };\n\t}\n\n\tdrainErrors(): Error[] {\n\t\tconst errors = this.errors;\n\t\tthis.errors = [];\n\t\treturn errors;\n\t}\n\n\tprivate async reloadFromStorageAsync(options?: AuthOperationOptions): Promise<AuthStorageData> {\n\t\treturn this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst revision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\tthis.updateReadState(currentData, revision);\n\t\t\treturn { result: currentData };\n\t\t}, options);\n\t}\n\n\tprivate async readLatestData(options?: AuthOperationOptions): Promise<AuthStorageData> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!this.authPath) {\n\t\t\ttry {\n\t\t\t\treturn await this.reloadFromStorageAsync(options);\n\t\t\t} catch (error) {\n\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\tthis.recordError(error);\n\t\t\t\treturn this.readState.data;\n\t\t\t}\n\t\t}\n\t\tconst revision = getFileRevision(this.authPath);\n\t\tif (revision !== undefined && revision === this.readState.revision) return this.readState.data;\n\t\tif (!this.readState.reload) {\n\t\t\tconst controller = new AbortController();\n\t\t\tconst reload: AuthFileReload = {\n\t\t\t\tcontroller,\n\t\t\t\tpromise: this.reloadFromStorageAsync({ signal: controller.signal }),\n\t\t\t\treaders: 0,\n\t\t\t};\n\t\t\tthis.readState.reload = reload;\n\t\t\tvoid reload.promise.then(\n\t\t\t\t() => {\n\t\t\t\t\tif (this.readState.reload === reload) this.readState.reload = undefined;\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tif (!controller.signal.aborted) this.recordError(error);\n\t\t\t\t\tif (this.readState.reload === reload) this.readState.reload = undefined;\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst reload = this.readState.reload;\n\t\treload.readers++;\n\t\ttry {\n\t\t\ttry {\n\t\t\t\treturn await raceWithAbortSignal(reload.promise, options?.signal);\n\t\t\t} catch {\n\t\t\t\toptions?.signal?.throwIfAborted();\n\t\t\t\treturn this.readState.data;\n\t\t\t}\n\t\t} finally {\n\t\t\treload.readers--;\n\t\t\tif (reload.readers === 0 && this.readState.reload === reload) {\n\t\t\t\tthis.readState.reload = undefined;\n\t\t\t\treload.controller.abort();\n\t\t\t}\n\t\t}\n\t}\n\n\tasync read(provider: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst runtimeKey = this.runtimeOverrides.get(provider);\n\t\tif (runtimeKey) return { type: \"api_key\", key: runtimeKey };\n\t\tconst credential = (await this.readLatestData(options))[provider];\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (credential?.type !== \"api_key\") return credential;\n\t\tif (credential.key === undefined) return credential;\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync modify(\n\t\tprovider: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tlet latestData = this.readState.data;\n\t\tlet revision: string | undefined;\n\t\tconst result = await this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst next = await fn(currentData[provider]);\n\t\t\tif (next === undefined) {\n\t\t\t\tlatestData = currentData;\n\t\t\t\trevision = this.authPath ? getFileRevision(this.authPath) : undefined;\n\t\t\t\treturn { result: currentData[provider] };\n\t\t\t}\n\n\t\t\tconst merged: AuthStorageData = { ...currentData, [provider]: next };\n\t\t\tlatestData = merged;\n\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t}, options);\n\t\tthis.updateReadState(latestData, revision);\n\t\treturn result;\n\t}\n\n\tasync delete(provider: string, options?: AuthOperationOptions): Promise<void> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.runtimeOverrides.delete(provider);\n\t\tlet latestData = this.readState.data;\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tdelete currentData[provider];\n\t\t\tlatestData = currentData;\n\t\t\treturn { result: undefined, next: JSON.stringify(currentData, null, 2) };\n\t\t}, options);\n\t\tthis.updateReadState(latestData);\n\t}\n\n\t/** List credential metadata without resolving configured key values. */\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\tconst entries = new Map(\n\t\t\tObject.entries(await this.readLatestData(options)).map(([providerId, credential]) => [\n\t\t\t\tproviderId,\n\t\t\t\t{ providerId, type: credential.type },\n\t\t\t]),\n\t\t);\n\t\toptions?.signal?.throwIfAborted();\n\t\tfor (const providerId of this.runtimeOverrides.keys()) {\n\t\t\tentries.set(providerId, { providerId, type: \"api_key\" });\n\t\t}\n\t\treturn [...entries.values()];\n\t}\n\n\tasync getApiKey(providerId: string, options: GetApiKeyOptions = {}): Promise<string | undefined> {\n\t\tconst runtimeKey = this.runtimeOverrides.get(providerId);\n\t\tif (runtimeKey) return runtimeKey;\n\t\tconst credential = await this.read(providerId);\n\t\tif (credential?.type === \"api_key\") return credential.key;\n\t\tif (credential?.type === \"oauth\") {\n\t\t\tconst oauth = builtinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\t\tif (!oauth) return undefined;\n\t\t\tlet current = credential;\n\t\t\tif (Date.now() >= current.expires) {\n\t\t\t\tconst refreshed = await this.modify(providerId, async (stored) => {\n\t\t\t\t\tif (stored?.type !== \"oauth\") return stored;\n\t\t\t\t\treturn Date.now() < stored.expires ? stored : oauth.refresh(stored, new AbortController().signal);\n\t\t\t\t});\n\t\t\t\tif (refreshed?.type !== \"oauth\") return undefined;\n\t\t\t\tcurrent = refreshed;\n\t\t\t}\n\t\t\treturn (await oauth.toAuth(current)).apiKey;\n\t\t}\n\t\tif (options.includeFallback === false) return undefined;\n\t\treturn getEnvApiKey(providerId);\n\t}\n\n\tregisterOAuthProvider(providerId: string, oauth: OAuthAuth): void {\n\t\tthis.extensionOAuthProviders.set(providerId, oauth);\n\t}\n\n\tunregisterOAuthProvider(providerId: string): void {\n\t\tthis.extensionOAuthProviders.delete(providerId);\n\t}\n\n\tgetOAuthProviders(): Array<{ id: string; name: string }> {\n\t\tconst dynamic = [...this.extensionOAuthProviders.entries()].map(([id, oauth]) => ({\n\t\t\tid,\n\t\t\tname: oauth.name,\n\t\t}));\n\t\tconst builtin = builtinProviders().flatMap((provider) =>\n\t\t\tprovider.auth.oauth && !this.extensionOAuthProviders.has(provider.id)\n\t\t\t\t? [{ id: provider.id, name: provider.auth.oauth.name }]\n\t\t\t\t: [],\n\t\t);\n\t\treturn [...dynamic, ...builtin];\n\t}\n\n\tasync login(providerId: string, callbacks: OAuthLoginCallbacks): Promise<void> {\n\t\tconst oauth =\n\t\t\tthis.extensionOAuthProviders.get(providerId) ??\n\t\t\tbuiltinProviders().find((provider) => provider.id === providerId)?.auth.oauth;\n\t\tif (!oauth) throw new Error(`Unknown OAuth provider: ${providerId}`);\n\t\tconst signal = callbacks.signal ?? new AbortController().signal;\n\t\tconst interaction: AuthInteraction & { signal: AbortSignal } = {\n\t\t\tsignal,\n\t\t\tprompt: (prompt) => this.handleLegacyPrompt(prompt, callbacks),\n\t\t\tnotify: (event) => this.handleLegacyEvent(event, callbacks),\n\t\t};\n\t\tconst credential = await oauth.login(interaction);\n\t\tthis.set(providerId, credential);\n\t}\n\n\tlogout(provider: string): void {\n\t\tthis.removeRuntimeApiKey(provider);\n\t\tthis.remove(provider);\n\t}\n\n\tprivate handleLegacyPrompt(prompt: AuthPrompt, callbacks: OAuthLoginCallbacks): Promise<string> {\n\t\tswitch (prompt.type) {\n\t\t\tcase \"manual_code\":\n\t\t\t\treturn callbacks.onManualCodeInput?.() ?? callbacks.onPrompt(prompt);\n\t\t\tcase \"select\":\n\t\t\t\treturn callbacks.onSelect(prompt).then((value) => {\n\t\t\t\t\tif (value === undefined) throw new Error(\"Login cancelled\");\n\t\t\t\t\treturn value;\n\t\t\t\t});\n\t\t\tcase \"secret\":\n\t\t\tcase \"text\":\n\t\t\t\treturn callbacks.onPrompt(prompt);\n\t\t}\n\t}\n\n\tprivate handleLegacyEvent(event: AuthEvent, callbacks: OAuthLoginCallbacks): void {\n\t\tswitch (event.type) {\n\t\t\tcase \"auth_url\":\n\t\t\t\tcallbacks.onAuth(event);\n\t\t\t\tbreak;\n\t\t\tcase \"device_code\":\n\t\t\t\tcallbacks.onDeviceCode(event);\n\t\t\t\tbreak;\n\t\t\tcase \"info\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t\tcase \"progress\":\n\t\t\t\tcallbacks.onProgress?.(event.message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * One-off synchronous read of a stored credential from an auth.json file,\n * without instantiating a store or resolving configured key values.\n */\nexport function readStoredCredential(\n\tproviderId: string,\n\tauthPath: string = join(getAgentDir(), \"auth.json\"),\n): Credential | undefined {\n\ttry {\n\t\tconst data = JSON.parse(stripBom(readFileSync(normalizePath(authPath), \"utf-8\"))) as AuthStorageData;\n\t\treturn data[providerId];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../../src/core/compaction/compaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAA8B,MAAM,uBAAuB,CAAC;AAC1G,OAAO,KAAK,EACX,gBAAgB,EAChB,OAAO,EAEP,KAAK,EACL,mBAAmB,EAEnB,KAAK,EACL,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAGN,KAAK,YAAY,EAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,KAAK,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAOhG,OAAO,EAIN,KAAK,cAAc,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAC7C,KAAK,oBAAoB,GAAG,mBAAmB,GAAG;IACjD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAuBF,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;CACxB;AA6ED,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;I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GAAG,gBAAgB,CAAC,GACnF,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAwEzC;AAMD,MAAM,WAAW,qBAAqB;IACrC,kCAAkC;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,mBAAmB,EAAE,YAAY,EAAE,CAAC;IACpC;;;OAGG;IACH,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC,2EAA2E;IAC3E,kBAAkB,EAAE,YAAY,EAAE,CAAC;IACnC,wFAAwF;IACxF,wBAAwB,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1C,iEAAiE;IACjE,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,OAAO,EAAE,cAAc,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,EAAE,kBAAkB,CAAC;CAC7B;AAED,wBAAgB,iBAAiB,CAChC,WAAW,EAAE,YAAY,EAAE,EAC3B,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,UAAQ,EACrB,gBAAgB,UAAQ,GACtB,qBAAqB,GAAG,SAAS,CAmGnC;AAMD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * Pure functions for compaction logic. The session manager handles I/O,
5
5
  * and after compaction the session is reloaded.
6
6
  */
7
- import { retryAssistantCall, uuidv7 } from "@earendil-works/pi-ai";
7
+ import { dropFailedAssistantTurns, retryAssistantCall, uuidv7, } from "@earendil-works/pi-ai";
8
8
  import { streamSimple } from "@earendil-works/pi-ai/compat";
9
9
  import { estimateContextTokens as estimateProviderContextTokens } from "@earendil-works/pi-ai/utils/estimate";
10
10
  import { convertToLlm, filterContextExcludedMessages, isContextExcludedCustomMessage } from "../messages.js";
@@ -160,9 +160,12 @@ export function getLastAssistantUsage(entries) {
160
160
  }
161
161
  return undefined;
162
162
  }
163
- function getLastAssistantUsageInfo(messages) {
163
+ function getLastAssistantUsageInfo(messages, counted) {
164
164
  for (let i = messages.length - 1; i >= 0; i--) {
165
- const usage = getAssistantUsage(messages[i]);
165
+ const message = messages[i];
166
+ if (!counted.has(message))
167
+ continue;
168
+ const usage = getAssistantUsage(message);
166
169
  if (usage)
167
170
  return { usage, index: i };
168
171
  }
@@ -173,11 +176,17 @@ function getLastAssistantUsageInfo(messages) {
173
176
  * If there are messages after the last usage, estimate their tokens with estimateTokens.
174
177
  */
175
178
  export function estimateContextTokens(messages) {
176
- const usageInfo = getLastAssistantUsageInfo(messages);
179
+ // Count the same set the next provider request will carry: convertToLlm drops
180
+ // failed (error/aborted) assistant turns and their orphaned tool results.
181
+ // Indices stay relative to the INPUT array because callers read
182
+ // `messages[lastUsageIndex]` on the array they passed in.
183
+ const counted = new Set(dropFailedAssistantTurns(messages));
184
+ const usageInfo = getLastAssistantUsageInfo(messages, counted);
177
185
  if (!usageInfo) {
178
186
  let estimated = 0;
179
187
  for (const message of messages) {
180
- estimated += estimateTokens(message);
188
+ if (counted.has(message))
189
+ estimated += estimateTokens(message);
181
190
  }
182
191
  return {
183
192
  tokens: estimated,
@@ -189,7 +198,8 @@ export function estimateContextTokens(messages) {
189
198
  const usageTokens = calculateContextTokens(usageInfo.usage);
190
199
  let trailingTokens = 0;
191
200
  for (let i = usageInfo.index + 1; i < messages.length; i++) {
192
- trailingTokens += estimateTokens(messages[i]);
201
+ if (counted.has(messages[i]))
202
+ trailingTokens += estimateTokens(messages[i]);
193
203
  }
194
204
  return {
195
205
  tokens: usageTokens + trailingTokens,
@@ -542,7 +552,6 @@ export async function completeSummarization(model, context, options, streamFn, r
542
552
  cacheRetention: options.cacheRetention ?? "none",
543
553
  affinitySessionId: options.affinitySessionId ?? options.sessionId,
544
554
  sessionId: uuidv7(),
545
- toolChoice: "none",
546
555
  };
547
556
  const callerSignal = options.signal;
548
557
  const produce = async () => {