@syntrologie/adapt-chatbot 2.8.0-canary.296 → 2.8.0-canary.297

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ChatAssistantLitMountable,
3
3
  renderFallbackHtml
4
- } from "./chunk-ES5JYJA7.js";
4
+ } from "./chunk-E2H6T7XI.js";
5
5
  import "./chunk-ZZUKH2D6.js";
6
6
  import "./chunk-VLJ3WOEX.js";
7
7
  import "./chunk-UVKRO5ER.js";
@@ -7325,6 +7325,7 @@ var AgUiTransport = class {
7325
7325
  this._pendingResume = false;
7326
7326
  this._currentAssistantMessageId = null;
7327
7327
  this._toolCallMessageIds = /* @__PURE__ */ new Map();
7328
+ this._localPendingInterrupts = /* @__PURE__ */ new Map();
7328
7329
  this._url = options.url;
7329
7330
  this._headers = options.headers ?? {};
7330
7331
  this._threadId = options.threadId;
@@ -7366,6 +7367,7 @@ var AgUiTransport = class {
7366
7367
  this._pendingResume = false;
7367
7368
  this._currentAssistantMessageId = null;
7368
7369
  this._toolCallMessageIds.clear();
7370
+ this._localPendingInterrupts.clear();
7369
7371
  }
7370
7372
  send(action) {
7371
7373
  if (!this._agent) return;
@@ -7395,9 +7397,13 @@ var AgUiTransport = class {
7395
7397
  // ---------------------------------------------------------------------------
7396
7398
  _sendUserMessage(text) {
7397
7399
  const agent = this._agent;
7398
- const pendingInterrupts = (agent.pendingInterrupts ?? []).map((i) => i).filter(
7400
+ const upstream = (agent.pendingInterrupts ?? []).map((i) => i).filter(
7399
7401
  (i) => typeof i?.id === "string" && i.id.length > 0
7400
7402
  );
7403
+ const byId = /* @__PURE__ */ new Map();
7404
+ for (const i of this._localPendingInterrupts.values()) byId.set(i.id, i);
7405
+ for (const i of upstream) byId.set(i.id, i);
7406
+ const pendingInterrupts = [...byId.values()];
7401
7407
  const cancelResume = pendingInterrupts.length > 0 ? pendingInterrupts.map((i) => {
7402
7408
  const toolCallId = i.toolCallId ?? i.tool_call_id;
7403
7409
  if (toolCallId) {
@@ -7408,6 +7414,7 @@ var AgUiTransport = class {
7408
7414
  status: "cancelled"
7409
7415
  };
7410
7416
  }) : void 0;
7417
+ if (cancelResume) this._localPendingInterrupts.clear();
7411
7418
  agent.addMessage({
7412
7419
  id: generateId(),
7413
7420
  role: "user",
@@ -7441,6 +7448,7 @@ var AgUiTransport = class {
7441
7448
  // ---------------------------------------------------------------------------
7442
7449
  _sendDeferredToolResume(action) {
7443
7450
  let entry;
7451
+ this._localPendingInterrupts.delete(action.interruptId);
7444
7452
  if (action.decision === "cancel") {
7445
7453
  entry = { interruptId: action.interruptId, status: "cancelled" };
7446
7454
  } else if (action.decision === "approve") {
@@ -7635,6 +7643,12 @@ var AgUiTransport = class {
7635
7643
  if (outcome?.type === "interrupt" && Array.isArray(outcome.interrupts)) {
7636
7644
  for (const interrupt of outcome.interrupts) {
7637
7645
  const toolCallId = interrupt.toolCallId ?? interrupt.tool_call_id;
7646
+ if (typeof interrupt.id === "string" && interrupt.id) {
7647
+ this._localPendingInterrupts.set(interrupt.id, {
7648
+ id: interrupt.id,
7649
+ toolCallId: typeof toolCallId === "string" ? toolCallId : void 0
7650
+ });
7651
+ }
7638
7652
  if (typeof toolCallId === "string" && typeof interrupt.id === "string") {
7639
7653
  this._emit({
7640
7654
  type: "tool-call-deferred",
@@ -8752,4 +8766,4 @@ fast-json-patch/module/duplex.mjs:
8752
8766
  * MIT license
8753
8767
  *)
8754
8768
  */
8755
- //# sourceMappingURL=chunk-ES5JYJA7.js.map
8769
+ //# sourceMappingURL=chunk-E2H6T7XI.js.map