Skip to content

Commit d8b4f8f

Browse files
committed
feat: add Go SDK and documentation
1 parent 51efde6 commit d8b4f8f

50 files changed

Lines changed: 5845 additions & 116 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ jobs:
8181
- name: Check Python SDK
8282
run: cargo check --manifest-path sdk/python/Cargo.toml
8383

84+
- uses: actions/setup-go@v6
85+
with:
86+
go-version: "1.23.x"
87+
cache-dependency-path: sdk/go/go.mod
88+
89+
- name: Check Go SDK
90+
run: |
91+
cargo build --package a3s-code-go-bridge --bin a3s-code-go-bridge
92+
A3S_CODE_GO_BRIDGE_TEST_BINARY="$PWD/../../target/debug/a3s-code-go-bridge" \
93+
go test -race ./...
94+
working-directory: sdk/go
95+
8496
windows-check:
8597
name: Windows check
8698
runs-on: windows-latest
@@ -103,3 +115,16 @@ jobs:
103115

104116
- name: Library tests
105117
run: cargo test --workspace --lib
118+
119+
- uses: actions/setup-go@v6
120+
with:
121+
go-version: "1.23.x"
122+
cache-dependency-path: sdk/go/go.mod
123+
124+
- name: Go SDK integration
125+
shell: pwsh
126+
working-directory: sdk/go
127+
run: |
128+
cargo build --package a3s-code-go-bridge --bin a3s-code-go-bridge
129+
$env:A3S_CODE_GO_BRIDGE_TEST_BINARY = (Resolve-Path "..\..\target\debug\a3s-code-go-bridge.exe").Path
130+
go test ./...

.github/workflows/publish-go.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Publish Go SDK
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: write
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build-bridge:
14+
name: Build Go bridge (${{ matrix.settings.target }})
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
settings:
19+
- host: ubuntu-latest
20+
target: x86_64-unknown-linux-gnu
21+
executable: a3s-code-go-bridge
22+
suffix: ""
23+
- host: macos-15-intel
24+
target: x86_64-apple-darwin
25+
executable: a3s-code-go-bridge
26+
suffix: ""
27+
- host: windows-latest
28+
target: x86_64-pc-windows-msvc
29+
executable: a3s-code-go-bridge.exe
30+
suffix: .exe
31+
runs-on: ${{ matrix.settings.host }}
32+
steps:
33+
- uses: actions/checkout@v6
34+
35+
- name: Setup workspace context
36+
shell: bash
37+
run: bash .github/setup-workspace.sh
38+
39+
- name: Install Rust
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
targets: ${{ matrix.settings.target }}
43+
44+
- uses: Swatinem/rust-cache@v2
45+
46+
- name: Install protobuf compiler
47+
uses: arduino/setup-protoc@v3
48+
49+
- name: Build bridge
50+
run: >-
51+
cargo build
52+
--release
53+
--package a3s-code-go-bridge
54+
--bin a3s-code-go-bridge
55+
--target ${{ matrix.settings.target }}
56+
57+
- name: Package bridge
58+
shell: bash
59+
run: |
60+
set -euo pipefail
61+
VERSION="${GITHUB_REF_NAME#v}"
62+
SOURCE="target/${{ matrix.settings.target }}/release/${{ matrix.settings.executable }}"
63+
ASSET="a3s-code-go-bridge-v${VERSION}-${{ matrix.settings.target }}${{ matrix.settings.suffix }}"
64+
mkdir -p dist
65+
cp "$SOURCE" "dist/$ASSET"
66+
(
67+
cd dist
68+
if command -v sha256sum >/dev/null 2>&1; then
69+
sha256sum "$ASSET" > "$ASSET.sha256"
70+
else
71+
shasum -a 256 "$ASSET" > "$ASSET.sha256"
72+
fi
73+
)
74+
75+
- uses: actions/upload-artifact@v4
76+
with:
77+
name: go-bridge-${{ matrix.settings.target }}
78+
path: dist/*
79+
if-no-files-found: error
80+
81+
publish:
82+
name: Publish Go module tag and bridge assets
83+
needs: [build-bridge]
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v6
87+
with:
88+
fetch-depth: 0
89+
90+
- uses: actions/download-artifact@v4
91+
with:
92+
pattern: go-bridge-*
93+
path: dist
94+
merge-multiple: true
95+
96+
- name: Create path-prefixed Go module tag
97+
env:
98+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
run: |
100+
set -euo pipefail
101+
VERSION="${GITHUB_REF_NAME#v}"
102+
MAJOR="${VERSION%%.*}"
103+
grep -qx "module github.com/A3S-Lab/Code/sdk/go/v${MAJOR}" sdk/go/go.mod
104+
GO_TAG="sdk/go/v${VERSION}"
105+
if git ls-remote --exit-code --tags origin "refs/tags/${GO_TAG}" >/dev/null 2>&1; then
106+
test "$(git rev-list -n 1 "refs/tags/$GO_TAG")" = "$GITHUB_SHA"
107+
else
108+
git config user.name "github-actions[bot]"
109+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
110+
git tag -a "$GO_TAG" "$GITHUB_SHA" -m "A3S Code Go SDK v${VERSION}"
111+
git push origin "$GO_TAG"
112+
fi
113+
114+
- name: Upload bridge assets
115+
env:
116+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
run: |
118+
set -euo pipefail
119+
cat dist/*.sha256 > dist/a3s-code-go-bridge-SHA256SUMS
120+
if ! gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
121+
gh release create "$GITHUB_REF_NAME" \
122+
--title "$GITHUB_REF_NAME" \
123+
--notes "Release assets are being published." || true
124+
fi
125+
for attempt in 1 2 3 4 5; do
126+
gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 && break
127+
sleep 2
128+
done
129+
gh release upload "$GITHUB_REF_NAME" \
130+
dist/a3s-code-go-bridge-* \
131+
--clobber

.github/workflows/release.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ jobs:
7171
- name: Check Python SDK
7272
run: cargo check --manifest-path sdk/python/Cargo.toml
7373

74+
- uses: actions/setup-go@v6
75+
with:
76+
go-version: "1.23.x"
77+
cache-dependency-path: sdk/go/go.mod
78+
79+
- name: Check Go SDK
80+
run: |
81+
cargo build --package a3s-code-go-bridge --bin a3s-code-go-bridge
82+
A3S_CODE_GO_BRIDGE_TEST_BINARY="$PWD/../../target/debug/a3s-code-go-bridge" \
83+
go test -race ./...
84+
working-directory: sdk/go
85+
7486
- name: Reclaim build space before tests
7587
run: |
7688
cargo clean --manifest-path sdk/node/Cargo.toml
@@ -177,12 +189,18 @@ jobs:
177189
uses: ./.github/workflows/publish-python-bootstrap.yml
178190
secrets: inherit
179191

192+
publish-go:
193+
name: Go SDK
194+
needs: [publish-crate, publish-python]
195+
uses: ./.github/workflows/publish-go.yml
196+
secrets: inherit
197+
180198
# ───────────────────────────────────────────────
181199
# Create GitHub Release
182200
# ───────────────────────────────────────────────
183201
github-release:
184202
name: GitHub Release
185-
needs: [publish-crate, publish-node, publish-python, publish-python-bootstrap]
203+
needs: [publish-crate, publish-node, publish-python, publish-python-bootstrap, publish-go]
186204
runs-on: ubuntu-latest
187205
steps:
188206
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added a pure-Go v6 SDK backed by a long-lived, capability-checked Rust bridge,
13+
covering sessions, lossless events, direct tools, run observation,
14+
verification, persistence, Skills, and MCP without requiring CGO.
15+
- Added version-matched x86-64 Linux, macOS, and Windows bridge release assets
16+
with SHA-256 checksums, Go protocol-alignment checks, CI integration, and
17+
bilingual website documentation.
18+
1019
## [6.5.2] - 2026-07-28
1120

1221
### Added

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "2"
33
members = [
44
"core",
5+
"sdk/go/bridge",
56
]
67
# Native SDK crates require special toolchains (Python/Node.js)
78
# Build them individually: cargo build -p a3s-code-node / a3s-code-py

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
**A3S Code** is an async Rust runtime for building governed coding agents. It
1515
keeps the agent loop, workspace tools, model adapters, policy decisions,
1616
versioned events, and durable evidence behind explicit contracts. Use it from
17-
Rust, Node.js, Python, or through the `a3s code` terminal application.
17+
Rust, Node.js, Python, Go, or through the `a3s code` terminal application.
1818

1919
<p align="center">
2020
<a href="#start-in-60-seconds">Start</a> ·
@@ -352,23 +352,29 @@ multiple agents or behaviors need one auditable shared model.
352352
| Rust | [`a3s-code-core`](https://crates.io/crates/a3s-code-core) | Complete runtime API and extension traits |
353353
| Node.js | [`@a3s-lab/code`](https://www.npmjs.com/package/@a3s-lab/code) | Native N-API bindings for async lifecycle, streams, tools, stores, orchestration, MCP, and state graph |
354354
| Python | [`a3s-code`](https://pypi.org/project/a3s-code/) | Native PyO3/bootstrap package with sync and async application APIs |
355+
| Go | [`github.com/A3S-Lab/Code/sdk/go/v6`](sdk/go/README.md) | Pure-Go client with a versioned local bridge for sessions, streams, tools, runs, verification, and MCP |
355356

356357
```bash
357358
# Node.js
358359
npm install @a3s-lab/code
359360

360361
# Python
361362
python -m pip install a3s-code
363+
364+
# Go
365+
go get github.com/A3S-Lab/Code/sdk/go/v6
362366
```
363367

364-
The native SDK crates enable the Core `s3` and `serve` features. See their
365-
[Node.js](sdk/node/README.md) and [Python](sdk/python/README.md) guides for
366-
surface-specific examples and intentional API differences.
368+
The native SDK crates enable the Core `s3` and `serve` features. The pure-Go
369+
package uses the matching `a3s-code-go-bridge` release asset and requires no
370+
CGO. See the [Node.js](sdk/node/README.md), [Python](sdk/python/README.md), and
371+
[Go](sdk/go/README.md) guides for surface-specific examples and intentional API
372+
differences.
367373

368374
## Architecture
369375

370376
```text
371-
Rust host / Node SDK / Python SDK / a3s code
377+
Rust host / Node SDK / Python SDK / Go SDK / a3s code
372378
373379
Agent
374380
@@ -392,6 +398,8 @@ hooks, security, MCP transports, and graph stores.
392398
Source is grouped by concern under `agent_api/`, `tools/`, `workspace/`,
393399
`context/`, `llm/`, `mcp/`, `orchestration/`, `store/`, and `state_graph/`.
394400
Node.js and Python bindings remain separate native crates over the same Core.
401+
The Go SDK reaches that Core through a long-lived, capability-checked local
402+
bridge process.
395403

396404
## Filesystem-first agents and releases
397405

@@ -442,6 +450,7 @@ the v1 schema.
442450
| [User Guide](manual/USER_GUIDE.md) · [Chinese](manual/USER_GUIDE_CN.md) | Installation, configuration, sessions, tools, and common workflows |
443451
| [Advanced Developer Manual](manual/ADVANCED_DEVELOPER_MANUAL.md) · [Chinese](manual/ADVANCED_DEVELOPER_MANUAL_CN.md) | Extension contracts, security, lifecycle, and production integration |
444452
| [SDK API Design](manual/SDK_API_DESIGN.md) | Cross-language API conventions and alignment |
453+
| [Go SDK](sdk/go/README.md) | Bridge installation, sessions, event streaming, direct tools, errors, and release compatibility |
445454
| [Code Intelligence Design](manual/CODE_INTELLIGENCE_DESIGN.md) | Language runtime, capability boundary, lifecycle, and verification |
446455
| [Agent Directory Tools](manual/AGENT_DIR_TOOLS_DESIGN.md) | Filesystem-first tool and agent definitions |
447456
| [Agent Release Contract](manual/AGENT_RELEASE_CONTRACT.md) | Admission schema, identity, compatibility, and security boundary |
@@ -457,6 +466,8 @@ cargo test -p a3s-code-core
457466
cargo test -p a3s-code-core --all-features
458467
cargo clippy -p a3s-code-core --all-targets --all-features -- -D warnings
459468
node scripts/sdk_api_alignment_check.mjs
469+
cargo test -p a3s-code-go-bridge
470+
go -C sdk/go test ./...
460471
```
461472

462473
Real-provider, browser-runtime, and S3 tests are ignored unless their external

release.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ from pathlib import Path
4242
4343
version = sys.argv[1]
4444
path = Path(sys.argv[2])
45-
data = json.loads(path.read_text())
45+
data = json.loads(path.read_text(encoding="utf-8"))
4646
4747
if data.get("name") == "@a3s-lab/code":
4848
data["version"] = version
@@ -56,7 +56,7 @@ for package in data.get("packages", {}).values():
5656
if name.startswith("@a3s-lab/code-"):
5757
optional[name] = version
5858
59-
path.write_text(json.dumps(data, indent=2) + "\n")
59+
path.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
6060
PY
6161
}
6262

@@ -90,6 +90,16 @@ sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" sdk/python/Cargo.toml
9090
sed -i.bak "s/a3s-code-core = { version = \"[^\"]*\"/a3s-code-core = { version = \"${VERSION}\"/" sdk/python/Cargo.toml
9191
rm -f sdk/python/Cargo.toml.bak
9292

93+
echo " Updating sdk/go/bridge/Cargo.toml..."
94+
sed -i.bak "s/^version = \".*\"/version = \"${VERSION}\"/" sdk/go/bridge/Cargo.toml
95+
sed -i.bak "s/a3s-code-core = { version = \"[^\"]*\"/a3s-code-core = { version = \"${VERSION}\"/" sdk/go/bridge/Cargo.toml
96+
rm -f sdk/go/bridge/Cargo.toml.bak
97+
98+
GO_MAJOR="${VERSION%%.*}"
99+
echo " Updating sdk/go/go.mod major path..."
100+
sed -i.bak "s#^module github.com/A3S-Lab/Code/sdk/go/v[0-9][0-9]*#module github.com/A3S-Lab/Code/sdk/go/v${GO_MAJOR}#" sdk/go/go.mod
101+
rm -f sdk/go/go.mod.bak
102+
93103
# Update Node SDK package.json
94104
echo " Updating sdk/node/package.json..."
95105
sed -i.bak "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" sdk/node/package.json
@@ -124,6 +134,12 @@ echo "----------------------------------------"
124134
cargo check --workspace
125135
cargo check --manifest-path sdk/node/Cargo.toml
126136
cargo check --manifest-path sdk/python/Cargo.toml
137+
cargo build --package a3s-code-go-bridge --bin a3s-code-go-bridge
138+
(
139+
cd sdk/go
140+
A3S_CODE_GO_BRIDGE_TEST_BINARY="$PWD/../../target/debug/a3s-code-go-bridge" \
141+
go test ./...
142+
)
127143
echo "✅ Cargo.lock updated"
128144
echo ""
129145

@@ -158,7 +174,7 @@ fi
158174
git add -A
159175
git commit -m "chore: bump version to ${VERSION}
160176
161-
- Update Rust, Node.js, and Python package versions
177+
- Update Rust, Node.js, Python, and Go package versions
162178
- Refresh release validation for A3S Code
163179
- Require real-provider ACL env integration before tagging
164180
"
@@ -169,6 +185,7 @@ git tag -a "v${VERSION}" -m "Release v${VERSION}
169185
## Tests
170186
- cargo test --workspace
171187
- cargo test --workspace --all-features --lib
188+
- go test ./...
172189
- git diff --check
173190
- scripts/check_release_versions.sh
174191
- REQUIRE_REAL_PROVIDER=1 scripts/release_preflight.sh
@@ -209,7 +226,8 @@ echo " 1. Run CI checks"
209226
echo " 2. Publish to crates.io"
210227
echo " 3. Publish Node SDK to npm"
211228
echo " 4. Build Python SDK wheels and attach to GitHub Release (PyPI no longer used)"
212-
echo " 5. Create GitHub Release"
229+
echo " 5. Publish the Go module tag and native bridge assets"
230+
echo " 6. Create GitHub Release"
213231
echo ""
214232
echo "Monitor progress at:"
215233
echo " https://github.com/A3S-Lab/Code/actions"

0 commit comments

Comments
 (0)