@qqbrowser/qbot-dsh 0.0.15 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) 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/node_modules/@deepseek-ai/cordis-plugin-hmr/package.json +1 -1
  4. package/node_modules/@deepseek-ai/dsh-agent/package.json +1 -1
  5. package/node_modules/@deepseek-ai/dsh-agent-default-model/package.json +1 -1
  6. package/node_modules/@deepseek-ai/dsh-agent-instructions/package.json +1 -1
  7. package/node_modules/@deepseek-ai/dsh-agent-loop/package.json +1 -1
  8. package/node_modules/@deepseek-ai/dsh-agent-presets/package.json +1 -1
  9. package/node_modules/@deepseek-ai/dsh-agent-tool-presentation/package.json +1 -1
  10. package/node_modules/@deepseek-ai/dsh-anonymous-user-id/package.json +1 -1
  11. package/node_modules/@deepseek-ai/dsh-api-gateway/package.json +1 -1
  12. package/node_modules/@deepseek-ai/dsh-api-remotes/package.json +1 -1
  13. package/node_modules/@deepseek-ai/dsh-app-boot/package.json +1 -1
  14. package/node_modules/@deepseek-ai/dsh-atomic-write/package.json +1 -1
  15. package/node_modules/@deepseek-ai/dsh-attachment/lib/index.js +1 -1
  16. package/node_modules/@deepseek-ai/dsh-attachment/package.json +1 -1
  17. package/node_modules/@deepseek-ai/dsh-attachment-local/package.json +1 -1
  18. package/node_modules/@deepseek-ai/dsh-base/package.json +1 -1
  19. package/node_modules/@deepseek-ai/dsh-bash-local/package.json +1 -1
  20. package/node_modules/@deepseek-ai/dsh-bash-sandbox/package.json +1 -1
  21. package/node_modules/@deepseek-ai/dsh-brand/package.json +1 -1
  22. package/node_modules/@deepseek-ai/dsh-client-connection/lib/client.js +1 -1
  23. package/node_modules/@deepseek-ai/dsh-client-connection/package.json +1 -1
  24. package/node_modules/@deepseek-ai/dsh-client-hmr/package.json +1 -1
  25. package/node_modules/@deepseek-ai/dsh-client-locale/lib/client.js +1 -1
  26. package/node_modules/@deepseek-ai/dsh-client-locale/package.json +1 -1
  27. package/node_modules/@deepseek-ai/dsh-client-modules/package.json +1 -1
  28. package/node_modules/@deepseek-ai/dsh-client-runtime/lib/client.js +4 -4
  29. package/node_modules/@deepseek-ai/dsh-client-runtime/package.json +1 -1
  30. package/node_modules/@deepseek-ai/dsh-client-schema-form/package.json +1 -1
  31. package/node_modules/@deepseek-ai/dsh-client-ui-agent-preset/lib/client.js +1 -1
  32. package/node_modules/@deepseek-ai/dsh-client-ui-agent-preset/package.json +1 -1
  33. package/node_modules/@deepseek-ai/dsh-client-ui-attachment/package.json +1 -1
  34. package/node_modules/@deepseek-ai/dsh-client-ui-commands/lib/client.js +1 -1
  35. package/node_modules/@deepseek-ai/dsh-client-ui-commands/package.json +1 -1
  36. package/node_modules/@deepseek-ai/dsh-client-ui-conversation/lib/client.js +8 -8
  37. package/node_modules/@deepseek-ai/dsh-client-ui-conversation/package.json +1 -1
  38. package/node_modules/@deepseek-ai/dsh-client-ui-cordis/lib/client.js +3 -3
  39. package/node_modules/@deepseek-ai/dsh-client-ui-cordis/package.json +1 -1
  40. package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/lib/client.js +1 -1
  41. package/node_modules/@deepseek-ai/dsh-client-ui-deliverables/package.json +1 -1
  42. package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-browse/lib/client.js +1 -1
  43. package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-browse/package.json +1 -1
  44. package/node_modules/@deepseek-ai/dsh-client-ui-directory-picker-native/package.json +1 -1
  45. package/node_modules/@deepseek-ai/dsh-client-ui-goal/lib/client.js +1 -1
  46. package/node_modules/@deepseek-ai/dsh-client-ui-goal/package.json +1 -1
  47. package/node_modules/@deepseek-ai/dsh-client-ui-input-trigger/lib/client.js +1 -1
  48. package/node_modules/@deepseek-ai/dsh-client-ui-input-trigger/package.json +1 -1
  49. package/node_modules/@deepseek-ai/dsh-client-ui-jobs/lib/client.js +1 -1
  50. package/node_modules/@deepseek-ai/dsh-client-ui-jobs/package.json +1 -1
  51. package/node_modules/@deepseek-ai/dsh-client-ui-layout/lib/client.js +1 -1
  52. package/node_modules/@deepseek-ai/dsh-client-ui-layout/package.json +1 -1
  53. package/node_modules/@deepseek-ai/dsh-client-ui-message-feedback/lib/client.js +1 -1
  54. package/node_modules/@deepseek-ai/dsh-client-ui-message-feedback/package.json +1 -1
  55. package/node_modules/@deepseek-ai/dsh-client-ui-model-selection/lib/client.js +1 -1
  56. package/node_modules/@deepseek-ai/dsh-client-ui-model-selection/package.json +1 -1
  57. package/node_modules/@deepseek-ai/dsh-client-ui-permission-presets/lib/client.js +1 -1
  58. package/node_modules/@deepseek-ai/dsh-client-ui-permission-presets/package.json +1 -1
  59. package/node_modules/@deepseek-ai/dsh-client-ui-plan/lib/client.js +1 -1
  60. package/node_modules/@deepseek-ai/dsh-client-ui-plan/package.json +1 -1
  61. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/lib/index.js +22 -22
  62. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +1 -1
  63. package/node_modules/@deepseek-ai/dsh-client-ui-settings/package.json +1 -1
  64. package/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
  65. package/node_modules/@deepseek-ai/dsh-client-ui-settings-general/package.json +1 -1
  66. package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/lib/client.js +3 -3
  67. package/node_modules/@deepseek-ai/dsh-client-ui-settings-models/package.json +1 -1
  68. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/lib/client.js +1 -1
  69. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/package.json +1 -1
  70. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugins/lib/client.js +1 -1
  71. package/node_modules/@deepseek-ai/dsh-client-ui-settings-plugins/package.json +1 -1
  72. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  73. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/package.json +1 -1
  74. package/node_modules/@deepseek-ai/dsh-client-ui-skill/lib/client.js +3 -3
  75. package/node_modules/@deepseek-ai/dsh-client-ui-skill/package.json +1 -1
  76. package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +1 -1
  77. package/node_modules/@deepseek-ai/dsh-client-ui-subagent/lib/client.js +1 -1
  78. package/node_modules/@deepseek-ai/dsh-client-ui-subagent/package.json +1 -1
  79. package/node_modules/@deepseek-ai/dsh-client-ui-theme/lib/client.js +1 -1
  80. package/node_modules/@deepseek-ai/dsh-client-ui-theme/package.json +1 -1
  81. package/node_modules/@deepseek-ai/dsh-client-ui-tool/lib/client.js +4 -4
  82. package/node_modules/@deepseek-ai/dsh-client-ui-tool/package.json +1 -1
  83. package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/lib/client.js +14 -14
  84. package/node_modules/@deepseek-ai/dsh-client-ui-trajectory/package.json +1 -1
  85. package/node_modules/@deepseek-ai/dsh-client-ui-user-questions/lib/client.js +1 -1
  86. package/node_modules/@deepseek-ai/dsh-client-ui-user-questions/package.json +1 -1
  87. package/node_modules/@deepseek-ai/dsh-client-ui-workflow-run/lib/client.js +1 -1
  88. package/node_modules/@deepseek-ai/dsh-client-ui-workflow-run/package.json +1 -1
  89. package/node_modules/@deepseek-ai/dsh-client-ui-workspace/lib/client.js +1 -1
  90. package/node_modules/@deepseek-ai/dsh-client-ui-workspace/package.json +1 -1
  91. package/node_modules/@deepseek-ai/dsh-client-web/package.json +1 -1
  92. package/node_modules/@deepseek-ai/dsh-client-web-react/package.json +1 -1
  93. package/node_modules/@deepseek-ai/dsh-cmdline/package.json +1 -1
  94. package/node_modules/@deepseek-ai/dsh-code-runtime/package.json +1 -1
  95. package/node_modules/@deepseek-ai/dsh-code-runtime-worker-thread/package.json +1 -1
  96. package/node_modules/@deepseek-ai/dsh-command-compact/package.json +1 -1
  97. package/node_modules/@deepseek-ai/dsh-command-feedback/package.json +1 -1
  98. package/node_modules/@deepseek-ai/dsh-command-goal/package.json +1 -1
  99. package/node_modules/@deepseek-ai/dsh-commands/lib/typert.host.js +5 -2
  100. package/node_modules/@deepseek-ai/dsh-commands/package.json +1 -1
  101. package/node_modules/@deepseek-ai/dsh-compaction/package.json +1 -1
  102. package/node_modules/@deepseek-ai/dsh-compaction-basic/package.json +1 -1
  103. package/node_modules/@deepseek-ai/dsh-compaction-tool-result-pruner/package.json +1 -1
  104. package/node_modules/@deepseek-ai/dsh-content-review/package.json +1 -1
  105. package/node_modules/@deepseek-ai/dsh-cordis-client-runner/lib/client.js +4 -4
  106. package/node_modules/@deepseek-ai/dsh-cordis-client-runner/package.json +1 -1
  107. package/node_modules/@deepseek-ai/dsh-cordis-host-runner/lib/typert.host.js +10 -4
  108. package/node_modules/@deepseek-ai/dsh-cordis-host-runner/package.json +1 -1
  109. package/node_modules/@deepseek-ai/dsh-credentials/package.json +1 -1
  110. package/node_modules/@deepseek-ai/dsh-credentials-local/package.json +1 -1
  111. package/node_modules/@deepseek-ai/dsh-fs/package.json +1 -1
  112. package/node_modules/@deepseek-ai/dsh-fs-local/package.json +1 -1
  113. package/node_modules/@deepseek-ai/dsh-fs-observation-policy/package.json +1 -1
  114. package/node_modules/@deepseek-ai/dsh-fs-sandbox/package.json +1 -1
  115. package/node_modules/@deepseek-ai/dsh-goal/lib/typert.host.js +5 -2
  116. package/node_modules/@deepseek-ai/dsh-goal/package.json +1 -1
  117. package/node_modules/@deepseek-ai/dsh-goal-round-driver/package.json +1 -1
  118. package/node_modules/@deepseek-ai/dsh-headless/package.json +1 -1
  119. package/node_modules/@deepseek-ai/dsh-home-paths/package.json +1 -1
  120. package/node_modules/@deepseek-ai/dsh-home-quarantine-macos/package.json +1 -1
  121. package/node_modules/@deepseek-ai/dsh-host-apiproxy/lib/index.js +7 -7
  122. package/node_modules/@deepseek-ai/dsh-host-apiproxy/lib/types/api/rpc.schema.js +1 -1
  123. package/node_modules/@deepseek-ai/dsh-host-apiproxy/lib/types/api-proxy.js +1 -1
  124. package/node_modules/@deepseek-ai/dsh-host-apiproxy/package.json +1 -1
  125. package/node_modules/@deepseek-ai/dsh-host-directory-picker/package.json +1 -1
  126. package/node_modules/@deepseek-ai/dsh-host-directory-picker-auto/package.json +1 -1
  127. package/node_modules/@deepseek-ai/dsh-host-directory-picker-browse/package.json +1 -1
  128. package/node_modules/@deepseek-ai/dsh-host-directory-picker-native/package.json +1 -1
  129. package/node_modules/@deepseek-ai/dsh-host-frontend-static/package.json +1 -1
  130. package/node_modules/@deepseek-ai/dsh-host-plugin-inventory/package.json +1 -1
  131. package/node_modules/@deepseek-ai/dsh-host-webserver/package.json +1 -1
  132. package/node_modules/@deepseek-ai/dsh-invariants/package.json +1 -1
  133. package/node_modules/@deepseek-ai/dsh-jobs/package.json +1 -1
  134. package/node_modules/@deepseek-ai/dsh-jobs-local/package.json +1 -1
  135. package/node_modules/@deepseek-ai/dsh-launch-environment/package.json +1 -1
  136. package/node_modules/@deepseek-ai/dsh-llm/lib/index.js +1 -1
  137. package/node_modules/@deepseek-ai/dsh-llm/lib/types/assembler.js +1 -1
  138. package/node_modules/@deepseek-ai/dsh-llm/package.json +1 -1
  139. package/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +1 -1
  140. package/node_modules/@deepseek-ai/dsh-llm-deepseek/package.json +1 -1
  141. package/node_modules/@deepseek-ai/dsh-llm-gateway-openai/package.json +1 -1
  142. package/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +1 -1
  143. package/node_modules/@deepseek-ai/dsh-llm-pi-ai/package.json +1 -1
  144. package/node_modules/@deepseek-ai/dsh-llm-retry/package.json +1 -1
  145. package/node_modules/@deepseek-ai/dsh-mcp-client/lib/index.js +3 -2
  146. package/node_modules/@deepseek-ai/dsh-mcp-client/package.json +1 -1
  147. package/node_modules/@deepseek-ai/dsh-message-feedback/package.json +1 -1
  148. package/node_modules/@deepseek-ai/dsh-native-command/package.json +1 -1
  149. package/node_modules/@deepseek-ai/dsh-output-retention/package.json +1 -1
  150. package/node_modules/@deepseek-ai/dsh-permission-presets/package.json +1 -1
  151. package/node_modules/@deepseek-ai/dsh-persona/package.json +1 -1
  152. package/node_modules/@deepseek-ai/dsh-plan-mode/package.json +1 -1
  153. package/node_modules/@deepseek-ai/dsh-pwsh-local/package.json +1 -1
  154. package/node_modules/@deepseek-ai/dsh-pwsh-sandbox/package.json +1 -1
  155. package/node_modules/@deepseek-ai/dsh-qb-auth/package.json +1 -1
  156. package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/package.json +1 -1
  157. package/node_modules/@deepseek-ai/dsh-sandbox/package.json +1 -1
  158. package/node_modules/@deepseek-ai/dsh-sandbox-local/package.json +1 -1
  159. package/node_modules/@deepseek-ai/dsh-sandbox-policy/package.json +1 -1
  160. package/node_modules/@deepseek-ai/dsh-sandbox-windows-acl/package.json +1 -1
  161. package/node_modules/@deepseek-ai/dsh-schedule/package.json +1 -1
  162. package/node_modules/@deepseek-ai/dsh-scope/package.json +1 -1
  163. package/node_modules/@deepseek-ai/dsh-session/package.json +1 -1
  164. package/node_modules/@deepseek-ai/dsh-session-checkpoint-policy/package.json +1 -1
  165. package/node_modules/@deepseek-ai/dsh-session-log-export/lib/client.js +1 -1
  166. package/node_modules/@deepseek-ai/dsh-session-log-export/package.json +1 -1
  167. package/node_modules/@deepseek-ai/dsh-session-persistence/package.json +1 -1
  168. package/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/package.json +1 -1
  169. package/node_modules/@deepseek-ai/dsh-session-projection/package.json +1 -1
  170. package/node_modules/@deepseek-ai/dsh-session-projection-cache/package.json +1 -1
  171. package/node_modules/@deepseek-ai/dsh-session-query/lib/index.js +2 -2
  172. package/node_modules/@deepseek-ai/dsh-session-query/package.json +1 -1
  173. package/node_modules/@deepseek-ai/dsh-session-query-sqlite/package.json +1 -1
  174. package/node_modules/@deepseek-ai/dsh-session-reference/package.json +1 -1
  175. package/node_modules/@deepseek-ai/dsh-session-stats/package.json +1 -1
  176. package/node_modules/@deepseek-ai/dsh-session-telemetry/package.json +1 -1
  177. package/node_modules/@deepseek-ai/dsh-session-telemetry-otel/package.json +1 -1
  178. package/node_modules/@deepseek-ai/dsh-session-title/package.json +1 -1
  179. package/node_modules/@deepseek-ai/dsh-session-title-first-prompt-llm/package.json +1 -1
  180. package/node_modules/@deepseek-ai/dsh-session-title-llm/package.json +1 -1
  181. package/node_modules/@deepseek-ai/dsh-settings/package.json +1 -1
  182. package/node_modules/@deepseek-ai/dsh-settings-file/package.json +1 -1
  183. package/node_modules/@deepseek-ai/dsh-shell/package.json +1 -1
  184. package/node_modules/@deepseek-ai/dsh-shell-env/package.json +1 -1
  185. package/node_modules/@deepseek-ai/dsh-skill/package.json +1 -1
  186. package/node_modules/@deepseek-ai/dsh-skill-badge/package.json +1 -1
  187. package/node_modules/@deepseek-ai/dsh-skill-filesystem/package.json +1 -1
  188. package/node_modules/@deepseek-ai/dsh-spill/package.json +1 -1
  189. package/node_modules/@deepseek-ai/dsh-spill-local/package.json +1 -1
  190. package/node_modules/@deepseek-ai/dsh-spill-policy/package.json +1 -1
  191. package/node_modules/@deepseek-ai/dsh-storage/package.json +1 -1
  192. package/node_modules/@deepseek-ai/dsh-storage-domain/package.json +1 -1
  193. package/node_modules/@deepseek-ai/dsh-storage-json/package.json +1 -1
  194. package/node_modules/@deepseek-ai/dsh-subagent/package.json +1 -1
  195. package/node_modules/@deepseek-ai/dsh-subagent-fork-in-process/package.json +1 -1
  196. package/node_modules/@deepseek-ai/dsh-subagent-in-process-driver/package.json +1 -1
  197. package/node_modules/@deepseek-ai/dsh-subagent-spawn-in-process/package.json +1 -1
  198. package/node_modules/@deepseek-ai/dsh-subprocess/package.json +1 -1
  199. package/node_modules/@deepseek-ai/dsh-subprocess-local/package.json +1 -1
  200. package/node_modules/@deepseek-ai/dsh-system-prompt/package.json +1 -1
  201. package/node_modules/@deepseek-ai/dsh-terminal/package.json +1 -1
  202. package/node_modules/@deepseek-ai/dsh-terminal-bash/lib/index.js +1 -1
  203. package/node_modules/@deepseek-ai/dsh-terminal-bash/package.json +1 -1
  204. package/node_modules/@deepseek-ai/dsh-time-context/package.json +1 -1
  205. package/node_modules/@deepseek-ai/dsh-timeout/package.json +1 -1
  206. package/node_modules/@deepseek-ai/dsh-tmux-context/package.json +1 -1
  207. package/node_modules/@deepseek-ai/dsh-token-meter/package.json +1 -1
  208. package/node_modules/@deepseek-ai/dsh-tool-ask-user/package.json +1 -1
  209. package/node_modules/@deepseek-ai/dsh-tool-bash/package.json +1 -1
  210. package/node_modules/@deepseek-ai/dsh-tool-bash-persistent/lib/index.js +7 -10
  211. package/node_modules/@deepseek-ai/dsh-tool-bash-persistent/package.json +1 -1
  212. package/node_modules/@deepseek-ai/dsh-tool-call-timeout-policy/package.json +1 -1
  213. package/node_modules/@deepseek-ai/dsh-tool-cordis/lib/index.js +5 -2
  214. package/node_modules/@deepseek-ai/dsh-tool-cordis/package.json +1 -1
  215. package/node_modules/@deepseek-ai/dsh-tool-fs/lib/index.js +8 -8
  216. package/node_modules/@deepseek-ai/dsh-tool-fs/package.json +1 -1
  217. package/node_modules/@deepseek-ai/dsh-tool-fs-search/package.json +1 -1
  218. package/node_modules/@deepseek-ai/dsh-tool-goal/package.json +1 -1
  219. package/node_modules/@deepseek-ai/dsh-tool-jobs/package.json +1 -1
  220. package/node_modules/@deepseek-ai/dsh-tool-pwsh/package.json +1 -1
  221. package/node_modules/@deepseek-ai/dsh-tool-ralph/package.json +1 -1
  222. package/node_modules/@deepseek-ai/dsh-tool-skill/package.json +1 -1
  223. package/node_modules/@deepseek-ai/dsh-tool-str-replace-editor/package.json +1 -1
  224. package/node_modules/@deepseek-ai/dsh-tool-subagent/lib/index.js +2 -2
  225. package/node_modules/@deepseek-ai/dsh-tool-subagent/package.json +1 -1
  226. package/node_modules/@deepseek-ai/dsh-tool-subagent-control/package.json +1 -1
  227. package/node_modules/@deepseek-ai/dsh-tool-subagent-report/package.json +1 -1
  228. package/node_modules/@deepseek-ai/dsh-tool-todo/package.json +1 -1
  229. package/node_modules/@deepseek-ai/dsh-tool-web/package.json +1 -1
  230. package/node_modules/@deepseek-ai/dsh-tool-workflow/package.json +1 -1
  231. package/node_modules/@deepseek-ai/dsh-tools/lib/index.js +15 -15
  232. package/node_modules/@deepseek-ai/dsh-tools/lib/types/code-mode.js +8 -8
  233. package/node_modules/@deepseek-ai/dsh-tools/lib/types/py-types.js +3 -3
  234. package/node_modules/@deepseek-ai/dsh-tools/lib/types/ts-types.js +4 -4
  235. package/node_modules/@deepseek-ai/dsh-tools/package.json +1 -1
  236. package/node_modules/@deepseek-ai/dsh-typert-loader/package.json +1 -1
  237. package/node_modules/@deepseek-ai/dsh-typert-protocol/package.json +1 -1
  238. package/node_modules/@deepseek-ai/dsh-typert-registry/package.json +1 -1
  239. package/node_modules/@deepseek-ai/dsh-user-approval/package.json +1 -1
  240. package/node_modules/@deepseek-ai/dsh-user-questions/package.json +1 -1
  241. package/node_modules/@deepseek-ai/dsh-web/package.json +1 -1
  242. package/node_modules/@deepseek-ai/dsh-web-app/package.json +1 -1
  243. package/node_modules/@deepseek-ai/dsh-web-frontend/dist/assets/{index-BQQQ5Qt-.js → index-fPGOmJjK.js} +25 -25
  244. package/node_modules/@deepseek-ai/dsh-web-frontend/dist/index.html +1 -1
  245. package/node_modules/@deepseek-ai/dsh-web-frontend/package.json +1 -1
  246. package/node_modules/@deepseek-ai/dsh-web-search-deepseek/package.json +1 -1
  247. package/node_modules/@deepseek-ai/dsh-web-search-dsh/package.json +1 -1
  248. package/node_modules/@deepseek-ai/dsh-workflow/package.json +1 -1
  249. package/node_modules/@deepseek-ai/dsh-workflow-worker-thread/package.json +1 -1
  250. package/node_modules/@deepseek-ai/dsh-workspace/package.json +1 -1
  251. package/node_modules/@tanstack/react-virtual/package.json +1 -1
  252. package/node_modules/@tanstack/virtual-core/dist/cjs/index.cjs +7 -1
  253. package/node_modules/@tanstack/virtual-core/dist/cjs/utils.cjs +14 -4
  254. package/node_modules/@tanstack/virtual-core/dist/esm/index.js +1 -1
  255. package/node_modules/@tanstack/virtual-core/dist/esm/utils.js +2 -2
  256. package/node_modules/@tanstack/virtual-core/package.json +1 -1
  257. package/node_modules/hono/dist/cjs/client/utils.js +1 -1
  258. package/node_modules/hono/dist/cjs/context.js +4 -0
  259. package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
  260. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
  261. package/node_modules/hono/dist/cjs/middleware/etag/digest.js +1 -1
  262. package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -2
  263. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
  264. package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
  265. package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
  266. package/node_modules/hono/dist/cjs/router/trie-router/node.js +43 -67
  267. package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
  268. package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
  269. package/node_modules/hono/dist/client/utils.js +1 -1
  270. package/node_modules/hono/dist/middleware/cors/index.js +1 -1
  271. package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
  272. package/node_modules/hono/dist/middleware/etag/digest.js +1 -1
  273. package/node_modules/hono/dist/middleware/etag/index.js +1 -1
  274. package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -1
  275. package/node_modules/hono/dist/router/linear-router/router.js +1 -1
  276. package/node_modules/hono/dist/router/pattern-router/router.js +1 -1
  277. package/node_modules/hono/dist/router/trie-router/node.js +1 -1
  278. package/node_modules/hono/dist/router/trie-router/router.js +1 -1
  279. package/node_modules/hono/dist/utils/ipaddr.js +1 -1
  280. package/node_modules/hono/package.json +1 -1
  281. package/node_modules/node-pty/lib/conpty_console_list_agent.js +11 -2
  282. package/node_modules/node-pty/lib/index.js +6 -6
  283. package/node_modules/node-pty/lib/shared/conout.js +2 -3
  284. package/node_modules/node-pty/lib/terminal.js +2 -2
  285. package/node_modules/node-pty/lib/unixTerminal.js +11 -6
  286. package/node_modules/node-pty/lib/utils.js +6 -7
  287. package/node_modules/node-pty/lib/windowsConoutConnection.js +24 -18
  288. package/node_modules/node-pty/lib/windowsPtyAgent.js +125 -101
  289. package/node_modules/node-pty/lib/windowsTerminal.js +14 -4
  290. package/node_modules/node-pty/lib/worker/conoutSocketWorker.js +3 -3
  291. package/node_modules/node-pty/package.json +1 -1
  292. package/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  293. package/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  294. package/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  295. package/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  296. package/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  297. package/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  298. package/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  299. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  300. package/node_modules/node-pty/scripts/post-install.js +1 -5
  301. package/node_modules/node-pty/third_party/conpty/1.25.260303002/win10-arm64/OpenConsole.exe +0 -0
  302. package/node_modules/node-pty/third_party/conpty/{1.23.251008001 → 1.25.260303002}/win10-arm64/conpty.dll +0 -0
  303. package/node_modules/node-pty/third_party/conpty/1.25.260303002/win10-x64/OpenConsole.exe +0 -0
  304. package/node_modules/node-pty/third_party/conpty/1.25.260303002/win10-x64/conpty.dll +0 -0
  305. package/package.json +1 -1
  306. package/node_modules/node-pty/deps/winpty/.drone.yml +0 -15
  307. package/node_modules/node-pty/deps/winpty/LICENSE +0 -21
  308. package/node_modules/node-pty/deps/winpty/configure +0 -167
  309. package/node_modules/node-pty/deps/winpty/misc/ConinMode.ps1 +0 -116
  310. package/node_modules/node-pty/deps/winpty/misc/IdentifyConsoleWindow.ps1 +0 -51
  311. package/node_modules/node-pty/deps/winpty/misc/build32.sh +0 -9
  312. package/node_modules/node-pty/deps/winpty/misc/build64.sh +0 -9
  313. package/node_modules/node-pty/deps/winpty/misc/color-test.sh +0 -212
  314. package/node_modules/node-pty/deps/winpty/ship/build-pty4j-libpty.bat +0 -36
  315. package/node_modules/node-pty/deps/winpty/src/shared/GetCommitHash.bat +0 -13
  316. package/node_modules/node-pty/deps/winpty/src/shared/UpdateGenVersion.bat +0 -20
  317. package/node_modules/node-pty/deps/winpty/vcbuild.bat +0 -83
  318. package/node_modules/node-pty/lib/eventEmitter2.test.js +0 -30
  319. package/node_modules/node-pty/lib/terminal.test.js +0 -139
  320. package/node_modules/node-pty/lib/testUtils.test.js +0 -28
  321. package/node_modules/node-pty/lib/unixTerminal.test.js +0 -351
  322. package/node_modules/node-pty/lib/windowsPtyAgent.test.js +0 -90
  323. package/node_modules/node-pty/lib/windowsTerminal.test.js +0 -219
  324. package/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
  325. package/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  326. package/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
  327. package/node_modules/node-pty/scripts/gen-compile-commands.js +0 -8
  328. package/node_modules/node-pty/scripts/increment-version.js +0 -54
  329. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
  330. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
  331. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
@@ -1 +1 @@
1
- var K=Object.defineProperty;var s=(e,n)=>K(e,"name",{value:n,configurable:!0});import m from"@deepseek-ai/schemastery";import{CONTEXT_WINDOW_EXCEEDED_CODE as q,CallId as I,EMPTY_RESPONSE_CODE as B,LlmAdapter as G,LlmError as g,ProviderRequestId as H,QUOTA_EXCEEDED_CODE as V,ReasoningEffortId as S,RetryPolicySchema as X,assertUsableApiKey as R,attributionHeaders as Y,contentHasImage as z,isContextWindowExceededError as J,isQuotaExceededError as Q,resolveRetryPolicy as Z}from"@deepseek-ai/dsh-llm";import{credentialRef as ee}from"@deepseek-ai/dsh-credentials";import{launchEnvironmentOf as O}from"@deepseek-ai/dsh-launch-environment";import{deepEqualJson as te,installSettingsSection as ne,settingsNamespace as oe}from"@deepseek-ai/dsh-settings";import{MAX_TIMER_DELAY_MS as v,idleWatchdog as re,timeoutOf as ie}from"@deepseek-ai/dsh-timeout";import{getOrCreateAnonymousUserId as se}from"@deepseek-ai/dsh-anonymous-user-id";import{EventSourceParserStream as ae}from"eventsource-parser/stream";function de(e){if(e==="off"||e==="high"||e==="max")return e;throw new g(`DeepSeek does not support reasoning effort "${e}"`,"UNSUPPORTED_REASONING_EFFORT")}s(de,"reasoningEffort");function le(e,n){if(e.purpose==="session-title")return{thinking:"disabled"};const t=e.reasoningEffort===void 0?n.reasoningEffort:de(e.reasoningEffort);if(n.thinking==="disabled"&&t!==void 0&&t!=="off")throw new g(`DeepSeek deployment does not support reasoning effort "${t}"`,"UNSUPPORTED_REASONING_EFFORT");return t==="off"?{thinking:"disabled"}:t==="high"||t==="max"?{thinking:"enabled",reasoningEffort:t}:n.thinking===void 0?{}:{thinking:n.thinking}}s(le,"resolveThinking");function w(e){return e.filter(n=>n.type==="text").map(n=>n.text).join("")}s(w,"flattenText");function ce(e){if(z(e))throw new g("The DeepSeek chat-completions adapter does not support image content.","UNSUPPORTED_CONTENT")}s(ce,"assertTextOnly");function fe(e){const n=w(e.content),t=e.content.filter(r=>r.type==="reasoning").map(r=>r.text).join(""),o=e.content.filter(r=>r.type==="tool-call").map(r=>({id:r.id,type:"function",function:{name:r.name,arguments:r.arguments}}));return{role:"assistant",content:n,...o.length>0&&t.length>0?{reasoning_content:t}:{},...o.length>0?{tool_calls:o}:{}}}s(fe,"serializeAssistant");function ue(e){const n=[];for(const t of e){if(ce(t.content),t.role==="system"){n.push({role:"system",content:w(t.content)});continue}if(t.role==="assistant"){n.push(fe(t));continue}const o=t.content.filter(i=>i.type==="tool-result"),r=w(t.content);(r.length>0||o.length===0)&&n.push({role:"user",content:r});for(const i of o)n.push({role:"tool",tool_call_id:i.toolCallId,content:w(i.content)||"(no output)"})}return n}s(ue,"serializeMessages");function pe(e,n={}){const t=[];e.system!==void 0&&t.push({role:"system",content:e.system}),t.push(...ue(e.messages));const o=e.tools?.map(i=>({type:"function",function:{name:i.name,description:i.description,parameters:i.parameters}})),r=le(e,n);return{model:e.model,messages:t,stream:!0,stream_options:{include_usage:!0},...r.thinking!==void 0?{thinking:{type:r.thinking}}:{},...r.reasoningEffort!==void 0?{reasoning_effort:r.reasoningEffort}:{},...o!==void 0&&o.length>0?{tools:o}:{},...e.temperature!==void 0?{temperature:e.temperature}:{},...e.maxTokens===void 0?{}:{max_tokens:e.maxTokens},...e.stop!==void 0?{stop:e.stop}:{}}}s(pe,"serializeRequest");async function*me(e,n){const t=e.pipeThrough(new TextDecoderStream).pipeThrough(new ae({onComment:n}));for await(const{data:o}of t)if(yield o,o==="[DONE]")return;throw new g("SSE stream ended without [DONE]","STREAM_CLOSED")}s(me,"parseSse");function he(e){switch(e){case"stop":return{kind:"stop"};case"tool_calls":return{kind:"tool-calls"};case"length":return{kind:"max-tokens"};default:return{kind:"error",failure:{message:`model stopped: ${e}`,code:e.toUpperCase()}}}}s(he,"mapFinishReason");function ge(e){const n=e.prompt_tokens_details?.cached_tokens??e.prompt_cache_hit_tokens,t=e.completion_tokens_details?.reasoning_tokens;return{inputTokens:e.prompt_tokens-(n??0),outputTokens:e.completion_tokens,...n!==void 0?{cacheReadTokens:n}:{},...t!==void 0?{reasoningTokens:t}:{}}}s(ge,"mapUsage");function Ee(e){switch(e.kind){case"text":return{type:"text",text:e.text};case"reasoning":return{type:"reasoning",text:e.text};case"tool-call":return{type:"tool-call",id:I(e.callId??""),name:e.name??"",arguments:e.text}}}s(Ee,"closeBlock");async function*ye(e){let n=0,t,o;const r=new Map,i=[];let p,u;function E(d){const a={index:n++,kind:d,text:""};return i.push(a),a}s(E,"open");for await(const d of e){if(d==="[DONE]"){for(const y of i)yield{type:"block-end",index:y.index,block:Ee(y)};u&&(yield{type:"usage",usage:u});const h=p??{kind:"stop"};yield{type:"finish",reason:h.kind==="stop"&&i.length===0?{kind:"error",failure:{message:"model returned a completed response with no content",code:B}}:h};return}let a;try{a=JSON.parse(d)}catch{throw new g(`malformed SSE payload: ${d.slice(0,120)}`,"MALFORMED_RESPONSE")}for(const h of a.choices??[]){const y=h.delta,l=y?.reasoning_content;typeof l=="string"&&l.length>0&&(o||(o=E("reasoning"),yield{type:"block-start",index:o.index,blockType:"reasoning"}),o.text+=l,yield{type:"reasoning-delta",index:o.index,text:l});const f=y?.content;typeof f=="string"&&f.length>0&&(t||(t=E("text"),yield{type:"block-start",index:t.index,blockType:"text"}),t.text+=f,yield{type:"text-delta",index:t.index,text:f});for(const k of y?.tool_calls??[]){let c=r.get(k.index);c||(c=E("tool-call"),r.set(k.index,c),yield{type:"block-start",index:c.index,blockType:"tool-call"}),k.id!==void 0&&(c.callId=k.id),k.function?.name!==void 0&&(c.name=k.function.name);const b=k.function?.arguments??"";c.text+=b,yield{type:"tool-call-delta",index:c.index,id:I(c.callId??""),...c.name!==void 0?{name:c.name}:{},argumentsDelta:b}}typeof h.finish_reason=="string"&&(p=he(h.finish_reason))}a.usage&&(u=ge(a.usage))}throw new g("SSE payload stream ended without [DONE]","STREAM_CLOSED")}s(ye,"translate");var ke=s(function(e,n,t){if(n!=null){if(typeof n!="object"&&typeof n!="function")throw new TypeError("Object expected.");var o,r;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=n[Symbol.asyncDispose]}if(o===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=n[Symbol.dispose],t&&(r=o)}if(typeof o!="function")throw new TypeError("Object not disposable.");r&&(o=s(function(){try{r.call(this)}catch(i){return Promise.reject(i)}},"dispose")),e.stack.push({value:n,dispose:o,async:t})}else t&&e.stack.push({async:!0});return n},"__addDisposableResource"),we=(function(e){return function(n){function t(p){n.error=n.hasError?new e(p,n.error,"An error was suppressed during disposal."):p,n.hasError=!0}s(t,"fail");var o,r=0;function i(){for(;o=n.stack.pop();)try{if(!o.async&&r===1)return r=0,n.stack.push(o),Promise.resolve().then(i);if(o.dispose){var p=o.dispose.call(o.value);if(o.async)return r|=2,Promise.resolve(p).then(i,function(u){return t(u),i()})}else r|=1}catch(u){t(u)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s(i,"next"),i()}})(typeof SuppressedError=="function"?SuppressedError:function(e,n,t){var o=new Error(t);return o.name="SuppressedError",o.error=e,o.suppressed=n,o});const D=3e5,x=1e6,A=256e3,N="LLM_STREAM_IDLE_TIMEOUT",T=S("off"),P=S("high"),M=S("max"),xe=[{id:T,name:"Off"},{id:P,name:"High"},{id:M,name:"Max"}],Te=[{id:T,name:"Off"}];function U(e,n){return{provider:e,id:n.id,name:n.name??n.id,...n.description===void 0?{}:{description:n.description},inputModalities:["text"]}}s(U,"modelInfo");function _e(e){if(e===null)return;if(/^\d+$/.test(e)){const t=Number(e)*1e3;return Number.isFinite(t)&&t>0?t:void 0}const n=Date.parse(e)-Date.now();return Number.isFinite(n)&&n>0?n:void 0}s(_e,"providerRetryAfterMs");function Se(e){const n=e.get("x-request-id")??e.get("x-deepseek-request-id");return n===null||n.length===0?void 0:H(n)}s(Se,"requestId");function ve(e,n){if(e===401||e===403)return"AUTH";const t=[n?.code,n?.type,n?.message].filter(Boolean).join(" ");return Q(t)?V:e===429?"RATE_LIMIT":e===400?J(t)?q:"INVALID_REQUEST":e>=500?"SERVER":`HTTP_${e}`}s(ve,"httpErrorCode");var F=class extends G{static{s(this,"DeepSeekAdapter")}config;constructor(e){super(),this.config=e}providerInfo(e){return{id:e,name:"DeepSeek"}}providerRetryPolicy(e){return this.config.options().retryPolicy}listModels(e){return Promise.resolve(this.config.options().models.map(n=>U(e,n)))}resolveModel(e,n,t){const o=this.config.options(),r=o.models.find(p=>p.id===n),i=r?.contextWindow??o.defaultContextWindow;return Promise.resolve({...r===void 0?{provider:e,id:n,name:n,inputModalities:["text"]}:U(e,r),context:{contextWindow:i},defaultMaxTokens:r?.maxTokens??o.maxTokens,...o.defaults.thinking==="disabled"?{reasoning:{efforts:Te,defaultEffort:T}}:{reasoning:{efforts:xe,defaultEffort:o.defaults.reasoningEffort==="off"?T:o.defaults.reasoningEffort==="max"?M:P}}})}async*stream(e){const n={stack:[],error:void 0,hasError:!1};try{const t=this.config.options(),o=await this.config.resolveApiKey(t),r=this.config.resolveUserId(),i=new AbortController,p=e.signal===void 0?i.signal:AbortSignal.any([e.signal,i.signal]),u=ke(n,re(p,t.streamIdleTimeoutMs,N),!1),E=this.request(e,u.signal,t,o,r,()=>{u.pulse()})[Symbol.asyncIterator]();let d=!1;try{for(;;){const a=await u.next(E);if(a.done){d=!0;return}yield a.value}}catch(a){throw ie(u.signal,N)!==void 0?new g(`DeepSeek stream idle timeout after ${t.streamIdleTimeoutMs}ms`,"TIMEOUT",{cause:a}):e.signal?.aborted?new g("DeepSeek request aborted by caller","ABORTED",{cause:a}):a instanceof g?a:new g(`DeepSeek API stream from ${t.baseURL} failed`,"TRANSPORT",{cause:a})}finally{if(i.abort("DeepSeek stream consumer stopped"),!d&&E.return!==void 0)try{await E.return()}catch{}}}catch(t){n.error=t,n.hasError=!0}finally{we(n)}}async*request(e,n,t,o,r,i){const p=pe(e,t.defaults),u=JSON.stringify(p),E={authorization:`Bearer ${o}`,"content-type":"application/json",accept:"text/event-stream",...Y(),"x-deepseek-harness-user-id":String(r),...e.sessionId!==void 0?{"x-deepseek-harness-session-id":String(e.sessionId)}:{},...e.purpose==="compaction"?{"x-deepseek-harness-compact":"1"}:{}};let d;try{d=await fetch(`${t.baseURL}/chat/completions`,{method:"POST",headers:E,body:u,signal:n})}catch(a){throw n.aborted?a:new g(`DeepSeek API request to ${t.baseURL} failed`,"TRANSPORT",{cause:a})}if(!d.ok){let a=`DeepSeek API error (HTTP ${d.status})`,h;try{h=(await d.json()).error,h?.message&&(a=h.message)}catch{}const y=_e(d.headers.get("retry-after")),l=Se(d.headers);throw new g(a,ve(d.status,h),{status:d.status,...y===void 0?{}:{providerRetryAfterMs:y},...l===void 0?{}:{requestId:l}})}if(!d.body)throw new g("DeepSeek API returned no response body","EMPTY_RESPONSE");yield*ye(me(d.body,i))}};const be="llm-deepseek",Ie=["llm"],C=oe("llm-deepseek"),L="DEEPSEEK_API_KEY",_="deepseek-official",W=[{id:"deepseek-v4-flash",name:"DeepSeek-V4-Flash",contextWindow:x},{id:"deepseek-v4-pro",name:"DeepSeek-V4-Pro",contextWindow:x}],Re=m.object({id:m.string().required(),name:m.string(),description:m.string(),contextWindow:m.number().step(1).min(1),maxTokens:m.number().step(1).min(1)}),$=m.object({apiKeyEnv:m.string().role("credential-ref").default(L),baseURL:m.string(),thinking:m.union(["enabled","disabled"]),reasoningEffort:m.union(["off","high","max"]),maxTokens:m.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(A),defaultContextWindow:m.number().step(1).min(1).default(x),models:m.array(Re).default(W),streamIdleTimeoutMs:m.number().min(Number.MIN_VALUE).max(v).default(D),retryPolicy:X}),Oe="https://api.deepseek.com",De="DEEPSEEK_BASE_URL";function Ae(e){const n=new Set;return(e??W).map(t=>{if(t.id.length===0)throw new Error("llm-deepseek: catalog model ids must be non-empty");if(t.name!==void 0&&t.name.length===0)throw new Error(`llm-deepseek: catalog model "${t.id}" has an empty name`);if(t.contextWindow!==void 0&&(!Number.isInteger(t.contextWindow)||t.contextWindow<=0))throw new Error(`llm-deepseek: catalog model "${t.id}" contextWindow must be a positive integer`);if(t.maxTokens!==void 0&&(!Number.isInteger(t.maxTokens)||t.maxTokens<=0))throw new Error(`llm-deepseek: catalog model "${t.id}" maxTokens must be a positive integer`);if(n.has(t.id))throw new Error(`llm-deepseek: duplicate catalog model "${t.id}"`);return n.add(t.id),{id:t.id,...t.name===void 0?{}:{name:t.name},...t.description===void 0?{}:{description:t.description},...t.contextWindow===void 0?{}:{contextWindow:t.contextWindow},...t.maxTokens===void 0?{}:{maxTokens:t.maxTokens}}})}s(Ae,"resolveModels");function j(e,n){if(e.thinking==="disabled"&&e.reasoningEffort!==void 0&&e.reasoningEffort!=="off")throw new Error('llm-deepseek: only reasoningEffort "off" can be configured when thinking is disabled');if(e.defaultContextWindow!==void 0&&(!Number.isInteger(e.defaultContextWindow)||e.defaultContextWindow<=0))throw new Error("llm-deepseek: defaultContextWindow must be a positive integer");if(e.maxTokens!==void 0&&(!Number.isSafeInteger(e.maxTokens)||e.maxTokens<=0))throw new Error("llm-deepseek: maxTokens must be a positive safe integer");const t=e.streamIdleTimeoutMs??3e5;if(!Number.isFinite(t)||t<=0||t>v)throw new Error(`llm-deepseek: streamIdleTimeoutMs must be a positive finite number no greater than ${v}`);return{apiKeyEnv:ee(e.apiKeyEnv??L),baseURL:e.baseURL??n?.get(De)?.value??"https://api.deepseek.com",defaults:{thinking:e.thinking,reasoningEffort:e.reasoningEffort},maxTokens:e.maxTokens??256e3,defaultContextWindow:e.defaultContextWindow??1e6,models:Ae(e.models),streamIdleTimeoutMs:t,retryPolicy:Z(e.retryPolicy,"llm-deepseek: retryPolicy")}}s(j,"resolveAdapterOptions");function Ne(e,n){let t=s(()=>n,"current"),o,r;const i=s(()=>{const l=t();if(l===o&&r!==void 0)return r;try{const f=j(l,O(e));return o=l,r=f,f}catch(f){if(r===void 0)throw f;return o=l,e.logger.error("llm-deepseek: keeping the last good configuration after an invalid settings section"),e.logger.error(f),r}},"options");i();const p=s(async l=>{const f=l.apiKeyEnv,k=e.get("credentials");if(k!==void 0){const c=await k.resolve(f);if(c!==void 0)return R(c.value,"llm-deepseek",f)}else{const c=O(e).get(f);if(c!==void 0&&c.value.length>0)return R(c.value,"llm-deepseek",f)}throw new g(`llm-deepseek: no API key for provider route "${_}"; store ${f} through the credentials service (the web Models page writes it), or export ${f} in the launching environment`,"MISSING_CREDENTIAL")},"resolveApiKey");let u;const E=s(()=>u??=se(),"resolveUserId"),d=new F({options:i,resolveApiKey:p,resolveUserId:E});e.llm.registerConfigurableProviders([{provider:_,displayName:"DeepSeek",settingsNs:C,settingsPath:[]}]);const a=e.llm.registerAdapter([_],d);let h=i().retryPolicy;ne(e,C,$,n,{setSource:s(l=>{t=l},"setSource"),onChange:s(()=>{const l=i().retryPolicy;te(l,h)||(a.replace([_]),h=l)},"ensureRegistrationFacts")})}s(Ne,"apply");export{$ as Config,x as DEFAULT_CONTEXT_WINDOW,A as DEFAULT_MAX_TOKENS,D as DEFAULT_STREAM_IDLE_TIMEOUT_MS,F as DeepSeekAdapter,Oe as PUBLIC_BASE_URL,Ne as apply,Ie as inject,be as name,j as resolveAdapterOptions};
1
+ var q=Object.defineProperty;var s=(e,n)=>q(e,"name",{value:n,configurable:!0});import m from"@deepseek-ai/schemastery";import{CONTEXT_WINDOW_EXCEEDED_CODE as G,CallId as R,EMPTY_RESPONSE_CODE as B,LlmAdapter as H,LlmError as g,ProviderRequestId as V,QUOTA_EXCEEDED_CODE as X,ReasoningEffortId as w,RetryPolicySchema as Y,assertUsableApiKey as I,attributionHeaders as z,contentHasImage as J,isContextWindowExceededError as Q,isQuotaExceededError as Z,resolveRetryPolicy as ee}from"@deepseek-ai/dsh-llm";import{credentialRef as te}from"@deepseek-ai/dsh-credentials";import{launchEnvironmentOf as O}from"@deepseek-ai/dsh-launch-environment";import{deepEqualJson as ne,installSettingsSection as oe,settingsNamespace as re}from"@deepseek-ai/dsh-settings";import{MAX_TIMER_DELAY_MS as v,idleWatchdog as ie,timeoutOf as se}from"@deepseek-ai/dsh-timeout";import{getOrCreateAnonymousUserId as ae}from"@deepseek-ai/dsh-anonymous-user-id";import{EventSourceParserStream as de}from"eventsource-parser/stream";function le(e){if(e==="off"||e==="low"||e==="high"||e==="max")return e;throw new g(`DeepSeek does not support reasoning effort "${e}"`,"UNSUPPORTED_REASONING_EFFORT")}s(le,"reasoningEffort");function ce(e,n){if(e.purpose==="session-title")return{thinking:"disabled"};const t=e.reasoningEffort===void 0?n.reasoningEffort:le(e.reasoningEffort);if(n.thinking==="disabled"&&t!==void 0&&t!=="off")throw new g(`DeepSeek deployment does not support reasoning effort "${t}"`,"UNSUPPORTED_REASONING_EFFORT");return t==="off"?{thinking:"disabled"}:t==="low"||t==="high"||t==="max"?{thinking:"enabled",reasoningEffort:t}:n.thinking===void 0?{}:{thinking:n.thinking}}s(ce,"resolveThinking");function x(e){return e.filter(n=>n.type==="text").map(n=>n.text).join("")}s(x,"flattenText");function fe(e){if(J(e))throw new g("The DeepSeek chat-completions adapter does not support image content.","UNSUPPORTED_CONTENT")}s(fe,"assertTextOnly");function ue(e){const n=x(e.content),t=e.content.filter(r=>r.type==="reasoning").map(r=>r.text).join(""),o=e.content.filter(r=>r.type==="tool-call").map(r=>({id:r.id,type:"function",function:{name:r.name,arguments:r.arguments}}));return{role:"assistant",content:n,...o.length>0&&t.length>0?{reasoning_content:t}:{},...o.length>0?{tool_calls:o}:{}}}s(ue,"serializeAssistant");function pe(e){const n=[];for(const t of e){if(fe(t.content),t.role==="system"){n.push({role:"system",content:x(t.content)});continue}if(t.role==="assistant"){n.push(ue(t));continue}const o=t.content.filter(i=>i.type==="tool-result"),r=x(t.content);(r.length>0||o.length===0)&&n.push({role:"user",content:r});for(const i of o)n.push({role:"tool",tool_call_id:i.toolCallId,content:x(i.content)||"(no output)"})}return n}s(pe,"serializeMessages");function me(e,n={}){const t=[];e.system!==void 0&&t.push({role:"system",content:e.system}),t.push(...pe(e.messages));const o=e.tools?.map(i=>({type:"function",function:{name:i.name,description:i.description,parameters:i.parameters}})),r=ce(e,n);return{model:e.model,messages:t,stream:!0,stream_options:{include_usage:!0},...r.thinking!==void 0?{thinking:{type:r.thinking}}:{},...r.reasoningEffort!==void 0?{reasoning_effort:r.reasoningEffort}:{},...o!==void 0&&o.length>0?{tools:o}:{},...e.temperature!==void 0?{temperature:e.temperature}:{},...e.maxTokens===void 0?{}:{max_tokens:e.maxTokens},...e.stop!==void 0?{stop:e.stop}:{}}}s(me,"serializeRequest");async function*he(e,n){const t=e.pipeThrough(new TextDecoderStream).pipeThrough(new de({onComment:n}));for await(const{data:o}of t)if(yield o,o==="[DONE]")return;throw new g("SSE stream ended without [DONE]","STREAM_CLOSED")}s(he,"parseSse");function ge(e){switch(e){case"stop":return{kind:"stop"};case"tool_calls":return{kind:"tool-calls"};case"length":return{kind:"max-tokens"};default:return{kind:"error",failure:{message:`model stopped: ${e}`,code:e.toUpperCase()}}}}s(ge,"mapFinishReason");function Ee(e){const n=e.prompt_tokens_details?.cached_tokens??e.prompt_cache_hit_tokens,t=e.completion_tokens_details?.reasoning_tokens;return{inputTokens:e.prompt_tokens-(n??0),outputTokens:e.completion_tokens,...n!==void 0?{cacheReadTokens:n}:{},...t!==void 0?{reasoningTokens:t}:{}}}s(Ee,"mapUsage");function ye(e){switch(e.kind){case"text":return{type:"text",text:e.text};case"reasoning":return{type:"reasoning",text:e.text};case"tool-call":return{type:"tool-call",id:R(e.callId??""),name:e.name??"",arguments:e.text}}}s(ye,"closeBlock");async function*ke(e){let n=0,t,o;const r=new Map,i=[];let p,u;function E(d){const a={index:n++,kind:d,text:""};return i.push(a),a}s(E,"open");for await(const d of e){if(d==="[DONE]"){for(const y of i)yield{type:"block-end",index:y.index,block:ye(y)};u&&(yield{type:"usage",usage:u});const h=p??{kind:"stop"};yield{type:"finish",reason:h.kind==="stop"&&i.length===0?{kind:"error",failure:{message:"model returned a completed response with no content",code:B}}:h};return}let a;try{a=JSON.parse(d)}catch{throw new g(`malformed SSE payload: ${d.slice(0,120)}`,"MALFORMED_RESPONSE")}for(const h of a.choices??[]){const y=h.delta,l=y?.reasoning_content;typeof l=="string"&&l.length>0&&(o||(o=E("reasoning"),yield{type:"block-start",index:o.index,blockType:"reasoning"}),o.text+=l,yield{type:"reasoning-delta",index:o.index,text:l});const f=y?.content;typeof f=="string"&&f.length>0&&(t||(t=E("text"),yield{type:"block-start",index:t.index,blockType:"text"}),t.text+=f,yield{type:"text-delta",index:t.index,text:f});for(const k of y?.tool_calls??[]){let c=r.get(k.index);c||(c=E("tool-call"),r.set(k.index,c),yield{type:"block-start",index:c.index,blockType:"tool-call"}),k.id!==void 0&&(c.callId=k.id),k.function?.name!==void 0&&(c.name=k.function.name);const b=k.function?.arguments??"";c.text+=b,yield{type:"tool-call-delta",index:c.index,id:R(c.callId??""),...c.name!==void 0?{name:c.name}:{},argumentsDelta:b}}typeof h.finish_reason=="string"&&(p=ge(h.finish_reason))}a.usage&&(u=Ee(a.usage))}throw new g("SSE payload stream ended without [DONE]","STREAM_CLOSED")}s(ke,"translate");var we=s(function(e,n,t){if(n!=null){if(typeof n!="object"&&typeof n!="function")throw new TypeError("Object expected.");var o,r;if(t){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=n[Symbol.asyncDispose]}if(o===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=n[Symbol.dispose],t&&(r=o)}if(typeof o!="function")throw new TypeError("Object not disposable.");r&&(o=s(function(){try{r.call(this)}catch(i){return Promise.reject(i)}},"dispose")),e.stack.push({value:n,dispose:o,async:t})}else t&&e.stack.push({async:!0});return n},"__addDisposableResource"),xe=(function(e){return function(n){function t(p){n.error=n.hasError?new e(p,n.error,"An error was suppressed during disposal."):p,n.hasError=!0}s(t,"fail");var o,r=0;function i(){for(;o=n.stack.pop();)try{if(!o.async&&r===1)return r=0,n.stack.push(o),Promise.resolve().then(i);if(o.dispose){var p=o.dispose.call(o.value);if(o.async)return r|=2,Promise.resolve(p).then(i,function(u){return t(u),i()})}else r|=1}catch(u){t(u)}if(r===1)return n.hasError?Promise.reject(n.error):Promise.resolve();if(n.hasError)throw n.error}return s(i,"next"),i()}})(typeof SuppressedError=="function"?SuppressedError:function(e,n,t){var o=new Error(t);return o.name="SuppressedError",o.error=e,o.suppressed=n,o});const D=3e5,T=1e6,N=256e3,A="LLM_STREAM_IDLE_TIMEOUT",_=w("off"),P=w("low"),M=w("high"),U=w("max"),Te=[{id:_,name:"Off"},{id:P,name:"Low"},{id:M,name:"High"},{id:U,name:"Max"}],_e=[{id:_,name:"Off"}];function F(e,n){return{provider:e,id:n.id,name:n.name??n.id,...n.description===void 0?{}:{description:n.description},inputModalities:["text"]}}s(F,"modelInfo");function Se(e){if(e===null)return;if(/^\d+$/.test(e)){const t=Number(e)*1e3;return Number.isFinite(t)&&t>0?t:void 0}const n=Date.parse(e)-Date.now();return Number.isFinite(n)&&n>0?n:void 0}s(Se,"providerRetryAfterMs");function ve(e){const n=e.get("x-request-id")??e.get("x-deepseek-request-id");return n===null||n.length===0?void 0:V(n)}s(ve,"requestId");function be(e,n){if(e===401||e===403)return"AUTH";const t=[n?.code,n?.type,n?.message].filter(Boolean).join(" ");return Z(t)?X:e===429?"RATE_LIMIT":e===400?Q(t)?G:"INVALID_REQUEST":e>=500?"SERVER":`HTTP_${e}`}s(be,"httpErrorCode");var L=class extends H{static{s(this,"DeepSeekAdapter")}config;constructor(e){super(),this.config=e}providerInfo(e){return{id:e,name:"DeepSeek"}}providerRetryPolicy(e){return this.config.options().retryPolicy}listModels(e){return Promise.resolve(this.config.options().models.map(n=>F(e,n)))}resolveModel(e,n,t){const o=this.config.options(),r=o.models.find(p=>p.id===n),i=r?.contextWindow??o.defaultContextWindow;return Promise.resolve({...r===void 0?{provider:e,id:n,name:n,inputModalities:["text"]}:F(e,r),context:{contextWindow:i},defaultMaxTokens:r?.maxTokens??o.maxTokens,...o.defaults.thinking==="disabled"?{reasoning:{efforts:_e,defaultEffort:_}}:{reasoning:{efforts:Te,defaultEffort:o.defaults.reasoningEffort==="off"?_:o.defaults.reasoningEffort==="low"?P:o.defaults.reasoningEffort==="max"?U:M}}})}async*stream(e){const n={stack:[],error:void 0,hasError:!1};try{const t=this.config.options(),o=await this.config.resolveApiKey(t),r=this.config.resolveUserId(),i=new AbortController,p=e.signal===void 0?i.signal:AbortSignal.any([e.signal,i.signal]),u=we(n,ie(p,t.streamIdleTimeoutMs,A),!1),E=this.request(e,u.signal,t,o,r,()=>{u.pulse()})[Symbol.asyncIterator]();let d=!1;try{for(;;){const a=await u.next(E);if(a.done){d=!0;return}yield a.value}}catch(a){throw se(u.signal,A)!==void 0?new g(`DeepSeek stream idle timeout after ${t.streamIdleTimeoutMs}ms`,"TIMEOUT",{cause:a}):e.signal?.aborted?new g("DeepSeek request aborted by caller","ABORTED",{cause:a}):a instanceof g?a:new g(`DeepSeek API stream from ${t.baseURL} failed`,"TRANSPORT",{cause:a})}finally{if(i.abort("DeepSeek stream consumer stopped"),!d&&E.return!==void 0)try{await E.return()}catch{}}}catch(t){n.error=t,n.hasError=!0}finally{xe(n)}}async*request(e,n,t,o,r,i){const p=me(e,t.defaults),u=JSON.stringify(p),E={authorization:`Bearer ${o}`,"content-type":"application/json",accept:"text/event-stream",...z(),"x-deepseek-harness-user-id":String(r),...e.sessionId!==void 0?{"x-deepseek-harness-session-id":String(e.sessionId)}:{},...e.purpose==="compaction"?{"x-deepseek-harness-compact":"1"}:{}};let d;try{d=await fetch(`${t.baseURL}/chat/completions`,{method:"POST",headers:E,body:u,signal:n})}catch(a){throw n.aborted?a:new g(`DeepSeek API request to ${t.baseURL} failed`,"TRANSPORT",{cause:a})}if(!d.ok){let a=`DeepSeek API error (HTTP ${d.status})`,h;try{h=(await d.json()).error,h?.message&&(a=h.message)}catch{}const y=Se(d.headers.get("retry-after")),l=ve(d.headers);throw new g(a,be(d.status,h),{status:d.status,...y===void 0?{}:{providerRetryAfterMs:y},...l===void 0?{}:{requestId:l}})}if(!d.body)throw new g("DeepSeek API returned no response body","EMPTY_RESPONSE");yield*ke(he(d.body,i))}};const Re="llm-deepseek",Ie=["llm"],C=re("llm-deepseek"),W="DEEPSEEK_API_KEY",S="deepseek-official",$=[{id:"deepseek-v4-flash",name:"DeepSeek-V4-Flash",contextWindow:T},{id:"deepseek-v4-pro",name:"DeepSeek-V4-Pro",contextWindow:T}],Oe=m.object({id:m.string().required(),name:m.string(),description:m.string(),contextWindow:m.number().step(1).min(1),maxTokens:m.number().step(1).min(1)}),j=m.object({apiKeyEnv:m.string().role("credential-ref").default(W),baseURL:m.string(),thinking:m.union(["enabled","disabled"]),reasoningEffort:m.union(["off","low","high","max"]),maxTokens:m.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(N),defaultContextWindow:m.number().step(1).min(1).default(T),models:m.array(Oe).default($),streamIdleTimeoutMs:m.number().min(Number.MIN_VALUE).max(v).default(D),retryPolicy:Y}),De="https://api.deepseek.com",Ne="DEEPSEEK_BASE_URL";function Ae(e){const n=new Set;return(e??$).map(t=>{if(t.id.length===0)throw new Error("llm-deepseek: catalog model ids must be non-empty");if(t.name!==void 0&&t.name.length===0)throw new Error(`llm-deepseek: catalog model "${t.id}" has an empty name`);if(t.contextWindow!==void 0&&(!Number.isInteger(t.contextWindow)||t.contextWindow<=0))throw new Error(`llm-deepseek: catalog model "${t.id}" contextWindow must be a positive integer`);if(t.maxTokens!==void 0&&(!Number.isInteger(t.maxTokens)||t.maxTokens<=0))throw new Error(`llm-deepseek: catalog model "${t.id}" maxTokens must be a positive integer`);if(n.has(t.id))throw new Error(`llm-deepseek: duplicate catalog model "${t.id}"`);return n.add(t.id),{id:t.id,...t.name===void 0?{}:{name:t.name},...t.description===void 0?{}:{description:t.description},...t.contextWindow===void 0?{}:{contextWindow:t.contextWindow},...t.maxTokens===void 0?{}:{maxTokens:t.maxTokens}}})}s(Ae,"resolveModels");function K(e,n){if(e.thinking==="disabled"&&e.reasoningEffort!==void 0&&e.reasoningEffort!=="off")throw new Error('llm-deepseek: only reasoningEffort "off" can be configured when thinking is disabled');if(e.defaultContextWindow!==void 0&&(!Number.isInteger(e.defaultContextWindow)||e.defaultContextWindow<=0))throw new Error("llm-deepseek: defaultContextWindow must be a positive integer");if(e.maxTokens!==void 0&&(!Number.isSafeInteger(e.maxTokens)||e.maxTokens<=0))throw new Error("llm-deepseek: maxTokens must be a positive safe integer");const t=e.streamIdleTimeoutMs??3e5;if(!Number.isFinite(t)||t<=0||t>v)throw new Error(`llm-deepseek: streamIdleTimeoutMs must be a positive finite number no greater than ${v}`);return{apiKeyEnv:te(e.apiKeyEnv??W),baseURL:e.baseURL??n?.get(Ne)?.value??"https://api.deepseek.com",defaults:{thinking:e.thinking,reasoningEffort:e.reasoningEffort},maxTokens:e.maxTokens??256e3,defaultContextWindow:e.defaultContextWindow??1e6,models:Ae(e.models),streamIdleTimeoutMs:t,retryPolicy:ee(e.retryPolicy,"llm-deepseek: retryPolicy")}}s(K,"resolveAdapterOptions");function Pe(e,n){let t=s(()=>n,"current"),o,r;const i=s(()=>{const l=t();if(l===o&&r!==void 0)return r;try{const f=K(l,O(e));return o=l,r=f,f}catch(f){if(r===void 0)throw f;return o=l,e.logger.error("llm-deepseek: keeping the last good configuration after an invalid settings section"),e.logger.error(f),r}},"options");i();const p=s(async l=>{const f=l.apiKeyEnv,k=e.get("credentials");if(k!==void 0){const c=await k.resolve(f);if(c!==void 0)return I(c.value,"llm-deepseek",f)}else{const c=O(e).get(f);if(c!==void 0&&c.value.length>0)return I(c.value,"llm-deepseek",f)}throw new g(`llm-deepseek: no API key for provider route "${S}"; store ${f} through the credentials service (the web Models page writes it), or export ${f} in the launching environment`,"MISSING_CREDENTIAL")},"resolveApiKey");let u;const E=s(()=>u??=ae(),"resolveUserId"),d=new L({options:i,resolveApiKey:p,resolveUserId:E});e.llm.registerConfigurableProviders([{provider:S,displayName:"DeepSeek",settingsNs:C,settingsPath:[]}]);const a=e.llm.registerAdapter([S],d);let h=i().retryPolicy;oe(e,C,j,n,{setSource:s(l=>{t=l},"setSource"),onChange:s(()=>{const l=i().retryPolicy;ne(l,h)||(a.replace([S]),h=l)},"ensureRegistrationFacts")})}s(Pe,"apply");export{j as Config,T as DEFAULT_CONTEXT_WINDOW,N as DEFAULT_MAX_TOKENS,D as DEFAULT_STREAM_IDLE_TIMEOUT_MS,L as DeepSeekAdapter,De as PUBLIC_BASE_URL,Pe as apply,Ie as inject,Re as name,K as resolveAdapterOptions};
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-llm-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-llm":"^0.0.15","@deepseek-ai/dsh-settings":"^0.0.15","@deepseek-ai/dsh-timeout":"^0.0.15","@deepseek-ai/dsh-credentials":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-anonymous-user-id":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"eventsource-parser":"^3.1.0","@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-llm-deepseek","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/dsh-launch-environment":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-timeout":"^0.1.0","@deepseek-ai/dsh-settings":"^0.1.0","@deepseek-ai/dsh-anonymous-user-id":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-credentials":"^0.1.0"},"dependencies":{"eventsource-parser":"^3.1.0","@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-llm-gateway-openai","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/cordis":"^4.0.1","@deepseek-ai/dsh-credentials":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-qb-auth":"^0.0.15","@deepseek-ai/dsh-content-review":"^0.0.15"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-llm-gateway-openai","version":"0.1.0","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/cordis":"^4.0.1","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-credentials":"^0.1.0","@deepseek-ai/dsh-qb-auth":"^0.1.0","@deepseek-ai/dsh-content-review":"^0.1.0"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- var le=Object.defineProperty;var s=(e,t)=>le(e,"name",{value:t,configurable:!0});import{launchEnvironmentOf as ce}from"@deepseek-ai/dsh-launch-environment";import{CONTEXT_WINDOW_EXCEEDED_CODE as ue,CallId as R,EMPTY_RESPONSE_CODE as pe,INVALID_CREDENTIAL_CODE as fe,LlmAdapter as me,LlmError as h,QUOTA_EXCEEDED_CODE as he,ReasoningEffortId as C,RetryPolicySchema as ge,assertUsableApiKey as ve,attributionHeaders as $,contentHasImage as S,isContextWindowExceededError as ye,isQuotaExceededError as be,normalizeApiKey as we,resolveRetryPolicy as Ee}from"@deepseek-ai/dsh-llm";import{deepEqualJson as D,installSettingsSection as ke,settingsNamespace as Re}from"@deepseek-ai/dsh-settings";import{createModels as xe,createProvider as Te,getSupportedThinkingLevels as I,isContextOverflow as Se}from"@earendil-works/pi-ai";import{MAX_TIMER_DELAY_MS as O,idleWatchdog as Ie,timeoutOf as j}from"@deepseek-ai/dsh-timeout";import{builtinProviders as Oe,getBuiltinModels as Me,getBuiltinProviders as Ae}from"@earendil-works/pi-ai/providers/all";import l from"@deepseek-ai/schemastery";import{credentialRef as _e}from"@deepseek-ai/dsh-credentials";import{anthropicMessagesApi as Le}from"@earendil-works/pi-ai/api/anthropic-messages.lazy";import{openAICompletionsApi as Ue}from"@earendil-works/pi-ai/api/openai-completions.lazy";import{openAIResponsesApi as Ne}from"@earendil-works/pi-ai/api/openai-responses.lazy";function F(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}catch{}return{}}s(F,"parseArguments");function W(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}s(W,"emptyPiUsage");function Pe(e){return{kind:"pi-ai",version:1,api:e.api,provider:e.provider,model:e.model,...e.responseModel===void 0?{}:{responseModel:e.responseModel},...e.responseId===void 0?{}:{responseId:e.responseId},stopReason:e.stopReason,blocks:e.content.map(t=>{switch(t.type){case"text":return{type:"text",...t.textSignature===void 0?{}:{textSignature:t.textSignature}};case"thinking":return{type:"reasoning",...t.thinkingSignature===void 0?{}:{thinkingSignature:t.thinkingSignature},...t.redacted===void 0?{}:{redacted:t.redacted}};case"toolCall":return{type:"tool-call",...t.thoughtSignature===void 0?{}:{thoughtSignature:t.thoughtSignature}}}})}}s(Pe,"toPiReplayState");function w(e){throw new h(`invalid pi-ai replay state: ${e}`,"INVALID_REPLAY_STATE")}s(w,"invalidReplay");function Ce(e){if(typeof e!="object"||e===null||Array.isArray(e))return w("expected an object");const t=e;if(t.kind!=="pi-ai")return w("unknown state kind");if(t.version!==1)return w(`unsupported version ${String(t.version)}`);for(const r of["api","provider","model"])if(typeof t[r]!="string"||t[r].length===0)return w(`${r} must be a non-empty string`);if(!["stop","length","toolUse","error","aborted"].includes(String(t.stopReason)))return w("unknown stopReason");if(t.responseModel!==void 0&&typeof t.responseModel!="string")return w("responseModel must be a string");if(t.responseId!==void 0&&typeof t.responseId!="string")return w("responseId must be a string");if(!Array.isArray(t.blocks))return w("blocks must be an array");for(const[r,o]of t.blocks.entries()){if(typeof o!="object"||o===null||Array.isArray(o))return w(`block ${r} must be an object`);const n=o;if(!["text","reasoning","tool-call"].includes(String(n.type)))return w(`block ${r} has an unknown type`);for(const a of["textSignature","thinkingSignature","thoughtSignature"])if(n[a]!==void 0&&typeof n[a]!="string")return w(`block ${r} ${a} must be a string`);if(n.redacted!==void 0&&typeof n.redacted!="boolean")return w(`block ${r} redacted must be boolean`)}return t}s(Ce,"readReplayState");function $e(e){const t=e.source.kind==="model"?e.source:void 0,r=[];for(const o of e.content)switch(o.type){case"text":r.push({type:"text",text:o.text});break;case"reasoning":r.push({type:"thinking",thinking:o.text});break;case"tool-call":r.push({type:"toolCall",id:o.id,name:o.name,arguments:F(o.arguments)});break;case"image":throw new h("pi-ai chat history cannot represent structured assistant image output","UNSUPPORTED_CONTENT")}return{role:"assistant",content:r,api:"dsh-foreign",provider:t?.provider??"dsh-foreign",model:t?.model??"dsh-foreign",usage:W(),stopReason:r.some(o=>o.type==="toolCall")?"toolUse":"stop",timestamp:0}}s($e,"foreignAssistant");function De(e,t,r){const o=Ce(r);return o.provider!==t.provider?w("provider does not match assistant source"):o.model!==t.model?w("model does not match assistant source"):o.blocks.length!==e.content.length?w("block count does not match assistant content"):{role:"assistant",content:e.content.map((n,a)=>{const i=o.blocks[a];if(i===void 0||i.type!==n.type)return w(`block ${a} does not match assistant content`);switch(n.type){case"text":return{type:"text",text:n.text,...i.type==="text"&&i.textSignature!==void 0?{textSignature:i.textSignature}:{}};case"reasoning":return{type:"thinking",thinking:n.text,...i.type==="reasoning"&&i.thinkingSignature!==void 0?{thinkingSignature:i.thinkingSignature}:{},...i.type==="reasoning"&&i.redacted!==void 0?{redacted:i.redacted}:{}};case"tool-call":return{type:"toolCall",id:n.id,name:n.name,arguments:F(n.arguments),...i.type==="tool-call"&&i.thoughtSignature!==void 0?{thoughtSignature:i.thoughtSignature}:{}};default:return w(`block ${a} has an unsupported Harness type`)}}),api:o.api,provider:o.provider,model:o.model,...o.responseModel===void 0?{}:{responseModel:o.responseModel},...o.responseId===void 0?{}:{responseId:o.responseId},usage:W(),stopReason:o.stopReason,timestamp:0}}s(De,"replayedAssistant");function K(e){const t=e.source;return t.kind!=="model"||t.replayState===void 0?$e(e):De(e,t,t.replayState)}s(K,"toPiAssistant");function M(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}s(M,"flattenText");function B(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool-result"?B(t.content):"").join("")}s(B,"toolResultText");async function A(e,t){const r=[];for(const o of e)switch(o.type){case"text":o.text.length>0&&r.push({type:"text",text:o.text});break;case"image":{const n=await t.readImage(o.attachment);r.push({type:"image",data:Buffer.from(n.data).toString("base64"),mimeType:n.ref.mediaType});break}case"tool-result":{const n=await A(o.content,t);typeof n=="string"?n.length>0&&r.push({type:"text",text:n}):r.push(...n)}}return r.every(o=>o.type==="text")?r.map(o=>o.text).join(""):r}s(A,"userContent");function je(e){return e.tools?.map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}s(je,"toolsOf");function V(e,t){const r=je(e);return{...e.system!==void 0?{systemPrompt:e.system}:{},messages:t,...r!==void 0&&r.length>0?{tools:r}:{}}}s(V,"piContext");function Fe(e){const t=new Map,r=[];for(const o of e.messages){if(S(o.content))throw new h("pi-ai image conversion requires the durable attachment service","UNSUPPORTED_CONTENT");if(o.role==="system"){r.push({role:"user",content:M(o),timestamp:0});continue}if(o.role==="assistant"){const i=K(o);for(const d of i.content)d.type==="toolCall"&&t.set(R(d.id),d.name);r.push(i);continue}const n=M(o),a=o.content.filter(i=>i.type==="tool-result");(n.length>0||a.length===0)&&r.push({role:"user",content:n,timestamp:0});for(const i of a)r.push({role:"toolResult",toolCallId:i.toolCallId,toolName:t.get(i.toolCallId)??"unknown",content:[{type:"text",text:B(i.content)||"(no output)"}],isError:i.isError??!1,timestamp:0})}return V(e,r)}s(Fe,"textOnlyContext");function Y(e,t){return t===void 0?Fe(e):We(e,t)}s(Y,"toPiContext");async function We(e,t){const r=new Map,o=[];for(const n of e.messages){if(n.role==="system"){if(S(n.content))throw new h("pi-ai cannot represent an image in an in-history system message","UNSUPPORTED_CONTENT");o.push({role:"user",content:M(n),timestamp:0});continue}if(n.role==="assistant"){const d=K(n);for(const f of d.content)f.type==="toolCall"&&r.set(R(f.id),f.name);o.push(d);continue}const a=await A(n.content.filter(d=>d.type!=="tool-result"),t),i=n.content.filter(d=>d.type==="tool-result");(a.length>0||i.length===0)&&o.push({role:"user",content:a,timestamp:0});for(const d of i){const f=await A(d.content,t);o.push({role:"toolResult",toolCallId:d.toolCallId,toolName:r.get(d.toolCallId)??"unknown",content:typeof f=="string"?[{type:"text",text:f||"(no output)"}]:f,isError:d.isError??!1,timestamp:0})}}return V(e,o)}s(We,"toPiContextWithImages");function H(e){return{inputTokens:e.input,outputTokens:e.output,...e.cacheRead>0?{cacheReadTokens:e.cacheRead}:{},...e.cacheWrite>0?{cacheWriteTokens:e.cacheWrite}:{}}}s(H,"mapUsage");function Ke(e){return/\b(?:401|403)\b/.test(e)?"AUTH":be(e)?he:/\b429\b|rate.?limit/i.test(e)?"RATE_LIMIT":/\b400\b|invalid.?request/i.test(e)?"INVALID_REQUEST":/\b5\d\d\b/.test(e)?"SERVER":/\btime(?:d)?\s*out\b|timeout/i.test(e)?"TIMEOUT":/stream ended (?:before|without)\b/i.test(e)||/\b(?:network|connection|socket|fetch)\b|\bECONN[A-Z]+\b/i.test(e)||/\b(?:other side closed|HTTP2 request did not get a response|WebSocket closed unexpectedly)\b/i.test(e)||/\bterminated\b|premature close/i.test(e)?"TRANSPORT":"PI_AI_ERROR"}s(Ke,"classifyPiAiError");function z(e,t){const r=Se(e,t),o=e.stopReason==="error"&&e.errorMessage!==void 0&&ye(e.errorMessage);if(r||o)return{kind:"error",failure:{message:e.errorMessage??`pi-ai detected context overflow for model "${e.model}"`,code:ue}};switch(e.stopReason){case"pending":return{kind:"error",failure:{message:"pi-ai terminal message remained pending",code:"PI_AI_ERROR"}};case"stop":return e.content.length===0?{kind:"error",failure:{message:`model "${e.model}" returned a completed response with no content`,code:pe}}:{kind:"stop"};case"length":return{kind:"max-tokens"};case"toolUse":return{kind:"tool-calls"};case"aborted":return{kind:"aborted",failure:{message:e.errorMessage??"pi-ai stream aborted",code:"ABORTED"}};case"error":{const n=e.errorMessage??"pi-ai stream error";return{kind:"error",failure:{message:n,code:Ke(n)}}}}}s(z,"mapStopReason");async function*Be(e,t){const r=new Map;for await(const o of e)switch(o.type){case"start":break;case"text_start":yield{type:"block-start",index:o.contentIndex,blockType:"text"};break;case"text_delta":yield{type:"text-delta",index:o.contentIndex,text:o.delta};break;case"text_end":yield{type:"block-end",index:o.contentIndex,block:{type:"text",text:o.content}};break;case"thinking_start":yield{type:"block-start",index:o.contentIndex,blockType:"reasoning"};break;case"thinking_delta":yield{type:"reasoning-delta",index:o.contentIndex,text:o.delta};break;case"thinking_end":yield{type:"block-end",index:o.contentIndex,block:{type:"reasoning",text:o.content}};break;case"toolcall_start":{const n=o.partial.content[o.contentIndex],a=n?.type==="toolCall"?n.id:"",i=n?.type==="toolCall"?n.name:"";r.set(o.contentIndex,{id:a,name:i}),yield{type:"block-start",index:o.contentIndex,blockType:"tool-call"};break}case"toolcall_delta":{const n=r.get(o.contentIndex);yield{type:"tool-call-delta",index:o.contentIndex,id:R(n?.id??""),...n?.name!==void 0&&n.name.length>0?{name:n.name}:{},argumentsDelta:o.delta};break}case"toolcall_end":yield{type:"block-end",index:o.contentIndex,block:{type:"tool-call",id:R(o.toolCall.id),name:o.toolCall.name,arguments:JSON.stringify(o.toolCall.arguments)}};break;case"done":yield{type:"usage",usage:H(o.message.usage)},yield{type:"finish",reason:z(o.message,t),replayState:Pe(o.message)};return;case"error":yield{type:"usage",usage:H(o.error.usage)},yield{type:"finish",reason:z(o.error,t)};return}throw new h("pi-ai event stream ended without done/error","STREAM_CLOSED")}s(Be,"toStreamChunks");var Ve=s(function(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var o,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=t[Symbol.asyncDispose]}if(o===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=t[Symbol.dispose],r&&(n=o)}if(typeof o!="function")throw new TypeError("Object not disposable.");n&&(o=s(function(){try{n.call(this)}catch(a){return Promise.reject(a)}},"dispose")),e.stack.push({value:t,dispose:o,async:r})}else r&&e.stack.push({async:!0});return t},"__addDisposableResource"),Ye=(function(e){return function(t){function r(i){t.error=t.hasError?new e(i,t.error,"An error was suppressed during disposal."):i,t.hasError=!0}s(r,"fail");var o,n=0;function a(){for(;o=t.stack.pop();)try{if(!o.async&&n===1)return n=0,t.stack.push(o),Promise.resolve().then(a);if(o.dispose){var i=o.dispose.call(o.value);if(o.async)return n|=2,Promise.resolve(i).then(a,function(d){return r(d),a()})}else n|=1}catch(d){r(d)}if(n===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return s(a,"next"),a()}})(typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var o=new Error(r);return o.name="SuppressedError",o.error=e,o.suppressed=t,o});function He(e,t,r){const o=t==="off"?void 0:t;return{...r===void 0?{}:{apiKey:r},...o===void 0?{}:{reasoning:o},...e.thinkingBudgets===void 0?{}:{thinkingBudgets:e.thinkingBudgets},...e.cacheRetention===void 0?{}:{cacheRetention:e.cacheRetention},...e.transport===void 0?{}:{transport:e.transport},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.websocketConnectTimeoutMs===void 0?{}:{websocketConnectTimeoutMs:e.websocketConnectTimeoutMs},maxRetries:0}}s(He,"profileOptions");function ze(e,t){if(t!==void 0)return I(e).some(r=>r===t)?t:void 0}s(ze,"describableReasoningLevel");function Xe(e,t){if(t!==void 0){if(I(e).some(r=>r===t))return t;throw new h(`pi-ai provider "${e.provider}" model "${e.id}" does not support reasoning effort "${t}"`,"UNSUPPORTED_REASONING_EFFORT")}}s(Xe,"resolveReasoningLevel");function Ge(e,t){return e.reasoning?{reasoning:{efforts:I(e).map(r=>({id:C(r),name:`${r.charAt(0).toUpperCase()}${r.slice(1)}`})),...t===void 0?{}:{defaultEffort:C(t)}}}:{}}s(Ge,"reasoningInfo");function Je(e){const t=$(),r=new Set(Object.keys(t).map(o=>o.toLowerCase()));return{...Object.fromEntries(Object.entries(e??{}).filter(([o])=>!r.has(o.toLowerCase()))),...t}}s(Je,"requestHeaders");var X=class extends me{static{s(this,"PiAiAdapter")}config;snapshot;constructor(e){super(),this.config=e}current(){const e=this.config.profiles();if(this.snapshot?.profiles===e)return this.snapshot;const t=xe();for(const r of e.values())t.setProvider(r.piProvider);return this.snapshot={profiles:e,models:t},this.snapshot}profileOf(e,t){const r=e.profiles.get(t);if(r===void 0)throw new h(`pi-ai adapter does not own provider "${t}"`,"NO_ADAPTER");return r}modelOf(e,t,r){this.profileOf(e,t);const o=e.models.getModel(t,r);if(o===void 0)throw new h(`pi-ai provider "${t}" has no configured model "${r}"`,"UNKNOWN_MODEL");return o}serviceRoutedModel(e,t){const r=e.baseURLService;if(r===void 0)return t;const o=this.config.resolveServiceBaseURL?.(r);if(o===void 0)throw new h(`pi-ai provider "${e.provider}" follows service "${r}", which is not mounted or exposes no baseURL`,"SERVICE_UNAVAILABLE");return{...t,baseUrl:o}}providerInfo(e){return{id:e,name:this.current().profiles.get(e)?.displayName??e}}providerRetryPolicy(e){return this.current().profiles.get(e)?.retryPolicy}listModels(e){return Promise.resolve().then(()=>{const t=this.current();return this.profileOf(t,e),t.models.getModels(e).map(r=>({provider:e,id:r.id,name:r.name,inputModalities:[...r.input]}))})}resolveModel(e,t,r){return Promise.resolve().then(()=>{const o=this.current(),n=this.profileOf(o,e),a=this.modelOf(o,e,t),i=ze(a,n.reasoning),d=n.configuredMaxTokens.get(t);return{provider:e,id:t,name:a.name,inputModalities:[...a.input],context:{contextWindow:a.contextWindow},...d===void 0?{}:{defaultMaxTokens:d},...Ge(a,i)}})}async*stream(e){const t={stack:[],error:void 0,hasError:!1};try{if(e.stop!==void 0)throw new h("llm-pi-ai does not support GenerateOptions.stop","UNSUPPORTED_OPTION");const r=this.current(),o=this.profileOf(r,e.provider),n=this.serviceRoutedModel(o,this.modelOf(r,e.provider,e.model)),a=Xe(n,e.reasoningEffort??o.reasoning),i=await this.config.resolveApiKey(e.provider,o),d=new AbortController,f=e.signal===void 0?d.signal:AbortSignal.any([e.signal,d.signal]),p=o.streamIdleTimeoutMs,v=Ve(t,Ie(f,p,"LLM_STREAM_IDLE_TIMEOUT"),!1);try{const E=e.messages.some(m=>S(m.content));if(E&&!n.input.includes("image"))throw new h(`pi-ai model "${n.id}" does not support image input`,"UNSUPPORTED_CONTENT");const c=E?this.config.resolveAttachments?.():void 0;if(E&&c===void 0)throw new h("pi-ai image input requires the durable attachment service","UNSUPPORTED_CONTENT");const g=c===void 0?Y(e):await Y(e,c),k=Be(r.models.streamSimple(n,g,{...He(o,a,i),...e.temperature===void 0?{}:{temperature:e.temperature},...e.maxTokens===void 0?{}:{maxTokens:e.maxTokens},...e.sessionId===void 0?{}:{sessionId:String(e.sessionId)},signal:v.signal,headers:Je(o.headers)}),n.contextWindow)[Symbol.asyncIterator]();let u=!1;try{for(;;){const m=await v.next(k),b=j(v.signal,"LLM_STREAM_IDLE_TIMEOUT");if(b!==void 0)throw b;if(m.done){u=!0;return}yield m.value}}finally{if(!u){d.abort("pi-ai stream consumer stopped");try{await k.return(void 0)}catch{}}}}catch(E){throw j(v.signal,"LLM_STREAM_IDLE_TIMEOUT")!==void 0?new h(`pi-ai stream idle timeout after ${p}ms`,"TIMEOUT",{cause:E}):e.signal?.aborted?new h("pi-ai request aborted by caller","ABORTED",{cause:E}):E}finally{d.abort("pi-ai stream consumer stopped")}}catch(r){t.error=r,t.hasError=!0}finally{Ye(t)}}};const Qe={input:0,output:0,cacheRead:0,cacheWrite:0},G=Object.keys({text:!0,image:!0});function Ze(e){return e===void 0||e.length===0?void 0:[...e]}s(Ze,"declaredInput");const x=Object.keys({off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0}),qe=Object.keys({openai:!0,deepseek:!0,openrouter:!0,together:!0,zai:!0,qwen:!0,"string-thinking":!0,"ant-ling":!0});let J;function Q(){return J??=new Map(Oe().map(e=>[e.id,e])),J}s(Q,"catalogProviders");function _(e){return Q().get(e)}s(_,"catalogProvider");function et(){return Ae()}s(et,"catalogProviderIds");function tt(e){return _(e)?.auth.apiKey!==void 0}s(tt,"catalogProviderTakesApiKey");function Z(e){if(!Q().has(e))return new Map;const t=Me(e);return new Map(t.map(r=>[r.id,r]))}s(Z,"catalogModels");function y(e,t){throw new Error(`llm-pi-ai: provider "${e}" ${t}`)}s(y,"invalid");function ot(e){const t=new Set;for(const r of e.values())t.add(r.api);return t.size===1?[...t][0]:void 0}s(ot,"sharedCatalogApi");function nt(e,t,r){const o=t.reasoningEfforts;if(o===void 0)return{reasoning:r?.reasoning??!1};if(o===!1)return{reasoning:!1};(o===null||Object.keys(o).length===0)&&y(e,`model "${t.id}" has an empty reasoningEfforts; declare the offered levels, set false for a non-reasoning model, or omit the field to keep the installed catalog's capability`);const n=x.flatMap(i=>{const d=o[i];return d===void 0?[]:[[i,d]]});for(const[i,d]of n)d===null?i!=="off"&&y(e,`model "${t.id}" reasoningEfforts.${i} needs the wire value dispatch should send; only "off" may leave it empty`):d.length===0&&y(e,`model "${t.id}" reasoningEfforts.${i} must not be an empty string`);n.some(([i])=>i!=="off")||y(e,`model "${t.id}" reasoningEfforts offers no level beyond "off"; declare a thinking level, or set reasoningEfforts to false for a non-reasoning model`);const a={};for(const i of x){const d=o[i];d===void 0?a[i]=null:d!==null&&(a[i]=d)}return{reasoning:!0,thinkingLevelMap:a}}s(nt,"resolveModelReasoning");function rt(e,t,r,o,n){const a=t.compat?.thinkingFormat??r?.thinkingFormat,i=t.compat?.supportsReasoningEffort??r?.supportsReasoningEffort;return a===void 0&&i===void 0?{}:n!=="openai-completions"?((t.compat?.thinkingFormat!==void 0||t.compat?.supportsReasoningEffort!==void 0)&&y(e,`model "${t.id}" sets compat reasoning switches, but its api is "${n}"; thinkingFormat and supportsReasoningEffort exist only on openai-completions`),{}):{compat:{...o?.api===n?o.compat:void 0,...a===void 0?{}:{thinkingFormat:a},...i===void 0?{}:{supportsReasoningEffort:i}}}}s(rt,"resolveModelCompat");function it(e){const{provider:t}=e,r=Z(t),o=_(t)?.baseUrl,n=e.models??[],a=e.modelOverrides??{};for(const[c,g]of Object.entries(a))c.length===0&&y(t,"has a modelOverrides entry with an empty model id"),r.size===0&&y(t,`sets modelOverrides for "${c}", but the installed catalog does not describe this route; a declared route spells every model out in its models list`),n.length>0&&y(t,`sets modelOverrides for "${c}" beside a models list; models already replaces the served catalog, so declare the fields on its entries`),r.has(c)||y(t,`modelOverrides names "${c}", which the installed catalog does not describe`),"id"in g&&y(t,`modelOverrides entry "${c}" sets "id", which is the dict key`);const i=n.length>0?n:[...r.values()].map(c=>({id:c.id,...a[c.id]}));i.length===0&&y(t,"resolves no models; the installed catalog does not describe this route, so its models must be listed in configuration");const d=ot(r),f=e.compat?.thinkingFormat!==void 0||e.compat?.supportsReasoningEffort!==void 0,p=new Set,v=new Map,E=i.map(c=>{c.id.length===0&&y(t,"has a model with an empty id"),p.has(c.id)&&y(t,`lists model "${c.id}" more than once`),p.add(c.id);const g=r.get(c.id),k=e.api??g?.api??d;k===void 0&&y(t,`model "${c.id}" needs an api; the installed catalog does not describe it, so set the route's api to the wire protocol its endpoint speaks`);const u=e.baseURL??g?.baseUrl??o;u===void 0&&y(t,`model "${c.id}" needs a baseURL; the installed catalog does not describe this route`);const m=c.contextWindow??g?.contextWindow??e.defaultContextWindow;(!Number.isInteger(m)||m<=0)&&y(t,`model "${c.id}" contextWindow must be a positive integer`);const b=c.maxTokens??g?.maxTokens??e.defaultMaxTokens;return(!Number.isInteger(b)||b<=0)&&y(t,`model "${c.id}" maxTokens must be a positive integer`),c.maxTokens!==void 0&&v.set(c.id,c.maxTokens),{...g,id:c.id,name:c.name??g?.name??c.id,api:k,provider:t,baseUrl:u,input:Ze(c.input)??g?.input??[...e.defaultInput],cost:g?.cost??Qe,contextWindow:m,maxTokens:b,...nt(t,c,g),...rt(t,c,e.compat,g,k)}});return f&&!E.some(c=>c.api==="openai-completions")&&y(t,"sets compat reasoning switches, but no model on the route speaks openai-completions; thinkingFormat and supportsReasoningEffort exist only on that protocol"),{models:E,configuredMaxTokens:v}}s(it,"resolveRouteModels");const q={"openai-completions":Ue,"openai-responses":Ne,"anthropic-messages":Le};function L(){return Object.keys(q)}s(L,"supportedProtocols");function ee(e){return{name:e,resolve:s(({credential:t})=>Promise.resolve({auth:t?.key===void 0?{}:{apiKey:t.key},source:e}),"resolve")}}s(ee,"harnessApiKeyAuth");function te(e,t){return t===void 0?{apiKey:ee(e.displayName)}:t.auth.apiKey!==void 0||!e.namesCredential?t.auth:{...t.auth,apiKey:ee(e.displayName)}}s(te,"routeAuth");function st(e,t){const r=t.baseURL??e.baseUrl;return{id:t.provider,name:t.displayName,...r===void 0?{}:{baseUrl:r},auth:te(t,e),getModels:s(()=>t.models,"getModels"),stream:s((o,n,a)=>e.stream(o,n,a),"stream"),streamSimple:s((o,n,a)=>e.streamSimple(o,n,a),"streamSimple")}}s(st,"reuseCatalogProvider");function at(e){const t=_(e.provider);if(t!==void 0&&e.api===void 0)return st(t,e);const r=e.api===void 0?void 0:q[e.api];if(r===void 0)throw new Error(`llm-pi-ai: provider "${e.provider}" names api "${e.api}", which this build cannot serve; supported protocols are ${L().join(", ")}`);return Te({id:e.provider,name:e.displayName,...e.baseURL===void 0?{}:{baseUrl:e.baseURL},auth:te(e,t),models:e.models,api:r()})}s(at,"buildProvider");const dt=3e5,lt=262144,ct="http://127.0.0.1:9",ut=32768,oe=["text"],pt=l.object({minimal:l.number(),low:l.number(),medium:l.number(),high:l.number()}),ne=l.object({thinkingFormat:l.union(qe),supportsReasoningEffort:l.boolean()}),ft=l.dict(l.union([l.string(),l.const(null)]),l.union(x)),re={name:l.string(),contextWindow:l.number().step(1).min(1),maxTokens:l.number().step(1).min(1),input:l.array(l.union(G)),reasoningEfforts:l.union([l.const(!1),ft]),compat:ne},mt=l.object({id:l.string().required(),...re}),ht=l.object(re),gt=l.object({apiKeyEnv:l.string().role("credential-ref"),displayName:l.string(),api:l.union(L()),baseURL:l.string(),baseURLService:l.string(),models:l.array(mt),modelOverrides:l.dict(ht),compat:ne,defaultContextWindow:l.number().step(1).min(1).default(lt),defaultMaxTokens:l.number().step(1).min(1).default(ut),defaultInput:l.array(l.union(G)).default([...oe]),headers:l.dict(l.string()),reasoning:l.union(x),thinkingBudgets:pt,cacheRetention:l.union(["none","short","long"]),transport:l.union(["sse","websocket","websocket-cached","auto"]),timeoutMs:l.natural(),websocketConnectTimeoutMs:l.natural(),streamIdleTimeoutMs:l.number().min(Number.MIN_VALUE).max(O).default(dt),retryPolicy:ge}),ie=l.object({providers:l.dict(gt).default({})});function vt(e){se(e.providers)}s(vt,"assertServiceable");function yt(e,t){const r=t;if("provider"in r)throw new Error(`llm-pi-ai: provider "${e}" sets "provider", which moved to the providers dict key`);if("maxRetries"in r||"maxRetryDelayMs"in r)throw new Error(`llm-pi-ai: provider "${e}" sets maxRetries or maxRetryDelayMs, which were removed; compose agent recovery with dsh-llm-retry`)}s(yt,"rejectRemovedFields");function se(e){if(Array.isArray(e))throw new Error("llm-pi-ai: providers is now a dict keyed by provider route, not an array of profiles");const t=Object.entries(e??{}),r=new Map;for(const[o,n]of t){if(yt(o,n),o.length===0)throw new Error("llm-pi-ai: provider names must be non-empty");if(n.baseURL!==void 0&&n.baseURL.length===0)throw new Error(`llm-pi-ai: provider "${o}" has an empty baseURL`);if(n.baseURL!==void 0&&n.baseURLService!==void 0)throw new Error(`llm-pi-ai: provider "${o}" sets both baseURL and baseURLService; name at most one endpoint source`);if(n.baseURLService!==void 0&&n.baseURLService.length===0)throw new Error(`llm-pi-ai: provider "${o}" has an empty baseURLService`);if(n.displayName!==void 0&&n.displayName.length===0)throw new Error(`llm-pi-ai: provider "${o}" has an empty displayName`);const a=n.streamIdleTimeoutMs??3e5;if(!Number.isFinite(a)||a<=0||a>O)throw new Error(`llm-pi-ai: provider "${o}" streamIdleTimeoutMs must be a positive finite number no greater than ${O}`);const i=[...n.defaultInput??oe];if(i.length===0)throw new Error(`llm-pi-ai: provider "${o}" defaultInput must name at least one modality`);const d=n.displayName??o,f=it({provider:o,...n.api===void 0?{}:{api:n.api},...n.baseURL===void 0?{}:{baseURL:n.baseURL},...n.baseURLService===void 0?{}:{baseURL:ct},...n.models===void 0?{}:{models:n.models},...n.modelOverrides===void 0?{}:{modelOverrides:n.modelOverrides},...n.compat===void 0?{}:{compat:n.compat},defaultInput:i,defaultContextWindow:n.defaultContextWindow??262144,defaultMaxTokens:n.defaultMaxTokens??32768}),{apiKeyEnv:p,retryPolicy:v,models:E,displayName:c,...g}=n;r.set(o,{...g,provider:o,displayName:d,...p===void 0?{}:{apiKeyEnv:_e(p)},streamIdleTimeoutMs:a,retryPolicy:Ee(v,`llm-pi-ai: provider "${o}" retryPolicy`),...g.headers===void 0?{}:{headers:{...g.headers}},...g.thinkingBudgets===void 0?{}:{thinkingBudgets:{...g.thinkingBudgets}},configuredMaxTokens:f.configuredMaxTokens,piProvider:at({provider:o,displayName:d,...n.api===void 0?{}:{api:n.api},...n.baseURL===void 0?{}:{baseURL:n.baseURL},models:f.models,namesCredential:p!==void 0})})}return r}s(se,"resolveProfiles");const bt=new Set(["openai-completions","openai-responses"]),U=4194304;function ae(...e){for(const t of e)if(typeof t=="number"&&Number.isInteger(t)&&t>0)return t}s(ae,"capacity");function de(...e){for(const t of e)if(typeof t=="string"&&t.length>0)return t}s(de,"label");function wt(e){return`${e.replace(/\/+$/,"")}/models`}s(wt,"listingUrl");async function Et(e,t){const r=s(()=>new h(`${t} answered with more than ${U} bytes`,"DISCOVERY_FAILED"),"oversized"),o=Number(e.headers.get("content-length")??NaN);if(Number.isFinite(o)&&o>U)throw await e.body?.cancel(),r();if(e.body===null)return"";const n=e.body.getReader(),a=[];let i=0;try{for(;;){const{done:p,value:v}=await n.read();if(p)break;if(i+=v.byteLength,i>U)throw r();a.push(v)}}finally{await n.cancel().catch(()=>{})}const d=new Uint8Array(i);let f=0;for(const p of a)d.set(p,f),f+=p.byteLength;return new TextDecoder().decode(d)}s(Et,"readBounded");function kt(e){const t=e?.data;if(!Array.isArray(t))throw new h(`the endpoint's model listing has no "data" array; enter this provider's models by hand`,"DISCOVERY_FAILED");const r=[];for(const o of t){const n=o,a=de(n?.id);if(a===void 0)continue;const i=de(n?.name,n?.display_name),d=ae(n?.context_window,n?.context_length),f=ae(n?.max_output_tokens,n?.max_tokens);r.push({id:a,...i===void 0?{}:{name:i},...d===void 0?{}:{contextWindow:d},...f===void 0?{}:{maxTokens:f}})}return r}s(kt,"readListing");function Rt(e){const t=we(e);if(t.ok)return t.value;throw new h(t.reason==="empty"?"this provider's API key is blank; enter it on the Models page, or clear it to probe unauthenticated":"this provider's API key contains characters no HTTP header can carry; paste the raw key only",fe)}s(Rt,"usableProbeKey");async function xt(e,t){if(e.provider!==void 0){const p=Z(e.provider);if(p.size>0)return[...p.values()].map(v=>({id:v.id,name:v.name,contextWindow:v.contextWindow,maxTokens:v.maxTokens}))}if(e.baseURL===void 0||e.baseURL.length===0)throw new h(`pi-ai ships no catalog for provider "${e.provider??""}", so its models can only come from its endpoint; set a baseURL, or enter this provider's models by hand`,"DISCOVERY_FAILED");const r=e.api??"openai-completions";if(!bt.has(r))throw new h(`pi-ai protocol "${r}" has no model listing this build can read; enter this provider's models by hand`,"DISCOVERY_UNSUPPORTED");const o=wt(e.baseURL),n=e.apiKey??await t?.(),a=n===void 0?void 0:Rt(n);let i;try{i=await fetch(o,{method:"GET",headers:{accept:"application/json",...a===void 0?{}:{authorization:`Bearer ${a}`},...$()},...e.signal===void 0?{}:{signal:e.signal}})}catch(p){throw e.signal?.aborted?new h("model discovery aborted by caller","ABORTED",{cause:p}):new h(`could not reach ${o}`,"DISCOVERY_FAILED",{cause:p})}if(!i.ok)throw new h(`${o} answered ${i.status}${i.status===401||i.status===403?"; check the API key":""}`,"DISCOVERY_FAILED");let d;try{d=await Et(i,o)}catch(p){throw e.signal?.aborted?new h("model discovery aborted by caller","ABORTED",{cause:p}):p}let f;try{f=JSON.parse(d)}catch(p){throw new h(`${o} did not answer with JSON`,"DISCOVERY_FAILED",{cause:p})}return kt(f)}s(xt,"discoverModels");const Tt="llm-pi-ai",St=["llm"],N=Re("llm-pi-ai");function It(e){return[...e.entries()].map(([t,r])=>({provider:t,displayName:r.displayName,retryPolicy:r.retryPolicy})).sort((t,r)=>t.provider.localeCompare(r.provider))}s(It,"registrationFacts");function Ot(e){const t=new Set(et()),r=new Map,o=s((n,a)=>{r.set(n,{provider:n,displayName:a,settingsNs:N,settingsPath:["providers",n],declared:!t.has(n)})},"declare");for(const n of t)tt(n)&&o(n,n);for(const[n,a]of e)o(n,a.displayName);return[...r.values()]}s(Ot,"directoryEntries");function Mt(e,t){let r=s(()=>t,"current"),o,n;const a=s(()=>{const u=r();if(u===o&&n!==void 0)return n;const m=se(u.providers);return o=u,n=m,m},"profiles");a();const i=s(async(u,m)=>{const b=m.apiKeyEnv;if(b===void 0)return;const P=e.get("credentials"),T=P!==void 0?(await P.resolve(b))?.value:ce(e).get(b)?.value;if(T!==void 0&&T.length>0)return ve(T,"llm-pi-ai",b);throw new h(`llm-pi-ai: no credential for provider route "${u}"; its profile resolves ${b}, which is not set — store ${b} through the credentials service (the web Models page writes it) or export it, and remove apiKeyEnv only if this provider should authenticate from pi-ai's own environment discovery`,"MISSING_CREDENTIAL")},"resolveApiKey"),d=new X({profiles:a,resolveApiKey:i,resolveAttachments:s(()=>e.get("attachments"),"resolveAttachments"),resolveServiceBaseURL:s(u=>{const m=e.get(u);if(m==null)return;const b=m.baseURL;return typeof b=="string"&&b.length>0?b:void 0},"resolveServiceBaseURL")});let f,p;const v=s(()=>{const u=Ot(a());D(u,p)||(f===void 0?f=e.llm.registerConfigurableProviders(u):f.replace(u),p=u)},"ensureDirectory");v();const E=s(async u=>{if(u===void 0)return;const m=a().get(u);if(m!==void 0)return i(u,m)},"storedApiKey");e.llm.registerModelDiscovery(N,u=>xt(u,()=>E(u.provider)));let c,g;const k=s(()=>{const u=It(a());if(D(u,g))return;const m=[...a().keys()];if(c===void 0){if(m.length===0){g=u;return}c=e.llm.registerAdapter(m,d)}else c.replace(m);g=u},"ensureRegistrationFacts");k(),ke(e,N,ie,t,{validate:vt,setSource:s(u=>{r=u},"setSource"),onChange:s(()=>{try{k()}catch(u){e.logger.error("llm-pi-ai: keeping the previously registered routes after a refused update"),e.logger.error(u)}try{v()}catch(u){e.logger.error("llm-pi-ai: keeping the previous configurable-provider directory after a refused update"),e.logger.error(u)}},"onChange")})}s(Mt,"apply");export{ie as Config,X as PiAiAdapter,Mt as apply,St as inject,Tt as name,L as supportedProtocols};
1
+ var ce=Object.defineProperty;var s=(e,t)=>ce(e,"name",{value:t,configurable:!0});import{launchEnvironmentOf as ue}from"@deepseek-ai/dsh-launch-environment";import{CONTEXT_WINDOW_EXCEEDED_CODE as pe,CallId as x,EMPTY_RESPONSE_CODE as fe,INVALID_CREDENTIAL_CODE as me,LlmAdapter as he,LlmError as m,QUOTA_EXCEEDED_CODE as ge,ReasoningEffortId as C,RetryPolicySchema as ve,assertUsableApiKey as ye,attributionHeaders as $,contentHasImage as I,isContextWindowExceededError as be,isQuotaExceededError as we,normalizeApiKey as Ee,resolveRetryPolicy as ke}from"@deepseek-ai/dsh-llm";import{deepEqualJson as D,installSettingsSection as Re,settingsNamespace as xe}from"@deepseek-ai/dsh-settings";import{createModels as Te,createProvider as Se,getSupportedThinkingLevels as O,isContextOverflow as Ie}from"@earendil-works/pi-ai";import{MAX_TIMER_DELAY_MS as A,idleWatchdog as Oe,timeoutOf as j}from"@deepseek-ai/dsh-timeout";import{builtinProviders as Ae,getBuiltinModels as Me,getBuiltinProviders as _e}from"@earendil-works/pi-ai/providers/all";import l from"@deepseek-ai/schemastery";import{credentialRef as Le}from"@deepseek-ai/dsh-credentials";import{anthropicMessagesApi as Ue}from"@earendil-works/pi-ai/api/anthropic-messages.lazy";import{openAICompletionsApi as Ne}from"@earendil-works/pi-ai/api/openai-completions.lazy";import{openAIResponsesApi as Pe}from"@earendil-works/pi-ai/api/openai-responses.lazy";function F(e){try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}catch{}return{}}s(F,"parseArguments");function W(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}s(W,"emptyPiUsage");function Ce(e){return{response:{kind:"pi-ai",version:2,api:e.api,provider:e.provider,model:e.model,...e.responseModel===void 0?{}:{responseModel:e.responseModel},...e.responseId===void 0?{}:{responseId:e.responseId},stopReason:e.stopReason},blocks:e.content.map(t=>{switch(t.type){case"text":return{type:"text",...t.textSignature===void 0?{}:{textSignature:t.textSignature}};case"thinking":return{type:"reasoning",...t.thinkingSignature===void 0?{}:{thinkingSignature:t.thinkingSignature},...t.redacted===void 0?{}:{redacted:t.redacted}};case"toolCall":return{type:"tool-call",...t.thoughtSignature===void 0?{}:{thoughtSignature:t.thoughtSignature}}}})}}s(Ce,"toPiReplayState");function b(e){throw new m(`invalid pi-ai replay state: ${e}`,"INVALID_REPLAY_STATE")}s(b,"invalidReplay");function $e(e){if(typeof e!="object"||e===null||Array.isArray(e))return b("expected a replay envelope");const t=e,r=t.response;if(typeof r!="object"||r===null||Array.isArray(r))return b("expected a response object");const o=r;if(o.kind!=="pi-ai")return b("unknown state kind");if(o.version!==2)return b(`unsupported version ${String(o.version)}`);for(const i of["api","provider","model"])if(typeof o[i]!="string"||o[i].length===0)return b(`${i} must be a non-empty string`);if(!["stop","length","toolUse","error","aborted"].includes(String(o.stopReason)))return b("unknown stopReason");if(o.responseModel!==void 0&&typeof o.responseModel!="string")return b("responseModel must be a string");if(o.responseId!==void 0&&typeof o.responseId!="string")return b("responseId must be a string");const n=t.blocks;if(!Array.isArray(n))return b("blocks must be an array");for(const[i,a]of n.entries()){if(typeof a!="object"||a===null||Array.isArray(a))return b(`block ${i} must be an object`);const d=a;if(!["text","reasoning","tool-call"].includes(String(d.type)))return b(`block ${i} has an unknown type`);for(const u of["textSignature","thinkingSignature","thoughtSignature"])if(d[u]!==void 0&&typeof d[u]!="string")return b(`block ${i} ${u} must be a string`);if(d.redacted!==void 0&&typeof d.redacted!="boolean")return b(`block ${i} redacted must be boolean`)}return{response:o,blocks:n}}s($e,"readReplayState");function K(e){const t=e.source.kind==="model"?e.source:void 0,r=[];for(const o of e.content)switch(o.type){case"text":r.push({type:"text",text:o.text});break;case"reasoning":r.push({type:"thinking",thinking:o.text});break;case"tool-call":r.push({type:"toolCall",id:o.id,name:o.name,arguments:F(o.arguments)});break;case"image":throw new m("pi-ai chat history cannot represent structured assistant image output","UNSUPPORTED_CONTENT")}return{role:"assistant",content:r,api:"dsh-foreign",provider:t?.provider??"dsh-foreign",model:t?.model??"dsh-foreign",usage:W(),stopReason:r.some(o=>o.type==="toolCall")?"toolUse":"stop",timestamp:0}}s(K,"foreignAssistant");function De(e,t,r){const o=$e(r);return o.response.provider!==t.provider?b("provider does not match assistant source"):o.response.model!==t.model?b("model does not match assistant source"):o.blocks.length!==e.content.length?b("block count does not match assistant content"):{role:"assistant",content:e.content.map((n,i)=>{const a=o.blocks[i];if(a===void 0||a.type!==n.type)return b(`block ${i} does not match assistant content`);switch(n.type){case"text":return{type:"text",text:n.text,...a.type==="text"&&a.textSignature!==void 0?{textSignature:a.textSignature}:{}};case"reasoning":return{type:"thinking",thinking:n.text,...a.type==="reasoning"&&a.thinkingSignature!==void 0?{thinkingSignature:a.thinkingSignature}:{},...a.type==="reasoning"&&a.redacted!==void 0?{redacted:a.redacted}:{}};case"tool-call":return{type:"toolCall",id:n.id,name:n.name,arguments:F(n.arguments),...a.type==="tool-call"&&a.thoughtSignature!==void 0?{thoughtSignature:a.thoughtSignature}:{}};default:return b(`block ${i} has an unsupported Harness type`)}}),api:o.response.api,provider:o.response.provider,model:o.response.model,...o.response.responseModel===void 0?{}:{responseModel:o.response.responseModel},...o.response.responseId===void 0?{}:{responseId:o.response.responseId},usage:W(),stopReason:o.response.stopReason,timestamp:0}}s(De,"replayedAssistant");function B(e,t){const r=e.source;if(r.kind!=="model"||r.replayState===void 0)return K(e);try{return De(e,r,r.replayState)}catch(o){if(!(o instanceof m)||o.code!=="INVALID_REPLAY_STATE")throw o;return t?.(o.message),K(e)}}s(B,"toPiAssistant");function M(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}s(M,"flattenText");function V(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool-result"?V(t.content):"").join("")}s(V,"toolResultText");async function _(e,t){const r=[];for(const o of e)switch(o.type){case"text":o.text.length>0&&r.push({type:"text",text:o.text});break;case"image":{const n=await t.readImage(o.attachment);r.push({type:"image",data:Buffer.from(n.data).toString("base64"),mimeType:n.ref.mediaType});break}case"tool-result":{const n=await _(o.content,t);typeof n=="string"?n.length>0&&r.push({type:"text",text:n}):r.push(...n)}}return r.every(o=>o.type==="text")?r.map(o=>o.text).join(""):r}s(_,"userContent");function je(e){return e.tools?.map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}s(je,"toolsOf");function Y(e,t){const r=je(e);return{...e.system!==void 0?{systemPrompt:e.system}:{},messages:t,...r!==void 0&&r.length>0?{tools:r}:{}}}s(Y,"piContext");function Fe(e,t){const r=new Map,o=[];for(const n of e.messages){if(I(n.content))throw new m("pi-ai image conversion requires the durable attachment service","UNSUPPORTED_CONTENT");if(n.role==="system"){o.push({role:"user",content:M(n),timestamp:0});continue}if(n.role==="assistant"){const d=B(n,t);for(const u of d.content)u.type==="toolCall"&&r.set(x(u.id),u.name);o.push(d);continue}const i=M(n),a=n.content.filter(d=>d.type==="tool-result");(i.length>0||a.length===0)&&o.push({role:"user",content:i,timestamp:0});for(const d of a)o.push({role:"toolResult",toolCallId:d.toolCallId,toolName:r.get(d.toolCallId)??"unknown",content:[{type:"text",text:V(d.content)||"(no output)"}],isError:d.isError??!1,timestamp:0})}return Y(e,o)}s(Fe,"textOnlyContext");function H(e,t,r){return t===void 0?Fe(e,r):We(e,t,r)}s(H,"toPiContext");async function We(e,t,r){const o=new Map,n=[];for(const i of e.messages){if(i.role==="system"){if(I(i.content))throw new m("pi-ai cannot represent an image in an in-history system message","UNSUPPORTED_CONTENT");n.push({role:"user",content:M(i),timestamp:0});continue}if(i.role==="assistant"){const u=B(i,r);for(const f of u.content)f.type==="toolCall"&&o.set(x(f.id),f.name);n.push(u);continue}const a=await _(i.content.filter(u=>u.type!=="tool-result"),t),d=i.content.filter(u=>u.type==="tool-result");(a.length>0||d.length===0)&&n.push({role:"user",content:a,timestamp:0});for(const u of d){const f=await _(u.content,t);n.push({role:"toolResult",toolCallId:u.toolCallId,toolName:o.get(u.toolCallId)??"unknown",content:typeof f=="string"?[{type:"text",text:f||"(no output)"}]:f,isError:u.isError??!1,timestamp:0})}}return Y(e,n)}s(We,"toPiContextWithImages");function z(e){return{inputTokens:e.input,outputTokens:e.output,...e.cacheRead>0?{cacheReadTokens:e.cacheRead}:{},...e.cacheWrite>0?{cacheWriteTokens:e.cacheWrite}:{}}}s(z,"mapUsage");function Ke(e){return/\b(?:401|403)\b/.test(e)?"AUTH":we(e)?ge:/\b429\b|rate.?limit/i.test(e)?"RATE_LIMIT":/\b400\b|invalid.?request/i.test(e)?"INVALID_REQUEST":/\b5\d\d\b/.test(e)?"SERVER":/\btime(?:d)?\s*out\b|timeout/i.test(e)?"TIMEOUT":/stream ended (?:before|without)\b/i.test(e)||/\b(?:network|connection|socket|fetch)\b|\bECONN[A-Z]+\b/i.test(e)||/\b(?:other side closed|HTTP2 request did not get a response|WebSocket closed unexpectedly)\b/i.test(e)||/\bterminated\b|premature close/i.test(e)?"TRANSPORT":"PI_AI_ERROR"}s(Ke,"classifyPiAiError");function X(e,t){const r=Ie(e,t),o=e.stopReason==="error"&&e.errorMessage!==void 0&&be(e.errorMessage);if(r||o)return{kind:"error",failure:{message:e.errorMessage??`pi-ai detected context overflow for model "${e.model}"`,code:pe}};switch(e.stopReason){case"pending":return{kind:"error",failure:{message:"pi-ai terminal message remained pending",code:"PI_AI_ERROR"}};case"stop":return e.content.length===0?{kind:"error",failure:{message:`model "${e.model}" returned a completed response with no content`,code:fe}}:{kind:"stop"};case"length":return{kind:"max-tokens"};case"toolUse":return{kind:"tool-calls"};case"aborted":return{kind:"aborted",failure:{message:e.errorMessage??"pi-ai stream aborted",code:"ABORTED"}};case"error":{const n=e.errorMessage??"pi-ai stream error";return{kind:"error",failure:{message:n,code:Ke(n)}}}}}s(X,"mapStopReason");async function*Be(e,t){const r=new Map;for await(const o of e)switch(o.type){case"start":break;case"text_start":yield{type:"block-start",index:o.contentIndex,blockType:"text"};break;case"text_delta":yield{type:"text-delta",index:o.contentIndex,text:o.delta};break;case"text_end":yield{type:"block-end",index:o.contentIndex,block:{type:"text",text:o.content}};break;case"thinking_start":yield{type:"block-start",index:o.contentIndex,blockType:"reasoning"};break;case"thinking_delta":yield{type:"reasoning-delta",index:o.contentIndex,text:o.delta};break;case"thinking_end":yield{type:"block-end",index:o.contentIndex,block:{type:"reasoning",text:o.content}};break;case"toolcall_start":{const n=o.partial.content[o.contentIndex],i=n?.type==="toolCall"?n.id:"",a=n?.type==="toolCall"?n.name:"";r.set(o.contentIndex,{id:i,name:a}),yield{type:"block-start",index:o.contentIndex,blockType:"tool-call"};break}case"toolcall_delta":{const n=r.get(o.contentIndex);yield{type:"tool-call-delta",index:o.contentIndex,id:x(n?.id??""),...n?.name!==void 0&&n.name.length>0?{name:n.name}:{},argumentsDelta:o.delta};break}case"toolcall_end":yield{type:"block-end",index:o.contentIndex,block:{type:"tool-call",id:x(o.toolCall.id),name:o.toolCall.name,arguments:JSON.stringify(o.toolCall.arguments)}};break;case"done":yield{type:"usage",usage:z(o.message.usage)},yield{type:"finish",reason:X(o.message,t),replayState:Ce(o.message)};return;case"error":yield{type:"usage",usage:z(o.error.usage)},yield{type:"finish",reason:X(o.error,t)};return}throw new m("pi-ai event stream ended without done/error","STREAM_CLOSED")}s(Be,"toStreamChunks");var Ve=s(function(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var o,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=t[Symbol.asyncDispose]}if(o===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=t[Symbol.dispose],r&&(n=o)}if(typeof o!="function")throw new TypeError("Object not disposable.");n&&(o=s(function(){try{n.call(this)}catch(i){return Promise.reject(i)}},"dispose")),e.stack.push({value:t,dispose:o,async:r})}else r&&e.stack.push({async:!0});return t},"__addDisposableResource"),Ye=(function(e){return function(t){function r(a){t.error=t.hasError?new e(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}s(r,"fail");var o,n=0;function i(){for(;o=t.stack.pop();)try{if(!o.async&&n===1)return n=0,t.stack.push(o),Promise.resolve().then(i);if(o.dispose){var a=o.dispose.call(o.value);if(o.async)return n|=2,Promise.resolve(a).then(i,function(d){return r(d),i()})}else n|=1}catch(d){r(d)}if(n===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return s(i,"next"),i()}})(typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var o=new Error(r);return o.name="SuppressedError",o.error=e,o.suppressed=t,o});function He(e,t,r){const o=t==="off"?void 0:t;return{...r===void 0?{}:{apiKey:r},...o===void 0?{}:{reasoning:o},...e.thinkingBudgets===void 0?{}:{thinkingBudgets:e.thinkingBudgets},...e.cacheRetention===void 0?{}:{cacheRetention:e.cacheRetention},...e.transport===void 0?{}:{transport:e.transport},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.websocketConnectTimeoutMs===void 0?{}:{websocketConnectTimeoutMs:e.websocketConnectTimeoutMs},maxRetries:0}}s(He,"profileOptions");function ze(e,t){if(t!==void 0)return O(e).some(r=>r===t)?t:void 0}s(ze,"describableReasoningLevel");function Xe(e,t){if(t!==void 0){if(O(e).some(r=>r===t))return t;throw new m(`pi-ai provider "${e.provider}" model "${e.id}" does not support reasoning effort "${t}"`,"UNSUPPORTED_REASONING_EFFORT")}}s(Xe,"resolveReasoningLevel");function Ge(e,t){return e.reasoning?{reasoning:{efforts:O(e).map(r=>({id:C(r),name:`${r.charAt(0).toUpperCase()}${r.slice(1)}`})),...t===void 0?{}:{defaultEffort:C(t)}}}:{}}s(Ge,"reasoningInfo");function Je(e){const t=$(),r=new Set(Object.keys(t).map(o=>o.toLowerCase()));return{...Object.fromEntries(Object.entries(e??{}).filter(([o])=>!r.has(o.toLowerCase()))),...t}}s(Je,"requestHeaders");var G=class extends he{static{s(this,"PiAiAdapter")}config;snapshot;constructor(e){super(),this.config=e}current(){const e=this.config.profiles();if(this.snapshot?.profiles===e)return this.snapshot;const t=Te();for(const r of e.values())t.setProvider(r.piProvider);return this.snapshot={profiles:e,models:t},this.snapshot}profileOf(e,t){const r=e.profiles.get(t);if(r===void 0)throw new m(`pi-ai adapter does not own provider "${t}"`,"NO_ADAPTER");return r}modelOf(e,t,r){this.profileOf(e,t);const o=e.models.getModel(t,r);if(o===void 0)throw new m(`pi-ai provider "${t}" has no configured model "${r}"`,"UNKNOWN_MODEL");return o}serviceRoutedModel(e,t){const r=e.baseURLService;if(r===void 0)return t;const o=this.config.resolveServiceBaseURL?.(r);if(o===void 0)throw new m(`pi-ai provider "${e.provider}" follows service "${r}", which is not mounted or exposes no baseURL`,"SERVICE_UNAVAILABLE");return{...t,baseUrl:o}}providerInfo(e){return{id:e,name:this.current().profiles.get(e)?.displayName??e}}providerRetryPolicy(e){return this.current().profiles.get(e)?.retryPolicy}listModels(e){return Promise.resolve().then(()=>{const t=this.current();return this.profileOf(t,e),t.models.getModels(e).map(r=>({provider:e,id:r.id,name:r.name,inputModalities:[...r.input]}))})}resolveModel(e,t,r){return Promise.resolve().then(()=>{const o=this.current(),n=this.profileOf(o,e),i=this.modelOf(o,e,t),a=ze(i,n.reasoning),d=n.configuredMaxTokens.get(t);return{provider:e,id:t,name:i.name,inputModalities:[...i.input],context:{contextWindow:i.contextWindow},...d===void 0?{}:{defaultMaxTokens:d},...Ge(i,a)}})}async*stream(e){const t={stack:[],error:void 0,hasError:!1};try{if(e.stop!==void 0)throw new m("llm-pi-ai does not support GenerateOptions.stop","UNSUPPORTED_OPTION");const r=this.current(),o=this.profileOf(r,e.provider),n=this.serviceRoutedModel(o,this.modelOf(r,e.provider,e.model)),i=Xe(n,e.reasoningEffort??o.reasoning),a=await this.config.resolveApiKey(e.provider,o),d=new AbortController,u=e.signal===void 0?d.signal:AbortSignal.any([e.signal,d.signal]),f=o.streamIdleTimeoutMs,y=Ve(t,Oe(u,f,"LLM_STREAM_IDLE_TIMEOUT"),!1);try{const E=e.messages.some(v=>I(v.content));if(E&&!n.input.includes("image"))throw new m(`pi-ai model "${n.id}" does not support image input`,"UNSUPPORTED_CONTENT");const c=E?this.config.resolveAttachments?.():void 0;if(E&&c===void 0)throw new m("pi-ai image input requires the durable attachment service","UNSUPPORTED_CONTENT");const h=s(v=>{this.config.onReplayDegrade?.({provider:e.provider,model:e.model,reason:v})},"onReplayDegrade"),k=c===void 0?H(e,void 0,h):await H(e,c,h),p=Be(r.models.streamSimple(n,k,{...He(o,i,a),...e.temperature===void 0?{}:{temperature:e.temperature},...e.maxTokens===void 0?{}:{maxTokens:e.maxTokens},...e.sessionId===void 0?{}:{sessionId:String(e.sessionId)},signal:y.signal,headers:Je(o.headers)}),n.contextWindow)[Symbol.asyncIterator]();let g=!1;try{for(;;){const v=await y.next(p),R=j(y.signal,"LLM_STREAM_IDLE_TIMEOUT");if(R!==void 0)throw R;if(v.done){g=!0;return}yield v.value}}finally{if(!g){d.abort("pi-ai stream consumer stopped");try{await p.return(void 0)}catch{}}}}catch(E){throw j(y.signal,"LLM_STREAM_IDLE_TIMEOUT")!==void 0?new m(`pi-ai stream idle timeout after ${f}ms`,"TIMEOUT",{cause:E}):e.signal?.aborted?new m("pi-ai request aborted by caller","ABORTED",{cause:E}):E}finally{d.abort("pi-ai stream consumer stopped")}}catch(r){t.error=r,t.hasError=!0}finally{Ye(t)}}};const Qe={input:0,output:0,cacheRead:0,cacheWrite:0},J=Object.keys({text:!0,image:!0});function Ze(e){return e===void 0||e.length===0?void 0:[...e]}s(Ze,"declaredInput");const T=Object.keys({off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0}),qe=Object.keys({openai:!0,deepseek:!0,openrouter:!0,together:!0,zai:!0,qwen:!0,"string-thinking":!0,"ant-ling":!0});let Q;function Z(){return Q??=new Map(Ae().map(e=>[e.id,e])),Q}s(Z,"catalogProviders");function L(e){return Z().get(e)}s(L,"catalogProvider");function et(){return _e()}s(et,"catalogProviderIds");function tt(e){return L(e)?.auth.apiKey!==void 0}s(tt,"catalogProviderTakesApiKey");function q(e){if(!Z().has(e))return new Map;const t=Me(e);return new Map(t.map(r=>[r.id,r]))}s(q,"catalogModels");function w(e,t){throw new Error(`llm-pi-ai: provider "${e}" ${t}`)}s(w,"invalid");function ot(e){const t=new Set;for(const r of e.values())t.add(r.api);return t.size===1?[...t][0]:void 0}s(ot,"sharedCatalogApi");function nt(e,t,r){const o=t.reasoningEfforts;if(o===void 0)return{reasoning:r?.reasoning??!1};if(o===!1)return{reasoning:!1};(o===null||Object.keys(o).length===0)&&w(e,`model "${t.id}" has an empty reasoningEfforts; declare the offered levels, set false for a non-reasoning model, or omit the field to keep the installed catalog's capability`);const n=T.flatMap(a=>{const d=o[a];return d===void 0?[]:[[a,d]]});for(const[a,d]of n)d===null?a!=="off"&&w(e,`model "${t.id}" reasoningEfforts.${a} needs the wire value dispatch should send; only "off" may leave it empty`):d.length===0&&w(e,`model "${t.id}" reasoningEfforts.${a} must not be an empty string`);n.some(([a])=>a!=="off")||w(e,`model "${t.id}" reasoningEfforts offers no level beyond "off"; declare a thinking level, or set reasoningEfforts to false for a non-reasoning model`);const i={};for(const a of T){const d=o[a];d===void 0?i[a]=null:d!==null&&(i[a]=d)}return{reasoning:!0,thinkingLevelMap:i}}s(nt,"resolveModelReasoning");function rt(e,t,r,o,n){const i=t.compat?.thinkingFormat??r?.thinkingFormat,a=t.compat?.supportsReasoningEffort??r?.supportsReasoningEffort;return i===void 0&&a===void 0?{}:n!=="openai-completions"?((t.compat?.thinkingFormat!==void 0||t.compat?.supportsReasoningEffort!==void 0)&&w(e,`model "${t.id}" sets compat reasoning switches, but its api is "${n}"; thinkingFormat and supportsReasoningEffort exist only on openai-completions`),{}):{compat:{...o?.api===n?o.compat:void 0,...i===void 0?{}:{thinkingFormat:i},...a===void 0?{}:{supportsReasoningEffort:a}}}}s(rt,"resolveModelCompat");function it(e){const{provider:t}=e,r=q(t),o=L(t)?.baseUrl,n=e.models??[],i=e.modelOverrides??{};for(const[c,h]of Object.entries(i))c.length===0&&w(t,"has a modelOverrides entry with an empty model id"),r.size===0&&w(t,`sets modelOverrides for "${c}", but the installed catalog does not describe this route; a declared route spells every model out in its models list`),n.length>0&&w(t,`sets modelOverrides for "${c}" beside a models list; models already replaces the served catalog, so declare the fields on its entries`),r.has(c)||w(t,`modelOverrides names "${c}", which the installed catalog does not describe`),"id"in h&&w(t,`modelOverrides entry "${c}" sets "id", which is the dict key`);const a=n.length>0?n:[...r.values()].map(c=>({id:c.id,...i[c.id]}));a.length===0&&w(t,"resolves no models; the installed catalog does not describe this route, so its models must be listed in configuration");const d=ot(r),u=e.compat?.thinkingFormat!==void 0||e.compat?.supportsReasoningEffort!==void 0,f=new Set,y=new Map,E=a.map(c=>{c.id.length===0&&w(t,"has a model with an empty id"),f.has(c.id)&&w(t,`lists model "${c.id}" more than once`),f.add(c.id);const h=r.get(c.id),k=e.api??h?.api??d;k===void 0&&w(t,`model "${c.id}" needs an api; the installed catalog does not describe it, so set the route's api to the wire protocol its endpoint speaks`);const p=e.baseURL??h?.baseUrl??o;p===void 0&&w(t,`model "${c.id}" needs a baseURL; the installed catalog does not describe this route`);const g=c.contextWindow??h?.contextWindow??e.defaultContextWindow;(!Number.isInteger(g)||g<=0)&&w(t,`model "${c.id}" contextWindow must be a positive integer`);const v=c.maxTokens??h?.maxTokens??e.defaultMaxTokens;return(!Number.isInteger(v)||v<=0)&&w(t,`model "${c.id}" maxTokens must be a positive integer`),c.maxTokens!==void 0&&y.set(c.id,c.maxTokens),{...h,id:c.id,name:c.name??h?.name??c.id,api:k,provider:t,baseUrl:p,input:Ze(c.input)??h?.input??[...e.defaultInput],cost:h?.cost??Qe,contextWindow:g,maxTokens:v,...nt(t,c,h),...rt(t,c,e.compat,h,k)}});return u&&!E.some(c=>c.api==="openai-completions")&&w(t,"sets compat reasoning switches, but no model on the route speaks openai-completions; thinkingFormat and supportsReasoningEffort exist only on that protocol"),{models:E,configuredMaxTokens:y}}s(it,"resolveRouteModels");const ee={"openai-completions":Ne,"openai-responses":Pe,"anthropic-messages":Ue};function U(){return Object.keys(ee)}s(U,"supportedProtocols");function te(e){return{name:e,resolve:s(({credential:t})=>Promise.resolve({auth:t?.key===void 0?{}:{apiKey:t.key},source:e}),"resolve")}}s(te,"harnessApiKeyAuth");function oe(e,t){return t===void 0?{apiKey:te(e.displayName)}:t.auth.apiKey!==void 0||!e.namesCredential?t.auth:{...t.auth,apiKey:te(e.displayName)}}s(oe,"routeAuth");function st(e,t){const r=t.baseURL??e.baseUrl;return{id:t.provider,name:t.displayName,...r===void 0?{}:{baseUrl:r},auth:oe(t,e),getModels:s(()=>t.models,"getModels"),stream:s((o,n,i)=>e.stream(o,n,i),"stream"),streamSimple:s((o,n,i)=>e.streamSimple(o,n,i),"streamSimple")}}s(st,"reuseCatalogProvider");function at(e){const t=L(e.provider);if(t!==void 0&&e.api===void 0)return st(t,e);const r=e.api===void 0?void 0:ee[e.api];if(r===void 0)throw new Error(`llm-pi-ai: provider "${e.provider}" names api "${e.api}", which this build cannot serve; supported protocols are ${U().join(", ")}`);return Se({id:e.provider,name:e.displayName,...e.baseURL===void 0?{}:{baseUrl:e.baseURL},auth:oe(e,t),models:e.models,api:r()})}s(at,"buildProvider");const dt=3e5,lt=262144,ct="http://127.0.0.1:9",ut=32768,ne=["text"],pt=l.object({minimal:l.number(),low:l.number(),medium:l.number(),high:l.number()}),re=l.object({thinkingFormat:l.union(qe),supportsReasoningEffort:l.boolean()}),ft=l.dict(l.union([l.string(),l.const(null)]),l.union(T)),ie={name:l.string(),contextWindow:l.number().step(1).min(1),maxTokens:l.number().step(1).min(1),input:l.array(l.union(J)),reasoningEfforts:l.union([l.const(!1),ft]),compat:re},mt=l.object({id:l.string().required(),...ie}),ht=l.object(ie),gt=l.object({apiKeyEnv:l.string().role("credential-ref"),displayName:l.string(),api:l.union(U()),baseURL:l.string(),baseURLService:l.string(),models:l.array(mt),modelOverrides:l.dict(ht),compat:re,defaultContextWindow:l.number().step(1).min(1).default(lt),defaultMaxTokens:l.number().step(1).min(1).default(ut),defaultInput:l.array(l.union(J)).default([...ne]),headers:l.dict(l.string()),reasoning:l.union(T),thinkingBudgets:pt,cacheRetention:l.union(["none","short","long"]),transport:l.union(["sse","websocket","websocket-cached","auto"]),timeoutMs:l.natural(),websocketConnectTimeoutMs:l.natural(),streamIdleTimeoutMs:l.number().min(Number.MIN_VALUE).max(A).default(dt),retryPolicy:ve}),se=l.object({providers:l.dict(gt).default({})});function vt(e){ae(e.providers)}s(vt,"assertServiceable");function yt(e,t){const r=t;if("provider"in r)throw new Error(`llm-pi-ai: provider "${e}" sets "provider", which moved to the providers dict key`);if("maxRetries"in r||"maxRetryDelayMs"in r)throw new Error(`llm-pi-ai: provider "${e}" sets maxRetries or maxRetryDelayMs, which were removed; compose agent recovery with dsh-llm-retry`)}s(yt,"rejectRemovedFields");function ae(e){if(Array.isArray(e))throw new Error("llm-pi-ai: providers is now a dict keyed by provider route, not an array of profiles");const t=Object.entries(e??{}),r=new Map;for(const[o,n]of t){if(yt(o,n),o.length===0)throw new Error("llm-pi-ai: provider names must be non-empty");if(n.baseURL!==void 0&&n.baseURL.length===0)throw new Error(`llm-pi-ai: provider "${o}" has an empty baseURL`);if(n.baseURL!==void 0&&n.baseURLService!==void 0)throw new Error(`llm-pi-ai: provider "${o}" sets both baseURL and baseURLService; name at most one endpoint source`);if(n.baseURLService!==void 0&&n.baseURLService.length===0)throw new Error(`llm-pi-ai: provider "${o}" has an empty baseURLService`);if(n.displayName!==void 0&&n.displayName.length===0)throw new Error(`llm-pi-ai: provider "${o}" has an empty displayName`);const i=n.streamIdleTimeoutMs??3e5;if(!Number.isFinite(i)||i<=0||i>A)throw new Error(`llm-pi-ai: provider "${o}" streamIdleTimeoutMs must be a positive finite number no greater than ${A}`);const a=[...n.defaultInput??ne];if(a.length===0)throw new Error(`llm-pi-ai: provider "${o}" defaultInput must name at least one modality`);const d=n.displayName??o,u=it({provider:o,...n.api===void 0?{}:{api:n.api},...n.baseURL===void 0?{}:{baseURL:n.baseURL},...n.baseURLService===void 0?{}:{baseURL:ct},...n.models===void 0?{}:{models:n.models},...n.modelOverrides===void 0?{}:{modelOverrides:n.modelOverrides},...n.compat===void 0?{}:{compat:n.compat},defaultInput:a,defaultContextWindow:n.defaultContextWindow??262144,defaultMaxTokens:n.defaultMaxTokens??32768}),{apiKeyEnv:f,retryPolicy:y,models:E,displayName:c,...h}=n;r.set(o,{...h,provider:o,displayName:d,...f===void 0?{}:{apiKeyEnv:Le(f)},streamIdleTimeoutMs:i,retryPolicy:ke(y,`llm-pi-ai: provider "${o}" retryPolicy`),...h.headers===void 0?{}:{headers:{...h.headers}},...h.thinkingBudgets===void 0?{}:{thinkingBudgets:{...h.thinkingBudgets}},configuredMaxTokens:u.configuredMaxTokens,piProvider:at({provider:o,displayName:d,...n.api===void 0?{}:{api:n.api},...n.baseURL===void 0?{}:{baseURL:n.baseURL},models:u.models,namesCredential:f!==void 0})})}return r}s(ae,"resolveProfiles");const bt=new Set(["openai-completions","openai-responses"]),N=4194304;function de(...e){for(const t of e)if(typeof t=="number"&&Number.isInteger(t)&&t>0)return t}s(de,"capacity");function le(...e){for(const t of e)if(typeof t=="string"&&t.length>0)return t}s(le,"label");function wt(e){return`${e.replace(/\/+$/,"")}/models`}s(wt,"listingUrl");async function Et(e,t){const r=s(()=>new m(`${t} answered with more than ${N} bytes`,"DISCOVERY_FAILED"),"oversized"),o=Number(e.headers.get("content-length")??NaN);if(Number.isFinite(o)&&o>N)throw await e.body?.cancel(),r();if(e.body===null)return"";const n=e.body.getReader(),i=[];let a=0;try{for(;;){const{done:f,value:y}=await n.read();if(f)break;if(a+=y.byteLength,a>N)throw r();i.push(y)}}finally{await n.cancel().catch(()=>{})}const d=new Uint8Array(a);let u=0;for(const f of i)d.set(f,u),u+=f.byteLength;return new TextDecoder().decode(d)}s(Et,"readBounded");function kt(e){const t=e?.data;if(!Array.isArray(t))throw new m(`the endpoint's model listing has no "data" array; enter this provider's models by hand`,"DISCOVERY_FAILED");const r=[];for(const o of t){const n=o,i=le(n?.id);if(i===void 0)continue;const a=le(n?.name,n?.display_name),d=de(n?.context_window,n?.context_length),u=de(n?.max_output_tokens,n?.max_tokens);r.push({id:i,...a===void 0?{}:{name:a},...d===void 0?{}:{contextWindow:d},...u===void 0?{}:{maxTokens:u}})}return r}s(kt,"readListing");function Rt(e){const t=Ee(e);if(t.ok)return t.value;throw new m(t.reason==="empty"?"this provider's API key is blank; enter it on the Models page, or clear it to probe unauthenticated":"this provider's API key contains characters no HTTP header can carry; paste the raw key only",me)}s(Rt,"usableProbeKey");async function xt(e,t){if(e.provider!==void 0){const f=q(e.provider);if(f.size>0)return[...f.values()].map(y=>({id:y.id,name:y.name,contextWindow:y.contextWindow,maxTokens:y.maxTokens}))}if(e.baseURL===void 0||e.baseURL.length===0)throw new m(`pi-ai ships no catalog for provider "${e.provider??""}", so its models can only come from its endpoint; set a baseURL, or enter this provider's models by hand`,"DISCOVERY_FAILED");const r=e.api??"openai-completions";if(!bt.has(r))throw new m(`pi-ai protocol "${r}" has no model listing this build can read; enter this provider's models by hand`,"DISCOVERY_UNSUPPORTED");const o=wt(e.baseURL),n=e.apiKey??await t?.(),i=n===void 0?void 0:Rt(n);let a;try{a=await fetch(o,{method:"GET",headers:{accept:"application/json",...i===void 0?{}:{authorization:`Bearer ${i}`},...$()},...e.signal===void 0?{}:{signal:e.signal}})}catch(f){throw e.signal?.aborted?new m("model discovery aborted by caller","ABORTED",{cause:f}):new m(`could not reach ${o}`,"DISCOVERY_FAILED",{cause:f})}if(!a.ok)throw new m(`${o} answered ${a.status}${a.status===401||a.status===403?"; check the API key":""}`,"DISCOVERY_FAILED");let d;try{d=await Et(a,o)}catch(f){throw e.signal?.aborted?new m("model discovery aborted by caller","ABORTED",{cause:f}):f}let u;try{u=JSON.parse(d)}catch(f){throw new m(`${o} did not answer with JSON`,"DISCOVERY_FAILED",{cause:f})}return kt(u)}s(xt,"discoverModels");const Tt="llm-pi-ai",St=["llm"],P=xe("llm-pi-ai");function It(e){return[...e.entries()].map(([t,r])=>({provider:t,displayName:r.displayName,retryPolicy:r.retryPolicy})).sort((t,r)=>t.provider.localeCompare(r.provider))}s(It,"registrationFacts");function Ot(e){const t=new Set(et()),r=new Map,o=s((n,i)=>{r.set(n,{provider:n,displayName:i,settingsNs:P,settingsPath:["providers",n],declared:!t.has(n)})},"declare");for(const n of t)tt(n)&&o(n,n);for(const[n,i]of e)o(n,i.displayName);return[...r.values()]}s(Ot,"directoryEntries");function At(e,t){let r=s(()=>t,"current"),o,n;const i=s(()=>{const p=r();if(p===o&&n!==void 0)return n;const g=ae(p.providers);return o=p,n=g,g},"profiles");i();const a=s(async(p,g)=>{const v=g.apiKeyEnv;if(v===void 0)return;const R=e.get("credentials"),S=R!==void 0?(await R.resolve(v))?.value:ue(e).get(v)?.value;if(S!==void 0&&S.length>0)return ye(S,"llm-pi-ai",v);throw new m(`llm-pi-ai: no credential for provider route "${p}"; its profile resolves ${v}, which is not set — store ${v} through the credentials service (the web Models page writes it) or export it, and remove apiKeyEnv only if this provider should authenticate from pi-ai's own environment discovery`,"MISSING_CREDENTIAL")},"resolveApiKey"),d=new G({profiles:i,resolveApiKey:a,resolveAttachments:s(()=>e.get("attachments"),"resolveAttachments"),resolveServiceBaseURL:s(p=>{const g=e.get(p);if(g==null)return;const v=g.baseURL;return typeof v=="string"&&v.length>0?v:void 0},"resolveServiceBaseURL"),onReplayDegrade:s(({provider:p,model:g,reason:v})=>{e.logger.warn(`llm-pi-ai: unusable replay state on assistant history for route "${p}/${g}"; sending that message as provider-neutral content (${v})`)},"onReplayDegrade")});let u,f;const y=s(()=>{const p=Ot(i());D(p,f)||(u===void 0?u=e.llm.registerConfigurableProviders(p):u.replace(p),f=p)},"ensureDirectory");y();const E=s(async p=>{if(p===void 0)return;const g=i().get(p);if(g!==void 0)return a(p,g)},"storedApiKey");e.llm.registerModelDiscovery(P,p=>xt(p,()=>E(p.provider)));let c,h;const k=s(()=>{const p=It(i());if(D(p,h))return;const g=[...i().keys()];if(c===void 0){if(g.length===0){h=p;return}c=e.llm.registerAdapter(g,d)}else c.replace(g);h=p},"ensureRegistrationFacts");k(),Re(e,P,se,t,{validate:vt,setSource:s(p=>{r=p},"setSource"),onChange:s(()=>{try{k()}catch(p){e.logger.error("llm-pi-ai: keeping the previously registered routes after a refused update"),e.logger.error(p)}try{y()}catch(p){e.logger.error("llm-pi-ai: keeping the previous configurable-provider directory after a refused update"),e.logger.error(p)}},"onChange")})}s(At,"apply");export{se as Config,G as PiAiAdapter,At as apply,St as inject,Tt as name,U as supportedProtocols};
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-llm-pi-ai","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-attachment":"^0.0.15","@deepseek-ai/dsh-launch-environment":"^0.0.15","@deepseek-ai/dsh-credentials":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-settings":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-timeout":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15"},"dependencies":{"@earendil-works/pi-ai":"^0.83.0","@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-llm-pi-ai","version":"0.1.0","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-attachment":"^0.1.0","@deepseek-ai/dsh-credentials":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-launch-environment":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-timeout":"^0.1.0","@deepseek-ai/dsh-settings":"^0.1.0"},"dependencies":{"@earendil-works/pi-ai":"^0.83.0","@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-llm-retry","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"},"./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-timeout":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-llm":"^0.0.15"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-llm-retry","version":"0.1.0","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"},"./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.1.0","@deepseek-ai/dsh-agent":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/dsh-timeout":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1,2 +1,3 @@
1
- var F=Object.defineProperty;var c=(e,t)=>F(e,"name",{value:t,configurable:!0});import i from"@deepseek-ai/schemastery";import{MAX_TIMER_DELAY_MS as g}from"@deepseek-ai/dsh-timeout";import{Client as P}from"@modelcontextprotocol/sdk/client/index.js";import{ListToolsResultSchema as U,ToolListChangedNotificationSchema as G}from"@modelcontextprotocol/sdk/types.js";import{StdioClientTransport as X}from"@modelcontextprotocol/sdk/client/stdio.js";import{StreamableHTTPClientTransport as J}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{scrubbedParentEnv as V}from"@deepseek-ai/dsh-subprocess";import{createHash as Z}from"node:crypto";import{z as S}from"zod";import{assertSupportedJsonSchema as B}from"@deepseek-ai/dsh-tools";function W(e){return{...V(),...e}}c(W,"buildChildEnv");function Y(e){switch(e.transport){case"stdio":return new X({command:e.command,args:e.args,env:W(e.env),cwd:e.cwd});case"streamable-http":return new J(new URL(e.url),{requestInit:{headers:e.headers}})}}c(Y,"createTransport");const K=64,Q=/[^A-Za-z0-9_-]/g,ee=12,te=S.record(S.string(),S.unknown());function re(e,t){return e.request({method:"tools/list",...t===void 0?{}:{params:{cursor:t}}},U)}c(re,"listToolsUncached");function ne(e,t,n,r,o){return e.request({method:"tools/call",params:{name:t,arguments:n}},te,{signal:r.signal,timeout:o.toolCallTimeoutMs})}c(ne,"callToolUncached");function oe(e,t){const n=`mcp__${e}__${t}`,r=n.replace(Q,"_");if(r===n&&r.length<=K)return r;const o=Z("sha256").update(`${e}\0${t}`).digest("hex").slice(0,ee);return`${r.slice(0,51)}_${o}`}c(oe,"publicToolName");async function se(e,t,n,r){const o=new Map;let d;do{const l=await re(e,d);for(const u of l.tools){const p=oe(n.serverName,u.name);if(o.has(p))throw new Error(`mcp-client(${n.serverName}): server listed tool "${u.name}" more than once — invalid tool list`);o.set(p,{name:p,description:u.description??"",parameters:u.inputSchema,output:ae(u.name,ie(u.outputSchema)),execute:ce(e,u.name,u.execution?.taskSupport==="required",n)})}d=l.nextCursor}while(d);for(const l of r.values())l();const a=new Map;try{for(const[l,u]of o)a.set(l,t.tools.register(u))}catch(l){for(const u of a.values())u();if(t.logger.error(`mcp-client(${n.serverName}): tool registration failed, no tools registered: ${String(l)}`),n.registrationFailure==="throw")throw l;return new Map}return a}c(se,"syncTools");function ie(e){if(e!==void 0)try{return B(e),e}catch{return}}c(ie,"supportedOutputSchema");function ae(e,t){return{schema:{type:"object",properties:{content:{type:"array",items:{}},structuredContent:t??{}},required:t===void 0?["content"]:["content","structuredContent"],additionalProperties:!1},render(n,r){return[{type:"text",text:k(r.content,e)}]}}}c(ae,"createOutput");function ce(e,t,n,r){return async(o,d)=>{if(n)throw new Error(`Tool "${t}" requires task-based execution, which this bridge does not support`);const a=await ne(e,t,typeof o=="object"&&o!==null?o:{},d,r);if(!Array.isArray(a.content)){const p="toolResult"in a?JSON.stringify(a.toolResult):"(no output)",h=typeof p=="string"?p:"(no output)";if(a.isError===!0)throw new Error(h);return{content:[{type:"text",text:h}],...a.structuredContent!==void 0?{structuredContent:a.structuredContent}:{}}}const l=a.content,u=k(l,t);if(a.isError===!0)throw new Error(u);return{content:l,...a.structuredContent!==void 0?{structuredContent:a.structuredContent}:{}}}}c(ce,"createExecutor");function k(e,t){const n=[];for(const r of e){if(typeof r!="object"||r===null||Array.isArray(r)){n.push("[unsupported content type: unknown]");continue}const o=r;switch(o.type){case"text":o.text!==void 0&&n.push(o.text);break;case"image":n.push(`[image: ${o.mimeType??"unknown"}, content discarded]`);break;case"audio":n.push(`[audio: ${o.mimeType??"unknown"}, content discarded]`);break;case"resource":case"resource_link":n.push("[resource: content discarded]");break;default:n.push(`[unsupported content type: ${o.type}]`)}}return n.join(`
2
- `)||`(${t} returned no text content)`}c(k,"extractText");const w=Object.freeze({enabled:!0,initialDelayMs:500,maxDelayMs:3e4,maxAttempts:10}),_=5e3;function le(e,t){if(e!==void 0){for(const a of Object.keys(e))if(!Object.hasOwn(w,a))throw new Error(`${t}.${a} is not a reconnect option`)}const n=e?.enabled??w.enabled,r=e?.initialDelayMs??w.initialDelayMs,o=e?.maxDelayMs??w.maxDelayMs,d=e?.maxAttempts??w.maxAttempts;if(!Number.isFinite(r)||r<=0||r>g)throw new Error(`${t}.initialDelayMs must be a positive finite number no greater than ${g}`);if(!Number.isFinite(o)||o<=0||o>g)throw new Error(`${t}.maxDelayMs must be a positive finite number no greater than ${g}`);if(r>o)throw new Error(`${t}.initialDelayMs must be less than or equal to maxDelayMs`);if(!Number.isInteger(d)||d<1)throw new Error(`${t}.maxAttempts must be a positive integer`);return Object.freeze({enabled:n,initialDelayMs:r,maxDelayMs:o,maxAttempts:d})}c(le,"resolveReconnectPolicy");function ue(e,t,n){const r=`mcp-client(${t.serverName})`,o={registrationFailure:"contain",serverName:t.serverName,toolCallTimeoutMs:t.toolCallTimeoutMs},d=t.failOnStartupError?{...o,registrationFailure:"throw"}:o;let a=!1,l,u,p=new Map,h,y=0,$,A;const b=c(m=>!a&&l===m,"isCurrent");let M=Promise.resolve();function x(m,s=o){const f=M.then(async()=>{b(m)&&(p=await se(m,e,s,p))});return M=f.catch(()=>{}),f}c(x,"enqueueSync");function E(m){b(m)&&(l=void 0,u=void 0,I())}c(E,"generationDown");function D(m){return new Promise(s=>{const f=setTimeout(()=>{s(!1)},_);f.unref(),m.then(()=>{clearTimeout(f),s(!0)})})}c(D,"waitForClose");function I(){const m=$!==void 0;if(!n.enabled){const v=m?"connection lost and reconnect is disabled — registered tools will fail until an HMR reload or Host restart":"connection failed and reconnect is disabled — no tools were registered; reload the plugin or restart the Host to connect";e.logger.error(`${r}: ${v}`);return}if($!==void 0&&Date.now()-$>=n.maxDelayMs&&(y=0),$=void 0,y+=1,y>n.maxAttempts){M=M.then(()=>{for(const v of p.values())v();p=new Map}),e.logger.error(`${r}: giving up after ${n.maxAttempts} consecutive failed reconnect attempts — tools unregistered; reload the plugin or restart the Host to reconnect`);return}const s=Math.min(n.maxDelayMs,n.initialDelayMs*2**(y-1)),f=m?"connection lost; reconnecting":"connection failed; retrying";e.logger.warn(`${r}: ${f} in ${s}ms (attempt ${y}/${n.maxAttempts})`),h=setTimeout(()=>{h=void 0,N=O(!1)},s),h.unref()}c(I,"scheduleReconnect");async function O(m){const s=new P({name:"dsh-mcp-client",version:"0.0.1"},{capabilities:{}}),f=Promise.withResolvers();let v=!1,R=!1;const C=c(()=>R,"hasClosed");l=s,u=f.promise,s.onclose=()=>{R=!0,f.resolve(),v&&E(s)},s.setNotificationHandler(G,async()=>{if(b(s)){e.logger.info(`${r}: tool list changed, re-syncing`);try{await x(s)}catch(T){a||e.logger.error(`${r}: tool re-sync failed: ${String(T)}`)}}});try{if(await s.connect(Y(t)),C()){v=!0,E(s);return}await x(s,m?d:o)}catch(T){A===void 0&&(A=T),b(s)&&e.logger.warn(`${r}: connection attempt failed: ${String(T)}`);try{await s.close()}catch{}const z=C()||await D(f.promise);if(v=!0,!b(s))return;if(!z){l=void 0,u=void 0,e.logger.error(`${r}: failed generation did not close within ${_}ms — reconnect stopped to avoid overlapping server processes; reload the plugin or restart the Host to retry`);return}E(s);return}if(v=!0,C()){E(s);return}b(s)&&($=Date.now(),y>0&&e.logger.info(`${r}: reconnected and re-synced tools (attempt ${y}/${n.maxAttempts})`))}c(O,"connectGeneration");let N=O(!0);return{ready:N.then(()=>l!==void 0?{}:{error:A??new Error(`${r}: initial connection failed`)}),async dispose(){a=!0,h!==void 0&&(clearTimeout(h),h=void 0);const m=l,s=u;if(l=void 0,u=void 0,m!==void 0){try{await m.close()}catch{}s!==void 0&&!await D(s)&&e.logger.error(`${r}: generation did not close within ${_}ms during disposal — server shutdown may be incomplete`)}await N,await M;for(const f of p.values())f();p=new Map}}}c(ue,"startConnection");const de="mcp-client",me=["tools"],q=6e4,L=/^[A-Za-z0-9_-]{1,32}$/,j=new WeakMap,H=i.object({enabled:i.boolean().default(w.enabled),initialDelayMs:i.number().min(1).max(g).default(w.initialDelayMs),maxDelayMs:i.number().min(1).max(g).default(w.maxDelayMs),maxAttempts:i.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(w.maxAttempts)}),pe=i.union([i.object({transport:i.const("stdio"),serverName:i.string().required().pattern(L),command:i.string().required(),args:i.array(String).default([]),env:i.dict(String).default({}),cwd:i.string().default(""),toolCallTimeoutMs:i.number().default(q),failOnStartupError:i.boolean().default(!1),reconnect:H}),i.object({transport:i.const("streamable-http"),serverName:i.string().required().pattern(L),url:i.string().required(),headers:i.dict(String).default({}),toolCallTimeoutMs:i.number().default(q),failOnStartupError:i.boolean().default(!1),reconnect:H})]);async function fe(e,t){const n=le(t.reconnect,`mcp-client(${t.serverName}): reconnect`);e.effect(()=>{let d=j.get(e.root);if(d||(d=new Set,j.set(e.root,d)),d.has(t.serverName))throw new Error(`mcp-client: serverName "${t.serverName}" is already in use by another mcp-client instance — pick a unique serverName in cordis.yml`);return d.add(t.serverName),()=>{d.delete(t.serverName)}},"mcp-client.serverName");const r=ue(e,t,n);e.effect(()=>()=>r.dispose(),"mcp-client.connection");const o=await r.ready;if(o.error!==void 0&&t.failOnStartupError)throw new Error(`mcp-client(${t.serverName}): initial connection or tool synchronization failed`,{cause:o.error})}c(fe,"apply");export{pe as Config,fe as apply,me as inject,de as name};
1
+ var Z=Object.defineProperty;var l=(e,t)=>Z(e,"name",{value:t,configurable:!0});import m from"@deepseek-ai/schemastery";import{MAX_TIMER_DELAY_MS as M}from"@deepseek-ai/dsh-timeout";import{Client as B}from"@modelcontextprotocol/sdk/client/index.js";import{ListToolsResultSchema as J,ToolListChangedNotificationSchema as W}from"@modelcontextprotocol/sdk/types.js";import{StdioClientTransport as X}from"@modelcontextprotocol/sdk/client/stdio.js";import{StreamableHTTPClientTransport as V}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{scrubbedParentEnv as Y}from"@deepseek-ai/dsh-subprocess";import{createHash as K}from"node:crypto";import{isDeepStrictEqual as q}from"node:util";import{z as N}from"zod";import{isImageAdmissionError as Q}from"@deepseek-ai/dsh-attachment";import{assertSupportedJsonSchema as ee}from"@deepseek-ai/dsh-tools";function te(e){return{...Y(),...e}}l(te,"buildChildEnv");function re(e){switch(e.transport){case"stdio":return new X({command:e.command,args:e.args,env:te(e.env),cwd:e.cwd});case"streamable-http":return new V(new URL(e.url),{requestInit:{headers:e.headers}})}}l(re,"createTransport");const ne=64,oe=/[^A-Za-z0-9_-]/g,ie=12,ae=N.record(N.string(),N.unknown()),se=["image/png","image/jpeg","image/webp","image/gif"],ce=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function le(e,t){return e.request({method:"tools/list",...t===void 0?{}:{params:{cursor:t}}},J)}l(le,"listToolsUncached");function ue(e,t,o,n,i){return e.request({method:"tools/call",params:{name:t,arguments:o}},ae,{signal:n.signal,timeout:i.toolCallTimeoutMs})}l(ue,"callToolUncached");function de(e,t){const o=`mcp__${e}__${t}`,n=o.replace(oe,"_");if(n===o&&n.length<=ne)return n;const i=K("sha256").update(`${e}\0${t}`).digest("hex").slice(0,ie);return`${n.slice(0,51)}_${i}`}l(de,"publicToolName");async function me(e,t,o,n){const i=new Map;let c;do{const a=await le(e,c);for(const r of a.tools){const s=de(o.serverName,r.name);if(i.has(s))throw new Error(`mcp-client(${o.serverName}): server listed tool "${r.name}" more than once — invalid tool list`);i.set(s,fe(e,t,s,r.name,r.description??"",r.inputSchema,pe(r.outputSchema),r.execution?.taskSupport==="required",o))}c=a.nextCursor}while(c);for(const a of n.values())a();const d=new Map;try{for(const[a,r]of i)d.set(a,t.tools.register(r))}catch(a){for(const r of d.values())r();if(t.logger.error(`mcp-client(${o.serverName}): tool registration failed, no tools registered: ${String(a)}`),o.registrationFailure==="throw")throw a;return new Map}return d}l(me,"syncTools");function pe(e){if(e!==void 0)try{return ee(e),e}catch{return}}l(pe,"supportedOutputSchema");function fe(e,t,o,n,i,c,d,a,r){const s=new WeakMap;return{name:o,description:i,parameters:c,output:he(n,d),execute:ge(e,t,n,a,r,s),finalizeContent(p,f){const g=s.get(p);if(g!==void 0&&(s.delete(p),!f.isError&&q(f.value,g.value)&&q(f.content,g.fallback)))return g.content}}}l(fe,"createDefinition");function he(e,t){return{schema:{type:"object",properties:{content:{type:"array",items:{}},structuredContent:t??{}},required:t===void 0?["content"]:["content","structuredContent"],additionalProperties:!1},render(o,n){return[{type:"text",text:I(n.content,e)}]}}}l(he,"createOutput");function ge(e,t,o,n,i,c){return async(d,a)=>{if(n)throw new Error(`Tool "${o}" requires task-based execution, which this bridge does not support`);const r=await ue(e,o,typeof d=="object"&&d!==null?d:{},a,i);if(!Array.isArray(r.content)){const g="toolResult"in r?JSON.stringify(r.toolResult):"(no output)",y=typeof g=="string"?g:"(no output)";if(r.isError===!0)throw new Error(y);return{content:[{type:"text",text:y}],...r.structuredContent!==void 0?{structuredContent:r.structuredContent}:{}}}const s=r.content,p=I(s,o);if(r.isError===!0)throw new Error(p);const f={content:s,...r.structuredContent!==void 0?{structuredContent:r.structuredContent}:{}};if(ve(s)){const g=[{type:"text",text:I(s,o)}],y=await Ee(t,a,s,o);c.set(a,{value:f,fallback:g,content:y})}return f}}l(ge,"createExecutor");function ve(e){return e.some(t=>D(t)&&t.type==="image")}l(ve,"containsImage");function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}l(D,"isRecord");function we(e){return se.includes(e)}l(we,"isImageMediaType");function ye(e){if(e.mimeType===void 0||!we(e.mimeType))throw new Error("the declared media type is not PNG, JPEG, WebP, or GIF");if(e.data===void 0||!ce.test(e.data))throw new Error("the image data is not canonical base64");const t=Buffer.from(e.data,"base64");if(t.toString("base64")!==e.data)throw new Error("the image data is not canonical base64");return{data:t,mediaType:e.mimeType}}l(ye,"decodeImage");async function be(e,t){const o=e.get("attachments");if(o===void 0)throw new Error("no attachment store is mounted");const n=t.agent?.session.requestHeader()?.config,i=n?.provider??t.agent?.options.provider,c=n?.model??t.agent?.options.model,d=e.get("llm");if(i===void 0||c===void 0||d===void 0)throw new Error("the current model route could not be resolved");let a;try{a=await d.resolveModelInfo(i,c,t.signal)}catch{throw new Error("the current model route could not be verified")}if(a.inputModalities===void 0||!a.inputModalities.includes("image"))throw new Error(`model "${c}" does not declare image input`);if(t.signal.aborted)throw new Error("the tool call was canceled before image storage");return o}l(be,"resolveImageAdmission");function x(e,t){return`[image unavailable: ${e.mimeType??"unknown media type"}; ${t}; raw image data remains available to programmatic callers]`}l(x,"imageDiagnostic");async function Ee(e,t,o,n){const i=[],c=new Map,d=[];for(const[r,s]of o.entries())if(!(!D(s)||s.type!=="image")){d.push(r);try{i.push(ye(s))}catch(p){c.set(r,p.message)}}if(c.size>0)return T(o,n,(r,s)=>({type:"text",text:x(r,c.get(s)??"another image in the same result was invalid")}));let a;try{a=await be(e,t)}catch(r){const s=r.message;return T(o,n,p=>({type:"text",text:x(p,s)}))}try{const r=await a.saveImages(i),s=new Map(d.map((p,f)=>[p,r[f]]));return T(o,n,(p,f)=>({type:"image",attachment:s.get(f)}))}catch(r){const s=Q(r)?`image admission rejected the result: ${r.message}`:"durable image storage rejected the result";return T(o,n,p=>({type:"text",text:x(p,s)}))}}l(Ee,"prepareImageProjection");function I(e,t){return T(e,t).map(o=>o.text).join(`
2
+ `)}l(I,"extractText");function T(e,t,o=n=>({type:"text",text:x(n,"this result was not admitted to durable model context")})){const n=[],i=[],c=l(()=>{i.length!==0&&n.push({type:"text",text:i.splice(0).join(`
3
+ `)})},"flushText");for(const[d,a]of e.entries()){if(!D(a)){i.push("[unsupported MCP content block: expected an object]");continue}const r=a;switch(r.type){case"text":r.text!==void 0&&i.push(r.text);break;case"image":c(),n.push(o(r,d));break;case"resource_link":r.name===void 0||r.uri===void 0?i.push("[resource link unavailable: the MCP block is missing its name or URI]"):i.push(`Resource link: ${r.name} (${r.uri})`);break;case"audio":i.push(`[audio result unsupported: ${r.mimeType??"unknown media type"}; raw audio data remains available to programmatic callers]`);break;case"resource":i.push("[embedded resource unsupported; raw resource data remains available to programmatic callers]");break;default:i.push(`[unsupported MCP content type: ${r.type}]`)}}return c(),n.length>0?n:[{type:"text",text:`(${t} returned no model-visible content)`}]}l(T,"projectContent");const w=Object.freeze({enabled:!0,initialDelayMs:500,maxDelayMs:3e4,maxAttempts:10}),j=5e3;function Me(e,t){if(e!==void 0){for(const d of Object.keys(e))if(!Object.hasOwn(w,d))throw new Error(`${t}.${d} is not a reconnect option`)}const o=e?.enabled??w.enabled,n=e?.initialDelayMs??w.initialDelayMs,i=e?.maxDelayMs??w.maxDelayMs,c=e?.maxAttempts??w.maxAttempts;if(!Number.isFinite(n)||n<=0||n>M)throw new Error(`${t}.initialDelayMs must be a positive finite number no greater than ${M}`);if(!Number.isFinite(i)||i<=0||i>M)throw new Error(`${t}.maxDelayMs must be a positive finite number no greater than ${M}`);if(n>i)throw new Error(`${t}.initialDelayMs must be less than or equal to maxDelayMs`);if(!Number.isInteger(c)||c<1)throw new Error(`${t}.maxAttempts must be a positive integer`);return Object.freeze({enabled:o,initialDelayMs:n,maxDelayMs:i,maxAttempts:c})}l(Me,"resolveReconnectPolicy");function $e(e,t,o){const n=`mcp-client(${t.serverName})`,i={registrationFailure:"contain",serverName:t.serverName,toolCallTimeoutMs:t.toolCallTimeoutMs},c=t.failOnStartupError?{...i,registrationFailure:"throw"}:i;let d=!1,a,r,s=new Map,p,f=0,g,y;const E=l(h=>!d&&a===h,"isCurrent");let $=Promise.resolve();function O(h,u=i){const v=$.then(async()=>{E(h)&&(s=await me(h,e,u,s))});return $=v.catch(()=>{}),v}l(O,"enqueueSync");function A(h){E(h)&&(a=void 0,r=void 0,G())}l(A,"generationDown");function R(h){return new Promise(u=>{const v=setTimeout(()=>{u(!1)},j);v.unref(),h.then(()=>{clearTimeout(v),u(!0)})})}l(R,"waitForClose");function G(){const h=g!==void 0;if(!o.enabled){const b=h?"connection lost and reconnect is disabled — registered tools will fail until an HMR reload or Host restart":"connection failed and reconnect is disabled — no tools were registered; reload the plugin or restart the Host to connect";e.logger.error(`${n}: ${b}`);return}if(g!==void 0&&Date.now()-g>=o.maxDelayMs&&(f=0),g=void 0,f+=1,f>o.maxAttempts){$=$.then(()=>{for(const b of s.values())b();s=new Map}),e.logger.error(`${n}: giving up after ${o.maxAttempts} consecutive failed reconnect attempts — tools unregistered; reload the plugin or restart the Host to reconnect`);return}const u=Math.min(o.maxDelayMs,o.initialDelayMs*2**(f-1)),v=h?"connection lost; reconnecting":"connection failed; retrying";e.logger.warn(`${n}: ${v} in ${u}ms (attempt ${f}/${o.maxAttempts})`),p=setTimeout(()=>{p=void 0,S=k(!1)},u),p.unref()}l(G,"scheduleReconnect");async function k(h){const u=new B({name:"dsh-mcp-client",version:"0.0.1"},{capabilities:{}}),v=Promise.withResolvers();let b=!1,P=!1;const _=l(()=>P,"hasClosed");a=u,r=v.promise,u.onclose=()=>{P=!0,v.resolve(),b&&A(u)},u.setNotificationHandler(W,async()=>{if(E(u)){e.logger.info(`${n}: tool list changed, re-syncing`);try{await O(u)}catch(C){d||e.logger.error(`${n}: tool re-sync failed: ${String(C)}`)}}});try{if(await u.connect(re(t)),_()){b=!0,A(u);return}await O(u,h?c:i)}catch(C){y===void 0&&(y=C),E(u)&&e.logger.warn(`${n}: connection attempt failed: ${String(C)}`);try{await u.close()}catch{}const U=_()||await R(v.promise);if(b=!0,!E(u))return;if(!U){a=void 0,r=void 0,e.logger.error(`${n}: failed generation did not close within ${j}ms — reconnect stopped to avoid overlapping server processes; reload the plugin or restart the Host to retry`);return}A(u);return}if(b=!0,_()){A(u);return}E(u)&&(g=Date.now(),f>0&&e.logger.info(`${n}: reconnected and re-synced tools (attempt ${f}/${o.maxAttempts})`))}l(k,"connectGeneration");let S=k(!0);return{ready:S.then(()=>a!==void 0?{}:{error:y??new Error(`${n}: initial connection failed`)}),async dispose(){d=!0,p!==void 0&&(clearTimeout(p),p=void 0);const h=a,u=r;if(a=void 0,r=void 0,h!==void 0){try{await h.close()}catch{}u!==void 0&&!await R(u)&&e.logger.error(`${n}: generation did not close within ${j}ms during disposal — server shutdown may be incomplete`)}await S,await $;for(const v of s.values())v();s=new Map}}}l($e,"startConnection");const Te="mcp-client",Ae=["tools"],L=6e4,z=/^[A-Za-z0-9_-]{1,32}$/,H=new WeakMap,F=m.object({enabled:m.boolean().default(w.enabled),initialDelayMs:m.number().min(1).max(M).default(w.initialDelayMs),maxDelayMs:m.number().min(1).max(M).default(w.maxDelayMs),maxAttempts:m.number().step(1).min(1).max(Number.MAX_SAFE_INTEGER).default(w.maxAttempts)}),Ce=m.union([m.object({transport:m.const("stdio"),serverName:m.string().required().pattern(z),command:m.string().required(),args:m.array(String).default([]),env:m.dict(String).default({}),cwd:m.string().default(""),toolCallTimeoutMs:m.number().default(L),failOnStartupError:m.boolean().default(!1),reconnect:F}),m.object({transport:m.const("streamable-http"),serverName:m.string().required().pattern(z),url:m.string().required(),headers:m.dict(String).default({}),toolCallTimeoutMs:m.number().default(L),failOnStartupError:m.boolean().default(!1),reconnect:F})]);async function xe(e,t){const o=Me(t.reconnect,`mcp-client(${t.serverName}): reconnect`);e.effect(()=>{let c=H.get(e.root);if(c||(c=new Set,H.set(e.root,c)),c.has(t.serverName))throw new Error(`mcp-client: serverName "${t.serverName}" is already in use by another mcp-client instance — pick a unique serverName in cordis.yml`);return c.add(t.serverName),()=>{c.delete(t.serverName)}},"mcp-client.serverName");const n=$e(e,t,o);e.effect(()=>()=>n.dispose(),"mcp-client.connection");const i=await n.ready;if(i.error!==void 0&&t.failOnStartupError)throw new Error(`mcp-client(${t.serverName}): initial connection or tool synchronization failed`,{cause:i.error})}l(xe,"apply");export{Ce as Config,xe as apply,Ae as inject,Te as name};
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-mcp-client","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-invariants":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-subprocess":"^0.0.15","@deepseek-ai/dsh-timeout":"^0.0.15","@deepseek-ai/dsh-tools":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@modelcontextprotocol/sdk":"^1.12.0","zod":"^4.4.3","@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-mcp-client","version":"0.1.0","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-attachment":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-subprocess":"^0.1.0","@deepseek-ai/dsh-tools":"^0.1.0","@deepseek-ai/dsh-timeout":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@modelcontextprotocol/sdk":"^1.12.0","zod":"^4.4.3","@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-message-feedback","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"},"./typert":{"types":"./lib/typert.host.d.ts","default":"./lib/typert.host.js"},"./remote":{"types":"./lib/typert.remote-client.d.ts","default":"./lib/typert.remote-client.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-session-persistence":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-brand":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-storage-domain":"^0.0.15","@deepseek-ai/dsh-typert-protocol":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"zod":"^4.4.3","@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-message-feedback","version":"0.1.0","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"},"./typert":{"types":"./lib/typert.host.d.ts","default":"./lib/typert.host.js"},"./remote":{"types":"./lib/typert.remote-client.d.ts","default":"./lib/typert.remote-client.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-brand":"^0.1.0","@deepseek-ai/dsh-session-persistence":"^0.1.0","@deepseek-ai/dsh-storage-domain":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-typert-protocol":"^0.1.0"},"dependencies":{"zod":"^4.4.3","@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-native-command","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-invariants":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"}}
1
+ {"name":"@deepseek-ai/dsh-native-command","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-output-retention","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/cordis":"^4.0.1","@deepseek-ai/dsh-invariants":"^0.0.15"}}
1
+ {"name":"@deepseek-ai/dsh-output-retention","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-permission-presets","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"},"./client":{"types":"./lib/types/client.d.ts","default":"./lib/types/client.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-shell":"^0.0.15","@deepseek-ai/dsh-commands":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-sandbox":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-sandbox-policy":"^0.0.15","@deepseek-ai/dsh-settings":"^0.0.15","@deepseek-ai/dsh-user-approval":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-session-projection":"^0.0.15"},"dependencies":{"zod":"^4.4.3","@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-permission-presets","version":"0.1.0","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"},"./client":{"types":"./lib/types/client.d.ts","default":"./lib/types/client.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-shell":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-sandbox-policy":"^0.1.0","@deepseek-ai/dsh-commands":"^0.1.0","@deepseek-ai/dsh-sandbox":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/dsh-session-projection":"^0.1.0","@deepseek-ai/dsh-settings":"^0.1.0","@deepseek-ai/dsh-user-approval":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"zod":"^4.4.3","@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-persona","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-invariants":"^0.0.15","@deepseek-ai/dsh-system-prompt":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-persona","version":"0.1.0","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-system-prompt":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-plan-mode","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"},"./client":{"types":"./lib/types/client.d.ts","default":"./lib/types/client.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-commands":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-session-projection":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-tools":"^0.0.15","@deepseek-ai/dsh-system-prompt":"^0.0.15","@deepseek-ai/dsh-user-questions":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"peerDependenciesMeta":{"@deepseek-ai/dsh-commands":{"optional":true}},"dependencies":{"zod":"^4.4.3"}}
1
+ {"name":"@deepseek-ai/dsh-plan-mode","version":"0.1.0","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"},"./client":{"types":"./lib/types/client.d.ts","default":"./lib/types/client.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-commands":"^0.1.0","@deepseek-ai/dsh-session-projection":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/dsh-system-prompt":"^0.1.0","@deepseek-ai/dsh-tools":"^0.1.0","@deepseek-ai/dsh-agent":"^0.1.0","@deepseek-ai/dsh-user-questions":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"peerDependenciesMeta":{"@deepseek-ai/dsh-commands":{"optional":true}},"dependencies":{"zod":"^4.4.3"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-pwsh-local","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-shell":"^0.0.15","@deepseek-ai/dsh-subprocess":"^0.0.15","@deepseek-ai/dsh-settings":"^0.0.15","@deepseek-ai/dsh-timeout":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-invariants":"^0.0.15"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-pwsh-local","version":"0.1.0","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-shell":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-subprocess":"^0.1.0","@deepseek-ai/dsh-timeout":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-settings":"^0.1.0"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-pwsh-sandbox","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-pwsh-local":"^0.0.15","@deepseek-ai/dsh-shell":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-sandbox-policy":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-sandbox":"^0.0.15"}}
1
+ {"name":"@deepseek-ai/dsh-pwsh-sandbox","version":"0.1.0","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-shell":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-pwsh-local":"^0.1.0","@deepseek-ai/dsh-sandbox-policy":"^0.1.0","@deepseek-ai/dsh-sandbox":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-qb-auth","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/cordis":"^4.0.1","@deepseek-ai/dsh-invariants":"^0.0.15"},"dependencies":{"@tencent/qb-auth-send-h5":"^2.5.0","@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-qb-auth","version":"0.1.0","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/cordis":"^4.0.1","@deepseek-ai/dsh-invariants":"^0.1.0"},"dependencies":{"@tencent/qb-auth-send-h5":"^2.5.0","@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-repeat-tool-reminder","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","dependencies":{"@deepseek-ai/schemastery":"^3.18.1"},"peerDependencies":{"@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-tools":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"}}
1
+ {"name":"@deepseek-ai/dsh-repeat-tool-reminder","version":"0.1.0","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","dependencies":{"@deepseek-ai/schemastery":"^3.18.1"},"peerDependencies":{"@deepseek-ai/dsh-agent":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-tools":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-sandbox","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-llm":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-session":"^0.0.15"}}
1
+ {"name":"@deepseek-ai/dsh-sandbox","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-session":"^0.1.0"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-sandbox-local","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-invariants":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-sandbox":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-session":"^0.0.15"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1","@deepseek-ai/dsh-sandbox-windows-acl":"^0.0.15","@deepseek-ai/node-addon-landlock-run":"^0.1.1"}}
1
+ {"name":"@deepseek-ai/dsh-sandbox-local","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-sandbox":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@deepseek-ai/dsh-sandbox-windows-acl":"^0.1.0","@deepseek-ai/schemastery":"^3.18.1","@deepseek-ai/node-addon-landlock-run":"^0.1.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-sandbox-policy","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-agent":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-sandbox":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-system-prompt":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
1
+ {"name":"@deepseek-ai/dsh-sandbox-policy","version":"0.1.0","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","@deepseek-ai/dsh-sandbox":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-system-prompt":"^0.1.0"},"dependencies":{"@deepseek-ai/schemastery":"^3.18.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-sandbox-windows-acl","version":"0.0.15","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./runner":{"types":"./lib/types/runner.d.ts","default":"./lib/runner.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-invariants":"^0.0.15"},"dependencies":{"koffi":"^3.1.0"}}
1
+ {"name":"@deepseek-ai/dsh-sandbox-windows-acl","version":"0.1.0","publishConfig":{"access":"public"},"type":"module","main":"lib/index.js","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./runner":{"types":"./lib/types/runner.d.ts","default":"./lib/runner.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"},"dependencies":{"koffi":"^3.1.0"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-schedule","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-agent":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-session-persistence":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-tools":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/dsh-brand":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"}}
1
+ {"name":"@deepseek-ai/dsh-schedule","version":"0.1.0","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","@deepseek-ai/dsh-brand":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-session-persistence":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/dsh-tools":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-scope","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-invariants":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"}}
1
+ {"name":"@deepseek-ai/dsh-scope","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-session","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","./surface":{"types":"./lib/types/surface.d.ts","default":"./lib/types/surface.js"}},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.0.15","@deepseek-ai/dsh-invariants":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-scope":"^0.0.15","@deepseek-ai/dsh-typert-protocol":"^0.0.15","@deepseek-ai/cordis":"^4.0.1"}}
1
+ {"name":"@deepseek-ai/dsh-session","version":"0.1.0","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","./surface":{"types":"./lib/types/surface.d.ts","default":"./lib/types/surface.js"}},"license":"MIT","peerDependencies":{"@deepseek-ai/dsh-brand":"^0.1.0","@deepseek-ai/dsh-invariants":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-typert-protocol":"^0.1.0","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-scope":"^0.1.0"}}
@@ -1 +1 @@
1
- {"name":"@deepseek-ai/dsh-session-checkpoint-policy","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-invariants":"^0.0.15","@deepseek-ai/dsh-agent":"^0.0.15","@deepseek-ai/dsh-llm":"^0.0.15","@deepseek-ai/dsh-session":"^0.0.15","@deepseek-ai/cordis":"^4.0.1","@deepseek-ai/dsh-session-persistence":"^0.0.15","@deepseek-ai/dsh-tools":"^0.0.15"}}
1
+ {"name":"@deepseek-ai/dsh-session-checkpoint-policy","version":"0.1.0","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-invariants":"^0.1.0","@deepseek-ai/dsh-agent":"^0.1.0","@deepseek-ai/dsh-llm":"^0.1.0","@deepseek-ai/dsh-session":"^0.1.0","@deepseek-ai/dsh-tools":"^0.1.0","@deepseek-ai/dsh-session-persistence":"^0.1.0","@deepseek-ai/cordis":"^4.0.1"}}