@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.
- package/CHANGELOG.md +34 -4
- package/README.md +2 -2
- package/RUNTASK_REQUEST.md +32 -17
- package/dist/builders/task-request-builder.d.ts.map +1 -1
- package/dist/builders/task-request-builder.js +2 -1
- package/dist/builders/task-request-builder.js.map +1 -1
- 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 +148 -180
- package/dist/core/task-sdk.js.map +1 -1
- package/dist/errors/runTaskExecutionError.d.ts.map +1 -1
- package/dist/errors/runTaskExecutionError.js +0 -2
- package/dist/errors/runTaskExecutionError.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/invocation/types.d.ts +1 -1
- package/dist/narrix/applyWebScopeToRequest.d.ts +9 -0
- package/dist/narrix/applyWebScopeToRequest.d.ts.map +1 -0
- package/dist/narrix/applyWebScopeToRequest.js +156 -0
- package/dist/narrix/applyWebScopeToRequest.js.map +1 -0
- package/dist/narrix/narrixUnitExecution.d.ts.map +1 -1
- package/dist/narrix/narrixUnitExecution.js +8 -3
- package/dist/narrix/narrixUnitExecution.js.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.d.ts +6 -0
- package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.js +4 -16
- 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/createNodeExecutionHost.d.ts.map +1 -1
- package/dist/node-execution/createNodeExecutionHost.js +97 -26
- package/dist/node-execution/createNodeExecutionHost.js.map +1 -1
- package/dist/node-execution/dispatchExecutionUnit.d.ts.map +1 -1
- package/dist/node-execution/dispatchExecutionUnit.js +4 -2
- package/dist/node-execution/dispatchExecutionUnit.js.map +1 -1
- package/dist/node-execution/orchestration/runPostOrchestration.d.ts +11 -0
- package/dist/node-execution/orchestration/runPostOrchestration.d.ts.map +1 -0
- package/dist/node-execution/orchestration/runPostOrchestration.js +123 -0
- package/dist/node-execution/orchestration/runPostOrchestration.js.map +1 -0
- package/dist/node-execution/orchestration/runPreOrchestration.d.ts +3 -0
- package/dist/node-execution/orchestration/runPreOrchestration.d.ts.map +1 -0
- package/dist/node-execution/orchestration/runPreOrchestration.js +110 -0
- package/dist/node-execution/orchestration/runPreOrchestration.js.map +1 -0
- package/dist/node-execution/orchestration/shardContext.d.ts +12 -0
- package/dist/node-execution/orchestration/shardContext.d.ts.map +1 -0
- package/dist/node-execution/orchestration/shardContext.js +71 -0
- package/dist/node-execution/orchestration/shardContext.js.map +1 -0
- package/dist/node-execution/orchestration/types.d.ts +21 -0
- package/dist/node-execution/orchestration/types.d.ts.map +1 -0
- package/dist/node-execution/orchestration/types.js +2 -0
- package/dist/node-execution/orchestration/types.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/observability/classifyRunTaskFailure.d.ts.map +1 -1
- package/dist/observability/classifyRunTaskFailure.js +4 -3
- package/dist/observability/classifyRunTaskFailure.js.map +1 -1
- package/dist/observability/logRunTaskFailure.d.ts.map +1 -1
- package/dist/observability/logRunTaskFailure.js +0 -2
- package/dist/observability/logRunTaskFailure.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/synthesis/runStructuredSynthesisRobust.d.ts.map +1 -1
- package/dist/synthesis/runStructuredSynthesisRobust.js +24 -4
- package/dist/synthesis/runStructuredSynthesisRobust.js.map +1 -1
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.d.ts +3 -0
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.d.ts.map +1 -1
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.js +28 -4
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.js.map +1 -1
- package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts +4 -4
- package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts.map +1 -1
- package/dist/task-strategies/canonicalInputExecutionStrategies.js +2 -1
- package/dist/task-strategies/canonicalInputExecutionStrategies.js.map +1 -1
- package/dist/task-strategies/canonicalOrchestrationStrategies.d.ts +42 -0
- package/dist/task-strategies/canonicalOrchestrationStrategies.d.ts.map +1 -0
- package/dist/task-strategies/canonicalOrchestrationStrategies.js +47 -0
- package/dist/task-strategies/canonicalOrchestrationStrategies.js.map +1 -0
- package/dist/task-strategies/canonicalTaskStrategies.d.ts +2 -1
- package/dist/task-strategies/canonicalTaskStrategies.d.ts.map +1 -1
- package/dist/task-strategies/canonicalTaskStrategies.js +2 -1
- package/dist/task-strategies/canonicalTaskStrategies.js.map +1 -1
- package/dist/task-strategies/constants.d.ts +9 -1
- package/dist/task-strategies/constants.d.ts.map +1 -1
- package/dist/task-strategies/constants.js +9 -1
- package/dist/task-strategies/constants.js.map +1 -1
- package/dist/task-strategies/index.d.ts +5 -3
- package/dist/task-strategies/index.d.ts.map +1 -1
- package/dist/task-strategies/index.js +4 -3
- package/dist/task-strategies/index.js.map +1 -1
- package/dist/task-strategies/listAiTaskStrategies.d.ts +10 -1
- package/dist/task-strategies/listAiTaskStrategies.d.ts.map +1 -1
- package/dist/task-strategies/listAiTaskStrategies.js +17 -2
- package/dist/task-strategies/listAiTaskStrategies.js.map +1 -1
- package/dist/types/task-types.d.ts +4 -11
- 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/resolveRunTaskModelReferences.d.ts.map +1 -1
- package/dist/utils/resolveRunTaskModelReferences.js +0 -32
- package/dist/utils/resolveRunTaskModelReferences.js.map +1 -1
- package/dist/utils/runTaskRequestShape.d.ts.map +1 -1
- package/dist/utils/runTaskRequestShape.js +4 -26
- package/dist/utils/runTaskRequestShape.js.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 +3 -66
- 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/skill-orchestration-strategy-cr-fr.md +147 -0
- 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
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
# Pre-Task component — **builder guide** (single entry for implementation)
|
|
2
|
-
|
|
3
|
-
Use this file plus the linked handler specs. **Full** platform rules (Activix field shapes, identity merge algorithm): [`../integration/platform.md`](../integration/platform.md).
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. What you are building
|
|
8
|
-
|
|
9
|
-
A **Pre-Task engine** that runs **before MAIN** and returns:
|
|
10
|
-
|
|
11
|
-
- Possibly updated `jobMemory` / `taskMemory` / `executionMemory` / `input`
|
|
12
|
-
- Optional **`contextMarkdown`** override for the MAIN skill prompt
|
|
13
|
-
- Optional **`synthesizedContext`** artifact on `executionMemory`
|
|
14
|
-
- **`intermediateSteps`** for observability
|
|
15
|
-
|
|
16
|
-
**Protocol:** [`unified-protocol.md`](unified-protocol.md).
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## 2. Stack (minimum you must honor)
|
|
21
|
-
|
|
22
|
-
| Topic | Rule |
|
|
23
|
-
|-------|------|
|
|
24
|
-
| LLM calls | **aifunctions-js** (`ask` / compatible client). Not a separate ai-gateway product API. |
|
|
25
|
-
| Synthesized-context step | **@athenices/xynthesis** for templates, modes, validation; **SynthesisInvoker** calls aifunctions-js. |
|
|
26
|
-
| Observability | **Activix** phase records where the host enables it; top-level **`identity`** on every record per `docs/activix-identity.md`. |
|
|
27
|
-
| Correlation | Prefer **`correlationId === taskId`** for one run. |
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## 3. NPM dependencies (pin to tested versions from `@woroces/ai-tasks`)
|
|
32
|
-
|
|
33
|
-
| Package | Role in pre paths |
|
|
34
|
-
|---------|-------------------|
|
|
35
|
-
| `aifunctions-js` | All generative calls (scoping, System-2, synthesis invoker). |
|
|
36
|
-
| `@athenices/xynthesis` | Synthesized-context PRE handler. |
|
|
37
|
-
| `@woroces/ai-skills` | `enrichMemoriesWithScoping`, `resolveRawTemplate`, executor (host). |
|
|
38
|
-
| `@woroces/memory-narrix-adapter` | `adaptMemoryToNarrixInput` (narrix preprocessor). |
|
|
39
|
-
| `@narrices/narrix-*` | Ingest, adapters, runner, packs, web-scoper (see `package.json` of ai-tasks). |
|
|
40
|
-
| `@xronoces/activix` | Phase recording (with host wrapper). |
|
|
41
|
-
|
|
42
|
-
Also used indirectly: `handlebars` (if you render web scope templates in-host).
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 4. Host contract (skills / task runtime)
|
|
47
|
-
|
|
48
|
-
The pre engine **does not** replace the skills client. The host must provide:
|
|
49
|
-
|
|
50
|
-
| Capability | Used by |
|
|
51
|
-
|------------|---------|
|
|
52
|
-
| `enrichMemoriesWithScoping(skillKey, "task", memoryBundle)` | Synthesis PRE, direct-path enrich (same as today). |
|
|
53
|
-
| `resolveRawTemplate(skillKey, "instructions" \| "prompt")` → raw markdown | Structured synthesis + template cores. |
|
|
54
|
-
| Optional: same client’s `generateContextMarkdown` / executor | After pre returns, MAIN still runs in host. |
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## 5. Request fields this engine reads (`RunTaskRequest`)
|
|
59
|
-
|
|
60
|
-
| Field | Handler |
|
|
61
|
-
|-------|---------|
|
|
62
|
-
| `narrix?: NarrixPreProcessorConfig` | [`handler-narrix-preprocessor.md`](handler-narrix-preprocessor.md) |
|
|
63
|
-
| `executionPipeline` with PRE `synthesized-context` | [`handler-synthesized-context.md`](handler-synthesized-context.md) |
|
|
64
|
-
| `aiScoping?: AIScopingInstruction[]` | [`handler-ai-scoping.md`](handler-ai-scoping.md) |
|
|
65
|
-
| `includeContextInPrompt`, `taskMemory`, `jobMemory`, `executionMemory`, `skillKey`, `input`, `identity`, `jobId`, `agentId` | Multiple |
|
|
66
|
-
|
|
67
|
-
**Note:** `executionType: narrix-then-direct` + `narrixInput` is a **different** flow (Narrix then MAIN with `taskMemory.narrix`); it still uses `narrixRunHandler` and is **host-orchestrated** in `task-sdk.ts`. If your pre package only covers “pipeline + scoping + narrix preprocessor”, document whether `narrix-then-direct` stays in the host.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## 6. Environment variables (pre-relevant)
|
|
72
|
-
|
|
73
|
-
| Variable | Handler / area |
|
|
74
|
-
|----------|----------------|
|
|
75
|
-
| `AI_SCOPING_MODEL`, `AI_SCOPING_CONCURRENCY`, `AI_SCOPING_TIMEOUT_MS` | AI scoping |
|
|
76
|
-
| `SYNTHESIS_MODEL`, `SYNTHESIS_TIMEOUT_MS`, `SYNTHESIS_MAX_OUTPUT_LENGTH` | Synthesis PRE |
|
|
77
|
-
| `NARRIX_SYSTEM2_MODE`, `NARRIX_SYSTEM2_MODEL`, `NARRIX_SYSTEM2_MAX_ITERATIONS`, `NARRIX_SYSTEM2_ENABLE_WRITES`, `NARRIX_SYSTEM2_SAVE_ARTIFACTS`, `NARRIX_SYSTEM2_ARTIFACT_DIR`, … | System-2 |
|
|
78
|
-
| `TAVILY_API_KEY` | Web scope (default search) |
|
|
79
|
-
| `MONGO_LOGS_DB` | Default `bindingDefaultsDb` merged into `execution` (current SDK behavior) |
|
|
80
|
-
|
|
81
|
-
Centralize in one config module in your package.
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## 7. Source file manifest (current `ai-tasks`)
|
|
86
|
-
|
|
87
|
-
Copy or depend on these paths when extracting:
|
|
88
|
-
|
|
89
|
-
| Path | Notes |
|
|
90
|
-
|------|--------|
|
|
91
|
-
| `src/aiScoping/*` | Scoping + `validateAiScoping.ts` |
|
|
92
|
-
| `src/internal/runLlmTextCall.ts` | Shared LLM primitive |
|
|
93
|
-
| `src/synthesis/resolveSourceMaterial.ts`, `synthesisGatewayCompat.ts`, `index.ts` | Synthesis wiring + xynthesis re-exports |
|
|
94
|
-
| `src/narrix/**` except tests | Narrix run, web scoper, system2, context markdown builders |
|
|
95
|
-
| `src/utils/jsonPaths.ts` | `getByPath` for scoping sources |
|
|
96
|
-
| `src/types/task-types.ts` | Types listed in handler docs |
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## 8. Definition of done (acceptance)
|
|
101
|
-
|
|
102
|
-
- [ ] Handlers run in order: narrix preprocessor (if any) → pipeline PRE synthesized-context (if any) → (host) enrich → ai scoping (if any).
|
|
103
|
-
- [ ] Synthesis: markdown + structured modes behave per [`handler-synthesized-context.md`](handler-synthesized-context.md); `fallbackToDirect` respected.
|
|
104
|
-
- [ ] Scoping: parallel bounded concurrency; missing paths skipped; validation before LLM.
|
|
105
|
-
- [ ] Web scope: never throws to caller; `webContext` optional on `executionMemory`.
|
|
106
|
-
- [ ] System-2: PatchPlan JSON validated; iteration cap enforced.
|
|
107
|
-
- [ ] Activix + `identity` on each recorded phase when host passes client.
|
|
108
|
-
- [ ] Test hooks: scoping / synthesis / llmPlan / web scoper injectable.
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## 9. Types (canonical source)
|
|
113
|
-
|
|
114
|
-
Implementations should align with **`src/types/task-types.ts`**: `AIScopingInstruction`, `AIScopedItem`, `SynthesisConfig`, `SynthesizedContextArtifact`, `ContextSourcePolicy`, `WebEvidenceConfig`, `ExecutionStep`, `NarrixPreProcessorConfig`, `IntermediateStep`, and pipeline constants (`SYNTHESIZED_CONTEXT`). Re-export or depend on a shared types package when splitting repos.
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## 10. Read next
|
|
119
|
-
|
|
120
|
-
1. [`unified-protocol.md`](unified-protocol.md)
|
|
121
|
-
2. [`handler-narrix-preprocessor.md`](handler-narrix-preprocessor.md)
|
|
122
|
-
3. [`handler-synthesized-context.md`](handler-synthesized-context.md)
|
|
123
|
-
4. [`handler-ai-scoping.md`](handler-ai-scoping.md)
|
|
124
|
-
5. [`handler-web-scope.md`](handler-web-scope.md)
|
|
125
|
-
6. [`handler-narrix-system2.md`](handler-narrix-system2.md)
|
|
126
|
-
7. [`gaps-and-artifacts.md`](gaps-and-artifacts.md)
|
|
127
|
-
8. Merge / shared checklist: [`../integration/roadmap-and-checklists.md`](../integration/roadmap-and-checklists.md) Phase B, [`../integration/reintegrate-into-ai-tasks.md`](../integration/reintegrate-into-ai-tasks.md)
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Pre-Task component — gaps, code, templates
|
|
2
|
-
|
|
3
|
-
What is **missing, external, or optional to add** when packaging the pre engine. **Behavior, env tables, dependencies, acceptance:** [`builder-guide.md`](builder-guide.md).
|
|
4
|
-
|
|
5
|
-
## Code modules (current `ai-tasks` anchors)
|
|
6
|
-
|
|
7
|
-
| Area | Paths / packages | Note |
|
|
8
|
-
|------|------------------|------|
|
|
9
|
-
| AI scoping | `src/aiScoping/*` (incl. `validateAiScoping.ts`) | Depends on `src/internal/runLlmTextCall.ts`. |
|
|
10
|
-
| Synthesis source wiring | `src/synthesis/resolveSourceMaterial.ts`, `synthesisGatewayCompat.ts` | Re-export surface: `src/synthesis/index.ts` → **@athenices/xynthesis**. |
|
|
11
|
-
| Narrix pre + web | `src/narrix/*` (large), `task-sdk` orchestration | System-1 ingest lives largely in **external** Narrix packages. |
|
|
12
|
-
| System-2 | `src/narrix/system2/*` | Tied to `runLlmTextCall`. |
|
|
13
|
-
| Types | `src/types/task-types.ts` (`AIScoping*`, `SynthesisConfig`, pipeline types) | May need a shared types package when extracting. |
|
|
14
|
-
|
|
15
|
-
## Templates & assets
|
|
16
|
-
|
|
17
|
-
| Asset | Status in repo | Action for standalone pre package |
|
|
18
|
-
|-------|----------------|-------------------------------------|
|
|
19
|
-
| Synthesis markdown templates | Loaded via **@athenices/xynthesis** `loadSynthesisTemplates()` | Confirm templates ship **inside** xynthesis or **vendor** copies into the pre package; audit/polish disk templates belong in **post** spec only. |
|
|
20
|
-
| Skill instructions/prompt | **@woroces/ai-skills** `resolveRawTemplate` | Pre component needs a **host callback**; not bundled in pre-only package. |
|
|
21
|
-
| AI scoping | **No** separate disk template — prompts inline in `runScopingCall.ts` | Optional: externalize to `templates/pre/scoping-system.md` for versioning. |
|
|
22
|
-
| Narrix System-2 | System prompt **inline** in `llmPlan.ts` | Optional: externalize for tuning without code change. |
|
|
23
|
-
|
|
24
|
-
## Environment variables
|
|
25
|
-
|
|
26
|
-
Canonical table: [`builder-guide.md`](builder-guide.md) §6.
|
|
27
|
-
|
|
28
|
-
## Tests / DI hooks to preserve
|
|
29
|
-
|
|
30
|
-
`setScopingGateway`, `setSynthesisInvoker` / `setSynthesisGateway`, `setLlmPlanGateway`, `setWebScoperForTesting` — or equivalent constructor injection in a new package.
|
|
31
|
-
|
|
32
|
-
## Open decisions
|
|
33
|
-
|
|
34
|
-
- Whether **narrix-preprocessor** ships inside pre package or stays a **peer** dependency.
|
|
35
|
-
- Single **Activix** wrapper module shared with post (owned under integration / shared lib).
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Handler: AI memory scoping (`direct.ai-scoping`)
|
|
2
|
-
|
|
3
|
-
> **Platform:** LLM + Activix + `identity` — [`../integration/platform.md`](../integration/platform.md).
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
Before MAIN, optionally turn memory slices into concise text. Each instruction is one LLM call over **only** resolved source content; results merge into `input.aiScoped[]`.
|
|
8
|
-
|
|
9
|
-
## Trigger (current repo)
|
|
10
|
-
|
|
11
|
-
- `RunTaskRequest.aiScoping?: AIScopingInstruction[]`
|
|
12
|
-
- After enrich, before `executor.execute` in `_executeDirect` (`src/core/task-sdk.ts`).
|
|
13
|
-
- Code: `src/aiScoping/runAiScoping.ts`, `runScopingCall.ts`.
|
|
14
|
-
|
|
15
|
-
## Inputs
|
|
16
|
-
|
|
17
|
-
| Field | Notes |
|
|
18
|
-
|--------|--------|
|
|
19
|
-
| Bundle | `jobMemory` / `taskMemory` / `executionMemory`; paths via `getByPath`. |
|
|
20
|
-
| Instructions | `source`, `instructions` (NL), `targetToken` per item. |
|
|
21
|
-
| Concurrency / timeout | Defaults 5 workers, 30s/item; env `AI_SCOPING_*`. |
|
|
22
|
-
|
|
23
|
-
Skipped if source path missing (no error). `validateAiScoping` before calls.
|
|
24
|
-
|
|
25
|
-
## Single call (`runScopingCall`)
|
|
26
|
-
|
|
27
|
-
- Fixed system: use only source, no invention, plain text, no markdown fences.
|
|
28
|
-
- User: `Instructions:\n…\n\nSource content:\n…` (serialized value).
|
|
29
|
-
- `runLlmTextCall`: temp 0.2, maxTokens 2048; test hook `setScopingGateway`.
|
|
30
|
-
|
|
31
|
-
## Orchestration (`runAiScoping`)
|
|
32
|
-
|
|
33
|
-
Bounded parallel workers; failures → omit that item (tolerant).
|
|
34
|
-
|
|
35
|
-
## Output
|
|
36
|
-
|
|
37
|
-
`AIScopedItem[]` → merged into object `input` as `aiScoped`.
|
|
38
|
-
|
|
39
|
-
## Non-goals
|
|
40
|
-
|
|
41
|
-
Not full RAG; chunks are independent. No automatic memory writeback.
|
|
42
|
-
|
|
43
|
-
## Types
|
|
44
|
-
|
|
45
|
-
`AIScopingInstruction`, `AIScopedItem` — `src/types/task-types.ts`.
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# Handler: Narrix preprocessor (`narrix-preprocessor`)
|
|
2
|
-
|
|
3
|
-
> **Platform:** [`../integration/platform.md`](../integration/platform.md).
|
|
4
|
-
> **Sub-steps:** [`handler-web-scope.md`](handler-web-scope.md), [`handler-narrix-system2.md`](handler-narrix-system2.md) (inside `narrixRunHandler`).
|
|
5
|
-
|
|
6
|
-
## Purpose
|
|
7
|
-
|
|
8
|
-
When `RunTaskRequest.narrix` is set, adapt task memory to a **Narrix run input**, execute **`narrixRunHandler`** (local skill `skills/skill.local:narrixRun`), attach enrichment to **`executionMemory`** and **`jobMemory`**, optionally fetch **web evidence**.
|
|
9
|
-
|
|
10
|
-
## Trigger (current repo)
|
|
11
|
-
|
|
12
|
-
- `request.narrix` present → phase `narrix` in `task-sdk.ts` before local-task dispatch and pipeline.
|
|
13
|
-
- Uses `adaptMemoryToNarrixInput` from `@woroces/memory-narrix-adapter` with path preferences (`executionMemory.input.raw`, `jobMemory.currentRecord`, …).
|
|
14
|
-
- Failure to adapt → **throw** (strict). Narrix run `ok: false` → **throw**.
|
|
15
|
-
|
|
16
|
-
## Config (`NarrixPreProcessorConfig`) — fields builders need
|
|
17
|
-
|
|
18
|
-
| Field | Role |
|
|
19
|
-
|-------|------|
|
|
20
|
-
| `datasetId` | Required. |
|
|
21
|
-
| `attachToField` | Default `_narrix`; where attachment lives on `executionMemory`. |
|
|
22
|
-
| `deterministicSort` | Default true (narrative ordering). |
|
|
23
|
-
| `enableWebScope` | After success, call web scoper → `executionMemory.webContext`. |
|
|
24
|
-
| `webScopeTemplates`, `webScopeQuestionTemplate`, `webScopeObjects`, `webScoping` | Web query shaping (see `NarrixPreProcessorConfig` in `task-types.ts`). |
|
|
25
|
-
| `engineConfigPath`, `packsRoot`, `assumptionsPolicy` | Reserved / future. |
|
|
26
|
-
|
|
27
|
-
Full interface: `src/types/task-types.ts`.
|
|
28
|
-
|
|
29
|
-
## Success path (summary)
|
|
30
|
-
|
|
31
|
-
1. `adaptMemoryToNarrixInput(...)` → `narrixInput`.
|
|
32
|
-
2. `narrixRunHandler({ input, ctx })` with skill/job/graph ids from request.
|
|
33
|
-
3. `buildNarrixAttachment(success)` → store under `executionMemory[attachToField]` and `jobMemory._narrix` (current behavior).
|
|
34
|
-
4. If `enableWebScope`: `resolveWebScopeQuestionAndTemplates` + `runWebScope` → merge `webContext` (lenient).
|
|
35
|
-
|
|
36
|
-
## Related execution mode
|
|
37
|
-
|
|
38
|
-
**`narrix-then-direct`** uses resolved `narrixInput` + `narrixRunHandler` + `applyNarrixScope` and writes **`taskMemory.narrix`** — different injection shape. Implement either in the same package behind flags or document as **host-only** if out of scope.
|
|
39
|
-
|
|
40
|
-
## Code anchors
|
|
41
|
-
|
|
42
|
-
- `src/core/task-sdk.ts` (narrix block)
|
|
43
|
-
- `src/narrix/task.ts` (`narrixRunHandler`)
|
|
44
|
-
- `src/narrix/buildNarrixAttachment.ts`, `buildWebScopeScopeInput`, `webScoper.ts`
|
|
45
|
-
- `src/activix/phaseTracking.ts` (`withPhaseRecord`)
|
|
46
|
-
|
|
47
|
-
## Dependencies
|
|
48
|
-
|
|
49
|
-
Narrix ingest/runner/packs packages; `NARRIX_DISABLED` / flags in `src/narrix/flags.ts` may disable behavior.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Sub-handler: Narrix System-2 LLM patch plan
|
|
2
|
-
|
|
3
|
-
> **Platform:** [`../integration/platform.md`](../integration/platform.md).
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
After Narrix System-1, optionally detect gaps and call an LLM for **PatchPlan** JSON (routing/schema actions), apply patches, optionally re-run System-1.
|
|
8
|
-
|
|
9
|
-
## Trigger (current repo)
|
|
10
|
-
|
|
11
|
-
- `narrixRunHandler` → `runWithSystem2` (`src/narrix/system2/runWithSystem2.ts`)
|
|
12
|
-
- LLM: `llmPlan` (`src/narrix/system2/llmPlan.ts`)
|
|
13
|
-
- Env/options: `NARRIX_SYSTEM2_MODE`, `maxIterations`, `enableWrites`, `model`, etc.
|
|
14
|
-
|
|
15
|
-
## LLM I/O
|
|
16
|
-
|
|
17
|
-
- User content from `buildSystem2Input(input, result, gapHints)`.
|
|
18
|
-
- System: PatchPlan JSON only; allowed action types defined in code (`rememberDatasetPackRouting`, …).
|
|
19
|
-
- Parse: `extractJsonFromText` + `validatePatchPlan`.
|
|
20
|
-
|
|
21
|
-
## Invocation
|
|
22
|
-
|
|
23
|
-
`runLlmTextCall`: temp 0.2, maxTokens 8192; `setLlmPlanGateway` for tests.
|
|
24
|
-
|
|
25
|
-
## Post-LLM
|
|
26
|
-
|
|
27
|
-
`applyPatchPlan`, optional `writeArtifacts`, rerun loop under `maxIterations`.
|
|
28
|
-
|
|
29
|
-
## Non-goals
|
|
30
|
-
|
|
31
|
-
Not a general agent; closed action set. Does not replace System-1 ingest (external packages).
|
|
32
|
-
|
|
33
|
-
## Dependencies (repo)
|
|
34
|
-
|
|
35
|
-
`src/narrix/system2/*`, `src/internal/runLlmTextCall.ts`
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Handler: synthesized context (`pipeline.synthesized-context`)
|
|
2
|
-
|
|
3
|
-
> **Platform:** **@athenices/xynthesis** for synthesis contracts; **aifunctions-js** inside `SynthesisInvoker`; Activix + `identity` — [`../integration/platform.md`](../integration/platform.md) §1b.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
PRE pipeline step: build markdown **context** for MAIN from memory, Narrix attachment, optional web evidence, and rendered skill templates. Modes: **markdown** completion vs **structured** synthesis (cores + validation).
|
|
8
|
-
|
|
9
|
-
## Trigger (current repo)
|
|
10
|
-
|
|
11
|
-
- `executionPipeline`: `{ phase: "pre", type: "synthesized-context", config?: SynthesisConfig }`
|
|
12
|
-
- Requires `includeContextInPrompt === true` or `config.autoEnableContext === true`
|
|
13
|
-
- `WorexClientTasks._runSynthesizedContextPreStep` in `src/core/task-sdk.ts`
|
|
14
|
-
|
|
15
|
-
## Orchestration (high level)
|
|
16
|
-
|
|
17
|
-
1. Merge `executionMemory` into `jobMemory.execution` (incl. `bindingDefaultsDb` default).
|
|
18
|
-
2. `enrichMemoriesWithScoping(skillKey, "task", memoryBundle)`.
|
|
19
|
-
3. Cleanse `execution` for prompts.
|
|
20
|
-
4. Narrix-shaped attachment from `executionMemory[attachToField]` or `taskMemory.narrix`.
|
|
21
|
-
5. `buildSynthesizerInputMaterial` (**@athenices/xynthesis** + host `resolveSourceMaterial*`).
|
|
22
|
-
6. `getRenderedTemplates` (skill raw templates + placeholders).
|
|
23
|
-
7. Branch: markdown vs structured (below).
|
|
24
|
-
8. Optional `SynthesizedContextArtifact` on `executionMemory.synthesizedContext`.
|
|
25
|
-
|
|
26
|
-
`fallbackToDirect` → empty context instead of throw on materialization failure (when enabled).
|
|
27
|
-
|
|
28
|
-
## Mode A — Markdown
|
|
29
|
-
|
|
30
|
-
- `loadSynthesisTemplates`, `buildSynthesisSystemPrompt`, `runSynthesisCall` from **@athenices/xynthesis**.
|
|
31
|
-
- Defaults: model from config → `SYNTHESIS_MODEL` → `gpt-5-nano`; timeout `SYNTHESIS_TIMEOUT_MS` / 30_000.
|
|
32
|
-
|
|
33
|
-
## Mode B — Structured
|
|
34
|
-
|
|
35
|
-
- Parts: `localMarkdown` / `supportingMarkdown`; `resolveSynthesisQuestion`; `discoverTemplateCores`.
|
|
36
|
-
- Custom path: `getContextSynthesizer()` if set; else `runStructuredSynthesisGatewayCall`.
|
|
37
|
-
- Output: `buildSynthesizedContextMarkdown(payload)`.
|
|
38
|
-
|
|
39
|
-
## Xynthesis vs aifunctions-js (single definition)
|
|
40
|
-
|
|
41
|
-
| Layer | Role |
|
|
42
|
-
|-------|------|
|
|
43
|
-
| **@athenices/xynthesis** | Templates, modes, validation, artifact types, `setSynthesisInvoker`. |
|
|
44
|
-
| **aifunctions-js** | Implement invoker with `client.ask` (or shared helper). |
|
|
45
|
-
|
|
46
|
-
## Testing / migration
|
|
47
|
-
|
|
48
|
-
- `setSynthesisInvoker` (preferred).
|
|
49
|
-
- Legacy: `src/synthesis/synthesisGatewayCompat.ts` → `setSynthesisGateway` for `invoke`-shaped mocks only.
|
|
50
|
-
|
|
51
|
-
## Downstream
|
|
52
|
-
|
|
53
|
-
MAIN uses `overrideContext`; `synthesisContextAuthoritative` blocks Narrix/web fill-in when empty. POST audit/polish use captured context markdown.
|
|
54
|
-
|
|
55
|
-
## Config surface
|
|
56
|
-
|
|
57
|
-
`SynthesisConfig`: `modelConfig`, `timeoutMs`, `maxOutputLength`, `synthesisInputStrategy`, `contextSourcePolicy`, `memoryPaths`, `webEvidence`, `fallbackToDirect`, structured limits, prompt overrides, mode.
|
|
58
|
-
|
|
59
|
-
## Risks
|
|
60
|
-
|
|
61
|
-
Structured mode needs `resolveRawTemplate` / registry; missing templates → errors unless fallback.
|
|
62
|
-
|
|
63
|
-
## Repo anchors
|
|
64
|
-
|
|
65
|
-
`src/synthesis/resolveSourceMaterial.ts`, `src/synthesis/synthesisGatewayCompat.ts`, `src/synthesis/index.ts` (re-exports xynthesis).
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Sub-step: Web scope / evidence (Narrix add-on)
|
|
2
|
-
|
|
3
|
-
> **Platform:** Activix + `identity` for phases; no generative LLM here — [`../integration/platform.md`](../integration/platform.md).
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
After a successful Narrix pre-processor run, optionally fetch search-backed evidence into `executionMemory.webContext` for synthesis / MAIN.
|
|
8
|
-
|
|
9
|
-
## Trigger (current repo)
|
|
10
|
-
|
|
11
|
-
- `request.narrix.enableWebScope === true`
|
|
12
|
-
- `resolveWebScopeQuestionAndTemplates` + `runWebScope` in `src/narrix/webScoper.ts`, called from `task-sdk.ts`.
|
|
13
|
-
|
|
14
|
-
## Stack
|
|
15
|
-
|
|
16
|
-
- `createWebScoper` + `createSearchAdapter` (Tavily + `TAVILY_API_KEY` default).
|
|
17
|
-
- Errors → `{ available: false, reason: "error", error }` (no throw).
|
|
18
|
-
|
|
19
|
-
## Testing
|
|
20
|
-
|
|
21
|
-
`setWebScoperForTesting`, `resetWebScoperSingleton`.
|
|
22
|
-
|
|
23
|
-
## Relation to synthesis
|
|
24
|
-
|
|
25
|
-
`SynthesisConfig.webEvidence` / `resolveSourceMaterial*` may consume `webContext` from memory.
|
|
26
|
-
|
|
27
|
-
## Dependencies
|
|
28
|
-
|
|
29
|
-
`@narrices/narrix-web-scoper`, `@narrices/search-adapter`
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# Pre-Task component — unified protocol
|
|
2
|
-
|
|
3
|
-
> **Scope:** Target architecture only; not a mandate to change `ai-tasks` code until you choose to.
|
|
4
|
-
> **Shared platform (aifunctions-js, Activix, identity, Xynthesis):** single source of truth is [`../integration/platform.md`](../integration/platform.md).
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Goal
|
|
9
|
-
|
|
10
|
-
One **Pre-Task engine** that:
|
|
11
|
-
|
|
12
|
-
- Accepts a standard **input envelope** (task request, skills client, memory, optional Activix + correlation + identity).
|
|
13
|
-
- Runs an **ordered chain** of handlers sharing one protocol.
|
|
14
|
-
- Produces **patches** to request/memory/input, optional **context override** for MAIN, optional **synthesis artifact**, and **intermediate steps**.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Handler protocol (conceptual)
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
type PreHandlerId =
|
|
22
|
-
| "narrix-preprocessor"
|
|
23
|
-
| "pipeline.synthesized-context"
|
|
24
|
-
| "direct.ai-scoping";
|
|
25
|
-
|
|
26
|
-
interface PreHandlerContext {
|
|
27
|
-
request: RunTaskRequest;
|
|
28
|
-
identity?: Record<string, unknown>;
|
|
29
|
-
memoryBundle?: unknown;
|
|
30
|
-
skillsClient?: unknown;
|
|
31
|
-
correlationId?: string;
|
|
32
|
-
activix?: unknown;
|
|
33
|
-
prior: {
|
|
34
|
-
contextMarkdownOverride?: string;
|
|
35
|
-
synthesisContextAuthoritative?: boolean;
|
|
36
|
-
executionMemoryPatch?: Record<string, unknown>;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface PreHandlerResult {
|
|
41
|
-
ok: boolean;
|
|
42
|
-
patches?: {
|
|
43
|
-
jobMemory?: Record<string, unknown>;
|
|
44
|
-
taskMemory?: Record<string, unknown>;
|
|
45
|
-
executionMemory?: Record<string, unknown>;
|
|
46
|
-
input?: unknown;
|
|
47
|
-
};
|
|
48
|
-
contextMarkdownOverride?: string;
|
|
49
|
-
synthesisContextAuthoritative?: boolean;
|
|
50
|
-
artifact?: unknown;
|
|
51
|
-
intermediateSteps?: IntermediateStep[];
|
|
52
|
-
error?: { code: string; message: string };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
interface PreTaskHandler {
|
|
56
|
-
id: PreHandlerId;
|
|
57
|
-
order: number;
|
|
58
|
-
shouldRun(ctx: PreHandlerContext): boolean;
|
|
59
|
-
run(ctx: PreHandlerContext): Promise<PreHandlerResult>;
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Composition:** engine merges `patches` in order, concatenates `intermediateSteps`, forwards `prior` to the next handler. Per-handler failure policy (strict vs tolerant) is part of each handler spec.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Built-in handlers (index)
|
|
68
|
-
|
|
69
|
-
| Handler id | Trigger (today) | Detail doc |
|
|
70
|
-
|------------|-----------------|------------|
|
|
71
|
-
| `narrix-preprocessor` | `RunTaskRequest.narrix` | [`handler-narrix-preprocessor.md`](handler-narrix-preprocessor.md); web scope [`handler-web-scope.md`](handler-web-scope.md). |
|
|
72
|
-
| `pipeline.synthesized-context` | `executionPipeline` PRE `synthesized-context` | [`handler-synthesized-context.md`](handler-synthesized-context.md) (**@athenices/xynthesis**). |
|
|
73
|
-
| `direct.ai-scoping` | `RunTaskRequest.aiScoping[]` | [`handler-ai-scoping.md`](handler-ai-scoping.md). |
|
|
74
|
-
|
|
75
|
-
**Narrix System-2** (`llmPlan`) is a **sub-phase** of narrix (or a nested handler with the same result type). Spec: [`handler-narrix-system2.md`](handler-narrix-system2.md).
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## Canonical execution order
|
|
80
|
-
|
|
81
|
-
1. `narrix-preprocessor` (if `request.narrix`)
|
|
82
|
-
2. Pipeline PRE steps — `pipeline.synthesized-context` when present
|
|
83
|
-
3. MAIN prep inside direct: memory enrich → `direct.ai-scoping` → executor
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Extension
|
|
88
|
-
|
|
89
|
-
New pre feature ⇒ new `PreTaskHandler` + register. For synthesis-like behavior, prefer **Xynthesis** (see platform doc §1b) instead of parallel prompt systems.
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# `PREFER_OPENROUTER` routing policy (Exellix stack)
|
|
2
|
-
|
|
3
|
-
Normative contract for **OpenRouter vs vendor-direct** model routing across `@exellix/ai-tasks`, `@exellix/graph-engine`, graphs-studio, and `@x12i/ai-profiles` consumers.
|
|
4
|
-
|
|
5
|
-
## Summary
|
|
6
|
-
|
|
7
|
-
| Env / API field | Meaning |
|
|
8
|
-
|-----------------|---------|
|
|
9
|
-
| **`PREFER_OPENROUTER`** | Operator **preference**: use OpenRouter when an OpenRouter API key is available. |
|
|
10
|
-
| **`preferOpenRouter`** | Same semantics as env; use on `resolveInvocationPlan({ policy })` and model-resolution options. |
|
|
11
|
-
|
|
12
|
-
**Vendor API keys** (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, …) do **not** change this policy. They are used only when effective routing is **direct**. To force vendor-direct routing, set `PREFER_OPENROUTER=false`.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Decision table (effective routing)
|
|
17
|
-
|
|
18
|
-
After resolving `preferOpenRouter` (explicit → env → default **`true`**):
|
|
19
|
-
|
|
20
|
-
| `preferOpenRouter` | `OPENROUTER_API_KEY` / `OPEN_ROUTER_KEY` | **Effective routing** | Wire model id (example) |
|
|
21
|
-
|--------------------|--------------------------------------------|------------------------|-------------------------|
|
|
22
|
-
| `false` | (any) | **direct** | `anthropic/claude-sonnet-4-5` |
|
|
23
|
-
| `true` | present | **openrouter** | `openrouter/anthropic/claude-sonnet-4.5` |
|
|
24
|
-
| `true` | absent | **direct** (fallback) + warning | `anthropic/claude-sonnet-4-5` |
|
|
25
|
-
|
|
26
|
-
**Prefer** means “use OpenRouter when you *can*”; missing key → honest direct fallback.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
|
-
## Environment
|
|
31
|
-
|
|
32
|
-
```env
|
|
33
|
-
# Prefer OpenRouter when OPENROUTER_API_KEY is set (default when omitted)
|
|
34
|
-
PREFER_OPENROUTER=true
|
|
35
|
-
|
|
36
|
-
# Force vendor-direct for all phases (MAIN + PRE/POST resolution)
|
|
37
|
-
# PREFER_OPENROUTER=false
|
|
38
|
-
|
|
39
|
-
OPENROUTER_API_KEY=sk-or-...
|
|
40
|
-
ANTHROPIC_API_KEY=sk-ant-... # used only when effective routing is direct
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## API (`@exellix/ai-tasks`)
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
import { resolveInvocationPlan } from "@exellix/ai-tasks";
|
|
49
|
-
|
|
50
|
-
const plan = await resolveInvocationPlan({
|
|
51
|
-
profiles: {
|
|
52
|
-
preActionModel: "cheap",
|
|
53
|
-
skillModel: "cyber@default",
|
|
54
|
-
postActionModel: "cheap",
|
|
55
|
-
},
|
|
56
|
-
policy: {
|
|
57
|
-
preferOpenRouter: true,
|
|
58
|
-
openrouterApiKeyPresent: !!process.env.OPENROUTER_API_KEY,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Policy fields on `resolveInvocationPlan`, `resolveProfileInvocationRouting`, and `resolveModelReference`:
|
|
64
|
-
|
|
65
|
-
- **`preferOpenRouter`** — operator preference (see decision table).
|
|
66
|
-
- **`openrouterApiKeyPresent`** — optional snapshot; defaults to env detection in-process.
|
|
67
|
-
|
|
68
|
-
Internal mapping to `@x12i/ai-profiles`:
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
resolveAIProfile(profile, {
|
|
72
|
-
preferOpenRouter: effectivePreferOpenRouter, // from resolvePreferOpenRouterPolicy()
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## Per-phase behavior (`runTask`)
|
|
79
|
-
|
|
80
|
-
All phases (PRE / MAIN / POST) use the **same** `resolvePreferOpenRouterPolicy()` snapshot at plan and execute time.
|
|
81
|
-
|
|
82
|
-
| Phase | Consumer | Notes |
|
|
83
|
-
|-------|----------|-------|
|
|
84
|
-
| PRE / POST | `@exellix/xynthesis` | Alias on wire; xynthesis resolves via ai-profiles with same effective routing. |
|
|
85
|
-
| MAIN (skill) | `@exellix/ai-skills` | Concrete model id on wire; must include `openrouter/` prefix when effective routing is openrouter. |
|
|
86
|
-
|
|
87
|
-
Plan output: trust **`routing`** + **`engineLabel`**, not model-id prefix alone.
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## Migration checklist (other components)
|
|
92
|
-
|
|
93
|
-
### graphs-studio / BFF
|
|
94
|
-
|
|
95
|
-
- [ ] POST `/api/exellix/invocation-plan` body: `policy.preferOpenRouter`.
|
|
96
|
-
- [ ] Simulate Engine layer: call `resolveInvocationPlan` only; do not re-derive from choices matrix.
|
|
97
|
-
- [ ] Update UI copy: “prefers OpenRouter when key present” vs “always OpenRouter”.
|
|
98
|
-
|
|
99
|
-
### `@exellix/graph-engine`
|
|
100
|
-
|
|
101
|
-
- [ ] Pass `policy: { preferOpenRouter, openrouterApiKeyPresent }` into `resolveInvocationPlan` before execute.
|
|
102
|
-
- [ ] Thread same snapshot into `runTask` policy (when execute parity lands on request env).
|
|
103
|
-
|
|
104
|
-
### `@exellix/xynthesis`
|
|
105
|
-
|
|
106
|
-
- [ ] Funcx OpenRouter client: align with effective routing fallback when key missing.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## Related
|
|
111
|
-
|
|
112
|
-
- [`.docs/ai-tasks-model-profile-aliases-7x.md`](ai-tasks-model-profile-aliases-7x.md) — profile slots on `RunTaskRequest`
|
|
113
|
-
- `src/invocation/preferOpenRouterPolicy.ts` — implementation in ai-tasks
|
|
114
|
-
- `src/invocation/resolveInvocationPlan.ts` — pre-run plan API
|