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.legacy.cjs
CHANGED
|
@@ -2328,7 +2328,23 @@ function parseCatalogItem(e2) {
|
|
|
2328
2328
|
var t2, n2, r2;
|
|
2329
2329
|
if (!isRecord$4(e2)) return null;
|
|
2330
2330
|
let i2 = readString$2(e2.actionKey), a2 = readString$2(e2.name), o2 = readNumber$1(e2.pageActionId);
|
|
2331
|
-
return !i2 || !a2 || o2 == null ? null : { pageActionId: o2, actionKey: i2, name: a2, description: e2.description === null || (t2 = readString$2(e2.description)) == null ? null : t2, pageScope: e2.pageScope === null || (n2 = readString$2(e2.pageScope)) == null ? null : n2, sortOrder: (r2 = readNumber$1(e2.sortOrder)) == null ? 0 : r2, myFeedback: parseCatalogMyFeedback(e2.myFeedback) };
|
|
2331
|
+
return !i2 || !a2 || o2 == null ? null : { pageActionId: o2, actionKey: i2, name: a2, description: e2.description === null || (t2 = readString$2(e2.description)) == null ? null : t2, pageScope: e2.pageScope === null || (n2 = readString$2(e2.pageScope)) == null ? null : n2, sortOrder: (r2 = readNumber$1(e2.sortOrder)) == null ? 0 : r2, rolloutRestricted: e2.rolloutRestricted === true, myFeedback: parseCatalogMyFeedback(e2.myFeedback) };
|
|
2332
|
+
}
|
|
2333
|
+
function parseRolloutCheckItem(e2) {
|
|
2334
|
+
var t2;
|
|
2335
|
+
if (!isRecord$4(e2)) return null;
|
|
2336
|
+
let n2 = readString$2(e2.actionKey);
|
|
2337
|
+
if (!n2 || typeof e2.allowed != `boolean`) return null;
|
|
2338
|
+
let r2 = (t2 = readString$2(e2.reason)) == null ? e2.allowed ? `open` : `denied` : t2;
|
|
2339
|
+
return { actionKey: n2, allowed: e2.allowed, reason: r2 };
|
|
2340
|
+
}
|
|
2341
|
+
function parsePageActionRolloutCheck(e2) {
|
|
2342
|
+
let t2 = parseApiEnvelope(e2), n2 = Array.isArray(t2) ? t2 : isRecord$4(t2) && Array.isArray(t2.items) ? t2.items : [], r2 = /* @__PURE__ */ new Set(), i2 = [];
|
|
2343
|
+
for (let e3 of n2) {
|
|
2344
|
+
let t3 = parseRolloutCheckItem(e3);
|
|
2345
|
+
!t3 || r2.has(t3.actionKey) || (r2.add(t3.actionKey), i2.push(t3));
|
|
2346
|
+
}
|
|
2347
|
+
return i2;
|
|
2332
2348
|
}
|
|
2333
2349
|
function parseFeedbackView(e2) {
|
|
2334
2350
|
var t2;
|
|
@@ -2441,6 +2457,10 @@ var PageActionService = class {
|
|
|
2441
2457
|
let r2 = (n2 = e2.pageScope) == null ? void 0 : n2.trim();
|
|
2442
2458
|
return parsePageActionFeedbackCatalog(await this.http.request(`/page-action/catalog`, { method: `GET`, signal: t2, searchParams: r2 ? { pageScope: r2 } : void 0 }));
|
|
2443
2459
|
}
|
|
2460
|
+
async checkRollout(e2, t2) {
|
|
2461
|
+
let n2 = Array.from(new Set(e2.map((e3) => e3.trim()).filter((e3) => e3.length > 0)));
|
|
2462
|
+
return n2.length === 0 ? [] : parsePageActionRolloutCheck(await this.http.request(`/page-action/rollout-check`, { method: `POST`, signal: t2, body: { actionKeys: n2 } }));
|
|
2463
|
+
}
|
|
2444
2464
|
async upsertFeedback(e2, t2, n2) {
|
|
2445
2465
|
let i2 = parsePageActionFeedbackView(await this.http.request(`/page-action/feedback/${encodeActionKeyPath(e2)}`, { method: `PUT`, signal: n2, body: t2 }));
|
|
2446
2466
|
if (!i2) throw new r(`TRANSPORT_FAILED`, `Invalid feedback response`);
|
|
@@ -3097,7 +3117,7 @@ var PageActionCoordinator = class {
|
|
|
3097
3117
|
}
|
|
3098
3118
|
return t2.autoResume && await this.runLiveRestore(t2.actionKey), { applyPhase: this.getApplyPhase(e2) };
|
|
3099
3119
|
}
|
|
3100
|
-
}, Z = `
|
|
3120
|
+
}, Z = `3.0.2`;
|
|
3101
3121
|
function nanoId(e2 = `id`) {
|
|
3102
3122
|
let t2 = globalThis.crypto;
|
|
3103
3123
|
return t2 != null && t2.randomUUID ? `${e2}_${t2.randomUUID().replace(/-/g, ``).slice(0, 12)}` : `${e2}_${Math.random().toString(36).slice(2, 14)}`;
|
|
@@ -3311,6 +3331,9 @@ var AgentChatClient = class {
|
|
|
3311
3331
|
listPageActionFeedbackCatalog() {
|
|
3312
3332
|
return this.pageActionFeedbackCatalogItems.slice();
|
|
3313
3333
|
}
|
|
3334
|
+
async checkPageActionRollout(e2, t2) {
|
|
3335
|
+
return await this.ensureInitialized(`checkPageActionRollout`, { signal: t2 == null ? void 0 : t2.signal }), await this.ensureLoggedIn(`checkPageActionRollout`, { signal: t2 == null ? void 0 : t2.signal }), this.requireState(`checkPageActionRollout`).pageAction.checkRollout(e2, t2 == null ? void 0 : t2.signal);
|
|
3336
|
+
}
|
|
3314
3337
|
async getPageActionFeedback(e2, t2) {
|
|
3315
3338
|
return await this.ensureInitialized(`getPageActionFeedback`, { signal: t2 == null ? void 0 : t2.signal }), await this.ensureLoggedIn(`getPageActionFeedback`, { signal: t2 == null ? void 0 : t2.signal }), this.requireState(`getPageActionFeedback`).pageAction.getMyFeedback(e2, t2 == null ? void 0 : t2.signal);
|
|
3316
3339
|
}
|
|
@@ -3556,12 +3579,13 @@ var AgentChatClient = class {
|
|
|
3556
3579
|
}
|
|
3557
3580
|
return await this.invokePageActionStream(n2, t2, i2);
|
|
3558
3581
|
} catch (e2) {
|
|
3559
|
-
|
|
3582
|
+
let n3 = remapPageActionRolloutDenied(e2);
|
|
3583
|
+
if (i2 && !(n3 instanceof r && n3.code === `PAGE_ACTION_ALREADY_ACTIVE`)) {
|
|
3560
3584
|
var w2, T2, E2, D2, O2, k2;
|
|
3561
|
-
let
|
|
3562
|
-
this.upsertPageActionRow(buildPageActionRowState({ rowKey: i2, actionKey: t2.actionKey.trim(), runId: (w2 = (T2 = this.pageActionRows.get(i2)) == null ? void 0 : T2.runId) == null ? null : w2, pageActionKey: (E2 = (D2 = this.pageActionRows.get(i2)) == null ? void 0 : D2.pageActionKey) == null ? null : E2, phase: `failed`, error:
|
|
3585
|
+
let e3 = n3 instanceof Error ? n3.message : String(n3);
|
|
3586
|
+
this.upsertPageActionRow(buildPageActionRowState({ rowKey: i2, actionKey: t2.actionKey.trim(), runId: (w2 = (T2 = this.pageActionRows.get(i2)) == null ? void 0 : T2.runId) == null ? null : w2, pageActionKey: (E2 = (D2 = this.pageActionRows.get(i2)) == null ? void 0 : D2.pageActionKey) == null ? null : E2, phase: `failed`, error: e3, message: null, progressLabel: null, approvalRequestId: (O2 = (k2 = this.pageActionRows.get(i2)) == null ? void 0 : k2.approvalRequestId) == null ? null : O2 })), this.schedulePageActionRowIdleReset(i2, 1600);
|
|
3563
3587
|
}
|
|
3564
|
-
throw
|
|
3588
|
+
throw n3;
|
|
3565
3589
|
} finally {
|
|
3566
3590
|
this.releasePageActionLock(a2);
|
|
3567
3591
|
}
|
|
@@ -5658,6 +5682,10 @@ function readWriteGateServerCode(e2) {
|
|
|
5658
5682
|
if (typeof t2.code == `string`) return t2.code;
|
|
5659
5683
|
}
|
|
5660
5684
|
}
|
|
5685
|
+
function remapPageActionRolloutDenied(e2) {
|
|
5686
|
+
var t2;
|
|
5687
|
+
return !(e2 instanceof r) || e2.code !== `TRANSPORT_FAILED` || ((t2 = e2.details) == null ? void 0 : t2.serverCode) !== `PAGE_ACTION_ROLLOUT_DENIED` ? e2 : new r(`PAGE_ACTION_ROLLOUT_DENIED`, e2.message || `PageAction not available for this user`, { cause: e2, details: e2.details });
|
|
5688
|
+
}
|
|
5661
5689
|
function createAgentChat() {
|
|
5662
5690
|
return new AgentChatClient();
|
|
5663
5691
|
}
|
|
@@ -5925,59 +5953,85 @@ function resolveLaunchAnchor(e2) {
|
|
|
5925
5953
|
}
|
|
5926
5954
|
function usePageActions(n2) {
|
|
5927
5955
|
var r2, i2;
|
|
5928
|
-
let a2 = useAgentChatClient(), o2 = useAgentChatStore((e2) => e2.isLoggedIn), s2 = n2.requireInstruction !== false, c2 = n2.autoResume === true, l2 = (r2 = n2.reconcileOnMount) == null ? !c2 : r2, [
|
|
5929
|
-
|
|
5930
|
-
let
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5956
|
+
let a2 = useAgentChatClient(), o2 = useAgentChatStore((e2) => e2.isLoggedIn), s2 = n2.requireInstruction !== false, c2 = n2.autoResume === true, l2 = n2.checkRollout !== false, u2 = (r2 = n2.reconcileOnMount) == null ? !c2 : r2, [d2, f2] = (0, t.useState)((i2 = n2.defaultInstruction) == null ? `` : i2), [p2, m2] = (0, t.useState)({}), [h2, g2] = (0, t.useState)(!l2 || null), [_2, v2] = (0, t.useState)(l2 ? null : `open`), y2 = (0, t.useRef)(n2);
|
|
5957
|
+
y2.current = n2;
|
|
5958
|
+
let b2 = (0, t.useRef)(0), x2 = (0, t.useRef)(h2);
|
|
5959
|
+
x2.current = h2;
|
|
5960
|
+
let S2 = n2.actionKey.trim(), C2 = (0, t.useCallback)(async () => {
|
|
5961
|
+
if (!l2 || !S2) {
|
|
5962
|
+
g2(true), v2(`open`);
|
|
5963
|
+
return;
|
|
5964
|
+
}
|
|
5965
|
+
if (!o2) {
|
|
5966
|
+
g2(null), v2(null);
|
|
5967
|
+
return;
|
|
5968
|
+
}
|
|
5969
|
+
try {
|
|
5970
|
+
var e2;
|
|
5971
|
+
let t2 = await a2.checkPageActionRollout([S2]), n3 = (e2 = t2.find((e3) => e3.actionKey === S2)) == null ? t2[0] : e2;
|
|
5972
|
+
if (!n3) {
|
|
5973
|
+
g2(true), v2(`open`);
|
|
5974
|
+
return;
|
|
5975
|
+
}
|
|
5976
|
+
g2(n3.allowed), v2(n3.reason);
|
|
5977
|
+
} catch (e3) {
|
|
5978
|
+
g2(true), v2(null);
|
|
5979
|
+
}
|
|
5980
|
+
}, [S2, l2, a2, o2]);
|
|
5981
|
+
(0, t.useEffect)(() => {
|
|
5982
|
+
C2();
|
|
5983
|
+
}, [C2]);
|
|
5984
|
+
let w2 = (0, t.useCallback)(() => {
|
|
5985
|
+
let e2 = buildPageActionRowsMap(a2.getPageActionRowsForActionKey(S2));
|
|
5986
|
+
m2((t2) => pageActionRowsShallowEqual(t2, e2) ? t2 : e2);
|
|
5987
|
+
}, [S2, a2]);
|
|
5934
5988
|
(0, t.useEffect)(() => {
|
|
5935
|
-
|
|
5989
|
+
w2();
|
|
5936
5990
|
let e2 = a2.on(`pageActionRowChanged`, (e3) => {
|
|
5937
|
-
e3.state.actionKey ===
|
|
5991
|
+
e3.state.actionKey === S2 && m2((t3) => {
|
|
5938
5992
|
let n4 = t3[e3.rowKey];
|
|
5939
5993
|
return n4 && n4.updatedAt === e3.state.updatedAt && n4.phase === e3.state.phase && n4.message === e3.state.message && n4.progressLabel === e3.state.progressLabel && n4.error === e3.state.error && n4.loading === e3.state.loading && n4.disabled === e3.state.disabled && n4.narrativeItems === e3.state.narrativeItems ? t3 : { ...t3, [e3.rowKey]: e3.state };
|
|
5940
5994
|
});
|
|
5941
|
-
}), t2 = a2.on(`automationTaskCenterChanged`,
|
|
5995
|
+
}), t2 = a2.on(`automationTaskCenterChanged`, w2), n3 = a2.on(`approvalExecutionCompleted`, w2), r3 = a2.on(`approvalInboxChanged`, w2);
|
|
5942
5996
|
return () => {
|
|
5943
5997
|
e2(), t2(), n3(), r3();
|
|
5944
5998
|
};
|
|
5945
|
-
}, [
|
|
5946
|
-
o2 ||
|
|
5999
|
+
}, [S2, a2, w2]), (0, t.useEffect)(() => {
|
|
6000
|
+
o2 || m2({});
|
|
5947
6001
|
}, [o2]), (0, t.useEffect)(() => {
|
|
5948
|
-
!
|
|
6002
|
+
!u2 || !o2 || !S2 || a2.reconcileActivePageActions({ actionKey: S2 }).then(w2).catch(() => {
|
|
5949
6003
|
});
|
|
5950
|
-
}, [
|
|
5951
|
-
if (!(!c2 || !
|
|
5952
|
-
}, [
|
|
5953
|
-
let
|
|
6004
|
+
}, [S2, a2, o2, u2, w2]), (0, t.useEffect)(() => {
|
|
6005
|
+
if (!(!c2 || !S2)) return a2.bindPageActionSlot({ actionKey: S2, rowKey: `*`, pageContext: n2.page ? { page: n2.page } : null, ready: true, autoResume: true, autoApplyPending: false });
|
|
6006
|
+
}, [S2, c2, a2, n2.page]);
|
|
6007
|
+
let T2 = (0, t.useCallback)((e2) => {
|
|
5954
6008
|
var t2, n3;
|
|
5955
6009
|
let r3 = e2.trim();
|
|
5956
|
-
return r3 ? (t2 = (n3 =
|
|
5957
|
-
}, [
|
|
5958
|
-
let e2 = await a2.reconcileActivePageActions({ actionKey:
|
|
5959
|
-
return
|
|
5960
|
-
}, [
|
|
6010
|
+
return r3 ? (t2 = (n3 = p2[r3]) == null ? a2.getPageActionRowState(r3) : n3) == null ? createIdlePageActionRowState(r3, S2) : t2 : createIdlePageActionRowState(``, S2);
|
|
6011
|
+
}, [S2, a2, p2]), E2 = (0, t.useCallback)(async () => {
|
|
6012
|
+
let e2 = await a2.reconcileActivePageActions({ actionKey: S2 });
|
|
6013
|
+
return w2(), e2;
|
|
6014
|
+
}, [S2, a2, w2]), D2 = (0, t.useCallback)((e2) => {
|
|
5961
6015
|
a2.openAutomationTaskCenter(e2);
|
|
5962
|
-
}, [a2]),
|
|
6016
|
+
}, [a2]), O2 = (0, t.useCallback)((e2) => {
|
|
5963
6017
|
a2.clearPageActionRowError(e2);
|
|
5964
6018
|
}, [a2]);
|
|
5965
|
-
return { instruction:
|
|
6019
|
+
return { instruction: d2, setInstruction: f2, rows: p2, getRow: T2, getProcessView: (t2) => e.a(T2(t2)), invoke: (0, t.useCallback)(async (e2) => {
|
|
5966
6020
|
var t2, n3, r3;
|
|
5967
6021
|
let i3 = e2.rowKey.trim();
|
|
5968
6022
|
if (!i3) return;
|
|
5969
|
-
let o3 = ((t2 = e2.instruction) == null ?
|
|
5970
|
-
if (s2 && !o3 || !
|
|
5971
|
-
|
|
5972
|
-
let c3 = (n3 =
|
|
5973
|
-
e2.preferReuse === false && (p3.preferReuse = false), o3 && (p3.instruction = o3), (
|
|
6023
|
+
let o3 = ((t2 = e2.instruction) == null ? d2 : t2).trim();
|
|
6024
|
+
if (s2 && !o3 || !S2 || x2.current === false) return;
|
|
6025
|
+
b2.current += 1;
|
|
6026
|
+
let c3 = (n3 = y2.current.page) == null ? void 0 : n3.trim(), l3 = e2.pageContext ? { ...e2.pageContext, ...c3 && !e2.pageContext.page ? { page: c3 } : {} } : c3 ? { page: c3 } : void 0, u3 = y2.current.context, f3 = e2.context, p3 = { actionKey: S2, rowKey: i3, clientActionId: ((r3 = e2.clientActionId) == null ? void 0 : r3.trim()) || `page-action-${i3}-${b2.current}`, awaitStream: false, launchAnchor: resolveLaunchAnchor(e2.launchAnchor), pageContext: l3 };
|
|
6027
|
+
e2.preferReuse === false && (p3.preferReuse = false), o3 && (p3.instruction = o3), (u3 || f3) && (p3.context = { ...u3, ...f3 }), e2.signal && (p3.signal = e2.signal), e2.onChunk && (p3.onChunk = e2.onChunk);
|
|
5974
6028
|
try {
|
|
5975
6029
|
let e3 = await a2.invokePageAction(p3);
|
|
5976
|
-
return
|
|
6030
|
+
return w2(), e3;
|
|
5977
6031
|
} catch (e3) {
|
|
5978
|
-
throw
|
|
6032
|
+
throw w2(), e3;
|
|
5979
6033
|
}
|
|
5980
|
-
}, [
|
|
6034
|
+
}, [S2, a2, d2, s2, w2]), reconcile: E2, openTaskCenter: D2, clearRowError: O2, rolloutAllowed: h2, rolloutReason: _2, visible: h2 !== false, refreshRollout: C2 };
|
|
5981
6035
|
}
|
|
5982
6036
|
function defaultRowKey(e2) {
|
|
5983
6037
|
var t2;
|
|
@@ -5988,7 +6042,7 @@ function usePageAction(n2) {
|
|
|
5988
6042
|
var r2;
|
|
5989
6043
|
let i2 = useAgentChatClient(), a2 = n2.ready !== false, o2 = n2.autoResume !== false, s2 = n2.autoApplyPending !== false, c2 = n2.actionKey.trim(), l2 = defaultRowKey(n2.pageContext), u2 = pageActionSlotKey({ actionKey: c2, rowKey: l2 }), d2 = (0, t.useRef)(n2);
|
|
5990
6044
|
d2.current = n2;
|
|
5991
|
-
let f2 = usePageActions({ actionKey: n2.actionKey, page: (r2 = n2.pageContext) == null ? void 0 : r2.page, defaultInstruction: n2.defaultInstruction, context: n2.context, requireInstruction: n2.requireInstruction, reconcileOnMount: false }), p2 = f2.getRow(l2), [m2, h2] = (0, t.useState)(null), [g2, _2] = (0, t.useState)(`idle`);
|
|
6045
|
+
let f2 = usePageActions({ actionKey: n2.actionKey, page: (r2 = n2.pageContext) == null ? void 0 : r2.page, defaultInstruction: n2.defaultInstruction, context: n2.context, requireInstruction: n2.requireInstruction, reconcileOnMount: false, checkRollout: n2.checkRollout }), p2 = f2.getRow(l2), [m2, h2] = (0, t.useState)(null), [g2, _2] = (0, t.useState)(`idle`);
|
|
5992
6046
|
return (0, t.useEffect)(() => {
|
|
5993
6047
|
let syncPending = () => {
|
|
5994
6048
|
let e2 = i2.getPendingPageActionApply(), t2 = matchesPendingPageActionApply(e2, { actionKey: c2, pageContext: d2.current.pageContext });
|
|
@@ -6006,7 +6060,7 @@ function usePageAction(n2) {
|
|
|
6006
6060
|
var t2, r3, i3;
|
|
6007
6061
|
let a3 = (e2 == null || (t2 = e2.rowKey) == null ? void 0 : t2.trim()) || l2, o3 = (r3 = (i3 = e2 == null ? void 0 : e2.pageContext) == null ? n2.pageContext : i3) == null ? void 0 : r3, s3 = { rowKey: a3, instruction: e2 == null ? void 0 : e2.instruction, context: e2 == null ? void 0 : e2.context, clientActionId: e2 == null ? void 0 : e2.clientActionId, pageContext: o3 == null ? void 0 : o3, signal: e2 == null ? void 0 : e2.signal, onChunk: e2 == null ? void 0 : e2.onChunk, launchAnchor: e2 == null ? void 0 : e2.launchAnchor, preferReuse: e2 == null ? void 0 : e2.preferReuse };
|
|
6008
6062
|
return f2.invoke(s3);
|
|
6009
|
-
}, openTaskCenter: () => f2.openTaskCenter(p2.runId == null ? void 0 : { runId: p2.runId }), loading: p2.loading, awaitingApproval: p2.awaitingApproval, disabled: p2.disabled, error: p2.error, message: p2.message, progressLabel: p2.progressLabel, narrativeItems: p2.narrativeItems, process: e.a(p2), clearError: () => f2.clearRowError(l2), pendingApply: m2 != null, pendingApplyIntent: m2, applyPhase: g2 };
|
|
6063
|
+
}, openTaskCenter: () => f2.openTaskCenter(p2.runId == null ? void 0 : { runId: p2.runId }), loading: p2.loading, awaitingApproval: p2.awaitingApproval, disabled: p2.disabled || f2.rolloutAllowed === false, rolloutAllowed: f2.rolloutAllowed, rolloutReason: f2.rolloutReason, visible: f2.visible, refreshRollout: f2.refreshRollout, error: p2.error, message: p2.message, progressLabel: p2.progressLabel, narrativeItems: p2.narrativeItems, process: e.a(p2), clearError: () => f2.clearRowError(l2), pendingApply: m2 != null, pendingApplyIntent: m2, applyPhase: g2 };
|
|
6010
6064
|
}
|
|
6011
6065
|
function readExtensionApi() {
|
|
6012
6066
|
if (typeof window > `u`) return null;
|
package/dist/react.legacy.cjs.js
CHANGED
|
@@ -2328,7 +2328,23 @@ function parseCatalogItem(e2) {
|
|
|
2328
2328
|
var t2, n2, r2;
|
|
2329
2329
|
if (!isRecord$4(e2)) return null;
|
|
2330
2330
|
let i2 = readString$2(e2.actionKey), a2 = readString$2(e2.name), o2 = readNumber$1(e2.pageActionId);
|
|
2331
|
-
return !i2 || !a2 || o2 == null ? null : { pageActionId: o2, actionKey: i2, name: a2, description: e2.description === null || (t2 = readString$2(e2.description)) == null ? null : t2, pageScope: e2.pageScope === null || (n2 = readString$2(e2.pageScope)) == null ? null : n2, sortOrder: (r2 = readNumber$1(e2.sortOrder)) == null ? 0 : r2, myFeedback: parseCatalogMyFeedback(e2.myFeedback) };
|
|
2331
|
+
return !i2 || !a2 || o2 == null ? null : { pageActionId: o2, actionKey: i2, name: a2, description: e2.description === null || (t2 = readString$2(e2.description)) == null ? null : t2, pageScope: e2.pageScope === null || (n2 = readString$2(e2.pageScope)) == null ? null : n2, sortOrder: (r2 = readNumber$1(e2.sortOrder)) == null ? 0 : r2, rolloutRestricted: e2.rolloutRestricted === true, myFeedback: parseCatalogMyFeedback(e2.myFeedback) };
|
|
2332
|
+
}
|
|
2333
|
+
function parseRolloutCheckItem(e2) {
|
|
2334
|
+
var t2;
|
|
2335
|
+
if (!isRecord$4(e2)) return null;
|
|
2336
|
+
let n2 = readString$2(e2.actionKey);
|
|
2337
|
+
if (!n2 || typeof e2.allowed != `boolean`) return null;
|
|
2338
|
+
let r2 = (t2 = readString$2(e2.reason)) == null ? e2.allowed ? `open` : `denied` : t2;
|
|
2339
|
+
return { actionKey: n2, allowed: e2.allowed, reason: r2 };
|
|
2340
|
+
}
|
|
2341
|
+
function parsePageActionRolloutCheck(e2) {
|
|
2342
|
+
let t2 = parseApiEnvelope(e2), n2 = Array.isArray(t2) ? t2 : isRecord$4(t2) && Array.isArray(t2.items) ? t2.items : [], r2 = /* @__PURE__ */ new Set(), i2 = [];
|
|
2343
|
+
for (let e3 of n2) {
|
|
2344
|
+
let t3 = parseRolloutCheckItem(e3);
|
|
2345
|
+
!t3 || r2.has(t3.actionKey) || (r2.add(t3.actionKey), i2.push(t3));
|
|
2346
|
+
}
|
|
2347
|
+
return i2;
|
|
2332
2348
|
}
|
|
2333
2349
|
function parseFeedbackView(e2) {
|
|
2334
2350
|
var t2;
|
|
@@ -2441,6 +2457,10 @@ var PageActionService = class {
|
|
|
2441
2457
|
let r2 = (n2 = e2.pageScope) == null ? void 0 : n2.trim();
|
|
2442
2458
|
return parsePageActionFeedbackCatalog(await this.http.request(`/page-action/catalog`, { method: `GET`, signal: t2, searchParams: r2 ? { pageScope: r2 } : void 0 }));
|
|
2443
2459
|
}
|
|
2460
|
+
async checkRollout(e2, t2) {
|
|
2461
|
+
let n2 = Array.from(new Set(e2.map((e3) => e3.trim()).filter((e3) => e3.length > 0)));
|
|
2462
|
+
return n2.length === 0 ? [] : parsePageActionRolloutCheck(await this.http.request(`/page-action/rollout-check`, { method: `POST`, signal: t2, body: { actionKeys: n2 } }));
|
|
2463
|
+
}
|
|
2444
2464
|
async upsertFeedback(e2, t2, n2) {
|
|
2445
2465
|
let i2 = parsePageActionFeedbackView(await this.http.request(`/page-action/feedback/${encodeActionKeyPath(e2)}`, { method: `PUT`, signal: n2, body: t2 }));
|
|
2446
2466
|
if (!i2) throw new r(`TRANSPORT_FAILED`, `Invalid feedback response`);
|
|
@@ -3097,7 +3117,7 @@ var PageActionCoordinator = class {
|
|
|
3097
3117
|
}
|
|
3098
3118
|
return t2.autoResume && await this.runLiveRestore(t2.actionKey), { applyPhase: this.getApplyPhase(e2) };
|
|
3099
3119
|
}
|
|
3100
|
-
}, Z = `
|
|
3120
|
+
}, Z = `3.0.2`;
|
|
3101
3121
|
function nanoId(e2 = `id`) {
|
|
3102
3122
|
let t2 = globalThis.crypto;
|
|
3103
3123
|
return t2 != null && t2.randomUUID ? `${e2}_${t2.randomUUID().replace(/-/g, ``).slice(0, 12)}` : `${e2}_${Math.random().toString(36).slice(2, 14)}`;
|
|
@@ -3311,6 +3331,9 @@ var AgentChatClient = class {
|
|
|
3311
3331
|
listPageActionFeedbackCatalog() {
|
|
3312
3332
|
return this.pageActionFeedbackCatalogItems.slice();
|
|
3313
3333
|
}
|
|
3334
|
+
async checkPageActionRollout(e2, t2) {
|
|
3335
|
+
return await this.ensureInitialized(`checkPageActionRollout`, { signal: t2 == null ? void 0 : t2.signal }), await this.ensureLoggedIn(`checkPageActionRollout`, { signal: t2 == null ? void 0 : t2.signal }), this.requireState(`checkPageActionRollout`).pageAction.checkRollout(e2, t2 == null ? void 0 : t2.signal);
|
|
3336
|
+
}
|
|
3314
3337
|
async getPageActionFeedback(e2, t2) {
|
|
3315
3338
|
return await this.ensureInitialized(`getPageActionFeedback`, { signal: t2 == null ? void 0 : t2.signal }), await this.ensureLoggedIn(`getPageActionFeedback`, { signal: t2 == null ? void 0 : t2.signal }), this.requireState(`getPageActionFeedback`).pageAction.getMyFeedback(e2, t2 == null ? void 0 : t2.signal);
|
|
3316
3339
|
}
|
|
@@ -3556,12 +3579,13 @@ var AgentChatClient = class {
|
|
|
3556
3579
|
}
|
|
3557
3580
|
return await this.invokePageActionStream(n2, t2, i2);
|
|
3558
3581
|
} catch (e2) {
|
|
3559
|
-
|
|
3582
|
+
let n3 = remapPageActionRolloutDenied(e2);
|
|
3583
|
+
if (i2 && !(n3 instanceof r && n3.code === `PAGE_ACTION_ALREADY_ACTIVE`)) {
|
|
3560
3584
|
var w2, T2, E2, D2, O2, k2;
|
|
3561
|
-
let
|
|
3562
|
-
this.upsertPageActionRow(buildPageActionRowState({ rowKey: i2, actionKey: t2.actionKey.trim(), runId: (w2 = (T2 = this.pageActionRows.get(i2)) == null ? void 0 : T2.runId) == null ? null : w2, pageActionKey: (E2 = (D2 = this.pageActionRows.get(i2)) == null ? void 0 : D2.pageActionKey) == null ? null : E2, phase: `failed`, error:
|
|
3585
|
+
let e3 = n3 instanceof Error ? n3.message : String(n3);
|
|
3586
|
+
this.upsertPageActionRow(buildPageActionRowState({ rowKey: i2, actionKey: t2.actionKey.trim(), runId: (w2 = (T2 = this.pageActionRows.get(i2)) == null ? void 0 : T2.runId) == null ? null : w2, pageActionKey: (E2 = (D2 = this.pageActionRows.get(i2)) == null ? void 0 : D2.pageActionKey) == null ? null : E2, phase: `failed`, error: e3, message: null, progressLabel: null, approvalRequestId: (O2 = (k2 = this.pageActionRows.get(i2)) == null ? void 0 : k2.approvalRequestId) == null ? null : O2 })), this.schedulePageActionRowIdleReset(i2, 1600);
|
|
3563
3587
|
}
|
|
3564
|
-
throw
|
|
3588
|
+
throw n3;
|
|
3565
3589
|
} finally {
|
|
3566
3590
|
this.releasePageActionLock(a2);
|
|
3567
3591
|
}
|
|
@@ -5658,6 +5682,10 @@ function readWriteGateServerCode(e2) {
|
|
|
5658
5682
|
if (typeof t2.code == `string`) return t2.code;
|
|
5659
5683
|
}
|
|
5660
5684
|
}
|
|
5685
|
+
function remapPageActionRolloutDenied(e2) {
|
|
5686
|
+
var t2;
|
|
5687
|
+
return !(e2 instanceof r) || e2.code !== `TRANSPORT_FAILED` || ((t2 = e2.details) == null ? void 0 : t2.serverCode) !== `PAGE_ACTION_ROLLOUT_DENIED` ? e2 : new r(`PAGE_ACTION_ROLLOUT_DENIED`, e2.message || `PageAction not available for this user`, { cause: e2, details: e2.details });
|
|
5688
|
+
}
|
|
5661
5689
|
function createAgentChat() {
|
|
5662
5690
|
return new AgentChatClient();
|
|
5663
5691
|
}
|
|
@@ -5925,59 +5953,85 @@ function resolveLaunchAnchor(e2) {
|
|
|
5925
5953
|
}
|
|
5926
5954
|
function usePageActions(n2) {
|
|
5927
5955
|
var r2, i2;
|
|
5928
|
-
let a2 = useAgentChatClient(), o2 = useAgentChatStore((e2) => e2.isLoggedIn), s2 = n2.requireInstruction !== false, c2 = n2.autoResume === true, l2 = (r2 = n2.reconcileOnMount) == null ? !c2 : r2, [
|
|
5929
|
-
|
|
5930
|
-
let
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5956
|
+
let a2 = useAgentChatClient(), o2 = useAgentChatStore((e2) => e2.isLoggedIn), s2 = n2.requireInstruction !== false, c2 = n2.autoResume === true, l2 = n2.checkRollout !== false, u2 = (r2 = n2.reconcileOnMount) == null ? !c2 : r2, [d2, f2] = (0, t.useState)((i2 = n2.defaultInstruction) == null ? `` : i2), [p2, m2] = (0, t.useState)({}), [h2, g2] = (0, t.useState)(!l2 || null), [_2, v2] = (0, t.useState)(l2 ? null : `open`), y2 = (0, t.useRef)(n2);
|
|
5957
|
+
y2.current = n2;
|
|
5958
|
+
let b2 = (0, t.useRef)(0), x2 = (0, t.useRef)(h2);
|
|
5959
|
+
x2.current = h2;
|
|
5960
|
+
let S2 = n2.actionKey.trim(), C2 = (0, t.useCallback)(async () => {
|
|
5961
|
+
if (!l2 || !S2) {
|
|
5962
|
+
g2(true), v2(`open`);
|
|
5963
|
+
return;
|
|
5964
|
+
}
|
|
5965
|
+
if (!o2) {
|
|
5966
|
+
g2(null), v2(null);
|
|
5967
|
+
return;
|
|
5968
|
+
}
|
|
5969
|
+
try {
|
|
5970
|
+
var e2;
|
|
5971
|
+
let t2 = await a2.checkPageActionRollout([S2]), n3 = (e2 = t2.find((e3) => e3.actionKey === S2)) == null ? t2[0] : e2;
|
|
5972
|
+
if (!n3) {
|
|
5973
|
+
g2(true), v2(`open`);
|
|
5974
|
+
return;
|
|
5975
|
+
}
|
|
5976
|
+
g2(n3.allowed), v2(n3.reason);
|
|
5977
|
+
} catch (e3) {
|
|
5978
|
+
g2(true), v2(null);
|
|
5979
|
+
}
|
|
5980
|
+
}, [S2, l2, a2, o2]);
|
|
5981
|
+
(0, t.useEffect)(() => {
|
|
5982
|
+
C2();
|
|
5983
|
+
}, [C2]);
|
|
5984
|
+
let w2 = (0, t.useCallback)(() => {
|
|
5985
|
+
let e2 = buildPageActionRowsMap(a2.getPageActionRowsForActionKey(S2));
|
|
5986
|
+
m2((t2) => pageActionRowsShallowEqual(t2, e2) ? t2 : e2);
|
|
5987
|
+
}, [S2, a2]);
|
|
5934
5988
|
(0, t.useEffect)(() => {
|
|
5935
|
-
|
|
5989
|
+
w2();
|
|
5936
5990
|
let e2 = a2.on(`pageActionRowChanged`, (e3) => {
|
|
5937
|
-
e3.state.actionKey ===
|
|
5991
|
+
e3.state.actionKey === S2 && m2((t3) => {
|
|
5938
5992
|
let n4 = t3[e3.rowKey];
|
|
5939
5993
|
return n4 && n4.updatedAt === e3.state.updatedAt && n4.phase === e3.state.phase && n4.message === e3.state.message && n4.progressLabel === e3.state.progressLabel && n4.error === e3.state.error && n4.loading === e3.state.loading && n4.disabled === e3.state.disabled && n4.narrativeItems === e3.state.narrativeItems ? t3 : { ...t3, [e3.rowKey]: e3.state };
|
|
5940
5994
|
});
|
|
5941
|
-
}), t2 = a2.on(`automationTaskCenterChanged`,
|
|
5995
|
+
}), t2 = a2.on(`automationTaskCenterChanged`, w2), n3 = a2.on(`approvalExecutionCompleted`, w2), r3 = a2.on(`approvalInboxChanged`, w2);
|
|
5942
5996
|
return () => {
|
|
5943
5997
|
e2(), t2(), n3(), r3();
|
|
5944
5998
|
};
|
|
5945
|
-
}, [
|
|
5946
|
-
o2 ||
|
|
5999
|
+
}, [S2, a2, w2]), (0, t.useEffect)(() => {
|
|
6000
|
+
o2 || m2({});
|
|
5947
6001
|
}, [o2]), (0, t.useEffect)(() => {
|
|
5948
|
-
!
|
|
6002
|
+
!u2 || !o2 || !S2 || a2.reconcileActivePageActions({ actionKey: S2 }).then(w2).catch(() => {
|
|
5949
6003
|
});
|
|
5950
|
-
}, [
|
|
5951
|
-
if (!(!c2 || !
|
|
5952
|
-
}, [
|
|
5953
|
-
let
|
|
6004
|
+
}, [S2, a2, o2, u2, w2]), (0, t.useEffect)(() => {
|
|
6005
|
+
if (!(!c2 || !S2)) return a2.bindPageActionSlot({ actionKey: S2, rowKey: `*`, pageContext: n2.page ? { page: n2.page } : null, ready: true, autoResume: true, autoApplyPending: false });
|
|
6006
|
+
}, [S2, c2, a2, n2.page]);
|
|
6007
|
+
let T2 = (0, t.useCallback)((e2) => {
|
|
5954
6008
|
var t2, n3;
|
|
5955
6009
|
let r3 = e2.trim();
|
|
5956
|
-
return r3 ? (t2 = (n3 =
|
|
5957
|
-
}, [
|
|
5958
|
-
let e2 = await a2.reconcileActivePageActions({ actionKey:
|
|
5959
|
-
return
|
|
5960
|
-
}, [
|
|
6010
|
+
return r3 ? (t2 = (n3 = p2[r3]) == null ? a2.getPageActionRowState(r3) : n3) == null ? createIdlePageActionRowState(r3, S2) : t2 : createIdlePageActionRowState(``, S2);
|
|
6011
|
+
}, [S2, a2, p2]), E2 = (0, t.useCallback)(async () => {
|
|
6012
|
+
let e2 = await a2.reconcileActivePageActions({ actionKey: S2 });
|
|
6013
|
+
return w2(), e2;
|
|
6014
|
+
}, [S2, a2, w2]), D2 = (0, t.useCallback)((e2) => {
|
|
5961
6015
|
a2.openAutomationTaskCenter(e2);
|
|
5962
|
-
}, [a2]),
|
|
6016
|
+
}, [a2]), O2 = (0, t.useCallback)((e2) => {
|
|
5963
6017
|
a2.clearPageActionRowError(e2);
|
|
5964
6018
|
}, [a2]);
|
|
5965
|
-
return { instruction:
|
|
6019
|
+
return { instruction: d2, setInstruction: f2, rows: p2, getRow: T2, getProcessView: (t2) => e.a(T2(t2)), invoke: (0, t.useCallback)(async (e2) => {
|
|
5966
6020
|
var t2, n3, r3;
|
|
5967
6021
|
let i3 = e2.rowKey.trim();
|
|
5968
6022
|
if (!i3) return;
|
|
5969
|
-
let o3 = ((t2 = e2.instruction) == null ?
|
|
5970
|
-
if (s2 && !o3 || !
|
|
5971
|
-
|
|
5972
|
-
let c3 = (n3 =
|
|
5973
|
-
e2.preferReuse === false && (p3.preferReuse = false), o3 && (p3.instruction = o3), (
|
|
6023
|
+
let o3 = ((t2 = e2.instruction) == null ? d2 : t2).trim();
|
|
6024
|
+
if (s2 && !o3 || !S2 || x2.current === false) return;
|
|
6025
|
+
b2.current += 1;
|
|
6026
|
+
let c3 = (n3 = y2.current.page) == null ? void 0 : n3.trim(), l3 = e2.pageContext ? { ...e2.pageContext, ...c3 && !e2.pageContext.page ? { page: c3 } : {} } : c3 ? { page: c3 } : void 0, u3 = y2.current.context, f3 = e2.context, p3 = { actionKey: S2, rowKey: i3, clientActionId: ((r3 = e2.clientActionId) == null ? void 0 : r3.trim()) || `page-action-${i3}-${b2.current}`, awaitStream: false, launchAnchor: resolveLaunchAnchor(e2.launchAnchor), pageContext: l3 };
|
|
6027
|
+
e2.preferReuse === false && (p3.preferReuse = false), o3 && (p3.instruction = o3), (u3 || f3) && (p3.context = { ...u3, ...f3 }), e2.signal && (p3.signal = e2.signal), e2.onChunk && (p3.onChunk = e2.onChunk);
|
|
5974
6028
|
try {
|
|
5975
6029
|
let e3 = await a2.invokePageAction(p3);
|
|
5976
|
-
return
|
|
6030
|
+
return w2(), e3;
|
|
5977
6031
|
} catch (e3) {
|
|
5978
|
-
throw
|
|
6032
|
+
throw w2(), e3;
|
|
5979
6033
|
}
|
|
5980
|
-
}, [
|
|
6034
|
+
}, [S2, a2, d2, s2, w2]), reconcile: E2, openTaskCenter: D2, clearRowError: O2, rolloutAllowed: h2, rolloutReason: _2, visible: h2 !== false, refreshRollout: C2 };
|
|
5981
6035
|
}
|
|
5982
6036
|
function defaultRowKey(e2) {
|
|
5983
6037
|
var t2;
|
|
@@ -5988,7 +6042,7 @@ function usePageAction(n2) {
|
|
|
5988
6042
|
var r2;
|
|
5989
6043
|
let i2 = useAgentChatClient(), a2 = n2.ready !== false, o2 = n2.autoResume !== false, s2 = n2.autoApplyPending !== false, c2 = n2.actionKey.trim(), l2 = defaultRowKey(n2.pageContext), u2 = pageActionSlotKey({ actionKey: c2, rowKey: l2 }), d2 = (0, t.useRef)(n2);
|
|
5990
6044
|
d2.current = n2;
|
|
5991
|
-
let f2 = usePageActions({ actionKey: n2.actionKey, page: (r2 = n2.pageContext) == null ? void 0 : r2.page, defaultInstruction: n2.defaultInstruction, context: n2.context, requireInstruction: n2.requireInstruction, reconcileOnMount: false }), p2 = f2.getRow(l2), [m2, h2] = (0, t.useState)(null), [g2, _2] = (0, t.useState)(`idle`);
|
|
6045
|
+
let f2 = usePageActions({ actionKey: n2.actionKey, page: (r2 = n2.pageContext) == null ? void 0 : r2.page, defaultInstruction: n2.defaultInstruction, context: n2.context, requireInstruction: n2.requireInstruction, reconcileOnMount: false, checkRollout: n2.checkRollout }), p2 = f2.getRow(l2), [m2, h2] = (0, t.useState)(null), [g2, _2] = (0, t.useState)(`idle`);
|
|
5992
6046
|
return (0, t.useEffect)(() => {
|
|
5993
6047
|
let syncPending = () => {
|
|
5994
6048
|
let e2 = i2.getPendingPageActionApply(), t2 = matchesPendingPageActionApply(e2, { actionKey: c2, pageContext: d2.current.pageContext });
|
|
@@ -6006,7 +6060,7 @@ function usePageAction(n2) {
|
|
|
6006
6060
|
var t2, r3, i3;
|
|
6007
6061
|
let a3 = (e2 == null || (t2 = e2.rowKey) == null ? void 0 : t2.trim()) || l2, o3 = (r3 = (i3 = e2 == null ? void 0 : e2.pageContext) == null ? n2.pageContext : i3) == null ? void 0 : r3, s3 = { rowKey: a3, instruction: e2 == null ? void 0 : e2.instruction, context: e2 == null ? void 0 : e2.context, clientActionId: e2 == null ? void 0 : e2.clientActionId, pageContext: o3 == null ? void 0 : o3, signal: e2 == null ? void 0 : e2.signal, onChunk: e2 == null ? void 0 : e2.onChunk, launchAnchor: e2 == null ? void 0 : e2.launchAnchor, preferReuse: e2 == null ? void 0 : e2.preferReuse };
|
|
6008
6062
|
return f2.invoke(s3);
|
|
6009
|
-
}, openTaskCenter: () => f2.openTaskCenter(p2.runId == null ? void 0 : { runId: p2.runId }), loading: p2.loading, awaitingApproval: p2.awaitingApproval, disabled: p2.disabled, error: p2.error, message: p2.message, progressLabel: p2.progressLabel, narrativeItems: p2.narrativeItems, process: e.a(p2), clearError: () => f2.clearRowError(l2), pendingApply: m2 != null, pendingApplyIntent: m2, applyPhase: g2 };
|
|
6063
|
+
}, openTaskCenter: () => f2.openTaskCenter(p2.runId == null ? void 0 : { runId: p2.runId }), loading: p2.loading, awaitingApproval: p2.awaitingApproval, disabled: p2.disabled || f2.rolloutAllowed === false, rolloutAllowed: f2.rolloutAllowed, rolloutReason: f2.rolloutReason, visible: f2.visible, refreshRollout: f2.refreshRollout, error: p2.error, message: p2.message, progressLabel: p2.progressLabel, narrativeItems: p2.narrativeItems, process: e.a(p2), clearError: () => f2.clearRowError(l2), pendingApply: m2 != null, pendingApplyIntent: m2, applyPhase: g2 };
|
|
6010
6064
|
}
|
|
6011
6065
|
function readExtensionApi() {
|
|
6012
6066
|
if (typeof window > `u`) return null;
|