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