@exellix/ai-tasks 9.1.0 → 9.1.1
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.
- package/CHANGELOG.md +15 -4
- package/README.md +2 -2
- package/RUNTASK_REQUEST.md +17 -15
- package/dist/compile/compileTaskConfiguration.d.ts.map +1 -1
- package/dist/compile/compileTaskConfiguration.js +3 -0
- package/dist/compile/compileTaskConfiguration.js.map +1 -1
- package/dist/core/task-sdk.d.ts.map +1 -1
- package/dist/core/task-sdk.js +112 -166
- package/dist/core/task-sdk.js.map +1 -1
- package/dist/invocation/types.d.ts +1 -1
- package/dist/narrix/narrixUnitExecution.js +2 -2
- package/dist/narrix/narrixUnitExecution.js.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.d.ts +4 -0
- package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.js +4 -13
- package/dist/node-execution/buildRequestFromNodePlan.js.map +1 -1
- package/dist/node-execution/compileProfessionalAnswerRequest.d.ts +2 -0
- package/dist/node-execution/compileProfessionalAnswerRequest.d.ts.map +1 -0
- package/dist/node-execution/compileProfessionalAnswerRequest.js +4 -0
- package/dist/node-execution/compileProfessionalAnswerRequest.js.map +1 -0
- package/dist/node-execution/rejectForbiddenWireFields.d.ts +2 -0
- package/dist/node-execution/rejectForbiddenWireFields.d.ts.map +1 -1
- package/dist/node-execution/rejectForbiddenWireFields.js +42 -7
- package/dist/node-execution/rejectForbiddenWireFields.js.map +1 -1
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts +19 -3
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts.map +1 -1
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js +7 -1
- package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js.map +1 -1
- package/dist/post-steps/audit/loadAuditTemplates.d.ts +2 -55
- package/dist/post-steps/audit/loadAuditTemplates.d.ts.map +1 -1
- package/dist/post-steps/audit/loadAuditTemplates.js +3 -38
- package/dist/post-steps/audit/loadAuditTemplates.js.map +1 -1
- package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts +8 -0
- package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts.map +1 -0
- package/dist/post-steps/audit/parseAuditFuncxOutput.js +62 -0
- package/dist/post-steps/audit/parseAuditFuncxOutput.js.map +1 -0
- package/dist/post-steps/audit/parseAuditOutput.d.ts +2 -0
- package/dist/post-steps/audit/parseAuditOutput.d.ts.map +1 -1
- package/dist/post-steps/audit/parseAuditOutput.js +56 -0
- package/dist/post-steps/audit/parseAuditOutput.js.map +1 -1
- package/dist/post-steps/audit/runAudit.d.ts.map +1 -1
- package/dist/post-steps/audit/runAudit.js +53 -113
- package/dist/post-steps/audit/runAudit.js.map +1 -1
- package/dist/post-steps/audit/runAuditFuncxCall.d.ts +18 -0
- package/dist/post-steps/audit/runAuditFuncxCall.d.ts.map +1 -0
- package/dist/post-steps/audit/runAuditFuncxCall.js +59 -0
- package/dist/post-steps/audit/runAuditFuncxCall.js.map +1 -0
- package/dist/synthesis/resolveSourceMaterial.d.ts.map +1 -1
- package/dist/synthesis/resolveSourceMaterial.js +14 -0
- package/dist/synthesis/resolveSourceMaterial.js.map +1 -1
- package/dist/types/task-types.d.ts +4 -3
- package/dist/types/task-types.d.ts.map +1 -1
- package/dist/utils/bridgeRunSkillGatewayMemory.d.ts.map +1 -1
- package/dist/utils/bridgeRunSkillGatewayMemory.js +1 -0
- package/dist/utils/bridgeRunSkillGatewayMemory.js.map +1 -1
- package/dist/utils/executionMemoryInputRecord.d.ts +12 -0
- package/dist/utils/executionMemoryInputRecord.d.ts.map +1 -0
- package/dist/utils/executionMemoryInputRecord.js +28 -0
- package/dist/utils/executionMemoryInputRecord.js.map +1 -0
- package/dist/utils/resolveAiProfileModel.d.ts +1 -1
- package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
- package/dist/utils/skillTemplateVariables.d.ts +3 -2
- package/dist/utils/skillTemplateVariables.d.ts.map +1 -1
- package/dist/utils/skillTemplateVariables.js +3 -2
- package/dist/utils/skillTemplateVariables.js.map +1 -1
- package/dist/validation/validateProfessionalAnswerContract.d.ts +8 -0
- package/dist/validation/validateProfessionalAnswerContract.d.ts.map +1 -0
- package/dist/validation/validateProfessionalAnswerContract.js +45 -0
- package/dist/validation/validateProfessionalAnswerContract.js.map +1 -0
- package/dist/validation/validateRunTaskConfig.d.ts.map +1 -1
- package/dist/validation/validateRunTaskConfig.js +2 -0
- package/dist/validation/validateRunTaskConfig.js.map +1 -1
- package/documenations/record-and-template-variables.md +21 -13
- package/documenations/run-task-execution-flow.md +1 -1
- package/documenations/upstream-feature-requests/README.md +9 -5
- package/documenations/upstream-feature-requests/ai-skills-orchestrator-invoke-contract-5.9.md +1 -1
- package/documenations/upstream-feature-requests/funcx-4.9.13-open-items.md +62 -0
- package/documenations/upstream-feature-requests/funcx-gap-analysis-cr-fr.md +401 -0
- package/documenations/upstream-feature-requests/funcx-pre-post-sidekick-actions.md +1 -0
- package/documenations/upstream-feature-requests/graph-engine-runtask-contract-alignment-investigation.md +370 -0
- package/documenations/upstream-feature-requests/xynthesis-ai-profiles-2.1-import-break.md +2 -2
- package/documenations/upstream-feature-requests/xynthesis-openrouter-wire-model-double-prefix-bug.md +1 -1
- package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +1 -1
- package/package.json +10 -9
- package/.docs/DOWNSTREAM_ENV.md +0 -42
- package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +0 -64
- package/.docs/INTERMEDIATE_STEPS.md +0 -82
- package/.docs/activity-structure.md +0 -31
- package/.docs/ai-task-ai-scoping-spec.md +0 -338
- package/.docs/ai-tasks-model-profile-aliases-7x.md +0 -96
- package/.docs/blockers-and-issues.md +0 -346
- package/.docs/building-runTask-sdk.md +0 -659
- package/.docs/building-skill-execution-orchestrator.md +0 -968
- package/.docs/code-used-before/run-task.txt +0 -39
- package/.docs/code-used-before/task-executor.ts.old +0 -57
- package/.docs/code-used-before/test-run-task.ts.old +0 -42
- package/.docs/code-used-before/types.txt +0 -23
- package/.docs/env-ready-policy.md +0 -40
- package/.docs/flow-io/flow-README.md +0 -76
- package/.docs/flow-io/narrix.md +0 -124
- package/.docs/flow-io/web-scoping.md +0 -135
- package/.docs/flow-io/xynthesis-post.md +0 -154
- package/.docs/flow-io/xynthesis-pre.md +0 -181
- package/.docs/gap-analysis.md +0 -201
- package/.docs/integration-facts-ai-tasks.md +0 -109
- package/.docs/investigation/ai-skills.md +0 -170
- package/.docs/investigation/external-packages-assignments.md +0 -66
- package/.docs/investigation/integration-summary.md +0 -20
- package/.docs/investigation/narrix-catalox.md +0 -29
- package/.docs/investigation/workplan-close-graph-engine-gaps.md +0 -101
- package/.docs/logging-stack.md +0 -30
- package/.docs/memory-narrix-adapter-developer-guide.md +0 -402
- package/.docs/memory-narrix-adapter-requirements.md +0 -112
- package/.docs/narrix-context-consumption-gap.md +0 -184
- package/.docs/narrix-context-downstream-report.md +0 -30
- package/.docs/narrix-ingest-and-packs-library-spec.md +0 -240
- package/.docs/narrix-record-input-current-design.md +0 -48
- package/.docs/pacakge.md +0 -48
- package/.docs/possible-components/README.md +0 -11
- package/.docs/possible-components/integration/README.md +0 -10
- package/.docs/possible-components/integration/gaps-when-merging.md +0 -16
- package/.docs/possible-components/integration/platform.md +0 -54
- package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +0 -26
- package/.docs/possible-components/integration/roadmap-and-checklists.md +0 -54
- package/.docs/possible-components/post-component/README.md +0 -18
- package/.docs/possible-components/post-component/builder-guide.md +0 -175
- package/.docs/possible-components/post-component/gaps-and-artifacts.md +0 -52
- package/.docs/possible-components/post-component/handler-audit.md +0 -47
- package/.docs/possible-components/post-component/handler-polish.md +0 -41
- package/.docs/possible-components/post-component/unified-protocol.md +0 -59
- package/.docs/possible-components/pre-component/README.md +0 -22
- package/.docs/possible-components/pre-component/builder-guide.md +0 -127
- package/.docs/possible-components/pre-component/gaps-and-artifacts.md +0 -35
- package/.docs/possible-components/pre-component/handler-ai-scoping.md +0 -45
- package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +0 -49
- package/.docs/possible-components/pre-component/handler-narrix-system2.md +0 -35
- package/.docs/possible-components/pre-component/handler-synthesized-context.md +0 -65
- package/.docs/possible-components/pre-component/handler-web-scope.md +0 -29
- package/.docs/possible-components/pre-component/unified-protocol.md +0 -89
- package/.docs/prefer-openrouter-routing-policy.md +0 -114
- package/.docs/questions-for-ai-skills.md +0 -123
- package/.docs/realtime-narrixing-gap-analysis.md +0 -40
- package/.docs/realtime-narrixing.md +0 -433
- package/.docs/run-context-object.md +0 -32
- package/.docs/session-id-usage.md +0 -26
- package/.docs/skill-library-spec.md +0 -249
- package/.docs/synthesized-context-strategy-spec.md +0 -906
- package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +0 -46
- package/.docs/web-scopper-embed.md +0 -93
- package/.docs/xynthesis-wiring-and-io.md +0 -12
- package/documenations/activix-feature-request-identity.md +0 -123
- package/documenations/bug-report-xynthesis-and-synthesis-call.md +0 -217
- package/documenations/feature-request-ai-skills-raw-template-access.md +0 -82
- package/documenations/feature-request-athenix-core-directive.md +0 -145
- package/documenations/feature-request-athenix-token-extraction.md +0 -124
- package/documenations/funcx-upstream-github-issues-draft.md +0 -153
- package/documenations/identity-metadata-contract.md +0 -165
- package/documenations/run-task-single-run-checklist.md +0 -109
- package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-1-no-concrete-wire-in-graph-plans.md +0 -93
- package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-2-skillModel-profile-only-at-storage.md +0 -88
- package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-3-reject-concrete-models-in-catalog-rows.md +0 -76
- package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-1-suggested-profile-in-catalogs.md +0 -96
- package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-2-graph-engine-failure-phase-attribution.md +0 -92
- package/documenations/sessions/2026-06-08-subnets-model-resolution/INVESTIGATION-original-bug.md +0 -182
- package/documenations/sessions/2026-06-08-subnets-model-resolution/PROBLEM.md +0 -236
- package/documenations/sessions/2026-06-08-subnets-model-resolution/README.md +0 -11
- package/documenations/sessions/2026-06-08-subnets-model-resolution/funcx-test-resolveModel.cheapDefaultWireSlug.test.ts +0 -117
- package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +0 -129
- package/documenations/upstream-feedback-request-shape-clarification.md +0 -101
- package/documenations/web-context-precedence.md +0 -33
- package/documenations/xynthesis-activix-telemetry.md +0 -28
package/dist/core/task-sdk.js
CHANGED
|
@@ -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 {
|
|
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"
|
|
264
|
-
return
|
|
263
|
+
if (config.synthesisMode === "structured") {
|
|
264
|
+
return "structured";
|
|
265
265
|
}
|
|
266
|
-
|
|
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);
|
|
@@ -1083,14 +1098,18 @@ export class WorexClientTasks {
|
|
|
1083
1098
|
};
|
|
1084
1099
|
}
|
|
1085
1100
|
const execMem = (enrichedBundle.executionMemory ?? memoryBundle.executionMemory);
|
|
1086
|
-
const recordRaw =
|
|
1101
|
+
const recordRaw = readInvokePayloadRecord(request);
|
|
1087
1102
|
const recordMd = recordRaw !== undefined
|
|
1088
|
-
? `## Record (
|
|
1103
|
+
? `## Record (input)\n\n\`\`\`json\n${truncate(JSON.stringify(recordRaw, null, 2), maxOutputLength ? Math.min(maxOutputLength, 60_000) : 60_000)}\n\`\`\`\n`
|
|
1089
1104
|
: "";
|
|
1090
1105
|
const webContextEntry = execMem?.webContext;
|
|
1091
1106
|
const webMd = buildWebContextEvidenceMarkdown(webContextEntry, config.webEvidence);
|
|
1092
|
-
const {
|
|
1093
|
-
|
|
1107
|
+
const { templateCores } = discoverTemplateCores({
|
|
1108
|
+
templates: [
|
|
1109
|
+
{ name: "instructions", content: rawInstructions },
|
|
1110
|
+
{ name: "prompt", content: rawPrompt },
|
|
1111
|
+
],
|
|
1112
|
+
});
|
|
1094
1113
|
const extractWebEvidence = () => {
|
|
1095
1114
|
if (!isRecord(webContextEntry))
|
|
1096
1115
|
return { webUnavailableReason: "webContext missing" };
|
|
@@ -1153,58 +1172,48 @@ export class WorexClientTasks {
|
|
|
1153
1172
|
if (allowWeb)
|
|
1154
1173
|
materialParts.push(webMd || "## Web sources (primary evidence)\n\n[unavailable]");
|
|
1155
1174
|
const perQuestionMaterial = materialParts.join("\n");
|
|
1156
|
-
const userPrompt = buildSynthesisUserPrompt(renderedInstructions, renderedPrompt, perQuestionMaterial, userTemplate);
|
|
1157
1175
|
let synthesisText;
|
|
1158
1176
|
if (allowWeb && !hasWeb && !allowRecord) {
|
|
1159
1177
|
const reason = webEvidence.webUnavailableReason ?? "web scoping unavailable";
|
|
1160
1178
|
synthesisText = `Unknown — web-derived context unavailable (${reason}).`;
|
|
1161
1179
|
}
|
|
1162
1180
|
else if (allowRecord && !hasRecord && !allowWeb) {
|
|
1163
|
-
synthesisText = `Unknown — record-derived context unavailable (missing executionMemory.input
|
|
1181
|
+
synthesisText = `Unknown — record-derived context unavailable (missing executionMemory.input).`;
|
|
1164
1182
|
}
|
|
1165
1183
|
else if (allowRecord && allowWeb && !hasRecord && !hasWeb) {
|
|
1166
1184
|
const reason = webEvidence.webUnavailableReason ?? "web scoping unavailable";
|
|
1167
1185
|
synthesisText =
|
|
1168
|
-
`Unknown — no inputs available (missing executionMemory.input
|
|
1186
|
+
`Unknown — no inputs available (missing executionMemory.input; web unavailable: ${reason}).`;
|
|
1169
1187
|
}
|
|
1170
1188
|
else {
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1189
|
+
const payload = await runStructuredSynthesisGatewayCallRobust({
|
|
1190
|
+
templateCores,
|
|
1191
|
+
question: question.trim(),
|
|
1192
|
+
localMarkdown: perQuestionMaterial,
|
|
1193
|
+
supportingMarkdown: "",
|
|
1194
|
+
renderedInstructions,
|
|
1195
|
+
renderedPrompt,
|
|
1196
|
+
model,
|
|
1197
|
+
timeoutMs,
|
|
1198
|
+
maxOutputLength,
|
|
1199
|
+
outputExpectation: synthLlmCall.outputExpectation,
|
|
1200
|
+
reasoningEffort: synthLlmCall.reasoningEffort,
|
|
1201
|
+
topP: synthLlmCall.topP,
|
|
1202
|
+
executionMode: traceCollector ? "trace" : undefined,
|
|
1177
1203
|
jobId: request.jobId,
|
|
1178
1204
|
taskId: request.taskId,
|
|
1179
1205
|
agentId: request.agentId,
|
|
1180
|
-
workScopeIdentity,
|
|
1181
|
-
|
|
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,
|
|
1206
|
+
identity: workScopeIdentity,
|
|
1207
|
+
gateway: buildPreSynthesisGateway(request),
|
|
1199
1208
|
});
|
|
1200
|
-
synthesisText =
|
|
1209
|
+
synthesisText = buildSynthesizedContextMarkdown(payload);
|
|
1201
1210
|
}
|
|
1202
1211
|
answers[id] = {
|
|
1203
1212
|
question: question.trim(),
|
|
1204
1213
|
source,
|
|
1205
1214
|
synthesis: synthesisText,
|
|
1206
1215
|
evidence: {
|
|
1207
|
-
recordPaths: allowRecord ? ["executionMemory.input
|
|
1216
|
+
recordPaths: allowRecord ? ["executionMemory.input"] : undefined,
|
|
1208
1217
|
webScopeIds: allowWeb ? webEvidence.webScopeIds : undefined,
|
|
1209
1218
|
sources: allowWeb ? webEvidence.sources : undefined,
|
|
1210
1219
|
},
|
|
@@ -1231,148 +1240,85 @@ export class WorexClientTasks {
|
|
|
1231
1240
|
};
|
|
1232
1241
|
}
|
|
1233
1242
|
const synthesisMode = resolveSynthesisMode(config);
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
if (
|
|
1244
|
-
|
|
1245
|
-
|
|
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}`);
|
|
1243
|
+
const parts = sourceMaterialParts;
|
|
1244
|
+
const question = safeResolveSynthesisQuestion(synthesisRequest, config, renderedPrompt);
|
|
1245
|
+
const { templateCores } = discoverTemplateCores({
|
|
1246
|
+
templates: [
|
|
1247
|
+
{ name: "instructions", content: rawInstructions },
|
|
1248
|
+
{ name: "prompt", content: rawPrompt },
|
|
1249
|
+
],
|
|
1250
|
+
});
|
|
1251
|
+
if (templateCores.length === 0) {
|
|
1252
|
+
if (!rawInstructions.trim() && !rawPrompt.trim()) {
|
|
1253
|
+
throw new Error(`structured synthesized-context could not resolve raw instructions/prompt templates for skillKey: ${request.skillKey}. ` +
|
|
1254
|
+
`Ensure ai-skills content registry is available for resolveRawTemplate().`);
|
|
1249
1255
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
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,
|
|
1256
|
+
throw new Error(`structured synthesized-context requires at least one template core token in instructions or prompt. skillKey: ${request.skillKey}`);
|
|
1257
|
+
}
|
|
1258
|
+
const validateOpts = {
|
|
1259
|
+
expectedTemplateCores: templateCores,
|
|
1260
|
+
expectedQuestion: question,
|
|
1261
|
+
maxItemsPerSide: config.structuredMaxItemsPerSide,
|
|
1262
|
+
maxItemContentChars: config.structuredMaxItemContentChars,
|
|
1263
|
+
};
|
|
1264
|
+
try {
|
|
1265
|
+
const custom = getContextSynthesizer();
|
|
1266
|
+
let payload;
|
|
1267
|
+
if (custom) {
|
|
1268
|
+
payload = await custom.synthesize({
|
|
1269
|
+
templateCores,
|
|
1270
|
+
question,
|
|
1271
|
+
localRaw: parts.localMarkdown,
|
|
1272
|
+
supportingRaw: parts.supportingMarkdown,
|
|
1273
|
+
metadata: {
|
|
1281
1274
|
renderedInstructions,
|
|
1282
1275
|
renderedPrompt,
|
|
1283
|
-
|
|
1284
|
-
|
|
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,
|
|
1276
|
+
templateCores,
|
|
1277
|
+
skillKey: request.skillKey,
|
|
1295
1278
|
jobId: request.jobId,
|
|
1296
1279
|
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
1280
|
},
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
templateCores,
|
|
1314
|
-
}),
|
|
1315
|
-
synthesizedContextLlmCalls: traceCollector ? synthLlmCalls : undefined,
|
|
1316
|
-
};
|
|
1281
|
+
});
|
|
1282
|
+
payload = normalizeAndValidateSynthesizedPayload(payload, validateOpts);
|
|
1317
1283
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1284
|
+
else {
|
|
1285
|
+
payload = await runStructuredSynthesisGatewayCallRobust({
|
|
1286
|
+
templateCores,
|
|
1287
|
+
question,
|
|
1288
|
+
localMarkdown: parts.localMarkdown,
|
|
1289
|
+
supportingMarkdown: parts.supportingMarkdown,
|
|
1290
|
+
renderedInstructions,
|
|
1291
|
+
renderedPrompt,
|
|
1292
|
+
templatesBasePath: config.templatesBasePath,
|
|
1293
|
+
synthesisPromptOverride: config.synthesisPromptOverride,
|
|
1294
|
+
customSynthesizingGuidelines: config.customSynthesizingGuidelines,
|
|
1295
|
+
model: model,
|
|
1296
|
+
timeoutMs: timeoutMs,
|
|
1297
|
+
maxOutputLength: maxOutputLength,
|
|
1298
|
+
// Caller-supplied outputExpectation overrides the per-action default in the structured-repair path.
|
|
1299
|
+
outputExpectation: synthLlmCall.outputExpectation,
|
|
1300
|
+
reasoningEffort: synthLlmCall.reasoningEffort,
|
|
1301
|
+
topP: synthLlmCall.topP,
|
|
1302
|
+
// Forward trace mode so the structured gateway returns a `debugTrace` (lifted into observations elsewhere).
|
|
1303
|
+
executionMode: traceCollector ? "trace" : undefined,
|
|
1304
|
+
jobId: request.jobId,
|
|
1305
|
+
taskId: request.taskId,
|
|
1306
|
+
agentId: request.agentId,
|
|
1307
|
+
identity: workScopeIdentity,
|
|
1308
|
+
gateway: buildPreSynthesisGateway(request),
|
|
1309
|
+
});
|
|
1325
1310
|
}
|
|
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
|
-
});
|
|
1311
|
+
const contextMarkdown = buildSynthesizedContextMarkdown(payload);
|
|
1366
1312
|
return {
|
|
1367
1313
|
contextMarkdown,
|
|
1368
1314
|
artifact: {
|
|
1369
1315
|
templateCores,
|
|
1370
1316
|
question,
|
|
1371
|
-
mode:
|
|
1372
|
-
payload
|
|
1317
|
+
mode: synthesisMode,
|
|
1318
|
+
payload,
|
|
1373
1319
|
contextMarkdown,
|
|
1374
1320
|
},
|
|
1375
|
-
synthesizedInput: buildSynthesizedInputArtifact(
|
|
1321
|
+
synthesizedInput: buildSynthesizedInputArtifact(synthesisMode, sourceMaterial, parts, {
|
|
1376
1322
|
question,
|
|
1377
1323
|
templateCores,
|
|
1378
1324
|
}),
|