@flamingo-stack/openframe-frontend-core 0.0.492-1506.3956.1 → 0.0.492

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 (296) hide show
  1. package/dist/{chunk-KX3K2EH4.cjs → chunk-2XAAFAQT.cjs} +11 -11
  2. package/dist/{chunk-KX3K2EH4.cjs.map → chunk-2XAAFAQT.cjs.map} +1 -1
  3. package/dist/{chunk-JHEIOXXZ.js → chunk-4AWRPTKE.js} +5 -6
  4. package/dist/chunk-4AWRPTKE.js.map +1 -0
  5. package/dist/{chunk-PTXZB2KW.js → chunk-4J3CB4KO.js} +2 -2
  6. package/dist/{chunk-7N7YZCHR.cjs → chunk-4MLOMMDX.cjs} +5519 -7555
  7. package/dist/chunk-4MLOMMDX.cjs.map +1 -0
  8. package/dist/{chunk-MEMRQTOI.js → chunk-56J7RLMM.js} +10434 -12470
  9. package/dist/chunk-56J7RLMM.js.map +1 -0
  10. package/dist/{chunk-MEIGDK7M.cjs → chunk-5ICPQAUI.cjs} +60 -60
  11. package/dist/chunk-5ICPQAUI.cjs.map +1 -0
  12. package/dist/{chunk-BEEPU44B.js → chunk-5RHJVPL7.js} +10 -10
  13. package/dist/chunk-5RHJVPL7.js.map +1 -0
  14. package/dist/{chunk-XOFE2RT4.js → chunk-BTIRYGDT.js} +4 -4
  15. package/dist/{chunk-JSEJ5MH5.cjs → chunk-DY6AJNVK.cjs} +5 -5
  16. package/dist/{chunk-JSEJ5MH5.cjs.map → chunk-DY6AJNVK.cjs.map} +1 -1
  17. package/dist/{chunk-PLB6CQSO.js → chunk-FG5ALORQ.js} +2 -2
  18. package/dist/{chunk-QG2EBIH5.cjs → chunk-J2J36PEN.cjs} +31 -31
  19. package/dist/{chunk-QG2EBIH5.cjs.map → chunk-J2J36PEN.cjs.map} +1 -1
  20. package/dist/{chunk-A6FPYAUD.cjs → chunk-LIRXKEOE.cjs} +15 -15
  21. package/dist/{chunk-A6FPYAUD.cjs.map → chunk-LIRXKEOE.cjs.map} +1 -1
  22. package/dist/{chunk-MSL5NE3N.cjs → chunk-LVDI7R7T.cjs} +37 -37
  23. package/dist/{chunk-MSL5NE3N.cjs.map → chunk-LVDI7R7T.cjs.map} +1 -1
  24. package/dist/{chunk-MPUQFRJG.cjs → chunk-M4SCYPCR.cjs} +7 -7
  25. package/dist/{chunk-MPUQFRJG.cjs.map → chunk-M4SCYPCR.cjs.map} +1 -1
  26. package/dist/{chunk-QDGB2DKY.cjs → chunk-O6S6Q52W.cjs} +26 -26
  27. package/dist/{chunk-QDGB2DKY.cjs.map → chunk-O6S6Q52W.cjs.map} +1 -1
  28. package/dist/{chunk-W56JYDSC.cjs → chunk-OFFYASUY.cjs} +27 -28
  29. package/dist/chunk-OFFYASUY.cjs.map +1 -0
  30. package/dist/{chunk-NCAN6VUF.js → chunk-P3ITKTUE.js} +2 -2
  31. package/dist/{chunk-M6FEGPQJ.cjs → chunk-PI5BMKV3.cjs} +62 -62
  32. package/dist/{chunk-M6FEGPQJ.cjs.map → chunk-PI5BMKV3.cjs.map} +1 -1
  33. package/dist/{chunk-34TDA22K.js → chunk-QHRNQTW5.js} +2 -2
  34. package/dist/{chunk-OL3MJKUI.js → chunk-SZWMJIH3.js} +2 -2
  35. package/dist/{chunk-MZRIRQYV.js → chunk-U5LU56JE.js} +2 -2
  36. package/dist/{chunk-C65NCIMV.cjs → chunk-VML66FJQ.cjs} +9 -9
  37. package/dist/{chunk-C65NCIMV.cjs.map → chunk-VML66FJQ.cjs.map} +1 -1
  38. package/dist/{chunk-3LKB722U.js → chunk-WKWZ7LVC.js} +2 -2
  39. package/dist/{chunk-J3VBVR4W.js → chunk-WPFLV4QJ.js} +4 -4
  40. package/dist/components/case-studies/index.cjs +8 -8
  41. package/dist/components/case-studies/index.js +2 -2
  42. package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
  43. package/dist/components/chat/chat-message-list.d.ts.map +1 -1
  44. package/dist/components/chat/hooks/index.d.ts +1 -0
  45. package/dist/components/chat/hooks/index.d.ts.map +1 -1
  46. package/dist/components/chat/hooks/use-chat.d.ts.map +1 -1
  47. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +48 -15
  48. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
  49. package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts +6 -0
  50. package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts.map +1 -0
  51. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +57 -10
  52. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  53. package/dist/components/chat/index.cjs +2 -10
  54. package/dist/components/chat/index.cjs.map +1 -1
  55. package/dist/components/chat/index.d.ts +0 -1
  56. package/dist/components/chat/index.d.ts.map +1 -1
  57. package/dist/components/chat/index.js +13 -21
  58. package/dist/components/chat/types/api.types.d.ts +81 -1
  59. package/dist/components/chat/types/api.types.d.ts.map +1 -1
  60. package/dist/components/chat/types/processing.types.d.ts +93 -2
  61. package/dist/components/chat/types/processing.types.d.ts.map +1 -1
  62. package/dist/components/chat/utils/chunk-parser.d.ts +25 -0
  63. package/dist/components/chat/utils/chunk-parser.d.ts.map +1 -0
  64. package/dist/components/chat/utils/extract-incomplete-message-state.d.ts +6 -34
  65. package/dist/components/chat/utils/extract-incomplete-message-state.d.ts.map +1 -1
  66. package/dist/components/chat/utils/index.d.ts +3 -2
  67. package/dist/components/chat/utils/index.d.ts.map +1 -1
  68. package/dist/components/chat/utils/process-historical-messages.d.ts +11 -59
  69. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  70. package/dist/components/contact/index.cjs +3 -3
  71. package/dist/components/contact/index.js +2 -2
  72. package/dist/components/docs/index.cjs +5 -5
  73. package/dist/components/docs/index.js +4 -4
  74. package/dist/components/embeds/index.cjs +3 -3
  75. package/dist/components/embeds/index.js +2 -2
  76. package/dist/components/faq/index.cjs +3 -3
  77. package/dist/components/faq/index.js +2 -2
  78. package/dist/components/features/floating-walkthrough-video.d.ts.map +1 -1
  79. package/dist/components/features/index.cjs +2 -2
  80. package/dist/components/features/index.js +1 -1
  81. package/dist/components/help-center-pages/index.cjs +20 -20
  82. package/dist/components/help-center-pages/index.js +11 -11
  83. package/dist/components/index.cjs +130 -172
  84. package/dist/components/index.cjs.map +1 -1
  85. package/dist/components/index.js +21 -63
  86. package/dist/components/index.js.map +1 -1
  87. package/dist/components/navigation/index.cjs +2 -2
  88. package/dist/components/navigation/index.js +1 -1
  89. package/dist/components/navigation/navigation-sidebar-item.d.ts +23 -1
  90. package/dist/components/navigation/navigation-sidebar-item.d.ts.map +1 -1
  91. package/dist/components/navigation/navigation-sidebar.d.ts.map +1 -1
  92. package/dist/components/onboarding-guides/index.cjs +5 -5
  93. package/dist/components/onboarding-guides/index.js +4 -4
  94. package/dist/components/onboarding-guides/onboarding-guide-detail-view.d.ts.map +1 -1
  95. package/dist/components/related-content/index.cjs +3 -3
  96. package/dist/components/related-content/index.js +2 -2
  97. package/dist/components/shared/product-release/release-detail-page.d.ts.map +1 -1
  98. package/dist/components/tickets/index.cjs +5 -5
  99. package/dist/components/tickets/index.js +4 -4
  100. package/dist/components/ui/data-table/data-table-column-filter.d.ts.map +1 -1
  101. package/dist/components/ui/data-table/data-table-header.d.ts.map +1 -1
  102. package/dist/components/ui/data-table/data-table-skeleton.d.ts.map +1 -1
  103. package/dist/components/ui/index.cjs +2 -44
  104. package/dist/components/ui/index.cjs.map +1 -1
  105. package/dist/components/ui/index.d.ts +2 -1
  106. package/dist/components/ui/index.d.ts.map +1 -1
  107. package/dist/components/ui/index.js +13 -55
  108. package/dist/components/ui/rich-markdown-renderer.d.ts +34 -0
  109. package/dist/components/ui/rich-markdown-renderer.d.ts.map +1 -0
  110. package/dist/components/ui/simple-markdown-renderer.d.ts +73 -0
  111. package/dist/components/ui/simple-markdown-renderer.d.ts.map +1 -0
  112. package/dist/components/ui/tab-navigation.d.ts.map +1 -1
  113. package/dist/index.cjs +2 -60
  114. package/dist/index.cjs.map +1 -1
  115. package/dist/index.js +13 -71
  116. package/dist/utils/index.cjs +40 -169
  117. package/dist/utils/index.cjs.map +1 -1
  118. package/dist/utils/index.d.ts +0 -1
  119. package/dist/utils/index.d.ts.map +1 -1
  120. package/dist/utils/index.js +41 -162
  121. package/dist/utils/index.js.map +1 -1
  122. package/dist/utils/markdown-section-extractor.d.ts.map +1 -1
  123. package/package.json +1 -7
  124. package/src/components/chat/__tests__/chat-message-list.test.tsx +5 -293
  125. package/src/components/chat/chat-message-enhanced.tsx +20 -122
  126. package/src/components/chat/chat-message-list.tsx +109 -358
  127. package/src/components/chat/embeddable-chat.tsx +0 -6
  128. package/src/components/chat/hooks/.index.md +33 -30
  129. package/src/components/chat/hooks/.use-nats-chat-adapter.md +55 -36
  130. package/src/components/chat/hooks/.use-realtime-chunk-processor.md +77 -0
  131. package/src/components/chat/hooks/index.ts +1 -0
  132. package/src/components/chat/hooks/use-chat.ts +0 -8
  133. package/src/components/chat/hooks/use-nats-chat-adapter.ts +825 -243
  134. package/src/components/chat/hooks/use-realtime-chunk-processor.ts +489 -0
  135. package/src/components/chat/hooks/use-sse-chat-adapter.ts +684 -380
  136. package/src/components/chat/index.ts +0 -5
  137. package/src/components/chat/thinking-display.tsx +1 -1
  138. package/src/components/chat/types/.api.types.md +49 -39
  139. package/src/components/chat/types/.processing.types.md +58 -29
  140. package/src/components/chat/types/api.types.ts +73 -6
  141. package/src/components/chat/types/processing.types.ts +53 -11
  142. package/src/components/chat/utils/.chunk-parser.md +62 -0
  143. package/src/components/chat/utils/.index.md +40 -31
  144. package/src/components/chat/utils/chunk-parser.ts +262 -0
  145. package/src/components/chat/utils/extract-incomplete-message-state.ts +5 -63
  146. package/src/components/chat/utils/index.ts +8 -5
  147. package/src/components/chat/utils/process-historical-messages.ts +386 -358
  148. package/src/components/features/floating-walkthrough-video.tsx +3 -1
  149. package/src/components/navigation/navigation-sidebar-item.tsx +80 -30
  150. package/src/components/navigation/navigation-sidebar.tsx +106 -46
  151. package/src/components/onboarding-guides/onboarding-guide-detail-view.tsx +4 -22
  152. package/src/components/shared/legal-document/legal-document-page.tsx +1 -1
  153. package/src/components/shared/product-release/release-detail-page.tsx +4 -19
  154. package/src/components/ui/.simple-markdown-renderer.md +52 -0
  155. package/src/components/ui/__tests__/tab-navigation.test.tsx +159 -0
  156. package/src/components/ui/data-table/data-table-column-filter.tsx +7 -1
  157. package/src/components/ui/data-table/data-table-header.tsx +4 -1
  158. package/src/components/ui/data-table/data-table-skeleton.tsx +7 -0
  159. package/src/components/ui/index.ts +2 -1
  160. package/src/components/ui/release-changelog-section.tsx +1 -1
  161. package/src/components/ui/rich-markdown-renderer.tsx +1223 -0
  162. package/src/components/ui/simple-markdown-renderer.tsx +964 -0
  163. package/src/components/ui/tab-navigation.tsx +370 -171
  164. package/src/components/ui/ticket-info-section.tsx +1 -1
  165. package/src/utils/index.ts +0 -1
  166. package/src/utils/markdown-section-extractor.ts +56 -41
  167. package/dist/chat-protocol/decode.d.ts +0 -58
  168. package/dist/chat-protocol/decode.d.ts.map +0 -1
  169. package/dist/chat-protocol/encode.d.ts +0 -44
  170. package/dist/chat-protocol/encode.d.ts.map +0 -1
  171. package/dist/chat-protocol/env-flag.d.ts +0 -35
  172. package/dist/chat-protocol/env-flag.d.ts.map +0 -1
  173. package/dist/chat-protocol/events.d.ts +0 -207
  174. package/dist/chat-protocol/events.d.ts.map +0 -1
  175. package/dist/chat-protocol/frames.d.ts +0 -213
  176. package/dist/chat-protocol/frames.d.ts.map +0 -1
  177. package/dist/chat-protocol/index.cjs +0 -500
  178. package/dist/chat-protocol/index.cjs.map +0 -1
  179. package/dist/chat-protocol/index.d.ts +0 -18
  180. package/dist/chat-protocol/index.d.ts.map +0 -1
  181. package/dist/chat-protocol/index.js +0 -484
  182. package/dist/chat-protocol/index.js.map +0 -1
  183. package/dist/chat-protocol/ip-normalize.d.ts +0 -44
  184. package/dist/chat-protocol/ip-normalize.d.ts.map +0 -1
  185. package/dist/chat-protocol/nats-decoder.d.ts +0 -26
  186. package/dist/chat-protocol/nats-decoder.d.ts.map +0 -1
  187. package/dist/chunk-7N7YZCHR.cjs.map +0 -1
  188. package/dist/chunk-BEEPU44B.js.map +0 -1
  189. package/dist/chunk-JHEIOXXZ.js.map +0 -1
  190. package/dist/chunk-MEIGDK7M.cjs.map +0 -1
  191. package/dist/chunk-MEMRQTOI.js.map +0 -1
  192. package/dist/chunk-W56JYDSC.cjs.map +0 -1
  193. package/dist/components/chat/stream/chat-dialog-store.d.ts +0 -184
  194. package/dist/components/chat/stream/chat-dialog-store.d.ts.map +0 -1
  195. package/dist/components/chat/stream/chat-stream-reducer.d.ts +0 -367
  196. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +0 -1
  197. package/dist/components/chat/stream/delta-batcher.d.ts +0 -51
  198. package/dist/components/chat/stream/delta-batcher.d.ts.map +0 -1
  199. package/dist/components/chat/stream/index.d.ts +0 -17
  200. package/dist/components/chat/stream/index.d.ts.map +0 -1
  201. package/dist/components/chat/stream/message-mutations.d.ts +0 -77
  202. package/dist/components/chat/stream/message-mutations.d.ts.map +0 -1
  203. package/dist/components/chat/stream/use-chat-stream-reducer.d.ts +0 -22
  204. package/dist/components/chat/stream/use-chat-stream-reducer.d.ts.map +0 -1
  205. package/dist/components/ui/markdown/base-components.d.ts +0 -51
  206. package/dist/components/ui/markdown/base-components.d.ts.map +0 -1
  207. package/dist/components/ui/markdown/engine.d.ts +0 -99
  208. package/dist/components/ui/markdown/engine.d.ts.map +0 -1
  209. package/dist/components/ui/markdown/heading-ids.d.ts +0 -65
  210. package/dist/components/ui/markdown/heading-ids.d.ts.map +0 -1
  211. package/dist/components/ui/markdown/index.d.ts +0 -18
  212. package/dist/components/ui/markdown/index.d.ts.map +0 -1
  213. package/dist/components/ui/markdown/mermaid-diagram.d.ts +0 -79
  214. package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +0 -1
  215. package/dist/components/ui/markdown/rich/embed-overrides.d.ts +0 -14
  216. package/dist/components/ui/markdown/rich/embed-overrides.d.ts.map +0 -1
  217. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +0 -40
  218. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +0 -1
  219. package/dist/components/ui/markdown/rich/shortcodes.d.ts +0 -8
  220. package/dist/components/ui/markdown/rich/shortcodes.d.ts.map +0 -1
  221. package/dist/components/ui/markdown/sanitize.d.ts +0 -153
  222. package/dist/components/ui/markdown/sanitize.d.ts.map +0 -1
  223. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +0 -23
  224. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +0 -1
  225. package/dist/components/ui/markdown/streaming.d.ts +0 -78
  226. package/dist/components/ui/markdown/streaming.d.ts.map +0 -1
  227. package/dist/components/ui/markdown/text-size.d.ts +0 -34
  228. package/dist/components/ui/markdown/text-size.d.ts.map +0 -1
  229. package/dist/utils/markdown-fences.d.ts +0 -42
  230. package/dist/utils/markdown-fences.d.ts.map +0 -1
  231. package/dist/utils/markdown-heading-id.d.ts +0 -85
  232. package/dist/utils/markdown-heading-id.d.ts.map +0 -1
  233. package/src/chat-protocol/__tests__/__snapshots__/nats-decoder-golden.test.ts.snap +0 -317
  234. package/src/chat-protocol/__tests__/chat-protocol.test.ts +0 -516
  235. package/src/chat-protocol/__tests__/env-flag.test.ts +0 -52
  236. package/src/chat-protocol/__tests__/ip-normalize.test.ts +0 -136
  237. package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +0 -232
  238. package/src/chat-protocol/decode.ts +0 -278
  239. package/src/chat-protocol/encode.ts +0 -71
  240. package/src/chat-protocol/env-flag.ts +0 -39
  241. package/src/chat-protocol/events.ts +0 -245
  242. package/src/chat-protocol/frames.ts +0 -245
  243. package/src/chat-protocol/index.ts +0 -21
  244. package/src/chat-protocol/ip-normalize.ts +0 -146
  245. package/src/chat-protocol/nats-decoder.ts +0 -258
  246. package/src/components/chat/__tests__/chat-message-streaming-memo.test.tsx +0 -207
  247. package/src/components/chat/__tests__/chat-pending-turn.test.tsx +0 -230
  248. package/src/components/chat/hooks/__tests__/__snapshots__/conversation-id-persistence-golden.test.ts.snap +0 -37
  249. package/src/components/chat/hooks/__tests__/__snapshots__/sse-stream-golden.test.ts.snap +0 -0
  250. package/src/components/chat/hooks/__tests__/conversation-id-persistence-golden.test.ts +0 -438
  251. package/src/components/chat/hooks/__tests__/sse-stream-golden.test.ts +0 -318
  252. package/src/components/chat/stream/__tests__/__snapshots__/chat-stream-reducer-golden.test.ts.snap +0 -940
  253. package/src/components/chat/stream/__tests__/chat-dialog-store.test.ts +0 -756
  254. package/src/components/chat/stream/__tests__/chat-stream-reducer-golden.test.ts +0 -460
  255. package/src/components/chat/stream/__tests__/chat-stream-reducer.test.ts +0 -973
  256. package/src/components/chat/stream/__tests__/delta-batcher.test.ts +0 -255
  257. package/src/components/chat/stream/__tests__/use-chat-stream-reducer.test.ts +0 -98
  258. package/src/components/chat/stream/chat-dialog-store.ts +0 -536
  259. package/src/components/chat/stream/chat-stream-reducer.ts +0 -1808
  260. package/src/components/chat/stream/delta-batcher.ts +0 -168
  261. package/src/components/chat/stream/index.ts +0 -55
  262. package/src/components/chat/stream/message-mutations.ts +0 -340
  263. package/src/components/chat/stream/use-chat-stream-reducer.ts +0 -126
  264. package/src/components/chat/utils/__tests__/__snapshots__/process-historical-messages-golden.test.ts.snap +0 -420
  265. package/src/components/chat/utils/__tests__/__snapshots__/segment-accumulator-golden.test.ts.snap +0 -605
  266. package/src/components/chat/utils/__tests__/process-historical-messages-golden.test.ts +0 -394
  267. package/src/components/chat/utils/__tests__/segment-accumulator-golden.test.ts +0 -270
  268. package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +0 -2420
  269. package/src/components/ui/__tests__/markdown-parity.test.tsx +0 -2528
  270. package/src/components/ui/markdown/__tests__/mermaid-security.test.ts +0 -115
  271. package/src/components/ui/markdown/__tests__/mermaid-stale-render.test.tsx +0 -95
  272. package/src/components/ui/markdown/__tests__/sanitize-invariant.test.ts +0 -309
  273. package/src/components/ui/markdown/__tests__/streaming.test.tsx +0 -388
  274. package/src/components/ui/markdown/base-components.tsx +0 -360
  275. package/src/components/ui/markdown/engine.tsx +0 -315
  276. package/src/components/ui/markdown/heading-ids.ts +0 -239
  277. package/src/components/ui/markdown/index.ts +0 -49
  278. package/src/components/ui/markdown/mermaid-diagram.tsx +0 -291
  279. package/src/components/ui/markdown/rich/embed-overrides.tsx +0 -199
  280. package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +0 -184
  281. package/src/components/ui/markdown/rich/shortcodes.ts +0 -170
  282. package/src/components/ui/markdown/sanitize.ts +0 -3499
  283. package/src/components/ui/markdown/simple-markdown-renderer.tsx +0 -28
  284. package/src/components/ui/markdown/streaming.ts +0 -362
  285. package/src/components/ui/markdown/text-size.ts +0 -106
  286. package/src/utils/markdown-fences.ts +0 -127
  287. package/src/utils/markdown-heading-id.ts +0 -348
  288. /package/dist/{chunk-PTXZB2KW.js.map → chunk-4J3CB4KO.js.map} +0 -0
  289. /package/dist/{chunk-XOFE2RT4.js.map → chunk-BTIRYGDT.js.map} +0 -0
  290. /package/dist/{chunk-PLB6CQSO.js.map → chunk-FG5ALORQ.js.map} +0 -0
  291. /package/dist/{chunk-NCAN6VUF.js.map → chunk-P3ITKTUE.js.map} +0 -0
  292. /package/dist/{chunk-34TDA22K.js.map → chunk-QHRNQTW5.js.map} +0 -0
  293. /package/dist/{chunk-OL3MJKUI.js.map → chunk-SZWMJIH3.js.map} +0 -0
  294. /package/dist/{chunk-MZRIRQYV.js.map → chunk-U5LU56JE.js.map} +0 -0
  295. /package/dist/{chunk-3LKB722U.js.map → chunk-WKWZ7LVC.js.map} +0 -0
  296. /package/dist/{chunk-J3VBVR4W.js.map → chunk-WPFLV4QJ.js.map} +0 -0
@@ -1,500 +0,0 @@
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
- GUIDE: "GUIDE",
219
- EXECUTING_TOOL: "EXECUTING_TOOL",
220
- EXECUTED_TOOL: "EXECUTED_TOOL",
221
- APPROVAL_REQUEST: "APPROVAL_REQUEST",
222
- APPROVAL_RESULT: "APPROVAL_RESULT",
223
- ERROR: "ERROR",
224
- MESSAGE_START: "MESSAGE_START",
225
- MESSAGE_END: "MESSAGE_END",
226
- MESSAGE_REQUEST: "MESSAGE_REQUEST",
227
- AI_METADATA: "AI_METADATA",
228
- TOKEN_USAGE: "TOKEN_USAGE",
229
- CONTEXT_COMPACTION_START: "CONTEXT_COMPACTION_START",
230
- CONTEXT_COMPACTION_END: "CONTEXT_COMPACTION_END",
231
- DIRECT_MESSAGE: "DIRECT_MESSAGE",
232
- SYSTEM: "SYSTEM",
233
- DIALOG_CLOSED: "DIALOG_CLOSED"
234
- };
235
-
236
- // src/chat-protocol/nats-decoder.ts
237
- function normalizeToolCalls(raw) {
238
- if (!Array.isArray(raw)) return [];
239
- return raw.filter((item) => !!item && typeof item === "object").map((item) => ({
240
- toolExecutionRequestId: String(item.toolExecutionRequestId ?? ""),
241
- toolName: String(item.toolName ?? ""),
242
- toolTitle: typeof item.toolTitle === "string" ? item.toolTitle : void 0,
243
- toolExplanation: typeof item.toolExplanation === "string" ? item.toolExplanation : void 0,
244
- toolType: typeof item.toolType === "string" ? item.toolType : void 0,
245
- requiresApproval: item.requiresApproval === true,
246
- approvalType: typeof item.approvalType === "string" ? item.approvalType : null,
247
- toolCallArguments: item.toolCallArguments && typeof item.toolCallArguments === "object" ? item.toolCallArguments : null
248
- }));
249
- }
250
- function decodeNatsChunk(chunk) {
251
- if (!chunk || typeof chunk !== "object") return null;
252
- const data = chunk;
253
- const type = String(data.type || "");
254
- const seq = typeof data.streamSeq === "number" ? { seq: data.streamSeq } : {};
255
- switch (type) {
256
- case MESSAGE_TYPE.MESSAGE_START:
257
- return { type: "turn-start", ...seq };
258
- case MESSAGE_TYPE.MESSAGE_END:
259
- return { type: "turn-end", ...seq };
260
- case MESSAGE_TYPE.AI_METADATA: {
261
- const providerName = data.providerName || data.provider;
262
- if (typeof data.modelName === "string" && typeof providerName === "string") {
263
- return {
264
- type: "metadata",
265
- modelLabel: data.modelDisplayName,
266
- modelName: data.modelName,
267
- provider: providerName,
268
- contextWindowMaxTokens: typeof data.contextWindow === "number" ? data.contextWindow : 0,
269
- ...seq
270
- };
271
- }
272
- return null;
273
- }
274
- case MESSAGE_TYPE.TEXT:
275
- if (typeof data.text === "string") {
276
- return { type: "text-delta", text: data.text, ...seq };
277
- }
278
- return null;
279
- case MESSAGE_TYPE.THINKING:
280
- if (typeof data.text === "string") {
281
- return { type: "thinking-delta", text: data.text, ...seq };
282
- }
283
- return null;
284
- case MESSAGE_TYPE.GUIDE:
285
- if (typeof data.text === "string") {
286
- return { type: "guide-delta", text: data.text, ...seq };
287
- }
288
- return null;
289
- case MESSAGE_TYPE.EXECUTING_TOOL:
290
- return {
291
- type: "tool-execution",
292
- data: {
293
- type: "EXECUTING_TOOL",
294
- integratedToolType: data.integratedToolType || "",
295
- toolFunction: data.toolFunction || "",
296
- toolTitle: typeof data.title === "string" ? data.title : void 0,
297
- parameters: data.parameters,
298
- toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
299
- },
300
- ...seq
301
- };
302
- case MESSAGE_TYPE.EXECUTED_TOOL:
303
- return {
304
- type: "tool-execution",
305
- data: {
306
- type: "EXECUTED_TOOL",
307
- integratedToolType: data.integratedToolType || "",
308
- toolFunction: data.toolFunction || "",
309
- toolTitle: typeof data.title === "string" ? data.title : void 0,
310
- parameters: data.parameters,
311
- result: data.result,
312
- success: data.success,
313
- toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
314
- },
315
- ...seq
316
- };
317
- case MESSAGE_TYPE.APPROVAL_REQUEST: {
318
- const requestId = data.approvalRequestId || data.approval_request_id || "";
319
- const approvalType = data.approvalType || "USER";
320
- const toolCalls = normalizeToolCalls(data.toolCalls);
321
- if (toolCalls.length > 0) {
322
- return { type: "approval-request", requestId, approvalType, toolCalls, ...seq };
323
- }
324
- return {
325
- type: "approval-request",
326
- requestId,
327
- approvalType,
328
- command: data.command || "",
329
- explanation: data.explanation,
330
- ...seq
331
- };
332
- }
333
- case MESSAGE_TYPE.APPROVAL_RESULT: {
334
- const resolvedByName = typeof data.resolvedByName === "string" ? data.resolvedByName : typeof data.displayName === "string" ? data.displayName : void 0;
335
- return {
336
- type: "approval-resolved",
337
- requestId: data.approvalRequestId || data.approval_request_id || "",
338
- status: data.approved === true ? "approved" : "rejected",
339
- approvalType: data.approvalType || "CLIENT",
340
- resolvedByName,
341
- ...seq
342
- };
343
- }
344
- case MESSAGE_TYPE.ERROR:
345
- return {
346
- type: "error",
347
- title: data.error || "An error occurred",
348
- details: data.details,
349
- ...seq
350
- };
351
- case MESSAGE_TYPE.MESSAGE_REQUEST:
352
- return {
353
- type: "participant",
354
- kind: "message-request",
355
- text: String(data.text || ""),
356
- ownerType: typeof data.ownerType === "string" ? data.ownerType : void 0,
357
- displayName: typeof data.displayName === "string" ? data.displayName : void 0,
358
- userId: typeof data.userId === "string" ? data.userId : void 0,
359
- // Wire shape carries no label; fall back to the id (parity with
360
- // the history path in `process-historical-messages.ts`).
361
- contextItems: Array.isArray(data.contextItems) ? data.contextItems.filter((it) => typeof it?.type === "string" && typeof it?.id === "string").map((it) => ({
362
- type: it.type,
363
- id: it.id,
364
- label: it.id
365
- })) : void 0,
366
- ...seq
367
- };
368
- case MESSAGE_TYPE.TOKEN_USAGE:
369
- return {
370
- type: "token-usage",
371
- inputTokensSize: data.inputTokensSize ?? 0,
372
- outputTokensSize: data.outputTokensSize ?? 0,
373
- totalTokensSize: data.totalTokensSize ?? 0,
374
- contextSize: data.contextSize ?? 0,
375
- ...seq
376
- };
377
- case MESSAGE_TYPE.CONTEXT_COMPACTION_START:
378
- return { type: "compaction", phase: "start", ...seq };
379
- case MESSAGE_TYPE.CONTEXT_COMPACTION_END:
380
- return {
381
- type: "compaction",
382
- phase: "end",
383
- summary: typeof data.text === "string" ? data.text : void 0,
384
- ...seq
385
- };
386
- case MESSAGE_TYPE.SYSTEM:
387
- if (typeof data.text === "string") {
388
- return { type: "participant", kind: "system", text: data.text, ...seq };
389
- }
390
- return null;
391
- case MESSAGE_TYPE.DIRECT_MESSAGE:
392
- if (typeof data.text === "string") {
393
- return {
394
- type: "participant",
395
- kind: "direct-message",
396
- text: data.text,
397
- ownerType: typeof data.ownerType === "string" ? data.ownerType : void 0,
398
- displayName: typeof data.displayName === "string" ? data.displayName : void 0,
399
- userId: typeof data.userId === "string" ? data.userId : void 0,
400
- ...seq
401
- };
402
- }
403
- return null;
404
- case MESSAGE_TYPE.DIALOG_CLOSED:
405
- return { type: "dialog-closed", ...seq };
406
- default:
407
- return null;
408
- }
409
- }
410
-
411
- // src/chat-protocol/ip-normalize.ts
412
- var IP_BUCKET_KEY_MAX_LENGTH = 64;
413
- function isIpv4(value) {
414
- const parts = value.split(".");
415
- if (parts.length !== 4) return false;
416
- for (const part of parts) {
417
- if (!/^\d{1,3}$/.test(part)) return false;
418
- if (part.length > 1 && part.startsWith("0")) return false;
419
- if (Number(part) > 255) return false;
420
- }
421
- return true;
422
- }
423
- function isIpv6(value) {
424
- if (!value.includes(":")) return false;
425
- if (!/^[0-9a-f:.]+$/.test(value)) return false;
426
- if (value.includes(":::")) return false;
427
- if (value.endsWith(":") && !value.endsWith("::")) return false;
428
- if (value.startsWith(":") && !value.startsWith("::")) return false;
429
- const compressions = value.split("::").length - 1;
430
- if (compressions > 1) return false;
431
- const groups = value.split(":");
432
- if (groups.length > 8) return false;
433
- for (let i = 0; i < groups.length; i += 1) {
434
- const group = groups[i];
435
- if (group === "") continue;
436
- if (group.includes(".")) {
437
- if (i !== groups.length - 1) return false;
438
- if (!isIpv4(group)) return false;
439
- continue;
440
- }
441
- if (!/^[0-9a-f]{1,4}$/.test(group)) return false;
442
- }
443
- if (compressions === 0) {
444
- const embedsIpv4 = groups[groups.length - 1]?.includes(".") ?? false;
445
- if (groups.length !== (embedsIpv4 ? 7 : 8)) return false;
446
- }
447
- return true;
448
- }
449
- function normalizeIpForBucketKey(value) {
450
- if (typeof value !== "string") return null;
451
- let candidate = value.trim();
452
- if (candidate === "" || candidate.length > IP_BUCKET_KEY_MAX_LENGTH) return null;
453
- if (candidate.startsWith("[")) {
454
- const close = candidate.indexOf("]");
455
- if (close === -1) return null;
456
- const trailer = candidate.slice(close + 1);
457
- if (trailer !== "" && !/^:\d{1,5}$/.test(trailer)) return null;
458
- candidate = candidate.slice(1, close);
459
- }
460
- const zone = candidate.indexOf("%");
461
- if (zone !== -1) candidate = candidate.slice(0, zone);
462
- if (candidate === "") return null;
463
- const portSplit = candidate.lastIndexOf(":");
464
- if (portSplit > 0 && /^\d{1,5}$/.test(candidate.slice(portSplit + 1))) {
465
- const head = candidate.slice(0, portSplit);
466
- if (isIpv4(head)) candidate = head;
467
- }
468
- if (isIpv4(candidate)) return candidate;
469
- const lowered = candidate.toLowerCase();
470
- const mapped = /^(?:(?:0{1,4}:){5}|::)ffff:(\d{1,3}(?:\.\d{1,3}){3})$/.exec(lowered);
471
- if (mapped) return isIpv4(mapped[1]) ? mapped[1] : null;
472
- if (isIpv6(lowered)) return lowered;
473
- return null;
474
- }
475
-
476
- // src/chat-protocol/env-flag.ts
477
- function envFlagEnabled(name) {
478
- const raw = process.env[name];
479
- if (!raw) return false;
480
- const v = raw.trim().toLowerCase();
481
- return v !== "" && v !== "0" && v !== "false" && v !== "off";
482
- }
483
-
484
- exports.CHAT_OWNER_ADMIN = CHAT_OWNER_ADMIN;
485
- exports.END_OF_LEADING = END_OF_LEADING;
486
- exports.FRAME_TERMINATOR = FRAME_TERMINATOR;
487
- exports.IP_BUCKET_KEY_MAX_LENGTH = IP_BUCKET_KEY_MAX_LENGTH;
488
- exports.TRAILER_SENTINEL = TRAILER_SENTINEL;
489
- exports.createSseFrameDecoder = createSseFrameDecoder;
490
- exports.decodeNatsChunk = decodeNatsChunk;
491
- exports.encodeEndOfLeading = encodeEndOfLeading;
492
- exports.encodeLeadingFrame = encodeLeadingFrame;
493
- exports.encodeTextDelta = encodeTextDelta;
494
- exports.encodeTrailingUsageFrame = encodeTrailingUsageFrame;
495
- exports.envFlagEnabled = envFlagEnabled;
496
- exports.escapeThinkingTags = escapeThinkingTags;
497
- exports.normalizeIpForBucketKey = normalizeIpForBucketKey;
498
- exports.stripSentinelBytes = stripSentinelBytes;
499
- //# sourceMappingURL=index.cjs.map
500
- //# sourceMappingURL=index.cjs.map