@burdenoff/fe-libs 2026.1001.4 → 2026.1001.5

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