@pluno/product-agent-web 0.1.203 → 0.1.204
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/adapters/web/errorAdapter.d.ts +2 -0
- package/dist/core/browser-execution/contracts.d.ts +16 -0
- package/dist/core/conversation/contracts.d.ts +21 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/interactions/contracts.d.ts +8 -0
- package/dist/core/kernel/capabilities.d.ts +333 -0
- package/dist/core/kernel/commands.d.ts +7 -0
- package/dist/core/kernel/effects.d.ts +37 -0
- package/dist/core/kernel/events.d.ts +9 -0
- package/dist/core/kernel/reducer.d.ts +10 -0
- package/dist/core/kernel/selectors.d.ts +3 -0
- package/dist/core/kernel/state.d.ts +46 -0
- package/dist/core/model-selection/contracts.d.ts +6 -0
- package/dist/core/ports.d.ts +14 -0
- package/dist/core/protocol/errors.d.ts +9 -0
- package/dist/core/protocol/json.d.ts +6 -0
- package/dist/product-agent-sdk.js +198 -90
- package/dist/product-agent-widget.js +2180 -2072
- package/dist/public/operationRoutes.d.ts +99 -0
- package/dist/runtime/effectRunner.d.ts +19 -0
- package/dist/runtime/engine.d.ts +33 -0
- package/package.json +6 -3
|
@@ -1248,7 +1248,7 @@ function Nt(s) {
|
|
|
1248
1248
|
};
|
|
1249
1249
|
}
|
|
1250
1250
|
const vn = globalThis.fetch.bind(globalThis), Ht = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Un = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Dn = ".pluno-pa-widget__panel", qn = ".pluno-pa-widget__timeline", On = "__plunoExtensionWidgetOwner";
|
|
1251
|
-
class
|
|
1251
|
+
class X extends Error {
|
|
1252
1252
|
constructor(e, t, n, i) {
|
|
1253
1253
|
super(e), this.retryable = t, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
|
|
1254
1254
|
}
|
|
@@ -1348,7 +1348,7 @@ class Se extends Error {
|
|
|
1348
1348
|
function Nn(s) {
|
|
1349
1349
|
return s === 408 || s === 425 || s === 429 || s >= 500;
|
|
1350
1350
|
}
|
|
1351
|
-
const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4,
|
|
1351
|
+
const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
|
|
1352
1352
|
".jpeg:image/jpeg",
|
|
1353
1353
|
".jpg:image/jpeg",
|
|
1354
1354
|
".pdf:application/pdf",
|
|
@@ -1377,7 +1377,7 @@ function hi(s) {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
1379
1379
|
function pi(s) {
|
|
1380
|
-
if (s instanceof
|
|
1380
|
+
if (s instanceof X)
|
|
1381
1381
|
return s.retryable;
|
|
1382
1382
|
if (s && typeof s == "object") {
|
|
1383
1383
|
const e = s.status;
|
|
@@ -1466,7 +1466,7 @@ class Le {
|
|
|
1466
1466
|
taskStatus: null,
|
|
1467
1467
|
isRetrying: !1,
|
|
1468
1468
|
lastError: null
|
|
1469
|
-
}, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents =
|
|
1469
|
+
}, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = $r(
|
|
1470
1470
|
Hr(e.clientId),
|
|
1471
1471
|
Br(e.clientId)
|
|
1472
1472
|
);
|
|
@@ -1533,6 +1533,16 @@ class Le {
|
|
|
1533
1533
|
retryAttemptsByClientMessageId = {};
|
|
1534
1534
|
retryTimersByClientMessageId = {};
|
|
1535
1535
|
reportedHealthSignalKeys = /* @__PURE__ */ new Set();
|
|
1536
|
+
/** @internal */
|
|
1537
|
+
transportDiagnosticEpisodes = /* @__PURE__ */ new Map();
|
|
1538
|
+
/** @internal */
|
|
1539
|
+
pendingTransportDiagnostics = [];
|
|
1540
|
+
/** @internal */
|
|
1541
|
+
pendingHealthDiagnostics = [];
|
|
1542
|
+
/** @internal */
|
|
1543
|
+
clientDiagnosticsFlush = null;
|
|
1544
|
+
/** @internal */
|
|
1545
|
+
clientDiagnosticsRetryTimer = null;
|
|
1536
1546
|
clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
|
|
1537
1547
|
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
1538
1548
|
backgroundClientMessageIds = /* @__PURE__ */ new Set();
|
|
@@ -1657,7 +1667,7 @@ class Le {
|
|
|
1657
1667
|
return this.options.token;
|
|
1658
1668
|
if (!this.options.tokenProvider)
|
|
1659
1669
|
return this.token;
|
|
1660
|
-
const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs -
|
|
1670
|
+
const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - $n > n;
|
|
1661
1671
|
if (!t.forceRefresh && (i || t.preferCached && this.token !== null))
|
|
1662
1672
|
return this.token;
|
|
1663
1673
|
if (this.tokenRequest && !t.forceRefresh)
|
|
@@ -1669,8 +1679,8 @@ class Le {
|
|
|
1669
1679
|
let a = null;
|
|
1670
1680
|
const l = new Promise((c, u) => {
|
|
1671
1681
|
a = window.setTimeout(() => {
|
|
1672
|
-
r.abort(), u(new
|
|
1673
|
-
},
|
|
1682
|
+
r.abort(), u(new X("Pluno token provider timed out", !0));
|
|
1683
|
+
}, Fn);
|
|
1674
1684
|
});
|
|
1675
1685
|
try {
|
|
1676
1686
|
const c = await Promise.race([
|
|
@@ -1678,9 +1688,9 @@ class Le {
|
|
|
1678
1688
|
l
|
|
1679
1689
|
]);
|
|
1680
1690
|
if (r.signal.aborted || this.tokenAbortController !== r)
|
|
1681
|
-
throw new
|
|
1691
|
+
throw new X("Pluno token request was cancelled", !0);
|
|
1682
1692
|
if (!c)
|
|
1683
|
-
throw new
|
|
1693
|
+
throw new X("Pluno token provider did not return a token", !1);
|
|
1684
1694
|
return this.token = c, this.tokenExpiresAtMs = hi(c), c;
|
|
1685
1695
|
} finally {
|
|
1686
1696
|
a !== null && window.clearTimeout(a);
|
|
@@ -1705,10 +1715,10 @@ class Le {
|
|
|
1705
1715
|
if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
1706
1716
|
return;
|
|
1707
1717
|
if (!this.token && !this.options.webSocketFactory)
|
|
1708
|
-
throw new
|
|
1718
|
+
throw new X("Pluno requires a token or tokenProvider", !1);
|
|
1709
1719
|
const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
1710
1720
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
1711
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
1721
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
|
|
1712
1722
|
}, jn), n.addEventListener("open", () => {
|
|
1713
1723
|
this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
|
|
1714
1724
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
@@ -1720,7 +1730,7 @@ class Le {
|
|
|
1720
1730
|
transportId: this.transportIdentity.transportId,
|
|
1721
1731
|
pageUrl: location.href
|
|
1722
1732
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
1723
|
-
this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
1733
|
+
this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
|
|
1724
1734
|
}, zn));
|
|
1725
1735
|
}), n.addEventListener("message", (i) => {
|
|
1726
1736
|
this.socket === n && this.handleServerEvent(zi(i.data));
|
|
@@ -1738,12 +1748,15 @@ class Le {
|
|
|
1738
1748
|
wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
|
|
1739
1749
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1740
1750
|
isThinking: this.state.isThinking
|
|
1751
|
+
}), (typeof i?.code != "number" || i.code !== 1e3) && this.reportTransportDiagnostic("socket_closed", {
|
|
1752
|
+
closeCode: typeof i?.code == "number" ? i.code : void 0,
|
|
1753
|
+
wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : void 0
|
|
1741
1754
|
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
1742
1755
|
}), n.addEventListener("error", () => {
|
|
1743
1756
|
this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
1744
1757
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1745
1758
|
isThinking: this.state.isThinking
|
|
1746
|
-
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
1759
|
+
}), this.reportTransportDiagnostic("socket_error"), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
1747
1760
|
});
|
|
1748
1761
|
} catch (t) {
|
|
1749
1762
|
if (e !== this.connectionAttemptId || this.state.status === "closed")
|
|
@@ -1753,12 +1766,12 @@ class Le {
|
|
|
1753
1766
|
b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
|
|
1754
1767
|
message: n.message,
|
|
1755
1768
|
reconnectAttempt: this.reconnectAttempts
|
|
1756
|
-
}), this.setState({
|
|
1769
|
+
}), t instanceof X && this.reportTransportDiagnostic("auth_timeout"), this.setState({
|
|
1757
1770
|
status: "reconnecting",
|
|
1758
1771
|
lastError: Zn,
|
|
1759
1772
|
lastErrorCode: "connection_failed"
|
|
1760
1773
|
}), this.emit("error", n), this.scheduleReconnect(
|
|
1761
|
-
t instanceof
|
|
1774
|
+
t instanceof X ? t.retryAfterMs : void 0
|
|
1762
1775
|
);
|
|
1763
1776
|
return;
|
|
1764
1777
|
}
|
|
@@ -1772,7 +1785,7 @@ class Le {
|
|
|
1772
1785
|
}
|
|
1773
1786
|
}
|
|
1774
1787
|
disconnect() {
|
|
1775
|
-
this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
1788
|
+
this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
1776
1789
|
}
|
|
1777
1790
|
destroy() {
|
|
1778
1791
|
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
@@ -2585,36 +2598,131 @@ class Le {
|
|
|
2585
2598
|
}
|
|
2586
2599
|
}
|
|
2587
2600
|
reportHealthSignal(e, t = {}) {
|
|
2588
|
-
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
2589
|
-
return;
|
|
2590
2601
|
const n = t.clientMessageId ?? this.activeResponseRunId;
|
|
2591
2602
|
if (n) {
|
|
2592
|
-
const
|
|
2593
|
-
if (this.reportedHealthSignalKeys.has(
|
|
2603
|
+
const r = `${e}:${n}`;
|
|
2604
|
+
if (this.reportedHealthSignalKeys.has(r))
|
|
2594
2605
|
return;
|
|
2595
|
-
this.reportedHealthSignalKeys.add(
|
|
2606
|
+
this.reportedHealthSignalKeys.add(r);
|
|
2607
|
+
}
|
|
2608
|
+
const i = {
|
|
2609
|
+
id: crypto.randomUUID(),
|
|
2610
|
+
name: e,
|
|
2611
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2612
|
+
source: "web_sdk",
|
|
2613
|
+
entrySurface: this.options.entrySurface,
|
|
2614
|
+
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
2615
|
+
...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
|
|
2616
|
+
...t
|
|
2617
|
+
};
|
|
2618
|
+
if (this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
2619
|
+
this.queueHealthDiagnostic(i);
|
|
2620
|
+
return;
|
|
2596
2621
|
}
|
|
2597
2622
|
try {
|
|
2598
2623
|
this.socket.send(JSON.stringify({
|
|
2599
2624
|
type: "runtime.health",
|
|
2600
|
-
signal:
|
|
2601
|
-
id: crypto.randomUUID(),
|
|
2602
|
-
name: e,
|
|
2603
|
-
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2604
|
-
source: "web_sdk",
|
|
2605
|
-
entrySurface: this.options.entrySurface,
|
|
2606
|
-
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
2607
|
-
...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
|
|
2608
|
-
...t
|
|
2609
|
-
}
|
|
2625
|
+
signal: i
|
|
2610
2626
|
}));
|
|
2611
|
-
} catch (
|
|
2627
|
+
} catch (r) {
|
|
2612
2628
|
b("web-sdk.agent", "Pluno health signal send failed", {
|
|
2613
2629
|
name: e,
|
|
2614
|
-
message:
|
|
2630
|
+
message: r instanceof Error ? r.message : String(r)
|
|
2631
|
+
}), this.queueHealthDiagnostic(i);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
/** @internal */
|
|
2635
|
+
reportTransportDiagnostic(e, t = {}) {
|
|
2636
|
+
const n = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", i = `${e}:${t.closeCode ?? "none"}:${n}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(i), a = {
|
|
2637
|
+
id: o?.id ?? crypto.randomUUID(),
|
|
2638
|
+
phase: e,
|
|
2639
|
+
entrySurface: this.options.entrySurface,
|
|
2640
|
+
firstOccurredAt: o?.firstOccurredAt ?? r,
|
|
2641
|
+
lastOccurredAt: r,
|
|
2642
|
+
occurrenceCount: (o?.occurrenceCount ?? 0) + 1,
|
|
2643
|
+
maxReconnectAttempt: Math.max(o?.maxReconnectAttempt ?? 0, this.reconnectAttempts),
|
|
2644
|
+
connectivity: n,
|
|
2645
|
+
...t
|
|
2646
|
+
};
|
|
2647
|
+
this.transportDiagnosticEpisodes.set(i, a), [1, 3, 10, 30, 100].includes(a.occurrenceCount) && (this.pendingTransportDiagnostics = [
|
|
2648
|
+
...this.pendingTransportDiagnostics.filter((l) => l.id !== a.id),
|
|
2649
|
+
a
|
|
2650
|
+
], this.pendingTransportDiagnostics.splice(0, Math.max(0, this.pendingTransportDiagnostics.length - 20)), this.flushClientDiagnostics());
|
|
2651
|
+
}
|
|
2652
|
+
/** @internal */
|
|
2653
|
+
queueHealthDiagnostic(e) {
|
|
2654
|
+
this.pendingHealthDiagnostics.push(e), this.pendingHealthDiagnostics.splice(0, Math.max(0, this.pendingHealthDiagnostics.length - 20)), this.flushClientDiagnostics();
|
|
2655
|
+
}
|
|
2656
|
+
/** @internal */
|
|
2657
|
+
async flushClientDiagnostics() {
|
|
2658
|
+
if (this.clientDiagnosticsFlush)
|
|
2659
|
+
return await this.clientDiagnosticsFlush;
|
|
2660
|
+
if (this.clientDiagnosticsRetryTimer !== null || this.pendingTransportDiagnostics.length === 0 && this.pendingHealthDiagnostics.length === 0)
|
|
2661
|
+
return;
|
|
2662
|
+
const e = this.performClientDiagnosticsFlush();
|
|
2663
|
+
this.clientDiagnosticsFlush = e;
|
|
2664
|
+
try {
|
|
2665
|
+
await e;
|
|
2666
|
+
} finally {
|
|
2667
|
+
this.clientDiagnosticsFlush === e && (this.clientDiagnosticsFlush = null), this.clientDiagnosticsRetryTimer === null && (this.pendingTransportDiagnostics.length > 0 || this.pendingHealthDiagnostics.length > 0) && this.flushClientDiagnostics();
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
/** @internal */
|
|
2671
|
+
async performClientDiagnosticsFlush() {
|
|
2672
|
+
const e = this.token ?? this.options.token ?? null;
|
|
2673
|
+
if (!e) {
|
|
2674
|
+
if (!this.options.tokenProvider) {
|
|
2675
|
+
this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [];
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
this.scheduleClientDiagnosticsRetry();
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
const t = this.pendingTransportDiagnostics.slice(0, 20), n = this.pendingHealthDiagnostics.slice(0, 20), i = this.options.productVariant === "customer_embedded" ? "/api/product-agent/embed/diagnostics" : "/api/product-agent/runtime/diagnostics";
|
|
2682
|
+
try {
|
|
2683
|
+
const r = await fetch(new URL(i, this.options.backendUrl), {
|
|
2684
|
+
method: "POST",
|
|
2685
|
+
headers: {
|
|
2686
|
+
"content-type": "application/json",
|
|
2687
|
+
authorization: this.options.productVariant === "customer_embedded" ? `Bearer ${e}` : e
|
|
2688
|
+
},
|
|
2689
|
+
body: JSON.stringify({
|
|
2690
|
+
clientId: this.options.clientId,
|
|
2691
|
+
transportId: this.transportIdentity.transportId,
|
|
2692
|
+
transportEpisodes: t,
|
|
2693
|
+
healthSignals: n
|
|
2694
|
+
}),
|
|
2695
|
+
signal: AbortSignal.timeout(1e4)
|
|
2615
2696
|
});
|
|
2697
|
+
if (r.status === 401 || r.status === 403) {
|
|
2698
|
+
const l = new Set(t.map((u) => u.id)), c = new Set(n.map((u) => u.id));
|
|
2699
|
+
this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
|
|
2700
|
+
(u) => !l.has(u.id)
|
|
2701
|
+
), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
|
|
2702
|
+
(u) => !c.has(u.id)
|
|
2703
|
+
);
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
if (!r.ok)
|
|
2707
|
+
throw new Error(`Client diagnostic upload failed (${r.status})`);
|
|
2708
|
+
const o = new Map(
|
|
2709
|
+
t.map((l) => [l.id, l.occurrenceCount])
|
|
2710
|
+
), a = new Set(n.map((l) => l.id));
|
|
2711
|
+
this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
|
|
2712
|
+
(l) => !o.has(l.id) || l.occurrenceCount > (o.get(l.id) ?? 0)
|
|
2713
|
+
), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
|
|
2714
|
+
(l) => !a.has(l.id)
|
|
2715
|
+
);
|
|
2716
|
+
} catch {
|
|
2717
|
+
this.scheduleClientDiagnosticsRetry();
|
|
2616
2718
|
}
|
|
2617
2719
|
}
|
|
2720
|
+
/** @internal */
|
|
2721
|
+
scheduleClientDiagnosticsRetry() {
|
|
2722
|
+
this.clientDiagnosticsRetryTimer !== null || this.state.status === "closed" || (this.clientDiagnosticsRetryTimer = window.setTimeout(() => {
|
|
2723
|
+
this.clientDiagnosticsRetryTimer = null, this.flushClientDiagnostics();
|
|
2724
|
+
}, 3e4));
|
|
2725
|
+
}
|
|
2618
2726
|
requestTransientStarterPrompts() {
|
|
2619
2727
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
2620
2728
|
return;
|
|
@@ -2836,7 +2944,7 @@ class Le {
|
|
|
2836
2944
|
return;
|
|
2837
2945
|
}
|
|
2838
2946
|
if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
2839
|
-
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
2947
|
+
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear();
|
|
2840
2948
|
const t = Zi(e.user);
|
|
2841
2949
|
this.authenticatedSocket !== this.socket && this.authenticatedUserId && t && t.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = t?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
2842
2950
|
const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
@@ -2910,16 +3018,16 @@ class Le {
|
|
|
2910
3018
|
}), S = lt(
|
|
2911
3019
|
this.state.messages,
|
|
2912
3020
|
st(D, this.options.backendUrl)
|
|
2913
|
-
), T = ss(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId,
|
|
3021
|
+
), T = ss(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, Y = M ? m?.runId ?? null : this.state.assistantDraftRunId, Z = g.some(
|
|
2914
3022
|
(U, q) => ns(
|
|
2915
3023
|
C(U),
|
|
2916
3024
|
N,
|
|
2917
3025
|
v,
|
|
2918
3026
|
re,
|
|
2919
|
-
|
|
3027
|
+
Y,
|
|
2920
3028
|
wr(g, q)
|
|
2921
3029
|
)
|
|
2922
|
-
),
|
|
3030
|
+
), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
|
|
2923
3031
|
if (!T && Sr(this.state.messages, g))
|
|
2924
3032
|
return;
|
|
2925
3033
|
this.lastUserMessagePageUrl = yr(g);
|
|
@@ -2938,7 +3046,7 @@ class Le {
|
|
|
2938
3046
|
isRetrying: p,
|
|
2939
3047
|
...y ? { taskStatus: "working" } : {},
|
|
2940
3048
|
...oe && this.state.taskStatus === "working" ? { taskStatus: oe } : {},
|
|
2941
|
-
...
|
|
3049
|
+
...Z ? {
|
|
2942
3050
|
assistantDraft: "",
|
|
2943
3051
|
assistantDraftItemId: null,
|
|
2944
3052
|
assistantDraftPhase: null,
|
|
@@ -3038,7 +3146,7 @@ class Le {
|
|
|
3038
3146
|
const n = ve(e.item, this.options.backendUrl);
|
|
3039
3147
|
if (n) {
|
|
3040
3148
|
const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
3041
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
3149
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
|
|
3042
3150
|
const o = de(this.state.messages, n), a = ss(o), l = ns(
|
|
3043
3151
|
t,
|
|
3044
3152
|
this.state.assistantDraft,
|
|
@@ -3049,7 +3157,7 @@ class Le {
|
|
|
3049
3157
|
o,
|
|
3050
3158
|
o.findIndex((d) => d.id === n.id)
|
|
3051
3159
|
)
|
|
3052
|
-
), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c ||
|
|
3160
|
+
), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c || F(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
3053
3161
|
this.setState({
|
|
3054
3162
|
messages: o,
|
|
3055
3163
|
...l ? {
|
|
@@ -3543,7 +3651,7 @@ class Le {
|
|
|
3543
3651
|
schedulePendingDeliveryAck(e) {
|
|
3544
3652
|
this.clearPendingDeliveryTimers(), !et() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
3545
3653
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
3546
|
-
},
|
|
3654
|
+
}, $t));
|
|
3547
3655
|
}
|
|
3548
3656
|
retryPendingDelivery(e) {
|
|
3549
3657
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
@@ -3605,13 +3713,13 @@ class Le {
|
|
|
3605
3713
|
scheduleRunAckWatchdog(e) {
|
|
3606
3714
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
3607
3715
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
3608
|
-
},
|
|
3716
|
+
}, $t);
|
|
3609
3717
|
}
|
|
3610
3718
|
recoverMissedRunAck(e) {
|
|
3611
3719
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
3612
3720
|
sessionId: this.state.sessionId,
|
|
3613
3721
|
clientMessageId: e
|
|
3614
|
-
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
3722
|
+
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft));
|
|
3615
3723
|
}
|
|
3616
3724
|
clearRunAckResyncRetryTimer() {
|
|
3617
3725
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -3644,7 +3752,7 @@ class Le {
|
|
|
3644
3752
|
sessionId: this.state.sessionId,
|
|
3645
3753
|
clientMessageId: e,
|
|
3646
3754
|
resyncAttempts: t + 1
|
|
3647
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
3755
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft);
|
|
3648
3756
|
}
|
|
3649
3757
|
resyncThinkingSession() {
|
|
3650
3758
|
this.state.sessionId ? this.send({
|
|
@@ -4492,7 +4600,7 @@ function Wi(s, e) {
|
|
|
4492
4600
|
"data-test",
|
|
4493
4601
|
"data-qa",
|
|
4494
4602
|
"data-cy"
|
|
4495
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } =
|
|
4603
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = Fi(), g = new Set(s);
|
|
4496
4604
|
e && g.add(e);
|
|
4497
4605
|
let f = 0;
|
|
4498
4606
|
const h = (w) => {
|
|
@@ -4503,11 +4611,11 @@ function Wi(s, e) {
|
|
|
4503
4611
|
return `${w.tagName.toLowerCase()}|${h(w)}|${D}`;
|
|
4504
4612
|
}, y = (w, D, H) => {
|
|
4505
4613
|
const S = (T, N) => {
|
|
4506
|
-
const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T),
|
|
4507
|
-
if (f >= 1e3 && !
|
|
4614
|
+
const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T), Y = u.has(T);
|
|
4615
|
+
if (f >= 1e3 && !Y || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || re.display === "none" || re.visibility === "hidden")
|
|
4508
4616
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
4509
4617
|
f += 1;
|
|
4510
|
-
const
|
|
4618
|
+
const Z = h(T), ee = Rs(T), fe = a.has(Z) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(v) || v === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), Q = /* @__PURE__ */ new Map();
|
|
4511
4619
|
for (const I of B) {
|
|
4512
4620
|
const R = p(I);
|
|
4513
4621
|
Q.set(R, (Q.get(R) ?? 0) + 1);
|
|
@@ -4531,25 +4639,25 @@ function Wi(s, e) {
|
|
|
4531
4639
|
if (T.shadowRoot)
|
|
4532
4640
|
for (const I of Array.from(T.shadowRoot.children))
|
|
4533
4641
|
I instanceof HTMLElement && Be.push(S(I, N + 1));
|
|
4534
|
-
const ye = [...kt, ...Be], We =
|
|
4535
|
-
[
|
|
4536
|
-
).slice(0, 180), js = T.hasAttribute("contenteditable") && (
|
|
4537
|
-
if (
|
|
4538
|
-
const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et :
|
|
4642
|
+
const ye = [...kt, ...Be], We = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
|
|
4643
|
+
[ee, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
4644
|
+
).slice(0, 180), js = T.hasAttribute("contenteditable") && (ee.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Z || js, Fe = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || Y) && (We || Y) && (!i.has(v) || We || Ct || Y), $e = Fe ? 1 : 0, ae = [];
|
|
4645
|
+
if (Fe) {
|
|
4646
|
+
const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et : ee;
|
|
4539
4647
|
ae.push(bs(T, l, o, R.slice(0, 180)));
|
|
4540
4648
|
}
|
|
4541
4649
|
for (const I of q)
|
|
4542
|
-
ae.push(...we(I,
|
|
4650
|
+
ae.push(...we(I, $e));
|
|
4543
4651
|
const je = Be.flatMap((I) => I.lines);
|
|
4544
4652
|
if (je.length > 0) {
|
|
4545
4653
|
const I = je.slice(0, 20);
|
|
4546
4654
|
je.length > I.length && I.push("… shadow DOM omitted");
|
|
4547
4655
|
const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
|
|
4548
4656
|
if (N < 2 && !R) {
|
|
4549
|
-
const z =
|
|
4550
|
-
ae.push(...we([z, ...we(I, 1)],
|
|
4657
|
+
const z = Fe ? "#shadow-root" : `${v} #shadow-root`;
|
|
4658
|
+
ae.push(...we([z, ...we(I, 1)], $e));
|
|
4551
4659
|
} else
|
|
4552
|
-
ae.push(...we(I,
|
|
4660
|
+
ae.push(...we(I, $e));
|
|
4553
4661
|
}
|
|
4554
4662
|
return {
|
|
4555
4663
|
lines: ae,
|
|
@@ -4562,7 +4670,7 @@ function Wi(s, e) {
|
|
|
4562
4670
|
`);
|
|
4563
4671
|
}, m = [], M = ne(window.getSelection()?.toString() ?? "");
|
|
4564
4672
|
M && m.push(`--- selected text ---
|
|
4565
|
-
${JSON.stringify(M)}`), d.length > 0 && m.push(
|
|
4673
|
+
${JSON.stringify(M)}`), d.length > 0 && m.push($i(d, t, l, o));
|
|
4566
4674
|
for (const w of s.slice(0, 3))
|
|
4567
4675
|
m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
4568
4676
|
if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -4590,7 +4698,7 @@ function bs(s, e, t, n) {
|
|
|
4590
4698
|
s.hasAttribute(a) && (r += `[${a}]`);
|
|
4591
4699
|
return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
4592
4700
|
}
|
|
4593
|
-
function
|
|
4701
|
+
function Fi() {
|
|
4594
4702
|
const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
|
|
4595
4703
|
if (!a)
|
|
4596
4704
|
return;
|
|
@@ -4633,7 +4741,7 @@ function $i() {
|
|
|
4633
4741
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
4634
4742
|
};
|
|
4635
4743
|
}
|
|
4636
|
-
function
|
|
4744
|
+
function $i(s, e, t, n) {
|
|
4637
4745
|
const i = ["--- active/current elements ---"];
|
|
4638
4746
|
for (const r of s) {
|
|
4639
4747
|
const o = [];
|
|
@@ -5227,7 +5335,7 @@ function dr(s, e) {
|
|
|
5227
5335
|
return i;
|
|
5228
5336
|
}
|
|
5229
5337
|
function ct(s) {
|
|
5230
|
-
const e =
|
|
5338
|
+
const e = J(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
|
|
5231
5339
|
// Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
|
|
5232
5340
|
// from substituting the call for its output and then appending a duplicate output at the end of the timeline.
|
|
5233
5341
|
...s.callId ? [`${n ? "call-output" : "call"}:${s.callId}`] : [],
|
|
@@ -5257,7 +5365,7 @@ function Es(s, e) {
|
|
|
5257
5365
|
const n = e.attachments.map((o) => {
|
|
5258
5366
|
const a = hr(t.attachments ?? [], o);
|
|
5259
5367
|
return a ? pr(o, a) : o;
|
|
5260
|
-
}), i = { ...e, attachments: n }, r =
|
|
5368
|
+
}), i = { ...e, attachments: n }, r = J(e);
|
|
5261
5369
|
return r && Object.defineProperty(i, "clientMessageId", {
|
|
5262
5370
|
value: r,
|
|
5263
5371
|
enumerable: !1
|
|
@@ -5282,13 +5390,13 @@ function gr(s, e) {
|
|
|
5282
5390
|
return n.splice(t, 1), n;
|
|
5283
5391
|
}
|
|
5284
5392
|
function Cs(s, e) {
|
|
5285
|
-
const t =
|
|
5393
|
+
const t = J(s), n = J(e);
|
|
5286
5394
|
return t && n ? t === n : s.content === e.content;
|
|
5287
5395
|
}
|
|
5288
5396
|
function Ne(s) {
|
|
5289
5397
|
return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
|
|
5290
5398
|
}
|
|
5291
|
-
function
|
|
5399
|
+
function J(s) {
|
|
5292
5400
|
const e = s.clientMessageId;
|
|
5293
5401
|
if (e)
|
|
5294
5402
|
return e;
|
|
@@ -5309,7 +5417,7 @@ function ss(s) {
|
|
|
5309
5417
|
for (let i = s.length - 1; i > e; i -= 1) {
|
|
5310
5418
|
const r = s[i];
|
|
5311
5419
|
if (!r.respondsToUserMessageId) {
|
|
5312
|
-
if (
|
|
5420
|
+
if (F(r))
|
|
5313
5421
|
return !0;
|
|
5314
5422
|
if (r.role === "system") {
|
|
5315
5423
|
if (r.dataType === "run_error")
|
|
@@ -5324,7 +5432,7 @@ function ss(s) {
|
|
|
5324
5432
|
function fr(s, e, t) {
|
|
5325
5433
|
const n = new Set(
|
|
5326
5434
|
s.filter(
|
|
5327
|
-
(i) => i.role === "user" && e !== null &&
|
|
5435
|
+
(i) => i.role === "user" && e !== null && J(i) === e
|
|
5328
5436
|
).map((i) => i.id)
|
|
5329
5437
|
);
|
|
5330
5438
|
return s.some((i, r) => {
|
|
@@ -5344,11 +5452,11 @@ function fr(s, e, t) {
|
|
|
5344
5452
|
function mr(s) {
|
|
5345
5453
|
const e = Ps(s);
|
|
5346
5454
|
if (e === null)
|
|
5347
|
-
return s.some(
|
|
5455
|
+
return s.some(F);
|
|
5348
5456
|
const t = s[e].id;
|
|
5349
5457
|
return s.some((n) => n.respondsToUserMessageId === t) ? s.some(
|
|
5350
|
-
(n) => n.respondsToUserMessageId === t &&
|
|
5351
|
-
) : s.slice(e + 1).some(
|
|
5458
|
+
(n) => n.respondsToUserMessageId === t && F(n)
|
|
5459
|
+
) : s.slice(e + 1).some(F);
|
|
5352
5460
|
}
|
|
5353
5461
|
function Ps(s) {
|
|
5354
5462
|
for (let e = s.length - 1; e >= 0; e -= 1)
|
|
@@ -5357,7 +5465,7 @@ function Ps(s) {
|
|
|
5357
5465
|
return null;
|
|
5358
5466
|
}
|
|
5359
5467
|
function Ue(s) {
|
|
5360
|
-
return
|
|
5468
|
+
return F(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
|
|
5361
5469
|
}
|
|
5362
5470
|
function ie(s) {
|
|
5363
5471
|
for (let e = s.length - 1; e >= 0; e -= 1) {
|
|
@@ -5479,7 +5587,7 @@ function Ar(s) {
|
|
|
5479
5587
|
const e = s;
|
|
5480
5588
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
5481
5589
|
}
|
|
5482
|
-
function
|
|
5590
|
+
function F(s) {
|
|
5483
5591
|
return s.role === "assistant" && s.phase !== "commentary";
|
|
5484
5592
|
}
|
|
5485
5593
|
function Mr(s) {
|
|
@@ -5517,7 +5625,7 @@ function Er(s, e, t, n) {
|
|
|
5517
5625
|
(l) => l.role === "user" && l.id === o
|
|
5518
5626
|
) : null;
|
|
5519
5627
|
return {
|
|
5520
|
-
clientMessageId: a ?
|
|
5628
|
+
clientMessageId: a ? J(a) : o ? null : n,
|
|
5521
5629
|
respondsToUserMessageId: o,
|
|
5522
5630
|
runId: t ?? r?.runId ?? null
|
|
5523
5631
|
};
|
|
@@ -5526,12 +5634,12 @@ function Ce(s) {
|
|
|
5526
5634
|
return s?.type === "run_status" && s.status === "stopped";
|
|
5527
5635
|
}
|
|
5528
5636
|
function Cr(s, e) {
|
|
5529
|
-
return
|
|
5637
|
+
return F(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
|
|
5530
5638
|
}
|
|
5531
5639
|
function rs(s, e, t) {
|
|
5532
5640
|
const n = new Set(
|
|
5533
5641
|
s.filter(
|
|
5534
|
-
(i) => i.role === "user" && e !== null &&
|
|
5642
|
+
(i) => i.role === "user" && e !== null && J(i) === e
|
|
5535
5643
|
).map((i) => i.id)
|
|
5536
5644
|
);
|
|
5537
5645
|
return s.filter(
|
|
@@ -5609,7 +5717,7 @@ function as(s) {
|
|
|
5609
5717
|
}
|
|
5610
5718
|
function vr(s, e) {
|
|
5611
5719
|
return s.some(
|
|
5612
|
-
(t) => t.respondsToUserMessageId === e && (
|
|
5720
|
+
(t) => t.respondsToUserMessageId === e && (F(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
|
|
5613
5721
|
);
|
|
5614
5722
|
}
|
|
5615
5723
|
function Ur(s, e) {
|
|
@@ -5751,7 +5859,7 @@ function Br(s) {
|
|
|
5751
5859
|
if (window.sessionStorage.removeItem(e), !t)
|
|
5752
5860
|
return [];
|
|
5753
5861
|
const n = JSON.parse(t);
|
|
5754
|
-
return Array.isArray(n) ? n.flatMap((i) =>
|
|
5862
|
+
return Array.isArray(n) ? n.flatMap((i) => Fr(i) ? [{
|
|
5755
5863
|
...i.event,
|
|
5756
5864
|
page: P(),
|
|
5757
5865
|
rawOutput: {
|
|
@@ -5778,13 +5886,13 @@ function Wr(s) {
|
|
|
5778
5886
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
5779
5887
|
Current URL: ${s}`;
|
|
5780
5888
|
}
|
|
5781
|
-
function
|
|
5889
|
+
function Fr(s) {
|
|
5782
5890
|
if (!s || typeof s != "object")
|
|
5783
5891
|
return !1;
|
|
5784
5892
|
const e = s, t = e.event;
|
|
5785
5893
|
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && bt(t) && t.type === "tool.result";
|
|
5786
5894
|
}
|
|
5787
|
-
function
|
|
5895
|
+
function $r(s, e) {
|
|
5788
5896
|
const t = new Set(
|
|
5789
5897
|
s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
5790
5898
|
);
|
|
@@ -5916,7 +6024,7 @@ function xs(s) {
|
|
|
5916
6024
|
return e;
|
|
5917
6025
|
}
|
|
5918
6026
|
function Rt(s, e) {
|
|
5919
|
-
return
|
|
6027
|
+
return Fs(s) ? He : W(Oe(e), ri);
|
|
5920
6028
|
}
|
|
5921
6029
|
function Jr(s, e) {
|
|
5922
6030
|
return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
|
|
@@ -6080,7 +6188,7 @@ function ao(s) {
|
|
|
6080
6188
|
function lo(s) {
|
|
6081
6189
|
return s === 401 || s === 403;
|
|
6082
6190
|
}
|
|
6083
|
-
const He = "[REDACTED_SECRET]",
|
|
6191
|
+
const He = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
|
|
6084
6192
|
function L(s) {
|
|
6085
6193
|
return qe(s, 0, /* @__PURE__ */ new WeakSet());
|
|
6086
6194
|
}
|
|
@@ -6097,35 +6205,35 @@ function qe(s, e, t) {
|
|
|
6097
6205
|
return s.map((i) => qe(i, e + 1, t));
|
|
6098
6206
|
const n = {};
|
|
6099
6207
|
for (const [i, r] of Object.entries(s))
|
|
6100
|
-
i === "pageContent" ? n[i] = r :
|
|
6208
|
+
i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
|
|
6101
6209
|
return n;
|
|
6102
6210
|
}
|
|
6103
|
-
function
|
|
6211
|
+
function Fs(s) {
|
|
6104
6212
|
const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
6105
6213
|
return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
|
|
6106
6214
|
}
|
|
6107
6215
|
function mo(s) {
|
|
6108
|
-
return typeof s == "string" ?
|
|
6216
|
+
return typeof s == "string" ? $s(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
|
|
6109
6217
|
}
|
|
6110
|
-
function
|
|
6218
|
+
function $s(s) {
|
|
6111
6219
|
try {
|
|
6112
6220
|
const e = new URL(s, location.href);
|
|
6113
6221
|
for (const t of Array.from(e.searchParams.keys()))
|
|
6114
|
-
ho.test(t) && e.searchParams.set(t,
|
|
6115
|
-
return e.username && (e.username =
|
|
6222
|
+
ho.test(t) && e.searchParams.set(t, $);
|
|
6223
|
+
return e.username && (e.username = $), e.password && (e.password = $), e.toString();
|
|
6116
6224
|
} catch {
|
|
6117
6225
|
return yo(s);
|
|
6118
6226
|
}
|
|
6119
6227
|
}
|
|
6120
6228
|
function Oe(s) {
|
|
6121
|
-
return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${
|
|
6229
|
+
return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
|
|
6122
6230
|
}
|
|
6123
6231
|
function yo(s) {
|
|
6124
|
-
return s.replace(Ns, `Bearer ${
|
|
6232
|
+
return s.replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
|
|
6125
6233
|
}
|
|
6126
6234
|
function Io(s) {
|
|
6127
6235
|
const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
|
|
6128
|
-
return `${
|
|
6236
|
+
return `${$s(t)}${e}`;
|
|
6129
6237
|
}
|
|
6130
6238
|
const Eo = Object.freeze({
|
|
6131
6239
|
init: (s) => Le.init(s)
|
|
@@ -6146,7 +6254,7 @@ export {
|
|
|
6146
6254
|
Le as ProductAgentSessionEngine,
|
|
6147
6255
|
Mn as ProductAgentSessionHistoryManager,
|
|
6148
6256
|
Ao as ProductAgentTaskPageTitleController,
|
|
6149
|
-
|
|
6257
|
+
X as ProductAgentTokenProviderError,
|
|
6150
6258
|
di as calculateReconnectDelay,
|
|
6151
6259
|
wo as createLocalStorageInteractionDecisionStorage,
|
|
6152
6260
|
Re as createProductAgentQueryState,
|