Skip to content

@codesoul-co/hypha-fsm / index

模块用法

聚合 @codesoul-co/hypha-fsm 的公共入口导出;应用应从包入口导入这些 Symbol,不应依赖内部文件路径。

从包入口导入

ts
import {
  FSMRuntime,
  defaultReActFSMProcessSpec,
  fsmProcessSpecDefinition,
  fsmProcessSpecExample,
  fsmProcessSpecJsonSchema,
  fsmProcessSpecSchema,
  fsmSpecDefinitions,
  fsmSpecJsonSchemas,
} from '@codesoul-co/hypha-fsm';

import type {
  FSMGuardContext,
  FSMProcessSpec,
  FSMRecoveryDecisionRecord,
  FSMRuntimeCancelOptions,
  FSMRuntimeOptions,
  FSMRuntimeTransitionOptions,
  FSMSnapshot,
  FSMStateEnteredRecord,
} from '@codesoul-co/hypha-fsm';

// 完整导出列表见下方。

使用要点

  • 19 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 17 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
  • 13 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

ts
import { fsmProcessSpecSchema } from '@codesoul-co/hypha-fsm';

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = fsmProcessSpecSchema.parse(input);

配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。

公共导出

Symbol种类签名说明
FSMRuntimenew FSMRuntime(spec: FSMProcessSpec, runId: string, options?: FSMRuntimeOptions, snapshot?: FSMSnapshot): FSMRuntimeFSM Runtime 类,共公开 8 个构造函数或成员;精确签名见本条目的声明与成员表。
defaultReActFSMProcessSpec常量const defaultReActFSMProcessSpec: FSMProcessSpecindex 模块导出的 Default ReAct FSM Process Spec 常量。
fsmProcessSpecDefinition常量const fsmProcessSpecDefinition: SpecSchemaDefinition<FSMProcessSpec>FSM Process Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。
fsmProcessSpecExample常量const fsmProcessSpecExample: FSMProcessSpecFSM Process Spec 的有效示例值。
fsmProcessSpecJsonSchema常量const fsmProcessSpecJsonSchema: JsonSchemaFSM Process Spec 的 JSON Schema。
fsmProcessSpecSchema常量const fsmProcessSpecSchema: z.ZodObject<{ id: z.ZodString; version: z.ZodString; } & { name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; owner: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; createdAt: z.ZodOptional<z.ZodString>; updatedAt: z.ZodOptional<z.ZodString>; } & { initialState: z.ZodString; states: z.ZodArray<z.ZodObject<{ name: z.ZodOptional<z....FSM Process Spec 的运行时 Schema。
fsmSpecDefinitions常量const fsmSpecDefinitions: readonly [SpecSchemaDefinition<FSMProcessSpec>]index 模块导出的 FSM Spec Definitions 常量。
fsmSpecJsonSchemas常量const fsmSpecJsonSchemas: Record<string, JsonSchema>index 模块导出的 FSM Spec JSON Schemas 常量。
fsmStateSpecSchema常量const fsmStateSpecSchema: z.ZodObject<{ name: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; owner: z.ZodOptional<z.ZodString>; tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; createdAt: z.ZodOptional<z.ZodString>; updatedAt: z.ZodOptional<z.ZodString>; } & { id: z.ZodString; kind: z.ZodOptional<z.ZodEnum<["idle", "run_initialized", "context_built", "reasoning", "action_selected", "poli...FSM State Spec 的运行时 Schema。
fsmTransitionSpecSchema常量const fsmTransitionSpecSchema: z.ZodObject<{ from: z.ZodString; to: z.ZodString; guard: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; traceEvent: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { from: string; to: string; description?: string | undefined; guard?: string | undefined; traceEvent?: string | undefined; }, { from: string; to: string; description?: string | undefined; guard?...FSM Transition Spec 的运行时 Schema。
HARNESS_FSM_STATE_IDS常量const HARNESS_FSM_STATE_IDS: readonly ["Idle", "RunInitialized", "ContextBuilt", "Reasoning", "ActionSelected", "PolicyChecked", "Acting", "ObservationRecorded", "Verifying", "MemorySync", "Recovering", "Compensating", "Quarantined", "HumanReview", "Completed", "Failed", "Cancelled"]Stable Harness states owned by the framework runtime. Domain Packs may bind capabilities and policy to these phases, but must not add, remove, rename, or reconnect them.
HARNESS_STATE_CAPABILITY_AREA常量const HARNESS_STATE_CAPABILITY_AREA: Readonly<Record<"Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled", HarnessCapabilityArea>>activity is the governed side-effect phase shared by Tool, MCP, Execution, file, Memory-write, and external-write adapters. The concrete activity type remains Event evidence; it never becomes a Domain-defined FSM state.
REACT_FSM_STATE_PATH常量const REACT_FSM_STATE_PATH: readonly ["Idle", "RunInitialized", "ContextBuilt", "Reasoning", "ActionSelected", "PolicyChecked", "Acting", "ObservationRecorded", "Verifying", "MemorySync", "Completed"]index 模块导出的 REACT FSM STATE PATH 常量。
REACT_PHASE_TO_HARNESS_STATE常量const REACT_PHASE_TO_HARNESS_STATE: Readonly<{ reason: "Reasoning"; select_action: "ActionSelected"; policy_check: "PolicyChecked"; act: "Acting"; observe_result: "ObservationRecorded"; verify: "Verifying"; memory_sync: "MemorySync"; complete: "Completed"; fail: "Failed"; human_review: "HumanReview"; cancel: "Cancelled"; }>index 模块导出的 REACT PHASE TO HARNESS STATE 常量。
analyzeFSMTopology函数analyzeFSMTopology(spec: FSMProcessSpec): FSMTopologyAnalysisDescribes graph properties without imposing product-specific topology rules. Callers can decide whether unreachable states, non-terminal dead ends, or cycles are valid for their Domain workflow.
applyTransition函数applyTransition(spec: FSMProcessSpec, snapshot: FSMSnapshot, to: string, nowOrOptions?: string | FSMTransitionOptions): FSMSnapshotApply Transition 函数,提供 1 个公开调用签名;参数与返回类型见下表。
applyTransitionWithRuntimePolicy函数applyTransitionWithRuntimePolicy(spec: FSMProcessSpec, snapshot: FSMSnapshot, to: string, options?: FSMRuntimeTransitionOptions): Promise<FSMSnapshot>Apply Transition With Runtime Policy 函数,提供 1 个公开调用签名;参数与返回类型见下表。
assertHarnessFSMProcessSpec函数assertHarnessFSMProcessSpec(spec: FSMProcessSpec): voidFails closed when an application or Domain Pack attempts to replace the Harness capability topology with a product workflow.
canRetryState函数canRetryState(spec: FSMProcessSpec, stateId: string, attemptedCount: number): booleanCan Retry State 函数,提供 1 个公开调用签名;参数与返回类型见下表。
createHarnessFSMProcessSpec函数createHarnessFSMProcessSpec(): FSMProcessSpecReturns an isolated copy so composition code cannot mutate the shared contract.
createInitialSnapshot函数createInitialSnapshot(spec: FSMProcessSpec, runId: string, now?: string): FSMSnapshotCreate Initial Snapshot 函数,提供 1 个公开调用签名;参数与返回类型见下表。
evaluateGuardExpression函数evaluateGuardExpression(guard: string, context?: FSMGuardContext): booleanEvaluate Guard Expression 函数,提供 1 个公开调用签名;参数与返回类型见下表。
evaluateStateTimeout函数evaluateStateTimeout(spec: FSMProcessSpec, snapshot: FSMSnapshot, now?: string): FSMTimeoutEvaluation | nullEvaluate State Timeout 函数,提供 1 个公开调用签名;参数与返回类型见下表。
getAllowedTransitions函数getAllowedTransitions(spec: FSMProcessSpec, stateId: string): FSMTransitionSpec[]Get Allowed Transitions 函数,提供 1 个公开调用签名;参数与返回类型见下表。
harnessStateForReActPhase函数harnessStateForReActPhase(phase: string): HarnessFSMStateId | undefinedHarness State For ReAct Phase 函数,提供 1 个公开调用签名;参数与返回类型见下表。
isHarnessFSMProcessSpec函数isHarnessFSMProcessSpec(spec: FSMProcessSpec): booleanReturns false for either an invalid process or a valid non-Harness topology.
isHarnessFSMStateId函数isHarnessFSMStateId(value: string): value is HarnessFSMStateIdIs Harness FSM State ID 函数,提供 1 个公开调用签名;参数与返回类型见下表。
parseFSMProcessSpec函数parseFSMProcessSpec(input: unknown): FSMProcessSpecParse FSM Process Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。
planHarnessCapabilityPath函数planHarnessCapabilityPath(from: HarnessFSMStateId, to: HarnessFSMStateId): HarnessFSMStateId[]Plans only normal capability movement. Recovery, compensation, quarantine, human review, failure, and cancellation are selected by their dedicated supervisors and can never be traversed as a shortcut for Domain work.
validateFSMProcessSpec函数validateFSMProcessSpec(spec: FSMProcessSpec): voidValidate FSM Process Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。
validateFSMSnapshot函数validateFSMSnapshot(spec: FSMProcessSpec, snapshot: FSMSnapshot, expectedRunId?: string): voidValidate FSM Snapshot 函数,提供 1 个公开调用签名;参数与返回类型见下表。
FSMGuardContext接口interface FSMGuardContextFSM Guard Context 接口,共包含 3 个公开字段或方法。
FSMProcessSpec接口interface FSMProcessSpec extends VersionedSpec, SpecMetadataFSM Process Spec 接口,共包含 13 个公开字段或方法。
FSMRecoveryDecisionRecord接口interface FSMRecoveryDecisionRecordFSM Recovery Decision Record 接口,共包含 4 个公开字段或方法。
FSMRuntimeCancelOptions接口interface FSMRuntimeCancelOptions extends FSMRuntimeTransitionOptionsFSM Runtime Cancel Options 接口,共包含 8 个公开字段或方法。
FSMRuntimeOptions接口interface FSMRuntimeOptionsFSM Runtime Options 接口,共包含 5 个公开字段或方法。
FSMRuntimeTransitionOptions接口interface FSMRuntimeTransitionOptions extends FSMTransitionOptionsFSM Runtime Transition Options 接口,共包含 7 个公开字段或方法。
FSMSnapshot接口interface FSMSnapshotFSM Snapshot 接口,共包含 8 个公开字段或方法。
FSMStateEnteredRecord接口interface FSMStateEnteredRecordFSM State Entered Record 接口,共包含 7 个公开字段或方法。
FSMStateSpec接口interface FSMStateSpec extends SpecMetadataFSM State Spec 接口,共包含 15 个公开字段或方法。
FSMTimeoutEvaluation接口interface FSMTimeoutEvaluationFSM Timeout Evaluation 接口,共包含 5 个公开字段或方法。
FSMTopologyAnalysis接口interface FSMTopologyAnalysisFSM Topology Analysis 接口,共包含 5 个公开字段或方法。
FSMTransitionOptions接口interface FSMTransitionOptionsFSM Transition Options 接口,共包含 3 个公开字段或方法。
FSMTransitionSpec接口interface FSMTransitionSpecFSM Transition Spec 接口,共包含 5 个公开字段或方法。
StateTransition接口interface StateTransitionState Transition 接口,共包含 8 个公开字段或方法。
FSMGuardEvaluator类型type FSMGuardEvaluator = (guard: string, context: FSMGuardContext) => booleanFSM Guard Evaluator 公共类型别名;完整类型表达式见声明。
FSMStateKind类型type FSMStateKind = 'idle' | 'run_initialized' | 'context_built' | 'reasoning' | 'action_selected' | 'policy_checked' | 'acting' | 'observation_recorded' | 'verifying' | 'memory_sync' | 'recovering' | 'compensating' | 'quarantined' | 'human_review' | 'completed' | 'failed' | 'cancelled' | 'domain'FSM State Kind 公共类型别名;完整类型表达式见声明。
FsmTerminalStatus类型type FsmTerminalStatus = 'completed' | 'failed' | 'cancelled'FSM Terminal Status 公共类型别名;完整类型表达式见声明。
HarnessCapabilityArea类型type HarnessCapabilityArea = 'lifecycle' | 'context' | 'reasoning' | 'policy' | 'activity' | 'observation' | 'verification' | 'memory' | 'recovery' | 'human_review' | 'terminal'Harness Capability Area 公共类型别名;完整类型表达式见声明。
HarnessFSMStateId类型type HarnessFSMStateId = (typeof HARNESS_FSM_STATE_IDS)[number]Harness FSM State ID 公共类型别名;完整类型表达式见声明。

FSMRuntime

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

  • 种类: 类
  • 导入: import { FSMRuntime } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare class FSMRuntime {
    constructor(spec: FSMProcessSpec, runId: string, options?: FSMRuntimeOptions, snapshot?: FSMSnapshot);
    getSnapshot(): FSMSnapshot;
    start(metadata?: Record<string, unknown>): Promise<FSMSnapshot>;
    transition(to: string, options?: FSMRuntimeTransitionOptions): Promise<StateTransition>;
    transitionPath(states: string[], options?: FSMRuntimeTransitionOptions): Promise<StateTransition[]>;
    cancel(options?: FSMRuntimeCancelOptions): Promise<StateTransition>;
    decideRecovery(anomaly: FSMAnomaly, options?: {
            stateId?: string;
            now?: string;
        }): Promise<FSMRecoveryDecision>;
    registerRecoverySuccess(circuitKey: string, now?: string): FSMSnapshot;
}

公开成员

成员种类签名说明
cancel方法cancel(options?: FSMRuntimeCancelOptions): Promise<StateTransition>公开方法;参数与返回类型以签名列为准。
constructor构造函数(spec: FSMProcessSpec, runId: string, options?: FSMRuntimeOptions, snapshot?: FSMSnapshot): FSMRuntime创建该类的实例。
decideRecovery方法decideRecovery(anomaly: FSMAnomaly, options?: { stateId?: string; now?: string; }): Promise<FSMRecoveryDecision>公开方法;参数与返回类型以签名列为准。
getSnapshot方法getSnapshot(): FSMSnapshot公开方法;参数与返回类型以签名列为准。
registerRecoverySuccess方法registerRecoverySuccess(circuitKey: string, now?: string): FSMSnapshot公开方法;参数与返回类型以签名列为准。
start方法start(metadata?: Record<string, unknown>): Promise<FSMSnapshot>公开方法;参数与返回类型以签名列为准。
transition方法transition(to: string, options?: FSMRuntimeTransitionOptions): Promise<StateTransition>公开方法;参数与返回类型以签名列为准。
transitionPath方法transitionPath(states: string[], options?: FSMRuntimeTransitionOptions): Promise<StateTransition[]>公开方法;参数与返回类型以签名列为准。

defaultReActFSMProcessSpec

index 模块导出的 Default ReAct FSM Process Spec 常量。

  • 种类: 常量
  • 导入: import { defaultReActFSMProcessSpec } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const defaultReActFSMProcessSpec: FSMProcessSpec;

fsmProcessSpecDefinition

FSM Process Spec 的运行时校验入口,组合 Parser、Example 与 JSON Schema。

  • 种类: 常量
  • 导入: import { fsmProcessSpecDefinition } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const fsmProcessSpecDefinition: SpecSchemaDefinition<FSMProcessSpec>;

fsmProcessSpecExample

FSM Process Spec 的有效示例值。

  • 种类: 常量
  • 导入: import { fsmProcessSpecExample } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const fsmProcessSpecExample: FSMProcessSpec;

fsmProcessSpecJsonSchema

FSM Process Spec 的 JSON Schema。

  • 种类: 常量
  • 导入: import { fsmProcessSpecJsonSchema } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const fsmProcessSpecJsonSchema: JsonSchema;

fsmProcessSpecSchema

FSM Process Spec 的运行时 Schema。

  • 种类: 常量
  • 导入: import { fsmProcessSpecSchema } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const fsmProcessSpecSchema: (typeof import('@codesoul-co/hypha-fsm'))['fsmProcessSpecSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

fsmSpecDefinitions

index 模块导出的 FSM Spec Definitions 常量。

  • 种类: 常量
  • 导入: import { fsmSpecDefinitions } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const fsmSpecDefinitions: readonly [SpecSchemaDefinition<FSMProcessSpec>];

fsmSpecJsonSchemas

index 模块导出的 FSM Spec JSON Schemas 常量。

  • 种类: 常量
  • 导入: import { fsmSpecJsonSchemas } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const fsmSpecJsonSchemas: Record<string, JsonSchema>;

fsmStateSpecSchema

FSM State Spec 的运行时 Schema。

  • 种类: 常量
  • 导入: import { fsmStateSpecSchema } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
// 精确类型由包入口解析;完整编译器展开定义见源码链接。
export declare const fsmStateSpecSchema: (typeof import('@codesoul-co/hypha-fsm'))['fsmStateSpecSchema'];

该常量的编译器展开类型已压缩;它的公共名称、顶层类型与源码位置仍保留在本条目中。相关输入/输出字段请使用同模块导出的接口、类型或 Runtime Schema。

fsmTransitionSpecSchema

FSM Transition Spec 的运行时 Schema。

  • 种类: 常量
  • 导入: import { fsmTransitionSpecSchema } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const fsmTransitionSpecSchema: z.ZodObject<{ from: z.ZodString; to: z.ZodString; guard: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; traceEvent: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { from: string; to: string; description?: string | undefined; guard?: string | undefined; traceEvent?: string | undefined; }, { from: string; to: string; description?: string | undefined; guard?: string | undefined; traceEvent?: string | undefined; }>;

HARNESS_FSM_STATE_IDS

Stable Harness states owned by the framework runtime. Domain Packs may bind capabilities and policy to these phases, but must not add, remove, rename, or reconnect them.

  • 种类: 常量
  • 导入: import { HARNESS_FSM_STATE_IDS } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const HARNESS_FSM_STATE_IDS: readonly ["Idle", "RunInitialized", "ContextBuilt", "Reasoning", "ActionSelected", "PolicyChecked", "Acting", "ObservationRecorded", "Verifying", "MemorySync", "Recovering", "Compensating", "Quarantined", "HumanReview", "Completed", "Failed", "Cancelled"];

HARNESS_STATE_CAPABILITY_AREA

activity is the governed side-effect phase shared by Tool, MCP, Execution, file, Memory-write, and external-write adapters. The concrete activity type remains Event evidence; it never becomes a Domain-defined FSM state.

  • 种类: 常量
  • 导入: import { HARNESS_STATE_CAPABILITY_AREA } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const HARNESS_STATE_CAPABILITY_AREA: Readonly<Record<"Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled", HarnessCapabilityArea>>;

REACT_FSM_STATE_PATH

index 模块导出的 REACT FSM STATE PATH 常量。

  • 种类: 常量
  • 导入: import { REACT_FSM_STATE_PATH } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const REACT_FSM_STATE_PATH: readonly ["Idle", "RunInitialized", "ContextBuilt", "Reasoning", "ActionSelected", "PolicyChecked", "Acting", "ObservationRecorded", "Verifying", "MemorySync", "Completed"];

REACT_PHASE_TO_HARNESS_STATE

index 模块导出的 REACT PHASE TO HARNESS STATE 常量。

  • 种类: 常量
  • 导入: import { REACT_PHASE_TO_HARNESS_STATE } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare const REACT_PHASE_TO_HARNESS_STATE: Readonly<{ reason: "Reasoning"; select_action: "ActionSelected"; policy_check: "PolicyChecked"; act: "Acting"; observe_result: "ObservationRecorded"; verify: "Verifying"; memory_sync: "MemorySync"; complete: "Completed"; fail: "Failed"; human_review: "HumanReview"; cancel: "Cancelled"; }>;

analyzeFSMTopology

Describes graph properties without imposing product-specific topology rules. Callers can decide whether unreachable states, non-terminal dead ends, or cycles are valid for their Domain workflow.

  • 种类: 函数
  • 导入: import { analyzeFSMTopology } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function analyzeFSMTopology(spec: FSMProcessSpec): FSMTopologyAnalysis;

调用签名

text
analyzeFSMTopology(spec: FSMProcessSpec): FSMTopologyAnalysis

Describes graph properties without imposing product-specific topology rules. Callers can decide whether unreachable states, non-terminal dead ends, or cycles are valid for their Domain workflow.

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。

返回值

  • 类型: FSMTopologyAnalysis
  • 说明: 返回值契约由上述类型定义。

applyTransition

Apply Transition 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { applyTransition } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function applyTransition(spec: FSMProcessSpec, snapshot: FSMSnapshot, to: string, nowOrOptions?: string | FSMTransitionOptions): FSMSnapshot;

调用签名

text
applyTransition(spec: FSMProcessSpec, snapshot: FSMSnapshot, to: string, nowOrOptions?: string | FSMTransitionOptions): FSMSnapshot

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
snapshotFSMSnapshot必需参数;接受的值由类型列定义。
tostring必需参数;接受的值由类型列定义。
nowOrOptionsstring | FSMTransitionOptions可选参数;接受的值由类型列定义。

返回值

  • 类型: FSMSnapshot
  • 说明: 返回值契约由上述类型定义。

applyTransitionWithRuntimePolicy

Apply Transition With Runtime Policy 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { applyTransitionWithRuntimePolicy } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function applyTransitionWithRuntimePolicy(spec: FSMProcessSpec, snapshot: FSMSnapshot, to: string, options?: FSMRuntimeTransitionOptions): Promise<FSMSnapshot>;

调用签名

text
applyTransitionWithRuntimePolicy(spec: FSMProcessSpec, snapshot: FSMSnapshot, to: string, options?: FSMRuntimeTransitionOptions): Promise<FSMSnapshot>

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
snapshotFSMSnapshot必需参数;接受的值由类型列定义。
tostring必需参数;接受的值由类型列定义。
optionsFSMRuntimeTransitionOptions可选参数;接受的值由类型列定义。

返回值

  • 类型: Promise<FSMSnapshot>
  • 说明: 返回值契约由上述类型定义。

assertHarnessFSMProcessSpec

Fails closed when an application or Domain Pack attempts to replace the Harness capability topology with a product workflow.

  • 种类: 函数
  • 导入: import { assertHarnessFSMProcessSpec } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function assertHarnessFSMProcessSpec(spec: FSMProcessSpec): void;

调用签名

text
assertHarnessFSMProcessSpec(spec: FSMProcessSpec): void

Fails closed when an application or Domain Pack attempts to replace the Harness capability topology with a product workflow.

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。

返回值

  • 类型: void
  • 说明: 不返回值。

canRetryState

Can Retry State 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { canRetryState } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function canRetryState(spec: FSMProcessSpec, stateId: string, attemptedCount: number): boolean;

调用签名

text
canRetryState(spec: FSMProcessSpec, stateId: string, attemptedCount: number): boolean

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
stateIdstring必需参数;接受的值由类型列定义。
attemptedCountnumber必需参数;接受的值由类型列定义。

返回值

  • 类型: boolean
  • 说明: 返回值契约由上述类型定义。

createHarnessFSMProcessSpec

Returns an isolated copy so composition code cannot mutate the shared contract.

  • 种类: 函数
  • 导入: import { createHarnessFSMProcessSpec } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function createHarnessFSMProcessSpec(): FSMProcessSpec;

调用签名

text
createHarnessFSMProcessSpec(): FSMProcessSpec

Returns an isolated copy so composition code cannot mutate the shared contract.

参数

无参数。

返回值

  • 类型: FSMProcessSpec
  • 说明: 返回值契约由上述类型定义。

createInitialSnapshot

Create Initial Snapshot 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { createInitialSnapshot } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function createInitialSnapshot(spec: FSMProcessSpec, runId: string, now?: string): FSMSnapshot;

调用签名

text
createInitialSnapshot(spec: FSMProcessSpec, runId: string, now?: string): FSMSnapshot

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
runIdstring必需参数;接受的值由类型列定义。
nowstring可选参数;接受的值由类型列定义。

返回值

  • 类型: FSMSnapshot
  • 说明: 返回值契约由上述类型定义。

evaluateGuardExpression

Evaluate Guard Expression 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { evaluateGuardExpression } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function evaluateGuardExpression(guard: string, context?: FSMGuardContext): boolean;

调用签名

text
evaluateGuardExpression(guard: string, context?: FSMGuardContext): boolean

参数

参数类型必需说明
guardstring必需参数;接受的值由类型列定义。
contextFSMGuardContext可选参数;接受的值由类型列定义。

返回值

  • 类型: boolean
  • 说明: 返回值契约由上述类型定义。

evaluateStateTimeout

Evaluate State Timeout 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { evaluateStateTimeout } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function evaluateStateTimeout(spec: FSMProcessSpec, snapshot: FSMSnapshot, now?: string): FSMTimeoutEvaluation | null;

调用签名

text
evaluateStateTimeout(spec: FSMProcessSpec, snapshot: FSMSnapshot, now?: string): FSMTimeoutEvaluation | null

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
snapshotFSMSnapshot必需参数;接受的值由类型列定义。
nowstring可选参数;接受的值由类型列定义。

返回值

  • 类型: FSMTimeoutEvaluation
  • 说明: 返回值契约由上述类型定义。

getAllowedTransitions

Get Allowed Transitions 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { getAllowedTransitions } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function getAllowedTransitions(spec: FSMProcessSpec, stateId: string): FSMTransitionSpec[];

调用签名

text
getAllowedTransitions(spec: FSMProcessSpec, stateId: string): FSMTransitionSpec[]

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
stateIdstring必需参数;接受的值由类型列定义。

返回值

  • 类型: FSMTransitionSpec[]
  • 说明: 返回值契约由上述类型定义。

harnessStateForReActPhase

Harness State For ReAct Phase 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { harnessStateForReActPhase } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function harnessStateForReActPhase(phase: string): HarnessFSMStateId | undefined;

调用签名

text
harnessStateForReActPhase(phase: string): HarnessFSMStateId | undefined

参数

参数类型必需说明
phasestring必需参数;接受的值由类型列定义。

返回值

  • 类型: "Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled"
  • 说明: 返回值契约由上述类型定义。

isHarnessFSMProcessSpec

Returns false for either an invalid process or a valid non-Harness topology.

  • 种类: 函数
  • 导入: import { isHarnessFSMProcessSpec } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function isHarnessFSMProcessSpec(spec: FSMProcessSpec): boolean;

调用签名

text
isHarnessFSMProcessSpec(spec: FSMProcessSpec): boolean

Returns false for either an invalid process or a valid non-Harness topology.

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。

返回值

  • 类型: boolean
  • 说明: 返回值契约由上述类型定义。

isHarnessFSMStateId

Is Harness FSM State ID 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { isHarnessFSMStateId } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function isHarnessFSMStateId(value: string): value is HarnessFSMStateId;

调用签名

text
isHarnessFSMStateId(value: string): value is HarnessFSMStateId

参数

参数类型必需说明
valuestring必需参数;接受的值由类型列定义。

返回值

  • 类型: value is "Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled"
  • 说明: 返回值契约由上述类型定义。

parseFSMProcessSpec

Parse FSM Process Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { parseFSMProcessSpec } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function parseFSMProcessSpec(input: unknown): FSMProcessSpec;

调用签名

text
parseFSMProcessSpec(input: unknown): FSMProcessSpec

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

  • 类型: FSMProcessSpec
  • 说明: 返回值契约由上述类型定义。

planHarnessCapabilityPath

Plans only normal capability movement. Recovery, compensation, quarantine, human review, failure, and cancellation are selected by their dedicated supervisors and can never be traversed as a shortcut for Domain work.

  • 种类: 函数
  • 导入: import { planHarnessCapabilityPath } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function planHarnessCapabilityPath(from: HarnessFSMStateId, to: HarnessFSMStateId): HarnessFSMStateId[];

调用签名

text
planHarnessCapabilityPath(from: HarnessFSMStateId, to: HarnessFSMStateId): HarnessFSMStateId[]

Plans only normal capability movement. Recovery, compensation, quarantine, human review, failure, and cancellation are selected by their dedicated supervisors and can never be traversed as a shortcut for Domain work.

参数

参数类型必需说明
from"Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled"必需参数;接受的值由类型列定义。
to"Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled"必需参数;接受的值由类型列定义。

返回值

  • 类型: ("Idle" | "RunInitialized" | "ContextBuilt" | "Reasoning" | "ActionSelected" | "PolicyChecked" | "Acting" | "ObservationRecorded" | "Verifying" | "MemorySync" | "Recovering" | "Compensating" | "Quarantined" | "HumanReview" | "Completed" | "Failed" | "Cancelled")[]
  • 说明: 返回值契约由上述类型定义。

validateFSMProcessSpec

Validate FSM Process Spec 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { validateFSMProcessSpec } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function validateFSMProcessSpec(spec: FSMProcessSpec): void;

调用签名

text
validateFSMProcessSpec(spec: FSMProcessSpec): void

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。

返回值

  • 类型: void
  • 说明: 不返回值。

validateFSMSnapshot

Validate FSM Snapshot 函数,提供 1 个公开调用签名;参数与返回类型见下表。

  • 种类: 函数
  • 导入: import { validateFSMSnapshot } from '@codesoul-co/hypha-fsm';
  • 源码模块: index

声明

text
export declare function validateFSMSnapshot(spec: FSMProcessSpec, snapshot: FSMSnapshot, expectedRunId?: string): void;

调用签名

text
validateFSMSnapshot(spec: FSMProcessSpec, snapshot: FSMSnapshot, expectedRunId?: string): void

参数

参数类型必需说明
specFSMProcessSpec必需参数;接受的值由类型列定义。
snapshotFSMSnapshot必需参数;接受的值由类型列定义。
expectedRunIdstring可选参数;接受的值由类型列定义。

返回值

  • 类型: void
  • 说明: 不返回值。

FSMGuardContext

FSM Guard Context 接口,共包含 3 个公开字段或方法。

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

声明

text
export interface FSMGuardContext {
    input?: unknown;
    variables?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
input属性input?: unknown公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
variables属性variables?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。

FSMProcessSpec

FSM Process Spec 接口,共包含 13 个公开字段或方法。

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

声明

text
export interface FSMProcessSpec extends VersionedSpec, SpecMetadata {
    initialState: string;
    states: FSMStateSpec[];
    transitions: FSMTransitionSpec[];
    terminalStates: string[];
    recoveryPolicy?: FSMRecoveryPolicySpec;
}

契约成员

成员种类签名说明
createdAt属性createdAt?: string公开属性;类型、只读和可选状态以签名列为准。
description属性description?: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
initialState属性initialState: string公开属性;类型、只读和可选状态以签名列为准。
name属性name?: string公开属性;类型、只读和可选状态以签名列为准。
owner属性owner?: string公开属性;类型、只读和可选状态以签名列为准。
recoveryPolicy属性recoveryPolicy?: FSMRecoveryPolicySpec公开属性;类型、只读和可选状态以签名列为准。
states属性states: FSMStateSpec[]公开属性;类型、只读和可选状态以签名列为准。
tags属性tags?: string[]公开属性;类型、只读和可选状态以签名列为准。
terminalStates属性terminalStates: string[]公开属性;类型、只读和可选状态以签名列为准。
transitions属性transitions: FSMTransitionSpec[]公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt?: string公开属性;类型、只读和可选状态以签名列为准。
version属性version: string公开属性;类型、只读和可选状态以签名列为准。

FSMRecoveryDecisionRecord

FSM Recovery Decision Record 接口,共包含 4 个公开字段或方法。

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

声明

text
export interface FSMRecoveryDecisionRecord {
    processId: string;
    runId: string;
    decision: FSMRecoveryDecision;
    snapshot: FSMSnapshot;
}

契约成员

成员种类签名说明
decision属性decision: FSMRecoveryDecision公开属性;类型、只读和可选状态以签名列为准。
processId属性processId: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
snapshot属性snapshot: FSMSnapshot公开属性;类型、只读和可选状态以签名列为准。

FSMRuntimeCancelOptions

FSM Runtime Cancel Options 接口,共包含 8 个公开字段或方法。

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

声明

text
export interface FSMRuntimeCancelOptions extends FSMRuntimeTransitionOptions {
    reason?: string;
}

契约成员

成员种类签名说明
guardContext属性guardContext?: FSMGuardContext公开属性;类型、只读和可选状态以签名列为准。
guardEvaluator方法guardEvaluator?(guard: string, context: FSMGuardContext): boolean公开方法;参数与返回类型以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
now属性now?: string公开属性;类型、只读和可选状态以签名列为准。
policy属性policy?: PolicyEngine公开属性;类型、只读和可选状态以签名列为准。
reason属性reason?: string公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。

FSMRuntimeOptions

FSM Runtime Options 接口,共包含 5 个公开字段或方法。

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

声明

text
export interface FSMRuntimeOptions {
    now?: () => string;
    policy?: PolicyEngine;
    onStateEntered?: (record: FSMStateEnteredRecord) => Promise<void> | void;
    onTransition?: (record: StateTransition) => Promise<void> | void;
    onRecoveryDecision?: (record: FSMRecoveryDecisionRecord) => Promise<void> | void;
}

契约成员

成员种类签名说明
now方法now?(): string公开方法;参数与返回类型以签名列为准。
onRecoveryDecision方法onRecoveryDecision?(record: FSMRecoveryDecisionRecord): Promise<void> | void公开方法;参数与返回类型以签名列为准。
onStateEntered方法onStateEntered?(record: FSMStateEnteredRecord): Promise<void> | void公开方法;参数与返回类型以签名列为准。
onTransition方法onTransition?(record: StateTransition): Promise<void> | void公开方法;参数与返回类型以签名列为准。
policy属性policy?: PolicyEngine公开属性;类型、只读和可选状态以签名列为准。

FSMRuntimeTransitionOptions

FSM Runtime Transition Options 接口,共包含 7 个公开字段或方法。

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

声明

text
export interface FSMRuntimeTransitionOptions extends FSMTransitionOptions {
    userId?: string;
    stepId?: string;
    policy?: PolicyEngine;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
guardContext属性guardContext?: FSMGuardContext公开属性;类型、只读和可选状态以签名列为准。
guardEvaluator方法guardEvaluator?(guard: string, context: FSMGuardContext): boolean公开方法;参数与返回类型以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
now属性now?: string公开属性;类型、只读和可选状态以签名列为准。
policy属性policy?: PolicyEngine公开属性;类型、只读和可选状态以签名列为准。
stepId属性stepId?: string公开属性;类型、只读和可选状态以签名列为准。
userId属性userId?: string公开属性;类型、只读和可选状态以签名列为准。

FSMSnapshot

FSM Snapshot 接口,共包含 8 个公开字段或方法。

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

声明

text
export interface FSMSnapshot {
    processId: string;
    runId: string;
    currentState: string;
    statePath: string[];
    status: 'running' | FsmTerminalStatus;
    updatedAt: string;
    recovery?: FSMRecoverySnapshot;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
currentState属性currentState: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
processId属性processId: string公开属性;类型、只读和可选状态以签名列为准。
recovery属性recovery?: FSMRecoverySnapshot公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
statePath属性statePath: string[]公开属性;类型、只读和可选状态以签名列为准。
status属性status: "running" | FsmTerminalStatus公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt: string公开属性;类型、只读和可选状态以签名列为准。

FSMStateEnteredRecord

FSM State Entered Record 接口,共包含 7 个公开字段或方法。

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

声明

text
export interface FSMStateEnteredRecord {
    processId: string;
    runId: string;
    stateId: string;
    fromState?: string;
    snapshot: FSMSnapshot;
    enteredAt: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
enteredAt属性enteredAt: string公开属性;类型、只读和可选状态以签名列为准。
fromState属性fromState?: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
processId属性processId: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
snapshot属性snapshot: FSMSnapshot公开属性;类型、只读和可选状态以签名列为准。
stateId属性stateId: string公开属性;类型、只读和可选状态以签名列为准。

FSMStateSpec

FSM State Spec 接口,共包含 15 个公开字段或方法。

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

声明

text
export interface FSMStateSpec extends SpecMetadata {
    id: string;
    kind?: FSMStateKind;
    entryAction?: string;
    exitAction?: string;
    timeoutPolicy?: TimeoutPolicySpec;
    retryPolicy?: RetryPolicySpec;
    humanReviewPolicy?: HumanReviewPolicySpec;
    policyRefs?: string[];
    traceEvents?: string[];
}

契约成员

成员种类签名说明
createdAt属性createdAt?: string公开属性;类型、只读和可选状态以签名列为准。
description属性description?: string公开属性;类型、只读和可选状态以签名列为准。
entryAction属性entryAction?: string公开属性;类型、只读和可选状态以签名列为准。
exitAction属性exitAction?: string公开属性;类型、只读和可选状态以签名列为准。
humanReviewPolicy属性humanReviewPolicy?: HumanReviewPolicySpec公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind?: FSMStateKind公开属性;类型、只读和可选状态以签名列为准。
name属性name?: string公开属性;类型、只读和可选状态以签名列为准。
owner属性owner?: string公开属性;类型、只读和可选状态以签名列为准。
policyRefs属性policyRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
retryPolicy属性retryPolicy?: RetryPolicySpec公开属性;类型、只读和可选状态以签名列为准。
tags属性tags?: string[]公开属性;类型、只读和可选状态以签名列为准。
timeoutPolicy属性timeoutPolicy?: TimeoutPolicySpec公开属性;类型、只读和可选状态以签名列为准。
traceEvents属性traceEvents?: string[]公开属性;类型、只读和可选状态以签名列为准。
updatedAt属性updatedAt?: string公开属性;类型、只读和可选状态以签名列为准。

FSMTimeoutEvaluation

FSM Timeout Evaluation 接口,共包含 5 个公开字段或方法。

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

声明

text
export interface FSMTimeoutEvaluation {
    timedOut: boolean;
    action?: NonNullable<TimeoutPolicySpec['onTimeout']>;
    stateId: string;
    elapsedMs: number;
    timeoutMs: number;
}

契约成员

成员种类签名说明
action属性action?: NonNullable<"fail" | "retry" | "human_review">公开属性;类型、只读和可选状态以签名列为准。
elapsedMs属性elapsedMs: number公开属性;类型、只读和可选状态以签名列为准。
stateId属性stateId: string公开属性;类型、只读和可选状态以签名列为准。
timedOut属性timedOut: boolean公开属性;类型、只读和可选状态以签名列为准。
timeoutMs属性timeoutMs: number公开属性;类型、只读和可选状态以签名列为准。

FSMTopologyAnalysis

FSM Topology Analysis 接口,共包含 5 个公开字段或方法。

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

声明

text
export interface FSMTopologyAnalysis {
    initialState: string;
    reachableStates: string[];
    unreachableStates: string[];
    deadEndStates: string[];
    cycleStates: string[];
}

契约成员

成员种类签名说明
cycleStates属性cycleStates: string[]公开属性;类型、只读和可选状态以签名列为准。
deadEndStates属性deadEndStates: string[]公开属性;类型、只读和可选状态以签名列为准。
initialState属性initialState: string公开属性;类型、只读和可选状态以签名列为准。
reachableStates属性reachableStates: string[]公开属性;类型、只读和可选状态以签名列为准。
unreachableStates属性unreachableStates: string[]公开属性;类型、只读和可选状态以签名列为准。

FSMTransitionOptions

FSM Transition Options 接口,共包含 3 个公开字段或方法。

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

声明

text
export interface FSMTransitionOptions {
    now?: string;
    guardContext?: FSMGuardContext;
    guardEvaluator?: FSMGuardEvaluator;
}

契约成员

成员种类签名说明
guardContext属性guardContext?: FSMGuardContext公开属性;类型、只读和可选状态以签名列为准。
guardEvaluator方法guardEvaluator?(guard: string, context: FSMGuardContext): boolean公开方法;参数与返回类型以签名列为准。
now属性now?: string公开属性;类型、只读和可选状态以签名列为准。

FSMTransitionSpec

FSM Transition Spec 接口,共包含 5 个公开字段或方法。

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

声明

text
export interface FSMTransitionSpec {
    from: string;
    to: string;
    guard?: string;
    description?: string;
    traceEvent?: string;
}

契约成员

成员种类签名说明
description属性description?: string公开属性;类型、只读和可选状态以签名列为准。
from属性from: string公开属性;类型、只读和可选状态以签名列为准。
guard属性guard?: string公开属性;类型、只读和可选状态以签名列为准。
to属性to: string公开属性;类型、只读和可选状态以签名列为准。
traceEvent属性traceEvent?: string公开属性;类型、只读和可选状态以签名列为准。

StateTransition

State Transition 接口,共包含 8 个公开字段或方法。

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

声明

text
export interface StateTransition {
    processId: string;
    runId: string;
    from: string;
    to: string;
    transition: FSMTransitionSpec;
    snapshot: FSMSnapshot;
    acceptedAt: string;
    metadata?: Record<string, unknown>;
}

契约成员

成员种类签名说明
acceptedAt属性acceptedAt: string公开属性;类型、只读和可选状态以签名列为准。
from属性from: string公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, unknown>公开属性;类型、只读和可选状态以签名列为准。
processId属性processId: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
snapshot属性snapshot: FSMSnapshot公开属性;类型、只读和可选状态以签名列为准。
to属性to: string公开属性;类型、只读和可选状态以签名列为准。
transition属性transition: FSMTransitionSpec公开属性;类型、只读和可选状态以签名列为准。

FSMGuardEvaluator

FSM Guard Evaluator 公共类型别名;完整类型表达式见声明。

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

声明

text
export type FSMGuardEvaluator = (guard: string, context: FSMGuardContext) => boolean;

FSMStateKind

FSM State Kind 公共类型别名;完整类型表达式见声明。

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

声明

text
export type FSMStateKind = 'idle' | 'run_initialized' | 'context_built' | 'reasoning' | 'action_selected' | 'policy_checked' | 'acting' | 'observation_recorded' | 'verifying' | 'memory_sync' | 'recovering' | 'compensating' | 'quarantined' | 'human_review' | 'completed' | 'failed' | 'cancelled' | 'domain';

FsmTerminalStatus

FSM Terminal Status 公共类型别名;完整类型表达式见声明。

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

声明

text
export type FsmTerminalStatus = 'completed' | 'failed' | 'cancelled';

HarnessCapabilityArea

Harness Capability Area 公共类型别名;完整类型表达式见声明。

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

声明

text
export type HarnessCapabilityArea = 'lifecycle' | 'context' | 'reasoning' | 'policy' | 'activity' | 'observation' | 'verification' | 'memory' | 'recovery' | 'human_review' | 'terminal';

HarnessFSMStateId

Harness FSM State ID 公共类型别名;完整类型表达式见声明。

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

声明

text
export type HarnessFSMStateId = (typeof HARNESS_FSM_STATE_IDS)[number];