@exellix/ai-tasks 9.1.0 → 10.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 (252) hide show
  1. package/CHANGELOG.md +34 -4
  2. package/README.md +2 -2
  3. package/RUNTASK_REQUEST.md +32 -17
  4. package/dist/builders/task-request-builder.d.ts.map +1 -1
  5. package/dist/builders/task-request-builder.js +2 -1
  6. package/dist/builders/task-request-builder.js.map +1 -1
  7. package/dist/compile/compileTaskConfiguration.d.ts.map +1 -1
  8. package/dist/compile/compileTaskConfiguration.js +3 -0
  9. package/dist/compile/compileTaskConfiguration.js.map +1 -1
  10. package/dist/core/task-sdk.d.ts.map +1 -1
  11. package/dist/core/task-sdk.js +148 -180
  12. package/dist/core/task-sdk.js.map +1 -1
  13. package/dist/errors/runTaskExecutionError.d.ts.map +1 -1
  14. package/dist/errors/runTaskExecutionError.js +0 -2
  15. package/dist/errors/runTaskExecutionError.js.map +1 -1
  16. package/dist/index.d.ts +0 -4
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +0 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/invocation/types.d.ts +1 -1
  21. package/dist/narrix/applyWebScopeToRequest.d.ts +9 -0
  22. package/dist/narrix/applyWebScopeToRequest.d.ts.map +1 -0
  23. package/dist/narrix/applyWebScopeToRequest.js +156 -0
  24. package/dist/narrix/applyWebScopeToRequest.js.map +1 -0
  25. package/dist/narrix/narrixUnitExecution.d.ts.map +1 -1
  26. package/dist/narrix/narrixUnitExecution.js +8 -3
  27. package/dist/narrix/narrixUnitExecution.js.map +1 -1
  28. package/dist/node-execution/buildRequestFromNodePlan.d.ts +6 -0
  29. package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
  30. package/dist/node-execution/buildRequestFromNodePlan.js +4 -16
  31. package/dist/node-execution/buildRequestFromNodePlan.js.map +1 -1
  32. package/dist/node-execution/compileProfessionalAnswerRequest.d.ts +2 -0
  33. package/dist/node-execution/compileProfessionalAnswerRequest.d.ts.map +1 -0
  34. package/dist/node-execution/compileProfessionalAnswerRequest.js +4 -0
  35. package/dist/node-execution/compileProfessionalAnswerRequest.js.map +1 -0
  36. package/dist/node-execution/createNodeExecutionHost.d.ts.map +1 -1
  37. package/dist/node-execution/createNodeExecutionHost.js +97 -26
  38. package/dist/node-execution/createNodeExecutionHost.js.map +1 -1
  39. package/dist/node-execution/dispatchExecutionUnit.d.ts.map +1 -1
  40. package/dist/node-execution/dispatchExecutionUnit.js +4 -2
  41. package/dist/node-execution/dispatchExecutionUnit.js.map +1 -1
  42. package/dist/node-execution/orchestration/runPostOrchestration.d.ts +11 -0
  43. package/dist/node-execution/orchestration/runPostOrchestration.d.ts.map +1 -0
  44. package/dist/node-execution/orchestration/runPostOrchestration.js +123 -0
  45. package/dist/node-execution/orchestration/runPostOrchestration.js.map +1 -0
  46. package/dist/node-execution/orchestration/runPreOrchestration.d.ts +3 -0
  47. package/dist/node-execution/orchestration/runPreOrchestration.d.ts.map +1 -0
  48. package/dist/node-execution/orchestration/runPreOrchestration.js +110 -0
  49. package/dist/node-execution/orchestration/runPreOrchestration.js.map +1 -0
  50. package/dist/node-execution/orchestration/shardContext.d.ts +12 -0
  51. package/dist/node-execution/orchestration/shardContext.d.ts.map +1 -0
  52. package/dist/node-execution/orchestration/shardContext.js +71 -0
  53. package/dist/node-execution/orchestration/shardContext.js.map +1 -0
  54. package/dist/node-execution/orchestration/types.d.ts +21 -0
  55. package/dist/node-execution/orchestration/types.d.ts.map +1 -0
  56. package/dist/node-execution/orchestration/types.js +2 -0
  57. package/dist/node-execution/orchestration/types.js.map +1 -0
  58. package/dist/node-execution/rejectForbiddenWireFields.d.ts +2 -0
  59. package/dist/node-execution/rejectForbiddenWireFields.d.ts.map +1 -1
  60. package/dist/node-execution/rejectForbiddenWireFields.js +42 -7
  61. package/dist/node-execution/rejectForbiddenWireFields.js.map +1 -1
  62. package/dist/observability/classifyRunTaskFailure.d.ts.map +1 -1
  63. package/dist/observability/classifyRunTaskFailure.js +4 -3
  64. package/dist/observability/classifyRunTaskFailure.js.map +1 -1
  65. package/dist/observability/logRunTaskFailure.d.ts.map +1 -1
  66. package/dist/observability/logRunTaskFailure.js +0 -2
  67. package/dist/observability/logRunTaskFailure.js.map +1 -1
  68. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts +19 -3
  69. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts.map +1 -1
  70. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js +7 -1
  71. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js.map +1 -1
  72. package/dist/post-steps/audit/loadAuditTemplates.d.ts +2 -55
  73. package/dist/post-steps/audit/loadAuditTemplates.d.ts.map +1 -1
  74. package/dist/post-steps/audit/loadAuditTemplates.js +3 -38
  75. package/dist/post-steps/audit/loadAuditTemplates.js.map +1 -1
  76. package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts +8 -0
  77. package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts.map +1 -0
  78. package/dist/post-steps/audit/parseAuditFuncxOutput.js +62 -0
  79. package/dist/post-steps/audit/parseAuditFuncxOutput.js.map +1 -0
  80. package/dist/post-steps/audit/parseAuditOutput.d.ts +2 -0
  81. package/dist/post-steps/audit/parseAuditOutput.d.ts.map +1 -1
  82. package/dist/post-steps/audit/parseAuditOutput.js +56 -0
  83. package/dist/post-steps/audit/parseAuditOutput.js.map +1 -1
  84. package/dist/post-steps/audit/runAudit.d.ts.map +1 -1
  85. package/dist/post-steps/audit/runAudit.js +53 -113
  86. package/dist/post-steps/audit/runAudit.js.map +1 -1
  87. package/dist/post-steps/audit/runAuditFuncxCall.d.ts +18 -0
  88. package/dist/post-steps/audit/runAuditFuncxCall.d.ts.map +1 -0
  89. package/dist/post-steps/audit/runAuditFuncxCall.js +59 -0
  90. package/dist/post-steps/audit/runAuditFuncxCall.js.map +1 -0
  91. package/dist/synthesis/resolveSourceMaterial.d.ts.map +1 -1
  92. package/dist/synthesis/resolveSourceMaterial.js +14 -0
  93. package/dist/synthesis/resolveSourceMaterial.js.map +1 -1
  94. package/dist/synthesis/runStructuredSynthesisRobust.d.ts.map +1 -1
  95. package/dist/synthesis/runStructuredSynthesisRobust.js +24 -4
  96. package/dist/synthesis/runStructuredSynthesisRobust.js.map +1 -1
  97. package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.d.ts +3 -0
  98. package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.d.ts.map +1 -1
  99. package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.js +28 -4
  100. package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.js.map +1 -1
  101. package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts +4 -4
  102. package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts.map +1 -1
  103. package/dist/task-strategies/canonicalInputExecutionStrategies.js +2 -1
  104. package/dist/task-strategies/canonicalInputExecutionStrategies.js.map +1 -1
  105. package/dist/task-strategies/canonicalOrchestrationStrategies.d.ts +42 -0
  106. package/dist/task-strategies/canonicalOrchestrationStrategies.d.ts.map +1 -0
  107. package/dist/task-strategies/canonicalOrchestrationStrategies.js +47 -0
  108. package/dist/task-strategies/canonicalOrchestrationStrategies.js.map +1 -0
  109. package/dist/task-strategies/canonicalTaskStrategies.d.ts +2 -1
  110. package/dist/task-strategies/canonicalTaskStrategies.d.ts.map +1 -1
  111. package/dist/task-strategies/canonicalTaskStrategies.js +2 -1
  112. package/dist/task-strategies/canonicalTaskStrategies.js.map +1 -1
  113. package/dist/task-strategies/constants.d.ts +9 -1
  114. package/dist/task-strategies/constants.d.ts.map +1 -1
  115. package/dist/task-strategies/constants.js +9 -1
  116. package/dist/task-strategies/constants.js.map +1 -1
  117. package/dist/task-strategies/index.d.ts +5 -3
  118. package/dist/task-strategies/index.d.ts.map +1 -1
  119. package/dist/task-strategies/index.js +4 -3
  120. package/dist/task-strategies/index.js.map +1 -1
  121. package/dist/task-strategies/listAiTaskStrategies.d.ts +10 -1
  122. package/dist/task-strategies/listAiTaskStrategies.d.ts.map +1 -1
  123. package/dist/task-strategies/listAiTaskStrategies.js +17 -2
  124. package/dist/task-strategies/listAiTaskStrategies.js.map +1 -1
  125. package/dist/types/task-types.d.ts +4 -11
  126. package/dist/types/task-types.d.ts.map +1 -1
  127. package/dist/utils/bridgeRunSkillGatewayMemory.d.ts.map +1 -1
  128. package/dist/utils/bridgeRunSkillGatewayMemory.js +1 -0
  129. package/dist/utils/bridgeRunSkillGatewayMemory.js.map +1 -1
  130. package/dist/utils/executionMemoryInputRecord.d.ts +12 -0
  131. package/dist/utils/executionMemoryInputRecord.d.ts.map +1 -0
  132. package/dist/utils/executionMemoryInputRecord.js +28 -0
  133. package/dist/utils/executionMemoryInputRecord.js.map +1 -0
  134. package/dist/utils/resolveAiProfileModel.d.ts +1 -1
  135. package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
  136. package/dist/utils/resolveRunTaskModelReferences.d.ts.map +1 -1
  137. package/dist/utils/resolveRunTaskModelReferences.js +0 -32
  138. package/dist/utils/resolveRunTaskModelReferences.js.map +1 -1
  139. package/dist/utils/runTaskRequestShape.d.ts.map +1 -1
  140. package/dist/utils/runTaskRequestShape.js +4 -26
  141. package/dist/utils/runTaskRequestShape.js.map +1 -1
  142. package/dist/utils/skillTemplateVariables.d.ts +3 -2
  143. package/dist/utils/skillTemplateVariables.d.ts.map +1 -1
  144. package/dist/utils/skillTemplateVariables.js +3 -2
  145. package/dist/utils/skillTemplateVariables.js.map +1 -1
  146. package/dist/validation/validateProfessionalAnswerContract.d.ts +8 -0
  147. package/dist/validation/validateProfessionalAnswerContract.d.ts.map +1 -0
  148. package/dist/validation/validateProfessionalAnswerContract.js +45 -0
  149. package/dist/validation/validateProfessionalAnswerContract.js.map +1 -0
  150. package/dist/validation/validateRunTaskConfig.d.ts.map +1 -1
  151. package/dist/validation/validateRunTaskConfig.js +3 -66
  152. package/dist/validation/validateRunTaskConfig.js.map +1 -1
  153. package/documenations/record-and-template-variables.md +21 -13
  154. package/documenations/run-task-execution-flow.md +1 -1
  155. package/documenations/skill-orchestration-strategy-cr-fr.md +147 -0
  156. package/documenations/upstream-feature-requests/README.md +9 -5
  157. package/documenations/upstream-feature-requests/ai-skills-orchestrator-invoke-contract-5.9.md +1 -1
  158. package/documenations/upstream-feature-requests/funcx-4.9.13-open-items.md +62 -0
  159. package/documenations/upstream-feature-requests/funcx-gap-analysis-cr-fr.md +401 -0
  160. package/documenations/upstream-feature-requests/funcx-pre-post-sidekick-actions.md +1 -0
  161. package/documenations/upstream-feature-requests/graph-engine-runtask-contract-alignment-investigation.md +370 -0
  162. package/documenations/upstream-feature-requests/xynthesis-ai-profiles-2.1-import-break.md +2 -2
  163. package/documenations/upstream-feature-requests/xynthesis-openrouter-wire-model-double-prefix-bug.md +1 -1
  164. package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +1 -1
  165. package/package.json +10 -9
  166. package/.docs/DOWNSTREAM_ENV.md +0 -42
  167. package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +0 -64
  168. package/.docs/INTERMEDIATE_STEPS.md +0 -82
  169. package/.docs/activity-structure.md +0 -31
  170. package/.docs/ai-task-ai-scoping-spec.md +0 -338
  171. package/.docs/ai-tasks-model-profile-aliases-7x.md +0 -96
  172. package/.docs/blockers-and-issues.md +0 -346
  173. package/.docs/building-runTask-sdk.md +0 -659
  174. package/.docs/building-skill-execution-orchestrator.md +0 -968
  175. package/.docs/code-used-before/run-task.txt +0 -39
  176. package/.docs/code-used-before/task-executor.ts.old +0 -57
  177. package/.docs/code-used-before/test-run-task.ts.old +0 -42
  178. package/.docs/code-used-before/types.txt +0 -23
  179. package/.docs/env-ready-policy.md +0 -40
  180. package/.docs/flow-io/flow-README.md +0 -76
  181. package/.docs/flow-io/narrix.md +0 -124
  182. package/.docs/flow-io/web-scoping.md +0 -135
  183. package/.docs/flow-io/xynthesis-post.md +0 -154
  184. package/.docs/flow-io/xynthesis-pre.md +0 -181
  185. package/.docs/gap-analysis.md +0 -201
  186. package/.docs/integration-facts-ai-tasks.md +0 -109
  187. package/.docs/investigation/ai-skills.md +0 -170
  188. package/.docs/investigation/external-packages-assignments.md +0 -66
  189. package/.docs/investigation/integration-summary.md +0 -20
  190. package/.docs/investigation/narrix-catalox.md +0 -29
  191. package/.docs/investigation/workplan-close-graph-engine-gaps.md +0 -101
  192. package/.docs/logging-stack.md +0 -30
  193. package/.docs/memory-narrix-adapter-developer-guide.md +0 -402
  194. package/.docs/memory-narrix-adapter-requirements.md +0 -112
  195. package/.docs/narrix-context-consumption-gap.md +0 -184
  196. package/.docs/narrix-context-downstream-report.md +0 -30
  197. package/.docs/narrix-ingest-and-packs-library-spec.md +0 -240
  198. package/.docs/narrix-record-input-current-design.md +0 -48
  199. package/.docs/pacakge.md +0 -48
  200. package/.docs/possible-components/README.md +0 -11
  201. package/.docs/possible-components/integration/README.md +0 -10
  202. package/.docs/possible-components/integration/gaps-when-merging.md +0 -16
  203. package/.docs/possible-components/integration/platform.md +0 -54
  204. package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +0 -26
  205. package/.docs/possible-components/integration/roadmap-and-checklists.md +0 -54
  206. package/.docs/possible-components/post-component/README.md +0 -18
  207. package/.docs/possible-components/post-component/builder-guide.md +0 -175
  208. package/.docs/possible-components/post-component/gaps-and-artifacts.md +0 -52
  209. package/.docs/possible-components/post-component/handler-audit.md +0 -47
  210. package/.docs/possible-components/post-component/handler-polish.md +0 -41
  211. package/.docs/possible-components/post-component/unified-protocol.md +0 -59
  212. package/.docs/possible-components/pre-component/README.md +0 -22
  213. package/.docs/possible-components/pre-component/builder-guide.md +0 -127
  214. package/.docs/possible-components/pre-component/gaps-and-artifacts.md +0 -35
  215. package/.docs/possible-components/pre-component/handler-ai-scoping.md +0 -45
  216. package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +0 -49
  217. package/.docs/possible-components/pre-component/handler-narrix-system2.md +0 -35
  218. package/.docs/possible-components/pre-component/handler-synthesized-context.md +0 -65
  219. package/.docs/possible-components/pre-component/handler-web-scope.md +0 -29
  220. package/.docs/possible-components/pre-component/unified-protocol.md +0 -89
  221. package/.docs/prefer-openrouter-routing-policy.md +0 -114
  222. package/.docs/questions-for-ai-skills.md +0 -123
  223. package/.docs/realtime-narrixing-gap-analysis.md +0 -40
  224. package/.docs/realtime-narrixing.md +0 -433
  225. package/.docs/run-context-object.md +0 -32
  226. package/.docs/session-id-usage.md +0 -26
  227. package/.docs/skill-library-spec.md +0 -249
  228. package/.docs/synthesized-context-strategy-spec.md +0 -906
  229. package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +0 -46
  230. package/.docs/web-scopper-embed.md +0 -93
  231. package/.docs/xynthesis-wiring-and-io.md +0 -12
  232. package/documenations/activix-feature-request-identity.md +0 -123
  233. package/documenations/bug-report-xynthesis-and-synthesis-call.md +0 -217
  234. package/documenations/feature-request-ai-skills-raw-template-access.md +0 -82
  235. package/documenations/feature-request-athenix-core-directive.md +0 -145
  236. package/documenations/feature-request-athenix-token-extraction.md +0 -124
  237. package/documenations/funcx-upstream-github-issues-draft.md +0 -153
  238. package/documenations/identity-metadata-contract.md +0 -165
  239. package/documenations/run-task-single-run-checklist.md +0 -109
  240. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-1-no-concrete-wire-in-graph-plans.md +0 -93
  241. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-2-skillModel-profile-only-at-storage.md +0 -88
  242. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-3-reject-concrete-models-in-catalog-rows.md +0 -76
  243. package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-1-suggested-profile-in-catalogs.md +0 -96
  244. package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-2-graph-engine-failure-phase-attribution.md +0 -92
  245. package/documenations/sessions/2026-06-08-subnets-model-resolution/INVESTIGATION-original-bug.md +0 -182
  246. package/documenations/sessions/2026-06-08-subnets-model-resolution/PROBLEM.md +0 -236
  247. package/documenations/sessions/2026-06-08-subnets-model-resolution/README.md +0 -11
  248. package/documenations/sessions/2026-06-08-subnets-model-resolution/funcx-test-resolveModel.cheapDefaultWireSlug.test.ts +0 -117
  249. package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +0 -129
  250. package/documenations/upstream-feedback-request-shape-clarification.md +0 -101
  251. package/documenations/web-context-precedence.md +0 -33
  252. package/documenations/xynthesis-activix-telemetry.md +0 -28
@@ -10,6 +10,7 @@ import { buildRunTaskResultMetaFromModelId } from "../invocation/buildRunTaskRes
10
10
  import { logRunTaskInvocationPlan } from "../observability/logLlmProviderInvocation.js";
11
11
  import { registerBuiltInLocalTasks } from "../localTasks/index.js";
12
12
  import { getByPath } from "../utils/jsonPaths.js";
13
+ import { readInvokePayloadRecord } from "../utils/executionMemoryInputRecord.js";
13
14
  import { passthroughJobTemplateVariables } from "../utils/skillTemplateVariables.js";
14
15
  import { emitRunTaskRequestWarnings } from "../utils/runTaskRequestShape.js";
15
16
  import { configureFuncxLogging } from "@x12i/funcx";
@@ -32,14 +33,13 @@ import { getActivixClient } from "../activix/activixClient.js";
32
33
  import { withPhaseRecord } from "../activix/phaseTracking.js";
33
34
  import { activixOuterTier } from "@x12i/activix";
34
35
  import { createDebugTraceCollector, traceWrap } from "../observability/debugTrace.js";
35
- import { loadSynthesisTemplates, buildSynthesisSystemPrompt, buildSynthesisUserPrompt, resolveSourceMaterial, resolveSourceMaterialParts, getRenderedTemplates, buildSynthesizedContextMarkdown, resolveSynthesisQuestion, runStructuredSynthesisGatewayCallRobust, getContextSynthesizer, normalizeAndValidateSynthesizedPayload, discoverTemplateCores, } from "../synthesis/index.js";
36
+ import { resolveSourceMaterial, resolveSourceMaterialParts, getRenderedTemplates, buildSynthesizedContextMarkdown, resolveSynthesisQuestion, runStructuredSynthesisGatewayCallRobust, getContextSynthesizer, normalizeAndValidateSynthesizedPayload, discoverTemplateCores, } from "../synthesis/index.js";
36
37
  import { resolveOutputExpectation as resolveOutputExpectationXynthesis } from "@exellix/xynthesis/ai-actions";
37
38
  import { llmCallEnvPrefix, resolveLlmCall } from "../post-steps/resolvePostStepConfig.js";
38
39
  import { buildXynthesisWorkScopeIdentity } from "../internal/buildXynthesisWorkScopeIdentity.js";
39
40
  import { getPostActionModelFromSlots, prepareMainSkillModelConfigForInvoke, resolvePreActionModel, } from "../utils/routeModelConfigSlots.js";
40
41
  import { assertPhaseModelAlias } from "../errors/modelConfigRequiredError.js";
41
42
  import { isRunTaskModelResolutionError } from "../errors/runTaskModelResolutionError.js";
42
- import { runPostStepLlmCall } from "../internal/runPostStepLlmCall.js";
43
43
  registerBuiltInLocalTasks();
44
44
  const DEFAULT_SYNTH_INPUT_MAX_CHARS = 200_000;
45
45
  function maxSynthesizedInputChars() {
@@ -260,10 +260,13 @@ function coerceTaskMemoryNarrixToAttachment(taskMemoryNarrix) {
260
260
  };
261
261
  }
262
262
  function resolveSynthesisMode(config) {
263
- if (config.synthesisMode === "structured" || config.synthesisMode === "markdown") {
264
- return config.synthesisMode;
263
+ if (config.synthesisMode === "structured") {
264
+ return "structured";
265
265
  }
266
- return "markdown";
266
+ if (config.synthesisMode === "markdown") {
267
+ return "structured";
268
+ }
269
+ return "structured";
267
270
  }
268
271
  function detectedTemplateCoresFromExecutionMemory(executionMemory) {
269
272
  const artifact = executionMemory?.synthesizedContext;
@@ -437,6 +440,18 @@ function buildSynthesizerInputMaterial(strategy, resolveOpts) {
437
440
  const parts = resolveSourceMaterialParts(resolveOpts);
438
441
  return { sourceMaterial, parts };
439
442
  }
443
+ function buildPreSynthesisGateway(request) {
444
+ return {
445
+ aiRequestId: randomUUID(),
446
+ agentId: typeof request.agentId === "string"
447
+ ? request.agentId
448
+ : (request.skillKey ?? "ai-tasks"),
449
+ sessionId: typeof request.taskId === "string" && request.taskId.trim()
450
+ ? request.taskId.trim()
451
+ : randomUUID(),
452
+ temperature: 0.7,
453
+ };
454
+ }
440
455
  function safeResolveSynthesisQuestion(synthesisRequest, config, renderedPrompt) {
441
456
  try {
442
457
  const q = resolveSynthesisQuestion(synthesisRequest, config, renderedPrompt);
@@ -543,7 +558,7 @@ export class WorexClientTasks {
543
558
  prevNodeId: input.prevNodeId,
544
559
  masterSkillId: input.masterSkillId,
545
560
  masterSkillActivityId: input.masterSkillActivityId,
546
- hasPipeline: Array.isArray(input.executionPipeline) && input.executionPipeline.length > 0,
561
+ hasPipeline: (input.nodePlan?.executionUnits?.length ?? 0) > 1,
547
562
  hasNarrix: !!input.narrix,
548
563
  hasNarrixInput: !!input.narrixInput,
549
564
  });
@@ -603,7 +618,7 @@ export class WorexClientTasks {
603
618
  }
604
619
  return result;
605
620
  };
606
- const hasPipeline = Array.isArray(input.executionPipeline) && input.executionPipeline.length > 0;
621
+ const hasPipeline = (input.nodePlan?.executionUnits?.length ?? 0) > 1;
607
622
  const hasNarrix = !!input.narrix;
608
623
  const hasNarrixInput = !!input.narrixInput;
609
624
  // Activix 6+: correlation + task identity belong in `runContext`, not a parallel top-level `identity` field.
@@ -663,13 +678,13 @@ export class WorexClientTasks {
663
678
  masterSkillId: req.masterSkillId,
664
679
  masterSkillActivityId: req.masterSkillActivityId,
665
680
  includeContextInPrompt: req.includeContextInPrompt === true,
666
- hasPipeline: Array.isArray(req.executionPipeline) && req.executionPipeline.length > 0,
681
+ hasPipeline: (req.nodePlan?.executionUnits?.length ?? 0) > 1,
667
682
  hasNarrix: !!req.narrix,
668
683
  hasNarrixInput: !!req.narrixInput,
669
684
  input: summarizeForOuter(req.input, 4_000),
670
685
  }, null, { phase: "direct" }),
671
686
  // pipeline MAIN vs DIRECT is still tracked as the same phase label ("direct")
672
- hasPipeline: !!req.executionPipeline,
687
+ hasPipeline: (req.nodePlan?.executionUnits?.length ?? 0) > 1,
673
688
  hasNarrix: !!req.narrix,
674
689
  hasNarrixInput: !!req.narrixInput,
675
690
  overrideContextProvided: options?.overrideContext !== undefined,
@@ -700,7 +715,7 @@ export class WorexClientTasks {
700
715
  masterSkillId: req.masterSkillId,
701
716
  masterSkillActivityId: req.masterSkillActivityId,
702
717
  includeContextInPrompt: req.includeContextInPrompt === true,
703
- hasPipeline: Array.isArray(req.executionPipeline) && req.executionPipeline.length > 0,
718
+ hasPipeline: (req.nodePlan?.executionUnits?.length ?? 0) > 1,
704
719
  hasNarrix: !!req.narrix,
705
720
  hasNarrixInput: !!req.narrixInput,
706
721
  input: summarizeForOuter(req.input, 4_000),
@@ -988,6 +1003,10 @@ export class WorexClientTasks {
988
1003
  return { contextMarkdown: "" };
989
1004
  throw e;
990
1005
  }
1006
+ const skillsClient = this.skillsClient;
1007
+ const resolveRawTemplateAvailable = typeof skillsClient.resolveRawTemplate === "function";
1008
+ const synthesisInputStrategy = config.synthesisInputStrategy ?? "policy";
1009
+ let lastTemplateResolveNote;
991
1010
  const resolveRawTemplate = async (key) => {
992
1011
  const section = key.endsWith(".instructions") || key.endsWith(".instructions.md")
993
1012
  ? "instructions"
@@ -995,17 +1014,33 @@ export class WorexClientTasks {
995
1014
  ? "prompt"
996
1015
  : null;
997
1016
  const baseSkillKey = request.skillKey;
998
- const skillsClient = this.skillsClient;
999
- if (section && typeof skillsClient.resolveRawTemplate === "function") {
1000
- try {
1001
- const result = await skillsClient.resolveRawTemplate(baseSkillKey, section);
1002
- if (result?.found && typeof result.content === "string" && result.content.length > 0) {
1003
- return result.content;
1004
- }
1017
+ if (!section) {
1018
+ return undefined;
1019
+ }
1020
+ if (!resolveRawTemplateAvailable) {
1021
+ lastTemplateResolveNote =
1022
+ "@exellix/ai-skills resolveRawTemplate() is missing — upgrade ai-skills to 4.1+.";
1023
+ return undefined;
1024
+ }
1025
+ try {
1026
+ const result = await skillsClient.resolveRawTemplate(baseSkillKey, section, {
1027
+ role: "synthesisContext",
1028
+ strategyKey: synthesisInputStrategy,
1029
+ });
1030
+ if (result?.found && typeof result.content === "string" && result.content.length > 0) {
1031
+ return result.content;
1005
1032
  }
1006
- catch {
1007
- // Keep hard failure behavior in structured mode via empty token discovery.
1033
+ lastTemplateResolveNote = `resolveRawTemplate(skillKey=${baseSkillKey}, role=synthesisContext, strategyKey=${synthesisInputStrategy}, section=${section}) returned found=${String(result?.found ?? false)}`;
1034
+ }
1035
+ catch (e) {
1036
+ if (e instanceof Error &&
1037
+ (e.name === "CataloxSkillNotFoundError" || /No Catalox catalog item/i.test(e.message))) {
1038
+ throw e;
1008
1039
  }
1040
+ lastTemplateResolveNote =
1041
+ e instanceof Error
1042
+ ? `${e.name}: ${e.message}`
1043
+ : `resolveRawTemplate threw: ${String(e)}`;
1009
1044
  }
1010
1045
  return undefined;
1011
1046
  };
@@ -1083,14 +1118,18 @@ export class WorexClientTasks {
1083
1118
  };
1084
1119
  }
1085
1120
  const execMem = (enrichedBundle.executionMemory ?? memoryBundle.executionMemory);
1086
- const recordRaw = isRecord(execMem?.input) ? execMem.input.raw : undefined;
1121
+ const recordRaw = readInvokePayloadRecord(request);
1087
1122
  const recordMd = recordRaw !== undefined
1088
- ? `## Record (executionMemory.input.raw)\n\n\`\`\`json\n${truncate(JSON.stringify(recordRaw, null, 2), maxOutputLength ? Math.min(maxOutputLength, 60_000) : 60_000)}\n\`\`\`\n`
1123
+ ? `## Record (input)\n\n\`\`\`json\n${truncate(JSON.stringify(recordRaw, null, 2), maxOutputLength ? Math.min(maxOutputLength, 60_000) : 60_000)}\n\`\`\`\n`
1089
1124
  : "";
1090
1125
  const webContextEntry = execMem?.webContext;
1091
1126
  const webMd = buildWebContextEvidenceMarkdown(webContextEntry, config.webEvidence);
1092
- const { system: systemTemplate, user: userTemplate } = await loadSynthesisTemplates();
1093
- const systemPrompt = buildSynthesisSystemPrompt(systemTemplate, config.synthesisPromptOverride, config.customSynthesizingGuidelines);
1127
+ const { templateCores } = discoverTemplateCores({
1128
+ templates: [
1129
+ { name: "instructions", content: rawInstructions },
1130
+ { name: "prompt", content: rawPrompt },
1131
+ ],
1132
+ });
1094
1133
  const extractWebEvidence = () => {
1095
1134
  if (!isRecord(webContextEntry))
1096
1135
  return { webUnavailableReason: "webContext missing" };
@@ -1153,58 +1192,48 @@ export class WorexClientTasks {
1153
1192
  if (allowWeb)
1154
1193
  materialParts.push(webMd || "## Web sources (primary evidence)\n\n[unavailable]");
1155
1194
  const perQuestionMaterial = materialParts.join("\n");
1156
- const userPrompt = buildSynthesisUserPrompt(renderedInstructions, renderedPrompt, perQuestionMaterial, userTemplate);
1157
1195
  let synthesisText;
1158
1196
  if (allowWeb && !hasWeb && !allowRecord) {
1159
1197
  const reason = webEvidence.webUnavailableReason ?? "web scoping unavailable";
1160
1198
  synthesisText = `Unknown — web-derived context unavailable (${reason}).`;
1161
1199
  }
1162
1200
  else if (allowRecord && !hasRecord && !allowWeb) {
1163
- synthesisText = `Unknown — record-derived context unavailable (missing executionMemory.input.raw).`;
1201
+ synthesisText = `Unknown — record-derived context unavailable (missing executionMemory.input).`;
1164
1202
  }
1165
1203
  else if (allowRecord && allowWeb && !hasRecord && !hasWeb) {
1166
1204
  const reason = webEvidence.webUnavailableReason ?? "web scoping unavailable";
1167
1205
  synthesisText =
1168
- `Unknown — no inputs available (missing executionMemory.input.raw; web unavailable: ${reason}).`;
1206
+ `Unknown — no inputs available (missing executionMemory.input; web unavailable: ${reason}).`;
1169
1207
  }
1170
1208
  else {
1171
- const res = await runPostStepLlmCall({
1172
- systemPrompt,
1173
- userPrompt,
1174
- llmCall: synthLlmCall,
1175
- stage: "pre-synthesis-question",
1176
- stepId: `questionDriven:${id}`,
1209
+ const payload = await runStructuredSynthesisGatewayCallRobust({
1210
+ templateCores,
1211
+ question: question.trim(),
1212
+ localMarkdown: perQuestionMaterial,
1213
+ supportingMarkdown: "",
1214
+ renderedInstructions,
1215
+ renderedPrompt,
1216
+ model,
1217
+ timeoutMs,
1218
+ maxOutputLength,
1219
+ outputExpectation: synthLlmCall.outputExpectation,
1220
+ reasoningEffort: synthLlmCall.reasoningEffort,
1221
+ topP: synthLlmCall.topP,
1222
+ executionMode: traceCollector ? "trace" : undefined,
1177
1223
  jobId: request.jobId,
1178
1224
  taskId: request.taskId,
1179
1225
  agentId: request.agentId,
1180
- workScopeIdentity,
1181
- traceCollector,
1182
- traceTask: traceCollector
1183
- ? {
1184
- taskType: "pre-execution",
1185
- details: "synthesized-context question call",
1186
- modelUsed: model ?? null,
1187
- metadata: {
1188
- jobId: request.jobId,
1189
- taskId: request.taskId,
1190
- skillKey: request.skillKey,
1191
- phase: "pipeline_pre",
1192
- preStepType: "synthesized-context",
1193
- step: { phase: "pre", type: "synthesized-context", stepId: `questionDriven:${id}` },
1194
- questionId: id,
1195
- },
1196
- }
1197
- : undefined,
1198
- observationSink: synthObservationSink,
1226
+ identity: workScopeIdentity,
1227
+ gateway: buildPreSynthesisGateway(request),
1199
1228
  });
1200
- synthesisText = res.text;
1229
+ synthesisText = buildSynthesizedContextMarkdown(payload);
1201
1230
  }
1202
1231
  answers[id] = {
1203
1232
  question: question.trim(),
1204
1233
  source,
1205
1234
  synthesis: synthesisText,
1206
1235
  evidence: {
1207
- recordPaths: allowRecord ? ["executionMemory.input.raw"] : undefined,
1236
+ recordPaths: allowRecord ? ["executionMemory.input"] : undefined,
1208
1237
  webScopeIds: allowWeb ? webEvidence.webScopeIds : undefined,
1209
1238
  sources: allowWeb ? webEvidence.sources : undefined,
1210
1239
  },
@@ -1231,148 +1260,87 @@ export class WorexClientTasks {
1231
1260
  };
1232
1261
  }
1233
1262
  const synthesisMode = resolveSynthesisMode(config);
1234
- if (synthesisMode === "structured") {
1235
- const parts = sourceMaterialParts;
1236
- const question = safeResolveSynthesisQuestion(synthesisRequest, config, renderedPrompt);
1237
- const { templateCores } = discoverTemplateCores({
1238
- templates: [
1239
- { name: "instructions", content: rawInstructions },
1240
- { name: "prompt", content: rawPrompt },
1241
- ],
1242
- });
1243
- if (templateCores.length === 0) {
1244
- if (!rawInstructions.trim() && !rawPrompt.trim()) {
1245
- throw new Error(`structured synthesized-context could not resolve raw instructions/prompt templates for skillKey: ${request.skillKey}. ` +
1246
- `Ensure ai-skills content registry is available for resolveRawTemplate().`);
1247
- }
1248
- throw new Error(`structured synthesized-context requires at least one template core token in instructions or prompt. skillKey: ${request.skillKey}`);
1263
+ const parts = sourceMaterialParts;
1264
+ const question = safeResolveSynthesisQuestion(synthesisRequest, config, renderedPrompt);
1265
+ const { templateCores } = discoverTemplateCores({
1266
+ templates: [
1267
+ { name: "instructions", content: rawInstructions },
1268
+ { name: "prompt", content: rawPrompt },
1269
+ ],
1270
+ });
1271
+ if (templateCores.length === 0) {
1272
+ if (!rawInstructions.trim() && !rawPrompt.trim()) {
1273
+ const hint = resolveRawTemplateAvailable
1274
+ ? `Missing synthesisContext templates for strategy "${synthesisInputStrategy}". ${lastTemplateResolveNote ?? "Publish/sync skill support templates to Catalox (ai-skills catalox:sync-skill-templates)."}`
1275
+ : "@exellix/ai-skills resolveRawTemplate() is missing upgrade ai-skills to 4.1+ and configure Catalox (FIREBASE_PROJECT_ID, GOOGLE_SERVICE_ACCOUNT_BASE64).";
1276
+ throw new Error(`structured synthesized-context could not resolve synthesisContext templates for skillKey: ${request.skillKey}, synthesisInputStrategy: ${synthesisInputStrategy}. ${hint}`);
1249
1277
  }
1250
- const validateOpts = {
1251
- expectedTemplateCores: templateCores,
1252
- expectedQuestion: question,
1253
- maxItemsPerSide: config.structuredMaxItemsPerSide,
1254
- maxItemContentChars: config.structuredMaxItemContentChars,
1255
- };
1256
- try {
1257
- const custom = getContextSynthesizer();
1258
- let payload;
1259
- if (custom) {
1260
- payload = await custom.synthesize({
1261
- templateCores,
1262
- question,
1263
- localRaw: parts.localMarkdown,
1264
- supportingRaw: parts.supportingMarkdown,
1265
- metadata: {
1266
- renderedInstructions,
1267
- renderedPrompt,
1268
- templateCores,
1269
- skillKey: request.skillKey,
1270
- jobId: request.jobId,
1271
- taskId: request.taskId,
1272
- },
1273
- });
1274
- payload = normalizeAndValidateSynthesizedPayload(payload, validateOpts);
1275
- }
1276
- else {
1277
- payload = await runStructuredSynthesisGatewayCallRobust({
1278
- question,
1279
- localMarkdown: parts.localMarkdown,
1280
- supportingMarkdown: parts.supportingMarkdown,
1278
+ throw new Error(`structured synthesized-context requires at least one template core token in synthesisContext templates. skillKey: ${request.skillKey}, synthesisInputStrategy: ${synthesisInputStrategy}`);
1279
+ }
1280
+ const validateOpts = {
1281
+ expectedTemplateCores: templateCores,
1282
+ expectedQuestion: question,
1283
+ maxItemsPerSide: config.structuredMaxItemsPerSide,
1284
+ maxItemContentChars: config.structuredMaxItemContentChars,
1285
+ };
1286
+ try {
1287
+ const custom = getContextSynthesizer();
1288
+ let payload;
1289
+ if (custom) {
1290
+ payload = await custom.synthesize({
1291
+ templateCores,
1292
+ question,
1293
+ localRaw: parts.localMarkdown,
1294
+ supportingRaw: parts.supportingMarkdown,
1295
+ metadata: {
1281
1296
  renderedInstructions,
1282
1297
  renderedPrompt,
1283
- templatesBasePath: config.templatesBasePath,
1284
- synthesisPromptOverride: config.synthesisPromptOverride,
1285
- customSynthesizingGuidelines: config.customSynthesizingGuidelines,
1286
- model: model,
1287
- timeoutMs: timeoutMs,
1288
- maxOutputLength: maxOutputLength,
1289
- // Caller-supplied outputExpectation overrides the per-action default in the structured-repair path.
1290
- outputExpectation: synthLlmCall.outputExpectation,
1291
- reasoningEffort: synthLlmCall.reasoningEffort,
1292
- topP: synthLlmCall.topP,
1293
- // Forward trace mode so the structured gateway returns a `debugTrace` (lifted into observations elsewhere).
1294
- executionMode: traceCollector ? "trace" : undefined,
1298
+ templateCores,
1299
+ skillKey: request.skillKey,
1295
1300
  jobId: request.jobId,
1296
1301
  taskId: request.taskId,
1297
- agentId: request.agentId,
1298
- identity: workScopeIdentity,
1299
- });
1300
- }
1301
- const contextMarkdown = buildSynthesizedContextMarkdown(payload);
1302
- return {
1303
- contextMarkdown,
1304
- artifact: {
1305
- templateCores,
1306
- question,
1307
- mode: synthesisMode,
1308
- payload,
1309
- contextMarkdown,
1310
1302
  },
1311
- synthesizedInput: buildSynthesizedInputArtifact(synthesisMode, sourceMaterial, parts, {
1312
- question,
1313
- templateCores,
1314
- }),
1315
- synthesizedContextLlmCalls: traceCollector ? synthLlmCalls : undefined,
1316
- };
1303
+ });
1304
+ payload = normalizeAndValidateSynthesizedPayload(payload, validateOpts);
1317
1305
  }
1318
- catch (e) {
1319
- if (config.fallbackToDirect === true)
1320
- return {
1321
- contextMarkdown: "",
1322
- synthesizedContextLlmCalls: traceCollector ? synthLlmCalls : undefined,
1323
- };
1324
- throw e;
1306
+ else {
1307
+ payload = await runStructuredSynthesisGatewayCallRobust({
1308
+ templateCores,
1309
+ question,
1310
+ localMarkdown: parts.localMarkdown,
1311
+ supportingMarkdown: parts.supportingMarkdown,
1312
+ renderedInstructions,
1313
+ renderedPrompt,
1314
+ templatesBasePath: config.templatesBasePath,
1315
+ synthesisPromptOverride: config.synthesisPromptOverride,
1316
+ customSynthesizingGuidelines: config.customSynthesizingGuidelines,
1317
+ model: model,
1318
+ timeoutMs: timeoutMs,
1319
+ maxOutputLength: maxOutputLength,
1320
+ // Caller-supplied outputExpectation overrides the per-action default in the structured-repair path.
1321
+ outputExpectation: synthLlmCall.outputExpectation,
1322
+ reasoningEffort: synthLlmCall.reasoningEffort,
1323
+ topP: synthLlmCall.topP,
1324
+ // Forward trace mode so the structured gateway returns a `debugTrace` (lifted into observations elsewhere).
1325
+ executionMode: traceCollector ? "trace" : undefined,
1326
+ jobId: request.jobId,
1327
+ taskId: request.taskId,
1328
+ agentId: request.agentId,
1329
+ identity: workScopeIdentity,
1330
+ gateway: buildPreSynthesisGateway(request),
1331
+ });
1325
1332
  }
1326
- }
1327
- const { system: systemTemplate, user: userTemplate } = await loadSynthesisTemplates();
1328
- const systemPrompt = buildSynthesisSystemPrompt(systemTemplate, config.synthesisPromptOverride, config.customSynthesizingGuidelines);
1329
- const userPrompt = buildSynthesisUserPrompt(renderedInstructions, renderedPrompt, sourceMaterial, userTemplate);
1330
- try {
1331
- const { text: contextMarkdown } = await runPostStepLlmCall({
1332
- systemPrompt,
1333
- userPrompt,
1334
- extraMaterial: sourceMaterial,
1335
- llmCall: synthLlmCall,
1336
- stage: "pre-synthesis-markdown",
1337
- jobId: request.jobId,
1338
- taskId: request.taskId,
1339
- agentId: request.agentId,
1340
- workScopeIdentity,
1341
- traceCollector,
1342
- traceTask: traceCollector
1343
- ? {
1344
- taskType: "pre-execution",
1345
- details: "synthesized-context markdown call",
1346
- modelUsed: model ?? null,
1347
- metadata: {
1348
- jobId: request.jobId,
1349
- taskId: request.taskId,
1350
- skillKey: request.skillKey,
1351
- phase: "pipeline_pre",
1352
- preStepType: "synthesized-context",
1353
- step: { phase: "pre", type: "synthesized-context", stepId: "markdown" },
1354
- },
1355
- }
1356
- : undefined,
1357
- observationSink: synthObservationSink,
1358
- });
1359
- const question = safeResolveSynthesisQuestion(synthesisRequest, config, renderedPrompt);
1360
- const { templateCores } = discoverTemplateCores({
1361
- templates: [
1362
- { name: "instructions", content: rawInstructions },
1363
- { name: "prompt", content: rawPrompt },
1364
- ],
1365
- });
1333
+ const contextMarkdown = buildSynthesizedContextMarkdown(payload);
1366
1334
  return {
1367
1335
  contextMarkdown,
1368
1336
  artifact: {
1369
1337
  templateCores,
1370
1338
  question,
1371
- mode: "markdown",
1372
- payload: { kind: "markdown-synthesis" },
1339
+ mode: synthesisMode,
1340
+ payload,
1373
1341
  contextMarkdown,
1374
1342
  },
1375
- synthesizedInput: buildSynthesizedInputArtifact("markdown", sourceMaterial, sourceMaterialParts, {
1343
+ synthesizedInput: buildSynthesizedInputArtifact(synthesisMode, sourceMaterial, parts, {
1376
1344
  question,
1377
1345
  templateCores,
1378
1346
  }),