Skip to content

@codesoul-co/hypha-harness / bounded-fsm-driver

模块用法

用于使用该功能边界的公共契约与操作。Bounded FSM driver 模块公开 1 类、5 接口、1 类型。

从包入口导入

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

import type {
  BoundedFSMDriverResult,
  BoundedFSMDriverRunInput,
  BoundedStateExecutionDecision,
  BoundedStateExecutorInput,
  FencedBoundedFSMDriverOptions,
  BoundedFSMDriverDisposition,
} from '@codesoul-co/hypha-harness';

使用要点

  • 6 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。

公共导出

Symbol种类签名说明
FencedBoundedFSMDrivernew FencedBoundedFSMDriver(options: FencedBoundedFSMDriverOptions): FencedBoundedFSMDriverFenced Bounded FSM Driver 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。
BoundedFSMDriverResult接口interface BoundedFSMDriverResultBounded FSM Driver Result 接口,共包含 4 个公开字段或方法。
BoundedFSMDriverRunInput接口interface BoundedFSMDriverRunInputBounded FSM Driver Run Input 接口,共包含 9 个公开字段或方法。
BoundedStateExecutionDecision接口interface BoundedStateExecutionDecisionBounded State Execution Decision 接口,共包含 3 个公开字段或方法。
BoundedStateExecutorInput接口interface BoundedStateExecutorInputBounded State Executor Input 接口,共包含 7 个公开字段或方法。
FencedBoundedFSMDriverOptions接口interface FencedBoundedFSMDriverOptionsFenced Bounded FSM Driver Options 接口,共包含 9 个公开字段或方法。
BoundedFSMDriverDisposition类型type BoundedFSMDriverDisposition = 'completed' | 'failed' | 'cancelled' | 'waiting' | 'budget_exhausted' | 'lease_unavailable' | 'state_claim_unavailable'Bounded FSM Driver Disposition 公共类型别名;完整类型表达式见声明。

FencedBoundedFSMDriver

Fenced Bounded FSM Driver 类,共公开 2 个构造函数或成员;精确签名见本条目的声明与成员表。

  • 种类: 类
  • 导入: import { FencedBoundedFSMDriver } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export declare class FencedBoundedFSMDriver {
    constructor(options: FencedBoundedFSMDriverOptions);
    run(input: BoundedFSMDriverRunInput): Promise<BoundedFSMDriverResult>;
}

公开成员

成员种类签名说明
constructor构造函数(options: FencedBoundedFSMDriverOptions): FencedBoundedFSMDriver创建该类的实例。
run方法run(input: BoundedFSMDriverRunInput): Promise<BoundedFSMDriverResult>公开方法;参数与返回类型以签名列为准。

BoundedFSMDriverResult

Bounded FSM Driver Result 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { BoundedFSMDriverResult } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export interface BoundedFSMDriverResult {
    disposition: BoundedFSMDriverDisposition;
    steps: number;
    projection: RuntimeOrchestrationProjection;
    wait?: RuntimeWaitIntent;
}

契约成员

成员种类签名说明
disposition属性disposition: BoundedFSMDriverDisposition公开属性;类型、只读和可选状态以签名列为准。
projection属性projection: RuntimeOrchestrationProjection公开属性;类型、只读和可选状态以签名列为准。
steps属性steps: number公开属性;类型、只读和可选状态以签名列为准。
wait属性wait?: RuntimeWaitIntent公开属性;类型、只读和可选状态以签名列为准。

BoundedFSMDriverRunInput

Bounded FSM Driver Run Input 接口,共包含 9 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { BoundedFSMDriverRunInput } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export interface BoundedFSMDriverRunInput {
    scope: RuntimeScope;
    process: FSMProcessSpec;
    ownerId: string;
    commandId?: string;
    maxSteps: number;
    leaseTtlMs: number;
    stateClaimTtlMs: number;
    deadlineAt?: string;
    abortSignal?: AbortSignal;
}

契约成员

成员种类签名说明
abortSignal属性abortSignal?: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
commandId属性commandId?: string公开属性;类型、只读和可选状态以签名列为准。
deadlineAt属性deadlineAt?: string公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
maxSteps属性maxSteps: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
process属性process: FSMProcessSpec公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
stateClaimTtlMs属性stateClaimTtlMs: number公开属性;类型、只读和可选状态以签名列为准。

BoundedStateExecutionDecision

Bounded State Execution Decision 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { BoundedStateExecutionDecision } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export interface BoundedStateExecutionDecision {
    result: RuntimeStateExecutionResult;
    transition?: RuntimeTransitionProposal;
    guardContext?: FSMGuardContext;
}

契约成员

成员种类签名说明
guardContext属性guardContext?: FSMGuardContext公开属性;类型、只读和可选状态以签名列为准。
result属性result: RuntimeStateExecutionResult公开属性;类型、只读和可选状态以签名列为准。
transition属性transition?: RuntimeTransitionProposal公开属性;类型、只读和可选状态以签名列为准。

BoundedStateExecutorInput

Bounded State Executor Input 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { BoundedStateExecutorInput } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export interface BoundedStateExecutorInput {
    scope: Readonly<RuntimeScope>;
    process: Readonly<FSMProcessSpec>;
    state: Readonly<FSMStateSpec>;
    projection: Readonly<RuntimeOrchestrationProjection>;
    runLease: Readonly<FencedRunLease>;
    stateClaim: Readonly<StateExecutionClaim>;
    abortSignal: AbortSignal;
}

契约成员

成员种类签名说明
abortSignal属性abortSignal: AbortSignal公开属性;类型、只读和可选状态以签名列为准。
process属性process: Readonly<FSMProcessSpec>公开属性;类型、只读和可选状态以签名列为准。
projection属性projection: Readonly<RuntimeOrchestrationProjection>公开属性;类型、只读和可选状态以签名列为准。
runLease属性runLease: Readonly<FencedRunLease>公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: Readonly<RuntimeScope>公开属性;类型、只读和可选状态以签名列为准。
state属性state: Readonly<FSMStateSpec>公开属性;类型、只读和可选状态以签名列为准。
stateClaim属性stateClaim: Readonly<StateExecutionClaim>公开属性;类型、只读和可选状态以签名列为准。

FencedBoundedFSMDriverOptions

Fenced Bounded FSM Driver Options 接口,共包含 9 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { FencedBoundedFSMDriverOptions } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export interface FencedBoundedFSMDriverOptions {
    events: EventRuntime;
    projections: ProjectionEngine;
    projectionStore: ProjectionStore<RuntimeOrchestrationProjection>;
    runLeases: RunLeaseStore;
    stateClaims: StateExecutionClaimStore;
    executeState(input: BoundedStateExecutorInput): Promise<BoundedStateExecutionDecision>;
    evaluateGuard?: (transition: Readonly<FSMTransitionSpec>, context: Readonly<FSMGuardContext>) => Promise<boolean> | boolean;
    now?: () => string;
    nextId?: (namespace: string) => string;
}

契约成员

成员种类签名说明
evaluateGuard方法evaluateGuard?(transition: Readonly<FSMTransitionSpec>, context: Readonly<FSMGuardContext>): Promise<boolean> | boolean公开方法;参数与返回类型以签名列为准。
events属性events: EventRuntime公开属性;类型、只读和可选状态以签名列为准。
executeState方法executeState(input: BoundedStateExecutorInput): Promise<BoundedStateExecutionDecision>公开方法;参数与返回类型以签名列为准。
nextId方法nextId?(namespace: string): string公开方法;参数与返回类型以签名列为准。
now方法now?(): string公开方法;参数与返回类型以签名列为准。
projections属性projections: ProjectionEngine公开属性;类型、只读和可选状态以签名列为准。
projectionStore属性projectionStore: ProjectionStore<RuntimeOrchestrationProjection>公开属性;类型、只读和可选状态以签名列为准。
runLeases属性runLeases: RunLeaseStore公开属性;类型、只读和可选状态以签名列为准。
stateClaims属性stateClaims: StateExecutionClaimStore公开属性;类型、只读和可选状态以签名列为准。

BoundedFSMDriverDisposition

Bounded FSM Driver Disposition 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { BoundedFSMDriverDisposition } from '@codesoul-co/hypha-harness';
  • 源码模块: bounded-fsm-driver

声明

text
export type BoundedFSMDriverDisposition = 'completed' | 'failed' | 'cancelled' | 'waiting' | 'budget_exhausted' | 'lease_unavailable' | 'state_claim_unavailable';