@eigenpal/sdk 0.4.10 → 0.4.12
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/CHANGELOG.md +59 -2
- package/README.md +58 -46
- package/package.json +1 -1
- package/src/client.ts +48 -17
- package/src/errors.ts +7 -2
- package/src/generated/index.ts +82 -21
- package/src/generated/sdk.gen.ts +203 -31
- package/src/generated/types.gen.ts +649 -88
- package/src/index.ts +21 -8
- package/src/lib/files.ts +27 -0
- package/src/resources/agents.ts +168 -0
- package/src/resources/executions.ts +35 -23
- package/src/resources/workflows.ts +9 -3
- package/src/runtime-config.ts +2 -2
- package/src/telemetry.ts +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,64 @@
|
|
|
1
1
|
# @eigenpal/sdk
|
|
2
2
|
|
|
3
|
-
## 0.4.
|
|
3
|
+
## 0.4.12
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- c15ce88: Rename agent API calls to `/v1/agents` and scope execution helpers under their owning workflow or agent.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 9905f7f: Fix the published SDKs so the README's default `baseUrl` works. 0.4.10
|
|
12
|
+
shipped paths under `/v1/...` while the actual Next.js routes live at
|
|
13
|
+
`/api/v1/...`, so every call from a freshly installed SDK either hit
|
|
14
|
+
the marketing-site HTML (200 OK silently parsed as a workflow object)
|
|
15
|
+
or 307'd to a redirect Python wouldn't follow. Now the OpenAPI spec
|
|
16
|
+
emits `/api/v1/...` and the regenerated TS + Python clients call the
|
|
17
|
+
real URLs without a `baseUrl: '.../api'` workaround.
|
|
18
|
+
|
|
19
|
+
Also trims the v1 public surface so SDK consumers no longer see internal
|
|
20
|
+
columns. The legacy app handlers spread the raw DB row, which dragged
|
|
21
|
+
`tenantId`, `isBlock`, `currentHistoryId`, `evalConfigYaml`, `createdBy`,
|
|
22
|
+
the full `currentVersion` object, `traceId`, `spanId`, `versionId`,
|
|
23
|
+
`leaseId`, `workerId`, `definitionSnapshot`, `blockSnapshots`,
|
|
24
|
+
`stepResults`, `evalScore`, `priority`, retry-chain pointers, etc. into
|
|
25
|
+
typed SDK output. The v1 endpoints now wrap the legacy response with
|
|
26
|
+
`pickPublicWorkflow` / `pickPublicWorkflowVersion` / `pickPublicExecution`
|
|
27
|
+
helpers (forwarded via `forwardItem` / `forwardList`), so the wire shape
|
|
28
|
+
matches the schema. `WorkflowSummary` is now
|
|
29
|
+
`{ id, version, createdAt, updatedAt }` — `version` is the release tag
|
|
30
|
+
string callers actually want, replacing the internal `currentHistoryId`.
|
|
31
|
+
|
|
32
|
+
Heads-up: workflow `name` is no longer surfaced as a top-level field
|
|
33
|
+
(it was previously leaked via `currentVersion.definition.name`). It's
|
|
34
|
+
authoritative inside the YAML, so fetch it via
|
|
35
|
+
`client.workflows.versions(id)[0].yamlContent` and parse, or treat the
|
|
36
|
+
workflow `id` as the canonical identifier.
|
|
37
|
+
|
|
38
|
+
Tightens response handling on both sides: the client throws
|
|
39
|
+
`EigenpalError` whenever a response carries a non-JSON Content-Type
|
|
40
|
+
(2xx or 4xx), so the next misconfigured `baseUrl` fails loudly with a
|
|
41
|
+
"point baseUrl at your EigenPal instance root" message instead of
|
|
42
|
+
silently returning string-as-object or surfacing a downstream
|
|
43
|
+
`JSONDecodeError`.
|
|
44
|
+
|
|
45
|
+
Renames the constructor: `Eigenpal` → `EigenpalClient` in both SDKs.
|
|
46
|
+
The old name was ambiguous when imported alongside `EigenpalError` etc.
|
|
47
|
+
and read awkwardly as `new Eigenpal(...)` next to the brand
|
|
48
|
+
("Eigenpal"); `EigenpalClient` matches the convention of every
|
|
49
|
+
neighbouring class. No backwards-compat alias since 0.4.10 is fresh.
|
|
50
|
+
|
|
51
|
+
Adds `bun sdk:smoke:local [ts|py|both]` — packs the local SDK as the
|
|
52
|
+
exact tarball / wheel that ships, installs into a clean tmp workspace,
|
|
53
|
+
and runs an end-to-end smoke against `EIGENPAL_BASE_URL`. Verifies the
|
|
54
|
+
v1 paths resolve, the trimmed public shape is enforced on the wire,
|
|
55
|
+
and the HTML-host guard fires.
|
|
56
|
+
|
|
57
|
+
`defineRoute` rejects paths that don't start with `/api/` so the
|
|
58
|
+
mismatch can't reappear by accident.
|
|
59
|
+
|
|
60
|
+
## Unreleased
|
|
4
61
|
|
|
5
62
|
- Initial release.
|
|
6
63
|
- Coverage: workflow trigger (sync + async), execution polling, cancel, workflow & version listing.
|
|
7
|
-
- `Eigenpal` facade with API key auth, automatic retries on 5xx / 429 / network errors with `Retry-After` honoring, typed `EigenpalError` subclasses, and `executions.runAndWait()` for client-side polling.
|
|
64
|
+
- `Eigenpal` facade with API key auth, automatic retries on 5xx / 429 / network errors with `Retry-After` honoring, typed `EigenpalError` subclasses, and `workflows.executions.runAndWait()` for client-side polling.
|
package/README.md
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
# @eigenpal/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Trigger EigenPal workflows from TypeScript.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@eigenpal/sdk)
|
|
6
|
+
[](https://www.npmjs.com/package/@eigenpal/sdk)
|
|
7
|
+
[](https://github.com/eigenpal/sdk-typescript/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/eigenpal/sdk-typescript)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
4
11
|
|
|
5
12
|
```bash
|
|
6
|
-
npm
|
|
13
|
+
npm i @eigenpal/sdk
|
|
7
14
|
```
|
|
8
15
|
|
|
16
|
+
Requires a TypeScript-aware runtime: Bun, Deno, Node 22+ (native TS), `tsx`, Next.js, Vite, or any modern bundler. Plain `node script.js` won't work — see [Configuration](./docs/configuration.md#typescript-runtime).
|
|
17
|
+
|
|
18
|
+
Get an API key at **app.eigenpal.com → Settings → API Keys**.
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
9
22
|
```ts
|
|
10
|
-
import {
|
|
23
|
+
import { EigenpalClient, EigenpalValidationError } from '@eigenpal/sdk';
|
|
11
24
|
|
|
12
|
-
const client = new
|
|
13
|
-
apiKey: process.env.EIGENPAL_API_KEY,
|
|
14
|
-
});
|
|
25
|
+
const client = new EigenpalClient({ apiKey: process.env.EIGENPAL_API_KEY });
|
|
15
26
|
|
|
16
27
|
// Pass a File / Blob / { content, filename, mimeType }. The SDK uploads
|
|
17
28
|
// the request as multipart/form-data, no base64 needed.
|
|
18
|
-
const result = await client.executions.runAndWait('extract-invoice', {
|
|
29
|
+
const result = await client.workflows.executions.runAndWait('extract-invoice', {
|
|
19
30
|
contract_document: file,
|
|
20
31
|
});
|
|
21
32
|
console.log(result.status, result.result);
|
|
@@ -26,7 +37,7 @@ console.log(result.status, result.result);
|
|
|
26
37
|
Generate an API key from the dashboard under **Settings → API Keys**, then pass it explicitly:
|
|
27
38
|
|
|
28
39
|
```ts
|
|
29
|
-
const client = new
|
|
40
|
+
const client = new EigenpalClient({ apiKey: process.env.EIGENPAL_API_KEY });
|
|
30
41
|
```
|
|
31
42
|
|
|
32
43
|
The `apiKey` constructor option always wins. If you omit it, the SDK falls back to `process.env.EIGENPAL_API_KEY` for convenience, handy in scripts where you'd be writing exactly the line above.
|
|
@@ -36,7 +47,7 @@ The `apiKey` constructor option always wins. If you omit it, the SDK falls back
|
|
|
36
47
|
Point the SDK at your own deployment via `baseUrl`:
|
|
37
48
|
|
|
38
49
|
```ts
|
|
39
|
-
const client = new
|
|
50
|
+
const client = new EigenpalClient({
|
|
40
51
|
apiKey: process.env.EIGENPAL_API_KEY,
|
|
41
52
|
baseUrl: process.env.EIGENPAL_BASE_URL ?? 'https://eigenpal.acme.internal',
|
|
42
53
|
});
|
|
@@ -63,7 +74,7 @@ const result = await client.workflows.run(
|
|
|
63
74
|
console.log(result.status, result.result);
|
|
64
75
|
|
|
65
76
|
// Long-running: client-side polling, default 5min cap.
|
|
66
|
-
const final = await client.executions.runAndWait('extract-invoice', {
|
|
77
|
+
const final = await client.workflows.executions.runAndWait('extract-invoice', {
|
|
67
78
|
contract_document: file,
|
|
68
79
|
});
|
|
69
80
|
```
|
|
@@ -95,17 +106,16 @@ await client.workflows.run('extract-invoice', {
|
|
|
95
106
|
## Execution polling
|
|
96
107
|
|
|
97
108
|
```ts
|
|
98
|
-
const status = await client.executions.get(executionId);
|
|
109
|
+
const status = await client.workflows.executions.get(executionId);
|
|
99
110
|
// { executionId, status, result?, error?, createdAt, completedAt? }
|
|
100
111
|
|
|
101
|
-
const list = await client.executions.list({
|
|
102
|
-
|
|
103
|
-
status: 'failed',
|
|
112
|
+
const list = await client.workflows.executions.list('extract-invoice', {
|
|
113
|
+
status: ['failed', 'cancelled'],
|
|
104
114
|
fromDate: 'now()-7d',
|
|
105
115
|
limit: 50,
|
|
106
116
|
});
|
|
107
117
|
|
|
108
|
-
await client.executions.cancel(executionId);
|
|
118
|
+
await client.workflows.executions.cancel(executionId);
|
|
109
119
|
```
|
|
110
120
|
|
|
111
121
|
## Workflows
|
|
@@ -116,6 +126,20 @@ await client.workflows.get('extract-invoice');
|
|
|
116
126
|
await client.workflows.versions('extract-invoice');
|
|
117
127
|
```
|
|
118
128
|
|
|
129
|
+
## Agents
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
await client.agents.list({ search: 'invoice' });
|
|
133
|
+
await client.agents.get('invoice-agent');
|
|
134
|
+
|
|
135
|
+
const { executionId } = await client.agents.run('invoice-agent', {
|
|
136
|
+
invoice: file,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await client.agents.executions.get(executionId);
|
|
140
|
+
await client.agents.executions.cancel(executionId);
|
|
141
|
+
```
|
|
142
|
+
|
|
119
143
|
## Errors
|
|
120
144
|
|
|
121
145
|
Every non-2xx response throws a typed subclass of `EigenpalError`:
|
|
@@ -131,48 +155,36 @@ Every non-2xx response throws a typed subclass of `EigenpalError`:
|
|
|
131
155
|
| timeout / abort | `EigenpalTimeoutError` | |
|
|
132
156
|
|
|
133
157
|
```ts
|
|
134
|
-
import {
|
|
158
|
+
import { EigenpalClient, EigenpalValidationError } from '@eigenpal/sdk';
|
|
159
|
+
|
|
160
|
+
const client = new EigenpalClient({ apiKey: process.env.EIGENPAL_API_KEY });
|
|
135
161
|
|
|
136
162
|
try {
|
|
137
|
-
|
|
163
|
+
// First arg accepts the workflow slug ('extract-invoice') or id ('wf_abc123').
|
|
164
|
+
const result = await client.workflows.executions.runAndWait('extract-invoice', {
|
|
165
|
+
language: 'en',
|
|
166
|
+
});
|
|
167
|
+
console.log(result.status, result.result);
|
|
138
168
|
} catch (err) {
|
|
139
169
|
if (err instanceof EigenpalValidationError) {
|
|
140
|
-
for (const issue of err.issues) {
|
|
141
|
-
console.error(`${issue.field}: ${issue.message}`);
|
|
142
|
-
}
|
|
170
|
+
for (const issue of err.issues) console.error(`${issue.field}: ${issue.message}`);
|
|
143
171
|
}
|
|
144
172
|
throw err;
|
|
145
173
|
}
|
|
146
174
|
```
|
|
147
175
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
new Eigenpal({
|
|
152
|
-
apiKey: 'eg_…', // or EIGENPAL_API_KEY
|
|
153
|
-
baseUrl: 'https://app.eigenpal.com', // or EIGENPAL_BASE_URL
|
|
154
|
-
timeoutMs: 60_000, // per-request timeout
|
|
155
|
-
maxRetries: 3, // 5xx / 429 / network
|
|
156
|
-
defaultHeaders: {
|
|
157
|
-
// merged into every request
|
|
158
|
-
'X-Trace-Id': '…',
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
The SDK retries on 5xx, 429 (honoring `Retry-After`), and network errors. 4xx errors are surfaced immediately as typed exceptions and are not retried.
|
|
176
|
+
For file inputs, see [docs/files.md](./docs/files.md).
|
|
164
177
|
|
|
165
|
-
##
|
|
178
|
+
## Reference
|
|
166
179
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
```
|
|
180
|
+
| Topic | What's in it |
|
|
181
|
+
| ----------------------------------------- | -------------------------------------------------- |
|
|
182
|
+
| [Workflows](./docs/workflows.md) | List, get, trigger runs, pin versions. |
|
|
183
|
+
| [Executions](./docs/executions.md) | Status, polling, cancel, run-and-wait. |
|
|
184
|
+
| [File inputs](./docs/files.md) | Multipart upload from File, Blob, Buffer, or path. |
|
|
185
|
+
| [Errors](./docs/errors.md) | Typed exceptions, retries, request ids. |
|
|
186
|
+
| [Configuration](./docs/configuration.md) | API key, baseUrl, timeouts, headers. |
|
|
187
|
+
| [Full API reference](./docs/reference.md) | Every method, generated from the OpenAPI spec. |
|
|
176
188
|
|
|
177
189
|
## License
|
|
178
190
|
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { EigenpalError, EigenpalTimeoutError, errorFromResponse } from './errors';
|
|
2
2
|
import { createClient, createConfig, type Client, type Config } from './generated/client';
|
|
3
3
|
import type { ApiErrorEnvelope } from './generated/types.gen';
|
|
4
|
-
import {
|
|
4
|
+
import { AgentsResource } from './resources/agents';
|
|
5
5
|
import { WorkflowsResource } from './resources/workflows';
|
|
6
|
+
import { buildTelemetryHeaders } from './telemetry';
|
|
6
7
|
|
|
7
8
|
export interface EigenpalOptions {
|
|
8
9
|
/**
|
|
9
10
|
* API key issued from Settings → API Keys (`eg_…`).
|
|
10
11
|
*
|
|
11
12
|
* Falls back to the `EIGENPAL_API_KEY` environment variable when omitted,
|
|
12
|
-
* so most users only need `new
|
|
13
|
+
* so most users only need `new EigenpalClient()`.
|
|
13
14
|
*/
|
|
14
15
|
apiKey?: string;
|
|
15
16
|
/**
|
|
@@ -31,7 +32,6 @@ export interface EigenpalOptions {
|
|
|
31
32
|
const DEFAULT_BASE_URL = 'https://app.eigenpal.com';
|
|
32
33
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
33
34
|
const DEFAULT_MAX_RETRIES = 3;
|
|
34
|
-
const SDK_VERSION = '0.0.0-placeholder';
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Result shape returned by hey-api operation calls. We let hey-api default
|
|
@@ -49,13 +49,13 @@ export interface OperationResult<T> {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* The
|
|
52
|
+
* The EigenPal SDK client.
|
|
53
53
|
*
|
|
54
54
|
* ```ts
|
|
55
|
-
* import {
|
|
55
|
+
* import { EigenpalClient } from '@eigenpal/sdk';
|
|
56
56
|
*
|
|
57
57
|
* // Reads EIGENPAL_API_KEY from env automatically.
|
|
58
|
-
* const client = new
|
|
58
|
+
* const client = new EigenpalClient();
|
|
59
59
|
*
|
|
60
60
|
* // Async — enqueue and poll later.
|
|
61
61
|
* const { executionId } = await client.workflows.run('wf_abc', { language: 'en' });
|
|
@@ -65,15 +65,15 @@ export interface OperationResult<T> {
|
|
|
65
65
|
* waitForCompletion: 60,
|
|
66
66
|
* });
|
|
67
67
|
*
|
|
68
|
-
* // Client-side polling for long-running
|
|
69
|
-
* const final = await client.executions.runAndWait('wf_abc', { language: 'en' });
|
|
68
|
+
* // Client-side polling for long-running executions (default 5min cap).
|
|
69
|
+
* const final = await client.workflows.executions.runAndWait('wf_abc', { language: 'en' });
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
export class
|
|
72
|
+
export class EigenpalClient {
|
|
73
73
|
/** Workflow operations: `list`, `get`, `versions`, `run`. */
|
|
74
74
|
public readonly workflows: WorkflowsResource;
|
|
75
|
-
/**
|
|
76
|
-
public readonly
|
|
75
|
+
/** Agent operations: `list`, `get`, `create`, `run`, `executions`. */
|
|
76
|
+
public readonly agents: AgentsResource;
|
|
77
77
|
|
|
78
78
|
/** Underlying hey-api client. Use `getRawClient()` for advanced cases. */
|
|
79
79
|
private readonly client: Client;
|
|
@@ -84,7 +84,7 @@ export class Eigenpal {
|
|
|
84
84
|
const apiKey = options.apiKey ?? readEnv('EIGENPAL_API_KEY');
|
|
85
85
|
if (!apiKey) {
|
|
86
86
|
throw new EigenpalError(
|
|
87
|
-
'Missing API key. Pass `new
|
|
87
|
+
'Missing API key. Pass `new EigenpalClient({ apiKey })` or set the EIGENPAL_API_KEY environment variable.',
|
|
88
88
|
{ status: 0 }
|
|
89
89
|
);
|
|
90
90
|
}
|
|
@@ -97,7 +97,10 @@ export class Eigenpal {
|
|
|
97
97
|
baseUrl,
|
|
98
98
|
headers: {
|
|
99
99
|
Authorization: `Bearer ${apiKey}`,
|
|
100
|
-
|
|
100
|
+
// SDK telemetry headers (X-Eigenpal-Sdk-*) + a richer User-Agent.
|
|
101
|
+
// User-supplied defaultHeaders override these so callers can opt out
|
|
102
|
+
// of telemetry by passing their own User-Agent / X-Eigenpal-Sdk.
|
|
103
|
+
...buildTelemetryHeaders(),
|
|
101
104
|
...(options.defaultHeaders ?? {}),
|
|
102
105
|
},
|
|
103
106
|
});
|
|
@@ -112,7 +115,7 @@ export class Eigenpal {
|
|
|
112
115
|
this.installTimeoutInterceptor();
|
|
113
116
|
|
|
114
117
|
this.workflows = new WorkflowsResource(this.client, this._request.bind(this));
|
|
115
|
-
this.
|
|
118
|
+
this.agents = new AgentsResource(this.client, this._request.bind(this));
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
/** Expose the underlying hey-api client for advanced use (custom interceptors, etc.). */
|
|
@@ -133,12 +136,24 @@ export class Eigenpal {
|
|
|
133
136
|
try {
|
|
134
137
|
const result = await call();
|
|
135
138
|
const response = result.response;
|
|
139
|
+
const status = response?.status ?? 0;
|
|
140
|
+
// Guard against misconfigured `baseUrl` pointed at an HTML host
|
|
141
|
+
// (e.g. `https://eigenpal.com` instead of `https://app.eigenpal.com`).
|
|
142
|
+
// Fires for both 2xx and non-2xx so a 4xx with HTML surfaces a typed
|
|
143
|
+
// baseUrl-pointing error instead of a misleading NotFoundError or a
|
|
144
|
+
// downstream JSON-parse crash. 0.4.10 shipped with this footgun.
|
|
145
|
+
//
|
|
146
|
+
// Don't run on retriable statuses — a 503 maintenance page from a
|
|
147
|
+
// CDN is transient and should consume retry budget, not throw on
|
|
148
|
+
// attempt zero. Only fire when we're about to surface the response
|
|
149
|
+
// as a final result or final error.
|
|
150
|
+
const willRetry = isRetriableStatus(status) && attempt < this.maxRetries;
|
|
151
|
+
if (response && !willRetry) assertJsonResponse(response);
|
|
136
152
|
if (response && response.ok && result.data !== undefined) {
|
|
137
153
|
return result.data;
|
|
138
154
|
}
|
|
139
155
|
// Non-2xx (or response missing — treat as opaque failure).
|
|
140
|
-
|
|
141
|
-
if (isRetriableStatus(status) && attempt < this.maxRetries) {
|
|
156
|
+
if (willRetry) {
|
|
142
157
|
await sleep(retryDelay(response, attempt));
|
|
143
158
|
continue;
|
|
144
159
|
}
|
|
@@ -146,7 +161,7 @@ export class Eigenpal {
|
|
|
146
161
|
const retryAfter = parseRetryAfter(response?.headers.get('retry-after') ?? null);
|
|
147
162
|
throw errorFromResponse(status, envelope, retryAfter);
|
|
148
163
|
} catch (err) {
|
|
149
|
-
// Re-throw mapped
|
|
164
|
+
// Re-throw mapped EigenpalError subclasses as-is.
|
|
150
165
|
if (err instanceof EigenpalError) throw err;
|
|
151
166
|
// Network/abort error — retry if budget allows. AbortSignal aborts
|
|
152
167
|
// surface as DOMException — we treat them as terminal (don't retry).
|
|
@@ -181,6 +196,22 @@ export class Eigenpal {
|
|
|
181
196
|
}
|
|
182
197
|
}
|
|
183
198
|
|
|
199
|
+
function assertJsonResponse(response: Response): void {
|
|
200
|
+
// 204 No Content has no body — accept silently.
|
|
201
|
+
if (response.status === 204) return;
|
|
202
|
+
const contentType = response.headers.get('content-type')?.toLowerCase() ?? '';
|
|
203
|
+
// Match `application/json`, `application/problem+json`, etc. Empty
|
|
204
|
+
// Content-Type is tolerated since some proxies strip it on small bodies.
|
|
205
|
+
if (contentType === '' || contentType.includes('json')) return;
|
|
206
|
+
throw new EigenpalError(
|
|
207
|
+
`Expected a JSON response from the API but got Content-Type "${contentType}". ` +
|
|
208
|
+
`This usually means \`baseUrl\` points at a non-API host (e.g. the marketing site or ` +
|
|
209
|
+
`a misconfigured proxy). Set \`baseUrl\` to your EigenPal instance root, ` +
|
|
210
|
+
`e.g. "https://app.eigenpal.com".`,
|
|
211
|
+
{ status: response.status }
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
184
215
|
function isRetriableStatus(status: number): boolean {
|
|
185
216
|
return status >= 500 || status === 429;
|
|
186
217
|
}
|
package/src/errors.ts
CHANGED
|
@@ -25,7 +25,12 @@ export class EigenpalError extends Error {
|
|
|
25
25
|
|
|
26
26
|
export class EigenpalAuthError extends EigenpalError {
|
|
27
27
|
constructor(envelope?: ApiErrorEnvelope) {
|
|
28
|
-
super(
|
|
28
|
+
super(
|
|
29
|
+
envelope?.issues?.[0]?.message ??
|
|
30
|
+
'Invalid or missing API key. Generate one at app.eigenpal.com → Settings → API Keys; ' +
|
|
31
|
+
'pass it as `new EigenpalClient({ apiKey })` or set EIGENPAL_API_KEY.',
|
|
32
|
+
{ status: 401, envelope }
|
|
33
|
+
);
|
|
29
34
|
this.name = 'EigenpalAuthError';
|
|
30
35
|
}
|
|
31
36
|
}
|
|
@@ -85,7 +90,7 @@ export class EigenpalTimeoutError extends EigenpalError {
|
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
92
|
* Map an HTTP response into the appropriate typed error. Used by the
|
|
88
|
-
* `
|
|
93
|
+
* `EigenpalClient` facade to wrap raw fetch errors before they bubble to user
|
|
89
94
|
* code.
|
|
90
95
|
*/
|
|
91
96
|
export function errorFromResponse(
|
package/src/generated/index.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
agentsCreate,
|
|
5
|
+
agentsExecutionsCancel,
|
|
6
|
+
agentsExecutionsGet,
|
|
7
|
+
agentsExecutionsList,
|
|
8
|
+
agentsGet,
|
|
9
|
+
agentsList,
|
|
10
|
+
agentsRun,
|
|
11
|
+
agentsUpdate,
|
|
12
|
+
workflowsExecutionsCancel,
|
|
13
|
+
workflowsExecutionsGet,
|
|
14
|
+
workflowsExecutionsList,
|
|
7
15
|
workflowsGet,
|
|
8
16
|
workflowsList,
|
|
9
17
|
workflowsRun,
|
|
@@ -11,35 +19,88 @@ export {
|
|
|
11
19
|
type Options,
|
|
12
20
|
} from './sdk.gen';
|
|
13
21
|
export type {
|
|
22
|
+
AgentExecutionResponse,
|
|
23
|
+
AgentExecutionSummary,
|
|
24
|
+
AgentSummary,
|
|
25
|
+
AgentsCreateData,
|
|
26
|
+
AgentsCreateError,
|
|
27
|
+
AgentsCreateErrors,
|
|
28
|
+
AgentsCreateResponse,
|
|
29
|
+
AgentsCreateResponses,
|
|
30
|
+
AgentsExecutionsCancelData,
|
|
31
|
+
AgentsExecutionsCancelError,
|
|
32
|
+
AgentsExecutionsCancelErrors,
|
|
33
|
+
AgentsExecutionsCancelResponse,
|
|
34
|
+
AgentsExecutionsCancelResponses,
|
|
35
|
+
AgentsExecutionsGetData,
|
|
36
|
+
AgentsExecutionsGetError,
|
|
37
|
+
AgentsExecutionsGetErrors,
|
|
38
|
+
AgentsExecutionsGetResponse,
|
|
39
|
+
AgentsExecutionsGetResponses,
|
|
40
|
+
AgentsExecutionsListData,
|
|
41
|
+
AgentsExecutionsListError,
|
|
42
|
+
AgentsExecutionsListErrors,
|
|
43
|
+
AgentsExecutionsListResponse,
|
|
44
|
+
AgentsExecutionsListResponses,
|
|
45
|
+
AgentsGetData,
|
|
46
|
+
AgentsGetError,
|
|
47
|
+
AgentsGetErrors,
|
|
48
|
+
AgentsGetResponse,
|
|
49
|
+
AgentsGetResponses,
|
|
50
|
+
AgentsListData,
|
|
51
|
+
AgentsListError,
|
|
52
|
+
AgentsListErrors,
|
|
53
|
+
AgentsListResponse,
|
|
54
|
+
AgentsListResponses,
|
|
55
|
+
AgentsRunData,
|
|
56
|
+
AgentsRunError,
|
|
57
|
+
AgentsRunErrors,
|
|
58
|
+
AgentsRunResponse,
|
|
59
|
+
AgentsRunResponses,
|
|
60
|
+
AgentsUpdateData,
|
|
61
|
+
AgentsUpdateError,
|
|
62
|
+
AgentsUpdateErrors,
|
|
63
|
+
AgentsUpdateResponse,
|
|
64
|
+
AgentsUpdateResponses,
|
|
14
65
|
ApiErrorEnvelope,
|
|
15
66
|
ApiErrorIssue,
|
|
16
|
-
|
|
67
|
+
CancelAgentExecutionResponse,
|
|
68
|
+
CancelWorkflowExecutionResponse,
|
|
17
69
|
ClientOptions,
|
|
70
|
+
CreateAgentBody,
|
|
71
|
+
CreateAgentResponse,
|
|
18
72
|
ExecutionStatus,
|
|
19
|
-
ExecutionStatusResponse,
|
|
20
73
|
ExecutionSummary,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
ExecutionsCancelResponse,
|
|
25
|
-
ExecutionsCancelResponses,
|
|
26
|
-
ExecutionsGetData,
|
|
27
|
-
ExecutionsGetError,
|
|
28
|
-
ExecutionsGetErrors,
|
|
29
|
-
ExecutionsGetResponse,
|
|
30
|
-
ExecutionsGetResponses,
|
|
31
|
-
ExecutionsListData,
|
|
32
|
-
ExecutionsListError,
|
|
33
|
-
ExecutionsListErrors,
|
|
34
|
-
ExecutionsListResponse,
|
|
35
|
-
ExecutionsListResponses,
|
|
36
|
-
ListExecutionsResponse,
|
|
74
|
+
GetAgentResponse,
|
|
75
|
+
ListAgentExecutionsResponse,
|
|
76
|
+
ListAgentsResponse,
|
|
37
77
|
ListVersionsResponse,
|
|
78
|
+
ListWorkflowExecutionsResponse,
|
|
38
79
|
ListWorkflowsResponse,
|
|
80
|
+
PatchAgentBody,
|
|
81
|
+
PatchAgentResponse,
|
|
82
|
+
RunAgentBody,
|
|
83
|
+
RunAgentResponse,
|
|
39
84
|
RunWorkflowBody,
|
|
40
85
|
RunWorkflowResponse,
|
|
86
|
+
WorkflowExecutionStatusResponse,
|
|
41
87
|
WorkflowSummary,
|
|
42
88
|
WorkflowVersion,
|
|
89
|
+
WorkflowsExecutionsCancelData,
|
|
90
|
+
WorkflowsExecutionsCancelError,
|
|
91
|
+
WorkflowsExecutionsCancelErrors,
|
|
92
|
+
WorkflowsExecutionsCancelResponse,
|
|
93
|
+
WorkflowsExecutionsCancelResponses,
|
|
94
|
+
WorkflowsExecutionsGetData,
|
|
95
|
+
WorkflowsExecutionsGetError,
|
|
96
|
+
WorkflowsExecutionsGetErrors,
|
|
97
|
+
WorkflowsExecutionsGetResponse,
|
|
98
|
+
WorkflowsExecutionsGetResponses,
|
|
99
|
+
WorkflowsExecutionsListData,
|
|
100
|
+
WorkflowsExecutionsListError,
|
|
101
|
+
WorkflowsExecutionsListErrors,
|
|
102
|
+
WorkflowsExecutionsListResponse,
|
|
103
|
+
WorkflowsExecutionsListResponses,
|
|
43
104
|
WorkflowsGetData,
|
|
44
105
|
WorkflowsGetError,
|
|
45
106
|
WorkflowsGetErrors,
|