@amigo-ai/sdk 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +50 -37
  2. package/dist/index.cjs +36 -2
  3. package/dist/index.cjs.map +2 -2
  4. package/dist/index.mjs +36 -2
  5. package/dist/index.mjs.map +2 -2
  6. package/dist/platform.cjs +1788 -0
  7. package/dist/platform.cjs.map +7 -0
  8. package/dist/platform.mjs +1757 -0
  9. package/dist/platform.mjs.map +7 -0
  10. package/dist/types/core/errors.d.ts +11 -1
  11. package/dist/types/core/utils.d.ts +11 -0
  12. package/dist/types/generated/api-types.d.ts +1 -1
  13. package/dist/types/generated/platform-api-types.d.ts +45240 -0
  14. package/dist/types/platform/core/auth.d.ts +6 -0
  15. package/dist/types/platform/core/branded-types.d.ts +59 -0
  16. package/dist/types/platform/core/openapi-client.d.ts +6 -0
  17. package/dist/types/platform/core/websocket.d.ts +8 -0
  18. package/dist/types/platform/index.d.ts +59 -0
  19. package/dist/types/platform/resources/agents.d.ts +107 -0
  20. package/dist/types/platform/resources/api-keys.d.ts +57 -0
  21. package/dist/types/platform/resources/context-graphs.d.ts +114 -0
  22. package/dist/types/platform/resources/conversations.d.ts +154 -0
  23. package/dist/types/platform/resources/data-sources.d.ts +143 -0
  24. package/dist/types/platform/resources/events.d.ts +253 -0
  25. package/dist/types/platform/resources/fhir.d.ts +186 -0
  26. package/dist/types/platform/resources/integrations.d.ts +114 -0
  27. package/dist/types/platform/resources/phone-numbers.d.ts +170 -0
  28. package/dist/types/platform/resources/services.d.ts +133 -0
  29. package/dist/types/platform/resources/sessions.d.ts +61 -0
  30. package/dist/types/platform/resources/skills.d.ts +169 -0
  31. package/dist/types/platform/resources/workspaces.d.ts +187 -0
  32. package/package.json +15 -11
  33. package/assets/readme/amigo-banner.png +0 -0
  34. package/assets/readme/classic-ts-architecture.png +0 -0
  35. package/assets/readme/classic-ts-architecture.svg +0 -102
package/README.md CHANGED
@@ -1,10 +1,6 @@
1
- <p align="center">
2
- <img src="./assets/readme/amigo-banner.png" alt="Amigo banner" width="100%" />
3
- </p>
4
-
5
1
  <h1 align="center">@amigo-ai/sdk</h1>
6
2
 
7
- <p align="center">Official TypeScript SDK for the classic Amigo API.</p>
3
+ <p align="center">Official TypeScript SDK for the Amigo classic and Platform APIs.</p>
8
4
 
9
5
  <p align="center">
10
6
  <a href="https://docs.amigo.ai">Product Docs</a>
@@ -25,36 +21,36 @@
25
21
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License" /></a>
26
22
  </p>
27
23
 
28
- Typed from the committed classic OpenAPI snapshot, shipped as ESM and CommonJS, and used by current org-scoped Amigo integrations.
24
+ Typed from the Amigo OpenAPI schemas, shipped as ESM and CommonJS, and used by current org-scoped and workspace-scoped Amigo integrations.
29
25
 
30
- ## Classic API Context
26
+ ## Product Status
31
27
 
32
- The classic SDK is the typed client boundary between your application and the org-scoped Amigo API. It remains the right fit for current integrations that depend on the classic resource model while platform-native coverage expands.
28
+ `@amigo-ai/sdk` remains the supported TypeScript client for the classic Amigo API and now also ships the Platform API client from the `@amigo-ai/sdk/platform` subpath.
33
29
 
34
- ![Classic TypeScript SDK architecture](./assets/readme/classic-ts-architecture.png)
30
+ The Platform API is the long-term home for new workspace-scoped capabilities. Classic customers are not being asked to make an abrupt rewrite: the root package export continues to target the current org-scoped API, while new platform integrations can use the platform subpath from the same package.
35
31
 
36
- ## Product Status
32
+ ## Choose The Right SDK
37
33
 
38
- `@amigo-ai/sdk` remains the supported TypeScript client for the classic Amigo API.
34
+ | If you need | Use |
35
+ | --- | --- |
36
+ | The current org-scoped Amigo API used by existing integrations | `@amigo-ai/sdk` |
37
+ | New workspace-scoped Platform API integrations | `@amigo-ai/sdk/platform` |
39
38
 
40
- The Platform API is the long-term home for new workspace-scoped capabilities, but classic customers are not being asked to make an abrupt rewrite. As equivalent platform surfaces become available, Amigo will publish a migration path and upgrade guidance before recommending a move.
39
+ ## API Context
41
40
 
42
- ## Choose The Right SDK
41
+ This SDK is the typed client boundary between your application and the classic Amigo API at `https://api.amigo.ai`. It covers the current org-scoped resources used by existing Amigo deployments: conversations, services, organizations, users, agents, context graphs, webhooks, and streaming events.
43
42
 
44
- | If you need | Use |
45
- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
46
- | The current org-scoped Amigo API used by existing integrations | `@amigo-ai/sdk` |
47
- | New workspace-scoped Platform API integrations | [`@amigo-ai/platform-sdk`](https://github.com/amigo-ai/amigo-platform-typescript-sdk) |
43
+ The platform subpath is the typed client boundary for the Platform API at `https://api.platform.amigo.ai`. It includes a raw OpenAPI-typed fetch client, workspace-scoped resources, SSE helpers for streaming turns and workspace events, and WebSocket helpers for public text sessions.
48
44
 
49
45
  ## Documentation
50
46
 
51
- | Need | Best entry point |
52
- | --------------------------------------- | ------------------------------------------------------------------------------------------- |
53
- | Product overview and deployment context | [docs.amigo.ai](https://docs.amigo.ai/) |
54
- | Integration guidance and developer docs | [Developer Guide](https://docs.amigo.ai/developer-guide) |
55
- | Generated API reference | [amigo-ai.github.io/amigo-typescript-sdk](https://amigo-ai.github.io/amigo-typescript-sdk/) |
56
- | Runnable examples | [examples/](https://github.com/amigo-ai/amigo-typescript-sdk/tree/main/examples) |
57
- | Release history | [CHANGELOG.md](https://github.com/amigo-ai/amigo-typescript-sdk/blob/main/CHANGELOG.md) |
47
+ | Need | Best entry point |
48
+ | --- | --- |
49
+ | Product overview and deployment context | [docs.amigo.ai](https://docs.amigo.ai/) |
50
+ | Integration guidance and developer docs | [Developer Guide](https://docs.amigo.ai/developer-guide) |
51
+ | Generated API reference | [amigo-ai.github.io/amigo-typescript-sdk](https://amigo-ai.github.io/amigo-typescript-sdk/) |
52
+ | Runnable examples | [examples/](https://github.com/amigo-ai/amigo-typescript-sdk/tree/main/examples) |
53
+ | Release history | [CHANGELOG.md](https://github.com/amigo-ai/amigo-typescript-sdk/blob/main/CHANGELOG.md) |
58
54
 
59
55
  ## Installation
60
56
 
@@ -62,7 +58,7 @@ The Platform API is the long-term home for new workspace-scoped capabilities, bu
62
58
  npm install @amigo-ai/sdk
63
59
  ```
64
60
 
65
- ## Quick Start
61
+ ## Classic Quick Start
66
62
 
67
63
  ```typescript
68
64
  import { AmigoClient } from '@amigo-ai/sdk'
@@ -79,19 +75,33 @@ const conversations = await client.conversations.getConversations({
79
75
  sort_by: ['-created_at'],
80
76
  })
81
77
 
82
- console.log(conversations.conversations.map(conversation => conversation.id))
78
+ console.log(conversations.conversations.map((conversation) => conversation.id))
79
+ ```
80
+
81
+ ## Platform Quick Start
82
+
83
+ ```typescript
84
+ import { PlatformClient } from '@amigo-ai/sdk/platform'
85
+
86
+ const platform = new PlatformClient({
87
+ apiKey: 'your-platform-api-key',
88
+ workspaceId: 'your-workspace-id',
89
+ })
90
+
91
+ const agents = await platform.agents.list({ query: { limit: 10 } })
92
+ console.log(agents.items.map((agent) => agent.id))
83
93
  ```
84
94
 
85
95
  ## Configuration
86
96
 
87
- | Option | Type | Required | Description |
88
- | ---------- | -------------- | -------- | ------------------------------------------------------------- |
89
- | `apiKey` | `string` | Yes | API key from the Amigo dashboard |
90
- | `apiKeyId` | `string` | Yes | API key ID paired with `apiKey` |
91
- | `userId` | `string` | Yes | User ID on whose behalf the request is made |
92
- | `orgId` | `string` | Yes | Organization ID for the classic API |
93
- | `baseUrl` | `string` | No | Override the API base URL. Defaults to `https://api.amigo.ai` |
94
- | `retry` | `RetryOptions` | No | Retry policy overrides for transient HTTP failures |
97
+ | Option | Type | Required | Description |
98
+ | --- | --- | --- | --- |
99
+ | `apiKey` | `string` | Yes | API key from the Amigo dashboard |
100
+ | `apiKeyId` | `string` | Yes | API key ID paired with `apiKey` |
101
+ | `userId` | `string` | Yes | User ID on whose behalf the request is made |
102
+ | `orgId` | `string` | Yes | Organization ID for the classic API |
103
+ | `baseUrl` | `string` | No | Override the API base URL. Defaults to `https://api.amigo.ai` |
104
+ | `retry` | `RetryOptions` | No | Retry policy overrides for transient HTTP failures |
95
105
 
96
106
  ### Runtime Requirements
97
107
 
@@ -108,10 +118,13 @@ type Conversation = components['schemas']['ConversationInstance']
108
118
  type GetConversationsQuery = operations['get-conversations']['parameters']['query']
109
119
  ```
110
120
 
111
- Public builds are generated from the committed [`specs/openapi-baseline.json`](./specs/openapi-baseline.json) snapshot in this repo so type output stays deterministic across machines and CI runs. When you need to refresh that snapshot, run:
121
+ Platform OpenAPI types are exported from the platform subpath:
112
122
 
113
- ```bash
114
- npm run openapi:sync
123
+ ```typescript
124
+ import type { components, operations, paths } from '@amigo-ai/sdk/platform'
125
+
126
+ type PlatformAgent = components['schemas']['AgentResponse']
127
+ type ListAgentsQuery = operations['list-agents']['parameters']['query']
115
128
  ```
116
129
 
117
130
  ## Retries
package/dist/index.cjs CHANGED
@@ -193,21 +193,50 @@ var AmigoError = class extends Error {
193
193
  };
194
194
  }
195
195
  };
196
+ function isAmigoErrorOptions(value) {
197
+ if (!value || typeof value !== "object") return false;
198
+ const options = value;
199
+ return "statusCode" in options && (typeof options.statusCode === "number" || options.statusCode === void 0) || "errorCode" in options && (typeof options.errorCode === "string" || options.errorCode === void 0) || "context" in options && (typeof options.context === "object" || options.context === void 0);
200
+ }
196
201
  var BadRequestError = class extends AmigoError {
202
+ constructor(message, options) {
203
+ super(message, { ...options, statusCode: options?.statusCode ?? 400 });
204
+ }
197
205
  };
198
206
  var AuthenticationError = class extends AmigoError {
207
+ constructor(message, options) {
208
+ super(message, { ...options, statusCode: options?.statusCode ?? 401 });
209
+ }
199
210
  };
200
211
  var PermissionError = class extends AmigoError {
212
+ constructor(message, options) {
213
+ super(message, { ...options, statusCode: options?.statusCode ?? 403 });
214
+ }
201
215
  };
202
216
  var NotFoundError = class extends AmigoError {
217
+ constructor(message, options) {
218
+ super(message, { ...options, statusCode: options?.statusCode ?? 404 });
219
+ }
203
220
  };
204
221
  var ConflictError = class extends AmigoError {
222
+ constructor(message, options) {
223
+ super(message, { ...options, statusCode: options?.statusCode ?? 409 });
224
+ }
205
225
  };
206
226
  var RateLimitError = class extends AmigoError {
227
+ constructor(message, options) {
228
+ super(message, { ...options, statusCode: options?.statusCode ?? 429 });
229
+ }
207
230
  };
208
231
  var ServerError = class extends AmigoError {
232
+ constructor(message, options) {
233
+ super(message, { ...options, statusCode: options?.statusCode ?? 500 });
234
+ }
209
235
  };
210
236
  var ServiceUnavailableError = class extends ServerError {
237
+ constructor(message, options) {
238
+ super(message, { ...options, statusCode: options?.statusCode ?? 503 });
239
+ }
211
240
  };
212
241
  var ConfigurationError = class extends AmigoError {
213
242
  constructor(message, field) {
@@ -216,9 +245,14 @@ var ConfigurationError = class extends AmigoError {
216
245
  }
217
246
  };
218
247
  var ValidationError = class extends BadRequestError {
219
- constructor(msg, fieldErrors) {
220
- super(msg);
248
+ constructor(msg, optionsOrFieldErrors, fieldErrors) {
249
+ const isErrorOptions = isAmigoErrorOptions(optionsOrFieldErrors);
250
+ super(
251
+ msg,
252
+ isErrorOptions ? { ...optionsOrFieldErrors, statusCode: optionsOrFieldErrors.statusCode ?? 422 } : { statusCode: 422 }
253
+ );
221
254
  this.fieldErrors = fieldErrors;
255
+ this.fieldErrors = isErrorOptions ? fieldErrors : optionsOrFieldErrors;
222
256
  }
223
257
  };
224
258
  var NetworkError = class extends AmigoError {