@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,33 @@
1
+ /**
2
+ * Graph engine interface for planning and execution state management
3
+ */
4
+ export type PlanStatus = "continue" | "completed" | "blocked" | "waiting";
5
+ export interface GraphPlan<NodeT = any> {
6
+ status: PlanStatus;
7
+ nextNodes: NodeT[];
8
+ details?: any;
9
+ }
10
+ export interface GraphEngine<NodeT = any> {
11
+ plan(): GraphPlan<NodeT>;
12
+ /**
13
+ * Commit results of a node execution back to the engine.
14
+ * The engine decides what it means (store output, mark done, update vars, etc.)
15
+ */
16
+ commit(input: {
17
+ nodeId: string;
18
+ output?: any;
19
+ error?: any;
20
+ meta?: Record<string, any>;
21
+ }): void;
22
+ snapshot(): any;
23
+ }
24
+ export interface GraphEngineFactory {
25
+ create(input: {
26
+ graph: any;
27
+ mode?: "forward" | "backward" | "hybrid";
28
+ goalNodeId?: string;
29
+ dimension?: string;
30
+ initialState?: any;
31
+ initialVariables?: Record<string, any>;
32
+ }): GraphEngine;
33
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Graph engine interface for planning and execution state management
3
+ */
4
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { RunTaskRequest, RunTaskResponse } from '../types/options.js';
2
+ /**
3
+ * Stable ai-tasks observability for graph-engine results: versioned digest from `@exellix/ai-tasks`
4
+ * plus selected metadata fields not duplicated in the digest.
5
+ */
6
+ export declare function buildAiTasksObservabilityRecord(response: RunTaskResponse, request?: RunTaskRequest): Record<string, unknown>;
@@ -0,0 +1,37 @@
1
+ import { extractAiTasksObservabilityFromRunTaskResponse } from '@exellix/ai-tasks';
2
+ import { resolveCanonicalModelUsed } from './canonicalModelUsed.js';
3
+ /** Metadata keys kept alongside {@link extractAiTasksObservabilityFromRunTaskResponse} digest for consoles / trace. */
4
+ const METADATA_EXTRAS = [
5
+ 'activityId',
6
+ 'durationMs',
7
+ 'instructionVersion',
8
+ 'localSkillKey',
9
+ 'synthesisContextAuthoritative',
10
+ ];
11
+ /**
12
+ * Stable ai-tasks observability for graph-engine results: versioned digest from `@exellix/ai-tasks`
13
+ * plus selected metadata fields not duplicated in the digest.
14
+ */
15
+ export function buildAiTasksObservabilityRecord(response, request) {
16
+ const digest = extractAiTasksObservabilityFromRunTaskResponse(response, request);
17
+ const out = { ...digest };
18
+ const modelUsed = resolveCanonicalModelUsed(response);
19
+ if (modelUsed != null)
20
+ out.modelUsed = modelUsed;
21
+ const r = response;
22
+ const meta = r.metadata ?? r.meta;
23
+ if (meta != null && typeof meta === 'object' && !Array.isArray(meta)) {
24
+ const m = meta;
25
+ for (const k of METADATA_EXTRAS) {
26
+ if (m[k] !== undefined)
27
+ out[k] = m[k];
28
+ }
29
+ if (modelUsed != null) {
30
+ out.metadata = { ...m, modelUsed };
31
+ }
32
+ }
33
+ else if (modelUsed != null) {
34
+ out.metadata = { modelUsed };
35
+ }
36
+ return out;
37
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Engine-level PRE/POST **utility** calls via `@exellix/ai-tasks` `runTask` only (no direct Xynthesis SDK usage).
3
+ * Triggered by `taskConfiguration.aiTaskProfile.preStrategyKey` / `postStrategyKey`.
4
+ * Distinct from `executionPipeline` PRE `synthesized-context`, which runs inside the MAIN node’s single ai-tasks `runTask`.
5
+ * Parsed outcomes are merged under **`execution.xynthesis.pre` / `execution.xynthesis.post`** (historical slot names on execution memory).
6
+ */
7
+ import type { RunTaskRequest } from '@exellix/ai-tasks';
8
+ import type { GraphAiModelConfig, Job } from '../types/refs.js';
9
+ import type { RunTaskResponse, TasksClientLike } from './ExellixGraphRuntime.js';
10
+ export type EngineStrategyPhase = 'pre' | 'post';
11
+ export type RunEngineAiTasksStrategyPhaseArgs = {
12
+ phase: EngineStrategyPhase;
13
+ strategySkillKey: string;
14
+ /** Main node skill key (telemetry / payload only). */
15
+ parentSkillKey: string;
16
+ aiTasks: TasksClientLike;
17
+ job?: Job;
18
+ nodeId: string;
19
+ graphId?: string;
20
+ taskId: string;
21
+ runTaskJobId: string;
22
+ execution: Record<string, unknown>;
23
+ variables?: Record<string, unknown>;
24
+ jobMemory?: unknown;
25
+ taskMemory?: unknown;
26
+ jobContext?: Record<string, unknown>;
27
+ prevNodeId?: string;
28
+ modelConfig?: GraphAiModelConfig;
29
+ llmCall?: RunTaskRequest['llmCall'];
30
+ runTaskIdentity?: Record<string, unknown>;
31
+ /** Task node `taskConfiguration` (identity envelope merge). */
32
+ nodeTaskConfiguration?: Record<string, unknown>;
33
+ forwardRunTaskTrace: boolean;
34
+ runTaskDiagnostics?: RunTaskRequest['diagnostics'];
35
+ nodeTimeoutMs?: number;
36
+ };
37
+ export declare function runEngineAiTasksStrategyPhase(args: RunEngineAiTasksStrategyPhaseArgs): Promise<{
38
+ ok: true;
39
+ } | {
40
+ ok: false;
41
+ response: RunTaskResponse;
42
+ }>;
43
+ export declare function getAiTaskProfileStrategyKeys(taskConfiguration: Record<string, unknown> | undefined): {
44
+ preStrategyKey?: string;
45
+ postStrategyKey?: string;
46
+ };
@@ -0,0 +1,93 @@
1
+ import { buildAiTasksRunTaskRequest } from './buildAiTasksRunTaskRequest.js';
2
+ import { buildRunTaskIdentityEnvelope } from './runTaskAugments.js';
3
+ import { runTaskResponseSucceeded } from './runTaskResponse.js';
4
+ import { withTimeout } from './withTimeout.js';
5
+ function nonEmptyStrategyKey(v) {
6
+ return typeof v === 'string' && v.trim().length > 0;
7
+ }
8
+ function mergeStrategyPhaseSlot(execution, phase, payload) {
9
+ const prev = execution.xynthesis;
10
+ const base = prev != null && typeof prev === 'object' && !Array.isArray(prev)
11
+ ? { ...prev }
12
+ : {};
13
+ base[phase] = payload;
14
+ execution.xynthesis = base;
15
+ }
16
+ export async function runEngineAiTasksStrategyPhase(args) {
17
+ const identity = buildRunTaskIdentityEnvelope({
18
+ base: args.runTaskIdentity,
19
+ graphId: args.graphId,
20
+ nodeId: args.nodeId,
21
+ taskId: args.taskId,
22
+ jobId: args.runTaskJobId,
23
+ nodeMeta: {
24
+ ...(args.nodeTaskConfiguration ?? {}),
25
+ /** Historical identity keys (telemetry); graph-engine does not import Xynthesis. */
26
+ xynthesisEnginePhase: args.phase,
27
+ xynthesisParentSkillKey: args.parentSkillKey,
28
+ },
29
+ });
30
+ const taskTypeIdOverride = args.phase === 'pre'
31
+ ? `exellix-graph-xynthesis-pre:${args.parentSkillKey}`
32
+ : `exellix-graph-xynthesis-post:${args.parentSkillKey}`;
33
+ const req = buildAiTasksRunTaskRequest({
34
+ skillKey: args.strategySkillKey,
35
+ job: args.job,
36
+ nodeId: args.nodeId,
37
+ taskConfiguration: undefined,
38
+ graphId: args.graphId,
39
+ taskId: args.taskId,
40
+ runTaskJobId: args.runTaskJobId,
41
+ taskInput: {
42
+ phase: `exellix-graph-${args.phase}-strategy`,
43
+ parentSkillKey: args.parentSkillKey,
44
+ nodeId: args.nodeId,
45
+ graphId: args.graphId,
46
+ executionMemory: { ...args.execution },
47
+ },
48
+ variables: args.variables,
49
+ jobMemory: args.jobMemory,
50
+ taskMemory: args.taskMemory,
51
+ executionMemory: args.execution,
52
+ jobContext: args.jobContext,
53
+ prevNodeId: args.prevNodeId,
54
+ executionPipeline: [{ phase: 'main', type: 'direct' }],
55
+ executionStrategies: [],
56
+ modelConfig: args.modelConfig,
57
+ llmCall: args.llmCall ?? undefined,
58
+ identity,
59
+ ...(args.forwardRunTaskTrace ? { executionMode: 'trace' } : {}),
60
+ ...(args.runTaskDiagnostics != null && { diagnostics: args.runTaskDiagnostics }),
61
+ taskKind: 'utility',
62
+ taskTypeIdOverride,
63
+ });
64
+ const run = () => args.aiTasks.runTask(req);
65
+ const response = await (args.nodeTimeoutMs
66
+ ? withTimeout(run(), args.nodeTimeoutMs, () => {
67
+ const err = new Error(`Engine ${args.phase} strategy runTask timed out after ${args.nodeTimeoutMs}ms (nodeId=${args.nodeId}, skillKey=${args.strategySkillKey})`);
68
+ err.code = 'NODE_TIMEOUT';
69
+ err.nodeId = args.nodeId;
70
+ return err;
71
+ })
72
+ : run());
73
+ if (!runTaskResponseSucceeded(response)) {
74
+ return { ok: false, response };
75
+ }
76
+ const out = response.parsed ??
77
+ response.output ??
78
+ response.executionMemory ??
79
+ null;
80
+ mergeStrategyPhaseSlot(args.execution, args.phase, out);
81
+ return { ok: true };
82
+ }
83
+ export function getAiTaskProfileStrategyKeys(taskConfiguration) {
84
+ const profile = taskConfiguration?.aiTaskProfile;
85
+ if (profile == null || typeof profile !== 'object' || Array.isArray(profile))
86
+ return {};
87
+ const pre = profile.preStrategyKey;
88
+ const post = profile.postStrategyKey;
89
+ return {
90
+ ...(nonEmptyStrategyKey(pre) ? { preStrategyKey: pre.trim() } : {}),
91
+ ...(nonEmptyStrategyKey(post) ? { postStrategyKey: post.trim() } : {}),
92
+ };
93
+ }
@@ -0,0 +1,17 @@
1
+ import type { AiTaskProfileMetadata } from '../types/aiTaskProfile.js';
2
+ import type { NarrixPreProcessorConfig, ResolvedNarrixWirePayload, WebScopeQuestion } from '../types/narrix.js';
3
+ /**
4
+ * Maps graph-composer `string[]` web questions to narrix-web-scoper object shape.
5
+ * Synthetic ids are stable per index for a given node run.
6
+ */
7
+ export declare function mapAiTaskProfileQuestionsToWebScopeQuestions(questions: string[]): WebScopeQuestion[];
8
+ /**
9
+ * Returns the resolved outbound `RunTaskRequest.narrix` payload.
10
+ *
11
+ * Authoring contract (5.x): `taskConfiguration.narrix` only carries the discovery fields on
12
+ * {@link NarrixPreProcessorConfig} (`datasetId`, `layer`, `narrativeTypeIds`, `questionId`).
13
+ * Web-scope fields (`enableWebScope`, `webScopeQuestions`, ...) are produced here from
14
+ * `taskConfiguration.aiTaskProfile.webScoping` and merged onto the wire payload — they are not
15
+ * authored on `taskConfiguration.narrix`.
16
+ */
17
+ export declare function applyAiTaskProfileWebScopingToNarrix(narrix: NarrixPreProcessorConfig | undefined, aiTaskProfile: AiTaskProfileMetadata | undefined): ResolvedNarrixWirePayload | undefined;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Maps graph-composer `string[]` web questions to narrix-web-scoper object shape.
3
+ * Synthetic ids are stable per index for a given node run.
4
+ */
5
+ export function mapAiTaskProfileQuestionsToWebScopeQuestions(questions) {
6
+ const out = [];
7
+ let i = 0;
8
+ for (const q of questions) {
9
+ const t = typeof q === 'string' ? q.trim() : '';
10
+ if (!t)
11
+ continue;
12
+ out.push({ id: `aiTaskProfile-q-${i}`, question: t });
13
+ i += 1;
14
+ }
15
+ return out;
16
+ }
17
+ function webScopingFromProfileIsActive(profile) {
18
+ if (profile?.webScoping?.enabled !== true)
19
+ return false;
20
+ const qs = profile.webScoping.questions;
21
+ if (!Array.isArray(qs) || qs.length === 0)
22
+ return false;
23
+ return mapAiTaskProfileQuestionsToWebScopeQuestions(qs).length > 0;
24
+ }
25
+ /**
26
+ * Returns the resolved outbound `RunTaskRequest.narrix` payload.
27
+ *
28
+ * Authoring contract (5.x): `taskConfiguration.narrix` only carries the discovery fields on
29
+ * {@link NarrixPreProcessorConfig} (`datasetId`, `layer`, `narrativeTypeIds`, `questionId`).
30
+ * Web-scope fields (`enableWebScope`, `webScopeQuestions`, ...) are produced here from
31
+ * `taskConfiguration.aiTaskProfile.webScoping` and merged onto the wire payload — they are not
32
+ * authored on `taskConfiguration.narrix`.
33
+ */
34
+ export function applyAiTaskProfileWebScopingToNarrix(narrix, aiTaskProfile) {
35
+ const base = narrix != null ? { ...narrix } : undefined;
36
+ if (!webScopingFromProfileIsActive(aiTaskProfile)) {
37
+ return base;
38
+ }
39
+ const mapped = mapAiTaskProfileQuestionsToWebScopeQuestions(aiTaskProfile.webScoping.questions);
40
+ const wire = (base ?? {});
41
+ return {
42
+ ...wire,
43
+ enableWebScope: true,
44
+ webScopeQuestions: mapped,
45
+ };
46
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Builds an `@exellix/ai-tasks` v7 {@link RunTaskRequest}: canonical `input` bucket, required
3
+ * correlation ids (`jobTypeId`, `taskTypeId`), and graph telemetry (`graphId`, `nodeId`, `coreSkillId`).
4
+ *
5
+ * See `node_modules/@exellix/ai-tasks/RUNTASK_REQUEST.md` for merge rules (ai-tasks merges `jobContext`,
6
+ * `variables`, and `input` — do not pre-merge `input` into `variables` in graph-engine).
7
+ * v7 closed schema: no root `executionType`, `outputConstraints`, `question`, or `jobInput`.
8
+ * Graph-engine forwards optional `inputs` (caller bag, as-is) separately from `input` (MAIN as-is + node bindings) — see `.docs/CR-input-and-inputs-dual-root.md`.
9
+ */
10
+ import type { LlmCallConfig, RunTaskRequest } from '@exellix/ai-tasks';
11
+ import type { SmartInputConfig, XynthesizedMemory } from '../types/aiTasksDerivedTypes.js';
12
+ import type { GraphAiModelConfig, Job } from '../types/refs.js';
13
+ import type { ExecutionStepOption } from '../types/options.js';
14
+ import type { ResolvedNarrixWirePayload } from '../types/narrix.js';
15
+ /** Reads task-node `taskConfiguration` keys forwarded to `@exellix/ai-tasks` `RunTaskRequest` (runtime strategy / Narrix wiring). */
16
+ export declare function extractRunTaskStrategyOverrides(taskConfiguration: Record<string, unknown> | undefined | null): Partial<Pick<BuildAiTasksRunTaskRequestArgs, 'narrixMode' | 'inputStrategyKey' | 'narrixInput'>>;
17
+ /** Optional `RunTaskRequest` fields commonly authored on task-node `taskConfiguration` (whitelist — closed merge order). */
18
+ export type RunTaskMetadataPassthrough = Partial<Pick<RunTaskRequest, 'narrixScope' | 'aiScoping' | 'aiScopingOptions' | 'timeoutMs' | 'templateRenderOptions' | 'smartInputRenderOptions' | 'templateTokens' | 'aiEngineId' | 'sessionId' | 'agentType' | 'gatewayDiagnostics' | 'context' | 'knowledge' | 'executionStrategyCatalogItems'>>;
19
+ /**
20
+ * Whitelisted optional transport fields from task-node `taskConfiguration` for `@exellix/ai-tasks` ≥ 7.2.x
21
+ * (`RunSkillRequest` / `RunTaskRequest` extras not covered by {@link extractRunTaskStrategyOverrides}).
22
+ */
23
+ export declare function extractRunTaskMetadataPassthrough(taskConfiguration: Record<string, unknown> | undefined | null): RunTaskMetadataPassthrough;
24
+ export type BuildAiTasksRunTaskRequestArgs = {
25
+ skillKey: string;
26
+ job?: Job;
27
+ /** Graph task node id — used for `nodeId`, `coreSkillId`, and default `taskTypeId`. */
28
+ nodeId: string;
29
+ taskConfiguration?: Record<string, unknown>;
30
+ graphId?: string;
31
+ taskId: string;
32
+ runTaskJobId: string;
33
+ /** Canonical ai-tasks task payload (`input`). */
34
+ taskInput: Record<string, unknown>;
35
+ /** Caller / graph-entry bag (`inputs`); forwarded when non-empty for dual-root smart-input resolution. */
36
+ callerInputs?: Record<string, unknown>;
37
+ variables?: Record<string, unknown>;
38
+ jobMemory?: unknown;
39
+ taskMemory?: unknown;
40
+ executionMemory?: Record<string, unknown>;
41
+ jobContext?: Record<string, unknown>;
42
+ prevNodeId?: string;
43
+ executionPipeline?: ExecutionStepOption[];
44
+ includeContextInPrompt?: boolean;
45
+ narrix?: ResolvedNarrixWirePayload;
46
+ outputValidation?: RunTaskRequest['outputValidation'];
47
+ diagnostics?: RunTaskRequest['diagnostics'];
48
+ modelConfig?: GraphAiModelConfig;
49
+ llmCall?: LlmCallConfig;
50
+ identity?: Record<string, unknown>;
51
+ executionMode?: 'default' | 'trace';
52
+ taskKind?: RunTaskRequest['taskKind'];
53
+ autoValidateDecisionOutput?: boolean;
54
+ /** Overrides default `resolveTaskTypeId(skillKey, nodeId, taskConfiguration)` e.g. engine strategy phases. */
55
+ taskTypeIdOverride?: string;
56
+ /** Usually from `taskConfiguration.narrixMode` via {@link extractRunTaskStrategyOverrides}. */
57
+ narrixMode?: RunTaskRequest['narrixMode'];
58
+ inputStrategyKey?: RunTaskRequest['inputStrategyKey'];
59
+ narrixInput?: RunTaskRequest['narrixInput'];
60
+ /** Required on every request for ai-tasks ≥ 7.1.x — use `[]` for plain MAIN. */
61
+ executionStrategies?: RunTaskRequest['executionStrategies'];
62
+ xynthesized?: XynthesizedMemory;
63
+ smartInput?: SmartInputConfig;
64
+ };
65
+ export declare function resolveJobTypeId(job?: Job): string;
66
+ export declare function resolveTaskTypeId(skillKey: string, nodeId: string, taskConfiguration?: Record<string, unknown>): string;
67
+ export declare function buildAiTasksRunTaskRequest(args: BuildAiTasksRunTaskRequestArgs): RunTaskRequest;
@@ -0,0 +1,164 @@
1
+ import { buildRunTaskTaskConfigurationForward } from './buildRunTaskTaskConfigurationForward.js';
2
+ import { normalizeSmartInputConfigForRunTask } from './smartInputPaths.js';
3
+ /** Reads task-node `taskConfiguration` keys forwarded to `@exellix/ai-tasks` `RunTaskRequest` (runtime strategy / Narrix wiring). */
4
+ export function extractRunTaskStrategyOverrides(taskConfiguration) {
5
+ if (taskConfiguration == null || typeof taskConfiguration !== 'object' || Array.isArray(taskConfiguration))
6
+ return {};
7
+ const m = taskConfiguration;
8
+ const out = {};
9
+ const narrixMode = m.narrixMode;
10
+ if (typeof narrixMode === 'string' && narrixMode.trim() !== '') {
11
+ out.narrixMode = narrixMode.trim();
12
+ }
13
+ const inputStrategyKey = m.inputStrategyKey;
14
+ if (typeof inputStrategyKey === 'string' && inputStrategyKey.trim() !== '') {
15
+ out.inputStrategyKey = inputStrategyKey.trim();
16
+ }
17
+ const narrixInput = m.narrixInput;
18
+ if (narrixInput != null && typeof narrixInput === 'object' && !Array.isArray(narrixInput)) {
19
+ out.narrixInput = narrixInput;
20
+ }
21
+ return out;
22
+ }
23
+ /**
24
+ * Whitelisted optional transport fields from task-node `taskConfiguration` for `@exellix/ai-tasks` ≥ 7.2.x
25
+ * (`RunSkillRequest` / `RunTaskRequest` extras not covered by {@link extractRunTaskStrategyOverrides}).
26
+ */
27
+ export function extractRunTaskMetadataPassthrough(taskConfiguration) {
28
+ if (taskConfiguration == null || typeof taskConfiguration !== 'object' || Array.isArray(taskConfiguration))
29
+ return {};
30
+ const m = taskConfiguration;
31
+ const out = {};
32
+ const narrixScope = m.narrixScope;
33
+ if (narrixScope != null && typeof narrixScope === 'object' && !Array.isArray(narrixScope)) {
34
+ out.narrixScope = narrixScope;
35
+ }
36
+ const aiScoping = m.aiScoping;
37
+ if (Array.isArray(aiScoping)) {
38
+ out.aiScoping = aiScoping;
39
+ }
40
+ const aiScopingOptions = m.aiScopingOptions;
41
+ if (aiScopingOptions != null && typeof aiScopingOptions === 'object' && !Array.isArray(aiScopingOptions)) {
42
+ out.aiScopingOptions = aiScopingOptions;
43
+ }
44
+ const timeoutMs = m.timeoutMs;
45
+ if (typeof timeoutMs === 'number' && Number.isFinite(timeoutMs)) {
46
+ out.timeoutMs = timeoutMs;
47
+ }
48
+ const templateRenderOptions = m.templateRenderOptions;
49
+ if (templateRenderOptions != null && typeof templateRenderOptions === 'object' && !Array.isArray(templateRenderOptions)) {
50
+ out.templateRenderOptions = templateRenderOptions;
51
+ }
52
+ const smartInputRenderOptions = m.smartInputRenderOptions;
53
+ if (smartInputRenderOptions != null &&
54
+ typeof smartInputRenderOptions === 'object' &&
55
+ !Array.isArray(smartInputRenderOptions)) {
56
+ out.smartInputRenderOptions = smartInputRenderOptions;
57
+ }
58
+ const templateTokens = m.templateTokens;
59
+ if (templateTokens != null && typeof templateTokens === 'object' && !Array.isArray(templateTokens)) {
60
+ out.templateTokens = templateTokens;
61
+ }
62
+ const aiEngineId = m.aiEngineId;
63
+ if (typeof aiEngineId === 'string' && aiEngineId.trim() !== '') {
64
+ out.aiEngineId = aiEngineId.trim();
65
+ }
66
+ const sessionId = m.sessionId;
67
+ if (typeof sessionId === 'string' && sessionId.trim() !== '') {
68
+ out.sessionId = sessionId.trim();
69
+ }
70
+ const agentType = m.agentType;
71
+ if (agentType === 'chat' ||
72
+ agentType === 'ai-reasoner' ||
73
+ agentType === 'ai-auditor' ||
74
+ agentType === 'ai-scoper' ||
75
+ agentType === 'ai-discovery' ||
76
+ agentType === 'ai-planner' ||
77
+ agentType === 'ai-executor') {
78
+ out.agentType = agentType;
79
+ }
80
+ const gatewayDiagnostics = m.gatewayDiagnostics;
81
+ if (gatewayDiagnostics != null && typeof gatewayDiagnostics === 'object' && !Array.isArray(gatewayDiagnostics)) {
82
+ out.gatewayDiagnostics = gatewayDiagnostics;
83
+ }
84
+ if (m.context !== undefined) {
85
+ out.context = m.context;
86
+ }
87
+ if (m.knowledge !== undefined) {
88
+ out.knowledge = m.knowledge;
89
+ }
90
+ const executionStrategyCatalogItems = m.executionStrategyCatalogItems;
91
+ if (Array.isArray(executionStrategyCatalogItems)) {
92
+ out.executionStrategyCatalogItems = executionStrategyCatalogItems;
93
+ }
94
+ return out;
95
+ }
96
+ export function resolveJobTypeId(job) {
97
+ const j = job;
98
+ const raw = j?.jobType ?? j?.jobTypeId;
99
+ return typeof raw === 'string' && raw.trim() !== '' ? raw.trim() : 'exellix-graph-job';
100
+ }
101
+ export function resolveTaskTypeId(skillKey, nodeId, taskConfiguration) {
102
+ const raw = taskConfiguration?.taskTypeId;
103
+ if (typeof raw === 'string' && raw.trim() !== '')
104
+ return raw.trim();
105
+ return skillKey;
106
+ }
107
+ export function buildAiTasksRunTaskRequest(args) {
108
+ const agentId = typeof args.job?.agentId === 'string' && args.job.agentId.trim() !== ''
109
+ ? args.job.agentId.trim()
110
+ : 'standalone-agent';
111
+ const jobTypeId = resolveJobTypeId(args.job);
112
+ const taskTypeId = args.taskTypeIdOverride ??
113
+ resolveTaskTypeId(args.skillKey, args.nodeId, args.taskConfiguration);
114
+ const masterSkillActivityId = `${args.runTaskJobId}:${args.nodeId}`;
115
+ const executionStrategies = args.executionStrategies ?? [];
116
+ const metaPassthrough = extractRunTaskMetadataPassthrough(args.taskConfiguration);
117
+ const taskConfigurationForward = buildRunTaskTaskConfigurationForward(args.taskConfiguration);
118
+ const smartInputForward = normalizeSmartInputConfigForRunTask(args.smartInput);
119
+ const req = {
120
+ ...metaPassthrough,
121
+ skillKey: args.skillKey,
122
+ jobId: args.runTaskJobId,
123
+ taskId: args.taskId,
124
+ agentId,
125
+ jobTypeId,
126
+ taskTypeId,
127
+ coreSkillId: args.nodeId,
128
+ nodeId: args.nodeId,
129
+ ...(args.graphId != null && args.graphId !== '' ? { graphId: args.graphId } : {}),
130
+ masterSkillId: args.graphId,
131
+ masterSkillActivityId,
132
+ input: { ...args.taskInput },
133
+ ...(args.callerInputs != null && Object.keys(args.callerInputs).length > 0
134
+ ? { inputs: { ...args.callerInputs } }
135
+ : {}),
136
+ ...(args.variables != null && typeof args.variables === 'object' && !Array.isArray(args.variables)
137
+ ? { variables: args.variables }
138
+ : {}),
139
+ ...(args.jobMemory !== undefined ? { jobMemory: args.jobMemory } : {}),
140
+ ...(args.taskMemory !== undefined ? { taskMemory: args.taskMemory } : {}),
141
+ ...(args.executionMemory != null ? { executionMemory: args.executionMemory } : {}),
142
+ ...(args.jobContext != null ? { jobContext: args.jobContext } : {}),
143
+ ...(args.prevNodeId != null && args.prevNodeId !== '' ? { prevNodeId: args.prevNodeId } : {}),
144
+ ...(args.executionPipeline != null ? { executionPipeline: args.executionPipeline } : {}),
145
+ ...(args.includeContextInPrompt === true ? { includeContextInPrompt: true } : {}),
146
+ ...(args.narrix != null ? { narrix: args.narrix } : {}),
147
+ ...(args.outputValidation != null ? { outputValidation: args.outputValidation } : {}),
148
+ ...(args.diagnostics != null ? { diagnostics: args.diagnostics } : {}),
149
+ ...(args.modelConfig != null ? { modelConfig: args.modelConfig } : {}),
150
+ ...(args.llmCall != null ? { llmCall: args.llmCall } : {}),
151
+ ...(args.identity != null ? { identity: args.identity } : {}),
152
+ ...(args.executionMode != null ? { executionMode: args.executionMode } : {}),
153
+ ...(args.taskKind != null ? { taskKind: args.taskKind } : {}),
154
+ ...(args.autoValidateDecisionOutput !== undefined ? { autoValidateDecisionOutput: args.autoValidateDecisionOutput } : {}),
155
+ ...(args.narrixMode != null ? { narrixMode: args.narrixMode } : {}),
156
+ ...(args.inputStrategyKey != null ? { inputStrategyKey: args.inputStrategyKey } : {}),
157
+ ...(args.narrixInput != null ? { narrixInput: args.narrixInput } : {}),
158
+ executionStrategies,
159
+ ...(args.xynthesized != null ? { xynthesized: args.xynthesized } : {}),
160
+ ...(smartInputForward != null ? { smartInput: smartInputForward } : {}),
161
+ ...(taskConfigurationForward != null ? { taskConfiguration: taskConfigurationForward } : {}),
162
+ };
163
+ return req;
164
+ }
@@ -0,0 +1,27 @@
1
+ import type { RunLogEntry, RunLogBuildOptions, RunLogBuildResult } from '../types/runLog.js';
2
+ /** Truncate `data` for HTTP/console payloads; returns replacement suitable for `RunLogEntry.data`. */
3
+ export declare function truncateRunLogData(data: unknown, maxJsonChars: number): unknown;
4
+ /** Normalize @exellix/ai-tasks epoch-ms or ISO `ts` to epoch ms for exellix-graph `RunLogEntry`. */
5
+ export declare function parseRunLogEntryTs(v: unknown): number;
6
+ /** Normalize entries from ai-tasks metadata (best-effort). */
7
+ export declare function normalizeExternalRunLogEntries(raw: unknown): RunLogEntry[];
8
+ export declare function extractTaskRunLogFromMetadata(metadata: unknown): RunLogEntry[];
9
+ export declare function extractLogxerCorrelationFromMetadata(metadata: unknown): string | undefined;
10
+ /**
11
+ * Build merged `runLog` for a completed graph run from execution trace + optional per-task lines.
12
+ */
13
+ export declare function buildRunLog(opts: RunLogBuildOptions): RunLogBuildResult;
14
+ export declare function resolveRunLogLimits(input: {
15
+ runLogMode?: import('../types/runLog.js').RunLogMode;
16
+ maxRunLogEntries?: number;
17
+ maxRunLogDataJsonChars?: number;
18
+ defaults?: {
19
+ runLogMode?: import('../types/runLog.js').RunLogMode;
20
+ maxRunLogEntries?: number;
21
+ maxRunLogDataJsonChars?: number;
22
+ };
23
+ }): {
24
+ mode: import('../types/runLog.js').RunLogMode;
25
+ maxEntries: number;
26
+ maxDataJsonChars: number;
27
+ };