|
| 1 | +from typing import ClassVar |
| 2 | + |
| 3 | +from acp._schema_base import BaseModel as _BaseModel |
| 4 | + |
| 5 | + |
| 6 | +class BaseModel(_BaseModel): |
| 7 | + """Runtime behavior shared by generated ACP v2 schema models.""" |
| 8 | + |
| 9 | + # datamodel-code-generator does not emit the `not` constraints used by ACP's |
| 10 | + # open unions, so catch-all variants must reject tags owned by known variants. |
| 11 | + _reserved_tags: ClassVar[dict[str, tuple[str, frozenset[str]]]] = { |
| 12 | + "OtherAuthMethod": ("type", frozenset({"agent", "terminal"})), |
| 13 | + "OtherAvailableCommandInput": ("type", frozenset({"text"})), |
| 14 | + "OtherContentBlock": ("type", frozenset({"audio", "image", "resource", "resource_link", "text"})), |
| 15 | + "OtherDiffChange": ("operation", frozenset({"add", "copy", "delete", "modify", "move"})), |
| 16 | + "OtherMcpServer": ("type", frozenset({"acp", "http", "stdio"})), |
| 17 | + "OtherNesSuggestion": ("kind", frozenset({"edit", "jump", "rename", "searchAndReplace"})), |
| 18 | + "OtherPermissionOutcome": ("outcome", frozenset({"cancelled", "selected"})), |
| 19 | + "OtherPermissionSubject": ("type", frozenset({"command", "tool_call"})), |
| 20 | + "OtherPlanUpdateContent": ("type", frozenset({"file", "items", "markdown"})), |
| 21 | + "OtherReplayFrom": ("type", frozenset({"start"})), |
| 22 | + "OtherSessionConfigOption": ("type", frozenset({"boolean", "select"})), |
| 23 | + "OtherSessionStateUpdate": ("state", frozenset({"idle", "requires_action", "running"})), |
| 24 | + "OtherSessionUpdate": ( |
| 25 | + "sessionUpdate", |
| 26 | + frozenset({ |
| 27 | + "agent_message", |
| 28 | + "agent_message_chunk", |
| 29 | + "agent_thought", |
| 30 | + "agent_thought_chunk", |
| 31 | + "available_commands_update", |
| 32 | + "compaction_summary_chunk", |
| 33 | + "compaction_update", |
| 34 | + "config_option_update", |
| 35 | + "plan_removed", |
| 36 | + "plan_update", |
| 37 | + "session_info_update", |
| 38 | + "state_update", |
| 39 | + "terminal_output_chunk", |
| 40 | + "terminal_update", |
| 41 | + "tool_call_content_chunk", |
| 42 | + "tool_call_update", |
| 43 | + "usage_update", |
| 44 | + "user_message", |
| 45 | + "user_message_chunk", |
| 46 | + }), |
| 47 | + ), |
| 48 | + "OtherState": ("state", frozenset({"idle", "requires_action", "running"})), |
| 49 | + "OtherToolCallContent": ("type", frozenset({"content", "diff", "terminal"})), |
| 50 | + "SetSessionConfigOptionOtherRequest": ("type", frozenset({"boolean", "id"})), |
| 51 | + "CreateOtherSessionElicitationRequest": ("mode", frozenset({"form", "url"})), |
| 52 | + "CreateOtherRequestElicitationRequest": ("mode", frozenset({"form", "url"})), |
| 53 | + "OtherElicitationResponse": ("action", frozenset({"accept", "cancel", "decline"})), |
| 54 | + "ElicitationOtherPropertySchema": ( |
| 55 | + "type", |
| 56 | + frozenset({"array", "boolean", "integer", "number", "string"}), |
| 57 | + ), |
| 58 | + "OtherMultiSelectItems": ("type", frozenset({"string"})), |
| 59 | + } |
0 commit comments