# HttpConnector
Source: https://docs.maelstrom-ai.co/0.2/reference/client/classes/httpconnector/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:70

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

```typescript
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

-   [`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/)

## Constructors

### Constructor

> **new HttpConnector**(`options`): `HttpConnector`

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:81

#### Parameters

##### options

[`HttpConnectorOptions`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/httpconnectoroptions/)

#### Returns

`HttpConnector`

## Properties

### capabilities

> `readonly` **capabilities**: [`ConnectorCapabilities`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/connectorcapabilities/)

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:75

Connector capabilities. Metadata for consumers — the ConnectionManager does not use these for flow control.

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`capabilities`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#capabilities)

## Methods

### addAssistantMessage()

> **addAssistantMessage**(`message`): `Promise`<`void`\>

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:116

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](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/acknowledgedassistantconnector/#addassistantmessageacknowledged) when dependent side effects require a correlated engine outcome.

#### Parameters

##### message

[`AssistantMessage`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/assistantmessage/)

#### Returns

`Promise`<`void`\>

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`addAssistantMessage`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#addassistantmessage)

* * *

### connect()

> **connect**(`_sessionId`): `Promise`<`void`\>

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:95

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

##### \_sessionId

[`SessionId`](https://docs.maelstrom-ai.co/0.2/reference/client/type-aliases/sessionid/)

#### Returns

`Promise`<`void`\>

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`connect`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#connect)

* * *

### disconnect()

> **disconnect**(): `Promise`<`void`\>

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:100

No-op. HTTP is stateless — nothing to clean up.

#### Returns

`Promise`<`void`\>

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`disconnect`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#disconnect)

* * *

### getHistory()

> **getHistory**(`sessionId`): `Promise`<readonly `SessionHistoryEntry`\[\]>

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:128

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

##### sessionId

[`SessionId`](https://docs.maelstrom-ai.co/0.2/reference/client/type-aliases/sessionid/)

#### Returns

`Promise`<readonly `SessionHistoryEntry`\[\]>

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`getHistory`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#gethistory)

* * *

### process()

> **process**(`message`): `Promise`<`MaelstromResponse`\>

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:112

Sends a chart\_request envelope to the API endpoint.

#### Parameters

##### message

`ChartRequestMessage`

#### Returns

`Promise`<`MaelstromResponse`\>

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`process`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#process)

* * *

### subscribe()

> **subscribe**(`_handler`): [`Unsubscribe`](https://docs.maelstrom-ai.co/0.2/reference/client/type-aliases/unsubscribe/)

Defined in: packages/client/src/lib/connection-manager/connectors/http-connector.ts:105

HTTP never fires transport events. Returns an unsubscribe no-op.

#### Parameters

##### \_handler

(`event`) => `void`

#### Returns

[`Unsubscribe`](https://docs.maelstrom-ai.co/0.2/reference/client/type-aliases/unsubscribe/)

#### Implementation of

[`EngineConnector`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/).[`subscribe`](https://docs.maelstrom-ai.co/0.2/reference/client/interfaces/engineconnector/#subscribe)
