> ## Documentation Index
> Fetch the complete documentation index at: https://codluv.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# runtime — Functions

> Functions and classes for the runtime package

Functions and classes exported by this package.

## AgentPoller

AgentPoller service — polls peek endpoint AND group conversations. Deduplicates messages by ID across both sources.

**Signature**

```typescript theme={null}
typeof AgentPoller
```

**Methods**

### onMessage()

Register a message handler.

```typescript theme={null}
(handler: MessageHandler) => void
```

### start()

Start the polling loop.

```typescript theme={null}
() => void
```

### stop()

Stop the polling loop.

```typescript theme={null}
() => void
```

### status()

Get poller status.

```typescript theme={null}
() => { running: boolean; seenCount: number; }
```

### pollCycle()

Single poll cycle — peek + group conversations.

```typescript theme={null}
() => Promise<void>
```

### peekMessages()

Peek for messages mentioning this agent. Delegates to transport when available.

```typescript theme={null}
() => Promise<ConduitMessage[]>
```

### pollGroupConversation()

Poll a group conversation for recent messages that  this agent. This is the fix for the group  blind spot.

```typescript theme={null}
(conversationId: string) => Promise<ConduitMessage[]>
```

### headers()

Build auth headers.

```typescript theme={null}
() => Record<string, string>
```

## HeartbeatService

HeartbeatService sends periodic online status to the cloud API.

**Signature**

```typescript theme={null}
typeof HeartbeatService
```

**Methods**

### start()

Start sending heartbeats at the configured interval.

```typescript theme={null}
() => void
```

### stop()

Stop sending heartbeats.

```typescript theme={null}
() => void
```

### status()

Get heartbeat service status.

```typescript theme={null}
() => { running: boolean; consecutiveFailures: number; }
```

### sendHeartbeat()

Send a single heartbeat to the cloud API.

```typescript theme={null}
() => Promise<void>
```

## KeyRotationService

KeyRotationService monitors credential age and auto-rotates when threshold is exceeded.

**Signature**

```typescript theme={null}
typeof KeyRotationService
```

**Methods**

### start()

Start monitoring key age at the configured interval.

```typescript theme={null}
() => void
```

### stop()

Stop monitoring.

```typescript theme={null}
() => void
```

### status()

Get rotation service status.

```typescript theme={null}
() => { running: boolean; lastRotationAt: string | null; }
```

### checkAndRotate()

Check credential age and rotate if needed.

```typescript theme={null}
() => Promise<void>
```

## SseConnectionService

SseConnectionService manages a persistent transport with subscribe() support.

**Signature**

```typescript theme={null}
typeof SseConnectionService
```

**Methods**

### onMessage()

Register a message handler for incoming messages.

```typescript theme={null}
(handler: SseMessageHandler) => void
```

### start()

Start the SSE connection.

```typescript theme={null}
() => Promise<void>
```

### stop()

Stop the connection and clean up.

```typescript theme={null}
() => Promise<void>
```

### status()

Get connection service status.

```typescript theme={null}
() => { running: boolean; transportName: string; }
```

## createRuntime(registry, config)

Create and start a runtime from the agent registry.  Resolves the agent credential, configures the poller, and starts polling. Returns a handle to register message handlers and stop the runtime.

**Signature**

```typescript theme={null}
(registry: AgentRegistryAPI, config?: RuntimeConfig) => Promise<RuntimeHandle>
```

**Parameters**

| Name       | Type               | Description                                      |
| ---------- | ------------------ | ------------------------------------------------ |
| `registry` | `AgentRegistryAPI` | AgentRegistryAPI instance for credential lookup. |
| `config`   | `: RuntimeConfig`  | Optional runtime configuration overrides.        |

**Returns** — A RuntimeHandle with the poller, agentId, and stop function.
