@codesoul-co/hypha-core / modules/runtime/session-command-worker
- Package index:
@codesoul-co/hypha-core - Source:
packages/core/src/modules/runtime/session-command-worker.ts - Exports: 7
Using this module
Use the Session command worker module for executing runtime behavior at this boundary. It exports 1 class, 3 interfaces, 3 types.
Import from the package entrypoint
import {
DurableSessionCommandWorker,
} from '@codesoul-co/hypha-core';
import type {
DurableSessionCommandWorkerOptions,
SessionCommandHandlerContext,
SessionCommandWorkerResult,
SessionCommandHandler,
SessionCommandHandlerResult,
SessionCommandWorkerDisposition,
} from '@codesoul-co/hypha-core';Usage patterns
- Use the 6 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
| Symbol | Kind | Signature | Description |
|---|---|---|---|
DurableSessionCommandWorker | class | new DurableSessionCommandWorker(options: DurableSessionCommandWorkerOptions): DurableSessionCommandWorker | Claims and resolves one durable Session command without owning a polling loop. Command handlers must explicitly classify expected retry and failure outcomes. |
DurableSessionCommandWorkerOptions | interface | interface DurableSessionCommandWorkerOptions | Durable Session Command Worker Options interface with 11 public fields or methods. |
SessionCommandHandlerContext | interface | interface SessionCommandHandlerContext | Session Command Handler Context interface with 4 public fields or methods. |
SessionCommandWorkerResult | interface | interface SessionCommandWorkerResult | Session Command Worker Result interface with 5 public fields or methods. |
SessionCommandHandler | type | type SessionCommandHandler = (context: Readonly<SessionCommandHandlerContext>) => Promise<SessionCommandHandlerResult> | Public type alias for Session Command Handler; the declaration contains its complete type expression. |
SessionCommandHandlerResult | type | type SessionCommandHandlerResult = { disposition: 'applied'; resultRunId?: string; resultEventIds?: string[]; } | { disposition: 'retry'; availableAt?: string; } | { disposition: 'failed'; rejectionCode: string; deadLetter?: boolean; } | Public type alias for Session Command Handler Result; the declaration contains its complete type expression. |
SessionCommandWorkerDisposition | type | type SessionCommandWorkerDisposition = 'idle' | 'applied' | 'retry_scheduled' | 'failed' | 'dead_lettered' | 'lease_lost' | 'aborted' | Public type alias for Session Command Worker Disposition; the declaration contains its complete type expression. |
DurableSessionCommandWorker
Claims and resolves one durable Session command without owning a polling loop. Command handlers must explicitly classify expected retry and failure outcomes.
- Kind: class
- Import:
import { DurableSessionCommandWorker } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export declare class DurableSessionCommandWorker {
constructor(options: DurableSessionCommandWorkerOptions);
processNext(scope?: SessionQueueScope, signal?: AbortSignal): Promise<SessionCommandWorkerResult>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
constructor | constructor | (options: DurableSessionCommandWorkerOptions): DurableSessionCommandWorker | Creates an instance of this class. |
processNext | method | processNext(scope?: SessionQueueScope, signal?: AbortSignal): Promise<SessionCommandWorkerResult> | Public method; parameters and return type are shown in the signature. |
DurableSessionCommandWorkerOptions
Durable Session Command Worker Options interface with 11 public fields or methods.
- Kind: interface
- Import:
import type { DurableSessionCommandWorkerOptions } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export interface DurableSessionCommandWorkerOptions {
queue: SessionQueue;
workerId: string;
leaseMs: number;
handlers: Partial<Record<SessionCommandType, SessionCommandHandler>>;
now?: () => string;
renewalIntervalMs?: number;
maxHandlerDurationMs?: number;
wait?: (delayMs: number, signal: AbortSignal) => Promise<void>;
onLeaseRenewalFailure?: (error: unknown, claim: Readonly<SessionCommandClaim>) => void;
operationalTelemetry?: RuntimeOperationalTelemetry;
monotonicNow?: () => number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
handlers | property | handlers: Partial<Record<"user_input" | "cancel" | "signal" | "start_run" | "resume" | "transition" | "continue_react" | "close_session", SessionCommandHandler>> | Public property; its type, readonly modifier and optionality are shown in the signature. |
leaseMs | property | leaseMs: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxHandlerDurationMs | property | maxHandlerDurationMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
monotonicNow | method | monotonicNow?(): number | Public method; parameters and return type are shown in the signature. |
now | method | now?(): string | Public method; parameters and return type are shown in the signature. |
onLeaseRenewalFailure | method | onLeaseRenewalFailure?(error: unknown, claim: Readonly<SessionCommandClaim>): void | Public method; parameters and return type are shown in the signature. |
operationalTelemetry | property | operationalTelemetry?: RuntimeOperationalTelemetry | Public property; its type, readonly modifier and optionality are shown in the signature. |
queue | property | queue: SessionQueue | Public property; its type, readonly modifier and optionality are shown in the signature. |
renewalIntervalMs | property | renewalIntervalMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
wait | method | wait?(delayMs: number, signal: AbortSignal): Promise<void> | Public method; parameters and return type are shown in the signature. |
workerId | property | workerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
SessionCommandHandlerContext
Session Command Handler Context interface with 4 public fields or methods.
- Kind: interface
- Import:
import type { SessionCommandHandlerContext } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export interface SessionCommandHandlerContext {
command: Readonly<SessionCommandRecord>;
signal: AbortSignal;
claimToken: string;
leaseEpoch: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
claimToken | property | claimToken: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
command | property | command: Readonly<SessionCommandRecord> | Public property; its type, readonly modifier and optionality are shown in the signature. |
leaseEpoch | property | leaseEpoch: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
signal | property | signal: AbortSignal | Public property; its type, readonly modifier and optionality are shown in the signature. |
SessionCommandWorkerResult
Session Command Worker Result interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { SessionCommandWorkerResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export interface SessionCommandWorkerResult {
disposition: SessionCommandWorkerDisposition;
commandId?: string;
commandType?: SessionCommandType;
attempts?: number;
rejectionCode?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
attempts | property | attempts?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
commandId | property | commandId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
commandType | property | commandType?: "user_input" | "cancel" | "signal" | "start_run" | "resume" | "transition" | "continue_react" | "close_session" | Public property; its type, readonly modifier and optionality are shown in the signature. |
disposition | property | disposition: SessionCommandWorkerDisposition | Public property; its type, readonly modifier and optionality are shown in the signature. |
rejectionCode | property | rejectionCode?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
SessionCommandHandler
Public type alias for Session Command Handler; the declaration contains its complete type expression.
- Kind: type
- Import:
import type { SessionCommandHandler } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export type SessionCommandHandler = (context: Readonly<SessionCommandHandlerContext>) => Promise<SessionCommandHandlerResult>;SessionCommandHandlerResult
Public type alias for Session Command Handler Result; the declaration contains its complete type expression.
- Kind: type
- Import:
import type { SessionCommandHandlerResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export type SessionCommandHandlerResult = {
disposition: 'applied';
resultRunId?: string;
resultEventIds?: string[];
} | {
disposition: 'retry';
availableAt?: string;
} | {
disposition: 'failed';
rejectionCode: string;
deadLetter?: boolean;
};SessionCommandWorkerDisposition
Public type alias for Session Command Worker Disposition; the declaration contains its complete type expression.
- Kind: type
- Import:
import type { SessionCommandWorkerDisposition } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/session-command-worker
Declaration
export type SessionCommandWorkerDisposition = 'idle' | 'applied' | 'retry_scheduled' | 'failed' | 'dead_lettered' | 'lease_lost' | 'aborted';