@qqbrowser/qbot-dsh 0.0.15 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (737) hide show
  1. package/config/agent-presets/code/agent.cordis.yml +2 -2
  2. package/config/agent-presets/standard/agent.cordis.yml +2 -2
  3. package/cordis.patch.yml +50 -0
  4. package/lib/args-w1okyL78.js +9 -0
  5. package/lib/bin.js +2 -2
  6. package/lib/client.js +1 -0
  7. package/lib/content-review-CqDoh3wY.js +1 -0
  8. package/lib/content-review.js +1 -0
  9. package/lib/dump-config-CIL0Goqj.js +1 -0
  10. package/lib/gateway-port-CSFbDyoZ.js +1 -0
  11. package/lib/index.js +1 -0
  12. package/lib/llm-gateway-openai.js +17 -0
  13. package/lib/native-protocol-DdrIh89-.js +2 -0
  14. package/lib/{plugin-DNAeLZbb.js → plugin-viWCLnSr.js} +1 -1
  15. package/lib/profile-boot-CxJUSdnu.js +1 -0
  16. package/lib/profile-boot-DCgBQ4qO.js +8 -0
  17. package/lib/qb-auth-C2ofR1zn.js +4 -0
  18. package/lib/qb-auth.js +1 -0
  19. package/lib/web-search-dsh.js +1 -0
  20. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +7 -2
  21. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +3 -0
  22. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +3 -0
  23. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +1 -1
  24. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +7 -2
  25. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +3 -0
  26. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +3 -0
  27. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +1 -1
  28. package/node_modules/@deepseek-ai/cordis-plugin-hmr/package.json +1 -1
  29. package/node_modules/@deepseek-ai/dsh-agent/package.json +1 -1
  30. package/node_modules/@deepseek-ai/dsh-agent-default-model/package.json +1 -1
  31. package/node_modules/@deepseek-ai/dsh-agent-instructions/lib/index.js +3 -3
  32. package/node_modules/@deepseek-ai/dsh-agent-instructions/package.json +1 -1
  33. package/node_modules/@deepseek-ai/dsh-agent-loop/package.json +1 -1
  34. package/node_modules/@deepseek-ai/dsh-agent-presets/package.json +1 -1
  35. package/node_modules/@deepseek-ai/dsh-agent-tool-presentation/package.json +1 -1
  36. package/node_modules/@deepseek-ai/dsh-anonymous-user-id/package.json +1 -1
  37. package/node_modules/@deepseek-ai/dsh-api-gateway/package.json +1 -1
  38. package/node_modules/@deepseek-ai/dsh-api-remotes/package.json +1 -1
  39. package/node_modules/@deepseek-ai/dsh-app-boot/lib/index.js +12 -12
  40. package/node_modules/@deepseek-ai/dsh-app-boot/package.json +1 -1
  41. package/node_modules/@deepseek-ai/dsh-atomic-write/package.json +1 -1
  42. package/node_modules/@deepseek-ai/dsh-attachment/lib/index.js +1 -1
  43. package/node_modules/@deepseek-ai/dsh-attachment/package.json +1 -1
  44. package/node_modules/@deepseek-ai/dsh-attachment-local/lib/index.js +1 -1
  45. package/node_modules/@deepseek-ai/dsh-attachment-local/package.json +1 -1
  46. package/node_modules/@deepseek-ai/dsh-base/cordis.patch.yml +6 -37
  47. package/node_modules/@deepseek-ai/dsh-base/package.json +1 -1
  48. package/node_modules/@deepseek-ai/dsh-bash-local/package.json +1 -1
  49. package/node_modules/@deepseek-ai/dsh-bash-sandbox/package.json +1 -1
  50. package/node_modules/@deepseek-ai/dsh-brand/package.json +1 -1
  51. package/node_modules/@deepseek-ai/dsh-client-connection/lib/client.js +1 -1
  52. package/node_modules/@deepseek-ai/dsh-client-connection/package.json +1 -1
  53. package/node_modules/@deepseek-ai/dsh-client-hmr/package.json +1 -1
  54. package/node_modules/@deepseek-ai/dsh-client-locale/lib/client.js +1 -1
  55. package/node_modules/@deepseek-ai/dsh-client-locale/package.json +1 -1
  56. package/node_modules/@deepseek-ai/dsh-client-modules/package.json +1 -1
  57. package/node_modules/@deepseek-ai/dsh-client-runtime/lib/client.js +4 -4
  58. package/node_modules/@deepseek-ai/dsh-client-runtime/package.json +1 -1
  59. package/node_modules/@deepseek-ai/dsh-client-schema-form/package.json +1 -1
  60. package/node_modules/@deepseek-ai/dsh-client-ui-agent-preset/lib/client.js +1 -1
  61. package/node_modules/@deepseek-ai/dsh-client-ui-agent-preset/package.json +1 -1
  62. package/node_modules/@deepseek-ai/dsh-client-ui-attachment/package.json +1 -1
  63. package/node_modules/@deepseek-ai/dsh-client-ui-commands/lib/client.js +1 -1
  64. package/node_modules/@deepseek-ai/dsh-client-ui-commands/package.json +1 -1
  65. package/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/client.js +8 -8
  66. package/node_modules/@deepseek-ai/dsh-client-ui-conversation/package.json +1 -1
  67. package/node_modules/@deepseek-ai/dsh-client-ui-cordis/lib/client.js +3 -3
  68. package/node_modules/@deepseek-ai/dsh-client-ui-cordis/package.json +1 -1
  69. package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/client.js +1 -1
  70. package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/package.json +1 -1
  71. package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-browse/lib/client.js +1 -1
  72. package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-browse/package.json +1 -1
  73. package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-native/package.json +1 -1
  74. package/node_modules/@deepseek-ai/dsh-client-ui-goal/lib/client.js +1 -1
  75. package/node_modules/@deepseek-ai/dsh-client-ui-goal/package.json +1 -1
  76. package/node_modules/@deepseek-ai/dsh-client-ui-input-trigger/lib/client.js +1 -1
  77. package/node_modules/@deepseek-ai/dsh-client-ui-input-trigger/package.json +1 -1
  78. package/node_modules/@deepseek-ai/dsh-client-ui-jobs/lib/client.js +1 -1
  79. package/node_modules/@deepseek-ai/dsh-client-ui-jobs/package.json +1 -1
  80. package/node_modules/@deepseek-ai/dsh-client-ui-layout/lib/client.js +1 -1
  81. package/node_modules/@deepseek-ai/dsh-client-ui-layout/package.json +1 -1
  82. package/node_modules/@deepseek-ai/dsh-client-ui-message-feedback/lib/client.js +1 -1
  83. package/node_modules/@deepseek-ai/dsh-client-ui-message-feedback/package.json +1 -1
  84. package/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/client.js +1 -1
  85. package/node_modules/@deepseek-ai/dsh-client-ui-model-selection/package.json +1 -1
  86. package/node_modules/@deepseek-ai/dsh-client-ui-permission-presets/lib/client.js +1 -1
  87. package/node_modules/@deepseek-ai/dsh-client-ui-permission-presets/package.json +1 -1
  88. package/node_modules/@deepseek-ai/dsh-client-ui-plan/lib/client.js +1 -1
  89. package/node_modules/@deepseek-ai/dsh-client-ui-plan/package.json +1 -1
  90. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/lib/index.js +22 -22
  91. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +1 -1
  92. package/node_modules/@deepseek-ai/dsh-client-ui-settings/lib/client.js +1 -1
  93. package/node_modules/@deepseek-ai/dsh-client-ui-settings/package.json +1 -1
  94. package/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
  95. package/node_modules/@deepseek-ai/dsh-client-ui-settings-general/package.json +1 -1
  96. package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/client.js +1 -1
  97. package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/package.json +1 -1
  98. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/lib/client.js +1 -1
  99. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/package.json +1 -1
  100. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugins/lib/client.js +1 -1
  101. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugins/package.json +1 -1
  102. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  103. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/package.json +1 -1
  104. package/node_modules/@deepseek-ai/dsh-client-ui-skill/lib/client.js +1 -1
  105. package/node_modules/@deepseek-ai/dsh-client-ui-skill/package.json +1 -1
  106. package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +1 -1
  107. package/node_modules/@deepseek-ai/dsh-client-ui-subagent/lib/client.js +1 -1
  108. package/node_modules/@deepseek-ai/dsh-client-ui-subagent/package.json +1 -1
  109. package/node_modules/@deepseek-ai/dsh-client-ui-theme/lib/client.js +1 -1
  110. package/node_modules/@deepseek-ai/dsh-client-ui-theme/package.json +1 -1
  111. package/node_modules/@deepseek-ai/dsh-client-ui-tool/lib/client.js +1 -1
  112. package/node_modules/@deepseek-ai/dsh-client-ui-tool/package.json +1 -1
  113. package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/lib/client.js +2 -2
  114. package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/package.json +1 -1
  115. package/node_modules/@deepseek-ai/dsh-client-ui-user-questions/lib/client.js +1 -1
  116. package/node_modules/@deepseek-ai/dsh-client-ui-user-questions/package.json +1 -1
  117. package/node_modules/@deepseek-ai/dsh-client-ui-workflow-run/lib/client.js +1 -1
  118. package/node_modules/@deepseek-ai/dsh-client-ui-workflow-run/package.json +1 -1
  119. package/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/client.js +1 -1
  120. package/node_modules/@deepseek-ai/dsh-client-ui-workspace/package.json +1 -1
  121. package/node_modules/@deepseek-ai/dsh-client-web/package.json +1 -1
  122. package/node_modules/@deepseek-ai/dsh-client-web-react/package.json +1 -1
  123. package/node_modules/@deepseek-ai/dsh-cmdline/lib/index.js +1 -1
  124. package/node_modules/@deepseek-ai/dsh-cmdline/package.json +1 -1
  125. package/node_modules/@deepseek-ai/dsh-code-runtime/package.json +1 -1
  126. package/node_modules/@deepseek-ai/dsh-code-runtime-worker-thread/package.json +1 -1
  127. package/node_modules/@deepseek-ai/dsh-command-compact/package.json +1 -1
  128. package/node_modules/@deepseek-ai/dsh-command-feedback/package.json +1 -1
  129. package/node_modules/@deepseek-ai/dsh-command-goal/package.json +1 -1
  130. package/node_modules/@deepseek-ai/dsh-commands/lib/typert.host.js +5 -2
  131. package/node_modules/@deepseek-ai/dsh-commands/package.json +1 -1
  132. package/node_modules/@deepseek-ai/dsh-compaction/package.json +1 -1
  133. package/node_modules/@deepseek-ai/dsh-compaction-basic/package.json +1 -1
  134. package/node_modules/@deepseek-ai/dsh-compaction-tool-result-pruner/package.json +1 -1
  135. package/node_modules/@deepseek-ai/dsh-cordis-client-runner/lib/client.js +4 -4
  136. package/node_modules/@deepseek-ai/dsh-cordis-client-runner/package.json +1 -1
  137. package/node_modules/@deepseek-ai/dsh-cordis-host-runner/lib/typert.host.js +10 -4
  138. package/node_modules/@deepseek-ai/dsh-cordis-host-runner/package.json +1 -1
  139. package/node_modules/@deepseek-ai/dsh-credentials/package.json +1 -1
  140. package/node_modules/@deepseek-ai/dsh-credentials-local/lib/index.js +1 -1
  141. package/node_modules/@deepseek-ai/dsh-credentials-local/package.json +1 -1
  142. package/node_modules/@deepseek-ai/dsh-fs/package.json +1 -1
  143. package/node_modules/@deepseek-ai/dsh-fs-local/package.json +1 -1
  144. package/node_modules/@deepseek-ai/dsh-fs-observation-policy/package.json +1 -1
  145. package/node_modules/@deepseek-ai/dsh-fs-sandbox/package.json +1 -1
  146. package/node_modules/@deepseek-ai/dsh-goal/lib/typert.host.js +5 -2
  147. package/node_modules/@deepseek-ai/dsh-goal/package.json +1 -1
  148. package/node_modules/@deepseek-ai/dsh-goal-round-driver/package.json +1 -1
  149. package/node_modules/@deepseek-ai/dsh-headless/lib/index.js +4 -4
  150. package/node_modules/@deepseek-ai/dsh-headless/lib/startup.js +3 -3
  151. package/node_modules/@deepseek-ai/dsh-headless/package.json +1 -1
  152. package/node_modules/@deepseek-ai/dsh-home-paths/lib/index.js +1 -1
  153. package/node_modules/@deepseek-ai/dsh-home-paths/package.json +1 -1
  154. package/node_modules/@deepseek-ai/dsh-host-apiproxy/lib/index.js +7 -7
  155. package/node_modules/@deepseek-ai/dsh-host-apiproxy/lib/types/api/rpc.schema.js +1 -1
  156. package/node_modules/@deepseek-ai/dsh-host-apiproxy/lib/types/api-proxy.js +1 -1
  157. package/node_modules/@deepseek-ai/dsh-host-apiproxy/package.json +1 -1
  158. package/node_modules/@deepseek-ai/dsh-host-directory-picker/package.json +1 -1
  159. package/node_modules/@deepseek-ai/dsh-host-directory-picker-auto/package.json +1 -1
  160. package/node_modules/@deepseek-ai/dsh-host-directory-picker-browse/package.json +1 -1
  161. package/node_modules/@deepseek-ai/dsh-host-directory-picker-native/package.json +1 -1
  162. package/node_modules/@deepseek-ai/dsh-host-frontend-static/package.json +1 -1
  163. package/node_modules/@deepseek-ai/dsh-host-plugin-inventory/package.json +1 -1
  164. package/node_modules/@deepseek-ai/dsh-host-webserver/lib/index.js +1 -1
  165. package/node_modules/@deepseek-ai/dsh-host-webserver/package.json +1 -1
  166. package/node_modules/@deepseek-ai/dsh-invariants/package.json +1 -1
  167. package/node_modules/@deepseek-ai/dsh-jobs/package.json +1 -1
  168. package/node_modules/@deepseek-ai/dsh-jobs-local/package.json +1 -1
  169. package/node_modules/@deepseek-ai/dsh-launch-environment/package.json +1 -1
  170. package/node_modules/@deepseek-ai/dsh-llm/lib/index.js +1 -1
  171. package/node_modules/@deepseek-ai/dsh-llm/lib/types/assembler.js +1 -1
  172. package/node_modules/@deepseek-ai/dsh-llm/package.json +1 -1
  173. package/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +1 -1
  174. package/node_modules/@deepseek-ai/dsh-llm-deepseek/package.json +1 -1
  175. package/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +1 -1
  176. package/node_modules/@deepseek-ai/dsh-llm-pi-ai/package.json +1 -1
  177. package/node_modules/@deepseek-ai/dsh-llm-retry/package.json +1 -1
  178. package/node_modules/@deepseek-ai/dsh-mcp-client/lib/index.js +3 -2
  179. package/node_modules/@deepseek-ai/dsh-mcp-client/package.json +1 -1
  180. package/node_modules/@deepseek-ai/dsh-message-feedback/package.json +1 -1
  181. package/node_modules/@deepseek-ai/dsh-native-command/package.json +1 -1
  182. package/node_modules/@deepseek-ai/dsh-output-retention/package.json +1 -1
  183. package/node_modules/@deepseek-ai/dsh-permission-presets/package.json +1 -1
  184. package/node_modules/@deepseek-ai/dsh-persona/package.json +1 -1
  185. package/node_modules/@deepseek-ai/dsh-plan-mode/package.json +1 -1
  186. package/node_modules/@deepseek-ai/dsh-pwsh-local/package.json +1 -1
  187. package/node_modules/@deepseek-ai/dsh-pwsh-sandbox/package.json +1 -1
  188. package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/package.json +1 -1
  189. package/node_modules/@deepseek-ai/dsh-sandbox/package.json +1 -1
  190. package/node_modules/@deepseek-ai/dsh-sandbox-local/package.json +1 -1
  191. package/node_modules/@deepseek-ai/dsh-sandbox-policy/package.json +1 -1
  192. package/node_modules/@deepseek-ai/dsh-sandbox-windows-acl/lib/index.js +1 -1
  193. package/node_modules/@deepseek-ai/dsh-sandbox-windows-acl/lib/runner.js +1 -1
  194. package/node_modules/@deepseek-ai/dsh-sandbox-windows-acl/package.json +1 -1
  195. package/node_modules/@deepseek-ai/dsh-schedule/package.json +1 -1
  196. package/node_modules/@deepseek-ai/dsh-scope/package.json +1 -1
  197. package/node_modules/@deepseek-ai/dsh-session/package.json +1 -1
  198. package/node_modules/@deepseek-ai/dsh-session-checkpoint-policy/package.json +1 -1
  199. package/node_modules/@deepseek-ai/dsh-session-log-export/package.json +1 -1
  200. package/node_modules/@deepseek-ai/dsh-session-persistence/package.json +1 -1
  201. package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/package.json +1 -1
  202. package/node_modules/@deepseek-ai/dsh-session-projection/package.json +1 -1
  203. package/node_modules/@deepseek-ai/dsh-session-projection-cache/package.json +1 -1
  204. package/node_modules/@deepseek-ai/dsh-session-query/lib/index.js +2 -2
  205. package/node_modules/@deepseek-ai/dsh-session-query/package.json +1 -1
  206. package/node_modules/@deepseek-ai/dsh-session-query-sqlite/package.json +1 -1
  207. package/node_modules/@deepseek-ai/dsh-session-reference/package.json +1 -1
  208. package/node_modules/@deepseek-ai/dsh-session-stats/package.json +1 -1
  209. package/node_modules/@deepseek-ai/dsh-session-telemetry/package.json +1 -1
  210. package/node_modules/@deepseek-ai/dsh-session-telemetry-otel/package.json +1 -1
  211. package/node_modules/@deepseek-ai/dsh-session-title/package.json +1 -1
  212. package/node_modules/@deepseek-ai/dsh-session-title-first-prompt-llm/package.json +1 -1
  213. package/node_modules/@deepseek-ai/dsh-session-title-llm/package.json +1 -1
  214. package/node_modules/@deepseek-ai/dsh-settings/package.json +1 -1
  215. package/node_modules/@deepseek-ai/dsh-settings-file/package.json +1 -1
  216. package/node_modules/@deepseek-ai/dsh-shell/package.json +1 -1
  217. package/node_modules/@deepseek-ai/dsh-shell-env/lib/index.js +1 -1
  218. package/node_modules/@deepseek-ai/dsh-shell-env/package.json +1 -1
  219. package/node_modules/@deepseek-ai/dsh-skill/package.json +1 -1
  220. package/node_modules/@deepseek-ai/dsh-skill-badge/package.json +1 -1
  221. package/node_modules/@deepseek-ai/dsh-skill-filesystem/package.json +1 -1
  222. package/node_modules/@deepseek-ai/dsh-spill/package.json +1 -1
  223. package/node_modules/@deepseek-ai/dsh-spill-local/package.json +1 -1
  224. package/node_modules/@deepseek-ai/dsh-spill-policy/package.json +1 -1
  225. package/node_modules/@deepseek-ai/dsh-storage/package.json +1 -1
  226. package/node_modules/@deepseek-ai/dsh-storage-domain/package.json +1 -1
  227. package/node_modules/@deepseek-ai/dsh-storage-json/package.json +1 -1
  228. package/node_modules/@deepseek-ai/dsh-subagent/package.json +1 -1
  229. package/node_modules/@deepseek-ai/dsh-subagent-fork-in-process/package.json +1 -1
  230. package/node_modules/@deepseek-ai/dsh-subagent-in-process-driver/package.json +1 -1
  231. package/node_modules/@deepseek-ai/dsh-subagent-spawn-in-process/package.json +1 -1
  232. package/node_modules/@deepseek-ai/dsh-subprocess/lib/index.js +1 -1
  233. package/node_modules/@deepseek-ai/dsh-subprocess/package.json +1 -1
  234. package/node_modules/@deepseek-ai/dsh-subprocess-local/package.json +1 -1
  235. package/node_modules/@deepseek-ai/dsh-system-prompt/package.json +1 -1
  236. package/node_modules/@deepseek-ai/dsh-terminal/package.json +1 -1
  237. package/node_modules/@deepseek-ai/dsh-terminal-bash/lib/index.js +1 -1
  238. package/node_modules/@deepseek-ai/dsh-terminal-bash/package.json +1 -1
  239. package/node_modules/@deepseek-ai/dsh-time-context/package.json +1 -1
  240. package/node_modules/@deepseek-ai/dsh-timeout/package.json +1 -1
  241. package/node_modules/@deepseek-ai/dsh-tmux-context/package.json +1 -1
  242. package/node_modules/@deepseek-ai/dsh-token-meter/package.json +1 -1
  243. package/node_modules/@deepseek-ai/dsh-tool-ask-user/package.json +1 -1
  244. package/node_modules/@deepseek-ai/dsh-tool-bash/package.json +1 -1
  245. package/node_modules/@deepseek-ai/dsh-tool-bash-persistent/lib/index.js +7 -10
  246. package/node_modules/@deepseek-ai/dsh-tool-bash-persistent/package.json +1 -1
  247. package/node_modules/@deepseek-ai/dsh-tool-call-timeout-policy/package.json +1 -1
  248. package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/index.js +9 -30
  249. package/node_modules/@deepseek-ai/dsh-tool-cordis/package.json +1 -1
  250. package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +8 -8
  251. package/node_modules/@deepseek-ai/dsh-tool-fs/package.json +1 -1
  252. package/node_modules/@deepseek-ai/dsh-tool-fs-search/package.json +1 -1
  253. package/node_modules/@deepseek-ai/dsh-tool-goal/package.json +1 -1
  254. package/node_modules/@deepseek-ai/dsh-tool-jobs/package.json +1 -1
  255. package/node_modules/@deepseek-ai/dsh-tool-pwsh/package.json +1 -1
  256. package/node_modules/@deepseek-ai/dsh-tool-ralph/package.json +1 -1
  257. package/node_modules/@deepseek-ai/dsh-tool-skill/package.json +1 -1
  258. package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/package.json +1 -1
  259. package/node_modules/@deepseek-ai/dsh-tool-subagent/lib/index.js +2 -2
  260. package/node_modules/@deepseek-ai/dsh-tool-subagent/package.json +1 -1
  261. package/node_modules/@deepseek-ai/dsh-tool-subagent-control/package.json +1 -1
  262. package/node_modules/@deepseek-ai/dsh-tool-subagent-report/package.json +1 -1
  263. package/node_modules/@deepseek-ai/dsh-tool-todo/package.json +1 -1
  264. package/node_modules/@deepseek-ai/dsh-tool-web/package.json +1 -1
  265. package/node_modules/@deepseek-ai/dsh-tool-workflow/package.json +1 -1
  266. package/node_modules/@deepseek-ai/dsh-tools/lib/index.js +15 -15
  267. package/node_modules/@deepseek-ai/dsh-tools/lib/types/code-mode.js +8 -8
  268. package/node_modules/@deepseek-ai/dsh-tools/lib/types/py-types.js +3 -3
  269. package/node_modules/@deepseek-ai/dsh-tools/lib/types/ts-types.js +4 -4
  270. package/node_modules/@deepseek-ai/dsh-tools/package.json +1 -1
  271. package/node_modules/@deepseek-ai/dsh-typert-loader/package.json +1 -1
  272. package/node_modules/@deepseek-ai/dsh-typert-protocol/package.json +1 -1
  273. package/node_modules/@deepseek-ai/dsh-typert-registry/package.json +1 -1
  274. package/node_modules/@deepseek-ai/dsh-user-approval/package.json +1 -1
  275. package/node_modules/@deepseek-ai/dsh-user-questions/package.json +1 -1
  276. package/node_modules/@deepseek-ai/dsh-web/lib/index.js +1 -1
  277. package/node_modules/@deepseek-ai/dsh-web/package.json +1 -1
  278. package/node_modules/@deepseek-ai/dsh-web-app/cordis.patch.yml +0 -1
  279. package/node_modules/@deepseek-ai/dsh-web-app/lib/index.js +1 -1
  280. package/node_modules/@deepseek-ai/dsh-web-app/lib/startup.js +4 -5
  281. package/node_modules/@deepseek-ai/dsh-web-app/package.json +1 -1
  282. package/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/{index-BQQQ5Qt-.js → index-fPGOmJjK.js} +25 -25
  283. package/node_modules/@deepseek-ai/dsh-web-frontend/dist/index.html +1 -1
  284. package/node_modules/@deepseek-ai/dsh-web-frontend/package.json +1 -1
  285. package/node_modules/@deepseek-ai/dsh-web-search-deepseek/package.json +1 -1
  286. package/node_modules/@deepseek-ai/dsh-workflow/package.json +1 -1
  287. package/node_modules/@deepseek-ai/dsh-workflow-worker-thread/lib/worker.cjs +9 -8
  288. package/node_modules/@deepseek-ai/dsh-workflow-worker-thread/package.json +1 -1
  289. package/node_modules/@deepseek-ai/dsh-workspace/package.json +1 -1
  290. package/node_modules/@deepseek-ai/node-addon-landlock-run/package.json +1 -1
  291. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
  292. package/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js +1 -1
  293. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +1 -1
  294. package/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.js +1 -1
  295. package/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.js +1 -1
  296. package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +3 -3
  297. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +4 -4
  298. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +5 -5
  299. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +6 -6
  300. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +1 -1
  301. package/node_modules/@earendil-works/pi-ai/dist/api/openrouter-images.js +1 -1
  302. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +2 -2
  303. package/node_modules/@earendil-works/pi-ai/dist/api/simple-options.js +1 -1
  304. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openrouter.js +1 -1
  305. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +1 -1
  306. package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  307. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  308. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  309. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  310. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  311. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  312. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  313. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  314. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  315. package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  316. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  317. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  318. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
  319. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
  320. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +5 -5
  321. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  322. package/node_modules/@koromix/koffi-darwin-arm64/darwin_arm64/koffi.node +0 -0
  323. package/node_modules/@koromix/koffi-darwin-arm64/package.json +1 -1
  324. package/node_modules/@koromix/koffi-darwin-x64/darwin_x64/koffi.node +0 -0
  325. package/node_modules/@koromix/koffi-darwin-x64/package.json +1 -1
  326. package/node_modules/@koromix/koffi-win32-x64/package.json +1 -1
  327. package/node_modules/@koromix/koffi-win32-x64/win32_x64/koffi.node +0 -0
  328. package/node_modules/@smithy/core/dist-cjs/index.js +3 -1
  329. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +126 -39
  330. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +14 -3
  331. package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.browser.js +3 -1
  332. package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +3 -1
  333. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +10 -1
  334. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +10 -1
  335. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +16 -2
  336. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +4 -1
  337. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +4 -1
  338. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +4 -1
  339. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +4 -1
  340. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +4 -1
  341. package/node_modules/@smithy/core/dist-cjs/submodules/transport/index.js +7 -0
  342. package/node_modules/@smithy/core/dist-es/legacy-root-exports/util-identity-and-auth/DefaultIdentityProviderConfig.js +3 -0
  343. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +29 -13
  344. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +12 -4
  345. package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v1/CborShapeDeserializer.js +9 -0
  346. package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v1/CborShapeSerializer.js +7 -0
  347. package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v2/CborShapeDeserializer2.js +44 -15
  348. package/node_modules/@smithy/core/dist-es/submodules/cbor/codec-v2/CborShapeSerializer2.js +22 -4
  349. package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +5 -0
  350. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/extensions/checksum.js +3 -0
  351. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +4 -1
  352. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/object-mapping.js +6 -1
  353. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/serde-json.js +4 -1
  354. package/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/resolveEndpoint.js +3 -0
  355. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +7 -0
  356. package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +4 -1
  357. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +9 -0
  358. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +5 -0
  359. package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +3 -0
  360. package/node_modules/@smithy/core/dist-es/submodules/retry/middleware-retry/parseRetryAfterHeader.js +4 -1
  361. package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +1 -0
  362. package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +1 -0
  363. package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +1 -0
  364. package/node_modules/@smithy/core/dist-es/submodules/serde/parse-utils.js +3 -0
  365. package/node_modules/@smithy/core/dist-es/submodules/transport/hasOwn.js +3 -0
  366. package/node_modules/@smithy/core/dist-es/submodules/transport/index.js +1 -0
  367. package/node_modules/@smithy/core/dist-es/submodules/transport/toEndpointV1.js +3 -0
  368. package/node_modules/@smithy/core/package.json +1 -1
  369. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +19 -7
  370. package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +4 -1
  371. package/node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js +4 -1
  372. package/node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js +4 -1
  373. package/node_modules/@smithy/signature-v4/dist-es/headerUtil.js +10 -3
  374. package/node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js +4 -1
  375. package/node_modules/@smithy/signature-v4/dist-es/prepareRequest.js +4 -1
  376. package/node_modules/@smithy/signature-v4/package.json +1 -1
  377. package/node_modules/@tanstack/react-virtual/package.json +1 -1
  378. package/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs +7 -1
  379. package/node_modules/@tanstack/virtual-core/dist/cjs/utils.cjs +14 -4
  380. package/node_modules/@tanstack/virtual-core/dist/esm/index.js +1 -1
  381. package/node_modules/@tanstack/virtual-core/dist/esm/utils.js +2 -2
  382. package/node_modules/@tanstack/virtual-core/package.json +1 -1
  383. package/node_modules/hono/dist/cjs/client/utils.js +1 -1
  384. package/node_modules/hono/dist/cjs/context.js +4 -0
  385. package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
  386. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  387. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
  388. package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -2
  389. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  390. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  391. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  392. package/node_modules/hono/dist/cjs/router/trie-router/node.js +43 -67
  393. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  394. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  395. package/node_modules/hono/dist/client/utils.js +1 -1
  396. package/node_modules/hono/dist/middleware/cors/index.js +1 -1
  397. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  398. package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
  399. package/node_modules/hono/dist/middleware/etag/index.js +1 -1
  400. package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -1
  401. package/node_modules/hono/dist/router/linear-router/router.js +1 -1
  402. package/node_modules/hono/dist/router/pattern-router/router.js +1 -1
  403. package/node_modules/hono/dist/router/trie-router/node.js +1 -1
  404. package/node_modules/hono/dist/router/trie-router/router.js +1 -1
  405. package/node_modules/hono/dist/utils/ipaddr.js +1 -1
  406. package/node_modules/hono/package.json +1 -1
  407. package/node_modules/koffi/package.json +1 -1
  408. package/node_modules/koffi/src/koffi/index.cjs +1 -1
  409. package/node_modules/koffi/src/koffi/index.js +1 -1
  410. package/node_modules/koffi/src/koffi/indirect.cjs +1 -1
  411. package/node_modules/koffi/src/koffi/indirect.js +1 -1
  412. package/node_modules/negotiator/lib/accept.js +54 -0
  413. package/node_modules/negotiator/lib/charset.js +10 -34
  414. package/node_modules/negotiator/lib/encoding.js +9 -30
  415. package/node_modules/negotiator/lib/language.js +15 -36
  416. package/node_modules/negotiator/lib/mediaType.js +16 -134
  417. package/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  418. package/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  419. package/node_modules/negotiator/node_modules/content-type/package.json +1 -0
  420. package/node_modules/negotiator/package.json +1 -1
  421. package/node_modules/node-pty/lib/conpty_console_list_agent.js +11 -2
  422. package/node_modules/node-pty/lib/index.js +6 -6
  423. package/node_modules/node-pty/lib/shared/conout.js +2 -3
  424. package/node_modules/node-pty/lib/terminal.js +2 -2
  425. package/node_modules/node-pty/lib/unixTerminal.js +11 -6
  426. package/node_modules/node-pty/lib/utils.js +6 -7
  427. package/node_modules/node-pty/lib/windowsConoutConnection.js +24 -18
  428. package/node_modules/node-pty/lib/windowsPtyAgent.js +125 -101
  429. package/node_modules/node-pty/lib/windowsTerminal.js +14 -4
  430. package/node_modules/node-pty/lib/worker/conoutSocketWorker.js +3 -3
  431. package/node_modules/node-pty/package.json +1 -1
  432. package/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  433. package/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  434. package/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  435. package/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  436. package/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  437. package/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  438. package/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  439. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  440. package/node_modules/node-pty/scripts/post-install.js +1 -5
  441. package/node_modules/node-pty/third_party/conpty/1.25.260303002/win10-arm64/OpenConsole.exe +0 -0
  442. package/node_modules/node-pty/third_party/conpty/{1.23.251008001 → 1.25.260303002}/win10-arm64/conpty.dll +0 -0
  443. package/node_modules/node-pty/third_party/conpty/1.25.260303002/win10-x64/OpenConsole.exe +0 -0
  444. package/node_modules/node-pty/third_party/conpty/1.25.260303002/win10-x64/conpty.dll +0 -0
  445. package/node_modules/typebox/build/compile/validator.mjs +1 -1
  446. package/node_modules/typebox/build/format/_idna.mjs +1 -1
  447. package/node_modules/typebox/build/format/_puny.mjs +1 -1
  448. package/node_modules/typebox/build/format/uuid.mjs +1 -1
  449. package/node_modules/typebox/build/guard/emit.mjs +1 -1
  450. package/node_modules/typebox/build/guard/guard.mjs +1 -1
  451. package/node_modules/typebox/build/guard/string.mjs +1 -1
  452. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
  453. package/node_modules/typebox/build/schema/engine/_guard.mjs +1 -0
  454. package/node_modules/typebox/build/schema/engine/boolean.mjs +1 -1
  455. package/node_modules/typebox/build/schema/engine/index.mjs +1 -1
  456. package/node_modules/typebox/build/schema/engine/schema.mjs +1 -1
  457. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  458. package/node_modules/typebox/build/schema/types/_guard.mjs +1 -0
  459. package/node_modules/typebox/build/schema/types/index.mjs +1 -1
  460. package/node_modules/typebox/build/schema/types/schema.mjs +1 -1
  461. package/node_modules/typebox/build/system/locale/ar_001.mjs +1 -1
  462. package/node_modules/typebox/build/system/locale/bn_BD.mjs +1 -1
  463. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +1 -1
  464. package/node_modules/typebox/build/system/locale/de_DE.mjs +1 -1
  465. package/node_modules/typebox/build/system/locale/el_GR.mjs +1 -1
  466. package/node_modules/typebox/build/system/locale/en_US.mjs +1 -1
  467. package/node_modules/typebox/build/system/locale/es_419.mjs +1 -1
  468. package/node_modules/typebox/build/system/locale/es_AR.mjs +1 -1
  469. package/node_modules/typebox/build/system/locale/es_ES.mjs +1 -1
  470. package/node_modules/typebox/build/system/locale/es_MX.mjs +1 -1
  471. package/node_modules/typebox/build/system/locale/fa_IR.mjs +1 -1
  472. package/node_modules/typebox/build/system/locale/fil_PH.mjs +1 -1
  473. package/node_modules/typebox/build/system/locale/fr_CA.mjs +1 -1
  474. package/node_modules/typebox/build/system/locale/fr_FR.mjs +1 -1
  475. package/node_modules/typebox/build/system/locale/ha_NG.mjs +1 -1
  476. package/node_modules/typebox/build/system/locale/hi_IN.mjs +1 -1
  477. package/node_modules/typebox/build/system/locale/hu_HU.mjs +1 -1
  478. package/node_modules/typebox/build/system/locale/id_ID.mjs +1 -1
  479. package/node_modules/typebox/build/system/locale/it_IT.mjs +1 -1
  480. package/node_modules/typebox/build/system/locale/ja_JP.mjs +1 -1
  481. package/node_modules/typebox/build/system/locale/ko_KR.mjs +1 -1
  482. package/node_modules/typebox/build/system/locale/ms_MY.mjs +1 -1
  483. package/node_modules/typebox/build/system/locale/nl_NL.mjs +1 -1
  484. package/node_modules/typebox/build/system/locale/pl_PL.mjs +1 -1
  485. package/node_modules/typebox/build/system/locale/pt_BR.mjs +1 -1
  486. package/node_modules/typebox/build/system/locale/pt_PT.mjs +1 -1
  487. package/node_modules/typebox/build/system/locale/ro_RO.mjs +1 -1
  488. package/node_modules/typebox/build/system/locale/ru_RU.mjs +1 -1
  489. package/node_modules/typebox/build/system/locale/sv_SE.mjs +1 -1
  490. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +1 -1
  491. package/node_modules/typebox/build/system/locale/th_TH.mjs +1 -1
  492. package/node_modules/typebox/build/system/locale/tr_TR.mjs +1 -1
  493. package/node_modules/typebox/build/system/locale/uk_UA.mjs +1 -1
  494. package/node_modules/typebox/build/system/locale/ur_PK.mjs +1 -1
  495. package/node_modules/typebox/build/system/locale/vi_VN.mjs +1 -1
  496. package/node_modules/typebox/build/system/locale/yo_NG.mjs +1 -1
  497. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +1 -1
  498. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +1 -1
  499. package/node_modules/typebox/build/system/memory/clone.mjs +1 -1
  500. package/node_modules/typebox/build/system/settings/settings.mjs +1 -1
  501. package/node_modules/typebox/build/type/action/_optional.mjs +1 -0
  502. package/node_modules/typebox/build/type/action/_readonly.mjs +1 -0
  503. package/node_modules/typebox/build/type/action/awaited.mjs +1 -0
  504. package/node_modules/typebox/build/type/action/conditional.mjs +1 -1
  505. package/node_modules/typebox/build/type/action/index.mjs +1 -1
  506. package/node_modules/typebox/build/type/action/mapped.mjs +1 -1
  507. package/node_modules/typebox/build/type/action/module.mjs +1 -1
  508. package/node_modules/typebox/build/type/action/options.mjs +1 -0
  509. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +1 -0
  510. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  511. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +1 -1
  512. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +1 -1
  513. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +1 -1
  514. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +1 -1
  515. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +1 -1
  516. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +1 -1
  517. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +1 -1
  518. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +1 -1
  519. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +1 -0
  520. package/node_modules/typebox/build/type/engine/enum/index.mjs +1 -1
  521. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +1 -1
  522. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +1 -1
  523. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +1 -1
  524. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +1 -1
  525. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +1 -1
  526. package/node_modules/typebox/build/type/engine/extract/operation.mjs +1 -1
  527. package/node_modules/typebox/build/type/engine/index.mjs +1 -1
  528. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +1 -1
  529. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +1 -1
  530. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +1 -1
  531. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +1 -1
  532. package/node_modules/typebox/build/type/engine/instantiate.mjs +1 -1
  533. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +1 -1
  534. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +1 -1
  535. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +1 -1
  536. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +1 -1
  537. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +1 -1
  538. package/node_modules/typebox/build/type/engine/object/from_type.mjs +1 -1
  539. package/node_modules/typebox/build/type/engine/object/from_union.mjs +1 -1
  540. package/node_modules/typebox/build/type/engine/options/index.mjs +1 -0
  541. package/node_modules/typebox/build/type/engine/options/instantiate.mjs +1 -0
  542. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +1 -1
  543. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +1 -1
  544. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +1 -1
  545. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +1 -1
  546. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +1 -1
  547. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +1 -1
  548. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +1 -1
  549. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +1 -1
  550. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +1 -1
  551. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +1 -1
  552. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +1 -1
  553. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +1 -1
  554. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +1 -1
  555. package/node_modules/typebox/build/type/engine/required/from_object.mjs +1 -1
  556. package/node_modules/typebox/build/type/engine/required/from_type.mjs +1 -1
  557. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +1 -1
  558. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +1 -1
  559. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  560. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +1 -1
  561. package/node_modules/typebox/build/type/extends/async_iterator.mjs +1 -0
  562. package/node_modules/typebox/build/type/extends/enum.mjs +1 -1
  563. package/node_modules/typebox/build/type/extends/extends_left.mjs +1 -1
  564. package/node_modules/typebox/build/type/extends/extends_right.mjs +1 -1
  565. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  566. package/node_modules/typebox/build/type/extends/iterator.mjs +1 -0
  567. package/node_modules/typebox/build/type/extends/object.mjs +1 -1
  568. package/node_modules/typebox/build/type/extends/parameters.mjs +1 -1
  569. package/node_modules/typebox/build/type/extends/promise.mjs +1 -0
  570. package/node_modules/typebox/build/type/extends/template_literal.mjs +1 -1
  571. package/node_modules/typebox/build/type/extends/tuple.mjs +1 -1
  572. package/node_modules/typebox/build/type/extends/union.mjs +1 -1
  573. package/node_modules/typebox/build/type/script/mapping.mjs +1 -1
  574. package/node_modules/typebox/build/type/script/parser.mjs +6 -6
  575. package/node_modules/typebox/build/type/script/script.mjs +1 -1
  576. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  577. package/node_modules/typebox/build/type/script/token/until.mjs +1 -1
  578. package/node_modules/typebox/build/type/types/_immutable.mjs +1 -1
  579. package/node_modules/typebox/build/type/types/_optional.mjs +1 -1
  580. package/node_modules/typebox/build/type/types/_readonly.mjs +1 -1
  581. package/node_modules/typebox/build/type/types/_refine.mjs +1 -1
  582. package/node_modules/typebox/build/type/types/async_iterator.mjs +1 -0
  583. package/node_modules/typebox/build/type/types/base.mjs +1 -0
  584. package/node_modules/typebox/build/type/types/call.mjs +1 -1
  585. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  586. package/node_modules/typebox/build/type/types/enum.mjs +1 -1
  587. package/node_modules/typebox/build/type/types/index.mjs +1 -1
  588. package/node_modules/typebox/build/type/types/iterator.mjs +1 -0
  589. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  590. package/node_modules/typebox/build/type/types/promise.mjs +1 -0
  591. package/node_modules/typebox/build/type/types/record.mjs +1 -1
  592. package/node_modules/typebox/build/typebox.mjs +1 -1
  593. package/node_modules/typebox/build/value/clean/clean.mjs +1 -1
  594. package/node_modules/typebox/build/value/clean/from_base.mjs +1 -0
  595. package/node_modules/typebox/build/value/clean/from_intersect.mjs +1 -1
  596. package/node_modules/typebox/build/value/clean/from_type.mjs +1 -1
  597. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -1
  598. package/node_modules/typebox/build/value/clone/clone.mjs +1 -1
  599. package/node_modules/typebox/build/value/codec/decode.mjs +1 -1
  600. package/node_modules/typebox/build/value/codec/encode.mjs +1 -1
  601. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -1
  602. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -1
  603. package/node_modules/typebox/build/value/codec/from_record.mjs +1 -1
  604. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -1
  605. package/node_modules/typebox/build/value/codec/from_union.mjs +1 -1
  606. package/node_modules/typebox/build/value/convert/from_base.mjs +1 -0
  607. package/node_modules/typebox/build/value/convert/from_enum.mjs +1 -1
  608. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +1 -1
  609. package/node_modules/typebox/build/value/convert/from_type.mjs +1 -1
  610. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +1 -0
  611. package/node_modules/typebox/build/value/create/from_base.mjs +1 -0
  612. package/node_modules/typebox/build/value/create/from_enum.mjs +1 -1
  613. package/node_modules/typebox/build/value/create/from_iterator.mjs +1 -0
  614. package/node_modules/typebox/build/value/create/from_promise.mjs +1 -0
  615. package/node_modules/typebox/build/value/create/from_type.mjs +1 -1
  616. package/node_modules/typebox/build/value/default/from_base.mjs +1 -0
  617. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  618. package/node_modules/typebox/build/value/default/from_type.mjs +1 -1
  619. package/node_modules/typebox/build/value/index.mjs +1 -1
  620. package/node_modules/typebox/build/value/mutate/error.mjs +1 -0
  621. package/node_modules/typebox/build/value/mutate/from_array.mjs +1 -0
  622. package/node_modules/typebox/build/value/mutate/from_object.mjs +1 -0
  623. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +1 -0
  624. package/node_modules/typebox/build/value/mutate/from_value.mjs +1 -0
  625. package/node_modules/typebox/build/value/mutate/index.mjs +1 -0
  626. package/node_modules/typebox/build/value/mutate/mutate.mjs +1 -0
  627. package/node_modules/typebox/build/value/repair/from_base.mjs +1 -0
  628. package/node_modules/typebox/build/value/repair/from_enum.mjs +1 -1
  629. package/node_modules/typebox/build/value/repair/from_type.mjs +1 -1
  630. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +1 -1
  631. package/node_modules/typebox/build/value/value.mjs +1 -1
  632. package/node_modules/typebox/package.json +1 -1
  633. package/package.json +1 -1
  634. package/lib/args-DcHS9iff.js +0 -9
  635. package/lib/dump-config-xQTUTTDD.js +0 -1
  636. package/lib/profile-boot-BkordgJK.js +0 -1
  637. package/lib/profile-boot-DDo03lXi.js +0 -8
  638. package/node_modules/@deepseek-ai/dsh-content-review/LICENSE +0 -21
  639. package/node_modules/@deepseek-ai/dsh-content-review/lib/index.js +0 -1
  640. package/node_modules/@deepseek-ai/dsh-content-review/lib/invariant.js +0 -1
  641. package/node_modules/@deepseek-ai/dsh-content-review/package.json +0 -1
  642. package/node_modules/@deepseek-ai/dsh-home-quarantine-macos/LICENSE +0 -21
  643. package/node_modules/@deepseek-ai/dsh-home-quarantine-macos/lib/index.js +0 -1
  644. package/node_modules/@deepseek-ai/dsh-home-quarantine-macos/lib/invariant.js +0 -1
  645. package/node_modules/@deepseek-ai/dsh-home-quarantine-macos/package.json +0 -1
  646. package/node_modules/@deepseek-ai/dsh-llm-gateway-openai/LICENSE +0 -21
  647. package/node_modules/@deepseek-ai/dsh-llm-gateway-openai/lib/index.js +0 -17
  648. package/node_modules/@deepseek-ai/dsh-llm-gateway-openai/lib/invariant.js +0 -1
  649. package/node_modules/@deepseek-ai/dsh-llm-gateway-openai/package.json +0 -1
  650. package/node_modules/@deepseek-ai/dsh-qb-auth/LICENSE +0 -21
  651. package/node_modules/@deepseek-ai/dsh-qb-auth/lib/index.js +0 -4
  652. package/node_modules/@deepseek-ai/dsh-qb-auth/lib/invariant.js +0 -1
  653. package/node_modules/@deepseek-ai/dsh-qb-auth/package.json +0 -1
  654. package/node_modules/@deepseek-ai/dsh-web-search-dsh/LICENSE +0 -21
  655. package/node_modules/@deepseek-ai/dsh-web-search-dsh/lib/index.js +0 -1
  656. package/node_modules/@deepseek-ai/dsh-web-search-dsh/lib/invariant.js +0 -1
  657. package/node_modules/@deepseek-ai/dsh-web-search-dsh/package.json +0 -1
  658. package/node_modules/@napi-rs/xattr/LICENSE +0 -21
  659. package/node_modules/@napi-rs/xattr/index.js +0 -567
  660. package/node_modules/@napi-rs/xattr/package.json +0 -1
  661. package/node_modules/@napi-rs/xattr-darwin-arm64/package.json +0 -1
  662. package/node_modules/@napi-rs/xattr-darwin-arm64/xattr.darwin-arm64.node +0 -0
  663. package/node_modules/@napi-rs/xattr-darwin-x64/package.json +0 -1
  664. package/node_modules/@napi-rs/xattr-darwin-x64/xattr.darwin-x64.node +0 -0
  665. package/node_modules/@parcel/watcher/LICENSE +0 -21
  666. package/node_modules/@parcel/watcher/index.js +0 -44
  667. package/node_modules/@parcel/watcher/index.js.flow +0 -45
  668. package/node_modules/@parcel/watcher/package.json +0 -1
  669. package/node_modules/@parcel/watcher/scripts/build-from-source.js +0 -16
  670. package/node_modules/@parcel/watcher/wrapper.js +0 -88
  671. package/node_modules/@parcel/watcher-darwin-arm64/LICENSE +0 -21
  672. package/node_modules/@parcel/watcher-darwin-arm64/package.json +0 -1
  673. package/node_modules/@parcel/watcher-darwin-arm64/watcher.node +0 -0
  674. package/node_modules/@parcel/watcher-darwin-x64/LICENSE +0 -21
  675. package/node_modules/@parcel/watcher-darwin-x64/package.json +0 -1
  676. package/node_modules/@parcel/watcher-darwin-x64/watcher.node +0 -0
  677. package/node_modules/@parcel/watcher-win32-x64/LICENSE +0 -21
  678. package/node_modules/@parcel/watcher-win32-x64/package.json +0 -1
  679. package/node_modules/@parcel/watcher-win32-x64/watcher.node +0 -0
  680. package/node_modules/is-extglob/LICENSE +0 -21
  681. package/node_modules/is-extglob/index.js +0 -20
  682. package/node_modules/is-extglob/package.json +0 -1
  683. package/node_modules/is-glob/LICENSE +0 -21
  684. package/node_modules/is-glob/index.js +0 -150
  685. package/node_modules/is-glob/package.json +0 -1
  686. package/node_modules/node-pty/deps/winpty/.drone.yml +0 -15
  687. package/node_modules/node-pty/deps/winpty/LICENSE +0 -21
  688. package/node_modules/node-pty/deps/winpty/configure +0 -167
  689. package/node_modules/node-pty/deps/winpty/misc/ConinMode.ps1 +0 -116
  690. package/node_modules/node-pty/deps/winpty/misc/IdentifyConsoleWindow.ps1 +0 -51
  691. package/node_modules/node-pty/deps/winpty/misc/build32.sh +0 -9
  692. package/node_modules/node-pty/deps/winpty/misc/build64.sh +0 -9
  693. package/node_modules/node-pty/deps/winpty/misc/color-test.sh +0 -212
  694. package/node_modules/node-pty/deps/winpty/ship/build-pty4j-libpty.bat +0 -36
  695. package/node_modules/node-pty/deps/winpty/src/shared/GetCommitHash.bat +0 -13
  696. package/node_modules/node-pty/deps/winpty/src/shared/UpdateGenVersion.bat +0 -20
  697. package/node_modules/node-pty/deps/winpty/vcbuild.bat +0 -83
  698. package/node_modules/node-pty/lib/eventEmitter2.test.js +0 -30
  699. package/node_modules/node-pty/lib/terminal.test.js +0 -139
  700. package/node_modules/node-pty/lib/testUtils.test.js +0 -28
  701. package/node_modules/node-pty/lib/unixTerminal.test.js +0 -351
  702. package/node_modules/node-pty/lib/windowsPtyAgent.test.js +0 -90
  703. package/node_modules/node-pty/lib/windowsTerminal.test.js +0 -219
  704. package/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
  705. package/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  706. package/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
  707. package/node_modules/node-pty/scripts/gen-compile-commands.js +0 -8
  708. package/node_modules/node-pty/scripts/increment-version.js +0 -54
  709. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
  710. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
  711. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
  712. package/node_modules/typebox/build/type/action/_add_immutable.mjs +0 -1
  713. package/node_modules/typebox/build/type/action/_add_optional.mjs +0 -1
  714. package/node_modules/typebox/build/type/action/_add_readonly.mjs +0 -1
  715. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +0 -1
  716. package/node_modules/typebox/build/type/action/_remove_optional.mjs +0 -1
  717. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +0 -1
  718. package/node_modules/typebox/build/type/action/with.mjs +0 -1
  719. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +0 -1
  720. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +0 -1
  721. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +0 -1
  722. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +0 -1
  723. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +0 -1
  724. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +0 -1
  725. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +0 -1
  726. package/node_modules/typebox/build/type/engine/priority/index.mjs +0 -1
  727. package/node_modules/typebox/build/type/engine/priority/priority.mjs +0 -1
  728. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +0 -1
  729. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +0 -1
  730. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +0 -1
  731. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +0 -1
  732. package/node_modules/typebox/build/type/engine/with/instantiate.mjs +0 -1
  733. package/node_modules/typebox/build/type/extends/dependent.mjs +0 -1
  734. package/node_modules/typebox/build/type/extends/record.mjs +0 -1
  735. package/node_modules/typebox/build/type/types/dependent.mjs +0 -1
  736. /package/node_modules/@deepseek-ai/dsh-sandbox-windows-acl/lib/{types-D2_FQYSK.js → types-DE3U0cmQ.js} +0 -0
  737. /package/node_modules/typebox/build/type/engine/{with → awaited}/index.mjs +0 -0
@@ -6,7 +6,7 @@
6
6
  <link rel="manifest" href="/manifest.webmanifest" />
7
7
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
8
8
  <title>DeepSeek Harness</title>
9
- <script type="module" crossorigin src="/assets/index-BQQQ5Qt-.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-fPGOmJjK.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/vendor-CeMKrCZm.js">
11
11
  <link rel="stylesheet" crossorigin href="/assets/vendor-CjyC-hUb.css">
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-CSGf6Qzd.css">
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-web-frontend","version":"0.0.15","publishConfig":{"access":"public"},"type":"module","exports":{"./dist/*":"./dist/*","./package.json":"./package.json"},"license":"MIT","dependencies":{"react":"^18.2.0","react-dom":"^18.2.0","@deepseek-ai/dsh-client-web":"^0.0.15"}}
1
+ {"name":"@deepseek-ai/dsh-web-frontend","version":"0.1.0-rc.7","publishConfig":{"access":"public"},"type":"module","exports":{"./dist/*":"./dist/*","./package.json":"./package.json"},"license":"MIT","dependencies":{"react":"^18.2.0","react-dom":"^18.2.0","@deepseek-ai/dsh-client-web":"^0.1.0-rc.7"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-web-search-deepseek","version":"0.0.15","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-launch-environment":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-credentials":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-settings":"^0.0.15","@deepseek-ai/dsh-web":"^0.0.15"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-web-search-deepseek","version":"0.1.0-rc.7","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-agent":"^0.1.0-rc.7","@deepseek-ai/dsh-credentials":"^0.1.0-rc.7","@deepseek-ai/dsh-invariants":"^0.1.0-rc.7","@deepseek-ai/dsh-launch-environment":"^0.1.0-rc.7","@deepseek-ai/dsh-web":"^0.1.0-rc.7","@deepseek-ai/dsh-session":"^0.1.0-rc.7","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-settings":"^0.1.0-rc.7"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-workflow","version":"0.0.15","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./types":{"types":"./lib/types/types.d.ts","default":"./lib/types/types.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.0.15","@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-session":"^0.0.15"}}
1
+ {"name":"@deepseek-ai/dsh-workflow","version":"0.1.0-rc.7","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./types":{"types":"./lib/types/types.d.ts","default":"./lib/types/types.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-agent":"^0.1.0-rc.7","@deepseek-ai/dsh-brand":"^0.1.0-rc.7","@deepseek-ai/dsh-session":"^0.1.0-rc.7","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-llm":"^0.1.0-rc.7","@deepseek-ai/dsh-invariants":"^0.1.0-rc.7"}}
@@ -76,14 +76,15 @@ var HostToWorkerType;
76
76
  })(HostToWorkerType || (HostToWorkerType = {}));
77
77
  //#endregion
78
78
  //#region lib/types/realm.js
79
- /**
80
- * Materializes values leaving the script vm into plain JSON before they cross the worker
81
- * boundary, and renders thrown script values without rejecting the run. The walk rejects
82
- * values that JSON cannot preserve but trusts model-written workflow scripts: getters and proxy traps may
83
- * run, and the vm is not a security boundary. The worker provides host-loop isolation and
84
- * forced termination, not hostile-value containment.
85
- * @module @deepseek-ai/dsh-workflow-worker-thread/realm
86
- */
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
87
88
  /** Thrown by {@link materializeFromRealm}; the caller wraps it into the right `WorkflowError` code. */
88
89
  var MaterializeError = class extends Error {
89
90
  path;
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-workflow-worker-thread","version":"0.0.15","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./worker":{"types":"./lib/types/worker.d.ts","default":"./lib/worker.cjs"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-subagent":"^0.0.15","@deepseek-ai/dsh-tools":"^0.0.15","@deepseek-ai/dsh-workflow":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-brand":"^0.0.15"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-workflow-worker-thread","version":"0.1.0-rc.7","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./worker":{"types":"./lib/types/worker.d.ts","default":"./lib/worker.cjs"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.1.0-rc.7","@deepseek-ai/dsh-llm":"^0.1.0-rc.7","@deepseek-ai/dsh-invariants":"^0.1.0-rc.7","@deepseek-ai/dsh-subagent":"^0.1.0-rc.7","@deepseek-ai/dsh-tools":"^0.1.0-rc.7","@deepseek-ai/dsh-session":"^0.1.0-rc.7","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-agent":"^0.1.0-rc.7","@deepseek-ai/dsh-workflow":"^0.1.0-rc.7"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-workspace","version":"0.0.15","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./types":{"types":"./lib/types/types.d.ts","default":"./lib/types/types.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.0.15","@deepseek-ai/dsh-storage-domain":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-storage":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-session-persistence":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"zod":"^4.4.3"}}
1
+ {"name":"@deepseek-ai/dsh-workspace","version":"0.1.0-rc.7","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./types":{"types":"./lib/types/types.d.ts","default":"./lib/types/types.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-storage-domain":"^0.1.0-rc.7","@deepseek-ai/dsh-session":"^0.1.0-rc.7","@deepseek-ai/dsh-storage":"^0.1.0-rc.7","@deepseek-ai/dsh-invariants":"^0.1.0-rc.7","@deepseek-ai/dsh-session-persistence":"^0.1.0-rc.7","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-brand":"^0.1.0-rc.7"},"dependencies":{"zod":"^4.4.3"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/node-addon-landlock-run","version":"0.1.1","type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/index.d.ts","default":"./lib/index.js"},"./package.json":"./package.json"},"engines":{"node":">=20"},"license":"BSD-3-Clause","publishConfig":{"access":"public"},"optionalDependencies":{"@deepseek-ai/node-addon-landlock-run-linux-arm64":"0.1.1","@deepseek-ai/node-addon-landlock-run-linux-x64":"0.1.1"}}
1
+ {"name":"@deepseek-ai/node-addon-landlock-run","version":"0.1.1","type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/index.d.ts","default":"./lib/index.js"},"./package.json":"./package.json"},"engines":{"node":">=20"},"license":"BSD-3-Clause","publishConfig":{"access":"public"},"optionalDependencies":{"@deepseek-ai/node-addon-landlock-run-linux-x64":"0.1.1","@deepseek-ai/node-addon-landlock-run-linux-arm64":"0.1.1"}}
@@ -1,5 +1,5 @@
1
- var N=Object.defineProperty;var f=(e,r)=>N(e,"name",{value:r,configurable:!0});import b from"@anthropic-ai/sdk";import{calculateCost as S}from"../models.js";import{splitDeferredTools as j}from"../utils/deferred-tools.js";import{AssistantMessageEventStream as B}from"../utils/event-stream.js";import{headersToRecord as O}from"../utils/headers.js";import{parseJsonWithRepair as P,parseStreamingJson as E}from"../utils/json-parse.js";import{getProviderEnvValue as W}from"../utils/provider-env.js";import{retryProviderRequest as H}from"../utils/provider-retry.js";import{sanitizeSurrogates as k}from"../utils/sanitize-unicode.js";import{resolveJsonSchemaStrictSampling as D}from"./constrained-sampling.js";import{buildCopilotDynamicHeaders as J,hasCopilotVisionInput as U}from"./github-copilot-headers.js";import{adjustMaxTokensForThinking as q,buildBaseOptions as z,clampMaxTokensToContext as $}from"./simple-options.js";import{transformMessages as G}from"./transform-messages.js";function C(e,r){return e||(W("PI_CACHE_RETENTION",r)==="long"?"long":"short")}f(C,"resolveCacheRetention");function F(e,r,n){const a=C(r,n);if(a==="none")return{retention:a};const t=a==="long"&&_(e).supportsLongCacheRetention?"1h":void 0;return{retention:a,cacheControl:{type:"ephemeral",...t&&{ttl:t}}}}f(F,"getCacheControl");const K="2.1.75",V=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"],Q=new Map(V.map(e=>[e.toLowerCase(),e])),y=f(e=>Q.get(e.toLowerCase())??e,"toClaudeCodeName"),Y=f((e,r)=>{if(r&&r.length>0){const n=e.toLowerCase(),a=r.find(t=>t.name.toLowerCase()===n);if(a)return a.name}return e},"fromClaudeCodeName");function Z(e){if(!e.some(t=>t.type==="image"))return k(e.map(t=>t.text).join(`
2
- `));const n=e.map(t=>t.type==="text"?{type:"text",text:k(t.text)}:{type:"image",source:{type:"base64",media_type:t.mimeType,data:t.data}});return n.some(t=>t.type==="text")||n.unshift({type:"text",text:"(see attached image)"}),n}f(Z,"convertContentBlocks");const X="fine-grained-tool-streaming-2025-05-14",ee="interleaved-thinking-2025-05-14";function _(e){return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:e.compat?.sendSessionAffinityHeaders??!1,supportsCacheControlOnTools:e.compat?.supportsCacheControlOnTools??!0,supportsTemperature:e.compat?.supportsTemperature??!0,allowEmptySignature:e.compat?.allowEmptySignature??!1,supportsStrictTools:e.compat?.supportsStrictTools??!1,supportsToolReferences:e.compat?.supportsToolReferences??te(e)}}f(_,"getAnthropicCompat");function te(e){if(e.provider!=="anthropic"||e.id.includes("haiku"))return!1;const r=e.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);if(!r)return!1;const n=Number(r[1]),a=r[2]&&r[2].length<8?Number(r[2]):0;return n>4||n===4&&a>=5}f(te,"defaultSupportsToolReferences");function w(...e){const r={};for(const n of e)n&&Object.assign(r,n);return r}f(w,"mergeHeaders");function T(e,r){if(!e)return!1;const n=r.toLowerCase();for(const[a,t]of Object.entries(e))if(a.toLowerCase()===n&&t!==null&&t.trim().length>0)return!0;return!1}f(T,"hasHeader");function I(e,r,n){if(!r&&!(T(n,"authorization")||T(n,"x-api-key")||T(n,"cf-aig-authorization")))throw new Error(`No API key for provider: ${e}`)}f(I,"assertRequestAuth");const ne=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function A(e){if(!e.event&&e.data.length===0)return null;const r={event:e.event,data:e.data.join(`
3
- `),raw:[...e.raw]};return e.event=null,e.data=[],e.raw=[],r}f(A,"flushSseEvent");function R(e,r){if(e==="")return A(r);if(r.raw.push(e),e.startsWith(":"))return null;const n=e.indexOf(":"),a=n===-1?e:e.slice(0,n);let t=n===-1?"":e.slice(n+1);return t.startsWith(" ")&&(t=t.slice(1)),a==="event"?r.event=t:a==="data"&&r.data.push(t),null}f(R,"decodeSseLine");function se(e){const r=e.indexOf("\r"),n=e.indexOf(`
4
- `);return r===-1?n:n===-1?r:Math.min(r,n)}f(se,"nextLineBreakIndex");function x(e){const r=se(e);if(r===-1)return null;let n=r+1;return e[r]==="\r"&&e[n]===`
5
- `&&(n+=1),{line:e.slice(0,r),rest:e.slice(n)}}f(x,"consumeLine");async function*re(e,r){const n=e.getReader(),a=new TextDecoder,t={event:null,data:[],raw:[]};let o="";try{for(;;){if(r?.aborted)throw new Error("Request was aborted");const{value:l,done:p}=await n.read();if(p)break;o+=a.decode(l,{stream:!0});let d=x(o);for(;d;){o=d.rest;const u=R(d.line,t);u&&(yield u),d=x(o)}}o+=a.decode();let c=x(o);for(;c;){o=c.rest;const l=R(c.line,t);l&&(yield l),c=x(o)}if(o.length>0){const l=R(o,t);l&&(yield l)}const h=A(t);h&&(yield h)}finally{n.releaseLock()}}f(re,"iterateSseMessages");async function*ae(e,r){if(!e.body)throw new Error("Attempted to iterate over an Anthropic response with no body");let n=!1,a=!1;for await(const t of re(e.body,r)){if(t.event==="error")throw new Error(t.data);if(ne.has(t.event??""))try{const o=P(t.data);o.type==="message_start"?n=!0:o.type==="message_stop"&&(a=!0),yield o}catch(o){const c=o instanceof Error?o.message:String(o);throw new Error(`Could not parse Anthropic SSE event ${t.event}: ${c}; data=${t.data}; raw=${t.raw.join("\\n")}`)}}if(n&&!a)throw new Error("Anthropic stream ended before message_stop")}f(ae,"iterateAnthropicEvents");export const stream=f((e,r,n)=>{const a=new B;return(async()=>{const t={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let o,c;if(n?.client)o=n.client,c=!1;else{const s=n?.apiKey;I(e.provider,s,n?.headers);let i;if(e.provider==="github-copilot"){const L=U(r.messages);i=J({messages:r.messages,hasImages:L})}const m=C(n?.cacheRetention,n?.env)==="none"?void 0:n?.sessionId,v=ce(e,s,n?.interleavedThinking??!0,ge(e,r),n?.headers,n?.fetch,i,m);o=v.client,c=v.isOAuthToken}let h=ue(e,r,c,n);const l=await n?.onPayload?.(h,e);l!==void 0&&(h=l);const p={...n?.signal?{signal:n.signal}:{},...n?.timeoutMs!==void 0?{timeout:n.timeoutMs}:{},maxRetries:0},d=await H(()=>o.messages.create({...h,stream:!0},p).asResponse(),{maxRetries:n?.maxRetries,maxRetryDelayMs:n?.maxRetryDelayMs,signal:n?.signal});await n?.onResponse?.({status:d.status,headers:O(d.headers)},e),a.push({type:"start",partial:t});const u=t.content;for await(const s of ae(d,n?.signal))if(s.type==="message_start")t.responseId=s.message.id,t.usage.input=s.message.usage.input_tokens||0,t.usage.output=s.message.usage.output_tokens||0,t.usage.cacheRead=s.message.usage.cache_read_input_tokens||0,t.usage.cacheWrite=s.message.usage.cache_creation_input_tokens||0,t.usage.cacheWrite1h=s.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,t.usage.totalTokens=t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,S(e,t.usage);else if(s.type==="content_block_start"){if(s.content_block.type==="text"){const i={type:"text",text:"",index:s.index};t.content.push(i),a.push({type:"text_start",contentIndex:t.content.length-1,partial:t})}else if(s.content_block.type==="thinking"){const i={type:"thinking",thinking:"",thinkingSignature:"",index:s.index};t.content.push(i),a.push({type:"thinking_start",contentIndex:t.content.length-1,partial:t})}else if(s.content_block.type==="redacted_thinking"){const i={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:s.content_block.data,redacted:!0,index:s.index};t.content.push(i),a.push({type:"thinking_start",contentIndex:t.content.length-1,partial:t})}else if(s.content_block.type==="tool_use"){const i={type:"toolCall",id:s.content_block.id,name:c?Y(s.content_block.name,r.tools):s.content_block.name,arguments:s.content_block.input??{},partialJson:"",index:s.index};t.content.push(i),a.push({type:"toolcall_start",contentIndex:t.content.length-1,partial:t})}}else if(s.type==="content_block_delta"){if(s.delta.type==="text_delta"){const i=u.findIndex(m=>m.index===s.index),g=u[i];g&&g.type==="text"&&(g.text+=s.delta.text,a.push({type:"text_delta",contentIndex:i,delta:s.delta.text,partial:t}))}else if(s.delta.type==="thinking_delta"){const i=u.findIndex(m=>m.index===s.index),g=u[i];g&&g.type==="thinking"&&(g.thinking+=s.delta.thinking,a.push({type:"thinking_delta",contentIndex:i,delta:s.delta.thinking,partial:t}))}else if(s.delta.type==="input_json_delta"){const i=u.findIndex(m=>m.index===s.index),g=u[i];g&&g.type==="toolCall"&&(g.partialJson+=s.delta.partial_json,g.arguments=E(g.partialJson),a.push({type:"toolcall_delta",contentIndex:i,delta:s.delta.partial_json,partial:t}))}else if(s.delta.type==="signature_delta"){const i=u.findIndex(m=>m.index===s.index),g=u[i];g&&g.type==="thinking"&&(g.thinkingSignature=g.thinkingSignature||"",g.thinkingSignature+=s.delta.signature)}}else if(s.type==="content_block_stop"){const i=u.findIndex(m=>m.index===s.index),g=u[i];g&&(delete g.index,g.type==="text"?a.push({type:"text_end",contentIndex:i,content:g.text,partial:t}):g.type==="thinking"?a.push({type:"thinking_end",contentIndex:i,content:g.thinking,partial:t}):g.type==="toolCall"&&(g.arguments=E(g.partialJson),delete g.partialJson,a.push({type:"toolcall_end",contentIndex:i,toolCall:g,partial:t})))}else if(s.type==="message_delta"){if(s.delta.stop_reason){t.rawStopReason=s.delta.stop_reason;const i=fe(s.delta.stop_reason,s.delta.stop_details);t.stopReason=i.stopReason,i.errorMessage&&(t.errorMessage=i.errorMessage)}if(s.usage){s.usage.input_tokens!=null&&(t.usage.input=s.usage.input_tokens),s.usage.output_tokens!=null&&(t.usage.output=s.usage.output_tokens),s.usage.cache_read_input_tokens!=null&&(t.usage.cacheRead=s.usage.cache_read_input_tokens),s.usage.cache_creation_input_tokens!=null&&(t.usage.cacheWrite=s.usage.cache_creation_input_tokens);const i=s.usage.output_tokens_details?.thinking_tokens;i!=null&&(t.usage.reasoning=i)}t.usage.totalTokens=t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,S(e,t.usage)}if(n?.signal?.aborted)throw new Error("Request was aborted");if(t.stopReason==="pending")throw new Error("Anthropic stream ended without a stop reason");if(t.stopReason==="aborted"||t.stopReason==="error")throw new Error(t.errorMessage||"An unknown error occurred");a.push({type:"done",reason:t.stopReason,message:t}),a.end()}catch(o){for(const c of t.content)delete c.index,delete c.partialJson;t.stopReason=n?.signal?.aborted?"aborted":"error",t.errorMessage=o instanceof Error?o.message:JSON.stringify(o),a.push({type:"error",reason:t.stopReason,error:t}),a.end()}})(),a},"stream");function oe(e,r){const n=r?e.thinkingLevelMap?.[r]:void 0;if(typeof n=="string")return n;switch(r){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}f(oe,"mapThinkingLevelToEffort");export const streamSimple=f((e,r,n)=>{I(e.provider,n?.apiKey,n?.headers);const a=z(e,r,n,n?.apiKey);if(!n?.reasoning)return stream(e,r,{...a,thinkingEnabled:!1});if(e.compat?.forceAdaptiveThinking===!0){const c=oe(e,n.reasoning);return stream(e,r,{...a,thinkingEnabled:!0,effort:c})}const t=q(a.maxTokens,e.maxTokens,n.reasoning,n.thinkingBudgets),o=$(e,r,t.maxTokens);return stream(e,r,{...a,maxTokens:o,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(t.thinkingBudget,Math.max(0,o-1024))})},"streamSimple");function ie(e){return e.includes("sk-ant-oat")}f(ie,"isOAuthToken");function ce(e,r,n,a,t,o,c,h){const l=n&&e.compat?.forceAdaptiveThinking!==!0,p=[];if(a&&p.push(X),l&&p.push(ee),e.provider==="github-copilot")return{client:new b({apiKey:null,authToken:r??null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:o,defaultHeaders:w({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...p.length>0?{"anthropic-beta":p.join(",")}:{}},e.headers,c,t)}),isOAuthToken:!1};if(r&&ie(r))return{client:new b({apiKey:null,authToken:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:o,defaultHeaders:w({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":["claude-code-20250219","oauth-2025-04-20",...p].join(","),"user-agent":`claude-cli/${K}`,"x-app":"cli"},e.headers,t)}),isOAuthToken:!0};const d=h&&_(e).sendSessionAffinityHeaders?{"x-session-affinity":h}:{},u=w({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...p.length>0?{"anthropic-beta":p.join(",")}:{}},d,e.headers,t);return{client:new b({apiKey:r??null,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:o,defaultHeaders:u}),isOAuthToken:!1}}f(ce,"createClient");function ue(e,r,n,a){const{cacheControl:t}=F(e,a?.cacheRetention,a?.env),o=_(e),c=G(r.messages,e,le),h=n?y:i=>i,l=j({...r,messages:c},o.supportsToolReferences,h);let p=l.immediate,d=[...l.deferred.values()];p.length===0&&d.length>0&&(p=d,d=[]);const u=new Set(d.map(i=>h(i.name))),s={model:e.id,messages:de(c,n,t,o.allowEmptySignature,u,h),max_tokens:a?.maxTokens??e.maxTokens,stream:!0};if(n?(s.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...t?{cache_control:t}:{}}],r.systemPrompt&&s.system.push({type:"text",text:k(r.systemPrompt),...t?{cache_control:t}:{}})):r.systemPrompt&&(s.system=[{type:"text",text:k(r.systemPrompt),...t?{cache_control:t}:{}}]),a?.temperature!==void 0&&!a?.thinkingEnabled&&o.supportsTemperature&&(s.temperature=a.temperature),(p.length>0||d.length>0)&&(s.tools=[...M(p,n,o.supportsEagerToolInputStreaming,o.supportsStrictTools,o.supportsCacheControlOnTools?t:void 0),...M(d,n,o.supportsEagerToolInputStreaming,o.supportsStrictTools,void 0,!0)]),e.reasoning)if(a?.thinkingEnabled){const i=a.thinkingDisplay??"summarized";e.compat?.forceAdaptiveThinking===!0?(s.thinking={type:"adaptive",display:i},a.effort&&(s.output_config=a.effort==="xhigh"?{effort:a.effort}:{effort:a.effort})):s.thinking={type:"enabled",budget_tokens:a.thinkingBudgetTokens||1024,display:i}}else a?.thinkingEnabled===!1&&e.thinkingLevelMap?.off!==null&&(s.thinking={type:"disabled"});if(a?.metadata){const i=a.metadata.user_id;typeof i=="string"&&(s.metadata={user_id:i})}return a?.toolChoice&&(typeof a.toolChoice=="string"?s.tool_choice={type:a.toolChoice}:s.tool_choice=a.toolChoice),s}f(ue,"buildParams");function le(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}f(le,"normalizeToolCallId");function pe(e,r,n,a,t){const o=[];for(const h of e.addedToolNames??[]){const l=t(h);!n.has(l)||a.has(l)||(a.add(l),o.push({type:"tool_reference",tool_name:r?y(h):h}))}const c=Z(e.content);return{toolResult:{type:"tool_result",tool_use_id:e.toolCallId,content:o.length>0?o:c,is_error:e.isError},siblingContent:o.length===0?[]:typeof c=="string"?[{type:"text",text:c}]:c}}f(pe,"convertToolResult");function de(e,r,n,a=!1,t=new Set,o=c=>c){const c=[],h=new Set;for(let l=0;l<e.length;l++){const p=e[l];if(p.role==="user")if(typeof p.content=="string")p.content.trim().length>0&&c.push({role:"user",content:k(p.content)});else{const u=p.content.map(s=>s.type==="text"?{type:"text",text:k(s.text)}:{type:"image",source:{type:"base64",media_type:s.mimeType,data:s.data}}).filter(s=>s.type==="text"?s.text.trim().length>0:!0);if(u.length===0)continue;c.push({role:"user",content:u})}else if(p.role==="assistant"){const d=[];for(const u of p.content)if(u.type==="text"){if(u.text.trim().length===0)continue;d.push({type:"text",text:k(u.text)})}else if(u.type==="thinking"){if(u.redacted){d.push({type:"redacted_thinking",data:u.thinkingSignature});continue}const s=u.thinkingSignature,i=!!s&&s.trim().length>0;if(u.thinking.trim().length===0&&!i)continue;i?d.push({type:"thinking",thinking:k(u.thinking),signature:s}):d.push(a?{type:"thinking",thinking:k(u.thinking),signature:""}:{type:"text",text:k(u.thinking)})}else u.type==="toolCall"&&d.push({type:"tool_use",id:u.id,name:r?y(u.name):u.name,input:u.arguments??{}});if(d.length===0)continue;c.push({role:"assistant",content:d})}else if(p.role==="toolResult"){const d=[],u=[];let s=l;for(;s<e.length&&e[s].role==="toolResult";){const i=pe(e[s],r,t,h,o);d.push(i.toolResult),u.push(...i.siblingContent),s++}l=s-1,c.push({role:"user",content:[...d,...u]})}}if(n&&c.length>0){const l=c[c.length-1];if(l.role==="user")if(Array.isArray(l.content)){const p=l.content[l.content.length-1];p&&(p.type==="text"||p.type==="image"||p.type==="tool_result")&&(p.cache_control=n)}else typeof l.content=="string"&&(l.content=[{type:"text",text:l.content,cache_control:n}])}return c}f(de,"convertMessages");function ge(e,r){return!!r.tools?.length&&!_(e).supportsEagerToolInputStreaming}f(ge,"shouldUseFineGrainedToolStreamingBeta");function M(e,r,n,a,t,o=!1){return e?e.map((c,h)=>{const l=D(c,a),p=c.parameters,d={type:"object",properties:p.properties??{},required:p.required??[]},u=l===!0?{...c.parameters,...d}:d;return{name:r?y(c.name):c.name,description:c.description,...n?{eager_input_streaming:!0}:{},...l===!0?{strict:!0}:{},input_schema:u,...o?{defer_loading:!0}:{},...t&&h===e.length-1?{cache_control:t}:{}}}):[]}f(M,"convertTools");function fe(e,r){switch(e){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:r?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error",errorMessage:"Provider stopped with: sensitive"};default:throw new Error(`Unhandled stop reason: ${e}`)}}f(fe,"mapStopReason");
1
+ var N=Object.defineProperty;var f=(e,r)=>N(e,"name",{value:r,configurable:!0});import b from"@anthropic-ai/sdk";import{calculateCost as S}from"../models.js";import{splitDeferredTools as j}from"../utils/deferred-tools.js";import{AssistantMessageEventStream as B}from"../utils/event-stream.js";import{headersToRecord as O}from"../utils/headers.js";import{parseJsonWithRepair as P,parseStreamingJson as C}from"../utils/json-parse.js";import{getProviderEnvValue as W}from"../utils/provider-env.js";import{retryProviderRequest as H}from"../utils/provider-retry.js";import{sanitizeSurrogates as k}from"../utils/sanitize-unicode.js";import{resolveJsonSchemaStrictSampling as D}from"./constrained-sampling.js";import{buildCopilotDynamicHeaders as J,hasCopilotVisionInput as U}from"./github-copilot-headers.js";import{adjustMaxTokensForThinking as q,buildBaseOptions as z,clampMaxTokensToContext as $}from"./simple-options.js";import{transformMessages as G}from"./transform-messages.js";function E(e,r){return e||(W("PI_CACHE_RETENTION",r)==="long"?"long":"short")}f(E,"resolveCacheRetention");function F(e,r,s){const a=E(r,s);if(a==="none")return{retention:a};const t=a==="long"&&_(e).supportsLongCacheRetention?"1h":void 0;return{retention:a,cacheControl:{type:"ephemeral",...t&&{ttl:t}}}}f(F,"getCacheControl");const K="2.1.75",V=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"],Q=new Map(V.map(e=>[e.toLowerCase(),e])),y=f(e=>Q.get(e.toLowerCase())??e,"toClaudeCodeName"),Y=f((e,r)=>{if(r&&r.length>0){const s=e.toLowerCase(),a=r.find(t=>t.name.toLowerCase()===s);if(a)return a.name}return e},"fromClaudeCodeName");function Z(e){if(!e.some(t=>t.type==="image"))return k(e.map(t=>t.text).join(`
2
+ `));const s=e.map(t=>t.type==="text"?{type:"text",text:k(t.text)}:{type:"image",source:{type:"base64",media_type:t.mimeType,data:t.data}});return s.some(t=>t.type==="text")||s.unshift({type:"text",text:"(see attached image)"}),s}f(Z,"convertContentBlocks");const X="fine-grained-tool-streaming-2025-05-14",ee="interleaved-thinking-2025-05-14";function _(e){return{supportsEagerToolInputStreaming:e.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:e.compat?.sendSessionAffinityHeaders??!1,supportsCacheControlOnTools:e.compat?.supportsCacheControlOnTools??!0,supportsTemperature:e.compat?.supportsTemperature??!0,allowEmptySignature:e.compat?.allowEmptySignature??!1,supportsStrictTools:e.compat?.supportsStrictTools??!1,supportsToolReferences:e.compat?.supportsToolReferences??te(e)}}f(_,"getAnthropicCompat");function te(e){if(e.provider!=="anthropic"||e.id.includes("haiku"))return!1;const r=e.id.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);if(!r)return!1;const s=Number(r[1]),a=r[2]&&r[2].length<8?Number(r[2]):0;return s>4||s===4&&a>=5}f(te,"defaultSupportsToolReferences");function T(...e){const r={};for(const s of e)s&&Object.assign(r,s);return r}f(T,"mergeHeaders");function w(e,r){if(!e)return!1;const s=r.toLowerCase();for(const[a,t]of Object.entries(e))if(a.toLowerCase()===s&&t!==null&&t.trim().length>0)return!0;return!1}f(w,"hasHeader");function I(e,r,s){if(!r&&!(w(s,"authorization")||w(s,"x-api-key")||w(s,"cf-aig-authorization")))throw new Error(`No API key for provider: ${e}`)}f(I,"assertRequestAuth");const ne=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function A(e){if(!e.event&&e.data.length===0)return null;const r={event:e.event,data:e.data.join(`
3
+ `),raw:[...e.raw]};return e.event=null,e.data=[],e.raw=[],r}f(A,"flushSseEvent");function R(e,r){if(e==="")return A(r);if(r.raw.push(e),e.startsWith(":"))return null;const s=e.indexOf(":"),a=s===-1?e:e.slice(0,s);let t=s===-1?"":e.slice(s+1);return t.startsWith(" ")&&(t=t.slice(1)),a==="event"?r.event=t:a==="data"&&r.data.push(t),null}f(R,"decodeSseLine");function se(e){const r=e.indexOf("\r"),s=e.indexOf(`
4
+ `);return r===-1?s:s===-1?r:Math.min(r,s)}f(se,"nextLineBreakIndex");function x(e){const r=se(e);if(r===-1)return null;let s=r+1;return e[r]==="\r"&&e[s]===`
5
+ `&&(s+=1),{line:e.slice(0,r),rest:e.slice(s)}}f(x,"consumeLine");async function*re(e,r){const s=e.getReader(),a=new TextDecoder,t={event:null,data:[],raw:[]};let o="";try{for(;;){if(r?.aborted)throw new Error("Request was aborted");const{value:u,done:g}=await s.read();if(g)break;o+=a.decode(u,{stream:!0});let p=x(o);for(;p;){o=p.rest;const l=R(p.line,t);l&&(yield l),p=x(o)}}o+=a.decode();let c=x(o);for(;c;){o=c.rest;const u=R(c.line,t);u&&(yield u),c=x(o)}if(o.length>0){const u=R(o,t);u&&(yield u)}const h=A(t);h&&(yield h)}finally{s.releaseLock()}}f(re,"iterateSseMessages");async function*ae(e,r){if(!e.body)throw new Error("Attempted to iterate over an Anthropic response with no body");let s=!1,a=!1;for await(const t of re(e.body,r)){if(t.event==="error")throw new Error(t.data);if(ne.has(t.event??""))try{const o=P(t.data);o.type==="message_start"?s=!0:o.type==="message_stop"&&(a=!0),yield o}catch(o){const c=o instanceof Error?o.message:String(o);throw new Error(`Could not parse Anthropic SSE event ${t.event}: ${c}; data=${t.data}; raw=${t.raw.join("\\n")}`)}}if(s&&!a)throw new Error("Anthropic stream ended before message_stop")}f(ae,"iterateAnthropicEvents");export const stream=f((e,r,s)=>{const a=new B;return(async()=>{const t={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let o,c;if(s?.client)o=s.client,c=!1;else{const n=s?.apiKey;I(e.provider,n,s?.headers);let i;if(e.provider==="github-copilot"){const L=U(r.messages);i=J({messages:r.messages,hasImages:L})}const m=E(s?.cacheRetention,s?.env)==="none"?void 0:s?.sessionId,v=ce(e,n,s?.interleavedThinking??!0,fe(e,r),s?.headers,i,m);o=v.client,c=v.isOAuthToken}let h=ue(e,r,c,s);const u=await s?.onPayload?.(h,e);u!==void 0&&(h=u);const g={...s?.signal?{signal:s.signal}:{},...s?.timeoutMs!==void 0?{timeout:s.timeoutMs}:{},maxRetries:0},p=await H(()=>o.messages.create({...h,stream:!0},g).asResponse(),{maxRetries:s?.maxRetries,maxRetryDelayMs:s?.maxRetryDelayMs,signal:s?.signal});await s?.onResponse?.({status:p.status,headers:O(p.headers)},e),a.push({type:"start",partial:t});const l=t.content;for await(const n of ae(p,s?.signal))if(n.type==="message_start")t.responseId=n.message.id,t.usage.input=n.message.usage.input_tokens||0,t.usage.output=n.message.usage.output_tokens||0,t.usage.cacheRead=n.message.usage.cache_read_input_tokens||0,t.usage.cacheWrite=n.message.usage.cache_creation_input_tokens||0,t.usage.cacheWrite1h=n.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,t.usage.totalTokens=t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,S(e,t.usage);else if(n.type==="content_block_start"){if(n.content_block.type==="text"){const i={type:"text",text:"",index:n.index};t.content.push(i),a.push({type:"text_start",contentIndex:t.content.length-1,partial:t})}else if(n.content_block.type==="thinking"){const i={type:"thinking",thinking:"",thinkingSignature:"",index:n.index};t.content.push(i),a.push({type:"thinking_start",contentIndex:t.content.length-1,partial:t})}else if(n.content_block.type==="redacted_thinking"){const i={type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:n.content_block.data,redacted:!0,index:n.index};t.content.push(i),a.push({type:"thinking_start",contentIndex:t.content.length-1,partial:t})}else if(n.content_block.type==="tool_use"){const i={type:"toolCall",id:n.content_block.id,name:c?Y(n.content_block.name,r.tools):n.content_block.name,arguments:n.content_block.input??{},partialJson:"",index:n.index};t.content.push(i),a.push({type:"toolcall_start",contentIndex:t.content.length-1,partial:t})}}else if(n.type==="content_block_delta"){if(n.delta.type==="text_delta"){const i=l.findIndex(m=>m.index===n.index),d=l[i];d&&d.type==="text"&&(d.text+=n.delta.text,a.push({type:"text_delta",contentIndex:i,delta:n.delta.text,partial:t}))}else if(n.delta.type==="thinking_delta"){const i=l.findIndex(m=>m.index===n.index),d=l[i];d&&d.type==="thinking"&&(d.thinking+=n.delta.thinking,a.push({type:"thinking_delta",contentIndex:i,delta:n.delta.thinking,partial:t}))}else if(n.delta.type==="input_json_delta"){const i=l.findIndex(m=>m.index===n.index),d=l[i];d&&d.type==="toolCall"&&(d.partialJson+=n.delta.partial_json,d.arguments=C(d.partialJson),a.push({type:"toolcall_delta",contentIndex:i,delta:n.delta.partial_json,partial:t}))}else if(n.delta.type==="signature_delta"){const i=l.findIndex(m=>m.index===n.index),d=l[i];d&&d.type==="thinking"&&(d.thinkingSignature=d.thinkingSignature||"",d.thinkingSignature+=n.delta.signature)}}else if(n.type==="content_block_stop"){const i=l.findIndex(m=>m.index===n.index),d=l[i];d&&(delete d.index,d.type==="text"?a.push({type:"text_end",contentIndex:i,content:d.text,partial:t}):d.type==="thinking"?a.push({type:"thinking_end",contentIndex:i,content:d.thinking,partial:t}):d.type==="toolCall"&&(d.arguments=C(d.partialJson),delete d.partialJson,a.push({type:"toolcall_end",contentIndex:i,toolCall:d,partial:t})))}else if(n.type==="message_delta"){if(n.delta.stop_reason){const i=ge(n.delta.stop_reason,n.delta.stop_details);t.stopReason=i.stopReason,i.errorMessage&&(t.errorMessage=i.errorMessage)}if(n.usage){n.usage.input_tokens!=null&&(t.usage.input=n.usage.input_tokens),n.usage.output_tokens!=null&&(t.usage.output=n.usage.output_tokens),n.usage.cache_read_input_tokens!=null&&(t.usage.cacheRead=n.usage.cache_read_input_tokens),n.usage.cache_creation_input_tokens!=null&&(t.usage.cacheWrite=n.usage.cache_creation_input_tokens);const i=n.usage.output_tokens_details?.thinking_tokens;i!=null&&(t.usage.reasoning=i)}t.usage.totalTokens=t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,S(e,t.usage)}if(s?.signal?.aborted)throw new Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw new Error(t.errorMessage||"An unknown error occurred");a.push({type:"done",reason:t.stopReason,message:t}),a.end()}catch(o){for(const c of t.content)delete c.index,delete c.partialJson;t.stopReason=s?.signal?.aborted?"aborted":"error",t.errorMessage=o instanceof Error?o.message:JSON.stringify(o),a.push({type:"error",reason:t.stopReason,error:t}),a.end()}})(),a},"stream");function oe(e,r){const s=r?e.thinkingLevelMap?.[r]:void 0;if(typeof s=="string")return s;switch(r){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}f(oe,"mapThinkingLevelToEffort");export const streamSimple=f((e,r,s)=>{I(e.provider,s?.apiKey,s?.headers);const a=z(e,r,s,s?.apiKey);if(!s?.reasoning)return stream(e,r,{...a,thinkingEnabled:!1});if(e.compat?.forceAdaptiveThinking===!0){const c=oe(e,s.reasoning);return stream(e,r,{...a,thinkingEnabled:!0,effort:c})}const t=q(a.maxTokens,e.maxTokens,s.reasoning,s.thinkingBudgets),o=$(e,r,t.maxTokens);return stream(e,r,{...a,maxTokens:o,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(t.thinkingBudget,Math.max(0,o-1024))})},"streamSimple");function ie(e){return e.includes("sk-ant-oat")}f(ie,"isOAuthToken");function ce(e,r,s,a,t,o,c){const h=s&&e.compat?.forceAdaptiveThinking!==!0,u=[];if(a&&u.push(X),h&&u.push(ee),e.provider==="github-copilot")return{client:new b({apiKey:null,authToken:r??null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:T({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...u.length>0?{"anthropic-beta":u.join(",")}:{}},e.headers,o,t)}),isOAuthToken:!1};if(r&&ie(r))return{client:new b({apiKey:null,authToken:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:T({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","anthropic-beta":["claude-code-20250219","oauth-2025-04-20",...u].join(","),"user-agent":`claude-cli/${K}`,"x-app":"cli"},e.headers,t)}),isOAuthToken:!0};const g=c&&_(e).sendSessionAffinityHeaders?{"x-session-affinity":c}:{},p=T({accept:"application/json","anthropic-dangerous-direct-browser-access":"true",...u.length>0?{"anthropic-beta":u.join(",")}:{}},g,e.headers,t);return{client:new b({apiKey:r??null,authToken:null,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:p}),isOAuthToken:!1}}f(ce,"createClient");function ue(e,r,s,a){const{cacheControl:t}=F(e,a?.cacheRetention,a?.env),o=_(e),c=G(r.messages,e,le),h=s?y:i=>i,u=j({...r,messages:c},o.supportsToolReferences,h);let g=u.immediate,p=[...u.deferred.values()];g.length===0&&p.length>0&&(g=p,p=[]);const l=new Set(p.map(i=>h(i.name))),n={model:e.id,messages:de(c,s,t,o.allowEmptySignature,l,h),max_tokens:a?.maxTokens??e.maxTokens,stream:!0};if(s?(n.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...t?{cache_control:t}:{}}],r.systemPrompt&&n.system.push({type:"text",text:k(r.systemPrompt),...t?{cache_control:t}:{}})):r.systemPrompt&&(n.system=[{type:"text",text:k(r.systemPrompt),...t?{cache_control:t}:{}}]),a?.temperature!==void 0&&!a?.thinkingEnabled&&o.supportsTemperature&&(n.temperature=a.temperature),(g.length>0||p.length>0)&&(n.tools=[...M(g,s,o.supportsEagerToolInputStreaming,o.supportsStrictTools,o.supportsCacheControlOnTools?t:void 0),...M(p,s,o.supportsEagerToolInputStreaming,o.supportsStrictTools,void 0,!0)]),e.reasoning)if(a?.thinkingEnabled){const i=a.thinkingDisplay??"summarized";e.compat?.forceAdaptiveThinking===!0?(n.thinking={type:"adaptive",display:i},a.effort&&(n.output_config=a.effort==="xhigh"?{effort:a.effort}:{effort:a.effort})):n.thinking={type:"enabled",budget_tokens:a.thinkingBudgetTokens||1024,display:i}}else a?.thinkingEnabled===!1&&e.thinkingLevelMap?.off!==null&&(n.thinking={type:"disabled"});if(a?.metadata){const i=a.metadata.user_id;typeof i=="string"&&(n.metadata={user_id:i})}return a?.toolChoice&&(typeof a.toolChoice=="string"?n.tool_choice={type:a.toolChoice}:n.tool_choice=a.toolChoice),n}f(ue,"buildParams");function le(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}f(le,"normalizeToolCallId");function pe(e,r,s,a,t){const o=[];for(const h of e.addedToolNames??[]){const u=t(h);!s.has(u)||a.has(u)||(a.add(u),o.push({type:"tool_reference",tool_name:r?y(h):h}))}const c=Z(e.content);return{toolResult:{type:"tool_result",tool_use_id:e.toolCallId,content:o.length>0?o:c,is_error:e.isError},siblingContent:o.length===0?[]:typeof c=="string"?[{type:"text",text:c}]:c}}f(pe,"convertToolResult");function de(e,r,s,a=!1,t=new Set,o=c=>c){const c=[],h=new Set;for(let u=0;u<e.length;u++){const g=e[u];if(g.role==="user")if(typeof g.content=="string")g.content.trim().length>0&&c.push({role:"user",content:k(g.content)});else{const l=g.content.map(n=>n.type==="text"?{type:"text",text:k(n.text)}:{type:"image",source:{type:"base64",media_type:n.mimeType,data:n.data}}).filter(n=>n.type==="text"?n.text.trim().length>0:!0);if(l.length===0)continue;c.push({role:"user",content:l})}else if(g.role==="assistant"){const p=[];for(const l of g.content)if(l.type==="text"){if(l.text.trim().length===0)continue;p.push({type:"text",text:k(l.text)})}else if(l.type==="thinking"){if(l.redacted){p.push({type:"redacted_thinking",data:l.thinkingSignature});continue}const n=l.thinkingSignature,i=!!n&&n.trim().length>0;if(l.thinking.trim().length===0&&!i)continue;i?p.push({type:"thinking",thinking:k(l.thinking),signature:n}):p.push(a?{type:"thinking",thinking:k(l.thinking),signature:""}:{type:"text",text:k(l.thinking)})}else l.type==="toolCall"&&p.push({type:"tool_use",id:l.id,name:r?y(l.name):l.name,input:l.arguments??{}});if(p.length===0)continue;c.push({role:"assistant",content:p})}else if(g.role==="toolResult"){const p=[],l=[];let n=u;for(;n<e.length&&e[n].role==="toolResult";){const i=pe(e[n],r,t,h,o);p.push(i.toolResult),l.push(...i.siblingContent),n++}u=n-1,c.push({role:"user",content:[...p,...l]})}}if(s&&c.length>0){const u=c[c.length-1];if(u.role==="user")if(Array.isArray(u.content)){const g=u.content[u.content.length-1];g&&(g.type==="text"||g.type==="image"||g.type==="tool_result")&&(g.cache_control=s)}else typeof u.content=="string"&&(u.content=[{type:"text",text:u.content,cache_control:s}])}return c}f(de,"convertMessages");function fe(e,r){return!!r.tools?.length&&!_(e).supportsEagerToolInputStreaming}f(fe,"shouldUseFineGrainedToolStreamingBeta");function M(e,r,s,a,t,o=!1){return e?e.map((c,h)=>{const u=D(c,a),g=c.parameters,p={type:"object",properties:g.properties??{},required:g.required??[]},l=u===!0?{...c.parameters,...p}:p;return{name:r?y(c.name):c.name,description:c.description,...s?{eager_input_streaming:!0}:{},...u===!0?{strict:!0}:{},input_schema:l,...o?{defer_loading:!0}:{},...t&&h===e.length-1?{cache_control:t}:{}}}):[]}f(M,"convertTools");function ge(e,r){switch(e){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:r?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error"};default:throw new Error(`Unhandled stop reason: ${e}`)}}f(ge,"mapStopReason");
@@ -1 +1 @@
1
- var R=Object.defineProperty;var i=(r,a)=>R(r,"name",{value:a,configurable:!0});import{AzureOpenAI as h}from"openai";import{clampThinkingLevel as g}from"../models.js";import{formatProviderError as y,normalizeProviderError as _}from"../utils/error-body.js";import{AssistantMessageEventStream as I}from"../utils/event-stream.js";import{headersToRecord as O}from"../utils/headers.js";import{getProviderEnvValue as m}from"../utils/provider-env.js";import{retryProviderRequest as v}from"../utils/provider-retry.js";import{createGrammarToolInputProperties as d}from"./constrained-sampling.js";import{clampOpenAIPromptCacheKey as w}from"./openai-prompt-cache.js";import{convertResponsesMessages as U,convertResponsesTools as P,processResponsesStream as N}from"./openai-responses-shared.js";import{buildBaseOptions as z}from"./simple-options.js";const S="v1",M=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),b=16;function T(r){const a=new Map;if(!r)return a;for(const e of r.split(",")){const n=e.trim();if(!n)continue;const[s,t]=n.split("=",2);!s||!t||a.set(s.trim(),t.trim())}return a}i(T,"parseDeploymentNameMap");function L(r,a){return a?.azureDeploymentName?a.azureDeploymentName:T(m("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",a?.env)).get(r.id)||r.id}i(L,"resolveDeploymentName");function k(r){return y(_(r),"Azure OpenAI API error")}i(k,"formatAzureOpenAIError");export const stream=i((r,a,e)=>{const n=new I;return(async()=>{const s=L(r,e),t={role:"assistant",content:[],api:"azure-openai-responses",provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{const o=e?.apiKey;if(!o)throw new Error(`No API key for provider: ${r.provider}`);const p=Z(r,o,e),c=d(a.tools,r.compat?.supportsOpenAIGrammarTools??!1);let u=V(r,a,e,s,c);const f=await e?.onPayload?.(u,r);f!==void 0&&(u=f);const A={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:0},{data:E,response:l}=await v(()=>p.responses.create(u,A).withResponse(),{maxRetries:e?.maxRetries,maxRetryDelayMs:e?.maxRetryDelayMs,signal:e?.signal});if(await e?.onResponse?.({status:l.status,headers:O(l.headers)},r),n.push({type:"start",partial:t}),await N(E,t,n,r,{grammarToolInputProperties:c}),e?.signal?.aborted)throw new Error("Request was aborted");if(t.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(t.stopReason==="aborted"||t.stopReason==="error")throw new Error("An unknown error occurred");n.push({type:"done",reason:t.stopReason,message:t}),n.end()}catch(o){for(const p of t.content)delete p.index,delete p.partialJson,delete p.customInput;t.stopReason=e?.signal?.aborted?"aborted":"error",t.errorMessage=k(o),n.push({type:"error",reason:t.stopReason,error:t}),n.end()}})(),n},"stream"),streamSimple=i((r,a,e)=>{const n=e?.apiKey;if(!n)throw new Error(`No API key for provider: ${r.provider}`);const s=z(r,a,e,n),t=e?.reasoning?g(r,e.reasoning):void 0;return stream(r,a,{...s,reasoningEffort:t==="off"?void 0:t})},"streamSimple");function D(r){const a=r.trim().replace(/\/+$/,"");let e;try{e=new URL(a)}catch{throw new Error(`Invalid Azure OpenAI base URL: ${r}`)}const n=e.hostname.endsWith(".openai.azure.com")||e.hostname.endsWith(".cognitiveservices.azure.com")||e.hostname.endsWith(".ai.azure.com"),s=e.pathname.replace(/\/+$/,"");return n&&(s===""||s==="/"||s==="/openai"||s==="/openai/v1/responses")&&(e.pathname="/openai/v1",e.search=""),e.toString().replace(/\/+$/,"")}i(D,"normalizeAzureBaseUrl");function B(r){return`https://${r}.openai.azure.com/openai/v1`}i(B,"buildDefaultBaseUrl");function x(r,a){const e=a?.azureApiVersion||m("AZURE_OPENAI_API_VERSION",a?.env)||S,n=a?.azureBaseUrl?.trim()||m("AZURE_OPENAI_BASE_URL",a?.env)?.trim()||void 0,s=a?.azureResourceName||m("AZURE_OPENAI_RESOURCE_NAME",a?.env);let t=n;if(!t&&s&&(t=B(s)),!t&&r.baseUrl&&(t=r.baseUrl),!t)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:D(t),apiVersion:e}}i(x,"resolveAzureConfig");function Z(r,a,e){const n={...r.headers};e?.headers&&Object.assign(n,e.headers);const{baseUrl:s,apiVersion:t}=x(r,e);return new h({apiKey:a,apiVersion:t,dangerouslyAllowBrowser:!0,fetch:e?.fetch,defaultHeaders:n,baseURL:s})}i(Z,"createClient");function V(r,a,e,n,s=d(a.tools,r.compat?.supportsOpenAIGrammarTools??!1)){const t=U(r,a,M,{grammarToolInputProperties:s}),o={model:n,input:t,stream:!0,prompt_cache_key:w(e?.sessionId),store:!1};if(e?.maxTokens&&(o.max_output_tokens=Math.max(e.maxTokens,b)),e?.temperature!==void 0&&(o.temperature=e?.temperature),a.tools&&a.tools.length>0&&(o.tools=P(a.tools,{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1})),r.reasoning)if(e?.reasoningEffort||e?.reasoningSummary){const p=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:"medium";o.reasoning={effort:p,summary:e?.reasoningSummary||"auto"},o.include=["reasoning.encrypted_content"]}else r.thinkingLevelMap?.off!==null&&(o.reasoning={effort:r.thinkingLevelMap?.off??"none"});return o}i(V,"buildParams");
1
+ var R=Object.defineProperty;var i=(r,a)=>R(r,"name",{value:a,configurable:!0});import{AzureOpenAI as h}from"openai";import{clampThinkingLevel as g}from"../models.js";import{formatProviderError as y,normalizeProviderError as _}from"../utils/error-body.js";import{AssistantMessageEventStream as I}from"../utils/event-stream.js";import{headersToRecord as v}from"../utils/headers.js";import{getProviderEnvValue as m}from"../utils/provider-env.js";import{retryProviderRequest as O}from"../utils/provider-retry.js";import{createGrammarToolInputProperties as d}from"./constrained-sampling.js";import{clampOpenAIPromptCacheKey as U}from"./openai-prompt-cache.js";import{convertResponsesMessages as P,convertResponsesTools as w,processResponsesStream as N}from"./openai-responses-shared.js";import{buildBaseOptions as z}from"./simple-options.js";const S="v1",M=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),b=16;function T(r){const a=new Map;if(!r)return a;for(const e of r.split(",")){const n=e.trim();if(!n)continue;const[s,t]=n.split("=",2);!s||!t||a.set(s.trim(),t.trim())}return a}i(T,"parseDeploymentNameMap");function L(r,a){return a?.azureDeploymentName?a.azureDeploymentName:T(m("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",a?.env)).get(r.id)||r.id}i(L,"resolveDeploymentName");function k(r){return y(_(r),"Azure OpenAI API error")}i(k,"formatAzureOpenAIError");export const stream=i((r,a,e)=>{const n=new I;return(async()=>{const s=L(r,e),t={role:"assistant",content:[],api:"azure-openai-responses",provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const o=e?.apiKey;if(!o)throw new Error(`No API key for provider: ${r.provider}`);const p=Z(r,o,e),c=d(a.tools,r.compat?.supportsOpenAIGrammarTools??!1);let u=V(r,a,e,s,c);const f=await e?.onPayload?.(u,r);f!==void 0&&(u=f);const A={...e?.signal?{signal:e.signal}:{},...e?.timeoutMs!==void 0?{timeout:e.timeoutMs}:{},maxRetries:0},{data:E,response:l}=await O(()=>p.responses.create(u,A).withResponse(),{maxRetries:e?.maxRetries,maxRetryDelayMs:e?.maxRetryDelayMs,signal:e?.signal});if(await e?.onResponse?.({status:l.status,headers:v(l.headers)},r),n.push({type:"start",partial:t}),await N(E,t,n,r,{grammarToolInputProperties:c}),e?.signal?.aborted)throw new Error("Request was aborted");if(t.stopReason==="aborted"||t.stopReason==="error")throw new Error("An unknown error occurred");n.push({type:"done",reason:t.stopReason,message:t}),n.end()}catch(o){for(const p of t.content)delete p.index,delete p.partialJson,delete p.customInput;t.stopReason=e?.signal?.aborted?"aborted":"error",t.errorMessage=k(o),n.push({type:"error",reason:t.stopReason,error:t}),n.end()}})(),n},"stream"),streamSimple=i((r,a,e)=>{const n=e?.apiKey;if(!n)throw new Error(`No API key for provider: ${r.provider}`);const s=z(r,a,e,n),t=e?.reasoning?g(r,e.reasoning):void 0;return stream(r,a,{...s,reasoningEffort:t==="off"?void 0:t})},"streamSimple");function D(r){const a=r.trim().replace(/\/+$/,"");let e;try{e=new URL(a)}catch{throw new Error(`Invalid Azure OpenAI base URL: ${r}`)}const n=e.hostname.endsWith(".openai.azure.com")||e.hostname.endsWith(".cognitiveservices.azure.com")||e.hostname.endsWith(".ai.azure.com"),s=e.pathname.replace(/\/+$/,"");return n&&(s===""||s==="/"||s==="/openai"||s==="/openai/v1/responses")&&(e.pathname="/openai/v1",e.search=""),e.toString().replace(/\/+$/,"")}i(D,"normalizeAzureBaseUrl");function B(r){return`https://${r}.openai.azure.com/openai/v1`}i(B,"buildDefaultBaseUrl");function x(r,a){const e=a?.azureApiVersion||m("AZURE_OPENAI_API_VERSION",a?.env)||S,n=a?.azureBaseUrl?.trim()||m("AZURE_OPENAI_BASE_URL",a?.env)?.trim()||void 0,s=a?.azureResourceName||m("AZURE_OPENAI_RESOURCE_NAME",a?.env);let t=n;if(!t&&s&&(t=B(s)),!t&&r.baseUrl&&(t=r.baseUrl),!t)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:D(t),apiVersion:e}}i(x,"resolveAzureConfig");function Z(r,a,e){const n={...r.headers};e?.headers&&Object.assign(n,e.headers);const{baseUrl:s,apiVersion:t}=x(r,e);return new h({apiKey:a,apiVersion:t,dangerouslyAllowBrowser:!0,defaultHeaders:n,baseURL:s})}i(Z,"createClient");function V(r,a,e,n,s=d(a.tools,r.compat?.supportsOpenAIGrammarTools??!1)){const t=P(r,a,M,{grammarToolInputProperties:s}),o={model:n,input:t,stream:!0,prompt_cache_key:U(e?.sessionId),store:!1};if(e?.maxTokens&&(o.max_output_tokens=Math.max(e.maxTokens,b)),e?.temperature!==void 0&&(o.temperature=e?.temperature),a.tools&&a.tools.length>0&&(o.tools=w(a.tools,{supportsStrictMode:r.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:r.compat?.supportsOpenAIGrammarTools??!1})),r.reasoning)if(e?.reasoningEffort||e?.reasoningSummary){const p=e?.reasoningEffort?r.thinkingLevelMap?.[e.reasoningEffort]??e.reasoningEffort:"medium";o.reasoning={effort:p,summary:e?.reasoningSummary||"auto"},o.include=["reasoning.encrypted_content"]}else r.thinkingLevelMap?.off!==null&&(o.reasoning={effort:r.thinkingLevelMap?.off??"none"});return o}i(V,"buildParams");
@@ -1 +1 @@
1
- var j=Object.defineProperty;var c=(e,n)=>j(e,"name",{value:n,configurable:!0});import{BedrockRuntimeClient as X,BedrockRuntimeServiceException as G,StopReason as E,CachePointType as P,CacheTTL as D,ConversationRole as x,ConverseStreamCommand as V,ImageFormat as S,ToolResultStatus as R}from"@aws-sdk/client-bedrock-runtime";import{NodeHttpHandler as W}from"@smithy/node-http-handler";import{HttpProxyAgent as Y}from"http-proxy-agent";import{HttpsProxyAgent as Q}from"https-proxy-agent";import{calculateCost as Z}from"../models.js";import{normalizeProviderError as ee}from"../utils/error-body.js";import{AssistantMessageEventStream as te}from"../utils/event-stream.js";import{providerHeadersToRecord as ne}from"../utils/headers.js";import{parseStreamingJson as H}from"../utils/json-parse.js";import{resolveHttpProxyUrlForTarget as re}from"../utils/node-http-proxy.js";import{getProviderEnvValue as f}from"../utils/provider-env.js";import{sanitizeSurrogates as _}from"../utils/sanitize-unicode.js";import{resolveJsonSchemaStrictSampling as oe}from"./constrained-sampling.js";import{adjustMaxTokensForThinking as ae,buildBaseOptions as se,clampMaxTokensToContext as ie,clampReasoning as ce}from"./simple-options.js";import{transformMessages as ue}from"./transform-messages.js";const B="<empty>";export const stream=c((e,n,t={})=>{const o=new te;return(async()=>{const r={role:"assistant",content:[],api:"bedrock-converse-stream",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()},a=r.content,u=t.profile||t.env?.AWS_PROFILE,s={profile:u||f("AWS_PROFILE",t.env)},i=K(t),d=!!f("AWS_PROFILE"),g=q(e.baseUrl),w=Ae(e.baseUrl,i,d);w&&(s.endpoint=e.baseUrl);const y=f("AWS_BEDROCK_SKIP_AUTH",t.env)==="1",A=t.bearerToken||t.apiKey||f("AWS_BEARER_TOKEN_BEDROCK",t.env)||void 0,F=A!==void 0&&!y;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun)){const h=e.id.match(/^arn:aws(?:-[a-z0-9-]+)?:bedrock:([a-z0-9-]+):/);h?s.region=h[1]:i?s.region=i:g&&w?s.region=g:d||(s.region="us-east-1"),y&&(s.credentials={accessKeyId:"dummy-access-key",secretAccessKey:"dummy-secret-key"});const p=ve(t.env);!y&&p&&!u&&(s.credentials=p);const m=re(e.baseUrl,t.env);m?s.requestHandler=new W({httpAgent:new Y(m),httpsAgent:new Q(m)}):f("AWS_BEDROCK_FORCE_HTTP1",t.env)==="1"&&(s.requestHandler=new W)}else s.region=i||(g&&w?g:void 0)||"us-east-1";F&&(s.token={token:A},s.authSchemePreference=["httpBearerAuth"]);try{const h=new X(s),p=ne(t.headers);p&&he(h,p);const m=Ce(t.cacheRetention,t.env),U=t.maxTokens??(C(e)?e.maxTokens:void 0);let b={modelId:e.id,messages:_e(n,e,m,t.env),system:we(n.systemPrompt,e,m,t.env),inferenceConfig:{...U!==void 0&&{maxTokens:U},...t.temperature!==void 0&&{temperature:t.temperature}},toolConfig:Be(n.tools,t.toolChoice,e.compat?.supportsStrictMode??!1),additionalModelRequestFields:Oe(e,t),...t.requestMetadata!==void 0&&{requestMetadata:t.requestMetadata}};const O=await t?.onPayload?.(b,e);O!==void 0&&(b=O);const $=new V(b),k=await h.send($,{abortSignal:t.signal});if(k.$metadata.httpStatusCode!==void 0){const l={};k.$metadata.requestId&&(l["x-amzn-requestid"]=k.$metadata.requestId),await t?.onResponse?.({status:k.$metadata.httpStatusCode,headers:l},e)}for await(const l of k.stream)if(l.messageStart){if(l.messageStart.role!==x.ASSISTANT)throw new Error("Unexpected assistant message start but got user message start instead");o.push({type:"start",partial:r})}else if(l.contentBlockStart)me(l.contentBlockStart,a,r,o);else if(l.contentBlockDelta)ke(l.contentBlockDelta,a,r,o);else if(l.contentBlockStop)xe(l.contentBlockStop,a,r,o);else if(l.messageStop){r.rawStopReason=l.messageStop.stopReason;const{stopReason:J,errorMessage:M}=Ie(l.messageStop.stopReason);r.stopReason=J,M&&(r.errorMessage=M)}else if(l.metadata)Ee(l.metadata,e,r);else{if(l.internalServerException)throw l.internalServerException;if(l.modelStreamErrorException)throw l.modelStreamErrorException;if(l.validationException)throw l.validationException;if(l.throttlingException)throw l.throttlingException;if(l.serviceUnavailableException)throw l.serviceUnavailableException}if(t.signal?.aborted)throw new Error("Request was aborted");if(r.stopReason==="pending")throw new Error("Bedrock stream ended without a stop reason");if(r.stopReason==="error"||r.stopReason==="aborted")throw new Error(r.errorMessage||"An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(h){for(const p of r.content)delete p.index,delete p.partialJson;r.stopReason=t.signal?.aborted?"aborted":"error",r.errorMessage=ge(h),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},"stream");const de={InternalServerException:"Internal server error",ModelStreamErrorException:"Model stream error",ValidationException:"Validation error",ThrottlingException:"Throttling error",ServiceUnavailableException:"Service unavailable"},le="https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html";function ge(e){const n=ee(e),t=!n.messageCarriesBody&&n.status!==void 0&&n.body!==void 0?`${n.status}: ${n.body}`:n.message,o=/data retention mode/i.test(t)?` See ${le} for supported data retention modes.`:"";return e instanceof G?`${de[e.name]??e.name}: ${t}${o}`:`${t}${o}`}c(ge,"formatBedrockError");const fe=new Set(["authorization","host"]);function pe(e){const n=e.toLowerCase();return n.startsWith("x-amz-")||fe.has(n)}c(pe,"isReservedHeader");function he(e,n){const t=c(o=>async r=>{const a=r.request;if(a&&typeof a=="object"&&"headers"in a){const u=a.headers;for(const[s,i]of Object.entries(n))pe(s)||(u[s]=i)}return o(r)},"middleware");e.middlewareStack.add(t,{step:"build",name:"pi-ai-custom-headers",priority:"low"})}c(he,"addCustomHeadersMiddleware");export const streamSimple=c((e,n,t)=>{const o=se(e,n,t,void 0);if(!t?.reasoning)return stream(e,n,{...o,reasoning:void 0});if(C(e)){if(v(e.id,e.name))return stream(e,n,{...o,reasoning:t.reasoning,thinkingBudgets:t.thinkingBudgets});const r=ae(o.maxTokens,e.maxTokens,t.reasoning,t.thinkingBudgets),a=ie(e,n,r.maxTokens);return stream(e,n,{...o,maxTokens:a,reasoning:t.reasoning,thinkingBudgets:{...t.thinkingBudgets||{},[ce(t.reasoning)]:Math.min(r.thinkingBudget,Math.max(0,a-1024))}})}return stream(e,n,{...o,reasoning:t.reasoning,thinkingBudgets:t.thinkingBudgets})},"streamSimple");function me(e,n,t,o){const r=e.contentBlockIndex,a=e.start;if(a?.toolUse){const u={type:"toolCall",id:a.toolUse.toolUseId||"",name:a.toolUse.name||"",arguments:{},partialJson:"",index:r};t.content.push(u),o.push({type:"toolcall_start",contentIndex:n.length-1,partial:t})}}c(me,"handleContentBlockStart");function ke(e,n,t,o){const r=e.contentBlockIndex,a=e.delta;let u=n.findIndex(i=>i.index===r),s=n[u];if(a?.text!==void 0){if(!s){const i={type:"text",text:"",index:r};t.content.push(i),u=n.length-1,s=n[u],o.push({type:"text_start",contentIndex:u,partial:t})}s.type==="text"&&(s.text+=a.text,o.push({type:"text_delta",contentIndex:u,delta:a.text,partial:t}))}else if(a?.toolUse&&s?.type==="toolCall")s.partialJson=(s.partialJson||"")+(a.toolUse.input||""),s.arguments=H(s.partialJson),o.push({type:"toolcall_delta",contentIndex:u,delta:a.toolUse.input||"",partial:t});else if(a?.reasoningContent){let i=s,d=u;if(!i){const g={type:"thinking",thinking:"",thinkingSignature:"",index:r};t.content.push(g),d=n.length-1,i=n[d],o.push({type:"thinking_start",contentIndex:d,partial:t})}i?.type==="thinking"&&(a.reasoningContent.text&&(i.thinking+=a.reasoningContent.text,o.push({type:"thinking_delta",contentIndex:d,delta:a.reasoningContent.text,partial:t})),a.reasoningContent.signature&&(i.thinkingSignature=(i.thinkingSignature||"")+a.reasoningContent.signature))}}c(ke,"handleContentBlockDelta");function Ee(e,n,t){e.usage&&(t.usage.input=e.usage.inputTokens||0,t.usage.output=e.usage.outputTokens||0,t.usage.cacheRead=e.usage.cacheReadInputTokens||0,t.usage.cacheWrite=e.usage.cacheWriteInputTokens||0,t.usage.totalTokens=e.usage.totalTokens||t.usage.input+t.usage.output,Z(n,t.usage))}c(Ee,"handleMetadata");function xe(e,n,t,o){const r=n.findIndex(u=>u.index===e.contentBlockIndex),a=n[r];if(a)switch(delete a.index,a.type){case"text":o.push({type:"text_end",contentIndex:r,content:a.text,partial:t});break;case"thinking":o.push({type:"thinking_end",contentIndex:r,content:a.thinking,partial:t});break;case"toolCall":a.arguments=H(a.partialJson),delete a.partialJson,o.push({type:"toolcall_end",contentIndex:r,toolCall:a,partial:t});break}}c(xe,"handleContentBlockStop");function I(e,n){return(n?[e,n]:[e]).flatMap(o=>{const r=o.toLowerCase();return[r,r.replace(/[\s_.:]+/g,"-")]})}c(I,"getModelMatchCandidates");function v(e,n){return I(e,n).some(o=>o.includes("opus-4-6")||o.includes("opus-4-7")||o.includes("opus-4-8")||o.includes("opus-5")||o.includes("sonnet-4-6")||o.includes("sonnet-5")||o.includes("fable-5"))}c(v,"supportsAdaptiveThinking");function Se(e){return I(e.id,e.name).some(t=>t.includes("opus-4-7")||t.includes("opus-4-8")||t.includes("opus-5")||t.includes("sonnet-5")||t.includes("fable-5"))}c(Se,"supportsNativeXhighEffort");function Re(e,n){if(n==="xhigh"&&Se(e))return"xhigh";const t=n?e.thinkingLevelMap?.[n]:void 0;if(typeof t=="string")return t;switch(n){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}c(Re,"mapThinkingLevelToEffort");function Ce(e,n){return e||(f("PI_CACHE_RETENTION",n)==="long"?"long":"short")}c(Ce,"resolveCacheRetention");function C(e){const n=e.id.toLowerCase(),t=e.name?.toLowerCase()??"";return n.includes("anthropic.claude")||n.includes("anthropic/claude")||t.includes("anthropic.claude")||t.includes("anthropic/claude")||t.includes("claude")}c(C,"isAnthropicClaudeModel");function L(e,n){const t=I(e.id,e.name);return t.some(r=>r.includes("claude"))?!!(t.some(r=>r.includes("fable-5")||r.includes("opus-5")||r.includes("sonnet-5"))||t.some(r=>r.includes("-4-"))||t.some(r=>r.includes("claude-3-7-sonnet"))||t.some(r=>r.includes("claude-3-5-haiku"))):f("AWS_BEDROCK_FORCE_CACHE",n)==="1"}c(L,"supportsPromptCaching");function Te(e){return C(e)}c(Te,"supportsThinkingSignature");function we(e,n,t,o){if(!e)return;const r=[{text:_(e)}];return t!=="none"&&L(n,o)&&r.push({cachePoint:{type:P.DEFAULT,...t==="long"?{ttl:D.ONE_HOUR}:{}}}),r}c(we,"buildSystemPrompt");function ye(e){const n=e.replace(/[^a-zA-Z0-9_-]/g,"_");return n.length>64?n.slice(0,64):n}c(ye,"normalizeToolCallId");function T(e){const n=_(e);return n.trim().length===0?void 0:{text:n}}c(T,"createNonBlankTextBlock");function be(e){return T(e)??{text:B}}c(be,"createRequiredTextBlock");function N(e){const n=[];for(const t of e)if(t.type==="image")n.push({image:z(t.mimeType,t.data)});else{const o=T(t.text);o&&n.push(o)}return n.length===0&&n.push({text:B}),n}c(N,"convertToolResultContent");function _e(e,n,t,o){const r=[],a=ue(e.messages,n,ye);for(let u=0;u<a.length;u++){const s=a[u];switch(s.role){case"user":{const i=[];if(typeof s.content=="string")i.push(be(s.content));else{for(const d of s.content)switch(d.type){case"text":{const g=T(d.text);g&&i.push(g);break}case"image":i.push({image:z(d.mimeType,d.data)});break;default:continue}i.length===0&&i.push({text:B})}r.push({role:x.USER,content:i});break}case"assistant":{if(s.content.length===0)continue;const i=[];for(const d of s.content)switch(d.type){case"text":{const g=T(d.text);if(!g)continue;i.push(g);break}case"toolCall":i.push({toolUse:{toolUseId:d.id,name:d.name,input:d.arguments}});break;case"thinking":{const g=_(d.thinking);if(g.trim().length===0)continue;Te(n)?!d.thinkingSignature||d.thinkingSignature.trim().length===0?i.push({text:g}):i.push({reasoningContent:{reasoningText:{text:g,signature:d.thinkingSignature}}}):i.push({reasoningContent:{reasoningText:{text:g}}});break}default:continue}if(i.length===0)continue;r.push({role:x.ASSISTANT,content:i});break}case"toolResult":{const i=[];i.push({toolResult:{toolUseId:s.toolCallId,content:N(s.content),status:s.isError?R.ERROR:R.SUCCESS}});let d=u+1;for(;d<a.length&&a[d].role==="toolResult";){const g=a[d];i.push({toolResult:{toolUseId:g.toolCallId,content:N(g.content),status:g.isError?R.ERROR:R.SUCCESS}}),d++}u=d-1,r.push({role:x.USER,content:i});break}default:continue}}if(t!=="none"&&L(n,o)&&r.length>0){const u=r[r.length-1];u.role===x.USER&&u.content&&u.content.push({cachePoint:{type:P.DEFAULT,...t==="long"?{ttl:D.ONE_HOUR}:{}}})}return r}c(_e,"convertMessages");function Be(e,n,t){if(!e?.length||n==="none")return;const o=e.map(a=>{const u=oe(a,t);return{toolSpec:{name:a.name,description:a.description,inputSchema:{json:a.parameters},...u===!0?{strict:!0}:{}}}});let r;switch(n){case"auto":r={auto:{}};break;case"any":r={any:{}};break;default:n?.type==="tool"&&(r={tool:{name:n.name}})}return{tools:o,toolChoice:r}}c(Be,"convertToolConfig");function Ie(e){switch(e){case E.END_TURN:case E.STOP_SEQUENCE:return{stopReason:"stop"};case E.MAX_TOKENS:case E.MODEL_CONTEXT_WINDOW_EXCEEDED:return{stopReason:"length"};case E.TOOL_USE:return{stopReason:"toolUse"};default:return e?{stopReason:"error",errorMessage:`Provider stopped with: ${e}`}:{stopReason:"error"}}}c(Ie,"mapStopReason");function K(e){return e.region||f("AWS_REGION",e.env)||f("AWS_DEFAULT_REGION",e.env)||void 0}c(K,"getConfiguredBedrockRegion");function ve(e){const n=f("AWS_ACCESS_KEY_ID",e),t=f("AWS_SECRET_ACCESS_KEY",e);if(!n||!t)return;const o=f("AWS_SESSION_TOKEN",e);return{accessKeyId:n,secretAccessKey:t,...o?{sessionToken:o}:{}}}c(ve,"getConfiguredBedrockCredentials");function q(e){if(e)try{const{hostname:n}=new URL(e);return n.toLowerCase().match(/^bedrock-runtime(?:-fips)?\.([a-z0-9-]+)\.amazonaws\.com(?:\.cn)?$/)?.[1]}catch{return}}c(q,"getStandardBedrockEndpointRegion");function Ae(e,n,t){return q(e)?!n&&!t:!0}c(Ae,"shouldUseExplicitBedrockEndpoint");function Ue(e,n){if(K(n)?.toLowerCase().startsWith("us-gov-"))return!0;const o=e.id.toLowerCase();return o.startsWith("us-gov.")||o.startsWith("arn:aws-us-gov:")}c(Ue,"isGovCloudBedrockTarget");function Oe(e,n){if(!(!n.reasoning||!e.reasoning)&&C(e)){const t=Ue(e,n)?void 0:n.thinkingDisplay??"summarized",o=v(e.id,e.name)?{thinking:{type:"adaptive",...t!==void 0?{display:t}:{}},output_config:{effort:Re(e,n.reasoning)}}:(()=>{const r={minimal:1024,low:2048,medium:8192,high:16384,xhigh:16384,max:16384},a=n.reasoning==="xhigh"||n.reasoning==="max"?"high":n.reasoning;return{thinking:{type:"enabled",budget_tokens:n.thinkingBudgets?.[a]??r[n.reasoning],...t!==void 0?{display:t}:{}}}})();return!v(e.id,e.name)&&(n.interleavedThinking??!0)&&(o.anthropic_beta=["interleaved-thinking-2025-05-14"]),o}}c(Oe,"buildAdditionalModelRequestFields");function z(e,n){let t;switch(e){case"image/jpeg":case"image/jpg":t=S.JPEG;break;case"image/png":t=S.PNG;break;case"image/gif":t=S.GIF;break;case"image/webp":t=S.WEBP;break;default:throw new Error(`Unknown image type: ${e}`)}const o=atob(n),r=new Uint8Array(o.length);for(let a=0;a<o.length;a++)r[a]=o.charCodeAt(a);return{source:{bytes:r},format:t}}c(z,"createImageBlock");
1
+ var J=Object.defineProperty;var c=(e,n)=>J(e,"name",{value:n,configurable:!0});import{BedrockRuntimeClient as j,BedrockRuntimeServiceException as X,StopReason as E,CachePointType as O,CacheTTL as D,ConversationRole as x,ConverseStreamCommand as G,ImageFormat as S,ToolResultStatus as R}from"@aws-sdk/client-bedrock-runtime";import{NodeHttpHandler as P}from"@smithy/node-http-handler";import{HttpProxyAgent as V}from"http-proxy-agent";import{HttpsProxyAgent as Y}from"https-proxy-agent";import{calculateCost as Q}from"../models.js";import{normalizeProviderError as Z}from"../utils/error-body.js";import{AssistantMessageEventStream as ee}from"../utils/event-stream.js";import{providerHeadersToRecord as te}from"../utils/headers.js";import{parseStreamingJson as H}from"../utils/json-parse.js";import{resolveHttpProxyUrlForTarget as ne}from"../utils/node-http-proxy.js";import{getProviderEnvValue as f}from"../utils/provider-env.js";import{sanitizeSurrogates as b}from"../utils/sanitize-unicode.js";import{resolveJsonSchemaStrictSampling as re}from"./constrained-sampling.js";import{adjustMaxTokensForThinking as ae,buildBaseOptions as oe,clampMaxTokensToContext as se,clampReasoning as ie}from"./simple-options.js";import{transformMessages as ce}from"./transform-messages.js";const _="<empty>";export const stream=c((e,n,t={})=>{const a=new ee;return(async()=>{const r={role:"assistant",content:[],api:"bedrock-converse-stream",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()},o=r.content,s={profile:t.profile||f("AWS_PROFILE",t.env)},d=L(t),i=!!f("AWS_PROFILE"),u=K(e.baseUrl),g=ve(e.baseUrl,d,i);g&&(s.endpoint=e.baseUrl);const y=f("AWS_BEDROCK_SKIP_AUTH",t.env)==="1",v=t.bearerToken||t.apiKey||f("AWS_BEARER_TOKEN_BEDROCK",t.env)||void 0,z=v!==void 0&&!y;if(typeof process<"u"&&(process.versions?.node||process.versions?.bun)){const h=e.id.match(/^arn:aws(?:-[a-z0-9-]+)?:bedrock:([a-z0-9-]+):/);h?s.region=h[1]:d?s.region=d:u&&g?s.region=u:i||(s.region="us-east-1"),y&&(s.credentials={accessKeyId:"dummy-access-key",secretAccessKey:"dummy-secret-key"});const p=Ie(t.env);!y&&p&&(s.credentials=p);const m=ne(e.baseUrl,t.env);m?s.requestHandler=new P({httpAgent:new V(m),httpsAgent:new Y(m)}):f("AWS_BEDROCK_FORCE_HTTP1",t.env)==="1"&&(s.requestHandler=new P)}else s.region=d||(u&&g?u:void 0)||"us-east-1";z&&(s.token={token:v},s.authSchemePreference=["httpBearerAuth"]);try{const h=new j(s),p=te(t.headers);p&&pe(h,p);const m=Re(t.cacheRetention,t.env),A=t.maxTokens??(C(e)?e.maxTokens:void 0);let w={modelId:e.id,messages:be(n,e,m,t.env),system:Te(n.systemPrompt,e,m,t.env),inferenceConfig:{...A!==void 0&&{maxTokens:A},...t.temperature!==void 0&&{temperature:t.temperature}},toolConfig:_e(n.tools,t.toolChoice,e.compat?.supportsStrictMode??!1),additionalModelRequestFields:Ue(e,t),...t.requestMetadata!==void 0&&{requestMetadata:t.requestMetadata}};const U=await t?.onPayload?.(w,e);U!==void 0&&(w=U);const F=new G(w),k=await h.send(F,{abortSignal:t.signal});if(k.$metadata.httpStatusCode!==void 0){const l={};k.$metadata.requestId&&(l["x-amzn-requestid"]=k.$metadata.requestId),await t?.onResponse?.({status:k.$metadata.httpStatusCode,headers:l},e)}for await(const l of k.stream)if(l.messageStart){if(l.messageStart.role!==x.ASSISTANT)throw new Error("Unexpected assistant message start but got user message start instead");a.push({type:"start",partial:r})}else if(l.contentBlockStart)he(l.contentBlockStart,o,r,a);else if(l.contentBlockDelta)me(l.contentBlockDelta,o,r,a);else if(l.contentBlockStop)Ee(l.contentBlockStop,o,r,a);else if(l.messageStop){const{stopReason:$,errorMessage:M}=Be(l.messageStop.stopReason);r.stopReason=$,M&&(r.errorMessage=M)}else if(l.metadata)ke(l.metadata,e,r);else{if(l.internalServerException)throw l.internalServerException;if(l.modelStreamErrorException)throw l.modelStreamErrorException;if(l.validationException)throw l.validationException;if(l.throttlingException)throw l.throttlingException;if(l.serviceUnavailableException)throw l.serviceUnavailableException}if(t.signal?.aborted)throw new Error("Request was aborted");if(r.stopReason==="error"||r.stopReason==="aborted")throw new Error(r.errorMessage||"An unknown error occurred");a.push({type:"done",reason:r.stopReason,message:r}),a.end()}catch(h){for(const p of r.content)delete p.index,delete p.partialJson;r.stopReason=t.signal?.aborted?"aborted":"error",r.errorMessage=le(h),a.push({type:"error",reason:r.stopReason,error:r}),a.end()}})(),a},"stream");const ue={InternalServerException:"Internal server error",ModelStreamErrorException:"Model stream error",ValidationException:"Validation error",ThrottlingException:"Throttling error",ServiceUnavailableException:"Service unavailable"},de="https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html";function le(e){const n=Z(e),t=!n.messageCarriesBody&&n.status!==void 0&&n.body!==void 0?`${n.status}: ${n.body}`:n.message,a=/data retention mode/i.test(t)?` See ${de} for supported data retention modes.`:"";return e instanceof X?`${ue[e.name]??e.name}: ${t}${a}`:`${t}${a}`}c(le,"formatBedrockError");const ge=new Set(["authorization","host"]);function fe(e){const n=e.toLowerCase();return n.startsWith("x-amz-")||ge.has(n)}c(fe,"isReservedHeader");function pe(e,n){const t=c(a=>async r=>{const o=r.request;if(o&&typeof o=="object"&&"headers"in o){const s=o.headers;for(const[d,i]of Object.entries(n))fe(d)||(s[d]=i)}return a(r)},"middleware");e.middlewareStack.add(t,{step:"build",name:"pi-ai-custom-headers",priority:"low"})}c(pe,"addCustomHeadersMiddleware");export const streamSimple=c((e,n,t)=>{const a=oe(e,n,t,void 0);if(!t?.reasoning)return stream(e,n,{...a,reasoning:void 0});if(C(e)){if(I(e.id,e.name))return stream(e,n,{...a,reasoning:t.reasoning,thinkingBudgets:t.thinkingBudgets});const r=ae(a.maxTokens,e.maxTokens,t.reasoning,t.thinkingBudgets),o=se(e,n,r.maxTokens);return stream(e,n,{...a,maxTokens:o,reasoning:t.reasoning,thinkingBudgets:{...t.thinkingBudgets||{},[ie(t.reasoning)]:Math.min(r.thinkingBudget,Math.max(0,o-1024))}})}return stream(e,n,{...a,reasoning:t.reasoning,thinkingBudgets:t.thinkingBudgets})},"streamSimple");function he(e,n,t,a){const r=e.contentBlockIndex,o=e.start;if(o?.toolUse){const s={type:"toolCall",id:o.toolUse.toolUseId||"",name:o.toolUse.name||"",arguments:{},partialJson:"",index:r};t.content.push(s),a.push({type:"toolcall_start",contentIndex:n.length-1,partial:t})}}c(he,"handleContentBlockStart");function me(e,n,t,a){const r=e.contentBlockIndex,o=e.delta;let s=n.findIndex(i=>i.index===r),d=n[s];if(o?.text!==void 0){if(!d){const i={type:"text",text:"",index:r};t.content.push(i),s=n.length-1,d=n[s],a.push({type:"text_start",contentIndex:s,partial:t})}d.type==="text"&&(d.text+=o.text,a.push({type:"text_delta",contentIndex:s,delta:o.text,partial:t}))}else if(o?.toolUse&&d?.type==="toolCall")d.partialJson=(d.partialJson||"")+(o.toolUse.input||""),d.arguments=H(d.partialJson),a.push({type:"toolcall_delta",contentIndex:s,delta:o.toolUse.input||"",partial:t});else if(o?.reasoningContent){let i=d,u=s;if(!i){const g={type:"thinking",thinking:"",thinkingSignature:"",index:r};t.content.push(g),u=n.length-1,i=n[u],a.push({type:"thinking_start",contentIndex:u,partial:t})}i?.type==="thinking"&&(o.reasoningContent.text&&(i.thinking+=o.reasoningContent.text,a.push({type:"thinking_delta",contentIndex:u,delta:o.reasoningContent.text,partial:t})),o.reasoningContent.signature&&(i.thinkingSignature=(i.thinkingSignature||"")+o.reasoningContent.signature))}}c(me,"handleContentBlockDelta");function ke(e,n,t){e.usage&&(t.usage.input=e.usage.inputTokens||0,t.usage.output=e.usage.outputTokens||0,t.usage.cacheRead=e.usage.cacheReadInputTokens||0,t.usage.cacheWrite=e.usage.cacheWriteInputTokens||0,t.usage.totalTokens=e.usage.totalTokens||t.usage.input+t.usage.output,Q(n,t.usage))}c(ke,"handleMetadata");function Ee(e,n,t,a){const r=n.findIndex(s=>s.index===e.contentBlockIndex),o=n[r];if(o)switch(delete o.index,o.type){case"text":a.push({type:"text_end",contentIndex:r,content:o.text,partial:t});break;case"thinking":a.push({type:"thinking_end",contentIndex:r,content:o.thinking,partial:t});break;case"toolCall":o.arguments=H(o.partialJson),delete o.partialJson,a.push({type:"toolcall_end",contentIndex:r,toolCall:o,partial:t});break}}c(Ee,"handleContentBlockStop");function B(e,n){return(n?[e,n]:[e]).flatMap(a=>{const r=a.toLowerCase();return[r,r.replace(/[\s_.:]+/g,"-")]})}c(B,"getModelMatchCandidates");function I(e,n){return B(e,n).some(a=>a.includes("opus-4-6")||a.includes("opus-4-7")||a.includes("opus-4-8")||a.includes("opus-5")||a.includes("sonnet-4-6")||a.includes("sonnet-5")||a.includes("fable-5"))}c(I,"supportsAdaptiveThinking");function xe(e){return B(e.id,e.name).some(t=>t.includes("opus-4-7")||t.includes("opus-4-8")||t.includes("opus-5")||t.includes("sonnet-5")||t.includes("fable-5"))}c(xe,"supportsNativeXhighEffort");function Se(e,n){if(n==="xhigh"&&xe(e))return"xhigh";const t=n?e.thinkingLevelMap?.[n]:void 0;if(typeof t=="string")return t;switch(n){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}c(Se,"mapThinkingLevelToEffort");function Re(e,n){return e||(f("PI_CACHE_RETENTION",n)==="long"?"long":"short")}c(Re,"resolveCacheRetention");function C(e){const n=e.id.toLowerCase(),t=e.name?.toLowerCase()??"";return n.includes("anthropic.claude")||n.includes("anthropic/claude")||t.includes("anthropic.claude")||t.includes("anthropic/claude")||t.includes("claude")}c(C,"isAnthropicClaudeModel");function N(e,n){const t=B(e.id,e.name);return t.some(r=>r.includes("claude"))?!!(t.some(r=>r.includes("fable-5")||r.includes("opus-5")||r.includes("sonnet-5"))||t.some(r=>r.includes("-4-"))||t.some(r=>r.includes("claude-3-7-sonnet"))||t.some(r=>r.includes("claude-3-5-haiku"))):f("AWS_BEDROCK_FORCE_CACHE",n)==="1"}c(N,"supportsPromptCaching");function Ce(e){return C(e)}c(Ce,"supportsThinkingSignature");function Te(e,n,t,a){if(!e)return;const r=[{text:b(e)}];return t!=="none"&&N(n,a)&&r.push({cachePoint:{type:O.DEFAULT,...t==="long"?{ttl:D.ONE_HOUR}:{}}}),r}c(Te,"buildSystemPrompt");function ye(e){const n=e.replace(/[^a-zA-Z0-9_-]/g,"_");return n.length>64?n.slice(0,64):n}c(ye,"normalizeToolCallId");function T(e){const n=b(e);return n.trim().length===0?void 0:{text:n}}c(T,"createNonBlankTextBlock");function we(e){return T(e)??{text:_}}c(we,"createRequiredTextBlock");function W(e){const n=[];for(const t of e)if(t.type==="image")n.push({image:q(t.mimeType,t.data)});else{const a=T(t.text);a&&n.push(a)}return n.length===0&&n.push({text:_}),n}c(W,"convertToolResultContent");function be(e,n,t,a){const r=[],o=ce(e.messages,n,ye);for(let s=0;s<o.length;s++){const d=o[s];switch(d.role){case"user":{const i=[];if(typeof d.content=="string")i.push(we(d.content));else{for(const u of d.content)switch(u.type){case"text":{const g=T(u.text);g&&i.push(g);break}case"image":i.push({image:q(u.mimeType,u.data)});break;default:continue}i.length===0&&i.push({text:_})}r.push({role:x.USER,content:i});break}case"assistant":{if(d.content.length===0)continue;const i=[];for(const u of d.content)switch(u.type){case"text":{const g=T(u.text);if(!g)continue;i.push(g);break}case"toolCall":i.push({toolUse:{toolUseId:u.id,name:u.name,input:u.arguments}});break;case"thinking":{const g=b(u.thinking);if(g.trim().length===0)continue;Ce(n)?!u.thinkingSignature||u.thinkingSignature.trim().length===0?i.push({text:g}):i.push({reasoningContent:{reasoningText:{text:g,signature:u.thinkingSignature}}}):i.push({reasoningContent:{reasoningText:{text:g}}});break}default:continue}if(i.length===0)continue;r.push({role:x.ASSISTANT,content:i});break}case"toolResult":{const i=[];i.push({toolResult:{toolUseId:d.toolCallId,content:W(d.content),status:d.isError?R.ERROR:R.SUCCESS}});let u=s+1;for(;u<o.length&&o[u].role==="toolResult";){const g=o[u];i.push({toolResult:{toolUseId:g.toolCallId,content:W(g.content),status:g.isError?R.ERROR:R.SUCCESS}}),u++}s=u-1,r.push({role:x.USER,content:i});break}default:continue}}if(t!=="none"&&N(n,a)&&r.length>0){const s=r[r.length-1];s.role===x.USER&&s.content&&s.content.push({cachePoint:{type:O.DEFAULT,...t==="long"?{ttl:D.ONE_HOUR}:{}}})}return r}c(be,"convertMessages");function _e(e,n,t){if(!e?.length||n==="none")return;const a=e.map(o=>{const s=re(o,t);return{toolSpec:{name:o.name,description:o.description,inputSchema:{json:o.parameters},...s===!0?{strict:!0}:{}}}});let r;switch(n){case"auto":r={auto:{}};break;case"any":r={any:{}};break;default:n?.type==="tool"&&(r={tool:{name:n.name}})}return{tools:a,toolChoice:r}}c(_e,"convertToolConfig");function Be(e){switch(e){case E.END_TURN:case E.STOP_SEQUENCE:return{stopReason:"stop"};case E.MAX_TOKENS:case E.MODEL_CONTEXT_WINDOW_EXCEEDED:return{stopReason:"length"};case E.TOOL_USE:return{stopReason:"toolUse"};default:return e?{stopReason:"error",errorMessage:e}:{stopReason:"error"}}}c(Be,"mapStopReason");function L(e){return e.region||f("AWS_REGION",e.env)||f("AWS_DEFAULT_REGION",e.env)||void 0}c(L,"getConfiguredBedrockRegion");function Ie(e){const n=f("AWS_ACCESS_KEY_ID",e),t=f("AWS_SECRET_ACCESS_KEY",e);if(!n||!t)return;const a=f("AWS_SESSION_TOKEN",e);return{accessKeyId:n,secretAccessKey:t,...a?{sessionToken:a}:{}}}c(Ie,"getConfiguredBedrockCredentials");function K(e){if(e)try{const{hostname:n}=new URL(e);return n.toLowerCase().match(/^bedrock-runtime(?:-fips)?\.([a-z0-9-]+)\.amazonaws\.com(?:\.cn)?$/)?.[1]}catch{return}}c(K,"getStandardBedrockEndpointRegion");function ve(e,n,t){return K(e)?!n&&!t:!0}c(ve,"shouldUseExplicitBedrockEndpoint");function Ae(e,n){if(L(n)?.toLowerCase().startsWith("us-gov-"))return!0;const a=e.id.toLowerCase();return a.startsWith("us-gov.")||a.startsWith("arn:aws-us-gov:")}c(Ae,"isGovCloudBedrockTarget");function Ue(e,n){if(!(!n.reasoning||!e.reasoning)&&C(e)){const t=Ae(e,n)?void 0:n.thinkingDisplay??"summarized",a=I(e.id,e.name)?{thinking:{type:"adaptive",...t!==void 0?{display:t}:{}},output_config:{effort:Se(e,n.reasoning)}}:(()=>{const r={minimal:1024,low:2048,medium:8192,high:16384,xhigh:16384,max:16384},o=n.reasoning==="xhigh"||n.reasoning==="max"?"high":n.reasoning;return{thinking:{type:"enabled",budget_tokens:n.thinkingBudgets?.[o]??r[n.reasoning],...t!==void 0?{display:t}:{}}}})();return!I(e.id,e.name)&&(n.interleavedThinking??!0)&&(a.anthropic_beta=["interleaved-thinking-2025-05-14"]),a}}c(Ue,"buildAdditionalModelRequestFields");function q(e,n){let t;switch(e){case"image/jpeg":case"image/jpg":t=S.JPEG;break;case"image/png":t=S.PNG;break;case"image/gif":t=S.GIF;break;case"image/webp":t=S.WEBP;break;default:throw new Error(`Unknown image type: ${e}`)}const a=atob(n),r=new Uint8Array(a.length);for(let o=0;o<a.length;o++)r[o]=a.charCodeAt(o);return{source:{bytes:r},format:t}}c(q,"createImageBlock");
@@ -1 +1 @@
1
- var M=Object.defineProperty;var g=(t,a)=>M(t,"name",{value:a,configurable:!0});import{GoogleGenAI as v}from"@google/genai";import{calculateCost as T,clampThinkingLevel as R}from"../models.js";import{formatProviderError as S,normalizeProviderError as L}from"../utils/error-body.js";import{AssistantMessageEventStream as _}from"../utils/event-stream.js";import{providerHeadersToRecord as G}from"../utils/headers.js";import{sanitizeSurrogates as P}from"../utils/sanitize-unicode.js";import{convertMessages as E,convertTools as A,isThinkingPart as O,mapStopReason as N,resolveGoogleFunctionCallingMode as H,retainThoughtSignature as I,supportsGoogleStrictToolSampling as W}from"./google-shared.js";import{buildBaseOptions as $}from"./simple-options.js";let B=0;export const stream=g((t,a,n)=>{const i=new _;return(async()=>{const e={role:"assistant",content:[],api:"google-generative-ai",provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{if(n?.fetch&&n.fetch!==globalThis.fetch)throw new Error("Custom fetch is not supported by the Google Generative AI adapter");const d=n?.apiKey;if(!d)throw new Error(`No API key for provider: ${t.provider}`);const s=U(t,d,n?.headers);let c=D(t,a,n);const p=await n?.onPayload?.(c,t);p!==void 0&&(c=p);const x=await s.models.generateContentStream(c);i.push({type:"start",partial:e});let o=null;const w=e.content,u=g(()=>w.length-1,"blockIndex");for await(const l of x){e.responseId||=l.responseId;const f=l.candidates?.[0];if(f?.content?.parts)for(const r of f.content.parts){if(r.text!==void 0){const h=O(r);(!o||h&&o.type!=="thinking"||!h&&o.type!=="text")&&(o&&(o.type==="text"?i.push({type:"text_end",contentIndex:w.length-1,content:o.text,partial:e}):i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:e})),h?(o={type:"thinking",thinking:"",thinkingSignature:void 0},e.content.push(o),i.push({type:"thinking_start",contentIndex:u(),partial:e})):(o={type:"text",text:""},e.content.push(o),i.push({type:"text_start",contentIndex:u(),partial:e}))),o.type==="thinking"?(o.thinking+=r.text,o.thinkingSignature=I(o.thinkingSignature,r.thoughtSignature),i.push({type:"thinking_delta",contentIndex:u(),delta:r.text,partial:e})):(o.text+=r.text,o.textSignature=I(o.textSignature,r.thoughtSignature),i.push({type:"text_delta",contentIndex:u(),delta:r.text,partial:e}))}if(r.functionCall){o&&(o.type==="text"?i.push({type:"text_end",contentIndex:u(),content:o.text,partial:e}):i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:e}),o=null);const h=r.functionCall.id,m={type:"toolCall",id:!h||e.content.some(C=>C.type==="toolCall"&&C.id===h)?`${r.functionCall.name}_${Date.now()}_${++B}`:h,name:r.functionCall.name||"",arguments:r.functionCall.args??{},...r.thoughtSignature&&{thoughtSignature:r.thoughtSignature}};e.content.push(m),i.push({type:"toolcall_start",contentIndex:u(),partial:e}),i.push({type:"toolcall_delta",contentIndex:u(),delta:JSON.stringify(m.arguments),partial:e}),i.push({type:"toolcall_end",contentIndex:u(),toolCall:m,partial:e})}}f?.finishReason&&(e.rawStopReason=f.finishReason,e.stopReason=N(f.finishReason),e.content.some(r=>r.type==="toolCall")&&(e.stopReason="toolUse")),l.usageMetadata&&(e.usage={input:(l.usageMetadata.promptTokenCount||0)-(l.usageMetadata.cachedContentTokenCount||0),output:(l.usageMetadata.candidatesTokenCount||0)+(l.usageMetadata.thoughtsTokenCount||0),cacheRead:l.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:l.usageMetadata.thoughtsTokenCount||0,totalTokens:l.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},T(t,e.usage))}if(o&&(o.type==="text"?i.push({type:"text_end",contentIndex:u(),content:o.text,partial:e}):i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:e})),n?.signal?.aborted)throw new Error("Request was aborted");if(e.stopReason==="pending")throw new Error("Google stream ended without a finish reason");if(e.stopReason==="aborted"||e.stopReason==="error"){const l=e.rawStopReason?`Provider stopped with: ${e.rawStopReason}`:"An unknown error occurred";throw new Error(l)}i.push({type:"done",reason:e.stopReason,message:e}),i.end()}catch(d){for(const s of e.content)"index"in s&&delete s.index;e.stopReason=n?.signal?.aborted?"aborted":"error",e.errorMessage=S(L(d)),i.push({type:"error",reason:e.stopReason,error:e}),i.end()}})(),i},"stream"),streamSimple=g((t,a,n)=>{const i=n?.apiKey;if(!i)throw new Error(`No API key for provider: ${t.provider}`);const e=$(t,a,n,i);if(!n?.reasoning)return stream(t,a,{...e,thinking:{enabled:!1}});const d=R(t,n.reasoning),s=d==="off"?"high":d,c=t;return y(c)||b(c)||k(c)?stream(t,a,{...e,thinking:{enabled:!0,level:j(s,c)}}):stream(t,a,{...e,thinking:{enabled:!0,budgetTokens:q(c,s,n.thinkingBudgets)}})},"streamSimple");function U(t,a,n){const i={};t.baseUrl&&(i.baseUrl=t.baseUrl,i.apiVersion="");const e=G({...t.headers,...n});return e&&(i.headers=e),new v({apiKey:a,httpOptions:Object.keys(i).length>0?i:void 0})}g(U,"createClient");function D(t,a,n={}){const i=E(t,a),e={};n.temperature!==void 0&&(e.temperature=n.temperature),n.maxTokens!==void 0&&(e.maxOutputTokens=n.maxTokens);const d=a.tools?.length?H(a.tools,n.toolChoice,W(t.id)):void 0,s={...Object.keys(e).length>0&&e,...a.systemPrompt&&{systemInstruction:P(a.systemPrompt)},...a.tools&&a.tools.length>0&&{tools:A(a.tools)},...d!==void 0&&{toolConfig:{functionCallingConfig:{mode:d}}}};if(n.thinking?.enabled&&t.reasoning){const p={includeThoughts:!0};n.thinking.level!==void 0?p.thinkingLevel=n.thinking.level:n.thinking.budgetTokens!==void 0&&(p.thinkingBudget=n.thinking.budgetTokens),s.thinkingConfig=p}else t.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=K(t));if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");s.abortSignal=n.signal}return{model:t.id,contents:i,config:s}}g(D,"buildParams");function k(t){return/gemma-?4/.test(t.id.toLowerCase())}g(k,"isGemma4Model");function y(t){return/gemini-3(?:\.\d+)?-pro/.test(t.id.toLowerCase())}g(y,"isGemini3ProModel");function b(t){const a=t.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(a)||a==="gemini-flash-latest"||a==="gemini-flash-lite-latest"}g(b,"isGemini3FlashModel");function K(t){return y(t)?{thinkingLevel:"LOW"}:b(t)?{thinkingLevel:"MINIMAL"}:k(t)?{thinkingLevel:"MINIMAL"}:{thinkingBudget:0}}g(K,"getDisabledThinkingConfig");function j(t,a){if(y(a))switch(t){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(k(a))switch(t){case"minimal":case"low":return"MINIMAL";case"medium":case"high":return"HIGH"}switch(t){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}g(j,"getThinkingLevel");function q(t,a,n){return n?.[a]!==void 0?n[a]:t.id.includes("2.5-pro")?{minimal:128,low:2048,medium:8192,high:32768}[a]:t.id.includes("2.5-flash-lite")?{minimal:512,low:2048,medium:8192,high:24576}[a]:t.id.includes("2.5-flash")?{minimal:128,low:2048,medium:8192,high:24576}[a]:-1}g(q,"getGoogleBudget");
1
+ var M=Object.defineProperty;var l=(t,a)=>M(t,"name",{value:a,configurable:!0});import{GoogleGenAI as T}from"@google/genai";import{calculateCost as v,clampThinkingLevel as S}from"../models.js";import{formatProviderError as R,normalizeProviderError as L}from"../utils/error-body.js";import{AssistantMessageEventStream as _}from"../utils/event-stream.js";import{providerHeadersToRecord as G}from"../utils/headers.js";import{sanitizeSurrogates as P}from"../utils/sanitize-unicode.js";import{convertMessages as O,convertTools as A,isThinkingPart as E,mapStopReason as N,resolveGoogleFunctionCallingMode as H,retainThoughtSignature as x,supportsGoogleStrictToolSampling as W}from"./google-shared.js";import{buildBaseOptions as B}from"./simple-options.js";let U=0;export const stream=l((t,a,n)=>{const i=new _;return(async()=>{const e={role:"assistant",content:[],api:"google-generative-ai",provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const g=n?.apiKey;if(!g)throw new Error(`No API key for provider: ${t.provider}`);const s=$(t,g,n?.headers);let c=D(t,a,n);const p=await n?.onPayload?.(c,t);p!==void 0&&(c=p);const w=await s.models.generateContentStream(c);i.push({type:"start",partial:e});let o=null;const C=e.content,u=l(()=>C.length-1,"blockIndex");for await(const d of w){e.responseId||=d.responseId;const f=d.candidates?.[0];if(f?.content?.parts)for(const r of f.content.parts){if(r.text!==void 0){const h=E(r);(!o||h&&o.type!=="thinking"||!h&&o.type!=="text")&&(o&&(o.type==="text"?i.push({type:"text_end",contentIndex:C.length-1,content:o.text,partial:e}):i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:e})),h?(o={type:"thinking",thinking:"",thinkingSignature:void 0},e.content.push(o),i.push({type:"thinking_start",contentIndex:u(),partial:e})):(o={type:"text",text:""},e.content.push(o),i.push({type:"text_start",contentIndex:u(),partial:e}))),o.type==="thinking"?(o.thinking+=r.text,o.thinkingSignature=x(o.thinkingSignature,r.thoughtSignature),i.push({type:"thinking_delta",contentIndex:u(),delta:r.text,partial:e})):(o.text+=r.text,o.textSignature=x(o.textSignature,r.thoughtSignature),i.push({type:"text_delta",contentIndex:u(),delta:r.text,partial:e}))}if(r.functionCall){o&&(o.type==="text"?i.push({type:"text_end",contentIndex:u(),content:o.text,partial:e}):i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:e}),o=null);const h=r.functionCall.id,m={type:"toolCall",id:!h||e.content.some(I=>I.type==="toolCall"&&I.id===h)?`${r.functionCall.name}_${Date.now()}_${++U}`:h,name:r.functionCall.name||"",arguments:r.functionCall.args??{},...r.thoughtSignature&&{thoughtSignature:r.thoughtSignature}};e.content.push(m),i.push({type:"toolcall_start",contentIndex:u(),partial:e}),i.push({type:"toolcall_delta",contentIndex:u(),delta:JSON.stringify(m.arguments),partial:e}),i.push({type:"toolcall_end",contentIndex:u(),toolCall:m,partial:e})}}f?.finishReason&&(e.stopReason=N(f.finishReason),e.content.some(r=>r.type==="toolCall")&&(e.stopReason="toolUse")),d.usageMetadata&&(e.usage={input:(d.usageMetadata.promptTokenCount||0)-(d.usageMetadata.cachedContentTokenCount||0),output:(d.usageMetadata.candidatesTokenCount||0)+(d.usageMetadata.thoughtsTokenCount||0),cacheRead:d.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:d.usageMetadata.thoughtsTokenCount||0,totalTokens:d.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},v(t,e.usage))}if(o&&(o.type==="text"?i.push({type:"text_end",contentIndex:u(),content:o.text,partial:e}):i.push({type:"thinking_end",contentIndex:u(),content:o.thinking,partial:e})),n?.signal?.aborted)throw new Error("Request was aborted");if(e.stopReason==="aborted"||e.stopReason==="error")throw new Error("An unknown error occurred");i.push({type:"done",reason:e.stopReason,message:e}),i.end()}catch(g){for(const s of e.content)"index"in s&&delete s.index;e.stopReason=n?.signal?.aborted?"aborted":"error",e.errorMessage=R(L(g)),i.push({type:"error",reason:e.stopReason,error:e}),i.end()}})(),i},"stream"),streamSimple=l((t,a,n)=>{const i=n?.apiKey;if(!i)throw new Error(`No API key for provider: ${t.provider}`);const e=B(t,a,n,i);if(!n?.reasoning)return stream(t,a,{...e,thinking:{enabled:!1}});const g=S(t,n.reasoning),s=g==="off"?"high":g,c=t;return y(c)||b(c)||k(c)?stream(t,a,{...e,thinking:{enabled:!0,level:j(s,c)}}):stream(t,a,{...e,thinking:{enabled:!0,budgetTokens:q(c,s,n.thinkingBudgets)}})},"streamSimple");function $(t,a,n){const i={};t.baseUrl&&(i.baseUrl=t.baseUrl,i.apiVersion="");const e=G({...t.headers,...n});return e&&(i.headers=e),new T({apiKey:a,httpOptions:Object.keys(i).length>0?i:void 0})}l($,"createClient");function D(t,a,n={}){const i=O(t,a),e={};n.temperature!==void 0&&(e.temperature=n.temperature),n.maxTokens!==void 0&&(e.maxOutputTokens=n.maxTokens);const g=a.tools?.length?H(a.tools,n.toolChoice,W(t.id)):void 0,s={...Object.keys(e).length>0&&e,...a.systemPrompt&&{systemInstruction:P(a.systemPrompt)},...a.tools&&a.tools.length>0&&{tools:A(a.tools)},...g!==void 0&&{toolConfig:{functionCallingConfig:{mode:g}}}};if(n.thinking?.enabled&&t.reasoning){const p={includeThoughts:!0};n.thinking.level!==void 0?p.thinkingLevel=n.thinking.level:n.thinking.budgetTokens!==void 0&&(p.thinkingBudget=n.thinking.budgetTokens),s.thinkingConfig=p}else t.reasoning&&n.thinking&&!n.thinking.enabled&&(s.thinkingConfig=K(t));if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");s.abortSignal=n.signal}return{model:t.id,contents:i,config:s}}l(D,"buildParams");function k(t){return/gemma-?4/.test(t.id.toLowerCase())}l(k,"isGemma4Model");function y(t){return/gemini-3(?:\.\d+)?-pro/.test(t.id.toLowerCase())}l(y,"isGemini3ProModel");function b(t){const a=t.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(a)||a==="gemini-flash-latest"||a==="gemini-flash-lite-latest"}l(b,"isGemini3FlashModel");function K(t){return y(t)?{thinkingLevel:"LOW"}:b(t)?{thinkingLevel:"MINIMAL"}:k(t)?{thinkingLevel:"MINIMAL"}:{thinkingBudget:0}}l(K,"getDisabledThinkingConfig");function j(t,a){if(y(a))switch(t){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}if(k(a))switch(t){case"minimal":case"low":return"MINIMAL";case"medium":case"high":return"HIGH"}switch(t){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}l(j,"getThinkingLevel");function q(t,a,n){return n?.[a]!==void 0?n[a]:t.id.includes("2.5-pro")?{minimal:128,low:2048,medium:8192,high:32768}[a]:t.id.includes("2.5-flash-lite")?{minimal:512,low:2048,medium:8192,high:24576}[a]:t.id.includes("2.5-flash")?{minimal:128,low:2048,medium:8192,high:24576}[a]:-1}l(q,"getGoogleBudget");
@@ -1 +1 @@
1
- var v=Object.defineProperty;var a=(e,t)=>v(e,"name",{value:t,configurable:!0});import{GoogleGenAI as L,ResourceScope as R,ThinkingLevel as h}from"@google/genai";import{calculateCost as _,clampThinkingLevel as M}from"../models.js";import{formatProviderError as S,normalizeProviderError as G}from"../utils/error-body.js";import{AssistantMessageEventStream as A}from"../utils/event-stream.js";import{providerHeadersToRecord as P}from"../utils/headers.js";import{getProviderEnvValue as k}from"../utils/provider-env.js";import{sanitizeSurrogates as N}from"../utils/sanitize-unicode.js";import{convertMessages as U,convertTools as D,isThinkingPart as V,mapStopReason as H,resolveGoogleFunctionCallingMode as K,retainThoughtSignature as x,supportsGoogleStrictToolSampling as W}from"./google-shared.js";import{buildBaseOptions as j}from"./simple-options.js";const E="v1",$="gcp-vertex-credentials",B={THINKING_LEVEL_UNSPECIFIED:h.THINKING_LEVEL_UNSPECIFIED,MINIMAL:h.MINIMAL,LOW:h.LOW,MEDIUM:h.MEDIUM,HIGH:h.HIGH};let F=0;export const stream=a((e,t,i)=>{const o=new A;return(async()=>{const n={role:"assistant",content:[],api:"google-vertex",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{if(i?.fetch&&i.fetch!==globalThis.fetch)throw new Error("Custom fetch is not supported by the Google Vertex adapter");const l=Y(i),u=l?q(e,l,i?.headers):J(e,ee(i),te(i),i?.headers,i?.env);let m=ne(e,t,i);const p=await i?.onPayload?.(m,e);p!==void 0&&(m=p);const b=await u.models.generateContentStream(m);o.push({type:"start",partial:n});let r=null;const y=n.content,c=a(()=>y.length-1,"blockIndex");for await(const d of b){n.responseId||=d.responseId;const f=d.candidates?.[0];if(f?.content?.parts)for(const s of f.content.parts){if(s.text!==void 0){const g=V(s);(!r||g&&r.type!=="thinking"||!g&&r.type!=="text")&&(r&&(r.type==="text"?o.push({type:"text_end",contentIndex:y.length-1,content:r.text,partial:n}):o.push({type:"thinking_end",contentIndex:c(),content:r.thinking,partial:n})),g?(r={type:"thinking",thinking:"",thinkingSignature:void 0},n.content.push(r),o.push({type:"thinking_start",contentIndex:c(),partial:n})):(r={type:"text",text:""},n.content.push(r),o.push({type:"text_start",contentIndex:c(),partial:n}))),r.type==="thinking"?(r.thinking+=s.text,r.thinkingSignature=x(r.thinkingSignature,s.thoughtSignature),o.push({type:"thinking_delta",contentIndex:c(),delta:s.text,partial:n})):(r.text+=s.text,r.textSignature=x(r.textSignature,s.thoughtSignature),o.push({type:"text_delta",contentIndex:c(),delta:s.text,partial:n}))}if(s.functionCall){r&&(r.type==="text"?o.push({type:"text_end",contentIndex:c(),content:r.text,partial:n}):o.push({type:"thinking_end",contentIndex:c(),content:r.thinking,partial:n}),r=null);const g=s.functionCall.id,C={type:"toolCall",id:!g||n.content.some(O=>O.type==="toolCall"&&O.id===g)?`${s.functionCall.name}_${Date.now()}_${++F}`:g,name:s.functionCall.name||"",arguments:s.functionCall.args??{},...s.thoughtSignature&&{thoughtSignature:s.thoughtSignature}};n.content.push(C),o.push({type:"toolcall_start",contentIndex:c(),partial:n}),o.push({type:"toolcall_delta",contentIndex:c(),delta:JSON.stringify(C.arguments),partial:n}),o.push({type:"toolcall_end",contentIndex:c(),toolCall:C,partial:n})}}f?.finishReason&&(n.rawStopReason=f.finishReason,n.stopReason=H(f.finishReason),n.content.some(s=>s.type==="toolCall")&&(n.stopReason="toolUse")),d.usageMetadata&&(n.usage={input:(d.usageMetadata.promptTokenCount||0)-(d.usageMetadata.cachedContentTokenCount||0),output:(d.usageMetadata.candidatesTokenCount||0)+(d.usageMetadata.thoughtsTokenCount||0),cacheRead:d.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:d.usageMetadata.thoughtsTokenCount||0,totalTokens:d.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},_(e,n.usage))}if(r&&(r.type==="text"?o.push({type:"text_end",contentIndex:c(),content:r.text,partial:n}):o.push({type:"thinking_end",contentIndex:c(),content:r.thinking,partial:n})),i?.signal?.aborted)throw new Error("Request was aborted");if(n.stopReason==="pending")throw new Error("Google Vertex stream ended without a finish reason");if(n.stopReason==="aborted"||n.stopReason==="error"){const d=n.rawStopReason?`Provider stopped with: ${n.rawStopReason}`:"An unknown error occurred";throw new Error(d)}o.push({type:"done",reason:n.stopReason,message:n}),o.end()}catch(l){for(const u of n.content)"index"in u&&delete u.index;n.stopReason=i?.signal?.aborted?"aborted":"error",n.errorMessage=S(G(l)),o.push({type:"error",reason:n.stopReason,error:n}),o.end()}})(),o},"stream"),streamSimple=a((e,t,i)=>{const o=j(e,t,i,void 0);if(!i?.reasoning)return stream(e,t,{...o,thinking:{enabled:!1}});const n=M(e,i.reasoning),l=n==="off"?"high":n,u=e;return I(u)||w(u)?stream(e,t,{...o,thinking:{enabled:!0,level:oe(l,u)}}):stream(e,t,{...o,thinking:{enabled:!0,budgetTokens:re(u,l,i.thinkingBudgets)}})},"streamSimple");function J(e,t,i,o,n){const l=Q(n);return new L({vertexai:!0,project:t,location:i,apiVersion:E,...l?{googleAuthOptions:l}:{},httpOptions:T(e,o)})}a(J,"createClient");function q(e,t,i){return new L({vertexai:!0,apiKey:t,apiVersion:E,httpOptions:T(e,i)})}a(q,"createClientWithApiKey");function T(e,t){const i={},o=z(e.baseUrl);o&&(i.baseUrl=o,i.baseUrlResourceScope=R.COLLECTION,X(o)&&(i.apiVersion=""));const n=P({...e.headers,...t});return n&&(i.headers=n),Object.keys(i).length>0?i:void 0}a(T,"buildHttpOptions");function z(e){const t=e.trim();if(!(!t||t.includes("{location}")))return t}a(z,"resolveCustomBaseUrl");function X(e){try{return new URL(e).pathname.split("/").some(i=>/^v\d+(?:beta\d*)?$/.test(i))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}a(X,"baseUrlIncludesApiVersion");function Q(e){const t=k("GOOGLE_APPLICATION_CREDENTIALS",e);return t?{keyFilename:t}:void 0}a(Q,"buildGoogleAuthOptions");function Y(e){const t=e?.apiKey?.trim();if(!(!t||t===$||Z(t)))return t}a(Y,"resolveApiKey");function Z(e){return/^<[^>]+>$/.test(e)}a(Z,"isPlaceholderApiKey");function ee(e){const t=e?.project||k("GOOGLE_CLOUD_PROJECT",e?.env)||k("GCLOUD_PROJECT",e?.env);if(!t)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return t}a(ee,"resolveProject");function te(e){const t=e?.location||k("GOOGLE_CLOUD_LOCATION",e?.env);if(!t)throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return t}a(te,"resolveLocation");function ne(e,t,i={}){const o=U(e,t),n={};i.temperature!==void 0&&(n.temperature=i.temperature),i.maxTokens!==void 0&&(n.maxOutputTokens=i.maxTokens);const l=t.tools?.length?K(t.tools,i.toolChoice,W(e.id)):void 0,u={...Object.keys(n).length>0&&n,...t.systemPrompt&&{systemInstruction:N(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:D(t.tools)},...l!==void 0&&{toolConfig:{functionCallingConfig:{mode:l}}}};if(i.thinking?.enabled&&e.reasoning){const p={includeThoughts:!0};i.thinking.level!==void 0?p.thinkingLevel=B[i.thinking.level]:i.thinking.budgetTokens!==void 0&&(p.thinkingBudget=i.thinking.budgetTokens),u.thinkingConfig=p}else e.reasoning&&i.thinking&&!i.thinking.enabled&&(u.thinkingConfig=ie(e));if(i.signal){if(i.signal.aborted)throw new Error("Request aborted");u.abortSignal=i.signal}return{model:e.id,contents:o,config:u}}a(ne,"buildParams");function I(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}a(I,"isGemini3ProModel");function w(e){const t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t==="gemini-flash-latest"||t==="gemini-flash-lite-latest"}a(w,"isGemini3FlashModel");function ie(e){const t=e;return I(t)?{thinkingLevel:h.LOW}:w(t)?{thinkingLevel:h.MINIMAL}:{thinkingBudget:0}}a(ie,"getDisabledThinkingConfig");function oe(e,t){if(I(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}a(oe,"getGemini3ThinkingLevel");function re(e,t,i){return i?.[t]!==void 0?i[t]:e.id.includes("2.5-pro")?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes("2.5-flash")?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1}a(re,"getGoogleBudget");
1
+ var v=Object.defineProperty;var a=(e,t)=>v(e,"name",{value:t,configurable:!0});import{GoogleGenAI as L,ResourceScope as M,ThinkingLevel as h}from"@google/genai";import{calculateCost as R,clampThinkingLevel as w}from"../models.js";import{formatProviderError as S,normalizeProviderError as G}from"../utils/error-body.js";import{AssistantMessageEventStream as A}from"../utils/event-stream.js";import{providerHeadersToRecord as P}from"../utils/headers.js";import{getProviderEnvValue as k}from"../utils/provider-env.js";import{sanitizeSurrogates as N}from"../utils/sanitize-unicode.js";import{convertMessages as U,convertTools as D,isThinkingPart as H,mapStopReason as V,resolveGoogleFunctionCallingMode as K,retainThoughtSignature as x,supportsGoogleStrictToolSampling as W}from"./google-shared.js";import{buildBaseOptions as j}from"./simple-options.js";const E="v1",B="gcp-vertex-credentials",$={THINKING_LEVEL_UNSPECIFIED:h.THINKING_LEVEL_UNSPECIFIED,MINIMAL:h.MINIMAL,LOW:h.LOW,MEDIUM:h.MEDIUM,HIGH:h.HIGH};let F=0;export const stream=a((e,t,n)=>{const o=new A;return(async()=>{const i={role:"assistant",content:[],api:"google-vertex",provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{const l=Y(n),u=l?q(e,l,n?.headers):J(e,ee(n),te(n),n?.headers,n?.env);let f=ne(e,t,n);const p=await n?.onPayload?.(f,e);p!==void 0&&(f=p);const b=await u.models.generateContentStream(f);o.push({type:"start",partial:i});let r=null;const y=i.content,c=a(()=>y.length-1,"blockIndex");for await(const d of b){i.responseId||=d.responseId;const m=d.candidates?.[0];if(m?.content?.parts)for(const s of m.content.parts){if(s.text!==void 0){const g=H(s);(!r||g&&r.type!=="thinking"||!g&&r.type!=="text")&&(r&&(r.type==="text"?o.push({type:"text_end",contentIndex:y.length-1,content:r.text,partial:i}):o.push({type:"thinking_end",contentIndex:c(),content:r.thinking,partial:i})),g?(r={type:"thinking",thinking:"",thinkingSignature:void 0},i.content.push(r),o.push({type:"thinking_start",contentIndex:c(),partial:i})):(r={type:"text",text:""},i.content.push(r),o.push({type:"text_start",contentIndex:c(),partial:i}))),r.type==="thinking"?(r.thinking+=s.text,r.thinkingSignature=x(r.thinkingSignature,s.thoughtSignature),o.push({type:"thinking_delta",contentIndex:c(),delta:s.text,partial:i})):(r.text+=s.text,r.textSignature=x(r.textSignature,s.thoughtSignature),o.push({type:"text_delta",contentIndex:c(),delta:s.text,partial:i}))}if(s.functionCall){r&&(r.type==="text"?o.push({type:"text_end",contentIndex:c(),content:r.text,partial:i}):o.push({type:"thinking_end",contentIndex:c(),content:r.thinking,partial:i}),r=null);const g=s.functionCall.id,I={type:"toolCall",id:!g||i.content.some(O=>O.type==="toolCall"&&O.id===g)?`${s.functionCall.name}_${Date.now()}_${++F}`:g,name:s.functionCall.name||"",arguments:s.functionCall.args??{},...s.thoughtSignature&&{thoughtSignature:s.thoughtSignature}};i.content.push(I),o.push({type:"toolcall_start",contentIndex:c(),partial:i}),o.push({type:"toolcall_delta",contentIndex:c(),delta:JSON.stringify(I.arguments),partial:i}),o.push({type:"toolcall_end",contentIndex:c(),toolCall:I,partial:i})}}m?.finishReason&&(i.stopReason=V(m.finishReason),i.content.some(s=>s.type==="toolCall")&&(i.stopReason="toolUse")),d.usageMetadata&&(i.usage={input:(d.usageMetadata.promptTokenCount||0)-(d.usageMetadata.cachedContentTokenCount||0),output:(d.usageMetadata.candidatesTokenCount||0)+(d.usageMetadata.thoughtsTokenCount||0),cacheRead:d.usageMetadata.cachedContentTokenCount||0,cacheWrite:0,reasoning:d.usageMetadata.thoughtsTokenCount||0,totalTokens:d.usageMetadata.totalTokenCount||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},R(e,i.usage))}if(r&&(r.type==="text"?o.push({type:"text_end",contentIndex:c(),content:r.text,partial:i}):o.push({type:"thinking_end",contentIndex:c(),content:r.thinking,partial:i})),n?.signal?.aborted)throw new Error("Request was aborted");if(i.stopReason==="aborted"||i.stopReason==="error")throw new Error("An unknown error occurred");o.push({type:"done",reason:i.stopReason,message:i}),o.end()}catch(l){for(const u of i.content)"index"in u&&delete u.index;i.stopReason=n?.signal?.aborted?"aborted":"error",i.errorMessage=S(G(l)),o.push({type:"error",reason:i.stopReason,error:i}),o.end()}})(),o},"stream"),streamSimple=a((e,t,n)=>{const o=j(e,t,n,void 0);if(!n?.reasoning)return stream(e,t,{...o,thinking:{enabled:!1}});const i=w(e,n.reasoning),l=i==="off"?"high":i,u=e;return C(u)||_(u)?stream(e,t,{...o,thinking:{enabled:!0,level:oe(l,u)}}):stream(e,t,{...o,thinking:{enabled:!0,budgetTokens:re(u,l,n.thinkingBudgets)}})},"streamSimple");function J(e,t,n,o,i){const l=Q(i);return new L({vertexai:!0,project:t,location:n,apiVersion:E,...l?{googleAuthOptions:l}:{},httpOptions:T(e,o)})}a(J,"createClient");function q(e,t,n){return new L({vertexai:!0,apiKey:t,apiVersion:E,httpOptions:T(e,n)})}a(q,"createClientWithApiKey");function T(e,t){const n={},o=z(e.baseUrl);o&&(n.baseUrl=o,n.baseUrlResourceScope=M.COLLECTION,X(o)&&(n.apiVersion=""));const i=P({...e.headers,...t});return i&&(n.headers=i),Object.keys(n).length>0?n:void 0}a(T,"buildHttpOptions");function z(e){const t=e.trim();if(!(!t||t.includes("{location}")))return t}a(z,"resolveCustomBaseUrl");function X(e){try{return new URL(e).pathname.split("/").some(n=>/^v\d+(?:beta\d*)?$/.test(n))}catch{return/(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e)}}a(X,"baseUrlIncludesApiVersion");function Q(e){const t=k("GOOGLE_APPLICATION_CREDENTIALS",e);return t?{keyFilename:t}:void 0}a(Q,"buildGoogleAuthOptions");function Y(e){const t=e?.apiKey?.trim();if(!(!t||t===B||Z(t)))return t}a(Y,"resolveApiKey");function Z(e){return/^<[^>]+>$/.test(e)}a(Z,"isPlaceholderApiKey");function ee(e){const t=e?.project||k("GOOGLE_CLOUD_PROJECT",e?.env)||k("GCLOUD_PROJECT",e?.env);if(!t)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");return t}a(ee,"resolveProject");function te(e){const t=e?.location||k("GOOGLE_CLOUD_LOCATION",e?.env);if(!t)throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");return t}a(te,"resolveLocation");function ne(e,t,n={}){const o=U(e,t),i={};n.temperature!==void 0&&(i.temperature=n.temperature),n.maxTokens!==void 0&&(i.maxOutputTokens=n.maxTokens);const l=t.tools?.length?K(t.tools,n.toolChoice,W(e.id)):void 0,u={...Object.keys(i).length>0&&i,...t.systemPrompt&&{systemInstruction:N(t.systemPrompt)},...t.tools&&t.tools.length>0&&{tools:D(t.tools)},...l!==void 0&&{toolConfig:{functionCallingConfig:{mode:l}}}};if(n.thinking?.enabled&&e.reasoning){const p={includeThoughts:!0};n.thinking.level!==void 0?p.thinkingLevel=$[n.thinking.level]:n.thinking.budgetTokens!==void 0&&(p.thinkingBudget=n.thinking.budgetTokens),u.thinkingConfig=p}else e.reasoning&&n.thinking&&!n.thinking.enabled&&(u.thinkingConfig=ie(e));if(n.signal){if(n.signal.aborted)throw new Error("Request aborted");u.abortSignal=n.signal}return{model:e.id,contents:o,config:u}}a(ne,"buildParams");function C(e){return/gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase())}a(C,"isGemini3ProModel");function _(e){const t=e.id.toLowerCase();return/gemini-3(?:\.\d+)?-flash/.test(t)||t==="gemini-flash-latest"||t==="gemini-flash-lite-latest"}a(_,"isGemini3FlashModel");function ie(e){const t=e;return C(t)?{thinkingLevel:h.LOW}:_(t)?{thinkingLevel:h.MINIMAL}:{thinkingBudget:0}}a(ie,"getDisabledThinkingConfig");function oe(e,t){if(C(t))switch(e){case"minimal":case"low":return"LOW";case"medium":case"high":return"HIGH"}switch(e){case"minimal":return"MINIMAL";case"low":return"LOW";case"medium":return"MEDIUM";case"high":return"HIGH"}}a(oe,"getGemini3ThinkingLevel");function re(e,t,n){return n?.[t]!==void 0?n[t]:e.id.includes("2.5-pro")?{minimal:128,low:2048,medium:8192,high:32768}[t]:e.id.includes("2.5-flash")?{minimal:128,low:2048,medium:8192,high:24576}[t]:-1}a(re,"getGoogleBudget");
@@ -1,3 +1,3 @@
1
- var A=Object.defineProperty;var i=(t,e)=>A(t,"name",{value:e,configurable:!0});import{HTTPClient as $,Mistral as P}from"@mistralai/mistralai";import{calculateCost as E,clampThinkingLevel as O}from"../models.js";import{AssistantMessageEventStream as v}from"../utils/event-stream.js";import{shortHash as D}from"../utils/hash.js";import{parseStreamingJson as C}from"../utils/json-parse.js";import{sanitizeSurrogates as y}from"../utils/sanitize-unicode.js";import{resolveJsonSchemaStrictSampling as L}from"./constrained-sampling.js";import{buildBaseOptions as N}from"./simple-options.js";import{transformMessages as B}from"./transform-messages.js";const w=9,U=4e3;export const stream=i((t,e,n)=>{const o=new v;return(async()=>{const r=j(t);try{const p=n?.apiKey;if(!p)throw new Error(`No API key for provider: ${t.provider}`);const f=new P({apiKey:p,serverURL:t.baseUrl,...n?.fetch?{httpClient:new $({fetcher:n.fetch})}:{}}),h=z(),s=B(e.messages,t,x=>h(x));let c=W(t,e,s,n);const a=await n?.onPayload?.(c,t);a!==void 0&&(c=a);const l=await f.chat.stream(c,H(t,n));if(o.push({type:"start",partial:r}),await Z(t,r,o,l),n?.signal?.aborted)throw new Error("Request was aborted");if(r.stopReason==="pending")throw new Error("Mistral stream ended without a finish reason");if(r.stopReason==="aborted"||r.stopReason==="error")throw new Error(r.errorMessage||"An unknown error occurred");o.push({type:"done",reason:r.stopReason,message:r}),o.end()}catch(p){for(const f of r.content)delete f.partialArgs;r.stopReason=n?.signal?.aborted?"aborted":"error",r.errorMessage=K(p),o.push({type:"error",reason:r.stopReason,error:r}),o.end()}})(),o},"stream"),streamSimple=i((t,e,n)=>{const o=n?.apiKey;if(!o)throw new Error(`No API key for provider: ${t.provider}`);const r=N(t,e,n,o),p=n?.reasoning?O(t,n.reasoning):void 0,f=p==="off"?void 0:p,h=t.reasoning&&f!==void 0;return stream(t,e,{...r,promptMode:h&&Q(t)?"reasoning":void 0,reasoningEffort:h&&b(t)?V(t,f):void 0})},"streamSimple");function j(t){return{role:"assistant",content:[],api:t.api,provider:t.provider,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()}}i(j,"createOutput");function z(){const t=new Map,e=new Map;return n=>{const o=t.get(n);if(o)return o;let r=0;for(;;){const p=_(n,r),f=e.get(p);if(!f||f===n)return t.set(n,p),e.set(p,n),p;r++}}}i(z,"createMistralToolCallIdNormalizer");function _(t,e){const n=t.replace(/[^a-zA-Z0-9]/g,"");if(e===0&&n.length===w)return n;const o=n||t,r=e===0?o:`${o}:${e}`;return D(r).replace(/[^a-zA-Z0-9]/g,"").slice(0,w)}i(_,"deriveMistralToolCallId");function K(t){if(t instanceof Error){const e=t,n=typeof e.statusCode=="number"?e.statusCode:void 0,o=typeof e.body=="string"?e.body.trim():void 0;return n!==void 0&&o?`Mistral API error (${n}): ${J(o,U)}`:n!==void 0?`Mistral API error (${n}): ${t.message}`:t.message}return q(t)}i(K,"formatMistralError");function J(t,e){return t.length<=e?t:`${t.slice(0,e)}... [truncated ${t.length-e} chars]`}i(J,"truncateErrorText");function q(t){try{const e=JSON.stringify(t);return e===void 0?String(t):e}catch{return String(t)}}i(q,"safeJsonStringify");function H(t,e){const n={retries:{strategy:"none"}};e?.signal&&(n.signal=e.signal);const o={};return t.headers&&Object.assign(o,t.headers),e?.headers&&Object.assign(o,e.headers),I(e)&&!o["x-affinity"]&&(o["x-affinity"]=e.sessionId),Object.keys(o).length>0&&(n.headers=o),n}i(H,"buildRequestOptions");function W(t,e,n,o){const r={model:t.id,stream:!0,messages:X(n,t.input.includes("image"))};return e.tools?.length&&(r.tools=G(e.tools)),o?.temperature!==void 0&&(r.temperature=o.temperature),o?.maxTokens!==void 0&&(r.maxTokens=o.maxTokens),o?.toolChoice&&(r.toolChoice=ee(o.toolChoice)),o?.promptMode&&(r.promptMode=o.promptMode),o?.reasoningEffort&&(r.reasoningEffort=o.reasoningEffort),I(o)&&(r.promptCacheKey=o.sessionId),e.systemPrompt&&r.messages.unshift({role:"system",content:y(e.systemPrompt)}),r}i(W,"buildChatPayload");function I(t){return t?.cacheRetention!=="none"&&!!t?.sessionId}i(I,"shouldUsePromptCaching");function F(t,e){const n=t,o=n.promptTokensDetails?.cachedTokens??n.prompt_tokens_details?.cached_tokens??n.promptTokenDetails?.cachedTokens??n.prompt_token_details?.cached_tokens??n.numCachedTokens??n.num_cached_tokens??0,r=typeof o=="number"&&Number.isFinite(o)?o:0;return Math.min(e,Math.max(0,r))}i(F,"getMistralCachedPromptTokens");async function Z(t,e,n,o){let r=null;const p=e.content,f=i(()=>p.length-1,"blockIndex"),h=new Map,s=i(c=>{if(c){if(c.type==="text"){n.push({type:"text_end",contentIndex:f(),content:c.text,partial:e});return}c.type==="thinking"&&n.push({type:"thinking_end",contentIndex:f(),content:c.thinking,partial:e})}},"finishCurrentBlock");for await(const c of o){const a=c.data;if(e.responseId||=a.id,a.usage){const d=a.usage.promptTokens||0,g=F(a.usage,d);e.usage.input=Math.max(0,d-g),e.usage.output=a.usage.completionTokens||0,e.usage.cacheRead=g,e.usage.cacheWrite=0,e.usage.totalTokens=a.usage.totalTokens||e.usage.input+e.usage.output+e.usage.cacheRead+e.usage.cacheWrite,E(t,e.usage)}const l=a.choices[0];if(!l)continue;if(l.finishReason){e.rawStopReason=l.finishReason;const d=te(l.finishReason);e.stopReason=d.stopReason,d.errorMessage&&(e.errorMessage=d.errorMessage)}const x=l.delta;if(x.content!==null&&x.content!==void 0){const d=typeof x.content=="string"?[x.content]:x.content;for(const g of d){if(typeof g=="string"){const m=y(g);(!r||r.type!=="text")&&(s(r),r={type:"text",text:""},e.content.push(r),n.push({type:"text_start",contentIndex:f(),partial:e})),r.text+=m,n.push({type:"text_delta",contentIndex:f(),delta:m,partial:e});continue}if(g.type==="thinking"){const m=g.thinking.map(u=>"text"in u?u.text:"").filter(u=>u.length>0).join(""),k=y(m);if(!k)continue;(!r||r.type!=="thinking")&&(s(r),r={type:"thinking",thinking:""},e.content.push(r),n.push({type:"thinking_start",contentIndex:f(),partial:e})),r.thinking+=k,n.push({type:"thinking_delta",contentIndex:f(),delta:k,partial:e});continue}if(g.type==="text"){const m=y(g.text);(!r||r.type!=="text")&&(s(r),r={type:"text",text:""},e.content.push(r),n.push({type:"text_start",contentIndex:f(),partial:e})),r.text+=m,n.push({type:"text_delta",contentIndex:f(),delta:m,partial:e})}}}const S=x.toolCalls||[];for(const d of S){r&&(s(r),r=null);const g=d.id&&d.id!=="null"?d.id:_(`toolcall:${d.index??0}`,0),m=`${g}:${d.index||0}`,k=h.get(m);let u;if(k!==void 0){const T=e.content[k];T?.type==="toolCall"&&(u=T)}u||(u={type:"toolCall",id:g,name:d.function.name,arguments:{},partialArgs:""},e.content.push(u),h.set(m,e.content.length-1),n.push({type:"toolcall_start",contentIndex:e.content.length-1,partial:e}));const M=typeof d.function.arguments=="string"?d.function.arguments:JSON.stringify(d.function.arguments||{});u.partialArgs=(u.partialArgs||"")+M,u.arguments=C(u.partialArgs),n.push({type:"toolcall_delta",contentIndex:h.get(m),delta:M,partial:e})}}s(r);for(const c of h.values()){const a=e.content[c];if(a.type!=="toolCall")continue;const l=a;l.arguments=C(l.partialArgs),delete l.partialArgs,n.push({type:"toolcall_end",contentIndex:c,toolCall:l,partial:e})}}i(Z,"consumeChatStream");function G(t){return t.map(e=>{const n=L(e,!0);return{type:"function",function:{name:e.name,description:e.description,parameters:R(e.parameters),strict:n??!1}}})}i(G,"toFunctionTools");function R(t){if(Array.isArray(t))return t.map(e=>R(e));if(t&&typeof t=="object"){const e={};for(const[n,o]of Object.entries(t))e[n]=R(o);return e}return t}i(R,"stripSymbolKeys");function X(t,e){const n=[];for(const o of t){if(o.role==="user"){if(typeof o.content=="string"){n.push({role:"user",content:y(o.content)});continue}const s=o.content.some(a=>a.type==="image"),c=o.content.filter(a=>a.type==="text"||e).map(a=>a.type==="text"?{type:"text",text:y(a.text)}:{type:"image_url",imageUrl:`data:${a.mimeType};base64,${a.data}`});if(c.length>0){n.push({role:"user",content:c});continue}s&&!e&&n.push({role:"user",content:"(image omitted: model does not support images)"});continue}if(o.role==="assistant"){const s=[],c=[];for(const l of o.content){if(l.type==="text"){l.text.trim().length>0&&s.push({type:"text",text:y(l.text)});continue}if(l.type==="thinking"){l.thinking.trim().length>0&&s.push({type:"thinking",thinking:[{type:"text",text:y(l.thinking)}]});continue}c.push({id:l.id,type:"function",function:{name:l.name,arguments:JSON.stringify(l.arguments||{})}})}const a={role:"assistant"};s.length>0&&(a.content=s),c.length>0&&(a.toolCalls=c),(s.length>0||c.length>0)&&n.push(a);continue}const r=[],p=o.content.filter(s=>s.type==="text").map(s=>s.type==="text"?y(s.text):"").join(`
2
- `),f=o.content.some(s=>s.type==="image"),h=Y(p,f,e,o.isError);r.push({type:"text",text:h});for(const s of o.content)e&&s.type==="image"&&r.push({type:"image_url",imageUrl:`data:${s.mimeType};base64,${s.data}`});n.push({role:"tool",toolCallId:o.toolCallId,name:o.toolName,content:r})}return n}i(X,"toChatMessages");function Y(t,e,n,o){const r=t.trim(),p=o?"[tool error] ":"";return r.length>0?`${p}${r}${e&&!n?`
3
- [tool image omitted: model does not support images]`:""}`:e?n?o?"[tool error] (see attached image)":"(see attached image)":o?"[tool error] (image omitted: model does not support images)":"(image omitted: model does not support images)":o?"[tool error] (no tool output)":"(no tool output)"}i(Y,"buildToolResultText");function b(t){return t.id==="mistral-small-2603"||t.id==="mistral-small-latest"||t.id==="mistral-medium-3.5"}i(b,"usesReasoningEffort");function Q(t){return t.reasoning&&!b(t)}i(Q,"usesPromptModeReasoning");function V(t,e){return t.thinkingLevelMap?.[e]??"high"}i(V,"mapReasoningEffort");function ee(t){if(t)return t==="auto"||t==="none"||t==="any"||t==="required"?t:{type:"function",function:{name:t.function.name}}}i(ee,"mapToolChoice");function te(t){if(t===null)return{stopReason:"stop"};switch(t){case"stop":return{stopReason:"stop"};case"length":case"model_length":return{stopReason:"length"};case"tool_calls":return{stopReason:"toolUse"};case"error":return{stopReason:"error",errorMessage:"Provider stopped with: error"};default:return{stopReason:"error",errorMessage:`Provider stopped with: ${t}`}}}i(te,"mapChatStopReason");
1
+ var S=Object.defineProperty;var i=(e,t)=>S(e,"name",{value:t,configurable:!0});import{Mistral as $}from"@mistralai/mistralai";import{calculateCost as E,clampThinkingLevel as O}from"../models.js";import{AssistantMessageEventStream as P}from"../utils/event-stream.js";import{shortHash as D}from"../utils/hash.js";import{parseStreamingJson as R}from"../utils/json-parse.js";import{sanitizeSurrogates as y}from"../utils/sanitize-unicode.js";import{resolveJsonSchemaStrictSampling as L}from"./constrained-sampling.js";import{buildBaseOptions as N}from"./simple-options.js";import{transformMessages as v}from"./transform-messages.js";const _=9,B=4e3;export const stream=i((e,t,o)=>{const n=new P;return(async()=>{const r=U(e);try{const u=o?.apiKey;if(!u)throw new Error(`No API key for provider: ${e.provider}`);const l=new $({apiKey:u,serverURL:e.baseUrl}),m=j(),s=v(t.messages,e,x=>m(x));let c=W(e,t,s,o);const a=await o?.onPayload?.(c,e);a!==void 0&&(c=a);const f=await l.chat.stream(c,q(e,o));if(n.push({type:"start",partial:r}),await F(e,r,n,f),o?.signal?.aborted)throw new Error("Request was aborted");if(r.stopReason==="aborted"||r.stopReason==="error")throw new Error("An unknown error occurred");n.push({type:"done",reason:r.stopReason,message:r}),n.end()}catch(u){for(const l of r.content)delete l.partialArgs;r.stopReason=o?.signal?.aborted?"aborted":"error",r.errorMessage=z(u),n.push({type:"error",reason:r.stopReason,error:r}),n.end()}})(),n},"stream"),streamSimple=i((e,t,o)=>{const n=o?.apiKey;if(!n)throw new Error(`No API key for provider: ${e.provider}`);const r=N(e,t,o,n),u=o?.reasoning?O(e,o.reasoning):void 0,l=u==="off"?void 0:u,m=e.reasoning&&l!==void 0;return stream(e,t,{...r,promptMode:m&&Y(e)?"reasoning":void 0,reasoningEffort:m&&w(e)?Q(e,l):void 0})},"streamSimple");function U(e){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()}}i(U,"createOutput");function j(){const e=new Map,t=new Map;return o=>{const n=e.get(o);if(n)return n;let r=0;for(;;){const u=I(o,r),l=t.get(u);if(!l||l===o)return e.set(o,u),t.set(u,o),u;r++}}}i(j,"createMistralToolCallIdNormalizer");function I(e,t){const o=e.replace(/[^a-zA-Z0-9]/g,"");if(t===0&&o.length===_)return o;const n=o||e,r=t===0?n:`${n}:${t}`;return D(r).replace(/[^a-zA-Z0-9]/g,"").slice(0,_)}i(I,"deriveMistralToolCallId");function z(e){if(e instanceof Error){const t=e,o=typeof t.statusCode=="number"?t.statusCode:void 0,n=typeof t.body=="string"?t.body.trim():void 0;return o!==void 0&&n?`Mistral API error (${o}): ${K(n,B)}`:o!==void 0?`Mistral API error (${o}): ${e.message}`:e.message}return J(e)}i(z,"formatMistralError");function K(e,t){return e.length<=t?e:`${e.slice(0,t)}... [truncated ${e.length-t} chars]`}i(K,"truncateErrorText");function J(e){try{const t=JSON.stringify(e);return t===void 0?String(e):t}catch{return String(e)}}i(J,"safeJsonStringify");function q(e,t){const o={retries:{strategy:"none"}};t?.signal&&(o.signal=t.signal);const n={};return e.headers&&Object.assign(n,e.headers),t?.headers&&Object.assign(n,t.headers),b(t)&&!n["x-affinity"]&&(n["x-affinity"]=t.sessionId),Object.keys(n).length>0&&(o.headers=n),o}i(q,"buildRequestOptions");function W(e,t,o,n){const r={model:e.id,stream:!0,messages:G(o,e.input.includes("image"))};return t.tools?.length&&(r.tools=Z(t.tools)),n?.temperature!==void 0&&(r.temperature=n.temperature),n?.maxTokens!==void 0&&(r.maxTokens=n.maxTokens),n?.toolChoice&&(r.toolChoice=V(n.toolChoice)),n?.promptMode&&(r.promptMode=n.promptMode),n?.reasoningEffort&&(r.reasoningEffort=n.reasoningEffort),b(n)&&(r.promptCacheKey=n.sessionId),t.systemPrompt&&r.messages.unshift({role:"system",content:y(t.systemPrompt)}),r}i(W,"buildChatPayload");function b(e){return e?.cacheRetention!=="none"&&!!e?.sessionId}i(b,"shouldUsePromptCaching");function H(e,t){const o=e,n=o.promptTokensDetails?.cachedTokens??o.prompt_tokens_details?.cached_tokens??o.promptTokenDetails?.cachedTokens??o.prompt_token_details?.cached_tokens??o.numCachedTokens??o.num_cached_tokens??0,r=typeof n=="number"&&Number.isFinite(n)?n:0;return Math.min(t,Math.max(0,r))}i(H,"getMistralCachedPromptTokens");async function F(e,t,o,n){let r=null;const u=t.content,l=i(()=>u.length-1,"blockIndex"),m=new Map,s=i(c=>{if(c){if(c.type==="text"){o.push({type:"text_end",contentIndex:l(),content:c.text,partial:t});return}c.type==="thinking"&&o.push({type:"thinking_end",contentIndex:l(),content:c.thinking,partial:t})}},"finishCurrentBlock");for await(const c of n){const a=c.data;if(t.responseId||=a.id,a.usage){const d=a.usage.promptTokens||0,g=H(a.usage,d);t.usage.input=Math.max(0,d-g),t.usage.output=a.usage.completionTokens||0,t.usage.cacheRead=g,t.usage.cacheWrite=0,t.usage.totalTokens=a.usage.totalTokens||t.usage.input+t.usage.output+t.usage.cacheRead+t.usage.cacheWrite,E(e,t.usage)}const f=a.choices[0];if(!f)continue;f.finishReason&&(t.stopReason=tt(f.finishReason));const x=f.delta;if(x.content!==null&&x.content!==void 0){const d=typeof x.content=="string"?[x.content]:x.content;for(const g of d){if(typeof g=="string"){const h=y(g);(!r||r.type!=="text")&&(s(r),r={type:"text",text:""},t.content.push(r),o.push({type:"text_start",contentIndex:l(),partial:t})),r.text+=h,o.push({type:"text_delta",contentIndex:l(),delta:h,partial:t});continue}if(g.type==="thinking"){const h=g.thinking.map(p=>"text"in p?p.text:"").filter(p=>p.length>0).join(""),k=y(h);if(!k)continue;(!r||r.type!=="thinking")&&(s(r),r={type:"thinking",thinking:""},t.content.push(r),o.push({type:"thinking_start",contentIndex:l(),partial:t})),r.thinking+=k,o.push({type:"thinking_delta",contentIndex:l(),delta:k,partial:t});continue}if(g.type==="text"){const h=y(g.text);(!r||r.type!=="text")&&(s(r),r={type:"text",text:""},t.content.push(r),o.push({type:"text_start",contentIndex:l(),partial:t})),r.text+=h,o.push({type:"text_delta",contentIndex:l(),delta:h,partial:t})}}}const A=x.toolCalls||[];for(const d of A){r&&(s(r),r=null);const g=d.id&&d.id!=="null"?d.id:I(`toolcall:${d.index??0}`,0),h=`${g}:${d.index||0}`,k=m.get(h);let p;if(k!==void 0){const M=t.content[k];M?.type==="toolCall"&&(p=M)}p||(p={type:"toolCall",id:g,name:d.function.name,arguments:{},partialArgs:""},t.content.push(p),m.set(h,t.content.length-1),o.push({type:"toolcall_start",contentIndex:t.content.length-1,partial:t}));const C=typeof d.function.arguments=="string"?d.function.arguments:JSON.stringify(d.function.arguments||{});p.partialArgs=(p.partialArgs||"")+C,p.arguments=R(p.partialArgs),o.push({type:"toolcall_delta",contentIndex:m.get(h),delta:C,partial:t})}}s(r);for(const c of m.values()){const a=t.content[c];if(a.type!=="toolCall")continue;const f=a;f.arguments=R(f.partialArgs),delete f.partialArgs,o.push({type:"toolcall_end",contentIndex:c,toolCall:f,partial:t})}}i(F,"consumeChatStream");function Z(e){return e.map(t=>{const o=L(t,!0);return{type:"function",function:{name:t.name,description:t.description,parameters:T(t.parameters),strict:o??!1}}})}i(Z,"toFunctionTools");function T(e){if(Array.isArray(e))return e.map(t=>T(t));if(e&&typeof e=="object"){const t={};for(const[o,n]of Object.entries(e))t[o]=T(n);return t}return e}i(T,"stripSymbolKeys");function G(e,t){const o=[];for(const n of e){if(n.role==="user"){if(typeof n.content=="string"){o.push({role:"user",content:y(n.content)});continue}const s=n.content.some(a=>a.type==="image"),c=n.content.filter(a=>a.type==="text"||t).map(a=>a.type==="text"?{type:"text",text:y(a.text)}:{type:"image_url",imageUrl:`data:${a.mimeType};base64,${a.data}`});if(c.length>0){o.push({role:"user",content:c});continue}s&&!t&&o.push({role:"user",content:"(image omitted: model does not support images)"});continue}if(n.role==="assistant"){const s=[],c=[];for(const f of n.content){if(f.type==="text"){f.text.trim().length>0&&s.push({type:"text",text:y(f.text)});continue}if(f.type==="thinking"){f.thinking.trim().length>0&&s.push({type:"thinking",thinking:[{type:"text",text:y(f.thinking)}]});continue}c.push({id:f.id,type:"function",function:{name:f.name,arguments:JSON.stringify(f.arguments||{})}})}const a={role:"assistant"};s.length>0&&(a.content=s),c.length>0&&(a.toolCalls=c),(s.length>0||c.length>0)&&o.push(a);continue}const r=[],u=n.content.filter(s=>s.type==="text").map(s=>s.type==="text"?y(s.text):"").join(`
2
+ `),l=n.content.some(s=>s.type==="image"),m=X(u,l,t,n.isError);r.push({type:"text",text:m});for(const s of n.content)t&&s.type==="image"&&r.push({type:"image_url",imageUrl:`data:${s.mimeType};base64,${s.data}`});o.push({role:"tool",toolCallId:n.toolCallId,name:n.toolName,content:r})}return o}i(G,"toChatMessages");function X(e,t,o,n){const r=e.trim(),u=n?"[tool error] ":"";return r.length>0?`${u}${r}${t&&!o?`
3
+ [tool image omitted: model does not support images]`:""}`:t?o?n?"[tool error] (see attached image)":"(see attached image)":n?"[tool error] (image omitted: model does not support images)":"(image omitted: model does not support images)":n?"[tool error] (no tool output)":"(no tool output)"}i(X,"buildToolResultText");function w(e){return e.id==="mistral-small-2603"||e.id==="mistral-small-latest"||e.id==="mistral-medium-3.5"}i(w,"usesReasoningEffort");function Y(e){return e.reasoning&&!w(e)}i(Y,"usesPromptModeReasoning");function Q(e,t){return e.thinkingLevelMap?.[t]??"high"}i(Q,"mapReasoningEffort");function V(e){if(e)return e==="auto"||e==="none"||e==="any"||e==="required"?e:{type:"function",function:{name:e.function.name}}}i(V,"mapToolChoice");function tt(e){if(e===null)return"stop";switch(e){case"stop":return"stop";case"length":case"model_length":return"length";case"tool_calls":return"toolUse";case"error":return"error";default:return"stop"}}i(tt,"mapChatStopReason");