@benchsdk/client 0.2.1 → 0.4.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/LICENSE +21 -0
- package/README.md +49 -98
- package/dist/index.cjs +17 -962
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -723
- package/dist/index.d.ts +7 -723
- package/dist/index.js +17 -943
- package/dist/index.js.map +1 -1
- package/package.json +18 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,727 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** API base URL. Defaults to https://platform.computesdk.com/api/v1. */
|
|
7
|
-
baseUrl?: string;
|
|
8
|
-
/** Bearer token. Defaults to process.env.COMPUTESDK_ADMIN_API_KEY, then process.env.COMPUTESDK_API_KEY. */
|
|
9
|
-
apiKey?: string;
|
|
10
|
-
/** Custom fetch implementation, mostly useful for tests. */
|
|
11
|
-
fetch?: typeof fetch;
|
|
12
|
-
}
|
|
13
|
-
interface BenchmarkResource {
|
|
14
|
-
id: string;
|
|
15
|
-
slug: string;
|
|
16
|
-
name: string;
|
|
17
|
-
kind?: string | null;
|
|
18
|
-
status?: string;
|
|
19
|
-
config?: JsonObject;
|
|
20
|
-
defaultRunConfig?: JsonObject;
|
|
21
|
-
}
|
|
22
|
-
type BenchmarkRunStatus = 'planned' | 'in_progress' | 'completed' | 'failed';
|
|
23
|
-
type BenchmarkWorkerStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
24
|
-
interface BenchmarkRun {
|
|
25
|
-
id: string;
|
|
26
|
-
benchmarkId: string;
|
|
27
|
-
name?: string | null;
|
|
28
|
-
status: BenchmarkRunStatus | string;
|
|
29
|
-
totalTasks: number;
|
|
30
|
-
workerCount: number;
|
|
31
|
-
config?: JsonObject;
|
|
32
|
-
createdAt?: string;
|
|
33
|
-
updatedAt?: string;
|
|
34
|
-
}
|
|
35
|
-
interface BenchmarkParticipant {
|
|
36
|
-
id: string;
|
|
37
|
-
benchmarkId: string;
|
|
38
|
-
runId: string;
|
|
39
|
-
slug: string;
|
|
40
|
-
label?: string | null;
|
|
41
|
-
provider?: string | null;
|
|
42
|
-
status: BenchmarkRunStatus | string;
|
|
43
|
-
totalTasks: number;
|
|
44
|
-
workerCount: number;
|
|
45
|
-
config?: JsonObject;
|
|
46
|
-
}
|
|
47
|
-
interface BenchmarkRunWorker {
|
|
48
|
-
id: string;
|
|
49
|
-
benchmarkId: string;
|
|
50
|
-
runId: string;
|
|
51
|
-
participantId: string;
|
|
52
|
-
workerIndex: number;
|
|
53
|
-
workerCount: number;
|
|
54
|
-
taskIndexStart: number;
|
|
55
|
-
taskIndexEnd: number;
|
|
56
|
-
targetConcurrency: number;
|
|
57
|
-
status: BenchmarkWorkerStatus | string;
|
|
58
|
-
progressDone?: number;
|
|
59
|
-
progressInFlight?: number;
|
|
60
|
-
progressErrors?: number;
|
|
61
|
-
progressTotal?: number;
|
|
62
|
-
currentStep?: string | null;
|
|
63
|
-
concurrency?: WorkerConcurrencySample[];
|
|
64
|
-
}
|
|
65
|
-
interface BenchmarkWorkerAttempt {
|
|
66
|
-
id: string;
|
|
67
|
-
benchmarkId: string;
|
|
68
|
-
runId: string;
|
|
69
|
-
participantId: string;
|
|
70
|
-
workerId: string;
|
|
71
|
-
attemptNumber: number;
|
|
72
|
-
status: string;
|
|
73
|
-
}
|
|
74
|
-
interface BenchmarkAssignment {
|
|
75
|
-
benchmarkId: string;
|
|
76
|
-
benchmarkSlug: string;
|
|
77
|
-
runId: string;
|
|
78
|
-
participantId: string;
|
|
79
|
-
participantSlug: string;
|
|
80
|
-
provider?: string | null;
|
|
81
|
-
workerId: string;
|
|
82
|
-
workerIndex: number;
|
|
83
|
-
workerCount: number;
|
|
84
|
-
attemptId: string;
|
|
85
|
-
attemptNumber: number;
|
|
86
|
-
taskRange: {
|
|
87
|
-
start: number;
|
|
88
|
-
end: number;
|
|
89
|
-
count: number;
|
|
90
|
-
};
|
|
91
|
-
targetConcurrency: number;
|
|
92
|
-
config?: JsonObject;
|
|
93
|
-
}
|
|
94
|
-
interface UpsertBenchmarkInput {
|
|
95
|
-
name: string;
|
|
96
|
-
kind?: string;
|
|
97
|
-
status?: string;
|
|
98
|
-
config?: JsonObject;
|
|
99
|
-
defaultRunConfig?: JsonObject;
|
|
100
|
-
}
|
|
101
|
-
interface UpdateBenchmarkInput {
|
|
102
|
-
name?: string;
|
|
103
|
-
kind?: string;
|
|
104
|
-
status?: string;
|
|
105
|
-
config?: JsonObject;
|
|
106
|
-
defaultRunConfig?: JsonObject;
|
|
107
|
-
}
|
|
108
|
-
interface CreateRunInput {
|
|
109
|
-
name?: string;
|
|
110
|
-
totalTasks: number;
|
|
111
|
-
workerCount: number;
|
|
112
|
-
participants?: string[];
|
|
113
|
-
config?: JsonObject;
|
|
114
|
-
}
|
|
115
|
-
interface UpdateRunInput {
|
|
116
|
-
name?: string;
|
|
117
|
-
status?: BenchmarkRunStatus;
|
|
118
|
-
config?: JsonObject;
|
|
119
|
-
}
|
|
120
|
-
interface UpsertParticipantInput {
|
|
121
|
-
label?: string;
|
|
122
|
-
provider?: string;
|
|
123
|
-
status?: string;
|
|
124
|
-
totalTasks?: number;
|
|
125
|
-
workerCount?: number;
|
|
126
|
-
config?: JsonObject;
|
|
127
|
-
}
|
|
128
|
-
type UpdateParticipantInput = UpsertParticipantInput;
|
|
129
|
-
interface UpdateWorkerInput {
|
|
130
|
-
status?: BenchmarkWorkerStatus;
|
|
131
|
-
progressDone?: number;
|
|
132
|
-
progressInFlight?: number;
|
|
133
|
-
progressErrors?: number;
|
|
134
|
-
progressTotal?: number;
|
|
135
|
-
}
|
|
136
|
-
interface ClaimWorkerInput {
|
|
137
|
-
processKind?: string;
|
|
138
|
-
processKey?: string;
|
|
139
|
-
}
|
|
140
|
-
interface PlanWorkersInput {
|
|
141
|
-
workerCount?: number;
|
|
142
|
-
targetConcurrency?: number;
|
|
143
|
-
config?: JsonObject;
|
|
144
|
-
}
|
|
145
|
-
interface TaskResultRecord {
|
|
146
|
-
taskIndex: number;
|
|
147
|
-
status: string;
|
|
148
|
-
startedAt?: string;
|
|
149
|
-
completedAt?: string;
|
|
150
|
-
latencyMs?: number;
|
|
151
|
-
firstCommandMs?: number | null;
|
|
152
|
-
errorCode?: string | null;
|
|
153
|
-
steps?: TaskStepRecord[];
|
|
154
|
-
data?: JsonObject;
|
|
155
|
-
}
|
|
156
|
-
interface TaskStepRecord {
|
|
157
|
-
name: string;
|
|
158
|
-
status: 'success' | 'error';
|
|
159
|
-
startedAt?: string;
|
|
160
|
-
completedAt?: string;
|
|
161
|
-
latencyMs?: number;
|
|
162
|
-
errorCode?: string | null;
|
|
163
|
-
data?: JsonObject;
|
|
164
|
-
}
|
|
165
|
-
interface SendTaskResultsInput {
|
|
166
|
-
benchmarkSlug: string;
|
|
167
|
-
runId: string;
|
|
168
|
-
workerId: string;
|
|
169
|
-
attemptId: string;
|
|
170
|
-
sequenceNumber: number;
|
|
171
|
-
isFinal: boolean;
|
|
172
|
-
records: TaskResultRecord[];
|
|
173
|
-
}
|
|
174
|
-
interface TaskResultsResponse {
|
|
175
|
-
accepted?: number;
|
|
176
|
-
eventBatchId?: string;
|
|
177
|
-
queued?: boolean;
|
|
178
|
-
eventBatch?: unknown;
|
|
179
|
-
duplicate?: boolean;
|
|
180
|
-
queueMessageId?: string;
|
|
181
|
-
}
|
|
182
|
-
interface CreateWorkerArtifactInput {
|
|
183
|
-
attemptId: string;
|
|
184
|
-
kind: string;
|
|
185
|
-
contentType?: string;
|
|
186
|
-
name?: string;
|
|
187
|
-
metadata?: JsonObject;
|
|
188
|
-
}
|
|
189
|
-
interface UploadWorkerArtifactInput extends CreateWorkerArtifactInput {
|
|
190
|
-
body: BodyInit;
|
|
191
|
-
}
|
|
192
|
-
interface BenchmarkArtifact {
|
|
193
|
-
id?: string;
|
|
194
|
-
artifactId?: string;
|
|
195
|
-
benchmarkId?: string;
|
|
196
|
-
runId?: string;
|
|
197
|
-
participantId?: string;
|
|
198
|
-
participantSlug?: string;
|
|
199
|
-
workerId?: string;
|
|
200
|
-
attemptId?: string;
|
|
201
|
-
kind: string;
|
|
202
|
-
name?: string | null;
|
|
203
|
-
contentType?: string | null;
|
|
204
|
-
objectKey?: string;
|
|
205
|
-
uploadUrl?: string;
|
|
206
|
-
uploadUrlExpiresAt?: string;
|
|
207
|
-
metadata?: JsonObject;
|
|
208
|
-
createdAt?: string;
|
|
209
|
-
}
|
|
210
|
-
interface CreateWorkerArtifactResponse {
|
|
211
|
-
artifact?: BenchmarkArtifact;
|
|
212
|
-
artifactId?: string;
|
|
213
|
-
uploadUrl?: string;
|
|
214
|
-
uploadUrlExpiresAt?: string;
|
|
215
|
-
objectKey?: string;
|
|
216
|
-
}
|
|
217
|
-
interface BenchmarkResultLatencySummary {
|
|
218
|
-
min: number | null;
|
|
219
|
-
avg: number | null;
|
|
220
|
-
p50: number | null;
|
|
221
|
-
p95: number | null;
|
|
222
|
-
p99: number | null;
|
|
223
|
-
max: number | null;
|
|
224
|
-
}
|
|
225
|
-
interface BenchmarkResultSummary {
|
|
226
|
-
taskCount: number;
|
|
227
|
-
successCount: number;
|
|
228
|
-
errorCount: number;
|
|
229
|
-
otherCount: number;
|
|
230
|
-
latencyCount: number;
|
|
231
|
-
successRate: number;
|
|
232
|
-
latencyMs: BenchmarkResultLatencySummary;
|
|
233
|
-
firstStartedAt: string | null;
|
|
234
|
-
lastCompletedAt: string | null;
|
|
235
|
-
}
|
|
236
|
-
interface BenchmarkParticipantResultSummary extends BenchmarkResultSummary {
|
|
237
|
-
participantSlug: string;
|
|
238
|
-
provider: string | null;
|
|
239
|
-
}
|
|
240
|
-
interface BenchmarkStepResultSummary {
|
|
241
|
-
participantSlug: string;
|
|
242
|
-
provider: string | null;
|
|
243
|
-
stepName: string;
|
|
244
|
-
stepCount: number;
|
|
245
|
-
successCount: number;
|
|
246
|
-
errorCount: number;
|
|
247
|
-
otherCount: number;
|
|
248
|
-
latencyCount: number;
|
|
249
|
-
successRate: number;
|
|
250
|
-
latencyMs: BenchmarkResultLatencySummary;
|
|
251
|
-
}
|
|
252
|
-
interface BenchmarkResultsOverviewInput {
|
|
253
|
-
limit?: number;
|
|
254
|
-
}
|
|
255
|
-
type BenchmarkAnalyticsReadiness = 'ready' | 'complete' | 'partial' | 'pending' | 'unavailable' | 'failed';
|
|
256
|
-
interface BenchmarkRunAnalyticsSummary {
|
|
257
|
-
status: BenchmarkAnalyticsReadiness;
|
|
258
|
-
eventBatches: number;
|
|
259
|
-
persisted: number;
|
|
260
|
-
queued: number;
|
|
261
|
-
failed: number;
|
|
262
|
-
imports: {
|
|
263
|
-
pending: number;
|
|
264
|
-
importing: number;
|
|
265
|
-
imported: number;
|
|
266
|
-
failed: number;
|
|
267
|
-
missing: number;
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
interface BenchmarkResultsOverviewAnalytics {
|
|
271
|
-
status: BenchmarkAnalyticsReadiness;
|
|
272
|
-
query: 'available' | 'unavailable';
|
|
273
|
-
error?: string;
|
|
274
|
-
}
|
|
275
|
-
interface BenchmarkResultsOverviewRun {
|
|
276
|
-
run: BenchmarkRun;
|
|
277
|
-
analytics: BenchmarkRunAnalyticsSummary;
|
|
278
|
-
participants: Array<BenchmarkParticipantResultSummary & {
|
|
279
|
-
runId: string;
|
|
280
|
-
}>;
|
|
281
|
-
}
|
|
282
|
-
interface BenchmarkResultsOverview {
|
|
283
|
-
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name' | 'kind'>;
|
|
284
|
-
generatedAt: string;
|
|
285
|
-
analytics: BenchmarkResultsOverviewAnalytics;
|
|
286
|
-
items: BenchmarkResultsOverviewRun[];
|
|
287
|
-
}
|
|
288
|
-
interface BenchmarkRunResults {
|
|
289
|
-
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name' | 'kind'>;
|
|
290
|
-
run: Pick<BenchmarkRun, 'id' | 'status' | 'totalTasks' | 'workerCount'>;
|
|
291
|
-
generatedAt: string;
|
|
292
|
-
overall: BenchmarkResultSummary;
|
|
293
|
-
participants: BenchmarkParticipantResultSummary[];
|
|
294
|
-
steps: BenchmarkStepResultSummary[];
|
|
295
|
-
}
|
|
296
|
-
interface BenchmarkRunTaskResultsInput {
|
|
297
|
-
bucketSize?: number;
|
|
298
|
-
failureLimit?: number;
|
|
299
|
-
}
|
|
300
|
-
interface BenchmarkTaskBucket {
|
|
301
|
-
participantSlug: string;
|
|
302
|
-
provider: string | null;
|
|
303
|
-
bucketStart: number;
|
|
304
|
-
bucketEnd: number;
|
|
305
|
-
taskIndexMidpoint: number;
|
|
306
|
-
taskCount: number;
|
|
307
|
-
successCount: number;
|
|
308
|
-
errorCount: number;
|
|
309
|
-
latencyMs: Pick<BenchmarkResultLatencySummary, 'p50' | 'p95' | 'max'>;
|
|
310
|
-
}
|
|
311
|
-
interface BenchmarkFailurePoint {
|
|
312
|
-
participantSlug: string;
|
|
313
|
-
provider: string | null;
|
|
314
|
-
taskIndex: number;
|
|
315
|
-
errorCode: string | null;
|
|
316
|
-
}
|
|
317
|
-
interface BenchmarkRunTaskResults {
|
|
318
|
-
run: {
|
|
319
|
-
id: string;
|
|
320
|
-
};
|
|
321
|
-
generatedAt: string;
|
|
322
|
-
bucketSize: number;
|
|
323
|
-
buckets: BenchmarkTaskBucket[];
|
|
324
|
-
failures: BenchmarkFailurePoint[];
|
|
325
|
-
}
|
|
326
|
-
interface BenchmarkRunTimelineInput {
|
|
327
|
-
bucketMs?: number;
|
|
328
|
-
}
|
|
329
|
-
interface BenchmarkEventRateBucket {
|
|
330
|
-
participantSlug: string;
|
|
331
|
-
provider: string | null;
|
|
332
|
-
tMs: number;
|
|
333
|
-
completed: number;
|
|
334
|
-
succeeded: number;
|
|
335
|
-
failed: number;
|
|
336
|
-
}
|
|
337
|
-
interface BenchmarkConcurrencyPoint {
|
|
338
|
-
participantSlug: string;
|
|
339
|
-
provider: string | null;
|
|
340
|
-
workerId: string;
|
|
341
|
-
recordedAt: string;
|
|
342
|
-
tMs: number;
|
|
343
|
-
step: string;
|
|
344
|
-
active: number;
|
|
345
|
-
target: number;
|
|
346
|
-
}
|
|
347
|
-
interface BenchmarkRunTimeline {
|
|
348
|
-
run: {
|
|
349
|
-
id: string;
|
|
350
|
-
};
|
|
351
|
-
generatedAt: string;
|
|
352
|
-
eventRate: {
|
|
353
|
-
bucketMs: number;
|
|
354
|
-
buckets: BenchmarkEventRateBucket[];
|
|
355
|
-
};
|
|
356
|
-
concurrency: {
|
|
357
|
-
firstRecordedAt: string | null;
|
|
358
|
-
heartbeatCount: number;
|
|
359
|
-
points: BenchmarkConcurrencyPoint[];
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
interface BenchmarkRunImportsSummary {
|
|
363
|
-
eventBatches: number;
|
|
364
|
-
persisted: number;
|
|
365
|
-
queued: number;
|
|
366
|
-
failed: number;
|
|
367
|
-
imports: {
|
|
368
|
-
pending: number;
|
|
369
|
-
importing: number;
|
|
370
|
-
imported: number;
|
|
371
|
-
failed: number;
|
|
372
|
-
missing: number;
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
interface BenchmarkRunImportItem {
|
|
376
|
-
eventBatchId: string;
|
|
377
|
-
batchType: string;
|
|
378
|
-
sequenceNumber: number;
|
|
379
|
-
batchStatus: string;
|
|
380
|
-
eventCount: number;
|
|
381
|
-
objectKey: string | null;
|
|
382
|
-
batchErrorMessage: string | null;
|
|
383
|
-
createdAt: string;
|
|
384
|
-
persistedAt: string | null;
|
|
385
|
-
sink: string | null;
|
|
386
|
-
importStatus: string | null;
|
|
387
|
-
importAttempts: number | null;
|
|
388
|
-
importedAt: string | null;
|
|
389
|
-
failedAt: string | null;
|
|
390
|
-
importErrorMessage: string | null;
|
|
391
|
-
}
|
|
392
|
-
interface BenchmarkRunImports {
|
|
393
|
-
run: {
|
|
394
|
-
id: string;
|
|
395
|
-
};
|
|
396
|
-
generatedAt: string;
|
|
397
|
-
summary: BenchmarkRunImportsSummary;
|
|
398
|
-
items: BenchmarkRunImportItem[];
|
|
399
|
-
}
|
|
400
|
-
interface WorkerConcurrencySample {
|
|
401
|
-
step: string;
|
|
402
|
-
active: number;
|
|
403
|
-
target: number;
|
|
404
|
-
}
|
|
405
|
-
interface WorkerHeartbeatInput {
|
|
406
|
-
attemptId: string;
|
|
407
|
-
progressDone?: number;
|
|
408
|
-
progressInFlight?: number;
|
|
409
|
-
progressErrors?: number;
|
|
410
|
-
progressTotal?: number;
|
|
411
|
-
currentStep?: string | null;
|
|
412
|
-
concurrency?: WorkerConcurrencySample[];
|
|
413
|
-
}
|
|
414
|
-
interface RunProgressConcurrency {
|
|
415
|
-
step: string;
|
|
416
|
-
active: number;
|
|
417
|
-
target: number;
|
|
418
|
-
ready: boolean;
|
|
419
|
-
freshWorkerCount: number;
|
|
420
|
-
}
|
|
421
|
-
type RunProgressStatus = 'planned' | 'in_progress' | 'completed' | 'failed';
|
|
422
|
-
interface RunProgressWorkerCounts {
|
|
423
|
-
pending: number;
|
|
424
|
-
running: number;
|
|
425
|
-
completed: number;
|
|
426
|
-
failed: number;
|
|
427
|
-
stale: number;
|
|
428
|
-
total: number;
|
|
429
|
-
}
|
|
430
|
-
interface RunProgressTaskCounts {
|
|
431
|
-
done: number;
|
|
432
|
-
inFlight: number;
|
|
433
|
-
errors: number;
|
|
434
|
-
total: number;
|
|
435
|
-
completionRatio: number;
|
|
436
|
-
}
|
|
437
|
-
interface RunProgressParticipantCounts {
|
|
438
|
-
planned: number;
|
|
439
|
-
inProgress: number;
|
|
440
|
-
completed: number;
|
|
441
|
-
failed: number;
|
|
442
|
-
total: number;
|
|
443
|
-
}
|
|
444
|
-
interface RunProgressSummary {
|
|
445
|
-
status: RunProgressStatus;
|
|
446
|
-
started: boolean;
|
|
447
|
-
completed: boolean;
|
|
448
|
-
participants: RunProgressParticipantCounts;
|
|
449
|
-
}
|
|
450
|
-
interface RunProgressParticipant {
|
|
451
|
-
id: string;
|
|
452
|
-
slug: string;
|
|
453
|
-
provider?: string | null;
|
|
454
|
-
status: RunProgressStatus;
|
|
455
|
-
totalTasks: number;
|
|
456
|
-
workerCount: number;
|
|
457
|
-
workers: RunProgressWorkerCounts;
|
|
458
|
-
tasks: RunProgressTaskCounts;
|
|
459
|
-
concurrency: RunProgressConcurrency[];
|
|
460
|
-
}
|
|
461
|
-
interface RunProgress {
|
|
462
|
-
run: {
|
|
463
|
-
id: string;
|
|
464
|
-
status: string;
|
|
465
|
-
totalTasks: number;
|
|
466
|
-
workerCount: number;
|
|
467
|
-
};
|
|
468
|
-
summary: RunProgressSummary;
|
|
469
|
-
freshnessWindowSeconds: number;
|
|
470
|
-
generatedAt: string;
|
|
471
|
-
participants: RunProgressParticipant[];
|
|
472
|
-
}
|
|
473
|
-
interface RunWorkerContext {
|
|
474
|
-
assignment: BenchmarkAssignment;
|
|
475
|
-
taskIndex: number;
|
|
476
|
-
step<T>(name: string, fn: () => Promise<T> | T, options?: DefineStepOptions): Promise<T>;
|
|
477
|
-
}
|
|
478
|
-
interface WorkerFinishContext {
|
|
479
|
-
assignment: BenchmarkAssignment;
|
|
480
|
-
records: TaskResultRecord[];
|
|
481
|
-
status: 'success' | 'error';
|
|
482
|
-
client: BenchmarkClient;
|
|
483
|
-
uploadArtifact(input: Omit<UploadWorkerArtifactInput, 'attemptId'>): Promise<CreateWorkerArtifactResponse>;
|
|
484
|
-
}
|
|
485
|
-
interface StepContext<TState extends Record<string, unknown> = Record<string, unknown>> {
|
|
486
|
-
assignment: BenchmarkAssignment;
|
|
487
|
-
taskIndex: number;
|
|
488
|
-
state: TState;
|
|
489
|
-
}
|
|
490
|
-
type CleanupContext<TState extends Record<string, unknown> = Record<string, unknown>> = StepContext<TState>;
|
|
491
|
-
interface DefineStepOptions {
|
|
492
|
-
/** Report this step as active in heartbeat concurrency samples. Defaults to true. */
|
|
493
|
-
reportConcurrency?: boolean;
|
|
494
|
-
/** Per-worker target for this step. Defaults to worker concurrency/assignment target. */
|
|
495
|
-
concurrency?: number;
|
|
496
|
-
/** Readiness coordination mode. Defaults to internal. */
|
|
497
|
-
readiness?: 'poll' | 'internal';
|
|
498
|
-
/** Poll interval while waiting for readiness. Defaults to 1000ms. */
|
|
499
|
-
readyPollIntervalMs?: number;
|
|
500
|
-
/** Maximum time to wait for readiness. Defaults to no timeout. */
|
|
501
|
-
readyTimeoutMs?: number;
|
|
502
|
-
}
|
|
503
|
-
interface DefinedStep<TState extends Record<string, unknown> = Record<string, unknown>> {
|
|
504
|
-
name: string;
|
|
505
|
-
options?: DefineStepOptions;
|
|
506
|
-
fn: (context: StepContext<TState>) => Promise<JsonObject | void> | JsonObject | void;
|
|
507
|
-
}
|
|
508
|
-
interface DefineTaskOptions<TState extends Record<string, unknown> = Record<string, unknown>> {
|
|
509
|
-
/**
|
|
510
|
-
* Runs after the task finishes, whether it succeeded or failed.
|
|
511
|
-
* Use this to tear down resources stored in task state.
|
|
512
|
-
*/
|
|
513
|
-
cleanup?: (context: CleanupContext<TState>) => Promise<void> | void;
|
|
514
|
-
}
|
|
515
|
-
interface DefinedTask<TState extends Record<string, unknown> = Record<string, unknown>> {
|
|
516
|
-
name: string;
|
|
517
|
-
steps: DefinedStep<TState>[];
|
|
518
|
-
options?: DefineTaskOptions<TState>;
|
|
519
|
-
}
|
|
520
|
-
type TaskFunction = (context: RunWorkerContext) => Promise<JsonObject | void> | JsonObject | void;
|
|
521
|
-
type WorkerTask = DefinedTask | TaskFunction;
|
|
522
|
-
interface RunWorkerResult {
|
|
523
|
-
assignment: BenchmarkAssignment | null;
|
|
524
|
-
records: TaskResultRecord[];
|
|
525
|
-
}
|
|
526
|
-
interface RunWorkerOptions {
|
|
527
|
-
benchmarkSlug: string;
|
|
528
|
-
runId: string;
|
|
529
|
-
participantSlug: string;
|
|
530
|
-
processKind?: string;
|
|
531
|
-
processKey?: string;
|
|
532
|
-
concurrency?: number;
|
|
533
|
-
batchSize?: number;
|
|
534
|
-
flushIntervalMs?: number;
|
|
535
|
-
heartbeatIntervalMs?: number;
|
|
536
|
-
readyPollIntervalMs?: number;
|
|
537
|
-
onResult?: (record: TaskResultRecord) => void;
|
|
538
|
-
/** Runs once after final result flush and before worker completion/failure is reported. */
|
|
539
|
-
onFinish?: (context: WorkerFinishContext) => Promise<void> | void;
|
|
540
|
-
task: WorkerTask;
|
|
541
|
-
}
|
|
542
|
-
interface WorkerDefaults {
|
|
543
|
-
concurrency?: number;
|
|
544
|
-
batchSize?: number;
|
|
545
|
-
flushIntervalMs?: number;
|
|
546
|
-
heartbeatIntervalMs?: number;
|
|
547
|
-
readyPollIntervalMs?: number;
|
|
548
|
-
}
|
|
549
|
-
interface DefineWorkerOptions extends WorkerDefaults {
|
|
550
|
-
benchmarkSlug: string;
|
|
551
|
-
runId: string;
|
|
552
|
-
participantSlug: string;
|
|
553
|
-
processKind?: string;
|
|
554
|
-
processKey?: string;
|
|
555
|
-
client?: BenchmarkClient;
|
|
556
|
-
onFinish?: RunWorkerOptions['onFinish'];
|
|
557
|
-
task: WorkerTask;
|
|
558
|
-
}
|
|
559
|
-
interface BenchmarkWorker {
|
|
560
|
-
run(overrides?: Partial<WorkerDefaults>): Promise<RunWorkerResult>;
|
|
561
|
-
}
|
|
562
|
-
interface DefineBenchOptions extends WorkerDefaults {
|
|
563
|
-
slug: string;
|
|
564
|
-
participantSlug?: string;
|
|
565
|
-
client?: BenchmarkClient;
|
|
566
|
-
task: WorkerTask;
|
|
567
|
-
}
|
|
568
|
-
interface BenchDefinition {
|
|
569
|
-
slug: string;
|
|
570
|
-
task: WorkerTask;
|
|
571
|
-
defineWorker(options: Omit<DefineWorkerOptions, 'benchmarkSlug' | 'client' | 'task' | 'participantSlug'> & {
|
|
572
|
-
client?: BenchmarkClient;
|
|
573
|
-
participantSlug?: string;
|
|
574
|
-
task?: WorkerTask;
|
|
575
|
-
}): BenchmarkWorker;
|
|
576
|
-
}
|
|
577
|
-
interface BenchmarkClient {
|
|
578
|
-
upsertBenchmark(slug: string, input: UpsertBenchmarkInput): Promise<BenchmarkResource>;
|
|
579
|
-
updateBenchmark(slug: string, input: UpdateBenchmarkInput): Promise<BenchmarkResource>;
|
|
580
|
-
getBenchmark(slug: string): Promise<BenchmarkResource>;
|
|
581
|
-
listBenchmarks(): Promise<BenchmarkResource[]>;
|
|
582
|
-
createRun(benchmarkSlug: string, input: CreateRunInput): Promise<{
|
|
583
|
-
run: BenchmarkRun;
|
|
584
|
-
participants: BenchmarkParticipant[];
|
|
585
|
-
}>;
|
|
586
|
-
listRuns(benchmarkSlug: string): Promise<BenchmarkRun[]>;
|
|
587
|
-
getRun(benchmarkSlug: string, runId: string): Promise<BenchmarkRun>;
|
|
588
|
-
updateRun(benchmarkSlug: string, runId: string, input: UpdateRunInput): Promise<BenchmarkRun>;
|
|
589
|
-
upsertParticipant(benchmarkSlug: string, runId: string, participantSlug: string, input?: UpsertParticipantInput): Promise<BenchmarkParticipant>;
|
|
590
|
-
updateParticipant(benchmarkSlug: string, runId: string, participantSlug: string, input: UpdateParticipantInput): Promise<BenchmarkParticipant>;
|
|
591
|
-
listParticipants(benchmarkSlug: string, runId: string): Promise<BenchmarkParticipant[]>;
|
|
592
|
-
getParticipant(benchmarkSlug: string, runId: string, participantSlug: string): Promise<BenchmarkParticipant>;
|
|
593
|
-
listWorkers(benchmarkSlug: string, runId: string, participantSlug: string): Promise<BenchmarkRunWorker[]>;
|
|
594
|
-
planWorkers(benchmarkSlug: string, runId: string, participantSlug: string, input?: PlanWorkersInput): Promise<BenchmarkRunWorker[]>;
|
|
595
|
-
getWorker(benchmarkSlug: string, runId: string, workerId: string): Promise<BenchmarkRunWorker>;
|
|
596
|
-
updateWorker(benchmarkSlug: string, runId: string, workerId: string, input: UpdateWorkerInput): Promise<BenchmarkRunWorker>;
|
|
597
|
-
getRunProgress(benchmarkSlug: string, runId: string): Promise<RunProgress>;
|
|
598
|
-
claimWorker(benchmarkSlug: string, runId: string, participantSlug: string, input?: ClaimWorkerInput): Promise<BenchmarkAssignment | null>;
|
|
599
|
-
releaseWorker(benchmarkSlug: string, runId: string, workerId: string, attemptId: string): Promise<{
|
|
600
|
-
worker: BenchmarkRunWorker;
|
|
601
|
-
attempt: BenchmarkWorkerAttempt;
|
|
602
|
-
}>;
|
|
603
|
-
sendTaskResults(input: SendTaskResultsInput): Promise<TaskResultsResponse>;
|
|
604
|
-
heartbeatWorker(benchmarkSlug: string, runId: string, workerId: string, input: WorkerHeartbeatInput): Promise<{
|
|
605
|
-
worker: BenchmarkRunWorker;
|
|
606
|
-
attempt: BenchmarkWorkerAttempt;
|
|
607
|
-
}>;
|
|
608
|
-
completeWorker(benchmarkSlug: string, runId: string, workerId: string, attemptId: string): Promise<{
|
|
609
|
-
worker: BenchmarkRunWorker;
|
|
610
|
-
attempt: BenchmarkWorkerAttempt;
|
|
611
|
-
}>;
|
|
612
|
-
failWorker(benchmarkSlug: string, runId: string, workerId: string, attemptId: string, error?: unknown): Promise<{
|
|
613
|
-
worker: BenchmarkRunWorker;
|
|
614
|
-
attempt: BenchmarkWorkerAttempt;
|
|
615
|
-
}>;
|
|
616
|
-
createWorkerArtifact(benchmarkSlug: string, runId: string, workerId: string, input: CreateWorkerArtifactInput): Promise<CreateWorkerArtifactResponse>;
|
|
617
|
-
uploadWorkerArtifact(benchmarkSlug: string, runId: string, workerId: string, input: UploadWorkerArtifactInput): Promise<CreateWorkerArtifactResponse>;
|
|
618
|
-
listRunArtifacts(benchmarkSlug: string, runId: string): Promise<BenchmarkArtifact[]>;
|
|
619
|
-
listWorkerArtifacts(benchmarkSlug: string, runId: string, workerId: string): Promise<BenchmarkArtifact[]>;
|
|
620
|
-
getBenchmarkResults(benchmarkSlug: string, input?: BenchmarkResultsOverviewInput): Promise<BenchmarkResultsOverview>;
|
|
621
|
-
getRunResults(benchmarkSlug: string, runId: string): Promise<BenchmarkRunResults>;
|
|
622
|
-
getRunTaskResults(benchmarkSlug: string, runId: string, input?: BenchmarkRunTaskResultsInput): Promise<BenchmarkRunTaskResults>;
|
|
623
|
-
getRunTimeline(benchmarkSlug: string, runId: string, input?: BenchmarkRunTimelineInput): Promise<BenchmarkRunTimeline>;
|
|
624
|
-
getRunImports(benchmarkSlug: string, runId: string): Promise<BenchmarkRunImports>;
|
|
1
|
+
import { BenchmarkClient as BenchmarkClient$1, RunWorkerOptions, RunWorkerResult, BenchmarkClientConfig } from '@benchsdk/api';
|
|
2
|
+
export { BenchmarkAnalyticsReadiness, BenchmarkApiError, BenchmarkArtifact, BenchmarkArtifactDownload, BenchmarkAssignment, BenchmarkClientConfig, BenchmarkConcurrencyPoint, BenchmarkEventRateBucket, BenchmarkFailurePoint, BenchmarkLogLevel, BenchmarkLogOptions, BenchmarkParticipant, BenchmarkResource, BenchmarkResultLatencySummary, BenchmarkResultSummary, BenchmarkResultsOverview, BenchmarkResultsOverviewAnalytics, BenchmarkResultsOverviewInput, BenchmarkResultsOverviewRun, BenchmarkRun, BenchmarkRunAnalyticsSummary, BenchmarkRunImportItem, BenchmarkRunImports, BenchmarkRunImportsSummary, BenchmarkRunResults, BenchmarkRunStatus, BenchmarkRunSummaryInput, BenchmarkRunSummaryMetric, BenchmarkRunSummaryResult, BenchmarkRunSummaryRunMetadata, BenchmarkRunSummaryScalar, BenchmarkRunTaskResults, BenchmarkRunTaskResultsInput, BenchmarkRunTimeline, BenchmarkRunTimelineInput, BenchmarkRunWorker, BenchmarkStepOutcome, BenchmarkStepResultSummary, BenchmarkTaskBucket, BenchmarkWorkerAttempt, BenchmarkWorkerStatus, ClaimWorkerInput, CreateRunInput, CreateWorkerArtifactInput, CreateWorkerArtifactResponse, DefineStepOptions, JsonObject, JsonValue, PlanWorkersInput, RunProgress, RunProgressConcurrency, RunProgressParticipant, RunProgressParticipantCounts, RunProgressStatus, RunProgressSummary, RunProgressTaskCounts, RunProgressWorkerCounts, RunWorkerContext, RunWorkerOptions, RunWorkerResult, SendTaskResultsInput, TaskFunction, TaskResultRecord, TaskResultsResponse, TaskStepRecord, UpdateBenchmarkInput, UpdateParticipantInput, UpdateRunInput, UpdateWorkerInput, UploadWorkerArtifactInput, UpsertBenchmarkInput, UpsertParticipantInput, WorkerConcurrencySample, WorkerFinishContext, WorkerHeartbeatInput } from '@benchsdk/api';
|
|
3
|
+
export { BaseParticipant, BenchmarkReporter, BenchmarkReporterArtifactInput, BenchmarkReporterBarrierInput, BenchmarkReporterBarrierResult, BenchmarkReporterConfig, BenchmarkReporterHeartbeatInput, BenchmarkReporterProgress, BenchmarkSystemMetricsCollector, BenchmarkSystemMetricsSample, claimBenchmarkReporter, createSystemMetricsCollector, filterParticipantsByEnv, runWorker, selectParticipants } from '@benchsdk/worker';
|
|
4
|
+
|
|
5
|
+
type BenchmarkClient = BenchmarkClient$1 & {
|
|
625
6
|
runWorker(options: RunWorkerOptions): Promise<RunWorkerResult>;
|
|
626
|
-
}
|
|
7
|
+
};
|
|
627
8
|
|
|
628
|
-
declare class BenchmarkApiError extends Error {
|
|
629
|
-
readonly status: number;
|
|
630
|
-
readonly body: string;
|
|
631
|
-
constructor(message: string, status: number, body: string);
|
|
632
|
-
}
|
|
633
9
|
declare function createBenchmarkClient(config?: BenchmarkClientConfig): BenchmarkClient;
|
|
634
|
-
declare function runBenchmarkWorker(config: BenchmarkClientConfig, options: RunWorkerOptions): Promise<RunWorkerResult>;
|
|
635
|
-
declare function defineStep<TState extends Record<string, unknown> = Record<string, unknown>>(name: string, optionsOrFn: DefineStepOptions | DefinedStep<TState>['fn'], maybeFn?: DefinedStep<TState>['fn']): DefinedStep<TState>;
|
|
636
|
-
declare function defineTask<TState extends Record<string, unknown> = Record<string, unknown>>(name: string, steps: DefinedStep<TState>[], options?: DefineTaskOptions<TState>): DefinedTask<TState>;
|
|
637
|
-
declare function defineWorker(options: DefineWorkerOptions): BenchmarkWorker;
|
|
638
|
-
declare function defineBench(options: DefineBenchOptions): BenchDefinition;
|
|
639
|
-
|
|
640
|
-
interface BenchmarkReporterConfig extends BenchmarkClientConfig {
|
|
641
|
-
benchmarkSlug: string;
|
|
642
|
-
runId: string;
|
|
643
|
-
participantSlug: string;
|
|
644
|
-
processKind?: string;
|
|
645
|
-
processKey?: string;
|
|
646
|
-
batchSize?: number;
|
|
647
|
-
}
|
|
648
|
-
interface BenchmarkReporterProgress {
|
|
649
|
-
done: number;
|
|
650
|
-
inFlight: number;
|
|
651
|
-
errors: number;
|
|
652
|
-
total?: number;
|
|
653
|
-
}
|
|
654
|
-
interface BenchmarkReporterArtifactInput {
|
|
655
|
-
kind: string;
|
|
656
|
-
name?: string;
|
|
657
|
-
contentType?: string;
|
|
658
|
-
body: BodyInit;
|
|
659
|
-
metadata?: JsonObject;
|
|
660
|
-
}
|
|
661
|
-
interface BenchmarkReporterHeartbeatInput {
|
|
662
|
-
currentStep?: string | null;
|
|
663
|
-
concurrency?: WorkerConcurrencySample[];
|
|
664
|
-
}
|
|
665
|
-
interface BenchmarkReporterBarrierInput {
|
|
666
|
-
step: string;
|
|
667
|
-
timeoutMs?: number;
|
|
668
|
-
pollIntervalMs?: number;
|
|
669
|
-
active?: number;
|
|
670
|
-
target?: number;
|
|
671
|
-
concurrency?: WorkerConcurrencySample[];
|
|
672
|
-
}
|
|
673
|
-
interface BenchmarkReporterBarrierResult {
|
|
674
|
-
active: number | null;
|
|
675
|
-
target: number | null;
|
|
676
|
-
ready: boolean;
|
|
677
|
-
measuredAt: string;
|
|
678
|
-
}
|
|
679
|
-
declare class BenchmarkReporter {
|
|
680
|
-
private readonly client;
|
|
681
|
-
private readonly assignment;
|
|
682
|
-
private readonly cfg;
|
|
683
|
-
private pending;
|
|
684
|
-
private sequenceNumber;
|
|
685
|
-
private flushChain;
|
|
686
|
-
private progress;
|
|
687
|
-
private barrier;
|
|
688
|
-
private constructor();
|
|
689
|
-
static claim(cfg: BenchmarkReporterConfig): Promise<BenchmarkReporter | null>;
|
|
690
|
-
get workerAssignment(): BenchmarkAssignment;
|
|
691
|
-
get taskCount(): number;
|
|
692
|
-
get taskIndexStart(): number;
|
|
693
|
-
setProgress(progress: BenchmarkReporterProgress): void;
|
|
694
|
-
recordResult(record: TaskResultRecord): void;
|
|
695
|
-
heartbeat(input?: BenchmarkReporterHeartbeatInput): Promise<void>;
|
|
696
|
-
waitForStepReady(input: BenchmarkReporterBarrierInput): Promise<BenchmarkReporterBarrierResult>;
|
|
697
|
-
uploadArtifact(input: BenchmarkReporterArtifactInput): Promise<CreateWorkerArtifactResponse | null>;
|
|
698
|
-
flush(isFinal?: boolean): Promise<void>;
|
|
699
|
-
finish(failed?: boolean, error?: unknown): Promise<void>;
|
|
700
|
-
}
|
|
701
|
-
declare function claimBenchmarkReporter(config: BenchmarkReporterConfig): Promise<BenchmarkReporter | null>;
|
|
702
|
-
|
|
703
|
-
interface BenchmarkSystemMetricsSample {
|
|
704
|
-
ts: string;
|
|
705
|
-
uptimeMs: number;
|
|
706
|
-
cpuUserUs: number;
|
|
707
|
-
cpuSystemUs: number;
|
|
708
|
-
memRssMb: number;
|
|
709
|
-
memHeapUsedMb: number;
|
|
710
|
-
memHeapTotalMb: number;
|
|
711
|
-
memExternalMb: number;
|
|
712
|
-
eventLoopP50Ms: number;
|
|
713
|
-
eventLoopP99Ms: number;
|
|
714
|
-
eventLoopMaxMs: number;
|
|
715
|
-
loadavg1m: number;
|
|
716
|
-
loadavg5m: number;
|
|
717
|
-
loadavg15m: number;
|
|
718
|
-
openFds: number | null;
|
|
719
|
-
sockstat: Record<string, number> | null;
|
|
720
|
-
}
|
|
721
|
-
interface BenchmarkSystemMetricsCollector {
|
|
722
|
-
sample(): BenchmarkSystemMetricsSample;
|
|
723
|
-
stop(): void;
|
|
724
|
-
}
|
|
725
|
-
declare function createSystemMetricsCollector(): BenchmarkSystemMetricsCollector;
|
|
726
10
|
|
|
727
|
-
export { type
|
|
11
|
+
export { type BenchmarkClient, createBenchmarkClient };
|