-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathgen_schema_v2.py
More file actions
232 lines (227 loc) · 9.87 KB
/
Copy pathgen_schema_v2.py
File metadata and controls
232 lines (227 loc) · 9.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
from __future__ import annotations
from ._schema_semantics import (
ROOT,
SchemaSemantics,
inline_model_ref,
variant_model_map,
)
MODEL_NAME_MAP = {
"#/$defs/AvailableCommandsUpdate": "AvailableCommandsUpdateBase",
"#/$defs/ConfigOptionUpdate": "ConfigOptionUpdateBase",
"#/$defs/SessionInfoUpdate": "SessionInfoUpdateBase",
"#/$defs/StringMultiSelectItems": "StringMultiSelectItemsBase",
"#/$defs/UsageUpdate": "UsageUpdateBase",
}
for variant_names in (
variant_model_map("AgentResponse", "anyOf", "object", ("AgentResponseMessage", "AgentErrorMessage")),
variant_model_map("ClientResponse", "anyOf", "object", ("ClientResponseMessage", "ClientErrorMessage")),
variant_model_map("AuthMethod", "anyOf", "allOf", ("TerminalAuthMethod", "AgentAuthMethod")),
variant_model_map("AvailableCommandInput", "anyOf", "allOf", ("TextAvailableCommandInput",)),
variant_model_map(
"ContentBlock",
"anyOf",
"allOf",
(
"TextContentBlock",
"ImageContentBlock",
"AudioContentBlock",
"ResourceContentBlock",
"EmbeddedResourceContentBlock",
),
),
variant_model_map(
"DiffChange",
"anyOf",
"allOf",
("AddDiffChange", "DeleteDiffChange", "ModifyDiffChange", "MoveDiffChange", "CopyDiffChange"),
),
variant_model_map("McpServer", "anyOf", "allOf", ("HttpMcpServer", "AcpMcpServer", "StdioMcpServer")),
variant_model_map("ReplayFrom", "anyOf", "allOf", ("ReplayFromStartVariant",)),
variant_model_map(
"RequestPermissionSubject",
"anyOf",
"allOf",
("ToolCallPermissionSubjectVariant", "CommandPermissionSubjectVariant"),
),
variant_model_map(
"SessionConfigOption",
"anyOf",
"allOf",
("SelectSessionConfigOption", "BooleanSessionConfigOption"),
),
variant_model_map(
"StateUpdate",
"anyOf",
"allOf",
("RunningState", "IdleState", "RequiresActionState"),
),
variant_model_map(
"ToolCallContent",
"anyOf",
"allOf",
("ContentToolCallContent", "DiffToolCallContent", "TerminalToolCallContent"),
),
variant_model_map(
"PlanUpdateContent",
"anyOf",
"allOf",
("PlanUpdateItems", "PlanUpdateFile", "PlanUpdateMarkdown"),
),
variant_model_map(
"NesSuggestion",
"anyOf",
"allOf",
(
"NesEditSuggestionVariant",
"NesJumpSuggestionVariant",
"NesRenameSuggestionVariant",
"NesSearchAndReplaceSuggestionVariant",
),
),
variant_model_map(
"ElicitationFormMode",
"anyOf",
"allOf",
("ElicitationFormSessionMode", "ElicitationFormRequestMode"),
),
variant_model_map(
"ElicitationUrlMode",
"anyOf",
"allOf",
("ElicitationUrlSessionMode", "ElicitationUrlRequestMode"),
),
variant_model_map(
"ElicitationPropertySchema",
"anyOf",
"allOf",
(
"ElicitationStringPropertySchema",
"ElicitationNumberPropertySchema",
"ElicitationIntegerPropertySchema",
"ElicitationBooleanPropertySchema",
"ElicitationMultiSelectPropertySchema",
),
),
variant_model_map("MultiSelectItems", "anyOf", "allOf", ("StringMultiSelectItems",)),
variant_model_map(
"SessionUpdate",
"anyOf",
"allOf",
(
"UserMessageChunk",
"UserMessageUpdate",
"AgentMessageChunk",
"AgentMessageUpdate",
"AgentThoughtChunk",
"AgentThoughtUpdate",
"SessionStateUpdate",
"ToolCallContentChunkUpdate",
"SessionToolCallUpdate",
"SessionTerminalUpdate",
"SessionTerminalOutputChunk",
"SessionPlanUpdate",
"SessionPlanRemovedUpdate",
"AvailableCommandsUpdate",
"ConfigOptionUpdate",
"SessionInfoUpdate",
"UsageUpdate",
"SessionCompactionUpdate",
"SessionCompactionSummaryChunk",
),
),
):
MODEL_NAME_MAP.update(variant_names)
MODEL_NAME_MAP.update({
inline_model_ref("AuthMethod", ("anyOf", 2), ("object", None)): "OtherAuthMethod",
inline_model_ref("AvailableCommandInput", ("anyOf", 1), ("object", None)): "OtherAvailableCommandInput",
inline_model_ref("ContentBlock", ("anyOf", 5), ("object", None)): "OtherContentBlock",
inline_model_ref("DiffChange", ("anyOf", 5), ("object", None)): "OtherDiffChange",
inline_model_ref("McpServer", ("anyOf", 3), ("object", None)): "OtherMcpServer",
inline_model_ref("ReplayFrom", ("anyOf", 1), ("object", None)): "OtherReplayFrom",
inline_model_ref("RequestPermissionOutcome", ("anyOf", 0), ("object", None)): ("CancelledPermissionOutcome"),
inline_model_ref("RequestPermissionOutcome", ("anyOf", 1), ("allOf", None)): ("SelectedPermissionOutcomeVariant"),
inline_model_ref("RequestPermissionOutcome", ("anyOf", 2), ("object", None)): "OtherPermissionOutcome",
inline_model_ref("RequestPermissionSubject", ("anyOf", 2), ("object", None)): "OtherPermissionSubject",
inline_model_ref("SessionConfigOption", ("anyOf", 2), ("object", None)): "OtherSessionConfigOption",
inline_model_ref("SetSessionConfigOptionRequest", ("anyOf", 0), ("object", None)): (
"SetSessionConfigOptionIdRequest"
),
inline_model_ref("SetSessionConfigOptionRequest", ("anyOf", 1), ("object", None)): (
"SetSessionConfigOptionBooleanRequest"
),
inline_model_ref("SetSessionConfigOptionRequest", ("anyOf", 2), ("object", None)): (
"SetSessionConfigOptionOtherRequest"
),
inline_model_ref("StateUpdate", ("anyOf", 3), ("object", None)): "OtherState",
inline_model_ref("ToolCallContent", ("anyOf", 3), ("object", None)): "OtherToolCallContent",
inline_model_ref("PlanUpdateContent", ("anyOf", 3), ("object", None)): "OtherPlanUpdateContent",
inline_model_ref("NesSuggestion", ("anyOf", 4), ("object", None)): "OtherNesSuggestion",
inline_model_ref("ElicitationPropertySchema", ("anyOf", 5), ("object", None)): ("ElicitationOtherPropertySchema"),
inline_model_ref("MultiSelectItems", ("anyOf", 1), ("object", None)): "OtherMultiSelectItems",
inline_model_ref("SessionUpdate", ("anyOf", 19), ("object", None)): "OtherSessionUpdate",
inline_model_ref("SessionUpdate", ("anyOf", 6), ("allOf", 0), ("allOf", None)): ("RunningSessionStateUpdateBase"),
inline_model_ref("SessionUpdate", ("anyOf", 6), ("allOf", 1), ("allOf", None)): ("IdleSessionStateUpdateBase"),
inline_model_ref("SessionUpdate", ("anyOf", 6), ("allOf", 2), ("allOf", None)): (
"RequiresActionSessionStateUpdateBase"
),
inline_model_ref("SessionUpdate", ("anyOf", 6), ("allOf", 3), ("object", None)): ("OtherSessionStateUpdateBase"),
inline_model_ref("SessionUpdate", ("anyOf", 6), ("allOf", None), ("allOf", None)): ("SessionStateUpdateBase"),
})
for index, name in enumerate((
"RunningSessionStateUpdate",
"IdleSessionStateUpdate",
"RequiresActionSessionStateUpdate",
"OtherSessionStateUpdate",
)):
MODEL_NAME_MAP[inline_model_ref("SessionUpdate", ("anyOf", 6), ("allOf", None), (f"union_model-{index}", None))] = (
name
)
MODEL_NAME_MAP.update({
inline_model_ref("CreateElicitationResponse", ("anyOf", 0), ("allOf", None)): "AcceptElicitationResponse",
inline_model_ref("CreateElicitationResponse", ("anyOf", 1), ("object", None)): "DeclineElicitationResponse",
inline_model_ref("CreateElicitationResponse", ("anyOf", 2), ("object", None)): "CancelElicitationResponse",
inline_model_ref("CreateElicitationResponse", ("anyOf", 3), ("object", None)): "OtherElicitationResponse",
inline_model_ref("CreateElicitationRequest", ("anyOf", 0), ("allOf", None), ("allOf", None)): (
"CreateFormElicitationRequestBase"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 0), ("allOf", 0), ("allOf", None)): (
"CreateFormSessionElicitationRequestBase"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 0), ("allOf", 1), ("allOf", None)): (
"CreateFormRequestElicitationRequestBase"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 0), ("allOf", None), ("union_model-0", None)): (
"CreateFormSessionElicitationRequest"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 0), ("allOf", None), ("union_model-1", None)): (
"CreateFormRequestElicitationRequest"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 1), ("allOf", None), ("allOf", None)): (
"CreateUrlElicitationRequestBase"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 1), ("allOf", 0), ("allOf", None)): (
"CreateUrlSessionElicitationRequestBase"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 1), ("allOf", 1), ("allOf", None)): (
"CreateUrlRequestElicitationRequestBase"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 1), ("allOf", None), ("union_model-0", None)): (
"CreateUrlSessionElicitationRequest"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 1), ("allOf", None), ("union_model-1", None)): (
"CreateUrlRequestElicitationRequest"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 2), ("anyOf", 0), ("allOf", None)): (
"CreateOtherSessionElicitationRequest"
),
inline_model_ref("CreateElicitationRequest", ("anyOf", 2), ("anyOf", 1), ("allOf", None)): (
"CreateOtherRequestElicitationRequest"
),
})
SEMANTICS = SchemaSemantics(
schema_json=ROOT / "schema" / "v2" / "schema.json",
version_file=ROOT / "schema" / "v2" / "VERSION",
schema_out=ROOT / "src" / "acp" / "experimental" / "v2" / "schema.py",
base_class="acp.experimental.v2._schema_base.BaseModel",
model_name_map=MODEL_NAME_MAP,
)