Skip to content

Commit 9a930c6

Browse files
committed
fix: overrides in gen_schema.py
Signed-off-by: Frost Ming <me@frostming.com>
1 parent 370988e commit 9a930c6

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

scripts/gen_schema.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
("PermissionOption", "kind", "PermissionOptionKind", False),
8686
("PlanEntry", "priority", "PlanEntryPriority", False),
8787
("PlanEntry", "status", "PlanEntryStatus", False),
88-
("PromptResponse", "stopReason", "StopReason", False),
88+
("PromptResponse", "stop_reason", "StopReason", False),
8989
("ToolCallProgress", "kind", "ToolKind", True),
9090
("ToolCallProgress", "status", "ToolCallStatus", True),
9191
("ToolCallStart", "kind", "ToolKind", True),
@@ -95,23 +95,23 @@
9595
)
9696

9797
DEFAULT_VALUE_OVERRIDES: tuple[tuple[str, str, str], ...] = (
98-
("AgentCapabilities", "mcpCapabilities", "McpCapabilities(http=False, sse=False)"),
98+
("AgentCapabilities", "mcp_capabilities", "McpCapabilities()"),
9999
(
100100
"AgentCapabilities",
101-
"promptCapabilities",
102-
"PromptCapabilities(audio=False, embeddedContext=False, image=False)",
101+
"prompt_capabilities",
102+
"PromptCapabilities()",
103103
),
104-
("ClientCapabilities", "fs", "FileSystemCapability(readTextFile=False, writeTextFile=False)"),
104+
("ClientCapabilities", "fs", "FileSystemCapability()"),
105105
("ClientCapabilities", "terminal", "False"),
106106
(
107107
"InitializeRequest",
108-
"clientCapabilities",
109-
"ClientCapabilities(fs=FileSystemCapability(readTextFile=False, writeTextFile=False), terminal=False)",
108+
"client_capabilities",
109+
"ClientCapabilities()",
110110
),
111111
(
112112
"InitializeResponse",
113-
"agentCapabilities",
114-
"AgentCapabilities(loadSession=False, mcpCapabilities=McpCapabilities(http=False, sse=False), promptCapabilities=PromptCapabilities(audio=False, embeddedContext=False, image=False))",
113+
"agent_capabilities",
114+
"AgentCapabilities()",
115115
),
116116
)
117117

scripts/gen_signature.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _to_param_def(self, name: str, field: FieldInfo) -> tuple[ast.arg, ast.expr
8686
ann = field.annotation
8787
if field.default is PydanticUndefined:
8888
default = None
89-
elif isinstance(field.default, dict):
89+
elif isinstance(field.default, dict | BaseModel):
9090
default = ast.Constant(None)
9191
else:
9292
default = ast.Constant(value=field.default)
@@ -128,6 +128,9 @@ def _format_annotation(self, annotation: t.Any) -> ast.expr:
128128

129129

130130
def gen_signature(source_dir: Path) -> None:
131+
import importlib
132+
133+
importlib.reload(schema) # Ensure schema is up to date
131134
for source_file in source_dir.rglob("*.py"):
132135
transformer = NodeTransformer()
133136
transformer.transform(source_file)

src/acp/schema.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,15 @@ class AgentCapabilities(BaseModel):
623623
alias="mcpCapabilities",
624624
description="MCP capabilities supported by the agent.",
625625
),
626-
] = {"http": False, "sse": False}
626+
] = McpCapabilities()
627627
# Prompt capabilities supported by the agent.
628628
prompt_capabilities: Annotated[
629629
Optional[PromptCapabilities],
630630
Field(
631631
alias="promptCapabilities",
632632
description="Prompt capabilities supported by the agent.",
633633
),
634-
] = {"audio": False, "embeddedContext": False, "image": False}
634+
] = PromptCapabilities()
635635

636636

637637
class AgentErrorMessage(BaseModel):
@@ -731,7 +731,7 @@ class ClientCapabilities(BaseModel):
731731
Field(
732732
description="File system capabilities supported by the client.\nDetermines which file operations the agent can request."
733733
),
734-
] = FileSystemCapability(readTextFile=False, writeTextFile=False)
734+
] = FileSystemCapability()
735735
# Whether the Client support all `terminal/*` methods.
736736
terminal: Annotated[
737737
Optional[bool],
@@ -870,7 +870,7 @@ class InitializeRequest(BaseModel):
870870
alias="clientCapabilities",
871871
description="Capabilities supported by the client.",
872872
),
873-
] = {"fs": {"readTextFile": False, "writeTextFile": False}, "terminal": False}
873+
] = ClientCapabilities()
874874
# Information about the Client name and version sent to the Agent.
875875
#
876876
# Note: in future versions of the protocol, this will be required.
@@ -906,15 +906,7 @@ class InitializeResponse(BaseModel):
906906
alias="agentCapabilities",
907907
description="Capabilities supported by the agent.",
908908
),
909-
] = {
910-
"loadSession": False,
911-
"mcpCapabilities": {"http": False, "sse": False},
912-
"promptCapabilities": {
913-
"audio": False,
914-
"embeddedContext": False,
915-
"image": False,
916-
},
917-
}
909+
] = AgentCapabilities()
918910
# Information about the Agent name and version sent to the Client.
919911
#
920912
# Note: in future versions of the protocol, this will be required.
@@ -1031,7 +1023,7 @@ class PromptResponse(BaseModel):
10311023
] = None
10321024
# Indicates why the agent stopped processing the turn.
10331025
stop_reason: Annotated[
1034-
str,
1026+
StopReason,
10351027
Field(
10361028
alias="stopReason",
10371029
description="Indicates why the agent stopped processing the turn.",

0 commit comments

Comments
 (0)