@benchsdk/client 0.2.1 → 0.3.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 +41 -96
- package/dist/index.cjs +125 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -73
- package/dist/index.d.ts +106 -73
- package/dist/index.js +123 -135
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,6 @@ interface BenchmarkResource {
|
|
|
14
14
|
id: string;
|
|
15
15
|
slug: string;
|
|
16
16
|
name: string;
|
|
17
|
-
kind?: string | null;
|
|
18
17
|
status?: string;
|
|
19
18
|
config?: JsonObject;
|
|
20
19
|
defaultRunConfig?: JsonObject;
|
|
@@ -26,7 +25,11 @@ interface BenchmarkRun {
|
|
|
26
25
|
benchmarkId: string;
|
|
27
26
|
name?: string | null;
|
|
28
27
|
status: BenchmarkRunStatus | string;
|
|
28
|
+
/** Idempotency key: runs created with the same key (per org + benchmark) are the same run. */
|
|
29
|
+
runKey?: string | null;
|
|
29
30
|
totalTasks: number;
|
|
31
|
+
/** The run declared no size: `totalTasks` is the sum of what its participants declare. */
|
|
32
|
+
participantSized?: boolean;
|
|
30
33
|
workerCount: number;
|
|
31
34
|
config?: JsonObject;
|
|
32
35
|
createdAt?: string;
|
|
@@ -93,27 +96,29 @@ interface BenchmarkAssignment {
|
|
|
93
96
|
}
|
|
94
97
|
interface UpsertBenchmarkInput {
|
|
95
98
|
name: string;
|
|
96
|
-
kind?: string;
|
|
97
99
|
status?: string;
|
|
98
100
|
config?: JsonObject;
|
|
99
101
|
defaultRunConfig?: JsonObject;
|
|
100
102
|
}
|
|
101
103
|
interface UpdateBenchmarkInput {
|
|
102
104
|
name?: string;
|
|
103
|
-
kind?: string;
|
|
104
105
|
status?: string;
|
|
105
106
|
config?: JsonObject;
|
|
106
107
|
defaultRunConfig?: JsonObject;
|
|
107
108
|
}
|
|
108
109
|
interface CreateRunInput {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Idempotency key for get-or-create: sibling callers passing the same key
|
|
112
|
+
* (per org + benchmark) converge on one run instead of each opening its own.
|
|
113
|
+
*/
|
|
114
|
+
runKey?: string;
|
|
115
|
+
/** Omit to open a participant-sized run: each participant declares its own size when it registers. */
|
|
116
|
+
totalTasks?: number;
|
|
117
|
+
workerCount?: number;
|
|
112
118
|
participants?: string[];
|
|
113
119
|
config?: JsonObject;
|
|
114
120
|
}
|
|
115
121
|
interface UpdateRunInput {
|
|
116
|
-
name?: string;
|
|
117
122
|
status?: BenchmarkRunStatus;
|
|
118
123
|
config?: JsonObject;
|
|
119
124
|
}
|
|
@@ -161,6 +166,10 @@ interface TaskStepRecord {
|
|
|
161
166
|
latencyMs?: number;
|
|
162
167
|
errorCode?: string | null;
|
|
163
168
|
data?: JsonObject;
|
|
169
|
+
/** Number of parallel invocations requested for this step. */
|
|
170
|
+
concurrency?: number;
|
|
171
|
+
/** Per-iteration timeout in milliseconds applied to this step. */
|
|
172
|
+
timeoutMs?: number;
|
|
164
173
|
}
|
|
165
174
|
interface SendTaskResultsInput {
|
|
166
175
|
benchmarkSlug: string;
|
|
@@ -280,13 +289,13 @@ interface BenchmarkResultsOverviewRun {
|
|
|
280
289
|
}>;
|
|
281
290
|
}
|
|
282
291
|
interface BenchmarkResultsOverview {
|
|
283
|
-
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'
|
|
292
|
+
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'>;
|
|
284
293
|
generatedAt: string;
|
|
285
294
|
analytics: BenchmarkResultsOverviewAnalytics;
|
|
286
295
|
items: BenchmarkResultsOverviewRun[];
|
|
287
296
|
}
|
|
288
297
|
interface BenchmarkRunResults {
|
|
289
|
-
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'
|
|
298
|
+
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'>;
|
|
290
299
|
run: Pick<BenchmarkRun, 'id' | 'status' | 'totalTasks' | 'workerCount'>;
|
|
291
300
|
generatedAt: string;
|
|
292
301
|
overall: BenchmarkResultSummary;
|
|
@@ -474,6 +483,15 @@ interface RunWorkerContext {
|
|
|
474
483
|
assignment: BenchmarkAssignment;
|
|
475
484
|
taskIndex: number;
|
|
476
485
|
step<T>(name: string, fn: () => Promise<T> | T, options?: DefineStepOptions): Promise<T>;
|
|
486
|
+
/**
|
|
487
|
+
* Attaches a JSON measurement to the platform. Called inside a `step`, it
|
|
488
|
+
* lands on that step's `data`; called at task top-level, on the task record's
|
|
489
|
+
* `data`. Repeated calls merge (shallow). Use this for anything you want on
|
|
490
|
+
* the platform — step return values are control flow and are never recorded.
|
|
491
|
+
*/
|
|
492
|
+
measure(data: JsonObject): void;
|
|
493
|
+
/** Appends a line to the worker log, uploaded as an artifact when the worker finishes. */
|
|
494
|
+
log(message: string, meta?: JsonObject): void;
|
|
477
495
|
}
|
|
478
496
|
interface WorkerFinishContext {
|
|
479
497
|
assignment: BenchmarkAssignment;
|
|
@@ -482,17 +500,15 @@ interface WorkerFinishContext {
|
|
|
482
500
|
client: BenchmarkClient;
|
|
483
501
|
uploadArtifact(input: Omit<UploadWorkerArtifactInput, 'attemptId'>): Promise<CreateWorkerArtifactResponse>;
|
|
484
502
|
}
|
|
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
503
|
interface DefineStepOptions {
|
|
492
504
|
/** Report this step as active in heartbeat concurrency samples. Defaults to true. */
|
|
493
505
|
reportConcurrency?: boolean;
|
|
494
506
|
/** Per-worker target for this step. Defaults to worker concurrency/assignment target. */
|
|
495
507
|
concurrency?: number;
|
|
508
|
+
/** Number of parallel invocations the step function should run internally. Used by the runner to record step-level concurrency. */
|
|
509
|
+
stepConcurrency?: number;
|
|
510
|
+
/** Per-invocation timeout in milliseconds for this step. Used by the runner to record step-level timeout metadata. */
|
|
511
|
+
timeoutMs?: number;
|
|
496
512
|
/** Readiness coordination mode. Defaults to internal. */
|
|
497
513
|
readiness?: 'poll' | 'internal';
|
|
498
514
|
/** Poll interval while waiting for readiness. Defaults to 1000ms. */
|
|
@@ -500,25 +516,13 @@ interface DefineStepOptions {
|
|
|
500
516
|
/** Maximum time to wait for readiness. Defaults to no timeout. */
|
|
501
517
|
readyTimeoutMs?: number;
|
|
502
518
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
}
|
|
519
|
+
/**
|
|
520
|
+
* The unit of work a worker runs, once per task index. Steps are declared
|
|
521
|
+
* imperatively via `context.step(...)`; this is the sole task shape the worker
|
|
522
|
+
* engine accepts. Higher-level authoring (`defineTask`) lives in
|
|
523
|
+
* `@benchsdk/runner`, which compiles down to a function of this shape.
|
|
524
|
+
*/
|
|
520
525
|
type TaskFunction = (context: RunWorkerContext) => Promise<JsonObject | void> | JsonObject | void;
|
|
521
|
-
type WorkerTask = DefinedTask | TaskFunction;
|
|
522
526
|
interface RunWorkerResult {
|
|
523
527
|
assignment: BenchmarkAssignment | null;
|
|
524
528
|
records: TaskResultRecord[];
|
|
@@ -537,42 +541,42 @@ interface RunWorkerOptions {
|
|
|
537
541
|
onResult?: (record: TaskResultRecord) => void;
|
|
538
542
|
/** Runs once after final result flush and before worker completion/failure is reported. */
|
|
539
543
|
onFinish?: (context: WorkerFinishContext) => Promise<void> | void;
|
|
540
|
-
task:
|
|
544
|
+
task: TaskFunction;
|
|
541
545
|
}
|
|
542
|
-
interface
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
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;
|
|
546
|
+
interface BenchmarkRunSummaryMetric {
|
|
547
|
+
name: string;
|
|
548
|
+
unit: string;
|
|
549
|
+
median: number;
|
|
550
|
+
p95: number;
|
|
551
|
+
p99: number;
|
|
567
552
|
}
|
|
568
|
-
interface
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
553
|
+
interface BenchmarkRunSummaryScalar {
|
|
554
|
+
name: string;
|
|
555
|
+
value: number;
|
|
556
|
+
unit: string;
|
|
557
|
+
}
|
|
558
|
+
interface BenchmarkRunSummaryResult {
|
|
559
|
+
provider: string;
|
|
560
|
+
dimensions?: Record<string, unknown>;
|
|
561
|
+
metrics: BenchmarkRunSummaryMetric[];
|
|
562
|
+
scalars?: BenchmarkRunSummaryScalar[];
|
|
563
|
+
compositeScore: number;
|
|
564
|
+
successRate: number;
|
|
565
|
+
scoringVersion?: string | null;
|
|
566
|
+
skipped: boolean;
|
|
567
|
+
skipReason?: string | null;
|
|
568
|
+
}
|
|
569
|
+
interface BenchmarkRunSummaryRunMetadata {
|
|
570
|
+
gitSha?: string;
|
|
571
|
+
gitRef?: string;
|
|
572
|
+
triggeredBy?: string;
|
|
573
|
+
nodeVersion?: string;
|
|
574
|
+
platform?: string;
|
|
575
|
+
arch?: string;
|
|
576
|
+
}
|
|
577
|
+
interface BenchmarkRunSummaryInput {
|
|
578
|
+
run: BenchmarkRunSummaryRunMetadata;
|
|
579
|
+
results: BenchmarkRunSummaryResult[];
|
|
576
580
|
}
|
|
577
581
|
interface BenchmarkClient {
|
|
578
582
|
upsertBenchmark(slug: string, input: UpsertBenchmarkInput): Promise<BenchmarkResource>;
|
|
@@ -582,6 +586,8 @@ interface BenchmarkClient {
|
|
|
582
586
|
createRun(benchmarkSlug: string, input: CreateRunInput): Promise<{
|
|
583
587
|
run: BenchmarkRun;
|
|
584
588
|
participants: BenchmarkParticipant[];
|
|
589
|
+
/** The slug of the org the run was attributed to, resolved server-side from the caller's API key. */
|
|
590
|
+
organizationSlug: string;
|
|
585
591
|
}>;
|
|
586
592
|
listRuns(benchmarkSlug: string): Promise<BenchmarkRun[]>;
|
|
587
593
|
getRun(benchmarkSlug: string, runId: string): Promise<BenchmarkRun>;
|
|
@@ -622,6 +628,7 @@ interface BenchmarkClient {
|
|
|
622
628
|
getRunTaskResults(benchmarkSlug: string, runId: string, input?: BenchmarkRunTaskResultsInput): Promise<BenchmarkRunTaskResults>;
|
|
623
629
|
getRunTimeline(benchmarkSlug: string, runId: string, input?: BenchmarkRunTimelineInput): Promise<BenchmarkRunTimeline>;
|
|
624
630
|
getRunImports(benchmarkSlug: string, runId: string): Promise<BenchmarkRunImports>;
|
|
631
|
+
submitRunSummary(benchmarkSlug: string, runId: string, input: BenchmarkRunSummaryInput): Promise<void>;
|
|
625
632
|
runWorker(options: RunWorkerOptions): Promise<RunWorkerResult>;
|
|
626
633
|
}
|
|
627
634
|
|
|
@@ -631,11 +638,6 @@ declare class BenchmarkApiError extends Error {
|
|
|
631
638
|
constructor(message: string, status: number, body: string);
|
|
632
639
|
}
|
|
633
640
|
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
641
|
|
|
640
642
|
interface BenchmarkReporterConfig extends BenchmarkClientConfig {
|
|
641
643
|
benchmarkSlug: string;
|
|
@@ -724,4 +726,35 @@ interface BenchmarkSystemMetricsCollector {
|
|
|
724
726
|
}
|
|
725
727
|
declare function createSystemMetricsCollector(): BenchmarkSystemMetricsCollector;
|
|
726
728
|
|
|
727
|
-
|
|
729
|
+
/**
|
|
730
|
+
* Base interface for a benchmark participant — the shared shape across all
|
|
731
|
+
* benchmark categories (sandbox, ai-gateway, browser, storage). Each category
|
|
732
|
+
* extends this with its own provider-specific fields.
|
|
733
|
+
*/
|
|
734
|
+
interface BaseParticipant {
|
|
735
|
+
/** Participant name (e.g. 'e2b', 'daytona', 'openrouter') */
|
|
736
|
+
name: string;
|
|
737
|
+
/** Environment variables that must all be set to run this participant */
|
|
738
|
+
requiredEnvVars: string[];
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
/**
|
|
742
|
+
* Filters `participants` down to those whose `requiredEnvVars` are all set
|
|
743
|
+
* in `process.env`. Returns an object `{ available, skipped }` where `skipped`
|
|
744
|
+
* includes the names and missing vars for logging.
|
|
745
|
+
*/
|
|
746
|
+
declare function filterParticipantsByEnv<T extends BaseParticipant>(participants: T[]): {
|
|
747
|
+
available: T[];
|
|
748
|
+
skipped: {
|
|
749
|
+
name: string;
|
|
750
|
+
missing: string[];
|
|
751
|
+
}[];
|
|
752
|
+
};
|
|
753
|
+
/**
|
|
754
|
+
* Filters `all` down to the requested `names`, exiting with a clear error
|
|
755
|
+
* if any name is unrecognized. Returns `all` unchanged when `names` is
|
|
756
|
+
* undefined (no filter specified).
|
|
757
|
+
*/
|
|
758
|
+
declare function selectParticipants<T extends BaseParticipant>(all: T[], names?: string[]): T[];
|
|
759
|
+
|
|
760
|
+
export { type BaseParticipant, type BenchmarkAnalyticsReadiness, BenchmarkApiError, type BenchmarkArtifact, type BenchmarkAssignment, type BenchmarkClient, type BenchmarkClientConfig, type BenchmarkConcurrencyPoint, type BenchmarkEventRateBucket, type BenchmarkFailurePoint, type BenchmarkParticipant, BenchmarkReporter, type BenchmarkReporterArtifactInput, type BenchmarkReporterBarrierInput, type BenchmarkReporterBarrierResult, type BenchmarkReporterConfig, type BenchmarkReporterHeartbeatInput, type BenchmarkReporterProgress, type BenchmarkResource, type BenchmarkResultLatencySummary, type BenchmarkResultSummary, type BenchmarkResultsOverview, type BenchmarkResultsOverviewAnalytics, type BenchmarkResultsOverviewInput, type BenchmarkResultsOverviewRun, type BenchmarkRun, type BenchmarkRunAnalyticsSummary, type BenchmarkRunImportItem, type BenchmarkRunImports, type BenchmarkRunImportsSummary, type BenchmarkRunResults, type BenchmarkRunStatus, type BenchmarkRunSummaryInput, type BenchmarkRunSummaryMetric, type BenchmarkRunSummaryResult, type BenchmarkRunSummaryRunMetadata, type BenchmarkRunSummaryScalar, type BenchmarkRunTaskResults, type BenchmarkRunTaskResultsInput, type BenchmarkRunTimeline, type BenchmarkRunTimelineInput, type BenchmarkRunWorker, type BenchmarkStepResultSummary, type BenchmarkSystemMetricsCollector, type BenchmarkSystemMetricsSample, type BenchmarkTaskBucket, type BenchmarkWorkerAttempt, type BenchmarkWorkerStatus, type ClaimWorkerInput, type CreateRunInput, type CreateWorkerArtifactInput, type CreateWorkerArtifactResponse, type DefineStepOptions, type JsonObject, type JsonValue, type PlanWorkersInput, type RunProgress, type RunProgressConcurrency, type RunProgressParticipant, type RunProgressParticipantCounts, type RunProgressStatus, type RunProgressSummary, type RunProgressTaskCounts, type RunProgressWorkerCounts, type RunWorkerContext, type RunWorkerOptions, type RunWorkerResult, type SendTaskResultsInput, type TaskFunction, type TaskResultRecord, type TaskResultsResponse, type TaskStepRecord, type UpdateBenchmarkInput, type UpdateParticipantInput, type UpdateRunInput, type UpdateWorkerInput, type UploadWorkerArtifactInput, type UpsertBenchmarkInput, type UpsertParticipantInput, type WorkerConcurrencySample, type WorkerFinishContext, type WorkerHeartbeatInput, claimBenchmarkReporter, createBenchmarkClient, createSystemMetricsCollector, filterParticipantsByEnv, selectParticipants };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ interface BenchmarkResource {
|
|
|
14
14
|
id: string;
|
|
15
15
|
slug: string;
|
|
16
16
|
name: string;
|
|
17
|
-
kind?: string | null;
|
|
18
17
|
status?: string;
|
|
19
18
|
config?: JsonObject;
|
|
20
19
|
defaultRunConfig?: JsonObject;
|
|
@@ -26,7 +25,11 @@ interface BenchmarkRun {
|
|
|
26
25
|
benchmarkId: string;
|
|
27
26
|
name?: string | null;
|
|
28
27
|
status: BenchmarkRunStatus | string;
|
|
28
|
+
/** Idempotency key: runs created with the same key (per org + benchmark) are the same run. */
|
|
29
|
+
runKey?: string | null;
|
|
29
30
|
totalTasks: number;
|
|
31
|
+
/** The run declared no size: `totalTasks` is the sum of what its participants declare. */
|
|
32
|
+
participantSized?: boolean;
|
|
30
33
|
workerCount: number;
|
|
31
34
|
config?: JsonObject;
|
|
32
35
|
createdAt?: string;
|
|
@@ -93,27 +96,29 @@ interface BenchmarkAssignment {
|
|
|
93
96
|
}
|
|
94
97
|
interface UpsertBenchmarkInput {
|
|
95
98
|
name: string;
|
|
96
|
-
kind?: string;
|
|
97
99
|
status?: string;
|
|
98
100
|
config?: JsonObject;
|
|
99
101
|
defaultRunConfig?: JsonObject;
|
|
100
102
|
}
|
|
101
103
|
interface UpdateBenchmarkInput {
|
|
102
104
|
name?: string;
|
|
103
|
-
kind?: string;
|
|
104
105
|
status?: string;
|
|
105
106
|
config?: JsonObject;
|
|
106
107
|
defaultRunConfig?: JsonObject;
|
|
107
108
|
}
|
|
108
109
|
interface CreateRunInput {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Idempotency key for get-or-create: sibling callers passing the same key
|
|
112
|
+
* (per org + benchmark) converge on one run instead of each opening its own.
|
|
113
|
+
*/
|
|
114
|
+
runKey?: string;
|
|
115
|
+
/** Omit to open a participant-sized run: each participant declares its own size when it registers. */
|
|
116
|
+
totalTasks?: number;
|
|
117
|
+
workerCount?: number;
|
|
112
118
|
participants?: string[];
|
|
113
119
|
config?: JsonObject;
|
|
114
120
|
}
|
|
115
121
|
interface UpdateRunInput {
|
|
116
|
-
name?: string;
|
|
117
122
|
status?: BenchmarkRunStatus;
|
|
118
123
|
config?: JsonObject;
|
|
119
124
|
}
|
|
@@ -161,6 +166,10 @@ interface TaskStepRecord {
|
|
|
161
166
|
latencyMs?: number;
|
|
162
167
|
errorCode?: string | null;
|
|
163
168
|
data?: JsonObject;
|
|
169
|
+
/** Number of parallel invocations requested for this step. */
|
|
170
|
+
concurrency?: number;
|
|
171
|
+
/** Per-iteration timeout in milliseconds applied to this step. */
|
|
172
|
+
timeoutMs?: number;
|
|
164
173
|
}
|
|
165
174
|
interface SendTaskResultsInput {
|
|
166
175
|
benchmarkSlug: string;
|
|
@@ -280,13 +289,13 @@ interface BenchmarkResultsOverviewRun {
|
|
|
280
289
|
}>;
|
|
281
290
|
}
|
|
282
291
|
interface BenchmarkResultsOverview {
|
|
283
|
-
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'
|
|
292
|
+
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'>;
|
|
284
293
|
generatedAt: string;
|
|
285
294
|
analytics: BenchmarkResultsOverviewAnalytics;
|
|
286
295
|
items: BenchmarkResultsOverviewRun[];
|
|
287
296
|
}
|
|
288
297
|
interface BenchmarkRunResults {
|
|
289
|
-
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'
|
|
298
|
+
benchmark: Pick<BenchmarkResource, 'id' | 'slug' | 'name'>;
|
|
290
299
|
run: Pick<BenchmarkRun, 'id' | 'status' | 'totalTasks' | 'workerCount'>;
|
|
291
300
|
generatedAt: string;
|
|
292
301
|
overall: BenchmarkResultSummary;
|
|
@@ -474,6 +483,15 @@ interface RunWorkerContext {
|
|
|
474
483
|
assignment: BenchmarkAssignment;
|
|
475
484
|
taskIndex: number;
|
|
476
485
|
step<T>(name: string, fn: () => Promise<T> | T, options?: DefineStepOptions): Promise<T>;
|
|
486
|
+
/**
|
|
487
|
+
* Attaches a JSON measurement to the platform. Called inside a `step`, it
|
|
488
|
+
* lands on that step's `data`; called at task top-level, on the task record's
|
|
489
|
+
* `data`. Repeated calls merge (shallow). Use this for anything you want on
|
|
490
|
+
* the platform — step return values are control flow and are never recorded.
|
|
491
|
+
*/
|
|
492
|
+
measure(data: JsonObject): void;
|
|
493
|
+
/** Appends a line to the worker log, uploaded as an artifact when the worker finishes. */
|
|
494
|
+
log(message: string, meta?: JsonObject): void;
|
|
477
495
|
}
|
|
478
496
|
interface WorkerFinishContext {
|
|
479
497
|
assignment: BenchmarkAssignment;
|
|
@@ -482,17 +500,15 @@ interface WorkerFinishContext {
|
|
|
482
500
|
client: BenchmarkClient;
|
|
483
501
|
uploadArtifact(input: Omit<UploadWorkerArtifactInput, 'attemptId'>): Promise<CreateWorkerArtifactResponse>;
|
|
484
502
|
}
|
|
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
503
|
interface DefineStepOptions {
|
|
492
504
|
/** Report this step as active in heartbeat concurrency samples. Defaults to true. */
|
|
493
505
|
reportConcurrency?: boolean;
|
|
494
506
|
/** Per-worker target for this step. Defaults to worker concurrency/assignment target. */
|
|
495
507
|
concurrency?: number;
|
|
508
|
+
/** Number of parallel invocations the step function should run internally. Used by the runner to record step-level concurrency. */
|
|
509
|
+
stepConcurrency?: number;
|
|
510
|
+
/** Per-invocation timeout in milliseconds for this step. Used by the runner to record step-level timeout metadata. */
|
|
511
|
+
timeoutMs?: number;
|
|
496
512
|
/** Readiness coordination mode. Defaults to internal. */
|
|
497
513
|
readiness?: 'poll' | 'internal';
|
|
498
514
|
/** Poll interval while waiting for readiness. Defaults to 1000ms. */
|
|
@@ -500,25 +516,13 @@ interface DefineStepOptions {
|
|
|
500
516
|
/** Maximum time to wait for readiness. Defaults to no timeout. */
|
|
501
517
|
readyTimeoutMs?: number;
|
|
502
518
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
}
|
|
519
|
+
/**
|
|
520
|
+
* The unit of work a worker runs, once per task index. Steps are declared
|
|
521
|
+
* imperatively via `context.step(...)`; this is the sole task shape the worker
|
|
522
|
+
* engine accepts. Higher-level authoring (`defineTask`) lives in
|
|
523
|
+
* `@benchsdk/runner`, which compiles down to a function of this shape.
|
|
524
|
+
*/
|
|
520
525
|
type TaskFunction = (context: RunWorkerContext) => Promise<JsonObject | void> | JsonObject | void;
|
|
521
|
-
type WorkerTask = DefinedTask | TaskFunction;
|
|
522
526
|
interface RunWorkerResult {
|
|
523
527
|
assignment: BenchmarkAssignment | null;
|
|
524
528
|
records: TaskResultRecord[];
|
|
@@ -537,42 +541,42 @@ interface RunWorkerOptions {
|
|
|
537
541
|
onResult?: (record: TaskResultRecord) => void;
|
|
538
542
|
/** Runs once after final result flush and before worker completion/failure is reported. */
|
|
539
543
|
onFinish?: (context: WorkerFinishContext) => Promise<void> | void;
|
|
540
|
-
task:
|
|
544
|
+
task: TaskFunction;
|
|
541
545
|
}
|
|
542
|
-
interface
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
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;
|
|
546
|
+
interface BenchmarkRunSummaryMetric {
|
|
547
|
+
name: string;
|
|
548
|
+
unit: string;
|
|
549
|
+
median: number;
|
|
550
|
+
p95: number;
|
|
551
|
+
p99: number;
|
|
567
552
|
}
|
|
568
|
-
interface
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
553
|
+
interface BenchmarkRunSummaryScalar {
|
|
554
|
+
name: string;
|
|
555
|
+
value: number;
|
|
556
|
+
unit: string;
|
|
557
|
+
}
|
|
558
|
+
interface BenchmarkRunSummaryResult {
|
|
559
|
+
provider: string;
|
|
560
|
+
dimensions?: Record<string, unknown>;
|
|
561
|
+
metrics: BenchmarkRunSummaryMetric[];
|
|
562
|
+
scalars?: BenchmarkRunSummaryScalar[];
|
|
563
|
+
compositeScore: number;
|
|
564
|
+
successRate: number;
|
|
565
|
+
scoringVersion?: string | null;
|
|
566
|
+
skipped: boolean;
|
|
567
|
+
skipReason?: string | null;
|
|
568
|
+
}
|
|
569
|
+
interface BenchmarkRunSummaryRunMetadata {
|
|
570
|
+
gitSha?: string;
|
|
571
|
+
gitRef?: string;
|
|
572
|
+
triggeredBy?: string;
|
|
573
|
+
nodeVersion?: string;
|
|
574
|
+
platform?: string;
|
|
575
|
+
arch?: string;
|
|
576
|
+
}
|
|
577
|
+
interface BenchmarkRunSummaryInput {
|
|
578
|
+
run: BenchmarkRunSummaryRunMetadata;
|
|
579
|
+
results: BenchmarkRunSummaryResult[];
|
|
576
580
|
}
|
|
577
581
|
interface BenchmarkClient {
|
|
578
582
|
upsertBenchmark(slug: string, input: UpsertBenchmarkInput): Promise<BenchmarkResource>;
|
|
@@ -582,6 +586,8 @@ interface BenchmarkClient {
|
|
|
582
586
|
createRun(benchmarkSlug: string, input: CreateRunInput): Promise<{
|
|
583
587
|
run: BenchmarkRun;
|
|
584
588
|
participants: BenchmarkParticipant[];
|
|
589
|
+
/** The slug of the org the run was attributed to, resolved server-side from the caller's API key. */
|
|
590
|
+
organizationSlug: string;
|
|
585
591
|
}>;
|
|
586
592
|
listRuns(benchmarkSlug: string): Promise<BenchmarkRun[]>;
|
|
587
593
|
getRun(benchmarkSlug: string, runId: string): Promise<BenchmarkRun>;
|
|
@@ -622,6 +628,7 @@ interface BenchmarkClient {
|
|
|
622
628
|
getRunTaskResults(benchmarkSlug: string, runId: string, input?: BenchmarkRunTaskResultsInput): Promise<BenchmarkRunTaskResults>;
|
|
623
629
|
getRunTimeline(benchmarkSlug: string, runId: string, input?: BenchmarkRunTimelineInput): Promise<BenchmarkRunTimeline>;
|
|
624
630
|
getRunImports(benchmarkSlug: string, runId: string): Promise<BenchmarkRunImports>;
|
|
631
|
+
submitRunSummary(benchmarkSlug: string, runId: string, input: BenchmarkRunSummaryInput): Promise<void>;
|
|
625
632
|
runWorker(options: RunWorkerOptions): Promise<RunWorkerResult>;
|
|
626
633
|
}
|
|
627
634
|
|
|
@@ -631,11 +638,6 @@ declare class BenchmarkApiError extends Error {
|
|
|
631
638
|
constructor(message: string, status: number, body: string);
|
|
632
639
|
}
|
|
633
640
|
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
641
|
|
|
640
642
|
interface BenchmarkReporterConfig extends BenchmarkClientConfig {
|
|
641
643
|
benchmarkSlug: string;
|
|
@@ -724,4 +726,35 @@ interface BenchmarkSystemMetricsCollector {
|
|
|
724
726
|
}
|
|
725
727
|
declare function createSystemMetricsCollector(): BenchmarkSystemMetricsCollector;
|
|
726
728
|
|
|
727
|
-
|
|
729
|
+
/**
|
|
730
|
+
* Base interface for a benchmark participant — the shared shape across all
|
|
731
|
+
* benchmark categories (sandbox, ai-gateway, browser, storage). Each category
|
|
732
|
+
* extends this with its own provider-specific fields.
|
|
733
|
+
*/
|
|
734
|
+
interface BaseParticipant {
|
|
735
|
+
/** Participant name (e.g. 'e2b', 'daytona', 'openrouter') */
|
|
736
|
+
name: string;
|
|
737
|
+
/** Environment variables that must all be set to run this participant */
|
|
738
|
+
requiredEnvVars: string[];
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
/**
|
|
742
|
+
* Filters `participants` down to those whose `requiredEnvVars` are all set
|
|
743
|
+
* in `process.env`. Returns an object `{ available, skipped }` where `skipped`
|
|
744
|
+
* includes the names and missing vars for logging.
|
|
745
|
+
*/
|
|
746
|
+
declare function filterParticipantsByEnv<T extends BaseParticipant>(participants: T[]): {
|
|
747
|
+
available: T[];
|
|
748
|
+
skipped: {
|
|
749
|
+
name: string;
|
|
750
|
+
missing: string[];
|
|
751
|
+
}[];
|
|
752
|
+
};
|
|
753
|
+
/**
|
|
754
|
+
* Filters `all` down to the requested `names`, exiting with a clear error
|
|
755
|
+
* if any name is unrecognized. Returns `all` unchanged when `names` is
|
|
756
|
+
* undefined (no filter specified).
|
|
757
|
+
*/
|
|
758
|
+
declare function selectParticipants<T extends BaseParticipant>(all: T[], names?: string[]): T[];
|
|
759
|
+
|
|
760
|
+
export { type BaseParticipant, type BenchmarkAnalyticsReadiness, BenchmarkApiError, type BenchmarkArtifact, type BenchmarkAssignment, type BenchmarkClient, type BenchmarkClientConfig, type BenchmarkConcurrencyPoint, type BenchmarkEventRateBucket, type BenchmarkFailurePoint, type BenchmarkParticipant, BenchmarkReporter, type BenchmarkReporterArtifactInput, type BenchmarkReporterBarrierInput, type BenchmarkReporterBarrierResult, type BenchmarkReporterConfig, type BenchmarkReporterHeartbeatInput, type BenchmarkReporterProgress, type BenchmarkResource, type BenchmarkResultLatencySummary, type BenchmarkResultSummary, type BenchmarkResultsOverview, type BenchmarkResultsOverviewAnalytics, type BenchmarkResultsOverviewInput, type BenchmarkResultsOverviewRun, type BenchmarkRun, type BenchmarkRunAnalyticsSummary, type BenchmarkRunImportItem, type BenchmarkRunImports, type BenchmarkRunImportsSummary, type BenchmarkRunResults, type BenchmarkRunStatus, type BenchmarkRunSummaryInput, type BenchmarkRunSummaryMetric, type BenchmarkRunSummaryResult, type BenchmarkRunSummaryRunMetadata, type BenchmarkRunSummaryScalar, type BenchmarkRunTaskResults, type BenchmarkRunTaskResultsInput, type BenchmarkRunTimeline, type BenchmarkRunTimelineInput, type BenchmarkRunWorker, type BenchmarkStepResultSummary, type BenchmarkSystemMetricsCollector, type BenchmarkSystemMetricsSample, type BenchmarkTaskBucket, type BenchmarkWorkerAttempt, type BenchmarkWorkerStatus, type ClaimWorkerInput, type CreateRunInput, type CreateWorkerArtifactInput, type CreateWorkerArtifactResponse, type DefineStepOptions, type JsonObject, type JsonValue, type PlanWorkersInput, type RunProgress, type RunProgressConcurrency, type RunProgressParticipant, type RunProgressParticipantCounts, type RunProgressStatus, type RunProgressSummary, type RunProgressTaskCounts, type RunProgressWorkerCounts, type RunWorkerContext, type RunWorkerOptions, type RunWorkerResult, type SendTaskResultsInput, type TaskFunction, type TaskResultRecord, type TaskResultsResponse, type TaskStepRecord, type UpdateBenchmarkInput, type UpdateParticipantInput, type UpdateRunInput, type UpdateWorkerInput, type UploadWorkerArtifactInput, type UpsertBenchmarkInput, type UpsertParticipantInput, type WorkerConcurrencySample, type WorkerFinishContext, type WorkerHeartbeatInput, claimBenchmarkReporter, createBenchmarkClient, createSystemMetricsCollector, filterParticipantsByEnv, selectParticipants };
|