@eigenpal/sdk 0.7.2 → 0.9.0

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/src/index.ts CHANGED
@@ -13,12 +13,13 @@
13
13
  * // Sync (server holds the connection up to 60s).
14
14
  * const result = await client.run('workflows.extract-invoice', { ... }, { waitForCompletion: 60 });
15
15
  *
16
- * // Client-side poll (up to 5min by default).
17
- * const final = await client.workflows.executions.runAndWait('wf_abc', { ... });
16
+ * // Inspect or manage runs later.
17
+ * const final = await client.runs.get(id);
18
18
  * ```
19
19
  */
20
20
  export {
21
21
  EigenpalClient,
22
+ isRunFinished,
22
23
  type EigenpalOptions,
23
24
  type RerunOptions,
24
25
  type RunCallOptions,
@@ -40,62 +41,41 @@ export {
40
41
 
41
42
  export { toFile } from './lib/files';
42
43
  export type { FileDescriptor, FileInput, NodeReadableStream } from './lib/files';
43
- export type { ListAgentsOptions } from './resources/agents';
44
44
  export type { ListRunsOptions, RunExpand, RunExpandSection } from './resources/runs';
45
- export type { SourceRawOptions, SourceReleasesOptions } from './resources/source';
46
- export type {
47
- ListVersionsOptions,
48
- ListWorkflowsOptions,
49
- WorkflowInput,
50
- } from './resources/workflows';
51
- // Note: FileReference (by fileId) is intentionally NOT exported. From the
52
- // SDK perspective you always upload a file; fileId is an internal wire id
53
- // the server creates after upload — not something users construct.
54
-
55
- export type { RunAndWaitOptions, WorkflowRunAndWaitResponse } from './resources/executions';
56
45
 
57
46
  // Re-export the canonical generated types so users can type their own
58
47
  // callbacks and helpers without reaching into `./generated`.
59
48
  export type {
60
- AgentSummary,
61
- AgentsTriggersEmailCreateAliasData,
62
- AgentsTriggersEmailCreateAliasResponse,
63
- AgentsTriggersEmailDeleteAliasResponse,
64
- AgentsTriggersEmailGetResponse,
65
- AgentsTriggersEmailListResponse,
66
- AgentsTriggersEmailUpdateAliasData,
67
- AgentsTriggersEmailUpdateAliasResponse,
68
- AgentsTriggersEmailUpdateData,
69
- AgentsTriggersEmailUpdateResponse,
70
49
  ApiErrorEnvelope,
71
50
  ApiErrorIssue,
72
- AutomationSyncResponse,
51
+ AuthCheckResponse,
52
+ AutomationDetail,
53
+ AutomationSummary,
54
+ AutomationTriggerState,
55
+ AutomationTriggersResponse,
56
+ AutomationVersion,
73
57
  ExecutionStatus,
74
- GetAgentResponse,
75
- ListAgentsResponse,
76
- ListVersionsResponse,
77
- ListWorkflowsResponse,
78
- RawSourceResponse,
58
+ File,
59
+ Run,
60
+ RunArtifact,
61
+ RunArtifactsResponse,
62
+ RunEvent,
63
+ RunEventsResponse,
79
64
  RunListItem,
80
65
  RunStartBody,
66
+ RunStepsResponse,
67
+ RunUsage,
68
+ RunUsageResponse,
81
69
  RunsCancelResponse,
82
- RunsExpectedCreateResponse,
83
- RunsExpectedFileDeleteResponse,
84
- RunsExpectedFileUpdateResponse,
85
- RunsExpectedGetResponse,
86
70
  RunsFeedbackClearResponse,
71
+ RunsFeedbackExpectedCreateResponse,
72
+ RunsFeedbackExpectedFileDeleteResponse,
73
+ RunsFeedbackExpectedFileUpdateResponse,
74
+ RunsFeedbackExpectedGetResponse,
75
+ RunsFeedbackGetResponse,
87
76
  RunsFeedbackUpdateResponse,
88
77
  RunsGetResponse,
89
78
  RunsListResponse,
90
79
  RunsRerunResponse,
91
- SourceLockfileResponse,
92
- SourceReleasesResponse,
93
- SourceRepositoryResponse,
94
- SourceSecretsDecryptBody,
95
- SourceSecretsDecryptResponse,
96
- SourceSecretsEncryptBody,
97
- SourceSecretsEncryptResponse,
98
- WorkflowDetail,
99
- WorkflowSummary,
100
- WorkflowVersion,
80
+ RunsTraceGetResponse,
101
81
  } from './generated/types.gen';
package/src/lib/files.ts CHANGED
@@ -237,3 +237,12 @@ export async function buildRunMultipart(args: {
237
237
  }
238
238
  return { formData: fd, fileCount };
239
239
  }
240
+
241
+ /** Build multipart for endpoints that accept one file field plus optional name. */
242
+ export async function buildSingleFileMultipart(file: FileInput, name?: string): Promise<FormData> {
243
+ const fd = new FormData();
244
+ const { blob, filename } = await resolveFileBlob(file);
245
+ fd.append('file', blob, filename);
246
+ if (name) fd.append('name', name);
247
+ return fd;
248
+ }
@@ -0,0 +1,18 @@
1
+ import type { OperationResult } from '../client';
2
+ import type { Client } from '../generated/client';
3
+ import { authCheck } from '../generated/sdk.gen';
4
+ import type { AuthCheckResponse } from '../generated/types.gen';
5
+
6
+ type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
7
+ type SignalOptions = { signal?: AbortSignal };
8
+
9
+ export class AuthResource {
10
+ constructor(
11
+ private readonly client: Client,
12
+ private readonly dispatch: Dispatch
13
+ ) {}
14
+
15
+ async check(options: SignalOptions = {}): Promise<AuthCheckResponse> {
16
+ return this.dispatch(() => authCheck({ client: this.client, signal: options.signal }));
17
+ }
18
+ }
@@ -1,22 +1,357 @@
1
1
  import type { OperationResult } from '../client';
2
2
  import type { Client } from '../generated/client';
3
- import { automationsSync } from '../generated/sdk.gen';
4
- import type { AutomationSyncResponse } from '../generated/types.gen';
3
+ import {
4
+ automationsDatasetExport,
5
+ automationsDatasetImport,
6
+ automationsEvaluatorsGet,
7
+ automationsEvaluatorsUpdate,
8
+ automationsExamplesCreate,
9
+ automationsExamplesDelete,
10
+ automationsExamplesGet,
11
+ automationsExamplesList,
12
+ automationsExamplesRun,
13
+ automationsExamplesUpdate,
14
+ automationsExperimentsCancel,
15
+ automationsExperimentsCreate,
16
+ automationsExperimentsCreateStream,
17
+ automationsExperimentsExport,
18
+ automationsExperimentsExportAll,
19
+ automationsExperimentsGet,
20
+ automationsExperimentsList,
21
+ automationsGet,
22
+ automationsList,
23
+ automationsSync,
24
+ automationsTriggersGet,
25
+ automationsVersionsList,
26
+ } from '../generated/sdk.gen';
5
27
 
6
28
  type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
29
+ type SignalOptions = { signal?: AbortSignal };
30
+ type AnyResponse = any;
7
31
 
8
32
  export class AutomationsResource {
33
+ public readonly dataset: AutomationDatasetResource;
34
+ public readonly examples: AutomationExamplesResource;
35
+ public readonly evaluators: AutomationEvaluatorsResource;
36
+ public readonly experiments: AutomationExperimentsResource;
37
+
38
+ constructor(
39
+ private readonly client: Client,
40
+ private readonly dispatch: Dispatch
41
+ ) {
42
+ this.dataset = new AutomationDatasetResource(client, dispatch);
43
+ this.examples = new AutomationExamplesResource(client, dispatch);
44
+ this.evaluators = new AutomationEvaluatorsResource(client, dispatch);
45
+ this.experiments = new AutomationExperimentsResource(client, dispatch);
46
+ }
47
+
48
+ async list(
49
+ options: {
50
+ search?: string;
51
+ type?: 'workflow' | 'agent';
52
+ limit?: number;
53
+ offset?: number;
54
+ signal?: AbortSignal;
55
+ } = {}
56
+ ): Promise<AnyResponse> {
57
+ const { signal, ...query } = options;
58
+ return this.dispatch(() => automationsList({ client: this.client, query, signal }));
59
+ }
60
+
61
+ async get(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
62
+ return this.dispatch(() =>
63
+ automationsGet({ client: this.client, path: { id }, signal: options.signal })
64
+ );
65
+ }
66
+
67
+ async versions(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
68
+ return this.dispatch(() =>
69
+ automationsVersionsList({ client: this.client, path: { id }, signal: options.signal })
70
+ );
71
+ }
72
+
73
+ async triggers(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
74
+ return this.dispatch(() =>
75
+ automationsTriggersGet({ client: this.client, path: { id }, signal: options.signal })
76
+ );
77
+ }
78
+
79
+ async sync(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
80
+ return this.dispatch(() =>
81
+ automationsSync({ client: this.client, path: { id }, signal: options.signal })
82
+ );
83
+ }
84
+ }
85
+
86
+ export class AutomationDatasetResource {
9
87
  constructor(
10
88
  private readonly client: Client,
11
89
  private readonly dispatch: Dispatch
12
90
  ) {}
13
91
 
14
- async sync(
15
- automation: string,
16
- options: { signal?: AbortSignal } = {}
17
- ): Promise<AutomationSyncResponse> {
92
+ async export(
93
+ automationId: string,
94
+ options: { exampleIds?: string[]; signal?: AbortSignal } = {}
95
+ ): Promise<Blob> {
96
+ const query = options.exampleIds?.length ? { exampleIds: options.exampleIds.join(',') } : {};
97
+ return this.dispatch(
98
+ () =>
99
+ automationsDatasetExport({
100
+ client: this.client,
101
+ path: { id: automationId },
102
+ query,
103
+ signal: options.signal,
104
+ }) as Promise<OperationResult<Blob>>
105
+ );
106
+ }
107
+
108
+ async import(
109
+ automationId: string,
110
+ file: Blob | File,
111
+ options: { mode?: 'append' | 'replace'; signal?: AbortSignal } = {}
112
+ ): Promise<AnyResponse> {
113
+ const formData = new FormData();
114
+ formData.set('file', file);
115
+ formData.set('mode', options.mode ?? 'append');
116
+ return this.dispatch(() =>
117
+ automationsDatasetImport({
118
+ client: this.client,
119
+ path: { id: automationId },
120
+ body: formData as never,
121
+ bodySerializer: null,
122
+ headers: { 'Content-Type': null },
123
+ signal: options.signal,
124
+ })
125
+ );
126
+ }
127
+ }
128
+
129
+ export class AutomationExamplesResource {
130
+ constructor(
131
+ private readonly client: Client,
132
+ private readonly dispatch: Dispatch
133
+ ) {}
134
+
135
+ async list(
136
+ automationId: string,
137
+ options: { limit?: number; offset?: number; signal?: AbortSignal } = {}
138
+ ): Promise<AnyResponse> {
139
+ const { signal, ...query } = options;
140
+ return this.dispatch(() =>
141
+ automationsExamplesList({ client: this.client, path: { id: automationId }, query, signal })
142
+ );
143
+ }
144
+
145
+ async create(
146
+ automationId: string,
147
+ body: Record<string, unknown>,
148
+ options: SignalOptions = {}
149
+ ): Promise<AnyResponse> {
18
150
  return this.dispatch(() =>
19
- automationsSync({ client: this.client, path: { automation }, signal: options.signal })
151
+ automationsExamplesCreate({
152
+ client: this.client,
153
+ path: { id: automationId },
154
+ body: body as never,
155
+ signal: options.signal,
156
+ })
157
+ );
158
+ }
159
+
160
+ async get(
161
+ automationId: string,
162
+ exampleId: string,
163
+ options: SignalOptions = {}
164
+ ): Promise<AnyResponse> {
165
+ return this.dispatch(() =>
166
+ automationsExamplesGet({
167
+ client: this.client,
168
+ path: { id: automationId, exampleId },
169
+ signal: options.signal,
170
+ })
171
+ );
172
+ }
173
+
174
+ async update(
175
+ automationId: string,
176
+ exampleId: string,
177
+ body: Record<string, unknown>,
178
+ options: SignalOptions = {}
179
+ ): Promise<AnyResponse> {
180
+ return this.dispatch(() =>
181
+ automationsExamplesUpdate({
182
+ client: this.client,
183
+ path: { id: automationId, exampleId },
184
+ body: body as never,
185
+ signal: options.signal,
186
+ })
187
+ );
188
+ }
189
+
190
+ async delete(
191
+ automationId: string,
192
+ exampleId: string,
193
+ options: SignalOptions = {}
194
+ ): Promise<AnyResponse> {
195
+ return this.dispatch(() =>
196
+ automationsExamplesDelete({
197
+ client: this.client,
198
+ path: { id: automationId, exampleId },
199
+ signal: options.signal,
200
+ })
201
+ );
202
+ }
203
+
204
+ async run(
205
+ automationId: string,
206
+ exampleId: string,
207
+ options: SignalOptions = {}
208
+ ): Promise<AnyResponse> {
209
+ return this.dispatch(() =>
210
+ automationsExamplesRun({
211
+ client: this.client,
212
+ path: { id: automationId, exampleId },
213
+ signal: options.signal,
214
+ })
215
+ );
216
+ }
217
+ }
218
+
219
+ export class AutomationEvaluatorsResource {
220
+ constructor(
221
+ private readonly client: Client,
222
+ private readonly dispatch: Dispatch
223
+ ) {}
224
+
225
+ async get(automationId: string, options: SignalOptions = {}): Promise<AnyResponse> {
226
+ return this.dispatch(() =>
227
+ automationsEvaluatorsGet({
228
+ client: this.client,
229
+ path: { id: automationId },
230
+ signal: options.signal,
231
+ })
232
+ );
233
+ }
234
+
235
+ async update(
236
+ automationId: string,
237
+ yaml: string,
238
+ options: SignalOptions = {}
239
+ ): Promise<AnyResponse> {
240
+ return this.dispatch(() =>
241
+ automationsEvaluatorsUpdate({
242
+ client: this.client,
243
+ path: { id: automationId },
244
+ body: { yaml },
245
+ signal: options.signal,
246
+ })
247
+ );
248
+ }
249
+ }
250
+
251
+ export class AutomationExperimentsResource {
252
+ constructor(
253
+ private readonly client: Client,
254
+ private readonly dispatch: Dispatch
255
+ ) {}
256
+
257
+ async list(
258
+ automationId: string,
259
+ options: { limit?: number; offset?: number; signal?: AbortSignal } = {}
260
+ ): Promise<AnyResponse> {
261
+ const { signal, ...query } = options;
262
+ return this.dispatch(() =>
263
+ automationsExperimentsList({ client: this.client, path: { id: automationId }, query, signal })
264
+ );
265
+ }
266
+
267
+ async create(
268
+ automationId: string,
269
+ body: Record<string, unknown> = {},
270
+ options: SignalOptions = {}
271
+ ): Promise<AnyResponse> {
272
+ return this.dispatch(() =>
273
+ automationsExperimentsCreate({
274
+ client: this.client,
275
+ path: { id: automationId },
276
+ body: body as never,
277
+ signal: options.signal,
278
+ })
279
+ );
280
+ }
281
+
282
+ async get(
283
+ automationId: string,
284
+ experimentId: string,
285
+ options: SignalOptions = {}
286
+ ): Promise<AnyResponse> {
287
+ return this.dispatch(() =>
288
+ automationsExperimentsGet({
289
+ client: this.client,
290
+ path: { id: automationId, experimentId },
291
+ signal: options.signal,
292
+ })
293
+ );
294
+ }
295
+
296
+ async cancel(
297
+ automationId: string,
298
+ experimentId: string,
299
+ options: SignalOptions = {}
300
+ ): Promise<AnyResponse> {
301
+ return this.dispatch(() =>
302
+ automationsExperimentsCancel({
303
+ client: this.client,
304
+ path: { id: automationId, experimentId },
305
+ signal: options.signal,
306
+ })
307
+ );
308
+ }
309
+
310
+ async export(
311
+ automationId: string,
312
+ experimentId: string,
313
+ options: { format?: 'csv' | 'json'; signal?: AbortSignal } = {}
314
+ ): Promise<string> {
315
+ return this.dispatch(() =>
316
+ automationsExperimentsExport({
317
+ client: this.client,
318
+ path: { id: automationId, experimentId },
319
+ query: { format: options.format ?? 'csv' },
320
+ parseAs: 'text',
321
+ signal: options.signal,
322
+ })
323
+ );
324
+ }
325
+
326
+ async exportAll(
327
+ automationId: string,
328
+ options: { format?: 'csv' | 'json'; signal?: AbortSignal } = {}
329
+ ): Promise<string> {
330
+ return this.dispatch(() =>
331
+ automationsExperimentsExportAll({
332
+ client: this.client,
333
+ path: { id: automationId },
334
+ query: { format: options.format ?? 'csv' },
335
+ parseAs: 'text',
336
+ signal: options.signal,
337
+ })
338
+ );
339
+ }
340
+
341
+ async createStream(
342
+ automationId: string,
343
+ body: Record<string, unknown> = {},
344
+ options: SignalOptions = {}
345
+ ): Promise<ReadableStream<Uint8Array> | null> {
346
+ return this.dispatch(
347
+ () =>
348
+ automationsExperimentsCreateStream({
349
+ client: this.client,
350
+ path: { id: automationId },
351
+ body: body as never,
352
+ parseAs: 'stream',
353
+ signal: options.signal,
354
+ }) as Promise<OperationResult<ReadableStream<Uint8Array> | null>>
20
355
  );
21
356
  }
22
357
  }
@@ -0,0 +1,51 @@
1
+ import type { OperationResult } from '../client';
2
+ import type { Client } from '../generated/client';
3
+ import { filesContentGet, filesCreate, filesDelete, filesGet } from '../generated/sdk.gen';
4
+
5
+ type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
6
+ type AnyResponse = any;
7
+ type SignalOptions = { signal?: AbortSignal };
8
+
9
+ export class FilesResource {
10
+ constructor(
11
+ private readonly client: Client,
12
+ private readonly dispatch: Dispatch
13
+ ) {}
14
+
15
+ async upload(file: Blob | File, options: SignalOptions = {}): Promise<AnyResponse> {
16
+ const form = new FormData();
17
+ form.append('file', file);
18
+ return this.dispatch(() =>
19
+ filesCreate({
20
+ client: this.client,
21
+ body: form as never,
22
+ bodySerializer: null,
23
+ headers: { 'Content-Type': null },
24
+ signal: options.signal,
25
+ })
26
+ );
27
+ }
28
+
29
+ async get(fileId: string, options: SignalOptions = {}): Promise<AnyResponse> {
30
+ return this.dispatch(() =>
31
+ filesGet({ client: this.client, path: { id: fileId }, signal: options.signal })
32
+ );
33
+ }
34
+
35
+ async download(fileId: string, options: SignalOptions = {}): Promise<Blob> {
36
+ return this.dispatch(async () => {
37
+ const response = await filesContentGet({
38
+ client: this.client,
39
+ path: { id: fileId },
40
+ signal: options.signal,
41
+ });
42
+ return response as OperationResult<Blob>;
43
+ });
44
+ }
45
+
46
+ async delete(fileId: string, options: SignalOptions = {}): Promise<AnyResponse> {
47
+ return this.dispatch(() =>
48
+ filesDelete({ client: this.client, path: { id: fileId }, signal: options.signal })
49
+ );
50
+ }
51
+ }