1919 SDKAgentCreateParams ,
2020 SDKDevboxCreateParams ,
2121 SDKObjectCreateParams ,
22+ SDKScenarioListParams ,
2223 SDKScorerCreateParams ,
2324 SDKBlueprintListParams ,
2425 SDKBlueprintCreateParams ,
3132from .async_agent import AsyncAgent
3233from .async_devbox import AsyncDevbox
3334from .async_scorer import AsyncScorer
35+ from .async_scenario import AsyncScenario
3436from .async_snapshot import AsyncSnapshot
3537from .async_blueprint import AsyncBlueprint
3638from ..lib .context_loader import TarFilter , build_directory_tar
@@ -548,7 +550,8 @@ async def list(self, **params: Unpack[SDKScorerListParams]) -> list[AsyncScorer]
548550 """
549551 page = await self ._client .scenarios .scorers .list (** params )
550552 return [AsyncScorer (self ._client , item .id ) async for item in page ]
551-
553+
554+
552555class AsyncAgentOps :
553556 """High-level async manager for creating and managing agents.
554557
@@ -558,15 +561,10 @@ class AsyncAgentOps:
558561 Example:
559562 >>> runloop = AsyncRunloopSDK()
560563 >>> # Create agent from NPM package
561- >>> agent = await runloop.agent.create_from_npm(
562- ... name="my-agent",
563- ... package_name="@runloop/example-agent"
564- ... )
564+ >>> agent = await runloop.agent.create_from_npm(name="my-agent", package_name="@runloop/example-agent")
565565 >>> # Create agent from Git repository
566566 >>> agent = await runloop.agent.create_from_git(
567- ... name="git-agent",
568- ... repository="https://github.com/user/agent-repo",
569- ... ref="main"
567+ ... name="git-agent", repository="https://github.com/user/agent-repo", ref="main"
570568 ... )
571569 >>> # List all agents
572570 >>> agents = await runloop.agent.list(limit=10)
@@ -620,7 +618,9 @@ async def create_from_npm(
620618 :raises ValueError: If 'source' is provided in params
621619 """
622620 if "source" in params :
623- raise ValueError ("Cannot specify 'source' when using create_from_npm(); source is automatically set to npm configuration" )
621+ raise ValueError (
622+ "Cannot specify 'source' when using create_from_npm(); source is automatically set to npm configuration"
623+ )
624624
625625 npm_config : dict = {"package_name" : package_name }
626626 if npm_version is not None :
@@ -660,7 +660,9 @@ async def create_from_pip(
660660 :raises ValueError: If 'source' is provided in params
661661 """
662662 if "source" in params :
663- raise ValueError ("Cannot specify 'source' when using create_from_pip(); source is automatically set to pip configuration" )
663+ raise ValueError (
664+ "Cannot specify 'source' when using create_from_pip(); source is automatically set to pip configuration"
665+ )
664666
665667 pip_config : dict = {"package_name" : package_name }
666668 if pip_version is not None :
@@ -697,7 +699,9 @@ async def create_from_git(
697699 :raises ValueError: If 'source' is provided in params
698700 """
699701 if "source" in params :
700- raise ValueError ("Cannot specify 'source' when using create_from_git(); source is automatically set to git configuration" )
702+ raise ValueError (
703+ "Cannot specify 'source' when using create_from_git(); source is automatically set to git configuration"
704+ )
701705
702706 git_config : dict = {"repository" : repository }
703707 if ref is not None :
@@ -729,7 +733,9 @@ async def create_from_object(
729733 :raises ValueError: If 'source' is provided in params
730734 """
731735 if "source" in params :
732- raise ValueError ("Cannot specify 'source' when using create_from_object(); source is automatically set to object configuration" )
736+ raise ValueError (
737+ "Cannot specify 'source' when using create_from_object(); source is automatically set to object configuration"
738+ )
733739
734740 object_config : dict = {"object_id" : object_id }
735741 if agent_setup is not None :
@@ -766,6 +772,45 @@ async def list(
766772 return [AsyncAgent (self ._client , item .id , item ) for item in page .agents ]
767773
768774
775+ class AsyncScenarioOps :
776+ """Manage scenarios (async). Access via ``runloop.scenario``.
777+
778+ Example:
779+ >>> runloop = AsyncRunloopSDK()
780+ >>> scenario = runloop.scenario.from_id("scn-xxx")
781+ >>> run = await scenario.run()
782+ >>> scenarios = await runloop.scenario.list()
783+ """
784+
785+ def __init__ (self , client : AsyncRunloop ) -> None :
786+ """Initialize AsyncScenarioOps.
787+
788+ :param client: AsyncRunloop client instance
789+ :type client: AsyncRunloop
790+ """
791+ self ._client = client
792+
793+ def from_id (self , scenario_id : str ) -> AsyncScenario :
794+ """Get an AsyncScenario instance for an existing scenario ID.
795+
796+ :param scenario_id: ID of the scenario
797+ :type scenario_id: str
798+ :return: AsyncScenario instance for the given ID
799+ :rtype: AsyncScenario
800+ """
801+ return AsyncScenario (self ._client , scenario_id )
802+
803+ async def list (self , ** params : Unpack [SDKScenarioListParams ]) -> list [AsyncScenario ]:
804+ """List all scenarios, optionally filtered by parameters.
805+
806+ :param params: See :typeddict:`~runloop_api_client.sdk._types.SDKScenarioListParams` for available parameters
807+ :return: List of scenarios
808+ :rtype: list[AsyncScenario]
809+ """
810+ page = await self ._client .scenarios .list (** params )
811+ return [AsyncScenario (self ._client , item .id ) async for item in page ]
812+
813+
769814class AsyncRunloopSDK :
770815 """High-level asynchronous entry point for the Runloop SDK.
771816
@@ -781,6 +826,8 @@ class AsyncRunloopSDK:
781826 :vartype devbox: AsyncDevboxOps
782827 :ivar blueprint: High-level async interface for blueprint management
783828 :vartype blueprint: AsyncBlueprintOps
829+ :ivar scenario: High-level async interface for scenario management
830+ :vartype scenario: AsyncScenarioOps
784831 :ivar scorer: High-level async interface for scorer management
785832 :vartype scorer: AsyncScorerOps
786833 :ivar snapshot: High-level async interface for snapshot management
@@ -800,6 +847,7 @@ class AsyncRunloopSDK:
800847 agent : AsyncAgentOps
801848 devbox : AsyncDevboxOps
802849 blueprint : AsyncBlueprintOps
850+ scenario : AsyncScenarioOps
803851 scorer : AsyncScorerOps
804852 snapshot : AsyncSnapshotOps
805853 storage_object : AsyncStorageObjectOps
@@ -845,6 +893,7 @@ def __init__(
845893 self .agent = AsyncAgentOps (self .api )
846894 self .devbox = AsyncDevboxOps (self .api )
847895 self .blueprint = AsyncBlueprintOps (self .api )
896+ self .scenario = AsyncScenarioOps (self .api )
848897 self .scorer = AsyncScorerOps (self .api )
849898 self .snapshot = AsyncSnapshotOps (self .api )
850899 self .storage_object = AsyncStorageObjectOps (self .api )
0 commit comments