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.cjs
CHANGED
|
@@ -1282,15 +1282,15 @@ var HTTPError = class extends Error {
|
|
|
1282
1282
|
throw e3;
|
|
1283
1283
|
}
|
|
1284
1284
|
return e2 && !t2;
|
|
1285
|
-
})(), D = typeof globalThis.AbortController == `function`, O = typeof globalThis.AbortSignal == `function` && typeof globalThis.AbortSignal.any == `function`, k = typeof globalThis.ReadableStream == `function`, A = typeof globalThis.FormData == `function`, j = [`get`, `post`, `put`, `patch`, `head`, `delete`], M = { json: `application/json`, text: `text/*`, formData: `multipart/form-data`, arrayBuffer: `*/*`, blob: `*/*`, bytes: `*/*` }, N = 2147483647,
|
|
1285
|
+
})(), D = typeof globalThis.AbortController == `function`, O = typeof globalThis.AbortSignal == `function` && typeof globalThis.AbortSignal.any == `function`, k = typeof globalThis.ReadableStream == `function`, A = typeof globalThis.FormData == `function`, j = [`get`, `post`, `put`, `patch`, `head`, `delete`], M = { json: `application/json`, text: `text/*`, formData: `multipart/form-data`, arrayBuffer: `*/*`, blob: `*/*`, bytes: `*/*` }, N = 2147483647, P = new TextEncoder().encode(`------WebKitFormBoundaryaxpyiPgbbPti10Rw`).length, F = Symbol(`stop`), RetryMarker = class {
|
|
1286
1286
|
constructor(t2) {
|
|
1287
1287
|
e.Tt(this, `options`, void 0), this.options = t2;
|
|
1288
1288
|
}
|
|
1289
|
-
}, retry = (e2) => new RetryMarker(e2),
|
|
1289
|
+
}, retry = (e2) => new RetryMarker(e2), ee = { json: true, parseJson: true, stringifyJson: true, searchParams: true, prefixUrl: true, retry: true, timeout: true, hooks: true, throwHttpErrors: true, onDownloadProgress: true, onUploadProgress: true, fetch: true, context: true }, te = { next: true }, ne = { method: true, headers: true, body: true, mode: true, credentials: true, cache: true, redirect: true, referrer: true, referrerPolicy: true, integrity: true, keepalive: true, signal: true, window: true, duplex: true }, getBodySize = (e2) => {
|
|
1290
1290
|
if (!e2) return 0;
|
|
1291
1291
|
if (e2 instanceof FormData) {
|
|
1292
1292
|
let t2 = 0;
|
|
1293
|
-
for (let [n2, r2] of e2) t2 +=
|
|
1293
|
+
for (let [n2, r2] of e2) t2 += P, t2 += new TextEncoder().encode(`Content-Disposition: form-data; name="${n2}"`).length, t2 += typeof r2 == `string` ? new TextEncoder().encode(r2).length : r2.size;
|
|
1294
1294
|
return t2;
|
|
1295
1295
|
}
|
|
1296
1296
|
if (e2 instanceof Blob) return e2.size;
|
|
@@ -1375,12 +1375,12 @@ var mergeHooks = (e2 = {}, t2 = {}) => ({ beforeRequest: newHookValue(e2, t2, `b
|
|
|
1375
1375
|
isObject(o2.hooks) && (r2 = mergeHooks(r2, o2.hooks), t2.hooks = r2), isObject(o2.headers) && (n2 = mergeHeaders(n2, o2.headers), t2.headers = n2);
|
|
1376
1376
|
}
|
|
1377
1377
|
return i2 !== void 0 && (t2.searchParams = i2), a2.length > 0 && (a2.length === 1 ? t2.signal = a2[0] : O ? t2.signal = AbortSignal.any(a2) : t2.signal = a2.at(-1)), t2;
|
|
1378
|
-
}, normalizeRequestMethod = (e2) => j.includes(e2) ? e2.toUpperCase() : e2,
|
|
1379
|
-
if (typeof e2 == `number`) return { ...
|
|
1378
|
+
}, normalizeRequestMethod = (e2) => j.includes(e2) ? e2.toUpperCase() : e2, I = { limit: 2, methods: [`get`, `put`, `head`, `delete`, `options`, `trace`], statusCodes: [408, 413, 429, 500, 502, 503, 504], afterStatusCodes: [413, 429, 503], maxRetryAfter: 1 / 0, backoffLimit: 1 / 0, delay: (e2) => 0.3 * 2 ** (e2 - 1) * 1e3, jitter: void 0, retryOnTimeout: false }, normalizeRetryOptions = (e2 = {}) => {
|
|
1379
|
+
if (typeof e2 == `number`) return { ...I, limit: e2 };
|
|
1380
1380
|
if (e2.methods && !Array.isArray(e2.methods)) throw Error(`retry.methods must be an array`);
|
|
1381
1381
|
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`);
|
|
1382
1382
|
let t2 = Object.fromEntries(Object.entries(e2).filter(([, e3]) => e3 !== void 0));
|
|
1383
|
-
return { ...
|
|
1383
|
+
return { ...I, ...t2 };
|
|
1384
1384
|
}, TimeoutError = class extends Error {
|
|
1385
1385
|
constructor(t2) {
|
|
1386
1386
|
super(`Request timed out: ${t2.method} ${t2.url}`), e.Tt(this, `request`, void 0), this.name = `TimeoutError`, this.request = t2;
|
|
@@ -1409,7 +1409,7 @@ async function delay(e2, { signal: t2 }) {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
var findUnknownOptions = (e2, t2) => {
|
|
1411
1411
|
let n2 = {};
|
|
1412
|
-
for (let r2 in t2) Object.hasOwn(t2, r2) && !(r2 in
|
|
1412
|
+
for (let r2 in t2) Object.hasOwn(t2, r2) && !(r2 in ne) && !(r2 in ee) && (!(r2 in e2) || r2 in te) && (n2[r2] = t2[r2]);
|
|
1413
1413
|
return n2;
|
|
1414
1414
|
}, 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;
|
|
1415
1415
|
function isHTTPError(e2) {
|
|
@@ -1437,38 +1437,38 @@ function _classPrivateFieldGet2(e2, t2) {
|
|
|
1437
1437
|
function _classPrivateFieldSet2(e2, t2, n2) {
|
|
1438
1438
|
return e2.set(_assertClassBrand(e2, t2), n2), n2;
|
|
1439
1439
|
}
|
|
1440
|
-
var
|
|
1440
|
+
var L = /* @__PURE__ */ new WeakMap(), R = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakSet(), G = class Ky {
|
|
1441
1441
|
static create(e2, t2) {
|
|
1442
1442
|
let n2 = new Ky(e2, t2), function_ = async () => {
|
|
1443
|
-
if (typeof _classPrivateFieldGet2(
|
|
1443
|
+
if (typeof _classPrivateFieldGet2(B, n2).timeout == `number` && _classPrivateFieldGet2(B, n2).timeout > 2147483647) throw RangeError(`The \`timeout\` option cannot be greater than ${N}`);
|
|
1444
1444
|
await Promise.resolve();
|
|
1445
|
-
let e3 = await _assertClassBrand(
|
|
1446
|
-
for (let t3 of _classPrivateFieldGet2(
|
|
1447
|
-
let r3 = _assertClassBrand(
|
|
1445
|
+
let e3 = await _assertClassBrand(W, n2, _fetch).call(n2);
|
|
1446
|
+
for (let t3 of _classPrivateFieldGet2(B, n2).hooks.afterResponse) {
|
|
1447
|
+
let r3 = _assertClassBrand(W, n2, _decorateResponse).call(n2, e3.clone()), i2;
|
|
1448
1448
|
try {
|
|
1449
|
-
i2 = await t3(n2.request, _assertClassBrand(
|
|
1449
|
+
i2 = await t3(n2.request, _assertClassBrand(W, n2, _getNormalizedOptions).call(n2), r3, { retryCount: _classPrivateFieldGet2(R, n2) });
|
|
1450
1450
|
} catch (t4) {
|
|
1451
|
-
throw _assertClassBrand(
|
|
1451
|
+
throw _assertClassBrand(W, n2, _cancelResponseBody).call(n2, r3), _assertClassBrand(W, n2, _cancelResponseBody).call(n2, e3), t4;
|
|
1452
1452
|
}
|
|
1453
|
-
if (i2 instanceof RetryMarker) throw _assertClassBrand(
|
|
1453
|
+
if (i2 instanceof RetryMarker) throw _assertClassBrand(W, n2, _cancelResponseBody).call(n2, r3), _assertClassBrand(W, n2, _cancelResponseBody).call(n2, e3), new ForceRetryError(i2.options);
|
|
1454
1454
|
let a2 = i2 instanceof globalThis.Response ? i2 : e3;
|
|
1455
|
-
r3 !== a2 && _assertClassBrand(
|
|
1455
|
+
r3 !== a2 && _assertClassBrand(W, n2, _cancelResponseBody).call(n2, r3), e3 !== a2 && _assertClassBrand(W, n2, _cancelResponseBody).call(n2, e3), e3 = a2;
|
|
1456
1456
|
}
|
|
1457
|
-
if (_assertClassBrand(
|
|
1458
|
-
let t3 = new HTTPError(e3, n2.request, _assertClassBrand(
|
|
1459
|
-
for (let e4 of _classPrivateFieldGet2(
|
|
1457
|
+
if (_assertClassBrand(W, n2, _decorateResponse).call(n2, e3), !e3.ok && (typeof _classPrivateFieldGet2(B, n2).throwHttpErrors == `function` ? _classPrivateFieldGet2(B, n2).throwHttpErrors(e3.status) : _classPrivateFieldGet2(B, n2).throwHttpErrors)) {
|
|
1458
|
+
let t3 = new HTTPError(e3, n2.request, _assertClassBrand(W, n2, _getNormalizedOptions).call(n2));
|
|
1459
|
+
for (let e4 of _classPrivateFieldGet2(B, n2).hooks.beforeError) t3 = await e4(t3, { retryCount: _classPrivateFieldGet2(R, n2) });
|
|
1460
1460
|
throw t3;
|
|
1461
1461
|
}
|
|
1462
|
-
if (_classPrivateFieldGet2(
|
|
1463
|
-
if (typeof _classPrivateFieldGet2(
|
|
1462
|
+
if (_classPrivateFieldGet2(B, n2).onDownloadProgress) {
|
|
1463
|
+
if (typeof _classPrivateFieldGet2(B, n2).onDownloadProgress != `function`) throw TypeError("The `onDownloadProgress` option must be a function");
|
|
1464
1464
|
if (!k) throw Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
1465
1465
|
let t3 = e3.clone();
|
|
1466
|
-
return _assertClassBrand(
|
|
1466
|
+
return _assertClassBrand(W, n2, _cancelResponseBody).call(n2, e3), streamResponse(t3, _classPrivateFieldGet2(B, n2).onDownloadProgress);
|
|
1467
1467
|
}
|
|
1468
1468
|
return e3;
|
|
1469
|
-
}, r2 = _assertClassBrand(
|
|
1470
|
-
let e3 = _classPrivateFieldGet2(
|
|
1471
|
-
_assertClassBrand(
|
|
1469
|
+
}, r2 = _assertClassBrand(W, n2, _retry).call(n2, function_).finally(() => {
|
|
1470
|
+
let e3 = _classPrivateFieldGet2(V, n2);
|
|
1471
|
+
_assertClassBrand(W, n2, _cancelBody).call(n2, e3?.body ?? void 0), _assertClassBrand(W, n2, _cancelBody).call(n2, n2.request.body ?? void 0);
|
|
1472
1472
|
});
|
|
1473
1473
|
for (let [e3, i2] of Object.entries(M)) (e3 !== `bytes` || typeof globalThis.Response?.prototype?.bytes == `function`) && (r2[e3] = async () => {
|
|
1474
1474
|
n2.request.headers.set(`accept`, n2.request.headers.get(`accept`) || i2);
|
|
@@ -1483,21 +1483,21 @@ var R = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), B = /*
|
|
|
1483
1483
|
return r2;
|
|
1484
1484
|
}
|
|
1485
1485
|
constructor(t2, n2 = {}) {
|
|
1486
|
-
if (_classPrivateMethodInitSpec(this,
|
|
1487
|
-
if (_classPrivateFieldGet2(
|
|
1488
|
-
if (_classPrivateFieldGet2(
|
|
1489
|
-
_classPrivateFieldGet2(
|
|
1486
|
+
if (_classPrivateMethodInitSpec(this, W), e.Tt(this, `request`, void 0), _classPrivateFieldInitSpec(this, L, void 0), _classPrivateFieldInitSpec(this, R, 0), _classPrivateFieldInitSpec(this, z, void 0), _classPrivateFieldInitSpec(this, B, void 0), _classPrivateFieldInitSpec(this, V, void 0), _classPrivateFieldInitSpec(this, H, void 0), _classPrivateFieldInitSpec(this, U, void 0), _classPrivateFieldSet2(z, this, t2), _classPrivateFieldSet2(B, this, { ...n2, headers: mergeHeaders(_classPrivateFieldGet2(z, this).headers, n2.headers), hooks: mergeHooks({ beforeRequest: [], beforeRetry: [], beforeError: [], afterResponse: [] }, n2.hooks), method: normalizeRequestMethod(n2.method ?? _classPrivateFieldGet2(z, this).method ?? `GET`), prefixUrl: String(n2.prefixUrl || ``), retry: normalizeRetryOptions(n2.retry), throwHttpErrors: n2.throwHttpErrors ?? true, timeout: n2.timeout ?? 1e4, fetch: n2.fetch ?? globalThis.fetch.bind(globalThis), context: n2.context ?? {} }), typeof _classPrivateFieldGet2(z, this) != `string` && !(_classPrivateFieldGet2(z, this) instanceof URL || _classPrivateFieldGet2(z, this) instanceof globalThis.Request)) throw TypeError("`input` must be a string, URL, or Request");
|
|
1487
|
+
if (_classPrivateFieldGet2(B, this).prefixUrl && typeof _classPrivateFieldGet2(z, this) == `string`) {
|
|
1488
|
+
if (_classPrivateFieldGet2(z, this).startsWith(`/`)) throw Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
1489
|
+
_classPrivateFieldGet2(B, this).prefixUrl.endsWith(`/`) || (_classPrivateFieldGet2(B, this).prefixUrl += `/`), _classPrivateFieldSet2(z, this, _classPrivateFieldGet2(B, this).prefixUrl + _classPrivateFieldGet2(z, this));
|
|
1490
1490
|
}
|
|
1491
|
-
D && O && (_classPrivateFieldSet2(
|
|
1491
|
+
D && O && (_classPrivateFieldSet2(H, this, _classPrivateFieldGet2(B, this).signal ?? _classPrivateFieldGet2(z, this).signal), _classPrivateFieldSet2(L, this, new globalThis.AbortController()), _classPrivateFieldGet2(B, this).signal = _classPrivateFieldGet2(H, this) ? AbortSignal.any([_classPrivateFieldGet2(H, this), _classPrivateFieldGet2(L, this).signal]) : _classPrivateFieldGet2(L, this).signal), E && (_classPrivateFieldGet2(B, this).duplex = `half`), _classPrivateFieldGet2(B, this).json !== void 0 && (_classPrivateFieldGet2(B, this).body = _classPrivateFieldGet2(B, this).stringifyJson?.(_classPrivateFieldGet2(B, this).json) ?? JSON.stringify(_classPrivateFieldGet2(B, this).json), _classPrivateFieldGet2(B, this).headers.set(`content-type`, _classPrivateFieldGet2(B, this).headers.get(`content-type`) ?? `application/json`));
|
|
1492
1492
|
let r2 = n2.headers && new globalThis.Headers(n2.headers).has(`content-type`);
|
|
1493
|
-
if (_classPrivateFieldGet2(
|
|
1494
|
-
let e2 = `?` + (typeof _classPrivateFieldGet2(
|
|
1495
|
-
this.request = new globalThis.Request(t3, _classPrivateFieldGet2(
|
|
1493
|
+
if (_classPrivateFieldGet2(z, this) instanceof globalThis.Request && (A && _classPrivateFieldGet2(B, this).body instanceof globalThis.FormData || _classPrivateFieldGet2(B, this).body instanceof URLSearchParams) && !r2 && _classPrivateFieldGet2(B, this).headers.delete(`content-type`), this.request = new globalThis.Request(_classPrivateFieldGet2(z, this), _classPrivateFieldGet2(B, this)), hasSearchParameters(_classPrivateFieldGet2(B, this).searchParams)) {
|
|
1494
|
+
let e2 = `?` + (typeof _classPrivateFieldGet2(B, this).searchParams == `string` ? _classPrivateFieldGet2(B, this).searchParams.replace(/^\?/, ``) : new URLSearchParams(_normalizeSearchParams.call(Ky, _classPrivateFieldGet2(B, this).searchParams)).toString()), t3 = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, e2);
|
|
1495
|
+
this.request = new globalThis.Request(t3, _classPrivateFieldGet2(B, this));
|
|
1496
1496
|
}
|
|
1497
|
-
if (_classPrivateFieldGet2(
|
|
1498
|
-
if (typeof _classPrivateFieldGet2(
|
|
1497
|
+
if (_classPrivateFieldGet2(B, this).onUploadProgress) {
|
|
1498
|
+
if (typeof _classPrivateFieldGet2(B, this).onUploadProgress != `function`) throw TypeError("The `onUploadProgress` option must be a function");
|
|
1499
1499
|
if (!E) throw Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
|
|
1500
|
-
this.request = _assertClassBrand(
|
|
1500
|
+
this.request = _assertClassBrand(W, this, _wrapRequestWithUploadProgress).call(this, this.request, _classPrivateFieldGet2(B, this).body ?? void 0);
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
1503
|
};
|
|
@@ -1505,98 +1505,98 @@ function _normalizeSearchParams(e2) {
|
|
|
1505
1505
|
return e2 && typeof e2 == `object` && !Array.isArray(e2) && !(e2 instanceof URLSearchParams) ? Object.fromEntries(Object.entries(e2).filter(([, e3]) => e3 !== void 0)) : e2;
|
|
1506
1506
|
}
|
|
1507
1507
|
function _calculateDelay() {
|
|
1508
|
-
let e2 = _classPrivateFieldGet2(
|
|
1509
|
-
_classPrivateFieldGet2(
|
|
1510
|
-
let n2 = _classPrivateFieldGet2(
|
|
1508
|
+
let e2 = _classPrivateFieldGet2(B, this).retry.delay(_classPrivateFieldGet2(R, this)), t2 = e2;
|
|
1509
|
+
_classPrivateFieldGet2(B, this).retry.jitter === true ? t2 = Math.random() * e2 : typeof _classPrivateFieldGet2(B, this).retry.jitter == `function` && (t2 = _classPrivateFieldGet2(B, this).retry.jitter(e2), (!Number.isFinite(t2) || t2 < 0) && (t2 = e2));
|
|
1510
|
+
let n2 = _classPrivateFieldGet2(B, this).retry.backoffLimit ?? 1 / 0;
|
|
1511
1511
|
return Math.min(n2, t2);
|
|
1512
1512
|
}
|
|
1513
1513
|
async function _calculateRetryDelay(e2) {
|
|
1514
1514
|
var t2;
|
|
1515
|
-
if (_classPrivateFieldSet2(
|
|
1515
|
+
if (_classPrivateFieldSet2(R, this, (t2 = _classPrivateFieldGet2(R, this), t2++, t2)), _classPrivateFieldGet2(R, this) > _classPrivateFieldGet2(B, this).retry.limit) throw e2;
|
|
1516
1516
|
let n2 = e2 instanceof Error ? e2 : new NonError(e2);
|
|
1517
|
-
if (n2 instanceof ForceRetryError) return n2.customDelay ?? _assertClassBrand(
|
|
1518
|
-
if (!_classPrivateFieldGet2(
|
|
1519
|
-
if (_classPrivateFieldGet2(
|
|
1520
|
-
let t3 = await _classPrivateFieldGet2(
|
|
1517
|
+
if (n2 instanceof ForceRetryError) return n2.customDelay ?? _assertClassBrand(W, this, _calculateDelay).call(this);
|
|
1518
|
+
if (!_classPrivateFieldGet2(B, this).retry.methods.includes(this.request.method.toLowerCase())) throw e2;
|
|
1519
|
+
if (_classPrivateFieldGet2(B, this).retry.shouldRetry !== void 0) {
|
|
1520
|
+
let t3 = await _classPrivateFieldGet2(B, this).retry.shouldRetry({ error: n2, retryCount: _classPrivateFieldGet2(R, this) });
|
|
1521
1521
|
if (t3 === false) throw e2;
|
|
1522
|
-
if (t3 === true) return _assertClassBrand(
|
|
1522
|
+
if (t3 === true) return _assertClassBrand(W, this, _calculateDelay).call(this);
|
|
1523
1523
|
}
|
|
1524
|
-
if (isTimeoutError(e2) && !_classPrivateFieldGet2(
|
|
1524
|
+
if (isTimeoutError(e2) && !_classPrivateFieldGet2(B, this).retry.retryOnTimeout) throw e2;
|
|
1525
1525
|
if (isHTTPError(e2)) {
|
|
1526
|
-
if (!_classPrivateFieldGet2(
|
|
1526
|
+
if (!_classPrivateFieldGet2(B, this).retry.statusCodes.includes(e2.response.status)) throw e2;
|
|
1527
1527
|
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`);
|
|
1528
|
-
if (t3 && _classPrivateFieldGet2(
|
|
1528
|
+
if (t3 && _classPrivateFieldGet2(B, this).retry.afterStatusCodes.includes(e2.response.status)) {
|
|
1529
1529
|
let e3 = Number(t3) * 1e3;
|
|
1530
1530
|
Number.isNaN(e3) ? e3 = Date.parse(t3) - Date.now() : e3 >= Date.parse(`2024-01-01`) && (e3 -= Date.now());
|
|
1531
|
-
let n3 = _classPrivateFieldGet2(
|
|
1531
|
+
let n3 = _classPrivateFieldGet2(B, this).retry.maxRetryAfter ?? e3;
|
|
1532
1532
|
return e3 < n3 ? e3 : n3;
|
|
1533
1533
|
}
|
|
1534
1534
|
if (e2.response.status === 413) throw e2;
|
|
1535
1535
|
}
|
|
1536
|
-
return _assertClassBrand(
|
|
1536
|
+
return _assertClassBrand(W, this, _calculateDelay).call(this);
|
|
1537
1537
|
}
|
|
1538
1538
|
function _decorateResponse(e2) {
|
|
1539
|
-
return _classPrivateFieldGet2(
|
|
1539
|
+
return _classPrivateFieldGet2(B, this).parseJson && (e2.json = async () => _classPrivateFieldGet2(B, this).parseJson(await e2.text())), e2;
|
|
1540
1540
|
}
|
|
1541
1541
|
function _cancelBody(e2) {
|
|
1542
1542
|
e2 && e2.cancel().catch(() => void 0);
|
|
1543
1543
|
}
|
|
1544
1544
|
function _cancelResponseBody(e2) {
|
|
1545
|
-
_assertClassBrand(
|
|
1545
|
+
_assertClassBrand(W, this, _cancelBody).call(this, e2.body ?? void 0);
|
|
1546
1546
|
}
|
|
1547
1547
|
async function _retry(e2) {
|
|
1548
1548
|
try {
|
|
1549
1549
|
return await e2();
|
|
1550
1550
|
} catch (t2) {
|
|
1551
|
-
let n2 = Math.min(await _assertClassBrand(
|
|
1552
|
-
if (_classPrivateFieldGet2(
|
|
1553
|
-
if (await delay(n2, _classPrivateFieldGet2(
|
|
1554
|
-
let e3 = _classPrivateFieldGet2(
|
|
1555
|
-
_assertClassBrand(
|
|
1556
|
-
}
|
|
1557
|
-
for (let e3 of _classPrivateFieldGet2(
|
|
1558
|
-
let n3 = await e3({ request: this.request, options: _assertClassBrand(
|
|
1551
|
+
let n2 = Math.min(await _assertClassBrand(W, this, _calculateRetryDelay).call(this, t2), N);
|
|
1552
|
+
if (_classPrivateFieldGet2(R, this) < 1) throw t2;
|
|
1553
|
+
if (await delay(n2, _classPrivateFieldGet2(H, this) ? { signal: _classPrivateFieldGet2(H, this) } : {}), t2 instanceof ForceRetryError && t2.customRequest) {
|
|
1554
|
+
let e3 = _classPrivateFieldGet2(B, this).signal ? new globalThis.Request(t2.customRequest, { signal: _classPrivateFieldGet2(B, this).signal }) : new globalThis.Request(t2.customRequest);
|
|
1555
|
+
_assertClassBrand(W, this, _assignRequest).call(this, e3);
|
|
1556
|
+
}
|
|
1557
|
+
for (let e3 of _classPrivateFieldGet2(B, this).hooks.beforeRetry) {
|
|
1558
|
+
let n3 = await e3({ request: this.request, options: _assertClassBrand(W, this, _getNormalizedOptions).call(this), error: t2, retryCount: _classPrivateFieldGet2(R, this) });
|
|
1559
1559
|
if (n3 instanceof globalThis.Request) {
|
|
1560
|
-
_assertClassBrand(
|
|
1560
|
+
_assertClassBrand(W, this, _assignRequest).call(this, n3);
|
|
1561
1561
|
break;
|
|
1562
1562
|
}
|
|
1563
1563
|
if (n3 instanceof globalThis.Response) return n3;
|
|
1564
|
-
if (n3 ===
|
|
1564
|
+
if (n3 === F) return;
|
|
1565
1565
|
}
|
|
1566
|
-
return _assertClassBrand(
|
|
1566
|
+
return _assertClassBrand(W, this, _retry).call(this, e2);
|
|
1567
1567
|
}
|
|
1568
1568
|
}
|
|
1569
1569
|
async function _fetch() {
|
|
1570
|
-
_classPrivateFieldGet2(
|
|
1571
|
-
for (let e3 of _classPrivateFieldGet2(
|
|
1572
|
-
let t2 = await e3(this.request, _assertClassBrand(
|
|
1570
|
+
_classPrivateFieldGet2(L, this)?.signal.aborted && (_classPrivateFieldSet2(L, this, new globalThis.AbortController()), _classPrivateFieldGet2(B, this).signal = _classPrivateFieldGet2(H, this) ? AbortSignal.any([_classPrivateFieldGet2(H, this), _classPrivateFieldGet2(L, this).signal]) : _classPrivateFieldGet2(L, this).signal, this.request = new globalThis.Request(this.request, { signal: _classPrivateFieldGet2(B, this).signal }));
|
|
1571
|
+
for (let e3 of _classPrivateFieldGet2(B, this).hooks.beforeRequest) {
|
|
1572
|
+
let t2 = await e3(this.request, _assertClassBrand(W, this, _getNormalizedOptions).call(this), { retryCount: _classPrivateFieldGet2(R, this) });
|
|
1573
1573
|
if (t2 instanceof Response) return t2;
|
|
1574
1574
|
if (t2 instanceof globalThis.Request) {
|
|
1575
|
-
_assertClassBrand(
|
|
1575
|
+
_assertClassBrand(W, this, _assignRequest).call(this, t2);
|
|
1576
1576
|
break;
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
|
-
let e2 = findUnknownOptions(this.request, _classPrivateFieldGet2(
|
|
1580
|
-
return _classPrivateFieldSet2(
|
|
1579
|
+
let e2 = findUnknownOptions(this.request, _classPrivateFieldGet2(B, this));
|
|
1580
|
+
return _classPrivateFieldSet2(V, this, this.request), this.request = _classPrivateFieldGet2(V, this).clone(), _classPrivateFieldGet2(B, this).timeout === false ? _classPrivateFieldGet2(B, this).fetch(_classPrivateFieldGet2(V, this), e2) : timeout(_classPrivateFieldGet2(V, this), e2, _classPrivateFieldGet2(L, this), _classPrivateFieldGet2(B, this));
|
|
1581
1581
|
}
|
|
1582
1582
|
function _getNormalizedOptions() {
|
|
1583
|
-
if (!_classPrivateFieldGet2(
|
|
1584
|
-
let { hooks: e2, ...t2 } = _classPrivateFieldGet2(
|
|
1585
|
-
_classPrivateFieldSet2(
|
|
1583
|
+
if (!_classPrivateFieldGet2(U, this)) {
|
|
1584
|
+
let { hooks: e2, ...t2 } = _classPrivateFieldGet2(B, this);
|
|
1585
|
+
_classPrivateFieldSet2(U, this, Object.freeze(t2));
|
|
1586
1586
|
}
|
|
1587
|
-
return _classPrivateFieldGet2(
|
|
1587
|
+
return _classPrivateFieldGet2(U, this);
|
|
1588
1588
|
}
|
|
1589
1589
|
function _assignRequest(e2) {
|
|
1590
|
-
_classPrivateFieldSet2(
|
|
1590
|
+
_classPrivateFieldSet2(U, this, void 0), this.request = _assertClassBrand(W, this, _wrapRequestWithUploadProgress).call(this, e2);
|
|
1591
1591
|
}
|
|
1592
1592
|
function _wrapRequestWithUploadProgress(e2, t2) {
|
|
1593
|
-
return !_classPrivateFieldGet2(
|
|
1593
|
+
return !_classPrivateFieldGet2(B, this).onUploadProgress || !e2.body ? e2 : streamRequest(e2, _classPrivateFieldGet2(B, this).onUploadProgress, t2 ?? _classPrivateFieldGet2(B, this).body ?? void 0);
|
|
1594
1594
|
}
|
|
1595
1595
|
var createInstance = (e2) => {
|
|
1596
|
-
let ky = (t2, n2) =>
|
|
1597
|
-
for (let t2 of j) ky[t2] = (n2, r2) =>
|
|
1598
|
-
return ky.create = (e3) => createInstance(validateAndMerge(e3)), ky.extend = (t2) => (typeof t2 == `function` && (t2 = t2(e2 ?? {})), createInstance(validateAndMerge(e2, t2))), ky.stop =
|
|
1599
|
-
},
|
|
1596
|
+
let ky = (t2, n2) => G.create(t2, validateAndMerge(e2, n2));
|
|
1597
|
+
for (let t2 of j) ky[t2] = (n2, r2) => G.create(n2, validateAndMerge(e2, r2, { method: t2 }));
|
|
1598
|
+
return ky.create = (e3) => createInstance(validateAndMerge(e3)), ky.extend = (t2) => (typeof t2 == `function` && (t2 = t2(e2 ?? {})), createInstance(validateAndMerge(e2, t2))), ky.stop = F, ky.retry = retry, ky;
|
|
1599
|
+
}, K = createInstance();
|
|
1600
1600
|
function normalizeServerMessage(e2) {
|
|
1601
1601
|
if (typeof e2 == `string`) return e2;
|
|
1602
1602
|
if (Array.isArray(e2)) return e2.filter((e3) => typeof e3 == `string`).join(`; `) || void 0;
|
|
@@ -1630,7 +1630,7 @@ var ParseError = class extends Error {
|
|
|
1630
1630
|
constructor(e2, t2) {
|
|
1631
1631
|
super(e2), this.name = `ParseError`, this.type = t2.type, this.field = t2.field, this.value = t2.value, this.line = t2.line;
|
|
1632
1632
|
}
|
|
1633
|
-
},
|
|
1633
|
+
}, q = 10, J = 13, Y = 32;
|
|
1634
1634
|
function noop(e2) {
|
|
1635
1635
|
}
|
|
1636
1636
|
function createParser(e2) {
|
|
@@ -1671,7 +1671,7 @@ function createParser(e2) {
|
|
|
1671
1671
|
let i3 = e3.charCodeAt(n3);
|
|
1672
1672
|
if (isDataPrefix(e3, n3, i3)) {
|
|
1673
1673
|
let i4 = e3.charCodeAt(n3 + 5) === Y ? n3 + 6 : n3 + 5, a3 = e3.slice(i4, r3);
|
|
1674
|
-
if (d2 === 0 && e3.charCodeAt(r3 + 1) ===
|
|
1674
|
+
if (d2 === 0 && e3.charCodeAt(r3 + 1) === q) {
|
|
1675
1675
|
t2({ id: l2, event: f2, data: a3 }), l2 = void 0, u2 = ``, f2 = void 0, n3 = r3 + 2, r3 = e3.indexOf(`
|
|
1676
1676
|
`, n3);
|
|
1677
1677
|
continue;
|
|
@@ -1688,7 +1688,7 @@ ${a3}`, d2++;
|
|
|
1688
1688
|
let t3 = e3.indexOf(`\r`, n3), r3 = e3.indexOf(`
|
|
1689
1689
|
`, n3), i3 = -1;
|
|
1690
1690
|
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;
|
|
1691
|
-
parseLine(e3, n3, i3), n3 = i3 + 1, e3.charCodeAt(n3 - 1) ===
|
|
1691
|
+
parseLine(e3, n3, i3), n3 = i3 + 1, e3.charCodeAt(n3 - 1) === J && e3.charCodeAt(n3) === q && n3++;
|
|
1692
1692
|
}
|
|
1693
1693
|
return e3.slice(n3);
|
|
1694
1694
|
}
|
|
@@ -1814,7 +1814,7 @@ function mergeRequestHeaders(e2, t2) {
|
|
|
1814
1814
|
function createHttpClient(e2) {
|
|
1815
1815
|
let t2 = e2.apiBase.replace(/\/+$/, ``), n2 = { ...e2.defaultHeaders ?? {} }, i2 = e2.fetch ?? (typeof fetch < `u` ? fetch.bind(globalThis) : void 0);
|
|
1816
1816
|
if (!i2) throw new r(`TRANSPORT_FAILED`, `No fetch implementation available. Provide one via HttpClientOptions.fetch.`);
|
|
1817
|
-
let a2 =
|
|
1817
|
+
let a2 = K.create({ prefixUrl: `${t2}/`, retry: { limit: 0 }, timeout: false, fetch: i2, hooks: { beforeError: [async (e3) => {
|
|
1818
1818
|
throw e3 instanceof HTTPError ? await readHttpError(e3.response) : isAbortError(e3) ? toTransportAbortError(e3) : toNetworkError(e3);
|
|
1819
1819
|
}] } });
|
|
1820
1820
|
return { setDefaultHeader(e3, t3) {
|
|
@@ -2170,7 +2170,22 @@ function parseCatalogMyFeedback(e2) {
|
|
|
2170
2170
|
function parseCatalogItem(e2) {
|
|
2171
2171
|
if (!isRecord$4(e2)) return null;
|
|
2172
2172
|
let t2 = readString$2(e2.actionKey), n2 = readString$2(e2.name), r2 = readNumber$1(e2.pageActionId);
|
|
2173
|
-
return !t2 || !n2 || r2 == null ? null : { pageActionId: r2, actionKey: t2, name: n2, description: e2.description === null ? null : readString$2(e2.description) ?? null, pageScope: e2.pageScope === null ? null : readString$2(e2.pageScope) ?? null, sortOrder: readNumber$1(e2.sortOrder) ?? 0, myFeedback: parseCatalogMyFeedback(e2.myFeedback) };
|
|
2173
|
+
return !t2 || !n2 || r2 == null ? null : { pageActionId: r2, actionKey: t2, name: n2, description: e2.description === null ? null : readString$2(e2.description) ?? null, pageScope: e2.pageScope === null ? null : readString$2(e2.pageScope) ?? null, sortOrder: readNumber$1(e2.sortOrder) ?? 0, rolloutRestricted: e2.rolloutRestricted === true, myFeedback: parseCatalogMyFeedback(e2.myFeedback) };
|
|
2174
|
+
}
|
|
2175
|
+
function parseRolloutCheckItem(e2) {
|
|
2176
|
+
if (!isRecord$4(e2)) return null;
|
|
2177
|
+
let t2 = readString$2(e2.actionKey);
|
|
2178
|
+
if (!t2 || typeof e2.allowed != `boolean`) return null;
|
|
2179
|
+
let n2 = readString$2(e2.reason) ?? (e2.allowed ? `open` : `denied`);
|
|
2180
|
+
return { actionKey: t2, allowed: e2.allowed, reason: n2 };
|
|
2181
|
+
}
|
|
2182
|
+
function parsePageActionRolloutCheck(e2) {
|
|
2183
|
+
let t2 = parseApiEnvelope(e2), n2 = Array.isArray(t2) ? t2 : isRecord$4(t2) && Array.isArray(t2.items) ? t2.items : [], r2 = /* @__PURE__ */ new Set(), i2 = [];
|
|
2184
|
+
for (let e3 of n2) {
|
|
2185
|
+
let t3 = parseRolloutCheckItem(e3);
|
|
2186
|
+
!t3 || r2.has(t3.actionKey) || (r2.add(t3.actionKey), i2.push(t3));
|
|
2187
|
+
}
|
|
2188
|
+
return i2;
|
|
2174
2189
|
}
|
|
2175
2190
|
function parseFeedbackView(e2) {
|
|
2176
2191
|
if (!isRecord$4(e2)) return null;
|
|
@@ -2278,6 +2293,10 @@ var PageActionService = class {
|
|
|
2278
2293
|
let n2 = e2.pageScope?.trim();
|
|
2279
2294
|
return parsePageActionFeedbackCatalog(await this.http.request(`/page-action/catalog`, { method: `GET`, signal: t2, searchParams: n2 ? { pageScope: n2 } : void 0 }));
|
|
2280
2295
|
}
|
|
2296
|
+
async checkRollout(e2, t2) {
|
|
2297
|
+
let n2 = Array.from(new Set(e2.map((e3) => e3.trim()).filter((e3) => e3.length > 0)));
|
|
2298
|
+
return n2.length === 0 ? [] : parsePageActionRolloutCheck(await this.http.request(`/page-action/rollout-check`, { method: `POST`, signal: t2, body: { actionKeys: n2 } }));
|
|
2299
|
+
}
|
|
2281
2300
|
async upsertFeedback(e2, t2, n2) {
|
|
2282
2301
|
let i2 = parsePageActionFeedbackView(await this.http.request(`/page-action/feedback/${encodeActionKeyPath(e2)}`, { method: `PUT`, signal: n2, body: t2 }));
|
|
2283
2302
|
if (!i2) throw new r(`TRANSPORT_FAILED`, `Invalid feedback response`);
|
|
@@ -2899,7 +2918,7 @@ var PageActionCoordinator = class {
|
|
|
2899
2918
|
}
|
|
2900
2919
|
return t2.autoResume && await this.runLiveRestore(t2.actionKey), { applyPhase: this.getApplyPhase(e2) };
|
|
2901
2920
|
}
|
|
2902
|
-
}, Z = `
|
|
2921
|
+
}, Z = `3.0.2`;
|
|
2903
2922
|
function nanoId(e2 = `id`) {
|
|
2904
2923
|
let t2 = globalThis.crypto;
|
|
2905
2924
|
return t2?.randomUUID ? `${e2}_${t2.randomUUID().replace(/-/g, ``).slice(0, 12)}` : `${e2}_${Math.random().toString(36).slice(2, 14)}`;
|
|
@@ -3092,6 +3111,9 @@ var AgentChatClient = class {
|
|
|
3092
3111
|
listPageActionFeedbackCatalog() {
|
|
3093
3112
|
return this.pageActionFeedbackCatalogItems.slice();
|
|
3094
3113
|
}
|
|
3114
|
+
async checkPageActionRollout(e2, t2) {
|
|
3115
|
+
return await this.ensureInitialized(`checkPageActionRollout`, { signal: t2?.signal }), await this.ensureLoggedIn(`checkPageActionRollout`, { signal: t2?.signal }), this.requireState(`checkPageActionRollout`).pageAction.checkRollout(e2, t2?.signal);
|
|
3116
|
+
}
|
|
3095
3117
|
async getPageActionFeedback(e2, t2) {
|
|
3096
3118
|
return await this.ensureInitialized(`getPageActionFeedback`, { signal: t2?.signal }), await this.ensureLoggedIn(`getPageActionFeedback`, { signal: t2?.signal }), this.requireState(`getPageActionFeedback`).pageAction.getMyFeedback(e2, t2?.signal);
|
|
3097
3119
|
}
|
|
@@ -3303,11 +3325,12 @@ var AgentChatClient = class {
|
|
|
3303
3325
|
}
|
|
3304
3326
|
return i2 && (this.clearPageActionNarrativeClearTimer(i2), this.upsertPageActionRow(buildPageActionRowState({ rowKey: i2, actionKey: t2.actionKey.trim(), runId: this.pageActionRows.get(i2)?.runId ?? null, pageActionKey: this.pageActionRows.get(i2)?.pageActionKey ?? null, phase: `submitting`, error: null, message: null, progressLabel: e.p(this.state?.options.locale), narrativeItems: [], approvalRequestId: this.pageActionRows.get(i2)?.approvalRequestId ?? null }))), await this.invokePageActionStream(n2, t2, i2);
|
|
3305
3327
|
} catch (e2) {
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3328
|
+
let n3 = remapPageActionRolloutDenied(e2);
|
|
3329
|
+
if (i2 && !(n3 instanceof r && n3.code === `PAGE_ACTION_ALREADY_ACTIVE`)) {
|
|
3330
|
+
let e3 = n3 instanceof Error ? n3.message : String(n3);
|
|
3331
|
+
this.upsertPageActionRow(buildPageActionRowState({ rowKey: i2, actionKey: t2.actionKey.trim(), runId: this.pageActionRows.get(i2)?.runId ?? null, pageActionKey: this.pageActionRows.get(i2)?.pageActionKey ?? null, phase: `failed`, error: e3, message: null, progressLabel: null, approvalRequestId: this.pageActionRows.get(i2)?.approvalRequestId ?? null })), this.schedulePageActionRowIdleReset(i2, 1600);
|
|
3309
3332
|
}
|
|
3310
|
-
throw
|
|
3333
|
+
throw n3;
|
|
3311
3334
|
} finally {
|
|
3312
3335
|
this.releasePageActionLock(a2);
|
|
3313
3336
|
}
|
|
@@ -5208,6 +5231,9 @@ function readWriteGateServerCode(e2) {
|
|
|
5208
5231
|
if (typeof t2.code == `string`) return t2.code;
|
|
5209
5232
|
}
|
|
5210
5233
|
}
|
|
5234
|
+
function remapPageActionRolloutDenied(e2) {
|
|
5235
|
+
return !(e2 instanceof r) || e2.code !== `TRANSPORT_FAILED` || e2.details?.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 });
|
|
5236
|
+
}
|
|
5211
5237
|
function createAgentChat() {
|
|
5212
5238
|
return new AgentChatClient();
|
|
5213
5239
|
}
|
|
@@ -5435,57 +5461,82 @@ function resolveLaunchAnchor(e2) {
|
|
|
5435
5461
|
return e2 ? `current` in e2 ? e2.current : e2 : null;
|
|
5436
5462
|
}
|
|
5437
5463
|
function usePageActions(n2) {
|
|
5438
|
-
let r2 = useAgentChatClient(), i2 = useAgentChatStore((e2) => e2.isLoggedIn), a2 = n2.requireInstruction !== false, o2 = n2.autoResume === true, s2 = n2.reconcileOnMount ?? !o2, [
|
|
5439
|
-
|
|
5440
|
-
let
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5464
|
+
let r2 = useAgentChatClient(), i2 = useAgentChatStore((e2) => e2.isLoggedIn), a2 = n2.requireInstruction !== false, o2 = n2.autoResume === true, s2 = n2.checkRollout !== false, c2 = n2.reconcileOnMount ?? !o2, [l2, u2] = (0, t.useState)(n2.defaultInstruction ?? ``), [d2, f2] = (0, t.useState)({}), [p2, m2] = (0, t.useState)(!s2 || null), [h2, g2] = (0, t.useState)(s2 ? null : `open`), _2 = (0, t.useRef)(n2);
|
|
5465
|
+
_2.current = n2;
|
|
5466
|
+
let v2 = (0, t.useRef)(0), y2 = (0, t.useRef)(p2);
|
|
5467
|
+
y2.current = p2;
|
|
5468
|
+
let b2 = n2.actionKey.trim(), x2 = (0, t.useCallback)(async () => {
|
|
5469
|
+
if (!s2 || !b2) {
|
|
5470
|
+
m2(true), g2(`open`);
|
|
5471
|
+
return;
|
|
5472
|
+
}
|
|
5473
|
+
if (!i2) {
|
|
5474
|
+
m2(null), g2(null);
|
|
5475
|
+
return;
|
|
5476
|
+
}
|
|
5477
|
+
try {
|
|
5478
|
+
let e2 = await r2.checkPageActionRollout([b2]), t2 = e2.find((e3) => e3.actionKey === b2) ?? e2[0];
|
|
5479
|
+
if (!t2) {
|
|
5480
|
+
m2(true), g2(`open`);
|
|
5481
|
+
return;
|
|
5482
|
+
}
|
|
5483
|
+
m2(t2.allowed), g2(t2.reason);
|
|
5484
|
+
} catch {
|
|
5485
|
+
m2(true), g2(null);
|
|
5486
|
+
}
|
|
5487
|
+
}, [b2, s2, r2, i2]);
|
|
5488
|
+
(0, t.useEffect)(() => {
|
|
5489
|
+
x2();
|
|
5490
|
+
}, [x2]);
|
|
5491
|
+
let S2 = (0, t.useCallback)(() => {
|
|
5492
|
+
let e2 = buildPageActionRowsMap(r2.getPageActionRowsForActionKey(b2));
|
|
5493
|
+
f2((t2) => pageActionRowsShallowEqual(t2, e2) ? t2 : e2);
|
|
5494
|
+
}, [b2, r2]);
|
|
5444
5495
|
(0, t.useEffect)(() => {
|
|
5445
|
-
|
|
5496
|
+
S2();
|
|
5446
5497
|
let e2 = r2.on(`pageActionRowChanged`, (e3) => {
|
|
5447
|
-
e3.state.actionKey ===
|
|
5498
|
+
e3.state.actionKey === b2 && f2((t3) => {
|
|
5448
5499
|
let n4 = t3[e3.rowKey];
|
|
5449
5500
|
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 };
|
|
5450
5501
|
});
|
|
5451
|
-
}), t2 = r2.on(`automationTaskCenterChanged`,
|
|
5502
|
+
}), t2 = r2.on(`automationTaskCenterChanged`, S2), n3 = r2.on(`approvalExecutionCompleted`, S2), i3 = r2.on(`approvalInboxChanged`, S2);
|
|
5452
5503
|
return () => {
|
|
5453
5504
|
e2(), t2(), n3(), i3();
|
|
5454
5505
|
};
|
|
5455
|
-
}, [
|
|
5456
|
-
i2 ||
|
|
5506
|
+
}, [b2, r2, S2]), (0, t.useEffect)(() => {
|
|
5507
|
+
i2 || f2({});
|
|
5457
5508
|
}, [i2]), (0, t.useEffect)(() => {
|
|
5458
|
-
!
|
|
5509
|
+
!c2 || !i2 || !b2 || r2.reconcileActivePageActions({ actionKey: b2 }).then(S2).catch(() => {
|
|
5459
5510
|
});
|
|
5460
|
-
}, [
|
|
5461
|
-
if (!(!o2 || !
|
|
5462
|
-
}, [
|
|
5463
|
-
let
|
|
5511
|
+
}, [b2, r2, i2, c2, S2]), (0, t.useEffect)(() => {
|
|
5512
|
+
if (!(!o2 || !b2)) return r2.bindPageActionSlot({ actionKey: b2, rowKey: `*`, pageContext: n2.page ? { page: n2.page } : null, ready: true, autoResume: true, autoApplyPending: false });
|
|
5513
|
+
}, [b2, o2, r2, n2.page]);
|
|
5514
|
+
let C2 = (0, t.useCallback)((e2) => {
|
|
5464
5515
|
let t2 = e2.trim();
|
|
5465
|
-
return t2 ?
|
|
5466
|
-
}, [
|
|
5467
|
-
let e2 = await r2.reconcileActivePageActions({ actionKey:
|
|
5468
|
-
return
|
|
5469
|
-
}, [
|
|
5516
|
+
return t2 ? d2[t2] ?? r2.getPageActionRowState(t2) ?? createIdlePageActionRowState(t2, b2) : createIdlePageActionRowState(``, b2);
|
|
5517
|
+
}, [b2, r2, d2]), w2 = (0, t.useCallback)(async () => {
|
|
5518
|
+
let e2 = await r2.reconcileActivePageActions({ actionKey: b2 });
|
|
5519
|
+
return S2(), e2;
|
|
5520
|
+
}, [b2, r2, S2]), T2 = (0, t.useCallback)((e2) => {
|
|
5470
5521
|
r2.openAutomationTaskCenter(e2);
|
|
5471
|
-
}, [r2]),
|
|
5522
|
+
}, [r2]), E2 = (0, t.useCallback)((e2) => {
|
|
5472
5523
|
r2.clearPageActionRowError(e2);
|
|
5473
5524
|
}, [r2]);
|
|
5474
|
-
return { instruction:
|
|
5525
|
+
return { instruction: l2, setInstruction: u2, rows: d2, getRow: C2, getProcessView: (t2) => e.a(C2(t2)), invoke: (0, t.useCallback)(async (e2) => {
|
|
5475
5526
|
let t2 = e2.rowKey.trim();
|
|
5476
5527
|
if (!t2) return;
|
|
5477
|
-
let n3 = (e2.instruction ??
|
|
5478
|
-
if (a2 && !n3 || !
|
|
5479
|
-
|
|
5480
|
-
let i3 =
|
|
5481
|
-
e2.preferReuse === false && (u3.preferReuse = false), n3 && (u3.instruction = n3), (s3 ||
|
|
5528
|
+
let n3 = (e2.instruction ?? l2).trim();
|
|
5529
|
+
if (a2 && !n3 || !b2 || y2.current === false) return;
|
|
5530
|
+
v2.current += 1;
|
|
5531
|
+
let i3 = _2.current.page?.trim(), o3 = e2.pageContext ? { ...e2.pageContext, ...i3 && !e2.pageContext.page ? { page: i3 } : {} } : i3 ? { page: i3 } : void 0, s3 = _2.current.context, c3 = e2.context, u3 = { actionKey: b2, rowKey: t2, clientActionId: e2.clientActionId?.trim() || `page-action-${t2}-${v2.current}`, awaitStream: false, launchAnchor: resolveLaunchAnchor(e2.launchAnchor), pageContext: o3 };
|
|
5532
|
+
e2.preferReuse === false && (u3.preferReuse = false), n3 && (u3.instruction = n3), (s3 || c3) && (u3.context = { ...s3, ...c3 }), e2.signal && (u3.signal = e2.signal), e2.onChunk && (u3.onChunk = e2.onChunk);
|
|
5482
5533
|
try {
|
|
5483
5534
|
let e3 = await r2.invokePageAction(u3);
|
|
5484
|
-
return
|
|
5535
|
+
return S2(), e3;
|
|
5485
5536
|
} catch (e3) {
|
|
5486
|
-
throw
|
|
5537
|
+
throw S2(), e3;
|
|
5487
5538
|
}
|
|
5488
|
-
}, [
|
|
5539
|
+
}, [b2, r2, l2, a2, S2]), reconcile: w2, openTaskCenter: T2, clearRowError: E2, rolloutAllowed: p2, rolloutReason: h2, visible: p2 !== false, refreshRollout: x2 };
|
|
5489
5540
|
}
|
|
5490
5541
|
function defaultRowKey(e2) {
|
|
5491
5542
|
let t2 = e2?.entity?.id;
|
|
@@ -5494,7 +5545,7 @@ function defaultRowKey(e2) {
|
|
|
5494
5545
|
function usePageAction(n2) {
|
|
5495
5546
|
let r2 = useAgentChatClient(), i2 = n2.ready !== false, a2 = n2.autoResume !== false, o2 = n2.autoApplyPending !== false, s2 = n2.actionKey.trim(), c2 = defaultRowKey(n2.pageContext), l2 = pageActionSlotKey({ actionKey: s2, rowKey: c2 }), u2 = (0, t.useRef)(n2);
|
|
5496
5547
|
u2.current = n2;
|
|
5497
|
-
let d2 = usePageActions({ actionKey: n2.actionKey, page: n2.pageContext?.page, defaultInstruction: n2.defaultInstruction, context: n2.context, requireInstruction: n2.requireInstruction, reconcileOnMount: false }), f2 = d2.getRow(c2), [p2, m2] = (0, t.useState)(null), [h2, g2] = (0, t.useState)(`idle`);
|
|
5548
|
+
let d2 = usePageActions({ actionKey: n2.actionKey, page: n2.pageContext?.page, defaultInstruction: n2.defaultInstruction, context: n2.context, requireInstruction: n2.requireInstruction, reconcileOnMount: false, checkRollout: n2.checkRollout }), f2 = d2.getRow(c2), [p2, m2] = (0, t.useState)(null), [h2, g2] = (0, t.useState)(`idle`);
|
|
5498
5549
|
return (0, t.useEffect)(() => {
|
|
5499
5550
|
let syncPending = () => {
|
|
5500
5551
|
let e2 = r2.getPendingPageActionApply(), t2 = matchesPendingPageActionApply(e2, { actionKey: s2, pageContext: u2.current.pageContext });
|
|
@@ -5511,7 +5562,7 @@ function usePageAction(n2) {
|
|
|
5511
5562
|
}, [l2, r2, n2.pageContext, i2, a2, o2]), { instruction: d2.instruction, setInstruction: d2.setInstruction, phase: f2.phase, pageActionKey: f2.pageActionKey, lastRunId: f2.runId, invoke: (e2) => {
|
|
5512
5563
|
let t2 = e2?.rowKey?.trim() || c2, r3 = e2?.pageContext ?? n2.pageContext ?? void 0, i3 = { rowKey: t2, instruction: e2?.instruction, context: e2?.context, clientActionId: e2?.clientActionId, pageContext: r3 ?? void 0, signal: e2?.signal, onChunk: e2?.onChunk, launchAnchor: e2?.launchAnchor, preferReuse: e2?.preferReuse };
|
|
5513
5564
|
return d2.invoke(i3);
|
|
5514
|
-
}, openTaskCenter: () => d2.openTaskCenter(f2.runId == null ? void 0 : { runId: f2.runId }), loading: f2.loading, awaitingApproval: f2.awaitingApproval, disabled: f2.disabled, error: f2.error, message: f2.message, progressLabel: f2.progressLabel, narrativeItems: f2.narrativeItems, process: e.a(f2), clearError: () => d2.clearRowError(c2), pendingApply: p2 != null, pendingApplyIntent: p2, applyPhase: h2 };
|
|
5565
|
+
}, openTaskCenter: () => d2.openTaskCenter(f2.runId == null ? void 0 : { runId: f2.runId }), loading: f2.loading, awaitingApproval: f2.awaitingApproval, disabled: f2.disabled || d2.rolloutAllowed === false, rolloutAllowed: d2.rolloutAllowed, rolloutReason: d2.rolloutReason, visible: d2.visible, refreshRollout: d2.refreshRollout, error: f2.error, message: f2.message, progressLabel: f2.progressLabel, narrativeItems: f2.narrativeItems, process: e.a(f2), clearError: () => d2.clearRowError(c2), pendingApply: p2 != null, pendingApplyIntent: p2, applyPhase: h2 };
|
|
5515
5566
|
}
|
|
5516
5567
|
function readExtensionApi() {
|
|
5517
5568
|
if (typeof window > `u`) return null;
|