@flamingo-stack/openframe-frontend-core 0.0.488 → 0.0.490-1506.3944.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 (311) hide show
  1. package/dist/chat-protocol/decode.d.ts +58 -0
  2. package/dist/chat-protocol/decode.d.ts.map +1 -0
  3. package/dist/chat-protocol/encode.d.ts +44 -0
  4. package/dist/chat-protocol/encode.d.ts.map +1 -0
  5. package/dist/chat-protocol/env-flag.d.ts +35 -0
  6. package/dist/chat-protocol/env-flag.d.ts.map +1 -0
  7. package/dist/chat-protocol/events.d.ts +196 -0
  8. package/dist/chat-protocol/events.d.ts.map +1 -0
  9. package/dist/chat-protocol/frames.d.ts +213 -0
  10. package/dist/chat-protocol/frames.d.ts.map +1 -0
  11. package/dist/chat-protocol/index.cjs +494 -0
  12. package/dist/chat-protocol/index.cjs.map +1 -0
  13. package/dist/chat-protocol/index.d.ts +18 -0
  14. package/dist/chat-protocol/index.d.ts.map +1 -0
  15. package/dist/chat-protocol/index.js +478 -0
  16. package/dist/chat-protocol/index.js.map +1 -0
  17. package/dist/chat-protocol/ip-normalize.d.ts +44 -0
  18. package/dist/chat-protocol/ip-normalize.d.ts.map +1 -0
  19. package/dist/chat-protocol/nats-decoder.d.ts +26 -0
  20. package/dist/chat-protocol/nats-decoder.d.ts.map +1 -0
  21. package/dist/{chunk-AJNDDXKC.js → chunk-4NWARV5I.js} +3 -3
  22. package/dist/{chunk-GQX6LFFA.cjs → chunk-5CJR2GZ4.cjs} +42 -42
  23. package/dist/{chunk-GQX6LFFA.cjs.map → chunk-5CJR2GZ4.cjs.map} +1 -1
  24. package/dist/{chunk-EUYIFALO.cjs → chunk-5EYRXSY5.cjs} +14 -14
  25. package/dist/{chunk-EUYIFALO.cjs.map → chunk-5EYRXSY5.cjs.map} +1 -1
  26. package/dist/{chunk-5RXKOGH6.cjs → chunk-5LMGFI4J.cjs} +7011 -4777
  27. package/dist/chunk-5LMGFI4J.cjs.map +1 -0
  28. package/dist/{chunk-KFQXO7QB.js → chunk-6GT557KN.js} +1 -1
  29. package/dist/chunk-6GT557KN.js.map +1 -0
  30. package/dist/{chunk-77DFPD35.js → chunk-BE6DK7QY.js} +12267 -10033
  31. package/dist/chunk-BE6DK7QY.js.map +1 -0
  32. package/dist/{chunk-A7IPON2V.cjs → chunk-BIKOJ4FH.cjs} +5 -5
  33. package/dist/{chunk-A7IPON2V.cjs.map → chunk-BIKOJ4FH.cjs.map} +1 -1
  34. package/dist/{chunk-HQYJINFV.js → chunk-CORIBKHG.js} +4 -4
  35. package/dist/{chunk-YEEHB4T6.cjs → chunk-CSYSYJCF.cjs} +40 -40
  36. package/dist/{chunk-YEEHB4T6.cjs.map → chunk-CSYSYJCF.cjs.map} +1 -1
  37. package/dist/{chunk-SIKCXKGB.cjs → chunk-DSDZ5T4P.cjs} +7 -7
  38. package/dist/{chunk-SIKCXKGB.cjs.map → chunk-DSDZ5T4P.cjs.map} +1 -1
  39. package/dist/{chunk-PNXNWGBY.js → chunk-GTWO5NAY.js} +2 -2
  40. package/dist/{chunk-SCCTJ2UI.js → chunk-HSACATCD.js} +4 -4
  41. package/dist/{chunk-PECGZWQR.cjs → chunk-KP5KRRD6.cjs} +3 -3
  42. package/dist/{chunk-PECGZWQR.cjs.map → chunk-KP5KRRD6.cjs.map} +1 -1
  43. package/dist/{chunk-2B6773QM.cjs → chunk-LILQJ3UZ.cjs} +1 -1
  44. package/dist/chunk-LILQJ3UZ.cjs.map +1 -0
  45. package/dist/{chunk-RZSA6MZL.cjs → chunk-NWX7MMF5.cjs} +15 -15
  46. package/dist/{chunk-RZSA6MZL.cjs.map → chunk-NWX7MMF5.cjs.map} +1 -1
  47. package/dist/{chunk-V3CNNMY3.cjs → chunk-P4WTZU6L.cjs} +18 -18
  48. package/dist/{chunk-V3CNNMY3.cjs.map → chunk-P4WTZU6L.cjs.map} +1 -1
  49. package/dist/{chunk-KLYHZRAD.js → chunk-PB3BTZDU.js} +2 -2
  50. package/dist/{chunk-FZOBQG6M.cjs → chunk-Q6E7VJ4W.cjs} +37 -36
  51. package/dist/chunk-Q6E7VJ4W.cjs.map +1 -0
  52. package/dist/{chunk-EYEIVYYF.cjs → chunk-QSCHCZL3.cjs} +7 -7
  53. package/dist/{chunk-EYEIVYYF.cjs.map → chunk-QSCHCZL3.cjs.map} +1 -1
  54. package/dist/{chunk-YJSKQ2ZV.js → chunk-RQLBHKXN.js} +3 -3
  55. package/dist/{chunk-CWQACI4Z.js → chunk-RW2LPL72.js} +2 -2
  56. package/dist/{chunk-DX6AOHNU.cjs → chunk-S2NHJDKQ.cjs} +77 -77
  57. package/dist/{chunk-DX6AOHNU.cjs.map → chunk-S2NHJDKQ.cjs.map} +1 -1
  58. package/dist/{chunk-AHDJMEEN.js → chunk-T2EGSZFN.js} +9 -8
  59. package/dist/chunk-T2EGSZFN.js.map +1 -0
  60. package/dist/{chunk-S52LJNMU.js → chunk-TKN5667N.js} +13 -13
  61. package/dist/chunk-TKN5667N.js.map +1 -0
  62. package/dist/{chunk-3BFX6HJM.js → chunk-UUYRJPGJ.js} +6 -6
  63. package/dist/{chunk-F6BYUO5U.js → chunk-VHG6AX5V.js} +3 -3
  64. package/dist/{chunk-FOQV6RCO.cjs → chunk-VQ523ORK.cjs} +29 -29
  65. package/dist/{chunk-FOQV6RCO.cjs.map → chunk-VQ523ORK.cjs.map} +1 -1
  66. package/dist/{chunk-PXF5J24T.js → chunk-XQ2B74SI.js} +2 -2
  67. package/dist/{chunk-H7JX2BG7.cjs → chunk-YHOIAA2E.cjs} +76 -76
  68. package/dist/chunk-YHOIAA2E.cjs.map +1 -0
  69. package/dist/{chunk-LLWBPPZ4.js → chunk-YZ2OIYQ3.js} +6 -6
  70. package/dist/components/case-studies/index.cjs +10 -10
  71. package/dist/components/case-studies/index.js +4 -4
  72. package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
  73. package/dist/components/chat/chat-message-list.d.ts.map +1 -1
  74. package/dist/components/chat/hooks/index.d.ts +0 -1
  75. package/dist/components/chat/hooks/index.d.ts.map +1 -1
  76. package/dist/components/chat/hooks/use-chat-history-hydration.d.ts +47 -0
  77. package/dist/components/chat/hooks/use-chat-history-hydration.d.ts.map +1 -0
  78. package/dist/components/chat/hooks/use-chat.d.ts +1 -0
  79. package/dist/components/chat/hooks/use-chat.d.ts.map +1 -1
  80. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +15 -48
  81. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
  82. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +10 -53
  83. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  84. package/dist/components/chat/index.cjs +12 -4
  85. package/dist/components/chat/index.cjs.map +1 -1
  86. package/dist/components/chat/index.d.ts +1 -0
  87. package/dist/components/chat/index.d.ts.map +1 -1
  88. package/dist/components/chat/index.js +23 -15
  89. package/dist/components/chat/stream/chat-dialog-store.d.ts +184 -0
  90. package/dist/components/chat/stream/chat-dialog-store.d.ts.map +1 -0
  91. package/dist/components/chat/stream/chat-stream-reducer.d.ts +367 -0
  92. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -0
  93. package/dist/components/chat/stream/delta-batcher.d.ts +51 -0
  94. package/dist/components/chat/stream/delta-batcher.d.ts.map +1 -0
  95. package/dist/components/chat/stream/index.d.ts +17 -0
  96. package/dist/components/chat/stream/index.d.ts.map +1 -0
  97. package/dist/components/chat/stream/message-mutations.d.ts +77 -0
  98. package/dist/components/chat/stream/message-mutations.d.ts.map +1 -0
  99. package/dist/components/chat/stream/use-chat-stream-reducer.d.ts +22 -0
  100. package/dist/components/chat/stream/use-chat-stream-reducer.d.ts.map +1 -0
  101. package/dist/components/chat/types/api.types.d.ts +1 -81
  102. package/dist/components/chat/types/api.types.d.ts.map +1 -1
  103. package/dist/components/chat/types/processing.types.d.ts +2 -90
  104. package/dist/components/chat/types/processing.types.d.ts.map +1 -1
  105. package/dist/components/chat/types/unified-chat-state.types.d.ts +5 -0
  106. package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
  107. package/dist/components/chat/utils/chat-conversation-storage.d.ts +34 -0
  108. package/dist/components/chat/utils/chat-conversation-storage.d.ts.map +1 -0
  109. package/dist/components/chat/utils/extract-incomplete-message-state.d.ts +34 -6
  110. package/dist/components/chat/utils/extract-incomplete-message-state.d.ts.map +1 -1
  111. package/dist/components/chat/utils/index.d.ts +2 -3
  112. package/dist/components/chat/utils/index.d.ts.map +1 -1
  113. package/dist/components/chat/utils/process-historical-messages.d.ts +59 -11
  114. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  115. package/dist/components/contact/index.cjs +5 -5
  116. package/dist/components/contact/index.js +4 -4
  117. package/dist/components/docs/index.cjs +7 -7
  118. package/dist/components/docs/index.js +6 -6
  119. package/dist/components/embeds/index.cjs +5 -5
  120. package/dist/components/embeds/index.js +4 -4
  121. package/dist/components/faq/index.cjs +6 -6
  122. package/dist/components/faq/index.js +5 -5
  123. package/dist/components/features/index.cjs +4 -4
  124. package/dist/components/features/index.js +3 -3
  125. package/dist/components/help-center-pages/index.cjs +23 -23
  126. package/dist/components/help-center-pages/index.js +14 -14
  127. package/dist/components/index.cjs +182 -140
  128. package/dist/components/index.cjs.map +1 -1
  129. package/dist/components/index.js +66 -24
  130. package/dist/components/index.js.map +1 -1
  131. package/dist/components/navigation/index.cjs +4 -4
  132. package/dist/components/navigation/index.js +3 -3
  133. package/dist/components/onboarding-guides/index.cjs +8 -8
  134. package/dist/components/onboarding-guides/index.js +7 -7
  135. package/dist/components/onboarding-guides/onboarding-guide-detail-view.d.ts.map +1 -1
  136. package/dist/components/related-content/index.cjs +6 -6
  137. package/dist/components/related-content/index.js +5 -5
  138. package/dist/components/shared/product-release/release-detail-page.d.ts.map +1 -1
  139. package/dist/components/tickets/index.cjs +7 -7
  140. package/dist/components/tickets/index.js +6 -6
  141. package/dist/components/ui/index.cjs +46 -4
  142. package/dist/components/ui/index.cjs.map +1 -1
  143. package/dist/components/ui/index.d.ts +1 -2
  144. package/dist/components/ui/index.d.ts.map +1 -1
  145. package/dist/components/ui/index.js +57 -15
  146. package/dist/components/ui/markdown/base-components.d.ts +51 -0
  147. package/dist/components/ui/markdown/base-components.d.ts.map +1 -0
  148. package/dist/components/ui/markdown/engine.d.ts +99 -0
  149. package/dist/components/ui/markdown/engine.d.ts.map +1 -0
  150. package/dist/components/ui/markdown/heading-ids.d.ts +65 -0
  151. package/dist/components/ui/markdown/heading-ids.d.ts.map +1 -0
  152. package/dist/components/ui/markdown/index.d.ts +18 -0
  153. package/dist/components/ui/markdown/index.d.ts.map +1 -0
  154. package/dist/components/ui/markdown/mermaid-diagram.d.ts +79 -0
  155. package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -0
  156. package/dist/components/ui/markdown/rich/embed-overrides.d.ts +14 -0
  157. package/dist/components/ui/markdown/rich/embed-overrides.d.ts.map +1 -0
  158. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +40 -0
  159. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +1 -0
  160. package/dist/components/ui/markdown/rich/shortcodes.d.ts +8 -0
  161. package/dist/components/ui/markdown/rich/shortcodes.d.ts.map +1 -0
  162. package/dist/components/ui/markdown/sanitize.d.ts +153 -0
  163. package/dist/components/ui/markdown/sanitize.d.ts.map +1 -0
  164. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +23 -0
  165. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +1 -0
  166. package/dist/components/ui/markdown/streaming.d.ts +78 -0
  167. package/dist/components/ui/markdown/streaming.d.ts.map +1 -0
  168. package/dist/components/ui/markdown/text-size.d.ts +34 -0
  169. package/dist/components/ui/markdown/text-size.d.ts.map +1 -0
  170. package/dist/contexts/chat-runtime-context.d.ts +8 -0
  171. package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
  172. package/dist/contexts/index.cjs +2 -2
  173. package/dist/contexts/index.js +1 -1
  174. package/dist/hooks/index.cjs +3 -3
  175. package/dist/hooks/index.js +2 -2
  176. package/dist/index.cjs +62 -4
  177. package/dist/index.cjs.map +1 -1
  178. package/dist/index.js +73 -15
  179. package/dist/utils/index.cjs +169 -40
  180. package/dist/utils/index.cjs.map +1 -1
  181. package/dist/utils/index.d.ts +1 -0
  182. package/dist/utils/index.d.ts.map +1 -1
  183. package/dist/utils/index.js +162 -41
  184. package/dist/utils/index.js.map +1 -1
  185. package/dist/utils/markdown-fences.d.ts +42 -0
  186. package/dist/utils/markdown-fences.d.ts.map +1 -0
  187. package/dist/utils/markdown-heading-id.d.ts +85 -0
  188. package/dist/utils/markdown-heading-id.d.ts.map +1 -0
  189. package/dist/utils/markdown-section-extractor.d.ts.map +1 -1
  190. package/package.json +7 -1
  191. package/src/chat-protocol/__tests__/__snapshots__/nats-decoder-golden.test.ts.snap +307 -0
  192. package/src/chat-protocol/__tests__/chat-protocol.test.ts +516 -0
  193. package/src/chat-protocol/__tests__/env-flag.test.ts +52 -0
  194. package/src/chat-protocol/__tests__/ip-normalize.test.ts +136 -0
  195. package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +228 -0
  196. package/src/chat-protocol/decode.ts +278 -0
  197. package/src/chat-protocol/encode.ts +71 -0
  198. package/src/chat-protocol/env-flag.ts +39 -0
  199. package/src/chat-protocol/events.ts +232 -0
  200. package/src/chat-protocol/frames.ts +245 -0
  201. package/src/chat-protocol/index.ts +21 -0
  202. package/src/chat-protocol/ip-normalize.ts +146 -0
  203. package/src/chat-protocol/nats-decoder.ts +252 -0
  204. package/src/components/chat/__tests__/chat-message-list.test.tsx +293 -5
  205. package/src/components/chat/__tests__/chat-message-streaming-memo.test.tsx +207 -0
  206. package/src/components/chat/__tests__/chat-pending-turn.test.tsx +209 -0
  207. package/src/components/chat/chat-message-enhanced.tsx +111 -17
  208. package/src/components/chat/chat-message-list.tsx +358 -109
  209. package/src/components/chat/embeddable-chat.tsx +6 -0
  210. package/src/components/chat/hooks/.index.md +30 -33
  211. package/src/components/chat/hooks/.use-nats-chat-adapter.md +36 -55
  212. package/src/components/chat/hooks/__tests__/__snapshots__/conversation-id-persistence-golden.test.ts.snap +37 -0
  213. package/src/components/chat/hooks/__tests__/__snapshots__/sse-stream-golden.test.ts.snap +0 -0
  214. package/src/components/chat/hooks/__tests__/conversation-id-persistence-golden.test.ts +438 -0
  215. package/src/components/chat/hooks/__tests__/sse-stream-golden.test.ts +318 -0
  216. package/src/components/chat/hooks/index.ts +0 -1
  217. package/src/components/chat/hooks/use-chat-history-hydration.ts +142 -0
  218. package/src/components/chat/hooks/use-chat.ts +20 -0
  219. package/src/components/chat/hooks/use-nats-chat-adapter.ts +243 -823
  220. package/src/components/chat/hooks/use-sse-chat-adapter.ts +417 -774
  221. package/src/components/chat/index.ts +5 -0
  222. package/src/components/chat/stream/__tests__/__snapshots__/chat-stream-reducer-golden.test.ts.snap +940 -0
  223. package/src/components/chat/stream/__tests__/chat-dialog-store.test.ts +756 -0
  224. package/src/components/chat/stream/__tests__/chat-stream-reducer-golden.test.ts +460 -0
  225. package/src/components/chat/stream/__tests__/chat-stream-reducer.test.ts +894 -0
  226. package/src/components/chat/stream/__tests__/delta-batcher.test.ts +255 -0
  227. package/src/components/chat/stream/__tests__/use-chat-stream-reducer.test.ts +98 -0
  228. package/src/components/chat/stream/chat-dialog-store.ts +536 -0
  229. package/src/components/chat/stream/chat-stream-reducer.ts +1796 -0
  230. package/src/components/chat/stream/delta-batcher.ts +159 -0
  231. package/src/components/chat/stream/index.ts +55 -0
  232. package/src/components/chat/stream/message-mutations.ts +338 -0
  233. package/src/components/chat/stream/use-chat-stream-reducer.ts +126 -0
  234. package/src/components/chat/thinking-display.tsx +1 -1
  235. package/src/components/chat/types/.api.types.md +39 -49
  236. package/src/components/chat/types/.processing.types.md +29 -58
  237. package/src/components/chat/types/api.types.ts +6 -73
  238. package/src/components/chat/types/processing.types.ts +11 -52
  239. package/src/components/chat/types/unified-chat-state.types.ts +6 -0
  240. package/src/components/chat/utils/.index.md +31 -40
  241. package/src/components/chat/utils/__tests__/__snapshots__/process-historical-messages-golden.test.ts.snap +420 -0
  242. package/src/components/chat/utils/__tests__/__snapshots__/segment-accumulator-golden.test.ts.snap +605 -0
  243. package/src/components/chat/utils/__tests__/process-historical-messages-golden.test.ts +317 -0
  244. package/src/components/chat/utils/__tests__/segment-accumulator-golden.test.ts +270 -0
  245. package/src/components/chat/utils/chat-conversation-storage.ts +83 -0
  246. package/src/components/chat/utils/extract-incomplete-message-state.ts +63 -5
  247. package/src/components/chat/utils/index.ts +5 -8
  248. package/src/components/chat/utils/process-historical-messages.ts +352 -384
  249. package/src/components/onboarding-guides/onboarding-guide-detail-view.tsx +22 -4
  250. package/src/components/shared/legal-document/legal-document-page.tsx +1 -1
  251. package/src/components/shared/product-release/release-detail-page.tsx +19 -4
  252. package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +2420 -0
  253. package/src/components/ui/__tests__/markdown-parity.test.tsx +2528 -0
  254. package/src/components/ui/index.ts +1 -2
  255. package/src/components/ui/markdown/__tests__/mermaid-security.test.ts +115 -0
  256. package/src/components/ui/markdown/__tests__/mermaid-stale-render.test.tsx +95 -0
  257. package/src/components/ui/markdown/__tests__/sanitize-invariant.test.ts +309 -0
  258. package/src/components/ui/markdown/__tests__/streaming.test.tsx +388 -0
  259. package/src/components/ui/markdown/base-components.tsx +360 -0
  260. package/src/components/ui/markdown/engine.tsx +315 -0
  261. package/src/components/ui/markdown/heading-ids.ts +239 -0
  262. package/src/components/ui/markdown/index.ts +49 -0
  263. package/src/components/ui/markdown/mermaid-diagram.tsx +291 -0
  264. package/src/components/ui/markdown/rich/embed-overrides.tsx +199 -0
  265. package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +184 -0
  266. package/src/components/ui/markdown/rich/shortcodes.ts +170 -0
  267. package/src/components/ui/markdown/sanitize.ts +3499 -0
  268. package/src/components/ui/markdown/simple-markdown-renderer.tsx +28 -0
  269. package/src/components/ui/markdown/streaming.ts +362 -0
  270. package/src/components/ui/markdown/text-size.ts +106 -0
  271. package/src/components/ui/release-changelog-section.tsx +1 -1
  272. package/src/components/ui/ticket-info-section.tsx +1 -1
  273. package/src/contexts/chat-runtime-context.tsx +8 -0
  274. package/src/utils/index.ts +1 -0
  275. package/src/utils/markdown-fences.ts +127 -0
  276. package/src/utils/markdown-heading-id.ts +348 -0
  277. package/src/utils/markdown-section-extractor.ts +41 -56
  278. package/dist/chunk-2B6773QM.cjs.map +0 -1
  279. package/dist/chunk-5RXKOGH6.cjs.map +0 -1
  280. package/dist/chunk-77DFPD35.js.map +0 -1
  281. package/dist/chunk-AHDJMEEN.js.map +0 -1
  282. package/dist/chunk-FZOBQG6M.cjs.map +0 -1
  283. package/dist/chunk-H7JX2BG7.cjs.map +0 -1
  284. package/dist/chunk-KFQXO7QB.js.map +0 -1
  285. package/dist/chunk-S52LJNMU.js.map +0 -1
  286. package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts +0 -6
  287. package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts.map +0 -1
  288. package/dist/components/chat/utils/chunk-parser.d.ts +0 -25
  289. package/dist/components/chat/utils/chunk-parser.d.ts.map +0 -1
  290. package/dist/components/ui/rich-markdown-renderer.d.ts +0 -34
  291. package/dist/components/ui/rich-markdown-renderer.d.ts.map +0 -1
  292. package/dist/components/ui/simple-markdown-renderer.d.ts +0 -73
  293. package/dist/components/ui/simple-markdown-renderer.d.ts.map +0 -1
  294. package/src/components/chat/hooks/.use-realtime-chunk-processor.md +0 -77
  295. package/src/components/chat/hooks/use-realtime-chunk-processor.ts +0 -479
  296. package/src/components/chat/utils/.chunk-parser.md +0 -62
  297. package/src/components/chat/utils/chunk-parser.ts +0 -256
  298. package/src/components/ui/.simple-markdown-renderer.md +0 -52
  299. package/src/components/ui/rich-markdown-renderer.tsx +0 -1223
  300. package/src/components/ui/simple-markdown-renderer.tsx +0 -964
  301. /package/dist/{chunk-AJNDDXKC.js.map → chunk-4NWARV5I.js.map} +0 -0
  302. /package/dist/{chunk-HQYJINFV.js.map → chunk-CORIBKHG.js.map} +0 -0
  303. /package/dist/{chunk-PNXNWGBY.js.map → chunk-GTWO5NAY.js.map} +0 -0
  304. /package/dist/{chunk-SCCTJ2UI.js.map → chunk-HSACATCD.js.map} +0 -0
  305. /package/dist/{chunk-KLYHZRAD.js.map → chunk-PB3BTZDU.js.map} +0 -0
  306. /package/dist/{chunk-YJSKQ2ZV.js.map → chunk-RQLBHKXN.js.map} +0 -0
  307. /package/dist/{chunk-CWQACI4Z.js.map → chunk-RW2LPL72.js.map} +0 -0
  308. /package/dist/{chunk-3BFX6HJM.js.map → chunk-UUYRJPGJ.js.map} +0 -0
  309. /package/dist/{chunk-F6BYUO5U.js.map → chunk-VHG6AX5V.js.map} +0 -0
  310. /package/dist/{chunk-PXF5J24T.js.map → chunk-XQ2B74SI.js.map} +0 -0
  311. /package/dist/{chunk-LLWBPPZ4.js.map → chunk-YZ2OIYQ3.js.map} +0 -0
@@ -0,0 +1,494 @@
1
+ 'use strict';
2
+
3
+ // src/chat-protocol/frames.ts
4
+ var FRAME_TERMINATOR = "\0";
5
+ var END_OF_LEADING = "";
6
+ var TRAILER_SENTINEL = "";
7
+
8
+ // src/chat-protocol/events.ts
9
+ var CHAT_OWNER_ADMIN = "ADMIN";
10
+
11
+ // src/chat-protocol/encode.ts
12
+ var encoder = new TextEncoder();
13
+ var SENTINEL_BYTES_RE = /[\u0000\u001E\u001F]/g;
14
+ function stripSentinelBytes(text) {
15
+ return text.replace(SENTINEL_BYTES_RE, "");
16
+ }
17
+ function encodeLeadingFrame(frame) {
18
+ return encoder.encode(JSON.stringify(frame) + FRAME_TERMINATOR);
19
+ }
20
+ function encodeEndOfLeading() {
21
+ return encoder.encode(END_OF_LEADING);
22
+ }
23
+ function encodeTextDelta(text) {
24
+ return encoder.encode(stripSentinelBytes(text));
25
+ }
26
+ function encodeTrailingUsageFrame(frame) {
27
+ return encoder.encode(TRAILER_SENTINEL + JSON.stringify(frame));
28
+ }
29
+
30
+ // src/chat-protocol/decode.ts
31
+ function escapeThinkingTags(text) {
32
+ return text.replace(/</g, "&lt;");
33
+ }
34
+ function mapLeadingFrame(meta, out) {
35
+ if (meta.status === "thinking") {
36
+ out.push({ type: "status", phase: "thinking" });
37
+ } else if (meta.kind === "thinking-delta" && typeof meta.text === "string") {
38
+ out.push({ type: "thinking-delta", text: meta.text });
39
+ } else if (meta.kind === "usage" && meta.stage === "start") {
40
+ out.push({
41
+ type: "usage",
42
+ stage: "start",
43
+ input_tokens: meta.input_tokens,
44
+ cache_read_input_tokens: meta.cache_read_input_tokens,
45
+ cache_creation_input_tokens: meta.cache_creation_input_tokens
46
+ });
47
+ } else if (meta.kind === "decision_resolved" && typeof meta.action === "string") {
48
+ const status = meta.action === "rejected" ? "rejected" : "approved";
49
+ const toolName = typeof meta.tool_name === "string" ? meta.tool_name : void 0;
50
+ const result = meta.result ?? null;
51
+ const card = meta.card ?? null;
52
+ out.push({
53
+ type: "approval-resolved",
54
+ status,
55
+ ok: meta.ok === true,
56
+ willAutoContinue: meta.willAutoContinue === true,
57
+ ...toolName ? { toolName } : {},
58
+ ...result ? { result } : {},
59
+ ...card?.marker ? { marker: card.marker } : {},
60
+ ...card?.ref ? { cardRef: card.ref } : {},
61
+ ...card?.type ? { cardType: card.type } : {},
62
+ ...typeof meta.receiptText === "string" ? { receiptText: meta.receiptText } : {},
63
+ requestId: typeof meta.proposalId === "string" ? meta.proposalId : void 0
64
+ });
65
+ } else if (meta.kind === "approval_request" && meta.proposalId) {
66
+ const proposalId = String(meta.proposalId);
67
+ const toolName = String(meta.toolName ?? "tool");
68
+ const headline = typeof meta.title === "string" && meta.title.length > 0 ? meta.title : toolName;
69
+ const rawFields = Array.isArray(meta.fields) ? meta.fields : [];
70
+ const fields = [];
71
+ for (const f of rawFields) {
72
+ if (!f || !f.label || !f.value) continue;
73
+ fields.push({ label: f.label, value: f.value });
74
+ }
75
+ out.push({
76
+ type: "approval-request",
77
+ requestId: proposalId,
78
+ approvalType: toolName,
79
+ command: headline,
80
+ fields,
81
+ status: "pending"
82
+ });
83
+ } else if (meta.kind === "text-leading" && typeof meta.text === "string") {
84
+ out.push({ type: "text-delta", text: meta.text, leading: true });
85
+ } else if (meta.kind === "tool_error") {
86
+ const msg = typeof meta.message === "string" && meta.message.length > 0 ? meta.message : "Could not complete the requested action right now.";
87
+ out.push({ type: "error", title: msg });
88
+ } else if (meta.kind === "routing") {
89
+ if (typeof meta.routedComplexity === "string") {
90
+ out.push({
91
+ type: "metadata",
92
+ routing: {
93
+ routedComplexity: meta.routedComplexity,
94
+ ...typeof meta.routedModel === "string" ? { routedModel: meta.routedModel } : {},
95
+ routedThinkingBudget: typeof meta.routedThinkingBudget === "number" ? meta.routedThinkingBudget : null
96
+ }
97
+ });
98
+ }
99
+ } else {
100
+ out.push({
101
+ type: "metadata",
102
+ sources: meta.sources,
103
+ refs: meta.refs,
104
+ provider: meta.provider,
105
+ modelLabel: meta.modelLabel,
106
+ modelName: meta.model,
107
+ contextWindowMaxTokens: meta.contextWindowMaxTokens,
108
+ scrollAnchor: meta.scrollAnchor,
109
+ conversationId: meta.conversationId
110
+ });
111
+ }
112
+ }
113
+ function createSseFrameDecoder() {
114
+ const textDecoder = new TextDecoder();
115
+ let buffer = "";
116
+ let inText = false;
117
+ let inTrailer = false;
118
+ let trailerBuffer = "";
119
+ let ended = false;
120
+ function push(bytes) {
121
+ const out = [];
122
+ const chunk = textDecoder.decode(bytes, { stream: true });
123
+ if (!inText) {
124
+ buffer += chunk;
125
+ while (!inText) {
126
+ const recIdx = buffer.indexOf(END_OF_LEADING);
127
+ const nullIdx = buffer.indexOf(FRAME_TERMINATOR);
128
+ if (recIdx !== -1 && (nullIdx === -1 || recIdx < nullIdx)) {
129
+ inText = true;
130
+ out.push({ type: "turn-start" });
131
+ const after = buffer.slice(recIdx + 1);
132
+ buffer = "";
133
+ if (after) {
134
+ const unitIdx = after.indexOf(TRAILER_SENTINEL);
135
+ if (unitIdx === -1) {
136
+ out.push({ type: "text-delta", text: after });
137
+ } else {
138
+ const textBefore = after.slice(0, unitIdx);
139
+ const trailerAfter = after.slice(unitIdx + 1);
140
+ if (textBefore) {
141
+ out.push({ type: "text-delta", text: textBefore });
142
+ }
143
+ inTrailer = true;
144
+ trailerBuffer = trailerAfter;
145
+ }
146
+ }
147
+ break;
148
+ }
149
+ if (nullIdx === -1) break;
150
+ const metaStr = buffer.slice(0, nullIdx);
151
+ const remaining = buffer.slice(nullIdx + 1);
152
+ let meta;
153
+ try {
154
+ meta = JSON.parse(metaStr);
155
+ } catch {
156
+ inText = true;
157
+ out.push({ type: "turn-start", implicit: true });
158
+ if (buffer.length > 0) {
159
+ out.push({ type: "text-delta", text: buffer });
160
+ buffer = "";
161
+ }
162
+ break;
163
+ }
164
+ mapLeadingFrame(meta, out);
165
+ buffer = remaining;
166
+ }
167
+ } else if (inTrailer) {
168
+ trailerBuffer += chunk;
169
+ } else {
170
+ const sepIdx = chunk.indexOf(TRAILER_SENTINEL);
171
+ if (sepIdx === -1) {
172
+ out.push({ type: "text-delta", text: chunk });
173
+ } else {
174
+ const before = chunk.slice(0, sepIdx);
175
+ const after = chunk.slice(sepIdx + 1);
176
+ if (before) out.push({ type: "text-delta", text: before });
177
+ inTrailer = true;
178
+ trailerBuffer = after;
179
+ }
180
+ }
181
+ return out;
182
+ }
183
+ function end() {
184
+ if (ended) return [];
185
+ ended = true;
186
+ const out = [];
187
+ if (trailerBuffer.length > 0) {
188
+ const raw = trailerBuffer;
189
+ trailerBuffer = "";
190
+ try {
191
+ const meta = JSON.parse(raw);
192
+ if (meta.kind === "usage" && (meta.stage === "end" || meta.stage === "display")) {
193
+ out.push({
194
+ type: "usage",
195
+ stage: "end",
196
+ input_tokens: meta.input_tokens,
197
+ output_tokens: meta.output_tokens,
198
+ cache_read_input_tokens: meta.cache_read_input_tokens,
199
+ cache_creation_input_tokens: meta.cache_creation_input_tokens,
200
+ hit_rate_pct: meta.hit_rate_pct,
201
+ telemetry: meta.telemetry,
202
+ breakdown: meta.breakdown,
203
+ debug: meta.debug
204
+ });
205
+ }
206
+ } catch {
207
+ }
208
+ }
209
+ return out;
210
+ }
211
+ return { push, end };
212
+ }
213
+
214
+ // src/components/chat/types/message.types.ts
215
+ var MESSAGE_TYPE = {
216
+ TEXT: "TEXT",
217
+ THINKING: "THINKING",
218
+ EXECUTING_TOOL: "EXECUTING_TOOL",
219
+ EXECUTED_TOOL: "EXECUTED_TOOL",
220
+ APPROVAL_REQUEST: "APPROVAL_REQUEST",
221
+ APPROVAL_RESULT: "APPROVAL_RESULT",
222
+ ERROR: "ERROR",
223
+ MESSAGE_START: "MESSAGE_START",
224
+ MESSAGE_END: "MESSAGE_END",
225
+ MESSAGE_REQUEST: "MESSAGE_REQUEST",
226
+ AI_METADATA: "AI_METADATA",
227
+ TOKEN_USAGE: "TOKEN_USAGE",
228
+ CONTEXT_COMPACTION_START: "CONTEXT_COMPACTION_START",
229
+ CONTEXT_COMPACTION_END: "CONTEXT_COMPACTION_END",
230
+ DIRECT_MESSAGE: "DIRECT_MESSAGE",
231
+ SYSTEM: "SYSTEM",
232
+ DIALOG_CLOSED: "DIALOG_CLOSED"
233
+ };
234
+
235
+ // src/chat-protocol/nats-decoder.ts
236
+ function normalizeToolCalls(raw) {
237
+ if (!Array.isArray(raw)) return [];
238
+ return raw.filter((item) => !!item && typeof item === "object").map((item) => ({
239
+ toolExecutionRequestId: String(item.toolExecutionRequestId ?? ""),
240
+ toolName: String(item.toolName ?? ""),
241
+ toolTitle: typeof item.toolTitle === "string" ? item.toolTitle : void 0,
242
+ toolExplanation: typeof item.toolExplanation === "string" ? item.toolExplanation : void 0,
243
+ toolType: typeof item.toolType === "string" ? item.toolType : void 0,
244
+ requiresApproval: item.requiresApproval === true,
245
+ approvalType: typeof item.approvalType === "string" ? item.approvalType : null,
246
+ toolCallArguments: item.toolCallArguments && typeof item.toolCallArguments === "object" ? item.toolCallArguments : null
247
+ }));
248
+ }
249
+ function decodeNatsChunk(chunk) {
250
+ if (!chunk || typeof chunk !== "object") return null;
251
+ const data = chunk;
252
+ const type = String(data.type || "");
253
+ const seq = typeof data.streamSeq === "number" ? { seq: data.streamSeq } : {};
254
+ switch (type) {
255
+ case MESSAGE_TYPE.MESSAGE_START:
256
+ return { type: "turn-start", ...seq };
257
+ case MESSAGE_TYPE.MESSAGE_END:
258
+ return { type: "turn-end", ...seq };
259
+ case MESSAGE_TYPE.AI_METADATA: {
260
+ const providerName = data.providerName || data.provider;
261
+ if (typeof data.modelName === "string" && typeof providerName === "string") {
262
+ return {
263
+ type: "metadata",
264
+ modelLabel: data.modelDisplayName,
265
+ modelName: data.modelName,
266
+ provider: providerName,
267
+ contextWindowMaxTokens: typeof data.contextWindow === "number" ? data.contextWindow : 0,
268
+ ...seq
269
+ };
270
+ }
271
+ return null;
272
+ }
273
+ case MESSAGE_TYPE.TEXT:
274
+ if (typeof data.text === "string") {
275
+ return { type: "text-delta", text: data.text, ...seq };
276
+ }
277
+ return null;
278
+ case MESSAGE_TYPE.THINKING:
279
+ if (typeof data.text === "string") {
280
+ return { type: "thinking-delta", text: data.text, ...seq };
281
+ }
282
+ return null;
283
+ case MESSAGE_TYPE.EXECUTING_TOOL:
284
+ return {
285
+ type: "tool-execution",
286
+ data: {
287
+ type: "EXECUTING_TOOL",
288
+ integratedToolType: data.integratedToolType || "",
289
+ toolFunction: data.toolFunction || "",
290
+ toolTitle: typeof data.title === "string" ? data.title : void 0,
291
+ parameters: data.parameters,
292
+ toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
293
+ },
294
+ ...seq
295
+ };
296
+ case MESSAGE_TYPE.EXECUTED_TOOL:
297
+ return {
298
+ type: "tool-execution",
299
+ data: {
300
+ type: "EXECUTED_TOOL",
301
+ integratedToolType: data.integratedToolType || "",
302
+ toolFunction: data.toolFunction || "",
303
+ toolTitle: typeof data.title === "string" ? data.title : void 0,
304
+ parameters: data.parameters,
305
+ result: data.result,
306
+ success: data.success,
307
+ toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
308
+ },
309
+ ...seq
310
+ };
311
+ case MESSAGE_TYPE.APPROVAL_REQUEST: {
312
+ const requestId = data.approvalRequestId || data.approval_request_id || "";
313
+ const approvalType = data.approvalType || "USER";
314
+ const toolCalls = normalizeToolCalls(data.toolCalls);
315
+ if (toolCalls.length > 0) {
316
+ return { type: "approval-request", requestId, approvalType, toolCalls, ...seq };
317
+ }
318
+ return {
319
+ type: "approval-request",
320
+ requestId,
321
+ approvalType,
322
+ command: data.command || "",
323
+ explanation: data.explanation,
324
+ ...seq
325
+ };
326
+ }
327
+ case MESSAGE_TYPE.APPROVAL_RESULT: {
328
+ const resolvedByName = typeof data.resolvedByName === "string" ? data.resolvedByName : typeof data.displayName === "string" ? data.displayName : void 0;
329
+ return {
330
+ type: "approval-resolved",
331
+ requestId: data.approvalRequestId || data.approval_request_id || "",
332
+ status: data.approved === true ? "approved" : "rejected",
333
+ approvalType: data.approvalType || "CLIENT",
334
+ resolvedByName,
335
+ ...seq
336
+ };
337
+ }
338
+ case MESSAGE_TYPE.ERROR:
339
+ return {
340
+ type: "error",
341
+ title: data.error || "An error occurred",
342
+ details: data.details,
343
+ ...seq
344
+ };
345
+ case MESSAGE_TYPE.MESSAGE_REQUEST:
346
+ return {
347
+ type: "participant",
348
+ kind: "message-request",
349
+ text: String(data.text || ""),
350
+ ownerType: typeof data.ownerType === "string" ? data.ownerType : void 0,
351
+ displayName: typeof data.displayName === "string" ? data.displayName : void 0,
352
+ userId: typeof data.userId === "string" ? data.userId : void 0,
353
+ // Wire shape carries no label; fall back to the id (parity with
354
+ // the history path in `process-historical-messages.ts`).
355
+ contextItems: Array.isArray(data.contextItems) ? data.contextItems.filter((it) => typeof it?.type === "string" && typeof it?.id === "string").map((it) => ({
356
+ type: it.type,
357
+ id: it.id,
358
+ label: it.id
359
+ })) : void 0,
360
+ ...seq
361
+ };
362
+ case MESSAGE_TYPE.TOKEN_USAGE:
363
+ return {
364
+ type: "token-usage",
365
+ inputTokensSize: data.inputTokensSize ?? 0,
366
+ outputTokensSize: data.outputTokensSize ?? 0,
367
+ totalTokensSize: data.totalTokensSize ?? 0,
368
+ contextSize: data.contextSize ?? 0,
369
+ ...seq
370
+ };
371
+ case MESSAGE_TYPE.CONTEXT_COMPACTION_START:
372
+ return { type: "compaction", phase: "start", ...seq };
373
+ case MESSAGE_TYPE.CONTEXT_COMPACTION_END:
374
+ return {
375
+ type: "compaction",
376
+ phase: "end",
377
+ summary: typeof data.text === "string" ? data.text : void 0,
378
+ ...seq
379
+ };
380
+ case MESSAGE_TYPE.SYSTEM:
381
+ if (typeof data.text === "string") {
382
+ return { type: "participant", kind: "system", text: data.text, ...seq };
383
+ }
384
+ return null;
385
+ case MESSAGE_TYPE.DIRECT_MESSAGE:
386
+ if (typeof data.text === "string") {
387
+ return {
388
+ type: "participant",
389
+ kind: "direct-message",
390
+ text: data.text,
391
+ ownerType: typeof data.ownerType === "string" ? data.ownerType : void 0,
392
+ displayName: typeof data.displayName === "string" ? data.displayName : void 0,
393
+ userId: typeof data.userId === "string" ? data.userId : void 0,
394
+ ...seq
395
+ };
396
+ }
397
+ return null;
398
+ case MESSAGE_TYPE.DIALOG_CLOSED:
399
+ return { type: "dialog-closed", ...seq };
400
+ default:
401
+ return null;
402
+ }
403
+ }
404
+
405
+ // src/chat-protocol/ip-normalize.ts
406
+ var IP_BUCKET_KEY_MAX_LENGTH = 64;
407
+ function isIpv4(value) {
408
+ const parts = value.split(".");
409
+ if (parts.length !== 4) return false;
410
+ for (const part of parts) {
411
+ if (!/^\d{1,3}$/.test(part)) return false;
412
+ if (part.length > 1 && part.startsWith("0")) return false;
413
+ if (Number(part) > 255) return false;
414
+ }
415
+ return true;
416
+ }
417
+ function isIpv6(value) {
418
+ if (!value.includes(":")) return false;
419
+ if (!/^[0-9a-f:.]+$/.test(value)) return false;
420
+ if (value.includes(":::")) return false;
421
+ if (value.endsWith(":") && !value.endsWith("::")) return false;
422
+ if (value.startsWith(":") && !value.startsWith("::")) return false;
423
+ const compressions = value.split("::").length - 1;
424
+ if (compressions > 1) return false;
425
+ const groups = value.split(":");
426
+ if (groups.length > 8) return false;
427
+ for (let i = 0; i < groups.length; i += 1) {
428
+ const group = groups[i];
429
+ if (group === "") continue;
430
+ if (group.includes(".")) {
431
+ if (i !== groups.length - 1) return false;
432
+ if (!isIpv4(group)) return false;
433
+ continue;
434
+ }
435
+ if (!/^[0-9a-f]{1,4}$/.test(group)) return false;
436
+ }
437
+ if (compressions === 0) {
438
+ const embedsIpv4 = groups[groups.length - 1]?.includes(".") ?? false;
439
+ if (groups.length !== (embedsIpv4 ? 7 : 8)) return false;
440
+ }
441
+ return true;
442
+ }
443
+ function normalizeIpForBucketKey(value) {
444
+ if (typeof value !== "string") return null;
445
+ let candidate = value.trim();
446
+ if (candidate === "" || candidate.length > IP_BUCKET_KEY_MAX_LENGTH) return null;
447
+ if (candidate.startsWith("[")) {
448
+ const close = candidate.indexOf("]");
449
+ if (close === -1) return null;
450
+ const trailer = candidate.slice(close + 1);
451
+ if (trailer !== "" && !/^:\d{1,5}$/.test(trailer)) return null;
452
+ candidate = candidate.slice(1, close);
453
+ }
454
+ const zone = candidate.indexOf("%");
455
+ if (zone !== -1) candidate = candidate.slice(0, zone);
456
+ if (candidate === "") return null;
457
+ const portSplit = candidate.lastIndexOf(":");
458
+ if (portSplit > 0 && /^\d{1,5}$/.test(candidate.slice(portSplit + 1))) {
459
+ const head = candidate.slice(0, portSplit);
460
+ if (isIpv4(head)) candidate = head;
461
+ }
462
+ if (isIpv4(candidate)) return candidate;
463
+ const lowered = candidate.toLowerCase();
464
+ const mapped = /^(?:(?:0{1,4}:){5}|::)ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(lowered);
465
+ if (mapped) return isIpv4(mapped[1]) ? mapped[1] : null;
466
+ if (isIpv6(lowered)) return lowered;
467
+ return null;
468
+ }
469
+
470
+ // src/chat-protocol/env-flag.ts
471
+ function envFlagEnabled(name) {
472
+ const raw = process.env[name];
473
+ if (!raw) return false;
474
+ const v = raw.trim().toLowerCase();
475
+ return v !== "" && v !== "0" && v !== "false" && v !== "off";
476
+ }
477
+
478
+ exports.CHAT_OWNER_ADMIN = CHAT_OWNER_ADMIN;
479
+ exports.END_OF_LEADING = END_OF_LEADING;
480
+ exports.FRAME_TERMINATOR = FRAME_TERMINATOR;
481
+ exports.IP_BUCKET_KEY_MAX_LENGTH = IP_BUCKET_KEY_MAX_LENGTH;
482
+ exports.TRAILER_SENTINEL = TRAILER_SENTINEL;
483
+ exports.createSseFrameDecoder = createSseFrameDecoder;
484
+ exports.decodeNatsChunk = decodeNatsChunk;
485
+ exports.encodeEndOfLeading = encodeEndOfLeading;
486
+ exports.encodeLeadingFrame = encodeLeadingFrame;
487
+ exports.encodeTextDelta = encodeTextDelta;
488
+ exports.encodeTrailingUsageFrame = encodeTrailingUsageFrame;
489
+ exports.envFlagEnabled = envFlagEnabled;
490
+ exports.escapeThinkingTags = escapeThinkingTags;
491
+ exports.normalizeIpForBucketKey = normalizeIpForBucketKey;
492
+ exports.stripSentinelBytes = stripSentinelBytes;
493
+ //# sourceMappingURL=index.cjs.map
494
+ //# sourceMappingURL=index.cjs.map