@flamingo-stack/openframe-frontend-core 0.0.609-2114.5919.1 → 0.0.609-snapshot.20260908170120
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/card-marker.d.ts +31 -0
- package/dist/chat-protocol/card-marker.d.ts.map +1 -0
- package/dist/chat-protocol/events.d.ts +21 -2
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +211 -9
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +211 -9
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/chat-protocol/source-metadata.d.ts +56 -0
- package/dist/chat-protocol/source-metadata.d.ts.map +1 -0
- package/dist/{chunk-LA2W5L6K.js → chunk-25YIHMZ6.js} +2 -2
- package/dist/{chunk-6MLRFM3T.js → chunk-2QBXG74C.js} +5 -5
- package/dist/{chunk-3N4FXBVJ.cjs → chunk-2YMDDD5V.cjs} +3 -3
- package/dist/{chunk-3N4FXBVJ.cjs.map → chunk-2YMDDD5V.cjs.map} +1 -1
- package/dist/{chunk-JOCVQZGT.js → chunk-37CAZTLP.js} +5 -5
- package/dist/{chunk-D3DTC7SZ.cjs → chunk-C4KQ2XPK.cjs} +15 -15
- package/dist/{chunk-D3DTC7SZ.cjs.map → chunk-C4KQ2XPK.cjs.map} +1 -1
- package/dist/{chunk-CZTOSG7Q.cjs → chunk-EANAFFAD.cjs} +22 -22
- package/dist/{chunk-CZTOSG7Q.cjs.map → chunk-EANAFFAD.cjs.map} +1 -1
- package/dist/{chunk-BSMPCPOZ.js → chunk-F2C2U7CP.js} +590 -299
- package/dist/chunk-F2C2U7CP.js.map +1 -0
- package/dist/{chunk-O2M4T34Q.cjs → chunk-FASOANK7.cjs} +4 -4
- package/dist/{chunk-O2M4T34Q.cjs.map → chunk-FASOANK7.cjs.map} +1 -1
- package/dist/{chunk-JKM5FH63.js → chunk-FS3CTGIR.js} +3 -3
- package/dist/{chunk-45XXK2VU.cjs → chunk-GFAHCXIL.cjs} +10 -10
- package/dist/{chunk-45XXK2VU.cjs.map → chunk-GFAHCXIL.cjs.map} +1 -1
- package/dist/{chunk-SEW25Y2W.cjs → chunk-GNLV326I.cjs} +10 -10
- package/dist/{chunk-SEW25Y2W.cjs.map → chunk-GNLV326I.cjs.map} +1 -1
- package/dist/{chunk-DKNXAJMP.cjs → chunk-HKJ3WKGW.cjs} +159 -159
- package/dist/{chunk-DKNXAJMP.cjs.map → chunk-HKJ3WKGW.cjs.map} +1 -1
- package/dist/{chunk-HGVW7OHI.js → chunk-HQSCJYCF.js} +2 -2
- package/dist/{chunk-QX4ANESW.js → chunk-HZS4TV34.js} +6 -6
- package/dist/{chunk-B3UXNGVM.js → chunk-IBMHEOBV.js} +3 -3
- package/dist/{chunk-BUXGWBTF.js → chunk-MGXSJI23.js} +2 -2
- package/dist/{chunk-B7LYKBCD.js → chunk-O6PO5BHE.js} +5 -5
- package/dist/{chunk-C7CTEUU7.js → chunk-OIKZDXNW.js} +2 -2
- package/dist/{chunk-TJ3GFULR.js → chunk-OJZW3GE2.js} +3 -3
- package/dist/{chunk-L2JWC5VS.cjs → chunk-OVVKVIMH.cjs} +43 -43
- package/dist/{chunk-L2JWC5VS.cjs.map → chunk-OVVKVIMH.cjs.map} +1 -1
- package/dist/{chunk-VCYRJY7J.js → chunk-Q2CNCBMK.js} +4 -4
- package/dist/{chunk-NJUSDREV.cjs → chunk-Q3APHZK5.cjs} +22 -22
- package/dist/{chunk-NJUSDREV.cjs.map → chunk-Q3APHZK5.cjs.map} +1 -1
- package/dist/{chunk-TCEALWE3.cjs → chunk-QE2Z6WME.cjs} +33 -33
- package/dist/{chunk-TCEALWE3.cjs.map → chunk-QE2Z6WME.cjs.map} +1 -1
- package/dist/{chunk-OTYV6SDN.js → chunk-R2UDEMKK.js} +3 -3
- package/dist/{chunk-JR7I2AGL.js → chunk-ROOIHDLS.js} +3 -3
- package/dist/{chunk-3XNMDLGB.cjs → chunk-THCB7NHV.cjs} +9 -9
- package/dist/{chunk-3XNMDLGB.cjs.map → chunk-THCB7NHV.cjs.map} +1 -1
- package/dist/{chunk-GMOBT5NP.cjs → chunk-THCSSPXU.cjs} +70 -70
- package/dist/{chunk-GMOBT5NP.cjs.map → chunk-THCSSPXU.cjs.map} +1 -1
- package/dist/{chunk-FYG7QNAO.cjs → chunk-UFFVMZDL.cjs} +5 -5
- package/dist/{chunk-FYG7QNAO.cjs.map → chunk-UFFVMZDL.cjs.map} +1 -1
- package/dist/{chunk-MVBRMQGU.js → chunk-V6TINNLD.js} +2 -2
- package/dist/{chunk-ZRLFBLME.cjs → chunk-WJQOYSR3.cjs} +3 -3
- package/dist/{chunk-ZRLFBLME.cjs.map → chunk-WJQOYSR3.cjs.map} +1 -1
- package/dist/{chunk-XNDTYTVT.cjs → chunk-YXTAV2E3.cjs} +974 -683
- package/dist/chunk-YXTAV2E3.cjs.map +1 -0
- package/dist/{chunk-RZM6FPOT.cjs → chunk-ZDLCWNM6.cjs} +25 -25
- package/dist/{chunk-RZM6FPOT.cjs.map → chunk-ZDLCWNM6.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +9 -9
- package/dist/components/case-studies/index.js +3 -3
- 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/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +5 -28
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/remark-card-links.d.ts +5 -4
- package/dist/components/chat/remark-card-links.d.ts.map +1 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
- package/dist/components/chat/types/component.types.d.ts +27 -0
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +81 -1
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +12 -3
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/cited-sources.d.ts +24 -0
- package/dist/components/chat/utils/cited-sources.d.ts.map +1 -0
- package/dist/components/chat/utils/host-message.d.ts +41 -0
- package/dist/components/chat/utils/host-message.d.ts.map +1 -0
- package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +38 -38
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +24 -24
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/card-marker.test.ts +63 -0
- package/src/chat-protocol/__tests__/source-metadata.test.ts +243 -0
- package/src/chat-protocol/card-marker.ts +40 -0
- package/src/chat-protocol/events.ts +22 -1
- package/src/chat-protocol/nats-decoder.ts +12 -0
- package/src/chat-protocol/source-metadata.ts +336 -0
- package/src/components/chat/__tests__/tool-execution-display.test.tsx +70 -0
- package/src/components/chat/chat-message-enhanced.tsx +37 -12
- package/src/components/chat/chat-message-list.tsx +14 -1
- package/src/components/chat/embeddable-chat.tsx +47 -87
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +5 -28
- package/src/components/chat/remark-card-links.ts +14 -12
- package/src/components/chat/stream/chat-stream-reducer.ts +48 -3
- package/src/components/chat/tool-execution-display.tsx +18 -4
- package/src/components/chat/types/component.types.ts +27 -0
- package/src/components/chat/types/message.types.ts +83 -0
- package/src/components/chat/types/unified-chat-state.types.ts +12 -3
- package/src/components/chat/utils/__tests__/cited-sources.test.ts +80 -0
- package/src/components/chat/utils/__tests__/host-message.test.ts +92 -0
- package/src/components/chat/utils/__tests__/process-historical-messages-sources.test.ts +138 -0
- package/src/components/chat/utils/cited-sources.ts +61 -0
- package/src/components/chat/utils/host-message.ts +87 -0
- package/src/components/chat/utils/process-historical-messages.ts +25 -0
- package/dist/chunk-BSMPCPOZ.js.map +0 -1
- package/dist/chunk-XNDTYTVT.cjs.map +0 -1
- /package/dist/{chunk-LA2W5L6K.js.map → chunk-25YIHMZ6.js.map} +0 -0
- /package/dist/{chunk-6MLRFM3T.js.map → chunk-2QBXG74C.js.map} +0 -0
- /package/dist/{chunk-JOCVQZGT.js.map → chunk-37CAZTLP.js.map} +0 -0
- /package/dist/{chunk-JKM5FH63.js.map → chunk-FS3CTGIR.js.map} +0 -0
- /package/dist/{chunk-HGVW7OHI.js.map → chunk-HQSCJYCF.js.map} +0 -0
- /package/dist/{chunk-QX4ANESW.js.map → chunk-HZS4TV34.js.map} +0 -0
- /package/dist/{chunk-B3UXNGVM.js.map → chunk-IBMHEOBV.js.map} +0 -0
- /package/dist/{chunk-BUXGWBTF.js.map → chunk-MGXSJI23.js.map} +0 -0
- /package/dist/{chunk-B7LYKBCD.js.map → chunk-O6PO5BHE.js.map} +0 -0
- /package/dist/{chunk-C7CTEUU7.js.map → chunk-OIKZDXNW.js.map} +0 -0
- /package/dist/{chunk-TJ3GFULR.js.map → chunk-OJZW3GE2.js.map} +0 -0
- /package/dist/{chunk-VCYRJY7J.js.map → chunk-Q2CNCBMK.js.map} +0 -0
- /package/dist/{chunk-OTYV6SDN.js.map → chunk-R2UDEMKK.js.map} +0 -0
- /package/dist/{chunk-JR7I2AGL.js.map → chunk-ROOIHDLS.js.map} +0 -0
- /package/dist/{chunk-MVBRMQGU.js.map → chunk-V6TINNLD.js.map} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `[card://<type>:<id>]` marker grammar — ONE definition, two readers.
|
|
3
|
+
*
|
|
4
|
+
* The model writes these markers into the answer body, and the metadata frame
|
|
5
|
+
* describes the same references separately. Two parsers therefore have to agree
|
|
6
|
+
* on what counts as a marker: the payload decoder (`source-metadata.ts`) and the
|
|
7
|
+
* body renderer (`chat-message-enhanced.tsx`). When they disagree the failure is
|
|
8
|
+
* silent and one-sided — the stricter side drops a reference the other accepted,
|
|
9
|
+
* and the reader is left looking at raw `[card://…]` text in a sentence.
|
|
10
|
+
*
|
|
11
|
+
* The id half is deliberately permissive: the backend validates it as "anything
|
|
12
|
+
* but `]` and newlines", and a client that narrows that is the side that breaks.
|
|
13
|
+
* `)` is excluded on top because the body form also terminates on it (a marker
|
|
14
|
+
* written as a markdown link target).
|
|
15
|
+
*
|
|
16
|
+
* Server-safe: no React, no browser APIs.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A marker standing ALONE, anchored — for validating a `ref` field in the
|
|
20
|
+
* metadata payload, where the whole string must be the marker and nothing else.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CARD_REFERENCE: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* A marker EMBEDDED in answer text, unanchored and global.
|
|
25
|
+
*
|
|
26
|
+
* Terminates on `]` or `)` so a marker used as a markdown link target
|
|
27
|
+
* (`[card://x:y](…)`) is matched too. Being global, it carries `lastIndex`
|
|
28
|
+
* state — reset it before each scan.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createCardMarkerScanner(): RegExp;
|
|
31
|
+
//# sourceMappingURL=card-marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-marker.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/card-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAQH;;;GAGG;AACH,eAAO,MAAM,cAAc,QAA2D,CAAC;AAEvF;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Server-safe: no React, no browser APIs.
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type { ChatRef } from '../components/chat/chat-ref.types';
|
|
11
|
+
import type { AskOptionData, ChatSource } from '../components/chat/types/message.types';
|
|
11
12
|
import type { ApprovalRequestField, DecisionResolvedFrame, UsageTelemetry } from './frames';
|
|
12
13
|
/** Optional envelope on every event. `seq` carries the transport's
|
|
13
14
|
* stream sequence (JetStream `streamSeq` on NATS; unused on SSE). */
|
|
@@ -181,6 +182,24 @@ export interface TicketEventEvent extends ChatStreamEventBase {
|
|
|
181
182
|
/** Kind-token the ticket reopened INTO (AI_ASSISTANCE / TECH_REQUIRED / ...). */
|
|
182
183
|
targetStatusKind?: string;
|
|
183
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Per-answer source metadata — the documents an answer cited, plus the video
|
|
187
|
+
* and entity-card references its `[card://type:id]` markers expand with.
|
|
188
|
+
*
|
|
189
|
+
* Unlike `ChatMetadataEvent`, this one is DECODED, not passthrough: the payload
|
|
190
|
+
* comes from a remote MCP server's tool output rather than from our own
|
|
191
|
+
* backend's frame, so it is validated at the protocol boundary (see
|
|
192
|
+
* `source-metadata.ts`) and never reaches a consumer half-checked.
|
|
193
|
+
*
|
|
194
|
+
* Both fields are optional and never both absent — the decoder returns `null`
|
|
195
|
+
* instead of emitting an empty event, so applying one can't blank metadata an
|
|
196
|
+
* earlier chunk of the same turn already supplied.
|
|
197
|
+
*/
|
|
198
|
+
export interface SourcesEvent extends ChatStreamEventBase {
|
|
199
|
+
type: 'sources';
|
|
200
|
+
sources?: ChatSource[];
|
|
201
|
+
refs?: ChatRef[];
|
|
202
|
+
}
|
|
184
203
|
/** Per-turn metadata. Raw wire values pass through UNVALIDATED — the
|
|
185
204
|
* consumer replicates the legacy truthiness/typeof gates (so a
|
|
186
205
|
* malformed frame degrades identically to the pre-SSOT parser). */
|
|
@@ -292,6 +311,6 @@ export interface ParticipantEvent extends ChatStreamEventBase {
|
|
|
292
311
|
export interface DialogClosedEvent extends ChatStreamEventBase {
|
|
293
312
|
type: 'dialog-closed';
|
|
294
313
|
}
|
|
295
|
-
export type ChatStreamEvent = TurnStartEvent | TurnEndEvent | TextDeltaEvent | ThinkingDeltaEvent | AskEvent | StatusEvent | ToolExecutionEvent | ApprovalRequestEvent | ApprovalResolvedEvent | EscalationOfferEvent | EscalationOfferResolvedEvent | TicketEscalatedEvent | TicketEventEvent | ChatMetadataEvent | UsageEvent | TokenUsageEvent | CompactionEvent | ErrorEvent | ParticipantEvent | DialogClosedEvent;
|
|
314
|
+
export type ChatStreamEvent = TurnStartEvent | TurnEndEvent | TextDeltaEvent | ThinkingDeltaEvent | AskEvent | StatusEvent | ToolExecutionEvent | ApprovalRequestEvent | ApprovalResolvedEvent | EscalationOfferEvent | EscalationOfferResolvedEvent | TicketEscalatedEvent | TicketEventEvent | ChatMetadataEvent | SourcesEvent | UsageEvent | TokenUsageEvent | CompactionEvent | ErrorEvent | ParticipantEvent | DialogClosedEvent;
|
|
296
315
|
export {};
|
|
297
316
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/chat-protocol/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAGxF,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE5F;sEACsE;AACtE,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;iDAMiD;AACjD,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;oEACoE;AACpE,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;iEACiE;AACjE,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;0BAM0B;AAC1B,MAAM,WAAW,QAAS,SAAQ,mBAAmB;IACnD,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,WAAY,SAAQ,mBAAm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AAC;AAE/D,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;IAC3D,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,QAAQ,CAAC;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,QAAQ,GACR,WAAW,GACX,kBAAkB,GAClB,oBAAoB,GACpB,qBAAqB,GACrB,oBAAoB,GACpB,4BAA4B,GAC5B,oBAAoB,GACpB,gBAAgB,GAChB,iBAAiB,GACjB,YAAY,GACZ,UAAU,GACV,eAAe,GACf,eAAe,GACf,UAAU,GACV,gBAAgB,GAChB,iBAAiB,CAAC"}
|
|
@@ -43,8 +43,8 @@ var CHAT_OWNER_ADMIN = "ADMIN";
|
|
|
43
43
|
// src/chat-protocol/encode.ts
|
|
44
44
|
var encoder = new TextEncoder();
|
|
45
45
|
var SENTINEL_BYTES_RE = /[\u0000\u001E\u001F]/g;
|
|
46
|
-
function stripSentinelBytes(
|
|
47
|
-
return
|
|
46
|
+
function stripSentinelBytes(text2) {
|
|
47
|
+
return text2.replace(SENTINEL_BYTES_RE, "");
|
|
48
48
|
}
|
|
49
49
|
function encodeLeadingFrame(frame) {
|
|
50
50
|
return encoder.encode(JSON.stringify(frame) + FRAME_TERMINATOR);
|
|
@@ -52,16 +52,16 @@ function encodeLeadingFrame(frame) {
|
|
|
52
52
|
function encodeEndOfLeading() {
|
|
53
53
|
return encoder.encode(END_OF_LEADING);
|
|
54
54
|
}
|
|
55
|
-
function encodeTextDelta(
|
|
56
|
-
return encoder.encode(stripSentinelBytes(
|
|
55
|
+
function encodeTextDelta(text2) {
|
|
56
|
+
return encoder.encode(stripSentinelBytes(text2));
|
|
57
57
|
}
|
|
58
58
|
function encodeTrailingUsageFrame(frame) {
|
|
59
59
|
return encoder.encode(TRAILER_SENTINEL + JSON.stringify(frame));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/chat-protocol/leading-frames.ts
|
|
63
|
-
function escapeThinkingTags(
|
|
64
|
-
return
|
|
63
|
+
function escapeThinkingTags(text2) {
|
|
64
|
+
return text2.replace(/</g, "<");
|
|
65
65
|
}
|
|
66
66
|
function frameStr(value) {
|
|
67
67
|
return typeof value === "string" ? value : void 0;
|
|
@@ -172,11 +172,11 @@ function isFrameObject(value) {
|
|
|
172
172
|
}
|
|
173
173
|
function frameTelemetry(value) {
|
|
174
174
|
if (!isFrameObject(value)) return void 0;
|
|
175
|
-
const { cards, chips, sentences, answerLen } = value;
|
|
176
|
-
if (typeof
|
|
175
|
+
const { cards: cards2, chips, sentences, answerLen } = value;
|
|
176
|
+
if (typeof cards2 !== "number" || typeof chips !== "number" || typeof sentences !== "number" || typeof answerLen !== "number") {
|
|
177
177
|
return void 0;
|
|
178
178
|
}
|
|
179
|
-
return { cards, chips, sentences, answerLen };
|
|
179
|
+
return { cards: cards2, chips, sentences, answerLen };
|
|
180
180
|
}
|
|
181
181
|
function createSseFrameDecoder() {
|
|
182
182
|
const textDecoder = new TextDecoder();
|
|
@@ -287,6 +287,15 @@ var MESSAGE_TYPE = {
|
|
|
287
287
|
TEXT: "TEXT",
|
|
288
288
|
THINKING: "THINKING",
|
|
289
289
|
ASK: "ASK",
|
|
290
|
+
/** Per-answer source metadata (documents, videos, entity cards).
|
|
291
|
+
*
|
|
292
|
+
* TWO names for ONE payload, on purpose. `SOURCES` is the contract the
|
|
293
|
+
* backend is moving to; `GUIDE` is the envelope it ships in today, reused
|
|
294
|
+
* from Guide Mode v2 so a released frontend keeps working during the v2→v3
|
|
295
|
+
* rollout. Both decode through the same path, so dropping `GUIDE` later is a
|
|
296
|
+
* deletion here and nothing else. */
|
|
297
|
+
GUIDE: "GUIDE",
|
|
298
|
+
SOURCES: "SOURCES",
|
|
290
299
|
EXECUTING_TOOL: "EXECUTING_TOOL",
|
|
291
300
|
EXECUTED_TOOL: "EXECUTED_TOOL",
|
|
292
301
|
APPROVAL_REQUEST: "APPROVAL_REQUEST",
|
|
@@ -307,6 +316,11 @@ var MESSAGE_TYPE = {
|
|
|
307
316
|
DIALOG_CLOSED: "DIALOG_CLOSED"
|
|
308
317
|
};
|
|
309
318
|
|
|
319
|
+
// src/chat-protocol/card-marker.ts
|
|
320
|
+
var CARD_TYPE = "[a-zA-Z0-9_-]+";
|
|
321
|
+
var CARD_ID = "[^\\]\\r\\n)]+";
|
|
322
|
+
var CARD_REFERENCE = new RegExp(`^\\[card://(${CARD_TYPE}):(${CARD_ID})\\]$`);
|
|
323
|
+
|
|
310
324
|
// src/chat-protocol/wire-narrow.ts
|
|
311
325
|
function isRecord(value) {
|
|
312
326
|
return typeof value === "object" && value !== null;
|
|
@@ -315,6 +329,184 @@ function unwrapEnvelope(payload) {
|
|
|
315
329
|
return isRecord(payload) && "data" in payload ? payload.data : payload;
|
|
316
330
|
}
|
|
317
331
|
|
|
332
|
+
// src/chat-protocol/source-metadata.ts
|
|
333
|
+
var YOUTUBE_ID = /^[A-Za-z0-9_-]{11}$/;
|
|
334
|
+
var VIDEO_URL_KEYS = ["videoUrl", "highlightVideoUrl", "videoPoster", "highlightVideoPoster"];
|
|
335
|
+
function text(value) {
|
|
336
|
+
if (typeof value !== "string") return void 0;
|
|
337
|
+
const trimmed = value.trim();
|
|
338
|
+
return trimmed || void 0;
|
|
339
|
+
}
|
|
340
|
+
function nullableText(value) {
|
|
341
|
+
return value === null ? null : text(value);
|
|
342
|
+
}
|
|
343
|
+
function httpsUrl(value) {
|
|
344
|
+
const candidate = text(value);
|
|
345
|
+
if (!candidate) return void 0;
|
|
346
|
+
try {
|
|
347
|
+
return new URL(candidate).protocol === "https:" ? candidate : void 0;
|
|
348
|
+
} catch {
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function youtubeVideoId(value) {
|
|
353
|
+
const candidate = text(value);
|
|
354
|
+
if (!candidate) return void 0;
|
|
355
|
+
if (YOUTUBE_ID.test(candidate)) return candidate;
|
|
356
|
+
const url = httpsUrl(candidate);
|
|
357
|
+
if (!url) return void 0;
|
|
358
|
+
const parsed = new URL(url);
|
|
359
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
360
|
+
const isYoutubeHost = hostname === "youtu.be" || hostname === "youtube.com" || hostname.endsWith(".youtube.com");
|
|
361
|
+
if (!isYoutubeHost) return void 0;
|
|
362
|
+
const fromPath = hostname === "youtu.be" ? parsed.pathname.split("/").filter(Boolean)[0] : /^\/(?:embed|v|shorts)\/([A-Za-z0-9_-]{11})(?:\/|$)/.exec(parsed.pathname)?.[1];
|
|
363
|
+
const id = fromPath ?? parsed.searchParams.get("v") ?? void 0;
|
|
364
|
+
return id && YOUTUBE_ID.test(id) ? id : void 0;
|
|
365
|
+
}
|
|
366
|
+
function sourceItems(value) {
|
|
367
|
+
if (!Array.isArray(value)) return void 0;
|
|
368
|
+
const items = value.filter(isRecord).flatMap((item) => {
|
|
369
|
+
const id = text(item.id);
|
|
370
|
+
const documentType = text(item.documentType);
|
|
371
|
+
const name = text(item.name);
|
|
372
|
+
if (!id || !documentType || !name) return [];
|
|
373
|
+
const externalUrl = httpsUrl(item.externalUrl);
|
|
374
|
+
const targetPlatform = nullableText(item.targetPlatform);
|
|
375
|
+
const path = nullableText(item.path);
|
|
376
|
+
return [
|
|
377
|
+
{
|
|
378
|
+
id,
|
|
379
|
+
documentType,
|
|
380
|
+
name,
|
|
381
|
+
...externalUrl ? { externalUrl } : {},
|
|
382
|
+
...targetPlatform !== void 0 ? { targetPlatform } : {},
|
|
383
|
+
...path !== void 0 ? { path } : {}
|
|
384
|
+
}
|
|
385
|
+
];
|
|
386
|
+
});
|
|
387
|
+
return items.length > 0 ? items : void 0;
|
|
388
|
+
}
|
|
389
|
+
function sources(value) {
|
|
390
|
+
if (!Array.isArray(value)) return [];
|
|
391
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
392
|
+
const decoded = [];
|
|
393
|
+
for (const candidate of value) {
|
|
394
|
+
if (!isRecord(candidate)) continue;
|
|
395
|
+
const index = candidate.index;
|
|
396
|
+
const name = text(candidate.name);
|
|
397
|
+
const isUsableIndex = typeof index === "number" && Number.isInteger(index) && index > 0 && !claimed.has(index);
|
|
398
|
+
if (!isUsableIndex || !name) continue;
|
|
399
|
+
claimed.add(index);
|
|
400
|
+
const path = text(candidate.path);
|
|
401
|
+
const documentType = text(candidate.documentType);
|
|
402
|
+
const externalUrl = httpsUrl(candidate.externalUrl);
|
|
403
|
+
const targetPlatform = nullableText(candidate.targetPlatform);
|
|
404
|
+
const id = text(candidate.id);
|
|
405
|
+
const sourceRepo = text(candidate.sourceRepo);
|
|
406
|
+
const label = text(candidate.label);
|
|
407
|
+
const items = sourceItems(candidate.items);
|
|
408
|
+
decoded.push({
|
|
409
|
+
index,
|
|
410
|
+
name,
|
|
411
|
+
// Both are typed non-optional on `ChatSource` and predate this decoder;
|
|
412
|
+
// '' is the established "no value" for them across the SSE path.
|
|
413
|
+
path: path ?? "",
|
|
414
|
+
documentType: documentType ?? "",
|
|
415
|
+
...externalUrl ? { externalUrl } : {},
|
|
416
|
+
...targetPlatform !== void 0 ? { targetPlatform } : {},
|
|
417
|
+
...id ? { id } : {},
|
|
418
|
+
...sourceRepo ? { sourceRepo } : {},
|
|
419
|
+
...label ? { label } : {},
|
|
420
|
+
...items ? { items } : {}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return decoded;
|
|
424
|
+
}
|
|
425
|
+
function videoMetadata(value, url) {
|
|
426
|
+
const metadata = {};
|
|
427
|
+
if (isRecord(value)) {
|
|
428
|
+
for (const key of VIDEO_URL_KEYS) {
|
|
429
|
+
const validated = httpsUrl(value[key]);
|
|
430
|
+
if (validated) metadata[key] = validated;
|
|
431
|
+
}
|
|
432
|
+
const declaredId = youtubeVideoId(value.youtubeUrl);
|
|
433
|
+
if (declaredId) metadata.youtubeUrl = declaredId;
|
|
434
|
+
}
|
|
435
|
+
if (url) {
|
|
436
|
+
const idFromUrl = youtubeVideoId(url);
|
|
437
|
+
if (idFromUrl) {
|
|
438
|
+
metadata.youtubeUrl = idFromUrl;
|
|
439
|
+
delete metadata.videoUrl;
|
|
440
|
+
} else {
|
|
441
|
+
metadata.videoUrl = url;
|
|
442
|
+
delete metadata.youtubeUrl;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return metadata;
|
|
446
|
+
}
|
|
447
|
+
function videos(value) {
|
|
448
|
+
if (!Array.isArray(value)) return [];
|
|
449
|
+
return value.filter(isRecord).flatMap((video) => {
|
|
450
|
+
const match = typeof video.ref === "string" ? CARD_REFERENCE.exec(video.ref) : null;
|
|
451
|
+
if (!match || match[1] !== "video") return [];
|
|
452
|
+
const id = match[2];
|
|
453
|
+
const url = httpsUrl(video.url) ?? null;
|
|
454
|
+
const sourceRepo = text(video.sourceRepo);
|
|
455
|
+
const metadata = videoMetadata(video.metadata, url);
|
|
456
|
+
return [
|
|
457
|
+
{
|
|
458
|
+
type: "video",
|
|
459
|
+
id,
|
|
460
|
+
title: text(video.title) ?? id,
|
|
461
|
+
url,
|
|
462
|
+
...sourceRepo ? { sourceRepo } : {},
|
|
463
|
+
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
464
|
+
}
|
|
465
|
+
];
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
function cards(value, decodedSources) {
|
|
469
|
+
if (!Array.isArray(value)) return [];
|
|
470
|
+
return value.filter(isRecord).flatMap((card) => {
|
|
471
|
+
const match = typeof card.ref === "string" ? CARD_REFERENCE.exec(card.ref) : null;
|
|
472
|
+
if (!match || match[1] === "video") return [];
|
|
473
|
+
const type = text(card.entityType);
|
|
474
|
+
const id = text(card.entityId);
|
|
475
|
+
if (!type || !id || type !== match[1] || id !== match[2]) return [];
|
|
476
|
+
const source = decodedSources.find((candidate) => candidate.id === id && candidate.documentType === type);
|
|
477
|
+
return [
|
|
478
|
+
{
|
|
479
|
+
type,
|
|
480
|
+
id,
|
|
481
|
+
title: source?.name ?? id,
|
|
482
|
+
url: source?.externalUrl ?? null,
|
|
483
|
+
...source?.sourceRepo ? { sourceRepo: source.sourceRepo } : {},
|
|
484
|
+
...source?.targetPlatform !== void 0 ? { targetPlatform: source.targetPlatform } : {},
|
|
485
|
+
...source?.path ? { metadata: { path: source.path } } : {}
|
|
486
|
+
}
|
|
487
|
+
];
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
function deduplicateRefs(refs) {
|
|
491
|
+
const byIdentity = /* @__PURE__ */ new Map();
|
|
492
|
+
for (const ref of refs) {
|
|
493
|
+
const identity = `${ref.type}:${ref.id}`;
|
|
494
|
+
if (!byIdentity.has(identity)) byIdentity.set(identity, ref);
|
|
495
|
+
}
|
|
496
|
+
return [...byIdentity.values()];
|
|
497
|
+
}
|
|
498
|
+
function sourceMetadataEvent(payload) {
|
|
499
|
+
if (!isRecord(payload)) return null;
|
|
500
|
+
const decodedSources = sources(payload.sources);
|
|
501
|
+
const refs = deduplicateRefs([...videos(payload.videos), ...cards(payload.cards, decodedSources)]);
|
|
502
|
+
if (decodedSources.length === 0 && refs.length === 0) return null;
|
|
503
|
+
return {
|
|
504
|
+
type: "sources",
|
|
505
|
+
...decodedSources.length > 0 ? { sources: decodedSources } : {},
|
|
506
|
+
...refs.length > 0 ? { refs } : {}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
318
510
|
// src/chat-protocol/nats-decoder.ts
|
|
319
511
|
function str(value) {
|
|
320
512
|
return typeof value === "string" ? value : void 0;
|
|
@@ -380,6 +572,16 @@ function decodeNatsChunk(chunk) {
|
|
|
380
572
|
return { type: "thinking-delta", text: data.text, ...seq };
|
|
381
573
|
}
|
|
382
574
|
return null;
|
|
575
|
+
// Two chunk names, one payload and one decoder. `SOURCES` is the contract
|
|
576
|
+
// the backend is moving to; `GUIDE` is the v2 envelope it ships in during
|
|
577
|
+
// the rollout (see `MESSAGE_TYPE.GUIDE`). The chunk arrives BEFORE or
|
|
578
|
+
// between the answer's text deltas, so the reducer — not this decoder —
|
|
579
|
+
// owns attaching it to the right turn.
|
|
580
|
+
case MESSAGE_TYPE.GUIDE:
|
|
581
|
+
case MESSAGE_TYPE.SOURCES: {
|
|
582
|
+
const event = sourceMetadataEvent(data.payload);
|
|
583
|
+
return event ? { ...event, ...seq } : null;
|
|
584
|
+
}
|
|
383
585
|
// An ask card is only an ask card with something to pick: a question and at
|
|
384
586
|
// least one option. Anything less is dropped rather than rendered as an
|
|
385
587
|
// empty card the user can't answer — the backend already falls back to a
|