@exellix/graph-engine 6.0.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 (202) hide show
  1. package/.env.example +3 -0
  2. package/CHANGELOG.md +208 -0
  3. package/README.md +827 -0
  4. package/dist/src/errors/ExellixGraphError.d.ts +38 -0
  5. package/dist/src/errors/ExellixGraphError.js +21 -0
  6. package/dist/src/errors/exellixGraphErrorCodes.d.ts +31 -0
  7. package/dist/src/errors/exellixGraphErrorCodes.js +32 -0
  8. package/dist/src/index.d.ts +100 -0
  9. package/dist/src/index.js +75 -0
  10. package/dist/src/inspection/contractInspection.d.ts +21 -0
  11. package/dist/src/inspection/contractInspection.js +526 -0
  12. package/dist/src/inspection/contractTypes.d.ts +137 -0
  13. package/dist/src/inspection/contractTypes.js +1 -0
  14. package/dist/src/inspection/controlInspection.d.ts +22 -0
  15. package/dist/src/inspection/controlInspection.js +130 -0
  16. package/dist/src/inspection/graphInspection.d.ts +51 -0
  17. package/dist/src/inspection/graphInspection.js +467 -0
  18. package/dist/src/inspection/index.d.ts +21 -0
  19. package/dist/src/inspection/index.js +17 -0
  20. package/dist/src/inspection/nodeInspection.d.ts +42 -0
  21. package/dist/src/inspection/nodeInspection.js +474 -0
  22. package/dist/src/inspection/types.d.ts +321 -0
  23. package/dist/src/inspection/types.js +14 -0
  24. package/dist/src/inspection/validateAiTasksNodeExtensions.d.ts +12 -0
  25. package/dist/src/inspection/validateAiTasksNodeExtensions.js +119 -0
  26. package/dist/src/inspection/validateCatalogPlanning.d.ts +21 -0
  27. package/dist/src/inspection/validateCatalogPlanning.js +187 -0
  28. package/dist/src/integrations/ActivityTrackerIntegration.d.ts +86 -0
  29. package/dist/src/integrations/ActivityTrackerIntegration.js +134 -0
  30. package/dist/src/integrations/ActivixGraphRunIntegration.d.ts +34 -0
  31. package/dist/src/integrations/ActivixGraphRunIntegration.js +338 -0
  32. package/dist/src/integrations/ActivixNodeActivityIntegration.d.ts +33 -0
  33. package/dist/src/integrations/ActivixNodeActivityIntegration.js +220 -0
  34. package/dist/src/integrations/cataloxGraphCatalog.d.ts +21 -0
  35. package/dist/src/integrations/cataloxGraphCatalog.js +30 -0
  36. package/dist/src/integrations/createActivixExellixIntegration.d.ts +14 -0
  37. package/dist/src/integrations/createActivixExellixIntegration.js +16 -0
  38. package/dist/src/integrations/createActivixFromEnv.d.ts +31 -0
  39. package/dist/src/integrations/createActivixFromEnv.js +53 -0
  40. package/dist/src/loaders/FileGraphLoader.d.ts +23 -0
  41. package/dist/src/loaders/FileGraphLoader.js +31 -0
  42. package/dist/src/playground/PlaygroundReporter.d.ts +40 -0
  43. package/dist/src/playground/PlaygroundReporter.js +480 -0
  44. package/dist/src/playground/index.d.ts +1 -0
  45. package/dist/src/playground/index.js +1 -0
  46. package/dist/src/runtime/ExellixGraphRuntime.d.ts +263 -0
  47. package/dist/src/runtime/ExellixGraphRuntime.js +1716 -0
  48. package/dist/src/runtime/GraphEngine.d.ts +33 -0
  49. package/dist/src/runtime/GraphEngine.js +4 -0
  50. package/dist/src/runtime/aiTasksObservability.d.ts +6 -0
  51. package/dist/src/runtime/aiTasksObservability.js +37 -0
  52. package/dist/src/runtime/aiTasksStrategyPhases.d.ts +46 -0
  53. package/dist/src/runtime/aiTasksStrategyPhases.js +93 -0
  54. package/dist/src/runtime/applyAiTaskProfileWebScopingToNarrix.d.ts +17 -0
  55. package/dist/src/runtime/applyAiTaskProfileWebScopingToNarrix.js +46 -0
  56. package/dist/src/runtime/buildAiTasksRunTaskRequest.d.ts +67 -0
  57. package/dist/src/runtime/buildAiTasksRunTaskRequest.js +164 -0
  58. package/dist/src/runtime/buildRunLog.d.ts +27 -0
  59. package/dist/src/runtime/buildRunLog.js +234 -0
  60. package/dist/src/runtime/buildRunTaskTaskConfigurationForward.d.ts +9 -0
  61. package/dist/src/runtime/buildRunTaskTaskConfigurationForward.js +80 -0
  62. package/dist/src/runtime/buildTaskNodeJobContext.d.ts +11 -0
  63. package/dist/src/runtime/buildTaskNodeJobContext.js +30 -0
  64. package/dist/src/runtime/canonicalModelUsed.d.ts +6 -0
  65. package/dist/src/runtime/canonicalModelUsed.js +36 -0
  66. package/dist/src/runtime/contextualScope.d.ts +7 -0
  67. package/dist/src/runtime/contextualScope.js +121 -0
  68. package/dist/src/runtime/dataFiltersEvaluation.d.ts +60 -0
  69. package/dist/src/runtime/dataFiltersEvaluation.js +169 -0
  70. package/dist/src/runtime/deepMerge.d.ts +5 -0
  71. package/dist/src/runtime/deepMerge.js +22 -0
  72. package/dist/src/runtime/events.d.ts +92 -0
  73. package/dist/src/runtime/events.js +122 -0
  74. package/dist/src/runtime/executionMatrixHost.d.ts +98 -0
  75. package/dist/src/runtime/executionMatrixHost.js +134 -0
  76. package/dist/src/runtime/executionVariableBuckets.d.ts +67 -0
  77. package/dist/src/runtime/executionVariableBuckets.js +96 -0
  78. package/dist/src/runtime/finalizers/errors.d.ts +9 -0
  79. package/dist/src/runtime/finalizers/errors.js +10 -0
  80. package/dist/src/runtime/finalizers/executeFinalizer.d.ts +40 -0
  81. package/dist/src/runtime/finalizers/executeFinalizer.js +471 -0
  82. package/dist/src/runtime/finalizers/schema.d.ts +18 -0
  83. package/dist/src/runtime/finalizers/schema.js +63 -0
  84. package/dist/src/runtime/finalizers/validateFinalizer.d.ts +16 -0
  85. package/dist/src/runtime/finalizers/validateFinalizer.js +534 -0
  86. package/dist/src/runtime/graphDocumentFingerprint.d.ts +8 -0
  87. package/dist/src/runtime/graphDocumentFingerprint.js +21 -0
  88. package/dist/src/runtime/graphEngineMemoryPaths.d.ts +12 -0
  89. package/dist/src/runtime/graphEngineMemoryPaths.js +55 -0
  90. package/dist/src/runtime/graphResponseMapping.d.ts +23 -0
  91. package/dist/src/runtime/graphResponseMapping.js +156 -0
  92. package/dist/src/runtime/graphResponseMigration.d.ts +7 -0
  93. package/dist/src/runtime/graphResponseMigration.js +44 -0
  94. package/dist/src/runtime/graphRunExecutionSeed.d.ts +29 -0
  95. package/dist/src/runtime/graphRunExecutionSeed.js +61 -0
  96. package/dist/src/runtime/graphRunIdentity.d.ts +7 -0
  97. package/dist/src/runtime/graphRunIdentity.js +18 -0
  98. package/dist/src/runtime/localSkills/deterministicRule.d.ts +137 -0
  99. package/dist/src/runtime/localSkills/deterministicRule.js +196 -0
  100. package/dist/src/runtime/localSkills/index.d.ts +12 -0
  101. package/dist/src/runtime/localSkills/index.js +14 -0
  102. package/dist/src/runtime/localSkills/memorixItemToScopedOutput.d.ts +7 -0
  103. package/dist/src/runtime/localSkills/memorixItemToScopedOutput.js +104 -0
  104. package/dist/src/runtime/localSkills/memorixRuntime.d.ts +9 -0
  105. package/dist/src/runtime/localSkills/memorixRuntime.js +70 -0
  106. package/dist/src/runtime/localSkills/memorixScopedConfig.d.ts +16 -0
  107. package/dist/src/runtime/localSkills/memorixScopedConfig.js +18 -0
  108. package/dist/src/runtime/localSkills/scopedAnswerAssembler.d.ts +23 -0
  109. package/dist/src/runtime/localSkills/scopedAnswerAssembler.js +35 -0
  110. package/dist/src/runtime/localSkills/scopedAnswerFields.d.ts +12 -0
  111. package/dist/src/runtime/localSkills/scopedAnswerFields.js +66 -0
  112. package/dist/src/runtime/localSkills/scopedAnswerWriter.d.ts +32 -0
  113. package/dist/src/runtime/localSkills/scopedAnswerWriter.js +156 -0
  114. package/dist/src/runtime/localSkills/scopedDataReader.d.ts +47 -0
  115. package/dist/src/runtime/localSkills/scopedDataReader.js +89 -0
  116. package/dist/src/runtime/localSkills/utils.d.ts +12 -0
  117. package/dist/src/runtime/localSkills/utils.js +39 -0
  118. package/dist/src/runtime/materializeStructuredRunTaskInput.d.ts +9 -0
  119. package/dist/src/runtime/materializeStructuredRunTaskInput.js +34 -0
  120. package/dist/src/runtime/memory.d.ts +51 -0
  121. package/dist/src/runtime/memory.js +250 -0
  122. package/dist/src/runtime/mergeExellixGraphRuntimeInvocation.d.ts +18 -0
  123. package/dist/src/runtime/mergeExellixGraphRuntimeInvocation.js +32 -0
  124. package/dist/src/runtime/modelConfigSelection.d.ts +7 -0
  125. package/dist/src/runtime/modelConfigSelection.js +37 -0
  126. package/dist/src/runtime/narrixIngestEnv.d.ts +9 -0
  127. package/dist/src/runtime/narrixIngestEnv.js +18 -0
  128. package/dist/src/runtime/pathExpr.d.ts +36 -0
  129. package/dist/src/runtime/pathExpr.js +131 -0
  130. package/dist/src/runtime/predicates.d.ts +14 -0
  131. package/dist/src/runtime/predicates.js +86 -0
  132. package/dist/src/runtime/readTaskNodeInputsConfig.d.ts +23 -0
  133. package/dist/src/runtime/readTaskNodeInputsConfig.js +27 -0
  134. package/dist/src/runtime/resolveExecutionPipelineForTaskNode.d.ts +11 -0
  135. package/dist/src/runtime/resolveExecutionPipelineForTaskNode.js +93 -0
  136. package/dist/src/runtime/resolveGraphEngineMemoryPaths.d.ts +63 -0
  137. package/dist/src/runtime/resolveGraphEngineMemoryPaths.js +213 -0
  138. package/dist/src/runtime/resolveModelConfigForNode.d.ts +20 -0
  139. package/dist/src/runtime/resolveModelConfigForNode.js +69 -0
  140. package/dist/src/runtime/resolveNarrixForTaskNode.d.ts +14 -0
  141. package/dist/src/runtime/resolveNarrixForTaskNode.js +19 -0
  142. package/dist/src/runtime/resolveTaskKey.d.ts +11 -0
  143. package/dist/src/runtime/resolveTaskKey.js +28 -0
  144. package/dist/src/runtime/resolveTaskNodeInputs.d.ts +25 -0
  145. package/dist/src/runtime/resolveTaskNodeInputs.js +140 -0
  146. package/dist/src/runtime/runTaskAugments.d.ts +17 -0
  147. package/dist/src/runtime/runTaskAugments.js +37 -0
  148. package/dist/src/runtime/runTaskResponse.d.ts +4 -0
  149. package/dist/src/runtime/runTaskResponse.js +13 -0
  150. package/dist/src/runtime/runtimeObjects.d.ts +85 -0
  151. package/dist/src/runtime/runtimeObjects.js +50 -0
  152. package/dist/src/runtime/smartInputPaths.d.ts +13 -0
  153. package/dist/src/runtime/smartInputPaths.js +38 -0
  154. package/dist/src/runtime/stepRetry.d.ts +21 -0
  155. package/dist/src/runtime/stepRetry.js +238 -0
  156. package/dist/src/runtime/synthesizedContextPipeline.d.ts +12 -0
  157. package/dist/src/runtime/synthesizedContextPipeline.js +28 -0
  158. package/dist/src/runtime/taskNodeConditionsEvaluation.d.ts +27 -0
  159. package/dist/src/runtime/taskNodeConditionsEvaluation.js +140 -0
  160. package/dist/src/runtime/taskNodeMainReadiness.d.ts +45 -0
  161. package/dist/src/runtime/taskNodeMainReadiness.js +164 -0
  162. package/dist/src/runtime/taskNodeRunTaskPreflight.d.ts +89 -0
  163. package/dist/src/runtime/taskNodeRunTaskPreflight.js +204 -0
  164. package/dist/src/runtime/validateCanonicalGraphDocument.d.ts +25 -0
  165. package/dist/src/runtime/validateCanonicalGraphDocument.js +567 -0
  166. package/dist/src/runtime/variables.d.ts +2 -0
  167. package/dist/src/runtime/variables.js +1 -0
  168. package/dist/src/runtime/withTimeout.d.ts +5 -0
  169. package/dist/src/runtime/withTimeout.js +20 -0
  170. package/dist/src/types/aiTaskProfile.d.ts +41 -0
  171. package/dist/src/types/aiTaskProfile.js +6 -0
  172. package/dist/src/types/aiTasksDerivedTypes.d.ts +5 -0
  173. package/dist/src/types/aiTasksDerivedTypes.js +1 -0
  174. package/dist/src/types/events.d.ts +23 -0
  175. package/dist/src/types/events.js +1 -0
  176. package/dist/src/types/job.d.ts +9 -0
  177. package/dist/src/types/job.js +1 -0
  178. package/dist/src/types/narrix.d.ts +60 -0
  179. package/dist/src/types/narrix.js +1 -0
  180. package/dist/src/types/options.d.ts +122 -0
  181. package/dist/src/types/options.js +1 -0
  182. package/dist/src/types/refs.d.ts +747 -0
  183. package/dist/src/types/refs.js +12 -0
  184. package/dist/src/types/results.d.ts +103 -0
  185. package/dist/src/types/results.js +1 -0
  186. package/dist/src/types/runLog.d.ts +72 -0
  187. package/dist/src/types/runLog.js +18 -0
  188. package/dist/src/types/taskNodeConfiguration.d.ts +95 -0
  189. package/dist/src/types/taskNodeConfiguration.js +3 -0
  190. package/dist/src/util/packageVersion.d.ts +2 -0
  191. package/dist/src/util/packageVersion.js +12 -0
  192. package/dist/testkit/RealTasksClient.d.ts +16 -0
  193. package/dist/testkit/RealTasksClient.js +143 -0
  194. package/dist/testkit/depGraphEngineFactory.d.ts +6 -0
  195. package/dist/testkit/depGraphEngineFactory.js +54 -0
  196. package/dist/testkit/exellixRuntimeObjects.d.ts +7 -0
  197. package/dist/testkit/exellixRuntimeObjects.js +25 -0
  198. package/dist/testkit/inMemoryGraphLoader.d.ts +6 -0
  199. package/dist/testkit/inMemoryGraphLoader.js +12 -0
  200. package/dist/testkit/index.d.ts +4 -0
  201. package/dist/testkit/index.js +4 -0
  202. package/package.json +70 -0
@@ -0,0 +1,250 @@
1
+ import { LogicEngine } from '@x12i/graphenix';
2
+ import { selectByPath, writeByPath } from './pathExpr.js';
3
+ /**
4
+ * Resolves a mapping path reference to its actual value using Graphenix LogicEngine.
5
+ *
6
+ * Supports:
7
+ * - Literals: "\"Asset\"" -> "Asset"
8
+ * - Node paths: "node.X" (with inputs/data/metadata hierarchy)
9
+ * - Output paths: "output.X"
10
+ * - Variables: "variables.X"
11
+ * - Job Memory: "jobMemory.X"
12
+ *
13
+ * @param path - Path reference string
14
+ * @param context - Context object
15
+ * @returns Resolved value or undefined
16
+ */
17
+ function resolveMappingPath(path, context) {
18
+ const { node, output, jobMemory, variables } = context;
19
+ // Map authoring-style paths to Graphenix `$` resolution where needed
20
+ let normalizedPath = path;
21
+ // If no prefix and not a literal, we try to be smart or just use it as is
22
+ // Graphenix resolveValue handles literals (starts with " or \")
23
+ // For variables/node/state, we prepend $ to use Graphenix resolution
24
+ if (!path.startsWith('"') && !path.startsWith('\\"') && !path.startsWith('$')) {
25
+ if (path.startsWith('node.')) {
26
+ normalizedPath = '$' + path;
27
+ }
28
+ else if (path.startsWith('output.')) {
29
+ normalizedPath = '$state.' + path.substring(7);
30
+ }
31
+ else if (path.startsWith('variables.')) {
32
+ normalizedPath = '$' + path.substring(10);
33
+ }
34
+ else if (path.startsWith('jobMemory.')) {
35
+ normalizedPath = '$memory.' + path.substring(10);
36
+ }
37
+ else {
38
+ // Shorthand: try output (state), then variables, then node
39
+ // We can't easily do this with a single resolveValue call in Graphenix
40
+ // so we try them sequentially
41
+ const resOutput = LogicEngine.resolveValue('$state.' + path, output, { state: output, variables: undefined, history: [], outputs: { byKey: {}, byNodeId: {} }, nodeStatus: {} });
42
+ if (resOutput !== undefined)
43
+ return resOutput;
44
+ const resVar = LogicEngine.resolveValue('$' + path, output, { state: output, variables: undefined, history: [], outputs: { byKey: {}, byNodeId: {} }, nodeStatus: {} });
45
+ if (resVar !== undefined)
46
+ return resVar;
47
+ const resNode = LogicEngine.resolveValue('$node.' + path, output, { state: output, variables: undefined, history: [], outputs: { byKey: {}, byNodeId: {} }, nodeStatus: {}, node: node });
48
+ if (resNode !== undefined)
49
+ return resNode;
50
+ return undefined;
51
+ }
52
+ }
53
+ // Build Graphenix ExecutionContext
54
+ const graphenixContext = {
55
+ state: output,
56
+ variables: variables || {},
57
+ history: [], // Not needed for simple value resolution
58
+ outputs: { byKey: {}, byNodeId: {} },
59
+ nodeStatus: {},
60
+ memory: jobMemory, // Pass jobMemory as history/memory
61
+ node: node
62
+ };
63
+ return LogicEngine.resolveValue(normalizedPath, output, graphenixContext);
64
+ }
65
+ /**
66
+ * Creates a mapped object from a map configuration.
67
+ * Uses pathExpr (selectByPath) for paths containing [*], {*}, or starting with executionMemory./jobMemory.;
68
+ * otherwise uses Graphenix resolveMappingPath for node.X, output.X, variables.X.
69
+ */
70
+ export function createMappedObject(map, context) {
71
+ const result = {};
72
+ const usePathExprRoot = context.executionMemory !== undefined || context.jobMemory !== undefined;
73
+ const executionMem = context.executionMemory;
74
+ const selectionRoot = usePathExprRoot
75
+ ? {
76
+ executionMemory: context.executionMemory,
77
+ jobMemory: context.jobMemory,
78
+ variables: executionMem != null && typeof executionMem.jobVariables === 'object'
79
+ ? executionMem.jobVariables
80
+ : executionMem != null && typeof executionMem.variables === 'object'
81
+ ? executionMem.variables
82
+ : context.variables,
83
+ jobVariables: executionMem != null && typeof executionMem.jobVariables === 'object'
84
+ ? executionMem.jobVariables
85
+ : undefined,
86
+ taskVariables: executionMem != null && typeof executionMem.taskVariables === 'object'
87
+ ? executionMem.taskVariables
88
+ : undefined,
89
+ node: context.node,
90
+ }
91
+ : null;
92
+ for (const [targetKey, sourcePath] of Object.entries(map)) {
93
+ let value;
94
+ if (selectionRoot &&
95
+ (sourcePath.includes('[*]') ||
96
+ sourcePath.includes('{*}') ||
97
+ sourcePath.startsWith('executionMemory.') ||
98
+ sourcePath.startsWith('jobMemory.') ||
99
+ sourcePath.startsWith('jobVariables.') ||
100
+ sourcePath.startsWith('taskVariables.'))) {
101
+ value = selectByPath(selectionRoot, sourcePath);
102
+ }
103
+ else {
104
+ value = resolveMappingPath(sourcePath, context);
105
+ }
106
+ if (value !== undefined) {
107
+ result[targetKey] = value;
108
+ }
109
+ }
110
+ return result;
111
+ }
112
+ /**
113
+ * Merges memory from job and node sources.
114
+ */
115
+ export function mergeMemory(options) {
116
+ const { jobMemory: baseJobMemory, taskMemory: baseTaskMemory, node } = options;
117
+ let finalJobMemory = baseJobMemory;
118
+ let finalTaskMemory = baseTaskMemory;
119
+ if (node?.memory) {
120
+ if (node.memory.jobMemory !== undefined) {
121
+ finalJobMemory = node.memory.jobMemory;
122
+ }
123
+ if (node.memory.taskMemory !== undefined) {
124
+ finalTaskMemory = node.memory.taskMemory;
125
+ }
126
+ }
127
+ return {
128
+ jobMemory: finalJobMemory,
129
+ taskMemory: finalTaskMemory,
130
+ };
131
+ }
132
+ /**
133
+ * Merges output into execution object based on mapping configuration.
134
+ * Uses writeByPath for target path (supports nested paths, creates missing objects).
135
+ * Resolves map sources via selectByPath on { output, node, variables } with fallback to Graphenix.
136
+ */
137
+ export function mergeExecutionObject(execution, path, output, mode, mappingConfig, context) {
138
+ // Start with a clean copy of the execution object
139
+ const result = execution ? JSON.parse(JSON.stringify(execution)) : {};
140
+ // Determine value to merge
141
+ let valueToMerge;
142
+ if (mappingConfig?.map) {
143
+ const outputRoot = { output, node: context?.node, variables: context?.variables };
144
+ valueToMerge = {};
145
+ for (const [targetKey, sourcePath] of Object.entries(mappingConfig.map)) {
146
+ let val = selectByPath(outputRoot, sourcePath);
147
+ if (val === undefined) {
148
+ val = resolveMappingPath(sourcePath, {
149
+ node: context?.node,
150
+ output,
151
+ variables: context?.variables,
152
+ });
153
+ }
154
+ if (val !== undefined)
155
+ valueToMerge[targetKey] = val;
156
+ }
157
+ }
158
+ else if (mappingConfig?.fields) {
159
+ valueToMerge = {};
160
+ for (const field of mappingConfig.fields) {
161
+ const val = LogicEngine.resolveValue('$state.' + field, output, { state: output, variables: undefined, history: [], outputs: { byKey: {}, byNodeId: {} }, nodeStatus: {} });
162
+ if (val !== undefined)
163
+ valueToMerge[field] = val;
164
+ }
165
+ }
166
+ else {
167
+ valueToMerge = output;
168
+ }
169
+ const effectiveMode = mode ?? 'replace';
170
+ writeByPath(result, path, valueToMerge, effectiveMode);
171
+ return result;
172
+ }
173
+ /**
174
+ * Merges execution object into jobMemory so it appears in workingMemory.
175
+ */
176
+ export function mergeExecutionIntoMemory(jobMemory, execution) {
177
+ if (execution === null || execution === undefined) {
178
+ return jobMemory;
179
+ }
180
+ // Use LogicEngine for the merge operation
181
+ const state = jobMemory ? JSON.parse(JSON.stringify(jobMemory)) : {};
182
+ const assignment = {
183
+ name: 'execution',
184
+ value: execution,
185
+ operation: 'merge'
186
+ };
187
+ LogicEngine.applyAssignment(assignment, state, { state: state, variables: state, history: [], outputs: { byKey: {}, byNodeId: {} }, nodeStatus: {} });
188
+ return state;
189
+ }
190
+ /**
191
+ * Builds a semantic memory key for a node result.
192
+ */
193
+ export function buildMemoryKey(node) {
194
+ if (node.data?.memoryKey)
195
+ return node.data.memoryKey;
196
+ if (node.taskConfiguration?.memoryKey)
197
+ return node.taskConfiguration.memoryKey;
198
+ const name = node.data?.name || node.metadata?.name;
199
+ if (name) {
200
+ return name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
201
+ }
202
+ return node.id;
203
+ }
204
+ /**
205
+ * Accumulates a node execution result into jobMemory.
206
+ */
207
+ export function accumulateNodeResult(currentMemory, node, result) {
208
+ const jobMemory = currentMemory ? JSON.parse(JSON.stringify(currentMemory)) : {};
209
+ const memoryKey = buildMemoryKey(node);
210
+ const nodeMemoryEntry = {
211
+ nodeId: node.id,
212
+ skillKey: result.skillKey,
213
+ status: result.success ? 'completed' : 'failed',
214
+ timestamp: new Date().toISOString(),
215
+ metadata: {
216
+ nodeName: node.data?.name || node.metadata?.name || node.id,
217
+ nodeType: node.type,
218
+ },
219
+ };
220
+ if (result.success) {
221
+ nodeMemoryEntry.result = result.output;
222
+ if (result.metadata?.executionTime) {
223
+ nodeMemoryEntry.executionTime = result.metadata.executionTime;
224
+ }
225
+ }
226
+ else {
227
+ nodeMemoryEntry.error = {
228
+ code: result.error?.code,
229
+ message: result.error?.message,
230
+ diagnostics: result.error?.diagnostics,
231
+ };
232
+ }
233
+ jobMemory[memoryKey] = nodeMemoryEntry;
234
+ jobMemory[`_nodes.${node.id}`] = nodeMemoryEntry;
235
+ return jobMemory;
236
+ }
237
+ /** Copy selected execution fields when target omits them (e.g. webContext from response.executionMemory). */
238
+ export function copyExecutionContextFields(targetExecution, sourceExecution, fields) {
239
+ if (targetExecution == null || typeof targetExecution !== 'object')
240
+ return;
241
+ if (sourceExecution == null || typeof sourceExecution !== 'object')
242
+ return;
243
+ const target = targetExecution;
244
+ const source = sourceExecution;
245
+ for (const field of fields) {
246
+ if (target[field] === undefined && source[field] !== undefined) {
247
+ target[field] = source[field];
248
+ }
249
+ }
250
+ }
@@ -0,0 +1,18 @@
1
+ import type { HostExecuteGraphRunOptions } from '../types/options.js';
2
+ /**
3
+ * Constructor-side options for {@link createExellixGraphRuntime} used when merging per-call input.
4
+ * Single canonical default in 5.x: `failFast` defaults to **false** on every entry (input → opts → false).
5
+ */
6
+ export type ExellixGraphRuntimeMergeOpts = HostExecuteGraphRunOptions;
7
+ /**
8
+ * Merges per-invocation graph-run knobs with runtime constructor defaults for injected execution.
9
+ *
10
+ * **Precedence:** each field uses `inputField ?? optsField ?? default`. `failFast` defaults to **false**
11
+ * (the legacy "different defaults per entry" rule was removed in 5.x).
12
+ *
13
+ * **Pipeline / node:** graph-level `executionPipeline` from this merge is passed as the run override;
14
+ * node metadata and `execution.executionPipeline` still win inside `executeNode`.
15
+ */
16
+ export declare function mergeExellixGraphRuntimeInvocation(input: HostExecuteGraphRunOptions, opts: ExellixGraphRuntimeMergeOpts): HostExecuteGraphRunOptions & {
17
+ failFast: boolean;
18
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Merges per-invocation graph-run knobs with runtime constructor defaults for injected execution.
3
+ *
4
+ * **Precedence:** each field uses `inputField ?? optsField ?? default`. `failFast` defaults to **false**
5
+ * (the legacy "different defaults per entry" rule was removed in 5.x).
6
+ *
7
+ * **Pipeline / node:** graph-level `executionPipeline` from this merge is passed as the run override;
8
+ * node metadata and `execution.executionPipeline` still win inside `executeNode`.
9
+ */
10
+ export function mergeExellixGraphRuntimeInvocation(input, opts) {
11
+ return {
12
+ failFast: input.failFast ?? opts.failFast ?? false,
13
+ skillKeyResolution: input.skillKeyResolution ?? opts.skillKeyResolution,
14
+ nodeTimeoutMs: input.nodeTimeoutMs ?? opts.nodeTimeoutMs,
15
+ executionPipeline: input.executionPipeline ?? opts.executionPipeline,
16
+ playgroundMeta: input.playgroundMeta ?? opts.playgroundMeta,
17
+ clearSynthesizedContextPerNode: input.clearSynthesizedContextPerNode ?? opts.clearSynthesizedContextPerNode,
18
+ modelConfig: input.modelConfig ?? opts.modelConfig,
19
+ aliasConfig: input.aliasConfig ?? opts.aliasConfig,
20
+ nodes: input.nodes ?? opts.nodes,
21
+ llmCall: input.llmCall ?? opts.llmCall,
22
+ runTaskIdentity: input.runTaskIdentity ?? opts.runTaskIdentity,
23
+ runTaskExecutionMode: input.runTaskExecutionMode ?? opts.runTaskExecutionMode,
24
+ runLogMode: input.runLogMode ?? opts.runLogMode,
25
+ maxRunLogEntries: input.maxRunLogEntries ?? opts.maxRunLogEntries,
26
+ maxRunLogDataJsonChars: input.maxRunLogDataJsonChars ?? opts.maxRunLogDataJsonChars,
27
+ runTaskDiagnostics: input.runTaskDiagnostics ?? opts.runTaskDiagnostics,
28
+ runtimeObjects: input.runtimeObjects ?? opts.runtimeObjects,
29
+ stepRetryPolicy: input.stepRetryPolicy ?? opts.stepRetryPolicy,
30
+ mainReadinessPolicy: input.mainReadinessPolicy ?? opts.mainReadinessPolicy,
31
+ };
32
+ }
@@ -0,0 +1,7 @@
1
+ import type { GraphAiModelConfig, ModelConfigCase, ModelConfigSelection, TaskNodeConditionWhen } from '../types/refs.js';
2
+ export declare function isGraphAiModelConfig(value: unknown): value is GraphAiModelConfig;
3
+ export declare function isEmptyConditionWhen(when: TaskNodeConditionWhen | undefined): boolean;
4
+ export declare function isModelConfigSelection(value: unknown): value is ModelConfigSelection;
5
+ /** Stable hash key for duplicate-when detection. */
6
+ export declare function conditionWhenSignature(when: TaskNodeConditionWhen): string;
7
+ export declare function countDefaultModelConfigCases(cases: ModelConfigCase[]): number;
@@ -0,0 +1,37 @@
1
+ export function isGraphAiModelConfig(value) {
2
+ if (value == null || typeof value !== 'object' || Array.isArray(value))
3
+ return false;
4
+ const o = value;
5
+ const keys = Object.keys(o);
6
+ return (keys.length === 2 &&
7
+ keys.includes('xynthesisModel') &&
8
+ keys.includes('skillModel') &&
9
+ typeof o.xynthesisModel === 'string' &&
10
+ o.xynthesisModel.trim() !== '' &&
11
+ typeof o.skillModel === 'string' &&
12
+ o.skillModel.trim() !== '');
13
+ }
14
+ export function isEmptyConditionWhen(when) {
15
+ if (when == null)
16
+ return true;
17
+ if (typeof when !== 'object' || Array.isArray(when))
18
+ return false;
19
+ const keys = Object.keys(when);
20
+ if (keys.length === 0)
21
+ return true;
22
+ return (when.jsonConditions == null &&
23
+ when.jsConditionFunction == null &&
24
+ when.aiCondition == null);
25
+ }
26
+ export function isModelConfigSelection(value) {
27
+ if (value == null || typeof value !== 'object' || Array.isArray(value))
28
+ return false;
29
+ return Array.isArray(value.cases);
30
+ }
31
+ /** Stable hash key for duplicate-when detection. */
32
+ export function conditionWhenSignature(when) {
33
+ return JSON.stringify(when);
34
+ }
35
+ export function countDefaultModelConfigCases(cases) {
36
+ return cases.filter((c) => isEmptyConditionWhen(c.when)).length;
37
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Package-level Narrix ingest flag semantics:
3
+ * - default enabled
4
+ * - DISABLE_NARRIX_INGEST=1 disables
5
+ *
6
+ * Upstream ai-tasks currently uses USE_NARRIX_INGEST. This helper maps the new
7
+ * semantic into the legacy flag before ai-tasks module initialization.
8
+ */
9
+ export declare function applyNarrixIngestEnvDefault(): void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Package-level Narrix ingest flag semantics:
3
+ * - default enabled
4
+ * - DISABLE_NARRIX_INGEST=1 disables
5
+ *
6
+ * Upstream ai-tasks currently uses USE_NARRIX_INGEST. This helper maps the new
7
+ * semantic into the legacy flag before ai-tasks module initialization.
8
+ */
9
+ export function applyNarrixIngestEnvDefault() {
10
+ const disabled = process.env.DISABLE_NARRIX_INGEST === '1';
11
+ if (disabled) {
12
+ process.env.USE_NARRIX_INGEST = '0';
13
+ return;
14
+ }
15
+ if (process.env.USE_NARRIX_INGEST == null) {
16
+ process.env.USE_NARRIX_INGEST = '1';
17
+ }
18
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Minimal path expression parser for graph mapping.
3
+ * Supports: dot paths (a.b.c), array wildcard (name[*]), object-values (name{*}).
4
+ * No full JSONPath; deterministic and minimal.
5
+ */
6
+ export type PathSegment = {
7
+ kind: 'prop';
8
+ name: string;
9
+ } | {
10
+ kind: 'arrayWildcard';
11
+ name: string;
12
+ } | {
13
+ kind: 'objectValues';
14
+ name: string;
15
+ };
16
+ /**
17
+ * Splits path by '.' and parses each segment.
18
+ * - name -> { kind: 'prop', name }
19
+ * - name[*] -> { kind: 'arrayWildcard', name }
20
+ * - name{*} -> { kind: 'objectValues', name }
21
+ */
22
+ export declare function parsePath(pathExpr: string): PathSegment[];
23
+ /**
24
+ * Select value(s) at pathExpr from root.
25
+ * - Dot path: single value (or undefined).
26
+ * - [*]: flattens to array of values (one per array element).
27
+ * - {*}: flattens to array of object values (deterministic key order).
28
+ * Returns undefined if any step is missing.
29
+ */
30
+ export declare function selectByPath(root: any, pathExpr: string): any;
31
+ /**
32
+ * Write value at pathExpr into root. Creates missing objects along the path.
33
+ * Path must not contain [*] or {*} for write.
34
+ * mode: replace = set; merge = object spread; append = array push.
35
+ */
36
+ export declare function writeByPath(root: any, pathExpr: string, value: any, mode: 'replace' | 'merge' | 'append'): void;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Minimal path expression parser for graph mapping.
3
+ * Supports: dot paths (a.b.c), array wildcard (name[*]), object-values (name{*}).
4
+ * No full JSONPath; deterministic and minimal.
5
+ */
6
+ /**
7
+ * Splits path by '.' and parses each segment.
8
+ * - name -> { kind: 'prop', name }
9
+ * - name[*] -> { kind: 'arrayWildcard', name }
10
+ * - name{*} -> { kind: 'objectValues', name }
11
+ */
12
+ export function parsePath(pathExpr) {
13
+ if (!pathExpr || typeof pathExpr !== 'string')
14
+ return [];
15
+ const parts = pathExpr.split('.');
16
+ const segments = [];
17
+ for (const part of parts) {
18
+ const t = part.trim();
19
+ if (!t)
20
+ continue;
21
+ if (t.endsWith('[*]')) {
22
+ segments.push({ kind: 'arrayWildcard', name: t.slice(0, -3) });
23
+ }
24
+ else if (t.endsWith('{*}')) {
25
+ segments.push({ kind: 'objectValues', name: t.slice(0, -3) });
26
+ }
27
+ else {
28
+ segments.push({ kind: 'prop', name: t });
29
+ }
30
+ }
31
+ return segments;
32
+ }
33
+ /**
34
+ * Select value(s) at pathExpr from root.
35
+ * - Dot path: single value (or undefined).
36
+ * - [*]: flattens to array of values (one per array element).
37
+ * - {*}: flattens to array of object values (deterministic key order).
38
+ * Returns undefined if any step is missing.
39
+ */
40
+ export function selectByPath(root, pathExpr) {
41
+ const segments = parsePath(pathExpr);
42
+ if (segments.length === 0)
43
+ return root;
44
+ let current = [root];
45
+ for (let i = 0; i < segments.length; i++) {
46
+ const seg = segments[i];
47
+ const next = [];
48
+ for (const c of current) {
49
+ if (c === undefined || c === null)
50
+ continue;
51
+ if (seg.kind === 'prop') {
52
+ next.push(c[seg.name]);
53
+ }
54
+ else if (seg.kind === 'arrayWildcard') {
55
+ const arr = c[seg.name];
56
+ if (!Array.isArray(arr))
57
+ continue;
58
+ for (const item of arr)
59
+ next.push(item);
60
+ }
61
+ else if (seg.kind === 'objectValues') {
62
+ const obj = c[seg.name];
63
+ if (obj === null || typeof obj !== 'object' || Array.isArray(obj))
64
+ continue;
65
+ const keys = Object.keys(obj).sort();
66
+ for (const k of keys)
67
+ next.push(obj[k]);
68
+ }
69
+ }
70
+ current = next;
71
+ if (current.length === 0)
72
+ return undefined;
73
+ }
74
+ if (current.length === 0)
75
+ return undefined;
76
+ const hasExpand = segments.some(s => s.kind === 'arrayWildcard' || s.kind === 'objectValues');
77
+ if (hasExpand)
78
+ return current;
79
+ return current[0];
80
+ }
81
+ /**
82
+ * Write value at pathExpr into root. Creates missing objects along the path.
83
+ * Path must not contain [*] or {*} for write.
84
+ * mode: replace = set; merge = object spread; append = array push.
85
+ */
86
+ export function writeByPath(root, pathExpr, value, mode) {
87
+ const segments = parsePath(pathExpr);
88
+ if (segments.length === 0)
89
+ return;
90
+ const hasExpand = segments.some(s => s.kind === 'arrayWildcard' || s.kind === 'objectValues');
91
+ if (hasExpand)
92
+ return; // write only supports simple paths
93
+ let current = root;
94
+ if (current === undefined || current === null)
95
+ return;
96
+ for (let i = 0; i < segments.length - 1; i++) {
97
+ const seg = segments[i];
98
+ if (seg.kind !== 'prop')
99
+ return;
100
+ const key = seg.name;
101
+ if (current[key] === undefined || current[key] === null) {
102
+ current[key] = {};
103
+ }
104
+ current = current[key];
105
+ }
106
+ const last = segments[segments.length - 1];
107
+ if (last.kind !== 'prop')
108
+ return;
109
+ const lastKey = last.name;
110
+ if (mode === 'replace') {
111
+ current[lastKey] = value;
112
+ }
113
+ else if (mode === 'merge') {
114
+ const existing = current[lastKey];
115
+ if (existing !== null && typeof existing === 'object' && !Array.isArray(existing) && typeof value === 'object' && value !== null && !Array.isArray(value)) {
116
+ current[lastKey] = { ...existing, ...value };
117
+ }
118
+ else {
119
+ current[lastKey] = value;
120
+ }
121
+ }
122
+ else if (mode === 'append') {
123
+ const arr = current[lastKey];
124
+ if (!Array.isArray(arr)) {
125
+ current[lastKey] = [value];
126
+ }
127
+ else {
128
+ arr.push(value);
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,14 @@
1
+ import type { GraphPredicate } from '../types/refs.js';
2
+ export type PredicateEvalContext = {
3
+ executionMemory?: unknown;
4
+ variables?: Record<string, unknown> | undefined;
5
+ jobMemory?: unknown;
6
+ taskMemory?: unknown;
7
+ };
8
+ /**
9
+ * Evaluate a graph predicate deterministically.
10
+ *
11
+ * - `undefined` predicate is treated as `true` (edge active).
12
+ * - Invalid predicate shapes evaluate to `false` (edge inactive).
13
+ */
14
+ export declare function evaluateGraphPredicate(predicate: GraphPredicate | undefined, ctx: PredicateEvalContext): boolean;
@@ -0,0 +1,86 @@
1
+ function getByDotPath(root, path) {
2
+ if (!path)
3
+ return undefined;
4
+ const parts = path.split('.').filter(Boolean);
5
+ let cur = root;
6
+ for (const p of parts) {
7
+ if (cur == null)
8
+ return undefined;
9
+ if (typeof cur !== 'object')
10
+ return undefined;
11
+ cur = cur[p];
12
+ }
13
+ return cur;
14
+ }
15
+ function resolvePath(ctx, fullPath) {
16
+ // Supported roots: executionMemory, variables, jobMemory, taskMemory, input, xynthesized
17
+ if (!fullPath)
18
+ return undefined;
19
+ const [rootKey, ...rest] = fullPath.split('.');
20
+ const tail = rest.join('.');
21
+ switch (rootKey) {
22
+ case 'executionMemory':
23
+ return tail ? getByDotPath(ctx.executionMemory, tail) : ctx.executionMemory;
24
+ case 'variables':
25
+ case 'jobVariables':
26
+ return tail
27
+ ? getByDotPath(ctx.executionMemory, `jobVariables.${tail}`)
28
+ : getByDotPath(ctx.executionMemory, 'jobVariables');
29
+ case 'taskVariables':
30
+ return tail
31
+ ? getByDotPath(ctx.executionMemory, `taskVariables.${tail}`)
32
+ : getByDotPath(ctx.executionMemory, 'taskVariables');
33
+ case 'jobMemory':
34
+ return tail ? getByDotPath(ctx.jobMemory, tail) : ctx.jobMemory;
35
+ case 'taskMemory':
36
+ return tail ? getByDotPath(ctx.taskMemory, tail) : ctx.taskMemory;
37
+ case 'input':
38
+ return tail ? getByDotPath(ctx.executionMemory, `input.${tail}`) : getByDotPath(ctx.executionMemory, 'input');
39
+ case 'xynthesized':
40
+ return tail ? getByDotPath(ctx.executionMemory, `xynthesized.${tail}`) : getByDotPath(ctx.executionMemory, 'xynthesized');
41
+ default:
42
+ return undefined;
43
+ }
44
+ }
45
+ /**
46
+ * Evaluate a graph predicate deterministically.
47
+ *
48
+ * - `undefined` predicate is treated as `true` (edge active).
49
+ * - Invalid predicate shapes evaluate to `false` (edge inactive).
50
+ */
51
+ export function evaluateGraphPredicate(predicate, ctx) {
52
+ if (predicate == null)
53
+ return true;
54
+ if (typeof predicate !== 'object')
55
+ return false;
56
+ if ('all' in predicate) {
57
+ const items = predicate.all;
58
+ if (!Array.isArray(items))
59
+ return false;
60
+ return items.every((p) => evaluateGraphPredicate(p, ctx));
61
+ }
62
+ if ('any' in predicate) {
63
+ const items = predicate.any;
64
+ if (!Array.isArray(items))
65
+ return false;
66
+ return items.some((p) => evaluateGraphPredicate(p, ctx));
67
+ }
68
+ if ('not' in predicate) {
69
+ return !evaluateGraphPredicate(predicate.not, ctx);
70
+ }
71
+ if ('path' in predicate && typeof predicate.path === 'string') {
72
+ const v = resolvePath(ctx, predicate.path);
73
+ if (predicate.exists !== undefined) {
74
+ if (typeof predicate.exists !== 'boolean')
75
+ return false;
76
+ const exists = v !== undefined && v !== null;
77
+ return predicate.exists ? exists : !exists;
78
+ }
79
+ if (predicate.eq !== undefined) {
80
+ return v === predicate.eq;
81
+ }
82
+ // If no operator was specified, treat as invalid.
83
+ return false;
84
+ }
85
+ return false;
86
+ }
@@ -0,0 +1,23 @@
1
+ import type { TaskNode } from '../types/refs.js';
2
+ export type TaskNodeInputsConfigCarrier = TaskNode & {
3
+ /** Runtime payload bindings (`executionMemoryPath`); canonical task-node field. */
4
+ inputsConfig?: Record<string, unknown>;
5
+ /** @deprecated Prefer `inputsConfig`. */
6
+ inputBindings?: Record<string, unknown>;
7
+ /**
8
+ * @deprecated Prefer `inputsConfig` — collides with `runtime.inputs` (caller bag)
9
+ * and `RunTaskRequest.inputs` on the wire.
10
+ */
11
+ inputs?: Record<string, unknown>;
12
+ };
13
+ /**
14
+ * Reads a task node's runtime binding recipe with backward-compatible fallbacks.
15
+ * Finalizers use `FinalizerNode.inputs` directly; this helper is for task nodes only.
16
+ */
17
+ export declare function readTaskNodeInputsConfig(node: TaskNode): Record<string, unknown>;
18
+ /**
19
+ * Model surface for graph.response selectors (`nodeInputsConfig` / legacy `nodeInputs`):
20
+ * runtime bindings plus `taskVariable` (taskVariable wins on key collision).
21
+ */
22
+ export declare function readTaskNodeModelInputSurface(node: TaskNode): Record<string, unknown>;
23
+ export declare function isNodeInputsConfigSelectorType(type: string): boolean;