-
Notifications
You must be signed in to change notification settings - Fork 422
Expand file tree
/
Copy pathgen_proto.sh
More file actions
executable file
·36 lines (27 loc) · 1.53 KB
/
gen_proto.sh
File metadata and controls
executable file
·36 lines (27 loc) · 1.53 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
#!/bin/bash
set -e
# Install proto2pydantic plugin for Pydantic model generation
echo "Installing protoc-gen-proto2pydantic@v0.5.2..."
go install github.com/protocgen/proto2pydantic@v0.5.2
# Run buf generate to regenerate protobuf code and OpenAPI spec
npx --yes @bufbuild/buf generate
# Format generated Pydantic models (line-length wrapping for long Field() descriptions)
echo "Formatting generated Pydantic models..."
ruff format src/a2a/types/a2a_pydantic.py
# The OpenAPI generator produces a file named like 'a2a.swagger.json' or similar.
# We need it to be 'a2a.json' for the A2A SDK.
# Find the generated json file in the output directory
generated_json=$(find src/a2a/types -name "*.swagger.json" -print -quit)
if [ -n "$generated_json" ]; then
echo "Renaming $generated_json to src/a2a/types/a2a.json"
mv "$generated_json" src/a2a/types/a2a.json
else
echo "Warning: No Swagger JSON generated."
fi
# Fix imports in generated grpc file
echo "Fixing imports in src/a2a/types/a2a_pb2_grpc.py"
sed 's/import a2a_pb2 as a2a__pb2/from . import a2a_pb2 as a2a__pb2/g' src/a2a/types/a2a_pb2_grpc.py > src/a2a/types/a2a_pb2_grpc.py.tmp && mv src/a2a/types/a2a_pb2_grpc.py.tmp src/a2a/types/a2a_pb2_grpc.py
# Download legacy v0.3 compatibility protobuf code
echo "Downloading legacy v0.3 proto file..."
# Commit hash was selected as a2a.proto version from 0.3 branch with latests fixes.
curl -o src/a2a/compat/v0_3/a2a_v0_3.proto https://raw.githubusercontent.com/a2aproject/A2A/b3b266d127dde3d1000ec103b252d1de81289e83/specification/grpc/a2a.proto