footprintjs 0.2.2 → 0.3.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/README.md +137 -41
- package/dist/esm/index.js +7 -1
- package/dist/esm/lib/builder/FlowChartBuilder.js +72 -91
- package/dist/esm/lib/builder/types.js +1 -1
- package/dist/esm/lib/contract/defineContract.js +32 -0
- package/dist/esm/lib/contract/index.js +18 -0
- package/dist/esm/lib/contract/openapi.js +120 -0
- package/dist/esm/lib/contract/schema.js +199 -0
- package/dist/esm/lib/contract/types.js +9 -0
- package/dist/esm/lib/engine/graph/StageNode.js +1 -1
- package/dist/esm/lib/engine/handlers/ChildrenExecutor.js +5 -5
- package/dist/esm/lib/engine/handlers/ContinuationResolver.js +6 -6
- package/dist/esm/lib/engine/handlers/DeciderHandler.js +4 -4
- package/dist/esm/lib/engine/handlers/NodeResolver.js +1 -2
- package/dist/esm/lib/engine/handlers/RuntimeStructureManager.js +1 -2
- package/dist/esm/lib/engine/handlers/SelectorHandler.js +6 -6
- package/dist/esm/lib/engine/narrative/ControlFlowNarrativeGenerator.js +13 -18
- package/dist/esm/lib/engine/narrative/types.js +1 -1
- package/dist/esm/lib/engine/traversal/FlowchartTraverser.js +10 -11
- package/dist/esm/lib/engine/types.js +1 -1
- package/dist/esm/lib/runner/ExecutionRuntime.js +1 -1
- package/dist/esm/types/index.d.ts +4 -0
- package/dist/esm/types/lib/builder/FlowChartBuilder.d.ts +17 -10
- package/dist/esm/types/lib/builder/types.d.ts +6 -6
- package/dist/esm/types/lib/contract/defineContract.d.ts +18 -0
- package/dist/esm/types/lib/contract/index.d.ts +14 -0
- package/dist/esm/types/lib/contract/openapi.d.ts +12 -0
- package/dist/esm/types/lib/contract/schema.d.ts +14 -0
- package/dist/esm/types/lib/contract/types.d.ts +94 -0
- package/dist/esm/types/lib/engine/graph/StageNode.d.ts +0 -2
- package/dist/esm/types/lib/engine/narrative/ControlFlowNarrativeGenerator.d.ts +6 -6
- package/dist/esm/types/lib/engine/narrative/types.d.ts +6 -6
- package/dist/esm/types/lib/engine/types.d.ts +0 -1
- package/dist/esm/types/lib/runner/ExecutionRuntime.d.ts +0 -1
- package/dist/index.js +12 -2
- package/dist/lib/builder/FlowChartBuilder.js +72 -91
- package/dist/lib/builder/types.js +1 -1
- package/dist/lib/contract/defineContract.js +36 -0
- package/dist/lib/contract/index.js +26 -0
- package/dist/lib/contract/openapi.js +124 -0
- package/dist/lib/contract/schema.js +205 -0
- package/dist/lib/contract/types.js +10 -0
- package/dist/lib/engine/graph/StageNode.js +1 -1
- package/dist/lib/engine/handlers/ChildrenExecutor.js +5 -5
- package/dist/lib/engine/handlers/ContinuationResolver.js +6 -6
- package/dist/lib/engine/handlers/DeciderHandler.js +4 -4
- package/dist/lib/engine/handlers/NodeResolver.js +1 -2
- package/dist/lib/engine/handlers/RuntimeStructureManager.js +1 -2
- package/dist/lib/engine/handlers/SelectorHandler.js +6 -6
- package/dist/lib/engine/narrative/ControlFlowNarrativeGenerator.js +13 -18
- package/dist/lib/engine/narrative/types.js +1 -1
- package/dist/lib/engine/traversal/FlowchartTraverser.js +10 -11
- package/dist/lib/engine/types.js +1 -1
- package/dist/lib/runner/ExecutionRuntime.js +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/lib/builder/FlowChartBuilder.d.ts +17 -10
- package/dist/types/lib/builder/types.d.ts +6 -6
- package/dist/types/lib/contract/defineContract.d.ts +18 -0
- package/dist/types/lib/contract/index.d.ts +14 -0
- package/dist/types/lib/contract/openapi.d.ts +12 -0
- package/dist/types/lib/contract/schema.d.ts +14 -0
- package/dist/types/lib/contract/types.d.ts +94 -0
- package/dist/types/lib/engine/graph/StageNode.d.ts +0 -2
- package/dist/types/lib/engine/narrative/ControlFlowNarrativeGenerator.d.ts +6 -6
- package/dist/types/lib/engine/narrative/types.d.ts +6 -6
- package/dist/types/lib/engine/types.d.ts +0 -1
- package/dist/types/lib/runner/ExecutionRuntime.d.ts +0 -1
- package/package.json +1 -1
|
@@ -28,13 +28,12 @@ export declare class DeciderList<TOut = any, TScope = any> {
|
|
|
28
28
|
private readonly deciderDescription?;
|
|
29
29
|
private readonly branchDescInfo;
|
|
30
30
|
constructor(builder: FlowChartBuilder<TOut, TScope>, curNode: StageNode<TOut, TScope>, curSpec: SerializedPipelineStructure, parentDescriptionParts?: string[], parentStageDescriptions?: Map<string, string>, reservedStepNumber?: number, deciderDescription?: string);
|
|
31
|
-
addFunctionBranch(id: string, name: string, fn?: PipelineStageFunction<TOut, TScope>,
|
|
31
|
+
addFunctionBranch(id: string, name: string, fn?: PipelineStageFunction<TOut, TScope>, description?: string): DeciderList<TOut, TScope>;
|
|
32
32
|
addSubFlowChartBranch(id: string, subflow: FlowChart<TOut, TScope>, mountName?: string, options?: SubflowMountOptions): DeciderList<TOut, TScope>;
|
|
33
33
|
addBranchList(branches: Array<{
|
|
34
34
|
id: string;
|
|
35
35
|
name: string;
|
|
36
36
|
fn?: PipelineStageFunction<TOut, TScope>;
|
|
37
|
-
displayName?: string;
|
|
38
37
|
}>): DeciderList<TOut, TScope>;
|
|
39
38
|
setDefault(id: string): DeciderList<TOut, TScope>;
|
|
40
39
|
end(): FlowChartBuilder<TOut, TScope>;
|
|
@@ -50,13 +49,12 @@ export declare class SelectorFnList<TOut = any, TScope = any> {
|
|
|
50
49
|
private readonly selectorDescription?;
|
|
51
50
|
private readonly branchDescInfo;
|
|
52
51
|
constructor(builder: FlowChartBuilder<TOut, TScope>, curNode: StageNode<TOut, TScope>, curSpec: SerializedPipelineStructure, parentDescriptionParts?: string[], parentStageDescriptions?: Map<string, string>, reservedStepNumber?: number, selectorDescription?: string);
|
|
53
|
-
addFunctionBranch(id: string, name: string, fn?: PipelineStageFunction<TOut, TScope>,
|
|
52
|
+
addFunctionBranch(id: string, name: string, fn?: PipelineStageFunction<TOut, TScope>, description?: string): SelectorFnList<TOut, TScope>;
|
|
54
53
|
addSubFlowChartBranch(id: string, subflow: FlowChart<TOut, TScope>, mountName?: string, options?: SubflowMountOptions): SelectorFnList<TOut, TScope>;
|
|
55
54
|
addBranchList(branches: Array<{
|
|
56
55
|
id: string;
|
|
57
56
|
name: string;
|
|
58
57
|
fn?: PipelineStageFunction<TOut, TScope>;
|
|
59
|
-
displayName?: string;
|
|
60
58
|
}>): SelectorFnList<TOut, TScope>;
|
|
61
59
|
end(): FlowChartBuilder<TOut, TScope>;
|
|
62
60
|
}
|
|
@@ -79,16 +77,25 @@ export declare class FlowChartBuilder<TOut = any, TScope = any> {
|
|
|
79
77
|
private _stepCounter;
|
|
80
78
|
private _stageDescriptions;
|
|
81
79
|
private _stageStepMap;
|
|
80
|
+
private _inputSchema?;
|
|
81
|
+
private _outputSchema?;
|
|
82
|
+
private _outputMapper?;
|
|
82
83
|
constructor(buildTimeExtractor?: BuildTimeExtractor<any>);
|
|
83
84
|
private _appendDescriptionLine;
|
|
84
85
|
private _appendSubflowDescription;
|
|
85
86
|
setEnableNarrative(): this;
|
|
86
87
|
setLogger(logger: ILogger): this;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
/** Declare the input schema (readOnlyContext shape). Accepts Zod schema or JSON Schema. */
|
|
89
|
+
setInputSchema(schema: unknown): this;
|
|
90
|
+
/** Declare the output schema (response shape). Accepts Zod schema or JSON Schema. */
|
|
91
|
+
setOutputSchema(schema: unknown): this;
|
|
92
|
+
/** Set the output mapper that extracts the response from final scope. */
|
|
93
|
+
setOutputMapper(mapper: (finalScope: Record<string, unknown>) => unknown): this;
|
|
94
|
+
start(name: string, fn?: PipelineStageFunction<TOut, TScope>, id?: string, description?: string): this;
|
|
95
|
+
addFunction(name: string, fn?: PipelineStageFunction<TOut, TScope>, id?: string, description?: string): this;
|
|
96
|
+
addStreamingFunction(name: string, streamId?: string, fn?: PipelineStageFunction<TOut, TScope>, id?: string, description?: string): this;
|
|
97
|
+
addDeciderFunction(name: string, fn: PipelineStageFunction<TOut, TScope>, id?: string, description?: string): DeciderList<TOut, TScope>;
|
|
98
|
+
addSelectorFunction(name: string, fn: PipelineStageFunction<TOut, TScope>, id?: string, description?: string): SelectorFnList<TOut, TScope>;
|
|
92
99
|
addListOfFunction(children: SimplifiedParallelSpec<TOut, TScope>[], options?: {
|
|
93
100
|
failFast?: boolean;
|
|
94
101
|
}): this;
|
|
@@ -117,5 +124,5 @@ export declare class FlowChartBuilder<TOut = any, TScope = any> {
|
|
|
117
124
|
root: StageNode<TOut, TScope>;
|
|
118
125
|
}> | undefined, prefix: string): void;
|
|
119
126
|
}
|
|
120
|
-
export declare function flowChart<TOut = any, TScope = any>(name: string, fn?: PipelineStageFunction<TOut, TScope>, id?: string,
|
|
127
|
+
export declare function flowChart<TOut = any, TScope = any>(name: string, fn?: PipelineStageFunction<TOut, TScope>, id?: string, buildTimeExtractor?: BuildTimeExtractor<any>, description?: string): FlowChartBuilder<TOut, TScope>;
|
|
121
128
|
export declare function specToStageNode(spec: FlowChartSpec): StageNode<any, any>;
|
|
@@ -40,8 +40,6 @@ export type StageNode<TOut = any, TScope = any> = {
|
|
|
40
40
|
name: string;
|
|
41
41
|
/** Optional stable id (required by decider/fork aggregation). */
|
|
42
42
|
id?: string;
|
|
43
|
-
/** Human-readable display name for UI. */
|
|
44
|
-
displayName?: string;
|
|
45
43
|
/** Human-readable description of what this stage does. */
|
|
46
44
|
description?: string;
|
|
47
45
|
/** Linear continuation. */
|
|
@@ -77,7 +75,6 @@ export interface SerializedPipelineStructure {
|
|
|
77
75
|
name: string;
|
|
78
76
|
id?: string;
|
|
79
77
|
type: 'stage' | 'decider' | 'fork' | 'streaming';
|
|
80
|
-
displayName?: string;
|
|
81
78
|
description?: string;
|
|
82
79
|
children?: SerializedPipelineStructure[];
|
|
83
80
|
next?: SerializedPipelineStructure;
|
|
@@ -98,7 +95,6 @@ export interface SerializedPipelineStructure {
|
|
|
98
95
|
export interface FlowChartSpec {
|
|
99
96
|
name: string;
|
|
100
97
|
id?: string;
|
|
101
|
-
displayName?: string;
|
|
102
98
|
description?: string;
|
|
103
99
|
children?: FlowChartSpec[];
|
|
104
100
|
next?: FlowChartSpec;
|
|
@@ -130,11 +126,16 @@ export type FlowChart<TOut = any, TScope = any> = {
|
|
|
130
126
|
logger?: ILogger;
|
|
131
127
|
description: string;
|
|
132
128
|
stageDescriptions: Map<string, string>;
|
|
129
|
+
/** Input schema (Zod or JSON Schema) — declared via setInputSchema(). */
|
|
130
|
+
inputSchema?: unknown;
|
|
131
|
+
/** Output schema (Zod or JSON Schema) — declared via setOutputSchema(). */
|
|
132
|
+
outputSchema?: unknown;
|
|
133
|
+
/** Output mapper — extracts response from final scope. */
|
|
134
|
+
outputMapper?: (finalScope: Record<string, unknown>) => unknown;
|
|
133
135
|
};
|
|
134
136
|
export type SimplifiedParallelSpec<TOut = any, TScope = any> = {
|
|
135
137
|
id: string;
|
|
136
138
|
name: string;
|
|
137
|
-
displayName?: string;
|
|
138
139
|
fn?: PipelineStageFunction<TOut, TScope>;
|
|
139
140
|
};
|
|
140
141
|
export type ExecOptions = {
|
|
@@ -148,5 +149,4 @@ export type ExecOptions = {
|
|
|
148
149
|
export interface SubflowRef {
|
|
149
150
|
$ref: string;
|
|
150
151
|
mountId: string;
|
|
151
|
-
displayName?: string;
|
|
152
152
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract/defineContract.ts — Factory for creating a FlowChartContract.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a compiled FlowChart with I/O schemas and an output mapper,
|
|
5
|
+
* using the same pattern as SubflowMountOptions (inputMapper/outputMapper).
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const contract = defineContract(chart, {
|
|
9
|
+
* inputSchema: z.object({ name: z.string() }),
|
|
10
|
+
* outputSchema: z.object({ greeting: z.string() }),
|
|
11
|
+
* outputMapper: (scope) => ({ greeting: scope.message as string }),
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* const openapi = contract.toOpenAPI();
|
|
15
|
+
*/
|
|
16
|
+
import type { FlowChart } from '../builder/types';
|
|
17
|
+
import type { FlowChartContract, FlowChartContractOptions } from './types';
|
|
18
|
+
export declare function defineContract<TInput = unknown, TOutput = unknown>(chart: FlowChart, options: FlowChartContractOptions<TInput, TOutput>): FlowChartContract<TInput, TOutput>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract/ — FlowChart I/O contract and OpenAPI generation layer.
|
|
3
|
+
*
|
|
4
|
+
* Standalone library: wraps a compiled FlowChart with input/output schemas
|
|
5
|
+
* and generates OpenAPI 3.1 specs. Uses the same inputMapper/outputMapper
|
|
6
|
+
* pattern as subflow mounting.
|
|
7
|
+
*
|
|
8
|
+
* Zero runtime deps on Zod — Zod schemas detected via duck-typing and
|
|
9
|
+
* converted to JSON Schema at contract creation time.
|
|
10
|
+
*/
|
|
11
|
+
export { defineContract } from './defineContract';
|
|
12
|
+
export { isZodSchema, normalizeSchema, zodToJsonSchema } from './schema';
|
|
13
|
+
export { generateOpenAPI } from './openapi';
|
|
14
|
+
export type { FlowChartContract, FlowChartContractOptions, JsonSchema, OpenAPIOptions, OpenAPISpec, SchemaInput, } from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract/openapi.ts — OpenAPI 3.1 spec generator.
|
|
3
|
+
*
|
|
4
|
+
* Generates an OpenAPI spec from a FlowChartContract by combining:
|
|
5
|
+
* - chart.description → operation description
|
|
6
|
+
* - chart.stageDescriptions → step-by-step detail
|
|
7
|
+
* - inputSchema → requestBody
|
|
8
|
+
* - outputSchema → response
|
|
9
|
+
* - chart.buildTimeStructure → operation metadata (branches, forks, etc.)
|
|
10
|
+
*/
|
|
11
|
+
import type { FlowChartContract, OpenAPIOptions, OpenAPISpec } from './types';
|
|
12
|
+
export declare function generateOpenAPI(contract: FlowChartContract, options?: OpenAPIOptions): OpenAPISpec;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract/schema.ts — Schema normalization utilities.
|
|
3
|
+
*
|
|
4
|
+
* Converts Zod schemas or raw JSON Schema objects into a normalized
|
|
5
|
+
* JsonSchema format. Zod detection uses duck-typing (checks for `_def`).
|
|
6
|
+
*
|
|
7
|
+
* Standalone: no dependency on Zod at import time.
|
|
8
|
+
* Compatible with Zod v4 internals.
|
|
9
|
+
*/
|
|
10
|
+
import type { JsonSchema, SchemaInput } from './types';
|
|
11
|
+
export declare function isZodSchema(input: unknown): boolean;
|
|
12
|
+
/** Convert a Zod schema object to JSON Schema. */
|
|
13
|
+
export declare function zodToJsonSchema(zodSchema: Record<string, unknown>): JsonSchema;
|
|
14
|
+
export declare function normalizeSchema(input: SchemaInput): JsonSchema;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract/types.ts — Types for the FlowChart contract layer.
|
|
3
|
+
*
|
|
4
|
+
* Defines the I/O boundary for a flowchart: input schema, output schema,
|
|
5
|
+
* and output mapper. Uses the same pattern as SubflowMountOptions
|
|
6
|
+
* (inputMapper/outputMapper) but at the top-level flowchart boundary.
|
|
7
|
+
*/
|
|
8
|
+
import type { FlowChart } from '../builder/types';
|
|
9
|
+
export type JsonSchema = {
|
|
10
|
+
type?: string | string[];
|
|
11
|
+
properties?: Record<string, JsonSchema>;
|
|
12
|
+
required?: string[];
|
|
13
|
+
items?: JsonSchema;
|
|
14
|
+
enum?: unknown[];
|
|
15
|
+
description?: string;
|
|
16
|
+
default?: unknown;
|
|
17
|
+
format?: string;
|
|
18
|
+
additionalProperties?: boolean | JsonSchema;
|
|
19
|
+
oneOf?: JsonSchema[];
|
|
20
|
+
anyOf?: JsonSchema[];
|
|
21
|
+
allOf?: JsonSchema[];
|
|
22
|
+
$ref?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
/** Anything with a `def` (Zod v4) or `_def` (Zod v3) property is treated as a Zod schema. */
|
|
26
|
+
export type SchemaInput = JsonSchema | {
|
|
27
|
+
def: unknown;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
export interface FlowChartContractOptions<TInput = unknown, TOutput = unknown> {
|
|
31
|
+
/** Schema describing the input (readOnlyContext) shape. Zod or JSON Schema. */
|
|
32
|
+
inputSchema?: SchemaInput;
|
|
33
|
+
/** Schema describing the output shape. Zod or JSON Schema. */
|
|
34
|
+
outputSchema?: SchemaInput;
|
|
35
|
+
/** Maps the final scope state into the response shape. */
|
|
36
|
+
outputMapper?: (finalScope: Record<string, unknown>) => TOutput;
|
|
37
|
+
}
|
|
38
|
+
export interface FlowChartContract<TInput = unknown, TOutput = unknown> {
|
|
39
|
+
/** The compiled flowchart. */
|
|
40
|
+
chart: FlowChart;
|
|
41
|
+
/** JSON Schema for the input (normalized from Zod or raw). */
|
|
42
|
+
inputSchema?: JsonSchema;
|
|
43
|
+
/** JSON Schema for the output (normalized from Zod or raw). */
|
|
44
|
+
outputSchema?: JsonSchema;
|
|
45
|
+
/** Maps the final scope state into the response shape. */
|
|
46
|
+
outputMapper?: (finalScope: Record<string, unknown>) => TOutput;
|
|
47
|
+
/** Auto-generated OpenAPI spec. */
|
|
48
|
+
toOpenAPI(options?: OpenAPIOptions): OpenAPISpec;
|
|
49
|
+
}
|
|
50
|
+
export interface OpenAPIOptions {
|
|
51
|
+
/** API version string (default: "1.0.0"). */
|
|
52
|
+
version?: string;
|
|
53
|
+
/** Base path prefix (default: "/"). */
|
|
54
|
+
basePath?: string;
|
|
55
|
+
/** HTTP method for the execute endpoint (default: "post"). */
|
|
56
|
+
method?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface OpenAPISpec {
|
|
59
|
+
openapi: '3.1.0';
|
|
60
|
+
info: {
|
|
61
|
+
title: string;
|
|
62
|
+
description: string;
|
|
63
|
+
version: string;
|
|
64
|
+
};
|
|
65
|
+
paths: Record<string, Record<string, OpenAPIOperation>>;
|
|
66
|
+
components?: {
|
|
67
|
+
schemas?: Record<string, JsonSchema>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface OpenAPIOperation {
|
|
71
|
+
operationId: string;
|
|
72
|
+
summary: string;
|
|
73
|
+
description: string;
|
|
74
|
+
requestBody?: {
|
|
75
|
+
required: boolean;
|
|
76
|
+
content: {
|
|
77
|
+
'application/json': {
|
|
78
|
+
schema: JsonSchema | {
|
|
79
|
+
$ref: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
responses: Record<string, {
|
|
85
|
+
description: string;
|
|
86
|
+
content?: {
|
|
87
|
+
'application/json': {
|
|
88
|
+
schema: JsonSchema | {
|
|
89
|
+
$ref: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
@@ -23,8 +23,6 @@ export type StageNode<TOut = any, TScope = any> = {
|
|
|
23
23
|
name: string;
|
|
24
24
|
/** Optional stable id (required by decider/fork aggregation) */
|
|
25
25
|
id?: string;
|
|
26
|
-
/** Human-readable display name for UI */
|
|
27
|
-
displayName?: string;
|
|
28
26
|
/** Description of what this stage does. Used for narrative and tool descriptions. */
|
|
29
27
|
description?: string;
|
|
30
28
|
/** Linear continuation (linked list next pointer) */
|
|
@@ -14,16 +14,16 @@ import type { IControlFlowNarrative } from './types';
|
|
|
14
14
|
export declare class ControlFlowNarrativeGenerator implements IControlFlowNarrative {
|
|
15
15
|
private sentences;
|
|
16
16
|
private isFirstStage;
|
|
17
|
-
onStageExecuted(stageName: string,
|
|
18
|
-
onNext(fromStage: string, toStage: string,
|
|
19
|
-
onDecision(deciderName: string, chosenBranch: string,
|
|
17
|
+
onStageExecuted(stageName: string, description?: string): void;
|
|
18
|
+
onNext(fromStage: string, toStage: string, description?: string): void;
|
|
19
|
+
onDecision(deciderName: string, chosenBranch: string, rationale?: string, deciderDescription?: string): void;
|
|
20
20
|
onFork(parentStage: string, childNames: string[]): void;
|
|
21
21
|
onSelected(parentStage: string, selectedNames: string[], totalCount: number): void;
|
|
22
22
|
onSubflowEntry(subflowName: string): void;
|
|
23
23
|
onSubflowExit(subflowName: string): void;
|
|
24
|
-
onLoop(targetStage: string,
|
|
25
|
-
onBreak(stageName: string
|
|
26
|
-
onError(stageName: string, errorMessage: string
|
|
24
|
+
onLoop(targetStage: string, iteration: number, description?: string): void;
|
|
25
|
+
onBreak(stageName: string): void;
|
|
26
|
+
onError(stageName: string, errorMessage: string): void;
|
|
27
27
|
/** Returns a defensive copy of accumulated sentences. */
|
|
28
28
|
getSentences(): string[];
|
|
29
29
|
}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export interface IControlFlowNarrative {
|
|
11
11
|
/** Called when a stage executes. First stage uses distinct opening pattern. */
|
|
12
|
-
onStageExecuted(stageName: string,
|
|
12
|
+
onStageExecuted(stageName: string, description?: string): void;
|
|
13
13
|
/** Called on linear continuation from one stage to the next. */
|
|
14
|
-
onNext(fromStage: string, toStage: string,
|
|
14
|
+
onNext(fromStage: string, toStage: string, description?: string): void;
|
|
15
15
|
/** Called when a decider selects a branch. Most valuable for LLM context. */
|
|
16
|
-
onDecision(deciderName: string, chosenBranch: string,
|
|
16
|
+
onDecision(deciderName: string, chosenBranch: string, rationale?: string, deciderDescription?: string): void;
|
|
17
17
|
/** Called when a fork executes all children in parallel. */
|
|
18
18
|
onFork(parentStage: string, childNames: string[]): void;
|
|
19
19
|
/** Called when a selector picks a subset of children. */
|
|
@@ -23,11 +23,11 @@ export interface IControlFlowNarrative {
|
|
|
23
23
|
/** Called when exiting a subflow. */
|
|
24
24
|
onSubflowExit(subflowName: string): void;
|
|
25
25
|
/** Called on loop iteration (back-edge traversal). */
|
|
26
|
-
onLoop(targetStage: string,
|
|
26
|
+
onLoop(targetStage: string, iteration: number, description?: string): void;
|
|
27
27
|
/** Called when a stage triggers break (early termination). */
|
|
28
|
-
onBreak(stageName: string
|
|
28
|
+
onBreak(stageName: string): void;
|
|
29
29
|
/** Called when a stage throws an error. */
|
|
30
|
-
onError(stageName: string, errorMessage: string
|
|
30
|
+
onError(stageName: string, errorMessage: string): void;
|
|
31
31
|
/** Returns accumulated narrative sentences in execution order. */
|
|
32
32
|
getSentences(): string[];
|
|
33
33
|
}
|
|
@@ -169,7 +169,6 @@ export interface SerializedPipelineNode {
|
|
|
169
169
|
name: string;
|
|
170
170
|
id?: string;
|
|
171
171
|
type?: 'stage' | 'decider' | 'fork' | 'streaming' | 'loop' | 'user' | 'tool' | 'function' | 'sequence';
|
|
172
|
-
displayName?: string;
|
|
173
172
|
description?: string;
|
|
174
173
|
children?: SerializedPipelineNode[];
|
|
175
174
|
next?: SerializedPipelineNode;
|
|
@@ -16,7 +16,6 @@ import type { CommitBundle, FlowMessage, StageSnapshot } from '../memory/types';
|
|
|
16
16
|
export interface NarrativeEntry {
|
|
17
17
|
stageId: string;
|
|
18
18
|
stageName: string;
|
|
19
|
-
displayName?: string;
|
|
20
19
|
stageMessages: string[];
|
|
21
20
|
flowMessage?: FlowMessage;
|
|
22
21
|
timeIndex: number;
|
package/package.json
CHANGED