@flamingo-stack/openframe-frontend-core 0.0.512-1640.4221.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.
Files changed (100) hide show
  1. package/dist/{chunk-OOJLER5V.cjs → chunk-2WWDZR4D.cjs} +31 -31
  2. package/dist/{chunk-OOJLER5V.cjs.map → chunk-2WWDZR4D.cjs.map} +1 -1
  3. package/dist/{chunk-N3CQTN5T.cjs → chunk-2XL7UK5Y.cjs} +5 -5
  4. package/dist/{chunk-N3CQTN5T.cjs.map → chunk-2XL7UK5Y.cjs.map} +1 -1
  5. package/dist/{chunk-JEKWIGG6.js → chunk-4NFDSMB5.js} +4 -4
  6. package/dist/{chunk-BXTVXQGZ.cjs → chunk-5JBDT2MQ.cjs} +7 -7
  7. package/dist/{chunk-BXTVXQGZ.cjs.map → chunk-5JBDT2MQ.cjs.map} +1 -1
  8. package/dist/{chunk-GVMHJK3B.cjs → chunk-67YDSTH7.cjs} +9 -9
  9. package/dist/{chunk-GVMHJK3B.cjs.map → chunk-67YDSTH7.cjs.map} +1 -1
  10. package/dist/{chunk-XYD3Y7WU.js → chunk-6LMTBNLN.js} +2 -2
  11. package/dist/{chunk-ZLCYLZFL.cjs → chunk-7VBEOGCR.cjs} +61 -61
  12. package/dist/{chunk-ZLCYLZFL.cjs.map → chunk-7VBEOGCR.cjs.map} +1 -1
  13. package/dist/{chunk-OEPGR7FT.cjs → chunk-AWLFJMOJ.cjs} +37 -37
  14. package/dist/{chunk-OEPGR7FT.cjs.map → chunk-AWLFJMOJ.cjs.map} +1 -1
  15. package/dist/{chunk-UXEVYNSX.cjs → chunk-DQDPDUI3.cjs} +4 -4
  16. package/dist/{chunk-UXEVYNSX.cjs.map → chunk-DQDPDUI3.cjs.map} +1 -1
  17. package/dist/{chunk-MWJARB2T.cjs → chunk-F2YI5N7E.cjs} +13 -13
  18. package/dist/{chunk-MWJARB2T.cjs.map → chunk-F2YI5N7E.cjs.map} +1 -1
  19. package/dist/{chunk-BH24GEIY.js → chunk-FI35LJ3L.js} +2 -2
  20. package/dist/{chunk-PDPNJJLB.cjs → chunk-GOFTC2HV.cjs} +431 -489
  21. package/dist/chunk-GOFTC2HV.cjs.map +1 -0
  22. package/dist/{chunk-OYYHTO7U.js → chunk-HGZPH7S5.js} +2 -2
  23. package/dist/{chunk-VIXKP7G7.js → chunk-IHNUMRMU.js} +2 -2
  24. package/dist/{chunk-MCFMOSY6.js → chunk-IK2WRYVA.js} +4 -4
  25. package/dist/{chunk-ORNBZJUZ.cjs → chunk-JIW5JI3E.cjs} +3 -3
  26. package/dist/{chunk-ORNBZJUZ.cjs.map → chunk-JIW5JI3E.cjs.map} +1 -1
  27. package/dist/{chunk-MSMSMXST.js → chunk-JKAX5K7C.js} +5 -5
  28. package/dist/{chunk-AXS2XECN.js → chunk-JO3NPEK6.js} +2 -2
  29. package/dist/{chunk-NLGPA3VY.js → chunk-JOFGJYIT.js} +2 -2
  30. package/dist/{chunk-PPVWJQTF.js → chunk-OT4RV6WY.js} +6 -6
  31. package/dist/{chunk-Z3MUSW3I.cjs → chunk-RJXI25TJ.cjs} +26 -26
  32. package/dist/{chunk-Z3MUSW3I.cjs.map → chunk-RJXI25TJ.cjs.map} +1 -1
  33. package/dist/{chunk-SEZR7FMU.cjs → chunk-SG25J6LV.cjs} +87 -87
  34. package/dist/{chunk-SEZR7FMU.cjs.map → chunk-SG25J6LV.cjs.map} +1 -1
  35. package/dist/{chunk-Z32PJFCD.js → chunk-V5WLIFKN.js} +312 -370
  36. package/dist/{chunk-Z32PJFCD.js.map → chunk-V5WLIFKN.js.map} +1 -1
  37. package/dist/{chunk-DPXBR7O2.cjs → chunk-VVXUUBML.cjs} +26 -26
  38. package/dist/{chunk-DPXBR7O2.cjs.map → chunk-VVXUUBML.cjs.map} +1 -1
  39. package/dist/{chunk-O2XT6VUS.js → chunk-VZX3SSFL.js} +2 -2
  40. package/dist/{chunk-7TKJAGBO.cjs → chunk-WVZHCDB5.cjs} +11 -11
  41. package/dist/{chunk-7TKJAGBO.cjs.map → chunk-WVZHCDB5.cjs.map} +1 -1
  42. package/dist/{chunk-ELED5PW4.js → chunk-XG7FLAKQ.js} +2 -2
  43. package/dist/{chunk-YIPZT3XR.js → chunk-ZIQMVAGA.js} +2 -2
  44. package/dist/components/case-studies/index.cjs +8 -8
  45. package/dist/components/case-studies/index.js +2 -2
  46. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  47. package/dist/components/chat/index.cjs +2 -2
  48. package/dist/components/chat/index.js +1 -1
  49. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
  50. package/dist/components/chat/stream/message-mutations.d.ts +33 -5
  51. package/dist/components/chat/stream/message-mutations.d.ts.map +1 -1
  52. package/dist/components/chat/utils/message-segment-accumulator.d.ts.map +1 -1
  53. package/dist/components/contact/index.cjs +3 -3
  54. package/dist/components/contact/index.js +2 -2
  55. package/dist/components/docs/index.cjs +5 -5
  56. package/dist/components/docs/index.js +4 -4
  57. package/dist/components/embeds/index.cjs +3 -3
  58. package/dist/components/embeds/index.js +2 -2
  59. package/dist/components/faq/index.cjs +3 -3
  60. package/dist/components/faq/index.js +2 -2
  61. package/dist/components/features/index.cjs +2 -2
  62. package/dist/components/features/index.js +1 -1
  63. package/dist/components/help-center-pages/index.cjs +22 -22
  64. package/dist/components/help-center-pages/index.js +13 -13
  65. package/dist/components/index.cjs +132 -132
  66. package/dist/components/index.js +11 -11
  67. package/dist/components/meeting-scheduler/index.cjs +34 -34
  68. package/dist/components/meeting-scheduler/index.js +3 -3
  69. package/dist/components/navigation/index.cjs +2 -2
  70. package/dist/components/navigation/index.js +1 -1
  71. package/dist/components/onboarding-guides/index.cjs +5 -5
  72. package/dist/components/onboarding-guides/index.js +4 -4
  73. package/dist/components/related-content/index.cjs +3 -3
  74. package/dist/components/related-content/index.js +2 -2
  75. package/dist/components/tickets/index.cjs +6 -6
  76. package/dist/components/tickets/index.js +5 -5
  77. package/dist/components/ui/index.cjs +2 -2
  78. package/dist/components/ui/index.js +1 -1
  79. package/dist/index.cjs +2 -2
  80. package/dist/index.js +1 -1
  81. package/package.json +1 -1
  82. package/src/components/chat/entity-cards/dispatch.tsx +87 -98
  83. package/src/components/chat/hooks/use-sse-chat-adapter.ts +15 -15
  84. package/src/components/chat/stream/chat-stream-reducer.ts +6 -0
  85. package/src/components/chat/stream/message-mutations.ts +140 -116
  86. package/src/components/chat/utils/message-segment-accumulator.ts +19 -27
  87. package/dist/chunk-PDPNJJLB.cjs.map +0 -1
  88. /package/dist/{chunk-JEKWIGG6.js.map → chunk-4NFDSMB5.js.map} +0 -0
  89. /package/dist/{chunk-XYD3Y7WU.js.map → chunk-6LMTBNLN.js.map} +0 -0
  90. /package/dist/{chunk-BH24GEIY.js.map → chunk-FI35LJ3L.js.map} +0 -0
  91. /package/dist/{chunk-OYYHTO7U.js.map → chunk-HGZPH7S5.js.map} +0 -0
  92. /package/dist/{chunk-VIXKP7G7.js.map → chunk-IHNUMRMU.js.map} +0 -0
  93. /package/dist/{chunk-MCFMOSY6.js.map → chunk-IK2WRYVA.js.map} +0 -0
  94. /package/dist/{chunk-MSMSMXST.js.map → chunk-JKAX5K7C.js.map} +0 -0
  95. /package/dist/{chunk-AXS2XECN.js.map → chunk-JO3NPEK6.js.map} +0 -0
  96. /package/dist/{chunk-NLGPA3VY.js.map → chunk-JOFGJYIT.js.map} +0 -0
  97. /package/dist/{chunk-PPVWJQTF.js.map → chunk-OT4RV6WY.js.map} +0 -0
  98. /package/dist/{chunk-O2XT6VUS.js.map → chunk-VZX3SSFL.js.map} +0 -0
  99. /package/dist/{chunk-ELED5PW4.js.map → chunk-XG7FLAKQ.js.map} +0 -0
  100. /package/dist/{chunk-YIPZT3XR.js.map → chunk-ZIQMVAGA.js.map} +0 -0
@@ -51548,26 +51548,27 @@ var FINANCIAL_CARD_CONFIGS = {
51548
51548
  balance_sheet: { label: "Balance sheet", icon: () => /* @__PURE__ */ jsx377(BankIcon, { size: 24 }) },
51549
51549
  cash_flow: { label: "Cash flow", icon: () => /* @__PURE__ */ jsx377(CoinsExchangeCurrencyIcon, { size: 24 }) }
51550
51550
  };
51551
- function financialRegistryEntries() {
51551
+ function registryEntries(configs, build) {
51552
51552
  const out = {};
51553
- for (const [docType, cfg] of Object.entries(FINANCIAL_CARD_CONFIGS)) {
51554
- out[docType] = {
51555
- mode: "no-fetch",
51556
- label: cfg.label,
51557
- bareInline: true,
51558
- render: (chatRef, opts) => /* @__PURE__ */ jsx377(
51559
- GenericFinancialChatCard,
51560
- {
51561
- chatRef,
51562
- icon: cfg.icon(),
51563
- isNewTab: opts.isNewTab,
51564
- discuss: opts.discuss
51565
- }
51566
- )
51567
- };
51568
- }
51553
+ for (const [docType, cfg] of Object.entries(configs)) out[docType] = build(cfg);
51569
51554
  return out;
51570
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
+ }
51571
51572
  var GITHUB_CARD_CONFIGS = {
51572
51573
  github_commit: { label: "GitHub commit", kind: "commit" },
51573
51574
  github_commit_public: { label: "GitHub commit (public)", kind: "commit" },
@@ -51577,24 +51578,20 @@ var GITHUB_CARD_CONFIGS = {
51577
51578
  github_pr_review_public: { label: "GitHub review (public)", kind: "pr_review" }
51578
51579
  };
51579
51580
  function githubRegistryEntries() {
51580
- const out = {};
51581
- for (const [docType, cfg] of Object.entries(GITHUB_CARD_CONFIGS)) {
51582
- out[docType] = {
51583
- mode: "no-fetch",
51584
- label: cfg.label,
51585
- bareInline: true,
51586
- render: (chatRef, opts) => /* @__PURE__ */ jsx377(
51587
- GitHubChatCard,
51588
- {
51589
- chatRef,
51590
- kind: cfg.kind,
51591
- isNewTab: opts.isNewTab,
51592
- discuss: opts.discuss
51593
- }
51594
- )
51595
- };
51596
- }
51597
- 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
+ }));
51598
51595
  }
51599
51596
  var PROGRAM_CARD_CONFIGS = {
51600
51597
  podcast: { label: "Podcast episode", configKey: "podcast", contentRefType: "podcast" },
@@ -51602,29 +51599,25 @@ var PROGRAM_CARD_CONFIGS = {
51602
51599
  event: { label: "Event", configKey: "event", contentRefType: "event" }
51603
51600
  };
51604
51601
  function programRegistryEntries() {
51605
- const out = {};
51606
- for (const [docType, cfg] of Object.entries(PROGRAM_CARD_CONFIGS)) {
51607
- out[docType] = {
51608
- mode: "fetch",
51609
- label: cfg.label,
51610
- contentRefType: cfg.contentRefType,
51611
- bareInline: true,
51612
- skeleton: () => /* @__PURE__ */ jsx377(ProgramCardSkeleton, { size: "sm" }),
51613
- render: (item, chatRef, opts) => /* @__PURE__ */ jsx377(
51614
- ProgramChatCard,
51615
- {
51616
- item,
51617
- chatRef,
51618
- isNewTab: opts.isNewTab,
51619
- discuss: opts.discuss,
51620
- configKey: cfg.configKey,
51621
- label: cfg.configKey.charAt(0).toUpperCase() + cfg.configKey.slice(1),
51622
- ogPlaceholder: opts?.extras?.buildOgPlaceholderUrl?.(item?.title ?? "") ?? null
51623
- }
51624
- )
51625
- };
51626
- }
51627
- 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
+ }));
51628
51621
  }
51629
51622
  var ROADMAP_CARD_CONFIGS = {
51630
51623
  roadmap_item: { label: "Roadmap item", cardType: "roadmap_item", contentRefType: "roadmap_item" },
@@ -51643,28 +51636,24 @@ var ROADMAP_CARD_CONFIGS = {
51643
51636
  }
51644
51637
  };
51645
51638
  function roadmapRegistryEntries() {
51646
- const out = {};
51647
- for (const [docType, cfg] of Object.entries(ROADMAP_CARD_CONFIGS)) {
51648
- out[docType] = {
51649
- mode: "fetch",
51650
- label: cfg.label,
51651
- contentRefType: cfg.contentRefType,
51652
- bareInline: true,
51653
- ...cfg.noComposedHref ? { noComposedHref: true } : {},
51654
- skeleton: () => /* @__PURE__ */ jsx377(RoadmapCardSkeleton, { size: "sm" }),
51655
- render: (item, chatRef, opts) => /* @__PURE__ */ jsx377(
51656
- RoadmapChatCard,
51657
- {
51658
- item,
51659
- chatRef,
51660
- isNewTab: opts.isNewTab,
51661
- discuss: opts.discuss,
51662
- cardType: cfg.cardType
51663
- }
51664
- )
51665
- };
51666
- }
51667
- 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
+ }));
51668
51657
  }
51669
51658
  var CHAT_CARD_REGISTRY = {
51670
51659
  // ───────── no-fetch: ChatRef carries everything ─────────
@@ -52019,21 +52008,19 @@ function ChatCardLoader({
52019
52008
  children
52020
52009
  }
52021
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
+ );
52022
52021
  if (entry.mode === "no-fetch") {
52023
52022
  if (!finalChatRef.sourceRepo) return null;
52024
- if (entry.bareInline) {
52025
- return navWrap(entry.render(finalChatRef, renderOpts));
52026
- }
52027
- return /* @__PURE__ */ jsx377(
52028
- ChatCardWithDiscuss,
52029
- {
52030
- chatRef: finalChatRef,
52031
- onDiscuss,
52032
- onDisplay,
52033
- displayAction: entry.displayAction,
52034
- children: navWrap(entry.render(finalChatRef, renderOpts))
52035
- }
52036
- );
52023
+ return finish(entry.render(finalChatRef, renderOpts));
52037
52024
  }
52038
52025
  if (isLoading) return /* @__PURE__ */ jsx377(Fragment87, { children: entry.skeleton() });
52039
52026
  if (!item) {
@@ -52051,19 +52038,7 @@ function ChatCardLoader({
52051
52038
  }
52052
52039
  return null;
52053
52040
  }
52054
- if (entry.bareInline) {
52055
- return /* @__PURE__ */ jsx377(Fragment87, { children: navWrap(entry.render(item, finalChatRef, renderOpts)) });
52056
- }
52057
- return /* @__PURE__ */ jsx377(
52058
- ChatCardWithDiscuss,
52059
- {
52060
- chatRef: finalChatRef,
52061
- onDiscuss,
52062
- onDisplay,
52063
- displayAction: entry.displayAction,
52064
- children: navWrap(entry.render(item, finalChatRef, renderOpts))
52065
- }
52066
- );
52041
+ return finish(entry.render(item, finalChatRef, renderOpts));
52067
52042
  }
52068
52043
  function renderChatInlineEntityCard(chatRef, options = {}) {
52069
52044
  const { onDiscuss, onDisplay, baseRoute, chipBasePlatform, extras } = options;
@@ -54099,6 +54074,214 @@ function buildDiscussPrompt(reference, options = {}) {
54099
54074
  return `${prompt} (${reference.type} ${id})`;
54100
54075
  }
54101
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
+
54102
54285
  // src/components/chat/utils/message-segment-accumulator.ts
54103
54286
  var MessageSegmentAccumulator = class {
54104
54287
  constructor(callbacks) {
@@ -54266,19 +54449,10 @@ var MessageSegmentAccumulator = class {
54266
54449
  const hasCall = seg.data.toolCalls.some((c) => c.toolExecutionRequestId === execId);
54267
54450
  if (!hasCall) return seg;
54268
54451
  const prev = seg.data.executions?.[execId];
54269
- if (toolData.type === "EXECUTING_TOOL" && prev?.status === "done") {
54270
- matched = true;
54271
- return seg;
54272
- }
54273
- 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);
54274
54453
  matched = true;
54275
- return {
54276
- ...seg,
54277
- data: {
54278
- ...seg.data,
54279
- executions: { ...seg.data.executions ?? {}, [execId]: next }
54280
- }
54281
- };
54454
+ if (next === null) return seg;
54455
+ return withBatchExecution(seg, execId, next);
54282
54456
  });
54283
54457
  return matched;
54284
54458
  }
@@ -54413,15 +54587,9 @@ var MessageSegmentAccumulator = class {
54413
54587
  * resolved card shows "by {name}"; omit it to leave any existing value untouched.
54414
54588
  */
54415
54589
  updateApprovalStatus(requestId, status, resolvedByName) {
54416
- this.segments = this.segments.map((segment) => {
54417
- if (segment.type === "approval_request" && segment.data.requestId === requestId) {
54418
- return { ...segment, status };
54419
- }
54420
- if (segment.type === "approval_batch" && segment.data.approvalRequestId === requestId) {
54421
- return { ...segment, status, resolvedByName: resolvedByName ?? segment.resolvedByName };
54422
- }
54423
- return segment;
54424
- });
54590
+ this.segments = this.segments.map(
54591
+ (segment) => applyApprovalStatusToSegment(segment, requestId, status, resolvedByName)
54592
+ );
54425
54593
  return this.getSegments();
54426
54594
  }
54427
54595
  /**
@@ -54566,231 +54734,6 @@ function createMessageSegmentAccumulator(callbacks) {
54566
54734
  // src/chat-protocol/events.ts
54567
54735
  var CHAT_OWNER_ADMIN = "ADMIN";
54568
54736
 
54569
- // src/components/chat/stream/message-mutations.ts
54570
- function nextId(role) {
54571
- return `${role}-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
54572
- }
54573
- var CONTENT_DEDUP_WINDOW = 4;
54574
- var SYSTEM_DEDUP_WINDOW = 10;
54575
- function hasRecentMessage(prev, predicate, window2) {
54576
- const start = Math.max(0, prev.length - window2);
54577
- for (let i = prev.length - 1; i >= start; i--) {
54578
- if (predicate(prev[i])) return true;
54579
- }
54580
- return false;
54581
- }
54582
- function updateTrailingAssistant(prev, segments) {
54583
- const last = prev[prev.length - 1];
54584
- if (!last || last.role !== "assistant") {
54585
- return [
54586
- ...prev,
54587
- {
54588
- id: nextId("assistant"),
54589
- role: "assistant",
54590
- content: "",
54591
- segments
54592
- }
54593
- ];
54594
- }
54595
- return [...prev.slice(0, -1), { ...last, segments }];
54596
- }
54597
- function appendToTrailingAssistant(prev, segments) {
54598
- if (segments.length === 0) return prev;
54599
- const last = prev[prev.length - 1];
54600
- if (!last || last.role !== "assistant") {
54601
- return [
54602
- ...prev,
54603
- { id: nextId("assistant"), role: "assistant", content: "", segments }
54604
- ];
54605
- }
54606
- const merged = [...last.segments ?? []];
54607
- for (const seg of segments) {
54608
- const tail = merged[merged.length - 1];
54609
- if (seg.type === "text" && tail?.type === "text") {
54610
- merged[merged.length - 1] = { type: "text", text: tail.text + seg.text };
54611
- } else if (seg.type === "thinking" && tail?.type === "thinking") {
54612
- merged[merged.length - 1] = { type: "thinking", text: tail.text + seg.text };
54613
- } else if (seg.type === "guide" && tail?.type === "guide") {
54614
- merged[merged.length - 1] = { type: "guide", text: tail.text + seg.text };
54615
- } else if (seg.type === "approval_batch") {
54616
- const idx = merged.findIndex(
54617
- (m) => m.type === "approval_batch" && m.data.approvalRequestId === seg.data.approvalRequestId
54618
- );
54619
- if (idx !== -1) merged[idx] = seg;
54620
- else merged.push(seg);
54621
- } else if (seg.type === "approval_request") {
54622
- const idx = merged.findIndex(
54623
- (m) => m.type === "approval_request" && m.data.requestId === seg.data.requestId && m.data.command === seg.data.command
54624
- );
54625
- if (idx !== -1) merged[idx] = seg;
54626
- else merged.push(seg);
54627
- } else {
54628
- merged.push(seg);
54629
- }
54630
- }
54631
- return [...prev.slice(0, -1), { ...last, segments: merged }];
54632
- }
54633
- function projectBatchStatusToMessages(prev, anchorId, status) {
54634
- let changed = false;
54635
- const next = prev.map((m) => {
54636
- if (m.role !== "assistant" || !m.segments) return m;
54637
- let msgChanged = false;
54638
- const segs = m.segments.map((s) => {
54639
- if (s.type !== "approval_batch") return s;
54640
- if (s.data.approvalRequestId !== anchorId || s.status === status) return s;
54641
- msgChanged = true;
54642
- return { ...s, status };
54643
- });
54644
- if (!msgChanged) return m;
54645
- changed = true;
54646
- return { ...m, segments: segs };
54647
- });
54648
- return changed ? next : prev;
54649
- }
54650
- function projectBatchRowFailureToMessages(prev, rowRequestId) {
54651
- let changed = false;
54652
- const next = prev.map((m) => {
54653
- if (m.role !== "assistant" || !m.segments) return m;
54654
- let msgChanged = false;
54655
- const segs = m.segments.map((s) => {
54656
- if (s.type !== "approval_batch" || !s.data.toolCalls?.some((c) => c.toolExecutionRequestId === rowRequestId)) {
54657
- return s;
54658
- }
54659
- const existing = s.data.executions?.[rowRequestId];
54660
- if (existing?.status === "done") return s;
54661
- msgChanged = true;
54662
- return {
54663
- ...s,
54664
- data: {
54665
- ...s.data,
54666
- executions: {
54667
- ...s.data.executions ?? {},
54668
- [rowRequestId]: { status: "done", success: false }
54669
- }
54670
- }
54671
- };
54672
- });
54673
- if (!msgChanged) return m;
54674
- changed = true;
54675
- return { ...m, segments: segs };
54676
- });
54677
- return changed ? next : prev;
54678
- }
54679
- function upsertTrailingCompaction(prev, segments) {
54680
- const compaction = [...segments].reverse().find((s) => s.type === "context_compaction");
54681
- if (!compaction) return prev;
54682
- const last = prev[prev.length - 1];
54683
- if (!last || last.role !== "assistant") {
54684
- return [
54685
- ...prev,
54686
- { id: nextId("assistant"), role: "assistant", content: "", segments: [compaction] }
54687
- ];
54688
- }
54689
- const existing = last.segments ?? [];
54690
- const startedIdx = existing.map((s) => s.type === "context_compaction" && s.status === "started").lastIndexOf(true);
54691
- const merged = startedIdx !== -1 ? existing.map((s, i) => i === startedIdx ? compaction : s) : [...existing, compaction];
54692
- return [...prev.slice(0, -1), { ...last, segments: merged }];
54693
- }
54694
- function sameToolData(a, b) {
54695
- 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));
54696
- }
54697
- function sameExecutionState(a, b) {
54698
- return !!a && a.status === b.status && a.result === b.result && a.success === b.success;
54699
- }
54700
- function applyToolExecutionToMessages(prev, segment) {
54701
- const merged = mergeToolExecutionIfPresent(prev, segment);
54702
- if (merged !== null) return merged;
54703
- return appendToTrailingAssistant(prev, [segment]);
54704
- }
54705
- function mergeToolExecutionIfPresent(prev, segment) {
54706
- const toolData = segment.data;
54707
- const execId = toolData.toolExecutionRequestId;
54708
- for (let i = prev.length - 1; i >= 0; i--) {
54709
- const message2 = prev[i];
54710
- if (message2.role !== "assistant" || !message2.segments) continue;
54711
- for (let j = message2.segments.length - 1; j >= 0; j--) {
54712
- const seg = message2.segments[j];
54713
- if (execId && seg.type === "approval_batch" && seg.data.toolCalls.some((c) => c.toolExecutionRequestId === execId)) {
54714
- const prevExec = seg.data.executions?.[execId];
54715
- if (toolData.type === "EXECUTING_TOOL" && prevExec?.status === "done") {
54716
- return prev;
54717
- }
54718
- const nextExec = toolData.type === "EXECUTED_TOOL" ? { status: "done", result: toolData.result, success: toolData.success } : { status: "executing", result: prevExec?.result, success: prevExec?.success };
54719
- if (sameExecutionState(prevExec, nextExec)) return prev;
54720
- const nextSegments = [...message2.segments];
54721
- nextSegments[j] = {
54722
- ...seg,
54723
- data: { ...seg.data, executions: { ...seg.data.executions ?? {}, [execId]: nextExec } }
54724
- };
54725
- const next = [...prev];
54726
- next[i] = { ...message2, segments: nextSegments };
54727
- return next;
54728
- }
54729
- if (seg.type === "tool_execution") {
54730
- const matches = execId ? seg.data.toolExecutionRequestId === execId : seg.data.type === "EXECUTING_TOOL" && seg.data.integratedToolType === toolData.integratedToolType && seg.data.toolFunction === toolData.toolFunction;
54731
- if (!matches) continue;
54732
- if (toolData.type === "EXECUTING_TOOL" && seg.data.type === "EXECUTED_TOOL") {
54733
- return prev;
54734
- }
54735
- const mergedData = {
54736
- ...toolData,
54737
- toolTitle: toolData.toolTitle ?? seg.data.toolTitle,
54738
- parameters: toolData.parameters || seg.data.parameters
54739
- };
54740
- if (sameToolData(seg.data, mergedData)) return prev;
54741
- const nextSegments = [...message2.segments];
54742
- nextSegments[j] = { type: "tool_execution", data: mergedData };
54743
- const next = [...prev];
54744
- next[i] = { ...message2, segments: nextSegments };
54745
- return next;
54746
- }
54747
- }
54748
- }
54749
- return null;
54750
- }
54751
- function projectApprovalResolutionToMessages(prev, requestId, status, resolvedByName) {
54752
- let changed = false;
54753
- const next = prev.map((m) => {
54754
- if (m.role !== "assistant" || !m.segments) return m;
54755
- let msgChanged = false;
54756
- const segs = m.segments.map((s) => {
54757
- if (s.type === "approval_request" && s.data.requestId === requestId && s.status !== status) {
54758
- msgChanged = true;
54759
- return { ...s, status };
54760
- }
54761
- if (s.type === "approval_batch") {
54762
- const isAnchor = s.data.approvalRequestId === requestId;
54763
- const hasRow = s.data.toolCalls?.some((c) => c.toolExecutionRequestId === requestId);
54764
- if (!isAnchor && !hasRow) return s;
54765
- const nextResolvedBy = resolvedByName ?? s.resolvedByName;
54766
- const nextExecutions = hasRow ? {
54767
- ...s.data.executions ?? {},
54768
- [requestId]: { status: "done", success: status === "approved" }
54769
- } : s.data.executions;
54770
- const nextStatus = isAnchor ? status : s.status;
54771
- if (s.status === nextStatus && nextResolvedBy === s.resolvedByName && nextExecutions === s.data.executions) {
54772
- return s;
54773
- }
54774
- msgChanged = true;
54775
- return {
54776
- ...s,
54777
- status: nextStatus,
54778
- resolvedByName: nextResolvedBy,
54779
- data: {
54780
- ...s.data,
54781
- ...nextExecutions ? { executions: nextExecutions } : {}
54782
- }
54783
- };
54784
- }
54785
- return s;
54786
- });
54787
- if (!msgChanged) return m;
54788
- changed = true;
54789
- return { ...m, segments: segs };
54790
- });
54791
- return changed ? next : prev;
54792
- }
54793
-
54794
54737
  // src/components/chat/stream/chat-stream-reducer.ts
54795
54738
  function createEmptyTurnMeta() {
54796
54739
  return {
@@ -55819,6 +55762,7 @@ function createChatStreamReducer(options = {}) {
55819
55762
  setMessagesInternal(
55820
55763
  projectApprovalResolutionToMessages(messages, requestId, status, resolvedByName)
55821
55764
  );
55765
+ mirrorApprovalStatus(requestId, status);
55822
55766
  return segments;
55823
55767
  },
55824
55768
  getPendingEscalated() {
@@ -56169,20 +56113,18 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
56169
56113
  const source = runtime.source || DEFAULT_CHAT_SOURCE;
56170
56114
  const tableIdForDocumentType = options?.tableIdForDocumentType ?? defaultTableIdForDocumentType;
56171
56115
  const sendMessageRef = useRef77(async () => true);
56172
- const cardApprove = useCallback54((reqId) => {
56173
- if (!reqId) return;
56174
- return sendMessageRef.current("", {
56175
- hidden: true,
56176
- approvalAction: { proposalId: reqId, action: "approve" }
56177
- });
56178
- }, []);
56179
- const cardReject = useCallback54((reqId) => {
56180
- if (!reqId) return;
56181
- return sendMessageRef.current("", {
56182
- hidden: true,
56183
- approvalAction: { proposalId: reqId, action: "reject" }
56184
- });
56185
- }, []);
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]);
56186
56128
  const createReducerOptions = useCallback54(
56187
56129
  () => ({
56188
56130
  transport: "sse",
@@ -60495,13 +60437,13 @@ export {
60495
60437
  extractEntityIdFilter,
60496
60438
  buildDiscussAddendum,
60497
60439
  buildDiscussPrompt,
60440
+ appendToTrailingAssistant,
60441
+ upsertTrailingCompaction,
60442
+ applyToolExecutionToMessages,
60498
60443
  MessageSegmentAccumulator,
60499
60444
  createMessageSegmentAccumulator,
60500
60445
  SCROLL_ANCHOR_WIRE_KEY,
60501
60446
  parseScrollAnchor,
60502
- appendToTrailingAssistant,
60503
- upsertTrailingCompaction,
60504
- applyToolExecutionToMessages,
60505
60447
  createEmptyTurnMeta,
60506
60448
  createChatStreamReducer,
60507
60449
  DEFAULT_DIALOG_SIDE,
@@ -60980,4 +60922,4 @@ export {
60980
60922
  LogsList,
60981
60923
  assets
60982
60924
  };
60983
- //# sourceMappingURL=chunk-Z32PJFCD.js.map
60925
+ //# sourceMappingURL=chunk-V5WLIFKN.js.map