@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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/cli/dev.d.ts +2 -0
- package/dist/cli/dev.js +114 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +215 -0
- package/dist/core/event-store.d.ts +182 -0
- package/dist/core/event-store.js +762 -0
- package/dist/core/fsm-engine.d.ts +94 -0
- package/dist/core/fsm-engine.js +648 -0
- package/dist/core/guard-evaluator.d.ts +19 -0
- package/dist/core/guard-evaluator.js +103 -0
- package/dist/core/legacy-adapter.d.ts +27 -0
- package/dist/core/legacy-adapter.js +126 -0
- package/dist/core/migration.d.ts +18 -0
- package/dist/core/migration.js +256 -0
- package/dist/core/projection-engine.d.ts +43 -0
- package/dist/core/projection-engine.js +167 -0
- package/dist/core/runtime-hooks.d.ts +51 -0
- package/dist/core/runtime-hooks.js +195 -0
- package/dist/core/types.d.ts +238 -0
- package/dist/core/types.js +55 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.js +453 -0
- package/dist/sync/cli.d.ts +1 -0
- package/dist/sync/cli.js +186 -0
- package/dist/sync/engine.d.ts +2 -0
- package/dist/sync/engine.js +366 -0
- package/dist/sync/types.d.ts +35 -0
- package/dist/sync/types.js +1 -0
- package/package.json +75 -0
|
@@ -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
|
+
}
|