@amigo-ai/platform-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -0
  3. package/dist/core/auth.js +32 -0
  4. package/dist/core/auth.js.map +1 -0
  5. package/dist/core/branded-types.js +22 -0
  6. package/dist/core/branded-types.js.map +1 -0
  7. package/dist/core/errors.js +168 -0
  8. package/dist/core/errors.js.map +1 -0
  9. package/dist/core/openapi-client.js +66 -0
  10. package/dist/core/openapi-client.js.map +1 -0
  11. package/dist/core/retry.js +48 -0
  12. package/dist/core/retry.js.map +1 -0
  13. package/dist/core/utils.js +35 -0
  14. package/dist/core/utils.js.map +1 -0
  15. package/dist/index.cjs +1005 -0
  16. package/dist/index.cjs.map +7 -0
  17. package/dist/index.js +111 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/index.mjs +982 -0
  20. package/dist/index.mjs.map +7 -0
  21. package/dist/resources/agents.js +49 -0
  22. package/dist/resources/agents.js.map +1 -0
  23. package/dist/resources/analytics.js +54 -0
  24. package/dist/resources/analytics.js.map +1 -0
  25. package/dist/resources/api-keys.js +45 -0
  26. package/dist/resources/api-keys.js.map +1 -0
  27. package/dist/resources/base.js +50 -0
  28. package/dist/resources/base.js.map +1 -0
  29. package/dist/resources/billing.js +15 -0
  30. package/dist/resources/billing.js.map +1 -0
  31. package/dist/resources/calls.js +28 -0
  32. package/dist/resources/calls.js.map +1 -0
  33. package/dist/resources/context-graphs.js +44 -0
  34. package/dist/resources/context-graphs.js.map +1 -0
  35. package/dist/resources/data-sources.js +29 -0
  36. package/dist/resources/data-sources.js.map +1 -0
  37. package/dist/resources/integrations.js +45 -0
  38. package/dist/resources/integrations.js.map +1 -0
  39. package/dist/resources/memory.js +31 -0
  40. package/dist/resources/memory.js.map +1 -0
  41. package/dist/resources/phone-numbers.js +38 -0
  42. package/dist/resources/phone-numbers.js.map +1 -0
  43. package/dist/resources/services.js +30 -0
  44. package/dist/resources/services.js.map +1 -0
  45. package/dist/resources/settings.js +47 -0
  46. package/dist/resources/settings.js.map +1 -0
  47. package/dist/resources/simulations.js +50 -0
  48. package/dist/resources/simulations.js.map +1 -0
  49. package/dist/resources/skills.js +44 -0
  50. package/dist/resources/skills.js.map +1 -0
  51. package/dist/resources/workspaces.js +57 -0
  52. package/dist/resources/workspaces.js.map +1 -0
  53. package/dist/resources/world.js +131 -0
  54. package/dist/resources/world.js.map +1 -0
  55. package/dist/types/api.js +12 -0
  56. package/dist/types/api.js.map +1 -0
  57. package/dist/types/core/auth.d.ts +20 -0
  58. package/dist/types/core/auth.d.ts.map +1 -0
  59. package/dist/types/core/branded-types.d.ts +50 -0
  60. package/dist/types/core/branded-types.d.ts.map +1 -0
  61. package/dist/types/core/errors.d.ts +76 -0
  62. package/dist/types/core/errors.d.ts.map +1 -0
  63. package/dist/types/core/openapi-client.d.ts +14 -0
  64. package/dist/types/core/openapi-client.d.ts.map +1 -0
  65. package/dist/types/core/retry.d.ts +21 -0
  66. package/dist/types/core/retry.d.ts.map +1 -0
  67. package/dist/types/core/utils.d.ts +39 -0
  68. package/dist/types/core/utils.d.ts.map +1 -0
  69. package/dist/types/index.d.ts +114 -0
  70. package/dist/types/index.d.ts.map +1 -0
  71. package/dist/types/resources/agents.d.ts +32 -0
  72. package/dist/types/resources/agents.d.ts.map +1 -0
  73. package/dist/types/resources/analytics.d.ts +146 -0
  74. package/dist/types/resources/analytics.d.ts.map +1 -0
  75. package/dist/types/resources/api-keys.d.ts +28 -0
  76. package/dist/types/resources/api-keys.d.ts.map +1 -0
  77. package/dist/types/resources/base.d.ts +18 -0
  78. package/dist/types/resources/base.d.ts.map +1 -0
  79. package/dist/types/resources/billing.d.ts +19 -0
  80. package/dist/types/resources/billing.d.ts.map +1 -0
  81. package/dist/types/resources/calls.d.ts +50 -0
  82. package/dist/types/resources/calls.d.ts.map +1 -0
  83. package/dist/types/resources/context-graphs.d.ts +32 -0
  84. package/dist/types/resources/context-graphs.d.ts.map +1 -0
  85. package/dist/types/resources/data-sources.d.ts +24 -0
  86. package/dist/types/resources/data-sources.d.ts.map +1 -0
  87. package/dist/types/resources/integrations.d.ts +38 -0
  88. package/dist/types/resources/integrations.d.ts.map +1 -0
  89. package/dist/types/resources/memory.d.ts +99 -0
  90. package/dist/types/resources/memory.d.ts.map +1 -0
  91. package/dist/types/resources/phone-numbers.d.ts +26 -0
  92. package/dist/types/resources/phone-numbers.d.ts.map +1 -0
  93. package/dist/types/resources/services.d.ts +21 -0
  94. package/dist/types/resources/services.d.ts.map +1 -0
  95. package/dist/types/resources/settings.d.ts +102 -0
  96. package/dist/types/resources/settings.d.ts.map +1 -0
  97. package/dist/types/resources/simulations.d.ts +39 -0
  98. package/dist/types/resources/simulations.d.ts.map +1 -0
  99. package/dist/types/resources/skills.d.ts +31 -0
  100. package/dist/types/resources/skills.d.ts.map +1 -0
  101. package/dist/types/resources/workspaces.d.ts +28 -0
  102. package/dist/types/resources/workspaces.d.ts.map +1 -0
  103. package/dist/types/resources/world.d.ts +177 -0
  104. package/dist/types/resources/world.d.ts.map +1 -0
  105. package/dist/types/types/api.d.ts +739 -0
  106. package/dist/types/types/api.d.ts.map +1 -0
  107. package/package.json +82 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,1005 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AmigoClient: () => AmigoClient,
24
+ AmigoError: () => AmigoError,
25
+ AuthenticationError: () => AuthenticationError,
26
+ BadRequestError: () => BadRequestError,
27
+ ConfigurationError: () => ConfigurationError,
28
+ ConflictError: () => ConflictError,
29
+ DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
30
+ NetworkError: () => NetworkError,
31
+ NotFoundError: () => NotFoundError,
32
+ ParseError: () => ParseError,
33
+ PermissionError: () => PermissionError,
34
+ RateLimitError: () => RateLimitError,
35
+ ServerError: () => ServerError,
36
+ ServiceUnavailableError: () => ServiceUnavailableError,
37
+ ValidationError: () => ValidationError,
38
+ agentId: () => agentId,
39
+ apiKeyId: () => apiKeyId,
40
+ callId: () => callId,
41
+ contextGraphId: () => contextGraphId,
42
+ dataSourceId: () => dataSourceId,
43
+ entityId: () => entityId,
44
+ eventId: () => eventId,
45
+ integrationId: () => integrationId,
46
+ isAmigoError: () => isAmigoError,
47
+ isAuthenticationError: () => isAuthenticationError,
48
+ isNotFoundError: () => isNotFoundError,
49
+ isRateLimitError: () => isRateLimitError,
50
+ paginate: () => paginate,
51
+ phoneNumberId: () => phoneNumberId,
52
+ serviceId: () => serviceId,
53
+ simulationRunId: () => simulationRunId,
54
+ simulationSessionId: () => simulationSessionId,
55
+ skillId: () => skillId,
56
+ workspaceId: () => workspaceId
57
+ });
58
+ module.exports = __toCommonJS(index_exports);
59
+
60
+ // src/core/errors.ts
61
+ var AmigoError = class extends Error {
62
+ statusCode;
63
+ errorCode;
64
+ requestId;
65
+ detail;
66
+ constructor(message, ctx = {}) {
67
+ super(message);
68
+ this.name = this.constructor.name;
69
+ this.statusCode = ctx.statusCode;
70
+ this.errorCode = ctx.errorCode;
71
+ this.requestId = ctx.requestId;
72
+ this.detail = ctx.detail;
73
+ Object.setPrototypeOf(this, new.target.prototype);
74
+ }
75
+ };
76
+ var BadRequestError = class extends AmigoError {
77
+ constructor(message, ctx = {}) {
78
+ super(message, { ...ctx, statusCode: 400 });
79
+ }
80
+ };
81
+ var AuthenticationError = class extends AmigoError {
82
+ constructor(message, ctx = {}) {
83
+ super(message, { ...ctx, statusCode: 401 });
84
+ }
85
+ };
86
+ var PermissionError = class extends AmigoError {
87
+ constructor(message, ctx = {}) {
88
+ super(message, { ...ctx, statusCode: 403 });
89
+ }
90
+ };
91
+ var NotFoundError = class extends AmigoError {
92
+ constructor(message, ctx = {}) {
93
+ super(message, { ...ctx, statusCode: 404 });
94
+ }
95
+ };
96
+ var ConflictError = class extends AmigoError {
97
+ constructor(message, ctx = {}) {
98
+ super(message, { ...ctx, statusCode: 409 });
99
+ }
100
+ };
101
+ var ValidationError = class extends AmigoError {
102
+ constructor(message, ctx = {}) {
103
+ super(message, { ...ctx, statusCode: 422 });
104
+ }
105
+ };
106
+ var RateLimitError = class extends AmigoError {
107
+ retryAfter;
108
+ constructor(message, ctx = {}) {
109
+ super(message, { ...ctx, statusCode: 429 });
110
+ this.retryAfter = ctx.retryAfter;
111
+ }
112
+ };
113
+ var ServerError = class extends AmigoError {
114
+ constructor(message, ctx = {}) {
115
+ super(message, { ...ctx, statusCode: ctx.statusCode ?? 500 });
116
+ }
117
+ };
118
+ var ServiceUnavailableError = class extends ServerError {
119
+ constructor(message, ctx = {}) {
120
+ super(message, { ...ctx, statusCode: 503 });
121
+ }
122
+ };
123
+ var NetworkError = class extends AmigoError {
124
+ constructor(message, cause) {
125
+ super(message);
126
+ if (cause !== void 0) {
127
+ ;
128
+ this.cause = cause;
129
+ }
130
+ }
131
+ };
132
+ var ParseError = class extends AmigoError {
133
+ body;
134
+ constructor(message, body) {
135
+ super(message);
136
+ this.body = body;
137
+ }
138
+ };
139
+ var ConfigurationError = class extends AmigoError {
140
+ constructor(message) {
141
+ super(message);
142
+ }
143
+ };
144
+ async function createApiError(response) {
145
+ let body = {};
146
+ let rawBody;
147
+ try {
148
+ rawBody = await response.text();
149
+ body = JSON.parse(rawBody);
150
+ } catch {
151
+ }
152
+ const ctx = {
153
+ statusCode: response.status,
154
+ errorCode: body.error_code,
155
+ requestId: body.request_id,
156
+ detail: body.detail
157
+ };
158
+ const message = body.message ?? body.detail ?? response.statusText ?? `HTTP ${response.status}`;
159
+ switch (response.status) {
160
+ case 400:
161
+ return new BadRequestError(message, ctx);
162
+ case 401:
163
+ return new AuthenticationError(message, ctx);
164
+ case 403:
165
+ return new PermissionError(message, ctx);
166
+ case 404:
167
+ return new NotFoundError(message, ctx);
168
+ case 409:
169
+ return new ConflictError(message, ctx);
170
+ case 422:
171
+ return new ValidationError(message, ctx);
172
+ case 429: {
173
+ const retryAfter = parseRetryAfter(response);
174
+ return new RateLimitError(message, { ...ctx, retryAfter });
175
+ }
176
+ case 503:
177
+ return new ServiceUnavailableError(message, ctx);
178
+ default:
179
+ return new ServerError(message, ctx);
180
+ }
181
+ }
182
+ function parseRetryAfter(response) {
183
+ const header = response.headers.get("Retry-After");
184
+ if (!header) return void 0;
185
+ const seconds = Number(header);
186
+ if (!isNaN(seconds)) return seconds;
187
+ const date = new Date(header);
188
+ if (!isNaN(date.getTime())) {
189
+ return Math.max(0, Math.ceil((date.getTime() - Date.now()) / 1e3));
190
+ }
191
+ return void 0;
192
+ }
193
+ function isAmigoError(err) {
194
+ return err instanceof AmigoError;
195
+ }
196
+ function isNotFoundError(err) {
197
+ return err instanceof NotFoundError;
198
+ }
199
+ function isRateLimitError(err) {
200
+ return err instanceof RateLimitError;
201
+ }
202
+ function isAuthenticationError(err) {
203
+ return err instanceof AuthenticationError;
204
+ }
205
+
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
227
+ }
228
+ });
229
+ if (!response.ok) {
230
+ throw await createApiError(response);
231
+ }
232
+ if (response.status === 204) return void 0;
233
+ return response.json();
234
+ }
235
+ };
236
+ function buildQuery(params) {
237
+ if (!params) return "";
238
+ const entries = Object.entries(params).filter(
239
+ ([, v]) => v !== void 0 && v !== null
240
+ );
241
+ if (entries.length === 0) return "";
242
+ const searchParams = new URLSearchParams();
243
+ for (const [k, v] of entries) {
244
+ searchParams.set(k, String(v));
245
+ }
246
+ return "?" + searchParams.toString();
247
+ }
248
+
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();
269
+ }
270
+ /** Create a new workspace */
271
+ async create(body) {
272
+ return this.request("", {
273
+ method: "POST",
274
+ body: JSON.stringify(body)
275
+ });
276
+ }
277
+ /** List workspaces accessible to the current API key */
278
+ async list(params) {
279
+ return this.request(buildQuery(params));
280
+ }
281
+ /** Get a single workspace by ID */
282
+ async get(id) {
283
+ return this.request(`/${id}`);
284
+ }
285
+ /** Update workspace metadata */
286
+ async update(id, body) {
287
+ return this.request(`/${id}`, {
288
+ method: "PUT",
289
+ body: JSON.stringify(body)
290
+ });
291
+ }
292
+ /** Archive (soft-delete) a workspace */
293
+ async delete(id) {
294
+ return this.request(`/${id}`, { method: "DELETE" });
295
+ }
296
+ };
297
+
298
+ // src/resources/api-keys.ts
299
+ var ApiKeysResource = class extends WorkspaceScopedResource {
300
+ /**
301
+ * Get info about the currently authenticated API key.
302
+ * Does not require a workspace ID in the path.
303
+ */
304
+ 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();
309
+ }
310
+ /** Create a new API key */
311
+ async create(body) {
312
+ return this.fetch("/api-keys", {
313
+ method: "POST",
314
+ body: JSON.stringify(body)
315
+ });
316
+ }
317
+ /** List API keys in the workspace */
318
+ 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}`);
324
+ }
325
+ /** Revoke an API key */
326
+ async revoke(keyId) {
327
+ return this.fetch(`/api-keys/${keyId}`, { method: "DELETE" });
328
+ }
329
+ /** 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" });
332
+ }
333
+ };
334
+
335
+ // src/resources/agents.ts
336
+ var AgentsResource = class extends WorkspaceScopedResource {
337
+ /** Create a new agent */
338
+ async create(body) {
339
+ return this.fetch("/agents", {
340
+ method: "POST",
341
+ body: JSON.stringify(body)
342
+ });
343
+ }
344
+ /** List agents in the workspace */
345
+ async list(params) {
346
+ return this.fetch(`/agents${buildQuery(params)}`);
347
+ }
348
+ /** Get a single agent */
349
+ async get(agentId2) {
350
+ return this.fetch(`/agents/${agentId2}`);
351
+ }
352
+ /** Update an agent's configuration */
353
+ async update(agentId2, body) {
354
+ return this.fetch(`/agents/${agentId2}`, {
355
+ method: "PUT",
356
+ body: JSON.stringify(body)
357
+ });
358
+ }
359
+ /** Delete an agent */
360
+ async delete(agentId2) {
361
+ return this.fetch(`/agents/${agentId2}`, { method: "DELETE" });
362
+ }
363
+ /** List all versions of an agent */
364
+ async listVersions(agentId2, params) {
365
+ return this.fetch(
366
+ `/agents/${agentId2}/versions${buildQuery(params)}`
367
+ );
368
+ }
369
+ /** Get a specific version of an agent — pass `"latest"` to get the most recent */
370
+ async getVersion(agentId2, version) {
371
+ return this.fetch(`/agents/${agentId2}/versions/${version}`);
372
+ }
373
+ /** Create a new version of an agent */
374
+ async createVersion(agentId2, body) {
375
+ return this.fetch(`/agents/${agentId2}/versions`, {
376
+ method: "POST",
377
+ body: JSON.stringify(body)
378
+ });
379
+ }
380
+ };
381
+
382
+ // src/resources/skills.ts
383
+ var SkillsResource = class extends WorkspaceScopedResource {
384
+ /** Create a new skill */
385
+ async create(body) {
386
+ return this.fetch("/skills", {
387
+ method: "POST",
388
+ body: JSON.stringify(body)
389
+ });
390
+ }
391
+ /** List skills in the workspace */
392
+ async list(params) {
393
+ return this.fetch(`/skills${buildQuery(params)}`);
394
+ }
395
+ /** Get a single skill */
396
+ async get(skillId2) {
397
+ return this.fetch(`/skills/${skillId2}`);
398
+ }
399
+ /** Update a skill */
400
+ async update(skillId2, body) {
401
+ return this.fetch(`/skills/${skillId2}`, {
402
+ method: "PUT",
403
+ body: JSON.stringify(body)
404
+ });
405
+ }
406
+ /** Delete a skill */
407
+ async delete(skillId2) {
408
+ return this.fetch(`/skills/${skillId2}`, { method: "DELETE" });
409
+ }
410
+ /**
411
+ * Test a skill with a sample input.
412
+ * Executes the skill in a sandbox and returns the result.
413
+ */
414
+ async test(skillId2, body) {
415
+ return this.fetch(`/skills/${skillId2}/test`, {
416
+ method: "POST",
417
+ body: JSON.stringify(body)
418
+ });
419
+ }
420
+ };
421
+
422
+ // src/resources/services.ts
423
+ var ServicesResource = class extends WorkspaceScopedResource {
424
+ async create(body) {
425
+ return this.fetch("/services", {
426
+ method: "POST",
427
+ body: JSON.stringify(body)
428
+ });
429
+ }
430
+ async list(params) {
431
+ return this.fetch(`/services${buildQuery(params)}`);
432
+ }
433
+ async get(serviceId2) {
434
+ return this.fetch(`/services/${serviceId2}`);
435
+ }
436
+ async update(serviceId2, body) {
437
+ return this.fetch(`/services/${serviceId2}`, {
438
+ method: "PUT",
439
+ body: JSON.stringify(body)
440
+ });
441
+ }
442
+ async delete(serviceId2) {
443
+ return this.fetch(`/services/${serviceId2}`, { method: "DELETE" });
444
+ }
445
+ };
446
+
447
+ // src/resources/context-graphs.ts
448
+ var ContextGraphsResource = class extends WorkspaceScopedResource {
449
+ async create(body) {
450
+ return this.fetch("/context-graphs", {
451
+ method: "POST",
452
+ body: JSON.stringify(body)
453
+ });
454
+ }
455
+ async list(params) {
456
+ return this.fetch(`/context-graphs${buildQuery(params)}`);
457
+ }
458
+ async get(contextGraphId2) {
459
+ return this.fetch(`/context-graphs/${contextGraphId2}`);
460
+ }
461
+ async update(contextGraphId2, body) {
462
+ return this.fetch(`/context-graphs/${contextGraphId2}`, {
463
+ method: "PUT",
464
+ body: JSON.stringify(body)
465
+ });
466
+ }
467
+ async delete(contextGraphId2) {
468
+ return this.fetch(`/context-graphs/${contextGraphId2}`, { method: "DELETE" });
469
+ }
470
+ /** 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
+ });
475
+ }
476
+ /** List all versions of a context graph */
477
+ async listVersions(contextGraphId2, params) {
478
+ return this.fetch(
479
+ `/context-graphs/${contextGraphId2}/versions${buildQuery(params)}`
480
+ );
481
+ }
482
+ /** Get a specific version */
483
+ async getVersion(contextGraphId2, version) {
484
+ return this.fetch(`/context-graphs/${contextGraphId2}/versions/${version}`);
485
+ }
486
+ };
487
+
488
+ // src/resources/data-sources.ts
489
+ var DataSourcesResource = class extends WorkspaceScopedResource {
490
+ async create(body) {
491
+ return this.fetch("/data-sources", {
492
+ method: "POST",
493
+ body: JSON.stringify(body)
494
+ });
495
+ }
496
+ async list(params) {
497
+ return this.fetch(`/data-sources${buildQuery(params)}`);
498
+ }
499
+ async get(dataSourceId2) {
500
+ return this.fetch(`/data-sources/${dataSourceId2}`);
501
+ }
502
+ async update(dataSourceId2, body) {
503
+ return this.fetch(`/data-sources/${dataSourceId2}`, {
504
+ method: "PUT",
505
+ body: JSON.stringify(body)
506
+ });
507
+ }
508
+ async delete(dataSourceId2) {
509
+ return this.fetch(`/data-sources/${dataSourceId2}`, { method: "DELETE" });
510
+ }
511
+ };
512
+
513
+ // src/resources/world.ts
514
+ var WorldResource = class extends WorkspaceScopedResource {
515
+ // ---- 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
+ /** List entities with optional filtering */
524
+ async listEntities(params) {
525
+ return this.fetch(`/world/entities${buildQuery(params)}`);
526
+ }
527
+ /** Get a single entity */
528
+ 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
+ });
537
+ }
538
+ /** Get all relationships for an entity */
539
+ async getRelationships(entityId2) {
540
+ return this.fetch(`/world/entities/${entityId2}/relationships`);
541
+ }
542
+ /** Get the knowledge graph centered on an entity (entity + neighbors + edges) */
543
+ async getGraph(entityId2) {
544
+ return this.fetch(`/world/entities/${entityId2}/graph`);
545
+ }
546
+ /** Get provenance — which source systems contributed data for an entity */
547
+ async getProvenance(entityId2) {
548
+ return this.fetch(`/world/entities/${entityId2}/provenance`);
549
+ }
550
+ /** Get lineage — merge history and canonical identity for an entity */
551
+ async getLineage(entityId2) {
552
+ return this.fetch(`/world/entities/${entityId2}/lineage`);
553
+ }
554
+ /** Get merged entities for a canonical entity */
555
+ async getMerged(entityId2) {
556
+ return this.fetch(`/world/entities/${entityId2}/merged`);
557
+ }
558
+ // ---- Entity Types ----
559
+ /** List registered entity types with counts and schemas */
560
+ async listEntityTypes() {
561
+ return this.fetch("/world/entity-types");
562
+ }
563
+ // ---- Duplicate Detection ----
564
+ /** List potential duplicate entity pairs for review or merging */
565
+ async listDuplicates(params) {
566
+ return this.fetch(`/world/entities/duplicates${buildQuery(params)}`);
567
+ }
568
+ // ---- Semantic Search ----
569
+ /** Semantic (vector) search over entities */
570
+ 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
+ });
583
+ }
584
+ // ---- Timeline ----
585
+ /** Get the event timeline for an entity (reverse-chronological) */
586
+ 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
+ });
604
+ }
605
+ // ---- Sync ----
606
+ /** Get sync status grouped by sink (Lakebase, Delta, etc.) */
607
+ async getSyncStatusBySink() {
608
+ return this.fetch("/world/sync/by-sink");
609
+ }
610
+ /** List sync events with status filtering */
611
+ async listSyncEvents(params) {
612
+ return this.fetch(`/world/sync/events${buildQuery(params)}`);
613
+ }
614
+ /** Get current sync queue depth */
615
+ async getSyncQueueDepth() {
616
+ return this.fetch("/world/sync/queue");
617
+ }
618
+ /** Retry a single failed sync event */
619
+ async retrySyncEvent(eventId2) {
620
+ return this.fetch(`/world/sync/retry/${eventId2}`, { method: "POST" });
621
+ }
622
+ /** Retry all failed sync events */
623
+ async retryAllSyncEvents() {
624
+ return this.fetch("/world/sync/retry-all", { method: "POST" });
625
+ }
626
+ // ---- Statistics ----
627
+ /** Get aggregate entity and event statistics */
628
+ async getStats() {
629
+ return this.fetch("/world/entity-stats");
630
+ }
631
+ /** Get entity counts broken down by source system */
632
+ async getSourceBreakdown() {
633
+ return this.fetch("/world/source-breakdown");
634
+ }
635
+ };
636
+
637
+ // src/resources/calls.ts
638
+ var CallsResource = class extends WorkspaceScopedResource {
639
+ /** List calls with optional filtering */
640
+ async list(params) {
641
+ return this.fetch(`/calls/${buildQuery(params)}`);
642
+ }
643
+ /** Get full call detail including transcript and intelligence */
644
+ async get(callSid) {
645
+ return this.fetch(`/calls/${callSid}`);
646
+ }
647
+ /** Get AI intelligence for a call */
648
+ async getIntelligence(callSid) {
649
+ return this.fetch(`/calls/${callSid}/intelligence`);
650
+ }
651
+ /** Get active intelligence across all in-progress calls */
652
+ async getActiveIntelligence() {
653
+ return this.fetch("/calls/active/intelligence");
654
+ }
655
+ /** Get performance benchmarks for a time period */
656
+ async getBenchmarks(params) {
657
+ return this.fetch(`/calls/benchmarks${buildQuery(params)}`);
658
+ }
659
+ };
660
+
661
+ // src/resources/phone-numbers.ts
662
+ var PhoneNumbersResource = class extends WorkspaceScopedResource {
663
+ /** Provision a new phone number (area code or specific number) */
664
+ async provision(body) {
665
+ return this.fetch("/phone-numbers", {
666
+ method: "POST",
667
+ body: JSON.stringify(body)
668
+ });
669
+ }
670
+ /** List phone numbers in the workspace */
671
+ async list(params) {
672
+ return this.fetch(`/phone-numbers${buildQuery(params)}`);
673
+ }
674
+ /** Get a phone number */
675
+ async get(phoneNumberId2) {
676
+ return this.fetch(`/phone-numbers/${phoneNumberId2}`);
677
+ }
678
+ /** Update a phone number (assign to agent, rename) */
679
+ async update(phoneNumberId2, body) {
680
+ return this.fetch(`/phone-numbers/${phoneNumberId2}`, {
681
+ method: "PUT",
682
+ body: JSON.stringify(body)
683
+ });
684
+ }
685
+ /** Release a phone number back to the carrier */
686
+ async release(phoneNumberId2) {
687
+ return this.fetch(`/phone-numbers/${phoneNumberId2}`, { method: "DELETE" });
688
+ }
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" }
694
+ );
695
+ }
696
+ };
697
+
698
+ // src/resources/integrations.ts
699
+ var IntegrationsResource = class extends WorkspaceScopedResource {
700
+ /** Create a new integration */
701
+ async create(body) {
702
+ return this.fetch("/integrations", {
703
+ method: "POST",
704
+ body: JSON.stringify(body)
705
+ });
706
+ }
707
+ /** List integrations */
708
+ async list(params) {
709
+ return this.fetch(`/integrations${buildQuery(params)}`);
710
+ }
711
+ /** Get a single integration */
712
+ async get(integrationId2) {
713
+ return this.fetch(`/integrations/${integrationId2}`);
714
+ }
715
+ /** Update integration configuration */
716
+ async update(integrationId2, body) {
717
+ return this.fetch(`/integrations/${integrationId2}`, {
718
+ method: "PUT",
719
+ body: JSON.stringify(body)
720
+ });
721
+ }
722
+ /** Delete an integration */
723
+ async delete(integrationId2) {
724
+ return this.fetch(`/integrations/${integrationId2}`, { method: "DELETE" });
725
+ }
726
+ /**
727
+ * Test a specific endpoint on an integration with given params.
728
+ * Used in the developer console to validate integration config.
729
+ */
730
+ async testEndpoint(integrationId2, endpointName, params) {
731
+ return this.fetch(
732
+ `/integrations/${integrationId2}/endpoints/${endpointName}/test`,
733
+ { method: "POST", body: JSON.stringify({ params }) }
734
+ );
735
+ }
736
+ /** Check health of all integrations in the workspace */
737
+ async getHealthCheck() {
738
+ return this.fetch("/integrations/health-check");
739
+ }
740
+ };
741
+
742
+ // src/resources/analytics.ts
743
+ var AnalyticsResource = class extends WorkspaceScopedResource {
744
+ /** High-level dashboard summary — pass `days` (default: 7) for the lookback window */
745
+ async getDashboard(params) {
746
+ return this.fetch(`/analytics/dashboard${buildQuery(params)}`);
747
+ }
748
+ /** Call volume and duration metrics */
749
+ async getCalls(params) {
750
+ return this.fetch(`/analytics/calls${buildQuery(params)}`);
751
+ }
752
+ /** Per-agent performance breakdown */
753
+ async getAgents(params) {
754
+ return this.fetch(`/analytics/agents${buildQuery(params)}`);
755
+ }
756
+ /** Call quality — sentiment, transcription confidence, flagged calls */
757
+ async getCallQuality(params) {
758
+ return this.fetch(`/analytics/call-quality${buildQuery(params)}`);
759
+ }
760
+ /** Emotion trend data over time */
761
+ async getEmotionTrends(params) {
762
+ return this.fetch(`/analytics/emotion-trends${buildQuery(params)}`);
763
+ }
764
+ /** Voice pipeline latency metrics (TTFB, response time) */
765
+ async getLatency(params) {
766
+ return this.fetch(`/analytics/latency${buildQuery(params)}`);
767
+ }
768
+ /** Tool call performance — success rates and latency per tool */
769
+ async getToolPerformance(params) {
770
+ return this.fetch(`/analytics/tool-performance${buildQuery(params)}`);
771
+ }
772
+ /** Data quality metrics for the workspace world model */
773
+ async getDataQuality(params) {
774
+ return this.fetch(`/analytics/data-quality${buildQuery(params)}`);
775
+ }
776
+ /** Usage summary — API requests, call minutes, storage */
777
+ async getUsage(params) {
778
+ return this.fetch(`/analytics/usage${buildQuery(params)}`);
779
+ }
780
+ /** Advanced call statistics (abandonment, transfers, silence, hour-of-day) */
781
+ async getAdvancedCallStats(params) {
782
+ return this.fetch(`/analytics/calls/advanced${buildQuery(params)}`);
783
+ }
784
+ /** Compare two time periods side by side */
785
+ async compareCallPeriods(params) {
786
+ return this.fetch(`/analytics/calls/comparison${buildQuery(params)}`);
787
+ }
788
+ };
789
+
790
+ // src/resources/simulations.ts
791
+ var SimulationsResource = class extends WorkspaceScopedResource {
792
+ /** Start a simulation session — returns the agent's greeting and initial snapshot */
793
+ async createSession(body) {
794
+ return this.fetch("/simulations/sessions", {
795
+ method: "POST",
796
+ body: JSON.stringify(body)
797
+ });
798
+ }
799
+ /** Get the current snapshot of a session */
800
+ async getSession(sessionId) {
801
+ return this.fetch(`/simulations/sessions/${sessionId}`);
802
+ }
803
+ /** Delete a simulation session */
804
+ async deleteSession(sessionId) {
805
+ return this.fetch(`/simulations/sessions/${sessionId}`, { method: "DELETE" });
806
+ }
807
+ /**
808
+ * Send a caller utterance and advance the session by one turn.
809
+ * Returns the agent's response observation and updated snapshot.
810
+ */
811
+ async step(body) {
812
+ return this.fetch("/simulations/sessions/step", {
813
+ method: "POST",
814
+ body: JSON.stringify(body)
815
+ });
816
+ }
817
+ /**
818
+ * Get LLM-generated caller message suggestions for the current session state.
819
+ * Helps exploratory testing by suggesting realistic next caller turns.
820
+ */
821
+ async recommend(sessionId, n) {
822
+ return this.fetch("/simulations/sessions/recommend", {
823
+ method: "POST",
824
+ body: JSON.stringify({ session_id: sessionId, n })
825
+ });
826
+ }
827
+ /** Get AI-generated call intelligence for a completed session */
828
+ async getIntelligence(sessionId) {
829
+ return this.fetch(`/simulations/sessions/${sessionId}/intelligence`);
830
+ }
831
+ };
832
+
833
+ // src/resources/settings.ts
834
+ 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
+ voice = {
845
+ get: () => this.getSettings("voice"),
846
+ update: (body) => this.updateSettings("voice", body)
847
+ };
848
+ branding = {
849
+ get: () => this.getSettings("branding"),
850
+ update: (body) => this.updateSettings("branding", body)
851
+ };
852
+ outreach = {
853
+ get: () => this.getSettings("outreach"),
854
+ update: (body) => this.updateSettings("outreach", body)
855
+ };
856
+ memory = {
857
+ get: () => this.getSettings("memory"),
858
+ update: (body) => this.updateSettings("memory", body)
859
+ };
860
+ security = {
861
+ get: () => this.getSettings("security"),
862
+ update: (body) => this.updateSettings("security", body)
863
+ };
864
+ retention = {
865
+ get: () => this.getSettings("retention"),
866
+ update: (body) => this.updateSettings("retention", body)
867
+ };
868
+ workflows = {
869
+ get: () => this.getSettings("workflows"),
870
+ update: (body) => this.updateSettings("workflows", body)
871
+ };
872
+ };
873
+
874
+ // src/resources/billing.ts
875
+ 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)}`);
879
+ }
880
+ /** List invoices */
881
+ async listInvoices(params) {
882
+ return this.fetch(`/billing/invoices${buildQuery(params)}`);
883
+ }
884
+ };
885
+
886
+ // src/resources/memory.ts
887
+ var MemoryResource = class extends WorkspaceScopedResource {
888
+ /**
889
+ * Get all memory dimension scores for an entity.
890
+ * Scores reflect how complete and confident each dimension's facts are.
891
+ */
892
+ async getEntityDimensions(entityId2) {
893
+ return this.fetch(`/memory/${entityId2}/dimensions`);
894
+ }
895
+ /**
896
+ * Get individual memory facts for an entity, optionally filtered by dimension.
897
+ */
898
+ async getEntityFacts(entityId2, params) {
899
+ return this.fetch(`/memory/${entityId2}/facts${buildQuery(params)}`);
900
+ }
901
+ /**
902
+ * Get workspace-level memory analytics — coverage rates, dimension health,
903
+ * and fact ingestion trends.
904
+ */
905
+ async getAnalytics() {
906
+ return this.fetch("/memory/analytics");
907
+ }
908
+ };
909
+
910
+ // src/core/branded-types.ts
911
+ var workspaceId = (id) => id;
912
+ var apiKeyId = (id) => id;
913
+ var agentId = (id) => id;
914
+ var skillId = (id) => id;
915
+ var serviceId = (id) => id;
916
+ var contextGraphId = (id) => id;
917
+ var callId = (id) => id;
918
+ var phoneNumberId = (id) => id;
919
+ var integrationId = (id) => id;
920
+ var entityId = (id) => id;
921
+ var eventId = (id) => id;
922
+ var simulationRunId = (id) => id;
923
+ var simulationSessionId = (id) => id;
924
+ var dataSourceId = (id) => id;
925
+
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;
936
+ }
937
+ }
938
+
939
+ // src/index.ts
940
+ var DEFAULT_BASE_URL = "https://api.platform.amigo.ai";
941
+ var AmigoClient = class {
942
+ /** Workspace management */
943
+ workspaces;
944
+ /** API key management */
945
+ apiKeys;
946
+ /** Agent management — AI agents that handle calls */
947
+ agents;
948
+ /** Skill management — reusable AI capabilities */
949
+ skills;
950
+ /** Service management — external service configurations */
951
+ services;
952
+ /** Context graph management — conversation flow structures */
953
+ contextGraphs;
954
+ /** Data source management — external data connections */
955
+ dataSources;
956
+ /** World model — entities, events, and timelines */
957
+ world;
958
+ /** Call records and intelligence */
959
+ calls;
960
+ /** Phone number provisioning and management */
961
+ phoneNumbers;
962
+ /** Integration management — EHR, CRM, and other external systems */
963
+ integrations;
964
+ /** Analytics — aggregate metrics about calls and conversions */
965
+ analytics;
966
+ /** Simulation runs and interactive testing sessions */
967
+ simulations;
968
+ /** Workspace-level settings (voice, branding, security, outreach, etc.) */
969
+ settings;
970
+ /** Billing — usage summaries and invoices */
971
+ billing;
972
+ /** Agent Memory — structured long-term memory for entities */
973
+ memory;
974
+ constructor(config) {
975
+ if (!config.apiKey || typeof config.apiKey !== "string") {
976
+ throw new ConfigurationError("apiKey is required and must be a non-empty string");
977
+ }
978
+ if (!config.workspaceId || typeof config.workspaceId !== "string") {
979
+ throw new ConfigurationError("workspaceId is required and must be a non-empty string");
980
+ }
981
+ const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
982
+ const rc = {
983
+ apiKey: config.apiKey,
984
+ 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);
1003
+ }
1004
+ };
1005
+ //# sourceMappingURL=index.cjs.map