Skip to main content
Type contracts exported by this package: interfaces, type aliases, and enums.

MessageHandler

Message handler callback.
MessageHandler

AgentPollerConfig

Poller configuration.
PropertyTypeRequiredDescription
agentIdstringYesAgent ID to poll as.
apiKeystringYesAPI key for authentication.
apiBaseUrlstringYesAPI base URL.
pollIntervalMsnumber | undefinedNoPoll interval in milliseconds. Default: 5000.
groupConversationIdsstring[] | undefinedNoKnown group conversation IDs to monitor for mentions.
groupPollLimitnumber | undefinedNoMax messages to fetch per group conversation poll. Default: 15.
transportTransport | undefinedNoTransport instance for polling messages. When provided, poll() delegates to transport.poll() instead of raw HTTP. The transport must already be connected before passing to AgentPoller.

HeartbeatConfig

Heartbeat service configuration.
PropertyTypeRequiredDescription
agentIdstringYesAgent ID to send heartbeats for.
apiKeystringYesAPI key for authentication.
apiBaseUrlstringYesAPI base URL.
intervalMsnumber | undefinedNoHeartbeat interval in milliseconds. Default: 30000 (30s).

KeyRotationConfig

Key rotation service configuration.
PropertyTypeRequiredDescription
agentIdstringYesAgent ID to monitor.
registryAgentRegistryAPIYesAgentRegistryAPI instance for credential lookup and rotation.
checkIntervalMsnumber | undefinedNoCheck interval in milliseconds. Default: 3600000 (1 hour).
maxKeyAgeMsnumber | undefinedNoMax key age in milliseconds before rotation. Default: 2592000000 (30 days).

SseConnectionConfig

SSE connection service configuration.
PropertyTypeRequiredDescription
agentIdstringYesAgent ID to connect as.
apiKeystringYesAPI key for authentication.
apiBaseUrlstringYesAPI base URL.
sseEndpointstring | undefinedNoSSE endpoint URL. If omitted, uses apiBaseUrl + /sse.
transportTransportYesTransport instance to use. Injected by createRuntime.

SseMessageHandler

Message handler callback.
SseMessageHandler

RuntimeConfig

Configuration for createRuntime().
PropertyTypeRequiredDescription
agentIdstring | undefinedNoAgent ID to run as. If omitted, uses the most recently used active agent.
pollIntervalMsnumber | undefinedNoPoll interval in milliseconds. Default: 5000.
groupConversationIdsstring[] | undefinedNoKnown group conversation IDs to monitor for mentions.
groupPollLimitnumber | undefinedNoMax messages per group conversation poll. Default: 15.
heartbeatIntervalMsnumber | undefinedNoHeartbeat interval in milliseconds. Default: 30000. Set to 0 to disable.
maxKeyAgeMsnumber | undefinedNoMax key age in milliseconds before rotation. Default: 30 days. Set to 0 to disable.
sseEndpointstring | undefinedNoSSE endpoint URL. If set, enables persistent SSE connection.
createSseTransport(() => import("@cleocode/contracts").Transport) | undefinedNoTransport factory for SSE connection. Caller provides to avoid circular deps.
transportTransport | undefinedNoPre-created transport instance. When provided, bypasses auto-resolution. The transport must NOT be connected yet — createRuntime handles connection.

RuntimeHandle

Handle returned by createRuntime().
PropertyTypeRequiredDescription
pollerAgentPollerYesThe AgentPoller instance.
heartbeatHeartbeatService | nullYesThe HeartbeatService instance (null if disabled).
keyRotationKeyRotationService | nullYesThe KeyRotationService instance (null if disabled).
sseConnectionSseConnectionService | nullYesThe SseConnectionService instance (null if no SSE endpoint).
transportTransportYesThe resolved transport (local, sse, or http).
agentIdstringYesThe agent ID the runtime is running as.
stop() => voidYesStop all runtime services and clean up.