@eigenpal/sdk 0.6.9 → 0.6.11
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 +6 -0
- package/README.md +23 -6
- package/package.json +3 -2
- package/src/client.ts +4 -0
- package/src/generated/index.ts +132 -112
- package/src/generated/sdk.gen.ts +272 -227
- package/src/generated/types.gen.ts +711 -737
- package/src/index.ts +15 -18
- package/src/resources/agents.ts +0 -298
- package/src/resources/executions.ts +19 -78
- package/src/resources/runs.ts +556 -0
- package/src/resources/workflows.ts +3 -4
- package/src/telemetry.ts +1 -1
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import type { OperationResult } from '../client';
|
|
2
|
+
import { EigenpalError } from '../errors';
|
|
3
|
+
import type { Client } from '../generated/client';
|
|
4
|
+
import {
|
|
5
|
+
runsArtifactGet,
|
|
6
|
+
runsCancel,
|
|
7
|
+
runsComparisonGet,
|
|
8
|
+
runsConnect,
|
|
9
|
+
runsExpectedCreate,
|
|
10
|
+
runsExpectedFileDelete,
|
|
11
|
+
runsExpectedFileGet,
|
|
12
|
+
runsExpectedFileUpdate,
|
|
13
|
+
runsExpectedGet,
|
|
14
|
+
runsFeedbackClear,
|
|
15
|
+
runsFeedbackGet,
|
|
16
|
+
runsFeedbackUpdate,
|
|
17
|
+
runsFilesDelete,
|
|
18
|
+
runsFilesList,
|
|
19
|
+
runsFilesUpload,
|
|
20
|
+
runsFilesZipGet,
|
|
21
|
+
runsGet,
|
|
22
|
+
runsList,
|
|
23
|
+
runsRerun,
|
|
24
|
+
runsResume,
|
|
25
|
+
runsTraceGet,
|
|
26
|
+
} from '../generated/sdk.gen';
|
|
27
|
+
import type {
|
|
28
|
+
RunRerunRequest,
|
|
29
|
+
RunsCancelResponse,
|
|
30
|
+
RunsComparisonGetResponse,
|
|
31
|
+
RunsConnectResponse,
|
|
32
|
+
RunsExpectedCreateData,
|
|
33
|
+
RunsExpectedCreateResponse,
|
|
34
|
+
RunsExpectedFileDeleteResponse,
|
|
35
|
+
RunsExpectedFileUpdateData,
|
|
36
|
+
RunsExpectedFileUpdateResponse,
|
|
37
|
+
RunsExpectedGetResponse,
|
|
38
|
+
RunsFeedbackClearResponse,
|
|
39
|
+
RunsFeedbackGetResponse,
|
|
40
|
+
RunsFeedbackUpdateData,
|
|
41
|
+
RunsFeedbackUpdateResponse,
|
|
42
|
+
RunsFilesDeleteResponse,
|
|
43
|
+
RunsFilesListResponse,
|
|
44
|
+
RunsFilesUploadData,
|
|
45
|
+
RunsFilesUploadResponse,
|
|
46
|
+
RunsGetResponse,
|
|
47
|
+
RunsListData,
|
|
48
|
+
RunsListResponse,
|
|
49
|
+
RunsRerunResponse,
|
|
50
|
+
RunsResumeResponse,
|
|
51
|
+
RunsTraceGetResponse,
|
|
52
|
+
} from '../generated/types.gen';
|
|
53
|
+
|
|
54
|
+
type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
|
|
55
|
+
|
|
56
|
+
export type ListRunsOptions = NonNullable<RunsListData['query']> & { signal?: AbortSignal };
|
|
57
|
+
type SignalOptions = { signal?: AbortSignal };
|
|
58
|
+
|
|
59
|
+
export class RunsResource {
|
|
60
|
+
public readonly feedback: RunsFeedbackResource;
|
|
61
|
+
public readonly expected: RunsExpectedResource;
|
|
62
|
+
public readonly files: RunsFilesResource;
|
|
63
|
+
public readonly artifacts: RunsArtifactsResource;
|
|
64
|
+
public readonly comparison: RunsComparisonResource;
|
|
65
|
+
public readonly trace: RunsTraceResource;
|
|
66
|
+
|
|
67
|
+
constructor(
|
|
68
|
+
private readonly client: Client,
|
|
69
|
+
private readonly dispatch: Dispatch
|
|
70
|
+
) {
|
|
71
|
+
this.feedback = new RunsFeedbackResource(client, dispatch);
|
|
72
|
+
this.expected = new RunsExpectedResource(client, dispatch);
|
|
73
|
+
this.files = new RunsFilesResource(client, dispatch);
|
|
74
|
+
this.artifacts = new RunsArtifactsResource(client);
|
|
75
|
+
this.comparison = new RunsComparisonResource(client, dispatch);
|
|
76
|
+
this.trace = new RunsTraceResource(client, dispatch);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async list(options: ListRunsOptions = {}): Promise<RunsListResponse> {
|
|
80
|
+
const { signal, ...query } = options;
|
|
81
|
+
return this.dispatch(() => runsList({ client: this.client, query, signal }));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async get(runId: string, options: { include?: string; signal?: AbortSignal } = {}) {
|
|
85
|
+
const response = await this.dispatch<RunsGetResponse>(() =>
|
|
86
|
+
runsGet({
|
|
87
|
+
client: this.client,
|
|
88
|
+
path: { id: runId },
|
|
89
|
+
query: options.include ? { include: options.include } : {},
|
|
90
|
+
signal: options.signal,
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
return response.run;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async resume(runId: string, options: SignalOptions = {}): Promise<RunsResumeResponse> {
|
|
97
|
+
return this.dispatch(() =>
|
|
98
|
+
runsResume({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async cancel(runId: string, options: SignalOptions = {}): Promise<RunsCancelResponse> {
|
|
103
|
+
return this.dispatch(() =>
|
|
104
|
+
runsCancel({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async rerun(
|
|
109
|
+
runId: string,
|
|
110
|
+
body: RunRerunRequest = {},
|
|
111
|
+
options: SignalOptions = {}
|
|
112
|
+
): Promise<RunsRerunResponse> {
|
|
113
|
+
return this.dispatch(() =>
|
|
114
|
+
runsRerun({ client: this.client, path: { id: runId }, body, signal: options.signal })
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async compare(
|
|
119
|
+
referenceRunId: string,
|
|
120
|
+
runId: string,
|
|
121
|
+
options: {
|
|
122
|
+
baseline?: boolean;
|
|
123
|
+
step?: string;
|
|
124
|
+
normalizeDates?: boolean;
|
|
125
|
+
signal?: AbortSignal;
|
|
126
|
+
} = {}
|
|
127
|
+
): Promise<RunComparisonReport> {
|
|
128
|
+
const mode = options.baseline ? 'baseline' : 'expected';
|
|
129
|
+
const [reference, target] = await Promise.all([
|
|
130
|
+
this.get(referenceRunId, {
|
|
131
|
+
include: mode === 'baseline' ? 'detail,files,output' : 'detail,expected',
|
|
132
|
+
signal: options.signal,
|
|
133
|
+
}),
|
|
134
|
+
this.get(runId, { include: 'detail,files,output', signal: options.signal }),
|
|
135
|
+
]);
|
|
136
|
+
|
|
137
|
+
if (isWorkflowRun(reference) && isWorkflowRun(target)) {
|
|
138
|
+
return compareWorkflowRuns(referenceRunId, reference, runId, target, options.step);
|
|
139
|
+
}
|
|
140
|
+
if (options.step) {
|
|
141
|
+
throw new EigenpalError(
|
|
142
|
+
'`step` is only supported when both runs are workflow runs. Agent runs do not have workflow steps.',
|
|
143
|
+
{ status: 400 }
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
if (isWorkflowRun(reference) || isWorkflowRun(target)) {
|
|
147
|
+
throw new EigenpalError(
|
|
148
|
+
'Mixed workflow/agent comparisons are not supported. Compare two workflow runs or two agent runs.',
|
|
149
|
+
{ status: 400 }
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return compareArtifactRuns(
|
|
153
|
+
referenceRunId,
|
|
154
|
+
reference,
|
|
155
|
+
runId,
|
|
156
|
+
target,
|
|
157
|
+
mode,
|
|
158
|
+
Boolean(options.normalizeDates)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async connect(runId: string, options: SignalOptions = {}): Promise<RunsConnectResponse> {
|
|
163
|
+
return this.dispatch(() =>
|
|
164
|
+
runsConnect({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type RunRecord = Record<string, unknown>;
|
|
170
|
+
type ComparisonMode = 'expected' | 'baseline';
|
|
171
|
+
|
|
172
|
+
export type RunComparisonReport = {
|
|
173
|
+
status: 'pass' | 'fail';
|
|
174
|
+
runId: string;
|
|
175
|
+
comparedWithRunId: string;
|
|
176
|
+
mode?: ComparisonMode;
|
|
177
|
+
steps?: Array<Record<string, unknown>>;
|
|
178
|
+
jsonDifferences?: Array<Record<string, string>>;
|
|
179
|
+
matchedFiles?: Array<Record<string, string>>;
|
|
180
|
+
missingFiles?: string[];
|
|
181
|
+
extraFiles?: string[];
|
|
182
|
+
warnings?: string[];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
function isWorkflowRun(run: unknown): run is RunRecord & { stepExecutions: unknown[] } {
|
|
186
|
+
return isRecord(run) && Array.isArray(run.stepExecutions);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isRecord(value: unknown): value is RunRecord {
|
|
190
|
+
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function compareWorkflowRuns(
|
|
194
|
+
referenceRunId: string,
|
|
195
|
+
reference: RunRecord & { stepExecutions: unknown[] },
|
|
196
|
+
runId: string,
|
|
197
|
+
target: RunRecord & { stepExecutions: unknown[] },
|
|
198
|
+
stepFilter?: string
|
|
199
|
+
): RunComparisonReport {
|
|
200
|
+
const wanted = stepFilter
|
|
201
|
+
?.split(',')
|
|
202
|
+
.map((step) => step.trim())
|
|
203
|
+
.filter(Boolean);
|
|
204
|
+
const targetSteps = new Map(
|
|
205
|
+
target.stepExecutions
|
|
206
|
+
.filter(isRecord)
|
|
207
|
+
.map((step) => [String(step.stepName ?? step.name ?? step.id ?? ''), step])
|
|
208
|
+
);
|
|
209
|
+
const steps = reference.stepExecutions
|
|
210
|
+
.filter(isRecord)
|
|
211
|
+
.filter(
|
|
212
|
+
(step) => !wanted?.length || wanted.includes(String(step.stepName ?? step.name ?? step.id))
|
|
213
|
+
)
|
|
214
|
+
.map((referenceStep) => {
|
|
215
|
+
const stepName = String(
|
|
216
|
+
referenceStep.stepName ?? referenceStep.name ?? referenceStep.id ?? ''
|
|
217
|
+
);
|
|
218
|
+
const targetStep = targetSteps.get(stepName);
|
|
219
|
+
const referenceOutput = referenceStep.outputData ?? referenceStep.output;
|
|
220
|
+
const targetOutput = targetStep?.outputData ?? targetStep?.output;
|
|
221
|
+
return {
|
|
222
|
+
stepName,
|
|
223
|
+
referenceStatus: String(referenceStep.status ?? ''),
|
|
224
|
+
targetStatus: String(targetStep?.status ?? 'missing'),
|
|
225
|
+
outputState: stableJson(referenceOutput) === stableJson(targetOutput) ? 'match' : 'diff',
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
status: steps.every((step) => step.targetStatus !== 'missing' && step.outputState === 'match')
|
|
230
|
+
? 'pass'
|
|
231
|
+
: 'fail',
|
|
232
|
+
runId,
|
|
233
|
+
comparedWithRunId: referenceRunId,
|
|
234
|
+
steps,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function compareArtifactRuns(
|
|
239
|
+
referenceRunId: string,
|
|
240
|
+
reference: unknown,
|
|
241
|
+
runId: string,
|
|
242
|
+
target: unknown,
|
|
243
|
+
mode: ComparisonMode,
|
|
244
|
+
normalizeDates: boolean
|
|
245
|
+
): RunComparisonReport {
|
|
246
|
+
const referenceRun = isRecord(reference) ? reference : {};
|
|
247
|
+
const targetRun = isRecord(target) ? target : {};
|
|
248
|
+
const expectedValue = mode === 'baseline' ? referenceRun.output : referenceRun.expected;
|
|
249
|
+
const expectedFiles =
|
|
250
|
+
mode === 'baseline' ? names(referenceRun.resultFiles) : names(referenceRun.expectedFiles);
|
|
251
|
+
const outputFiles = names(targetRun.resultFiles);
|
|
252
|
+
const missing = expectedFiles.filter(
|
|
253
|
+
(name) =>
|
|
254
|
+
!outputFiles.some(
|
|
255
|
+
(out) => comparableName(out, normalizeDates) === comparableName(name, normalizeDates)
|
|
256
|
+
)
|
|
257
|
+
);
|
|
258
|
+
const extra = outputFiles.filter(
|
|
259
|
+
(name) =>
|
|
260
|
+
!expectedFiles.some(
|
|
261
|
+
(exp) => comparableName(exp, normalizeDates) === comparableName(name, normalizeDates)
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
const matched = expectedFiles
|
|
265
|
+
.filter((name) => !missing.includes(name))
|
|
266
|
+
.map((name) => ({
|
|
267
|
+
expected: name,
|
|
268
|
+
actual:
|
|
269
|
+
outputFiles.find(
|
|
270
|
+
(out) => comparableName(out, normalizeDates) === comparableName(name, normalizeDates)
|
|
271
|
+
) ?? name,
|
|
272
|
+
}));
|
|
273
|
+
const jsonDifferences = diffJson(expectedValue, targetRun.output);
|
|
274
|
+
return {
|
|
275
|
+
status:
|
|
276
|
+
jsonDifferences.length === 0 && missing.length === 0 && extra.length === 0 ? 'pass' : 'fail',
|
|
277
|
+
runId,
|
|
278
|
+
comparedWithRunId: referenceRunId,
|
|
279
|
+
mode,
|
|
280
|
+
jsonDifferences,
|
|
281
|
+
matchedFiles: matched,
|
|
282
|
+
missingFiles: missing,
|
|
283
|
+
extraFiles: extra,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function names(value: unknown): string[] {
|
|
288
|
+
if (!Array.isArray(value)) return [];
|
|
289
|
+
return value.map((item) => (isRecord(item) ? String(item.name ?? '') : '')).filter(Boolean);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function comparableName(value: string, normalizeDates: boolean): string {
|
|
293
|
+
if (!normalizeDates) return value;
|
|
294
|
+
return value.replace(/\d{4}-\d{2}-\d{2}/g, '<date>').replace(/\d{8}/g, '<date>');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function stableJson(value: unknown): string {
|
|
298
|
+
return JSON.stringify(value ?? null);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function diffJson(
|
|
302
|
+
expected: unknown,
|
|
303
|
+
actual: unknown,
|
|
304
|
+
basePath = '$'
|
|
305
|
+
): Array<Record<string, string>> {
|
|
306
|
+
if (expected == null) return [];
|
|
307
|
+
if (Object.is(expected, actual)) return [];
|
|
308
|
+
if (isRecord(expected) && isRecord(actual)) {
|
|
309
|
+
const keys = new Set([...Object.keys(expected), ...Object.keys(actual)]);
|
|
310
|
+
return [...keys].flatMap((key) => {
|
|
311
|
+
const next = `${basePath}.${key}`;
|
|
312
|
+
if (!(key in actual)) return [{ path: next, type: 'missing' }];
|
|
313
|
+
if (!(key in expected)) return [{ path: next, type: 'extra' }];
|
|
314
|
+
return diffJson(expected[key], actual[key], next);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return [{ path: basePath, type: 'changed' }];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export class RunsFeedbackResource {
|
|
321
|
+
constructor(
|
|
322
|
+
private readonly client: Client,
|
|
323
|
+
private readonly dispatch: Dispatch
|
|
324
|
+
) {}
|
|
325
|
+
|
|
326
|
+
async get(runId: string, options: SignalOptions = {}): Promise<RunsFeedbackGetResponse> {
|
|
327
|
+
return this.dispatch(() =>
|
|
328
|
+
runsFeedbackGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async update(
|
|
333
|
+
runId: string,
|
|
334
|
+
body: RunsFeedbackUpdateData['body'],
|
|
335
|
+
options: SignalOptions = {}
|
|
336
|
+
): Promise<RunsFeedbackUpdateResponse> {
|
|
337
|
+
return this.dispatch(() =>
|
|
338
|
+
runsFeedbackUpdate({
|
|
339
|
+
client: this.client,
|
|
340
|
+
path: { id: runId },
|
|
341
|
+
body,
|
|
342
|
+
signal: options.signal,
|
|
343
|
+
})
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async resolve(
|
|
348
|
+
runId: string,
|
|
349
|
+
body: Omit<NonNullable<RunsFeedbackUpdateData['body']>, 'status'> = {},
|
|
350
|
+
options: SignalOptions = {}
|
|
351
|
+
): Promise<RunsFeedbackUpdateResponse> {
|
|
352
|
+
return this.update(runId, { ...body, status: 'resolved' }, options);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async clear(runId: string, options: SignalOptions = {}): Promise<RunsFeedbackClearResponse> {
|
|
356
|
+
return this.dispatch(() =>
|
|
357
|
+
runsFeedbackClear({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export class RunsExpectedResource {
|
|
363
|
+
constructor(
|
|
364
|
+
private readonly client: Client,
|
|
365
|
+
private readonly dispatch: Dispatch
|
|
366
|
+
) {}
|
|
367
|
+
|
|
368
|
+
async list(runId: string, options: SignalOptions = {}): Promise<RunsExpectedGetResponse> {
|
|
369
|
+
return this.dispatch(() =>
|
|
370
|
+
runsExpectedGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
async copyOutput(
|
|
375
|
+
runId: string,
|
|
376
|
+
body: RunsExpectedCreateData['body'],
|
|
377
|
+
options: SignalOptions = {}
|
|
378
|
+
): Promise<RunsExpectedCreateResponse> {
|
|
379
|
+
return this.dispatch(() =>
|
|
380
|
+
runsExpectedCreate({
|
|
381
|
+
client: this.client,
|
|
382
|
+
path: { id: runId },
|
|
383
|
+
body,
|
|
384
|
+
signal: options.signal,
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
async upload(
|
|
390
|
+
runId: string,
|
|
391
|
+
file: Blob,
|
|
392
|
+
options: { name?: string; filename?: string; signal?: AbortSignal } = {}
|
|
393
|
+
): Promise<RunsExpectedCreateResponse> {
|
|
394
|
+
const form = new FormData();
|
|
395
|
+
if (options.filename) form.append('file', file, options.filename);
|
|
396
|
+
else form.append('file', file);
|
|
397
|
+
if (options.name) form.append('name', options.name);
|
|
398
|
+
return this.dispatch(
|
|
399
|
+
() =>
|
|
400
|
+
this.client.post({
|
|
401
|
+
url: '/api/v1/runs/{id}/expected',
|
|
402
|
+
path: { id: runId },
|
|
403
|
+
body: form,
|
|
404
|
+
signal: options.signal,
|
|
405
|
+
}) as Promise<OperationResult<RunsExpectedCreateResponse>>
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async rename(
|
|
410
|
+
runId: string,
|
|
411
|
+
filename: string,
|
|
412
|
+
body: RunsExpectedFileUpdateData['body'],
|
|
413
|
+
options: SignalOptions = {}
|
|
414
|
+
): Promise<RunsExpectedFileUpdateResponse> {
|
|
415
|
+
return this.dispatch(() =>
|
|
416
|
+
runsExpectedFileUpdate({
|
|
417
|
+
client: this.client,
|
|
418
|
+
path: { id: runId, filename },
|
|
419
|
+
body,
|
|
420
|
+
signal: options.signal,
|
|
421
|
+
})
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
async delete(
|
|
426
|
+
runId: string,
|
|
427
|
+
filename: string,
|
|
428
|
+
options: SignalOptions = {}
|
|
429
|
+
): Promise<RunsExpectedFileDeleteResponse> {
|
|
430
|
+
return this.dispatch(() =>
|
|
431
|
+
runsExpectedFileDelete({
|
|
432
|
+
client: this.client,
|
|
433
|
+
path: { id: runId, filename },
|
|
434
|
+
signal: options.signal,
|
|
435
|
+
})
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async download(runId: string, filename: string, options: SignalOptions = {}): Promise<Blob> {
|
|
440
|
+
return downloadBlob(
|
|
441
|
+
() =>
|
|
442
|
+
runsExpectedFileGet({
|
|
443
|
+
client: this.client,
|
|
444
|
+
path: { id: runId, filename },
|
|
445
|
+
parseAs: 'blob',
|
|
446
|
+
signal: options.signal,
|
|
447
|
+
}) as Promise<OperationResult<Blob>>
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export class RunsFilesResource {
|
|
453
|
+
constructor(
|
|
454
|
+
private readonly client: Client,
|
|
455
|
+
private readonly dispatch: Dispatch
|
|
456
|
+
) {}
|
|
457
|
+
|
|
458
|
+
async list(runId: string, options: SignalOptions = {}): Promise<RunsFilesListResponse> {
|
|
459
|
+
return this.dispatch(() =>
|
|
460
|
+
runsFilesList({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
async upload(
|
|
465
|
+
runId: string,
|
|
466
|
+
body: RunsFilesUploadData['body'],
|
|
467
|
+
options: SignalOptions = {}
|
|
468
|
+
): Promise<RunsFilesUploadResponse> {
|
|
469
|
+
return this.dispatch(() =>
|
|
470
|
+
runsFilesUpload({ client: this.client, path: { id: runId }, body, signal: options.signal })
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async delete(
|
|
475
|
+
runId: string,
|
|
476
|
+
fileId: string,
|
|
477
|
+
options: SignalOptions = {}
|
|
478
|
+
): Promise<RunsFilesDeleteResponse> {
|
|
479
|
+
return this.dispatch(() =>
|
|
480
|
+
runsFilesDelete({
|
|
481
|
+
client: this.client,
|
|
482
|
+
path: { id: runId, fileId },
|
|
483
|
+
signal: options.signal,
|
|
484
|
+
})
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export class RunsArtifactsResource {
|
|
490
|
+
constructor(private readonly client: Client) {}
|
|
491
|
+
|
|
492
|
+
async download(runId: string, path: string, options: SignalOptions = {}): Promise<Blob> {
|
|
493
|
+
return downloadBlob(
|
|
494
|
+
() =>
|
|
495
|
+
runsArtifactGet({
|
|
496
|
+
client: this.client,
|
|
497
|
+
path: { id: runId, path },
|
|
498
|
+
parseAs: 'blob',
|
|
499
|
+
signal: options.signal,
|
|
500
|
+
}) as Promise<OperationResult<Blob>>
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async downloadZip(
|
|
505
|
+
runId: string,
|
|
506
|
+
options: { files?: string; token?: string; signal?: AbortSignal } = {}
|
|
507
|
+
): Promise<Blob> {
|
|
508
|
+
const { signal, ...query } = options;
|
|
509
|
+
return downloadBlob(
|
|
510
|
+
() =>
|
|
511
|
+
runsFilesZipGet({
|
|
512
|
+
client: this.client,
|
|
513
|
+
path: { id: runId },
|
|
514
|
+
query,
|
|
515
|
+
parseAs: 'blob',
|
|
516
|
+
signal,
|
|
517
|
+
}) as Promise<OperationResult<Blob>>
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export class RunsComparisonResource {
|
|
523
|
+
constructor(
|
|
524
|
+
private readonly client: Client,
|
|
525
|
+
private readonly dispatch: Dispatch
|
|
526
|
+
) {}
|
|
527
|
+
|
|
528
|
+
async get(runId: string, options: SignalOptions = {}): Promise<RunsComparisonGetResponse> {
|
|
529
|
+
return this.dispatch(() =>
|
|
530
|
+
runsComparisonGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export class RunsTraceResource {
|
|
536
|
+
constructor(
|
|
537
|
+
private readonly client: Client,
|
|
538
|
+
private readonly dispatch: Dispatch
|
|
539
|
+
) {}
|
|
540
|
+
|
|
541
|
+
async get(runId: string, options: SignalOptions = {}): Promise<RunsTraceGetResponse> {
|
|
542
|
+
return this.dispatch(() =>
|
|
543
|
+
runsTraceGet({ client: this.client, path: { id: runId }, signal: options.signal })
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
async function downloadBlob(call: () => Promise<OperationResult<Blob>>): Promise<Blob> {
|
|
549
|
+
const result = await call();
|
|
550
|
+
if (result.response?.ok && result.data instanceof Blob) {
|
|
551
|
+
return result.data;
|
|
552
|
+
}
|
|
553
|
+
throw new EigenpalError('Failed to download run artifact.', {
|
|
554
|
+
status: result.response?.status ?? 0,
|
|
555
|
+
});
|
|
556
|
+
}
|
|
@@ -55,8 +55,8 @@ export interface ListVersionsOptions {
|
|
|
55
55
|
type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Workflow resource — list, get, run, and inspect versions of saved
|
|
59
|
-
*
|
|
58
|
+
* Workflow resource — list, get, run, and inspect versions of saved workflows.
|
|
59
|
+
* Existing run retrieval and mutation lives on `client.runs`.
|
|
60
60
|
*/
|
|
61
61
|
export class WorkflowsResource {
|
|
62
62
|
public readonly executions: WorkflowExecutionsResource;
|
|
@@ -76,8 +76,7 @@ export class WorkflowsResource {
|
|
|
76
76
|
* @param options — `version`, `waitForCompletion`, `overrides`.
|
|
77
77
|
*
|
|
78
78
|
* - With no `waitForCompletion`, returns immediately with `{ executionId }`.
|
|
79
|
-
* Poll via `client.
|
|
80
|
-
* `client.workflows.executions.runAndWait`.
|
|
79
|
+
* Poll via `client.runs.get(id)` or use `client.workflows.executions.runAndWait`.
|
|
81
80
|
* - With `waitForCompletion: 60`, the server holds the connection up to 60
|
|
82
81
|
* seconds. The response also includes `status`, `result`, and `error`
|
|
83
82
|
* when the run finishes within the window.
|
package/src/telemetry.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
export const SDK_LANGUAGE = 'typescript';
|
|
20
20
|
// Rewritten at publish time by scripts/render-sdk-versions.sh.
|
|
21
21
|
// Keep this string literal exactly stable — sed matches on it.
|
|
22
|
-
export const SDK_VERSION = '0.6.
|
|
22
|
+
export const SDK_VERSION = '0.6.11';
|
|
23
23
|
|
|
24
24
|
function detectRuntime(): string {
|
|
25
25
|
const g = globalThis as unknown as {
|