@burdenoff/fe-libs 2026.1026.1 → 2026.1027.1
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/credentials/SchemaForm.js +2 -0
- package/dist/shared/agent-tools/AgentToolsProvider.d.ts +33 -0
- package/dist/shared/agent-tools/AgentToolsProvider.js +48 -0
- package/dist/shared/agent-tools/adapters/assistant.d.ts +85 -0
- package/dist/shared/agent-tools/adapters/assistant.js +110 -0
- package/dist/shared/agent-tools/adapters/webmcp.d.ts +69 -0
- package/dist/shared/agent-tools/adapters/webmcp.js +81 -0
- package/dist/shared/agent-tools/confirm/AgentConfirmHost.d.ts +12 -0
- package/dist/shared/agent-tools/confirm/AgentConfirmHost.js +34 -0
- package/dist/shared/agent-tools/confirm/confirmStore.d.ts +37 -0
- package/dist/shared/agent-tools/confirm/confirmStore.js +58 -0
- package/dist/shared/agent-tools/defineAgentTool.d.ts +13 -0
- package/dist/shared/agent-tools/defineAgentTool.js +27 -0
- package/dist/shared/agent-tools/errors.d.ts +33 -0
- package/dist/shared/agent-tools/errors.js +105 -0
- package/dist/shared/agent-tools/index.d.ts +29 -0
- package/dist/shared/agent-tools/limits.d.ts +20 -0
- package/dist/shared/agent-tools/limits.js +4 -0
- package/dist/shared/agent-tools/log.d.ts +15 -0
- package/dist/shared/agent-tools/log.js +11 -0
- package/dist/shared/agent-tools/outputBudget.d.ts +21 -0
- package/dist/shared/agent-tools/outputBudget.js +51 -0
- package/dist/shared/agent-tools/registry.d.ts +13 -0
- package/dist/shared/agent-tools/registry.js +53 -0
- package/dist/shared/agent-tools/runAgentTool.d.ts +21 -0
- package/dist/shared/agent-tools/runAgentTool.js +57 -0
- package/dist/shared/agent-tools/shell/shellTools.d.ts +44 -0
- package/dist/shared/agent-tools/shell/shellTools.js +145 -0
- package/dist/shared/agent-tools/testSupport/installDom.d.ts +6 -0
- package/dist/shared/agent-tools/types.d.ts +106 -0
- package/dist/shared/agent-tools/ui/dom.d.ts +43 -0
- package/dist/shared/agent-tools/ui/dom.js +178 -0
- package/dist/shared/agent-tools/ui/refs.d.ts +8 -0
- package/dist/shared/agent-tools/ui/refs.js +20 -0
- package/dist/shared/agent-tools/ui/uiTools.d.ts +40 -0
- package/dist/shared/agent-tools/ui/uiTools.js +277 -0
- package/dist/shared/agent-tools/useAgentTools.d.ts +14 -0
- package/dist/shared/agent-tools/useAgentTools.js +14 -0
- package/dist/shared/assistant/api.d.ts +18 -0
- package/dist/shared/assistant/api.js +145 -131
- package/dist/shared/assistant/ui/AssistantChatArea.js +1158 -1148
- package/dist/shared/assistant/writeProposals.d.ts +6 -0
- package/dist/shared/providers/shell/ActiveContextProvider.d.ts +5 -0
- package/dist/shared/providers/shell/ActiveContextProvider.js +4 -1
- package/dist/shared/providers/shell/index.d.ts +1 -1
- package/dist/shared-agent-tools.d.ts +2 -0
- package/dist/shared-agent-tools.js +16 -0
- package/dist/shared-assistant.js +285 -285
- package/dist/shared-providers-shell.js +20 -20
- package/dist/ui/alert-dialog.js +2 -0
- package/package.json +7 -2
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { extensionObjectsIn as
|
|
3
|
-
import { abandonAssistantSandboxTurns as
|
|
4
|
-
import { buildSandboxContextInput as
|
|
5
|
-
import { CHECK_AI_CREDITS as
|
|
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
|
|
1
|
+
import { SandboxProxyError as e, sandboxProxyErrorFromBody as t, sandboxProxyErrorFromTurnTerminal as n } from "./sandboxProxyError.js";
|
|
2
|
+
import { extensionObjectsIn as r } from "./quota.js";
|
|
3
|
+
import { abandonAssistantSandboxTurns as i, withAssistantProxyResponse as a } from "./promptDelivery.js";
|
|
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, WAIT_FOR_SANDBOX_RUNNING as oe } from "./operations.js";
|
|
6
|
+
import { ASSISTANT_API_AUTH_STRATEGY as se, getImageForMode as m, getImageTagForMode as ce, getResourcesForMode as le, 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 ue, getCapability as y, isMissingGatewayFieldError as b, isUnknownFieldError as de, markSupported as x, markUnsupported as S, streamMintBackedOff as fe } from "./capabilities.js";
|
|
8
|
+
import { filterAssistantPageContext as pe } 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 me } from "./gatewayLimits.js";
|
|
11
11
|
//#region src/shared/assistant/api.ts
|
|
12
12
|
function w(e) {
|
|
13
13
|
return e === "assistant" || e === "api-calls";
|
|
14
14
|
}
|
|
15
|
-
function T(e, t, n, r, i,
|
|
15
|
+
function T(e, t, n, r, i, a, s) {
|
|
16
16
|
return {
|
|
17
|
-
query:
|
|
17
|
+
query: ne,
|
|
18
18
|
operationName: "ProxySandboxRequest",
|
|
19
19
|
variables: { input: {
|
|
20
20
|
sandboxId: e,
|
|
21
21
|
path: n,
|
|
22
22
|
method: r,
|
|
23
23
|
body: i,
|
|
24
|
-
context:
|
|
25
|
-
...w(
|
|
24
|
+
context: o(t, s),
|
|
25
|
+
...w(a) ? {
|
|
26
26
|
forwardedAuthToken: s?.accessToken ?? void 0,
|
|
27
27
|
forwardedWorkspaceToken: s?.workspaceToken ?? void 0
|
|
28
28
|
} : {}
|
|
29
29
|
} }
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
async function E(
|
|
33
|
-
let f = (await (d === "transport" ?
|
|
34
|
-
...T(
|
|
32
|
+
async function E(e, n, r, i, o, l, u, d) {
|
|
33
|
+
let f = (await (d === "transport" ? c : s)({
|
|
34
|
+
...T(e, n, r, i, o, l, u),
|
|
35
35
|
workspaceId: n,
|
|
36
36
|
authContext: u
|
|
37
37
|
})).proxySandboxRequest;
|
|
38
38
|
if (!f || f.status >= 400) {
|
|
39
|
-
let
|
|
40
|
-
throw
|
|
39
|
+
let e = f?.body, n = e?.error ?? `Proxy error: ${f?.status ?? "unknown"}`;
|
|
40
|
+
throw a(t(n, f?.status ?? null, e) ?? Error(n), f?.status, e);
|
|
41
41
|
}
|
|
42
42
|
return f.body;
|
|
43
43
|
}
|
|
44
|
-
async function D(e, t, n, r, i, a,
|
|
45
|
-
let c = (await
|
|
46
|
-
...T(e, t, n, r, i, a,
|
|
44
|
+
async function D(e, t, n, r, i, a, o) {
|
|
45
|
+
let c = (await s({
|
|
46
|
+
...T(e, t, n, r, i, a, o),
|
|
47
47
|
workspaceId: t,
|
|
48
|
-
authContext:
|
|
48
|
+
authContext: o
|
|
49
49
|
})).proxySandboxRequest;
|
|
50
50
|
if (typeof c != "object" || !c || !("status" in c) || typeof c.status != "number" || !Number.isInteger(c.status)) throw Error("Proxy error: unknown");
|
|
51
51
|
return {
|
|
@@ -53,19 +53,19 @@ async function D(e, t, n, r, i, a, s) {
|
|
|
53
53
|
body: "body" in c ? c.body ?? null : null
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
async function
|
|
56
|
+
async function he(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
57
57
|
return (await O(e, t, n, r, i, a, o))?.id ?? null;
|
|
58
58
|
}
|
|
59
|
-
async function O(e, t, n, r, i,
|
|
60
|
-
let l = (await
|
|
61
|
-
query:
|
|
59
|
+
async function O(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
60
|
+
let l = (await c({
|
|
61
|
+
query: p,
|
|
62
62
|
operationName: "GetActiveSandboxes",
|
|
63
|
-
variables: { context:
|
|
63
|
+
variables: { context: o(e, i) },
|
|
64
64
|
workspaceId: e,
|
|
65
65
|
authContext: i
|
|
66
66
|
})).getActiveSandboxes ?? [];
|
|
67
67
|
R(l);
|
|
68
|
-
let u = A(l, t, n, r, i,
|
|
68
|
+
let u = A(l, t, n, r, i, a, V(s));
|
|
69
69
|
return u ? {
|
|
70
70
|
id: u,
|
|
71
71
|
status: k(l, u)
|
|
@@ -123,14 +123,14 @@ function F(e, t, n, r) {
|
|
|
123
123
|
value: "1"
|
|
124
124
|
}), i;
|
|
125
125
|
}
|
|
126
|
-
var
|
|
126
|
+
var ge = "assistant.errors.assistantProvisioningUnavailable", _e = "provisionAssistantSandbox", ve = [
|
|
127
127
|
"ProvisionAssistantSandboxInput",
|
|
128
128
|
"SandboxAssistantMode",
|
|
129
129
|
"SandboxAssistantWriteApproval"
|
|
130
130
|
], I = /* @__PURE__ */ new Set();
|
|
131
131
|
function L(e) {
|
|
132
132
|
let t = e.metadata?.assistantAuth;
|
|
133
|
-
return M(t) && t.provisionedVia ===
|
|
133
|
+
return M(t) && t.provisionedVia === _e;
|
|
134
134
|
}
|
|
135
135
|
function R(e) {
|
|
136
136
|
for (let t of e) L(t) && I.add(t.id);
|
|
@@ -145,14 +145,14 @@ function V(e) {
|
|
|
145
145
|
return J(e) === "proposal-v1" && y("provisionAssistantSandbox") !== "unsupported" ? "proposal-v1" : "legacy";
|
|
146
146
|
}
|
|
147
147
|
function H(e) {
|
|
148
|
-
return
|
|
148
|
+
return r(e).some((e) => e.i18nKey === ge || e.code === "SERVICE_UNAVAILABLE");
|
|
149
149
|
}
|
|
150
150
|
function U(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 W(e, t, n, r, i,
|
|
155
|
+
function W(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",
|
|
@@ -174,12 +174,12 @@ function W(e, t, n, r, i, o) {
|
|
|
174
174
|
value: n
|
|
175
175
|
}
|
|
176
176
|
],
|
|
177
|
-
context:
|
|
177
|
+
context: o(n, a)
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
async function G(e, t, n, r, i, a) {
|
|
181
|
-
let o = (await
|
|
182
|
-
query:
|
|
181
|
+
let o = (await c({
|
|
182
|
+
query: te,
|
|
183
183
|
operationName: "ProvisionAssistantSandbox",
|
|
184
184
|
variables: { input: W(e, t, n, r, i, a) },
|
|
185
185
|
workspaceId: n,
|
|
@@ -188,7 +188,7 @@ async function G(e, t, n, r, i, a) {
|
|
|
188
188
|
if (!o) throw Error("provisionAssistantSandbox returned empty response");
|
|
189
189
|
return o;
|
|
190
190
|
}
|
|
191
|
-
async function
|
|
191
|
+
async function ye(e, t, n, r, i, a) {
|
|
192
192
|
try {
|
|
193
193
|
return await G(e, t, n, r, i, a);
|
|
194
194
|
} catch (o) {
|
|
@@ -197,20 +197,20 @@ async function ve(e, t, n, r, i, a) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
function K(e) {
|
|
200
|
-
return b(e, "provisionAssistantSandbox",
|
|
200
|
+
return b(e, "provisionAssistantSandbox", ve);
|
|
201
201
|
}
|
|
202
|
-
async function
|
|
202
|
+
async function be(e, t, n, r, i, a, o = {}) {
|
|
203
203
|
if (B(t, o.writeApproval)) try {
|
|
204
|
-
let o = await
|
|
204
|
+
let o = await ye(e, t, n, r, i, a);
|
|
205
205
|
return x("provisionAssistantSandbox"), I.add(o), o;
|
|
206
206
|
} catch (e) {
|
|
207
207
|
if (!K(e)) throw e;
|
|
208
208
|
S("provisionAssistantSandbox");
|
|
209
209
|
}
|
|
210
|
-
return
|
|
210
|
+
return xe(e, t, n, r, i, a);
|
|
211
211
|
}
|
|
212
|
-
async function
|
|
213
|
-
let
|
|
212
|
+
async function xe(e, t, n, r, i, a) {
|
|
213
|
+
let s = le(t), l = F(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",
|
|
@@ -222,26 +222,26 @@ async function be(e, t, n, r, i, o) {
|
|
|
222
222
|
containerPort: 8080,
|
|
223
223
|
name: "http"
|
|
224
224
|
}],
|
|
225
|
-
env:
|
|
225
|
+
env: l
|
|
226
226
|
}],
|
|
227
|
-
resources:
|
|
227
|
+
resources: s,
|
|
228
228
|
ttlSeconds: i,
|
|
229
229
|
metadata: {
|
|
230
230
|
assistantMode: t,
|
|
231
231
|
assistantProduct: e,
|
|
232
|
-
assistantOwnerUserId:
|
|
233
|
-
assistantOrganizationId:
|
|
234
|
-
authStrategy:
|
|
235
|
-
imageTag:
|
|
232
|
+
assistantOwnerUserId: a.userId ?? null,
|
|
233
|
+
assistantOrganizationId: a.organizationId ?? null,
|
|
234
|
+
authStrategy: se,
|
|
235
|
+
imageTag: ce(t, r),
|
|
236
236
|
confirmWrites: P(t)
|
|
237
237
|
},
|
|
238
|
-
context:
|
|
239
|
-
}), f = (e) =>
|
|
240
|
-
query:
|
|
238
|
+
context: o(n, a)
|
|
239
|
+
}), f = (e) => c({
|
|
240
|
+
query: u,
|
|
241
241
|
operationName: "CreateSandbox",
|
|
242
242
|
variables: { input: d(e) },
|
|
243
243
|
workspaceId: n,
|
|
244
|
-
authContext:
|
|
244
|
+
authContext: a
|
|
245
245
|
}), p;
|
|
246
246
|
try {
|
|
247
247
|
p = await f(i);
|
|
@@ -252,13 +252,13 @@ async function be(e, t, n, r, i, o) {
|
|
|
252
252
|
if (!p?.createSandbox?.id) throw Error("createSandbox returned empty response");
|
|
253
253
|
return p.createSandbox.id;
|
|
254
254
|
}
|
|
255
|
-
async function
|
|
256
|
-
return (await
|
|
257
|
-
query:
|
|
255
|
+
async function Se(e, t, n) {
|
|
256
|
+
return (await c({
|
|
257
|
+
query: ee,
|
|
258
258
|
operationName: "GetSandbox",
|
|
259
259
|
variables: {
|
|
260
260
|
id: e,
|
|
261
|
-
context:
|
|
261
|
+
context: o(t, n)
|
|
262
262
|
},
|
|
263
263
|
workspaceId: t,
|
|
264
264
|
authContext: n
|
|
@@ -267,16 +267,16 @@ async function xe(e, t, n) {
|
|
|
267
267
|
function q(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 Ce(e, t, n, r = 3e5) {
|
|
271
271
|
let i = Date.now();
|
|
272
272
|
if (y("waitForSandboxRunning") !== "unsupported") for (; Date.now() - i < r;) try {
|
|
273
|
-
let r = await
|
|
274
|
-
query:
|
|
273
|
+
let r = await c({
|
|
274
|
+
query: oe,
|
|
275
275
|
operationName: "WaitForSandboxRunning",
|
|
276
276
|
variables: {
|
|
277
277
|
id: e,
|
|
278
278
|
timeoutSeconds: 25,
|
|
279
|
-
context:
|
|
279
|
+
context: o(t, n)
|
|
280
280
|
},
|
|
281
281
|
workspaceId: t,
|
|
282
282
|
authContext: n
|
|
@@ -286,20 +286,20 @@ async function Se(e, t, n, r = 3e5) {
|
|
|
286
286
|
if (i?.status === "RUNNING") return;
|
|
287
287
|
q(i?.status, i?.errorMessage);
|
|
288
288
|
} catch (e) {
|
|
289
|
-
if (
|
|
289
|
+
if (de(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 Se(e, t, n);
|
|
297
297
|
if (r?.status === "RUNNING") return;
|
|
298
298
|
q(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
|
|
302
|
+
async function we(e, t, n, r, i = 9e4, a) {
|
|
303
303
|
let o = Date.now();
|
|
304
304
|
for (; Date.now() - o < i;) {
|
|
305
305
|
try {
|
|
@@ -320,7 +320,7 @@ function J(e) {
|
|
|
320
320
|
function Y(e, t) {
|
|
321
321
|
return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
|
|
322
322
|
}
|
|
323
|
-
var
|
|
323
|
+
var Te = new Set([
|
|
324
324
|
"relay",
|
|
325
325
|
"delegated",
|
|
326
326
|
"direct",
|
|
@@ -334,11 +334,12 @@ function X(e) {
|
|
|
334
334
|
writeExecution: Y(n.writeExecution, r),
|
|
335
335
|
replyApproval: "off",
|
|
336
336
|
...typeof i == "string" && i ? { writeRiskVersion: i } : {},
|
|
337
|
-
...typeof a == "string" &&
|
|
338
|
-
...n.uiOffers === 1 ? { uiOffers: !0 } : {}
|
|
337
|
+
...typeof a == "string" && Te.has(a) ? { sessionCredentials: a } : {},
|
|
338
|
+
...n.uiOffers === 1 ? { uiOffers: !0 } : {},
|
|
339
|
+
...n.clientTools === 1 ? { clientTools: !0 } : {}
|
|
339
340
|
};
|
|
340
341
|
}
|
|
341
|
-
async function
|
|
342
|
+
async function Ee(e, t, n, r) {
|
|
342
343
|
let i;
|
|
343
344
|
try {
|
|
344
345
|
i = await D(e, t, "/health", "GET", void 0, n, r);
|
|
@@ -350,29 +351,29 @@ async function Te(e, t, n, r) {
|
|
|
350
351
|
let o = X(a);
|
|
351
352
|
return C.getState().setSandboxWriteCapabilities(e, o), o;
|
|
352
353
|
}
|
|
353
|
-
async function
|
|
354
|
+
async function De(e, t, n, r) {
|
|
354
355
|
return { sessionId: (await E(e, t, "/sessions", "POST", { mode: n }, n, r, "never")).session.id };
|
|
355
356
|
}
|
|
356
|
-
async function
|
|
357
|
+
async function Oe(e, t, n, r, i) {
|
|
357
358
|
let a = await E(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i, "never");
|
|
358
359
|
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.");
|
|
359
360
|
}
|
|
360
361
|
function Z(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
|
|
361
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 && (!P(n) || N(e.metadata, o)) && j(e, n, o))).map((e) => e.id) : [];
|
|
362
363
|
}
|
|
363
|
-
async function
|
|
364
|
+
async function ke(e, t, n, r, i, a = /* @__PURE__ */ new Set(), s = "legacy") {
|
|
364
365
|
let l, u = /* @__PURE__ */ new Set();
|
|
365
366
|
try {
|
|
366
|
-
let d = (await
|
|
367
|
-
query:
|
|
367
|
+
let d = (await c({
|
|
368
|
+
query: p,
|
|
368
369
|
operationName: "GetActiveSandboxes",
|
|
369
|
-
variables: { context:
|
|
370
|
+
variables: { context: o(e, i) },
|
|
370
371
|
workspaceId: e,
|
|
371
372
|
authContext: i
|
|
372
373
|
})).getActiveSandboxes ?? [];
|
|
373
374
|
R(d);
|
|
374
|
-
let
|
|
375
|
-
if (l = Z(d, t, n, r, i,
|
|
375
|
+
let f = V(s);
|
|
376
|
+
if (l = Z(d, t, n, r, i, a, f), f === "proposal-v1") {
|
|
376
377
|
let e = new Set(l);
|
|
377
378
|
for (let t of d) {
|
|
378
379
|
let n = h(t);
|
|
@@ -384,20 +385,20 @@ async function Oe(e, t, n, r, i, o = /* @__PURE__ */ new Set(), c = "legacy") {
|
|
|
384
385
|
}
|
|
385
386
|
return (await Promise.all(l.map(async (t) => {
|
|
386
387
|
try {
|
|
387
|
-
return await
|
|
388
|
+
return await Ae(t, e, i, { ownerScoped: u.has(t) }), t;
|
|
388
389
|
} catch {
|
|
389
390
|
return null;
|
|
390
391
|
}
|
|
391
392
|
}))).filter((e) => e !== null);
|
|
392
393
|
}
|
|
393
|
-
async function
|
|
394
|
-
if (
|
|
395
|
-
await
|
|
396
|
-
query:
|
|
394
|
+
async function Ae(e, t, n, r = {}) {
|
|
395
|
+
if (i(e), (r.ownerScoped === !0 || z(e)) && y("stopMyAssistantSandbox") !== "unsupported") try {
|
|
396
|
+
await c({
|
|
397
|
+
query: ae,
|
|
397
398
|
operationName: "StopMyAssistantSandbox",
|
|
398
399
|
variables: {
|
|
399
400
|
id: e,
|
|
400
|
-
context:
|
|
401
|
+
context: o(t, n)
|
|
401
402
|
},
|
|
402
403
|
workspaceId: t,
|
|
403
404
|
authContext: n
|
|
@@ -407,34 +408,34 @@ async function ke(e, t, n, i = {}) {
|
|
|
407
408
|
if (!b(e, "stopMyAssistantSandbox")) throw e;
|
|
408
409
|
S("stopMyAssistantSandbox");
|
|
409
410
|
}
|
|
410
|
-
await
|
|
411
|
-
query:
|
|
411
|
+
await c({
|
|
412
|
+
query: ie,
|
|
412
413
|
operationName: "StopAssistantSandbox",
|
|
413
414
|
variables: {
|
|
414
415
|
id: e,
|
|
415
|
-
context:
|
|
416
|
+
context: o(t, n)
|
|
416
417
|
},
|
|
417
418
|
workspaceId: t,
|
|
418
419
|
authContext: n
|
|
419
420
|
});
|
|
420
421
|
}
|
|
421
|
-
var
|
|
422
|
+
var je = /^[A-Za-z0-9_-]{1,128}$/, Me = new Set([
|
|
422
423
|
"affirm",
|
|
423
424
|
"decline",
|
|
424
425
|
"other"
|
|
425
|
-
]),
|
|
426
|
+
]), Ne = new Set([
|
|
426
427
|
"typed",
|
|
427
428
|
"spoken",
|
|
428
429
|
"chip",
|
|
429
430
|
"host_queued",
|
|
430
431
|
"retry",
|
|
431
432
|
"proposal_result"
|
|
432
|
-
]),
|
|
433
|
-
function
|
|
434
|
-
return !e || !
|
|
433
|
+
]), Pe = /^wp_[0-9a-f]{32}$/;
|
|
434
|
+
function Fe(e) {
|
|
435
|
+
return !e || !Me.has(e.kind) || !Ne.has(e.origin) ? null : e.proposalId === void 0 ? {
|
|
435
436
|
kind: e.kind,
|
|
436
437
|
origin: e.origin
|
|
437
|
-
} :
|
|
438
|
+
} : Pe.test(e.proposalId) ? {
|
|
438
439
|
kind: e.kind,
|
|
439
440
|
origin: e.origin,
|
|
440
441
|
proposalId: e.proposalId
|
|
@@ -444,19 +445,19 @@ function Q(e) {
|
|
|
444
445
|
let { mode: t, prompt: n, parts: r } = e, i = {
|
|
445
446
|
mode: t,
|
|
446
447
|
prompt: n,
|
|
447
|
-
pageContext:
|
|
448
|
+
pageContext: pe(e.pageContext)
|
|
448
449
|
};
|
|
449
|
-
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" &&
|
|
450
|
-
let a =
|
|
451
|
-
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), i;
|
|
450
|
+
r && r.length > 0 && (i.parts = r), typeof e.conversationId == "string" && je.test(e.conversationId) && (i.conversationId = e.conversationId);
|
|
451
|
+
let a = Fe(e.writeReply);
|
|
452
|
+
return a && (i.writeReply = a), e.uiCatalogue && (i.uiCatalogue = e.uiCatalogue), e.clientTools && e.clientTools.length > 0 && (i.clientTools = e.clientTools), i;
|
|
452
453
|
}
|
|
453
|
-
function
|
|
454
|
+
function Ie(e) {
|
|
454
455
|
return T(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST", Q(e), e.mode, e.authContext);
|
|
455
456
|
}
|
|
456
457
|
function $(e) {
|
|
457
|
-
return new TextEncoder().encode(JSON.stringify(
|
|
458
|
+
return new TextEncoder().encode(JSON.stringify(Ie(e))).byteLength;
|
|
458
459
|
}
|
|
459
|
-
async function
|
|
460
|
+
async function Le(e, t, n, r, i, a, o, s) {
|
|
460
461
|
if ($({
|
|
461
462
|
sandboxId: e,
|
|
462
463
|
workspaceId: t,
|
|
@@ -468,8 +469,9 @@ async function Ie(e, t, n, r, i, a, o, s) {
|
|
|
468
469
|
parts: s?.parts,
|
|
469
470
|
conversationId: s?.conversationId,
|
|
470
471
|
writeReply: s?.writeReply,
|
|
471
|
-
uiCatalogue: s?.uiCatalogue
|
|
472
|
-
|
|
472
|
+
uiCatalogue: s?.uiCatalogue,
|
|
473
|
+
clientTools: s?.clientTools
|
|
474
|
+
}) > 262144) throw Object.assign(Error(me), { assistantPromptNotDispatched: !0 });
|
|
473
475
|
let c = await E(e, t, `/sessions/${n}/prompt-async`, "POST", Q({
|
|
474
476
|
mode: i,
|
|
475
477
|
prompt: r,
|
|
@@ -477,24 +479,36 @@ async function Ie(e, t, n, r, i, a, o, s) {
|
|
|
477
479
|
parts: s?.parts,
|
|
478
480
|
conversationId: s?.conversationId,
|
|
479
481
|
writeReply: s?.writeReply,
|
|
480
|
-
uiCatalogue: s?.uiCatalogue
|
|
482
|
+
uiCatalogue: s?.uiCatalogue,
|
|
483
|
+
clientTools: s?.clientTools
|
|
481
484
|
}), i, o, "never");
|
|
482
485
|
return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
|
|
483
486
|
}
|
|
484
|
-
async function
|
|
487
|
+
async function Re(e, t, r, i, a, o) {
|
|
485
488
|
let s = `/sessions/${r}/messages?limit=${o?.limit ?? 50}`;
|
|
486
489
|
o?.sinceMs && y("sinceParam") !== "unsupported" && (s += `&since=${o.sinceMs}`);
|
|
487
|
-
let c = await E(e,
|
|
490
|
+
let c = await E(e, t, s, "GET", void 0, i, a, "transport");
|
|
488
491
|
if (typeof c.now == "number" && x("sinceParam"), o?.surfaceUiOffers) try {
|
|
489
492
|
o.surfaceUiOffers(c.uiOffers, typeof c.now == "number" ? c.now : NaN);
|
|
490
493
|
} catch {}
|
|
494
|
+
if (o?.surfaceClientToolRequests) try {
|
|
495
|
+
o.surfaceClientToolRequests(c.clientToolRequests);
|
|
496
|
+
} catch {}
|
|
491
497
|
if (o?.surfaceTurnTerminal === !0) {
|
|
492
|
-
let e =
|
|
498
|
+
let e = n(c.turnTerminal);
|
|
493
499
|
if (e) throw e;
|
|
494
500
|
}
|
|
495
501
|
return c.messages ?? [];
|
|
496
502
|
}
|
|
497
|
-
async function
|
|
503
|
+
async function ze(t, n, r, i, a, o, s) {
|
|
504
|
+
try {
|
|
505
|
+
await E(t, n, `/sessions/${r}/client-tools/${i}/result`, "POST", { result: a }, o, s, "never");
|
|
506
|
+
} catch (t) {
|
|
507
|
+
if (t instanceof e && t.status === 409) return;
|
|
508
|
+
throw t;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
async function Be(e, t, n, r, i) {
|
|
498
512
|
if (y("sse") === "unsupported") return null;
|
|
499
513
|
try {
|
|
500
514
|
let a = await E(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i, "transport");
|
|
@@ -506,13 +520,13 @@ async function Re(e, t, n, r, i) {
|
|
|
506
520
|
return S("sse"), null;
|
|
507
521
|
}
|
|
508
522
|
}
|
|
509
|
-
async function
|
|
510
|
-
if (
|
|
523
|
+
async function Ve(e, t, n, r, i, a = Date.now) {
|
|
524
|
+
if (fe(a())) return null;
|
|
511
525
|
try {
|
|
512
526
|
let { status: o, body: s } = await D(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i);
|
|
513
527
|
if (o === 404) return v(_, a()), null;
|
|
514
528
|
let c = o >= 200 && o < 300 && typeof s == "object" && s ? s : null;
|
|
515
|
-
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" &&
|
|
529
|
+
return c && c.transport === "relay" && typeof c.url == "string" && typeof c.expiresAt == "number" && He(c.url) ? (ue(), {
|
|
516
530
|
url: c.url,
|
|
517
531
|
expiresAt: c.expiresAt
|
|
518
532
|
}) : (v(c ? _ : g, a()), null);
|
|
@@ -520,7 +534,7 @@ async function ze(e, t, n, r, i, a = Date.now) {
|
|
|
520
534
|
return v(g, a()), null;
|
|
521
535
|
}
|
|
522
536
|
}
|
|
523
|
-
function
|
|
537
|
+
function He(e) {
|
|
524
538
|
try {
|
|
525
539
|
let { protocol: t } = new URL(e);
|
|
526
540
|
return t === "https:" || t === "http:";
|
|
@@ -528,15 +542,15 @@ function Be(e) {
|
|
|
528
542
|
return !1;
|
|
529
543
|
}
|
|
530
544
|
}
|
|
531
|
-
async function
|
|
545
|
+
async function Ue(e, t, n, r) {
|
|
532
546
|
if (z(e) && y("extendMyAssistantSandboxTTL") !== "unsupported") try {
|
|
533
|
-
await
|
|
534
|
-
query:
|
|
547
|
+
await c({
|
|
548
|
+
query: d,
|
|
535
549
|
operationName: "ExtendMyAssistantSandboxTtl",
|
|
536
550
|
variables: {
|
|
537
551
|
id: e,
|
|
538
552
|
additionalSeconds: n,
|
|
539
|
-
context:
|
|
553
|
+
context: o(t, r)
|
|
540
554
|
},
|
|
541
555
|
workspaceId: t,
|
|
542
556
|
authContext: r
|
|
@@ -546,39 +560,39 @@ async function Ve(e, t, n, r) {
|
|
|
546
560
|
if (!b(e, "extendMyAssistantSandboxTTL")) throw e;
|
|
547
561
|
S("extendMyAssistantSandboxTTL");
|
|
548
562
|
}
|
|
549
|
-
await
|
|
550
|
-
query:
|
|
563
|
+
await c({
|
|
564
|
+
query: f,
|
|
551
565
|
operationName: "ExtendSandboxTtl",
|
|
552
566
|
variables: {
|
|
553
567
|
id: e,
|
|
554
568
|
additionalSeconds: n,
|
|
555
|
-
context:
|
|
569
|
+
context: o(t, r)
|
|
556
570
|
},
|
|
557
571
|
workspaceId: t,
|
|
558
572
|
authContext: r
|
|
559
573
|
});
|
|
560
574
|
}
|
|
561
|
-
async function
|
|
575
|
+
async function We(e, t, n, r, i) {
|
|
562
576
|
await E(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r, i, "transport").catch(() => void 0);
|
|
563
577
|
}
|
|
564
|
-
async function
|
|
578
|
+
async function Ge(e, t, n, r, i) {
|
|
565
579
|
try {
|
|
566
580
|
return (await E(e, t, `/sessions/${n}/abort`, "POST", void 0, r, i, "never"))?.aborted === !0;
|
|
567
581
|
} catch {
|
|
568
582
|
return !1;
|
|
569
583
|
}
|
|
570
584
|
}
|
|
571
|
-
async function
|
|
585
|
+
async function Ke(e, t, n, r, i) {
|
|
572
586
|
return ((await E(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r, i, "transport")).artifacts ?? []).filter((e) => !e.name.startsWith("."));
|
|
573
587
|
}
|
|
574
|
-
async function
|
|
588
|
+
async function qe(e, t, n, r, i) {
|
|
575
589
|
let a = await E(e, t, `/sessions/${n}`, "GET", void 0, r, i, "transport");
|
|
576
590
|
return {
|
|
577
591
|
id: a.session?.id ?? n,
|
|
578
592
|
mode: a.mode ?? "unknown"
|
|
579
593
|
};
|
|
580
594
|
}
|
|
581
|
-
async function
|
|
595
|
+
async function Je(e, t, n, r, i, a) {
|
|
582
596
|
let o = (await E(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i, a, "transport")).artifact;
|
|
583
597
|
if (!o) throw Error("Artifact download returned an empty response");
|
|
584
598
|
return {
|
|
@@ -587,21 +601,21 @@ async function Ke(e, t, n, r, i, a) {
|
|
|
587
601
|
contentBase64: o.contentBase64
|
|
588
602
|
};
|
|
589
603
|
}
|
|
590
|
-
async function
|
|
591
|
-
return (await
|
|
592
|
-
query:
|
|
604
|
+
async function Ye(e, t) {
|
|
605
|
+
return (await c({
|
|
606
|
+
query: l,
|
|
593
607
|
operationName: "CheckAiCredits",
|
|
594
608
|
variables: {},
|
|
595
609
|
workspaceId: e,
|
|
596
610
|
authContext: t
|
|
597
611
|
})).checkAiCredits;
|
|
598
612
|
}
|
|
599
|
-
async function
|
|
600
|
-
let
|
|
601
|
-
if (
|
|
613
|
+
async function Xe(e, t, n, r, i, a) {
|
|
614
|
+
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
|
+
if (o + l + u + d === 0 || !r) return;
|
|
602
616
|
let f = !1;
|
|
603
617
|
if (i.cache) try {
|
|
604
|
-
f = (await
|
|
618
|
+
f = (await s({
|
|
605
619
|
query: "query AiCacheTokensSupported { aiCacheTokensSupported }",
|
|
606
620
|
operationName: "AiCacheTokensSupported",
|
|
607
621
|
variables: {},
|
|
@@ -609,14 +623,14 @@ async function Je(e, t, n, r, i, a) {
|
|
|
609
623
|
authContext: a
|
|
610
624
|
})).aiCacheTokensSupported === !0;
|
|
611
625
|
} catch {}
|
|
612
|
-
await
|
|
613
|
-
query:
|
|
626
|
+
await c({
|
|
627
|
+
query: re,
|
|
614
628
|
operationName: "ReportAiTokenUsage",
|
|
615
629
|
variables: { input: {
|
|
616
630
|
sessionId: t,
|
|
617
631
|
messageId: n,
|
|
618
632
|
model: r,
|
|
619
|
-
inputTokens:
|
|
633
|
+
inputTokens: o,
|
|
620
634
|
outputTokens: l,
|
|
621
635
|
...f ? {
|
|
622
636
|
cacheReadTokens: u,
|
|
@@ -628,4 +642,4 @@ async function Je(e, t, n, r, i, a) {
|
|
|
628
642
|
});
|
|
629
643
|
}
|
|
630
644
|
//#endregion
|
|
631
|
-
export {
|
|
645
|
+
export { je as PROMPT_CONVERSATION_ID_PATTERN, Ge as abortAssistantTurn, Oe as approvePendingWrite, j as askReuseMatchesProvisioning, F as buildAssistantSandboxEnv, Ie as buildPromptGatewayRequest, Q as buildPromptRequestBody, W as buildProvisionAssistantSandboxInput, Ye as checkAssistantAiCredits, be as createAssistantSandbox, De as createAssistantSession, Je as downloadAssistantArtifact, Ue as extendAssistantSandboxTTL, he as findExistingSandbox, O as findExistingSandboxWithStatus, w as forwardsUserTokensToSandbox, Ke as getAssistantArtifacts, Re as getAssistantMessages, qe as getAssistantSession, Be as getAssistantStreamAccess, H as isAssistantProvisioningUnavailable, z as isDedicatedAssistantSandbox, L as isDedicatedAssistantSandboxRow, Ve as mintAssistantTurnStream, P as modeRequiresConfirmWrites, ze as postClientToolResult, $ as promptGatewayRequestBytes, D as proxySandboxRaw, X as readSandboxWriteCapabilities, Ee as readSandboxWriteCapabilitiesOnce, ke as releaseSupersededAssistantSandboxes, Xe as reportAssistantAiTokenUsage, k as sandboxStatusOf, A as selectExistingAssistantSandbox, Z as selectSupersededAssistantSandboxes, Le as sendAssistantPromptAsync, We as sendHeartbeat, Ae as stopReapedAssistantSandbox, B as usesDedicatedAssistantProvisioning, we as waitForAssistantServiceReady, Ce as waitForSandboxRunning, J as writeApprovalModeOf, N as writeApprovalReuseMatches, Y as writeExecutionOf };
|