@burdenoff/fe-libs 2026.928.3 → 2026.930.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/shared/assistant/adminModeSendGate.d.ts +6 -5
  2. package/dist/shared/assistant/adminModeSendGate.d.ts.map +1 -1
  3. package/dist/shared/assistant/adminModeSendGate.js +11 -11
  4. package/dist/shared/assistant/api.d.ts +313 -28
  5. package/dist/shared/assistant/api.d.ts.map +1 -1
  6. package/dist/shared/assistant/api.js +351 -135
  7. package/dist/shared/assistant/autoRouting.d.ts +11 -3
  8. package/dist/shared/assistant/autoRouting.d.ts.map +1 -1
  9. package/dist/shared/assistant/autoRouting.js +7 -7
  10. package/dist/shared/assistant/capabilities.d.ts +28 -0
  11. package/dist/shared/assistant/capabilities.d.ts.map +1 -1
  12. package/dist/shared/assistant/capabilities.js +19 -10
  13. package/dist/shared/assistant/conversation.d.ts +24 -2
  14. package/dist/shared/assistant/conversation.d.ts.map +1 -1
  15. package/dist/shared/assistant/createSandboxAssistantTransport.d.ts.map +1 -1
  16. package/dist/shared/assistant/createSandboxAssistantTransport.js +67 -54
  17. package/dist/shared/assistant/history/historyList.js +1 -1
  18. package/dist/shared/assistant/history/historyMapping.d.ts.map +1 -1
  19. package/dist/shared/assistant/history/historyMapping.js +5 -1
  20. package/dist/shared/assistant/history/historyResume.js +7 -7
  21. package/dist/shared/assistant/i18nManifest.d.ts +53 -0
  22. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  23. package/dist/shared/assistant/i18nManifest.js +75 -16
  24. package/dist/shared/assistant/index.d.ts +15 -0
  25. package/dist/shared/assistant/index.d.ts.map +1 -1
  26. package/dist/shared/assistant/modeCapabilities.js +1 -1
  27. package/dist/shared/assistant/operations.d.ts +22 -0
  28. package/dist/shared/assistant/operations.d.ts.map +1 -1
  29. package/dist/shared/assistant/operations.js +2 -2
  30. package/dist/shared/assistant/prewarm.d.ts +7 -0
  31. package/dist/shared/assistant/prewarm.d.ts.map +1 -1
  32. package/dist/shared/assistant/prewarm.js +1 -1
  33. package/dist/shared/assistant/product.d.ts +80 -2
  34. package/dist/shared/assistant/product.d.ts.map +1 -1
  35. package/dist/shared/assistant/product.js +10 -6
  36. package/dist/shared/assistant/proposalWriteRules.d.ts +40 -0
  37. package/dist/shared/assistant/proposalWriteRules.d.ts.map +1 -0
  38. package/dist/shared/assistant/proposalWriteRules.js +14 -0
  39. package/dist/shared/assistant/store.d.ts +17 -0
  40. package/dist/shared/assistant/store.d.ts.map +1 -1
  41. package/dist/shared/assistant/store.js +50 -43
  42. package/dist/shared/assistant/turnOutcome.d.ts +34 -2
  43. package/dist/shared/assistant/turnOutcome.d.ts.map +1 -1
  44. package/dist/shared/assistant/turnOutcome.js +28 -17
  45. package/dist/shared/assistant/turnOutcomeCopy.d.ts +29 -7
  46. package/dist/shared/assistant/turnOutcomeCopy.d.ts.map +1 -1
  47. package/dist/shared/assistant/turnOutcomeCopy.js +18 -6
  48. package/dist/shared/assistant/types.d.ts +5 -1
  49. package/dist/shared/assistant/types.d.ts.map +1 -1
  50. package/dist/shared/assistant/ui/AssistantApiCallsConsentDialog.js +4 -4
  51. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  52. package/dist/shared/assistant/ui/AssistantChatArea.js +992 -718
  53. package/dist/shared/assistant/ui/AssistantConversationList.js +6 -6
  54. package/dist/shared/assistant/ui/AssistantLanguageMenu.js +6 -6
  55. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +8 -1
  56. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts.map +1 -1
  57. package/dist/shared/assistant/ui/AssistantMessageItem.js +77 -76
  58. package/dist/shared/assistant/ui/AssistantMessageList.d.ts +13 -1
  59. package/dist/shared/assistant/ui/AssistantMessageList.d.ts.map +1 -1
  60. package/dist/shared/assistant/ui/AssistantMessageList.js +15 -13
  61. package/dist/shared/assistant/ui/AssistantReplyLanguageSelector.js +5 -5
  62. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +209 -209
  63. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.d.ts +62 -0
  64. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.d.ts.map +1 -0
  65. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.js +253 -0
  66. package/dist/shared/assistant/ui/AssistantWriteProposalCard.d.ts +72 -0
  67. package/dist/shared/assistant/ui/AssistantWriteProposalCard.d.ts.map +1 -0
  68. package/dist/shared/assistant/ui/AssistantWriteProposalCard.js +439 -0
  69. package/dist/shared/assistant/ui/AssistantWriteProposalSlot.d.ts +40 -0
  70. package/dist/shared/assistant/ui/AssistantWriteProposalSlot.d.ts.map +1 -0
  71. package/dist/shared/assistant/ui/AssistantWriteProposalSlot.js +35 -0
  72. package/dist/shared/assistant/ui/composer/AssistantComposer.js +8 -8
  73. package/dist/shared/assistant/ui/useVoiceSession.d.ts +28 -0
  74. package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
  75. package/dist/shared/assistant/ui/useVoiceSession.js +159 -110
  76. package/dist/shared/assistant/ui/useWriteProposalConfirm.d.ts +61 -0
  77. package/dist/shared/assistant/ui/useWriteProposalConfirm.d.ts.map +1 -0
  78. package/dist/shared/assistant/ui/useWriteProposalConfirm.js +109 -0
  79. package/dist/shared/assistant/ui/useWriteProposals.d.ts +128 -0
  80. package/dist/shared/assistant/ui/useWriteProposals.d.ts.map +1 -0
  81. package/dist/shared/assistant/ui/useWriteProposals.js +240 -0
  82. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +17 -1
  83. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts.map +1 -1
  84. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +141 -109
  85. package/dist/shared/assistant/ui/writeProposalPresentation.d.ts +76 -0
  86. package/dist/shared/assistant/ui/writeProposalPresentation.d.ts.map +1 -0
  87. package/dist/shared/assistant/ui/writeProposalPresentation.js +110 -0
  88. package/dist/shared/assistant/usageReporting.d.ts +108 -0
  89. package/dist/shared/assistant/usageReporting.d.ts.map +1 -0
  90. package/dist/shared/assistant/usageReporting.js +155 -0
  91. package/dist/shared/assistant/useAssistantApiAccess.d.ts +49 -14
  92. package/dist/shared/assistant/useAssistantApiAccess.d.ts.map +1 -1
  93. package/dist/shared/assistant/useAssistantApiAccess.js +43 -25
  94. package/dist/shared/assistant/useAssistantHeartbeat.d.ts.map +1 -1
  95. package/dist/shared/assistant/useAssistantHeartbeat.js +5 -5
  96. package/dist/shared/assistant/useWorkspaceWriteAccess.d.ts +5 -6
  97. package/dist/shared/assistant/useWorkspaceWriteAccess.d.ts.map +1 -1
  98. package/dist/shared/assistant/voice/voiceSession.d.ts +46 -0
  99. package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
  100. package/dist/shared/assistant/voice/voiceSession.js +35 -2
  101. package/dist/shared/assistant/writeConfirmSeam.d.ts +32 -0
  102. package/dist/shared/assistant/writeConfirmSeam.d.ts.map +1 -0
  103. package/dist/shared/assistant/writeConfirmSeam.js +23 -0
  104. package/dist/shared/assistant/writeModeConsent.d.ts +16 -8
  105. package/dist/shared/assistant/writeModeConsent.d.ts.map +1 -1
  106. package/dist/shared/assistant/writeModeConsent.js +2 -2
  107. package/dist/shared/assistant/writeProposalDiscovery.d.ts +187 -0
  108. package/dist/shared/assistant/writeProposalDiscovery.d.ts.map +1 -0
  109. package/dist/shared/assistant/writeProposalDiscovery.js +246 -0
  110. package/dist/shared/assistant/writeProposalErrorCopy.d.ts +135 -0
  111. package/dist/shared/assistant/writeProposalErrorCopy.d.ts.map +1 -0
  112. package/dist/shared/assistant/writeProposalErrorCopy.js +135 -0
  113. package/dist/shared/assistant/writeProposalVoice.d.ts +133 -0
  114. package/dist/shared/assistant/writeProposalVoice.d.ts.map +1 -0
  115. package/dist/shared/assistant/writeProposalVoice.js +66 -0
  116. package/dist/shared/assistant/writeProposals.d.ts +268 -0
  117. package/dist/shared/assistant/writeProposals.d.ts.map +1 -0
  118. package/dist/shared/assistant/writeProposals.js +445 -0
  119. package/dist/shared/assistant/writeReplyBinder.d.ts +166 -0
  120. package/dist/shared/assistant/writeReplyBinder.d.ts.map +1 -0
  121. package/dist/shared/assistant/writeReplyBinder.js +233 -0
  122. package/dist/shared/assistant/writeReplySend.d.ts +110 -0
  123. package/dist/shared/assistant/writeReplySend.d.ts.map +1 -0
  124. package/dist/shared/assistant/writeReplySend.js +93 -0
  125. package/dist/shared-assistant.js +168 -153
  126. package/dist/ui/modal-shell.d.ts +14 -1
  127. package/dist/ui/modal-shell.d.ts.map +1 -1
  128. package/dist/ui/modal-shell.js +8 -6
  129. package/package.json +1 -1
@@ -1,33 +1,35 @@
1
- import { buildSandboxContextInput as e, executeSandboxGraphQL as t } from "./gatewayClient.js";
2
- import { CHECK_AI_CREDITS as n, CREATE_SANDBOX as r, EXTEND_SANDBOX_TTL as i, GET_ACTIVE_SANDBOXES as a, GET_SANDBOX as o, PROXY_SANDBOX_REQUEST as s, REPORT_AI_TOKEN_USAGE as c, STOP_ASSISTANT_SANDBOX as l, WAIT_FOR_SANDBOX_RUNNING as u } from "./operations.js";
3
- import { ASSISTANT_API_AUTH_STRATEGY as d, getImageForMode as f, getImageTagForMode as p, getResourcesForMode as m, resolveSandboxAssistantMode as h } from "./images.js";
4
- import { getCapability as g, isUnknownFieldError as _, markSupported as v, markUnsupported as y } from "./capabilities.js";
5
- import { REQUEST_TOO_LARGE_REFUSAL as b } from "./gatewayLimits.js";
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";
6
+ import { useAssistantStore as b } from "./store.js";
7
+ import { REQUEST_TOO_LARGE_REFUSAL as oe } from "./gatewayLimits.js";
6
8
  //#region src/shared/assistant/api.ts
7
9
  function x(e) {
8
- return e === "assistant";
10
+ return e === "assistant" || e === "api-calls";
9
11
  }
10
- function S(t, n, r, i, a, o, c) {
12
+ function S(e, n, r, i, a, o, s) {
11
13
  return {
12
- query: s,
14
+ query: d,
13
15
  operationName: "ProxySandboxRequest",
14
16
  variables: { input: {
15
- sandboxId: t,
17
+ sandboxId: e,
16
18
  path: r,
17
19
  method: i,
18
20
  body: a,
19
- context: e(n, c),
21
+ context: t(n, s),
20
22
  ...x(o) ? {
21
- forwardedAuthToken: c?.accessToken ?? void 0,
22
- forwardedWorkspaceToken: c?.workspaceToken ?? void 0
23
+ forwardedAuthToken: s?.accessToken ?? void 0,
24
+ forwardedWorkspaceToken: s?.workspaceToken ?? void 0
23
25
  } : {}
24
26
  } }
25
27
  };
26
28
  }
27
- async function C(e, n, r, i, a, o, s) {
28
- let c = (await t({
29
- ...S(e, n, r, i, a, o, s),
30
- workspaceId: n,
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,
31
33
  authContext: s
32
34
  })).proxySandboxRequest;
33
35
  if (!c || c.status >= 400) {
@@ -36,32 +38,56 @@ async function C(e, n, r, i, a, o, s) {
36
38
  }
37
39
  return c.body;
38
40
  }
39
- async function w(e, t, n, r, i, a = /* @__PURE__ */ new Set()) {
40
- return (await T(e, t, n, r, i, a))?.id ?? null;
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),
44
+ workspaceId: t,
45
+ authContext: s
46
+ })).proxySandboxRequest;
47
+ if (typeof c != "object" || !c || !("status" in c) || typeof c.status != "number" || !Number.isInteger(c.status)) throw Error("Proxy error: unknown");
48
+ return {
49
+ status: c.status,
50
+ body: "body" in c ? c.body ?? null : null
51
+ };
52
+ }
53
+ async function se(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
54
+ return (await T(e, t, n, r, i, a, o))?.id ?? null;
41
55
  }
42
- async function T(n, r, i, o, s, c = /* @__PURE__ */ new Set()) {
43
- let l = (await t({
44
- query: a,
56
+ async function T(e, n, i, a, o, s = /* @__PURE__ */ new Set(), l = "legacy") {
57
+ let u = (await r({
58
+ query: c,
45
59
  operationName: "GetActiveSandboxes",
46
- variables: { context: e(n, s) },
47
- workspaceId: n,
48
- authContext: s
49
- })).getActiveSandboxes ?? [], u = D(l, r, i, o, s, c);
50
- return u ? {
51
- id: u,
52
- status: E(l, u)
60
+ variables: { context: t(e, o) },
61
+ workspaceId: e,
62
+ authContext: o
63
+ })).getActiveSandboxes ?? [];
64
+ F(u);
65
+ let d = D(u, n, i, a, o, s, R(l));
66
+ return d ? {
67
+ id: d,
68
+ status: E(u, d)
53
69
  } : null;
54
70
  }
55
71
  function E(e, t) {
56
72
  return e.find((e) => e.id === t)?.status ?? "UNKNOWN";
57
73
  }
58
- function D(e, t, n, r, i, a = /* @__PURE__ */ new Set()) {
59
- 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 && (!O(n) || e.metadata?.confirmWrites === !0))?.id ?? null;
74
+ function D(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
75
+ 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;
60
76
  }
61
- function O(e) {
77
+ function O(e, t, n) {
78
+ return t !== "assistant" || n !== "proposal-v1" ? !0 : P(e);
79
+ }
80
+ function k(e) {
81
+ return typeof e == "object" && !!e && !Array.isArray(e);
82
+ }
83
+ function A(e, t) {
84
+ let n = e?.assistantAuth;
85
+ return k(n) && n.accessProfile === "member" ? !0 : (e?.writeApproval ?? "legacy") === t ? e?.confirmWrites === (t === "proposal-v1" ? "proposal-v1" : !0) : !1;
86
+ }
87
+ function j(e) {
62
88
  return e === "api-calls";
63
89
  }
64
- function k(e, t, n, r) {
90
+ function M(e, t, n, r) {
65
91
  let i = [
66
92
  {
67
93
  name: "AI_ASSISTANT_MODE",
@@ -89,20 +115,106 @@ function k(e, t, n, r) {
89
115
  }), r.workspaceToken && i.push({
90
116
  name: "WORKSPACE_AUTH_TOKEN",
91
117
  value: r.workspaceToken
92
- })), O(t) && i.push({
118
+ })), j(t) && i.push({
93
119
  name: "AI_ASSISTANT_CONFIRM_WRITES",
94
120
  value: "1"
95
121
  }), i;
96
122
  }
97
- async function A(n, i, a, o, s, c) {
98
- let l = m(i), u = k(n, i, a, c), h = (t) => ({
99
- name: `ai-assistant-${i}-${Date.now()}`,
100
- description: `AI Assistant sandbox (${i} mode)`,
123
+ var ce = "assistant.errors.assistantProvisioningUnavailable", le = "provisionAssistantSandbox", ue = [
124
+ "ProvisionAssistantSandboxInput",
125
+ "SandboxAssistantMode",
126
+ "SandboxAssistantWriteApproval"
127
+ ], N = /* @__PURE__ */ new Set();
128
+ function P(e) {
129
+ let t = e.metadata?.assistantAuth;
130
+ return k(t) && t.provisionedVia === le;
131
+ }
132
+ function F(e) {
133
+ for (let t of e) P(t) && N.add(t.id);
134
+ }
135
+ function I(e) {
136
+ return N.has(e);
137
+ }
138
+ function L(e, t) {
139
+ return G(t) === "proposal-v1" && (e === "assistant" || e === "api-calls") && g("provisionAssistantSandbox") !== "unsupported";
140
+ }
141
+ function R(e) {
142
+ return G(e) === "proposal-v1" && g("provisionAssistantSandbox") !== "unsupported" ? "proposal-v1" : "legacy";
143
+ }
144
+ function z(t) {
145
+ return e(t).some((e) => e.i18nKey === ce || e.code === "SERVICE_UNAVAILABLE");
146
+ }
147
+ function B(e, t) {
148
+ if (t <= 600) return !1;
149
+ let n = e instanceof Error ? e.message.toLowerCase() : String(e);
150
+ return n.includes("ttl") || n.includes("validation") || n.includes("maximum");
151
+ }
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`);
154
+ return {
155
+ mode: n === "assistant" ? "ASSISTANT" : "API_CALLS",
156
+ product: e,
157
+ image: m(n, i),
158
+ ttlSeconds: a,
159
+ ...n === "api-calls" ? { writeApproval: "PROPOSAL_V1" } : {},
160
+ env: [
161
+ {
162
+ name: "AI_ASSISTANT_PRODUCT",
163
+ value: e
164
+ },
165
+ {
166
+ name: "HOSTNAME",
167
+ value: "0.0.0.0"
168
+ },
169
+ {
170
+ name: "WORKSPACE_ID",
171
+ value: r
172
+ }
173
+ ],
174
+ context: t(r, o)
175
+ };
176
+ }
177
+ async function H(e, t, n, i, a, o) {
178
+ let s = (await r({
179
+ query: u,
180
+ operationName: "ProvisionAssistantSandbox",
181
+ variables: { input: V(e, t, n, i, a, o) },
182
+ workspaceId: n,
183
+ authContext: o
184
+ }))?.provisionAssistantSandbox?.id;
185
+ if (!s) throw Error("provisionAssistantSandbox returned empty response");
186
+ return s;
187
+ }
188
+ async function de(e, t, n, r, i, a) {
189
+ try {
190
+ return await H(e, t, n, r, i, a);
191
+ } catch (o) {
192
+ if (z(o) || U(o) || !B(o, i)) throw o;
193
+ return H(e, t, n, r, 600, a);
194
+ }
195
+ }
196
+ function U(e) {
197
+ return _(e, "provisionAssistantSandbox", ue);
198
+ }
199
+ async function fe(e, t, n, r, i, a, o = {}) {
200
+ if (L(t, o.writeApproval)) try {
201
+ let o = await de(e, t, n, r, i, a);
202
+ return v("provisionAssistantSandbox"), N.add(o), o;
203
+ } catch (e) {
204
+ if (!U(e)) throw e;
205
+ y("provisionAssistantSandbox");
206
+ }
207
+ return pe(e, t, n, r, i, a);
208
+ }
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)`,
101
213
  template: "AI_BUILDER",
102
214
  mode: "DEPLOYMENT",
103
215
  containers: [{
104
216
  name: "ai-assistant",
105
- image: f(i, o),
217
+ image: m(n, o),
106
218
  ports: [{
107
219
  containerPort: 8080,
108
220
  name: "http"
@@ -110,87 +222,86 @@ async function A(n, i, a, o, s, c) {
110
222
  env: u
111
223
  }],
112
224
  resources: l,
113
- ttlSeconds: t,
225
+ ttlSeconds: r,
114
226
  metadata: {
115
- assistantMode: i,
116
- assistantProduct: n,
227
+ assistantMode: n,
228
+ assistantProduct: e,
117
229
  assistantOwnerUserId: c.userId ?? null,
118
230
  assistantOrganizationId: c.organizationId ?? null,
119
- authStrategy: d,
120
- imageTag: p(i, o),
121
- confirmWrites: O(i)
231
+ authStrategy: ne,
232
+ imageTag: re(n, o),
233
+ confirmWrites: j(n)
122
234
  },
123
- context: e(a, c)
124
- }), g = (e) => t({
125
- query: r,
235
+ context: t(i, c)
236
+ }), f = (e) => r({
237
+ query: a,
126
238
  operationName: "CreateSandbox",
127
- variables: { input: h(e) },
128
- workspaceId: a,
239
+ variables: { input: d(e) },
240
+ workspaceId: i,
129
241
  authContext: c
130
- }), _;
242
+ }), p;
131
243
  try {
132
- _ = await g(s);
244
+ p = await f(s);
133
245
  } catch (e) {
134
- let t = e instanceof Error ? e.message.toLowerCase() : String(e);
135
- if (s > 600 && (t.includes("ttl") || t.includes("validation") || t.includes("maximum"))) _ = await g(600);
246
+ if (B(e, s)) p = await f(600);
136
247
  else throw e;
137
248
  }
138
- if (!_?.createSandbox?.id) throw Error("createSandbox returned empty response");
139
- return _.createSandbox.id;
249
+ if (!p?.createSandbox?.id) throw Error("createSandbox returned empty response");
250
+ return p.createSandbox.id;
140
251
  }
141
- async function j(n, r, i) {
142
- return (await t({
143
- query: o,
252
+ async function me(e, n, i) {
253
+ return (await r({
254
+ query: l,
144
255
  operationName: "GetSandbox",
145
256
  variables: {
146
- id: n,
147
- context: e(r, i)
257
+ id: e,
258
+ context: t(n, i)
148
259
  },
149
- workspaceId: r,
260
+ workspaceId: n,
150
261
  authContext: i
151
262
  })).getSandbox;
152
263
  }
153
- function M(e, t) {
264
+ function W(e, t) {
154
265
  if (e === "FAILED" || e === "STOPPED" || e === "EXPIRED") throw Error(t ? `Sandbox ${e.toLowerCase()}: ${t}` : `Sandbox ${e.toLowerCase()}`);
155
266
  }
156
- async function N(n, r, i, a = 3e5) {
267
+ async function he(e, n, i, a = 3e5) {
157
268
  let o = Date.now();
158
269
  if (g("waitForSandboxRunning") !== "unsupported") for (; Date.now() - o < a;) try {
159
- let a = await t({
160
- query: u,
270
+ let a = await r({
271
+ query: te,
161
272
  operationName: "WaitForSandboxRunning",
162
273
  variables: {
163
- id: n,
274
+ id: e,
164
275
  timeoutSeconds: 25,
165
- context: e(r, i)
276
+ context: t(n, i)
166
277
  },
167
- workspaceId: r,
278
+ workspaceId: n,
168
279
  authContext: i
169
280
  });
170
281
  v("waitForSandboxRunning");
171
282
  let o = a.waitForSandboxRunning;
172
283
  if (o?.status === "RUNNING") return;
173
- M(o?.status, o?.errorMessage);
284
+ W(o?.status, o?.errorMessage);
174
285
  } catch (e) {
175
- if (_(e)) {
286
+ if (ae(e)) {
176
287
  y("waitForSandboxRunning");
177
288
  break;
178
289
  }
179
290
  throw e;
180
291
  }
181
292
  for (; Date.now() - o < a;) {
182
- let e = await j(n, r, i);
183
- if (e?.status === "RUNNING") return;
184
- M(e?.status, e?.errorMessage), await new Promise((e) => setTimeout(e, 2e3));
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));
185
296
  }
186
297
  throw Error("Sandbox startup timed out");
187
298
  }
188
- async function P(e, t, n, r, i = 9e4, a) {
299
+ async function ge(e, t, n, r, i = 9e4, a) {
189
300
  let o = Date.now();
190
301
  for (; Date.now() - o < i;) {
191
302
  try {
192
- await C(e, t, "/health", "GET", void 0, n, r);
193
- return;
303
+ let i = await C(e, t, "/health", "GET", void 0, n, r);
304
+ return b.getState().setSandboxWriteCapabilities(e, q(i)), i;
194
305
  } catch (e) {
195
306
  let t = e instanceof Error ? e.message : String(e);
196
307
  if (!/proxy error: 502|proxy error: 503|proxy error: 404|service not available|starting/i.test(t)) throw e;
@@ -200,65 +311,149 @@ async function P(e, t, n, r, i = 9e4, a) {
200
311
  }
201
312
  throw Error("Assistant service did not become healthy before timeout");
202
313
  }
203
- async function F(e, t, n, r) {
314
+ function G(e) {
315
+ return e === "proposal-v1" ? "proposal-v1" : "legacy";
316
+ }
317
+ function K(e, t) {
318
+ return e === "enabled" || e === void 0 && !t ? "enabled" : "fenced";
319
+ }
320
+ var _e = new Set([
321
+ "relay",
322
+ "delegated",
323
+ "direct",
324
+ "unconfigured"
325
+ ]);
326
+ function q(e) {
327
+ 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;
328
+ return {
329
+ proposals: n.writeProposals === "v1",
330
+ writeApprovalMode: G(n.writeApprovalMode),
331
+ writeExecution: K(n.writeExecution, r),
332
+ replyApproval: "off",
333
+ ...typeof i == "string" && i ? { writeRiskVersion: i } : {},
334
+ ...typeof a == "string" && _e.has(a) ? { sessionCredentials: a } : {}
335
+ };
336
+ }
337
+ async function ve(e, t, n, r) {
338
+ let i;
339
+ try {
340
+ i = await w(e, t, "/health", "GET", void 0, n, r);
341
+ } catch {
342
+ return null;
343
+ }
344
+ let a = i.body;
345
+ if (i.status < 200 || i.status >= 300 || typeof a != "object" || !a || Array.isArray(a)) return null;
346
+ let o = q(a);
347
+ return b.getState().setSandboxWriteCapabilities(e, o), o;
348
+ }
349
+ async function ye(e, t, n, r) {
204
350
  return { sessionId: (await C(e, t, "/sessions", "POST", { mode: n }, n, r)).session.id };
205
351
  }
206
- async function I(e, t, n, r, i) {
352
+ async function be(e, t, n, r, i) {
207
353
  let a = await C(e, t, `/write-confirmations/${encodeURIComponent(n)}/approve`, "POST", {}, r, i);
208
354
  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.");
209
355
  }
210
- function L(e, t, n, r, i, a = /* @__PURE__ */ new Set()) {
211
- 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)).map((e) => e.id) : [];
356
+ function J(e, t, n, r, i, a = /* @__PURE__ */ new Set(), o = "legacy") {
357
+ 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) : [];
212
358
  }
213
- async function R(n, r, i, o, s, c = /* @__PURE__ */ new Set()) {
214
- let l;
359
+ async function xe(e, n, i, a, o, s = /* @__PURE__ */ new Set(), l = "legacy") {
360
+ let u, d = /* @__PURE__ */ new Set();
215
361
  try {
216
- l = L((await t({
217
- query: a,
362
+ let f = (await r({
363
+ query: c,
218
364
  operationName: "GetActiveSandboxes",
219
- variables: { context: e(n, s) },
220
- workspaceId: n,
221
- authContext: s
222
- })).getActiveSandboxes ?? [], r, i, o, s, c);
365
+ variables: { context: t(e, o) },
366
+ workspaceId: e,
367
+ authContext: o
368
+ })).getActiveSandboxes ?? [];
369
+ 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);
373
+ for (let t of f) {
374
+ let n = h(t);
375
+ e.has(t.id) && (n === "assistant" || n === "api-calls") && d.add(t.id);
376
+ }
377
+ }
223
378
  } catch {
224
379
  return [];
225
380
  }
226
- return (await Promise.all(l.map(async (e) => {
381
+ return (await Promise.all(u.map(async (t) => {
227
382
  try {
228
- return await z(e, n, s), e;
383
+ return await Y(t, e, o, { ownerScoped: d.has(t) }), t;
229
384
  } catch {
230
385
  return null;
231
386
  }
232
387
  }))).filter((e) => e !== null);
233
388
  }
234
- async function z(n, r, i) {
235
- await t({
236
- query: l,
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,
393
+ operationName: "StopMyAssistantSandbox",
394
+ variables: {
395
+ id: e,
396
+ context: t(n, i)
397
+ },
398
+ workspaceId: n,
399
+ authContext: i
400
+ }), v("stopMyAssistantSandbox");
401
+ return;
402
+ } catch (e) {
403
+ if (!_(e, "stopMyAssistantSandbox")) throw e;
404
+ y("stopMyAssistantSandbox");
405
+ }
406
+ await r({
407
+ query: p,
237
408
  operationName: "StopAssistantSandbox",
238
409
  variables: {
239
- id: n,
240
- context: e(r, i)
410
+ id: e,
411
+ context: t(n, i)
241
412
  },
242
- workspaceId: r,
413
+ workspaceId: n,
243
414
  authContext: i
244
415
  });
245
416
  }
246
- function B(e) {
417
+ var X = /^[A-Za-z0-9_-]{1,128}$/, Se = new Set([
418
+ "affirm",
419
+ "decline",
420
+ "other"
421
+ ]), Ce = new Set([
422
+ "typed",
423
+ "spoken",
424
+ "chip",
425
+ "host_queued",
426
+ "retry",
427
+ "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 ? {
431
+ kind: e.kind,
432
+ origin: e.origin
433
+ } : we.test(e.proposalId) ? {
434
+ kind: e.kind,
435
+ origin: e.origin,
436
+ proposalId: e.proposalId
437
+ } : null;
438
+ }
439
+ function Z(e) {
247
440
  let { mode: t, prompt: n, pageContext: r, parts: i } = e, a = {
248
441
  mode: t,
249
442
  prompt: n,
250
443
  pageContext: r
251
444
  };
252
- return i && i.length > 0 && (a.parts = i), a;
445
+ 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
+ return o && (a.writeReply = o), a;
253
448
  }
254
- function V(e) {
255
- return S(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST", B(e), e.mode, e.authContext);
449
+ function Q(e) {
450
+ return S(e.sandboxId, e.workspaceId, `/sessions/${e.sessionId}/prompt-async`, "POST", Z(e), e.mode, e.authContext);
256
451
  }
257
- function H(e) {
258
- return new TextEncoder().encode(JSON.stringify(V(e))).byteLength;
452
+ function $(e) {
453
+ return new TextEncoder().encode(JSON.stringify(Q(e))).byteLength;
259
454
  }
260
- async function U(e, t, n, r, i, a, o, s) {
261
- if (H({
455
+ async function Ee(e, t, n, r, i, a, o, s) {
456
+ if ($({
262
457
  sandboxId: e,
263
458
  workspaceId: t,
264
459
  sessionId: n,
@@ -266,23 +461,27 @@ async function U(e, t, n, r, i, a, o, s) {
266
461
  mode: i,
267
462
  pageContext: a,
268
463
  authContext: o,
269
- parts: s?.parts
270
- }) > 262144) throw Error(b);
271
- let c = await C(e, t, `/sessions/${n}/prompt-async`, "POST", B({
464
+ parts: s?.parts,
465
+ conversationId: s?.conversationId,
466
+ writeReply: s?.writeReply
467
+ }) > 262144) throw Error(oe);
468
+ let c = await C(e, t, `/sessions/${n}/prompt-async`, "POST", Z({
272
469
  mode: i,
273
470
  prompt: r,
274
471
  pageContext: a,
275
- parts: s?.parts
472
+ parts: s?.parts,
473
+ conversationId: s?.conversationId,
474
+ writeReply: s?.writeReply
276
475
  }), i, o);
277
476
  return { messageID: typeof c.messageID == "string" ? c.messageID : void 0 };
278
477
  }
279
- async function W(e, t, n, r, i, a) {
478
+ async function De(e, t, n, r, i, a) {
280
479
  let o = `/sessions/${n}/messages?limit=${a?.limit ?? 50}`;
281
480
  a?.sinceMs && g("sinceParam") !== "unsupported" && (o += `&since=${a.sinceMs}`);
282
481
  let s = await C(e, t, o, "GET", void 0, r, i);
283
482
  return typeof s.now == "number" && v("sinceParam"), s.messages ?? [];
284
483
  }
285
- async function G(e, t, n, r, i) {
484
+ async function Oe(e, t, n, r, i) {
286
485
  if (g("sse") === "unsupported") return null;
287
486
  try {
288
487
  let a = await C(e, t, `/sessions/${n}/stream-url`, "GET", void 0, r, i);
@@ -294,40 +493,57 @@ async function G(e, t, n, r, i) {
294
493
  return y("sse"), null;
295
494
  }
296
495
  }
297
- async function K(n, r, a, o) {
298
- await t({
299
- query: i,
496
+ async function ke(e, n, i, a) {
497
+ if (I(e) && g("extendMyAssistantSandboxTTL") !== "unsupported") try {
498
+ await r({
499
+ query: o,
500
+ operationName: "ExtendMyAssistantSandboxTtl",
501
+ variables: {
502
+ id: e,
503
+ additionalSeconds: i,
504
+ context: t(n, a)
505
+ },
506
+ workspaceId: n,
507
+ authContext: a
508
+ }), v("extendMyAssistantSandboxTTL");
509
+ return;
510
+ } catch (e) {
511
+ if (!_(e, "extendMyAssistantSandboxTTL")) throw e;
512
+ y("extendMyAssistantSandboxTTL");
513
+ }
514
+ await r({
515
+ query: s,
300
516
  operationName: "ExtendSandboxTtl",
301
517
  variables: {
302
- id: n,
303
- additionalSeconds: a,
304
- context: e(r, o)
518
+ id: e,
519
+ additionalSeconds: i,
520
+ context: t(n, a)
305
521
  },
306
- workspaceId: r,
307
- authContext: o
522
+ workspaceId: n,
523
+ authContext: a
308
524
  });
309
525
  }
310
- async function q(e, t, n, r, i) {
526
+ async function Ae(e, t, n, r, i) {
311
527
  await C(e, t, `/sessions/${n}/heartbeat`, "POST", void 0, r, i).catch(() => void 0);
312
528
  }
313
- async function J(e, t, n, r, i) {
529
+ async function je(e, t, n, r, i) {
314
530
  try {
315
531
  return (await C(e, t, `/sessions/${n}/abort`, "POST", void 0, r, i))?.aborted === !0;
316
532
  } catch {
317
533
  return !1;
318
534
  }
319
535
  }
320
- async function Y(e, t, n, r, i) {
536
+ async function Me(e, t, n, r, i) {
321
537
  return ((await C(e, t, `/sessions/${n}/artifacts`, "GET", void 0, r, i)).artifacts ?? []).filter((e) => !e.name.startsWith("."));
322
538
  }
323
- async function X(e, t, n, r, i) {
539
+ async function Ne(e, t, n, r, i) {
324
540
  let a = await C(e, t, `/sessions/${n}`, "GET", void 0, r, i);
325
541
  return {
326
542
  id: a.session?.id ?? n,
327
543
  mode: a.mode ?? "unknown"
328
544
  };
329
545
  }
330
- async function Z(e, t, n, r, i, a) {
546
+ async function Pe(e, t, n, r, i, a) {
331
547
  let o = (await C(e, t, `/sessions/${n}/artifacts/download?path=${encodeURIComponent(r)}`, "GET", void 0, i, a)).artifact;
332
548
  if (!o) throw Error("Artifact download returned an empty response");
333
549
  return {
@@ -336,30 +552,30 @@ async function Z(e, t, n, r, i, a) {
336
552
  contentBase64: o.contentBase64
337
553
  };
338
554
  }
339
- async function Q(e, r) {
340
- return (await t({
341
- query: n,
555
+ async function Fe(e, t) {
556
+ return (await r({
557
+ query: i,
342
558
  operationName: "CheckAiCredits",
343
559
  variables: {},
344
560
  workspaceId: e,
345
- authContext: r
561
+ authContext: t
346
562
  })).checkAiCredits;
347
563
  }
348
- async function $(e, n, r, i, a, o) {
349
- let s = Math.max(0, Math.round(a.input ?? 0)), l = Math.max(0, Math.round(a.output ?? 0));
350
- s + l === 0 || !i || await t({
351
- query: c,
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,
352
568
  operationName: "ReportAiTokenUsage",
353
569
  variables: { input: {
354
- sessionId: n,
355
- messageId: r,
570
+ sessionId: t,
571
+ messageId: n,
356
572
  model: i,
357
573
  inputTokens: s,
358
- outputTokens: l
574
+ outputTokens: c
359
575
  } },
360
576
  workspaceId: e,
361
577
  authContext: o
362
578
  });
363
579
  }
364
580
  //#endregion
365
- export { J as abortAssistantTurn, I as approvePendingWrite, k as buildAssistantSandboxEnv, V as buildPromptGatewayRequest, B as buildPromptRequestBody, Q as checkAssistantAiCredits, A as createAssistantSandbox, F as createAssistantSession, Z as downloadAssistantArtifact, K as extendAssistantSandboxTTL, w as findExistingSandbox, T as findExistingSandboxWithStatus, x as forwardsUserTokensToSandbox, Y as getAssistantArtifacts, W as getAssistantMessages, X as getAssistantSession, G as getAssistantStreamAccess, O as modeRequiresConfirmWrites, H as promptGatewayRequestBytes, R as releaseSupersededAssistantSandboxes, $ as reportAssistantAiTokenUsage, E as sandboxStatusOf, D as selectExistingAssistantSandbox, L as selectSupersededAssistantSandboxes, U as sendAssistantPromptAsync, q as sendHeartbeat, z as stopReapedAssistantSandbox, P as waitForAssistantServiceReady, N as waitForSandboxRunning };
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 };