@eigenpal/sdk 0.7.1 → 0.8.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,37 @@ 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
+ RunsFeedbackGetResponse,
87
72
  RunsFeedbackUpdateResponse,
88
73
  RunsGetResponse,
89
74
  RunsListResponse,
90
75
  RunsRerunResponse,
91
- SourceLockfileResponse,
92
- SourceReleasesResponse,
93
- SourceRepositoryResponse,
94
- SourceSecretsDecryptBody,
95
- SourceSecretsDecryptResponse,
96
- SourceSecretsEncryptBody,
97
- SourceSecretsEncryptResponse,
98
- WorkflowDetail,
99
- WorkflowSummary,
100
- WorkflowVersion,
76
+ RunsTraceGetResponse,
101
77
  } from './generated/types.gen';
@@ -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,299 @@
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
+ automationsExperimentsGet,
17
+ automationsExperimentsList,
18
+ automationsGet,
19
+ automationsList,
20
+ automationsTriggersGet,
21
+ automationsVersionsList,
22
+ } from '../generated/sdk.gen';
5
23
 
6
24
  type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
25
+ type SignalOptions = { signal?: AbortSignal };
26
+ type AnyResponse = any;
7
27
 
8
28
  export class AutomationsResource {
29
+ public readonly dataset: AutomationDatasetResource;
30
+ public readonly examples: AutomationExamplesResource;
31
+ public readonly evaluators: AutomationEvaluatorsResource;
32
+ public readonly experiments: AutomationExperimentsResource;
33
+
34
+ constructor(
35
+ private readonly client: Client,
36
+ private readonly dispatch: Dispatch
37
+ ) {
38
+ this.dataset = new AutomationDatasetResource(client, dispatch);
39
+ this.examples = new AutomationExamplesResource(client, dispatch);
40
+ this.evaluators = new AutomationEvaluatorsResource(client, dispatch);
41
+ this.experiments = new AutomationExperimentsResource(client, dispatch);
42
+ }
43
+
44
+ async list(
45
+ options: {
46
+ search?: string;
47
+ type?: 'workflow' | 'agent';
48
+ limit?: number;
49
+ offset?: number;
50
+ signal?: AbortSignal;
51
+ } = {}
52
+ ): Promise<AnyResponse> {
53
+ const { signal, ...query } = options;
54
+ return this.dispatch(() => automationsList({ client: this.client, query, signal }));
55
+ }
56
+
57
+ async get(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
58
+ return this.dispatch(() =>
59
+ automationsGet({ client: this.client, path: { id }, signal: options.signal })
60
+ );
61
+ }
62
+
63
+ async versions(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
64
+ return this.dispatch(() =>
65
+ automationsVersionsList({ client: this.client, path: { id }, signal: options.signal })
66
+ );
67
+ }
68
+
69
+ async triggers(id: string, options: SignalOptions = {}): Promise<AnyResponse> {
70
+ return this.dispatch(() =>
71
+ automationsTriggersGet({ client: this.client, path: { id }, signal: options.signal })
72
+ );
73
+ }
74
+ }
75
+
76
+ export class AutomationDatasetResource {
77
+ constructor(
78
+ private readonly client: Client,
79
+ private readonly dispatch: Dispatch
80
+ ) {}
81
+
82
+ async export(
83
+ automationId: string,
84
+ options: { exampleIds?: string[]; signal?: AbortSignal } = {}
85
+ ): Promise<Blob> {
86
+ const query = options.exampleIds?.length ? { exampleIds: options.exampleIds.join(',') } : {};
87
+ return this.dispatch(
88
+ () =>
89
+ automationsDatasetExport({
90
+ client: this.client,
91
+ path: { id: automationId },
92
+ query,
93
+ signal: options.signal,
94
+ }) as Promise<OperationResult<Blob>>
95
+ );
96
+ }
97
+
98
+ async import(
99
+ automationId: string,
100
+ file: Blob | File,
101
+ options: { mode?: 'append' | 'replace'; signal?: AbortSignal } = {}
102
+ ): Promise<AnyResponse> {
103
+ const formData = new FormData();
104
+ formData.set('file', file);
105
+ formData.set('mode', options.mode ?? 'append');
106
+ return this.dispatch(() =>
107
+ automationsDatasetImport({
108
+ client: this.client,
109
+ path: { id: automationId },
110
+ body: formData as never,
111
+ bodySerializer: null,
112
+ headers: { 'Content-Type': null },
113
+ signal: options.signal,
114
+ })
115
+ );
116
+ }
117
+ }
118
+
119
+ export class AutomationExamplesResource {
120
+ constructor(
121
+ private readonly client: Client,
122
+ private readonly dispatch: Dispatch
123
+ ) {}
124
+
125
+ async list(
126
+ automationId: string,
127
+ options: { limit?: number; offset?: number; signal?: AbortSignal } = {}
128
+ ): Promise<AnyResponse> {
129
+ const { signal, ...query } = options;
130
+ return this.dispatch(() =>
131
+ automationsExamplesList({ client: this.client, path: { id: automationId }, query, signal })
132
+ );
133
+ }
134
+
135
+ async create(
136
+ automationId: string,
137
+ body: Record<string, unknown>,
138
+ options: SignalOptions = {}
139
+ ): Promise<AnyResponse> {
140
+ return this.dispatch(() =>
141
+ automationsExamplesCreate({
142
+ client: this.client,
143
+ path: { id: automationId },
144
+ body: body as never,
145
+ signal: options.signal,
146
+ })
147
+ );
148
+ }
149
+
150
+ async get(
151
+ automationId: string,
152
+ exampleId: string,
153
+ options: SignalOptions = {}
154
+ ): Promise<AnyResponse> {
155
+ return this.dispatch(() =>
156
+ automationsExamplesGet({
157
+ client: this.client,
158
+ path: { id: automationId, exampleId },
159
+ signal: options.signal,
160
+ })
161
+ );
162
+ }
163
+
164
+ async update(
165
+ automationId: string,
166
+ exampleId: string,
167
+ body: Record<string, unknown>,
168
+ options: SignalOptions = {}
169
+ ): Promise<AnyResponse> {
170
+ return this.dispatch(() =>
171
+ automationsExamplesUpdate({
172
+ client: this.client,
173
+ path: { id: automationId, exampleId },
174
+ body: body as never,
175
+ signal: options.signal,
176
+ })
177
+ );
178
+ }
179
+
180
+ async delete(
181
+ automationId: string,
182
+ exampleId: string,
183
+ options: SignalOptions = {}
184
+ ): Promise<AnyResponse> {
185
+ return this.dispatch(() =>
186
+ automationsExamplesDelete({
187
+ client: this.client,
188
+ path: { id: automationId, exampleId },
189
+ signal: options.signal,
190
+ })
191
+ );
192
+ }
193
+
194
+ async run(
195
+ automationId: string,
196
+ exampleId: string,
197
+ options: SignalOptions = {}
198
+ ): Promise<AnyResponse> {
199
+ return this.dispatch(() =>
200
+ automationsExamplesRun({
201
+ client: this.client,
202
+ path: { id: automationId, exampleId },
203
+ signal: options.signal,
204
+ })
205
+ );
206
+ }
207
+ }
208
+
209
+ export class AutomationEvaluatorsResource {
9
210
  constructor(
10
211
  private readonly client: Client,
11
212
  private readonly dispatch: Dispatch
12
213
  ) {}
13
214
 
14
- async sync(
15
- automation: string,
16
- options: { signal?: AbortSignal } = {}
17
- ): Promise<AutomationSyncResponse> {
215
+ async get(automationId: string, options: SignalOptions = {}): Promise<AnyResponse> {
216
+ return this.dispatch(() =>
217
+ automationsEvaluatorsGet({
218
+ client: this.client,
219
+ path: { id: automationId },
220
+ signal: options.signal,
221
+ })
222
+ );
223
+ }
224
+
225
+ async update(
226
+ automationId: string,
227
+ yaml: string,
228
+ options: SignalOptions = {}
229
+ ): Promise<AnyResponse> {
230
+ return this.dispatch(() =>
231
+ automationsEvaluatorsUpdate({
232
+ client: this.client,
233
+ path: { id: automationId },
234
+ body: { yaml },
235
+ signal: options.signal,
236
+ })
237
+ );
238
+ }
239
+ }
240
+
241
+ export class AutomationExperimentsResource {
242
+ constructor(
243
+ private readonly client: Client,
244
+ private readonly dispatch: Dispatch
245
+ ) {}
246
+
247
+ async list(
248
+ automationId: string,
249
+ options: { limit?: number; offset?: number; signal?: AbortSignal } = {}
250
+ ): Promise<AnyResponse> {
251
+ const { signal, ...query } = options;
252
+ return this.dispatch(() =>
253
+ automationsExperimentsList({ client: this.client, path: { id: automationId }, query, signal })
254
+ );
255
+ }
256
+
257
+ async create(
258
+ automationId: string,
259
+ body: Record<string, unknown> = {},
260
+ options: SignalOptions = {}
261
+ ): Promise<AnyResponse> {
262
+ return this.dispatch(() =>
263
+ automationsExperimentsCreate({
264
+ client: this.client,
265
+ path: { id: automationId },
266
+ body: body as never,
267
+ signal: options.signal,
268
+ })
269
+ );
270
+ }
271
+
272
+ async get(
273
+ automationId: string,
274
+ experimentId: string,
275
+ options: SignalOptions = {}
276
+ ): Promise<AnyResponse> {
277
+ return this.dispatch(() =>
278
+ automationsExperimentsGet({
279
+ client: this.client,
280
+ path: { id: automationId, experimentId },
281
+ signal: options.signal,
282
+ })
283
+ );
284
+ }
285
+
286
+ async cancel(
287
+ automationId: string,
288
+ experimentId: string,
289
+ options: SignalOptions = {}
290
+ ): Promise<AnyResponse> {
18
291
  return this.dispatch(() =>
19
- automationsSync({ client: this.client, path: { automation }, signal: options.signal })
292
+ automationsExperimentsCancel({
293
+ client: this.client,
294
+ path: { id: automationId, experimentId },
295
+ signal: options.signal,
296
+ })
20
297
  );
21
298
  }
22
299
  }
@@ -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
+ }