API Reference

Channel Types

Type definitions for channels, external channels, and channel handles in Noetic.

Channel

A typed communication channel for inter-step message passing.

interface Channel<T> {
  readonly name: string;
  readonly schema: ZodType<T>;
  readonly mode: 'value' | 'queue' | 'topic';
  readonly capacity?: number;
}
FieldTypeRequiredDescription
namestringyesUnique channel name
schemaZodType<T>yesZod schema for message validation
mode'value' | 'queue' | 'topic'yesChannel semantics
capacitynumbernoMaximum buffered messages (for queue/topic modes)

Channel Modes

ModeBehavior
'value'Holds a single value. New sends overwrite the previous value.
'queue'FIFO buffer. Sends enqueue, receives dequeue.
'topic'Pub/sub broadcast. All receivers get every message.

ExternalChannel

An external channel extends Channel with an external flag, enabling cross-process communication.

interface ExternalChannel<T> extends Channel<T> {
  readonly external: true;
}
FieldTypeRequiredDescription
namestringyesUnique channel name
schemaZodType<T>yesZod schema for message validation
mode'value' | 'queue' | 'topic'yesChannel semantics
capacitynumbernoMaximum buffered messages
externaltrueyesMarks channel as externally accessible

ChannelHandle

A handle for sending messages into a channel from outside the agent execution context.

interface ChannelHandle<T> {
  send(value: T): void;
  readonly closed: boolean;
  readonly channel: Channel<T>;
}
FieldTypeDescription
send(value: T) => voidSend a value into the channel
closedbooleanWhether the handle is closed (execution completed)
channelChannel<T>Reference to the underlying channel

Context Channel Methods

The Context object provides three methods for channel interaction:

interface Context {
  send<T>(channel: Channel<T>, value: T): void;
  recv<T>(channel: Channel<T>, opts?: { timeout?: number }): Promise<T>;
  tryRecv<T>(channel: Channel<T>): T | null;
}
MethodDescription
send(channel, value)Send a value to the channel. Non-blocking.
recv(channel, opts?)Receive a value. Blocks until available or timeout.
tryRecv(channel)Non-blocking receive. Returns null if no value available.

On this page