@burdenoff/fe-libs 2026.1001.4 → 2026.1001.5
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/shared/assistant/api.d.ts +12 -0
- package/dist/shared/assistant/api.d.ts.map +1 -1
- package/dist/shared/assistant/api.js +159 -154
- package/dist/shared/assistant/createSandboxAssistantTransport.d.ts.map +1 -1
- package/dist/shared/assistant/createSandboxAssistantTransport.js +4 -1
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/permissionError.d.ts +15 -2
- package/dist/shared/assistant/permissionError.d.ts.map +1 -1
- package/dist/shared/assistant/permissionError.js +24 -14
- package/dist/shared/assistant/progress.d.ts +9 -1
- package/dist/shared/assistant/progress.d.ts.map +1 -1
- package/dist/shared/assistant/progress.js +49 -46
- package/dist/shared/assistant/quota.d.ts +18 -2
- package/dist/shared/assistant/quota.d.ts.map +1 -1
- package/dist/shared/assistant/quota.js +46 -42
- package/dist/shared/assistant/sandboxProxyError.d.ts +91 -0
- package/dist/shared/assistant/sandboxProxyError.d.ts.map +1 -0
- package/dist/shared/assistant/sandboxProxyError.js +43 -0
- package/dist/shared/assistant/transportErrors.d.ts +14 -1
- package/dist/shared/assistant/transportErrors.d.ts.map +1 -1
- package/dist/shared/assistant/transportErrors.js +20 -14
- package/dist/shared/assistant/turnOutcome.d.ts +27 -3
- package/dist/shared/assistant/turnOutcome.d.ts.map +1 -1
- package/dist/shared/assistant/turnOutcome.js +82 -31
- package/dist/shared/assistant/turnOutcomeCopy.d.ts +24 -0
- package/dist/shared/assistant/turnOutcomeCopy.d.ts.map +1 -1
- package/dist/shared/assistant/turnOutcomeCopy.js +24 -0
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +3 -2
- package/dist/shared-assistant.js +180 -179
- package/package.json +1 -1
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { sandboxProxyErrorFromBody as e, sandboxProxyErrorFromTurnTerminal as t } from "./sandboxProxyError.js";
|
|
2
|
+
import { extensionObjectsIn as n } from "./quota.js";
|
|
3
|
+
import { buildSandboxContextInput as r, executeAssistantGraphQLOnce as i, executeSandboxGraphQL as a } from "./gatewayClient.js";
|
|
4
|
+
import { CHECK_AI_CREDITS as o, CREATE_SANDBOX as s, EXTEND_MY_ASSISTANT_SANDBOX_TTL as c, EXTEND_SANDBOX_TTL as l, GET_ACTIVE_SANDBOXES as u, GET_SANDBOX as d, PROVISION_ASSISTANT_SANDBOX as f, PROXY_SANDBOX_REQUEST as p, REPORT_AI_TOKEN_USAGE as ee, STOP_ASSISTANT_SANDBOX as te, STOP_MY_ASSISTANT_SANDBOX as ne, WAIT_FOR_SANDBOX_RUNNING as re } from "./operations.js";
|
|
5
|
+
import { ASSISTANT_API_AUTH_STRATEGY as ie, getImageForMode as m, getImageTagForMode as ae, getResourcesForMode as oe, resolveSandboxAssistantMode as h } from "./images.js";
|
|
6
|
+
import { getCapability as g, isMissingGatewayFieldError as _, isUnknownFieldError as se, markSupported as v, markUnsupported as y } from "./capabilities.js";
|
|
6
7
|
import { useAssistantStore as b } from "./store.js";
|
|
7
|
-
import { REQUEST_TOO_LARGE_REFUSAL as
|
|
8
|
+
import { REQUEST_TOO_LARGE_REFUSAL as ce } from "./gatewayLimits.js";
|
|
8
9
|
//#region src/shared/assistant/api.ts
|
|
9
10
|
function x(e) {
|
|
10
11
|
return e === "assistant" || e === "api-calls";
|
|
11
12
|
}
|
|
12
|
-
function S(e,
|
|
13
|
+
function S(e, t, n, i, a, o, s) {
|
|
13
14
|
return {
|
|
14
|
-
query:
|
|
15
|
+
query: p,
|
|
15
16
|
operationName: "ProxySandboxRequest",
|
|
16
17
|
variables: { input: {
|
|
17
18
|
sandboxId: e,
|
|
18
|
-
path:
|
|
19
|
+
path: n,
|
|
19
20
|
method: i,
|
|
20
21
|
body: a,
|
|
21
|
-
context: t
|
|
22
|
+
context: r(t, s),
|
|
22
23
|
...x(o) ? {
|
|
23
24
|
forwardedAuthToken: s?.accessToken ?? void 0,
|
|
24
25
|
forwardedWorkspaceToken: s?.workspaceToken ?? void 0
|
|
@@ -26,21 +27,21 @@ function S(e, n, r, i, a, o, s) {
|
|
|
26
27
|
} }
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
async function C(
|
|
30
|
-
let
|
|
31
|
-
...S(
|
|
32
|
-
workspaceId:
|
|
33
|
-
authContext:
|
|
30
|
+
async function C(t, n, r, i, o, s, c) {
|
|
31
|
+
let l = (await a({
|
|
32
|
+
...S(t, n, r, i, o, s, c),
|
|
33
|
+
workspaceId: n,
|
|
34
|
+
authContext: c
|
|
34
35
|
})).proxySandboxRequest;
|
|
35
|
-
if (!
|
|
36
|
-
let
|
|
37
|
-
throw
|
|
36
|
+
if (!l || l.status >= 400) {
|
|
37
|
+
let t = l?.body, n = t?.error ?? `Proxy error: ${l?.status ?? "unknown"}`;
|
|
38
|
+
throw e(n, l?.status ?? null, t) ?? Error(n);
|
|
38
39
|
}
|
|
39
|
-
return
|
|
40
|
+
return l.body;
|
|
40
41
|
}
|
|
41
|
-
async function w(e, t,
|
|
42
|
-
let c = (await
|
|
43
|
-
...S(e, t,
|
|
42
|
+
async function w(e, t, n, r, a, o, s) {
|
|
43
|
+
let c = (await i({
|
|
44
|
+
...S(e, t, n, r, a, o, s),
|
|
44
45
|
workspaceId: t,
|
|
45
46
|
authContext: s
|
|
46
47
|
})).proxySandboxRequest;
|
|
@@ -50,22 +51,22 @@ async function w(e, t, r, i, a, o, s) {
|
|
|
50
51
|
body: "body" in c ? c.body ?? null : null
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
|
-
async function
|
|
54
|
+
async function le(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
54
55
|
return (await T(e, t, n, r, i, a, o))?.id ?? null;
|
|
55
56
|
}
|
|
56
|
-
async function T(e, n, i,
|
|
57
|
-
let
|
|
58
|
-
query:
|
|
57
|
+
async function T(e, t, n, i, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
58
|
+
let l = (await a({
|
|
59
|
+
query: u,
|
|
59
60
|
operationName: "GetActiveSandboxes",
|
|
60
|
-
variables: { context:
|
|
61
|
+
variables: { context: r(e, o) },
|
|
61
62
|
workspaceId: e,
|
|
62
63
|
authContext: o
|
|
63
64
|
})).getActiveSandboxes ?? [];
|
|
64
|
-
F(
|
|
65
|
-
let d = D(
|
|
65
|
+
F(l);
|
|
66
|
+
let d = D(l, t, n, i, o, s, R(c));
|
|
66
67
|
return d ? {
|
|
67
68
|
id: d,
|
|
68
|
-
status: E(
|
|
69
|
+
status: E(l, d)
|
|
69
70
|
} : null;
|
|
70
71
|
}
|
|
71
72
|
function E(e, t) {
|
|
@@ -120,14 +121,14 @@ function M(e, t, n, r) {
|
|
|
120
121
|
value: "1"
|
|
121
122
|
}), i;
|
|
122
123
|
}
|
|
123
|
-
var
|
|
124
|
+
var ue = "assistant.errors.assistantProvisioningUnavailable", de = "provisionAssistantSandbox", fe = [
|
|
124
125
|
"ProvisionAssistantSandboxInput",
|
|
125
126
|
"SandboxAssistantMode",
|
|
126
127
|
"SandboxAssistantWriteApproval"
|
|
127
128
|
], N = /* @__PURE__ */ new Set();
|
|
128
129
|
function P(e) {
|
|
129
130
|
let t = e.metadata?.assistantAuth;
|
|
130
|
-
return k(t) && t.provisionedVia ===
|
|
131
|
+
return k(t) && t.provisionedVia === de;
|
|
131
132
|
}
|
|
132
133
|
function F(e) {
|
|
133
134
|
for (let t of e) P(t) && N.add(t.id);
|
|
@@ -141,22 +142,22 @@ function L(e, t) {
|
|
|
141
142
|
function R(e) {
|
|
142
143
|
return G(e) === "proposal-v1" && g("provisionAssistantSandbox") !== "unsupported" ? "proposal-v1" : "legacy";
|
|
143
144
|
}
|
|
144
|
-
function z(
|
|
145
|
-
return e
|
|
145
|
+
function z(e) {
|
|
146
|
+
return n(e).some((e) => e.i18nKey === ue || e.code === "SERVICE_UNAVAILABLE");
|
|
146
147
|
}
|
|
147
148
|
function B(e, t) {
|
|
148
149
|
if (t <= 600) return !1;
|
|
149
150
|
let n = e instanceof Error ? e.message.toLowerCase() : String(e);
|
|
150
151
|
return n.includes("ttl") || n.includes("validation") || n.includes("maximum");
|
|
151
152
|
}
|
|
152
|
-
function V(e,
|
|
153
|
-
if (
|
|
153
|
+
function V(e, t, n, i, a, o) {
|
|
154
|
+
if (t !== "assistant" && t !== "api-calls") throw Error(`Mode ${t} is not provisioned through the assistant path`);
|
|
154
155
|
return {
|
|
155
|
-
mode:
|
|
156
|
+
mode: t === "assistant" ? "ASSISTANT" : "API_CALLS",
|
|
156
157
|
product: e,
|
|
157
|
-
image: m(
|
|
158
|
+
image: m(t, i),
|
|
158
159
|
ttlSeconds: a,
|
|
159
|
-
...
|
|
160
|
+
...t === "api-calls" ? { writeApproval: "PROPOSAL_V1" } : {},
|
|
160
161
|
env: [
|
|
161
162
|
{
|
|
162
163
|
name: "AI_ASSISTANT_PRODUCT",
|
|
@@ -168,24 +169,24 @@ function V(e, n, r, i, a, o) {
|
|
|
168
169
|
},
|
|
169
170
|
{
|
|
170
171
|
name: "WORKSPACE_ID",
|
|
171
|
-
value:
|
|
172
|
+
value: n
|
|
172
173
|
}
|
|
173
174
|
],
|
|
174
|
-
context:
|
|
175
|
+
context: r(n, o)
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
|
-
async function H(e, t, n,
|
|
178
|
-
let s = (await
|
|
179
|
-
query:
|
|
178
|
+
async function H(e, t, n, r, i, o) {
|
|
179
|
+
let s = (await a({
|
|
180
|
+
query: f,
|
|
180
181
|
operationName: "ProvisionAssistantSandbox",
|
|
181
|
-
variables: { input: V(e, t, n,
|
|
182
|
+
variables: { input: V(e, t, n, r, i, o) },
|
|
182
183
|
workspaceId: n,
|
|
183
184
|
authContext: o
|
|
184
185
|
}))?.provisionAssistantSandbox?.id;
|
|
185
186
|
if (!s) throw Error("provisionAssistantSandbox returned empty response");
|
|
186
187
|
return s;
|
|
187
188
|
}
|
|
188
|
-
async function
|
|
189
|
+
async function pe(e, t, n, r, i, a) {
|
|
189
190
|
try {
|
|
190
191
|
return await H(e, t, n, r, i, a);
|
|
191
192
|
} catch (o) {
|
|
@@ -194,27 +195,27 @@ async function de(e, t, n, r, i, a) {
|
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
function U(e) {
|
|
197
|
-
return _(e, "provisionAssistantSandbox",
|
|
198
|
+
return _(e, "provisionAssistantSandbox", fe);
|
|
198
199
|
}
|
|
199
|
-
async function
|
|
200
|
+
async function me(e, t, n, r, i, a, o = {}) {
|
|
200
201
|
if (L(t, o.writeApproval)) try {
|
|
201
|
-
let o = await
|
|
202
|
+
let o = await pe(e, t, n, r, i, a);
|
|
202
203
|
return v("provisionAssistantSandbox"), N.add(o), o;
|
|
203
204
|
} catch (e) {
|
|
204
205
|
if (!U(e)) throw e;
|
|
205
206
|
y("provisionAssistantSandbox");
|
|
206
207
|
}
|
|
207
|
-
return
|
|
208
|
+
return he(e, t, n, r, i, a);
|
|
208
209
|
}
|
|
209
|
-
async function
|
|
210
|
-
let l =
|
|
211
|
-
name: `ai-assistant-${
|
|
212
|
-
description: `AI Assistant sandbox (${
|
|
210
|
+
async function he(e, t, n, i, o, c) {
|
|
211
|
+
let l = oe(t), u = M(e, t, n, c), d = (a) => ({
|
|
212
|
+
name: `ai-assistant-${t}-${Date.now()}`,
|
|
213
|
+
description: `AI Assistant sandbox (${t} mode)`,
|
|
213
214
|
template: "AI_BUILDER",
|
|
214
215
|
mode: "DEPLOYMENT",
|
|
215
216
|
containers: [{
|
|
216
217
|
name: "ai-assistant",
|
|
217
|
-
image: m(
|
|
218
|
+
image: m(t, i),
|
|
218
219
|
ports: [{
|
|
219
220
|
containerPort: 8080,
|
|
220
221
|
name: "http"
|
|
@@ -222,81 +223,81 @@ async function pe(e, n, i, o, s, c) {
|
|
|
222
223
|
env: u
|
|
223
224
|
}],
|
|
224
225
|
resources: l,
|
|
225
|
-
ttlSeconds:
|
|
226
|
+
ttlSeconds: a,
|
|
226
227
|
metadata: {
|
|
227
|
-
assistantMode:
|
|
228
|
+
assistantMode: t,
|
|
228
229
|
assistantProduct: e,
|
|
229
230
|
assistantOwnerUserId: c.userId ?? null,
|
|
230
231
|
assistantOrganizationId: c.organizationId ?? null,
|
|
231
|
-
authStrategy:
|
|
232
|
-
imageTag:
|
|
233
|
-
confirmWrites: j(
|
|
232
|
+
authStrategy: ie,
|
|
233
|
+
imageTag: ae(t, i),
|
|
234
|
+
confirmWrites: j(t)
|
|
234
235
|
},
|
|
235
|
-
context:
|
|
236
|
-
}), f = (e) =>
|
|
237
|
-
query:
|
|
236
|
+
context: r(n, c)
|
|
237
|
+
}), f = (e) => a({
|
|
238
|
+
query: s,
|
|
238
239
|
operationName: "CreateSandbox",
|
|
239
240
|
variables: { input: d(e) },
|
|
240
|
-
workspaceId:
|
|
241
|
+
workspaceId: n,
|
|
241
242
|
authContext: c
|
|
242
243
|
}), p;
|
|
243
244
|
try {
|
|
244
|
-
p = await f(
|
|
245
|
+
p = await f(o);
|
|
245
246
|
} catch (e) {
|
|
246
|
-
if (B(e,
|
|
247
|
+
if (B(e, o)) p = await f(600);
|
|
247
248
|
else throw e;
|
|
248
249
|
}
|
|
249
250
|
if (!p?.createSandbox?.id) throw Error("createSandbox returned empty response");
|
|
250
251
|
return p.createSandbox.id;
|
|
251
252
|
}
|
|
252
|
-
async function
|
|
253
|
-
return (await
|
|
254
|
-
query:
|
|
253
|
+
async function ge(e, t, n) {
|
|
254
|
+
return (await a({
|
|
255
|
+
query: d,
|
|
255
256
|
operationName: "GetSandbox",
|
|
256
257
|
variables: {
|
|
257
258
|
id: e,
|
|
258
|
-
context: t
|
|
259
|
+
context: r(t, n)
|
|
259
260
|
},
|
|
260
|
-
workspaceId:
|
|
261
|
-
authContext:
|
|
261
|
+
workspaceId: t,
|
|
262
|
+
authContext: n
|
|
262
263
|
})).getSandbox;
|
|
263
264
|
}
|
|
264
265
|
function W(e, t) {
|
|
265
266
|
if (e === "FAILED" || e === "STOPPED" || e === "EXPIRED") throw Error(t ? `Sandbox ${e.toLowerCase()}: ${t}` : `Sandbox ${e.toLowerCase()}`);
|
|
266
267
|
}
|
|
267
|
-
async function
|
|
268
|
+
async function _e(e, t, n, i = 3e5) {
|
|
268
269
|
let o = Date.now();
|
|
269
|
-
if (g("waitForSandboxRunning") !== "unsupported") for (; Date.now() - o <
|
|
270
|
-
let
|
|
271
|
-
query:
|
|
270
|
+
if (g("waitForSandboxRunning") !== "unsupported") for (; Date.now() - o < i;) try {
|
|
271
|
+
let i = await a({
|
|
272
|
+
query: re,
|
|
272
273
|
operationName: "WaitForSandboxRunning",
|
|
273
274
|
variables: {
|
|
274
275
|
id: e,
|
|
275
276
|
timeoutSeconds: 25,
|
|
276
|
-
context: t
|
|
277
|
+
context: r(t, n)
|
|
277
278
|
},
|
|
278
|
-
workspaceId:
|
|
279
|
-
authContext:
|
|
279
|
+
workspaceId: t,
|
|
280
|
+
authContext: n
|
|
280
281
|
});
|
|
281
282
|
v("waitForSandboxRunning");
|
|
282
|
-
let o =
|
|
283
|
+
let o = i.waitForSandboxRunning;
|
|
283
284
|
if (o?.status === "RUNNING") return;
|
|
284
285
|
W(o?.status, o?.errorMessage);
|
|
285
286
|
} catch (e) {
|
|
286
|
-
if (
|
|
287
|
+
if (se(e)) {
|
|
287
288
|
y("waitForSandboxRunning");
|
|
288
289
|
break;
|
|
289
290
|
}
|
|
290
291
|
throw e;
|
|
291
292
|
}
|
|
292
|
-
for (; Date.now() - o <
|
|
293
|
-
let
|
|
294
|
-
if (
|
|
295
|
-
W(
|
|
293
|
+
for (; Date.now() - o < i;) {
|
|
294
|
+
let r = await ge(e, t, n);
|
|
295
|
+
if (r?.status === "RUNNING") return;
|
|
296
|
+
W(r?.status, r?.errorMessage), await new Promise((e) => setTimeout(e, 2e3));
|
|
296
297
|
}
|
|
297
298
|
throw Error("Sandbox startup timed out");
|
|
298
299
|
}
|
|
299
|
-
async function
|
|
300
|
+
async function ve(e, t, n, r, i = 9e4, a) {
|
|
300
301
|
let o = Date.now();
|
|
301
302
|
for (; Date.now() - o < i;) {
|
|
302
303
|
try {
|
|
@@ -317,7 +318,7 @@ function G(e) {
|
|
|
317
318
|
function K(e, t) {
|
|
318
319
|
return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
|
|
319
320
|
}
|
|
320
|
-
var
|
|
321
|
+
var ye = new Set([
|
|
321
322
|
"relay",
|
|
322
323
|
"delegated",
|
|
323
324
|
"direct",
|
|
@@ -331,10 +332,10 @@ function q(e) {
|
|
|
331
332
|
writeExecution: K(n.writeExecution, r),
|
|
332
333
|
replyApproval: "off",
|
|
333
334
|
...typeof i == "string" && i ? { writeRiskVersion: i } : {},
|
|
334
|
-
...typeof a == "string" &&
|
|
335
|
+
...typeof a == "string" && ye.has(a) ? { sessionCredentials: a } : {}
|
|
335
336
|
};
|
|
336
337
|
}
|
|
337
|
-
async function
|
|
338
|
+
async function be(e, t, n, r) {
|
|
338
339
|
let i;
|
|
339
340
|
try {
|
|
340
341
|
i = await w(e, t, "/health", "GET", void 0, n, r);
|
|
@@ -346,30 +347,30 @@ async function ve(e, t, n, r) {
|
|
|
346
347
|
let o = q(a);
|
|
347
348
|
return b.getState().setSandboxWriteCapabilities(e, o), o;
|
|
348
349
|
}
|
|
349
|
-
async function
|
|
350
|
+
async function xe(e, t, n, r) {
|
|
350
351
|
return { sessionId: (await C(e, t, "/sessions", "POST", { mode: n }, n, r)).session.id };
|
|
351
352
|
}
|
|
352
|
-
async function
|
|
353
|
+
async function Se(e, t, n, r, i) {
|
|
353
354
|
let a = await C(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i);
|
|
354
355
|
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.");
|
|
355
356
|
}
|
|
356
357
|
function J(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
357
358
|
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 && (!j(n) || A(e.metadata, o)) && O(e, n, o))).map((e) => e.id) : [];
|
|
358
359
|
}
|
|
359
|
-
async function
|
|
360
|
-
let
|
|
360
|
+
async function Ce(e, t, n, i, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
361
|
+
let l, d = /* @__PURE__ */ new Set();
|
|
361
362
|
try {
|
|
362
|
-
let f = (await
|
|
363
|
-
query:
|
|
363
|
+
let f = (await a({
|
|
364
|
+
query: u,
|
|
364
365
|
operationName: "GetActiveSandboxes",
|
|
365
|
-
variables: { context:
|
|
366
|
+
variables: { context: r(e, o) },
|
|
366
367
|
workspaceId: e,
|
|
367
368
|
authContext: o
|
|
368
369
|
})).getActiveSandboxes ?? [];
|
|
369
370
|
F(f);
|
|
370
|
-
let p = R(
|
|
371
|
-
if (
|
|
372
|
-
let e = new Set(
|
|
371
|
+
let p = R(c);
|
|
372
|
+
if (l = J(f, t, n, i, o, s, p), p === "proposal-v1") {
|
|
373
|
+
let e = new Set(l);
|
|
373
374
|
for (let t of f) {
|
|
374
375
|
let n = h(t);
|
|
375
376
|
e.has(t.id) && (n === "assistant" || n === "api-calls") && d.add(t.id);
|
|
@@ -378,7 +379,7 @@ async function xe(e, n, i, a, o, s = /* @__PURE__ */ new Set(), l = "legacy") {
|
|
|
378
379
|
} catch {
|
|
379
380
|
return [];
|
|
380
381
|
}
|
|
381
|
-
return (await Promise.all(
|
|
382
|
+
return (await Promise.all(l.map(async (t) => {
|
|
382
383
|
try {
|
|
383
384
|
return await Y(t, e, o, { ownerScoped: d.has(t) }), t;
|
|
384
385
|
} catch {
|
|
@@ -386,51 +387,51 @@ async function xe(e, n, i, a, o, s = /* @__PURE__ */ new Set(), l = "legacy") {
|
|
|
386
387
|
}
|
|
387
388
|
}))).filter((e) => e !== null);
|
|
388
389
|
}
|
|
389
|
-
async function Y(e, n, i
|
|
390
|
-
if ((
|
|
391
|
-
await
|
|
392
|
-
query:
|
|
390
|
+
async function Y(e, t, n, i = {}) {
|
|
391
|
+
if ((i.ownerScoped === !0 || I(e)) && g("stopMyAssistantSandbox") !== "unsupported") try {
|
|
392
|
+
await a({
|
|
393
|
+
query: ne,
|
|
393
394
|
operationName: "StopMyAssistantSandbox",
|
|
394
395
|
variables: {
|
|
395
396
|
id: e,
|
|
396
|
-
context: t
|
|
397
|
+
context: r(t, n)
|
|
397
398
|
},
|
|
398
|
-
workspaceId:
|
|
399
|
-
authContext:
|
|
399
|
+
workspaceId: t,
|
|
400
|
+
authContext: n
|
|
400
401
|
}), v("stopMyAssistantSandbox");
|
|
401
402
|
return;
|
|
402
403
|
} catch (e) {
|
|
403
404
|
if (!_(e, "stopMyAssistantSandbox")) throw e;
|
|
404
405
|
y("stopMyAssistantSandbox");
|
|
405
406
|
}
|
|
406
|
-
await
|
|
407
|
-
query:
|
|
407
|
+
await a({
|
|
408
|
+
query: te,
|
|
408
409
|
operationName: "StopAssistantSandbox",
|
|
409
410
|
variables: {
|
|
410
411
|
id: e,
|
|
411
|
-
context: t
|
|
412
|
+
context: r(t, n)
|
|
412
413
|
},
|
|
413
|
-
workspaceId:
|
|
414
|
-
authContext:
|
|
414
|
+
workspaceId: t,
|
|
415
|
+
authContext: n
|
|
415
416
|
});
|
|
416
417
|
}
|
|
417
|
-
var X = /^[A-Za-z0-9_-]{1,128}$/,
|
|
418
|
+
var X = /^[A-Za-z0-9_-]{1,128}$/, we = new Set([
|
|
418
419
|
"affirm",
|
|
419
420
|
"decline",
|
|
420
421
|
"other"
|
|
421
|
-
]),
|
|
422
|
+
]), Te = new Set([
|
|
422
423
|
"typed",
|
|
423
424
|
"spoken",
|
|
424
425
|
"chip",
|
|
425
426
|
"host_queued",
|
|
426
427
|
"retry",
|
|
427
428
|
"proposal_result"
|
|
428
|
-
]),
|
|
429
|
-
function
|
|
430
|
-
return !e || !
|
|
429
|
+
]), Ee = /^wp_[0-9a-f]{32}$/;
|
|
430
|
+
function De(e) {
|
|
431
|
+
return !e || !we.has(e.kind) || !Te.has(e.origin) ? null : e.proposalId === void 0 ? {
|
|
431
432
|
kind: e.kind,
|
|
432
433
|
origin: e.origin
|
|
433
|
-
} :
|
|
434
|
+
} : Ee.test(e.proposalId) ? {
|
|
434
435
|
kind: e.kind,
|
|
435
436
|
origin: e.origin,
|
|
436
437
|
proposalId: e.proposalId
|
|
@@ -443,7 +444,7 @@ function Z(e) {
|
|
|
443
444
|
pageContext: r
|
|
444
445
|
};
|
|
445
446
|
i && i.length > 0 && (a.parts = i), typeof e.conversationId == "string" && X.test(e.conversationId) && (a.conversationId = e.conversationId);
|
|
446
|
-
let o =
|
|
447
|
+
let o = De(e.writeReply);
|
|
447
448
|
return o && (a.writeReply = o), a;
|
|
448
449
|
}
|
|
449
450
|
function Q(e) {
|
|
@@ -452,7 +453,7 @@ function Q(e) {
|
|
|
452
453
|
function $(e) {
|
|
453
454
|
return new TextEncoder().encode(JSON.stringify(Q(e))).byteLength;
|
|
454
455
|
}
|
|
455
|
-
async function
|
|
456
|
+
async function Oe(e, t, n, r, i, a, o, s) {
|
|
456
457
|
if ($({
|
|
457
458
|
sandboxId: e,
|
|
458
459
|
workspaceId: t,
|
|
@@ -464,7 +465,7 @@ async function Ee(e, t, n, r, i, a, o, s) {
|
|
|
464
465
|
parts: s?.parts,
|
|
465
466
|
conversationId: s?.conversationId,
|
|
466
467
|
writeReply: s?.writeReply
|
|
467
|
-
}) > 262144) throw Error(
|
|
468
|
+
}) > 262144) throw Error(ce);
|
|
468
469
|
let c = await C(e, t, `/sessions/${n}/prompt-async`, "POST", Z({
|
|
469
470
|
mode: i,
|
|
470
471
|
prompt: r,
|
|
@@ -475,13 +476,17 @@ async function Ee(e, t, n, r, i, a, o, s) {
|
|
|
475
476
|
}), i, o);
|
|
476
477
|
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
477
478
|
}
|
|
478
|
-
async function
|
|
479
|
-
let
|
|
480
|
-
|
|
481
|
-
let
|
|
482
|
-
|
|
479
|
+
async function ke(e, n, r, i, a, o) {
|
|
480
|
+
let s = `/sessions/${r}/messages?limit=${o?.limit ?? 50}`;
|
|
481
|
+
o?.sinceMs && g("sinceParam") !== "unsupported" && (s += `&since=${o.sinceMs}`);
|
|
482
|
+
let c = await C(e, n, s, "GET", void 0, i, a);
|
|
483
|
+
if (typeof c.now == "number" && v("sinceParam"), o?.surfaceTurnTerminal === !0) {
|
|
484
|
+
let e = t(c.turnTerminal);
|
|
485
|
+
if (e) throw e;
|
|
486
|
+
}
|
|
487
|
+
return c.messages ?? [];
|
|
483
488
|
}
|
|
484
|
-
async function
|
|
489
|
+
async function Ae(e, t, n, r, i) {
|
|
485
490
|
if (g("sse") === "unsupported") return null;
|
|
486
491
|
try {
|
|
487
492
|
let a = await C(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i);
|
|
@@ -493,57 +498,57 @@ async function Oe(e, t, n, r, i) {
|
|
|
493
498
|
return y("sse"), null;
|
|
494
499
|
}
|
|
495
500
|
}
|
|
496
|
-
async function
|
|
501
|
+
async function je(e, t, n, i) {
|
|
497
502
|
if (I(e) && g("extendMyAssistantSandboxTTL") !== "unsupported") try {
|
|
498
|
-
await
|
|
499
|
-
query:
|
|
503
|
+
await a({
|
|
504
|
+
query: c,
|
|
500
505
|
operationName: "ExtendMyAssistantSandboxTtl",
|
|
501
506
|
variables: {
|
|
502
507
|
id: e,
|
|
503
|
-
additionalSeconds:
|
|
504
|
-
context: t
|
|
508
|
+
additionalSeconds: n,
|
|
509
|
+
context: r(t, i)
|
|
505
510
|
},
|
|
506
|
-
workspaceId:
|
|
507
|
-
authContext:
|
|
511
|
+
workspaceId: t,
|
|
512
|
+
authContext: i
|
|
508
513
|
}), v("extendMyAssistantSandboxTTL");
|
|
509
514
|
return;
|
|
510
515
|
} catch (e) {
|
|
511
516
|
if (!_(e, "extendMyAssistantSandboxTTL")) throw e;
|
|
512
517
|
y("extendMyAssistantSandboxTTL");
|
|
513
518
|
}
|
|
514
|
-
await
|
|
515
|
-
query:
|
|
519
|
+
await a({
|
|
520
|
+
query: l,
|
|
516
521
|
operationName: "ExtendSandboxTtl",
|
|
517
522
|
variables: {
|
|
518
523
|
id: e,
|
|
519
|
-
additionalSeconds:
|
|
520
|
-
context: t
|
|
524
|
+
additionalSeconds: n,
|
|
525
|
+
context: r(t, i)
|
|
521
526
|
},
|
|
522
|
-
workspaceId:
|
|
523
|
-
authContext:
|
|
527
|
+
workspaceId: t,
|
|
528
|
+
authContext: i
|
|
524
529
|
});
|
|
525
530
|
}
|
|
526
|
-
async function
|
|
531
|
+
async function Me(e, t, n, r, i) {
|
|
527
532
|
await C(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r, i).catch(() => void 0);
|
|
528
533
|
}
|
|
529
|
-
async function
|
|
534
|
+
async function Ne(e, t, n, r, i) {
|
|
530
535
|
try {
|
|
531
536
|
return (await C(e, t, `/sessions/${n}/abort`, "POST", void 0, r, i))?.aborted === !0;
|
|
532
537
|
} catch {
|
|
533
538
|
return !1;
|
|
534
539
|
}
|
|
535
540
|
}
|
|
536
|
-
async function
|
|
541
|
+
async function Pe(e, t, n, r, i) {
|
|
537
542
|
return ((await C(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r, i)).artifacts ?? []).filter((e) => !e.name.startsWith("."));
|
|
538
543
|
}
|
|
539
|
-
async function
|
|
544
|
+
async function Fe(e, t, n, r, i) {
|
|
540
545
|
let a = await C(e, t, `/sessions/${n}`, "GET", void 0, r, i);
|
|
541
546
|
return {
|
|
542
547
|
id: a.session?.id ?? n,
|
|
543
548
|
mode: a.mode ?? "unknown"
|
|
544
549
|
};
|
|
545
550
|
}
|
|
546
|
-
async function
|
|
551
|
+
async function Ie(e, t, n, r, i, a) {
|
|
547
552
|
let o = (await C(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i, a)).artifact;
|
|
548
553
|
if (!o) throw Error("Artifact download returned an empty response");
|
|
549
554
|
return {
|
|
@@ -552,24 +557,24 @@ async function Pe(e, t, n, r, i, a) {
|
|
|
552
557
|
contentBase64: o.contentBase64
|
|
553
558
|
};
|
|
554
559
|
}
|
|
555
|
-
async function
|
|
556
|
-
return (await
|
|
557
|
-
query:
|
|
560
|
+
async function Le(e, t) {
|
|
561
|
+
return (await a({
|
|
562
|
+
query: o,
|
|
558
563
|
operationName: "CheckAiCredits",
|
|
559
564
|
variables: {},
|
|
560
565
|
workspaceId: e,
|
|
561
566
|
authContext: t
|
|
562
567
|
})).checkAiCredits;
|
|
563
568
|
}
|
|
564
|
-
async function
|
|
565
|
-
let s = Math.max(0, Math.round(
|
|
566
|
-
s + c === 0 || !
|
|
567
|
-
query:
|
|
569
|
+
async function Re(e, t, n, r, i, o) {
|
|
570
|
+
let s = Math.max(0, Math.round(i.input ?? 0)), c = Math.max(0, Math.round(i.output ?? 0));
|
|
571
|
+
s + c === 0 || !r || await a({
|
|
572
|
+
query: ee,
|
|
568
573
|
operationName: "ReportAiTokenUsage",
|
|
569
574
|
variables: { input: {
|
|
570
575
|
sessionId: t,
|
|
571
576
|
messageId: n,
|
|
572
|
-
model:
|
|
577
|
+
model: r,
|
|
573
578
|
inputTokens: s,
|
|
574
579
|
outputTokens: c
|
|
575
580
|
} },
|
|
@@ -578,4 +583,4 @@ async function Ie(e, t, n, i, a, o) {
|
|
|
578
583
|
});
|
|
579
584
|
}
|
|
580
585
|
//#endregion
|
|
581
|
-
export { X as PROMPT_CONVERSATION_ID_PATTERN,
|
|
586
|
+
export { X as PROMPT_CONVERSATION_ID_PATTERN, Ne as abortAssistantTurn, Se as approvePendingWrite, O as askReuseMatchesProvisioning, M as buildAssistantSandboxEnv, Q as buildPromptGatewayRequest, Z as buildPromptRequestBody, V as buildProvisionAssistantSandboxInput, Le as checkAssistantAiCredits, me as createAssistantSandbox, xe as createAssistantSession, Ie as downloadAssistantArtifact, je as extendAssistantSandboxTTL, le as findExistingSandbox, T as findExistingSandboxWithStatus, x as forwardsUserTokensToSandbox, Pe as getAssistantArtifacts, ke as getAssistantMessages, Fe as getAssistantSession, Ae as getAssistantStreamAccess, z as isAssistantProvisioningUnavailable, I as isDedicatedAssistantSandbox, P as isDedicatedAssistantSandboxRow, j as modeRequiresConfirmWrites, $ as promptGatewayRequestBytes, w as proxySandboxRaw, q as readSandboxWriteCapabilities, be as readSandboxWriteCapabilitiesOnce, Ce as releaseSupersededAssistantSandboxes, Re as reportAssistantAiTokenUsage, E as sandboxStatusOf, D as selectExistingAssistantSandbox, J as selectSupersededAssistantSandboxes, Oe as sendAssistantPromptAsync, Me as sendHeartbeat, Y as stopReapedAssistantSandbox, L as usesDedicatedAssistantProvisioning, ve as waitForAssistantServiceReady, _e as waitForSandboxRunning, G as writeApprovalModeOf, A as writeApprovalReuseMatches, K as writeExecutionOf };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSandboxAssistantTransport.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/createSandboxAssistantTransport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH,OAAO,KAAK,EAGV,2BAA2B,EAE3B,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,2BAA2B,CAAC;IAClD,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B;AAYD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,aAAa,GAClB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"createSandboxAssistantTransport.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/createSandboxAssistantTransport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH,OAAO,KAAK,EAGV,2BAA2B,EAE3B,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,2BAA2B,CAAC;IAClD,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B;AAYD,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,aAAa,GAClB,yBAAyB,CAmO3B"}
|
|
@@ -56,7 +56,10 @@ function C(C, w) {
|
|
|
56
56
|
}), _ = l + E, v = [], S = c([], l, D), w = l;
|
|
57
57
|
for (; Date.now() < _;) {
|
|
58
58
|
if (e.signal.aborted) throw Error("Cancelled");
|
|
59
|
-
let r = await n(o, t, s, T, i, {
|
|
59
|
+
let r = await n(o, t, s, T, i, {
|
|
60
|
+
sinceMs: w,
|
|
61
|
+
surfaceTurnTerminal: !0
|
|
62
|
+
});
|
|
60
63
|
v = d(v, r);
|
|
61
64
|
for (let e of r) {
|
|
62
65
|
let t = e.info?.time?.created;
|
|
@@ -185,6 +185,7 @@ export * from './useAssistantApiAccess';
|
|
|
185
185
|
export * from './useConversationTurns';
|
|
186
186
|
export * from './transportErrors';
|
|
187
187
|
export * from './quota';
|
|
188
|
+
export * from './sandboxProxyError';
|
|
188
189
|
export * from './permissionError';
|
|
189
190
|
export * from './autoRouting';
|
|
190
191
|
export * from './turnOutcome';
|