@benchsdk/runner 0.3.0 → 0.5.2

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/dist/index.d.cts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { TaskResultRecord, JsonObject, DefineStepOptions, BenchmarkLogOptions, TaskStepRecord } from '@benchsdk/api';
2
+ export { BenchmarkAnalyticsReadiness, BenchmarkApiError, BenchmarkArtifact, BenchmarkArtifactDownload, BenchmarkAssignment, BenchmarkClient, 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, createBenchmarkClient } from '@benchsdk/api';
2
3
  import { BaseParticipant } from '@benchsdk/worker';
4
+ export { BaseParticipant, BenchmarkReporter, BenchmarkReporterArtifactInput, BenchmarkReporterBarrierInput, BenchmarkReporterBarrierResult, BenchmarkReporterConfig, BenchmarkReporterHeartbeatInput, BenchmarkReporterProgress, BenchmarkSystemMetricsCollector, BenchmarkSystemMetricsSample, claimBenchmarkReporter, createSystemMetricsCollector, filterParticipantsByEnv, runWorker, selectParticipants } from '@benchsdk/worker';
5
+ export { AuthError, CliAuth, createApiClient, resolveAuth } from '@benchsdk/cli';
3
6
 
4
7
  type MetricValue = string | ((record: TaskResultRecord) => number | number[] | undefined);
5
8
  interface MetricScoring {
@@ -192,8 +195,19 @@ interface TaskStepOptions extends Omit<DefineStepOptions, 'concurrency' | 'stepC
192
195
  /** Per-iteration timeout in milliseconds. If an invocation exceeds this, it is aborted and a `step_timeout` TaskError is thrown. */
193
196
  timeoutMs?: number;
194
197
  /** Number of times to invoke `fn` in parallel. Defaults to 1. When greater than 1, the step returns an array of results. */
198
+ parallelInvocations?: number;
199
+ /** @deprecated use `parallelInvocations` instead. */
195
200
  concurrency?: number;
196
201
  }
202
+ interface TaskErrorOptions {
203
+ code?: string;
204
+ data?: JsonObject;
205
+ steps?: TaskStepRecord[];
206
+ /** The step name this error was thrown from, when known. */
207
+ step?: string;
208
+ /** The timeout that was exceeded, when this is a timeout error. */
209
+ timeoutMs?: number;
210
+ }
197
211
  /**
198
212
  * Throw this from a task to record a failure while preserving domain data and
199
213
  * any pre-measured steps (a plain thrown Error loses them).
@@ -202,11 +216,10 @@ declare class TaskError extends Error {
202
216
  readonly code?: string;
203
217
  readonly data?: JsonObject;
204
218
  readonly steps?: TaskStepRecord[];
205
- constructor(message: string, opts?: {
206
- code?: string;
207
- data?: JsonObject;
208
- steps?: TaskStepRecord[];
209
- });
219
+ readonly step?: string;
220
+ readonly timeoutMs?: number;
221
+ constructor(message: string, opts?: TaskErrorOptions);
222
+ toString(): string;
210
223
  }
211
224
  /** Context handed to a benchmark `task` for a single iteration. */
212
225
  interface TaskContext<T extends BaseParticipant = BaseParticipant> {
@@ -218,11 +231,12 @@ interface TaskContext<T extends BaseParticipant = BaseParticipant> {
218
231
  phase?: string;
219
232
  /**
220
233
  * Runs `fn` as a named platform step. Mirrors `@benchsdk/worker`'s
221
- * `RunWorkerContext.step`; supports closures and try/finally. A `concurrency`
234
+ * `RunWorkerContext.step`; supports closures and try/finally. `parallelInvocations`
222
235
  * greater than 1 invokes `fn` that many times in parallel and returns an array.
223
236
  * `timeoutMs` aborts any invocation that exceeds it with a `step_timeout` TaskError.
224
237
  */
225
238
  step<R, C extends number = 1>(name: string, fn: () => Promise<R> | R, options?: TaskStepOptions & {
239
+ parallelInvocations?: C;
226
240
  concurrency?: C;
227
241
  }): Promise<C extends 1 ? R : R[]>;
228
242
  /**
@@ -268,49 +282,6 @@ interface ResolvedRunConfig {
268
282
  groupBy: GroupBy;
269
283
  providers?: string[];
270
284
  }
271
- /** Display metadata for a single custom metric a benchmark reports via `ctx.measure`. */
272
- interface BenchmarkMetricDisplay {
273
- /** Stable metric key, matching the key in `ctx.measure` or `data`. */
274
- key: string;
275
- /** Human-readable label shown in the platform UI. */
276
- label: string;
277
- /** Optional unit shown after the value (e.g. `Mbps`, `/s`, `ms`). */
278
- unit?: string;
279
- /** Number of decimal places when formatting numeric values. Defaults to the display format. */
280
- decimals?: number;
281
- /** Whether higher or lower values rank better. */
282
- direction?: 'higher-better' | 'lower-better';
283
- /** Optional ordering hint for metric lists. */
284
- order?: number;
285
- }
286
- /** Display metadata for a single task lifecycle step. */
287
- interface BenchmarkStepDisplay {
288
- /** Stable step name, matching the string passed to `ctx.step`. */
289
- key: string;
290
- /** Human-readable label shown in the platform UI. */
291
- label: string;
292
- /** Optional ordering hint for step lists. */
293
- order?: number;
294
- }
295
- /** Display defaults for the benchmark overview page. */
296
- interface BenchmarkOverviewDisplay {
297
- /** Metric key to rank participants by by default (falls back to overall task latency). */
298
- defaultMetric?: string;
299
- /** Default overview layout. */
300
- defaultLayout?: 'ranking' | 'cards' | 'chart' | 'leaderboard';
301
- }
302
- /**
303
- * Optional platform display manifest. A `*.bench.ts` file owns not only how the
304
- * benchmark runs, but how it should be rendered, without a platform code change.
305
- */
306
- interface BenchmarkDisplayConfig {
307
- /** Metric catalog — labels, units, and ranking direction for `ctx.measure` keys. */
308
- metrics?: BenchmarkMetricDisplay[];
309
- /** Step catalog — human labels for lifecycle steps reported via `ctx.step`. */
310
- steps?: BenchmarkStepDisplay[];
311
- /** Overview defaults. */
312
- overview?: BenchmarkOverviewDisplay;
313
- }
314
285
  /**
315
286
  * Result of a benchmark run, passed to `config.onComplete`. Exposes the raw
316
287
  * per-participant records so completion hooks can write legacy local results.
@@ -409,6 +380,58 @@ interface BenchmarkConfig<T extends BaseParticipant = BaseParticipant> {
409
380
  */
410
381
  display?: BenchmarkDisplayConfig;
411
382
  }
383
+ /** Display metadata for a single custom metric a benchmark reports via `ctx.measure`. */
384
+ interface BenchmarkMetricDisplay {
385
+ /** Stable metric key, matching the key in `ctx.measure` or `data`. */
386
+ key: string;
387
+ /** Human-readable label shown in the platform UI. */
388
+ label: string;
389
+ /** Optional unit shown after the value (e.g. `Mbps`, `/s`, `ms`). */
390
+ unit?: string;
391
+ /** Number of decimal places when formatting numeric values. Defaults to the display format. */
392
+ decimals?: number;
393
+ /** Whether higher or lower values rank better. */
394
+ direction?: 'higher-better' | 'lower-better';
395
+ /** Optional ordering hint for metric lists. */
396
+ order?: number;
397
+ }
398
+ /** Display metadata for a single task lifecycle step. */
399
+ interface BenchmarkStepDisplay {
400
+ /** Stable step name, matching the string passed to `ctx.step`. */
401
+ key: string;
402
+ /** Human-readable label shown in the platform UI. */
403
+ label: string;
404
+ /** Optional ordering hint for step lists. */
405
+ order?: number;
406
+ }
407
+ /** Display defaults for the benchmark overview page. */
408
+ interface BenchmarkOverviewDisplay {
409
+ /** Metric key to rank participants by by default (falls back to overall task latency). */
410
+ defaultMetric?: string;
411
+ /** Default overview layout. */
412
+ defaultLayout?: 'ranking' | 'cards' | 'chart' | 'leaderboard';
413
+ }
414
+ /**
415
+ * Optional platform display manifest. A `*.bench.ts` file owns not only how the
416
+ * benchmark runs, but how it should be rendered, without a platform code change.
417
+ */
418
+ interface BenchmarkDisplayConfig {
419
+ /** Metric catalog — labels, units, and ranking direction for `ctx.measure` keys. */
420
+ metrics?: BenchmarkMetricDisplay[];
421
+ /** Step catalog — human labels for lifecycle steps reported via `ctx.step`. */
422
+ steps?: BenchmarkStepDisplay[];
423
+ /** Overview defaults. */
424
+ overview?: BenchmarkOverviewDisplay;
425
+ }
426
+ interface BenchmarkConfigErrorItem {
427
+ field: string;
428
+ message: string;
429
+ }
430
+ declare class BenchmarkConfigError extends Error {
431
+ readonly issues: BenchmarkConfigErrorItem[];
432
+ constructor(issues: BenchmarkConfigErrorItem[]);
433
+ private static formatIssues;
434
+ }
412
435
  /** Validates `config` at file-evaluation time so mistakes surface immediately. */
413
436
  declare function defineBenchmarkConfig<T extends BaseParticipant = BaseParticipant>(config: BenchmarkConfig<T>): BenchmarkConfig<T>;
414
437
  /**
@@ -423,6 +446,16 @@ declare function defineBenchmarkConfig<T extends BaseParticipant = BaseParticipa
423
446
  * });
424
447
  */
425
448
  declare function defineTask<T extends BaseParticipant = BaseParticipant>(task: BenchmarkTask<T>): BenchmarkTask<T>;
449
+ /**
450
+ * Validates a `BenchmarkConfig` without throwing, returning a list of
451
+ * `{ field, message }` issues. Returns an empty array when the config is valid.
452
+ */
453
+ declare function validateBenchmarkConfig<T extends BaseParticipant = BaseParticipant>(config: BenchmarkConfig<T>): BenchmarkConfigErrorItem[];
454
+ /**
455
+ * Typed helper for `config.onComplete` callbacks. The body receives the full
456
+ * `BenchmarkRunOutcome` and can be sync or async.
457
+ */
458
+ declare function defineOnComplete(onComplete: (outcome: BenchmarkRunOutcome) => void | Promise<void>): (outcome: BenchmarkRunOutcome) => void | Promise<void>;
426
459
 
427
460
  /**
428
461
  * Thrown when every selected participant was env-gated out, i.e. none of their
@@ -473,6 +506,11 @@ interface CliArgs {
473
506
  declare function parseCliArgs(argv: string[], allowedCustomFlags?: readonly string[]): CliArgs;
474
507
  /** Merges CLI overrides over config defaults, filling in knob fallbacks. */
475
508
  declare function mergeConfig<T extends BaseParticipant>(config: BenchmarkConfig<T>, args: CliArgs): ResolvedRunConfig;
509
+ interface PlatformConfig {
510
+ baseUrl?: string;
511
+ apiKey?: string;
512
+ }
513
+ type RunBenchmarkOptions = PlatformConfig;
476
514
  /**
477
515
  * Runs `config`'s `task` against its participants. Selects participants by
478
516
  * `--provider` (if given), env-gates them, then drives them per the resolved
@@ -482,7 +520,26 @@ declare function mergeConfig<T extends BaseParticipant>(config: BenchmarkConfig<
482
520
  * CI job per provider) get-or-create one shared run and each registers only its
483
521
  * own participants.
484
522
  */
485
- declare function runBenchmark<T extends BaseParticipant>(fileConfig: BenchmarkConfig<T>, task: BenchmarkTask<T>, argv?: string[]): Promise<BenchmarkRunOutcome>;
523
+ declare function runBenchmark<T extends BaseParticipant>(fileConfig: BenchmarkConfig<T>, task: BenchmarkTask<T>, argv?: string[], options?: RunBenchmarkOptions): Promise<BenchmarkRunOutcome>;
524
+ interface RunBenchmarkWorkerOptions<T extends BaseParticipant = BaseParticipant> {
525
+ benchmarkSlug: string;
526
+ benchmarkName?: string;
527
+ runKey?: string;
528
+ participant: T;
529
+ task: BenchmarkTask<T>;
530
+ iterations?: number;
531
+ concurrency?: number;
532
+ staggerDelayMs?: number;
533
+ groupBy?: GroupBy;
534
+ noIngest?: boolean;
535
+ }
536
+ /**
537
+ * One-shot helper: run a single participant's worker for a benchmark without
538
+ * creating a `*.bench.ts` file. This is a convenience wrapper around
539
+ * `runBenchmark` that builds a minimal `BenchmarkConfig` from the supplied
540
+ * options.
541
+ */
542
+ declare function runBenchmarkWorker<T extends BaseParticipant>(options: RunBenchmarkWorkerOptions<T>): Promise<BenchmarkRunOutcome>;
486
543
 
487
544
  /**
488
545
  * Dispatches one CLI invocation. Throws on bad usage / invalid exports and lets
@@ -495,4 +552,4 @@ declare function run(argv: string[]): Promise<void>;
495
552
 
496
553
  declare const BENCHSDK_RUNNER_VERSION: string;
497
554
 
498
- export { BENCHSDK_RUNNER_VERSION, type BenchmarkConfig, type BenchmarkDisplayConfig, type BenchmarkMetricDisplay, type BenchmarkOverviewDisplay, type BenchmarkRunOutcome, type BenchmarkScoreResult, type BenchmarkScoringConfig, type BenchmarkScoringMetric, type BenchmarkScoringSuccess, type BenchmarkScoringWeights, type BenchmarkStepDisplay, type BenchmarkTask, type CliArgs, type GroupBy, type MetricScoring, NoAvailableParticipantsError, type ParticipantRecords, type Phase, type ResolvedRunConfig, type ScoringSpec, ScoringSpecError, type TaskContext, TaskError, type TaskResult, type TaskStepOptions, defineBenchmarkConfig, defineTask, higherIsBetter, lowerIsBetter, mergeConfig, parseCliArgs, run, runBenchmark, runBenchmarkFile, score, scoringConfigToSpec, validateScoringSpec };
555
+ export { BENCHSDK_RUNNER_VERSION, type BenchmarkConfig, BenchmarkConfigError, type BenchmarkConfigErrorItem, type BenchmarkDisplayConfig, type BenchmarkMetricDisplay, type BenchmarkOverviewDisplay, type BenchmarkRunOutcome, type BenchmarkScoreResult, type BenchmarkScoringConfig, type BenchmarkScoringMetric, type BenchmarkScoringSuccess, type BenchmarkScoringWeights, type BenchmarkStepDisplay, type BenchmarkTask, type CliArgs, type GroupBy, type MetricScoring, NoAvailableParticipantsError, type ParticipantRecords, type Phase, type PlatformConfig, type ResolvedRunConfig, type RunBenchmarkOptions, type RunBenchmarkWorkerOptions, type ScoringSpec, ScoringSpecError, type TaskContext, TaskError, type TaskResult, type TaskStepOptions, defineBenchmarkConfig, defineOnComplete, defineTask, higherIsBetter, lowerIsBetter, mergeConfig, parseCliArgs, run, runBenchmark, runBenchmarkFile, runBenchmarkWorker, score, scoringConfigToSpec, validateBenchmarkConfig, validateScoringSpec };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { TaskResultRecord, JsonObject, DefineStepOptions, BenchmarkLogOptions, TaskStepRecord } from '@benchsdk/api';
2
+ export { BenchmarkAnalyticsReadiness, BenchmarkApiError, BenchmarkArtifact, BenchmarkArtifactDownload, BenchmarkAssignment, BenchmarkClient, 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, createBenchmarkClient } from '@benchsdk/api';
2
3
  import { BaseParticipant } from '@benchsdk/worker';
4
+ export { BaseParticipant, BenchmarkReporter, BenchmarkReporterArtifactInput, BenchmarkReporterBarrierInput, BenchmarkReporterBarrierResult, BenchmarkReporterConfig, BenchmarkReporterHeartbeatInput, BenchmarkReporterProgress, BenchmarkSystemMetricsCollector, BenchmarkSystemMetricsSample, claimBenchmarkReporter, createSystemMetricsCollector, filterParticipantsByEnv, runWorker, selectParticipants } from '@benchsdk/worker';
5
+ export { AuthError, CliAuth, createApiClient, resolveAuth } from '@benchsdk/cli';
3
6
 
4
7
  type MetricValue = string | ((record: TaskResultRecord) => number | number[] | undefined);
5
8
  interface MetricScoring {
@@ -192,8 +195,19 @@ interface TaskStepOptions extends Omit<DefineStepOptions, 'concurrency' | 'stepC
192
195
  /** Per-iteration timeout in milliseconds. If an invocation exceeds this, it is aborted and a `step_timeout` TaskError is thrown. */
193
196
  timeoutMs?: number;
194
197
  /** Number of times to invoke `fn` in parallel. Defaults to 1. When greater than 1, the step returns an array of results. */
198
+ parallelInvocations?: number;
199
+ /** @deprecated use `parallelInvocations` instead. */
195
200
  concurrency?: number;
196
201
  }
202
+ interface TaskErrorOptions {
203
+ code?: string;
204
+ data?: JsonObject;
205
+ steps?: TaskStepRecord[];
206
+ /** The step name this error was thrown from, when known. */
207
+ step?: string;
208
+ /** The timeout that was exceeded, when this is a timeout error. */
209
+ timeoutMs?: number;
210
+ }
197
211
  /**
198
212
  * Throw this from a task to record a failure while preserving domain data and
199
213
  * any pre-measured steps (a plain thrown Error loses them).
@@ -202,11 +216,10 @@ declare class TaskError extends Error {
202
216
  readonly code?: string;
203
217
  readonly data?: JsonObject;
204
218
  readonly steps?: TaskStepRecord[];
205
- constructor(message: string, opts?: {
206
- code?: string;
207
- data?: JsonObject;
208
- steps?: TaskStepRecord[];
209
- });
219
+ readonly step?: string;
220
+ readonly timeoutMs?: number;
221
+ constructor(message: string, opts?: TaskErrorOptions);
222
+ toString(): string;
210
223
  }
211
224
  /** Context handed to a benchmark `task` for a single iteration. */
212
225
  interface TaskContext<T extends BaseParticipant = BaseParticipant> {
@@ -218,11 +231,12 @@ interface TaskContext<T extends BaseParticipant = BaseParticipant> {
218
231
  phase?: string;
219
232
  /**
220
233
  * Runs `fn` as a named platform step. Mirrors `@benchsdk/worker`'s
221
- * `RunWorkerContext.step`; supports closures and try/finally. A `concurrency`
234
+ * `RunWorkerContext.step`; supports closures and try/finally. `parallelInvocations`
222
235
  * greater than 1 invokes `fn` that many times in parallel and returns an array.
223
236
  * `timeoutMs` aborts any invocation that exceeds it with a `step_timeout` TaskError.
224
237
  */
225
238
  step<R, C extends number = 1>(name: string, fn: () => Promise<R> | R, options?: TaskStepOptions & {
239
+ parallelInvocations?: C;
226
240
  concurrency?: C;
227
241
  }): Promise<C extends 1 ? R : R[]>;
228
242
  /**
@@ -268,49 +282,6 @@ interface ResolvedRunConfig {
268
282
  groupBy: GroupBy;
269
283
  providers?: string[];
270
284
  }
271
- /** Display metadata for a single custom metric a benchmark reports via `ctx.measure`. */
272
- interface BenchmarkMetricDisplay {
273
- /** Stable metric key, matching the key in `ctx.measure` or `data`. */
274
- key: string;
275
- /** Human-readable label shown in the platform UI. */
276
- label: string;
277
- /** Optional unit shown after the value (e.g. `Mbps`, `/s`, `ms`). */
278
- unit?: string;
279
- /** Number of decimal places when formatting numeric values. Defaults to the display format. */
280
- decimals?: number;
281
- /** Whether higher or lower values rank better. */
282
- direction?: 'higher-better' | 'lower-better';
283
- /** Optional ordering hint for metric lists. */
284
- order?: number;
285
- }
286
- /** Display metadata for a single task lifecycle step. */
287
- interface BenchmarkStepDisplay {
288
- /** Stable step name, matching the string passed to `ctx.step`. */
289
- key: string;
290
- /** Human-readable label shown in the platform UI. */
291
- label: string;
292
- /** Optional ordering hint for step lists. */
293
- order?: number;
294
- }
295
- /** Display defaults for the benchmark overview page. */
296
- interface BenchmarkOverviewDisplay {
297
- /** Metric key to rank participants by by default (falls back to overall task latency). */
298
- defaultMetric?: string;
299
- /** Default overview layout. */
300
- defaultLayout?: 'ranking' | 'cards' | 'chart' | 'leaderboard';
301
- }
302
- /**
303
- * Optional platform display manifest. A `*.bench.ts` file owns not only how the
304
- * benchmark runs, but how it should be rendered, without a platform code change.
305
- */
306
- interface BenchmarkDisplayConfig {
307
- /** Metric catalog — labels, units, and ranking direction for `ctx.measure` keys. */
308
- metrics?: BenchmarkMetricDisplay[];
309
- /** Step catalog — human labels for lifecycle steps reported via `ctx.step`. */
310
- steps?: BenchmarkStepDisplay[];
311
- /** Overview defaults. */
312
- overview?: BenchmarkOverviewDisplay;
313
- }
314
285
  /**
315
286
  * Result of a benchmark run, passed to `config.onComplete`. Exposes the raw
316
287
  * per-participant records so completion hooks can write legacy local results.
@@ -409,6 +380,58 @@ interface BenchmarkConfig<T extends BaseParticipant = BaseParticipant> {
409
380
  */
410
381
  display?: BenchmarkDisplayConfig;
411
382
  }
383
+ /** Display metadata for a single custom metric a benchmark reports via `ctx.measure`. */
384
+ interface BenchmarkMetricDisplay {
385
+ /** Stable metric key, matching the key in `ctx.measure` or `data`. */
386
+ key: string;
387
+ /** Human-readable label shown in the platform UI. */
388
+ label: string;
389
+ /** Optional unit shown after the value (e.g. `Mbps`, `/s`, `ms`). */
390
+ unit?: string;
391
+ /** Number of decimal places when formatting numeric values. Defaults to the display format. */
392
+ decimals?: number;
393
+ /** Whether higher or lower values rank better. */
394
+ direction?: 'higher-better' | 'lower-better';
395
+ /** Optional ordering hint for metric lists. */
396
+ order?: number;
397
+ }
398
+ /** Display metadata for a single task lifecycle step. */
399
+ interface BenchmarkStepDisplay {
400
+ /** Stable step name, matching the string passed to `ctx.step`. */
401
+ key: string;
402
+ /** Human-readable label shown in the platform UI. */
403
+ label: string;
404
+ /** Optional ordering hint for step lists. */
405
+ order?: number;
406
+ }
407
+ /** Display defaults for the benchmark overview page. */
408
+ interface BenchmarkOverviewDisplay {
409
+ /** Metric key to rank participants by by default (falls back to overall task latency). */
410
+ defaultMetric?: string;
411
+ /** Default overview layout. */
412
+ defaultLayout?: 'ranking' | 'cards' | 'chart' | 'leaderboard';
413
+ }
414
+ /**
415
+ * Optional platform display manifest. A `*.bench.ts` file owns not only how the
416
+ * benchmark runs, but how it should be rendered, without a platform code change.
417
+ */
418
+ interface BenchmarkDisplayConfig {
419
+ /** Metric catalog — labels, units, and ranking direction for `ctx.measure` keys. */
420
+ metrics?: BenchmarkMetricDisplay[];
421
+ /** Step catalog — human labels for lifecycle steps reported via `ctx.step`. */
422
+ steps?: BenchmarkStepDisplay[];
423
+ /** Overview defaults. */
424
+ overview?: BenchmarkOverviewDisplay;
425
+ }
426
+ interface BenchmarkConfigErrorItem {
427
+ field: string;
428
+ message: string;
429
+ }
430
+ declare class BenchmarkConfigError extends Error {
431
+ readonly issues: BenchmarkConfigErrorItem[];
432
+ constructor(issues: BenchmarkConfigErrorItem[]);
433
+ private static formatIssues;
434
+ }
412
435
  /** Validates `config` at file-evaluation time so mistakes surface immediately. */
413
436
  declare function defineBenchmarkConfig<T extends BaseParticipant = BaseParticipant>(config: BenchmarkConfig<T>): BenchmarkConfig<T>;
414
437
  /**
@@ -423,6 +446,16 @@ declare function defineBenchmarkConfig<T extends BaseParticipant = BaseParticipa
423
446
  * });
424
447
  */
425
448
  declare function defineTask<T extends BaseParticipant = BaseParticipant>(task: BenchmarkTask<T>): BenchmarkTask<T>;
449
+ /**
450
+ * Validates a `BenchmarkConfig` without throwing, returning a list of
451
+ * `{ field, message }` issues. Returns an empty array when the config is valid.
452
+ */
453
+ declare function validateBenchmarkConfig<T extends BaseParticipant = BaseParticipant>(config: BenchmarkConfig<T>): BenchmarkConfigErrorItem[];
454
+ /**
455
+ * Typed helper for `config.onComplete` callbacks. The body receives the full
456
+ * `BenchmarkRunOutcome` and can be sync or async.
457
+ */
458
+ declare function defineOnComplete(onComplete: (outcome: BenchmarkRunOutcome) => void | Promise<void>): (outcome: BenchmarkRunOutcome) => void | Promise<void>;
426
459
 
427
460
  /**
428
461
  * Thrown when every selected participant was env-gated out, i.e. none of their
@@ -473,6 +506,11 @@ interface CliArgs {
473
506
  declare function parseCliArgs(argv: string[], allowedCustomFlags?: readonly string[]): CliArgs;
474
507
  /** Merges CLI overrides over config defaults, filling in knob fallbacks. */
475
508
  declare function mergeConfig<T extends BaseParticipant>(config: BenchmarkConfig<T>, args: CliArgs): ResolvedRunConfig;
509
+ interface PlatformConfig {
510
+ baseUrl?: string;
511
+ apiKey?: string;
512
+ }
513
+ type RunBenchmarkOptions = PlatformConfig;
476
514
  /**
477
515
  * Runs `config`'s `task` against its participants. Selects participants by
478
516
  * `--provider` (if given), env-gates them, then drives them per the resolved
@@ -482,7 +520,26 @@ declare function mergeConfig<T extends BaseParticipant>(config: BenchmarkConfig<
482
520
  * CI job per provider) get-or-create one shared run and each registers only its
483
521
  * own participants.
484
522
  */
485
- declare function runBenchmark<T extends BaseParticipant>(fileConfig: BenchmarkConfig<T>, task: BenchmarkTask<T>, argv?: string[]): Promise<BenchmarkRunOutcome>;
523
+ declare function runBenchmark<T extends BaseParticipant>(fileConfig: BenchmarkConfig<T>, task: BenchmarkTask<T>, argv?: string[], options?: RunBenchmarkOptions): Promise<BenchmarkRunOutcome>;
524
+ interface RunBenchmarkWorkerOptions<T extends BaseParticipant = BaseParticipant> {
525
+ benchmarkSlug: string;
526
+ benchmarkName?: string;
527
+ runKey?: string;
528
+ participant: T;
529
+ task: BenchmarkTask<T>;
530
+ iterations?: number;
531
+ concurrency?: number;
532
+ staggerDelayMs?: number;
533
+ groupBy?: GroupBy;
534
+ noIngest?: boolean;
535
+ }
536
+ /**
537
+ * One-shot helper: run a single participant's worker for a benchmark without
538
+ * creating a `*.bench.ts` file. This is a convenience wrapper around
539
+ * `runBenchmark` that builds a minimal `BenchmarkConfig` from the supplied
540
+ * options.
541
+ */
542
+ declare function runBenchmarkWorker<T extends BaseParticipant>(options: RunBenchmarkWorkerOptions<T>): Promise<BenchmarkRunOutcome>;
486
543
 
487
544
  /**
488
545
  * Dispatches one CLI invocation. Throws on bad usage / invalid exports and lets
@@ -495,4 +552,4 @@ declare function run(argv: string[]): Promise<void>;
495
552
 
496
553
  declare const BENCHSDK_RUNNER_VERSION: string;
497
554
 
498
- export { BENCHSDK_RUNNER_VERSION, type BenchmarkConfig, type BenchmarkDisplayConfig, type BenchmarkMetricDisplay, type BenchmarkOverviewDisplay, type BenchmarkRunOutcome, type BenchmarkScoreResult, type BenchmarkScoringConfig, type BenchmarkScoringMetric, type BenchmarkScoringSuccess, type BenchmarkScoringWeights, type BenchmarkStepDisplay, type BenchmarkTask, type CliArgs, type GroupBy, type MetricScoring, NoAvailableParticipantsError, type ParticipantRecords, type Phase, type ResolvedRunConfig, type ScoringSpec, ScoringSpecError, type TaskContext, TaskError, type TaskResult, type TaskStepOptions, defineBenchmarkConfig, defineTask, higherIsBetter, lowerIsBetter, mergeConfig, parseCliArgs, run, runBenchmark, runBenchmarkFile, score, scoringConfigToSpec, validateScoringSpec };
555
+ export { BENCHSDK_RUNNER_VERSION, type BenchmarkConfig, BenchmarkConfigError, type BenchmarkConfigErrorItem, type BenchmarkDisplayConfig, type BenchmarkMetricDisplay, type BenchmarkOverviewDisplay, type BenchmarkRunOutcome, type BenchmarkScoreResult, type BenchmarkScoringConfig, type BenchmarkScoringMetric, type BenchmarkScoringSuccess, type BenchmarkScoringWeights, type BenchmarkStepDisplay, type BenchmarkTask, type CliArgs, type GroupBy, type MetricScoring, NoAvailableParticipantsError, type ParticipantRecords, type Phase, type PlatformConfig, type ResolvedRunConfig, type RunBenchmarkOptions, type RunBenchmarkWorkerOptions, type ScoringSpec, ScoringSpecError, type TaskContext, TaskError, type TaskResult, type TaskStepOptions, defineBenchmarkConfig, defineOnComplete, defineTask, higherIsBetter, lowerIsBetter, mergeConfig, parseCliArgs, run, runBenchmark, runBenchmarkFile, runBenchmarkWorker, score, scoringConfigToSpec, validateBenchmarkConfig, validateScoringSpec };