@flamingo-stack/openframe-frontend-core 0.0.532 → 0.0.533

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 (151) hide show
  1. package/dist/chat-protocol/confirm-tool.d.ts +50 -0
  2. package/dist/chat-protocol/confirm-tool.d.ts.map +1 -0
  3. package/dist/chat-protocol/decode.d.ts +1 -9
  4. package/dist/chat-protocol/decode.d.ts.map +1 -1
  5. package/dist/chat-protocol/events.d.ts +35 -0
  6. package/dist/chat-protocol/events.d.ts.map +1 -1
  7. package/dist/chat-protocol/index.cjs +72 -3
  8. package/dist/chat-protocol/index.cjs.map +1 -1
  9. package/dist/chat-protocol/index.d.ts +1 -0
  10. package/dist/chat-protocol/index.d.ts.map +1 -1
  11. package/dist/chat-protocol/index.js +67 -4
  12. package/dist/chat-protocol/index.js.map +1 -1
  13. package/dist/chat-protocol/leading-frames.d.ts +38 -0
  14. package/dist/chat-protocol/leading-frames.d.ts.map +1 -0
  15. package/dist/chat-protocol/nats-decoder.d.ts +41 -0
  16. package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
  17. package/dist/{chunk-QEMI34VA.cjs → chunk-2MYDGLJS.cjs} +87 -87
  18. package/dist/{chunk-QEMI34VA.cjs.map → chunk-2MYDGLJS.cjs.map} +1 -1
  19. package/dist/{chunk-TQ7EPKKO.js → chunk-2TUOBFPK.js} +2 -2
  20. package/dist/{chunk-XBYEPSNZ.js → chunk-2XGHEJZK.js} +4 -4
  21. package/dist/{chunk-OAEJWP7H.js → chunk-46FKXLNE.js} +2 -2
  22. package/dist/{chunk-ECR37JHH.js → chunk-4QKXNWH5.js} +2 -2
  23. package/dist/{chunk-GWFC3NE5.cjs → chunk-4ZRHVOEB.cjs} +31 -31
  24. package/dist/{chunk-GWFC3NE5.cjs.map → chunk-4ZRHVOEB.cjs.map} +1 -1
  25. package/dist/{chunk-AZBS4PZG.js → chunk-5U67WTAS.js} +2 -2
  26. package/dist/{chunk-3G7FDE5E.js → chunk-6SMLYZLH.js} +4 -4
  27. package/dist/{chunk-7SGBF2I2.js → chunk-6W3ULZ4X.js} +6 -6
  28. package/dist/{chunk-ALXLWF75.js → chunk-6YXN5RHW.js} +2 -2
  29. package/dist/{chunk-2QP67D2L.cjs → chunk-DFQLUK75.cjs} +3 -3
  30. package/dist/{chunk-2QP67D2L.cjs.map → chunk-DFQLUK75.cjs.map} +1 -1
  31. package/dist/{chunk-ETF2QXXU.cjs → chunk-ENPGPZIB.cjs} +61 -61
  32. package/dist/{chunk-ETF2QXXU.cjs.map → chunk-ENPGPZIB.cjs.map} +1 -1
  33. package/dist/{chunk-HJDCDOJM.cjs → chunk-GNOK5J34.cjs} +37 -37
  34. package/dist/{chunk-HJDCDOJM.cjs.map → chunk-GNOK5J34.cjs.map} +1 -1
  35. package/dist/{chunk-4GL2XJ5C.cjs → chunk-J4BE4FIR.cjs} +4 -4
  36. package/dist/{chunk-4GL2XJ5C.cjs.map → chunk-J4BE4FIR.cjs.map} +1 -1
  37. package/dist/{chunk-HXHA3DCI.cjs → chunk-JDW2IL7A.cjs} +11 -11
  38. package/dist/{chunk-HXHA3DCI.cjs.map → chunk-JDW2IL7A.cjs.map} +1 -1
  39. package/dist/{chunk-TMZS63G2.cjs → chunk-KMB66NYX.cjs} +7 -7
  40. package/dist/{chunk-TMZS63G2.cjs.map → chunk-KMB66NYX.cjs.map} +1 -1
  41. package/dist/{chunk-5W3RCZIK.js → chunk-LE3BJ5H2.js} +2 -2
  42. package/dist/{chunk-WINT757E.js → chunk-LIUARTOZ.js} +206 -64
  43. package/dist/chunk-LIUARTOZ.js.map +1 -0
  44. package/dist/{chunk-65NR333L.js → chunk-MVGL5NNJ.js} +2 -2
  45. package/dist/{chunk-LYWSHNK4.cjs → chunk-NAV4FRNL.cjs} +26 -26
  46. package/dist/{chunk-LYWSHNK4.cjs.map → chunk-NAV4FRNL.cjs.map} +1 -1
  47. package/dist/{chunk-2MBS3YEY.cjs → chunk-OLOKQQAP.cjs} +5 -5
  48. package/dist/{chunk-2MBS3YEY.cjs.map → chunk-OLOKQQAP.cjs.map} +1 -1
  49. package/dist/{chunk-QYNLVIGQ.cjs → chunk-QZ2NAPLF.cjs} +9 -9
  50. package/dist/{chunk-QYNLVIGQ.cjs.map → chunk-QZ2NAPLF.cjs.map} +1 -1
  51. package/dist/{chunk-L6EKEYF7.cjs → chunk-RKITTO5V.cjs} +14 -14
  52. package/dist/{chunk-L6EKEYF7.cjs.map → chunk-RKITTO5V.cjs.map} +1 -1
  53. package/dist/{chunk-UP4RA54U.js → chunk-U555TMPC.js} +5 -5
  54. package/dist/{chunk-GVLA2BPW.cjs → chunk-UPHN2VRZ.cjs} +259 -117
  55. package/dist/chunk-UPHN2VRZ.cjs.map +1 -0
  56. package/dist/{chunk-IZOGFZ7N.js → chunk-XN4JKIJY.js} +2 -2
  57. package/dist/{chunk-KYQZBQYV.js → chunk-YLB6XXO6.js} +2 -2
  58. package/dist/{chunk-JZ5XDZYD.cjs → chunk-Z3NOI7X7.cjs} +26 -26
  59. package/dist/{chunk-JZ5XDZYD.cjs.map → chunk-Z3NOI7X7.cjs.map} +1 -1
  60. package/dist/components/case-studies/index.cjs +8 -8
  61. package/dist/components/case-studies/index.js +2 -2
  62. package/dist/components/chat/embeddable-chat.d.ts +13 -0
  63. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  64. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  65. package/dist/components/chat/index.cjs +10 -2
  66. package/dist/components/chat/index.cjs.map +1 -1
  67. package/dist/components/chat/index.js +9 -1
  68. package/dist/components/chat/stream/chat-stream-reducer.d.ts +9 -0
  69. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
  70. package/dist/components/chat/types/message.types.d.ts +15 -0
  71. package/dist/components/chat/types/message.types.d.ts.map +1 -1
  72. package/dist/components/chat/types/network.types.d.ts +4 -0
  73. package/dist/components/chat/types/network.types.d.ts.map +1 -1
  74. package/dist/components/chat/types/processing.types.d.ts +7 -1
  75. package/dist/components/chat/types/processing.types.d.ts.map +1 -1
  76. package/dist/components/chat/utils/approval-display.d.ts +49 -0
  77. package/dist/components/chat/utils/approval-display.d.ts.map +1 -0
  78. package/dist/components/chat/utils/index.d.ts +1 -0
  79. package/dist/components/chat/utils/index.d.ts.map +1 -1
  80. package/dist/components/chat/utils/message-segment-accumulator.d.ts +25 -3
  81. package/dist/components/chat/utils/message-segment-accumulator.d.ts.map +1 -1
  82. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  83. package/dist/components/contact/index.cjs +3 -3
  84. package/dist/components/contact/index.js +2 -2
  85. package/dist/components/docs/index.cjs +5 -5
  86. package/dist/components/docs/index.js +4 -4
  87. package/dist/components/embeds/index.cjs +3 -3
  88. package/dist/components/embeds/index.js +2 -2
  89. package/dist/components/faq/index.cjs +3 -3
  90. package/dist/components/faq/index.js +2 -2
  91. package/dist/components/features/index.cjs +2 -2
  92. package/dist/components/features/index.js +1 -1
  93. package/dist/components/help-center-pages/index.cjs +22 -22
  94. package/dist/components/help-center-pages/index.js +13 -13
  95. package/dist/components/index.cjs +140 -132
  96. package/dist/components/index.cjs.map +1 -1
  97. package/dist/components/index.js +19 -11
  98. package/dist/components/index.js.map +1 -1
  99. package/dist/components/meeting-scheduler/index.cjs +34 -34
  100. package/dist/components/meeting-scheduler/index.js +3 -3
  101. package/dist/components/navigation/index.cjs +2 -2
  102. package/dist/components/navigation/index.js +1 -1
  103. package/dist/components/onboarding-guides/index.cjs +5 -5
  104. package/dist/components/onboarding-guides/index.js +4 -4
  105. package/dist/components/related-content/index.cjs +3 -3
  106. package/dist/components/related-content/index.js +2 -2
  107. package/dist/components/tickets/index.cjs +6 -6
  108. package/dist/components/tickets/index.js +5 -5
  109. package/dist/components/ui/index.cjs +10 -2
  110. package/dist/components/ui/index.cjs.map +1 -1
  111. package/dist/components/ui/index.js +9 -1
  112. package/dist/index.cjs +10 -2
  113. package/dist/index.cjs.map +1 -1
  114. package/dist/index.js +9 -1
  115. package/dist/utils/index.cjs.map +1 -1
  116. package/dist/utils/index.js.map +1 -1
  117. package/package.json +1 -1
  118. package/src/chat-protocol/__tests__/__snapshots__/nats-decoder-golden.test.ts.snap +70 -0
  119. package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +108 -1
  120. package/src/chat-protocol/confirm-tool.ts +67 -0
  121. package/src/chat-protocol/decode.ts +7 -153
  122. package/src/chat-protocol/events.ts +40 -0
  123. package/src/chat-protocol/index.ts +3 -0
  124. package/src/chat-protocol/leading-frames.ts +175 -0
  125. package/src/chat-protocol/nats-decoder.ts +111 -3
  126. package/src/components/chat/embeddable-chat.tsx +18 -0
  127. package/src/components/chat/hooks/use-sse-chat-adapter.ts +7 -16
  128. package/src/components/chat/stream/chat-stream-reducer.ts +49 -3
  129. package/src/components/chat/types/message.types.ts +15 -0
  130. package/src/components/chat/types/network.types.ts +4 -0
  131. package/src/components/chat/types/processing.types.ts +12 -1
  132. package/src/components/chat/utils/__tests__/process-historical-messages-approvals.test.ts +92 -0
  133. package/src/components/chat/utils/approval-display.ts +70 -0
  134. package/src/components/chat/utils/index.ts +9 -0
  135. package/src/components/chat/utils/message-segment-accumulator.ts +62 -32
  136. package/src/components/chat/utils/process-historical-messages.ts +40 -6
  137. package/dist/chunk-GVLA2BPW.cjs.map +0 -1
  138. package/dist/chunk-WINT757E.js.map +0 -1
  139. /package/dist/{chunk-TQ7EPKKO.js.map → chunk-2TUOBFPK.js.map} +0 -0
  140. /package/dist/{chunk-XBYEPSNZ.js.map → chunk-2XGHEJZK.js.map} +0 -0
  141. /package/dist/{chunk-OAEJWP7H.js.map → chunk-46FKXLNE.js.map} +0 -0
  142. /package/dist/{chunk-ECR37JHH.js.map → chunk-4QKXNWH5.js.map} +0 -0
  143. /package/dist/{chunk-AZBS4PZG.js.map → chunk-5U67WTAS.js.map} +0 -0
  144. /package/dist/{chunk-3G7FDE5E.js.map → chunk-6SMLYZLH.js.map} +0 -0
  145. /package/dist/{chunk-7SGBF2I2.js.map → chunk-6W3ULZ4X.js.map} +0 -0
  146. /package/dist/{chunk-ALXLWF75.js.map → chunk-6YXN5RHW.js.map} +0 -0
  147. /package/dist/{chunk-5W3RCZIK.js.map → chunk-LE3BJ5H2.js.map} +0 -0
  148. /package/dist/{chunk-65NR333L.js.map → chunk-MVGL5NNJ.js.map} +0 -0
  149. /package/dist/{chunk-UP4RA54U.js.map → chunk-U555TMPC.js.map} +0 -0
  150. /package/dist/{chunk-IZOGFZ7N.js.map → chunk-XN4JKIJY.js.map} +0 -0
  151. /package/dist/{chunk-KYQZBQYV.js.map → chunk-YLB6XXO6.js.map} +0 -0
@@ -54602,12 +54602,29 @@ function useChat({
54602
54602
  // src/components/chat/hooks/use-sse-chat-adapter.ts
54603
54603
  import { useCallback as useCallback56, useMemo as useMemo52, useRef as useRef79 } from "react";
54604
54604
 
54605
+ // src/chat-protocol/confirm-tool.ts
54606
+ function buildConfirmToolBody(request) {
54607
+ return {
54608
+ proposal_id: request.proposalId,
54609
+ action: request.action,
54610
+ conversationId: request.conversationId
54611
+ };
54612
+ }
54613
+ async function readServerErrorMessage(response) {
54614
+ try {
54615
+ const body = await response.json();
54616
+ if (typeof body?.error === "string" && body.error.length > 0) return body.error;
54617
+ } catch {
54618
+ }
54619
+ return null;
54620
+ }
54621
+
54605
54622
  // src/chat-protocol/frames.ts
54606
54623
  var FRAME_TERMINATOR = "\0";
54607
54624
  var END_OF_LEADING = "";
54608
54625
  var TRAILER_SENTINEL = "";
54609
54626
 
54610
- // src/chat-protocol/decode.ts
54627
+ // src/chat-protocol/leading-frames.ts
54611
54628
  function escapeThinkingTags(text) {
54612
54629
  return text.replace(/</g, "&lt;");
54613
54630
  }
@@ -54714,6 +54731,8 @@ function mapLeadingFrame(meta, out) {
54714
54731
  });
54715
54732
  }
54716
54733
  }
54734
+
54735
+ // src/chat-protocol/decode.ts
54717
54736
  function createSseFrameDecoder() {
54718
54737
  const textDecoder = new TextDecoder();
54719
54738
  let buffer = "";
@@ -55373,21 +55392,41 @@ var MessageSegmentAccumulator = class {
55373
55392
  /**
55374
55393
  * Add an approval request segment directly (for CLIENT approvals)
55375
55394
  */
55376
- addApprovalRequest(requestId, command, explanation, approvalType, status = "pending") {
55377
- const segment = {
55395
+ addApprovalRequest(requestId, command, explanation, approvalType, status = "pending", fields, origin) {
55396
+ this.segments.push(
55397
+ this.buildApprovalRequestSegment(
55398
+ requestId,
55399
+ { command, explanation, approvalType, fields, origin },
55400
+ status
55401
+ )
55402
+ );
55403
+ return this.getSegments();
55404
+ }
55405
+ /**
55406
+ * Build one approval-request segment — THE constructor for this segment type.
55407
+ *
55408
+ * Three paths produce these: `addApprovalRequest` (live stream and replay),
55409
+ * `flushPendingApprovals` (tracked-but-unresolved after a history replay) and
55410
+ * `processApprovalResult` (a result arriving for a tracked request). They used
55411
+ * to hand-write the object each, which is how `fields` and `origin` reached
55412
+ * the card down one path and not the others — the same proposal rendering as a
55413
+ * bare title, or losing the marker that routes its buttons to the hub.
55414
+ */
55415
+ buildApprovalRequestSegment(requestId, approval, status) {
55416
+ return {
55378
55417
  type: "approval_request",
55379
55418
  data: {
55380
- command,
55381
- explanation,
55419
+ command: approval.command,
55420
+ explanation: approval.explanation,
55382
55421
  requestId,
55383
- approvalType
55422
+ approvalType: approval.approvalType,
55423
+ ...approval.fields && approval.fields.length > 0 ? { fields: approval.fields } : {},
55424
+ ...approval.origin ? { origin: approval.origin } : {}
55384
55425
  },
55385
55426
  status,
55386
55427
  onApprove: this.callbacks.onApprove,
55387
55428
  onReject: this.callbacks.onReject
55388
55429
  };
55389
- this.segments.push(segment);
55390
- return this.getSegments();
55391
55430
  }
55392
55431
  /**
55393
55432
  * Add a batch approval segment containing multiple tool calls. Upserts by
@@ -55402,20 +55441,22 @@ var MessageSegmentAccumulator = class {
55402
55441
  * `executions` is forwarded as-is. On upsert, a new `executions` object
55403
55442
  * overrides the existing one (so the latest replay wins).
55404
55443
  */
55405
- addApprovalBatch(approvalRequestId, approvalType, toolCalls, status = "pending", executions, resolvedByName) {
55444
+ addApprovalBatch(approvalRequestId, approvalType, toolCalls, status = "pending", executions, resolvedByName, origin) {
55406
55445
  const existingIndex = this.segments.findIndex(
55407
55446
  (s) => s.type === "approval_batch" && s.data.approvalRequestId === approvalRequestId
55408
55447
  );
55409
55448
  if (existingIndex !== -1) {
55410
55449
  const existing = this.segments[existingIndex];
55411
55450
  const mergedExecutions = executions ?? existing.data.executions;
55451
+ const mergedOrigin = origin ?? existing.data.origin;
55412
55452
  this.segments[existingIndex] = {
55413
55453
  ...existing,
55414
55454
  data: {
55415
55455
  approvalRequestId,
55416
55456
  approvalType,
55417
55457
  toolCalls,
55418
- ...mergedExecutions ? { executions: mergedExecutions } : {}
55458
+ ...mergedExecutions ? { executions: mergedExecutions } : {},
55459
+ ...mergedOrigin ? { origin: mergedOrigin } : {}
55419
55460
  },
55420
55461
  status,
55421
55462
  resolvedByName: resolvedByName ?? existing.resolvedByName,
@@ -55430,7 +55471,8 @@ var MessageSegmentAccumulator = class {
55430
55471
  approvalRequestId,
55431
55472
  approvalType,
55432
55473
  toolCalls,
55433
- ...executions ? { executions } : {}
55474
+ ...executions ? { executions } : {},
55475
+ ...origin ? { origin } : {}
55434
55476
  },
55435
55477
  status,
55436
55478
  resolvedByName,
@@ -55447,18 +55489,15 @@ var MessageSegmentAccumulator = class {
55447
55489
  processApprovalResult(requestId, approved, approvalType) {
55448
55490
  const pendingApproval = this.pendingApprovals.get(requestId);
55449
55491
  const status = approved ? "approved" : "rejected";
55450
- const segment = {
55451
- type: "approval_request",
55452
- data: {
55492
+ const segment = this.buildApprovalRequestSegment(
55493
+ requestId,
55494
+ {
55495
+ ...pendingApproval,
55453
55496
  command: pendingApproval?.command || "",
55454
- explanation: pendingApproval?.explanation,
55455
- requestId,
55456
55497
  approvalType: pendingApproval?.approvalType || approvalType
55457
55498
  },
55458
- status,
55459
- onApprove: this.callbacks.onApprove,
55460
- onReject: this.callbacks.onReject
55461
- };
55499
+ status
55500
+ );
55462
55501
  this.segments.push(segment);
55463
55502
  if (pendingApproval) {
55464
55503
  this.pendingApprovals.delete(requestId);
@@ -55539,18 +55578,7 @@ var MessageSegmentAccumulator = class {
55539
55578
  flushPendingApprovals() {
55540
55579
  const segments = [];
55541
55580
  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
- });
55581
+ segments.push(this.buildApprovalRequestSegment(requestId, approval, "pending"));
55554
55582
  });
55555
55583
  return segments;
55556
55584
  }
@@ -55616,7 +55644,9 @@ var MessageSegmentAccumulator = class {
55616
55644
  data.command,
55617
55645
  data.explanation,
55618
55646
  data.approvalType || "",
55619
- status
55647
+ status,
55648
+ data.fields,
55649
+ data.origin
55620
55650
  );
55621
55651
  break;
55622
55652
  }
@@ -55628,7 +55658,8 @@ var MessageSegmentAccumulator = class {
55628
55658
  data.toolCalls,
55629
55659
  status,
55630
55660
  data.executions,
55631
- resolvedByName
55661
+ resolvedByName,
55662
+ data.origin
55632
55663
  );
55633
55664
  break;
55634
55665
  }
@@ -55672,6 +55703,10 @@ function createMessageSegmentAccumulator(callbacks) {
55672
55703
  }
55673
55704
 
55674
55705
  // src/chat-protocol/events.ts
55706
+ var GUIDE_ORIGIN = "guide";
55707
+ function isGuideOrigin(source) {
55708
+ return source?.origin === GUIDE_ORIGIN;
55709
+ }
55675
55710
  var ESCALATION_STATE = {
55676
55711
  PENDING: "PENDING",
55677
55712
  APPROVED: "APPROVED",
@@ -55692,6 +55727,22 @@ function escalationResolvedStatus(state) {
55692
55727
  }
55693
55728
  var CHAT_OWNER_ADMIN = "ADMIN";
55694
55729
 
55730
+ // src/components/chat/utils/approval-display.ts
55731
+ function isGuideApproval(source) {
55732
+ return isGuideOrigin(source);
55733
+ }
55734
+ function guideApprovalOrigin(source) {
55735
+ return isGuideApproval(source) ? GUIDE_ORIGIN : void 0;
55736
+ }
55737
+ function approvalDisplaysInline(source, approvalType, displayApprovalTypes) {
55738
+ if (isGuideApproval(source)) return true;
55739
+ return !displayApprovalTypes || displayApprovalTypes.includes(approvalType);
55740
+ }
55741
+ function isGuideApprovalSegment(segment) {
55742
+ if (segment.type !== "approval_request" && segment.type !== "approval_batch") return false;
55743
+ return isGuideApproval(segment.data);
55744
+ }
55745
+
55695
55746
  // src/components/chat/stream/chat-stream-reducer.ts
55696
55747
  function createEmptyTurnMeta() {
55697
55748
  return {
@@ -55727,6 +55778,7 @@ function createChatStreamReducer(options = {}) {
55727
55778
  let streamingPhase = "idle";
55728
55779
  let dialogTokenUsage = null;
55729
55780
  let liveModel = null;
55781
+ let guideConversationId = null;
55730
55782
  let approvalStatuses = {
55731
55783
  ...options.approvalStatuses ?? {}
55732
55784
  };
@@ -55787,7 +55839,8 @@ function createChatStreamReducer(options = {}) {
55787
55839
  turnMeta: { meta: metaMap, sources: sourcesMap, refs: refsMap, sendCount },
55788
55840
  dialogTokenUsage,
55789
55841
  liveModel,
55790
- approvalStatuses
55842
+ approvalStatuses,
55843
+ guideConversationId
55791
55844
  };
55792
55845
  }
55793
55846
  return stateCache;
@@ -55977,6 +56030,13 @@ function createChatStreamReducer(options = {}) {
55977
56030
  break;
55978
56031
  }
55979
56032
  case "metadata": {
56033
+ if (isGuideOrigin(event)) {
56034
+ if (typeof event.conversationId === "string" && event.conversationId) {
56035
+ guideConversationId = event.conversationId;
56036
+ invalidate();
56037
+ }
56038
+ break;
56039
+ }
55980
56040
  emit("onMetadata", {
55981
56041
  action: "metadata",
55982
56042
  modelDisplayName: event.modelLabel ?? void 0,
@@ -56053,9 +56113,11 @@ function createChatStreamReducer(options = {}) {
56053
56113
  const requestId = event.requestId;
56054
56114
  const approvalType = event.approvalType ?? "USER";
56055
56115
  const toolCalls = event.toolCalls;
56116
+ const guideOrigin = guideApprovalOrigin(event);
56117
+ const displayInline = (type) => approvalDisplaysInline(event, type, displayApprovalTypes);
56056
56118
  if (toolCalls && toolCalls.length > 0) {
56057
56119
  const status = approvalStatuses[requestId] || "pending";
56058
- if (!displayApprovalTypes.includes(approvalType)) {
56120
+ if (!displayInline(approvalType)) {
56059
56121
  const required = toolCalls.find((c) => c.requiresApproval) ?? toolCalls[0];
56060
56122
  const summary = required ? getCommandText(required) : `Batch of ${toolCalls.length} tool calls`;
56061
56123
  pendingEscalated.set(requestId, {
@@ -56073,7 +56135,15 @@ function createChatStreamReducer(options = {}) {
56073
56135
  }
56074
56136
  if (batchApprovalsEnabled) {
56075
56137
  const before2 = accumulator.getSegments().length;
56076
- const segments2 = accumulator.addApprovalBatch(requestId, approvalType, toolCalls, status);
56138
+ const segments2 = accumulator.addApprovalBatch(
56139
+ requestId,
56140
+ approvalType,
56141
+ toolCalls,
56142
+ status,
56143
+ void 0,
56144
+ void 0,
56145
+ guideOrigin
56146
+ );
56077
56147
  applyAccumulated(before2, segments2);
56078
56148
  break;
56079
56149
  }
@@ -56086,7 +56156,9 @@ function createChatStreamReducer(options = {}) {
56086
56156
  getCommandText(call),
56087
56157
  call.toolExplanation,
56088
56158
  approvalType,
56089
- status
56159
+ status,
56160
+ void 0,
56161
+ guideOrigin
56090
56162
  );
56091
56163
  }
56092
56164
  applyAccumulated(before, segments);
@@ -56094,7 +56166,7 @@ function createChatStreamReducer(options = {}) {
56094
56166
  }
56095
56167
  const command = event.command ?? "";
56096
56168
  const explanation = event.explanation;
56097
- if (displayApprovalTypes.includes(approvalType)) {
56169
+ if (displayInline(approvalType)) {
56098
56170
  const status = approvalStatuses[requestId] || "pending";
56099
56171
  const before = accumulator.getSegments().length;
56100
56172
  const segments = accumulator.addApprovalRequest(
@@ -56102,7 +56174,11 @@ function createChatStreamReducer(options = {}) {
56102
56174
  command,
56103
56175
  explanation,
56104
56176
  approvalType,
56105
- status
56177
+ status,
56178
+ // SSE-shaped cards (a re-streamed Product Guide proposal) carry
56179
+ // their body as structured rows rather than prose.
56180
+ event.fields,
56181
+ guideOrigin
56106
56182
  );
56107
56183
  applyAccumulated(before, segments);
56108
56184
  } else {
@@ -56519,6 +56595,7 @@ function createChatStreamReducer(options = {}) {
56519
56595
  streamingPhase = "idle";
56520
56596
  dialogTokenUsage = null;
56521
56597
  liveModel = null;
56598
+ guideConversationId = null;
56522
56599
  approvalStatuses = {};
56523
56600
  accumulator.reset();
56524
56601
  pendingEscalated.clear();
@@ -56542,6 +56619,7 @@ function createChatStreamReducer(options = {}) {
56542
56619
  streamingPhase = "idle";
56543
56620
  dialogTokenUsage = null;
56544
56621
  liveModel = null;
56622
+ guideConversationId = null;
56545
56623
  accumulator.reset();
56546
56624
  pendingEscalated.clear();
56547
56625
  isInStream = false;
@@ -57237,13 +57315,13 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
57237
57315
  const { hidden, attachments, commandOverride, approvalAction } = sendOptions ?? {};
57238
57316
  const conversationId = conversationIdRef.current;
57239
57317
  const targetPath = approvalAction ? endpointsRef.current.approvalToolUrl : endpointsRef.current.chatStreamUrl;
57240
- const requestBody = approvalAction ? {
57241
- proposal_id: approvalAction.proposalId,
57242
- action: approvalAction.action,
57243
- // Always present here an approval can only happen inside an
57318
+ const requestBody = approvalAction ? (
57319
+ // Shared with every other transport that resolves a hub proposal —
57320
+ // the body shape is the hub's, not this adapter's. `conversationId`
57321
+ // is always present here: an approval can only happen inside an
57244
57322
  // established conversation (the proposal turn captured the id).
57245
- conversationId
57246
- } : {
57323
+ buildConfirmToolBody({ ...approvalAction, conversationId })
57324
+ ) : {
57247
57325
  messages: [{ role: "user", content: text }],
57248
57326
  ...commandOverride ? { commandOverride } : {},
57249
57327
  ...attachments && attachments.length > 0 ? { pendingAttachments: attachments } : {},
@@ -57261,14 +57339,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
57261
57339
  signal: ctrl.signal
57262
57340
  });
57263
57341
  if (!response.ok) {
57264
- let serverMessage = null;
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
- }
57342
+ const serverMessage = await readServerErrorMessage(response);
57272
57343
  throw new Error(serverMessage ?? `Chat request failed: ${response.status}`);
57273
57344
  }
57274
57345
  const reader = response.body?.getReader();
@@ -57507,6 +57578,37 @@ function normalizeAskOptions(raw) {
57507
57578
  description: typeof item.description === "string" ? item.description : void 0
57508
57579
  })).filter((option) => option.label.length > 0);
57509
57580
  }
57581
+ var AGENT_OWNED_EVENTS = /* @__PURE__ */ new Set([
57582
+ "usage",
57583
+ "token-usage",
57584
+ "status",
57585
+ "compaction",
57586
+ "participant",
57587
+ "dialog-closed"
57588
+ ]);
57589
+ var ORIGIN_BEARING_EVENTS = /* @__PURE__ */ new Set([
57590
+ "approval-request",
57591
+ "approval-resolved"
57592
+ ]);
57593
+ function guideEventForNats(event) {
57594
+ switch (event.type) {
57595
+ case "text-delta":
57596
+ return { type: "guide-delta", text: event.text };
57597
+ case "thinking-delta":
57598
+ return { type: "thinking-delta", text: escapeThinkingTags(event.text) };
57599
+ case "metadata":
57600
+ return typeof event.conversationId === "string" && event.conversationId ? { type: "metadata", conversationId: event.conversationId, origin: GUIDE_ORIGIN } : null;
57601
+ default:
57602
+ if (AGENT_OWNED_EVENTS.has(event.type)) return null;
57603
+ return ORIGIN_BEARING_EVENTS.has(event.type) ? { ...event, origin: GUIDE_ORIGIN } : event;
57604
+ }
57605
+ }
57606
+ function guideFrameEvent(frame) {
57607
+ const events = [];
57608
+ mapLeadingFrame(frame, events);
57609
+ const event = events[0];
57610
+ return event ? guideEventForNats(event) : null;
57611
+ }
57510
57612
  function decodeNatsChunk(chunk) {
57511
57613
  if (!chunk || typeof chunk !== "object") return null;
57512
57614
  const data = chunk;
@@ -57541,11 +57643,20 @@ function decodeNatsChunk(chunk) {
57541
57643
  return { type: "thinking-delta", text: data.text, ...seq };
57542
57644
  }
57543
57645
  return null;
57544
- case MESSAGE_TYPE.GUIDE:
57646
+ // Two shapes share this chunk type. `text` is the answer body the agent
57647
+ // streams (and persists). `payload` is a Product Guide frame re-streamed
57648
+ // verbatim from the hub — decoded through the shared frame table, with the
57649
+ // narrowing `guideFrameEvent` documents.
57650
+ case MESSAGE_TYPE.GUIDE: {
57545
57651
  if (typeof data.text === "string") {
57546
57652
  return { type: "guide-delta", text: data.text, ...seq };
57547
57653
  }
57548
- return null;
57654
+ const frame = data.payload;
57655
+ if (!frame || typeof frame !== "object" || Array.isArray(frame)) return null;
57656
+ const event = guideFrameEvent(frame);
57657
+ if (!event) return null;
57658
+ return { ...event, ...seq };
57659
+ }
57549
57660
  // An ask card is only an ask card with something to pick: a question and at
57550
57661
  // least one option. Anything less is dropped rather than rendered as an
57551
57662
  // empty card the user can't answer — the backend already falls back to a
@@ -57764,11 +57875,21 @@ function decodeHistoricalMessageData(data) {
57764
57875
  return { type: "thinking-delta", text: data.text };
57765
57876
  }
57766
57877
  return null;
57767
- case MESSAGE_TYPE.GUIDE:
57878
+ // Two persisted shapes, mirroring the live `GUIDE` chunk: the answer body
57879
+ // (`text`) and a Product Guide frame the agent re-streamed (`payload`,
57880
+ // persisted so a card survives a reload). Decoded through the SAME
57881
+ // `guideFrameEvent` the live path uses — a second mapping here would let
57882
+ // history and realtime disagree about the same bytes.
57883
+ case MESSAGE_TYPE.GUIDE: {
57768
57884
  if ("text" in data && data.text) {
57769
57885
  return { type: "guide-delta", text: data.text };
57770
57886
  }
57887
+ const payload = "payload" in data ? data.payload : void 0;
57888
+ if (payload && typeof payload === "object" && !Array.isArray(payload)) {
57889
+ return guideFrameEvent(payload);
57890
+ }
57771
57891
  return null;
57892
+ }
57772
57893
  // Same completeness gate as the live decoder (`decodeNatsChunk`): a
57773
57894
  // persisted row without a question or without options is not a card the
57774
57895
  // user can answer, so it replays as nothing rather than as empty chrome.
@@ -57946,11 +58067,20 @@ function applyHistoryEvent(event, accumulator, approvalStatuses, options, escala
57946
58067
  const approvalType = event.approvalType || "CLIENT";
57947
58068
  const toolCalls = event.toolCalls;
57948
58069
  const isBatch = !!toolCalls && toolCalls.length > 0;
57949
- if (!displayApprovalTypes || displayApprovalTypes.includes(approvalType)) {
58070
+ const guideOrigin = guideApprovalOrigin(event);
58071
+ if (approvalDisplaysInline(event, approvalType, displayApprovalTypes)) {
57950
58072
  if (isBatch) {
57951
58073
  const status = approvalStatuses[event.requestId] || "pending";
57952
58074
  if (batchApprovalsEnabled) {
57953
- accumulator.addApprovalBatch(event.requestId, approvalType, toolCalls, status);
58075
+ accumulator.addApprovalBatch(
58076
+ event.requestId,
58077
+ approvalType,
58078
+ toolCalls,
58079
+ status,
58080
+ void 0,
58081
+ void 0,
58082
+ guideOrigin
58083
+ );
57954
58084
  } else {
57955
58085
  for (const call of toolCalls) {
57956
58086
  if (!call.requiresApproval) continue;
@@ -57959,25 +58089,31 @@ function applyHistoryEvent(event, accumulator, approvalStatuses, options, escala
57959
58089
  getCommandText(call),
57960
58090
  call.toolExplanation,
57961
58091
  approvalType,
57962
- status
58092
+ status,
58093
+ void 0,
58094
+ guideOrigin
57963
58095
  );
57964
58096
  }
57965
58097
  }
57966
58098
  } else {
57967
58099
  const resolvedStatus = approvalStatuses[event.requestId];
57968
- if (resolvedStatus === "approved" || resolvedStatus === "rejected") {
58100
+ const isResolved = resolvedStatus === "approved" || resolvedStatus === "rejected";
58101
+ if (guideOrigin || isResolved) {
57969
58102
  accumulator.addApprovalRequest(
57970
58103
  event.requestId,
57971
58104
  event.command || "",
57972
58105
  event.explanation,
57973
58106
  approvalType,
57974
- resolvedStatus
58107
+ resolvedStatus ?? "pending",
58108
+ event.fields,
58109
+ guideOrigin
57975
58110
  );
57976
58111
  } else {
57977
58112
  accumulator.trackApprovalRequest(event.requestId, {
57978
58113
  command: event.command || "",
57979
58114
  explanation: event.explanation,
57980
- approvalType
58115
+ approvalType,
58116
+ fields: event.fields
57981
58117
  });
57982
58118
  }
57983
58119
  }
@@ -59923,6 +60059,7 @@ function EmbeddableChatInner({
59923
60059
  tableIdForDocumentType,
59924
60060
  modes,
59925
60061
  mingoState,
60062
+ pendingApprovals,
59926
60063
  mingoDialogCapabilities,
59927
60064
  activeMode: controlledActiveMode,
59928
60065
  onActiveModeChange,
@@ -60800,6 +60937,7 @@ function EmbeddableChatInner({
60800
60937
  {
60801
60938
  messages,
60802
60939
  isTyping: chatLoading,
60940
+ pendingApprovals,
60803
60941
  autoScroll: !previewMode,
60804
60942
  pinBottom: previewMode,
60805
60943
  overscrollContain: !previewMode,
@@ -61647,6 +61785,10 @@ export {
61647
61785
  createMessageSegmentAccumulator,
61648
61786
  SCROLL_ANCHOR_WIRE_KEY,
61649
61787
  parseScrollAnchor,
61788
+ isGuideApproval,
61789
+ guideApprovalOrigin,
61790
+ approvalDisplaysInline,
61791
+ isGuideApprovalSegment,
61650
61792
  createEmptyTurnMeta,
61651
61793
  createChatStreamReducer,
61652
61794
  DEFAULT_DIALOG_SIDE,
@@ -62125,4 +62267,4 @@ export {
62125
62267
  LogsList,
62126
62268
  assets
62127
62269
  };
62128
- //# sourceMappingURL=chunk-WINT757E.js.map
62270
+ //# sourceMappingURL=chunk-LIUARTOZ.js.map