@alwith/module-chat 0.5.21 → 0.5.23

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 (384) hide show
  1. package/dist/activity-host.js +1 -1
  2. package/dist/approval/choice-elicitation-form.js +1 -1
  3. package/dist/approval/choice-schema.js +1 -1
  4. package/dist/approval/permission-options.js +1 -1
  5. package/dist/approval/permission-view.js +1 -1
  6. package/dist/approval/schema-elicitation-form.d.ts +1 -1
  7. package/dist/approval/schema-elicitation-form.js +1 -1
  8. package/dist/approval/url-elicitation-card.js +1 -1
  9. package/dist/{chunk-1tkzxktd.js → chunk-0mmcy6k7.js} +2 -2
  10. package/dist/chunk-0p6y2t9b.js +2 -0
  11. package/dist/{chunk-xgjkj9j8.js → chunk-0wa9yjg3.js} +2 -2
  12. package/dist/{chunk-dya74vts.js → chunk-0whxm2f0.js} +2 -2
  13. package/dist/{chunk-s55n9cby.js → chunk-1fggcrvs.js} +2 -2
  14. package/dist/{chunk-r9dt4bs3.js → chunk-1k21j77z.js} +2 -2
  15. package/dist/chunk-1k697ncv.js +2 -0
  16. package/dist/chunk-1mn2t6ga.js +2 -0
  17. package/dist/{chunk-2tce3pc5.js → chunk-1qyxrh0n.js} +3 -3
  18. package/dist/{chunk-2f1qx13s.js → chunk-1rg3nab3.js} +2 -2
  19. package/dist/{chunk-63kxepkh.js → chunk-2388yq9z.js} +2 -2
  20. package/dist/{chunk-2tkeevm0.js → chunk-28f3zv6v.js} +2 -2
  21. package/dist/{chunk-1ppfn0e1.js → chunk-2f9vjmxz.js} +2 -2
  22. package/dist/{chunk-8hte6dh7.js → chunk-36m8zstj.js} +2 -2
  23. package/dist/chunk-3bzqcxq2.js +2 -0
  24. package/dist/{chunk-9sq2etjk.js → chunk-3e6wcamp.js} +2 -2
  25. package/dist/{chunk-8t36vprh.js → chunk-3ka3bt0t.js} +2 -2
  26. package/dist/{chunk-xmstt6hh.js → chunk-3s94ekrs.js} +2 -2
  27. package/dist/{chunk-23rjsm3a.js → chunk-3yxjh7b1.js} +2 -2
  28. package/dist/{chunk-8jxcdap5.js → chunk-42atrgm1.js} +2 -2
  29. package/dist/{chunk-mg2mkzkk.js → chunk-48fj5m0p.js} +2 -2
  30. package/dist/{chunk-1e6x0018.js → chunk-4bb6dzzs.js} +2 -2
  31. package/dist/{chunk-dv65h7z5.js → chunk-4ddkzbm0.js} +2 -2
  32. package/dist/chunk-4fk0vjh5.js +2 -0
  33. package/dist/{chunk-n0khj68q.js → chunk-4gyd9hx9.js} +2 -2
  34. package/dist/chunk-4jfynrgh.js +2 -0
  35. package/dist/chunk-4p6svs37.js +2 -0
  36. package/dist/chunk-4wa7tehh.js +3 -0
  37. package/dist/{chunk-m2b8kzpk.js → chunk-5a6xc345.js} +2 -2
  38. package/dist/chunk-5ap6fvrp.js +2 -0
  39. package/dist/chunk-6179zrn1.js +3 -0
  40. package/dist/chunk-658njfx1.js +4 -0
  41. package/dist/{chunk-nxp1b8ny.js → chunk-667z0pac.js} +2 -2
  42. package/dist/chunk-6cmttr4w.js +1 -0
  43. package/dist/{chunk-3jcmv5qf.js → chunk-6t5war9h.js} +2 -2
  44. package/dist/chunk-6trv0snh.js +2 -0
  45. package/dist/{chunk-jm6zja6h.js → chunk-76a04a6j.js} +2 -2
  46. package/dist/{chunk-k7k6qsqh.js → chunk-7z4gtfkd.js} +2 -2
  47. package/dist/{chunk-nq7gg9vg.js → chunk-855w49k0.js} +2 -2
  48. package/dist/chunk-8c8ncw1m.js +2 -0
  49. package/dist/{chunk-0fs2k5fe.js → chunk-95mynf7q.js} +2 -2
  50. package/dist/chunk-9tp0z23q.js +2 -0
  51. package/dist/{chunk-v4t0p6pp.js → chunk-9wasxr1v.js} +2 -2
  52. package/dist/{chunk-0gy6ngda.js → chunk-a42211a1.js} +2 -2
  53. package/dist/{chunk-77j8n5k5.js → chunk-a63k8tht.js} +2 -2
  54. package/dist/{chunk-ap0vmczf.js → chunk-acb8t4jt.js} +2 -2
  55. package/dist/{chunk-2nvsvw67.js → chunk-agqnt7xq.js} +2 -2
  56. package/dist/chunk-ah4pgmqr.js +2 -0
  57. package/dist/{chunk-vyk4zh1m.js → chunk-asyfpv8n.js} +7 -7
  58. package/dist/chunk-awmra30d.js +2 -0
  59. package/dist/{chunk-aza82m2p.js → chunk-azfmr99x.js} +2 -2
  60. package/dist/{chunk-0vhkv9ax.js → chunk-b12v22de.js} +2 -2
  61. package/dist/chunk-bbnhytn3.js +2 -0
  62. package/dist/{chunk-mcjwwxa1.js → chunk-bfhfbrzt.js} +2 -2
  63. package/dist/{chunk-w9dh298r.js → chunk-bg03czcx.js} +2 -2
  64. package/dist/chunk-bmey8et5.js +2 -0
  65. package/dist/{chunk-67hrx4kg.js → chunk-bvgqsaey.js} +2 -2
  66. package/dist/chunk-c32z3wjq.js +2 -0
  67. package/dist/{chunk-33620ca6.js → chunk-c723sswh.js} +2 -2
  68. package/dist/{chunk-x6nz6eyb.js → chunk-ce1qr37c.js} +2 -2
  69. package/dist/chunk-cgk9mtky.js +2 -0
  70. package/dist/{chunk-1q2cykp4.js → chunk-ckyat78p.js} +2 -2
  71. package/dist/chunk-cvz3k5gk.js +2 -0
  72. package/dist/{chunk-aqvy57zs.js → chunk-cw76pj9b.js} +2 -2
  73. package/dist/{chunk-b2wczqtd.js → chunk-cz4k8aad.js} +2 -2
  74. package/dist/{chunk-xyvqcpjx.js → chunk-d257n8gj.js} +2 -2
  75. package/dist/{chunk-sy5tq3y6.js → chunk-d8ytdk0x.js} +2 -2
  76. package/dist/{chunk-m7wn4z9x.js → chunk-drhzcs6e.js} +2 -2
  77. package/dist/{chunk-nqw4deag.js → chunk-dte0n4kf.js} +2 -2
  78. package/dist/{chunk-4s6gx750.js → chunk-e3pfvwhd.js} +2 -2
  79. package/dist/chunk-e5qk8b1f.js +2 -0
  80. package/dist/{chunk-dyqvhn6y.js → chunk-eg9hemqa.js} +5 -5
  81. package/dist/chunk-f1gj3yzt.js +2 -0
  82. package/dist/{chunk-0gersbj0.js → chunk-f1x483c9.js} +2 -2
  83. package/dist/chunk-f2rq6nj6.js +3 -0
  84. package/dist/{chunk-dyrgfdxz.js → chunk-f2w2sct6.js} +2 -2
  85. package/dist/{chunk-mgm1x3de.js → chunk-f5gsffbv.js} +2 -2
  86. package/dist/chunk-fh3pjhe6.js +2 -0
  87. package/dist/{chunk-vcy5vyp7.js → chunk-fnpf84rf.js} +2 -2
  88. package/dist/{chunk-3aq5c12k.js → chunk-g2qcyqc6.js} +2 -2
  89. package/dist/{chunk-hv1ejvhg.js → chunk-g44hhdha.js} +2 -2
  90. package/dist/chunk-g8w3emvn.js +2 -0
  91. package/dist/{chunk-xrs7x5ah.js → chunk-g9t2d8hg.js} +2 -2
  92. package/dist/{chunk-z2v008kc.js → chunk-gha517v4.js} +2 -2
  93. package/dist/{chunk-fke98cj0.js → chunk-gsfgdnfp.js} +2 -2
  94. package/dist/{chunk-memvzzc6.js → chunk-hac9xtfv.js} +2 -2
  95. package/dist/{chunk-8w22ck92.js → chunk-heyqzkxq.js} +2 -2
  96. package/dist/{chunk-k5rkpqbh.js → chunk-jgd6dcgy.js} +2 -2
  97. package/dist/chunk-jmb8r6aj.js +2 -0
  98. package/dist/{chunk-42nhwnbe.js → chunk-jwt7q6yx.js} +4 -4
  99. package/dist/{chunk-983gkw32.js → chunk-jxntqarp.js} +2 -2
  100. package/dist/chunk-k2k5tt5x.js +2 -0
  101. package/dist/{chunk-6dn3j8a2.js → chunk-k7ye738q.js} +2 -2
  102. package/dist/{chunk-72x7rae0.js → chunk-kc56dhwd.js} +2 -2
  103. package/dist/chunk-kfy7yvke.js +2 -0
  104. package/dist/{chunk-j86x2rn0.js → chunk-kg5hcf28.js} +2 -2
  105. package/dist/{chunk-42hkbpey.js → chunk-kmdag4vy.js} +2 -2
  106. package/dist/{chunk-n929wkw7.js → chunk-kz1kjzmq.js} +2 -2
  107. package/dist/{chunk-qwfwxfhn.js → chunk-m271yxxm.js} +2 -2
  108. package/dist/chunk-m8hb96f5.js +2 -0
  109. package/dist/{chunk-zxkvvecz.js → chunk-mj7094yh.js} +2 -2
  110. package/dist/{chunk-nn25kjm4.js → chunk-mvs2dzyt.js} +2 -2
  111. package/dist/{chunk-xktybk48.js → chunk-mxfvakya.js} +2 -2
  112. package/dist/chunk-mz8a6292.js +2 -0
  113. package/dist/chunk-mztwft71.js +2 -0
  114. package/dist/chunk-n0acc2tb.js +2 -0
  115. package/dist/{chunk-p4bb313p.js → chunk-n45a05jx.js} +3 -3
  116. package/dist/{chunk-e9ntencj.js → chunk-n5v1h0sk.js} +2 -2
  117. package/dist/{chunk-1f628zap.js → chunk-n66yy1m1.js} +2 -2
  118. package/dist/{chunk-0mp7tyea.js → chunk-nn2hmwzd.js} +2 -2
  119. package/dist/{chunk-a8p82wp7.js → chunk-nsf0e6gj.js} +2 -2
  120. package/dist/chunk-nv6s8x9f.js +2 -0
  121. package/dist/{chunk-82xjggwn.js → chunk-p7dd93e5.js} +2 -2
  122. package/dist/chunk-p8g927x6.js +2 -0
  123. package/dist/chunk-pk2rvqd0.js +2 -0
  124. package/dist/{chunk-7wk3d01c.js → chunk-pprt7ntb.js} +4 -4
  125. package/dist/{chunk-rcbb4ke2.js → chunk-pqa37epj.js} +2 -2
  126. package/dist/{chunk-t97yjy4f.js → chunk-pw8b9brz.js} +2 -2
  127. package/dist/{chunk-ns5rnxdj.js → chunk-pwjz3yxb.js} +2 -2
  128. package/dist/{chunk-z71pp1mb.js → chunk-pzjag1mt.js} +3 -3
  129. package/dist/chunk-pzyradqt.js +2 -0
  130. package/dist/chunk-q9zawfn1.js +2 -0
  131. package/dist/{chunk-141kppzb.js → chunk-qd1z91fm.js} +1 -1
  132. package/dist/{chunk-k5wgf59a.js → chunk-qdg5zphd.js} +2 -2
  133. package/dist/chunk-qn6ppn0r.js +2 -0
  134. package/dist/{chunk-8ch9444t.js → chunk-qwfw4xpn.js} +2 -2
  135. package/dist/chunk-r5z08bp6.js +2 -0
  136. package/dist/{chunk-mwpchd85.js → chunk-raye7hnk.js} +3 -3
  137. package/dist/{chunk-x2yc5748.js → chunk-rbv1scqm.js} +2 -2
  138. package/dist/{chunk-156m3888.js → chunk-rjkpe1fw.js} +3 -3
  139. package/dist/{chunk-xf36kt74.js → chunk-rjw63t34.js} +3 -3
  140. package/dist/chunk-rq5e0922.js +2 -0
  141. package/dist/{chunk-x334e7wb.js → chunk-sjs9484n.js} +3 -3
  142. package/dist/{chunk-b614gnnv.js → chunk-swpy2b9a.js} +2 -2
  143. package/dist/chunk-sz3vcbp5.js +2 -0
  144. package/dist/{chunk-c38t8809.js → chunk-t6vcdf4j.js} +2 -2
  145. package/dist/{chunk-7p1r1ha9.js → chunk-t7drk9ja.js} +2 -2
  146. package/dist/{chunk-5cdr7q6f.js → chunk-t9f2cw75.js} +3 -3
  147. package/dist/chunk-tpbqg729.js +2 -0
  148. package/dist/chunk-ttn8ss6b.js +2 -0
  149. package/dist/{chunk-w6rwngm3.js → chunk-tv0fwt2g.js} +2 -2
  150. package/dist/{chunk-vs02ry2r.js → chunk-tz1kzpzp.js} +2 -2
  151. package/dist/{chunk-8c042xya.js → chunk-vbab9hc4.js} +2 -2
  152. package/dist/{chunk-w0hpztj7.js → chunk-vfhxerxt.js} +2 -2
  153. package/dist/chunk-vnsgjnp3.js +2 -0
  154. package/dist/{chunk-59957gfy.js → chunk-vt6cyes7.js} +2 -2
  155. package/dist/chunk-vvtbtx09.js +2 -0
  156. package/dist/{chunk-z2fjwkmt.js → chunk-wccx911q.js} +2 -2
  157. package/dist/{chunk-g73f62qm.js → chunk-wgrmjfyp.js} +2 -2
  158. package/dist/chunk-wm0jty6e.js +2 -0
  159. package/dist/{chunk-h5m2fpp4.js → chunk-wvry7t79.js} +2 -2
  160. package/dist/{chunk-00eytt1z.js → chunk-y0q6jwq4.js} +2 -2
  161. package/dist/chunk-y97ne5kj.js +2 -0
  162. package/dist/{chunk-cbwya2ss.js → chunk-yakar0e2.js} +2 -2
  163. package/dist/{chunk-3yvd77ph.js → chunk-yg3xhn5m.js} +2 -2
  164. package/dist/{chunk-et8rcxw6.js → chunk-z3nybrbb.js} +2 -2
  165. package/dist/chunk-zheyzqcq.js +2 -0
  166. package/dist/codex/activity-group.js +1 -1
  167. package/dist/codex/assistant-message.js +1 -1
  168. package/dist/codex/async-question-card.js +1 -1
  169. package/dist/codex/disclosure-state.js +1 -1
  170. package/dist/codex/edited-files-card.js +1 -1
  171. package/dist/codex/image-view-activity.js +1 -1
  172. package/dist/codex/markdown-renderer.js +1 -1
  173. package/dist/codex/navigation-audio.js +1 -1
  174. package/dist/codex/navigation-preview.js +1 -1
  175. package/dist/codex/navigation-rail.js +1 -1
  176. package/dist/codex/patch-view.js +1 -1
  177. package/dist/codex/plan.js +1 -1
  178. package/dist/codex/timeline-virtualizer.js +1 -1
  179. package/dist/codex/turn-activity.js +1 -1
  180. package/dist/codex/user-message.js +1 -1
  181. package/dist/codex/virtualized-turn-list.js +1 -1
  182. package/dist/collections/collection-emoji.js +1 -1
  183. package/dist/collections/collection-menu.js +1 -1
  184. package/dist/collections/collection-panel.js +1 -1
  185. package/dist/collections/collections.js +1 -1
  186. package/dist/collections/host.js +1 -1
  187. package/dist/collections/locales.js +1 -1
  188. package/dist/collections/model.js +1 -1
  189. package/dist/collections/store.js +1 -1
  190. package/dist/composer/completion-filter.js +1 -1
  191. package/dist/composer/completion-menu.js +1 -1
  192. package/dist/composer/completion-trigger.js +1 -1
  193. package/dist/composer/effort-slider.js +1 -1
  194. package/dist/composer/menu-radio.js +1 -1
  195. package/dist/composer/model-select.js +1 -1
  196. package/dist/composer/permission-mode-select.js +1 -1
  197. package/dist/composer/prompt-input-attachments.js +1 -1
  198. package/dist/composer/prompt-input-clipboard.js +1 -1
  199. package/dist/composer/prompt-input-context.js +1 -1
  200. package/dist/composer/prompt-input-textarea.js +1 -1
  201. package/dist/composer/prompt-input.js +1 -1
  202. package/dist/conversation/action-card.js +1 -1
  203. package/dist/conversation/composer/composer.js +1 -1
  204. package/dist/conversation/composer/config-options.js +1 -1
  205. package/dist/conversation/composer/context.js +1 -1
  206. package/dist/conversation/composer/drafts.js +1 -1
  207. package/dist/conversation/composer/file-items.js +1 -1
  208. package/dist/conversation/composer/long-text.js +1 -1
  209. package/dist/conversation/composer/mention-chips.js +1 -1
  210. package/dist/conversation/composer/mention-uri.js +1 -1
  211. package/dist/conversation/composer/model-menu.js +1 -1
  212. package/dist/conversation/composer/pasted-text-attachment.js +1 -1
  213. package/dist/conversation/composer/permission-mode-menu.js +1 -1
  214. package/dist/conversation/composer/prediction.js +1 -1
  215. package/dist/conversation/composer/slash-command-button.js +1 -1
  216. package/dist/conversation/composer/submit-button.js +1 -1
  217. package/dist/conversation/composer/usage-meter.js +1 -1
  218. package/dist/conversation/connection-notice.js +1 -1
  219. package/dist/conversation/context.js +1 -1
  220. package/dist/conversation/conversation-body.js +1 -1
  221. package/dist/conversation/conversation-search.js +1 -1
  222. package/dist/conversation/conversation-view.js +1 -1
  223. package/dist/conversation/conversation.js +1 -1
  224. package/dist/conversation/diff-modal.js +1 -1
  225. package/dist/conversation/draft-project-picker.js +1 -1
  226. package/dist/conversation/session-actions.js +1 -1
  227. package/dist/conversation/subagent-sessions.js +1 -1
  228. package/dist/image-lightbox.js +1 -1
  229. package/dist/image-preview-dialog.js +1 -1
  230. package/dist/lib/code-highlighter.js +1 -1
  231. package/dist/lib/fuzzy.js +1 -1
  232. package/dist/lib/group-blocks.js +1 -1
  233. package/dist/lib/image-encode.js +1 -1
  234. package/dist/lib/limits.js +1 -1
  235. package/dist/lib/markdown-parser.js +1 -1
  236. package/dist/lib/markdown-rules.js +1 -1
  237. package/dist/lib/model-name.js +1 -1
  238. package/dist/lib/pointer-centered-zoom.js +1 -1
  239. package/dist/lib/prepare-prompt-files.js +1 -1
  240. package/dist/lib/stream-style.js +1 -1
  241. package/dist/lib/streaming-markdown.js +1 -1
  242. package/dist/locales.js +1 -1
  243. package/dist/plugins/catalog-header.js +1 -1
  244. package/dist/plugins/catalog-skeleton.js +1 -1
  245. package/dist/plugins/host.js +1 -1
  246. package/dist/plugins/new-chat-directory.js +1 -1
  247. package/dist/plugins/pane.js +1 -1
  248. package/dist/plugins/panel-item.js +1 -1
  249. package/dist/plugins/plugin-detail-page.js +1 -1
  250. package/dist/plugins/plugin-icon.js +1 -1
  251. package/dist/plugins/plugin-icons.js +1 -1
  252. package/dist/plugins/plugins-page.js +1 -1
  253. package/dist/plugins/plugins.js +1 -1
  254. package/dist/plugins/read-skill-document.js +1 -1
  255. package/dist/plugins/skill-document.js +1 -1
  256. package/dist/plugins/skills-tab.js +1 -1
  257. package/dist/plugins/store.js +1 -1
  258. package/dist/plugins/toolbox-layout.js +1 -1
  259. package/dist/search/chat-search.js +1 -1
  260. package/dist/search/codex-source-matches.js +1 -1
  261. package/dist/search/dom-matches.js +1 -1
  262. package/dist/search/find-bar.js +1 -1
  263. package/dist/search/literal-matches.js +1 -1
  264. package/dist/session-list/account-menu.js +1 -1
  265. package/dist/session-list/activity-list.js +1 -1
  266. package/dist/session-list/archived-sessions.js +1 -1
  267. package/dist/session-list/help-menu.js +1 -1
  268. package/dist/session-list/highlight.js +1 -1
  269. package/dist/session-list/host.js +1 -1
  270. package/dist/session-list/hover-info-card.js +1 -1
  271. package/dist/session-list/navigation-header.js +1 -1
  272. package/dist/session-list/navigation-store.js +1 -1
  273. package/dist/session-list/navigation-tabs.js +1 -1
  274. package/dist/session-list/navigation.js +1 -1
  275. package/dist/session-list/overflow-marquee.js +1 -1
  276. package/dist/session-list/platform.js +1 -1
  277. package/dist/session-list/row-stop-button.js +1 -1
  278. package/dist/session-list/session-groups.js +1 -1
  279. package/dist/session-list/session-info-card.js +1 -1
  280. package/dist/session-list/session-list.js +1 -1
  281. package/dist/session-list/session-row.js +1 -1
  282. package/dist/session-list/session-state-dot.js +1 -1
  283. package/dist/session-list/session-state-menu.js +1 -1
  284. package/dist/session-list/shortcut-hint.js +1 -1
  285. package/dist/session-list/shortcut.js +1 -1
  286. package/dist/session-list/sidebar-overlay.js +1 -1
  287. package/dist/session-list/trailing-swap.js +1 -1
  288. package/dist/session-list/use-activity-notification.js +1 -1
  289. package/dist/session-list/use-activity-preview.js +1 -1
  290. package/dist/session-list/use-cmd-held.js +1 -1
  291. package/dist/session-list/use-project-sessions.js +1 -1
  292. package/dist/session-list/virtual-session-rows.js +1 -1
  293. package/dist/session-timeline/activity-group.js +1 -1
  294. package/dist/session-timeline/activity-projection.js +1 -1
  295. package/dist/session-timeline/assistant-content.js +1 -1
  296. package/dist/session-timeline/assistant-turn.js +1 -1
  297. package/dist/session-timeline/async-questions.js +1 -1
  298. package/dist/session-timeline/edited-files-card.js +1 -1
  299. package/dist/session-timeline/history-timeline.js +1 -1
  300. package/dist/session-timeline/host.js +1 -1
  301. package/dist/session-timeline/navigation-rail.js +1 -1
  302. package/dist/session-timeline/plan.js +1 -1
  303. package/dist/session-timeline/question-reply.js +1 -1
  304. package/dist/session-timeline/resource-content.js +1 -1
  305. package/dist/session-timeline/session-timeline.js +1 -1
  306. package/dist/session-timeline/timeline-registry.js +1 -1
  307. package/dist/session-timeline/turn-activity.js +1 -1
  308. package/dist/session-timeline/turn-error.js +1 -1
  309. package/dist/session-timeline/turn-retry.js +1 -1
  310. package/dist/session-timeline/turn-time.js +1 -1
  311. package/dist/session-timeline/turns.js +1 -1
  312. package/dist/session-timeline/use-timeline-scroll.js +1 -1
  313. package/dist/session-timeline/user-message.js +1 -1
  314. package/dist/settings/codex-account-card.js +1 -1
  315. package/dist/settings/login-card.js +1 -1
  316. package/dist/settings/model-alias-settings.js +1 -1
  317. package/dist/settings/model-aliases.js +1 -1
  318. package/dist/settings/provider-logos.js +1 -1
  319. package/dist/settings/provider-section.js +1 -1
  320. package/dist/settings/providers-port.d.ts +3 -3
  321. package/dist/settings/providers-port.js +1 -1
  322. package/dist/settings/providers.js +1 -1
  323. package/dist/settings/settings-bridge.d.ts +3 -3
  324. package/dist/settings/settings-bridge.js +1 -1
  325. package/dist/settings/settings.js +1 -1
  326. package/package.json +3 -3
  327. package/rust/Cargo.lock +484 -10
  328. package/rust/Cargo.toml +16 -1
  329. package/rust/src/__tests__/native_network.rs +406 -0
  330. package/rust/src/lib.rs +3 -0
  331. package/rust/src/native_network.rs +302 -0
  332. package/rust/src/native_network_diagnostics.rs +220 -0
  333. package/rust/src/providers/tests.rs +4 -1
  334. package/rust/src/system_proxy.rs +257 -0
  335. package/dist/chunk-14exd146.js +0 -2
  336. package/dist/chunk-2ce8gd89.js +0 -2
  337. package/dist/chunk-3n47hknp.js +0 -2
  338. package/dist/chunk-3nr5qe41.js +0 -2
  339. package/dist/chunk-40bcp4pa.js +0 -2
  340. package/dist/chunk-4w3g7d6w.js +0 -2
  341. package/dist/chunk-52p7kyam.js +0 -2
  342. package/dist/chunk-59exzf5n.js +0 -2
  343. package/dist/chunk-5nc3dtyt.js +0 -2
  344. package/dist/chunk-78s6h7r4.js +0 -2
  345. package/dist/chunk-80ckz04b.js +0 -2
  346. package/dist/chunk-85ffkcch.js +0 -2
  347. package/dist/chunk-8qw8erv6.js +0 -2
  348. package/dist/chunk-908ndb9r.js +0 -2
  349. package/dist/chunk-9g67z1b4.js +0 -2
  350. package/dist/chunk-9n79tr1q.js +0 -2
  351. package/dist/chunk-ajpxjj5m.js +0 -2
  352. package/dist/chunk-b3jg6nzv.js +0 -3
  353. package/dist/chunk-c1b8z8pa.js +0 -2
  354. package/dist/chunk-c9nbavk0.js +0 -2
  355. package/dist/chunk-cg8ekwka.js +0 -2
  356. package/dist/chunk-ec9rgnt3.js +0 -2
  357. package/dist/chunk-efrn25h9.js +0 -2
  358. package/dist/chunk-emcefs0g.js +0 -2
  359. package/dist/chunk-f28hhbf4.js +0 -2
  360. package/dist/chunk-f3924gdb.js +0 -2
  361. package/dist/chunk-f8zy35gz.js +0 -2
  362. package/dist/chunk-f98at4r5.js +0 -2
  363. package/dist/chunk-g242n3dt.js +0 -2
  364. package/dist/chunk-h1bhhqtq.js +0 -2
  365. package/dist/chunk-kc5k5e59.js +0 -3
  366. package/dist/chunk-kvc6ewkt.js +0 -4
  367. package/dist/chunk-kxmajv0m.js +0 -3
  368. package/dist/chunk-myrdfa3s.js +0 -2
  369. package/dist/chunk-nacjea1s.js +0 -2
  370. package/dist/chunk-py837qjk.js +0 -1
  371. package/dist/chunk-q7nn5xe5.js +0 -2
  372. package/dist/chunk-qjhkzdhm.js +0 -2
  373. package/dist/chunk-qxcnyvps.js +0 -2
  374. package/dist/chunk-r3qrftds.js +0 -2
  375. package/dist/chunk-rbqn4725.js +0 -2
  376. package/dist/chunk-rekc1q3m.js +0 -2
  377. package/dist/chunk-rwkkqdcv.js +0 -2
  378. package/dist/chunk-rwnz06kr.js +0 -2
  379. package/dist/chunk-sxh0pd3y.js +0 -2
  380. package/dist/chunk-t0cr21e3.js +0 -2
  381. package/dist/chunk-vkrgdqnm.js +0 -2
  382. package/dist/chunk-wvdncbrt.js +0 -2
  383. package/dist/chunk-y7xcync7.js +0 -2
  384. package/dist/chunk-ye9tsdhn.js +0 -2
@@ -0,0 +1,302 @@
1
+ //! Native HTTP/SSE and WebSocket transport. The adapter owns model compatibility only.
2
+ use axum::body::Body;
3
+ use futures_util::{SinkExt, StreamExt};
4
+ use http_body_util::BodyExt;
5
+ use hyper::{Request, Response, StatusCode, body::Incoming};
6
+ use hyper_util::rt::TokioIo;
7
+ use std::{convert::Infallible, io, sync::Arc, time::Duration};
8
+ use tokio::{net::TcpListener, task::JoinHandle};
9
+ use tokio_tungstenite::{
10
+ WebSocketStream,
11
+ tungstenite::{self, protocol::Role},
12
+ };
13
+ use tokio_util::sync::CancellationToken;
14
+
15
+ #[path = "native_network_diagnostics.rs"]
16
+ mod diagnostics;
17
+ #[path = "system_proxy.rs"]
18
+ mod system_proxy;
19
+ use diagnostics::Trace;
20
+ const TOKEN: &str = "x-alwith-native-token";
21
+ const TARGET: &str = "x-alwith-native-target";
22
+ const LIMIT: usize = 64 * 1024 * 1024;
23
+ type Resolver = Arc<dyn Fn(&reqwest::Url, &Trace) -> Result<Option<String>, &'static str> + Send + Sync>;
24
+ #[derive(Clone)]
25
+ struct State {
26
+ token: String,
27
+ cancel: CancellationToken,
28
+ resolver: Resolver,
29
+ roots: Vec<reqwest::Certificate>,
30
+ }
31
+ /// The owner cancels listeners, requests and upgraded WebSockets together.
32
+ pub struct NativeNetwork {
33
+ endpoint: String,
34
+ cancel: CancellationToken,
35
+ task: JoinHandle<()>,
36
+ }
37
+ impl NativeNetwork {
38
+ pub async fn start() -> io::Result<Self> {
39
+ Self::with_resolver(Arc::new(system_proxy::resolve), vec![]).await
40
+ }
41
+ async fn with_resolver(resolver: Resolver, roots: Vec<reqwest::Certificate>) -> io::Result<Self> {
42
+ let listener = TcpListener::bind((std::net::Ipv4Addr::LOCALHOST, 0)).await?;
43
+ let token = format!("{}{}", uuid::Uuid::new_v4().simple(), uuid::Uuid::new_v4().simple());
44
+ let endpoint =
45
+ serde_json::json!({"version":1,"host":"127.0.0.1","port":listener.local_addr()?.port(),"token":token})
46
+ .to_string();
47
+ let cancel = CancellationToken::new();
48
+ let state = State { token, cancel: cancel.clone(), resolver, roots };
49
+ let task = tokio::spawn(async move {
50
+ let mut connections = tokio::task::JoinSet::new();
51
+ let slots = Arc::new(tokio::sync::Semaphore::new(128));
52
+ loop {
53
+ tokio::select! {
54
+ _ = state.cancel.cancelled() => break,
55
+ accepted = listener.accept() => {
56
+ let Ok((socket,_)) = accepted else { break };
57
+ let Ok(permit) = slots.clone().try_acquire_owned() else {drop(socket);continue};
58
+ let state = state.clone();
59
+ connections.spawn(async move {
60
+ let _permit = permit;
61
+ let cancel = state.cancel.clone();
62
+ let service = hyper::service::service_fn(move |request| {
63
+ let state = state.clone();
64
+ async move { Ok::<_, Infallible>(match handle(request,state).await {Ok(r)=>r,Err(code)=>error(code)}) }
65
+ });
66
+ let connection = hyper::server::conn::http1::Builder::new().timer(hyper_util::rt::TokioTimer::new()).header_read_timeout(Duration::from_secs(15)).serve_connection(TokioIo::new(socket),service).with_upgrades();
67
+ tokio::select! { _ = cancel.cancelled() => {}, _ = connection => {} }
68
+ });
69
+ },
70
+ _ = connections.join_next(), if !connections.is_empty() => {}
71
+ }
72
+ }
73
+ });
74
+ Ok(Self { endpoint, cancel, task })
75
+ }
76
+ pub fn endpoint(&self) -> &str {
77
+ &self.endpoint
78
+ }
79
+ }
80
+ impl Drop for NativeNetwork {
81
+ fn drop(&mut self) {
82
+ self.cancel.cancel();
83
+ self.task.abort();
84
+ }
85
+ }
86
+ fn error(code: &'static str) -> Response<Body> {
87
+ let status = if code == "NATIVE_NETWORK_AUTH_FAILED" { StatusCode::FORBIDDEN } else { StatusCode::BAD_GATEWAY };
88
+ Response::builder().status(status).header("x-alwith-native-error", code).body(Body::from(code)).unwrap()
89
+ }
90
+ fn clean(headers: &hyper::HeaderMap, websocket: bool) -> hyper::HeaderMap {
91
+ let mut result = headers.clone();
92
+ // Remove headers named by Connection as well as the standard hop-by-hop fields.
93
+ for value in headers.get_all("connection") {
94
+ if let Ok(value) = value.to_str() {
95
+ for name in value.split(',') {
96
+ result.remove(name.trim());
97
+ }
98
+ }
99
+ }
100
+ for name in [
101
+ TOKEN,
102
+ TARGET,
103
+ "x-alwith-native-error",
104
+ "x-alwith-native-request-id",
105
+ "host",
106
+ "connection",
107
+ "upgrade",
108
+ "proxy-authorization",
109
+ "proxy-authenticate",
110
+ "keep-alive",
111
+ "transfer-encoding",
112
+ "te",
113
+ "trailer",
114
+ ] {
115
+ result.remove(name);
116
+ }
117
+ if !websocket {
118
+ for name in [
119
+ "sec-websocket-key",
120
+ "sec-websocket-version",
121
+ "sec-websocket-accept",
122
+ "sec-websocket-protocol",
123
+ "sec-websocket-extensions",
124
+ ] {
125
+ result.remove(name);
126
+ }
127
+ }
128
+ result
129
+ }
130
+ async fn client(state: &State, url: &reqwest::Url, trace: &Trace) -> Result<reqwest::Client, &'static str> {
131
+ let resolver = state.resolver.clone();
132
+ let target = url.clone();
133
+ let resolution_trace = trace.clone();
134
+ let proxy = tokio::time::timeout(
135
+ Duration::from_secs(20),
136
+ tokio::task::spawn_blocking(move || resolver(&target, &resolution_trace)),
137
+ )
138
+ .await
139
+ .map_err(|_| "NATIVE_PROXY_RESOLUTION_FAILED")?
140
+ .map_err(|_| "NATIVE_PROXY_RESOLUTION_FAILED")??;
141
+ trace.route(proxy.as_deref());
142
+ // Both HTTP and WebSocket use this exact client and explicit system-proxy decision.
143
+ let mut builder = reqwest::Client::builder()
144
+ .tls_backend_native()
145
+ .no_proxy()
146
+ .redirect(reqwest::redirect::Policy::none())
147
+ .connect_timeout(Duration::from_secs(15))
148
+ .no_gzip()
149
+ .no_brotli()
150
+ .no_deflate()
151
+ .no_zstd();
152
+ for root in &state.roots {
153
+ builder = builder.add_root_certificate(root.clone());
154
+ }
155
+ if let Some(proxy) = proxy {
156
+ builder = builder.proxy(reqwest::Proxy::all(proxy).map_err(|_| "NATIVE_PROXY_RESOLUTION_FAILED")?);
157
+ }
158
+ builder.build().map_err(|_| "NATIVE_NETWORK_CONNECT_FAILED")
159
+ }
160
+ async fn handle(request: Request<Incoming>, state: State) -> Result<Response<Body>, &'static str> {
161
+ let token = request.headers().get(TOKEN).and_then(|h| h.to_str().ok()).unwrap_or("");
162
+ if token.len() != state.token.len()
163
+ || token.bytes().zip(state.token.bytes()).fold(0u8, |a, (b, c)| a | (b ^ c)) != 0
164
+ {
165
+ return Err("NATIVE_NETWORK_AUTH_FAILED");
166
+ }
167
+ let raw = request.headers().get(TARGET).and_then(|h| h.to_str().ok()).ok_or("NATIVE_NETWORK_PROTOCOL_ERROR")?;
168
+ let url = reqwest::Url::parse(raw).map_err(|_| "NATIVE_NETWORK_PROTOCOL_ERROR")?;
169
+ if !matches!(url.scheme(), "http" | "https")
170
+ || url.host_str().is_none()
171
+ || !url.username().is_empty()
172
+ || url.password().is_some()
173
+ {
174
+ return Err("NATIVE_NETWORK_PROTOCOL_ERROR");
175
+ }
176
+ let websocket = request.uri().path() == "/v1/websocket";
177
+ if !websocket && request.uri().path() != "/v1/http" {
178
+ return Err("NATIVE_NETWORK_PROTOCOL_ERROR");
179
+ }
180
+ let trace =
181
+ Trace::new(&url, websocket, request.headers().get("x-alwith-native-request-id").and_then(|v| v.to_str().ok()));
182
+ let result = perform(request, state, url, websocket, trace.clone()).await;
183
+ if let Err(code) = result {
184
+ trace.fail(code);
185
+ }
186
+ result
187
+ }
188
+ async fn perform(
189
+ mut request: Request<Incoming>, state: State, url: reqwest::Url, websocket: bool, trace: Trace,
190
+ ) -> Result<Response<Body>, &'static str> {
191
+ let client = client(&state, &url, &trace).await?;
192
+ let mut headers = clean(request.headers(), websocket);
193
+ let key = if websocket {
194
+ if request.method() != hyper::Method::GET {
195
+ return Err("NATIVE_NETWORK_PROTOCOL_ERROR");
196
+ }
197
+ let key = headers
198
+ .get("sec-websocket-key")
199
+ .and_then(|v| v.to_str().ok())
200
+ .ok_or("NATIVE_NETWORK_PROTOCOL_ERROR")?
201
+ .to_owned();
202
+ headers.insert("connection", hyper::header::HeaderValue::from_static("Upgrade"));
203
+ headers.insert("upgrade", hyper::header::HeaderValue::from_static("websocket"));
204
+ headers.remove("sec-websocket-extensions");
205
+ Some(key)
206
+ } else {
207
+ None
208
+ };
209
+ let upgrade = websocket.then(|| hyper::upgrade::on(&mut request));
210
+ let method = request.method().clone();
211
+ let body = http_body_util::Limited::new(request.into_body(), LIMIT)
212
+ .collect()
213
+ .await
214
+ .map_err(|_| "NATIVE_NETWORK_PROTOCOL_ERROR")?
215
+ .to_bytes();
216
+ trace.sent(body.len());
217
+ let mut outgoing = client.request(method, url).headers(headers).body(body);
218
+ if websocket {
219
+ outgoing = outgoing.version(hyper::Version::HTTP_11).timeout(Duration::from_secs(15));
220
+ }
221
+ let incoming = tokio::select! {
222
+ _ = state.cancel.cancelled() => return Err("NATIVE_NETWORK_CANCELLED"),
223
+ result = outgoing.send() => result.map_err(|e| {trace.error(&e); if e.is_timeout(){"ETIMEDOUT"}else{"NATIVE_NETWORK_CONNECT_FAILED"}})?
224
+ };
225
+ let status = incoming.status();
226
+ trace.headers(status.as_u16());
227
+ let mut response_headers = clean(incoming.headers(), websocket && status == StatusCode::SWITCHING_PROTOCOLS);
228
+ if websocket && status == StatusCode::SWITCHING_PROTOCOLS {
229
+ let accept = tungstenite::handshake::derive_accept_key(key.as_ref().unwrap().as_bytes());
230
+ if incoming.headers().get("sec-websocket-accept").and_then(|v| v.to_str().ok()) != Some(accept.as_str()) {
231
+ return Err("NATIVE_NETWORK_PROTOCOL_ERROR");
232
+ }
233
+ let remote = incoming.upgrade().await.map_err(|_| "NATIVE_NETWORK_PROTOCOL_ERROR")?;
234
+ let local = upgrade.unwrap();
235
+ let cancel = state.cancel.clone();
236
+ tokio::spawn(async move {
237
+ let task_trace = trace.clone();
238
+ tokio::select! {
239
+ _ = cancel.cancelled() => {},
240
+ _ = async {
241
+ let Ok(local) = local.await else {return};
242
+ let config = tungstenite::protocol::WebSocketConfig::default().max_message_size(Some(LIMIT)).max_frame_size(Some(LIMIT));
243
+ let local = WebSocketStream::from_raw_socket(TokioIo::new(local),Role::Server,Some(config)).await;
244
+ let remote = WebSocketStream::from_raw_socket(remote,Role::Client,Some(config)).await;
245
+ relay(local,remote,task_trace).await;
246
+ } => {}
247
+ }
248
+ });
249
+ response_headers.insert("connection", hyper::header::HeaderValue::from_static("Upgrade"));
250
+ response_headers.insert("upgrade", hyper::header::HeaderValue::from_static("websocket"));
251
+ let mut response = Response::new(Body::empty());
252
+ *response.status_mut() = status;
253
+ *response.headers_mut() = response_headers;
254
+ return Ok(response);
255
+ }
256
+ let stream = futures_util::stream::unfold((incoming.bytes_stream(), trace), |(mut stream, trace)| async move {
257
+ match stream.next().await {
258
+ Some(Ok(bytes)) => {
259
+ trace.received(bytes.len());
260
+ Some((Ok(bytes), (stream, trace)))
261
+ }
262
+ Some(Err(error)) => {
263
+ trace.error(&error);
264
+ trace.fail("NATIVE_NETWORK_STREAM_FAILED");
265
+ Some((Err(error), (stream, trace)))
266
+ }
267
+ None => {
268
+ trace.complete();
269
+ None
270
+ }
271
+ }
272
+ });
273
+ let mut response = Response::new(Body::from_stream(stream));
274
+ *response.status_mut() = status;
275
+ *response.headers_mut() = response_headers;
276
+ Ok(response)
277
+ }
278
+ async fn relay<A, B>(mut local: WebSocketStream<A>, mut remote: WebSocketStream<B>, trace: Trace)
279
+ where
280
+ A: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin,
281
+ B: tokio::io::AsyncRead + tokio::io::AsyncWrite + Unpin,
282
+ {
283
+ loop {
284
+ tokio::select! {
285
+ message=local.next()=>match message {
286
+ Some(Ok(message))=>{trace.sent(message.len());let close=message.is_close();if let tungstenite::Message::Close(frame)=&message{trace.close(frame.as_ref().map_or(1000,|f|f.code.into()));}
287
+ if remote.send(message).await.is_err(){trace.fail("NATIVE_NETWORK_STREAM_FAILED");break}
288
+ if close{break}},
289
+ _=>{let _=remote.close(None).await;break}
290
+ },
291
+ message=remote.next()=>match message {
292
+ Some(Ok(message))=>{trace.received(message.len());let close=message.is_close();if let tungstenite::Message::Close(frame)=&message{trace.close(frame.as_ref().map_or(1000,|f|f.code.into()));}
293
+ if local.send(message).await.is_err(){break}
294
+ if close{break}},
295
+ failure=>{if let Some(Err(error))=failure { trace.websocket_error(&error); } trace.fail("NATIVE_NETWORK_STREAM_FAILED");let _=local.close(Some(tungstenite::protocol::CloseFrame{code:tungstenite::protocol::frame::coding::CloseCode::Error,reason:"Upstream disconnected".into()})).await;break}
296
+ }
297
+ }
298
+ }
299
+ }
300
+ #[cfg(test)]
301
+ #[path = "__tests__/native_network.rs"]
302
+ mod tests;
@@ -0,0 +1,220 @@
1
+ //! Allowlisted transport metadata only. Never log request bodies, credentials or complete URLs.
2
+ use serde::Serialize;
3
+ use std::{
4
+ sync::{Arc, Mutex},
5
+ time::Instant,
6
+ };
7
+ const PREFIX: &str = "[alwith-native-network] ";
8
+ #[derive(Clone, Serialize)]
9
+ #[serde(rename_all = "camelCase")]
10
+ struct Record {
11
+ version: u8,
12
+ request_id: String,
13
+ transport: &'static str,
14
+ tls_backend: &'static str,
15
+ target_host: String,
16
+ target_port: u16,
17
+ phase: &'static str,
18
+ stage: &'static str,
19
+ route: &'static str,
20
+ proxy_host: Option<String>,
21
+ proxy_port: Option<u16>,
22
+ proxy_scheme: Option<String>,
23
+ proxy_source: Option<&'static str>,
24
+ winhttp_error: Option<u32>,
25
+ elapsed_ms: u64,
26
+ proxy_resolve_ms: Option<u64>,
27
+ first_byte_ms: Option<u64>,
28
+ status: Option<u16>,
29
+ close_code: Option<u16>,
30
+ sent_bytes: u64,
31
+ received_bytes: u64,
32
+ error_code: Option<&'static str>,
33
+ error_kind: Option<&'static str>,
34
+ os_error: Option<i32>,
35
+ }
36
+ struct Inner {
37
+ record: Record,
38
+ started: Instant,
39
+ finished: bool,
40
+ }
41
+ impl Inner {
42
+ fn emit(&mut self, phase: &'static str) {
43
+ self.record.phase = phase;
44
+ self.record.elapsed_ms = self.started.elapsed().as_millis() as u64;
45
+ log::info!("{}{}", PREFIX, serde_json::to_string(&self.record).expect("network metadata serializes"));
46
+ }
47
+ fn end(&mut self, phase: &'static str) {
48
+ if !self.finished {
49
+ self.finished = true;
50
+ self.emit(phase);
51
+ }
52
+ }
53
+ }
54
+ impl Drop for Inner {
55
+ fn drop(&mut self) {
56
+ self.end("cancelled");
57
+ }
58
+ }
59
+ #[derive(Clone)]
60
+ pub(super) struct Trace(Arc<Mutex<Inner>>);
61
+ impl Trace {
62
+ pub(super) fn new(url: &reqwest::Url, websocket: bool, request_id: Option<&str>) -> Self {
63
+ let request_id = request_id
64
+ .filter(|id| id.len() == 24 && id.bytes().all(|b| b.is_ascii_hexdigit()))
65
+ .map(str::to_owned)
66
+ .unwrap_or_else(|| uuid::Uuid::new_v4().simple().to_string()[..24].into());
67
+ let mut inner = Inner {
68
+ started: Instant::now(),
69
+ finished: false,
70
+ record: Record {
71
+ version: 1,
72
+ request_id,
73
+ transport: if websocket { "websocket" } else { "http" },
74
+ tls_backend: if url.scheme() == "http" {
75
+ "none"
76
+ } else if cfg!(windows) {
77
+ "schannel"
78
+ } else {
79
+ "native-tls"
80
+ },
81
+ target_host: url.host_str().expect("validated target host").into(),
82
+ target_port: url.port_or_known_default().expect("validated HTTP URL"),
83
+ phase: "started",
84
+ stage: "resolve_proxy",
85
+ route: "unresolved",
86
+ proxy_host: None,
87
+ proxy_port: None,
88
+ proxy_scheme: None,
89
+ proxy_source: None,
90
+ winhttp_error: None,
91
+ elapsed_ms: 0,
92
+ proxy_resolve_ms: None,
93
+ first_byte_ms: None,
94
+ status: None,
95
+ close_code: None,
96
+ sent_bytes: 0,
97
+ received_bytes: 0,
98
+ error_code: None,
99
+ error_kind: None,
100
+ os_error: None,
101
+ },
102
+ };
103
+ inner.emit("started");
104
+ Self(Arc::new(Mutex::new(inner)))
105
+ }
106
+ #[cfg(any(windows, test))]
107
+ pub(super) fn proxy_source(&self, source: &'static str) {
108
+ self.0.lock().unwrap().record.proxy_source = Some(source);
109
+ }
110
+ #[cfg(any(windows, test))]
111
+ pub(super) fn proxy_error(&self, code: u32) {
112
+ self.0.lock().unwrap().record.winhttp_error = Some(code);
113
+ }
114
+ pub(super) fn route(&self, proxy: Option<&str>) {
115
+ let mut inner = self.0.lock().unwrap();
116
+ inner.record.proxy_resolve_ms = Some(inner.started.elapsed().as_millis() as u64);
117
+ inner.record.route = if proxy.is_some() { "proxy" } else { "direct" };
118
+ if let Some(proxy) = proxy.and_then(|p| reqwest::Url::parse(p).ok()) {
119
+ inner.record.proxy_host = proxy.host_str().map(str::to_owned);
120
+ inner.record.proxy_port = proxy.port_or_known_default();
121
+ inner.record.proxy_scheme = Some(proxy.scheme().into());
122
+ }
123
+ inner.record.stage = "connect_upstream";
124
+ inner.emit("proxy_resolved");
125
+ }
126
+ pub(super) fn headers(&self, status: u16) {
127
+ let mut inner = self.0.lock().unwrap();
128
+ inner.record.status = Some(status);
129
+ inner.record.stage = "read_response";
130
+ inner.emit("headers");
131
+ }
132
+ pub(super) fn sent(&self, bytes: usize) {
133
+ self.0.lock().unwrap().record.sent_bytes += bytes as u64;
134
+ }
135
+ pub(super) fn received(&self, bytes: usize) {
136
+ let mut inner = self.0.lock().unwrap();
137
+ let elapsed = inner.started.elapsed().as_millis() as u64;
138
+ inner.record.first_byte_ms.get_or_insert(elapsed);
139
+ inner.record.received_bytes += bytes as u64;
140
+ }
141
+ pub(super) fn complete(&self) {
142
+ self.0.lock().unwrap().end("completed");
143
+ }
144
+ pub(super) fn close(&self, code: u16) {
145
+ let mut inner = self.0.lock().unwrap();
146
+ inner.record.close_code = Some(code);
147
+ inner.end(if code == 1000 || code == 1001 || code >= 3000 { "completed" } else { "failed" });
148
+ }
149
+ pub(super) fn fail(&self, code: &'static str) {
150
+ let mut inner = self.0.lock().unwrap();
151
+ if !inner.finished {
152
+ inner.record.error_code = Some(code);
153
+ inner.end("failed");
154
+ }
155
+ }
156
+ pub(super) fn websocket_error(&self, error: &tokio_tungstenite::tungstenite::Error) {
157
+ let mut inner = self.0.lock().unwrap();
158
+ inner.record.error_kind = Some("websocket");
159
+ inner.record.close_code = Some(1006);
160
+ if let tokio_tungstenite::tungstenite::Error::Io(error) = error {
161
+ inner.record.os_error = error.raw_os_error();
162
+ }
163
+ }
164
+ pub(super) fn error(&self, error: &reqwest::Error) {
165
+ let mut inner = self.0.lock().unwrap();
166
+ inner.record.error_kind = Some(if error.is_timeout() {
167
+ "timeout"
168
+ } else if error.is_dns() {
169
+ "dns"
170
+ } else if error.is_connect() {
171
+ "connect"
172
+ } else if error.is_body() {
173
+ "body"
174
+ } else {
175
+ "request"
176
+ });
177
+ let mut cause = std::error::Error::source(error);
178
+ for _ in 0..8 {
179
+ let Some(current) = cause else { break };
180
+ if let Some(io) = current.downcast_ref::<std::io::Error>()
181
+ && let Some(code) = io.raw_os_error()
182
+ {
183
+ inner.record.os_error = Some(code);
184
+ break;
185
+ }
186
+ cause = current.source();
187
+ }
188
+ }
189
+ }
190
+ #[cfg(test)]
191
+ mod tests {
192
+ use super::*;
193
+ #[test]
194
+ fn metadata_excludes_urls_credentials_and_invalid_identifiers() {
195
+ let trace = Trace::new(
196
+ &reqwest::Url::parse("https://example.org/private?token=secret").unwrap(),
197
+ true,
198
+ Some("secret-id"),
199
+ );
200
+ trace.proxy_source("windows-pac");
201
+ trace.proxy_error(12166);
202
+ trace.route(Some("http://username:password@127.0.0.1:7890/private?secret"));
203
+ trace.sent(17);
204
+ trace.received(23);
205
+ trace.headers(101);
206
+ trace.close(1000);
207
+ let inner = trace.0.lock().unwrap();
208
+ let value = serde_json::to_value(&inner.record).unwrap();
209
+ let text = value.to_string();
210
+ for forbidden in ["secret", "private", "username", "password"] {
211
+ assert!(!text.contains(forbidden));
212
+ }
213
+ assert_eq!(value["targetHost"], "example.org");
214
+ assert_eq!(value["proxyHost"], "127.0.0.1");
215
+ assert_eq!(value["proxyPort"], 7890);
216
+ assert_eq!(value["receivedBytes"], 23);
217
+ assert_eq!(value["phase"], "completed");
218
+ assert_eq!(value["requestId"].as_str().unwrap().len(), 24);
219
+ }
220
+ }
@@ -556,7 +556,10 @@ async fn recognized_custom_models_receive_their_catalog_without_changing_routing
556
556
  assert_eq!(params["baseUrl"], "https://open.bigmodel.cn/api/v1");
557
557
  assert_eq!(params["_meta"]["alwith"]["models"][0]["id"], "glm-5.3");
558
558
  assert_eq!(params["_meta"]["alwith"]["models"][0]["label"], "My GLM");
559
- assert_eq!(params["_meta"]["codex"]["config"]["model_catalog_json"], "/resources/custom/models.json");
559
+ assert_eq!(
560
+ params["_meta"]["codex"]["config"]["model_catalog_json"],
561
+ std::path::Path::new("/resources").join("custom/models.json").to_string_lossy().as_ref()
562
+ );
560
563
  assert_eq!(params["_meta"]["codex"]["config"]["web_search"], "disabled");
561
564
  }
562
565