Skip to content

@codesoul-co/hypha-core / contracts/runtime-messages

Using this module

Use the Runtime messages module for declaring and runtime-validating contracts. It exports 3 constants, 4 interfaces, 3 types.

Import from the package entrypoint

ts
import {
  RUNTIME_INBOX_STATUSES,
  RUNTIME_MESSAGE_TYPES,
  RUNTIME_OUTBOX_STATES,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeMessageEnvelope,
  RuntimeMessageEnvelopeInput,
  RuntimeMessageInboxRecord,
  RuntimeMessageOutboxRecord,
  RuntimeMessageInboxStatus,
  RuntimeMessageOutboxState,
  RuntimeMessageType,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 7 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The 3 constant/enum exports provide stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
RUNTIME_INBOX_STATUSESconstantconst RUNTIME_INBOX_STATUSES: readonly ["processing", "applied", "ignored", "failed"]RUNTIME INBOX STATUSES constant exported by the contracts/runtime-messages module.
RUNTIME_MESSAGE_TYPESconstantconst RUNTIME_MESSAGE_TYPES: readonly ["runtime.command.start", "runtime.command.resume", "runtime.command.cancel", "runtime.signal", "runtime.timer.fire", "runtime.activity.requested", "runtime.activity.completed", "runtime.activity.failed", "runtime.agent.message", "runtime.child.completed", "runtime.projection.rebuild", "runtime.recovery.requested", "runtime.custom"]RUNTIME MESSAGE TYPES constant exported by the contracts/runtime-messages module.
RUNTIME_OUTBOX_STATESconstantconst RUNTIME_OUTBOX_STATES: readonly ["pending", "publishing", "published", "failed", "dead_letter"]RUNTIME OUTBOX STATES constant exported by the contracts/runtime-messages module.
RuntimeMessageEnvelopeinterfaceinterface RuntimeMessageEnvelopeRuntime Message Envelope interface with 28 public fields or methods.
RuntimeMessageEnvelopeInputinterfaceinterface RuntimeMessageEnvelopeInput extends Omit<RuntimeMessageEnvelope<TPayload>, 'payloadHash' | 'sequence'>Runtime Message Envelope Input interface with 28 public fields or methods.
RuntimeMessageInboxRecordinterfaceinterface RuntimeMessageInboxRecordRuntime Message Inbox Record interface with 12 public fields or methods.
RuntimeMessageOutboxRecordinterfaceinterface RuntimeMessageOutboxRecordRuntime Message Outbox Record interface with 14 public fields or methods.
RuntimeMessageInboxStatustypetype RuntimeMessageInboxStatus = (typeof RUNTIME_INBOX_STATUSES)[number]Public type alias for Runtime Message Inbox Status; the declaration contains its complete type expression.
RuntimeMessageOutboxStatetypetype RuntimeMessageOutboxState = (typeof RUNTIME_OUTBOX_STATES)[number]Public type alias for Runtime Message Outbox State; the declaration contains its complete type expression.
RuntimeMessageTypetypetype RuntimeMessageType = (typeof RUNTIME_MESSAGE_TYPES)[number]Public type alias for Runtime Message Type; the declaration contains its complete type expression.

RUNTIME_INBOX_STATUSES

RUNTIME INBOX STATUSES constant exported by the contracts/runtime-messages module.

Declaration

text
export declare const RUNTIME_INBOX_STATUSES: readonly ["processing", "applied", "ignored", "failed"];

RUNTIME_MESSAGE_TYPES

RUNTIME MESSAGE TYPES constant exported by the contracts/runtime-messages module.

Declaration

text
export declare const RUNTIME_MESSAGE_TYPES: readonly ["runtime.command.start", "runtime.command.resume", "runtime.command.cancel", "runtime.signal", "runtime.timer.fire", "runtime.activity.requested", "runtime.activity.completed", "runtime.activity.failed", "runtime.agent.message", "runtime.child.completed", "runtime.projection.rebuild", "runtime.recovery.requested", "runtime.custom"];

RUNTIME_OUTBOX_STATES

RUNTIME OUTBOX STATES constant exported by the contracts/runtime-messages module.

Declaration

text
export declare const RUNTIME_OUTBOX_STATES: readonly ["pending", "publishing", "published", "failed", "dead_letter"];

RuntimeMessageEnvelope

Runtime Message Envelope interface with 28 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeMessageEnvelope } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-messages

Declaration

text
export interface RuntimeMessageEnvelope<TPayload = unknown> {
    messageId: string;
    messageType: RuntimeMessageType;
    schemaVersion: string;
    topic: string;
    partitionKey: string;
    orderingKey?: string;
    sequence?: number;
    tenantId?: string;
    workspaceId?: string;
    userId?: string;
    sessionId?: string;
    runId?: string;
    stepId?: string;
    activityId?: string;
    agentId?: string;
    correlationId?: string;
    causationId?: string;
    traceId?: string;
    principal?: RuntimePrincipal;
    payload: TPayload;
    payloadHash: string;
    priority?: number;
    availableAt?: string;
    expiresAt?: string;
    publishedAt: string;
    producerId: string;
    producerRevision?: string;
    metadata?: Record<string, unknown>;
}

Contract members

MemberKindSignatureDescription
activityIdpropertyactivityId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
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.
messageIdpropertymessageId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
messageTypepropertymessageType: "runtime.activity.requested" | "runtime.activity.completed" | "runtime.activity.failed" | "runtime.command.start" | "runtime.command.resume" | "runtime.command.cancel" | "runtime.signal" | "runtime.timer.fire" | "runtime.agent.message" | "runtime.child.completed" | "runtime.projection.rebuild" | "runtime.recovery.requested" | "runtime.custom"Public 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.
orderingKeypropertyorderingKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
partitionKeypropertypartitionKey: stringPublic 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.
payloadHashpropertypayloadHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
principalpropertyprincipal?: RuntimePrincipalPublic property; its type, readonly modifier and optionality are shown in the signature.
prioritypropertypriority?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
producerIdpropertyproducerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
producerRevisionpropertyproducerRevision?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
publishedAtpropertypublishedAt: 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.
schemaVersionpropertyschemaVersion: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sequencepropertysequence?: numberPublic 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.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
topicpropertytopic: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
traceIdpropertytraceId?: 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.
workspaceIdpropertyworkspaceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeMessageEnvelopeInput

Runtime Message Envelope Input interface with 28 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeMessageEnvelopeInput } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-messages

Declaration

text
export interface RuntimeMessageEnvelopeInput<TPayload = unknown> extends Omit<RuntimeMessageEnvelope<TPayload>, 'payloadHash' | 'sequence'> {
    payloadHash?: string;
    sequence?: number;
}

Contract members

MemberKindSignatureDescription
activityIdpropertyactivityId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
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.
messageIdpropertymessageId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
messageTypepropertymessageType: "runtime.activity.requested" | "runtime.activity.completed" | "runtime.activity.failed" | "runtime.command.start" | "runtime.command.resume" | "runtime.command.cancel" | "runtime.signal" | "runtime.timer.fire" | "runtime.agent.message" | "runtime.child.completed" | "runtime.projection.rebuild" | "runtime.recovery.requested" | "runtime.custom"Public 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.
orderingKeypropertyorderingKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
partitionKeypropertypartitionKey: stringPublic 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.
payloadHashpropertypayloadHash?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
principalpropertyprincipal?: RuntimePrincipalPublic property; its type, readonly modifier and optionality are shown in the signature.
prioritypropertypriority?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
producerIdpropertyproducerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
producerRevisionpropertyproducerRevision?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
publishedAtpropertypublishedAt: 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.
schemaVersionpropertyschemaVersion: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
sequencepropertysequence?: numberPublic 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.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
topicpropertytopic: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
traceIdpropertytraceId?: 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.
workspaceIdpropertyworkspaceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeMessageInboxRecord

Runtime Message Inbox Record interface with 12 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeMessageInboxRecord } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-messages

Declaration

text
export interface RuntimeMessageInboxRecord {
    consumerId: string;
    messageId: string;
    payloadHash: string;
    status: RuntimeMessageInboxStatus;
    appliedEventIds?: string[];
    firstReceivedAt: string;
    lastReceivedAt: string;
    attempts: number;
    expiresAt?: string;
    processingOwner?: string;
    processingExpiresAt?: string;
    lastError?: NormalizedRuntimeError;
}

Contract members

MemberKindSignatureDescription
appliedEventIdspropertyappliedEventIds?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
attemptspropertyattempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
consumerIdpropertyconsumerId: 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.
firstReceivedAtpropertyfirstReceivedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
lastErrorpropertylastError?: NormalizedRuntimeErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
lastReceivedAtpropertylastReceivedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
messageIdpropertymessageId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
payloadHashpropertypayloadHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
processingExpiresAtpropertyprocessingExpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
processingOwnerpropertyprocessingOwner?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "failed" | "processing" | "applied" | "ignored"Public property; its type, readonly modifier and optionality are shown in the signature.

RuntimeMessageOutboxRecord

Runtime Message Outbox Record interface with 14 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeMessageOutboxRecord } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-messages

Declaration

text
export interface RuntimeMessageOutboxRecord {
    id: string;
    eventId?: string;
    messageId: string;
    topic: string;
    partitionKey: string;
    envelope: RuntimeMessageEnvelope;
    state: RuntimeMessageOutboxState;
    attempts: number;
    availableAt: string;
    leaseOwner?: string;
    leaseExpiresAt?: string;
    lastError?: NormalizedRuntimeError;
    createdAt: string;
    updatedAt: string;
}

Contract members

MemberKindSignatureDescription
attemptspropertyattempts: 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.
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
envelopepropertyenvelope: RuntimeMessageEnvelope<unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
eventIdpropertyeventId?: 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.
lastErrorpropertylastError?: NormalizedRuntimeErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseExpiresAtpropertyleaseExpiresAt?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseOwnerpropertyleaseOwner?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
messageIdpropertymessageId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
partitionKeypropertypartitionKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statepropertystate: "failed" | "pending" | "publishing" | "published" | "dead_letter"Public property; its type, readonly modifier and optionality are shown in the signature.
topicpropertytopic: 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.

RuntimeMessageInboxStatus

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

  • Kind: type
  • Import: import type { RuntimeMessageInboxStatus } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-messages

Declaration

text
export type RuntimeMessageInboxStatus = (typeof RUNTIME_INBOX_STATUSES)[number];

RuntimeMessageOutboxState

Public type alias for Runtime Message Outbox State; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { RuntimeMessageOutboxState } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-messages

Declaration

text
export type RuntimeMessageOutboxState = (typeof RUNTIME_OUTBOX_STATES)[number];

RuntimeMessageType

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

Declaration

text
export type RuntimeMessageType = (typeof RUNTIME_MESSAGE_TYPES)[number];