@songtonyli/dsh-cli 0.1.35 → 0.1.37

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 (67) hide show
  1. package/README.md +1 -1
  2. package/bin/dsh.mjs +1 -1
  3. package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
  4. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  5. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +2 -2
  6. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +15 -12
  7. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +15 -12
  8. package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +959 -659
  9. package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
  10. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +1 -1
  11. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +1 -1
  12. package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +85 -33
  13. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +22 -37
  14. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +26 -4
  15. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +49 -8
  16. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +12 -7
  17. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +22 -22
  18. package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +0 -15
  19. package/node_modules/@smithy/core/dist-es/submodules/client/index.js +1 -1
  20. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/command.js +8 -1
  21. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +18 -3
  22. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +49 -8
  23. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +12 -7
  24. package/node_modules/@smithy/core/package.json +2 -2
  25. package/node_modules/@smithy/types/package.json +1 -1
  26. package/node_modules/undici/docs/docs/api/Agent.md +8 -8
  27. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
  28. package/node_modules/undici/docs/docs/api/Errors.md +25 -0
  29. package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
  30. package/node_modules/undici/docs/docs/api/Pool.md +5 -6
  31. package/node_modules/undici/lib/api/readable.js +1 -2
  32. package/node_modules/undici/lib/core/request.js +23 -2
  33. package/node_modules/undici/lib/core/util.js +0 -39
  34. package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
  35. package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
  36. package/node_modules/undici/lib/dispatcher/client.js +1 -1
  37. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -2
  38. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
  39. package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
  40. package/node_modules/undici/lib/dispatcher/pool.js +90 -7
  41. package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
  42. package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
  43. package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
  44. package/node_modules/undici/lib/handler/retry-handler.js +72 -13
  45. package/node_modules/undici/lib/interceptor/cache.js +4 -1
  46. package/node_modules/undici/lib/interceptor/decompress.js +236 -69
  47. package/node_modules/undici/lib/web/cache/cache.js +17 -8
  48. package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
  49. package/node_modules/undici/lib/web/cookies/index.js +19 -7
  50. package/node_modules/undici/lib/web/cookies/util.js +3 -1
  51. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
  52. package/node_modules/undici/lib/web/fetch/body.js +22 -15
  53. package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
  54. package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
  55. package/node_modules/undici/lib/web/fetch/headers.js +34 -31
  56. package/node_modules/undici/lib/web/fetch/index.js +38 -14
  57. package/node_modules/undici/lib/web/fetch/request.js +74 -79
  58. package/node_modules/undici/lib/web/fetch/response.js +43 -44
  59. package/node_modules/undici/lib/web/fetch/util.js +7 -7
  60. package/node_modules/undici/lib/web/infra/index.js +16 -1
  61. package/node_modules/undici/lib/web/webidl/index.js +2 -14
  62. package/node_modules/undici/lib/web/websocket/events.js +43 -26
  63. package/node_modules/undici/lib/web/websocket/receiver.js +5 -0
  64. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
  65. package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
  66. package/node_modules/undici/package.json +1 -1
  67. package/package.json +4 -4
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/bundle/tui-app/README.md
5
- README.md: 97dc4bfc8054fa5738430bd04fb121bd5163bad1
6
- README.zh.md: 2fc08fafcbf0b6bf1d9a1f6e51ad7ec101cc1558
5
+ README.md: 58e0ed0b4d68ad66e8ad91d57211f335e696d747
6
+ README.zh.md: 5c01bc43cb57f4ca62f55ed896d852afe66282a9
@@ -48,7 +48,7 @@ While the keyboard walks the conversation a framed inspector is docked directly
48
48
 
49
49
  The focused block is also marked where it stands, with a two-column gutter that is dim beside the block's other lines and accented beside the focused section's own — or beside the fold marker, when the fold left that section out of the drawn rows entirely — and its content wraps two columns narrower while the mark is drawn. That mark reaches only the lines pi-tui still repaints differentially — the last `rows` lines of the last frame it wrote, a window a taller frame raises and a shorter one never lowers — because changing anything above them would clear the terminal's scrollback. A block that has scrolled past that point keeps no gutter, the inspector heading appends ` · off screen`, and the frame's own rules draw dim instead of accent, so the frame itself reports that the mark cannot be drawn where the block stands. A fade whose rows reach that edge settles them to their final colors in the frame that writes them, so nothing stays dim in the scrollback.
50
50
 
51
- `Ctrl+G` from any region, `Enter` on a conversation section, and `/turns` read the conversation full screen, one turn at a time. The reader takes the terminal rather than drawing over the conversation: it runs on the terminal's alternate screen, the screen a pager runs on, and the conversation's own screen is held off the terminal for as long as it is up. So it costs the conversation no line, leaves the repaint window where it was, fills the screen on every terminal, and cannot leave a row of itself in your scrollback; closing it restores the conversation exactly as you left it, with whatever landed meanwhile drawn underneath. Under a top rule carrying a ` ● READER ` chip and `turn <n> of <total>`, the turn being read takes most of the screen and a narrow turn list sits to its left. The list has one row per turn — `❯` on the turn being read, the turn number, the first line of its prompt, and right-aligned markers, `⬡<n>` injected context blocks, `✻` any reasoning, `¶` any reply, `◆<n>` tool calls — with the sections of the turn being read listed under it, `▸` on the one the reader holds, so any turn's own context is one step away. The turn panel scrolls that turn end to end in the conversation's own glyphs, a blank row between each two sections: the prompt opens it behind `❯` on a shaded band, then `✻ Thinking` dim, `¶ Reply` with Markdown bullets drawn as `•`, a call's `◆` — green once its result landed, yellow while it runs — with the tool name in bold and its headline in the link blue, `⎿ Result` indented under its call with a diff's `+ ` rows green and `- ` rows red on shaded bands, and `⬡` with the label of an injected context. The section the top row belongs to is accented and carries the conversation walk's `┃` gutter on every row, which reads with no color at all. The bands are mixed from the background color the terminal reports, so a terminal that reports none, or draws no color, draws the panel without them. Rows are never folded there: the reader is where the full model-facing text of a system prompt, an injected snapshot, a long reply, or a tool result is read. `Right` opens the selected turn and `Left` goes back to the list; in the list `Up` / `Down` step one section at a time and cross into the turn either side while `PageUp` / `PageDown` step a whole turn, in the turn they scroll one row at a time, and the section the top row belongs to is where the conversation resumes when the reader closes. `/` opens a query line in place of the legend and narrows the list to the turns whose prompt or text matches, with the readout reading `<kept>/<total> turns`; otherwise the legend rule reports `turn 3/12 · row 14/212` at its right, which no width drops. Below `readerMinColumns` the body draws one panel at a time — the list, or the turn `Right` opens from it — and below 24 columns or 8 rows it draws one dim line, `terminal too small for the reader (needs 24×8)`, and answers only `Esc`, `Ctrl+G`, and `Ctrl+C`. It re-reads the conversation on every render, so a streaming reply grows inside it, a landing tool result appears, and a new turn joins the list; a rewrap re-anchors on the section being read rather than on a row number; an approval or a question steps it aside for that prompt's lifetime; and a session switch takes it down with the notice `the transcript changed · reader closed`.
51
+ `Ctrl+G` from any region, `Enter` on a conversation section, and `/turns` read the conversation full screen, one turn at a time. The reader takes the terminal rather than drawing over the conversation: it runs on the terminal's alternate screen, the screen a pager runs on, and the conversation's own screen is held off the terminal for as long as it is up. So it costs the conversation no line, leaves the repaint window where it was, fills the screen on every terminal, and cannot leave a row of itself in your scrollback; closing it restores the conversation exactly as you left it, with whatever landed meanwhile drawn underneath. Under a top rule carrying a ` ● READER ` chip and `turn <n> of <total>`, the turn being read takes most of the screen and a narrow turn list sits to its left, every body row closed by a right border. The list has one row per turn — `❯` on the turn being read, the turn number, the first line of its prompt, and right-aligned markers, `⬡<n>` injected context blocks, `✻` any reasoning, `¶` any reply, `◆<n>` tool calls — with the sections of the turn being read listed under it, `▸` on the one the reader holds, so any turn's own context is one step away. The turn panel scrolls that turn end to end in the conversation's own glyphs, a blank row between each two sections: the prompt opens it behind `❯` on a shaded band, then `✻ Thinking` in dim italic, `¶ Reply` rendered as the conversation renders Markdown — headings, emphasis, inline code, and fenced code in syntax colour — except that unordered bullets are drawn as `•`, a call's `◆` — green once its result landed, yellow while it runs — with the tool name in bold and its headline in the link blue, `⎿ Result` indented under its call with a diff's `+ ` rows green and `- ` rows red on shaded bands and a `read` card's file rows in syntax colour, and `⬡` with the label of an injected context. The section the top row belongs to is accented and carries the conversation walk's `┃` gutter on every row, which reads with no color at all. The bands are mixed from the background color the terminal reports, so a terminal that reports none, or draws no color, draws the panel without them. Rows are never folded there: the reader is where the full model-facing text of a system prompt, an injected snapshot, a long reply, or a tool result is read. `Right` opens the selected turn and `Left` goes back to the list; in the list `Up` / `Down` step one section at a time and cross into the turn either side while `PageUp` / `PageDown` step a whole turn, in the turn they scroll one row at a time, and the section the top row belongs to is where the conversation resumes when the reader closes. `/` opens a query line in place of the legend and narrows the list to the turns whose prompt or text matches, with the readout reading `<kept>/<total> turns`; otherwise the legend rule reports `turn 3/12 · row 14/212` at its right, which no width drops. Below `readerMinColumns` the body draws one panel at a time — the list, or the turn `Right` opens from it — and below 24 columns or 8 rows it draws one dim line, `terminal too small for the reader (needs 24×8)`, and answers only `Esc`, `Ctrl+G`, and `Ctrl+C`. It re-reads the conversation on every render, so a streaming reply grows inside it, a landing tool result appears, and a new turn joins the list; a rewrap re-anchors on the section being read rather than on a row number; an approval or a question steps it aside for that prompt's lifetime; and a session switch takes it down with the notice `the transcript changed · reader closed`.
52
52
 
53
53
  Transient key feedback floats as a dim framed line in the top-right corner of the viewport: `press Esc again to stop turn <n>`, `press Ctrl+C again to quit`, and `nothing in the transcript to read yet`. It holds at full strength for `toastMs`, fades out, costs the conversation no row of its own, and takes no keyboard; where the renderer can no longer repaint the top of the viewport it is printed into the conversation instead, which keeps it. Facts worth keeping are notices in the conversation: `stopping the turn…`, `wait for the session switch to finish`, `above the repaint window · opened in the reader`, and every command result.
54
54
 
@@ -48,7 +48,7 @@ dsh tui --no-open # print sign-in URLs without opening a
48
48
 
49
49
  被聚焦的块也会在原地被标记:一条两列宽的标记条,在块的其他行旁为暗色、在被聚焦小节自身的行旁为强调色——若折叠把该小节整个留在了绘出的行之外,强调色便落在那一行折叠标记旁——标记绘制期间该块的内容按窄两列换行。这个标记只能落在 pi-tui 仍以差分方式重绘的行上——也就是它写出的上一帧的最后 `rows` 行,这条边界只会被更高的帧抬高、不会被更矮的帧降低——因为改动其上方的任何一行都会清空终端的回滚区。已经滚过该位置的块不带标记条,检视面板的标题追加 ` · off screen`,其边框线也改画暗色而非强调色,于是边框本身就报告出标记无法画在该块所在之处。淡入中的各行抵达这一边界时,会在写出它们的同一帧内被结算为最终颜色,因此回滚区里不会留下暗色文字。
50
50
 
51
- 在任一区域按 `Ctrl+G`、在对话记录的某个小节上按 `Enter`,以及 `/turns`,都会整屏读出对话记录,一次读一个轮次。阅读器并不画在对话记录之上,而是接管终端:它运行在终端的备用屏幕(alternate screen,分页器所用的那块屏幕)上,只要它还开着,对话记录自己的屏幕就被挡在终端之外。因此它不占用对话记录的任何一行,让重绘边界保持原位,在任何终端上都铺满整屏,也不可能把自己的任何一行留在你的回滚缓冲里;关闭它会把对话记录原样恢复成你离开时的样子,期间落地的内容则绘制在其下方。在带有 ` ● READER ` 徽标与 `turn <n> of <total>` 的顶边线之下,正在阅读的轮次占据屏幕的大部分,左侧是一列窄的轮次列表。列表每个轮次一行——正在阅读的轮次带 `❯`、轮次编号、其提示的首行,以及右对齐的标记 `⬡<n>` 注入上下文块数、`✻` 有推理、`¶` 有回复、`◆<n>` 工具调用数——并在正在阅读的那个轮次之下列出它的各小节,`▸` 落在阅读器所持的那一个上,因此任何轮次自己的上下文都只有一步之遥。轮次面板用对话记录自己的符号把该轮次从头到尾滚动读出,相邻两个小节之间隔一空行:提示以 `❯` 开头、铺在着色背景带上,其后是暗色的 `✻ Thinking`、Markdown 列表符号画成 `•` 的 `¶ Reply`、工具调用的 `◆`(结果落地后为绿色、运行中为黄色)连同粗体工具名与链接蓝色的标题、缩进在调用之下的 `⎿ Result`(diff 的 `+ ` 行为绿色、`- ` 行为红色,各铺在着色背景带上),以及带注入上下文标签的 `⬡`。顶行所属的小节带强调色,并在每一行带上对话记录走查所用的 `┃` 标记条,无色时也能辨认。背景带由终端报告的背景色混合而成,因此没有报告背景色、或不绘制颜色的终端画出的面板不带背景带。那里的行从不折叠:阅读器正是读取系统提示词、注入快照、长回复或工具结果完整面向模型文本的地方。`Right` 打开被选中的轮次,`Left` 回到轮次列表;在列表中 `Up` / `Down` 每次步进一个小节并跨入相邻的轮次,而 `PageUp` / `PageDown` 步进整个轮次;在轮次面板中它们逐行滚动,而顶行所属的小节就是阅读器关闭后对话记录恢复到的位置。`/` 在按键提示的位置打开一行查询,把轮次列表收窄到提示或文本匹配的轮次,读数写作 `<kept>/<total> turns`;其余时候提示边线在右端报告 `turn 3/12 · row 14/212`,任何宽度都不会丢弃它。列数不足 `readerMinColumns` 时正文一次只画一个面板——轮次列表,或由 `Right` 从中打开的那个轮次——不足 24 列或 8 行时只画一行暗色文字 `terminal too small for the reader (needs 24×8)`,并且只应答 `Esc`、`Ctrl+G` 与 `Ctrl+C`。它在每一帧都重新读取对话记录,因此流式回复会在其中增长、落地的工具结果会出现、新轮次会加入轮次列表;重新换行时它按正在阅读的小节重新锚定,而不是按行号;审批或提问出现时它在该提示存续期间让位;切换会话会让它随通知 `the transcript changed · reader closed` 一同关闭。
51
+ 在任一区域按 `Ctrl+G`、在对话记录的某个小节上按 `Enter`,以及 `/turns`,都会整屏读出对话记录,一次读一个轮次。阅读器并不画在对话记录之上,而是接管终端:它运行在终端的备用屏幕(alternate screen,分页器所用的那块屏幕)上,只要它还开着,对话记录自己的屏幕就被挡在终端之外。因此它不占用对话记录的任何一行,让重绘边界保持原位,在任何终端上都铺满整屏,也不可能把自己的任何一行留在你的回滚缓冲里;关闭它会把对话记录原样恢复成你离开时的样子,期间落地的内容则绘制在其下方。在带有 ` ● READER ` 徽标与 `turn <n> of <total>` 的顶边线之下,正在阅读的轮次占据屏幕的大部分,左侧是一列窄的轮次列表,每个正文行都以右边框收口。列表每个轮次一行——正在阅读的轮次带 `❯`、轮次编号、其提示的首行,以及右对齐的标记 `⬡<n>` 注入上下文块数、`✻` 有推理、`¶` 有回复、`◆<n>` 工具调用数——并在正在阅读的那个轮次之下列出它的各小节,`▸` 落在阅读器所持的那一个上,因此任何轮次自己的上下文都只有一步之遥。轮次面板用对话记录自己的符号把该轮次从头到尾滚动读出,相邻两个小节之间隔一空行:提示以 `❯` 开头、铺在着色背景带上,其后是暗色斜体的 `✻ Thinking`、按对话记录的方式渲染 Markdown(标题、强调、行内代码,以及带语法着色的围栏代码)但无序列表符号画成 `•` 的 `¶ Reply`、工具调用的 `◆`(结果落地后为绿色、运行中为黄色)连同粗体工具名与链接蓝色的标题、缩进在调用之下的 `⎿ Result`(diff 的 `+ ` 行为绿色、`- ` 行为红色,各铺在着色背景带上;`read` 卡片的文件行带语法着色),以及带注入上下文标签的 `⬡`。顶行所属的小节带强调色,并在每一行带上对话记录走查所用的 `┃` 标记条,无色时也能辨认。背景带由终端报告的背景色混合而成,因此没有报告背景色、或不绘制颜色的终端画出的面板不带背景带。那里的行从不折叠:阅读器正是读取系统提示词、注入快照、长回复或工具结果完整面向模型文本的地方。`Right` 打开被选中的轮次,`Left` 回到轮次列表;在列表中 `Up` / `Down` 每次步进一个小节并跨入相邻的轮次,而 `PageUp` / `PageDown` 步进整个轮次;在轮次面板中它们逐行滚动,而顶行所属的小节就是阅读器关闭后对话记录恢复到的位置。`/` 在按键提示的位置打开一行查询,把轮次列表收窄到提示或文本匹配的轮次,读数写作 `<kept>/<total> turns`;其余时候提示边线在右端报告 `turn 3/12 · row 14/212`,任何宽度都不会丢弃它。列数不足 `readerMinColumns` 时正文一次只画一个面板——轮次列表,或由 `Right` 从中打开的那个轮次——不足 24 列或 8 行时只画一行暗色文字 `terminal too small for the reader (needs 24×8)`,并且只应答 `Esc`、`Ctrl+G` 与 `Ctrl+C`。它在每一帧都重新读取对话记录,因此流式回复会在其中增长、落地的工具结果会出现、新轮次会加入轮次列表;重新换行时它按正在阅读的小节重新锚定,而不是按行号;审批或提问出现时它在该提示存续期间让位;切换会话会让它随通知 `the transcript changed · reader closed` 一同关闭。
52
52
 
53
53
  临时按键反馈以一行暗色带框文字浮在视口右上角:`press Esc again to stop turn <n>`、`press Ctrl+C again to quit` 与 `nothing in the transcript to read yet`。它以全亮度保持 `toastMs`、随后淡出,不占用对话记录自身的任何一行,也不接管键盘;渲染器已无法重绘视口顶部时,它改为打印进对话记录,从而被保留下来。值得留存的事实则是对话记录中的通知:`stopping the turn…`、`wait for the session switch to finish`、`above the repaint window · opened in the reader` 以及每一条命令结果。
54
54
 
@@ -3373,14 +3373,23 @@ var ToolBlock = class {
3373
3373
  * @returns the call section, then the result section once the tool answered.
3374
3374
  */
3375
3375
  parts() {
3376
- const call = [...this.call.title === "" ? [] : [this.call.title], ...this.call.lines];
3377
- const parts = [{
3376
+ const title = this.call.title === "" ? [] : [this.call.title];
3377
+ const call = [...title, ...this.call.lines];
3378
+ const parts = [call.length === 0 ? {
3378
3379
  kind: "call",
3379
- rows: call.length === 0 ? [NO_ARGUMENTS] : call
3380
+ rows: [NO_ARGUMENTS]
3381
+ } : {
3382
+ kind: "call",
3383
+ rows: call,
3384
+ ...this.call.code === void 0 ? {} : { code: [...title.map(() => void 0), ...this.call.code] }
3380
3385
  }];
3381
- if (this.status !== "running") parts.push({
3386
+ if (this.status !== "running") parts.push(this.resultLines.length === 0 ? {
3382
3387
  kind: "result",
3383
- rows: this.resultLines.length === 0 ? [NO_OUTPUT] : this.resultLines
3388
+ rows: [NO_OUTPUT]
3389
+ } : {
3390
+ kind: "result",
3391
+ rows: this.resultLines,
3392
+ ...this.resultCode === void 0 ? {} : { code: this.resultCode }
3384
3393
  });
3385
3394
  return parts;
3386
3395
  }
@@ -7410,11 +7419,13 @@ const LIST_SHARE = .25;
7410
7419
  const CHROME_ROWS = 3;
7411
7420
  /** Columns one body column spends on the border before it and the space after it. */
7412
7421
  const COLUMN_MARGIN = 2;
7422
+ /** Columns a body row spends closing the frame: the space and the right border. */
7423
+ const CLOSE_MARGIN = 2;
7413
7424
  /** What the chip names this mode. */
7414
7425
  const READER_CHIP = "READER";
7415
7426
  /** What ends a line the width cut short; one column, so the mark itself fits. */
7416
7427
  const ELLIPSIS$1 = "…";
7417
- /** The left border of a body row and the border between the two panels. */
7428
+ /** The left and right borders of a body row and the border between the two panels. */
7418
7429
  const SIDE = "│";
7419
7430
  /** Marks the listed section the keyboard holds. */
7420
7431
  const LIST_MARK = "▸";
@@ -7430,8 +7441,8 @@ const BODY_INDENT = " ";
7430
7441
  const RESULT_INDENT = " ";
7431
7442
  /** What a Markdown bullet of a reply is drawn as. */
7432
7443
  const BULLET = "• ";
7433
- /** A Markdown bullet at the start of a reply row: its indentation, then the marker and one space. */
7434
- const MARKDOWN_BULLET = /^(\s*)[-*+] /;
7444
+ /** The marker pi-tui's Markdown draws an unordered list item with. */
7445
+ const MARKDOWN_BULLET = "- ";
7435
7446
  /** What opens a source row a diff adds. */
7436
7447
  const ADDED_PREFIX = "+ ";
7437
7448
  /** What opens a source row a diff removes. */
@@ -7657,20 +7668,57 @@ function rowTone(block, part, row) {
7657
7668
  if (row.startsWith(ADDED_PREFIX)) return "added";
7658
7669
  if (row.startsWith(REMOVED_PREFIX)) return "removed";
7659
7670
  }
7660
- return part.kind === "reasoning" || part.kind === "call" ? "dim" : "plain";
7671
+ if (part.kind === "reasoning") return "thought";
7672
+ return part.kind === "call" ? "dim" : "plain";
7661
7673
  }
7674
+ /** An unstyled palette, which is all measuring needs: styling never changes a row count. */
7675
+ const MEASURING = createPalette(false);
7676
+ /** Replies whose measured rows {@link measuredReplies} keeps before it starts over. */
7677
+ const MEASURED_REPLIES = 256;
7678
+ /** Measured reply rows, by width and text. */
7679
+ const measuredReplies = /* @__PURE__ */ new Map();
7662
7680
  /**
7663
7681
  * The source rows a section's body draws. A call whose first row repeats the
7664
- * headline the header already names starts after it, and a reply's Markdown
7665
- * bullets are drawn as `•`; every other row is the model-facing text as is.
7682
+ * headline the header already names starts after it; every other row is the
7683
+ * model-facing text as is.
7666
7684
  * @param block - the block the section belongs to.
7667
7685
  * @param part - the section.
7668
- * @returns the rows, unwrapped.
7686
+ * @returns the rows, unwrapped, with their code spans.
7669
7687
  */
7670
7688
  function bodySource(block, part) {
7671
- if (block.blockKind === "tool" && part.kind === "call" && block.title !== "" && part.rows[0] === block.title) return part.rows.slice(1);
7672
- if (part.kind === "reply") return part.rows.map((row) => row.replace(MARKDOWN_BULLET, `$1${BULLET}`));
7673
- return part.rows;
7689
+ if (block.blockKind === "tool" && part.kind === "call" && block.title !== "" && part.rows[0] === block.title) return {
7690
+ rows: part.rows.slice(1),
7691
+ code: part.code?.slice(1)
7692
+ };
7693
+ return {
7694
+ rows: part.rows,
7695
+ code: part.code
7696
+ };
7697
+ }
7698
+ /**
7699
+ * A reply drawn as the conversation draws it: Markdown, with fenced code in
7700
+ * syntax colour, except that an unordered list item is marked `•`. The rows
7701
+ * depend on the text and the width alone, since every theme role keeps the
7702
+ * text it is given.
7703
+ * @param rows - the reply's source rows.
7704
+ * @param width - the columns the reply lays out in.
7705
+ * @param look - the palette and the highlighter.
7706
+ * @returns the rows, trailing padding removed.
7707
+ */
7708
+ function replyRows(rows, width, look) {
7709
+ const text = rows.join("\n");
7710
+ const key = look.palette === MEASURING ? `${String(width)}\n${text}` : void 0;
7711
+ const known = key === void 0 ? void 0 : measuredReplies.get(key);
7712
+ if (known !== void 0) return known;
7713
+ const theme = markdownTheme(look.palette, look.highlight);
7714
+ const listBullet = theme.listBullet;
7715
+ theme.listBullet = (marker) => listBullet(marker === MARKDOWN_BULLET ? BULLET : marker);
7716
+ const lines = new Markdown(text, 0, 0, theme).render(width).map((line) => line.trimEnd());
7717
+ if (key !== void 0) {
7718
+ if (measuredReplies.size >= MEASURED_REPLIES) measuredReplies.clear();
7719
+ measuredReplies.set(key, lines);
7720
+ }
7721
+ return lines;
7674
7722
  }
7675
7723
  /**
7676
7724
  * Fit one styled text to an exact number of columns.
@@ -7726,6 +7774,7 @@ function bodyRow(line, tone, indent, width, look) {
7726
7774
  switch (tone) {
7727
7775
  case "plain": return `${indent}${line}`;
7728
7776
  case "dim": return `${indent}${palette.dim(line)}`;
7777
+ case "thought": return `${indent}${palette.dim(palette.italic(line))}`;
7729
7778
  case "added":
7730
7779
  case "removed": {
7731
7780
  const paint = tone === "added" ? palette.success : palette.error;
@@ -7748,7 +7797,7 @@ function bodyRow(line, tone, indent, width, look) {
7748
7797
  * @param cursor - the section.
7749
7798
  * @param blocks - the navigable blocks.
7750
7799
  * @param width - the panel's columns, the gutter included.
7751
- * @param look - the palette, the bands, and whether the reader holds the section.
7800
+ * @param look - the palette, the bands, the highlighter, and whether the reader holds the section.
7752
7801
  * @returns the rows, or none for a section the transcript no longer carries.
7753
7802
  */
7754
7803
  function sectionRows(cursor, blocks, width, look) {
@@ -7761,10 +7810,15 @@ function sectionRows(cursor, blocks, width, look) {
7761
7810
  else {
7762
7811
  const indent = part.kind === "result" ? `${RESULT_INDENT}${BODY_INDENT}` : BODY_INDENT;
7763
7812
  const room = Math.max(1, content - visibleWidth(indent));
7764
- rows = [headerRow(block, part, content, look), ...bodySource(block, part).flatMap((row) => {
7765
- const tone = rowTone(block, part, row);
7766
- return wrapTextWithAnsi(row, room).map((line) => bodyRow(line, tone, indent, content, look));
7767
- })];
7813
+ const header = headerRow(block, part, content, look);
7814
+ if (block.blockKind === "assistant" && part.kind === "reply") rows = [header, ...replyRows(part.rows, room, look).map((line) => `${indent}${line}`)];
7815
+ else {
7816
+ const source = bodySource(block, part);
7817
+ rows = [header, ...paintCodeRows(source.rows, source.code, look.highlight).flatMap((row, index) => {
7818
+ const tone = rowTone(block, part, source.rows[index]);
7819
+ return wrapTextWithAnsi(row, room).map((line) => bodyRow(line, tone, indent, content, look));
7820
+ })];
7821
+ }
7768
7822
  }
7769
7823
  const gutter = look.held ? look.palette.accent(HELD_GUTTER) : GUTTER;
7770
7824
  return rows.map((row) => `${gutter}${row}`);
@@ -7784,13 +7838,12 @@ function turnLayout(group, blocks, width, look) {
7784
7838
  const rows = sectionRows(section, blocks, width, {
7785
7839
  palette: look.palette,
7786
7840
  tints: look.tints,
7841
+ highlight: look.highlight,
7787
7842
  held
7788
7843
  });
7789
7844
  return index === last || rows.length === 0 ? rows : [...rows, ""];
7790
7845
  });
7791
7846
  }
7792
- /** An unstyled palette, which is all measuring needs: styling never changes a row count. */
7793
- const MEASURING = createPalette(false);
7794
7847
  /**
7795
7848
  * Measure the turn panel, which is what the scroll keys move over.
7796
7849
  * @param group - the turn the panel shows.
@@ -7835,17 +7888,17 @@ function readerGeometry(width, rows, state, minColumns) {
7835
7888
  if (width < minColumns) return state.column === "pane" ? {
7836
7889
  ...base,
7837
7890
  list: 0,
7838
- pane: width - COLUMN_MARGIN
7891
+ pane: width - COLUMN_MARGIN - CLOSE_MARGIN
7839
7892
  } : {
7840
7893
  ...base,
7841
- list: width - COLUMN_MARGIN,
7894
+ list: width - COLUMN_MARGIN - CLOSE_MARGIN,
7842
7895
  pane: 0
7843
7896
  };
7844
7897
  const list = clamp(Math.floor(width * LIST_SHARE), LIST_MIN_WIDTH, LIST_MAX_WIDTH);
7845
7898
  return {
7846
7899
  ...base,
7847
7900
  list,
7848
- pane: width - list - 2 * COLUMN_MARGIN
7901
+ pane: width - list - 2 * COLUMN_MARGIN - CLOSE_MARGIN
7849
7902
  };
7850
7903
  }
7851
7904
  /**
@@ -8210,10 +8263,11 @@ function listColumn(rows, blocks, look, body) {
8210
8263
  * @returns the rows, before the scroll window is applied.
8211
8264
  */
8212
8265
  function paneColumn(group, blocks, cursor, render, width) {
8213
- const { palette, tints, reveal } = render;
8266
+ const { palette, tints, reveal, highlight } = render;
8214
8267
  return turnLayout(group, blocks, width, {
8215
8268
  palette,
8216
8269
  tints,
8270
+ highlight,
8217
8271
  cursor
8218
8272
  }).flatMap((rows, index) => {
8219
8273
  const section = group.sections[index];
@@ -8229,12 +8283,8 @@ function paneColumn(group, blocks, cursor, render, width) {
8229
8283
  * @returns the row, no wider than `width`.
8230
8284
  */
8231
8285
  function frameRow(columns, row, palette, width) {
8232
- let line = `${palette.accent(SIDE)} `;
8233
- for (const [index, column] of columns.entries()) {
8234
- const text = column.rows[row] ?? "";
8235
- line += index === columns.length - 1 ? truncateToWidth(text, Math.max(1, column.width), ELLIPSIS$1) : `${cell(text, column.width)}${palette.dim(SIDE)} `;
8236
- }
8237
- return truncateToWidth(line, Math.max(1, width), ELLIPSIS$1);
8286
+ const inner = columns.map((column) => cell(column.rows[row] ?? "", column.width)).join(`${palette.dim(SIDE)} `);
8287
+ return truncateToWidth(`${palette.accent(SIDE)} ${inner} ${palette.accent(SIDE)}`, Math.max(1, width), ELLIPSIS$1);
8238
8288
  }
8239
8289
  /**
8240
8290
  * What the legend rule says on its left: the query line while one is open, or
@@ -8498,7 +8548,8 @@ var ReaderPane = class {
8498
8548
  minColumns: this.options.minColumns,
8499
8549
  totalTurns: groups.length,
8500
8550
  tints: effects === void 0 ? void 0 : readerTints(effects.style(), effects.background()),
8501
- reveal: this.revealNow()
8551
+ reveal: this.revealNow(),
8552
+ highlight: this.options.highlight
8502
8553
  });
8503
8554
  }
8504
8555
  /**
@@ -11345,6 +11396,7 @@ var TuiApp = class {
11345
11396
  rows: () => Math.max(1, this.deps.terminal.rows),
11346
11397
  minColumns: this.deps.readerMinColumns,
11347
11398
  cursor,
11399
+ highlight: this.codeHighlight,
11348
11400
  effects: {
11349
11401
  style: () => this.fadeStyle,
11350
11402
  background: () => this.background,
@@ -902,26 +902,11 @@ const loadSmithyRpcV2CborErrorCode = (output, data) => {
902
902
  if (cleanValue.indexOf(":") >= 0) {
903
903
  cleanValue = cleanValue.split(":")[0];
904
904
  }
905
- if (cleanValue.indexOf("#") >= 0) {
906
- cleanValue = cleanValue.split("#")[1];
907
- }
908
905
  return cleanValue;
909
906
  };
910
907
  if (data["__type"] !== undefined) {
911
908
  return sanitizeErrorCode(data["__type"]);
912
909
  }
913
- let codeKey;
914
- for (const key in data) {
915
- if (!hasOwn(data, key))
916
- continue;
917
- if (key.toLowerCase() === "code") {
918
- codeKey = key;
919
- break;
920
- }
921
- }
922
- if (codeKey && data[codeKey] !== undefined) {
923
- return sanitizeErrorCode(data[codeKey]);
924
- }
925
910
  };
926
911
  const checkCborResponse = (response) => {
927
912
  if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
@@ -2278,37 +2263,37 @@ class SmithyRpcV2CborProtocol extends RpcProtocol {
2278
2263
  return super.deserializeResponse(operationSchema, context, response);
2279
2264
  }
2280
2265
  async handleError(operationSchema, context, response, dataObject, metadata) {
2281
- const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
2266
+ const errorIdentifier = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
2267
+ const preferredNamespaces = ["*"];
2268
+ const { defaultNamespace } = this.options;
2269
+ preferredNamespaces.unshift(defaultNamespace);
2270
+ const [namespace, errorShapeName] = (() => {
2271
+ if (errorIdentifier.includes("#")) {
2272
+ return errorIdentifier.split("#");
2273
+ }
2274
+ return [undefined, errorIdentifier];
2275
+ })();
2276
+ if (namespace) {
2277
+ preferredNamespaces.unshift(namespace);
2278
+ }
2282
2279
  const errorMetadata = {
2283
2280
  $metadata: metadata,
2284
- $fault: response.statusCode <= 500 ? "client" : "server",
2281
+ $fault: response.statusCode < 500 ? "client" : "server",
2285
2282
  };
2286
- let namespace = this.options.defaultNamespace;
2287
- if (errorName.includes("#")) {
2288
- [namespace] = errorName.split("#");
2289
- }
2290
- const registry = this.compositeErrorRegistry;
2291
- const nsRegistry = TypeRegistry.for(namespace);
2292
- registry.copyFrom(nsRegistry);
2293
- let errorSchema;
2294
- try {
2295
- errorSchema = registry.getSchema(errorName);
2283
+ const preferredRegistries = [this.compositeErrorRegistry];
2284
+ if (namespace) {
2285
+ preferredRegistries.push(TypeRegistry.for(namespace));
2296
2286
  }
2297
- catch (ignored) {
2287
+ preferredRegistries.push(TypeRegistry.for(defaultNamespace));
2288
+ const [errorSchema, ErrorCtor, errorMode] = this.resolveError(errorShapeName, preferredNamespaces, preferredRegistries);
2289
+ if (errorMode === "native" || errorMode === "synthetic") {
2298
2290
  if (dataObject.Message) {
2299
2291
  dataObject.message = dataObject.Message;
2300
2292
  }
2301
- const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
2302
- registry.copyFrom(syntheticRegistry);
2303
- const baseExceptionSchema = registry.getBaseException();
2304
- if (baseExceptionSchema) {
2305
- const ErrorCtor = registry.getErrorCtor(baseExceptionSchema);
2306
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
2307
- }
2308
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
2293
+ const error = errorMode === "synthetic" ? new ErrorCtor({ name: errorShapeName }) : new Error(errorShapeName);
2294
+ throw Object.assign(error, errorMetadata, dataObject);
2309
2295
  }
2310
2296
  const ns = NormalizedSchema.of(errorSchema);
2311
- const ErrorCtor = registry.getErrorCtor(errorSchema);
2312
2297
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
2313
2298
  const exception = new ErrorCtor({});
2314
2299
  const output = {};
@@ -590,20 +590,27 @@ class Command {
590
590
  }
591
591
  const stack = clientStack.concat(this.middlewareStack);
592
592
  const { logger } = configuration;
593
+ const additionalSmithyContext = additionalContext[SMITHY_CONTEXT_KEY];
593
594
  const handlerExecutionContext = {
594
595
  logger,
595
596
  clientName,
596
597
  commandName,
597
598
  inputFilterSensitiveLog,
598
599
  outputFilterSensitiveLog,
600
+ ...additionalContext,
599
601
  [SMITHY_CONTEXT_KEY]: {
602
+ ...additionalSmithyContext,
600
603
  commandInstance: this,
601
604
  ...smithyContext,
605
+ ...(options?.metricsRecorder === undefined ? {} : { metricsRecorder: options.metricsRecorder }),
602
606
  },
603
- ...additionalContext,
604
607
  };
605
608
  const { requestHandler } = configuration;
606
609
  let requestOptions = options ?? {};
610
+ if (requestOptions.metricsRecorder) {
611
+ requestOptions = { ...requestOptions };
612
+ delete requestOptions.metricsRecorder;
613
+ }
607
614
  if (smithyContext.eventStream) {
608
615
  requestOptions = {
609
616
  isEventStream: true,
@@ -786,10 +793,25 @@ class ServiceException extends Error {
786
793
  return ServiceException.isInstance(instance);
787
794
  }
788
795
  if (ServiceException.isInstance(instance)) {
789
- if (candidate.name && this.name) {
790
- return this.prototype.isPrototypeOf(instance) || candidate.name === this.name;
796
+ if (this.prototype.isPrototypeOf(instance)) {
797
+ return true;
798
+ }
799
+ const targetName = this.name;
800
+ if (!targetName || !candidate.name) {
801
+ return false;
791
802
  }
792
- return this.prototype.isPrototypeOf(instance);
803
+ if (candidate.name === targetName) {
804
+ return true;
805
+ }
806
+ let proto = Object.getPrototypeOf(candidate);
807
+ while (proto && proto !== Object.prototype) {
808
+ const ctorName = proto.constructor?.name;
809
+ if (ctorName && ctorName !== "Error" && ctorName === targetName) {
810
+ return true;
811
+ }
812
+ proto = Object.getPrototypeOf(proto);
813
+ }
814
+ return false;
793
815
  }
794
816
  return false;
795
817
  }
@@ -39,7 +39,7 @@ class HttpProtocol extends SerdeContext {
39
39
  constructor(options) {
40
40
  super();
41
41
  this.options = options;
42
- this.compositeErrorRegistry = TypeRegistry.for(options.defaultNamespace);
42
+ this.compositeErrorRegistry = new TypeRegistry(options.defaultNamespace);
43
43
  for (const etr of options.errorTypeRegistries ?? []) {
44
44
  this.compositeErrorRegistry.copyFrom(etr);
45
45
  }
@@ -134,6 +134,47 @@ class HttpProtocol extends SerdeContext {
134
134
  cfId: output.headers["x-amz-cf-id"],
135
135
  };
136
136
  }
137
+ resolveError(name, namespaces, registries) {
138
+ const defaultErrorSchema = [-3, "", "Error", 0, [], [], 0];
139
+ let schema;
140
+ for (const registry of registries) {
141
+ for (const ns of namespaces) {
142
+ try {
143
+ if (ns === "*") {
144
+ schema = registry.getSchema(name);
145
+ }
146
+ else {
147
+ schema = registry.getSchema(ns + "#" + name);
148
+ }
149
+ const errorCtor = registry.getErrorCtor(schema);
150
+ if (errorCtor) {
151
+ return [schema, errorCtor, "modeled"];
152
+ }
153
+ else {
154
+ const syntheticErrorSchema = registry.getBaseException();
155
+ if (syntheticErrorSchema) {
156
+ const syntheticErrorCtor = registry.getErrorCtor(syntheticErrorSchema);
157
+ if (syntheticErrorCtor) {
158
+ return [schema, syntheticErrorCtor, "synthetic"];
159
+ }
160
+ }
161
+ }
162
+ }
163
+ catch (ignored) {
164
+ }
165
+ }
166
+ }
167
+ for (const registry of registries) {
168
+ const syntheticErrorSchema = registry.getBaseException();
169
+ if (syntheticErrorSchema) {
170
+ const syntheticErrorCtor = registry.getErrorCtor(syntheticErrorSchema);
171
+ if (syntheticErrorCtor) {
172
+ return [syntheticErrorSchema, syntheticErrorCtor, "synthetic"];
173
+ }
174
+ }
175
+ }
176
+ return [defaultErrorSchema, Error, "native"];
177
+ }
137
178
  async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {
138
179
  const eventStreamSerde = await this.loadEventStreamCapability();
139
180
  return eventStreamSerde.serializeEventStream({
@@ -162,13 +203,6 @@ class HttpProtocol extends SerdeContext {
162
203
  compositeErrorRegistry: this.compositeErrorRegistry,
163
204
  });
164
205
  }
165
- resolveEventStreamMarshaller(importedProvider) {
166
- const context = this.serdeContext;
167
- if (context.eventStreamMarshaller) {
168
- return context.eventStreamMarshaller;
169
- }
170
- return importedProvider(this.serdeContext);
171
- }
172
206
  getDefaultContentType() {
173
207
  throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`);
174
208
  }
@@ -182,6 +216,13 @@ class HttpProtocol extends SerdeContext {
182
216
  }
183
217
  return context.eventStreamMarshaller;
184
218
  }
219
+ resolveEventStreamMarshaller(importedProvider) {
220
+ const context = this.serdeContext;
221
+ if (context.eventStreamMarshaller) {
222
+ return context.eventStreamMarshaller;
223
+ }
224
+ return importedProvider(this.serdeContext);
225
+ }
185
226
  }
186
227
 
187
228
  class HttpBindingProtocol extends HttpProtocol {
@@ -579,12 +579,12 @@ class TypeRegistry {
579
579
  this.namespace = namespace;
580
580
  this.schemas = schemas;
581
581
  this.exceptions = exceptions;
582
- }
583
- static for(namespace) {
584
582
  if (!TypeRegistry.registries.has(namespace)) {
585
- TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
583
+ TypeRegistry.registries.set(namespace, this);
586
584
  }
587
- return TypeRegistry.registries.get(namespace);
585
+ }
586
+ static for(namespace) {
587
+ return TypeRegistry.registries.get(namespace) ?? new TypeRegistry(namespace);
588
588
  }
589
589
  copyFrom(other) {
590
590
  const { schemas, exceptions } = this;
@@ -602,7 +602,9 @@ class TypeRegistry {
602
602
  register(shapeId, schema) {
603
603
  const qualifiedName = this.normalizeShapeId(shapeId);
604
604
  for (const r of [this, TypeRegistry.for(qualifiedName.split("#")[0])]) {
605
- r.schemas.set(qualifiedName, schema);
605
+ if (!r.schemas.has(qualifiedName)) {
606
+ r.schemas.set(qualifiedName, schema);
607
+ }
606
608
  }
607
609
  }
608
610
  getSchema(shapeId) {
@@ -627,9 +629,12 @@ class TypeRegistry {
627
629
  registerError(es, ctor) {
628
630
  const $error = es;
629
631
  const ns = $error[1];
632
+ const qualifiedName = ns + "#" + $error[2];
630
633
  for (const r of [this, TypeRegistry.for(ns)]) {
631
- r.schemas.set(ns + "#" + $error[2], $error);
632
- r.exceptions.set($error, ctor);
634
+ if (!r.schemas.has(qualifiedName) && !r.exceptions.has($error)) {
635
+ r.schemas.set(qualifiedName, $error);
636
+ r.exceptions.set($error, ctor);
637
+ }
633
638
  }
634
639
  }
635
640
  getErrorCtor(es) {
@@ -50,37 +50,37 @@ export class SmithyRpcV2CborProtocol extends RpcProtocol {
50
50
  return super.deserializeResponse(operationSchema, context, response);
51
51
  }
52
52
  async handleError(operationSchema, context, response, dataObject, metadata) {
53
- const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
53
+ const errorIdentifier = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
54
+ const preferredNamespaces = ["*"];
55
+ const { defaultNamespace } = this.options;
56
+ preferredNamespaces.unshift(defaultNamespace);
57
+ const [namespace, errorShapeName] = (() => {
58
+ if (errorIdentifier.includes("#")) {
59
+ return errorIdentifier.split("#");
60
+ }
61
+ return [undefined, errorIdentifier];
62
+ })();
63
+ if (namespace) {
64
+ preferredNamespaces.unshift(namespace);
65
+ }
54
66
  const errorMetadata = {
55
67
  $metadata: metadata,
56
- $fault: response.statusCode <= 500 ? "client" : "server",
68
+ $fault: response.statusCode < 500 ? "client" : "server",
57
69
  };
58
- let namespace = this.options.defaultNamespace;
59
- if (errorName.includes("#")) {
60
- [namespace] = errorName.split("#");
70
+ const preferredRegistries = [this.compositeErrorRegistry];
71
+ if (namespace) {
72
+ preferredRegistries.push(TypeRegistry.for(namespace));
61
73
  }
62
- const registry = this.compositeErrorRegistry;
63
- const nsRegistry = TypeRegistry.for(namespace);
64
- registry.copyFrom(nsRegistry);
65
- let errorSchema;
66
- try {
67
- errorSchema = registry.getSchema(errorName);
68
- }
69
- catch (ignored) {
74
+ preferredRegistries.push(TypeRegistry.for(defaultNamespace));
75
+ const [errorSchema, ErrorCtor, errorMode] = this.resolveError(errorShapeName, preferredNamespaces, preferredRegistries);
76
+ if (errorMode === "native" || errorMode === "synthetic") {
70
77
  if (dataObject.Message) {
71
78
  dataObject.message = dataObject.Message;
72
79
  }
73
- const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
74
- registry.copyFrom(syntheticRegistry);
75
- const baseExceptionSchema = registry.getBaseException();
76
- if (baseExceptionSchema) {
77
- const ErrorCtor = registry.getErrorCtor(baseExceptionSchema);
78
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
79
- }
80
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
80
+ const error = errorMode === "synthetic" ? new ErrorCtor({ name: errorShapeName }) : new Error(errorShapeName);
81
+ throw Object.assign(error, errorMetadata, dataObject);
81
82
  }
82
83
  const ns = NormalizedSchema.of(errorSchema);
83
- const ErrorCtor = registry.getErrorCtor(errorSchema);
84
84
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
85
85
  const exception = new ErrorCtor({});
86
86
  const output = {};