@flamingo-stack/openframe-frontend-core 0.0.490-1506.3944.1 → 0.0.490

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 (293) hide show
  1. package/dist/{chunk-5CJR2GZ4.cjs → chunk-2MKUHJ3O.cjs} +31 -31
  2. package/dist/{chunk-5CJR2GZ4.cjs.map → chunk-2MKUHJ3O.cjs.map} +1 -1
  3. package/dist/{chunk-S2NHJDKQ.cjs → chunk-3IEVA5AO.cjs} +62 -62
  4. package/dist/{chunk-S2NHJDKQ.cjs.map → chunk-3IEVA5AO.cjs.map} +1 -1
  5. package/dist/{chunk-GTWO5NAY.js → chunk-6CFFISUC.js} +2 -2
  6. package/dist/{chunk-VHG6AX5V.js → chunk-6CJ2K7BD.js} +2 -2
  7. package/dist/{chunk-4NWARV5I.js → chunk-6QK3ONDD.js} +2 -2
  8. package/dist/{chunk-YHOIAA2E.cjs → chunk-7I42V2OD.cjs} +60 -60
  9. package/dist/chunk-7I42V2OD.cjs.map +1 -0
  10. package/dist/{chunk-T2EGSZFN.js → chunk-AIRNG27G.js} +5 -6
  11. package/dist/chunk-AIRNG27G.js.map +1 -0
  12. package/dist/{chunk-NWX7MMF5.cjs → chunk-AW63ET2A.cjs} +15 -15
  13. package/dist/{chunk-NWX7MMF5.cjs.map → chunk-AW63ET2A.cjs.map} +1 -1
  14. package/dist/{chunk-TKN5667N.js → chunk-BZMOEWWS.js} +10 -10
  15. package/dist/chunk-BZMOEWWS.js.map +1 -0
  16. package/dist/{chunk-DSDZ5T4P.cjs → chunk-D5LQMRPU.cjs} +5 -5
  17. package/dist/{chunk-DSDZ5T4P.cjs.map → chunk-D5LQMRPU.cjs.map} +1 -1
  18. package/dist/{chunk-CORIBKHG.js → chunk-EGXCWZYP.js} +2 -2
  19. package/dist/{chunk-5EYRXSY5.cjs → chunk-EJQUYZXF.cjs} +9 -9
  20. package/dist/{chunk-5EYRXSY5.cjs.map → chunk-EJQUYZXF.cjs.map} +1 -1
  21. package/dist/{chunk-P4WTZU6L.cjs → chunk-FY5XAW3H.cjs} +11 -11
  22. package/dist/{chunk-P4WTZU6L.cjs.map → chunk-FY5XAW3H.cjs.map} +1 -1
  23. package/dist/{chunk-VQ523ORK.cjs → chunk-GMPYR3MX.cjs} +26 -26
  24. package/dist/{chunk-VQ523ORK.cjs.map → chunk-GMPYR3MX.cjs.map} +1 -1
  25. package/dist/{chunk-QSCHCZL3.cjs → chunk-GUTYUMGV.cjs} +7 -7
  26. package/dist/{chunk-QSCHCZL3.cjs.map → chunk-GUTYUMGV.cjs.map} +1 -1
  27. package/dist/{chunk-Q6E7VJ4W.cjs → chunk-IEZ3YBAP.cjs} +27 -28
  28. package/dist/chunk-IEZ3YBAP.cjs.map +1 -0
  29. package/dist/{chunk-HSACATCD.js → chunk-MPYDX5WX.js} +2 -2
  30. package/dist/{chunk-RQLBHKXN.js → chunk-NGEFYPY7.js} +2 -2
  31. package/dist/{chunk-BE6DK7QY.js → chunk-OQIMH2WQ.js} +8985 -11081
  32. package/dist/chunk-OQIMH2WQ.js.map +1 -0
  33. package/dist/{chunk-CSYSYJCF.cjs → chunk-UZZT65PQ.cjs} +37 -37
  34. package/dist/{chunk-CSYSYJCF.cjs.map → chunk-UZZT65PQ.cjs.map} +1 -1
  35. package/dist/{chunk-YZ2OIYQ3.js → chunk-VDZO6IDR.js} +4 -4
  36. package/dist/{chunk-UUYRJPGJ.js → chunk-VL2YMDPH.js} +4 -4
  37. package/dist/{chunk-5LMGFI4J.cjs → chunk-VUXNXWOQ.cjs} +4946 -7042
  38. package/dist/chunk-VUXNXWOQ.cjs.map +1 -0
  39. package/dist/{chunk-XQ2B74SI.js → chunk-WLM3F3WU.js} +2 -2
  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/guide-display.d.ts +14 -0
  45. package/dist/components/chat/guide-display.d.ts.map +1 -0
  46. package/dist/components/chat/hooks/index.d.ts +1 -0
  47. package/dist/components/chat/hooks/index.d.ts.map +1 -1
  48. package/dist/components/chat/hooks/use-chat.d.ts.map +1 -1
  49. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +48 -15
  50. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
  51. package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts +6 -0
  52. package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts.map +1 -0
  53. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +57 -10
  54. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  55. package/dist/components/chat/index.cjs +2 -8
  56. package/dist/components/chat/index.cjs.map +1 -1
  57. package/dist/components/chat/index.d.ts +1 -1
  58. package/dist/components/chat/index.d.ts.map +1 -1
  59. package/dist/components/chat/index.js +15 -21
  60. package/dist/components/chat/types/api.types.d.ts +81 -1
  61. package/dist/components/chat/types/api.types.d.ts.map +1 -1
  62. package/dist/components/chat/types/component.types.d.ts +6 -0
  63. package/dist/components/chat/types/component.types.d.ts.map +1 -1
  64. package/dist/components/chat/types/message.types.d.ts +15 -2
  65. package/dist/components/chat/types/message.types.d.ts.map +1 -1
  66. package/dist/components/chat/types/processing.types.d.ts +93 -2
  67. package/dist/components/chat/types/processing.types.d.ts.map +1 -1
  68. package/dist/components/chat/utils/chunk-parser.d.ts +25 -0
  69. package/dist/components/chat/utils/chunk-parser.d.ts.map +1 -0
  70. package/dist/components/chat/utils/extract-incomplete-message-state.d.ts +6 -34
  71. package/dist/components/chat/utils/extract-incomplete-message-state.d.ts.map +1 -1
  72. package/dist/components/chat/utils/index.d.ts +3 -2
  73. package/dist/components/chat/utils/index.d.ts.map +1 -1
  74. package/dist/components/chat/utils/message-segment-accumulator.d.ts +5 -0
  75. package/dist/components/chat/utils/message-segment-accumulator.d.ts.map +1 -1
  76. package/dist/components/chat/utils/process-historical-messages.d.ts +11 -59
  77. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  78. package/dist/components/contact/index.cjs +3 -3
  79. package/dist/components/contact/index.js +2 -2
  80. package/dist/components/docs/index.cjs +5 -5
  81. package/dist/components/docs/index.js +4 -4
  82. package/dist/components/embeds/index.cjs +3 -3
  83. package/dist/components/embeds/index.js +2 -2
  84. package/dist/components/faq/index.cjs +3 -3
  85. package/dist/components/faq/index.js +2 -2
  86. package/dist/components/features/index.cjs +2 -2
  87. package/dist/components/features/index.js +1 -1
  88. package/dist/components/help-center-pages/index.cjs +20 -20
  89. package/dist/components/help-center-pages/index.js +11 -11
  90. package/dist/components/index.cjs +130 -170
  91. package/dist/components/index.cjs.map +1 -1
  92. package/dist/components/index.js +23 -63
  93. package/dist/components/index.js.map +1 -1
  94. package/dist/components/navigation/index.cjs +2 -2
  95. package/dist/components/navigation/index.js +1 -1
  96. package/dist/components/onboarding-guides/index.cjs +5 -5
  97. package/dist/components/onboarding-guides/index.js +4 -4
  98. package/dist/components/onboarding-guides/onboarding-guide-detail-view.d.ts.map +1 -1
  99. package/dist/components/related-content/index.cjs +3 -3
  100. package/dist/components/related-content/index.js +2 -2
  101. package/dist/components/shared/product-release/release-detail-page.d.ts.map +1 -1
  102. package/dist/components/tickets/index.cjs +5 -5
  103. package/dist/components/tickets/index.js +4 -4
  104. package/dist/components/ui/index.cjs +2 -42
  105. package/dist/components/ui/index.cjs.map +1 -1
  106. package/dist/components/ui/index.d.ts +2 -1
  107. package/dist/components/ui/index.d.ts.map +1 -1
  108. package/dist/components/ui/index.js +15 -55
  109. package/dist/components/ui/rich-markdown-renderer.d.ts +34 -0
  110. package/dist/components/ui/rich-markdown-renderer.d.ts.map +1 -0
  111. package/dist/components/ui/simple-markdown-renderer.d.ts +73 -0
  112. package/dist/components/ui/simple-markdown-renderer.d.ts.map +1 -0
  113. package/dist/index.cjs +2 -58
  114. package/dist/index.cjs.map +1 -1
  115. package/dist/index.js +15 -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 +80 -163
  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/guide-display.tsx +44 -0
  129. package/src/components/chat/hooks/.index.md +33 -30
  130. package/src/components/chat/hooks/.use-nats-chat-adapter.md +55 -36
  131. package/src/components/chat/hooks/.use-realtime-chunk-processor.md +77 -0
  132. package/src/components/chat/hooks/index.ts +1 -0
  133. package/src/components/chat/hooks/use-chat.ts +0 -8
  134. package/src/components/chat/hooks/use-nats-chat-adapter.ts +825 -243
  135. package/src/components/chat/hooks/use-realtime-chunk-processor.ts +489 -0
  136. package/src/components/chat/hooks/use-sse-chat-adapter.ts +684 -380
  137. package/src/components/chat/index.ts +1 -5
  138. package/src/components/chat/thinking-display.tsx +1 -1
  139. package/src/components/chat/types/.api.types.md +49 -39
  140. package/src/components/chat/types/.processing.types.md +58 -29
  141. package/src/components/chat/types/api.types.ts +73 -6
  142. package/src/components/chat/types/component.types.ts +9 -0
  143. package/src/components/chat/types/message.types.ts +17 -1
  144. package/src/components/chat/types/processing.types.ts +53 -11
  145. package/src/components/chat/utils/.chunk-parser.md +62 -0
  146. package/src/components/chat/utils/.index.md +40 -31
  147. package/src/components/chat/utils/chunk-parser.ts +262 -0
  148. package/src/components/chat/utils/extract-incomplete-message-state.ts +5 -63
  149. package/src/components/chat/utils/index.ts +8 -5
  150. package/src/components/chat/utils/message-segment-accumulator.ts +19 -0
  151. package/src/components/chat/utils/process-historical-messages.ts +390 -352
  152. package/src/components/onboarding-guides/onboarding-guide-detail-view.tsx +4 -22
  153. package/src/components/shared/legal-document/legal-document-page.tsx +1 -1
  154. package/src/components/shared/product-release/release-detail-page.tsx +4 -19
  155. package/src/components/ui/.simple-markdown-renderer.md +52 -0
  156. package/src/components/ui/index.ts +2 -1
  157. package/src/components/ui/release-changelog-section.tsx +1 -1
  158. package/src/components/ui/rich-markdown-renderer.tsx +1223 -0
  159. package/src/components/ui/simple-markdown-renderer.tsx +964 -0
  160. package/src/components/ui/ticket-info-section.tsx +1 -1
  161. package/src/stories/ChatMessageEnhanced.stories.tsx +48 -1
  162. package/src/utils/index.ts +0 -1
  163. package/src/utils/markdown-section-extractor.ts +56 -41
  164. package/dist/chat-protocol/decode.d.ts +0 -58
  165. package/dist/chat-protocol/decode.d.ts.map +0 -1
  166. package/dist/chat-protocol/encode.d.ts +0 -44
  167. package/dist/chat-protocol/encode.d.ts.map +0 -1
  168. package/dist/chat-protocol/env-flag.d.ts +0 -35
  169. package/dist/chat-protocol/env-flag.d.ts.map +0 -1
  170. package/dist/chat-protocol/events.d.ts +0 -196
  171. package/dist/chat-protocol/events.d.ts.map +0 -1
  172. package/dist/chat-protocol/frames.d.ts +0 -213
  173. package/dist/chat-protocol/frames.d.ts.map +0 -1
  174. package/dist/chat-protocol/index.cjs +0 -494
  175. package/dist/chat-protocol/index.cjs.map +0 -1
  176. package/dist/chat-protocol/index.d.ts +0 -18
  177. package/dist/chat-protocol/index.d.ts.map +0 -1
  178. package/dist/chat-protocol/index.js +0 -478
  179. package/dist/chat-protocol/index.js.map +0 -1
  180. package/dist/chat-protocol/ip-normalize.d.ts +0 -44
  181. package/dist/chat-protocol/ip-normalize.d.ts.map +0 -1
  182. package/dist/chat-protocol/nats-decoder.d.ts +0 -26
  183. package/dist/chat-protocol/nats-decoder.d.ts.map +0 -1
  184. package/dist/chunk-5LMGFI4J.cjs.map +0 -1
  185. package/dist/chunk-BE6DK7QY.js.map +0 -1
  186. package/dist/chunk-Q6E7VJ4W.cjs.map +0 -1
  187. package/dist/chunk-T2EGSZFN.js.map +0 -1
  188. package/dist/chunk-TKN5667N.js.map +0 -1
  189. package/dist/chunk-YHOIAA2E.cjs.map +0 -1
  190. package/dist/components/chat/stream/chat-dialog-store.d.ts +0 -184
  191. package/dist/components/chat/stream/chat-dialog-store.d.ts.map +0 -1
  192. package/dist/components/chat/stream/chat-stream-reducer.d.ts +0 -367
  193. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +0 -1
  194. package/dist/components/chat/stream/delta-batcher.d.ts +0 -51
  195. package/dist/components/chat/stream/delta-batcher.d.ts.map +0 -1
  196. package/dist/components/chat/stream/index.d.ts +0 -17
  197. package/dist/components/chat/stream/index.d.ts.map +0 -1
  198. package/dist/components/chat/stream/message-mutations.d.ts +0 -77
  199. package/dist/components/chat/stream/message-mutations.d.ts.map +0 -1
  200. package/dist/components/chat/stream/use-chat-stream-reducer.d.ts +0 -22
  201. package/dist/components/chat/stream/use-chat-stream-reducer.d.ts.map +0 -1
  202. package/dist/components/ui/markdown/base-components.d.ts +0 -51
  203. package/dist/components/ui/markdown/base-components.d.ts.map +0 -1
  204. package/dist/components/ui/markdown/engine.d.ts +0 -99
  205. package/dist/components/ui/markdown/engine.d.ts.map +0 -1
  206. package/dist/components/ui/markdown/heading-ids.d.ts +0 -65
  207. package/dist/components/ui/markdown/heading-ids.d.ts.map +0 -1
  208. package/dist/components/ui/markdown/index.d.ts +0 -18
  209. package/dist/components/ui/markdown/index.d.ts.map +0 -1
  210. package/dist/components/ui/markdown/mermaid-diagram.d.ts +0 -79
  211. package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +0 -1
  212. package/dist/components/ui/markdown/rich/embed-overrides.d.ts +0 -14
  213. package/dist/components/ui/markdown/rich/embed-overrides.d.ts.map +0 -1
  214. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +0 -40
  215. package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +0 -1
  216. package/dist/components/ui/markdown/rich/shortcodes.d.ts +0 -8
  217. package/dist/components/ui/markdown/rich/shortcodes.d.ts.map +0 -1
  218. package/dist/components/ui/markdown/sanitize.d.ts +0 -153
  219. package/dist/components/ui/markdown/sanitize.d.ts.map +0 -1
  220. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +0 -23
  221. package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +0 -1
  222. package/dist/components/ui/markdown/streaming.d.ts +0 -78
  223. package/dist/components/ui/markdown/streaming.d.ts.map +0 -1
  224. package/dist/components/ui/markdown/text-size.d.ts +0 -34
  225. package/dist/components/ui/markdown/text-size.d.ts.map +0 -1
  226. package/dist/utils/markdown-fences.d.ts +0 -42
  227. package/dist/utils/markdown-fences.d.ts.map +0 -1
  228. package/dist/utils/markdown-heading-id.d.ts +0 -85
  229. package/dist/utils/markdown-heading-id.d.ts.map +0 -1
  230. package/src/chat-protocol/__tests__/__snapshots__/nats-decoder-golden.test.ts.snap +0 -307
  231. package/src/chat-protocol/__tests__/chat-protocol.test.ts +0 -516
  232. package/src/chat-protocol/__tests__/env-flag.test.ts +0 -52
  233. package/src/chat-protocol/__tests__/ip-normalize.test.ts +0 -136
  234. package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +0 -228
  235. package/src/chat-protocol/decode.ts +0 -278
  236. package/src/chat-protocol/encode.ts +0 -71
  237. package/src/chat-protocol/env-flag.ts +0 -39
  238. package/src/chat-protocol/events.ts +0 -232
  239. package/src/chat-protocol/frames.ts +0 -245
  240. package/src/chat-protocol/index.ts +0 -21
  241. package/src/chat-protocol/ip-normalize.ts +0 -146
  242. package/src/chat-protocol/nats-decoder.ts +0 -252
  243. package/src/components/chat/__tests__/chat-message-streaming-memo.test.tsx +0 -207
  244. package/src/components/chat/__tests__/chat-pending-turn.test.tsx +0 -209
  245. package/src/components/chat/hooks/__tests__/__snapshots__/conversation-id-persistence-golden.test.ts.snap +0 -37
  246. package/src/components/chat/hooks/__tests__/__snapshots__/sse-stream-golden.test.ts.snap +0 -0
  247. package/src/components/chat/hooks/__tests__/conversation-id-persistence-golden.test.ts +0 -438
  248. package/src/components/chat/hooks/__tests__/sse-stream-golden.test.ts +0 -318
  249. package/src/components/chat/stream/__tests__/__snapshots__/chat-stream-reducer-golden.test.ts.snap +0 -940
  250. package/src/components/chat/stream/__tests__/chat-dialog-store.test.ts +0 -756
  251. package/src/components/chat/stream/__tests__/chat-stream-reducer-golden.test.ts +0 -460
  252. package/src/components/chat/stream/__tests__/chat-stream-reducer.test.ts +0 -894
  253. package/src/components/chat/stream/__tests__/delta-batcher.test.ts +0 -255
  254. package/src/components/chat/stream/__tests__/use-chat-stream-reducer.test.ts +0 -98
  255. package/src/components/chat/stream/chat-dialog-store.ts +0 -536
  256. package/src/components/chat/stream/chat-stream-reducer.ts +0 -1796
  257. package/src/components/chat/stream/delta-batcher.ts +0 -159
  258. package/src/components/chat/stream/index.ts +0 -55
  259. package/src/components/chat/stream/message-mutations.ts +0 -338
  260. package/src/components/chat/stream/use-chat-stream-reducer.ts +0 -126
  261. package/src/components/chat/utils/__tests__/__snapshots__/process-historical-messages-golden.test.ts.snap +0 -420
  262. package/src/components/chat/utils/__tests__/__snapshots__/segment-accumulator-golden.test.ts.snap +0 -605
  263. package/src/components/chat/utils/__tests__/process-historical-messages-golden.test.ts +0 -317
  264. package/src/components/chat/utils/__tests__/segment-accumulator-golden.test.ts +0 -270
  265. package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +0 -2420
  266. package/src/components/ui/__tests__/markdown-parity.test.tsx +0 -2528
  267. package/src/components/ui/markdown/__tests__/mermaid-security.test.ts +0 -115
  268. package/src/components/ui/markdown/__tests__/mermaid-stale-render.test.tsx +0 -95
  269. package/src/components/ui/markdown/__tests__/sanitize-invariant.test.ts +0 -309
  270. package/src/components/ui/markdown/__tests__/streaming.test.tsx +0 -388
  271. package/src/components/ui/markdown/base-components.tsx +0 -360
  272. package/src/components/ui/markdown/engine.tsx +0 -315
  273. package/src/components/ui/markdown/heading-ids.ts +0 -239
  274. package/src/components/ui/markdown/index.ts +0 -49
  275. package/src/components/ui/markdown/mermaid-diagram.tsx +0 -291
  276. package/src/components/ui/markdown/rich/embed-overrides.tsx +0 -199
  277. package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +0 -184
  278. package/src/components/ui/markdown/rich/shortcodes.ts +0 -170
  279. package/src/components/ui/markdown/sanitize.ts +0 -3499
  280. package/src/components/ui/markdown/simple-markdown-renderer.tsx +0 -28
  281. package/src/components/ui/markdown/streaming.ts +0 -362
  282. package/src/components/ui/markdown/text-size.ts +0 -106
  283. package/src/utils/markdown-fences.ts +0 -127
  284. package/src/utils/markdown-heading-id.ts +0 -348
  285. /package/dist/{chunk-GTWO5NAY.js.map → chunk-6CFFISUC.js.map} +0 -0
  286. /package/dist/{chunk-VHG6AX5V.js.map → chunk-6CJ2K7BD.js.map} +0 -0
  287. /package/dist/{chunk-4NWARV5I.js.map → chunk-6QK3ONDD.js.map} +0 -0
  288. /package/dist/{chunk-CORIBKHG.js.map → chunk-EGXCWZYP.js.map} +0 -0
  289. /package/dist/{chunk-HSACATCD.js.map → chunk-MPYDX5WX.js.map} +0 -0
  290. /package/dist/{chunk-RQLBHKXN.js.map → chunk-NGEFYPY7.js.map} +0 -0
  291. /package/dist/{chunk-YZ2OIYQ3.js.map → chunk-VDZO6IDR.js.map} +0 -0
  292. /package/dist/{chunk-UUYRJPGJ.js.map → chunk-VL2YMDPH.js.map} +0 -0
  293. /package/dist/{chunk-XQ2B74SI.js.map → chunk-WLM3F3WU.js.map} +0 -0
@@ -6,6 +6,7 @@ export * from './approval-batch-message'
6
6
  export * from './context-compaction-display'
7
7
  export * from './expand-chevron'
8
8
  export * from './thinking-display'
9
+ export * from './guide-display'
9
10
  export * from './error-message-display'
10
11
  export * from './chat-container'
11
12
  export * from './chat-input'
@@ -75,11 +76,6 @@ export * from './types'
75
76
  // Chat hooks
76
77
  export * from './hooks'
77
78
 
78
- // Chat stream module — master reducer + dialog store + React wrapper
79
- // (Phase 3 of the chat unification; ONE accumulation path for SSE + NATS
80
- // + history replay).
81
- export * from './stream'
82
-
83
79
  // Chat utilities
84
80
  export * from './utils'
85
81
 
@@ -4,7 +4,7 @@ import { forwardRef, useState } from "react"
4
4
 
5
5
  import { cn } from "../../utils/cn"
6
6
  import { DotsLoaderIcon } from "../icons-v2-generated"
7
- import { SimpleMarkdownRenderer } from "../ui/markdown/simple-markdown-renderer"
7
+ import { SimpleMarkdownRenderer } from "../ui/simple-markdown-renderer"
8
8
  import { ExpandChevron } from "./expand-chevron"
9
9
  import { useCollapsible } from "./hooks/use-collapsible"
10
10
  import type { ThinkingDisplayProps } from "./types"
@@ -1,60 +1,70 @@
1
- <!-- source-hash: 60ad035125eceb97fa074f58783d5bc8 -->
2
- Defines TypeScript interfaces for API interactions and React hook contracts used across Flamingo's chat and dialog systems, covering NATS/JetStream subscriptions, real-time chunk processing, and REST-style request/response shapes.
1
+ <!-- source-hash: 76966dd4845d1486e56288fc8033df68 -->
2
+ Defines TypeScript interfaces for API interactions and React hook contracts used in the OpenFrame real-time chat and NATS messaging system.
3
3
 
4
4
  ## Key Components
5
5
 
6
- ### Hook Options
7
- | Interface | Purpose |
8
- |---|---|
9
- | `UseChunkCatchupOptions` | Configure chunk catch-up replay with optional custom fetch function |
10
- | `UseNatsDialogSubscriptionOptions` | Core NATS WebSocket subscription config with reconnection backoff tuning |
11
- | `UseJetStreamDialogSubscriptionOptions` | JetStream-based subscription with sequence-based resume support |
12
-
13
- ### Hook Return Types
14
- | Interface | Purpose |
15
- |---|---|
16
- | `UseChunkCatchupReturn` | Exposes catchup, processing, and buffering controls |
17
- | `UseNatsDialogSubscriptionReturn` | Connection state and reconnection counter |
18
- | `UseJetStreamDialogSubscriptionReturn` | Connection state plus current stream sequence |
19
-
20
- ### Callbacks
21
- - **`RealtimeChunkCallbacks`** — Rich event callback map for streaming events: `onStreamStart`, `onStreamEnd`, `onSegmentsUpdate`, `onTokenUsage`, `onApprove`, `onReject`, `onEscalatedApproval`, `onApprovalResolved`, `onToolExecuted`, `onDialogClosed`, and more.
22
-
23
- ### API Request/Response Types
24
- - **Chat** — `ChatAPIRequest` / `ChatAPIResponse`
25
- - **Dialogs** — `DialogCreateRequest/Response`, `DialogListRequest/Response`
26
- - **Approvals** — `ApprovalRequest` / `ApprovalResponse`
27
- - **Settings** — `ChatSettings`, `UpdateSettingsRequest/Response`
6
+ ### Hook Option Interfaces
7
+ - **`UseChunkCatchupOptions`** Configuration for chunk catch-up logic, including dialog ID, chunk callbacks, chat type filters, and an optional custom fetch function
8
+ - **`UseNatsDialogSubscriptionOptions`** — NATS WebSocket subscription config with reconnection backoff tuning, auth lifecycle hooks, and client credentials
9
+ - **`UseJetStreamDialogSubscriptionOptions`** JetStream-specific variant adding stream name, sequence-based replay (`optStartSeq`), and consumer inactivity threshold
10
+ - **`UseRealtimeChunkProcessorOptions`** Controls chunk processing behavior: approval type routing, batch approvals, direct-mode barrier, and initial accumulator state for reconnection
11
+
12
+ ### Hook Return Interfaces
13
+ - **`UseChunkCatchupReturn`** Exposes `catchUpChunks`, `processChunk`, `resetAndCatchUp`, and buffering state controls
14
+ - **`UseNatsDialogSubscriptionReturn`** / **`UseJetStreamDialogSubscriptionReturn`** — Connection/subscription status and reconnection counters; JetStream variant also tracks `currentStreamSeq`
15
+ - **`UseRealtimeChunkProcessorReturn`** — `processChunk`, `getSegments`, `reset`, and `updateApprovalStatus`
16
+
17
+ ### Callback & Metadata Interfaces
18
+ - **`RealtimeChunkCallbacks`** — Comprehensive event callback surface covering stream lifecycle (`onStreamStart`, `onStreamEnd`), message types (user, direct, system), tool execution (`onToolExecuted`, `onAgentBusy`), approval flows (`onApprove`, `onReject`, `onEscalatedApproval`, `onApprovalResolved`), token usage, and dialog closure
19
+ - **`SegmentsUpdateMetadata`** — Carries append mode, compaction flags, and JetStream `streamSeq` for history deduplication
28
20
 
29
21
  ## Usage Example
30
22
 
31
23
  ```typescript
32
- const options: ChatStreamReducerOptions = {
33
- callbacks: {
34
- onSegmentsUpdate: (segments, meta) => {
35
- if (meta?.append) appendToLastMessage(segments)
36
- else setSegments(segments)
37
- },
38
- onApprovalResolved: (requestId, status, approvalType) => {
39
- updateApprovalBadge(requestId, status)
40
- },
41
- onTokenUsage: (data) => console.log('Tokens used:', data),
24
+ import type {
25
+ UseNatsDialogSubscriptionOptions,
26
+ UseRealtimeChunkProcessorOptions,
27
+ RealtimeChunkCallbacks,
28
+ } from './api.types'
29
+
30
+ const callbacks: RealtimeChunkCallbacks = {
31
+ onStreamStart: () => setStreaming(true),
32
+ onStreamEnd: () => setStreaming(false),
33
+ onSegmentsUpdate: (segments, meta) => {
34
+ if (meta?.append) appendSegments(segments)
35
+ else setSegments(segments)
42
36
  },
43
- batchApprovalsEnabled: true,
37
+ onToolExecuted: (segment) => mergeToolResult(segment),
38
+ onApprovalResolved: (requestId, status, approvalType) => {
39
+ updateApprovalCard(requestId, status)
40
+ },
41
+ }
42
+
43
+ const processorOptions: UseRealtimeChunkProcessorOptions = {
44
+ callbacks,
44
45
  displayApprovalTypes: ['CLIENT'],
45
- enableThinking: false,
46
+ batchApprovalsEnabled: true,
47
+ initialState: {
48
+ existingSegments: historicalSegments,
49
+ executingTools: new Map(),
50
+ },
46
51
  }
47
52
 
48
53
  const natsOptions: UseNatsDialogSubscriptionOptions = {
49
54
  enabled: true,
50
55
  dialogId: 'dialog-123',
56
+ topics: ['message'],
51
57
  getNatsWsUrl: () => 'wss://nats.example.com',
58
+ onBeforeReconnect: async () => refreshAuthToken(),
52
59
  reconnectionBackoff: {
53
60
  fastRetries: 3,
54
61
  fastRetryDelayMs: 500,
55
- maxDelayMs: 30000,
62
+ maxDelayMs: 30_000,
56
63
  multiplier: 2,
57
64
  },
58
- onBeforeReconnect: async () => refreshAuthToken(),
59
65
  }
60
- ```
66
+ ```
67
+
68
+ ## Source
69
+
70
+ [`api.types.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/api.types.ts)
@@ -1,51 +1,80 @@
1
- <!-- source-hash: 118d3a4cacf89174498282067448e4bf -->
2
- Defines TypeScript types for message processing pipeline operations, including chunk parsing, accumulator state management, stream control, and buffer management for AI chat message flows.
1
+ <!-- source-hash: bdb71cca9908cf9cfebf089a00d84db8 -->
2
+ Defines TypeScript types for the message processing pipeline, covering chunk parsing, state accumulation, stream control, and buffer management.
3
3
 
4
4
  ## Key Components
5
5
 
6
- | Export | Type | Description |
7
- |--------|------|-------------|
8
- | `AccumulatorState` | Interface | Stateful container tracking message segments, pending approvals, and executing tools during stream processing |
9
- | `PendingApproval` | Interface | Represents an approval request awaiting user action (command, explanation, type) |
10
- | `MessageProcessingOptions` | Interface | Configuration for assistant rendering, approval callbacks, chat filtering, and batch approval UI |
11
- | `StreamProcessor` | Interface | Full lifecycle control (start/stop/pause/resume/reset) for stream consumers |
12
- | `StreamState` | Interface | Snapshot of stream health: active status, buffered chunks, error log, and last activity timestamp |
13
- | `BufferManager` | Interface | CRUD-style contract for managing `ChunkData` buffers |
14
- | `BufferOptions` | Interface | Configuration for buffer capacity, flush intervals, and overflow handling callbacks |
6
+ ### Union Types
7
+ - **`ParsedChunkAction`** — Discriminated union of all possible chunk parse results: `message_start`, `message_end`, `error`, `metadata`, `text`, `thinking`, `tool_execution`, `approval_request`, `approval_batch`, `approval_result`, `token_usage`, `direct_message`, `system`, `context_compaction_start/end`, `dialog_closed`
8
+
9
+ ### Accumulator State
10
+ - **`AccumulatorState`** Tracks in-flight message segments, pending approvals, and executing tool states during streaming
11
+ - **`PendingApproval`** Holds command, explanation, and approval type for a deferred approval card
12
+
13
+ ### Processing Configuration
14
+ - **`MessageProcessingOptions`** Runtime options passed to the processor: assistant identity, approval callbacks, chat type filter, approval status map, `displayApprovalTypes`, and `batchApprovalsEnabled` (consumer-owned feature flag)
15
+
16
+ ### Chunk Processing
17
+ - **`ChunkProcessor`** — Interface for stateful chunk parsing with `processChunk` and `reset`
18
+ - **`ChunkProcessorOptions`** — Lifecycle callbacks for chunk events (`onText`, `onToolExecution`, `onApprovalRequest`, etc.)
19
+
20
+ ### Message Transformation
21
+ - **`MessageTransformer`** — Single and batch transform interface producing `ProcessedMessage` outputs
22
+ - **`TransformationOptions`** — Flags for segment merging, timestamp formatting, and metadata inclusion
23
+
24
+ ### Stream & Buffer Management
25
+ - **`StreamProcessor`** — Lifecycle control (`start`, `stop`, `pause`, `resume`, `reset`, `getState`)
26
+ - **`StreamState`** — Runtime counters: active state, pause flag, processed message count, buffered chunks, error log
27
+ - **`BufferManager`** — FIFO buffer operations (`add`, `flush`, `clear`, `size`, `isEmpty`, `isFull`)
28
+ - **`BufferOptions`** — Max size, flush interval, and overflow/flush callbacks
15
29
 
16
30
  ## Usage Example
17
31
 
18
32
  ```typescript
19
33
  import type {
34
+ ParsedChunkAction,
20
35
  AccumulatorState,
21
36
  MessageProcessingOptions,
22
- StreamState
37
+ StreamState,
23
38
  } from './processing.types'
24
39
 
25
-
26
- // Initializing accumulator state
27
- const state: AccumulatorState = {
28
- segments: [],
29
- pendingApprovals: new Map(),
30
- executingTools: new Map()
40
+ // Narrow a parsed chunk action by discriminant
41
+ function handleChunk(action: ParsedChunkAction) {
42
+ switch (action.action) {
43
+ case 'text':
44
+ console.log('Text received:', action.text)
45
+ break
46
+ case 'tool_execution':
47
+ console.log('Tool segment:', action.segment)
48
+ break
49
+ case 'approval_batch':
50
+ console.log('Batch approval', action.requestId, action.toolCalls)
51
+ break
52
+ case 'error':
53
+ console.error(action.error, action.details)
54
+ break
55
+ }
31
56
  }
32
57
 
33
- // Configuring message processing
58
+ // Configure message processing with batch approvals enabled
34
59
  const options: MessageProcessingOptions = {
35
60
  assistantName: 'Mingo',
36
61
  assistantType: 'mingo',
37
- batchApprovalsEnabled: true,
38
- displayApprovalTypes: ['shell', 'file'],
62
+ batchApprovalsEnabled: true, // consumer sets this from their feature flag
63
+ displayApprovalTypes: ['shell', 'file_write'],
39
64
  onApprove: async (requestId) => {
40
- await submitApproval(requestId)
65
+ await fetch(`/api/approvals/${requestId}/approve`, { method: 'POST' })
41
66
  },
42
- onReject: (requestId) => {
43
- logRejection(requestId)
44
- }
67
+ onReject: async (requestId) => {
68
+ await fetch(`/api/approvals/${requestId}/reject`, { method: 'POST' })
69
+ },
70
+ }
71
+
72
+ // Initialize accumulator state
73
+ const state: AccumulatorState = {
74
+ segments: [],
75
+ pendingApprovals: new Map(),
76
+ executingTools: new Map(),
45
77
  }
46
78
  ```
47
79
 
48
- > NOTE: the wire-chunk vocabulary now lives in `src/chat-protocol/events.ts`
49
- > (`ChatStreamEvent`, produced by `decodeNatsChunk`). The old
50
- > `ParsedChunkAction` union and the `ChunkProcessor` contract were deleted
51
- > together with the legacy `chunk-parser`.
80
+ **Source:** [`processing.types.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/processing.types.ts)
@@ -213,12 +213,79 @@ export interface RealtimeChunkCallbacks {
213
213
  onDialogClosed?: () => void
214
214
  }
215
215
 
216
- // NOTE: `UseRealtimeChunkProcessorOptions` / `UseRealtimeChunkProcessorReturn`
217
- // were DELETED along with the `useRealtimeChunkProcessor` compat hook. The
218
- // equivalents are `ChatStreamReducerOptions` + `ChatStreamReducer` in
219
- // `../stream/chat-stream-reducer`. `RealtimeChunkCallbacks` above SURVIVES:
220
- // it is still the canonical description of the effect names/args the reducer
221
- // emits via `ChatReducerEffect`.
216
+ export interface UseRealtimeChunkProcessorOptions {
217
+ callbacks: RealtimeChunkCallbacks
218
+ /**
219
+ * Filter approval types that should be displayed directly
220
+ * Others will trigger onEscalatedApproval
221
+ * Default: ['CLIENT']
222
+ */
223
+ displayApprovalTypes?: string[]
224
+ /**
225
+ * Map of existing approval statuses
226
+ */
227
+ approvalStatuses?: Record<string, ChatApprovalStatus>
228
+ /**
229
+ * Initialize accumulator with existing state from incomplete historical message
230
+ * Used to continue building messages across page refreshes or reconnections
231
+ */
232
+ initialState?: {
233
+ /** Existing segments to continue building upon */
234
+ existingSegments?: MessageSegment[]
235
+ /** Pending approvals that haven't been resolved */
236
+ pendingApprovals?: Map<string, { command: string; explanation?: string; approvalType: string }>
237
+ /** Executing tools waiting for completion */
238
+ executingTools?: Map<string, ExecutingToolState>
239
+ /** Escalated approvals */
240
+ escalatedApprovals?: Map<
241
+ string,
242
+ { command: string; explanation?: string; approvalType: string; toolCalls?: PendingToolCallData[] }
243
+ >
244
+ }
245
+ /**
246
+ * Consumer-owned (e.g. set in `openframe-oss-tenant` chat client via the
247
+ * `'batch-approvals'` feature flag and forwarded here). The lib does NOT
248
+ * default this to a batch-on behavior — when omitted it falls back to the
249
+ * legacy single-card rendering.
250
+ *
251
+ * When true: `APPROVAL_REQUEST` chunks containing `toolCalls[]` are rendered
252
+ * as a single batch card. When false / omitted: the batch is split into N
253
+ * legacy approval cards (one per tool that requires approval), all sharing
254
+ * the same `approvalRequestId`. Tools with `requiresApproval=false` are
255
+ * dropped from the UI in the unfolded mode.
256
+ */
257
+ batchApprovalsEnabled?: boolean
258
+ /**
259
+ * Engages the direct-mode barrier optimistically: once true, all AI-assistant
260
+ * chunks (text, thinking, tool executions, approvals, metadata, errors, etc.)
261
+ * are dropped and any open stream is torn down, leaving only human/control
262
+ * messages. A `DIRECT_MESSAGE` chunk engages the same barrier automatically
263
+ * regardless of this flag. Pass this from a host that already knows the dialog
264
+ * switched to direct mode (e.g. an optimistic mode toggle) to close the race
265
+ * window before the server emits the first `DIRECT_MESSAGE`.
266
+ *
267
+ * Do NOT set this when the host reconstructs history by replaying chunks
268
+ * through `processChunk` — a static flag would drop legitimate pre-switch AI
269
+ * history. Rely on the in-order `DIRECT_MESSAGE` detection instead.
270
+ */
271
+ isDirectMode?: boolean
272
+ }
273
+
274
+ export interface UseRealtimeChunkProcessorReturn {
275
+ /** Process a single chunk */
276
+ processChunk: (chunk: unknown) => void
277
+ /** Get current segments */
278
+ getSegments: () => MessageSegment[]
279
+ /** Reset the accumulator */
280
+ reset: () => void
281
+ /** Update approval status for a request */
282
+ updateApprovalStatus: (requestId: string, status: ChatApprovalStatus, resolvedByName?: string | null) => MessageSegment[]
283
+ /** Get pending approval requests */
284
+ getPendingApprovals: () => Map<
285
+ string,
286
+ { command: string; explanation?: string; approvalType: string; toolCalls?: PendingToolCallData[] }
287
+ >
288
+ }
222
289
 
223
290
  // ========== API Request Types ==========
224
291
 
@@ -556,6 +556,15 @@ export interface ThinkingDisplayProps extends HTMLAttributes<HTMLDivElement> {
556
556
  isStreaming?: boolean
557
557
  }
558
558
 
559
+ // ========== Guide Display Props ==========
560
+
561
+ export interface GuideDisplayProps extends HTMLAttributes<HTMLDivElement> {
562
+ /** Rendered guide body. `ChatMessageEnhanced` passes the SAME markdown
563
+ * output a text segment gets, so `[card://]` cards and mention chips
564
+ * behave identically inside a guide. */
565
+ children?: ReactNode
566
+ }
567
+
559
568
  // ========== Model Display Props ==========
560
569
 
561
570
  export interface ModelDisplayProps extends HTMLAttributes<HTMLDivElement> {
@@ -10,6 +10,7 @@ import type { AssistantType, AuthorType, ChatApprovalStatus, MessageOwner } from
10
10
  export const MESSAGE_TYPE = {
11
11
  TEXT: 'TEXT',
12
12
  THINKING: 'THINKING',
13
+ GUIDE: 'GUIDE',
13
14
  EXECUTING_TOOL: 'EXECUTING_TOOL',
14
15
  EXECUTED_TOOL: 'EXECUTED_TOOL',
15
16
  APPROVAL_REQUEST: 'APPROVAL_REQUEST',
@@ -170,6 +171,15 @@ export type ThinkingSegment = {
170
171
  text: string
171
172
  }
172
173
 
174
+ /** Guide answer body — the assistant's how-to/documentation reply, rendered as
175
+ * a titled "OpenFrame Guide" card instead of a bare paragraph. `text` is
176
+ * markdown, streamed in fragments like a `text` segment and coalesced by the
177
+ * accumulator. */
178
+ export type GuideSegment = {
179
+ type: 'guide'
180
+ text: string
181
+ }
182
+
173
183
  export type ToolExecutionSegment = {
174
184
  type: 'tool_execution'
175
185
  data: ToolExecutionData
@@ -208,7 +218,7 @@ export type ContextCompactionSegment = {
208
218
  summary?: string
209
219
  }
210
220
 
211
- export type MessageSegment = TextSegment | ThinkingSegment | ToolExecutionSegment | ApprovalRequestSegment | ApprovalBatchSegment | ErrorSegment | ContextCompactionSegment
221
+ export type MessageSegment = TextSegment | ThinkingSegment | GuideSegment | ToolExecutionSegment | ApprovalRequestSegment | ApprovalBatchSegment | ErrorSegment | ContextCompactionSegment
212
222
 
213
223
  export type MessageContent = string | MessageSegment[]
214
224
 
@@ -228,6 +238,11 @@ export interface ThinkingMessageData extends MessageDataBase {
228
238
  text?: string
229
239
  }
230
240
 
241
+ export interface GuideMessageData extends MessageDataBase {
242
+ type: 'GUIDE'
243
+ text?: string
244
+ }
245
+
231
246
  export interface ExecutingToolMessageData extends MessageDataBase {
232
247
  type: 'EXECUTING_TOOL'
233
248
  integratedToolType?: string
@@ -309,6 +324,7 @@ export interface ContextCompactionEndMessageData extends MessageDataBase {
309
324
  export type MessageData =
310
325
  | TextMessageData
311
326
  | ThinkingMessageData
327
+ | GuideMessageData
312
328
  | ExecutingToolMessageData
313
329
  | ExecutedToolMessageData
314
330
  | ApprovalRequestMessageData
@@ -3,14 +3,38 @@
3
3
  * Contains types for message parsing, accumulation, and processing
4
4
  */
5
5
 
6
- import type { MessageSegment, PendingToolCallData, ExecutingToolState } from './message.types'
6
+ import type { MessageSegment, ProcessedMessage, ToolExecutionSegment, TokenUsageData, PendingToolCallData, ExecutingToolState } from './message.types'
7
7
  import type { ChatApprovalStatus, AssistantType } from './chat.types'
8
- import type { ChunkData } from './network.types'
9
-
10
- // NOTE: the `ParsedChunkAction` union that used to live here was DELETED
11
- // alongside the legacy `chunk-parser`. The wire → normalized-event
12
- // vocabulary is now `ChatStreamEvent` in `src/chat-protocol/events.ts`,
13
- // produced by `decodeNatsChunk`.
8
+ import type { ChunkData, NatsMessageType } from './network.types'
9
+
10
+ // ========== Parsed Chunk Result Types ==========
11
+
12
+ export type ParsedChunkAction =
13
+ | { action: 'message_start' }
14
+ | { action: 'message_end' }
15
+ | { action: 'error'; error: string; details?: string }
16
+ | { action: 'metadata'; modelDisplayName: string; modelName: string; providerName: string; contextWindow: number }
17
+ | { action: 'text'; text: string }
18
+ | { action: 'thinking'; text: string }
19
+ | { action: 'guide'; text: string }
20
+ | { action: 'tool_execution'; segment: ToolExecutionSegment }
21
+ | { action: 'approval_request'; requestId: string; command: string; explanation?: string; approvalType: string }
22
+ | { action: 'approval_batch'; requestId: string; approvalType: string; toolCalls: PendingToolCallData[] }
23
+ | { action: 'approval_result'; requestId: string; approved: boolean; approvalType: string; resolvedByName?: string | null }
24
+ | {
25
+ action: 'message_request'
26
+ text: string
27
+ ownerType?: string
28
+ displayName?: string
29
+ userId?: string
30
+ contextItems?: Array<{ type: string; id: string }>
31
+ }
32
+ | { action: 'token_usage'; data: TokenUsageData }
33
+ | { action: 'direct_message'; text: string; ownerType?: string; displayName?: string; userId?: string }
34
+ | { action: 'system'; text: string }
35
+ | { action: 'context_compaction_start' }
36
+ | { action: 'context_compaction_end'; summary?: string }
37
+ | { action: 'dialog_closed' }
14
38
 
15
39
  // ========== Accumulator State ==========
16
40
 
@@ -58,13 +82,31 @@ export interface MessageProcessingOptions {
58
82
  batchApprovalsEnabled?: boolean
59
83
  }
60
84
 
61
- // NOTE: `ChunkProcessorOptions` (the options bag of the deleted
62
- // `ChunkProcessor`) and `MessageTransformer` were DELETED — both were left
63
- // behind by the chunk-processor removal with zero references in lib, hub, or
64
- // app.
85
+ // ========== Chunk Processing Types ==========
86
+
87
+ export interface ChunkProcessor {
88
+ processChunk: (chunk: ChunkData, messageType: NatsMessageType) => ParsedChunkAction | null
89
+ reset: () => void
90
+ }
91
+
92
+ export interface ChunkProcessorOptions {
93
+ onMessageStart?: () => void
94
+ onMessageEnd?: () => void
95
+ onError?: (error: string, details?: string) => void
96
+ onText?: (text: string) => void
97
+ onToolExecution?: (segment: MessageSegment) => void
98
+ onApprovalRequest?: (data: any) => void
99
+ onApprovalResult?: (data: any) => void
100
+ onMetadata?: (data: any) => void
101
+ }
65
102
 
66
103
  // ========== Message Transformation Types ==========
67
104
 
105
+ export interface MessageTransformer {
106
+ transform: (input: any) => ProcessedMessage | null
107
+ batch: (inputs: any[]) => ProcessedMessage[]
108
+ }
109
+
68
110
  export interface TransformationOptions {
69
111
  preserveOriginal?: boolean
70
112
  mergeSegments?: boolean
@@ -0,0 +1,62 @@
1
+ <!-- source-hash: c8c1cef3b3966f8791e7003c4f74429f -->
2
+ Utilities for parsing raw NATS message chunks into typed, structured action objects consumed by the OpenFrame chat pipeline.
3
+
4
+ ## Key Components
5
+
6
+ ### `parseChunkToAction(chunk: unknown): ParsedChunkAction | null`
7
+ The primary export. Accepts an untyped NATS chunk, inspects its `type` field against `MESSAGE_TYPE` constants, and returns a discriminated `ParsedChunkAction` union or `null` for unrecognized types. Handles the full message lifecycle including:
8
+
9
+ - **Lifecycle signals:** `message_start`, `message_end`, `dialog_closed`
10
+ - **Content:** `text`, `thinking`, `system`, `direct_message`
11
+ - **Tool execution:** `tool_execution` (both `EXECUTING_TOOL` and `EXECUTED_TOOL` states)
12
+ - **Approval flow:** `approval_request`, `approval_batch`, `approval_result`
13
+ - **Metadata & telemetry:** `metadata`, `token_usage`, `context_compaction_start/end`
14
+ - **Error handling:** `error`
15
+
16
+ ### `normalizeToolCalls(raw: unknown): PendingToolCallData[]` *(internal)*
17
+ Safely coerces an untyped array into `PendingToolCallData[]`, filtering non-objects and providing safe defaults for all fields.
18
+
19
+ ### Predicate helpers
20
+ Lightweight type guards for fast chunk classification without full parsing:
21
+
22
+ | Function | Returns `true` when |
23
+ |---|---|
24
+ | `isControlChunk` | `MESSAGE_START` or `MESSAGE_END` |
25
+ | `isErrorChunk` | `ERROR` type |
26
+ | `isMetadataChunk` | `AI_METADATA` type |
27
+ | `extractTextFromChunk` | `TEXT` type — returns the string or `null` |
28
+
29
+ ## Usage Example
30
+
31
+ ```typescript
32
+ import {
33
+ parseChunkToAction,
34
+ isControlChunk,
35
+ isErrorChunk,
36
+ } from './chunk-parser'
37
+
38
+ // Parse an incoming NATS chunk
39
+ const action = parseChunkToAction(rawChunk)
40
+
41
+ if (action?.action === 'text') {
42
+ appendToTranscript(action.text)
43
+ } else if (action?.action === 'approval_batch') {
44
+ promptUserApproval(action.toolCalls)
45
+ }
46
+
47
+ // Fast-path guards before full parse
48
+ if (isErrorChunk(rawChunk)) {
49
+ handleError()
50
+ }
51
+ if (isControlChunk(rawChunk)) {
52
+ resetStreamState()
53
+ }
54
+ ```
55
+
56
+ ## Notes
57
+
58
+ - All field access is defensive — missing or wrong-typed properties fall back to safe defaults rather than throwing.
59
+ - `approval_result` accepts both `resolvedByName` and `displayName` so realtime NATS chunks and GraphQL history replays produce identical output shapes.
60
+ - `contextItems` on `message_request` back-fills `label` from `id` to satisfy the required `ChatContextItem` contract when no label is present on the wire.
61
+
62
+ **Source:** [`https://github.com/flamingo-stack/openframe-oss-lib/blob/main/chunk-parser.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/chunk-parser.ts)
@@ -1,48 +1,57 @@
1
- <!-- source-hash: 85c0af6cd361347beeabcd097260378a -->
2
- Barrel export module that consolidates and re-exports all message processing, chat navigation, UI styling, and content utility functions for chat interfaces.
1
+ <!-- source-hash: 0435e7889d0ba1d3a5186507e28737c9 -->
2
+ Barrel export module for the message processing utilities library, re-exporting all public APIs from specialized sub-modules covering chat message parsing, navigation, attachments, icons, and more.
3
3
 
4
4
  ## Key Components
5
5
 
6
- | Category | Exports |
7
- |----------|---------|
8
- | **Message Accumulation** | `MessageSegmentAccumulator`, `createMessageSegmentAccumulator`, `AccumulatorCallbacks` |
9
- | **Historical Messages** | `processHistoricalMessages`, `extractErrorMessages`, `processHistoricalMessagesWithErrors` |
10
- | **Chat Navigation** | `handleChatNavClick`, `resolveExternalNavigation`, `decideNewTab`, `computeIsNewTab`, `buildAnchorProps` |
11
- | **Proxy Auth** | `getChatProxyAuth`, `setChatProxyAuth`, `clearChatProxyAuth`, `applyProxyAuth`, `chatAuthedFetch` |
12
- | **Attachments** | `formatChatAttachmentMarkdownForBubble`, `stripChatAttachmentMarkdown`, `buildChatAttachmentViewUrl` |
13
- | **UI / Styling** | `chatChipClass`, compact card class constants (`COMPACT_CARD_*`), `getStatusColorScheme` |
14
- | **Icon Registry** | `ICON_REGISTRY`, `getIconComponent`, `normalizeIconKey`, `getDynamicIcon` |
15
- | **Source Utilities** | `getSourceIconName`, `getSourceLabel`, `resolveSourceRowCTA`, `resolveSourceIcon` |
16
- | **Slash Commands** | `parseWireCommandOverride`, `sanitizeTitleForChat`, `buildDiscussAddendum` |
6
+ | Export Group | Source Module | Description |
7
+ |---|---|---|
8
+ | Chunk parsing | `chunk-parser` | Parse streaming chunks into actions, detect control/error/metadata chunks |
9
+ | Segment accumulator | `message-segment-accumulator` | Accumulate streaming message segments with callbacks |
10
+ | Historical messages | `process-historical-messages` | Process and reconcile chat history with error extraction |
11
+ | History merge | `history-merge` | Reconcile persisted history with realtime stream data |
12
+ | Navigation | `execute-navigation`, `nav-click-handler`, `decide-new-tab` | Unified navigation primitive for new-tab/same-tab, internal/external, embed/host routing |
13
+ | Chat attachment | `chat-attachment-markdown` | Format and strip attachment markdown, URL/token helpers |
14
+ | Icon registry | `icon-registry`, `icon-library`, `source-icons` | Single source of truth for icon-name → component lookups |
15
+ | Proxy auth | `chat-proxy-auth-storage`, `chat-authed-fetch` | localStorage adapter and authenticated fetch wrapper |
16
+ | Slash commands | `slash-dispatch-utils` | Command parsing, entity filtering, and dispatch utilities |
17
+ | Compact card | `compact-card-classes` | Shared CSS class constants and safe-href guard |
18
+ | Scripted stream | `scripted-stream` | Re-exported wholesale via `export *` |
17
19
 
18
20
  ## Usage Example
19
21
 
20
22
  ```typescript
21
23
  import {
24
+ parseChunkToAction,
22
25
  createMessageSegmentAccumulator,
23
- handleChatNavClick,
24
- getChatProxyAuth,
25
- getIconComponent,
26
- formatChatAttachmentMarkdownForBubble,
27
- decideNewTab,
26
+ executeNavigation,
27
+ resolveIcon,
28
28
  getStatusColorScheme,
29
- } from '@flamingo/chat-utils'
29
+ mergeHistoryWithRealtime,
30
+ formatChatAttachmentMarkdownForBubble,
31
+ } from '@openframe/chat-utils'
32
+
33
+ // Parse a streaming chunk
34
+ const action = parseChunkToAction(rawChunk)
30
35
 
31
- // Accumulate streamed message segments
36
+ // Accumulate message segments from a stream
32
37
  const accumulator = createMessageSegmentAccumulator({
33
- onSegmentComplete: (segment) => console.log('Segment:', segment),
38
+ onSegmentComplete: (segment) => console.log('Segment done:', segment),
34
39
  })
35
40
 
36
- // Resolve navigation target for a chat link
37
- const { openInNewTab } = decideNewTab({
38
- href: 'https://app.example.com/tickets/123',
39
- surface: 'chat-bubble',
40
- mode: 'web',
41
+ // Execute navigation respecting new-tab rules
42
+ executeNavigation({
43
+ href: '/tickets/123',
44
+ event: clickEvent,
45
+ surface: 'chat',
41
46
  })
42
47
 
43
- // Look up a registered icon by kebab-case key
44
- const Icon = getIconComponent('clickup')
48
+ // Resolve an icon by name
49
+ const Icon = resolveIcon('clickup')
50
+
51
+ // Get agent status color scheme
52
+ const colors = getStatusColorScheme('online')
53
+ ```
54
+
55
+ ## Source
45
56
 
46
- // Apply agent status color scheme to UI
47
- const colors = getStatusColorScheme('running')
48
- ```
57
+ [`index.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/index.ts)