@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,28 @@
1
+ export function normalizeSynthesizedContextConfig(config) {
2
+ const normalized = config != null && typeof config === 'object' && !Array.isArray(config)
3
+ ? { ...config }
4
+ : {};
5
+ if (typeof normalized.mode === 'string' && normalized.synthesisMode === undefined) {
6
+ normalized.synthesisMode = normalized.mode;
7
+ }
8
+ return normalized;
9
+ }
10
+ /**
11
+ * When the pipeline includes a `pre` + `synthesized-context` step, shallow-merge
12
+ * a caller-supplied baseline into that step's `config` (step keys override).
13
+ */
14
+ export function mergeNodeSynthesizedContextIntoPipeline(executionPipeline, rawNodeSynth) {
15
+ const hasSynthesizedContextPre = executionPipeline.some((s) => s.phase === 'pre' && s.type === 'synthesized-context');
16
+ if (!hasSynthesizedContextPre)
17
+ return executionPipeline;
18
+ const nodeSynthBaseline = rawNodeSynth != null && rawNodeSynth !== false
19
+ ? normalizeSynthesizedContextConfig(rawNodeSynth)
20
+ : {};
21
+ return executionPipeline.map((s) => {
22
+ if (s.phase === 'pre' && s.type === 'synthesized-context') {
23
+ const stepConfig = normalizeSynthesizedContextConfig(s.config);
24
+ return { ...s, config: { ...nodeSynthBaseline, ...stepConfig } };
25
+ }
26
+ return s;
27
+ });
28
+ }
@@ -0,0 +1,27 @@
1
+ import type { RunxClient } from '@x12i/runx';
2
+ import type { TaskNodeConditionWhen, TaskNodeConditions } from '../types/refs.js';
3
+ import type { PredicateEvalContext } from './predicates.js';
4
+ export type TaskNodeConditionEvalContext = PredicateEvalContext & {
5
+ job?: unknown;
6
+ };
7
+ export type TaskNodeConditionsEvalDeps = {
8
+ runx?: RunxClient;
9
+ };
10
+ export type TaskNodeConditionsEvalResult = {
11
+ ok: true;
12
+ } | {
13
+ ok: false;
14
+ skipReason: string;
15
+ error?: string;
16
+ };
17
+ export declare function applyConditionNegate(meetsCondition: boolean, negate?: boolean): boolean;
18
+ /** AND across present gates in a `when` block. */
19
+ export declare function evaluateConditionWhen(when: TaskNodeConditionWhen, ctx: TaskNodeConditionEvalContext, executionInput: Record<string, unknown>, deps: TaskNodeConditionsEvalDeps): Promise<{
20
+ ok: boolean;
21
+ skipReason?: string;
22
+ error?: string;
23
+ }>;
24
+ /**
25
+ * Returns whether the node should run. False → caller should skip the node.
26
+ */
27
+ export declare function evaluateTaskNodeConditions(conditions: TaskNodeConditions | undefined, ctx: TaskNodeConditionEvalContext, executionInput: Record<string, unknown>, deps: TaskNodeConditionsEvalDeps): Promise<TaskNodeConditionsEvalResult>;
@@ -0,0 +1,140 @@
1
+ import { checkContentCondition } from '@x12i/runx/condition';
2
+ export function applyConditionNegate(meetsCondition, negate) {
3
+ return negate === true ? !meetsCondition : meetsCondition;
4
+ }
5
+ function buildConditionContent(ctx, executionInput) {
6
+ const em = ctx.executionMemory != null && typeof ctx.executionMemory === 'object' && !Array.isArray(ctx.executionMemory)
7
+ ? ctx.executionMemory
8
+ : undefined;
9
+ return {
10
+ data: executionInput,
11
+ input: executionInput,
12
+ executionMemory: ctx.executionMemory,
13
+ variables: em?.jobVariables ?? ctx.variables,
14
+ jobVariables: em?.jobVariables ?? ctx.variables,
15
+ taskVariables: em?.taskVariables,
16
+ jobMemory: ctx.jobMemory,
17
+ taskMemory: ctx.taskMemory,
18
+ job: ctx.job,
19
+ };
20
+ }
21
+ function normalizeCapabilityBoolean(output) {
22
+ if (typeof output === 'boolean')
23
+ return output;
24
+ if (output != null && typeof output === 'object' && !Array.isArray(output)) {
25
+ const o = output;
26
+ if (typeof o.meetsCondition === 'boolean')
27
+ return o.meetsCondition;
28
+ if (typeof o.ok === 'boolean' && 'meetsCondition' in o)
29
+ return o.meetsCondition;
30
+ }
31
+ return undefined;
32
+ }
33
+ async function evaluateJsonCondition(spec, content, deps) {
34
+ const result = await checkContentCondition({
35
+ content,
36
+ condition: spec.condition,
37
+ parameters: spec.parameters,
38
+ conditionType: 'json',
39
+ mode: 'deterministic',
40
+ options: spec.options,
41
+ }, deps.runx?.funcx != null ? { funcx: deps.runx.funcx } : undefined);
42
+ if (!result.ok) {
43
+ return { ok: false, error: result.error };
44
+ }
45
+ return { ok: applyConditionNegate(result.meetsCondition, spec.negate) };
46
+ }
47
+ async function evaluateJsCondition(spec, content, deps) {
48
+ if (!deps.runx) {
49
+ return { ok: false, error: 'runx client is required for jsConditionFunction' };
50
+ }
51
+ const runResult = await deps.runx.run(spec.conditionFunctionId, {
52
+ content,
53
+ parameters: spec.parameters ?? {},
54
+ });
55
+ if (!runResult.ok) {
56
+ return { ok: false, error: String(runResult.error ?? 'runx.run failed') };
57
+ }
58
+ const meets = normalizeCapabilityBoolean(runResult.output);
59
+ if (meets === undefined) {
60
+ return { ok: false, error: 'jsConditionFunction capability must return boolean or { meetsCondition: boolean }' };
61
+ }
62
+ return { ok: applyConditionNegate(meets, spec.negate) };
63
+ }
64
+ async function evaluateAiCondition(spec, content, deps) {
65
+ const mode = spec.mode ?? 'hybrid';
66
+ const result = await checkContentCondition({
67
+ content,
68
+ condition: spec.condition,
69
+ parameters: spec.parameters,
70
+ conditionType: 'json',
71
+ mode,
72
+ model: spec.model,
73
+ client: deps.runx?.funcx,
74
+ }, deps.runx?.funcx != null ? { funcx: deps.runx.funcx } : undefined);
75
+ if (!result.ok) {
76
+ return { ok: false, error: result.error };
77
+ }
78
+ return { ok: applyConditionNegate(result.meetsCondition, spec.negate) };
79
+ }
80
+ /** AND across present gates in a `when` block. */
81
+ export async function evaluateConditionWhen(when, ctx, executionInput, deps) {
82
+ const content = buildConditionContent(ctx, executionInput);
83
+ if (when.jsonConditions != null) {
84
+ const ev = await evaluateJsonCondition(when.jsonConditions, content, deps);
85
+ if (ev.error) {
86
+ return { ok: false, skipReason: 'condition_eval_error', error: ev.error };
87
+ }
88
+ if (!ev.ok) {
89
+ return { ok: false, skipReason: 'json_conditions' };
90
+ }
91
+ }
92
+ if (when.jsConditionFunction != null) {
93
+ const ev = await evaluateJsCondition(when.jsConditionFunction, content, deps);
94
+ if (ev.error) {
95
+ return { ok: false, skipReason: 'condition_eval_error', error: ev.error };
96
+ }
97
+ if (!ev.ok) {
98
+ return { ok: false, skipReason: 'js_condition' };
99
+ }
100
+ }
101
+ if (when.aiCondition != null) {
102
+ const ev = await evaluateAiCondition(when.aiCondition, content, deps);
103
+ if (ev.error) {
104
+ return { ok: false, skipReason: 'condition_eval_error', error: ev.error };
105
+ }
106
+ if (!ev.ok) {
107
+ return { ok: false, skipReason: 'ai_condition' };
108
+ }
109
+ }
110
+ return { ok: true };
111
+ }
112
+ function hasEvaluatedConditionGate(conditions) {
113
+ if (conditions == null)
114
+ return false;
115
+ return (conditions.jsonConditions != null ||
116
+ conditions.jsConditionFunction != null ||
117
+ conditions.aiCondition != null);
118
+ }
119
+ /**
120
+ * Returns whether the node should run. False → caller should skip the node.
121
+ */
122
+ export async function evaluateTaskNodeConditions(conditions, ctx, executionInput, deps) {
123
+ if (!hasEvaluatedConditionGate(conditions)) {
124
+ return { ok: true };
125
+ }
126
+ const when = {
127
+ jsonConditions: conditions.jsonConditions,
128
+ jsConditionFunction: conditions.jsConditionFunction,
129
+ aiCondition: conditions.aiCondition,
130
+ };
131
+ const ev = await evaluateConditionWhen(when, ctx, executionInput, deps);
132
+ if (ev.ok) {
133
+ return { ok: true };
134
+ }
135
+ return {
136
+ ok: false,
137
+ skipReason: ev.skipReason ?? 'condition_eval_error',
138
+ error: ev.error,
139
+ };
140
+ }
@@ -0,0 +1,45 @@
1
+ import type { GraphEntryContract, TaskNode } from '../types/refs.js';
2
+ import type { MainReadinessPolicy } from '../types/options.js';
3
+ import { type GraphEngineMemoryResolutionRoot } from './resolveGraphEngineMemoryPaths.js';
4
+ export type { MainReadinessPolicy };
5
+ /** Check ids aligned with graphs-studio Run Analysis (G1, G4). */
6
+ export type MainReadinessCheckId = 'execution_input_empty' | 'synthesis_context_empty';
7
+ export type MainReadinessEvaluation = {
8
+ policy: MainReadinessPolicy;
9
+ ok: boolean;
10
+ failedChecks: MainReadinessCheckId[];
11
+ warnings: MainReadinessCheckId[];
12
+ pathsByCheck: Partial<Record<MainReadinessCheckId, string[]>>;
13
+ };
14
+ export { normalizeSmartInputPath } from './smartInputPaths.js';
15
+ export declare function collectInputSynthesisSourcePaths(node: TaskNode): string[];
16
+ /**
17
+ * Evaluates MAIN-readiness before invoking the skill. Paths resolve via {@link resolveGraphEngineMemoryPathValue}
18
+ * (`input.*` and `inputs.*` are distinct roots). Policy `off` skips all checks.
19
+ */
20
+ export declare function evaluateTaskNodeMainReadiness(args: {
21
+ policy: MainReadinessPolicy;
22
+ node: TaskNode;
23
+ graphEntry?: GraphEntryContract;
24
+ resolutionRoot: GraphEngineMemoryResolutionRoot;
25
+ smartInputPaths?: string[];
26
+ inputSynthesisPaths?: string[];
27
+ }): MainReadinessEvaluation;
28
+ export declare function buildMainReadinessResolutionRoot(args: {
29
+ taskInput: Record<string, unknown>;
30
+ callerInputs?: Record<string, unknown>;
31
+ executionMemory: Record<string, unknown>;
32
+ xynthesized: {
33
+ job: Record<string, unknown>;
34
+ task: Record<string, unknown>;
35
+ execution?: Record<string, unknown>;
36
+ };
37
+ jobMemory?: unknown;
38
+ taskMemory?: unknown;
39
+ }): GraphEngineMemoryResolutionRoot;
40
+ export declare function resolveMainReadinessPolicy(args: {
41
+ runtimePolicy?: MainReadinessPolicy;
42
+ nodeTaskConfiguration?: Record<string, unknown>;
43
+ }): MainReadinessPolicy;
44
+ /** Normalizes a smart-input path entry to a memory root key (for inspection helpers). */
45
+ export declare function smartInputPathRoot(path: string): string | undefined;
@@ -0,0 +1,164 @@
1
+ import { splitGraphEngineMemoryPath } from './graphEngineMemoryPaths.js';
2
+ import { buildMemoryResolutionRootFromExecution } from './executionVariableBuckets.js';
3
+ import { resolveGraphEngineMemoryPathValue, } from './resolveGraphEngineMemoryPaths.js';
4
+ function isPlainObject(v) {
5
+ return v != null && typeof v === 'object' && !Array.isArray(v);
6
+ }
7
+ function isEmptyReadinessValue(value) {
8
+ if (value === undefined || value === null)
9
+ return true;
10
+ if (typeof value === 'string')
11
+ return value.trim() === '';
12
+ if (Array.isArray(value))
13
+ return value.length === 0;
14
+ if (isPlainObject(value))
15
+ return Object.keys(value).length === 0;
16
+ return false;
17
+ }
18
+ export { normalizeSmartInputPath } from './smartInputPaths.js';
19
+ import { collectSmartInputPaths } from './smartInputPaths.js';
20
+ export function collectInputSynthesisSourcePaths(node) {
21
+ const profile = node.taskConfiguration?.aiTaskProfile;
22
+ const sources = profile?.inputSynthesis?.sources;
23
+ if (!Array.isArray(sources))
24
+ return [];
25
+ return sources
26
+ .map((s) => (typeof s === 'string' ? s.trim() : undefined))
27
+ .filter((s) => s != null && s.length > 0);
28
+ }
29
+ function collectGraphEntryInputPaths(graphEntry) {
30
+ const paths = new Set();
31
+ for (const p of graphEntry?.requiredExecutionPaths ?? []) {
32
+ if (typeof p === 'string' && p.trim() !== '')
33
+ paths.add(p.trim());
34
+ }
35
+ for (const spec of graphEntry?.inputs ?? []) {
36
+ if (spec == null || typeof spec !== 'object')
37
+ continue;
38
+ const rec = spec;
39
+ if (rec.kind === 'execution')
40
+ continue;
41
+ if (rec.required === false)
42
+ continue;
43
+ if (typeof rec.path === 'string' && rec.path.trim() !== '')
44
+ paths.add(rec.path.trim());
45
+ }
46
+ return [...paths];
47
+ }
48
+ function executionInputWatchPaths(args) {
49
+ const paths = new Set();
50
+ for (const p of collectGraphEntryInputPaths(args.graphEntry)) {
51
+ if (p === 'input' || p.startsWith('input.'))
52
+ paths.add(p);
53
+ }
54
+ for (const p of [...args.smartInputPaths, ...args.inputSynthesisPaths]) {
55
+ if (p === 'input' || p.startsWith('input.'))
56
+ paths.add(p);
57
+ }
58
+ return [...paths];
59
+ }
60
+ function synthesisWatchPaths(smartInputPaths, inputSynthesisPaths) {
61
+ const paths = new Set();
62
+ for (const p of [...smartInputPaths, ...inputSynthesisPaths]) {
63
+ const trimmed = p.trim();
64
+ if (trimmed === 'xynthesized.job' || trimmed.startsWith('xynthesized.job.')) {
65
+ paths.add(trimmed === 'xynthesized.job' ? 'xynthesized.job' : trimmed);
66
+ }
67
+ if (trimmed === 'xynthesized.execution' || trimmed.startsWith('xynthesized.execution.')) {
68
+ paths.add(trimmed === 'xynthesized.execution' ? 'xynthesized.execution' : trimmed);
69
+ }
70
+ }
71
+ return [...paths];
72
+ }
73
+ function pathRequiresDeclaredEntry(path, graphEntry) {
74
+ if (graphEntry == null)
75
+ return false;
76
+ const declared = collectGraphEntryInputPaths(graphEntry);
77
+ if (declared.length > 0)
78
+ return true;
79
+ return (graphEntry.inputs?.length ?? 0) > 0 || (graphEntry.requiredExecutionPaths?.length ?? 0) > 0;
80
+ }
81
+ /**
82
+ * Evaluates MAIN-readiness before invoking the skill. Paths resolve via {@link resolveGraphEngineMemoryPathValue}
83
+ * (`input.*` and `inputs.*` are distinct roots). Policy `off` skips all checks.
84
+ */
85
+ export function evaluateTaskNodeMainReadiness(args) {
86
+ const policy = args.policy ?? 'off';
87
+ const smartInputPaths = args.smartInputPaths ?? collectSmartInputPaths(args.node);
88
+ const inputSynthesisPaths = args.inputSynthesisPaths ?? collectInputSynthesisSourcePaths(args.node);
89
+ const failedChecks = [];
90
+ const warnings = [];
91
+ const pathsByCheck = {};
92
+ if (policy === 'off') {
93
+ return { policy, ok: true, failedChecks, warnings, pathsByCheck };
94
+ }
95
+ const inputPaths = executionInputWatchPaths({
96
+ graphEntry: args.graphEntry,
97
+ smartInputPaths,
98
+ inputSynthesisPaths,
99
+ });
100
+ const emptyInputPaths = [];
101
+ const graphEntryDeclaresInputs = pathRequiresDeclaredEntry('input', args.graphEntry);
102
+ if (graphEntryDeclaresInputs || inputPaths.length > 0) {
103
+ const toCheck = inputPaths.length > 0
104
+ ? inputPaths
105
+ : collectGraphEntryInputPaths(args.graphEntry).filter((p) => p === 'input' || p.startsWith('input.'));
106
+ for (const path of toCheck) {
107
+ const value = resolveGraphEngineMemoryPathValue(args.resolutionRoot, path);
108
+ if (isEmptyReadinessValue(value))
109
+ emptyInputPaths.push(path);
110
+ }
111
+ if (emptyInputPaths.length > 0) {
112
+ pathsByCheck.execution_input_empty = emptyInputPaths;
113
+ if (policy === 'fail')
114
+ failedChecks.push('execution_input_empty');
115
+ else
116
+ warnings.push('execution_input_empty');
117
+ }
118
+ }
119
+ const synthPaths = synthesisWatchPaths(smartInputPaths, inputSynthesisPaths);
120
+ const emptySynthPaths = [];
121
+ for (const path of synthPaths) {
122
+ const value = resolveGraphEngineMemoryPathValue(args.resolutionRoot, path);
123
+ if (isEmptyReadinessValue(value))
124
+ emptySynthPaths.push(path);
125
+ }
126
+ if (emptySynthPaths.length > 0) {
127
+ pathsByCheck.synthesis_context_empty = emptySynthPaths;
128
+ if (policy === 'fail')
129
+ failedChecks.push('synthesis_context_empty');
130
+ else
131
+ warnings.push('synthesis_context_empty');
132
+ }
133
+ return {
134
+ policy,
135
+ ok: failedChecks.length === 0,
136
+ failedChecks,
137
+ warnings,
138
+ pathsByCheck,
139
+ };
140
+ }
141
+ export function buildMainReadinessResolutionRoot(args) {
142
+ return buildMemoryResolutionRootFromExecution({
143
+ execution: args.executionMemory,
144
+ input: args.taskInput,
145
+ inputs: args.callerInputs,
146
+ jobMemory: args.jobMemory,
147
+ taskMemory: args.taskMemory,
148
+ xynthesized: args.xynthesized,
149
+ });
150
+ }
151
+ export function resolveMainReadinessPolicy(args) {
152
+ const nodePolicy = args.nodeTaskConfiguration?.mainReadinessPolicy;
153
+ if (nodePolicy === 'fail' || nodePolicy === 'warn' || nodePolicy === 'off')
154
+ return nodePolicy;
155
+ const rt = args.runtimePolicy;
156
+ if (rt === 'fail' || rt === 'warn' || rt === 'off')
157
+ return rt;
158
+ return 'off';
159
+ }
160
+ /** Normalizes a smart-input path entry to a memory root key (for inspection helpers). */
161
+ export function smartInputPathRoot(path) {
162
+ const { root } = splitGraphEngineMemoryPath(path.trim());
163
+ return root ?? undefined;
164
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Graph-level preflight for `@exellix/ai-tasks` validation and analysis on task nodes.
3
+ * Builds the same outbound {@link RunTaskRequest} as `executeNode` (without PRE strategy phases or `runTask`).
4
+ */
5
+ import type { Catalox } from '@x12i/catalox';
6
+ import type { RunTaskRequest } from '@exellix/ai-tasks';
7
+ import { type AnalyzeRunTaskRequestOptions, type AnalyzeRunTaskRequestResult, type RunTaskInvokeValidationResult, type RunTaskValidationResult, type ValidateRunTaskInvokeParams } from '@exellix/ai-tasks';
8
+ import type { GraphAiModelConfig, Job, TaskNode } from '../types/refs.js';
9
+ import type { ExecutionStepOption, RunTaskDiagnostics, SkillKeyResolutionOptions } from '../types/options.js';
10
+ export type TaskNodeRunTaskPreflightSkipReason = 'local_skill' | 'finalizer';
11
+ export type BuildTaskNodeRunTaskRequestResult = {
12
+ runnable: true;
13
+ skillKey: string;
14
+ request: RunTaskRequest;
15
+ } | {
16
+ runnable: false;
17
+ skillKey: string;
18
+ reason: TaskNodeRunTaskPreflightSkipReason;
19
+ };
20
+ export type BuildTaskNodeRunTaskRequestArgs = {
21
+ graphId: string;
22
+ node: TaskNode;
23
+ job: Job;
24
+ execution?: Record<string, unknown>;
25
+ jobMemory?: unknown;
26
+ taskMemory?: unknown;
27
+ taskVariables?: Record<string, unknown>;
28
+ prevNodeId?: string;
29
+ /** Same UUID used for every `runTask` in one `executeGraph` invocation. */
30
+ graphRunTaskId?: string;
31
+ /** Host job id on `job.jobId` / `job.id`; defaults from `job` when omitted. */
32
+ runTaskJobId?: string;
33
+ modelConfig?: GraphAiModelConfig;
34
+ llmCall?: Record<string, unknown>;
35
+ /** Runtime default merged with per-node `taskConfiguration.llmCall`. */
36
+ runtimeLlmCall?: Record<string, unknown>;
37
+ runTaskIdentity?: Record<string, unknown>;
38
+ runTaskExecutionMode?: 'default' | 'trace';
39
+ runTaskDiagnostics?: RunTaskDiagnostics;
40
+ jobKnowledgePatch?: Record<string, unknown>;
41
+ taskKnowledgePatch?: Record<string, unknown>;
42
+ graphExecutionPipeline?: ExecutionStepOption[];
43
+ skillKeyResolution?: SkillKeyResolutionOptions;
44
+ clearSynthesizedContextPerNode?: boolean;
45
+ };
46
+ /**
47
+ * Materialize the outbound `RunTaskRequest` graph-engine would send for a task node
48
+ * (mirrors `executeNode` request assembly; does not run PRE strategy phases or `runTask`).
49
+ */
50
+ export declare function buildTaskNodeRunTaskRequest(args: BuildTaskNodeRunTaskRequestArgs): BuildTaskNodeRunTaskRequestResult;
51
+ export type ValidateTaskNodeRunTaskConfigArgs = BuildTaskNodeRunTaskRequestArgs;
52
+ export type ValidateTaskNodeRunTaskConfigResult = {
53
+ skipped: true;
54
+ skillKey: string;
55
+ reason: TaskNodeRunTaskPreflightSkipReason;
56
+ } | ({
57
+ skipped: false;
58
+ skillKey: string;
59
+ request: RunTaskRequest;
60
+ } & RunTaskValidationResult);
61
+ /** Static ai-tasks validation on the graph-built {@link RunTaskRequest}. */
62
+ export declare function validateTaskNodeRunTaskConfig(args: ValidateTaskNodeRunTaskConfigArgs): ValidateTaskNodeRunTaskConfigResult;
63
+ export type ValidateTaskNodeRunTaskInvokeArgs = BuildTaskNodeRunTaskRequestArgs & Omit<ValidateRunTaskInvokeParams, 'request'>;
64
+ export type ValidateTaskNodeRunTaskInvokeResult = {
65
+ skipped: true;
66
+ skillKey: string;
67
+ reason: TaskNodeRunTaskPreflightSkipReason;
68
+ } | ({
69
+ skipped: false;
70
+ skillKey: string;
71
+ request: RunTaskRequest;
72
+ } & RunTaskInvokeValidationResult);
73
+ /** Config + payload + template path validation via ai-tasks {@link validateRunTaskInvoke}. */
74
+ export declare function validateTaskNodeRunTaskInvoke(args: ValidateTaskNodeRunTaskInvokeArgs): Promise<ValidateTaskNodeRunTaskInvokeResult>;
75
+ export type AnalyzeTaskNodeRunTaskRequestArgs = BuildTaskNodeRunTaskRequestArgs & {
76
+ catalox: Catalox;
77
+ analyzeOptions?: AnalyzeRunTaskRequestOptions;
78
+ };
79
+ export type AnalyzeTaskNodeRunTaskRequestResult = {
80
+ skipped: true;
81
+ skillKey: string;
82
+ reason: TaskNodeRunTaskPreflightSkipReason;
83
+ } | ({
84
+ skipped: false;
85
+ skillKey: string;
86
+ request: RunTaskRequest;
87
+ } & AnalyzeRunTaskRequestResult);
88
+ /** Catalox-backed skill request analysis on the graph-built {@link RunTaskRequest}. */
89
+ export declare function analyzeTaskNodeRunTaskRequest(args: AnalyzeTaskNodeRunTaskRequestArgs): Promise<AnalyzeTaskNodeRunTaskRequestResult>;