|
27 | 27 | ) |
28 | 28 |
|
29 | 29 | STDIO_TYPE_LITERAL = 'Literal["2#-datamodel-code-generator-#-object-#-special-#"]' |
30 | | -STDIO_TYPE_PATTERN = re.compile( |
31 | | - r"^ type:\s*Literal\[['\"]McpServerStdio['\"]\]" |
32 | | - r"(?:\s*=\s*['\"][^'\"]+['\"])?\s*$", |
33 | | - re.MULTILINE, |
34 | | -) |
35 | | -MODELS_TO_REMOVE = ["Model1", "Model2", "Model3", "Model4", "Model5", "Model6", "Model"] |
| 30 | +MODELS_TO_REMOVE = [ |
| 31 | + "AgentClientProtocol", |
| 32 | + "AgentClientProtocol1", |
| 33 | + "AgentClientProtocol2", |
| 34 | + "AgentClientProtocol3", |
| 35 | + "AgentClientProtocol4", |
| 36 | + "AgentClientProtocol5", |
| 37 | + "AgentClientProtocol6", |
| 38 | +] |
36 | 39 |
|
37 | 40 | # Map of numbered classes produced by datamodel-code-generator to descriptive names. |
38 | 41 | # Keep this in sync with the Rust/TypeScript SDK nomenclature. |
|
58 | 61 | "SessionUpdate6": "AgentPlanUpdate", |
59 | 62 | "SessionUpdate7": "AvailableCommandsUpdate", |
60 | 63 | "SessionUpdate8": "CurrentModeUpdate", |
| 64 | + "SessionUpdate9": "SessionInfoUpdate", |
61 | 65 | "ToolCallContent1": "ContentToolCallContent", |
62 | 66 | "ToolCallContent2": "FileEditToolCallContent", |
63 | 67 | "ToolCallContent3": "TerminalToolCallContent", |
@@ -175,7 +179,6 @@ def postprocess_generated_schema(output_path: Path) -> list[str]: |
175 | 179 | processing_steps: tuple[_ProcessingStep, ...] = ( |
176 | 180 | _ProcessingStep("apply field overrides", _apply_field_overrides), |
177 | 181 | _ProcessingStep("apply default overrides", _apply_default_overrides), |
178 | | - _ProcessingStep("normalize stdio literal", _normalize_stdio_model), |
179 | 182 | _ProcessingStep("attach description comments", _add_description_comments), |
180 | 183 | _ProcessingStep("ensure custom BaseModel", _ensure_custom_base_model), |
181 | 184 | ) |
@@ -242,6 +245,8 @@ def _remove_backcompat_block(content: str) -> str: |
242 | 245 | def _rename_numbered_models(content: str) -> tuple[str, list[str]]: |
243 | 246 | renamed = content |
244 | 247 | for old, new in sorted(RENAME_MAP.items(), key=lambda item: len(item[0]), reverse=True): |
| 248 | + if re.search(rf"\b{re.escape(new)}\b", renamed) is not None: |
| 249 | + renamed = re.sub(rf"\b{re.escape(new)}\b", f"_{new}", renamed) |
245 | 250 | pattern = re.compile(rf"\b{re.escape(old)}\b") |
246 | 251 | renamed = pattern.sub(new, renamed) |
247 | 252 |
|
@@ -417,20 +422,6 @@ def replace_block( |
417 | 422 | return content |
418 | 423 |
|
419 | 424 |
|
420 | | -def _normalize_stdio_model(content: str) -> str: |
421 | | - replacement_line = ' type: Literal["stdio"] = "stdio"' |
422 | | - new_content, count = STDIO_TYPE_PATTERN.subn(replacement_line, content) |
423 | | - if count == 0: |
424 | | - print("Warning: stdio type placeholder not found; no replacements made.", file=sys.stderr) |
425 | | - return content |
426 | | - if count > 1: |
427 | | - print( |
428 | | - "Warning: multiple stdio type placeholders detected; manual review required.", |
429 | | - file=sys.stderr, |
430 | | - ) |
431 | | - return new_content |
432 | | - |
433 | | - |
434 | 425 | def _add_description_comments(content: str) -> str: |
435 | 426 | lines = content.splitlines() |
436 | 427 | new_lines: list[str] = [] |
|
0 commit comments