Skip to content

Commit 513f0ac

Browse files
author
Mark Pollack
committed
Micronaut: the listener's own keys move under acp.agent.transport.http.listener
host, port and max-concurrent-streams-per-connection configure only the SDK's Jetty listener, so they now sit under acp.agent.transport.http.listener, as in Spring Boot and acp-integration. The keys any host of the endpoint reads (path, allowed-origins, the buffer limits, shutdown-timeout) stay under acp.agent.transport.http. No aliases: the old keys never shipped.
1 parent 628dd0a commit 513f0ac

12 files changed

Lines changed: 153 additions & 94 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
its own. It now binds `127.0.0.1`, and `::1` too where the machine has IPv6, unless told
1616
otherwise. Remote exposure is an explicit opt-in: `StreamableHttpAcpAgentTransportOptions.builder()
1717
.host("0.0.0.0")` (or one address), `spring.acp.agent.transport.http.listener.host` (Spring Boot,
18-
non-web applications), `acp.agent.transport.http.host` (Micronaut) and
18+
non-web applications), `acp.agent.transport.http.listener.host` (Micronaut) and
1919
`transport.http.listener.host` in `AcpAgentSettings`. Servers a framework runs (a Spring MVC
2020
servlet container, Quarkus) keep the framework's own bind settings (`server.address`,
2121
`quarkus.http.host`). Migration: a deployment that reached the listener from another machine or
@@ -228,7 +228,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
228228
(the context closes and the process exits 0 when the client closes the agent's input; SIGTERM
229229
closes the agent gracefully), or `http`/`websocket` through the SDK's Jetty listener on its own
230230
port, with every `StreamableHttpAcpAgentTransportOptions` limit as a property, plus
231-
`cancel-grace-period` and `max-prompt-duration`.
231+
`cancel-grace-period` and `max-prompt-duration`. As in Spring Boot and `acp-integration`, the
232+
listener's own keys sit under `acp.agent.transport.http.listener` (`host`, `port`,
233+
`max-concurrent-streams-per-connection`); the keys any host of the endpoint reads (`path`,
234+
`allowed-origins`, the buffer limits, `shutdown-timeout`) stay under `acp.agent.transport.http`.
232235
- **Client.** `acp.client.*` builds the stdio, WebSocket or Streamable HTTP transport, an
233236
`AcpAsyncClient` customized by `AcpClientCustomizer` beans in order, and an `AcpSyncClient` over
234237
it; it closes gracefully, once, with the context.

‎acp-micronaut-sample/src/main/java/com/agentclientprotocol/sdk/micronaut/sample/Application.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Starts the agent. Over stdio (the default) standard output carries the protocol, so the
1111
* banner is off and {@code logback.xml} logs to standard error; the process exits when its
1212
* client closes the agent's input. With {@code -Dacp.agent.transport.type=http} it serves
13-
* Streamable HTTP and WebSocket on {@code acp.agent.transport.http.port} until stopped.
13+
* Streamable HTTP and WebSocket on {@code acp.agent.transport.http.listener.port} until stopped.
1414
*/
1515
public final class Application {
1616

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
micronaut.application.name=acp-micronaut-sample
22
# stdio by default: standard output carries the protocol (logback.xml logs to standard error)
33
acp.agent.transport.type=stdio
4-
acp.agent.transport.http.port=8080
4+
acp.agent.transport.http.listener.port=8080

‎acp-micronaut-sample/src/test/java/com/agentclientprotocol/sdk/micronaut/sample/AgentProcessTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void stdioStopsGracefullyOnSigterm() throws Exception {
7070

7171
@Test
7272
void httpServesUntilSigtermThenStopsGracefully() throws Exception {
73-
Process agent = AgentProcess.start("--acp.agent.transport.type=http", "--acp.agent.transport.http.port=0",
73+
Process agent = AgentProcess.start("--acp.agent.transport.type=http", "--acp.agent.transport.http.listener.port=0",
7474
"--acp.agent.transport.http.shutdown-timeout=2s");
7575
List<String> stderr = AgentProcess.collectStderr(agent);
7676
int port = awaitPort(stderr);

‎acp-micronaut-sample/src/test/java/com/agentclientprotocol/sdk/micronaut/sample/EchoAgentTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/** The sample agent in-process, over WebSocket, with a configured greeting. */
2626
@MicronautTest
2727
@Property(name = "acp.agent.transport.type", value = "http")
28-
@Property(name = "acp.agent.transport.http.port", value = "0")
28+
@Property(name = "acp.agent.transport.http.listener.port", value = "0")
2929
@Property(name = "sample.prefix", value = "hi: ")
3030
class EchoAgentTest {
3131

‎acp-micronaut/README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ public final class Application {
8989
| `acp.agent.shutdown-on-transport-end` | `true` | close the context when the stdio input ends |
9090
| `acp.agent.shutdown-timeout` | `10s` | how long closing waits for a stdio agent's graceful close, then closes it at once |
9191
| `acp.agent.transport.type` | `stdio` | `stdio`, `http` or `websocket`, in any case (the last two mean the same listener) |
92-
| `acp.agent.transport.http.host` | loopback | the address the listener binds; unset binds `127.0.0.1` and `::1` only, `0.0.0.0` every interface (an explicit opt-in: the listener has no authentication) |
92+
| `acp.agent.transport.http.listener.host` | loopback | the address the listener binds; unset binds `127.0.0.1` and `::1` only, `0.0.0.0` every interface (an explicit opt-in: the listener has no authentication) |
9393
| `acp.agent.transport.http.allowed-origins` | none | browser origins accepted besides `localhost`, `127.0.0.1` and `[::1]`; any other `Origin` is answered 403, over HTTP and on the WebSocket handshake; `*` for any |
94-
| `acp.agent.transport.http.port` | `8080` | the listener's own port; `0` for an ephemeral one (`AcpAgentRuntime.port()`) |
94+
| `acp.agent.transport.http.listener.port` | `8080` | the listener's own port; `0` for an ephemeral one (`AcpAgentRuntime.port()`) |
95+
| `acp.agent.transport.http.listener.max-concurrent-streams-per-connection` | SDK (1024) | HTTP/2 streams one client connection may hold open |
9596
| `acp.agent.transport.http.path` | `/acp` | |
9697
| `acp.agent.transport.http.max-post-body-size` | SDK (16MB) | e.g. `4MB` |
97-
| `acp.agent.transport.http.keep-alive-interval`, `mailbox-capacity`, `max-pending-sse-events`, `max-web-socket-pending-frames`, `max-provisional-sessions`, `max-concurrent-streams-per-connection`, `shutdown-timeout` | SDK | `StreamableHttpAcpAgentTransportOptions`; closing waits for the listener at most `shutdown-timeout` plus 5 seconds |
98+
| `acp.agent.transport.http.keep-alive-interval`, `mailbox-capacity`, `max-pending-sse-events`, `max-web-socket-pending-frames`, `max-provisional-sessions`, `shutdown-timeout` | SDK | `StreamableHttpAcpAgentTransportOptions`; closing waits for the listener at most `shutdown-timeout` plus 5 seconds |
9899

99100
An application bean of type `AcpAgentTransport` replaces stdio, for example the in-memory
100101
transport of `acp-test` in a test.
@@ -106,7 +107,7 @@ one, not inside it. It serves HTTP/1.1, cleartext HTTP/2 and WebSocket upgrades
106107
**Micronaut's security does not apply to it.** Because the listener is the SDK's own server,
107108
Micronaut's filters, `micronaut-security` rules, CORS, TLS and metrics never see its requests. It
108109
binds the loopback interface by default, so only programs on the same machine can connect, and it
109-
refuses browser requests from foreign origins. Setting `acp.agent.transport.http.host=0.0.0.0`
110+
refuses browser requests from foreign origins. Setting `acp.agent.transport.http.listener.host=0.0.0.0`
110111
exposes an endpoint without authentication to the network: put a proxy that authenticates in front
111112
of it. This is the interim arrangement for 0.80.0; serving ACP on Micronaut's own server, where its
112113
security applies, is planned for 0.81.0.

‎acp-micronaut/src/main/java/com/agentclientprotocol/sdk/micronaut/agent/AcpAgentConfiguration.java‎

Lines changed: 106 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
* acp.agent.shutdown-on-transport-end true close the context when stdio input ends
3030
* acp.agent.shutdown-timeout 10s closing waits this long for a stdio agent
3131
* acp.agent.transport.type stdio stdio | http | websocket
32-
* acp.agent.transport.http.host (unset) loopback only; 0.0.0.0 for every interface
33-
* acp.agent.transport.http.port 8080 0 for an ephemeral port
32+
* acp.agent.transport.http.listener.host (unset) loopback only; 0.0.0.0 for every interface
33+
* acp.agent.transport.http.listener.port 8080 0 for an ephemeral port
34+
* acp.agent.transport.http.listener.max-concurrent-streams-per-connection (unset: the SDK default)
3435
* acp.agent.transport.http.allowed-origins (none) browser origins accepted besides loopback
3536
* acp.agent.transport.http.path /acp
3637
* acp.agent.transport.http.max-post-body-size, keep-alive-interval, mailbox-capacity,
3738
* max-pending-sse-events, max-web-socket-pending-frames, max-provisional-sessions,
38-
* max-concurrent-streams-per-connection, shutdown-timeout (unset: the SDK defaults)
39+
* shutdown-timeout (unset: the SDK defaults)
3940
* </pre>
4041
*
4142
* <p>Durations take Micronaut's forms, such as {@code 30s} or {@code 500ms}; a size is a number of
@@ -235,10 +236,10 @@ public AcpAgentSettings toSettings() {
235236
.maxWebSocketPendingFrames(http.getMaxWebSocketPendingFrames())
236237
.maxProvisionalSessions(http.getMaxProvisionalSessions())
237238
.shutdownTimeout(http.getShutdownTimeout())
238-
.listenerHost(http.getHost())
239+
.listenerHost(http.getListener().getHost())
239240
.allowedOrigins(http.getAllowedOrigins())
240-
.listenerPort(http.getPort())
241-
.maxConcurrentStreamsPerConnection(http.getMaxConcurrentStreamsPerConnection())
241+
.listenerPort(http.getListener().getPort())
242+
.maxConcurrentStreamsPerConnection(http.getListener().getMaxConcurrentStreamsPerConnection())
242243
.build();
243244
}
244245

@@ -311,10 +312,6 @@ public void setHttp(Http http) {
311312
@ConfigurationProperties("http")
312313
public static class Http {
313314

314-
private @Nullable String host;
315-
316-
private int port = 8080;
317-
318315
private List<String> allowedOrigins = new ArrayList<>();
319316

320317
private String path = AcpAgentSettings.DEFAULT_PATH;
@@ -331,31 +328,9 @@ public static class Http {
331328

332329
private @Nullable Integer maxProvisionalSessions;
333330

334-
private @Nullable Integer maxConcurrentStreamsPerConnection;
335-
336331
private @Nullable Duration shutdownTimeout;
337332

338-
/**
339-
* Returns the address the listener binds ({@code acp.agent.transport.http.host}).
340-
* Default: unset, which binds the loopback interface only ({@code 127.0.0.1}, and
341-
* {@code ::1} where the machine has IPv6), so only programs on the same machine can
342-
* connect. {@code 0.0.0.0} exposes the agent on every interface. The listener is the
343-
* SDK's own server, not Micronaut's: Micronaut's security filters do not apply to it
344-
* and it has no authentication of its own, so expose it only behind a proxy or
345-
* firewall that controls who connects. Maps to {@link AcpAgentSettings.Listener#host()}.
346-
* @return the host, or {@code null} for loopback only
347-
*/
348-
public @Nullable String getHost() {
349-
return host;
350-
}
351-
352-
/**
353-
* Sets the address the listener binds; see {@link #getHost()}.
354-
* @param host a host name or address, or {@code null} for loopback only
355-
*/
356-
public void setHost(@Nullable String host) {
357-
this.host = host;
358-
}
333+
private Listener listener = new Listener();
359334

360335
/**
361336
* Returns the browser origins the listener accepts besides the loopback ones
@@ -380,24 +355,6 @@ public void setAllowedOrigins(List<String> allowedOrigins) {
380355
this.allowedOrigins = allowedOrigins;
381356
}
382357

383-
/**
384-
* Returns the listener's port ({@code acp.agent.transport.http.port}). Default 8080;
385-
* {@code 0} picks a free port, which {@link AcpAgentRuntime#port()} then returns. Maps
386-
* to {@link AcpAgentSettings.Listener#port()}.
387-
* @return the port
388-
*/
389-
public int getPort() {
390-
return port;
391-
}
392-
393-
/**
394-
* Sets the listener's port; default 8080, 0 for an ephemeral port.
395-
* @param port the listener's port; 0 for an ephemeral port
396-
*/
397-
public void setPort(int port) {
398-
this.port = port;
399-
}
400-
401358
/**
402359
* Returns the endpoint's path ({@code acp.agent.transport.http.path}). Default
403360
* {@value AcpAgentSettings#DEFAULT_PATH}. Maps to {@link AcpAgentSettings.Http#path()}.
@@ -539,27 +496,6 @@ public void setMaxProvisionalSessions(@Nullable Integer maxProvisionalSessions)
539496
this.maxProvisionalSessions = maxProvisionalSessions;
540497
}
541498

542-
/**
543-
* Returns how many HTTP/2 streams one client connection may hold open at once, each
544-
* open SSE stream holding one
545-
* ({@code acp.agent.transport.http.max-concurrent-streams-per-connection}). Default:
546-
* unset, which keeps the SDK's default of 1024. Maps to the transport option
547-
* {@code maxConcurrentStreamsPerConnection}.
548-
* @return the limit, or {@code null} for the SDK's default
549-
*/
550-
public @Nullable Integer getMaxConcurrentStreamsPerConnection() {
551-
return maxConcurrentStreamsPerConnection;
552-
}
553-
554-
/**
555-
* Sets the HTTP/2 streams one client connection may hold open; unset keeps the SDK
556-
* default, 1024.
557-
* @param maxConcurrentStreamsPerConnection the stream count; positive
558-
*/
559-
public void setMaxConcurrentStreamsPerConnection(@Nullable Integer maxConcurrentStreamsPerConnection) {
560-
this.maxConcurrentStreamsPerConnection = maxConcurrentStreamsPerConnection;
561-
}
562-
563499
/**
564500
* Returns how long closing the listener waits for its connections' agents to close
565501
* before it closes the rest at once
@@ -583,6 +519,104 @@ public void setShutdownTimeout(@Nullable Duration shutdownTimeout) {
583519
this.shutdownTimeout = shutdownTimeout;
584520
}
585521

522+
/**
523+
* Returns the SDK listener's own properties, {@code acp.agent.transport.http.listener.*}:
524+
* the address and port it binds and its HTTP/2 stream limit. The other
525+
* {@code acp.agent.transport.http.*} properties apply to whichever server serves the
526+
* endpoint.
527+
* @return the listener properties
528+
*/
529+
public Listener getListener() {
530+
return listener;
531+
}
532+
533+
/**
534+
* Replaces the listener's own properties.
535+
* @param listener the listener properties
536+
*/
537+
public void setListener(Listener listener) {
538+
this.listener = listener;
539+
}
540+
541+
/**
542+
* The {@code acp.agent.transport.http.listener.*} properties: the SDK's own Jetty
543+
* listener's address, port and HTTP/2 stream limit, the keys Spring Boot and
544+
* {@code acp-integration} also keep under {@code listener}.
545+
*/
546+
@ConfigurationProperties("listener")
547+
public static class Listener {
548+
549+
private @Nullable String host;
550+
551+
private int port = 8080;
552+
553+
private @Nullable Integer maxConcurrentStreamsPerConnection;
554+
555+
/**
556+
* Returns the address the listener binds
557+
* ({@code acp.agent.transport.http.listener.host}). Default: unset, which binds the
558+
* loopback interface only ({@code 127.0.0.1}, and {@code ::1} where the machine has
559+
* IPv6), so only programs on the same machine can connect. {@code 0.0.0.0} exposes the
560+
* agent on every interface. The listener is the SDK's own server, not Micronaut's:
561+
* Micronaut's security filters do not apply to it and it has no authentication of its
562+
* own, so expose it only behind a proxy or firewall that controls who connects. Maps to
563+
* {@link AcpAgentSettings.Listener#host()}.
564+
* @return the host, or {@code null} for loopback only
565+
*/
566+
public @Nullable String getHost() {
567+
return host;
568+
}
569+
570+
/**
571+
* Sets the address the listener binds; see {@link #getHost()}.
572+
* @param host a host name or address, or {@code null} for loopback only
573+
*/
574+
public void setHost(@Nullable String host) {
575+
this.host = host;
576+
}
577+
578+
/**
579+
* Returns the listener's port ({@code acp.agent.transport.http.listener.port}).
580+
* Default 8080; {@code 0} picks a free port, which {@link AcpAgentRuntime#port()} then
581+
* returns. Maps to {@link AcpAgentSettings.Listener#port()}.
582+
* @return the port
583+
*/
584+
public int getPort() {
585+
return port;
586+
}
587+
588+
/**
589+
* Sets the listener's port; default 8080, 0 for an ephemeral port.
590+
* @param port the listener's port; 0 for an ephemeral port
591+
*/
592+
public void setPort(int port) {
593+
this.port = port;
594+
}
595+
596+
/**
597+
* Returns how many HTTP/2 streams one client connection may hold open at once, each
598+
* open SSE stream holding one
599+
* ({@code acp.agent.transport.http.listener.max-concurrent-streams-per-connection}).
600+
* Default: unset, which keeps the SDK's default of 1024. Maps to the transport option
601+
* {@code maxConcurrentStreamsPerConnection}.
602+
* @return the limit, or {@code null} for the SDK's default
603+
*/
604+
public @Nullable Integer getMaxConcurrentStreamsPerConnection() {
605+
return maxConcurrentStreamsPerConnection;
606+
}
607+
608+
/**
609+
* Sets the HTTP/2 streams one client connection may hold open; unset keeps the SDK
610+
* default, 1024.
611+
* @param maxConcurrentStreamsPerConnection the stream count; positive
612+
*/
613+
public void setMaxConcurrentStreamsPerConnection(
614+
@Nullable Integer maxConcurrentStreamsPerConnection) {
615+
this.maxConcurrentStreamsPerConnection = maxConcurrentStreamsPerConnection;
616+
}
617+
618+
}
619+
586620
}
587621

588622
}

‎acp-micronaut/src/main/java/com/agentclientprotocol/sdk/micronaut/agent/AcpAgentRuntime.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void start() {
183183

184184
/**
185185
* Returns the port the HTTP listener is bound to, useful with
186-
* {@code acp.agent.transport.http.port=0}.
186+
* {@code acp.agent.transport.http.listener.port=0}.
187187
* @return the port, or empty over stdio, before the start and after the close
188188
*/
189189
public OptionalInt port() {

0 commit comments

Comments
 (0)