@flamingo-stack/openframe-frontend-core 0.0.489 → 0.0.490-1506.3944.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-protocol/decode.d.ts +58 -0
- package/dist/chat-protocol/decode.d.ts.map +1 -0
- package/dist/chat-protocol/encode.d.ts +44 -0
- package/dist/chat-protocol/encode.d.ts.map +1 -0
- package/dist/chat-protocol/env-flag.d.ts +35 -0
- package/dist/chat-protocol/env-flag.d.ts.map +1 -0
- package/dist/chat-protocol/events.d.ts +196 -0
- package/dist/chat-protocol/events.d.ts.map +1 -0
- package/dist/chat-protocol/frames.d.ts +213 -0
- package/dist/chat-protocol/frames.d.ts.map +1 -0
- package/dist/chat-protocol/index.cjs +494 -0
- package/dist/chat-protocol/index.cjs.map +1 -0
- package/dist/chat-protocol/index.d.ts +18 -0
- package/dist/chat-protocol/index.d.ts.map +1 -0
- package/dist/chat-protocol/index.js +478 -0
- package/dist/chat-protocol/index.js.map +1 -0
- package/dist/chat-protocol/ip-normalize.d.ts +44 -0
- package/dist/chat-protocol/ip-normalize.d.ts.map +1 -0
- package/dist/chat-protocol/nats-decoder.d.ts +26 -0
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -0
- package/dist/{chunk-K7MNWYYI.js → chunk-4NWARV5I.js} +2 -2
- package/dist/{chunk-2RNJYJWO.cjs → chunk-5CJR2GZ4.cjs} +31 -31
- package/dist/{chunk-2RNJYJWO.cjs.map → chunk-5CJR2GZ4.cjs.map} +1 -1
- package/dist/{chunk-H3YRJ3LZ.cjs → chunk-5EYRXSY5.cjs} +9 -9
- package/dist/{chunk-H3YRJ3LZ.cjs.map → chunk-5EYRXSY5.cjs.map} +1 -1
- package/dist/{chunk-IN4IO7BL.cjs → chunk-5LMGFI4J.cjs} +6930 -4755
- package/dist/chunk-5LMGFI4J.cjs.map +1 -0
- package/dist/{chunk-YMJZOANX.js → chunk-BE6DK7QY.js} +12228 -10053
- package/dist/chunk-BE6DK7QY.js.map +1 -0
- package/dist/{chunk-TWGYBXYV.js → chunk-CORIBKHG.js} +2 -2
- package/dist/{chunk-RO7Q56ZK.cjs → chunk-CSYSYJCF.cjs} +37 -37
- package/dist/{chunk-RO7Q56ZK.cjs.map → chunk-CSYSYJCF.cjs.map} +1 -1
- package/dist/{chunk-Z7Y63IFU.cjs → chunk-DSDZ5T4P.cjs} +5 -5
- package/dist/{chunk-Z7Y63IFU.cjs.map → chunk-DSDZ5T4P.cjs.map} +1 -1
- package/dist/{chunk-EU6QNO4S.js → chunk-GTWO5NAY.js} +2 -2
- package/dist/{chunk-BGWDDB7Y.js → chunk-HSACATCD.js} +2 -2
- package/dist/{chunk-3OIB763B.cjs → chunk-NWX7MMF5.cjs} +15 -15
- package/dist/{chunk-3OIB763B.cjs.map → chunk-NWX7MMF5.cjs.map} +1 -1
- package/dist/{chunk-J7H32E3R.cjs → chunk-P4WTZU6L.cjs} +11 -11
- package/dist/{chunk-J7H32E3R.cjs.map → chunk-P4WTZU6L.cjs.map} +1 -1
- package/dist/{chunk-VLOE7MI2.cjs → chunk-Q6E7VJ4W.cjs} +28 -27
- package/dist/chunk-Q6E7VJ4W.cjs.map +1 -0
- package/dist/{chunk-ZIAS5NNL.cjs → chunk-QSCHCZL3.cjs} +7 -7
- package/dist/{chunk-ZIAS5NNL.cjs.map → chunk-QSCHCZL3.cjs.map} +1 -1
- package/dist/{chunk-VL4LUO32.js → chunk-RQLBHKXN.js} +2 -2
- package/dist/{chunk-5YMY4BAW.cjs → chunk-S2NHJDKQ.cjs} +62 -62
- package/dist/{chunk-5YMY4BAW.cjs.map → chunk-S2NHJDKQ.cjs.map} +1 -1
- package/dist/{chunk-N4MTNTSX.js → chunk-T2EGSZFN.js} +6 -5
- package/dist/chunk-T2EGSZFN.js.map +1 -0
- package/dist/{chunk-W6ZUOWSB.js → chunk-TKN5667N.js} +10 -10
- package/dist/chunk-TKN5667N.js.map +1 -0
- package/dist/{chunk-B4YR342L.js → chunk-UUYRJPGJ.js} +4 -4
- package/dist/{chunk-FKPXFTZT.js → chunk-VHG6AX5V.js} +2 -2
- package/dist/{chunk-2IHN7NNB.cjs → chunk-VQ523ORK.cjs} +26 -26
- package/dist/{chunk-2IHN7NNB.cjs.map → chunk-VQ523ORK.cjs.map} +1 -1
- package/dist/{chunk-X2YF5TJS.js → chunk-XQ2B74SI.js} +2 -2
- package/dist/{chunk-LLEDO4P7.cjs → chunk-YHOIAA2E.cjs} +60 -60
- package/dist/chunk-YHOIAA2E.cjs.map +1 -0
- package/dist/{chunk-5VSEMWWE.js → chunk-YZ2OIYQ3.js} +4 -4
- package/dist/components/case-studies/index.cjs +8 -8
- package/dist/components/case-studies/index.js +2 -2
- package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/hooks/index.d.ts +0 -1
- package/dist/components/chat/hooks/index.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +15 -48
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +10 -57
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +10 -2
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.d.ts +1 -0
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/index.js +21 -13
- package/dist/components/chat/stream/chat-dialog-store.d.ts +184 -0
- package/dist/components/chat/stream/chat-dialog-store.d.ts.map +1 -0
- package/dist/components/chat/stream/chat-stream-reducer.d.ts +367 -0
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -0
- package/dist/components/chat/stream/delta-batcher.d.ts +51 -0
- package/dist/components/chat/stream/delta-batcher.d.ts.map +1 -0
- package/dist/components/chat/stream/index.d.ts +17 -0
- package/dist/components/chat/stream/index.d.ts.map +1 -0
- package/dist/components/chat/stream/message-mutations.d.ts +77 -0
- package/dist/components/chat/stream/message-mutations.d.ts.map +1 -0
- package/dist/components/chat/stream/use-chat-stream-reducer.d.ts +22 -0
- package/dist/components/chat/stream/use-chat-stream-reducer.d.ts.map +1 -0
- package/dist/components/chat/types/api.types.d.ts +1 -81
- package/dist/components/chat/types/api.types.d.ts.map +1 -1
- package/dist/components/chat/types/processing.types.d.ts +2 -90
- package/dist/components/chat/types/processing.types.d.ts.map +1 -1
- package/dist/components/chat/utils/extract-incomplete-message-state.d.ts +34 -6
- package/dist/components/chat/utils/extract-incomplete-message-state.d.ts.map +1 -1
- package/dist/components/chat/utils/index.d.ts +2 -3
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/chat/utils/process-historical-messages.d.ts +59 -11
- package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +3 -3
- package/dist/components/contact/index.js +2 -2
- package/dist/components/docs/index.cjs +5 -5
- package/dist/components/docs/index.js +4 -4
- package/dist/components/embeds/index.cjs +3 -3
- package/dist/components/embeds/index.js +2 -2
- package/dist/components/faq/index.cjs +3 -3
- package/dist/components/faq/index.js +2 -2
- package/dist/components/features/index.cjs +2 -2
- package/dist/components/features/index.js +1 -1
- package/dist/components/help-center-pages/index.cjs +20 -20
- package/dist/components/help-center-pages/index.js +11 -11
- package/dist/components/index.cjs +172 -130
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +63 -21
- package/dist/components/index.js.map +1 -1
- package/dist/components/navigation/index.cjs +2 -2
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/onboarding-guides/index.cjs +5 -5
- package/dist/components/onboarding-guides/index.js +4 -4
- package/dist/components/onboarding-guides/onboarding-guide-detail-view.d.ts.map +1 -1
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/shared/product-release/release-detail-page.d.ts.map +1 -1
- package/dist/components/tickets/index.cjs +5 -5
- package/dist/components/tickets/index.js +4 -4
- package/dist/components/ui/index.cjs +44 -2
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.d.ts +1 -2
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +55 -13
- package/dist/components/ui/markdown/base-components.d.ts +51 -0
- package/dist/components/ui/markdown/base-components.d.ts.map +1 -0
- package/dist/components/ui/markdown/engine.d.ts +99 -0
- package/dist/components/ui/markdown/engine.d.ts.map +1 -0
- package/dist/components/ui/markdown/heading-ids.d.ts +65 -0
- package/dist/components/ui/markdown/heading-ids.d.ts.map +1 -0
- package/dist/components/ui/markdown/index.d.ts +18 -0
- package/dist/components/ui/markdown/index.d.ts.map +1 -0
- package/dist/components/ui/markdown/mermaid-diagram.d.ts +79 -0
- package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -0
- package/dist/components/ui/markdown/rich/embed-overrides.d.ts +14 -0
- package/dist/components/ui/markdown/rich/embed-overrides.d.ts.map +1 -0
- package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts +40 -0
- package/dist/components/ui/markdown/rich/rich-markdown-renderer.d.ts.map +1 -0
- package/dist/components/ui/markdown/rich/shortcodes.d.ts +8 -0
- package/dist/components/ui/markdown/rich/shortcodes.d.ts.map +1 -0
- package/dist/components/ui/markdown/sanitize.d.ts +153 -0
- package/dist/components/ui/markdown/sanitize.d.ts.map +1 -0
- package/dist/components/ui/markdown/simple-markdown-renderer.d.ts +23 -0
- package/dist/components/ui/markdown/simple-markdown-renderer.d.ts.map +1 -0
- package/dist/components/ui/markdown/streaming.d.ts +78 -0
- package/dist/components/ui/markdown/streaming.d.ts.map +1 -0
- package/dist/components/ui/markdown/text-size.d.ts +34 -0
- package/dist/components/ui/markdown/text-size.d.ts.map +1 -0
- package/dist/index.cjs +60 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -13
- package/dist/utils/index.cjs +169 -40
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +162 -41
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/markdown-fences.d.ts +42 -0
- package/dist/utils/markdown-fences.d.ts.map +1 -0
- package/dist/utils/markdown-heading-id.d.ts +85 -0
- package/dist/utils/markdown-heading-id.d.ts.map +1 -0
- package/dist/utils/markdown-section-extractor.d.ts.map +1 -1
- package/package.json +7 -1
- package/src/chat-protocol/__tests__/__snapshots__/nats-decoder-golden.test.ts.snap +307 -0
- package/src/chat-protocol/__tests__/chat-protocol.test.ts +516 -0
- package/src/chat-protocol/__tests__/env-flag.test.ts +52 -0
- package/src/chat-protocol/__tests__/ip-normalize.test.ts +136 -0
- package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +228 -0
- package/src/chat-protocol/decode.ts +278 -0
- package/src/chat-protocol/encode.ts +71 -0
- package/src/chat-protocol/env-flag.ts +39 -0
- package/src/chat-protocol/events.ts +232 -0
- package/src/chat-protocol/frames.ts +245 -0
- package/src/chat-protocol/index.ts +21 -0
- package/src/chat-protocol/ip-normalize.ts +146 -0
- package/src/chat-protocol/nats-decoder.ts +252 -0
- package/src/components/chat/__tests__/chat-message-list.test.tsx +293 -5
- package/src/components/chat/__tests__/chat-message-streaming-memo.test.tsx +207 -0
- package/src/components/chat/__tests__/chat-pending-turn.test.tsx +209 -0
- package/src/components/chat/chat-message-enhanced.tsx +111 -17
- package/src/components/chat/chat-message-list.tsx +358 -109
- package/src/components/chat/embeddable-chat.tsx +6 -0
- package/src/components/chat/hooks/.index.md +30 -33
- package/src/components/chat/hooks/.use-nats-chat-adapter.md +36 -55
- package/src/components/chat/hooks/__tests__/__snapshots__/conversation-id-persistence-golden.test.ts.snap +37 -0
- package/src/components/chat/hooks/__tests__/__snapshots__/sse-stream-golden.test.ts.snap +0 -0
- package/src/components/chat/hooks/__tests__/conversation-id-persistence-golden.test.ts +438 -0
- package/src/components/chat/hooks/__tests__/sse-stream-golden.test.ts +318 -0
- package/src/components/chat/hooks/index.ts +0 -1
- package/src/components/chat/hooks/use-chat.ts +8 -0
- package/src/components/chat/hooks/use-nats-chat-adapter.ts +243 -823
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +380 -684
- package/src/components/chat/index.ts +5 -0
- package/src/components/chat/stream/__tests__/__snapshots__/chat-stream-reducer-golden.test.ts.snap +940 -0
- package/src/components/chat/stream/__tests__/chat-dialog-store.test.ts +756 -0
- package/src/components/chat/stream/__tests__/chat-stream-reducer-golden.test.ts +460 -0
- package/src/components/chat/stream/__tests__/chat-stream-reducer.test.ts +894 -0
- package/src/components/chat/stream/__tests__/delta-batcher.test.ts +255 -0
- package/src/components/chat/stream/__tests__/use-chat-stream-reducer.test.ts +98 -0
- package/src/components/chat/stream/chat-dialog-store.ts +536 -0
- package/src/components/chat/stream/chat-stream-reducer.ts +1796 -0
- package/src/components/chat/stream/delta-batcher.ts +159 -0
- package/src/components/chat/stream/index.ts +55 -0
- package/src/components/chat/stream/message-mutations.ts +338 -0
- package/src/components/chat/stream/use-chat-stream-reducer.ts +126 -0
- package/src/components/chat/thinking-display.tsx +1 -1
- package/src/components/chat/types/.api.types.md +39 -49
- package/src/components/chat/types/.processing.types.md +29 -58
- package/src/components/chat/types/api.types.ts +6 -73
- package/src/components/chat/types/processing.types.ts +11 -52
- package/src/components/chat/utils/.index.md +31 -40
- package/src/components/chat/utils/__tests__/__snapshots__/process-historical-messages-golden.test.ts.snap +420 -0
- package/src/components/chat/utils/__tests__/__snapshots__/segment-accumulator-golden.test.ts.snap +605 -0
- package/src/components/chat/utils/__tests__/process-historical-messages-golden.test.ts +317 -0
- package/src/components/chat/utils/__tests__/segment-accumulator-golden.test.ts +270 -0
- package/src/components/chat/utils/extract-incomplete-message-state.ts +63 -5
- package/src/components/chat/utils/index.ts +5 -8
- package/src/components/chat/utils/process-historical-messages.ts +352 -384
- package/src/components/onboarding-guides/onboarding-guide-detail-view.tsx +22 -4
- package/src/components/shared/legal-document/legal-document-page.tsx +1 -1
- package/src/components/shared/product-release/release-detail-page.tsx +19 -4
- package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +2420 -0
- package/src/components/ui/__tests__/markdown-parity.test.tsx +2528 -0
- package/src/components/ui/index.ts +1 -2
- package/src/components/ui/markdown/__tests__/mermaid-security.test.ts +115 -0
- package/src/components/ui/markdown/__tests__/mermaid-stale-render.test.tsx +95 -0
- package/src/components/ui/markdown/__tests__/sanitize-invariant.test.ts +309 -0
- package/src/components/ui/markdown/__tests__/streaming.test.tsx +388 -0
- package/src/components/ui/markdown/base-components.tsx +360 -0
- package/src/components/ui/markdown/engine.tsx +315 -0
- package/src/components/ui/markdown/heading-ids.ts +239 -0
- package/src/components/ui/markdown/index.ts +49 -0
- package/src/components/ui/markdown/mermaid-diagram.tsx +291 -0
- package/src/components/ui/markdown/rich/embed-overrides.tsx +199 -0
- package/src/components/ui/markdown/rich/rich-markdown-renderer.tsx +184 -0
- package/src/components/ui/markdown/rich/shortcodes.ts +170 -0
- package/src/components/ui/markdown/sanitize.ts +3499 -0
- package/src/components/ui/markdown/simple-markdown-renderer.tsx +28 -0
- package/src/components/ui/markdown/streaming.ts +362 -0
- package/src/components/ui/markdown/text-size.ts +106 -0
- package/src/components/ui/release-changelog-section.tsx +1 -1
- package/src/components/ui/ticket-info-section.tsx +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/markdown-fences.ts +127 -0
- package/src/utils/markdown-heading-id.ts +348 -0
- package/src/utils/markdown-section-extractor.ts +41 -56
- package/dist/chunk-IN4IO7BL.cjs.map +0 -1
- package/dist/chunk-LLEDO4P7.cjs.map +0 -1
- package/dist/chunk-N4MTNTSX.js.map +0 -1
- package/dist/chunk-VLOE7MI2.cjs.map +0 -1
- package/dist/chunk-W6ZUOWSB.js.map +0 -1
- package/dist/chunk-YMJZOANX.js.map +0 -1
- package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts +0 -6
- package/dist/components/chat/hooks/use-realtime-chunk-processor.d.ts.map +0 -1
- package/dist/components/chat/utils/chunk-parser.d.ts +0 -25
- package/dist/components/chat/utils/chunk-parser.d.ts.map +0 -1
- package/dist/components/ui/rich-markdown-renderer.d.ts +0 -34
- package/dist/components/ui/rich-markdown-renderer.d.ts.map +0 -1
- package/dist/components/ui/simple-markdown-renderer.d.ts +0 -73
- package/dist/components/ui/simple-markdown-renderer.d.ts.map +0 -1
- package/src/components/chat/hooks/.use-realtime-chunk-processor.md +0 -77
- package/src/components/chat/hooks/use-realtime-chunk-processor.ts +0 -479
- package/src/components/chat/utils/.chunk-parser.md +0 -62
- package/src/components/chat/utils/chunk-parser.ts +0 -256
- package/src/components/ui/.simple-markdown-renderer.md +0 -52
- package/src/components/ui/rich-markdown-renderer.tsx +0 -1223
- package/src/components/ui/simple-markdown-renderer.tsx +0 -964
- /package/dist/{chunk-K7MNWYYI.js.map → chunk-4NWARV5I.js.map} +0 -0
- /package/dist/{chunk-TWGYBXYV.js.map → chunk-CORIBKHG.js.map} +0 -0
- /package/dist/{chunk-EU6QNO4S.js.map → chunk-GTWO5NAY.js.map} +0 -0
- /package/dist/{chunk-BGWDDB7Y.js.map → chunk-HSACATCD.js.map} +0 -0
- /package/dist/{chunk-VL4LUO32.js.map → chunk-RQLBHKXN.js.map} +0 -0
- /package/dist/{chunk-B4YR342L.js.map → chunk-UUYRJPGJ.js.map} +0 -0
- /package/dist/{chunk-FKPXFTZT.js.map → chunk-VHG6AX5V.js.map} +0 -0
- /package/dist/{chunk-X2YF5TJS.js.map → chunk-XQ2B74SI.js.map} +0 -0
- /package/dist/{chunk-5VSEMWWE.js.map → chunk-YZ2OIYQ3.js.map} +0 -0
|
@@ -1,70 +1,60 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
2
|
-
Defines TypeScript interfaces for API interactions and React hook contracts used
|
|
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.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
5
5
|
|
|
6
|
-
### Hook
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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`
|
|
20
28
|
|
|
21
29
|
## Usage Example
|
|
22
30
|
|
|
23
31
|
```typescript
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (meta?.append) appendSegments(segments)
|
|
35
|
-
else setSegments(segments)
|
|
36
|
-
},
|
|
37
|
-
onToolExecuted: (segment) => mergeToolResult(segment),
|
|
38
|
-
onApprovalResolved: (requestId, status, approvalType) => {
|
|
39
|
-
updateApprovalCard(requestId, status)
|
|
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),
|
|
40
42
|
},
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const processorOptions: UseRealtimeChunkProcessorOptions = {
|
|
44
|
-
callbacks,
|
|
45
|
-
displayApprovalTypes: ['CLIENT'],
|
|
46
43
|
batchApprovalsEnabled: true,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
executingTools: new Map(),
|
|
50
|
-
},
|
|
44
|
+
displayApprovalTypes: ['CLIENT'],
|
|
45
|
+
enableThinking: false,
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
const natsOptions: UseNatsDialogSubscriptionOptions = {
|
|
54
49
|
enabled: true,
|
|
55
50
|
dialogId: 'dialog-123',
|
|
56
|
-
topics: ['message'],
|
|
57
51
|
getNatsWsUrl: () => 'wss://nats.example.com',
|
|
58
|
-
onBeforeReconnect: async () => refreshAuthToken(),
|
|
59
52
|
reconnectionBackoff: {
|
|
60
53
|
fastRetries: 3,
|
|
61
54
|
fastRetryDelayMs: 500,
|
|
62
|
-
maxDelayMs:
|
|
55
|
+
maxDelayMs: 30000,
|
|
63
56
|
multiplier: 2,
|
|
64
57
|
},
|
|
58
|
+
onBeforeReconnect: async () => refreshAuthToken(),
|
|
65
59
|
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Source
|
|
69
|
-
|
|
70
|
-
[`api.types.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/api.types.ts)
|
|
60
|
+
```
|
|
@@ -1,80 +1,51 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
2
|
-
Defines TypeScript types for
|
|
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.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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 |
|
|
29
15
|
|
|
30
16
|
## Usage Example
|
|
31
17
|
|
|
32
18
|
```typescript
|
|
33
19
|
import type {
|
|
34
|
-
ParsedChunkAction,
|
|
35
20
|
AccumulatorState,
|
|
36
21
|
MessageProcessingOptions,
|
|
37
|
-
StreamState
|
|
22
|
+
StreamState
|
|
38
23
|
} from './processing.types'
|
|
39
24
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}
|
|
25
|
+
|
|
26
|
+
// Initializing accumulator state
|
|
27
|
+
const state: AccumulatorState = {
|
|
28
|
+
segments: [],
|
|
29
|
+
pendingApprovals: new Map(),
|
|
30
|
+
executingTools: new Map()
|
|
56
31
|
}
|
|
57
32
|
|
|
58
|
-
//
|
|
33
|
+
// Configuring message processing
|
|
59
34
|
const options: MessageProcessingOptions = {
|
|
60
35
|
assistantName: 'Mingo',
|
|
61
36
|
assistantType: 'mingo',
|
|
62
|
-
batchApprovalsEnabled: true,
|
|
63
|
-
displayApprovalTypes: ['shell', '
|
|
37
|
+
batchApprovalsEnabled: true,
|
|
38
|
+
displayApprovalTypes: ['shell', 'file'],
|
|
64
39
|
onApprove: async (requestId) => {
|
|
65
|
-
await
|
|
66
|
-
},
|
|
67
|
-
onReject: async (requestId) => {
|
|
68
|
-
await fetch(`/api/approvals/${requestId}/reject`, { method: 'POST' })
|
|
40
|
+
await submitApproval(requestId)
|
|
69
41
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const state: AccumulatorState = {
|
|
74
|
-
segments: [],
|
|
75
|
-
pendingApprovals: new Map(),
|
|
76
|
-
executingTools: new Map(),
|
|
42
|
+
onReject: (requestId) => {
|
|
43
|
+
logRejection(requestId)
|
|
44
|
+
}
|
|
77
45
|
}
|
|
78
46
|
```
|
|
79
47
|
|
|
80
|
-
|
|
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`.
|
|
@@ -213,79 +213,12 @@ export interface RealtimeChunkCallbacks {
|
|
|
213
213
|
onDialogClosed?: () => void
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
}
|
|
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`.
|
|
289
222
|
|
|
290
223
|
// ========== API Request Types ==========
|
|
291
224
|
|
|
@@ -3,37 +3,14 @@
|
|
|
3
3
|
* Contains types for message parsing, accumulation, and processing
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { MessageSegment,
|
|
6
|
+
import type { MessageSegment, PendingToolCallData, ExecutingToolState } from './message.types'
|
|
7
7
|
import type { ChatApprovalStatus, AssistantType } from './chat.types'
|
|
8
|
-
import type { ChunkData
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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: 'tool_execution'; segment: ToolExecutionSegment }
|
|
20
|
-
| { action: 'approval_request'; requestId: string; command: string; explanation?: string; approvalType: string }
|
|
21
|
-
| { action: 'approval_batch'; requestId: string; approvalType: string; toolCalls: PendingToolCallData[] }
|
|
22
|
-
| { action: 'approval_result'; requestId: string; approved: boolean; approvalType: string; resolvedByName?: string | null }
|
|
23
|
-
| {
|
|
24
|
-
action: 'message_request'
|
|
25
|
-
text: string
|
|
26
|
-
ownerType?: string
|
|
27
|
-
displayName?: string
|
|
28
|
-
userId?: string
|
|
29
|
-
contextItems?: Array<{ type: string; id: string }>
|
|
30
|
-
}
|
|
31
|
-
| { action: 'token_usage'; data: TokenUsageData }
|
|
32
|
-
| { action: 'direct_message'; text: string; ownerType?: string; displayName?: string; userId?: string }
|
|
33
|
-
| { action: 'system'; text: string }
|
|
34
|
-
| { action: 'context_compaction_start' }
|
|
35
|
-
| { action: 'context_compaction_end'; summary?: string }
|
|
36
|
-
| { action: 'dialog_closed' }
|
|
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`.
|
|
37
14
|
|
|
38
15
|
// ========== Accumulator State ==========
|
|
39
16
|
|
|
@@ -81,31 +58,13 @@ export interface MessageProcessingOptions {
|
|
|
81
58
|
batchApprovalsEnabled?: boolean
|
|
82
59
|
}
|
|
83
60
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
reset: () => void
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface ChunkProcessorOptions {
|
|
92
|
-
onMessageStart?: () => void
|
|
93
|
-
onMessageEnd?: () => void
|
|
94
|
-
onError?: (error: string, details?: string) => void
|
|
95
|
-
onText?: (text: string) => void
|
|
96
|
-
onToolExecution?: (segment: MessageSegment) => void
|
|
97
|
-
onApprovalRequest?: (data: any) => void
|
|
98
|
-
onApprovalResult?: (data: any) => void
|
|
99
|
-
onMetadata?: (data: any) => void
|
|
100
|
-
}
|
|
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.
|
|
101
65
|
|
|
102
66
|
// ========== Message Transformation Types ==========
|
|
103
67
|
|
|
104
|
-
export interface MessageTransformer {
|
|
105
|
-
transform: (input: any) => ProcessedMessage | null
|
|
106
|
-
batch: (inputs: any[]) => ProcessedMessage[]
|
|
107
|
-
}
|
|
108
|
-
|
|
109
68
|
export interface TransformationOptions {
|
|
110
69
|
preserveOriginal?: boolean
|
|
111
70
|
mergeSegments?: boolean
|
|
@@ -1,57 +1,48 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
2
|
-
Barrel export module
|
|
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.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
5
5
|
|
|
6
|
-
|
|
|
7
|
-
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
| Icon
|
|
15
|
-
|
|
|
16
|
-
| Slash
|
|
17
|
-
| Compact card | `compact-card-classes` | Shared CSS class constants and safe-href guard |
|
|
18
|
-
| Scripted stream | `scripted-stream` | Re-exported wholesale via `export *` |
|
|
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` |
|
|
19
17
|
|
|
20
18
|
## Usage Example
|
|
21
19
|
|
|
22
20
|
```typescript
|
|
23
21
|
import {
|
|
24
|
-
parseChunkToAction,
|
|
25
22
|
createMessageSegmentAccumulator,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
mergeHistoryWithRealtime,
|
|
23
|
+
handleChatNavClick,
|
|
24
|
+
getChatProxyAuth,
|
|
25
|
+
getIconComponent,
|
|
30
26
|
formatChatAttachmentMarkdownForBubble,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const action = parseChunkToAction(rawChunk)
|
|
27
|
+
decideNewTab,
|
|
28
|
+
getStatusColorScheme,
|
|
29
|
+
} from '@flamingo/chat-utils'
|
|
35
30
|
|
|
36
|
-
// Accumulate message segments
|
|
31
|
+
// Accumulate streamed message segments
|
|
37
32
|
const accumulator = createMessageSegmentAccumulator({
|
|
38
|
-
onSegmentComplete: (segment) => console.log('Segment
|
|
33
|
+
onSegmentComplete: (segment) => console.log('Segment:', segment),
|
|
39
34
|
})
|
|
40
35
|
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
href: '/tickets/123',
|
|
44
|
-
|
|
45
|
-
|
|
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',
|
|
46
41
|
})
|
|
47
42
|
|
|
48
|
-
//
|
|
49
|
-
const Icon =
|
|
50
|
-
|
|
51
|
-
// Get agent status color scheme
|
|
52
|
-
const colors = getStatusColorScheme('online')
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Source
|
|
43
|
+
// Look up a registered icon by kebab-case key
|
|
44
|
+
const Icon = getIconComponent('clickup')
|
|
56
45
|
|
|
57
|
-
|
|
46
|
+
// Apply agent status color scheme to UI
|
|
47
|
+
const colors = getStatusColorScheme('running')
|
|
48
|
+
```
|