@mutagent/sdk 0.6.1 → 0.6.2
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 +266 -426
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,179 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
See publish workflow for copy step. -->
|
|
5
|
-
|
|
6
|
-
```bash
|
|
7
|
-
╔════════════════════════════════════════════════════════════════════════════════════════════╗
|
|
8
|
-
║ ║
|
|
9
|
-
║ ███╗ ███╗██╗ ██╗████████╗ █████╗ ██████╗ ███████╗███╗ ██╗████████╗ ║
|
|
10
|
-
║ ████╗ ████║██║ ██║╚══██╔══╝██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝ ║
|
|
11
|
-
║ ██╔████╔██║██║ ██║ ██║ ███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║ ║
|
|
12
|
-
║ ██║╚██╔╝██║██║ ██║ ██║ ██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║ ║
|
|
13
|
-
║ ██║ ╚═╝ ██║╚██████╔╝ ██║ ██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║ ║
|
|
14
|
-
║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ║
|
|
15
|
-
║ ║
|
|
16
|
-
║ ███████╗██████╗ ██╗ ██╗ ║
|
|
17
|
-
║ ██╔════╝██╔══██╗██║ ██╔╝ ║
|
|
18
|
-
║ ███████╗██║ ██║█████╔╝ ║
|
|
19
|
-
║ ╚════██║██║ ██║██╔═██╗ ║
|
|
20
|
-
║ ███████║██████╔╝██║ ██╗ ║
|
|
21
|
-
║ ╚══════╝╚═════╝ ╚═╝ ╚═╝ ║
|
|
22
|
-
║ ║
|
|
23
|
-
║ TypeScript SDK for AI-Native Development. ║
|
|
24
|
-
║ ║
|
|
25
|
-
╚════════════════════════════════════════════════════════════════════════════════════════════╝
|
|
26
|
-
```
|
|
3
|
+
# MutagenT TypeScript SDK
|
|
27
4
|
|
|
28
5
|
<p align="center">
|
|
29
6
|
<a href="https://www.npmjs.com/package/@mutagent/sdk"><img src="https://img.shields.io/npm/v/@mutagent/sdk?style=for-the-badge&color=cb3837&logo=npm&logoColor=white" alt="npm"></a>
|
|
30
7
|
<a href="https://bun.sh"><img src="https://img.shields.io/badge/Bun-1.1+-f472b6?style=for-the-badge&logo=bun&logoColor=white" alt="Bun"></a>
|
|
31
8
|
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/Node-18+-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js"></a>
|
|
32
9
|
<a href="https://www.typescriptlang.org"><img src="https://img.shields.io/badge/TypeScript-5.0+-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript"></a>
|
|
33
|
-
<a href="#"><img src="https://img.shields.io/badge/License-
|
|
10
|
+
<a href="#"><img src="https://img.shields.io/badge/License-Apache_2.0-blue?style=for-the-badge" alt="License: Apache 2.0"></a>
|
|
34
11
|
</p>
|
|
35
12
|
|
|
36
13
|
<p align="center">
|
|
37
14
|
<em>The TypeScript client for the MutagenT platform API.</em>
|
|
38
15
|
</p>
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## What the SDK covers
|
|
43
|
-
|
|
44
|
-
`@mutagent/sdk` is generated from the MutagenT platform OpenAPI document. One `Mutagent` client
|
|
45
|
-
exposes 13 groups of methods:
|
|
46
|
-
|
|
47
|
-
| Group | What it calls |
|
|
48
|
-
|-------|---------------|
|
|
49
|
-
| `userProfile` | The signed-in user's profile, password and login sessions |
|
|
50
|
-
| `organizations` | Organizations, slug lookups and member counts |
|
|
51
|
-
| `organizationMembers` | Organization membership and roles |
|
|
52
|
-
| `workspaces` | Workspaces and the default workspace |
|
|
53
|
-
| `workspaceMembers` | Workspace membership and roles |
|
|
54
|
-
| `invitations` | Organization invitations |
|
|
55
|
-
| `agents` | Agent records: create, read, update, delete, look up by slug |
|
|
56
|
-
| `llmProviders` | LLM provider configurations, model catalog, connection tests |
|
|
57
|
-
| `managedAgents` | Managed agent deployments: slots, revisions, operations |
|
|
58
|
-
| `traces` | Trace ingestion and reads of traces, spans and logs |
|
|
59
|
-
| `sandbox` | Sandbox providers, presets, sandbox lifecycle, commands, the sandbox token exchange, and Helix sessions addressed by sandbox id |
|
|
60
|
-
| `environments` | Workspace Environments (named sets of variables and secrets) |
|
|
61
|
-
| `helixSessions` | Helix sessions addressed by session reference: launch, list, input, signal, checkpoint, restore, stream |
|
|
62
|
-
|
|
63
|
-
Every method is also available as a standalone function (see [Standalone functions](#standalone-functions)).
|
|
17
|
+
**Status:** `@mutagent/sdk` is on `0.6.1`, generated from `openapi.json` via Speakeasy. 13 client groups, all with sync methods and standalone-function equivalents. The manual tracing subsystem (`src/tracing/`) documented in older revisions of this file has been removed — tracing/observability was retired platform-wide; there is no `./tracing` export and no tracing tests in this package today.
|
|
64
18
|
|
|
65
19
|
---
|
|
66
20
|
|
|
67
|
-
##
|
|
68
|
-
|
|
69
|
-
0.6.0 is one breaking release after 0.5.x. Code written against 0.5.x needs the following changes.
|
|
70
|
-
|
|
71
|
-
**Client groups**
|
|
72
|
-
|
|
73
|
-
- `sandbox` holds sandbox providers, presets, the sandbox lifecycle, commands, the token exchange
|
|
74
|
-
(`createSandboxToken`) and the session routes addressed by sandbox id.
|
|
75
|
-
- New group `helixSessions`: `launchHelixSession`, `listHelixSessions`, `sendHelixSessionInput`,
|
|
76
|
-
`closeHelixSessionInput`, `signalHelixSession`, `checkpointHelixSession`,
|
|
77
|
-
`listHelixSessionCheckpoints`, `restoreHelixSession`, `streamHelixSession`, `getHelixModels`,
|
|
78
|
-
`setHelixDefaultModels`. The ones that existed in 0.5.x were methods of `sandbox`.
|
|
79
|
-
- New group `environments`. In 0.5.x its operations were methods of `sandbox`.
|
|
80
|
-
- `helixAgentDeployments` is renamed `managedAgents`. Its method names are unchanged.
|
|
81
|
-
- `providerConfigs` is renamed `llmProviders`. Its methods are renamed too; see the table below.
|
|
82
|
-
- `userProfile` keeps its name. Two of its methods are renamed; see the table below.
|
|
83
|
-
|
|
84
|
-
**Operation names**
|
|
85
|
-
|
|
86
|
-
39 operations are renamed. In the first 27 rows the 0.5.x name was derived from the route. The last
|
|
87
|
-
12 rows rename operations that already had their own names.
|
|
88
|
-
|
|
89
|
-
| 0.5.x | 0.6.0 |
|
|
90
|
-
|-------|-------|
|
|
91
|
-
| `sandbox.getApiSandboxProviders` | `sandbox.listSandboxProviders` |
|
|
92
|
-
| `sandbox.postApiSandboxPreflight` | `sandbox.preflightSandbox` |
|
|
93
|
-
| `sandbox.getApiSandboxPresets` | `sandbox.listSandboxPresets` |
|
|
94
|
-
| `sandbox.postApiSandboxRun` | `sandbox.runSandboxCommand` |
|
|
95
|
-
| `sandbox.postApiSandbox` | `sandbox.createSandbox` |
|
|
96
|
-
| `sandbox.getApiSandbox` | `sandbox.listSandboxes` |
|
|
97
|
-
| `sandbox.getApiSandboxById` | `sandbox.getSandbox` |
|
|
98
|
-
| `sandbox.deleteApiSandboxById` | `sandbox.deleteSandbox` |
|
|
99
|
-
| `sandbox.getApiSandboxByIdStream` | `sandbox.streamSandbox` |
|
|
100
|
-
| `sandbox.postApiSandboxByIdExec` | `sandbox.execSandboxCommand` |
|
|
101
|
-
| `sandbox.postApiSandboxTelemetryV1Traces` | `sandbox.ingestSandboxTraces` |
|
|
102
|
-
| `sandbox.getApiSandboxByIdTraces` | `sandbox.listSandboxSpans` |
|
|
103
|
-
| `sandbox.postApiSandboxByIdSession` | `sandbox.startSandboxHelixSession` |
|
|
104
|
-
| `sandbox.getApiSandboxHelixDefaults` | `helixSessions.getHelixModels` |
|
|
105
|
-
| `sandbox.putApiSandboxHelixDefaults` | `helixSessions.setHelixDefaultModels` |
|
|
106
|
-
| `sandbox.getApiSandboxByIdSessions` | `sandbox.listSandboxHelixSessions` |
|
|
107
|
-
| `sandbox.postApiSandboxByIdInput` | `sandbox.sendSandboxHelixSessionInput` |
|
|
108
|
-
| `sandbox.postApiSandboxByIdSignal` | `sandbox.signalSandboxHelixSession` |
|
|
109
|
-
| `sandbox.postApiSandboxByIdCheckpoint` | `sandbox.checkpointSandboxHelixSession` |
|
|
110
|
-
| `sandbox.getApiSandboxByIdCheckpoints` | `sandbox.listSandboxCheckpoints` |
|
|
111
|
-
| `sandbox.postApiSandboxByIdRestore` | `sandbox.restoreSandbox` |
|
|
112
|
-
| `sandbox.postApiSandboxToken` | `sandbox.createSandboxToken` |
|
|
113
|
-
| `sandbox.getApiSandboxEnvironments` | `environments.listEnvironments` |
|
|
114
|
-
| `sandbox.getApiSandboxEnvironmentsByName` | `environments.getEnvironment` |
|
|
115
|
-
| `sandbox.putApiSandboxEnvironmentsByName` | `environments.replaceEnvironment` |
|
|
116
|
-
| `sandbox.patchApiSandboxEnvironmentsByName` | `environments.updateEnvironment` |
|
|
117
|
-
| `sandbox.deleteApiSandboxEnvironmentsByName` | `environments.deleteEnvironment` |
|
|
118
|
-
| `userProfile.listSessions` | `userProfile.listUserSessions` |
|
|
119
|
-
| `userProfile.deleteSession` | `userProfile.revokeUserSession` |
|
|
120
|
-
| `sandbox.listHelixWorkspaceSessions` | `helixSessions.listHelixSessions` |
|
|
121
|
-
| `sandbox.inputHelixSession` | `helixSessions.sendHelixSessionInput` |
|
|
122
|
-
| `providerConfigs.listProviders` | `llmProviders.listProviderConfigs` |
|
|
123
|
-
| `providerConfigs.createProvider` | `llmProviders.createProviderConfig` |
|
|
124
|
-
| `providerConfigs.getProvider` | `llmProviders.getProviderConfig` |
|
|
125
|
-
| `providerConfigs.updateProvider` | `llmProviders.updateProviderConfig` |
|
|
126
|
-
| `providerConfigs.deleteProvider` | `llmProviders.deleteProviderConfig` |
|
|
127
|
-
| `providerConfigs.getModelsCatalog` | `llmProviders.getModelCatalog` |
|
|
128
|
-
| `providerConfigs.listProviderModels` | `llmProviders.listProviderConfigModels` |
|
|
129
|
-
| `providerConfigs.testProvider` | `llmProviders.testProviderConfig` |
|
|
130
|
-
|
|
131
|
-
The standalone function names follow the same change, including the group prefix. For example
|
|
132
|
-
`sandboxGetApiSandboxById` is now `sandboxGetSandbox`, and `providerConfigsTestProvider` is now
|
|
133
|
-
`llmProvidersTestProviderConfig`.
|
|
134
|
-
|
|
135
|
-
**Model, enum and error names**
|
|
136
|
-
|
|
137
|
-
Model, enum and error class names come from the schema names in the API document, for example
|
|
138
|
-
`Mode`, `HelixArm`, `HelixSignal`, `HelixLaunchRequest`, `LlmProviderType` and
|
|
139
|
-
`ErrorResponse`. Names the generator invented in 0.5.x, such as `Schemadefaul7`, `ModeArmModel` and
|
|
140
|
-
`NameSlugDescription5`, no longer exist.
|
|
21
|
+
## Context
|
|
141
22
|
|
|
142
|
-
|
|
23
|
+
`@mutagent/sdk` is the official TypeScript client for the MutagenT platform API. One `Mutagent` client class exposes every route in the platform's OpenAPI document as a typed method, grouped by API tag. See the [root README](../README.md) for where this SDK sits relative to the platform API and the other clients (Python SDK, CLI, `mutagent-client`).
|
|
143
24
|
|
|
144
|
-
|
|
145
|
-
0.5.x values `oneshot` and `rpc` are gone.
|
|
25
|
+
## Concepts
|
|
146
26
|
|
|
147
|
-
**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
**
|
|
153
|
-
|
|
154
|
-
`streamHelixSession` and `streamSandbox` send `Accept: text/event-stream`. They resolve to the event
|
|
155
|
-
text as one string when the server closes the stream. They do not yield events as they arrive.
|
|
156
|
-
|
|
157
|
-
---
|
|
27
|
+
- **Client groups** — one namespace per API tag on the `Mutagent` instance (`mutagent.agents`, `mutagent.sandbox`, …). See the table in [Components](#components).
|
|
28
|
+
- **Security schemes** — `apiKey` (`x-api-key` header) and `bearerAuth` (`Authorization: Bearer`), set via the `security` client option or per environment variable; see [Configuration](#configuration).
|
|
29
|
+
- **Sandbox token** — a short-lived bearer credential, exchanged for an API key via `sandbox.createSandboxToken`, required by the `sandbox`, `environments` and `helixSessions` groups.
|
|
30
|
+
- **Standalone functions** — every method is also exported as a tree-shakeable function for bundle-size-sensitive apps; rationale and pattern in [FUNCTIONS.md](./FUNCTIONS.md), per-operation names in [docs/sdks/](./docs/sdks/).
|
|
31
|
+
- **Streaming** — `streamHelixSession` / `streamSandbox` resolve to the whole event text as one string after the server closes the connection; they do not yield events incrementally.
|
|
32
|
+
- **Pagination** — endpoints that page resolve to a response that is also an async iterable (`for await...of`).
|
|
158
33
|
|
|
159
|
-
##
|
|
34
|
+
## Components
|
|
160
35
|
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
#
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
#
|
|
168
|
-
|
|
36
|
+
```
|
|
37
|
+
mutagent-sdk/
|
|
38
|
+
├── openapi.json # fetched from server, processed by scripts/fix-openapi.ts
|
|
39
|
+
├── .speakeasy/ # Speakeasy config (gen.yaml, workflow.yaml, gen.lock)
|
|
40
|
+
├── src/
|
|
41
|
+
│ ├── sdk/ # [generated] client classes, one file per group
|
|
42
|
+
│ ├── models/ # [generated] request/response types, errors
|
|
43
|
+
│ ├── funcs/ # [generated] standalone functions
|
|
44
|
+
│ └── lib/ # [generated] HTTP client, config, security, retries
|
|
45
|
+
├── docs/sdks/ # [generated] one page per group: every method, parameter, error
|
|
46
|
+
├── examples/ # [generated] runnable usage examples
|
|
47
|
+
├── __tests__/unit/ # [manual] tests for the generation scripts (fix-openapi.ts etc.)
|
|
48
|
+
├── scripts/ # [manual] generate-sdk.sh, fix-openapi.ts, post-generate.ts
|
|
49
|
+
└── README.md # this file — not tracked by Speakeasy, safe to hand-edit
|
|
169
50
|
```
|
|
170
51
|
|
|
171
|
-
|
|
172
|
-
|
|
52
|
+
| Command | What it does |
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `npm add @mutagent/sdk` / `bun add @mutagent/sdk` | Install (npm, pnpm, Bun and Yarn all work; CJS + ESM builds ship) |
|
|
55
|
+
| `bun run build` | tshy dual ESM + CommonJS build |
|
|
56
|
+
| `bun test __tests__/unit` | Runs the unit tests for the generation scripts (the only hand-written tests) |
|
|
57
|
+
| `bun run lint` | ESLint |
|
|
58
|
+
| `./scripts/generate-sdk.sh` | Full pipeline: fetch spec → `fix-openapi.ts` → `speakeasy run` → `post-generate.ts`. Needs the MutagenT API on `http://localhost:3003` and the `speakeasy` CLI |
|
|
173
59
|
|
|
174
|
-
|
|
60
|
+
Supported runtimes and recommended `tsconfig.json` options: [RUNTIMES.md](./RUNTIMES.md).
|
|
175
61
|
|
|
176
|
-
|
|
62
|
+
### Quick start
|
|
177
63
|
|
|
178
64
|
```typescript
|
|
179
65
|
import { Mutagent } from "@mutagent/sdk";
|
|
@@ -195,37 +81,18 @@ async function run() {
|
|
|
195
81
|
run();
|
|
196
82
|
```
|
|
197
83
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
## Authentication
|
|
201
|
-
|
|
202
|
-
The `security` option has two fields. Both are read from the environment when you do not pass them.
|
|
84
|
+
### Authentication
|
|
203
85
|
|
|
204
|
-
|
|
205
|
-
|--------|---------|----------------------|---------|
|
|
206
|
-
| `apiKey` | `x-api-key` header | `MUTAGENT_API_KEY` | Every group except `sandbox`, `environments` and `helixSessions` |
|
|
207
|
-
| `bearerAuth` | `Authorization: Bearer` header | `MUTAGENT_BEARER_AUTH` | `sandbox` (except `createSandboxToken`), `environments` and `helixSessions`, which accept no other credential. The other groups also declare it |
|
|
86
|
+
The `security` option has two fields, each read from its environment variable when not passed explicitly (see [Configuration](#configuration)):
|
|
208
87
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
A platform API key starts with `mg_live_`. Create one in the MutagenT app under Settings, API Keys.
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
217
|
-
|
|
218
|
-
const mutagent = new Mutagent({
|
|
219
|
-
security: { apiKey: process.env["MUTAGENT_API_KEY"] ?? "" },
|
|
220
|
-
});
|
|
221
|
-
```
|
|
88
|
+
| Option | Sent as | Used by |
|
|
89
|
+
|--------|---------|---------|
|
|
90
|
+
| `apiKey` | `x-api-key` header | Every group except `sandbox`, `environments` and `helixSessions` |
|
|
91
|
+
| `bearerAuth` | `Authorization: Bearer` header | `sandbox` (except `createSandboxToken`), `environments` and `helixSessions` |
|
|
222
92
|
|
|
223
|
-
|
|
93
|
+
When an operation accepts both and both are set, the SDK sends the API key. `security` also accepts an async function that returns the credentials, useful for refreshing a sandbox token before it expires.
|
|
224
94
|
|
|
225
|
-
The `sandbox`, `environments` and `helixSessions` operations
|
|
226
|
-
short-lived sandbox token, sent as a bearer token. Exchange an API key for one with
|
|
227
|
-
`sandbox.createSandboxToken`. That call takes the API key in its own first argument; it does not read
|
|
228
|
-
the client's `security` option or `MUTAGENT_API_KEY`.
|
|
95
|
+
The `sandbox`, `environments` and `helixSessions` operations require a short-lived sandbox token instead of an API key. Exchange one with `sandbox.createSandboxToken`, which takes the API key as its own argument (it does not read `security` or `MUTAGENT_API_KEY`):
|
|
229
96
|
|
|
230
97
|
```typescript
|
|
231
98
|
import { Mutagent } from "@mutagent/sdk";
|
|
@@ -240,345 +107,322 @@ async function sandboxClient(workspaceId: string): Promise<Mutagent> {
|
|
|
240
107
|
);
|
|
241
108
|
console.log(`sandbox token expires in ${expiresIn}s`);
|
|
242
109
|
|
|
243
|
-
// apiKey stays in place for the platform groups; bearerAuth is used by
|
|
244
|
-
// sandbox, environments and helixSessions.
|
|
245
110
|
return new Mutagent({ security: { apiKey, bearerAuth: token } });
|
|
246
111
|
}
|
|
247
112
|
```
|
|
248
113
|
|
|
249
|
-
|
|
250
|
-
sandbox token before it expires.
|
|
114
|
+
### Client groups
|
|
251
115
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
## Client groups
|
|
116
|
+
Full per-method reference — every parameter and response type — lives in [docs/sdks/](./docs/sdks/), one page per group:
|
|
255
117
|
|
|
256
|
-
|
|
257
|
-
|
|
118
|
+
| Group | Covers | Reference |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| `userProfile` | The signed-in user's profile, password and login sessions | [docs/sdks/userprofile/](docs/sdks/userprofile/README.md) |
|
|
121
|
+
| `organizations` | Organizations, slug lookups and member counts | [docs/sdks/organizations/](docs/sdks/organizations/README.md) |
|
|
122
|
+
| `organizationMembers` | Organization membership and roles | [docs/sdks/organizationmembers/](docs/sdks/organizationmembers/README.md) |
|
|
123
|
+
| `workspaces` | Workspaces and the default workspace | [docs/sdks/workspaces/](docs/sdks/workspaces/README.md) |
|
|
124
|
+
| `workspaceMembers` | Workspace membership and roles | [docs/sdks/workspacemembers/](docs/sdks/workspacemembers/README.md) |
|
|
125
|
+
| `invitations` | Organization invitations | [docs/sdks/invitations/](docs/sdks/invitations/README.md) |
|
|
126
|
+
| `agents` | Agent records: create, read, update, delete, look up by slug | [docs/sdks/agents/](docs/sdks/agents/README.md) |
|
|
127
|
+
| `llmProviders` | LLM provider configurations, model catalog, connection tests | [docs/sdks/llmproviders/](docs/sdks/llmproviders/README.md) |
|
|
128
|
+
| `managedAgents` | Managed agent deployments: slots, revisions, operations | [docs/sdks/managedagents/](docs/sdks/managedagents/README.md) |
|
|
129
|
+
| `traces` | Trace ingestion and reads of traces, spans and logs | [docs/sdks/traces/](docs/sdks/traces/README.md) |
|
|
130
|
+
| `sandbox` | Sandbox providers, presets, lifecycle, commands, token exchange, sandbox-hosted Helix sessions | [docs/sdks/sandbox/](docs/sdks/sandbox/README.md) |
|
|
131
|
+
| `environments` | Workspace Environments (named sets of variables and secrets) | [docs/sdks/environments/](docs/sdks/environments/README.md) |
|
|
132
|
+
| `helixSessions` | Helix sessions addressed by session reference: launch, list, input, signal, checkpoint, restore, stream | [docs/sdks/helixsessions/](docs/sdks/helixsessions/README.md) |
|
|
258
133
|
|
|
259
|
-
|
|
134
|
+
Two representative examples (the rest are one call each, per the reference pages above):
|
|
260
135
|
|
|
261
136
|
```typescript
|
|
262
137
|
import { Mutagent } from "@mutagent/sdk";
|
|
138
|
+
import { LlmProviderType } from "@mutagent/sdk/models";
|
|
263
139
|
|
|
264
140
|
async function example(mutagent: Mutagent) {
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
141
|
+
const provider = await mutagent.llmProviders.createProviderConfig({
|
|
142
|
+
name: "Anthropic",
|
|
143
|
+
provider: LlmProviderType.Anthropic,
|
|
144
|
+
apiKey: process.env["ANTHROPIC_API_KEY"] ?? "",
|
|
145
|
+
});
|
|
146
|
+
console.log(await mutagent.llmProviders.testProviderConfig({ id: provider.id }));
|
|
268
147
|
}
|
|
269
148
|
```
|
|
270
149
|
|
|
271
|
-
### organizations
|
|
272
|
-
|
|
273
150
|
```typescript
|
|
274
151
|
import { Mutagent } from "@mutagent/sdk";
|
|
152
|
+
import { HelixSignal, Mode } from "@mutagent/sdk/models";
|
|
275
153
|
|
|
154
|
+
// Requires a sandbox token (see Authentication above).
|
|
276
155
|
async function example(mutagent: Mutagent) {
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
156
|
+
const session = await mutagent.helixSessions.launchHelixSession({
|
|
157
|
+
mode: Mode.Interactive,
|
|
158
|
+
environment: "staging",
|
|
159
|
+
});
|
|
160
|
+
await mutagent.helixSessions.sendHelixSessionInput({
|
|
161
|
+
reference: session.reference,
|
|
162
|
+
body: { line: JSON.stringify({ type: "prompt", id: "p1", message: "List the files" }) },
|
|
163
|
+
});
|
|
164
|
+
await mutagent.helixSessions.signalHelixSession({
|
|
165
|
+
reference: session.reference,
|
|
166
|
+
body: { signal: HelixSignal.Sigint },
|
|
167
|
+
});
|
|
280
168
|
}
|
|
281
169
|
```
|
|
282
170
|
|
|
283
|
-
###
|
|
171
|
+
### Streaming
|
|
284
172
|
|
|
285
173
|
```typescript
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
174
|
+
async function example(mutagent: Mutagent, reference: string) {
|
|
175
|
+
const eventText = await mutagent.helixSessions.streamHelixSession({ reference });
|
|
176
|
+
for (const block of eventText.split("\n\n")) {
|
|
177
|
+
console.log(block);
|
|
178
|
+
}
|
|
291
179
|
}
|
|
292
180
|
```
|
|
293
181
|
|
|
294
|
-
|
|
182
|
+
Pass the last `seq` you have read as `since` to receive only later events.
|
|
295
183
|
|
|
296
|
-
|
|
297
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
298
|
-
|
|
299
|
-
async function example(mutagent: Mutagent) {
|
|
300
|
-
const workspace = await mutagent.workspaces.createWorkspace({
|
|
301
|
-
name: "Support",
|
|
302
|
-
slug: "support",
|
|
303
|
-
});
|
|
304
|
-
await mutagent.workspaces.setDefaultWorkspace({ wsId: workspace.id });
|
|
305
|
-
}
|
|
306
|
-
```
|
|
184
|
+
### Error handling
|
|
307
185
|
|
|
308
|
-
|
|
186
|
+
Every HTTP error extends `MutagentError`; most operations also document `ErrorResponse` (`error`, `message`). Full error class list: [Reference § Error classes](#error-classes).
|
|
309
187
|
|
|
310
188
|
```typescript
|
|
311
|
-
import
|
|
189
|
+
import * as errors from "@mutagent/sdk/models/errors";
|
|
312
190
|
|
|
313
191
|
async function example(mutagent: Mutagent) {
|
|
314
|
-
|
|
315
|
-
|
|
192
|
+
try {
|
|
193
|
+
await mutagent.agents.getAgent({ id: 404 });
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error instanceof errors.ErrorResponse) {
|
|
196
|
+
console.error(error.statusCode, error.data$.error, error.data$.message);
|
|
197
|
+
} else if (error instanceof errors.MutagentError) {
|
|
198
|
+
console.error(`HTTP ${error.statusCode}: ${error.body}`);
|
|
199
|
+
} else {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
316
203
|
}
|
|
317
204
|
```
|
|
318
205
|
|
|
319
|
-
|
|
206
|
+
## Configuration
|
|
320
207
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
208
|
+
| Variable | Required | Default | Read at | Secret | Purpose |
|
|
209
|
+
| --- | --- | --- | --- | --- | --- |
|
|
210
|
+
| `MUTAGENT_API_KEY` | No (or pass `security.apiKey`) | none | `src/lib/security.ts:255` | Yes | Fallback for the `apiKey` security scheme |
|
|
211
|
+
| `MUTAGENT_BEARER_AUTH` | No (or pass `security.bearerAuth`) | none | `src/lib/security.ts:262` | Yes | Fallback for the `bearerAuth` security scheme (sandbox token) |
|
|
212
|
+
| `MUTAGENT_DEBUG` | No | `false` | `src/lib/sdks.ts:114` | No | Enables `console` debug logging when no `debugLogger` option is passed — reveals secrets in log output, development only |
|
|
324
213
|
|
|
325
|
-
|
|
326
|
-
const invitation = await mutagent.invitations.createInvitation({
|
|
327
|
-
orgId: "<org-id>",
|
|
328
|
-
body: { email: "dev@example.com", role: OrganizationRole.Editor },
|
|
329
|
-
});
|
|
330
|
-
console.log(invitation.id);
|
|
331
|
-
}
|
|
332
|
-
```
|
|
214
|
+
All three are user-set (this package owns no platform infrastructure). The default server URL is not an environment variable — it is hardcoded to `https://api.mutagent.io` in [`src/lib/config.ts`](src/lib/config.ts) (index `0` in the server list; `http://localhost:3003` is index `1`), overridable via the `serverURL` or `serverIdx` client options. See [`.env.example`](.env.example) for placeholder values.
|
|
333
215
|
|
|
334
|
-
|
|
216
|
+
---
|
|
335
217
|
|
|
336
|
-
|
|
337
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
218
|
+
## Reference
|
|
338
219
|
|
|
339
|
-
|
|
340
|
-
const agent = await mutagent.agents.createAgent({
|
|
341
|
-
name: "Support Agent",
|
|
342
|
-
slug: "support-agent",
|
|
343
|
-
systemPrompt: "You answer customer support questions.",
|
|
344
|
-
});
|
|
220
|
+
### API naming migration
|
|
345
221
|
|
|
346
|
-
|
|
347
|
-
await mutagent.agents.updateAgent({ id: agent.id, body: { description: "Tier 1 support" } });
|
|
348
|
-
console.log(sameAgent.id === agent.id);
|
|
349
|
-
}
|
|
350
|
-
```
|
|
222
|
+
The checked-in client is `0.6.1` on npm. `0.6.0` was the first release published under a version number that officially carries the renamed groups and operations below; `0.5.13`, published about twelve minutes earlier from the same source changes, already carried the same renames under the old numbering (see [PR #2113](https://github.com/architech-printworks/mutagent-monorepo/pull/2113)).
|
|
351
223
|
|
|
352
|
-
|
|
224
|
+
**Client groups**
|
|
353
225
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
226
|
+
- `sandbox` holds sandbox providers, presets, the sandbox lifecycle, commands, the token exchange (`createSandboxToken`) and the session routes addressed by sandbox id.
|
|
227
|
+
- New group `helixSessions`: `launchHelixSession`, `listHelixSessions`, `sendHelixSessionInput`, `closeHelixSessionInput`, `signalHelixSession`, `checkpointHelixSession`, `listHelixSessionCheckpoints`, `restoreHelixSession`, `streamHelixSession`, `getHelixModels`, `setHelixDefaultModels`. These existed as `sandbox` methods in `0.5.x`.
|
|
228
|
+
- New group `environments`. In `0.5.x` its operations were methods of `sandbox`.
|
|
229
|
+
- `helixAgentDeployments` is renamed `managedAgents`; method names are unchanged.
|
|
230
|
+
- `providerConfigs` is renamed `llmProviders`; its methods are renamed too (table below).
|
|
231
|
+
- `userProfile` keeps its name; two of its methods are renamed (table below).
|
|
357
232
|
|
|
358
|
-
|
|
359
|
-
const provider = await mutagent.llmProviders.createProviderConfig({
|
|
360
|
-
name: "Anthropic",
|
|
361
|
-
provider: LlmProviderType.Anthropic,
|
|
362
|
-
apiKey: process.env["ANTHROPIC_API_KEY"] ?? "",
|
|
363
|
-
});
|
|
233
|
+
<details><summary>39 renamed operations</summary>
|
|
364
234
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
235
|
+
| Previous name | Checked-in name |
|
|
236
|
+
|-------|-------|
|
|
237
|
+
| `sandbox.getApiSandboxProviders` | `sandbox.listSandboxProviders` |
|
|
238
|
+
| `sandbox.postApiSandboxPreflight` | `sandbox.preflightSandbox` |
|
|
239
|
+
| `sandbox.getApiSandboxPresets` | `sandbox.listSandboxPresets` |
|
|
240
|
+
| `sandbox.postApiSandboxRun` | `sandbox.runSandboxCommand` |
|
|
241
|
+
| `sandbox.postApiSandbox` | `sandbox.createSandbox` |
|
|
242
|
+
| `sandbox.getApiSandbox` | `sandbox.listSandboxes` |
|
|
243
|
+
| `sandbox.getApiSandboxById` | `sandbox.getSandbox` |
|
|
244
|
+
| `sandbox.deleteApiSandboxById` | `sandbox.deleteSandbox` |
|
|
245
|
+
| `sandbox.getApiSandboxByIdStream` | `sandbox.streamSandbox` |
|
|
246
|
+
| `sandbox.postApiSandboxByIdExec` | `sandbox.execSandboxCommand` |
|
|
247
|
+
| `sandbox.postApiSandboxTelemetryV1Traces` | `sandbox.ingestSandboxTraces` |
|
|
248
|
+
| `sandbox.getApiSandboxByIdTraces` | `sandbox.listSandboxSpans` |
|
|
249
|
+
| `sandbox.postApiSandboxByIdSession` | `sandbox.startSandboxHelixSession` |
|
|
250
|
+
| `sandbox.getApiSandboxHelixDefaults` | `helixSessions.getHelixModels` |
|
|
251
|
+
| `sandbox.putApiSandboxHelixDefaults` | `helixSessions.setHelixDefaultModels` |
|
|
252
|
+
| `sandbox.getApiSandboxByIdSessions` | `sandbox.listSandboxHelixSessions` |
|
|
253
|
+
| `sandbox.postApiSandboxByIdInput` | `sandbox.sendSandboxHelixSessionInput` |
|
|
254
|
+
| `sandbox.postApiSandboxByIdSignal` | `sandbox.signalSandboxHelixSession` |
|
|
255
|
+
| `sandbox.postApiSandboxByIdCheckpoint` | `sandbox.checkpointSandboxHelixSession` |
|
|
256
|
+
| `sandbox.getApiSandboxByIdCheckpoints` | `sandbox.listSandboxCheckpoints` |
|
|
257
|
+
| `sandbox.postApiSandboxByIdRestore` | `sandbox.restoreSandbox` |
|
|
258
|
+
| `sandbox.postApiSandboxToken` | `sandbox.createSandboxToken` |
|
|
259
|
+
| `sandbox.getApiSandboxEnvironments` | `environments.listEnvironments` |
|
|
260
|
+
| `sandbox.getApiSandboxEnvironmentsByName` | `environments.getEnvironment` |
|
|
261
|
+
| `sandbox.putApiSandboxEnvironmentsByName` | `environments.replaceEnvironment` |
|
|
262
|
+
| `sandbox.patchApiSandboxEnvironmentsByName` | `environments.updateEnvironment` |
|
|
263
|
+
| `sandbox.deleteApiSandboxEnvironmentsByName` | `environments.deleteEnvironment` |
|
|
264
|
+
| `userProfile.listSessions` | `userProfile.listUserSessions` |
|
|
265
|
+
| `userProfile.deleteSession` | `userProfile.revokeUserSession` |
|
|
266
|
+
| `sandbox.listHelixWorkspaceSessions` | `helixSessions.listHelixSessions` |
|
|
267
|
+
| `sandbox.inputHelixSession` | `helixSessions.sendHelixSessionInput` |
|
|
268
|
+
| `providerConfigs.listProviders` | `llmProviders.listProviderConfigs` |
|
|
269
|
+
| `providerConfigs.createProvider` | `llmProviders.createProviderConfig` |
|
|
270
|
+
| `providerConfigs.getProvider` | `llmProviders.getProviderConfig` |
|
|
271
|
+
| `providerConfigs.updateProvider` | `llmProviders.updateProviderConfig` |
|
|
272
|
+
| `providerConfigs.deleteProvider` | `llmProviders.deleteProviderConfig` |
|
|
273
|
+
| `providerConfigs.getModelsCatalog` | `llmProviders.getModelCatalog` |
|
|
274
|
+
| `providerConfigs.listProviderModels` | `llmProviders.listProviderConfigModels` |
|
|
275
|
+
| `providerConfigs.testProvider` | `llmProviders.testProviderConfig` |
|
|
370
276
|
|
|
371
|
-
|
|
277
|
+
Standalone function names follow the same change, including the group prefix (e.g. `sandboxGetApiSandboxById` → `sandboxGetSandbox`).
|
|
372
278
|
|
|
373
|
-
|
|
374
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
279
|
+
</details>
|
|
375
280
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const detail = await mutagent.managedAgents.getHelixAgent({ slug: agent.slug });
|
|
380
|
-
console.log(detail);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
```
|
|
281
|
+
- **Model, enum and error names** come from the schema names in the API document (`Mode`, `HelixArm`, `HelixSignal`, `HelixLaunchRequest`, `LlmProviderType`, `ErrorResponse`). Generator-invented names from `0.5.x` (`Schemadefaul7`, `ModeArmModel`, `NameSlugDescription5`) no longer exist.
|
|
282
|
+
- **Session mode values**: `headless` or `interactive` (`Mode.Headless`, `Mode.Interactive`). The `0.5.x` values `oneshot` and `rpc` are gone.
|
|
283
|
+
- **Default server**: `https://api.mutagent.io`; was `http://localhost:3003` in `0.5.x`. Pass `serverURL: "http://localhost:3003"` or `serverIdx: 1` for a local server.
|
|
384
284
|
|
|
385
|
-
###
|
|
285
|
+
### Standalone functions
|
|
386
286
|
|
|
387
|
-
|
|
388
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
287
|
+
Every method above is also available as a standalone function, for bundlers that tree-shake unused functionality. Rationale and a worked example: [FUNCTIONS.md](./FUNCTIONS.md). The standalone function name for each operation is listed on its own page under [docs/sdks/](./docs/sdks/) (one page per group — see the [Client groups](#client-groups) table above), under that operation's "Standalone function" heading.
|
|
389
288
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
289
|
+
### Pagination
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
async function run(mutagent: Mutagent) {
|
|
293
|
+
const result = await mutagent.agents.listAgents({ limit: 0, offset: 0, isPublic: false });
|
|
294
|
+
for await (const page of result) {
|
|
295
|
+
console.log(page);
|
|
395
296
|
}
|
|
396
297
|
}
|
|
397
298
|
```
|
|
398
299
|
|
|
399
|
-
###
|
|
300
|
+
### Retries
|
|
400
301
|
|
|
401
|
-
|
|
302
|
+
Endpoints that support retries fall back to the API's default retry strategy. Override per call or for the whole SDK:
|
|
402
303
|
|
|
403
304
|
```typescript
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
305
|
+
// Per call
|
|
306
|
+
await mutagent.userProfile.getProfile({
|
|
307
|
+
retries: {
|
|
308
|
+
strategy: "backoff",
|
|
309
|
+
backoff: { initialInterval: 1, maxInterval: 50, exponent: 1.1, maxElapsedTime: 100 },
|
|
310
|
+
retryConnectionErrors: false,
|
|
311
|
+
},
|
|
312
|
+
});
|
|
411
313
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
await mutagent.sandbox.deleteSandbox({ id: sandbox.id });
|
|
422
|
-
}
|
|
314
|
+
// SDK-wide
|
|
315
|
+
const mutagent = new Mutagent({
|
|
316
|
+
retryConfig: {
|
|
317
|
+
strategy: "backoff",
|
|
318
|
+
backoff: { initialInterval: 1, maxInterval: 50, exponent: 1.1, maxElapsedTime: 100 },
|
|
319
|
+
retryConnectionErrors: false,
|
|
320
|
+
},
|
|
321
|
+
security: { apiKey: process.env["MUTAGENT_API_KEY"] ?? "" },
|
|
322
|
+
});
|
|
423
323
|
```
|
|
424
324
|
|
|
425
|
-
###
|
|
426
|
-
|
|
427
|
-
Requires a sandbox token.
|
|
325
|
+
### Error classes
|
|
428
326
|
|
|
429
|
-
|
|
430
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
327
|
+
[`MutagentError`](./src/models/errors/mutagent-error.ts) is the base class; it carries `message`, `statusCode`, `headers`, `body`, `rawResponse` and an optional `data$` for structured errors.
|
|
431
328
|
|
|
432
|
-
|
|
433
|
-
await mutagent.environments.replaceEnvironment({
|
|
434
|
-
name: "staging",
|
|
435
|
-
body: {
|
|
436
|
-
vars: { LOG_LEVEL: "debug" },
|
|
437
|
-
secrets: { DATABASE_URL: "<secret>" },
|
|
438
|
-
},
|
|
439
|
-
});
|
|
329
|
+
<details><summary>18 less-common error classes</summary>
|
|
440
330
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
331
|
+
**Network errors:**
|
|
332
|
+
* [`ConnectionError`](./src/models/errors/http-client-errors.ts): HTTP client was unable to make a request to a server.
|
|
333
|
+
* [`RequestTimeoutError`](./src/models/errors/http-client-errors.ts): HTTP request timed out due to an AbortSignal signal.
|
|
334
|
+
* [`RequestAbortedError`](./src/models/errors/http-client-errors.ts): HTTP request was aborted by the client.
|
|
335
|
+
* [`InvalidRequestError`](./src/models/errors/http-client-errors.ts): Any input used to create a request is invalid.
|
|
336
|
+
* [`UnexpectedClientError`](./src/models/errors/http-client-errors.ts): Unrecognised or unexpected error.
|
|
445
337
|
|
|
446
|
-
|
|
338
|
+
**Inherit from `MutagentError`:**
|
|
339
|
+
* [`ErrorResponse`](./src/models/errors/error-response.ts): Applicable to 75 of 96 methods.
|
|
340
|
+
* [`ErrorResponseWithStatus`](./src/models/errors/error-response-with-status.ts): Applicable to 61 of 96 methods.
|
|
341
|
+
* [`ProviderError`](./src/models/errors/provider-error.ts): Applicable to 8 of 96 methods.
|
|
342
|
+
* [`DeploymentError`](./src/models/errors/deployment-error.ts): Response for status 400. Applicable to 7 of 96 methods.
|
|
343
|
+
* [`WsError`](./src/models/errors/ws-error.ts): Applicable to 6 of 96 methods.
|
|
344
|
+
* [`SandboxPayloadTooLargeError`](./src/models/errors/sandbox-payload-too-large-error.ts): Status `413`. Applicable to 5 of 96 methods.
|
|
345
|
+
* [`ModelNotInListError`](./src/models/errors/model-not-in-list-error.ts): Status `422`. Applicable to 5 of 96 methods.
|
|
346
|
+
* [`ModelResolutionError`](./src/models/errors/model-resolution-error.ts): Status `422`. Applicable to 5 of 96 methods.
|
|
347
|
+
* [`NoProviderConfiguredError`](./src/models/errors/no-provider-configured-error.ts): Status `428`. Applicable to 4 of 96 methods.
|
|
348
|
+
* [`TestConnectionResultError`](./src/models/errors/test-connection-result-error.ts): Provider connection test result. Applicable to 1 of 96 methods.
|
|
349
|
+
* [`WorkspaceModelListingError`](./src/models/errors/workspace-model-listing-error.ts): Applicable to 1 of 96 methods.
|
|
350
|
+
* [`SandboxProviderUnreachableError`](./src/models/errors/sandbox-provider-unreachable-error.ts): Status `503`. Applicable to 1 of 96 methods.
|
|
351
|
+
* [`ResponseValidationError`](./src/models/errors/response-validation-error.ts): Type mismatch between the server response and the SDK's expected structure. See `error.rawValue` / `error.pretty()`.
|
|
447
352
|
|
|
448
|
-
|
|
449
|
-
`interactive` session stays open and reads one JSON command per `sendHelixSessionInput` call.
|
|
353
|
+
</details>
|
|
450
354
|
|
|
451
|
-
|
|
452
|
-
import { Mutagent } from "@mutagent/sdk";
|
|
453
|
-
import { HelixSignal, Mode } from "@mutagent/sdk/models";
|
|
355
|
+
### Server selection
|
|
454
356
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
});
|
|
460
|
-
console.log(headless.reference, headless.sandboxId);
|
|
357
|
+
| # | Server | Description |
|
|
358
|
+
| --- | --- | --- |
|
|
359
|
+
| 0 | `https://api.mutagent.io` | Production |
|
|
360
|
+
| 1 | `http://localhost:3003` | Development server |
|
|
461
361
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
await mutagent.helixSessions.sendHelixSessionInput({
|
|
467
|
-
reference: session.reference,
|
|
468
|
-
body: { line: JSON.stringify({ type: "prompt", id: "p1", message: "List the files" }) },
|
|
469
|
-
});
|
|
470
|
-
await mutagent.helixSessions.signalHelixSession({
|
|
471
|
-
reference: session.reference,
|
|
472
|
-
body: { signal: HelixSignal.Sigint },
|
|
473
|
-
});
|
|
474
|
-
}
|
|
362
|
+
```typescript
|
|
363
|
+
const mutagent = new Mutagent({ serverIdx: 0, security: { apiKey: process.env["MUTAGENT_API_KEY"] ?? "" } });
|
|
364
|
+
// or
|
|
365
|
+
const mutagent = new Mutagent({ serverURL: "http://localhost:3003", security: { apiKey: process.env["MUTAGENT_API_KEY"] ?? "" } });
|
|
475
366
|
```
|
|
476
367
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
---
|
|
368
|
+
### Custom HTTP client
|
|
480
369
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
`helixSessions.streamHelixSession` and `sandbox.streamSandbox` request `Accept: text/event-stream`. The
|
|
484
|
-
returned promise resolves to the whole event text as one string after the server closes the stream. The
|
|
485
|
-
SDK does not parse the events and does not yield them while the stream is open. Pass the last `seq` you
|
|
486
|
-
have read as `since` to receive only later events.
|
|
370
|
+
`HTTPClient` wraps the native Fetch API and exposes `beforeRequest` / `requestError` hooks and a custom `fetcher` (e.g. to route through an [undici](https://www.npmjs.com/package/undici) `ProxyAgent`, or to mock `fetch` in tests):
|
|
487
371
|
|
|
488
372
|
```typescript
|
|
489
|
-
import {
|
|
373
|
+
import { HTTPClient } from "@mutagent/sdk/lib/http";
|
|
374
|
+
import { ProxyAgent } from "undici";
|
|
490
375
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
376
|
+
const dispatcher = new ProxyAgent("http://proxy.example.com:8080");
|
|
377
|
+
const httpClient = new HTTPClient({
|
|
378
|
+
fetcher: (input, init) => fetch(input, { ...init, dispatcher } as RequestInit),
|
|
379
|
+
});
|
|
380
|
+
httpClient.addHook("beforeRequest", (request) => {
|
|
381
|
+
const next = new Request(request, { signal: request.signal || AbortSignal.timeout(5000) });
|
|
382
|
+
next.headers.set("x-custom-header", "custom value");
|
|
383
|
+
return next;
|
|
384
|
+
});
|
|
385
|
+
httpClient.addHook("requestError", (error, request) => {
|
|
386
|
+
console.error("Request Error:", `${error}`, `${request.method} ${request.url}`);
|
|
387
|
+
});
|
|
498
388
|
|
|
499
|
-
|
|
389
|
+
const sdk = new Mutagent({ httpClient });
|
|
390
|
+
```
|
|
500
391
|
|
|
501
|
-
|
|
392
|
+
### Debugging
|
|
502
393
|
|
|
503
|
-
|
|
504
|
-
`error` and `message`. The generated [Error Handling](#error-handling-1) section below lists every error
|
|
505
|
-
class.
|
|
394
|
+
Pass a `console`-shaped logger via `debugLogger`, or set `MUTAGENT_DEBUG=true` to enable one by default. Debug logging reveals secrets (API tokens in headers) — development only.
|
|
506
395
|
|
|
507
396
|
```typescript
|
|
508
|
-
|
|
509
|
-
import * as errors from "@mutagent/sdk/models/errors";
|
|
510
|
-
|
|
511
|
-
async function example(mutagent: Mutagent) {
|
|
512
|
-
try {
|
|
513
|
-
await mutagent.agents.getAgent({ id: 404 });
|
|
514
|
-
} catch (error) {
|
|
515
|
-
if (error instanceof errors.ErrorResponse) {
|
|
516
|
-
console.error(error.statusCode, error.data$.error, error.data$.message);
|
|
517
|
-
} else if (error instanceof errors.MutagentError) {
|
|
518
|
-
console.error(`HTTP ${error.statusCode}: ${error.body}`);
|
|
519
|
-
} else {
|
|
520
|
-
throw error;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
397
|
+
const sdk = new Mutagent({ debugLogger: console });
|
|
524
398
|
```
|
|
525
399
|
|
|
526
400
|
---
|
|
527
401
|
|
|
528
402
|
## Development
|
|
529
403
|
|
|
530
|
-
The code under `src/sdk`, `src/models`, `src/funcs`, `src/lib`, `src/types
|
|
531
|
-
pages under `docs/`, are generated by Speakeasy from `openapi.json`. Do not edit them by hand: the next
|
|
532
|
-
generation overwrites them. Change the API route definitions or the scripts in `scripts/` instead.
|
|
404
|
+
The code under `src/sdk`, `src/models`, `src/funcs`, `src/lib`, `src/types`, `src/hooks`, and `docs/`, is generated by Speakeasy from `openapi.json`; do not hand-edit it, the next generation overwrites it (see [CLAUDE.md](CLAUDE.md) for the escalation path). Change the backend Elysia route annotations, `scripts/fix-openapi.ts` or `scripts/post-generate.ts` instead.
|
|
533
405
|
|
|
534
|
-
Prerequisites: [Bun](https://bun.sh) 1.1
|
|
535
|
-
`http://localhost:3003`.
|
|
406
|
+
Prerequisites: [Bun](https://bun.sh) 1.1+, the `speakeasy` CLI, and the MutagenT API running on `http://localhost:3003`.
|
|
536
407
|
|
|
537
408
|
```bash
|
|
538
|
-
#
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
# Build the ESM and CommonJS output
|
|
542
|
-
bun run build
|
|
543
|
-
|
|
544
|
-
# Run the unit tests for the generation scripts
|
|
545
|
-
bun test __tests__/unit
|
|
409
|
+
./scripts/generate-sdk.sh # fetch spec, generate, apply post-generation patches
|
|
410
|
+
bun run build # ESM + CommonJS output
|
|
411
|
+
bun test __tests__/unit # unit tests for the generation scripts
|
|
546
412
|
```
|
|
547
413
|
|
|
548
|
-
---
|
|
549
|
-
|
|
550
|
-
## API Reference
|
|
551
|
-
|
|
552
|
-
- [docs/sdks/](./docs/sdks/): one page per group, with every method, parameter and error
|
|
553
|
-
- [FUNCTIONS.md](./FUNCTIONS.md): standalone functions
|
|
554
|
-
- [RUNTIMES.md](./RUNTIMES.md): supported runtimes and TypeScript compiler options
|
|
555
|
-
- [docs.mutagent.io](https://docs.mutagent.io): platform documentation
|
|
556
|
-
|
|
557
|
-
---
|
|
558
|
-
|
|
559
414
|
## Contributing
|
|
560
415
|
|
|
561
416
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
562
417
|
|
|
563
|
-
---
|
|
564
|
-
|
|
565
418
|
## License
|
|
566
419
|
|
|
567
420
|
This software is proprietary and confidential. Unauthorized copying, distribution, or use is strictly prohibited.
|
|
568
421
|
|
|
569
422
|
© 2026 MutagenT. All rights reserved.
|
|
570
423
|
|
|
571
|
-
---
|
|
572
|
-
|
|
573
|
-
<p align="center">
|
|
574
|
-
<sub>Built with ❤️ by the MutagenT Team</sub>
|
|
575
|
-
</p>
|
|
576
|
-
|
|
577
424
|
<p align="center">
|
|
578
|
-
<a href="https://
|
|
579
|
-
<a href="https://discord.gg/mutagent">Discord</a> •
|
|
580
|
-
<a href="https://mutagent.io">Website</a> •
|
|
581
|
-
<a href="https://docs.mutagent.io">Documentation</a>
|
|
425
|
+
<sub>Built with care by the MutagenT Team • <a href="https://mutagent.io">mutagent.io</a></sub>
|
|
582
426
|
</p>
|
|
583
427
|
|
|
584
428
|
<!-- Start Summary [summary] -->
|
|
@@ -590,28 +434,24 @@ MutagenT Server API Documentation: MutagenT platform API: workspaces, LLM provid
|
|
|
590
434
|
<!-- Start Table of Contents [toc] -->
|
|
591
435
|
## Table of Contents
|
|
592
436
|
<!-- $toc-max-depth=2 -->
|
|
593
|
-
* [MutagenT SDK](#mutagent-sdk)
|
|
594
|
-
* [
|
|
595
|
-
* [
|
|
596
|
-
* [
|
|
597
|
-
* [
|
|
598
|
-
* [
|
|
599
|
-
* [Client groups](#client-groups)
|
|
600
|
-
* [Streaming](#streaming)
|
|
601
|
-
* [Error Handling](#error-handling)
|
|
437
|
+
* [MutagenT TypeScript SDK](#mutagent-typescript-sdk)
|
|
438
|
+
* [Context](#context)
|
|
439
|
+
* [Concepts](#concepts)
|
|
440
|
+
* [Components](#components)
|
|
441
|
+
* [Configuration](#configuration)
|
|
442
|
+
* [Reference](#reference)
|
|
602
443
|
* [Development](#development)
|
|
603
|
-
* [API Reference](#api-reference)
|
|
604
444
|
* [Contributing](#contributing)
|
|
605
445
|
* [License](#license)
|
|
606
446
|
* [SDK Installation](#sdk-installation)
|
|
607
447
|
* [Requirements](#requirements)
|
|
608
448
|
* [SDK Example Usage](#sdk-example-usage)
|
|
609
|
-
* [Authentication](#authentication
|
|
449
|
+
* [Authentication](#authentication)
|
|
610
450
|
* [Available Resources and Operations](#available-resources-and-operations)
|
|
611
451
|
* [Standalone functions](#standalone-functions)
|
|
612
452
|
* [Pagination](#pagination)
|
|
613
453
|
* [Retries](#retries)
|
|
614
|
-
* [Error Handling](#error-handling
|
|
454
|
+
* [Error Handling](#error-handling)
|
|
615
455
|
* [Server Selection](#server-selection)
|
|
616
456
|
* [Custom HTTP Client](#custom-http-client)
|
|
617
457
|
* [Debugging](#debugging)
|
|
@@ -35,8 +35,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
35
35
|
export declare const SDK_METADATA: {
|
|
36
36
|
readonly language: "typescript";
|
|
37
37
|
readonly openapiDocVersion: "2.0.0";
|
|
38
|
-
readonly sdkVersion: "0.6.
|
|
38
|
+
readonly sdkVersion: "0.6.2";
|
|
39
39
|
readonly genVersion: "2.938.0";
|
|
40
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.6.
|
|
40
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.6.2 2.938.0 2.0.0 @mutagent/sdk";
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -35,8 +35,8 @@ function serverURLFromOptions(options) {
|
|
|
35
35
|
exports.SDK_METADATA = {
|
|
36
36
|
language: "typescript",
|
|
37
37
|
openapiDocVersion: "2.0.0",
|
|
38
|
-
sdkVersion: "0.6.
|
|
38
|
+
sdkVersion: "0.6.2",
|
|
39
39
|
genVersion: "2.938.0",
|
|
40
|
-
userAgent: "speakeasy-sdk/typescript 0.6.
|
|
40
|
+
userAgent: "speakeasy-sdk/typescript 0.6.2 2.938.0 2.0.0 @mutagent/sdk",
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=config.js.map
|
package/dist/esm/lib/config.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
35
35
|
export declare const SDK_METADATA: {
|
|
36
36
|
readonly language: "typescript";
|
|
37
37
|
readonly openapiDocVersion: "2.0.0";
|
|
38
|
-
readonly sdkVersion: "0.6.
|
|
38
|
+
readonly sdkVersion: "0.6.2";
|
|
39
39
|
readonly genVersion: "2.938.0";
|
|
40
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.6.
|
|
40
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.6.2 2.938.0 2.0.0 @mutagent/sdk";
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/esm/lib/config.js
CHANGED
|
@@ -31,8 +31,8 @@ export function serverURLFromOptions(options) {
|
|
|
31
31
|
export const SDK_METADATA = {
|
|
32
32
|
language: "typescript",
|
|
33
33
|
openapiDocVersion: "2.0.0",
|
|
34
|
-
sdkVersion: "0.6.
|
|
34
|
+
sdkVersion: "0.6.2",
|
|
35
35
|
genVersion: "2.938.0",
|
|
36
|
-
userAgent: "speakeasy-sdk/typescript 0.6.
|
|
36
|
+
userAgent: "speakeasy-sdk/typescript 0.6.2 2.938.0 2.0.0 @mutagent/sdk",
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=config.js.map
|