gsd-pi 2.69.0 → 2.70.0-dev.7ebda5e

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 (255) hide show
  1. package/dist/loader.js +4 -0
  2. package/dist/resources/extensions/claude-code-cli/stream-adapter.js +150 -2
  3. package/dist/resources/extensions/gsd/auto-model-selection.js +33 -19
  4. package/dist/resources/extensions/gsd/auto-prompts.js +7 -3
  5. package/dist/resources/extensions/gsd/auto-start.js +25 -1
  6. package/dist/resources/extensions/gsd/auto.js +12 -8
  7. package/dist/resources/extensions/gsd/bootstrap/system-context.js +6 -2
  8. package/dist/resources/extensions/gsd/commands-cmux.js +30 -1
  9. package/dist/resources/extensions/gsd/commands-handlers.js +22 -8
  10. package/dist/resources/extensions/gsd/doctor-engine-checks.js +12 -0
  11. package/dist/resources/extensions/gsd/doctor-format.js +2 -0
  12. package/dist/resources/extensions/gsd/guided-flow.js +21 -10
  13. package/dist/resources/extensions/gsd/pre-execution-checks.js +5 -3
  14. package/dist/resources/extensions/gsd/validate-directory.js +30 -12
  15. package/dist/resources/extensions/gsd/workflow-mcp.js +64 -6
  16. package/dist/resources/extensions/slash-commands/audit.js +2 -1
  17. package/dist/resources/extensions/subagent/isolation.js +4 -2
  18. package/dist/update-check.d.ts +1 -0
  19. package/dist/update-check.js +30 -27
  20. package/dist/update-cmd.js +3 -11
  21. package/dist/web/standalone/.next/BUILD_ID +1 -1
  22. package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
  23. package/dist/web/standalone/.next/build-manifest.json +3 -3
  24. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  25. package/dist/web/standalone/.next/required-server-files.json +4 -4
  26. package/dist/web/standalone/.next/server/app/_global-error/page.js +3 -3
  27. package/dist/web/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  28. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  29. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  33. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  34. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  35. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  36. package/dist/web/standalone/.next/server/app/_not-found/page.js +2 -2
  37. package/dist/web/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  38. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  39. package/dist/web/standalone/.next/server/app/_not-found.rsc +3 -3
  40. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  41. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  42. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  43. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  44. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  45. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  46. package/dist/web/standalone/.next/server/app/api/boot/route.js +1 -1
  47. package/dist/web/standalone/.next/server/app/api/boot/route_client-reference-manifest.js +1 -1
  48. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route.js +1 -1
  49. package/dist/web/standalone/.next/server/app/api/bridge-terminal/input/route_client-reference-manifest.js +1 -1
  50. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route.js +1 -1
  51. package/dist/web/standalone/.next/server/app/api/bridge-terminal/resize/route_client-reference-manifest.js +1 -1
  52. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route.js +2 -2
  53. package/dist/web/standalone/.next/server/app/api/bridge-terminal/stream/route_client-reference-manifest.js +1 -1
  54. package/dist/web/standalone/.next/server/app/api/browse-directories/route.js +1 -1
  55. package/dist/web/standalone/.next/server/app/api/browse-directories/route_client-reference-manifest.js +1 -1
  56. package/dist/web/standalone/.next/server/app/api/captures/route.js +1 -1
  57. package/dist/web/standalone/.next/server/app/api/captures/route_client-reference-manifest.js +1 -1
  58. package/dist/web/standalone/.next/server/app/api/cleanup/route.js +1 -1
  59. package/dist/web/standalone/.next/server/app/api/cleanup/route_client-reference-manifest.js +1 -1
  60. package/dist/web/standalone/.next/server/app/api/dev-mode/route.js +1 -1
  61. package/dist/web/standalone/.next/server/app/api/dev-mode/route_client-reference-manifest.js +1 -1
  62. package/dist/web/standalone/.next/server/app/api/doctor/route.js +1 -1
  63. package/dist/web/standalone/.next/server/app/api/doctor/route_client-reference-manifest.js +1 -1
  64. package/dist/web/standalone/.next/server/app/api/experimental/route.js +2 -2
  65. package/dist/web/standalone/.next/server/app/api/experimental/route_client-reference-manifest.js +1 -1
  66. package/dist/web/standalone/.next/server/app/api/export-data/route.js +1 -1
  67. package/dist/web/standalone/.next/server/app/api/export-data/route_client-reference-manifest.js +1 -1
  68. package/dist/web/standalone/.next/server/app/api/files/route.js +1 -1
  69. package/dist/web/standalone/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  70. package/dist/web/standalone/.next/server/app/api/forensics/route.js +1 -1
  71. package/dist/web/standalone/.next/server/app/api/forensics/route_client-reference-manifest.js +1 -1
  72. package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
  73. package/dist/web/standalone/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  74. package/dist/web/standalone/.next/server/app/api/history/route.js +1 -1
  75. package/dist/web/standalone/.next/server/app/api/history/route_client-reference-manifest.js +1 -1
  76. package/dist/web/standalone/.next/server/app/api/hooks/route.js +1 -1
  77. package/dist/web/standalone/.next/server/app/api/hooks/route_client-reference-manifest.js +1 -1
  78. package/dist/web/standalone/.next/server/app/api/inspect/route.js +1 -1
  79. package/dist/web/standalone/.next/server/app/api/inspect/route_client-reference-manifest.js +1 -1
  80. package/dist/web/standalone/.next/server/app/api/knowledge/route.js +1 -1
  81. package/dist/web/standalone/.next/server/app/api/knowledge/route_client-reference-manifest.js +1 -1
  82. package/dist/web/standalone/.next/server/app/api/live-state/route.js +1 -1
  83. package/dist/web/standalone/.next/server/app/api/live-state/route_client-reference-manifest.js +1 -1
  84. package/dist/web/standalone/.next/server/app/api/notifications/route.js +2 -2
  85. package/dist/web/standalone/.next/server/app/api/notifications/route_client-reference-manifest.js +1 -1
  86. package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
  87. package/dist/web/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  88. package/dist/web/standalone/.next/server/app/api/preferences/route.js +1 -1
  89. package/dist/web/standalone/.next/server/app/api/preferences/route_client-reference-manifest.js +1 -1
  90. package/dist/web/standalone/.next/server/app/api/projects/route.js +1 -1
  91. package/dist/web/standalone/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  92. package/dist/web/standalone/.next/server/app/api/recovery/route.js +1 -1
  93. package/dist/web/standalone/.next/server/app/api/recovery/route_client-reference-manifest.js +1 -1
  94. package/dist/web/standalone/.next/server/app/api/remote-questions/route.js +2 -2
  95. package/dist/web/standalone/.next/server/app/api/remote-questions/route_client-reference-manifest.js +1 -1
  96. package/dist/web/standalone/.next/server/app/api/session/browser/route.js +1 -1
  97. package/dist/web/standalone/.next/server/app/api/session/browser/route_client-reference-manifest.js +1 -1
  98. package/dist/web/standalone/.next/server/app/api/session/command/route.js +1 -1
  99. package/dist/web/standalone/.next/server/app/api/session/command/route_client-reference-manifest.js +1 -1
  100. package/dist/web/standalone/.next/server/app/api/session/events/route.js +2 -2
  101. package/dist/web/standalone/.next/server/app/api/session/events/route_client-reference-manifest.js +1 -1
  102. package/dist/web/standalone/.next/server/app/api/session/manage/route.js +1 -1
  103. package/dist/web/standalone/.next/server/app/api/session/manage/route_client-reference-manifest.js +1 -1
  104. package/dist/web/standalone/.next/server/app/api/settings-data/route.js +1 -1
  105. package/dist/web/standalone/.next/server/app/api/settings-data/route_client-reference-manifest.js +1 -1
  106. package/dist/web/standalone/.next/server/app/api/shutdown/route.js +1 -1
  107. package/dist/web/standalone/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  108. package/dist/web/standalone/.next/server/app/api/skill-health/route.js +1 -1
  109. package/dist/web/standalone/.next/server/app/api/skill-health/route_client-reference-manifest.js +1 -1
  110. package/dist/web/standalone/.next/server/app/api/steer/route.js +1 -1
  111. package/dist/web/standalone/.next/server/app/api/steer/route_client-reference-manifest.js +1 -1
  112. package/dist/web/standalone/.next/server/app/api/switch-root/route.js +1 -1
  113. package/dist/web/standalone/.next/server/app/api/switch-root/route_client-reference-manifest.js +1 -1
  114. package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
  115. package/dist/web/standalone/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  116. package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +2 -2
  117. package/dist/web/standalone/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  118. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
  119. package/dist/web/standalone/.next/server/app/api/terminal/sessions/route_client-reference-manifest.js +1 -1
  120. package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +2 -2
  121. package/dist/web/standalone/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  122. package/dist/web/standalone/.next/server/app/api/terminal/upload/route.js +1 -1
  123. package/dist/web/standalone/.next/server/app/api/terminal/upload/route_client-reference-manifest.js +1 -1
  124. package/dist/web/standalone/.next/server/app/api/undo/route.js +1 -1
  125. package/dist/web/standalone/.next/server/app/api/undo/route_client-reference-manifest.js +1 -1
  126. package/dist/web/standalone/.next/server/app/api/update/route.js +1 -1
  127. package/dist/web/standalone/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  128. package/dist/web/standalone/.next/server/app/api/visualizer/route.js +1 -1
  129. package/dist/web/standalone/.next/server/app/api/visualizer/route_client-reference-manifest.js +1 -1
  130. package/dist/web/standalone/.next/server/app/index.html +1 -1
  131. package/dist/web/standalone/.next/server/app/index.rsc +4 -4
  132. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  133. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  134. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  135. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  136. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  137. package/dist/web/standalone/.next/server/app/page.js +2 -2
  138. package/dist/web/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  139. package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
  140. package/dist/web/standalone/.next/server/chunks/63.js +3 -3
  141. package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
  142. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  143. package/dist/web/standalone/.next/server/middleware.js +2 -2
  144. package/dist/web/standalone/.next/server/next-font-manifest.js +1 -1
  145. package/dist/web/standalone/.next/server/next-font-manifest.json +1 -1
  146. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  147. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  148. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  149. package/dist/web/standalone/.next/static/chunks/app/_not-found/{page-2f24283c162b6ab3.js → page-f2a7482d42a5614b.js} +1 -1
  150. package/dist/web/standalone/.next/static/chunks/app/{layout-9ecfd95f343793f0.js → layout-a16c7a7ecdf0c2cf.js} +1 -1
  151. package/dist/web/standalone/.next/static/chunks/app/page-f1e30ab6bb269149.js +1 -0
  152. package/dist/web/standalone/.next/static/chunks/main-app-fdab67f7802d7832.js +1 -0
  153. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-459824ffb8c323dd.js +1 -0
  154. package/dist/web/standalone/node_modules/node-pty/build/Makefile +2 -2
  155. package/dist/web/standalone/node_modules/node-pty/build/Release/pty.node +0 -0
  156. package/dist/web/standalone/node_modules/node-pty/build/pty.target.mk +14 -14
  157. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +14 -14
  158. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +14 -14
  159. package/dist/web/standalone/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +14 -14
  160. package/dist/web/standalone/server.js +1 -1
  161. package/dist/web-mode.js +4 -0
  162. package/package.json +11 -11
  163. package/packages/daemon/src/orchestrator.ts +9 -84
  164. package/packages/mcp-server/README.md +25 -3
  165. package/packages/mcp-server/dist/cli.d.ts +0 -1
  166. package/packages/mcp-server/dist/cli.d.ts.map +1 -1
  167. package/packages/mcp-server/dist/cli.js +4 -2
  168. package/packages/mcp-server/dist/cli.js.map +1 -1
  169. package/packages/mcp-server/dist/server.d.ts +32 -1
  170. package/packages/mcp-server/dist/server.d.ts.map +1 -1
  171. package/packages/mcp-server/dist/server.js +118 -1
  172. package/packages/mcp-server/dist/server.js.map +1 -1
  173. package/packages/mcp-server/dist/tool-credentials.d.ts +6 -0
  174. package/packages/mcp-server/dist/tool-credentials.d.ts.map +1 -0
  175. package/packages/mcp-server/dist/tool-credentials.js +90 -0
  176. package/packages/mcp-server/dist/tool-credentials.js.map +1 -0
  177. package/packages/mcp-server/dist/workflow-tools.d.ts +3 -0
  178. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -1
  179. package/packages/mcp-server/dist/workflow-tools.js +308 -4
  180. package/packages/mcp-server/dist/workflow-tools.js.map +1 -1
  181. package/packages/mcp-server/src/cli.ts +5 -3
  182. package/packages/mcp-server/src/import-candidates.test.ts +48 -0
  183. package/packages/mcp-server/src/mcp-server.test.ts +85 -1
  184. package/packages/mcp-server/src/server.ts +188 -1
  185. package/packages/mcp-server/src/tool-credentials.test.ts +95 -0
  186. package/packages/mcp-server/src/tool-credentials.ts +97 -0
  187. package/packages/mcp-server/src/workflow-tools.test.ts +32 -25
  188. package/packages/mcp-server/src/workflow-tools.ts +398 -2
  189. package/packages/pi-agent-core/dist/agent.d.ts +8 -0
  190. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  191. package/packages/pi-agent-core/dist/agent.js +3 -0
  192. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  193. package/packages/pi-agent-core/src/agent.test.ts +82 -0
  194. package/packages/pi-agent-core/src/agent.ts +12 -0
  195. package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  196. package/packages/pi-ai/dist/providers/anthropic.js +1 -23
  197. package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
  198. package/packages/pi-ai/dist/utils/oauth/index.d.ts +3 -2
  199. package/packages/pi-ai/dist/utils/oauth/index.d.ts.map +1 -1
  200. package/packages/pi-ai/dist/utils/oauth/index.js +3 -5
  201. package/packages/pi-ai/dist/utils/oauth/index.js.map +1 -1
  202. package/packages/pi-ai/src/providers/anthropic.ts +1 -31
  203. package/packages/pi-ai/src/utils/oauth/index.ts +3 -5
  204. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +1 -0
  205. package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
  206. package/packages/pi-coding-agent/dist/core/lsp/config.js +38 -15
  207. package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
  208. package/packages/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
  209. package/packages/pi-coding-agent/dist/core/sdk.js +10 -0
  210. package/packages/pi-coding-agent/dist/core/sdk.js.map +1 -1
  211. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -1
  212. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +3 -1
  213. package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -1
  214. package/packages/pi-coding-agent/package.json +1 -1
  215. package/packages/pi-coding-agent/src/core/lsp/config.ts +43 -17
  216. package/packages/pi-coding-agent/src/core/sdk.ts +8 -0
  217. package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +7 -5
  218. package/pkg/package.json +1 -1
  219. package/src/resources/extensions/claude-code-cli/stream-adapter.ts +227 -2
  220. package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +172 -0
  221. package/src/resources/extensions/gsd/auto-model-selection.ts +39 -25
  222. package/src/resources/extensions/gsd/auto-prompts.ts +7 -3
  223. package/src/resources/extensions/gsd/auto-start.ts +34 -1
  224. package/src/resources/extensions/gsd/auto.ts +12 -8
  225. package/src/resources/extensions/gsd/bootstrap/system-context.ts +9 -5
  226. package/src/resources/extensions/gsd/commands-cmux.ts +32 -1
  227. package/src/resources/extensions/gsd/commands-handlers.ts +22 -7
  228. package/src/resources/extensions/gsd/doctor-engine-checks.ts +14 -0
  229. package/src/resources/extensions/gsd/doctor-format.ts +1 -0
  230. package/src/resources/extensions/gsd/doctor-types.ts +1 -0
  231. package/src/resources/extensions/gsd/guided-flow.ts +24 -8
  232. package/src/resources/extensions/gsd/pre-execution-checks.ts +6 -3
  233. package/src/resources/extensions/gsd/tests/cmux.test.ts +67 -1
  234. package/src/resources/extensions/gsd/tests/doctor-scope-db-unavailable.test.ts +43 -0
  235. package/src/resources/extensions/gsd/tests/interactive-routing-bypass.test.ts +207 -0
  236. package/src/resources/extensions/gsd/tests/mcp-project-config.test.ts +6 -2
  237. package/src/resources/extensions/gsd/tests/pre-exec-backtick-strip.test.ts +48 -1
  238. package/src/resources/extensions/gsd/tests/resource-loader-import-path.test.ts +8 -7
  239. package/src/resources/extensions/gsd/tests/validate-directory.test.ts +33 -1
  240. package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +87 -1
  241. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +48 -7
  242. package/src/resources/extensions/gsd/validate-directory.ts +33 -11
  243. package/src/resources/extensions/gsd/workflow-mcp.ts +74 -5
  244. package/src/resources/extensions/slash-commands/audit.ts +2 -1
  245. package/src/resources/extensions/subagent/isolation.ts +4 -3
  246. package/dist/web/standalone/.next/static/chunks/app/page-7115e62689b5fd84.js +0 -1
  247. package/dist/web/standalone/.next/static/chunks/main-app-d3d4c336195465f9.js +0 -1
  248. package/dist/web/standalone/.next/static/chunks/next/dist/client/components/builtin/global-error-ab5a8926e07ec673.js +0 -1
  249. package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts +0 -17
  250. package/packages/pi-ai/dist/utils/oauth/anthropic.d.ts.map +0 -1
  251. package/packages/pi-ai/dist/utils/oauth/anthropic.js +0 -106
  252. package/packages/pi-ai/dist/utils/oauth/anthropic.js.map +0 -1
  253. package/packages/pi-ai/src/utils/oauth/anthropic.ts +0 -140
  254. /package/dist/web/standalone/.next/static/{DrWdzskk28E5Qz-Wjw1mj → yvFbuOJuph5517lR7HBt2}/_buildManifest.js +0 -0
  255. /package/dist/web/standalone/.next/static/{DrWdzskk28E5Qz-Wjw1mj → yvFbuOJuph5517lR7HBt2}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EAKR,YAAY,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB3E;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAwB;IACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACvG,CAAC;AAoFD,MAAM,OAAO,KAAK;IAkCjB,YAAY,OAAqB,EAAE;QAjC3B,WAAM,GAAe;YAC5B,YAAY,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ACV,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;YACjD,IAAI,CAAC,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC;YAC7C,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;YAC/B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACvC,CAAC;IACF,CAAC;IAEO,uBAAuB,CAAC,MAAwB,EAAE,EAAU;QACnE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAChD,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAClC,CAAC;IAEO,IAAI,CAAC,CAAa;QACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Agent class that uses the agent-loop directly.\n * No transport abstraction - calls streamSimple via the loop.\n */\n\nimport {\n\tgetModel,\n\ttype ImageContent,\n\ttype Message,\n\ttype Model,\n\ttype SimpleStreamOptions,\n\tstreamSimple,\n\ttype TextContent,\n\ttype ThinkingBudgets,\n\ttype Transport,\n} from \"@gsd/pi-ai\";\nimport { agentLoop, agentLoopContinue, ZERO_USAGE } from \"./agent-loop.js\";\nimport type {\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tBeforeToolCallContext,\n\tBeforeToolCallResult,\n\tAfterToolCallContext,\n\tAfterToolCallResult,\n\tStreamFn,\n\tThinkingLevel,\n} from \"./types.js\";\n\n/**\n * Default convertToLlm: Keep only LLM-compatible messages, convert attachments.\n */\nfunction defaultConvertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages.filter((m) => m.role === \"user\" || m.role === \"assistant\" || m.role === \"toolResult\");\n}\n\nexport interface AgentOptions {\n\tinitialState?: Partial<AgentState>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t * Default filters to user/assistant/toolResult and converts attachments.\n\t */\n\tconvertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to context before convertToLlm.\n\t * Use for context pruning, injecting external context, etc.\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Steering mode: \"all\" = send all steering messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Follow-up mode: \"all\" = send all follow-up messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Custom stream function (for proxy backends, etc.). Default uses streamSimple.\n\t */\n\tstreamFn?: StreamFn;\n\n\t/**\n\t * Optional session identifier forwarded to LLM providers.\n\t * Used by providers that support session-based caching (e.g., OpenAI Codex).\n\t */\n\tsessionId?: string;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t * Useful for expiring tokens (e.g., GitHub Copilot OAuth).\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Inspect or replace provider payloads before they are sent.\n\t */\n\tonPayload?: SimpleStreamOptions[\"onPayload\"];\n\n\t/**\n\t * Custom token budgets for thinking levels (token-based providers only).\n\t */\n\tthinkingBudgets?: ThinkingBudgets;\n\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t */\n\ttransport?: Transport;\n\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately,\n\t * allowing higher-level retry logic to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n\n\t/**\n\t * Determines whether a model uses external tool execution (tools handled\n\t * by the provider, not dispatched locally). Evaluated per-loop so model\n\t * switches mid-session are handled correctly.\n\t */\n\texternalToolExecution?: (model: Model<any>) => boolean;\n}\n\n/**\n * Internal wrapper that tracks message origin for origin-aware queue clearing.\n * \"user\" = typed by human in TUI; \"system\" = generated by extensions/background jobs.\n */\ninterface QueueEntry {\n\tmessage: AgentMessage;\n\torigin: \"user\" | \"system\";\n}\n\nexport class Agent {\n\tprivate _state: AgentState = {\n\t\tsystemPrompt: \"\",\n\t\tmodel: getModel(\"google\", \"gemini-2.5-flash-lite-preview-06-17\"),\n\t\tthinkingLevel: \"off\",\n\t\ttools: [],\n\t\tmessages: [],\n\t\tisStreaming: false,\n\t\tstreamMessage: null,\n\t\tpendingToolCalls: new Set<string>(),\n\t\terror: undefined,\n\t};\n\n\tprivate listeners = new Set<(e: AgentEvent) => void>();\n\tprivate abortController?: AbortController;\n\tprivate convertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\tprivate transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\tprivate steeringQueue: QueueEntry[] = [];\n\tprivate followUpQueue: QueueEntry[] = [];\n\tprivate steeringMode: \"all\" | \"one-at-a-time\";\n\tprivate followUpMode: \"all\" | \"one-at-a-time\";\n\tpublic streamFn: StreamFn;\n\tprivate _sessionId?: string;\n\tpublic getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\tprivate _onPayload?: SimpleStreamOptions[\"onPayload\"];\n\tprivate runningPrompt?: Promise<void>;\n\tprivate resolveRunningPrompt?: () => void;\n\tprivate _thinkingBudgets?: ThinkingBudgets;\n\tprivate _transport: Transport;\n\tprivate _maxRetryDelayMs?: number;\n\tprivate _beforeToolCall?: AgentLoopConfig[\"beforeToolCall\"];\n\tprivate _afterToolCall?: AgentLoopConfig[\"afterToolCall\"];\n\tprivate _externalToolExecution?: (model: Model<any>) => boolean;\n\n\tconstructor(opts: AgentOptions = {}) {\n\t\tthis._state = { ...this._state, ...opts.initialState };\n\t\tthis.convertToLlm = opts.convertToLlm || defaultConvertToLlm;\n\t\tthis.transformContext = opts.transformContext;\n\t\tthis.steeringMode = opts.steeringMode || \"one-at-a-time\";\n\t\tthis.followUpMode = opts.followUpMode || \"one-at-a-time\";\n\t\tthis.streamFn = opts.streamFn || streamSimple;\n\t\tthis._sessionId = opts.sessionId;\n\t\tthis.getApiKey = opts.getApiKey;\n\t\tthis._onPayload = opts.onPayload;\n\t\tthis._thinkingBudgets = opts.thinkingBudgets;\n\t\tthis._transport = opts.transport ?? \"sse\";\n\t\tthis._maxRetryDelayMs = opts.maxRetryDelayMs;\n\t\tthis._externalToolExecution = opts.externalToolExecution;\n\t}\n\n\t/**\n\t * Get the current session ID used for provider caching.\n\t */\n\tget sessionId(): string | undefined {\n\t\treturn this._sessionId;\n\t}\n\n\t/**\n\t * Set the session ID for provider caching.\n\t * Call this when switching sessions (new session, branch, resume).\n\t */\n\tset sessionId(value: string | undefined) {\n\t\tthis._sessionId = value;\n\t}\n\n\t/**\n\t * Get the current thinking budgets.\n\t */\n\tget thinkingBudgets(): ThinkingBudgets | undefined {\n\t\treturn this._thinkingBudgets;\n\t}\n\n\t/**\n\t * Set custom thinking budgets for token-based providers.\n\t */\n\tset thinkingBudgets(value: ThinkingBudgets | undefined) {\n\t\tthis._thinkingBudgets = value;\n\t}\n\n\t/**\n\t * Get the current preferred transport.\n\t */\n\tget transport(): Transport {\n\t\treturn this._transport;\n\t}\n\n\t/**\n\t * Set the preferred transport.\n\t */\n\tsetTransport(value: Transport) {\n\t\tthis._transport = value;\n\t}\n\n\t/**\n\t * Get the current max retry delay in milliseconds.\n\t */\n\tget maxRetryDelayMs(): number | undefined {\n\t\treturn this._maxRetryDelayMs;\n\t}\n\n\t/**\n\t * Set the maximum delay to wait for server-requested retries.\n\t * Set to 0 to disable the cap.\n\t */\n\tset maxRetryDelayMs(value: number | undefined) {\n\t\tthis._maxRetryDelayMs = value;\n\t}\n\n\t/**\n\t * Install a hook called before each tool executes, after argument validation.\n\t * Return `{ block: true }` to prevent execution.\n\t */\n\tsetBeforeToolCall(fn: AgentLoopConfig[\"beforeToolCall\"]): void {\n\t\tthis._beforeToolCall = fn;\n\t}\n\n\t/**\n\t * Install a hook called after each tool executes, before results are emitted.\n\t * Return field overrides for content/details/isError.\n\t */\n\tsetAfterToolCall(fn: AgentLoopConfig[\"afterToolCall\"]): void {\n\t\tthis._afterToolCall = fn;\n\t}\n\n\tget state(): AgentState {\n\t\treturn this._state;\n\t}\n\n\tsubscribe(fn: (e: AgentEvent) => void): () => void {\n\t\tthis.listeners.add(fn);\n\t\treturn () => this.listeners.delete(fn);\n\t}\n\n\t// State mutators\n\tsetSystemPrompt(v: string) {\n\t\tthis._state.systemPrompt = v;\n\t}\n\n\tsetModel(m: Model<any>) {\n\t\tthis._state.model = m;\n\t}\n\n\tsetThinkingLevel(l: ThinkingLevel) {\n\t\tthis._state.thinkingLevel = l;\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.steeringMode = mode;\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.steeringMode;\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.followUpMode = mode;\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.followUpMode;\n\t}\n\n\tsetTools(t: AgentTool<any>[]) {\n\t\tthis._state.tools = t;\n\t}\n\n\treplaceMessages(ms: AgentMessage[]) {\n\t\tthis._state.messages = ms.slice();\n\t}\n\n\tappendMessage(m: AgentMessage) {\n\t\tthis._state.messages = [...this._state.messages, m];\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t * Delivered after current tool execution, skips remaining tools.\n\t */\n\tsteer(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.steeringQueue.push({ message: m, origin });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t */\n\tfollowUp(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.followUpQueue.push({ message: m, origin });\n\t}\n\n\tclearSteeringQueue() {\n\t\tthis.steeringQueue = [];\n\t}\n\n\tclearFollowUpQueue() {\n\t\tthis.followUpQueue = [];\n\t}\n\n\tclearAllQueues() {\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/**\n\t * Drain user-origin messages from queues, leaving system messages in place.\n\t * Used during abort to preserve messages the user explicitly typed.\n\t */\n\tdrainUserMessages(): { steering: AgentMessage[]; followUp: AgentMessage[] } {\n\t\tconst userSteering = this.steeringQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tconst userFollowUp = this.followUpQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tthis.steeringQueue = this.steeringQueue.filter((e) => e.origin !== \"user\");\n\t\tthis.followUpQueue = this.followUpQueue.filter((e) => e.origin !== \"user\");\n\t\treturn { steering: userSteering, followUp: userFollowUp };\n\t}\n\n\thasQueuedMessages(): boolean {\n\t\treturn this.steeringQueue.length > 0 || this.followUpQueue.length > 0;\n\t}\n\n\tprivate dequeueSteeringMessages(): AgentMessage[] {\n\t\tif (this.steeringMode === \"one-at-a-time\") {\n\t\t\tif (this.steeringQueue.length > 0) {\n\t\t\t\tconst first = this.steeringQueue[0];\n\t\t\t\tthis.steeringQueue = this.steeringQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst steering = this.steeringQueue.map((e) => e.message);\n\t\tthis.steeringQueue = [];\n\t\treturn steering;\n\t}\n\n\tprivate dequeueFollowUpMessages(): AgentMessage[] {\n\t\tif (this.followUpMode === \"one-at-a-time\") {\n\t\t\tif (this.followUpQueue.length > 0) {\n\t\t\t\tconst first = this.followUpQueue[0];\n\t\t\t\tthis.followUpQueue = this.followUpQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst followUp = this.followUpQueue.map((e) => e.message);\n\t\tthis.followUpQueue = [];\n\t\treturn followUp;\n\t}\n\n\tclearMessages() {\n\t\tthis._state.messages = [];\n\t}\n\n\tabort() {\n\t\tthis.abortController?.abort();\n\t}\n\n\twaitForIdle(): Promise<void> {\n\t\treturn this.runningPrompt ?? Promise.resolve();\n\t}\n\n\treset() {\n\t\tthis._state.messages = [];\n\t\tthis._state.isStreaming = false;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\tthis._state.error = undefined;\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/** Send a prompt with an AgentMessage */\n\tasync prompt(message: AgentMessage | AgentMessage[]): Promise<void>;\n\tasync prompt(input: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(input: string | AgentMessage | AgentMessage[], images?: ImageContent[]) {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.\",\n\t\t\t);\n\t\t}\n\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tlet msgs: AgentMessage[];\n\n\t\tif (Array.isArray(input)) {\n\t\t\tmsgs = input;\n\t\t} else if (typeof input === \"string\") {\n\t\t\tconst content: Array<TextContent | ImageContent> = [{ type: \"text\", text: input }];\n\t\t\tif (images && images.length > 0) {\n\t\t\t\tcontent.push(...images);\n\t\t\t}\n\t\t\tmsgs = [\n\t\t\t\t{\n\t\t\t\t\trole: \"user\",\n\t\t\t\t\tcontent,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\tmsgs = [input];\n\t\t}\n\n\t\tawait this._runLoop(msgs);\n\t}\n\n\t/**\n\t * Continue from current context (used for retries and resuming queued messages).\n\t */\n\tasync continue() {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\"Agent is already processing. Wait for completion before continuing.\");\n\t\t}\n\n\t\tconst messages = this._state.messages;\n\t\tif (messages.length === 0) {\n\t\t\tthrow new Error(\"No messages to continue from\");\n\t\t}\n\t\tif (messages[messages.length - 1].role === \"assistant\") {\n\t\t\tconst queuedSteering = this.dequeueSteeringMessages();\n\t\t\tif (queuedSteering.length > 0) {\n\t\t\t\tawait this._runLoop(queuedSteering, { skipInitialSteeringPoll: true });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst queuedFollowUp = this.dequeueFollowUpMessages();\n\t\t\tif (queuedFollowUp.length > 0) {\n\t\t\t\tawait this._runLoop(queuedFollowUp);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new Error(\"Cannot continue from message role: assistant\");\n\t\t}\n\n\t\tawait this._runLoop(undefined);\n\t}\n\n\t/**\n\t * Run the agent loop.\n\t * If messages are provided, starts a new conversation turn with those messages.\n\t * Otherwise, continues from existing context.\n\t */\n\tprivate async _runLoop(messages?: AgentMessage[], options?: { skipInitialSteeringPoll?: boolean }) {\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tthis._state.activeInferenceModel = model;\n\n\t\tthis.runningPrompt = new Promise<void>((resolve) => {\n\t\t\tthis.resolveRunningPrompt = resolve;\n\t\t});\n\n\t\tthis.abortController = new AbortController();\n\t\tthis._state.isStreaming = true;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.error = undefined;\n\n\t\tconst reasoning = this._state.thinkingLevel === \"off\" ? undefined : this._state.thinkingLevel;\n\n\t\tconst context: AgentContext = {\n\t\t\tsystemPrompt: this._state.systemPrompt,\n\t\t\tmessages: this._state.messages.slice(),\n\t\t\ttools: this._state.tools,\n\t\t};\n\n\t\tlet skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;\n\n\t\tconst config: AgentLoopConfig = {\n\t\t\tmodel,\n\t\t\treasoning,\n\t\t\tsessionId: this._sessionId,\n\t\t\tonPayload: this._onPayload,\n\t\t\ttransport: this._transport,\n\t\t\tthinkingBudgets: this._thinkingBudgets,\n\t\t\tmaxRetryDelayMs: this._maxRetryDelayMs,\n\t\t\tconvertToLlm: this.convertToLlm,\n\t\t\ttransformContext: this.transformContext,\n\t\t\tgetApiKey: this.getApiKey,\n\t\t\tgetSteeringMessages: async () => {\n\t\t\t\tif (skipInitialSteeringPoll) {\n\t\t\t\t\tskipInitialSteeringPoll = false;\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn this.dequeueSteeringMessages();\n\t\t\t},\n\t\t\tgetFollowUpMessages: async () => this.dequeueFollowUpMessages(),\n\t\t\tbeforeToolCall: this._beforeToolCall,\n\t\t\tafterToolCall: this._afterToolCall,\n\t\t\texternalToolExecution: this._externalToolExecution?.(model) ?? false,\n\t\t};\n\n\t\tlet partial: AgentMessage | null = null;\n\n\t\ttry {\n\t\t\tconst stream = messages\n\t\t\t\t? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)\n\t\t\t\t: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);\n\n\t\t\tfor await (const event of stream) {\n\t\t\t\t// Update internal state based on events\n\t\t\t\tswitch (event.type) {\n\t\t\t\t\tcase \"message_start\":\n\t\t\t\t\tcase \"message_update\":\n\t\t\t\t\t\tpartial = event.message;\n\t\t\t\t\t\tthis._state.streamMessage = event.message;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"message_end\":\n\t\t\t\t\t\tpartial = null;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tthis.appendMessage(event.message);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_start\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"add\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_end\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"delete\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"turn_end\":\n\t\t\t\t\t\tif (event.message.role === \"assistant\" && (event.message as any).errorMessage) {\n\t\t\t\t\t\t\tthis._state.error = (event.message as any).errorMessage;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"agent_end\":\n\t\t\t\t\t\tthis._state.isStreaming = false;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Emit to listeners\n\t\t\t\tthis.emit(event);\n\t\t\t}\n\n\t\t\t// Handle any remaining partial message\n\t\t\tif (partial && partial.role === \"assistant\" && partial.content.length > 0) {\n\t\t\t\tconst onlyEmpty = !partial.content.some(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\t(c.type === \"thinking\" && c.thinking.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"text\" && c.text.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"toolCall\" && c.name.trim().length > 0),\n\t\t\t\t);\n\t\t\t\tif (!onlyEmpty) {\n\t\t\t\t\tthis.appendMessage(partial);\n\t\t\t\t} else {\n\t\t\t\t\tif (this.abortController?.signal.aborted) {\n\t\t\t\t\t\tthrow new Error(\"Request was aborted\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconst errorMsg: AgentMessage = {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{ type: \"text\", text: \"\" }],\n\t\t\t\tapi: model.api,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.id,\n\t\t\t\tusage: ZERO_USAGE,\n\t\t\t\tstopReason: this.abortController?.signal.aborted ? \"aborted\" : \"error\",\n\t\t\t\terrorMessage: err?.message || String(err),\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t} as AgentMessage;\n\n\t\t\tthis.appendMessage(errorMsg);\n\t\t\tthis._state.error = err?.message || String(err);\n\t\t\tthis.emit({ type: \"agent_end\", messages: [errorMsg] });\n\t\t} finally {\n\t\t\tthis._state.isStreaming = false;\n\t\t\tthis._state.streamMessage = null;\n\t\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\t\tthis._state.activeInferenceModel = undefined;\n\t\t\tthis.abortController = undefined;\n\t\t\tthis.resolveRunningPrompt?.();\n\t\t\tthis.runningPrompt = undefined;\n\t\t\tthis.resolveRunningPrompt = undefined;\n\t\t}\n\t}\n\n\tprivate _updatePendingToolCalls(action: \"add\" | \"delete\", id: string): void {\n\t\tconst s = new Set(this._state.pendingToolCalls);\n\t\ts[action](id);\n\t\tthis._state.pendingToolCalls = s;\n\t}\n\n\tprivate emit(e: AgentEvent) {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener(e);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,QAAQ,EAKR,YAAY,GAIZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB3E;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAwB;IACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AACvG,CAAC;AA4FD,MAAM,OAAO,KAAK;I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C,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;YACjD,IAAI,CAAC,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC;YAC7C,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAC9B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;YAC/B,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;QACvC,CAAC;IACF,CAAC;IAEO,uBAAuB,CAAC,MAAwB,EAAE,EAAU;QACnE,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAChD,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAClC,CAAC;IAEO,IAAI,CAAC,CAAa;QACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * Agent class that uses the agent-loop directly.\n * No transport abstraction - calls streamSimple via the loop.\n */\n\nimport {\n\tgetModel,\n\ttype ImageContent,\n\ttype Message,\n\ttype Model,\n\ttype SimpleStreamOptions,\n\tstreamSimple,\n\ttype TextContent,\n\ttype ThinkingBudgets,\n\ttype Transport,\n} from \"@gsd/pi-ai\";\nimport { agentLoop, agentLoopContinue, ZERO_USAGE } from \"./agent-loop.js\";\nimport type {\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopConfig,\n\tAgentMessage,\n\tAgentState,\n\tAgentTool,\n\tBeforeToolCallContext,\n\tBeforeToolCallResult,\n\tAfterToolCallContext,\n\tAfterToolCallResult,\n\tStreamFn,\n\tThinkingLevel,\n} from \"./types.js\";\n\n/**\n * Default convertToLlm: Keep only LLM-compatible messages, convert attachments.\n */\nfunction defaultConvertToLlm(messages: AgentMessage[]): Message[] {\n\treturn messages.filter((m) => m.role === \"user\" || m.role === \"assistant\" || m.role === \"toolResult\");\n}\n\nexport interface AgentOptions {\n\tinitialState?: Partial<AgentState>;\n\n\t/**\n\t * Converts AgentMessage[] to LLM-compatible Message[] before each LLM call.\n\t * Default filters to user/assistant/toolResult and converts attachments.\n\t */\n\tconvertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\n\t/**\n\t * Optional transform applied to context before convertToLlm.\n\t * Use for context pruning, injecting external context, etc.\n\t */\n\ttransformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\n\t/**\n\t * Steering mode: \"all\" = send all steering messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tsteeringMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Follow-up mode: \"all\" = send all follow-up messages at once, \"one-at-a-time\" = one per turn\n\t */\n\tfollowUpMode?: \"all\" | \"one-at-a-time\";\n\n\t/**\n\t * Custom stream function (for proxy backends, etc.). Default uses streamSimple.\n\t */\n\tstreamFn?: StreamFn;\n\n\t/**\n\t * Optional session identifier forwarded to LLM providers.\n\t * Used by providers that support session-based caching (e.g., OpenAI Codex).\n\t */\n\tsessionId?: string;\n\n\t/**\n\t * Resolves an API key dynamically for each LLM call.\n\t * Useful for expiring tokens (e.g., GitHub Copilot OAuth).\n\t */\n\tgetApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\n\t/**\n\t * Inspect or replace provider payloads before they are sent.\n\t */\n\tonPayload?: SimpleStreamOptions[\"onPayload\"];\n\n\t/**\n\t * Custom token budgets for thinking levels (token-based providers only).\n\t */\n\tthinkingBudgets?: ThinkingBudgets;\n\n\t/**\n\t * Preferred transport for providers that support multiple transports.\n\t */\n\ttransport?: Transport;\n\n\t/**\n\t * Maximum delay in milliseconds to wait for a retry when the server requests a long wait.\n\t * If the server's requested delay exceeds this value, the request fails immediately,\n\t * allowing higher-level retry logic to handle it with user visibility.\n\t * Default: 60000 (60 seconds). Set to 0 to disable the cap.\n\t */\n\tmaxRetryDelayMs?: number;\n\n\t/**\n\t * Determines whether a model uses external tool execution (tools handled\n\t * by the provider, not dispatched locally). Evaluated per-loop so model\n\t * switches mid-session are handled correctly.\n\t */\n\texternalToolExecution?: (model: Model<any>) => boolean;\n\n\t/**\n\t * Optional provider-specific options to merge into the next stream call.\n\t *\n\t * Use this for runtime-only callbacks or handles that should not live in\n\t * shared agent state, such as UI bridges for external CLI providers.\n\t */\n\tgetProviderOptions?: (model: Model<any>) => Record<string, unknown> | undefined | Promise<Record<string, unknown> | undefined>;\n}\n\n/**\n * Internal wrapper that tracks message origin for origin-aware queue clearing.\n * \"user\" = typed by human in TUI; \"system\" = generated by extensions/background jobs.\n */\ninterface QueueEntry {\n\tmessage: AgentMessage;\n\torigin: \"user\" | \"system\";\n}\n\nexport class Agent {\n\tprivate _state: AgentState = {\n\t\tsystemPrompt: \"\",\n\t\tmodel: getModel(\"google\", \"gemini-2.5-flash-lite-preview-06-17\"),\n\t\tthinkingLevel: \"off\",\n\t\ttools: [],\n\t\tmessages: [],\n\t\tisStreaming: false,\n\t\tstreamMessage: null,\n\t\tpendingToolCalls: new Set<string>(),\n\t\terror: undefined,\n\t};\n\n\tprivate listeners = new Set<(e: AgentEvent) => void>();\n\tprivate abortController?: AbortController;\n\tprivate convertToLlm: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;\n\tprivate transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;\n\tprivate steeringQueue: QueueEntry[] = [];\n\tprivate followUpQueue: QueueEntry[] = [];\n\tprivate steeringMode: \"all\" | \"one-at-a-time\";\n\tprivate followUpMode: \"all\" | \"one-at-a-time\";\n\tpublic streamFn: StreamFn;\n\tprivate _sessionId?: string;\n\tpublic getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;\n\tprivate _onPayload?: SimpleStreamOptions[\"onPayload\"];\n\tprivate runningPrompt?: Promise<void>;\n\tprivate resolveRunningPrompt?: () => void;\n\tprivate _thinkingBudgets?: ThinkingBudgets;\n\tprivate _transport: Transport;\n\tprivate _maxRetryDelayMs?: number;\n\tprivate _beforeToolCall?: AgentLoopConfig[\"beforeToolCall\"];\n\tprivate _afterToolCall?: AgentLoopConfig[\"afterToolCall\"];\n\tprivate _externalToolExecution?: (model: Model<any>) => boolean;\n\tprivate _getProviderOptions?: AgentOptions[\"getProviderOptions\"];\n\n\tconstructor(opts: AgentOptions = {}) {\n\t\tthis._state = { ...this._state, ...opts.initialState };\n\t\tthis.convertToLlm = opts.convertToLlm || defaultConvertToLlm;\n\t\tthis.transformContext = opts.transformContext;\n\t\tthis.steeringMode = opts.steeringMode || \"one-at-a-time\";\n\t\tthis.followUpMode = opts.followUpMode || \"one-at-a-time\";\n\t\tthis.streamFn = opts.streamFn || streamSimple;\n\t\tthis._sessionId = opts.sessionId;\n\t\tthis.getApiKey = opts.getApiKey;\n\t\tthis._onPayload = opts.onPayload;\n\t\tthis._thinkingBudgets = opts.thinkingBudgets;\n\t\tthis._transport = opts.transport ?? \"sse\";\n\t\tthis._maxRetryDelayMs = opts.maxRetryDelayMs;\n\t\tthis._externalToolExecution = opts.externalToolExecution;\n\t\tthis._getProviderOptions = opts.getProviderOptions;\n\t}\n\n\t/**\n\t * Get the current session ID used for provider caching.\n\t */\n\tget sessionId(): string | undefined {\n\t\treturn this._sessionId;\n\t}\n\n\t/**\n\t * Set the session ID for provider caching.\n\t * Call this when switching sessions (new session, branch, resume).\n\t */\n\tset sessionId(value: string | undefined) {\n\t\tthis._sessionId = value;\n\t}\n\n\t/**\n\t * Get the current thinking budgets.\n\t */\n\tget thinkingBudgets(): ThinkingBudgets | undefined {\n\t\treturn this._thinkingBudgets;\n\t}\n\n\t/**\n\t * Set custom thinking budgets for token-based providers.\n\t */\n\tset thinkingBudgets(value: ThinkingBudgets | undefined) {\n\t\tthis._thinkingBudgets = value;\n\t}\n\n\t/**\n\t * Get the current preferred transport.\n\t */\n\tget transport(): Transport {\n\t\treturn this._transport;\n\t}\n\n\t/**\n\t * Set the preferred transport.\n\t */\n\tsetTransport(value: Transport) {\n\t\tthis._transport = value;\n\t}\n\n\t/**\n\t * Get the current max retry delay in milliseconds.\n\t */\n\tget maxRetryDelayMs(): number | undefined {\n\t\treturn this._maxRetryDelayMs;\n\t}\n\n\t/**\n\t * Set the maximum delay to wait for server-requested retries.\n\t * Set to 0 to disable the cap.\n\t */\n\tset maxRetryDelayMs(value: number | undefined) {\n\t\tthis._maxRetryDelayMs = value;\n\t}\n\n\t/**\n\t * Install a hook called before each tool executes, after argument validation.\n\t * Return `{ block: true }` to prevent execution.\n\t */\n\tsetBeforeToolCall(fn: AgentLoopConfig[\"beforeToolCall\"]): void {\n\t\tthis._beforeToolCall = fn;\n\t}\n\n\t/**\n\t * Install a hook called after each tool executes, before results are emitted.\n\t * Return field overrides for content/details/isError.\n\t */\n\tsetAfterToolCall(fn: AgentLoopConfig[\"afterToolCall\"]): void {\n\t\tthis._afterToolCall = fn;\n\t}\n\n\tget state(): AgentState {\n\t\treturn this._state;\n\t}\n\n\tsubscribe(fn: (e: AgentEvent) => void): () => void {\n\t\tthis.listeners.add(fn);\n\t\treturn () => this.listeners.delete(fn);\n\t}\n\n\t// State mutators\n\tsetSystemPrompt(v: string) {\n\t\tthis._state.systemPrompt = v;\n\t}\n\n\tsetModel(m: Model<any>) {\n\t\tthis._state.model = m;\n\t}\n\n\tsetThinkingLevel(l: ThinkingLevel) {\n\t\tthis._state.thinkingLevel = l;\n\t}\n\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.steeringMode = mode;\n\t}\n\n\tgetSteeringMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.steeringMode;\n\t}\n\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\") {\n\t\tthis.followUpMode = mode;\n\t}\n\n\tgetFollowUpMode(): \"all\" | \"one-at-a-time\" {\n\t\treturn this.followUpMode;\n\t}\n\n\tsetTools(t: AgentTool<any>[]) {\n\t\tthis._state.tools = t;\n\t}\n\n\treplaceMessages(ms: AgentMessage[]) {\n\t\tthis._state.messages = ms.slice();\n\t}\n\n\tappendMessage(m: AgentMessage) {\n\t\tthis._state.messages = [...this._state.messages, m];\n\t}\n\n\t/**\n\t * Queue a steering message to interrupt the agent mid-run.\n\t * Delivered after current tool execution, skips remaining tools.\n\t */\n\tsteer(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.steeringQueue.push({ message: m, origin });\n\t}\n\n\t/**\n\t * Queue a follow-up message to be processed after the agent finishes.\n\t * Delivered only when agent has no more tool calls or steering messages.\n\t */\n\tfollowUp(m: AgentMessage, origin: \"user\" | \"system\" = \"system\") {\n\t\tthis.followUpQueue.push({ message: m, origin });\n\t}\n\n\tclearSteeringQueue() {\n\t\tthis.steeringQueue = [];\n\t}\n\n\tclearFollowUpQueue() {\n\t\tthis.followUpQueue = [];\n\t}\n\n\tclearAllQueues() {\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/**\n\t * Drain user-origin messages from queues, leaving system messages in place.\n\t * Used during abort to preserve messages the user explicitly typed.\n\t */\n\tdrainUserMessages(): { steering: AgentMessage[]; followUp: AgentMessage[] } {\n\t\tconst userSteering = this.steeringQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tconst userFollowUp = this.followUpQueue.filter((e) => e.origin === \"user\").map((e) => e.message);\n\t\tthis.steeringQueue = this.steeringQueue.filter((e) => e.origin !== \"user\");\n\t\tthis.followUpQueue = this.followUpQueue.filter((e) => e.origin !== \"user\");\n\t\treturn { steering: userSteering, followUp: userFollowUp };\n\t}\n\n\thasQueuedMessages(): boolean {\n\t\treturn this.steeringQueue.length > 0 || this.followUpQueue.length > 0;\n\t}\n\n\tprivate dequeueSteeringMessages(): AgentMessage[] {\n\t\tif (this.steeringMode === \"one-at-a-time\") {\n\t\t\tif (this.steeringQueue.length > 0) {\n\t\t\t\tconst first = this.steeringQueue[0];\n\t\t\t\tthis.steeringQueue = this.steeringQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst steering = this.steeringQueue.map((e) => e.message);\n\t\tthis.steeringQueue = [];\n\t\treturn steering;\n\t}\n\n\tprivate dequeueFollowUpMessages(): AgentMessage[] {\n\t\tif (this.followUpMode === \"one-at-a-time\") {\n\t\t\tif (this.followUpQueue.length > 0) {\n\t\t\t\tconst first = this.followUpQueue[0];\n\t\t\t\tthis.followUpQueue = this.followUpQueue.slice(1);\n\t\t\t\treturn [first.message];\n\t\t\t}\n\t\t\treturn [];\n\t\t}\n\n\t\tconst followUp = this.followUpQueue.map((e) => e.message);\n\t\tthis.followUpQueue = [];\n\t\treturn followUp;\n\t}\n\n\tclearMessages() {\n\t\tthis._state.messages = [];\n\t}\n\n\tabort() {\n\t\tthis.abortController?.abort();\n\t}\n\n\twaitForIdle(): Promise<void> {\n\t\treturn this.runningPrompt ?? Promise.resolve();\n\t}\n\n\treset() {\n\t\tthis._state.messages = [];\n\t\tthis._state.isStreaming = false;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\tthis._state.error = undefined;\n\t\tthis.steeringQueue = [];\n\t\tthis.followUpQueue = [];\n\t}\n\n\t/** Send a prompt with an AgentMessage */\n\tasync prompt(message: AgentMessage | AgentMessage[]): Promise<void>;\n\tasync prompt(input: string, images?: ImageContent[]): Promise<void>;\n\tasync prompt(input: string | AgentMessage | AgentMessage[], images?: ImageContent[]) {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Agent is already processing a prompt. Use steer() or followUp() to queue messages, or wait for completion.\",\n\t\t\t);\n\t\t}\n\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tlet msgs: AgentMessage[];\n\n\t\tif (Array.isArray(input)) {\n\t\t\tmsgs = input;\n\t\t} else if (typeof input === \"string\") {\n\t\t\tconst content: Array<TextContent | ImageContent> = [{ type: \"text\", text: input }];\n\t\t\tif (images && images.length > 0) {\n\t\t\t\tcontent.push(...images);\n\t\t\t}\n\t\t\tmsgs = [\n\t\t\t\t{\n\t\t\t\t\trole: \"user\",\n\t\t\t\t\tcontent,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t},\n\t\t\t];\n\t\t} else {\n\t\t\tmsgs = [input];\n\t\t}\n\n\t\tawait this._runLoop(msgs);\n\t}\n\n\t/**\n\t * Continue from current context (used for retries and resuming queued messages).\n\t */\n\tasync continue() {\n\t\tif (this._state.isStreaming) {\n\t\t\tthrow new Error(\"Agent is already processing. Wait for completion before continuing.\");\n\t\t}\n\n\t\tconst messages = this._state.messages;\n\t\tif (messages.length === 0) {\n\t\t\tthrow new Error(\"No messages to continue from\");\n\t\t}\n\t\tif (messages[messages.length - 1].role === \"assistant\") {\n\t\t\tconst queuedSteering = this.dequeueSteeringMessages();\n\t\t\tif (queuedSteering.length > 0) {\n\t\t\t\tawait this._runLoop(queuedSteering, { skipInitialSteeringPoll: true });\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst queuedFollowUp = this.dequeueFollowUpMessages();\n\t\t\tif (queuedFollowUp.length > 0) {\n\t\t\t\tawait this._runLoop(queuedFollowUp);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new Error(\"Cannot continue from message role: assistant\");\n\t\t}\n\n\t\tawait this._runLoop(undefined);\n\t}\n\n\t/**\n\t * Run the agent loop.\n\t * If messages are provided, starts a new conversation turn with those messages.\n\t * Otherwise, continues from existing context.\n\t */\n\tprivate async _runLoop(messages?: AgentMessage[], options?: { skipInitialSteeringPoll?: boolean }) {\n\t\tconst model = this._state.model;\n\t\tif (!model) throw new Error(\"No model configured\");\n\n\t\tthis._state.activeInferenceModel = model;\n\n\t\tthis.runningPrompt = new Promise<void>((resolve) => {\n\t\t\tthis.resolveRunningPrompt = resolve;\n\t\t});\n\n\t\tthis.abortController = new AbortController();\n\t\tthis._state.isStreaming = true;\n\t\tthis._state.streamMessage = null;\n\t\tthis._state.error = undefined;\n\n\t\tconst reasoning = this._state.thinkingLevel === \"off\" ? undefined : this._state.thinkingLevel;\n\n\t\tconst context: AgentContext = {\n\t\t\tsystemPrompt: this._state.systemPrompt,\n\t\t\tmessages: this._state.messages.slice(),\n\t\t\ttools: this._state.tools,\n\t\t};\n\n\t\tlet skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;\n\t\tconst providerOptions = await this._getProviderOptions?.(model);\n\n\t\tconst config: AgentLoopConfig = {\n\t\t\t...(providerOptions ?? {}),\n\t\t\tmodel,\n\t\t\treasoning,\n\t\t\tsessionId: this._sessionId,\n\t\t\tonPayload: this._onPayload,\n\t\t\ttransport: this._transport,\n\t\t\tthinkingBudgets: this._thinkingBudgets,\n\t\t\tmaxRetryDelayMs: this._maxRetryDelayMs,\n\t\t\tconvertToLlm: this.convertToLlm,\n\t\t\ttransformContext: this.transformContext,\n\t\t\tgetApiKey: this.getApiKey,\n\t\t\tgetSteeringMessages: async () => {\n\t\t\t\tif (skipInitialSteeringPoll) {\n\t\t\t\t\tskipInitialSteeringPoll = false;\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\treturn this.dequeueSteeringMessages();\n\t\t\t},\n\t\t\tgetFollowUpMessages: async () => this.dequeueFollowUpMessages(),\n\t\t\tbeforeToolCall: this._beforeToolCall,\n\t\t\tafterToolCall: this._afterToolCall,\n\t\t\texternalToolExecution: this._externalToolExecution?.(model) ?? false,\n\t\t};\n\n\t\tlet partial: AgentMessage | null = null;\n\n\t\ttry {\n\t\t\tconst stream = messages\n\t\t\t\t? agentLoop(messages, context, config, this.abortController.signal, this.streamFn)\n\t\t\t\t: agentLoopContinue(context, config, this.abortController.signal, this.streamFn);\n\n\t\t\tfor await (const event of stream) {\n\t\t\t\t// Update internal state based on events\n\t\t\t\tswitch (event.type) {\n\t\t\t\t\tcase \"message_start\":\n\t\t\t\t\tcase \"message_update\":\n\t\t\t\t\t\tpartial = event.message;\n\t\t\t\t\t\tthis._state.streamMessage = event.message;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"message_end\":\n\t\t\t\t\t\tpartial = null;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tthis.appendMessage(event.message);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_start\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"add\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"tool_execution_end\":\n\t\t\t\t\t\tthis._updatePendingToolCalls(\"delete\", event.toolCallId);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"turn_end\":\n\t\t\t\t\t\tif (event.message.role === \"assistant\" && (event.message as any).errorMessage) {\n\t\t\t\t\t\t\tthis._state.error = (event.message as any).errorMessage;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"agent_end\":\n\t\t\t\t\t\tthis._state.isStreaming = false;\n\t\t\t\t\t\tthis._state.streamMessage = null;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Emit to listeners\n\t\t\t\tthis.emit(event);\n\t\t\t}\n\n\t\t\t// Handle any remaining partial message\n\t\t\tif (partial && partial.role === \"assistant\" && partial.content.length > 0) {\n\t\t\t\tconst onlyEmpty = !partial.content.some(\n\t\t\t\t\t(c) =>\n\t\t\t\t\t\t(c.type === \"thinking\" && c.thinking.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"text\" && c.text.trim().length > 0) ||\n\t\t\t\t\t\t(c.type === \"toolCall\" && c.name.trim().length > 0),\n\t\t\t\t);\n\t\t\t\tif (!onlyEmpty) {\n\t\t\t\t\tthis.appendMessage(partial);\n\t\t\t\t} else {\n\t\t\t\t\tif (this.abortController?.signal.aborted) {\n\t\t\t\t\t\tthrow new Error(\"Request was aborted\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\tconst errorMsg: AgentMessage = {\n\t\t\t\trole: \"assistant\",\n\t\t\t\tcontent: [{ type: \"text\", text: \"\" }],\n\t\t\t\tapi: model.api,\n\t\t\t\tprovider: model.provider,\n\t\t\t\tmodel: model.id,\n\t\t\t\tusage: ZERO_USAGE,\n\t\t\t\tstopReason: this.abortController?.signal.aborted ? \"aborted\" : \"error\",\n\t\t\t\terrorMessage: err?.message || String(err),\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t} as AgentMessage;\n\n\t\t\tthis.appendMessage(errorMsg);\n\t\t\tthis._state.error = err?.message || String(err);\n\t\t\tthis.emit({ type: \"agent_end\", messages: [errorMsg] });\n\t\t} finally {\n\t\t\tthis._state.isStreaming = false;\n\t\t\tthis._state.streamMessage = null;\n\t\t\tthis._state.pendingToolCalls = new Set<string>();\n\t\t\tthis._state.activeInferenceModel = undefined;\n\t\t\tthis.abortController = undefined;\n\t\t\tthis.resolveRunningPrompt?.();\n\t\t\tthis.runningPrompt = undefined;\n\t\t\tthis.resolveRunningPrompt = undefined;\n\t\t}\n\t}\n\n\tprivate _updatePendingToolCalls(action: \"add\" | \"delete\", id: string): void {\n\t\tconst s = new Set(this._state.pendingToolCalls);\n\t\ts[action](id);\n\t\tthis._state.pendingToolCalls = s;\n\t}\n\n\tprivate emit(e: AgentEvent) {\n\t\tfor (const listener of this.listeners) {\n\t\t\tlistener(e);\n\t\t}\n\t}\n}\n"]}
@@ -8,6 +8,8 @@ import assert from "node:assert/strict";
8
8
  import { readFileSync } from "node:fs";
9
9
  import { join, dirname } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
+ import { Agent } from "./agent.ts";
12
+ import { getModel, type AssistantMessageEventStream } from "@gsd/pi-ai";
11
13
 
12
14
  const __dirname = dirname(fileURLToPath(import.meta.url));
13
15
 
@@ -50,4 +52,84 @@ describe("Agent — activeInferenceModel (#1844 Bug 2)", () => {
50
52
  assert.ok(setLine < abortLine,
51
53
  "activeInferenceModel must be set before streaming infrastructure is created");
52
54
  });
55
+
56
+ it("getProviderOptions are forwarded into the provider stream call", async () => {
57
+ let capturedOptions: Record<string, unknown> | undefined;
58
+ const agent = new Agent({
59
+ initialState: {
60
+ model: getModel("anthropic", "claude-3-5-sonnet-20241022"),
61
+ systemPrompt: "test",
62
+ tools: [],
63
+ },
64
+ getProviderOptions: async () => ({ customRuntimeOption: "present" }),
65
+ streamFn: (_model, _context, options): AssistantMessageEventStream => {
66
+ capturedOptions = options as Record<string, unknown> | undefined;
67
+ return {
68
+ async *[Symbol.asyncIterator]() {
69
+ yield {
70
+ type: "start",
71
+ partial: {
72
+ role: "assistant",
73
+ content: [],
74
+ api: "anthropic-messages",
75
+ provider: "anthropic",
76
+ model: "claude-3-5-sonnet-20241022",
77
+ usage: {
78
+ input: 0,
79
+ output: 0,
80
+ cacheRead: 0,
81
+ cacheWrite: 0,
82
+ totalTokens: 0,
83
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
84
+ },
85
+ stopReason: "stop",
86
+ timestamp: Date.now(),
87
+ },
88
+ };
89
+ yield {
90
+ type: "done",
91
+ message: {
92
+ role: "assistant",
93
+ content: [{ type: "text", text: "ok" }],
94
+ api: "anthropic-messages",
95
+ provider: "anthropic",
96
+ model: "claude-3-5-sonnet-20241022",
97
+ usage: {
98
+ input: 0,
99
+ output: 0,
100
+ cacheRead: 0,
101
+ cacheWrite: 0,
102
+ totalTokens: 0,
103
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
104
+ },
105
+ stopReason: "stop",
106
+ timestamp: Date.now(),
107
+ },
108
+ };
109
+ },
110
+ result: async () => ({
111
+ role: "assistant",
112
+ content: [{ type: "text", text: "ok" }],
113
+ api: "anthropic-messages",
114
+ provider: "anthropic",
115
+ model: "claude-3-5-sonnet-20241022",
116
+ usage: {
117
+ input: 0,
118
+ output: 0,
119
+ cacheRead: 0,
120
+ cacheWrite: 0,
121
+ totalTokens: 0,
122
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
123
+ },
124
+ stopReason: "stop",
125
+ timestamp: Date.now(),
126
+ }),
127
+ [Symbol.asyncDispose]: async () => {},
128
+ } as AssistantMessageEventStream;
129
+ },
130
+ });
131
+
132
+ await agent.prompt("hello");
133
+ assert.equal(capturedOptions?.customRuntimeOption, "present");
134
+ });
53
135
  });
@@ -108,6 +108,14 @@ export interface AgentOptions {
108
108
  * switches mid-session are handled correctly.
109
109
  */
110
110
  externalToolExecution?: (model: Model<any>) => boolean;
111
+
112
+ /**
113
+ * Optional provider-specific options to merge into the next stream call.
114
+ *
115
+ * Use this for runtime-only callbacks or handles that should not live in
116
+ * shared agent state, such as UI bridges for external CLI providers.
117
+ */
118
+ getProviderOptions?: (model: Model<any>) => Record<string, unknown> | undefined | Promise<Record<string, unknown> | undefined>;
111
119
  }
112
120
 
113
121
  /**
@@ -152,6 +160,7 @@ export class Agent {
152
160
  private _beforeToolCall?: AgentLoopConfig["beforeToolCall"];
153
161
  private _afterToolCall?: AgentLoopConfig["afterToolCall"];
154
162
  private _externalToolExecution?: (model: Model<any>) => boolean;
163
+ private _getProviderOptions?: AgentOptions["getProviderOptions"];
155
164
 
156
165
  constructor(opts: AgentOptions = {}) {
157
166
  this._state = { ...this._state, ...opts.initialState };
@@ -167,6 +176,7 @@ export class Agent {
167
176
  this._transport = opts.transport ?? "sse";
168
177
  this._maxRetryDelayMs = opts.maxRetryDelayMs;
169
178
  this._externalToolExecution = opts.externalToolExecution;
179
+ this._getProviderOptions = opts.getProviderOptions;
170
180
  }
171
181
 
172
182
  /**
@@ -486,8 +496,10 @@ export class Agent {
486
496
  };
487
497
 
488
498
  let skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;
499
+ const providerOptions = await this._getProviderOptions?.(model);
489
500
 
490
501
  const config: AgentLoopConfig = {
502
+ ...(providerOptions ?? {}),
491
503
  model,
492
504
  reasoning,
493
505
  sessionId: this._sessionId,
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,MAAM,aAAa,CAAC;AAKrB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,mBAAmB,EAInB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAuH/B,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAsClF,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAuC3F,CAAC"}
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,MAAM,aAAa,CAAC;AAKrB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,mBAAmB,EAInB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAyF/B,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAsClF,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAuC3F,CAAC"}
@@ -12,8 +12,6 @@ async function getAnthropicClass() {
12
12
  }
13
13
  return _AnthropicClass;
14
14
  }
15
- // Stealth mode: Mimic Claude Code's tool naming exactly
16
- const claudeCodeVersion = "2.1.62";
17
15
  function mergeHeaders(...headerSources) {
18
16
  const merged = {};
19
17
  for (const headers of headerSources) {
@@ -23,9 +21,6 @@ function mergeHeaders(...headerSources) {
23
21
  }
24
22
  return merged;
25
23
  }
26
- function isOAuthToken(apiKey) {
27
- return apiKey.includes("sk-ant-oat");
28
- }
29
24
  async function createClient(model, apiKey, interleavedThinking, optionsHeaders, dynamicHeaders) {
30
25
  const AnthropicClass = await getAnthropicClass();
31
26
  // Adaptive thinking models (Opus 4.6, Sonnet 4.6) have interleaved thinking built-in.
@@ -56,24 +51,7 @@ async function createClient(model, apiKey, interleavedThinking, optionsHeaders,
56
51
  if (needsInterleavedBeta && !skipBetaHeaders) {
57
52
  betaFeatures.push("interleaved-thinking-2025-05-14");
58
53
  }
59
- // OAuth: Bearer auth, Claude Code identity headers
60
- if (isOAuthToken(apiKey)) {
61
- const client = new AnthropicClass({
62
- apiKey: null,
63
- authToken: apiKey,
64
- baseURL: model.baseUrl,
65
- dangerouslyAllowBrowser: true,
66
- defaultHeaders: mergeHeaders({
67
- accept: "application/json",
68
- "anthropic-dangerous-direct-browser-access": "true",
69
- ...(betaFeatures.length > 0 ? { "anthropic-beta": `claude-code-20250219,oauth-2025-04-20,${betaFeatures.join(",")}` } : {}),
70
- "user-agent": `claude-cli/${claudeCodeVersion}`,
71
- "x-app": "cli",
72
- }, model.headers, optionsHeaders),
73
- });
74
- return { client, isOAuthToken: true };
75
- }
76
- // API key auth
54
+ // API key auth (Anthropic OAuth removed per TOS compliance — use API keys or Claude CLI)
77
55
  // Alibaba Coding Plan uses Bearer token auth instead of x-api-key
78
56
  const isAlibabaProvider = model.provider === "alibaba-coding-plan";
79
57
  const client = new AnthropicClass({
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAGN,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,GACxB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAE/B,IAAI,eAA6C,CAAC;AAClD,KAAK,UAAU,iBAAiB;IAC/B,IAAI,CAAC,eAAe,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC9C,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC;IAC/B,CAAC;IACD,OAAO,eAAe,CAAC;AACxB,CAAC;AAED,wDAAwD;AACxD,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAEnC,SAAS,YAAY,CAAC,GAAG,aAAqD;IAC7E,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;QACrC,IAAI,OAAO,EAAE,CAAC;YACb,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC;A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n// This avoids penalizing users who don't use Anthropic models.\nimport type Anthropic from \"@anthropic-ai/sdk\";\nimport { getEnvApiKey } from \"../env-api-keys.js\";\nimport type {\n\tContext,\n\tModel,\n\tSimpleStreamOptions,\n\tStreamFunction,\n} from \"../types.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\n\nimport { buildCopilotDynamicHeaders, hasCopilotVisionInput } from \"./github-copilot-headers.js\";\nimport { adjustMaxTokensForThinking, buildBaseOptions } from \"./simple-options.js\";\nimport {\n\ttype AnthropicEffort,\n\ttype AnthropicOptions,\n\textractRetryAfterMs,\n\tmapThinkingLevelToEffort,\n\tprocessAnthropicStream,\n\tsupportsAdaptiveThinking,\n} from \"./anthropic-shared.js\";\n\n// Re-export types used by other modules\nexport type { AnthropicEffort, AnthropicOptions };\nexport { extractRetryAfterMs };\n\nlet _AnthropicClass: typeof Anthropic | undefined;\nasync function getAnthropicClass(): Promise<typeof Anthropic> {\n\tif (!_AnthropicClass) {\n\t\tconst mod = await import(\"@anthropic-ai/sdk\");\n\t\t_AnthropicClass = mod.default;\n\t}\n\treturn _AnthropicClass;\n}\n\n// Stealth mode: Mimic Claude Code's tool naming exactly\nconst claudeCodeVersion = \"2.1.62\";\n\nfunction mergeHeaders(...headerSources: (Record<string, string> | undefined)[]): Record<string, string> {\n\tconst merged: Record<string, string> = {};\n\tfor (const headers of headerSources) {\n\t\tif (headers) {\n\t\t\tObject.assign(merged, headers);\n\t\t}\n\t}\n\treturn merged;\n}\n\nfunction isOAuthToken(apiKey: string): boolean {\n\treturn apiKey.includes(\"sk-ant-oat\");\n}\n\nasync function createClient(\n\tmodel: Model<\"anthropic-messages\">,\n\tapiKey: string,\n\tinterleavedThinking: boolean,\n\toptionsHeaders?: Record<string, string>,\n\tdynamicHeaders?: Record<string, string>,\n): Promise<{ client: Anthropic; isOAuthToken: boolean }> {\n\tconst AnthropicClass = await getAnthropicClass();\n\t// Adaptive thinking models (Opus 4.6, Sonnet 4.6) have interleaved thinking built-in.\n\t// The beta header is deprecated on Opus 4.6 and redundant on Sonnet 4.6, so skip it.\n\tconst needsInterleavedBeta = interleavedThinking && !supportsAdaptiveThinking(model.id);\n\n\t// Copilot: Bearer auth, selective betas (no fine-grained-tool-streaming)\n\tif (model.provider === \"github-copilot\") {\n\t\tconst betaFeatures: string[] = [];\n\t\tif (needsInterleavedBeta) {\n\t\t\tbetaFeatures.push(\"interleaved-thinking-2025-05-14\");\n\t\t}\n\n\t\tconst client = new AnthropicClass({\n\t\t\tapiKey: null,\n\t\t\tauthToken: apiKey,\n\t\t\tbaseURL: model.baseUrl,\n\t\t\tdangerouslyAllowBrowser: true,\n\t\t\tdefaultHeaders: mergeHeaders(\n\t\t\t\t{\n\t\t\t\t\taccept: \"application/json\",\n\t\t\t\t\t\"anthropic-dangerous-direct-browser-access\": \"true\",\n\t\t\t\t\t...(betaFeatures.length > 0 ? { \"anthropic-beta\": betaFeatures.join(\",\") } : {}),\n\t\t\t\t},\n\t\t\t\tmodel.headers,\n\t\t\t\tdynamicHeaders,\n\t\t\t\toptionsHeaders,\n\t\t\t),\n\t\t});\n\n\t\treturn { client, isOAuthToken: false };\n\t}\n\n\t// Skip beta headers for providers that don't support them (e.g., Alibaba Coding Plan)\n\tconst skipBetaHeaders = model.provider === \"alibaba-coding-plan\";\n\tconst betaFeatures = skipBetaHeaders ? [] : [\"fine-grained-tool-streaming-2025-05-14\"];\n\tif (needsInterleavedBeta && !skipBetaHeaders) {\n\t\tbetaFeatures.push(\"interleaved-thinking-2025-05-14\");\n\t}\n\n\t// OAuth: Bearer auth, Claude Code identity headers\n\tif (isOAuthToken(apiKey)) {\n\t\tconst client = new AnthropicClass({\n\t\t\tapiKey: null,\n\t\t\tauthToken: apiKey,\n\t\t\tbaseURL: model.baseUrl,\n\t\t\tdangerouslyAllowBrowser: true,\n\t\t\tdefaultHeaders: mergeHeaders(\n\t\t\t\t{\n\t\t\t\t\taccept: \"application/json\",\n\t\t\t\t\t\"anthropic-dangerous-direct-browser-access\": \"true\",\n\t\t\t\t\t...(betaFeatures.length > 0 ? { \"anthropic-beta\": `claude-code-20250219,oauth-2025-04-20,${betaFeatures.join(\",\")}` } : {}),\n\t\t\t\t\t\"user-agent\": `claude-cli/${claudeCodeVersion}`,\n\t\t\t\t\t\"x-app\": \"cli\",\n\t\t\t\t},\n\t\t\t\tmodel.headers,\n\t\t\t\toptionsHeaders,\n\t\t\t),\n\t\t});\n\n\t\treturn { client, isOAuthToken: true };\n\t}\n\n\t// API key auth\n\t// Alibaba Coding Plan uses Bearer token auth instead of x-api-key\n\tconst isAlibabaProvider = model.provider === \"alibaba-coding-plan\";\n\tconst client = new AnthropicClass({\n\t\tapiKey: isAlibabaProvider ? null : apiKey,\n\t\tauthToken: isAlibabaProvider ? apiKey : undefined,\n\t\tbaseURL: model.baseUrl,\n\t\tdangerouslyAllowBrowser: true,\n\t\tdefaultHeaders: mergeHeaders(\n\t\t\t{\n\t\t\t\taccept: \"application/json\",\n\t\t\t\t\"anthropic-dangerous-direct-browser-access\": \"true\",\n\t\t\t\t...(betaFeatures.length > 0 ? { \"anthropic-beta\": betaFeatures.join(\",\") } : {}),\n\t\t\t},\n\t\t\tmodel.headers,\n\t\t\toptionsHeaders,\n\t\t),\n\t});\n\n\treturn { client, isOAuthToken: false };\n}\n\nexport const streamAnthropic: StreamFunction<\"anthropic-messages\", AnthropicOptions> = (\n\tmodel: Model<\"anthropic-messages\">,\n\tcontext: Context,\n\toptions?: AnthropicOptions,\n): AssistantMessageEventStream => {\n\tconst stream = new AssistantMessageEventStream();\n\n\t(async () => {\n\t\tconst apiKey = options?.apiKey ?? getEnvApiKey(model.provider) ?? \"\";\n\n\t\tlet copilotDynamicHeaders: Record<string, string> | undefined;\n\t\tif (model.provider === \"github-copilot\") {\n\t\t\tconst hasImages = hasCopilotVisionInput(context.messages);\n\t\t\tcopilotDynamicHeaders = buildCopilotDynamicHeaders({\n\t\t\t\tmessages: context.messages,\n\t\t\t\thasImages,\n\t\t\t});\n\t\t}\n\n\t\tconst { client, isOAuthToken: isOAuth } = await createClient(\n\t\t\tmodel,\n\t\t\tapiKey,\n\t\t\toptions?.interleavedThinking ?? true,\n\t\t\toptions?.headers,\n\t\t\tcopilotDynamicHeaders,\n\t\t);\n\n\t\tprocessAnthropicStream(stream, {\n\t\t\tclient,\n\t\t\tmodel,\n\t\t\tcontext,\n\t\t\tisOAuthToken: isOAuth,\n\t\t\toptions,\n\t\t\tAnthropicSdkClass: _AnthropicClass,\n\t\t});\n\t})();\n\n\treturn stream;\n};\n\nexport const streamSimpleAnthropic: StreamFunction<\"anthropic-messages\", SimpleStreamOptions> = (\n\tmodel: Model<\"anthropic-messages\">,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): AssistantMessageEventStream => {\n\tconst apiKey = options?.apiKey || getEnvApiKey(model.provider);\n\tif (!apiKey) {\n\t\tthrow new Error(`No API key for provider: ${model.provider}`);\n\t}\n\n\tconst base = buildBaseOptions(model, options, apiKey);\n\tif (!options?.reasoning) {\n\t\treturn streamAnthropic(model, context, { ...base, thinkingEnabled: false } satisfies AnthropicOptions);\n\t}\n\n\t// For Opus 4.6 and Sonnet 4.6: use adaptive thinking with effort level\n\t// For older models: use budget-based thinking\n\tif (supportsAdaptiveThinking(model.id)) {\n\t\tconst effort = mapThinkingLevelToEffort(options.reasoning, model.id);\n\t\treturn streamAnthropic(model, context, {\n\t\t\t...base,\n\t\t\tthinkingEnabled: true,\n\t\t\teffort,\n\t\t} satisfies AnthropicOptions);\n\t}\n\n\tconst adjusted = adjustMaxTokensForThinking(\n\t\tbase.maxTokens || 0,\n\t\tmodel.maxTokens,\n\t\toptions.reasoning,\n\t\toptions.thinkingBudgets,\n\t);\n\n\treturn streamAnthropic(model, context, {\n\t\t...base,\n\t\tmaxTokens: adjusted.maxTokens,\n\t\tthinkingEnabled: true,\n\t\tthinkingBudgetTokens: adjusted.thinkingBudget,\n\t} satisfies AnthropicOptions);\n};\n"]}
1
+ {"version":3,"file":"anthropic.js","s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CAAC;IAEF,OAAO,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE;QACtC,GAAG,IAAI;QACP,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,eAAe,EAAE,IAAI;QACrB,oBAAoB,EAAE,QAAQ,CAAC,cAAc;KAClB,CAAC,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["// Lazy-loaded: Anthropic SDK (~500ms) is imported on first use, not at startup.\n// This avoids penalizing users who don't use Anthropic models.\nimport type Anthropic from \"@anthropic-ai/sdk\";\nimport { getEnvApiKey } from \"../env-api-keys.js\";\nimport type {\n\tContext,\n\tModel,\n\tSimpleStreamOptions,\n\tStreamFunction,\n} from \"../types.js\";\nimport { AssistantMessageEventStream } from \"../utils/event-stream.js\";\n\nimport { buildCopilotDynamicHeaders, hasCopilotVisionInput } from \"./github-copilot-headers.js\";\nimport { adjustMaxTokensForThinking, buildBaseOptions } from \"./simple-options.js\";\nimport {\n\ttype AnthropicEffort,\n\ttype AnthropicOptions,\n\textractRetryAfterMs,\n\tmapThinkingLevelToEffort,\n\tprocessAnthropicStream,\n\tsupportsAdaptiveThinking,\n} from \"./anthropic-shared.js\";\n\n// Re-export types used by other modules\nexport type { AnthropicEffort, AnthropicOptions };\nexport { extractRetryAfterMs };\n\nlet _AnthropicClass: typeof Anthropic | undefined;\nasync function getAnthropicClass(): Promise<typeof Anthropic> {\n\tif (!_AnthropicClass) {\n\t\tconst mod = await import(\"@anthropic-ai/sdk\");\n\t\t_AnthropicClass = mod.default;\n\t}\n\treturn _AnthropicClass;\n}\n\nfunction mergeHeaders(...headerSources: (Record<string, string> | undefined)[]): Record<string, string> {\n\tconst merged: Record<string, string> = {};\n\tfor (const headers of headerSources) {\n\t\tif (headers) {\n\t\t\tObject.assign(merged, headers);\n\t\t}\n\t}\n\treturn merged;\n}\n\nasync function createClient(\n\tmodel: Model<\"anthropic-messages\">,\n\tapiKey: string,\n\tinterleavedThinking: boolean,\n\toptionsHeaders?: Record<string, string>,\n\tdynamicHeaders?: Record<string, string>,\n): Promise<{ client: Anthropic; isOAuthToken: boolean }> {\n\tconst AnthropicClass = await getAnthropicClass();\n\t// Adaptive thinking models (Opus 4.6, Sonnet 4.6) have interleaved thinking built-in.\n\t// The beta header is deprecated on Opus 4.6 and redundant on Sonnet 4.6, so skip it.\n\tconst needsInterleavedBeta = interleavedThinking && !supportsAdaptiveThinking(model.id);\n\n\t// Copilot: Bearer auth, selective betas (no fine-grained-tool-streaming)\n\tif (model.provider === \"github-copilot\") {\n\t\tconst betaFeatures: string[] = [];\n\t\tif (needsInterleavedBeta) {\n\t\t\tbetaFeatures.push(\"interleaved-thinking-2025-05-14\");\n\t\t}\n\n\t\tconst client = new AnthropicClass({\n\t\t\tapiKey: null,\n\t\t\tauthToken: apiKey,\n\t\t\tbaseURL: model.baseUrl,\n\t\t\tdangerouslyAllowBrowser: true,\n\t\t\tdefaultHeaders: mergeHeaders(\n\t\t\t\t{\n\t\t\t\t\taccept: \"application/json\",\n\t\t\t\t\t\"anthropic-dangerous-direct-browser-access\": \"true\",\n\t\t\t\t\t...(betaFeatures.length > 0 ? { \"anthropic-beta\": betaFeatures.join(\",\") } : {}),\n\t\t\t\t},\n\t\t\t\tmodel.headers,\n\t\t\t\tdynamicHeaders,\n\t\t\t\toptionsHeaders,\n\t\t\t),\n\t\t});\n\n\t\treturn { client, isOAuthToken: false };\n\t}\n\n\t// Skip beta headers for providers that don't support them (e.g., Alibaba Coding Plan)\n\tconst skipBetaHeaders = model.provider === \"alibaba-coding-plan\";\n\tconst betaFeatures = skipBetaHeaders ? [] : [\"fine-grained-tool-streaming-2025-05-14\"];\n\tif (needsInterleavedBeta && !skipBetaHeaders) {\n\t\tbetaFeatures.push(\"interleaved-thinking-2025-05-14\");\n\t}\n\n\t// API key auth (Anthropic OAuth removed per TOS compliance — use API keys or Claude CLI)\n\t// Alibaba Coding Plan uses Bearer token auth instead of x-api-key\n\tconst isAlibabaProvider = model.provider === \"alibaba-coding-plan\";\n\tconst client = new AnthropicClass({\n\t\tapiKey: isAlibabaProvider ? null : apiKey,\n\t\tauthToken: isAlibabaProvider ? apiKey : undefined,\n\t\tbaseURL: model.baseUrl,\n\t\tdangerouslyAllowBrowser: true,\n\t\tdefaultHeaders: mergeHeaders(\n\t\t\t{\n\t\t\t\taccept: \"application/json\",\n\t\t\t\t\"anthropic-dangerous-direct-browser-access\": \"true\",\n\t\t\t\t...(betaFeatures.length > 0 ? { \"anthropic-beta\": betaFeatures.join(\",\") } : {}),\n\t\t\t},\n\t\t\tmodel.headers,\n\t\t\toptionsHeaders,\n\t\t),\n\t});\n\n\treturn { client, isOAuthToken: false };\n}\n\nexport const streamAnthropic: StreamFunction<\"anthropic-messages\", AnthropicOptions> = (\n\tmodel: Model<\"anthropic-messages\">,\n\tcontext: Context,\n\toptions?: AnthropicOptions,\n): AssistantMessageEventStream => {\n\tconst stream = new AssistantMessageEventStream();\n\n\t(async () => {\n\t\tconst apiKey = options?.apiKey ?? getEnvApiKey(model.provider) ?? \"\";\n\n\t\tlet copilotDynamicHeaders: Record<string, string> | undefined;\n\t\tif (model.provider === \"github-copilot\") {\n\t\t\tconst hasImages = hasCopilotVisionInput(context.messages);\n\t\t\tcopilotDynamicHeaders = buildCopilotDynamicHeaders({\n\t\t\t\tmessages: context.messages,\n\t\t\t\thasImages,\n\t\t\t});\n\t\t}\n\n\t\tconst { client, isOAuthToken: isOAuth } = await createClient(\n\t\t\tmodel,\n\t\t\tapiKey,\n\t\t\toptions?.interleavedThinking ?? true,\n\t\t\toptions?.headers,\n\t\t\tcopilotDynamicHeaders,\n\t\t);\n\n\t\tprocessAnthropicStream(stream, {\n\t\t\tclient,\n\t\t\tmodel,\n\t\t\tcontext,\n\t\t\tisOAuthToken: isOAuth,\n\t\t\toptions,\n\t\t\tAnthropicSdkClass: _AnthropicClass,\n\t\t});\n\t})();\n\n\treturn stream;\n};\n\nexport const streamSimpleAnthropic: StreamFunction<\"anthropic-messages\", SimpleStreamOptions> = (\n\tmodel: Model<\"anthropic-messages\">,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n): AssistantMessageEventStream => {\n\tconst apiKey = options?.apiKey || getEnvApiKey(model.provider);\n\tif (!apiKey) {\n\t\tthrow new Error(`No API key for provider: ${model.provider}`);\n\t}\n\n\tconst base = buildBaseOptions(model, options, apiKey);\n\tif (!options?.reasoning) {\n\t\treturn streamAnthropic(model, context, { ...base, thinkingEnabled: false } satisfies AnthropicOptions);\n\t}\n\n\t// For Opus 4.6 and Sonnet 4.6: use adaptive thinking with effort level\n\t// For older models: use budget-based thinking\n\tif (supportsAdaptiveThinking(model.id)) {\n\t\tconst effort = mapThinkingLevelToEffort(options.reasoning, model.id);\n\t\treturn streamAnthropic(model, context, {\n\t\t\t...base,\n\t\t\tthinkingEnabled: true,\n\t\t\teffort,\n\t\t} satisfies AnthropicOptions);\n\t}\n\n\tconst adjusted = adjustMaxTokensForThinking(\n\t\tbase.maxTokens || 0,\n\t\tmodel.maxTokens,\n\t\toptions.reasoning,\n\t\toptions.thinkingBudgets,\n\t);\n\n\treturn streamAnthropic(model, context, {\n\t\t...base,\n\t\tmaxTokens: adjusted.maxTokens,\n\t\tthinkingEnabled: true,\n\t\tthinkingBudgetTokens: adjusted.thinkingBudget,\n\t} satisfies AnthropicOptions);\n};\n"]}
@@ -3,12 +3,13 @@
3
3
  *
4
4
  * This module handles login, token refresh, and credential storage
5
5
  * for OAuth-based providers:
6
- * - Anthropic (Claude Pro/Max)
7
6
  * - GitHub Copilot
8
7
  * - Google Cloud Code Assist (Gemini CLI)
9
8
  * - Antigravity (Gemini 3, Claude, GPT-OSS via Google Cloud)
9
+ *
10
+ * Note: Anthropic OAuth was removed per TOS compliance (see docs/user-docs/claude-code-auth-compliance.md).
11
+ * Use API keys or the local Claude Code CLI for Anthropic access.
10
12
  */
11
- export { anthropicOAuthProvider, loginAnthropic, refreshAnthropicToken } from "./anthropic.js";
12
13
  export { getGitHubCopilotBaseUrl, githubCopilotOAuthProvider, loginGitHubCopilot, normalizeDomain, refreshGitHubCopilotToken, } from "./github-copilot.js";
13
14
  export { antigravityOAuthProvider, loginAntigravity, refreshAntigravityToken } from "./google-antigravity.js";
14
15
  export { geminiCliOAuthProvider, loginGeminiCli, refreshGoogleCloudToken } from "./google-gemini-cli.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE/F,OAAO,EACN,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,yBAAyB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE9G,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEzG,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAExG,cAAc,YAAY,CAAC;AAW3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAc5F;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,eAAe,GAAG,sBAAsB,GAAG,SAAS,CAExF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAOxD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,sBAAsB,EAAE,CAE5D;AAMD;;;;;;GAMG;AACH,wBAAsB,cAAc,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,gBAAgB,CAAC,GAC3C,OAAO,CAAC;IAAE,cAAc,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAsBtE"}
@@ -3,13 +3,13 @@
3
3
  *
4
4
  * This module handles login, token refresh, and credential storage
5
5
  * for OAuth-based providers:
6
- * - Anthropic (Claude Pro/Max)
7
6
  * - GitHub Copilot
8
7
  * - Google Cloud Code Assist (Gemini CLI)
9
8
  * - Antigravity (Gemini 3, Claude, GPT-OSS via Google Cloud)
9
+ *
10
+ * Note: Anthropic OAuth was removed per TOS compliance (see docs/user-docs/claude-code-auth-compliance.md).
11
+ * Use API keys or the local Claude Code CLI for Anthropic access.
10
12
  */
11
- // Anthropic
12
- export { anthropicOAuthProvider, loginAnthropic, refreshAnthropicToken } from "./anthropic.js";
13
13
  // GitHub Copilot
14
14
  export { getGitHubCopilotBaseUrl, githubCopilotOAuthProvider, loginGitHubCopilot, normalizeDomain, refreshGitHubCopilotToken, } from "./github-copilot.js";
15
15
  // Google Antigravity
@@ -22,13 +22,11 @@ export * from "./types.js";
22
22
  // ============================================================================
23
23
  // Provider Registry
24
24
  // ============================================================================
25
- import { anthropicOAuthProvider } from "./anthropic.js";
26
25
  import { githubCopilotOAuthProvider } from "./github-copilot.js";
27
26
  import { antigravityOAuthProvider } from "./google-antigravity.js";
28
27
  import { geminiCliOAuthProvider } from "./google-gemini-cli.js";
29
28
  import { openaiCodexOAuthProvider } from "./openai-codex.js";
30
29
  const BUILT_IN_OAUTH_PROVIDERS = [
31
- anthropicOAuthProvider,
32
30
  githubCopilotOAuthProvider,
33
31
  geminiCliOAuthProvider,
34
32
  antigravityOAuthProvider,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY;AACZ,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,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,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC;YACJ,KAAK,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACF,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * OAuth credential management for AI providers.\n *\n * This module handles login, token refresh, and credential storage\n * for OAuth-based providers:\n * - Anthropic (Claude Pro/Max)\n * - GitHub Copilot\n * - Google Cloud Code Assist (Gemini CLI)\n * - Antigravity (Gemini 3, Claude, GPT-OSS via Google Cloud)\n */\n\n// Anthropic\nexport { anthropicOAuthProvider, loginAnthropic, refreshAnthropicToken } from \"./anthropic.js\";\n// GitHub Copilot\nexport {\n\tgetGitHubCopilotBaseUrl,\n\tgithubCopilotOAuthProvider,\n\tloginGitHubCopilot,\n\tnormalizeDomain,\n\trefreshGitHubCopilotToken,\n} from \"./github-copilot.js\";\n// Google Antigravity\nexport { antigravityOAuthProvider, loginAntigravity, refreshAntigravityToken } from \"./google-antigravity.js\";\n// Google Gemini CLI\nexport { geminiCliOAuthProvider, loginGeminiCli, refreshGoogleCloudToken } from \"./google-gemini-cli.js\";\n// OpenAI Codex (ChatGPT OAuth)\nexport { loginOpenAICodex, openaiCodexOAuthProvider, refreshOpenAICodexToken } from \"./openai-codex.js\";\n\nexport * from \"./types.js\";\n\n// ============================================================================\n// Provider Registry\n// ============================================================================\n\nimport { anthropicOAuthProvider } from \"./anthropic.js\";\nimport { githubCopilotOAuthProvider } from \"./github-copilot.js\";\nimport { antigravityOAuthProvider } from \"./google-antigravity.js\";\nimport { geminiCliOAuthProvider } from \"./google-gemini-cli.js\";\nimport { openaiCodexOAuthProvider } from \"./openai-codex.js\";\nimport type { OAuthCredentials, OAuthProviderId, OAuthProviderInterface } from \"./types.js\";\n\nconst BUILT_IN_OAUTH_PROVIDERS: OAuthProviderInterface[] = [\n\tanthropicOAuthProvider,\n\tgithubCopilotOAuthProvider,\n\tgeminiCliOAuthProvider,\n\tantigravityOAuthProvider,\n\topenaiCodexOAuthProvider,\n];\n\nconst oauthProviderRegistry = new Map<string, OAuthProviderInterface>(\n\tBUILT_IN_OAUTH_PROVIDERS.map((provider) => [provider.id, provider]),\n);\n\n/**\n * Get an OAuth provider by ID\n */\nexport function getOAuthProvider(id: OAuthProviderId): OAuthProviderInterface | undefined {\n\treturn oauthProviderRegistry.get(id);\n}\n\n/**\n * Register a custom OAuth provider\n */\nexport function registerOAuthProvider(provider: OAuthProviderInterface): void {\n\toauthProviderRegistry.set(provider.id, provider);\n}\n\n/**\n * Unregister an OAuth provider.\n *\n * If the provider is built-in, restores the built-in implementation.\n * Custom providers are removed completely.\n */\nexport function unregisterOAuthProvider(id: string): void {\n\tconst builtInProvider = BUILT_IN_OAUTH_PROVIDERS.find((provider) => provider.id === id);\n\tif (builtInProvider) {\n\t\toauthProviderRegistry.set(id, builtInProvider);\n\t\treturn;\n\t}\n\toauthProviderRegistry.delete(id);\n}\n\n/**\n * Reset OAuth providers to built-ins.\n */\nexport function resetOAuthProviders(): void {\n\toauthProviderRegistry.clear();\n\tfor (const provider of BUILT_IN_OAUTH_PROVIDERS) {\n\t\toauthProviderRegistry.set(provider.id, provider);\n\t}\n}\n\n/**\n * Get all registered OAuth providers\n */\nexport function getOAuthProviders(): OAuthProviderInterface[] {\n\treturn Array.from(oauthProviderRegistry.values());\n}\n\n// ============================================================================\n// High-level API (uses provider registry)\n// ============================================================================\n\n/**\n * Get API key for a provider from OAuth credentials.\n * Automatically refreshes expired tokens.\n *\n * @returns API key string and updated credentials, or null if no credentials\n * @throws Error if refresh fails\n */\nexport async function getOAuthApiKey(\n\tproviderId: OAuthProviderId,\n\tcredentials: Record<string, OAuthCredentials>,\n): Promise<{ newCredentials: OAuthCredentials; apiKey: string } | null> {\n\tconst provider = getOAuthProvider(providerId);\n\tif (!provider) {\n\t\tthrow new Error(`Unknown OAuth provider: ${providerId}`);\n\t}\n\n\tlet creds = credentials[providerId];\n\tif (!creds) {\n\t\treturn null;\n\t}\n\n\t// Refresh if expired\n\tif (Date.now() >= creds.expires) {\n\t\ttry {\n\t\t\tcreds = await provider.refreshToken(creds);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to refresh OAuth token for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tconst apiKey = provider.getApiKey(creds);\n\treturn { newCredentials: creds, apiKey };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iBAAiB;AACjB,OAAO,EACN,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,yBAAyB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,qBAAqB;AACrB,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC9G,oBAAoB;AACpB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACzG,+BAA+B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAExG,cAAc,YAAY,CAAC;AAE3B,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAA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AO,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,+EAA+E;AAC/E,0CAA0C;AAC1C,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,UAA2B,EAC3B,WAA6C;IAE7C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAED,qBAAqB;IACrB,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC;YACJ,KAAK,GAAG,MAAM,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACtF,CAAC;IACF,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * OAuth credential management for AI providers.\n *\n * This module handles login, token refresh, and credential storage\n * for OAuth-based providers:\n * - GitHub Copilot\n * - Google Cloud Code Assist (Gemini CLI)\n * - Antigravity (Gemini 3, Claude, GPT-OSS via Google Cloud)\n *\n * Note: Anthropic OAuth was removed per TOS compliance (see docs/user-docs/claude-code-auth-compliance.md).\n * Use API keys or the local Claude Code CLI for Anthropic access.\n */\n\n// GitHub Copilot\nexport {\n\tgetGitHubCopilotBaseUrl,\n\tgithubCopilotOAuthProvider,\n\tloginGitHubCopilot,\n\tnormalizeDomain,\n\trefreshGitHubCopilotToken,\n} from \"./github-copilot.js\";\n// Google Antigravity\nexport { antigravityOAuthProvider, loginAntigravity, refreshAntigravityToken } from \"./google-antigravity.js\";\n// Google Gemini CLI\nexport { geminiCliOAuthProvider, loginGeminiCli, refreshGoogleCloudToken } from \"./google-gemini-cli.js\";\n// OpenAI Codex (ChatGPT OAuth)\nexport { loginOpenAICodex, openaiCodexOAuthProvider, refreshOpenAICodexToken } from \"./openai-codex.js\";\n\nexport * from \"./types.js\";\n\n// ============================================================================\n// Provider Registry\n// ============================================================================\n\nimport { githubCopilotOAuthProvider } from \"./github-copilot.js\";\nimport { antigravityOAuthProvider } from \"./google-antigravity.js\";\nimport { geminiCliOAuthProvider } from \"./google-gemini-cli.js\";\nimport { openaiCodexOAuthProvider } from \"./openai-codex.js\";\nimport type { OAuthCredentials, OAuthProviderId, OAuthProviderInterface } from \"./types.js\";\n\nconst BUILT_IN_OAUTH_PROVIDERS: OAuthProviderInterface[] = [\n\tgithubCopilotOAuthProvider,\n\tgeminiCliOAuthProvider,\n\tantigravityOAuthProvider,\n\topenaiCodexOAuthProvider,\n];\n\nconst oauthProviderRegistry = new Map<string, OAuthProviderInterface>(\n\tBUILT_IN_OAUTH_PROVIDERS.map((provider) => [provider.id, provider]),\n);\n\n/**\n * Get an OAuth provider by ID\n */\nexport function getOAuthProvider(id: OAuthProviderId): OAuthProviderInterface | undefined {\n\treturn oauthProviderRegistry.get(id);\n}\n\n/**\n * Register a custom OAuth provider\n */\nexport function registerOAuthProvider(provider: OAuthProviderInterface): void {\n\toauthProviderRegistry.set(provider.id, provider);\n}\n\n/**\n * Unregister an OAuth provider.\n *\n * If the provider is built-in, restores the built-in implementation.\n * Custom providers are removed completely.\n */\nexport function unregisterOAuthProvider(id: string): void {\n\tconst builtInProvider = BUILT_IN_OAUTH_PROVIDERS.find((provider) => provider.id === id);\n\tif (builtInProvider) {\n\t\toauthProviderRegistry.set(id, builtInProvider);\n\t\treturn;\n\t}\n\toauthProviderRegistry.delete(id);\n}\n\n/**\n * Reset OAuth providers to built-ins.\n */\nexport function resetOAuthProviders(): void {\n\toauthProviderRegistry.clear();\n\tfor (const provider of BUILT_IN_OAUTH_PROVIDERS) {\n\t\toauthProviderRegistry.set(provider.id, provider);\n\t}\n}\n\n/**\n * Get all registered OAuth providers\n */\nexport function getOAuthProviders(): OAuthProviderInterface[] {\n\treturn Array.from(oauthProviderRegistry.values());\n}\n\n// ============================================================================\n// High-level API (uses provider registry)\n// ============================================================================\n\n/**\n * Get API key for a provider from OAuth credentials.\n * Automatically refreshes expired tokens.\n *\n * @returns API key string and updated credentials, or null if no credentials\n * @throws Error if refresh fails\n */\nexport async function getOAuthApiKey(\n\tproviderId: OAuthProviderId,\n\tcredentials: Record<string, OAuthCredentials>,\n): Promise<{ newCredentials: OAuthCredentials; apiKey: string } | null> {\n\tconst provider = getOAuthProvider(providerId);\n\tif (!provider) {\n\t\tthrow new Error(`Unknown OAuth provider: ${providerId}`);\n\t}\n\n\tlet creds = credentials[providerId];\n\tif (!creds) {\n\t\treturn null;\n\t}\n\n\t// Refresh if expired\n\tif (Date.now() >= creds.expires) {\n\t\ttry {\n\t\t\tcreds = await provider.refreshToken(creds);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to refresh OAuth token for ${providerId}`, { cause: error });\n\t\t}\n\t}\n\n\tconst apiKey = provider.getApiKey(creds);\n\treturn { newCredentials: creds, apiKey };\n}\n"]}
@@ -34,9 +34,6 @@ async function getAnthropicClass(): Promise<typeof Anthropic> {
34
34
  return _AnthropicClass;
35
35
  }
36
36
 
37
- // Stealth mode: Mimic Claude Code's tool naming exactly
38
- const claudeCodeVersion = "2.1.62";
39
-
40
37
  function mergeHeaders(...headerSources: (Record<string, string> | undefined)[]): Record<string, string> {
41
38
  const merged: Record<string, string> = {};
42
39
  for (const headers of headerSources) {
@@ -47,10 +44,6 @@ function mergeHeaders(...headerSources: (Record<string, string> | undefined)[]):
47
44
  return merged;
48
45
  }
49
46
 
50
- function isOAuthToken(apiKey: string): boolean {
51
- return apiKey.includes("sk-ant-oat");
52
- }
53
-
54
47
  async function createClient(
55
48
  model: Model<"anthropic-messages">,
56
49
  apiKey: string,
@@ -97,30 +90,7 @@ async function createClient(
97
90
  betaFeatures.push("interleaved-thinking-2025-05-14");
98
91
  }
99
92
 
100
- // OAuth: Bearer auth, Claude Code identity headers
101
- if (isOAuthToken(apiKey)) {
102
- const client = new AnthropicClass({
103
- apiKey: null,
104
- authToken: apiKey,
105
- baseURL: model.baseUrl,
106
- dangerouslyAllowBrowser: true,
107
- defaultHeaders: mergeHeaders(
108
- {
109
- accept: "application/json",
110
- "anthropic-dangerous-direct-browser-access": "true",
111
- ...(betaFeatures.length > 0 ? { "anthropic-beta": `claude-code-20250219,oauth-2025-04-20,${betaFeatures.join(",")}` } : {}),
112
- "user-agent": `claude-cli/${claudeCodeVersion}`,
113
- "x-app": "cli",
114
- },
115
- model.headers,
116
- optionsHeaders,
117
- ),
118
- });
119
-
120
- return { client, isOAuthToken: true };
121
- }
122
-
123
- // API key auth
93
+ // API key auth (Anthropic OAuth removed per TOS compliance — use API keys or Claude CLI)
124
94
  // Alibaba Coding Plan uses Bearer token auth instead of x-api-key
125
95
  const isAlibabaProvider = model.provider === "alibaba-coding-plan";
126
96
  const client = new AnthropicClass({
@@ -3,14 +3,14 @@
3
3
  *
4
4
  * This module handles login, token refresh, and credential storage
5
5
  * for OAuth-based providers:
6
- * - Anthropic (Claude Pro/Max)
7
6
  * - GitHub Copilot
8
7
  * - Google Cloud Code Assist (Gemini CLI)
9
8
  * - Antigravity (Gemini 3, Claude, GPT-OSS via Google Cloud)
9
+ *
10
+ * Note: Anthropic OAuth was removed per TOS compliance (see docs/user-docs/claude-code-auth-compliance.md).
11
+ * Use API keys or the local Claude Code CLI for Anthropic access.
10
12
  */
11
13
 
12
- // Anthropic
13
- export { anthropicOAuthProvider, loginAnthropic, refreshAnthropicToken } from "./anthropic.js";
14
14
  // GitHub Copilot
15
15
  export {
16
16
  getGitHubCopilotBaseUrl,
@@ -32,7 +32,6 @@ export * from "./types.js";
32
32
  // Provider Registry
33
33
  // ============================================================================
34
34
 
35
- import { anthropicOAuthProvider } from "./anthropic.js";
36
35
  import { githubCopilotOAuthProvider } from "./github-copilot.js";
37
36
  import { antigravityOAuthProvider } from "./google-antigravity.js";
38
37
  import { geminiCliOAuthProvider } from "./google-gemini-cli.js";
@@ -40,7 +39,6 @@ import { openaiCodexOAuthProvider } from "./openai-codex.js";
40
39
  import type { OAuthCredentials, OAuthProviderId, OAuthProviderInterface } from "./types.js";
41
40
 
42
41
  const BUILT_IN_OAUTH_PROVIDERS: OAuthProviderInterface[] = [
43
- anthropicOAuthProvider,
44
42
  githubCopilotOAuthProvider,
45
43
  geminiCliOAuthProvider,
46
44
  antigravityOAuthProvider,
@@ -5,6 +5,7 @@ export interface LspConfig {
5
5
  idleTimeoutMs?: number;
6
6
  }
7
7
  export declare function hasRootMarkers(cwd: string, markers: string[]): boolean;
8
+ export declare function resolveLocalBinaryPath(command: string, cwd: string, isWindows: boolean): string | null;
8
9
  export declare function which(command: string): string | null;
9
10
  export declare function resolveCommand(command: string, cwd: string): string | null;
10
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/lsp/config.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAU/C,MAAM,WAAW,SAAS;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,+HAA+H;IAC/H,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AA8HD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAmBtE;AAgBD,wBAA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