@amigo-ai/sdk 1.0.0 → 1.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 (32) hide show
  1. package/README.md +50 -37
  2. package/dist/index.cjs.map +2 -2
  3. package/dist/index.mjs.map +2 -2
  4. package/dist/platform.cjs +1754 -0
  5. package/dist/platform.cjs.map +7 -0
  6. package/dist/platform.mjs +1723 -0
  7. package/dist/platform.mjs.map +7 -0
  8. package/dist/types/core/utils.d.ts +11 -0
  9. package/dist/types/generated/api-types.d.ts +1 -1
  10. package/dist/types/generated/platform-api-types.d.ts +45240 -0
  11. package/dist/types/platform/core/auth.d.ts +6 -0
  12. package/dist/types/platform/core/branded-types.d.ts +59 -0
  13. package/dist/types/platform/core/openapi-client.d.ts +6 -0
  14. package/dist/types/platform/core/websocket.d.ts +8 -0
  15. package/dist/types/platform/index.d.ts +59 -0
  16. package/dist/types/platform/resources/agents.d.ts +107 -0
  17. package/dist/types/platform/resources/api-keys.d.ts +57 -0
  18. package/dist/types/platform/resources/context-graphs.d.ts +114 -0
  19. package/dist/types/platform/resources/conversations.d.ts +154 -0
  20. package/dist/types/platform/resources/data-sources.d.ts +143 -0
  21. package/dist/types/platform/resources/events.d.ts +253 -0
  22. package/dist/types/platform/resources/fhir.d.ts +186 -0
  23. package/dist/types/platform/resources/integrations.d.ts +114 -0
  24. package/dist/types/platform/resources/phone-numbers.d.ts +170 -0
  25. package/dist/types/platform/resources/services.d.ts +133 -0
  26. package/dist/types/platform/resources/sessions.d.ts +61 -0
  27. package/dist/types/platform/resources/skills.d.ts +169 -0
  28. package/dist/types/platform/resources/workspaces.d.ts +187 -0
  29. package/package.json +15 -11
  30. package/assets/readme/amigo-banner.png +0 -0
  31. package/assets/readme/classic-ts-architecture.png +0 -0
  32. package/assets/readme/classic-ts-architecture.svg +0 -102
@@ -0,0 +1,1754 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
+
32
+ // src/platform/index.ts
33
+ var index_exports = {};
34
+ __export(index_exports, {
35
+ AmigoError: () => AmigoError,
36
+ AuthenticationError: () => AuthenticationError,
37
+ BadRequestError: () => BadRequestError,
38
+ ConfigurationError: () => ConfigurationError,
39
+ ConflictError: () => ConflictError,
40
+ NetworkError: () => NetworkError,
41
+ NotFoundError: () => NotFoundError,
42
+ ParseError: () => ParseError,
43
+ PermissionError: () => PermissionError,
44
+ PlatformClient: () => PlatformClient,
45
+ RateLimitError: () => RateLimitError,
46
+ ServerError: () => ServerError,
47
+ ServiceUnavailableError: () => ServiceUnavailableError,
48
+ ValidationError: () => ValidationError,
49
+ callSid: () => callSid,
50
+ contextGraphId: () => contextGraphId,
51
+ createPlatformFetch: () => createPlatformFetch,
52
+ dataSourceId: () => dataSourceId,
53
+ entityId: () => entityId,
54
+ integrationId: () => integrationId,
55
+ isAmigoError: () => isAmigoError,
56
+ monitorConceptId: () => monitorConceptId,
57
+ operatorId: () => operatorId,
58
+ phoneNumberId: () => phoneNumberId,
59
+ platformAgentId: () => platformAgentId,
60
+ platformApiKeyId: () => platformApiKeyId,
61
+ platformConversationId: () => platformConversationId,
62
+ platformServiceId: () => platformServiceId,
63
+ reviewItemId: () => reviewItemId,
64
+ skillId: () => skillId,
65
+ taskId: () => taskId,
66
+ unificationRuleId: () => unificationRuleId,
67
+ workspaceId: () => workspaceId
68
+ });
69
+ module.exports = __toCommonJS(index_exports);
70
+
71
+ // src/core/utils.ts
72
+ async function extractData(responsePromise) {
73
+ const result = await responsePromise;
74
+ const data = result.data;
75
+ if (data === void 0 || data === null) {
76
+ throw new ParseError("Expected response data to be present for successful request", "response");
77
+ }
78
+ return data;
79
+ }
80
+ async function* parseSseStream(response) {
81
+ const body = response.body;
82
+ if (!body) return;
83
+ const reader = body.getReader();
84
+ const decoder = new TextDecoder();
85
+ let bufferedText = "";
86
+ let eventId;
87
+ let eventName;
88
+ let retry;
89
+ let dataLines = [];
90
+ const flushEvent = function* () {
91
+ if (dataLines.length === 0) {
92
+ eventName = void 0;
93
+ retry = void 0;
94
+ return;
95
+ }
96
+ const rawData = dataLines.join("\n");
97
+ let data = rawData;
98
+ try {
99
+ data = JSON.parse(rawData);
100
+ } catch {
101
+ }
102
+ const event = { data };
103
+ if (eventId !== void 0) event.id = eventId;
104
+ if (eventName !== void 0) event.event = eventName;
105
+ if (retry !== void 0) event.retry = retry;
106
+ eventName = void 0;
107
+ retry = void 0;
108
+ dataLines = [];
109
+ yield event;
110
+ };
111
+ const processLine = function* (line) {
112
+ if (line === "") {
113
+ yield* flushEvent();
114
+ return;
115
+ }
116
+ if (line.startsWith(":")) return;
117
+ const colonIndex = line.indexOf(":");
118
+ const field = colonIndex === -1 ? line : line.slice(0, colonIndex);
119
+ const value = colonIndex === -1 ? "" : line.slice(colonIndex + 1).replace(/^ /, "");
120
+ switch (field) {
121
+ case "id":
122
+ eventId = value;
123
+ break;
124
+ case "event":
125
+ eventName = value;
126
+ break;
127
+ case "data":
128
+ dataLines.push(value);
129
+ break;
130
+ case "retry": {
131
+ const retryMs = Number.parseInt(value, 10);
132
+ if (!Number.isNaN(retryMs)) retry = retryMs;
133
+ break;
134
+ }
135
+ }
136
+ };
137
+ try {
138
+ while (true) {
139
+ const { done, value } = await reader.read();
140
+ if (done) break;
141
+ bufferedText += decoder.decode(value, { stream: true });
142
+ let newlineIndex;
143
+ while ((newlineIndex = bufferedText.search(/\r?\n/)) !== -1) {
144
+ const line = bufferedText.slice(0, newlineIndex);
145
+ const newlineLength = bufferedText[newlineIndex] === "\r" && bufferedText[newlineIndex + 1] === "\n" ? 2 : 1;
146
+ bufferedText = bufferedText.slice(newlineIndex + newlineLength);
147
+ yield* processLine(line);
148
+ }
149
+ }
150
+ const trailing = bufferedText.trimEnd();
151
+ if (trailing) {
152
+ yield* processLine(trailing);
153
+ }
154
+ yield* flushEvent();
155
+ } finally {
156
+ reader.releaseLock();
157
+ }
158
+ }
159
+ async function parseResponseBody(response) {
160
+ try {
161
+ const text = await response.text();
162
+ if (!text) return void 0;
163
+ try {
164
+ return JSON.parse(text);
165
+ } catch {
166
+ return text;
167
+ }
168
+ } catch {
169
+ return void 0;
170
+ }
171
+ }
172
+ function isNetworkError(error) {
173
+ if (!(error instanceof Error)) return false;
174
+ return error instanceof TypeError || error.message.includes("fetch") || error.message.includes("Failed to fetch") || error.message.includes("Network request failed") || error.message.includes("ECONNREFUSED") || error.message.includes("ETIMEDOUT") || error.message.includes("ENOTFOUND") || error.message.includes("network");
175
+ }
176
+
177
+ // src/core/errors.ts
178
+ var SENSITIVE_FIELDS = /* @__PURE__ */ new Set([
179
+ "id_token",
180
+ "access_token",
181
+ "refresh_token",
182
+ "authorization",
183
+ "api_key",
184
+ "apikey",
185
+ "token",
186
+ "secret",
187
+ "password",
188
+ "x-api-key"
189
+ ]);
190
+ function sanitizeErrorContext(obj) {
191
+ if (obj === null || obj === void 0) return obj;
192
+ if (typeof obj !== "object") return obj;
193
+ if (Array.isArray(obj)) return obj.map(sanitizeErrorContext);
194
+ const result = {};
195
+ for (const [key, value] of Object.entries(obj)) {
196
+ if (SENSITIVE_FIELDS.has(key.toLowerCase())) {
197
+ result[key] = "[REDACTED]";
198
+ } else if (typeof value === "object" && value !== null) {
199
+ result[key] = sanitizeErrorContext(value);
200
+ } else {
201
+ result[key] = value;
202
+ }
203
+ }
204
+ return result;
205
+ }
206
+ var AmigoError = class extends Error {
207
+ constructor(message, options) {
208
+ super(message);
209
+ /** Unique error code for programmatic error handling */
210
+ __publicField(this, "errorCode");
211
+ /** HTTP status code if applicable */
212
+ __publicField(this, "statusCode");
213
+ /** Additional context data */
214
+ __publicField(this, "context");
215
+ this.name = this.constructor.name;
216
+ Object.setPrototypeOf(this, new.target.prototype);
217
+ if (Error.captureStackTrace) {
218
+ Error.captureStackTrace(this, this.constructor);
219
+ }
220
+ this.statusCode = options?.statusCode;
221
+ this.errorCode = options?.errorCode;
222
+ this.context = options?.context;
223
+ }
224
+ /**
225
+ * Returns a JSON-serializable representation of the error.
226
+ * Sensitive fields (tokens, keys) are redacted to prevent leakage.
227
+ */
228
+ toJSON() {
229
+ return {
230
+ name: this.name,
231
+ message: this.message,
232
+ code: this.errorCode,
233
+ statusCode: this.statusCode,
234
+ context: sanitizeErrorContext(this.context),
235
+ stack: this.stack
236
+ };
237
+ }
238
+ };
239
+ var BadRequestError = class extends AmigoError {
240
+ };
241
+ var AuthenticationError = class extends AmigoError {
242
+ };
243
+ var PermissionError = class extends AmigoError {
244
+ };
245
+ var NotFoundError = class extends AmigoError {
246
+ };
247
+ var ConflictError = class extends AmigoError {
248
+ };
249
+ var RateLimitError = class extends AmigoError {
250
+ };
251
+ var ServerError = class extends AmigoError {
252
+ };
253
+ var ServiceUnavailableError = class extends ServerError {
254
+ };
255
+ var ConfigurationError = class extends AmigoError {
256
+ constructor(message, field) {
257
+ super(message, { context: { field } });
258
+ this.field = field;
259
+ }
260
+ };
261
+ var ValidationError = class extends BadRequestError {
262
+ constructor(msg, fieldErrors) {
263
+ super(msg);
264
+ this.fieldErrors = fieldErrors;
265
+ }
266
+ };
267
+ var NetworkError = class extends AmigoError {
268
+ constructor(message, originalError, request) {
269
+ super(message, { context: { request } });
270
+ this.originalError = originalError;
271
+ this.request = request;
272
+ }
273
+ };
274
+ var ParseError = class extends AmigoError {
275
+ constructor(message, parseType, originalError) {
276
+ super(message, { context: { parseType } });
277
+ this.parseType = parseType;
278
+ this.originalError = originalError;
279
+ }
280
+ };
281
+ function isAmigoError(error) {
282
+ return error instanceof AmigoError;
283
+ }
284
+ function createApiError(response, body) {
285
+ const map = {
286
+ 400: BadRequestError,
287
+ 401: AuthenticationError,
288
+ 403: PermissionError,
289
+ 404: NotFoundError,
290
+ 409: ConflictError,
291
+ 422: ValidationError,
292
+ 429: RateLimitError,
293
+ 500: ServerError,
294
+ 503: ServiceUnavailableError
295
+ };
296
+ const errorMessageKeys = ["message", "error", "detail"];
297
+ const ErrorClass = map[response.status] ?? AmigoError;
298
+ let message = `HTTP ${response.status} ${response.statusText}`;
299
+ if (body && typeof body === "object") {
300
+ for (const key of errorMessageKeys) {
301
+ if (key in body) {
302
+ message = String(body[key]);
303
+ break;
304
+ }
305
+ }
306
+ }
307
+ const error = new ErrorClass(message, {
308
+ statusCode: response.status,
309
+ errorCode: body && typeof body === "object" && "code" in body ? String(body.code) : void 0,
310
+ context: { response: sanitizeErrorContext(body) }
311
+ });
312
+ return error;
313
+ }
314
+ function createErrorMiddleware() {
315
+ return {
316
+ onResponse: async ({ response }) => {
317
+ if (!response.ok) {
318
+ const body = await parseResponseBody(response);
319
+ throw createApiError(response, body);
320
+ }
321
+ },
322
+ onError: async ({ error, request }) => {
323
+ if (isNetworkError(error)) {
324
+ throw new NetworkError(
325
+ `Network error: ${error instanceof Error ? error.message : String(error)}`,
326
+ error instanceof Error ? error : new Error(String(error)),
327
+ {
328
+ url: request?.url,
329
+ method: request?.method
330
+ }
331
+ );
332
+ }
333
+ throw error;
334
+ }
335
+ };
336
+ }
337
+
338
+ // src/platform/core/openapi-client.ts
339
+ var import_openapi_fetch = __toESM(require("openapi-fetch"), 1);
340
+
341
+ // src/platform/core/auth.ts
342
+ function createPlatformAuthMiddleware(apiKey) {
343
+ return {
344
+ onRequest: async ({ request }) => {
345
+ request.headers.set("Authorization", `Bearer ${apiKey}`);
346
+ return request;
347
+ }
348
+ };
349
+ }
350
+
351
+ // src/core/retry.ts
352
+ var DEFAULT_RETRYABLE_STATUS = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
353
+ var DEFAULT_RETRYABLE_METHODS = /* @__PURE__ */ new Set(["GET"]);
354
+ function resolveRetryOptions(options) {
355
+ return {
356
+ maxAttempts: options?.maxAttempts ?? 3,
357
+ backoffBaseMs: options?.backoffBaseMs ?? 250,
358
+ maxDelayMs: options?.maxDelayMs ?? 3e4,
359
+ retryOnStatus: new Set(options?.retryOnStatus ?? DEFAULT_RETRYABLE_STATUS),
360
+ retryOnMethods: new Set(options?.retryOnMethods ?? DEFAULT_RETRYABLE_METHODS)
361
+ };
362
+ }
363
+ function clamp(value, min, max) {
364
+ return Math.max(min, Math.min(max, value));
365
+ }
366
+ function parseRetryAfterMs(headerValue, maxDelayMs) {
367
+ if (!headerValue) return null;
368
+ const seconds = Number(headerValue);
369
+ if (Number.isFinite(seconds)) {
370
+ return clamp(seconds * 1e3, 0, maxDelayMs);
371
+ }
372
+ const date = new Date(headerValue);
373
+ const ms = date.getTime() - Date.now();
374
+ if (Number.isFinite(ms)) {
375
+ return clamp(ms, 0, maxDelayMs);
376
+ }
377
+ return null;
378
+ }
379
+ function computeBackoffWithJitterMs(attemptIndexZeroBased, baseMs, capMs) {
380
+ const windowMs = Math.min(capMs, baseMs * Math.pow(2, attemptIndexZeroBased));
381
+ return Math.random() * windowMs;
382
+ }
383
+ function isAbortError(err) {
384
+ return typeof err === "object" && err !== null && "name" in err && err["name"] === "AbortError";
385
+ }
386
+ function isNetworkError2(err) {
387
+ return err instanceof TypeError && !isAbortError(err);
388
+ }
389
+ async function abortableSleep(ms, signal) {
390
+ if (ms <= 0) {
391
+ signal?.throwIfAborted?.();
392
+ return;
393
+ }
394
+ await new Promise((resolve, reject) => {
395
+ const rejectWith = signal?.reason instanceof Error ? signal.reason : signal?.reason ?? new Error("AbortError");
396
+ if (signal?.aborted) {
397
+ reject(rejectWith);
398
+ return;
399
+ }
400
+ const t = setTimeout(() => {
401
+ off();
402
+ resolve();
403
+ }, ms);
404
+ const onAbort = () => {
405
+ off();
406
+ clearTimeout(t);
407
+ reject(rejectWith);
408
+ };
409
+ const off = () => signal?.removeEventListener("abort", onAbort);
410
+ signal?.addEventListener("abort", onAbort, { once: true });
411
+ });
412
+ }
413
+ function createRetryingFetch(retryOptions, baseFetch) {
414
+ const resolved = resolveRetryOptions(retryOptions);
415
+ const underlying = baseFetch ?? globalThis.fetch;
416
+ const retryingFetch = async (input, init) => {
417
+ const inputMethod = typeof Request !== "undefined" && input instanceof Request ? input.method : void 0;
418
+ const method = (init?.method ?? inputMethod ?? "GET").toUpperCase();
419
+ const signal = init?.signal;
420
+ const isMethodRetryableByDefault = resolved.retryOnMethods.has(method);
421
+ const maxAttempts = Math.max(1, resolved.maxAttempts);
422
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
423
+ let response = null;
424
+ let error = null;
425
+ try {
426
+ response = await underlying(input, init);
427
+ } catch (err) {
428
+ error = err;
429
+ }
430
+ if (!error && response && response.ok) {
431
+ return response;
432
+ }
433
+ let shouldRetry = false;
434
+ let delayMs = null;
435
+ if (isNetworkError2(error)) {
436
+ shouldRetry = isMethodRetryableByDefault;
437
+ if (shouldRetry) {
438
+ delayMs = computeBackoffWithJitterMs(
439
+ attempt - 1,
440
+ resolved.backoffBaseMs,
441
+ resolved.maxDelayMs
442
+ );
443
+ }
444
+ } else if (response) {
445
+ const status = response.status;
446
+ if (method === "POST") {
447
+ if (status === 429) {
448
+ const ra = response.headers.get("Retry-After");
449
+ const parsed = parseRetryAfterMs(ra, resolved.maxDelayMs);
450
+ if (parsed !== null) {
451
+ shouldRetry = true;
452
+ delayMs = parsed;
453
+ }
454
+ }
455
+ } else if (isMethodRetryableByDefault && resolved.retryOnStatus.has(status)) {
456
+ const ra = response.headers.get("Retry-After");
457
+ delayMs = parseRetryAfterMs(ra, resolved.maxDelayMs) ?? computeBackoffWithJitterMs(attempt - 1, resolved.backoffBaseMs, resolved.maxDelayMs);
458
+ shouldRetry = true;
459
+ }
460
+ }
461
+ const attemptsRemain = attempt < maxAttempts;
462
+ if (!shouldRetry || !attemptsRemain) {
463
+ if (error) throw error;
464
+ return response;
465
+ }
466
+ if (signal?.aborted) {
467
+ if (error) throw error;
468
+ return response;
469
+ }
470
+ await abortableSleep(delayMs ?? 0, signal ?? void 0);
471
+ }
472
+ throw new Error("Retry loop exited unexpectedly");
473
+ };
474
+ return retryingFetch;
475
+ }
476
+
477
+ // src/platform/core/openapi-client.ts
478
+ var createClient = typeof import_openapi_fetch.default === "function" ? import_openapi_fetch.default : import_openapi_fetch.default.default;
479
+ function createPlatformFetch(config, mockFetch) {
480
+ const wrappedFetch = createRetryingFetch(
481
+ config.retry,
482
+ mockFetch ?? config.fetch ?? globalThis.fetch
483
+ );
484
+ const client = createClient({
485
+ baseUrl: config.baseUrl,
486
+ fetch: wrappedFetch
487
+ });
488
+ client.use(createErrorMiddleware());
489
+ client.use(createPlatformAuthMiddleware(config.apiKey));
490
+ return client;
491
+ }
492
+
493
+ // src/platform/core/websocket.ts
494
+ function webSocketBaseFromHttpBase(baseUrl) {
495
+ const url = new URL(baseUrl);
496
+ if (url.protocol === "https:") {
497
+ url.protocol = "wss:";
498
+ } else if (url.protocol === "http:") {
499
+ url.protocol = "ws:";
500
+ } else if (url.protocol !== "ws:" && url.protocol !== "wss:") {
501
+ throw new ConfigurationError(`Unsupported Platform API protocol: ${url.protocol}`, "baseUrl");
502
+ }
503
+ return url.toString().replace(/\/$/, "");
504
+ }
505
+ function getWebSocketConstructor(override) {
506
+ if (override) return override;
507
+ if (typeof globalThis.WebSocket === "function") {
508
+ return globalThis.WebSocket;
509
+ }
510
+ throw new ConfigurationError(
511
+ "WebSocket is not available in this runtime; pass WebSocket in the PlatformClient config",
512
+ "WebSocket"
513
+ );
514
+ }
515
+
516
+ // src/platform/resources/agents.ts
517
+ var PlatformAgentResource = class {
518
+ constructor(c, workspaceId2) {
519
+ this.c = c;
520
+ this.workspaceId = workspaceId2;
521
+ }
522
+ /** List agents in the workspace. */
523
+ async list(options) {
524
+ return extractData(
525
+ this.c.GET("/v1/{workspace_id}/agents", {
526
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
527
+ })
528
+ );
529
+ }
530
+ /** Get an agent by ID. */
531
+ async get(options) {
532
+ return extractData(
533
+ this.c.GET("/v1/{workspace_id}/agents/{agent_id}", {
534
+ params: { path: { workspace_id: this.workspaceId, agent_id: options.agentId } }
535
+ })
536
+ );
537
+ }
538
+ /** Create a new agent. */
539
+ async create(options) {
540
+ return extractData(
541
+ this.c.POST("/v1/{workspace_id}/agents", {
542
+ params: { path: { workspace_id: this.workspaceId } },
543
+ body: options.body
544
+ })
545
+ );
546
+ }
547
+ /** Update an agent. */
548
+ async update(options) {
549
+ return extractData(
550
+ this.c.PUT("/v1/{workspace_id}/agents/{agent_id}", {
551
+ params: { path: { workspace_id: this.workspaceId, agent_id: options.agentId } },
552
+ body: options.body
553
+ })
554
+ );
555
+ }
556
+ /** Delete an agent. */
557
+ async delete(options) {
558
+ await this.c.DELETE("/v1/{workspace_id}/agents/{agent_id}", {
559
+ params: { path: { workspace_id: this.workspaceId, agent_id: options.agentId } }
560
+ });
561
+ return void 0;
562
+ }
563
+ /** List agent versions. */
564
+ async listVersions(options) {
565
+ return extractData(
566
+ this.c.GET("/v1/{workspace_id}/agents/{agent_id}/versions", {
567
+ params: {
568
+ path: { workspace_id: this.workspaceId, agent_id: options.agentId },
569
+ query: options.query
570
+ }
571
+ })
572
+ );
573
+ }
574
+ /** Get a specific agent version, or pass `"latest"` for the most recent version. */
575
+ async getVersion(options) {
576
+ return extractData(
577
+ this.c.GET("/v1/{workspace_id}/agents/{agent_id}/versions/{version}", {
578
+ params: {
579
+ path: {
580
+ workspace_id: this.workspaceId,
581
+ agent_id: options.agentId,
582
+ version: options.version
583
+ }
584
+ }
585
+ })
586
+ );
587
+ }
588
+ /** Create a new agent version. */
589
+ async createVersion(options) {
590
+ return extractData(
591
+ this.c.POST("/v1/{workspace_id}/agents/{agent_id}/versions", {
592
+ params: { path: { workspace_id: this.workspaceId, agent_id: options.agentId } },
593
+ body: options.body
594
+ })
595
+ );
596
+ }
597
+ };
598
+
599
+ // src/platform/resources/api-keys.ts
600
+ var PlatformApiKeyResource = class {
601
+ constructor(c, workspaceId2) {
602
+ this.c = c;
603
+ this.workspaceId = workspaceId2;
604
+ }
605
+ /** Get information about the currently authenticated API key. */
606
+ async me() {
607
+ return extractData(this.c.GET("/v1/auth/me"));
608
+ }
609
+ /** List API keys in the workspace. */
610
+ async list(options) {
611
+ return extractData(
612
+ this.c.GET("/v1/{workspace_id}/api-keys", {
613
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
614
+ })
615
+ );
616
+ }
617
+ /** Create a new API key. */
618
+ async create(options) {
619
+ return extractData(
620
+ this.c.POST("/v1/{workspace_id}/api-keys", {
621
+ params: { path: { workspace_id: this.workspaceId } },
622
+ body: options.body
623
+ })
624
+ );
625
+ }
626
+ /** Delete an API key. */
627
+ async delete(options) {
628
+ await this.c.DELETE("/v1/{workspace_id}/api-keys/{key_id}", {
629
+ params: { path: { workspace_id: this.workspaceId, key_id: options.keyId } }
630
+ });
631
+ return void 0;
632
+ }
633
+ /** Rotate an API key and return the replacement secret. */
634
+ async rotate(options) {
635
+ return extractData(
636
+ this.c.POST("/v1/{workspace_id}/api-keys/{key_id}/rotate", {
637
+ params: { path: { workspace_id: this.workspaceId, key_id: options.keyId } },
638
+ body: options.body
639
+ })
640
+ );
641
+ }
642
+ };
643
+
644
+ // src/platform/resources/context-graphs.ts
645
+ var ContextGraphResource = class {
646
+ constructor(c, workspaceId2) {
647
+ this.c = c;
648
+ this.workspaceId = workspaceId2;
649
+ }
650
+ /** List context graphs in the workspace. */
651
+ async list(options) {
652
+ return extractData(
653
+ this.c.GET("/v1/{workspace_id}/context-graphs", {
654
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
655
+ })
656
+ );
657
+ }
658
+ /** Get a context graph by ID. */
659
+ async get(options) {
660
+ return extractData(
661
+ this.c.GET("/v1/{workspace_id}/context-graphs/{context_graph_id}", {
662
+ params: {
663
+ path: {
664
+ workspace_id: this.workspaceId,
665
+ context_graph_id: options.contextGraphId
666
+ }
667
+ }
668
+ })
669
+ );
670
+ }
671
+ /** Create a new context graph. */
672
+ async create(options) {
673
+ return extractData(
674
+ this.c.POST("/v1/{workspace_id}/context-graphs", {
675
+ params: { path: { workspace_id: this.workspaceId } },
676
+ body: options.body
677
+ })
678
+ );
679
+ }
680
+ /** Update a context graph. */
681
+ async update(options) {
682
+ return extractData(
683
+ this.c.PUT("/v1/{workspace_id}/context-graphs/{context_graph_id}", {
684
+ params: {
685
+ path: {
686
+ workspace_id: this.workspaceId,
687
+ context_graph_id: options.contextGraphId
688
+ }
689
+ },
690
+ body: options.body
691
+ })
692
+ );
693
+ }
694
+ /** Delete a context graph. */
695
+ async delete(options) {
696
+ await this.c.DELETE("/v1/{workspace_id}/context-graphs/{context_graph_id}", {
697
+ params: {
698
+ path: {
699
+ workspace_id: this.workspaceId,
700
+ context_graph_id: options.contextGraphId
701
+ }
702
+ }
703
+ });
704
+ return void 0;
705
+ }
706
+ /** List context graph versions. */
707
+ async listVersions(options) {
708
+ return extractData(
709
+ this.c.GET("/v1/{workspace_id}/context-graphs/{context_graph_id}/versions", {
710
+ params: {
711
+ path: {
712
+ workspace_id: this.workspaceId,
713
+ context_graph_id: options.contextGraphId
714
+ },
715
+ query: options.query
716
+ }
717
+ })
718
+ );
719
+ }
720
+ /** Get a specific context graph version. */
721
+ async getVersion(options) {
722
+ return extractData(
723
+ this.c.GET("/v1/{workspace_id}/context-graphs/{context_graph_id}/versions/{version}", {
724
+ params: {
725
+ path: {
726
+ workspace_id: this.workspaceId,
727
+ context_graph_id: options.contextGraphId,
728
+ version: options.version
729
+ }
730
+ }
731
+ })
732
+ );
733
+ }
734
+ /** Create a new context graph version. */
735
+ async createVersion(options) {
736
+ return extractData(
737
+ this.c.POST("/v1/{workspace_id}/context-graphs/{context_graph_id}/versions", {
738
+ params: {
739
+ path: {
740
+ workspace_id: this.workspaceId,
741
+ context_graph_id: options.contextGraphId
742
+ }
743
+ },
744
+ body: options.body
745
+ })
746
+ );
747
+ }
748
+ };
749
+
750
+ // src/platform/resources/conversations.ts
751
+ var PlatformConversationResource = class {
752
+ constructor(c, workspaceId2) {
753
+ this.c = c;
754
+ this.workspaceId = workspaceId2;
755
+ }
756
+ /** List voice and text conversations in the workspace. */
757
+ async list(options) {
758
+ return extractData(
759
+ this.c.GET("/v1/{workspace_id}/conversations", {
760
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
761
+ })
762
+ );
763
+ }
764
+ /** Create a text conversation. */
765
+ async create(options) {
766
+ return extractData(
767
+ this.c.POST("/v1/{workspace_id}/conversations", {
768
+ params: { path: { workspace_id: this.workspaceId } },
769
+ body: options.body
770
+ })
771
+ );
772
+ }
773
+ /** Get a conversation detail by ID. */
774
+ async get(options) {
775
+ return extractData(
776
+ this.c.GET("/v1/{workspace_id}/conversations/{conversation_id}", {
777
+ params: {
778
+ path: {
779
+ workspace_id: this.workspaceId,
780
+ conversation_id: options.conversationId
781
+ }
782
+ }
783
+ })
784
+ );
785
+ }
786
+ /** Close a text conversation. */
787
+ async close(options) {
788
+ await this.c.DELETE("/v1/{workspace_id}/conversations/{conversation_id}", {
789
+ params: {
790
+ path: {
791
+ workspace_id: this.workspaceId,
792
+ conversation_id: options.conversationId
793
+ }
794
+ }
795
+ });
796
+ return void 0;
797
+ }
798
+ /** Send a text turn and receive the full JSON response. */
799
+ async createTurn(options) {
800
+ return extractData(
801
+ this.c.POST("/v1/{workspace_id}/conversations/{conversation_id}/turns", {
802
+ params: {
803
+ path: {
804
+ workspace_id: this.workspaceId,
805
+ conversation_id: options.conversationId
806
+ },
807
+ query: options.query
808
+ },
809
+ body: options.body,
810
+ headers: { Accept: "application/json" }
811
+ })
812
+ );
813
+ }
814
+ /** Send a text turn and receive typed Server-Sent Events. */
815
+ async streamTurn(options) {
816
+ const resp = await this.c.POST("/v1/{workspace_id}/conversations/{conversation_id}/turns", {
817
+ params: {
818
+ path: {
819
+ workspace_id: this.workspaceId,
820
+ conversation_id: options.conversationId
821
+ },
822
+ query: options.query
823
+ },
824
+ body: options.body,
825
+ headers: { Accept: "text/event-stream" },
826
+ parseAs: "stream",
827
+ ...options.signal && { signal: options.signal }
828
+ });
829
+ return parseSseStream(resp.response);
830
+ }
831
+ };
832
+
833
+ // src/platform/resources/data-sources.ts
834
+ var DataSourceResource = class {
835
+ constructor(c, workspaceId2) {
836
+ this.c = c;
837
+ this.workspaceId = workspaceId2;
838
+ }
839
+ /** List data sources in the workspace. */
840
+ async list(options) {
841
+ return extractData(
842
+ this.c.GET("/v1/{workspace_id}/data-sources", {
843
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
844
+ })
845
+ );
846
+ }
847
+ /** Get a data source by ID. */
848
+ async get(options) {
849
+ return extractData(
850
+ this.c.GET("/v1/{workspace_id}/data-sources/{data_source_id}", {
851
+ params: {
852
+ path: { workspace_id: this.workspaceId, data_source_id: options.dataSourceId }
853
+ }
854
+ })
855
+ );
856
+ }
857
+ /** Create a new data source. */
858
+ async create(options) {
859
+ return extractData(
860
+ this.c.POST("/v1/{workspace_id}/data-sources", {
861
+ params: { path: { workspace_id: this.workspaceId } },
862
+ body: options.body
863
+ })
864
+ );
865
+ }
866
+ /** Update a data source. */
867
+ async update(options) {
868
+ return extractData(
869
+ this.c.PATCH("/v1/{workspace_id}/data-sources/{data_source_id}", {
870
+ params: {
871
+ path: { workspace_id: this.workspaceId, data_source_id: options.dataSourceId }
872
+ },
873
+ body: options.body
874
+ })
875
+ );
876
+ }
877
+ /** Get data source status. */
878
+ async getStatus(options) {
879
+ return extractData(
880
+ this.c.GET("/v1/{workspace_id}/data-sources/{data_source_id}/status", {
881
+ params: {
882
+ path: { workspace_id: this.workspaceId, data_source_id: options.dataSourceId }
883
+ }
884
+ })
885
+ );
886
+ }
887
+ /** Get data source sync history. */
888
+ async getSyncHistory(options) {
889
+ return extractData(
890
+ this.c.GET("/v1/{workspace_id}/data-sources/{data_source_id}/sync-history", {
891
+ params: {
892
+ path: { workspace_id: this.workspaceId, data_source_id: options.dataSourceId },
893
+ query: options.query
894
+ }
895
+ })
896
+ );
897
+ }
898
+ /** Trigger a data source sync. */
899
+ async triggerSync(options) {
900
+ return extractData(
901
+ this.c.POST("/v1/{workspace_id}/data-sources/{data_source_id}/sync", {
902
+ params: {
903
+ path: { workspace_id: this.workspaceId, data_source_id: options.dataSourceId }
904
+ }
905
+ })
906
+ );
907
+ }
908
+ /** Delete a data source. */
909
+ async delete(options) {
910
+ await this.c.DELETE("/v1/{workspace_id}/data-sources/{data_source_id}", {
911
+ params: {
912
+ path: { workspace_id: this.workspaceId, data_source_id: options.dataSourceId }
913
+ }
914
+ });
915
+ return void 0;
916
+ }
917
+ };
918
+
919
+ // src/platform/resources/events.ts
920
+ var PlatformEventResource = class {
921
+ constructor(c, workspaceId2) {
922
+ this.c = c;
923
+ this.workspaceId = workspaceId2;
924
+ }
925
+ /** Open the workspace Server-Sent Events stream. */
926
+ async stream(options) {
927
+ const headers = { Accept: "text/event-stream" };
928
+ if (options?.lastEventId) {
929
+ headers["Last-Event-ID"] = options.lastEventId;
930
+ }
931
+ const resp = await this.c.GET("/v1/{workspace_id}/events/stream", {
932
+ params: { path: { workspace_id: this.workspaceId } },
933
+ headers,
934
+ parseAs: "stream",
935
+ ...options?.signal && { signal: options.signal }
936
+ });
937
+ return parseSseStream(resp.response);
938
+ }
939
+ };
940
+
941
+ // src/platform/resources/fhir.ts
942
+ var FhirResource = class {
943
+ constructor(c, workspaceId2) {
944
+ this.c = c;
945
+ this.workspaceId = workspaceId2;
946
+ }
947
+ /** Get FHIR store status for the workspace. */
948
+ async status() {
949
+ return extractData(
950
+ this.c.GET("/v1/{workspace_id}/fhir/status", {
951
+ params: { path: { workspace_id: this.workspaceId } }
952
+ })
953
+ );
954
+ }
955
+ /** Search FHIR resources by type. */
956
+ async searchResources(options) {
957
+ return extractData(
958
+ this.c.GET("/v1/{workspace_id}/fhir/resources/{resource_type}", {
959
+ params: {
960
+ path: { workspace_id: this.workspaceId, resource_type: options.resourceType },
961
+ query: options.query
962
+ }
963
+ })
964
+ );
965
+ }
966
+ /** Get a specific FHIR resource by type and ID. */
967
+ async getResource(options) {
968
+ return extractData(
969
+ this.c.GET("/v1/{workspace_id}/fhir/resources/{resource_type}/{resource_id}", {
970
+ params: {
971
+ path: {
972
+ workspace_id: this.workspaceId,
973
+ resource_type: options.resourceType,
974
+ resource_id: options.resourceId
975
+ }
976
+ }
977
+ })
978
+ );
979
+ }
980
+ /** Create a FHIR resource. */
981
+ async createResource(options) {
982
+ return extractData(
983
+ this.c.POST("/v1/{workspace_id}/fhir/resources/{resource_type}", {
984
+ params: {
985
+ path: { workspace_id: this.workspaceId, resource_type: options.resourceType }
986
+ },
987
+ body: options.body
988
+ })
989
+ );
990
+ }
991
+ /** Update a FHIR resource. */
992
+ async updateResource(options) {
993
+ return extractData(
994
+ this.c.PUT("/v1/{workspace_id}/fhir/resources/{resource_type}/{resource_id}", {
995
+ params: {
996
+ path: {
997
+ workspace_id: this.workspaceId,
998
+ resource_type: options.resourceType,
999
+ resource_id: options.resourceId
1000
+ }
1001
+ },
1002
+ body: options.body
1003
+ })
1004
+ );
1005
+ }
1006
+ /** Get sync failures. */
1007
+ async syncFailures(options) {
1008
+ return extractData(
1009
+ this.c.GET("/v1/{workspace_id}/fhir/sync-failures", {
1010
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1011
+ })
1012
+ );
1013
+ }
1014
+ /** Import FHIR data. */
1015
+ async import(options) {
1016
+ return extractData(
1017
+ this.c.POST("/v1/{workspace_id}/fhir/import", {
1018
+ params: { path: { workspace_id: this.workspaceId } },
1019
+ body: options.body
1020
+ })
1021
+ );
1022
+ }
1023
+ /** Search patients. */
1024
+ async searchPatients(options) {
1025
+ return extractData(
1026
+ this.c.GET("/v1/{workspace_id}/fhir/patients", {
1027
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1028
+ })
1029
+ );
1030
+ }
1031
+ /** Get patient timeline. */
1032
+ async getPatientTimeline(options) {
1033
+ return extractData(
1034
+ this.c.GET("/v1/{workspace_id}/fhir/patients/{patient_id}/timeline", {
1035
+ params: {
1036
+ path: { workspace_id: this.workspaceId, patient_id: options.patientId },
1037
+ query: options.query
1038
+ }
1039
+ })
1040
+ );
1041
+ }
1042
+ /** Get patient summary. */
1043
+ async getPatientSummary(options) {
1044
+ return extractData(
1045
+ this.c.GET("/v1/{workspace_id}/fhir/patients/{patient_id}/summary", {
1046
+ params: {
1047
+ path: { workspace_id: this.workspaceId, patient_id: options.patientId }
1048
+ }
1049
+ })
1050
+ );
1051
+ }
1052
+ /** Get FHIR views — patients. */
1053
+ async viewPatients(options) {
1054
+ return extractData(
1055
+ this.c.GET("/v1/{workspace_id}/fhir/views/patients", {
1056
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1057
+ })
1058
+ );
1059
+ }
1060
+ /** Get FHIR views — practitioners. */
1061
+ async viewPractitioners(options) {
1062
+ return extractData(
1063
+ this.c.GET("/v1/{workspace_id}/fhir/views/practitioners", {
1064
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1065
+ })
1066
+ );
1067
+ }
1068
+ /** Get FHIR views — locations. */
1069
+ async viewLocations(options) {
1070
+ return extractData(
1071
+ this.c.GET("/v1/{workspace_id}/fhir/views/locations", {
1072
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1073
+ })
1074
+ );
1075
+ }
1076
+ /** Get FHIR views — appointments. */
1077
+ async viewAppointments(options) {
1078
+ return extractData(
1079
+ this.c.GET("/v1/{workspace_id}/fhir/views/appointments", {
1080
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1081
+ })
1082
+ );
1083
+ }
1084
+ /** Get FHIR views — organizations. */
1085
+ async viewOrganizations(options) {
1086
+ return extractData(
1087
+ this.c.GET("/v1/{workspace_id}/fhir/views/organizations", {
1088
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1089
+ })
1090
+ );
1091
+ }
1092
+ /** Get FHIR views — slots. */
1093
+ async viewSlots(options) {
1094
+ return extractData(
1095
+ this.c.GET("/v1/{workspace_id}/fhir/views/slots", {
1096
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1097
+ })
1098
+ );
1099
+ }
1100
+ };
1101
+
1102
+ // src/platform/resources/integrations.ts
1103
+ var IntegrationResource = class {
1104
+ constructor(c, workspaceId2) {
1105
+ this.c = c;
1106
+ this.workspaceId = workspaceId2;
1107
+ }
1108
+ /** List integrations in the workspace. */
1109
+ async list(options) {
1110
+ return extractData(
1111
+ this.c.GET("/v1/{workspace_id}/integrations", {
1112
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1113
+ })
1114
+ );
1115
+ }
1116
+ /** Get an integration by ID. */
1117
+ async get(options) {
1118
+ return extractData(
1119
+ this.c.GET("/v1/{workspace_id}/integrations/{integration_id}", {
1120
+ params: {
1121
+ path: { workspace_id: this.workspaceId, integration_id: options.integrationId }
1122
+ }
1123
+ })
1124
+ );
1125
+ }
1126
+ /** Create a new integration. */
1127
+ async create(options) {
1128
+ return extractData(
1129
+ this.c.POST("/v1/{workspace_id}/integrations", {
1130
+ params: { path: { workspace_id: this.workspaceId } },
1131
+ body: options.body
1132
+ })
1133
+ );
1134
+ }
1135
+ /** Update an integration. */
1136
+ async update(options) {
1137
+ return extractData(
1138
+ this.c.PUT("/v1/{workspace_id}/integrations/{integration_id}", {
1139
+ params: {
1140
+ path: { workspace_id: this.workspaceId, integration_id: options.integrationId }
1141
+ },
1142
+ body: options.body
1143
+ })
1144
+ );
1145
+ }
1146
+ /** Delete an integration. */
1147
+ async delete(options) {
1148
+ await this.c.DELETE("/v1/{workspace_id}/integrations/{integration_id}", {
1149
+ params: {
1150
+ path: { workspace_id: this.workspaceId, integration_id: options.integrationId }
1151
+ }
1152
+ });
1153
+ return void 0;
1154
+ }
1155
+ /** Test an integration endpoint. */
1156
+ async testEndpoint(options) {
1157
+ return extractData(
1158
+ this.c.POST(
1159
+ "/v1/{workspace_id}/integrations/{integration_id}/endpoints/{endpoint_name}/test",
1160
+ {
1161
+ params: {
1162
+ path: {
1163
+ workspace_id: this.workspaceId,
1164
+ integration_id: options.integrationId,
1165
+ endpoint_name: options.endpointName
1166
+ }
1167
+ },
1168
+ body: options.body
1169
+ }
1170
+ )
1171
+ );
1172
+ }
1173
+ /** Check integration health for the workspace. */
1174
+ async healthCheck() {
1175
+ return extractData(
1176
+ this.c.GET("/v1/{workspace_id}/integrations/health-check", {
1177
+ params: { path: { workspace_id: this.workspaceId } }
1178
+ })
1179
+ );
1180
+ }
1181
+ };
1182
+
1183
+ // src/platform/resources/phone-numbers.ts
1184
+ var PhoneNumberResource = class {
1185
+ constructor(c, workspaceId2) {
1186
+ this.c = c;
1187
+ this.workspaceId = workspaceId2;
1188
+ }
1189
+ /** List phone numbers in the workspace. */
1190
+ async list(options) {
1191
+ return extractData(
1192
+ this.c.GET("/v1/{workspace_id}/phone-numbers", {
1193
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1194
+ })
1195
+ );
1196
+ }
1197
+ /** Get a phone number by ID. */
1198
+ async get(options) {
1199
+ return extractData(
1200
+ this.c.GET("/v1/{workspace_id}/phone-numbers/{phone_number_id}", {
1201
+ params: {
1202
+ path: { workspace_id: this.workspaceId, phone_number_id: options.phoneNumberId }
1203
+ }
1204
+ })
1205
+ );
1206
+ }
1207
+ /** Create a phone number. */
1208
+ async create(options) {
1209
+ return extractData(
1210
+ this.c.POST("/v1/{workspace_id}/phone-numbers", {
1211
+ params: { path: { workspace_id: this.workspaceId } },
1212
+ body: options.body
1213
+ })
1214
+ );
1215
+ }
1216
+ /** Update a phone number. */
1217
+ async update(options) {
1218
+ return extractData(
1219
+ this.c.PUT("/v1/{workspace_id}/phone-numbers/{phone_number_id}", {
1220
+ params: {
1221
+ path: { workspace_id: this.workspaceId, phone_number_id: options.phoneNumberId }
1222
+ },
1223
+ body: options.body
1224
+ })
1225
+ );
1226
+ }
1227
+ /** Delete a phone number. */
1228
+ async delete(options) {
1229
+ await this.c.DELETE("/v1/{workspace_id}/phone-numbers/{phone_number_id}", {
1230
+ params: {
1231
+ path: { workspace_id: this.workspaceId, phone_number_id: options.phoneNumberId }
1232
+ }
1233
+ });
1234
+ return void 0;
1235
+ }
1236
+ /** Set call forwarding for a phone number. */
1237
+ async setForwarding(options) {
1238
+ return extractData(
1239
+ this.c.PUT("/v1/{workspace_id}/phone-numbers/{phone_number_id}/forwarding", {
1240
+ params: {
1241
+ path: { workspace_id: this.workspaceId, phone_number_id: options.phoneNumberId }
1242
+ },
1243
+ body: options.body
1244
+ })
1245
+ );
1246
+ }
1247
+ /** Clear call forwarding for a phone number. */
1248
+ async clearForwarding(options) {
1249
+ await this.c.DELETE("/v1/{workspace_id}/phone-numbers/{phone_number_id}/forwarding", {
1250
+ params: {
1251
+ path: { workspace_id: this.workspaceId, phone_number_id: options.phoneNumberId }
1252
+ }
1253
+ });
1254
+ return void 0;
1255
+ }
1256
+ /** Get the Twilio sub-account for the workspace. */
1257
+ async getTwilioSubAccount() {
1258
+ return extractData(
1259
+ this.c.GET("/v1/{workspace_id}/twilio/sub-account", {
1260
+ params: { path: { workspace_id: this.workspaceId } }
1261
+ })
1262
+ );
1263
+ }
1264
+ /** Provision a Twilio sub-account for the workspace. */
1265
+ async provisionTwilioSubAccount() {
1266
+ return extractData(
1267
+ this.c.POST("/v1/{workspace_id}/twilio/sub-account", {
1268
+ params: { path: { workspace_id: this.workspaceId } }
1269
+ })
1270
+ );
1271
+ }
1272
+ /** Search available phone numbers for purchase. */
1273
+ async searchAvailable(options) {
1274
+ return extractData(
1275
+ this.c.GET("/v1/{workspace_id}/twilio/phone-numbers/available", {
1276
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1277
+ })
1278
+ );
1279
+ }
1280
+ /** Purchase a phone number. */
1281
+ async purchase(options) {
1282
+ return extractData(
1283
+ this.c.POST("/v1/{workspace_id}/twilio/phone-numbers/purchase", {
1284
+ params: { path: { workspace_id: this.workspaceId } },
1285
+ body: options.body
1286
+ })
1287
+ );
1288
+ }
1289
+ /** Release a purchased phone number. */
1290
+ async release(options) {
1291
+ await this.c.DELETE("/v1/{workspace_id}/twilio/phone-numbers/{phone_number_id}/release", {
1292
+ params: {
1293
+ path: { workspace_id: this.workspaceId, phone_number_id: options.phoneNumberId }
1294
+ }
1295
+ });
1296
+ return void 0;
1297
+ }
1298
+ /** Bind a channel-manager phone number to a workspace/service. */
1299
+ async bind(options) {
1300
+ return extractData(
1301
+ this.c.POST("/v1/{workspace_id}/phone-numbers/bind", {
1302
+ params: { path: { workspace_id: this.workspaceId } },
1303
+ body: options.body
1304
+ })
1305
+ );
1306
+ }
1307
+ };
1308
+
1309
+ // src/platform/resources/services.ts
1310
+ var PlatformServiceResource = class {
1311
+ constructor(c, workspaceId2) {
1312
+ this.c = c;
1313
+ this.workspaceId = workspaceId2;
1314
+ }
1315
+ /** List services in the workspace. */
1316
+ async list(options) {
1317
+ return extractData(
1318
+ this.c.GET("/v1/{workspace_id}/services", {
1319
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1320
+ })
1321
+ );
1322
+ }
1323
+ /** Get a service by ID. */
1324
+ async get(options) {
1325
+ return extractData(
1326
+ this.c.GET("/v1/{workspace_id}/services/{service_id}", {
1327
+ params: { path: { workspace_id: this.workspaceId, service_id: options.serviceId } }
1328
+ })
1329
+ );
1330
+ }
1331
+ /** Create a new service. */
1332
+ async create(options) {
1333
+ return extractData(
1334
+ this.c.POST("/v1/{workspace_id}/services", {
1335
+ params: { path: { workspace_id: this.workspaceId } },
1336
+ body: options.body
1337
+ })
1338
+ );
1339
+ }
1340
+ /** Update a service. */
1341
+ async update(options) {
1342
+ return extractData(
1343
+ this.c.PUT("/v1/{workspace_id}/services/{service_id}", {
1344
+ params: { path: { workspace_id: this.workspaceId, service_id: options.serviceId } },
1345
+ body: options.body
1346
+ })
1347
+ );
1348
+ }
1349
+ /** Delete a service. */
1350
+ async delete(options) {
1351
+ await this.c.DELETE("/v1/{workspace_id}/services/{service_id}", {
1352
+ params: { path: { workspace_id: this.workspaceId, service_id: options.serviceId } }
1353
+ });
1354
+ return void 0;
1355
+ }
1356
+ /** Upsert a version set for a service. */
1357
+ async upsertVersionSet(options) {
1358
+ return extractData(
1359
+ this.c.PUT("/v1/{workspace_id}/services/{service_id}/version-sets/{name}", {
1360
+ params: {
1361
+ path: {
1362
+ workspace_id: this.workspaceId,
1363
+ service_id: options.serviceId,
1364
+ name: options.name
1365
+ }
1366
+ },
1367
+ body: options.body
1368
+ })
1369
+ );
1370
+ }
1371
+ /** Resolve all tools available to a service. */
1372
+ async resolveTools(options) {
1373
+ return extractData(
1374
+ this.c.GET("/v1/{workspace_id}/services/{service_id}/tools/resolve", {
1375
+ params: {
1376
+ path: { workspace_id: this.workspaceId, service_id: options.serviceId },
1377
+ query: options.query
1378
+ }
1379
+ })
1380
+ );
1381
+ }
1382
+ /** Run one voice turn through a service. */
1383
+ async voiceTurn(options) {
1384
+ return extractData(
1385
+ this.c.POST("/v1/{workspace_id}/services/{service_id}/voice-turn", {
1386
+ params: { path: { workspace_id: this.workspaceId, service_id: options.serviceId } },
1387
+ body: options.body
1388
+ })
1389
+ );
1390
+ }
1391
+ };
1392
+
1393
+ // src/platform/resources/sessions.ts
1394
+ var PlatformSessionResource = class {
1395
+ constructor(c, workspaceId2, realtime) {
1396
+ this.c = c;
1397
+ this.workspaceId = workspaceId2;
1398
+ this.realtime = realtime;
1399
+ }
1400
+ /** List active voice sessions. */
1401
+ async listActive() {
1402
+ return extractData(
1403
+ this.c.GET("/v1/{workspace_id}/sessions/active", {
1404
+ params: { path: { workspace_id: this.workspaceId } }
1405
+ })
1406
+ );
1407
+ }
1408
+ /** Start an SMS, WhatsApp, or web text session with an entity. */
1409
+ async start(options) {
1410
+ return extractData(
1411
+ this.c.POST("/v1/{workspace_id}/sessions/start", {
1412
+ params: { path: { workspace_id: this.workspaceId } },
1413
+ body: options.body
1414
+ })
1415
+ );
1416
+ }
1417
+ /** Inject an external event or operator guidance into an active voice session. */
1418
+ async inject(options) {
1419
+ return extractData(
1420
+ this.c.POST("/v1/{workspace_id}/sessions/{call_sid}/inject", {
1421
+ params: {
1422
+ path: {
1423
+ workspace_id: this.workspaceId,
1424
+ call_sid: options.callSid
1425
+ }
1426
+ },
1427
+ body: options.body
1428
+ })
1429
+ );
1430
+ }
1431
+ /** Build the public platform text-session WebSocket URL. */
1432
+ buildTextSessionUrl(options) {
1433
+ const url = new URL(
1434
+ `/v1/${encodeURIComponent(this.workspaceId)}/sessions/connect`,
1435
+ `${this.realtime.webSocketBaseUrl}/`
1436
+ );
1437
+ url.searchParams.set("service_id", options.serviceId);
1438
+ url.searchParams.set("entity_id", options.entityId);
1439
+ url.searchParams.set("tool_events", String(options.toolEvents ?? true));
1440
+ if (options.conversationId) {
1441
+ url.searchParams.set("conversation_id", options.conversationId);
1442
+ }
1443
+ return url.toString();
1444
+ }
1445
+ /** Connect to the public bidirectional text-session WebSocket. */
1446
+ connectTextSession(options) {
1447
+ const WebSocketCtor = getWebSocketConstructor(options.WebSocket ?? this.realtime.WebSocket);
1448
+ const token = options.token ?? this.realtime.apiKey;
1449
+ const url = this.buildTextSessionUrl(options);
1450
+ return new WebSocketCtor(url, ["auth", token]);
1451
+ }
1452
+ };
1453
+
1454
+ // src/platform/resources/skills.ts
1455
+ var SkillResource = class {
1456
+ constructor(c, workspaceId2) {
1457
+ this.c = c;
1458
+ this.workspaceId = workspaceId2;
1459
+ }
1460
+ /** List skills in the workspace. */
1461
+ async list(options) {
1462
+ return extractData(
1463
+ this.c.GET("/v1/{workspace_id}/skills", {
1464
+ params: { path: { workspace_id: this.workspaceId }, query: options?.query }
1465
+ })
1466
+ );
1467
+ }
1468
+ /** Get a skill by ID. */
1469
+ async get(options) {
1470
+ return extractData(
1471
+ this.c.GET("/v1/{workspace_id}/skills/{skill_id}", {
1472
+ params: { path: { workspace_id: this.workspaceId, skill_id: options.skillId } }
1473
+ })
1474
+ );
1475
+ }
1476
+ /** Create a new skill. */
1477
+ async create(options) {
1478
+ return extractData(
1479
+ this.c.POST("/v1/{workspace_id}/skills", {
1480
+ params: { path: { workspace_id: this.workspaceId } },
1481
+ body: options.body
1482
+ })
1483
+ );
1484
+ }
1485
+ /** Update a skill. */
1486
+ async update(options) {
1487
+ return extractData(
1488
+ this.c.PUT("/v1/{workspace_id}/skills/{skill_id}", {
1489
+ params: { path: { workspace_id: this.workspaceId, skill_id: options.skillId } },
1490
+ body: options.body
1491
+ })
1492
+ );
1493
+ }
1494
+ /** Delete a skill. */
1495
+ async delete(options) {
1496
+ await this.c.DELETE("/v1/{workspace_id}/skills/{skill_id}", {
1497
+ params: { path: { workspace_id: this.workspaceId, skill_id: options.skillId } }
1498
+ });
1499
+ return void 0;
1500
+ }
1501
+ /** Test a skill in isolation. */
1502
+ async test(options) {
1503
+ return extractData(
1504
+ this.c.POST("/v1/{workspace_id}/skills/{skill_id}/test", {
1505
+ params: { path: { workspace_id: this.workspaceId, skill_id: options.skillId } },
1506
+ body: options.body
1507
+ })
1508
+ );
1509
+ }
1510
+ /** Get HSM/service references for a skill. */
1511
+ async getReferences(options) {
1512
+ return extractData(
1513
+ this.c.GET("/v1/{workspace_id}/skills/{skill_id}/references", {
1514
+ params: { path: { workspace_id: this.workspaceId, skill_id: options.skillId } }
1515
+ })
1516
+ );
1517
+ }
1518
+ };
1519
+
1520
+ // src/platform/resources/workspaces.ts
1521
+ var WorkspaceResource = class {
1522
+ constructor(c, workspaceId2) {
1523
+ this.c = c;
1524
+ this.workspaceId = workspaceId2;
1525
+ }
1526
+ requireWorkspaceId() {
1527
+ if (!this.workspaceId) {
1528
+ throw new Error("workspaceId is required for this operation");
1529
+ }
1530
+ return this.workspaceId;
1531
+ }
1532
+ /** List workspaces accessible to this API key. */
1533
+ async list(options) {
1534
+ return extractData(
1535
+ this.c.GET("/v1/workspaces", {
1536
+ params: { query: options?.query }
1537
+ })
1538
+ );
1539
+ }
1540
+ /** Get a workspace by ID. */
1541
+ async get(options) {
1542
+ return extractData(
1543
+ this.c.GET("/v1/workspaces/{workspace_id}", {
1544
+ params: { path: { workspace_id: options?.workspaceId ?? this.requireWorkspaceId() } }
1545
+ })
1546
+ );
1547
+ }
1548
+ /** Create a new workspace. */
1549
+ async create(options) {
1550
+ return extractData(
1551
+ this.c.POST("/v1/workspaces", {
1552
+ body: options.body
1553
+ })
1554
+ );
1555
+ }
1556
+ /** Create a self-service workspace. */
1557
+ async createSelfService(options) {
1558
+ return extractData(
1559
+ this.c.POST("/v1/workspaces/self-service", {
1560
+ body: options.body
1561
+ })
1562
+ );
1563
+ }
1564
+ /** Update a workspace. */
1565
+ async update(options) {
1566
+ return extractData(
1567
+ this.c.PATCH("/v1/workspaces/{workspace_id}", {
1568
+ params: { path: { workspace_id: options.workspaceId ?? this.requireWorkspaceId() } },
1569
+ body: options.body
1570
+ })
1571
+ );
1572
+ }
1573
+ /** Provision workspace resources (idempotent). */
1574
+ async provision(options) {
1575
+ return extractData(
1576
+ this.c.POST("/v1/workspaces/{workspace_id}/provision", {
1577
+ params: { path: { workspace_id: options?.workspaceId ?? this.requireWorkspaceId() } }
1578
+ })
1579
+ );
1580
+ }
1581
+ /** Archive a workspace. */
1582
+ async archive(options) {
1583
+ return extractData(
1584
+ this.c.POST("/v1/workspaces/{workspace_id}/archive", {
1585
+ params: { path: { workspace_id: options.workspaceId ?? this.requireWorkspaceId() } },
1586
+ body: options.body
1587
+ })
1588
+ );
1589
+ }
1590
+ /** Check whether a workspace can be converted between environments. */
1591
+ async checkEnvironmentConversion(options) {
1592
+ return extractData(
1593
+ this.c.GET("/v1/workspaces/{workspace_id}/environment-check", {
1594
+ params: {
1595
+ path: { workspace_id: options?.workspaceId ?? this.requireWorkspaceId() },
1596
+ query: options?.query
1597
+ }
1598
+ })
1599
+ );
1600
+ }
1601
+ /** Convert a workspace environment. */
1602
+ async convertEnvironment(options) {
1603
+ return extractData(
1604
+ this.c.POST("/v1/workspaces/{workspace_id}/convert-environment", {
1605
+ params: { path: { workspace_id: options.workspaceId ?? this.requireWorkspaceId() } },
1606
+ body: options.body
1607
+ })
1608
+ );
1609
+ }
1610
+ /** Get voice settings for a workspace. */
1611
+ async getVoiceSettings(options) {
1612
+ return extractData(
1613
+ this.c.GET("/v1/{workspace_id}/settings/voice", {
1614
+ params: { path: { workspace_id: options?.workspaceId ?? this.requireWorkspaceId() } }
1615
+ })
1616
+ );
1617
+ }
1618
+ /** Update voice settings for a workspace. */
1619
+ async updateVoiceSettings(options) {
1620
+ return extractData(
1621
+ this.c.PUT("/v1/{workspace_id}/settings/voice", {
1622
+ params: { path: { workspace_id: options.workspaceId ?? this.requireWorkspaceId() } },
1623
+ body: options.body
1624
+ })
1625
+ );
1626
+ }
1627
+ /** Get test caller numbers for a workspace. */
1628
+ async getTestCallerNumbers(options) {
1629
+ return extractData(
1630
+ this.c.GET("/v1/workspaces/{workspace_id}/test-caller-numbers", {
1631
+ params: { path: { workspace_id: options?.workspaceId ?? this.requireWorkspaceId() } }
1632
+ })
1633
+ );
1634
+ }
1635
+ /** Update test caller numbers for a workspace. */
1636
+ async updateTestCallerNumbers(options) {
1637
+ return extractData(
1638
+ this.c.PUT("/v1/workspaces/{workspace_id}/test-caller-numbers", {
1639
+ params: { path: { workspace_id: options.workspaceId ?? this.requireWorkspaceId() } },
1640
+ body: options.body
1641
+ })
1642
+ );
1643
+ }
1644
+ };
1645
+
1646
+ // src/platform/core/branded-types.ts
1647
+ function workspaceId(id) {
1648
+ return id;
1649
+ }
1650
+ function skillId(id) {
1651
+ return id;
1652
+ }
1653
+ function integrationId(id) {
1654
+ return id;
1655
+ }
1656
+ function contextGraphId(id) {
1657
+ return id;
1658
+ }
1659
+ function platformAgentId(id) {
1660
+ return id;
1661
+ }
1662
+ function platformServiceId(id) {
1663
+ return id;
1664
+ }
1665
+ function phoneNumberId(id) {
1666
+ return id;
1667
+ }
1668
+ function platformApiKeyId(id) {
1669
+ return id;
1670
+ }
1671
+ function callSid(id) {
1672
+ return id;
1673
+ }
1674
+ function platformConversationId(id) {
1675
+ return id;
1676
+ }
1677
+ function dataSourceId(id) {
1678
+ return id;
1679
+ }
1680
+ function operatorId(id) {
1681
+ return id;
1682
+ }
1683
+ function reviewItemId(id) {
1684
+ return id;
1685
+ }
1686
+ function monitorConceptId(id) {
1687
+ return id;
1688
+ }
1689
+ function unificationRuleId(id) {
1690
+ return id;
1691
+ }
1692
+ function entityId(id) {
1693
+ return id;
1694
+ }
1695
+ function taskId(id) {
1696
+ return id;
1697
+ }
1698
+
1699
+ // src/platform/index.ts
1700
+ var defaultBaseUrl = "https://api.platform.amigo.ai";
1701
+ var PlatformClient = class {
1702
+ constructor(config) {
1703
+ __publicField(this, "api");
1704
+ __publicField(this, "agents");
1705
+ __publicField(this, "apiKeys");
1706
+ __publicField(this, "contextGraphs");
1707
+ __publicField(this, "conversations");
1708
+ __publicField(this, "dataSources");
1709
+ __publicField(this, "events");
1710
+ __publicField(this, "fhir");
1711
+ __publicField(this, "integrations");
1712
+ __publicField(this, "phoneNumbers");
1713
+ __publicField(this, "services");
1714
+ __publicField(this, "sessions");
1715
+ __publicField(this, "skills");
1716
+ __publicField(this, "workspaces");
1717
+ __publicField(this, "config");
1718
+ this.config = validateConfig(config);
1719
+ this.api = createPlatformFetch(this.config);
1720
+ this.workspaces = new WorkspaceResource(this.api, this.config.workspaceId);
1721
+ this.agents = new PlatformAgentResource(this.api, this.config.workspaceId);
1722
+ this.apiKeys = new PlatformApiKeyResource(this.api, this.config.workspaceId);
1723
+ this.contextGraphs = new ContextGraphResource(this.api, this.config.workspaceId);
1724
+ this.conversations = new PlatformConversationResource(this.api, this.config.workspaceId);
1725
+ this.dataSources = new DataSourceResource(this.api, this.config.workspaceId);
1726
+ this.events = new PlatformEventResource(this.api, this.config.workspaceId);
1727
+ this.fhir = new FhirResource(this.api, this.config.workspaceId);
1728
+ this.integrations = new IntegrationResource(this.api, this.config.workspaceId);
1729
+ this.phoneNumbers = new PhoneNumberResource(this.api, this.config.workspaceId);
1730
+ this.services = new PlatformServiceResource(this.api, this.config.workspaceId);
1731
+ this.sessions = new PlatformSessionResource(this.api, this.config.workspaceId, {
1732
+ apiKey: this.config.apiKey,
1733
+ webSocketBaseUrl: this.config.webSocketBaseUrl,
1734
+ WebSocket: this.config.WebSocket
1735
+ });
1736
+ this.skills = new SkillResource(this.api, this.config.workspaceId);
1737
+ }
1738
+ };
1739
+ function validateConfig(config) {
1740
+ if (!config.apiKey) {
1741
+ throw new ConfigurationError("Platform API key is required", "apiKey");
1742
+ }
1743
+ if (!config.workspaceId) {
1744
+ throw new ConfigurationError("Workspace ID is required", "workspaceId");
1745
+ }
1746
+ const baseUrl = config.baseUrl ?? defaultBaseUrl;
1747
+ const webSocketBaseUrl = config.webSocketBaseUrl ?? webSocketBaseFromHttpBase(baseUrl);
1748
+ return {
1749
+ ...config,
1750
+ baseUrl,
1751
+ webSocketBaseUrl
1752
+ };
1753
+ }
1754
+ //# sourceMappingURL=platform.cjs.map