@burdenoff/fe-libs 2026.1021.11 → 2026.1021.13

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