@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,140 @@
1
+ import { readExecutionVariableBuckets, } from './executionVariableBuckets.js';
2
+ import { readTaskNodeInputsConfig } from './readTaskNodeInputsConfig.js';
3
+ function isPlainObject(v) {
4
+ return v != null && typeof v === 'object' && !Array.isArray(v);
5
+ }
6
+ function getByDotPath(root, path) {
7
+ if (!path)
8
+ return root;
9
+ const parts = path.split('.').filter(Boolean);
10
+ let cur = root;
11
+ for (const p of parts) {
12
+ if (cur == null)
13
+ return undefined;
14
+ if (typeof cur !== 'object')
15
+ return undefined;
16
+ cur = cur[p];
17
+ }
18
+ return cur;
19
+ }
20
+ function isExecutionMemoryBinding(val) {
21
+ return isPlainObject(val) && val.type === 'executionMemoryPath' && typeof val.path === 'string';
22
+ }
23
+ /** Best-effort `$path` resolution for legacy binding refs in `inputsConfig`. */
24
+ function resolvePathRef(fullPath, execution) {
25
+ const p = fullPath.trim();
26
+ if (p.startsWith('executionMemory.'))
27
+ return getByDotPath(execution, p.slice('executionMemory.'.length));
28
+ if (p.startsWith('input.'))
29
+ return getByDotPath(execution, p);
30
+ if (p.startsWith('execution.'))
31
+ return getByDotPath(execution, p.slice('execution.'.length));
32
+ return getByDotPath(execution, p);
33
+ }
34
+ function resolveExecutionMemoryBinding(val, execution) {
35
+ const v = getByDotPath(execution, val.path);
36
+ if ((v === undefined || v === null) && val.optional === true)
37
+ return undefined;
38
+ return v;
39
+ }
40
+ function resolvePathFromBuckets(fullPath, buckets) {
41
+ const p = fullPath.trim();
42
+ if (p.startsWith('variables.') || p.startsWith('jobVariables.')) {
43
+ const tail = p.startsWith('variables.')
44
+ ? p.slice('variables.'.length)
45
+ : p.slice('jobVariables.'.length);
46
+ return getByDotPath(buckets.jobVariables, tail);
47
+ }
48
+ if (p.startsWith('taskVariables.')) {
49
+ return getByDotPath(buckets.taskVariables, p.slice('taskVariables.'.length));
50
+ }
51
+ return undefined;
52
+ }
53
+ /**
54
+ * Resolves `node.taskVariable` into concrete values for `RunTaskRequest.input`.
55
+ * `$path` refs resolve against the matching execution bucket only (no cross-bucket merge).
56
+ */
57
+ export function resolveTaskNodeTaskVariableForRunTask(args) {
58
+ const recipe = (args.node.taskVariable ?? {});
59
+ const out = {};
60
+ for (const [key, val] of Object.entries(recipe)) {
61
+ const resolved = resolveTaskVariableValue(val, args.buckets);
62
+ if (resolved !== undefined)
63
+ out[key] = resolved;
64
+ }
65
+ return out;
66
+ }
67
+ function resolveTaskVariableValue(val, buckets) {
68
+ if (!isPlainObject(val))
69
+ return val;
70
+ const o = val;
71
+ if (typeof o.$path === 'string') {
72
+ return resolvePathFromBuckets(o.$path, buckets);
73
+ }
74
+ const nested = {};
75
+ for (const [k, v] of Object.entries(o)) {
76
+ if (k === '$path')
77
+ continue;
78
+ const child = resolveTaskVariableValue(v, buckets);
79
+ if (child !== undefined)
80
+ nested[k] = child;
81
+ }
82
+ return Object.keys(nested).length > 0 ? nested : val;
83
+ }
84
+ /**
85
+ * Resolves runtime payload bindings from `node.inputsConfig` only (plus deprecated aliases).
86
+ */
87
+ export function resolveTaskNodeInputBindingsForRunTask(args) {
88
+ const recipe = readTaskNodeInputsConfig(args.node);
89
+ const out = {};
90
+ for (const [key, val] of Object.entries(recipe)) {
91
+ if (isExecutionMemoryBinding(val)) {
92
+ out[key] = resolveExecutionMemoryBinding(val, args.execution);
93
+ continue;
94
+ }
95
+ if (isPlainObject(val) && typeof val.$path === 'string') {
96
+ const p = val.$path.trim();
97
+ if (p.startsWith('variables.') || p.startsWith('jobVariables.') || p.startsWith('taskVariables.')) {
98
+ continue;
99
+ }
100
+ out[key] = resolvePathRef(p, args.execution);
101
+ }
102
+ }
103
+ return out;
104
+ }
105
+ /** Legacy literals / variable refs still under deprecated `inputs`. */
106
+ function resolveLegacyTaskVariableFromInputBindings(args) {
107
+ const recipe = readTaskNodeInputsConfig(args.node);
108
+ const out = {};
109
+ for (const [key, val] of Object.entries(recipe)) {
110
+ if (isExecutionMemoryBinding(val))
111
+ continue;
112
+ if (isPlainObject(val) && typeof val.$path === 'string') {
113
+ const p = val.$path.trim();
114
+ if (!p.startsWith('variables.') && !p.startsWith('jobVariables.') && !p.startsWith('taskVariables.')) {
115
+ continue;
116
+ }
117
+ }
118
+ const resolved = resolveTaskVariableValue(val, args.buckets);
119
+ if (resolved !== undefined)
120
+ out[key] = resolved;
121
+ }
122
+ return out;
123
+ }
124
+ /**
125
+ * Resolves task-node model input for MAIN `RunTaskRequest.input`:
126
+ * `taskVariable` plus execution-memory bindings (separate buckets, no merge).
127
+ */
128
+ export function resolveTaskNodeInputsForRunTask(args) {
129
+ const buckets = readExecutionVariableBuckets(args.execution);
130
+ const legacyTaskVar = resolveLegacyTaskVariableFromInputBindings({
131
+ node: args.node,
132
+ buckets,
133
+ });
134
+ const taskVariable = resolveTaskNodeTaskVariableForRunTask({ node: args.node, buckets });
135
+ const bindings = resolveTaskNodeInputBindingsForRunTask({
136
+ node: args.node,
137
+ execution: args.execution,
138
+ });
139
+ return { ...legacyTaskVar, ...taskVariable, ...bindings };
140
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared pieces for assembling `@exellix/ai-tasks` requests from graph-engine (llmCall merge, identity, trace mode).
3
+ */
4
+ export declare function mergeDefinedLlmCallParts(...parts: Array<Record<string, unknown> | undefined | null>): Record<string, unknown> | undefined;
5
+ /** Whether to send `executionMode: "trace"` on `runTask` (ai-tasks 5.6+). */
6
+ export declare function shouldForwardRunTaskTraceMode(opts: {
7
+ debugMode?: boolean;
8
+ runTaskExecutionMode?: 'default' | 'trace';
9
+ }): boolean;
10
+ export declare function buildRunTaskIdentityEnvelope(args: {
11
+ base?: Record<string, unknown>;
12
+ nodeMeta?: Record<string, unknown> | undefined;
13
+ graphId?: string;
14
+ nodeId: string;
15
+ taskId: string;
16
+ jobId: string;
17
+ }): Record<string, unknown>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shared pieces for assembling `@exellix/ai-tasks` requests from graph-engine (llmCall merge, identity, trace mode).
3
+ */
4
+ export function mergeDefinedLlmCallParts(...parts) {
5
+ const out = {};
6
+ for (const p of parts) {
7
+ if (!p || typeof p !== 'object' || Array.isArray(p))
8
+ continue;
9
+ for (const [k, v] of Object.entries(p)) {
10
+ if (v !== undefined)
11
+ out[k] = v;
12
+ }
13
+ }
14
+ return Object.keys(out).length > 0 ? out : undefined;
15
+ }
16
+ /** Whether to send `executionMode: "trace"` on `runTask` (ai-tasks 5.6+). */
17
+ export function shouldForwardRunTaskTraceMode(opts) {
18
+ if (opts.runTaskExecutionMode === 'trace')
19
+ return true;
20
+ if (opts.runTaskExecutionMode === 'default')
21
+ return false;
22
+ return opts.debugMode === true;
23
+ }
24
+ export function buildRunTaskIdentityEnvelope(args) {
25
+ const fromNodeRaw = args.nodeMeta?.runTaskIdentity ?? args.nodeMeta?.identity;
26
+ const fromNode = fromNodeRaw != null && typeof fromNodeRaw === 'object' && !Array.isArray(fromNodeRaw)
27
+ ? fromNodeRaw
28
+ : {};
29
+ return {
30
+ ...(args.base ?? {}),
31
+ ...fromNode,
32
+ ...(args.graphId != null && args.graphId !== '' ? { graphId: args.graphId } : {}),
33
+ nodeId: args.nodeId,
34
+ taskId: args.taskId,
35
+ jobId: args.jobId,
36
+ };
37
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Normalize task client responses: mocks and adapters may set `success`, `ok`, or neither (throw-only errors).
3
+ */
4
+ export declare function runTaskResponseSucceeded(res: unknown): boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Normalize task client responses: mocks and adapters may set `success`, `ok`, or neither (throw-only errors).
3
+ */
4
+ export function runTaskResponseSucceeded(res) {
5
+ if (res == null || typeof res !== 'object')
6
+ return false;
7
+ const r = res;
8
+ if (r.error != null)
9
+ return false;
10
+ if (r.success === false || r.ok === false)
11
+ return false;
12
+ return true;
13
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Runtime Objects Observability — types and composition for graph + downstream packages.
3
+ * Callers (playground, UIs) use {@link RuntimeObjects} and queryable clients instead of reading Mongo directly.
4
+ */
5
+ /** Published npm name of this package (root layer in composed observability). */
6
+ export declare const EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME: "@exellix/graph-engine";
7
+ /** Task layer package name in {@link RuntimeObjects.packagesRuntimeObjects}. */
8
+ export declare const EXELLIX_AI_TASKS_PACKAGE_NAME: "@exellix/ai-tasks";
9
+ export type ActivixQueryableClient = {
10
+ getJobActivities(input: {
11
+ jobId: string;
12
+ graphId?: string;
13
+ nodeId?: string;
14
+ limit?: number;
15
+ }): Promise<{
16
+ jobId: string;
17
+ graphRun?: unknown;
18
+ activities: unknown[];
19
+ }>;
20
+ };
21
+ export type LogxerLogLine = {
22
+ ts?: number | string;
23
+ level?: 'debug' | 'info' | 'warn' | 'error';
24
+ scope?: string;
25
+ packageName?: string;
26
+ nodeId?: string;
27
+ message: string;
28
+ data?: unknown;
29
+ };
30
+ export type LogxerQueryableClient = {
31
+ getJobLogs(input: {
32
+ jobId: string;
33
+ graphId?: string;
34
+ nodeId?: string;
35
+ limit?: number;
36
+ }): Promise<{
37
+ jobId: string;
38
+ lines: LogxerLogLine[];
39
+ }>;
40
+ };
41
+ export type PackageRuntimeObjects = {
42
+ name: string;
43
+ activixClient?: ActivixQueryableClient;
44
+ logxerClient?: LogxerQueryableClient;
45
+ };
46
+ export type RuntimeObjects = {
47
+ lastJobId?: string;
48
+ activixClient?: ActivixQueryableClient;
49
+ logxerClient?: LogxerQueryableClient;
50
+ packagesRuntimeObjects: PackageRuntimeObjects[];
51
+ };
52
+ export type BuildExellixGraphRuntimeObjectsInput = {
53
+ /** Graph-level Activix query surface (e.g. from `@x12i/activix` when available). */
54
+ graphActivixClient?: ActivixQueryableClient;
55
+ /** Graph-level Logxer query surface. */
56
+ graphLogxerClient?: LogxerQueryableClient;
57
+ /**
58
+ * Partial subtree from `@exellix/ai-tasks` when that package exports `runtimeObjects`.
59
+ * Nested `packagesRuntimeObjects` are appended after the ai-tasks row without overwriting entries.
60
+ */
61
+ aiTasksRuntimeObjects?: Pick<RuntimeObjects, 'activixClient' | 'logxerClient'> & {
62
+ packagesRuntimeObjects?: PackageRuntimeObjects[];
63
+ };
64
+ };
65
+ /**
66
+ * Builds the composed {@link RuntimeObjects} for exellix-graph: graph-level clients at the root,
67
+ * then an `@exellix/ai-tasks` package row plus any nested package rows from ai-tasks (flattened as siblings).
68
+ */
69
+ export declare function buildExellixGraphRuntimeObjects(input: BuildExellixGraphRuntimeObjectsInput): RuntimeObjects;
70
+ /**
71
+ * Sets the root correlation id for the current graph run (same id forwarded on `runTask` as `jobId`).
72
+ * Mutates `runtimeObjects` in place when defined.
73
+ */
74
+ export declare function setRuntimeObjectsLastJobId(runtimeObjects: RuntimeObjects | undefined, jobId: string): void;
75
+ export type RuntimeObjectsObservabilitySummary = {
76
+ lastJobId?: string;
77
+ graphActivix: boolean;
78
+ graphLogxer: boolean;
79
+ packages: Array<{
80
+ name: string;
81
+ activix: boolean;
82
+ logxer: boolean;
83
+ }>;
84
+ };
85
+ export declare function summarizeRuntimeObjectsForPlayground(ro: RuntimeObjects): RuntimeObjectsObservabilitySummary;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Runtime Objects Observability — types and composition for graph + downstream packages.
3
+ * Callers (playground, UIs) use {@link RuntimeObjects} and queryable clients instead of reading Mongo directly.
4
+ */
5
+ /** Published npm name of this package (root layer in composed observability). */
6
+ export const EXELLIX_GRAPH_RUNTIME_PACKAGE_NAME = '@exellix/graph-engine';
7
+ /** Task layer package name in {@link RuntimeObjects.packagesRuntimeObjects}. */
8
+ export const EXELLIX_AI_TASKS_PACKAGE_NAME = '@exellix/ai-tasks';
9
+ /**
10
+ * Builds the composed {@link RuntimeObjects} for exellix-graph: graph-level clients at the root,
11
+ * then an `@exellix/ai-tasks` package row plus any nested package rows from ai-tasks (flattened as siblings).
12
+ */
13
+ export function buildExellixGraphRuntimeObjects(input) {
14
+ const ai = input.aiTasksRuntimeObjects;
15
+ const tail = [...(ai?.packagesRuntimeObjects ?? [])];
16
+ const packagesRuntimeObjects = [
17
+ {
18
+ name: EXELLIX_AI_TASKS_PACKAGE_NAME,
19
+ activixClient: ai?.activixClient,
20
+ logxerClient: ai?.logxerClient,
21
+ },
22
+ ...tail,
23
+ ];
24
+ return {
25
+ activixClient: input.graphActivixClient,
26
+ logxerClient: input.graphLogxerClient,
27
+ packagesRuntimeObjects,
28
+ };
29
+ }
30
+ /**
31
+ * Sets the root correlation id for the current graph run (same id forwarded on `runTask` as `jobId`).
32
+ * Mutates `runtimeObjects` in place when defined.
33
+ */
34
+ export function setRuntimeObjectsLastJobId(runtimeObjects, jobId) {
35
+ if (!runtimeObjects || jobId.length === 0)
36
+ return;
37
+ runtimeObjects.lastJobId = jobId;
38
+ }
39
+ export function summarizeRuntimeObjectsForPlayground(ro) {
40
+ return {
41
+ lastJobId: ro.lastJobId,
42
+ graphActivix: ro.activixClient != null,
43
+ graphLogxer: ro.logxerClient != null,
44
+ packages: ro.packagesRuntimeObjects.map((p) => ({
45
+ name: p.name,
46
+ activix: p.activixClient != null,
47
+ logxer: p.logxerClient != null,
48
+ })),
49
+ };
50
+ }
@@ -0,0 +1,13 @@
1
+ import type { SmartInputConfig } from '../types/aiTasksDerivedTypes.js';
2
+ import type { TaskNode } from '../types/refs.js';
3
+ /**
4
+ * Normalizes one smartInput path entry: plain string or graphs-studio `{ path, title?, required? }`.
5
+ */
6
+ export declare function normalizeSmartInputPath(entry: unknown): string | undefined;
7
+ /** Collects normalized path strings from a task node (authoring may use string or object entries). */
8
+ export declare function collectSmartInputPaths(node: TaskNode): string[];
9
+ /** Wire shape for ai-tasks `runTask`: normalized string `paths` (authoring may use graphs-studio objects). */
10
+ export declare function normalizeSmartInputConfigForRunTask(smartInput: SmartInputConfig | undefined): {
11
+ paths: string[];
12
+ strict?: boolean;
13
+ } | undefined;
@@ -0,0 +1,38 @@
1
+ function isPlainObject(v) {
2
+ return v != null && typeof v === 'object' && !Array.isArray(v);
3
+ }
4
+ /**
5
+ * Normalizes one smartInput path entry: plain string or graphs-studio `{ path, title?, required? }`.
6
+ */
7
+ export function normalizeSmartInputPath(entry) {
8
+ if (typeof entry === 'string') {
9
+ const t = entry.trim();
10
+ return t.length > 0 ? t : undefined;
11
+ }
12
+ if (isPlainObject(entry) && typeof entry.path === 'string') {
13
+ const t = entry.path.trim();
14
+ return t.length > 0 ? t : undefined;
15
+ }
16
+ return undefined;
17
+ }
18
+ /** Collects normalized path strings from a task node (authoring may use string or object entries). */
19
+ export function collectSmartInputPaths(node) {
20
+ const raw = node.smartInput?.paths;
21
+ if (!Array.isArray(raw))
22
+ return [];
23
+ return raw.map(normalizeSmartInputPath).filter((p) => p != null);
24
+ }
25
+ /** Wire shape for ai-tasks `runTask`: normalized string `paths` (authoring may use graphs-studio objects). */
26
+ export function normalizeSmartInputConfigForRunTask(smartInput) {
27
+ if (smartInput == null || typeof smartInput !== 'object' || Array.isArray(smartInput)) {
28
+ return undefined;
29
+ }
30
+ const raw = smartInput;
31
+ const paths = collectSmartInputPaths({ smartInput: raw });
32
+ if (paths.length === 0 && raw.strict === undefined)
33
+ return undefined;
34
+ return {
35
+ ...(raw.strict !== undefined ? { strict: raw.strict } : {}),
36
+ paths,
37
+ };
38
+ }
@@ -0,0 +1,21 @@
1
+ import type { RunLogEntry } from '../types/runLog.js';
2
+ import type { RunTaskRequest, RunTaskResponse, StepRetryPolicy } from '../types/options.js';
3
+ import type { TaskNode } from '../types/refs.js';
4
+ import type { StepAttemptRecord } from '../types/results.js';
5
+ export type ResolvedStepRetryPolicy = Required<Pick<StepRetryPolicy, 'maxAttempts' | 'retryOnTimeout' | 'retryOnTokenLimit' | 'tokenBumpMultiplier' | 'tokenBumpCap' | 'baseMaxTokensFallback'>>;
6
+ export declare function resolveStepRetryPolicy(graphPolicy: StepRetryPolicy | undefined, node: Pick<TaskNode, 'taskConfiguration'> | undefined): ResolvedStepRetryPolicy;
7
+ export type RunTaskWithRetryResult = {
8
+ response: RunTaskResponse;
9
+ attempts: StepAttemptRecord[];
10
+ syntheticRunLog: RunLogEntry[];
11
+ lastRequest: RunTaskRequest;
12
+ };
13
+ export declare function runRunTaskWithRetry(args: {
14
+ initialRequest: RunTaskRequest;
15
+ doRunTask: (req: RunTaskRequest) => Promise<RunTaskResponse>;
16
+ nodeTimeoutMs?: number;
17
+ policy: ResolvedStepRetryPolicy;
18
+ nodeId: string;
19
+ skillKey: string;
20
+ nodeTimeoutErrorFactory: () => Error;
21
+ }): Promise<RunTaskWithRetryResult>;
@@ -0,0 +1,238 @@
1
+ import { runTaskResponseSucceeded } from './runTaskResponse.js';
2
+ import { withTimeout } from './withTimeout.js';
3
+ const DEFAULT_POLICY = {
4
+ maxAttempts: 3,
5
+ retryOnTimeout: true,
6
+ retryOnTokenLimit: true,
7
+ tokenBumpMultiplier: 2,
8
+ tokenBumpCap: 16_000,
9
+ baseMaxTokensFallback: 2000,
10
+ };
11
+ export function resolveStepRetryPolicy(graphPolicy, node) {
12
+ const nodeRaw = node?.taskConfiguration?.stepRetryPolicy;
13
+ const nodePolicy = nodeRaw != null && typeof nodeRaw === 'object' && !Array.isArray(nodeRaw) ? nodeRaw : undefined;
14
+ const merged = { ...DEFAULT_POLICY, ...graphPolicy, ...nodePolicy };
15
+ const maxAttempts = Math.max(1, Math.floor(merged.maxAttempts ?? DEFAULT_POLICY.maxAttempts));
16
+ return {
17
+ maxAttempts,
18
+ retryOnTimeout: merged.retryOnTimeout !== false,
19
+ retryOnTokenLimit: merged.retryOnTokenLimit !== false,
20
+ tokenBumpMultiplier: Math.max(1, merged.tokenBumpMultiplier ?? DEFAULT_POLICY.tokenBumpMultiplier),
21
+ tokenBumpCap: Math.max(1, merged.tokenBumpCap ?? DEFAULT_POLICY.tokenBumpCap),
22
+ baseMaxTokensFallback: Math.max(1, merged.baseMaxTokensFallback ?? DEFAULT_POLICY.baseMaxTokensFallback),
23
+ };
24
+ }
25
+ function readNum(v) {
26
+ return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
27
+ }
28
+ function readMaxTokensFromRequest(req) {
29
+ const llm = req.llmCall;
30
+ return (readNum(llm?.maxTokens) ??
31
+ readNum(llm?.max_tokens));
32
+ }
33
+ function shallowCloneRunTaskRequest(req) {
34
+ return {
35
+ ...req,
36
+ ...(req.modelConfig != null && typeof req.modelConfig === 'object' && !Array.isArray(req.modelConfig)
37
+ ? { modelConfig: { ...req.modelConfig } }
38
+ : {}),
39
+ ...(req.llmCall != null && typeof req.llmCall === 'object' && !Array.isArray(req.llmCall)
40
+ ? { llmCall: { ...req.llmCall } }
41
+ : {}),
42
+ ...(req.input != null && typeof req.input === 'object' && !Array.isArray(req.input)
43
+ ? { input: { ...req.input } }
44
+ : {}),
45
+ };
46
+ }
47
+ function applyTokenBump(workingReq, policy) {
48
+ const current = readMaxTokensFromRequest(workingReq) ?? policy.baseMaxTokensFallback;
49
+ const after = Math.min(policy.tokenBumpCap, Math.floor(current * policy.tokenBumpMultiplier));
50
+ workingReq.llmCall =
51
+ workingReq.llmCall != null && typeof workingReq.llmCall === 'object' && !Array.isArray(workingReq.llmCall)
52
+ ? { ...workingReq.llmCall, maxTokens: after }
53
+ : { maxTokens: after };
54
+ return { before: current, after };
55
+ }
56
+ function classifyThrownError(err) {
57
+ if (err == null || typeof err !== 'object')
58
+ return 'other';
59
+ const e = err;
60
+ const code = typeof e.code === 'string' ? e.code : '';
61
+ const name = typeof e.name === 'string' ? e.name : '';
62
+ const msg = typeof e.message === 'string' ? e.message.toLowerCase() : '';
63
+ if (code === 'NODE_TIMEOUT' || code === 'ETIMEDOUT')
64
+ return 'timeout';
65
+ if (name === 'ProviderTimeoutError')
66
+ return 'timeout';
67
+ if (msg.includes('timed out') || msg.includes('timeout'))
68
+ return 'timeout';
69
+ if (code === 'MAX_TOKENS' ||
70
+ code === 'LENGTH' ||
71
+ code === 'OUTPUT_TRUNCATED' ||
72
+ code === 'CONTEXT_LENGTH_EXCEEDED') {
73
+ return 'token-limit';
74
+ }
75
+ return 'other';
76
+ }
77
+ function classifyResponseFailure(response) {
78
+ const err = response.error;
79
+ const code = typeof err?.code === 'string' ? err.code.toUpperCase() : '';
80
+ if (code === 'MAX_TOKENS' || code === 'LENGTH' || code === 'OUTPUT_TRUNCATED' || code === 'CONTEXT_LENGTH_EXCEEDED') {
81
+ return 'token-limit';
82
+ }
83
+ const parsed = response.parsed;
84
+ const meta = parsed?.meta;
85
+ const finishReason = typeof meta?.finishReason === 'string' ? meta.finishReason.toLowerCase() : '';
86
+ if (finishReason === 'length')
87
+ return 'token-limit';
88
+ if (code === 'ETIMEDOUT' || code === 'NODE_TIMEOUT')
89
+ return 'timeout';
90
+ const msg = typeof err?.message === 'string' ? err.message.toLowerCase() : '';
91
+ if (msg.includes('timed out') || msg.includes('timeout'))
92
+ return 'timeout';
93
+ return 'other';
94
+ }
95
+ function shouldRetryClassification(c, policy, attemptIndex) {
96
+ if (c === 'other')
97
+ return false;
98
+ if (attemptIndex >= policy.maxAttempts - 1)
99
+ return false;
100
+ if (c === 'timeout' && !policy.retryOnTimeout)
101
+ return false;
102
+ if (c === 'token-limit' && !policy.retryOnTokenLimit)
103
+ return false;
104
+ return true;
105
+ }
106
+ function pushSyntheticRunLog(out, args) {
107
+ out.push({
108
+ ts: Date.now(),
109
+ level: args.level,
110
+ scope: 'node',
111
+ nodeId: args.nodeId,
112
+ skillKey: args.skillKey,
113
+ message: args.message,
114
+ data: args.data,
115
+ });
116
+ }
117
+ export async function runRunTaskWithRetry(args) {
118
+ const { policy, nodeId, skillKey } = args;
119
+ let workingReq = shallowCloneRunTaskRequest(args.initialRequest);
120
+ const attempts = [];
121
+ const syntheticRunLog = [];
122
+ for (let attemptIndex = 0; attemptIndex < policy.maxAttempts; attemptIndex++) {
123
+ const startedAt = Date.now();
124
+ let response;
125
+ let thrown;
126
+ try {
127
+ const p = args.doRunTask(workingReq);
128
+ response = args.nodeTimeoutMs
129
+ ? await withTimeout(p, args.nodeTimeoutMs, args.nodeTimeoutErrorFactory)
130
+ : await p;
131
+ }
132
+ catch (e) {
133
+ thrown = e;
134
+ }
135
+ const endedAt = Date.now();
136
+ const durationMs = endedAt - startedAt;
137
+ const maxTok = readMaxTokensFromRequest(workingReq);
138
+ if (thrown != null) {
139
+ const c = classifyThrownError(thrown);
140
+ attempts.push({
141
+ index: attemptIndex,
142
+ ok: false,
143
+ startedAt,
144
+ endedAt,
145
+ durationMs,
146
+ classification: c,
147
+ errorCode: thrown?.code,
148
+ errorMessage: thrown?.message,
149
+ maxTokensRequested: maxTok,
150
+ });
151
+ pushSyntheticRunLog(syntheticRunLog, {
152
+ nodeId,
153
+ skillKey,
154
+ level: c === 'other' ? 'error' : 'warn',
155
+ message: `step attempt ${attemptIndex + 1}/${policy.maxAttempts} failed (${c})`,
156
+ data: {
157
+ classification: c,
158
+ errorCode: thrown?.code,
159
+ maxTokensRequested: maxTok,
160
+ },
161
+ });
162
+ if (!shouldRetryClassification(c, policy, attemptIndex)) {
163
+ const err = thrown instanceof Error ? thrown : new Error(String(thrown));
164
+ err.syntheticStepRetryRunLog = syntheticRunLog;
165
+ err.stepRetryAttempts = attempts;
166
+ throw err;
167
+ }
168
+ if (c === 'token-limit' && policy.retryOnTokenLimit) {
169
+ const { before, after } = applyTokenBump(workingReq, policy);
170
+ pushSyntheticRunLog(syntheticRunLog, {
171
+ nodeId,
172
+ skillKey,
173
+ level: 'info',
174
+ message: `step retry ${attemptIndex + 2}/${policy.maxAttempts}: token-limit bump maxTokens ${before} -> ${after}`,
175
+ data: { classification: c, maxTokensBefore: before, maxTokensAfter: after, attempt: attemptIndex + 1 },
176
+ });
177
+ }
178
+ continue;
179
+ }
180
+ if (response == null) {
181
+ const err = new Error('runTask returned undefined');
182
+ err.syntheticStepRetryRunLog = syntheticRunLog;
183
+ err.stepRetryAttempts = attempts;
184
+ throw err;
185
+ }
186
+ if (runTaskResponseSucceeded(response)) {
187
+ attempts.push({
188
+ index: attemptIndex,
189
+ ok: true,
190
+ startedAt,
191
+ endedAt,
192
+ durationMs,
193
+ maxTokensRequested: maxTok,
194
+ });
195
+ return { response, attempts, syntheticRunLog, lastRequest: workingReq };
196
+ }
197
+ const c = classifyResponseFailure(response);
198
+ attempts.push({
199
+ index: attemptIndex,
200
+ ok: false,
201
+ startedAt,
202
+ endedAt,
203
+ durationMs,
204
+ classification: c,
205
+ errorCode: response.error?.code,
206
+ errorMessage: response.error?.message,
207
+ maxTokensRequested: maxTok,
208
+ });
209
+ pushSyntheticRunLog(syntheticRunLog, {
210
+ nodeId,
211
+ skillKey,
212
+ level: c === 'other' ? 'error' : 'warn',
213
+ message: `step attempt ${attemptIndex + 1}/${policy.maxAttempts} failed (${c})`,
214
+ data: {
215
+ classification: c,
216
+ errorCode: response.error?.code,
217
+ maxTokensRequested: maxTok,
218
+ },
219
+ });
220
+ if (!shouldRetryClassification(c, policy, attemptIndex)) {
221
+ return { response, attempts, syntheticRunLog, lastRequest: workingReq };
222
+ }
223
+ if (c === 'token-limit' && policy.retryOnTokenLimit) {
224
+ const { before, after } = applyTokenBump(workingReq, policy);
225
+ pushSyntheticRunLog(syntheticRunLog, {
226
+ nodeId,
227
+ skillKey,
228
+ level: 'info',
229
+ message: `step retry ${attemptIndex + 2}/${policy.maxAttempts}: token-limit bump maxTokens ${before} -> ${after}`,
230
+ data: { classification: c, maxTokensBefore: before, maxTokensAfter: after, attempt: attemptIndex + 1 },
231
+ });
232
+ }
233
+ }
234
+ const err = new Error('runRunTaskWithRetry: exhausted attempts without result');
235
+ err.syntheticStepRetryRunLog = syntheticRunLog;
236
+ err.stepRetryAttempts = attempts;
237
+ throw err;
238
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * PRE `synthesized-context` step config normalization. Used by executeNode and ExellixGraphRuntime
3
+ * so explicit pipeline `config` is normalized; input synthesis is authored on `taskConfiguration.aiTaskProfile.inputSynthesis`.
4
+ */
5
+ import type { ExecutionStepOption } from '../types/options.js';
6
+ export declare function normalizeSynthesizedContextConfig(config: unknown): Record<string, unknown>;
7
+ export type PipelineStep = ExecutionStepOption;
8
+ /**
9
+ * When the pipeline includes a `pre` + `synthesized-context` step, shallow-merge
10
+ * a caller-supplied baseline into that step's `config` (step keys override).
11
+ */
12
+ export declare function mergeNodeSynthesizedContextIntoPipeline(executionPipeline: PipelineStep[], rawNodeSynth: unknown): PipelineStep[];