Skip to content

Commit 46d2f23

Browse files
author
e.s.prilutskiy
committed
feat: Merge remote-tracking branch 'upstream/main' into fix/out-of-order-messages
2 parents afd0125 + 62137e8 commit 46d2f23

File tree

26 files changed

+3596
-3015
lines changed

26 files changed

+3596
-3015
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
actions: write
2626
steps:
2727
- name: Checkout
28-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2929
with:
3030
fetch-depth: 0
3131
fetch-tags: true
@@ -35,7 +35,7 @@ jobs:
3535
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
3636

3737
- name: Cache Nix store
38-
uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3
38+
uses: nix-community/cache-nix-action@106bba72ed8e29c8357661199511ef07790175e9 # v7.0.1
3939
with:
4040
primary-key: nix-acp-go-sdk-${{ runner.os }}-${{ hashFiles('**/*.nix', 'flake.lock') }}
4141
restore-prefixes-first-match: nix-acp-go-sdk-${{ runner.os }}-

README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Learn more about the protocol itself at <https://agentclientprotocol.com>.
1414
<!-- `$ printf 'go get github.com/coder/acp-go-sdk@v%s\n' "$(cat schema/version)"` as bash -->
1515

1616
```bash
17-
go get github.com/coder/acp-go-sdk@v0.6.3
17+
go get github.com/coder/acp-go-sdk@v0.10.7
1818
```
1919

2020
## Get Started
@@ -64,6 +64,71 @@ Helper constructors are provided to reduce boilerplate when working with union t
6464
- Tool content: `acp.ToolContent`, `acp.ToolDiffContent`, `acp.ToolTerminalRef`.
6565
- Utility: `acp.Ptr[T]` for pointer fields in request/update structs.
6666

67+
### Extension methods
68+
69+
ACP supports **extension methods** for custom JSON-RPC methods whose names start with `_`.
70+
Use them to add functionality without conflicting with future ACP versions.
71+
72+
#### Handling inbound extension methods
73+
74+
Implement `acp.ExtensionMethodHandler` on your Agent or Client. Your handler will be
75+
invoked for any incoming method starting with `_`.
76+
77+
```go
78+
// HandleExtensionMethod handles ACP extension methods (names starting with "_").
79+
func (a MyAgent) HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error) {
80+
switch method {
81+
case "_example.com/hello":
82+
var p struct {
83+
Name string `json:"name"`
84+
}
85+
if err := json.Unmarshal(params, &p); err != nil {
86+
return nil, err
87+
}
88+
return map[string]any{"greeting": "hello " + p.Name}, nil
89+
default:
90+
return nil, acp.NewMethodNotFound(method)
91+
}
92+
}
93+
```
94+
95+
> Note: Per the ACP spec, unknown extension notifications should be ignored.
96+
> This SDK suppresses noisy logs for unhandled extension notifications that return
97+
> “Method not found”.
98+
99+
#### Calling extension methods
100+
101+
From either side, use `CallExtension` / `NotifyExtension` on the connection.
102+
103+
```go
104+
raw, err := conn.CallExtension(ctx, "_example.com/hello", map[string]any{"name": "world"})
105+
if err != nil {
106+
return err
107+
}
108+
109+
var resp struct {
110+
Greeting string `json:"greeting"`
111+
}
112+
if err := json.Unmarshal(raw, &resp); err != nil {
113+
return err
114+
}
115+
116+
if err := conn.NotifyExtension(ctx, "_example.com/progress", map[string]any{"pct": 50}); err != nil {
117+
return err
118+
}
119+
```
120+
121+
#### Advertising extension support via `_meta`
122+
123+
ACP uses the `_meta` field inside capability objects as the negotiation/advertising
124+
surface for extensions.
125+
126+
- Client -> Agent: `InitializeRequest.ClientCapabilities.Meta`
127+
- Agent -> Client: `InitializeResponse.AgentCapabilities.Meta`
128+
129+
Keys `traceparent`, `tracestate`, and `baggage` are reserved in `_meta` for W3C trace
130+
context/OpenTelemetry compatibility.
131+
67132
### Study a Production Implementation
68133

69134
For a complete, production‑ready integration, see the

0 commit comments

Comments
 (0)