@burdenoff/fe-libs 2026.1004.8 → 2026.1005.2

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 (99) hide show
  1. package/dist/shared/assistant/api.d.ts +18 -0
  2. package/dist/shared/assistant/api.d.ts.map +1 -1
  3. package/dist/shared/assistant/api.js +169 -147
  4. package/dist/shared/assistant/capabilities.d.ts +21 -0
  5. package/dist/shared/assistant/capabilities.d.ts.map +1 -1
  6. package/dist/shared/assistant/capabilities.js +11 -1
  7. package/dist/shared/assistant/i18nManifest.d.ts +4 -0
  8. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  9. package/dist/shared/assistant/i18nManifest.js +4 -0
  10. package/dist/shared/assistant/index.d.ts +20 -0
  11. package/dist/shared/assistant/index.d.ts.map +1 -1
  12. package/dist/shared/assistant/liveDeltas.d.ts +76 -0
  13. package/dist/shared/assistant/liveDeltas.d.ts.map +1 -0
  14. package/dist/shared/assistant/liveDeltas.js +196 -0
  15. package/dist/shared/assistant/liveOverlay.d.ts +62 -0
  16. package/dist/shared/assistant/liveOverlay.d.ts.map +1 -0
  17. package/dist/shared/assistant/liveOverlay.js +64 -0
  18. package/dist/shared/assistant/snapshotPoller.d.ts +48 -0
  19. package/dist/shared/assistant/snapshotPoller.d.ts.map +1 -0
  20. package/dist/shared/assistant/snapshotPoller.js +58 -0
  21. package/dist/shared/assistant/speech/browserSpeechEngine.d.ts.map +1 -1
  22. package/dist/shared/assistant/speech/browserSpeechEngine.js +46 -45
  23. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.d.ts.map +1 -1
  24. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +80 -79
  25. package/dist/shared/assistant/store.d.ts +3 -0
  26. package/dist/shared/assistant/store.d.ts.map +1 -1
  27. package/dist/shared/assistant/store.js +43 -35
  28. package/dist/shared/assistant/turnStream.d.ts +71 -0
  29. package/dist/shared/assistant/turnStream.d.ts.map +1 -0
  30. package/dist/shared/assistant/turnStream.js +266 -0
  31. package/dist/shared/assistant/turnTimeline.d.ts +27 -2
  32. package/dist/shared/assistant/turnTimeline.d.ts.map +1 -1
  33. package/dist/shared/assistant/turnTimeline.js +17 -28
  34. package/dist/shared/assistant/types.d.ts +10 -0
  35. package/dist/shared/assistant/types.d.ts.map +1 -1
  36. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  37. package/dist/shared/assistant/ui/AssistantChatArea.js +886 -843
  38. package/dist/shared/assistant/ui/AssistantMessageList.d.ts +2 -0
  39. package/dist/shared/assistant/ui/AssistantMessageList.d.ts.map +1 -1
  40. package/dist/shared/assistant/ui/AssistantMessageList.js +48 -32
  41. package/dist/shared/assistant/ui/AssistantMoreMenu.d.ts.map +1 -1
  42. package/dist/shared/assistant/ui/AssistantMoreMenu.js +59 -57
  43. package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.d.ts +17 -0
  44. package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.d.ts.map +1 -0
  45. package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.js +34 -0
  46. package/dist/shared/assistant/ui/useVoiceSession.d.ts +29 -2
  47. package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
  48. package/dist/shared/assistant/ui/useVoiceSession.js +247 -213
  49. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +2 -0
  50. package/dist/shared/assistant/voice/handsfree/audioTrackTransport.d.ts +33 -0
  51. package/dist/shared/assistant/voice/handsfree/audioTrackTransport.d.ts.map +1 -0
  52. package/dist/shared/assistant/voice/handsfree/audioTrackTransport.js +98 -0
  53. package/dist/shared/assistant/voice/handsfree/backendStreamTransport.d.ts +34 -0
  54. package/dist/shared/assistant/voice/handsfree/backendStreamTransport.d.ts.map +1 -0
  55. package/dist/shared/assistant/voice/handsfree/backendStreamTransport.js +130 -0
  56. package/dist/shared/assistant/voice/handsfree/bargeIn.d.ts +43 -0
  57. package/dist/shared/assistant/voice/handsfree/bargeIn.d.ts.map +1 -0
  58. package/dist/shared/assistant/voice/handsfree/bargeIn.js +32 -0
  59. package/dist/shared/assistant/voice/handsfree/captureWorklet.d.ts +47 -0
  60. package/dist/shared/assistant/voice/handsfree/captureWorklet.d.ts.map +1 -0
  61. package/dist/shared/assistant/voice/handsfree/captureWorklet.js +85 -0
  62. package/dist/shared/assistant/voice/handsfree/echoGate.d.ts +140 -0
  63. package/dist/shared/assistant/voice/handsfree/echoGate.d.ts.map +1 -0
  64. package/dist/shared/assistant/voice/handsfree/echoGate.js +198 -0
  65. package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts +77 -0
  66. package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts.map +1 -0
  67. package/dist/shared/assistant/voice/handsfree/handsFreeController.js +126 -0
  68. package/dist/shared/assistant/voice/handsfree/handsFreeRuntime.d.ts +15 -0
  69. package/dist/shared/assistant/voice/handsfree/handsFreeRuntime.d.ts.map +1 -0
  70. package/dist/shared/assistant/voice/handsfree/handsFreeRuntime.js +78 -0
  71. package/dist/shared/assistant/voice/handsfree/handsFreeSetting.d.ts +26 -0
  72. package/dist/shared/assistant/voice/handsfree/handsFreeSetting.d.ts.map +1 -0
  73. package/dist/shared/assistant/voice/handsfree/handsFreeSetting.js +25 -0
  74. package/dist/shared/assistant/voice/handsfree/micCapture.d.ts +21 -0
  75. package/dist/shared/assistant/voice/handsfree/micCapture.d.ts.map +1 -0
  76. package/dist/shared/assistant/voice/handsfree/micCapture.js +72 -0
  77. package/dist/shared/assistant/voice/handsfree/playbackReference.d.ts +38 -0
  78. package/dist/shared/assistant/voice/handsfree/playbackReference.d.ts.map +1 -0
  79. package/dist/shared/assistant/voice/handsfree/playbackReference.js +55 -0
  80. package/dist/shared/assistant/voice/handsfree/preRollRing.d.ts +32 -0
  81. package/dist/shared/assistant/voice/handsfree/preRollRing.d.ts.map +1 -0
  82. package/dist/shared/assistant/voice/handsfree/preRollRing.js +34 -0
  83. package/dist/shared/assistant/voice/handsfree/sttTransport.d.ts +94 -0
  84. package/dist/shared/assistant/voice/handsfree/sttTransport.d.ts.map +1 -0
  85. package/dist/shared/assistant/voice/handsfree/sttTransport.js +27 -0
  86. package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts +33 -0
  87. package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts.map +1 -0
  88. package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.js +70 -0
  89. package/dist/shared/assistant/voice/handsfree/vad.d.ts +55 -0
  90. package/dist/shared/assistant/voice/handsfree/vad.d.ts.map +1 -0
  91. package/dist/shared/assistant/voice/handsfree/vad.js +41 -0
  92. package/dist/shared/assistant/voice/handsfree/webSpeechTransport.d.ts +3 -0
  93. package/dist/shared/assistant/voice/handsfree/webSpeechTransport.d.ts.map +1 -0
  94. package/dist/shared/assistant/voice/handsfree/webSpeechTransport.js +16 -0
  95. package/dist/shared/assistant/voice/voiceSession.d.ts +9 -0
  96. package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
  97. package/dist/shared/assistant/voice/voiceSession.js +2 -2
  98. package/dist/shared-assistant.js +224 -204
  99. package/package.json +2 -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 { getCapability as g, isMissingGatewayFieldError as _, isUnknownFieldError as se, markSupported as v, markUnsupported as y } from "./capabilities.js";
7
- import { useAssistantStore as b } from "./store.js";
8
- import { REQUEST_TOO_LARGE_REFUSAL as ce } from "./gatewayLimits.js";
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 x(e) {
10
+ function w(e) {
11
11
  return e === "assistant" || e === "api-calls";
12
12
  }
13
- function S(e, t, n, i, a, o, s) {
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
- ...x(o) ? {
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 C(t, n, r, i, o, s, c) {
30
+ async function E(t, n, r, i, o, s, c) {
31
31
  let l = (await a({
32
- ...S(t, n, r, i, o, s, c),
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 w(e, t, n, r, a, o, s) {
42
+ async function D(e, t, n, r, a, o, s) {
43
43
  let c = (await i({
44
- ...S(e, t, n, r, a, o, s),
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 le(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
55
- return (await T(e, t, n, r, i, a, o))?.id ?? null;
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 T(e, t, n, i, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
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
- F(l);
66
- let d = D(l, t, n, i, o, s, R(c));
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: E(l, d)
69
+ status: k(l, d)
70
70
  } : null;
71
71
  }
72
- function E(e, t) {
72
+ function k(e, t) {
73
73
  return e.find((e) => e.id === t)?.status ?? "UNKNOWN";
74
74
  }
75
- function D(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 && (!j(n) || A(e.metadata, o)) && O(e, n, o))?.id ?? null;
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 O(e, t, n) {
79
- return t !== "assistant" || n !== "proposal-v1" ? !0 : P(e);
78
+ function j(e, t, n) {
79
+ return t !== "assistant" || n !== "proposal-v1" ? !0 : L(e);
80
80
  }
81
- function k(e) {
81
+ function M(e) {
82
82
  return typeof e == "object" && !!e && !Array.isArray(e);
83
83
  }
84
- function A(e, t) {
84
+ function N(e, t) {
85
85
  let n = e?.assistantAuth;
86
- return k(n) && n.accessProfile === "member" ? !0 : (e?.writeApproval ?? "legacy") === t ? e?.confirmWrites === (t === "proposal-v1" ? "proposal-v1" : !0) : !1;
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 j(e) {
88
+ function P(e) {
89
89
  return e === "api-calls";
90
90
  }
91
- function M(e, t, n, r) {
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
- })), j(t) && i.push({
119
+ })), P(t) && i.push({
120
120
  name: "AI_ASSISTANT_CONFIRM_WRITES",
121
121
  value: "1"
122
122
  }), i;
123
123
  }
124
- var ue = "assistant.errors.assistantProvisioningUnavailable", de = "provisionAssistantSandbox", fe = [
124
+ var fe = "assistant.errors.assistantProvisioningUnavailable", pe = "provisionAssistantSandbox", me = [
125
125
  "ProvisionAssistantSandboxInput",
126
126
  "SandboxAssistantMode",
127
127
  "SandboxAssistantWriteApproval"
128
- ], N = /* @__PURE__ */ new Set();
129
- function P(e) {
128
+ ], I = /* @__PURE__ */ new Set();
129
+ function L(e) {
130
130
  let t = e.metadata?.assistantAuth;
131
- return k(t) && t.provisionedVia === de;
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
- return G(e) === "proposal-v1" && g("provisionAssistantSandbox") !== "unsupported" ? "proposal-v1" : "legacy";
134
+ for (let t of e) L(t) && I.add(t.id);
144
135
  }
145
136
  function z(e) {
146
- return n(e).some((e) => e.i18nKey === ue || e.code === "SERVICE_UNAVAILABLE");
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 V(e, t, n, i, a, o) {
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 H(e, t, n, r, i, o) {
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: V(e, t, n, r, i, o) },
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 pe(e, t, n, r, i, a) {
189
+ async function he(e, t, n, r, i, a) {
190
190
  try {
191
- return await H(e, t, n, r, i, a);
191
+ return await G(e, t, n, r, i, a);
192
192
  } catch (o) {
193
- if (z(o) || U(o) || !B(o, i)) throw o;
194
- return H(e, t, n, r, 600, a);
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 U(e) {
198
- return _(e, "provisionAssistantSandbox", fe);
197
+ function K(e) {
198
+ return b(e, "provisionAssistantSandbox", me);
199
199
  }
200
- async function me(e, t, n, r, i, a, o = {}) {
201
- if (L(t, o.writeApproval)) try {
202
- let o = await pe(e, t, n, r, i, a);
203
- return v("provisionAssistantSandbox"), N.add(o), o;
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 (!U(e)) throw e;
206
- y("provisionAssistantSandbox");
205
+ if (!K(e)) throw e;
206
+ S("provisionAssistantSandbox");
207
207
  }
208
- return he(e, t, n, r, i, a);
208
+ return _e(e, t, n, r, i, a);
209
209
  }
210
- async function he(e, t, n, i, o, c) {
211
- let l = oe(t), u = M(e, t, n, c), d = (a) => ({
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: j(t)
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 (B(e, o)) p = await f(600);
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 ge(e, t, n) {
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 W(e, t) {
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 _e(e, t, n, i = 3e5) {
268
+ async function ye(e, t, n, i = 3e5) {
269
269
  let o = Date.now();
270
- if (g("waitForSandboxRunning") !== "unsupported") for (; Date.now() - o < i;) try {
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
- v("waitForSandboxRunning");
282
+ x("waitForSandboxRunning");
283
283
  let o = i.waitForSandboxRunning;
284
284
  if (o?.status === "RUNNING") return;
285
- W(o?.status, o?.errorMessage);
285
+ q(o?.status, o?.errorMessage);
286
286
  } catch (e) {
287
- if (se(e)) {
288
- y("waitForSandboxRunning");
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 ge(e, t, n);
294
+ let r = await ve(e, t, n);
295
295
  if (r?.status === "RUNNING") return;
296
- W(r?.status, r?.errorMessage), await new Promise((e) => setTimeout(e, 2e3));
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 ve(e, t, n, r, i = 9e4, a) {
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 C(e, t, "/health", "GET", void 0, n, r);
305
- return b.getState().setSandboxWriteCapabilities(e, q(i)), i;
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 G(e) {
315
+ function J(e) {
316
316
  return e === "proposal-v1" ? "proposal-v1" : "legacy";
317
317
  }
318
- function K(e, t) {
318
+ function Y(e, t) {
319
319
  return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
320
320
  }
321
- var ye = new Set([
321
+ var xe = new Set([
322
322
  "relay",
323
323
  "delegated",
324
324
  "direct",
325
325
  "unconfigured"
326
326
  ]);
327
- function q(e) {
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: G(n.writeApprovalMode),
332
- writeExecution: K(n.writeExecution, r),
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" && ye.has(a) ? { sessionCredentials: a } : {}
335
+ ...typeof a == "string" && xe.has(a) ? { sessionCredentials: a } : {}
336
336
  };
337
337
  }
338
- async function be(e, t, n, r) {
338
+ async function Se(e, t, n, r) {
339
339
  let i;
340
340
  try {
341
- i = await w(e, t, "/health", "GET", void 0, n, r);
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 = q(a);
348
- return b.getState().setSandboxWriteCapabilities(e, o), o;
347
+ let o = X(a);
348
+ return C.getState().setSandboxWriteCapabilities(e, o), o;
349
349
  }
350
- async function xe(e, t, n, r) {
351
- return { sessionId: (await C(e, t, "/sessions", "POST", { mode: n }, n, r)).session.id };
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 Se(e, t, n, r, i) {
354
- let a = await C(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i);
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 J(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 && (!j(n) || A(e.metadata, o)) && O(e, n, o))).map((e) => e.id) : [];
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 Ce(e, t, n, i, o, s = /* @__PURE__ */ new Set(), c = "legacy") {
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
- F(f);
371
- let p = R(c);
372
- if (l = J(f, t, n, i, o, s, p), p === "proposal-v1") {
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 Y(t, e, o, { ownerScoped: d.has(t) }), t;
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 Y(e, t, n, i = {}) {
391
- if ((i.ownerScoped === !0 || I(e)) && g("stopMyAssistantSandbox") !== "unsupported") try {
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
- }), v("stopMyAssistantSandbox");
401
+ }), x("stopMyAssistantSandbox");
402
402
  return;
403
403
  } catch (e) {
404
- if (!_(e, "stopMyAssistantSandbox")) throw e;
405
- y("stopMyAssistantSandbox");
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 X = /^[A-Za-z0-9_-]{1,128}$/, we = new Set([
418
+ var Ee = /^[A-Za-z0-9_-]{1,128}$/, De = new Set([
419
419
  "affirm",
420
420
  "decline",
421
421
  "other"
422
- ]), Te = new Set([
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
- ]), 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 ? {
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
- } : Ee.test(e.proposalId) ? {
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 Z(e) {
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" && X.test(e.conversationId) && (a.conversationId = e.conversationId);
447
- let o = De(e.writeReply);
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 Q(e) {
451
- return S(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST", Z(e), e.mode, e.authContext);
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 $(e) {
454
- return new TextEncoder().encode(JSON.stringify(Q(e))).byteLength;
453
+ function Me(e) {
454
+ return new TextEncoder().encode(JSON.stringify(je(e))).byteLength;
455
455
  }
456
- async function Oe(e, t, n, r, i, a, o, s) {
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(ce);
470
- let c = await C(e, t, `/sessions/${n}/prompt-async`, "POST", Z({
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 ke(e, n, r, i, a, o) {
481
+ async function Pe(e, n, r, i, a, o) {
482
482
  let s = `/sessions/${r}/messages?limit=${o?.limit ?? 50}`;
483
- o?.sinceMs && g("sinceParam") !== "unsupported" && (s += `&since=${o.sinceMs}`);
484
- let c = await C(e, n, s, "GET", void 0, i, a);
485
- if (typeof c.now == "number" && v("sinceParam"), o?.surfaceTurnTerminal === !0) {
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 Ae(e, t, n, r, i) {
492
- if (g("sse") === "unsupported") return null;
491
+ async function Fe(e, t, n, r, i) {
492
+ if (y("sse") === "unsupported") return null;
493
493
  try {
494
- let a = await C(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i);
495
- return typeof a.url == "string" && typeof a.expiresAt == "number" ? (v("sse"), {
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
- }) : (y("sse"), null);
498
+ }) : (S("sse"), null);
499
499
  } catch {
500
- return y("sse"), null;
500
+ return S("sse"), null;
501
501
  }
502
502
  }
503
- async function je(e, t, n, i) {
504
- if (I(e) && g("extendMyAssistantSandboxTTL") !== "unsupported") try {
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
- }), v("extendMyAssistantSandboxTTL");
537
+ }), x("extendMyAssistantSandboxTTL");
516
538
  return;
517
539
  } catch (e) {
518
- if (!_(e, "extendMyAssistantSandboxTTL")) throw e;
519
- y("extendMyAssistantSandboxTTL");
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 Me(e, t, n, r, i) {
534
- await C(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r, i).catch(() => void 0);
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 Ne(e, t, n, r, i) {
558
+ async function Be(e, t, n, r, i) {
537
559
  try {
538
- return (await C(e, t, `/sessions/${n}/abort`, "POST", void 0, r, i))?.aborted === !0;
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 Pe(e, t, n, r, i) {
544
- return ((await C(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r, i)).artifacts ?? []).filter((e) => !e.name.startsWith("."));
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 Fe(e, t, n, r, i) {
547
- let a = await C(e, t, `/sessions/${n}`, "GET", void 0, r, i);
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 Ie(e, t, n, r, i, a) {
554
- let o = (await C(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i, a)).artifact;
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 Le(e, t) {
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 Re(e, t, n, r, i, o) {
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 { 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 };
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 };