omnix-chat 2.5.9 → 3.0.2
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/dist/omnix-chat.es.js +775 -737
- package/dist/omnix-chat.es.js.map +1 -1
- package/dist/omnix-chat.umd.cjs +15 -15
- package/dist/omnix-chat.umd.js +15 -15
- package/dist/omnix-chat.umd.js.map +1 -1
- package/dist/react-types-4kCc9MAv.cjs.js.map +1 -1
- package/dist/react-types-D6g7_-_a.js.map +1 -1
- package/dist/react.cjs +173 -122
- package/dist/react.cjs.js +173 -122
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +518 -441
- package/dist/react.es.js.map +1 -1
- package/dist/react.legacy-types-B3OBHme4.cjs.js.map +1 -1
- package/dist/react.legacy-types-C11EZiOU.js.map +1 -1
- package/dist/react.legacy.cjs +93 -39
- package/dist/react.legacy.cjs.js +93 -39
- package/dist/react.legacy.cjs.js.map +1 -1
- package/dist/react.legacy.es.js +142 -62
- package/dist/react.legacy.es.js.map +1 -1
- package/dist/src/core/client/instance.d.ts +8 -1
- package/dist/src/core/client/instance.d.ts.map +1 -1
- package/dist/src/core/lib/errors.d.ts +1 -1
- package/dist/src/core/lib/errors.d.ts.map +1 -1
- package/dist/src/core/page/page-action-feedback-wish-response.d.ts +3 -1
- package/dist/src/core/page/page-action-feedback-wish-response.d.ts.map +1 -1
- package/dist/src/core/services/page-action.service.d.ts +6 -1
- package/dist/src/core/services/page-action.service.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/usePageAction.d.ts +16 -2
- package/dist/src/react/usePageAction.d.ts.map +1 -1
- package/dist/src/react/usePageActions.d.ts +15 -1
- package/dist/src/react/usePageActions.d.ts.map +1 -1
- package/dist/src/types.d.ts +23 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/sdk-version.d.ts +1 -1
- package/package.json +1 -1
package/dist/react.es.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { $ as e, A as t, C as n, Ct as r, E as i, F as a, G as o, J as s, K as c, M as l, N as u, O as d, Q as f, S as p, T as m, Tt as h, Y as g, Z as _, _ as v, _t as y, a as b, b as
|
|
2
|
-
import
|
|
3
|
-
import { jsx as
|
|
4
|
-
var
|
|
1
|
+
import { $ as e, A as t, C as n, Ct as r, E as i, F as a, G as o, J as s, K as c, M as l, N as u, O as d, Q as f, S as p, T as m, Tt as h, Y as g, Z as _, _ as v, _t as y, a as b, b as x, bt as S, d as ee, et as te, f as ne, g as re, h as ie, i as ae, it as oe, j as se, k as C, kt as w, l as T, n as ce, p as E, q as le, r as ue, t as de, u as fe, ut as pe, v as me, vt as he, w as ge, wt as _e, x as ve, xt as D, y as ye, yt as be } from "./react-types-D6g7_-_a.js";
|
|
2
|
+
import O, { Suspense as xe, createContext as Se, lazy as Ce, useCallback as k, useContext as we, useEffect as A, useMemo as Te, useRef as j, useState as M, useSyncExternalStore as Ee } from "react";
|
|
3
|
+
import { jsx as N, jsxs as De } from "react/jsx-runtime";
|
|
4
|
+
var P = class AgentChatError extends Error {
|
|
5
5
|
constructor(e2, t2, n2 = {}) {
|
|
6
6
|
super(t2), h(this, "code", void 0), h(this, "details", void 0), this.name = "AgentChatError", this.code = e2, n2.cause !== void 0 && (this.cause = n2.cause), n2.details !== void 0 && (this.details = n2.details), typeof Object.setPrototypeOf == "function" && Object.setPrototypeOf(this, AgentChatError.prototype);
|
|
7
7
|
}
|
|
8
|
-
},
|
|
8
|
+
}, F = "x-app-dsn";
|
|
9
9
|
function normalizeDsn(e2) {
|
|
10
|
-
if (typeof e2 != "string" || e2.trim() === "") throw new
|
|
10
|
+
if (typeof e2 != "string" || e2.trim() === "") throw new P("INVALID_DSN", "DSN must be a non-empty string", { details: { received: typeof e2 } });
|
|
11
11
|
return e2.trim();
|
|
12
12
|
}
|
|
13
|
-
var
|
|
13
|
+
var Oe = "x-account-token", ke = "Authorization", Ae = "X-App-Dsn";
|
|
14
14
|
function buildAppClientAuthHeaders(e2, t2) {
|
|
15
|
-
let n2 = { [
|
|
16
|
-
return t2?.trim() && (n2[
|
|
15
|
+
let n2 = { [F]: e2.trim() };
|
|
16
|
+
return t2?.trim() && (n2[Oe] = normalizeAccessToken(t2)), n2;
|
|
17
17
|
}
|
|
18
18
|
function normalizeAccessToken(e2) {
|
|
19
19
|
return e2.trim().replace(/^Bearer\s+/i, "");
|
|
@@ -22,25 +22,25 @@ function formatBearerToken(e2) {
|
|
|
22
22
|
return `Bearer ${normalizeAccessToken(e2)}`;
|
|
23
23
|
}
|
|
24
24
|
function applyAccessTokenHeader(e2, t2) {
|
|
25
|
-
e2.setDefaultHeader(
|
|
25
|
+
e2.setDefaultHeader(ke, formatBearerToken(t2));
|
|
26
26
|
}
|
|
27
27
|
function clearAccessTokenHeader(e2) {
|
|
28
|
-
e2.setDefaultHeader(
|
|
28
|
+
e2.setDefaultHeader(ke, void 0);
|
|
29
29
|
}
|
|
30
30
|
function buildAgentClientHeaders(e2) {
|
|
31
|
-
return { [
|
|
31
|
+
return { [Ae]: e2.trim() };
|
|
32
32
|
}
|
|
33
33
|
function isRecord$10(e2) {
|
|
34
34
|
return typeof e2 == "object" && !!e2;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
w(isRecord$10, "isRecord");
|
|
37
37
|
function unwrapApiData(e2) {
|
|
38
38
|
return isRecord$10(e2) ? isRecord$10(e2.data) ? e2.data : e2 : null;
|
|
39
39
|
}
|
|
40
40
|
function readString$7(e2) {
|
|
41
41
|
return typeof e2 == "string" && e2.trim().length > 0 ? e2.trim() : void 0;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
w(readString$7, "readString");
|
|
44
44
|
function parseAppClient(e2) {
|
|
45
45
|
if (!isRecord$10(e2)) return;
|
|
46
46
|
let t2 = e2.id, n2 = readString$7(e2.dsn), r2 = readString$7(e2.name);
|
|
@@ -79,7 +79,7 @@ function parseAuthResponse(e2) {
|
|
|
79
79
|
function isRecord$9(e2) {
|
|
80
80
|
return typeof e2 == "object" && !!e2;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
w(isRecord$9, "isRecord");
|
|
83
83
|
function readNumber$5(e2) {
|
|
84
84
|
if (typeof e2 == "number" && Number.isFinite(e2)) return e2;
|
|
85
85
|
if (typeof e2 == "string" && e2.trim().length > 0) {
|
|
@@ -87,7 +87,7 @@ function readNumber$5(e2) {
|
|
|
87
87
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
w(readNumber$5, "readNumber");
|
|
91
91
|
function isStaleAgentRunEvent(e2, t2) {
|
|
92
92
|
return t2 != null && t2 < e2;
|
|
93
93
|
}
|
|
@@ -99,10 +99,10 @@ function parsePendingWriteGate(e2) {
|
|
|
99
99
|
if (!isRecord$9(e2)) return null;
|
|
100
100
|
let t2 = readNumber$5(e2.runId), n2 = readNumber$5(e2.turnId);
|
|
101
101
|
if (t2 == null || n2 == null) return null;
|
|
102
|
-
let r2 = readNumber$5(e2.draftRetryCount) ?? 0, i2 = readNumber$5(e2.draftRetryMax) ?? 3, a2 = e2.canRetry === false ? false : e2.canRetry === true || r2 < i2, o2 =
|
|
102
|
+
let r2 = readNumber$5(e2.draftRetryCount) ?? 0, i2 = readNumber$5(e2.draftRetryMax) ?? 3, a2 = e2.canRetry === false ? false : e2.canRetry === true || r2 < i2, o2 = oe({
|
|
103
103
|
writeDraft: y(e2.writeDraft),
|
|
104
104
|
writeDrafts: e2.writeDrafts,
|
|
105
|
-
editPolicy:
|
|
105
|
+
editPolicy: pe(e2.editPolicy),
|
|
106
106
|
editPolicies: e2.editPolicies
|
|
107
107
|
}), s2 = o2[0] ?? null;
|
|
108
108
|
return {
|
|
@@ -147,11 +147,11 @@ function parseCancelRunResponse(e2) {
|
|
|
147
147
|
function isRecord$8(e2) {
|
|
148
148
|
return typeof e2 == "object" && !!e2;
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
w(isRecord$8, "isRecord");
|
|
151
151
|
function readString$6(e2) {
|
|
152
152
|
return typeof e2 == "string" && e2.trim().length > 0 ? e2.trim() : void 0;
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
w(readString$6, "readString");
|
|
155
155
|
function parseSessionRow(e2) {
|
|
156
156
|
if (!isRecord$8(e2)) return null;
|
|
157
157
|
let t2 = readString$6(e2.sessionId) ?? readString$6(e2.id) ?? (typeof e2.sessionId == "number" ? String(e2.sessionId) : void 0) ?? (typeof e2.id == "number" ? String(e2.id) : void 0);
|
|
@@ -207,7 +207,7 @@ function readNumber$4(e2) {
|
|
|
207
207
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
|
|
210
|
+
w(readNumber$4, "readNumber");
|
|
211
211
|
function readBoolean(e2) {
|
|
212
212
|
if (typeof e2 == "boolean") return e2;
|
|
213
213
|
}
|
|
@@ -397,8 +397,8 @@ var createStoreImpl = (e2) => {
|
|
|
397
397
|
return r2;
|
|
398
398
|
}, createStore = ((e2) => e2 ? createStoreImpl(e2) : createStoreImpl), identity = (e2) => e2;
|
|
399
399
|
function useStore(e2, t2 = identity) {
|
|
400
|
-
let n2 =
|
|
401
|
-
return
|
|
400
|
+
let n2 = O.useSyncExternalStore(e2.subscribe, O.useCallback(() => t2(e2.getState()), [e2, t2]), O.useCallback(() => t2(e2.getInitialState()), [e2, t2]));
|
|
401
|
+
return O.useDebugValue(n2), n2;
|
|
402
402
|
}
|
|
403
403
|
var createImpl = (e2) => {
|
|
404
404
|
let t2 = createStore(e2), useBoundStore = (e3) => useStore(t2, e3);
|
|
@@ -511,21 +511,21 @@ var toThenable = (e2) => (t2) => {
|
|
|
511
511
|
l2.delete(e3);
|
|
512
512
|
})
|
|
513
513
|
}, a2.skipHydration || hydrate(), p2 || f2;
|
|
514
|
-
},
|
|
514
|
+
}, je = persistImpl, Me = "agent-chat-auth", Ne = "omnix:auth-changed";
|
|
515
515
|
function notifyOmnixAuthBridge(e2) {
|
|
516
516
|
if (!(typeof window > "u")) try {
|
|
517
|
-
window.dispatchEvent(new CustomEvent(
|
|
517
|
+
window.dispatchEvent(new CustomEvent(Ne, { detail: e2 }));
|
|
518
518
|
} catch {
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
var
|
|
521
|
+
var Pe = {
|
|
522
522
|
dsn: null,
|
|
523
523
|
accessToken: null,
|
|
524
524
|
user: null,
|
|
525
525
|
appClient: null,
|
|
526
526
|
accountTokenBound: null
|
|
527
|
-
},
|
|
528
|
-
...
|
|
527
|
+
}, I = create()(je((e2, t2) => ({
|
|
528
|
+
...Pe,
|
|
529
529
|
setAuth(t3, n2) {
|
|
530
530
|
let r2 = n2.accessToken ?? null, i2 = n2.user ?? null;
|
|
531
531
|
e2({
|
|
@@ -542,7 +542,7 @@ var Ie = {
|
|
|
542
542
|
});
|
|
543
543
|
},
|
|
544
544
|
clearAuth() {
|
|
545
|
-
e2({ ...
|
|
545
|
+
e2({ ...Pe }), notifyOmnixAuthBridge({
|
|
546
546
|
loggedIn: false,
|
|
547
547
|
dsn: null,
|
|
548
548
|
accessToken: null,
|
|
@@ -553,21 +553,21 @@ var Ie = {
|
|
|
553
553
|
let n2 = t2();
|
|
554
554
|
return n2.dsn === e3 && n2.accessToken ? n2.accessToken : null;
|
|
555
555
|
}
|
|
556
|
-
}), { name:
|
|
556
|
+
}), { name: Me }));
|
|
557
557
|
function waitForAuthStoreRehydration(e2 = 3e3) {
|
|
558
|
-
return
|
|
559
|
-
let n2 = setTimeout(t2, e2), r2 =
|
|
558
|
+
return I.persist.hasHydrated() ? Promise.resolve() : new Promise((t2) => {
|
|
559
|
+
let n2 = setTimeout(t2, e2), r2 = I.persist.onFinishHydration(() => {
|
|
560
560
|
clearTimeout(n2), r2(), t2();
|
|
561
561
|
});
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
564
|
function isSdkAuthenticatedForDsn(e2) {
|
|
565
565
|
if (!e2?.trim()) return false;
|
|
566
|
-
let { dsn: t2, accessToken: n2 } =
|
|
566
|
+
let { dsn: t2, accessToken: n2 } = I.getState();
|
|
567
567
|
return t2 === e2 && !!n2?.trim();
|
|
568
568
|
}
|
|
569
569
|
function getSdkAccessTokenForDsn(e2) {
|
|
570
|
-
return
|
|
570
|
+
return I.getState().getAccessTokenForDsn(e2);
|
|
571
571
|
}
|
|
572
572
|
var LoginGate = class {
|
|
573
573
|
constructor(e2, t2, n2) {
|
|
@@ -586,12 +586,12 @@ var LoginGate = class {
|
|
|
586
586
|
if (this.waiters.length === 0) return;
|
|
587
587
|
let t2 = this.waiters.splice(0);
|
|
588
588
|
this.pendingJobs = [], this.onPendingChange?.();
|
|
589
|
-
let n2 = new
|
|
589
|
+
let n2 = new P("CANCELLED", e2);
|
|
590
590
|
for (let e3 of t2) e3.dispose(), e3.reject(n2);
|
|
591
591
|
}
|
|
592
592
|
wait(e2 = {}) {
|
|
593
593
|
let t2 = e2.label ?? "operation", n2 = e2.timeoutMs ?? 3e5, { signal: r2 } = e2;
|
|
594
|
-
return this.isReady() ? Promise.resolve() : r2?.aborted ? Promise.reject(new
|
|
594
|
+
return this.isReady() ? Promise.resolve() : r2?.aborted ? Promise.reject(new P("CANCELLED", `${t2} \u5DF2\u53D6\u6D88`)) : new Promise((e3, i2) => {
|
|
595
595
|
let a2 = false;
|
|
596
596
|
this.pendingSeq += 1;
|
|
597
597
|
let o2 = `gate-${this.kind}-${Date.now()}-${this.pendingSeq}`, s2 = {
|
|
@@ -619,9 +619,9 @@ var LoginGate = class {
|
|
|
619
619
|
},
|
|
620
620
|
dispose
|
|
621
621
|
}, l2 = setTimeout(() => {
|
|
622
|
-
c2.reject(new
|
|
622
|
+
c2.reject(new P("PENDING_TIMEOUT", `${t2} \u7B49\u5F85${this.kind === "init" ? "\u521D\u59CB\u5316" : "\u767B\u5F55"}\u8D85\u65F6\uFF08${Math.round(n2 / 1e3)}s\uFF09`));
|
|
623
623
|
}, n2), onAbort = () => {
|
|
624
|
-
c2.reject(new
|
|
624
|
+
c2.reject(new P("CANCELLED", `${t2} \u5DF2\u53D6\u6D88`));
|
|
625
625
|
};
|
|
626
626
|
r2?.addEventListener("abort", onAbort), this.waiters.push(c2);
|
|
627
627
|
});
|
|
@@ -629,23 +629,23 @@ var LoginGate = class {
|
|
|
629
629
|
async run(e2, t2) {
|
|
630
630
|
return await this.wait(e2), t2();
|
|
631
631
|
}
|
|
632
|
-
},
|
|
632
|
+
}, L = "omnix:extension-ready", Fe = "omnix:request-extension-bridge";
|
|
633
633
|
function isOmnixSdkAuthenticated() {
|
|
634
|
-
return isSdkAuthenticatedForDsn(
|
|
634
|
+
return isSdkAuthenticatedForDsn(I.getState().dsn);
|
|
635
635
|
}
|
|
636
636
|
function requireOmnixSdkAuthentication() {
|
|
637
637
|
if (!isOmnixSdkAuthenticated()) throw Error("\u8BF7\u5148\u767B\u5F55 Omnix");
|
|
638
638
|
}
|
|
639
|
-
var
|
|
639
|
+
var Ie = false;
|
|
640
640
|
function ensureExtensionAuthResyncListener() {
|
|
641
|
-
if (!(
|
|
642
|
-
|
|
641
|
+
if (!(Ie || typeof window > "u")) {
|
|
642
|
+
Ie = true;
|
|
643
643
|
try {
|
|
644
|
-
window.dispatchEvent(new CustomEvent(
|
|
644
|
+
window.dispatchEvent(new CustomEvent(Fe));
|
|
645
645
|
} catch {
|
|
646
646
|
}
|
|
647
|
-
window.addEventListener(
|
|
648
|
-
let { dsn: e2, accessToken: t2, user: n2 } =
|
|
647
|
+
window.addEventListener(L, () => {
|
|
648
|
+
let { dsn: e2, accessToken: t2, user: n2 } = I.getState();
|
|
649
649
|
notifyOmnixAuthBridge({
|
|
650
650
|
loggedIn: !!t2?.trim(),
|
|
651
651
|
dsn: e2,
|
|
@@ -690,11 +690,11 @@ function isHostActionStreamPayload(e2) {
|
|
|
690
690
|
function readString$5(e2) {
|
|
691
691
|
if (typeof e2 == "string") return e2.trim() || void 0;
|
|
692
692
|
}
|
|
693
|
-
|
|
693
|
+
w(readString$5, "readString");
|
|
694
694
|
function isRecord$7(e2) {
|
|
695
695
|
return !!e2 && typeof e2 == "object" && !Array.isArray(e2);
|
|
696
696
|
}
|
|
697
|
-
|
|
697
|
+
w(isRecord$7, "isRecord");
|
|
698
698
|
function readEntity(e2) {
|
|
699
699
|
if (!isRecord$7(e2)) return;
|
|
700
700
|
let t2 = readString$5(e2.type), n2 = readString$5(e2.id);
|
|
@@ -734,7 +734,7 @@ function isHostActionMarker(e2) {
|
|
|
734
734
|
function readMessageId$1(e2, t2) {
|
|
735
735
|
return readString$5(e2.messageId) ?? readString$5(e2.message_id) ?? readString$5(t2.messageId) ?? readString$5(t2.message_id);
|
|
736
736
|
}
|
|
737
|
-
|
|
737
|
+
w(readMessageId$1, "readMessageId");
|
|
738
738
|
function parseModernHostAction(e2) {
|
|
739
739
|
let t2 = readHostActionEnvelope(e2), n2 = readString$5(t2.action) ?? readString$5(e2.action), r2 = e2.hostAction && typeof e2.hostAction == "object";
|
|
740
740
|
if (n2 !== "host_action" && n2 !== "host-action" && !r2) return null;
|
|
@@ -773,7 +773,7 @@ function isDispatchableHostAction(e2) {
|
|
|
773
773
|
function parseHostActionPayload(e2) {
|
|
774
774
|
return isRecord$7(e2) ? parseModernHostAction(e2) || parseLegacyHostAction(e2) : null;
|
|
775
775
|
}
|
|
776
|
-
var
|
|
776
|
+
var Le = parseHostActionPayload;
|
|
777
777
|
function parseHostActionSsePayload(e2) {
|
|
778
778
|
if (!isRecord$7(e2)) return null;
|
|
779
779
|
let t2 = readHostActionEnvelope(e2), n2 = readString$5(t2.action) ?? readString$5(e2.action), r2 = e2.hostAction && typeof e2.hostAction == "object";
|
|
@@ -847,7 +847,7 @@ function tryParseJson$1(e2) {
|
|
|
847
847
|
return null;
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
|
-
|
|
850
|
+
w(tryParseJson$1, "tryParseJson");
|
|
851
851
|
function readGeneration(e2) {
|
|
852
852
|
if (!e2) return;
|
|
853
853
|
let t2 = e2.generation ?? e2.runGeneration ?? e2.run_generation;
|
|
@@ -888,7 +888,7 @@ function readErrorFromData(e2) {
|
|
|
888
888
|
code: typeof t2?.code == "string" ? t2.code : void 0
|
|
889
889
|
};
|
|
890
890
|
}
|
|
891
|
-
var
|
|
891
|
+
var R = /* @__PURE__ */ new Set([
|
|
892
892
|
"delta",
|
|
893
893
|
"stream",
|
|
894
894
|
"chunk",
|
|
@@ -897,7 +897,7 @@ var I = /* @__PURE__ */ new Set([
|
|
|
897
897
|
"message.delta"
|
|
898
898
|
]);
|
|
899
899
|
function resolveStreamTextMode(e2) {
|
|
900
|
-
return e2 ? e2 === "full" || e2 === "replace" ? "replace" : (
|
|
900
|
+
return e2 ? e2 === "full" || e2 === "replace" ? "replace" : (R.has(e2), "append") : "append";
|
|
901
901
|
}
|
|
902
902
|
function parseThinkEnvelope(e2) {
|
|
903
903
|
let t2 = readMessageId(e2), n2 = readSseRunMeta(e2), r2 = tryParseJson$1(e2);
|
|
@@ -945,7 +945,7 @@ function readResultChunkText(e2) {
|
|
|
945
945
|
function parseResultEnvelope(e2) {
|
|
946
946
|
let t2 = readMessageId(e2), n2 = readSseRunMeta(e2), r2 = tryParseJson$1(e2)?.content ?? e2, i2 = typeof r2 == "string" ? tryParseJson$1(r2) : r2;
|
|
947
947
|
if (i2 && typeof i2 == "object") {
|
|
948
|
-
let e3 = i2, r3 = typeof e3.source == "string" ? e3.source : void 0, a3 = typeof e3.action == "string" ? e3.action : void 0, o2 = typeof e3.stream?.mode == "string" ? String(e3.stream.mode) : void 0, s2 = readResultChunkText(e3), c2 = (a3 ?
|
|
948
|
+
let e3 = i2, r3 = typeof e3.source == "string" ? e3.source : void 0, a3 = typeof e3.action == "string" ? e3.action : void 0, o2 = typeof e3.stream?.mode == "string" ? String(e3.stream.mode) : void 0, s2 = readResultChunkText(e3), c2 = (a3 ? R.has(a3) : false) || (o2 ? R.has(o2) : false);
|
|
949
949
|
if (r3 === "agent-run") {
|
|
950
950
|
if (a3 === "final") return s2.trim() ? {
|
|
951
951
|
type: "result",
|
|
@@ -989,7 +989,7 @@ function parseHostActionEnvelope(e2) {
|
|
|
989
989
|
if (!t2 || !isHostActionEnvelope(t2)) return { type: "noop" };
|
|
990
990
|
let n2 = parseHostActionSsePayload(t2);
|
|
991
991
|
if (!n2) return { type: "noop" };
|
|
992
|
-
let r2 =
|
|
992
|
+
let r2 = Le(t2) ?? void 0, i2 = readHostActionRunMeta(t2, n2);
|
|
993
993
|
return {
|
|
994
994
|
type: "host-action",
|
|
995
995
|
action: r2,
|
|
@@ -999,7 +999,7 @@ function parseHostActionEnvelope(e2) {
|
|
|
999
999
|
};
|
|
1000
1000
|
}
|
|
1001
1001
|
function parseWriteConfirmationEnvelope(e2) {
|
|
1002
|
-
let t2 = typeof e2.action == "string" ? e2.action : void 0, n2 = typeof e2.message == "string" ? e2.message.trim() : "", r2 = typeof e2.code == "string" ? e2.code : void 0, i2 = typeof e2.runId == "number" ? e2.runId : void 0, a2 = typeof e2.turnId == "number" ? e2.turnId : void 0, o2 = readGeneration(e2), s2 = typeof e2.draftRetryCount == "number" ? e2.draftRetryCount : void 0, c2 = typeof e2.draftRetryMax == "number" ? e2.draftRetryMax : void 0, l2 = typeof e2.canRetry == "boolean" ? e2.canRetry : void 0, u2 = y(e2.writeDraft) ?? void 0, d2 =
|
|
1002
|
+
let t2 = typeof e2.action == "string" ? e2.action : void 0, n2 = typeof e2.message == "string" ? e2.message.trim() : "", r2 = typeof e2.code == "string" ? e2.code : void 0, i2 = typeof e2.runId == "number" ? e2.runId : void 0, a2 = typeof e2.turnId == "number" ? e2.turnId : void 0, o2 = readGeneration(e2), s2 = typeof e2.draftRetryCount == "number" ? e2.draftRetryCount : void 0, c2 = typeof e2.draftRetryMax == "number" ? e2.draftRetryMax : void 0, l2 = typeof e2.canRetry == "boolean" ? e2.canRetry : void 0, u2 = y(e2.writeDraft) ?? void 0, d2 = pe(e2.editPolicy) ?? void 0, f2 = oe({
|
|
1003
1003
|
writeDraft: u2,
|
|
1004
1004
|
writeDrafts: e2.writeDrafts,
|
|
1005
1005
|
editPolicy: d2,
|
|
@@ -1039,7 +1039,7 @@ function parseMessageBlocksEnvelope(e2) {
|
|
|
1039
1039
|
if (isHostActionEnvelope(n2)) {
|
|
1040
1040
|
let e3 = parseHostActionSsePayload(n2);
|
|
1041
1041
|
if (!e3) return { type: "noop" };
|
|
1042
|
-
let t3 =
|
|
1042
|
+
let t3 = Le(n2) ?? void 0, r3 = readHostActionRunMeta(n2, e3);
|
|
1043
1043
|
return {
|
|
1044
1044
|
type: "host-action",
|
|
1045
1045
|
action: t3,
|
|
@@ -1142,7 +1142,7 @@ function parseChatSseEvent(e2, t2) {
|
|
|
1142
1142
|
return { type: "noop" };
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
1145
|
-
var
|
|
1145
|
+
var z = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
|
|
1146
1146
|
function registryScope(e2) {
|
|
1147
1147
|
return e2.trim() || "*";
|
|
1148
1148
|
}
|
|
@@ -1153,11 +1153,11 @@ function registryName(e2) {
|
|
|
1153
1153
|
}
|
|
1154
1154
|
function resolveEntry(e2, t2) {
|
|
1155
1155
|
let n2 = registryName(t2), r2 = registryScope(e2);
|
|
1156
|
-
return
|
|
1156
|
+
return z.get(r2)?.get(n2) ?? z.get("*")?.get(n2);
|
|
1157
1157
|
}
|
|
1158
1158
|
function registerHostTool(e2, t2, n2, r2) {
|
|
1159
|
-
let i2 = registryScope(e2), a2 = registryName(t2), o2 =
|
|
1160
|
-
o2 || (o2 = /* @__PURE__ */ new Map(),
|
|
1159
|
+
let i2 = registryScope(e2), a2 = registryName(t2), o2 = z.get(i2);
|
|
1160
|
+
o2 || (o2 = /* @__PURE__ */ new Map(), z.set(i2, o2)), o2.set(a2, {
|
|
1161
1161
|
handler: n2,
|
|
1162
1162
|
...r2?.invokeOnAppend === void 0 ? {} : { invokeOnAppend: r2.invokeOnAppend },
|
|
1163
1163
|
...r2?.onPreview ? { onPreview: r2.onPreview } : {}
|
|
@@ -1166,8 +1166,8 @@ function registerHostTool(e2, t2, n2, r2) {
|
|
|
1166
1166
|
function unregisterHostTool(e2, t2) {
|
|
1167
1167
|
let n2 = t2.trim();
|
|
1168
1168
|
if (!n2) return;
|
|
1169
|
-
let r2 =
|
|
1170
|
-
r2?.delete(n2), r2 && r2.size === 0 &&
|
|
1169
|
+
let r2 = z.get(registryScope(e2));
|
|
1170
|
+
r2?.delete(n2), r2 && r2.size === 0 && z.delete(registryScope(e2));
|
|
1171
1171
|
}
|
|
1172
1172
|
function getHostToolStreamConfig(e2, t2) {
|
|
1173
1173
|
let n2 = resolveEntry(e2, t2);
|
|
@@ -1189,25 +1189,25 @@ async function executeHostToolsFromAction(e2) {
|
|
|
1189
1189
|
for (let e3 of t2) !await runHostTool(n2, e3.name, e3.args) && typeof console < "u" && typeof console.warn == "function" && console.warn("[agent-chat] hostTool not registered:", e3.name, "(scope:", n2, ")");
|
|
1190
1190
|
}
|
|
1191
1191
|
function declareHostTool(e2, t2) {
|
|
1192
|
-
let n2 = registryScope(e2), r2 = registryName(t2), i2 =
|
|
1193
|
-
i2 || (i2 = /* @__PURE__ */ new Set(),
|
|
1192
|
+
let n2 = registryScope(e2), r2 = registryName(t2), i2 = B.get(n2);
|
|
1193
|
+
i2 || (i2 = /* @__PURE__ */ new Set(), B.set(n2, i2)), i2.add(r2);
|
|
1194
1194
|
}
|
|
1195
1195
|
function undeclareHostTool(e2, t2) {
|
|
1196
1196
|
let n2 = t2.trim();
|
|
1197
1197
|
if (!n2) return;
|
|
1198
|
-
let r2 =
|
|
1199
|
-
r2?.delete(n2), r2 && r2.size === 0 &&
|
|
1198
|
+
let r2 = B.get(registryScope(e2));
|
|
1199
|
+
r2?.delete(n2), r2 && r2.size === 0 && B.delete(registryScope(e2));
|
|
1200
1200
|
}
|
|
1201
1201
|
function isHostToolRegisteredInScope(e2, t2) {
|
|
1202
1202
|
let n2 = t2.trim();
|
|
1203
|
-
return n2 ?
|
|
1203
|
+
return n2 ? z.get(registryScope(e2))?.has(n2) ?? false : false;
|
|
1204
1204
|
}
|
|
1205
1205
|
function isHostToolRegisteredGlobally(e2) {
|
|
1206
1206
|
return isHostToolRegisteredInScope("*", e2);
|
|
1207
1207
|
}
|
|
1208
1208
|
function isHostToolDeclaredInScope(e2, t2) {
|
|
1209
1209
|
let n2 = t2.trim();
|
|
1210
|
-
return n2 ?
|
|
1210
|
+
return n2 ? B.get(registryScope(e2))?.has(n2) ?? false : false;
|
|
1211
1211
|
}
|
|
1212
1212
|
function isHostToolDeclaredGlobally(e2) {
|
|
1213
1213
|
return isHostToolDeclaredInScope("*", e2);
|
|
@@ -1215,37 +1215,37 @@ function isHostToolDeclaredGlobally(e2) {
|
|
|
1215
1215
|
function isHostToolKnownGlobally(e2) {
|
|
1216
1216
|
return isHostToolRegisteredGlobally(e2) || isHostToolDeclaredGlobally(e2);
|
|
1217
1217
|
}
|
|
1218
|
-
var
|
|
1218
|
+
var V = /* @__PURE__ */ new Map(), Re = /* @__PURE__ */ new Set();
|
|
1219
1219
|
function addHandler(e2, t2) {
|
|
1220
1220
|
return e2.add(t2), () => {
|
|
1221
1221
|
e2.delete(t2);
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
function registerHostAction(e2, t2) {
|
|
1225
|
-
if (typeof e2 == "function") return addHandler(
|
|
1225
|
+
if (typeof e2 == "function") return addHandler(Re, e2);
|
|
1226
1226
|
if (!t2) throw Error("registerHostAction(scope, handler): handler is required");
|
|
1227
1227
|
let n2 = e2.trim();
|
|
1228
1228
|
if (!n2) throw Error("registerHostAction(scope, handler): scope is required");
|
|
1229
|
-
let r2 =
|
|
1230
|
-
r2 || (r2 = /* @__PURE__ */ new Set(),
|
|
1229
|
+
let r2 = V.get(n2);
|
|
1230
|
+
r2 || (r2 = /* @__PURE__ */ new Set(), V.set(n2, r2));
|
|
1231
1231
|
let i2 = addHandler(r2, t2);
|
|
1232
1232
|
return () => {
|
|
1233
1233
|
i2();
|
|
1234
|
-
let e3 =
|
|
1235
|
-
e3 && e3.size === 0 &&
|
|
1234
|
+
let e3 = V.get(n2);
|
|
1235
|
+
e3 && e3.size === 0 && V.delete(n2);
|
|
1236
1236
|
};
|
|
1237
1237
|
}
|
|
1238
1238
|
async function dispatchHostAction(e2) {
|
|
1239
1239
|
if (e2.action !== "host_action" || e2.streamPhase === "streaming" || !e2.hostTools.length) return;
|
|
1240
1240
|
let t2 = e2.scope?.trim();
|
|
1241
1241
|
if (!t2) return;
|
|
1242
|
-
let n2 = [], r2 =
|
|
1242
|
+
let n2 = [], r2 = V.get(t2);
|
|
1243
1243
|
if (r2?.size) for (let t3 of r2) n2.push(t3(e2));
|
|
1244
1244
|
else !e2.hostTools.some((e3) => isHostToolRegisteredInScope(t2, e3.name) || isHostToolRegisteredGlobally(e3.name)) && typeof console < "u" && typeof console.warn == "function" && console.warn("[agent-chat] hostAction: no handler registered for scope:", t2);
|
|
1245
|
-
for (let t3 of
|
|
1245
|
+
for (let t3 of Re) n2.push(t3(e2));
|
|
1246
1246
|
await Promise.all(n2);
|
|
1247
1247
|
}
|
|
1248
|
-
var
|
|
1248
|
+
var ze = registerHostAction;
|
|
1249
1249
|
function setByDotPath(e2, t2, n2) {
|
|
1250
1250
|
let r2 = t2.split(".").filter(Boolean);
|
|
1251
1251
|
if (r2.length === 0) return e2;
|
|
@@ -1740,7 +1740,7 @@ var HostToolStreamManager = class {
|
|
|
1740
1740
|
function isHostToolStreamEnabled(e2, t2) {
|
|
1741
1741
|
return e2 !== false || !isHostActionStreamPayload(t2) || t2.stream.mode === "full";
|
|
1742
1742
|
}
|
|
1743
|
-
var
|
|
1743
|
+
var Be = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Map();
|
|
1744
1744
|
function syncKey(e2, t2) {
|
|
1745
1745
|
return `${e2}:${t2}`;
|
|
1746
1746
|
}
|
|
@@ -1759,13 +1759,13 @@ function toServerToolMeta(e2, t2) {
|
|
|
1759
1759
|
};
|
|
1760
1760
|
}
|
|
1761
1761
|
function queuePendingHostToolSync(e2, t2) {
|
|
1762
|
-
let n2 =
|
|
1763
|
-
n2.push(t2),
|
|
1762
|
+
let n2 = H.get(e2) ?? [];
|
|
1763
|
+
n2.push(t2), H.set(e2, n2);
|
|
1764
1764
|
}
|
|
1765
1765
|
async function syncHostToolMetadataToServer(e2, t2) {
|
|
1766
1766
|
let { scope: n2, tools: r2, appLevel: i2 = false } = t2, a2 = e2.getAppClientId();
|
|
1767
1767
|
if (a2 == null) return 0;
|
|
1768
|
-
let o2 = r2.filter((e3) => !
|
|
1768
|
+
let o2 = r2.filter((e3) => !Be.has(syncKey(a2, e3.name)));
|
|
1769
1769
|
if (o2.length === 0) return 0;
|
|
1770
1770
|
let s2 = await e2.syncHostToolsToServer({
|
|
1771
1771
|
scope: i2 ? "*" : n2,
|
|
@@ -1773,14 +1773,14 @@ async function syncHostToolMetadataToServer(e2, t2) {
|
|
|
1773
1773
|
routePattern: t2.routePattern,
|
|
1774
1774
|
tools: o2.map((e3) => toServerToolMeta(e3, i2))
|
|
1775
1775
|
});
|
|
1776
|
-
for (let e3 of [...s2.created, ...s2.skipped]) e3.name &&
|
|
1776
|
+
for (let e3 of [...s2.created, ...s2.skipped]) e3.name && Be.add(syncKey(a2, e3.name));
|
|
1777
1777
|
return o2.length;
|
|
1778
1778
|
}
|
|
1779
1779
|
async function flushPendingHostToolSyncs(e2) {
|
|
1780
1780
|
if (!e2.isHostToolServerSyncReady()) return;
|
|
1781
|
-
let t2 =
|
|
1781
|
+
let t2 = H.get(e2.id);
|
|
1782
1782
|
if (t2?.length) {
|
|
1783
|
-
|
|
1783
|
+
H.delete(e2.id);
|
|
1784
1784
|
for (let n2 of t2) await syncHostToolMetadataToServer(e2, n2);
|
|
1785
1785
|
}
|
|
1786
1786
|
}
|
|
@@ -1819,7 +1819,7 @@ function mergePageContextWithMentions(e2, t2) {
|
|
|
1819
1819
|
};
|
|
1820
1820
|
return n2.metadata = r2, Object.keys(n2).length > 0 ? n2 : null;
|
|
1821
1821
|
}
|
|
1822
|
-
var
|
|
1822
|
+
var U = "host:";
|
|
1823
1823
|
function slugContextMentionKey(e2) {
|
|
1824
1824
|
return e2.trim().toLowerCase().replace(/[^\w\u4e00-\u9fff]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "mention";
|
|
1825
1825
|
}
|
|
@@ -1847,10 +1847,10 @@ function coerceContextMentionPayload(e2) {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
function hostMentionId(e2) {
|
|
1849
1849
|
let t2 = e2.trim();
|
|
1850
|
-
return t2 ? t2.startsWith(
|
|
1850
|
+
return t2 ? t2.startsWith(U) ? t2 : `${U}${t2}` : `${U}mention`;
|
|
1851
1851
|
}
|
|
1852
1852
|
function normalizeContextMentionRegistration(e2) {
|
|
1853
|
-
let t2 = hostMentionId(e2.id || slugContextMentionKey(e2.label)), n2 = t2.startsWith(
|
|
1853
|
+
let t2 = hostMentionId(e2.id || slugContextMentionKey(e2.label)), n2 = t2.startsWith(U) ? t2.slice(5) : t2, r2 = e2.kind?.trim() || n2, i2 = e2.payload == null ? e2.description ? coerceContextMentionPayload(e2.description) : void 0 : coerceContextMentionPayload(e2.payload);
|
|
1854
1854
|
return {
|
|
1855
1855
|
...e2,
|
|
1856
1856
|
id: t2,
|
|
@@ -1959,7 +1959,7 @@ var HTTPError = class extends Error {
|
|
|
1959
1959
|
let t2 = e2?.cause ? e2.cause instanceof Error ? e2.cause : new NonError(e2.cause) : void 0;
|
|
1960
1960
|
super(e2?.code ? `Forced retry: ${e2.code}` : "Forced retry", t2 ? { cause: t2 } : void 0), h(this, "name", "ForceRetryError"), h(this, "customDelay", void 0), h(this, "code", void 0), h(this, "customRequest", void 0), this.customDelay = e2?.delay, this.code = e2?.code, this.customRequest = e2?.request;
|
|
1961
1961
|
}
|
|
1962
|
-
},
|
|
1962
|
+
}, Ve = (() => {
|
|
1963
1963
|
let e2 = false, t2 = false, n2 = typeof globalThis.ReadableStream == "function", r2 = typeof globalThis.Request == "function";
|
|
1964
1964
|
if (n2 && r2) try {
|
|
1965
1965
|
t2 = new globalThis.Request("https://empty.invalid", {
|
|
@@ -1974,25 +1974,25 @@ var HTTPError = class extends Error {
|
|
|
1974
1974
|
throw e3;
|
|
1975
1975
|
}
|
|
1976
1976
|
return e2 && !t2;
|
|
1977
|
-
})(),
|
|
1977
|
+
})(), He = typeof globalThis.AbortController == "function", Ue = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", We = typeof globalThis.ReadableStream == "function", Ge = typeof globalThis.FormData == "function", Ke = [
|
|
1978
1978
|
"get",
|
|
1979
1979
|
"post",
|
|
1980
1980
|
"put",
|
|
1981
1981
|
"patch",
|
|
1982
1982
|
"head",
|
|
1983
1983
|
"delete"
|
|
1984
|
-
],
|
|
1984
|
+
], qe = {
|
|
1985
1985
|
json: "application/json",
|
|
1986
1986
|
text: "text/*",
|
|
1987
1987
|
formData: "multipart/form-data",
|
|
1988
1988
|
arrayBuffer: "*/*",
|
|
1989
1989
|
blob: "*/*",
|
|
1990
1990
|
bytes: "*/*"
|
|
1991
|
-
},
|
|
1991
|
+
}, Je = 2147483647, Ye = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, Xe = Symbol("stop"), RetryMarker = class {
|
|
1992
1992
|
constructor(e2) {
|
|
1993
1993
|
h(this, "options", void 0), this.options = e2;
|
|
1994
1994
|
}
|
|
1995
|
-
}, retry = (e2) => new RetryMarker(e2),
|
|
1995
|
+
}, retry = (e2) => new RetryMarker(e2), Ze = {
|
|
1996
1996
|
json: true,
|
|
1997
1997
|
parseJson: true,
|
|
1998
1998
|
stringifyJson: true,
|
|
@@ -2006,7 +2006,7 @@ var HTTPError = class extends Error {
|
|
|
2006
2006
|
onUploadProgress: true,
|
|
2007
2007
|
fetch: true,
|
|
2008
2008
|
context: true
|
|
2009
|
-
},
|
|
2009
|
+
}, Qe = { next: true }, $e = {
|
|
2010
2010
|
method: true,
|
|
2011
2011
|
headers: true,
|
|
2012
2012
|
body: true,
|
|
@@ -2025,7 +2025,7 @@ var HTTPError = class extends Error {
|
|
|
2025
2025
|
if (!e2) return 0;
|
|
2026
2026
|
if (e2 instanceof FormData) {
|
|
2027
2027
|
let t2 = 0;
|
|
2028
|
-
for (let [n2, r2] of e2) t2 +=
|
|
2028
|
+
for (let [n2, r2] of e2) t2 += Ye, t2 += new TextEncoder().encode(`Content-Disposition: form-data; name="${n2}"`).length, t2 += typeof r2 == "string" ? new TextEncoder().encode(r2).length : r2.size;
|
|
2029
2029
|
return t2;
|
|
2030
2030
|
}
|
|
2031
2031
|
if (e2 instanceof Blob) return e2.size;
|
|
@@ -2145,8 +2145,8 @@ var mergeHooks = (e2 = {}, t2 = {}) => ({
|
|
|
2145
2145
|
}
|
|
2146
2146
|
isObject(o2.hooks) && (r2 = mergeHooks(r2, o2.hooks), t2.hooks = r2), isObject(o2.headers) && (n2 = mergeHeaders(n2, o2.headers), t2.headers = n2);
|
|
2147
2147
|
}
|
|
2148
|
-
return i2 !== void 0 && (t2.searchParams = i2), a2.length > 0 && (a2.length === 1 ? t2.signal = a2[0] :
|
|
2149
|
-
}, normalizeRequestMethod = (e2) =>
|
|
2148
|
+
return i2 !== void 0 && (t2.searchParams = i2), a2.length > 0 && (a2.length === 1 ? t2.signal = a2[0] : Ue ? t2.signal = AbortSignal.any(a2) : t2.signal = a2.at(-1)), t2;
|
|
2149
|
+
}, normalizeRequestMethod = (e2) => Ke.includes(e2) ? e2.toUpperCase() : e2, et = {
|
|
2150
2150
|
limit: 2,
|
|
2151
2151
|
methods: [
|
|
2152
2152
|
"get",
|
|
@@ -2177,14 +2177,14 @@ var mergeHooks = (e2 = {}, t2 = {}) => ({
|
|
|
2177
2177
|
retryOnTimeout: false
|
|
2178
2178
|
}, normalizeRetryOptions = (e2 = {}) => {
|
|
2179
2179
|
if (typeof e2 == "number") return {
|
|
2180
|
-
...
|
|
2180
|
+
...et,
|
|
2181
2181
|
limit: e2
|
|
2182
2182
|
};
|
|
2183
2183
|
if (e2.methods && !Array.isArray(e2.methods)) throw Error("retry.methods must be an array");
|
|
2184
2184
|
if (e2.methods && (e2.methods = e2.methods.map((e3) => e3.toLowerCase())), e2.statusCodes && !Array.isArray(e2.statusCodes)) throw Error("retry.statusCodes must be an array");
|
|
2185
2185
|
let t2 = Object.fromEntries(Object.entries(e2).filter(([, e3]) => e3 !== void 0));
|
|
2186
2186
|
return {
|
|
2187
|
-
...
|
|
2187
|
+
...et,
|
|
2188
2188
|
...t2
|
|
2189
2189
|
};
|
|
2190
2190
|
}, TimeoutError = class extends Error {
|
|
@@ -2215,7 +2215,7 @@ async function delay(e2, { signal: t2 }) {
|
|
|
2215
2215
|
}
|
|
2216
2216
|
var findUnknownOptions = (e2, t2) => {
|
|
2217
2217
|
let n2 = {};
|
|
2218
|
-
for (let r2 in t2) Object.hasOwn(t2, r2) && !(r2 in
|
|
2218
|
+
for (let r2 in t2) Object.hasOwn(t2, r2) && !(r2 in $e) && !(r2 in Ze) && (!(r2 in e2) || r2 in Qe) && (n2[r2] = t2[r2]);
|
|
2219
2219
|
return n2;
|
|
2220
2220
|
}, hasSearchParameters = (e2) => e2 === void 0 ? false : Array.isArray(e2) ? e2.length > 0 : e2 instanceof URLSearchParams ? e2.size > 0 : typeof e2 == "object" ? Object.keys(e2).length > 0 : typeof e2 == "string" ? e2.trim().length > 0 : !!e2;
|
|
2221
2221
|
function isHTTPError(e2) {
|
|
@@ -2243,40 +2243,40 @@ function _classPrivateFieldGet2(e2, t2) {
|
|
|
2243
2243
|
function _classPrivateFieldSet2(e2, t2, n2) {
|
|
2244
2244
|
return e2.set(_assertClassBrand(e2, t2), n2), n2;
|
|
2245
2245
|
}
|
|
2246
|
-
var
|
|
2246
|
+
var W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakSet(), tt = class Ky {
|
|
2247
2247
|
static create(e2, t2) {
|
|
2248
2248
|
let n2 = new Ky(e2, t2), function_ = async () => {
|
|
2249
|
-
if (typeof _classPrivateFieldGet2(
|
|
2249
|
+
if (typeof _classPrivateFieldGet2(q, n2).timeout == "number" && _classPrivateFieldGet2(q, n2).timeout > 2147483647) throw RangeError(`The \`timeout\` option cannot be greater than ${Je}`);
|
|
2250
2250
|
await Promise.resolve();
|
|
2251
|
-
let e3 = await _assertClassBrand(
|
|
2252
|
-
for (let t3 of _classPrivateFieldGet2(
|
|
2253
|
-
let r3 = _assertClassBrand(
|
|
2251
|
+
let e3 = await _assertClassBrand(Z, n2, _fetch).call(n2);
|
|
2252
|
+
for (let t3 of _classPrivateFieldGet2(q, n2).hooks.afterResponse) {
|
|
2253
|
+
let r3 = _assertClassBrand(Z, n2, _decorateResponse).call(n2, e3.clone()), i2;
|
|
2254
2254
|
try {
|
|
2255
|
-
i2 = await t3(n2.request, _assertClassBrand(
|
|
2255
|
+
i2 = await t3(n2.request, _assertClassBrand(Z, n2, _getNormalizedOptions).call(n2), r3, { retryCount: _classPrivateFieldGet2(G, n2) });
|
|
2256
2256
|
} catch (t4) {
|
|
2257
|
-
throw _assertClassBrand(
|
|
2257
|
+
throw _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, r3), _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, e3), t4;
|
|
2258
2258
|
}
|
|
2259
|
-
if (i2 instanceof RetryMarker) throw _assertClassBrand(
|
|
2259
|
+
if (i2 instanceof RetryMarker) throw _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, r3), _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, e3), new ForceRetryError(i2.options);
|
|
2260
2260
|
let a2 = i2 instanceof globalThis.Response ? i2 : e3;
|
|
2261
|
-
r3 !== a2 && _assertClassBrand(
|
|
2261
|
+
r3 !== a2 && _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, r3), e3 !== a2 && _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, e3), e3 = a2;
|
|
2262
2262
|
}
|
|
2263
|
-
if (_assertClassBrand(
|
|
2264
|
-
let t3 = new HTTPError(e3, n2.request, _assertClassBrand(
|
|
2265
|
-
for (let e4 of _classPrivateFieldGet2(
|
|
2263
|
+
if (_assertClassBrand(Z, n2, _decorateResponse).call(n2, e3), !e3.ok && (typeof _classPrivateFieldGet2(q, n2).throwHttpErrors == "function" ? _classPrivateFieldGet2(q, n2).throwHttpErrors(e3.status) : _classPrivateFieldGet2(q, n2).throwHttpErrors)) {
|
|
2264
|
+
let t3 = new HTTPError(e3, n2.request, _assertClassBrand(Z, n2, _getNormalizedOptions).call(n2));
|
|
2265
|
+
for (let e4 of _classPrivateFieldGet2(q, n2).hooks.beforeError) t3 = await e4(t3, { retryCount: _classPrivateFieldGet2(G, n2) });
|
|
2266
2266
|
throw t3;
|
|
2267
2267
|
}
|
|
2268
|
-
if (_classPrivateFieldGet2(
|
|
2269
|
-
if (typeof _classPrivateFieldGet2(
|
|
2270
|
-
if (!
|
|
2268
|
+
if (_classPrivateFieldGet2(q, n2).onDownloadProgress) {
|
|
2269
|
+
if (typeof _classPrivateFieldGet2(q, n2).onDownloadProgress != "function") throw TypeError("The `onDownloadProgress` option must be a function");
|
|
2270
|
+
if (!We) throw Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
2271
2271
|
let t3 = e3.clone();
|
|
2272
|
-
return _assertClassBrand(
|
|
2272
|
+
return _assertClassBrand(Z, n2, _cancelResponseBody).call(n2, e3), streamResponse(t3, _classPrivateFieldGet2(q, n2).onDownloadProgress);
|
|
2273
2273
|
}
|
|
2274
2274
|
return e3;
|
|
2275
|
-
}, r2 = _assertClassBrand(
|
|
2276
|
-
let e3 = _classPrivateFieldGet2(
|
|
2277
|
-
_assertClassBrand(
|
|
2275
|
+
}, r2 = _assertClassBrand(Z, n2, _retry).call(n2, function_).finally(() => {
|
|
2276
|
+
let e3 = _classPrivateFieldGet2(J, n2);
|
|
2277
|
+
_assertClassBrand(Z, n2, _cancelBody).call(n2, e3?.body ?? void 0), _assertClassBrand(Z, n2, _cancelBody).call(n2, n2.request.body ?? void 0);
|
|
2278
2278
|
});
|
|
2279
|
-
for (let [e3, i2] of Object.entries(
|
|
2279
|
+
for (let [e3, i2] of Object.entries(qe)) (e3 !== "bytes" || typeof globalThis.Response?.prototype?.bytes == "function") && (r2[e3] = async () => {
|
|
2280
2280
|
n2.request.headers.set("accept", n2.request.headers.get("accept") || i2);
|
|
2281
2281
|
let a2 = await r2;
|
|
2282
2282
|
if (e3 === "json") {
|
|
@@ -2289,37 +2289,37 @@ var H = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), W = /*
|
|
|
2289
2289
|
return r2;
|
|
2290
2290
|
}
|
|
2291
2291
|
constructor(e2, t2 = {}) {
|
|
2292
|
-
if (_classPrivateMethodInitSpec(this,
|
|
2292
|
+
if (_classPrivateMethodInitSpec(this, Z), h(this, "request", void 0), _classPrivateFieldInitSpec(this, W, void 0), _classPrivateFieldInitSpec(this, G, 0), _classPrivateFieldInitSpec(this, K, void 0), _classPrivateFieldInitSpec(this, q, void 0), _classPrivateFieldInitSpec(this, J, void 0), _classPrivateFieldInitSpec(this, Y, void 0), _classPrivateFieldInitSpec(this, X, void 0), _classPrivateFieldSet2(K, this, e2), _classPrivateFieldSet2(q, this, {
|
|
2293
2293
|
...t2,
|
|
2294
|
-
headers: mergeHeaders(_classPrivateFieldGet2(
|
|
2294
|
+
headers: mergeHeaders(_classPrivateFieldGet2(K, this).headers, t2.headers),
|
|
2295
2295
|
hooks: mergeHooks({
|
|
2296
2296
|
beforeRequest: [],
|
|
2297
2297
|
beforeRetry: [],
|
|
2298
2298
|
beforeError: [],
|
|
2299
2299
|
afterResponse: []
|
|
2300
2300
|
}, t2.hooks),
|
|
2301
|
-
method: normalizeRequestMethod(t2.method ?? _classPrivateFieldGet2(
|
|
2301
|
+
method: normalizeRequestMethod(t2.method ?? _classPrivateFieldGet2(K, this).method ?? "GET"),
|
|
2302
2302
|
prefixUrl: String(t2.prefixUrl || ""),
|
|
2303
2303
|
retry: normalizeRetryOptions(t2.retry),
|
|
2304
2304
|
throwHttpErrors: t2.throwHttpErrors ?? true,
|
|
2305
2305
|
timeout: t2.timeout ?? 1e4,
|
|
2306
2306
|
fetch: t2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
2307
2307
|
context: t2.context ?? {}
|
|
2308
|
-
}), typeof _classPrivateFieldGet2(
|
|
2309
|
-
if (_classPrivateFieldGet2(
|
|
2310
|
-
if (_classPrivateFieldGet2(
|
|
2311
|
-
_classPrivateFieldGet2(
|
|
2308
|
+
}), typeof _classPrivateFieldGet2(K, this) != "string" && !(_classPrivateFieldGet2(K, this) instanceof URL || _classPrivateFieldGet2(K, this) instanceof globalThis.Request)) throw TypeError("`input` must be a string, URL, or Request");
|
|
2309
|
+
if (_classPrivateFieldGet2(q, this).prefixUrl && typeof _classPrivateFieldGet2(K, this) == "string") {
|
|
2310
|
+
if (_classPrivateFieldGet2(K, this).startsWith("/")) throw Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
2311
|
+
_classPrivateFieldGet2(q, this).prefixUrl.endsWith("/") || (_classPrivateFieldGet2(q, this).prefixUrl += "/"), _classPrivateFieldSet2(K, this, _classPrivateFieldGet2(q, this).prefixUrl + _classPrivateFieldGet2(K, this));
|
|
2312
2312
|
}
|
|
2313
|
-
|
|
2313
|
+
He && Ue && (_classPrivateFieldSet2(Y, this, _classPrivateFieldGet2(q, this).signal ?? _classPrivateFieldGet2(K, this).signal), _classPrivateFieldSet2(W, this, new globalThis.AbortController()), _classPrivateFieldGet2(q, this).signal = _classPrivateFieldGet2(Y, this) ? AbortSignal.any([_classPrivateFieldGet2(Y, this), _classPrivateFieldGet2(W, this).signal]) : _classPrivateFieldGet2(W, this).signal), Ve && (_classPrivateFieldGet2(q, this).duplex = "half"), _classPrivateFieldGet2(q, this).json !== void 0 && (_classPrivateFieldGet2(q, this).body = _classPrivateFieldGet2(q, this).stringifyJson?.(_classPrivateFieldGet2(q, this).json) ?? JSON.stringify(_classPrivateFieldGet2(q, this).json), _classPrivateFieldGet2(q, this).headers.set("content-type", _classPrivateFieldGet2(q, this).headers.get("content-type") ?? "application/json"));
|
|
2314
2314
|
let n2 = t2.headers && new globalThis.Headers(t2.headers).has("content-type");
|
|
2315
|
-
if (_classPrivateFieldGet2(
|
|
2316
|
-
let e3 = "?" + (typeof _classPrivateFieldGet2(
|
|
2317
|
-
this.request = new globalThis.Request(t3, _classPrivateFieldGet2(
|
|
2315
|
+
if (_classPrivateFieldGet2(K, this) instanceof globalThis.Request && (Ge && _classPrivateFieldGet2(q, this).body instanceof globalThis.FormData || _classPrivateFieldGet2(q, this).body instanceof URLSearchParams) && !n2 && _classPrivateFieldGet2(q, this).headers.delete("content-type"), this.request = new globalThis.Request(_classPrivateFieldGet2(K, this), _classPrivateFieldGet2(q, this)), hasSearchParameters(_classPrivateFieldGet2(q, this).searchParams)) {
|
|
2316
|
+
let e3 = "?" + (typeof _classPrivateFieldGet2(q, this).searchParams == "string" ? _classPrivateFieldGet2(q, this).searchParams.replace(/^\?/, "") : new URLSearchParams(_normalizeSearchParams.call(Ky, _classPrivateFieldGet2(q, this).searchParams)).toString()), t3 = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, e3);
|
|
2317
|
+
this.request = new globalThis.Request(t3, _classPrivateFieldGet2(q, this));
|
|
2318
2318
|
}
|
|
2319
|
-
if (_classPrivateFieldGet2(
|
|
2320
|
-
if (typeof _classPrivateFieldGet2(
|
|
2321
|
-
if (!
|
|
2322
|
-
this.request = _assertClassBrand(
|
|
2319
|
+
if (_classPrivateFieldGet2(q, this).onUploadProgress) {
|
|
2320
|
+
if (typeof _classPrivateFieldGet2(q, this).onUploadProgress != "function") throw TypeError("The `onUploadProgress` option must be a function");
|
|
2321
|
+
if (!Ve) throw Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
2322
|
+
this.request = _assertClassBrand(Z, this, _wrapRequestWithUploadProgress).call(this, this.request, _classPrivateFieldGet2(q, this).body ?? void 0);
|
|
2323
2323
|
}
|
|
2324
2324
|
}
|
|
2325
2325
|
};
|
|
@@ -2327,106 +2327,106 @@ function _normalizeSearchParams(e2) {
|
|
|
2327
2327
|
return e2 && typeof e2 == "object" && !Array.isArray(e2) && !(e2 instanceof URLSearchParams) ? Object.fromEntries(Object.entries(e2).filter(([, e3]) => e3 !== void 0)) : e2;
|
|
2328
2328
|
}
|
|
2329
2329
|
function _calculateDelay() {
|
|
2330
|
-
let e2 = _classPrivateFieldGet2(
|
|
2331
|
-
_classPrivateFieldGet2(
|
|
2332
|
-
let n2 = _classPrivateFieldGet2(
|
|
2330
|
+
let e2 = _classPrivateFieldGet2(q, this).retry.delay(_classPrivateFieldGet2(G, this)), t2 = e2;
|
|
2331
|
+
_classPrivateFieldGet2(q, this).retry.jitter === true ? t2 = Math.random() * e2 : typeof _classPrivateFieldGet2(q, this).retry.jitter == "function" && (t2 = _classPrivateFieldGet2(q, this).retry.jitter(e2), (!Number.isFinite(t2) || t2 < 0) && (t2 = e2));
|
|
2332
|
+
let n2 = _classPrivateFieldGet2(q, this).retry.backoffLimit ?? Infinity;
|
|
2333
2333
|
return Math.min(n2, t2);
|
|
2334
2334
|
}
|
|
2335
2335
|
async function _calculateRetryDelay(e2) {
|
|
2336
2336
|
var t2;
|
|
2337
|
-
if (_classPrivateFieldSet2(
|
|
2337
|
+
if (_classPrivateFieldSet2(G, this, (t2 = _classPrivateFieldGet2(G, this), t2++, t2)), _classPrivateFieldGet2(G, this) > _classPrivateFieldGet2(q, this).retry.limit) throw e2;
|
|
2338
2338
|
let n2 = e2 instanceof Error ? e2 : new NonError(e2);
|
|
2339
|
-
if (n2 instanceof ForceRetryError) return n2.customDelay ?? _assertClassBrand(
|
|
2340
|
-
if (!_classPrivateFieldGet2(
|
|
2341
|
-
if (_classPrivateFieldGet2(
|
|
2342
|
-
let t3 = await _classPrivateFieldGet2(
|
|
2339
|
+
if (n2 instanceof ForceRetryError) return n2.customDelay ?? _assertClassBrand(Z, this, _calculateDelay).call(this);
|
|
2340
|
+
if (!_classPrivateFieldGet2(q, this).retry.methods.includes(this.request.method.toLowerCase())) throw e2;
|
|
2341
|
+
if (_classPrivateFieldGet2(q, this).retry.shouldRetry !== void 0) {
|
|
2342
|
+
let t3 = await _classPrivateFieldGet2(q, this).retry.shouldRetry({
|
|
2343
2343
|
error: n2,
|
|
2344
|
-
retryCount: _classPrivateFieldGet2(
|
|
2344
|
+
retryCount: _classPrivateFieldGet2(G, this)
|
|
2345
2345
|
});
|
|
2346
2346
|
if (t3 === false) throw e2;
|
|
2347
|
-
if (t3 === true) return _assertClassBrand(
|
|
2347
|
+
if (t3 === true) return _assertClassBrand(Z, this, _calculateDelay).call(this);
|
|
2348
2348
|
}
|
|
2349
|
-
if (isTimeoutError(e2) && !_classPrivateFieldGet2(
|
|
2349
|
+
if (isTimeoutError(e2) && !_classPrivateFieldGet2(q, this).retry.retryOnTimeout) throw e2;
|
|
2350
2350
|
if (isHTTPError(e2)) {
|
|
2351
|
-
if (!_classPrivateFieldGet2(
|
|
2351
|
+
if (!_classPrivateFieldGet2(q, this).retry.statusCodes.includes(e2.response.status)) throw e2;
|
|
2352
2352
|
let t3 = e2.response.headers.get("Retry-After") ?? e2.response.headers.get("RateLimit-Reset") ?? e2.response.headers.get("X-RateLimit-Retry-After") ?? e2.response.headers.get("X-RateLimit-Reset") ?? e2.response.headers.get("X-Rate-Limit-Reset");
|
|
2353
|
-
if (t3 && _classPrivateFieldGet2(
|
|
2353
|
+
if (t3 && _classPrivateFieldGet2(q, this).retry.afterStatusCodes.includes(e2.response.status)) {
|
|
2354
2354
|
let e3 = Number(t3) * 1e3;
|
|
2355
2355
|
Number.isNaN(e3) ? e3 = Date.parse(t3) - Date.now() : e3 >= Date.parse("2024-01-01") && (e3 -= Date.now());
|
|
2356
|
-
let n3 = _classPrivateFieldGet2(
|
|
2356
|
+
let n3 = _classPrivateFieldGet2(q, this).retry.maxRetryAfter ?? e3;
|
|
2357
2357
|
return e3 < n3 ? e3 : n3;
|
|
2358
2358
|
}
|
|
2359
2359
|
if (e2.response.status === 413) throw e2;
|
|
2360
2360
|
}
|
|
2361
|
-
return _assertClassBrand(
|
|
2361
|
+
return _assertClassBrand(Z, this, _calculateDelay).call(this);
|
|
2362
2362
|
}
|
|
2363
2363
|
function _decorateResponse(e2) {
|
|
2364
|
-
return _classPrivateFieldGet2(
|
|
2364
|
+
return _classPrivateFieldGet2(q, this).parseJson && (e2.json = async () => _classPrivateFieldGet2(q, this).parseJson(await e2.text())), e2;
|
|
2365
2365
|
}
|
|
2366
2366
|
function _cancelBody(e2) {
|
|
2367
2367
|
e2 && e2.cancel().catch(() => void 0);
|
|
2368
2368
|
}
|
|
2369
2369
|
function _cancelResponseBody(e2) {
|
|
2370
|
-
_assertClassBrand(
|
|
2370
|
+
_assertClassBrand(Z, this, _cancelBody).call(this, e2.body ?? void 0);
|
|
2371
2371
|
}
|
|
2372
2372
|
async function _retry(e2) {
|
|
2373
2373
|
try {
|
|
2374
2374
|
return await e2();
|
|
2375
2375
|
} catch (t2) {
|
|
2376
|
-
let n2 = Math.min(await _assertClassBrand(
|
|
2377
|
-
if (_classPrivateFieldGet2(
|
|
2378
|
-
if (await delay(n2, _classPrivateFieldGet2(
|
|
2379
|
-
let e3 = _classPrivateFieldGet2(
|
|
2380
|
-
_assertClassBrand(
|
|
2376
|
+
let n2 = Math.min(await _assertClassBrand(Z, this, _calculateRetryDelay).call(this, t2), Je);
|
|
2377
|
+
if (_classPrivateFieldGet2(G, this) < 1) throw t2;
|
|
2378
|
+
if (await delay(n2, _classPrivateFieldGet2(Y, this) ? { signal: _classPrivateFieldGet2(Y, this) } : {}), t2 instanceof ForceRetryError && t2.customRequest) {
|
|
2379
|
+
let e3 = _classPrivateFieldGet2(q, this).signal ? new globalThis.Request(t2.customRequest, { signal: _classPrivateFieldGet2(q, this).signal }) : new globalThis.Request(t2.customRequest);
|
|
2380
|
+
_assertClassBrand(Z, this, _assignRequest).call(this, e3);
|
|
2381
2381
|
}
|
|
2382
|
-
for (let e3 of _classPrivateFieldGet2(
|
|
2382
|
+
for (let e3 of _classPrivateFieldGet2(q, this).hooks.beforeRetry) {
|
|
2383
2383
|
let n3 = await e3({
|
|
2384
2384
|
request: this.request,
|
|
2385
|
-
options: _assertClassBrand(
|
|
2385
|
+
options: _assertClassBrand(Z, this, _getNormalizedOptions).call(this),
|
|
2386
2386
|
error: t2,
|
|
2387
|
-
retryCount: _classPrivateFieldGet2(
|
|
2387
|
+
retryCount: _classPrivateFieldGet2(G, this)
|
|
2388
2388
|
});
|
|
2389
2389
|
if (n3 instanceof globalThis.Request) {
|
|
2390
|
-
_assertClassBrand(
|
|
2390
|
+
_assertClassBrand(Z, this, _assignRequest).call(this, n3);
|
|
2391
2391
|
break;
|
|
2392
2392
|
}
|
|
2393
2393
|
if (n3 instanceof globalThis.Response) return n3;
|
|
2394
|
-
if (n3 ===
|
|
2394
|
+
if (n3 === Xe) return;
|
|
2395
2395
|
}
|
|
2396
|
-
return _assertClassBrand(
|
|
2396
|
+
return _assertClassBrand(Z, this, _retry).call(this, e2);
|
|
2397
2397
|
}
|
|
2398
2398
|
}
|
|
2399
2399
|
async function _fetch() {
|
|
2400
|
-
_classPrivateFieldGet2(
|
|
2401
|
-
for (let e3 of _classPrivateFieldGet2(
|
|
2402
|
-
let t2 = await e3(this.request, _assertClassBrand(
|
|
2400
|
+
_classPrivateFieldGet2(W, this)?.signal.aborted && (_classPrivateFieldSet2(W, this, new globalThis.AbortController()), _classPrivateFieldGet2(q, this).signal = _classPrivateFieldGet2(Y, this) ? AbortSignal.any([_classPrivateFieldGet2(Y, this), _classPrivateFieldGet2(W, this).signal]) : _classPrivateFieldGet2(W, this).signal, this.request = new globalThis.Request(this.request, { signal: _classPrivateFieldGet2(q, this).signal }));
|
|
2401
|
+
for (let e3 of _classPrivateFieldGet2(q, this).hooks.beforeRequest) {
|
|
2402
|
+
let t2 = await e3(this.request, _assertClassBrand(Z, this, _getNormalizedOptions).call(this), { retryCount: _classPrivateFieldGet2(G, this) });
|
|
2403
2403
|
if (t2 instanceof Response) return t2;
|
|
2404
2404
|
if (t2 instanceof globalThis.Request) {
|
|
2405
|
-
_assertClassBrand(
|
|
2405
|
+
_assertClassBrand(Z, this, _assignRequest).call(this, t2);
|
|
2406
2406
|
break;
|
|
2407
2407
|
}
|
|
2408
2408
|
}
|
|
2409
|
-
let e2 = findUnknownOptions(this.request, _classPrivateFieldGet2(
|
|
2410
|
-
return _classPrivateFieldSet2(
|
|
2409
|
+
let e2 = findUnknownOptions(this.request, _classPrivateFieldGet2(q, this));
|
|
2410
|
+
return _classPrivateFieldSet2(J, this, this.request), this.request = _classPrivateFieldGet2(J, this).clone(), _classPrivateFieldGet2(q, this).timeout === false ? _classPrivateFieldGet2(q, this).fetch(_classPrivateFieldGet2(J, this), e2) : timeout(_classPrivateFieldGet2(J, this), e2, _classPrivateFieldGet2(W, this), _classPrivateFieldGet2(q, this));
|
|
2411
2411
|
}
|
|
2412
2412
|
function _getNormalizedOptions() {
|
|
2413
|
-
if (!_classPrivateFieldGet2(
|
|
2414
|
-
let { hooks: e2, ...t2 } = _classPrivateFieldGet2(
|
|
2415
|
-
_classPrivateFieldSet2(
|
|
2413
|
+
if (!_classPrivateFieldGet2(X, this)) {
|
|
2414
|
+
let { hooks: e2, ...t2 } = _classPrivateFieldGet2(q, this);
|
|
2415
|
+
_classPrivateFieldSet2(X, this, Object.freeze(t2));
|
|
2416
2416
|
}
|
|
2417
|
-
return _classPrivateFieldGet2(
|
|
2417
|
+
return _classPrivateFieldGet2(X, this);
|
|
2418
2418
|
}
|
|
2419
2419
|
function _assignRequest(e2) {
|
|
2420
|
-
_classPrivateFieldSet2(
|
|
2420
|
+
_classPrivateFieldSet2(X, this, void 0), this.request = _assertClassBrand(Z, this, _wrapRequestWithUploadProgress).call(this, e2);
|
|
2421
2421
|
}
|
|
2422
2422
|
function _wrapRequestWithUploadProgress(e2, t2) {
|
|
2423
|
-
return !_classPrivateFieldGet2(
|
|
2423
|
+
return !_classPrivateFieldGet2(q, this).onUploadProgress || !e2.body ? e2 : streamRequest(e2, _classPrivateFieldGet2(q, this).onUploadProgress, t2 ?? _classPrivateFieldGet2(q, this).body ?? void 0);
|
|
2424
2424
|
}
|
|
2425
2425
|
var createInstance = (e2) => {
|
|
2426
|
-
let ky = (t2, n2) =>
|
|
2427
|
-
for (let t2 of
|
|
2428
|
-
return ky.create = (e3) => createInstance(validateAndMerge(e3)), ky.extend = (t2) => (typeof t2 == "function" && (t2 = t2(e2 ?? {})), createInstance(validateAndMerge(e2, t2))), ky.stop =
|
|
2429
|
-
},
|
|
2426
|
+
let ky = (t2, n2) => tt.create(t2, validateAndMerge(e2, n2));
|
|
2427
|
+
for (let t2 of Ke) ky[t2] = (n2, r2) => tt.create(n2, validateAndMerge(e2, r2, { method: t2 }));
|
|
2428
|
+
return ky.create = (e3) => createInstance(validateAndMerge(e3)), ky.extend = (t2) => (typeof t2 == "function" && (t2 = t2(e2 ?? {})), createInstance(validateAndMerge(e2, t2))), ky.stop = Xe, ky.retry = retry, ky;
|
|
2429
|
+
}, nt = createInstance();
|
|
2430
2430
|
function normalizeServerMessage(e2) {
|
|
2431
2431
|
if (typeof e2 == "string") return e2;
|
|
2432
2432
|
if (Array.isArray(e2)) return e2.filter((e3) => typeof e3 == "string").join("; ") || void 0;
|
|
@@ -2445,7 +2445,7 @@ async function readHttpError(e2) {
|
|
|
2445
2445
|
} catch {
|
|
2446
2446
|
}
|
|
2447
2447
|
let i2 = n2 ? `HTTP ${e2.status}: ${n2}` : `HTTP ${e2.status}: ${e2.statusText || "request failed"}`, a2 = typeof r2 == "object" && r2 && !Array.isArray(r2) && "data" in r2 ? r2.data : r2;
|
|
2448
|
-
return new
|
|
2448
|
+
return new P("TRANSPORT_FAILED", i2, { details: {
|
|
2449
2449
|
status: e2.status,
|
|
2450
2450
|
serverCode: t2,
|
|
2451
2451
|
url: e2.url,
|
|
@@ -2454,19 +2454,19 @@ async function readHttpError(e2) {
|
|
|
2454
2454
|
} });
|
|
2455
2455
|
}
|
|
2456
2456
|
function toTransportAbortError(e2, t2 = "Request aborted") {
|
|
2457
|
-
return new
|
|
2457
|
+
return new P("TRANSPORT_ABORTED", t2, { cause: e2 });
|
|
2458
2458
|
}
|
|
2459
2459
|
function toNetworkError(e2, t2 = "Network error") {
|
|
2460
|
-
return new
|
|
2460
|
+
return new P("TRANSPORT_FAILED", t2, { cause: e2 });
|
|
2461
2461
|
}
|
|
2462
2462
|
function isAbortError(e2) {
|
|
2463
|
-
return e2 instanceof
|
|
2463
|
+
return e2 instanceof P && e2.code === "TRANSPORT_ABORTED" || e2?.name === "AbortError";
|
|
2464
2464
|
}
|
|
2465
2465
|
var ParseError = class extends Error {
|
|
2466
2466
|
constructor(e2, t2) {
|
|
2467
2467
|
super(e2), this.name = "ParseError", this.type = t2.type, this.field = t2.field, this.value = t2.value, this.line = t2.line;
|
|
2468
2468
|
}
|
|
2469
|
-
},
|
|
2469
|
+
}, rt = 10, it = 13, Q = 32;
|
|
2470
2470
|
function noop(e2) {
|
|
2471
2471
|
}
|
|
2472
2472
|
function createParser(e2) {
|
|
@@ -2507,8 +2507,8 @@ function createParser(e2) {
|
|
|
2507
2507
|
}
|
|
2508
2508
|
let i3 = e3.charCodeAt(n3);
|
|
2509
2509
|
if (isDataPrefix(e3, n3, i3)) {
|
|
2510
|
-
let i4 = e3.charCodeAt(n3 + 5) ===
|
|
2511
|
-
if (d2 === 0 && e3.charCodeAt(r3 + 1) ===
|
|
2510
|
+
let i4 = e3.charCodeAt(n3 + 5) === Q ? n3 + 6 : n3 + 5, a3 = e3.slice(i4, r3);
|
|
2511
|
+
if (d2 === 0 && e3.charCodeAt(r3 + 1) === rt) {
|
|
2512
2512
|
t2({
|
|
2513
2513
|
id: l2,
|
|
2514
2514
|
event: f2,
|
|
@@ -2518,7 +2518,7 @@ function createParser(e2) {
|
|
|
2518
2518
|
}
|
|
2519
2519
|
u2 = d2 === 0 ? a3 : `${u2}
|
|
2520
2520
|
${a3}`, d2++;
|
|
2521
|
-
} else isEventPrefix(e3, n3, i3) ? f2 = e3.slice(e3.charCodeAt(n3 + 6) ===
|
|
2521
|
+
} else isEventPrefix(e3, n3, i3) ? f2 = e3.slice(e3.charCodeAt(n3 + 6) === Q ? n3 + 7 : n3 + 6, r3) || void 0 : parseLine(e3, n3, r3);
|
|
2522
2522
|
n3 = r3 + 1, r3 = e3.indexOf("\n", n3);
|
|
2523
2523
|
}
|
|
2524
2524
|
return e3.slice(n3);
|
|
@@ -2526,7 +2526,7 @@ ${a3}`, d2++;
|
|
|
2526
2526
|
for (; n3 < e3.length; ) {
|
|
2527
2527
|
let t3 = e3.indexOf("\r", n3), r3 = e3.indexOf("\n", n3), i3 = -1;
|
|
2528
2528
|
if (t3 !== -1 && r3 !== -1 ? i3 = t3 < r3 ? t3 : r3 : t3 === -1 ? r3 !== -1 && (i3 = r3) : i3 = t3 === e3.length - 1 ? -1 : t3, i3 === -1) break;
|
|
2529
|
-
parseLine(e3, n3, i3), n3 = i3 + 1, e3.charCodeAt(n3 - 1) ===
|
|
2529
|
+
parseLine(e3, n3, i3), n3 = i3 + 1, e3.charCodeAt(n3 - 1) === it && e3.charCodeAt(n3) === rt && n3++;
|
|
2530
2530
|
}
|
|
2531
2531
|
return e3.slice(n3);
|
|
2532
2532
|
}
|
|
@@ -2537,24 +2537,24 @@ ${a3}`, d2++;
|
|
|
2537
2537
|
}
|
|
2538
2538
|
let r3 = e3.charCodeAt(t3);
|
|
2539
2539
|
if (isDataPrefix(e3, t3, r3)) {
|
|
2540
|
-
let r4 = e3.charCodeAt(t3 + 5) ===
|
|
2540
|
+
let r4 = e3.charCodeAt(t3 + 5) === Q ? t3 + 6 : t3 + 5, i3 = e3.slice(r4, n3);
|
|
2541
2541
|
u2 = d2 === 0 ? i3 : `${u2}
|
|
2542
2542
|
${i3}`, d2++;
|
|
2543
2543
|
return;
|
|
2544
2544
|
}
|
|
2545
2545
|
if (isEventPrefix(e3, t3, r3)) {
|
|
2546
|
-
f2 = e3.slice(e3.charCodeAt(t3 + 6) ===
|
|
2546
|
+
f2 = e3.slice(e3.charCodeAt(t3 + 6) === Q ? t3 + 7 : t3 + 6, n3) || void 0;
|
|
2547
2547
|
return;
|
|
2548
2548
|
}
|
|
2549
2549
|
if (r3 === 105 && e3.charCodeAt(t3 + 1) === 100 && e3.charCodeAt(t3 + 2) === 58) {
|
|
2550
|
-
let r4 = e3.slice(e3.charCodeAt(t3 + 3) ===
|
|
2550
|
+
let r4 = e3.slice(e3.charCodeAt(t3 + 3) === Q ? t3 + 4 : t3 + 3, n3);
|
|
2551
2551
|
r4.includes("\0") || (l2 = r4);
|
|
2552
2552
|
return;
|
|
2553
2553
|
}
|
|
2554
2554
|
if (r3 === 58) {
|
|
2555
2555
|
if (i2) {
|
|
2556
2556
|
let r4 = e3.slice(t3, n3);
|
|
2557
|
-
i2(r4.slice(e3.charCodeAt(t3 + 1) ===
|
|
2557
|
+
i2(r4.slice(e3.charCodeAt(t3 + 1) === Q ? 2 : 1));
|
|
2558
2558
|
}
|
|
2559
2559
|
return;
|
|
2560
2560
|
}
|
|
@@ -2563,7 +2563,7 @@ ${i3}`, d2++;
|
|
|
2563
2563
|
processField(a3, "", a3);
|
|
2564
2564
|
return;
|
|
2565
2565
|
}
|
|
2566
|
-
let s3 = a3.slice(0, o3), c3 = a3.charCodeAt(o3 + 1) ===
|
|
2566
|
+
let s3 = a3.slice(0, o3), c3 = a3.charCodeAt(o3 + 1) === Q ? 2 : 1;
|
|
2567
2567
|
processField(s3, a3.slice(o3 + c3), a3);
|
|
2568
2568
|
}
|
|
2569
2569
|
function processField(e3, t3, i3) {
|
|
@@ -2640,7 +2640,7 @@ async function* readSseStream(e2, t2, n2, r2 = {}) {
|
|
|
2640
2640
|
throw toNetworkError(e3);
|
|
2641
2641
|
}
|
|
2642
2642
|
if (!s2.ok) throw await readHttpError(s2);
|
|
2643
|
-
if (!s2.body) throw new
|
|
2643
|
+
if (!s2.body) throw new P("TRANSPORT_FAILED", "SSE response has no body");
|
|
2644
2644
|
r2.onConnected?.();
|
|
2645
2645
|
let c2 = s2.body.getReader(), l2 = new TextDecoder("utf-8"), u2 = [], d2 = createParser({ onEvent(e3) {
|
|
2646
2646
|
let t3 = e3.event?.trim() ? e3.event.trim() : "message";
|
|
@@ -2679,8 +2679,8 @@ function mergeRequestHeaders(e2, t2) {
|
|
|
2679
2679
|
}
|
|
2680
2680
|
function createHttpClient(e2) {
|
|
2681
2681
|
let t2 = e2.apiBase.replace(/\/+$/, ""), n2 = { ...e2.defaultHeaders ?? {} }, r2 = e2.fetch ?? (typeof fetch < "u" ? fetch.bind(globalThis) : void 0);
|
|
2682
|
-
if (!r2) throw new
|
|
2683
|
-
let i2 =
|
|
2682
|
+
if (!r2) throw new P("TRANSPORT_FAILED", "No fetch implementation available. Provide one via HttpClientOptions.fetch.");
|
|
2683
|
+
let i2 = nt.create({
|
|
2684
2684
|
prefixUrl: `${t2}/`,
|
|
2685
2685
|
retry: { limit: 0 },
|
|
2686
2686
|
timeout: false,
|
|
@@ -2708,7 +2708,7 @@ function createHttpClient(e2) {
|
|
|
2708
2708
|
});
|
|
2709
2709
|
return n3.status === 204 ? void 0 : (n3.headers.get("content-type") ?? "").includes("application/json") ? await n3.json() : await n3.text();
|
|
2710
2710
|
} catch (e4) {
|
|
2711
|
-
throw e4 instanceof
|
|
2711
|
+
throw e4 instanceof P ? e4 : isAbortError(e4) ? toTransportAbortError(e4) : toNetworkError(e4);
|
|
2712
2712
|
}
|
|
2713
2713
|
},
|
|
2714
2714
|
stream(e3, i3 = {}) {
|
|
@@ -2726,7 +2726,7 @@ var AuthService = class {
|
|
|
2726
2726
|
method: "POST",
|
|
2727
2727
|
headers: buildAppClientAuthHeaders(e2, t2)
|
|
2728
2728
|
}));
|
|
2729
|
-
if (!n2?.ok) throw new
|
|
2729
|
+
if (!n2?.ok) throw new P("AUTH_REQUIRED", "App client authentication failed");
|
|
2730
2730
|
return n2;
|
|
2731
2731
|
}
|
|
2732
2732
|
async login(e2, t2) {
|
|
@@ -2737,7 +2737,7 @@ var AuthService = class {
|
|
|
2737
2737
|
password: t2
|
|
2738
2738
|
}
|
|
2739
2739
|
}));
|
|
2740
|
-
if (!n2?.accessToken) throw new
|
|
2740
|
+
if (!n2?.accessToken) throw new P("LOGIN_FAILED", "Login succeeded but accessToken is missing");
|
|
2741
2741
|
return n2;
|
|
2742
2742
|
}
|
|
2743
2743
|
};
|
|
@@ -2755,7 +2755,7 @@ var AgentService = class {
|
|
|
2755
2755
|
method: "GET",
|
|
2756
2756
|
signal: t2.signal,
|
|
2757
2757
|
searchParams: t2.searchParams,
|
|
2758
|
-
omitDefaultHeaders: [
|
|
2758
|
+
omitDefaultHeaders: [F],
|
|
2759
2759
|
headers: buildAgentClientHeaders(e2)
|
|
2760
2760
|
};
|
|
2761
2761
|
}
|
|
@@ -2783,12 +2783,12 @@ function buildPageContextRequestBody(e2) {
|
|
|
2783
2783
|
return e2.page && (t2.page = e2.page), e2.routePath && (t2.routePath = e2.routePath), e2.routeParams && (t2.routeParams = e2.routeParams), e2.flowId != null && (t2.flowId = e2.flowId), e2.programName && (t2.programName = e2.programName), e2.entity && (t2.entity = e2.entity), e2.metadata && (t2.metadata = e2.metadata), t2;
|
|
2784
2784
|
}
|
|
2785
2785
|
function isContentFieldRejected(e2) {
|
|
2786
|
-
return !(e2 instanceof
|
|
2786
|
+
return !(e2 instanceof P) || e2.code !== "TRANSPORT_FAILED" ? false : e2.message.toLowerCase().includes("property content should not exist");
|
|
2787
2787
|
}
|
|
2788
2788
|
function normalizeSessionId$2(e2) {
|
|
2789
2789
|
return e2.trim().toLowerCase();
|
|
2790
2790
|
}
|
|
2791
|
-
|
|
2791
|
+
w(normalizeSessionId$2, "normalizeSessionId");
|
|
2792
2792
|
var ChatService = class {
|
|
2793
2793
|
constructor(e2) {
|
|
2794
2794
|
h(this, "http", void 0), this.http = e2;
|
|
@@ -2900,11 +2900,11 @@ function pickPageContextFields(e2) {
|
|
|
2900
2900
|
function isRecord$6(e2) {
|
|
2901
2901
|
return typeof e2 == "object" && !!e2;
|
|
2902
2902
|
}
|
|
2903
|
-
|
|
2903
|
+
w(isRecord$6, "isRecord");
|
|
2904
2904
|
function readString$4(e2) {
|
|
2905
2905
|
return typeof e2 == "string" && e2.trim().length > 0 ? e2.trim() : void 0;
|
|
2906
2906
|
}
|
|
2907
|
-
|
|
2907
|
+
w(readString$4, "readString");
|
|
2908
2908
|
function readNumber$3(e2) {
|
|
2909
2909
|
if (typeof e2 == "number" && Number.isFinite(e2)) return e2;
|
|
2910
2910
|
if (typeof e2 == "string" && e2.trim().length > 0) {
|
|
@@ -2912,11 +2912,11 @@ function readNumber$3(e2) {
|
|
|
2912
2912
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
2913
2913
|
}
|
|
2914
2914
|
}
|
|
2915
|
-
|
|
2915
|
+
w(readNumber$3, "readNumber");
|
|
2916
2916
|
function parseApiEnvelope(e2) {
|
|
2917
|
-
if (!isRecord$6(e2)) throw new
|
|
2917
|
+
if (!isRecord$6(e2)) throw new P("TRANSPORT_FAILED", "Invalid API response");
|
|
2918
2918
|
let t2 = readNumber$3(e2.status);
|
|
2919
|
-
if (t2 !== void 0 && t2 !== 200) throw new
|
|
2919
|
+
if (t2 !== void 0 && t2 !== 200) throw new P("TRANSPORT_FAILED", readString$4(e2.message) ?? "request failed", { details: {
|
|
2920
2920
|
status: t2,
|
|
2921
2921
|
data: e2.data
|
|
2922
2922
|
} });
|
|
@@ -2927,7 +2927,7 @@ function parseApiEnvelope(e2) {
|
|
|
2927
2927
|
function normalizeSessionId$1(e2) {
|
|
2928
2928
|
return e2.trim().toLowerCase();
|
|
2929
2929
|
}
|
|
2930
|
-
|
|
2930
|
+
w(normalizeSessionId$1, "normalizeSessionId");
|
|
2931
2931
|
var FeedbackService = class {
|
|
2932
2932
|
constructor(e2) {
|
|
2933
2933
|
h(this, "http", void 0), this.http = e2;
|
|
@@ -3013,11 +3013,11 @@ function parseAgentChatPageContext(e2) {
|
|
|
3013
3013
|
function isRecord$5(e2) {
|
|
3014
3014
|
return typeof e2 == "object" && !!e2 && !Array.isArray(e2);
|
|
3015
3015
|
}
|
|
3016
|
-
|
|
3016
|
+
w(isRecord$5, "isRecord");
|
|
3017
3017
|
function readString$3(e2) {
|
|
3018
3018
|
return typeof e2 == "string" && e2.trim().length > 0 ? e2.trim() : void 0;
|
|
3019
3019
|
}
|
|
3020
|
-
|
|
3020
|
+
w(readString$3, "readString");
|
|
3021
3021
|
function readNumber$2(e2) {
|
|
3022
3022
|
if (typeof e2 == "number" && Number.isFinite(e2)) return e2;
|
|
3023
3023
|
if (typeof e2 == "string" && e2.trim().length > 0) {
|
|
@@ -3025,7 +3025,7 @@ function readNumber$2(e2) {
|
|
|
3025
3025
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
3026
3026
|
}
|
|
3027
3027
|
}
|
|
3028
|
-
|
|
3028
|
+
w(readNumber$2, "readNumber");
|
|
3029
3029
|
function readTaskStatus(e2) {
|
|
3030
3030
|
let t2 = readString$3(e2);
|
|
3031
3031
|
if (t2 === "running" || t2 === "awaiting_approval" || t2 === "completed" || t2 === "failed" || t2 === "cancelled") return t2;
|
|
@@ -3227,11 +3227,11 @@ function parsePageActionReuseHint(e2) {
|
|
|
3227
3227
|
function isRecord$4(e2) {
|
|
3228
3228
|
return typeof e2 == "object" && !!e2 && !Array.isArray(e2);
|
|
3229
3229
|
}
|
|
3230
|
-
|
|
3230
|
+
w(isRecord$4, "isRecord");
|
|
3231
3231
|
function readString$2(e2) {
|
|
3232
3232
|
return typeof e2 == "string" && e2.trim().length > 0 ? e2.trim() : void 0;
|
|
3233
3233
|
}
|
|
3234
|
-
|
|
3234
|
+
w(readString$2, "readString");
|
|
3235
3235
|
function readNumber$1(e2) {
|
|
3236
3236
|
if (typeof e2 == "number" && Number.isFinite(e2)) return e2;
|
|
3237
3237
|
if (typeof e2 == "string" && e2.trim().length > 0) {
|
|
@@ -3239,8 +3239,8 @@ function readNumber$1(e2) {
|
|
|
3239
3239
|
return Number.isFinite(t2) ? t2 : void 0;
|
|
3240
3240
|
}
|
|
3241
3241
|
}
|
|
3242
|
-
|
|
3243
|
-
var
|
|
3242
|
+
w(readNumber$1, "readNumber");
|
|
3243
|
+
var at = /* @__PURE__ */ new Set([
|
|
3244
3244
|
"submitted",
|
|
3245
3245
|
"reviewing",
|
|
3246
3246
|
"planned",
|
|
@@ -3251,7 +3251,7 @@ var ot = /* @__PURE__ */ new Set([
|
|
|
3251
3251
|
]);
|
|
3252
3252
|
function readWishStatus(e2) {
|
|
3253
3253
|
let t2 = readString$2(e2);
|
|
3254
|
-
if (t2 &&
|
|
3254
|
+
if (t2 && at.has(t2)) return t2;
|
|
3255
3255
|
}
|
|
3256
3256
|
function parseCatalogMyFeedback(e2) {
|
|
3257
3257
|
if (e2 == null || !isRecord$4(e2)) return null;
|
|
@@ -3272,9 +3272,29 @@ function parseCatalogItem(e2) {
|
|
|
3272
3272
|
description: e2.description === null ? null : readString$2(e2.description) ?? null,
|
|
3273
3273
|
pageScope: e2.pageScope === null ? null : readString$2(e2.pageScope) ?? null,
|
|
3274
3274
|
sortOrder: readNumber$1(e2.sortOrder) ?? 0,
|
|
3275
|
+
rolloutRestricted: e2.rolloutRestricted === true,
|
|
3275
3276
|
myFeedback: parseCatalogMyFeedback(e2.myFeedback)
|
|
3276
3277
|
};
|
|
3277
3278
|
}
|
|
3279
|
+
function parseRolloutCheckItem(e2) {
|
|
3280
|
+
if (!isRecord$4(e2)) return null;
|
|
3281
|
+
let t2 = readString$2(e2.actionKey);
|
|
3282
|
+
if (!t2 || typeof e2.allowed != "boolean") return null;
|
|
3283
|
+
let n2 = readString$2(e2.reason) ?? (e2.allowed ? "open" : "denied");
|
|
3284
|
+
return {
|
|
3285
|
+
actionKey: t2,
|
|
3286
|
+
allowed: e2.allowed,
|
|
3287
|
+
reason: n2
|
|
3288
|
+
};
|
|
3289
|
+
}
|
|
3290
|
+
function parsePageActionRolloutCheck(e2) {
|
|
3291
|
+
let t2 = parseApiEnvelope(e2), n2 = Array.isArray(t2) ? t2 : isRecord$4(t2) && Array.isArray(t2.items) ? t2.items : [], r2 = /* @__PURE__ */ new Set(), i2 = [];
|
|
3292
|
+
for (let e3 of n2) {
|
|
3293
|
+
let t3 = parseRolloutCheckItem(e3);
|
|
3294
|
+
!t3 || r2.has(t3.actionKey) || (r2.add(t3.actionKey), i2.push(t3));
|
|
3295
|
+
}
|
|
3296
|
+
return i2;
|
|
3297
|
+
}
|
|
3278
3298
|
function parseFeedbackView(e2) {
|
|
3279
3299
|
if (!isRecord$4(e2)) return null;
|
|
3280
3300
|
let t2 = readNumber$1(e2.id), n2 = readNumber$1(e2.pageActionId), r2 = readString$2(e2.actionKey), i2 = readString$2(e2.pageActionName), a2 = readNumber$1(e2.appClientId), o2 = readNumber$1(e2.userId), s2 = readNumber$1(e2.rating), c2 = readString$2(e2.createdAt), l2 = readString$2(e2.updatedAt);
|
|
@@ -3391,9 +3411,9 @@ function encodeActionKeyPath(e2) {
|
|
|
3391
3411
|
function isRecord$3(e2) {
|
|
3392
3412
|
return typeof e2 == "object" && !!e2 && !Array.isArray(e2);
|
|
3393
3413
|
}
|
|
3394
|
-
|
|
3414
|
+
w(isRecord$3, "isRecord");
|
|
3395
3415
|
function tryParseAlreadyActiveFromTransportError(e2) {
|
|
3396
|
-
if (!(e2 instanceof
|
|
3416
|
+
if (!(e2 instanceof P) || e2.code !== "TRANSPORT_FAILED") return null;
|
|
3397
3417
|
let t2 = e2.details;
|
|
3398
3418
|
if (!isRecord$3(t2) || t2.status !== 409) return null;
|
|
3399
3419
|
let n2 = [];
|
|
@@ -3457,13 +3477,21 @@ var PageActionService = class {
|
|
|
3457
3477
|
searchParams: n2 ? { pageScope: n2 } : void 0
|
|
3458
3478
|
}));
|
|
3459
3479
|
}
|
|
3480
|
+
async checkRollout(e2, t2) {
|
|
3481
|
+
let n2 = Array.from(new Set(e2.map((e3) => e3.trim()).filter((e3) => e3.length > 0)));
|
|
3482
|
+
return n2.length === 0 ? [] : parsePageActionRolloutCheck(await this.http.request("/page-action/rollout-check", {
|
|
3483
|
+
method: "POST",
|
|
3484
|
+
signal: t2,
|
|
3485
|
+
body: { actionKeys: n2 }
|
|
3486
|
+
}));
|
|
3487
|
+
}
|
|
3460
3488
|
async upsertFeedback(e2, t2, n2) {
|
|
3461
3489
|
let r2 = parsePageActionFeedbackView(await this.http.request(`/page-action/feedback/${encodeActionKeyPath(e2)}`, {
|
|
3462
3490
|
method: "PUT",
|
|
3463
3491
|
signal: n2,
|
|
3464
3492
|
body: t2
|
|
3465
3493
|
}));
|
|
3466
|
-
if (!r2) throw new
|
|
3494
|
+
if (!r2) throw new P("TRANSPORT_FAILED", "Invalid feedback response");
|
|
3467
3495
|
return r2;
|
|
3468
3496
|
}
|
|
3469
3497
|
async getMyFeedback(e2, t2) {
|
|
@@ -3564,7 +3592,7 @@ var PageActionService = class {
|
|
|
3564
3592
|
signal: r2,
|
|
3565
3593
|
body: i2
|
|
3566
3594
|
});
|
|
3567
|
-
return
|
|
3595
|
+
return se(parseApiEnvelope(a2));
|
|
3568
3596
|
}
|
|
3569
3597
|
async confirm(e2, n2) {
|
|
3570
3598
|
let r2 = await this.http.request(`/approval/${e2}/confirm`, {
|
|
@@ -3585,11 +3613,11 @@ var PageActionService = class {
|
|
|
3585
3613
|
function isRecord$2(e2) {
|
|
3586
3614
|
return typeof e2 == "object" && !!e2 && !Array.isArray(e2);
|
|
3587
3615
|
}
|
|
3588
|
-
|
|
3616
|
+
w(isRecord$2, "isRecord");
|
|
3589
3617
|
function readString$1(e2) {
|
|
3590
3618
|
return typeof e2 == "string" && e2.trim() ? e2.trim() : void 0;
|
|
3591
3619
|
}
|
|
3592
|
-
|
|
3620
|
+
w(readString$1, "readString");
|
|
3593
3621
|
function readNumber(e2) {
|
|
3594
3622
|
if (typeof e2 == "number" && Number.isFinite(e2)) return e2;
|
|
3595
3623
|
}
|
|
@@ -3608,9 +3636,9 @@ function parseCallableItem(e2) {
|
|
|
3608
3636
|
};
|
|
3609
3637
|
}
|
|
3610
3638
|
function parseInvokeResult(e2) {
|
|
3611
|
-
if (!isRecord$2(e2)) throw new
|
|
3639
|
+
if (!isRecord$2(e2)) throw new P("TRANSPORT_FAILED", "Invalid app tool invoke response");
|
|
3612
3640
|
let t2 = readString$1(e2.definitionKey), n2 = readString$1(e2.name), r2 = readNumber(e2.toolId), i2 = readNumber(e2.latencyMs) ?? 0;
|
|
3613
|
-
if (!t2 || !n2 || r2 === void 0) throw new
|
|
3641
|
+
if (!t2 || !n2 || r2 === void 0) throw new P("TRANSPORT_FAILED", "Invalid app tool invoke response shape");
|
|
3614
3642
|
return {
|
|
3615
3643
|
ok: e2.ok === true,
|
|
3616
3644
|
definitionKey: t2,
|
|
@@ -3623,7 +3651,7 @@ function parseInvokeResult(e2) {
|
|
|
3623
3651
|
};
|
|
3624
3652
|
}
|
|
3625
3653
|
function getAppToolServerErrorCode(e2) {
|
|
3626
|
-
if (!(e2 instanceof
|
|
3654
|
+
if (!(e2 instanceof P)) return null;
|
|
3627
3655
|
let t2 = e2.details?.serverCode;
|
|
3628
3656
|
return typeof t2 == "string" && t2.trim() ? t2.trim() : null;
|
|
3629
3657
|
}
|
|
@@ -3640,7 +3668,7 @@ var AppToolService = class {
|
|
|
3640
3668
|
}
|
|
3641
3669
|
async invoke(e2) {
|
|
3642
3670
|
let t2 = e2.definitionKey.trim();
|
|
3643
|
-
if (!t2) throw new
|
|
3671
|
+
if (!t2) throw new P("INVALID_OPTIONS", "definitionKey is required");
|
|
3644
3672
|
return parseInvokeResult(parseApiEnvelope(await this.http.request("/app/tools/invoke", {
|
|
3645
3673
|
method: "POST",
|
|
3646
3674
|
signal: e2.signal,
|
|
@@ -3679,7 +3707,7 @@ var AppToolService = class {
|
|
|
3679
3707
|
function isRecord$1(e2) {
|
|
3680
3708
|
return typeof e2 == "object" && !!e2 && !Array.isArray(e2);
|
|
3681
3709
|
}
|
|
3682
|
-
|
|
3710
|
+
w(isRecord$1, "isRecord");
|
|
3683
3711
|
function normalizeSteps(e2) {
|
|
3684
3712
|
if (typeof e2 == "string") try {
|
|
3685
3713
|
return normalizeSteps(JSON.parse(e2));
|
|
@@ -3767,7 +3795,7 @@ function readSkillIntentMismatchObservation(e2) {
|
|
|
3767
3795
|
}
|
|
3768
3796
|
return null;
|
|
3769
3797
|
}
|
|
3770
|
-
var
|
|
3798
|
+
var ot = "page-action:";
|
|
3771
3799
|
function isRecord(e2) {
|
|
3772
3800
|
return typeof e2 == "object" && !!e2 && !Array.isArray(e2);
|
|
3773
3801
|
}
|
|
@@ -3782,12 +3810,12 @@ function tryParseJson(e2) {
|
|
|
3782
3810
|
}
|
|
3783
3811
|
}
|
|
3784
3812
|
function throwPageActionFailed(e2, t2) {
|
|
3785
|
-
throw new
|
|
3813
|
+
throw new P("PAGE_ACTION_FAILED", e2, { details: t2 });
|
|
3786
3814
|
}
|
|
3787
3815
|
function rethrowPageActionError(e2) {
|
|
3788
|
-
if (e2 instanceof
|
|
3816
|
+
if (e2 instanceof P) {
|
|
3789
3817
|
if (e2.code === "TRANSPORT_ABORTED" || e2.code === "PAGE_ACTION_FAILED") throw e2;
|
|
3790
|
-
if (e2.code === "TRANSPORT_FAILED") throw new
|
|
3818
|
+
if (e2.code === "TRANSPORT_FAILED") throw new P("PAGE_ACTION_FAILED", e2.message, {
|
|
3791
3819
|
cause: e2,
|
|
3792
3820
|
details: e2.details
|
|
3793
3821
|
});
|
|
@@ -4347,7 +4375,7 @@ var PageActionCoordinator = class {
|
|
|
4347
4375
|
}
|
|
4348
4376
|
return t2.autoResume && await this.runLiveRestore(t2.actionKey), { applyPhase: this.getApplyPhase(e2) };
|
|
4349
4377
|
}
|
|
4350
|
-
}, ft = "
|
|
4378
|
+
}, ft = "3.0.2";
|
|
4351
4379
|
function nanoId(e2 = "id") {
|
|
4352
4380
|
let t2 = globalThis.crypto;
|
|
4353
4381
|
return t2?.randomUUID ? `${e2}_${t2.randomUUID().replace(/-/g, "").slice(0, 12)}` : `${e2}_${Math.random().toString(36).slice(2, 14)}`;
|
|
@@ -4383,7 +4411,7 @@ function createEmptyAgentStream() {
|
|
|
4383
4411
|
};
|
|
4384
4412
|
}
|
|
4385
4413
|
function finalizeAgentReply(e2, t2, n2 = {}) {
|
|
4386
|
-
let i2 = (n2.content?.type === "text" ? n2.content.text : void 0) ?? (t2.resultText || e2.content.text), a2 = n2.blocks ?? t2.resultBlocks ?? e2.blocks, o2 = r(i2), s2 = o2 ??
|
|
4414
|
+
let i2 = (n2.content?.type === "text" ? n2.content.text : void 0) ?? (t2.resultText || e2.content.text), a2 = n2.blocks ?? t2.resultBlocks ?? e2.blocks, o2 = r(i2), s2 = o2 ?? _e(a2 ?? []), c2 = o2 ? D(s2) : i2;
|
|
4387
4415
|
return {
|
|
4388
4416
|
...e2,
|
|
4389
4417
|
...n2,
|
|
@@ -4443,21 +4471,21 @@ var AgentChatClient = class {
|
|
|
4443
4471
|
attachPageContext: e2.attachPageContext,
|
|
4444
4472
|
pageContext: e2.pageContext
|
|
4445
4473
|
}), this;
|
|
4446
|
-
throw new
|
|
4474
|
+
throw new P("ALREADY_INITIALIZED", "AgentChat is already initialized with a different DSN. Call destroy() first.");
|
|
4447
4475
|
}
|
|
4448
|
-
if (!e2 || typeof e2 != "object") throw new
|
|
4476
|
+
if (!e2 || typeof e2 != "object") throw new P("INVALID_OPTIONS", "init(options): options object is required");
|
|
4449
4477
|
let t2 = trimRight((e2.baseUrl?.trim() || "http://localhost:3030").replace(/\s+/g, "")), n2 = normalizeDsn(e2.dsn);
|
|
4450
4478
|
await waitForAuthStoreRehydration();
|
|
4451
|
-
let r2 =
|
|
4479
|
+
let r2 = I.getState().getAccessTokenForDsn(n2), i2 = typeof e2.accountToken == "string" && e2.accountToken.trim() || typeof e2.userAccessToken == "string" && e2.userAccessToken.trim() || r2 || null, a2 = createHttpClient({
|
|
4452
4480
|
apiBase: t2,
|
|
4453
4481
|
defaultHeaders: {
|
|
4454
|
-
[
|
|
4482
|
+
[F]: n2,
|
|
4455
4483
|
"X-Agent-Sdk-Version": ft,
|
|
4456
4484
|
...e2.headers ?? {}
|
|
4457
4485
|
}
|
|
4458
4486
|
}), o2 = new AuthService(a2), s2 = new ChatService(a2), c2 = new FeedbackService(a2), l2 = new HostToolService(a2), u2 = new AgentRunService(a2), d2 = new PageActionService(a2), f2 = new ApprovalService(a2), p2 = new AutomationService(a2), m2 = new AppToolService(a2), h2 = null, g2 = false, _2 = null, v2 = null;
|
|
4459
4487
|
try {
|
|
4460
|
-
h2 = await o2.authenticate(n2, i2), g2 = true, _2 = h2.accessToken?.trim() ?? null,
|
|
4488
|
+
h2 = await o2.authenticate(n2, i2), g2 = true, _2 = h2.accessToken?.trim() ?? null, I.getState().setAuth(n2, h2), _2 && applyAccessTokenHeader(a2, _2);
|
|
4461
4489
|
} catch (t3) {
|
|
4462
4490
|
v2 = toAgentChatErrorPayload(t3), e2.debug && console.warn("[agent-chat] app-client auth failed during init:", v2);
|
|
4463
4491
|
}
|
|
@@ -4545,7 +4573,7 @@ var AgentChatClient = class {
|
|
|
4545
4573
|
attachPageContext: e2.attachPageContext === true,
|
|
4546
4574
|
appClientId: h2?.appClient?.id ?? null,
|
|
4547
4575
|
contextMentionRegistry: /* @__PURE__ */ new Map()
|
|
4548
|
-
}, this.lifecycle = "initialized", this.stateSnapshot = null, this.initGate.reconcile(), this.authStoreUnsub =
|
|
4576
|
+
}, this.lifecycle = "initialized", this.stateSnapshot = null, this.initGate.reconcile(), this.authStoreUnsub = I.subscribe(() => {
|
|
4549
4577
|
this.syncAuthFromStore();
|
|
4550
4578
|
}), this.syncAuthFromStore(), this.applyPendingRuntimeConfig(this.state), this.syncRouteContextFromWindow(), this.applyStaticSkills(this.state), this.syncDefaultAgentSelection(this.state), e2.onReady && this.bus.on("ready", e2.onReady), queueMicrotask(() => this.bus.emit("ready", void 0)), this.isHostToolServerSyncReady() && flushPendingHostToolSyncs(this).catch((t3) => {
|
|
4551
4579
|
e2.debug && console.warn("[agent-chat] flushPendingHostToolSyncs failed:", t3);
|
|
@@ -4554,18 +4582,18 @@ var AgentChatClient = class {
|
|
|
4554
4582
|
async login(e2) {
|
|
4555
4583
|
await this.ensureInitialized("login");
|
|
4556
4584
|
let t2 = this.requireState("login"), n2 = e2?.email?.trim(), r2 = e2?.password?.trim();
|
|
4557
|
-
if (!n2 || !r2) throw new
|
|
4585
|
+
if (!n2 || !r2) throw new P("INVALID_OPTIONS", "login requires email and password");
|
|
4558
4586
|
let i2;
|
|
4559
4587
|
try {
|
|
4560
4588
|
i2 = await t2.auth.login(n2, r2);
|
|
4561
4589
|
} catch (e3) {
|
|
4562
|
-
throw e3 instanceof
|
|
4590
|
+
throw e3 instanceof P && e3.code === "TRANSPORT_FAILED" ? new P("LOGIN_FAILED", e3.message, {
|
|
4563
4591
|
cause: e3,
|
|
4564
4592
|
details: e3.details
|
|
4565
4593
|
}) : e3;
|
|
4566
4594
|
}
|
|
4567
4595
|
let a2 = i2.accessToken?.trim();
|
|
4568
|
-
if (!a2) throw new
|
|
4596
|
+
if (!a2) throw new P("LOGIN_FAILED", "Login succeeded but no access token was returned.");
|
|
4569
4597
|
clearAccessTokenHeader(t2.http);
|
|
4570
4598
|
let o2 = await t2.auth.authenticate(t2.dsn, a2);
|
|
4571
4599
|
this.commitAuthSession(o2), flushPendingHostToolSyncs(this).catch((e3) => {
|
|
@@ -4575,7 +4603,7 @@ var AgentChatClient = class {
|
|
|
4575
4603
|
}
|
|
4576
4604
|
logout() {
|
|
4577
4605
|
let e2 = this.state;
|
|
4578
|
-
e2 && (this.abortAllSessionStreams(e2), this.cancelAllSessionStreamReconnects(), e2.isLoggedIn = false, clearAccessTokenHeader(e2.http),
|
|
4606
|
+
e2 && (this.abortAllSessionStreams(e2), this.cancelAllSessionStreamReconnects(), e2.isLoggedIn = false, clearAccessTokenHeader(e2.http), I.getState().clearAuth(), e2.session.reset(), e2.sessions = [], e2.sessionsPage = 0, e2.sessionsHasMore = false, e2.sessionsLoadingMore = false, e2.activeSessionId = null, e2.activeSessionMessagesPage = 0, e2.activeSessionMessagesHasMore = false, e2.sessionMessagesLoadingMore = false, e2.sessionMessagesCache.clear(), e2.agents = [], e2.skills = [], e2.selectedAgentId = null, e2.autoAgent = null, e2.selectedSkillId = null, e2.agentsLoading = false, e2.skillsLoading = false, e2.agentsEmptyReason = null, e2.userJwt = null, e2.messages = [], e2.sessionStreams.clear(), e2.sessionRuns.clear(), e2.writeConfirmationsBySession.clear(), e2.approvalInboxItems = [], e2.approvalInboxLoading = false, e2.approvalInboxLoadingMore = false, e2.approvalInboxHasMore = false, e2.approvalInboxStatusFilter = "pending", e2.approvalInboxPendingCount = 0, e2.automationTaskItems = [], e2.automationTaskLoading = false, e2.automationTaskLoadingMore = false, e2.automationTaskHasMore = false, e2.automationTaskTotal = 0, e2.automationTaskStatusFilter = "active", e2.automationTaskTabCaches = createAutomationTaskTabCaches(), e2.automationTaskActiveCount = 0, e2.automationRecentRunIds = [], e2.automationTaskSelectedDetail = null, e2.automationTaskDetailLoading = false, this.abortAllPageActionRunStreams(), this.pageActionInFlightKeys.clear(), this.pageActionAwaitingApprovalNotified.clear(), this.clearAutomationRunRegistry(), e2.catalogHydrated = false, this.pendingStreamTargets.clear(), this.sessionStreamConnects.clear(), this.hostToolStreamManagers.clear(), this.notifyStateChange());
|
|
4579
4607
|
}
|
|
4580
4608
|
isLoggedIn() {
|
|
4581
4609
|
return this.syncAuthFromStore(), this.state?.isLoggedIn ?? false;
|
|
@@ -4589,7 +4617,7 @@ var AgentChatClient = class {
|
|
|
4589
4617
|
syncAuthFromStore() {
|
|
4590
4618
|
let e2 = this.state;
|
|
4591
4619
|
if (!e2) return;
|
|
4592
|
-
let t2 =
|
|
4620
|
+
let t2 = I.getState().getAccessTokenForDsn(e2.dsn);
|
|
4593
4621
|
if (t2?.trim()) {
|
|
4594
4622
|
(e2.userJwt !== t2 || !e2.isLoggedIn) && (e2.userJwt = t2, e2.isLoggedIn = true, applyAccessTokenHeader(e2.http, t2), this.notifyStateChange(), this.loginGate.reconcile(), this.notifyPageActionAuthReady());
|
|
4595
4623
|
return;
|
|
@@ -4598,8 +4626,8 @@ var AgentChatClient = class {
|
|
|
4598
4626
|
}
|
|
4599
4627
|
commitAuthSession(e2) {
|
|
4600
4628
|
let t2 = this.requireState("commitAuthSession"), n2 = e2.accessToken?.trim();
|
|
4601
|
-
if (!n2) throw new
|
|
4602
|
-
|
|
4629
|
+
if (!n2) throw new P("LOGIN_FAILED", "App client auth succeeded but accessToken is missing");
|
|
4630
|
+
I.getState().setAuth(t2.dsn, e2), applyAccessTokenHeader(t2.http, n2), t2.userJwt = n2, t2.isLoggedIn = true, t2.isClientAuthenticated = true, t2.appClientId = e2.appClient?.id ?? t2.appClientId, this.notifyStateChange(), this.loginGate.reconcile(), this.notifyPageActionAuthReady();
|
|
4603
4631
|
}
|
|
4604
4632
|
notifyPageActionAuthReady() {
|
|
4605
4633
|
this.state?.isLoggedIn && this.pageActionCoordinator.onAuthReady();
|
|
@@ -4671,6 +4699,9 @@ var AgentChatClient = class {
|
|
|
4671
4699
|
listPageActionFeedbackCatalog() {
|
|
4672
4700
|
return this.pageActionFeedbackCatalogItems.slice();
|
|
4673
4701
|
}
|
|
4702
|
+
async checkPageActionRollout(e2, t2) {
|
|
4703
|
+
return await this.ensureInitialized("checkPageActionRollout", { signal: t2?.signal }), await this.ensureLoggedIn("checkPageActionRollout", { signal: t2?.signal }), this.requireState("checkPageActionRollout").pageAction.checkRollout(e2, t2?.signal);
|
|
4704
|
+
}
|
|
4674
4705
|
async getPageActionFeedback(e2, t2) {
|
|
4675
4706
|
return await this.ensureInitialized("getPageActionFeedback", { signal: t2?.signal }), await this.ensureLoggedIn("getPageActionFeedback", { signal: t2?.signal }), this.requireState("getPageActionFeedback").pageAction.getMyFeedback(e2, t2?.signal);
|
|
4676
4707
|
}
|
|
@@ -4788,7 +4819,7 @@ var AgentChatClient = class {
|
|
|
4788
4819
|
return e2 ? e2.pageContext ?? e2.options.pageContext ?? null : null;
|
|
4789
4820
|
}
|
|
4790
4821
|
getAppClientId() {
|
|
4791
|
-
return
|
|
4822
|
+
return I.getState().appClient?.id ?? this.state?.appClientId ?? null;
|
|
4792
4823
|
}
|
|
4793
4824
|
isHostToolServerSyncReady() {
|
|
4794
4825
|
let e2 = this.state;
|
|
@@ -4812,7 +4843,7 @@ var AgentChatClient = class {
|
|
|
4812
4843
|
async syncHostToolsToServer(e2) {
|
|
4813
4844
|
await this.ensureLoggedIn("syncHostToolsToServer");
|
|
4814
4845
|
let t2 = this.requireState("syncHostToolsToServer");
|
|
4815
|
-
if (!t2.isClientAuthenticated || t2.appClientId == null) throw new
|
|
4846
|
+
if (!t2.isClientAuthenticated || t2.appClientId == null) throw new P("AUTH_REQUIRED", "Host tool server sync requires app client authentication.");
|
|
4816
4847
|
return t2.hostTool.register(e2);
|
|
4817
4848
|
}
|
|
4818
4849
|
getHostToolCatalog(e2) {
|
|
@@ -4859,7 +4890,7 @@ var AgentChatClient = class {
|
|
|
4859
4890
|
rowKey: t2.rowKey,
|
|
4860
4891
|
entityId: r2.pageContext?.entity?.id ?? null,
|
|
4861
4892
|
findRowKeyByRunId: () => this.findRowKeyByRunId(n2) || this.findRowKeyByPageActionKey(r2.pageActionKey)
|
|
4862
|
-
}), a2 = t2.actionKey?.trim() || r2.actionKey?.trim() || this.automationRunRegistry.get(n2)?.actionKey || r2.title, o2 = r2.taskStatus === "failed" && s(r2.errorCode) && r2.brainClarify != null, c2 = o2 ? "awaiting_clarify" : taskStatusToPageActionPhase(r2.taskStatus), l2 = derivePageActionRowFlags(c2), u2 = this.pageActionRows.get(i2), d2 = l2.loading ? u2?.progressLabel ??
|
|
4893
|
+
}), a2 = t2.actionKey?.trim() || r2.actionKey?.trim() || this.automationRunRegistry.get(n2)?.actionKey || r2.title, o2 = r2.taskStatus === "failed" && s(r2.errorCode) && r2.brainClarify != null, c2 = o2 ? "awaiting_clarify" : taskStatusToPageActionPhase(r2.taskStatus), l2 = derivePageActionRowFlags(c2), u2 = this.pageActionRows.get(i2), d2 = l2.loading ? u2?.progressLabel ?? E(this.state?.options.locale) : c2 === "awaiting_clarify" ? v(this.state?.options.locale) : c2 === "awaiting_approval" ? m({
|
|
4863
4894
|
phase: "awaiting_approval",
|
|
4864
4895
|
actionRunId: n2,
|
|
4865
4896
|
actionKey: a2,
|
|
@@ -4965,7 +4996,7 @@ var AgentChatClient = class {
|
|
|
4965
4996
|
phase: l2 ? "awaiting_reuse" : "submitting",
|
|
4966
4997
|
error: null,
|
|
4967
4998
|
message: null,
|
|
4968
|
-
progressLabel: c2 ?
|
|
4999
|
+
progressLabel: c2 ? me(this.state?.options.locale) : l2 ? null : E(this.state?.options.locale),
|
|
4969
5000
|
narrativeItems: [],
|
|
4970
5001
|
approvalRequestId: this.pageActionRows.get(n2)?.approvalRequestId ?? null
|
|
4971
5002
|
}))), await this.ensureLoggedIn("invokePageAction", { signal: e2.signal }), l2) {
|
|
@@ -4983,26 +5014,27 @@ var AgentChatClient = class {
|
|
|
4983
5014
|
phase: "submitting",
|
|
4984
5015
|
error: null,
|
|
4985
5016
|
message: null,
|
|
4986
|
-
progressLabel:
|
|
5017
|
+
progressLabel: E(this.state?.options.locale),
|
|
4987
5018
|
narrativeItems: [],
|
|
4988
5019
|
approvalRequestId: this.pageActionRows.get(n2)?.approvalRequestId ?? null
|
|
4989
5020
|
}))), await this.invokePageActionStream(t2, e2, n2);
|
|
4990
5021
|
} catch (t3) {
|
|
4991
|
-
|
|
4992
|
-
|
|
5022
|
+
let r3 = remapPageActionRolloutDenied(t3);
|
|
5023
|
+
if (n2 && !(r3 instanceof P && r3.code === "PAGE_ACTION_ALREADY_ACTIVE")) {
|
|
5024
|
+
let t4 = r3 instanceof Error ? r3.message : String(r3);
|
|
4993
5025
|
this.upsertPageActionRow(buildPageActionRowState({
|
|
4994
5026
|
rowKey: n2,
|
|
4995
5027
|
actionKey: e2.actionKey.trim(),
|
|
4996
5028
|
runId: this.pageActionRows.get(n2)?.runId ?? null,
|
|
4997
5029
|
pageActionKey: this.pageActionRows.get(n2)?.pageActionKey ?? null,
|
|
4998
5030
|
phase: "failed",
|
|
4999
|
-
error:
|
|
5031
|
+
error: t4,
|
|
5000
5032
|
message: null,
|
|
5001
5033
|
progressLabel: null,
|
|
5002
5034
|
approvalRequestId: this.pageActionRows.get(n2)?.approvalRequestId ?? null
|
|
5003
5035
|
})), this.schedulePageActionRowIdleReset(n2, 1600);
|
|
5004
5036
|
}
|
|
5005
|
-
throw
|
|
5037
|
+
throw r3;
|
|
5006
5038
|
} finally {
|
|
5007
5039
|
this.releasePageActionLock(r2);
|
|
5008
5040
|
}
|
|
@@ -5090,7 +5122,7 @@ var AgentChatClient = class {
|
|
|
5090
5122
|
async selectSession(e2, t2 = {}) {
|
|
5091
5123
|
await this.ensureLoggedIn("selectSession");
|
|
5092
5124
|
let n2 = this.requireState("selectSession"), r2 = e2.trim();
|
|
5093
|
-
if (!r2) throw new
|
|
5125
|
+
if (!r2) throw new P("INVALID_OPTIONS", "selectSession: sessionId is required");
|
|
5094
5126
|
this.sessionEpoch += 1;
|
|
5095
5127
|
let i2 = this.sessionEpoch, a2 = normalizeSessionId(r2);
|
|
5096
5128
|
n2.activeSessionId && n2.activeSessionId !== r2 && (this.writeSessionMessagesCache(n2, n2.activeSessionId), !t2.skipAbortStream && !this.sessionHasPendingAgent(n2.messages) && this.abortSessionStream(n2, n2.activeSessionId, { suppressReconnect: true })), n2.lastError = null, n2.activeSessionId != null && normalizeSessionId(n2.activeSessionId) !== a2 && this.clearSkillIntentUi(n2);
|
|
@@ -5129,7 +5161,7 @@ var AgentChatClient = class {
|
|
|
5129
5161
|
async sendMessage(e2, t2 = {}) {
|
|
5130
5162
|
await this.ensureLoggedIn("sendMessage");
|
|
5131
5163
|
let n2 = this.requireState("sendMessage"), r2 = e2.trim();
|
|
5132
|
-
if (r2.length === 0) throw new
|
|
5164
|
+
if (r2.length === 0) throw new P("INVALID_OPTIONS", "sendMessage: text must not be empty");
|
|
5133
5165
|
this.settlePendingAgentReplies(n2, n2.activeSessionId ?? void 0), n2.activeSessionId && this.persistWriteConfirmation(n2, n2.activeSessionId, null), n2.lastTurnUserMessage = r2, this.clearSkillIntentUi(n2), n2.brainClarify = null;
|
|
5134
5166
|
let i2 = t2.contextMentions?.length ? await resolveContextMentionsForSend(t2.contextMentions, n2.contextMentionRegistry) : void 0, a2 = i2?.length ? mergePageContextWithMentions(this.buildOutboundPageContext(n2), i2) : void 0, o2 = this.appendOptimisticUserMessage(n2, r2, t2.id, t2.contextMentions), s2 = this.appendAgentPlaceholder(n2), c2 = this.makeAbortController();
|
|
5135
5167
|
try {
|
|
@@ -5145,13 +5177,13 @@ var AgentChatClient = class {
|
|
|
5145
5177
|
status: "failed"
|
|
5146
5178
|
} : e4);
|
|
5147
5179
|
n2.messages = r3, t3 ? this.commitSessionMessages(n2, t3, r3) : this.notifyStateChange();
|
|
5148
|
-
let i3 = e3 instanceof
|
|
5180
|
+
let i3 = e3 instanceof P ? new P("MESSAGE_FAILED", e3.message, {
|
|
5149
5181
|
cause: e3,
|
|
5150
5182
|
details: {
|
|
5151
5183
|
...e3.details ?? {},
|
|
5152
5184
|
messageId: o2.id
|
|
5153
5185
|
}
|
|
5154
|
-
}) : new
|
|
5186
|
+
}) : new P("MESSAGE_FAILED", "Failed to send message", {
|
|
5155
5187
|
cause: e3,
|
|
5156
5188
|
details: { messageId: o2.id }
|
|
5157
5189
|
});
|
|
@@ -5165,7 +5197,7 @@ var AgentChatClient = class {
|
|
|
5165
5197
|
}
|
|
5166
5198
|
async confirmWriteWithEdits(e2) {
|
|
5167
5199
|
let { editedPreviewSerialized: t2, editedPendingWriteArguments: n2 } = e2;
|
|
5168
|
-
if (!t2?.trim() && !n2) throw new
|
|
5200
|
+
if (!t2?.trim() && !n2) throw new P("INVALID_OPTIONS", "confirmWriteWithEdits: editedPreviewSerialized or editedPendingWriteArguments is required");
|
|
5169
5201
|
await this.submitWriteGate({
|
|
5170
5202
|
action: "confirm_with_edits",
|
|
5171
5203
|
editedPreviewSerialized: t2?.trim() || void 0,
|
|
@@ -5174,7 +5206,7 @@ var AgentChatClient = class {
|
|
|
5174
5206
|
}
|
|
5175
5207
|
async retryWrite(e2) {
|
|
5176
5208
|
let t2 = e2.trim();
|
|
5177
|
-
if (!t2) throw new
|
|
5209
|
+
if (!t2) throw new P("INVALID_OPTIONS", "retryWrite: retryInstruction must not be empty");
|
|
5178
5210
|
await this.submitWriteGate({
|
|
5179
5211
|
action: "retry",
|
|
5180
5212
|
retryInstruction: t2
|
|
@@ -5187,10 +5219,10 @@ var AgentChatClient = class {
|
|
|
5187
5219
|
let t2 = `submitWriteGate:${e2.action}`;
|
|
5188
5220
|
await this.ensureLoggedIn(t2);
|
|
5189
5221
|
let n2 = this.requireState(t2), r2 = n2.writeConfirmation;
|
|
5190
|
-
if (!r2?.awaiting) throw new
|
|
5191
|
-
if (e2.action === "retry" && r2.canRetry === false) throw new
|
|
5222
|
+
if (!r2?.awaiting) throw new P("INVALID_OPTIONS", "No pending write confirmation");
|
|
5223
|
+
if (e2.action === "retry" && r2.canRetry === false) throw new P("INVALID_OPTIONS", "Draft retry limit exceeded");
|
|
5192
5224
|
let i2 = n2.activeSessionId ?? n2.session.getSession()?.sessionId ?? null;
|
|
5193
|
-
if (!i2) throw new
|
|
5225
|
+
if (!i2) throw new P("INVALID_OPTIONS", `${t2}: no active session`);
|
|
5194
5226
|
let a2 = e2.action === "retry";
|
|
5195
5227
|
if (n2.writeConfirmation = {
|
|
5196
5228
|
...r2,
|
|
@@ -5210,12 +5242,12 @@ var AgentChatClient = class {
|
|
|
5210
5242
|
...r2,
|
|
5211
5243
|
awaiting: true,
|
|
5212
5244
|
submitting: false,
|
|
5213
|
-
gateError: e3 instanceof
|
|
5245
|
+
gateError: e3 instanceof P ? e3.message : void 0,
|
|
5214
5246
|
gateErrorCode: t3,
|
|
5215
5247
|
canRetry: t3 !== "DRAFT_RETRY_LIMIT_EXCEEDED" && r2.canRetry
|
|
5216
5248
|
};
|
|
5217
5249
|
if (n2.writeConfirmation = o3, this.persistWriteConfirmation(n2, i2, o3), this.notifyStateChange(), a3) return;
|
|
5218
|
-
let s2 = e3 instanceof
|
|
5250
|
+
let s2 = e3 instanceof P ? e3 : new P("MESSAGE_FAILED", "Failed to submit write gate decision", { cause: e3 });
|
|
5219
5251
|
throw this.reportError(s2), s2;
|
|
5220
5252
|
} finally {
|
|
5221
5253
|
n2.abortControllers.delete(o2);
|
|
@@ -5451,9 +5483,9 @@ var AgentChatClient = class {
|
|
|
5451
5483
|
async applyPageActionToPage(e2, t2 = {}) {
|
|
5452
5484
|
await this.ensureLoggedIn("applyPageActionToPage", { signal: t2.signal });
|
|
5453
5485
|
let n2 = this.requireState("applyPageActionToPage"), r2 = Math.trunc(e2);
|
|
5454
|
-
if (!Number.isFinite(r2)) throw new
|
|
5486
|
+
if (!Number.isFinite(r2)) throw new P("INVALID_OPTIONS", "applyPageActionToPage requires a valid runId");
|
|
5455
5487
|
let i2 = await this.hydrateAutomationTaskDetail(r2, t2.signal) ?? await this.getAutomationTaskDetail(r2, t2.signal);
|
|
5456
|
-
if (!i2 || i2.ref.kind !== "page_action_run") throw new
|
|
5488
|
+
if (!i2 || i2.ref.kind !== "page_action_run") throw new P("PAGE_ACTION_FAILED", `PageAction run ${r2} not found`);
|
|
5457
5489
|
let a2 = i2.pageContext, o2 = resolvePageContextNavigateTarget(a2), s2 = {
|
|
5458
5490
|
runId: r2,
|
|
5459
5491
|
actionKey: i2.actionKey,
|
|
@@ -5521,7 +5553,7 @@ var AgentChatClient = class {
|
|
|
5521
5553
|
let n2 = this.requireState("replayPageAction"), r2 = Math.trunc(e2), clearIfPending = () => {
|
|
5522
5554
|
this.getPendingPageActionApply()?.runId === r2 && this.clearPendingPageActionApply();
|
|
5523
5555
|
}, i2 = n2.automationTaskSelectedDetail?.ref.id === r2 ? n2.automationTaskSelectedDetail : await this.getAutomationTaskDetail(r2, t2.signal);
|
|
5524
|
-
if (!i2 || i2.ref.kind !== "page_action_run") throw clearIfPending(), new
|
|
5556
|
+
if (!i2 || i2.ref.kind !== "page_action_run") throw clearIfPending(), new P("PAGE_ACTION_FAILED", `PageAction run ${r2} not found`);
|
|
5525
5557
|
if (i2.taskStatus !== "completed" || !i2.replay.canReplay) {
|
|
5526
5558
|
clearIfPending();
|
|
5527
5559
|
return;
|
|
@@ -5638,11 +5670,11 @@ var AgentChatClient = class {
|
|
|
5638
5670
|
async submitMessageFeedback(e2, t2) {
|
|
5639
5671
|
await this.ensureLoggedIn("submitMessageFeedback");
|
|
5640
5672
|
let n2 = this.requireState("submitMessageFeedback"), r2 = n2.activeSessionId ?? n2.session.getSession()?.sessionId ?? null;
|
|
5641
|
-
if (!r2) throw new
|
|
5642
|
-
let i2 =
|
|
5643
|
-
if (i2 === null) throw new
|
|
5673
|
+
if (!r2) throw new P("INVALID_OPTIONS", "submitMessageFeedback: no active session");
|
|
5674
|
+
let i2 = C(e2);
|
|
5675
|
+
if (i2 === null) throw new P("INVALID_OPTIONS", "submitMessageFeedback: invalid messageId");
|
|
5644
5676
|
let a2 = n2.messages.find((t3) => t3.id === e2);
|
|
5645
|
-
if (!a2 || a2.role !== "agent") throw new
|
|
5677
|
+
if (!a2 || a2.role !== "agent") throw new P("INVALID_OPTIONS", "submitMessageFeedback: not an assistant message");
|
|
5646
5678
|
let o2 = a2.feedback ?? null, s2 = this.buildOptimisticFeedback(i2, t2);
|
|
5647
5679
|
this.patchMessageFeedback(n2, e2, s2);
|
|
5648
5680
|
try {
|
|
@@ -5650,25 +5682,25 @@ var AgentChatClient = class {
|
|
|
5650
5682
|
this.patchMessageFeedback(n2, e2, a3);
|
|
5651
5683
|
} catch (t3) {
|
|
5652
5684
|
this.patchMessageFeedback(n2, e2, o2);
|
|
5653
|
-
let r3 = t3 instanceof
|
|
5685
|
+
let r3 = t3 instanceof P ? t3 : new P("MESSAGE_FAILED", "Failed to submit feedback", { cause: t3 });
|
|
5654
5686
|
throw this.reportError(r3), r3;
|
|
5655
5687
|
}
|
|
5656
5688
|
}
|
|
5657
5689
|
async removeMessageFeedback(e2) {
|
|
5658
5690
|
await this.ensureLoggedIn("removeMessageFeedback");
|
|
5659
5691
|
let t2 = this.requireState("removeMessageFeedback"), n2 = t2.activeSessionId ?? t2.session.getSession()?.sessionId ?? null;
|
|
5660
|
-
if (!n2) throw new
|
|
5661
|
-
let r2 =
|
|
5662
|
-
if (r2 === null) throw new
|
|
5692
|
+
if (!n2) throw new P("INVALID_OPTIONS", "removeMessageFeedback: no active session");
|
|
5693
|
+
let r2 = C(e2);
|
|
5694
|
+
if (r2 === null) throw new P("INVALID_OPTIONS", "removeMessageFeedback: invalid messageId");
|
|
5663
5695
|
let i2 = t2.messages.find((t3) => t3.id === e2);
|
|
5664
|
-
if (!i2 || i2.role !== "agent") throw new
|
|
5696
|
+
if (!i2 || i2.role !== "agent") throw new P("INVALID_OPTIONS", "removeMessageFeedback: not an assistant message");
|
|
5665
5697
|
let a2 = i2.feedback ?? null;
|
|
5666
5698
|
this.patchMessageFeedback(t2, e2, null);
|
|
5667
5699
|
try {
|
|
5668
5700
|
await t2.feedback.remove(n2, r2);
|
|
5669
5701
|
} catch (n3) {
|
|
5670
5702
|
this.patchMessageFeedback(t2, e2, a2);
|
|
5671
|
-
let r3 = n3 instanceof
|
|
5703
|
+
let r3 = n3 instanceof P ? n3 : new P("MESSAGE_FAILED", "Failed to remove feedback", { cause: n3 });
|
|
5672
5704
|
throw this.reportError(r3), r3;
|
|
5673
5705
|
}
|
|
5674
5706
|
}
|
|
@@ -5862,7 +5894,7 @@ var AgentChatClient = class {
|
|
|
5862
5894
|
});
|
|
5863
5895
|
}
|
|
5864
5896
|
requireState(e2) {
|
|
5865
|
-
if (!this.state) throw new
|
|
5897
|
+
if (!this.state) throw new P("NOT_INITIALIZED", `AgentChat.${e2}() called before init(). Call AgentChat.init({ dsn }) first.`);
|
|
5866
5898
|
return this.state;
|
|
5867
5899
|
}
|
|
5868
5900
|
refreshApprovalBadgeBestEffort() {
|
|
@@ -5946,12 +5978,12 @@ var AgentChatClient = class {
|
|
|
5946
5978
|
async deleteSession(e2) {
|
|
5947
5979
|
await this.ensureLoggedIn("deleteSession");
|
|
5948
5980
|
let t2 = this.requireState("deleteSession"), n2 = e2.trim();
|
|
5949
|
-
if (!n2) throw new
|
|
5981
|
+
if (!n2) throw new P("INVALID_OPTIONS", "deleteSession: sessionId is required");
|
|
5950
5982
|
let r2 = normalizeSessionId(n2), i2 = t2.activeSessionId != null && normalizeSessionId(t2.activeSessionId) === r2;
|
|
5951
5983
|
try {
|
|
5952
5984
|
await t2.chat.deleteSession(n2);
|
|
5953
5985
|
} catch (e3) {
|
|
5954
|
-
let t3 = e3 instanceof
|
|
5986
|
+
let t3 = e3 instanceof P ? e3 : new P("TRANSPORT_FAILED", "Failed to delete session", { cause: e3 });
|
|
5955
5987
|
throw this.reportError(t3), t3;
|
|
5956
5988
|
}
|
|
5957
5989
|
this.abortSessionStream(t2, r2), t2.writeConfirmationsBySession.delete(r2), t2.sessionRuns.delete(r2);
|
|
@@ -6042,8 +6074,8 @@ var AgentChatClient = class {
|
|
|
6042
6074
|
let t2 = this.requireState("commitBrainClarify"), n2 = t2.brainClarify;
|
|
6043
6075
|
if (!n2) return;
|
|
6044
6076
|
let r2 = e2.trim();
|
|
6045
|
-
if (!r2) throw new
|
|
6046
|
-
let i2 = n2.brainClarify.candidates.find((e3) => e3.id === r2) ?? null, a2 = i2 ?
|
|
6077
|
+
if (!r2) throw new P("INVALID_OPTIONS", "commitBrainClarify: selectedId required");
|
|
6078
|
+
let i2 = n2.brainClarify.candidates.find((e3) => e3.id === r2) ?? null, a2 = i2 ? le(i2) : r2, s2 = o(n2.brainClarify, r2);
|
|
6047
6079
|
t2.brainClarify = null, this.notifyStateChange();
|
|
6048
6080
|
try {
|
|
6049
6081
|
await this.sendMessage(a2, { entityCommit: s2 });
|
|
@@ -6054,7 +6086,7 @@ var AgentChatClient = class {
|
|
|
6054
6086
|
async followSkillIntentClarify() {
|
|
6055
6087
|
await this.ensureLoggedIn("followSkillIntentClarify");
|
|
6056
6088
|
let e2 = this.requireState("followSkillIntentClarify"), t2 = e2.skillIntentClarify?.userMessage?.trim() ?? e2.lastTurnUserMessage?.trim() ?? "";
|
|
6057
|
-
if (!t2) throw new
|
|
6089
|
+
if (!t2) throw new P("INVALID_OPTIONS", "No user message to resend");
|
|
6058
6090
|
e2.skillIntentClarify = null, this.selectSkill(""), await this.sendMessage(t2);
|
|
6059
6091
|
}
|
|
6060
6092
|
openSkillPicker() {
|
|
@@ -6201,7 +6233,7 @@ var AgentChatClient = class {
|
|
|
6201
6233
|
return;
|
|
6202
6234
|
}
|
|
6203
6235
|
if (this.getPageScope(e2)) {
|
|
6204
|
-
e2.selectedSkillId =
|
|
6236
|
+
e2.selectedSkillId = te(e2.skills) ?? null;
|
|
6205
6237
|
return;
|
|
6206
6238
|
}
|
|
6207
6239
|
e2.selectedSkillId = e2.skills[0]?.id ?? null;
|
|
@@ -6260,7 +6292,7 @@ var AgentChatClient = class {
|
|
|
6260
6292
|
});
|
|
6261
6293
|
}
|
|
6262
6294
|
emitPageAgentError(e2, t2, n2, r2) {
|
|
6263
|
-
let i2 = r2 instanceof
|
|
6295
|
+
let i2 = r2 instanceof P || r2 instanceof Error ? r2.message : String(r2), a2 = r2 instanceof P ? r2.code : void 0;
|
|
6264
6296
|
this.emitPageAgentLifecycle({
|
|
6265
6297
|
type: "error",
|
|
6266
6298
|
context: {
|
|
@@ -6313,7 +6345,7 @@ var AgentChatClient = class {
|
|
|
6313
6345
|
acquirePageActionLock(e2) {
|
|
6314
6346
|
let t2 = e2?.trim();
|
|
6315
6347
|
if (!t2) return null;
|
|
6316
|
-
if (this.pageActionInFlightKeys.has(t2)) throw new
|
|
6348
|
+
if (this.pageActionInFlightKeys.has(t2)) throw new P("INVALID_OPTIONS", `Page action invoke already in flight for clientActionId: ${t2}`);
|
|
6317
6349
|
return this.pageActionInFlightKeys.add(t2), t2;
|
|
6318
6350
|
}
|
|
6319
6351
|
releasePageActionLock(e2) {
|
|
@@ -6321,12 +6353,12 @@ var AgentChatClient = class {
|
|
|
6321
6353
|
}
|
|
6322
6354
|
requirePageActionKey(e2) {
|
|
6323
6355
|
let t2 = e2.actionKey?.trim();
|
|
6324
|
-
if (!t2) throw new
|
|
6356
|
+
if (!t2) throw new P("INVALID_OPTIONS", "Page action: actionKey is required");
|
|
6325
6357
|
return t2;
|
|
6326
6358
|
}
|
|
6327
6359
|
resolvePageActionStreamSessionKey(e2, t2) {
|
|
6328
6360
|
let n2 = e2.clientActionId?.trim();
|
|
6329
|
-
return n2 ? `${
|
|
6361
|
+
return n2 ? `${ot}${n2}` : t2 == null ? `${ot}${nanoId()}` : `${ot}${t2}`;
|
|
6330
6362
|
}
|
|
6331
6363
|
releasePageActionStreamManager(e2) {
|
|
6332
6364
|
this.hostToolStreamManagers.delete(normalizeSessionId(e2));
|
|
@@ -6376,7 +6408,7 @@ var AgentChatClient = class {
|
|
|
6376
6408
|
actionKey: a2.actionKey,
|
|
6377
6409
|
pageActionKey: a2.pageActionKey,
|
|
6378
6410
|
items: a2.reusable.items,
|
|
6379
|
-
sourceRect:
|
|
6411
|
+
sourceRect: T(t2.launchAnchor),
|
|
6380
6412
|
launchAnchor: t2.launchAnchor ?? null,
|
|
6381
6413
|
invokeSnapshot: {
|
|
6382
6414
|
pageContext: t2.pageContext,
|
|
@@ -6399,7 +6431,7 @@ var AgentChatClient = class {
|
|
|
6399
6431
|
phase: "submitting",
|
|
6400
6432
|
error: null,
|
|
6401
6433
|
message: null,
|
|
6402
|
-
progressLabel:
|
|
6434
|
+
progressLabel: E(this.state?.options.locale),
|
|
6403
6435
|
narrativeItems: [],
|
|
6404
6436
|
approvalRequestId: e3?.approvalRequestId ?? null
|
|
6405
6437
|
}));
|
|
@@ -6436,7 +6468,7 @@ var AgentChatClient = class {
|
|
|
6436
6468
|
return s2 ? this.applyPageActionReuse(t2, n2, a2, s2) : null;
|
|
6437
6469
|
}
|
|
6438
6470
|
async applyPageActionReuse(e2, t2, n2, r2) {
|
|
6439
|
-
let i2 = r2.ref.id, a2 = this.state?.options.locale, o2 =
|
|
6471
|
+
let i2 = r2.ref.id, a2 = this.state?.options.locale, o2 = ye(a2), s2 = e2.actionKey.trim(), c2 = t2 ? this.pageActionReuseDismissEpochByRowKey.get(t2) ?? 0 : 0, wasDismissed = () => t2 != null && (this.pageActionReuseDismissEpochByRowKey.get(t2) ?? 0) !== c2, setRow = (e3) => {
|
|
6440
6472
|
if (!t2 || wasDismissed()) return;
|
|
6441
6473
|
let r3 = this.pageActionRows.get(t2);
|
|
6442
6474
|
this.upsertPageActionRow(buildPageActionRowState({
|
|
@@ -6457,7 +6489,7 @@ var AgentChatClient = class {
|
|
|
6457
6489
|
phase: "streaming",
|
|
6458
6490
|
loading: true,
|
|
6459
6491
|
disabled: true,
|
|
6460
|
-
progressLabel:
|
|
6492
|
+
progressLabel: x(a2),
|
|
6461
6493
|
message: null,
|
|
6462
6494
|
error: null
|
|
6463
6495
|
}), this.bus.emit("pageActionApplyStarted", {
|
|
@@ -6477,8 +6509,8 @@ var AgentChatClient = class {
|
|
|
6477
6509
|
cancelled: true,
|
|
6478
6510
|
reused: true
|
|
6479
6511
|
};
|
|
6480
|
-
if (!n3 || n3.ref.kind !== "page_action_run") throw new
|
|
6481
|
-
if (n3.taskStatus !== "completed") throw new
|
|
6512
|
+
if (!n3 || n3.ref.kind !== "page_action_run") throw new P("PAGE_ACTION_FAILED", `PageAction run ${i2} not found`);
|
|
6513
|
+
if (n3.taskStatus !== "completed") throw new P("PAGE_ACTION_FAILED", `PageAction run ${i2} is not completed`);
|
|
6482
6514
|
let r3 = n3.outputs.preview?.trim() || l2;
|
|
6483
6515
|
if (r3 && (l2 = r3), (n3.replay.canReplay || n3.outputs.hasFillText === true || l2) && (n3.replay.canReplay || n3.outputs.hasFillText)) {
|
|
6484
6516
|
if (await this.replayPageAction(i2, { signal: e2.signal }), wasDismissed()) return {
|
|
@@ -6542,7 +6574,7 @@ var AgentChatClient = class {
|
|
|
6542
6574
|
actionKey: s2,
|
|
6543
6575
|
rowKey: t2,
|
|
6544
6576
|
errorMessage: r3
|
|
6545
|
-
}), n3 instanceof
|
|
6577
|
+
}), n3 instanceof P ? n3 : new P("PAGE_ACTION_FAILED", r3);
|
|
6546
6578
|
}
|
|
6547
6579
|
}
|
|
6548
6580
|
async invokePageActionStream(e2, t2, n2 = null) {
|
|
@@ -6568,7 +6600,7 @@ var AgentChatClient = class {
|
|
|
6568
6600
|
pageActionKey: n3.pageActionKey,
|
|
6569
6601
|
rowKey: o2
|
|
6570
6602
|
});
|
|
6571
|
-
let c3 = n3.existingStatus === "awaiting_approval" ?
|
|
6603
|
+
let c3 = n3.existingStatus === "awaiting_approval" ? ie(this.state?.options.locale) : re(this.state?.options.locale);
|
|
6572
6604
|
if (o2 && this.syncPageActionRowFromAccepted(o2, t2.actionKey, a3, {
|
|
6573
6605
|
approvalRequestId: n3.approvalRequestId,
|
|
6574
6606
|
message: c3
|
|
@@ -6611,7 +6643,7 @@ var AgentChatClient = class {
|
|
|
6611
6643
|
}), o2 && this.syncPageActionRowFromAccepted(o2, t2.actionKey, c2), this.rememberPageActionInvokeSnapshot(t2, o2, c2.runId);
|
|
6612
6644
|
let l2 = {
|
|
6613
6645
|
...c2,
|
|
6614
|
-
sourceRect:
|
|
6646
|
+
sourceRect: T(t2.launchAnchor),
|
|
6615
6647
|
launchAnchor: t2.launchAnchor ?? null,
|
|
6616
6648
|
rowKey: o2,
|
|
6617
6649
|
actionKey: t2.actionKey.trim()
|
|
@@ -6651,7 +6683,7 @@ var AgentChatClient = class {
|
|
|
6651
6683
|
};
|
|
6652
6684
|
}
|
|
6653
6685
|
finishAlreadyActiveInvoke(e2, t2, n2) {
|
|
6654
|
-
let r2 = this.pageActionRows.get(t2), i2 = r2?.awaitingApproval === true || r2?.phase === "awaiting_approval", a2 = i2 ?
|
|
6686
|
+
let r2 = this.pageActionRows.get(t2), i2 = r2?.awaitingApproval === true || r2?.phase === "awaiting_approval", a2 = i2 ? ie(this.state?.options.locale) : re(this.state?.options.locale);
|
|
6655
6687
|
if (r2) {
|
|
6656
6688
|
let { loading: e3, disabled: t3, ...n3 } = r2;
|
|
6657
6689
|
this.upsertPageActionRow(buildPageActionRowState({
|
|
@@ -6781,7 +6813,7 @@ var AgentChatClient = class {
|
|
|
6781
6813
|
actionKey: e2.actionKey,
|
|
6782
6814
|
runId: t2,
|
|
6783
6815
|
brainClarify: e2.brainClarify,
|
|
6784
|
-
sourceRect:
|
|
6816
|
+
sourceRect: T(r2?.launchAnchor ?? null),
|
|
6785
6817
|
launchAnchor: r2?.launchAnchor ?? null,
|
|
6786
6818
|
invokeSnapshot: r2 ? {
|
|
6787
6819
|
pageContext: r2.pageContext,
|
|
@@ -6940,7 +6972,7 @@ var AgentChatClient = class {
|
|
|
6940
6972
|
generation: n2.generation,
|
|
6941
6973
|
nodeId: "",
|
|
6942
6974
|
stageKind: "other"
|
|
6943
|
-
}, this.state?.options.locale) : i2 === "launched" || i2 === "streaming" ? this.pageActionRows.get(e2)?.progressLabel ??
|
|
6975
|
+
}, this.state?.options.locale) : i2 === "launched" || i2 === "streaming" ? this.pageActionRows.get(e2)?.progressLabel ?? E(this.state?.options.locale) : null,
|
|
6944
6976
|
narrativeItems: this.pageActionRows.get(e2)?.narrativeItems ?? [],
|
|
6945
6977
|
approvalRequestId: r2.approvalRequestId ?? null
|
|
6946
6978
|
}));
|
|
@@ -6950,7 +6982,7 @@ var AgentChatClient = class {
|
|
|
6950
6982
|
if (!n2) return;
|
|
6951
6983
|
let r2 = this.pageActionRows.get(n2);
|
|
6952
6984
|
if (!r2 || e2.phase === "failed" || r2.phase === "idle" || r2.phase === "completed" || r2.phase === "failed" || r2.phase === "awaiting_reuse") return;
|
|
6953
|
-
let i2 =
|
|
6985
|
+
let i2 = fe(r2.narrativeItems, e2.narrativeItems), a2 = m(e2, this.state?.options.locale), o2 = a2 == null || a2 === r2.progressLabel, s2 = i2 === r2.narrativeItems;
|
|
6954
6986
|
if (o2 && s2) return;
|
|
6955
6987
|
let c2 = e2.phase === "awaiting_approval" ? "awaiting_approval" : r2.phase === "submitting" || r2.phase === "launched" || r2.loading || r2.phase === "streaming" ? "streaming" : r2.phase;
|
|
6956
6988
|
this.upsertPageActionRow(buildPageActionRowState({
|
|
@@ -6975,7 +7007,7 @@ var AgentChatClient = class {
|
|
|
6975
7007
|
generation: e2.generation,
|
|
6976
7008
|
nodeId: "",
|
|
6977
7009
|
stageKind: "other"
|
|
6978
|
-
}, this.state?.options.locale) : r2?.progressLabel ??
|
|
7010
|
+
}, this.state?.options.locale) : r2?.progressLabel ?? E(this.state?.options.locale);
|
|
6979
7011
|
this.upsertPageActionRow(buildPageActionRowState({
|
|
6980
7012
|
rowKey: n2,
|
|
6981
7013
|
actionKey: e2.actionKey || r2?.actionKey || `Run ${t2}`,
|
|
@@ -7054,7 +7086,7 @@ var AgentChatClient = class {
|
|
|
7054
7086
|
trackAutomationRun(e2, t2) {
|
|
7055
7087
|
let n2 = this.state;
|
|
7056
7088
|
if (!n2) return;
|
|
7057
|
-
let r2 = (/* @__PURE__ */ new Date()).toISOString(), i2 = this.pageActionFeedbackNames.get(t2.actionKey.trim()), a2 = n2.options.locale, o2 = e2.status === "awaiting_approval" ?
|
|
7089
|
+
let r2 = (/* @__PURE__ */ new Date()).toISOString(), i2 = this.pageActionFeedbackNames.get(t2.actionKey.trim()), a2 = n2.options.locale, o2 = e2.status === "awaiting_approval" ? ve(a2) : p(a2), s2 = buildOptimisticAutomationTaskItem(e2, t2.actionKey, {
|
|
7058
7090
|
title: formatPageActionDisplayTitle(t2.actionKey, i2),
|
|
7059
7091
|
subtitle: o2
|
|
7060
7092
|
}), c2 = t2.rowKey?.trim() || null;
|
|
@@ -7306,7 +7338,7 @@ var AgentChatClient = class {
|
|
|
7306
7338
|
}
|
|
7307
7339
|
async fetchSessionMessagesPage(e2, t2, n2, r2) {
|
|
7308
7340
|
let i2 = parseChatSessionDetailPage(await e2.chat.getSession(t2, n2, e2.sessionMessagesPageSize, r2), t2, n2, e2.sessionMessagesPageSize);
|
|
7309
|
-
if (!i2) throw new
|
|
7341
|
+
if (!i2) throw new P("TRANSPORT_FAILED", "Invalid session detail response", { details: {
|
|
7310
7342
|
sessionId: t2,
|
|
7311
7343
|
page: n2
|
|
7312
7344
|
} });
|
|
@@ -7330,7 +7362,7 @@ var AgentChatClient = class {
|
|
|
7330
7362
|
systemHint: "\u5DF2\u505C\u6B62\u751F\u6210\u3002"
|
|
7331
7363
|
});
|
|
7332
7364
|
} catch (e3) {
|
|
7333
|
-
let t3 = e3 instanceof
|
|
7365
|
+
let t3 = e3 instanceof P ? e3 : new P("MESSAGE_FAILED", "Failed to cancel generation", { cause: e3 });
|
|
7334
7366
|
throw this.reportError(t3), t3;
|
|
7335
7367
|
}
|
|
7336
7368
|
}
|
|
@@ -7707,7 +7739,7 @@ var AgentChatClient = class {
|
|
|
7707
7739
|
}
|
|
7708
7740
|
async createChatSession(e2, t2, n2, r2, i2) {
|
|
7709
7741
|
let a2 = await e2.chat.createSession(t2, n2, this.getMessageSendContext(e2, r2, i2)), o2 = parseCreateSessionResponse(a2);
|
|
7710
|
-
if (!o2?.sessionId) throw new
|
|
7742
|
+
if (!o2?.sessionId) throw new P("TRANSPORT_FAILED", "POST /chat did not return sessionId", { details: { body: a2 } });
|
|
7711
7743
|
e2.activeSessionId = o2.sessionId, this.applyAutoAgentBinding(e2, o2.agent);
|
|
7712
7744
|
let s2 = parseRunGeneration(a2);
|
|
7713
7745
|
return s2 != null && this.applySessionRunGeneration(e2, o2.sessionId, s2), e2.activeSessionMessagesPage = 1, e2.activeSessionMessagesHasMore = false, e2.session.setSession(o2.sessionId, e2.messages), this.writeSessionMessagesCache(e2, o2.sessionId), this.bus.emit("session", e2.session.getSession()), this.schedulePrepareSession(), o2.sessionId;
|
|
@@ -7844,11 +7876,11 @@ var AgentChatClient = class {
|
|
|
7844
7876
|
if (a2 != null && r3.has(a2)) return e3;
|
|
7845
7877
|
a2 != null && r3.add(a2);
|
|
7846
7878
|
let i5 = n4.resultBlocks ?? e3.blocks ?? [], o2 = i5;
|
|
7847
|
-
t3.action === "stream" ? o2 = t3.streamMode === "full" ?
|
|
7879
|
+
t3.action === "stream" ? o2 = t3.streamMode === "full" ? S(i5, t3.blocks ?? []) : be(i5, t3.blocks ?? []) : t3.action === "patch" && (o2 = he(i5, (t3.patches ?? []).map((e4) => ({
|
|
7848
7880
|
replaceId: e4.replaceId,
|
|
7849
7881
|
block: e4.block
|
|
7850
|
-
})))), o2 =
|
|
7851
|
-
let s2 =
|
|
7882
|
+
})))), o2 = _e(o2);
|
|
7883
|
+
let s2 = D(o2);
|
|
7852
7884
|
return {
|
|
7853
7885
|
...e3,
|
|
7854
7886
|
status: "pending",
|
|
@@ -7972,7 +8004,7 @@ var AgentChatClient = class {
|
|
|
7972
8004
|
break;
|
|
7973
8005
|
}
|
|
7974
8006
|
}
|
|
7975
|
-
throw new
|
|
8007
|
+
throw new P("MESSAGE_FAILED", t3.message, { details: t3.code ? { code: t3.code } : void 0 });
|
|
7976
8008
|
}
|
|
7977
8009
|
}
|
|
7978
8010
|
let i2 = getAgent(this.resolveStreamTargetMessageId(r2, e2));
|
|
@@ -8009,12 +8041,12 @@ var AgentChatClient = class {
|
|
|
8009
8041
|
}
|
|
8010
8042
|
}, n3.id);
|
|
8011
8043
|
}
|
|
8012
|
-
let i2 = t3 instanceof
|
|
8044
|
+
let i2 = t3 instanceof P ? t3 : new P("MESSAGE_FAILED", "Failed to receive assistant reply", { cause: t3 });
|
|
8013
8045
|
this.isViewingSession(r2, e2) ? this.reportError(i2) : r2.options.debug && typeof console < "u" && console.warn(`[agent-chat] Background stream error for session ${e2} (suppressed from UI):`, i2);
|
|
8014
8046
|
}
|
|
8015
8047
|
}
|
|
8016
8048
|
toAgentMessage(e2) {
|
|
8017
|
-
let t2 = e2.role === "assistant" ? "agent" : e2.role === "user" ? "user" : "system", n2 = e2.createdAt, i2 = typeof n2 == "number" ? n2 : new Date(n2).getTime(), a2 = r(e2.content), o2 = a2 ?
|
|
8049
|
+
let t2 = e2.role === "assistant" ? "agent" : e2.role === "user" ? "user" : "system", n2 = e2.createdAt, i2 = typeof n2 == "number" ? n2 : new Date(n2).getTime(), a2 = r(e2.content), o2 = a2 ? D(a2) : e2.content ?? "";
|
|
8018
8050
|
return {
|
|
8019
8051
|
id: String(e2.id),
|
|
8020
8052
|
role: t2,
|
|
@@ -8104,7 +8136,7 @@ var AgentChatClient = class {
|
|
|
8104
8136
|
let t2 = [];
|
|
8105
8137
|
for (let n2 of e2) {
|
|
8106
8138
|
if (n2.role !== "agent" || n2.status !== "sent" || n2.stream) continue;
|
|
8107
|
-
let e3 =
|
|
8139
|
+
let e3 = C(n2.id);
|
|
8108
8140
|
e3 !== null && t2.push(e3);
|
|
8109
8141
|
}
|
|
8110
8142
|
return t2;
|
|
@@ -8134,7 +8166,7 @@ function authUserToContext(e2) {
|
|
|
8134
8166
|
};
|
|
8135
8167
|
}
|
|
8136
8168
|
function toAgentChatErrorPayload(e2) {
|
|
8137
|
-
return e2 instanceof
|
|
8169
|
+
return e2 instanceof P ? {
|
|
8138
8170
|
code: e2.code,
|
|
8139
8171
|
message: e2.message,
|
|
8140
8172
|
cause: e2.cause
|
|
@@ -8145,17 +8177,23 @@ function toAgentChatErrorPayload(e2) {
|
|
|
8145
8177
|
};
|
|
8146
8178
|
}
|
|
8147
8179
|
function readWriteGateServerCode(e2) {
|
|
8148
|
-
if (!(e2 instanceof
|
|
8180
|
+
if (!(e2 instanceof P)) return;
|
|
8149
8181
|
let t2 = e2.details;
|
|
8150
8182
|
if (t2) {
|
|
8151
8183
|
if (typeof t2.serverCode == "string") return t2.serverCode;
|
|
8152
8184
|
if (typeof t2.code == "string") return t2.code;
|
|
8153
8185
|
}
|
|
8154
8186
|
}
|
|
8187
|
+
function remapPageActionRolloutDenied(e2) {
|
|
8188
|
+
return !(e2 instanceof P) || e2.code !== "TRANSPORT_FAILED" || e2.details?.serverCode !== "PAGE_ACTION_ROLLOUT_DENIED" ? e2 : new P("PAGE_ACTION_ROLLOUT_DENIED", e2.message || "PageAction not available for this user", {
|
|
8189
|
+
cause: e2,
|
|
8190
|
+
details: e2.details
|
|
8191
|
+
});
|
|
8192
|
+
}
|
|
8155
8193
|
function createAgentChat() {
|
|
8156
8194
|
return new AgentChatClient();
|
|
8157
8195
|
}
|
|
8158
|
-
var $ =
|
|
8196
|
+
var $ = Se(null), gt = 'useAgentChat must be used within <AgentChatProvider>. Wrap your app: <AgentChatProvider dsn="..."><App /></AgentChatProvider>, or use <AgentChat dsn="..." /> for the all-in-one integration.', _t = Ce(() => import("./react-AgentChatEmbedded-C3EXVQzH.js").then((e2) => e2.n));
|
|
8159
8197
|
function syncRuntimeOptions(e2, t2) {
|
|
8160
8198
|
e2.applyRuntimeOptions({
|
|
8161
8199
|
attachPageContext: t2.attachPageContext,
|
|
@@ -8164,8 +8202,8 @@ function syncRuntimeOptions(e2, t2) {
|
|
|
8164
8202
|
}
|
|
8165
8203
|
function AgentChat({ children: e2, dsn: t2, ...n2 }) {
|
|
8166
8204
|
if (!t2) throw Error("<AgentChat> requires a `dsn` prop.");
|
|
8167
|
-
let [r2] =
|
|
8168
|
-
return
|
|
8205
|
+
let [r2] = M(() => createAgentChat()), [i2, a2] = M(false), o2 = j(0), s2 = j(null), c2 = Te(() => JSON.stringify(n2.pageContext ?? null), [n2.pageContext]);
|
|
8206
|
+
return A(() => {
|
|
8169
8207
|
let e3 = JSON.stringify({
|
|
8170
8208
|
dsn: t2,
|
|
8171
8209
|
baseUrl: n2.baseUrl,
|
|
@@ -8194,7 +8232,7 @@ function AgentChat({ children: e2, dsn: t2, ...n2 }) {
|
|
|
8194
8232
|
n2.baseUrl,
|
|
8195
8233
|
n2.accountToken,
|
|
8196
8234
|
n2.userAccessToken
|
|
8197
|
-
]),
|
|
8235
|
+
]), A(() => {
|
|
8198
8236
|
syncRuntimeOptions(r2, {
|
|
8199
8237
|
attachPageContext: n2.attachPageContext,
|
|
8200
8238
|
pageContext: n2.pageContext
|
|
@@ -8204,11 +8242,11 @@ function AgentChat({ children: e2, dsn: t2, ...n2 }) {
|
|
|
8204
8242
|
n2.attachPageContext,
|
|
8205
8243
|
c2,
|
|
8206
8244
|
n2.pageContext
|
|
8207
|
-
]), /* @__PURE__ */
|
|
8245
|
+
]), /* @__PURE__ */ De($.Provider, {
|
|
8208
8246
|
value: r2,
|
|
8209
|
-
children: [e2, i2 ? /* @__PURE__ */
|
|
8247
|
+
children: [e2, i2 ? /* @__PURE__ */ N(xe, {
|
|
8210
8248
|
fallback: null,
|
|
8211
|
-
children: /* @__PURE__ */
|
|
8249
|
+
children: /* @__PURE__ */ N(_t, {
|
|
8212
8250
|
client: r2,
|
|
8213
8251
|
position: n2.position
|
|
8214
8252
|
})
|
|
@@ -8216,10 +8254,10 @@ function AgentChat({ children: e2, dsn: t2, ...n2 }) {
|
|
|
8216
8254
|
});
|
|
8217
8255
|
}
|
|
8218
8256
|
function AgentChatProvider({ children: e2, ...t2 }) {
|
|
8219
|
-
let { dsn: n2 } = t2, r2 =
|
|
8257
|
+
let { dsn: n2 } = t2, r2 = j(t2);
|
|
8220
8258
|
r2.current = t2;
|
|
8221
|
-
let [i2] =
|
|
8222
|
-
|
|
8259
|
+
let [i2] = M(() => createAgentChat()), a2 = j(null);
|
|
8260
|
+
A(() => {
|
|
8223
8261
|
if (a2.current === n2) return;
|
|
8224
8262
|
let e3 = false, t3 = false, run = async () => {
|
|
8225
8263
|
if (a2.current !== null && i2.destroy(), await i2.init({
|
|
@@ -8237,33 +8275,33 @@ function AgentChatProvider({ children: e2, ...t2 }) {
|
|
|
8237
8275
|
e3 = true, (t3 || a2.current === n2) && (i2.destroy(), a2.current = null);
|
|
8238
8276
|
};
|
|
8239
8277
|
}, [n2]);
|
|
8240
|
-
let o2 =
|
|
8241
|
-
return /* @__PURE__ */
|
|
8278
|
+
let o2 = Te(() => i2, [i2]);
|
|
8279
|
+
return /* @__PURE__ */ N($.Provider, {
|
|
8242
8280
|
value: o2,
|
|
8243
8281
|
children: e2
|
|
8244
8282
|
});
|
|
8245
8283
|
}
|
|
8246
8284
|
function useAgentChatClient() {
|
|
8247
|
-
let e2 =
|
|
8285
|
+
let e2 = we($);
|
|
8248
8286
|
if (!e2) throw Error(gt);
|
|
8249
8287
|
return e2;
|
|
8250
8288
|
}
|
|
8251
8289
|
function useAgentChatStore(e2, t2 = Object.is) {
|
|
8252
|
-
let n2 = useAgentChatClient(), r2 =
|
|
8290
|
+
let n2 = useAgentChatClient(), r2 = j(e2);
|
|
8253
8291
|
r2.current = e2;
|
|
8254
|
-
let i2 =
|
|
8292
|
+
let i2 = j(t2);
|
|
8255
8293
|
i2.current = t2;
|
|
8256
|
-
let a2 =
|
|
8294
|
+
let a2 = j(void 0), getSnapshot = () => {
|
|
8257
8295
|
let e3 = r2.current(n2.getState()), t3 = a2.current;
|
|
8258
8296
|
return t3 !== void 0 && i2.current(t3, e3) ? t3 : (a2.current = e3, e3);
|
|
8259
8297
|
}, subscribe = (e3) => n2.subscribeStateChange(() => {
|
|
8260
8298
|
let t3 = r2.current(n2.getState()), o2 = a2.current;
|
|
8261
8299
|
o2 !== void 0 && i2.current(o2, t3) || (a2.current = t3, e3());
|
|
8262
8300
|
});
|
|
8263
|
-
return
|
|
8301
|
+
return Ee(subscribe, getSnapshot, getSnapshot);
|
|
8264
8302
|
}
|
|
8265
8303
|
function useAgentChat() {
|
|
8266
|
-
let e2 = useAgentChatClient(), t2 =
|
|
8304
|
+
let e2 = useAgentChatClient(), t2 = Ee((t3) => e2.subscribeStateChange(t3), () => e2.getState(), () => e2.getState()), n2 = k(() => e2.open(), [e2]), r2 = k(() => e2.close(), [e2]), i2 = k(() => e2.toggle(), [e2]), a2 = k((t3) => e2.login(t3), [e2]), o2 = k(() => e2.logout(), [e2]), s2 = k((t3) => e2.sendMessage(t3), [e2]), c2 = k((t3) => e2.selectSession(t3), [e2]), l2 = k(() => e2.refreshSessions(), [e2]), u2 = k(() => e2.loadMoreSessions(), [e2]), d2 = k(() => e2.loadMoreSessionMessages(), [e2]), f2 = k((t3) => e2.selectAgent(t3), [e2]), p2 = k((t3) => e2.selectSkill(t3), [e2]), m2 = k((t3) => e2.setAttachPageContext(t3), [e2]), h2 = k((t3) => e2.setRouteContext(t3), [e2]), g2 = k(() => e2.syncRouteContextFromWindow(), [e2]);
|
|
8267
8305
|
return {
|
|
8268
8306
|
instance: e2,
|
|
8269
8307
|
state: t2,
|
|
@@ -8304,8 +8342,8 @@ function useAgentChat() {
|
|
|
8304
8342
|
};
|
|
8305
8343
|
}
|
|
8306
8344
|
function useHostAction(e2, t2) {
|
|
8307
|
-
let n2 = typeof e2 == "function", r2 = n2 ? "" : e2.trim(), i2 =
|
|
8308
|
-
n2 && (i2.current = e2), a2.current = t2,
|
|
8345
|
+
let n2 = typeof e2 == "function", r2 = n2 ? "" : e2.trim(), i2 = j(n2 ? e2 : null), a2 = j(t2);
|
|
8346
|
+
n2 && (i2.current = e2), a2.current = t2, A(() => {
|
|
8309
8347
|
let wrapped = (e3) => (n2 ? i2.current : a2.current)?.(e3);
|
|
8310
8348
|
if (n2) return registerHostAction(wrapped);
|
|
8311
8349
|
if (r2) return registerHostAction(r2, wrapped);
|
|
@@ -8389,20 +8427,20 @@ function bindPageToolsFromRef(e2) {
|
|
|
8389
8427
|
})) : [];
|
|
8390
8428
|
}
|
|
8391
8429
|
function usePageAgent(e2) {
|
|
8392
|
-
let t2 = useAgentChatClient(), n2 = useAgentChatStore((e3) => e3.lifecycle), r2 = e2.scope.trim(), i2 =
|
|
8430
|
+
let t2 = useAgentChatClient(), n2 = useAgentChatStore((e3) => e3.lifecycle), r2 = e2.scope.trim(), i2 = j(e2);
|
|
8393
8431
|
i2.current = e2;
|
|
8394
|
-
let a2 =
|
|
8432
|
+
let a2 = j(e2.tools);
|
|
8395
8433
|
a2.current = e2.tools;
|
|
8396
|
-
let o2 = hostToolNamesKey(e2.tools), s2 =
|
|
8434
|
+
let o2 = hostToolNamesKey(e2.tools), s2 = j(e2.genericTools);
|
|
8397
8435
|
s2.current = e2.genericTools;
|
|
8398
|
-
let c2 = hostToolNamesKey(e2.genericTools), l2 =
|
|
8399
|
-
|
|
8436
|
+
let c2 = hostToolNamesKey(e2.genericTools), l2 = j(false);
|
|
8437
|
+
A(() => {
|
|
8400
8438
|
n2 === "initialized" && e2.pageContext && t2.setPageContext(e2.pageContext);
|
|
8401
8439
|
}, [
|
|
8402
8440
|
t2,
|
|
8403
8441
|
e2.pageContext,
|
|
8404
8442
|
n2
|
|
8405
|
-
]),
|
|
8443
|
+
]), A(() => {
|
|
8406
8444
|
if (!c2) return;
|
|
8407
8445
|
l2.current || (l2.current = true, console.warn("[agent-chat] usePageAgent: genericTools is deprecated \u2014 use useAppAgent at the app root."));
|
|
8408
8446
|
let e3 = false;
|
|
@@ -8419,7 +8457,7 @@ function usePageAgent(e2) {
|
|
|
8419
8457
|
e3 = true;
|
|
8420
8458
|
for (let e4 of splitHostToolNamesKey(c2)) t2.unregisterHostTool("*", e4);
|
|
8421
8459
|
};
|
|
8422
|
-
}, [t2, c2]),
|
|
8460
|
+
}, [t2, c2]), A(() => {
|
|
8423
8461
|
if (!r2 || !o2) return;
|
|
8424
8462
|
let n3 = false, i3 = splitHostToolNamesKey(o2);
|
|
8425
8463
|
return (async () => {
|
|
@@ -8444,10 +8482,10 @@ function usePageAgent(e2) {
|
|
|
8444
8482
|
e2.routePattern,
|
|
8445
8483
|
o2
|
|
8446
8484
|
]);
|
|
8447
|
-
let u2 =
|
|
8485
|
+
let u2 = j(e2.handlers);
|
|
8448
8486
|
u2.current = e2.handlers;
|
|
8449
8487
|
let d2 = e2.handlers ? Object.keys(e2.handlers).sort().join("\0") : "";
|
|
8450
|
-
|
|
8488
|
+
A(() => {
|
|
8451
8489
|
if (!r2 || !d2) return;
|
|
8452
8490
|
let e3 = splitHostToolNamesKey(d2);
|
|
8453
8491
|
for (let n3 of e3) t2.registerHostTool(r2, n3, (e4) => u2.current?.[n3]?.(e4));
|
|
@@ -8458,7 +8496,7 @@ function usePageAgent(e2) {
|
|
|
8458
8496
|
t2,
|
|
8459
8497
|
r2,
|
|
8460
8498
|
d2
|
|
8461
|
-
]),
|
|
8499
|
+
]), A(() => {
|
|
8462
8500
|
if (r2) return subscribePageAgentLifecycle(t2, {
|
|
8463
8501
|
shouldDeliver: (e3) => shouldDeliverPageLifecycle(e3, r2),
|
|
8464
8502
|
streamThrottleMs: e2.streamThrottleMs,
|
|
@@ -8495,44 +8533,74 @@ function resolveLaunchAnchor(e2) {
|
|
|
8495
8533
|
return e2 ? "current" in e2 ? e2.current : e2 : null;
|
|
8496
8534
|
}
|
|
8497
8535
|
function usePageActions(e2) {
|
|
8498
|
-
let t2 = useAgentChatClient(), n2 = useAgentChatStore((e3) => e3.isLoggedIn), r2 = e2.requireInstruction !== false, i2 = e2.autoResume === true, a2 = e2.reconcileOnMount ?? !i2, [
|
|
8499
|
-
|
|
8500
|
-
let
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8536
|
+
let t2 = useAgentChatClient(), n2 = useAgentChatStore((e3) => e3.isLoggedIn), r2 = e2.requireInstruction !== false, i2 = e2.autoResume === true, a2 = e2.checkRollout !== false, o2 = e2.reconcileOnMount ?? !i2, [s2, c2] = M(e2.defaultInstruction ?? ""), [l2, u2] = M({}), [d2, f2] = M(!a2 || null), [p2, m2] = M(a2 ? null : "open"), h2 = j(e2);
|
|
8537
|
+
h2.current = e2;
|
|
8538
|
+
let g2 = j(0), _2 = j(d2);
|
|
8539
|
+
_2.current = d2;
|
|
8540
|
+
let v2 = e2.actionKey.trim(), y2 = k(async () => {
|
|
8541
|
+
if (!a2 || !v2) {
|
|
8542
|
+
f2(true), m2("open");
|
|
8543
|
+
return;
|
|
8544
|
+
}
|
|
8545
|
+
if (!n2) {
|
|
8546
|
+
f2(null), m2(null);
|
|
8547
|
+
return;
|
|
8548
|
+
}
|
|
8549
|
+
try {
|
|
8550
|
+
let e3 = await t2.checkPageActionRollout([v2]), n3 = e3.find((e4) => e4.actionKey === v2) ?? e3[0];
|
|
8551
|
+
if (!n3) {
|
|
8552
|
+
f2(true), m2("open");
|
|
8553
|
+
return;
|
|
8554
|
+
}
|
|
8555
|
+
f2(n3.allowed), m2(n3.reason);
|
|
8556
|
+
} catch {
|
|
8557
|
+
f2(true), m2(null);
|
|
8558
|
+
}
|
|
8559
|
+
}, [
|
|
8560
|
+
v2,
|
|
8561
|
+
a2,
|
|
8562
|
+
t2,
|
|
8563
|
+
n2
|
|
8564
|
+
]);
|
|
8565
|
+
A(() => {
|
|
8566
|
+
y2();
|
|
8567
|
+
}, [y2]);
|
|
8568
|
+
let x2 = k(() => {
|
|
8569
|
+
let e3 = buildPageActionRowsMap(t2.getPageActionRowsForActionKey(v2));
|
|
8570
|
+
u2((t3) => pageActionRowsShallowEqual(t3, e3) ? t3 : e3);
|
|
8571
|
+
}, [v2, t2]);
|
|
8572
|
+
A(() => {
|
|
8573
|
+
x2();
|
|
8506
8574
|
let e3 = t2.on("pageActionRowChanged", (e4) => {
|
|
8507
|
-
e4.state.actionKey ===
|
|
8575
|
+
e4.state.actionKey === v2 && u2((t3) => {
|
|
8508
8576
|
let n4 = t3[e4.rowKey];
|
|
8509
8577
|
return n4 && n4.updatedAt === e4.state.updatedAt && n4.phase === e4.state.phase && n4.message === e4.state.message && n4.progressLabel === e4.state.progressLabel && n4.error === e4.state.error && n4.loading === e4.state.loading && n4.disabled === e4.state.disabled && n4.narrativeItems === e4.state.narrativeItems ? t3 : {
|
|
8510
8578
|
...t3,
|
|
8511
8579
|
[e4.rowKey]: e4.state
|
|
8512
8580
|
};
|
|
8513
8581
|
});
|
|
8514
|
-
}), n3 = t2.on("automationTaskCenterChanged",
|
|
8582
|
+
}), n3 = t2.on("automationTaskCenterChanged", x2), r3 = t2.on("approvalExecutionCompleted", x2), i3 = t2.on("approvalInboxChanged", x2);
|
|
8515
8583
|
return () => {
|
|
8516
8584
|
e3(), n3(), r3(), i3();
|
|
8517
8585
|
};
|
|
8518
8586
|
}, [
|
|
8519
|
-
|
|
8587
|
+
v2,
|
|
8520
8588
|
t2,
|
|
8521
|
-
|
|
8522
|
-
]),
|
|
8523
|
-
n2 ||
|
|
8524
|
-
}, [n2]),
|
|
8525
|
-
!
|
|
8589
|
+
x2
|
|
8590
|
+
]), A(() => {
|
|
8591
|
+
n2 || u2({});
|
|
8592
|
+
}, [n2]), A(() => {
|
|
8593
|
+
!o2 || !n2 || !v2 || t2.reconcileActivePageActions({ actionKey: v2 }).then(x2).catch(() => {
|
|
8526
8594
|
});
|
|
8527
8595
|
}, [
|
|
8528
|
-
|
|
8596
|
+
v2,
|
|
8529
8597
|
t2,
|
|
8530
8598
|
n2,
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
]),
|
|
8534
|
-
if (!(!i2 || !
|
|
8535
|
-
actionKey:
|
|
8599
|
+
o2,
|
|
8600
|
+
x2
|
|
8601
|
+
]), A(() => {
|
|
8602
|
+
if (!(!i2 || !v2)) return t2.bindPageActionSlot({
|
|
8603
|
+
actionKey: v2,
|
|
8536
8604
|
rowKey: "*",
|
|
8537
8605
|
pageContext: e2.page ? { page: e2.page } : null,
|
|
8538
8606
|
ready: true,
|
|
@@ -8540,73 +8608,77 @@ function usePageActions(e2) {
|
|
|
8540
8608
|
autoApplyPending: false
|
|
8541
8609
|
});
|
|
8542
8610
|
}, [
|
|
8543
|
-
|
|
8611
|
+
v2,
|
|
8544
8612
|
i2,
|
|
8545
8613
|
t2,
|
|
8546
8614
|
e2.page
|
|
8547
8615
|
]);
|
|
8548
|
-
let
|
|
8616
|
+
let S2 = k((e3) => {
|
|
8549
8617
|
let n3 = e3.trim();
|
|
8550
|
-
return n3 ?
|
|
8618
|
+
return n3 ? l2[n3] ?? t2.getPageActionRowState(n3) ?? createIdlePageActionRowState(n3, v2) : createIdlePageActionRowState("", v2);
|
|
8551
8619
|
}, [
|
|
8552
|
-
|
|
8620
|
+
v2,
|
|
8553
8621
|
t2,
|
|
8554
|
-
|
|
8555
|
-
]),
|
|
8556
|
-
let e3 = await t2.reconcileActivePageActions({ actionKey:
|
|
8557
|
-
return
|
|
8622
|
+
l2
|
|
8623
|
+
]), ee2 = k(async () => {
|
|
8624
|
+
let e3 = await t2.reconcileActivePageActions({ actionKey: v2 });
|
|
8625
|
+
return x2(), e3;
|
|
8558
8626
|
}, [
|
|
8559
|
-
|
|
8627
|
+
v2,
|
|
8560
8628
|
t2,
|
|
8561
|
-
|
|
8562
|
-
]),
|
|
8629
|
+
x2
|
|
8630
|
+
]), te2 = k((e3) => {
|
|
8563
8631
|
t2.openAutomationTaskCenter(e3);
|
|
8564
|
-
}, [t2]),
|
|
8632
|
+
}, [t2]), ne2 = k((e3) => {
|
|
8565
8633
|
t2.clearPageActionRowError(e3);
|
|
8566
8634
|
}, [t2]);
|
|
8567
8635
|
return {
|
|
8568
|
-
instruction:
|
|
8569
|
-
setInstruction:
|
|
8570
|
-
rows:
|
|
8571
|
-
getRow:
|
|
8572
|
-
getProcessView: (e3) => b(
|
|
8573
|
-
invoke:
|
|
8636
|
+
instruction: s2,
|
|
8637
|
+
setInstruction: c2,
|
|
8638
|
+
rows: l2,
|
|
8639
|
+
getRow: S2,
|
|
8640
|
+
getProcessView: (e3) => b(S2(e3)),
|
|
8641
|
+
invoke: k(async (e3) => {
|
|
8574
8642
|
let n3 = e3.rowKey.trim();
|
|
8575
8643
|
if (!n3) return;
|
|
8576
|
-
let i3 = (e3.instruction ??
|
|
8577
|
-
if (r2 && !i3 || !
|
|
8578
|
-
|
|
8579
|
-
let a3 =
|
|
8644
|
+
let i3 = (e3.instruction ?? s2).trim();
|
|
8645
|
+
if (r2 && !i3 || !v2 || _2.current === false) return;
|
|
8646
|
+
g2.current += 1;
|
|
8647
|
+
let a3 = h2.current.page?.trim(), o3 = e3.pageContext ? {
|
|
8580
8648
|
...e3.pageContext,
|
|
8581
8649
|
...a3 && !e3.pageContext.page ? { page: a3 } : {}
|
|
8582
|
-
} : a3 ? { page: a3 } : void 0, c3 =
|
|
8583
|
-
actionKey:
|
|
8650
|
+
} : a3 ? { page: a3 } : void 0, c3 = h2.current.context, l3 = e3.context, u3 = {
|
|
8651
|
+
actionKey: v2,
|
|
8584
8652
|
rowKey: n3,
|
|
8585
|
-
clientActionId: e3.clientActionId?.trim() || `page-action-${n3}-${
|
|
8653
|
+
clientActionId: e3.clientActionId?.trim() || `page-action-${n3}-${g2.current}`,
|
|
8586
8654
|
awaitStream: false,
|
|
8587
8655
|
launchAnchor: resolveLaunchAnchor(e3.launchAnchor),
|
|
8588
|
-
pageContext:
|
|
8656
|
+
pageContext: o3
|
|
8589
8657
|
};
|
|
8590
|
-
e3.preferReuse === false && (
|
|
8658
|
+
e3.preferReuse === false && (u3.preferReuse = false), i3 && (u3.instruction = i3), (c3 || l3) && (u3.context = {
|
|
8591
8659
|
...c3,
|
|
8592
8660
|
...l3
|
|
8593
|
-
}), e3.signal && (
|
|
8661
|
+
}), e3.signal && (u3.signal = e3.signal), e3.onChunk && (u3.onChunk = e3.onChunk);
|
|
8594
8662
|
try {
|
|
8595
|
-
let e4 = await t2.invokePageAction(
|
|
8596
|
-
return
|
|
8663
|
+
let e4 = await t2.invokePageAction(u3);
|
|
8664
|
+
return x2(), e4;
|
|
8597
8665
|
} catch (e4) {
|
|
8598
|
-
throw
|
|
8666
|
+
throw x2(), e4;
|
|
8599
8667
|
}
|
|
8600
8668
|
}, [
|
|
8601
|
-
|
|
8669
|
+
v2,
|
|
8602
8670
|
t2,
|
|
8603
|
-
|
|
8671
|
+
s2,
|
|
8604
8672
|
r2,
|
|
8605
|
-
|
|
8673
|
+
x2
|
|
8606
8674
|
]),
|
|
8607
|
-
reconcile:
|
|
8608
|
-
openTaskCenter:
|
|
8609
|
-
clearRowError:
|
|
8675
|
+
reconcile: ee2,
|
|
8676
|
+
openTaskCenter: te2,
|
|
8677
|
+
clearRowError: ne2,
|
|
8678
|
+
rolloutAllowed: d2,
|
|
8679
|
+
rolloutReason: p2,
|
|
8680
|
+
visible: d2 !== false,
|
|
8681
|
+
refreshRollout: y2
|
|
8610
8682
|
};
|
|
8611
8683
|
}
|
|
8612
8684
|
function defaultRowKey(e2) {
|
|
@@ -8617,7 +8689,7 @@ function usePageAction(e2) {
|
|
|
8617
8689
|
let t2 = useAgentChatClient(), n2 = e2.ready !== false, r2 = e2.autoResume !== false, i2 = e2.autoApplyPending !== false, a2 = e2.actionKey.trim(), o2 = defaultRowKey(e2.pageContext), s2 = pageActionSlotKey({
|
|
8618
8690
|
actionKey: a2,
|
|
8619
8691
|
rowKey: o2
|
|
8620
|
-
}), c2 =
|
|
8692
|
+
}), c2 = j(e2);
|
|
8621
8693
|
c2.current = e2;
|
|
8622
8694
|
let l2 = usePageActions({
|
|
8623
8695
|
actionKey: e2.actionKey,
|
|
@@ -8625,9 +8697,10 @@ function usePageAction(e2) {
|
|
|
8625
8697
|
defaultInstruction: e2.defaultInstruction,
|
|
8626
8698
|
context: e2.context,
|
|
8627
8699
|
requireInstruction: e2.requireInstruction,
|
|
8628
|
-
reconcileOnMount: false
|
|
8629
|
-
|
|
8630
|
-
|
|
8700
|
+
reconcileOnMount: false,
|
|
8701
|
+
checkRollout: e2.checkRollout
|
|
8702
|
+
}), u2 = l2.getRow(o2), [d2, f2] = M(null), [p2, m2] = M("idle");
|
|
8703
|
+
return A(() => {
|
|
8631
8704
|
let syncPending = () => {
|
|
8632
8705
|
let e3 = t2.getPendingPageActionApply(), n3 = matchesPendingPageActionApply(e3, {
|
|
8633
8706
|
actionKey: a2,
|
|
@@ -8636,9 +8709,9 @@ function usePageAction(e2) {
|
|
|
8636
8709
|
f2(n3 ? e3 : null);
|
|
8637
8710
|
};
|
|
8638
8711
|
return syncPending(), t2.on("pendingPageActionApplyChanged", syncPending);
|
|
8639
|
-
}, [a2, t2]),
|
|
8712
|
+
}, [a2, t2]), A(() => t2.on("pageActionSlotApplyPhaseChanged", (e3) => {
|
|
8640
8713
|
e3.slotKey === s2 && m2(e3.phase);
|
|
8641
|
-
}), [t2, s2]),
|
|
8714
|
+
}), [t2, s2]), A(() => {
|
|
8642
8715
|
let e3 = c2.current;
|
|
8643
8716
|
return t2.bindPageActionSlot({
|
|
8644
8717
|
actionKey: a2,
|
|
@@ -8652,7 +8725,7 @@ function usePageAction(e2) {
|
|
|
8652
8725
|
a2,
|
|
8653
8726
|
t2,
|
|
8654
8727
|
o2
|
|
8655
|
-
]),
|
|
8728
|
+
]), A(() => {
|
|
8656
8729
|
t2.patchPageActionSlot(s2, {
|
|
8657
8730
|
pageContext: e2.pageContext,
|
|
8658
8731
|
ready: n2,
|
|
@@ -8689,7 +8762,11 @@ function usePageAction(e2) {
|
|
|
8689
8762
|
openTaskCenter: () => l2.openTaskCenter(u2.runId == null ? void 0 : { runId: u2.runId }),
|
|
8690
8763
|
loading: u2.loading,
|
|
8691
8764
|
awaitingApproval: u2.awaitingApproval,
|
|
8692
|
-
disabled: u2.disabled,
|
|
8765
|
+
disabled: u2.disabled || l2.rolloutAllowed === false,
|
|
8766
|
+
rolloutAllowed: l2.rolloutAllowed,
|
|
8767
|
+
rolloutReason: l2.rolloutReason,
|
|
8768
|
+
visible: l2.visible,
|
|
8769
|
+
refreshRollout: l2.refreshRollout,
|
|
8693
8770
|
error: u2.error,
|
|
8694
8771
|
message: u2.message,
|
|
8695
8772
|
progressLabel: u2.progressLabel,
|
|
@@ -8711,16 +8788,16 @@ function isOmnixExtensionAvailable() {
|
|
|
8711
8788
|
}
|
|
8712
8789
|
function requestOmnixExtensionBridge() {
|
|
8713
8790
|
if (!(typeof window > "u")) try {
|
|
8714
|
-
window.dispatchEvent(new CustomEvent(
|
|
8791
|
+
window.dispatchEvent(new CustomEvent(Fe));
|
|
8715
8792
|
} catch {
|
|
8716
8793
|
}
|
|
8717
8794
|
}
|
|
8718
8795
|
function waitForOmnixExtensionAvailable(e2 = 8e3) {
|
|
8719
8796
|
return isOmnixExtensionAvailable() ? Promise.resolve(true) : typeof window > "u" ? Promise.resolve(false) : (requestOmnixExtensionBridge(), new Promise((t2) => {
|
|
8720
8797
|
let n2 = false, finish = (e3) => {
|
|
8721
|
-
n2 || (n2 = true, window.removeEventListener(
|
|
8798
|
+
n2 || (n2 = true, window.removeEventListener(L, onReady), clearInterval(r2), clearTimeout(i2), t2(e3));
|
|
8722
8799
|
}, onReady = () => finish(isOmnixExtensionAvailable());
|
|
8723
|
-
window.addEventListener(
|
|
8800
|
+
window.addEventListener(L, onReady);
|
|
8724
8801
|
let r2 = window.setInterval(() => {
|
|
8725
8802
|
requestOmnixExtensionBridge(), isOmnixExtensionAvailable() && finish(true);
|
|
8726
8803
|
}, 500), i2 = window.setTimeout(() => finish(isOmnixExtensionAvailable()), e2);
|
|
@@ -8744,11 +8821,11 @@ async function trackGofoWaybill(e2, t2) {
|
|
|
8744
8821
|
});
|
|
8745
8822
|
}
|
|
8746
8823
|
function useOmnixExtension(e2 = {}) {
|
|
8747
|
-
let t2 = e2.waitMs ?? 1e4, n2 = useAgentChatStore((e3) => e3.isLoggedIn), [r2, i2] =
|
|
8748
|
-
|
|
8824
|
+
let t2 = e2.waitMs ?? 1e4, n2 = useAgentChatStore((e3) => e3.isLoggedIn), [r2, i2] = M(() => isOmnixExtensionAvailable());
|
|
8825
|
+
A(() => {
|
|
8749
8826
|
let sync = () => i2(isOmnixExtensionAvailable());
|
|
8750
|
-
return window.addEventListener(
|
|
8751
|
-
}, []),
|
|
8827
|
+
return window.addEventListener(L, sync), () => window.removeEventListener(L, sync);
|
|
8828
|
+
}, []), A(() => {
|
|
8752
8829
|
if (isOmnixExtensionAvailable()) {
|
|
8753
8830
|
i2(true);
|
|
8754
8831
|
return;
|
|
@@ -8760,7 +8837,7 @@ function useOmnixExtension(e2 = {}) {
|
|
|
8760
8837
|
e3 = true;
|
|
8761
8838
|
};
|
|
8762
8839
|
}, [t2]);
|
|
8763
|
-
let a2 =
|
|
8840
|
+
let a2 = k((e3, t3) => trackGofoWaybill(e3, t3), []), o2 = k((e3) => syncOmnixPmsIntegration(e3), []), s2 = r2;
|
|
8764
8841
|
return {
|
|
8765
8842
|
extensionAvailable: r2,
|
|
8766
8843
|
isLoggedIn: n2,
|
|
@@ -8772,7 +8849,7 @@ function useOmnixExtension(e2 = {}) {
|
|
|
8772
8849
|
};
|
|
8773
8850
|
}
|
|
8774
8851
|
function useAppTool() {
|
|
8775
|
-
let e2 = useAgentChatClient(), t2 = useAgentChatStore((e3) => e3.isLoggedIn), [n2, r2] =
|
|
8852
|
+
let e2 = useAgentChatClient(), t2 = useAgentChatStore((e3) => e3.isLoggedIn), [n2, r2] = M(false), [i2, a2] = M(null), [o2, s2] = M([]), [c2, l2] = M(null), [u2, d2] = M(null);
|
|
8776
8853
|
return {
|
|
8777
8854
|
isLoggedIn: t2,
|
|
8778
8855
|
loading: n2,
|
|
@@ -8780,7 +8857,7 @@ function useAppTool() {
|
|
|
8780
8857
|
items: o2,
|
|
8781
8858
|
lastResult: c2,
|
|
8782
8859
|
lastServerCode: u2,
|
|
8783
|
-
listCallable:
|
|
8860
|
+
listCallable: k(async (t3) => {
|
|
8784
8861
|
r2(true), a2(null), d2(null);
|
|
8785
8862
|
try {
|
|
8786
8863
|
let { items: n3 } = await e2.listCallableTools(t3);
|
|
@@ -8793,7 +8870,7 @@ function useAppTool() {
|
|
|
8793
8870
|
r2(false);
|
|
8794
8871
|
}
|
|
8795
8872
|
}, [e2]),
|
|
8796
|
-
invoke:
|
|
8873
|
+
invoke: k(async (t3) => {
|
|
8797
8874
|
a2(null), d2(null);
|
|
8798
8875
|
try {
|
|
8799
8876
|
let n3 = await e2.invokeAppTool(t3);
|
|
@@ -8804,13 +8881,13 @@ function useAppTool() {
|
|
|
8804
8881
|
throw a2(t4), e3;
|
|
8805
8882
|
}
|
|
8806
8883
|
}, [e2]),
|
|
8807
|
-
clearError:
|
|
8884
|
+
clearError: k(() => {
|
|
8808
8885
|
a2(null), d2(null);
|
|
8809
8886
|
}, [])
|
|
8810
8887
|
};
|
|
8811
8888
|
}
|
|
8812
8889
|
function useContextMentions(e2, t2) {
|
|
8813
|
-
|
|
8890
|
+
A(() => {
|
|
8814
8891
|
if (t2.length === 0) {
|
|
8815
8892
|
e2.clearContextMentions();
|
|
8816
8893
|
return;
|
|
@@ -8829,12 +8906,12 @@ function bindAppToolsFromRef(e2) {
|
|
|
8829
8906
|
})) : [];
|
|
8830
8907
|
}
|
|
8831
8908
|
function useAppAgent(e2) {
|
|
8832
|
-
let t2 = useAgentChatClient(), n2 =
|
|
8909
|
+
let t2 = useAgentChatClient(), n2 = j(e2);
|
|
8833
8910
|
n2.current = e2;
|
|
8834
|
-
let r2 =
|
|
8911
|
+
let r2 = j(e2.tools);
|
|
8835
8912
|
r2.current = e2.tools;
|
|
8836
8913
|
let i2 = hostToolNamesKey(e2.tools);
|
|
8837
|
-
|
|
8914
|
+
A(() => {
|
|
8838
8915
|
if (!i2) return;
|
|
8839
8916
|
let e3 = false, n3 = splitHostToolNamesKey(i2);
|
|
8840
8917
|
return (async () => {
|
|
@@ -8850,7 +8927,7 @@ function useAppAgent(e2) {
|
|
|
8850
8927
|
e3 = true;
|
|
8851
8928
|
for (let e4 of n3) r2.current?.find((t3) => t3.name === e4)?.handler ? t2.unregisterHostTool("*", e4) : t2.undeclareHostTool("*", e4);
|
|
8852
8929
|
};
|
|
8853
|
-
}, [t2, i2]),
|
|
8930
|
+
}, [t2, i2]), A(() => subscribePageAgentLifecycle(t2, {
|
|
8854
8931
|
shouldDeliver: shouldDeliverAppLifecycle,
|
|
8855
8932
|
streamThrottleMs: e2.streamThrottleMs,
|
|
8856
8933
|
callbacks: {
|
|
@@ -8864,25 +8941,25 @@ function useAppAgent(e2) {
|
|
|
8864
8941
|
export {
|
|
8865
8942
|
AgentChat,
|
|
8866
8943
|
$ as AgentChatContext,
|
|
8867
|
-
|
|
8944
|
+
P as AgentChatError,
|
|
8868
8945
|
AgentChatProvider,
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8946
|
+
de as DEFAULT_LAUNCHER_MODE,
|
|
8947
|
+
ce as DEFAULT_PANEL_MODE,
|
|
8948
|
+
ue as HOST_ACTION_REASON,
|
|
8949
|
+
ee as buildNarrativeDisplayBlocks,
|
|
8873
8950
|
buildPageActionInvokePageContextSnapshot,
|
|
8874
|
-
|
|
8951
|
+
ne as countInterestingNarrativeItems,
|
|
8875
8952
|
AgentChat as default,
|
|
8876
8953
|
defineContextMention,
|
|
8877
8954
|
definePageContextMentions,
|
|
8878
8955
|
dispatchHostAction,
|
|
8879
|
-
|
|
8956
|
+
ae as isPageActionProcessLivePhase,
|
|
8880
8957
|
lifecycleMatchesPageScope,
|
|
8881
8958
|
lifecycleTouchesGlobalTool,
|
|
8882
8959
|
matchesPendingPageActionApply,
|
|
8883
|
-
|
|
8960
|
+
ze as onHostAction,
|
|
8884
8961
|
parseAgentChatPageContext,
|
|
8885
|
-
|
|
8962
|
+
ge as pickNarrativeHeadline,
|
|
8886
8963
|
registerHostAction,
|
|
8887
8964
|
registerHostTool,
|
|
8888
8965
|
registerHostToolsWithSync,
|
|
@@ -8899,7 +8976,7 @@ export {
|
|
|
8899
8976
|
useAgentChatStore,
|
|
8900
8977
|
useAppAgent,
|
|
8901
8978
|
useAppTool,
|
|
8902
|
-
|
|
8979
|
+
I as useAuthStore,
|
|
8903
8980
|
useContextMentions,
|
|
8904
8981
|
useHostAction,
|
|
8905
8982
|
useOmnixExtension,
|