@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
@@ -12,7 +12,7 @@ import { TicketDetailSection } from "./ticket-detail-section"
12
12
  import { type TicketAttachment, TicketAttachmentsList } from "./ticket-attachments-list"
13
13
  import type { TicketNote } from "./ticket-note-card"
14
14
  import { TicketNotesSection } from "./ticket-notes-section"
15
- import { SimpleMarkdownRenderer } from "./markdown/simple-markdown-renderer"
15
+ import { SimpleMarkdownRenderer } from "./simple-markdown-renderer"
16
16
 
17
17
  export type { TicketAssigneeOption }
18
18
 
@@ -183,7 +183,50 @@ export const PendingApprovalSegment: Story = {
183
183
  },
184
184
  };
185
185
 
186
- /** Every remaining segment type in one message — thinking, tool execution, context compaction, error. */
186
+ /**
187
+ * `[card://]` markers inside a `guide` segment resolve exactly as they do in a
188
+ * text segment — the host's `renderEntityCard` node is hoisted out of the
189
+ * markdown as a sibling block, and an unknown id degrades to the bare id.
190
+ * Regression guard: the guide body used to skip the marker plan entirely.
191
+ */
192
+ export const GuideWithEntityCards: Story = {
193
+ args: {
194
+ role: "assistant",
195
+ name: "Mingo",
196
+ assistantType: "mingo",
197
+ timestamp: at247(),
198
+ chatRefs: {
199
+ "onboarding_guide:first-check": {
200
+ type: "onboarding_guide",
201
+ id: "first-check",
202
+ title: "Create Your First Monitoring Check",
203
+ url: "/help-center/onboarding-guides/first-check",
204
+ },
205
+ "onboarding_guide:add-devices": {
206
+ type: "onboarding_guide",
207
+ id: "add-devices",
208
+ title: "Add Devices to a Policy",
209
+ url: "/help-center/onboarding-guides/add-devices",
210
+ },
211
+ },
212
+ renderEntityCard: (ref) =>
213
+ ref.type === "onboarding_guide" ? (
214
+ <div className="flex items-center gap-[var(--spacing-system-s)] rounded-md border border-ods-border bg-ods-card p-[var(--spacing-system-s)]">
215
+ <span className="flex-1 text-h4 text-ods-text-primary">{ref.title}</span>
216
+ <span className="text-h5 text-ods-text-secondary">Guide</span>
217
+ </div>
218
+ ) : null,
219
+ content: [
220
+ {
221
+ type: "guide",
222
+ text: "Here's how to create a monitoring policy (check) in OpenFrame:\n\n[card://onboarding_guide:first-check]\n\nStep-by-step:\n\n1. Go to Monitoring → Policies → Add Policy\n2. Write your osquery SQL query\n3. Save the policy",
223
+ },
224
+ { type: "text", text: "A plain text segment renders its own marker identically:\n\n[card://onboarding_guide:add-devices]" },
225
+ ] satisfies MessageSegment[],
226
+ },
227
+ };
228
+
229
+ /** Every remaining segment type in one message — thinking, guide, tool execution, context compaction, error. */
187
230
  export const AllSegmentTypes: Story = {
188
231
  args: {
189
232
  role: "assistant",
@@ -195,6 +238,10 @@ export const AllSegmentTypes: Story = {
195
238
  text: "The user wants Slack installed. Homebrew is present on the endpoint, so `brew install --cask slack` is the cleanest path.",
196
239
  },
197
240
  { type: "text", text: "Installing Slack now." },
241
+ {
242
+ type: "guide",
243
+ text: "Here's how to create a monitoring policy (check) in OpenFrame:\n\nStep-by-step:\n\n1. Go to Monitoring → Policies → Add Policy\n2. Give it a Name (something descriptive)\n3. Write your osquery SQL query — the query should return rows for devices that fail the check\n4. Set the interval — how often each device runs the check\n5. Save the policy",
244
+ },
198
245
  {
199
246
  type: "tool_execution",
200
247
  data: {
@@ -334,7 +334,6 @@ export * from './humanity-signals'
334
334
  export * from './doc-path-utils'
335
335
  export * from './doc-tree-nav'
336
336
  export * from './tree-builder'
337
- export * from './markdown-heading-id'
338
337
  export * from './markdown-section-extractor'
339
338
  export * from './markdown-to-plain'
340
339
  export * from './embed-url-converters'
@@ -4,12 +4,6 @@
4
4
  */
5
5
 
6
6
  import { stripInlineMarkdown } from './markdown-to-plain'
7
- import {
8
- createHeadingIdDeduper,
9
- scanHeadings,
10
- slugifyHeadingBase,
11
- stripHeadingEmojis,
12
- } from './markdown-heading-id'
13
7
 
14
8
  export interface MarkdownSection {
15
9
  id: string
@@ -44,47 +38,68 @@ export function extractSections(
44
38
  ): MarkdownSection[] {
45
39
  const opts = { ...DEFAULT_OPTIONS, ...options }
46
40
  const sections: MarkdownSection[] = []
47
- const dedupe = createHeadingIdDeduper()
48
-
49
- // ONE scanner, shared with the renderer's heading-id map
50
- // (utils/markdown-heading-id.ts). This file used to carry its own
51
- // line loop — `line.startsWith('```')` for fences (blind to `~~~`, to
52
- // longer backtick runs and to the CommonMark 0..3-space indent) and a
53
- // bare `line === '---'` YAML toggle (which a mid-document thematic break
54
- // or setext underline tripped, swallowing every heading after it). Both
55
- // produced sections the renderer emitted no id for.
56
- const scanned = scanHeadings(markdown, {
57
- skipFrontmatter: opts.skipCodeAndYamlBlocks,
58
- skipFences: opts.skipCodeAndYamlBlocks,
59
- })
60
-
61
- for (const heading of scanned) {
62
- if (heading.level > opts.maxLevel) continue
63
-
64
- let title = heading.text
41
+ const lines = markdown.split('\n')
42
+ const idCounts: Record<string, number> = {}
43
+
44
+ let inCodeBlock = false
45
+ let inYamlBlock = false
46
+
47
+ for (const line of lines) {
48
+ if (opts.skipCodeAndYamlBlocks) {
49
+ if (line.startsWith('```')) {
50
+ inCodeBlock = !inCodeBlock
51
+ continue
52
+ }
53
+ if (line === '---') {
54
+ inYamlBlock = !inYamlBlock
55
+ continue
56
+ }
57
+ if (inCodeBlock || inYamlBlock) continue
58
+ }
59
+
60
+ const pattern = new RegExp(`^(#{1,${opts.maxLevel}})\\s+(.+)`)
61
+ const match = line.match(pattern)
62
+ if (!match) continue
63
+
64
+ const level = match[1].length
65
+ if (level > opts.maxLevel) continue
66
+
67
+ let title = match[2].trim()
68
+
65
69
  if (opts.stripFormattingMarkers) {
66
70
  title = stripInlineMarkdown(title).trim()
67
71
  }
68
72
 
69
- // Slug chain SSOT — shared with the renderers' heading-id generator
70
- // (see utils/markdown-heading-id.ts). Extractor and renderers MUST
71
- // agree or deep-link anchors silently diverge.
72
- const baseId = slugifyHeadingBase(
73
- opts.removeEmojis ? stripHeadingEmojis(title) : title,
74
- )
75
-
76
- // Symbol-only heading fallback: the 1-based ordinal among the headings
77
- // this extractor EMITS (levels ≤ maxLevel). The renderer's heading-id
78
- // generator mirrors this exact counter for levels ≤ 2
79
- // (components/ui/markdown/heading-ids.ts) — the two must agree or
80
- // deep-link anchors diverge for symbol-only headings.
73
+ let baseId = title
74
+
75
+ if (opts.removeEmojis) {
76
+ baseId = baseId
77
+ .replace(
78
+ /[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]/gu,
79
+ '',
80
+ )
81
+ .trim()
82
+ }
83
+
84
+ baseId = baseId
85
+ .toLowerCase()
86
+ .replace(/[^\w\s-]/g, '')
87
+ .replace(/\s+/g, '-')
88
+ .replace(/^-+|-+$/g, '')
89
+
81
90
  const cleanId = baseId || `section-${sections.length + 1}`
82
91
 
83
- sections.push({
84
- id: opts.handleDuplicateIds ? dedupe(cleanId) : cleanId,
85
- title,
86
- level: heading.level,
87
- })
92
+ let id = cleanId
93
+ if (opts.handleDuplicateIds) {
94
+ if (idCounts[cleanId]) {
95
+ idCounts[cleanId]++
96
+ id = `${cleanId}-${idCounts[cleanId]}`
97
+ } else {
98
+ idCounts[cleanId] = 1
99
+ }
100
+ }
101
+
102
+ sections.push({ id, title, level })
88
103
  }
89
104
 
90
105
  return sections
@@ -1,58 +0,0 @@
1
- /**
2
- * SSE wire-protocol decoder — a timer-free synchronous state machine,
3
- * mechanically extracted from `useSseChatAdapter`'s inline
4
- * `createDocStreamFn` parser. Byte-for-byte behavior parity with the
5
- * legacy parser is the contract (the golden fixtures in
6
- * `src/components/chat/hooks/__tests__/sse-stream-golden.test.ts` pin it
7
- * through the full hook path), including its quirks:
8
- *
9
- * - A leading `\0`-terminated block that fails JSON.parse flips the
10
- * stream into text mode and the WHOLE buffer (including the `\0`)
11
- * is emitted as answer text (legacy no-frame stream fallback). This
12
- * transition is marked `turn-start { implicit: true }`.
13
- * - In text mode only `\x1F` is scanned — literal `\0` / `\x1E` bytes
14
- * pass through into the answer; the FIRST literal `\x1F` flips into
15
- * trailer mode and everything after is captured as the trailer
16
- * (golden fixture (d) characterizes this mis-framing; the fix lives
17
- * in `encode.ts`'s sentinel stripping, NOT here).
18
- * - The `\x1E` sentinel and the `\x1F` trailer can arrive in ONE TCP
19
- * chunk (fixed-answer responses) — the post-sentinel slice is
20
- * re-scanned for the trailer sentinel.
21
- * - Multi-byte UTF-8 across chunk boundaries survives via a single
22
- * streaming TextDecoder (`{ stream: true }` on every push; no final
23
- * flush — a trailing partial code point is dropped, as legacy did).
24
- * - `end()` parses the accumulated trailer (malformed → silently
25
- * ignored) and drops any un-terminated leading buffer, as legacy did.
26
- * It is IDEMPOTENT (a deliberate deviation from legacy): repeat calls
27
- * emit nothing, so an adapter that ends in both its completion path
28
- * and its `finally` cannot double-count the usage frame.
29
- *
30
- * State flow: leading → (sentinel | parse-failure) → text → (\x1F) →
31
- * trailer-accumulate → end().
32
- *
33
- * Server-safe: no React, no timers, TextDecoder only.
34
- */
35
- import type { ChatStreamEvent } from './events';
36
- export interface SseFrameDecoder {
37
- /** Feed raw response bytes; returns the events they produced. */
38
- push(bytes: Uint8Array): ChatStreamEvent[];
39
- /**
40
- * Signal end-of-stream; parses the trailing usage frame if present.
41
- * IDEMPOTENT — every call after the first returns `[]`. Adapters
42
- * routinely call this from BOTH their completion path and a `finally`,
43
- * and a re-emitted `usage`/`stage:'end'` event would double-count token
44
- * usage (displayed cost doubles).
45
- */
46
- end(): ChatStreamEvent[];
47
- }
48
- /**
49
- * Escape `<` so markdown renderers that pass HTML through (rehypeRaw)
50
- * don't treat XML-like tokens in Claude's thinking output as elements.
51
- * `<` → `&lt;` preserves the visible character without breaking
52
- * blockquote `>` markers. Per-character, so it distributes over
53
- * concatenation: escape(a + b) === escape(a) + escape(b) — callers may
54
- * apply it per-delta or on the accumulated string interchangeably.
55
- */
56
- export declare function escapeThinkingTags(text: string): string;
57
- export declare function createSseFrameDecoder(): SseFrameDecoder;
58
- //# sourceMappingURL=decode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,EAAE,CAAA;IAC1C;;;;;;OAMG;IACH,GAAG,IAAI,eAAe,EAAE,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAqGD,wBAAgB,qBAAqB,IAAI,eAAe,CAmHvD"}
@@ -1,44 +0,0 @@
1
- /**
2
- * SSE wire-protocol encoders — the emit side of the framing contract in
3
- * `./frames.ts`. Server-safe (TextEncoder only). The hub's stream route
4
- * consumes these so emitter and decoder can never drift.
5
- */
6
- import { type SseLeadingFrame, type SseTrailingUsageFrame } from './frames';
7
- /**
8
- * Remove the SSE framing sentinel bytes (`\0`, `\x1E`, `\x1F`) from model
9
- * text. Exported as a STANDALONE helper — not just folded into
10
- * `encodeTextDelta` — because producers must strip at the point where they
11
- * first take custody of the text, BEFORE any local accumulation.
12
- *
13
- * Concretely: the hub's `claude-util.ts` accumulates `state.answerText` for
14
- * persistence + telemetry. If stripping only happened at encode time, the
15
- * persisted/telemetered answer would diverge, character for character, from
16
- * the bytes the user actually received whenever the model echoes a control
17
- * byte. Both sides call this, so there is exactly ONE definition of "which
18
- * bytes are framing" in the whole system — do not re-declare the regex.
19
- *
20
- * Idempotent and per-character, so it distributes over concatenation:
21
- * `strip(a + b) === strip(a) + strip(b)` — safe to apply per-delta or on the
22
- * accumulated string interchangeably.
23
- */
24
- export declare function stripSentinelBytes(text: string): string;
25
- /** Encode one leading frame: JSON + `\0` terminator. */
26
- export declare function encodeLeadingFrame(frame: SseLeadingFrame): Uint8Array;
27
- /** Encode the single `\x1E` end-of-leading-frames sentinel. */
28
- export declare function encodeEndOfLeading(): Uint8Array;
29
- /**
30
- * Encode a raw answer-text delta. STRIPS the framing sentinel bytes via
31
- * `stripSentinelBytes` so model-echoed control bytes can no longer
32
- * mis-frame the stream (a literal `\x1F` in the answer used to flip the
33
- * client into trailer mode and swallow the rest of the answer PLUS the real
34
- * usage trailer — characterized by golden fixture (d)). Forward-looking
35
- * encoder fix only; the decoder's behavior is unchanged.
36
- *
37
- * Producers that ALSO accumulate the text locally (persistence, telemetry)
38
- * must call `stripSentinelBytes` on their own copy — see its docblock.
39
- */
40
- export declare function encodeTextDelta(text: string): Uint8Array;
41
- /** Encode the trailing usage frame: `\x1F` + JSON, no terminator
42
- * (runs to stream end). */
43
- export declare function encodeTrailingUsageFrame(frame: SseTrailingUsageFrame): Uint8Array;
44
- //# sourceMappingURL=encode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/encode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAA;AAQjB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CAErE;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,IAAI,UAAU,CAE/C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAExD;AAED;4BAC4B;AAC5B,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,qBAAqB,GAAG,UAAU,CAEjF"}
@@ -1,35 +0,0 @@
1
- /**
2
- * `envFlagEnabled` — THE cross-repo predicate for reading a boolean env flag.
3
- *
4
- * WHY IT LIVES HERE: the same flag is read on BOTH sides of the guide-chat
5
- * seam and each side had grown its own reading of it. The hub parsed the
6
- * value (`'0'` / `'false'` / `'off'` mean OFF); the producing app used bare
7
- * `Boolean(process.env.X)`, under which every non-empty string — including
8
- * `'0'` and `'false'` — is TRUE.
9
- *
10
- * That divergence failed OPEN on the one flag that gates a security boundary.
11
- * `TRUSTED_INGRESS_SETS_REAL_IP` is an operator's assertion that a reverse
12
- * proxy OVERWRITES the client-IP headers; without it those headers are
13
- * attacker-writable and must not be read. An operator writing `=0` to mean
14
- * "off" got the hub honoring that while the producer read `x-real-ip` /
15
- * `x-forwarded-for` anyway and forwarded the value as `x-chat-ip`, which the
16
- * hub then trusts verbatim under the service token. A rate-limit-bucket
17
- * spoof, reachable through a plausible operator typo.
18
- *
19
- * Both repos already depend on this package and `./chat-protocol` is its
20
- * server-safe subpath (no React, no browser APIs), so this is the one place
21
- * both sides can share — same reasoning that moved `normalizeIpForBucketKey`
22
- * here. Keep it as ONE definition: a second copy is what caused the drift.
23
- *
24
- * Contract:
25
- * - unset, empty, or whitespace-only → `false`;
26
- * - `'0'`, `'false'`, `'off'` → `false` (case- and
27
- * surrounding-whitespace-insensitive);
28
- * - any other non-empty value → `true`.
29
- *
30
- * `process.env` is read PER CALL, never module-hoisted, so tests, preview and
31
- * prod all observe the live value rather than whatever was present at
32
- * module-eval time.
33
- */
34
- export declare function envFlagEnabled(name: string): boolean;
35
- //# sourceMappingURL=env-flag.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"env-flag.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/env-flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKpD"}
@@ -1,196 +0,0 @@
1
- /**
2
- * Normalized chat stream events — the transport-agnostic event union BOTH
3
- * decoders (SSE byte framing in `./decode.ts`, NATS chunks in
4
- * `./nats-decoder.ts`) emit. Phase 3 of the chat unification makes the
5
- * reducer consume these directly; today the SSE adapter maps them back to
6
- * legacy `MessageSegment` yields.
7
- *
8
- * Server-safe: no React, no browser APIs.
9
- */
10
- import type { ApprovalRequestField, DecisionResolvedFrame, UsageTelemetry } from './frames';
11
- /** Optional envelope on every event. `seq` carries the transport's
12
- * stream sequence (JetStream `streamSeq` on NATS; unused on SSE). */
13
- interface ChatStreamEventBase {
14
- seq?: number;
15
- }
16
- /** Stream entered answer-text mode (SSE: the `\x1E` sentinel or the
17
- * JSON-parse-failure fallback; NATS: MESSAGE_START).
18
- * `implicit` is true ONLY for the SSE fallback path where a
19
- * non-JSON leading buffer flips straight into text mode — consumers
20
- * that flush coalesced thinking on turn-start must SKIP the flush for
21
- * implicit starts (legacy adapter parity: the fallback path never
22
- * flushed pending thinking before the text). */
23
- export interface TurnStartEvent extends ChatStreamEventBase {
24
- type: 'turn-start';
25
- implicit?: boolean;
26
- }
27
- export interface TurnEndEvent extends ChatStreamEventBase {
28
- type: 'turn-end';
29
- }
30
- /** Answer text delta. `leading: true` marks SSE `text-leading` frames
31
- * (model preamble prose emitted BEFORE the tool approval card). */
32
- export interface TextDeltaEvent extends ChatStreamEventBase {
33
- type: 'text-delta';
34
- text: string;
35
- leading?: boolean;
36
- }
37
- /** Thinking delta — APPEND-ONLY contract: each event carries the next
38
- * verbatim slice; consumers accumulate. Decoders never diff. */
39
- export interface ThinkingDeltaEvent extends ChatStreamEventBase {
40
- type: 'thinking-delta';
41
- text: string;
42
- }
43
- export interface StatusEvent extends ChatStreamEventBase {
44
- type: 'status';
45
- phase: 'thinking';
46
- }
47
- /** NATS tool execution progress (EXECUTING_TOOL / EXECUTED_TOOL). */
48
- export interface ToolExecutionEvent extends ChatStreamEventBase {
49
- type: 'tool-execution';
50
- data: {
51
- type: 'EXECUTING_TOOL' | 'EXECUTED_TOOL';
52
- integratedToolType: string;
53
- toolFunction: string;
54
- toolTitle?: string;
55
- parameters?: Record<string, unknown>;
56
- result?: string;
57
- success?: boolean;
58
- toolExecutionRequestId?: string;
59
- };
60
- }
61
- /** Single tool call inside a batch approval request (NATS). */
62
- export interface ApprovalToolCall {
63
- toolExecutionRequestId: string;
64
- toolName: string;
65
- toolTitle?: string;
66
- toolExplanation?: string;
67
- toolType?: string;
68
- requiresApproval: boolean;
69
- approvalType?: string | null;
70
- toolCallArguments?: Record<string, unknown> | null;
71
- }
72
- /** A tool call awaits user approval. SSE fills `command`/`fields`
73
- * (card-ready payload); NATS fills `command`/`explanation` or
74
- * `toolCalls` (batch form). */
75
- export interface ApprovalRequestEvent extends ChatStreamEventBase {
76
- type: 'approval-request';
77
- requestId: string;
78
- /** SSE: the write tool's name. NATS: approval tier (USER/ADMIN/…). */
79
- approvalType?: string;
80
- command?: string;
81
- explanation?: string;
82
- fields?: ApprovalRequestField[];
83
- toolCalls?: ApprovalToolCall[];
84
- status?: 'pending';
85
- }
86
- /** An approval request was resolved (SSE `decision_resolved` frame /
87
- * NATS APPROVAL_RESULT chunk). */
88
- export interface ApprovalResolvedEvent extends ChatStreamEventBase {
89
- type: 'approval-resolved';
90
- requestId?: string;
91
- status: 'approved' | 'rejected';
92
- ok?: boolean;
93
- toolName?: string;
94
- approvalType?: string;
95
- resolvedByName?: string | null;
96
- receiptText?: string;
97
- /** Inline post-approve card: the ref payload + its documentType +
98
- * the `[card://…]` marker (SSE only). */
99
- cardRef?: unknown;
100
- cardType?: string;
101
- marker?: string;
102
- result?: DecisionResolvedFrame['result'];
103
- willAutoContinue?: boolean;
104
- }
105
- /** Per-turn metadata. Raw wire values pass through UNVALIDATED — the
106
- * consumer replicates the legacy truthiness/typeof gates (so a
107
- * malformed frame degrades identically to the pre-SSOT parser). */
108
- export interface ChatMetadataEvent extends ChatStreamEventBase {
109
- type: 'metadata';
110
- provider?: string | null;
111
- modelLabel?: string | null;
112
- /** Raw model id (SSE `meta.model`; NATS `modelName`). */
113
- modelName?: string | null;
114
- contextWindowMaxTokens?: number | null;
115
- sources?: unknown;
116
- refs?: unknown;
117
- scrollAnchor?: unknown;
118
- /** Server-minted conversation id (`ChatMetadataFrame.conversationId`),
119
- * passed through raw like every other catch-all field — the consumer
120
- * applies the `typeof === 'string' && truthy` gate. */
121
- conversationId?: string | null;
122
- routing?: {
123
- routedComplexity: string;
124
- routedModel?: string;
125
- routedThinkingBudget: number | null;
126
- };
127
- }
128
- /** SSE usage frames — raw wire keys (snake_case) preserved. */
129
- export interface UsageEvent extends ChatStreamEventBase {
130
- type: 'usage';
131
- stage: 'start' | 'end';
132
- input_tokens?: number;
133
- output_tokens?: number;
134
- cache_read_input_tokens?: number;
135
- cache_creation_input_tokens?: number;
136
- hit_rate_pct?: number;
137
- telemetry?: UsageTelemetry;
138
- /** Left OPAQUE on purpose: the consumer (`chat-stream-reducer`'s
139
- * `applySseUsage`) re-validates every nested field with the legacy
140
- * truthiness/typeof gates, so a malformed frame degrades identically
141
- * to the pre-SSOT parser. Typing it would imply guarantees the wire
142
- * does not make. */
143
- breakdown?: unknown;
144
- debug?: unknown;
145
- }
146
- /** NATS TOKEN_USAGE chunk (camelCase backend shape). */
147
- export interface TokenUsageEvent extends ChatStreamEventBase {
148
- type: 'token-usage';
149
- inputTokensSize: number;
150
- outputTokensSize: number;
151
- totalTokensSize: number;
152
- contextSize: number;
153
- }
154
- export interface CompactionEvent extends ChatStreamEventBase {
155
- type: 'compaction';
156
- phase: 'start' | 'end';
157
- summary?: string;
158
- }
159
- export interface ErrorEvent extends ChatStreamEventBase {
160
- type: 'error';
161
- title: string;
162
- details?: string;
163
- }
164
- /** Non-assistant message on the stream (NATS): the user's own message
165
- * echo (`message-request`), an operator direct message, or a system
166
- * line. */
167
- /**
168
- * Dialog participant owner type. The two members below are the ones clients
169
- * BRANCH ON (admin-vs-not decides echo dedup and author styling); the union
170
- * stays open (`string & {}`) because the wire may carry other roles that the
171
- * client treats as "not admin". Always compare against `CHAT_OWNER_ADMIN`,
172
- * never a bare `'ADMIN'` literal — a typo in a literal silently disables
173
- * dedup instead of failing to compile.
174
- */
175
- export type ChatOwnerType = 'ADMIN' | 'CLIENT' | (string & {});
176
- /** Canonical ADMIN owner-type token (see `ChatOwnerType`). */
177
- export declare const CHAT_OWNER_ADMIN = "ADMIN";
178
- export interface ParticipantEvent extends ChatStreamEventBase {
179
- type: 'participant';
180
- kind: 'message-request' | 'direct-message' | 'system';
181
- text: string;
182
- ownerType?: ChatOwnerType;
183
- displayName?: string;
184
- userId?: string;
185
- contextItems?: Array<{
186
- type: string;
187
- id: string;
188
- label: string;
189
- }>;
190
- }
191
- export interface DialogClosedEvent extends ChatStreamEventBase {
192
- type: 'dialog-closed';
193
- }
194
- export type ChatStreamEvent = TurnStartEvent | TurnEndEvent | TextDeltaEvent | ThinkingDeltaEvent | StatusEvent | ToolExecutionEvent | ApprovalRequestEvent | ApprovalResolvedEvent | ChatMetadataEvent | UsageEvent | TokenUsageEvent | CompactionEvent | ErrorEvent | ParticipantEvent | DialogClosedEvent;
195
- export {};
196
- //# sourceMappingURL=events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACf,MAAM,UAAU,CAAA;AAEjB;sEACsE;AACtE,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;iDAMiD;AACjD,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,IAAI,EAAE,UAAU,CAAA;CACjB;AAED;oEACoE;AACpE,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,IAAI,EAAE,YAAY,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;iEACiE;AACjE,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,IAAI,EAAE,gBAAgB,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,mBAAmB;IACtD,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,IAAI,EAAE,gBAAgB,CAAA;IACtB,IAAI,EAAE;QACJ,IAAI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