@amigo-ai/platform-sdk 0.4.2 → 0.4.4
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.
- package/README.md +72 -15
- package/api.md +14 -21
- package/assets/readme/amigo-banner.png +0 -0
- package/assets/readme/platform-architecture.svg +117 -0
- package/dist/core/openapi-client.js +89 -55
- package/dist/core/openapi-client.js.map +1 -1
- package/dist/core/request-options.js +80 -0
- package/dist/core/request-options.js.map +1 -0
- package/dist/core/retry.js +29 -1
- package/dist/core/retry.js.map +1 -1
- package/dist/core/webhooks.js +9 -0
- package/dist/core/webhooks.js.map +1 -1
- package/dist/index.cjs +383 -123
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +81 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +383 -123
- package/dist/index.mjs.map +3 -3
- package/dist/resources/base.js +33 -0
- package/dist/resources/base.js.map +1 -1
- package/dist/types/core/openapi-client.d.ts +2 -0
- package/dist/types/core/openapi-client.d.ts.map +1 -1
- package/dist/types/core/request-options.d.ts +66 -0
- package/dist/types/core/request-options.d.ts.map +1 -0
- package/dist/types/core/retry.d.ts.map +1 -1
- package/dist/types/core/webhooks.d.ts.map +1 -1
- package/dist/types/generated/api.d.ts +1132 -244
- package/dist/types/generated/api.d.ts.map +1 -1
- package/dist/types/index.d.ts +14 -23
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/actions.d.ts.map +1 -1
- package/dist/types/resources/agents.d.ts +4 -4
- package/dist/types/resources/agents.d.ts.map +1 -1
- package/dist/types/resources/analytics.d.ts +1 -3
- package/dist/types/resources/analytics.d.ts.map +1 -1
- package/dist/types/resources/api-keys.d.ts.map +1 -1
- package/dist/types/resources/audit.d.ts.map +1 -1
- package/dist/types/resources/base.d.ts +8 -3
- package/dist/types/resources/base.d.ts.map +1 -1
- package/dist/types/resources/billing.d.ts.map +1 -1
- package/dist/types/resources/calls.d.ts +1 -1
- package/dist/types/resources/calls.d.ts.map +1 -1
- package/dist/types/resources/context-graphs.d.ts.map +1 -1
- package/dist/types/resources/data-sources.d.ts.map +1 -1
- package/dist/types/resources/functions.d.ts.map +1 -1
- package/dist/types/resources/integrations.d.ts.map +1 -1
- package/dist/types/resources/memory.d.ts.map +1 -1
- package/dist/types/resources/operators.d.ts +18 -18
- package/dist/types/resources/operators.d.ts.map +1 -1
- package/dist/types/resources/personas.d.ts.map +1 -1
- package/dist/types/resources/phone-numbers.d.ts +8 -8
- package/dist/types/resources/phone-numbers.d.ts.map +1 -1
- package/dist/types/resources/review-queue.d.ts +6 -6
- package/dist/types/resources/review-queue.d.ts.map +1 -1
- package/dist/types/resources/safety.d.ts.map +1 -1
- package/dist/types/resources/services.d.ts.map +1 -1
- package/dist/types/resources/settings.d.ts.map +1 -1
- package/dist/types/resources/simulations.d.ts.map +1 -1
- package/dist/types/resources/skills.d.ts.map +1 -1
- package/dist/types/resources/triggers.d.ts +35 -35
- package/dist/types/resources/triggers.d.ts.map +1 -1
- package/dist/types/resources/webhook-destinations.d.ts +6 -6
- package/dist/types/resources/webhook-destinations.d.ts.map +1 -1
- package/dist/types/resources/workspaces.d.ts.map +1 -1
- package/dist/types/resources/world.d.ts.map +1 -1
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -1,10 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/readme/amigo-banner.png" alt="Amigo banner" width="100%" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
[](https://github.com/amigo-ai/amigo-platform-typescript-sdk/actions/workflows/test.yml)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
<h1 align="center">@amigo-ai/platform-sdk</h1>
|
|
6
6
|
|
|
7
|
-
Official TypeScript SDK for the
|
|
7
|
+
<p align="center">Official TypeScript SDK for the <a href="https://api.platform.amigo.ai/v1/docs">Amigo Platform API</a>.</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://docs.amigo.ai">Product Docs</a>
|
|
11
|
+
·
|
|
12
|
+
<a href="https://docs.amigo.ai/developer-guide">Developer Guide</a>
|
|
13
|
+
·
|
|
14
|
+
<a href="https://docs.amigo.ai/api-reference">API Reference</a>
|
|
15
|
+
·
|
|
16
|
+
<a href="./examples/README.md">Examples</a>
|
|
17
|
+
·
|
|
18
|
+
<a href="./api.md">API Surface</a>
|
|
19
|
+
·
|
|
20
|
+
<a href="./CHANGELOG.md">Changelog</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="https://www.npmjs.com/package/@amigo-ai/platform-sdk"><img src="https://img.shields.io/npm/v/@amigo-ai/platform-sdk.svg" alt="npm version" /></a>
|
|
25
|
+
<a href="https://github.com/amigo-ai/amigo-platform-typescript-sdk/actions/workflows/test.yml"><img src="https://github.com/amigo-ai/amigo-platform-typescript-sdk/actions/workflows/test.yml/badge.svg" alt="CI" /></a>
|
|
26
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License" /></a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
Typed from the committed `openapi.json` snapshot, validated on Node 18, 20, and 22, and tested as packaged ESM and CommonJS tarballs before release.
|
|
30
|
+
|
|
31
|
+
## Platform context
|
|
32
|
+
|
|
33
|
+
The SDK is the typed client boundary between your runtime and the workspace-scoped Platform API. The API then fronts the platform systems that power agents, actions, calls, analytics, world state, connectors, and webhooks.
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
| Need | Best entry point |
|
|
40
|
+
| ------------------------------------------- | -------------------------------------------------------- |
|
|
41
|
+
| Product architecture and deployment context | [docs.amigo.ai](https://docs.amigo.ai/) |
|
|
42
|
+
| Tutorials and integration guidance | [Developer Guide](https://docs.amigo.ai/developer-guide) |
|
|
43
|
+
| Endpoint-by-endpoint REST reference | [API Reference](https://docs.amigo.ai/api-reference) |
|
|
44
|
+
| Repo-local SDK examples | [examples/README.md](./examples/README.md) |
|
|
45
|
+
| Generated package surface | [api.md](./api.md) |
|
|
46
|
+
| Published release history | [CHANGELOG.md](./CHANGELOG.md) |
|
|
47
|
+
|
|
48
|
+
The docs site remains the primary reference. The repo-local examples stay close to the shipped package surface and are typechecked in CI to reduce drift.
|
|
8
49
|
|
|
9
50
|
## Installation
|
|
10
51
|
|
|
@@ -39,14 +80,6 @@ const stats = await client.analytics.getCalls({ days: 30 })
|
|
|
39
80
|
console.log(stats.total_calls, stats.avg_duration_seconds)
|
|
40
81
|
```
|
|
41
82
|
|
|
42
|
-
## Examples and Docs
|
|
43
|
-
|
|
44
|
-
- Product docs and API reference: [docs.amigo.ai](https://docs.amigo.ai/)
|
|
45
|
-
- Repo-local SDK examples: [examples/README.md](./examples/README.md)
|
|
46
|
-
- Repo-local API surface guide: [api.md](./api.md)
|
|
47
|
-
|
|
48
|
-
The docs site remains the primary reference. The examples in this repo stay close to the package surface and are typechecked in CI to reduce drift.
|
|
49
|
-
|
|
50
83
|
## Configuration
|
|
51
84
|
|
|
52
85
|
| Option | Type | Required | Description |
|
|
@@ -105,11 +138,33 @@ Public builds are generated from the committed [`openapi.json`](./openapi.json)
|
|
|
105
138
|
npm run openapi:sync
|
|
106
139
|
```
|
|
107
140
|
|
|
108
|
-
For a repo-local overview of the exported client surface, see [api.md](./api.md).
|
|
141
|
+
For a repo-local overview of the exported client surface, see the generated [api.md](./api.md).
|
|
109
142
|
|
|
110
143
|
## Advanced request control
|
|
111
144
|
|
|
112
|
-
|
|
145
|
+
The normal resource surface supports scoped request overrides, so you can keep the ergonomic API while adding timeout, retry, and header controls:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const agents = await client
|
|
149
|
+
.withOptions({
|
|
150
|
+
timeout: 5_000,
|
|
151
|
+
maxRetries: 1,
|
|
152
|
+
headers: { 'X-Debug-Trace': 'true' },
|
|
153
|
+
})
|
|
154
|
+
.agents.list({ limit: 10 })
|
|
155
|
+
|
|
156
|
+
console.log(agents._request_id)
|
|
157
|
+
console.log(agents.lastResponse.statusCode)
|
|
158
|
+
console.log(agents.items)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
You can scope options to a single resource as well:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const agent = await client.agents.withOptions({ timeout: 2_000 }).get('agent-id')
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
For lower-level control, use the built-in typed HTTP helpers. Workspace-scoped routes automatically receive your configured `workspaceId`, and the configured value wins if `workspace_id` is provided manually.
|
|
113
168
|
|
|
114
169
|
```typescript
|
|
115
170
|
const result = await client.GET('/v1/{workspace_id}/agents', {
|
|
@@ -133,6 +188,8 @@ Available helpers:
|
|
|
133
188
|
- `client.DELETE(...)`
|
|
134
189
|
- `client.HEAD(...)`
|
|
135
190
|
- `client.OPTIONS(...)`
|
|
191
|
+
- `client.withOptions(...)`
|
|
192
|
+
- `client.<resource>.withOptions(...)`
|
|
136
193
|
|
|
137
194
|
### Response metadata
|
|
138
195
|
|
package/api.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# API Surface
|
|
2
2
|
|
|
3
|
+
> Generated from source. Do not edit directly.
|
|
4
|
+
|
|
3
5
|
Repo-local reference for the public TypeScript SDK surface. This document complements the product docs and stays focused on the package exports that ship from this repository.
|
|
4
6
|
|
|
5
7
|
## Client
|
|
@@ -14,17 +16,18 @@ Configuration fields:
|
|
|
14
16
|
- `retry?: RetryOptions`
|
|
15
17
|
- `maxRetries?: number`
|
|
16
18
|
- `timeout?: number`
|
|
17
|
-
- `headers?:
|
|
19
|
+
- `headers?: HeadersOptions`
|
|
18
20
|
- `hooks?: ClientHooks`
|
|
19
|
-
- `fetch?: typeof fetch`
|
|
21
|
+
- `fetch?: typeof globalThis.fetch`
|
|
20
22
|
|
|
21
23
|
Instance fields:
|
|
22
24
|
|
|
23
25
|
- `workspaceId: string`
|
|
24
26
|
- `baseUrl: string`
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Client methods:
|
|
27
29
|
|
|
30
|
+
- `withOptions(options)`
|
|
28
31
|
- `GET(path, options?)`
|
|
29
32
|
- `POST(path, options?)`
|
|
30
33
|
- `PUT(path, options?)`
|
|
@@ -35,7 +38,8 @@ Low-level typed request helpers:
|
|
|
35
38
|
|
|
36
39
|
Notes:
|
|
37
40
|
|
|
38
|
-
- Workspace-scoped paths
|
|
41
|
+
- Workspace-scoped paths receive the configured `workspaceId` automatically, and the configured value wins if `workspace_id` is provided manually.
|
|
42
|
+
- `client.withOptions(options)` and `client.<resource>.withOptions(options)` layer headers, timeout, and retry overrides onto the normal resource surface.
|
|
39
43
|
- Low-level helpers return `AmigoResponse<T>` with `data`, `response`, `requestId`, and `rateLimit`.
|
|
40
44
|
- Object responses from resource methods include `_request_id` and `lastResponse` metadata.
|
|
41
45
|
|
|
@@ -43,27 +47,16 @@ Notes:
|
|
|
43
47
|
|
|
44
48
|
- Errors: `AmigoError`, `BadRequestError`, `AuthenticationError`, `PermissionError`, `NotFoundError`, `ConflictError`, `ValidationError`, `RateLimitError`, `ServerError`, `ServiceUnavailableError`, `NetworkError`, `RequestTimeoutError`, `ParseError`, `ConfigurationError`
|
|
45
49
|
- Error guards: `isAmigoError`, `isNotFoundError`, `isRateLimitError`, `isAuthenticationError`, `isRequestTimeoutError`
|
|
50
|
+
- Request option types: `AmigoRequestOptions`, `ScopedRequestOptions`
|
|
46
51
|
- Webhooks: `verifyWebhookSignature`, `parseWebhookEvent`, `WebhookVerificationError`
|
|
47
|
-
- Pagination: `paginate`
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- Generated types: `components`, `operations`, `paths`
|
|
51
|
-
|
|
52
|
-
## Response types
|
|
53
|
-
|
|
54
|
-
- `AmigoRequestOptions<T>`
|
|
55
|
-
- `AmigoResponse<T>`
|
|
56
|
-
- `ResponseMetadata`
|
|
57
|
-
- `LastResponseInfo`
|
|
58
|
-
- `RetryOptions`
|
|
59
|
-
- `RateLimitInfo`
|
|
60
|
-
- `ClientHooks`
|
|
61
|
-
- `RequestHookContext`
|
|
62
|
-
- `ResponseHookContext`
|
|
63
|
-
- `ErrorHookContext`
|
|
52
|
+
- Pagination and response helpers: `paginate`, `buildLastResponse`, `extractRequestId`
|
|
53
|
+
- Response and hook types: `PaginatedList`, `ListParams`, `LastResponseInfo`, `ResponseMetadata`, `WithResponseMetadata`, `AmigoResponse`, `RetryOptions`, `RateLimitInfo`, `ClientHooks`, `RequestHookContext`, `ResponseHookContext`, `ErrorHookContext`
|
|
54
|
+
- Generated OpenAPI types: `paths`, `components`, `operations`
|
|
64
55
|
|
|
65
56
|
## Resources
|
|
66
57
|
|
|
58
|
+
All workspace-scoped resources also expose `withOptions(options)`.
|
|
59
|
+
|
|
67
60
|
### `workspaces`
|
|
68
61
|
|
|
69
62
|
- `create`
|
|
Binary file
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="540" viewBox="0 0 1200 540">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0%" stop-color="#081E2A"/>
|
|
5
|
+
<stop offset="55%" stop-color="#0A2C3B"/>
|
|
6
|
+
<stop offset="100%" stop-color="#051822"/>
|
|
7
|
+
</linearGradient>
|
|
8
|
+
<radialGradient id="glowLeft" cx="0.2" cy="0.22" r="0.7">
|
|
9
|
+
<stop offset="0%" stop-color="#26C6FF" stop-opacity="0.18"/>
|
|
10
|
+
<stop offset="100%" stop-color="#26C6FF" stop-opacity="0"/>
|
|
11
|
+
</radialGradient>
|
|
12
|
+
<radialGradient id="glowRight" cx="0.84" cy="0.16" r="0.55">
|
|
13
|
+
<stop offset="0%" stop-color="#7DE1B5" stop-opacity="0.12"/>
|
|
14
|
+
<stop offset="100%" stop-color="#7DE1B5" stop-opacity="0"/>
|
|
15
|
+
</radialGradient>
|
|
16
|
+
<linearGradient id="panelStroke" x1="0" y1="0" x2="1" y2="1">
|
|
17
|
+
<stop offset="0%" stop-color="#FFFFFF" stop-opacity="0.14"/>
|
|
18
|
+
<stop offset="100%" stop-color="#92B4C3" stop-opacity="0.06"/>
|
|
19
|
+
</linearGradient>
|
|
20
|
+
<linearGradient id="highlightStroke" x1="0" y1="0" x2="1" y2="1">
|
|
21
|
+
<stop offset="0%" stop-color="#82E4FF" stop-opacity="0.92"/>
|
|
22
|
+
<stop offset="100%" stop-color="#64AFFF" stop-opacity="0.56"/>
|
|
23
|
+
</linearGradient>
|
|
24
|
+
<linearGradient id="arrowStroke" x1="0" y1="0" x2="1" y2="0">
|
|
25
|
+
<stop offset="0%" stop-color="#8EE4FF"/>
|
|
26
|
+
<stop offset="100%" stop-color="#7FC8FF"/>
|
|
27
|
+
</linearGradient>
|
|
28
|
+
<marker id="arrow" viewBox="0 0 12 12" refX="10.5" refY="6" markerWidth="8" markerHeight="8" orient="auto">
|
|
29
|
+
<path d="M 0 0 L 12 6 L 0 12 z" fill="#8EE4FF"/>
|
|
30
|
+
</marker>
|
|
31
|
+
</defs>
|
|
32
|
+
|
|
33
|
+
<rect width="1200" height="540" fill="url(#bg)"/>
|
|
34
|
+
<rect width="1200" height="540" fill="url(#glowLeft)"/>
|
|
35
|
+
<rect width="1200" height="540" fill="url(#glowRight)"/>
|
|
36
|
+
|
|
37
|
+
<text x="68" y="62" font-family="'SFMono-Regular', Menlo, monospace" font-size="13" font-weight="600" fill="#BBD1DC" letter-spacing="2.4">PLATFORM CONTEXT</text>
|
|
38
|
+
<text x="68" y="98" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="30" font-weight="700" fill="white">How the TypeScript SDK fits into the stack</text>
|
|
39
|
+
<text x="68" y="126" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="15" fill="#A9C0CB">Your runtime calls the SDK, the SDK targets the workspace-scoped Platform API, and the API fronts the operational systems behind the product.</text>
|
|
40
|
+
|
|
41
|
+
<rect x="60" y="152" width="246" height="208" rx="22" fill="white" fill-opacity="0.045" stroke="url(#panelStroke)" stroke-width="1"/>
|
|
42
|
+
<text x="88" y="184" font-family="'SFMono-Regular', Menlo, monospace" font-size="12" font-weight="600" fill="#B4C9D4" letter-spacing="2">YOUR RUNTIME</text>
|
|
43
|
+
|
|
44
|
+
<rect x="82" y="206" width="202" height="42" rx="12" fill="#173E4D" fill-opacity="0.95" stroke="white" stroke-opacity="0.06"/>
|
|
45
|
+
<text x="183" y="231" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="16" font-weight="600" fill="white">Node servers</text>
|
|
46
|
+
|
|
47
|
+
<rect x="82" y="260" width="202" height="42" rx="12" fill="#173E4D" fill-opacity="0.88" stroke="white" stroke-opacity="0.06"/>
|
|
48
|
+
<text x="183" y="285" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="16" font-weight="600" fill="white">Workers and jobs</text>
|
|
49
|
+
|
|
50
|
+
<rect x="82" y="314" width="202" height="42" rx="12" fill="#173E4D" fill-opacity="0.82" stroke="white" stroke-opacity="0.06"/>
|
|
51
|
+
<text x="183" y="339" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="16" font-weight="600" fill="white">Edge or BFF layers</text>
|
|
52
|
+
|
|
53
|
+
<rect x="366" y="128" width="338" height="256" rx="24" fill="#0D3446" fill-opacity="0.9" stroke="url(#highlightStroke)" stroke-width="1.5"/>
|
|
54
|
+
<text x="394" y="162" font-family="'SFMono-Regular', Menlo, monospace" font-size="12" font-weight="600" fill="#BFEBFF" letter-spacing="2">SDK LAYER</text>
|
|
55
|
+
<text x="394" y="214" font-family="'SFMono-Regular', Menlo, monospace" font-size="28" font-weight="700" fill="white">@amigo-ai/platform-sdk</text>
|
|
56
|
+
<text x="394" y="245" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="16" fill="#C4D8E1">Typed workspace-scoped client for the Platform API.</text>
|
|
57
|
+
<text x="394" y="271" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="16" fill="#C4D8E1">It keeps auth, retries, webhooks, request control,</text>
|
|
58
|
+
<text x="394" y="295" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="16" fill="#C4D8E1">and generated types on the package surface.</text>
|
|
59
|
+
|
|
60
|
+
<rect x="394" y="321" width="114" height="30" rx="15" fill="#123D50" stroke="#7CCFFF" stroke-opacity="0.28"/>
|
|
61
|
+
<text x="451" y="340" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="13" font-weight="600" fill="#DFF4FF">Typed surface</text>
|
|
62
|
+
<rect x="519" y="321" width="104" height="30" rx="15" fill="#123D50" stroke="#7CCFFF" stroke-opacity="0.22"/>
|
|
63
|
+
<text x="571" y="340" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="13" font-weight="600" fill="#DFF4FF">ESM + CJS</text>
|
|
64
|
+
<rect x="394" y="360" width="110" height="30" rx="15" fill="#123D50" stroke="#7CCFFF" stroke-opacity="0.22"/>
|
|
65
|
+
<text x="449" y="379" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="13" font-weight="600" fill="#DFF4FF">Webhooks</text>
|
|
66
|
+
<rect x="515" y="360" width="136" height="30" rx="15" fill="#123D50" stroke="#7CCFFF" stroke-opacity="0.22"/>
|
|
67
|
+
<text x="583" y="379" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="13" font-weight="600" fill="#DFF4FF">Request control</text>
|
|
68
|
+
|
|
69
|
+
<rect x="764" y="110" width="376" height="296" rx="22" fill="white" fill-opacity="0.045" stroke="url(#panelStroke)" stroke-width="1"/>
|
|
70
|
+
<text x="792" y="142" font-family="'SFMono-Regular', Menlo, monospace" font-size="12" font-weight="600" fill="#B4C9D4" letter-spacing="2">PLATFORM API</text>
|
|
71
|
+
<text x="792" y="172" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="15" fill="#C0D4DE">Workspace-scoped REST resources exposed by the SDK.</text>
|
|
72
|
+
|
|
73
|
+
<rect x="792" y="198" width="148" height="54" rx="14" fill="#173E4D" fill-opacity="0.9" stroke="white" stroke-opacity="0.06"/>
|
|
74
|
+
<text x="866" y="222" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="17" font-weight="600" fill="white">Agents</text>
|
|
75
|
+
<text x="866" y="241" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="12" fill="#B0C5CF">Actions, skills, services</text>
|
|
76
|
+
|
|
77
|
+
<rect x="962" y="198" width="148" height="54" rx="14" fill="#173E4D" fill-opacity="0.86" stroke="white" stroke-opacity="0.06"/>
|
|
78
|
+
<text x="1036" y="222" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="17" font-weight="600" fill="white">Calls</text>
|
|
79
|
+
<text x="1036" y="241" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="12" fill="#B0C5CF">Voice, history, recordings</text>
|
|
80
|
+
|
|
81
|
+
<rect x="792" y="270" width="148" height="54" rx="14" fill="#173E4D" fill-opacity="0.86" stroke="white" stroke-opacity="0.06"/>
|
|
82
|
+
<text x="866" y="294" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="17" font-weight="600" fill="white">World</text>
|
|
83
|
+
<text x="866" y="313" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="12" fill="#B0C5CF">Entities and events</text>
|
|
84
|
+
|
|
85
|
+
<rect x="962" y="270" width="148" height="54" rx="14" fill="#173E4D" fill-opacity="0.82" stroke="white" stroke-opacity="0.06"/>
|
|
86
|
+
<text x="1036" y="294" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="17" font-weight="600" fill="white">Analytics</text>
|
|
87
|
+
<text x="1036" y="313" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="12" fill="#B0C5CF">Dashboards and trends</text>
|
|
88
|
+
|
|
89
|
+
<rect x="792" y="342" width="148" height="54" rx="14" fill="#173E4D" fill-opacity="0.82" stroke="white" stroke-opacity="0.06"/>
|
|
90
|
+
<text x="866" y="366" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="17" font-weight="600" fill="white">Webhooks</text>
|
|
91
|
+
<text x="866" y="385" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="12" fill="#B0C5CF">Signed inbound events</text>
|
|
92
|
+
|
|
93
|
+
<rect x="962" y="342" width="148" height="54" rx="14" fill="#173E4D" fill-opacity="0.78" stroke="white" stroke-opacity="0.06"/>
|
|
94
|
+
<text x="1036" y="366" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="17" font-weight="600" fill="white">Operations</text>
|
|
95
|
+
<text x="1036" y="385" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="12" fill="#B0C5CF">Operators, integrations, numbers</text>
|
|
96
|
+
|
|
97
|
+
<path d="M 306 256 C 328 256 344 256 366 256" fill="none" stroke="url(#arrowStroke)" stroke-width="2.5" stroke-linecap="round" marker-end="url(#arrow)"/>
|
|
98
|
+
|
|
99
|
+
<path d="M 704 256 C 728 256 740 256 764 256" fill="none" stroke="url(#arrowStroke)" stroke-width="2.5" stroke-linecap="round" marker-end="url(#arrow)"/>
|
|
100
|
+
|
|
101
|
+
<path d="M 952 406 C 952 420 952 430 952 446" fill="none" stroke="url(#arrowStroke)" stroke-width="2.5" stroke-linecap="round" marker-end="url(#arrow)"/>
|
|
102
|
+
|
|
103
|
+
<rect x="60" y="448" width="1080" height="70" rx="20" fill="white" fill-opacity="0.05" stroke="url(#panelStroke)" stroke-width="1"/>
|
|
104
|
+
<text x="88" y="477" font-family="'SFMono-Regular', Menlo, monospace" font-size="12" font-weight="600" fill="#B4C9D4" letter-spacing="2">PLATFORM SYSTEMS</text>
|
|
105
|
+
|
|
106
|
+
<rect x="84" y="487" width="238" height="18" rx="9" fill="#173E4D" fill-opacity="0.84"/>
|
|
107
|
+
<text x="203" y="500" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="11" font-weight="600" fill="#D6E7EE">Connectors and EHR sync</text>
|
|
108
|
+
|
|
109
|
+
<rect x="350" y="487" width="222" height="18" rx="9" fill="#173E4D" fill-opacity="0.84"/>
|
|
110
|
+
<text x="461" y="500" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="11" font-weight="600" fill="#D6E7EE">World model and projections</text>
|
|
111
|
+
|
|
112
|
+
<rect x="600" y="487" width="226" height="18" rx="9" fill="#173E4D" fill-opacity="0.84"/>
|
|
113
|
+
<text x="713" y="500" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="11" font-weight="600" fill="#D6E7EE">Operators and outbound automation</text>
|
|
114
|
+
|
|
115
|
+
<rect x="854" y="487" width="262" height="18" rx="9" fill="#173E4D" fill-opacity="0.84"/>
|
|
116
|
+
<text x="985" y="500" text-anchor="middle" font-family="'Inter', 'Helvetica Neue', Arial, sans-serif" font-size="11" font-weight="600" fill="#D6E7EE">Observability, analytics, and webhook delivery</text>
|
|
117
|
+
</svg>
|
|
@@ -9,70 +9,27 @@ import createClientImport from 'openapi-fetch';
|
|
|
9
9
|
import { createAuthMiddleware } from './auth.js';
|
|
10
10
|
import { createApiError, NetworkError, RequestTimeoutError } from './errors.js';
|
|
11
11
|
import { parseRateLimitHeaders } from './rate-limit.js';
|
|
12
|
+
import { stripRequestControls, } from './request-options.js';
|
|
12
13
|
import { shouldRetry, computeDelay, resolveRetryOptions } from './retry.js';
|
|
13
14
|
import { extractRequestId } from './utils.js';
|
|
14
15
|
// Handle ESM/CJS interop for openapi-fetch (esbuild __toESM wrapper)
|
|
15
16
|
const createClient = typeof createClientImport === 'function'
|
|
16
17
|
? createClientImport
|
|
17
18
|
: createClientImport.default;
|
|
19
|
+
const platformClientContext = new WeakMap();
|
|
18
20
|
export function createPlatformClient(config) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const requestRetry = getRequestOption(baseRequest, 'retry');
|
|
25
|
-
const requestMaxRetries = getRequestOption(baseRequest, 'maxRetries');
|
|
26
|
-
const retryOpts = resolveRetryOptions(requestRetry ?? config.retry, requestMaxRetries ?? config.maxRetries);
|
|
27
|
-
const timeoutMs = getRequestOption(baseRequest, 'timeout') ?? config.timeout;
|
|
28
|
-
const isIdempotent = method === 'GET' || method === 'HEAD' || method === 'OPTIONS';
|
|
29
|
-
for (let attempt = 0; attempt < retryOpts.maxAttempts; attempt++) {
|
|
30
|
-
let response;
|
|
31
|
-
let error;
|
|
32
|
-
let timedOut = false;
|
|
33
|
-
try {
|
|
34
|
-
const prepared = prepareRequestForAttempt(baseRequest, timeoutMs);
|
|
35
|
-
try {
|
|
36
|
-
response = await baseFetch(prepared.request, init);
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
timedOut = prepared.timedOut;
|
|
40
|
-
prepared.cleanup();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
error = err;
|
|
45
|
-
}
|
|
46
|
-
if (!error && response && response.ok)
|
|
47
|
-
return response;
|
|
48
|
-
const ctx = { method, attempt, response: response, options: retryOpts };
|
|
49
|
-
const attemptsRemain = attempt + 1 < retryOpts.maxAttempts;
|
|
50
|
-
if (error) {
|
|
51
|
-
if (timedOut) {
|
|
52
|
-
throw new RequestTimeoutError(`Request timed out after ${timeoutMs}ms`, timeoutMs, error);
|
|
53
|
-
}
|
|
54
|
-
if (isIdempotent && attemptsRemain) {
|
|
55
|
-
await sleep(computeDelay(attempt, new Response(), retryOpts));
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
throw new NetworkError(`Network error: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
59
|
-
}
|
|
60
|
-
if (response && attemptsRemain && shouldRetry(ctx)) {
|
|
61
|
-
const delay = computeDelay(attempt, response, retryOpts);
|
|
62
|
-
if (baseRequest.signal.aborted)
|
|
63
|
-
return response;
|
|
64
|
-
await sleep(delay);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
return response;
|
|
68
|
-
}
|
|
69
|
-
throw new NetworkError('Retry loop exhausted');
|
|
21
|
+
const transport = toRequestTransport(config.fetch ?? globalThis.fetch);
|
|
22
|
+
const defaults = {
|
|
23
|
+
retry: config.retry,
|
|
24
|
+
maxRetries: config.maxRetries,
|
|
25
|
+
timeout: config.timeout,
|
|
70
26
|
};
|
|
71
27
|
const client = createClient({
|
|
72
28
|
baseUrl: config.baseUrl,
|
|
73
|
-
fetch:
|
|
29
|
+
fetch: createRetryingFetch(transport, defaults),
|
|
74
30
|
headers: config.headers,
|
|
75
31
|
});
|
|
32
|
+
platformClientContext.set(client, { transport, defaults });
|
|
76
33
|
// Error middleware — convert HTTP errors to typed AmigoError subclasses
|
|
77
34
|
const errorMiddleware = {
|
|
78
35
|
async onResponse({ response }) {
|
|
@@ -114,12 +71,89 @@ export function createPlatformClient(config) {
|
|
|
114
71
|
}
|
|
115
72
|
return client;
|
|
116
73
|
}
|
|
74
|
+
export function applyPlatformRequestOptions(client, init) {
|
|
75
|
+
if (!init) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const context = platformClientContext.get(client);
|
|
79
|
+
const stripped = stripRequestControls(init);
|
|
80
|
+
if (!context) {
|
|
81
|
+
return stripped;
|
|
82
|
+
}
|
|
83
|
+
const overrideFetch = stripped?.fetch;
|
|
84
|
+
const hasControlOverride = overrideFetch !== undefined ||
|
|
85
|
+
init.timeout !== undefined ||
|
|
86
|
+
init.maxRetries !== undefined ||
|
|
87
|
+
init.retry !== undefined;
|
|
88
|
+
if (!hasControlOverride) {
|
|
89
|
+
return stripped;
|
|
90
|
+
}
|
|
91
|
+
const transport = toRequestTransport((overrideFetch ?? context.transport));
|
|
92
|
+
const fetch = createRetryingFetch(transport, {
|
|
93
|
+
timeout: init.timeout ?? context.defaults.timeout,
|
|
94
|
+
maxRetries: init.maxRetries ?? context.defaults.maxRetries,
|
|
95
|
+
retry: init.retry ?? context.defaults.retry,
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
...stripped,
|
|
99
|
+
fetch,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function createRetryingFetch(transport, defaults) {
|
|
103
|
+
return async (input, init) => {
|
|
104
|
+
const baseRequest = input instanceof Request ? input : new Request(input, init);
|
|
105
|
+
const method = baseRequest.method.toUpperCase();
|
|
106
|
+
const retryOpts = resolveRetryOptions(defaults.retry, defaults.maxRetries);
|
|
107
|
+
const timeoutMs = defaults.timeout;
|
|
108
|
+
const isIdempotent = method === 'GET' || method === 'HEAD' || method === 'OPTIONS';
|
|
109
|
+
for (let attempt = 0; attempt < retryOpts.maxAttempts; attempt++) {
|
|
110
|
+
let response;
|
|
111
|
+
let error;
|
|
112
|
+
let timedOut = false;
|
|
113
|
+
try {
|
|
114
|
+
const prepared = prepareRequestForAttempt(baseRequest, timeoutMs);
|
|
115
|
+
try {
|
|
116
|
+
response = await transport(prepared.request);
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
timedOut = prepared.timedOut;
|
|
120
|
+
prepared.cleanup();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
error = err;
|
|
125
|
+
}
|
|
126
|
+
if (!error && response && response.ok)
|
|
127
|
+
return response;
|
|
128
|
+
const ctx = { method, attempt, response: response, options: retryOpts };
|
|
129
|
+
const attemptsRemain = attempt + 1 < retryOpts.maxAttempts;
|
|
130
|
+
if (error) {
|
|
131
|
+
if (timedOut) {
|
|
132
|
+
throw new RequestTimeoutError(`Request timed out after ${timeoutMs}ms`, timeoutMs, error);
|
|
133
|
+
}
|
|
134
|
+
if (isIdempotent && attemptsRemain) {
|
|
135
|
+
await sleep(computeDelay(attempt, new Response(), retryOpts));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
throw new NetworkError(`Network error: ${error instanceof Error ? error.message : String(error)}`, error);
|
|
139
|
+
}
|
|
140
|
+
if (response && attemptsRemain && shouldRetry(ctx)) {
|
|
141
|
+
const delay = computeDelay(attempt, response, retryOpts);
|
|
142
|
+
if (baseRequest.signal.aborted)
|
|
143
|
+
return response;
|
|
144
|
+
await sleep(delay);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
throw new NetworkError('Retry loop exhausted');
|
|
150
|
+
};
|
|
151
|
+
}
|
|
117
152
|
function sleep(ms) {
|
|
118
153
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
119
154
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
return value;
|
|
155
|
+
function toRequestTransport(fetcher) {
|
|
156
|
+
return async (input) => fetcher(input);
|
|
123
157
|
}
|
|
124
158
|
function prepareRequestForAttempt(request, timeoutMs) {
|
|
125
159
|
const attemptRequest = request.clone();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-client.js","sourceRoot":"","sources":["../../src/core/openapi-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,kBAA4D,MAAM,eAAe,CAAA;AAExF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAqB,MAAM,YAAY,CAAA;AAC9F,OAAO,EAAE,gB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|
|
5
|
+
const rest = { ...options };
|
|
6
|
+
delete rest.timeout;
|
|
7
|
+
delete rest.maxRetries;
|
|
8
|
+
delete rest.retry;
|
|
9
|
+
return rest;
|
|
10
|
+
}
|
|
11
|
+
export function mergeRequestOptions(base, override) {
|
|
12
|
+
if (!base) {
|
|
13
|
+
return override;
|
|
14
|
+
}
|
|
15
|
+
if (!override) {
|
|
16
|
+
return base;
|
|
17
|
+
}
|
|
18
|
+
const mergeableOverride = override;
|
|
19
|
+
return {
|
|
20
|
+
...base,
|
|
21
|
+
...override,
|
|
22
|
+
headers: mergeHeaders(base.headers, mergeableOverride.headers),
|
|
23
|
+
signal: mergeableOverride.signal ?? base.signal,
|
|
24
|
+
timeout: mergeableOverride.timeout ?? base.timeout,
|
|
25
|
+
maxRetries: mergeableOverride.maxRetries ?? base.maxRetries,
|
|
26
|
+
retry: mergeableOverride.retry ?? base.retry,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function mergeScopedRequestOptions(base, override) {
|
|
30
|
+
return mergeRequestOptions(base, override) ?? override;
|
|
31
|
+
}
|
|
32
|
+
export function mergeHeaders(base, override) {
|
|
33
|
+
if (!base && !override) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const headers = new Headers();
|
|
37
|
+
let hasEntries = false;
|
|
38
|
+
applyHeaders(headers, base, () => {
|
|
39
|
+
hasEntries = true;
|
|
40
|
+
});
|
|
41
|
+
applyHeaders(headers, override, () => {
|
|
42
|
+
hasEntries = true;
|
|
43
|
+
});
|
|
44
|
+
return hasEntries ? headers : undefined;
|
|
45
|
+
}
|
|
46
|
+
function applyHeaders(target, source, onSet) {
|
|
47
|
+
if (!source) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (source instanceof Headers) {
|
|
51
|
+
source.forEach((value, key) => {
|
|
52
|
+
target.set(key, value);
|
|
53
|
+
onSet();
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(source)) {
|
|
58
|
+
for (const [key, value] of source) {
|
|
59
|
+
if (!key) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (value === null || value === undefined) {
|
|
63
|
+
target.delete(key);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
target.set(key, String(value));
|
|
67
|
+
onSet();
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
for (const [key, value] of Object.entries(source)) {
|
|
72
|
+
if (value === null || value === undefined) {
|
|
73
|
+
target.delete(key);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
target.set(key, Array.isArray(value) ? value.map((item) => String(item)).join(', ') : String(value));
|
|
77
|
+
onSet();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=request-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-options.js","sourceRoot":"","sources":["../../src/core/request-options.ts"],"names":[],"mappings":"AAiFA,MAAM,UAAU,oBAAoB,CAClC,OAA4B;IAE5B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,EAAE,GAAG,OAAO,EAA8C,CAAA;IACvE,OAAO,IAAI,CAAC,OAAO,CAAA;IACnB,OAAO,IAAI,CAAC,UAAU,CAAA;IACtB,OAAO,IAAI,CAAC,KAAK,CAAA;IACjB,OAAO,IAAkD,CAAA;AAC3D,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAsC,EACtC,QAA6B;IAE7B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,QAA2D,CAAA;IACpE,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAyC,CAAA;IAClD,CAAC;IAED,MAAM,iBAAiB,GAAG,QAAsD,CAAA;IAEhF,OAAO;QACL,GAAG,IAAI;QACP,GAAG,QAAQ;QACX,OA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