@burdenoff/fe-libs 2026.1022.3 → 2026.1023.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/dist/chrome/Tabs.js +1 -1
- package/dist/shared/assistant/api.js +218 -217
- package/dist/shared/assistant/createSandboxAssistantTransport.js +99 -85
- package/dist/shared/assistant/history/historyMapping.js +26 -26
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/progress.d.ts +2 -0
- package/dist/shared/assistant/progress.js +13 -5
- package/dist/shared/assistant/promptDelivery.d.ts +24 -0
- package/dist/shared/assistant/promptDelivery.js +80 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +1526 -1516
- package/dist/shared-assistant.js +305 -304
- package/package.json +1 -1
- package/scripts/a11y-audit/README.md +63 -0
- package/scripts/a11y-audit/audit.ts +120 -22
- package/scripts/a11y-audit/cli.ts +10 -3
- package/scripts/a11y-audit/config.ts +123 -0
- package/scripts/a11y-audit/fixtures.ts +277 -0
- package/scripts/a11y-audit/index.ts +17 -1
- package/scripts/a11y-audit/report.ts +36 -5
- package/scripts/a11y-audit/types.ts +48 -1
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
import { sandboxProxyErrorFromBody as e, sandboxProxyErrorFromTurnTerminal as t } from "./sandboxProxyError.js";
|
|
2
2
|
import { extensionObjectsIn as n } from "./quota.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { abandonAssistantSandboxTurns as r, withAssistantProxyResponse as i } from "./promptDelivery.js";
|
|
4
|
+
import { buildSandboxContextInput as a, executeAssistantGraphQLOnce as o, executeSandboxGraphQL as s } from "./gatewayClient.js";
|
|
5
|
+
import { CHECK_AI_CREDITS as c, CREATE_SANDBOX as l, EXTEND_MY_ASSISTANT_SANDBOX_TTL as u, EXTEND_SANDBOX_TTL as d, GET_ACTIVE_SANDBOXES as f, GET_SANDBOX as p, PROVISION_ASSISTANT_SANDBOX as ee, PROXY_SANDBOX_REQUEST as te, REPORT_AI_TOKEN_USAGE as ne, STOP_ASSISTANT_SANDBOX as re, STOP_MY_ASSISTANT_SANDBOX as ie, WAIT_FOR_SANDBOX_RUNNING as ae } from "./operations.js";
|
|
6
|
+
import { ASSISTANT_API_AUTH_STRATEGY as oe, getImageForMode as m, getImageTagForMode as se, getResourcesForMode as ce, resolveSandboxAssistantMode as h } from "./images.js";
|
|
7
|
+
import { STREAM_MINT_BACKOFF_ERROR_MS as g, STREAM_MINT_BACKOFF_UNAVAILABLE_MS as _, backOffStreamMint as v, clearStreamMintBackoff as le, getCapability as y, isMissingGatewayFieldError as b, isUnknownFieldError as ue, markSupported as x, markUnsupported as S, streamMintBackedOff as de } from "./capabilities.js";
|
|
8
|
+
import { filterAssistantPageContext as fe } from "./pageContextKeys.js";
|
|
8
9
|
import { useAssistantStore as C } from "./store.js";
|
|
9
|
-
import { REQUEST_TOO_LARGE_REFUSAL as
|
|
10
|
+
import { REQUEST_TOO_LARGE_REFUSAL as pe } from "./gatewayLimits.js";
|
|
10
11
|
//#region src/shared/assistant/api.ts
|
|
11
|
-
function
|
|
12
|
+
function w(e) {
|
|
12
13
|
return e === "assistant" || e === "api-calls";
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function T(e, t, n, r, i, o, s) {
|
|
15
16
|
return {
|
|
16
|
-
query:
|
|
17
|
+
query: te,
|
|
17
18
|
operationName: "ProxySandboxRequest",
|
|
18
19
|
variables: { input: {
|
|
19
20
|
sandboxId: e,
|
|
20
21
|
path: n,
|
|
21
|
-
method:
|
|
22
|
-
body:
|
|
23
|
-
context:
|
|
24
|
-
...
|
|
22
|
+
method: r,
|
|
23
|
+
body: i,
|
|
24
|
+
context: a(t, s),
|
|
25
|
+
...w(o) ? {
|
|
25
26
|
forwardedAuthToken: s?.accessToken ?? void 0,
|
|
26
27
|
forwardedWorkspaceToken: s?.workspaceToken ?? void 0
|
|
27
28
|
} : {}
|
|
28
29
|
} }
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
async function
|
|
32
|
-
let
|
|
33
|
-
...
|
|
32
|
+
async function E(t, n, r, a, c, l, u, d) {
|
|
33
|
+
let f = (await (d === "transport" ? s : o)({
|
|
34
|
+
...T(t, n, r, a, c, l, u),
|
|
34
35
|
workspaceId: n,
|
|
35
|
-
authContext:
|
|
36
|
+
authContext: u
|
|
36
37
|
})).proxySandboxRequest;
|
|
37
|
-
if (!
|
|
38
|
-
let t =
|
|
39
|
-
throw e(n,
|
|
38
|
+
if (!f || f.status >= 400) {
|
|
39
|
+
let t = f?.body, n = t?.error ?? `Proxy error: ${f?.status ?? "unknown"}`;
|
|
40
|
+
throw i(e(n, f?.status ?? null, t) ?? Error(n), f?.status, t);
|
|
40
41
|
}
|
|
41
|
-
return
|
|
42
|
+
return f.body;
|
|
42
43
|
}
|
|
43
|
-
async function
|
|
44
|
-
let c = (await
|
|
45
|
-
...
|
|
44
|
+
async function D(e, t, n, r, i, a, s) {
|
|
45
|
+
let c = (await o({
|
|
46
|
+
...T(e, t, n, r, i, a, s),
|
|
46
47
|
workspaceId: t,
|
|
47
48
|
authContext: s
|
|
48
49
|
})).proxySandboxRequest;
|
|
@@ -52,44 +53,44 @@ async function E(e, t, n, r, a, o, s) {
|
|
|
52
53
|
body: "body" in c ? c.body ?? null : null
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
async function
|
|
56
|
-
return (await
|
|
56
|
+
async function me(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
57
|
+
return (await O(e, t, n, r, i, a, o))?.id ?? null;
|
|
57
58
|
}
|
|
58
|
-
async function
|
|
59
|
-
let l = (await
|
|
60
|
-
query:
|
|
59
|
+
async function O(e, t, n, r, i, o = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
60
|
+
let l = (await s({
|
|
61
|
+
query: f,
|
|
61
62
|
operationName: "GetActiveSandboxes",
|
|
62
|
-
variables: { context:
|
|
63
|
+
variables: { context: a(e, i) },
|
|
63
64
|
workspaceId: e,
|
|
64
|
-
authContext:
|
|
65
|
+
authContext: i
|
|
65
66
|
})).getActiveSandboxes ?? [];
|
|
66
|
-
|
|
67
|
-
let
|
|
68
|
-
return
|
|
69
|
-
id:
|
|
70
|
-
status:
|
|
67
|
+
R(l);
|
|
68
|
+
let u = A(l, t, n, r, i, o, V(c));
|
|
69
|
+
return u ? {
|
|
70
|
+
id: u,
|
|
71
|
+
status: k(l, u)
|
|
71
72
|
} : null;
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
+
function k(e, t) {
|
|
74
75
|
return e.find((e) => e.id === t)?.status ?? "UNKNOWN";
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
return e.find((e) => !a.has(e.id) && (e.status === "RUNNING" || e.status === "PROVISIONING" || e.status === "PENDING") && e.template === "AI_BUILDER" && h(e, [n]) === n && (!i.userId || e.createdBy === i.userId) && e.metadata?.authStrategy === "sandbox-app-client-headers-v1" && e.metadata?.assistantProduct === t && (!
|
|
77
|
+
function A(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
78
|
+
return e.find((e) => !a.has(e.id) && (e.status === "RUNNING" || e.status === "PROVISIONING" || e.status === "PENDING") && e.template === "AI_BUILDER" && h(e, [n]) === n && (!i.userId || e.createdBy === i.userId) && e.metadata?.authStrategy === "sandbox-app-client-headers-v1" && e.metadata?.assistantProduct === t && (!P(n) || N(e.metadata, o)) && j(e, n, o))?.id ?? null;
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
-
return t !== "assistant" || n !== "proposal-v1" ? !0 :
|
|
80
|
+
function j(e, t, n) {
|
|
81
|
+
return t !== "assistant" || n !== "proposal-v1" ? !0 : L(e);
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function M(e) {
|
|
83
84
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function N(e, t) {
|
|
86
87
|
let n = e?.assistantAuth;
|
|
87
|
-
return
|
|
88
|
+
return M(n) && n.accessProfile === "member" ? !0 : (e?.writeApproval ?? "legacy") === t ? e?.confirmWrites === (t === "proposal-v1" ? "proposal-v1" : !0) : !1;
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
+
function P(e) {
|
|
90
91
|
return e === "api-calls";
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function F(e, t, n, r) {
|
|
93
94
|
let i = [
|
|
94
95
|
{
|
|
95
96
|
name: "AI_ASSISTANT_MODE",
|
|
@@ -117,47 +118,47 @@ function P(e, t, n, r) {
|
|
|
117
118
|
}), r.workspaceToken && i.push({
|
|
118
119
|
name: "WORKSPACE_AUTH_TOKEN",
|
|
119
120
|
value: r.workspaceToken
|
|
120
|
-
})),
|
|
121
|
+
})), P(t) && i.push({
|
|
121
122
|
name: "AI_ASSISTANT_CONFIRM_WRITES",
|
|
122
123
|
value: "1"
|
|
123
124
|
}), i;
|
|
124
125
|
}
|
|
125
|
-
var
|
|
126
|
+
var he = "assistant.errors.assistantProvisioningUnavailable", ge = "provisionAssistantSandbox", _e = [
|
|
126
127
|
"ProvisionAssistantSandboxInput",
|
|
127
128
|
"SandboxAssistantMode",
|
|
128
129
|
"SandboxAssistantWriteApproval"
|
|
129
|
-
],
|
|
130
|
-
function I(e) {
|
|
131
|
-
let t = e.metadata?.assistantAuth;
|
|
132
|
-
return j(t) && t.provisionedVia === he;
|
|
133
|
-
}
|
|
130
|
+
], I = /* @__PURE__ */ new Set();
|
|
134
131
|
function L(e) {
|
|
135
|
-
|
|
132
|
+
let t = e.metadata?.assistantAuth;
|
|
133
|
+
return M(t) && t.provisionedVia === ge;
|
|
136
134
|
}
|
|
137
135
|
function R(e) {
|
|
138
|
-
|
|
136
|
+
for (let t of e) L(t) && I.add(t.id);
|
|
139
137
|
}
|
|
140
|
-
function z(e
|
|
141
|
-
return
|
|
138
|
+
function z(e) {
|
|
139
|
+
return I.has(e);
|
|
142
140
|
}
|
|
143
|
-
function B(e) {
|
|
144
|
-
return
|
|
141
|
+
function B(e, t) {
|
|
142
|
+
return J(t) === "proposal-v1" && (e === "assistant" || e === "api-calls") && y("provisionAssistantSandbox") !== "unsupported";
|
|
145
143
|
}
|
|
146
144
|
function V(e) {
|
|
147
|
-
return
|
|
145
|
+
return J(e) === "proposal-v1" && y("provisionAssistantSandbox") !== "unsupported" ? "proposal-v1" : "legacy";
|
|
146
|
+
}
|
|
147
|
+
function H(e) {
|
|
148
|
+
return n(e).some((e) => e.i18nKey === he || e.code === "SERVICE_UNAVAILABLE");
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function U(e, t) {
|
|
150
151
|
if (t <= 600) return !1;
|
|
151
152
|
let n = e instanceof Error ? e.message.toLowerCase() : String(e);
|
|
152
153
|
return n.includes("ttl") || n.includes("validation") || n.includes("maximum");
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
+
function W(e, t, n, r, i, o) {
|
|
155
156
|
if (t !== "assistant" && t !== "api-calls") throw Error(`Mode ${t} is not provisioned through the assistant path`);
|
|
156
157
|
return {
|
|
157
158
|
mode: t === "assistant" ? "ASSISTANT" : "API_CALLS",
|
|
158
159
|
product: e,
|
|
159
|
-
image: m(t,
|
|
160
|
-
ttlSeconds:
|
|
160
|
+
image: m(t, r),
|
|
161
|
+
ttlSeconds: i,
|
|
161
162
|
...t === "api-calls" ? { writeApproval: "PROPOSAL_V1" } : {},
|
|
162
163
|
env: [
|
|
163
164
|
{
|
|
@@ -173,137 +174,137 @@ function U(e, t, n, i, a, o) {
|
|
|
173
174
|
value: n
|
|
174
175
|
}
|
|
175
176
|
],
|
|
176
|
-
context:
|
|
177
|
+
context: a(n, o)
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
|
-
async function
|
|
180
|
-
let
|
|
181
|
-
query:
|
|
180
|
+
async function G(e, t, n, r, i, a) {
|
|
181
|
+
let o = (await s({
|
|
182
|
+
query: ee,
|
|
182
183
|
operationName: "ProvisionAssistantSandbox",
|
|
183
|
-
variables: { input:
|
|
184
|
+
variables: { input: W(e, t, n, r, i, a) },
|
|
184
185
|
workspaceId: n,
|
|
185
|
-
authContext:
|
|
186
|
+
authContext: a
|
|
186
187
|
}))?.provisionAssistantSandbox?.id;
|
|
187
|
-
if (!
|
|
188
|
-
return
|
|
188
|
+
if (!o) throw Error("provisionAssistantSandbox returned empty response");
|
|
189
|
+
return o;
|
|
189
190
|
}
|
|
190
|
-
async function
|
|
191
|
+
async function ve(e, t, n, r, i, a) {
|
|
191
192
|
try {
|
|
192
|
-
return await
|
|
193
|
+
return await G(e, t, n, r, i, a);
|
|
193
194
|
} catch (o) {
|
|
194
|
-
if (
|
|
195
|
-
return
|
|
195
|
+
if (H(o) || K(o) || !U(o, i)) throw o;
|
|
196
|
+
return G(e, t, n, r, 600, a);
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
function
|
|
199
|
-
return b(e, "provisionAssistantSandbox",
|
|
199
|
+
function K(e) {
|
|
200
|
+
return b(e, "provisionAssistantSandbox", _e);
|
|
200
201
|
}
|
|
201
|
-
async function
|
|
202
|
-
if (
|
|
203
|
-
let o = await
|
|
204
|
-
return x("provisionAssistantSandbox"),
|
|
202
|
+
async function ye(e, t, n, r, i, a, o = {}) {
|
|
203
|
+
if (B(t, o.writeApproval)) try {
|
|
204
|
+
let o = await ve(e, t, n, r, i, a);
|
|
205
|
+
return x("provisionAssistantSandbox"), I.add(o), o;
|
|
205
206
|
} catch (e) {
|
|
206
|
-
if (!
|
|
207
|
+
if (!K(e)) throw e;
|
|
207
208
|
S("provisionAssistantSandbox");
|
|
208
209
|
}
|
|
209
|
-
return
|
|
210
|
+
return be(e, t, n, r, i, a);
|
|
210
211
|
}
|
|
211
|
-
async function
|
|
212
|
-
let
|
|
212
|
+
async function be(e, t, n, r, i, o) {
|
|
213
|
+
let c = ce(t), u = F(e, t, n, o), d = (i) => ({
|
|
213
214
|
name: `ai-assistant-${t}-${Date.now()}`,
|
|
214
215
|
description: `AI Assistant sandbox (${t} mode)`,
|
|
215
216
|
template: "AI_BUILDER",
|
|
216
217
|
mode: "DEPLOYMENT",
|
|
217
218
|
containers: [{
|
|
218
219
|
name: "ai-assistant",
|
|
219
|
-
image: m(t,
|
|
220
|
+
image: m(t, r),
|
|
220
221
|
ports: [{
|
|
221
222
|
containerPort: 8080,
|
|
222
223
|
name: "http"
|
|
223
224
|
}],
|
|
224
225
|
env: u
|
|
225
226
|
}],
|
|
226
|
-
resources:
|
|
227
|
-
ttlSeconds:
|
|
227
|
+
resources: c,
|
|
228
|
+
ttlSeconds: i,
|
|
228
229
|
metadata: {
|
|
229
230
|
assistantMode: t,
|
|
230
231
|
assistantProduct: e,
|
|
231
|
-
assistantOwnerUserId:
|
|
232
|
-
assistantOrganizationId:
|
|
233
|
-
authStrategy:
|
|
234
|
-
imageTag:
|
|
235
|
-
confirmWrites:
|
|
232
|
+
assistantOwnerUserId: o.userId ?? null,
|
|
233
|
+
assistantOrganizationId: o.organizationId ?? null,
|
|
234
|
+
authStrategy: oe,
|
|
235
|
+
imageTag: se(t, r),
|
|
236
|
+
confirmWrites: P(t)
|
|
236
237
|
},
|
|
237
|
-
context:
|
|
238
|
-
}), f = (e) =>
|
|
239
|
-
query:
|
|
238
|
+
context: a(n, o)
|
|
239
|
+
}), f = (e) => s({
|
|
240
|
+
query: l,
|
|
240
241
|
operationName: "CreateSandbox",
|
|
241
242
|
variables: { input: d(e) },
|
|
242
243
|
workspaceId: n,
|
|
243
|
-
authContext:
|
|
244
|
+
authContext: o
|
|
244
245
|
}), p;
|
|
245
246
|
try {
|
|
246
|
-
p = await f(
|
|
247
|
+
p = await f(i);
|
|
247
248
|
} catch (e) {
|
|
248
|
-
if (
|
|
249
|
+
if (U(e, i)) p = await f(600);
|
|
249
250
|
else throw e;
|
|
250
251
|
}
|
|
251
252
|
if (!p?.createSandbox?.id) throw Error("createSandbox returned empty response");
|
|
252
253
|
return p.createSandbox.id;
|
|
253
254
|
}
|
|
254
|
-
async function
|
|
255
|
-
return (await
|
|
256
|
-
query:
|
|
255
|
+
async function xe(e, t, n) {
|
|
256
|
+
return (await s({
|
|
257
|
+
query: p,
|
|
257
258
|
operationName: "GetSandbox",
|
|
258
259
|
variables: {
|
|
259
260
|
id: e,
|
|
260
|
-
context:
|
|
261
|
+
context: a(t, n)
|
|
261
262
|
},
|
|
262
263
|
workspaceId: t,
|
|
263
264
|
authContext: n
|
|
264
265
|
})).getSandbox;
|
|
265
266
|
}
|
|
266
|
-
function
|
|
267
|
+
function q(e, t) {
|
|
267
268
|
if (e === "FAILED" || e === "STOPPED" || e === "EXPIRED") throw Error(t ? `Sandbox ${e.toLowerCase()}: ${t}` : `Sandbox ${e.toLowerCase()}`);
|
|
268
269
|
}
|
|
269
|
-
async function
|
|
270
|
-
let
|
|
271
|
-
if (y("waitForSandboxRunning") !== "unsupported") for (; Date.now() -
|
|
272
|
-
let
|
|
273
|
-
query:
|
|
270
|
+
async function Se(e, t, n, r = 3e5) {
|
|
271
|
+
let i = Date.now();
|
|
272
|
+
if (y("waitForSandboxRunning") !== "unsupported") for (; Date.now() - i < r;) try {
|
|
273
|
+
let r = await s({
|
|
274
|
+
query: ae,
|
|
274
275
|
operationName: "WaitForSandboxRunning",
|
|
275
276
|
variables: {
|
|
276
277
|
id: e,
|
|
277
278
|
timeoutSeconds: 25,
|
|
278
|
-
context:
|
|
279
|
+
context: a(t, n)
|
|
279
280
|
},
|
|
280
281
|
workspaceId: t,
|
|
281
282
|
authContext: n
|
|
282
283
|
});
|
|
283
284
|
x("waitForSandboxRunning");
|
|
284
|
-
let
|
|
285
|
-
if (
|
|
286
|
-
|
|
285
|
+
let i = r.waitForSandboxRunning;
|
|
286
|
+
if (i?.status === "RUNNING") return;
|
|
287
|
+
q(i?.status, i?.errorMessage);
|
|
287
288
|
} catch (e) {
|
|
288
|
-
if (
|
|
289
|
+
if (ue(e)) {
|
|
289
290
|
S("waitForSandboxRunning");
|
|
290
291
|
break;
|
|
291
292
|
}
|
|
292
293
|
throw e;
|
|
293
294
|
}
|
|
294
|
-
for (; Date.now() -
|
|
295
|
-
let r = await
|
|
295
|
+
for (; Date.now() - i < r;) {
|
|
296
|
+
let r = await xe(e, t, n);
|
|
296
297
|
if (r?.status === "RUNNING") return;
|
|
297
|
-
|
|
298
|
+
q(r?.status, r?.errorMessage), await new Promise((e) => setTimeout(e, 2e3));
|
|
298
299
|
}
|
|
299
300
|
throw Error("Sandbox startup timed out");
|
|
300
301
|
}
|
|
301
|
-
async function
|
|
302
|
+
async function Ce(e, t, n, r, i = 9e4, a) {
|
|
302
303
|
let o = Date.now();
|
|
303
304
|
for (; Date.now() - o < i;) {
|
|
304
305
|
try {
|
|
305
|
-
let i = await
|
|
306
|
-
return C.getState().setSandboxWriteCapabilities(e,
|
|
306
|
+
let i = await E(e, t, "/health", "GET", void 0, n, r, "transport");
|
|
307
|
+
return C.getState().setSandboxWriteCapabilities(e, X(i)), i;
|
|
307
308
|
} catch (e) {
|
|
308
309
|
let t = e instanceof Error ? e.message : String(e);
|
|
309
310
|
if (!/proxy error: 502|proxy error: 503|proxy error: 404|service not available|starting/i.test(t)) throw e;
|
|
@@ -313,69 +314,69 @@ async function Se(e, t, n, r, i = 9e4, a) {
|
|
|
313
314
|
}
|
|
314
315
|
throw Error("Assistant service did not become healthy before timeout");
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
+
function J(e) {
|
|
317
318
|
return e === "proposal-v1" ? "proposal-v1" : "legacy";
|
|
318
319
|
}
|
|
319
|
-
function
|
|
320
|
+
function Y(e, t) {
|
|
320
321
|
return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
|
|
321
322
|
}
|
|
322
|
-
var
|
|
323
|
+
var we = new Set([
|
|
323
324
|
"relay",
|
|
324
325
|
"delegated",
|
|
325
326
|
"direct",
|
|
326
327
|
"unconfigured"
|
|
327
328
|
]);
|
|
328
|
-
function
|
|
329
|
+
function X(e) {
|
|
329
330
|
let t = typeof e == "object" && e && !Array.isArray(e) ? e.capabilities : void 0, n = typeof t == "object" && t && !Array.isArray(t) ? t : {}, r = n.writeProposals !== void 0 || n.writeApprovalMode !== void 0 || n.writeExecution !== void 0, i = n.writeRiskVersion, a = n.sessionCredentials;
|
|
330
331
|
return {
|
|
331
332
|
proposals: n.writeProposals === "v1",
|
|
332
|
-
writeApprovalMode:
|
|
333
|
-
writeExecution:
|
|
333
|
+
writeApprovalMode: J(n.writeApprovalMode),
|
|
334
|
+
writeExecution: Y(n.writeExecution, r),
|
|
334
335
|
replyApproval: "off",
|
|
335
336
|
...typeof i == "string" && i ? { writeRiskVersion: i } : {},
|
|
336
|
-
...typeof a == "string" &&
|
|
337
|
+
...typeof a == "string" && we.has(a) ? { sessionCredentials: a } : {},
|
|
337
338
|
...n.uiOffers === 1 ? { uiOffers: !0 } : {}
|
|
338
339
|
};
|
|
339
340
|
}
|
|
340
|
-
async function
|
|
341
|
+
async function Te(e, t, n, r) {
|
|
341
342
|
let i;
|
|
342
343
|
try {
|
|
343
|
-
i = await
|
|
344
|
+
i = await D(e, t, "/health", "GET", void 0, n, r);
|
|
344
345
|
} catch {
|
|
345
346
|
return null;
|
|
346
347
|
}
|
|
347
348
|
let a = i.body;
|
|
348
349
|
if (i.status < 200 || i.status >= 300 || typeof a != "object" || !a || Array.isArray(a)) return null;
|
|
349
|
-
let o =
|
|
350
|
+
let o = X(a);
|
|
350
351
|
return C.getState().setSandboxWriteCapabilities(e, o), o;
|
|
351
352
|
}
|
|
352
|
-
async function
|
|
353
|
-
return { sessionId: (await
|
|
353
|
+
async function Ee(e, t, n, r) {
|
|
354
|
+
return { sessionId: (await E(e, t, "/sessions", "POST", { mode: n }, n, r, "never")).session.id };
|
|
354
355
|
}
|
|
355
|
-
async function
|
|
356
|
-
let a = await
|
|
356
|
+
async function De(e, t, n, r, i) {
|
|
357
|
+
let a = await E(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i, "never");
|
|
357
358
|
if (a?.approved !== !0) throw Error(typeof a?.error == "string" ? a.error : "The change could not be approved. It may have expired — ask the assistant to try again.");
|
|
358
359
|
}
|
|
359
|
-
function
|
|
360
|
-
return i.userId ? e.filter((e) => e.metadata?.authStrategy === "sandbox-app-client-headers-v1" && e.createdBy === i.userId && !(!a.has(e.id) && e.metadata?.assistantProduct === t && h(e, [n]) === n && (!
|
|
360
|
+
function Z(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
361
|
+
return i.userId ? e.filter((e) => e.metadata?.authStrategy === "sandbox-app-client-headers-v1" && e.createdBy === i.userId && !(!a.has(e.id) && e.metadata?.assistantProduct === t && h(e, [n]) === n && (!P(n) || N(e.metadata, o)) && j(e, n, o))).map((e) => e.id) : [];
|
|
361
362
|
}
|
|
362
|
-
async function
|
|
363
|
-
let l,
|
|
363
|
+
async function Oe(e, t, n, r, i, o = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
364
|
+
let l, u = /* @__PURE__ */ new Set();
|
|
364
365
|
try {
|
|
365
|
-
let
|
|
366
|
-
query:
|
|
366
|
+
let d = (await s({
|
|
367
|
+
query: f,
|
|
367
368
|
operationName: "GetActiveSandboxes",
|
|
368
|
-
variables: { context:
|
|
369
|
+
variables: { context: a(e, i) },
|
|
369
370
|
workspaceId: e,
|
|
370
|
-
authContext:
|
|
371
|
+
authContext: i
|
|
371
372
|
})).getActiveSandboxes ?? [];
|
|
372
|
-
|
|
373
|
-
let p =
|
|
374
|
-
if (l =
|
|
373
|
+
R(d);
|
|
374
|
+
let p = V(c);
|
|
375
|
+
if (l = Z(d, t, n, r, i, o, p), p === "proposal-v1") {
|
|
375
376
|
let e = new Set(l);
|
|
376
|
-
for (let t of
|
|
377
|
+
for (let t of d) {
|
|
377
378
|
let n = h(t);
|
|
378
|
-
e.has(t.id) && (n === "assistant" || n === "api-calls") &&
|
|
379
|
+
e.has(t.id) && (n === "assistant" || n === "api-calls") && u.add(t.id);
|
|
379
380
|
}
|
|
380
381
|
}
|
|
381
382
|
} catch {
|
|
@@ -383,20 +384,20 @@ async function De(e, t, n, i, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
|
383
384
|
}
|
|
384
385
|
return (await Promise.all(l.map(async (t) => {
|
|
385
386
|
try {
|
|
386
|
-
return await
|
|
387
|
+
return await ke(t, e, i, { ownerScoped: u.has(t) }), t;
|
|
387
388
|
} catch {
|
|
388
389
|
return null;
|
|
389
390
|
}
|
|
390
391
|
}))).filter((e) => e !== null);
|
|
391
392
|
}
|
|
392
|
-
async function
|
|
393
|
-
if ((i.ownerScoped === !0 ||
|
|
394
|
-
await
|
|
395
|
-
query:
|
|
393
|
+
async function ke(e, t, n, i = {}) {
|
|
394
|
+
if (r(e), (i.ownerScoped === !0 || z(e)) && y("stopMyAssistantSandbox") !== "unsupported") try {
|
|
395
|
+
await s({
|
|
396
|
+
query: ie,
|
|
396
397
|
operationName: "StopMyAssistantSandbox",
|
|
397
398
|
variables: {
|
|
398
399
|
id: e,
|
|
399
|
-
context:
|
|
400
|
+
context: a(t, n)
|
|
400
401
|
},
|
|
401
402
|
workspaceId: t,
|
|
402
403
|
authContext: n
|
|
@@ -406,57 +407,57 @@ async function Z(e, t, n, i = {}) {
|
|
|
406
407
|
if (!b(e, "stopMyAssistantSandbox")) throw e;
|
|
407
408
|
S("stopMyAssistantSandbox");
|
|
408
409
|
}
|
|
409
|
-
await
|
|
410
|
-
query:
|
|
410
|
+
await s({
|
|
411
|
+
query: re,
|
|
411
412
|
operationName: "StopAssistantSandbox",
|
|
412
413
|
variables: {
|
|
413
414
|
id: e,
|
|
414
|
-
context:
|
|
415
|
+
context: a(t, n)
|
|
415
416
|
},
|
|
416
417
|
workspaceId: t,
|
|
417
418
|
authContext: n
|
|
418
419
|
});
|
|
419
420
|
}
|
|
420
|
-
var
|
|
421
|
+
var Ae = /^[A-Za-z0-9_-]{1,128}$/, je = new Set([
|
|
421
422
|
"affirm",
|
|
422
423
|
"decline",
|
|
423
424
|
"other"
|
|
424
|
-
]),
|
|
425
|
+
]), Me = new Set([
|
|
425
426
|
"typed",
|
|
426
427
|
"spoken",
|
|
427
428
|
"chip",
|
|
428
429
|
"host_queued",
|
|
429
430
|
"retry",
|
|
430
431
|
"proposal_result"
|
|
431
|
-
]),
|
|
432
|
-
function
|
|
433
|
-
return !e || !
|
|
432
|
+
]), Ne = /^wp_[0-9a-f]{32}$/;
|
|
433
|
+
function Pe(e) {
|
|
434
|
+
return !e || !je.has(e.kind) || !Me.has(e.origin) ? null : e.proposalId === void 0 ? {
|
|
434
435
|
kind: e.kind,
|
|
435
436
|
origin: e.origin
|
|
436
|
-
} :
|
|
437
|
+
} : Ne.test(e.proposalId) ? {
|
|
437
438
|
kind: e.kind,
|
|
438
439
|
origin: e.origin,
|
|
439
440
|
proposalId: e.proposalId
|
|
440
441
|
} : null;
|
|
441
442
|
}
|
|
442
|
-
function
|
|
443
|
+
function Q(e) {
|
|
443
444
|
let { mode: t, prompt: n, parts: r } = e, i = {
|
|
444
445
|
mode: t,
|
|
445
446
|
prompt: n,
|
|
446
|
-
pageContext:
|
|
447
|
+
pageContext: fe(e.pageContext)
|
|
447
448
|
};
|
|
448
|
-
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" &&
|
|
449
|
-
let a =
|
|
449
|
+
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" && Ae.test(e.conversationId) && (i.conversationId = e.conversationId);
|
|
450
|
+
let a = Pe(e.writeReply);
|
|
450
451
|
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), i;
|
|
451
452
|
}
|
|
452
|
-
function
|
|
453
|
-
return
|
|
453
|
+
function Fe(e) {
|
|
454
|
+
return T(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST", Q(e), e.mode, e.authContext);
|
|
454
455
|
}
|
|
455
|
-
function
|
|
456
|
-
return new TextEncoder().encode(JSON.stringify(
|
|
456
|
+
function $(e) {
|
|
457
|
+
return new TextEncoder().encode(JSON.stringify(Fe(e))).byteLength;
|
|
457
458
|
}
|
|
458
|
-
async function
|
|
459
|
-
if (
|
|
459
|
+
async function Ie(e, t, n, r, i, a, o, s) {
|
|
460
|
+
if ($({
|
|
460
461
|
sandboxId: e,
|
|
461
462
|
workspaceId: t,
|
|
462
463
|
sessionId: n,
|
|
@@ -468,8 +469,8 @@ async function Pe(e, t, n, r, i, a, o, s) {
|
|
|
468
469
|
conversationId: s?.conversationId,
|
|
469
470
|
writeReply: s?.writeReply,
|
|
470
471
|
uiCatalogue: s?.uiCatalogue
|
|
471
|
-
}) > 262144) throw Error(
|
|
472
|
-
let c = await
|
|
472
|
+
}) > 262144) throw Object.assign(Error(pe), { assistantPromptNotDispatched: !0 });
|
|
473
|
+
let c = await E(e, t, `/sessions/${n}/prompt-async`, "POST", Q({
|
|
473
474
|
mode: i,
|
|
474
475
|
prompt: r,
|
|
475
476
|
pageContext: a,
|
|
@@ -477,13 +478,13 @@ async function Pe(e, t, n, r, i, a, o, s) {
|
|
|
477
478
|
conversationId: s?.conversationId,
|
|
478
479
|
writeReply: s?.writeReply,
|
|
479
480
|
uiCatalogue: s?.uiCatalogue
|
|
480
|
-
}), i, o);
|
|
481
|
+
}), i, o, "never");
|
|
481
482
|
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
482
483
|
}
|
|
483
|
-
async function
|
|
484
|
+
async function Le(e, n, r, i, a, o) {
|
|
484
485
|
let s = `/sessions/${r}/messages?limit=${o?.limit ?? 50}`;
|
|
485
486
|
o?.sinceMs && y("sinceParam") !== "unsupported" && (s += `&since=${o.sinceMs}`);
|
|
486
|
-
let c = await
|
|
487
|
+
let c = await E(e, n, s, "GET", void 0, i, a, "transport");
|
|
487
488
|
if (typeof c.now == "number" && x("sinceParam"), o?.surfaceUiOffers) try {
|
|
488
489
|
o.surfaceUiOffers(c.uiOffers, typeof c.now == "number" ? c.now : NaN);
|
|
489
490
|
} catch {}
|
|
@@ -493,10 +494,10 @@ async function Fe(e, n, r, i, a, o) {
|
|
|
493
494
|
}
|
|
494
495
|
return c.messages ?? [];
|
|
495
496
|
}
|
|
496
|
-
async function
|
|
497
|
+
async function Re(e, t, n, r, i) {
|
|
497
498
|
if (y("sse") === "unsupported") return null;
|
|
498
499
|
try {
|
|
499
|
-
let a = await
|
|
500
|
+
let a = await E(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i, "transport");
|
|
500
501
|
return typeof a.url == "string" && typeof a.expiresAt == "number" ? (x("sse"), {
|
|
501
502
|
url: a.url,
|
|
502
503
|
expiresAt: a.expiresAt
|
|
@@ -505,13 +506,13 @@ async function Ie(e, t, n, r, i) {
|
|
|
505
506
|
return S("sse"), null;
|
|
506
507
|
}
|
|
507
508
|
}
|
|
508
|
-
async function
|
|
509
|
-
if (
|
|
509
|
+
async function ze(e, t, n, r, i, a = Date.now) {
|
|
510
|
+
if (de(a())) return null;
|
|
510
511
|
try {
|
|
511
|
-
let { status: o, body: s } = await
|
|
512
|
+
let { status: o, body: s } = await D(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i);
|
|
512
513
|
if (o === 404) return v(_, a()), null;
|
|
513
514
|
let c = o >= 200 && o < 300 && typeof s == "object" && s ? s : null;
|
|
514
|
-
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" &&
|
|
515
|
+
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" && Be(c.url) ? (le(), {
|
|
515
516
|
url: c.url,
|
|
516
517
|
expiresAt: c.expiresAt
|
|
517
518
|
}) : (v(c ? _ : g, a()), null);
|
|
@@ -519,7 +520,7 @@ async function Le(e, t, n, r, i, a = Date.now) {
|
|
|
519
520
|
return v(g, a()), null;
|
|
520
521
|
}
|
|
521
522
|
}
|
|
522
|
-
function
|
|
523
|
+
function Be(e) {
|
|
523
524
|
try {
|
|
524
525
|
let { protocol: t } = new URL(e);
|
|
525
526
|
return t === "https:" || t === "http:";
|
|
@@ -527,58 +528,58 @@ function Re(e) {
|
|
|
527
528
|
return !1;
|
|
528
529
|
}
|
|
529
530
|
}
|
|
530
|
-
async function
|
|
531
|
-
if (
|
|
532
|
-
await
|
|
533
|
-
query:
|
|
531
|
+
async function Ve(e, t, n, r) {
|
|
532
|
+
if (z(e) && y("extendMyAssistantSandboxTTL") !== "unsupported") try {
|
|
533
|
+
await s({
|
|
534
|
+
query: u,
|
|
534
535
|
operationName: "ExtendMyAssistantSandboxTtl",
|
|
535
536
|
variables: {
|
|
536
537
|
id: e,
|
|
537
538
|
additionalSeconds: n,
|
|
538
|
-
context:
|
|
539
|
+
context: a(t, r)
|
|
539
540
|
},
|
|
540
541
|
workspaceId: t,
|
|
541
|
-
authContext:
|
|
542
|
+
authContext: r
|
|
542
543
|
}), x("extendMyAssistantSandboxTTL");
|
|
543
544
|
return;
|
|
544
545
|
} catch (e) {
|
|
545
546
|
if (!b(e, "extendMyAssistantSandboxTTL")) throw e;
|
|
546
547
|
S("extendMyAssistantSandboxTTL");
|
|
547
548
|
}
|
|
548
|
-
await
|
|
549
|
-
query:
|
|
549
|
+
await s({
|
|
550
|
+
query: d,
|
|
550
551
|
operationName: "ExtendSandboxTtl",
|
|
551
552
|
variables: {
|
|
552
553
|
id: e,
|
|
553
554
|
additionalSeconds: n,
|
|
554
|
-
context:
|
|
555
|
+
context: a(t, r)
|
|
555
556
|
},
|
|
556
557
|
workspaceId: t,
|
|
557
|
-
authContext:
|
|
558
|
+
authContext: r
|
|
558
559
|
});
|
|
559
560
|
}
|
|
560
|
-
async function
|
|
561
|
-
await
|
|
561
|
+
async function He(e, t, n, r, i) {
|
|
562
|
+
await E(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r, i, "transport").catch(() => void 0);
|
|
562
563
|
}
|
|
563
|
-
async function
|
|
564
|
+
async function Ue(e, t, n, r, i) {
|
|
564
565
|
try {
|
|
565
|
-
return (await
|
|
566
|
+
return (await E(e, t, `/sessions/${n}/abort`, "POST", void 0, r, i, "never"))?.aborted === !0;
|
|
566
567
|
} catch {
|
|
567
568
|
return !1;
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
|
-
async function
|
|
571
|
-
return ((await
|
|
571
|
+
async function We(e, t, n, r, i) {
|
|
572
|
+
return ((await E(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r, i, "transport")).artifacts ?? []).filter((e) => !e.name.startsWith("."));
|
|
572
573
|
}
|
|
573
|
-
async function
|
|
574
|
-
let a = await
|
|
574
|
+
async function Ge(e, t, n, r, i) {
|
|
575
|
+
let a = await E(e, t, `/sessions/${n}`, "GET", void 0, r, i, "transport");
|
|
575
576
|
return {
|
|
576
577
|
id: a.session?.id ?? n,
|
|
577
578
|
mode: a.mode ?? "unknown"
|
|
578
579
|
};
|
|
579
580
|
}
|
|
580
|
-
async function
|
|
581
|
-
let o = (await
|
|
581
|
+
async function Ke(e, t, n, r, i, a) {
|
|
582
|
+
let o = (await E(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i, a, "transport")).artifact;
|
|
582
583
|
if (!o) throw Error("Artifact download returned an empty response");
|
|
583
584
|
return {
|
|
584
585
|
filename: o.filename,
|
|
@@ -586,30 +587,30 @@ async function We(e, t, n, r, i, a) {
|
|
|
586
587
|
contentBase64: o.contentBase64
|
|
587
588
|
};
|
|
588
589
|
}
|
|
589
|
-
async function
|
|
590
|
-
return (await
|
|
591
|
-
query:
|
|
590
|
+
async function qe(e, t) {
|
|
591
|
+
return (await s({
|
|
592
|
+
query: c,
|
|
592
593
|
operationName: "CheckAiCredits",
|
|
593
594
|
variables: {},
|
|
594
595
|
workspaceId: e,
|
|
595
596
|
authContext: t
|
|
596
597
|
})).checkAiCredits;
|
|
597
598
|
}
|
|
598
|
-
async function
|
|
599
|
-
let c = Math.max(0, Math.round(
|
|
599
|
+
async function Je(e, t, n, r, i, a) {
|
|
600
|
+
let c = Math.max(0, Math.round(i.input ?? 0)), l = Math.max(0, Math.round(i.output ?? 0)), u = Math.max(0, Math.round(i.cache?.read ?? 0)), d = Math.max(0, Math.round(i.cache?.write ?? 0));
|
|
600
601
|
if (c + l + u + d === 0 || !r) return;
|
|
601
602
|
let f = !1;
|
|
602
|
-
if (
|
|
603
|
-
f = (await
|
|
603
|
+
if (i.cache) try {
|
|
604
|
+
f = (await o({
|
|
604
605
|
query: "query AiCacheTokensSupported { aiCacheTokensSupported }",
|
|
605
606
|
operationName: "AiCacheTokensSupported",
|
|
606
607
|
variables: {},
|
|
607
608
|
workspaceId: e,
|
|
608
|
-
authContext:
|
|
609
|
+
authContext: a
|
|
609
610
|
})).aiCacheTokensSupported === !0;
|
|
610
611
|
} catch {}
|
|
611
|
-
await
|
|
612
|
-
query:
|
|
612
|
+
await s({
|
|
613
|
+
query: ne,
|
|
613
614
|
operationName: "ReportAiTokenUsage",
|
|
614
615
|
variables: { input: {
|
|
615
616
|
sessionId: t,
|
|
@@ -623,8 +624,8 @@ async function Ke(e, t, n, r, o, s) {
|
|
|
623
624
|
} : {}
|
|
624
625
|
} },
|
|
625
626
|
workspaceId: e,
|
|
626
|
-
authContext:
|
|
627
|
+
authContext: a
|
|
627
628
|
});
|
|
628
629
|
}
|
|
629
630
|
//#endregion
|
|
630
|
-
export {
|
|
631
|
+
export { Ae as PROMPT_CONVERSATION_ID_PATTERN, Ue as abortAssistantTurn, De as approvePendingWrite, j as askReuseMatchesProvisioning, F as buildAssistantSandboxEnv, Fe as buildPromptGatewayRequest, Q as buildPromptRequestBody, W as buildProvisionAssistantSandboxInput, qe as checkAssistantAiCredits, ye as createAssistantSandbox, Ee as createAssistantSession, Ke as downloadAssistantArtifact, Ve as extendAssistantSandboxTTL, me as findExistingSandbox, O as findExistingSandboxWithStatus, w as forwardsUserTokensToSandbox, We as getAssistantArtifacts, Le as getAssistantMessages, Ge as getAssistantSession, Re as getAssistantStreamAccess, H as isAssistantProvisioningUnavailable, z as isDedicatedAssistantSandbox, L as isDedicatedAssistantSandboxRow, ze as mintAssistantTurnStream, P as modeRequiresConfirmWrites, $ as promptGatewayRequestBytes, D as proxySandboxRaw, X as readSandboxWriteCapabilities, Te as readSandboxWriteCapabilitiesOnce, Oe as releaseSupersededAssistantSandboxes, Je as reportAssistantAiTokenUsage, k as sandboxStatusOf, A as selectExistingAssistantSandbox, Z as selectSupersededAssistantSandboxes, Ie as sendAssistantPromptAsync, He as sendHeartbeat, ke as stopReapedAssistantSandbox, B as usesDedicatedAssistantProvisioning, Ce as waitForAssistantServiceReady, Se as waitForSandboxRunning, J as writeApprovalModeOf, N as writeApprovalReuseMatches, Y as writeExecutionOf };
|