@flamingo-stack/openframe-frontend-core 0.0.512-1640.4220.1 → 0.0.512
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-HCKICFSZ.cjs → chunk-2WWDZR4D.cjs} +31 -31
- package/dist/{chunk-HCKICFSZ.cjs.map → chunk-2WWDZR4D.cjs.map} +1 -1
- package/dist/{chunk-FAPHWUEM.cjs → chunk-2XL7UK5Y.cjs} +5 -5
- package/dist/{chunk-FAPHWUEM.cjs.map → chunk-2XL7UK5Y.cjs.map} +1 -1
- package/dist/{chunk-XHGL7XHL.js → chunk-4NFDSMB5.js} +4 -4
- package/dist/{chunk-YJRJCJRK.cjs → chunk-5JBDT2MQ.cjs} +7 -7
- package/dist/{chunk-YJRJCJRK.cjs.map → chunk-5JBDT2MQ.cjs.map} +1 -1
- package/dist/{chunk-VL6RXIPW.cjs → chunk-67YDSTH7.cjs} +9 -9
- package/dist/{chunk-VL6RXIPW.cjs.map → chunk-67YDSTH7.cjs.map} +1 -1
- package/dist/{chunk-7UYW6C4P.js → chunk-6LMTBNLN.js} +2 -2
- package/dist/{chunk-QXFJU5I2.cjs → chunk-7VBEOGCR.cjs} +61 -61
- package/dist/{chunk-QXFJU5I2.cjs.map → chunk-7VBEOGCR.cjs.map} +1 -1
- package/dist/{chunk-WOM5RZ6T.cjs → chunk-AWLFJMOJ.cjs} +37 -37
- package/dist/{chunk-WOM5RZ6T.cjs.map → chunk-AWLFJMOJ.cjs.map} +1 -1
- package/dist/{chunk-SIRV5BCG.cjs → chunk-DQDPDUI3.cjs} +4 -4
- package/dist/{chunk-SIRV5BCG.cjs.map → chunk-DQDPDUI3.cjs.map} +1 -1
- package/dist/{chunk-Y5QFN4WH.cjs → chunk-F2YI5N7E.cjs} +13 -13
- package/dist/{chunk-Y5QFN4WH.cjs.map → chunk-F2YI5N7E.cjs.map} +1 -1
- package/dist/{chunk-IYIO2OVS.js → chunk-FI35LJ3L.js} +2 -2
- package/dist/{chunk-NZR2U5VK.cjs → chunk-GOFTC2HV.cjs} +444 -479
- package/dist/chunk-GOFTC2HV.cjs.map +1 -0
- package/dist/{chunk-6SVI63CC.js → chunk-HGZPH7S5.js} +2 -2
- package/dist/{chunk-7LHDZK7M.js → chunk-IHNUMRMU.js} +2 -2
- package/dist/{chunk-YLVVZVK6.js → chunk-IK2WRYVA.js} +4 -4
- package/dist/{chunk-XDOZN745.cjs → chunk-JIW5JI3E.cjs} +3 -3
- package/dist/{chunk-XDOZN745.cjs.map → chunk-JIW5JI3E.cjs.map} +1 -1
- package/dist/{chunk-CLEAYFOX.js → chunk-JKAX5K7C.js} +5 -5
- package/dist/{chunk-4BUHSV4D.js → chunk-JO3NPEK6.js} +2 -2
- package/dist/{chunk-ARTN2P3B.js → chunk-JOFGJYIT.js} +2 -2
- package/dist/{chunk-ZI3GAXFN.js → chunk-OT4RV6WY.js} +6 -6
- package/dist/{chunk-QUT2X2LX.cjs → chunk-RJXI25TJ.cjs} +26 -26
- package/dist/{chunk-QUT2X2LX.cjs.map → chunk-RJXI25TJ.cjs.map} +1 -1
- package/dist/{chunk-EXDW3LB5.cjs → chunk-SG25J6LV.cjs} +87 -87
- package/dist/{chunk-EXDW3LB5.cjs.map → chunk-SG25J6LV.cjs.map} +1 -1
- package/dist/{chunk-DDWLGE6D.js → chunk-V5WLIFKN.js} +325 -360
- package/dist/chunk-V5WLIFKN.js.map +1 -0
- package/dist/{chunk-OOYBU46B.cjs → chunk-VVXUUBML.cjs} +26 -26
- package/dist/{chunk-OOYBU46B.cjs.map → chunk-VVXUUBML.cjs.map} +1 -1
- package/dist/{chunk-Q4XWNC33.js → chunk-VZX3SSFL.js} +2 -2
- package/dist/{chunk-WHKVCEAB.cjs → chunk-WVZHCDB5.cjs} +11 -11
- package/dist/{chunk-WHKVCEAB.cjs.map → chunk-WVZHCDB5.cjs.map} +1 -1
- package/dist/{chunk-UMUNWABO.js → chunk-XG7FLAKQ.js} +2 -2
- package/dist/{chunk-EYUANCRA.js → chunk-ZIQMVAGA.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/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat-card-item.d.ts +3 -0
- package/dist/components/chat/hooks/use-chat-card-item.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-strip-citations.d.ts.map +1 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/stream/message-mutations.d.ts +42 -5
- package/dist/components/chat/stream/message-mutations.d.ts.map +1 -1
- package/dist/components/chat/utils/message-segment-accumulator.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 +132 -132
- package/dist/components/index.js +11 -11
- 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 +2 -2
- package/dist/components/ui/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/chat/entity-cards/dispatch.tsx +92 -99
- package/src/components/chat/hooks/use-chat-card-item.ts +9 -0
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +15 -15
- package/src/components/chat/remark-strip-citations.ts +7 -5
- package/src/components/chat/stream/__tests__/chat-stream-reducer-approval-batch.test.ts +18 -0
- package/src/components/chat/stream/chat-stream-reducer.ts +12 -3
- package/src/components/chat/stream/message-mutations.ts +153 -96
- package/src/components/chat/utils/message-segment-accumulator.ts +19 -27
- package/dist/chunk-DDWLGE6D.js.map +0 -1
- package/dist/chunk-NZR2U5VK.cjs.map +0 -1
- /package/dist/{chunk-XHGL7XHL.js.map → chunk-4NFDSMB5.js.map} +0 -0
- /package/dist/{chunk-7UYW6C4P.js.map → chunk-6LMTBNLN.js.map} +0 -0
- /package/dist/{chunk-IYIO2OVS.js.map → chunk-FI35LJ3L.js.map} +0 -0
- /package/dist/{chunk-6SVI63CC.js.map → chunk-HGZPH7S5.js.map} +0 -0
- /package/dist/{chunk-7LHDZK7M.js.map → chunk-IHNUMRMU.js.map} +0 -0
- /package/dist/{chunk-YLVVZVK6.js.map → chunk-IK2WRYVA.js.map} +0 -0
- /package/dist/{chunk-CLEAYFOX.js.map → chunk-JKAX5K7C.js.map} +0 -0
- /package/dist/{chunk-4BUHSV4D.js.map → chunk-JO3NPEK6.js.map} +0 -0
- /package/dist/{chunk-ARTN2P3B.js.map → chunk-JOFGJYIT.js.map} +0 -0
- /package/dist/{chunk-ZI3GAXFN.js.map → chunk-OT4RV6WY.js.map} +0 -0
- /package/dist/{chunk-Q4XWNC33.js.map → chunk-VZX3SSFL.js.map} +0 -0
- /package/dist/{chunk-UMUNWABO.js.map → chunk-XG7FLAKQ.js.map} +0 -0
- /package/dist/{chunk-EYUANCRA.js.map → chunk-ZIQMVAGA.js.map} +0 -0
|
@@ -7019,8 +7019,9 @@ var remarkStripCitations = () => {
|
|
|
7019
7019
|
return (tree) => {
|
|
7020
7020
|
visit3(tree, "text", (node) => {
|
|
7021
7021
|
if (!node.value || !node.value.includes("[")) return;
|
|
7022
|
-
const
|
|
7023
|
-
if (
|
|
7022
|
+
const withoutCitations = node.value.replace(CITATION_REGEX, "$1");
|
|
7023
|
+
if (withoutCitations === node.value) return;
|
|
7024
|
+
node.value = withoutCitations.replace(/ {2,}/g, " ");
|
|
7024
7025
|
});
|
|
7025
7026
|
};
|
|
7026
7027
|
};
|
|
@@ -50776,7 +50777,13 @@ function useChatCardItem(type, id) {
|
|
|
50776
50777
|
return {
|
|
50777
50778
|
item: query.data ?? void 0,
|
|
50778
50779
|
isLoading: query.isLoading,
|
|
50779
|
-
isError: query.isError
|
|
50780
|
+
isError: query.isError,
|
|
50781
|
+
// True only after the query actually completed a fetch. DISABLED
|
|
50782
|
+
// queries (no list URL registered for the type, empty id) never
|
|
50783
|
+
// fetch — `item` is undefined there as well, and callers must not
|
|
50784
|
+
// read that as "fetched fine, entity absent" (tombstone gate in
|
|
50785
|
+
// entity-cards/dispatch.tsx).
|
|
50786
|
+
isFetched: query.isFetched
|
|
50780
50787
|
};
|
|
50781
50788
|
}
|
|
50782
50789
|
|
|
@@ -51541,26 +51548,27 @@ var FINANCIAL_CARD_CONFIGS = {
|
|
|
51541
51548
|
balance_sheet: { label: "Balance sheet", icon: () => /* @__PURE__ */ jsx377(BankIcon, { size: 24 }) },
|
|
51542
51549
|
cash_flow: { label: "Cash flow", icon: () => /* @__PURE__ */ jsx377(CoinsExchangeCurrencyIcon, { size: 24 }) }
|
|
51543
51550
|
};
|
|
51544
|
-
function
|
|
51551
|
+
function registryEntries(configs, build) {
|
|
51545
51552
|
const out = {};
|
|
51546
|
-
for (const [docType, cfg] of Object.entries(
|
|
51547
|
-
out[docType] = {
|
|
51548
|
-
mode: "no-fetch",
|
|
51549
|
-
label: cfg.label,
|
|
51550
|
-
bareInline: true,
|
|
51551
|
-
render: (chatRef, opts) => /* @__PURE__ */ jsx377(
|
|
51552
|
-
GenericFinancialChatCard,
|
|
51553
|
-
{
|
|
51554
|
-
chatRef,
|
|
51555
|
-
icon: cfg.icon(),
|
|
51556
|
-
isNewTab: opts.isNewTab,
|
|
51557
|
-
discuss: opts.discuss
|
|
51558
|
-
}
|
|
51559
|
-
)
|
|
51560
|
-
};
|
|
51561
|
-
}
|
|
51553
|
+
for (const [docType, cfg] of Object.entries(configs)) out[docType] = build(cfg);
|
|
51562
51554
|
return out;
|
|
51563
51555
|
}
|
|
51556
|
+
function financialRegistryEntries() {
|
|
51557
|
+
return registryEntries(FINANCIAL_CARD_CONFIGS, (cfg) => ({
|
|
51558
|
+
mode: "no-fetch",
|
|
51559
|
+
label: cfg.label,
|
|
51560
|
+
bareInline: true,
|
|
51561
|
+
render: (chatRef, opts) => /* @__PURE__ */ jsx377(
|
|
51562
|
+
GenericFinancialChatCard,
|
|
51563
|
+
{
|
|
51564
|
+
chatRef,
|
|
51565
|
+
icon: cfg.icon(),
|
|
51566
|
+
isNewTab: opts.isNewTab,
|
|
51567
|
+
discuss: opts.discuss
|
|
51568
|
+
}
|
|
51569
|
+
)
|
|
51570
|
+
}));
|
|
51571
|
+
}
|
|
51564
51572
|
var GITHUB_CARD_CONFIGS = {
|
|
51565
51573
|
github_commit: { label: "GitHub commit", kind: "commit" },
|
|
51566
51574
|
github_commit_public: { label: "GitHub commit (public)", kind: "commit" },
|
|
@@ -51570,24 +51578,20 @@ var GITHUB_CARD_CONFIGS = {
|
|
|
51570
51578
|
github_pr_review_public: { label: "GitHub review (public)", kind: "pr_review" }
|
|
51571
51579
|
};
|
|
51572
51580
|
function githubRegistryEntries() {
|
|
51573
|
-
|
|
51574
|
-
|
|
51575
|
-
|
|
51576
|
-
|
|
51577
|
-
|
|
51578
|
-
|
|
51579
|
-
|
|
51580
|
-
|
|
51581
|
-
|
|
51582
|
-
|
|
51583
|
-
|
|
51584
|
-
|
|
51585
|
-
|
|
51586
|
-
|
|
51587
|
-
)
|
|
51588
|
-
};
|
|
51589
|
-
}
|
|
51590
|
-
return out;
|
|
51581
|
+
return registryEntries(GITHUB_CARD_CONFIGS, (cfg) => ({
|
|
51582
|
+
mode: "no-fetch",
|
|
51583
|
+
label: cfg.label,
|
|
51584
|
+
bareInline: true,
|
|
51585
|
+
render: (chatRef, opts) => /* @__PURE__ */ jsx377(
|
|
51586
|
+
GitHubChatCard,
|
|
51587
|
+
{
|
|
51588
|
+
chatRef,
|
|
51589
|
+
kind: cfg.kind,
|
|
51590
|
+
isNewTab: opts.isNewTab,
|
|
51591
|
+
discuss: opts.discuss
|
|
51592
|
+
}
|
|
51593
|
+
)
|
|
51594
|
+
}));
|
|
51591
51595
|
}
|
|
51592
51596
|
var PROGRAM_CARD_CONFIGS = {
|
|
51593
51597
|
podcast: { label: "Podcast episode", configKey: "podcast", contentRefType: "podcast" },
|
|
@@ -51595,29 +51599,25 @@ var PROGRAM_CARD_CONFIGS = {
|
|
|
51595
51599
|
event: { label: "Event", configKey: "event", contentRefType: "event" }
|
|
51596
51600
|
};
|
|
51597
51601
|
function programRegistryEntries() {
|
|
51598
|
-
|
|
51599
|
-
|
|
51600
|
-
|
|
51601
|
-
|
|
51602
|
-
|
|
51603
|
-
|
|
51604
|
-
|
|
51605
|
-
|
|
51606
|
-
|
|
51607
|
-
|
|
51608
|
-
|
|
51609
|
-
|
|
51610
|
-
|
|
51611
|
-
|
|
51612
|
-
|
|
51613
|
-
|
|
51614
|
-
|
|
51615
|
-
|
|
51616
|
-
|
|
51617
|
-
)
|
|
51618
|
-
};
|
|
51619
|
-
}
|
|
51620
|
-
return out;
|
|
51602
|
+
return registryEntries(PROGRAM_CARD_CONFIGS, (cfg) => ({
|
|
51603
|
+
mode: "fetch",
|
|
51604
|
+
label: cfg.label,
|
|
51605
|
+
contentRefType: cfg.contentRefType,
|
|
51606
|
+
bareInline: true,
|
|
51607
|
+
skeleton: () => /* @__PURE__ */ jsx377(ProgramCardSkeleton, { size: "sm" }),
|
|
51608
|
+
render: (item, chatRef, opts) => /* @__PURE__ */ jsx377(
|
|
51609
|
+
ProgramChatCard,
|
|
51610
|
+
{
|
|
51611
|
+
item,
|
|
51612
|
+
chatRef,
|
|
51613
|
+
isNewTab: opts.isNewTab,
|
|
51614
|
+
discuss: opts.discuss,
|
|
51615
|
+
configKey: cfg.configKey,
|
|
51616
|
+
label: cfg.configKey.charAt(0).toUpperCase() + cfg.configKey.slice(1),
|
|
51617
|
+
ogPlaceholder: opts?.extras?.buildOgPlaceholderUrl?.(item?.title ?? "") ?? null
|
|
51618
|
+
}
|
|
51619
|
+
)
|
|
51620
|
+
}));
|
|
51621
51621
|
}
|
|
51622
51622
|
var ROADMAP_CARD_CONFIGS = {
|
|
51623
51623
|
roadmap_item: { label: "Roadmap item", cardType: "roadmap_item", contentRefType: "roadmap_item" },
|
|
@@ -51636,28 +51636,24 @@ var ROADMAP_CARD_CONFIGS = {
|
|
|
51636
51636
|
}
|
|
51637
51637
|
};
|
|
51638
51638
|
function roadmapRegistryEntries() {
|
|
51639
|
-
|
|
51640
|
-
|
|
51641
|
-
|
|
51642
|
-
|
|
51643
|
-
|
|
51644
|
-
|
|
51645
|
-
|
|
51646
|
-
|
|
51647
|
-
|
|
51648
|
-
|
|
51649
|
-
|
|
51650
|
-
|
|
51651
|
-
|
|
51652
|
-
|
|
51653
|
-
|
|
51654
|
-
|
|
51655
|
-
|
|
51656
|
-
|
|
51657
|
-
)
|
|
51658
|
-
};
|
|
51659
|
-
}
|
|
51660
|
-
return out;
|
|
51639
|
+
return registryEntries(ROADMAP_CARD_CONFIGS, (cfg) => ({
|
|
51640
|
+
mode: "fetch",
|
|
51641
|
+
label: cfg.label,
|
|
51642
|
+
contentRefType: cfg.contentRefType,
|
|
51643
|
+
bareInline: true,
|
|
51644
|
+
...cfg.noComposedHref ? { noComposedHref: true } : {},
|
|
51645
|
+
skeleton: () => /* @__PURE__ */ jsx377(RoadmapCardSkeleton, { size: "sm" }),
|
|
51646
|
+
render: (item, chatRef, opts) => /* @__PURE__ */ jsx377(
|
|
51647
|
+
RoadmapChatCard,
|
|
51648
|
+
{
|
|
51649
|
+
item,
|
|
51650
|
+
chatRef,
|
|
51651
|
+
isNewTab: opts.isNewTab,
|
|
51652
|
+
discuss: opts.discuss,
|
|
51653
|
+
cardType: cfg.cardType
|
|
51654
|
+
}
|
|
51655
|
+
)
|
|
51656
|
+
}));
|
|
51661
51657
|
}
|
|
51662
51658
|
var CHAT_CARD_REGISTRY = {
|
|
51663
51659
|
// ───────── no-fetch: ChatRef carries everything ─────────
|
|
@@ -51957,7 +51953,7 @@ function ChatCardLoader({
|
|
|
51957
51953
|
}, [chatRef, runtime, baseRoute, chipBasePlatform]);
|
|
51958
51954
|
const entry = CHAT_CARD_REGISTRY[resolvedChatRef.type];
|
|
51959
51955
|
const fetchEntry = entry && entry.mode === "fetch" ? entry : null;
|
|
51960
|
-
const { item, isLoading, isError } = useChatCardItem(
|
|
51956
|
+
const { item, isLoading, isError, isFetched } = useChatCardItem(
|
|
51961
51957
|
fetchEntry?.contentRefType ?? "",
|
|
51962
51958
|
fetchEntry ? resolvedChatRef.id : ""
|
|
51963
51959
|
);
|
|
@@ -52012,25 +52008,24 @@ function ChatCardLoader({
|
|
|
52012
52008
|
children
|
|
52013
52009
|
}
|
|
52014
52010
|
);
|
|
52011
|
+
const finish = (node) => entry.bareInline ? /* @__PURE__ */ jsx377(Fragment87, { children: navWrap(node) }) : /* @__PURE__ */ jsx377(
|
|
52012
|
+
ChatCardWithDiscuss,
|
|
52013
|
+
{
|
|
52014
|
+
chatRef: finalChatRef,
|
|
52015
|
+
onDiscuss,
|
|
52016
|
+
onDisplay,
|
|
52017
|
+
displayAction: entry.displayAction,
|
|
52018
|
+
children: navWrap(node)
|
|
52019
|
+
}
|
|
52020
|
+
);
|
|
52015
52021
|
if (entry.mode === "no-fetch") {
|
|
52016
52022
|
if (!finalChatRef.sourceRepo) return null;
|
|
52017
|
-
|
|
52018
|
-
return navWrap(entry.render(finalChatRef, renderOpts));
|
|
52019
|
-
}
|
|
52020
|
-
return /* @__PURE__ */ jsx377(
|
|
52021
|
-
ChatCardWithDiscuss,
|
|
52022
|
-
{
|
|
52023
|
-
chatRef: finalChatRef,
|
|
52024
|
-
onDiscuss,
|
|
52025
|
-
onDisplay,
|
|
52026
|
-
displayAction: entry.displayAction,
|
|
52027
|
-
children: navWrap(entry.render(finalChatRef, renderOpts))
|
|
52028
|
-
}
|
|
52029
|
-
);
|
|
52023
|
+
return finish(entry.render(finalChatRef, renderOpts));
|
|
52030
52024
|
}
|
|
52031
52025
|
if (isLoading) return /* @__PURE__ */ jsx377(Fragment87, { children: entry.skeleton() });
|
|
52032
52026
|
if (!item) {
|
|
52033
52027
|
if (isError) return null;
|
|
52028
|
+
if (!isFetched) return null;
|
|
52034
52029
|
if (finalChatRef.sourceRepo) {
|
|
52035
52030
|
return /* @__PURE__ */ jsx377(
|
|
52036
52031
|
DeletedDataCard,
|
|
@@ -52043,19 +52038,7 @@ function ChatCardLoader({
|
|
|
52043
52038
|
}
|
|
52044
52039
|
return null;
|
|
52045
52040
|
}
|
|
52046
|
-
|
|
52047
|
-
return /* @__PURE__ */ jsx377(Fragment87, { children: navWrap(entry.render(item, finalChatRef, renderOpts)) });
|
|
52048
|
-
}
|
|
52049
|
-
return /* @__PURE__ */ jsx377(
|
|
52050
|
-
ChatCardWithDiscuss,
|
|
52051
|
-
{
|
|
52052
|
-
chatRef: finalChatRef,
|
|
52053
|
-
onDiscuss,
|
|
52054
|
-
onDisplay,
|
|
52055
|
-
displayAction: entry.displayAction,
|
|
52056
|
-
children: navWrap(entry.render(item, finalChatRef, renderOpts))
|
|
52057
|
-
}
|
|
52058
|
-
);
|
|
52041
|
+
return finish(entry.render(item, finalChatRef, renderOpts));
|
|
52059
52042
|
}
|
|
52060
52043
|
function renderChatInlineEntityCard(chatRef, options = {}) {
|
|
52061
52044
|
const { onDiscuss, onDisplay, baseRoute, chipBasePlatform, extras } = options;
|
|
@@ -54091,6 +54074,214 @@ function buildDiscussPrompt(reference, options = {}) {
|
|
|
54091
54074
|
return `${prompt} (${reference.type} ${id})`;
|
|
54092
54075
|
}
|
|
54093
54076
|
|
|
54077
|
+
// src/components/chat/stream/message-mutations.ts
|
|
54078
|
+
function nextId(role) {
|
|
54079
|
+
return `${role}-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
54080
|
+
}
|
|
54081
|
+
var CONTENT_DEDUP_WINDOW = 4;
|
|
54082
|
+
var SYSTEM_DEDUP_WINDOW = 10;
|
|
54083
|
+
function hasRecentMessage(prev, predicate, window2) {
|
|
54084
|
+
const start = Math.max(0, prev.length - window2);
|
|
54085
|
+
for (let i = prev.length - 1; i >= start; i--) {
|
|
54086
|
+
if (predicate(prev[i])) return true;
|
|
54087
|
+
}
|
|
54088
|
+
return false;
|
|
54089
|
+
}
|
|
54090
|
+
function updateTrailingAssistant(prev, segments) {
|
|
54091
|
+
const last = prev[prev.length - 1];
|
|
54092
|
+
if (!last || last.role !== "assistant") {
|
|
54093
|
+
return [
|
|
54094
|
+
...prev,
|
|
54095
|
+
{
|
|
54096
|
+
id: nextId("assistant"),
|
|
54097
|
+
role: "assistant",
|
|
54098
|
+
content: "",
|
|
54099
|
+
segments
|
|
54100
|
+
}
|
|
54101
|
+
];
|
|
54102
|
+
}
|
|
54103
|
+
return [...prev.slice(0, -1), { ...last, segments }];
|
|
54104
|
+
}
|
|
54105
|
+
function appendToTrailingAssistant(prev, segments) {
|
|
54106
|
+
if (segments.length === 0) return prev;
|
|
54107
|
+
const last = prev[prev.length - 1];
|
|
54108
|
+
if (!last || last.role !== "assistant") {
|
|
54109
|
+
return [
|
|
54110
|
+
...prev,
|
|
54111
|
+
{ id: nextId("assistant"), role: "assistant", content: "", segments }
|
|
54112
|
+
];
|
|
54113
|
+
}
|
|
54114
|
+
const merged = [...last.segments ?? []];
|
|
54115
|
+
for (const seg of segments) {
|
|
54116
|
+
const tail = merged[merged.length - 1];
|
|
54117
|
+
if (seg.type === "text" && tail?.type === "text") {
|
|
54118
|
+
merged[merged.length - 1] = { type: "text", text: tail.text + seg.text };
|
|
54119
|
+
} else if (seg.type === "thinking" && tail?.type === "thinking") {
|
|
54120
|
+
merged[merged.length - 1] = { type: "thinking", text: tail.text + seg.text };
|
|
54121
|
+
} else if (seg.type === "guide" && tail?.type === "guide") {
|
|
54122
|
+
merged[merged.length - 1] = { type: "guide", text: tail.text + seg.text };
|
|
54123
|
+
} else if (seg.type === "approval_batch") {
|
|
54124
|
+
const idx = merged.findIndex(
|
|
54125
|
+
(m) => m.type === "approval_batch" && m.data.approvalRequestId === seg.data.approvalRequestId
|
|
54126
|
+
);
|
|
54127
|
+
if (idx !== -1) merged[idx] = seg;
|
|
54128
|
+
else merged.push(seg);
|
|
54129
|
+
} else if (seg.type === "approval_request") {
|
|
54130
|
+
const idx = merged.findIndex(
|
|
54131
|
+
(m) => m.type === "approval_request" && m.data.requestId === seg.data.requestId && m.data.command === seg.data.command
|
|
54132
|
+
);
|
|
54133
|
+
if (idx !== -1) merged[idx] = seg;
|
|
54134
|
+
else merged.push(seg);
|
|
54135
|
+
} else {
|
|
54136
|
+
merged.push(seg);
|
|
54137
|
+
}
|
|
54138
|
+
}
|
|
54139
|
+
return [...prev.slice(0, -1), { ...last, segments: merged }];
|
|
54140
|
+
}
|
|
54141
|
+
function mapSegments(prev, fn) {
|
|
54142
|
+
let changed = false;
|
|
54143
|
+
const next = prev.map((m) => {
|
|
54144
|
+
if (m.role !== "assistant" || !m.segments) return m;
|
|
54145
|
+
let msgChanged = false;
|
|
54146
|
+
const segs = m.segments.map((s) => {
|
|
54147
|
+
const out = fn(s);
|
|
54148
|
+
if (out !== s) msgChanged = true;
|
|
54149
|
+
return out;
|
|
54150
|
+
});
|
|
54151
|
+
if (!msgChanged) return m;
|
|
54152
|
+
changed = true;
|
|
54153
|
+
return { ...m, segments: segs };
|
|
54154
|
+
});
|
|
54155
|
+
return changed ? next : prev;
|
|
54156
|
+
}
|
|
54157
|
+
function applyApprovalStatusToSegment(s, requestId, status, resolvedByName) {
|
|
54158
|
+
if (s.type === "approval_request" && s.data.requestId === requestId && s.status !== status) {
|
|
54159
|
+
return { ...s, status };
|
|
54160
|
+
}
|
|
54161
|
+
if (s.type !== "approval_batch") return s;
|
|
54162
|
+
const isAnchor = s.data.approvalRequestId === requestId;
|
|
54163
|
+
const hasRow = s.data.toolCalls?.some((c) => c.toolExecutionRequestId === requestId);
|
|
54164
|
+
if (!isAnchor && !hasRow) return s;
|
|
54165
|
+
const nextResolvedBy = resolvedByName ?? s.resolvedByName;
|
|
54166
|
+
const nextExecutions = hasRow ? {
|
|
54167
|
+
...s.data.executions ?? {},
|
|
54168
|
+
[requestId]: { status: "done", success: status === "approved" }
|
|
54169
|
+
} : s.data.executions;
|
|
54170
|
+
const nextStatus = isAnchor ? status : s.status;
|
|
54171
|
+
if (s.status === nextStatus && nextResolvedBy === s.resolvedByName && nextExecutions === s.data.executions) {
|
|
54172
|
+
return s;
|
|
54173
|
+
}
|
|
54174
|
+
return {
|
|
54175
|
+
...s,
|
|
54176
|
+
status: nextStatus,
|
|
54177
|
+
resolvedByName: nextResolvedBy,
|
|
54178
|
+
data: {
|
|
54179
|
+
...s.data,
|
|
54180
|
+
...nextExecutions ? { executions: nextExecutions } : {}
|
|
54181
|
+
}
|
|
54182
|
+
};
|
|
54183
|
+
}
|
|
54184
|
+
function nextBatchExecution(prevExec, toolData) {
|
|
54185
|
+
if (toolData.type === "EXECUTING_TOOL" && prevExec?.status === "done") return null;
|
|
54186
|
+
return toolData.type === "EXECUTED_TOOL" ? { status: "done", result: toolData.result, success: toolData.success } : { status: "executing", result: prevExec?.result, success: prevExec?.success };
|
|
54187
|
+
}
|
|
54188
|
+
function withBatchExecution(seg, execId, state) {
|
|
54189
|
+
return {
|
|
54190
|
+
...seg,
|
|
54191
|
+
data: { ...seg.data, executions: { ...seg.data.executions ?? {}, [execId]: state } }
|
|
54192
|
+
};
|
|
54193
|
+
}
|
|
54194
|
+
function projectBatchStatusToMessages(prev, anchorId, status) {
|
|
54195
|
+
return mapSegments(prev, (s) => {
|
|
54196
|
+
if (s.type !== "approval_batch") return s;
|
|
54197
|
+
if (s.data.approvalRequestId !== anchorId || s.status === status) return s;
|
|
54198
|
+
return { ...s, status };
|
|
54199
|
+
});
|
|
54200
|
+
}
|
|
54201
|
+
function projectBatchRowFailureToMessages(prev, rowRequestId) {
|
|
54202
|
+
return mapSegments(prev, (s) => {
|
|
54203
|
+
if (s.type !== "approval_batch" || !s.data.toolCalls?.some((c) => c.toolExecutionRequestId === rowRequestId)) {
|
|
54204
|
+
return s;
|
|
54205
|
+
}
|
|
54206
|
+
const existing = s.data.executions?.[rowRequestId];
|
|
54207
|
+
if (existing?.status === "done") return s;
|
|
54208
|
+
return withBatchExecution(s, rowRequestId, { status: "done", success: false });
|
|
54209
|
+
});
|
|
54210
|
+
}
|
|
54211
|
+
function upsertTrailingCompaction(prev, segments) {
|
|
54212
|
+
const compaction = [...segments].reverse().find((s) => s.type === "context_compaction");
|
|
54213
|
+
if (!compaction) return prev;
|
|
54214
|
+
const last = prev[prev.length - 1];
|
|
54215
|
+
if (!last || last.role !== "assistant") {
|
|
54216
|
+
return [
|
|
54217
|
+
...prev,
|
|
54218
|
+
{ id: nextId("assistant"), role: "assistant", content: "", segments: [compaction] }
|
|
54219
|
+
];
|
|
54220
|
+
}
|
|
54221
|
+
const existing = last.segments ?? [];
|
|
54222
|
+
const startedIdx = existing.map((s) => s.type === "context_compaction" && s.status === "started").lastIndexOf(true);
|
|
54223
|
+
const merged = startedIdx !== -1 ? existing.map((s, i) => i === startedIdx ? compaction : s) : [...existing, compaction];
|
|
54224
|
+
return [...prev.slice(0, -1), { ...last, segments: merged }];
|
|
54225
|
+
}
|
|
54226
|
+
function sameToolData(a, b) {
|
|
54227
|
+
return a.type === b.type && a.integratedToolType === b.integratedToolType && a.toolFunction === b.toolFunction && a.toolTitle === b.toolTitle && a.result === b.result && a.success === b.success && a.toolExecutionRequestId === b.toolExecutionRequestId && (a.parameters === b.parameters || JSON.stringify(a.parameters ?? null) === JSON.stringify(b.parameters ?? null));
|
|
54228
|
+
}
|
|
54229
|
+
function sameExecutionState(a, b) {
|
|
54230
|
+
return !!a && a.status === b.status && a.result === b.result && a.success === b.success;
|
|
54231
|
+
}
|
|
54232
|
+
function applyToolExecutionToMessages(prev, segment) {
|
|
54233
|
+
const merged = mergeToolExecutionIfPresent(prev, segment);
|
|
54234
|
+
if (merged !== null) return merged;
|
|
54235
|
+
return appendToTrailingAssistant(prev, [segment]);
|
|
54236
|
+
}
|
|
54237
|
+
function mergeToolExecutionIfPresent(prev, segment) {
|
|
54238
|
+
const toolData = segment.data;
|
|
54239
|
+
const execId = toolData.toolExecutionRequestId;
|
|
54240
|
+
for (let i = prev.length - 1; i >= 0; i--) {
|
|
54241
|
+
const message2 = prev[i];
|
|
54242
|
+
if (message2.role !== "assistant" || !message2.segments) continue;
|
|
54243
|
+
for (let j = message2.segments.length - 1; j >= 0; j--) {
|
|
54244
|
+
const seg = message2.segments[j];
|
|
54245
|
+
if (execId && seg.type === "approval_batch" && seg.data.toolCalls.some((c) => c.toolExecutionRequestId === execId)) {
|
|
54246
|
+
const prevExec = seg.data.executions?.[execId];
|
|
54247
|
+
const nextExec = nextBatchExecution(prevExec, toolData);
|
|
54248
|
+
if (nextExec === null) return prev;
|
|
54249
|
+
if (sameExecutionState(prevExec, nextExec)) return prev;
|
|
54250
|
+
const nextSegments = [...message2.segments];
|
|
54251
|
+
nextSegments[j] = withBatchExecution(seg, execId, nextExec);
|
|
54252
|
+
const next = [...prev];
|
|
54253
|
+
next[i] = { ...message2, segments: nextSegments };
|
|
54254
|
+
return next;
|
|
54255
|
+
}
|
|
54256
|
+
if (seg.type === "tool_execution") {
|
|
54257
|
+
const matches = execId ? seg.data.toolExecutionRequestId === execId : seg.data.type === "EXECUTING_TOOL" && seg.data.integratedToolType === toolData.integratedToolType && seg.data.toolFunction === toolData.toolFunction;
|
|
54258
|
+
if (!matches) continue;
|
|
54259
|
+
if (toolData.type === "EXECUTING_TOOL" && seg.data.type === "EXECUTED_TOOL") {
|
|
54260
|
+
return prev;
|
|
54261
|
+
}
|
|
54262
|
+
const mergedData = {
|
|
54263
|
+
...toolData,
|
|
54264
|
+
toolTitle: toolData.toolTitle ?? seg.data.toolTitle,
|
|
54265
|
+
parameters: toolData.parameters || seg.data.parameters
|
|
54266
|
+
};
|
|
54267
|
+
if (sameToolData(seg.data, mergedData)) return prev;
|
|
54268
|
+
const nextSegments = [...message2.segments];
|
|
54269
|
+
nextSegments[j] = { type: "tool_execution", data: mergedData };
|
|
54270
|
+
const next = [...prev];
|
|
54271
|
+
next[i] = { ...message2, segments: nextSegments };
|
|
54272
|
+
return next;
|
|
54273
|
+
}
|
|
54274
|
+
}
|
|
54275
|
+
}
|
|
54276
|
+
return null;
|
|
54277
|
+
}
|
|
54278
|
+
function projectApprovalResolutionToMessages(prev, requestId, status, resolvedByName) {
|
|
54279
|
+
return mapSegments(
|
|
54280
|
+
prev,
|
|
54281
|
+
(s) => applyApprovalStatusToSegment(s, requestId, status, resolvedByName)
|
|
54282
|
+
);
|
|
54283
|
+
}
|
|
54284
|
+
|
|
54094
54285
|
// src/components/chat/utils/message-segment-accumulator.ts
|
|
54095
54286
|
var MessageSegmentAccumulator = class {
|
|
54096
54287
|
constructor(callbacks) {
|
|
@@ -54258,19 +54449,10 @@ var MessageSegmentAccumulator = class {
|
|
|
54258
54449
|
const hasCall = seg.data.toolCalls.some((c) => c.toolExecutionRequestId === execId);
|
|
54259
54450
|
if (!hasCall) return seg;
|
|
54260
54451
|
const prev = seg.data.executions?.[execId];
|
|
54261
|
-
|
|
54262
|
-
matched = true;
|
|
54263
|
-
return seg;
|
|
54264
|
-
}
|
|
54265
|
-
const next = toolData.type === "EXECUTED_TOOL" ? { status: "done", result: toolData.result, success: toolData.success } : { status: "executing", result: prev?.result, success: prev?.success };
|
|
54452
|
+
const next = nextBatchExecution(prev, toolData);
|
|
54266
54453
|
matched = true;
|
|
54267
|
-
return
|
|
54268
|
-
|
|
54269
|
-
data: {
|
|
54270
|
-
...seg.data,
|
|
54271
|
-
executions: { ...seg.data.executions ?? {}, [execId]: next }
|
|
54272
|
-
}
|
|
54273
|
-
};
|
|
54454
|
+
if (next === null) return seg;
|
|
54455
|
+
return withBatchExecution(seg, execId, next);
|
|
54274
54456
|
});
|
|
54275
54457
|
return matched;
|
|
54276
54458
|
}
|
|
@@ -54405,15 +54587,9 @@ var MessageSegmentAccumulator = class {
|
|
|
54405
54587
|
* resolved card shows "by {name}"; omit it to leave any existing value untouched.
|
|
54406
54588
|
*/
|
|
54407
54589
|
updateApprovalStatus(requestId, status, resolvedByName) {
|
|
54408
|
-
this.segments = this.segments.map(
|
|
54409
|
-
|
|
54410
|
-
|
|
54411
|
-
}
|
|
54412
|
-
if (segment.type === "approval_batch" && segment.data.approvalRequestId === requestId) {
|
|
54413
|
-
return { ...segment, status, resolvedByName: resolvedByName ?? segment.resolvedByName };
|
|
54414
|
-
}
|
|
54415
|
-
return segment;
|
|
54416
|
-
});
|
|
54590
|
+
this.segments = this.segments.map(
|
|
54591
|
+
(segment) => applyApprovalStatusToSegment(segment, requestId, status, resolvedByName)
|
|
54592
|
+
);
|
|
54417
54593
|
return this.getSegments();
|
|
54418
54594
|
}
|
|
54419
54595
|
/**
|
|
@@ -54558,214 +54734,6 @@ function createMessageSegmentAccumulator(callbacks) {
|
|
|
54558
54734
|
// src/chat-protocol/events.ts
|
|
54559
54735
|
var CHAT_OWNER_ADMIN = "ADMIN";
|
|
54560
54736
|
|
|
54561
|
-
// src/components/chat/stream/message-mutations.ts
|
|
54562
|
-
function nextId(role) {
|
|
54563
|
-
return `${role}-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
54564
|
-
}
|
|
54565
|
-
var CONTENT_DEDUP_WINDOW = 4;
|
|
54566
|
-
var SYSTEM_DEDUP_WINDOW = 10;
|
|
54567
|
-
function hasRecentMessage(prev, predicate, window2) {
|
|
54568
|
-
const start = Math.max(0, prev.length - window2);
|
|
54569
|
-
for (let i = prev.length - 1; i >= start; i--) {
|
|
54570
|
-
if (predicate(prev[i])) return true;
|
|
54571
|
-
}
|
|
54572
|
-
return false;
|
|
54573
|
-
}
|
|
54574
|
-
function updateTrailingAssistant(prev, segments) {
|
|
54575
|
-
const last = prev[prev.length - 1];
|
|
54576
|
-
if (!last || last.role !== "assistant") {
|
|
54577
|
-
return [
|
|
54578
|
-
...prev,
|
|
54579
|
-
{
|
|
54580
|
-
id: nextId("assistant"),
|
|
54581
|
-
role: "assistant",
|
|
54582
|
-
content: "",
|
|
54583
|
-
segments
|
|
54584
|
-
}
|
|
54585
|
-
];
|
|
54586
|
-
}
|
|
54587
|
-
return [...prev.slice(0, -1), { ...last, segments }];
|
|
54588
|
-
}
|
|
54589
|
-
function appendToTrailingAssistant(prev, segments) {
|
|
54590
|
-
if (segments.length === 0) return prev;
|
|
54591
|
-
const last = prev[prev.length - 1];
|
|
54592
|
-
if (!last || last.role !== "assistant") {
|
|
54593
|
-
return [
|
|
54594
|
-
...prev,
|
|
54595
|
-
{ id: nextId("assistant"), role: "assistant", content: "", segments }
|
|
54596
|
-
];
|
|
54597
|
-
}
|
|
54598
|
-
const merged = [...last.segments ?? []];
|
|
54599
|
-
for (const seg of segments) {
|
|
54600
|
-
const tail = merged[merged.length - 1];
|
|
54601
|
-
if (seg.type === "text" && tail?.type === "text") {
|
|
54602
|
-
merged[merged.length - 1] = { type: "text", text: tail.text + seg.text };
|
|
54603
|
-
} else if (seg.type === "thinking" && tail?.type === "thinking") {
|
|
54604
|
-
merged[merged.length - 1] = { type: "thinking", text: tail.text + seg.text };
|
|
54605
|
-
} else if (seg.type === "guide" && tail?.type === "guide") {
|
|
54606
|
-
merged[merged.length - 1] = { type: "guide", text: tail.text + seg.text };
|
|
54607
|
-
} else if (seg.type === "approval_batch") {
|
|
54608
|
-
const idx = merged.findIndex(
|
|
54609
|
-
(m) => m.type === "approval_batch" && m.data.approvalRequestId === seg.data.approvalRequestId
|
|
54610
|
-
);
|
|
54611
|
-
if (idx !== -1) merged[idx] = seg;
|
|
54612
|
-
else merged.push(seg);
|
|
54613
|
-
} else if (seg.type === "approval_request") {
|
|
54614
|
-
const idx = merged.findIndex(
|
|
54615
|
-
(m) => m.type === "approval_request" && m.data.requestId === seg.data.requestId && m.data.command === seg.data.command
|
|
54616
|
-
);
|
|
54617
|
-
if (idx !== -1) merged[idx] = seg;
|
|
54618
|
-
else merged.push(seg);
|
|
54619
|
-
} else {
|
|
54620
|
-
merged.push(seg);
|
|
54621
|
-
}
|
|
54622
|
-
}
|
|
54623
|
-
return [...prev.slice(0, -1), { ...last, segments: merged }];
|
|
54624
|
-
}
|
|
54625
|
-
function projectBatchRowFailureToMessages(prev, rowRequestId) {
|
|
54626
|
-
let changed = false;
|
|
54627
|
-
const next = prev.map((m) => {
|
|
54628
|
-
if (m.role !== "assistant" || !m.segments) return m;
|
|
54629
|
-
let msgChanged = false;
|
|
54630
|
-
const segs = m.segments.map((s) => {
|
|
54631
|
-
if (s.type !== "approval_batch" || !s.data.toolCalls?.some((c) => c.toolExecutionRequestId === rowRequestId)) {
|
|
54632
|
-
return s;
|
|
54633
|
-
}
|
|
54634
|
-
const existing = s.data.executions?.[rowRequestId];
|
|
54635
|
-
if (existing?.status === "done") return s;
|
|
54636
|
-
msgChanged = true;
|
|
54637
|
-
return {
|
|
54638
|
-
...s,
|
|
54639
|
-
data: {
|
|
54640
|
-
...s.data,
|
|
54641
|
-
executions: {
|
|
54642
|
-
...s.data.executions ?? {},
|
|
54643
|
-
[rowRequestId]: { status: "done", success: false }
|
|
54644
|
-
}
|
|
54645
|
-
}
|
|
54646
|
-
};
|
|
54647
|
-
});
|
|
54648
|
-
if (!msgChanged) return m;
|
|
54649
|
-
changed = true;
|
|
54650
|
-
return { ...m, segments: segs };
|
|
54651
|
-
});
|
|
54652
|
-
return changed ? next : prev;
|
|
54653
|
-
}
|
|
54654
|
-
function upsertTrailingCompaction(prev, segments) {
|
|
54655
|
-
const compaction = [...segments].reverse().find((s) => s.type === "context_compaction");
|
|
54656
|
-
if (!compaction) return prev;
|
|
54657
|
-
const last = prev[prev.length - 1];
|
|
54658
|
-
if (!last || last.role !== "assistant") {
|
|
54659
|
-
return [
|
|
54660
|
-
...prev,
|
|
54661
|
-
{ id: nextId("assistant"), role: "assistant", content: "", segments: [compaction] }
|
|
54662
|
-
];
|
|
54663
|
-
}
|
|
54664
|
-
const existing = last.segments ?? [];
|
|
54665
|
-
const startedIdx = existing.map((s) => s.type === "context_compaction" && s.status === "started").lastIndexOf(true);
|
|
54666
|
-
const merged = startedIdx !== -1 ? existing.map((s, i) => i === startedIdx ? compaction : s) : [...existing, compaction];
|
|
54667
|
-
return [...prev.slice(0, -1), { ...last, segments: merged }];
|
|
54668
|
-
}
|
|
54669
|
-
function sameToolData(a, b) {
|
|
54670
|
-
return a.type === b.type && a.integratedToolType === b.integratedToolType && a.toolFunction === b.toolFunction && a.toolTitle === b.toolTitle && a.result === b.result && a.success === b.success && a.toolExecutionRequestId === b.toolExecutionRequestId && (a.parameters === b.parameters || JSON.stringify(a.parameters ?? null) === JSON.stringify(b.parameters ?? null));
|
|
54671
|
-
}
|
|
54672
|
-
function sameExecutionState(a, b) {
|
|
54673
|
-
return !!a && a.status === b.status && a.result === b.result && a.success === b.success;
|
|
54674
|
-
}
|
|
54675
|
-
function applyToolExecutionToMessages(prev, segment) {
|
|
54676
|
-
const merged = mergeToolExecutionIfPresent(prev, segment);
|
|
54677
|
-
if (merged !== null) return merged;
|
|
54678
|
-
return appendToTrailingAssistant(prev, [segment]);
|
|
54679
|
-
}
|
|
54680
|
-
function mergeToolExecutionIfPresent(prev, segment) {
|
|
54681
|
-
const toolData = segment.data;
|
|
54682
|
-
const execId = toolData.toolExecutionRequestId;
|
|
54683
|
-
for (let i = prev.length - 1; i >= 0; i--) {
|
|
54684
|
-
const message2 = prev[i];
|
|
54685
|
-
if (message2.role !== "assistant" || !message2.segments) continue;
|
|
54686
|
-
for (let j = message2.segments.length - 1; j >= 0; j--) {
|
|
54687
|
-
const seg = message2.segments[j];
|
|
54688
|
-
if (execId && seg.type === "approval_batch" && seg.data.toolCalls.some((c) => c.toolExecutionRequestId === execId)) {
|
|
54689
|
-
const prevExec = seg.data.executions?.[execId];
|
|
54690
|
-
if (toolData.type === "EXECUTING_TOOL" && prevExec?.status === "done") {
|
|
54691
|
-
return prev;
|
|
54692
|
-
}
|
|
54693
|
-
const nextExec = toolData.type === "EXECUTED_TOOL" ? { status: "done", result: toolData.result, success: toolData.success } : { status: "executing", result: prevExec?.result, success: prevExec?.success };
|
|
54694
|
-
if (sameExecutionState(prevExec, nextExec)) return prev;
|
|
54695
|
-
const nextSegments = [...message2.segments];
|
|
54696
|
-
nextSegments[j] = {
|
|
54697
|
-
...seg,
|
|
54698
|
-
data: { ...seg.data, executions: { ...seg.data.executions ?? {}, [execId]: nextExec } }
|
|
54699
|
-
};
|
|
54700
|
-
const next = [...prev];
|
|
54701
|
-
next[i] = { ...message2, segments: nextSegments };
|
|
54702
|
-
return next;
|
|
54703
|
-
}
|
|
54704
|
-
if (seg.type === "tool_execution") {
|
|
54705
|
-
const matches = execId ? seg.data.toolExecutionRequestId === execId : seg.data.type === "EXECUTING_TOOL" && seg.data.integratedToolType === toolData.integratedToolType && seg.data.toolFunction === toolData.toolFunction;
|
|
54706
|
-
if (!matches) continue;
|
|
54707
|
-
if (toolData.type === "EXECUTING_TOOL" && seg.data.type === "EXECUTED_TOOL") {
|
|
54708
|
-
return prev;
|
|
54709
|
-
}
|
|
54710
|
-
const mergedData = {
|
|
54711
|
-
...toolData,
|
|
54712
|
-
toolTitle: toolData.toolTitle ?? seg.data.toolTitle,
|
|
54713
|
-
parameters: toolData.parameters || seg.data.parameters
|
|
54714
|
-
};
|
|
54715
|
-
if (sameToolData(seg.data, mergedData)) return prev;
|
|
54716
|
-
const nextSegments = [...message2.segments];
|
|
54717
|
-
nextSegments[j] = { type: "tool_execution", data: mergedData };
|
|
54718
|
-
const next = [...prev];
|
|
54719
|
-
next[i] = { ...message2, segments: nextSegments };
|
|
54720
|
-
return next;
|
|
54721
|
-
}
|
|
54722
|
-
}
|
|
54723
|
-
}
|
|
54724
|
-
return null;
|
|
54725
|
-
}
|
|
54726
|
-
function projectApprovalResolutionToMessages(prev, requestId, status, resolvedByName) {
|
|
54727
|
-
let changed = false;
|
|
54728
|
-
const next = prev.map((m) => {
|
|
54729
|
-
if (m.role !== "assistant" || !m.segments) return m;
|
|
54730
|
-
let msgChanged = false;
|
|
54731
|
-
const segs = m.segments.map((s) => {
|
|
54732
|
-
if (s.type === "approval_request" && s.data.requestId === requestId && s.status !== status) {
|
|
54733
|
-
msgChanged = true;
|
|
54734
|
-
return { ...s, status };
|
|
54735
|
-
}
|
|
54736
|
-
if (s.type === "approval_batch") {
|
|
54737
|
-
const isAnchor = s.data.approvalRequestId === requestId;
|
|
54738
|
-
const hasRow = s.data.toolCalls?.some((c) => c.toolExecutionRequestId === requestId);
|
|
54739
|
-
if (!isAnchor && !hasRow) return s;
|
|
54740
|
-
const nextResolvedBy = resolvedByName ?? s.resolvedByName;
|
|
54741
|
-
const nextExecutions = hasRow ? {
|
|
54742
|
-
...s.data.executions ?? {},
|
|
54743
|
-
[requestId]: { status: "done", success: status === "approved" }
|
|
54744
|
-
} : s.data.executions;
|
|
54745
|
-
const nextStatus = isAnchor ? status : s.status;
|
|
54746
|
-
if (s.status === nextStatus && nextResolvedBy === s.resolvedByName && nextExecutions === s.data.executions) {
|
|
54747
|
-
return s;
|
|
54748
|
-
}
|
|
54749
|
-
msgChanged = true;
|
|
54750
|
-
return {
|
|
54751
|
-
...s,
|
|
54752
|
-
status: nextStatus,
|
|
54753
|
-
resolvedByName: nextResolvedBy,
|
|
54754
|
-
data: {
|
|
54755
|
-
...s.data,
|
|
54756
|
-
...nextExecutions ? { executions: nextExecutions } : {}
|
|
54757
|
-
}
|
|
54758
|
-
};
|
|
54759
|
-
}
|
|
54760
|
-
return s;
|
|
54761
|
-
});
|
|
54762
|
-
if (!msgChanged) return m;
|
|
54763
|
-
changed = true;
|
|
54764
|
-
return { ...m, segments: segs };
|
|
54765
|
-
});
|
|
54766
|
-
return changed ? next : prev;
|
|
54767
|
-
}
|
|
54768
|
-
|
|
54769
54737
|
// src/components/chat/stream/chat-stream-reducer.ts
|
|
54770
54738
|
function createEmptyTurnMeta() {
|
|
54771
54739
|
return {
|
|
@@ -55483,9 +55451,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
55483
55451
|
// remaining rows still get their attempt.
|
|
55484
55452
|
...(() => {
|
|
55485
55453
|
const resolveBatch = (status, confirm) => async () => {
|
|
55486
|
-
setMessagesInternal(
|
|
55487
|
-
projectApprovalResolutionToMessages(messages, anchorId, status)
|
|
55488
|
-
);
|
|
55454
|
+
setMessagesInternal(projectBatchStatusToMessages(messages, anchorId, status));
|
|
55489
55455
|
for (const id of ids) {
|
|
55490
55456
|
const ok = await confirm?.(id);
|
|
55491
55457
|
if (ok === false) {
|
|
@@ -55796,6 +55762,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
55796
55762
|
setMessagesInternal(
|
|
55797
55763
|
projectApprovalResolutionToMessages(messages, requestId, status, resolvedByName)
|
|
55798
55764
|
);
|
|
55765
|
+
mirrorApprovalStatus(requestId, status);
|
|
55799
55766
|
return segments;
|
|
55800
55767
|
},
|
|
55801
55768
|
getPendingEscalated() {
|
|
@@ -56146,20 +56113,18 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
56146
56113
|
const source = runtime.source || DEFAULT_CHAT_SOURCE;
|
|
56147
56114
|
const tableIdForDocumentType = options?.tableIdForDocumentType ?? defaultTableIdForDocumentType;
|
|
56148
56115
|
const sendMessageRef = useRef77(async () => true);
|
|
56149
|
-
const
|
|
56150
|
-
|
|
56151
|
-
|
|
56152
|
-
|
|
56153
|
-
|
|
56154
|
-
|
|
56155
|
-
|
|
56156
|
-
|
|
56157
|
-
|
|
56158
|
-
|
|
56159
|
-
|
|
56160
|
-
|
|
56161
|
-
});
|
|
56162
|
-
}, []);
|
|
56116
|
+
const cardResolve = useCallback54(
|
|
56117
|
+
(action) => (reqId) => {
|
|
56118
|
+
if (!reqId) return;
|
|
56119
|
+
return sendMessageRef.current("", {
|
|
56120
|
+
hidden: true,
|
|
56121
|
+
approvalAction: { proposalId: reqId, action }
|
|
56122
|
+
});
|
|
56123
|
+
},
|
|
56124
|
+
[]
|
|
56125
|
+
);
|
|
56126
|
+
const cardApprove = useMemo51(() => cardResolve("approve"), [cardResolve]);
|
|
56127
|
+
const cardReject = useMemo51(() => cardResolve("reject"), [cardResolve]);
|
|
56163
56128
|
const createReducerOptions = useCallback54(
|
|
56164
56129
|
() => ({
|
|
56165
56130
|
transport: "sse",
|
|
@@ -60472,13 +60437,13 @@ export {
|
|
|
60472
60437
|
extractEntityIdFilter,
|
|
60473
60438
|
buildDiscussAddendum,
|
|
60474
60439
|
buildDiscussPrompt,
|
|
60440
|
+
appendToTrailingAssistant,
|
|
60441
|
+
upsertTrailingCompaction,
|
|
60442
|
+
applyToolExecutionToMessages,
|
|
60475
60443
|
MessageSegmentAccumulator,
|
|
60476
60444
|
createMessageSegmentAccumulator,
|
|
60477
60445
|
SCROLL_ANCHOR_WIRE_KEY,
|
|
60478
60446
|
parseScrollAnchor,
|
|
60479
|
-
appendToTrailingAssistant,
|
|
60480
|
-
upsertTrailingCompaction,
|
|
60481
|
-
applyToolExecutionToMessages,
|
|
60482
60447
|
createEmptyTurnMeta,
|
|
60483
60448
|
createChatStreamReducer,
|
|
60484
60449
|
DEFAULT_DIALOG_SIDE,
|
|
@@ -60957,4 +60922,4 @@ export {
|
|
|
60957
60922
|
LogsList,
|
|
60958
60923
|
assets
|
|
60959
60924
|
};
|
|
60960
|
-
//# sourceMappingURL=chunk-
|
|
60925
|
+
//# sourceMappingURL=chunk-V5WLIFKN.js.map
|