HttpConnector
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:74
HTTP connector for stateless API communication.
HTTP connections are per-request, so connect() and disconnect() are
no-ops, and subscribe() never fires any events. Useful for traditional
REST APIs.
Example
Section titled “Example”import { HttpConnector } from '@maelstrom-co/client';import { ChartRequestMessage, SessionId } from '@maelstrom-co/protocol';
const connector = new HttpConnector({ baseUrl: 'https://api.example.com', timeout: 30000, headers: { 'Authorization': 'Bearer token' },});
const manager = new ConnectionManager(store, connector);await manager.connect(SessionId('session-1'));
const envelope = ChartRequestMessage({ sessionId: SessionId('session-1'), request: chartRequestPayload,});const response = await connector.process(envelope);Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new HttpConnector(
options):HttpConnector
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:85
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”HttpConnector
Properties
Section titled “Properties”capabilities
Section titled “capabilities”
readonlycapabilities:ConnectorCapabilities
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:79
Connector capabilities. Metadata for consumers — the ConnectionManager does not use these for flow control.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”addAssistantMessage()
Section titled “addAssistantMessage()”addAssistantMessage(
message):Promise<void>
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:120
Add an assistant message to conversation history without LLM processing. Used for programmatic messages (greetings, notifications).
This legacy capability is fire-and-forget: it resolves after the transport accepts the send and does not confirm insertion. Use AcknowledgedAssistantConnector.addAssistantMessageAcknowledged when dependent side effects require a correlated engine outcome.
Parameters
Section titled “Parameters”message
Section titled “message”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”EngineConnector.addAssistantMessage
connect()
Section titled “connect()”connect(
_sessionId):Promise<void>
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:99
No-op. HTTP is per-request — there is no persistent connection to establish. Override this to implement a health check if desired.
Note: the sessionId is not stored because HTTP requests carry session context in the request body. Subclasses that need session correlation should override this method and store the sessionId.
Parameters
Section titled “Parameters”_sessionId
Section titled “_sessionId”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”disconnect()
Section titled “disconnect()”disconnect():
Promise<void>
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:104
No-op. HTTP is stateless — nothing to clean up.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”getHistory()
Section titled “getHistory()”getHistory(
sessionId):Promise<readonlySessionHistoryEntry[]>
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:153
Fetch the engine-recorded history for a session via POST /history.
POST (not GET) keeps the request body symmetric with /process and
/assistant-message, lets clients send opaque session ids without URL
encoding concerns, and avoids accidental caching by intermediaries that
cache GET responses.
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”Returns
Section titled “Returns”Promise<readonly SessionHistoryEntry[]>
Implementation of
Section titled “Implementation of”onEvent()
Section titled “onEvent()”onEvent(
_handler):Unsubscribe
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:141
HTTP never delivers agent events. Returns an unsubscribe no-op.
The agent loop is experimental in 0.3 and may change in any minor release.
Parameters
Section titled “Parameters”_handler
Section titled “_handler”(event) => void
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”process()
Section titled “process()”process(
message):Promise<MaelstromResponse>
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:116
Sends a chart_request envelope to the API endpoint.
Parameters
Section titled “Parameters”message
Section titled “message”ChartRequestMessage
Returns
Section titled “Returns”Promise<MaelstromResponse>
Implementation of
Section titled “Implementation of”sendInput()
Section titled “sendInput()”sendInput(
_input):Promise<void>
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:130
Always rejects with AgentWireUnsupportedError. The Agent Session wire needs a persistent transport and makes no HTTP request.
The agent loop is experimental in 0.3 and may change in any minor release.
Parameters
Section titled “Parameters”_input
Section titled “_input”AgentInput
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”subscribe()
Section titled “subscribe()”subscribe(
_handler):Unsubscribe
Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:109
HTTP never fires transport events. Returns an unsubscribe no-op.
Parameters
Section titled “Parameters”_handler
Section titled “_handler”(event) => void