Skip to content

Commit f80ed4c

Browse files
authored
feat(sdk): add ScenarioBuilder class to OO-SDK (#748)
1 parent d50b603 commit f80ed4c

5 files changed

Lines changed: 816 additions & 2 deletions

File tree

src/sdk.ts

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

1718
// Import types used in this file
@@ -2012,7 +2013,8 @@ export class McpConfigOps {
20122013
*
20132014
* ## Quickstart
20142015
*
2015-
* Use `fromId()` to get a {@link Scenario} by ID, or `list()` to retrieve all scenarios.
2016+
* Use `fromId()` to get a {@link Scenario} by ID, `list()` to retrieve all scenarios,
2017+
* or `builder()` to construct a new scenario with a fluent API.
20162018
* Once you have a scenario, call `scenario.run()` to start a {@link ScenarioRun} with
20172019
* your agent mounted.
20182020
*
@@ -2056,6 +2058,26 @@ export class ScenarioOps {
20562058
*/
20572059
constructor(private client: RunloopAPI) {}
20582060

2061+
/**
2062+
* Create a new {@link ScenarioBuilder} for constructing a scenario with a fluent API.
2063+
*
2064+
* @example
2065+
* ```typescript
2066+
* const runloop = new RunloopSDK();
2067+
* const scenario = await runloop.scenario
2068+
* .builder('my-scenario')
2069+
* .withProblemStatement('Fix the bug in main.py')
2070+
* .addTestCommandScorer('tests', { test_command: 'pytest' })
2071+
* .push();
2072+
* ```
2073+
*
2074+
* @param {string} name - Name for the scenario
2075+
* @returns {ScenarioBuilder} A {@link ScenarioBuilder} instance
2076+
*/
2077+
builder(name: string): ScenarioBuilder {
2078+
return new ScenarioBuilder(name, this.client);
2079+
}
2080+
20592081
/**
20602082
* Get a scenario object by its ID.
20612083
*

src/sdk/index.ts

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

0 commit comments

Comments
 (0)