@amigo-ai/platform-sdk 0.1.0 → 0.3.0

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 (149) hide show
  1. package/README.md +126 -8
  2. package/dist/core/branded-types.js +1 -0
  3. package/dist/core/branded-types.js.map +1 -1
  4. package/dist/core/errors.js +43 -3
  5. package/dist/core/errors.js.map +1 -1
  6. package/dist/core/openapi-client.js +60 -48
  7. package/dist/core/openapi-client.js.map +1 -1
  8. package/dist/core/rate-limit.js +13 -0
  9. package/dist/core/rate-limit.js.map +1 -0
  10. package/dist/core/webhooks.js +17 -0
  11. package/dist/core/webhooks.js.map +1 -0
  12. package/dist/generated/api.js +2 -0
  13. package/dist/{types → generated}/api.js.map +1 -1
  14. package/dist/index.cjs +1668 -371
  15. package/dist/index.cjs.map +4 -4
  16. package/dist/index.js +59 -43
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +1658 -371
  19. package/dist/index.mjs.map +4 -4
  20. package/dist/resources/actions.js +52 -0
  21. package/dist/resources/actions.js.map +1 -0
  22. package/dist/resources/agents.js +30 -30
  23. package/dist/resources/agents.js.map +1 -1
  24. package/dist/resources/analytics.js +34 -15
  25. package/dist/resources/analytics.js.map +1 -1
  26. package/dist/resources/api-keys.js +17 -19
  27. package/dist/resources/api-keys.js.map +1 -1
  28. package/dist/resources/audit.js +35 -0
  29. package/dist/resources/audit.js.map +1 -0
  30. package/dist/resources/base.js +12 -44
  31. package/dist/resources/base.js.map +1 -1
  32. package/dist/resources/billing.js +35 -7
  33. package/dist/resources/billing.js.map +1 -1
  34. package/dist/resources/calls.js +25 -9
  35. package/dist/resources/calls.js.map +1 -1
  36. package/dist/resources/compliance.js +19 -0
  37. package/dist/resources/compliance.js.map +1 -0
  38. package/dist/resources/context-graphs.js +46 -18
  39. package/dist/resources/context-graphs.js.map +1 -1
  40. package/dist/resources/data-sources.js +30 -12
  41. package/dist/resources/data-sources.js.map +1 -1
  42. package/dist/resources/functions.js +42 -0
  43. package/dist/resources/functions.js.map +1 -0
  44. package/dist/resources/integrations.js +32 -15
  45. package/dist/resources/integrations.js.map +1 -1
  46. package/dist/resources/memory.js +13 -4
  47. package/dist/resources/memory.js.map +1 -1
  48. package/dist/resources/operators.js +102 -0
  49. package/dist/resources/operators.js.map +1 -0
  50. package/dist/resources/personas.js +31 -0
  51. package/dist/resources/personas.js.map +1 -0
  52. package/dist/resources/phone-numbers.js +31 -16
  53. package/dist/resources/phone-numbers.js.map +1 -1
  54. package/dist/resources/recordings.js +19 -0
  55. package/dist/resources/recordings.js.map +1 -0
  56. package/dist/resources/review-queue.js +94 -0
  57. package/dist/resources/review-queue.js.map +1 -0
  58. package/dist/resources/safety.js +31 -0
  59. package/dist/resources/safety.js.map +1 -0
  60. package/dist/resources/services.js +18 -12
  61. package/dist/resources/services.js.map +1 -1
  62. package/dist/resources/settings.js +50 -24
  63. package/dist/resources/settings.js.map +1 -1
  64. package/dist/resources/simulations.js +23 -17
  65. package/dist/resources/simulations.js.map +1 -1
  66. package/dist/resources/skills.js +22 -16
  67. package/dist/resources/skills.js.map +1 -1
  68. package/dist/resources/triggers.js +51 -0
  69. package/dist/resources/triggers.js.map +1 -0
  70. package/dist/resources/webhook-destinations.js +44 -0
  71. package/dist/resources/webhook-destinations.js.map +1 -0
  72. package/dist/resources/workspaces.js +24 -38
  73. package/dist/resources/workspaces.js.map +1 -1
  74. package/dist/resources/world.js +58 -60
  75. package/dist/resources/world.js.map +1 -1
  76. package/dist/types/core/branded-types.d.ts +3 -0
  77. package/dist/types/core/branded-types.d.ts.map +1 -1
  78. package/dist/types/core/errors.d.ts +3 -0
  79. package/dist/types/core/errors.d.ts.map +1 -1
  80. package/dist/types/core/openapi-client.d.ts +13 -5
  81. package/dist/types/core/openapi-client.d.ts.map +1 -1
  82. package/dist/types/core/rate-limit.d.ts +8 -0
  83. package/dist/types/core/rate-limit.d.ts.map +1 -0
  84. package/dist/types/core/webhooks.d.ts +9 -0
  85. package/dist/types/core/webhooks.d.ts.map +1 -0
  86. package/dist/types/generated/api.d.ts +35120 -0
  87. package/dist/types/generated/api.d.ts.map +1 -0
  88. package/dist/types/index.d.ts +45 -43
  89. package/dist/types/index.d.ts.map +1 -1
  90. package/dist/types/resources/actions.d.ts +158 -0
  91. package/dist/types/resources/actions.d.ts.map +1 -0
  92. package/dist/types/resources/agents.d.ts +70 -22
  93. package/dist/types/resources/agents.d.ts.map +1 -1
  94. package/dist/types/resources/analytics.d.ts +100 -118
  95. package/dist/types/resources/analytics.d.ts.map +1 -1
  96. package/dist/types/resources/api-keys.d.ts +36 -7
  97. package/dist/types/resources/api-keys.d.ts.map +1 -1
  98. package/dist/types/resources/audit.d.ts +70 -0
  99. package/dist/types/resources/audit.d.ts.map +1 -0
  100. package/dist/types/resources/base.d.ts +13 -13
  101. package/dist/types/resources/base.d.ts.map +1 -1
  102. package/dist/types/resources/billing.d.ts +52 -12
  103. package/dist/types/resources/billing.d.ts.map +1 -1
  104. package/dist/types/resources/calls.d.ts +89 -35
  105. package/dist/types/resources/calls.d.ts.map +1 -1
  106. package/dist/types/resources/compliance.d.ts +45 -0
  107. package/dist/types/resources/compliance.d.ts.map +1 -0
  108. package/dist/types/resources/context-graphs.d.ts +77 -14
  109. package/dist/types/resources/context-graphs.d.ts.map +1 -1
  110. package/dist/types/resources/data-sources.d.ts +105 -9
  111. package/dist/types/resources/data-sources.d.ts.map +1 -1
  112. package/dist/types/resources/functions.d.ts +46 -0
  113. package/dist/types/resources/functions.d.ts.map +1 -0
  114. package/dist/types/resources/integrations.d.ts +83 -12
  115. package/dist/types/resources/integrations.d.ts.map +1 -1
  116. package/dist/types/resources/memory.d.ts +26 -73
  117. package/dist/types/resources/memory.d.ts.map +1 -1
  118. package/dist/types/resources/operators.d.ts +157 -0
  119. package/dist/types/resources/operators.d.ts.map +1 -0
  120. package/dist/types/resources/personas.d.ts +60 -0
  121. package/dist/types/resources/personas.d.ts.map +1 -0
  122. package/dist/types/resources/phone-numbers.d.ts +70 -10
  123. package/dist/types/resources/phone-numbers.d.ts.map +1 -1
  124. package/dist/types/resources/recordings.d.ts +29 -0
  125. package/dist/types/resources/recordings.d.ts.map +1 -0
  126. package/dist/types/resources/review-queue.d.ts +184 -0
  127. package/dist/types/resources/review-queue.d.ts.map +1 -0
  128. package/dist/types/resources/safety.d.ts +57 -0
  129. package/dist/types/resources/safety.d.ts.map +1 -0
  130. package/dist/types/resources/services.d.ts +85 -5
  131. package/dist/types/resources/services.d.ts.map +1 -1
  132. package/dist/types/resources/settings.d.ts +79 -78
  133. package/dist/types/resources/settings.d.ts.map +1 -1
  134. package/dist/types/resources/simulations.d.ts +41 -12
  135. package/dist/types/resources/simulations.d.ts.map +1 -1
  136. package/dist/types/resources/skills.d.ts +131 -6
  137. package/dist/types/resources/skills.d.ts.map +1 -1
  138. package/dist/types/resources/triggers.d.ts +129 -0
  139. package/dist/types/resources/triggers.d.ts.map +1 -0
  140. package/dist/types/resources/webhook-destinations.d.ts +75 -0
  141. package/dist/types/resources/webhook-destinations.d.ts.map +1 -0
  142. package/dist/types/resources/workspaces.d.ts +60 -15
  143. package/dist/types/resources/workspaces.d.ts.map +1 -1
  144. package/dist/types/resources/world.d.ts +152 -143
  145. package/dist/types/resources/world.d.ts.map +1 -1
  146. package/package.json +13 -5
  147. package/dist/types/api.js +0 -12
  148. package/dist/types/types/api.d.ts +0 -739
  149. package/dist/types/types/api.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,9 +1,39 @@
1
1
  // src/core/errors.ts
2
+ var SENSITIVE_FIELDS = /* @__PURE__ */ new Set([
3
+ "id_token",
4
+ "access_token",
5
+ "refresh_token",
6
+ "authorization",
7
+ "api_key",
8
+ "apikey",
9
+ "token",
10
+ "secret",
11
+ "password",
12
+ "x-api-key",
13
+ "cookie",
14
+ "set-cookie"
15
+ ]);
16
+ function sanitizeErrorContext(obj) {
17
+ if (typeof obj !== "object" || !obj) return obj;
18
+ if (Array.isArray(obj)) return obj.map(sanitizeErrorContext);
19
+ const result = {};
20
+ for (const [key, value] of Object.entries(obj)) {
21
+ if (SENSITIVE_FIELDS.has(key.toLowerCase())) {
22
+ result[key] = "[REDACTED]";
23
+ } else if (typeof value === "object" && value !== null) {
24
+ result[key] = sanitizeErrorContext(value);
25
+ } else {
26
+ result[key] = value;
27
+ }
28
+ }
29
+ return result;
30
+ }
2
31
  var AmigoError = class extends Error {
3
32
  statusCode;
4
33
  errorCode;
5
34
  requestId;
6
35
  detail;
36
+ context;
7
37
  constructor(message, ctx = {}) {
8
38
  super(message);
9
39
  this.name = this.constructor.name;
@@ -11,7 +41,23 @@ var AmigoError = class extends Error {
11
41
  this.errorCode = ctx.errorCode;
12
42
  this.requestId = ctx.requestId;
13
43
  this.detail = ctx.detail;
44
+ this.context = ctx.context ? sanitizeErrorContext(ctx.context) : void 0;
14
45
  Object.setPrototypeOf(this, new.target.prototype);
46
+ if (typeof Error.captureStackTrace === "function") {
47
+ Error.captureStackTrace(this, this.constructor);
48
+ }
49
+ }
50
+ toJSON() {
51
+ return {
52
+ name: this.name,
53
+ message: this.message,
54
+ statusCode: this.statusCode,
55
+ errorCode: this.errorCode,
56
+ requestId: this.requestId,
57
+ detail: this.detail,
58
+ context: this.context,
59
+ stack: this.stack
60
+ };
15
61
  }
16
62
  };
17
63
  var BadRequestError = class extends AmigoError {
@@ -65,8 +111,7 @@ var NetworkError = class extends AmigoError {
65
111
  constructor(message, cause) {
66
112
  super(message);
67
113
  if (cause !== void 0) {
68
- ;
69
- this.cause = cause;
114
+ Object.defineProperty(this, "cause", { value: cause, writable: false, enumerable: true });
70
115
  }
71
116
  }
72
117
  };
@@ -94,7 +139,8 @@ async function createApiError(response) {
94
139
  statusCode: response.status,
95
140
  errorCode: body.error_code,
96
141
  requestId: body.request_id,
97
- detail: body.detail
142
+ detail: body.detail,
143
+ context: { url: response.url, response: body }
98
144
  };
99
145
  const message = body.message ?? body.detail ?? response.statusText ?? `HTTP ${response.status}`;
100
146
  switch (response.status) {
@@ -144,95 +190,200 @@ function isAuthenticationError(err) {
144
190
  return err instanceof AuthenticationError;
145
191
  }
146
192
 
147
- // src/resources/base.ts
148
- var WorkspaceScopedResource = class {
149
- constructor(config) {
150
- this.config = config;
151
- }
152
- get headers() {
153
- return {
154
- Authorization: `Bearer ${this.config.apiKey}`,
155
- "Content-Type": "application/json"
156
- };
157
- }
158
- workspaceUrl(path) {
159
- return `${this.config.baseUrl}/v1/${this.config.workspaceId}${path}`;
160
- }
161
- async fetch(path, init = {}) {
162
- const url = this.workspaceUrl(path);
163
- const response = await globalThis.fetch(url, {
164
- ...init,
165
- headers: {
166
- ...this.headers,
167
- ...init.headers
193
+ // src/core/openapi-client.ts
194
+ import createClientImport from "openapi-fetch";
195
+
196
+ // src/core/auth.ts
197
+ function createAuthMiddleware(config) {
198
+ return {
199
+ async onRequest({ request }) {
200
+ request.headers.set("Authorization", `Bearer ${config.apiKey}`);
201
+ return request;
202
+ },
203
+ async onResponse({ response }) {
204
+ if (response.status === 401) {
205
+ throw new AuthenticationError("Invalid or expired API key. Check your credentials.", {
206
+ statusCode: 401
207
+ });
168
208
  }
169
- });
170
- if (!response.ok) {
171
- throw await createApiError(response);
209
+ return response;
172
210
  }
173
- if (response.status === 204) return void 0;
174
- return response.json();
211
+ };
212
+ }
213
+
214
+ // src/core/retry.ts
215
+ var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
216
+ var POST_RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429]);
217
+ function shouldRetry(ctx) {
218
+ const { method, attempt, response, options } = ctx;
219
+ if (attempt >= options.maxAttempts) return false;
220
+ const status = response.status;
221
+ if (method === "GET" || method === "HEAD") {
222
+ return RETRYABLE_STATUS_CODES.has(status);
223
+ }
224
+ if (method === "POST" && POST_RETRYABLE_STATUS_CODES.has(status)) {
225
+ return response.headers.has("Retry-After");
226
+ }
227
+ return false;
228
+ }
229
+ function computeDelay(attempt, response, options) {
230
+ const retryAfterHeader = response.headers.get("Retry-After");
231
+ if (retryAfterHeader) {
232
+ const seconds = parseRetryAfterHeader(retryAfterHeader);
233
+ if (seconds !== void 0) return seconds * 1e3;
234
+ }
235
+ const exponential = Math.min(options.maxDelayMs, options.baseDelayMs * Math.pow(2, attempt));
236
+ return Math.random() * exponential;
237
+ }
238
+ function parseRetryAfterHeader(header) {
239
+ const seconds = Number(header);
240
+ if (!isNaN(seconds)) return seconds;
241
+ const date = new Date(header);
242
+ if (!isNaN(date.getTime())) {
243
+ return Math.max(0, Math.ceil((date.getTime() - Date.now()) / 1e3));
175
244
  }
176
- };
177
- function buildQuery(params) {
178
- if (!params) return "";
179
- const entries = Object.entries(params).filter(
180
- ([, v]) => v !== void 0 && v !== null
245
+ return void 0;
246
+ }
247
+ function resolveRetryOptions(opts) {
248
+ return {
249
+ maxAttempts: opts?.maxAttempts ?? 3,
250
+ baseDelayMs: opts?.baseDelayMs ?? 250,
251
+ maxDelayMs: opts?.maxDelayMs ?? 3e4
252
+ };
253
+ }
254
+
255
+ // src/core/openapi-client.ts
256
+ var createClient = typeof createClientImport === "function" ? createClientImport : createClientImport.default;
257
+ function createPlatformClient(config) {
258
+ const retryOpts = resolveRetryOptions(config.retry);
259
+ const baseFetch = config.fetch ?? globalThis.fetch;
260
+ const retryingFetch = async (input, init) => {
261
+ const method = (init?.method ?? "GET").toUpperCase();
262
+ const signal = init?.signal;
263
+ const isIdempotent = method === "GET" || method === "HEAD" || method === "OPTIONS";
264
+ for (let attempt = 0; attempt < retryOpts.maxAttempts; attempt++) {
265
+ let response;
266
+ let error;
267
+ try {
268
+ response = await baseFetch(input, init);
269
+ } catch (err) {
270
+ error = err;
271
+ }
272
+ if (!error && response && response.ok) return response;
273
+ const ctx = { method, attempt, response, options: retryOpts };
274
+ const attemptsRemain = attempt + 1 < retryOpts.maxAttempts;
275
+ if (error) {
276
+ if (isIdempotent && attemptsRemain) {
277
+ await sleep(computeDelay(attempt, new Response(), retryOpts));
278
+ continue;
279
+ }
280
+ throw new NetworkError(
281
+ `Network error: ${error instanceof Error ? error.message : String(error)}`,
282
+ error
283
+ );
284
+ }
285
+ if (response && attemptsRemain && shouldRetry(ctx)) {
286
+ const delay = computeDelay(attempt, response, retryOpts);
287
+ if (signal?.aborted) return response;
288
+ await sleep(delay);
289
+ continue;
290
+ }
291
+ return response;
292
+ }
293
+ throw new NetworkError("Retry loop exhausted");
294
+ };
295
+ const client = createClient({
296
+ baseUrl: config.baseUrl,
297
+ fetch: retryingFetch
298
+ });
299
+ const errorMiddleware = {
300
+ async onResponse({ response }) {
301
+ if (!response.ok) {
302
+ throw await createApiError(response);
303
+ }
304
+ return response;
305
+ }
306
+ };
307
+ const authMiddleware = createAuthMiddleware({ apiKey: config.apiKey });
308
+ client.use(authMiddleware);
309
+ client.use(errorMiddleware);
310
+ return client;
311
+ }
312
+ function sleep(ms) {
313
+ return new Promise((resolve) => setTimeout(resolve, ms));
314
+ }
315
+
316
+ // src/core/utils.ts
317
+ function extractData(result) {
318
+ if (result.data !== void 0) return result.data;
319
+ throw new ParseError(
320
+ "Unexpected empty response from API",
321
+ result.error !== void 0 ? JSON.stringify(result.error) : void 0
181
322
  );
182
- if (entries.length === 0) return "";
183
- const searchParams = new URLSearchParams();
184
- for (const [k, v] of entries) {
185
- searchParams.set(k, String(v));
323
+ }
324
+ async function* paginate(fetcher) {
325
+ let token = void 0;
326
+ while (true) {
327
+ const page = await fetcher(token);
328
+ for (const item of page.items) {
329
+ yield item;
330
+ }
331
+ if (!page.has_more || page.continuation_token === null) break;
332
+ token = page.continuation_token;
186
333
  }
187
- return "?" + searchParams.toString();
188
334
  }
189
335
 
190
- // src/resources/workspaces.ts
191
- var WorkspacesResource = class {
192
- constructor(config) {
193
- this.config = config;
194
- }
195
- get headers() {
196
- return {
197
- Authorization: `Bearer ${this.config.apiKey}`,
198
- "Content-Type": "application/json"
199
- };
200
- }
201
- async request(path, init = {}) {
202
- const url = `${this.config.baseUrl}/v1/workspaces${path}`;
203
- const response = await globalThis.fetch(url, {
204
- ...init,
205
- headers: { ...this.headers, ...init.headers }
206
- });
207
- if (!response.ok) throw await createApiError(response);
208
- if (response.status === 204) return void 0;
209
- return response.json();
336
+ // src/resources/base.ts
337
+ var WorkspaceScopedResource = class {
338
+ constructor(client, workspaceId2) {
339
+ this.client = client;
340
+ this.workspaceId = workspaceId2;
210
341
  }
342
+ };
343
+
344
+ // src/resources/workspaces.ts
345
+ var WorkspacesResource = class extends WorkspaceScopedResource {
211
346
  /** Create a new workspace */
212
347
  async create(body) {
213
- return this.request("", {
214
- method: "POST",
215
- body: JSON.stringify(body)
216
- });
348
+ return extractData(
349
+ await this.client.POST("/v1/workspaces", {
350
+ body
351
+ })
352
+ );
217
353
  }
218
354
  /** List workspaces accessible to the current API key */
219
355
  async list(params) {
220
- return this.request(buildQuery(params));
356
+ return extractData(
357
+ await this.client.GET("/v1/workspaces", {
358
+ params: { query: params }
359
+ })
360
+ );
221
361
  }
222
362
  /** Get a single workspace by ID */
223
363
  async get(id) {
224
- return this.request(`/${id}`);
364
+ return extractData(
365
+ await this.client.GET("/v1/workspaces/{workspace_id}", {
366
+ params: { path: { workspace_id: id ?? this.workspaceId } }
367
+ })
368
+ );
225
369
  }
226
370
  /** Update workspace metadata */
227
- async update(id, body) {
228
- return this.request(`/${id}`, {
229
- method: "PUT",
230
- body: JSON.stringify(body)
231
- });
371
+ async update(body, id) {
372
+ return extractData(
373
+ await this.client.PATCH("/v1/workspaces/{workspace_id}", {
374
+ params: { path: { workspace_id: id ?? this.workspaceId } },
375
+ body
376
+ })
377
+ );
232
378
  }
233
379
  /** Archive (soft-delete) a workspace */
234
- async delete(id) {
235
- return this.request(`/${id}`, { method: "DELETE" });
380
+ async archive(body, id) {
381
+ return extractData(
382
+ await this.client.POST("/v1/workspaces/{workspace_id}/archive", {
383
+ params: { path: { workspace_id: id ?? this.workspaceId } },
384
+ body
385
+ })
386
+ );
236
387
  }
237
388
  };
238
389
 
@@ -243,80 +394,102 @@ var ApiKeysResource = class extends WorkspaceScopedResource {
243
394
  * Does not require a workspace ID in the path.
244
395
  */
245
396
  async me() {
246
- const url = `${this.config.baseUrl}/v1/auth/me`;
247
- const response = await globalThis.fetch(url, { headers: this.headers });
248
- if (!response.ok) throw await createApiError(response);
249
- return response.json();
397
+ return extractData(await this.client.GET("/v1/auth/me", {}));
250
398
  }
251
399
  /** Create a new API key */
252
400
  async create(body) {
253
- return this.fetch("/api-keys", {
254
- method: "POST",
255
- body: JSON.stringify(body)
256
- });
401
+ return extractData(
402
+ await this.client.POST("/v1/{workspace_id}/api-keys", {
403
+ params: { path: { workspace_id: this.workspaceId } },
404
+ body
405
+ })
406
+ );
257
407
  }
258
408
  /** List API keys in the workspace */
259
409
  async list(params) {
260
- return this.fetch(`/api-keys${buildQuery(params)}`);
261
- }
262
- /** Get a specific API key */
263
- async get(keyId) {
264
- return this.fetch(`/api-keys/${keyId}`);
410
+ return extractData(
411
+ await this.client.GET("/v1/{workspace_id}/api-keys", {
412
+ params: { path: { workspace_id: this.workspaceId }, query: params }
413
+ })
414
+ );
265
415
  }
266
416
  /** Revoke an API key */
267
417
  async revoke(keyId) {
268
- return this.fetch(`/api-keys/${keyId}`, { method: "DELETE" });
418
+ await this.client.DELETE("/v1/{workspace_id}/api-keys/{key_id}", {
419
+ params: { path: { workspace_id: this.workspaceId, key_id: keyId } }
420
+ });
269
421
  }
270
422
  /** Rotate an API key — invalidates the old key and issues a new one */
271
- async rotate(keyId) {
272
- return this.fetch(`/api-keys/${keyId}/rotate`, { method: "POST" });
423
+ async rotate(keyId, body) {
424
+ return extractData(
425
+ await this.client.POST("/v1/{workspace_id}/api-keys/{key_id}/rotate", {
426
+ params: { path: { workspace_id: this.workspaceId, key_id: keyId } },
427
+ body
428
+ })
429
+ );
273
430
  }
274
431
  };
275
432
 
276
433
  // src/resources/agents.ts
277
434
  var AgentsResource = class extends WorkspaceScopedResource {
278
- /** Create a new agent */
279
435
  async create(body) {
280
- return this.fetch("/agents", {
281
- method: "POST",
282
- body: JSON.stringify(body)
283
- });
436
+ return extractData(
437
+ await this.client.POST("/v1/{workspace_id}/agents", {
438
+ params: { path: { workspace_id: this.workspaceId } },
439
+ body
440
+ })
441
+ );
284
442
  }
285
- /** List agents in the workspace */
286
443
  async list(params) {
287
- return this.fetch(`/agents${buildQuery(params)}`);
444
+ return extractData(
445
+ await this.client.GET("/v1/{workspace_id}/agents", {
446
+ params: { path: { workspace_id: this.workspaceId }, query: params }
447
+ })
448
+ );
288
449
  }
289
- /** Get a single agent */
290
450
  async get(agentId2) {
291
- return this.fetch(`/agents/${agentId2}`);
451
+ return extractData(
452
+ await this.client.GET("/v1/{workspace_id}/agents/{agent_id}", {
453
+ params: { path: { workspace_id: this.workspaceId, agent_id: agentId2 } }
454
+ })
455
+ );
292
456
  }
293
- /** Update an agent's configuration */
294
457
  async update(agentId2, body) {
295
- return this.fetch(`/agents/${agentId2}`, {
296
- method: "PUT",
297
- body: JSON.stringify(body)
298
- });
458
+ return extractData(
459
+ await this.client.PUT("/v1/{workspace_id}/agents/{agent_id}", {
460
+ params: { path: { workspace_id: this.workspaceId, agent_id: agentId2 } },
461
+ body
462
+ })
463
+ );
299
464
  }
300
- /** Delete an agent */
301
465
  async delete(agentId2) {
302
- return this.fetch(`/agents/${agentId2}`, { method: "DELETE" });
466
+ await this.client.DELETE("/v1/{workspace_id}/agents/{agent_id}", {
467
+ params: { path: { workspace_id: this.workspaceId, agent_id: agentId2 } }
468
+ });
303
469
  }
304
- /** List all versions of an agent */
305
470
  async listVersions(agentId2, params) {
306
- return this.fetch(
307
- `/agents/${agentId2}/versions${buildQuery(params)}`
471
+ return extractData(
472
+ await this.client.GET("/v1/{workspace_id}/agents/{agent_id}/versions", {
473
+ params: { path: { workspace_id: this.workspaceId, agent_id: agentId2 }, query: params }
474
+ })
308
475
  );
309
476
  }
310
- /** Get a specific version of an agent — pass `"latest"` to get the most recent */
311
477
  async getVersion(agentId2, version) {
312
- return this.fetch(`/agents/${agentId2}/versions/${version}`);
478
+ return extractData(
479
+ await this.client.GET("/v1/{workspace_id}/agents/{agent_id}/versions/{version}", {
480
+ params: {
481
+ path: { workspace_id: this.workspaceId, agent_id: agentId2, version: String(version) }
482
+ }
483
+ })
484
+ );
313
485
  }
314
- /** Create a new version of an agent */
315
486
  async createVersion(agentId2, body) {
316
- return this.fetch(`/agents/${agentId2}/versions`, {
317
- method: "POST",
318
- body: JSON.stringify(body)
319
- });
487
+ return extractData(
488
+ await this.client.POST("/v1/{workspace_id}/agents/{agent_id}/versions", {
489
+ params: { path: { workspace_id: this.workspaceId, agent_id: agentId2 } },
490
+ body
491
+ })
492
+ );
320
493
  }
321
494
  };
322
495
 
@@ -324,254 +497,652 @@ var AgentsResource = class extends WorkspaceScopedResource {
324
497
  var SkillsResource = class extends WorkspaceScopedResource {
325
498
  /** Create a new skill */
326
499
  async create(body) {
327
- return this.fetch("/skills", {
328
- method: "POST",
329
- body: JSON.stringify(body)
330
- });
500
+ return extractData(
501
+ await this.client.POST("/v1/{workspace_id}/skills", {
502
+ params: { path: { workspace_id: this.workspaceId } },
503
+ body
504
+ })
505
+ );
331
506
  }
332
507
  /** List skills in the workspace */
333
508
  async list(params) {
334
- return this.fetch(`/skills${buildQuery(params)}`);
509
+ return extractData(
510
+ await this.client.GET("/v1/{workspace_id}/skills", {
511
+ params: { path: { workspace_id: this.workspaceId }, query: params }
512
+ })
513
+ );
335
514
  }
336
515
  /** Get a single skill */
337
516
  async get(skillId2) {
338
- return this.fetch(`/skills/${skillId2}`);
517
+ return extractData(
518
+ await this.client.GET("/v1/{workspace_id}/skills/{skill_id}", {
519
+ params: { path: { workspace_id: this.workspaceId, skill_id: skillId2 } }
520
+ })
521
+ );
339
522
  }
340
523
  /** Update a skill */
341
524
  async update(skillId2, body) {
342
- return this.fetch(`/skills/${skillId2}`, {
343
- method: "PUT",
344
- body: JSON.stringify(body)
345
- });
525
+ return extractData(
526
+ await this.client.PUT("/v1/{workspace_id}/skills/{skill_id}", {
527
+ params: { path: { workspace_id: this.workspaceId, skill_id: skillId2 } },
528
+ body
529
+ })
530
+ );
346
531
  }
347
532
  /** Delete a skill */
348
533
  async delete(skillId2) {
349
- return this.fetch(`/skills/${skillId2}`, { method: "DELETE" });
534
+ await this.client.DELETE("/v1/{workspace_id}/skills/{skill_id}", {
535
+ params: { path: { workspace_id: this.workspaceId, skill_id: skillId2 } }
536
+ });
350
537
  }
351
538
  /**
352
539
  * Test a skill with a sample input.
353
540
  * Executes the skill in a sandbox and returns the result.
354
541
  */
355
542
  async test(skillId2, body) {
356
- return this.fetch(`/skills/${skillId2}/test`, {
357
- method: "POST",
358
- body: JSON.stringify(body)
543
+ return extractData(
544
+ await this.client.POST("/v1/{workspace_id}/skills/{skill_id}/test", {
545
+ params: { path: { workspace_id: this.workspaceId, skill_id: skillId2 } },
546
+ body
547
+ })
548
+ );
549
+ }
550
+ };
551
+
552
+ // src/resources/actions.ts
553
+ var ActionsResource = class extends WorkspaceScopedResource {
554
+ /** Create a new action */
555
+ async create(body) {
556
+ return extractData(
557
+ await this.client.POST("/v1/{workspace_id}/skills", {
558
+ params: { path: { workspace_id: this.workspaceId } },
559
+ body
560
+ })
561
+ );
562
+ }
563
+ /** List actions in the workspace */
564
+ async list(params) {
565
+ return extractData(
566
+ await this.client.GET("/v1/{workspace_id}/skills", {
567
+ params: { path: { workspace_id: this.workspaceId }, query: params }
568
+ })
569
+ );
570
+ }
571
+ /** Get a single action */
572
+ async get(actionId2) {
573
+ return extractData(
574
+ await this.client.GET("/v1/{workspace_id}/skills/{skill_id}", {
575
+ params: { path: { workspace_id: this.workspaceId, skill_id: actionId2 } }
576
+ })
577
+ );
578
+ }
579
+ /** Update an action */
580
+ async update(actionId2, body) {
581
+ return extractData(
582
+ await this.client.PUT("/v1/{workspace_id}/skills/{skill_id}", {
583
+ params: { path: { workspace_id: this.workspaceId, skill_id: actionId2 } },
584
+ body
585
+ })
586
+ );
587
+ }
588
+ /** Delete an action */
589
+ async delete(actionId2) {
590
+ await this.client.DELETE("/v1/{workspace_id}/skills/{skill_id}", {
591
+ params: { path: { workspace_id: this.workspaceId, skill_id: actionId2 } }
359
592
  });
360
593
  }
594
+ /**
595
+ * Test an action with a sample input.
596
+ * Executes the action in a sandbox and returns the result.
597
+ */
598
+ async test(actionId2, body) {
599
+ return extractData(
600
+ await this.client.POST("/v1/{workspace_id}/skills/{skill_id}/test", {
601
+ params: { path: { workspace_id: this.workspaceId, skill_id: actionId2 } },
602
+ body
603
+ })
604
+ );
605
+ }
606
+ };
607
+
608
+ // src/resources/operators.ts
609
+ var OperatorsResource = class extends WorkspaceScopedResource {
610
+ async list(params) {
611
+ return extractData(
612
+ await this.client.GET("/v1/{workspace_id}/operators", {
613
+ params: { path: { workspace_id: this.workspaceId }, query: params }
614
+ })
615
+ );
616
+ }
617
+ async create(body) {
618
+ return extractData(
619
+ await this.client.POST("/v1/{workspace_id}/operators", {
620
+ params: { path: { workspace_id: this.workspaceId } },
621
+ body
622
+ })
623
+ );
624
+ }
625
+ async get(operatorId) {
626
+ return extractData(
627
+ await this.client.GET("/v1/{workspace_id}/operators/{operator_id}", {
628
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } }
629
+ })
630
+ );
631
+ }
632
+ async getDashboard() {
633
+ return extractData(
634
+ await this.client.GET("/v1/{workspace_id}/operators/dashboard", {
635
+ params: { path: { workspace_id: this.workspaceId } }
636
+ })
637
+ );
638
+ }
639
+ async getQueue() {
640
+ return extractData(
641
+ await this.client.GET("/v1/{workspace_id}/operators/queue", {
642
+ params: { path: { workspace_id: this.workspaceId } }
643
+ })
644
+ );
645
+ }
646
+ async getEscalations(params) {
647
+ return extractData(
648
+ await this.client.GET("/v1/{workspace_id}/operators/escalations", {
649
+ params: { path: { workspace_id: this.workspaceId }, query: params }
650
+ })
651
+ );
652
+ }
653
+ async getActiveEscalations() {
654
+ return extractData(
655
+ await this.client.GET("/v1/{workspace_id}/operators/escalations/active", {
656
+ params: { path: { workspace_id: this.workspaceId } }
657
+ })
658
+ );
659
+ }
660
+ async getEscalationStats(params) {
661
+ return extractData(
662
+ await this.client.GET("/v1/{workspace_id}/operators/escalations/stats", {
663
+ params: { path: { workspace_id: this.workspaceId }, query: params }
664
+ })
665
+ );
666
+ }
667
+ async getPerformance(params) {
668
+ return extractData(
669
+ await this.client.GET("/v1/{workspace_id}/operators/performance", {
670
+ params: { path: { workspace_id: this.workspaceId }, query: params }
671
+ })
672
+ );
673
+ }
674
+ async getAccessToken(operatorId, body) {
675
+ return extractData(
676
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/access-token", {
677
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
678
+ body
679
+ })
680
+ );
681
+ }
682
+ async joinCall(operatorId, body) {
683
+ return extractData(
684
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/join-call", {
685
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
686
+ body
687
+ })
688
+ );
689
+ }
690
+ async leaveCall(operatorId, body) {
691
+ return extractData(
692
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/leave-call", {
693
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
694
+ body
695
+ })
696
+ );
697
+ }
698
+ async switchMode(operatorId, body) {
699
+ return extractData(
700
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/switch-mode", {
701
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
702
+ body
703
+ })
704
+ );
705
+ }
706
+ async sendGuidance(operatorId, body) {
707
+ return extractData(
708
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/send-guidance", {
709
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
710
+ body
711
+ })
712
+ );
713
+ }
714
+ async createBriefing(operatorId, body) {
715
+ return extractData(
716
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/briefing", {
717
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
718
+ body
719
+ })
720
+ );
721
+ }
722
+ async wrapUp(operatorId, body) {
723
+ return extractData(
724
+ await this.client.POST("/v1/{workspace_id}/operators/{operator_id}/wrap-up", {
725
+ params: { path: { workspace_id: this.workspaceId, operator_id: operatorId } },
726
+ body
727
+ })
728
+ );
729
+ }
730
+ async getCallTranscript(callSid) {
731
+ return extractData(
732
+ await this.client.GET("/v1/{workspace_id}/operators/calls/{call_sid}/transcript", {
733
+ params: { path: { workspace_id: this.workspaceId, call_sid: callSid } }
734
+ })
735
+ );
736
+ }
737
+ async getAuditLog(params) {
738
+ return extractData(
739
+ await this.client.GET("/v1/{workspace_id}/operators/audit-log", {
740
+ params: { path: { workspace_id: this.workspaceId }, query: params }
741
+ })
742
+ );
743
+ }
744
+ };
745
+
746
+ // src/resources/triggers.ts
747
+ var TriggersResource = class extends WorkspaceScopedResource {
748
+ async list(params) {
749
+ return extractData(
750
+ await this.client.GET("/v1/{workspace_id}/triggers", {
751
+ params: { path: { workspace_id: this.workspaceId }, query: params }
752
+ })
753
+ );
754
+ }
755
+ async create(body) {
756
+ return extractData(
757
+ await this.client.POST("/v1/{workspace_id}/triggers", {
758
+ params: { path: { workspace_id: this.workspaceId } },
759
+ body
760
+ })
761
+ );
762
+ }
763
+ async get(triggerId) {
764
+ return extractData(
765
+ await this.client.GET("/v1/{workspace_id}/triggers/{trigger_id}", {
766
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } }
767
+ })
768
+ );
769
+ }
770
+ async update(triggerId, body) {
771
+ return extractData(
772
+ await this.client.PUT("/v1/{workspace_id}/triggers/{trigger_id}", {
773
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
774
+ body
775
+ })
776
+ );
777
+ }
778
+ async delete(triggerId) {
779
+ await this.client.DELETE("/v1/{workspace_id}/triggers/{trigger_id}", {
780
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } }
781
+ });
782
+ }
783
+ async fire(triggerId) {
784
+ return extractData(
785
+ await this.client.POST("/v1/{workspace_id}/triggers/{trigger_id}/fire", {
786
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } }
787
+ })
788
+ );
789
+ }
790
+ async pause(triggerId) {
791
+ return extractData(
792
+ await this.client.POST("/v1/{workspace_id}/triggers/{trigger_id}/pause", {
793
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } }
794
+ })
795
+ );
796
+ }
797
+ async resume(triggerId) {
798
+ return extractData(
799
+ await this.client.POST("/v1/{workspace_id}/triggers/{trigger_id}/resume", {
800
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } }
801
+ })
802
+ );
803
+ }
804
+ async listRuns(triggerId, params) {
805
+ return extractData(
806
+ await this.client.GET("/v1/{workspace_id}/triggers/{trigger_id}/runs", {
807
+ params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId }, query: params }
808
+ })
809
+ );
810
+ }
361
811
  };
362
812
 
363
813
  // src/resources/services.ts
364
814
  var ServicesResource = class extends WorkspaceScopedResource {
365
815
  async create(body) {
366
- return this.fetch("/services", {
367
- method: "POST",
368
- body: JSON.stringify(body)
369
- });
816
+ return extractData(
817
+ await this.client.POST("/v1/{workspace_id}/services", {
818
+ params: { path: { workspace_id: this.workspaceId } },
819
+ body
820
+ })
821
+ );
370
822
  }
371
823
  async list(params) {
372
- return this.fetch(`/services${buildQuery(params)}`);
824
+ return extractData(
825
+ await this.client.GET("/v1/{workspace_id}/services", {
826
+ params: { path: { workspace_id: this.workspaceId }, query: params }
827
+ })
828
+ );
373
829
  }
374
830
  async get(serviceId2) {
375
- return this.fetch(`/services/${serviceId2}`);
831
+ return extractData(
832
+ await this.client.GET("/v1/{workspace_id}/services/{service_id}", {
833
+ params: { path: { workspace_id: this.workspaceId, service_id: serviceId2 } }
834
+ })
835
+ );
376
836
  }
377
837
  async update(serviceId2, body) {
378
- return this.fetch(`/services/${serviceId2}`, {
379
- method: "PUT",
380
- body: JSON.stringify(body)
381
- });
838
+ return extractData(
839
+ await this.client.PUT("/v1/{workspace_id}/services/{service_id}", {
840
+ params: { path: { workspace_id: this.workspaceId, service_id: serviceId2 } },
841
+ body
842
+ })
843
+ );
382
844
  }
383
845
  async delete(serviceId2) {
384
- return this.fetch(`/services/${serviceId2}`, { method: "DELETE" });
846
+ await this.client.DELETE("/v1/{workspace_id}/services/{service_id}", {
847
+ params: { path: { workspace_id: this.workspaceId, service_id: serviceId2 } }
848
+ });
385
849
  }
386
850
  };
387
851
 
388
852
  // src/resources/context-graphs.ts
389
853
  var ContextGraphsResource = class extends WorkspaceScopedResource {
390
854
  async create(body) {
391
- return this.fetch("/context-graphs", {
392
- method: "POST",
393
- body: JSON.stringify(body)
394
- });
855
+ return extractData(
856
+ await this.client.POST("/v1/{workspace_id}/context-graphs", {
857
+ params: { path: { workspace_id: this.workspaceId } },
858
+ body
859
+ })
860
+ );
395
861
  }
396
862
  async list(params) {
397
- return this.fetch(`/context-graphs${buildQuery(params)}`);
863
+ return extractData(
864
+ await this.client.GET("/v1/{workspace_id}/context-graphs", {
865
+ params: { path: { workspace_id: this.workspaceId }, query: params }
866
+ })
867
+ );
398
868
  }
399
869
  async get(contextGraphId2) {
400
- return this.fetch(`/context-graphs/${contextGraphId2}`);
870
+ return extractData(
871
+ await this.client.GET("/v1/{workspace_id}/context-graphs/{context_graph_id}", {
872
+ params: {
873
+ path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId2 }
874
+ }
875
+ })
876
+ );
401
877
  }
402
878
  async update(contextGraphId2, body) {
403
- return this.fetch(`/context-graphs/${contextGraphId2}`, {
404
- method: "PUT",
405
- body: JSON.stringify(body)
406
- });
879
+ return extractData(
880
+ await this.client.PUT("/v1/{workspace_id}/context-graphs/{context_graph_id}", {
881
+ params: {
882
+ path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId2 }
883
+ },
884
+ body
885
+ })
886
+ );
407
887
  }
408
888
  async delete(contextGraphId2) {
409
- return this.fetch(`/context-graphs/${contextGraphId2}`, { method: "DELETE" });
889
+ await this.client.DELETE("/v1/{workspace_id}/context-graphs/{context_graph_id}", {
890
+ params: {
891
+ path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId2 }
892
+ }
893
+ });
410
894
  }
411
895
  /** Create a version snapshot of the current context graph */
412
- async createVersion(contextGraphId2) {
413
- return this.fetch(`/context-graphs/${contextGraphId2}/versions`, {
414
- method: "POST"
415
- });
896
+ async createVersion(contextGraphId2, body) {
897
+ return extractData(
898
+ await this.client.POST("/v1/{workspace_id}/context-graphs/{context_graph_id}/versions", {
899
+ params: {
900
+ path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId2 }
901
+ },
902
+ body
903
+ })
904
+ );
416
905
  }
417
906
  /** List all versions of a context graph */
418
907
  async listVersions(contextGraphId2, params) {
419
- return this.fetch(
420
- `/context-graphs/${contextGraphId2}/versions${buildQuery(params)}`
908
+ return extractData(
909
+ await this.client.GET("/v1/{workspace_id}/context-graphs/{context_graph_id}/versions", {
910
+ params: {
911
+ path: { workspace_id: this.workspaceId, context_graph_id: contextGraphId2 },
912
+ query: params
913
+ }
914
+ })
421
915
  );
422
916
  }
423
917
  /** Get a specific version */
424
918
  async getVersion(contextGraphId2, version) {
425
- return this.fetch(`/context-graphs/${contextGraphId2}/versions/${version}`);
919
+ return extractData(
920
+ await this.client.GET(
921
+ "/v1/{workspace_id}/context-graphs/{context_graph_id}/versions/{version}",
922
+ {
923
+ params: {
924
+ path: {
925
+ workspace_id: this.workspaceId,
926
+ context_graph_id: contextGraphId2,
927
+ version
928
+ }
929
+ }
930
+ }
931
+ )
932
+ );
426
933
  }
427
934
  };
428
935
 
429
936
  // src/resources/data-sources.ts
430
937
  var DataSourcesResource = class extends WorkspaceScopedResource {
431
938
  async create(body) {
432
- return this.fetch("/data-sources", {
433
- method: "POST",
434
- body: JSON.stringify(body)
435
- });
939
+ return extractData(
940
+ await this.client.POST("/v1/{workspace_id}/data-sources", {
941
+ params: { path: { workspace_id: this.workspaceId } },
942
+ body
943
+ })
944
+ );
436
945
  }
437
946
  async list(params) {
438
- return this.fetch(`/data-sources${buildQuery(params)}`);
947
+ return extractData(
948
+ await this.client.GET("/v1/{workspace_id}/data-sources", {
949
+ params: { path: { workspace_id: this.workspaceId }, query: params }
950
+ })
951
+ );
439
952
  }
440
953
  async get(dataSourceId2) {
441
- return this.fetch(`/data-sources/${dataSourceId2}`);
954
+ return extractData(
955
+ await this.client.GET("/v1/{workspace_id}/data-sources/{data_source_id}", {
956
+ params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId2 } }
957
+ })
958
+ );
442
959
  }
443
960
  async update(dataSourceId2, body) {
444
- return this.fetch(`/data-sources/${dataSourceId2}`, {
445
- method: "PUT",
446
- body: JSON.stringify(body)
447
- });
961
+ return extractData(
962
+ await this.client.PATCH("/v1/{workspace_id}/data-sources/{data_source_id}", {
963
+ params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId2 } },
964
+ body
965
+ })
966
+ );
448
967
  }
449
968
  async delete(dataSourceId2) {
450
- return this.fetch(`/data-sources/${dataSourceId2}`, { method: "DELETE" });
969
+ await this.client.DELETE("/v1/{workspace_id}/data-sources/{data_source_id}", {
970
+ params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId2 } }
971
+ });
972
+ }
973
+ /** Get event counts, sync status, and health for a data source */
974
+ async getStatus(dataSourceId2) {
975
+ return extractData(
976
+ await this.client.GET("/v1/{workspace_id}/data-sources/{data_source_id}/status", {
977
+ params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId2 } }
978
+ })
979
+ );
980
+ }
981
+ /** Get daily event timeline + recent sync failures for a data source */
982
+ async getSyncHistory(dataSourceId2) {
983
+ return extractData(
984
+ await this.client.GET("/v1/{workspace_id}/data-sources/{data_source_id}/sync-history", {
985
+ params: { path: { workspace_id: this.workspaceId, data_source_id: dataSourceId2 } }
986
+ })
987
+ );
451
988
  }
452
989
  };
453
990
 
454
991
  // src/resources/world.ts
455
992
  var WorldResource = class extends WorkspaceScopedResource {
456
993
  // ---- Entities ----
457
- /** Create a new entity */
458
- async createEntity(body) {
459
- return this.fetch("/world/entities", {
460
- method: "POST",
461
- body: JSON.stringify(body)
462
- });
463
- }
464
994
  /** List entities with optional filtering */
465
995
  async listEntities(params) {
466
- return this.fetch(`/world/entities${buildQuery(params)}`);
996
+ return extractData(
997
+ await this.client.GET("/v1/{workspace_id}/world/entities", {
998
+ params: { path: { workspace_id: this.workspaceId }, query: params }
999
+ })
1000
+ );
467
1001
  }
468
1002
  /** Get a single entity */
469
1003
  async getEntity(entityId2) {
470
- return this.fetch(`/world/entities/${entityId2}`);
471
- }
472
- /** Update entity properties */
473
- async updateEntity(entityId2, body) {
474
- return this.fetch(`/world/entities/${entityId2}`, {
475
- method: "PUT",
476
- body: JSON.stringify(body)
477
- });
1004
+ return extractData(
1005
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}", {
1006
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1007
+ })
1008
+ );
478
1009
  }
479
1010
  /** Get all relationships for an entity */
480
1011
  async getRelationships(entityId2) {
481
- return this.fetch(`/world/entities/${entityId2}/relationships`);
1012
+ return extractData(
1013
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}/relationships", {
1014
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1015
+ })
1016
+ );
482
1017
  }
483
1018
  /** Get the knowledge graph centered on an entity (entity + neighbors + edges) */
484
1019
  async getGraph(entityId2) {
485
- return this.fetch(`/world/entities/${entityId2}/graph`);
1020
+ return extractData(
1021
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}/graph", {
1022
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1023
+ })
1024
+ );
486
1025
  }
487
1026
  /** Get provenance — which source systems contributed data for an entity */
488
1027
  async getProvenance(entityId2) {
489
- return this.fetch(`/world/entities/${entityId2}/provenance`);
1028
+ return extractData(
1029
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}/provenance", {
1030
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1031
+ })
1032
+ );
490
1033
  }
491
1034
  /** Get lineage — merge history and canonical identity for an entity */
492
1035
  async getLineage(entityId2) {
493
- return this.fetch(`/world/entities/${entityId2}/lineage`);
1036
+ return extractData(
1037
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}/lineage", {
1038
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1039
+ })
1040
+ );
494
1041
  }
495
1042
  /** Get merged entities for a canonical entity */
496
1043
  async getMerged(entityId2) {
497
- return this.fetch(`/world/entities/${entityId2}/merged`);
1044
+ return extractData(
1045
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}/merged", {
1046
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1047
+ })
1048
+ );
498
1049
  }
499
1050
  // ---- Entity Types ----
500
1051
  /** List registered entity types with counts and schemas */
501
1052
  async listEntityTypes() {
502
- return this.fetch("/world/entity-types");
1053
+ return extractData(
1054
+ await this.client.GET("/v1/{workspace_id}/world/entity-types", {
1055
+ params: { path: { workspace_id: this.workspaceId } }
1056
+ })
1057
+ );
503
1058
  }
504
1059
  // ---- Duplicate Detection ----
505
1060
  /** List potential duplicate entity pairs for review or merging */
506
1061
  async listDuplicates(params) {
507
- return this.fetch(`/world/entities/duplicates${buildQuery(params)}`);
1062
+ return extractData(
1063
+ await this.client.GET("/v1/{workspace_id}/world/entities/duplicates", {
1064
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1065
+ })
1066
+ );
508
1067
  }
509
1068
  // ---- Semantic Search ----
510
1069
  /** Semantic (vector) search over entities */
511
1070
  async search(params) {
512
- return this.fetch(`/world/search${buildQuery(params)}`);
513
- }
514
- // ---- Events ----
515
- /**
516
- * Emit an event for an entity.
517
- * Events flow to Delta via ZeroBus for downstream analytics.
518
- */
519
- async emitEvent(body) {
520
- return this.fetch("/world/events", {
521
- method: "POST",
522
- body: JSON.stringify(body)
523
- });
1071
+ return extractData(
1072
+ await this.client.GET("/v1/{workspace_id}/world/search", {
1073
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1074
+ })
1075
+ );
524
1076
  }
525
1077
  // ---- Timeline ----
526
1078
  /** Get the event timeline for an entity (reverse-chronological) */
527
1079
  async getTimeline(entityId2, params) {
528
- return this.fetch(`/world/timeline/${entityId2}${buildQuery(params)}`);
529
- }
530
- // ---- Intelligence ----
531
- /** Get AI-derived intelligence for an entity */
532
- async getIntelligence(entityId2) {
533
- return this.fetch(`/world/intelligence/${entityId2}`);
534
- }
535
- /** Find entities similar to a given entity using vector similarity */
536
- async getSimilar(entityId2, limit) {
537
- return this.fetch(`/world/similar/${entityId2}${buildQuery({ limit })}`);
538
- }
539
- /** Merge multiple entities into one canonical entity */
540
- async merge(body) {
541
- return this.fetch("/world/merge", {
542
- method: "POST",
543
- body: JSON.stringify(body)
544
- });
1080
+ return extractData(
1081
+ await this.client.GET("/v1/{workspace_id}/world/entities/{entity_id}/timeline", {
1082
+ params: {
1083
+ path: { workspace_id: this.workspaceId, entity_id: entityId2 },
1084
+ query: params
1085
+ }
1086
+ })
1087
+ );
545
1088
  }
546
1089
  // ---- Sync ----
547
1090
  /** Get sync status grouped by sink (Lakebase, Delta, etc.) */
548
1091
  async getSyncStatusBySink() {
549
- return this.fetch("/world/sync/by-sink");
1092
+ return extractData(
1093
+ await this.client.GET("/v1/{workspace_id}/world/sync/by-sink", {
1094
+ params: { path: { workspace_id: this.workspaceId } }
1095
+ })
1096
+ );
550
1097
  }
551
1098
  /** List sync events with status filtering */
552
1099
  async listSyncEvents(params) {
553
- return this.fetch(`/world/sync/events${buildQuery(params)}`);
1100
+ return extractData(
1101
+ await this.client.GET("/v1/{workspace_id}/world/sync/events", {
1102
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1103
+ })
1104
+ );
554
1105
  }
555
1106
  /** Get current sync queue depth */
556
1107
  async getSyncQueueDepth() {
557
- return this.fetch("/world/sync/queue");
1108
+ return extractData(
1109
+ await this.client.GET("/v1/{workspace_id}/world/sync/queue", {
1110
+ params: { path: { workspace_id: this.workspaceId } }
1111
+ })
1112
+ );
558
1113
  }
559
1114
  /** Retry a single failed sync event */
560
1115
  async retrySyncEvent(eventId2) {
561
- return this.fetch(`/world/sync/retry/${eventId2}`, { method: "POST" });
1116
+ return extractData(
1117
+ await this.client.POST("/v1/{workspace_id}/world/sync/retry/{event_id}", {
1118
+ params: { path: { workspace_id: this.workspaceId, event_id: eventId2 } }
1119
+ })
1120
+ );
562
1121
  }
563
1122
  /** Retry all failed sync events */
564
1123
  async retryAllSyncEvents() {
565
- return this.fetch("/world/sync/retry-all", { method: "POST" });
1124
+ return extractData(
1125
+ await this.client.POST("/v1/{workspace_id}/world/sync/retry-all", {
1126
+ params: { path: { workspace_id: this.workspaceId } }
1127
+ })
1128
+ );
566
1129
  }
567
1130
  // ---- Statistics ----
568
1131
  /** Get aggregate entity and event statistics */
569
1132
  async getStats() {
570
- return this.fetch("/world/entity-stats");
1133
+ return extractData(
1134
+ await this.client.GET("/v1/{workspace_id}/world/entity-stats", {
1135
+ params: { path: { workspace_id: this.workspaceId } }
1136
+ })
1137
+ );
571
1138
  }
572
1139
  /** Get entity counts broken down by source system */
573
1140
  async getSourceBreakdown() {
574
- return this.fetch("/world/source-breakdown");
1141
+ return extractData(
1142
+ await this.client.GET("/v1/{workspace_id}/world/source-breakdown", {
1143
+ params: { path: { workspace_id: this.workspaceId } }
1144
+ })
1145
+ );
575
1146
  }
576
1147
  };
577
1148
 
@@ -579,104 +1150,183 @@ var WorldResource = class extends WorkspaceScopedResource {
579
1150
  var CallsResource = class extends WorkspaceScopedResource {
580
1151
  /** List calls with optional filtering */
581
1152
  async list(params) {
582
- return this.fetch(`/calls/${buildQuery(params)}`);
1153
+ return extractData(
1154
+ await this.client.GET("/v1/{workspace_id}/calls", {
1155
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1156
+ })
1157
+ );
583
1158
  }
584
- /** Get full call detail including transcript and intelligence */
585
- async get(callSid) {
586
- return this.fetch(`/calls/${callSid}`);
1159
+ /** Get full call detail including turns, escalation, safety, and recording info */
1160
+ async get(callId2) {
1161
+ return extractData(
1162
+ await this.client.GET("/v1/{workspace_id}/calls/{call_id}", {
1163
+ params: { path: { workspace_id: this.workspaceId, call_id: callId2 } }
1164
+ })
1165
+ );
587
1166
  }
588
1167
  /** Get AI intelligence for a call */
589
- async getIntelligence(callSid) {
590
- return this.fetch(`/calls/${callSid}/intelligence`);
1168
+ async getIntelligence(callId2) {
1169
+ return extractData(
1170
+ await this.client.GET("/v1/{workspace_id}/calls/{call_id}/intelligence", {
1171
+ params: { path: { workspace_id: this.workspaceId, call_id: callId2 } }
1172
+ })
1173
+ );
591
1174
  }
592
1175
  /** Get active intelligence across all in-progress calls */
593
1176
  async getActiveIntelligence() {
594
- return this.fetch("/calls/active/intelligence");
1177
+ return extractData(
1178
+ await this.client.GET("/v1/{workspace_id}/calls/active/intelligence", {
1179
+ params: { path: { workspace_id: this.workspaceId } }
1180
+ })
1181
+ );
595
1182
  }
596
1183
  /** Get performance benchmarks for a time period */
597
1184
  async getBenchmarks(params) {
598
- return this.fetch(`/calls/benchmarks${buildQuery(params)}`);
1185
+ return extractData(
1186
+ await this.client.GET("/v1/{workspace_id}/calls/benchmarks", {
1187
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1188
+ })
1189
+ );
1190
+ }
1191
+ /** Get deep call trace analysis */
1192
+ async getTraceAnalysis(callId2) {
1193
+ return extractData(
1194
+ await this.client.GET("/v1/{workspace_id}/calls/{call_id}/trace-analysis", {
1195
+ params: { path: { workspace_id: this.workspaceId, call_id: callId2 } }
1196
+ })
1197
+ );
599
1198
  }
600
1199
  };
601
1200
 
602
1201
  // src/resources/phone-numbers.ts
603
1202
  var PhoneNumbersResource = class extends WorkspaceScopedResource {
604
- /** Provision a new phone number (area code or specific number) */
1203
+ /** Create a new phone number */
605
1204
  async provision(body) {
606
- return this.fetch("/phone-numbers", {
607
- method: "POST",
608
- body: JSON.stringify(body)
609
- });
1205
+ return extractData(
1206
+ await this.client.POST("/v1/{workspace_id}/phone-numbers", {
1207
+ params: { path: { workspace_id: this.workspaceId } },
1208
+ body
1209
+ })
1210
+ );
610
1211
  }
611
1212
  /** List phone numbers in the workspace */
612
1213
  async list(params) {
613
- return this.fetch(`/phone-numbers${buildQuery(params)}`);
1214
+ return extractData(
1215
+ await this.client.GET("/v1/{workspace_id}/phone-numbers", {
1216
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1217
+ })
1218
+ );
614
1219
  }
615
1220
  /** Get a phone number */
616
1221
  async get(phoneNumberId2) {
617
- return this.fetch(`/phone-numbers/${phoneNumberId2}`);
1222
+ return extractData(
1223
+ await this.client.GET("/v1/{workspace_id}/phone-numbers/{phone_number_id}", {
1224
+ params: { path: { workspace_id: this.workspaceId, phone_number_id: phoneNumberId2 } }
1225
+ })
1226
+ );
618
1227
  }
619
1228
  /** Update a phone number (assign to agent, rename) */
620
1229
  async update(phoneNumberId2, body) {
621
- return this.fetch(`/phone-numbers/${phoneNumberId2}`, {
622
- method: "PUT",
623
- body: JSON.stringify(body)
624
- });
1230
+ return extractData(
1231
+ await this.client.PUT("/v1/{workspace_id}/phone-numbers/{phone_number_id}", {
1232
+ params: { path: { workspace_id: this.workspaceId, phone_number_id: phoneNumberId2 } },
1233
+ body
1234
+ })
1235
+ );
625
1236
  }
626
1237
  /** Release a phone number back to the carrier */
627
1238
  async release(phoneNumberId2) {
628
- return this.fetch(`/phone-numbers/${phoneNumberId2}`, { method: "DELETE" });
1239
+ await this.client.DELETE("/v1/{workspace_id}/phone-numbers/{phone_number_id}", {
1240
+ params: { path: { workspace_id: this.workspaceId, phone_number_id: phoneNumberId2 } }
1241
+ });
629
1242
  }
630
- /** Send a test call to a phone number to verify it's working */
631
- async test(phoneNumberId2) {
632
- return this.fetch(
633
- `/phone-numbers/${phoneNumberId2}/test`,
634
- { method: "POST" }
1243
+ /** Set call forwarding for a phone number */
1244
+ async setForwarding(phoneNumberId2, body) {
1245
+ return extractData(
1246
+ await this.client.PUT("/v1/{workspace_id}/phone-numbers/{phone_number_id}/forwarding", {
1247
+ params: { path: { workspace_id: this.workspaceId, phone_number_id: phoneNumberId2 } },
1248
+ body
1249
+ })
635
1250
  );
636
1251
  }
1252
+ /** Clear call forwarding for a phone number */
1253
+ async clearForwarding(phoneNumberId2) {
1254
+ await this.client.DELETE("/v1/{workspace_id}/phone-numbers/{phone_number_id}/forwarding", {
1255
+ params: { path: { workspace_id: this.workspaceId, phone_number_id: phoneNumberId2 } }
1256
+ });
1257
+ }
637
1258
  };
638
1259
 
639
1260
  // src/resources/integrations.ts
640
1261
  var IntegrationsResource = class extends WorkspaceScopedResource {
641
1262
  /** Create a new integration */
642
1263
  async create(body) {
643
- return this.fetch("/integrations", {
644
- method: "POST",
645
- body: JSON.stringify(body)
646
- });
1264
+ return extractData(
1265
+ await this.client.POST("/v1/{workspace_id}/integrations", {
1266
+ params: { path: { workspace_id: this.workspaceId } },
1267
+ body
1268
+ })
1269
+ );
647
1270
  }
648
1271
  /** List integrations */
649
1272
  async list(params) {
650
- return this.fetch(`/integrations${buildQuery(params)}`);
1273
+ return extractData(
1274
+ await this.client.GET("/v1/{workspace_id}/integrations", {
1275
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1276
+ })
1277
+ );
651
1278
  }
652
1279
  /** Get a single integration */
653
1280
  async get(integrationId2) {
654
- return this.fetch(`/integrations/${integrationId2}`);
1281
+ return extractData(
1282
+ await this.client.GET("/v1/{workspace_id}/integrations/{integration_id}", {
1283
+ params: { path: { workspace_id: this.workspaceId, integration_id: integrationId2 } }
1284
+ })
1285
+ );
655
1286
  }
656
1287
  /** Update integration configuration */
657
1288
  async update(integrationId2, body) {
658
- return this.fetch(`/integrations/${integrationId2}`, {
659
- method: "PUT",
660
- body: JSON.stringify(body)
661
- });
1289
+ return extractData(
1290
+ await this.client.PUT("/v1/{workspace_id}/integrations/{integration_id}", {
1291
+ params: { path: { workspace_id: this.workspaceId, integration_id: integrationId2 } },
1292
+ body
1293
+ })
1294
+ );
662
1295
  }
663
1296
  /** Delete an integration */
664
1297
  async delete(integrationId2) {
665
- return this.fetch(`/integrations/${integrationId2}`, { method: "DELETE" });
1298
+ await this.client.DELETE("/v1/{workspace_id}/integrations/{integration_id}", {
1299
+ params: { path: { workspace_id: this.workspaceId, integration_id: integrationId2 } }
1300
+ });
666
1301
  }
667
1302
  /**
668
1303
  * Test a specific endpoint on an integration with given params.
669
1304
  * Used in the developer console to validate integration config.
670
1305
  */
671
- async testEndpoint(integrationId2, endpointName, params) {
672
- return this.fetch(
673
- `/integrations/${integrationId2}/endpoints/${endpointName}/test`,
674
- { method: "POST", body: JSON.stringify({ params }) }
1306
+ async testEndpoint(integrationId2, endpointName, body) {
1307
+ return extractData(
1308
+ await this.client.POST(
1309
+ "/v1/{workspace_id}/integrations/{integration_id}/endpoints/{endpoint_name}/test",
1310
+ {
1311
+ params: {
1312
+ path: {
1313
+ workspace_id: this.workspaceId,
1314
+ integration_id: integrationId2,
1315
+ endpoint_name: endpointName
1316
+ }
1317
+ },
1318
+ body
1319
+ }
1320
+ )
675
1321
  );
676
1322
  }
677
1323
  /** Check health of all integrations in the workspace */
678
1324
  async getHealthCheck() {
679
- return this.fetch("/integrations/health-check");
1325
+ return extractData(
1326
+ await this.client.GET("/v1/{workspace_id}/integrations/health-check", {
1327
+ params: { path: { workspace_id: this.workspaceId } }
1328
+ })
1329
+ );
680
1330
  }
681
1331
  };
682
1332
 
@@ -684,47 +1334,91 @@ var IntegrationsResource = class extends WorkspaceScopedResource {
684
1334
  var AnalyticsResource = class extends WorkspaceScopedResource {
685
1335
  /** High-level dashboard summary — pass `days` (default: 7) for the lookback window */
686
1336
  async getDashboard(params) {
687
- return this.fetch(`/analytics/dashboard${buildQuery(params)}`);
1337
+ return extractData(
1338
+ await this.client.GET("/v1/{workspace_id}/analytics/dashboard", {
1339
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1340
+ })
1341
+ );
688
1342
  }
689
1343
  /** Call volume and duration metrics */
690
1344
  async getCalls(params) {
691
- return this.fetch(`/analytics/calls${buildQuery(params)}`);
1345
+ return extractData(
1346
+ await this.client.GET("/v1/{workspace_id}/analytics/calls", {
1347
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1348
+ })
1349
+ );
692
1350
  }
693
1351
  /** Per-agent performance breakdown */
694
1352
  async getAgents(params) {
695
- return this.fetch(`/analytics/agents${buildQuery(params)}`);
1353
+ return extractData(
1354
+ await this.client.GET("/v1/{workspace_id}/analytics/agents", {
1355
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1356
+ })
1357
+ );
696
1358
  }
697
1359
  /** Call quality — sentiment, transcription confidence, flagged calls */
698
1360
  async getCallQuality(params) {
699
- return this.fetch(`/analytics/call-quality${buildQuery(params)}`);
1361
+ return extractData(
1362
+ await this.client.GET("/v1/{workspace_id}/analytics/call-quality", {
1363
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1364
+ })
1365
+ );
700
1366
  }
701
1367
  /** Emotion trend data over time */
702
1368
  async getEmotionTrends(params) {
703
- return this.fetch(`/analytics/emotion-trends${buildQuery(params)}`);
1369
+ return extractData(
1370
+ await this.client.GET("/v1/{workspace_id}/analytics/emotion-trends", {
1371
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1372
+ })
1373
+ );
704
1374
  }
705
1375
  /** Voice pipeline latency metrics (TTFB, response time) */
706
1376
  async getLatency(params) {
707
- return this.fetch(`/analytics/latency${buildQuery(params)}`);
1377
+ return extractData(
1378
+ await this.client.GET("/v1/{workspace_id}/analytics/latency", {
1379
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1380
+ })
1381
+ );
708
1382
  }
709
1383
  /** Tool call performance — success rates and latency per tool */
710
1384
  async getToolPerformance(params) {
711
- return this.fetch(`/analytics/tool-performance${buildQuery(params)}`);
1385
+ return extractData(
1386
+ await this.client.GET("/v1/{workspace_id}/analytics/tool-performance", {
1387
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1388
+ })
1389
+ );
712
1390
  }
713
1391
  /** Data quality metrics for the workspace world model */
714
1392
  async getDataQuality(params) {
715
- return this.fetch(`/analytics/data-quality${buildQuery(params)}`);
1393
+ return extractData(
1394
+ await this.client.GET("/v1/{workspace_id}/analytics/data-quality", {
1395
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1396
+ })
1397
+ );
716
1398
  }
717
1399
  /** Usage summary — API requests, call minutes, storage */
718
1400
  async getUsage(params) {
719
- return this.fetch(`/analytics/usage${buildQuery(params)}`);
1401
+ return extractData(
1402
+ await this.client.GET("/v1/{workspace_id}/analytics/usage", {
1403
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1404
+ })
1405
+ );
720
1406
  }
721
1407
  /** Advanced call statistics (abandonment, transfers, silence, hour-of-day) */
722
1408
  async getAdvancedCallStats(params) {
723
- return this.fetch(`/analytics/calls/advanced${buildQuery(params)}`);
1409
+ return extractData(
1410
+ await this.client.GET("/v1/{workspace_id}/analytics/calls/advanced", {
1411
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1412
+ })
1413
+ );
724
1414
  }
725
1415
  /** Compare two time periods side by side */
726
1416
  async compareCallPeriods(params) {
727
- return this.fetch(`/analytics/calls/comparison${buildQuery(params)}`);
1417
+ return extractData(
1418
+ await this.client.GET("/v1/{workspace_id}/analytics/calls/comparison", {
1419
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1420
+ })
1421
+ );
728
1422
  }
729
1423
  };
730
1424
 
@@ -732,95 +1426,207 @@ var AnalyticsResource = class extends WorkspaceScopedResource {
732
1426
  var SimulationsResource = class extends WorkspaceScopedResource {
733
1427
  /** Start a simulation session — returns the agent's greeting and initial snapshot */
734
1428
  async createSession(body) {
735
- return this.fetch("/simulations/sessions", {
736
- method: "POST",
737
- body: JSON.stringify(body)
738
- });
1429
+ return extractData(
1430
+ await this.client.POST("/v1/{workspace_id}/simulations/sessions", {
1431
+ params: { path: { workspace_id: this.workspaceId } },
1432
+ body
1433
+ })
1434
+ );
739
1435
  }
740
1436
  /** Get the current snapshot of a session */
741
1437
  async getSession(sessionId) {
742
- return this.fetch(`/simulations/sessions/${sessionId}`);
1438
+ return extractData(
1439
+ await this.client.GET("/v1/{workspace_id}/simulations/sessions/{session_id}", {
1440
+ params: { path: { workspace_id: this.workspaceId, session_id: sessionId } }
1441
+ })
1442
+ );
743
1443
  }
744
1444
  /** Delete a simulation session */
745
1445
  async deleteSession(sessionId) {
746
- return this.fetch(`/simulations/sessions/${sessionId}`, { method: "DELETE" });
1446
+ return extractData(
1447
+ await this.client.DELETE("/v1/{workspace_id}/simulations/sessions/{session_id}", {
1448
+ params: { path: { workspace_id: this.workspaceId, session_id: sessionId } }
1449
+ })
1450
+ );
747
1451
  }
748
1452
  /**
749
1453
  * Send a caller utterance and advance the session by one turn.
750
1454
  * Returns the agent's response observation and updated snapshot.
751
1455
  */
752
1456
  async step(body) {
753
- return this.fetch("/simulations/sessions/step", {
754
- method: "POST",
755
- body: JSON.stringify(body)
756
- });
1457
+ return extractData(
1458
+ await this.client.POST("/v1/{workspace_id}/simulations/sessions/step", {
1459
+ params: { path: { workspace_id: this.workspaceId } },
1460
+ body
1461
+ })
1462
+ );
757
1463
  }
758
1464
  /**
759
1465
  * Get LLM-generated caller message suggestions for the current session state.
760
1466
  * Helps exploratory testing by suggesting realistic next caller turns.
761
1467
  */
762
- async recommend(sessionId, n) {
763
- return this.fetch("/simulations/sessions/recommend", {
764
- method: "POST",
765
- body: JSON.stringify({ session_id: sessionId, n })
766
- });
1468
+ async recommend(body) {
1469
+ return extractData(
1470
+ await this.client.POST("/v1/{workspace_id}/simulations/sessions/recommend", {
1471
+ params: { path: { workspace_id: this.workspaceId } },
1472
+ body
1473
+ })
1474
+ );
767
1475
  }
768
1476
  /** Get AI-generated call intelligence for a completed session */
769
1477
  async getIntelligence(sessionId) {
770
- return this.fetch(`/simulations/sessions/${sessionId}/intelligence`);
1478
+ return extractData(
1479
+ await this.client.GET("/v1/{workspace_id}/simulations/sessions/{session_id}/intelligence", {
1480
+ params: { path: { workspace_id: this.workspaceId, session_id: sessionId } }
1481
+ })
1482
+ );
771
1483
  }
772
1484
  };
773
1485
 
774
1486
  // src/resources/settings.ts
775
1487
  var SettingsResource = class extends WorkspaceScopedResource {
776
- async getSettings(key) {
777
- return this.fetch(`/settings/${key}`);
778
- }
779
- async updateSettings(key, body) {
780
- return this.fetch(`/settings/${key}`, {
781
- method: "PUT",
782
- body: JSON.stringify(body)
783
- });
784
- }
785
1488
  voice = {
786
- get: () => this.getSettings("voice"),
787
- update: (body) => this.updateSettings("voice", body)
1489
+ get: async () => extractData(
1490
+ await this.client.GET("/v1/{workspace_id}/settings/voice", {
1491
+ params: { path: { workspace_id: this.workspaceId } }
1492
+ })
1493
+ ),
1494
+ update: async (body) => extractData(
1495
+ await this.client.PUT("/v1/{workspace_id}/settings/voice", {
1496
+ params: { path: { workspace_id: this.workspaceId } },
1497
+ body
1498
+ })
1499
+ )
788
1500
  };
789
1501
  branding = {
790
- get: () => this.getSettings("branding"),
791
- update: (body) => this.updateSettings("branding", body)
1502
+ get: async () => extractData(
1503
+ await this.client.GET("/v1/{workspace_id}/settings/branding", {
1504
+ params: { path: { workspace_id: this.workspaceId } }
1505
+ })
1506
+ ),
1507
+ update: async (body) => extractData(
1508
+ await this.client.PUT("/v1/{workspace_id}/settings/branding", {
1509
+ params: { path: { workspace_id: this.workspaceId } },
1510
+ body
1511
+ })
1512
+ )
792
1513
  };
793
1514
  outreach = {
794
- get: () => this.getSettings("outreach"),
795
- update: (body) => this.updateSettings("outreach", body)
1515
+ get: async () => extractData(
1516
+ await this.client.GET("/v1/{workspace_id}/settings/outreach", {
1517
+ params: { path: { workspace_id: this.workspaceId } }
1518
+ })
1519
+ ),
1520
+ update: async (body) => extractData(
1521
+ await this.client.PUT("/v1/{workspace_id}/settings/outreach", {
1522
+ params: { path: { workspace_id: this.workspaceId } },
1523
+ body
1524
+ })
1525
+ )
796
1526
  };
797
1527
  memory = {
798
- get: () => this.getSettings("memory"),
799
- update: (body) => this.updateSettings("memory", body)
1528
+ get: async () => extractData(
1529
+ await this.client.GET("/v1/{workspace_id}/settings/memory", {
1530
+ params: { path: { workspace_id: this.workspaceId } }
1531
+ })
1532
+ ),
1533
+ update: async (body) => extractData(
1534
+ await this.client.PUT("/v1/{workspace_id}/settings/memory", {
1535
+ params: { path: { workspace_id: this.workspaceId } },
1536
+ body
1537
+ })
1538
+ )
800
1539
  };
801
1540
  security = {
802
- get: () => this.getSettings("security"),
803
- update: (body) => this.updateSettings("security", body)
1541
+ get: async () => extractData(
1542
+ await this.client.GET("/v1/{workspace_id}/settings/security", {
1543
+ params: { path: { workspace_id: this.workspaceId } }
1544
+ })
1545
+ ),
1546
+ update: async (body) => extractData(
1547
+ await this.client.PUT("/v1/{workspace_id}/settings/security", {
1548
+ params: { path: { workspace_id: this.workspaceId } },
1549
+ body
1550
+ })
1551
+ )
804
1552
  };
805
1553
  retention = {
806
- get: () => this.getSettings("retention"),
807
- update: (body) => this.updateSettings("retention", body)
1554
+ get: async () => extractData(
1555
+ await this.client.GET("/v1/{workspace_id}/settings/retention", {
1556
+ params: { path: { workspace_id: this.workspaceId } }
1557
+ })
1558
+ ),
1559
+ update: async (body) => extractData(
1560
+ await this.client.PUT("/v1/{workspace_id}/settings/retention", {
1561
+ params: { path: { workspace_id: this.workspaceId } },
1562
+ body
1563
+ })
1564
+ )
808
1565
  };
809
1566
  workflows = {
810
- get: () => this.getSettings("workflows"),
811
- update: (body) => this.updateSettings("workflows", body)
1567
+ get: async () => extractData(
1568
+ await this.client.GET("/v1/{workspace_id}/settings/workflows", {
1569
+ params: { path: { workspace_id: this.workspaceId } }
1570
+ })
1571
+ ),
1572
+ update: async (body) => extractData(
1573
+ await this.client.PUT("/v1/{workspace_id}/settings/workflows", {
1574
+ params: { path: { workspace_id: this.workspaceId } },
1575
+ body
1576
+ })
1577
+ )
812
1578
  };
813
1579
  };
814
1580
 
815
1581
  // src/resources/billing.ts
816
1582
  var BillingResource = class extends WorkspaceScopedResource {
817
- /** Get usage summary for a time period */
818
- async getUsage(params) {
819
- return this.fetch(`/billing/usage${buildQuery(params)}`);
1583
+ /** Get composite billing dashboard KPIs, period comparison, top meters, invoice summary */
1584
+ async getDashboard() {
1585
+ return extractData(
1586
+ await this.client.GET("/v1/{workspace_id}/billing/dashboard", {
1587
+ params: { path: { workspace_id: this.workspaceId } }
1588
+ })
1589
+ );
1590
+ }
1591
+ /** Get usage summary for the workspace */
1592
+ async getUsage() {
1593
+ return extractData(
1594
+ await this.client.GET("/v1/{workspace_id}/billing/usage", {
1595
+ params: { path: { workspace_id: this.workspaceId } }
1596
+ })
1597
+ );
820
1598
  }
821
- /** List invoices */
1599
+ /** Get usage time-series per meter for trend charts */
1600
+ async getUsageTrends(params) {
1601
+ return extractData(
1602
+ await this.client.GET("/v1/{workspace_id}/billing/usage/trends", {
1603
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1604
+ })
1605
+ );
1606
+ }
1607
+ /** List invoices for the workspace */
822
1608
  async listInvoices(params) {
823
- return this.fetch(`/billing/invoices${buildQuery(params)}`);
1609
+ return extractData(
1610
+ await this.client.GET("/v1/{workspace_id}/billing/invoices", {
1611
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1612
+ })
1613
+ );
1614
+ }
1615
+ /** Get invoice detail */
1616
+ async getInvoice(invoiceId) {
1617
+ return extractData(
1618
+ await this.client.GET("/v1/{workspace_id}/billing/invoices/{invoice_id}", {
1619
+ params: { path: { workspace_id: this.workspaceId, invoice_id: invoiceId } }
1620
+ })
1621
+ );
1622
+ }
1623
+ /** Get presigned S3 URL for invoice PDF download */
1624
+ async getInvoicePdf(invoiceId) {
1625
+ return extractData(
1626
+ await this.client.GET("/v1/{workspace_id}/billing/invoices/{invoice_id}/pdf", {
1627
+ params: { path: { workspace_id: this.workspaceId, invoice_id: invoiceId } }
1628
+ })
1629
+ );
824
1630
  }
825
1631
  };
826
1632
 
@@ -831,20 +1637,456 @@ var MemoryResource = class extends WorkspaceScopedResource {
831
1637
  * Scores reflect how complete and confident each dimension's facts are.
832
1638
  */
833
1639
  async getEntityDimensions(entityId2) {
834
- return this.fetch(`/memory/${entityId2}/dimensions`);
1640
+ return extractData(
1641
+ await this.client.GET("/v1/{workspace_id}/memory/{entity_id}/dimensions", {
1642
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 } }
1643
+ })
1644
+ );
835
1645
  }
836
1646
  /**
837
1647
  * Get individual memory facts for an entity, optionally filtered by dimension.
838
1648
  */
839
1649
  async getEntityFacts(entityId2, params) {
840
- return this.fetch(`/memory/${entityId2}/facts${buildQuery(params)}`);
1650
+ return extractData(
1651
+ await this.client.GET("/v1/{workspace_id}/memory/{entity_id}/facts", {
1652
+ params: {
1653
+ path: { workspace_id: this.workspaceId, entity_id: entityId2 },
1654
+ query: params
1655
+ }
1656
+ })
1657
+ );
841
1658
  }
842
1659
  /**
843
1660
  * Get workspace-level memory analytics — coverage rates, dimension health,
844
1661
  * and fact ingestion trends.
845
1662
  */
846
1663
  async getAnalytics() {
847
- return this.fetch("/memory/analytics");
1664
+ return extractData(
1665
+ await this.client.GET("/v1/{workspace_id}/memory/analytics", {
1666
+ params: { path: { workspace_id: this.workspaceId } }
1667
+ })
1668
+ );
1669
+ }
1670
+ };
1671
+
1672
+ // src/resources/personas.ts
1673
+ var PersonasResource = class extends WorkspaceScopedResource {
1674
+ async list(params) {
1675
+ return extractData(
1676
+ await this.client.GET("/v1/{workspace_id}/personas", {
1677
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1678
+ })
1679
+ );
1680
+ }
1681
+ async create(body) {
1682
+ return extractData(
1683
+ await this.client.POST("/v1/{workspace_id}/personas", {
1684
+ params: { path: { workspace_id: this.workspaceId } },
1685
+ body
1686
+ })
1687
+ );
1688
+ }
1689
+ async get(personaId2) {
1690
+ return extractData(
1691
+ await this.client.GET("/v1/{workspace_id}/personas/{persona_id}", {
1692
+ params: { path: { workspace_id: this.workspaceId, persona_id: personaId2 } }
1693
+ })
1694
+ );
1695
+ }
1696
+ async update(personaId2, body) {
1697
+ return extractData(
1698
+ await this.client.PATCH("/v1/{workspace_id}/personas/{persona_id}", {
1699
+ params: { path: { workspace_id: this.workspaceId, persona_id: personaId2 } },
1700
+ body
1701
+ })
1702
+ );
1703
+ }
1704
+ async delete(personaId2) {
1705
+ await this.client.DELETE("/v1/{workspace_id}/personas/{persona_id}", {
1706
+ params: { path: { workspace_id: this.workspaceId, persona_id: personaId2 } }
1707
+ });
1708
+ }
1709
+ };
1710
+
1711
+ // src/resources/review-queue.ts
1712
+ var ReviewQueueResource = class extends WorkspaceScopedResource {
1713
+ async list(params) {
1714
+ return extractData(
1715
+ await this.client.GET("/v1/{workspace_id}/review-queue", {
1716
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1717
+ })
1718
+ );
1719
+ }
1720
+ async get(itemId) {
1721
+ return extractData(
1722
+ await this.client.GET("/v1/{workspace_id}/review-queue/{item_id}", {
1723
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } }
1724
+ })
1725
+ );
1726
+ }
1727
+ async getStats() {
1728
+ return extractData(
1729
+ await this.client.GET("/v1/{workspace_id}/review-queue/stats", {
1730
+ params: { path: { workspace_id: this.workspaceId } }
1731
+ })
1732
+ );
1733
+ }
1734
+ async getDashboard() {
1735
+ return extractData(
1736
+ await this.client.GET("/v1/{workspace_id}/review-queue/dashboard", {
1737
+ params: { path: { workspace_id: this.workspaceId } }
1738
+ })
1739
+ );
1740
+ }
1741
+ async getMyQueue(params) {
1742
+ return extractData(
1743
+ await this.client.GET("/v1/{workspace_id}/review-queue/my-queue", {
1744
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1745
+ })
1746
+ );
1747
+ }
1748
+ async approve(itemId, body) {
1749
+ return extractData(
1750
+ await this.client.POST("/v1/{workspace_id}/review-queue/{item_id}/approve", {
1751
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } },
1752
+ body
1753
+ })
1754
+ );
1755
+ }
1756
+ async reject(itemId, body) {
1757
+ return extractData(
1758
+ await this.client.POST("/v1/{workspace_id}/review-queue/{item_id}/reject", {
1759
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } },
1760
+ body
1761
+ })
1762
+ );
1763
+ }
1764
+ async claim(itemId) {
1765
+ return extractData(
1766
+ await this.client.POST("/v1/{workspace_id}/review-queue/{item_id}/claim", {
1767
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } }
1768
+ })
1769
+ );
1770
+ }
1771
+ async unclaim(itemId) {
1772
+ return extractData(
1773
+ await this.client.POST("/v1/{workspace_id}/review-queue/{item_id}/unclaim", {
1774
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } }
1775
+ })
1776
+ );
1777
+ }
1778
+ async correct(itemId, body) {
1779
+ return extractData(
1780
+ await this.client.POST("/v1/{workspace_id}/review-queue/{item_id}/correct", {
1781
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } },
1782
+ body
1783
+ })
1784
+ );
1785
+ }
1786
+ async batchApprove(body) {
1787
+ return extractData(
1788
+ await this.client.POST("/v1/{workspace_id}/review-queue/batch-approve", {
1789
+ params: { path: { workspace_id: this.workspaceId } },
1790
+ body
1791
+ })
1792
+ );
1793
+ }
1794
+ async batchReject(body) {
1795
+ return extractData(
1796
+ await this.client.POST("/v1/{workspace_id}/review-queue/batch-reject", {
1797
+ params: { path: { workspace_id: this.workspaceId } },
1798
+ body
1799
+ })
1800
+ );
1801
+ }
1802
+ async getHistory(params) {
1803
+ return extractData(
1804
+ await this.client.GET("/v1/{workspace_id}/review-queue/history", {
1805
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1806
+ })
1807
+ );
1808
+ }
1809
+ async getTrends(params) {
1810
+ return extractData(
1811
+ await this.client.GET("/v1/{workspace_id}/review-queue/trends", {
1812
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1813
+ })
1814
+ );
1815
+ }
1816
+ async getPerformance(params) {
1817
+ return extractData(
1818
+ await this.client.GET("/v1/{workspace_id}/review-queue/performance", {
1819
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1820
+ })
1821
+ );
1822
+ }
1823
+ async getCorrectionSchema(itemId) {
1824
+ return extractData(
1825
+ await this.client.GET("/v1/{workspace_id}/review-queue/{item_id}/correction-schema", {
1826
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } }
1827
+ })
1828
+ );
1829
+ }
1830
+ async getDiff(itemId) {
1831
+ return extractData(
1832
+ await this.client.GET("/v1/{workspace_id}/review-queue/{item_id}/diff", {
1833
+ params: { path: { workspace_id: this.workspaceId, item_id: itemId } }
1834
+ })
1835
+ );
1836
+ }
1837
+ };
1838
+
1839
+ // src/resources/recordings.ts
1840
+ var RecordingsResource = class extends WorkspaceScopedResource {
1841
+ async getUrls(callSid) {
1842
+ return extractData(
1843
+ await this.client.GET("/v1/{workspace_id}/recordings/{call_sid}/urls", {
1844
+ params: { path: { workspace_id: this.workspaceId, call_sid: callSid } }
1845
+ })
1846
+ );
1847
+ }
1848
+ async getMetadata(callSid) {
1849
+ return extractData(
1850
+ await this.client.GET("/v1/{workspace_id}/recordings/{call_sid}/metadata", {
1851
+ params: { path: { workspace_id: this.workspaceId, call_sid: callSid } }
1852
+ })
1853
+ );
1854
+ }
1855
+ async download(callSid, filename) {
1856
+ return extractData(
1857
+ await this.client.GET("/v1/{workspace_id}/recordings/{call_sid}/download/{filename}", {
1858
+ params: { path: { workspace_id: this.workspaceId, call_sid: callSid, filename } }
1859
+ })
1860
+ );
1861
+ }
1862
+ };
1863
+
1864
+ // src/resources/audit.ts
1865
+ var AuditResource = class extends WorkspaceScopedResource {
1866
+ async list(params) {
1867
+ return extractData(
1868
+ await this.client.GET("/v1/{workspace_id}/audit", {
1869
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1870
+ })
1871
+ );
1872
+ }
1873
+ async getSummary(params) {
1874
+ return extractData(
1875
+ await this.client.GET("/v1/{workspace_id}/audit/summary", {
1876
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1877
+ })
1878
+ );
1879
+ }
1880
+ async getPhiAccess(params) {
1881
+ return extractData(
1882
+ await this.client.GET("/v1/{workspace_id}/audit/phi-access", {
1883
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1884
+ })
1885
+ );
1886
+ }
1887
+ async createExport(body) {
1888
+ return extractData(
1889
+ await this.client.POST("/v1/{workspace_id}/audit/export", {
1890
+ params: { path: { workspace_id: this.workspaceId } },
1891
+ body
1892
+ })
1893
+ );
1894
+ }
1895
+ async listExports() {
1896
+ return extractData(
1897
+ await this.client.GET("/v1/{workspace_id}/audit/exports", {
1898
+ params: { path: { workspace_id: this.workspaceId } }
1899
+ })
1900
+ );
1901
+ }
1902
+ async getEntityAccessLog(entityId2, params) {
1903
+ return extractData(
1904
+ await this.client.GET("/v1/{workspace_id}/audit/entity/{entity_id}/access-log", {
1905
+ params: { path: { workspace_id: this.workspaceId, entity_id: entityId2 }, query: params }
1906
+ })
1907
+ );
1908
+ }
1909
+ };
1910
+
1911
+ // src/resources/webhook-destinations.ts
1912
+ var WebhookDestinationsResource = class extends WorkspaceScopedResource {
1913
+ async list(params) {
1914
+ return extractData(
1915
+ await this.client.GET("/v1/{workspace_id}/webhook-destinations", {
1916
+ params: { path: { workspace_id: this.workspaceId }, query: params }
1917
+ })
1918
+ );
1919
+ }
1920
+ async create(body) {
1921
+ return extractData(
1922
+ await this.client.POST("/v1/{workspace_id}/webhook-destinations", {
1923
+ params: { path: { workspace_id: this.workspaceId } },
1924
+ body
1925
+ })
1926
+ );
1927
+ }
1928
+ async get(destinationId) {
1929
+ return extractData(
1930
+ await this.client.GET("/v1/{workspace_id}/webhook-destinations/{destination_id}", {
1931
+ params: { path: { workspace_id: this.workspaceId, destination_id: destinationId } }
1932
+ })
1933
+ );
1934
+ }
1935
+ async update(destinationId, body) {
1936
+ return extractData(
1937
+ await this.client.PUT("/v1/{workspace_id}/webhook-destinations/{destination_id}", {
1938
+ params: { path: { workspace_id: this.workspaceId, destination_id: destinationId } },
1939
+ body
1940
+ })
1941
+ );
1942
+ }
1943
+ async delete(destinationId) {
1944
+ await this.client.DELETE("/v1/{workspace_id}/webhook-destinations/{destination_id}", {
1945
+ params: { path: { workspace_id: this.workspaceId, destination_id: destinationId } }
1946
+ });
1947
+ }
1948
+ async listDeliveries(destinationId, params) {
1949
+ return extractData(
1950
+ await this.client.GET(
1951
+ "/v1/{workspace_id}/webhook-destinations/{destination_id}/deliveries",
1952
+ {
1953
+ params: {
1954
+ path: { workspace_id: this.workspaceId, destination_id: destinationId },
1955
+ query: params
1956
+ }
1957
+ }
1958
+ )
1959
+ );
1960
+ }
1961
+ async rotateSecret(destinationId) {
1962
+ return extractData(
1963
+ await this.client.POST(
1964
+ "/v1/{workspace_id}/webhook-destinations/{destination_id}/rotate-secret",
1965
+ {
1966
+ params: { path: { workspace_id: this.workspaceId, destination_id: destinationId } }
1967
+ }
1968
+ )
1969
+ );
1970
+ }
1971
+ };
1972
+
1973
+ // src/resources/safety.ts
1974
+ var SafetyResource = class extends WorkspaceScopedResource {
1975
+ async getConfig() {
1976
+ return extractData(
1977
+ await this.client.GET("/v1/{workspace_id}/safety/config", {
1978
+ params: { path: { workspace_id: this.workspaceId } }
1979
+ })
1980
+ );
1981
+ }
1982
+ async updateConfig(body) {
1983
+ return extractData(
1984
+ await this.client.PUT("/v1/{workspace_id}/safety/config", {
1985
+ params: { path: { workspace_id: this.workspaceId } },
1986
+ body
1987
+ })
1988
+ );
1989
+ }
1990
+ async listTemplates() {
1991
+ return extractData(
1992
+ await this.client.GET("/v1/{workspace_id}/safety/templates", {
1993
+ params: { path: { workspace_id: this.workspaceId } }
1994
+ })
1995
+ );
1996
+ }
1997
+ async getTemplate(templateId) {
1998
+ return extractData(
1999
+ await this.client.GET("/v1/{workspace_id}/safety/templates/{template_id}", {
2000
+ params: { path: { workspace_id: this.workspaceId, template_id: templateId } }
2001
+ })
2002
+ );
2003
+ }
2004
+ async applyTemplate(templateId, body) {
2005
+ return extractData(
2006
+ await this.client.POST("/v1/{workspace_id}/safety/templates/{template_id}/apply", {
2007
+ params: { path: { workspace_id: this.workspaceId, template_id: templateId } },
2008
+ body
2009
+ })
2010
+ );
2011
+ }
2012
+ };
2013
+
2014
+ // src/resources/compliance.ts
2015
+ var ComplianceResource = class extends WorkspaceScopedResource {
2016
+ async getDashboard() {
2017
+ return extractData(
2018
+ await this.client.GET("/v1/{workspace_id}/compliance/dashboard", {
2019
+ params: { path: { workspace_id: this.workspaceId } }
2020
+ })
2021
+ );
2022
+ }
2023
+ async getHipaa(params) {
2024
+ return extractData(
2025
+ await this.client.GET("/v1/{workspace_id}/compliance/hipaa", {
2026
+ params: { path: { workspace_id: this.workspaceId }, query: params }
2027
+ })
2028
+ );
2029
+ }
2030
+ async getAccessReview() {
2031
+ return extractData(
2032
+ await this.client.GET("/v1/{workspace_id}/compliance/access-review", {
2033
+ params: { path: { workspace_id: this.workspaceId } }
2034
+ })
2035
+ );
2036
+ }
2037
+ };
2038
+
2039
+ // src/resources/functions.ts
2040
+ var FunctionsResource = class extends WorkspaceScopedResource {
2041
+ async list() {
2042
+ return extractData(
2043
+ await this.client.GET("/v1/{workspace_id}/functions", {
2044
+ params: { path: { workspace_id: this.workspaceId } }
2045
+ })
2046
+ );
2047
+ }
2048
+ async create(body) {
2049
+ return extractData(
2050
+ await this.client.POST("/v1/{workspace_id}/functions", {
2051
+ params: { path: { workspace_id: this.workspaceId } },
2052
+ body
2053
+ })
2054
+ );
2055
+ }
2056
+ async delete(functionName) {
2057
+ await this.client.DELETE("/v1/{workspace_id}/functions/{function_name}", {
2058
+ params: { path: { workspace_id: this.workspaceId, function_name: functionName } }
2059
+ });
2060
+ }
2061
+ async test(functionName, body) {
2062
+ return extractData(
2063
+ await this.client.POST("/v1/{workspace_id}/functions/{function_name}/test", {
2064
+ params: { path: { workspace_id: this.workspaceId, function_name: functionName } },
2065
+ body
2066
+ })
2067
+ );
2068
+ }
2069
+ async getCatalog() {
2070
+ return extractData(
2071
+ await this.client.GET("/v1/{workspace_id}/functions/catalog", {
2072
+ params: { path: { workspace_id: this.workspaceId } }
2073
+ })
2074
+ );
2075
+ }
2076
+ async query(body) {
2077
+ return extractData(
2078
+ await this.client.POST("/v1/{workspace_id}/functions/query", {
2079
+ params: { path: { workspace_id: this.workspaceId } },
2080
+ body
2081
+ })
2082
+ );
2083
+ }
2084
+ async sync() {
2085
+ return extractData(
2086
+ await this.client.POST("/v1/{workspace_id}/functions/sync", {
2087
+ params: { path: { workspace_id: this.workspaceId } }
2088
+ })
2089
+ );
848
2090
  }
849
2091
  };
850
2092
 
@@ -852,7 +2094,9 @@ var MemoryResource = class extends WorkspaceScopedResource {
852
2094
  var workspaceId = (id) => id;
853
2095
  var apiKeyId = (id) => id;
854
2096
  var agentId = (id) => id;
2097
+ var personaId = (id) => id;
855
2098
  var skillId = (id) => id;
2099
+ var actionId = (id) => id;
856
2100
  var serviceId = (id) => id;
857
2101
  var contextGraphId = (id) => id;
858
2102
  var callId = (id) => id;
@@ -862,56 +2106,80 @@ var entityId = (id) => id;
862
2106
  var eventId = (id) => id;
863
2107
  var simulationRunId = (id) => id;
864
2108
  var simulationSessionId = (id) => id;
2109
+ var functionId = (id) => id;
865
2110
  var dataSourceId = (id) => id;
866
2111
 
867
- // src/core/utils.ts
868
- async function* paginate(fetcher) {
869
- let token = void 0;
870
- while (true) {
871
- const page = await fetcher(token);
872
- for (const item of page.items) {
873
- yield item;
874
- }
875
- if (!page.has_more || page.continuation_token === null) break;
876
- token = page.continuation_token;
2112
+ // src/core/rate-limit.ts
2113
+ function parseRateLimitHeaders(headers) {
2114
+ const limit = headers.get("x-ratelimit-limit");
2115
+ const remaining = headers.get("x-ratelimit-remaining");
2116
+ const reset = headers.get("x-ratelimit-reset");
2117
+ const retryAfter = headers.get("retry-after");
2118
+ return {
2119
+ limit: limit ? parseInt(limit, 10) : null,
2120
+ remaining: remaining ? parseInt(remaining, 10) : null,
2121
+ reset: reset ? new Date(parseInt(reset, 10) * 1e3) : null,
2122
+ retryAfter: retryAfter ? parseInt(retryAfter, 10) : null
2123
+ };
2124
+ }
2125
+
2126
+ // src/core/webhooks.ts
2127
+ async function verifyWebhookSignature(payload, signature, secret) {
2128
+ const encoder = new TextEncoder();
2129
+ const key = await crypto.subtle.importKey(
2130
+ "raw",
2131
+ encoder.encode(secret),
2132
+ { name: "HMAC", hash: "SHA-256" },
2133
+ false,
2134
+ ["sign"]
2135
+ );
2136
+ const mac = await crypto.subtle.sign(
2137
+ "HMAC",
2138
+ key,
2139
+ typeof payload === "string" ? encoder.encode(payload) : payload
2140
+ );
2141
+ const expected = Array.from(new Uint8Array(mac)).map((b) => b.toString(16).padStart(2, "0")).join("");
2142
+ return signature === `sha256=${expected}`;
2143
+ }
2144
+ async function parseWebhookEvent(payload, signature, secret) {
2145
+ const valid = await verifyWebhookSignature(payload, signature, secret);
2146
+ if (!valid) {
2147
+ throw new Error("Invalid webhook signature");
877
2148
  }
2149
+ return JSON.parse(payload);
878
2150
  }
879
2151
 
880
2152
  // src/index.ts
881
2153
  var DEFAULT_BASE_URL = "https://api.platform.amigo.ai";
882
2154
  var AmigoClient = class {
883
- /** Workspace management */
884
2155
  workspaces;
885
- /** API key management */
886
2156
  apiKeys;
887
- /** Agent management — AI agents that handle calls */
888
2157
  agents;
889
- /** Skill management reusable AI capabilities */
2158
+ /** @deprecated Use `actions` instead */
890
2159
  skills;
891
- /** Service management — external service configurations */
2160
+ actions;
2161
+ operators;
2162
+ triggers;
892
2163
  services;
893
- /** Context graph management — conversation flow structures */
894
2164
  contextGraphs;
895
- /** Data source management — external data connections */
896
2165
  dataSources;
897
- /** World model — entities, events, and timelines */
898
2166
  world;
899
- /** Call records and intelligence */
900
2167
  calls;
901
- /** Phone number provisioning and management */
902
2168
  phoneNumbers;
903
- /** Integration management — EHR, CRM, and other external systems */
904
2169
  integrations;
905
- /** Analytics — aggregate metrics about calls and conversions */
906
2170
  analytics;
907
- /** Simulation runs and interactive testing sessions */
908
2171
  simulations;
909
- /** Workspace-level settings (voice, branding, security, outreach, etc.) */
910
2172
  settings;
911
- /** Billing — usage summaries and invoices */
912
2173
  billing;
913
- /** Agent Memory — structured long-term memory for entities */
914
2174
  memory;
2175
+ personas;
2176
+ reviewQueue;
2177
+ recordings;
2178
+ audit;
2179
+ webhookDestinations;
2180
+ safety;
2181
+ compliance;
2182
+ functions;
915
2183
  constructor(config) {
916
2184
  if (!config.apiKey || typeof config.apiKey !== "string") {
917
2185
  throw new ConfigurationError("apiKey is required and must be a non-empty string");
@@ -920,27 +2188,40 @@ var AmigoClient = class {
920
2188
  throw new ConfigurationError("workspaceId is required and must be a non-empty string");
921
2189
  }
922
2190
  const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
923
- const rc = {
2191
+ const client = createPlatformClient({
924
2192
  apiKey: config.apiKey,
925
2193
  baseUrl,
926
- workspaceId: config.workspaceId
927
- };
928
- this.workspaces = new WorkspacesResource({ apiKey: config.apiKey, baseUrl });
929
- this.apiKeys = new ApiKeysResource(rc);
930
- this.agents = new AgentsResource(rc);
931
- this.skills = new SkillsResource(rc);
932
- this.services = new ServicesResource(rc);
933
- this.contextGraphs = new ContextGraphsResource(rc);
934
- this.dataSources = new DataSourcesResource(rc);
935
- this.world = new WorldResource(rc);
936
- this.calls = new CallsResource(rc);
937
- this.phoneNumbers = new PhoneNumbersResource(rc);
938
- this.integrations = new IntegrationsResource(rc);
939
- this.analytics = new AnalyticsResource(rc);
940
- this.simulations = new SimulationsResource(rc);
941
- this.settings = new SettingsResource(rc);
942
- this.billing = new BillingResource(rc);
943
- this.memory = new MemoryResource(rc);
2194
+ retry: config.retry,
2195
+ fetch: config.fetch
2196
+ });
2197
+ const ws = config.workspaceId;
2198
+ this.workspaces = new WorkspacesResource(client, ws);
2199
+ this.apiKeys = new ApiKeysResource(client, ws);
2200
+ this.agents = new AgentsResource(client, ws);
2201
+ this.skills = new SkillsResource(client, ws);
2202
+ this.actions = new ActionsResource(client, ws);
2203
+ this.operators = new OperatorsResource(client, ws);
2204
+ this.triggers = new TriggersResource(client, ws);
2205
+ this.services = new ServicesResource(client, ws);
2206
+ this.contextGraphs = new ContextGraphsResource(client, ws);
2207
+ this.dataSources = new DataSourcesResource(client, ws);
2208
+ this.world = new WorldResource(client, ws);
2209
+ this.calls = new CallsResource(client, ws);
2210
+ this.phoneNumbers = new PhoneNumbersResource(client, ws);
2211
+ this.integrations = new IntegrationsResource(client, ws);
2212
+ this.analytics = new AnalyticsResource(client, ws);
2213
+ this.simulations = new SimulationsResource(client, ws);
2214
+ this.settings = new SettingsResource(client, ws);
2215
+ this.billing = new BillingResource(client, ws);
2216
+ this.memory = new MemoryResource(client, ws);
2217
+ this.personas = new PersonasResource(client, ws);
2218
+ this.reviewQueue = new ReviewQueueResource(client, ws);
2219
+ this.recordings = new RecordingsResource(client, ws);
2220
+ this.audit = new AuditResource(client, ws);
2221
+ this.webhookDestinations = new WebhookDestinationsResource(client, ws);
2222
+ this.safety = new SafetyResource(client, ws);
2223
+ this.compliance = new ComplianceResource(client, ws);
2224
+ this.functions = new FunctionsResource(client, ws);
944
2225
  }
945
2226
  };
946
2227
  export {
@@ -959,6 +2240,7 @@ export {
959
2240
  ServerError,
960
2241
  ServiceUnavailableError,
961
2242
  ValidationError,
2243
+ actionId,
962
2244
  agentId,
963
2245
  apiKeyId,
964
2246
  callId,
@@ -966,17 +2248,22 @@ export {
966
2248
  dataSourceId,
967
2249
  entityId,
968
2250
  eventId,
2251
+ functionId,
969
2252
  integrationId,
970
2253
  isAmigoError,
971
2254
  isAuthenticationError,
972
2255
  isNotFoundError,
973
2256
  isRateLimitError,
974
2257
  paginate,
2258
+ parseRateLimitHeaders,
2259
+ parseWebhookEvent,
2260
+ personaId,
975
2261
  phoneNumberId,
976
2262
  serviceId,
977
2263
  simulationRunId,
978
2264
  simulationSessionId,
979
2265
  skillId,
2266
+ verifyWebhookSignature,
980
2267
  workspaceId
981
2268
  };
982
2269
  //# sourceMappingURL=index.mjs.map