@gravity-rail/sdk 0.8.0 → 0.10.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 (43) hide show
  1. package/README.md +38 -0
  2. package/dist/{chunk-ML55PVP7.js → chunk-2BJG4GYM.js} +641 -541
  3. package/dist/chunk-2BJG4GYM.js.map +1 -0
  4. package/dist/chunk-FSSXKQR5.js +471 -0
  5. package/dist/chunk-FSSXKQR5.js.map +1 -0
  6. package/dist/{chunk-QS6ZRQUZ.js → chunk-TJT7A4CO.js} +8 -1
  7. package/dist/{chunk-QS6ZRQUZ.js.map → chunk-TJT7A4CO.js.map} +1 -1
  8. package/dist/{client-C2aWAalu.d.cts → client-BffM3KcA.d.cts} +1190 -313
  9. package/dist/{client-CLGovEox.d.ts → client-DfjAYbt8.d.ts} +1190 -313
  10. package/dist/helpers.cjs +178 -2
  11. package/dist/helpers.cjs.map +1 -1
  12. package/dist/helpers.d.cts +82 -3
  13. package/dist/helpers.d.ts +82 -3
  14. package/dist/helpers.js +156 -1
  15. package/dist/helpers.js.map +1 -1
  16. package/dist/index.cjs +851 -166
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +14 -8
  19. package/dist/index.d.ts +14 -8
  20. package/dist/index.js +144 -20
  21. package/dist/index.js.map +1 -1
  22. package/dist/{inquiries-CmECZnkl.d.cts → inquiries-UcWNYo-Q.d.cts} +564 -79
  23. package/dist/{inquiries-CmECZnkl.d.ts → inquiries-UcWNYo-Q.d.ts} +564 -79
  24. package/dist/internal.cjs +784 -153
  25. package/dist/internal.cjs.map +1 -1
  26. package/dist/internal.d.cts +241 -5
  27. package/dist/internal.d.ts +241 -5
  28. package/dist/internal.js +71 -7
  29. package/dist/internal.js.map +1 -1
  30. package/dist/realtime.cjs +1 -0
  31. package/dist/realtime.cjs.map +1 -1
  32. package/dist/realtime.js +1 -0
  33. package/dist/realtime.js.map +1 -1
  34. package/dist/schemas.cjs +29 -7
  35. package/dist/schemas.cjs.map +1 -1
  36. package/dist/schemas.d.cts +106 -51
  37. package/dist/schemas.d.ts +106 -51
  38. package/dist/schemas.js +29 -8
  39. package/dist/schemas.js.map +1 -1
  40. package/dist/{scopes-D6a_Mvqr.d.ts → scopes-CjSvITpL.d.cts} +53 -8
  41. package/dist/{scopes-CDaJBQVT.d.cts → scopes-CmNKWrzb.d.ts} +53 -8
  42. package/package.json +5 -5
  43. package/dist/chunk-ML55PVP7.js.map +0 -1
@@ -1,456 +1,6 @@
1
- // src/api/base.ts
2
- function getCookieValue(name) {
3
- if (typeof document === "undefined") return void 0;
4
- const cookies = document.cookie.split(";");
5
- for (const cookie of cookies) {
6
- const trimmedCookie = cookie.trim();
7
- const eqIndex = trimmedCookie.indexOf("=");
8
- if (eqIndex === -1) continue;
9
- const cookieName = trimmedCookie.substring(0, eqIndex);
10
- const cookieValue = trimmedCookie.substring(eqIndex + 1);
11
- if (cookieName === name) {
12
- return cookieValue;
13
- }
14
- }
15
- return void 0;
16
- }
17
- function isApiValidationError(value) {
18
- if (!value || typeof value !== "object") return false;
19
- const v = value;
20
- return typeof v.field === "string" && typeof v.kind === "string" && typeof v.message === "string";
21
- }
22
- var ApiError = class extends Error {
23
- statusCode;
24
- /** Legacy string-array errors — kept for non-validation callers. */
25
- errors;
26
- /**
27
- * Structured workflow-expression validation errors (CEL/Jinja).
28
- * Populated when the backend returns a WorkflowValidationErrorResponse.
29
- */
30
- validationErrors;
31
- constructor(message, statusCode, errors, validationErrors) {
32
- super(message);
33
- this.statusCode = statusCode;
34
- this.errors = errors;
35
- this.validationErrors = validationErrors;
36
- }
37
- };
38
- function requiresStepUpAuth(wwwAuthenticate) {
39
- if (!wwwAuthenticate) return false;
40
- return wwwAuthenticate.includes('error="insufficient_user_authentication"');
41
- }
42
- function parseOrgAuthChallenge(wwwAuthenticate) {
43
- if (!wwwAuthenticate) return null;
44
- if (!wwwAuthenticate.includes('realm="org"')) return null;
45
- const orgUuidMatch = wwwAuthenticate.match(/org_uuid="([^"]+)"/);
46
- const cookieNameMatch = wwwAuthenticate.match(/cookie_name="([^"]+)"/);
47
- const authUrlMatch = wwwAuthenticate.match(/auth_url="([^"]+)"/);
48
- if (!orgUuidMatch?.[1] || !cookieNameMatch?.[1] || !authUrlMatch?.[1]) {
49
- console.warn("Invalid org auth challenge header: missing required fields");
50
- return null;
51
- }
52
- return {
53
- orgUuid: orgUuidMatch[1],
54
- cookieName: cookieNameMatch[1],
55
- authUrl: authUrlMatch[1]
56
- };
57
- }
58
- var BaseApiClient = class {
59
- baseUrl;
60
- apiKey;
61
- isCrossDomain;
62
- fetchFunction;
63
- enhancedAuthHandler;
64
- enhancedAuthInProgress = null;
65
- orgAuthHandler;
66
- orgAuthInProgress = null;
67
- actingMemberUuid;
68
- orgToken;
69
- /**
70
- * The org_uuid that issued the current orgToken. Tracked so we can detect
71
- * a 401 challenge from a *different* org and re-fire the handler — the
72
- * orgToken is an opaque JWE we cannot decrypt client-side, so without this
73
- * the original guard `!this.orgToken` would prevent re-auth across orgs and
74
- * surface as a silent 401 in multi-org CLI workflows.
75
- */
76
- orgTokenOrgUuid;
77
- constructor(apiKey, baseUrl, customFetch) {
78
- this.baseUrl = baseUrl;
79
- this.apiKey = apiKey;
80
- this.fetchFunction = customFetch || (typeof window !== "undefined" ? fetch.bind(window) : fetch);
81
- const apiUrlParsed = new URL(baseUrl);
82
- const currentOrigin = typeof window !== "undefined" ? window.location.origin : "";
83
- this.isCrossDomain = currentOrigin !== "" && currentOrigin !== apiUrlParsed.origin;
84
- }
85
- /**
86
- * Set the handler for enhanced authentication requirements (RFC 9470 Step-Up Auth).
87
- * This handler is called when a 401 response includes WWW-Authenticate header
88
- * with error="insufficient_user_authentication".
89
- */
90
- setEnhancedAuthHandler(handler) {
91
- this.enhancedAuthHandler = handler;
92
- }
93
- /**
94
- * Set the handler for organization authentication requirements.
95
- * This handler is called when a 401 response includes WWW-Authenticate header
96
- * with realm="org". The handler should redirect the user to complete org auth.
97
- */
98
- setOrgAuthHandler(handler) {
99
- this.orgAuthHandler = handler;
100
- }
101
- /**
102
- * Update the API key (used after successful re-authentication).
103
- */
104
- updateApiKey(newApiKey) {
105
- this.apiKey = newApiKey;
106
- }
107
- /**
108
- * Set the acting member UUID for member identity switching.
109
- * When set, all API requests will include the X-Acting-Member header.
110
- * The backend will validate that the authenticated account owns this member
111
- * and use it as the effective identity for the request.
112
- */
113
- setActingMember(memberUuid) {
114
- this.actingMemberUuid = memberUuid;
115
- }
116
- /**
117
- * Get the current acting member UUID.
118
- */
119
- getActingMember() {
120
- return this.actingMemberUuid;
121
- }
122
- /**
123
- * Set the org token for cross-domain requests.
124
- * When set, all API requests will include the X-Org-Token header,
125
- * allowing org-level SSO verification without cookies.
126
- *
127
- * `orgUuid` is the org that issued the token; passing it lets the 401
128
- * handler detect a stale token when a subsequent request targets a
129
- * different org and re-fire the org-auth handler instead of silently
130
- * 401-ing. Callers without that context (legacy / unknown) may omit it.
131
- */
132
- setOrgToken(token, orgUuid) {
133
- this.orgToken = token;
134
- this.orgTokenOrgUuid = token ? orgUuid : void 0;
135
- }
136
- async fetch(endpoint, options) {
137
- try {
138
- const headers = new Headers({
139
- // Don't set Content-Type for FormData — the browser must set it
140
- // with the multipart boundary automatically.
141
- ...options?.body instanceof FormData ? {} : { "Content-Type": "application/json" },
142
- ...options?.headers || {}
143
- });
144
- if (this.apiKey) {
145
- headers.set("Authorization", `Bearer ${this.apiKey}`);
146
- } else if (this.isCrossDomain) {
147
- const requestToken = getCookieValue("requestToken");
148
- if (requestToken) {
149
- headers.set("Authorization", `Bearer ${requestToken}`);
150
- }
151
- }
152
- if (this.actingMemberUuid) {
153
- headers.set("X-Acting-Member", this.actingMemberUuid);
154
- }
155
- if (this.orgToken) {
156
- headers.set("X-Org-Token", this.orgToken);
157
- }
158
- const fullUrl = `${this.baseUrl}/api/v2/${endpoint}`;
159
- const response = await this.fetchFunction(fullUrl, {
160
- ...options,
161
- ...this.apiKey ? {} : { credentials: "include" },
162
- ...this.isCrossDomain ? { mode: "cors" } : {},
163
- headers
164
- });
165
- if (!response.ok) {
166
- if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
167
- if (this.enhancedAuthInProgress) {
168
- await this.enhancedAuthInProgress;
169
- } else {
170
- this.enhancedAuthInProgress = this.enhancedAuthHandler();
171
- try {
172
- const newToken = await this.enhancedAuthInProgress;
173
- this.apiKey = newToken;
174
- } finally {
175
- this.enhancedAuthInProgress = null;
176
- }
177
- }
178
- try {
179
- return await this.fetch(endpoint, options);
180
- } catch (retryError) {
181
- this.orgToken = void 0;
182
- this.orgTokenOrgUuid = void 0;
183
- throw retryError;
184
- }
185
- }
186
- if (response.status === 401) {
187
- const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
188
- if (orgAuthInfo && this.orgToken && this.orgTokenOrgUuid && this.orgTokenOrgUuid !== orgAuthInfo.orgUuid) {
189
- this.orgToken = void 0;
190
- this.orgTokenOrgUuid = void 0;
191
- }
192
- if (orgAuthInfo && !this.orgToken) {
193
- const requestCookieName = orgAuthInfo.cookieName.replace(
194
- /^orgToken/,
195
- "requestOrgToken"
196
- );
197
- const cachedOrgToken = getCookieValue(requestCookieName);
198
- if (cachedOrgToken) {
199
- this.orgToken = cachedOrgToken;
200
- this.orgTokenOrgUuid = orgAuthInfo.orgUuid;
201
- try {
202
- return await this.fetch(endpoint, options);
203
- } catch (retryError) {
204
- this.orgToken = void 0;
205
- this.orgTokenOrgUuid = void 0;
206
- throw retryError;
207
- }
208
- }
209
- if (this.orgAuthHandler) {
210
- if (!this.orgAuthInProgress) {
211
- const handler = this.orgAuthHandler;
212
- this.orgAuthInProgress = (async () => {
213
- try {
214
- await handler(orgAuthInfo);
215
- } finally {
216
- this.orgAuthInProgress = null;
217
- }
218
- })();
219
- }
220
- await this.orgAuthInProgress;
221
- const postHandlerToken = getCookieValue(requestCookieName) ?? this.orgToken;
222
- if (!postHandlerToken) {
223
- throw new ApiError(
224
- "Organization authentication did not issue a token",
225
- 401
226
- );
227
- }
228
- this.orgToken = postHandlerToken;
229
- this.orgTokenOrgUuid = orgAuthInfo.orgUuid;
230
- try {
231
- return await this.fetch(endpoint, options);
232
- } catch (retryError) {
233
- this.orgToken = void 0;
234
- this.orgTokenOrgUuid = void 0;
235
- throw retryError;
236
- }
237
- }
238
- }
239
- }
240
- const errorData = await response.json().catch(() => ({}));
241
- if (response.status === 401 && endpoint === "account") {
242
- throw new Error("unauthorized");
243
- }
244
- if (Array.isArray(errorData.detail)) {
245
- const formattedErrors = errorData.detail.map((error) => {
246
- const location = error.loc.join(" > ");
247
- return `${location}: ${error.msg}`;
248
- }).join("\n");
249
- throw new ApiError(`Validation Error:
250
- ${formattedErrors}`, response.status);
251
- }
252
- if (errorData.errors && Array.isArray(errorData.errors)) {
253
- if (errorData.errors.length > 0 && isApiValidationError(errorData.errors[0])) {
254
- const validationErrors = errorData.errors.filter(isApiValidationError);
255
- const [first] = validationErrors;
256
- if (first) {
257
- const extra = validationErrors.length > 1 ? ` (+${validationErrors.length - 1} more)` : "";
258
- const readable = `${first.field}: ${first.message}${extra}`;
259
- throw new ApiError(
260
- readable,
261
- response.status,
262
- validationErrors.map((e) => `${e.field}: ${e.message}`),
263
- validationErrors
264
- );
265
- }
266
- }
267
- const stringErrors = errorData.errors.filter(
268
- (e) => typeof e === "string"
269
- );
270
- const details = stringErrors.join("; ");
271
- const message = errorData.detail ? `${errorData.detail}: ${details}` : `Validation failed: ${details}`;
272
- throw new ApiError(message, response.status, stringErrors);
273
- }
274
- const structuredError = errorData.detail || errorData;
275
- if (structuredError && typeof structuredError === "object" && (structuredError.error === true || structuredError.code)) {
276
- const message = structuredError.message || structuredError.code || "Unknown error";
277
- const error = new ApiError(message, response.status);
278
- error.errorData = structuredError;
279
- throw error;
280
- }
281
- const errorMessage = typeof errorData.detail === "string" ? errorData.detail : errorData.message || response.statusText;
282
- throw new ApiError(errorMessage, response.status);
283
- }
284
- if (response.status === 204) {
285
- return void 0;
286
- }
287
- return response.json();
288
- } catch (error) {
289
- console.warn(error);
290
- throw error;
291
- }
292
- }
293
- async fetchRaw(endpoint, options, allowedErrorStatuses = []) {
294
- try {
295
- const headers = new Headers({
296
- ...options?.headers || {}
297
- });
298
- if (this.apiKey) {
299
- headers.set("Authorization", `Bearer ${this.apiKey}`);
300
- } else if (this.isCrossDomain) {
301
- const requestToken = getCookieValue("requestToken");
302
- if (requestToken) {
303
- headers.set("Authorization", `Bearer ${requestToken}`);
304
- }
305
- }
306
- if (this.actingMemberUuid) {
307
- headers.set("X-Acting-Member", this.actingMemberUuid);
308
- }
309
- if (this.orgToken) {
310
- headers.set("X-Org-Token", this.orgToken);
311
- }
312
- const response = await this.fetchFunction(`${this.baseUrl}/api/v2/${endpoint}`, {
313
- ...options,
314
- ...this.apiKey ? {} : { credentials: "include" },
315
- ...this.isCrossDomain ? { mode: "cors" } : {},
316
- headers
317
- });
318
- if (!response.ok) {
319
- if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
320
- if (this.enhancedAuthInProgress) {
321
- await this.enhancedAuthInProgress;
322
- } else {
323
- this.enhancedAuthInProgress = this.enhancedAuthHandler();
324
- try {
325
- const newToken = await this.enhancedAuthInProgress;
326
- this.apiKey = newToken;
327
- } finally {
328
- this.enhancedAuthInProgress = null;
329
- }
330
- }
331
- try {
332
- return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
333
- } catch (retryError) {
334
- this.orgToken = void 0;
335
- this.orgTokenOrgUuid = void 0;
336
- throw retryError;
337
- }
338
- }
339
- if (response.status === 401) {
340
- const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
341
- if (orgAuthInfo && this.orgToken && this.orgTokenOrgUuid && this.orgTokenOrgUuid !== orgAuthInfo.orgUuid) {
342
- this.orgToken = void 0;
343
- this.orgTokenOrgUuid = void 0;
344
- }
345
- if (orgAuthInfo && !this.orgToken) {
346
- const requestCookieName = orgAuthInfo.cookieName.replace(
347
- /^orgToken/,
348
- "requestOrgToken"
349
- );
350
- const cachedOrgToken = getCookieValue(requestCookieName);
351
- if (cachedOrgToken) {
352
- this.orgToken = cachedOrgToken;
353
- this.orgTokenOrgUuid = orgAuthInfo.orgUuid;
354
- try {
355
- return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
356
- } catch (retryError) {
357
- this.orgToken = void 0;
358
- this.orgTokenOrgUuid = void 0;
359
- throw retryError;
360
- }
361
- }
362
- if (this.orgAuthHandler) {
363
- if (!this.orgAuthInProgress) {
364
- const handler = this.orgAuthHandler;
365
- this.orgAuthInProgress = (async () => {
366
- try {
367
- await handler(orgAuthInfo);
368
- } finally {
369
- this.orgAuthInProgress = null;
370
- }
371
- })();
372
- }
373
- await this.orgAuthInProgress;
374
- const postHandlerToken = getCookieValue(requestCookieName) ?? this.orgToken;
375
- if (!postHandlerToken) {
376
- throw new ApiError(
377
- "Organization authentication did not issue a token",
378
- 401
379
- );
380
- }
381
- this.orgToken = postHandlerToken;
382
- this.orgTokenOrgUuid = orgAuthInfo.orgUuid;
383
- try {
384
- return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
385
- } catch (retryError) {
386
- this.orgToken = void 0;
387
- this.orgTokenOrgUuid = void 0;
388
- throw retryError;
389
- }
390
- }
391
- }
392
- }
393
- if (allowedErrorStatuses.includes(response.status)) {
394
- return response;
395
- }
396
- const errorText = await response.text().catch(() => "");
397
- throw new ApiError(errorText || response.statusText, response.status);
398
- }
399
- return response;
400
- } catch (error) {
401
- console.warn(error);
402
- throw error;
403
- }
404
- }
405
- /**
406
- * Fetch from root path (not prefixed with /api/v2/)
407
- * Used for OAuth and other non-API endpoints
408
- */
409
- async fetchRoot(path, options) {
410
- try {
411
- const headers = new Headers({
412
- ...options?.body instanceof FormData ? {} : { "Content-Type": "application/json" },
413
- ...options?.headers || {}
414
- });
415
- if (this.apiKey) {
416
- headers.set("Authorization", `Bearer ${this.apiKey}`);
417
- } else if (this.isCrossDomain) {
418
- const requestToken = getCookieValue("requestToken");
419
- if (requestToken) {
420
- headers.set("Authorization", `Bearer ${requestToken}`);
421
- }
422
- }
423
- if (this.actingMemberUuid) {
424
- headers.set("X-Acting-Member", this.actingMemberUuid);
425
- }
426
- if (this.orgToken) {
427
- headers.set("X-Org-Token", this.orgToken);
428
- }
429
- const fullUrl = `${this.baseUrl}/${path}`;
430
- const response = await this.fetchFunction(fullUrl, {
431
- ...options,
432
- ...this.apiKey ? {} : { credentials: "include" },
433
- ...this.isCrossDomain ? { mode: "cors" } : {},
434
- headers
435
- });
436
- if (!response.ok) {
437
- if (response.status === 404) {
438
- return null;
439
- }
440
- const errorData = await response.json().catch(() => ({}));
441
- const errorMessage = errorData.detail || errorData.message || response.statusText;
442
- throw new ApiError(errorMessage, response.status);
443
- }
444
- if (response.status === 204) {
445
- return void 0;
446
- }
447
- return response.json();
448
- } catch (error) {
449
- console.warn(error);
450
- throw error;
451
- }
452
- }
453
- };
1
+ import {
2
+ BaseApiClient
3
+ } from "./chunk-FSSXKQR5.js";
454
4
 
455
5
  // src/api/abilities.ts
456
6
  var AbilitiesApi = class extends BaseApiClient {
@@ -1134,15 +684,11 @@ var AuthApi = class extends BaseApiClient {
1134
684
  body: JSON.stringify({ email, organizationUuid, redirectUrl })
1135
685
  });
1136
686
  }
1137
- /** Validate a magic link token and optional OTP to complete authentication. */
1138
- async validateMagicLink(token, otp) {
1139
- const body = { token };
1140
- if (otp) {
1141
- body.otp = otp;
1142
- }
687
+ /** Validate a magic link token to complete authentication. */
688
+ async validateMagicLink(token) {
1143
689
  return await this.fetch(`auth/validate-magic-link`, {
1144
690
  method: "POST",
1145
- body: JSON.stringify(body)
691
+ body: JSON.stringify({ token })
1146
692
  });
1147
693
  }
1148
694
  // ===== EMAIL VERIFICATION METHODS =====
@@ -1648,6 +1194,26 @@ var CallsApi = class extends BaseApiClient {
1648
1194
  async getMessageTiming(wid, chatId) {
1649
1195
  return this.fetch(`w/${wid}/recordings/chat/${chatId}/message-timing`);
1650
1196
  }
1197
+ /** List the recorded audio chunks for a chat (metadata only). */
1198
+ async listChatRecordings(wid, chatId, options = {}) {
1199
+ const params = new URLSearchParams();
1200
+ if (options.role) params.set("role", options.role);
1201
+ return this.fetch(
1202
+ `w/${wid}/recordings/chat/${chatId}${params.toString() ? `?${params.toString()}` : ""}`
1203
+ );
1204
+ }
1205
+ /**
1206
+ * Get a single short-lived presigned URL to download the complete call
1207
+ * recording as one WAV file. The first request assembles + caches the
1208
+ * full-call WAV; later requests reuse it.
1209
+ */
1210
+ async getCallRecordingDownloadUrl(wid, chatId, options = {}) {
1211
+ const params = new URLSearchParams();
1212
+ if (options.expiresIn !== void 0) params.set("expires_in", String(options.expiresIn));
1213
+ return this.fetch(
1214
+ `w/${wid}/recordings/chat/${chatId}/download-url${params.toString() ? `?${params.toString()}` : ""}`
1215
+ );
1216
+ }
1651
1217
  };
1652
1218
 
1653
1219
  // src/api/cel.ts
@@ -1732,6 +1298,17 @@ var ChatsApi = class extends BaseApiClient {
1732
1298
  async getChatTokenUsage(wid, chatId) {
1733
1299
  return this.fetch(`w/${wid}/chats/${chatId}/token-usage`);
1734
1300
  }
1301
+ /** List scheduled callbacks for a chat (newest first). */
1302
+ async getChatCallbacks(wid, chatId) {
1303
+ return this.fetch(`w/${wid}/chats/${chatId}/callbacks`);
1304
+ }
1305
+ /** Cancel a pending scheduled callback on a chat. */
1306
+ async cancelChatCallback(wid, chatId, callbackId) {
1307
+ return this.fetch(
1308
+ `w/${wid}/chats/${chatId}/callbacks/${callbackId}/cancel`,
1309
+ { method: "POST" }
1310
+ );
1311
+ }
1735
1312
  /** Get todo items extracted from a chat. */
1736
1313
  async getChatTodos(wid, chatId) {
1737
1314
  return this.fetch(`w/${wid}/chats/${chatId}/todos`);
@@ -1770,9 +1347,11 @@ var ChatsApi = class extends BaseApiClient {
1770
1347
  }
1771
1348
  /** Create a new chat. */
1772
1349
  async createChat(wid, chat) {
1350
+ const { agentMemberId, ...rest } = chat;
1351
+ const payload = agentMemberId !== void 0 && rest.assistantMemberId === void 0 ? { ...rest, assistantMemberId: agentMemberId } : rest;
1773
1352
  return this.fetch(`w/${wid}/chats`, {
1774
1353
  method: "POST",
1775
- body: JSON.stringify(chat)
1354
+ body: JSON.stringify(payload)
1776
1355
  });
1777
1356
  }
1778
1357
  /**
@@ -1835,7 +1414,8 @@ var ChatsApi = class extends BaseApiClient {
1835
1414
  }
1836
1415
  );
1837
1416
  }
1838
- /** List messages in a chat with optional pagination. */
1417
+ /** List messages in a chat with optional pagination.
1418
+ * ``id`` is the numeric chat id (documented) or the chat uuid (accepted). */
1839
1419
  async getChatMessages(wid, id, limit, offset) {
1840
1420
  const params = new URLSearchParams();
1841
1421
  if (limit) params.append("limit", limit.toString());
@@ -2215,6 +1795,7 @@ var DataTypesApi = class extends BaseApiClient {
2215
1795
  async getDataRecords(wid, dataTypeId, options) {
2216
1796
  const params = new URLSearchParams();
2217
1797
  if (options?.memberId !== void 0) params.append("member_id", options.memberId.toString());
1798
+ if (options?.memberIds?.length) params.append("member_ids", options.memberIds.join(","));
2218
1799
  if (options?.search) params.append("search", options.search);
2219
1800
  if (options?.searchField) params.append("search_field", options.searchField);
2220
1801
  if (options?.page) params.append("page", options.page.toString());
@@ -2557,6 +2138,13 @@ var EventsApi = class extends BaseApiClient {
2557
2138
  method: "DELETE"
2558
2139
  });
2559
2140
  }
2141
+ /** Send a one-off test webhook for an existing webhook event rule. */
2142
+ async testWebhook(wid, id, request) {
2143
+ return this.fetch(`w/${wid}/event-rules/${id}/test-webhook`, {
2144
+ method: "POST",
2145
+ body: JSON.stringify(request)
2146
+ });
2147
+ }
2560
2148
  /** Reorder event rules by specifying the desired rule ID sequence. */
2561
2149
  async reorderEventRules(wid, ruleIds) {
2562
2150
  return this.fetch(`w/${wid}/event-rules/reorder`, {
@@ -3061,6 +2649,18 @@ var FilesApi = class extends BaseApiClient {
3061
2649
  async getFile(wid, id) {
3062
2650
  return this.fetch(`w/${wid}/files/${id}`);
3063
2651
  }
2652
+ /**
2653
+ * Download the given files + folders (folders recursively) as a single ZIP.
2654
+ * Returns the raw archive bytes for the caller to save.
2655
+ */
2656
+ async downloadFilesZip(wid, fileIds, folderIds) {
2657
+ const response = await this.fetchRaw(`w/${wid}/files/download/zip`, {
2658
+ method: "POST",
2659
+ headers: { "Content-Type": "application/json" },
2660
+ body: JSON.stringify({ file_ids: fileIds, folder_ids: folderIds })
2661
+ });
2662
+ return response.blob();
2663
+ }
3064
2664
  /** Create a new file record in the workspace. */
3065
2665
  async createFile(wid, file) {
3066
2666
  return this.fetch(`w/${wid}/files`, {
@@ -3677,6 +3277,31 @@ var McpServersApi = class extends BaseApiClient {
3677
3277
  };
3678
3278
 
3679
3279
  // src/api/members.ts
3280
+ var MemberImportValidationError = class extends Error {
3281
+ validationErrors;
3282
+ constructor(message, validationErrors) {
3283
+ super(message);
3284
+ this.name = "MemberImportValidationError";
3285
+ this.validationErrors = validationErrors;
3286
+ }
3287
+ };
3288
+ function throwMemberImportError(errorBody, fallback) {
3289
+ let detail = errorBody?.detail;
3290
+ if (typeof detail === "string") {
3291
+ try {
3292
+ const parsed = JSON.parse(detail);
3293
+ if (parsed && typeof parsed === "object") detail = parsed;
3294
+ } catch {
3295
+ }
3296
+ }
3297
+ if (detail && typeof detail === "object") {
3298
+ const { message, errors } = detail;
3299
+ if (Array.isArray(errors)) {
3300
+ throw new MemberImportValidationError(message || fallback, errors);
3301
+ }
3302
+ }
3303
+ throw new Error(typeof detail === "string" ? detail : fallback);
3304
+ }
3680
3305
  var MembersApi = class extends BaseApiClient {
3681
3306
  /** Get the currently authenticated member for a workspace. */
3682
3307
  async getCurrentMember(wid) {
@@ -3717,8 +3342,10 @@ var MembersApi = class extends BaseApiClient {
3717
3342
  });
3718
3343
  }
3719
3344
  /** List workspace members with pagination, filtering, and sorting. */
3720
- async getWorkspaceMembers(wid, page = 1, pageSize = 10, filters, search, role, sortBy, sortOrder, memberType, isArchived = false, isManager, memberTypes, hasAccount, excludeIds) {
3345
+ async getWorkspaceMembers(wid, page = 1, pageSize = 10, filters, search, role, sortBy, sortOrder, memberType, isArchived = false, isManager, memberTypes, hasAccount, excludeIds, memberFilterId, query) {
3721
3346
  const params = new URLSearchParams();
3347
+ if (memberFilterId != null) params.append("memberFilterId", memberFilterId.toString());
3348
+ if (query != null) params.append("query", JSON.stringify(query));
3722
3349
  if (page) params.append("page", page.toString());
3723
3350
  if (pageSize) params.append("pageSize", pageSize.toString());
3724
3351
  if (sortBy) params.append("sortBy", sortBy);
@@ -3791,6 +3418,17 @@ var MembersApi = class extends BaseApiClient {
3791
3418
  method: "POST"
3792
3419
  });
3793
3420
  }
3421
+ /**
3422
+ * Send the member an SMS asking them to confirm their phone number. When they
3423
+ * reply, a trusted phone auth binding is created so they can use SMS as
3424
+ * themselves without an account (member-attested alternative to the
3425
+ * members:admin "Trusted" override).
3426
+ */
3427
+ async sendMemberPhoneConfirmation(wid, memberId) {
3428
+ return this.fetch(`w/${wid}/members/${memberId}/phone-confirmation`, {
3429
+ method: "POST"
3430
+ });
3431
+ }
3794
3432
  // Member Filter APIs
3795
3433
  /** List all saved member filters for a workspace. */
3796
3434
  async getMemberFilters(wid) {
@@ -3814,6 +3452,22 @@ var MembersApi = class extends BaseApiClient {
3814
3452
  body: JSON.stringify(data)
3815
3453
  });
3816
3454
  }
3455
+ /**
3456
+ * Convert a legacy rules filter to a query-engine predicate. One-way and
3457
+ * transactional: on success the filter's legacy rules are gone and
3458
+ * `query` holds the equivalent IR predicate. 409 if already query-format;
3459
+ * 422 when rules have no engine equivalent.
3460
+ *
3461
+ * With `dryRun: true` the same validation runs but nothing persists: the
3462
+ * response previews the normalized predicate in `query` while `rules`
3463
+ * stay intact on the filter.
3464
+ */
3465
+ async convertMemberFilterToQuery(wid, filterId, opts) {
3466
+ const suffix = opts?.dryRun ? "?dryRun=true" : "";
3467
+ return this.fetch(`w/${wid}/member-filters/${filterId}/convert${suffix}`, {
3468
+ method: "PUT"
3469
+ });
3470
+ }
3817
3471
  /** Delete a saved member filter. */
3818
3472
  async deleteMemberFilter(wid, filterId) {
3819
3473
  return this.fetch(`w/${wid}/member-filters/${filterId}`, {
@@ -3891,48 +3545,98 @@ var MembersApi = class extends BaseApiClient {
3891
3545
  });
3892
3546
  }
3893
3547
  // Import/Export Members API
3894
- /** Import members from a CSV file, streaming progress updates via callback. */
3895
- async importMembers(wid, file, newMemberRoleId, onProgress) {
3548
+ /**
3549
+ * Read-only preview classifying each CSV row before any write (GRA-5545).
3550
+ *
3551
+ * Returns create/update/unchanged/conflict/error counts. For phone-only
3552
+ * identity conflicts it also returns existing vs incoming identity so the
3553
+ * operator can decide whether to skip or explicitly overwrite before
3554
+ * committing. Requires MEMBERS_ADMIN and is bulk-PHI audited server-side.
3555
+ */
3556
+ async previewImportMembers(wid, file, newMemberRoleId, options) {
3896
3557
  const formData = new FormData();
3897
3558
  formData.append("file", file);
3898
3559
  const params = new URLSearchParams();
3899
3560
  params.append("new_member_role_id", newMemberRoleId.toString());
3900
- const response = await fetch(
3901
- `${this.baseUrl}/api/v2/w/${wid}/members/import?${params.toString()}`,
3561
+ if (options?.trustEmailAddresses) {
3562
+ params.append("trust_email_addresses", "true");
3563
+ }
3564
+ if (options?.trustPhoneNumbers) {
3565
+ params.append("trust_phone_numbers", "true");
3566
+ }
3567
+ const response = await this.fetchRaw(
3568
+ `w/${wid}/members/import/preview?${params.toString()}`,
3902
3569
  {
3903
3570
  method: "POST",
3904
- body: formData,
3905
- credentials: "include"
3906
- }
3571
+ body: formData
3572
+ },
3573
+ [400, 413]
3907
3574
  );
3908
3575
  if (!response.ok) {
3909
- const error = await response.json();
3910
- if (error.detail && typeof error.detail === "object") {
3911
- const { message, errors } = error.detail;
3912
- if (errors && Array.isArray(errors)) {
3913
- const importError = new Error(message || "Import validation failed");
3914
- importError.validationErrors = errors;
3915
- throw importError;
3916
- }
3917
- }
3918
- throw new Error(error.detail || "Import failed");
3576
+ const error = await response.json().catch(() => ({}));
3577
+ throwMemberImportError(error, "Import preview failed");
3578
+ }
3579
+ return response.json();
3580
+ }
3581
+ /**
3582
+ * Import members from a CSV file, streaming progress updates via callback.
3583
+ *
3584
+ * ``identityConflictPolicy`` (default 'skip') controls how a row matching an
3585
+ * existing member ONLY by phone with different identity fields is handled.
3586
+ * Send 'overwrite_identity_fields' only after the operator confirms a preview.
3587
+ */
3588
+ async importMembers(wid, file, newMemberRoleId, onProgress, options) {
3589
+ const formData = new FormData();
3590
+ formData.append("file", file);
3591
+ const params = new URLSearchParams();
3592
+ params.append("new_member_role_id", newMemberRoleId.toString());
3593
+ if (options?.trustEmailAddresses) {
3594
+ params.append("trust_email_addresses", "true");
3595
+ }
3596
+ if (options?.trustPhoneNumbers) {
3597
+ params.append("trust_phone_numbers", "true");
3598
+ }
3599
+ if (options?.identityConflictPolicy) {
3600
+ params.append("identity_conflict_policy", options.identityConflictPolicy);
3601
+ }
3602
+ const response = await this.fetchRaw(
3603
+ `w/${wid}/members/import?${params.toString()}`,
3604
+ {
3605
+ method: "POST",
3606
+ body: formData
3607
+ },
3608
+ [400, 413]
3609
+ );
3610
+ if (!response.ok) {
3611
+ const error = await response.json().catch(() => ({}));
3612
+ throwMemberImportError(error, "Import failed");
3919
3613
  }
3920
3614
  if (onProgress && response.body) {
3921
3615
  const reader = response.body.getReader();
3922
3616
  const decoder = new TextDecoder();
3617
+ let buffer = "";
3923
3618
  while (true) {
3924
3619
  const { done, value } = await reader.read();
3925
3620
  if (done) break;
3926
- const chunk = decoder.decode(value);
3927
- const lines = chunk.split("\n").filter((line) => line.trim());
3621
+ buffer += decoder.decode(value, { stream: true });
3622
+ const lines = buffer.split("\n");
3623
+ buffer = lines.pop() ?? "";
3928
3624
  for (const line of lines) {
3625
+ const trimmed = line.trim();
3626
+ if (!trimmed) continue;
3929
3627
  try {
3930
- const progress = JSON.parse(line);
3931
- onProgress(progress);
3628
+ onProgress(JSON.parse(trimmed));
3932
3629
  } catch {
3933
3630
  }
3934
3631
  }
3935
3632
  }
3633
+ const tail = buffer.trim();
3634
+ if (tail) {
3635
+ try {
3636
+ onProgress(JSON.parse(tail));
3637
+ } catch {
3638
+ }
3639
+ }
3936
3640
  }
3937
3641
  return { success: true };
3938
3642
  }
@@ -4124,6 +3828,17 @@ var MembersApi = class extends BaseApiClient {
4124
3828
  { method: "DELETE" }
4125
3829
  );
4126
3830
  }
3831
+ /** Bulk-create members in a workspace. */
3832
+ async bulkCreateMembers(wid, request) {
3833
+ return this.fetch(`w/${wid}/members/bulk`, {
3834
+ method: "POST",
3835
+ body: JSON.stringify(request)
3836
+ });
3837
+ }
3838
+ /** Get all sync links for a member across app connections. */
3839
+ async getMemberSyncLinks(wid, memberId) {
3840
+ return this.fetch(`w/${wid}/members/${memberId}/sync-links`);
3841
+ }
4127
3842
  };
4128
3843
 
4129
3844
  // src/api/milestones.ts
@@ -4620,6 +4335,7 @@ var OrgApi = class extends BaseApiClient {
4620
4335
  */
4621
4336
  async searchPhoneNumbers(orgUuid, params) {
4622
4337
  const query = new URLSearchParams();
4338
+ if (params?.country) query.set("country", params.country);
4623
4339
  if (params?.numberType) query.set("number_type", params.numberType);
4624
4340
  if (params?.areaCode) query.set("area_code", params.areaCode);
4625
4341
  if (params?.contains) query.set("contains", params.contains);
@@ -4631,11 +4347,20 @@ var OrgApi = class extends BaseApiClient {
4631
4347
  }
4632
4348
  /**
4633
4349
  * Purchase a phone number from Twilio for this org inventory (org admin only).
4350
+ *
4351
+ * Numbers in regulated countries (e.g. Australia) require a Twilio regulatory
4352
+ * bundle and an address — pass `bundleSid` and `addressSid` for those.
4634
4353
  */
4635
- async purchasePhoneNumber(orgUuid, phoneNumber, numberType) {
4354
+ async purchasePhoneNumber(orgUuid, phoneNumber, numberType, opts) {
4636
4355
  return this.fetch(`o/${orgUuid}/phone-numbers/purchase`, {
4637
4356
  method: "POST",
4638
- body: JSON.stringify({ phoneNumber, numberType })
4357
+ body: JSON.stringify({
4358
+ phoneNumber,
4359
+ numberType,
4360
+ country: opts?.country,
4361
+ bundleSid: opts?.bundleSid,
4362
+ addressSid: opts?.addressSid
4363
+ })
4639
4364
  });
4640
4365
  }
4641
4366
  /**
@@ -4843,6 +4568,90 @@ var OrgApi = class extends BaseApiClient {
4843
4568
  method: "POST"
4844
4569
  });
4845
4570
  }
4571
+ /**
4572
+ * List the org's A2P brands (broker resources). The SMS-consent editor uses
4573
+ * this to pick which brand's consent config to edit.
4574
+ */
4575
+ async listA2PBrands(orgUuid) {
4576
+ return this.fetch(`o/${orgUuid}/a2p-brands`);
4577
+ }
4578
+ /**
4579
+ * Fetch a brand's resolved A2P campaign config. The response carries both the
4580
+ * raw `overrides` and the `resolved` payload (defaults + overrides) the editor
4581
+ * previews — including the canonical SMS consent text.
4582
+ */
4583
+ async getA2PCampaignConfig(orgUuid, brandUuid) {
4584
+ return this.fetch(
4585
+ `o/${orgUuid}/a2p-brands/${brandUuid}/campaign-config`
4586
+ );
4587
+ }
4588
+ /**
4589
+ * Partial-update a brand's A2P campaign config. Returns the freshly resolved
4590
+ * config so the editor's live preview updates without a second round-trip.
4591
+ */
4592
+ async updateA2PCampaignConfig(orgUuid, brandUuid, data) {
4593
+ return this.fetch(
4594
+ `o/${orgUuid}/a2p-brands/${brandUuid}/campaign-config`,
4595
+ {
4596
+ method: "PUT",
4597
+ body: JSON.stringify(data)
4598
+ }
4599
+ );
4600
+ }
4601
+ /**
4602
+ * Published Sites across the org's workspaces that can be linked as this
4603
+ * brand's enrollment (opt-in) surface. Org-authorized, so it works even when
4604
+ * the admin isn't a member of the workspace holding the Site.
4605
+ */
4606
+ async listA2PEnrollmentSiteCandidates(orgUuid, brandUuid) {
4607
+ return this.fetch(
4608
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site/candidates`
4609
+ );
4610
+ }
4611
+ /**
4612
+ * Link the brand to a published enrollment Site (sets `site_uuid`). Returns
4613
+ * the refreshed campaign config so the editor's link state updates inline.
4614
+ */
4615
+ async linkA2PEnrollmentSite(orgUuid, brandUuid, data) {
4616
+ return this.fetch(
4617
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site`,
4618
+ {
4619
+ method: "PUT",
4620
+ body: JSON.stringify(data)
4621
+ }
4622
+ );
4623
+ }
4624
+ /**
4625
+ * Provision (or reuse) a patient-enrollment Site for the brand and link it —
4626
+ * the one-click path behind the SMS Consent tab. `workspaceUuid` is required
4627
+ * only when the org has multiple workspaces. Returns the refreshed campaign
4628
+ * config so the editor's link state updates inline. Idempotent.
4629
+ */
4630
+ async provisionA2PEnrollmentSite(orgUuid, brandUuid, data = {}) {
4631
+ return this.fetch(
4632
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site/provision`,
4633
+ {
4634
+ method: "POST",
4635
+ body: JSON.stringify(data)
4636
+ }
4637
+ );
4638
+ }
4639
+ /** Clear the brand's enrollment-site link. */
4640
+ async unlinkA2PEnrollmentSite(orgUuid, brandUuid) {
4641
+ return this.fetch(
4642
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site`,
4643
+ { method: "DELETE" }
4644
+ );
4645
+ }
4646
+ /**
4647
+ * The brand-addressable enrollment form URL (carries `?brand=…`). Outreach
4648
+ * appends each patient's `external_id`. `url` is null until a Site is linked.
4649
+ */
4650
+ async getA2PBrandEnrollmentUrl(orgUuid, brandUuid) {
4651
+ return this.fetch(
4652
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-url`
4653
+ );
4654
+ }
4846
4655
  /**
4847
4656
  * List available member roles for a workspace in the organization.
4848
4657
  */
@@ -4867,58 +4676,53 @@ var OrgApi = class extends BaseApiClient {
4867
4676
  function getOAuthPath(providerSlug, action) {
4868
4677
  if (providerSlug === "google_calendar") {
4869
4678
  return `oauth/google/calendar/${action}`;
4870
- } else if (providerSlug === "gmail") {
4679
+ }
4680
+ if (providerSlug === "gmail") {
4871
4681
  return `oauth/google/gmail/${action}`;
4872
- } else {
4873
- return `oauth/${providerSlug}/${action}`;
4874
4682
  }
4683
+ if (providerSlug === "gdrive") {
4684
+ return `oauth/google/drive/${action}`;
4685
+ }
4686
+ return `oauth/${providerSlug}/${action}`;
4687
+ }
4688
+ function buildAuthorizeQuery(options) {
4689
+ if (!options) return "";
4690
+ const params = new URLSearchParams();
4691
+ if (options.credentialUuid) params.set("credentialUuid", options.credentialUuid);
4692
+ if (options.loginHint) params.set("loginHint", options.loginHint);
4693
+ if (options.redirect) params.set("redirect", options.redirect);
4694
+ const qs = params.toString();
4695
+ return qs ? `?${qs}` : "";
4875
4696
  }
4876
4697
  var OAuthConnectionsApi = class extends BaseApiClient {
4877
- /**
4878
- * Get the connection status for an OAuth provider
4879
- */
4880
4698
  async getConnectionStatus(providerSlug) {
4881
4699
  const path = getOAuthPath(providerSlug, "status");
4882
4700
  return this.fetchRoot(path);
4883
4701
  }
4884
- /**
4885
- * Get the authorization URL to start OAuth flow
4886
- */
4887
- async getAuthorizationUrl(providerSlug) {
4888
- const path = getOAuthPath(providerSlug, "authorize");
4702
+ async listAccounts(providerSlug) {
4703
+ const path = getOAuthPath(providerSlug, "accounts");
4889
4704
  return this.fetchRoot(path);
4890
4705
  }
4891
- /**
4892
- * Disconnect an OAuth provider
4893
- */
4894
- async disconnect(providerSlug) {
4706
+ async getAuthorizationUrl(providerSlug, options) {
4707
+ const path = getOAuthPath(providerSlug, "authorize") + buildAuthorizeQuery(options);
4708
+ return this.fetchRoot(path);
4709
+ }
4710
+ async disconnect(providerSlug, credentialUuid) {
4895
4711
  const path = getOAuthPath(providerSlug, "disconnect");
4896
- return this.fetchRoot(path, { method: "DELETE" });
4712
+ const qs = credentialUuid ? `?credentialUuid=${encodeURIComponent(credentialUuid)}` : "";
4713
+ return this.fetchRoot(`${path}${qs}`, { method: "DELETE" });
4897
4714
  }
4898
4715
  };
4899
4716
  var OAuthApi = class extends BaseApiClient {
4900
- /**
4901
- * Get all available OAuth/API key scopes with metadata.
4902
- *
4903
- * This returns the full scope definitions from the backend,
4904
- * ensuring the UI always shows the correct scopes.
4905
- */
4906
4717
  async getAvailableScopes() {
4907
4718
  return this.fetch("oauth/scopes");
4908
4719
  }
4909
- /**
4910
- * Create an authorization code for OAuth flow
4911
- * This is called after the user approves the authorization request
4912
- */
4913
4720
  async authorize(request) {
4914
4721
  return this.fetch("oauth/authorize", {
4915
4722
  method: "POST",
4916
4723
  body: JSON.stringify(request)
4917
4724
  });
4918
4725
  }
4919
- /**
4920
- * Exchange authorization code for access token
4921
- */
4922
4726
  async exchangeOAuthToken(request) {
4923
4727
  const formData = new URLSearchParams();
4924
4728
  formData.append("grant_type", request.grant_type);
@@ -5212,6 +5016,37 @@ var PersonasApi = class extends BaseApiClient {
5212
5016
  }
5213
5017
  };
5214
5018
 
5019
+ // src/api/queries.ts
5020
+ var QueriesApi = class extends BaseApiClient {
5021
+ /** Queryable namespace: native fields, operators per type, DataType record fields. */
5022
+ async getQueryFields(wid) {
5023
+ return this.fetch(`w/${wid}/queries/fields`, {
5024
+ method: "GET"
5025
+ });
5026
+ }
5027
+ /** Structure / field / access / cost validation without execution. */
5028
+ async validateQuery(wid, query) {
5029
+ return this.fetch(`w/${wid}/queries/validate`, {
5030
+ method: "POST",
5031
+ body: JSON.stringify({ query })
5032
+ });
5033
+ }
5034
+ /** Bounded sample run (limit capped server-side). */
5035
+ async previewQuery(wid, query, mode) {
5036
+ return this.fetch(`w/${wid}/queries/preview`, {
5037
+ method: "POST",
5038
+ body: JSON.stringify({ query, mode })
5039
+ });
5040
+ }
5041
+ /** Execute a query (rows / count / aggregate). */
5042
+ async runQuery(wid, query, mode) {
5043
+ return this.fetch(`w/${wid}/queries/run`, {
5044
+ method: "POST",
5045
+ body: JSON.stringify({ query, mode })
5046
+ });
5047
+ }
5048
+ };
5049
+
5215
5050
  // src/api/qualifications.ts
5216
5051
  var QualificationsApi = class extends BaseApiClient {
5217
5052
  /** List qualifications in a workspace, paginated. */
@@ -5263,6 +5098,9 @@ var QualificationsApi = class extends BaseApiClient {
5263
5098
  async listTestChatRuns(wid, workflowId, params) {
5264
5099
  const query = new URLSearchParams();
5265
5100
  if (params?.scenarioId !== void 0) query.set("scenarioId", String(params.scenarioId));
5101
+ if (params?.assistantChatModelId !== void 0) {
5102
+ query.set("assistantChatModelId", params.assistantChatModelId);
5103
+ }
5266
5104
  if (params?.limit !== void 0) query.set("limit", String(params.limit));
5267
5105
  const qs = query.toString() ? `?${query.toString()}` : "";
5268
5106
  return this.fetch(
@@ -5697,6 +5535,112 @@ var SitesApi = class extends BaseApiClient {
5697
5535
  async getSite(wid, id) {
5698
5536
  return this.fetch(`w/${wid}/sites/${id}`);
5699
5537
  }
5538
+ /** Get a site's sharing settings. */
5539
+ async getSiteSharing(wid, siteId) {
5540
+ return this.fetch(`w/${wid}/sites/${siteId}/sharing`);
5541
+ }
5542
+ /** Update a site's sharing settings. */
5543
+ async updateSiteSharing(wid, siteId, data) {
5544
+ return this.fetch(`w/${wid}/sites/${siteId}/sharing`, {
5545
+ method: "PUT",
5546
+ body: JSON.stringify(data)
5547
+ });
5548
+ }
5549
+ /** Get a site's source tree. */
5550
+ async getSiteSource(wid, siteId) {
5551
+ return this.fetch(`w/${wid}/sites/${siteId}/source`);
5552
+ }
5553
+ /** Starter templates the caller may seed (superuser-only ones filtered server-side). */
5554
+ async getSiteSourceTemplates(wid, siteId) {
5555
+ return this.fetch(`w/${wid}/sites/${siteId}/source/templates`);
5556
+ }
5557
+ /** Create a site's source tree with starter files if it does not exist. */
5558
+ async createSiteSource(wid, siteId) {
5559
+ return this.fetch(`w/${wid}/sites/${siteId}/source`, {
5560
+ method: "POST"
5561
+ });
5562
+ }
5563
+ /** Build a site's source without publishing. */
5564
+ async buildSiteSource(wid, siteId) {
5565
+ return this.fetch(`w/${wid}/sites/${siteId}/source/build`, {
5566
+ method: "POST"
5567
+ });
5568
+ }
5569
+ /**
5570
+ * Build and publish a site's source. Optionally label the published version
5571
+ * with a `name` and `note`; both default to null (the UI then shows
5572
+ * "Version {version}").
5573
+ */
5574
+ async publishSiteSource(wid, siteId, options) {
5575
+ return this.fetch(`w/${wid}/sites/${siteId}/source/publish`, {
5576
+ method: "POST",
5577
+ body: JSON.stringify({
5578
+ name: options?.name ?? null,
5579
+ note: options?.note ?? null
5580
+ })
5581
+ });
5582
+ }
5583
+ /**
5584
+ * Reset a site's source files: load a starter template and/or wipe existing
5585
+ * files. `template` selects which starter to seed when `loadDefaults` is set
5586
+ * (defaults to "hello-world"; "patient-enrollment" is the other built-in).
5587
+ */
5588
+ async resetSiteSource(wid, siteId, options) {
5589
+ return this.fetch(`w/${wid}/sites/${siteId}/source/reset`, {
5590
+ method: "POST",
5591
+ body: JSON.stringify({
5592
+ load_defaults: options.loadDefaults,
5593
+ delete_existing: options.deleteExisting,
5594
+ ...options.template ? { template: options.template } : {}
5595
+ })
5596
+ });
5597
+ }
5598
+ /**
5599
+ * Re-point the published release to a prior version from the history. A pure
5600
+ * pointer move (no rebuild); the other versions stay in the history.
5601
+ */
5602
+ async rollbackSiteSource(wid, siteId, releaseUuid) {
5603
+ return this.fetch(`w/${wid}/sites/${siteId}/source/rollback`, {
5604
+ method: "POST",
5605
+ body: JSON.stringify({ release_uuid: releaseUuid })
5606
+ });
5607
+ }
5608
+ /**
5609
+ * Export the site's source tree as a ZIP archive (editor-gated server-side).
5610
+ * Returns the raw archive bytes for the caller to save.
5611
+ */
5612
+ async downloadSiteSourceZip(wid, siteId) {
5613
+ const response = await this.fetchRaw(`w/${wid}/sites/${siteId}/source/download`);
5614
+ return response.blob();
5615
+ }
5616
+ /**
5617
+ * Replace the site's source tree with the contents of an uploaded ZIP
5618
+ * (clears the existing source first, like a reset that loads a template).
5619
+ */
5620
+ async importSiteSourceZip(wid, siteId, file) {
5621
+ const form = new FormData();
5622
+ form.append("file", file, "source.zip");
5623
+ return this.fetch(`w/${wid}/sites/${siteId}/source/import`, {
5624
+ method: "POST",
5625
+ body: form
5626
+ });
5627
+ }
5628
+ /**
5629
+ * Get a theme's settings schema, the site's saved values, and capabilities.
5630
+ * Pass `theme` to resolve the schema for a theme other than the saved one
5631
+ * (e.g. one the builder has selected but not yet saved).
5632
+ */
5633
+ async getThemeSettings(wid, siteId, theme) {
5634
+ const query = theme ? `?theme=${encodeURIComponent(theme)}` : "";
5635
+ return this.fetch(`w/${wid}/sites/${siteId}/theme-settings${query}`);
5636
+ }
5637
+ /** Save values for the active theme's settings (validated against the schema). */
5638
+ async updateThemeSettings(wid, siteId, values) {
5639
+ return this.fetch(`w/${wid}/sites/${siteId}/theme-settings`, {
5640
+ method: "PUT",
5641
+ body: JSON.stringify({ values })
5642
+ });
5643
+ }
5700
5644
  /** Get a single site by UUID. */
5701
5645
  async getSiteByUuid(wid, uuid) {
5702
5646
  return this.fetch(`s/${wid}/${uuid}`);
@@ -6079,6 +6023,16 @@ var SupportRequestsApi = class extends BaseApiClient {
6079
6023
  body: JSON.stringify(data)
6080
6024
  });
6081
6025
  }
6026
+ /**
6027
+ * Reopen a resolved support request (e.g. staff resolved it prematurely).
6028
+ * The server rejects requests that are not in the `resolved` state.
6029
+ */
6030
+ async reopenWorkspaceSupportRequest(workspaceUuid, uuid, data = {}) {
6031
+ return this.fetch(`w/${workspaceUuid}/support-requests/${uuid}/reopen`, {
6032
+ method: "POST",
6033
+ body: JSON.stringify(data)
6034
+ });
6035
+ }
6082
6036
  /**
6083
6037
  * Record a click on a pushed resource (Proactive Support). For a
6084
6038
  * manager_prompt, pass the Manager Chat UUID it opened so the
@@ -7013,6 +6967,20 @@ var BulkMemberResultStatus = {
7013
6967
  updated: "updated",
7014
6968
  failed: "failed"
7015
6969
  };
6970
+ var MemberImportMatchInfoMatchType = {
6971
+ external_id: "external_id",
6972
+ email: "email",
6973
+ phone: "phone",
6974
+ account_email: "account_email",
6975
+ account_phone: "account_phone"
6976
+ };
6977
+ var MemberImportPreviewRowAction = {
6978
+ create: "create",
6979
+ update: "update",
6980
+ unchanged: "unchanged",
6981
+ conflict: "conflict",
6982
+ error: "error"
6983
+ };
7016
6984
 
7017
6985
  // src/types/member-types.ts
7018
6986
  var MemberType = /* @__PURE__ */ ((MemberType2) => {
@@ -7056,6 +7024,9 @@ var EventRuleObjectType = /* @__PURE__ */ ((EventRuleObjectType2) => {
7056
7024
  })(EventRuleObjectType || {});
7057
7025
  var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
7058
7026
  EventRuleEventType2["TASK_EXECUTE"] = "task:execute";
7027
+ EventRuleEventType2["TASK_ENTER"] = "task:enter";
7028
+ EventRuleEventType2["TASK_COMMAND"] = "task:command";
7029
+ EventRuleEventType2["TASK_EXIT"] = "task:exit";
7059
7030
  EventRuleEventType2["MEMBER_JOINED"] = "workspace:member_joined";
7060
7031
  EventRuleEventType2["MEMBER_LEFT"] = "workspace:member_left";
7061
7032
  EventRuleEventType2["DATA_RECORD_CREATED"] = "data_record:created";
@@ -7089,6 +7060,7 @@ var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
7089
7060
  EventRuleActionType2["SWITCH_TASK_ACTION"] = "task:switch";
7090
7061
  EventRuleActionType2["ASSISTANT_MESSAGE"] = "assistant:message";
7091
7062
  EventRuleActionType2["FORM_FIELD_UPDATE"] = "form:update_field";
7063
+ EventRuleActionType2["CEL_MUTATE"] = "record:cel_mutate";
7092
7064
  EventRuleActionType2["MESSAGE_VALIDATION"] = "message:validation";
7093
7065
  EventRuleActionType2["CHAT_CREATE"] = "chat:create";
7094
7066
  EventRuleActionType2["CHAT_CONTINUE"] = "chat:continue";
@@ -7239,7 +7211,6 @@ var ModelProvider = {
7239
7211
  aws: "aws",
7240
7212
  elevenlabs: "elevenlabs",
7241
7213
  deepgram: "deepgram",
7242
- pocket: "pocket",
7243
7214
  xai: "xai",
7244
7215
  custom: "custom"
7245
7216
  };
@@ -7269,7 +7240,10 @@ var TTS_MODEL_ELEVENLABS_MULTILINGUAL = "elevenlabs:tts:eleven_multilingual_v2";
7269
7240
  var TTS_MODEL_DEEPGRAM_AURA_2 = "deepgram:tts:aura-2";
7270
7241
  var TTS_MODEL_AWS_POLLY_GENERATIVE = "aws:tts:polly-generative";
7271
7242
  var TTS_MODEL_AWS_POLLY_NEURAL = "aws:tts:polly-neural";
7272
- var TTS_MODEL_POCKET = "pocket:tts:default";
7243
+
7244
+ // src/types/pids-types.ts
7245
+ var PIDS_DISPOSITIONS = ["true_positive", "false_positive", "needs_more_context"];
7246
+ var PIDS_SOURCES = ["scheduled", "backfill", "pre_llm"];
7273
7247
 
7274
7248
  // src/types/fhir-connection-types.ts
7275
7249
  var FhirVendor = /* @__PURE__ */ ((FhirVendor2) => {
@@ -7967,6 +7941,25 @@ var ExperimentsApi = class extends BaseApiClient {
7967
7941
  }
7968
7942
  };
7969
7943
 
7944
+ // src/api/patientsync-connections.ts
7945
+ var PatientSyncConnectionsApi = class extends BaseApiClient {
7946
+ /** Create or update the workspace's PatientSync connection (singleton). */
7947
+ async configurePatientSync(wid, data) {
7948
+ return this.fetch(
7949
+ `w/${wid}/app-connections/patientsync/configure`,
7950
+ { method: "POST", body: JSON.stringify(data) }
7951
+ );
7952
+ }
7953
+ /** Read the PatientSync connection status (never returns the API key). */
7954
+ async getPatientSyncStatus(wid) {
7955
+ return this.fetch(`w/${wid}/app-connections/patientsync/status`);
7956
+ }
7957
+ /** Delete the workspace's PatientSync connection. */
7958
+ async deletePatientSyncConnection(wid) {
7959
+ return this.fetch(`w/${wid}/app-connections/patientsync/`, { method: "DELETE" });
7960
+ }
7961
+ };
7962
+
7970
7963
  // src/app-context.ts
7971
7964
  function formatAppContextAsMarkdown(context) {
7972
7965
  if (!context) {
@@ -8057,6 +8050,7 @@ function createApiModules(apiKey, baseUrl, customFetch) {
8057
8050
  events: new EventsApi(apiKey, baseUrl, customFetch),
8058
8051
  experiments: new ExperimentsApi(apiKey, baseUrl, customFetch),
8059
8052
  fhirConnections: new FhirConnectionsApi(apiKey, baseUrl, customFetch),
8053
+ patientSyncConnections: new PatientSyncConnectionsApi(apiKey, baseUrl, customFetch),
8060
8054
  healthie: new HealthieApi(apiKey, baseUrl, customFetch),
8061
8055
  hubspot: new HubspotApi(apiKey, baseUrl, customFetch),
8062
8056
  features: new FeaturesApi(apiKey, baseUrl, customFetch),
@@ -8080,6 +8074,7 @@ function createApiModules(apiKey, baseUrl, customFetch) {
8080
8074
  pronunciations: new PronunciationsApi(apiKey, baseUrl, customFetch),
8081
8075
  qualifications: new QualificationsApi(apiKey, baseUrl, customFetch),
8082
8076
  personas: new PersonasApi(apiKey, baseUrl, customFetch),
8077
+ queries: new QueriesApi(apiKey, baseUrl, customFetch),
8083
8078
  reports: new ReportsApi(apiKey, baseUrl, customFetch),
8084
8079
  salesforce: new SalesforceApi(apiKey, baseUrl, customFetch),
8085
8080
  sites: new SitesApi(apiKey, baseUrl, customFetch),
@@ -8124,6 +8119,7 @@ var WORKSPACE_METHOD_NAMES = [
8124
8119
  "cancelAgentTask",
8125
8120
  "cancelAssignment",
8126
8121
  "cancelCalendarEvent",
8122
+ "cancelChatCallback",
8127
8123
  "cancelCredentialUpdateInvite",
8128
8124
  "checkAvailability",
8129
8125
  "checkSiteDomainAvailability",
@@ -8138,6 +8134,7 @@ var WORKSPACE_METHOD_NAMES = [
8138
8134
  "commentOnWorkspaceSupportRequest",
8139
8135
  "configureConfluence",
8140
8136
  "configureHealthie",
8137
+ "configurePatientSync",
8141
8138
  "configureHubspot",
8142
8139
  "configureMondayConnection",
8143
8140
  "configureSalesforce",
@@ -8168,6 +8165,7 @@ var WORKSPACE_METHOD_NAMES = [
8168
8165
  "createExperiment",
8169
8166
  "createExperimentAssignment",
8170
8167
  "createExperimentGroup",
8168
+ "convertMemberFilterToQuery",
8171
8169
  "createFhirConnection",
8172
8170
  "createFile",
8173
8171
  "createFileLabel",
@@ -8232,6 +8230,7 @@ var WORKSPACE_METHOD_NAMES = [
8232
8230
  "deleteExperimentAssignment",
8233
8231
  "deleteExperimentGroup",
8234
8232
  "deleteFhirConnection",
8233
+ "deletePatientSyncConnection",
8235
8234
  "deleteFile",
8236
8235
  "deleteFileLabel",
8237
8236
  "deleteFolder",
@@ -8367,6 +8366,7 @@ var WORKSPACE_METHOD_NAMES = [
8367
8366
  "getCelContext",
8368
8367
  "getChat",
8369
8368
  "getChatAssignmentTasks",
8369
+ "getChatCallbacks",
8370
8370
  "getChatEmails",
8371
8371
  "getChatFilter",
8372
8372
  "getChatFilterByUuid",
@@ -8433,6 +8433,7 @@ var WORKSPACE_METHOD_NAMES = [
8433
8433
  "getHealthieAvailableSlots",
8434
8434
  "getHealthieReconciliationMatches",
8435
8435
  "getHealthieStatus",
8436
+ "getPatientSyncStatus",
8436
8437
  "getHubspotContactProperties",
8437
8438
  "getHubspotManagedRules",
8438
8439
  "getHubspotReconciliationMatches",
@@ -8478,6 +8479,7 @@ var WORKSPACE_METHOD_NAMES = [
8478
8479
  "getMemberRole",
8479
8480
  "getMemberRoleByUuid",
8480
8481
  "getMemberRoles",
8482
+ "getMemberSyncLinks",
8481
8483
  "getMemberSyncSummary",
8482
8484
  "getMemberUsage",
8483
8485
  "getMembersMessageActivity",
@@ -8642,6 +8644,7 @@ var WORKSPACE_METHOD_NAMES = [
8642
8644
  "markEmailAsRead",
8643
8645
  "markEmailAsUnread",
8644
8646
  "markNotificationAsRead",
8647
+ "previewImportMembers",
8645
8648
  "previewImportWorkspace",
8646
8649
  "previewSchedule",
8647
8650
  "previewTTS",
@@ -8868,6 +8871,8 @@ function bindTasksMethods(target, tasks, abilities) {
8868
8871
  function bindChatsMethods(target, chats) {
8869
8872
  target.getChats = chats.getChats.bind(chats);
8870
8873
  target.getChat = chats.getChat.bind(chats);
8874
+ target.getChatCallbacks = chats.getChatCallbacks.bind(chats);
8875
+ target.cancelChatCallback = chats.cancelChatCallback.bind(chats);
8871
8876
  target.getChatTokenUsage = chats.getChatTokenUsage.bind(chats);
8872
8877
  target.getChatTodos = chats.getChatTodos.bind(chats);
8873
8878
  target.getChatSkills = chats.getChatSkills.bind(chats);
@@ -8917,6 +8922,8 @@ function bindCallsMethods(target, calls, cel) {
8917
8922
  target.initiateCall = calls.initiateCall.bind(calls);
8918
8923
  target.getVoiceToken = calls.getVoiceToken.bind(calls);
8919
8924
  target.getMessageTiming = calls.getMessageTiming.bind(calls);
8925
+ target.listChatRecordings = calls.listChatRecordings.bind(calls);
8926
+ target.getCallRecordingDownloadUrl = calls.getCallRecordingDownloadUrl.bind(calls);
8920
8927
  target.getCelContext = cel.getCelContext.bind(cel);
8921
8928
  }
8922
8929
 
@@ -8959,6 +8966,9 @@ function bindMembersMethods(target, members) {
8959
8966
  target.deleteMember = members.deleteMember.bind(members);
8960
8967
  target.archiveMember = members.archiveMember.bind(members);
8961
8968
  target.unarchiveMember = members.unarchiveMember.bind(members);
8969
+ target.sendMemberPhoneConfirmation = members.sendMemberPhoneConfirmation.bind(members);
8970
+ target.bulkCreateMembers = members.bulkCreateMembers.bind(members);
8971
+ target.previewImportMembers = members.previewImportMembers.bind(members);
8962
8972
  target.importMembers = members.importMembers.bind(members);
8963
8973
  target.exportMembers = members.exportMembers.bind(members);
8964
8974
  target.getMembersMessageActivity = members.getMembersMessageActivity.bind(members);
@@ -8966,6 +8976,7 @@ function bindMembersMethods(target, members) {
8966
8976
  target.getMemberFilter = members.getMemberFilter.bind(members);
8967
8977
  target.createMemberFilter = members.createMemberFilter.bind(members);
8968
8978
  target.updateMemberFilter = members.updateMemberFilter.bind(members);
8979
+ target.convertMemberFilterToQuery = members.convertMemberFilterToQuery.bind(members);
8969
8980
  target.deleteMemberFilter = members.deleteMemberFilter.bind(members);
8970
8981
  target.getMemberFilterCount = members.getMemberFilterCount.bind(members);
8971
8982
  target.getMemberLabels = members.getMemberLabels.bind(members);
@@ -8995,6 +9006,7 @@ function bindMembersMethods(target, members) {
8995
9006
  target.getMemberMemories = members.getMemberMemories.bind(members);
8996
9007
  target.createMemberMemory = members.createMemberMemory.bind(members);
8997
9008
  target.deleteMemberMemory = members.deleteMemberMemory.bind(members);
9009
+ target.getMemberSyncLinks = members.getMemberSyncLinks.bind(members);
8998
9010
  }
8999
9011
 
9000
9012
  // src/client/bindings/workspaces.ts
@@ -9128,6 +9140,19 @@ function bindSitesMethods(target, sites) {
9128
9140
  target.checkSiteSlugAvailability = sites.checkSiteSlugAvailability.bind(sites);
9129
9141
  target.checkSiteDomainAvailability = sites.checkSiteDomainAvailability.bind(sites);
9130
9142
  target.getSite = sites.getSite.bind(sites);
9143
+ target.getSiteSharing = sites.getSiteSharing.bind(sites);
9144
+ target.updateSiteSharing = sites.updateSiteSharing.bind(sites);
9145
+ target.getSiteSource = sites.getSiteSource.bind(sites);
9146
+ target.getSiteSourceTemplates = sites.getSiteSourceTemplates.bind(sites);
9147
+ target.createSiteSource = sites.createSiteSource.bind(sites);
9148
+ target.buildSiteSource = sites.buildSiteSource.bind(sites);
9149
+ target.publishSiteSource = sites.publishSiteSource.bind(sites);
9150
+ target.resetSiteSource = sites.resetSiteSource.bind(sites);
9151
+ target.rollbackSiteSource = sites.rollbackSiteSource.bind(sites);
9152
+ target.downloadSiteSourceZip = sites.downloadSiteSourceZip.bind(sites);
9153
+ target.importSiteSourceZip = sites.importSiteSourceZip.bind(sites);
9154
+ target.getThemeSettings = sites.getThemeSettings.bind(sites);
9155
+ target.updateThemeSettings = sites.updateThemeSettings.bind(sites);
9131
9156
  target.getSiteByUuid = sites.getSiteByUuid.bind(sites);
9132
9157
  target.getSiteRenderedPage = sites.getSiteRenderedPage.bind(sites);
9133
9158
  target.getSiteRenderedMenu = sites.getSiteRenderedMenu.bind(sites);
@@ -9160,6 +9185,7 @@ function bindSitesMethods(target, sites) {
9160
9185
  function bindFilesMethods(target, files) {
9161
9186
  target.getFiles = files.getFiles.bind(files);
9162
9187
  target.getFile = files.getFile.bind(files);
9188
+ target.downloadFilesZip = files.downloadFilesZip.bind(files);
9163
9189
  target.createFile = files.createFile.bind(files);
9164
9190
  target.uploadFile = files.uploadFile.bind(files);
9165
9191
  target.updateFile = files.updateFile.bind(files);
@@ -9201,6 +9227,7 @@ function bindEventsMethods(target, events) {
9201
9227
  target.createEventRule = events.createEventRule.bind(events);
9202
9228
  target.updateEventRule = events.updateEventRule.bind(events);
9203
9229
  target.deleteEventRule = events.deleteEventRule.bind(events);
9230
+ target.testWebhook = events.testWebhook.bind(events);
9204
9231
  target.reorderEventRules = events.reorderEventRules.bind(events);
9205
9232
  target.getWebhookLogs = events.getWebhookLogs.bind(events);
9206
9233
  target.getRuleExecutions = events.getRuleExecutions.bind(events);
@@ -9451,12 +9478,13 @@ function bindAppsMethods(target, apps, builders, inquiries, oauth, oauthConnecti
9451
9478
  target.exchangeOAuthToken = oauth.exchangeOAuthToken.bind(oauth);
9452
9479
  target.getAvailableScopes = oauth.getAvailableScopes.bind(oauth);
9453
9480
  target.getOAuthConnectionStatus = oauthConnections.getConnectionStatus.bind(oauthConnections);
9481
+ target.listOAuthAccounts = oauthConnections.listAccounts.bind(oauthConnections);
9454
9482
  target.getOAuthAuthorizationUrl = oauthConnections.getAuthorizationUrl.bind(oauthConnections);
9455
9483
  target.disconnectOAuthProvider = oauthConnections.disconnect.bind(oauthConnections);
9456
9484
  }
9457
9485
 
9458
9486
  // src/client/bindings/integrations.ts
9459
- function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackApps, teamsApps, fhirConnections, healthie, salesforce, hubspot, appConnections, connectionSync, confluence) {
9487
+ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackApps, teamsApps, fhirConnections, patientSyncConnections, healthie, salesforce, hubspot, appConnections, connectionSync, confluence) {
9460
9488
  target.getMondayBoards = mondayIntegration.getBoards.bind(mondayIntegration);
9461
9489
  target.getMondayBoardColumns = mondayIntegration.getBoardColumns.bind(mondayIntegration);
9462
9490
  target.getMondayBoardGroups = mondayIntegration.getBoardGroups.bind(mondayIntegration);
@@ -9541,6 +9569,9 @@ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackAp
9541
9569
  target.fhirGetEncounterSyncRuns = fhirConnections.fhirGetEncounterSyncRuns.bind(fhirConnections);
9542
9570
  target.fhirRefreshEncounterPatient = fhirConnections.fhirRefreshEncounterPatient.bind(fhirConnections);
9543
9571
  target.fhirBackfillEncounterSync = fhirConnections.fhirBackfillEncounterSync.bind(fhirConnections);
9572
+ target.configurePatientSync = patientSyncConnections.configurePatientSync.bind(patientSyncConnections);
9573
+ target.getPatientSyncStatus = patientSyncConnections.getPatientSyncStatus.bind(patientSyncConnections);
9574
+ target.deletePatientSyncConnection = patientSyncConnections.deletePatientSyncConnection.bind(patientSyncConnections);
9544
9575
  target.configureHealthie = healthie.configureHealthie.bind(healthie);
9545
9576
  target.getHealthieStatus = healthie.getHealthieStatus.bind(healthie);
9546
9577
  target.listHealthieProviders = healthie.listHealthieProviders.bind(healthie);
@@ -9734,6 +9765,14 @@ function bindPersonasMethods(target, personas) {
9734
9765
  target.deletePersona = personas.deletePersona.bind(personas);
9735
9766
  }
9736
9767
 
9768
+ // src/client/bindings/queries.ts
9769
+ function bindQueriesMethods(target, queries) {
9770
+ target.getQueryFields = queries.getQueryFields.bind(queries);
9771
+ target.validateQuery = queries.validateQuery.bind(queries);
9772
+ target.previewQuery = queries.previewQuery.bind(queries);
9773
+ target.runQuery = queries.runQuery.bind(queries);
9774
+ }
9775
+
9737
9776
  // src/client/bindings/customers.ts
9738
9777
  function bindCustomersMethods(target, customers) {
9739
9778
  target.getMyCustomers = customers.getMyCustomers.bind(customers);
@@ -9780,6 +9819,7 @@ function bindSupportRequestMethods(target, supportRequests) {
9780
9819
  target.createWorkspaceSupportRequest = supportRequests.createWorkspaceSupportRequest.bind(supportRequests);
9781
9820
  target.commentOnWorkspaceSupportRequest = supportRequests.commentOnWorkspaceSupportRequest.bind(supportRequests);
9782
9821
  target.closeWorkspaceSupportRequest = supportRequests.closeWorkspaceSupportRequest.bind(supportRequests);
9822
+ target.reopenWorkspaceSupportRequest = supportRequests.reopenWorkspaceSupportRequest.bind(supportRequests);
9783
9823
  target.clickWorkspaceSupportRequestResource = supportRequests.clickWorkspaceSupportRequestResource.bind(supportRequests);
9784
9824
  }
9785
9825
 
@@ -9807,6 +9847,8 @@ var GravityRailClient = class {
9807
9847
  // Chats API
9808
9848
  getChats;
9809
9849
  getChat;
9850
+ getChatCallbacks;
9851
+ cancelChatCallback;
9810
9852
  getChatTokenUsage;
9811
9853
  getChatTodos;
9812
9854
  getChatSkills;
@@ -9853,6 +9895,8 @@ var GravityRailClient = class {
9853
9895
  initiateCall;
9854
9896
  getVoiceToken;
9855
9897
  getMessageTiming;
9898
+ listChatRecordings;
9899
+ getCallRecordingDownloadUrl;
9856
9900
  getCelContext;
9857
9901
  // Data Types API
9858
9902
  getDataTypes;
@@ -9889,6 +9933,9 @@ var GravityRailClient = class {
9889
9933
  deleteMember;
9890
9934
  archiveMember;
9891
9935
  unarchiveMember;
9936
+ sendMemberPhoneConfirmation;
9937
+ bulkCreateMembers;
9938
+ previewImportMembers;
9892
9939
  importMembers;
9893
9940
  exportMembers;
9894
9941
  getMembersMessageActivity;
@@ -9896,6 +9943,7 @@ var GravityRailClient = class {
9896
9943
  getMemberFilter;
9897
9944
  createMemberFilter;
9898
9945
  updateMemberFilter;
9946
+ convertMemberFilterToQuery;
9899
9947
  deleteMemberFilter;
9900
9948
  getMemberFilterCount;
9901
9949
  getMemberLabels;
@@ -9929,6 +9977,8 @@ var GravityRailClient = class {
9929
9977
  getMemberMemories;
9930
9978
  createMemberMemory;
9931
9979
  deleteMemberMemory;
9980
+ // Member Sync Links
9981
+ getMemberSyncLinks;
9932
9982
  // Agent Tasks API (operator-facing async sub-agent inspection/cancel)
9933
9983
  getAgentTasks;
9934
9984
  getAgentTask;
@@ -9959,6 +10009,11 @@ var GravityRailClient = class {
9959
10009
  evaluateTestChatRun;
9960
10010
  endTestChatRun;
9961
10011
  // Personas API (workspace-scoped test-identity templates)
10012
+ // Unified Query Engine
10013
+ getQueryFields;
10014
+ validateQuery;
10015
+ previewQuery;
10016
+ runQuery;
9962
10017
  listPersonas;
9963
10018
  getPersona;
9964
10019
  createPersona;
@@ -10177,6 +10232,19 @@ var GravityRailClient = class {
10177
10232
  checkSiteSlugAvailability;
10178
10233
  checkSiteDomainAvailability;
10179
10234
  getSite;
10235
+ getSiteSharing;
10236
+ updateSiteSharing;
10237
+ getSiteSource;
10238
+ getSiteSourceTemplates;
10239
+ createSiteSource;
10240
+ buildSiteSource;
10241
+ publishSiteSource;
10242
+ resetSiteSource;
10243
+ rollbackSiteSource;
10244
+ downloadSiteSourceZip;
10245
+ importSiteSourceZip;
10246
+ getThemeSettings;
10247
+ updateThemeSettings;
10180
10248
  getSiteByUuid;
10181
10249
  getSiteRenderedPage;
10182
10250
  getSiteRenderedMenu;
@@ -10206,6 +10274,7 @@ var GravityRailClient = class {
10206
10274
  // Files API
10207
10275
  getFiles;
10208
10276
  getFile;
10277
+ downloadFilesZip;
10209
10278
  createFile;
10210
10279
  uploadFile;
10211
10280
  updateFile;
@@ -10245,6 +10314,7 @@ var GravityRailClient = class {
10245
10314
  createEventRule;
10246
10315
  updateEventRule;
10247
10316
  deleteEventRule;
10317
+ testWebhook;
10248
10318
  reorderEventRules;
10249
10319
  getWebhookLogs;
10250
10320
  getRuleExecutions;
@@ -10460,6 +10530,7 @@ var GravityRailClient = class {
10460
10530
  exchangeOAuthToken;
10461
10531
  getAvailableScopes;
10462
10532
  getOAuthConnectionStatus;
10533
+ listOAuthAccounts;
10463
10534
  getOAuthAuthorizationUrl;
10464
10535
  disconnectOAuthProvider;
10465
10536
  // Integrations API
@@ -10553,6 +10624,9 @@ var GravityRailClient = class {
10553
10624
  fhirRefreshEncounterPatient;
10554
10625
  fhirBackfillEncounterSync;
10555
10626
  // Healthie API
10627
+ configurePatientSync;
10628
+ getPatientSyncStatus;
10629
+ deletePatientSyncConnection;
10556
10630
  configureHealthie;
10557
10631
  getHealthieStatus;
10558
10632
  listHealthieProviders;
@@ -10681,6 +10755,7 @@ var GravityRailClient = class {
10681
10755
  createWorkspaceSupportRequest;
10682
10756
  commentOnWorkspaceSupportRequest;
10683
10757
  closeWorkspaceSupportRequest;
10758
+ reopenWorkspaceSupportRequest;
10684
10759
  clickWorkspaceSupportRequestResource;
10685
10760
  constructor(apiKey, baseUrl, customFetch) {
10686
10761
  const apis = createApiModules(apiKey, baseUrl, customFetch);
@@ -10695,6 +10770,7 @@ var GravityRailClient = class {
10695
10770
  bindAgentsMethods(this, apis.agents);
10696
10771
  bindQualificationsMethods(this, apis.qualifications);
10697
10772
  bindPersonasMethods(this, apis.personas);
10773
+ bindQueriesMethods(this, apis.queries);
10698
10774
  bindJourneysMethods(this, apis.journeys);
10699
10775
  bindExperimentsMethods(this, apis.experiments);
10700
10776
  bindOperatorMethods(this, apis.operatorGroups);
@@ -10734,6 +10810,7 @@ var GravityRailClient = class {
10734
10810
  apis.slackApps,
10735
10811
  apis.teamsApps,
10736
10812
  apis.fhirConnections,
10813
+ apis.patientSyncConnections,
10737
10814
  apis.healthie,
10738
10815
  apis.salesforce,
10739
10816
  apis.hubspot,
@@ -10787,23 +10864,30 @@ var GravityRailClient = class {
10787
10864
  });
10788
10865
  }
10789
10866
  /**
10790
- * Set the org token for cross-domain / non-browser clients (e.g. CLI).
10791
- * When set, all API requests include the X-Org-Token header so the backend
10792
- * accepts the request without requiring a browser cookie.
10867
+ * Set the org session credential for cross-domain / non-browser clients (e.g. CLI).
10868
+ * Opaque gr_sess_ values use X-Org-Session. Legacy orgToken JWE values still
10869
+ * use X-Org-Token during the migration window.
10793
10870
  *
10794
- * `orgUuid` is the org that issued the token. Pass it so the SDK can
10795
- * detect a stale token (e.g. switching orgs mid-session) and re-fire the
10871
+ * `orgUuid` is the org that issued the session. Pass it so the SDK can
10872
+ * detect a stale session (e.g. switching orgs mid-session) and re-fire the
10796
10873
  * org-auth handler instead of silently 401-ing.
10797
10874
  *
10798
10875
  * Propagates to all API modules.
10799
10876
  */
10800
- setOrgToken(token, orgUuid) {
10877
+ setOrgSession(session, orgUuid) {
10801
10878
  Object.values(this.apis).forEach((api) => {
10802
- if (typeof api.setOrgToken === "function") {
10803
- api.setOrgToken(token, orgUuid);
10879
+ if (typeof api.setOrgSession === "function") {
10880
+ api.setOrgSession(session, orgUuid);
10804
10881
  }
10805
10882
  });
10806
10883
  }
10884
+ /**
10885
+ * @deprecated Legacy compatibility for stateless orgToken JWE credentials.
10886
+ * Prefer setOrgSession() for opaque org browser sessions.
10887
+ */
10888
+ setOrgToken(token, orgUuid) {
10889
+ this.setOrgSession(token, orgUuid);
10890
+ }
10807
10891
  /**
10808
10892
  * Update the API key across all modules.
10809
10893
  * Used after successful re-authentication.
@@ -10854,15 +10938,20 @@ var AbilityTypeSlugs = {
10854
10938
  TOOLKITS: "tools:toolkits",
10855
10939
  WEB_SEARCH: "tools:web_search",
10856
10940
  CONVERSATION_HISTORY: "tools:conversation_history",
10941
+ IMAGE_GENERATION: "tools:image_generation",
10942
+ CONVERSATION_CONTROL: "tools:conversation_control",
10857
10943
  // Integration
10858
10944
  CALENDAR_BOOKING: "integration:calendar_booking",
10859
10945
  FILE_ACCESS: "integration:file_access",
10860
10946
  DATA_ACCESS: "integration:data_access",
10861
10947
  GMAIL: "integration:gmail",
10948
+ GOOGLE_CALENDAR: "integration:google_calendar",
10949
+ GOOGLE_DRIVE: "integration:google_drive",
10862
10950
  CHARLESTON_PMD_PAGING: "integration:charleston_pmd_paging",
10863
10951
  // Communication
10864
10952
  PHONE_CALL_TOOLS: "communication:phone_call_tools",
10865
10953
  SEND_SMS: "communication:send_sms",
10954
+ SEND_WHATSAPP: "communication:send_whatsapp",
10866
10955
  MEMBER_ACCESS: "communication:member_access",
10867
10956
  AUDIO_PLAYBACK: "communication:audio_playback",
10868
10957
  // Oversight
@@ -10871,6 +10960,12 @@ var AbilityTypeSlugs = {
10871
10960
  ESCALATION: "oversight:escalation",
10872
10961
  // Identity
10873
10962
  MEMBER_FIELD_VERIFICATION: "identity:member_field_verification",
10963
+ // Delegation
10964
+ CONTRIBUTOR: "delegation:contributor",
10965
+ // Workflow
10966
+ WORKFLOW_RUN: "workflow:run",
10967
+ // Commerce
10968
+ RESELLER: "commerce:reseller",
10874
10969
  // System (auto-injected, hidden from users)
10875
10970
  USER_MESSAGE_RULES: "system:user_message_rules",
10876
10971
  ASSISTANT_MESSAGE_RULES: "chat:assistant_message_rules",
@@ -10892,7 +10987,6 @@ var TTS_PREVIEW_PROVIDERS = [
10892
10987
  "elevenlabs",
10893
10988
  "google",
10894
10989
  "aws",
10895
- "pocket",
10896
10990
  "deepgram",
10897
10991
  "xai"
10898
10992
  ];
@@ -10907,6 +11001,13 @@ function canPreviewVoice(entity) {
10907
11001
  return TTS_PREVIEW_PROVIDERS.includes(provider);
10908
11002
  }
10909
11003
 
11004
+ // src/types/query-engine-types.ts
11005
+ var QUERY_VALUELESS_OPS = /* @__PURE__ */ new Set([
11006
+ "isEmpty",
11007
+ "notEmpty",
11008
+ "exists"
11009
+ ]);
11010
+
10910
11011
  // src/types/chat-types.ts
10911
11012
  var SMS_DELIVERY_FAILURE_STATUSES = /* @__PURE__ */ new Set([
10912
11013
  "failed",
@@ -11132,21 +11233,16 @@ var CHAT_TYPES = {
11132
11233
  ASSIGNMENT: "assignment",
11133
11234
  MANAGER: "manager",
11134
11235
  CONTRIBUTOR: "contributor",
11135
- DEVELOPER: "developer",
11136
- MEMBER: "member",
11137
- /** @deprecated Use MEMBER instead */
11138
- AGENT: "member",
11139
- /** @deprecated Use MEMBER instead */
11140
- DM: "member"
11236
+ DM: "dm"
11141
11237
  };
11142
11238
  var BUILTIN_ASSISTANT_CHAT_TYPES = /* @__PURE__ */ new Set([
11143
11239
  CHAT_TYPES.MANAGER,
11144
- CHAT_TYPES.CONTRIBUTOR,
11145
- CHAT_TYPES.DEVELOPER
11240
+ CHAT_TYPES.CONTRIBUTOR
11146
11241
  ]);
11242
+ var MEMBER_AGENT_CHAT_TYPES = /* @__PURE__ */ new Set([CHAT_TYPES.DM]);
11147
11243
  var NO_ASSISTANT_PARTICIPANT_CHAT_TYPES = /* @__PURE__ */ new Set([
11148
11244
  ...BUILTIN_ASSISTANT_CHAT_TYPES,
11149
- CHAT_TYPES.MEMBER
11245
+ ...MEMBER_AGENT_CHAT_TYPES
11150
11246
  ]);
11151
11247
  function usesBuiltinAssistant(chatType) {
11152
11248
  return BUILTIN_ASSISTANT_CHAT_TYPES.has(chatType);
@@ -11939,9 +12035,6 @@ var SCOPE_PRESETS = {
11939
12035
  };
11940
12036
 
11941
12037
  export {
11942
- getCookieValue,
11943
- ApiError,
11944
- BaseApiClient,
11945
12038
  AbilitiesApi,
11946
12039
  AccessGrantsApi,
11947
12040
  AgentTasksApi,
@@ -11971,6 +12064,7 @@ export {
11971
12064
  InquiriesApi,
11972
12065
  AppConnectionsApi,
11973
12066
  McpServersApi,
12067
+ MemberImportValidationError,
11974
12068
  MembersApi,
11975
12069
  MilestonesApi,
11976
12070
  MondayIntegrationApi,
@@ -11983,6 +12077,7 @@ export {
11983
12077
  PronunciationsApi,
11984
12078
  PromptsApi,
11985
12079
  PersonasApi,
12080
+ QueriesApi,
11986
12081
  QualificationsApi,
11987
12082
  ReportsApi,
11988
12083
  SalesforceApi,
@@ -12016,6 +12111,8 @@ export {
12016
12111
  encodePermissions,
12017
12112
  Scope,
12018
12113
  BulkMemberResultStatus,
12114
+ MemberImportMatchInfoMatchType,
12115
+ MemberImportPreviewRowAction,
12019
12116
  MemberType,
12020
12117
  McpServerState,
12021
12118
  ToolkitState,
@@ -12051,7 +12148,8 @@ export {
12051
12148
  TTS_MODEL_DEEPGRAM_AURA_2,
12052
12149
  TTS_MODEL_AWS_POLLY_GENERATIVE,
12053
12150
  TTS_MODEL_AWS_POLLY_NEURAL,
12054
- TTS_MODEL_POCKET,
12151
+ PIDS_DISPOSITIONS,
12152
+ PIDS_SOURCES,
12055
12153
  FhirVendor,
12056
12154
  FhirConnectionState,
12057
12155
  FhirClientType,
@@ -12095,6 +12193,7 @@ export {
12095
12193
  bindJourneysMethods,
12096
12194
  bindQualificationsMethods,
12097
12195
  bindPersonasMethods,
12196
+ bindQueriesMethods,
12098
12197
  bindCustomersMethods,
12099
12198
  bindResellersMethods,
12100
12199
  bindPromptsMethods,
@@ -12109,6 +12208,7 @@ export {
12109
12208
  TTS_PREVIEW_PROVIDERS,
12110
12209
  getVoiceModelId,
12111
12210
  canPreviewVoice,
12211
+ QUERY_VALUELESS_OPS,
12112
12212
  SMS_DELIVERY_FAILURE_STATUSES,
12113
12213
  isSMSDeliveryFailureStatus,
12114
12214
  BusinessIndustry,
@@ -12153,4 +12253,4 @@ export {
12153
12253
  ScopeManager,
12154
12254
  SCOPE_PRESETS
12155
12255
  };
12156
- //# sourceMappingURL=chunk-ML55PVP7.js.map
12256
+ //# sourceMappingURL=chunk-2BJG4GYM.js.map