@amigo-ai/platform-sdk 0.1.0 → 0.2.1

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