diff --git a/agent_sdks/python/a2ui_agent/CHANGELOG.md b/agent_sdks/python/a2ui_agent/CHANGELOG.md index 3f227bdc9f..67814d2cd6 100644 --- a/agent_sdks/python/a2ui_agent/CHANGELOG.md +++ b/agent_sdks/python/a2ui_agent/CHANGELOG.md @@ -1,5 +1,8 @@ ## Unreleased +- Invoke ANTLR from the grammar's directory when regenerating the Express parser, so generated file headers no longer embed the absolute path of the machine that built them. +- Stop rewriting the non-package fallback import in the generated Express visitor to a relative import, which pointed at a module name the rename step had already replaced. A from-source build now leaves the working tree clean. + ## 0.5.0 - Rename inference format `Transport` / `transport` terminology to `Direct JSON` / `direct_json` (`DirectJsonFormat`, `DirectJsonParser`, `DirectJsonStreamParser`). Deprecate `a2ui.inference_formats.transport` module alias. diff --git a/agent_sdks/python/a2ui_agent/README.md b/agent_sdks/python/a2ui_agent/README.md index e18deb7db0..708bf3bf1a 100644 --- a/agent_sdks/python/a2ui_agent/README.md +++ b/agent_sdks/python/a2ui_agent/README.md @@ -59,6 +59,10 @@ protocol. ## Building the SDK +Building from source regenerates the Express parser from +`specification/inference_formats/express/Express.g4`. That step runs ANTLR, which +requires a Java runtime (JRE 11 or newer) on the `PATH`. + To build the SDK, run the following command from the `agent_sdks/python/a2ui_agent` directory: diff --git a/agent_sdks/python/a2ui_agent/pack_specs_hook.py b/agent_sdks/python/a2ui_agent/pack_specs_hook.py index 57673dfbc9..09730e0c7c 100644 --- a/agent_sdks/python/a2ui_agent/pack_specs_hook.py +++ b/agent_sdks/python/a2ui_agent/pack_specs_hook.py @@ -132,15 +132,15 @@ def initialize(self, version, build_data): "-visitor", "-no-listener", "-o", - "generated", - g4_path, + os.path.abspath(generated_dir), + os.path.basename(g4_path), ] env = os.environ.copy() env["ANTLR4_TOOLS_ANTLR_VERSION"] = "4.13.2" res = subprocess.run( cmd, - cwd=express_dir, + cwd=os.path.dirname(g4_path), env=env, capture_output=True, text=True, @@ -190,7 +190,7 @@ def initialize(self, version, build_data): "from .ExpressParser import", "from .express_parser import" ) content = content.replace( - "from ExpressParser import", "from .express_parser import" + "from ExpressParser import", "from express_parser import" ) with open(visitor_path, "w", encoding="utf-8") as f: f.write(content) diff --git a/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_lexer.py b/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_lexer.py index 2696a12b7e..f35fe0070b 100644 --- a/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_lexer.py +++ b/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_lexer.py @@ -1,4 +1,4 @@ -# Generated from /usr/local/google/home/gspencer/code/a2ui/kotlin_express/specification/inference_formats/express/Express.g4 by ANTLR 4.13.2 +# Generated from Express.g4 by ANTLR 4.13.2 from antlr4 import * from io import StringIO import sys diff --git a/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_parser.py b/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_parser.py index cb929c782c..827a9d28b7 100644 --- a/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_parser.py +++ b/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_parser.py @@ -1,4 +1,4 @@ -# Generated from /usr/local/google/home/gspencer/code/a2ui/kotlin_express/specification/inference_formats/express/Express.g4 by ANTLR 4.13.2 +# Generated from Express.g4 by ANTLR 4.13.2 # encoding: utf-8 from antlr4 import * from io import StringIO diff --git a/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_visitor.py b/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_visitor.py index 9bd827cec7..6f29f2da66 100644 --- a/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_visitor.py +++ b/agent_sdks/python/a2ui_agent/src/a2ui/inference_formats/experimental/express/generated/express_visitor.py @@ -1,11 +1,10 @@ -# Generated from /usr/local/google/home/gspencer/code/a2ui/kotlin_express/specification/inference_formats/express/Express.g4 by ANTLR 4.13.2 +# Generated from Express.g4 by ANTLR 4.13.2 from antlr4 import * if "." in __name__: from .express_parser import ExpressParser else: from express_parser import ExpressParser - # This class defines a complete generic visitor for a parse tree produced by ExpressParser. class ExpressVisitor(ParseTreeVisitor):