Skip to content

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

Using this module

Use the Runtime activities module for declaring and runtime-validating contracts. It exports 3 constants, 9 interfaces, 8 types.

Import from the package entrypoint

ts
import {
  RUNTIME_ACTIVITY_EFFECTS,
  RUNTIME_ACTIVITY_OBSERVATION_STATUSES,
  RUNTIME_ACTIVITY_TYPES,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeActivityDispatchPort,
  RuntimeActivityHelper,
  RuntimeActivityInvocation,
  RuntimeActivityLifecycleCommitPort,
  RuntimeActivityLifecycleCommitRequest,
  RuntimeActivityObservation,
  RuntimeActivityOptions,
  RuntimeActivityRequest,
} from '@codesoul-co/hypha-core';

// The complete export list is documented below.

Usage patterns

  • Use the 17 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_ACTIVITY_EFFECTSconstantconst RUNTIME_ACTIVITY_EFFECTS: readonly ["pure", "idempotent", "external_effect", "irreversible"]RUNTIME ACTIVITY EFFECTS constant exported by the contracts/runtime-activities module.
RUNTIME_ACTIVITY_OBSERVATION_STATUSESconstantconst RUNTIME_ACTIVITY_OBSERVATION_STATUSES: readonly ["completed", "failed", "waiting", "cancelled"]RUNTIME ACTIVITY OBSERVATION STATUSES constant exported by the contracts/runtime-activities module.
RUNTIME_ACTIVITY_TYPESconstantconst RUNTIME_ACTIVITY_TYPES: readonly ["tool", "memory", "model", "execution", "custom"]RUNTIME ACTIVITY TYPES constant exported by the contracts/runtime-activities module.
RuntimeActivityDispatchPortinterfaceinterface RuntimeActivityDispatchPortRuntime Activity Dispatch Port interface with 1 public fields or methods.
RuntimeActivityHelperinterfaceinterface RuntimeActivityHelperRuntime Activity Helper interface with 5 public fields or methods.
RuntimeActivityInvocationinterfaceinterface RuntimeActivityInvocationRuntime Activity Invocation interface with 17 public fields or methods.
RuntimeActivityLifecycleCommitPortinterfaceinterface RuntimeActivityLifecycleCommitPortRuntime Activity Lifecycle Commit Port interface with 1 public fields or methods.
RuntimeActivityLifecycleCommitRequestinterfaceinterface RuntimeActivityLifecycleCommitRequestRuntime Activity Lifecycle Commit Request interface with 4 public fields or methods.
RuntimeActivityObservationinterfaceinterface RuntimeActivityObservationRuntime Activity Observation interface with 8 public fields or methods.
RuntimeActivityOptionsinterfaceinterface RuntimeActivityOptionsRuntime Activity Options interface with 6 public fields or methods.
RuntimeActivityRequestinterfaceinterface RuntimeActivityRequestRuntime Activity Request interface with 3 public fields or methods.
RuntimeActivityRetryOptionsinterfaceinterface RuntimeActivityRetryOptionsRuntime Activity Retry Options interface with 3 public fields or methods.
RuntimeActivityEffecttypetype RuntimeActivityEffect = (typeof RUNTIME_ACTIVITY_EFFECTS)[number]Public type alias for Runtime Activity Effect; the declaration contains its complete type expression.
RuntimeActivityObservationStatustypetype RuntimeActivityObservationStatus = (typeof RUNTIME_ACTIVITY_OBSERVATION_STATUSES)[number]Public type alias for Runtime Activity Observation Status; the declaration contains its complete type expression.
RuntimeActivityTypetypetype RuntimeActivityType = (typeof RUNTIME_ACTIVITY_TYPES)[number]Public type alias for Runtime Activity Type; the declaration contains its complete type expression.
RuntimeCustomActivityRequesttypetype RuntimeCustomActivityRequest = RuntimeActivityRequest<TInput>Public type alias for Runtime Custom Activity Request; the declaration contains its complete type expression.
RuntimeExecutionActivityRequesttypetype RuntimeExecutionActivityRequest = RuntimeActivityRequest<TInput>Public type alias for Runtime Execution Activity Request; the declaration contains its complete type expression.
RuntimeMemoryActivityRequesttypetype RuntimeMemoryActivityRequest = RuntimeActivityRequest<TInput>Public type alias for Runtime Memory Activity Request; the declaration contains its complete type expression.
RuntimeModelActivityRequesttypetype RuntimeModelActivityRequest = RuntimeActivityRequest<TInput>Public type alias for Runtime Model Activity Request; the declaration contains its complete type expression.
RuntimeToolActivityRequesttypetype RuntimeToolActivityRequest = RuntimeActivityRequest<TInput>Public type alias for Runtime Tool Activity Request; the declaration contains its complete type expression.

RUNTIME_ACTIVITY_EFFECTS

RUNTIME ACTIVITY EFFECTS constant exported by the contracts/runtime-activities module.

Declaration

text
export declare const RUNTIME_ACTIVITY_EFFECTS: readonly ["pure", "idempotent", "external_effect", "irreversible"];

RUNTIME_ACTIVITY_OBSERVATION_STATUSES

RUNTIME ACTIVITY OBSERVATION STATUSES constant exported by the contracts/runtime-activities module.

  • Kind: constant
  • Import: import { RUNTIME_ACTIVITY_OBSERVATION_STATUSES } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-activities

Declaration

text
export declare const RUNTIME_ACTIVITY_OBSERVATION_STATUSES: readonly ["completed", "failed", "waiting", "cancelled"];

RUNTIME_ACTIVITY_TYPES

RUNTIME ACTIVITY TYPES constant exported by the contracts/runtime-activities module.

Declaration

text
export declare const RUNTIME_ACTIVITY_TYPES: readonly ["tool", "memory", "model", "execution", "custom"];

RuntimeActivityDispatchPort

Runtime Activity Dispatch Port interface with 1 public fields or methods.

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

Declaration

text
export interface RuntimeActivityDispatchPort {
    dispatch(invocation: RuntimeActivityInvocation, abortSignal: AbortSignal): Promise<RuntimeActivityObservation>;
}

Contract members

MemberKindSignatureDescription
dispatchmethoddispatch(invocation: RuntimeActivityInvocation, abortSignal: AbortSignal): Promise<RuntimeActivityObservation>Public method; parameters and return type are shown in the signature.

RuntimeActivityHelper

Runtime Activity Helper interface with 5 public fields or methods.

Declaration

text
export interface RuntimeActivityHelper {
    tool(request: RuntimeToolActivityRequest): Promise<RuntimeActivityObservation>;
    memory(request: RuntimeMemoryActivityRequest): Promise<RuntimeActivityObservation>;
    model(request: RuntimeModelActivityRequest): Promise<RuntimeActivityObservation>;
    execution(request: RuntimeExecutionActivityRequest): Promise<RuntimeActivityObservation>;
    custom(request: RuntimeCustomActivityRequest): Promise<RuntimeActivityObservation>;
}

Contract members

MemberKindSignatureDescription
custommethodcustom(request: RuntimeCustomActivityRequest): Promise<RuntimeActivityObservation>Public method; parameters and return type are shown in the signature.
executionmethodexecution(request: RuntimeExecutionActivityRequest): Promise<RuntimeActivityObservation>Public method; parameters and return type are shown in the signature.
memorymethodmemory(request: RuntimeMemoryActivityRequest): Promise<RuntimeActivityObservation>Public method; parameters and return type are shown in the signature.
modelmethodmodel(request: RuntimeModelActivityRequest): Promise<RuntimeActivityObservation>Public method; parameters and return type are shown in the signature.
toolmethodtool(request: RuntimeToolActivityRequest): Promise<RuntimeActivityObservation>Public method; parameters and return type are shown in the signature.

RuntimeActivityInvocation

Runtime Activity Invocation interface with 17 public fields or methods.

Declaration

text
export interface RuntimeActivityInvocation<TInput extends RuntimeJsonValue = RuntimeJsonValue> {
    activityId: string;
    operationId: string;
    activityType: RuntimeActivityType;
    target: string;
    input: TInput;
    scope: RuntimeScope;
    stateId: string;
    stateAttempt: number;
    fencingToken: number;
    correlationId: string;
    causationId?: string;
    idempotencyKey: string;
    requestedAt: string;
    effect: RuntimeActivityEffect;
    timeoutMs?: number;
    retry?: RuntimeActivityRetryOptions;
    metadata?: Record<string, RuntimeJsonValue>;
}

Contract members

MemberKindSignatureDescription
activityIdpropertyactivityId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
activityTypepropertyactivityType: "memory" | "tool" | "model" | "custom" | "execution"Public 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.
effectpropertyeffect: "external_effect" | "irreversible" | "pure" | "idempotent"Public property; its type, readonly modifier and optionality are shown in the signature.
fencingTokenpropertyfencingToken: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
inputpropertyinput: TInputPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, RuntimeJsonValue>Public property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestedAtpropertyrequestedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
retrypropertyretry?: RuntimeActivityRetryOptionsPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: RuntimeScopePublic property; its type, readonly modifier and optionality are shown in the signature.
stateAttemptpropertystateAttempt: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
stateIdpropertystateId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
targetpropertytarget: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
timeoutMspropertytimeoutMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityLifecycleCommitPort

Runtime Activity Lifecycle Commit Port interface with 1 public fields or methods.

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

Declaration

text
export interface RuntimeActivityLifecycleCommitPort {
    append(request: RuntimeActivityLifecycleCommitRequest): Promise<FrameworkEvent>;
}

Contract members

MemberKindSignatureDescription
appendmethodappend(request: RuntimeActivityLifecycleCommitRequest): Promise<FrameworkEvent>Public method; parameters and return type are shown in the signature.

RuntimeActivityLifecycleCommitRequest

Runtime Activity Lifecycle Commit Request interface with 4 public fields or methods.

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

Declaration

text
export interface RuntimeActivityLifecycleCommitRequest {
    execution: RuntimeHelperExecutionScope;
    event: EventCreateInput;
    fencingToken: number;
    idempotencyKey: string;
}

Contract members

MemberKindSignatureDescription
eventpropertyevent: EventCreateInput<unknown>Public property; its type, readonly modifier and optionality are shown in the signature.
executionpropertyexecution: RuntimeHelperExecutionScopePublic property; its type, readonly modifier and optionality are shown in the signature.
fencingTokenpropertyfencingToken: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityObservation

Runtime Activity Observation interface with 8 public fields or methods.

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

Declaration

text
export interface RuntimeActivityObservation<TOutput extends RuntimeJsonValue = RuntimeJsonValue> {
    activityId: string;
    status: RuntimeActivityObservationStatus;
    eventIds: string[];
    output?: TOutput;
    artifactRefs?: string[];
    retryable?: boolean;
    error?: NormalizedRuntimeError;
    metadata?: Record<string, RuntimeJsonValue>;
}

Contract members

MemberKindSignatureDescription
activityIdpropertyactivityId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
artifactRefspropertyartifactRefs?: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
errorpropertyerror?: NormalizedRuntimeErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
eventIdspropertyeventIds: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, RuntimeJsonValue>Public property; its type, readonly modifier and optionality are shown in the signature.
outputpropertyoutput?: TOutputPublic property; its type, readonly modifier and optionality are shown in the signature.
retryablepropertyretryable?: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "completed" | "cancelled" | "failed" | "waiting"Public property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityOptions

Runtime Activity Options interface with 6 public fields or methods.

Declaration

text
export interface RuntimeActivityOptions {
    effect?: RuntimeActivityEffect;
    timeoutMs?: number;
    retry?: RuntimeActivityRetryOptions;
    idempotencyKey?: string;
    causationId?: string;
    metadata?: Record<string, RuntimeJsonValue>;
}

Contract members

MemberKindSignatureDescription
causationIdpropertycausationId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
effectpropertyeffect?: "external_effect" | "irreversible" | "pure" | "idempotent"Public property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
metadatapropertymetadata?: Record<string, RuntimeJsonValue>Public property; its type, readonly modifier and optionality are shown in the signature.
retrypropertyretry?: RuntimeActivityRetryOptionsPublic property; its type, readonly modifier and optionality are shown in the signature.
timeoutMspropertytimeoutMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityRequest

Runtime Activity Request interface with 3 public fields or methods.

Declaration

text
export interface RuntimeActivityRequest<TInput extends RuntimeJsonValue = RuntimeJsonValue> {
    target: string;
    input: TInput;
    options?: RuntimeActivityOptions;
}

Contract members

MemberKindSignatureDescription
inputpropertyinput: TInputPublic property; its type, readonly modifier and optionality are shown in the signature.
optionspropertyoptions?: RuntimeActivityOptionsPublic property; its type, readonly modifier and optionality are shown in the signature.
targetpropertytarget: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityRetryOptions

Runtime Activity Retry Options interface with 3 public fields or methods.

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

Declaration

text
export interface RuntimeActivityRetryOptions {
    maxAttempts: number;
    initialDelayMs?: number;
    maxDelayMs?: number;
}

Contract members

MemberKindSignatureDescription
initialDelayMspropertyinitialDelayMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxAttemptspropertymaxAttempts: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
maxDelayMspropertymaxDelayMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityEffect

Public type alias for Runtime Activity Effect; the declaration contains its complete type expression.

Declaration

text
export type RuntimeActivityEffect = (typeof RUNTIME_ACTIVITY_EFFECTS)[number];

RuntimeActivityObservationStatus

Public type alias for Runtime Activity Observation Status; the declaration contains its complete type expression.

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

Declaration

text
export type RuntimeActivityObservationStatus = (typeof RUNTIME_ACTIVITY_OBSERVATION_STATUSES)[number];

RuntimeActivityType

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

Declaration

text
export type RuntimeActivityType = (typeof RUNTIME_ACTIVITY_TYPES)[number];

RuntimeCustomActivityRequest

Public type alias for Runtime Custom Activity Request; the declaration contains its complete type expression.

Declaration

text
export type RuntimeCustomActivityRequest<TInput extends RuntimeJsonValue = RuntimeJsonValue> = RuntimeActivityRequest<TInput>;

RuntimeExecutionActivityRequest

Public type alias for Runtime Execution Activity Request; the declaration contains its complete type expression.

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

Declaration

text
export type RuntimeExecutionActivityRequest<TInput extends RuntimeJsonValue = RuntimeJsonValue> = RuntimeActivityRequest<TInput>;

RuntimeMemoryActivityRequest

Public type alias for Runtime Memory Activity Request; the declaration contains its complete type expression.

Declaration

text
export type RuntimeMemoryActivityRequest<TInput extends RuntimeJsonValue = RuntimeJsonValue> = RuntimeActivityRequest<TInput>;

RuntimeModelActivityRequest

Public type alias for Runtime Model Activity Request; the declaration contains its complete type expression.

Declaration

text
export type RuntimeModelActivityRequest<TInput extends RuntimeJsonValue = RuntimeJsonValue> = RuntimeActivityRequest<TInput>;

RuntimeToolActivityRequest

Public type alias for Runtime Tool Activity Request; the declaration contains its complete type expression.

Declaration

text
export type RuntimeToolActivityRequest<TInput extends RuntimeJsonValue = RuntimeJsonValue> = RuntimeActivityRequest<TInput>;