@draht/coding-agent 2026.11.5-1 → 2026.11.14-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/bundle/chunks/anthropic-messages-C5ZJVCKX.js +6 -0
  3. package/dist/bundle/chunks/{azure-openai-responses-NCMJPZVJ.js → azure-openai-responses-TNRID5YC.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
  5. package/dist/bundle/chunks/chunk-2CHTECAU.js +2 -0
  6. package/dist/bundle/chunks/{chunk-DWOGGNWY.js → chunk-2IQVBLH6.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-P7O36UDU.js → chunk-4FPBO5KP.js} +5 -1
  8. package/dist/bundle/chunks/{chunk-Q2QKCYPU.js → chunk-5C4MAPF6.js} +1 -1
  9. package/dist/bundle/chunks/chunk-5WEOWREV.js +82 -0
  10. package/dist/bundle/chunks/{chunk-DN7SM3LX.js → chunk-ATYP3OSV.js} +3 -1
  11. package/dist/bundle/chunks/chunk-B6S2UR4T.js +2 -0
  12. package/dist/bundle/chunks/chunk-EBTEI43G.js +20 -0
  13. package/dist/bundle/chunks/{chunk-F5TDVH26.js → chunk-GAABJAG4.js} +12 -15
  14. package/dist/bundle/chunks/{chunk-PMINB7UH.js → chunk-JHKMYVPC.js} +169 -130
  15. package/dist/bundle/chunks/{chunk-EOXOMUKR.js → chunk-LCTFXH4P.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-UFACUBF2.js → chunk-MPJIXESS.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-PZKD35UB.js → chunk-MXA4WY3C.js} +1 -1
  18. package/dist/bundle/chunks/chunk-O2XYFH2E.js +30 -0
  19. package/dist/bundle/chunks/{chunk-CA23BDNK.js → chunk-OUXJRC2W.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-3BJ462DN.js → chunk-RI7HJ6AF.js} +1 -1
  21. package/dist/bundle/chunks/chunk-RVXTPNXQ.js +44 -0
  22. package/dist/bundle/chunks/{chunk-QBUTRTYN.js → chunk-SXHVGWCU.js} +1 -1
  23. package/dist/bundle/chunks/chunk-WNZ64GW3.js +2 -0
  24. package/dist/bundle/chunks/chunk-XWZLYE4L.js +9 -0
  25. package/dist/bundle/chunks/{chunk-HJ3PS7QP.js → chunk-YSE3VKKB.js} +2 -2
  26. package/dist/bundle/chunks/{cli-4SUT6MJ6.js → cli-2QKCAPPD.js} +3 -3
  27. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-BJVMNETD.js → cloudflare-workers-ai-system-one-UCG6T3XP.js} +1 -1
  28. package/dist/bundle/chunks/codemode-worker.js +2 -0
  29. package/dist/bundle/chunks/{execute-ZI7T2SUH.js → execute-KGJOWTPG.js} +2 -2
  30. package/dist/bundle/chunks/github-copilot.js +1 -1
  31. package/dist/bundle/chunks/google-generative-ai-GPBKPOXA.js +2 -0
  32. package/dist/bundle/chunks/google-vertex-USZY53NF.js +2 -0
  33. package/dist/bundle/chunks/{llama-cpp-classify-L4URPZ4F.js → llama-cpp-classify-7DEQ4ZUF.js} +1 -1
  34. package/dist/bundle/chunks/{mistral-conversations-CK2BS74V.js → mistral-conversations-UOGXPDZ3.js} +1 -1
  35. package/dist/bundle/chunks/{openai-codex-responses-XGVNKP4D.js → openai-codex-responses-VUDXQ3EU.js} +1 -1
  36. package/dist/bundle/chunks/{openai-completions-72XZO4Q3.js → openai-completions-UQOOS7NM.js} +3 -3
  37. package/dist/bundle/chunks/{openai-decisions-P5OCXLLD.js → openai-decisions-24WNXO2R.js} +1 -1
  38. package/dist/bundle/chunks/{openai-responses-RGLZ4E3Q.js → openai-responses-5AF6MZ5L.js} +1 -1
  39. package/dist/bundle/chunks/{openrouter-images-LSBWMZDK.js → openrouter-images-OUXVVTYQ.js} +1 -1
  40. package/dist/bundle/chunks/{pi-messages-CL4MEVNS.js → pi-messages-DRMOEO6B.js} +1 -1
  41. package/dist/bundle/chunks/{runtime-FJYRBK3O.js → runtime-FZKS2BWI.js} +1 -1
  42. package/dist/bundle/chunks/{runtime-F4362CZF.js → runtime-L23MZBKL.js} +1 -1
  43. package/dist/bundle/chunks/{settings-manager-T6G6KKY3.js → settings-manager-CWRQW6PZ.js} +1 -1
  44. package/dist/bundle/chunks/{typesafe-system-one-BFYS6AEA.js → typesafe-system-one-K63EBJDD.js} +1 -1
  45. package/dist/bundle/chunks/virtual-modules-JZV35VDE.js +2 -0
  46. package/dist/bundle/cli-runtime.js +1 -1
  47. package/dist/bundle/index.js +1 -1
  48. package/dist/bundle/rpc-entry.js +1 -1
  49. package/dist/cli/args.d.ts.map +1 -1
  50. package/dist/cli/args.js +5 -3
  51. package/dist/cli/args.js.map +1 -1
  52. package/dist/cli/auth-command.d.ts.map +1 -1
  53. package/dist/cli/auth-command.js +30 -6
  54. package/dist/cli/auth-command.js.map +1 -1
  55. package/dist/cli/auth-login.d.ts +15 -0
  56. package/dist/cli/auth-login.d.ts.map +1 -0
  57. package/dist/cli/auth-login.js +232 -0
  58. package/dist/cli/auth-login.js.map +1 -0
  59. package/dist/cli/auth-logout.d.ts +14 -0
  60. package/dist/cli/auth-logout.d.ts.map +1 -0
  61. package/dist/cli/auth-logout.js +57 -0
  62. package/dist/cli/auth-logout.js.map +1 -0
  63. package/dist/cli/auth-terminal.d.ts +17 -0
  64. package/dist/cli/auth-terminal.d.ts.map +1 -0
  65. package/dist/cli/auth-terminal.js +63 -0
  66. package/dist/cli/auth-terminal.js.map +1 -0
  67. package/dist/core/agent-session-runtime.d.ts +5 -0
  68. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  69. package/dist/core/agent-session-runtime.js +16 -2
  70. package/dist/core/agent-session-runtime.js.map +1 -1
  71. package/dist/core/agent-session.d.ts +20 -9
  72. package/dist/core/agent-session.d.ts.map +1 -1
  73. package/dist/core/agent-session.js +71 -29
  74. package/dist/core/agent-session.js.map +1 -1
  75. package/dist/core/ai-schemas.d.ts +1 -0
  76. package/dist/core/ai-schemas.d.ts.map +1 -1
  77. package/dist/core/builtins/budgets.d.ts.map +1 -1
  78. package/dist/core/builtins/budgets.js +6 -3
  79. package/dist/core/builtins/budgets.js.map +1 -1
  80. package/dist/core/cache-warmer.d.ts +4 -37
  81. package/dist/core/cache-warmer.d.ts.map +1 -1
  82. package/dist/core/cache-warmer.js +11 -91
  83. package/dist/core/cache-warmer.js.map +1 -1
  84. package/dist/core/compaction/utils.d.ts.map +1 -1
  85. package/dist/core/compaction/utils.js +2 -1
  86. package/dist/core/compaction/utils.js.map +1 -1
  87. package/dist/core/exec.d.ts +1 -0
  88. package/dist/core/exec.d.ts.map +1 -1
  89. package/dist/core/exec.js +4 -1
  90. package/dist/core/exec.js.map +1 -1
  91. package/dist/core/export-html/ansi-to-html.d.ts +5 -0
  92. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  93. package/dist/core/export-html/ansi-to-html.js +57 -20
  94. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  95. package/dist/core/export-html/template.js +1 -1
  96. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  97. package/dist/core/export-html/tool-renderer.js +2 -3
  98. package/dist/core/export-html/tool-renderer.js.map +1 -1
  99. package/dist/core/extensions/types.d.ts +3 -2
  100. package/dist/core/extensions/types.d.ts.map +1 -1
  101. package/dist/core/extensions/types.js.map +1 -1
  102. package/dist/core/model-config.d.ts +13 -0
  103. package/dist/core/model-config.d.ts.map +1 -1
  104. package/dist/core/model-resolver.d.ts +0 -1
  105. package/dist/core/model-resolver.d.ts.map +1 -1
  106. package/dist/core/model-resolver.js +17 -24
  107. package/dist/core/model-resolver.js.map +1 -1
  108. package/dist/core/model-runtime.d.ts +5 -0
  109. package/dist/core/model-runtime.d.ts.map +1 -1
  110. package/dist/core/model-runtime.js +7 -0
  111. package/dist/core/model-runtime.js.map +1 -1
  112. package/dist/core/polyphase/render/format.d.ts +2 -0
  113. package/dist/core/polyphase/render/format.d.ts.map +1 -1
  114. package/dist/core/polyphase/render/format.js +6 -0
  115. package/dist/core/polyphase/render/format.js.map +1 -1
  116. package/dist/core/polyphase/render/run-block.d.ts +4 -0
  117. package/dist/core/polyphase/render/run-block.d.ts.map +1 -1
  118. package/dist/core/polyphase/render/run-block.js +71 -12
  119. package/dist/core/polyphase/render/run-block.js.map +1 -1
  120. package/dist/core/polyphase/render/snapshot.d.ts +1 -1
  121. package/dist/core/polyphase/render/snapshot.d.ts.map +1 -1
  122. package/dist/core/polyphase/render/snapshot.js +22 -7
  123. package/dist/core/polyphase/render/snapshot.js.map +1 -1
  124. package/dist/core/polyphase/ui/dock.d.ts.map +1 -1
  125. package/dist/core/polyphase/ui/dock.js +34 -2
  126. package/dist/core/polyphase/ui/dock.js.map +1 -1
  127. package/dist/core/polyphase/ui/inspector.d.ts +18 -6
  128. package/dist/core/polyphase/ui/inspector.d.ts.map +1 -1
  129. package/dist/core/polyphase/ui/inspector.js +125 -44
  130. package/dist/core/polyphase/ui/inspector.js.map +1 -1
  131. package/dist/core/polyphase/ui/transcript-layout.d.ts.map +1 -1
  132. package/dist/core/polyphase/ui/transcript-layout.js +5 -1
  133. package/dist/core/polyphase/ui/transcript-layout.js.map +1 -1
  134. package/dist/core/preferred-providers.d.ts +17 -0
  135. package/dist/core/preferred-providers.d.ts.map +1 -0
  136. package/dist/core/preferred-providers.js +24 -0
  137. package/dist/core/preferred-providers.js.map +1 -0
  138. package/dist/core/prompt-templates.d.ts.map +1 -1
  139. package/dist/core/prompt-templates.js +18 -2
  140. package/dist/core/prompt-templates.js.map +1 -1
  141. package/dist/core/provider-composer.d.ts.map +1 -1
  142. package/dist/core/provider-composer.js +2 -0
  143. package/dist/core/provider-composer.js.map +1 -1
  144. package/dist/core/provider-matching.d.ts +6 -0
  145. package/dist/core/provider-matching.d.ts.map +1 -0
  146. package/dist/core/provider-matching.js +8 -0
  147. package/dist/core/provider-matching.js.map +1 -0
  148. package/dist/core/radius-mcp.d.ts +13 -0
  149. package/dist/core/radius-mcp.d.ts.map +1 -0
  150. package/dist/core/radius-mcp.js +29 -0
  151. package/dist/core/radius-mcp.js.map +1 -0
  152. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  153. package/dist/core/remote-catalog-provider.js +2 -0
  154. package/dist/core/remote-catalog-provider.js.map +1 -1
  155. package/dist/core/runtime-credentials.d.ts +8 -0
  156. package/dist/core/runtime-credentials.d.ts.map +1 -1
  157. package/dist/core/runtime-credentials.js +15 -1
  158. package/dist/core/runtime-credentials.js.map +1 -1
  159. package/dist/core/session-cwd.d.ts +7 -0
  160. package/dist/core/session-cwd.d.ts.map +1 -1
  161. package/dist/core/session-cwd.js +9 -1
  162. package/dist/core/session-cwd.js.map +1 -1
  163. package/dist/core/session-manager.d.ts.map +1 -1
  164. package/dist/core/session-manager.js +45 -36
  165. package/dist/core/session-manager.js.map +1 -1
  166. package/dist/core/settings-defaults.d.ts +1 -1
  167. package/dist/core/settings-defaults.d.ts.map +1 -1
  168. package/dist/core/settings-defaults.js +1 -1
  169. package/dist/core/settings-defaults.js.map +1 -1
  170. package/dist/core/tools/bash.d.ts.map +1 -1
  171. package/dist/core/tools/bash.js +35 -5
  172. package/dist/core/tools/bash.js.map +1 -1
  173. package/dist/core/tools/edit-diff.d.ts +23 -14
  174. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  175. package/dist/core/tools/edit-diff.js +182 -41
  176. package/dist/core/tools/edit-diff.js.map +1 -1
  177. package/dist/core/tools/edit.d.ts.map +1 -1
  178. package/dist/core/tools/edit.js +8 -7
  179. package/dist/core/tools/edit.js.map +1 -1
  180. package/dist/core/tools/find.d.ts.map +1 -1
  181. package/dist/core/tools/find.js +57 -16
  182. package/dist/core/tools/find.js.map +1 -1
  183. package/dist/core/tools/grep.d.ts +4 -0
  184. package/dist/core/tools/grep.d.ts.map +1 -1
  185. package/dist/core/tools/grep.js +20 -8
  186. package/dist/core/tools/grep.js.map +1 -1
  187. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  188. package/dist/core/tools/output-accumulator.js +4 -1
  189. package/dist/core/tools/output-accumulator.js.map +1 -1
  190. package/dist/core/tools/powershell.d.ts.map +1 -1
  191. package/dist/core/tools/powershell.js +15 -2
  192. package/dist/core/tools/powershell.js.map +1 -1
  193. package/dist/core/tools/read.d.ts +13 -0
  194. package/dist/core/tools/read.d.ts.map +1 -1
  195. package/dist/core/tools/read.js +146 -35
  196. package/dist/core/tools/read.js.map +1 -1
  197. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  198. package/dist/core/tools/renderers/read.js +6 -2
  199. package/dist/core/tools/renderers/read.js.map +1 -1
  200. package/dist/core/tools/truncate.d.ts +4 -0
  201. package/dist/core/tools/truncate.d.ts.map +1 -1
  202. package/dist/core/tools/truncate.js +24 -1
  203. package/dist/core/tools/truncate.js.map +1 -1
  204. package/dist/extensions/codemode/execute.js +4 -4
  205. package/dist/extensions/codemode/execute.js.map +1 -1
  206. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  207. package/dist/extensions/codemode/tool.js +34 -12
  208. package/dist/extensions/codemode/tool.js.map +1 -1
  209. package/dist/extensions/llama/provider.d.ts +1 -1
  210. package/dist/extensions/llama/provider.js +1 -1
  211. package/dist/extensions/llama/provider.js.map +1 -1
  212. package/dist/extensions/llama/ui.d.ts.map +1 -1
  213. package/dist/extensions/llama/ui.js +15 -3
  214. package/dist/extensions/llama/ui.js.map +1 -1
  215. package/dist/extensions/mcp/cli.js +5 -8
  216. package/dist/extensions/mcp/cli.js.map +1 -1
  217. package/dist/extensions/mcp/index.d.ts.map +1 -1
  218. package/dist/extensions/mcp/index.js +2 -1
  219. package/dist/extensions/mcp/index.js.map +1 -1
  220. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  221. package/dist/extensions/mcp/runtime.js +3 -2
  222. package/dist/extensions/mcp/runtime.js.map +1 -1
  223. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  224. package/dist/extensions/tool-search/tool.js +18 -6
  225. package/dist/extensions/tool-search/tool.js.map +1 -1
  226. package/dist/main.d.ts.map +1 -1
  227. package/dist/main.js +67 -15
  228. package/dist/main.js.map +1 -1
  229. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  230. package/dist/modes/interactive/components/login-dialog.js +2 -19
  231. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  232. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  233. package/dist/modes/interactive/components/model-selector.js +14 -6
  234. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  235. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  236. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  237. package/dist/modes/interactive/components/oauth-selector.js +32 -5
  238. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  239. package/dist/modes/interactive/components/provider-brand.d.ts +14 -0
  240. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  241. package/dist/modes/interactive/components/provider-brand.js +66 -0
  242. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  243. package/dist/modes/interactive/components/radius-login-selector.d.ts +1 -2
  244. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  245. package/dist/modes/interactive/components/radius-login-selector.js +6 -37
  246. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  247. package/dist/modes/interactive/components/session-selector.d.ts +6 -1
  248. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/session-selector.js +23 -5
  250. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  251. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  252. package/dist/modes/interactive/components/tool-execution.js +3 -1
  253. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  254. package/dist/modes/interactive/interactive-mode.d.ts +11 -1
  255. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  256. package/dist/modes/interactive/interactive-mode.js +133 -78
  257. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  258. package/dist/modes/interactive/session-share.js +2 -0
  259. package/dist/modes/interactive/session-share.js.map +1 -1
  260. package/dist/package-manager-cli.d.ts.map +1 -1
  261. package/dist/package-manager-cli.js +27 -4
  262. package/dist/package-manager-cli.js.map +1 -1
  263. package/dist/prompts/commands/test-audit.md +84 -0
  264. package/dist/utils/image-resize.d.ts.map +1 -1
  265. package/dist/utils/image-resize.js +3 -1
  266. package/dist/utils/image-resize.js.map +1 -1
  267. package/dist/utils/terminal-question.d.ts +8 -0
  268. package/dist/utils/terminal-question.d.ts.map +1 -0
  269. package/dist/utils/terminal-question.js +24 -0
  270. package/dist/utils/terminal-question.js.map +1 -0
  271. package/dist/utils/web-url.d.ts +12 -0
  272. package/dist/utils/web-url.d.ts.map +1 -0
  273. package/dist/utils/web-url.js +20 -0
  274. package/dist/utils/web-url.js.map +1 -0
  275. package/docs/cli.md +14 -1
  276. package/docs/extensions.md +6 -4
  277. package/docs/llama-cpp.md +5 -5
  278. package/docs/models-configuration.md +2 -1
  279. package/docs/nvidia-rtx-llama-cpp.md +5 -5
  280. package/docs/polyphase.md +13 -1
  281. package/docs/prompt-templates.md +1 -1
  282. package/docs/providers.md +4 -2
  283. package/docs/quickstart.md +1 -1
  284. package/docs/rpc-commands.md +1 -1
  285. package/docs/rpc.md +1 -1
  286. package/docs/sessions.md +7 -1
  287. package/docs/settings.md +1 -1
  288. package/docs/tui.md +1 -1
  289. package/examples/extensions/gondolin/index.ts +4 -7
  290. package/examples/extensions/subagent/index.ts +5 -1
  291. package/package.json +10 -10
  292. package/prompts/commands/test-audit.md +84 -0
  293. package/schemas/models.schema.json +5 -1
  294. package/schemas/settings.schema.json +1 -1
  295. package/dist/bundle/chunks/anthropic-messages-UJZ4SGHU.js +0 -6
  296. package/dist/bundle/chunks/chunk-AOCWORXE.js +0 -2
  297. package/dist/bundle/chunks/chunk-BK5LXGIH.js +0 -2
  298. package/dist/bundle/chunks/chunk-DQ4G4IS4.js +0 -20
  299. package/dist/bundle/chunks/chunk-SUVMF4W5.js +0 -2
  300. package/dist/bundle/chunks/chunk-VXO6B72D.js +0 -9
  301. package/dist/bundle/chunks/chunk-WXASQQBZ.js +0 -44
  302. package/dist/bundle/chunks/chunk-YD5VPPI4.js +0 -30
  303. package/dist/bundle/chunks/chunk-YWRWN7ZB.js +0 -82
  304. package/dist/bundle/chunks/google-generative-ai-N5IPPKQY.js +0 -2
  305. package/dist/bundle/chunks/google-vertex-A4BKUE4H.js +0 -2
  306. package/dist/bundle/chunks/virtual-modules-BPZIVXNK.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __drahtCreateRequire } from "node:module"; const require = __drahtCreateRequire(import.meta.url);
2
- import{ownedSlice}from"./chunk-VXO6B72D.js";var MAX_PROVIDER_ERROR_BODY_CHARS=4e3;function normalizeProviderError(error){if(!(error instanceof Error))return{message:safeJsonStringify(error),messageCarriesBody:!1};let sdkError=error,status=extractStatus(sdkError),body=extractBody(sdkError),messageCarriesBody=body===void 0||error.message.includes(body),message=status===void 0&&body===void 0?withCauseDetail(error):error.message;return{status,body,message,messageCarriesBody}}var MAX_CAUSE_DEPTH=5;function withCauseDetail(error){let deepest,current=error.cause;for(let depth=0;depth<MAX_CAUSE_DEPTH&&current instanceof Error;depth++)deepest=current,current=current.cause;if(!deepest)return error.message;let detail=(deepest.message||deepest.name).trim(),code=deepest.code;return(typeof code=="string"||typeof code=="number")&&!detail.includes(String(code))&&(detail=detail?`${detail} (${code})`:String(code)),!detail||error.message.includes(detail)?error.message:error.message?`${error.message}: ${detail}`:detail}function extractStatus(error){if(typeof error.statusCode=="number")return error.statusCode;if(typeof error.status=="number")return error.status;if(typeof error.$metadata?.httpStatusCode=="number")return error.$metadata.httpStatusCode;if(typeof error.$response?.statusCode=="number")return error.$response.statusCode}function extractBody(error){let bodyText=pickBodyText(error);if(bodyText===void 0)return;let trimmed=bodyText.trim();if(trimmed.length!==0)return truncateErrorText(trimmed,MAX_PROVIDER_ERROR_BODY_CHARS)}function pickBodyText(error){if(typeof error.body=="string")return error.body;if(isPlainNonEmptyObject(error.error))return safeJsonStringify(error.error);let responseBody=error.$response?.body;if(typeof responseBody=="string")return responseBody;if(!isReadableStreamLike(responseBody)&&isPlainNonEmptyObject(responseBody))return safeJsonStringify(responseBody)}function isReadableStreamLike(value){return typeof value=="object"&&value!==null&&"pipe"in value&&typeof value.pipe=="function"}function isPlainNonEmptyObject(value){if(typeof value!="object"||value===null)return!1;let proto=Object.getPrototypeOf(value);return proto!==Object.prototype&&proto!==null?!1:Object.keys(value).length>0}function formatProviderError(norm,prefix){return norm.messageCarriesBody||norm.status===void 0||norm.body===void 0?prefix!==void 0&&norm.status!==void 0?`${prefix} (${norm.status}): ${norm.message}`:norm.message:prefix!==void 0?`${prefix} (${norm.status}): ${norm.body}`:`${norm.status}: ${norm.body}`}function truncateErrorText(text,maxChars){return text.length<=maxChars?text:`${ownedSlice(text,0,maxChars)}... [truncated ${text.length-maxChars} chars]`}function safeJsonStringify(value){try{let serialized=JSON.stringify(value);return serialized===void 0?String(value):serialized}catch{return String(value)}}export{normalizeProviderError,withCauseDetail,formatProviderError,truncateErrorText};
2
+ import{ownedSlice}from"./chunk-XWZLYE4L.js";var MAX_PROVIDER_ERROR_BODY_CHARS=4e3;function normalizeProviderError(error){if(!(error instanceof Error))return{message:safeJsonStringify(error),messageCarriesBody:!1};let sdkError=error,status=extractStatus(sdkError),body=extractBody(sdkError),messageCarriesBody=body===void 0||error.message.includes(body),message=status===void 0&&body===void 0?withCauseDetail(error):error.message;return{status,body,message,messageCarriesBody}}var MAX_CAUSE_DEPTH=5;function withCauseDetail(error){let deepest,current=error.cause;for(let depth=0;depth<MAX_CAUSE_DEPTH&&current instanceof Error;depth++)deepest=current,current=current.cause;if(!deepest)return error.message;let detail=(deepest.message||deepest.name).trim(),code=deepest.code;return(typeof code=="string"||typeof code=="number")&&!detail.includes(String(code))&&(detail=detail?`${detail} (${code})`:String(code)),!detail||error.message.includes(detail)?error.message:error.message?`${error.message}: ${detail}`:detail}function extractStatus(error){if(typeof error.statusCode=="number")return error.statusCode;if(typeof error.status=="number")return error.status;if(typeof error.$metadata?.httpStatusCode=="number")return error.$metadata.httpStatusCode;if(typeof error.$response?.statusCode=="number")return error.$response.statusCode}function extractBody(error){let bodyText=pickBodyText(error);if(bodyText===void 0)return;let trimmed=bodyText.trim();if(trimmed.length!==0)return truncateErrorText(trimmed,MAX_PROVIDER_ERROR_BODY_CHARS)}function pickBodyText(error){if(typeof error.body=="string")return error.body;if(isPlainNonEmptyObject(error.error))return safeJsonStringify(error.error);let responseBody=error.$response?.body;if(typeof responseBody=="string")return responseBody;if(!isReadableStreamLike(responseBody)&&isPlainNonEmptyObject(responseBody))return safeJsonStringify(responseBody)}function isReadableStreamLike(value){return typeof value=="object"&&value!==null&&"pipe"in value&&typeof value.pipe=="function"}function isPlainNonEmptyObject(value){if(typeof value!="object"||value===null)return!1;let proto=Object.getPrototypeOf(value);return proto!==Object.prototype&&proto!==null?!1:Object.keys(value).length>0}function formatProviderError(norm,prefix){return norm.messageCarriesBody||norm.status===void 0||norm.body===void 0?prefix!==void 0&&norm.status!==void 0?`${prefix} (${norm.status}): ${norm.message}`:norm.message:prefix!==void 0?`${prefix} (${norm.status}): ${norm.body}`:`${norm.status}: ${norm.body}`}function truncateErrorText(text,maxChars){return text.length<=maxChars?text:`${ownedSlice(text,0,maxChars)}... [truncated ${text.length-maxChars} chars]`}function safeJsonStringify(value){try{let serialized=JSON.stringify(value);return serialized===void 0?String(value):serialized}catch{return String(value)}}export{normalizeProviderError,withCauseDetail,formatProviderError,truncateErrorText};