Repository navigation
Commit b6e6b59
committed
Headers on the remote client transports: webSocketCustomizer and requestCustomizer
The JDK's HttpClient has no default headers, so neither
WebSocketAcpClientTransport nor StreamableHttpAcpClientTransport could
send an Authorization header, an API key or any other header an agent's
endpoint requires; an application had to write its own transport.
goose serve, for one, refuses every connection without X-Secret-Key.
- WebSocketAcpClientTransport.webSocketCustomizer(Consumer<WebSocket.Builder>)
runs on every connect attempt, after the connect timeout is set. A
customizer that throws, or sets a header the JDK reserves for the
handshake, fails that connect, which may be tried again.
- StreamableHttpAcpClientTransport.requestCustomizer(Consumer<HttpRequest.Builder>)
runs for every request the transport sends: the cleartext probe,
initialize, each POST, every SSE stream opened or reopened, and the
closing DELETE, so a token that expires is read again for each. It
runs on a builder of its own and the result is copied with the
protocol headers (Content-Type, Accept, Acp-Connection-Id,
Acp-Session-Id) filtered out and the endpoint's URI restored, because
a builder can replace a header but not remove one: the bootstrap
initialize carries no connection id of the transport's own to replace
a customizer's with.
- Each HTTP request is now built inside its Mono, so a customizer that
throws fails that Mono rather than escaping sendMessage, and a failed
initialize may be sent again. initialize is built after the cleartext
probe instead of being re-stamped with the settled version, so
StreamableHttpRequests.pinned(HttpRequest) is gone.
Verified against goose serve 1.52.0: without the header the WebSocket
handshake is refused and initialize over HTTP answers 401; with
X-Secret-Key from either customizer, initialize and session/new succeed.1 parent 0d3e20c commit b6e6b59
6 files changed
Lines changed: 363 additions & 33 deletions
File tree
- acp-core/src
- main/java/com/agentclientprotocol/sdk/client/transport
- test/java/com/agentclientprotocol/sdk/client/transport
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
65 | 74 | | |
66 | 75 | | |
67 | 76 | | |
| |||
201 | 210 | | |
202 | 211 | | |
203 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
204 | 238 | | |
205 | 239 | | |
206 | 240 | | |
| |||
249 | 283 | | |
250 | 284 | | |
251 | 285 | | |
252 | | - | |
| 286 | + | |
253 | 287 | | |
254 | | - | |
| 288 | + | |
255 | 289 | | |
256 | 290 | | |
257 | 291 | | |
258 | 292 | | |
259 | 293 | | |
260 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
261 | 298 | | |
262 | | - | |
| 299 | + | |
| 300 | + | |
263 | 301 | | |
264 | 302 | | |
265 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
34 | | - | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
75 | 85 | | |
76 | 86 | | |
77 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
| |||
106 | 119 | | |
107 | 120 | | |
108 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
109 | 126 | | |
110 | 127 | | |
111 | 128 | | |
| |||
129 | 146 | | |
130 | 147 | | |
131 | 148 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
135 | 153 | | |
136 | 154 | | |
137 | 155 | | |
| |||
148 | 166 | | |
149 | 167 | | |
150 | 168 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 169 | + | |
160 | 170 | | |
161 | | - | |
| 171 | + | |
162 | 172 | | |
163 | 173 | | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
167 | 177 | | |
168 | 178 | | |
169 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
170 | 199 | | |
171 | | - | |
172 | | - | |
| 200 | + | |
| 201 | + | |
173 | 202 | | |
174 | 203 | | |
175 | 204 | | |
176 | 205 | | |
177 | 206 | | |
178 | 207 | | |
179 | | - | |
| 208 | + | |
180 | 209 | | |
181 | 210 | | |
182 | 211 | | |
183 | 212 | | |
184 | 213 | | |
185 | | - | |
186 | | - | |
187 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
188 | 219 | | |
189 | 220 | | |
190 | 221 | | |
191 | 222 | | |
192 | 223 | | |
193 | 224 | | |
194 | 225 | | |
195 | | - | |
196 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
197 | 229 | | |
198 | 230 | | |
199 | 231 | | |
| |||
215 | 247 | | |
216 | 248 | | |
217 | 249 | | |
218 | | - | |
| 250 | + | |
219 | 251 | | |
220 | 252 | | |
221 | | - | |
| 253 | + | |
222 | 254 | | |
223 | 255 | | |
224 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
111 | 122 | | |
112 | 123 | | |
113 | 124 | | |
| |||
186 | 197 | | |
187 | 198 | | |
188 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
189 | 220 | | |
190 | 221 | | |
191 | 222 | | |
| |||
204 | 235 | | |
205 | 236 | | |
206 | 237 | | |
207 | | - | |
208 | | - | |
209 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
210 | 241 | | |
211 | 242 | | |
212 | 243 | | |
| |||
0 commit comments