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