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.
Files changed (39) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/dist/omnix-chat.es.js +775 -737
  4. package/dist/omnix-chat.es.js.map +1 -1
  5. package/dist/omnix-chat.umd.cjs +15 -15
  6. package/dist/omnix-chat.umd.js +15 -15
  7. package/dist/omnix-chat.umd.js.map +1 -1
  8. package/dist/react-types-4kCc9MAv.cjs.js.map +1 -1
  9. package/dist/react-types-D6g7_-_a.js.map +1 -1
  10. package/dist/react.cjs +173 -122
  11. package/dist/react.cjs.js +173 -122
  12. package/dist/react.cjs.js.map +1 -1
  13. package/dist/react.es.js +518 -441
  14. package/dist/react.es.js.map +1 -1
  15. package/dist/react.legacy-types-B3OBHme4.cjs.js.map +1 -1
  16. package/dist/react.legacy-types-C11EZiOU.js.map +1 -1
  17. package/dist/react.legacy.cjs +93 -39
  18. package/dist/react.legacy.cjs.js +93 -39
  19. package/dist/react.legacy.cjs.js.map +1 -1
  20. package/dist/react.legacy.es.js +142 -62
  21. package/dist/react.legacy.es.js.map +1 -1
  22. package/dist/src/core/client/instance.d.ts +8 -1
  23. package/dist/src/core/client/instance.d.ts.map +1 -1
  24. package/dist/src/core/lib/errors.d.ts +1 -1
  25. package/dist/src/core/lib/errors.d.ts.map +1 -1
  26. package/dist/src/core/page/page-action-feedback-wish-response.d.ts +3 -1
  27. package/dist/src/core/page/page-action-feedback-wish-response.d.ts.map +1 -1
  28. package/dist/src/core/services/page-action.service.d.ts +6 -1
  29. package/dist/src/core/services/page-action.service.d.ts.map +1 -1
  30. package/dist/src/index.d.ts +1 -1
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/react/usePageAction.d.ts +16 -2
  33. package/dist/src/react/usePageAction.d.ts.map +1 -1
  34. package/dist/src/react/usePageActions.d.ts +15 -1
  35. package/dist/src/react/usePageActions.d.ts.map +1 -1
  36. package/dist/src/types.d.ts +23 -0
  37. package/dist/src/types.d.ts.map +1 -1
  38. package/dist/src/utils/sdk-version.d.ts +1 -1
  39. package/package.json +1 -1
@@ -3430,9 +3430,30 @@ function parseCatalogItem(e2) {
3430
3430
  description: e2.description === null || (t2 = readString$2(e2.description)) == null ? null : t2,
3431
3431
  pageScope: e2.pageScope === null || (n2 = readString$2(e2.pageScope)) == null ? null : n2,
3432
3432
  sortOrder: (r2 = readNumber$1(e2.sortOrder)) == null ? 0 : r2,
3433
+ rolloutRestricted: e2.rolloutRestricted === true,
3433
3434
  myFeedback: parseCatalogMyFeedback(e2.myFeedback)
3434
3435
  };
3435
3436
  }
3437
+ function parseRolloutCheckItem(e2) {
3438
+ var t2;
3439
+ if (!isRecord$4(e2)) return null;
3440
+ let n2 = readString$2(e2.actionKey);
3441
+ if (!n2 || typeof e2.allowed != "boolean") return null;
3442
+ let r2 = (t2 = readString$2(e2.reason)) == null ? e2.allowed ? "open" : "denied" : t2;
3443
+ return {
3444
+ actionKey: n2,
3445
+ allowed: e2.allowed,
3446
+ reason: r2
3447
+ };
3448
+ }
3449
+ function parsePageActionRolloutCheck(e2) {
3450
+ let t2 = parseApiEnvelope(e2), n2 = Array.isArray(t2) ? t2 : isRecord$4(t2) && Array.isArray(t2.items) ? t2.items : [], r2 = /* @__PURE__ */ new Set(), i2 = [];
3451
+ for (let e3 of n2) {
3452
+ let t3 = parseRolloutCheckItem(e3);
3453
+ !t3 || r2.has(t3.actionKey) || (r2.add(t3.actionKey), i2.push(t3));
3454
+ }
3455
+ return i2;
3456
+ }
3436
3457
  function parseFeedbackView(e2) {
3437
3458
  var t2;
3438
3459
  if (!isRecord$4(e2)) return null;
@@ -3620,6 +3641,14 @@ var PageActionService = class {
3620
3641
  searchParams: r2 ? { pageScope: r2 } : void 0
3621
3642
  }));
3622
3643
  }
3644
+ async checkRollout(e2, t2) {
3645
+ let n2 = Array.from(new Set(e2.map((e3) => e3.trim()).filter((e3) => e3.length > 0)));
3646
+ return n2.length === 0 ? [] : parsePageActionRolloutCheck(await this.http.request("/page-action/rollout-check", {
3647
+ method: "POST",
3648
+ signal: t2,
3649
+ body: { actionKeys: n2 }
3650
+ }));
3651
+ }
3623
3652
  async upsertFeedback(e2, t2, n2) {
3624
3653
  let r2 = parsePageActionFeedbackView(await this.http.request(`/page-action/feedback/${encodeActionKeyPath(e2)}`, {
3625
3654
  method: "PUT",
@@ -4545,7 +4574,7 @@ var PageActionCoordinator = class {
4545
4574
  }
4546
4575
  return t2.autoResume && await this.runLiveRestore(t2.actionKey), { applyPhase: this.getApplyPhase(e2) };
4547
4576
  }
4548
- }, dt = "2.4.7";
4577
+ }, dt = "3.0.2";
4549
4578
  function nanoId(e2 = "id") {
4550
4579
  let t2 = globalThis.crypto;
4551
4580
  return t2 != null && t2.randomUUID ? `${e2}_${t2.randomUUID().replace(/-/g, "").slice(0, 12)}` : `${e2}_${Math.random().toString(36).slice(2, 14)}`;
@@ -4890,6 +4919,9 @@ var AgentChatClient = class {
4890
4919
  listPageActionFeedbackCatalog() {
4891
4920
  return this.pageActionFeedbackCatalogItems.slice();
4892
4921
  }
4922
+ async checkPageActionRollout(e2, t2) {
4923
+ 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);
4924
+ }
4893
4925
  async getPageActionFeedback(e2, t2) {
4894
4926
  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);
4895
4927
  }
@@ -5241,22 +5273,23 @@ var AgentChatClient = class {
5241
5273
  }
5242
5274
  return await this.invokePageActionStream(t2, e2, n2);
5243
5275
  } catch (t3) {
5244
- if (n2 && !(t3 instanceof z && t3.code === "PAGE_ACTION_ALREADY_ACTIVE")) {
5276
+ let r3 = remapPageActionRolloutDenied(t3);
5277
+ if (n2 && !(r3 instanceof z && r3.code === "PAGE_ACTION_ALREADY_ACTIVE")) {
5245
5278
  var S2, C2, w2, T2, E2, D2;
5246
- let r3 = t3 instanceof Error ? t3.message : String(t3);
5279
+ let t4 = r3 instanceof Error ? r3.message : String(r3);
5247
5280
  this.upsertPageActionRow(buildPageActionRowState({
5248
5281
  rowKey: n2,
5249
5282
  actionKey: e2.actionKey.trim(),
5250
5283
  runId: (S2 = (C2 = this.pageActionRows.get(n2)) == null ? void 0 : C2.runId) == null ? null : S2,
5251
5284
  pageActionKey: (w2 = (T2 = this.pageActionRows.get(n2)) == null ? void 0 : T2.pageActionKey) == null ? null : w2,
5252
5285
  phase: "failed",
5253
- error: r3,
5286
+ error: t4,
5254
5287
  message: null,
5255
5288
  progressLabel: null,
5256
5289
  approvalRequestId: (E2 = (D2 = this.pageActionRows.get(n2)) == null ? void 0 : D2.approvalRequestId) == null ? null : E2
5257
5290
  })), this.schedulePageActionRowIdleReset(n2, 1600);
5258
5291
  }
5259
- throw t3;
5292
+ throw r3;
5260
5293
  } finally {
5261
5294
  this.releasePageActionLock(r2);
5262
5295
  }
@@ -8602,6 +8635,13 @@ function readWriteGateServerCode(e2) {
8602
8635
  if (typeof t2.code == "string") return t2.code;
8603
8636
  }
8604
8637
  }
8638
+ function remapPageActionRolloutDenied(e2) {
8639
+ var t2;
8640
+ return !(e2 instanceof z) || e2.code !== "TRANSPORT_FAILED" || ((t2 = e2.details) == null ? void 0 : t2.serverCode) !== "PAGE_ACTION_ROLLOUT_DENIED" ? e2 : new z("PAGE_ACTION_ROLLOUT_DENIED", e2.message || "PageAction not available for this user", {
8641
+ cause: e2,
8642
+ details: e2.details
8643
+ });
8644
+ }
8605
8645
  function createAgentChat() {
8606
8646
  return new AgentChatClient();
8607
8647
  }
@@ -8985,44 +9025,75 @@ function resolveLaunchAnchor(e2) {
8985
9025
  }
8986
9026
  function usePageActions(e2) {
8987
9027
  var t2, n2;
8988
- let r2 = useAgentChatClient(), i2 = useAgentChatStore((e3) => e3.isLoggedIn), a2 = e2.requireInstruction !== false, o2 = e2.autoResume === true, s2 = (t2 = e2.reconcileOnMount) == null ? !o2 : t2, [c2, l2] = R((n2 = e2.defaultInstruction) == null ? "" : n2), [u2, d2] = R({}), f2 = L(e2);
8989
- f2.current = e2;
8990
- let p2 = L(0), m2 = e2.actionKey.trim(), h2 = F(() => {
8991
- let e3 = buildPageActionRowsMap(r2.getPageActionRowsForActionKey(m2));
8992
- d2((t3) => pageActionRowsShallowEqual(t3, e3) ? t3 : e3);
8993
- }, [m2, r2]);
9028
+ let r2 = useAgentChatClient(), i2 = useAgentChatStore((e3) => e3.isLoggedIn), a2 = e2.requireInstruction !== false, o2 = e2.autoResume === true, s2 = e2.checkRollout !== false, c2 = (t2 = e2.reconcileOnMount) == null ? !o2 : t2, [l2, u2] = R((n2 = e2.defaultInstruction) == null ? "" : n2), [d2, f2] = R({}), [p2, m2] = R(!s2 || null), [h2, g2] = R(s2 ? null : "open"), _2 = L(e2);
9029
+ _2.current = e2;
9030
+ let v2 = L(0), y2 = L(p2);
9031
+ y2.current = p2;
9032
+ let x2 = e2.actionKey.trim(), S2 = F(async () => {
9033
+ if (!s2 || !x2) {
9034
+ m2(true), g2("open");
9035
+ return;
9036
+ }
9037
+ if (!i2) {
9038
+ m2(null), g2(null);
9039
+ return;
9040
+ }
9041
+ try {
9042
+ var e3;
9043
+ let t3 = await r2.checkPageActionRollout([x2]), n3 = (e3 = t3.find((e4) => e4.actionKey === x2)) == null ? t3[0] : e3;
9044
+ if (!n3) {
9045
+ m2(true), g2("open");
9046
+ return;
9047
+ }
9048
+ m2(n3.allowed), g2(n3.reason);
9049
+ } catch (e4) {
9050
+ m2(true), g2(null);
9051
+ }
9052
+ }, [
9053
+ x2,
9054
+ s2,
9055
+ r2,
9056
+ i2
9057
+ ]);
8994
9058
  I(() => {
8995
- h2();
9059
+ S2();
9060
+ }, [S2]);
9061
+ let C2 = F(() => {
9062
+ let e3 = buildPageActionRowsMap(r2.getPageActionRowsForActionKey(x2));
9063
+ f2((t3) => pageActionRowsShallowEqual(t3, e3) ? t3 : e3);
9064
+ }, [x2, r2]);
9065
+ I(() => {
9066
+ C2();
8996
9067
  let e3 = r2.on("pageActionRowChanged", (e4) => {
8997
- e4.state.actionKey === m2 && d2((t4) => {
9068
+ e4.state.actionKey === x2 && f2((t4) => {
8998
9069
  let n4 = t4[e4.rowKey];
8999
9070
  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 ? t4 : {
9000
9071
  ...t4,
9001
9072
  [e4.rowKey]: e4.state
9002
9073
  };
9003
9074
  });
9004
- }), t3 = r2.on("automationTaskCenterChanged", h2), n3 = r2.on("approvalExecutionCompleted", h2), i3 = r2.on("approvalInboxChanged", h2);
9075
+ }), t3 = r2.on("automationTaskCenterChanged", C2), n3 = r2.on("approvalExecutionCompleted", C2), i3 = r2.on("approvalInboxChanged", C2);
9005
9076
  return () => {
9006
9077
  e3(), t3(), n3(), i3();
9007
9078
  };
9008
9079
  }, [
9009
- m2,
9080
+ x2,
9010
9081
  r2,
9011
- h2
9082
+ C2
9012
9083
  ]), I(() => {
9013
- i2 || d2({});
9084
+ i2 || f2({});
9014
9085
  }, [i2]), I(() => {
9015
- !s2 || !i2 || !m2 || r2.reconcileActivePageActions({ actionKey: m2 }).then(h2).catch(() => {
9086
+ !c2 || !i2 || !x2 || r2.reconcileActivePageActions({ actionKey: x2 }).then(C2).catch(() => {
9016
9087
  });
9017
9088
  }, [
9018
- m2,
9089
+ x2,
9019
9090
  r2,
9020
9091
  i2,
9021
- s2,
9022
- h2
9092
+ c2,
9093
+ C2
9023
9094
  ]), I(() => {
9024
- if (!(!o2 || !m2)) return r2.bindPageActionSlot({
9025
- actionKey: m2,
9095
+ if (!(!o2 || !x2)) return r2.bindPageActionSlot({
9096
+ actionKey: x2,
9026
9097
  rowKey: "*",
9027
9098
  pageContext: e2.page ? { page: e2.page } : null,
9028
9099
  ready: true,
@@ -9030,75 +9101,79 @@ function usePageActions(e2) {
9030
9101
  autoApplyPending: false
9031
9102
  });
9032
9103
  }, [
9033
- m2,
9104
+ x2,
9034
9105
  o2,
9035
9106
  r2,
9036
9107
  e2.page
9037
9108
  ]);
9038
- let g2 = F((e3) => {
9109
+ let w2 = F((e3) => {
9039
9110
  var t3, n3;
9040
9111
  let i3 = e3.trim();
9041
- return i3 ? (t3 = (n3 = u2[i3]) == null ? r2.getPageActionRowState(i3) : n3) == null ? createIdlePageActionRowState(i3, m2) : t3 : createIdlePageActionRowState("", m2);
9112
+ return i3 ? (t3 = (n3 = d2[i3]) == null ? r2.getPageActionRowState(i3) : n3) == null ? createIdlePageActionRowState(i3, x2) : t3 : createIdlePageActionRowState("", x2);
9042
9113
  }, [
9043
- m2,
9114
+ x2,
9044
9115
  r2,
9045
- u2
9046
- ]), _2 = F(async () => {
9047
- let e3 = await r2.reconcileActivePageActions({ actionKey: m2 });
9048
- return h2(), e3;
9116
+ d2
9117
+ ]), T2 = F(async () => {
9118
+ let e3 = await r2.reconcileActivePageActions({ actionKey: x2 });
9119
+ return C2(), e3;
9049
9120
  }, [
9050
- m2,
9121
+ x2,
9051
9122
  r2,
9052
- h2
9053
- ]), v2 = F((e3) => {
9123
+ C2
9124
+ ]), E2 = F((e3) => {
9054
9125
  r2.openAutomationTaskCenter(e3);
9055
- }, [r2]), y2 = F((e3) => {
9126
+ }, [r2]), D2 = F((e3) => {
9056
9127
  r2.clearPageActionRowError(e3);
9057
9128
  }, [r2]);
9058
9129
  return {
9059
- instruction: c2,
9060
- setInstruction: l2,
9061
- rows: u2,
9062
- getRow: g2,
9063
- getProcessView: (e3) => b(g2(e3)),
9130
+ instruction: l2,
9131
+ setInstruction: u2,
9132
+ rows: d2,
9133
+ getRow: w2,
9134
+ getProcessView: (e3) => b(w2(e3)),
9064
9135
  invoke: F(async (e3) => {
9065
9136
  var t3, n3, i3;
9066
9137
  let o3 = e3.rowKey.trim();
9067
9138
  if (!o3) return;
9068
- let s3 = ((t3 = e3.instruction) == null ? c2 : t3).trim();
9069
- if (a2 && !s3 || !m2) return;
9070
- p2.current += 1;
9071
- let l3 = (n3 = f2.current.page) == null ? void 0 : n3.trim(), u3 = e3.pageContext ? {
9139
+ let s3 = ((t3 = e3.instruction) == null ? l2 : t3).trim();
9140
+ if (a2 && !s3 || !x2 || y2.current === false) return;
9141
+ v2.current += 1;
9142
+ let c3 = (n3 = _2.current.page) == null ? void 0 : n3.trim(), u3 = e3.pageContext ? {
9072
9143
  ...e3.pageContext,
9073
- ...l3 && !e3.pageContext.page ? { page: l3 } : {}
9074
- } : l3 ? { page: l3 } : void 0, d3 = f2.current.context, g3 = e3.context, _3 = {
9075
- actionKey: m2,
9144
+ ...c3 && !e3.pageContext.page ? { page: c3 } : {}
9145
+ } : c3 ? { page: c3 } : void 0, d3 = _2.current.context, f3 = e3.context, p3 = {
9146
+ actionKey: x2,
9076
9147
  rowKey: o3,
9077
- clientActionId: ((i3 = e3.clientActionId) == null ? void 0 : i3.trim()) || `page-action-${o3}-${p2.current}`,
9148
+ clientActionId: ((i3 = e3.clientActionId) == null ? void 0 : i3.trim()) || `page-action-${o3}-${v2.current}`,
9078
9149
  awaitStream: false,
9079
9150
  launchAnchor: resolveLaunchAnchor(e3.launchAnchor),
9080
9151
  pageContext: u3
9081
9152
  };
9082
- e3.preferReuse === false && (_3.preferReuse = false), s3 && (_3.instruction = s3), (d3 || g3) && (_3.context = {
9153
+ e3.preferReuse === false && (p3.preferReuse = false), s3 && (p3.instruction = s3), (d3 || f3) && (p3.context = {
9083
9154
  ...d3,
9084
- ...g3
9085
- }), e3.signal && (_3.signal = e3.signal), e3.onChunk && (_3.onChunk = e3.onChunk);
9155
+ ...f3
9156
+ }), e3.signal && (p3.signal = e3.signal), e3.onChunk && (p3.onChunk = e3.onChunk);
9086
9157
  try {
9087
- let e4 = await r2.invokePageAction(_3);
9088
- return h2(), e4;
9158
+ let e4 = await r2.invokePageAction(p3);
9159
+ return C2(), e4;
9089
9160
  } catch (e4) {
9090
- throw h2(), e4;
9161
+ throw C2(), e4;
9091
9162
  }
9092
9163
  }, [
9093
- m2,
9164
+ x2,
9094
9165
  r2,
9095
- c2,
9166
+ l2,
9096
9167
  a2,
9097
- h2
9168
+ C2
9098
9169
  ]),
9099
- reconcile: _2,
9100
- openTaskCenter: v2,
9101
- clearRowError: y2
9170
+ reconcile: T2,
9171
+ openTaskCenter: E2,
9172
+ clearRowError: D2,
9173
+ rolloutAllowed: p2,
9174
+ rolloutReason: h2,
9175
+ visible: p2 !== false,
9176
+ refreshRollout: S2
9102
9177
  };
9103
9178
  }
9104
9179
  function defaultRowKey(e2) {
@@ -9119,7 +9194,8 @@ function usePageAction(e2) {
9119
9194
  defaultInstruction: e2.defaultInstruction,
9120
9195
  context: e2.context,
9121
9196
  requireInstruction: e2.requireInstruction,
9122
- reconcileOnMount: false
9197
+ reconcileOnMount: false,
9198
+ checkRollout: e2.checkRollout
9123
9199
  }), d2 = u2.getRow(s2), [f2, p2] = R(null), [m2, h2] = R("idle");
9124
9200
  return I(() => {
9125
9201
  let syncPending = () => {
@@ -9184,7 +9260,11 @@ function usePageAction(e2) {
9184
9260
  openTaskCenter: () => u2.openTaskCenter(d2.runId == null ? void 0 : { runId: d2.runId }),
9185
9261
  loading: d2.loading,
9186
9262
  awaitingApproval: d2.awaitingApproval,
9187
- disabled: d2.disabled,
9263
+ disabled: d2.disabled || u2.rolloutAllowed === false,
9264
+ rolloutAllowed: u2.rolloutAllowed,
9265
+ rolloutReason: u2.rolloutReason,
9266
+ visible: u2.visible,
9267
+ refreshRollout: u2.refreshRollout,
9188
9268
  error: d2.error,
9189
9269
  message: d2.message,
9190
9270
  progressLabel: d2.progressLabel,