@decaf-ts/integrations 0.3.11 → 0.4.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 (120) hide show
  1. package/dist/integrations.cjs +1 -1
  2. package/lib/cjs/graph/engine/execution/CodeGraphNodeExecutor.cjs +26 -29
  3. package/lib/cjs/graph/engine/execution/CodeGraphNodeExecutor.cjs.map +1 -1
  4. package/lib/cjs/graph/engine/execution/GraphExecutionEngine.cjs +20 -1
  5. package/lib/cjs/graph/engine/execution/GraphExecutionEngine.cjs.map +1 -1
  6. package/lib/cjs/graph/engine/execution/IsolatedVmCodeSandboxEvaluator.cjs +126 -0
  7. package/lib/cjs/graph/engine/execution/IsolatedVmCodeSandboxEvaluator.cjs.map +1 -1
  8. package/lib/cjs/graph/engine/execution/LogGraphNodeExecutor.cjs +19 -0
  9. package/lib/cjs/graph/engine/execution/LogGraphNodeExecutor.cjs.map +1 -0
  10. package/lib/cjs/graph/engine/execution/SwitchGraphNodeExecutor.cjs +21 -4
  11. package/lib/cjs/graph/engine/execution/SwitchGraphNodeExecutor.cjs.map +1 -1
  12. package/lib/cjs/graph/engine/execution/index.cjs +1 -0
  13. package/lib/cjs/graph/engine/execution/index.cjs.map +1 -1
  14. package/lib/cjs/graph/engine/index.cjs +1 -0
  15. package/lib/cjs/graph/engine/index.cjs.map +1 -1
  16. package/lib/cjs/graph/engine/loops/ForeachGraphNodeExecutor.cjs +1 -0
  17. package/lib/cjs/graph/engine/loops/ForeachGraphNodeExecutor.cjs.map +1 -1
  18. package/lib/cjs/graph/shared/nodes/flow-control.cjs +91 -9
  19. package/lib/cjs/graph/shared/nodes/flow-control.cjs.map +1 -1
  20. package/lib/cjs/index.cjs +3 -3
  21. package/lib/cjs/nest/graph/GraphExecutionController.cjs +39 -50
  22. package/lib/cjs/nest/graph/GraphExecutionController.cjs.map +1 -1
  23. package/lib/cjs/nest/graph/GraphExecutionModule.cjs +45 -40
  24. package/lib/cjs/nest/graph/GraphExecutionModule.cjs.map +1 -1
  25. package/lib/cjs/nest/graph/GraphExecutionResultModel.cjs +0 -18
  26. package/lib/cjs/nest/graph/GraphExecutionResultModel.cjs.map +1 -1
  27. package/lib/cjs/nest/graph/GraphExecutorRegistryFactory.cjs +11 -46
  28. package/lib/cjs/nest/graph/GraphExecutorRegistryFactory.cjs.map +1 -1
  29. package/lib/cjs/nest/graph/GraphResultService.cjs +54 -0
  30. package/lib/cjs/nest/graph/GraphResultService.cjs.map +1 -0
  31. package/lib/cjs/nest/graph/GraphWorkflowModel.cjs +44 -0
  32. package/lib/cjs/nest/graph/GraphWorkflowModel.cjs.map +1 -0
  33. package/lib/cjs/nest/graph/GraphWorkflowService.cjs +62 -0
  34. package/lib/cjs/nest/graph/GraphWorkflowService.cjs.map +1 -0
  35. package/lib/cjs/nest/graph/index.cjs +3 -6
  36. package/lib/cjs/nest/graph/index.cjs.map +1 -1
  37. package/lib/cjs/nest/graph/main.cjs +1 -1
  38. package/lib/cjs/nest/graph/main.cjs.map +1 -1
  39. package/lib/esm/graph/engine/execution/CodeGraphNodeExecutor.js +26 -29
  40. package/lib/esm/graph/engine/execution/CodeGraphNodeExecutor.js.map +1 -1
  41. package/lib/esm/graph/engine/execution/GraphExecutionEngine.js +20 -1
  42. package/lib/esm/graph/engine/execution/GraphExecutionEngine.js.map +1 -1
  43. package/lib/esm/graph/engine/execution/IsolatedVmCodeSandboxEvaluator.js +126 -0
  44. package/lib/esm/graph/engine/execution/IsolatedVmCodeSandboxEvaluator.js.map +1 -1
  45. package/lib/esm/graph/engine/execution/LogGraphNodeExecutor.js +14 -0
  46. package/lib/esm/graph/engine/execution/LogGraphNodeExecutor.js.map +1 -0
  47. package/lib/esm/graph/engine/execution/SwitchGraphNodeExecutor.js +21 -4
  48. package/lib/esm/graph/engine/execution/SwitchGraphNodeExecutor.js.map +1 -1
  49. package/lib/esm/graph/engine/execution/index.js +1 -0
  50. package/lib/esm/graph/engine/execution/index.js.map +1 -1
  51. package/lib/esm/graph/engine/index.js +1 -0
  52. package/lib/esm/graph/engine/index.js.map +1 -1
  53. package/lib/esm/graph/engine/loops/ForeachGraphNodeExecutor.js +1 -0
  54. package/lib/esm/graph/engine/loops/ForeachGraphNodeExecutor.js.map +1 -1
  55. package/lib/esm/graph/shared/nodes/flow-control.js +91 -9
  56. package/lib/esm/graph/shared/nodes/flow-control.js.map +1 -1
  57. package/lib/esm/index.js +3 -3
  58. package/lib/esm/nest/graph/GraphExecutionController.js +39 -50
  59. package/lib/esm/nest/graph/GraphExecutionController.js.map +1 -1
  60. package/lib/esm/nest/graph/GraphExecutionModule.js +11 -39
  61. package/lib/esm/nest/graph/GraphExecutionModule.js.map +1 -1
  62. package/lib/esm/nest/graph/GraphExecutionResultModel.js +0 -18
  63. package/lib/esm/nest/graph/GraphExecutionResultModel.js.map +1 -1
  64. package/lib/esm/nest/graph/GraphExecutorRegistryFactory.js +12 -47
  65. package/lib/esm/nest/graph/GraphExecutorRegistryFactory.js.map +1 -1
  66. package/lib/esm/nest/graph/GraphResultService.js +45 -0
  67. package/lib/esm/nest/graph/GraphResultService.js.map +1 -0
  68. package/lib/esm/nest/graph/GraphWorkflowModel.js +35 -0
  69. package/lib/esm/nest/graph/GraphWorkflowModel.js.map +1 -0
  70. package/lib/esm/nest/graph/GraphWorkflowService.js +53 -0
  71. package/lib/esm/nest/graph/GraphWorkflowService.js.map +1 -0
  72. package/lib/esm/nest/graph/index.js +3 -6
  73. package/lib/esm/nest/graph/index.js.map +1 -1
  74. package/lib/esm/nest/graph/main.js +1 -1
  75. package/lib/esm/nest/graph/main.js.map +1 -1
  76. package/lib/types/graph/engine/execution/CodeGraphNodeExecutor.d.cts +17 -17
  77. package/lib/types/graph/engine/execution/CodeGraphNodeExecutor.d.mts +17 -17
  78. package/lib/types/graph/engine/execution/CodeSandboxEvaluator.d.cts +23 -0
  79. package/lib/types/graph/engine/execution/CodeSandboxEvaluator.d.mts +23 -0
  80. package/lib/types/graph/engine/execution/GraphExecutionEngine.d.cts +6 -0
  81. package/lib/types/graph/engine/execution/GraphExecutionEngine.d.mts +6 -0
  82. package/lib/types/graph/engine/execution/IsolatedVmCodeSandboxEvaluator.d.cts +18 -0
  83. package/lib/types/graph/engine/execution/IsolatedVmCodeSandboxEvaluator.d.mts +18 -0
  84. package/lib/types/graph/engine/execution/LogGraphNodeExecutor.d.cts +19 -0
  85. package/lib/types/graph/engine/execution/LogGraphNodeExecutor.d.mts +19 -0
  86. package/lib/types/graph/engine/execution/SwitchGraphNodeExecutor.d.cts +3 -2
  87. package/lib/types/graph/engine/execution/SwitchGraphNodeExecutor.d.mts +3 -2
  88. package/lib/types/graph/engine/execution/index.d.cts +1 -0
  89. package/lib/types/graph/engine/execution/index.d.mts +1 -0
  90. package/lib/types/graph/engine/index.d.cts +1 -0
  91. package/lib/types/graph/engine/index.d.mts +1 -0
  92. package/lib/types/graph/shared/nodes/flow-control.d.cts +29 -3
  93. package/lib/types/graph/shared/nodes/flow-control.d.mts +29 -3
  94. package/lib/types/graph/shared/types.d.cts +6 -0
  95. package/lib/types/graph/shared/types.d.mts +6 -0
  96. package/lib/types/index.d.cts +2 -2
  97. package/lib/types/index.d.mts +2 -2
  98. package/lib/types/nest/graph/GraphExecutionController.d.cts +11 -42
  99. package/lib/types/nest/graph/GraphExecutionController.d.mts +11 -42
  100. package/lib/types/nest/graph/GraphExecutionModule.d.cts +9 -29
  101. package/lib/types/nest/graph/GraphExecutionModule.d.mts +9 -29
  102. package/lib/types/nest/graph/GraphExecutionResultModel.d.cts +0 -34
  103. package/lib/types/nest/graph/GraphExecutionResultModel.d.mts +0 -34
  104. package/lib/types/nest/graph/GraphExecutorRegistryFactory.d.cts +9 -9
  105. package/lib/types/nest/graph/GraphExecutorRegistryFactory.d.mts +9 -9
  106. package/lib/types/nest/graph/GraphResultService.d.cts +8 -0
  107. package/lib/types/nest/graph/GraphResultService.d.mts +8 -0
  108. package/lib/types/nest/graph/GraphWorkflowModel.d.cts +7 -0
  109. package/lib/types/nest/graph/GraphWorkflowModel.d.mts +7 -0
  110. package/lib/types/nest/graph/GraphWorkflowService.d.cts +7 -0
  111. package/lib/types/nest/graph/GraphWorkflowService.d.mts +7 -0
  112. package/lib/types/nest/graph/index.d.cts +3 -6
  113. package/lib/types/nest/graph/index.d.mts +3 -6
  114. package/package.json +3 -3
  115. package/lib/cjs/nest/graph/GraphExecutionResultRepository.cjs +0 -66
  116. package/lib/cjs/nest/graph/GraphExecutionResultRepository.cjs.map +0 -1
  117. package/lib/esm/nest/graph/GraphExecutionResultRepository.js +0 -60
  118. package/lib/esm/nest/graph/GraphExecutionResultRepository.js.map +0 -1
  119. package/lib/types/nest/graph/GraphExecutionResultRepository.d.cts +0 -38
  120. package/lib/types/nest/graph/GraphExecutionResultRepository.d.mts +0 -38
@@ -11,4 +11,5 @@ export * from "./GraphExecutionEngine.d.cts";
11
11
  export * from "./CodeSandboxEvaluator.d.cts";
12
12
  export * from "./SwitchGraphNodeExecutor.d.cts";
13
13
  export * from "./CodeGraphNodeExecutor.d.cts";
14
+ export * from "./LogGraphNodeExecutor.d.cts";
14
15
  export * from "./IsolatedVmCodeSandboxEvaluator.d.cts";
@@ -11,4 +11,5 @@ export * from "./GraphExecutionEngine.d.mts";
11
11
  export * from "./CodeSandboxEvaluator.d.mts";
12
12
  export * from "./SwitchGraphNodeExecutor.d.mts";
13
13
  export * from "./CodeGraphNodeExecutor.d.mts";
14
+ export * from "./LogGraphNodeExecutor.d.mts";
14
15
  export * from "./IsolatedVmCodeSandboxEvaluator.d.mts";
@@ -32,6 +32,7 @@ export * from "./execution/GraphExecutionEngine.d.cts";
32
32
  export * from "./execution/CodeSandboxEvaluator.d.cts";
33
33
  export * from "./execution/SwitchGraphNodeExecutor.d.cts";
34
34
  export * from "./execution/CodeGraphNodeExecutor.d.cts";
35
+ export * from "./execution/LogGraphNodeExecutor.d.cts";
35
36
  export * from "./execution/IsolatedVmCodeSandboxEvaluator.d.cts";
36
37
  export * from "./registry/GraphNodeExecutorRegistry.d.cts";
37
38
  export * from "./registry/GraphNodeExecutorResolver.d.cts";
@@ -32,6 +32,7 @@ export * from "./execution/GraphExecutionEngine.d.mts";
32
32
  export * from "./execution/CodeSandboxEvaluator.d.mts";
33
33
  export * from "./execution/SwitchGraphNodeExecutor.d.mts";
34
34
  export * from "./execution/CodeGraphNodeExecutor.d.mts";
35
+ export * from "./execution/LogGraphNodeExecutor.d.mts";
35
36
  export * from "./execution/IsolatedVmCodeSandboxEvaluator.d.mts";
36
37
  export * from "./registry/GraphNodeExecutorRegistry.d.mts";
37
38
  export * from "./registry/GraphNodeExecutorResolver.d.mts";
@@ -38,7 +38,9 @@ export declare class SwitchFlowNode extends GraphNode {
38
38
  /**
39
39
  * Computes the node's ports, size, and data patch from the given switch
40
40
  * metadata. Each case gets its own output port on the right side; the
41
- * node grows in height as cases are added.
41
+ * `default` port always renders **last** (DECAF-32 §21 port-ordering rule,
42
+ * DECAF-34 §6.2). When `hasDefault` is `false`, the `default` output port
43
+ * is omitted entirely. The node grows in height as cases are added.
42
44
  */
43
45
  static applyMetadata(meta: SwitchNodeMetadata): NodeMetadataChange;
44
46
  }
@@ -103,11 +105,35 @@ export declare class ReturnFlowNode extends Model {
103
105
  * sandbox context exposes `$input`, `$vars`, `$item`, `$index`, `$node`, and
104
106
  * `$output` as data variables. TypeScript is supported via transpilation.
105
107
  */
108
+ /**
109
+ * Input schema for the Code node. The `@input` on `CodeFlowNode.input` is a
110
+ * schema group — the nested model's `@input` ports are spliced into the
111
+ * parent unprefixed. `code` has `@input` + `@uielement("code-editor")`, so it
112
+ * appears as a port AND in the CRUD modal (the only visible field). `data`
113
+ * has `@input` + `@hidden()` but no `@uielement`, so it is a canvas-only port
114
+ * (for edge connections from workflow input badges) but never appears in the
115
+ * CRUD modal. `language` has no `@input` and no `@uielement`, so it is
116
+ * neither a port nor rendered — it defaults to `"javascript"`.
117
+ */
118
+ export declare class CodeInputSchema extends Model {
119
+ language: string;
120
+ code: string;
121
+ data?: unknown;
122
+ }
106
123
  export declare class CodeFlowNode extends Model {
107
- input: unknown;
124
+ input: CodeInputSchema;
108
125
  result: unknown;
109
126
  }
127
+ /**
128
+ * Log — logs the input value and forwards it unchanged on the `logged`
129
+ * output port. Useful for debugging, audit trails, and discard/side-effect
130
+ * branches in a workflow.
131
+ */
132
+ export declare class LogFlowNode extends Model {
133
+ value: unknown;
134
+ logged: unknown;
135
+ }
110
136
  /**
111
137
  * All built-in flow-control node constructors.
112
138
  */
113
- 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];
139
+ 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];
@@ -38,7 +38,9 @@ export declare class SwitchFlowNode extends GraphNode {
38
38
  /**
39
39
  * Computes the node's ports, size, and data patch from the given switch
40
40
  * metadata. Each case gets its own output port on the right side; the
41
- * node grows in height as cases are added.
41
+ * `default` port always renders **last** (DECAF-32 §21 port-ordering rule,
42
+ * DECAF-34 §6.2). When `hasDefault` is `false`, the `default` output port
43
+ * is omitted entirely. The node grows in height as cases are added.
42
44
  */
43
45
  static applyMetadata(meta: SwitchNodeMetadata): NodeMetadataChange;
44
46
  }
@@ -103,11 +105,35 @@ export declare class ReturnFlowNode extends Model {
103
105
  * sandbox context exposes `$input`, `$vars`, `$item`, `$index`, `$node`, and
104
106
  * `$output` as data variables. TypeScript is supported via transpilation.
105
107
  */
108
+ /**
109
+ * Input schema for the Code node. The `@input` on `CodeFlowNode.input` is a
110
+ * schema group — the nested model's `@input` ports are spliced into the
111
+ * parent unprefixed. `code` has `@input` + `@uielement("code-editor")`, so it
112
+ * appears as a port AND in the CRUD modal (the only visible field). `data`
113
+ * has `@input` + `@hidden()` but no `@uielement`, so it is a canvas-only port
114
+ * (for edge connections from workflow input badges) but never appears in the
115
+ * CRUD modal. `language` has no `@input` and no `@uielement`, so it is
116
+ * neither a port nor rendered — it defaults to `"javascript"`.
117
+ */
118
+ export declare class CodeInputSchema extends Model {
119
+ language: string;
120
+ code: string;
121
+ data?: unknown;
122
+ }
106
123
  export declare class CodeFlowNode extends Model {
107
- input: unknown;
124
+ input: CodeInputSchema;
108
125
  result: unknown;
109
126
  }
127
+ /**
128
+ * Log — logs the input value and forwards it unchanged on the `logged`
129
+ * output port. Useful for debugging, audit trails, and discard/side-effect
130
+ * branches in a workflow.
131
+ */
132
+ export declare class LogFlowNode extends Model {
133
+ value: unknown;
134
+ logged: unknown;
135
+ }
110
136
  /**
111
137
  * All built-in flow-control node constructors.
112
138
  */
113
- 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];
139
+ 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];
@@ -102,10 +102,16 @@ export interface SwitchCase {
102
102
  }
103
103
  /**
104
104
  * Metadata for a Switch node, stored in `metadata.switch`.
105
+ *
106
+ * When `hasDefault` is `false` (the default), the `default` output port is
107
+ * hidden and the executor throws a `GraphExecutionError` when no case
108
+ * matches. When `hasDefault` is `true`, the `default` output port is visible
109
+ * and receives the input when no case matches (DECAF-34 §6.2).
105
110
  */
106
111
  export interface SwitchNodeMetadata {
107
112
  cases: SwitchCase[];
108
113
  defaultPort?: string;
114
+ hasDefault?: boolean;
109
115
  }
110
116
  /**
111
117
  * The result of applying a metadata change to a node. Each concrete node
@@ -102,10 +102,16 @@ export interface SwitchCase {
102
102
  }
103
103
  /**
104
104
  * Metadata for a Switch node, stored in `metadata.switch`.
105
+ *
106
+ * When `hasDefault` is `false` (the default), the `default` output port is
107
+ * hidden and the executor throws a `GraphExecutionError` when no case
108
+ * matches. When `hasDefault` is `true`, the `default` output port is visible
109
+ * and receives the input when no case matches (DECAF-34 §6.2).
105
110
  */
106
111
  export interface SwitchNodeMetadata {
107
112
  cases: SwitchCase[];
108
113
  defaultPort?: string;
114
+ hasDefault?: boolean;
109
115
  }
110
116
  /**
111
117
  * The result of applying a metadata change to a node. Each concrete node
@@ -6,6 +6,6 @@
6
6
  export * from "./utils.d.cts";
7
7
  export * from "./namespaces/index.d.cts";
8
8
  export declare const VERSION: string;
9
- export declare const COMMIT = "857014d";
10
- export declare const FULL_VERSION = "0.3.10-857014d";
9
+ export declare const COMMIT = "2b2b991";
10
+ export declare const FULL_VERSION = "0.3.12-2b2b991";
11
11
  export declare const PACKAGE_NAME: string;
@@ -6,6 +6,6 @@
6
6
  export * from "./utils.d.mts";
7
7
  export * from "./namespaces/index.d.mts";
8
8
  export declare const VERSION: string;
9
- export declare const COMMIT = "857014d";
10
- export declare const FULL_VERSION = "0.3.10-857014d";
9
+ export declare const COMMIT = "2b2b991";
10
+ export declare const FULL_VERSION = "0.3.12-2b2b991";
11
11
  export declare const PACKAGE_NAME: string;
@@ -1,62 +1,31 @@
1
- /**
2
- * @module integrations/nest/graph/GraphExecutionController
3
- * @summary NestJS controller bridging the graph execution engine to REST + SSE.
4
- * @description Exposes three endpoints:
5
- * - `POST /graph/execute` — triggers {@link GraphExecutionEngine.execute}, persists the result via a Decaf repository, and returns `{ runId, status, outputs }`.
6
- * - `GET /graph/events` — SSE endpoint streaming {@link GraphExecutionEvent}s as `[modelName, operation, id, payload]` tuples (compatible with for-http's `ServerEventConnector`).
7
- * - `GET /graph/results/:runId` — retrieves a persisted {@link GraphExecutionResultModel} from the repository.
8
- *
9
- * This is the production pattern: for-nest hosts the engine, for-angular consumes events over the network via SSE and fetches persisted results via REST.
10
- */
11
1
  import { MessageEvent } from "@nestjs/common";
12
2
  import { Observable } from "rxjs";
13
3
  import { GraphExecutionEngine, type GraphExecutionValues } from "../../graph/index.d.cts";
14
4
  import type { GraphWorkflowDefinition } from "@decaf-ts/ui-decorators/graph";
15
- import { type GraphExecutionResultRepositoryInstance } from "./GraphExecutionResultRepository.d.cts";
16
- /**
17
- * NestJS injection token for the graph execution result repository.
18
- */
19
- export declare const GRAPH_RESULT_REPOSITORY = "GRAPH_RESULT_REPOSITORY";
20
- /**
21
- * Payload for the `POST /graph/execute` endpoint.
22
- */
5
+ import { DecafRequestContext } from "@decaf-ts/for-nest";
6
+ import { GraphResultService } from "./GraphResultService.d.cts";
7
+ import { GraphWorkflowService } from "./GraphWorkflowService.d.cts";
23
8
  export interface GraphExecutePayload {
24
9
  workflow: GraphWorkflowDefinition;
25
10
  inputs: GraphExecutionValues;
26
11
  }
27
- /**
28
- * Response shape for the `POST /graph/execute` endpoint.
29
- */
30
12
  export interface GraphExecuteResponse {
31
13
  runId: string;
32
14
  status: string;
33
15
  outputs: Record<string, unknown>;
34
16
  }
35
- /**
36
- * NestJS controller that hosts the graph execution engine server-side,
37
- * streams events via SSE, and persists results for later retrieval.
38
- */
39
17
  export declare class GraphExecutionController {
40
18
  private readonly engine;
41
- private readonly resultRepository;
19
+ private readonly resultService;
20
+ private readonly workflowService;
21
+ private readonly requestContext?;
42
22
  private readonly eventSubject;
43
- constructor(engine: GraphExecutionEngine, resultRepository: GraphExecutionResultRepositoryInstance);
44
- /**
45
- * Triggers graph execution server-side, persists the result, and returns
46
- * a summary containing the `runId`, `status`, and `outputs`.
47
- */
23
+ constructor(engine: GraphExecutionEngine, resultService: GraphResultService, workflowService: GraphWorkflowService, requestContext?: DecafRequestContext | undefined);
48
24
  execute(body: GraphExecutePayload): Promise<GraphExecuteResponse>;
49
- /**
50
- * SSE endpoint that streams graph execution events.
51
- *
52
- * Events are serialized as `[modelName, operation, id, payload]` to match
53
- * the format expected by for-http's `ServerEventConnector`.
54
- */
55
25
  events(): Observable<MessageEvent>;
56
- /**
57
- * Retrieves a persisted graph execution result by its `runId`.
58
- *
59
- * @throws {NotFoundException} when no result is stored for the given `runId`.
60
- */
61
26
  getResult(runId: string): Promise<unknown>;
27
+ saveWorkflow(id: string, snapshot: Record<string, unknown>): Promise<{
28
+ workflowId: string;
29
+ savedAt: string;
30
+ }>;
62
31
  }
@@ -1,62 +1,31 @@
1
- /**
2
- * @module integrations/nest/graph/GraphExecutionController
3
- * @summary NestJS controller bridging the graph execution engine to REST + SSE.
4
- * @description Exposes three endpoints:
5
- * - `POST /graph/execute` — triggers {@link GraphExecutionEngine.execute}, persists the result via a Decaf repository, and returns `{ runId, status, outputs }`.
6
- * - `GET /graph/events` — SSE endpoint streaming {@link GraphExecutionEvent}s as `[modelName, operation, id, payload]` tuples (compatible with for-http's `ServerEventConnector`).
7
- * - `GET /graph/results/:runId` — retrieves a persisted {@link GraphExecutionResultModel} from the repository.
8
- *
9
- * This is the production pattern: for-nest hosts the engine, for-angular consumes events over the network via SSE and fetches persisted results via REST.
10
- */
11
1
  import { MessageEvent } from "@nestjs/common";
12
2
  import { Observable } from "rxjs";
13
3
  import { GraphExecutionEngine, type GraphExecutionValues } from "../../graph/index.d.mts";
14
4
  import type { GraphWorkflowDefinition } from "@decaf-ts/ui-decorators/graph";
15
- import { type GraphExecutionResultRepositoryInstance } from "./GraphExecutionResultRepository.d.mts";
16
- /**
17
- * NestJS injection token for the graph execution result repository.
18
- */
19
- export declare const GRAPH_RESULT_REPOSITORY = "GRAPH_RESULT_REPOSITORY";
20
- /**
21
- * Payload for the `POST /graph/execute` endpoint.
22
- */
5
+ import { DecafRequestContext } from "@decaf-ts/for-nest";
6
+ import { GraphResultService } from "./GraphResultService.d.mts";
7
+ import { GraphWorkflowService } from "./GraphWorkflowService.d.mts";
23
8
  export interface GraphExecutePayload {
24
9
  workflow: GraphWorkflowDefinition;
25
10
  inputs: GraphExecutionValues;
26
11
  }
27
- /**
28
- * Response shape for the `POST /graph/execute` endpoint.
29
- */
30
12
  export interface GraphExecuteResponse {
31
13
  runId: string;
32
14
  status: string;
33
15
  outputs: Record<string, unknown>;
34
16
  }
35
- /**
36
- * NestJS controller that hosts the graph execution engine server-side,
37
- * streams events via SSE, and persists results for later retrieval.
38
- */
39
17
  export declare class GraphExecutionController {
40
18
  private readonly engine;
41
- private readonly resultRepository;
19
+ private readonly resultService;
20
+ private readonly workflowService;
21
+ private readonly requestContext?;
42
22
  private readonly eventSubject;
43
- constructor(engine: GraphExecutionEngine, resultRepository: GraphExecutionResultRepositoryInstance);
44
- /**
45
- * Triggers graph execution server-side, persists the result, and returns
46
- * a summary containing the `runId`, `status`, and `outputs`.
47
- */
23
+ constructor(engine: GraphExecutionEngine, resultService: GraphResultService, workflowService: GraphWorkflowService, requestContext?: DecafRequestContext | undefined);
48
24
  execute(body: GraphExecutePayload): Promise<GraphExecuteResponse>;
49
- /**
50
- * SSE endpoint that streams graph execution events.
51
- *
52
- * Events are serialized as `[modelName, operation, id, payload]` to match
53
- * the format expected by for-http's `ServerEventConnector`.
54
- */
55
25
  events(): Observable<MessageEvent>;
56
- /**
57
- * Retrieves a persisted graph execution result by its `runId`.
58
- *
59
- * @throws {NotFoundException} when no result is stored for the given `runId`.
60
- */
61
26
  getResult(runId: string): Promise<unknown>;
27
+ saveWorkflow(id: string, snapshot: Record<string, unknown>): Promise<{
28
+ workflowId: string;
29
+ savedAt: string;
30
+ }>;
62
31
  }
@@ -1,39 +1,19 @@
1
- /**
2
- * @module integrations/nest/graph/GraphExecutionModule
3
- * @summary NestJS DynamicModule hosting the graph execution engine.
4
- * @description Wires the {@link GraphExecutionEngine}, a demo executor registry, a RamAdapter-backed result repository, and the {@link GraphExecutionController} into a single NestJS module. Use `GraphExecutionModule.forRoot()` to register it in the application.
5
- */
6
1
  import { DynamicModule } from "@nestjs/common";
7
- /**
8
- * Options for {@link GraphExecutionModule.forRoot}.
9
- */
10
2
  export interface GraphExecutionModuleOptions {
11
3
  /**
12
- * User identifier passed to the RamAdapter. Defaults to `"graph-engine"`.
4
+ * When `true`, the module bootstraps a default RamAdapter for standalone
5
+ * development. When `false`, the host application is expected to have
6
+ * already configured a Decaf adapter via `DecafModule.forRoot(...)`.
7
+ * Defaults to `true` for backwards compatibility.
13
8
  */
14
- adapterUser?: string;
9
+ initAdapter?: boolean;
15
10
  /**
16
- * When `true`, calls `RamAdapter.decoration()` and
17
- * `Adapter.setCurrent(RamFlavour)` during module initialisation. Defaults to
18
- * `true`. Set to `false` when the host application has already configured a
19
- * RamAdapter.
11
+ * Adapter user identifier passed to `RamAdapter` when `initAdapter` is
12
+ * `true`. Ignored when `initAdapter` is `false`.
13
+ * Defaults to `"graph-engine"`.
20
14
  */
21
- initAdapter?: boolean;
15
+ adapterUser?: string;
22
16
  }
23
- /**
24
- * NestJS module that hosts the graph execution engine server-side.
25
- *
26
- * Provides:
27
- * - {@link GraphExecutionEngine} — singleton engine with a demo executor registry.
28
- * - `GRAPH_RESULT_REPOSITORY` — Decaf repository for {@link GraphExecutionResultModel} backed by RamAdapter.
29
- * - {@link GraphExecutionController} — REST + SSE controller.
30
- */
31
17
  export declare class GraphExecutionModule {
32
- /**
33
- * Creates a configured {@link DynamicModule} for the graph execution backend.
34
- *
35
- * @param options - Module configuration options.
36
- * @returns A NestJS `DynamicModule` ready for import.
37
- */
38
18
  static forRoot(options?: GraphExecutionModuleOptions): DynamicModule;
39
19
  }
@@ -1,39 +1,19 @@
1
- /**
2
- * @module integrations/nest/graph/GraphExecutionModule
3
- * @summary NestJS DynamicModule hosting the graph execution engine.
4
- * @description Wires the {@link GraphExecutionEngine}, a demo executor registry, a RamAdapter-backed result repository, and the {@link GraphExecutionController} into a single NestJS module. Use `GraphExecutionModule.forRoot()` to register it in the application.
5
- */
6
1
  import { DynamicModule } from "@nestjs/common";
7
- /**
8
- * Options for {@link GraphExecutionModule.forRoot}.
9
- */
10
2
  export interface GraphExecutionModuleOptions {
11
3
  /**
12
- * User identifier passed to the RamAdapter. Defaults to `"graph-engine"`.
4
+ * When `true`, the module bootstraps a default RamAdapter for standalone
5
+ * development. When `false`, the host application is expected to have
6
+ * already configured a Decaf adapter via `DecafModule.forRoot(...)`.
7
+ * Defaults to `true` for backwards compatibility.
13
8
  */
14
- adapterUser?: string;
9
+ initAdapter?: boolean;
15
10
  /**
16
- * When `true`, calls `RamAdapter.decoration()` and
17
- * `Adapter.setCurrent(RamFlavour)` during module initialisation. Defaults to
18
- * `true`. Set to `false` when the host application has already configured a
19
- * RamAdapter.
11
+ * Adapter user identifier passed to `RamAdapter` when `initAdapter` is
12
+ * `true`. Ignored when `initAdapter` is `false`.
13
+ * Defaults to `"graph-engine"`.
20
14
  */
21
- initAdapter?: boolean;
15
+ adapterUser?: string;
22
16
  }
23
- /**
24
- * NestJS module that hosts the graph execution engine server-side.
25
- *
26
- * Provides:
27
- * - {@link GraphExecutionEngine} — singleton engine with a demo executor registry.
28
- * - `GRAPH_RESULT_REPOSITORY` — Decaf repository for {@link GraphExecutionResultModel} backed by RamAdapter.
29
- * - {@link GraphExecutionController} — REST + SSE controller.
30
- */
31
17
  export declare class GraphExecutionModule {
32
- /**
33
- * Creates a configured {@link DynamicModule} for the graph execution backend.
34
- *
35
- * @param options - Module configuration options.
36
- * @returns A NestJS `DynamicModule` ready for import.
37
- */
38
18
  static forRoot(options?: GraphExecutionModuleOptions): DynamicModule;
39
19
  }
@@ -1,46 +1,12 @@
1
- /**
2
- * @module integrations/nest/graph/GraphExecutionResultModel
3
- * @summary Decaf model for persisting graph execution results.
4
- * @description Serializes a {@link GraphExecutionResult} for storage in a Decaf persistence adapter (e.g. RamAdapter). Stores the run id, workflow id, status, inputs, outputs, per-node results, and timing information so clients can retrieve a completed run's full state via `GET /graph/results/:runId`.
5
- */
6
1
  import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
7
- /**
8
- * Persisted representation of a completed graph execution run.
9
- *
10
- * Stored in the `graph_execution_result` table and keyed by `runId`.
11
- */
12
2
  export declare class GraphExecutionResultModel extends Model {
13
- /**
14
- * Unique identifier for this execution run. Acts as the primary key.
15
- */
16
3
  runId: string;
17
- /**
18
- * Identifier of the workflow that was executed.
19
- */
20
4
  workflowId: string;
21
- /**
22
- * Final status of the run (e.g. `succeeded`, `failed`).
23
- */
24
5
  status: string;
25
- /**
26
- * Inputs supplied to the workflow at execution time.
27
- */
28
6
  inputs: Record<string, unknown>;
29
- /**
30
- * Outputs produced by the workflow.
31
- */
32
7
  outputs: Record<string, unknown>;
33
- /**
34
- * Per-node execution results keyed by node id.
35
- */
36
8
  nodeResults: Record<string, unknown>;
37
- /**
38
- * Timestamp marking when the run started.
39
- */
40
9
  startedAt: Date;
41
- /**
42
- * Timestamp marking when the run finished.
43
- */
44
10
  finishedAt?: Date;
45
11
  constructor(arg?: ModelArg<GraphExecutionResultModel>);
46
12
  }
@@ -1,46 +1,12 @@
1
- /**
2
- * @module integrations/nest/graph/GraphExecutionResultModel
3
- * @summary Decaf model for persisting graph execution results.
4
- * @description Serializes a {@link GraphExecutionResult} for storage in a Decaf persistence adapter (e.g. RamAdapter). Stores the run id, workflow id, status, inputs, outputs, per-node results, and timing information so clients can retrieve a completed run's full state via `GET /graph/results/:runId`.
5
- */
6
1
  import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
7
- /**
8
- * Persisted representation of a completed graph execution run.
9
- *
10
- * Stored in the `graph_execution_result` table and keyed by `runId`.
11
- */
12
2
  export declare class GraphExecutionResultModel extends Model {
13
- /**
14
- * Unique identifier for this execution run. Acts as the primary key.
15
- */
16
3
  runId: string;
17
- /**
18
- * Identifier of the workflow that was executed.
19
- */
20
4
  workflowId: string;
21
- /**
22
- * Final status of the run (e.g. `succeeded`, `failed`).
23
- */
24
5
  status: string;
25
- /**
26
- * Inputs supplied to the workflow at execution time.
27
- */
28
6
  inputs: Record<string, unknown>;
29
- /**
30
- * Outputs produced by the workflow.
31
- */
32
7
  outputs: Record<string, unknown>;
33
- /**
34
- * Per-node execution results keyed by node id.
35
- */
36
8
  nodeResults: Record<string, unknown>;
37
- /**
38
- * Timestamp marking when the run started.
39
- */
40
9
  startedAt: Date;
41
- /**
42
- * Timestamp marking when the run finished.
43
- */
44
10
  finishedAt?: Date;
45
11
  constructor(arg?: ModelArg<GraphExecutionResultModel>);
46
12
  }
@@ -3,9 +3,10 @@
3
3
  * @summary Factory that builds a populated {@link GraphNodeExecutorRegistry}.
4
4
  * @description Creates a registry pre-loaded with the demo executors used by
5
5
  * the graph execution backend's sample workflows. The executors cover the
6
- * publishing-workflow node tags, the flow-control kinds, the agent kind, and
7
- * the loop kinds. Additional executors can be registered on the returned
8
- * registry before it is handed to the {@link GraphExecutionEngine}.
6
+ * flow-control kinds (including Code, Log, and Switch with code conditions),
7
+ * the agent kind, and the loop kinds. Additional executors can be registered
8
+ * on the returned registry before it is handed to the
9
+ * {@link GraphExecutionEngine}.
9
10
  */
10
11
  import { GraphNodeExecutorRegistry, GraphExecutionEngine, type GraphNodeExecutor, IsolatedVmCodeSandboxEvaluator } from "../../graph/index.d.cts";
11
12
  /**
@@ -18,12 +19,11 @@ import { GraphNodeExecutorRegistry, GraphExecutionEngine, type GraphNodeExecutor
18
19
  *
19
20
  * Registered kinds:
20
21
  * - `math.add`, `math.multiply` — arithmetic demo executors.
21
- * - `graph-intake-workflow`, `graph-planning-pipeline`, `graph-draft-node`,
22
- * `graph-review-node`, `graph-publish-workflow` — publishing workflow demo.
23
- * - `core.flow.*` — flow-control kinds (map, delay, return, merge, if, switch,
24
- * parallel, errorBoundary, humanApproval). The `core.flow.code` kind is
25
- * registered in `onEngineCreated` via the real {@link CodeGraphNodeExecutor}
26
- * because it needs the engine's `codeSandboxEvaluator`.
22
+ * - `core.flow.*` — flow-control kinds (map, delay, return, merge, if,
23
+ * parallel, errorBoundary, humanApproval). The `core.flow.code`,
24
+ * `core.flow.log`, and `core.flow.switch` kinds are registered in
25
+ * `onEngineCreated` via their real executors because Code and Switch
26
+ * need the engine's `codeSandboxEvaluator`.
27
27
  * - `core.agent` — agent node.
28
28
  * - `core.loop.foreach`, `core.loop.while`, `core.loop.until` — loop executors
29
29
  * (registered after the engine is created via `onEngineCreated`).
@@ -3,9 +3,10 @@
3
3
  * @summary Factory that builds a populated {@link GraphNodeExecutorRegistry}.
4
4
  * @description Creates a registry pre-loaded with the demo executors used by
5
5
  * the graph execution backend's sample workflows. The executors cover the
6
- * publishing-workflow node tags, the flow-control kinds, the agent kind, and
7
- * the loop kinds. Additional executors can be registered on the returned
8
- * registry before it is handed to the {@link GraphExecutionEngine}.
6
+ * flow-control kinds (including Code, Log, and Switch with code conditions),
7
+ * the agent kind, and the loop kinds. Additional executors can be registered
8
+ * on the returned registry before it is handed to the
9
+ * {@link GraphExecutionEngine}.
9
10
  */
10
11
  import { GraphNodeExecutorRegistry, GraphExecutionEngine, type GraphNodeExecutor, IsolatedVmCodeSandboxEvaluator } from "../../graph/index.d.mts";
11
12
  /**
@@ -18,12 +19,11 @@ import { GraphNodeExecutorRegistry, GraphExecutionEngine, type GraphNodeExecutor
18
19
  *
19
20
  * Registered kinds:
20
21
  * - `math.add`, `math.multiply` — arithmetic demo executors.
21
- * - `graph-intake-workflow`, `graph-planning-pipeline`, `graph-draft-node`,
22
- * `graph-review-node`, `graph-publish-workflow` — publishing workflow demo.
23
- * - `core.flow.*` — flow-control kinds (map, delay, return, merge, if, switch,
24
- * parallel, errorBoundary, humanApproval). The `core.flow.code` kind is
25
- * registered in `onEngineCreated` via the real {@link CodeGraphNodeExecutor}
26
- * because it needs the engine's `codeSandboxEvaluator`.
22
+ * - `core.flow.*` — flow-control kinds (map, delay, return, merge, if,
23
+ * parallel, errorBoundary, humanApproval). The `core.flow.code`,
24
+ * `core.flow.log`, and `core.flow.switch` kinds are registered in
25
+ * `onEngineCreated` via their real executors because Code and Switch
26
+ * need the engine's `codeSandboxEvaluator`.
27
27
  * - `core.agent` — agent node.
28
28
  * - `core.loop.foreach`, `core.loop.while`, `core.loop.until` — loop executors
29
29
  * (registered after the engine is created via `onEngineCreated`).
@@ -0,0 +1,8 @@
1
+ import { ModelService, type Context, type MaybeContextualArg } from "@decaf-ts/core";
2
+ import { GraphExecutionResultModel } from "./GraphExecutionResultModel.d.cts";
3
+ import type { GraphExecutionResult } from "../../graph/index.d.cts";
4
+ export declare class GraphResultService extends ModelService<GraphExecutionResultModel> {
5
+ constructor();
6
+ saveResult(result: GraphExecutionResult, ...args: MaybeContextualArg<Context>): Promise<GraphExecutionResultModel>;
7
+ findByRunId(runId: string, ...args: MaybeContextualArg<Context>): Promise<GraphExecutionResultModel | null>;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { ModelService, type Context, type MaybeContextualArg } from "@decaf-ts/core";
2
+ import { GraphExecutionResultModel } from "./GraphExecutionResultModel.d.mts";
3
+ import type { GraphExecutionResult } from "../../graph/index.d.mts";
4
+ export declare class GraphResultService extends ModelService<GraphExecutionResultModel> {
5
+ constructor();
6
+ saveResult(result: GraphExecutionResult, ...args: MaybeContextualArg<Context>): Promise<GraphExecutionResultModel>;
7
+ findByRunId(runId: string, ...args: MaybeContextualArg<Context>): Promise<GraphExecutionResultModel | null>;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
2
+ export declare class GraphWorkflowModel extends Model {
3
+ workflowId: string;
4
+ snapshot: Record<string, unknown>;
5
+ updatedAt: Date;
6
+ constructor(arg?: ModelArg<GraphWorkflowModel>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { Model, type ModelArg } from "@decaf-ts/decorator-validation";
2
+ export declare class GraphWorkflowModel extends Model {
3
+ workflowId: string;
4
+ snapshot: Record<string, unknown>;
5
+ updatedAt: Date;
6
+ constructor(arg?: ModelArg<GraphWorkflowModel>);
7
+ }
@@ -0,0 +1,7 @@
1
+ import { ModelService, type Context, type MaybeContextualArg } from "@decaf-ts/core";
2
+ import { GraphWorkflowModel } from "./GraphWorkflowModel.d.cts";
3
+ export declare class GraphWorkflowService extends ModelService<GraphWorkflowModel> {
4
+ constructor();
5
+ saveSnapshot(workflowId: string, snapshot: Record<string, unknown>, ...args: MaybeContextualArg<Context>): Promise<GraphWorkflowModel>;
6
+ loadSnapshot(workflowId: string, ...args: MaybeContextualArg<Context>): Promise<GraphWorkflowModel | null>;
7
+ }