| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,116 +1,15 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from enum import Enum | ||
| from typing import Any | ||
|
|
||
| from pydantic import Field, BaseModel | ||
|
|
||
| from agentex.types.task import Task | ||
| from agentex.types.agent import Agent | ||
| from agentex.types.event import Event | ||
| from agentex.types.task_message_content import TaskMessageContent | ||
|
|
||
|
|
||
| class RPCMethod(str, Enum): | ||
| """Available JSON-RPC methods for agent communication.""" | ||
|
|
||
| EVENT_SEND = "event/send" | ||
| MESSAGE_SEND = "message/send" | ||
| TASK_CANCEL = "task/cancel" | ||
| TASK_CREATE = "task/create" | ||
|
|
||
|
|
||
| class CreateTaskParams(BaseModel): | ||
| """Parameters for task/create method. | ||
|
|
||
| Attributes: | ||
| agent: The agent that the task was sent to. | ||
| task: The task to be created. | ||
| params: The parameters for the task as inputted by the user. | ||
| request: Additional request context including headers forwarded to this agent. | ||
| """ | ||
|
|
||
| agent: Agent = Field(..., description="The agent that the task was sent to") | ||
| task: Task = Field(..., description="The task to be created") | ||
| params: dict[str, Any] | None = Field( | ||
| None, | ||
| description="The parameters for the task as inputted by the user", | ||
| ) | ||
| request: dict[str, Any] | None = Field( | ||
| default=None, | ||
| description="Additional request context including headers forwarded to this agent", | ||
| ) | ||
|
|
||
|
|
||
| class SendMessageParams(BaseModel): | ||
| """Parameters for message/send method. | ||
|
|
||
| Attributes: | ||
| agent: The agent that the message was sent to. | ||
| task: The task that the message was sent to. | ||
| content: The message that was sent to the agent. | ||
| stream: Whether to stream the message back to the agentex server from the agent. | ||
| request: Additional request context including headers forwarded to this agent. | ||
| """ | ||
|
|
||
| agent: Agent = Field(..., description="The agent that the message was sent to") | ||
| task: Task = Field(..., description="The task that the message was sent to") | ||
| content: TaskMessageContent = Field( | ||
| ..., description="The message that was sent to the agent" | ||
| ) | ||
| stream: bool = Field( | ||
| False, | ||
| description="Whether to stream the message back to the agentex server from the agent", | ||
| ) | ||
| request: dict[str, Any] | None = Field( | ||
| default=None, | ||
| description="Additional request context including headers forwarded to this agent", | ||
| ) | ||
|
|
||
|
|
||
| class SendEventParams(BaseModel): | ||
| """Parameters for event/send method. | ||
|
|
||
| Attributes: | ||
| agent: The agent that the event was sent to. | ||
| task: The task that the message was sent to. | ||
| event: The event that was sent to the agent. | ||
| request: Additional request context including headers forwarded to this agent. | ||
| """ | ||
|
|
||
| agent: Agent = Field(..., description="The agent that the event was sent to") | ||
| task: Task = Field(..., description="The task that the message was sent to") | ||
| event: Event = Field(..., description="The event that was sent to the agent") | ||
| request: dict[str, Any] | None = Field( | ||
| default=None, | ||
| description="Additional request context including headers forwarded to this agent", | ||
| ) | ||
|
|
||
|
|
||
| class CancelTaskParams(BaseModel): | ||
| """Parameters for task/cancel method. | ||
|
|
||
| Attributes: | ||
| agent: The agent that the task was sent to. | ||
| task: The task that was cancelled. | ||
| request: Additional request context including headers forwarded to this agent. | ||
| """ | ||
|
|
||
| agent: Agent = Field(..., description="The agent that the task was sent to") | ||
| task: Task = Field(..., description="The task that was cancelled") | ||
| request: dict[str, Any] | None = Field( | ||
| default=None, | ||
| description="Additional request context including headers forwarded to this agent", | ||
| ) | ||
|
|
||
|
|
||
| RPC_SYNC_METHODS = [ | ||
| RPCMethod.MESSAGE_SEND, | ||
| ] | ||
|
|
||
| PARAMS_MODEL_BY_METHOD: dict[RPCMethod, type[BaseModel]] = { | ||
| RPCMethod.EVENT_SEND: SendEventParams, | ||
| RPCMethod.TASK_CANCEL: CancelTaskParams, | ||
| RPCMethod.MESSAGE_SEND: SendMessageParams, | ||
| RPCMethod.TASK_CREATE: CreateTaskParams, | ||
| } | ||
| """Back-compat shim. The canonical location is :mod:`agentex.protocol.acp`. | ||
|
|
||
| Kept here so existing ``from agentex.lib.types.acp import ...`` imports | ||
| continue to work. New code should import from the canonical path. | ||
| """ | ||
|
|
||
| from agentex.protocol.acp import ( # noqa: F401 | ||
| RPC_SYNC_METHODS, | ||
| PARAMS_MODEL_BY_METHOD, | ||
| RPCMethod, | ||
| SendEventParams, | ||
| CancelTaskParams, | ||
| CreateTaskParams, | ||
| SendMessageParams, | ||
| ) | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.