Skip to main content

Class: CallManager

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:68

Constructors​

Constructor​

new CallManager(config): CallManager

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:84

Parameters​

config​

VoiceCallConfig

Returns​

CallManager

Methods​

dispose()​

dispose(): void

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:765

Clean up all state (for shutdown).

A store transaction already in flight still commits, and a hangup whose end is committing still asks its carrier, but neither changes the records of a disposed manager.

Returns​

void


findCallByProviderCallId()​

findCallByProviderCallId(providerCallId): CallRecord | undefined

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:628

Find a call by provider-assigned call ID.

Parameters​

providerCallId​

string

Returns​

CallRecord | undefined


getActiveCalls()​

getActiveCalls(): CallRecord[]

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:640

Get all active (non-terminal) calls.

Returns​

CallRecord[]


getCall()​

getCall(callId): CallRecord | undefined

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:623

Get a call by internal ID.

Parameters​

callId​

string

Returns​

CallRecord | undefined


getProvider()​

getProvider(name?): IVoiceCallProvider | undefined

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:100

Get a registered provider by name.

Parameters​

name?​

VoiceProviderName

Returns​

IVoiceCallProvider | undefined


handleInboundCall()​

handleInboundCall(params): CallRecord | null

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:650

Handle an inbound call based on the configured policy. Creates a CallRecord if the call is accepted.

Parameters​

params​
fromNumber​

string

provider​

VoiceProviderName

providerCallId​

string

seedId?​

string

toNumber​

string

Returns​

CallRecord | null


hangupCall()​

hangupCall(callId): Promise<void>

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:233

Hang up a call. Transitions to 'hangup-bot' terminal state.

A call persisted with persistCall or read by processWebhookDurable ends in its store: the end, with any bot speech not yet committed, commits there before the carrier is asked to hang up, so the completion callback the hangup causes, like any callback after the commit, finds the call ended and changes nothing, whichever manager processes it. call:ended is emitted after the carrier request returns. The carrier is asked even when that commit fails, and the promise then rejects with the commit's error. A call the store already holds as ended keeps its stored outcome and emits nothing.

Parameters​

callId​

string

Returns​

Promise<void>


initiateCall()​

initiateCall(params): Promise<CallRecord>

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:142

Initiate an outbound phone call.

Creates a CallRecord in 'initiated' state, delegates to the provider to place the call, and returns the internal call ID.

Parameters​

params​
fromNumber?​

string

message?​

string

mode?​

CallMode

providerName?​

VoiceProviderName

seedId?​

string

toNumber​

string

Returns​

Promise<CallRecord>


on()​

on(handler): () => void

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:111

Register a handler for call events.

Parameters​

handler​

CallManagerEventHandler

Returns​

Unsubscribe function.

(): void

Returns​

void


persistCall()​

persistCall(callId, store): Promise<CallRecord>

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:496

Inserts an admitted call once. A callback that races admission must be retried, never acknowledged.

Parameters​

callId​

string

store​

ITelephonyCallStore

Returns​

Promise<CallRecord>


processNormalizedEvent()​

processNormalizedEvent(event): void

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:315

Process a single normalized call event.

With eventHandling: 'carrier' the event is matched to a call by its provider and call id (or its request id), bound to that call's carrier identity and applied once per record: a state the call has passed emits nothing, a call emits one terminal notification, and the record stays in the manager. This repairs transitions in process and adds no restart durability; see processWebhookDurable. Otherwise the original handling below applies.

Parameters​

event​

NormalizedCallEvent

Returns​

void


processWebhook()​

processWebhook(providerName, ctx): void

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:282

Process an incoming webhook from a telephony provider.

Verifies the signature, parses events, and applies state transitions. Idempotent — duplicate event IDs are silently skipped.

Parameters​

providerName​

VoiceProviderName

ctx​

WebhookContext

Returns​

void


processWebhookDurable()​

processWebhookDurable(providerName, context, store): Promise<{ accepted: boolean; applied: number; }>

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:514

Verifies, binds and applies callbacks in the store transaction. State and dedupe commit together. Unknown admission throws so the host returns a retryable response. Notifications happen only after commit and are best-effort; financial/external effects must consume durable records, not handlers. A call's bot speech not yet committed commits first, and the manager's record of each call becomes the committed one with the speech recorded since on top; the manager's store transactions run one at a time.

Parameters​

providerName​

VoiceProviderName

context​

WebhookContext

store​

ITelephonyCallStore

Returns​

Promise<{ accepted: boolean; applied: number; }>


registerProvider()​

registerProvider(provider): void

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:93

Register a telephony provider.

Parameters​

provider​

IVoiceCallProvider

Returns​

void


speakText()​

speakText(callId, text): void

Defined in: packages/agentos/src/io/channels/telephony/CallManager.ts:260

Add a bot speech entry to the transcript and transition to speaking.

On a call persisted with persistCall or read by processWebhookDurable, the entry and the speaking state also commit to the call's store, after the manager's earlier store transactions; until one commits them, every later transaction for the call carries them, so a callback does not drop them from the manager's record. When another manager has ended the call in the store meanwhile, the entry still commits to its transcript and the call keeps its stored outcome. A failed commit is written to the console and left to the next transaction.

Parameters​

callId​

string

text​

string

Returns​

void