@eigenpal/sdk 0.6.13 → 0.6.15

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.
@@ -12,20 +12,6 @@ export type PatchAgentBody = {
12
12
  };
13
13
  };
14
14
 
15
- export type RunAgentBody = {
16
- input?: {
17
- [key: string]: unknown;
18
- };
19
- _metadata?: {
20
- [key: string]: unknown;
21
- };
22
- /**
23
- * Git source ref to resolve for this run. Defaults to latest. Supports latest, main, exact versions/tags such as 1.2.3, semver ranges such as 1.2.x or 1.x, and exact commit SHAs.
24
- */
25
- sourceRef?: string;
26
- [key: string]: unknown;
27
- };
28
-
29
15
  export type CreateAgentBody = {
30
16
  name: string;
31
17
  slug: string;
@@ -35,6 +21,10 @@ export type CreateAgentBody = {
35
21
  };
36
22
  };
37
23
 
24
+ export type RunTargetInputBody = {
25
+ [key: string]: unknown;
26
+ };
27
+
38
28
  export type RunFeedbackRequest = {
39
29
  body?: string | null;
40
30
  feedback?: string | null;
@@ -97,29 +87,6 @@ export type SourceSecretsEncryptBody = {
97
87
  }>;
98
88
  };
99
89
 
100
- export type RunWorkflowBody = {
101
- /**
102
- * Workflow inputs keyed by input name
103
- */
104
- input?: {
105
- [key: string]: unknown;
106
- };
107
- /**
108
- * Per-step output overrides for replay
109
- */
110
- overrides?: {
111
- steps?: {
112
- [key: string]: {
113
- [key: string]: unknown;
114
- };
115
- };
116
- } | null;
117
- /**
118
- * Caller surface (defaults to "api")
119
- */
120
- trigger?: 'api' | 'cli';
121
- };
122
-
123
90
  export type ApiErrorEnvelope = {
124
91
  issues: Array<ApiErrorIssue>;
125
92
  /**
@@ -187,32 +154,6 @@ export type PatchAgentResponse = {
187
154
  agent: AgentSummary;
188
155
  };
189
156
 
190
- export type RunAgentResponse = {
191
- runId: string;
192
- status?: ExecutionStatus | 'timeout';
193
- output?: unknown;
194
- schemaValid?: boolean | null;
195
- error?: string | null;
196
- requestedSourceRef?: string | null;
197
- resolvedGitRef?: string | null;
198
- resolvedGitTag?: string | null;
199
- resolvedCommitSha?: string | null;
200
- cost?: {
201
- [key: string]: unknown;
202
- };
203
- };
204
-
205
- export type ExecutionStatus =
206
- | 'created'
207
- | 'pending'
208
- | 'running'
209
- | 'waiting'
210
- | 'finalizing'
211
- | 'completed'
212
- | 'failed'
213
- | 'cancelled'
214
- | 'rejected';
215
-
216
157
  export type ListAgentVersionsResponse = {
217
158
  agentId: string;
218
159
  slug: string;
@@ -263,6 +204,33 @@ export type AutomationSyncResponse = {
263
204
  warnings: Array<string>;
264
205
  };
265
206
 
207
+ export type RunStartResponse = {
208
+ runId: string;
209
+ type: 'workflow' | 'agent';
210
+ status?: ExecutionStatus | 'pending' | 'timeout';
211
+ output?: unknown;
212
+ error?: string | null;
213
+ schemaValid?: boolean | null;
214
+ requestedSourceRef?: string | null;
215
+ resolvedGitRef?: string | null;
216
+ resolvedGitTag?: string | null;
217
+ resolvedCommitSha?: string | null;
218
+ cost?: {
219
+ [key: string]: unknown;
220
+ };
221
+ };
222
+
223
+ export type ExecutionStatus =
224
+ | 'created'
225
+ | 'pending'
226
+ | 'running'
227
+ | 'waiting'
228
+ | 'finalizing'
229
+ | 'completed'
230
+ | 'failed'
231
+ | 'cancelled'
232
+ | 'rejected';
233
+
266
234
  export type RunFilesResponse = {
267
235
  inputs: Array<{
268
236
  [key: string]: unknown;
@@ -414,25 +382,6 @@ export type WorkflowDetail = {
414
382
  yamlContent?: string | null;
415
383
  };
416
384
 
417
- export type RunWorkflowResponse = {
418
- /**
419
- * Newly created execution id (e.g. exec_xyz)
420
- */
421
- executionId: string;
422
- /**
423
- * Final execution status. Only set when the run completed within `wait_for_completion`.
424
- */
425
- status?: ExecutionStatus;
426
- /**
427
- * Workflow output (status=completed)
428
- */
429
- result?: unknown;
430
- /**
431
- * Error message (status=failed)
432
- */
433
- error?: string;
434
- };
435
-
436
385
  export type ListVersionsResponse = {
437
386
  data: Array<WorkflowVersion>;
438
387
  total: number;
@@ -761,69 +710,6 @@ export type AgentsUpdateResponses = {
761
710
 
762
711
  export type AgentsUpdateResponse = AgentsUpdateResponses[keyof AgentsUpdateResponses];
763
712
 
764
- export type AgentsRunData = {
765
- body: RunAgentBody;
766
- path: {
767
- /**
768
- * Agent id or slug
769
- */
770
- agentId: string;
771
- };
772
- query?: {
773
- /**
774
- * Seconds to hold the connection waiting for completion (max 600). Omit for async.
775
- */
776
- wait_for_completion?: number;
777
- /**
778
- * Git source ref to resolve for this run. Defaults to latest. Supports latest, main, exact versions/tags such as 1.2.3, semver ranges such as 1.2.x or 1.x, and exact commit SHAs.
779
- */
780
- sourceRef?: string;
781
- };
782
- url: '/api/v1/agents/{agentId}/run';
783
- };
784
-
785
- export type AgentsRunErrors = {
786
- /**
787
- * Validation error. Request shape did not match the spec.
788
- */
789
- 400: ApiErrorEnvelope;
790
- /**
791
- * Missing or invalid API key
792
- */
793
- 401: ApiErrorEnvelope;
794
- /**
795
- * API key lacks required scope
796
- */
797
- 403: ApiErrorEnvelope;
798
- /**
799
- * Resource not found
800
- */
801
- 404: ApiErrorEnvelope;
802
- /**
803
- * Rate limit exceeded
804
- */
805
- 429: ApiErrorEnvelope;
806
- /**
807
- * Internal server error
808
- */
809
- 500: ApiErrorEnvelope;
810
- };
811
-
812
- export type AgentsRunError = AgentsRunErrors[keyof AgentsRunErrors];
813
-
814
- export type AgentsRunResponses = {
815
- /**
816
- * Execution completed while waiting
817
- */
818
- 200: RunAgentResponse;
819
- /**
820
- * Execution accepted
821
- */
822
- 202: RunAgentResponse;
823
- };
824
-
825
- export type AgentsRunResponse = AgentsRunResponses[keyof AgentsRunResponses];
826
-
827
713
  export type AgentsTriggersEmailDeleteAliasData = {
828
714
  body?: never;
829
715
  path: {
@@ -1374,6 +1260,71 @@ export type AutomationsSyncResponses = {
1374
1260
 
1375
1261
  export type AutomationsSyncResponse = AutomationsSyncResponses[keyof AutomationsSyncResponses];
1376
1262
 
1263
+ export type RunStartWithTargetData = {
1264
+ body: RunTargetInputBody;
1265
+ path: {
1266
+ /**
1267
+ * Automation target without a version suffix.
1268
+ */
1269
+ target: string;
1270
+ };
1271
+ query?: {
1272
+ /**
1273
+ * Optional version or source ref. Defaults to latest.
1274
+ */
1275
+ version?: string;
1276
+ wait_for_completion?: number;
1277
+ };
1278
+ url: '/api/v1/run/{target}';
1279
+ };
1280
+
1281
+ export type RunStartWithTargetErrors = {
1282
+ /**
1283
+ * Validation error. Request shape did not match the spec.
1284
+ */
1285
+ 400: ApiErrorEnvelope;
1286
+ /**
1287
+ * Missing or invalid API key
1288
+ */
1289
+ 401: ApiErrorEnvelope;
1290
+ /**
1291
+ * API key lacks required scope
1292
+ */
1293
+ 403: ApiErrorEnvelope;
1294
+ /**
1295
+ * Resource not found
1296
+ */
1297
+ 404: ApiErrorEnvelope;
1298
+ /**
1299
+ * Rate limit exceeded
1300
+ */
1301
+ 429: ApiErrorEnvelope;
1302
+ /**
1303
+ * Internal server error
1304
+ */
1305
+ 500: ApiErrorEnvelope;
1306
+ };
1307
+
1308
+ export type RunStartWithTargetError = RunStartWithTargetErrors[keyof RunStartWithTargetErrors];
1309
+
1310
+ export type RunStartWithTargetResponses = {
1311
+ /**
1312
+ * Run completed while waiting
1313
+ */
1314
+ 200: RunStartResponse;
1315
+ /**
1316
+ * Workflow run accepted
1317
+ */
1318
+ 201: RunStartResponse;
1319
+ /**
1320
+ * Agent run accepted or wait timed out
1321
+ */
1322
+ 202: RunStartResponse;
1323
+ };
1324
+
1325
+ export type RunStartWithTargetResponse =
1326
+ RunStartWithTargetResponses[keyof RunStartWithTargetResponses];
1327
+
1377
1328
  export type RunsArtifactGetData = {
1378
1329
  body?: never;
1379
1330
  path: {
@@ -2165,7 +2116,9 @@ export type RunsRerunData = {
2165
2116
  path: {
2166
2117
  id: string;
2167
2118
  };
2168
- query?: never;
2119
+ query?: {
2120
+ wait_for_completion?: number;
2121
+ };
2169
2122
  url: '/api/v1/runs/{id}/rerun';
2170
2123
  };
2171
2124
 
@@ -2200,13 +2153,17 @@ export type RunsRerunError = RunsRerunErrors[keyof RunsRerunErrors];
2200
2153
 
2201
2154
  export type RunsRerunResponses = {
2202
2155
  /**
2203
- * Rerun started
2156
+ * Rerun completed while waiting
2204
2157
  */
2205
2158
  200: RunRerunResponse;
2206
2159
  /**
2207
- * Rerun started
2160
+ * Workflow rerun accepted
2208
2161
  */
2209
2162
  201: RunRerunResponse;
2163
+ /**
2164
+ * Agent rerun accepted or wait timed out
2165
+ */
2166
+ 202: RunRerunResponse;
2210
2167
  };
2211
2168
 
2212
2169
  export type RunsRerunResponse = RunsRerunResponses[keyof RunsRerunResponses];
@@ -2764,65 +2721,6 @@ export type WorkflowsGetResponses = {
2764
2721
 
2765
2722
  export type WorkflowsGetResponse = WorkflowsGetResponses[keyof WorkflowsGetResponses];
2766
2723
 
2767
- export type WorkflowsRunData = {
2768
- body: RunWorkflowBody;
2769
- path: {
2770
- /**
2771
- * Workflow id (e.g. `wf_abc123`) or slug (e.g. `extract-invoice`, the workflow `name`).
2772
- */
2773
- id: string;
2774
- };
2775
- query?: {
2776
- /**
2777
- * Version id, or "latest" (default)
2778
- */
2779
- version?: string;
2780
- /**
2781
- * Seconds to hold the connection waiting for completion (max 60). Omit for async.
2782
- */
2783
- wait_for_completion?: number;
2784
- };
2785
- url: '/api/v1/workflows/{id}/run';
2786
- };
2787
-
2788
- export type WorkflowsRunErrors = {
2789
- /**
2790
- * Validation error. Request shape did not match the spec.
2791
- */
2792
- 400: ApiErrorEnvelope;
2793
- /**
2794
- * Missing or invalid API key
2795
- */
2796
- 401: ApiErrorEnvelope;
2797
- /**
2798
- * API key lacks required scope
2799
- */
2800
- 403: ApiErrorEnvelope;
2801
- /**
2802
- * Resource not found
2803
- */
2804
- 404: ApiErrorEnvelope;
2805
- /**
2806
- * Rate limit exceeded
2807
- */
2808
- 429: ApiErrorEnvelope;
2809
- /**
2810
- * Internal server error
2811
- */
2812
- 500: ApiErrorEnvelope;
2813
- };
2814
-
2815
- export type WorkflowsRunError = WorkflowsRunErrors[keyof WorkflowsRunErrors];
2816
-
2817
- export type WorkflowsRunResponses = {
2818
- /**
2819
- * Execution accepted. Body always includes `executionId`. When `wait_for_completion` is set and the execution completes within the window, `status`/`result`/`error` are also returned; otherwise poll `/api/v1/runs/{executionId}` for status.
2820
- */
2821
- 201: RunWorkflowResponse;
2822
- };
2823
-
2824
- export type WorkflowsRunResponse = WorkflowsRunResponses[keyof WorkflowsRunResponses];
2825
-
2826
2724
  export type WorkflowsVersionsListData = {
2827
2725
  body?: never;
2828
2726
  path: {
package/src/index.ts CHANGED
@@ -8,10 +8,13 @@
8
8
  * const client = new EigenpalClient({ apiKey: process.env.EIGENPAL_API_KEY! });
9
9
  *
10
10
  * // Async — enqueue and poll later.
11
- * const { executionId } = await client.workflows.run('wf_abc', { input: { ... } });
11
+ * const { runId } = await client.run('workflows.extract-invoice', {
12
+ * input: { ... },
13
+ * });
12
14
  *
13
15
  * // Sync (server holds the connection up to 60s).
14
- * const result = await client.workflows.run('wf_abc', { input: { ... } }, {
16
+ * const result = await client.run('workflows.extract-invoice', {
17
+ * input: { ... },
15
18
  * waitForCompletion: 60,
16
19
  * });
17
20
  *
@@ -19,7 +22,15 @@
19
22
  * const final = await client.workflows.executions.runAndWait('wf_abc', { input: { ... } });
20
23
  * ```
21
24
  */
22
- export { EigenpalClient, type EigenpalOptions } from './client';
25
+ export {
26
+ EigenpalClient,
27
+ type EigenpalOptions,
28
+ type RerunOptions,
29
+ type RunInput,
30
+ type RunOptions,
31
+ type RunStartResponse,
32
+ type RunTarget,
33
+ } from './client';
23
34
 
24
35
  export {
25
36
  EigenpalAuthError,
@@ -34,20 +45,19 @@ export {
34
45
 
35
46
  export { toFile } from './lib/files';
36
47
  export type { FileDescriptor, FileInput, NodeReadableStream } from './lib/files';
37
- export type { ListAgentsOptions, RunAgentOptions } from './resources/agents';
48
+ export type { ListAgentsOptions } from './resources/agents';
38
49
  export type { ListRunsOptions } from './resources/runs';
39
50
  export type { SourceRawOptions, SourceReleasesOptions } from './resources/source';
40
51
  export type {
41
52
  ListVersionsOptions,
42
53
  ListWorkflowsOptions,
43
- RunWorkflowOptions,
44
54
  WorkflowInput,
45
55
  } from './resources/workflows';
46
56
  // Note: FileReference (by fileId) is intentionally NOT exported. From the
47
57
  // SDK perspective you always upload a file; fileId is an internal wire id
48
58
  // the server creates after upload — not something users construct.
49
59
 
50
- export type { RunAndWaitOptions } from './resources/executions';
60
+ export type { RunAndWaitOptions, WorkflowRunAndWaitResponse } from './resources/executions';
51
61
 
52
62
  // Re-export the canonical generated types so users can type their own
53
63
  // callbacks and helpers without reaching into `./generated`.
@@ -71,10 +81,8 @@ export type {
71
81
  ListVersionsResponse,
72
82
  ListWorkflowsResponse,
73
83
  RawSourceResponse,
74
- RunAgentResponse,
75
84
  RunSummary,
76
- RunWorkflowBody,
77
- RunWorkflowResponse,
85
+ RunTargetInputBody,
78
86
  RunsCancelResponse,
79
87
  RunsExpectedCreateResponse,
80
88
  RunsExpectedFileDeleteResponse,
package/src/lib/files.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * File-input helpers for `client.workflows.run()` (and agent runs).
2
+ * File-input helpers for `client.run()`.
3
3
  *
4
4
  * A workflow input value is treated as a file when it is one of:
5
5
  * - a Node readable stream — `fs.createReadStream('contract.pdf')`
@@ -69,7 +69,7 @@ export type FileInput = Blob | FileDescriptor | NodeReadableStream;
69
69
  * a file path or stream.
70
70
  *
71
71
  * ```ts
72
- * await client.workflows.run('extract-invoice', {
72
+ * await client.run('workflows.extract-invoice', {
73
73
  * contract_document: toFile(buffer, 'contract.pdf'),
74
74
  * });
75
75
  * ```
@@ -188,49 +188,39 @@ async function appendFiles(
188
188
  }
189
189
 
190
190
  /**
191
- * Build a `multipart/form-data` body matching what `processMultipartRunBody`
192
- * on the server expects:
191
+ * JSON-body counterpart of {@link buildRunMultipart}: per-step overrides ride
192
+ * in the reserved `_overrides` body key.
193
+ */
194
+ export function buildRunJsonBody(
195
+ input: Record<string, unknown> | undefined,
196
+ overrides?: { steps?: Record<string, Record<string, unknown>> }
197
+ ): Record<string, unknown> {
198
+ return overrides ? { ...(input ?? {}), _overrides: overrides } : (input ?? {});
199
+ }
200
+
201
+ /**
202
+ * Build multipart for the canonical `client.run(...)` endpoint
203
+ * (`POST /api/v1/run/{target}`):
193
204
  *
194
- * - Each file in `input` becomes a top-level form field (key = input name).
195
- * - Non-file inputs + overrides + trigger go in a `_json` text field.
205
+ * - Each top-level file in `input` becomes a form field (key = input name).
206
+ * - Non-file inputs go in the `_json` text field (the input object itself).
207
+ * - Per-step overrides go in the reserved `_overrides` text field.
196
208
  *
197
209
  * Async because stream inputs are drained to bytes here. Only top-level file
198
210
  * values are extracted — files nested inside arrays / objects keep their
199
211
  * position in the JSON sidecar (the server has no nested-upload path).
200
212
  */
201
- export async function buildMultipart(args: {
213
+ export async function buildRunMultipart(args: {
202
214
  input?: Record<string, unknown>;
203
215
  overrides?: { steps?: Record<string, Record<string, unknown>> };
204
- trigger?: 'api' | 'cli';
205
216
  }): Promise<MultipartParts> {
206
217
  const fd = new FormData();
207
218
  const { scalars, fileCount } = await appendFiles(fd, args.input);
208
-
209
- const sidecar: Record<string, unknown> = {};
210
- if (Object.keys(scalars).length > 0) sidecar.input = scalars;
211
- if (args.overrides) sidecar.overrides = args.overrides;
212
- if (args.trigger) sidecar.trigger = args.trigger;
213
- if (Object.keys(sidecar).length > 0) {
214
- fd.append('_json', JSON.stringify(sidecar));
215
- }
216
-
217
- return { formData: fd, fileCount };
218
- }
219
-
220
- /**
221
- * Build multipart for agent runs. Agent run endpoints consume `_json` as the
222
- * input object itself, unlike workflow runs where `_json` is a sidecar with
223
- * `{ input, overrides, trigger }`.
224
- */
225
- export async function buildAgentMultipart(
226
- input?: Record<string, unknown>
227
- ): Promise<MultipartParts> {
228
- const fd = new FormData();
229
- const { scalars, fileCount } = await appendFiles(fd, input);
230
-
231
219
  if (Object.keys(scalars).length > 0) {
232
220
  fd.append('_json', JSON.stringify(scalars));
233
221
  }
234
-
222
+ if (args.overrides) {
223
+ fd.append('_overrides', JSON.stringify(args.overrides));
224
+ }
235
225
  return { formData: fd, fileCount };
236
226
  }
@@ -7,7 +7,6 @@ import {
7
7
  agentsFilesUploadBatch,
8
8
  agentsGet,
9
9
  agentsList,
10
- agentsRun,
11
10
  agentsTriggersEmailCreateAlias,
12
11
  agentsTriggersEmailDeleteAlias,
13
12
  agentsTriggersEmailGet,
@@ -34,10 +33,7 @@ import type {
34
33
  ListAgentsResponse,
35
34
  PatchAgentBody,
36
35
  PatchAgentResponse,
37
- RunAgentResponse,
38
36
  } from '../generated/types.gen';
39
- import { buildAgentMultipart, hasFileInput } from '../lib/files';
40
- import type { WorkflowInput } from './workflows';
41
37
 
42
38
  type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
43
39
 
@@ -48,12 +44,6 @@ export interface ListAgentsOptions {
48
44
  signal?: AbortSignal;
49
45
  }
50
46
 
51
- export interface RunAgentOptions {
52
- waitForCompletion?: number;
53
- sourceRef?: string;
54
- signal?: AbortSignal;
55
- }
56
-
57
47
  export class AgentEmailTriggersResource {
58
48
  constructor(
59
49
  private readonly client: Client,
@@ -228,46 +218,4 @@ export class AgentsResource {
228
218
  agentsUpdate({ client: this.client, path: { agentId }, body, signal: options.signal })
229
219
  );
230
220
  }
231
-
232
- async run(
233
- agentId: string,
234
- input?: WorkflowInput,
235
- options: RunAgentOptions = {}
236
- ): Promise<RunAgentResponse> {
237
- const query = {
238
- ...(options.waitForCompletion !== undefined
239
- ? { wait_for_completion: options.waitForCompletion }
240
- : {}),
241
- ...(options.sourceRef !== undefined ? { sourceRef: options.sourceRef } : {}),
242
- };
243
-
244
- if (hasFileInput(input)) {
245
- const { formData } = await buildAgentMultipart(input);
246
- return this.dispatch<RunAgentResponse>(
247
- () =>
248
- this.client.post({
249
- url: '/api/v1/agents/{agentId}/run',
250
- path: { agentId },
251
- query,
252
- body: formData,
253
- bodySerializer: null,
254
- headers: { 'Content-Type': null },
255
- signal: options.signal,
256
- }) as Promise<OperationResult<RunAgentResponse>>
257
- );
258
- }
259
-
260
- return this.dispatch(() =>
261
- agentsRun({
262
- client: this.client,
263
- path: { agentId },
264
- query,
265
- body: {
266
- ...(input !== undefined ? { input } : {}),
267
- ...(options.sourceRef !== undefined ? { sourceRef: options.sourceRef } : {}),
268
- },
269
- signal: options.signal,
270
- })
271
- );
272
- }
273
221
  }