@reactive-skills/runtime 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ import { SkillManifest, StateDefinition, SignalEvent, PromptSlice, EventContext, ChildRunSummary, DecisionRecord } from './types.js';
2
+ import { EventStore } from './event-store.js';
3
+ export interface FSMEngineOptions {
4
+ skillDir: string;
5
+ workspaceDir?: string;
6
+ eventStore?: EventStore;
7
+ eventContext?: EventContext;
8
+ runId?: string;
9
+ initialContext?: Record<string, any>;
10
+ autoRehydrate?: boolean;
11
+ }
12
+ export declare class FSMEngine {
13
+ private skillDir;
14
+ private workspaceDir;
15
+ private manifest;
16
+ private activeStatePath;
17
+ private context;
18
+ private eventStore;
19
+ private projectionEngine;
20
+ private signalQueue;
21
+ private isProcessingQueue;
22
+ private signalQueueDepth;
23
+ private turnsSinceLastSignal;
24
+ private inBypassState;
25
+ private readonly strictExecution;
26
+ constructor(options: FSMEngineOptions);
27
+ /**
28
+ * Rehydrate state machine state and context from immutable event history,
29
+ * resuming from the latest point-in-time state snapshot if available (PERF-02 / INV-08)
30
+ */
31
+ private rehydrate;
32
+ private loadManifest;
33
+ getManifest(): SkillManifest;
34
+ getCurrentState(): string;
35
+ getActiveStatePath(): string[];
36
+ getContext(): Record<string, any>;
37
+ updateContext(updates: Record<string, any>): void;
38
+ getEventStore(): EventStore;
39
+ getEventContext(): EventContext;
40
+ isStrictExecution(): boolean;
41
+ getTurnsSinceLastSignal(): number;
42
+ isBypassDetected(): boolean;
43
+ recordTurnStart(): void;
44
+ checkBypass(): void;
45
+ recordChildRunStarted(childSkillId: string, childRunId: string, requestId?: string): SignalEvent;
46
+ recordChildRunCompleted(summary: ChildRunSummary): SignalEvent;
47
+ invokeSkill(skillNameOrPath: string): Promise<{
48
+ skillId: string;
49
+ currentState: string;
50
+ promptSlice: PromptSlice;
51
+ event: SignalEvent;
52
+ }>;
53
+ recordDecision(decision: DecisionRecord, source?: string): SignalEvent;
54
+ /**
55
+ * Resolves full hierarchical path including default/initial substates
56
+ */
57
+ private resolveInitialPath;
58
+ /**
59
+ * Get StateDefinition by path hierarchy
60
+ */
61
+ getStateDefinition(pathSegments: string[]): StateDefinition | null;
62
+ /**
63
+ * Generates the prompt slice for the active state hierarchy
64
+ */
65
+ generatePromptSlice(): PromptSlice;
66
+ /**
67
+ * Check if current state has a blocking Human-in-the-Loop gate
68
+ */
69
+ isWaitingForHuman(): boolean;
70
+ /**
71
+ * Process an incoming signal event, evaluating transitions with HSM bubbling and draining queued signals
72
+ */
73
+ handleSignal(signalName: string, payload?: Record<string, any>, metadata?: {
74
+ source?: string;
75
+ causationId?: string;
76
+ }): Promise<{
77
+ transitioned: boolean;
78
+ previousState: string;
79
+ newState: string;
80
+ event: SignalEvent;
81
+ handledAtDepth?: number;
82
+ deliverablesWritten: string[];
83
+ }>;
84
+ /**
85
+ * Transition between two hierarchical paths executing exit, transition, and entry hooks
86
+ */
87
+ private transitionBetweenPaths;
88
+ /**
89
+ * Enter a state hierarchy starting below the common ancestor
90
+ */
91
+ private enterPath;
92
+ private executeEntryHook;
93
+ private executeExitHook;
94
+ }