@pluno/product-agent-web 0.1.221 → 0.1.223
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/backendTransport.d.ts +1 -0
- package/dist/adapters/web/socketIOTransport.d.ts +3 -1
- package/dist/core/active-users/reducer.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/product-agent-sdk.js +267 -236
- package/dist/product-agent-widget.js +1174 -1133
- package/package.json +1 -1
|
@@ -190,24 +190,24 @@ function Kn(s, e) {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
const Hi = 4;
|
|
193
|
-
function
|
|
193
|
+
function E(s) {
|
|
194
194
|
if (s) return Vn(s);
|
|
195
195
|
}
|
|
196
196
|
function Vn(s) {
|
|
197
|
-
for (var e in
|
|
198
|
-
s[e] =
|
|
197
|
+
for (var e in E.prototype)
|
|
198
|
+
s[e] = E.prototype[e];
|
|
199
199
|
return s;
|
|
200
200
|
}
|
|
201
|
-
|
|
201
|
+
E.prototype.on = E.prototype.addEventListener = function(s, e) {
|
|
202
202
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(e), this;
|
|
203
203
|
};
|
|
204
|
-
|
|
204
|
+
E.prototype.once = function(s, e) {
|
|
205
205
|
function t() {
|
|
206
206
|
this.off(s, t), e.apply(this, arguments);
|
|
207
207
|
}
|
|
208
208
|
return t.fn = e, this.on(s, t), this;
|
|
209
209
|
};
|
|
210
|
-
|
|
210
|
+
E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(s, e) {
|
|
211
211
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
212
212
|
return this._callbacks = {}, this;
|
|
213
213
|
var t = this._callbacks["$" + s];
|
|
@@ -221,7 +221,7 @@ C.prototype.off = C.prototype.removeListener = C.prototype.removeAllListeners =
|
|
|
221
221
|
}
|
|
222
222
|
return t.length === 0 && delete this._callbacks["$" + s], this;
|
|
223
223
|
};
|
|
224
|
-
|
|
224
|
+
E.prototype.emit = function(s) {
|
|
225
225
|
this._callbacks = this._callbacks || {};
|
|
226
226
|
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + s], i = 1; i < arguments.length; i++)
|
|
227
227
|
e[i - 1] = arguments[i];
|
|
@@ -232,20 +232,20 @@ C.prototype.emit = function(s) {
|
|
|
232
232
|
}
|
|
233
233
|
return this;
|
|
234
234
|
};
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
E.prototype.emitReserved = E.prototype.emit;
|
|
236
|
+
E.prototype.listeners = function(s) {
|
|
237
237
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + s] || [];
|
|
238
238
|
};
|
|
239
|
-
|
|
239
|
+
E.prototype.hasListeners = function(s) {
|
|
240
240
|
return !!this.listeners(s).length;
|
|
241
241
|
};
|
|
242
|
-
const St = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0),
|
|
242
|
+
const St = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), Q = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Qn = "arraybuffer";
|
|
243
243
|
function ji(s, ...e) {
|
|
244
244
|
return e.reduce((t, i) => (s.hasOwnProperty(i) && (t[i] = s[i]), t), {});
|
|
245
245
|
}
|
|
246
|
-
const Gn =
|
|
246
|
+
const Gn = Q.setTimeout, Jn = Q.clearTimeout;
|
|
247
247
|
function wt(s, e) {
|
|
248
|
-
e.useNativeTimers ? (s.setTimeoutFn = Gn.bind(
|
|
248
|
+
e.useNativeTimers ? (s.setTimeoutFn = Gn.bind(Q), s.clearTimeoutFn = Jn.bind(Q)) : (s.setTimeoutFn = Q.setTimeout.bind(Q), s.clearTimeoutFn = Q.clearTimeout.bind(Q));
|
|
249
249
|
}
|
|
250
250
|
const Xn = 1.33;
|
|
251
251
|
function Yn(s) {
|
|
@@ -279,7 +279,7 @@ class sr extends Error {
|
|
|
279
279
|
super(e), this.description = t, this.context = i, this.type = "TransportError";
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
class Is extends
|
|
282
|
+
class Is extends E {
|
|
283
283
|
/**
|
|
284
284
|
* Transport abstract constructor.
|
|
285
285
|
*
|
|
@@ -519,7 +519,7 @@ class or extends ir {
|
|
|
519
519
|
}), this.pollXhr = e;
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
let me = class it extends
|
|
522
|
+
let me = class it extends E {
|
|
523
523
|
/**
|
|
524
524
|
* Request constructor
|
|
525
525
|
*
|
|
@@ -622,7 +622,7 @@ if (typeof document < "u") {
|
|
|
622
622
|
if (typeof attachEvent == "function")
|
|
623
623
|
attachEvent("onunload", xs);
|
|
624
624
|
else if (typeof addEventListener == "function") {
|
|
625
|
-
const s = "onpagehide" in
|
|
625
|
+
const s = "onpagehide" in Q ? "pagehide" : "unload";
|
|
626
626
|
addEventListener(s, xs, !1);
|
|
627
627
|
}
|
|
628
628
|
}
|
|
@@ -655,7 +655,7 @@ function zi(s) {
|
|
|
655
655
|
}
|
|
656
656
|
if (!e)
|
|
657
657
|
try {
|
|
658
|
-
return new
|
|
658
|
+
return new Q[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
659
659
|
} catch {
|
|
660
660
|
}
|
|
661
661
|
}
|
|
@@ -716,10 +716,10 @@ class lr extends Is {
|
|
|
716
716
|
return this.opts.timestampRequests && (t[this.opts.timestampParam] = $i()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
|
-
const
|
|
719
|
+
const Ct = Q.WebSocket || Q.MozWebSocket;
|
|
720
720
|
class dr extends lr {
|
|
721
721
|
createSocket(e, t, i) {
|
|
722
|
-
return Ki ? new
|
|
722
|
+
return Ki ? new Ct(e, t, i) : t ? new Ct(e, t) : new Ct(e);
|
|
723
723
|
}
|
|
724
724
|
doWrite(e, t) {
|
|
725
725
|
this.ws.send(t);
|
|
@@ -815,7 +815,7 @@ const Jt = typeof addEventListener == "function" && typeof removeEventListener =
|
|
|
815
815
|
Jt && addEventListener("offline", () => {
|
|
816
816
|
nt.forEach((s) => s());
|
|
817
817
|
}, !1);
|
|
818
|
-
class re extends
|
|
818
|
+
class re extends E {
|
|
819
819
|
/**
|
|
820
820
|
* Socket constructor.
|
|
821
821
|
*
|
|
@@ -1249,10 +1249,10 @@ const Rr = [
|
|
|
1249
1249
|
"removeListener"
|
|
1250
1250
|
// used by the Node.js EventEmitter
|
|
1251
1251
|
];
|
|
1252
|
-
var
|
|
1252
|
+
var T;
|
|
1253
1253
|
(function(s) {
|
|
1254
1254
|
s[s.CONNECT = 0] = "CONNECT", s[s.DISCONNECT = 1] = "DISCONNECT", s[s.EVENT = 2] = "EVENT", s[s.ACK = 3] = "ACK", s[s.CONNECT_ERROR = 4] = "CONNECT_ERROR", s[s.BINARY_EVENT = 5] = "BINARY_EVENT", s[s.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1255
|
-
})(
|
|
1255
|
+
})(T || (T = {}));
|
|
1256
1256
|
class kr {
|
|
1257
1257
|
/**
|
|
1258
1258
|
* Encoder constructor
|
|
@@ -1269,8 +1269,8 @@ class kr {
|
|
|
1269
1269
|
* @param {Object} obj - packet object
|
|
1270
1270
|
*/
|
|
1271
1271
|
encode(e) {
|
|
1272
|
-
return (e.type ===
|
|
1273
|
-
type: e.type ===
|
|
1272
|
+
return (e.type === T.EVENT || e.type === T.ACK) && rt(e) ? this.encodeAsBinary({
|
|
1273
|
+
type: e.type === T.EVENT ? T.BINARY_EVENT : T.BINARY_ACK,
|
|
1274
1274
|
nsp: e.nsp,
|
|
1275
1275
|
data: e.data,
|
|
1276
1276
|
id: e.id
|
|
@@ -1281,7 +1281,7 @@ class kr {
|
|
|
1281
1281
|
*/
|
|
1282
1282
|
encodeAsString(e) {
|
|
1283
1283
|
let t = "" + e.type;
|
|
1284
|
-
return (e.type ===
|
|
1284
|
+
return (e.type === T.BINARY_EVENT || e.type === T.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
|
|
1285
1285
|
}
|
|
1286
1286
|
/**
|
|
1287
1287
|
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
@@ -1293,7 +1293,7 @@ class kr {
|
|
|
1293
1293
|
return n.unshift(i), n;
|
|
1294
1294
|
}
|
|
1295
1295
|
}
|
|
1296
|
-
class ws extends
|
|
1296
|
+
class ws extends E {
|
|
1297
1297
|
/**
|
|
1298
1298
|
* Decoder constructor
|
|
1299
1299
|
*/
|
|
@@ -1314,8 +1314,8 @@ class ws extends C {
|
|
|
1314
1314
|
if (this.reconstructor)
|
|
1315
1315
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1316
1316
|
t = this.decodeString(e);
|
|
1317
|
-
const i = t.type ===
|
|
1318
|
-
i || t.type ===
|
|
1317
|
+
const i = t.type === T.BINARY_EVENT;
|
|
1318
|
+
i || t.type === T.BINARY_ACK ? (t.type = i ? T.EVENT : T.ACK, this.reconstructor = new Mr(t)) : super.emitReserved("decoded", t);
|
|
1319
1319
|
} else if (Ss(e) || e.base64)
|
|
1320
1320
|
if (this.reconstructor)
|
|
1321
1321
|
t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
@@ -1335,9 +1335,9 @@ class ws extends C {
|
|
|
1335
1335
|
const i = {
|
|
1336
1336
|
type: Number(e.charAt(0))
|
|
1337
1337
|
};
|
|
1338
|
-
if (
|
|
1338
|
+
if (T[i.type] === void 0)
|
|
1339
1339
|
throw new Error("unknown packet type " + i.type);
|
|
1340
|
-
if (i.type ===
|
|
1340
|
+
if (i.type === T.BINARY_EVENT || i.type === T.BINARY_ACK) {
|
|
1341
1341
|
const r = t + 1;
|
|
1342
1342
|
for (; e.charAt(++t) !== "-" && t != e.length; )
|
|
1343
1343
|
;
|
|
@@ -1345,7 +1345,7 @@ class ws extends C {
|
|
|
1345
1345
|
if (o != Number(o) || e.charAt(t) !== "-")
|
|
1346
1346
|
throw new Error("Illegal attachments");
|
|
1347
1347
|
const a = Number(o);
|
|
1348
|
-
if (!
|
|
1348
|
+
if (!Cr(a) || a < 1)
|
|
1349
1349
|
throw new Error("Illegal attachments");
|
|
1350
1350
|
if (a > this.opts.maxAttachments)
|
|
1351
1351
|
throw new Error("too many attachments");
|
|
@@ -1390,17 +1390,17 @@ class ws extends C {
|
|
|
1390
1390
|
}
|
|
1391
1391
|
static isPayloadValid(e, t) {
|
|
1392
1392
|
switch (e) {
|
|
1393
|
-
case
|
|
1393
|
+
case T.CONNECT:
|
|
1394
1394
|
return Ns(t);
|
|
1395
|
-
case
|
|
1395
|
+
case T.DISCONNECT:
|
|
1396
1396
|
return t === void 0;
|
|
1397
|
-
case
|
|
1397
|
+
case T.CONNECT_ERROR:
|
|
1398
1398
|
return typeof t == "string" || Ns(t);
|
|
1399
|
-
case
|
|
1400
|
-
case
|
|
1399
|
+
case T.EVENT:
|
|
1400
|
+
case T.BINARY_EVENT:
|
|
1401
1401
|
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && Rr.indexOf(t[0]) === -1);
|
|
1402
|
-
case
|
|
1403
|
-
case
|
|
1402
|
+
case T.ACK:
|
|
1403
|
+
case T.BINARY_ACK:
|
|
1404
1404
|
return Array.isArray(t);
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
@@ -1437,18 +1437,18 @@ class Mr {
|
|
|
1437
1437
|
this.reconPack = null, this.buffers = [];
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
1440
|
-
const
|
|
1440
|
+
const Cr = Number.isInteger || function(s) {
|
|
1441
1441
|
return typeof s == "number" && isFinite(s) && Math.floor(s) === s;
|
|
1442
1442
|
};
|
|
1443
1443
|
function Ns(s) {
|
|
1444
1444
|
return Object.prototype.toString.call(s) === "[object Object]";
|
|
1445
1445
|
}
|
|
1446
|
-
const
|
|
1446
|
+
const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1447
1447
|
__proto__: null,
|
|
1448
1448
|
Decoder: ws,
|
|
1449
1449
|
Encoder: kr,
|
|
1450
1450
|
get PacketType() {
|
|
1451
|
-
return
|
|
1451
|
+
return T;
|
|
1452
1452
|
}
|
|
1453
1453
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1454
1454
|
function G(s, e, t) {
|
|
@@ -1465,7 +1465,7 @@ const Pr = Object.freeze({
|
|
|
1465
1465
|
newListener: 1,
|
|
1466
1466
|
removeListener: 1
|
|
1467
1467
|
});
|
|
1468
|
-
class Qi extends
|
|
1468
|
+
class Qi extends E {
|
|
1469
1469
|
/**
|
|
1470
1470
|
* `Socket` constructor.
|
|
1471
1471
|
*/
|
|
@@ -1586,7 +1586,7 @@ class Qi extends C {
|
|
|
1586
1586
|
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1587
1587
|
return this._addToQueue(t), this;
|
|
1588
1588
|
const o = {
|
|
1589
|
-
type:
|
|
1589
|
+
type: T.EVENT,
|
|
1590
1590
|
data: t
|
|
1591
1591
|
};
|
|
1592
1592
|
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
|
|
@@ -1694,7 +1694,7 @@ class Qi extends C {
|
|
|
1694
1694
|
*/
|
|
1695
1695
|
_sendConnectPacket(e) {
|
|
1696
1696
|
this.packet({
|
|
1697
|
-
type:
|
|
1697
|
+
type: T.CONNECT,
|
|
1698
1698
|
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
|
|
1699
1699
|
});
|
|
1700
1700
|
}
|
|
@@ -1740,21 +1740,21 @@ class Qi extends C {
|
|
|
1740
1740
|
onpacket(e) {
|
|
1741
1741
|
if (e.nsp === this.nsp)
|
|
1742
1742
|
switch (e.type) {
|
|
1743
|
-
case
|
|
1743
|
+
case T.CONNECT:
|
|
1744
1744
|
e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
|
1745
1745
|
break;
|
|
1746
|
-
case
|
|
1747
|
-
case
|
|
1746
|
+
case T.EVENT:
|
|
1747
|
+
case T.BINARY_EVENT:
|
|
1748
1748
|
this.onevent(e);
|
|
1749
1749
|
break;
|
|
1750
|
-
case
|
|
1751
|
-
case
|
|
1750
|
+
case T.ACK:
|
|
1751
|
+
case T.BINARY_ACK:
|
|
1752
1752
|
this.onack(e);
|
|
1753
1753
|
break;
|
|
1754
|
-
case
|
|
1754
|
+
case T.DISCONNECT:
|
|
1755
1755
|
this.ondisconnect();
|
|
1756
1756
|
break;
|
|
1757
|
-
case
|
|
1757
|
+
case T.CONNECT_ERROR:
|
|
1758
1758
|
this.destroy();
|
|
1759
1759
|
const i = new Error(e.data.message);
|
|
1760
1760
|
i.data = e.data.data, this.emitReserved("connect_error", i);
|
|
@@ -1789,7 +1789,7 @@ class Qi extends C {
|
|
|
1789
1789
|
let i = !1;
|
|
1790
1790
|
return function(...n) {
|
|
1791
1791
|
i || (i = !0, t.packet({
|
|
1792
|
-
type:
|
|
1792
|
+
type: T.ACK,
|
|
1793
1793
|
id: e,
|
|
1794
1794
|
data: n
|
|
1795
1795
|
}));
|
|
@@ -1858,7 +1858,7 @@ class Qi extends C {
|
|
|
1858
1858
|
* @return self
|
|
1859
1859
|
*/
|
|
1860
1860
|
disconnect() {
|
|
1861
|
-
return this.connected && this.packet({ type:
|
|
1861
|
+
return this.connected && this.packet({ type: T.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
|
|
1862
1862
|
}
|
|
1863
1863
|
/**
|
|
1864
1864
|
* Alias for {@link disconnect()}.
|
|
@@ -2080,7 +2080,7 @@ we.prototype.setMax = function(s) {
|
|
|
2080
2080
|
we.prototype.setJitter = function(s) {
|
|
2081
2081
|
this.jitter = s;
|
|
2082
2082
|
};
|
|
2083
|
-
class Yt extends
|
|
2083
|
+
class Yt extends E {
|
|
2084
2084
|
constructor(e, t) {
|
|
2085
2085
|
var i;
|
|
2086
2086
|
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, wt(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((i = t.randomizationFactor) !== null && i !== void 0 ? i : 0.5), this.backoff = new we({
|
|
@@ -2088,7 +2088,7 @@ class Yt extends C {
|
|
|
2088
2088
|
max: this.reconnectionDelayMax(),
|
|
2089
2089
|
jitter: this.randomizationFactor()
|
|
2090
2090
|
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
2091
|
-
const n = t.parser ||
|
|
2091
|
+
const n = t.parser || Er;
|
|
2092
2092
|
this.encoder = new n.Encoder(), this.decoder = new n.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
2093
2093
|
}
|
|
2094
2094
|
reconnection(e) {
|
|
@@ -2343,13 +2343,14 @@ const Dr = /* @__PURE__ */ new Set([
|
|
|
2343
2343
|
"tool.started",
|
|
2344
2344
|
"tool.result"
|
|
2345
2345
|
]);
|
|
2346
|
-
class
|
|
2347
|
-
constructor(e, t, i = !1, n) {
|
|
2348
|
-
super(e), this.code = t, this.outcomeUnknown = i, this.detail = n, this.code = t === "401" ? "unauthorized" : t;
|
|
2346
|
+
class v extends Error {
|
|
2347
|
+
constructor(e, t, i = !1, n, r = !1) {
|
|
2348
|
+
super(e), this.code = t, this.outcomeUnknown = i, this.detail = n, this.backendRefusal = r, this.code = t === "401" ? "unauthorized" : t;
|
|
2349
2349
|
}
|
|
2350
2350
|
code;
|
|
2351
2351
|
outcomeUnknown;
|
|
2352
2352
|
detail;
|
|
2353
|
+
backendRefusal;
|
|
2353
2354
|
}
|
|
2354
2355
|
class Ur {
|
|
2355
2356
|
constructor(e) {
|
|
@@ -2366,7 +2367,7 @@ class Ur {
|
|
|
2366
2367
|
reconnection: e.reconnect ?? !0
|
|
2367
2368
|
}), this.socket.on("connection.ready", (t) => {
|
|
2368
2369
|
if (t.protocol !== 1 || t.role !== this.options.auth.role || t.display_projection_ready !== !1) {
|
|
2369
|
-
this.options.onError(new
|
|
2370
|
+
this.options.onError(new v("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
|
|
2370
2371
|
return;
|
|
2371
2372
|
}
|
|
2372
2373
|
this.admitted = t, this.activate();
|
|
@@ -2377,7 +2378,7 @@ class Ur {
|
|
|
2377
2378
|
)), this.socket.on("connect_error", (t) => {
|
|
2378
2379
|
const i = t.data?.code;
|
|
2379
2380
|
if (i === "unauthorized" && t.data?.reason === "token_expired" && t.data.retryable === !0) {
|
|
2380
|
-
this.options.onError(new
|
|
2381
|
+
this.options.onError(new v(t.message, i, !1, t.data)), this.disconnect();
|
|
2381
2382
|
return;
|
|
2382
2383
|
}
|
|
2383
2384
|
if (!i || t.data?.retryable === !0) {
|
|
@@ -2389,7 +2390,7 @@ class Ur {
|
|
|
2389
2390
|
}
|
|
2390
2391
|
return;
|
|
2391
2392
|
}
|
|
2392
|
-
(i === "unauthorized" || i === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new
|
|
2393
|
+
(i === "unauthorized" || i === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new v(t.message, i ?? "connection_error", !1, t.data)), this.rejectedToken === this.options.auth.token && this.disconnect();
|
|
2393
2394
|
}), this.socket.on("conversation.event", (t) => {
|
|
2394
2395
|
this.ready && t.protocol === 1 && t.session_id && this.bindings.get(t.session_id)?.owners.size && this.options.onEvent("conversation.event", t.event);
|
|
2395
2396
|
}), this.socket.on("conversation.metadata.updated", (t) => {
|
|
@@ -2403,7 +2404,7 @@ class Ur {
|
|
|
2403
2404
|
const n = this.generation, r = await this.options.onToolCall(t);
|
|
2404
2405
|
i({ received: r && !!this.ready && n === this.generation });
|
|
2405
2406
|
}), this.socket.on("executor.replaced", () => {
|
|
2406
|
-
this.retired = !0, this.options.onError(new
|
|
2407
|
+
this.retired = !0, this.options.onError(new v("Browser executor was replaced", "executor_replaced")), this.disconnect();
|
|
2407
2408
|
});
|
|
2408
2409
|
}
|
|
2409
2410
|
options;
|
|
@@ -2440,20 +2441,20 @@ class Ur {
|
|
|
2440
2441
|
async retain(e, t) {
|
|
2441
2442
|
let i = this.bindings.get(e);
|
|
2442
2443
|
if (!i) {
|
|
2443
|
-
if (this.bindings.size >= 64) throw new
|
|
2444
|
+
if (this.bindings.size >= 64) throw new v("Too many conversation subscriptions", "subscription_limit");
|
|
2444
2445
|
i = { id: crypto.randomUUID(), owners: /* @__PURE__ */ new Set(), joinedGeneration: -1 }, this.bindings.set(e, i);
|
|
2445
2446
|
}
|
|
2446
2447
|
if (i.owners.add(t), !this.ready) return;
|
|
2447
2448
|
const n = this.generation;
|
|
2448
2449
|
await this.synchronize().catch((r) => {
|
|
2449
|
-
throw n !== this.generation || (i.owners.delete(t), r instanceof
|
|
2450
|
+
throw n !== this.generation || (i.owners.delete(t), r instanceof v && r.outcomeUnknown && this.ready && (i.joinedGeneration = this.generation), this.synchronize().catch((o) => this.options.onError(o))), r;
|
|
2450
2451
|
});
|
|
2451
2452
|
}
|
|
2452
2453
|
async release(e, t) {
|
|
2453
2454
|
this.bindings.get(e)?.owners.delete(t), this.ready && await this.synchronize();
|
|
2454
2455
|
}
|
|
2455
2456
|
async rpc(e, t) {
|
|
2456
|
-
if (!Dr.has(e)) throw new
|
|
2457
|
+
if (!Dr.has(e)) throw new v("Operation requires its HTTP adapter", "unsupported_rpc");
|
|
2457
2458
|
const i = this.generation, n = JSON.stringify(t);
|
|
2458
2459
|
return e === "run.stop" && this.uploadingResult ? (this.assertReady(i), this.request("runtime.rpc", { type: e, payload: JSON.parse(n) }, i)) : this.enqueue(async () => {
|
|
2459
2460
|
if (this.assertReady(i), e === "tool.result") {
|
|
@@ -2471,7 +2472,7 @@ class Ur {
|
|
|
2471
2472
|
if (this.options.auth.role !== "session_surface" && await this.request("executor.register", {}, e), e !== this.generation || !this.socket.connected) return;
|
|
2472
2473
|
this.ready = t, await this.synchronize(!0), e === this.generation && this.ready && this.options.onReady(t);
|
|
2473
2474
|
} catch (i) {
|
|
2474
|
-
e === this.generation && this.activationFailed(i instanceof
|
|
2475
|
+
e === this.generation && this.activationFailed(i instanceof v ? i : new v(String(i), "activation_error"));
|
|
2475
2476
|
} finally {
|
|
2476
2477
|
e === this.generation && (this.activating = !1);
|
|
2477
2478
|
}
|
|
@@ -2487,7 +2488,7 @@ class Ur {
|
|
|
2487
2488
|
for (const [i, n] of this.bindings) {
|
|
2488
2489
|
if (n.owners.size && n.joinedGeneration !== t) {
|
|
2489
2490
|
if (!await this.request("conversation.subscribe", { session_id: i, subscription_id: n.id }, t).then(() => !0).catch((o) => {
|
|
2490
|
-
if (o instanceof
|
|
2491
|
+
if (o instanceof v && !o.outcomeUnknown && o.detail?.retryable !== !0 && this.bindings.get(i) === n && (this.bindings.delete(i), e))
|
|
2491
2492
|
return this.options.onError(o), !1;
|
|
2492
2493
|
throw o;
|
|
2493
2494
|
})) continue;
|
|
@@ -2498,8 +2499,10 @@ class Ur {
|
|
|
2498
2499
|
});
|
|
2499
2500
|
}
|
|
2500
2501
|
enqueue(e) {
|
|
2501
|
-
if (this.queuedOperations >= 128)
|
|
2502
|
-
|
|
2502
|
+
if (this.queuedOperations >= 128) {
|
|
2503
|
+
const i = new v("Product Agent transport queue is full", "backpressure");
|
|
2504
|
+
return this.recoverUncertainDelivery(i, this.generation), Promise.reject(i);
|
|
2505
|
+
}
|
|
2503
2506
|
this.queuedOperations++;
|
|
2504
2507
|
const t = this.operations.then(e).finally(() => {
|
|
2505
2508
|
this.queuedOperations--;
|
|
@@ -2508,7 +2511,7 @@ class Ur {
|
|
|
2508
2511
|
}), t;
|
|
2509
2512
|
}
|
|
2510
2513
|
assertReady(e) {
|
|
2511
|
-
if (!this.ready || !this.socket.connected || e !== this.generation) throw new
|
|
2514
|
+
if (!this.ready || !this.socket.connected || e !== this.generation) throw new v("Transport is not ready", "disconnected");
|
|
2512
2515
|
}
|
|
2513
2516
|
async uploadResult(e, t, i) {
|
|
2514
2517
|
const n = crypto.randomUUID();
|
|
@@ -2533,37 +2536,43 @@ class Ur {
|
|
|
2533
2536
|
body: JSON.stringify({ request_id: n, type: "tool.result", payload: e })
|
|
2534
2537
|
});
|
|
2535
2538
|
if (u.status >= 500)
|
|
2536
|
-
throw new
|
|
2537
|
-
if (!u.ok) throw new
|
|
2539
|
+
throw new v("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
2540
|
+
if (!u.ok) throw new v(`Result upload rejected (${u.status})`, String(u.status), !1, void 0, !0);
|
|
2538
2541
|
const h = await u.json();
|
|
2539
2542
|
if (t !== this.generation || r.signal.aborted)
|
|
2540
|
-
throw new
|
|
2543
|
+
throw new v("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
2541
2544
|
if (h?.request_id !== n || typeof h.ok != "boolean")
|
|
2542
|
-
throw new
|
|
2543
|
-
if (!h.ok) throw new
|
|
2545
|
+
throw new v("Invalid result acknowledgement identity", "invalid_ack", !0);
|
|
2546
|
+
if (!h.ok) throw new v("Product Agent result rejected", h.code ?? "request_rejected", !1, h.result, !0);
|
|
2544
2547
|
return h.result;
|
|
2545
2548
|
} catch (l) {
|
|
2546
|
-
|
|
2549
|
+
const d = l instanceof v ? l : new v("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
2550
|
+
throw this.recoverUncertainDelivery(d, t), d;
|
|
2547
2551
|
} finally {
|
|
2548
2552
|
clearTimeout(c), this.uploadingResult = !1, this.pending.delete(o);
|
|
2549
2553
|
}
|
|
2550
2554
|
}
|
|
2551
2555
|
request(e, t, i) {
|
|
2552
|
-
if (!this.socket.connected || i !== this.generation) return Promise.reject(new
|
|
2556
|
+
if (!this.socket.connected || i !== this.generation) return Promise.reject(new v("Transport disconnected", "disconnected"));
|
|
2553
2557
|
const n = crypto.randomUUID();
|
|
2554
2558
|
return new Promise((r, o) => {
|
|
2555
2559
|
const a = (c) => {
|
|
2556
2560
|
this.pending.delete(a), o(c);
|
|
2557
2561
|
};
|
|
2558
2562
|
this.pending.add(a), this.socket.timeout(this.options.requestTimeoutMs ?? 15e3).emit(e, { ...t, request_id: n }, (c, l) => {
|
|
2559
|
-
this.pending.delete(a) && (c || i !== this.generation ? o(new
|
|
2563
|
+
this.pending.delete(a) && (c || i !== this.generation ? o(new v("Delivery outcome is unknown; reconcile without repeating execution", "delivery_unknown", !0)) : l?.request_id !== n || typeof l.ok != "boolean" ? o(new v("Invalid acknowledgement identity", "invalid_ack", !0)) : l.ok ? r(l.result) : o(new v("Product Agent request rejected", l.code ?? "request_rejected", !1, l.result, !0)));
|
|
2560
2564
|
});
|
|
2565
|
+
}).catch((r) => {
|
|
2566
|
+
throw this.recoverUncertainDelivery(r, i), r;
|
|
2561
2567
|
});
|
|
2562
2568
|
}
|
|
2569
|
+
recoverUncertainDelivery(e, t) {
|
|
2570
|
+
e instanceof v && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && t === this.generation && this.active && this.socket.io.engine.close();
|
|
2571
|
+
}
|
|
2563
2572
|
invalidate(e = !1) {
|
|
2564
2573
|
if (this.active) {
|
|
2565
2574
|
this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
|
|
2566
|
-
for (const t of [...this.pending]) t(new
|
|
2575
|
+
for (const t of [...this.pending]) t(new v("Connection lost before acknowledgement", "delivery_unknown", !0));
|
|
2567
2576
|
this.options.onDisconnect(e);
|
|
2568
2577
|
}
|
|
2569
2578
|
}
|
|
@@ -2597,12 +2606,12 @@ class Gi {
|
|
|
2597
2606
|
if (!h.ok) {
|
|
2598
2607
|
const f = h.status === 401 ? "unauthorized" : h.status === 426 ? "update_required" : String(h.status), p = (await h.json().catch(() => null))?.detail;
|
|
2599
2608
|
if (h.status !== 401 && p && typeof p == "object" && ["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(p.code) && typeof p.message == "string")
|
|
2600
|
-
throw new
|
|
2609
|
+
throw new v(p.message, p.code, !1, {
|
|
2601
2610
|
...typeof p.blockedOrigin == "string" ? { blockedOrigin: p.blockedOrigin } : {},
|
|
2602
2611
|
...typeof p.securitySettingsUrl == "string" ? { securitySettingsUrl: p.securitySettingsUrl } : {}
|
|
2603
2612
|
});
|
|
2604
2613
|
const y = p === "Token expired" ? "token_expired" : p?.reason, I = h.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(y) ? { reason: y, retryable: y === "token_expired" && (p === "Token expired" || p.retryable === !0) } : void 0;
|
|
2605
|
-
throw new
|
|
2614
|
+
throw new v(`Product Agent request failed (${h.status})`, f, !1, I);
|
|
2606
2615
|
}
|
|
2607
2616
|
return await h.json();
|
|
2608
2617
|
} finally {
|
|
@@ -2706,12 +2715,12 @@ class Zt {
|
|
|
2706
2715
|
}
|
|
2707
2716
|
}
|
|
2708
2717
|
const Or = { activeIntervalMs: 3e3, idleIntervalMs: 15e3, maxFailureIntervalMs: 3e4 };
|
|
2709
|
-
function
|
|
2718
|
+
function z(s) {
|
|
2710
2719
|
const e = s.currentAuthority();
|
|
2711
2720
|
return e.authorityId === s.authority.authorityId && e.generation === s.authority.generation;
|
|
2712
2721
|
}
|
|
2713
|
-
function
|
|
2714
|
-
if (
|
|
2722
|
+
function Ce(s, e) {
|
|
2723
|
+
if (!z(s) || e.authorityId !== s.authority.authorityId || e.generation !== s.authority.generation)
|
|
2715
2724
|
throw new Error("Directory authority is no longer current.");
|
|
2716
2725
|
}
|
|
2717
2726
|
function qe(s) {
|
|
@@ -2745,31 +2754,31 @@ function xr(s) {
|
|
|
2745
2754
|
return {
|
|
2746
2755
|
"directory.query": async (i) => {
|
|
2747
2756
|
try {
|
|
2748
|
-
|
|
2757
|
+
Ce(s, i);
|
|
2749
2758
|
const n = qe(i.query), r = { origin: n.origin, pinned: n.kind === "pinned", cursor: i.cursor, limit: n.limit };
|
|
2750
2759
|
let o;
|
|
2751
2760
|
if (s.http.auth.client_kind === "embed") {
|
|
2752
2761
|
const a = await s.http.request("/conversations", { ...r, page_url: n.origin ?? s.pageUrl() });
|
|
2753
|
-
|
|
2762
|
+
Ce(s, i), o = { entries: await Promise.all(a.sessions.map(async (l) => ({
|
|
2754
2763
|
...await Xi(s.http, l.id),
|
|
2755
2764
|
...typeof l.isActive == "boolean" ? { is_active: l.isActive } : {}
|
|
2756
2765
|
}))), next_cursor: a.nextCursor };
|
|
2757
2766
|
} else
|
|
2758
2767
|
o = await s.http.request("/conversations", r, void 0, "GET", e);
|
|
2759
|
-
return
|
|
2768
|
+
return Ce(s, i), { ...o, updatedAt: s.now() };
|
|
2760
2769
|
} catch (n) {
|
|
2761
|
-
throw
|
|
2770
|
+
throw z({ authority: i, currentAuthority: s.currentAuthority }) && s.onError?.(n), n;
|
|
2762
2771
|
}
|
|
2763
2772
|
},
|
|
2764
2773
|
"directory.mutate": (i) => {
|
|
2765
2774
|
const r = (t.get(i.sessionId) ?? Promise.resolve()).catch(() => {
|
|
2766
2775
|
}).then(async () => {
|
|
2767
2776
|
try {
|
|
2768
|
-
|
|
2777
|
+
Ce(s, i);
|
|
2769
2778
|
const a = await s.http.request(`/conversations/${encodeURIComponent(i.sessionId)}`, {}, i.patch, "PATCH", e);
|
|
2770
|
-
return
|
|
2779
|
+
return Ce(s, i), a;
|
|
2771
2780
|
} catch (a) {
|
|
2772
|
-
throw
|
|
2781
|
+
throw z({ authority: i, currentAuthority: s.currentAuthority }) && s.onError?.(a), a;
|
|
2773
2782
|
}
|
|
2774
2783
|
});
|
|
2775
2784
|
t.set(i.sessionId, r);
|
|
@@ -2794,7 +2803,7 @@ class Nr {
|
|
|
2794
2803
|
disposed = !1;
|
|
2795
2804
|
boundary;
|
|
2796
2805
|
reconcile() {
|
|
2797
|
-
const e = this.options.runtime.engine.getProjection().directory.intents, t = !this.disposed &&
|
|
2806
|
+
const e = this.options.runtime.engine.getProjection().directory.intents, t = !this.disposed && z(this.boundary) && (this.options.enabled?.() ?? !0);
|
|
2798
2807
|
for (const [i, n] of this.observations)
|
|
2799
2808
|
t && e[i]?.observe || (n.metadata.stop(), n.recovery.transcript.stop(), n.recovery.activity.stop(), this.observations.delete(i), this.options.socket.release(i, this.owner).catch((r) => this.report(r)));
|
|
2800
2809
|
if (t) for (const [i, n] of Object.entries(e)) {
|
|
@@ -2823,14 +2832,14 @@ class Nr {
|
|
|
2823
2832
|
this.observations.size ? this.options.wakeup.start() : this.options.wakeup.stop();
|
|
2824
2833
|
}
|
|
2825
2834
|
metadata(e) {
|
|
2826
|
-
if (this.disposed ||
|
|
2835
|
+
if (this.disposed || !z(this.boundary) || !this.observations.has(e.conversation_id)) return;
|
|
2827
2836
|
const t = this.options.runtime.engine.getState().slices.directory.metadataRevision;
|
|
2828
2837
|
if (this.options.runtime.engine.accept({ ...this.options.authority, type: "directory.metadata_received", metadata: e }), this.options.runtime.engine.getState().slices.directory.metadataRevision !== t)
|
|
2829
2838
|
for (const n of this.observedQueryStates())
|
|
2830
2839
|
n.invalidated && this.refreshObservedQuery(n.query).catch((r) => this.report(r));
|
|
2831
2840
|
}
|
|
2832
2841
|
open(e, t = "replace", i) {
|
|
2833
|
-
if (this.disposed ||
|
|
2842
|
+
if (this.disposed || !z(this.boundary)) return Promise.resolve();
|
|
2834
2843
|
e = qe(e);
|
|
2835
2844
|
const n = O(e);
|
|
2836
2845
|
return t === "replace" && this.options.runtime.engine.getState().slices.directory.queries[n]?.requestId ? (this.refreshAfterRequest.add(n), Promise.resolve()) : (this.requestPage(e, t, i).catch((r) => this.report(r)), Promise.resolve());
|
|
@@ -2851,9 +2860,9 @@ class Nr {
|
|
|
2851
2860
|
}), r;
|
|
2852
2861
|
}
|
|
2853
2862
|
async readPage(e, t, i) {
|
|
2854
|
-
for (; !this.disposed &&
|
|
2863
|
+
for (; !this.disposed && z(this.boundary) && this.options.runtime.engine.getState().slices.directory.queries[O(e)]?.requestId; )
|
|
2855
2864
|
await this.waitForQuery(e, !1);
|
|
2856
|
-
if (this.disposed ||
|
|
2865
|
+
if (this.disposed || !z(this.boundary)) throw new Error("Directory authority is no longer current.");
|
|
2857
2866
|
return await this.options.runtime.engine.dispatch({
|
|
2858
2867
|
...this.options.authority,
|
|
2859
2868
|
type: "directory.query",
|
|
@@ -2887,26 +2896,26 @@ class Nr {
|
|
|
2887
2896
|
o?.(), o = null, this.queryWaiters.delete(c);
|
|
2888
2897
|
}, c = () => {
|
|
2889
2898
|
const l = this.options.runtime.engine.getState().slices.directory.queries[i];
|
|
2890
|
-
return this.disposed ||
|
|
2899
|
+
return this.disposed || !z(this.boundary) || !l ? (a(), t ? r(new Error("Directory authority is no longer current.")) : n(), !0) : l.requestId !== null ? !1 : (a(), t && l.status === "error" ? r(new Error(l.error?.message ?? "Conversation directory failed")) : n(), !0);
|
|
2891
2900
|
};
|
|
2892
2901
|
c() || (this.queryWaiters.add(c), o = this.options.runtime.engine.subscribe(c));
|
|
2893
2902
|
});
|
|
2894
2903
|
}
|
|
2895
2904
|
async focus() {
|
|
2896
|
-
this.disposed ||
|
|
2905
|
+
this.disposed || !z(this.boundary) || !(this.options.enabled?.() ?? !0) || this.refreshObservedQueries().catch((e) => this.report(e));
|
|
2897
2906
|
}
|
|
2898
2907
|
observedQueryStates() {
|
|
2899
2908
|
const e = this.options.runtime.engine.getState().slices.directory.queries;
|
|
2900
2909
|
return this.options.observedQueries().flatMap((t) => e[O(qe(t))] ?? []);
|
|
2901
2910
|
}
|
|
2902
2911
|
isObserved(e) {
|
|
2903
|
-
return !this.disposed &&
|
|
2912
|
+
return !this.disposed && z(this.boundary) && (this.options.enabled?.() ?? !0) && this.observedQueryStates().some((t) => O(t.query) === O(e));
|
|
2904
2913
|
}
|
|
2905
2914
|
async refreshObservedQueries() {
|
|
2906
2915
|
await Promise.all(this.observedQueryStates().map((e) => this.refreshObservedQuery(e.query)));
|
|
2907
2916
|
}
|
|
2908
2917
|
async reconnect() {
|
|
2909
|
-
if (!(this.disposed ||
|
|
2918
|
+
if (!(this.disposed || !z(this.boundary) || !(this.options.enabled?.() ?? !0))) {
|
|
2910
2919
|
this.reconcile();
|
|
2911
2920
|
for (const [e, t] of this.observations)
|
|
2912
2921
|
this.options.socket.retain(e, this.owner).catch((i) => this.report(i)), t.metadata.refresh(), t.recovery.transcript.refresh(), t.recovery.activity.refresh();
|
|
@@ -2914,7 +2923,7 @@ class Nr {
|
|
|
2914
2923
|
}
|
|
2915
2924
|
}
|
|
2916
2925
|
report(e) {
|
|
2917
|
-
!this.disposed &&
|
|
2926
|
+
!this.disposed && z(this.boundary) && this.options.onError(e);
|
|
2918
2927
|
}
|
|
2919
2928
|
dispose() {
|
|
2920
2929
|
this.disposed = !0;
|
|
@@ -3059,7 +3068,7 @@ function Hr(s, e, t = () => crypto.randomUUID()) {
|
|
|
3059
3068
|
};
|
|
3060
3069
|
}
|
|
3061
3070
|
}
|
|
3062
|
-
class
|
|
3071
|
+
class $ extends EventTarget {
|
|
3063
3072
|
constructor(e) {
|
|
3064
3073
|
super(), this.options = e, this.httpTransport = new Gi(e), this.transport = new Ur({
|
|
3065
3074
|
backendUrl: e.backendUrl,
|
|
@@ -3136,6 +3145,13 @@ class K extends EventTarget {
|
|
|
3136
3145
|
}
|
|
3137
3146
|
});
|
|
3138
3147
|
}
|
|
3148
|
+
async sendRetainedCommand(e) {
|
|
3149
|
+
try {
|
|
3150
|
+
return await this.transport.rpc(e.type, Object.fromEntries(Object.entries(e).filter(([t]) => t !== "type"))), !0;
|
|
3151
|
+
} catch (t) {
|
|
3152
|
+
return t instanceof v && t.code === "backpressure" && !t.backendRefusal || this.fail(t, e), t instanceof v && t.backendRefusal;
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3139
3155
|
receive(e) {
|
|
3140
3156
|
const t = new MessageEvent("message", { data: JSON.stringify(e) });
|
|
3141
3157
|
this.readyState !== 3 && this.dispatchEvent(t), this.toolReceipts.get(e)?.(this.readyState !== 3 && this.acceptedMessages.has(t)), this.toolReceipts.delete(e);
|
|
@@ -3152,13 +3168,15 @@ class K extends EventTarget {
|
|
|
3152
3168
|
}
|
|
3153
3169
|
buffer(e, t) {
|
|
3154
3170
|
if (e.length >= 128) {
|
|
3155
|
-
this.fail(new
|
|
3171
|
+
this.fail(new v("Product Agent delivery buffer is full", "backpressure")), this.close();
|
|
3156
3172
|
return;
|
|
3157
3173
|
}
|
|
3158
3174
|
e.push(t);
|
|
3159
3175
|
}
|
|
3160
3176
|
fail(e, t, i = !1) {
|
|
3161
|
-
const n = e instanceof
|
|
3177
|
+
const n = e instanceof v ? e : new v(String(e), "request_failed");
|
|
3178
|
+
if (n.code === "disconnected" || n.outcomeUnknown) return;
|
|
3179
|
+
const r = n.detail && typeof n.detail == "object" ? n.detail : {};
|
|
3162
3180
|
this.options.auth.client_kind === "extension" && n.code === "update_required" && r.version_status && this.receive(r.version_status), this.receive({
|
|
3163
3181
|
...r,
|
|
3164
3182
|
type: "error",
|
|
@@ -3350,7 +3368,7 @@ function zr(s, e) {
|
|
|
3350
3368
|
updatedAt: t ? s.updatedAt : null
|
|
3351
3369
|
};
|
|
3352
3370
|
}
|
|
3353
|
-
const Kr = 1e4, Vr =
|
|
3371
|
+
const Kr = 1e4, Vr = 3e3;
|
|
3354
3372
|
function en() {
|
|
3355
3373
|
return { authenticated: !1, generation: 0, sequence: 0, displaySequence: 0, backendCount: null, query: Zi("activeUsers") };
|
|
3356
3374
|
}
|
|
@@ -3559,7 +3577,7 @@ function ts(s) {
|
|
|
3559
3577
|
queries: Object.fromEntries(Object.entries(s.queries).map(([e, t]) => [e, { ...t, invalidated: !0 }]))
|
|
3560
3578
|
};
|
|
3561
3579
|
}
|
|
3562
|
-
function
|
|
3580
|
+
function Et(s, e, t) {
|
|
3563
3581
|
if (e.conversation_id !== e.conversation.id || !Number.isSafeInteger(e.version) || e.version < 0)
|
|
3564
3582
|
throw new Error("Invalid conversation metadata envelope identity or version.");
|
|
3565
3583
|
const i = s.entities[e.conversation_id];
|
|
@@ -3583,7 +3601,7 @@ function eo(s, e) {
|
|
|
3583
3601
|
if (e.type === "effect.failed")
|
|
3584
3602
|
t = { ...t, queries: { ...t.queries, [o]: { ...a, status: "error", error: { ...e.error }, requestId: null } } };
|
|
3585
3603
|
else if (e.effectKind === "directory.query") {
|
|
3586
|
-
for (const p of e.output.entries) t =
|
|
3604
|
+
for (const p of e.output.entries) t = Et(t, p, !0);
|
|
3587
3605
|
const c = e.output.entries.map((p) => p.conversation_id), l = { ...t.durableActivityBySessionId }, d = { ...t.activityBySessionId }, u = { ...t.activityRevisionBySessionId };
|
|
3588
3606
|
for (const p of e.output.entries) {
|
|
3589
3607
|
if (typeof p.is_active != "boolean") continue;
|
|
@@ -3610,7 +3628,7 @@ function eo(s, e) {
|
|
|
3610
3628
|
} else {
|
|
3611
3629
|
if (e.type === "effect.completed" && e.effectKind === "directory.mutate") {
|
|
3612
3630
|
if (e.output.conversation_id !== n.input.sessionId) throw new Error("Mutation response has the wrong conversation identity.");
|
|
3613
|
-
t =
|
|
3631
|
+
t = Et(t, e.output, !0);
|
|
3614
3632
|
}
|
|
3615
3633
|
const o = { ...t.mutations[n.input.sessionId] };
|
|
3616
3634
|
for (const a of ["title", "pinned"]) {
|
|
@@ -3623,7 +3641,7 @@ function eo(s, e) {
|
|
|
3623
3641
|
if (e.authorityId !== s.authorityId || e.generation !== s.generation)
|
|
3624
3642
|
return { state: s, effects: i };
|
|
3625
3643
|
if (e.type === "directory.metadata_received")
|
|
3626
|
-
t =
|
|
3644
|
+
t = Et(s, e.metadata, !0);
|
|
3627
3645
|
else if (e.type === "directory.invalidate")
|
|
3628
3646
|
t = ts(s);
|
|
3629
3647
|
else if (e.type === "directory.optimistic_upsert")
|
|
@@ -4155,7 +4173,7 @@ function Js(s, e, t, i) {
|
|
|
4155
4173
|
});
|
|
4156
4174
|
}
|
|
4157
4175
|
const Pt = "pluno.productAgent.transportId", Ao = "pluno.productAgent.transportIdentity", Dt = "pluno.productAgent.transportIdentity.event", Ro = 50, ko = globalThis.setTimeout.bind(globalThis);
|
|
4158
|
-
let
|
|
4176
|
+
let Ee = null;
|
|
4159
4177
|
const ct = /* @__PURE__ */ new Set(), Ut = /* @__PURE__ */ new Map();
|
|
4160
4178
|
async function Mo(s = rn()) {
|
|
4161
4179
|
const e = s.randomUUID(), t = s.storage.getItem(Pt);
|
|
@@ -4195,17 +4213,17 @@ async function Mo(s = rn()) {
|
|
|
4195
4213
|
}
|
|
4196
4214
|
};
|
|
4197
4215
|
}
|
|
4198
|
-
async function
|
|
4199
|
-
|
|
4216
|
+
async function Co(s = !1) {
|
|
4217
|
+
Ee || (Ee = Mo({
|
|
4200
4218
|
...rn(),
|
|
4201
4219
|
skipStoredIdentityCollisionCheck: s
|
|
4202
|
-
}),
|
|
4220
|
+
}), Ee.then((n) => {
|
|
4203
4221
|
const r = (o) => {
|
|
4204
|
-
o.persisted || (n.release(),
|
|
4222
|
+
o.persisted || (n.release(), Ee = null, ct.clear(), window.removeEventListener("pagehide", r));
|
|
4205
4223
|
};
|
|
4206
4224
|
window.addEventListener("pagehide", r);
|
|
4207
4225
|
}));
|
|
4208
|
-
const e = await
|
|
4226
|
+
const e = await Ee, t = Eo();
|
|
4209
4227
|
ct.add(t);
|
|
4210
4228
|
let i = !1;
|
|
4211
4229
|
return {
|
|
@@ -4216,7 +4234,7 @@ async function Eo(s = !1) {
|
|
|
4216
4234
|
}
|
|
4217
4235
|
};
|
|
4218
4236
|
}
|
|
4219
|
-
function
|
|
4237
|
+
function Eo() {
|
|
4220
4238
|
let s = 0;
|
|
4221
4239
|
for (; ct.has(s); )
|
|
4222
4240
|
s += 1;
|
|
@@ -5482,7 +5500,7 @@ const la = "https://app.pluno.ai", da = 2e4, ua = 1e4, ha = 6e4, pa = 6e4, fa =
|
|
|
5482
5500
|
".pdf:application/pdf",
|
|
5483
5501
|
".png:image/png",
|
|
5484
5502
|
".webp:image/webp"
|
|
5485
|
-
]), Kl = ".pdf,.png,.jpg,.jpeg,.webp", As = 64e3, Bt = 4e3, Rs = 30, ka = 2e3, Ma = 1e3, pn = "Image is too large for model vision input.",
|
|
5503
|
+
]), Kl = ".pdf,.png,.jpg,.jpeg,.webp", As = 64e3, Bt = 4e3, Rs = 30, ka = 2e3, Ma = 1e3, pn = "Image is too large for model vision input.", Ca = 100, Ea = 20, fn = "pluno.productAgent.state.", as = "pluno.productAgent.pendingEvents.", gn = "pluno.productAgent.pendingDeliveryRecovery.", bt = "pluno.productAgent.activeToolCalls.", Pa = 100;
|
|
5486
5504
|
function Da(s, e = 0) {
|
|
5487
5505
|
const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
|
|
5488
5506
|
return Math.max(e, t);
|
|
@@ -5599,7 +5617,7 @@ class vt {
|
|
|
5599
5617
|
);
|
|
5600
5618
|
if (r?.clientMessageId) {
|
|
5601
5619
|
this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending";
|
|
5602
|
-
const o =
|
|
5620
|
+
const o = Ei(e.clientId);
|
|
5603
5621
|
o?.clientMessageId === r.clientMessageId && (this.retryAttemptsByClientMessageId[o.clientMessageId] = o.retryAttempts, this.pendingDeliveryIssued = o.deliveryIssued, this.queuedDeliveryRetryAttempt = o.queuedRetryAttempt, o.missedResponseChecks < Je && this.startFirstResponseTimer(
|
|
5604
5622
|
o.clientMessageId,
|
|
5605
5623
|
o.submittedAt,
|
|
@@ -5607,7 +5625,7 @@ class vt {
|
|
|
5607
5625
|
));
|
|
5608
5626
|
} else
|
|
5609
5627
|
et(e.clientId, null);
|
|
5610
|
-
|
|
5628
|
+
W(e.clientId, this.queuedClientEvents);
|
|
5611
5629
|
}
|
|
5612
5630
|
options;
|
|
5613
5631
|
clientRuntime;
|
|
@@ -5633,6 +5651,7 @@ class vt {
|
|
|
5633
5651
|
networkBatchTimer = null;
|
|
5634
5652
|
queuedNetworkEvents = [];
|
|
5635
5653
|
queuedClientEvents = [];
|
|
5654
|
+
pendingRetainedCommandDeliveries = /* @__PURE__ */ new Set();
|
|
5636
5655
|
pendingWidgetLifecycleEvents = [];
|
|
5637
5656
|
pendingPassiveWarmupEvent = null;
|
|
5638
5657
|
pendingComposerWarmup = null;
|
|
@@ -5755,7 +5774,7 @@ class vt {
|
|
|
5755
5774
|
lastErrorSecuritySettingsUrl: null
|
|
5756
5775
|
};
|
|
5757
5776
|
static async init(e) {
|
|
5758
|
-
const t = e, i = await
|
|
5777
|
+
const t = e, i = await Co(
|
|
5759
5778
|
t.skipStoredTransportIdentityCollisionCheck === !0
|
|
5760
5779
|
), n = new vt({
|
|
5761
5780
|
...e,
|
|
@@ -5842,13 +5861,13 @@ class vt {
|
|
|
5842
5861
|
socket: {
|
|
5843
5862
|
retain: async (t, i) => {
|
|
5844
5863
|
const n = this.socket;
|
|
5845
|
-
n instanceof
|
|
5864
|
+
n instanceof $ && await n.directoryRooms.retain(t, i).catch((r) => {
|
|
5846
5865
|
if (this.socket === n) throw r;
|
|
5847
5866
|
});
|
|
5848
5867
|
},
|
|
5849
5868
|
release: async (t, i) => {
|
|
5850
5869
|
const n = this.socket;
|
|
5851
|
-
n instanceof
|
|
5870
|
+
n instanceof $ && await n.directoryRooms.release(t, i).catch((r) => {
|
|
5852
5871
|
if (this.socket === n) throw r;
|
|
5853
5872
|
});
|
|
5854
5873
|
}
|
|
@@ -5886,7 +5905,7 @@ class vt {
|
|
|
5886
5905
|
)), await this.directoryScope.persist());
|
|
5887
5906
|
}
|
|
5888
5907
|
handleDirectoryTransportError(e) {
|
|
5889
|
-
if (!(e instanceof
|
|
5908
|
+
if (!(e instanceof v) || e.code !== "unauthorized" && e.code !== "update_required") return;
|
|
5890
5909
|
const t = e.detail && typeof e.detail == "object" ? e.detail : {};
|
|
5891
5910
|
this.handleServerEvent({
|
|
5892
5911
|
...t,
|
|
@@ -6007,11 +6026,11 @@ class vt {
|
|
|
6007
6026
|
this.setState({ status: "error", lastError: t });
|
|
6008
6027
|
return;
|
|
6009
6028
|
}
|
|
6010
|
-
if (this.socket instanceof
|
|
6029
|
+
if (this.socket instanceof $) {
|
|
6011
6030
|
await this.replaceDefaultTransportCredentials(this.socket);
|
|
6012
6031
|
return;
|
|
6013
6032
|
}
|
|
6014
|
-
const i = ic(this.options.backendUrl), n = this.options.webSocketFactory?.(i) ?? new
|
|
6033
|
+
const i = ic(this.options.backendUrl), n = this.options.webSocketFactory?.(i) ?? new $({
|
|
6015
6034
|
backendUrl: this.options.backendUrl,
|
|
6016
6035
|
auth: {
|
|
6017
6036
|
protocol: 1,
|
|
@@ -6050,19 +6069,19 @@ class vt {
|
|
|
6050
6069
|
if (this.socket !== n)
|
|
6051
6070
|
return;
|
|
6052
6071
|
const o = pc(r.data);
|
|
6053
|
-
if (n instanceof
|
|
6072
|
+
if (n instanceof $ && o.type === "tool.call" && !hc(o)) {
|
|
6054
6073
|
this.handleServerEvent({ type: "error", message: "Invalid tool-call envelope" });
|
|
6055
6074
|
return;
|
|
6056
6075
|
}
|
|
6057
6076
|
const a = this.handleServerEvent(o);
|
|
6058
|
-
n instanceof
|
|
6077
|
+
n instanceof $ && o.type === "tool.call" && a === !0 && n.acceptMessage(r);
|
|
6059
6078
|
}), n.addEventListener("sendfailure", (r) => {
|
|
6060
6079
|
if (this.socket !== n)
|
|
6061
6080
|
return;
|
|
6062
6081
|
const o = fc(r?.detail?.data);
|
|
6063
6082
|
o?.type === "chat.user_message" && o.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
6064
6083
|
(a) => a.type === "chat.user_message" && a.clientMessageId === o.clientMessageId
|
|
6065
|
-
) && (this.queuedClientEvents.push(o),
|
|
6084
|
+
) && (this.queuedClientEvents.push(o), W(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
6066
6085
|
}), n.addEventListener("close", (r) => {
|
|
6067
6086
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
6068
6087
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -6083,7 +6102,7 @@ class vt {
|
|
|
6083
6102
|
} catch (i) {
|
|
6084
6103
|
if (e !== this.connectionAttemptId || this.state.status === "closed")
|
|
6085
6104
|
return;
|
|
6086
|
-
if (i instanceof
|
|
6105
|
+
if (i instanceof v && (i.code === "unauthorized" || i.code === "update_required")) {
|
|
6087
6106
|
this.handleDirectoryTransportError(i);
|
|
6088
6107
|
return;
|
|
6089
6108
|
}
|
|
@@ -6467,7 +6486,7 @@ class vt {
|
|
|
6467
6486
|
for (const n of [this.pendingClientMessageId, this.activeClientMessageId])
|
|
6468
6487
|
n && (this.cancelledSubmissions.set(n, this.state.sessionId), this.clearFirstResponseTimer(n));
|
|
6469
6488
|
for (; this.cancelledSubmissions.size > 100; ) this.cancelledSubmissions.delete(this.cancelledSubmissions.keys().next().value);
|
|
6470
|
-
this.queuedClientEvents = this.queuedClientEvents.filter((n) => !("clientMessageId" in n && typeof n.clientMessageId == "string" && this.cancelledSubmissions.has(n.clientMessageId))),
|
|
6489
|
+
this.queuedClientEvents = this.queuedClientEvents.filter((n) => !("clientMessageId" in n && typeof n.clientMessageId == "string" && this.cancelledSubmissions.has(n.clientMessageId))), W(this.options.clientId, this.queuedClientEvents);
|
|
6471
6490
|
const e = this.getStopClientMessageId();
|
|
6472
6491
|
this.state.sessionId && e && this.send({ type: "run.stop", sessionId: this.state.sessionId, expectedUserMessageId: e, reason: "user_requested" });
|
|
6473
6492
|
const t = this.pendingClientMessageId, i = Ri(
|
|
@@ -6521,7 +6540,7 @@ class vt {
|
|
|
6521
6540
|
}
|
|
6522
6541
|
for (const [n, r] of this.cancelledSubmissions)
|
|
6523
6542
|
r === this.state.sessionId && this.detachedClientMessageIds.add(n);
|
|
6524
|
-
this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"),
|
|
6543
|
+
this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), W(this.options.clientId, this.queuedClientEvents), et(this.options.clientId, null), this.pendingDeliveryIssued = !1, this.queuedDeliveryRetryAttempt = null, this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.clientRuntime.engine.dispatch({ type: "model.scope_navigate", clientScopeId: this.modelClientScopeId, sessionId: null }), t && this.send({
|
|
6525
6544
|
type: "session.reset",
|
|
6526
6545
|
sessionId: this.state.sessionId ?? void 0,
|
|
6527
6546
|
warmupId: i ?? void 0,
|
|
@@ -7039,10 +7058,10 @@ class vt {
|
|
|
7039
7058
|
});
|
|
7040
7059
|
}
|
|
7041
7060
|
send(e) {
|
|
7042
|
-
const t = this.sendNow(
|
|
7061
|
+
const t = this.sendNow(V(e));
|
|
7043
7062
|
return t || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
7044
7063
|
(n) => n.type === "chat.user_message" && n.clientMessageId === e.clientMessageId
|
|
7045
|
-
) || this.queuedClientEvents.push(e),
|
|
7064
|
+
) || this.queuedClientEvents.push(e), W(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
7046
7065
|
status: "reconnecting",
|
|
7047
7066
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
7048
7067
|
}), this.scheduleReconnect()), t;
|
|
@@ -7059,6 +7078,12 @@ class vt {
|
|
|
7059
7078
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
7060
7079
|
return !1;
|
|
7061
7080
|
const t = this.socket;
|
|
7081
|
+
if ((e.type === "tool.result" || e.type === "run.stop") && t instanceof $) {
|
|
7082
|
+
const i = this.queuedClientEvents.find((n) => "sessionId" in n && n.sessionId === e.sessionId && (e.type === "tool.result" && n.type === "tool.result" && n.callId === e.callId || e.type === "run.stop" && n.type === "run.stop" && n.expectedUserMessageId === e.expectedUserMessageId)) ?? e;
|
|
7083
|
+
return this.queuedClientEvents.includes(i) || this.queuedClientEvents.push(i), W(this.options.clientId, this.queuedClientEvents), this.pendingRetainedCommandDeliveries.has(i) || (this.pendingRetainedCommandDeliveries.add(i), t.sendRetainedCommand(V(i)).then((n) => {
|
|
7084
|
+
this.pendingRetainedCommandDeliveries.delete(i), n && (this.queuedClientEvents = this.queuedClientEvents.filter((r) => r !== i), W(this.options.clientId, this.queuedClientEvents));
|
|
7085
|
+
})), !0;
|
|
7086
|
+
}
|
|
7062
7087
|
try {
|
|
7063
7088
|
return t.send(JSON.stringify(e)), Qe("client_event", e.type, ni(e)), !0;
|
|
7064
7089
|
} catch (i) {
|
|
@@ -7171,13 +7196,13 @@ class vt {
|
|
|
7171
7196
|
rememberPendingDeliveryForRecovery(e) {
|
|
7172
7197
|
this.queuedClientEvents.some(
|
|
7173
7198
|
(t) => t.type === "chat.user_message" && t.clientMessageId === e.clientMessageId
|
|
7174
|
-
) || (this.queuedClientEvents.push(e),
|
|
7199
|
+
) || (this.queuedClientEvents.push(e), W(this.options.clientId, this.queuedClientEvents)), this.persistCurrentPendingDeliveryRecovery();
|
|
7175
7200
|
}
|
|
7176
7201
|
persistCurrentPendingDeliveryRecovery() {
|
|
7177
7202
|
const e = this.pendingClientMessageId, t = e ? this.firstResponseTimersByClientMessageId.get(e) : null;
|
|
7178
7203
|
if (!e)
|
|
7179
7204
|
return;
|
|
7180
|
-
const i =
|
|
7205
|
+
const i = Ei(this.options.clientId);
|
|
7181
7206
|
!t && i?.clientMessageId !== e || et(this.options.clientId, {
|
|
7182
7207
|
clientMessageId: e,
|
|
7183
7208
|
retryAttempts: this.retryAttemptsByClientMessageId[e] ?? 0,
|
|
@@ -7190,7 +7215,7 @@ class vt {
|
|
|
7190
7215
|
clearPersistedPendingDelivery(e) {
|
|
7191
7216
|
this.queuedClientEvents = this.queuedClientEvents.filter(
|
|
7192
7217
|
(t) => t.type !== "chat.user_message" || t.clientMessageId !== e
|
|
7193
|
-
),
|
|
7218
|
+
), W(this.options.clientId, this.queuedClientEvents), et(this.options.clientId, null), this.pendingDeliveryIssued = !1, this.queuedDeliveryRetryAttempt = null;
|
|
7194
7219
|
}
|
|
7195
7220
|
/** @internal */
|
|
7196
7221
|
reportTransportDiagnostic(e, t = {}) {
|
|
@@ -7290,7 +7315,7 @@ class vt {
|
|
|
7290
7315
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
7291
7316
|
const e = nc();
|
|
7292
7317
|
this.sendNow(
|
|
7293
|
-
|
|
7318
|
+
V({
|
|
7294
7319
|
type: "starter_prompts.page_context",
|
|
7295
7320
|
pageUrl: e.pageUrl,
|
|
7296
7321
|
pageTitle: e.pageTitle,
|
|
@@ -7319,22 +7344,22 @@ class vt {
|
|
|
7319
7344
|
flushQueuedClientEvents() {
|
|
7320
7345
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
7321
7346
|
return;
|
|
7322
|
-
const e = this.queuedClientEvents
|
|
7323
|
-
|
|
7347
|
+
const e = [...this.queuedClientEvents];
|
|
7348
|
+
this.queuedClientEvents = this.queuedClientEvents.filter((t) => (t.type === "tool.result" || t.type === "run.stop") && this.socket instanceof $), W(this.options.clientId, this.queuedClientEvents);
|
|
7324
7349
|
for (let t = 0; t < e.length; t += 1) {
|
|
7325
7350
|
const i = e[t];
|
|
7326
|
-
if (!this.sendNow(
|
|
7327
|
-
this.queuedClientEvents.unshift(
|
|
7351
|
+
if (!this.sendNow(V(i))) {
|
|
7352
|
+
this.queuedClientEvents.unshift(...e.slice(t).filter((n) => !this.queuedClientEvents.includes(n))), W(this.options.clientId, this.queuedClientEvents);
|
|
7328
7353
|
return;
|
|
7329
7354
|
}
|
|
7330
|
-
i.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && (this.queuedDeliveryRetryAttempt !== null ? (this.retryAttemptsByClientMessageId[i.clientMessageId] = this.queuedDeliveryRetryAttempt, this.queuedDeliveryRetryAttempt = null) : this.pendingDeliveryIssued && (this.retryAttemptsByClientMessageId[i.clientMessageId] = (this.retryAttemptsByClientMessageId[i.clientMessageId] ?? 0) + 1), this.pendingDeliveryIssued = !0, this.setState({ pendingMessageStatus: "sending" }), this.queuedClientEvents.push(i), this.persistCurrentPendingDeliveryRecovery(), this.schedulePendingDeliveryAck(i.clientMessageId)),
|
|
7355
|
+
i.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && (this.queuedDeliveryRetryAttempt !== null ? (this.retryAttemptsByClientMessageId[i.clientMessageId] = this.queuedDeliveryRetryAttempt, this.queuedDeliveryRetryAttempt = null) : this.pendingDeliveryIssued && (this.retryAttemptsByClientMessageId[i.clientMessageId] = (this.retryAttemptsByClientMessageId[i.clientMessageId] ?? 0) + 1), this.pendingDeliveryIssued = !0, this.setState({ pendingMessageStatus: "sending" }), this.queuedClientEvents.push(i), this.persistCurrentPendingDeliveryRecovery(), this.schedulePendingDeliveryAck(i.clientMessageId)), W(this.options.clientId, this.queuedClientEvents);
|
|
7331
7356
|
}
|
|
7332
7357
|
}
|
|
7333
7358
|
resetForAuthenticationScopeChange() {
|
|
7334
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
7359
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], W(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear(), this.sessionTimelineCache.clear();
|
|
7335
7360
|
}
|
|
7336
7361
|
applyAuthenticatedDirectoryIdentity(e) {
|
|
7337
|
-
const t = Ii(e), i = R(e, "runtimeCommunityId") ?? this.directoryHttp.auth.community_id, n = !!(this.authenticatedUserId && t && (this.socket instanceof
|
|
7362
|
+
const t = Ii(e), i = R(e, "runtimeCommunityId") ?? this.directoryHttp.auth.community_id, n = !!(this.authenticatedUserId && t && (this.socket instanceof $ || this.authenticatedSocket !== this.socket) && (this.authenticatedUserId !== t.id || this.directoryHttp.auth.community_id !== i));
|
|
7338
7363
|
if (n) {
|
|
7339
7364
|
const r = this.directoryAuthority;
|
|
7340
7365
|
this.directoryObservation.dispose(), this.directoryAuthority = { ...r, generation: r.generation + 1 }, this.clientRuntime.engine.dispatch({
|
|
@@ -7349,7 +7374,7 @@ class vt {
|
|
|
7349
7374
|
}
|
|
7350
7375
|
rememberSessionTimeline(e, t) {
|
|
7351
7376
|
const i = [...t];
|
|
7352
|
-
for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, i); this.sessionTimelineCache.size >
|
|
7377
|
+
for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, i); this.sessionTimelineCache.size > Ea; ) {
|
|
7353
7378
|
const n = this.sessionTimelineCache.keys().next().value;
|
|
7354
7379
|
if (!n)
|
|
7355
7380
|
break;
|
|
@@ -7403,7 +7428,7 @@ class vt {
|
|
|
7403
7428
|
const i = q(t);
|
|
7404
7429
|
if (!e || !i || !xe(i) || this.findStoppedTurn(e, i))
|
|
7405
7430
|
return;
|
|
7406
|
-
const n = H(i), r =
|
|
7431
|
+
const n = H(i), r = C(i), o = typeof i.clientMessageId == "string" ? i.clientMessageId : n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null;
|
|
7407
7432
|
this.stoppedTurns.push({
|
|
7408
7433
|
sessionId: e,
|
|
7409
7434
|
clientMessageId: o,
|
|
@@ -7554,7 +7579,7 @@ class vt {
|
|
|
7554
7579
|
type: "directory.activity_set",
|
|
7555
7580
|
sessionId: i,
|
|
7556
7581
|
active: !1
|
|
7557
|
-
}), this.socket instanceof
|
|
7582
|
+
}), this.socket instanceof $ && this.socket.synchronizeReferences()), t)
|
|
7558
7583
|
return;
|
|
7559
7584
|
const n = pi(e), r = this.pendingClientMessageId, o = n ? this.getResponseEvidenceClientMessageId(e) : null, a = n ? this.promotePendingDeliveryFromResponseEvidence(e) : !1;
|
|
7560
7585
|
if (n) {
|
|
@@ -7653,19 +7678,19 @@ class vt {
|
|
|
7653
7678
|
const N = w !== void 0;
|
|
7654
7679
|
this.rememberUserMessageClientMessageIds(S);
|
|
7655
7680
|
const se = Fc(S), He = S.filter((j) => {
|
|
7656
|
-
const
|
|
7657
|
-
return Lc(
|
|
7681
|
+
const K = q(j);
|
|
7682
|
+
return Lc(K) ? !1 : !K || !se || !Le(K) ? !0 : us(S, K) !== se;
|
|
7658
7683
|
}), ve = cs(
|
|
7659
7684
|
this.state.messages,
|
|
7660
7685
|
Wt(He, this.options.backendUrl)
|
|
7661
7686
|
), ue = zt(ve), he = N ? w?.content ?? "" : this.state.assistantDraft, Te = N ? w?.itemId ?? null : this.state.assistantDraftItemId, je = N ? w?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, $e = N ? w?.runId ?? null : this.state.assistantDraftRunId, pe = S.some(
|
|
7662
|
-
(j,
|
|
7687
|
+
(j, K) => _i(
|
|
7663
7688
|
q(j),
|
|
7664
7689
|
he,
|
|
7665
7690
|
Te,
|
|
7666
7691
|
je,
|
|
7667
7692
|
$e,
|
|
7668
|
-
Hc(S,
|
|
7693
|
+
Hc(S, K)
|
|
7669
7694
|
)
|
|
7670
7695
|
), _e = N ? w?.content ?? "" : this.state.assistantDraft, Ae = !!w?.content && !pe;
|
|
7671
7696
|
this.promotePendingDeliveryFromSnapshotResponseEvidence(S, u);
|
|
@@ -7726,8 +7751,8 @@ class vt {
|
|
|
7726
7751
|
else if (!m && (Ae || ce)) {
|
|
7727
7752
|
if (ce) {
|
|
7728
7753
|
this.activeClientMessageId = ce;
|
|
7729
|
-
const j = Se(S),
|
|
7730
|
-
this.activeResponseUserMessageId = R(
|
|
7754
|
+
const j = Se(S), K = j === null ? null : S[j];
|
|
7755
|
+
this.activeResponseUserMessageId = R(K, "id");
|
|
7731
7756
|
}
|
|
7732
7757
|
this.markThinkingProgress();
|
|
7733
7758
|
}
|
|
@@ -7924,7 +7949,7 @@ class vt {
|
|
|
7924
7949
|
if ((e.code === "unauthorized" || e.code === "401") && e.reason === "token_expired" && e.retryable === !0 && this.options.tokenProvider) {
|
|
7925
7950
|
this.invalidateProviderToken(), this.clearSocketPhaseTimers(), this.stopHeartbeat();
|
|
7926
7951
|
const g = this.socket;
|
|
7927
|
-
this.setReconnectingState(), g instanceof
|
|
7952
|
+
this.setReconnectingState(), g instanceof $ ? (this.refreshingDefaultCredentials = !0, g.pause(), this.refreshDefaultTransportCredentials(g)) : (this.socket = null, this.scheduleReconnect(), g?.close());
|
|
7928
7953
|
return;
|
|
7929
7954
|
}
|
|
7930
7955
|
if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "update_required" || e.code === "executor_replaced")) {
|
|
@@ -8298,7 +8323,7 @@ class vt {
|
|
|
8298
8323
|
i,
|
|
8299
8324
|
t,
|
|
8300
8325
|
o,
|
|
8301
|
-
|
|
8326
|
+
C(r)
|
|
8302
8327
|
), this.clearFirstResponseTimer(i);
|
|
8303
8328
|
return;
|
|
8304
8329
|
}
|
|
@@ -8452,16 +8477,22 @@ class vt {
|
|
|
8452
8477
|
), o = e.rawInput;
|
|
8453
8478
|
if (!t || !i || !n)
|
|
8454
8479
|
return;
|
|
8455
|
-
const a =
|
|
8456
|
-
if (
|
|
8480
|
+
const a = this.queuedClientEvents.find((h) => h.type === "tool.result" && h.sessionId === t && h.callId === i);
|
|
8481
|
+
if (a) {
|
|
8482
|
+
this.sendNow(a);
|
|
8483
|
+
return;
|
|
8484
|
+
}
|
|
8485
|
+
if (this.activeBrowserToolCalls.has(i)) return;
|
|
8486
|
+
const c = n === "execute_code", l = n === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
8487
|
+
if (!c && !l || !gl(o)) {
|
|
8457
8488
|
this.setToolMessageLoading(i, !1), this.send({
|
|
8458
8489
|
type: "tool.result",
|
|
8459
8490
|
sessionId: t,
|
|
8460
8491
|
callId: i,
|
|
8461
8492
|
toolName: n,
|
|
8462
8493
|
summary: r,
|
|
8463
|
-
rawInput:
|
|
8464
|
-
rawOutput:
|
|
8494
|
+
rawInput: V(o),
|
|
8495
|
+
rawOutput: V({
|
|
8465
8496
|
ok: !1,
|
|
8466
8497
|
toolName: n,
|
|
8467
8498
|
error: `Unsupported browser tool: ${n}`
|
|
@@ -8476,7 +8507,7 @@ class vt {
|
|
|
8476
8507
|
callId: i,
|
|
8477
8508
|
toolName: n,
|
|
8478
8509
|
summary: r,
|
|
8479
|
-
rawInput:
|
|
8510
|
+
rawInput: V(o),
|
|
8480
8511
|
rawOutput: {
|
|
8481
8512
|
ok: !1,
|
|
8482
8513
|
toolName: n,
|
|
@@ -8492,21 +8523,21 @@ class vt {
|
|
|
8492
8523
|
callId: i,
|
|
8493
8524
|
toolName: n,
|
|
8494
8525
|
summary: r,
|
|
8495
|
-
rawInput:
|
|
8526
|
+
rawInput: V(o),
|
|
8496
8527
|
rawOutput: null
|
|
8497
8528
|
},
|
|
8498
8529
|
startedAtMs: Date.now(),
|
|
8499
8530
|
startedAtUrl: location.href,
|
|
8500
8531
|
startedAtOrigin: location.origin
|
|
8501
8532
|
}), this.installSessionBrowserApis();
|
|
8502
|
-
let
|
|
8503
|
-
|
|
8533
|
+
let d = null, u;
|
|
8534
|
+
d = await this.executeRuntimeHelper(), u = await fi(
|
|
8504
8535
|
o,
|
|
8505
8536
|
Xa(e.runtimeContext, this.options.backendUrl)
|
|
8506
|
-
).catch((
|
|
8537
|
+
).catch((h) => ({
|
|
8507
8538
|
ok: !1,
|
|
8508
8539
|
exception: {
|
|
8509
|
-
message:
|
|
8540
|
+
message: h instanceof Error ? h.message : String(h)
|
|
8510
8541
|
}
|
|
8511
8542
|
})), this.activeBrowserToolCalls.has(i) && (this.activeBrowserToolCalls.delete(i), this.setToolMessageLoading(i, !1), this.send({
|
|
8512
8543
|
type: "tool.result",
|
|
@@ -8514,8 +8545,8 @@ class vt {
|
|
|
8514
8545
|
callId: i,
|
|
8515
8546
|
toolName: n,
|
|
8516
8547
|
summary: o.summary,
|
|
8517
|
-
rawInput:
|
|
8518
|
-
rawOutput:
|
|
8548
|
+
rawInput: V(o),
|
|
8549
|
+
rawOutput: V(Ic(u, d))
|
|
8519
8550
|
}), Pi(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
8520
8551
|
}
|
|
8521
8552
|
setToolMessageLoading(e, t) {
|
|
@@ -8575,7 +8606,7 @@ class vt {
|
|
|
8575
8606
|
Math.max(Ua(this.reconnectAttempts), e)
|
|
8576
8607
|
);
|
|
8577
8608
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
8578
|
-
this.reconnectTimer = null, (this.refreshingDefaultCredentials && this.socket instanceof
|
|
8609
|
+
this.reconnectTimer = null, (this.refreshingDefaultCredentials && this.socket instanceof $ ? this.refreshDefaultTransportCredentials(this.socket) : this.connect()).catch((n) => {
|
|
8579
8610
|
M("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
8580
8611
|
message: n instanceof Error ? n.message : String(n),
|
|
8581
8612
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
@@ -8611,7 +8642,7 @@ class vt {
|
|
|
8611
8642
|
this.token = t, this.directoryHttp.auth.token = t, await this.replaceDefaultTransportCredentials(e);
|
|
8612
8643
|
} catch (t) {
|
|
8613
8644
|
if (this.socket !== e || this.state.status === "closed") return;
|
|
8614
|
-
if (t instanceof
|
|
8645
|
+
if (t instanceof v && (t.code === "unauthorized" || t.code === "update_required")) {
|
|
8615
8646
|
this.handleDirectoryTransportError(t);
|
|
8616
8647
|
return;
|
|
8617
8648
|
}
|
|
@@ -8674,7 +8705,7 @@ class vt {
|
|
|
8674
8705
|
reason: "active_turn_phase_moved_backward",
|
|
8675
8706
|
previousPhase: this.lastProjectedTurnPhase,
|
|
8676
8707
|
nextPhase: o.turnPhase
|
|
8677
|
-
}), this.state = o, this.clientRuntime.engine.dispatch({ type: "activeUsers.authenticate", authenticated: !!(this.token && this.state.user && this.state.status !== "closed") }), this.socket instanceof
|
|
8708
|
+
}), this.state = o, this.clientRuntime.engine.dispatch({ type: "activeUsers.authenticate", authenticated: !!(this.token && this.state.user && this.state.status !== "closed") }), this.socket instanceof $ && this.socket.synchronizeReferences(), this.lastProjectedTurnClientMessageId = d, this.lastProjectedTurnPhase = o.turnPhase, o.sessionId && (o.sessionId === a && l !== c || o.sessionId !== a && l) && (this.clientRuntime.engine.dispatch({
|
|
8678
8709
|
...this.directoryAuthority,
|
|
8679
8710
|
type: "directory.activity_set",
|
|
8680
8711
|
sessionId: o.sessionId,
|
|
@@ -8753,7 +8784,7 @@ function xa() {
|
|
|
8753
8784
|
throw b;
|
|
8754
8785
|
}
|
|
8755
8786
|
try {
|
|
8756
|
-
const b = f instanceof Request ? f : null, g = yl(f, b), m =
|
|
8787
|
+
const b = f instanceof Request ? f : null, g = yl(f, b), m = Cn(p?.headers ?? b?.headers);
|
|
8757
8788
|
if (!fe(g, m, p?.body)) {
|
|
8758
8789
|
const P = {
|
|
8759
8790
|
requestId: Kt("fetch"),
|
|
@@ -8799,7 +8830,7 @@ function xa() {
|
|
|
8799
8830
|
}), g;
|
|
8800
8831
|
}, c = function(f, p) {
|
|
8801
8832
|
const y = n.call(this, f, p), I = Ht.get(this);
|
|
8802
|
-
return I && Object.keys(I.requestHeaders).length < Rs && (I.requestHeaders[f] =
|
|
8833
|
+
return I && Object.keys(I.requestHeaders).length < Rs && (I.requestHeaders[f] = Es(f, p), I.excluded = I.excluded || fe(I.url, I.requestHeaders)), y;
|
|
8803
8834
|
}, l = function(f) {
|
|
8804
8835
|
try {
|
|
8805
8836
|
const p = Ht.get(this);
|
|
@@ -9362,55 +9393,55 @@ function cc(s, e) {
|
|
|
9362
9393
|
if (f >= 1e3 && !se || P.has(k) || r.has(w) || k.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || N.display === "none" || N.visibility === "hidden")
|
|
9363
9394
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
9364
9395
|
f += 1;
|
|
9365
|
-
const He = p(k), be = In(k), ve = a.has(He) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(w) || w === "a" && k.hasAttribute("href"), ue = Array.from(k.children).filter((
|
|
9366
|
-
for (const
|
|
9367
|
-
const U = y(
|
|
9396
|
+
const He = p(k), be = In(k), ve = a.has(He) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(w) || w === "a" && k.hasAttribute("href"), ue = Array.from(k.children).filter((_) => _ instanceof HTMLElement), he = /* @__PURE__ */ new Map();
|
|
9397
|
+
for (const _ of ue) {
|
|
9398
|
+
const U = y(_);
|
|
9368
9399
|
he.set(U, (he.get(U) ?? 0) + 1);
|
|
9369
9400
|
}
|
|
9370
9401
|
const Te = /* @__PURE__ */ new Map(), je = /* @__PURE__ */ new Map();
|
|
9371
|
-
for (const
|
|
9372
|
-
const U = y(
|
|
9373
|
-
je.set(U, ie + 1), (he.get(U) ?? 0) > 8 && ie >= 6 && !d.has(
|
|
9402
|
+
for (const _ of ue) {
|
|
9403
|
+
const U = y(_), ie = je.get(U) ?? 0;
|
|
9404
|
+
je.set(U, ie + 1), (he.get(U) ?? 0) > 8 && ie >= 6 && !d.has(_) && Te.set(U, (Te.get(U) ?? 0) + 1);
|
|
9374
9405
|
}
|
|
9375
9406
|
const $e = /* @__PURE__ */ new Map(), pe = /* @__PURE__ */ new Set(), _e = [], Ae = [];
|
|
9376
|
-
for (const
|
|
9377
|
-
const U = y(
|
|
9378
|
-
if ($e.set(U, Ps + 1), ie > 8 && Ps >= 6 && !d.has(
|
|
9407
|
+
for (const _ of ue) {
|
|
9408
|
+
const U = y(_), ie = he.get(U) ?? 0, Ps = $e.get(U) ?? 0;
|
|
9409
|
+
if ($e.set(U, Ps + 1), ie > 8 && Ps >= 6 && !d.has(_)) {
|
|
9379
9410
|
pe.has(U) || (_e.push([`… ${Te.get(U) ?? 0} similar siblings omitted`]), pe.add(U));
|
|
9380
9411
|
continue;
|
|
9381
9412
|
}
|
|
9382
|
-
const Ds = D(
|
|
9413
|
+
const Ds = D(_, A);
|
|
9383
9414
|
Ae.push(Ds), _e.push(Ds.lines);
|
|
9384
9415
|
}
|
|
9385
9416
|
const Z = [];
|
|
9386
9417
|
if (k.shadowRoot)
|
|
9387
|
-
for (const
|
|
9388
|
-
|
|
9389
|
-
const ae = [...Ae, ...Z], We = be.length > 0 || ve || ae.some((
|
|
9390
|
-
[be, ...ae.map((
|
|
9391
|
-
).slice(0, 180), ce = k.hasAttribute("contenteditable") && (be.length > 0 || !k.querySelector("[contenteditable]")), j = l.some((
|
|
9392
|
-
if (
|
|
9393
|
-
const
|
|
9418
|
+
for (const _ of Array.from(k.shadowRoot.children))
|
|
9419
|
+
_ instanceof HTMLElement && Z.push(D(_, A + 1));
|
|
9420
|
+
const ae = [...Ae, ...Z], We = be.length > 0 || ve || ae.some((_) => _.hasUsefulContent), Re = Ie(
|
|
9421
|
+
[be, ...ae.map((_) => _.textPreview)].filter(Boolean).join(" ")
|
|
9422
|
+
).slice(0, 180), ce = k.hasAttribute("contenteditable") && (be.length > 0 || !k.querySelector("[contenteditable]")), j = l.some((_) => k.hasAttribute(_)) || !!He || ce, K = (k.getClientRects().length > 0 || N.display === "contents") && (t.has(w) || j || se) && (We || se) && (!n.has(w) || We || j || se), At = K ? 1 : 0, ke = [];
|
|
9423
|
+
if (K) {
|
|
9424
|
+
const _ = ae.some((ie) => ie.containsTextElement), U = i.has(w) && !_ ? Re : be;
|
|
9394
9425
|
ke.push(mn(k, c, o, U.slice(0, 180)));
|
|
9395
9426
|
}
|
|
9396
|
-
for (const
|
|
9397
|
-
ke.push(...Ye(
|
|
9398
|
-
const Rt = Z.flatMap((
|
|
9427
|
+
for (const _ of _e)
|
|
9428
|
+
ke.push(...Ye(_, At));
|
|
9429
|
+
const Rt = Z.flatMap((_) => _.lines);
|
|
9399
9430
|
if (Rt.length > 0) {
|
|
9400
|
-
const
|
|
9401
|
-
Rt.length >
|
|
9431
|
+
const _ = Rt.slice(0, 20);
|
|
9432
|
+
Rt.length > _.length && _.push("… shadow DOM omitted");
|
|
9402
9433
|
const U = w.includes("tooltip") || w.includes("popper") || w.includes("loader");
|
|
9403
9434
|
if (A < 2 && !U) {
|
|
9404
|
-
const ie =
|
|
9405
|
-
ke.push(...Ye([ie, ...Ye(
|
|
9435
|
+
const ie = K ? "#shadow-root" : `${w} #shadow-root`;
|
|
9436
|
+
ke.push(...Ye([ie, ...Ye(_, 1)], At));
|
|
9406
9437
|
} else
|
|
9407
|
-
ke.push(...Ye(
|
|
9438
|
+
ke.push(...Ye(_, At));
|
|
9408
9439
|
}
|
|
9409
9440
|
return {
|
|
9410
9441
|
lines: ke,
|
|
9411
9442
|
hasUsefulContent: We,
|
|
9412
9443
|
textPreview: Re,
|
|
9413
|
-
containsTextElement: i.has(w) || ae.some((
|
|
9444
|
+
containsTextElement: i.has(w) || ae.some((_) => _.containsTextElement)
|
|
9414
9445
|
};
|
|
9415
9446
|
};
|
|
9416
9447
|
return [`--- ${S} ---`, ...D(m, 0).lines].join(`
|
|
@@ -9691,7 +9722,7 @@ function ft(s, e) {
|
|
|
9691
9722
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9692
9723
|
...F(n) !== null ? { causalSequence: F(n) } : {},
|
|
9693
9724
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9694
|
-
...
|
|
9725
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9695
9726
|
dataType: "assistant_draft",
|
|
9696
9727
|
...n.steered === !0 ? { steered: !0 } : {}
|
|
9697
9728
|
};
|
|
@@ -9708,7 +9739,7 @@ function ft(s, e) {
|
|
|
9708
9739
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9709
9740
|
...F(n) !== null ? { causalSequence: F(n) } : {},
|
|
9710
9741
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9711
|
-
...
|
|
9742
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9712
9743
|
attachments: Rn(n.attachments, e),
|
|
9713
9744
|
...n.steered === !0 ? { steered: !0 } : {}
|
|
9714
9745
|
};
|
|
@@ -9733,7 +9764,7 @@ function ft(s, e) {
|
|
|
9733
9764
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
9734
9765
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9735
9766
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9736
|
-
...
|
|
9767
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9737
9768
|
dataType: "function_call_output",
|
|
9738
9769
|
toolName: _s,
|
|
9739
9770
|
callId: De(n) ?? void 0,
|
|
@@ -9748,7 +9779,7 @@ function ft(s, e) {
|
|
|
9748
9779
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
9749
9780
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9750
9781
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9751
|
-
...
|
|
9782
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9752
9783
|
dataType: "scheduled_check_in",
|
|
9753
9784
|
toolName: on,
|
|
9754
9785
|
callId: De(n) ?? void 0,
|
|
@@ -9764,7 +9795,7 @@ function ft(s, e) {
|
|
|
9764
9795
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9765
9796
|
...F(n) !== null ? { causalSequence: F(n) } : {},
|
|
9766
9797
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9767
|
-
...
|
|
9798
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9768
9799
|
dataType: "function_call_output",
|
|
9769
9800
|
toolName: "authenticate_pipedream_app",
|
|
9770
9801
|
callId: De(n) ?? void 0,
|
|
@@ -9777,7 +9808,7 @@ function ft(s, e) {
|
|
|
9777
9808
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9778
9809
|
...F(n) !== null ? { causalSequence: F(n) } : {},
|
|
9779
9810
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9780
|
-
...
|
|
9811
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9781
9812
|
dataType: "function_call_output",
|
|
9782
9813
|
toolName: "request_personal_channel_connection",
|
|
9783
9814
|
callId: De(n) ?? void 0,
|
|
@@ -9792,7 +9823,7 @@ function ft(s, e) {
|
|
|
9792
9823
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9793
9824
|
...F(n) !== null ? { causalSequence: F(n) } : {},
|
|
9794
9825
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9795
|
-
...
|
|
9826
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9796
9827
|
dataType: String(n.type),
|
|
9797
9828
|
toolName: n.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof n.name == "string" ? n.name : void 0,
|
|
9798
9829
|
callId: De(n) ?? void 0,
|
|
@@ -9806,7 +9837,7 @@ function ft(s, e) {
|
|
|
9806
9837
|
...x(n) !== null ? { displaySequence: x(n) } : {},
|
|
9807
9838
|
...F(n) !== null ? { causalSequence: F(n) } : {},
|
|
9808
9839
|
respondsToUserMessageId: H(n) ?? void 0,
|
|
9809
|
-
...
|
|
9840
|
+
...C(n) ? { runId: C(n) } : {},
|
|
9810
9841
|
dataType: String(n.type),
|
|
9811
9842
|
loading: n.steered !== !0 && n.type === "run_status" && (n.status === "running" || n.status === "retrying"),
|
|
9812
9843
|
...n.steered === !0 || n.type === "run_status" && n.status === "steered" ? { steered: !0 } : {},
|
|
@@ -9921,8 +9952,8 @@ function Oe(s, e) {
|
|
|
9921
9952
|
const t = wn(
|
|
9922
9953
|
s,
|
|
9923
9954
|
Ms(s, e)
|
|
9924
|
-
), i =
|
|
9925
|
-
|
|
9955
|
+
), i = Ec(
|
|
9956
|
+
Cc(
|
|
9926
9957
|
qc(
|
|
9927
9958
|
Mc(s, e),
|
|
9928
9959
|
e
|
|
@@ -9959,7 +9990,7 @@ function Mc(s, e) {
|
|
|
9959
9990
|
const r = [...s];
|
|
9960
9991
|
return r[n] = e, r;
|
|
9961
9992
|
}
|
|
9962
|
-
function
|
|
9993
|
+
function Cc(s, e) {
|
|
9963
9994
|
const t = e.assistantDraftItemId;
|
|
9964
9995
|
return t ? s.map(
|
|
9965
9996
|
(i) => i.dataType === "assistant_draft" && i.id === t ? e : i
|
|
@@ -10027,7 +10058,7 @@ function Ti(s) {
|
|
|
10027
10058
|
loading: !0
|
|
10028
10059
|
};
|
|
10029
10060
|
}
|
|
10030
|
-
function
|
|
10061
|
+
function Ec(s, e) {
|
|
10031
10062
|
if (e.id.startsWith("transient-activity:"))
|
|
10032
10063
|
return s;
|
|
10033
10064
|
const t = e.toolName === "tab_lifecycle";
|
|
@@ -10306,7 +10337,7 @@ function _i(s, e, t, i, n, r) {
|
|
|
10306
10337
|
if (Le(o) || t !== null && typeof o.id == "string" && o.id !== t)
|
|
10307
10338
|
return !1;
|
|
10308
10339
|
const a = H(o);
|
|
10309
|
-
return i !== null ? a !== null ? a === i : n !== null &&
|
|
10340
|
+
return i !== null ? a !== null ? a === i : n !== null && C(o) === n && r === i : n === null || C(o) === n;
|
|
10310
10341
|
}
|
|
10311
10342
|
function Hc(s, e) {
|
|
10312
10343
|
for (let t = e - 1; t >= 0; t -= 1) {
|
|
@@ -10409,7 +10440,7 @@ function Qc(s, e, t) {
|
|
|
10409
10440
|
}
|
|
10410
10441
|
function Mi(s, e, t, i) {
|
|
10411
10442
|
const n = (t && t !== e ? t : null) ?? [...s].reverse().find(
|
|
10412
|
-
(c) => c.respondsToUserMessageId !== void 0 && c.respondsToUserMessageId !== e &&
|
|
10443
|
+
(c) => c.respondsToUserMessageId !== void 0 && c.respondsToUserMessageId !== e && Ci(c) && !Jc(
|
|
10413
10444
|
s,
|
|
10414
10445
|
c.respondsToUserMessageId
|
|
10415
10446
|
)
|
|
@@ -10420,7 +10451,7 @@ function Mi(s, e, t, i) {
|
|
|
10420
10451
|
if (!n)
|
|
10421
10452
|
return s;
|
|
10422
10453
|
let r = !1;
|
|
10423
|
-
const o = s.map((c) => c.respondsToUserMessageId !== n || !
|
|
10454
|
+
const o = s.map((c) => c.respondsToUserMessageId !== n || !Ci(c) ? c : (r = !0, { ...c, steered: !0 }));
|
|
10424
10455
|
if (r)
|
|
10425
10456
|
return o;
|
|
10426
10457
|
const a = s.find(
|
|
@@ -10453,7 +10484,7 @@ function Gc(s, e) {
|
|
|
10453
10484
|
return s[i].id;
|
|
10454
10485
|
return null;
|
|
10455
10486
|
}
|
|
10456
|
-
function
|
|
10487
|
+
function Ci(s) {
|
|
10457
10488
|
return s.role === "tool" || oe(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
|
|
10458
10489
|
}
|
|
10459
10490
|
function Jc(s, e) {
|
|
@@ -10536,7 +10567,7 @@ function il(s, e) {
|
|
|
10536
10567
|
`${fn}${s}`,
|
|
10537
10568
|
JSON.stringify({
|
|
10538
10569
|
sessionId: e.sessionId,
|
|
10539
|
-
messages: e.messages.filter(fs).slice(-
|
|
10570
|
+
messages: e.messages.filter(fs).slice(-Ca).map(fl)
|
|
10540
10571
|
})
|
|
10541
10572
|
);
|
|
10542
10573
|
} catch {
|
|
@@ -10549,14 +10580,14 @@ function nl(s) {
|
|
|
10549
10580
|
if (!e)
|
|
10550
10581
|
return [];
|
|
10551
10582
|
const t = JSON.parse(e);
|
|
10552
|
-
return Array.isArray(t) ? t.filter(
|
|
10583
|
+
return Array.isArray(t) ? t.filter(Cs) : [];
|
|
10553
10584
|
} catch {
|
|
10554
10585
|
return [];
|
|
10555
10586
|
}
|
|
10556
10587
|
}
|
|
10557
|
-
function
|
|
10588
|
+
function W(s, e) {
|
|
10558
10589
|
try {
|
|
10559
|
-
const t = e.filter(
|
|
10590
|
+
const t = e.filter(Cs);
|
|
10560
10591
|
if (t.length === 0) {
|
|
10561
10592
|
window.localStorage.removeItem(`${as}${s}`);
|
|
10562
10593
|
return;
|
|
@@ -10569,7 +10600,7 @@ function V(s, e) {
|
|
|
10569
10600
|
return;
|
|
10570
10601
|
}
|
|
10571
10602
|
}
|
|
10572
|
-
function
|
|
10603
|
+
function Ei(s) {
|
|
10573
10604
|
try {
|
|
10574
10605
|
const e = window.localStorage.getItem(`${gn}${s}`);
|
|
10575
10606
|
if (!e)
|
|
@@ -10661,7 +10692,7 @@ function al(s) {
|
|
|
10661
10692
|
if (!s || typeof s != "object")
|
|
10662
10693
|
return !1;
|
|
10663
10694
|
const e = s, t = e.event;
|
|
10664
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
10695
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Cs(t) && t.type === "tool.result";
|
|
10665
10696
|
}
|
|
10666
10697
|
function cl(s, e) {
|
|
10667
10698
|
const t = new Set(
|
|
@@ -10679,7 +10710,7 @@ function ll(s) {
|
|
|
10679
10710
|
return;
|
|
10680
10711
|
}
|
|
10681
10712
|
}
|
|
10682
|
-
function
|
|
10713
|
+
function Cs(s) {
|
|
10683
10714
|
if (!s || typeof s != "object")
|
|
10684
10715
|
return !1;
|
|
10685
10716
|
const e = s;
|
|
@@ -10775,7 +10806,7 @@ function H(s) {
|
|
|
10775
10806
|
const e = s.respondsToUserMessageId;
|
|
10776
10807
|
return typeof e == "string" && e ? e : null;
|
|
10777
10808
|
}
|
|
10778
|
-
function
|
|
10809
|
+
function C(s) {
|
|
10779
10810
|
const e = s.runId;
|
|
10780
10811
|
return typeof e == "string" && e ? e : null;
|
|
10781
10812
|
}
|
|
@@ -10783,25 +10814,25 @@ function gl(s) {
|
|
|
10783
10814
|
const e = s?.timeoutMs;
|
|
10784
10815
|
return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Fa);
|
|
10785
10816
|
}
|
|
10786
|
-
function
|
|
10817
|
+
function Cn(s) {
|
|
10787
10818
|
const e = {};
|
|
10788
10819
|
try {
|
|
10789
10820
|
new Headers(s).forEach((t, i) => {
|
|
10790
|
-
Object.keys(e).length < Rs && (e[i] =
|
|
10821
|
+
Object.keys(e).length < Rs && (e[i] = Es(i, t));
|
|
10791
10822
|
});
|
|
10792
10823
|
} catch {
|
|
10793
10824
|
return {};
|
|
10794
10825
|
}
|
|
10795
10826
|
return e;
|
|
10796
10827
|
}
|
|
10797
|
-
function
|
|
10828
|
+
function Es(s, e) {
|
|
10798
10829
|
return On(s) ? _t : ee(It(e), ka);
|
|
10799
10830
|
}
|
|
10800
10831
|
function yl(s, e) {
|
|
10801
10832
|
return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
|
|
10802
10833
|
}
|
|
10803
10834
|
async function ml(s, e, t, i) {
|
|
10804
|
-
const n =
|
|
10835
|
+
const n = Cn(s.headers);
|
|
10805
10836
|
i({
|
|
10806
10837
|
...e,
|
|
10807
10838
|
responseStatus: s.status,
|
|
@@ -10811,7 +10842,7 @@ async function ml(s, e, t, i) {
|
|
|
10811
10842
|
});
|
|
10812
10843
|
}
|
|
10813
10844
|
async function Il(s) {
|
|
10814
|
-
if (!
|
|
10845
|
+
if (!En(s.headers))
|
|
10815
10846
|
return;
|
|
10816
10847
|
let e = null, t = null;
|
|
10817
10848
|
try {
|
|
@@ -10843,7 +10874,7 @@ async function Il(s) {
|
|
|
10843
10874
|
}
|
|
10844
10875
|
}
|
|
10845
10876
|
function Sl(s, e) {
|
|
10846
|
-
if (
|
|
10877
|
+
if (En(new Headers(e)))
|
|
10847
10878
|
try {
|
|
10848
10879
|
return s.responseType === "" || s.responseType === "text" ? ee(s.responseText ?? "") : void 0;
|
|
10849
10880
|
} catch {
|
|
@@ -10855,7 +10886,7 @@ function Ui(s) {
|
|
|
10855
10886
|
return ee(s);
|
|
10856
10887
|
}
|
|
10857
10888
|
function wl(s) {
|
|
10858
|
-
return
|
|
10889
|
+
return V({
|
|
10859
10890
|
...s,
|
|
10860
10891
|
requestBody: qi(s.requestBody),
|
|
10861
10892
|
responseBody: qi(s.responseBody)
|
|
@@ -10868,12 +10899,12 @@ function qi(s) {
|
|
|
10868
10899
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
10869
10900
|
return It(s);
|
|
10870
10901
|
try {
|
|
10871
|
-
return JSON.stringify(
|
|
10902
|
+
return JSON.stringify(V(JSON.parse(s)));
|
|
10872
10903
|
} catch {
|
|
10873
10904
|
return It(s);
|
|
10874
10905
|
}
|
|
10875
10906
|
}
|
|
10876
|
-
function
|
|
10907
|
+
function En(s) {
|
|
10877
10908
|
if (!s)
|
|
10878
10909
|
return !1;
|
|
10879
10910
|
const e = s.get("content-type")?.toLowerCase() ?? "", t = s.get("content-length"), i = Number(t);
|
|
@@ -10917,7 +10948,7 @@ function Tl(s) {
|
|
|
10917
10948
|
if (Object.keys(e).length >= Rs)
|
|
10918
10949
|
break;
|
|
10919
10950
|
const n = t.slice(0, i).trim();
|
|
10920
|
-
e[n] =
|
|
10951
|
+
e[n] = Es(n, t.slice(i + 1).trim());
|
|
10921
10952
|
}
|
|
10922
10953
|
return e;
|
|
10923
10954
|
}
|
|
@@ -10959,8 +10990,8 @@ function Rl(s) {
|
|
|
10959
10990
|
function kl(s) {
|
|
10960
10991
|
return s === 401 || s === 403;
|
|
10961
10992
|
}
|
|
10962
|
-
const _t = "[REDACTED_SECRET]", te = "[REDACTED_TOKEN]", Ml = "[REDACTED_SIGNED_URL]",
|
|
10963
|
-
function
|
|
10993
|
+
const _t = "[REDACTED_SECRET]", te = "[REDACTED_TOKEN]", Ml = "[REDACTED_SIGNED_URL]", Cl = 20, El = /^(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, Pn = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Dn = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Un = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, qn = /\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, Pl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Dl = /\bhttps?:\/\/[^\s"'<>]+/gi, Ul = /[),.;\]]+$/;
|
|
10994
|
+
function V(s) {
|
|
10964
10995
|
return mt(s, 0, /* @__PURE__ */ new WeakSet());
|
|
10965
10996
|
}
|
|
10966
10997
|
function mt(s, e, t) {
|
|
@@ -10968,7 +10999,7 @@ function mt(s, e, t) {
|
|
|
10968
10999
|
return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : It(s);
|
|
10969
11000
|
if (s === null || typeof s != "object")
|
|
10970
11001
|
return s;
|
|
10971
|
-
if (e >=
|
|
11002
|
+
if (e >= Cl)
|
|
10972
11003
|
return "[REDACTED_MAX_DEPTH]";
|
|
10973
11004
|
if (t.has(s))
|
|
10974
11005
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -10990,7 +11021,7 @@ function xn(s) {
|
|
|
10990
11021
|
try {
|
|
10991
11022
|
const e = new URL(s, location.href);
|
|
10992
11023
|
for (const t of Array.from(e.searchParams.keys()))
|
|
10993
|
-
|
|
11024
|
+
El.test(t) && e.searchParams.set(t, te);
|
|
10994
11025
|
return e.username && (e.username = te), e.password && (e.password = te), e.toString();
|
|
10995
11026
|
} catch {
|
|
10996
11027
|
return Ol(s);
|