Skip to content

Documentation / @agentick/core / Channel

Class: Channel ​

Defined in: kernel/src/channel.ts:88

Core Channel primitive. Works standalone in any Node environment. Uses EventEmitter internally for pub/sub.

Constructors ​

Constructor ​

new Channel(name): Channel

Defined in: kernel/src/channel.ts:101

Parameters ​

name ​

string

Returns ​

Channel

Properties ​

name ​

readonly name: string

Defined in: kernel/src/channel.ts:101

Methods ​

destroy() ​

destroy(): void

Defined in: kernel/src/channel.ts:230

Cleanup: remove all subscribers and pending requests.

Returns ​

void


getSubscriberCount() ​

getSubscriberCount(): number

Defined in: kernel/src/channel.ts:223

Get the number of active subscribers.

Returns ​

number


publish() ​

publish(event): void

Defined in: kernel/src/channel.ts:106

Publish an event to the channel.

Parameters ​

event ​

ChannelEvent

Returns ​

void


subscribe() ​

subscribe(handler): () => void

Defined in: kernel/src/channel.ts:167

Subscribe to events on this channel.

Parameters ​

handler ​

(event) => void

Returns ​

Unsubscribe function

(): void

Returns ​

void


waitForResponse() ​

waitForResponse(requestId, timeoutMs?): Promise<ChannelEvent>

Defined in: kernel/src/channel.ts:183

Wait for a response to a specific request. Used by tools/components for bidirectional communication.

Parameters ​

requestId ​

string

The request ID to wait for

timeoutMs? ​

number = 30000

Timeout in milliseconds (default: 30000)

Returns ​

Promise<ChannelEvent>

Promise that resolves when response is received

Released under the ISC License.