@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,480 @@
1
+ /**
2
+ * Playground reporter: collects execution steps and in-memory debug artifacts
3
+ * for full visibility (graph start, plan rounds, node request/response/outputMapping, graph end).
4
+ *
5
+ * Each reporter instance corresponds to ONE graph execution.
6
+ * It never writes to the filesystem; callers can inspect artifacts via getArtifacts/getDebugSnapshot.
7
+ */
8
+ const MAX_JSON_EXCERPT = 500;
9
+ function safeKeys(obj) {
10
+ if (obj == null || typeof obj !== 'object')
11
+ return [];
12
+ return Object.keys(obj);
13
+ }
14
+ function jsonExcerpt(obj, maxLen = MAX_JSON_EXCERPT) {
15
+ try {
16
+ const s = JSON.stringify(obj, null, 2);
17
+ if (s.length <= maxLen)
18
+ return s;
19
+ return s.slice(0, maxLen) + '...';
20
+ }
21
+ catch {
22
+ return String(obj);
23
+ }
24
+ }
25
+ export function createPlaygroundReporter(options = {}) {
26
+ const { runId } = options;
27
+ const steps = [];
28
+ const artifacts = [];
29
+ /** Next 1-based step number to assign (single execution, single counter). */
30
+ let nextStep = 0;
31
+ /** nodeId -> assigned 1-based step number. */
32
+ const nodeStepIndex = new Map();
33
+ const artifactId = (stepNumber, nodeId, kind) => {
34
+ const prefix = stepNumber != null ? `${String(stepNumber).padStart(2, '0')}-` : '';
35
+ return `${prefix}${nodeId}-${kind}`;
36
+ };
37
+ const recordArtifact = (artifact) => {
38
+ const existingIndex = artifacts.findIndex((a) => a.artifactId === artifact.artifactId);
39
+ if (existingIndex >= 0) {
40
+ artifacts[existingIndex] = artifact;
41
+ }
42
+ else {
43
+ artifacts.push(artifact);
44
+ }
45
+ };
46
+ const step = (name, data) => {
47
+ const ts = Date.now();
48
+ steps.push({ name, data, ts });
49
+ if (!data)
50
+ return;
51
+ const nodeId = data.nodeId != null ? String(data.nodeId) : undefined;
52
+ if (!nodeId)
53
+ return;
54
+ if (name === 'node:request' && data.fullRequest !== undefined) {
55
+ nextStep += 1;
56
+ const stepNumber = nextStep;
57
+ nodeStepIndex.set(nodeId, stepNumber);
58
+ recordArtifact({
59
+ artifactId: artifactId(stepNumber, nodeId, 'request'),
60
+ kind: 'request',
61
+ nodeId,
62
+ stepNumber,
63
+ payload: data.fullRequest,
64
+ ts,
65
+ });
66
+ }
67
+ else if (name === 'node:response') {
68
+ const stepNumber = nodeStepIndex.get(nodeId);
69
+ const executionPart = data.execution !== undefined ? { execution: data.execution } : {};
70
+ const responsePayload = data.fullOutput !== undefined
71
+ ? { success: data.success !== false, output: data.fullOutput, ...executionPart }
72
+ : { success: data.success === true, error: data.errorMessage ?? data.error, ...executionPart };
73
+ recordArtifact({
74
+ artifactId: artifactId(stepNumber, nodeId, 'response'),
75
+ kind: 'response',
76
+ nodeId,
77
+ stepNumber,
78
+ payload: responsePayload,
79
+ ts,
80
+ });
81
+ }
82
+ else if (name === 'node:fail' && data.errorMessage != null) {
83
+ const stepNumber = nodeStepIndex.get(nodeId);
84
+ recordArtifact({
85
+ artifactId: artifactId(stepNumber, nodeId, 'response'),
86
+ kind: 'response',
87
+ nodeId,
88
+ stepNumber,
89
+ payload: {
90
+ success: false,
91
+ error: { message: data.errorMessage, code: data.errorCode },
92
+ ...(data.execution !== undefined ? { execution: data.execution } : {}),
93
+ },
94
+ ts,
95
+ });
96
+ }
97
+ };
98
+ const getMarkdown = () => {
99
+ const lines = [];
100
+ lines.push('# Execution report');
101
+ lines.push('');
102
+ const startTs = steps[0]?.ts ?? Date.now();
103
+ const endTs = steps.length > 0 ? steps[steps.length - 1].ts : Date.now();
104
+ lines.push(`**Generated:** ${new Date().toISOString()} | **Duration:** ${endTs - startTs} ms`);
105
+ if (runId) {
106
+ lines.push(`**Run ID:** \`${runId}\``);
107
+ }
108
+ if (artifacts.length > 0) {
109
+ lines.push(`**Debug artifacts:** ${artifacts.length} full request/response payload(s) retained in memory via \`getArtifacts()\` / \`getDebugSnapshot()\`.`);
110
+ }
111
+ if (runId || artifacts.length > 0) {
112
+ lines.push('');
113
+ }
114
+ /** Step numbers for artifact ids: computed from execution order (node:request order). */
115
+ let nextStepRender = 0;
116
+ const nodeStepIndexRender = new Map();
117
+ let i = 0;
118
+ while (i < steps.length) {
119
+ const s = steps[i];
120
+ if (s.name === 'graph:start') {
121
+ lines.push('---');
122
+ lines.push('## Graph start');
123
+ lines.push('');
124
+ if (s.data?.jobId != null)
125
+ lines.push(`- **Job ID:** ${s.data.jobId}`);
126
+ if (s.data?.graphId != null)
127
+ lines.push(`- **Graph ID:** ${s.data.graphId}`);
128
+ if (s.data?.aiTasksPackageVersion != null) {
129
+ lines.push(`- **@exellix/ai-tasks version:** \`${s.data.aiTasksPackageVersion}\``);
130
+ }
131
+ if (s.data?.exellixGraphPackageVersion != null) {
132
+ lines.push(`- **@exellix/graph-engine version:** \`${s.data.exellixGraphPackageVersion}\``);
133
+ }
134
+ if (s.data?.executionKeys != null)
135
+ lines.push(`- **Execution keys:** \`${s.data.executionKeys.join('`, `')}\``);
136
+ if (s.data?.variablesKeys != null)
137
+ lines.push(`- **Variables keys:** \`${s.data.variablesKeys.join('`, `')}\``);
138
+ if (s.data?.executionExcerpt != null) {
139
+ lines.push('- **Execution (excerpt):**');
140
+ lines.push('```json');
141
+ lines.push(String(s.data.executionExcerpt));
142
+ lines.push('```');
143
+ }
144
+ lines.push('');
145
+ i++;
146
+ continue;
147
+ }
148
+ if (s.name === 'graph:observability') {
149
+ lines.push('### Runtime observability (`runtimeObjects`)');
150
+ lines.push('');
151
+ const d = s.data;
152
+ if (d?.lastJobId != null)
153
+ lines.push(`- **lastJobId:** \`${d.lastJobId}\``);
154
+ lines.push(`- **Graph-level Activix client:** ${d?.graphActivix ? 'yes' : 'no'}`);
155
+ lines.push(`- **Graph-level Logxer client:** ${d?.graphLogxer ? 'yes' : 'no'}`);
156
+ if (d?.packages?.length) {
157
+ lines.push('- **Packages:**');
158
+ for (const p of d.packages) {
159
+ lines.push(` - \`${p.name}\`: activix=${p.activix}, logxer=${p.logxer}`);
160
+ }
161
+ }
162
+ lines.push('');
163
+ i++;
164
+ continue;
165
+ }
166
+ if (s.name === 'plan') {
167
+ lines.push('### Plan round');
168
+ lines.push('');
169
+ if (s.data?.round != null)
170
+ lines.push(`- **Round:** ${s.data.round}`);
171
+ if (s.data?.status != null)
172
+ lines.push(`- **Status:** ${s.data.status}`);
173
+ if (s.data?.runnableNodeIds != null) {
174
+ const ids = s.data.runnableNodeIds;
175
+ lines.push(`- **Runnable nodes:** ${ids.length ? ids.join(', ') : '(none)'}`);
176
+ }
177
+ lines.push('');
178
+ i++;
179
+ continue;
180
+ }
181
+ if (s.name === 'node:start') {
182
+ lines.push(`### Node: ${s.data?.nodeId ?? '?'}`);
183
+ lines.push('');
184
+ if (s.data?.skillKey != null)
185
+ lines.push(`- **Skill key:** \`${s.data.skillKey}\``);
186
+ if (s.data?.executionKeys != null)
187
+ lines.push(`- **Execution keys (in):** \`${s.data.executionKeys.join('`, `')}\``);
188
+ lines.push('');
189
+ i++;
190
+ continue;
191
+ }
192
+ if (s.name === 'node:request') {
193
+ lines.push('- **Request:**');
194
+ if (s.data?.skillKey != null)
195
+ lines.push(` - skillKey: \`${s.data.skillKey}\``);
196
+ if (s.data?.executionMemoryKeys != null)
197
+ lines.push(` - executionMemory keys: \`${s.data.executionMemoryKeys.join('`, `')}\``);
198
+ if (s.data?.synthesisEnabled != null)
199
+ lines.push(` - synthesis enabled: ${s.data.synthesisEnabled}`);
200
+ if (s.data?.playgroundPhase != null)
201
+ lines.push(` - trace phase: \`${s.data.playgroundPhase}\``);
202
+ if (s.data?.synthesizedContextInMemoryBeforeTask != null) {
203
+ lines.push(` - **before runTask:** synthesizedContext already in executionMemory: ${s.data.synthesizedContextInMemoryBeforeTask}`);
204
+ }
205
+ if (s.data?.synthesizedContextCleared === true) {
206
+ lines.push(` - **synthesizedContext cleared before task** (\`clearSynthesizedContextPerNode=true\`): upstream artifact stripped; PRE will run fresh`);
207
+ }
208
+ if (s.data?.preRanFresh != null) {
209
+ lines.push(` - **preRanFresh:** ${s.data.preRanFresh}`);
210
+ }
211
+ if (s.data?.mainContextBeforeRunTask != null) {
212
+ lines.push(` - **before runTask (MAIN context):** ${s.data.mainContextBeforeRunTask}`);
213
+ }
214
+ if (s.data?.synthesizedContextInMemoryBeforeTask == null &&
215
+ s.data?.synthesizedContextPresent != null) {
216
+ lines.push(` - synthesizedContext present (legacy): ${s.data.synthesizedContextPresent}`);
217
+ }
218
+ if (s.data?.mainContextBeforeRunTask == null && s.data?.mainContextSource != null) {
219
+ lines.push(` - main context source (legacy): \`${s.data.mainContextSource}\``);
220
+ }
221
+ if (s.data?.effectiveExecutionPipeline != null) {
222
+ lines.push(` - effective pipeline: \`${JSON.stringify(s.data.effectiveExecutionPipeline)}\``);
223
+ }
224
+ if (s.data?.nodeId != null && s.data.fullRequest !== undefined) {
225
+ const n = String(s.data.nodeId);
226
+ nextStepRender += 1;
227
+ const stepNum = nextStepRender;
228
+ nodeStepIndexRender.set(n, stepNum);
229
+ lines.push(` - **Full request artifact:** \`${artifactId(stepNum, n, 'request')}\``);
230
+ }
231
+ lines.push('');
232
+ i++;
233
+ continue;
234
+ }
235
+ if (s.name === 'node:response') {
236
+ lines.push('- **Response:**');
237
+ if (s.data?.success != null)
238
+ lines.push(` - success: ${s.data.success}`);
239
+ if (s.data?.outputKeys != null)
240
+ lines.push(` - output keys: \`${s.data.outputKeys.join('`, `')}\``);
241
+ if (s.data?.synthesisEnabled != null)
242
+ lines.push(` - synthesis enabled: ${s.data.synthesisEnabled}`);
243
+ if (s.data?.playgroundPhase != null)
244
+ lines.push(` - trace phase: \`${s.data.playgroundPhase}\``);
245
+ if (s.data?.synthesizedContextInMemoryAfterTask != null) {
246
+ lines.push(` - **after runTask:** synthesizedContext in executionMemory: ${s.data.synthesizedContextInMemoryAfterTask}`);
247
+ }
248
+ if (s.data?.inferredMainContextForMainStep != null) {
249
+ lines.push(` - **after runTask:** inferred MAIN input source: \`${s.data.inferredMainContextForMainStep}\` (from executionMemory shape; see ai-tasks metadata for authoritative MAIN routing)`);
250
+ }
251
+ if (s.data?.synthesizedContextInMemoryAfterTask == null &&
252
+ s.data?.synthesizedContextPresent != null) {
253
+ lines.push(` - synthesizedContext present (legacy): ${s.data.synthesizedContextPresent}`);
254
+ }
255
+ if (s.data?.inferredMainContextForMainStep == null && s.data?.mainContextSource != null) {
256
+ lines.push(` - main context source (legacy): \`${s.data.mainContextSource}\``);
257
+ }
258
+ if (s.data?.effectiveExecutionPipeline != null) {
259
+ lines.push(` - effective pipeline: \`${JSON.stringify(s.data.effectiveExecutionPipeline)}\``);
260
+ }
261
+ if (s.data?.synthesizedContextCleared === true) {
262
+ lines.push(` - **synthesizedContext cleared before task** (\`clearSynthesizedContextPerNode=true\`): PRE ran fresh`);
263
+ }
264
+ if (s.data?.preRanFresh != null) {
265
+ lines.push(` - **preRanFresh:** ${s.data.preRanFresh}`);
266
+ }
267
+ if (s.data?.aiTasksObservability != null && typeof s.data.aiTasksObservability === 'object') {
268
+ const obs = s.data.aiTasksObservability;
269
+ const cores = obs.detectedTemplateCores;
270
+ const coresEmpty = Array.isArray(cores) && cores.length === 0;
271
+ const synthEnabled = obs.synthesisEnabled === true;
272
+ lines.push(' - **ai-tasks observability (metadata):**');
273
+ if (synthEnabled && coresEmpty) {
274
+ lines.push(' > ⚠ `detectedTemplateCores` is empty — template-core detection did not fire. Structured synthesis anchors may be missing from the skill template.');
275
+ }
276
+ lines.push(' ```json');
277
+ String(JSON.stringify(s.data.aiTasksObservability, null, 2))
278
+ .split('\n')
279
+ .forEach((l) => lines.push(' ' + l));
280
+ lines.push(' ```');
281
+ }
282
+ if (s.data?.outputExcerpt != null) {
283
+ lines.push(' - output (excerpt):');
284
+ lines.push(' ```json');
285
+ String(s.data.outputExcerpt).split('\n').forEach((l) => lines.push(' ' + l));
286
+ lines.push(' ```');
287
+ }
288
+ if (s.data?.errorMessage != null)
289
+ lines.push(` - error: ${s.data.errorMessage}`);
290
+ const execution = s.data?.execution;
291
+ const webContext = execution != null && typeof execution === 'object'
292
+ ? execution.webContext
293
+ : undefined;
294
+ if (webContext != null && typeof webContext === 'object') {
295
+ const available = webContext.available;
296
+ if (typeof available === 'boolean') {
297
+ lines.push(' - **Web scoping:**');
298
+ lines.push(` - available: ${available}`);
299
+ if (available === true) {
300
+ const ctx = webContext.context;
301
+ const findings = ctx?.findings;
302
+ const findingsArr = Array.isArray(findings) ? findings : [];
303
+ lines.push(` - findings: ${findingsArr.length}`);
304
+ // Small, capped URL sample for readability.
305
+ const urls = [];
306
+ for (const f of findingsArr.slice(0, 3)) {
307
+ const sources = f?.sources;
308
+ if (!Array.isArray(sources))
309
+ continue;
310
+ for (const src of sources.slice(0, 3)) {
311
+ const url = src?.url;
312
+ if (typeof url === 'string' && url.length > 0)
313
+ urls.push(url);
314
+ if (urls.length >= 6)
315
+ break;
316
+ }
317
+ if (urls.length >= 6)
318
+ break;
319
+ }
320
+ if (urls.length > 0) {
321
+ lines.push(' - source URLs (sample):');
322
+ urls.forEach((u) => lines.push(` - ${u}`));
323
+ }
324
+ }
325
+ else {
326
+ const reason = webContext.reason;
327
+ if (typeof reason === 'string' && reason.length > 0) {
328
+ lines.push(` - reason: ${reason}`);
329
+ }
330
+ }
331
+ }
332
+ }
333
+ if (s.data?.nodeId != null) {
334
+ const n = String(s.data.nodeId);
335
+ const stepNum = nodeStepIndexRender.get(n);
336
+ lines.push(` - **Full response artifact:** \`${artifactId(stepNum, n, 'response')}\``);
337
+ }
338
+ if (s.data?.intermediateSteps != null && Array.isArray(s.data.intermediateSteps) && s.data.intermediateSteps.length > 0) {
339
+ lines.push(' - **Intermediate steps (combined task):**');
340
+ s.data.intermediateSteps.forEach((step, idx) => {
341
+ const id = step.id ?? step.step ?? idx + 1;
342
+ const summary = step.summary != null ? ` — ${String(step.summary)}` : '';
343
+ const ok = step.ok !== false ? 'ok' : 'fail';
344
+ lines.push(` - ${idx + 1}. ${id}${summary} — ${ok}`);
345
+ });
346
+ }
347
+ lines.push('');
348
+ i++;
349
+ continue;
350
+ }
351
+ if (s.name === 'node:outputMapping') {
352
+ lines.push('- **Output mapping:**');
353
+ if (s.data?.path != null)
354
+ lines.push(` - path: \`${s.data.path}\``);
355
+ if (s.data?.mode != null)
356
+ lines.push(` - mode: ${s.data.mode}`);
357
+ if (s.data?.executionKeysAfter != null)
358
+ lines.push(` - execution keys after: \`${s.data.executionKeysAfter.join('`, `')}\``);
359
+ lines.push('');
360
+ i++;
361
+ continue;
362
+ }
363
+ if (s.name === 'node:complete') {
364
+ lines.push('- **Result:** complete');
365
+ if (s.data?.executionKeys != null)
366
+ lines.push(` - execution keys: \`${s.data.executionKeys.join('`, `')}\``);
367
+ lines.push('');
368
+ i++;
369
+ continue;
370
+ }
371
+ if (s.name === 'node:fail') {
372
+ lines.push('- **Result:** fail');
373
+ if (s.data?.errorMessage != null)
374
+ lines.push(` - error: ${s.data.errorMessage}`);
375
+ if (s.data?.errorCode != null)
376
+ lines.push(` - code: ${s.data.errorCode}`);
377
+ const execution = s.data?.execution;
378
+ const webContext = execution != null && typeof execution === 'object'
379
+ ? execution.webContext
380
+ : undefined;
381
+ if (webContext != null && typeof webContext === 'object') {
382
+ const available = webContext.available;
383
+ if (typeof available === 'boolean') {
384
+ lines.push(' - **Web scoping:**');
385
+ lines.push(` - available: ${available}`);
386
+ if (available === false) {
387
+ const reason = webContext.reason;
388
+ if (typeof reason === 'string' && reason.length > 0) {
389
+ lines.push(` - reason: ${reason}`);
390
+ }
391
+ }
392
+ else {
393
+ const ctx = webContext.context;
394
+ const findings = ctx?.findings;
395
+ const findingsArr = Array.isArray(findings) ? findings : [];
396
+ lines.push(` - findings: ${findingsArr.length}`);
397
+ }
398
+ }
399
+ }
400
+ lines.push('');
401
+ i++;
402
+ continue;
403
+ }
404
+ if (s.name === 'graph:complete') {
405
+ lines.push('## Graph complete');
406
+ lines.push('');
407
+ if (s.data?.nodesExecuted != null)
408
+ lines.push(`- **Nodes executed:** ${s.data.nodesExecuted}`);
409
+ if (s.data?.executionKeys != null)
410
+ lines.push(`- **Final execution keys:** \`${s.data.executionKeys.join('`, `')}\``);
411
+ lines.push('');
412
+ i++;
413
+ continue;
414
+ }
415
+ if (s.name === 'graph:fail') {
416
+ lines.push('## Graph fail');
417
+ lines.push('');
418
+ if (s.data?.errorMessage != null)
419
+ lines.push(`- **Error:** ${s.data.errorMessage}`);
420
+ if (s.data?.errorCode != null)
421
+ lines.push(`- **Code:** ${s.data.errorCode}`);
422
+ if (s.data?.executionKeys != null)
423
+ lines.push(`- **Execution keys at fail:** \`${s.data.executionKeys.join('`, `')}\``);
424
+ lines.push('');
425
+ i++;
426
+ continue;
427
+ }
428
+ if (s.name === 'ai-activities') {
429
+ lines.push('---');
430
+ lines.push('## AI activities');
431
+ lines.push('');
432
+ if (s.data?.activities != null && Array.isArray(s.data.activities) && s.data.activities.length > 0) {
433
+ const activities = s.data.activities;
434
+ activities.forEach((a, idx) => {
435
+ lines.push(`- **${idx + 1}.** ${a.nodeId ?? a.activityId ?? '?'}${a.activityId != null ? ` (activityId: \`${a.activityId}\`)` : ''}`);
436
+ });
437
+ lines.push('');
438
+ }
439
+ else {
440
+ lines.push('*Not collected for this run. AI activities are recorded when `ActivityTrackerIntegration` is used with `executeGraph` (eventEmitter). Query MongoDB collection `cognitive-activities` by `jobId`/`graphId` to see them.*');
441
+ lines.push('');
442
+ }
443
+ i++;
444
+ continue;
445
+ }
446
+ lines.push(`### ${s.name}`);
447
+ if (s.data && Object.keys(s.data).length > 0) {
448
+ lines.push('```json');
449
+ lines.push(jsonExcerpt(s.data));
450
+ lines.push('```');
451
+ lines.push('');
452
+ }
453
+ i++;
454
+ }
455
+ // Always append AI activities section (empty unless step('ai-activities', { activities }) was used)
456
+ const hasAiActivitiesStep = steps.some((st) => st.name === 'ai-activities');
457
+ if (!hasAiActivitiesStep) {
458
+ lines.push('---');
459
+ lines.push('## AI activities');
460
+ lines.push('');
461
+ lines.push('*Not collected for this run. AI activities are recorded when `ActivityTrackerIntegration` is used with `executeGraph` (eventEmitter). Query MongoDB collection `cognitive-activities` by `jobId`/`graphId` to see them.*');
462
+ lines.push('');
463
+ }
464
+ return lines.join('\n');
465
+ };
466
+ const getSteps = () => steps.map((s) => ({ ...s }));
467
+ const getArtifacts = () => artifacts.map((a) => ({ ...a }));
468
+ const getDebugSnapshot = () => {
469
+ const snapshot = {
470
+ steps: getSteps(),
471
+ artifacts: getArtifacts(),
472
+ markdown: getMarkdown(),
473
+ };
474
+ if (runId !== undefined) {
475
+ snapshot.runId = runId;
476
+ }
477
+ return snapshot;
478
+ };
479
+ return { step, getSteps, getArtifacts, getDebugSnapshot, getMarkdown };
480
+ }
@@ -0,0 +1 @@
1
+ export { createPlaygroundReporter, type CreatePlaygroundReporterOptions, type PlaygroundDebugArtifact, type PlaygroundDebugArtifactKind, type PlaygroundDebugSnapshot, type PlaygroundReporter, type PlaygroundStep, } from './PlaygroundReporter.js';
@@ -0,0 +1 @@
1
+ export { createPlaygroundReporter, } from './PlaygroundReporter.js';