Skip to content

@codesoul-co/hypha-harness / message-bus

Using this module

Use the Message bus module for using the public contracts and operations for this capability boundary. It exports 1 class, 9 interfaces, 2 types.

Import from the package entrypoint

ts
import {
  InMemoryMessageBus,
} from '@codesoul-co/hypha-harness';

import type {
  InMemoryMessageBusOptions,
  MessageAckInput,
  MessageAddress,
  MessageBus,
  MessageFailInput,
  MessageListFilter,
  PublishMessageInput,
  PullMessageFilter,
} from '@codesoul-co/hypha-harness';

// The complete export list is documented below.

Usage patterns

  • Use the 11 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.

Public exports

SymbolKindSignatureDescription
InMemoryMessageBusclassnew InMemoryMessageBus(options?: InMemoryMessageBusOptions): InMemoryMessageBusIn Memory Message Bus class with 6 public constructor or member entries; its exact declarations are listed below.
InMemoryMessageBusOptionsinterfaceinterface InMemoryMessageBusOptionsIn Memory Message Bus Options interface with 6 public fields or methods.
MessageAckInputinterfaceinterface MessageAckInputMessage Ack Input interface with 7 public fields or methods.
MessageAddressinterfaceinterface MessageAddressMessage Address interface with 2 public fields or methods.
MessageBusinterfaceinterface MessageBusMessage Bus interface with 5 public fields or methods.
MessageFailInputinterfaceinterface MessageFailInput extends MessageAckInputMessage Fail Input interface with 11 public fields or methods.
MessageListFilterinterfaceinterface MessageListFilterMessage List Filter interface with 5 public fields or methods.
PublishMessageInputinterfaceinterface PublishMessageInputPublish Message Input interface with 16 public fields or methods.
PullMessageFilterinterfaceinterface PullMessageFilterPull Message Filter interface with 6 public fields or methods.
RuntimeMessageinterfaceinterface RuntimeMessageRuntime Message interface with 20 public fields or methods.
MessageAddressKindtypetype MessageAddressKind = 'runtime' | 'session' | 'workflow' | 'agent' | 'tool' | 'human'Public type alias for Message Address Kind; the declaration contains its complete type expression.
MessageStatustypetype MessageStatus = 'queued' | 'delivered' | 'acknowledged' | 'failed' | 'dead_lettered'Public type alias for Message Status; the declaration contains its complete type expression.

InMemoryMessageBus

In Memory Message Bus class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InMemoryMessageBus } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export declare class InMemoryMessageBus implements MessageBus {
    constructor(options?: InMemoryMessageBusOptions);
    publish<TPayload = unknown>(input: PublishMessageInput<TPayload>): Promise<RuntimeMessage<TPayload>>;
    pull<TPayload = unknown>(filter: PullMessageFilter): Promise<RuntimeMessage<TPayload> | null>;
    acknowledge(input: MessageAckInput): Promise<RuntimeMessage | null>;
    fail(input: MessageFailInput): Promise<RuntimeMessage | null>;
    list(filter?: MessageListFilter): Promise<RuntimeMessage[]>;
}

Public members

MemberKindSignatureDescription
acknowledgemethodacknowledge(input: MessageAckInput): Promise<RuntimeMessage | null>Public method; parameters and return type are shown in the signature.
constructorconstructor(options?: InMemoryMessageBusOptions): InMemoryMessageBusCreates an instance of this class.
failmethodfail(input: MessageFailInput): Promise<RuntimeMessage | null>Public method; parameters and return type are shown in the signature.
listmethodlist(filter?: MessageListFilter): Promise<RuntimeMessage[]>Public method; parameters and return type are shown in the signature.
publishmethodpublish<TPayload = unknown>(input: PublishMessageInput<TPayload>): Promise<RuntimeMessage<TPayload>>Public method; parameters and return type are shown in the signature.
pullmethodpull<TPayload = unknown>(filter: PullMessageFilter): Promise<RuntimeMessage<TPayload> | null>Public method; parameters and return type are shown in the signature.

InMemoryMessageBusOptions

In Memory Message Bus Options interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { InMemoryMessageBusOptions } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface InMemoryMessageBusOptions {
    trace?: TraceRecorder;
    now?: () => string;
    maxDeliveryAttempts?: number;
    initialRetryDelayMs?: number;
    maxRetryDelayMs?: number;
    retryMultiplier?: number;
}

Contract members

MemberKindSignatureDescription
initialRetryDelayMspropertyinitialRetryDelayMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxDeliveryAttemptspropertymaxDeliveryAttempts?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxRetryDelayMspropertymaxRetryDelayMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
retryMultiplierpropertyretryMultiplier?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
tracepropertytrace?: TraceRecorderPublic property; its type, readonly modifier and optionality are shown in the signature.

MessageAckInput

Message Ack Input interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { MessageAckInput } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface MessageAckInput {
    id: string;
    userId: string;
    sessionId: string;
    runId?: string;
    handledBy?: MessageAddress;
    timestamp?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
handledBypropertyhandledBy?: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
timestamppropertytimestamp?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MessageAddress

Message Address interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { MessageAddress } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface MessageAddress {
    kind: MessageAddressKind;
    id: string;
}

Contract members

MemberKindSignatureDescription
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
kindpropertykind: MessageAddressKindPublic property; its type, readonly modifier and optionality are shown in the signature.

MessageBus

Message Bus interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { MessageBus } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface MessageBus {
    publish<TPayload = unknown>(input: PublishMessageInput<TPayload>): Promise<RuntimeMessage<TPayload>>;
    pull<TPayload = unknown>(filter: PullMessageFilter): Promise<RuntimeMessage<TPayload> | null>;
    acknowledge(input: MessageAckInput): Promise<RuntimeMessage | null>;
    fail(input: MessageFailInput): Promise<RuntimeMessage | null>;
    list(filter?: MessageListFilter): Promise<RuntimeMessage[]>;
}

Contract members

MemberKindSignatureDescription
acknowledgemethodacknowledge(input: MessageAckInput): Promise<RuntimeMessage | null>Public method; parameters and return type are shown in the signature.
failmethodfail(input: MessageFailInput): Promise<RuntimeMessage | null>Public method; parameters and return type are shown in the signature.
listmethodlist(filter?: MessageListFilter): Promise<RuntimeMessage[]>Public method; parameters and return type are shown in the signature.
publishmethodpublish<TPayload = unknown>(input: PublishMessageInput<TPayload>): Promise<RuntimeMessage<TPayload>>Public method; parameters and return type are shown in the signature.
pullmethodpull<TPayload = unknown>(filter: PullMessageFilter): Promise<RuntimeMessage<TPayload> | null>Public method; parameters and return type are shown in the signature.

MessageFailInput

Message Fail Input interface with 11 public fields or methods.

  • Kind: interface
  • Import: import type { MessageFailInput } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface MessageFailInput extends MessageAckInput {
    reason?: string;
    deadLetter?: boolean;
    retry?: boolean;
    retryAfterMs?: number;
}

Contract members

MemberKindSignatureDescription
deadLetterpropertydeadLetter?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
handledBypropertyhandledBy?: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
retrypropertyretry?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
retryAfterMspropertyretryAfterMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
timestamppropertytimestamp?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MessageListFilter

Message List Filter interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { MessageListFilter } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface MessageListFilter {
    userId?: string;
    sessionId?: string;
    runId?: string;
    to?: MessageAddress;
    status?: MessageStatus;
}

Contract members

MemberKindSignatureDescription
runIdpropertyrunId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus?: MessageStatusPublic property; its type, readonly modifier and optionality are shown in the signature.
topropertyto?: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

PublishMessageInput

Publish Message Input interface with 16 public fields or methods.

  • Kind: interface
  • Import: import type { PublishMessageInput } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface PublishMessageInput<TPayload = unknown> {
    id: string;
    type: string;
    userId: string;
    sessionId: string;
    runId: string;
    from: MessageAddress;
    to: MessageAddress;
    payload: TPayload;
    stepId?: string;
    agentId?: string;
    fsmState?: string;
    correlationId?: string;
    causationId?: string;
    availableAt?: string;
    expiresAt?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
availableAtpropertyavailableAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
causationIdpropertycausationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
correlationIdpropertycorrelationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
frompropertyfrom: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
fsmStatepropertyfsmState?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
payloadpropertypayload: TPayloadPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
stepIdpropertystepId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
topropertyto: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

PullMessageFilter

Pull Message Filter interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { PullMessageFilter } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface PullMessageFilter {
    userId: string;
    sessionId: string;
    to: MessageAddress;
    runId?: string;
    fsmState?: string;
    now?: string;
}

Contract members

MemberKindSignatureDescription
fsmStatepropertyfsmState?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
nowpropertynow?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
topropertyto: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeMessage

Runtime Message interface with 20 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeMessage } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export interface RuntimeMessage<TPayload = unknown> {
    id: string;
    type: string;
    userId: string;
    sessionId: string;
    runId: string;
    from: MessageAddress;
    to: MessageAddress;
    payload: TPayload;
    status: MessageStatus;
    createdAt: string;
    updatedAt: string;
    stepId?: string;
    agentId?: string;
    fsmState?: string;
    correlationId?: string;
    causationId?: string;
    availableAt?: string;
    expiresAt?: string;
    attemptCount: number;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
agentIdpropertyagentId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
attemptCountpropertyattemptCount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
availableAtpropertyavailableAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
causationIdpropertycausationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
correlationIdpropertycorrelationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
frompropertyfrom: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
fsmStatepropertyfsmState?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
payloadpropertypayload: TPayloadPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sessionIdpropertysessionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: MessageStatusPublic property; its type, readonly modifier and optionality are shown in the signature.
stepIdpropertystepId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
topropertyto: MessageAddressPublic property; its type, readonly modifier and optionality are shown in the signature.
typepropertytype: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
updatedAtpropertyupdatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

MessageAddressKind

Public type alias for Message Address Kind; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MessageAddressKind } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export type MessageAddressKind = 'runtime' | 'session' | 'workflow' | 'agent' | 'tool' | 'human';

MessageStatus

Public type alias for Message Status; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { MessageStatus } from '@codesoul-co/hypha-harness';
  • Source module: message-bus

Declaration

text
export type MessageStatus = 'queued' | 'delivered' | 'acknowledged' | 'failed' | 'dead_lettered';