@decaf-ts/integrations 0.6.2 → 0.7.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.
Files changed (93) hide show
  1. package/dist/integrations.cjs +1 -1
  2. package/jest.config.cjs +10 -0
  3. package/lib/cjs/graph/engine/execution/GraphExecutionContext.cjs +23 -2
  4. package/lib/cjs/graph/engine/execution/GraphExecutionContext.cjs.map +1 -1
  5. package/lib/cjs/graph/engine/execution/GraphExecutionEngine.cjs +76 -0
  6. package/lib/cjs/graph/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  7. package/lib/cjs/graph/engine/execution/LogGraphNodeExecutor.cjs +29 -4
  8. package/lib/cjs/graph/engine/execution/LogGraphNodeExecutor.cjs.map +1 -1
  9. package/lib/cjs/graph/index.cjs +1 -0
  10. package/lib/cjs/graph/index.cjs.map +1 -1
  11. package/lib/cjs/graph/log/GraphRunLogger.cjs +142 -0
  12. package/lib/cjs/graph/log/GraphRunLogger.cjs.map +1 -0
  13. package/lib/cjs/graph/log/LogParameters.cjs +73 -0
  14. package/lib/cjs/graph/log/LogParameters.cjs.map +1 -0
  15. package/lib/cjs/graph/shared/GraphExecutionStateMapper.cjs +97 -0
  16. package/lib/cjs/graph/shared/GraphExecutionStateMapper.cjs.map +1 -0
  17. package/lib/cjs/graph/shared/constants.cjs +56 -1
  18. package/lib/cjs/graph/shared/constants.cjs.map +1 -1
  19. package/lib/cjs/graph/shared/index.cjs +9 -1
  20. package/lib/cjs/graph/shared/index.cjs.map +1 -1
  21. package/lib/cjs/graph/shared/nodes/flow-control.cjs +50 -6
  22. package/lib/cjs/graph/shared/nodes/flow-control.cjs.map +1 -1
  23. package/lib/cjs/index.cjs +3 -3
  24. package/lib/cjs/nest/graph/GraphExecutionResultModel.cjs +1 -1
  25. package/lib/cjs/nest/graph/GraphExecutionResultModel.cjs.map +1 -1
  26. package/lib/cjs/nest/graph/GraphExecutorRegistryFactory.cjs +4 -3
  27. package/lib/cjs/nest/graph/GraphExecutorRegistryFactory.cjs.map +1 -1
  28. package/lib/cjs/nest/graph/GraphWorkflowModel.cjs +1 -5
  29. package/lib/cjs/nest/graph/GraphWorkflowModel.cjs.map +1 -1
  30. package/lib/cjs/user-requests/index.cjs +27 -0
  31. package/lib/cjs/user-requests/index.cjs.map +1 -0
  32. package/lib/esm/graph/engine/execution/GraphExecutionContext.js +23 -2
  33. package/lib/esm/graph/engine/execution/GraphExecutionContext.js.map +1 -1
  34. package/lib/esm/graph/engine/execution/GraphExecutionEngine.js +77 -1
  35. package/lib/esm/graph/engine/execution/GraphExecutionEngine.js.map +1 -1
  36. package/lib/esm/graph/engine/execution/LogGraphNodeExecutor.js +29 -4
  37. package/lib/esm/graph/engine/execution/LogGraphNodeExecutor.js.map +1 -1
  38. package/lib/esm/graph/index.js +1 -0
  39. package/lib/esm/graph/index.js.map +1 -1
  40. package/lib/esm/graph/log/GraphRunLogger.js +137 -0
  41. package/lib/esm/graph/log/GraphRunLogger.js.map +1 -0
  42. package/lib/esm/graph/log/LogParameters.js +69 -0
  43. package/lib/esm/graph/log/LogParameters.js.map +1 -0
  44. package/lib/esm/graph/shared/GraphExecutionStateMapper.js +91 -0
  45. package/lib/esm/graph/shared/GraphExecutionStateMapper.js.map +1 -0
  46. package/lib/esm/graph/shared/constants.js +82 -3
  47. package/lib/esm/graph/shared/constants.js.map +1 -1
  48. package/lib/esm/graph/shared/index.js +6 -0
  49. package/lib/esm/graph/shared/index.js.map +1 -1
  50. package/lib/esm/graph/shared/nodes/flow-control.js +49 -5
  51. package/lib/esm/graph/shared/nodes/flow-control.js.map +1 -1
  52. package/lib/esm/index.js +3 -3
  53. package/lib/esm/nest/graph/GraphExecutionResultModel.js +3 -3
  54. package/lib/esm/nest/graph/GraphExecutionResultModel.js.map +1 -1
  55. package/lib/esm/nest/graph/GraphExecutorRegistryFactory.js +4 -3
  56. package/lib/esm/nest/graph/GraphExecutorRegistryFactory.js.map +1 -1
  57. package/lib/esm/nest/graph/GraphWorkflowModel.js +3 -7
  58. package/lib/esm/nest/graph/GraphWorkflowModel.js.map +1 -1
  59. package/lib/esm/user-requests/index.js +10 -0
  60. package/lib/esm/user-requests/index.js.map +1 -0
  61. package/lib/types/graph/engine/execution/GraphExecutionContext.d.cts +12 -2
  62. package/lib/types/graph/engine/execution/GraphExecutionContext.d.mts +12 -2
  63. package/lib/types/graph/engine/execution/GraphExecutionEngine.d.cts +34 -1
  64. package/lib/types/graph/engine/execution/GraphExecutionEngine.d.mts +34 -1
  65. package/lib/types/graph/engine/execution/LogGraphNodeExecutor.d.cts +16 -10
  66. package/lib/types/graph/engine/execution/LogGraphNodeExecutor.d.mts +16 -10
  67. package/lib/types/graph/index.d.cts +1 -0
  68. package/lib/types/graph/index.d.mts +1 -0
  69. package/lib/types/graph/log/GraphRunLogger.d.cts +72 -0
  70. package/lib/types/graph/log/GraphRunLogger.d.mts +72 -0
  71. package/lib/types/graph/log/LogParameters.d.cts +7 -0
  72. package/lib/types/graph/log/LogParameters.d.mts +7 -0
  73. package/lib/types/graph/shared/GraphExecutionStateMapper.d.cts +66 -0
  74. package/lib/types/graph/shared/GraphExecutionStateMapper.d.mts +66 -0
  75. package/lib/types/graph/shared/constants.d.cts +70 -3
  76. package/lib/types/graph/shared/constants.d.mts +70 -3
  77. package/lib/types/graph/shared/index.d.cts +3 -0
  78. package/lib/types/graph/shared/index.d.mts +3 -0
  79. package/lib/types/graph/shared/nodes/flow-control.d.cts +20 -7
  80. package/lib/types/graph/shared/nodes/flow-control.d.mts +20 -7
  81. package/lib/types/graph/shared/types.d.cts +94 -5
  82. package/lib/types/graph/shared/types.d.mts +94 -5
  83. package/lib/types/index.d.cts +2 -2
  84. package/lib/types/index.d.mts +2 -2
  85. package/lib/types/nest/graph/GraphExecutionResultModel.d.cts +3 -3
  86. package/lib/types/nest/graph/GraphExecutionResultModel.d.mts +3 -3
  87. package/lib/types/nest/graph/GraphExecutorRegistryFactory.d.cts +3 -3
  88. package/lib/types/nest/graph/GraphExecutorRegistryFactory.d.mts +3 -3
  89. package/lib/types/nest/graph/GraphWorkflowModel.d.cts +3 -4
  90. package/lib/types/nest/graph/GraphWorkflowModel.d.mts +3 -4
  91. package/lib/types/user-requests/index.d.cts +9 -0
  92. package/lib/types/user-requests/index.d.mts +9 -0
  93. package/package.json +13 -2
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @module integrations/graph/shared/GraphExecutionStateMapper
3
+ * @summary Maps engine state to the frontend-safe visual-state contract.
4
+ * @description Pure, engine-agnostic helpers that derive
5
+ * {@link GraphVisualState} values from engine execution signals. Frontend
6
+ * bundles may import this from `@decaf-ts/integrations/graph/shared` (no
7
+ * engine runtime dependency); a future Mastra/NestJS driver maps its own
8
+ * runtime states onto {@link GraphVisualState} with the same rules.
9
+ */
10
+ import type { GraphExecutionEvent } from "./types.d.mts";
11
+ import { GraphExecutionStatus, GraphVisualState } from "./constants.d.mts";
12
+ /**
13
+ * Maps an engine execution {@link GraphExecutionStatus} to the shared visual
14
+ * state. `CACHED` collapses onto {@link GraphVisualState.SUCCEEDED} for
15
+ * rendering; `CANCELLED`/`PENDING`/`PLANNING` yield `IDLE`.
16
+ *
17
+ * @param status - The engine execution status, if any.
18
+ * @returns The visual state for the node/edge.
19
+ */
20
+ export declare function mapExecutionStatus(status?: GraphExecutionStatus): GraphVisualState;
21
+ /**
22
+ * Options describing a single node's position within a run (DECAF-48 §4.4).
23
+ */
24
+ export interface GraphVisualStateDerivation {
25
+ /** Whether the node has already executed (any terminal engine status). */
26
+ executed: boolean;
27
+ /** Whether the node is currently running. */
28
+ running: boolean;
29
+ /** Whether the node completed successfully (or from cache). */
30
+ succeeded?: boolean;
31
+ /** Whether the node failed. */
32
+ failed?: boolean;
33
+ /** Number of incoming edges that have completed value routing. */
34
+ completedUpstreams?: number;
35
+ /** Total number of incoming edges for the node. */
36
+ upstreamCount?: number;
37
+ /** Whether the node is reachable from the workflow inputs in the plan. */
38
+ reachable?: boolean;
39
+ /** Whether the whole run has failed (unexecuted nodes then fade/disable). */
40
+ runFailed?: boolean;
41
+ }
42
+ /**
43
+ * Derives the visual state for one node from its execution signals.
44
+ *
45
+ * Rules (DECAF-48 §4.4 / Req-5/Req-6):
46
+ * - currently running → {@link GraphVisualState.RUNNING}
47
+ * - failed → {@link GraphVisualState.FAILED}
48
+ * - executed and succeeded (or from cache) → {@link GraphVisualState.SUCCEEDED}
49
+ * - unexecuted and reachable with incomplete upstream deps → {@link GraphVisualState.BLOCKED}
50
+ * - unexecuted with `runFailed` → {@link GraphVisualState.SKIPPED} (faded/disabled)
51
+ * - otherwise → {@link GraphVisualState.IDLE}
52
+ *
53
+ * @param options - The node execution signals.
54
+ * @returns The derived visual state.
55
+ */
56
+ export declare function deriveNodeVisualState(options: GraphVisualStateDerivation): GraphVisualState;
57
+ /**
58
+ * Translates a {@link GraphExecutionEvent} into a node visual state when the
59
+ * event carries enough information. Used by contract conformance checks and
60
+ * engine-agnostic consumers that derive state from the shared event stream.
61
+ *
62
+ * @param event - The graph execution event.
63
+ * @returns The corresponding {@link GraphVisualState}, or `IDLE` when the
64
+ * event does not indicate a specific visual transition.
65
+ */
66
+ export declare function visualStateOfEvent(event: GraphExecutionEvent): GraphVisualState;
@@ -2,9 +2,14 @@
2
2
  * @module integrations/graph/shared/constants
3
3
  * @summary Frontend-safe graph constants and enums.
4
4
  * @description Constants and enumerations that are safe to import from a
5
- * frontend bundle (no engine runtime dependency). The execution-status and
6
- * event-type enums live here because the frontend renders status badges and
7
- * event timelines and must not pull in the execution engine.
5
+ * frontend bundle (no engine runtime dependency). Alongside the existing
6
+ * execution-status and event-type enums (rendered as status badges and event
7
+ * timelines), this module carries the DECAF-48 visual-state contract: the
8
+ * frontend-safe {@link GraphVisualState} enum, the `graph.run.log` /
9
+ * `graph.run.state` SSE topic constants, the run-log attribute keys
10
+ * ({@link GraphLogAttribute}), and the `NODE_STATE_CHANGED` /
11
+ * `EDGE_STATE_CHANGED` / `GRAPH_RUN_LOG` event types. The frontend must not
12
+ * pull in the execution engine.
8
13
  */
9
14
  /**
10
15
  * Execution status for a workflow or individual node.
@@ -19,8 +24,64 @@ export declare enum GraphExecutionStatus {
19
24
  CANCELLED = "cancelled",
20
25
  CACHED = "cached"
21
26
  }
27
+ /**
28
+ * Visual execution state for a node or edge on the workflow canvas.
29
+ *
30
+ * Frontend-safe (DECAF-48 §4.4): a superset of {@link GraphExecutionStatus}
31
+ * normalised for rendering. `BLOCKED` is derived from the plan and execution
32
+ * events (waiting on upstream dependencies), not emitted as an engine status.
33
+ * `SKIPPED` is the post-failure "unexecuted/disabled" visual state.
34
+ */
35
+ export declare enum GraphVisualState {
36
+ IDLE = "idle",
37
+ RUNNING = "running",
38
+ BLOCKED = "blocked",
39
+ SUCCEEDED = "succeeded",
40
+ FAILED = "failed",
41
+ SKIPPED = "skipped"
42
+ }
43
+ /**
44
+ * Namespace root for graph run SSE topics (DECAF-48 §4.2). A subscription
45
+ * filters on these granular topics before `observer.next(...)`.
46
+ */
47
+ export declare const GRAPH_RUN_TOPIC = "graph.run";
48
+ /**
49
+ * SSE sub-topic streaming per-node log lines during a run.
50
+ */
51
+ export declare const GRAPH_RUN_LOG_TOPIC = "graph.run.log";
52
+ /**
53
+ * SSE sub-topic streaming node/edge execution-state updates during a run.
54
+ */
55
+ export declare const GRAPH_RUN_STATE_TOPIC = "graph.run.state";
56
+ /**
57
+ * Logger custom-attribute keys attached to every run log line via
58
+ * DECAF-9 `logger.for({...})` (DECAF-48 §4.3). Rendered as discrete columns
59
+ * (not buried in the message string).
60
+ */
61
+ export declare enum GraphLogAttribute {
62
+ NODE_ID = "nodeId",
63
+ WORKFLOW_ID = "workflowId",
64
+ RUN_ID = "runId",
65
+ USER = "user"
66
+ }
67
+ /**
68
+ * Namespace topic helper for a graph execution event.
69
+ *
70
+ * Log-carrier events resolve to `graph.run.log`; node/edge execution-state
71
+ * events resolve to `graph.run.state`; everything else stays under the shared
72
+ * `graph.run` topic and is only delivered to subscribers that match it.
73
+ *
74
+ * @param eventType - The graph execution event type to scope to a topic.
75
+ * @returns The SSE topic constant for the given event type.
76
+ */
77
+ export declare function graphRunTopicOf(eventType: GraphExecutionEventType): string;
22
78
  /**
23
79
  * Event types emitted through the graph execution observer pipeline.
80
+ *
81
+ * DECAF-48 extends this set with the visual-state and run-log event types the
82
+ * engine emits on the existing Observable: {@link GraphExecutionEventType.NODE_STATE_CHANGED},
83
+ * {@link GraphExecutionEventType.EDGE_STATE_CHANGED} and
84
+ * {@link GraphExecutionEventType.GRAPH_RUN_LOG}.
24
85
  */
25
86
  export declare enum GraphExecutionEventType {
26
87
  WORKFLOW_STARTED = "workflow.started",
@@ -37,7 +98,13 @@ export declare enum GraphExecutionEventType {
37
98
  NODE_CACHE_HIT = "node.cacheHit",
38
99
  NODE_PINNED = "node.pinned",
39
100
  NODE_UNPINNED = "node.unpinned",
101
+ /** Node execution-state transition carrying a `GraphNodeStateChangedPayload` (DECAF-48 §4.4). */
102
+ NODE_STATE_CHANGED = "node.stateChanged",
40
103
  EDGE_VALUE_ROUTED = "edge.valueRouted",
104
+ /** Edge execution-state transition carrying a `GraphEdgeStateChangedPayload` (DECAF-48 §4.4). */
105
+ EDGE_STATE_CHANGED = "edge.stateChanged",
106
+ /** Structured run log line carrying a `GraphRunLogEntry` (DECAF-48 §4.3). */
107
+ GRAPH_RUN_LOG = "graph.run.log",
41
108
  LOOP_STARTED = "loop.started",
42
109
  LOOP_ITERATION_STARTED = "loop.iteration.started",
43
110
  LOOP_ITERATION_COMPLETED = "loop.iteration.completed",
@@ -2,9 +2,14 @@
2
2
  * @module integrations/graph/shared/constants
3
3
  * @summary Frontend-safe graph constants and enums.
4
4
  * @description Constants and enumerations that are safe to import from a
5
- * frontend bundle (no engine runtime dependency). The execution-status and
6
- * event-type enums live here because the frontend renders status badges and
7
- * event timelines and must not pull in the execution engine.
5
+ * frontend bundle (no engine runtime dependency). Alongside the existing
6
+ * execution-status and event-type enums (rendered as status badges and event
7
+ * timelines), this module carries the DECAF-48 visual-state contract: the
8
+ * frontend-safe {@link GraphVisualState} enum, the `graph.run.log` /
9
+ * `graph.run.state` SSE topic constants, the run-log attribute keys
10
+ * ({@link GraphLogAttribute}), and the `NODE_STATE_CHANGED` /
11
+ * `EDGE_STATE_CHANGED` / `GRAPH_RUN_LOG` event types. The frontend must not
12
+ * pull in the execution engine.
8
13
  */
9
14
  /**
10
15
  * Execution status for a workflow or individual node.
@@ -19,8 +24,64 @@ export declare enum GraphExecutionStatus {
19
24
  CANCELLED = "cancelled",
20
25
  CACHED = "cached"
21
26
  }
27
+ /**
28
+ * Visual execution state for a node or edge on the workflow canvas.
29
+ *
30
+ * Frontend-safe (DECAF-48 §4.4): a superset of {@link GraphExecutionStatus}
31
+ * normalised for rendering. `BLOCKED` is derived from the plan and execution
32
+ * events (waiting on upstream dependencies), not emitted as an engine status.
33
+ * `SKIPPED` is the post-failure "unexecuted/disabled" visual state.
34
+ */
35
+ export declare enum GraphVisualState {
36
+ IDLE = "idle",
37
+ RUNNING = "running",
38
+ BLOCKED = "blocked",
39
+ SUCCEEDED = "succeeded",
40
+ FAILED = "failed",
41
+ SKIPPED = "skipped"
42
+ }
43
+ /**
44
+ * Namespace root for graph run SSE topics (DECAF-48 §4.2). A subscription
45
+ * filters on these granular topics before `observer.next(...)`.
46
+ */
47
+ export declare const GRAPH_RUN_TOPIC = "graph.run";
48
+ /**
49
+ * SSE sub-topic streaming per-node log lines during a run.
50
+ */
51
+ export declare const GRAPH_RUN_LOG_TOPIC = "graph.run.log";
52
+ /**
53
+ * SSE sub-topic streaming node/edge execution-state updates during a run.
54
+ */
55
+ export declare const GRAPH_RUN_STATE_TOPIC = "graph.run.state";
56
+ /**
57
+ * Logger custom-attribute keys attached to every run log line via
58
+ * DECAF-9 `logger.for({...})` (DECAF-48 §4.3). Rendered as discrete columns
59
+ * (not buried in the message string).
60
+ */
61
+ export declare enum GraphLogAttribute {
62
+ NODE_ID = "nodeId",
63
+ WORKFLOW_ID = "workflowId",
64
+ RUN_ID = "runId",
65
+ USER = "user"
66
+ }
67
+ /**
68
+ * Namespace topic helper for a graph execution event.
69
+ *
70
+ * Log-carrier events resolve to `graph.run.log`; node/edge execution-state
71
+ * events resolve to `graph.run.state`; everything else stays under the shared
72
+ * `graph.run` topic and is only delivered to subscribers that match it.
73
+ *
74
+ * @param eventType - The graph execution event type to scope to a topic.
75
+ * @returns The SSE topic constant for the given event type.
76
+ */
77
+ export declare function graphRunTopicOf(eventType: GraphExecutionEventType): string;
22
78
  /**
23
79
  * Event types emitted through the graph execution observer pipeline.
80
+ *
81
+ * DECAF-48 extends this set with the visual-state and run-log event types the
82
+ * engine emits on the existing Observable: {@link GraphExecutionEventType.NODE_STATE_CHANGED},
83
+ * {@link GraphExecutionEventType.EDGE_STATE_CHANGED} and
84
+ * {@link GraphExecutionEventType.GRAPH_RUN_LOG}.
24
85
  */
25
86
  export declare enum GraphExecutionEventType {
26
87
  WORKFLOW_STARTED = "workflow.started",
@@ -37,7 +98,13 @@ export declare enum GraphExecutionEventType {
37
98
  NODE_CACHE_HIT = "node.cacheHit",
38
99
  NODE_PINNED = "node.pinned",
39
100
  NODE_UNPINNED = "node.unpinned",
101
+ /** Node execution-state transition carrying a `GraphNodeStateChangedPayload` (DECAF-48 §4.4). */
102
+ NODE_STATE_CHANGED = "node.stateChanged",
40
103
  EDGE_VALUE_ROUTED = "edge.valueRouted",
104
+ /** Edge execution-state transition carrying a `GraphEdgeStateChangedPayload` (DECAF-48 §4.4). */
105
+ EDGE_STATE_CHANGED = "edge.stateChanged",
106
+ /** Structured run log line carrying a `GraphRunLogEntry` (DECAF-48 §4.3). */
107
+ GRAPH_RUN_LOG = "graph.run.log",
41
108
  LOOP_STARTED = "loop.started",
42
109
  LOOP_ITERATION_STARTED = "loop.iteration.started",
43
110
  LOOP_ITERATION_COMPLETED = "loop.iteration.completed",
@@ -15,4 +15,7 @@ import "@decaf-ts/ui-decorators/graph";
15
15
  export { Metadata } from "@decaf-ts/decoration";
16
16
  export * from "./constants.d.cts";
17
17
  export * from "./types.d.cts";
18
+ export * from "./GraphExecutionStateMapper.d.cts";
18
19
  export * from "./nodes/index.d.cts";
20
+ export { GRAPH_VISUAL_STATE_STYLES, graphVisualStyleOf, } from "@decaf-ts/ui-decorators/graph";
21
+ export type { GraphNodeIoMetadata, GraphNodeIoViewMode, GraphVisualStyle, } from "@decaf-ts/ui-decorators/graph";
@@ -15,4 +15,7 @@ import "@decaf-ts/ui-decorators/graph";
15
15
  export { Metadata } from "@decaf-ts/decoration";
16
16
  export * from "./constants.d.mts";
17
17
  export * from "./types.d.mts";
18
+ export * from "./GraphExecutionStateMapper.d.mts";
18
19
  export * from "./nodes/index.d.mts";
20
+ export { GRAPH_VISUAL_STATE_STYLES, graphVisualStyleOf, } from "@decaf-ts/ui-decorators/graph";
21
+ export type { GraphNodeIoMetadata, GraphNodeIoViewMode, GraphVisualStyle, } from "@decaf-ts/ui-decorators/graph";
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * @module integrations/graph/nodes/flow-control
3
3
  * @summary Production flow-control node kind declarations (DECAF-32 §22.2.2).
4
- * @description Canonical `@node`-decorated classes for the ten ALFRED-5
5
- * flow-control kinds. These are graph-level macros: the engine's planner
6
- * recognises them as ordinary executable nodes (§5.7) but they have no
7
- * built-in executors — downstream projects (e.g. ALFRED) register custom
8
- * executors or compile them into Mastra composition APIs (§22.2.2).
4
+ * @description Canonical `@node`-decorated classes for the ALFRED-5
5
+ * flow-control kinds, plus the DECAF-48 `core.utility.log` Log node. These
6
+ * are graph-level macros: the engine's planner recognises them as ordinary
7
+ * executable nodes (§5.7) but they have no built-in executors — downstream
8
+ * projects (e.g. ALFRED) register custom executors or compile them into
9
+ * Mastra composition APIs (§22.2.2). The `core.utility.log` node is the one
10
+ * exception: its {@link LogGraphNodeExecutor} is built in and logs the input
11
+ * through the run's `ctx.logger` (DECAF-48 §4.3).
9
12
  *
10
13
  * The three loop kinds (`core.loop.foreach/while/until`) already have built-in
11
14
  * executors (§5.9) and are NOT redeclared here.
12
15
  */
13
16
  import { Model } from "@decaf-ts/decorator-validation";
14
- import type { NodeMetadataChange, SwitchNodeMetadata } from "../types.d.cts";
17
+ import type { LogNodeLevel, NodeMetadataChange, SwitchNodeMetadata } from "../types.d.cts";
15
18
  import { GraphNode } from "./base.d.cts";
16
19
  /**
17
20
  * If — conditional branch. Evaluates a `ConditionExpression` (§22.3) and
@@ -133,6 +136,16 @@ export declare class LogFlowNode extends Model {
133
136
  value: unknown;
134
137
  logged: unknown;
135
138
  }
139
+ /**
140
+ * Utility Log — logs the input value through the run's `ctx.logger` at a
141
+ * configurable level and forwards it unchanged on the `logged` output port
142
+ * (DECAF-48 §4.3).
143
+ */
144
+ export declare class UtilityLogNode extends Model {
145
+ value: unknown;
146
+ level: LogNodeLevel;
147
+ logged: unknown;
148
+ }
136
149
  /**
137
150
  * Break — breaks out of the enclosing loop (foreach/while/until). When
138
151
  * executed inside a loop body, the loop terminates early and the loop's
@@ -147,4 +160,4 @@ export declare class BreakFlowNode extends Model {
147
160
  /**
148
161
  * All built-in flow-control node constructors.
149
162
  */
150
- export declare const GRAPH_FLOW_CONTROL_NODES: readonly [typeof IfFlowNode, typeof SwitchFlowNode, typeof ParallelFlowNode, typeof MergeFlowNode, typeof MapFlowNode, typeof DelayFlowNode, typeof ErrorBoundaryFlowNode, typeof HumanApprovalFlowNode, typeof ReturnFlowNode, typeof CodeFlowNode, typeof LogFlowNode, typeof BreakFlowNode];
163
+ export declare const GRAPH_FLOW_CONTROL_NODES: readonly [typeof IfFlowNode, typeof SwitchFlowNode, typeof ParallelFlowNode, typeof MergeFlowNode, typeof MapFlowNode, typeof DelayFlowNode, typeof ErrorBoundaryFlowNode, typeof HumanApprovalFlowNode, typeof ReturnFlowNode, typeof CodeFlowNode, typeof LogFlowNode, typeof UtilityLogNode, typeof BreakFlowNode];
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * @module integrations/graph/nodes/flow-control
3
3
  * @summary Production flow-control node kind declarations (DECAF-32 §22.2.2).
4
- * @description Canonical `@node`-decorated classes for the ten ALFRED-5
5
- * flow-control kinds. These are graph-level macros: the engine's planner
6
- * recognises them as ordinary executable nodes (§5.7) but they have no
7
- * built-in executors — downstream projects (e.g. ALFRED) register custom
8
- * executors or compile them into Mastra composition APIs (§22.2.2).
4
+ * @description Canonical `@node`-decorated classes for the ALFRED-5
5
+ * flow-control kinds, plus the DECAF-48 `core.utility.log` Log node. These
6
+ * are graph-level macros: the engine's planner recognises them as ordinary
7
+ * executable nodes (§5.7) but they have no built-in executors — downstream
8
+ * projects (e.g. ALFRED) register custom executors or compile them into
9
+ * Mastra composition APIs (§22.2.2). The `core.utility.log` node is the one
10
+ * exception: its {@link LogGraphNodeExecutor} is built in and logs the input
11
+ * through the run's `ctx.logger` (DECAF-48 §4.3).
9
12
  *
10
13
  * The three loop kinds (`core.loop.foreach/while/until`) already have built-in
11
14
  * executors (§5.9) and are NOT redeclared here.
12
15
  */
13
16
  import { Model } from "@decaf-ts/decorator-validation";
14
- import type { NodeMetadataChange, SwitchNodeMetadata } from "../types.d.mts";
17
+ import type { LogNodeLevel, NodeMetadataChange, SwitchNodeMetadata } from "../types.d.mts";
15
18
  import { GraphNode } from "./base.d.mts";
16
19
  /**
17
20
  * If — conditional branch. Evaluates a `ConditionExpression` (§22.3) and
@@ -133,6 +136,16 @@ export declare class LogFlowNode extends Model {
133
136
  value: unknown;
134
137
  logged: unknown;
135
138
  }
139
+ /**
140
+ * Utility Log — logs the input value through the run's `ctx.logger` at a
141
+ * configurable level and forwards it unchanged on the `logged` output port
142
+ * (DECAF-48 §4.3).
143
+ */
144
+ export declare class UtilityLogNode extends Model {
145
+ value: unknown;
146
+ level: LogNodeLevel;
147
+ logged: unknown;
148
+ }
136
149
  /**
137
150
  * Break — breaks out of the enclosing loop (foreach/while/until). When
138
151
  * executed inside a loop body, the loop terminates early and the loop's
@@ -147,4 +160,4 @@ export declare class BreakFlowNode extends Model {
147
160
  /**
148
161
  * All built-in flow-control node constructors.
149
162
  */
150
- export declare const GRAPH_FLOW_CONTROL_NODES: readonly [typeof IfFlowNode, typeof SwitchFlowNode, typeof ParallelFlowNode, typeof MergeFlowNode, typeof MapFlowNode, typeof DelayFlowNode, typeof ErrorBoundaryFlowNode, typeof HumanApprovalFlowNode, typeof ReturnFlowNode, typeof CodeFlowNode, typeof LogFlowNode, typeof BreakFlowNode];
163
+ export declare const GRAPH_FLOW_CONTROL_NODES: readonly [typeof IfFlowNode, typeof SwitchFlowNode, typeof ParallelFlowNode, typeof MergeFlowNode, typeof MapFlowNode, typeof DelayFlowNode, typeof ErrorBoundaryFlowNode, typeof HumanApprovalFlowNode, typeof ReturnFlowNode, typeof CodeFlowNode, typeof LogFlowNode, typeof UtilityLogNode, typeof BreakFlowNode];
@@ -2,13 +2,15 @@
2
2
  * @module integrations/graph/shared/types
3
3
  * @summary Frontend-safe graph type declarations.
4
4
  * @description Type aliases and interfaces that are safe to import from a
5
- * frontend bundle. These types describe declarative graph metadata (loop
6
- * condition DSL, switch cases, node metadata patches) and the execution-event
7
- * data contract consumed by the frontend via SSE — no engine runtime
8
- * dependency.
5
+ * frontend bundle. Alongside the declarative graph metadata types (loop
6
+ * condition DSL, switch cases, node metadata patches), this module carries the
7
+ * DECAF-48 execution contract consumed by the frontend via SSE: the node/edge
8
+ * state-change payloads, the structured run log entry, the node I/O
9
+ * inspection payload, the run-scoped subscription ownership tuple, and the
10
+ * Log-node level. All consumed over SSE — no engine runtime dependency.
9
11
  */
10
12
  import type { GraphPortDefinition } from "@decaf-ts/ui-decorators/graph";
11
- import type { GraphExecutionEventType, GraphExecutionStatus } from "./constants.d.cts";
13
+ import type { GraphExecutionEventType, GraphExecutionStatus, GraphVisualState } from "./constants.d.cts";
12
14
  /**
13
15
  * A value reference inside a {@link ConditionExpression}.
14
16
  *
@@ -166,3 +168,90 @@ export interface GraphExecutionEvent {
166
168
  error?: GraphExecutionErrorPayload;
167
169
  metadata?: Record<string, unknown>;
168
170
  }
171
+ /**
172
+ * Payload carried by `NODE_STATE_CHANGED` events (DECAF-48 §4.4).
173
+ *
174
+ * The visual state is the engine-agnostic contract a Mastra/NestJS driver
175
+ * MUST emit; the reference engine derives it from its own execution events.
176
+ */
177
+ export interface GraphNodeStateChangedPayload {
178
+ nodeId: string;
179
+ state: GraphVisualState;
180
+ runId: string;
181
+ workflowId: string;
182
+ /** Engine status that produced the visual state (when available). */
183
+ status?: GraphExecutionStatus;
184
+ iteration?: number;
185
+ }
186
+ /**
187
+ * Payload carried by `EDGE_STATE_CHANGED` events (DECAF-48 §4.4).
188
+ */
189
+ export interface GraphEdgeStateChangedPayload {
190
+ edgeId: string;
191
+ state: GraphVisualState;
192
+ runId: string;
193
+ workflowId: string;
194
+ /** Source node of the routed edge (when available). */
195
+ nodeId?: string;
196
+ /** Engine status that produced the visual state (when available). */
197
+ status?: GraphExecutionStatus;
198
+ }
199
+ /**
200
+ * Structured log line streamed over the `graph.run.log` SSE channel
201
+ * (DECAF-48 §4.3). Serialized from the run's `ctx.logger` output; the level
202
+ * drives the Chrome-console-style filter while the attributes render as
203
+ * discrete columns.
204
+ */
205
+ export interface GraphRunLogEntry {
206
+ /** Log severity level driving the Chrome-console-style widget filter (all `LogNodeLevel` values plus `benchmark`). */
207
+ level: "silly" | "trace" | "debug" | "verbose" | "info" | "warn" | "error" | "critical" | "fatal" | "benchmark";
208
+ message: string;
209
+ timestamp: string;
210
+ runId: string;
211
+ workflowId: string;
212
+ nodeId?: string;
213
+ user?: string | null;
214
+ /** Structured payload associated with the log line, if any. */
215
+ payload?: unknown;
216
+ }
217
+ /**
218
+ * Structured per-node I/O payload exposed for node inspection (DECAF-48 §4.6).
219
+ *
220
+ * Frontend-safe: pure data delivered via `graph/shared` types over the SSE
221
+ * state channel (or a `GET /graph/results/:runId` lookup); the frontend
222
+ * renders both panes (inputs right, outputs/error left) from this one shape.
223
+ */
224
+ export interface GraphNodeInspectionPayload {
225
+ runId: string;
226
+ workflowId: string;
227
+ nodeId: string;
228
+ state: GraphVisualState;
229
+ inputs: Record<string, unknown>;
230
+ /** Present when SUCCEEDED (or from cache). */
231
+ outputs?: Record<string, unknown>;
232
+ /** Present when FAILED. */
233
+ error?: GraphExecutionErrorPayload;
234
+ }
235
+ /**
236
+ * Log levels accepted by the Log node (DECAF-48 §4.3).
237
+ *
238
+ * Mirrors the DECAF-9 log level set so the Log node executor (and the
239
+ * {@link GraphRunLogger} dispatch) can forward onto the run's `ctx.logger`.
240
+ * Includes every level rendered by the Chrome-console-style widget filter.
241
+ */
242
+ export type LogNodeLevel = "silly" | "trace" | "debug" | "verbose" | "info" | "warn" | "error" | "critical" | "fatal";
243
+ /**
244
+ * Run-scoped SSE subscription ownership key (DECAF-48 §4.2).
245
+ *
246
+ * Subscription-mode SSE is keyed by run ownership: a consumer is only
247
+ * delivered graph events/logs for runs it owns. This tuple is the
248
+ * engine-agnostic contract a Mastra/NestJS driver MUST honour —
249
+ * `runId` together with the owning `user` (or a `system` runner when the
250
+ * identity is absent) scope every `graph.run.*` event before `next(...)`.
251
+ */
252
+ export interface GraphRunSubscription {
253
+ runId: string;
254
+ ownerUser: string | null;
255
+ /** Optional topic filter (e.g. `graph.run.log`, `graph.run.state`). */
256
+ topics?: string[];
257
+ }
@@ -2,13 +2,15 @@
2
2
  * @module integrations/graph/shared/types
3
3
  * @summary Frontend-safe graph type declarations.
4
4
  * @description Type aliases and interfaces that are safe to import from a
5
- * frontend bundle. These types describe declarative graph metadata (loop
6
- * condition DSL, switch cases, node metadata patches) and the execution-event
7
- * data contract consumed by the frontend via SSE — no engine runtime
8
- * dependency.
5
+ * frontend bundle. Alongside the declarative graph metadata types (loop
6
+ * condition DSL, switch cases, node metadata patches), this module carries the
7
+ * DECAF-48 execution contract consumed by the frontend via SSE: the node/edge
8
+ * state-change payloads, the structured run log entry, the node I/O
9
+ * inspection payload, the run-scoped subscription ownership tuple, and the
10
+ * Log-node level. All consumed over SSE — no engine runtime dependency.
9
11
  */
10
12
  import type { GraphPortDefinition } from "@decaf-ts/ui-decorators/graph";
11
- import type { GraphExecutionEventType, GraphExecutionStatus } from "./constants.d.mts";
13
+ import type { GraphExecutionEventType, GraphExecutionStatus, GraphVisualState } from "./constants.d.mts";
12
14
  /**
13
15
  * A value reference inside a {@link ConditionExpression}.
14
16
  *
@@ -166,3 +168,90 @@ export interface GraphExecutionEvent {
166
168
  error?: GraphExecutionErrorPayload;
167
169
  metadata?: Record<string, unknown>;
168
170
  }
171
+ /**
172
+ * Payload carried by `NODE_STATE_CHANGED` events (DECAF-48 §4.4).
173
+ *
174
+ * The visual state is the engine-agnostic contract a Mastra/NestJS driver
175
+ * MUST emit; the reference engine derives it from its own execution events.
176
+ */
177
+ export interface GraphNodeStateChangedPayload {
178
+ nodeId: string;
179
+ state: GraphVisualState;
180
+ runId: string;
181
+ workflowId: string;
182
+ /** Engine status that produced the visual state (when available). */
183
+ status?: GraphExecutionStatus;
184
+ iteration?: number;
185
+ }
186
+ /**
187
+ * Payload carried by `EDGE_STATE_CHANGED` events (DECAF-48 §4.4).
188
+ */
189
+ export interface GraphEdgeStateChangedPayload {
190
+ edgeId: string;
191
+ state: GraphVisualState;
192
+ runId: string;
193
+ workflowId: string;
194
+ /** Source node of the routed edge (when available). */
195
+ nodeId?: string;
196
+ /** Engine status that produced the visual state (when available). */
197
+ status?: GraphExecutionStatus;
198
+ }
199
+ /**
200
+ * Structured log line streamed over the `graph.run.log` SSE channel
201
+ * (DECAF-48 §4.3). Serialized from the run's `ctx.logger` output; the level
202
+ * drives the Chrome-console-style filter while the attributes render as
203
+ * discrete columns.
204
+ */
205
+ export interface GraphRunLogEntry {
206
+ /** Log severity level driving the Chrome-console-style widget filter (all `LogNodeLevel` values plus `benchmark`). */
207
+ level: "silly" | "trace" | "debug" | "verbose" | "info" | "warn" | "error" | "critical" | "fatal" | "benchmark";
208
+ message: string;
209
+ timestamp: string;
210
+ runId: string;
211
+ workflowId: string;
212
+ nodeId?: string;
213
+ user?: string | null;
214
+ /** Structured payload associated with the log line, if any. */
215
+ payload?: unknown;
216
+ }
217
+ /**
218
+ * Structured per-node I/O payload exposed for node inspection (DECAF-48 §4.6).
219
+ *
220
+ * Frontend-safe: pure data delivered via `graph/shared` types over the SSE
221
+ * state channel (or a `GET /graph/results/:runId` lookup); the frontend
222
+ * renders both panes (inputs right, outputs/error left) from this one shape.
223
+ */
224
+ export interface GraphNodeInspectionPayload {
225
+ runId: string;
226
+ workflowId: string;
227
+ nodeId: string;
228
+ state: GraphVisualState;
229
+ inputs: Record<string, unknown>;
230
+ /** Present when SUCCEEDED (or from cache). */
231
+ outputs?: Record<string, unknown>;
232
+ /** Present when FAILED. */
233
+ error?: GraphExecutionErrorPayload;
234
+ }
235
+ /**
236
+ * Log levels accepted by the Log node (DECAF-48 §4.3).
237
+ *
238
+ * Mirrors the DECAF-9 log level set so the Log node executor (and the
239
+ * {@link GraphRunLogger} dispatch) can forward onto the run's `ctx.logger`.
240
+ * Includes every level rendered by the Chrome-console-style widget filter.
241
+ */
242
+ export type LogNodeLevel = "silly" | "trace" | "debug" | "verbose" | "info" | "warn" | "error" | "critical" | "fatal";
243
+ /**
244
+ * Run-scoped SSE subscription ownership key (DECAF-48 §4.2).
245
+ *
246
+ * Subscription-mode SSE is keyed by run ownership: a consumer is only
247
+ * delivered graph events/logs for runs it owns. This tuple is the
248
+ * engine-agnostic contract a Mastra/NestJS driver MUST honour —
249
+ * `runId` together with the owning `user` (or a `system` runner when the
250
+ * identity is absent) scope every `graph.run.*` event before `next(...)`.
251
+ */
252
+ export interface GraphRunSubscription {
253
+ runId: string;
254
+ ownerUser: string | null;
255
+ /** Optional topic filter (e.g. `graph.run.log`, `graph.run.state`). */
256
+ topics?: string[];
257
+ }
@@ -7,6 +7,6 @@ export * from "./utils.d.cts";
7
7
  export * from "./namespaces/index.d.cts";
8
8
  export * from "./feature-flags/index.d.cts";
9
9
  export declare const VERSION: string;
10
- export declare const COMMIT = "2638fa3";
11
- export declare const FULL_VERSION = "0.6.1-2638fa3";
10
+ export declare const COMMIT = "6c8a9c2";
11
+ export declare const FULL_VERSION = "0.6.2-6c8a9c2";
12
12
  export declare const PACKAGE_NAME: string;
@@ -7,6 +7,6 @@ export * from "./utils.d.mts";
7
7
  export * from "./namespaces/index.d.mts";
8
8
  export * from "./feature-flags/index.d.mts";
9
9
  export declare const VERSION: string;
10
- export declare const COMMIT = "2638fa3";
11
- export declare const FULL_VERSION = "0.6.1-2638fa3";
10
+ export declare const COMMIT = "6c8a9c2";
11
+ export declare const FULL_VERSION = "0.6.2-6c8a9c2";
12
12
  export declare const PACKAGE_NAME: string;
@@ -1,5 +1,5 @@
1
- import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
2
- export declare class GraphExecutionResultModel extends Model {
1
+ import { BaseModel } from "@decaf-ts/core";
2
+ export declare class GraphExecutionResultModel extends BaseModel {
3
3
  runId: string;
4
4
  workflowId: string;
5
5
  status: string;
@@ -8,5 +8,5 @@ export declare class GraphExecutionResultModel extends Model {
8
8
  nodeResults: Record<string, unknown>;
9
9
  startedAt: Date;
10
10
  finishedAt?: Date;
11
- constructor(arg?: ModelArg<GraphExecutionResultModel>);
11
+ constructor(arg?: Partial<GraphExecutionResultModel>);
12
12
  }
@@ -1,5 +1,5 @@
1
- import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
2
- export declare class GraphExecutionResultModel extends Model {
1
+ import { BaseModel } from "@decaf-ts/core";
2
+ export declare class GraphExecutionResultModel extends BaseModel {
3
3
  runId: string;
4
4
  workflowId: string;
5
5
  status: string;
@@ -8,5 +8,5 @@ export declare class GraphExecutionResultModel extends Model {
8
8
  nodeResults: Record<string, unknown>;
9
9
  startedAt: Date;
10
10
  finishedAt?: Date;
11
- constructor(arg?: ModelArg<GraphExecutionResultModel>);
11
+ constructor(arg?: Partial<GraphExecutionResultModel>);
12
12
  }