@eigenpal/sdk 0.6.8 → 0.6.10

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
@@ -34,12 +34,8 @@ export {
34
34
 
35
35
  export { toFile } from './lib/files';
36
36
  export type { FileDescriptor, FileInput, NodeReadableStream } from './lib/files';
37
- export type {
38
- AgentExecutionFileKind,
39
- ListAgentRunsOptions,
40
- ListAgentsOptions,
41
- RunAgentOptions,
42
- } from './resources/agents';
37
+ export type { ListAgentsOptions, RunAgentOptions } from './resources/agents';
38
+ export type { ListRunsOptions } from './resources/runs';
43
39
  export type { SourceRawOptions, SourceReleasesOptions } from './resources/source';
44
40
  export type {
45
41
  ListVersionsOptions,
@@ -51,16 +47,11 @@ export type {
51
47
  // SDK perspective you always upload a file; fileId is an internal wire id
52
48
  // the server creates after upload — not something users construct.
53
49
 
54
- export type { ListExecutionsOptions, RunAndWaitOptions } from './resources/executions';
50
+ export type { RunAndWaitOptions } from './resources/executions';
55
51
 
56
52
  // Re-export the canonical generated types so users can type their own
57
53
  // callbacks and helpers without reaching into `./generated`.
58
54
  export type {
59
- AgentExecutionExpectedArtifacts,
60
- AgentExecutionFeedback,
61
- AgentExecutionFeedbackDetail,
62
- AgentExecutionSummary,
63
- AgentRunResponse,
64
55
  AgentSummary,
65
56
  AgentsTriggersEmailCreateAliasData,
66
57
  AgentsTriggersEmailCreateAliasResponse,
@@ -74,20 +65,27 @@ export type {
74
65
  ApiErrorEnvelope,
75
66
  ApiErrorIssue,
76
67
  AutomationSyncResponse,
77
- CancelAgentExecutionResponse,
78
- CancelWorkflowExecutionResponse,
79
68
  ExecutionStatus,
80
- ExecutionSummary,
81
69
  GetAgentResponse,
82
- ListAgentRunsResponse,
83
70
  ListAgentsResponse,
84
71
  ListVersionsResponse,
85
- ListWorkflowExecutionsResponse,
86
72
  ListWorkflowsResponse,
87
73
  RawSourceResponse,
88
74
  RunAgentResponse,
75
+ RunSummary,
89
76
  RunWorkflowBody,
90
77
  RunWorkflowResponse,
78
+ RunsCancelResponse,
79
+ RunsExpectedCreateResponse,
80
+ RunsExpectedFileDeleteResponse,
81
+ RunsExpectedFileUpdateResponse,
82
+ RunsExpectedGetResponse,
83
+ RunsFeedbackClearResponse,
84
+ RunsFeedbackUpdateResponse,
85
+ RunsGetResponse,
86
+ RunsListResponse,
87
+ RunsRerunResponse,
88
+ RunsResumeResponse,
91
89
  SourceLockfileResponse,
92
90
  SourceReleasesResponse,
93
91
  SourceRepositoryResponse,
@@ -96,7 +94,6 @@ export type {
96
94
  SourceSecretsEncryptBody,
97
95
  SourceSecretsEncryptResponse,
98
96
  WorkflowDetail,
99
- WorkflowExecutionStatusResponse,
100
97
  WorkflowSummary,
101
98
  WorkflowVersion,
102
99
  } from './generated/types.gen';
@@ -1,5 +1,4 @@
1
1
  import type { OperationResult } from '../client';
2
- import { EigenpalError } from '../errors';
3
2
  import type { Client } from '../generated/client';
4
3
  import {
5
4
  agentsCreate,
@@ -9,18 +8,6 @@ import {
9
8
  agentsGet,
10
9
  agentsList,
11
10
  agentsRun,
12
- agentsRunsCancel,
13
- agentsRunsExpectedCreate,
14
- agentsRunsExpectedDelete,
15
- agentsRunsExpectedDownload,
16
- agentsRunsExpectedList,
17
- agentsRunsExpectedRename,
18
- agentsRunsFeedbackDelete,
19
- agentsRunsFeedbackGet,
20
- agentsRunsFeedbackUpdate,
21
- agentsRunsGet,
22
- agentsRunsList,
23
- agentsRunsRerun,
24
11
  agentsTriggersEmailCreateAlias,
25
12
  agentsTriggersEmailDeleteAlias,
26
13
  agentsTriggersEmailGet,
@@ -31,9 +18,6 @@ import {
31
18
  agentsVersionsList,
32
19
  } from '../generated/sdk.gen';
33
20
  import type {
34
- AgentExecutionExpectedArtifacts,
35
- AgentExecutionFeedbackDetail,
36
- AgentRunResponse,
37
21
  AgentsTriggersEmailCreateAliasData,
38
22
  AgentsTriggersEmailCreateAliasResponse,
39
23
  AgentsTriggersEmailDeleteAliasResponse,
@@ -43,20 +27,14 @@ import type {
43
27
  AgentsTriggersEmailUpdateAliasResponse,
44
28
  AgentsTriggersEmailUpdateData,
45
29
  AgentsTriggersEmailUpdateResponse,
46
- CancelAgentExecutionResponse,
47
- CopyAgentExecutionOutputToExpectedBody,
48
30
  CreateAgentBody,
49
31
  CreateAgentResponse,
50
32
  GetAgentResponse,
51
- ListAgentRunsResponse,
52
33
  ListAgentVersionsResponse,
53
34
  ListAgentsResponse,
54
35
  PatchAgentBody,
55
36
  PatchAgentResponse,
56
- RenameExpectedFileBody,
57
- RerunAgentRunResponse,
58
37
  RunAgentResponse,
59
- UpdateAgentExecutionFeedbackBody,
60
38
  } from '../generated/types.gen';
61
39
  import { buildAgentMultipart, hasFileInput } from '../lib/files';
62
40
  import type { WorkflowInput } from './workflows';
@@ -76,43 +54,6 @@ export interface RunAgentOptions {
76
54
  signal?: AbortSignal;
77
55
  }
78
56
 
79
- export interface ListAgentRunsOptions {
80
- status?: string;
81
- batchId?: string;
82
- exampleId?: string;
83
- exampleIdContains?: string;
84
- createdAfter?: string;
85
- createdBefore?: string;
86
- completedAfter?: string;
87
- completedBefore?: string;
88
- feedbackStatus?: 'open' | 'resolved' | 'ignored';
89
- feedbackRating?: 'pass' | 'fail' | 'partial' | 'none';
90
- hasFeedback?: boolean;
91
- noFeedback?: boolean;
92
- hasExpected?: boolean;
93
- hasExpectedJson?: boolean;
94
- hasExpectedFiles?: boolean;
95
- feedbackBodyContains?: string;
96
- feedbackCreatedAfter?: string;
97
- feedbackCreatedBefore?: string;
98
- feedbackUpdatedAfter?: string;
99
- feedbackUpdatedBefore?: string;
100
- feedbackResolvedAfter?: string;
101
- feedbackResolvedBefore?: string;
102
- promotedToExample?: boolean;
103
- promotedExampleName?: string;
104
- sinceLastResolved?: boolean;
105
- include?: string;
106
- sort?: 'createdAt' | 'completedAt' | 'status' | 'exampleId';
107
- order?: 'asc' | 'desc';
108
- scanLimit?: number;
109
- limit?: number;
110
- offset?: number;
111
- signal?: AbortSignal;
112
- }
113
-
114
- export type AgentExecutionFileKind = 'input' | 'output' | 'issues' | 'trace' | 'lockfile';
115
-
116
57
  export class AgentEmailTriggersResource {
117
58
  constructor(
118
59
  private readonly client: Client,
@@ -199,252 +140,13 @@ export class AgentEmailTriggersResource {
199
140
  }
200
141
  }
201
142
 
202
- export class AgentRunsResource {
203
- constructor(
204
- private readonly client: Client,
205
- private readonly dispatch: Dispatch
206
- ) {}
207
-
208
- async list(agentId: string, options: ListAgentRunsOptions = {}): Promise<ListAgentRunsResponse> {
209
- const { signal, ...query } = options;
210
- return this.dispatch(() =>
211
- agentsRunsList({ client: this.client, path: { agentId }, query, signal })
212
- );
213
- }
214
-
215
- async get(
216
- runId: string,
217
- options: { include?: string; signal?: AbortSignal } = {}
218
- ): Promise<AgentRunResponse> {
219
- const { signal, include } = options;
220
- return this.dispatch(() =>
221
- agentsRunsGet({
222
- client: this.client,
223
- path: { runId },
224
- query: include ? { include } : {},
225
- signal,
226
- })
227
- );
228
- }
229
-
230
- async cancel(
231
- runId: string,
232
- options: { signal?: AbortSignal } = {}
233
- ): Promise<CancelAgentExecutionResponse> {
234
- return this.dispatch(() =>
235
- agentsRunsCancel({
236
- client: this.client,
237
- path: { runId },
238
- signal: options.signal,
239
- })
240
- );
241
- }
242
-
243
- async rerun(
244
- runId: string,
245
- options: { sourceRef?: string; signal?: AbortSignal } = {}
246
- ): Promise<RerunAgentRunResponse> {
247
- return this.dispatch(() =>
248
- agentsRunsRerun({
249
- client: this.client,
250
- path: { runId },
251
- body: {
252
- ...(options.sourceRef !== undefined ? { sourceRef: options.sourceRef } : {}),
253
- },
254
- signal: options.signal,
255
- })
256
- );
257
- }
258
-
259
- async getFeedback(
260
- runId: string,
261
- options: { signal?: AbortSignal } = {}
262
- ): Promise<AgentExecutionFeedbackDetail> {
263
- return this.dispatch(() =>
264
- agentsRunsFeedbackGet({
265
- client: this.client,
266
- path: { runId },
267
- signal: options.signal,
268
- })
269
- );
270
- }
271
-
272
- async updateFeedback(
273
- runId: string,
274
- body: UpdateAgentExecutionFeedbackBody,
275
- options: { signal?: AbortSignal } = {}
276
- ): Promise<AgentExecutionFeedbackDetail> {
277
- return this.dispatch(() =>
278
- agentsRunsFeedbackUpdate({
279
- client: this.client,
280
- path: { runId },
281
- body,
282
- signal: options.signal,
283
- })
284
- );
285
- }
286
-
287
- async clearFeedback(
288
- runId: string,
289
- options: { signal?: AbortSignal } = {}
290
- ): Promise<AgentExecutionFeedbackDetail> {
291
- return this.dispatch(() =>
292
- agentsRunsFeedbackDelete({
293
- client: this.client,
294
- path: { runId },
295
- signal: options.signal,
296
- })
297
- );
298
- }
299
-
300
- async listExpected(
301
- runId: string,
302
- options: { signal?: AbortSignal } = {}
303
- ): Promise<AgentExecutionExpectedArtifacts> {
304
- return this.dispatch(() =>
305
- agentsRunsExpectedList({
306
- client: this.client,
307
- path: { runId },
308
- signal: options.signal,
309
- })
310
- );
311
- }
312
-
313
- async copyOutputToExpected(
314
- runId: string,
315
- body: CopyAgentExecutionOutputToExpectedBody,
316
- options: { signal?: AbortSignal } = {}
317
- ): Promise<{ name: string }> {
318
- return this.dispatch(() =>
319
- agentsRunsExpectedCreate({
320
- client: this.client,
321
- path: { runId },
322
- body,
323
- signal: options.signal,
324
- })
325
- );
326
- }
327
-
328
- async renameExpected(
329
- runId: string,
330
- filename: string,
331
- body: RenameExpectedFileBody,
332
- options: { signal?: AbortSignal } = {}
333
- ): Promise<{ name: string }> {
334
- return this.dispatch(() =>
335
- agentsRunsExpectedRename({
336
- client: this.client,
337
- path: { runId, filename },
338
- body,
339
- signal: options.signal,
340
- })
341
- );
342
- }
343
-
344
- async deleteExpected(
345
- runId: string,
346
- filename: string,
347
- options: { signal?: AbortSignal } = {}
348
- ): Promise<void> {
349
- await this.dispatch(() =>
350
- agentsRunsExpectedDelete({
351
- client: this.client,
352
- path: { runId, filename },
353
- signal: options.signal,
354
- })
355
- );
356
- }
357
-
358
- async uploadExpected(
359
- runId: string,
360
- file: Blob,
361
- options: { name?: string; signal?: AbortSignal } = {}
362
- ): Promise<{ name: string }> {
363
- const formData = new FormData();
364
- formData.set('file', file);
365
- if (options.name) formData.set('name', options.name);
366
- return this.dispatch(
367
- () =>
368
- this.client.post({
369
- url: '/api/v1/agents/runs/{runId}/expected',
370
- path: { runId },
371
- body: formData,
372
- bodySerializer: null,
373
- headers: { 'Content-Type': null },
374
- signal: options.signal,
375
- }) as Promise<OperationResult<{ name: string }>>
376
- );
377
- }
378
-
379
- async downloadExpected(
380
- runId: string,
381
- filename: string,
382
- options: { signal?: AbortSignal } = {}
383
- ): Promise<Blob> {
384
- return this.downloadBlob(
385
- () =>
386
- agentsRunsExpectedDownload({
387
- client: this.client,
388
- path: { runId, filename },
389
- parseAs: 'blob',
390
- signal: options.signal,
391
- }) as Promise<OperationResult<Blob>>
392
- );
393
- }
394
-
395
- async downloadFile(
396
- runId: string,
397
- artifactPathOrKind: string,
398
- filenameOrOptions?: string | { signal?: AbortSignal },
399
- options: { signal?: AbortSignal } = {}
400
- ): Promise<Blob> {
401
- const artifactPath =
402
- typeof filenameOrOptions === 'string'
403
- ? artifactPathForKind(artifactPathOrKind as AgentExecutionFileKind, filenameOrOptions)
404
- : artifactPathOrKind;
405
- const requestOptions =
406
- typeof filenameOrOptions === 'string' ? options : (filenameOrOptions ?? {});
407
- return this.downloadBlob(
408
- () =>
409
- this.client.get({
410
- url: `/api/v1/agents/runs/${encodeURIComponent(runId)}/files/${encodeArtifactPath(
411
- artifactPath
412
- )}`,
413
- parseAs: 'blob',
414
- signal: requestOptions.signal,
415
- }) as Promise<OperationResult<Blob>>
416
- );
417
- }
418
-
419
- private async downloadBlob(call: () => Promise<OperationResult<Blob>>): Promise<Blob> {
420
- const result = await call();
421
- if (result.response?.ok && result.data instanceof Blob) {
422
- return result.data;
423
- }
424
- throw new EigenpalError('Failed to download agent execution artifact.', {
425
- status: result.response?.status ?? 0,
426
- });
427
- }
428
- }
429
-
430
- function artifactPathForKind(kind: AgentExecutionFileKind, filename: string): string {
431
- if (kind === 'issues' || kind === 'trace' || kind === 'lockfile') return filename;
432
- return `${kind}/${filename}`;
433
- }
434
-
435
- function encodeArtifactPath(artifactPath: string): string {
436
- return artifactPath.split('/').map(encodeURIComponent).join('/');
437
- }
438
-
439
143
  export class AgentsResource {
440
- public readonly runs: AgentRunsResource;
441
144
  public readonly emailTriggers: AgentEmailTriggersResource;
442
145
 
443
146
  constructor(
444
147
  private readonly client: Client,
445
148
  private readonly dispatch: Dispatch
446
149
  ) {
447
- this.runs = new AgentRunsResource(client, dispatch);
448
150
  this.emailTriggers = new AgentEmailTriggersResource(client, dispatch);
449
151
  }
450
152
 
@@ -1,34 +1,11 @@
1
1
  import type { OperationResult } from '../client';
2
2
  import { EigenpalTimeoutError } from '../errors';
3
3
  import type { Client } from '../generated/client';
4
- import {
5
- workflowsExecutionsCancel,
6
- workflowsExecutionsGet,
7
- workflowsExecutionsList,
8
- workflowsRun,
9
- } from '../generated/sdk.gen';
10
- import type {
11
- CancelWorkflowExecutionResponse,
12
- ExecutionStatus,
13
- ListWorkflowExecutionsResponse,
14
- RunWorkflowResponse,
15
- WorkflowExecutionStatusResponse,
16
- } from '../generated/types.gen';
4
+ import { runsGet, workflowsRun } from '../generated/sdk.gen';
5
+ import type { ExecutionStatus, RunsGetResponse, RunWorkflowResponse } from '../generated/types.gen';
17
6
  import { buildMultipart, hasFileInput } from '../lib/files';
18
7
  import type { WorkflowInput } from './workflows';
19
8
 
20
- export interface ListExecutionsOptions {
21
- /** Execution status, or an array of statuses. */
22
- status?: string | string[];
23
- /** ISO timestamp or relative expression like `"now()-7d"`. */
24
- fromDate?: string;
25
- toDate?: string;
26
- exampleId?: string;
27
- limit?: number;
28
- offset?: number;
29
- signal?: AbortSignal;
30
- }
31
-
32
9
  export interface RunAndWaitOptions {
33
10
  /** Workflow version. Default: `"latest"`. */
34
11
  version?: string;
@@ -58,9 +35,9 @@ const DEFAULT_RUN_AND_WAIT_TIMEOUT_MS = 5 * 60 * 1000;
58
35
  type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
59
36
 
60
37
  /**
61
- * Workflow execution resource read execution status, list executions, cancel
62
- * in-flight executions, and the convenience `runAndWait` helper that wraps a
63
- * workflow trigger + client-side poll loop. Reached via `client.workflows.executions`.
38
+ * Workflow execution helper namespace. Retrieval and mutation of existing runs
39
+ * lives on `client.runs`; this namespace only keeps `runAndWait` because it
40
+ * triggers a workflow before polling.
64
41
  */
65
42
  export class WorkflowExecutionsResource {
66
43
  constructor(
@@ -68,55 +45,6 @@ export class WorkflowExecutionsResource {
68
45
  private readonly dispatch: Dispatch
69
46
  ) {}
70
47
 
71
- /** Get execution status. Pass `includeSteps` for the full per-step payload. */
72
- async get(
73
- executionId: string,
74
- options: { includeSteps?: boolean; signal?: AbortSignal } = {}
75
- ): Promise<WorkflowExecutionStatusResponse> {
76
- return this.dispatch<WorkflowExecutionStatusResponse>(
77
- () =>
78
- workflowsExecutionsGet({
79
- client: this.client,
80
- path: { executionId },
81
- query: options.includeSteps ? { includeSteps: 'true' } : {},
82
- signal: options.signal,
83
- }) as Promise<OperationResult<WorkflowExecutionStatusResponse>>
84
- );
85
- }
86
-
87
- /** List executions, paginated. */
88
- async list(
89
- workflowId: string,
90
- options: ListExecutionsOptions = {}
91
- ): Promise<ListWorkflowExecutionsResponse> {
92
- const { signal, status, ...rest } = options;
93
- // Wire format takes comma-separated lists; idiomatic JS callers can
94
- // pass a string[] and we serialize.
95
- const query = {
96
- ...rest,
97
- ...(status !== undefined
98
- ? { status: Array.isArray(status) ? status.join(',') : status }
99
- : {}),
100
- };
101
- return this.dispatch(() =>
102
- workflowsExecutionsList({ client: this.client, path: { id: workflowId }, query, signal })
103
- );
104
- }
105
-
106
- /** Cancel an execution. Idempotent. */
107
- async cancel(
108
- executionId: string,
109
- options: { signal?: AbortSignal } = {}
110
- ): Promise<CancelWorkflowExecutionResponse> {
111
- return this.dispatch(() =>
112
- workflowsExecutionsCancel({
113
- client: this.client,
114
- path: { executionId },
115
- signal: options.signal,
116
- })
117
- );
118
- }
119
-
120
48
  /**
121
49
  * Trigger a workflow and poll for completion client-side.
122
50
  *
@@ -180,7 +108,20 @@ export class WorkflowExecutionsResource {
180
108
  );
181
109
  }
182
110
 
183
- const status = await this.get(executionId, { signal: options.signal });
111
+ const response = await this.dispatch<RunsGetResponse>(
112
+ () =>
113
+ runsGet({
114
+ client: this.client,
115
+ path: { id: executionId },
116
+ query: { include: 'detail' },
117
+ signal: options.signal,
118
+ }) as Promise<OperationResult<RunsGetResponse>>
119
+ );
120
+ const status = response.run as {
121
+ status?: ExecutionStatus | null;
122
+ result?: unknown;
123
+ error?: string | null;
124
+ };
184
125
 
185
126
  if (status.status && TERMINAL_STATUSES.has(status.status)) {
186
127
  return {