@flamingo-stack/openframe-frontend-core 0.0.532 → 0.0.533-snapshot.20260811225540
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/confirm-tool.d.ts +50 -0
- package/dist/chat-protocol/confirm-tool.d.ts.map +1 -0
- package/dist/chat-protocol/decode.d.ts +1 -9
- package/dist/chat-protocol/decode.d.ts.map +1 -1
- package/dist/chat-protocol/events.d.ts +35 -0
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +72 -3
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.d.ts +1 -0
- package/dist/chat-protocol/index.d.ts.map +1 -1
- package/dist/chat-protocol/index.js +67 -4
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/leading-frames.d.ts +38 -0
- package/dist/chat-protocol/leading-frames.d.ts.map +1 -0
- package/dist/chat-protocol/nats-decoder.d.ts +41 -0
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/{chunk-IZOGFZ7N.js → chunk-2ALT6CTY.js} +2 -2
- package/dist/{chunk-GWFC3NE5.cjs → chunk-2YJ2CVRC.cjs} +31 -31
- package/dist/{chunk-GWFC3NE5.cjs.map → chunk-2YJ2CVRC.cjs.map} +1 -1
- package/dist/{chunk-LYWSHNK4.cjs → chunk-67MWXMNT.cjs} +26 -26
- package/dist/{chunk-LYWSHNK4.cjs.map → chunk-67MWXMNT.cjs.map} +1 -1
- package/dist/{chunk-ECR37JHH.js → chunk-BSE2UT6L.js} +2 -2
- package/dist/{chunk-XBYEPSNZ.js → chunk-BUVD2OAI.js} +4 -4
- package/dist/{chunk-7SGBF2I2.js → chunk-D62VYSTL.js} +6 -6
- package/dist/{chunk-4GL2XJ5C.cjs → chunk-EBSZWSC5.cjs} +4 -4
- package/dist/{chunk-4GL2XJ5C.cjs.map → chunk-EBSZWSC5.cjs.map} +1 -1
- package/dist/{chunk-UP4RA54U.js → chunk-H4W4LENJ.js} +5 -5
- package/dist/{chunk-2QP67D2L.cjs → chunk-JELZAWSM.cjs} +3 -3
- package/dist/{chunk-2QP67D2L.cjs.map → chunk-JELZAWSM.cjs.map} +1 -1
- package/dist/{chunk-ALXLWF75.js → chunk-KZ6PWFHK.js} +2 -2
- package/dist/{chunk-HXHA3DCI.cjs → chunk-LBZEPB4Y.cjs} +11 -11
- package/dist/{chunk-HXHA3DCI.cjs.map → chunk-LBZEPB4Y.cjs.map} +1 -1
- package/dist/{chunk-GVLA2BPW.cjs → chunk-LYRGM25P.cjs} +948 -1002
- package/dist/chunk-LYRGM25P.cjs.map +1 -0
- package/dist/{chunk-HJDCDOJM.cjs → chunk-M5ODB6RQ.cjs} +37 -37
- package/dist/{chunk-HJDCDOJM.cjs.map → chunk-M5ODB6RQ.cjs.map} +1 -1
- package/dist/{chunk-ETF2QXXU.cjs → chunk-MLILEBJU.cjs} +61 -61
- package/dist/{chunk-ETF2QXXU.cjs.map → chunk-MLILEBJU.cjs.map} +1 -1
- package/dist/{chunk-OAEJWP7H.js → chunk-MTCU5MQN.js} +2 -2
- package/dist/{chunk-QEMI34VA.cjs → chunk-NCUKKJRG.cjs} +87 -87
- package/dist/{chunk-QEMI34VA.cjs.map → chunk-NCUKKJRG.cjs.map} +1 -1
- package/dist/{chunk-WINT757E.js → chunk-O6VJZX2N.js} +261 -315
- package/dist/chunk-O6VJZX2N.js.map +1 -0
- package/dist/{chunk-5W3RCZIK.js → chunk-ONIYUMTO.js} +2 -2
- package/dist/{chunk-TQ7EPKKO.js → chunk-POFCTXNH.js} +2 -2
- package/dist/{chunk-2MBS3YEY.cjs → chunk-RHKH4YUY.cjs} +5 -5
- package/dist/{chunk-2MBS3YEY.cjs.map → chunk-RHKH4YUY.cjs.map} +1 -1
- package/dist/{chunk-JZ5XDZYD.cjs → chunk-UMDGRL6A.cjs} +26 -26
- package/dist/{chunk-JZ5XDZYD.cjs.map → chunk-UMDGRL6A.cjs.map} +1 -1
- package/dist/{chunk-L6EKEYF7.cjs → chunk-UWB33C6R.cjs} +14 -14
- package/dist/{chunk-L6EKEYF7.cjs.map → chunk-UWB33C6R.cjs.map} +1 -1
- package/dist/{chunk-65NR333L.js → chunk-VYOGAQLM.js} +2 -2
- package/dist/{chunk-AZBS4PZG.js → chunk-W4MXOBEW.js} +2 -2
- package/dist/{chunk-KYQZBQYV.js → chunk-WBYRBTAS.js} +2 -2
- package/dist/{chunk-TMZS63G2.cjs → chunk-YW2ZU7LC.cjs} +7 -7
- package/dist/{chunk-TMZS63G2.cjs.map → chunk-YW2ZU7LC.cjs.map} +1 -1
- package/dist/{chunk-QYNLVIGQ.cjs → chunk-ZKQXE2P4.cjs} +9 -9
- package/dist/{chunk-QYNLVIGQ.cjs.map → chunk-ZKQXE2P4.cjs.map} +1 -1
- package/dist/{chunk-3G7FDE5E.js → chunk-ZLLXYE2G.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/embeddable-chat.d.ts +13 -0
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- 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.js +9 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts +9 -0
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +15 -0
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/network.types.d.ts +4 -0
- package/dist/components/chat/types/network.types.d.ts.map +1 -1
- package/dist/components/chat/types/processing.types.d.ts +7 -1
- package/dist/components/chat/types/processing.types.d.ts.map +1 -1
- package/dist/components/chat/utils/approval-display.d.ts +49 -0
- package/dist/components/chat/utils/approval-display.d.ts.map +1 -0
- package/dist/components/chat/utils/index.d.ts +1 -0
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/chat/utils/message-segment-accumulator.d.ts +25 -3
- package/dist/components/chat/utils/message-segment-accumulator.d.ts.map +1 -1
- 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 +22 -22
- package/dist/components/help-center-pages/index.js +13 -13
- package/dist/components/index.cjs +140 -132
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +19 -11
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +34 -34
- package/dist/components/meeting-scheduler/index.js +3 -3
- 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/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +6 -6
- package/dist/components/tickets/index.js +5 -5
- package/dist/components/ui/index.cjs +10 -2
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +9 -1
- package/dist/components/ui/markdown/rich/embed-overrides.d.ts.map +1 -1
- package/dist/components/ui/markdown/rich/shortcodes.d.ts.map +1 -1
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/social-embed-cache.d.ts +16 -16
- package/dist/utils/social-embed-cache.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/__snapshots__/nats-decoder-golden.test.ts.snap +70 -0
- package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +108 -1
- package/src/chat-protocol/confirm-tool.ts +67 -0
- package/src/chat-protocol/decode.ts +7 -153
- package/src/chat-protocol/events.ts +40 -0
- package/src/chat-protocol/index.ts +3 -0
- package/src/chat-protocol/leading-frames.ts +175 -0
- package/src/chat-protocol/nats-decoder.ts +111 -3
- package/src/components/chat/embeddable-chat.tsx +18 -0
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +7 -16
- package/src/components/chat/stream/chat-stream-reducer.ts +49 -3
- package/src/components/chat/types/message.types.ts +15 -0
- package/src/components/chat/types/network.types.ts +4 -0
- package/src/components/chat/types/processing.types.ts +12 -1
- package/src/components/chat/utils/__tests__/process-historical-messages-approvals.test.ts +92 -0
- package/src/components/chat/utils/approval-display.ts +70 -0
- package/src/components/chat/utils/index.ts +9 -0
- package/src/components/chat/utils/message-segment-accumulator.ts +62 -32
- package/src/components/chat/utils/process-historical-messages.ts +40 -6
- package/src/components/ui/__tests__/__snapshots__/markdown-parity.test.tsx.snap +1 -5
- package/src/components/ui/markdown/rich/__tests__/shortcodes.test.ts +58 -0
- package/src/components/ui/markdown/rich/embed-overrides.tsx +13 -7
- package/src/components/ui/markdown/rich/shortcodes.ts +15 -0
- package/src/utils/social-embed-cache.ts +63 -336
- package/dist/chunk-GVLA2BPW.cjs.map +0 -1
- package/dist/chunk-WINT757E.js.map +0 -1
- /package/dist/{chunk-IZOGFZ7N.js.map → chunk-2ALT6CTY.js.map} +0 -0
- /package/dist/{chunk-ECR37JHH.js.map → chunk-BSE2UT6L.js.map} +0 -0
- /package/dist/{chunk-XBYEPSNZ.js.map → chunk-BUVD2OAI.js.map} +0 -0
- /package/dist/{chunk-7SGBF2I2.js.map → chunk-D62VYSTL.js.map} +0 -0
- /package/dist/{chunk-UP4RA54U.js.map → chunk-H4W4LENJ.js.map} +0 -0
- /package/dist/{chunk-ALXLWF75.js.map → chunk-KZ6PWFHK.js.map} +0 -0
- /package/dist/{chunk-OAEJWP7H.js.map → chunk-MTCU5MQN.js.map} +0 -0
- /package/dist/{chunk-5W3RCZIK.js.map → chunk-ONIYUMTO.js.map} +0 -0
- /package/dist/{chunk-TQ7EPKKO.js.map → chunk-POFCTXNH.js.map} +0 -0
- /package/dist/{chunk-65NR333L.js.map → chunk-VYOGAQLM.js.map} +0 -0
- /package/dist/{chunk-AZBS4PZG.js.map → chunk-W4MXOBEW.js.map} +0 -0
- /package/dist/{chunk-KYQZBQYV.js.map → chunk-WBYRBTAS.js.map} +0 -0
- /package/dist/{chunk-3G7FDE5E.js.map → chunk-ZLLXYE2G.js.map} +0 -0
|
@@ -23109,9 +23109,8 @@ function useRichMarkdownRuntime() {
|
|
|
23109
23109
|
import { useState as useState50, useEffect as useEffect41, useRef as useRef33 } from "react";
|
|
23110
23110
|
|
|
23111
23111
|
// src/utils/social-embed-cache.ts
|
|
23112
|
-
var cachingRequests = /* @__PURE__ */ new Map();
|
|
23113
23112
|
var dataCache = /* @__PURE__ */ new Map();
|
|
23114
|
-
var
|
|
23113
|
+
var inflightRequests = /* @__PURE__ */ new Map();
|
|
23115
23114
|
var SocialEmbedCache = class _SocialEmbedCache {
|
|
23116
23115
|
static getInstance() {
|
|
23117
23116
|
if (!_SocialEmbedCache.instance) {
|
|
@@ -23119,269 +23118,64 @@ var SocialEmbedCache = class _SocialEmbedCache {
|
|
|
23119
23118
|
}
|
|
23120
23119
|
return _SocialEmbedCache.instance;
|
|
23121
23120
|
}
|
|
23122
|
-
// Check if data exists in memory cache
|
|
23123
23121
|
getFromMemory(url) {
|
|
23124
23122
|
return dataCache.get(url) || null;
|
|
23125
23123
|
}
|
|
23126
|
-
// Store data in memory cache
|
|
23127
23124
|
setInMemory(url, data) {
|
|
23128
23125
|
dataCache.set(url, data);
|
|
23129
23126
|
}
|
|
23130
|
-
|
|
23131
|
-
|
|
23132
|
-
|
|
23133
|
-
|
|
23134
|
-
const response = await fetch(`${options.apiEndpoint}?url=${encodeURIComponent(options.url)}&cache-only=true`);
|
|
23135
|
-
if (response.ok) {
|
|
23136
|
-
const data = await response.json();
|
|
23137
|
-
console.log(`\u2705 [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] Server cache hit: ${options.url}`);
|
|
23138
|
-
return data;
|
|
23139
|
-
} else if (response.status === 404) {
|
|
23140
|
-
console.log(`\u{1F4A8} [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] No server cache available for: ${options.url}`);
|
|
23141
|
-
return null;
|
|
23142
|
-
}
|
|
23143
|
-
} catch (error) {
|
|
23144
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] Server cache check failed for: ${options.url}`, error);
|
|
23145
|
-
}
|
|
23146
|
-
return null;
|
|
23147
|
-
}
|
|
23148
|
-
// Helper method to update server cache asynchronously
|
|
23149
|
-
async updateServerCache(apiEndpoint, url, data) {
|
|
23150
|
-
try {
|
|
23151
|
-
console.log(`\u{1F4BE} [Cache] Updating server cache for: ${url}`);
|
|
23152
|
-
await fetch(`${apiEndpoint}?url=${encodeURIComponent(url)}`, {
|
|
23153
|
-
method: "POST",
|
|
23154
|
-
headers: { "Content-Type": "application/json" },
|
|
23155
|
-
body: JSON.stringify(data)
|
|
23156
|
-
});
|
|
23157
|
-
console.log(`\u2705 [Cache] Server cache updated for: ${url}`);
|
|
23158
|
-
} catch (error) {
|
|
23159
|
-
console.log(`\u274C [Cache] Server cache update failed for: ${url}`, error);
|
|
23160
|
-
}
|
|
23161
|
-
}
|
|
23162
|
-
// Store data in server cache (with deduplication)
|
|
23163
|
-
async setInServer(options, data) {
|
|
23164
|
-
const cacheKey = `${options.platform}-${options.url}`;
|
|
23165
|
-
if (cachingRequests.has(cacheKey)) {
|
|
23166
|
-
console.log(`\u23ED\uFE0F [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] Server cache update skipped (already in progress): ${options.url}`);
|
|
23167
|
-
return;
|
|
23168
|
-
}
|
|
23169
|
-
console.log(`\u{1F4BE} [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] Updating server cache for: ${options.url}`);
|
|
23170
|
-
const cachePromise = fetch(`${options.apiEndpoint}?url=${encodeURIComponent(options.url)}`, {
|
|
23171
|
-
method: "POST",
|
|
23172
|
-
headers: { "Content-Type": "application/json" },
|
|
23173
|
-
body: JSON.stringify(data)
|
|
23174
|
-
}).then(() => {
|
|
23175
|
-
console.log(`\u2705 [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] Server cache updated successfully: ${options.url}`);
|
|
23176
|
-
cachingRequests.delete(cacheKey);
|
|
23177
|
-
}).catch((error) => {
|
|
23178
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Cache] Server cache update failed: ${options.url}`, error);
|
|
23179
|
-
cachingRequests.delete(cacheKey);
|
|
23180
|
-
});
|
|
23181
|
-
cachingRequests.set(cacheKey, cachePromise);
|
|
23182
|
-
await cachePromise;
|
|
23183
|
-
}
|
|
23184
|
-
// Direct fetch with platform-specific logic
|
|
23185
|
-
async fetchDirect(options) {
|
|
23186
|
-
try {
|
|
23187
|
-
console.log(`\u{1F504} [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Direct] Fetching content: ${options.url}`);
|
|
23188
|
-
const result = await options.directFetcher();
|
|
23189
|
-
console.log(`\u2705 [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Direct] Fetch successful: ${options.url}`);
|
|
23190
|
-
return result;
|
|
23191
|
-
} catch (error) {
|
|
23192
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Direct] Fetch failed: ${options.url}`, error);
|
|
23193
|
-
return null;
|
|
23194
|
-
}
|
|
23195
|
-
}
|
|
23196
|
-
// Unified cache hierarchy: Memory → Server → Direct
|
|
23127
|
+
/**
|
|
23128
|
+
* Memory → proxy. Kept the historical name so the embed clients'
|
|
23129
|
+
* call sites are unchanged.
|
|
23130
|
+
*/
|
|
23197
23131
|
async fetchWithHierarchy(options) {
|
|
23198
|
-
const { url, platform, onDataUpdate, onError, onLoading
|
|
23199
|
-
const platformName = platform.charAt(0).toUpperCase() + platform.slice(1);
|
|
23200
|
-
this.scheduleAsyncRefresh(platform, url, dataValidator, options.apiEndpoint);
|
|
23201
|
-
console.log(`\u{1F50D} [${platformName} Cache] Checking memory cache for: ${url}`);
|
|
23132
|
+
const { url, platform, apiEndpoint, dataValidator, onDataUpdate, onError, onLoading } = options;
|
|
23202
23133
|
const memoryData = this.getFromMemory(url);
|
|
23203
23134
|
if (memoryData && dataValidator(memoryData)) {
|
|
23204
|
-
console.log(`\u{1F48E} [${platformName} Cache] Memory cache hit for: ${url}`);
|
|
23205
23135
|
onDataUpdate(memoryData);
|
|
23206
23136
|
onLoading(false);
|
|
23207
23137
|
return;
|
|
23208
23138
|
}
|
|
23209
|
-
console.log(`\u{1F50D} [${platformName} Cache] No memory cache, checking server cache for: ${url}`);
|
|
23210
|
-
const serverCacheData = await this.getFromServer(options);
|
|
23211
|
-
if (serverCacheData && dataValidator(serverCacheData)) {
|
|
23212
|
-
console.log(`\u{1F3AF} [${platformName} Cache] Server cache hit (cached data) for: ${url}`);
|
|
23213
|
-
onDataUpdate(serverCacheData);
|
|
23214
|
-
this.setInMemory(url, serverCacheData);
|
|
23215
|
-
onLoading(false);
|
|
23216
|
-
return;
|
|
23217
|
-
}
|
|
23218
|
-
console.log(`\u{1F50D} [${platformName} Cache] No server cache, attempting direct fetch for: ${url}`);
|
|
23219
|
-
if (platform === "reddit") {
|
|
23220
|
-
try {
|
|
23221
|
-
const directResponse = await fetch(url, {
|
|
23222
|
-
method: "GET",
|
|
23223
|
-
headers: {
|
|
23224
|
-
"Accept": "application/json"
|
|
23225
|
-
},
|
|
23226
|
-
signal: AbortSignal.timeout(1e4)
|
|
23227
|
-
});
|
|
23228
|
-
if (directResponse.ok) {
|
|
23229
|
-
const directData = await directResponse.json();
|
|
23230
|
-
if (directData && dataValidator(directData)) {
|
|
23231
|
-
console.log(`\u2705 [${platformName} Direct] Browser direct fetch successful for: ${url}`);
|
|
23232
|
-
onDataUpdate(directData);
|
|
23233
|
-
this.setInMemory(url, directData);
|
|
23234
|
-
onLoading(false);
|
|
23235
|
-
setTimeout(() => {
|
|
23236
|
-
this.updateServerCache(options.apiEndpoint, url, directData);
|
|
23237
|
-
}, 0);
|
|
23238
|
-
return;
|
|
23239
|
-
}
|
|
23240
|
-
}
|
|
23241
|
-
console.log(`\u{1F4A8} [${platformName} Direct] Browser direct fetch failed (${directResponse.status}), trying server proxy...`);
|
|
23242
|
-
} catch (directError) {
|
|
23243
|
-
console.log(`\u{1F4A8} [${platformName} Direct] Browser direct fetch failed, trying server proxy...`, directError);
|
|
23244
|
-
}
|
|
23245
|
-
}
|
|
23246
|
-
console.log(`\u{1F50D} [${platformName} Cache] Trying server proxy for: ${url}`);
|
|
23247
23139
|
try {
|
|
23248
|
-
const
|
|
23249
|
-
if (
|
|
23250
|
-
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23254
|
-
console.log(`\u{1F3AF} [${platformName} Proxy] Server cache hit (cached data) for: ${url}`);
|
|
23255
|
-
} else if (cacheStatus === "MISS-FETCHED") {
|
|
23256
|
-
console.log(`\u{1F504} [${platformName} Proxy] Server processed fresh fetch (now cached) for: ${url}`);
|
|
23257
|
-
} else {
|
|
23258
|
-
console.log(`\u2705 [${platformName} Proxy] Server returned data (${cacheStatus}) for: ${url}`);
|
|
23259
|
-
}
|
|
23260
|
-
onDataUpdate(serverData);
|
|
23261
|
-
this.setInMemory(url, serverData);
|
|
23262
|
-
onLoading(false);
|
|
23263
|
-
return;
|
|
23264
|
-
} else {
|
|
23265
|
-
console.log(`\u26A0\uFE0F [${platformName} Proxy] Server returned data but validation failed for: ${url}`);
|
|
23266
|
-
throw new Error("Server proxy returned invalid data shape");
|
|
23267
|
-
}
|
|
23268
|
-
} else {
|
|
23269
|
-
let errorData = null;
|
|
23270
|
-
try {
|
|
23271
|
-
errorData = await response.json();
|
|
23272
|
-
} catch {
|
|
23273
|
-
}
|
|
23274
|
-
if (response.status === 404 && errorData?.error && errorData?.message) {
|
|
23275
|
-
console.log(`\u{1F6AB} [${platformName} Proxy] Content unavailable: ${errorData.message}`);
|
|
23276
|
-
onError(errorData.message);
|
|
23277
|
-
onLoading(false);
|
|
23278
|
-
return;
|
|
23279
|
-
}
|
|
23280
|
-
if (errorData?.error) {
|
|
23281
|
-
throw new Error(`Server error: ${errorData.error}`);
|
|
23282
|
-
}
|
|
23283
|
-
throw new Error(`Server proxy failed: ${response.status}`);
|
|
23140
|
+
const data = await this.fetchFromProxy(url, apiEndpoint, dataValidator);
|
|
23141
|
+
if (data) {
|
|
23142
|
+
this.setInMemory(url, data);
|
|
23143
|
+
onDataUpdate(data);
|
|
23144
|
+
onLoading(false);
|
|
23145
|
+
return;
|
|
23284
23146
|
}
|
|
23147
|
+
onError(`This ${platform === "reddit" ? "Reddit post" : "tweet"} could not be loaded.`);
|
|
23285
23148
|
} catch (error) {
|
|
23286
|
-
console.log(`\u274C [${
|
|
23149
|
+
console.log(`\u274C [${platform} embed] Proxy fetch failed for: ${url}`, error);
|
|
23287
23150
|
onError(`Unable to load ${platform} content`);
|
|
23288
|
-
onLoading(false);
|
|
23289
23151
|
}
|
|
23152
|
+
onLoading(false);
|
|
23290
23153
|
}
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
|
|
23297
|
-
|
|
23298
|
-
|
|
23299
|
-
|
|
23300
|
-
fetch(`${apiEndpoint}?url=${encodeURIComponent(url)}
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
23307
|
-
}).then((data) => {
|
|
23308
|
-
if (data && dataValidator(data)) {
|
|
23309
|
-
this.setInMemory(url, data);
|
|
23310
|
-
console.log(`\u2705 [${platformName} Async] Background refresh completed for: ${url}`);
|
|
23311
|
-
} else if (data) {
|
|
23312
|
-
console.log(`\u274C [${platformName} Async] Background refresh failed (invalid data) for: ${url}`);
|
|
23313
|
-
}
|
|
23314
|
-
}).catch((error) => console.log(`\u274C [${platformName} Async] Background refresh failed for: ${url}`, error));
|
|
23315
|
-
}, 1e3);
|
|
23316
|
-
}
|
|
23317
|
-
// Background refresh to keep cache fresh (with request deduplication)
|
|
23318
|
-
async backgroundRefresh(options, currentData) {
|
|
23319
|
-
const refreshKey = `refresh-${options.platform}-${options.url}`;
|
|
23320
|
-
const now = Date.now();
|
|
23321
|
-
const lastRefresh = refreshTimestamps.get(refreshKey);
|
|
23322
|
-
if (lastRefresh && now - lastRefresh < 3e4) {
|
|
23323
|
-
console.log(`\u23ED\uFE0F [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Background] Refresh skipped (recent refresh): ${options.url}`);
|
|
23324
|
-
return;
|
|
23325
|
-
}
|
|
23326
|
-
if (cachingRequests.has(refreshKey)) {
|
|
23327
|
-
console.log(`\u23ED\uFE0F [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Background] Refresh skipped (already in progress): ${options.url}`);
|
|
23328
|
-
return;
|
|
23329
|
-
}
|
|
23330
|
-
const refreshPromise = (async () => {
|
|
23331
|
-
try {
|
|
23332
|
-
console.log(`\u{1F504} [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Background] Starting background refresh for: ${options.url}`);
|
|
23333
|
-
refreshTimestamps.set(refreshKey, now);
|
|
23334
|
-
const freshData = await this.fetchDirect(options);
|
|
23335
|
-
if (freshData && options.dataValidator(freshData)) {
|
|
23336
|
-
this.setInMemory(options.url, freshData);
|
|
23337
|
-
await this.setInServer(options, freshData);
|
|
23338
|
-
console.log(`\u2705 [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Background] Background refresh completed for: ${options.url}`);
|
|
23339
|
-
} else {
|
|
23340
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Background] Background refresh failed (invalid data) for: ${options.url}`);
|
|
23341
|
-
}
|
|
23342
|
-
} catch (error) {
|
|
23343
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Background] Background refresh failed for: ${options.url}`, error);
|
|
23344
|
-
} finally {
|
|
23345
|
-
cachingRequests.delete(refreshKey);
|
|
23154
|
+
/**
|
|
23155
|
+
* Returns the validated payload, `null` for a structured "content
|
|
23156
|
+
* unavailable" 404, and throws for everything else. Concurrent calls for
|
|
23157
|
+
* the same URL share one request.
|
|
23158
|
+
*/
|
|
23159
|
+
fetchFromProxy(url, apiEndpoint, dataValidator) {
|
|
23160
|
+
const inflight = inflightRequests.get(url);
|
|
23161
|
+
if (inflight) return inflight;
|
|
23162
|
+
const request = (async () => {
|
|
23163
|
+
const response = await fetch(`${apiEndpoint}?url=${encodeURIComponent(url)}`, {
|
|
23164
|
+
signal: AbortSignal.timeout(15e3)
|
|
23165
|
+
});
|
|
23166
|
+
if (response.ok) {
|
|
23167
|
+
const data = await response.json();
|
|
23168
|
+
if (data && dataValidator(data)) return data;
|
|
23169
|
+
throw new Error("Server proxy returned invalid data shape");
|
|
23346
23170
|
}
|
|
23171
|
+
if (response.status === 404) return null;
|
|
23172
|
+
throw new Error(`Server proxy failed: ${response.status}`);
|
|
23347
23173
|
})();
|
|
23348
|
-
|
|
23349
|
-
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
|
|
23353
|
-
const refreshKey = `silent-refresh-${options.platform}-${options.url}`;
|
|
23354
|
-
const now = Date.now();
|
|
23355
|
-
const lastRefresh = refreshTimestamps.get(refreshKey);
|
|
23356
|
-
if (lastRefresh && now - lastRefresh < 3e5) {
|
|
23357
|
-
console.log(`\u23ED\uFE0F [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Silent] Silent refresh skipped (recent refresh): ${options.url}`);
|
|
23358
|
-
return;
|
|
23359
|
-
}
|
|
23360
|
-
if (cachingRequests.has(refreshKey)) {
|
|
23361
|
-
console.log(`\u23ED\uFE0F [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Silent] Silent refresh skipped (already in progress): ${options.url}`);
|
|
23362
|
-
return;
|
|
23363
|
-
}
|
|
23364
|
-
setTimeout(() => {
|
|
23365
|
-
const refreshPromise = (async () => {
|
|
23366
|
-
try {
|
|
23367
|
-
console.log(`\u{1F504} [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Silent] Starting silent background refresh for: ${options.url}`);
|
|
23368
|
-
refreshTimestamps.set(refreshKey, now);
|
|
23369
|
-
const freshData = await this.fetchDirect(options);
|
|
23370
|
-
if (freshData && options.dataValidator(freshData)) {
|
|
23371
|
-
this.setInMemory(options.url, freshData);
|
|
23372
|
-
await this.setInServer(options, freshData);
|
|
23373
|
-
console.log(`\u2705 [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Silent] Silent refresh completed for: ${options.url}`);
|
|
23374
|
-
} else {
|
|
23375
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Silent] Silent refresh failed (invalid data) for: ${options.url}`);
|
|
23376
|
-
}
|
|
23377
|
-
} catch (error) {
|
|
23378
|
-
console.log(`\u274C [${options.platform.charAt(0).toUpperCase() + options.platform.slice(1)} Silent] Silent refresh failed for: ${options.url}`, error);
|
|
23379
|
-
} finally {
|
|
23380
|
-
cachingRequests.delete(refreshKey);
|
|
23381
|
-
}
|
|
23382
|
-
})();
|
|
23383
|
-
cachingRequests.set(refreshKey, refreshPromise);
|
|
23384
|
-
}, 0);
|
|
23174
|
+
inflightRequests.set(
|
|
23175
|
+
url,
|
|
23176
|
+
request.finally(() => inflightRequests.delete(url))
|
|
23177
|
+
);
|
|
23178
|
+
return inflightRequests.get(url);
|
|
23385
23179
|
}
|
|
23386
23180
|
};
|
|
23387
23181
|
var socialCache = SocialEmbedCache.getInstance();
|
|
@@ -25019,13 +24813,15 @@ function buildRichEmbedOverrides({
|
|
|
25019
24813
|
}
|
|
25020
24814
|
return standard.div(divProps);
|
|
25021
24815
|
},
|
|
25022
|
-
//
|
|
25023
|
-
// `<blockquote class="reddit-embed-bq">…<a href="post-url">`
|
|
25024
|
-
//
|
|
25025
|
-
//
|
|
25026
|
-
//
|
|
25027
|
-
//
|
|
25028
|
-
//
|
|
24816
|
+
// Pasted-from-the-platform embed markup lives in published blog posts as
|
|
24817
|
+
// `<blockquote class="reddit-embed-bq">…<a href="post-url">` (58 blocks
|
|
24818
|
+
// across 9 posts) — and Twitter's equivalent is
|
|
24819
|
+
// `<blockquote class="twitter-tweet">…<a href="status-url">`. Each pair
|
|
24820
|
+
// ships a `widgets.js` loader script, which `processShortcodes` strips
|
|
24821
|
+
// from the source text (Step 1.5). The composition rehydrates the
|
|
24822
|
+
// blockquote itself: extract the post URL from the first matching link
|
|
24823
|
+
// and render the platform's embed-client SSOT. Other blockquotes fall
|
|
24824
|
+
// through to the engine's base blockquote.
|
|
25029
24825
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25030
24826
|
blockquote: (bqProps) => {
|
|
25031
24827
|
const { node, className } = bqProps;
|
|
@@ -25034,6 +24830,10 @@ function buildRichEmbedOverrides({
|
|
|
25034
24830
|
const postUrl = findFirstHref(node, /reddit\.com/);
|
|
25035
24831
|
if (postUrl) return /* @__PURE__ */ jsx169(RedditEmbedClient, { url: postUrl });
|
|
25036
24832
|
}
|
|
24833
|
+
if (classNames.includes("twitter-tweet")) {
|
|
24834
|
+
const tweetUrl = findFirstHref(node, /(?:twitter\.com|x\.com)\/[^/]+\/status\//);
|
|
24835
|
+
if (tweetUrl) return /* @__PURE__ */ jsx169(TwitterEmbedClient, { url: tweetUrl });
|
|
24836
|
+
}
|
|
25037
24837
|
return standard.blockquote(bqProps);
|
|
25038
24838
|
},
|
|
25039
24839
|
// In-article images: MarkdownImage reads `transformImageSrc` from the
|
|
@@ -25120,6 +24920,10 @@ var processShortcodes = (content) => {
|
|
|
25120
24920
|
codeBlocks.push(match2);
|
|
25121
24921
|
return placeholder;
|
|
25122
24922
|
});
|
|
24923
|
+
processedContent = processedContent.replace(
|
|
24924
|
+
/<script\b[^>]{0,2000}>[\s\S]{0,20000}?<\/script\s{0,10}>/gi,
|
|
24925
|
+
""
|
|
24926
|
+
);
|
|
25123
24927
|
const markdownLinks = [];
|
|
25124
24928
|
processedContent = processedContent.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match2) => {
|
|
25125
24929
|
const placeholder = `__MARKDOWN_LINK_${markdownLinks.length}__`;
|
|
@@ -54602,12 +54406,29 @@ function useChat({
|
|
|
54602
54406
|
// src/components/chat/hooks/use-sse-chat-adapter.ts
|
|
54603
54407
|
import { useCallback as useCallback56, useMemo as useMemo52, useRef as useRef79 } from "react";
|
|
54604
54408
|
|
|
54409
|
+
// src/chat-protocol/confirm-tool.ts
|
|
54410
|
+
function buildConfirmToolBody(request) {
|
|
54411
|
+
return {
|
|
54412
|
+
proposal_id: request.proposalId,
|
|
54413
|
+
action: request.action,
|
|
54414
|
+
conversationId: request.conversationId
|
|
54415
|
+
};
|
|
54416
|
+
}
|
|
54417
|
+
async function readServerErrorMessage(response) {
|
|
54418
|
+
try {
|
|
54419
|
+
const body = await response.json();
|
|
54420
|
+
if (typeof body?.error === "string" && body.error.length > 0) return body.error;
|
|
54421
|
+
} catch {
|
|
54422
|
+
}
|
|
54423
|
+
return null;
|
|
54424
|
+
}
|
|
54425
|
+
|
|
54605
54426
|
// src/chat-protocol/frames.ts
|
|
54606
54427
|
var FRAME_TERMINATOR = "\0";
|
|
54607
54428
|
var END_OF_LEADING = "";
|
|
54608
54429
|
var TRAILER_SENTINEL = "";
|
|
54609
54430
|
|
|
54610
|
-
// src/chat-protocol/
|
|
54431
|
+
// src/chat-protocol/leading-frames.ts
|
|
54611
54432
|
function escapeThinkingTags(text) {
|
|
54612
54433
|
return text.replace(/</g, "<");
|
|
54613
54434
|
}
|
|
@@ -54714,6 +54535,8 @@ function mapLeadingFrame(meta, out) {
|
|
|
54714
54535
|
});
|
|
54715
54536
|
}
|
|
54716
54537
|
}
|
|
54538
|
+
|
|
54539
|
+
// src/chat-protocol/decode.ts
|
|
54717
54540
|
function createSseFrameDecoder() {
|
|
54718
54541
|
const textDecoder = new TextDecoder();
|
|
54719
54542
|
let buffer = "";
|
|
@@ -55373,21 +55196,41 @@ var MessageSegmentAccumulator = class {
|
|
|
55373
55196
|
/**
|
|
55374
55197
|
* Add an approval request segment directly (for CLIENT approvals)
|
|
55375
55198
|
*/
|
|
55376
|
-
addApprovalRequest(requestId, command, explanation, approvalType, status = "pending") {
|
|
55377
|
-
|
|
55199
|
+
addApprovalRequest(requestId, command, explanation, approvalType, status = "pending", fields, origin) {
|
|
55200
|
+
this.segments.push(
|
|
55201
|
+
this.buildApprovalRequestSegment(
|
|
55202
|
+
requestId,
|
|
55203
|
+
{ command, explanation, approvalType, fields, origin },
|
|
55204
|
+
status
|
|
55205
|
+
)
|
|
55206
|
+
);
|
|
55207
|
+
return this.getSegments();
|
|
55208
|
+
}
|
|
55209
|
+
/**
|
|
55210
|
+
* Build one approval-request segment — THE constructor for this segment type.
|
|
55211
|
+
*
|
|
55212
|
+
* Three paths produce these: `addApprovalRequest` (live stream and replay),
|
|
55213
|
+
* `flushPendingApprovals` (tracked-but-unresolved after a history replay) and
|
|
55214
|
+
* `processApprovalResult` (a result arriving for a tracked request). They used
|
|
55215
|
+
* to hand-write the object each, which is how `fields` and `origin` reached
|
|
55216
|
+
* the card down one path and not the others — the same proposal rendering as a
|
|
55217
|
+
* bare title, or losing the marker that routes its buttons to the hub.
|
|
55218
|
+
*/
|
|
55219
|
+
buildApprovalRequestSegment(requestId, approval, status) {
|
|
55220
|
+
return {
|
|
55378
55221
|
type: "approval_request",
|
|
55379
55222
|
data: {
|
|
55380
|
-
command,
|
|
55381
|
-
explanation,
|
|
55223
|
+
command: approval.command,
|
|
55224
|
+
explanation: approval.explanation,
|
|
55382
55225
|
requestId,
|
|
55383
|
-
approvalType
|
|
55226
|
+
approvalType: approval.approvalType,
|
|
55227
|
+
...approval.fields && approval.fields.length > 0 ? { fields: approval.fields } : {},
|
|
55228
|
+
...approval.origin ? { origin: approval.origin } : {}
|
|
55384
55229
|
},
|
|
55385
55230
|
status,
|
|
55386
55231
|
onApprove: this.callbacks.onApprove,
|
|
55387
55232
|
onReject: this.callbacks.onReject
|
|
55388
55233
|
};
|
|
55389
|
-
this.segments.push(segment);
|
|
55390
|
-
return this.getSegments();
|
|
55391
55234
|
}
|
|
55392
55235
|
/**
|
|
55393
55236
|
* Add a batch approval segment containing multiple tool calls. Upserts by
|
|
@@ -55402,20 +55245,22 @@ var MessageSegmentAccumulator = class {
|
|
|
55402
55245
|
* `executions` is forwarded as-is. On upsert, a new `executions` object
|
|
55403
55246
|
* overrides the existing one (so the latest replay wins).
|
|
55404
55247
|
*/
|
|
55405
|
-
addApprovalBatch(approvalRequestId, approvalType, toolCalls, status = "pending", executions, resolvedByName) {
|
|
55248
|
+
addApprovalBatch(approvalRequestId, approvalType, toolCalls, status = "pending", executions, resolvedByName, origin) {
|
|
55406
55249
|
const existingIndex = this.segments.findIndex(
|
|
55407
55250
|
(s) => s.type === "approval_batch" && s.data.approvalRequestId === approvalRequestId
|
|
55408
55251
|
);
|
|
55409
55252
|
if (existingIndex !== -1) {
|
|
55410
55253
|
const existing = this.segments[existingIndex];
|
|
55411
55254
|
const mergedExecutions = executions ?? existing.data.executions;
|
|
55255
|
+
const mergedOrigin = origin ?? existing.data.origin;
|
|
55412
55256
|
this.segments[existingIndex] = {
|
|
55413
55257
|
...existing,
|
|
55414
55258
|
data: {
|
|
55415
55259
|
approvalRequestId,
|
|
55416
55260
|
approvalType,
|
|
55417
55261
|
toolCalls,
|
|
55418
|
-
...mergedExecutions ? { executions: mergedExecutions } : {}
|
|
55262
|
+
...mergedExecutions ? { executions: mergedExecutions } : {},
|
|
55263
|
+
...mergedOrigin ? { origin: mergedOrigin } : {}
|
|
55419
55264
|
},
|
|
55420
55265
|
status,
|
|
55421
55266
|
resolvedByName: resolvedByName ?? existing.resolvedByName,
|
|
@@ -55430,7 +55275,8 @@ var MessageSegmentAccumulator = class {
|
|
|
55430
55275
|
approvalRequestId,
|
|
55431
55276
|
approvalType,
|
|
55432
55277
|
toolCalls,
|
|
55433
|
-
...executions ? { executions } : {}
|
|
55278
|
+
...executions ? { executions } : {},
|
|
55279
|
+
...origin ? { origin } : {}
|
|
55434
55280
|
},
|
|
55435
55281
|
status,
|
|
55436
55282
|
resolvedByName,
|
|
@@ -55447,18 +55293,15 @@ var MessageSegmentAccumulator = class {
|
|
|
55447
55293
|
processApprovalResult(requestId, approved, approvalType) {
|
|
55448
55294
|
const pendingApproval = this.pendingApprovals.get(requestId);
|
|
55449
55295
|
const status = approved ? "approved" : "rejected";
|
|
55450
|
-
const segment =
|
|
55451
|
-
|
|
55452
|
-
|
|
55296
|
+
const segment = this.buildApprovalRequestSegment(
|
|
55297
|
+
requestId,
|
|
55298
|
+
{
|
|
55299
|
+
...pendingApproval,
|
|
55453
55300
|
command: pendingApproval?.command || "",
|
|
55454
|
-
explanation: pendingApproval?.explanation,
|
|
55455
|
-
requestId,
|
|
55456
55301
|
approvalType: pendingApproval?.approvalType || approvalType
|
|
55457
55302
|
},
|
|
55458
|
-
status
|
|
55459
|
-
|
|
55460
|
-
onReject: this.callbacks.onReject
|
|
55461
|
-
};
|
|
55303
|
+
status
|
|
55304
|
+
);
|
|
55462
55305
|
this.segments.push(segment);
|
|
55463
55306
|
if (pendingApproval) {
|
|
55464
55307
|
this.pendingApprovals.delete(requestId);
|
|
@@ -55539,18 +55382,7 @@ var MessageSegmentAccumulator = class {
|
|
|
55539
55382
|
flushPendingApprovals() {
|
|
55540
55383
|
const segments = [];
|
|
55541
55384
|
this.pendingApprovals.forEach((approval, requestId) => {
|
|
55542
|
-
segments.push(
|
|
55543
|
-
type: "approval_request",
|
|
55544
|
-
data: {
|
|
55545
|
-
command: approval.command,
|
|
55546
|
-
explanation: approval.explanation,
|
|
55547
|
-
requestId,
|
|
55548
|
-
approvalType: approval.approvalType
|
|
55549
|
-
},
|
|
55550
|
-
status: "pending",
|
|
55551
|
-
onApprove: this.callbacks.onApprove,
|
|
55552
|
-
onReject: this.callbacks.onReject
|
|
55553
|
-
});
|
|
55385
|
+
segments.push(this.buildApprovalRequestSegment(requestId, approval, "pending"));
|
|
55554
55386
|
});
|
|
55555
55387
|
return segments;
|
|
55556
55388
|
}
|
|
@@ -55616,7 +55448,9 @@ var MessageSegmentAccumulator = class {
|
|
|
55616
55448
|
data.command,
|
|
55617
55449
|
data.explanation,
|
|
55618
55450
|
data.approvalType || "",
|
|
55619
|
-
status
|
|
55451
|
+
status,
|
|
55452
|
+
data.fields,
|
|
55453
|
+
data.origin
|
|
55620
55454
|
);
|
|
55621
55455
|
break;
|
|
55622
55456
|
}
|
|
@@ -55628,7 +55462,8 @@ var MessageSegmentAccumulator = class {
|
|
|
55628
55462
|
data.toolCalls,
|
|
55629
55463
|
status,
|
|
55630
55464
|
data.executions,
|
|
55631
|
-
resolvedByName
|
|
55465
|
+
resolvedByName,
|
|
55466
|
+
data.origin
|
|
55632
55467
|
);
|
|
55633
55468
|
break;
|
|
55634
55469
|
}
|
|
@@ -55672,6 +55507,10 @@ function createMessageSegmentAccumulator(callbacks) {
|
|
|
55672
55507
|
}
|
|
55673
55508
|
|
|
55674
55509
|
// src/chat-protocol/events.ts
|
|
55510
|
+
var GUIDE_ORIGIN = "guide";
|
|
55511
|
+
function isGuideOrigin(source) {
|
|
55512
|
+
return source?.origin === GUIDE_ORIGIN;
|
|
55513
|
+
}
|
|
55675
55514
|
var ESCALATION_STATE = {
|
|
55676
55515
|
PENDING: "PENDING",
|
|
55677
55516
|
APPROVED: "APPROVED",
|
|
@@ -55692,6 +55531,22 @@ function escalationResolvedStatus(state) {
|
|
|
55692
55531
|
}
|
|
55693
55532
|
var CHAT_OWNER_ADMIN = "ADMIN";
|
|
55694
55533
|
|
|
55534
|
+
// src/components/chat/utils/approval-display.ts
|
|
55535
|
+
function isGuideApproval(source) {
|
|
55536
|
+
return isGuideOrigin(source);
|
|
55537
|
+
}
|
|
55538
|
+
function guideApprovalOrigin(source) {
|
|
55539
|
+
return isGuideApproval(source) ? GUIDE_ORIGIN : void 0;
|
|
55540
|
+
}
|
|
55541
|
+
function approvalDisplaysInline(source, approvalType, displayApprovalTypes) {
|
|
55542
|
+
if (isGuideApproval(source)) return true;
|
|
55543
|
+
return !displayApprovalTypes || displayApprovalTypes.includes(approvalType);
|
|
55544
|
+
}
|
|
55545
|
+
function isGuideApprovalSegment(segment) {
|
|
55546
|
+
if (segment.type !== "approval_request" && segment.type !== "approval_batch") return false;
|
|
55547
|
+
return isGuideApproval(segment.data);
|
|
55548
|
+
}
|
|
55549
|
+
|
|
55695
55550
|
// src/components/chat/stream/chat-stream-reducer.ts
|
|
55696
55551
|
function createEmptyTurnMeta() {
|
|
55697
55552
|
return {
|
|
@@ -55727,6 +55582,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
55727
55582
|
let streamingPhase = "idle";
|
|
55728
55583
|
let dialogTokenUsage = null;
|
|
55729
55584
|
let liveModel = null;
|
|
55585
|
+
let guideConversationId = null;
|
|
55730
55586
|
let approvalStatuses = {
|
|
55731
55587
|
...options.approvalStatuses ?? {}
|
|
55732
55588
|
};
|
|
@@ -55787,7 +55643,8 @@ function createChatStreamReducer(options = {}) {
|
|
|
55787
55643
|
turnMeta: { meta: metaMap, sources: sourcesMap, refs: refsMap, sendCount },
|
|
55788
55644
|
dialogTokenUsage,
|
|
55789
55645
|
liveModel,
|
|
55790
|
-
approvalStatuses
|
|
55646
|
+
approvalStatuses,
|
|
55647
|
+
guideConversationId
|
|
55791
55648
|
};
|
|
55792
55649
|
}
|
|
55793
55650
|
return stateCache;
|
|
@@ -55977,6 +55834,13 @@ function createChatStreamReducer(options = {}) {
|
|
|
55977
55834
|
break;
|
|
55978
55835
|
}
|
|
55979
55836
|
case "metadata": {
|
|
55837
|
+
if (isGuideOrigin(event)) {
|
|
55838
|
+
if (typeof event.conversationId === "string" && event.conversationId) {
|
|
55839
|
+
guideConversationId = event.conversationId;
|
|
55840
|
+
invalidate();
|
|
55841
|
+
}
|
|
55842
|
+
break;
|
|
55843
|
+
}
|
|
55980
55844
|
emit("onMetadata", {
|
|
55981
55845
|
action: "metadata",
|
|
55982
55846
|
modelDisplayName: event.modelLabel ?? void 0,
|
|
@@ -56053,9 +55917,11 @@ function createChatStreamReducer(options = {}) {
|
|
|
56053
55917
|
const requestId = event.requestId;
|
|
56054
55918
|
const approvalType = event.approvalType ?? "USER";
|
|
56055
55919
|
const toolCalls = event.toolCalls;
|
|
55920
|
+
const guideOrigin = guideApprovalOrigin(event);
|
|
55921
|
+
const displayInline = (type) => approvalDisplaysInline(event, type, displayApprovalTypes);
|
|
56056
55922
|
if (toolCalls && toolCalls.length > 0) {
|
|
56057
55923
|
const status = approvalStatuses[requestId] || "pending";
|
|
56058
|
-
if (!
|
|
55924
|
+
if (!displayInline(approvalType)) {
|
|
56059
55925
|
const required = toolCalls.find((c) => c.requiresApproval) ?? toolCalls[0];
|
|
56060
55926
|
const summary = required ? getCommandText(required) : `Batch of ${toolCalls.length} tool calls`;
|
|
56061
55927
|
pendingEscalated.set(requestId, {
|
|
@@ -56073,7 +55939,15 @@ function createChatStreamReducer(options = {}) {
|
|
|
56073
55939
|
}
|
|
56074
55940
|
if (batchApprovalsEnabled) {
|
|
56075
55941
|
const before2 = accumulator.getSegments().length;
|
|
56076
|
-
const segments2 = accumulator.addApprovalBatch(
|
|
55942
|
+
const segments2 = accumulator.addApprovalBatch(
|
|
55943
|
+
requestId,
|
|
55944
|
+
approvalType,
|
|
55945
|
+
toolCalls,
|
|
55946
|
+
status,
|
|
55947
|
+
void 0,
|
|
55948
|
+
void 0,
|
|
55949
|
+
guideOrigin
|
|
55950
|
+
);
|
|
56077
55951
|
applyAccumulated(before2, segments2);
|
|
56078
55952
|
break;
|
|
56079
55953
|
}
|
|
@@ -56086,7 +55960,9 @@ function createChatStreamReducer(options = {}) {
|
|
|
56086
55960
|
getCommandText(call),
|
|
56087
55961
|
call.toolExplanation,
|
|
56088
55962
|
approvalType,
|
|
56089
|
-
status
|
|
55963
|
+
status,
|
|
55964
|
+
void 0,
|
|
55965
|
+
guideOrigin
|
|
56090
55966
|
);
|
|
56091
55967
|
}
|
|
56092
55968
|
applyAccumulated(before, segments);
|
|
@@ -56094,7 +55970,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
56094
55970
|
}
|
|
56095
55971
|
const command = event.command ?? "";
|
|
56096
55972
|
const explanation = event.explanation;
|
|
56097
|
-
if (
|
|
55973
|
+
if (displayInline(approvalType)) {
|
|
56098
55974
|
const status = approvalStatuses[requestId] || "pending";
|
|
56099
55975
|
const before = accumulator.getSegments().length;
|
|
56100
55976
|
const segments = accumulator.addApprovalRequest(
|
|
@@ -56102,7 +55978,11 @@ function createChatStreamReducer(options = {}) {
|
|
|
56102
55978
|
command,
|
|
56103
55979
|
explanation,
|
|
56104
55980
|
approvalType,
|
|
56105
|
-
status
|
|
55981
|
+
status,
|
|
55982
|
+
// SSE-shaped cards (a re-streamed Product Guide proposal) carry
|
|
55983
|
+
// their body as structured rows rather than prose.
|
|
55984
|
+
event.fields,
|
|
55985
|
+
guideOrigin
|
|
56106
55986
|
);
|
|
56107
55987
|
applyAccumulated(before, segments);
|
|
56108
55988
|
} else {
|
|
@@ -56519,6 +56399,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
56519
56399
|
streamingPhase = "idle";
|
|
56520
56400
|
dialogTokenUsage = null;
|
|
56521
56401
|
liveModel = null;
|
|
56402
|
+
guideConversationId = null;
|
|
56522
56403
|
approvalStatuses = {};
|
|
56523
56404
|
accumulator.reset();
|
|
56524
56405
|
pendingEscalated.clear();
|
|
@@ -56542,6 +56423,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
56542
56423
|
streamingPhase = "idle";
|
|
56543
56424
|
dialogTokenUsage = null;
|
|
56544
56425
|
liveModel = null;
|
|
56426
|
+
guideConversationId = null;
|
|
56545
56427
|
accumulator.reset();
|
|
56546
56428
|
pendingEscalated.clear();
|
|
56547
56429
|
isInStream = false;
|
|
@@ -57237,13 +57119,13 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
57237
57119
|
const { hidden, attachments, commandOverride, approvalAction } = sendOptions ?? {};
|
|
57238
57120
|
const conversationId = conversationIdRef.current;
|
|
57239
57121
|
const targetPath = approvalAction ? endpointsRef.current.approvalToolUrl : endpointsRef.current.chatStreamUrl;
|
|
57240
|
-
const requestBody = approvalAction ?
|
|
57241
|
-
|
|
57242
|
-
|
|
57243
|
-
//
|
|
57122
|
+
const requestBody = approvalAction ? (
|
|
57123
|
+
// Shared with every other transport that resolves a hub proposal —
|
|
57124
|
+
// the body shape is the hub's, not this adapter's. `conversationId`
|
|
57125
|
+
// is always present here: an approval can only happen inside an
|
|
57244
57126
|
// established conversation (the proposal turn captured the id).
|
|
57245
|
-
conversationId
|
|
57246
|
-
|
|
57127
|
+
buildConfirmToolBody({ ...approvalAction, conversationId })
|
|
57128
|
+
) : {
|
|
57247
57129
|
messages: [{ role: "user", content: text }],
|
|
57248
57130
|
...commandOverride ? { commandOverride } : {},
|
|
57249
57131
|
...attachments && attachments.length > 0 ? { pendingAttachments: attachments } : {},
|
|
@@ -57261,14 +57143,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
57261
57143
|
signal: ctrl.signal
|
|
57262
57144
|
});
|
|
57263
57145
|
if (!response.ok) {
|
|
57264
|
-
|
|
57265
|
-
try {
|
|
57266
|
-
const errBody = await response.json();
|
|
57267
|
-
if (typeof errBody?.error === "string" && errBody.error.length > 0) {
|
|
57268
|
-
serverMessage = errBody.error;
|
|
57269
|
-
}
|
|
57270
|
-
} catch {
|
|
57271
|
-
}
|
|
57146
|
+
const serverMessage = await readServerErrorMessage(response);
|
|
57272
57147
|
throw new Error(serverMessage ?? `Chat request failed: ${response.status}`);
|
|
57273
57148
|
}
|
|
57274
57149
|
const reader = response.body?.getReader();
|
|
@@ -57507,6 +57382,37 @@ function normalizeAskOptions(raw) {
|
|
|
57507
57382
|
description: typeof item.description === "string" ? item.description : void 0
|
|
57508
57383
|
})).filter((option) => option.label.length > 0);
|
|
57509
57384
|
}
|
|
57385
|
+
var AGENT_OWNED_EVENTS = /* @__PURE__ */ new Set([
|
|
57386
|
+
"usage",
|
|
57387
|
+
"token-usage",
|
|
57388
|
+
"status",
|
|
57389
|
+
"compaction",
|
|
57390
|
+
"participant",
|
|
57391
|
+
"dialog-closed"
|
|
57392
|
+
]);
|
|
57393
|
+
var ORIGIN_BEARING_EVENTS = /* @__PURE__ */ new Set([
|
|
57394
|
+
"approval-request",
|
|
57395
|
+
"approval-resolved"
|
|
57396
|
+
]);
|
|
57397
|
+
function guideEventForNats(event) {
|
|
57398
|
+
switch (event.type) {
|
|
57399
|
+
case "text-delta":
|
|
57400
|
+
return { type: "guide-delta", text: event.text };
|
|
57401
|
+
case "thinking-delta":
|
|
57402
|
+
return { type: "thinking-delta", text: escapeThinkingTags(event.text) };
|
|
57403
|
+
case "metadata":
|
|
57404
|
+
return typeof event.conversationId === "string" && event.conversationId ? { type: "metadata", conversationId: event.conversationId, origin: GUIDE_ORIGIN } : null;
|
|
57405
|
+
default:
|
|
57406
|
+
if (AGENT_OWNED_EVENTS.has(event.type)) return null;
|
|
57407
|
+
return ORIGIN_BEARING_EVENTS.has(event.type) ? { ...event, origin: GUIDE_ORIGIN } : event;
|
|
57408
|
+
}
|
|
57409
|
+
}
|
|
57410
|
+
function guideFrameEvent(frame) {
|
|
57411
|
+
const events = [];
|
|
57412
|
+
mapLeadingFrame(frame, events);
|
|
57413
|
+
const event = events[0];
|
|
57414
|
+
return event ? guideEventForNats(event) : null;
|
|
57415
|
+
}
|
|
57510
57416
|
function decodeNatsChunk(chunk) {
|
|
57511
57417
|
if (!chunk || typeof chunk !== "object") return null;
|
|
57512
57418
|
const data = chunk;
|
|
@@ -57541,11 +57447,20 @@ function decodeNatsChunk(chunk) {
|
|
|
57541
57447
|
return { type: "thinking-delta", text: data.text, ...seq };
|
|
57542
57448
|
}
|
|
57543
57449
|
return null;
|
|
57544
|
-
|
|
57450
|
+
// Two shapes share this chunk type. `text` is the answer body the agent
|
|
57451
|
+
// streams (and persists). `payload` is a Product Guide frame re-streamed
|
|
57452
|
+
// verbatim from the hub — decoded through the shared frame table, with the
|
|
57453
|
+
// narrowing `guideFrameEvent` documents.
|
|
57454
|
+
case MESSAGE_TYPE.GUIDE: {
|
|
57545
57455
|
if (typeof data.text === "string") {
|
|
57546
57456
|
return { type: "guide-delta", text: data.text, ...seq };
|
|
57547
57457
|
}
|
|
57548
|
-
|
|
57458
|
+
const frame = data.payload;
|
|
57459
|
+
if (!frame || typeof frame !== "object" || Array.isArray(frame)) return null;
|
|
57460
|
+
const event = guideFrameEvent(frame);
|
|
57461
|
+
if (!event) return null;
|
|
57462
|
+
return { ...event, ...seq };
|
|
57463
|
+
}
|
|
57549
57464
|
// An ask card is only an ask card with something to pick: a question and at
|
|
57550
57465
|
// least one option. Anything less is dropped rather than rendered as an
|
|
57551
57466
|
// empty card the user can't answer — the backend already falls back to a
|
|
@@ -57764,11 +57679,21 @@ function decodeHistoricalMessageData(data) {
|
|
|
57764
57679
|
return { type: "thinking-delta", text: data.text };
|
|
57765
57680
|
}
|
|
57766
57681
|
return null;
|
|
57767
|
-
|
|
57682
|
+
// Two persisted shapes, mirroring the live `GUIDE` chunk: the answer body
|
|
57683
|
+
// (`text`) and a Product Guide frame the agent re-streamed (`payload`,
|
|
57684
|
+
// persisted so a card survives a reload). Decoded through the SAME
|
|
57685
|
+
// `guideFrameEvent` the live path uses — a second mapping here would let
|
|
57686
|
+
// history and realtime disagree about the same bytes.
|
|
57687
|
+
case MESSAGE_TYPE.GUIDE: {
|
|
57768
57688
|
if ("text" in data && data.text) {
|
|
57769
57689
|
return { type: "guide-delta", text: data.text };
|
|
57770
57690
|
}
|
|
57691
|
+
const payload = "payload" in data ? data.payload : void 0;
|
|
57692
|
+
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
|
57693
|
+
return guideFrameEvent(payload);
|
|
57694
|
+
}
|
|
57771
57695
|
return null;
|
|
57696
|
+
}
|
|
57772
57697
|
// Same completeness gate as the live decoder (`decodeNatsChunk`): a
|
|
57773
57698
|
// persisted row without a question or without options is not a card the
|
|
57774
57699
|
// user can answer, so it replays as nothing rather than as empty chrome.
|
|
@@ -57946,11 +57871,20 @@ function applyHistoryEvent(event, accumulator, approvalStatuses, options, escala
|
|
|
57946
57871
|
const approvalType = event.approvalType || "CLIENT";
|
|
57947
57872
|
const toolCalls = event.toolCalls;
|
|
57948
57873
|
const isBatch = !!toolCalls && toolCalls.length > 0;
|
|
57949
|
-
|
|
57874
|
+
const guideOrigin = guideApprovalOrigin(event);
|
|
57875
|
+
if (approvalDisplaysInline(event, approvalType, displayApprovalTypes)) {
|
|
57950
57876
|
if (isBatch) {
|
|
57951
57877
|
const status = approvalStatuses[event.requestId] || "pending";
|
|
57952
57878
|
if (batchApprovalsEnabled) {
|
|
57953
|
-
accumulator.addApprovalBatch(
|
|
57879
|
+
accumulator.addApprovalBatch(
|
|
57880
|
+
event.requestId,
|
|
57881
|
+
approvalType,
|
|
57882
|
+
toolCalls,
|
|
57883
|
+
status,
|
|
57884
|
+
void 0,
|
|
57885
|
+
void 0,
|
|
57886
|
+
guideOrigin
|
|
57887
|
+
);
|
|
57954
57888
|
} else {
|
|
57955
57889
|
for (const call of toolCalls) {
|
|
57956
57890
|
if (!call.requiresApproval) continue;
|
|
@@ -57959,25 +57893,31 @@ function applyHistoryEvent(event, accumulator, approvalStatuses, options, escala
|
|
|
57959
57893
|
getCommandText(call),
|
|
57960
57894
|
call.toolExplanation,
|
|
57961
57895
|
approvalType,
|
|
57962
|
-
status
|
|
57896
|
+
status,
|
|
57897
|
+
void 0,
|
|
57898
|
+
guideOrigin
|
|
57963
57899
|
);
|
|
57964
57900
|
}
|
|
57965
57901
|
}
|
|
57966
57902
|
} else {
|
|
57967
57903
|
const resolvedStatus = approvalStatuses[event.requestId];
|
|
57968
|
-
|
|
57904
|
+
const isResolved = resolvedStatus === "approved" || resolvedStatus === "rejected";
|
|
57905
|
+
if (guideOrigin || isResolved) {
|
|
57969
57906
|
accumulator.addApprovalRequest(
|
|
57970
57907
|
event.requestId,
|
|
57971
57908
|
event.command || "",
|
|
57972
57909
|
event.explanation,
|
|
57973
57910
|
approvalType,
|
|
57974
|
-
resolvedStatus
|
|
57911
|
+
resolvedStatus ?? "pending",
|
|
57912
|
+
event.fields,
|
|
57913
|
+
guideOrigin
|
|
57975
57914
|
);
|
|
57976
57915
|
} else {
|
|
57977
57916
|
accumulator.trackApprovalRequest(event.requestId, {
|
|
57978
57917
|
command: event.command || "",
|
|
57979
57918
|
explanation: event.explanation,
|
|
57980
|
-
approvalType
|
|
57919
|
+
approvalType,
|
|
57920
|
+
fields: event.fields
|
|
57981
57921
|
});
|
|
57982
57922
|
}
|
|
57983
57923
|
}
|
|
@@ -59923,6 +59863,7 @@ function EmbeddableChatInner({
|
|
|
59923
59863
|
tableIdForDocumentType,
|
|
59924
59864
|
modes,
|
|
59925
59865
|
mingoState,
|
|
59866
|
+
pendingApprovals,
|
|
59926
59867
|
mingoDialogCapabilities,
|
|
59927
59868
|
activeMode: controlledActiveMode,
|
|
59928
59869
|
onActiveModeChange,
|
|
@@ -60800,6 +60741,7 @@ function EmbeddableChatInner({
|
|
|
60800
60741
|
{
|
|
60801
60742
|
messages,
|
|
60802
60743
|
isTyping: chatLoading,
|
|
60744
|
+
pendingApprovals,
|
|
60803
60745
|
autoScroll: !previewMode,
|
|
60804
60746
|
pinBottom: previewMode,
|
|
60805
60747
|
overscrollContain: !previewMode,
|
|
@@ -61647,6 +61589,10 @@ export {
|
|
|
61647
61589
|
createMessageSegmentAccumulator,
|
|
61648
61590
|
SCROLL_ANCHOR_WIRE_KEY,
|
|
61649
61591
|
parseScrollAnchor,
|
|
61592
|
+
isGuideApproval,
|
|
61593
|
+
guideApprovalOrigin,
|
|
61594
|
+
approvalDisplaysInline,
|
|
61595
|
+
isGuideApprovalSegment,
|
|
61650
61596
|
createEmptyTurnMeta,
|
|
61651
61597
|
createChatStreamReducer,
|
|
61652
61598
|
DEFAULT_DIALOG_SIDE,
|
|
@@ -62125,4 +62071,4 @@ export {
|
|
|
62125
62071
|
LogsList,
|
|
62126
62072
|
assets
|
|
62127
62073
|
};
|
|
62128
|
-
//# sourceMappingURL=chunk-
|
|
62074
|
+
//# sourceMappingURL=chunk-O6VJZX2N.js.map
|