Class AgentHttpService
java.lang.Object
ai.singlr.runtime.AgentHttpService
- All Implemented Interfaces:
io.helidon.webserver.http.HttpService, io.helidon.webserver.ServerLifecycle
Helidon
HttpService that exposes one SessionRegistry's sessions over HTTP. The
five Phase 1 routes mirror the spec §15.1 sketch and are mounted by the caller under whatever
prefix fits the deployment (routing.register("/v1", new AgentHttpService(...))).
POST /sessions— create a fresh session; returns{sessionId, eventsUrl}with201 Created.POST /sessions/{sessionId}/messages— body{text: "..."}; queues the message and returns202 Accepted.POST /sessions/{sessionId}/interrupt— body{reason: "..."}; queues a synthetic interrupt message and returns202 Accepted.GET /sessions/{sessionId}/events— opens an SSE stream ofQueryEvents. The handler blocks the request thread until the publisher signalsonCompleteor the client disconnects.GET /sessions/{sessionId}/result?timeout=<seconds>— long-poll for the terminalResultMessage. Returns200 OKwith body{type: "<SubtypeName>", result: <record-fields>}when terminal;204 No Contentwhen thetimeoutelapses with no terminal.timeoutdefaults to 60 s and is clamped to[0, 300]so a single request cannot pin a server thread longer than five minutes.DELETE /sessions/{sessionId}— closes and unregisters the session; returns204 No Content.
The optionsFactory is the seam through which deployments choose how a new session is
configured: the runtime takes the generated session id and produces a fully-populated SessionOptions. For Phase 1 the typical impl returns the same Model for every session.
Thread-safety
Thread-safe. Each request runs on its own virtual thread;SessionRegistry synchronises
shared session state.-
Constructor Summary
ConstructorsConstructorDescriptionAgentHttpService(SessionRegistry registry, Function<String, ai.singlr.session.SessionOptions> optionsFactory, tools.jackson.databind.ObjectMapper objectMapper, String eventsPathPrefix) Build a service. -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.webserver.ServerLifecycle
afterStart, afterStop, beforeStart
-
Constructor Details
-
AgentHttpService
public AgentHttpService(SessionRegistry registry, Function<String, ai.singlr.session.SessionOptions> optionsFactory, tools.jackson.databind.ObjectMapper objectMapper, String eventsPathPrefix) Build a service.- Parameters:
registry- registry of live sessions; non-nulloptionsFactory- function that maps a generated session id to a fully-configuredSessionOptions; non-nullobjectMapper- mapper for request/response bodies; non-nulleventsPathPrefix- prefix used to build theeventsUrlreturned byPOST /sessions(e.g."/v1"); non-null- Throws:
NullPointerException- if any argument is null
-
-
Method Details
-
routing
- Specified by:
routingin interfaceio.helidon.webserver.http.HttpService
-