Skip to content

Commit a4e4e2f

Browse files
committed
add ScenarioBuilder class to OO-SDK
1 parent 6c52cce commit a4e4e2f

5 files changed

Lines changed: 808 additions & 2 deletions

File tree

src/sdk.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { NetworkPolicy } from './sdk/network-policy';
1111
import { GatewayConfig } from './sdk/gateway-config';
1212
import { McpConfig } from './sdk/mcp-config';
1313
import { Scenario } from './sdk/scenario';
14+
import { ScenarioBuilder } from './sdk/scenario-builder';
1415
import { Secret } from './sdk/secret';
1516

1617
// Import types used in this file
@@ -1923,7 +1924,8 @@ export class McpConfigOps {
19231924
*
19241925
* ## Quickstart
19251926
*
1926-
* Use `fromId()` to get a {@link Scenario} by ID, or `list()` to retrieve all scenarios.
1927+
* Use `fromId()` to get a {@link Scenario} by ID, `list()` to retrieve all scenarios,
1928+
* or `builder()` to construct a new scenario with a fluent API.
19271929
* Once you have a scenario, call `scenario.run()` to start a {@link ScenarioRun} with
19281930
* your agent mounted.
19291931
*
@@ -1967,6 +1969,26 @@ export class ScenarioOps {
19671969
*/
19681970
constructor(private client: RunloopAPI) {}
19691971

1972+
/**
1973+
* Create a new {@link ScenarioBuilder} for constructing a scenario with a fluent API.
1974+
*
1975+
* @example
1976+
* ```typescript
1977+
* const runloop = new RunloopSDK();
1978+
* const scenario = await runloop.scenario
1979+
* .builder('my-scenario')
1980+
* .withProblemStatement('Fix the bug in main.py')
1981+
* .addTestCommandScorer('tests', { test_command: 'pytest' })
1982+
* .push();
1983+
* ```
1984+
*
1985+
* @param {string} name - Name for the scenario
1986+
* @returns {ScenarioBuilder} A {@link ScenarioBuilder} instance
1987+
*/
1988+
builder(name: string): ScenarioBuilder {
1989+
return new ScenarioBuilder(name, this.client);
1990+
}
1991+
19701992
/**
19711993
* Get a scenario object by its ID.
19721994
*

src/sdk/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export { McpConfig } from './mcp-config';
1212
export { Secret } from './secret';
1313
export { ScenarioRun } from './scenario-run';
1414
export { Scenario, type ScenarioRunParams } from './scenario';
15+
export { ScenarioBuilder } from './scenario-builder';

0 commit comments

Comments
 (0)