@@ -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
69134For a complete, production‑ready integration, see the
0 commit comments