From d40e6e0d6911be0bc9bfc419e02bd7c1d5ad5be4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 12:04:34 +0000 Subject: [PATCH 1/7] fix(parsing): parse extra field types --- src/agentex/_models.py | 25 +++++++++++++++++++++++-- tests/test_models.py | 29 ++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/agentex/_models.py b/src/agentex/_models.py index ffcbf67b..b8387ce9 100644 --- a/src/agentex/_models.py +++ b/src/agentex/_models.py @@ -208,14 +208,18 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride] else: fields_values[name] = field_get_default(field) + extra_field_type = _get_extra_fields_type(__cls) + _extra = {} for key, value in values.items(): if key not in model_fields: + parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value + if PYDANTIC_V2: - _extra[key] = value + _extra[key] = parsed else: _fields_set.add(key) - fields_values[key] = value + fields_values[key] = parsed object.__setattr__(m, "__dict__", fields_values) @@ -370,6 +374,23 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object: return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None)) +def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None: + if not PYDANTIC_V2: + # TODO + return None + + schema = cls.__pydantic_core_schema__ + if schema["type"] == "model": + fields = schema["schema"] + if fields["type"] == "model-fields": + extras = fields.get("extras_schema") + if extras and "cls" in extras: + # mypy can't narrow the type + return extras["cls"] # type: ignore[no-any-return] + + return None + + def is_basemodel(type_: type) -> bool: """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`""" if is_union(type_): diff --git a/tests/test_models.py b/tests/test_models.py index a8867d60..14d98180 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,5 +1,5 @@ import json -from typing import Any, Dict, List, Union, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, Union, Optional, cast from datetime import datetime, timezone from typing_extensions import Literal, Annotated, TypeAliasType @@ -934,3 +934,30 @@ class Type2(BaseModel): ) assert isinstance(model, Type1) assert isinstance(model.value, InnerType2) + + +@pytest.mark.skipif(not PYDANTIC_V2, reason="this is only supported in pydantic v2 for now") +def test_extra_properties() -> None: + class Item(BaseModel): + prop: int + + class Model(BaseModel): + __pydantic_extra__: Dict[str, Item] = Field(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + other: str + + if TYPE_CHECKING: + + def __getattr__(self, attr: str) -> Item: ... + + model = construct_type( + type_=Model, + value={ + "a": {"prop": 1}, + "other": "foo", + }, + ) + assert isinstance(model, Model) + assert model.a.prop == 1 + assert isinstance(model.a, Item) + assert model.other == "foo" From 7bde6b727d6d16ebd6805ef843596fc3224445a6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:00:11 +0000 Subject: [PATCH 2/7] fix(api): build errors - update openapi spec - comment out models that don't exist - add back methods for backwards compatibility for now --- .stats.yml | 4 +- README.md | 44 +- api.md | 45 +- src/agentex/_client.py | 4 +- src/agentex/resources/agents/__init__.py | 33 ++ src/agentex/resources/{ => agents}/agents.py | 50 +- src/agentex/resources/agents/name.py | 454 ++++++++++++++++++ src/agentex/resources/tasks/__init__.py | 33 ++ src/agentex/resources/tasks/name.py | 324 +++++++++++++ src/agentex/resources/{ => tasks}/tasks.py | 48 +- src/agentex/types/agents/__init__.py | 6 + .../types/agents/name_handle_rpc_params.py | 85 ++++ src/agentex/types/agents/name_rpc_params.py | 85 ++++ src/agentex/types/tasks/__init__.py | 3 + tests/api_resources/agents/__init__.py | 1 + tests/api_resources/agents/test_name.py | 452 +++++++++++++++++ tests/api_resources/tasks/__init__.py | 1 + tests/api_resources/tasks/test_name.py | 274 +++++++++++ tests/conftest.py | 8 +- tests/test_client.py | 227 ++++++--- 20 files changed, 2044 insertions(+), 137 deletions(-) create mode 100644 src/agentex/resources/agents/__init__.py rename src/agentex/resources/{ => agents}/agents.py (94%) create mode 100644 src/agentex/resources/agents/name.py create mode 100644 src/agentex/resources/tasks/__init__.py create mode 100644 src/agentex/resources/tasks/name.py rename src/agentex/resources/{ => tasks}/tasks.py (94%) create mode 100644 src/agentex/types/agents/__init__.py create mode 100644 src/agentex/types/agents/name_handle_rpc_params.py create mode 100644 src/agentex/types/agents/name_rpc_params.py create mode 100644 src/agentex/types/tasks/__init__.py create mode 100644 tests/api_resources/agents/__init__.py create mode 100644 tests/api_resources/agents/test_name.py create mode 100644 tests/api_resources/tasks/__init__.py create mode 100644 tests/api_resources/tasks/test_name.py diff --git a/.stats.yml b/.stats.yml index 91523e16..5a7503fb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-021b55c88964b7a5bfc9d692d32a52c6b0150445656d2407c4cb8e9dd1e5f100.yml -openapi_spec_hash: ed92c0d5d6bed9cb5617f8a776ac42c9 -config_hash: 7661726e3cccf9f6349179841153601d +openapi_spec_hash: 3f634d45f6241dea4fbdac496b70f5a3 +config_hash: 7c45df33d1cc4df7ea9dac3b0968b0f0 diff --git a/README.md b/README.md index 2bdbb592..588fc8cc 100644 --- a/README.md +++ b/README.md @@ -28,17 +28,16 @@ pip install git+ssh://git@github.com/scaleapi/agentex-python.git The full API of this library can be found in [api.md](api.md). ```python +import os from agentex import Agentex client = Agentex( + api_key=os.environ.get("AGENTEX_SDK_API_KEY"), # This is the default and can be omitted # defaults to "production". environment="development", ) -agent = client.agents.retrieve( - "agent_id", -) -print(agent.id) +tasks = client.tasks.list() ``` While you can provide an `api_key` keyword argument, @@ -51,20 +50,19 @@ so that your API Key is not stored in source control. Simply import `AsyncAgentex` instead of `Agentex` and use `await` with each API call: ```python +import os import asyncio from agentex import AsyncAgentex client = AsyncAgentex( + api_key=os.environ.get("AGENTEX_SDK_API_KEY"), # This is the default and can be omitted # defaults to "production". environment="development", ) async def main() -> None: - agent = await client.agents.retrieve( - "agent_id", - ) - print(agent.id) + tasks = await client.tasks.list() asyncio.run(main()) @@ -93,12 +91,10 @@ from agentex import AsyncAgentex async def main() -> None: async with AsyncAgentex( + api_key="My API Key", http_client=DefaultAioHttpClient(), ) as client: - agent = await client.agents.retrieve( - "agent_id", - ) - print(agent.id) + tasks = await client.tasks.list() asyncio.run(main()) @@ -129,9 +125,7 @@ from agentex import Agentex client = Agentex() try: - client.agents.retrieve( - "agent_id", - ) + client.tasks.list() except agentex.APIConnectionError as e: print("The server could not be reached") print(e.__cause__) # an underlying Exception, likely raised within httpx. @@ -174,9 +168,7 @@ client = Agentex( ) # Or, configure per-request: -client.with_options(max_retries=5).agents.retrieve( - "agent_id", -) +client.with_options(max_retries=5).tasks.list() ``` ### Timeouts @@ -199,9 +191,7 @@ client = Agentex( ) # Override per-request: -client.with_options(timeout=5.0).agents.retrieve( - "agent_id", -) +client.with_options(timeout=5.0).tasks.list() ``` On timeout, an `APITimeoutError` is thrown. @@ -242,13 +232,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to from agentex import Agentex client = Agentex() -response = client.agents.with_raw_response.retrieve( - "agent_id", -) +response = client.tasks.with_raw_response.list() print(response.headers.get('X-My-Header')) -agent = response.parse() # get the object that `agents.retrieve()` would have returned -print(agent.id) +task = response.parse() # get the object that `tasks.list()` would have returned +print(task) ``` These methods return an [`APIResponse`](https://github.com/scaleapi/agentex-python/tree/main/src/agentex/_response.py) object. @@ -262,9 +250,7 @@ The above interface eagerly reads the full response body when you make the reque To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods. ```python -with client.agents.with_streaming_response.retrieve( - "agent_id", -) as response: +with client.tasks.with_streaming_response.list() as response: print(response.headers.get("X-My-Header")) for line in response.iter_lines(): diff --git a/api.md b/api.md index 8c2841ca..0d482fb9 100644 --- a/api.md +++ b/api.md @@ -8,13 +8,22 @@ from agentex.types import AcpType, Agent, AgentRpcRequest, AgentListResponse Methods: -- client.agents.retrieve(agent_id) -> Agent -- client.agents.list(\*\*params) -> AgentListResponse -- client.agents.delete(agent_id) -> Agent -- client.agents.delete_by_name(agent_name) -> Agent -- client.agents.retrieve_by_name(agent_name) -> Agent -- client.agents.rpc(agent_id, \*\*params) -> object -- client.agents.rpc_by_name(agent_name, \*\*params) -> object +- client.agents.retrieve(agent_id) -> Agent +- client.agents.list(\*\*params) -> AgentListResponse +- client.agents.delete(agent_id) -> Agent +- client.agents.delete_by_name(agent_name) -> Agent +- client.agents.retrieve_by_name(agent_name) -> Agent +- client.agents.rpc(agent_id, \*\*params) -> object +- client.agents.rpc_by_name(agent_name, \*\*params) -> object + +## Name + +Methods: + +- client.agents.name.retrieve(agent_name) -> Agent +- client.agents.name.delete(agent_name) -> Agent +- client.agents.name.handle_rpc(agent_name, \*\*params) -> object +- client.agents.name.rpc(agent_name, \*\*params) -> object # Tasks @@ -26,13 +35,21 @@ from agentex.types import Task, TaskListResponse Methods: -- client.tasks.retrieve(task_id) -> Task -- client.tasks.list() -> TaskListResponse -- client.tasks.delete(task_id) -> Task -- client.tasks.delete_by_name(task_name) -> Task -- client.tasks.retrieve_by_name(task_name) -> Task -- client.tasks.stream_events(task_id) -> object -- client.tasks.stream_events_by_name(task_name) -> object +- client.tasks.retrieve(task_id) -> Task +- client.tasks.list() -> TaskListResponse +- client.tasks.delete(task_id) -> Task +- client.tasks.delete_by_name(task_name) -> Task +- client.tasks.retrieve_by_name(task_name) -> Task +- client.tasks.stream_events(task_id) -> object +- client.tasks.stream_events_by_name(task_name) -> object + +## Name + +Methods: + +- client.tasks.name.retrieve(task_name) -> Task +- client.tasks.name.delete(task_name) -> Task +- client.tasks.name.stream_events(task_name) -> object # Messages diff --git a/src/agentex/_client.py b/src/agentex/_client.py index 51ebb5e8..d1af575d 100644 --- a/src/agentex/_client.py +++ b/src/agentex/_client.py @@ -21,7 +21,7 @@ ) from ._utils import is_given, get_async_library from ._version import __version__ -from .resources import spans, tasks, agents, events, states, tracker +from .resources import spans, events, states, tracker from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import APIStatusError from ._base_client import ( @@ -29,6 +29,8 @@ SyncAPIClient, AsyncAPIClient, ) +from .resources.tasks import tasks +from .resources.agents import agents from .resources.messages import messages __all__ = [ diff --git a/src/agentex/resources/agents/__init__.py b/src/agentex/resources/agents/__init__.py new file mode 100644 index 00000000..374345e0 --- /dev/null +++ b/src/agentex/resources/agents/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .name import ( + NameResource, + AsyncNameResource, + NameResourceWithRawResponse, + AsyncNameResourceWithRawResponse, + NameResourceWithStreamingResponse, + AsyncNameResourceWithStreamingResponse, +) +from .agents import ( + AgentsResource, + AsyncAgentsResource, + AgentsResourceWithRawResponse, + AsyncAgentsResourceWithRawResponse, + AgentsResourceWithStreamingResponse, + AsyncAgentsResourceWithStreamingResponse, +) + +__all__ = [ + "NameResource", + "AsyncNameResource", + "NameResourceWithRawResponse", + "AsyncNameResourceWithRawResponse", + "NameResourceWithStreamingResponse", + "AsyncNameResourceWithStreamingResponse", + "AgentsResource", + "AsyncAgentsResource", + "AgentsResourceWithRawResponse", + "AsyncAgentsResourceWithRawResponse", + "AgentsResourceWithStreamingResponse", + "AsyncAgentsResourceWithStreamingResponse", +] diff --git a/src/agentex/resources/agents.py b/src/agentex/resources/agents/agents.py similarity index 94% rename from src/agentex/resources/agents.py rename to src/agentex/resources/agents/agents.py index 9c2e4bd5..cdd3b891 100644 --- a/src/agentex/resources/agents.py +++ b/src/agentex/resources/agents/agents.py @@ -7,25 +7,37 @@ import httpx -from ..types import agent_rpc_params, agent_list_params, agent_rpc_by_name_params -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._utils import maybe_transform, async_maybe_transform -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( +from .name import ( + NameResource, + AsyncNameResource, + NameResourceWithRawResponse, + AsyncNameResourceWithRawResponse, + NameResourceWithStreamingResponse, + AsyncNameResourceWithStreamingResponse, +) +from ...types import agent_rpc_params, agent_list_params, agent_rpc_by_name_params +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ..types.agent import Agent -from .._base_client import make_request_options -from ..types.agent_list_response import AgentListResponse +from ...types.agent import Agent +from ..._base_client import make_request_options +from ...types.agent_list_response import AgentListResponse __all__ = ["AgentsResource", "AsyncAgentsResource"] class AgentsResource(SyncAPIResource): + @cached_property + def name(self) -> NameResource: + return NameResource(self._client) + @cached_property def with_raw_response(self) -> AgentsResourceWithRawResponse: """ @@ -308,6 +320,10 @@ def rpc_by_name( class AsyncAgentsResource(AsyncAPIResource): + @cached_property + def name(self) -> AsyncNameResource: + return AsyncNameResource(self._client) + @cached_property def with_raw_response(self) -> AsyncAgentsResourceWithRawResponse: """ @@ -615,6 +631,10 @@ def __init__(self, agents: AgentsResource) -> None: agents.rpc_by_name, ) + @cached_property + def name(self) -> NameResourceWithRawResponse: + return NameResourceWithRawResponse(self._agents.name) + class AsyncAgentsResourceWithRawResponse: def __init__(self, agents: AsyncAgentsResource) -> None: @@ -642,6 +662,10 @@ def __init__(self, agents: AsyncAgentsResource) -> None: agents.rpc_by_name, ) + @cached_property + def name(self) -> AsyncNameResourceWithRawResponse: + return AsyncNameResourceWithRawResponse(self._agents.name) + class AgentsResourceWithStreamingResponse: def __init__(self, agents: AgentsResource) -> None: @@ -669,6 +693,10 @@ def __init__(self, agents: AgentsResource) -> None: agents.rpc_by_name, ) + @cached_property + def name(self) -> NameResourceWithStreamingResponse: + return NameResourceWithStreamingResponse(self._agents.name) + class AsyncAgentsResourceWithStreamingResponse: def __init__(self, agents: AsyncAgentsResource) -> None: @@ -695,3 +723,7 @@ def __init__(self, agents: AsyncAgentsResource) -> None: self.rpc_by_name = async_to_streamed_response_wrapper( agents.rpc_by_name, ) + + @cached_property + def name(self) -> AsyncNameResourceWithStreamingResponse: + return AsyncNameResourceWithStreamingResponse(self._agents.name) diff --git a/src/agentex/resources/agents/name.py b/src/agentex/resources/agents/name.py new file mode 100644 index 00000000..fd8c82f9 --- /dev/null +++ b/src/agentex/resources/agents/name.py @@ -0,0 +1,454 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...types.agent import Agent +from ..._base_client import make_request_options +from ...types.agents import name_rpc_params, name_handle_rpc_params + +__all__ = ["NameResource", "AsyncNameResource"] + + +class NameResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> NameResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers + """ + return NameResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> NameResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response + """ + return NameResourceWithStreamingResponse(self) + + def retrieve( + self, + agent_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Agent: + """ + Get an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return self._get( + f"/agents/name/{agent_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Agent, + ) + + def delete( + self, + agent_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Agent: + """ + Delete an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return self._delete( + f"/agents/name/{agent_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Agent, + ) + + def handle_rpc( + self, + agent_name: str, + *, + method: Literal["event/send", "task/create", "message/send", "task/cancel"], + params: name_handle_rpc_params.Params, + id: Union[int, str, None] | NotGiven = NOT_GIVEN, + jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Handle JSON-RPC requests for an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return self._post( + f"/agents/name/{agent_name}/rpc", + body=maybe_transform( + { + "method": method, + "params": params, + "id": id, + "jsonrpc": jsonrpc, + }, + name_handle_rpc_params.NameHandleRpcParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + def rpc( + self, + agent_name: str, + *, + method: Literal["event/send", "task/create", "message/send", "task/cancel"], + params: name_rpc_params.Params, + id: Union[int, str, None] | NotGiven = NOT_GIVEN, + jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Handle JSON-RPC requests for an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return self._post( + f"/agents/name/{agent_name}/rpc", + body=maybe_transform( + { + "method": method, + "params": params, + "id": id, + "jsonrpc": jsonrpc, + }, + name_rpc_params.NameRpcParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncNameResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncNameResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers + """ + return AsyncNameResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncNameResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response + """ + return AsyncNameResourceWithStreamingResponse(self) + + async def retrieve( + self, + agent_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Agent: + """ + Get an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return await self._get( + f"/agents/name/{agent_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Agent, + ) + + async def delete( + self, + agent_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Agent: + """ + Delete an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return await self._delete( + f"/agents/name/{agent_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Agent, + ) + + async def handle_rpc( + self, + agent_name: str, + *, + method: Literal["event/send", "task/create", "message/send", "task/cancel"], + params: name_handle_rpc_params.Params, + id: Union[int, str, None] | NotGiven = NOT_GIVEN, + jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Handle JSON-RPC requests for an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return await self._post( + f"/agents/name/{agent_name}/rpc", + body=await async_maybe_transform( + { + "method": method, + "params": params, + "id": id, + "jsonrpc": jsonrpc, + }, + name_handle_rpc_params.NameHandleRpcParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + async def rpc( + self, + agent_name: str, + *, + method: Literal["event/send", "task/create", "message/send", "task/cancel"], + params: name_rpc_params.Params, + id: Union[int, str, None] | NotGiven = NOT_GIVEN, + jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Handle JSON-RPC requests for an agent by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not agent_name: + raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") + return await self._post( + f"/agents/name/{agent_name}/rpc", + body=await async_maybe_transform( + { + "method": method, + "params": params, + "id": id, + "jsonrpc": jsonrpc, + }, + name_rpc_params.NameRpcParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class NameResourceWithRawResponse: + def __init__(self, name: NameResource) -> None: + self._name = name + + self.retrieve = to_raw_response_wrapper( + name.retrieve, + ) + self.delete = to_raw_response_wrapper( + name.delete, + ) + self.handle_rpc = to_raw_response_wrapper( + name.handle_rpc, + ) + self.rpc = to_raw_response_wrapper( + name.rpc, + ) + + +class AsyncNameResourceWithRawResponse: + def __init__(self, name: AsyncNameResource) -> None: + self._name = name + + self.retrieve = async_to_raw_response_wrapper( + name.retrieve, + ) + self.delete = async_to_raw_response_wrapper( + name.delete, + ) + self.handle_rpc = async_to_raw_response_wrapper( + name.handle_rpc, + ) + self.rpc = async_to_raw_response_wrapper( + name.rpc, + ) + + +class NameResourceWithStreamingResponse: + def __init__(self, name: NameResource) -> None: + self._name = name + + self.retrieve = to_streamed_response_wrapper( + name.retrieve, + ) + self.delete = to_streamed_response_wrapper( + name.delete, + ) + self.handle_rpc = to_streamed_response_wrapper( + name.handle_rpc, + ) + self.rpc = to_streamed_response_wrapper( + name.rpc, + ) + + +class AsyncNameResourceWithStreamingResponse: + def __init__(self, name: AsyncNameResource) -> None: + self._name = name + + self.retrieve = async_to_streamed_response_wrapper( + name.retrieve, + ) + self.delete = async_to_streamed_response_wrapper( + name.delete, + ) + self.handle_rpc = async_to_streamed_response_wrapper( + name.handle_rpc, + ) + self.rpc = async_to_streamed_response_wrapper( + name.rpc, + ) diff --git a/src/agentex/resources/tasks/__init__.py b/src/agentex/resources/tasks/__init__.py new file mode 100644 index 00000000..5a9c81b0 --- /dev/null +++ b/src/agentex/resources/tasks/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .name import ( + NameResource, + AsyncNameResource, + NameResourceWithRawResponse, + AsyncNameResourceWithRawResponse, + NameResourceWithStreamingResponse, + AsyncNameResourceWithStreamingResponse, +) +from .tasks import ( + TasksResource, + AsyncTasksResource, + TasksResourceWithRawResponse, + AsyncTasksResourceWithRawResponse, + TasksResourceWithStreamingResponse, + AsyncTasksResourceWithStreamingResponse, +) + +__all__ = [ + "NameResource", + "AsyncNameResource", + "NameResourceWithRawResponse", + "AsyncNameResourceWithRawResponse", + "NameResourceWithStreamingResponse", + "AsyncNameResourceWithStreamingResponse", + "TasksResource", + "AsyncTasksResource", + "TasksResourceWithRawResponse", + "AsyncTasksResourceWithRawResponse", + "TasksResourceWithStreamingResponse", + "AsyncTasksResourceWithStreamingResponse", +] diff --git a/src/agentex/resources/tasks/name.py b/src/agentex/resources/tasks/name.py new file mode 100644 index 00000000..7cef42eb --- /dev/null +++ b/src/agentex/resources/tasks/name.py @@ -0,0 +1,324 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._streaming import Stream, AsyncStream +from ...types.task import Task +from ..._base_client import make_request_options + +__all__ = ["NameResource", "AsyncNameResource"] + + +class NameResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> NameResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers + """ + return NameResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> NameResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response + """ + return NameResourceWithStreamingResponse(self) + + def retrieve( + self, + task_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Task: + """ + Get a task by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not task_name: + raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") + return self._get( + f"/tasks/name/{task_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Task, + ) + + def delete( + self, + task_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Task: + """ + Delete a task by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not task_name: + raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") + return self._delete( + f"/tasks/name/{task_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Task, + ) + + def stream_events( + self, + task_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Stream[object]: + """ + Stream events for a task by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not task_name: + raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") + return self._get( + f"/tasks/name/{task_name}/stream", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + stream=True, + stream_cls=Stream[object], + ) + + +class AsyncNameResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncNameResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers + """ + return AsyncNameResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncNameResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response + """ + return AsyncNameResourceWithStreamingResponse(self) + + async def retrieve( + self, + task_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Task: + """ + Get a task by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not task_name: + raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") + return await self._get( + f"/tasks/name/{task_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Task, + ) + + async def delete( + self, + task_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Task: + """ + Delete a task by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not task_name: + raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") + return await self._delete( + f"/tasks/name/{task_name}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Task, + ) + + async def stream_events( + self, + task_name: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncStream[object]: + """ + Stream events for a task by its unique name. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not task_name: + raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") + return await self._get( + f"/tasks/name/{task_name}/stream", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + stream=True, + stream_cls=AsyncStream[object], + ) + + +class NameResourceWithRawResponse: + def __init__(self, name: NameResource) -> None: + self._name = name + + self.retrieve = to_raw_response_wrapper( + name.retrieve, + ) + self.delete = to_raw_response_wrapper( + name.delete, + ) + self.stream_events = to_raw_response_wrapper( + name.stream_events, + ) + + +class AsyncNameResourceWithRawResponse: + def __init__(self, name: AsyncNameResource) -> None: + self._name = name + + self.retrieve = async_to_raw_response_wrapper( + name.retrieve, + ) + self.delete = async_to_raw_response_wrapper( + name.delete, + ) + self.stream_events = async_to_raw_response_wrapper( + name.stream_events, + ) + + +class NameResourceWithStreamingResponse: + def __init__(self, name: NameResource) -> None: + self._name = name + + self.retrieve = to_streamed_response_wrapper( + name.retrieve, + ) + self.delete = to_streamed_response_wrapper( + name.delete, + ) + self.stream_events = to_streamed_response_wrapper( + name.stream_events, + ) + + +class AsyncNameResourceWithStreamingResponse: + def __init__(self, name: AsyncNameResource) -> None: + self._name = name + + self.retrieve = async_to_streamed_response_wrapper( + name.retrieve, + ) + self.delete = async_to_streamed_response_wrapper( + name.delete, + ) + self.stream_events = async_to_streamed_response_wrapper( + name.stream_events, + ) diff --git a/src/agentex/resources/tasks.py b/src/agentex/resources/tasks/tasks.py similarity index 94% rename from src/agentex/resources/tasks.py rename to src/agentex/resources/tasks/tasks.py index 936ee66c..ce1a7813 100644 --- a/src/agentex/resources/tasks.py +++ b/src/agentex/resources/tasks/tasks.py @@ -4,24 +4,36 @@ import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( +from .name import ( + NameResource, + AsyncNameResource, + NameResourceWithRawResponse, + AsyncNameResourceWithRawResponse, + NameResourceWithStreamingResponse, + AsyncNameResourceWithStreamingResponse, +) +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from .._streaming import Stream, AsyncStream -from ..types.task import Task -from .._base_client import make_request_options -from ..types.task_list_response import TaskListResponse +from ..._streaming import Stream, AsyncStream +from ...types.task import Task +from ..._base_client import make_request_options +from ...types.task_list_response import TaskListResponse __all__ = ["TasksResource", "AsyncTasksResource"] class TasksResource(SyncAPIResource): + @cached_property + def name(self) -> NameResource: + return NameResource(self._client) + @cached_property def with_raw_response(self) -> TasksResourceWithRawResponse: """ @@ -264,6 +276,10 @@ def stream_events_by_name( class AsyncTasksResource(AsyncAPIResource): + @cached_property + def name(self) -> AsyncNameResource: + return AsyncNameResource(self._client) + @cached_property def with_raw_response(self) -> AsyncTasksResourceWithRawResponse: """ @@ -531,6 +547,10 @@ def __init__(self, tasks: TasksResource) -> None: tasks.stream_events_by_name, ) + @cached_property + def name(self) -> NameResourceWithRawResponse: + return NameResourceWithRawResponse(self._tasks.name) + class AsyncTasksResourceWithRawResponse: def __init__(self, tasks: AsyncTasksResource) -> None: @@ -558,6 +578,10 @@ def __init__(self, tasks: AsyncTasksResource) -> None: tasks.stream_events_by_name, ) + @cached_property + def name(self) -> AsyncNameResourceWithRawResponse: + return AsyncNameResourceWithRawResponse(self._tasks.name) + class TasksResourceWithStreamingResponse: def __init__(self, tasks: TasksResource) -> None: @@ -585,6 +609,10 @@ def __init__(self, tasks: TasksResource) -> None: tasks.stream_events_by_name, ) + @cached_property + def name(self) -> NameResourceWithStreamingResponse: + return NameResourceWithStreamingResponse(self._tasks.name) + class AsyncTasksResourceWithStreamingResponse: def __init__(self, tasks: AsyncTasksResource) -> None: @@ -611,3 +639,7 @@ def __init__(self, tasks: AsyncTasksResource) -> None: self.stream_events_by_name = async_to_streamed_response_wrapper( tasks.stream_events_by_name, ) + + @cached_property + def name(self) -> AsyncNameResourceWithStreamingResponse: + return AsyncNameResourceWithStreamingResponse(self._tasks.name) diff --git a/src/agentex/types/agents/__init__.py b/src/agentex/types/agents/__init__.py new file mode 100644 index 00000000..6211202a --- /dev/null +++ b/src/agentex/types/agents/__init__.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .name_rpc_params import NameRpcParams as NameRpcParams +from .name_handle_rpc_params import NameHandleRpcParams as NameHandleRpcParams diff --git a/src/agentex/types/agents/name_handle_rpc_params.py b/src/agentex/types/agents/name_handle_rpc_params.py new file mode 100644 index 00000000..d1d903a6 --- /dev/null +++ b/src/agentex/types/agents/name_handle_rpc_params.py @@ -0,0 +1,85 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Optional +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +from ..data_content_param import DataContentParam +from ..text_content_param import TextContentParam +from ..tool_request_content_param import ToolRequestContentParam +from ..tool_response_content_param import ToolResponseContentParam + +__all__ = [ + "NameHandleRpcParams", + "Params", + "ParamsCreateTaskRequest", + "ParamsCancelTaskRequest", + "ParamsSendMessageRequest", + "ParamsSendMessageRequestContent", + "ParamsSendEventRequest", + "ParamsSendEventRequestContent", +] + + +class NameHandleRpcParams(TypedDict, total=False): + method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] + + params: Required[Params] + + id: Union[int, str, None] + + jsonrpc: Literal["2.0"] + + +class ParamsCreateTaskRequest(TypedDict, total=False): + name: Optional[str] + """The name of the task to create""" + + params: Optional[Dict[str, object]] + """The parameters for the task""" + + +class ParamsCancelTaskRequest(TypedDict, total=False): + task_id: Optional[str] + """The ID of the task to cancel. Either this or task_name must be provided.""" + + task_name: Optional[str] + """The name of the task to cancel. Either this or task_id must be provided.""" + + +ParamsSendMessageRequestContent: TypeAlias = Union[ + TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam +] + + +class ParamsSendMessageRequest(TypedDict, total=False): + content: Required[ParamsSendMessageRequestContent] + """The message that was sent to the agent""" + + stream: bool + """Whether to stream the response message back to the client""" + + task_id: Optional[str] + """The ID of the task that the message was sent to""" + + +ParamsSendEventRequestContent: TypeAlias = Union[ + TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam +] + + +class ParamsSendEventRequest(TypedDict, total=False): + content: Optional[ParamsSendEventRequestContent] + """The content to send to the event""" + + task_id: Optional[str] + """The ID of the task that the event was sent to""" + + task_name: Optional[str] + """The name of the task that the event was sent to""" + + +Params: TypeAlias = Union[ + ParamsCreateTaskRequest, ParamsCancelTaskRequest, ParamsSendMessageRequest, ParamsSendEventRequest +] diff --git a/src/agentex/types/agents/name_rpc_params.py b/src/agentex/types/agents/name_rpc_params.py new file mode 100644 index 00000000..6a68b0ba --- /dev/null +++ b/src/agentex/types/agents/name_rpc_params.py @@ -0,0 +1,85 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Optional +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +from ..data_content_param import DataContentParam +from ..text_content_param import TextContentParam +from ..tool_request_content_param import ToolRequestContentParam +from ..tool_response_content_param import ToolResponseContentParam + +__all__ = [ + "NameRpcParams", + "Params", + "ParamsCreateTaskRequest", + "ParamsCancelTaskRequest", + "ParamsSendMessageRequest", + "ParamsSendMessageRequestContent", + "ParamsSendEventRequest", + "ParamsSendEventRequestContent", +] + + +class NameRpcParams(TypedDict, total=False): + method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] + + params: Required[Params] + + id: Union[int, str, None] + + jsonrpc: Literal["2.0"] + + +class ParamsCreateTaskRequest(TypedDict, total=False): + name: Optional[str] + """The name of the task to create""" + + params: Optional[Dict[str, object]] + """The parameters for the task""" + + +class ParamsCancelTaskRequest(TypedDict, total=False): + task_id: Optional[str] + """The ID of the task to cancel. Either this or task_name must be provided.""" + + task_name: Optional[str] + """The name of the task to cancel. Either this or task_id must be provided.""" + + +ParamsSendMessageRequestContent: TypeAlias = Union[ + TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam +] + + +class ParamsSendMessageRequest(TypedDict, total=False): + content: Required[ParamsSendMessageRequestContent] + """The message that was sent to the agent""" + + stream: bool + """Whether to stream the response message back to the client""" + + task_id: Optional[str] + """The ID of the task that the message was sent to""" + + +ParamsSendEventRequestContent: TypeAlias = Union[ + TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam +] + + +class ParamsSendEventRequest(TypedDict, total=False): + content: Optional[ParamsSendEventRequestContent] + """The content to send to the event""" + + task_id: Optional[str] + """The ID of the task that the event was sent to""" + + task_name: Optional[str] + """The name of the task that the event was sent to""" + + +Params: TypeAlias = Union[ + ParamsCreateTaskRequest, ParamsCancelTaskRequest, ParamsSendMessageRequest, ParamsSendEventRequest +] diff --git a/src/agentex/types/tasks/__init__.py b/src/agentex/types/tasks/__init__.py new file mode 100644 index 00000000..f8ee8b14 --- /dev/null +++ b/src/agentex/types/tasks/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/tests/api_resources/agents/__init__.py b/tests/api_resources/agents/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/agents/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/agents/test_name.py b/tests/api_resources/agents/test_name.py new file mode 100644 index 00000000..dea82f12 --- /dev/null +++ b/tests/api_resources/agents/test_name.py @@ -0,0 +1,452 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from agentex import Agentex, AsyncAgentex +from tests.utils import assert_matches_type +from agentex.types import Agent + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestName: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_retrieve(self, client: Agentex) -> None: + name = client.agents.name.retrieve( + "agent_name", + ) + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_retrieve(self, client: Agentex) -> None: + response = client.agents.name.with_raw_response.retrieve( + "agent_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = response.parse() + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_retrieve(self, client: Agentex) -> None: + with client.agents.name.with_streaming_response.retrieve( + "agent_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = response.parse() + assert_matches_type(Agent, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_retrieve(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + client.agents.name.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Agentex) -> None: + name = client.agents.name.delete( + "agent_name", + ) + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Agentex) -> None: + response = client.agents.name.with_raw_response.delete( + "agent_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = response.parse() + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Agentex) -> None: + with client.agents.name.with_streaming_response.delete( + "agent_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = response.parse() + assert_matches_type(Agent, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + client.agents.name.with_raw_response.delete( + "", + ) + + @pytest.mark.skip() + @parametrize + def test_method_handle_rpc(self, client: Agentex) -> None: + name = client.agents.name.handle_rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_handle_rpc_with_all_params(self, client: Agentex) -> None: + name = client.agents.name.handle_rpc( + agent_name="agent_name", + method="event/send", + params={ + "name": "name", + "params": {"foo": "bar"}, + }, + id=0, + jsonrpc="2.0", + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_handle_rpc(self, client: Agentex) -> None: + response = client.agents.name.with_raw_response.handle_rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = response.parse() + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_handle_rpc(self, client: Agentex) -> None: + with client.agents.name.with_streaming_response.handle_rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = response.parse() + assert_matches_type(object, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_handle_rpc(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + client.agents.name.with_raw_response.handle_rpc( + agent_name="", + method="event/send", + params={}, + ) + + @pytest.mark.skip() + @parametrize + def test_method_rpc(self, client: Agentex) -> None: + name = client.agents.name.rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_rpc_with_all_params(self, client: Agentex) -> None: + name = client.agents.name.rpc( + agent_name="agent_name", + method="event/send", + params={ + "name": "name", + "params": {"foo": "bar"}, + }, + id=0, + jsonrpc="2.0", + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_rpc(self, client: Agentex) -> None: + response = client.agents.name.with_raw_response.rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = response.parse() + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_rpc(self, client: Agentex) -> None: + with client.agents.name.with_streaming_response.rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = response.parse() + assert_matches_type(object, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_rpc(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + client.agents.name.with_raw_response.rpc( + agent_name="", + method="event/send", + params={}, + ) + + +class TestAsyncName: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip() + @parametrize + async def test_method_retrieve(self, async_client: AsyncAgentex) -> None: + name = await async_client.agents.name.retrieve( + "agent_name", + ) + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncAgentex) -> None: + response = await async_client.agents.name.with_raw_response.retrieve( + "agent_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = await response.parse() + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncAgentex) -> None: + async with async_client.agents.name.with_streaming_response.retrieve( + "agent_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = await response.parse() + assert_matches_type(Agent, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + await async_client.agents.name.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncAgentex) -> None: + name = await async_client.agents.name.delete( + "agent_name", + ) + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncAgentex) -> None: + response = await async_client.agents.name.with_raw_response.delete( + "agent_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = await response.parse() + assert_matches_type(Agent, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncAgentex) -> None: + async with async_client.agents.name.with_streaming_response.delete( + "agent_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = await response.parse() + assert_matches_type(Agent, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + await async_client.agents.name.with_raw_response.delete( + "", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_handle_rpc(self, async_client: AsyncAgentex) -> None: + name = await async_client.agents.name.handle_rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_handle_rpc_with_all_params(self, async_client: AsyncAgentex) -> None: + name = await async_client.agents.name.handle_rpc( + agent_name="agent_name", + method="event/send", + params={ + "name": "name", + "params": {"foo": "bar"}, + }, + id=0, + jsonrpc="2.0", + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_handle_rpc(self, async_client: AsyncAgentex) -> None: + response = await async_client.agents.name.with_raw_response.handle_rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = await response.parse() + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_handle_rpc(self, async_client: AsyncAgentex) -> None: + async with async_client.agents.name.with_streaming_response.handle_rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = await response.parse() + assert_matches_type(object, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_handle_rpc(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + await async_client.agents.name.with_raw_response.handle_rpc( + agent_name="", + method="event/send", + params={}, + ) + + @pytest.mark.skip() + @parametrize + async def test_method_rpc(self, async_client: AsyncAgentex) -> None: + name = await async_client.agents.name.rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_rpc_with_all_params(self, async_client: AsyncAgentex) -> None: + name = await async_client.agents.name.rpc( + agent_name="agent_name", + method="event/send", + params={ + "name": "name", + "params": {"foo": "bar"}, + }, + id=0, + jsonrpc="2.0", + ) + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_rpc(self, async_client: AsyncAgentex) -> None: + response = await async_client.agents.name.with_raw_response.rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = await response.parse() + assert_matches_type(object, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_rpc(self, async_client: AsyncAgentex) -> None: + async with async_client.agents.name.with_streaming_response.rpc( + agent_name="agent_name", + method="event/send", + params={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = await response.parse() + assert_matches_type(object, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_rpc(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): + await async_client.agents.name.with_raw_response.rpc( + agent_name="", + method="event/send", + params={}, + ) diff --git a/tests/api_resources/tasks/__init__.py b/tests/api_resources/tasks/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/tasks/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/tasks/test_name.py b/tests/api_resources/tasks/test_name.py new file mode 100644 index 00000000..cb000659 --- /dev/null +++ b/tests/api_resources/tasks/test_name.py @@ -0,0 +1,274 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from agentex import Agentex, AsyncAgentex +from tests.utils import assert_matches_type +from agentex.types import Task + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestName: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_retrieve(self, client: Agentex) -> None: + name = client.tasks.name.retrieve( + "task_name", + ) + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_retrieve(self, client: Agentex) -> None: + response = client.tasks.name.with_raw_response.retrieve( + "task_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = response.parse() + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_retrieve(self, client: Agentex) -> None: + with client.tasks.name.with_streaming_response.retrieve( + "task_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = response.parse() + assert_matches_type(Task, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_retrieve(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): + client.tasks.name.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Agentex) -> None: + name = client.tasks.name.delete( + "task_name", + ) + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Agentex) -> None: + response = client.tasks.name.with_raw_response.delete( + "task_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = response.parse() + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Agentex) -> None: + with client.tasks.name.with_streaming_response.delete( + "task_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = response.parse() + assert_matches_type(Task, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): + client.tasks.name.with_raw_response.delete( + "", + ) + + @pytest.mark.skip() + @parametrize + def test_method_stream_events(self, client: Agentex) -> None: + name_stream = client.tasks.name.stream_events( + "task_name", + ) + name_stream.response.close() + + @pytest.mark.skip() + @parametrize + def test_raw_response_stream_events(self, client: Agentex) -> None: + response = client.tasks.name.with_raw_response.stream_events( + "task_name", + ) + + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + stream = response.parse() + stream.close() + + @pytest.mark.skip() + @parametrize + def test_streaming_response_stream_events(self, client: Agentex) -> None: + with client.tasks.name.with_streaming_response.stream_events( + "task_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + stream = response.parse() + stream.close() + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_stream_events(self, client: Agentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): + client.tasks.name.with_raw_response.stream_events( + "", + ) + + +class TestAsyncName: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip() + @parametrize + async def test_method_retrieve(self, async_client: AsyncAgentex) -> None: + name = await async_client.tasks.name.retrieve( + "task_name", + ) + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncAgentex) -> None: + response = await async_client.tasks.name.with_raw_response.retrieve( + "task_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = await response.parse() + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncAgentex) -> None: + async with async_client.tasks.name.with_streaming_response.retrieve( + "task_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = await response.parse() + assert_matches_type(Task, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): + await async_client.tasks.name.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncAgentex) -> None: + name = await async_client.tasks.name.delete( + "task_name", + ) + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncAgentex) -> None: + response = await async_client.tasks.name.with_raw_response.delete( + "task_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + name = await response.parse() + assert_matches_type(Task, name, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncAgentex) -> None: + async with async_client.tasks.name.with_streaming_response.delete( + "task_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + name = await response.parse() + assert_matches_type(Task, name, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): + await async_client.tasks.name.with_raw_response.delete( + "", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_stream_events(self, async_client: AsyncAgentex) -> None: + name_stream = await async_client.tasks.name.stream_events( + "task_name", + ) + await name_stream.response.aclose() + + @pytest.mark.skip() + @parametrize + async def test_raw_response_stream_events(self, async_client: AsyncAgentex) -> None: + response = await async_client.tasks.name.with_raw_response.stream_events( + "task_name", + ) + + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + stream = await response.parse() + await stream.close() + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_stream_events(self, async_client: AsyncAgentex) -> None: + async with async_client.tasks.name.with_streaming_response.stream_events( + "task_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + stream = await response.parse() + await stream.close() + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_stream_events(self, async_client: AsyncAgentex) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): + await async_client.tasks.name.with_raw_response.stream_events( + "", + ) diff --git a/tests/conftest.py b/tests/conftest.py index b6e6697e..d08e65cf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -45,6 +45,8 @@ def pytest_collection_modifyitems(items: list[pytest.Function]) -> None: base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") +api_key = "My API Key" + @pytest.fixture(scope="session") def client(request: FixtureRequest) -> Iterator[Agentex]: @@ -52,7 +54,7 @@ def client(request: FixtureRequest) -> Iterator[Agentex]: if not isinstance(strict, bool): raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}") - with Agentex(base_url=base_url, _strict_response_validation=strict) as client: + with Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client: yield client @@ -76,5 +78,7 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncAgentex]: else: raise TypeError(f"Unexpected fixture parameter type {type(param)}, expected bool or dict") - async with AsyncAgentex(base_url=base_url, _strict_response_validation=strict, http_client=http_client) as client: + async with AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=strict, http_client=http_client + ) as client: yield client diff --git a/tests/test_client.py b/tests/test_client.py index 2fe22ed9..da5399da 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -37,6 +37,7 @@ from .utils import update_env base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") +api_key = "My API Key" def _get_params(client: BaseClient[Any, Any]) -> dict[str, str]: @@ -58,7 +59,7 @@ def _get_open_connections(client: Agentex | AsyncAgentex) -> int: class TestAgentex: - client = Agentex(base_url=base_url, _strict_response_validation=True) + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) @pytest.mark.respx(base_url=base_url) def test_raw_response(self, respx_mock: MockRouter) -> None: @@ -84,6 +85,10 @@ def test_copy(self) -> None: copied = self.client.copy() assert id(copied) != id(self.client) + copied = self.client.copy(api_key="another My API Key") + assert copied.api_key == "another My API Key" + assert self.client.api_key == "My API Key" + def test_copy_default_options(self) -> None: # options that have a default are overridden correctly copied = self.client.copy(max_retries=7) @@ -101,7 +106,9 @@ def test_copy_default_options(self) -> None: assert isinstance(self.client.timeout, httpx.Timeout) def test_copy_default_headers(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True, default_headers={"X-Foo": "bar"}) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"} + ) assert client.default_headers["X-Foo"] == "bar" # does not override the already given value when not specified @@ -133,7 +140,9 @@ def test_copy_default_headers(self) -> None: client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"}) def test_copy_default_query(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True, default_query={"foo": "bar"}) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"} + ) assert _get_params(client)["foo"] == "bar" # does not override the already given value when not specified @@ -257,7 +266,7 @@ def test_request_timeout(self) -> None: assert timeout == httpx.Timeout(100.0) def test_client_timeout_option(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True, timeout=httpx.Timeout(0)) + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0)) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -266,7 +275,9 @@ def test_client_timeout_option(self) -> None: def test_http_client_timeout_option(self) -> None: # custom timeout given to the httpx client should be used with httpx.Client(timeout=None) as http_client: - client = Agentex(base_url=base_url, _strict_response_validation=True, http_client=http_client) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -274,7 +285,9 @@ def test_http_client_timeout_option(self) -> None: # no timeout given to the httpx client should not use the httpx default with httpx.Client() as http_client: - client = Agentex(base_url=base_url, _strict_response_validation=True, http_client=http_client) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -282,7 +295,9 @@ def test_http_client_timeout_option(self) -> None: # explicitly passing the default timeout currently results in it being ignored with httpx.Client(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client: - client = Agentex(base_url=base_url, _strict_response_validation=True, http_client=http_client) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -291,16 +306,24 @@ def test_http_client_timeout_option(self) -> None: async def test_invalid_http_client(self) -> None: with pytest.raises(TypeError, match="Invalid `http_client` arg"): async with httpx.AsyncClient() as http_client: - Agentex(base_url=base_url, _strict_response_validation=True, http_client=cast(Any, http_client)) + Agentex( + base_url=base_url, + api_key=api_key, + _strict_response_validation=True, + http_client=cast(Any, http_client), + ) def test_default_headers_option(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True, default_headers={"X-Foo": "bar"}) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"} + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) assert request.headers.get("x-foo") == "bar" assert request.headers.get("x-stainless-lang") == "python" client2 = Agentex( base_url=base_url, + api_key=api_key, _strict_response_validation=True, default_headers={ "X-Foo": "stainless", @@ -311,8 +334,20 @@ def test_default_headers_option(self) -> None: assert request.headers.get("x-foo") == "stainless" assert request.headers.get("x-stainless-lang") == "my-overriding-header" + def test_validate_headers(self) -> None: + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) + request = client._build_request(FinalRequestOptions(method="get", url="/foo")) + assert request.headers.get("Authorization") == f"Bearer {api_key}" + + with update_env(**{"AGENTEX_SDK_API_KEY": Omit()}): + client2 = Agentex(base_url=base_url, api_key=None, _strict_response_validation=True) + + client2._build_request(FinalRequestOptions(method="get", url="/foo")) + def test_default_query_option(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True, default_query={"query_param": "bar"}) + client = Agentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"} + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) url = httpx.URL(request.url) assert dict(url.params) == {"query_param": "bar"} @@ -511,7 +546,7 @@ class Model(BaseModel): assert response.foo == 2 def test_base_url_setter(self) -> None: - client = Agentex(base_url="https://example.com/from_init", _strict_response_validation=True) + client = Agentex(base_url="https://example.com/from_init", api_key=api_key, _strict_response_validation=True) assert client.base_url == "https://example.com/from_init/" client.base_url = "https://example.com/from_setter" # type: ignore[assignment] @@ -520,23 +555,24 @@ def test_base_url_setter(self) -> None: def test_base_url_env(self) -> None: with update_env(AGENTEX_BASE_URL="http://localhost:5000/from/env"): - client = Agentex(_strict_response_validation=True) + client = Agentex(api_key=api_key, _strict_response_validation=True) assert client.base_url == "http://localhost:5000/from/env/" # explicit environment arg requires explicitness with update_env(AGENTEX_BASE_URL="http://localhost:5000/from/env"): with pytest.raises(ValueError, match=r"you must pass base_url=None"): - Agentex(_strict_response_validation=True, environment="production") + Agentex(api_key=api_key, _strict_response_validation=True, environment="production") - client = Agentex(base_url=None, _strict_response_validation=True, environment="production") + client = Agentex(base_url=None, api_key=api_key, _strict_response_validation=True, environment="production") assert str(client.base_url).startswith("http://localhost:5003") @pytest.mark.parametrize( "client", [ - Agentex(base_url="http://localhost:5000/custom/path/", _strict_response_validation=True), + Agentex(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), Agentex( base_url="http://localhost:5000/custom/path/", + api_key=api_key, _strict_response_validation=True, http_client=httpx.Client(), ), @@ -556,9 +592,10 @@ def test_base_url_trailing_slash(self, client: Agentex) -> None: @pytest.mark.parametrize( "client", [ - Agentex(base_url="http://localhost:5000/custom/path/", _strict_response_validation=True), + Agentex(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), Agentex( base_url="http://localhost:5000/custom/path/", + api_key=api_key, _strict_response_validation=True, http_client=httpx.Client(), ), @@ -578,9 +615,10 @@ def test_base_url_no_trailing_slash(self, client: Agentex) -> None: @pytest.mark.parametrize( "client", [ - Agentex(base_url="http://localhost:5000/custom/path/", _strict_response_validation=True), + Agentex(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), Agentex( base_url="http://localhost:5000/custom/path/", + api_key=api_key, _strict_response_validation=True, http_client=httpx.Client(), ), @@ -598,7 +636,7 @@ def test_absolute_request_url(self, client: Agentex) -> None: assert request.url == "https://myapi.com/foo" def test_copied_client_does_not_close_http(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True) + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) assert not client.is_closed() copied = client.copy() @@ -609,7 +647,7 @@ def test_copied_client_does_not_close_http(self) -> None: assert not client.is_closed() def test_client_context_manager(self) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True) + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) with client as c2: assert c2 is client assert not c2.is_closed() @@ -630,7 +668,7 @@ class Model(BaseModel): def test_client_max_retries_validation(self) -> None: with pytest.raises(TypeError, match=r"max_retries cannot be None"): - Agentex(base_url=base_url, _strict_response_validation=True, max_retries=cast(Any, None)) + Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None)) @pytest.mark.respx(base_url=base_url) def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None: @@ -639,12 +677,12 @@ class Model(BaseModel): respx_mock.get("/foo").mock(return_value=httpx.Response(200, text="my-custom-format")) - strict_client = Agentex(base_url=base_url, _strict_response_validation=True) + strict_client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) with pytest.raises(APIResponseValidationError): strict_client.get("/foo", cast_to=Model) - client = Agentex(base_url=base_url, _strict_response_validation=False) + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=False) response = client.get("/foo", cast_to=Model) assert isinstance(response, str) # type: ignore[unreachable] @@ -672,7 +710,7 @@ class Model(BaseModel): ) @mock.patch("time.time", mock.MagicMock(return_value=1696004797)) def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None: - client = Agentex(base_url=base_url, _strict_response_validation=True) + client = Agentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) headers = httpx.Headers({"retry-after": retry_after}) options = FinalRequestOptions(method="get", url="/foo", max_retries=3) @@ -682,20 +720,20 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str @mock.patch("agentex._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Agentex) -> None: - respx_mock.get("/agents/agent_id").mock(side_effect=httpx.TimeoutException("Test timeout error")) + respx_mock.get("/tasks").mock(side_effect=httpx.TimeoutException("Test timeout error")) with pytest.raises(APITimeoutError): - client.agents.with_streaming_response.retrieve("agent_id").__enter__() + client.tasks.with_streaming_response.list().__enter__() assert _get_open_connections(self.client) == 0 @mock.patch("agentex._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Agentex) -> None: - respx_mock.get("/agents/agent_id").mock(return_value=httpx.Response(500)) + respx_mock.get("/tasks").mock(return_value=httpx.Response(500)) with pytest.raises(APIStatusError): - client.agents.with_streaming_response.retrieve("agent_id").__enter__() + client.tasks.with_streaming_response.list().__enter__() assert _get_open_connections(self.client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @@ -722,9 +760,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.get("/agents/agent_id").mock(side_effect=retry_handler) + respx_mock.get("/tasks").mock(side_effect=retry_handler) - response = client.agents.with_raw_response.retrieve("agent_id") + response = client.tasks.with_raw_response.list() assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -746,11 +784,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.get("/agents/agent_id").mock(side_effect=retry_handler) + respx_mock.get("/tasks").mock(side_effect=retry_handler) - response = client.agents.with_raw_response.retrieve( - "agent_id", extra_headers={"x-stainless-retry-count": Omit()} - ) + response = client.tasks.with_raw_response.list(extra_headers={"x-stainless-retry-count": Omit()}) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -771,9 +807,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.get("/agents/agent_id").mock(side_effect=retry_handler) + respx_mock.get("/tasks").mock(side_effect=retry_handler) - response = client.agents.with_raw_response.retrieve("agent_id", extra_headers={"x-stainless-retry-count": "42"}) + response = client.tasks.with_raw_response.list(extra_headers={"x-stainless-retry-count": "42"}) assert response.http_request.headers.get("x-stainless-retry-count") == "42" @@ -828,7 +864,7 @@ def test_follow_redirects_disabled(self, respx_mock: MockRouter) -> None: class TestAsyncAgentex: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True) + client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) @pytest.mark.respx(base_url=base_url) @pytest.mark.asyncio @@ -856,6 +892,10 @@ def test_copy(self) -> None: copied = self.client.copy() assert id(copied) != id(self.client) + copied = self.client.copy(api_key="another My API Key") + assert copied.api_key == "another My API Key" + assert self.client.api_key == "My API Key" + def test_copy_default_options(self) -> None: # options that have a default are overridden correctly copied = self.client.copy(max_retries=7) @@ -873,7 +913,9 @@ def test_copy_default_options(self) -> None: assert isinstance(self.client.timeout, httpx.Timeout) def test_copy_default_headers(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, default_headers={"X-Foo": "bar"}) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"} + ) assert client.default_headers["X-Foo"] == "bar" # does not override the already given value when not specified @@ -905,7 +947,9 @@ def test_copy_default_headers(self) -> None: client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"}) def test_copy_default_query(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, default_query={"foo": "bar"}) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"} + ) assert _get_params(client)["foo"] == "bar" # does not override the already given value when not specified @@ -1029,7 +1073,9 @@ async def test_request_timeout(self) -> None: assert timeout == httpx.Timeout(100.0) async def test_client_timeout_option(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, timeout=httpx.Timeout(0)) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0) + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -1038,7 +1084,9 @@ async def test_client_timeout_option(self) -> None: async def test_http_client_timeout_option(self) -> None: # custom timeout given to the httpx client should be used async with httpx.AsyncClient(timeout=None) as http_client: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, http_client=http_client) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -1046,7 +1094,9 @@ async def test_http_client_timeout_option(self) -> None: # no timeout given to the httpx client should not use the httpx default async with httpx.AsyncClient() as http_client: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, http_client=http_client) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -1054,7 +1104,9 @@ async def test_http_client_timeout_option(self) -> None: # explicitly passing the default timeout currently results in it being ignored async with httpx.AsyncClient(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, http_client=http_client) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -1063,16 +1115,24 @@ async def test_http_client_timeout_option(self) -> None: def test_invalid_http_client(self) -> None: with pytest.raises(TypeError, match="Invalid `http_client` arg"): with httpx.Client() as http_client: - AsyncAgentex(base_url=base_url, _strict_response_validation=True, http_client=cast(Any, http_client)) + AsyncAgentex( + base_url=base_url, + api_key=api_key, + _strict_response_validation=True, + http_client=cast(Any, http_client), + ) def test_default_headers_option(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, default_headers={"X-Foo": "bar"}) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"} + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) assert request.headers.get("x-foo") == "bar" assert request.headers.get("x-stainless-lang") == "python" client2 = AsyncAgentex( base_url=base_url, + api_key=api_key, _strict_response_validation=True, default_headers={ "X-Foo": "stainless", @@ -1083,8 +1143,20 @@ def test_default_headers_option(self) -> None: assert request.headers.get("x-foo") == "stainless" assert request.headers.get("x-stainless-lang") == "my-overriding-header" + def test_validate_headers(self) -> None: + client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) + request = client._build_request(FinalRequestOptions(method="get", url="/foo")) + assert request.headers.get("Authorization") == f"Bearer {api_key}" + + with update_env(**{"AGENTEX_SDK_API_KEY": Omit()}): + client2 = AsyncAgentex(base_url=base_url, api_key=None, _strict_response_validation=True) + + client2._build_request(FinalRequestOptions(method="get", url="/foo")) + def test_default_query_option(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True, default_query={"query_param": "bar"}) + client = AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"} + ) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) url = httpx.URL(request.url) assert dict(url.params) == {"query_param": "bar"} @@ -1283,7 +1355,9 @@ class Model(BaseModel): assert response.foo == 2 def test_base_url_setter(self) -> None: - client = AsyncAgentex(base_url="https://example.com/from_init", _strict_response_validation=True) + client = AsyncAgentex( + base_url="https://example.com/from_init", api_key=api_key, _strict_response_validation=True + ) assert client.base_url == "https://example.com/from_init/" client.base_url = "https://example.com/from_setter" # type: ignore[assignment] @@ -1292,23 +1366,28 @@ def test_base_url_setter(self) -> None: def test_base_url_env(self) -> None: with update_env(AGENTEX_BASE_URL="http://localhost:5000/from/env"): - client = AsyncAgentex(_strict_response_validation=True) + client = AsyncAgentex(api_key=api_key, _strict_response_validation=True) assert client.base_url == "http://localhost:5000/from/env/" # explicit environment arg requires explicitness with update_env(AGENTEX_BASE_URL="http://localhost:5000/from/env"): with pytest.raises(ValueError, match=r"you must pass base_url=None"): - AsyncAgentex(_strict_response_validation=True, environment="production") + AsyncAgentex(api_key=api_key, _strict_response_validation=True, environment="production") - client = AsyncAgentex(base_url=None, _strict_response_validation=True, environment="production") + client = AsyncAgentex( + base_url=None, api_key=api_key, _strict_response_validation=True, environment="production" + ) assert str(client.base_url).startswith("http://localhost:5003") @pytest.mark.parametrize( "client", [ - AsyncAgentex(base_url="http://localhost:5000/custom/path/", _strict_response_validation=True), + AsyncAgentex( + base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True + ), AsyncAgentex( base_url="http://localhost:5000/custom/path/", + api_key=api_key, _strict_response_validation=True, http_client=httpx.AsyncClient(), ), @@ -1328,9 +1407,12 @@ def test_base_url_trailing_slash(self, client: AsyncAgentex) -> None: @pytest.mark.parametrize( "client", [ - AsyncAgentex(base_url="http://localhost:5000/custom/path/", _strict_response_validation=True), + AsyncAgentex( + base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True + ), AsyncAgentex( base_url="http://localhost:5000/custom/path/", + api_key=api_key, _strict_response_validation=True, http_client=httpx.AsyncClient(), ), @@ -1350,9 +1432,12 @@ def test_base_url_no_trailing_slash(self, client: AsyncAgentex) -> None: @pytest.mark.parametrize( "client", [ - AsyncAgentex(base_url="http://localhost:5000/custom/path/", _strict_response_validation=True), + AsyncAgentex( + base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True + ), AsyncAgentex( base_url="http://localhost:5000/custom/path/", + api_key=api_key, _strict_response_validation=True, http_client=httpx.AsyncClient(), ), @@ -1370,7 +1455,7 @@ def test_absolute_request_url(self, client: AsyncAgentex) -> None: assert request.url == "https://myapi.com/foo" async def test_copied_client_does_not_close_http(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True) + client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) assert not client.is_closed() copied = client.copy() @@ -1382,7 +1467,7 @@ async def test_copied_client_does_not_close_http(self) -> None: assert not client.is_closed() async def test_client_context_manager(self) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True) + client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) async with client as c2: assert c2 is client assert not c2.is_closed() @@ -1404,7 +1489,9 @@ class Model(BaseModel): async def test_client_max_retries_validation(self) -> None: with pytest.raises(TypeError, match=r"max_retries cannot be None"): - AsyncAgentex(base_url=base_url, _strict_response_validation=True, max_retries=cast(Any, None)) + AsyncAgentex( + base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None) + ) @pytest.mark.respx(base_url=base_url) @pytest.mark.asyncio @@ -1414,12 +1501,12 @@ class Model(BaseModel): respx_mock.get("/foo").mock(return_value=httpx.Response(200, text="my-custom-format")) - strict_client = AsyncAgentex(base_url=base_url, _strict_response_validation=True) + strict_client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) with pytest.raises(APIResponseValidationError): await strict_client.get("/foo", cast_to=Model) - client = AsyncAgentex(base_url=base_url, _strict_response_validation=False) + client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=False) response = await client.get("/foo", cast_to=Model) assert isinstance(response, str) # type: ignore[unreachable] @@ -1448,7 +1535,7 @@ class Model(BaseModel): @mock.patch("time.time", mock.MagicMock(return_value=1696004797)) @pytest.mark.asyncio async def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None: - client = AsyncAgentex(base_url=base_url, _strict_response_validation=True) + client = AsyncAgentex(base_url=base_url, api_key=api_key, _strict_response_validation=True) headers = httpx.Headers({"retry-after": retry_after}) options = FinalRequestOptions(method="get", url="/foo", max_retries=3) @@ -1460,20 +1547,20 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte async def test_retrying_timeout_errors_doesnt_leak( self, respx_mock: MockRouter, async_client: AsyncAgentex ) -> None: - respx_mock.get("/agents/agent_id").mock(side_effect=httpx.TimeoutException("Test timeout error")) + respx_mock.get("/tasks").mock(side_effect=httpx.TimeoutException("Test timeout error")) with pytest.raises(APITimeoutError): - await async_client.agents.with_streaming_response.retrieve("agent_id").__aenter__() + await async_client.tasks.with_streaming_response.list().__aenter__() assert _get_open_connections(self.client) == 0 @mock.patch("agentex._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncAgentex) -> None: - respx_mock.get("/agents/agent_id").mock(return_value=httpx.Response(500)) + respx_mock.get("/tasks").mock(return_value=httpx.Response(500)) with pytest.raises(APIStatusError): - await async_client.agents.with_streaming_response.retrieve("agent_id").__aenter__() + await async_client.tasks.with_streaming_response.list().__aenter__() assert _get_open_connections(self.client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @@ -1501,9 +1588,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.get("/agents/agent_id").mock(side_effect=retry_handler) + respx_mock.get("/tasks").mock(side_effect=retry_handler) - response = await client.agents.with_raw_response.retrieve("agent_id") + response = await client.tasks.with_raw_response.list() assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -1526,11 +1613,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.get("/agents/agent_id").mock(side_effect=retry_handler) + respx_mock.get("/tasks").mock(side_effect=retry_handler) - response = await client.agents.with_raw_response.retrieve( - "agent_id", extra_headers={"x-stainless-retry-count": Omit()} - ) + response = await client.tasks.with_raw_response.list(extra_headers={"x-stainless-retry-count": Omit()}) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -1552,11 +1637,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.get("/agents/agent_id").mock(side_effect=retry_handler) + respx_mock.get("/tasks").mock(side_effect=retry_handler) - response = await client.agents.with_raw_response.retrieve( - "agent_id", extra_headers={"x-stainless-retry-count": "42"} - ) + response = await client.tasks.with_raw_response.list(extra_headers={"x-stainless-retry-count": "42"}) assert response.http_request.headers.get("x-stainless-retry-count") == "42" From a8c900eab8db5bbcdd8cc4866078cd4e6f576487 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:23:50 +0000 Subject: [PATCH 3/7] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5a7503fb..48c29b8d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-021b55c88964b7a5bfc9d692d32a52c6b0150445656d2407c4cb8e9dd1e5f100.yml -openapi_spec_hash: 3f634d45f6241dea4fbdac496b70f5a3 +openapi_spec_hash: ed92c0d5d6bed9cb5617f8a776ac42c9 config_hash: 7c45df33d1cc4df7ea9dac3b0968b0f0 From 14881c0ff2922e0a622975a0f5b314de99d7aabb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:59:44 +0000 Subject: [PATCH 4/7] feat(api): deprecate name subresource --- .stats.yml | 2 +- api.md | 45 +- src/agentex/_client.py | 4 +- src/agentex/resources/{agents => }/agents.py | 50 +- src/agentex/resources/agents/__init__.py | 33 -- src/agentex/resources/agents/name.py | 454 ------------------ src/agentex/resources/{tasks => }/tasks.py | 48 +- src/agentex/resources/tasks/__init__.py | 33 -- src/agentex/resources/tasks/name.py | 324 ------------- src/agentex/types/agents/__init__.py | 6 - .../types/agents/name_handle_rpc_params.py | 85 ---- src/agentex/types/agents/name_rpc_params.py | 85 ---- src/agentex/types/tasks/__init__.py | 3 - tests/api_resources/agents/__init__.py | 1 - tests/api_resources/agents/test_name.py | 452 ----------------- tests/api_resources/tasks/__init__.py | 1 - tests/api_resources/tasks/test_name.py | 274 ----------- 17 files changed, 33 insertions(+), 1867 deletions(-) rename src/agentex/resources/{agents => }/agents.py (94%) delete mode 100644 src/agentex/resources/agents/__init__.py delete mode 100644 src/agentex/resources/agents/name.py rename src/agentex/resources/{tasks => }/tasks.py (94%) delete mode 100644 src/agentex/resources/tasks/__init__.py delete mode 100644 src/agentex/resources/tasks/name.py delete mode 100644 src/agentex/types/agents/__init__.py delete mode 100644 src/agentex/types/agents/name_handle_rpc_params.py delete mode 100644 src/agentex/types/agents/name_rpc_params.py delete mode 100644 src/agentex/types/tasks/__init__.py delete mode 100644 tests/api_resources/agents/__init__.py delete mode 100644 tests/api_resources/agents/test_name.py delete mode 100644 tests/api_resources/tasks/__init__.py delete mode 100644 tests/api_resources/tasks/test_name.py diff --git a/.stats.yml b/.stats.yml index 48c29b8d..a111f762 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-021b55c88964b7a5bfc9d692d32a52c6b0150445656d2407c4cb8e9dd1e5f100.yml openapi_spec_hash: ed92c0d5d6bed9cb5617f8a776ac42c9 -config_hash: 7c45df33d1cc4df7ea9dac3b0968b0f0 +config_hash: 5a41a91d658dffbd60d617eb02e945f6 diff --git a/api.md b/api.md index 0d482fb9..8c2841ca 100644 --- a/api.md +++ b/api.md @@ -8,22 +8,13 @@ from agentex.types import AcpType, Agent, AgentRpcRequest, AgentListResponse Methods: -- client.agents.retrieve(agent_id) -> Agent -- client.agents.list(\*\*params) -> AgentListResponse -- client.agents.delete(agent_id) -> Agent -- client.agents.delete_by_name(agent_name) -> Agent -- client.agents.retrieve_by_name(agent_name) -> Agent -- client.agents.rpc(agent_id, \*\*params) -> object -- client.agents.rpc_by_name(agent_name, \*\*params) -> object - -## Name - -Methods: - -- client.agents.name.retrieve(agent_name) -> Agent -- client.agents.name.delete(agent_name) -> Agent -- client.agents.name.handle_rpc(agent_name, \*\*params) -> object -- client.agents.name.rpc(agent_name, \*\*params) -> object +- client.agents.retrieve(agent_id) -> Agent +- client.agents.list(\*\*params) -> AgentListResponse +- client.agents.delete(agent_id) -> Agent +- client.agents.delete_by_name(agent_name) -> Agent +- client.agents.retrieve_by_name(agent_name) -> Agent +- client.agents.rpc(agent_id, \*\*params) -> object +- client.agents.rpc_by_name(agent_name, \*\*params) -> object # Tasks @@ -35,21 +26,13 @@ from agentex.types import Task, TaskListResponse Methods: -- client.tasks.retrieve(task_id) -> Task -- client.tasks.list() -> TaskListResponse -- client.tasks.delete(task_id) -> Task -- client.tasks.delete_by_name(task_name) -> Task -- client.tasks.retrieve_by_name(task_name) -> Task -- client.tasks.stream_events(task_id) -> object -- client.tasks.stream_events_by_name(task_name) -> object - -## Name - -Methods: - -- client.tasks.name.retrieve(task_name) -> Task -- client.tasks.name.delete(task_name) -> Task -- client.tasks.name.stream_events(task_name) -> object +- client.tasks.retrieve(task_id) -> Task +- client.tasks.list() -> TaskListResponse +- client.tasks.delete(task_id) -> Task +- client.tasks.delete_by_name(task_name) -> Task +- client.tasks.retrieve_by_name(task_name) -> Task +- client.tasks.stream_events(task_id) -> object +- client.tasks.stream_events_by_name(task_name) -> object # Messages diff --git a/src/agentex/_client.py b/src/agentex/_client.py index d1af575d..51ebb5e8 100644 --- a/src/agentex/_client.py +++ b/src/agentex/_client.py @@ -21,7 +21,7 @@ ) from ._utils import is_given, get_async_library from ._version import __version__ -from .resources import spans, events, states, tracker +from .resources import spans, tasks, agents, events, states, tracker from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import APIStatusError from ._base_client import ( @@ -29,8 +29,6 @@ SyncAPIClient, AsyncAPIClient, ) -from .resources.tasks import tasks -from .resources.agents import agents from .resources.messages import messages __all__ = [ diff --git a/src/agentex/resources/agents/agents.py b/src/agentex/resources/agents.py similarity index 94% rename from src/agentex/resources/agents/agents.py rename to src/agentex/resources/agents.py index cdd3b891..9c2e4bd5 100644 --- a/src/agentex/resources/agents/agents.py +++ b/src/agentex/resources/agents.py @@ -7,37 +7,25 @@ import httpx -from .name import ( - NameResource, - AsyncNameResource, - NameResourceWithRawResponse, - AsyncNameResourceWithRawResponse, - NameResourceWithStreamingResponse, - AsyncNameResourceWithStreamingResponse, -) -from ...types import agent_rpc_params, agent_list_params, agent_rpc_by_name_params -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import maybe_transform, async_maybe_transform -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( +from ..types import agent_rpc_params, agent_list_params, agent_rpc_by_name_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import maybe_transform, async_maybe_transform +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...types.agent import Agent -from ..._base_client import make_request_options -from ...types.agent_list_response import AgentListResponse +from ..types.agent import Agent +from .._base_client import make_request_options +from ..types.agent_list_response import AgentListResponse __all__ = ["AgentsResource", "AsyncAgentsResource"] class AgentsResource(SyncAPIResource): - @cached_property - def name(self) -> NameResource: - return NameResource(self._client) - @cached_property def with_raw_response(self) -> AgentsResourceWithRawResponse: """ @@ -320,10 +308,6 @@ def rpc_by_name( class AsyncAgentsResource(AsyncAPIResource): - @cached_property - def name(self) -> AsyncNameResource: - return AsyncNameResource(self._client) - @cached_property def with_raw_response(self) -> AsyncAgentsResourceWithRawResponse: """ @@ -631,10 +615,6 @@ def __init__(self, agents: AgentsResource) -> None: agents.rpc_by_name, ) - @cached_property - def name(self) -> NameResourceWithRawResponse: - return NameResourceWithRawResponse(self._agents.name) - class AsyncAgentsResourceWithRawResponse: def __init__(self, agents: AsyncAgentsResource) -> None: @@ -662,10 +642,6 @@ def __init__(self, agents: AsyncAgentsResource) -> None: agents.rpc_by_name, ) - @cached_property - def name(self) -> AsyncNameResourceWithRawResponse: - return AsyncNameResourceWithRawResponse(self._agents.name) - class AgentsResourceWithStreamingResponse: def __init__(self, agents: AgentsResource) -> None: @@ -693,10 +669,6 @@ def __init__(self, agents: AgentsResource) -> None: agents.rpc_by_name, ) - @cached_property - def name(self) -> NameResourceWithStreamingResponse: - return NameResourceWithStreamingResponse(self._agents.name) - class AsyncAgentsResourceWithStreamingResponse: def __init__(self, agents: AsyncAgentsResource) -> None: @@ -723,7 +695,3 @@ def __init__(self, agents: AsyncAgentsResource) -> None: self.rpc_by_name = async_to_streamed_response_wrapper( agents.rpc_by_name, ) - - @cached_property - def name(self) -> AsyncNameResourceWithStreamingResponse: - return AsyncNameResourceWithStreamingResponse(self._agents.name) diff --git a/src/agentex/resources/agents/__init__.py b/src/agentex/resources/agents/__init__.py deleted file mode 100644 index 374345e0..00000000 --- a/src/agentex/resources/agents/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .name import ( - NameResource, - AsyncNameResource, - NameResourceWithRawResponse, - AsyncNameResourceWithRawResponse, - NameResourceWithStreamingResponse, - AsyncNameResourceWithStreamingResponse, -) -from .agents import ( - AgentsResource, - AsyncAgentsResource, - AgentsResourceWithRawResponse, - AsyncAgentsResourceWithRawResponse, - AgentsResourceWithStreamingResponse, - AsyncAgentsResourceWithStreamingResponse, -) - -__all__ = [ - "NameResource", - "AsyncNameResource", - "NameResourceWithRawResponse", - "AsyncNameResourceWithRawResponse", - "NameResourceWithStreamingResponse", - "AsyncNameResourceWithStreamingResponse", - "AgentsResource", - "AsyncAgentsResource", - "AgentsResourceWithRawResponse", - "AsyncAgentsResourceWithRawResponse", - "AgentsResourceWithStreamingResponse", - "AsyncAgentsResourceWithStreamingResponse", -] diff --git a/src/agentex/resources/agents/name.py b/src/agentex/resources/agents/name.py deleted file mode 100644 index fd8c82f9..00000000 --- a/src/agentex/resources/agents/name.py +++ /dev/null @@ -1,454 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from typing_extensions import Literal - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import maybe_transform, async_maybe_transform -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...types.agent import Agent -from ..._base_client import make_request_options -from ...types.agents import name_rpc_params, name_handle_rpc_params - -__all__ = ["NameResource", "AsyncNameResource"] - - -class NameResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> NameResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers - """ - return NameResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> NameResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response - """ - return NameResourceWithStreamingResponse(self) - - def retrieve( - self, - agent_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Agent: - """ - Get an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return self._get( - f"/agents/name/{agent_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Agent, - ) - - def delete( - self, - agent_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Agent: - """ - Delete an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return self._delete( - f"/agents/name/{agent_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Agent, - ) - - def handle_rpc( - self, - agent_name: str, - *, - method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: name_handle_rpc_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: - """ - Handle JSON-RPC requests for an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return self._post( - f"/agents/name/{agent_name}/rpc", - body=maybe_transform( - { - "method": method, - "params": params, - "id": id, - "jsonrpc": jsonrpc, - }, - name_handle_rpc_params.NameHandleRpcParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - ) - - def rpc( - self, - agent_name: str, - *, - method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: name_rpc_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: - """ - Handle JSON-RPC requests for an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return self._post( - f"/agents/name/{agent_name}/rpc", - body=maybe_transform( - { - "method": method, - "params": params, - "id": id, - "jsonrpc": jsonrpc, - }, - name_rpc_params.NameRpcParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - ) - - -class AsyncNameResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncNameResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers - """ - return AsyncNameResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncNameResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response - """ - return AsyncNameResourceWithStreamingResponse(self) - - async def retrieve( - self, - agent_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Agent: - """ - Get an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return await self._get( - f"/agents/name/{agent_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Agent, - ) - - async def delete( - self, - agent_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Agent: - """ - Delete an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return await self._delete( - f"/agents/name/{agent_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Agent, - ) - - async def handle_rpc( - self, - agent_name: str, - *, - method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: name_handle_rpc_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: - """ - Handle JSON-RPC requests for an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return await self._post( - f"/agents/name/{agent_name}/rpc", - body=await async_maybe_transform( - { - "method": method, - "params": params, - "id": id, - "jsonrpc": jsonrpc, - }, - name_handle_rpc_params.NameHandleRpcParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - ) - - async def rpc( - self, - agent_name: str, - *, - method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: name_rpc_params.Params, - id: Union[int, str, None] | NotGiven = NOT_GIVEN, - jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: - """ - Handle JSON-RPC requests for an agent by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not agent_name: - raise ValueError(f"Expected a non-empty value for `agent_name` but received {agent_name!r}") - return await self._post( - f"/agents/name/{agent_name}/rpc", - body=await async_maybe_transform( - { - "method": method, - "params": params, - "id": id, - "jsonrpc": jsonrpc, - }, - name_rpc_params.NameRpcParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - ) - - -class NameResourceWithRawResponse: - def __init__(self, name: NameResource) -> None: - self._name = name - - self.retrieve = to_raw_response_wrapper( - name.retrieve, - ) - self.delete = to_raw_response_wrapper( - name.delete, - ) - self.handle_rpc = to_raw_response_wrapper( - name.handle_rpc, - ) - self.rpc = to_raw_response_wrapper( - name.rpc, - ) - - -class AsyncNameResourceWithRawResponse: - def __init__(self, name: AsyncNameResource) -> None: - self._name = name - - self.retrieve = async_to_raw_response_wrapper( - name.retrieve, - ) - self.delete = async_to_raw_response_wrapper( - name.delete, - ) - self.handle_rpc = async_to_raw_response_wrapper( - name.handle_rpc, - ) - self.rpc = async_to_raw_response_wrapper( - name.rpc, - ) - - -class NameResourceWithStreamingResponse: - def __init__(self, name: NameResource) -> None: - self._name = name - - self.retrieve = to_streamed_response_wrapper( - name.retrieve, - ) - self.delete = to_streamed_response_wrapper( - name.delete, - ) - self.handle_rpc = to_streamed_response_wrapper( - name.handle_rpc, - ) - self.rpc = to_streamed_response_wrapper( - name.rpc, - ) - - -class AsyncNameResourceWithStreamingResponse: - def __init__(self, name: AsyncNameResource) -> None: - self._name = name - - self.retrieve = async_to_streamed_response_wrapper( - name.retrieve, - ) - self.delete = async_to_streamed_response_wrapper( - name.delete, - ) - self.handle_rpc = async_to_streamed_response_wrapper( - name.handle_rpc, - ) - self.rpc = async_to_streamed_response_wrapper( - name.rpc, - ) diff --git a/src/agentex/resources/tasks/tasks.py b/src/agentex/resources/tasks.py similarity index 94% rename from src/agentex/resources/tasks/tasks.py rename to src/agentex/resources/tasks.py index ce1a7813..936ee66c 100644 --- a/src/agentex/resources/tasks/tasks.py +++ b/src/agentex/resources/tasks.py @@ -4,36 +4,24 @@ import httpx -from .name import ( - NameResource, - AsyncNameResource, - NameResourceWithRawResponse, - AsyncNameResourceWithRawResponse, - NameResourceWithStreamingResponse, - AsyncNameResourceWithStreamingResponse, -) -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ..._streaming import Stream, AsyncStream -from ...types.task import Task -from ..._base_client import make_request_options -from ...types.task_list_response import TaskListResponse +from .._streaming import Stream, AsyncStream +from ..types.task import Task +from .._base_client import make_request_options +from ..types.task_list_response import TaskListResponse __all__ = ["TasksResource", "AsyncTasksResource"] class TasksResource(SyncAPIResource): - @cached_property - def name(self) -> NameResource: - return NameResource(self._client) - @cached_property def with_raw_response(self) -> TasksResourceWithRawResponse: """ @@ -276,10 +264,6 @@ def stream_events_by_name( class AsyncTasksResource(AsyncAPIResource): - @cached_property - def name(self) -> AsyncNameResource: - return AsyncNameResource(self._client) - @cached_property def with_raw_response(self) -> AsyncTasksResourceWithRawResponse: """ @@ -547,10 +531,6 @@ def __init__(self, tasks: TasksResource) -> None: tasks.stream_events_by_name, ) - @cached_property - def name(self) -> NameResourceWithRawResponse: - return NameResourceWithRawResponse(self._tasks.name) - class AsyncTasksResourceWithRawResponse: def __init__(self, tasks: AsyncTasksResource) -> None: @@ -578,10 +558,6 @@ def __init__(self, tasks: AsyncTasksResource) -> None: tasks.stream_events_by_name, ) - @cached_property - def name(self) -> AsyncNameResourceWithRawResponse: - return AsyncNameResourceWithRawResponse(self._tasks.name) - class TasksResourceWithStreamingResponse: def __init__(self, tasks: TasksResource) -> None: @@ -609,10 +585,6 @@ def __init__(self, tasks: TasksResource) -> None: tasks.stream_events_by_name, ) - @cached_property - def name(self) -> NameResourceWithStreamingResponse: - return NameResourceWithStreamingResponse(self._tasks.name) - class AsyncTasksResourceWithStreamingResponse: def __init__(self, tasks: AsyncTasksResource) -> None: @@ -639,7 +611,3 @@ def __init__(self, tasks: AsyncTasksResource) -> None: self.stream_events_by_name = async_to_streamed_response_wrapper( tasks.stream_events_by_name, ) - - @cached_property - def name(self) -> AsyncNameResourceWithStreamingResponse: - return AsyncNameResourceWithStreamingResponse(self._tasks.name) diff --git a/src/agentex/resources/tasks/__init__.py b/src/agentex/resources/tasks/__init__.py deleted file mode 100644 index 5a9c81b0..00000000 --- a/src/agentex/resources/tasks/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .name import ( - NameResource, - AsyncNameResource, - NameResourceWithRawResponse, - AsyncNameResourceWithRawResponse, - NameResourceWithStreamingResponse, - AsyncNameResourceWithStreamingResponse, -) -from .tasks import ( - TasksResource, - AsyncTasksResource, - TasksResourceWithRawResponse, - AsyncTasksResourceWithRawResponse, - TasksResourceWithStreamingResponse, - AsyncTasksResourceWithStreamingResponse, -) - -__all__ = [ - "NameResource", - "AsyncNameResource", - "NameResourceWithRawResponse", - "AsyncNameResourceWithRawResponse", - "NameResourceWithStreamingResponse", - "AsyncNameResourceWithStreamingResponse", - "TasksResource", - "AsyncTasksResource", - "TasksResourceWithRawResponse", - "AsyncTasksResourceWithRawResponse", - "TasksResourceWithStreamingResponse", - "AsyncTasksResourceWithStreamingResponse", -] diff --git a/src/agentex/resources/tasks/name.py b/src/agentex/resources/tasks/name.py deleted file mode 100644 index 7cef42eb..00000000 --- a/src/agentex/resources/tasks/name.py +++ /dev/null @@ -1,324 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._streaming import Stream, AsyncStream -from ...types.task import Task -from ..._base_client import make_request_options - -__all__ = ["NameResource", "AsyncNameResource"] - - -class NameResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> NameResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers - """ - return NameResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> NameResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response - """ - return NameResourceWithStreamingResponse(self) - - def retrieve( - self, - task_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Task: - """ - Get a task by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not task_name: - raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") - return self._get( - f"/tasks/name/{task_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Task, - ) - - def delete( - self, - task_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Task: - """ - Delete a task by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not task_name: - raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") - return self._delete( - f"/tasks/name/{task_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Task, - ) - - def stream_events( - self, - task_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Stream[object]: - """ - Stream events for a task by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not task_name: - raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") - return self._get( - f"/tasks/name/{task_name}/stream", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - stream=True, - stream_cls=Stream[object], - ) - - -class AsyncNameResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncNameResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/scaleapi/agentex-python#accessing-raw-response-data-eg-headers - """ - return AsyncNameResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncNameResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/scaleapi/agentex-python#with_streaming_response - """ - return AsyncNameResourceWithStreamingResponse(self) - - async def retrieve( - self, - task_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Task: - """ - Get a task by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not task_name: - raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") - return await self._get( - f"/tasks/name/{task_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Task, - ) - - async def delete( - self, - task_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Task: - """ - Delete a task by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not task_name: - raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") - return await self._delete( - f"/tasks/name/{task_name}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Task, - ) - - async def stream_events( - self, - task_name: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncStream[object]: - """ - Stream events for a task by its unique name. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not task_name: - raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}") - return await self._get( - f"/tasks/name/{task_name}/stream", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=object, - stream=True, - stream_cls=AsyncStream[object], - ) - - -class NameResourceWithRawResponse: - def __init__(self, name: NameResource) -> None: - self._name = name - - self.retrieve = to_raw_response_wrapper( - name.retrieve, - ) - self.delete = to_raw_response_wrapper( - name.delete, - ) - self.stream_events = to_raw_response_wrapper( - name.stream_events, - ) - - -class AsyncNameResourceWithRawResponse: - def __init__(self, name: AsyncNameResource) -> None: - self._name = name - - self.retrieve = async_to_raw_response_wrapper( - name.retrieve, - ) - self.delete = async_to_raw_response_wrapper( - name.delete, - ) - self.stream_events = async_to_raw_response_wrapper( - name.stream_events, - ) - - -class NameResourceWithStreamingResponse: - def __init__(self, name: NameResource) -> None: - self._name = name - - self.retrieve = to_streamed_response_wrapper( - name.retrieve, - ) - self.delete = to_streamed_response_wrapper( - name.delete, - ) - self.stream_events = to_streamed_response_wrapper( - name.stream_events, - ) - - -class AsyncNameResourceWithStreamingResponse: - def __init__(self, name: AsyncNameResource) -> None: - self._name = name - - self.retrieve = async_to_streamed_response_wrapper( - name.retrieve, - ) - self.delete = async_to_streamed_response_wrapper( - name.delete, - ) - self.stream_events = async_to_streamed_response_wrapper( - name.stream_events, - ) diff --git a/src/agentex/types/agents/__init__.py b/src/agentex/types/agents/__init__.py deleted file mode 100644 index 6211202a..00000000 --- a/src/agentex/types/agents/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .name_rpc_params import NameRpcParams as NameRpcParams -from .name_handle_rpc_params import NameHandleRpcParams as NameHandleRpcParams diff --git a/src/agentex/types/agents/name_handle_rpc_params.py b/src/agentex/types/agents/name_handle_rpc_params.py deleted file mode 100644 index d1d903a6..00000000 --- a/src/agentex/types/agents/name_handle_rpc_params.py +++ /dev/null @@ -1,85 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Union, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict - -from ..data_content_param import DataContentParam -from ..text_content_param import TextContentParam -from ..tool_request_content_param import ToolRequestContentParam -from ..tool_response_content_param import ToolResponseContentParam - -__all__ = [ - "NameHandleRpcParams", - "Params", - "ParamsCreateTaskRequest", - "ParamsCancelTaskRequest", - "ParamsSendMessageRequest", - "ParamsSendMessageRequestContent", - "ParamsSendEventRequest", - "ParamsSendEventRequestContent", -] - - -class NameHandleRpcParams(TypedDict, total=False): - method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] - - params: Required[Params] - - id: Union[int, str, None] - - jsonrpc: Literal["2.0"] - - -class ParamsCreateTaskRequest(TypedDict, total=False): - name: Optional[str] - """The name of the task to create""" - - params: Optional[Dict[str, object]] - """The parameters for the task""" - - -class ParamsCancelTaskRequest(TypedDict, total=False): - task_id: Optional[str] - """The ID of the task to cancel. Either this or task_name must be provided.""" - - task_name: Optional[str] - """The name of the task to cancel. Either this or task_id must be provided.""" - - -ParamsSendMessageRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendMessageRequest(TypedDict, total=False): - content: Required[ParamsSendMessageRequestContent] - """The message that was sent to the agent""" - - stream: bool - """Whether to stream the response message back to the client""" - - task_id: Optional[str] - """The ID of the task that the message was sent to""" - - -ParamsSendEventRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendEventRequest(TypedDict, total=False): - content: Optional[ParamsSendEventRequestContent] - """The content to send to the event""" - - task_id: Optional[str] - """The ID of the task that the event was sent to""" - - task_name: Optional[str] - """The name of the task that the event was sent to""" - - -Params: TypeAlias = Union[ - ParamsCreateTaskRequest, ParamsCancelTaskRequest, ParamsSendMessageRequest, ParamsSendEventRequest -] diff --git a/src/agentex/types/agents/name_rpc_params.py b/src/agentex/types/agents/name_rpc_params.py deleted file mode 100644 index 6a68b0ba..00000000 --- a/src/agentex/types/agents/name_rpc_params.py +++ /dev/null @@ -1,85 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Union, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict - -from ..data_content_param import DataContentParam -from ..text_content_param import TextContentParam -from ..tool_request_content_param import ToolRequestContentParam -from ..tool_response_content_param import ToolResponseContentParam - -__all__ = [ - "NameRpcParams", - "Params", - "ParamsCreateTaskRequest", - "ParamsCancelTaskRequest", - "ParamsSendMessageRequest", - "ParamsSendMessageRequestContent", - "ParamsSendEventRequest", - "ParamsSendEventRequestContent", -] - - -class NameRpcParams(TypedDict, total=False): - method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] - - params: Required[Params] - - id: Union[int, str, None] - - jsonrpc: Literal["2.0"] - - -class ParamsCreateTaskRequest(TypedDict, total=False): - name: Optional[str] - """The name of the task to create""" - - params: Optional[Dict[str, object]] - """The parameters for the task""" - - -class ParamsCancelTaskRequest(TypedDict, total=False): - task_id: Optional[str] - """The ID of the task to cancel. Either this or task_name must be provided.""" - - task_name: Optional[str] - """The name of the task to cancel. Either this or task_id must be provided.""" - - -ParamsSendMessageRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendMessageRequest(TypedDict, total=False): - content: Required[ParamsSendMessageRequestContent] - """The message that was sent to the agent""" - - stream: bool - """Whether to stream the response message back to the client""" - - task_id: Optional[str] - """The ID of the task that the message was sent to""" - - -ParamsSendEventRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendEventRequest(TypedDict, total=False): - content: Optional[ParamsSendEventRequestContent] - """The content to send to the event""" - - task_id: Optional[str] - """The ID of the task that the event was sent to""" - - task_name: Optional[str] - """The name of the task that the event was sent to""" - - -Params: TypeAlias = Union[ - ParamsCreateTaskRequest, ParamsCancelTaskRequest, ParamsSendMessageRequest, ParamsSendEventRequest -] diff --git a/src/agentex/types/tasks/__init__.py b/src/agentex/types/tasks/__init__.py deleted file mode 100644 index f8ee8b14..00000000 --- a/src/agentex/types/tasks/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations diff --git a/tests/api_resources/agents/__init__.py b/tests/api_resources/agents/__init__.py deleted file mode 100644 index fd8019a9..00000000 --- a/tests/api_resources/agents/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/agents/test_name.py b/tests/api_resources/agents/test_name.py deleted file mode 100644 index dea82f12..00000000 --- a/tests/api_resources/agents/test_name.py +++ /dev/null @@ -1,452 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from agentex import Agentex, AsyncAgentex -from tests.utils import assert_matches_type -from agentex.types import Agent - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestName: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - def test_method_retrieve(self, client: Agentex) -> None: - name = client.agents.name.retrieve( - "agent_name", - ) - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_retrieve(self, client: Agentex) -> None: - response = client.agents.name.with_raw_response.retrieve( - "agent_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = response.parse() - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_retrieve(self, client: Agentex) -> None: - with client.agents.name.with_streaming_response.retrieve( - "agent_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = response.parse() - assert_matches_type(Agent, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_retrieve(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - client.agents.name.with_raw_response.retrieve( - "", - ) - - @pytest.mark.skip() - @parametrize - def test_method_delete(self, client: Agentex) -> None: - name = client.agents.name.delete( - "agent_name", - ) - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_delete(self, client: Agentex) -> None: - response = client.agents.name.with_raw_response.delete( - "agent_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = response.parse() - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_delete(self, client: Agentex) -> None: - with client.agents.name.with_streaming_response.delete( - "agent_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = response.parse() - assert_matches_type(Agent, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_delete(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - client.agents.name.with_raw_response.delete( - "", - ) - - @pytest.mark.skip() - @parametrize - def test_method_handle_rpc(self, client: Agentex) -> None: - name = client.agents.name.handle_rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_method_handle_rpc_with_all_params(self, client: Agentex) -> None: - name = client.agents.name.handle_rpc( - agent_name="agent_name", - method="event/send", - params={ - "name": "name", - "params": {"foo": "bar"}, - }, - id=0, - jsonrpc="2.0", - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_handle_rpc(self, client: Agentex) -> None: - response = client.agents.name.with_raw_response.handle_rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = response.parse() - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_handle_rpc(self, client: Agentex) -> None: - with client.agents.name.with_streaming_response.handle_rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = response.parse() - assert_matches_type(object, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_handle_rpc(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - client.agents.name.with_raw_response.handle_rpc( - agent_name="", - method="event/send", - params={}, - ) - - @pytest.mark.skip() - @parametrize - def test_method_rpc(self, client: Agentex) -> None: - name = client.agents.name.rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_method_rpc_with_all_params(self, client: Agentex) -> None: - name = client.agents.name.rpc( - agent_name="agent_name", - method="event/send", - params={ - "name": "name", - "params": {"foo": "bar"}, - }, - id=0, - jsonrpc="2.0", - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_rpc(self, client: Agentex) -> None: - response = client.agents.name.with_raw_response.rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = response.parse() - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_rpc(self, client: Agentex) -> None: - with client.agents.name.with_streaming_response.rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = response.parse() - assert_matches_type(object, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_rpc(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - client.agents.name.with_raw_response.rpc( - agent_name="", - method="event/send", - params={}, - ) - - -class TestAsyncName: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip() - @parametrize - async def test_method_retrieve(self, async_client: AsyncAgentex) -> None: - name = await async_client.agents.name.retrieve( - "agent_name", - ) - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncAgentex) -> None: - response = await async_client.agents.name.with_raw_response.retrieve( - "agent_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = await response.parse() - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncAgentex) -> None: - async with async_client.agents.name.with_streaming_response.retrieve( - "agent_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = await response.parse() - assert_matches_type(Agent, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - await async_client.agents.name.with_raw_response.retrieve( - "", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_delete(self, async_client: AsyncAgentex) -> None: - name = await async_client.agents.name.delete( - "agent_name", - ) - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_delete(self, async_client: AsyncAgentex) -> None: - response = await async_client.agents.name.with_raw_response.delete( - "agent_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = await response.parse() - assert_matches_type(Agent, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncAgentex) -> None: - async with async_client.agents.name.with_streaming_response.delete( - "agent_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = await response.parse() - assert_matches_type(Agent, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_delete(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - await async_client.agents.name.with_raw_response.delete( - "", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_handle_rpc(self, async_client: AsyncAgentex) -> None: - name = await async_client.agents.name.handle_rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_method_handle_rpc_with_all_params(self, async_client: AsyncAgentex) -> None: - name = await async_client.agents.name.handle_rpc( - agent_name="agent_name", - method="event/send", - params={ - "name": "name", - "params": {"foo": "bar"}, - }, - id=0, - jsonrpc="2.0", - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_handle_rpc(self, async_client: AsyncAgentex) -> None: - response = await async_client.agents.name.with_raw_response.handle_rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = await response.parse() - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_handle_rpc(self, async_client: AsyncAgentex) -> None: - async with async_client.agents.name.with_streaming_response.handle_rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = await response.parse() - assert_matches_type(object, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_handle_rpc(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - await async_client.agents.name.with_raw_response.handle_rpc( - agent_name="", - method="event/send", - params={}, - ) - - @pytest.mark.skip() - @parametrize - async def test_method_rpc(self, async_client: AsyncAgentex) -> None: - name = await async_client.agents.name.rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_method_rpc_with_all_params(self, async_client: AsyncAgentex) -> None: - name = await async_client.agents.name.rpc( - agent_name="agent_name", - method="event/send", - params={ - "name": "name", - "params": {"foo": "bar"}, - }, - id=0, - jsonrpc="2.0", - ) - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_rpc(self, async_client: AsyncAgentex) -> None: - response = await async_client.agents.name.with_raw_response.rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = await response.parse() - assert_matches_type(object, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_rpc(self, async_client: AsyncAgentex) -> None: - async with async_client.agents.name.with_streaming_response.rpc( - agent_name="agent_name", - method="event/send", - params={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = await response.parse() - assert_matches_type(object, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_rpc(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `agent_name` but received ''"): - await async_client.agents.name.with_raw_response.rpc( - agent_name="", - method="event/send", - params={}, - ) diff --git a/tests/api_resources/tasks/__init__.py b/tests/api_resources/tasks/__init__.py deleted file mode 100644 index fd8019a9..00000000 --- a/tests/api_resources/tasks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/tasks/test_name.py b/tests/api_resources/tasks/test_name.py deleted file mode 100644 index cb000659..00000000 --- a/tests/api_resources/tasks/test_name.py +++ /dev/null @@ -1,274 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from agentex import Agentex, AsyncAgentex -from tests.utils import assert_matches_type -from agentex.types import Task - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestName: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip() - @parametrize - def test_method_retrieve(self, client: Agentex) -> None: - name = client.tasks.name.retrieve( - "task_name", - ) - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_retrieve(self, client: Agentex) -> None: - response = client.tasks.name.with_raw_response.retrieve( - "task_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = response.parse() - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_retrieve(self, client: Agentex) -> None: - with client.tasks.name.with_streaming_response.retrieve( - "task_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = response.parse() - assert_matches_type(Task, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_retrieve(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): - client.tasks.name.with_raw_response.retrieve( - "", - ) - - @pytest.mark.skip() - @parametrize - def test_method_delete(self, client: Agentex) -> None: - name = client.tasks.name.delete( - "task_name", - ) - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_delete(self, client: Agentex) -> None: - response = client.tasks.name.with_raw_response.delete( - "task_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = response.parse() - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_delete(self, client: Agentex) -> None: - with client.tasks.name.with_streaming_response.delete( - "task_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = response.parse() - assert_matches_type(Task, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_delete(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): - client.tasks.name.with_raw_response.delete( - "", - ) - - @pytest.mark.skip() - @parametrize - def test_method_stream_events(self, client: Agentex) -> None: - name_stream = client.tasks.name.stream_events( - "task_name", - ) - name_stream.response.close() - - @pytest.mark.skip() - @parametrize - def test_raw_response_stream_events(self, client: Agentex) -> None: - response = client.tasks.name.with_raw_response.stream_events( - "task_name", - ) - - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = response.parse() - stream.close() - - @pytest.mark.skip() - @parametrize - def test_streaming_response_stream_events(self, client: Agentex) -> None: - with client.tasks.name.with_streaming_response.stream_events( - "task_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = response.parse() - stream.close() - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_stream_events(self, client: Agentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): - client.tasks.name.with_raw_response.stream_events( - "", - ) - - -class TestAsyncName: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip() - @parametrize - async def test_method_retrieve(self, async_client: AsyncAgentex) -> None: - name = await async_client.tasks.name.retrieve( - "task_name", - ) - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncAgentex) -> None: - response = await async_client.tasks.name.with_raw_response.retrieve( - "task_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = await response.parse() - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncAgentex) -> None: - async with async_client.tasks.name.with_streaming_response.retrieve( - "task_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = await response.parse() - assert_matches_type(Task, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): - await async_client.tasks.name.with_raw_response.retrieve( - "", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_delete(self, async_client: AsyncAgentex) -> None: - name = await async_client.tasks.name.delete( - "task_name", - ) - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_delete(self, async_client: AsyncAgentex) -> None: - response = await async_client.tasks.name.with_raw_response.delete( - "task_name", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - name = await response.parse() - assert_matches_type(Task, name, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncAgentex) -> None: - async with async_client.tasks.name.with_streaming_response.delete( - "task_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - name = await response.parse() - assert_matches_type(Task, name, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_delete(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): - await async_client.tasks.name.with_raw_response.delete( - "", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_stream_events(self, async_client: AsyncAgentex) -> None: - name_stream = await async_client.tasks.name.stream_events( - "task_name", - ) - await name_stream.response.aclose() - - @pytest.mark.skip() - @parametrize - async def test_raw_response_stream_events(self, async_client: AsyncAgentex) -> None: - response = await async_client.tasks.name.with_raw_response.stream_events( - "task_name", - ) - - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - stream = await response.parse() - await stream.close() - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_stream_events(self, async_client: AsyncAgentex) -> None: - async with async_client.tasks.name.with_streaming_response.stream_events( - "task_name", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - stream = await response.parse() - await stream.close() - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_stream_events(self, async_client: AsyncAgentex) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_name` but received ''"): - await async_client.tasks.name.with_raw_response.stream_events( - "", - ) From a885d8dbabfe2cc2a556ef02e75e5502fd799c46 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:03:14 +0000 Subject: [PATCH 5/7] feat(api): manual updates --- .stats.yml | 4 +- api.md | 14 +- src/agentex/resources/agents.py | 26 ++- src/agentex/resources/messages/messages.py | 12 +- src/agentex/types/__init__.py | 3 +- src/agentex/types/agent_rpc_by_name_params.py | 1 + .../types/agent_rpc_by_name_response.py | 165 ++++++++++++++++++ src/agentex/types/agent_rpc_params.py | 1 + src/agentex/types/agent_rpc_response.py | 165 ++++++++++++++++++ src/agentex/types/message_create_params.py | 5 +- src/agentex/types/message_update_params.py | 5 +- src/agentex/types/streaming_status.py | 7 - src/agentex/types/task_message.py | 21 ++- tests/api_resources/test_agents.py | 39 +++-- 14 files changed, 409 insertions(+), 59 deletions(-) create mode 100644 src/agentex/types/agent_rpc_by_name_response.py create mode 100644 src/agentex/types/agent_rpc_response.py delete mode 100644 src/agentex/types/streaming_status.py diff --git a/.stats.yml b/.stats.yml index a111f762..e880ba66 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-021b55c88964b7a5bfc9d692d32a52c6b0150445656d2407c4cb8e9dd1e5f100.yml -openapi_spec_hash: ed92c0d5d6bed9cb5617f8a776ac42c9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-1d08fb2290b5310c91801d7575d356628d372fd5434e15d3b9cead48eadb893f.yml +openapi_spec_hash: c07c588fb8429fbf024189df62f20fa4 config_hash: 5a41a91d658dffbd60d617eb02e945f6 diff --git a/api.md b/api.md index 8c2841ca..474200e1 100644 --- a/api.md +++ b/api.md @@ -3,7 +3,14 @@ Types: ```python -from agentex.types import AcpType, Agent, AgentRpcRequest, AgentListResponse +from agentex.types import ( + AcpType, + Agent, + AgentRpcRequest, + AgentListResponse, + AgentRpcResponse, + AgentRpcByNameResponse, +) ``` Methods: @@ -13,8 +20,8 @@ Methods: - client.agents.delete(agent_id) -> Agent - client.agents.delete_by_name(agent_name) -> Agent - client.agents.retrieve_by_name(agent_name) -> Agent -- client.agents.rpc(agent_id, \*\*params) -> object -- client.agents.rpc_by_name(agent_name, \*\*params) -> object +- client.agents.rpc(agent_id, \*\*params) -> AgentRpcResponse +- client.agents.rpc_by_name(agent_name, \*\*params) -> AgentRpcByNameResponse # Tasks @@ -43,7 +50,6 @@ from agentex.types import ( DataContent, MessageAuthor, MessageStyle, - StreamingStatus, TaskMessage, TextContent, ToolRequestContent, diff --git a/src/agentex/resources/agents.py b/src/agentex/resources/agents.py index 9c2e4bd5..3e5626c6 100644 --- a/src/agentex/resources/agents.py +++ b/src/agentex/resources/agents.py @@ -20,7 +20,9 @@ ) from ..types.agent import Agent from .._base_client import make_request_options +from ..types.agent_rpc_response import AgentRpcResponse from ..types.agent_list_response import AgentListResponse +from ..types.agent_rpc_by_name_response import AgentRpcByNameResponse __all__ = ["AgentsResource", "AsyncAgentsResource"] @@ -228,11 +230,13 @@ def rpc( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique ID. Args: + params: The parameters for the agent RPC request + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -257,7 +261,7 @@ def rpc( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AgentRpcResponse, ) def rpc_by_name( @@ -274,11 +278,13 @@ def rpc_by_name( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AgentRpcByNameResponse: """ Handle JSON-RPC requests for an agent by its unique name. Args: + params: The parameters for the agent RPC request + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -303,7 +309,7 @@ def rpc_by_name( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AgentRpcByNameResponse, ) @@ -510,11 +516,13 @@ async def rpc( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique ID. Args: + params: The parameters for the agent RPC request + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -539,7 +547,7 @@ async def rpc( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AgentRpcResponse, ) async def rpc_by_name( @@ -556,11 +564,13 @@ async def rpc_by_name( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AgentRpcByNameResponse: """ Handle JSON-RPC requests for an agent by its unique name. Args: + params: The parameters for the agent RPC request + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -585,7 +595,7 @@ async def rpc_by_name( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AgentRpcByNameResponse, ) diff --git a/src/agentex/resources/messages/messages.py b/src/agentex/resources/messages/messages.py index 7745cf76..2d83fb4e 100644 --- a/src/agentex/resources/messages/messages.py +++ b/src/agentex/resources/messages/messages.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Optional +from typing_extensions import Literal import httpx @@ -14,7 +15,7 @@ BatchResourceWithStreamingResponse, AsyncBatchResourceWithStreamingResponse, ) -from ...types import StreamingStatus, message_list_params, message_create_params, message_update_params +from ...types import message_list_params, message_create_params, message_update_params from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import maybe_transform, async_maybe_transform from ..._compat import cached_property @@ -27,7 +28,6 @@ ) from ..._base_client import make_request_options from ...types.task_message import TaskMessage -from ...types.streaming_status import StreamingStatus from ...types.message_list_response import MessageListResponse __all__ = ["MessagesResource", "AsyncMessagesResource"] @@ -62,7 +62,7 @@ def create( *, content: message_create_params.Content, task_id: str, - streaming_status: Optional[StreamingStatus] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -137,7 +137,7 @@ def update( *, content: message_update_params.Content, task_id: str, - streaming_status: Optional[StreamingStatus] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -247,7 +247,7 @@ async def create( *, content: message_create_params.Content, task_id: str, - streaming_status: Optional[StreamingStatus] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -322,7 +322,7 @@ async def update( *, content: message_update_params.Content, task_id: str, - streaming_status: Optional[StreamingStatus] | NotGiven = NOT_GIVEN, + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/agentex/types/__init__.py b/src/agentex/types/__init__.py index a5e72143..5a380cdc 100644 --- a/src/agentex/types/__init__.py +++ b/src/agentex/types/__init__.py @@ -15,10 +15,10 @@ from .message_author import MessageAuthor as MessageAuthor from .agent_rpc_params import AgentRpcParams as AgentRpcParams from .span_list_params import SpanListParams as SpanListParams -from .streaming_status import StreamingStatus as StreamingStatus from .agent_list_params import AgentListParams as AgentListParams from .event_list_params import EventListParams as EventListParams from .state_list_params import StateListParams as StateListParams +from .agent_rpc_response import AgentRpcResponse as AgentRpcResponse from .agent_task_tracker import AgentTaskTracker as AgentTaskTracker from .data_content_param import DataContentParam as DataContentParam from .span_create_params import SpanCreateParams as SpanCreateParams @@ -41,5 +41,6 @@ from .tracker_list_response import TrackerListResponse as TrackerListResponse from .tracker_update_params import TrackerUpdateParams as TrackerUpdateParams from .agent_rpc_by_name_params import AgentRpcByNameParams as AgentRpcByNameParams +from .agent_rpc_by_name_response import AgentRpcByNameResponse as AgentRpcByNameResponse from .tool_request_content_param import ToolRequestContentParam as ToolRequestContentParam from .tool_response_content_param import ToolResponseContentParam as ToolResponseContentParam diff --git a/src/agentex/types/agent_rpc_by_name_params.py b/src/agentex/types/agent_rpc_by_name_params.py index 5014a076..191081cc 100644 --- a/src/agentex/types/agent_rpc_by_name_params.py +++ b/src/agentex/types/agent_rpc_by_name_params.py @@ -26,6 +26,7 @@ class AgentRpcByNameParams(TypedDict, total=False): method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] params: Required[Params] + """The parameters for the agent RPC request""" id: Union[int, str, None] diff --git a/src/agentex/types/agent_rpc_by_name_response.py b/src/agentex/types/agent_rpc_by_name_response.py new file mode 100644 index 00000000..05317965 --- /dev/null +++ b/src/agentex/types/agent_rpc_by_name_response.py @@ -0,0 +1,165 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal, Annotated, TypeAlias + +from .task import Task +from .event import Event +from .._utils import PropertyInfo +from .._models import BaseModel +from .data_content import DataContent +from .task_message import TaskMessage +from .text_content import TextContent +from .tool_request_content import ToolRequestContent +from .tool_response_content import ToolResponseContent + +__all__ = [ + "AgentRpcByNameResponse", + "Result", + "ResultStreamTaskMessageStart", + "ResultStreamTaskMessageStartContent", + "ResultStreamTaskMessageDelta", + "ResultStreamTaskMessageDeltaDelta", + "ResultStreamTaskMessageDeltaDeltaTextDelta", + "ResultStreamTaskMessageDeltaDeltaDataDelta", + "ResultStreamTaskMessageDeltaDeltaToolRequestDelta", + "ResultStreamTaskMessageDeltaDeltaToolResponseDelta", + "ResultStreamTaskMessageFull", + "ResultStreamTaskMessageFullContent", + "ResultStreamTaskMessageDone", +] + +ResultStreamTaskMessageStartContent: TypeAlias = Annotated[ + Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") +] + + +class ResultStreamTaskMessageStart(BaseModel): + content: ResultStreamTaskMessageStartContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["start"]] = None + + +class ResultStreamTaskMessageDeltaDeltaTextDelta(BaseModel): + text_delta: Optional[str] = None + + type: Optional[Literal["text"]] = None + + +class ResultStreamTaskMessageDeltaDeltaDataDelta(BaseModel): + data_delta: Optional[str] = None + + type: Optional[Literal["data"]] = None + + +class ResultStreamTaskMessageDeltaDeltaToolRequestDelta(BaseModel): + name: str + + tool_call_id: str + + arguments_delta: Optional[str] = None + + type: Optional[Literal["tool_request"]] = None + + +class ResultStreamTaskMessageDeltaDeltaToolResponseDelta(BaseModel): + name: str + + tool_call_id: str + + content_delta: Optional[str] = None + + type: Optional[Literal["tool_response"]] = None + + +ResultStreamTaskMessageDeltaDelta: TypeAlias = Annotated[ + Union[ + ResultStreamTaskMessageDeltaDeltaTextDelta, + ResultStreamTaskMessageDeltaDeltaDataDelta, + ResultStreamTaskMessageDeltaDeltaToolRequestDelta, + ResultStreamTaskMessageDeltaDeltaToolResponseDelta, + None, + ], + PropertyInfo(discriminator="type"), +] + + +class ResultStreamTaskMessageDelta(BaseModel): + delta: Optional[ResultStreamTaskMessageDeltaDelta] = None + """Delta for text updates""" + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["delta"]] = None + + +ResultStreamTaskMessageFullContent: TypeAlias = Annotated[ + Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") +] + + +class ResultStreamTaskMessageFull(BaseModel): + content: ResultStreamTaskMessageFullContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["full"]] = None + + +class ResultStreamTaskMessageDone(BaseModel): + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["done"]] = None + + +Result: TypeAlias = Union[ + List[TaskMessage], + ResultStreamTaskMessageStart, + ResultStreamTaskMessageDelta, + ResultStreamTaskMessageFull, + ResultStreamTaskMessageDone, + Task, + Event, + None, +] + + +class AgentRpcByNameResponse(BaseModel): + result: Optional[Result] = None + """The result of the agent RPC request""" + + id: Union[int, str, None] = None + + error: Optional[object] = None + + jsonrpc: Optional[Literal["2.0"]] = None diff --git a/src/agentex/types/agent_rpc_params.py b/src/agentex/types/agent_rpc_params.py index 2c79a7a9..4e83e75f 100644 --- a/src/agentex/types/agent_rpc_params.py +++ b/src/agentex/types/agent_rpc_params.py @@ -26,6 +26,7 @@ class AgentRpcParams(TypedDict, total=False): method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] params: Required[Params] + """The parameters for the agent RPC request""" id: Union[int, str, None] diff --git a/src/agentex/types/agent_rpc_response.py b/src/agentex/types/agent_rpc_response.py new file mode 100644 index 00000000..f67a8152 --- /dev/null +++ b/src/agentex/types/agent_rpc_response.py @@ -0,0 +1,165 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal, Annotated, TypeAlias + +from .task import Task +from .event import Event +from .._utils import PropertyInfo +from .._models import BaseModel +from .data_content import DataContent +from .task_message import TaskMessage +from .text_content import TextContent +from .tool_request_content import ToolRequestContent +from .tool_response_content import ToolResponseContent + +__all__ = [ + "AgentRpcResponse", + "Result", + "ResultStreamTaskMessageStart", + "ResultStreamTaskMessageStartContent", + "ResultStreamTaskMessageDelta", + "ResultStreamTaskMessageDeltaDelta", + "ResultStreamTaskMessageDeltaDeltaTextDelta", + "ResultStreamTaskMessageDeltaDeltaDataDelta", + "ResultStreamTaskMessageDeltaDeltaToolRequestDelta", + "ResultStreamTaskMessageDeltaDeltaToolResponseDelta", + "ResultStreamTaskMessageFull", + "ResultStreamTaskMessageFullContent", + "ResultStreamTaskMessageDone", +] + +ResultStreamTaskMessageStartContent: TypeAlias = Annotated[ + Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") +] + + +class ResultStreamTaskMessageStart(BaseModel): + content: ResultStreamTaskMessageStartContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["start"]] = None + + +class ResultStreamTaskMessageDeltaDeltaTextDelta(BaseModel): + text_delta: Optional[str] = None + + type: Optional[Literal["text"]] = None + + +class ResultStreamTaskMessageDeltaDeltaDataDelta(BaseModel): + data_delta: Optional[str] = None + + type: Optional[Literal["data"]] = None + + +class ResultStreamTaskMessageDeltaDeltaToolRequestDelta(BaseModel): + name: str + + tool_call_id: str + + arguments_delta: Optional[str] = None + + type: Optional[Literal["tool_request"]] = None + + +class ResultStreamTaskMessageDeltaDeltaToolResponseDelta(BaseModel): + name: str + + tool_call_id: str + + content_delta: Optional[str] = None + + type: Optional[Literal["tool_response"]] = None + + +ResultStreamTaskMessageDeltaDelta: TypeAlias = Annotated[ + Union[ + ResultStreamTaskMessageDeltaDeltaTextDelta, + ResultStreamTaskMessageDeltaDeltaDataDelta, + ResultStreamTaskMessageDeltaDeltaToolRequestDelta, + ResultStreamTaskMessageDeltaDeltaToolResponseDelta, + None, + ], + PropertyInfo(discriminator="type"), +] + + +class ResultStreamTaskMessageDelta(BaseModel): + delta: Optional[ResultStreamTaskMessageDeltaDelta] = None + """Delta for text updates""" + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["delta"]] = None + + +ResultStreamTaskMessageFullContent: TypeAlias = Annotated[ + Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") +] + + +class ResultStreamTaskMessageFull(BaseModel): + content: ResultStreamTaskMessageFullContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["full"]] = None + + +class ResultStreamTaskMessageDone(BaseModel): + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["done"]] = None + + +Result: TypeAlias = Union[ + List[TaskMessage], + ResultStreamTaskMessageStart, + ResultStreamTaskMessageDelta, + ResultStreamTaskMessageFull, + ResultStreamTaskMessageDone, + Task, + Event, + None, +] + + +class AgentRpcResponse(BaseModel): + result: Optional[Result] = None + """The result of the agent RPC request""" + + id: Union[int, str, None] = None + + error: Optional[object] = None + + jsonrpc: Optional[Literal["2.0"]] = None diff --git a/src/agentex/types/message_create_params.py b/src/agentex/types/message_create_params.py index 06ec3727..4d59ca07 100644 --- a/src/agentex/types/message_create_params.py +++ b/src/agentex/types/message_create_params.py @@ -3,9 +3,8 @@ from __future__ import annotations from typing import Union, Optional -from typing_extensions import Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, TypeAlias, TypedDict -from .streaming_status import StreamingStatus from .data_content_param import DataContentParam from .text_content_param import TextContentParam from .tool_request_content_param import ToolRequestContentParam @@ -19,7 +18,7 @@ class MessageCreateParams(TypedDict, total=False): task_id: Required[str] - streaming_status: Optional[StreamingStatus] + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] Content: TypeAlias = Union[TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam] diff --git a/src/agentex/types/message_update_params.py b/src/agentex/types/message_update_params.py index bc5305b8..08ce8478 100644 --- a/src/agentex/types/message_update_params.py +++ b/src/agentex/types/message_update_params.py @@ -3,9 +3,8 @@ from __future__ import annotations from typing import Union, Optional -from typing_extensions import Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, TypeAlias, TypedDict -from .streaming_status import StreamingStatus from .data_content_param import DataContentParam from .text_content_param import TextContentParam from .tool_request_content_param import ToolRequestContentParam @@ -19,7 +18,7 @@ class MessageUpdateParams(TypedDict, total=False): task_id: Required[str] - streaming_status: Optional[StreamingStatus] + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] Content: TypeAlias = Union[TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam] diff --git a/src/agentex/types/streaming_status.py b/src/agentex/types/streaming_status.py deleted file mode 100644 index 196d7881..00000000 --- a/src/agentex/types/streaming_status.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal, TypeAlias - -__all__ = ["StreamingStatus"] - -StreamingStatus: TypeAlias = Literal["IN_PROGRESS", "DONE"] diff --git a/src/agentex/types/task_message.py b/src/agentex/types/task_message.py index 686ade7d..29adf4d3 100644 --- a/src/agentex/types/task_message.py +++ b/src/agentex/types/task_message.py @@ -2,13 +2,12 @@ from typing import Union, Optional from datetime import datetime -from typing_extensions import Annotated, TypeAlias +from typing_extensions import Literal, Annotated, TypeAlias from .._utils import PropertyInfo from .._models import BaseModel from .data_content import DataContent from .text_content import TextContent -from .streaming_status import StreamingStatus from .tool_request_content import ToolRequestContent from .tool_response_content import ToolResponseContent @@ -20,17 +19,23 @@ class TaskMessage(BaseModel): - id: str - """The task message's unique id""" - content: Content + """The content of the message. - created_at: datetime - """The timestamp when the message was created""" + This content is not OpenAI compatible. These are messages that are meant to be + displayed to the user. + """ task_id: str + """ID of the task this message belongs to""" + + id: Optional[str] = None + """The task message's unique id""" + + created_at: Optional[datetime] = None + """The timestamp when the message was created""" - streaming_status: Optional[StreamingStatus] = None + streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] = None updated_at: Optional[datetime] = None """The timestamp when the message was last updated""" diff --git a/tests/api_resources/test_agents.py b/tests/api_resources/test_agents.py index b2819f31..e415e011 100644 --- a/tests/api_resources/test_agents.py +++ b/tests/api_resources/test_agents.py @@ -9,7 +9,12 @@ from agentex import Agentex, AsyncAgentex from tests.utils import assert_matches_type -from agentex.types import Agent, AgentListResponse +from agentex.types import ( + Agent, + AgentRpcResponse, + AgentListResponse, + AgentRpcByNameResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -229,7 +234,7 @@ def test_method_rpc(self, client: Agentex) -> None: method="event/send", params={}, ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -244,7 +249,7 @@ def test_method_rpc_with_all_params(self, client: Agentex) -> None: id=0, jsonrpc="2.0", ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -258,7 +263,7 @@ def test_raw_response_rpc(self, client: Agentex) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -272,7 +277,7 @@ def test_streaming_response_rpc(self, client: Agentex) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) assert cast(Any, response.is_closed) is True @@ -294,7 +299,7 @@ def test_method_rpc_by_name(self, client: Agentex) -> None: method="event/send", params={}, ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -309,7 +314,7 @@ def test_method_rpc_by_name_with_all_params(self, client: Agentex) -> None: id=0, jsonrpc="2.0", ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -323,7 +328,7 @@ def test_raw_response_rpc_by_name(self, client: Agentex) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -337,7 +342,7 @@ def test_streaming_response_rpc_by_name(self, client: Agentex) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) assert cast(Any, response.is_closed) is True @@ -569,7 +574,7 @@ async def test_method_rpc(self, async_client: AsyncAgentex) -> None: method="event/send", params={}, ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -584,7 +589,7 @@ async def test_method_rpc_with_all_params(self, async_client: AsyncAgentex) -> N id=0, jsonrpc="2.0", ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -598,7 +603,7 @@ async def test_raw_response_rpc(self, async_client: AsyncAgentex) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = await response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -612,7 +617,7 @@ async def test_streaming_response_rpc(self, async_client: AsyncAgentex) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = await response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) assert cast(Any, response.is_closed) is True @@ -634,7 +639,7 @@ async def test_method_rpc_by_name(self, async_client: AsyncAgentex) -> None: method="event/send", params={}, ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -649,7 +654,7 @@ async def test_method_rpc_by_name_with_all_params(self, async_client: AsyncAgent id=0, jsonrpc="2.0", ) - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -663,7 +668,7 @@ async def test_raw_response_rpc_by_name(self, async_client: AsyncAgentex) -> Non assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = await response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -677,7 +682,7 @@ async def test_streaming_response_rpc_by_name(self, async_client: AsyncAgentex) assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = await response.parse() - assert_matches_type(object, agent, path=["response"]) + assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) assert cast(Any, response.is_closed) is True From d999a438c409f04b7e36b5df2d9b080d1d1b0e4a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:04:04 +0000 Subject: [PATCH 6/7] feat(api): manual updates --- .stats.yml | 2 +- api.md | 20 ++- src/agentex/resources/agents.py | 20 +-- src/agentex/resources/messages/batch.py | 9 +- src/agentex/resources/messages/messages.py | 9 +- src/agentex/types/__init__.py | 10 +- src/agentex/types/agent_rpc_by_name_params.py | 75 +------- .../types/agent_rpc_by_name_response.py | 165 ------------------ src/agentex/types/agent_rpc_params.py | 55 ++---- src/agentex/types/agent_rpc_params1.py | 21 +++ src/agentex/types/agent_rpc_response.py | 155 +--------------- src/agentex/types/agent_rpc_result.py | 90 ++++++++++ src/agentex/types/data_delta.py | 14 ++ src/agentex/types/event.py | 17 +- src/agentex/types/message_create_params.py | 16 +- src/agentex/types/message_update_params.py | 16 +- .../types/messages/batch_create_params.py | 16 +- .../types/messages/batch_update_params.py | 16 +- src/agentex/types/shared/__init__.py | 3 + .../types/shared/task_message_update.py | 83 +++++++++ src/agentex/types/task_message.py | 18 +- src/agentex/types/task_message_content.py | 16 ++ .../types/task_message_content_param.py | 17 ++ src/agentex/types/task_message_delta.py | 16 ++ src/agentex/types/text_delta.py | 14 ++ src/agentex/types/tool_request_delta.py | 18 ++ src/agentex/types/tool_response_delta.py | 18 ++ tests/api_resources/test_agents.py | 17 +- 28 files changed, 414 insertions(+), 532 deletions(-) delete mode 100644 src/agentex/types/agent_rpc_by_name_response.py create mode 100644 src/agentex/types/agent_rpc_params1.py create mode 100644 src/agentex/types/agent_rpc_result.py create mode 100644 src/agentex/types/data_delta.py create mode 100644 src/agentex/types/shared/__init__.py create mode 100644 src/agentex/types/shared/task_message_update.py create mode 100644 src/agentex/types/task_message_content.py create mode 100644 src/agentex/types/task_message_content_param.py create mode 100644 src/agentex/types/task_message_delta.py create mode 100644 src/agentex/types/text_delta.py create mode 100644 src/agentex/types/tool_request_delta.py create mode 100644 src/agentex/types/tool_response_delta.py diff --git a/.stats.yml b/.stats.yml index e880ba66..3a087b17 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-1d08fb2290b5310c91801d7575d356628d372fd5434e15d3b9cead48eadb893f.yml openapi_spec_hash: c07c588fb8429fbf024189df62f20fa4 -config_hash: 5a41a91d658dffbd60d617eb02e945f6 +config_hash: 2e4b423af3db79ebd8170c401ea9093a diff --git a/api.md b/api.md index 474200e1..f0754dd0 100644 --- a/api.md +++ b/api.md @@ -1,3 +1,9 @@ +# Shared Types + +```python +from agentex.types import TaskMessageUpdate +``` + # Agents Types: @@ -6,10 +12,18 @@ Types: from agentex.types import ( AcpType, Agent, + AgentRpcParams, AgentRpcRequest, - AgentListResponse, AgentRpcResponse, - AgentRpcByNameResponse, + AgentRpcResult, + DataDelta, + TaskMessageContent, + TaskMessageDelta, + TaskMessageUpdate, + TextDelta, + ToolRequestDelta, + ToolResponseDelta, + AgentListResponse, ) ``` @@ -21,7 +35,7 @@ Methods: - client.agents.delete_by_name(agent_name) -> Agent - client.agents.retrieve_by_name(agent_name) -> Agent - client.agents.rpc(agent_id, \*\*params) -> AgentRpcResponse -- client.agents.rpc_by_name(agent_name, \*\*params) -> AgentRpcByNameResponse +- client.agents.rpc_by_name(agent_name, \*\*params) -> AgentRpcResponse # Tasks diff --git a/src/agentex/resources/agents.py b/src/agentex/resources/agents.py index 3e5626c6..8b329be8 100644 --- a/src/agentex/resources/agents.py +++ b/src/agentex/resources/agents.py @@ -7,7 +7,7 @@ import httpx -from ..types import agent_rpc_params, agent_list_params, agent_rpc_by_name_params +from ..types import AgentRpcParams, agent_rpc_params, agent_list_params, agent_rpc_by_name_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property @@ -20,9 +20,9 @@ ) from ..types.agent import Agent from .._base_client import make_request_options +from ..types.agent_rpc_params import AgentRpcParams from ..types.agent_rpc_response import AgentRpcResponse from ..types.agent_list_response import AgentListResponse -from ..types.agent_rpc_by_name_response import AgentRpcByNameResponse __all__ = ["AgentsResource", "AsyncAgentsResource"] @@ -221,7 +221,7 @@ def rpc( agent_id: str, *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: agent_rpc_params.Params, + params: AgentRpcParams, id: Union[int, str, None] | NotGiven = NOT_GIVEN, jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -269,7 +269,7 @@ def rpc_by_name( agent_name: str, *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: agent_rpc_by_name_params.Params, + params: AgentRpcParams, id: Union[int, str, None] | NotGiven = NOT_GIVEN, jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -278,7 +278,7 @@ def rpc_by_name( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AgentRpcByNameResponse: + ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique name. @@ -309,7 +309,7 @@ def rpc_by_name( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentRpcByNameResponse, + cast_to=AgentRpcResponse, ) @@ -507,7 +507,7 @@ async def rpc( agent_id: str, *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: agent_rpc_params.Params, + params: AgentRpcParams, id: Union[int, str, None] | NotGiven = NOT_GIVEN, jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -555,7 +555,7 @@ async def rpc_by_name( agent_name: str, *, method: Literal["event/send", "task/create", "message/send", "task/cancel"], - params: agent_rpc_by_name_params.Params, + params: AgentRpcParams, id: Union[int, str, None] | NotGiven = NOT_GIVEN, jsonrpc: Literal["2.0"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -564,7 +564,7 @@ async def rpc_by_name( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AgentRpcByNameResponse: + ) -> AgentRpcResponse: """ Handle JSON-RPC requests for an agent by its unique name. @@ -595,7 +595,7 @@ async def rpc_by_name( options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=AgentRpcByNameResponse, + cast_to=AgentRpcResponse, ) diff --git a/src/agentex/resources/messages/batch.py b/src/agentex/resources/messages/batch.py index 478c2df5..58412663 100644 --- a/src/agentex/resources/messages/batch.py +++ b/src/agentex/resources/messages/batch.py @@ -18,6 +18,7 @@ ) from ..._base_client import make_request_options from ...types.messages import batch_create_params, batch_update_params +from ...types.task_message_content_param import TaskMessageContentParam from ...types.messages.batch_create_response import BatchCreateResponse from ...types.messages.batch_update_response import BatchUpdateResponse @@ -47,7 +48,7 @@ def with_streaming_response(self) -> BatchResourceWithStreamingResponse: def create( self, *, - contents: Iterable[batch_create_params.Content], + contents: Iterable[TaskMessageContentParam], task_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -87,7 +88,7 @@ def update( self, *, task_id: str, - updates: Dict[str, batch_update_params.Updates], + updates: Dict[str, TaskMessageContentParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -146,7 +147,7 @@ def with_streaming_response(self) -> AsyncBatchResourceWithStreamingResponse: async def create( self, *, - contents: Iterable[batch_create_params.Content], + contents: Iterable[TaskMessageContentParam], task_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -186,7 +187,7 @@ async def update( self, *, task_id: str, - updates: Dict[str, batch_update_params.Updates], + updates: Dict[str, TaskMessageContentParam], # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, diff --git a/src/agentex/resources/messages/messages.py b/src/agentex/resources/messages/messages.py index 2d83fb4e..b7f78c94 100644 --- a/src/agentex/resources/messages/messages.py +++ b/src/agentex/resources/messages/messages.py @@ -29,6 +29,7 @@ from ..._base_client import make_request_options from ...types.task_message import TaskMessage from ...types.message_list_response import MessageListResponse +from ...types.task_message_content_param import TaskMessageContentParam __all__ = ["MessagesResource", "AsyncMessagesResource"] @@ -60,7 +61,7 @@ def with_streaming_response(self) -> MessagesResourceWithStreamingResponse: def create( self, *, - content: message_create_params.Content, + content: TaskMessageContentParam, task_id: str, streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -135,7 +136,7 @@ def update( self, message_id: str, *, - content: message_update_params.Content, + content: TaskMessageContentParam, task_id: str, streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -245,7 +246,7 @@ def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse: async def create( self, *, - content: message_create_params.Content, + content: TaskMessageContentParam, task_id: str, streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -320,7 +321,7 @@ async def update( self, message_id: str, *, - content: message_update_params.Content, + content: TaskMessageContentParam, task_id: str, streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. diff --git a/src/agentex/types/__init__.py b/src/agentex/types/__init__.py index 5a380cdc..f021a20d 100644 --- a/src/agentex/types/__init__.py +++ b/src/agentex/types/__init__.py @@ -7,13 +7,17 @@ from .agent import Agent as Agent from .event import Event as Event from .state import State as State +from .shared import TaskMessageUpdate as TaskMessageUpdate from .acp_type import AcpType as AcpType +from .data_delta import DataDelta as DataDelta +from .text_delta import TextDelta as TextDelta from .data_content import DataContent as DataContent from .task_message import TaskMessage as TaskMessage from .text_content import TextContent as TextContent from .message_style import MessageStyle as MessageStyle from .message_author import MessageAuthor as MessageAuthor from .agent_rpc_params import AgentRpcParams as AgentRpcParams +from .agent_rpc_result import AgentRpcResult as AgentRpcResult from .span_list_params import SpanListParams as SpanListParams from .agent_list_params import AgentListParams as AgentListParams from .event_list_params import EventListParams as EventListParams @@ -25,14 +29,18 @@ from .span_list_response import SpanListResponse as SpanListResponse from .span_update_params import SpanUpdateParams as SpanUpdateParams from .task_list_response import TaskListResponse as TaskListResponse +from .task_message_delta import TaskMessageDelta as TaskMessageDelta from .text_content_param import TextContentParam as TextContentParam +from .tool_request_delta import ToolRequestDelta as ToolRequestDelta from .agent_list_response import AgentListResponse as AgentListResponse from .event_list_response import EventListResponse as EventListResponse from .message_list_params import MessageListParams as MessageListParams from .state_create_params import StateCreateParams as StateCreateParams from .state_list_response import StateListResponse as StateListResponse from .state_update_params import StateUpdateParams as StateUpdateParams +from .tool_response_delta import ToolResponseDelta as ToolResponseDelta from .tracker_list_params import TrackerListParams as TrackerListParams +from .task_message_content import TaskMessageContent as TaskMessageContent from .tool_request_content import ToolRequestContent as ToolRequestContent from .message_create_params import MessageCreateParams as MessageCreateParams from .message_list_response import MessageListResponse as MessageListResponse @@ -41,6 +49,6 @@ from .tracker_list_response import TrackerListResponse as TrackerListResponse from .tracker_update_params import TrackerUpdateParams as TrackerUpdateParams from .agent_rpc_by_name_params import AgentRpcByNameParams as AgentRpcByNameParams -from .agent_rpc_by_name_response import AgentRpcByNameResponse as AgentRpcByNameResponse +from .task_message_content_param import TaskMessageContentParam as TaskMessageContentParam from .tool_request_content_param import ToolRequestContentParam as ToolRequestContentParam from .tool_response_content_param import ToolResponseContentParam as ToolResponseContentParam diff --git a/src/agentex/types/agent_rpc_by_name_params.py b/src/agentex/types/agent_rpc_by_name_params.py index 191081cc..5be189d7 100644 --- a/src/agentex/types/agent_rpc_by_name_params.py +++ b/src/agentex/types/agent_rpc_by_name_params.py @@ -2,85 +2,20 @@ from __future__ import annotations -from typing import Dict, Union, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing import Union +from typing_extensions import Literal, Required, TypedDict -from .data_content_param import DataContentParam -from .text_content_param import TextContentParam -from .tool_request_content_param import ToolRequestContentParam -from .tool_response_content_param import ToolResponseContentParam +from .agent_rpc_params import AgentRpcParams -__all__ = [ - "AgentRpcByNameParams", - "Params", - "ParamsCreateTaskRequest", - "ParamsCancelTaskRequest", - "ParamsSendMessageRequest", - "ParamsSendMessageRequestContent", - "ParamsSendEventRequest", - "ParamsSendEventRequestContent", -] +__all__ = ["AgentRpcByNameParams"] class AgentRpcByNameParams(TypedDict, total=False): method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] - params: Required[Params] + params: Required[AgentRpcParams] """The parameters for the agent RPC request""" id: Union[int, str, None] jsonrpc: Literal["2.0"] - - -class ParamsCreateTaskRequest(TypedDict, total=False): - name: Optional[str] - """The name of the task to create""" - - params: Optional[Dict[str, object]] - """The parameters for the task""" - - -class ParamsCancelTaskRequest(TypedDict, total=False): - task_id: Optional[str] - """The ID of the task to cancel. Either this or task_name must be provided.""" - - task_name: Optional[str] - """The name of the task to cancel. Either this or task_id must be provided.""" - - -ParamsSendMessageRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendMessageRequest(TypedDict, total=False): - content: Required[ParamsSendMessageRequestContent] - """The message that was sent to the agent""" - - stream: bool - """Whether to stream the response message back to the client""" - - task_id: Optional[str] - """The ID of the task that the message was sent to""" - - -ParamsSendEventRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendEventRequest(TypedDict, total=False): - content: Optional[ParamsSendEventRequestContent] - """The content to send to the event""" - - task_id: Optional[str] - """The ID of the task that the event was sent to""" - - task_name: Optional[str] - """The name of the task that the event was sent to""" - - -Params: TypeAlias = Union[ - ParamsCreateTaskRequest, ParamsCancelTaskRequest, ParamsSendMessageRequest, ParamsSendEventRequest -] diff --git a/src/agentex/types/agent_rpc_by_name_response.py b/src/agentex/types/agent_rpc_by_name_response.py deleted file mode 100644 index 05317965..00000000 --- a/src/agentex/types/agent_rpc_by_name_response.py +++ /dev/null @@ -1,165 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from typing_extensions import Literal, Annotated, TypeAlias - -from .task import Task -from .event import Event -from .._utils import PropertyInfo -from .._models import BaseModel -from .data_content import DataContent -from .task_message import TaskMessage -from .text_content import TextContent -from .tool_request_content import ToolRequestContent -from .tool_response_content import ToolResponseContent - -__all__ = [ - "AgentRpcByNameResponse", - "Result", - "ResultStreamTaskMessageStart", - "ResultStreamTaskMessageStartContent", - "ResultStreamTaskMessageDelta", - "ResultStreamTaskMessageDeltaDelta", - "ResultStreamTaskMessageDeltaDeltaTextDelta", - "ResultStreamTaskMessageDeltaDeltaDataDelta", - "ResultStreamTaskMessageDeltaDeltaToolRequestDelta", - "ResultStreamTaskMessageDeltaDeltaToolResponseDelta", - "ResultStreamTaskMessageFull", - "ResultStreamTaskMessageFullContent", - "ResultStreamTaskMessageDone", -] - -ResultStreamTaskMessageStartContent: TypeAlias = Annotated[ - Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") -] - - -class ResultStreamTaskMessageStart(BaseModel): - content: ResultStreamTaskMessageStartContent - - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["start"]] = None - - -class ResultStreamTaskMessageDeltaDeltaTextDelta(BaseModel): - text_delta: Optional[str] = None - - type: Optional[Literal["text"]] = None - - -class ResultStreamTaskMessageDeltaDeltaDataDelta(BaseModel): - data_delta: Optional[str] = None - - type: Optional[Literal["data"]] = None - - -class ResultStreamTaskMessageDeltaDeltaToolRequestDelta(BaseModel): - name: str - - tool_call_id: str - - arguments_delta: Optional[str] = None - - type: Optional[Literal["tool_request"]] = None - - -class ResultStreamTaskMessageDeltaDeltaToolResponseDelta(BaseModel): - name: str - - tool_call_id: str - - content_delta: Optional[str] = None - - type: Optional[Literal["tool_response"]] = None - - -ResultStreamTaskMessageDeltaDelta: TypeAlias = Annotated[ - Union[ - ResultStreamTaskMessageDeltaDeltaTextDelta, - ResultStreamTaskMessageDeltaDeltaDataDelta, - ResultStreamTaskMessageDeltaDeltaToolRequestDelta, - ResultStreamTaskMessageDeltaDeltaToolResponseDelta, - None, - ], - PropertyInfo(discriminator="type"), -] - - -class ResultStreamTaskMessageDelta(BaseModel): - delta: Optional[ResultStreamTaskMessageDeltaDelta] = None - """Delta for text updates""" - - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["delta"]] = None - - -ResultStreamTaskMessageFullContent: TypeAlias = Annotated[ - Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") -] - - -class ResultStreamTaskMessageFull(BaseModel): - content: ResultStreamTaskMessageFullContent - - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["full"]] = None - - -class ResultStreamTaskMessageDone(BaseModel): - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["done"]] = None - - -Result: TypeAlias = Union[ - List[TaskMessage], - ResultStreamTaskMessageStart, - ResultStreamTaskMessageDelta, - ResultStreamTaskMessageFull, - ResultStreamTaskMessageDone, - Task, - Event, - None, -] - - -class AgentRpcByNameResponse(BaseModel): - result: Optional[Result] = None - """The result of the agent RPC request""" - - id: Union[int, str, None] = None - - error: Optional[object] = None - - jsonrpc: Optional[Literal["2.0"]] = None diff --git a/src/agentex/types/agent_rpc_params.py b/src/agentex/types/agent_rpc_params.py index 4e83e75f..5082b18c 100644 --- a/src/agentex/types/agent_rpc_params.py +++ b/src/agentex/types/agent_rpc_params.py @@ -3,37 +3,14 @@ from __future__ import annotations from typing import Dict, Union, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Required, TypeAlias, TypedDict -from .data_content_param import DataContentParam -from .text_content_param import TextContentParam -from .tool_request_content_param import ToolRequestContentParam -from .tool_response_content_param import ToolResponseContentParam +from .task_message_content_param import TaskMessageContentParam -__all__ = [ - "AgentRpcParams", - "Params", - "ParamsCreateTaskRequest", - "ParamsCancelTaskRequest", - "ParamsSendMessageRequest", - "ParamsSendMessageRequestContent", - "ParamsSendEventRequest", - "ParamsSendEventRequestContent", -] +__all__ = ["AgentRpcParams", "CreateTaskRequest", "CancelTaskRequest", "SendMessageRequest", "SendEventRequest"] -class AgentRpcParams(TypedDict, total=False): - method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] - - params: Required[Params] - """The parameters for the agent RPC request""" - - id: Union[int, str, None] - - jsonrpc: Literal["2.0"] - - -class ParamsCreateTaskRequest(TypedDict, total=False): +class CreateTaskRequest(TypedDict, total=False): name: Optional[str] """The name of the task to create""" @@ -41,7 +18,7 @@ class ParamsCreateTaskRequest(TypedDict, total=False): """The parameters for the task""" -class ParamsCancelTaskRequest(TypedDict, total=False): +class CancelTaskRequest(TypedDict, total=False): task_id: Optional[str] """The ID of the task to cancel. Either this or task_name must be provided.""" @@ -49,13 +26,8 @@ class ParamsCancelTaskRequest(TypedDict, total=False): """The name of the task to cancel. Either this or task_id must be provided.""" -ParamsSendMessageRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendMessageRequest(TypedDict, total=False): - content: Required[ParamsSendMessageRequestContent] +class SendMessageRequest(TypedDict, total=False): + content: Required[TaskMessageContentParam] """The message that was sent to the agent""" stream: bool @@ -65,13 +37,8 @@ class ParamsSendMessageRequest(TypedDict, total=False): """The ID of the task that the message was sent to""" -ParamsSendEventRequestContent: TypeAlias = Union[ - TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam -] - - -class ParamsSendEventRequest(TypedDict, total=False): - content: Optional[ParamsSendEventRequestContent] +class SendEventRequest(TypedDict, total=False): + content: Optional[TaskMessageContentParam] """The content to send to the event""" task_id: Optional[str] @@ -81,6 +48,4 @@ class ParamsSendEventRequest(TypedDict, total=False): """The name of the task that the event was sent to""" -Params: TypeAlias = Union[ - ParamsCreateTaskRequest, ParamsCancelTaskRequest, ParamsSendMessageRequest, ParamsSendEventRequest -] +AgentRpcParams: TypeAlias = Union[CreateTaskRequest, CancelTaskRequest, SendMessageRequest, SendEventRequest] diff --git a/src/agentex/types/agent_rpc_params1.py b/src/agentex/types/agent_rpc_params1.py new file mode 100644 index 00000000..3eae8b68 --- /dev/null +++ b/src/agentex/types/agent_rpc_params1.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal, Required, TypedDict + +from . import agent_rpc_params + +__all__ = ["AgentRpcParams"] + + +class AgentRpcParams(TypedDict, total=False): + method: Required[Literal["event/send", "task/create", "message/send", "task/cancel"]] + + params: Required[agent_rpc_params.AgentRpcParams] + """The parameters for the agent RPC request""" + + id: Union[int, str, None] + + jsonrpc: Literal["2.0"] diff --git a/src/agentex/types/agent_rpc_response.py b/src/agentex/types/agent_rpc_response.py index f67a8152..e9995e80 100644 --- a/src/agentex/types/agent_rpc_response.py +++ b/src/agentex/types/agent_rpc_response.py @@ -1,161 +1,16 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional -from typing_extensions import Literal, Annotated, TypeAlias +from typing import Union, Optional +from typing_extensions import Literal -from .task import Task -from .event import Event -from .._utils import PropertyInfo from .._models import BaseModel -from .data_content import DataContent -from .task_message import TaskMessage -from .text_content import TextContent -from .tool_request_content import ToolRequestContent -from .tool_response_content import ToolResponseContent +from .agent_rpc_result import AgentRpcResult -__all__ = [ - "AgentRpcResponse", - "Result", - "ResultStreamTaskMessageStart", - "ResultStreamTaskMessageStartContent", - "ResultStreamTaskMessageDelta", - "ResultStreamTaskMessageDeltaDelta", - "ResultStreamTaskMessageDeltaDeltaTextDelta", - "ResultStreamTaskMessageDeltaDeltaDataDelta", - "ResultStreamTaskMessageDeltaDeltaToolRequestDelta", - "ResultStreamTaskMessageDeltaDeltaToolResponseDelta", - "ResultStreamTaskMessageFull", - "ResultStreamTaskMessageFullContent", - "ResultStreamTaskMessageDone", -] - -ResultStreamTaskMessageStartContent: TypeAlias = Annotated[ - Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") -] - - -class ResultStreamTaskMessageStart(BaseModel): - content: ResultStreamTaskMessageStartContent - - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["start"]] = None - - -class ResultStreamTaskMessageDeltaDeltaTextDelta(BaseModel): - text_delta: Optional[str] = None - - type: Optional[Literal["text"]] = None - - -class ResultStreamTaskMessageDeltaDeltaDataDelta(BaseModel): - data_delta: Optional[str] = None - - type: Optional[Literal["data"]] = None - - -class ResultStreamTaskMessageDeltaDeltaToolRequestDelta(BaseModel): - name: str - - tool_call_id: str - - arguments_delta: Optional[str] = None - - type: Optional[Literal["tool_request"]] = None - - -class ResultStreamTaskMessageDeltaDeltaToolResponseDelta(BaseModel): - name: str - - tool_call_id: str - - content_delta: Optional[str] = None - - type: Optional[Literal["tool_response"]] = None - - -ResultStreamTaskMessageDeltaDelta: TypeAlias = Annotated[ - Union[ - ResultStreamTaskMessageDeltaDeltaTextDelta, - ResultStreamTaskMessageDeltaDeltaDataDelta, - ResultStreamTaskMessageDeltaDeltaToolRequestDelta, - ResultStreamTaskMessageDeltaDeltaToolResponseDelta, - None, - ], - PropertyInfo(discriminator="type"), -] - - -class ResultStreamTaskMessageDelta(BaseModel): - delta: Optional[ResultStreamTaskMessageDeltaDelta] = None - """Delta for text updates""" - - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["delta"]] = None - - -ResultStreamTaskMessageFullContent: TypeAlias = Annotated[ - Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") -] - - -class ResultStreamTaskMessageFull(BaseModel): - content: ResultStreamTaskMessageFullContent - - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["full"]] = None - - -class ResultStreamTaskMessageDone(BaseModel): - index: Optional[int] = None - - parent_task_message: Optional[TaskMessage] = None - """Represents a message in the agent system. - - This entity is used to store messages in MongoDB, with each message associated - with a specific task. - """ - - type: Optional[Literal["done"]] = None - - -Result: TypeAlias = Union[ - List[TaskMessage], - ResultStreamTaskMessageStart, - ResultStreamTaskMessageDelta, - ResultStreamTaskMessageFull, - ResultStreamTaskMessageDone, - Task, - Event, - None, -] +__all__ = ["AgentRpcResponse"] class AgentRpcResponse(BaseModel): - result: Optional[Result] = None + result: Optional[AgentRpcResult] = None """The result of the agent RPC request""" id: Union[int, str, None] = None diff --git a/src/agentex/types/agent_rpc_result.py b/src/agentex/types/agent_rpc_result.py new file mode 100644 index 00000000..63e30a5d --- /dev/null +++ b/src/agentex/types/agent_rpc_result.py @@ -0,0 +1,90 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal, TypeAlias + +from .task import Task +from .event import Event +from .._models import BaseModel +from .task_message import TaskMessage +from .task_message_delta import TaskMessageDelta +from .task_message_content import TaskMessageContent + +__all__ = [ + "AgentRpcResult", + "StreamTaskMessageStart", + "StreamTaskMessageDelta", + "StreamTaskMessageFull", + "StreamTaskMessageDone", +] + + +class StreamTaskMessageStart(BaseModel): + content: TaskMessageContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["start"]] = None + + +class StreamTaskMessageDelta(BaseModel): + delta: Optional[TaskMessageDelta] = None + """Delta for text updates""" + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["delta"]] = None + + +class StreamTaskMessageFull(BaseModel): + content: TaskMessageContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["full"]] = None + + +class StreamTaskMessageDone(BaseModel): + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["done"]] = None + + +AgentRpcResult: TypeAlias = Union[ + List[TaskMessage], + StreamTaskMessageStart, + StreamTaskMessageDelta, + StreamTaskMessageFull, + StreamTaskMessageDone, + Task, + Event, + None, +] diff --git a/src/agentex/types/data_delta.py b/src/agentex/types/data_delta.py new file mode 100644 index 00000000..e30c12e7 --- /dev/null +++ b/src/agentex/types/data_delta.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["DataDelta"] + + +class DataDelta(BaseModel): + data_delta: Optional[str] = None + + type: Optional[Literal["data"]] = None diff --git a/src/agentex/types/event.py b/src/agentex/types/event.py index 3f1e5997..9a544cb6 100644 --- a/src/agentex/types/event.py +++ b/src/agentex/types/event.py @@ -1,21 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import Optional from datetime import datetime -from typing_extensions import Annotated, TypeAlias -from .._utils import PropertyInfo from .._models import BaseModel -from .data_content import DataContent -from .text_content import TextContent -from .tool_request_content import ToolRequestContent -from .tool_response_content import ToolResponseContent +from .task_message_content import TaskMessageContent -__all__ = ["Event", "Content"] - -Content: TypeAlias = Annotated[ - Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent, None], PropertyInfo(discriminator="type") -] +__all__ = ["Event"] class Event(BaseModel): @@ -31,7 +22,7 @@ class Event(BaseModel): task_id: str """The UUID of the task that the event belongs to""" - content: Optional[Content] = None + content: Optional[TaskMessageContent] = None """The content of the event""" created_at: Optional[datetime] = None diff --git a/src/agentex/types/message_create_params.py b/src/agentex/types/message_create_params.py index 4d59ca07..787715ec 100644 --- a/src/agentex/types/message_create_params.py +++ b/src/agentex/types/message_create_params.py @@ -2,23 +2,17 @@ from __future__ import annotations -from typing import Union, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing import Optional +from typing_extensions import Literal, Required, TypedDict -from .data_content_param import DataContentParam -from .text_content_param import TextContentParam -from .tool_request_content_param import ToolRequestContentParam -from .tool_response_content_param import ToolResponseContentParam +from .task_message_content_param import TaskMessageContentParam -__all__ = ["MessageCreateParams", "Content"] +__all__ = ["MessageCreateParams"] class MessageCreateParams(TypedDict, total=False): - content: Required[Content] + content: Required[TaskMessageContentParam] task_id: Required[str] streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] - - -Content: TypeAlias = Union[TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam] diff --git a/src/agentex/types/message_update_params.py b/src/agentex/types/message_update_params.py index 08ce8478..ea3dbaf8 100644 --- a/src/agentex/types/message_update_params.py +++ b/src/agentex/types/message_update_params.py @@ -2,23 +2,17 @@ from __future__ import annotations -from typing import Union, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing import Optional +from typing_extensions import Literal, Required, TypedDict -from .data_content_param import DataContentParam -from .text_content_param import TextContentParam -from .tool_request_content_param import ToolRequestContentParam -from .tool_response_content_param import ToolResponseContentParam +from .task_message_content_param import TaskMessageContentParam -__all__ = ["MessageUpdateParams", "Content"] +__all__ = ["MessageUpdateParams"] class MessageUpdateParams(TypedDict, total=False): - content: Required[Content] + content: Required[TaskMessageContentParam] task_id: Required[str] streaming_status: Optional[Literal["IN_PROGRESS", "DONE"]] - - -Content: TypeAlias = Union[TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam] diff --git a/src/agentex/types/messages/batch_create_params.py b/src/agentex/types/messages/batch_create_params.py index c09c69a9..0a0153ae 100644 --- a/src/agentex/types/messages/batch_create_params.py +++ b/src/agentex/types/messages/batch_create_params.py @@ -2,21 +2,15 @@ from __future__ import annotations -from typing import Union, Iterable -from typing_extensions import Required, TypeAlias, TypedDict +from typing import Iterable +from typing_extensions import Required, TypedDict -from ..data_content_param import DataContentParam -from ..text_content_param import TextContentParam -from ..tool_request_content_param import ToolRequestContentParam -from ..tool_response_content_param import ToolResponseContentParam +from ..task_message_content_param import TaskMessageContentParam -__all__ = ["BatchCreateParams", "Content"] +__all__ = ["BatchCreateParams"] class BatchCreateParams(TypedDict, total=False): - contents: Required[Iterable[Content]] + contents: Required[Iterable[TaskMessageContentParam]] task_id: Required[str] - - -Content: TypeAlias = Union[TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam] diff --git a/src/agentex/types/messages/batch_update_params.py b/src/agentex/types/messages/batch_update_params.py index 68f24f8d..c25e46f6 100644 --- a/src/agentex/types/messages/batch_update_params.py +++ b/src/agentex/types/messages/batch_update_params.py @@ -2,21 +2,15 @@ from __future__ import annotations -from typing import Dict, Union -from typing_extensions import Required, TypeAlias, TypedDict +from typing import Dict +from typing_extensions import Required, TypedDict -from ..data_content_param import DataContentParam -from ..text_content_param import TextContentParam -from ..tool_request_content_param import ToolRequestContentParam -from ..tool_response_content_param import ToolResponseContentParam +from ..task_message_content_param import TaskMessageContentParam -__all__ = ["BatchUpdateParams", "Updates"] +__all__ = ["BatchUpdateParams"] class BatchUpdateParams(TypedDict, total=False): task_id: Required[str] - updates: Required[Dict[str, Updates]] - - -Updates: TypeAlias = Union[TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam] + updates: Required[Dict[str, TaskMessageContentParam]] diff --git a/src/agentex/types/shared/__init__.py b/src/agentex/types/shared/__init__.py new file mode 100644 index 00000000..7b5a4954 --- /dev/null +++ b/src/agentex/types/shared/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .task_message_update import TaskMessageUpdate as TaskMessageUpdate diff --git a/src/agentex/types/shared/task_message_update.py b/src/agentex/types/shared/task_message_update.py new file mode 100644 index 00000000..cc01b598 --- /dev/null +++ b/src/agentex/types/shared/task_message_update.py @@ -0,0 +1,83 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel +from ..task_message import TaskMessage +from ..task_message_delta import TaskMessageDelta +from ..task_message_content import TaskMessageContent + +__all__ = [ + "TaskMessageUpdate", + "StreamTaskMessageStart", + "StreamTaskMessageDelta", + "StreamTaskMessageFull", + "StreamTaskMessageDone", +] + + +class StreamTaskMessageStart(BaseModel): + content: TaskMessageContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["start"]] = None + + +class StreamTaskMessageDelta(BaseModel): + delta: Optional[TaskMessageDelta] = None + """Delta for text updates""" + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["delta"]] = None + + +class StreamTaskMessageFull(BaseModel): + content: TaskMessageContent + + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["full"]] = None + + +class StreamTaskMessageDone(BaseModel): + index: Optional[int] = None + + parent_task_message: Optional[TaskMessage] = None + """Represents a message in the agent system. + + This entity is used to store messages in MongoDB, with each message associated + with a specific task. + """ + + type: Optional[Literal["done"]] = None + + +TaskMessageUpdate: TypeAlias = Annotated[ + Union[StreamTaskMessageStart, StreamTaskMessageDelta, StreamTaskMessageFull, StreamTaskMessageDone], + PropertyInfo(discriminator="type"), +] diff --git a/src/agentex/types/task_message.py b/src/agentex/types/task_message.py index 29adf4d3..b5938cc8 100644 --- a/src/agentex/types/task_message.py +++ b/src/agentex/types/task_message.py @@ -1,25 +1,17 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union, Optional +from typing import Optional from datetime import datetime -from typing_extensions import Literal, Annotated, TypeAlias +from typing_extensions import Literal -from .._utils import PropertyInfo from .._models import BaseModel -from .data_content import DataContent -from .text_content import TextContent -from .tool_request_content import ToolRequestContent -from .tool_response_content import ToolResponseContent +from .task_message_content import TaskMessageContent -__all__ = ["TaskMessage", "Content"] - -Content: TypeAlias = Annotated[ - Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") -] +__all__ = ["TaskMessage"] class TaskMessage(BaseModel): - content: Content + content: TaskMessageContent """The content of the message. This content is not OpenAI compatible. These are messages that are meant to be diff --git a/src/agentex/types/task_message_content.py b/src/agentex/types/task_message_content.py new file mode 100644 index 00000000..126992b4 --- /dev/null +++ b/src/agentex/types/task_message_content.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Annotated, TypeAlias + +from .._utils import PropertyInfo +from .data_content import DataContent +from .text_content import TextContent +from .tool_request_content import ToolRequestContent +from .tool_response_content import ToolResponseContent + +__all__ = ["TaskMessageContent"] + +TaskMessageContent: TypeAlias = Annotated[ + Union[TextContent, DataContent, ToolRequestContent, ToolResponseContent], PropertyInfo(discriminator="type") +] diff --git a/src/agentex/types/task_message_content_param.py b/src/agentex/types/task_message_content_param.py new file mode 100644 index 00000000..6991c64e --- /dev/null +++ b/src/agentex/types/task_message_content_param.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import TypeAlias + +from .data_content_param import DataContentParam +from .text_content_param import TextContentParam +from .tool_request_content_param import ToolRequestContentParam +from .tool_response_content_param import ToolResponseContentParam + +__all__ = ["TaskMessageContentParam"] + +TaskMessageContentParam: TypeAlias = Union[ + TextContentParam, DataContentParam, ToolRequestContentParam, ToolResponseContentParam +] diff --git a/src/agentex/types/task_message_delta.py b/src/agentex/types/task_message_delta.py new file mode 100644 index 00000000..5a477e5a --- /dev/null +++ b/src/agentex/types/task_message_delta.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union +from typing_extensions import Annotated, TypeAlias + +from .._utils import PropertyInfo +from .data_delta import DataDelta +from .text_delta import TextDelta +from .tool_request_delta import ToolRequestDelta +from .tool_response_delta import ToolResponseDelta + +__all__ = ["TaskMessageDelta"] + +TaskMessageDelta: TypeAlias = Annotated[ + Union[TextDelta, DataDelta, ToolRequestDelta, ToolResponseDelta], PropertyInfo(discriminator="type") +] diff --git a/src/agentex/types/text_delta.py b/src/agentex/types/text_delta.py new file mode 100644 index 00000000..29a60cfd --- /dev/null +++ b/src/agentex/types/text_delta.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["TextDelta"] + + +class TextDelta(BaseModel): + text_delta: Optional[str] = None + + type: Optional[Literal["text"]] = None diff --git a/src/agentex/types/tool_request_delta.py b/src/agentex/types/tool_request_delta.py new file mode 100644 index 00000000..7877dfdd --- /dev/null +++ b/src/agentex/types/tool_request_delta.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["ToolRequestDelta"] + + +class ToolRequestDelta(BaseModel): + name: str + + tool_call_id: str + + arguments_delta: Optional[str] = None + + type: Optional[Literal["tool_request"]] = None diff --git a/src/agentex/types/tool_response_delta.py b/src/agentex/types/tool_response_delta.py new file mode 100644 index 00000000..383770db --- /dev/null +++ b/src/agentex/types/tool_response_delta.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["ToolResponseDelta"] + + +class ToolResponseDelta(BaseModel): + name: str + + tool_call_id: str + + content_delta: Optional[str] = None + + type: Optional[Literal["tool_response"]] = None diff --git a/tests/api_resources/test_agents.py b/tests/api_resources/test_agents.py index e415e011..7cb79375 100644 --- a/tests/api_resources/test_agents.py +++ b/tests/api_resources/test_agents.py @@ -13,7 +13,6 @@ Agent, AgentRpcResponse, AgentListResponse, - AgentRpcByNameResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -299,7 +298,7 @@ def test_method_rpc_by_name(self, client: Agentex) -> None: method="event/send", params={}, ) - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -314,7 +313,7 @@ def test_method_rpc_by_name_with_all_params(self, client: Agentex) -> None: id=0, jsonrpc="2.0", ) - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -328,7 +327,7 @@ def test_raw_response_rpc_by_name(self, client: Agentex) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = response.parse() - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -342,7 +341,7 @@ def test_streaming_response_rpc_by_name(self, client: Agentex) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = response.parse() - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) assert cast(Any, response.is_closed) is True @@ -639,7 +638,7 @@ async def test_method_rpc_by_name(self, async_client: AsyncAgentex) -> None: method="event/send", params={}, ) - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -654,7 +653,7 @@ async def test_method_rpc_by_name_with_all_params(self, async_client: AsyncAgent id=0, jsonrpc="2.0", ) - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -668,7 +667,7 @@ async def test_raw_response_rpc_by_name(self, async_client: AsyncAgentex) -> Non assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = await response.parse() - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) @pytest.mark.skip() @parametrize @@ -682,7 +681,7 @@ async def test_streaming_response_rpc_by_name(self, async_client: AsyncAgentex) assert response.http_request.headers.get("X-Stainless-Lang") == "python" agent = await response.parse() - assert_matches_type(AgentRpcByNameResponse, agent, path=["response"]) + assert_matches_type(AgentRpcResponse, agent, path=["response"]) assert cast(Any, response.is_closed) is True From fd451068df59dcc5d4bef8bf03649a0f3ff46836 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:04:24 +0000 Subject: [PATCH 7/7] release: 0.1.0-alpha.5 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 16 ++++++++++++++++ pyproject.toml | 2 +- src/agentex/_version.py | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b56c3d0b..e8285b71 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.4" + ".": "0.1.0-alpha.5" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f014202..14160687 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.1.0-alpha.5 (2025-07-23) + +Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/scaleapi/agentex-python/compare/v0.1.0-alpha.4...v0.1.0-alpha.5) + +### Features + +* **api:** deprecate name subresource ([14881c0](https://github.com/scaleapi/agentex-python/commit/14881c0ff2922e0a622975a0f5b314de99d7aabb)) +* **api:** manual updates ([d999a43](https://github.com/scaleapi/agentex-python/commit/d999a438c409f04b7e36b5df2d9b080d1d1b0e4a)) +* **api:** manual updates ([a885d8d](https://github.com/scaleapi/agentex-python/commit/a885d8dbabfe2cc2a556ef02e75e5502fd799c46)) + + +### Bug Fixes + +* **api:** build errors ([7bde6b7](https://github.com/scaleapi/agentex-python/commit/7bde6b727d6d16ebd6805ef843596fc3224445a6)) +* **parsing:** parse extra field types ([d40e6e0](https://github.com/scaleapi/agentex-python/commit/d40e6e0d6911be0bc9bfc419e02bd7c1d5ad5be4)) + ## 0.1.0-alpha.4 (2025-07-22) Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/scaleapi/agentex-python/compare/v0.1.0-alpha.3...v0.1.0-alpha.4) diff --git a/pyproject.toml b/pyproject.toml index 8e69b5ed..168acc46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "agentex" -version = "0.1.0-alpha.4" +version = "0.1.0-alpha.5" description = "The official Python library for the agentex API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/agentex/_version.py b/src/agentex/_version.py index 756d68b8..6c4f3e31 100644 --- a/src/agentex/_version.py +++ b/src/agentex/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "agentex" -__version__ = "0.1.0-alpha.4" # x-release-please-version +__version__ = "0.1.0-alpha.5" # x-release-please-version