@burdenoff/fe-libs 2026.1027.10 → 2026.1027.11
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.js +154 -125
- package/dist/shared/assistant/capabilities.d.ts +1 -0
- package/dist/shared/assistant/capabilities.js +1 -0
- package/dist/shared/assistant/operations.d.ts +1 -0
- package/dist/shared/assistant/operations.js +2 -2
- package/dist/shared/assistant/voice/assistantPollSchedule.d.ts +5 -9
- package/dist/shared-assistant.js +308 -308
- package/package.json +1 -1
|
@@ -2,12 +2,12 @@ import { SandboxProxyError as e, sandboxProxyErrorFromBody as t, sandboxProxyErr
|
|
|
2
2
|
import { extensionObjectsIn as r } from "./quota.js";
|
|
3
3
|
import { abandonAssistantSandboxTurns as i, withAssistantProxyResponse as a } from "./promptDelivery.js";
|
|
4
4
|
import { buildSandboxContextInput as o, executeAssistantGraphQLOnce as s, executeSandboxGraphQL as c } from "./gatewayClient.js";
|
|
5
|
-
import { CHECK_AI_CREDITS as l, CREATE_SANDBOX as u, EXTEND_MY_ASSISTANT_SANDBOX_TTL as d, EXTEND_SANDBOX_TTL as f, GET_ACTIVE_SANDBOXES as p, GET_SANDBOX as ee, PROVISION_ASSISTANT_SANDBOX as te, PROXY_SANDBOX_REQUEST as ne, REPORT_AI_TOKEN_USAGE as re, STOP_ASSISTANT_SANDBOX as ie, STOP_MY_ASSISTANT_SANDBOX as ae,
|
|
6
|
-
import { ASSISTANT_API_AUTH_STRATEGY as
|
|
7
|
-
import { STREAM_MINT_BACKOFF_ERROR_MS as g, STREAM_MINT_BACKOFF_UNAVAILABLE_MS as _, backOffStreamMint as v, clearStreamMintBackoff as
|
|
8
|
-
import { filterAssistantPageContext as
|
|
5
|
+
import { CHECK_AI_CREDITS as l, CREATE_SANDBOX as u, EXTEND_MY_ASSISTANT_SANDBOX_TTL as d, EXTEND_SANDBOX_TTL as f, GET_ACTIVE_SANDBOXES as p, GET_SANDBOX as ee, PROVISION_ASSISTANT_SANDBOX as te, PROXY_SANDBOX_REQUEST as ne, REPORT_AI_TOKEN_USAGE as re, STOP_ASSISTANT_SANDBOX as ie, STOP_MY_ASSISTANT_SANDBOX as ae, WAIT_FOR_ASSISTANT_READY as oe, WAIT_FOR_SANDBOX_RUNNING as se } from "./operations.js";
|
|
6
|
+
import { ASSISTANT_API_AUTH_STRATEGY as ce, getImageForMode as m, getImageTagForMode as le, getResourcesForMode as ue, 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 de, getCapability as y, isMissingGatewayFieldError as b, isUnknownFieldError as fe, markSupported as x, markUnsupported as S, streamMintBackedOff as pe } from "./capabilities.js";
|
|
8
|
+
import { filterAssistantPageContext as me } from "./pageContextKeys.js";
|
|
9
9
|
import { useAssistantStore as C } from "./store.js";
|
|
10
|
-
import { REQUEST_TOO_LARGE_REFUSAL as
|
|
10
|
+
import { REQUEST_TOO_LARGE_REFUSAL as he } from "./gatewayLimits.js";
|
|
11
11
|
//#region src/shared/assistant/api.ts
|
|
12
12
|
function w(e) {
|
|
13
13
|
return e === "assistant" || e === "api-calls";
|
|
@@ -53,10 +53,10 @@ async function D(e, t, n, r, i, a, o) {
|
|
|
53
53
|
body: "body" in c ? c.body ?? null : null
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
async function
|
|
57
|
-
return (await
|
|
56
|
+
async function ge(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
57
|
+
return (await _e(e, t, n, r, i, a, o))?.id ?? null;
|
|
58
58
|
}
|
|
59
|
-
async function
|
|
59
|
+
async function _e(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
60
60
|
let l = (await c({
|
|
61
61
|
query: p,
|
|
62
62
|
operationName: "GetActiveSandboxes",
|
|
@@ -64,33 +64,33 @@ async function O(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
|
64
64
|
workspaceId: e,
|
|
65
65
|
authContext: i
|
|
66
66
|
})).getActiveSandboxes ?? [];
|
|
67
|
-
|
|
68
|
-
let u =
|
|
67
|
+
L(l);
|
|
68
|
+
let u = k(l, t, n, r, i, a, B(s));
|
|
69
69
|
return u ? {
|
|
70
70
|
id: u,
|
|
71
|
-
status:
|
|
71
|
+
status: O(l, u)
|
|
72
72
|
} : null;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function O(e, t) {
|
|
75
75
|
return e.find((e) => e.id === t)?.status ?? "UNKNOWN";
|
|
76
76
|
}
|
|
77
|
-
function
|
|
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 && (!
|
|
77
|
+
function k(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 && (!N(n) || M(e.metadata, o)) && A(e, n, o))?.id ?? null;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
return t !== "assistant" || n !== "proposal-v1" ? !0 :
|
|
80
|
+
function A(e, t, n) {
|
|
81
|
+
return t !== "assistant" || n !== "proposal-v1" ? !0 : I(e);
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function j(e) {
|
|
84
84
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function M(e, t) {
|
|
87
87
|
let n = e?.assistantAuth;
|
|
88
|
-
return
|
|
88
|
+
return j(n) && n.accessProfile === "member" ? !0 : (e?.writeApproval ?? "legacy") === t ? e?.confirmWrites === (t === "proposal-v1" ? "proposal-v1" : !0) : !1;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function N(e) {
|
|
91
91
|
return e === "api-calls";
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function P(e, t, n, r) {
|
|
94
94
|
let i = [
|
|
95
95
|
{
|
|
96
96
|
name: "AI_ASSISTANT_MODE",
|
|
@@ -118,41 +118,41 @@ function F(e, t, n, r) {
|
|
|
118
118
|
}), r.workspaceToken && i.push({
|
|
119
119
|
name: "WORKSPACE_AUTH_TOKEN",
|
|
120
120
|
value: r.workspaceToken
|
|
121
|
-
})),
|
|
121
|
+
})), N(t) && i.push({
|
|
122
122
|
name: "AI_ASSISTANT_CONFIRM_WRITES",
|
|
123
123
|
value: "1"
|
|
124
124
|
}), i;
|
|
125
125
|
}
|
|
126
|
-
var
|
|
126
|
+
var ve = "assistant.errors.assistantProvisioningUnavailable", ye = "provisionAssistantSandbox", be = [
|
|
127
127
|
"ProvisionAssistantSandboxInput",
|
|
128
128
|
"SandboxAssistantMode",
|
|
129
129
|
"SandboxAssistantWriteApproval"
|
|
130
|
-
],
|
|
131
|
-
function
|
|
130
|
+
], F = /* @__PURE__ */ new Set();
|
|
131
|
+
function I(e) {
|
|
132
132
|
let t = e.metadata?.assistantAuth;
|
|
133
|
-
return
|
|
133
|
+
return j(t) && t.provisionedVia === ye;
|
|
134
|
+
}
|
|
135
|
+
function L(e) {
|
|
136
|
+
for (let t of e) I(t) && F.add(t.id);
|
|
134
137
|
}
|
|
135
138
|
function R(e) {
|
|
136
|
-
|
|
139
|
+
return F.has(e);
|
|
137
140
|
}
|
|
138
|
-
function z(e) {
|
|
139
|
-
return
|
|
141
|
+
function z(e, t) {
|
|
142
|
+
return q(t) === "proposal-v1" && (e === "assistant" || e === "api-calls") && y("provisionAssistantSandbox") !== "unsupported";
|
|
140
143
|
}
|
|
141
|
-
function B(e
|
|
142
|
-
return
|
|
144
|
+
function B(e) {
|
|
145
|
+
return q(e) === "proposal-v1" && y("provisionAssistantSandbox") !== "unsupported" ? "proposal-v1" : "legacy";
|
|
143
146
|
}
|
|
144
147
|
function V(e) {
|
|
145
|
-
return
|
|
148
|
+
return r(e).some((e) => e.i18nKey === ve || e.code === "SERVICE_UNAVAILABLE");
|
|
146
149
|
}
|
|
147
|
-
function H(e) {
|
|
148
|
-
return r(e).some((e) => e.i18nKey === ge || e.code === "SERVICE_UNAVAILABLE");
|
|
149
|
-
}
|
|
150
|
-
function U(e, t) {
|
|
150
|
+
function H(e, t) {
|
|
151
151
|
if (t <= 600) return !1;
|
|
152
152
|
let n = e instanceof Error ? e.message.toLowerCase() : String(e);
|
|
153
153
|
return n.includes("ttl") || n.includes("validation") || n.includes("maximum");
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function U(e, t, n, r, i, a) {
|
|
156
156
|
if (t !== "assistant" && t !== "api-calls") throw Error(`Mode ${t} is not provisioned through the assistant path`);
|
|
157
157
|
return {
|
|
158
158
|
mode: t === "assistant" ? "ASSISTANT" : "API_CALLS",
|
|
@@ -177,40 +177,40 @@ function W(e, t, n, r, i, a) {
|
|
|
177
177
|
context: o(n, a)
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
async function
|
|
180
|
+
async function W(e, t, n, r, i, a) {
|
|
181
181
|
let o = (await c({
|
|
182
182
|
query: te,
|
|
183
183
|
operationName: "ProvisionAssistantSandbox",
|
|
184
|
-
variables: { input:
|
|
184
|
+
variables: { input: U(e, t, n, r, i, a) },
|
|
185
185
|
workspaceId: n,
|
|
186
186
|
authContext: a
|
|
187
187
|
}))?.provisionAssistantSandbox?.id;
|
|
188
188
|
if (!o) throw Error("provisionAssistantSandbox returned empty response");
|
|
189
189
|
return o;
|
|
190
190
|
}
|
|
191
|
-
async function
|
|
191
|
+
async function xe(e, t, n, r, i, a) {
|
|
192
192
|
try {
|
|
193
|
-
return await
|
|
193
|
+
return await W(e, t, n, r, i, a);
|
|
194
194
|
} catch (o) {
|
|
195
|
-
if (
|
|
196
|
-
return
|
|
195
|
+
if (V(o) || G(o) || !H(o, i)) throw o;
|
|
196
|
+
return W(e, t, n, r, 600, a);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return b(e, "provisionAssistantSandbox",
|
|
199
|
+
function G(e) {
|
|
200
|
+
return b(e, "provisionAssistantSandbox", be);
|
|
201
201
|
}
|
|
202
|
-
async function
|
|
203
|
-
if (
|
|
204
|
-
let o = await
|
|
205
|
-
return x("provisionAssistantSandbox"),
|
|
202
|
+
async function Se(e, t, n, r, i, a, o = {}) {
|
|
203
|
+
if (z(t, o.writeApproval)) try {
|
|
204
|
+
let o = await xe(e, t, n, r, i, a);
|
|
205
|
+
return x("provisionAssistantSandbox"), F.add(o), o;
|
|
206
206
|
} catch (e) {
|
|
207
|
-
if (!
|
|
207
|
+
if (!G(e)) throw e;
|
|
208
208
|
S("provisionAssistantSandbox");
|
|
209
209
|
}
|
|
210
|
-
return
|
|
210
|
+
return Ce(e, t, n, r, i, a);
|
|
211
211
|
}
|
|
212
|
-
async function
|
|
213
|
-
let s =
|
|
212
|
+
async function Ce(e, t, n, r, i, a) {
|
|
213
|
+
let s = ue(t), l = P(e, t, n, a), d = (i) => ({
|
|
214
214
|
name: `ai-assistant-${t}-${Date.now()}`,
|
|
215
215
|
description: `AI Assistant sandbox (${t} mode)`,
|
|
216
216
|
template: "AI_BUILDER",
|
|
@@ -231,9 +231,9 @@ async function xe(e, t, n, r, i, a) {
|
|
|
231
231
|
assistantProduct: e,
|
|
232
232
|
assistantOwnerUserId: a.userId ?? null,
|
|
233
233
|
assistantOrganizationId: a.organizationId ?? null,
|
|
234
|
-
authStrategy:
|
|
235
|
-
imageTag:
|
|
236
|
-
confirmWrites:
|
|
234
|
+
authStrategy: ce,
|
|
235
|
+
imageTag: le(t, r),
|
|
236
|
+
confirmWrites: N(t)
|
|
237
237
|
},
|
|
238
238
|
context: o(n, a)
|
|
239
239
|
}), f = (e) => c({
|
|
@@ -246,13 +246,13 @@ async function xe(e, t, n, r, i, a) {
|
|
|
246
246
|
try {
|
|
247
247
|
p = await f(i);
|
|
248
248
|
} catch (e) {
|
|
249
|
-
if (
|
|
249
|
+
if (H(e, i)) p = await f(600);
|
|
250
250
|
else throw e;
|
|
251
251
|
}
|
|
252
252
|
if (!p?.createSandbox?.id) throw Error("createSandbox returned empty response");
|
|
253
253
|
return p.createSandbox.id;
|
|
254
254
|
}
|
|
255
|
-
async function
|
|
255
|
+
async function we(e, t, n) {
|
|
256
256
|
return (await c({
|
|
257
257
|
query: ee,
|
|
258
258
|
operationName: "GetSandbox",
|
|
@@ -264,14 +264,14 @@ async function Se(e, t, n) {
|
|
|
264
264
|
authContext: n
|
|
265
265
|
})).getSandbox;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function K(e, t) {
|
|
268
268
|
if (e === "FAILED" || e === "STOPPED" || e === "EXPIRED") throw Error(t ? `Sandbox ${e.toLowerCase()}: ${t}` : `Sandbox ${e.toLowerCase()}`);
|
|
269
269
|
}
|
|
270
|
-
async function
|
|
270
|
+
async function Te(e, t, n, r = 3e5) {
|
|
271
271
|
let i = Date.now();
|
|
272
272
|
if (y("waitForSandboxRunning") !== "unsupported") for (; Date.now() - i < r;) try {
|
|
273
273
|
let r = await c({
|
|
274
|
-
query:
|
|
274
|
+
query: se,
|
|
275
275
|
operationName: "WaitForSandboxRunning",
|
|
276
276
|
variables: {
|
|
277
277
|
id: e,
|
|
@@ -284,27 +284,51 @@ async function Ce(e, t, n, r = 3e5) {
|
|
|
284
284
|
x("waitForSandboxRunning");
|
|
285
285
|
let i = r.waitForSandboxRunning;
|
|
286
286
|
if (i?.status === "RUNNING") return;
|
|
287
|
-
|
|
287
|
+
K(i?.status, i?.errorMessage);
|
|
288
288
|
} catch (e) {
|
|
289
|
-
if (
|
|
289
|
+
if (fe(e)) {
|
|
290
290
|
S("waitForSandboxRunning");
|
|
291
291
|
break;
|
|
292
292
|
}
|
|
293
293
|
throw e;
|
|
294
294
|
}
|
|
295
295
|
for (; Date.now() - i < r;) {
|
|
296
|
-
let r = await
|
|
296
|
+
let r = await we(e, t, n);
|
|
297
297
|
if (r?.status === "RUNNING") return;
|
|
298
|
-
|
|
298
|
+
K(r?.status, r?.errorMessage), await new Promise((e) => setTimeout(e, 2e3));
|
|
299
299
|
}
|
|
300
300
|
throw Error("Sandbox startup timed out");
|
|
301
301
|
}
|
|
302
|
-
async function
|
|
303
|
-
let
|
|
304
|
-
for (; Date.now() -
|
|
302
|
+
async function Ee(e, t, n, r, i = 9e4, a) {
|
|
303
|
+
let s = Date.now(), l = (t) => (C.getState().setSandboxWriteCapabilities(e, Y(t)), t);
|
|
304
|
+
if (y("waitForAssistantReady") !== "unsupported") for (; Date.now() - s < i;) {
|
|
305
|
+
let n = Date.now();
|
|
306
|
+
try {
|
|
307
|
+
let u = await c({
|
|
308
|
+
query: oe,
|
|
309
|
+
operationName: "WaitForAssistantReady",
|
|
310
|
+
variables: {
|
|
311
|
+
id: e,
|
|
312
|
+
timeoutSeconds: Math.max(1, Math.min(25, Math.floor((i - (Date.now() - s)) / 1e3))),
|
|
313
|
+
context: o(t, r)
|
|
314
|
+
},
|
|
315
|
+
workspaceId: t,
|
|
316
|
+
authContext: r
|
|
317
|
+
});
|
|
318
|
+
x("waitForAssistantReady");
|
|
319
|
+
let d = u.waitForAssistantReady;
|
|
320
|
+
if ((d.waited || !d.ready) && a?.(), d.ready && d.health) return l(d.health);
|
|
321
|
+
let f = Date.now(), p = i - (f - s);
|
|
322
|
+
f - n < 400 && p > 0 && await new Promise((e) => setTimeout(e, Math.min(400, p)));
|
|
323
|
+
} catch (e) {
|
|
324
|
+
if (!b(e, "waitForAssistantReady")) throw e;
|
|
325
|
+
S("waitForAssistantReady");
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (; Date.now() - s < i;) {
|
|
305
330
|
try {
|
|
306
|
-
|
|
307
|
-
return C.getState().setSandboxWriteCapabilities(e, X(i)), i;
|
|
331
|
+
return l(await E(e, t, "/health", "GET", void 0, n, r, "transport"));
|
|
308
332
|
} catch (e) {
|
|
309
333
|
let t = e instanceof Error ? e.message : String(e);
|
|
310
334
|
if (!/proxy error: 502|proxy error: 503|proxy error: 404|service not available|starting/i.test(t)) throw e;
|
|
@@ -314,32 +338,32 @@ async function we(e, t, n, r, i = 9e4, a) {
|
|
|
314
338
|
}
|
|
315
339
|
throw Error("Assistant service did not become healthy before timeout");
|
|
316
340
|
}
|
|
317
|
-
function
|
|
341
|
+
function q(e) {
|
|
318
342
|
return e === "proposal-v1" ? "proposal-v1" : "legacy";
|
|
319
343
|
}
|
|
320
|
-
function
|
|
344
|
+
function J(e, t) {
|
|
321
345
|
return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
|
|
322
346
|
}
|
|
323
|
-
var
|
|
347
|
+
var De = new Set([
|
|
324
348
|
"relay",
|
|
325
349
|
"delegated",
|
|
326
350
|
"direct",
|
|
327
351
|
"unconfigured"
|
|
328
352
|
]);
|
|
329
|
-
function
|
|
353
|
+
function Y(e) {
|
|
330
354
|
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;
|
|
331
355
|
return {
|
|
332
356
|
proposals: n.writeProposals === "v1",
|
|
333
|
-
writeApprovalMode:
|
|
334
|
-
writeExecution:
|
|
357
|
+
writeApprovalMode: q(n.writeApprovalMode),
|
|
358
|
+
writeExecution: J(n.writeExecution, r),
|
|
335
359
|
replyApproval: "off",
|
|
336
360
|
...typeof i == "string" && i ? { writeRiskVersion: i } : {},
|
|
337
|
-
...typeof a == "string" &&
|
|
361
|
+
...typeof a == "string" && De.has(a) ? { sessionCredentials: a } : {},
|
|
338
362
|
...n.uiOffers === 1 ? { uiOffers: !0 } : {},
|
|
339
363
|
...n.clientTools === 1 ? { clientTools: !0 } : {}
|
|
340
364
|
};
|
|
341
365
|
}
|
|
342
|
-
async function
|
|
366
|
+
async function Oe(e, t, n, r) {
|
|
343
367
|
let i;
|
|
344
368
|
try {
|
|
345
369
|
i = await D(e, t, "/health", "GET", void 0, n, r);
|
|
@@ -348,20 +372,20 @@ async function Ee(e, t, n, r) {
|
|
|
348
372
|
}
|
|
349
373
|
let a = i.body;
|
|
350
374
|
if (i.status < 200 || i.status >= 300 || typeof a != "object" || !a || Array.isArray(a)) return null;
|
|
351
|
-
let o =
|
|
375
|
+
let o = Y(a);
|
|
352
376
|
return C.getState().setSandboxWriteCapabilities(e, o), o;
|
|
353
377
|
}
|
|
354
|
-
async function
|
|
378
|
+
async function ke(e, t, n, r) {
|
|
355
379
|
return { sessionId: (await E(e, t, "/sessions", "POST", { mode: n }, n, r, "never")).session.id };
|
|
356
380
|
}
|
|
357
|
-
async function
|
|
381
|
+
async function Ae(e, t, n, r, i) {
|
|
358
382
|
let a = await E(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i, "never");
|
|
359
383
|
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.");
|
|
360
384
|
}
|
|
361
|
-
function
|
|
362
|
-
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 && (!
|
|
385
|
+
function X(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
386
|
+
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 && (!N(n) || M(e.metadata, o)) && A(e, n, o))).map((e) => e.id) : [];
|
|
363
387
|
}
|
|
364
|
-
async function
|
|
388
|
+
async function je(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
365
389
|
let l, u = /* @__PURE__ */ new Set();
|
|
366
390
|
try {
|
|
367
391
|
let d = (await c({
|
|
@@ -371,9 +395,9 @@ async function ke(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
|
371
395
|
workspaceId: e,
|
|
372
396
|
authContext: i
|
|
373
397
|
})).getActiveSandboxes ?? [];
|
|
374
|
-
|
|
375
|
-
let f =
|
|
376
|
-
if (l =
|
|
398
|
+
L(d);
|
|
399
|
+
let f = B(s);
|
|
400
|
+
if (l = X(d, t, n, r, i, a, f), f === "proposal-v1") {
|
|
377
401
|
let e = new Set(l);
|
|
378
402
|
for (let t of d) {
|
|
379
403
|
let n = h(t);
|
|
@@ -385,14 +409,14 @@ async function ke(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
|
385
409
|
}
|
|
386
410
|
return (await Promise.all(l.map(async (t) => {
|
|
387
411
|
try {
|
|
388
|
-
return await
|
|
412
|
+
return await Z(t, e, i, { ownerScoped: u.has(t) }), t;
|
|
389
413
|
} catch {
|
|
390
414
|
return null;
|
|
391
415
|
}
|
|
392
416
|
}))).filter((e) => e !== null);
|
|
393
417
|
}
|
|
394
|
-
async function
|
|
395
|
-
if (i(e), (r.ownerScoped === !0 ||
|
|
418
|
+
async function Z(e, t, n, r = {}) {
|
|
419
|
+
if (i(e), (r.ownerScoped === !0 || R(e)) && y("stopMyAssistantSandbox") !== "unsupported") try {
|
|
396
420
|
await c({
|
|
397
421
|
query: ae,
|
|
398
422
|
operationName: "StopMyAssistantSandbox",
|
|
@@ -419,7 +443,7 @@ async function Ae(e, t, n, r = {}) {
|
|
|
419
443
|
authContext: n
|
|
420
444
|
});
|
|
421
445
|
}
|
|
422
|
-
var
|
|
446
|
+
var Q = /^[A-Za-z0-9_-]{1,128}$/, Me = new Set([
|
|
423
447
|
"affirm",
|
|
424
448
|
"decline",
|
|
425
449
|
"other"
|
|
@@ -441,24 +465,24 @@ function Fe(e) {
|
|
|
441
465
|
proposalId: e.proposalId
|
|
442
466
|
} : null;
|
|
443
467
|
}
|
|
444
|
-
function
|
|
468
|
+
function $(e) {
|
|
445
469
|
let { mode: t, prompt: n, parts: r } = e, i = {
|
|
446
470
|
mode: t,
|
|
447
471
|
prompt: n,
|
|
448
|
-
pageContext:
|
|
472
|
+
pageContext: me(e.pageContext)
|
|
449
473
|
};
|
|
450
|
-
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" &&
|
|
474
|
+
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" && Q.test(e.conversationId) && (i.conversationId = e.conversationId);
|
|
451
475
|
let a = Fe(e.writeReply);
|
|
452
476
|
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), e.clientTools && e.clientTools.length > 0 && (i.clientTools = e.clientTools), i;
|
|
453
477
|
}
|
|
454
478
|
function Ie(e) {
|
|
455
|
-
return T(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST",
|
|
479
|
+
return T(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST", $(e), e.mode, e.authContext);
|
|
456
480
|
}
|
|
457
|
-
function
|
|
481
|
+
function Le(e) {
|
|
458
482
|
return new TextEncoder().encode(JSON.stringify(Ie(e))).byteLength;
|
|
459
483
|
}
|
|
460
|
-
async function
|
|
461
|
-
if (
|
|
484
|
+
async function Re(e, t, n, r, i, a, o, s) {
|
|
485
|
+
if (Le({
|
|
462
486
|
sandboxId: e,
|
|
463
487
|
workspaceId: t,
|
|
464
488
|
sessionId: n,
|
|
@@ -471,8 +495,8 @@ async function Le(e, t, n, r, i, a, o, s) {
|
|
|
471
495
|
writeReply: s?.writeReply,
|
|
472
496
|
uiCatalogue: s?.uiCatalogue,
|
|
473
497
|
clientTools: s?.clientTools
|
|
474
|
-
}) > 262144) throw Object.assign(Error(
|
|
475
|
-
let c = await E(e, t, `/sessions/${n}/prompt-async`, "POST",
|
|
498
|
+
}) > 262144) throw Object.assign(Error(he), { assistantPromptNotDispatched: !0 });
|
|
499
|
+
let c = await E(e, t, `/sessions/${n}/prompt-async`, "POST", $({
|
|
476
500
|
mode: i,
|
|
477
501
|
prompt: r,
|
|
478
502
|
pageContext: a,
|
|
@@ -484,23 +508,28 @@ async function Le(e, t, n, r, i, a, o, s) {
|
|
|
484
508
|
}), i, o, "never");
|
|
485
509
|
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
486
510
|
}
|
|
487
|
-
async function
|
|
488
|
-
let s = `/sessions/${r}/messages?limit=${o?.limit ?? 50}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
511
|
+
async function ze(e, t, r, i, a, o) {
|
|
512
|
+
let s = `/sessions/${r}/messages?limit=${o?.limit ?? 50}`, c = Number.isFinite(o?.sinceMs) && (o?.sinceMs ?? 0) > 0 && y("sinceParam") !== "unsupported", l = c, u = (n) => E(e, t, n, "GET", void 0, i, a, "transport"), d;
|
|
513
|
+
try {
|
|
514
|
+
d = await u(c ? `${s}&since=${o?.sinceMs}` : s);
|
|
515
|
+
} catch (e) {
|
|
516
|
+
let t = typeof e == "object" && e && "assistantProxyResponse" in e ? e.assistantProxyResponse : null;
|
|
517
|
+
if (!c || typeof t != "object" || !t || !("status" in t) || ![400, 422].includes(Number(t.status)) || !("errorBody" in t) || typeof t.errorBody != "string" || !/\b(?:unknown|unsupported|unrecognized)\b.{0,40}\b(?:parameter|argument)\b.{0,20}["']?since\b/i.test(t.errorBody)) throw e;
|
|
518
|
+
S("sinceParam"), l = !1, d = await u(s);
|
|
519
|
+
}
|
|
520
|
+
if (l && (typeof d.now == "number" && Number.isFinite(d.now) ? x("sinceParam") : S("sinceParam")), o?.surfaceUiOffers) try {
|
|
521
|
+
o.surfaceUiOffers(d.uiOffers, typeof d.now == "number" ? d.now : NaN);
|
|
493
522
|
} catch {}
|
|
494
523
|
if (o?.surfaceClientToolRequests) try {
|
|
495
|
-
o.surfaceClientToolRequests(
|
|
524
|
+
o.surfaceClientToolRequests(d.clientToolRequests);
|
|
496
525
|
} catch {}
|
|
497
526
|
if (o?.surfaceTurnTerminal === !0) {
|
|
498
|
-
let e = n(
|
|
527
|
+
let e = n(d.turnTerminal);
|
|
499
528
|
if (e) throw e;
|
|
500
529
|
}
|
|
501
|
-
return
|
|
530
|
+
return d.messages ?? [];
|
|
502
531
|
}
|
|
503
|
-
async function
|
|
532
|
+
async function Be(t, n, r, i, a, o, s) {
|
|
504
533
|
try {
|
|
505
534
|
await E(t, n, `/sessions/${r}/client-tools/${i}/result`, "POST", { result: a }, o, s, "never");
|
|
506
535
|
} catch (t) {
|
|
@@ -508,7 +537,7 @@ async function ze(t, n, r, i, a, o, s) {
|
|
|
508
537
|
throw t;
|
|
509
538
|
}
|
|
510
539
|
}
|
|
511
|
-
async function
|
|
540
|
+
async function Ve(e, t, n, r, i) {
|
|
512
541
|
if (y("sse") === "unsupported") return null;
|
|
513
542
|
try {
|
|
514
543
|
let a = await E(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i, "transport");
|
|
@@ -520,13 +549,13 @@ async function Be(e, t, n, r, i) {
|
|
|
520
549
|
return S("sse"), null;
|
|
521
550
|
}
|
|
522
551
|
}
|
|
523
|
-
async function
|
|
524
|
-
if (
|
|
552
|
+
async function He(e, t, n, r, i, a = Date.now) {
|
|
553
|
+
if (pe(a())) return null;
|
|
525
554
|
try {
|
|
526
555
|
let { status: o, body: s } = await D(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i);
|
|
527
556
|
if (o === 404) return v(_, a()), null;
|
|
528
557
|
let c = o >= 200 && o < 300 && typeof s == "object" && s ? s : null;
|
|
529
|
-
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" &&
|
|
558
|
+
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" && Ue(c.url) ? (de(), {
|
|
530
559
|
url: c.url,
|
|
531
560
|
expiresAt: c.expiresAt
|
|
532
561
|
}) : (v(c ? _ : g, a()), null);
|
|
@@ -534,7 +563,7 @@ async function Ve(e, t, n, r, i, a = Date.now) {
|
|
|
534
563
|
return v(g, a()), null;
|
|
535
564
|
}
|
|
536
565
|
}
|
|
537
|
-
function
|
|
566
|
+
function Ue(e) {
|
|
538
567
|
try {
|
|
539
568
|
let { protocol: t } = new URL(e);
|
|
540
569
|
return t === "https:" || t === "http:";
|
|
@@ -542,8 +571,8 @@ function He(e) {
|
|
|
542
571
|
return !1;
|
|
543
572
|
}
|
|
544
573
|
}
|
|
545
|
-
async function
|
|
546
|
-
if (
|
|
574
|
+
async function We(e, t, n, r) {
|
|
575
|
+
if (R(e) && y("extendMyAssistantSandboxTTL") !== "unsupported") try {
|
|
547
576
|
await c({
|
|
548
577
|
query: d,
|
|
549
578
|
operationName: "ExtendMyAssistantSandboxTtl",
|
|
@@ -572,27 +601,27 @@ async function Ue(e, t, n, r) {
|
|
|
572
601
|
authContext: r
|
|
573
602
|
});
|
|
574
603
|
}
|
|
575
|
-
async function
|
|
604
|
+
async function Ge(e, t, n, r, i) {
|
|
576
605
|
await E(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r, i, "transport").catch(() => void 0);
|
|
577
606
|
}
|
|
578
|
-
async function
|
|
607
|
+
async function Ke(e, t, n, r, i) {
|
|
579
608
|
try {
|
|
580
609
|
return (await E(e, t, `/sessions/${n}/abort`, "POST", void 0, r, i, "never"))?.aborted === !0;
|
|
581
610
|
} catch {
|
|
582
611
|
return !1;
|
|
583
612
|
}
|
|
584
613
|
}
|
|
585
|
-
async function
|
|
614
|
+
async function qe(e, t, n, r, i) {
|
|
586
615
|
return ((await E(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r, i, "transport")).artifacts ?? []).filter((e) => !e.name.startsWith("."));
|
|
587
616
|
}
|
|
588
|
-
async function
|
|
617
|
+
async function Je(e, t, n, r, i) {
|
|
589
618
|
let a = await E(e, t, `/sessions/${n}`, "GET", void 0, r, i, "transport");
|
|
590
619
|
return {
|
|
591
620
|
id: a.session?.id ?? n,
|
|
592
621
|
mode: a.mode ?? "unknown"
|
|
593
622
|
};
|
|
594
623
|
}
|
|
595
|
-
async function
|
|
624
|
+
async function Ye(e, t, n, r, i, a) {
|
|
596
625
|
let o = (await E(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i, a, "transport")).artifact;
|
|
597
626
|
if (!o) throw Error("Artifact download returned an empty response");
|
|
598
627
|
return {
|
|
@@ -601,7 +630,7 @@ async function Je(e, t, n, r, i, a) {
|
|
|
601
630
|
contentBase64: o.contentBase64
|
|
602
631
|
};
|
|
603
632
|
}
|
|
604
|
-
async function
|
|
633
|
+
async function Xe(e, t) {
|
|
605
634
|
return (await c({
|
|
606
635
|
query: l,
|
|
607
636
|
operationName: "CheckAiCredits",
|
|
@@ -610,7 +639,7 @@ async function Ye(e, t) {
|
|
|
610
639
|
authContext: t
|
|
611
640
|
})).checkAiCredits;
|
|
612
641
|
}
|
|
613
|
-
async function
|
|
642
|
+
async function Ze(e, t, n, r, i, a) {
|
|
614
643
|
let o = 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));
|
|
615
644
|
if (o + l + u + d === 0 || !r) return;
|
|
616
645
|
let f = !1;
|
|
@@ -642,4 +671,4 @@ async function Xe(e, t, n, r, i, a) {
|
|
|
642
671
|
});
|
|
643
672
|
}
|
|
644
673
|
//#endregion
|
|
645
|
-
export {
|
|
674
|
+
export { Q as PROMPT_CONVERSATION_ID_PATTERN, Ke as abortAssistantTurn, Ae as approvePendingWrite, A as askReuseMatchesProvisioning, P as buildAssistantSandboxEnv, Ie as buildPromptGatewayRequest, $ as buildPromptRequestBody, U as buildProvisionAssistantSandboxInput, Xe as checkAssistantAiCredits, Se as createAssistantSandbox, ke as createAssistantSession, Ye as downloadAssistantArtifact, We as extendAssistantSandboxTTL, ge as findExistingSandbox, _e as findExistingSandboxWithStatus, w as forwardsUserTokensToSandbox, qe as getAssistantArtifacts, ze as getAssistantMessages, Je as getAssistantSession, Ve as getAssistantStreamAccess, V as isAssistantProvisioningUnavailable, R as isDedicatedAssistantSandbox, I as isDedicatedAssistantSandboxRow, He as mintAssistantTurnStream, N as modeRequiresConfirmWrites, Be as postClientToolResult, Le as promptGatewayRequestBytes, D as proxySandboxRaw, Y as readSandboxWriteCapabilities, Oe as readSandboxWriteCapabilitiesOnce, je as releaseSupersededAssistantSandboxes, Ze as reportAssistantAiTokenUsage, O as sandboxStatusOf, k as selectExistingAssistantSandbox, X as selectSupersededAssistantSandboxes, Re as sendAssistantPromptAsync, Ge as sendHeartbeat, Z as stopReapedAssistantSandbox, z as usesDedicatedAssistantProvisioning, Ee as waitForAssistantServiceReady, Te as waitForSandboxRunning, q as writeApprovalModeOf, M as writeApprovalReuseMatches, J as writeExecutionOf };
|
|
@@ -11,6 +11,7 @@ export declare const GET_SANDBOX = "\n query GetSandbox($id: ID!, $context: Con
|
|
|
11
11
|
* back to polling getSandbox.
|
|
12
12
|
*/
|
|
13
13
|
export declare const WAIT_FOR_SANDBOX_RUNNING = "\n query WaitForSandboxRunning($id: ID!, $timeoutSeconds: Int, $context: ContextInput!) {\n waitForSandboxRunning(id: $id, timeoutSeconds: $timeoutSeconds, context: $context) {\n id\n status\n errorMessage\n }\n }\n";
|
|
14
|
+
export declare const WAIT_FOR_ASSISTANT_READY = "\n query WaitForAssistantReady($id: ID!, $timeoutSeconds: Int, $context: ContextInput!) {\n waitForAssistantReady(id: $id, timeoutSeconds: $timeoutSeconds, context: $context) {\n ready\n health\n waited\n }\n }\n";
|
|
14
15
|
export declare const GET_ACTIVE_SANDBOXES = "\n query GetActiveSandboxes($context: ContextInput!) {\n getActiveSandboxes(context: $context) {\n id\n name\n status\n metadata\n template\n createdBy\n }\n }\n";
|
|
15
16
|
export declare const PROXY_SANDBOX_REQUEST = "\n mutation ProxySandboxRequest($input: ProxySandboxRequestInput!) {\n proxySandboxRequest(input: $input) {\n status\n body\n }\n }\n";
|
|
16
17
|
export declare const STOP_ASSISTANT_SANDBOX = "\n mutation StopAssistantSandbox($id: ID!, $context: ContextInput!) {\n stopSandbox(id: $id, context: $context) {\n id\n status\n }\n }\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/shared/assistant/operations.ts
|
|
2
|
-
var e = "\n mutation CreateSandbox($input: CreateSandboxInput!) {\n createSandbox(input: $input) {\n id\n name\n status\n network {\n internalUrl\n }\n }\n }\n", t = "\n query GetSandbox($id: ID!, $context: ContextInput!) {\n getSandbox(id: $id, context: $context) {\n id\n status\n errorMessage\n network {\n internalUrl\n }\n }\n }\n", n = "\n query WaitForSandboxRunning($id: ID!, $timeoutSeconds: Int, $context: ContextInput!) {\n waitForSandboxRunning(id: $id, timeoutSeconds: $timeoutSeconds, context: $context) {\n id\n status\n errorMessage\n }\n }\n", r = "\n query GetActiveSandboxes($context: ContextInput!) {\n getActiveSandboxes(context: $context) {\n id\n name\n status\n metadata\n template\n createdBy\n }\n }\n",
|
|
2
|
+
var e = "\n mutation CreateSandbox($input: CreateSandboxInput!) {\n createSandbox(input: $input) {\n id\n name\n status\n network {\n internalUrl\n }\n }\n }\n", t = "\n query GetSandbox($id: ID!, $context: ContextInput!) {\n getSandbox(id: $id, context: $context) {\n id\n status\n errorMessage\n network {\n internalUrl\n }\n }\n }\n", n = "\n query WaitForSandboxRunning($id: ID!, $timeoutSeconds: Int, $context: ContextInput!) {\n waitForSandboxRunning(id: $id, timeoutSeconds: $timeoutSeconds, context: $context) {\n id\n status\n errorMessage\n }\n }\n", r = "\n query WaitForAssistantReady($id: ID!, $timeoutSeconds: Int, $context: ContextInput!) {\n waitForAssistantReady(id: $id, timeoutSeconds: $timeoutSeconds, context: $context) {\n ready\n health\n waited\n }\n }\n", i = "\n query GetActiveSandboxes($context: ContextInput!) {\n getActiveSandboxes(context: $context) {\n id\n name\n status\n metadata\n template\n createdBy\n }\n }\n", a = "\n mutation ProxySandboxRequest($input: ProxySandboxRequestInput!) {\n proxySandboxRequest(input: $input) {\n status\n body\n }\n }\n", o = "\n mutation StopAssistantSandbox($id: ID!, $context: ContextInput!) {\n stopSandbox(id: $id, context: $context) {\n id\n status\n }\n }\n", s = "\n mutation ExtendSandboxTtl($id: ID!, $additionalSeconds: Int!, $context: ContextInput!) {\n extendSandboxTTL(id: $id, additionalSeconds: $additionalSeconds, context: $context) {\n id\n expiresAt\n }\n }\n", c = "\n mutation ProvisionAssistantSandbox($input: ProvisionAssistantSandboxInput!) {\n provisionAssistantSandbox(input: $input) {\n id\n name\n status\n }\n }\n", l = "\n mutation StopMyAssistantSandbox($id: ID!, $context: ContextInput!) {\n stopMyAssistantSandbox(id: $id, context: $context) {\n id\n status\n }\n }\n", u = "\n mutation ExtendMyAssistantSandboxTtl(\n $id: ID!\n $additionalSeconds: Int!\n $context: ContextInput!\n ) {\n extendMyAssistantSandboxTTL(id: $id, additionalSeconds: $additionalSeconds, context: $context) {\n id\n expiresAt\n }\n }\n", d = "\n mutation CheckAiCredits {\n checkAiCredits\n }\n", f = "\n mutation ReportAiTokenUsage($input: ReportAiTokenUsageInput!) {\n reportAiTokenUsage(input: $input)\n }\n", p = "\n mutation ReportMyAssistantTurnTimings($input: ReportAssistantTurnTimingsInput!) {\n reportMyAssistantTurnTimings(input: $input) {\n enabled\n accepted\n rejected\n duplicate\n rateLimited\n }\n }\n";
|
|
3
3
|
//#endregion
|
|
4
|
-
export {
|
|
4
|
+
export { d as CHECK_AI_CREDITS, e as CREATE_SANDBOX, u as EXTEND_MY_ASSISTANT_SANDBOX_TTL, s as EXTEND_SANDBOX_TTL, i as GET_ACTIVE_SANDBOXES, t as GET_SANDBOX, c as PROVISION_ASSISTANT_SANDBOX, a as PROXY_SANDBOX_REQUEST, f as REPORT_AI_TOKEN_USAGE, p as REPORT_MY_ASSISTANT_TURN_TIMINGS, o as STOP_ASSISTANT_SANDBOX, l as STOP_MY_ASSISTANT_SANDBOX, r as WAIT_FOR_ASSISTANT_READY, n as WAIT_FOR_SANDBOX_RUNNING };
|