@exellix/ai-tasks 9.0.6 → 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.
Files changed (177) hide show
  1. package/CHANGELOG.md +22 -4
  2. package/README.md +5 -5
  3. package/RUNTASK_REQUEST.md +17 -15
  4. package/dist/compile/compileTaskConfiguration.d.ts.map +1 -1
  5. package/dist/compile/compileTaskConfiguration.js +3 -0
  6. package/dist/compile/compileTaskConfiguration.js.map +1 -1
  7. package/dist/core/task-sdk.d.ts.map +1 -1
  8. package/dist/core/task-sdk.js +112 -166
  9. package/dist/core/task-sdk.js.map +1 -1
  10. package/dist/invocation/types.d.ts +1 -1
  11. package/dist/narrix/narrixUnitExecution.js +2 -2
  12. package/dist/narrix/narrixUnitExecution.js.map +1 -1
  13. package/dist/node-execution/buildRequestFromNodePlan.d.ts +4 -0
  14. package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
  15. package/dist/node-execution/buildRequestFromNodePlan.js +4 -13
  16. package/dist/node-execution/buildRequestFromNodePlan.js.map +1 -1
  17. package/dist/node-execution/compileProfessionalAnswerRequest.d.ts +2 -0
  18. package/dist/node-execution/compileProfessionalAnswerRequest.d.ts.map +1 -0
  19. package/dist/node-execution/compileProfessionalAnswerRequest.js +4 -0
  20. package/dist/node-execution/compileProfessionalAnswerRequest.js.map +1 -0
  21. package/dist/node-execution/rejectForbiddenWireFields.d.ts +2 -0
  22. package/dist/node-execution/rejectForbiddenWireFields.d.ts.map +1 -1
  23. package/dist/node-execution/rejectForbiddenWireFields.js +42 -7
  24. package/dist/node-execution/rejectForbiddenWireFields.js.map +1 -1
  25. package/dist/node-execution/resolveUnitModelSelection.d.ts.map +1 -1
  26. package/dist/node-execution/resolveUnitModelSelection.js +10 -1
  27. package/dist/node-execution/resolveUnitModelSelection.js.map +1 -1
  28. package/dist/observability/graphExecutionRunLogContract.d.ts +1 -1
  29. package/dist/observability/graphExecutionRunLogContract.js +1 -1
  30. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts +19 -3
  31. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.d.ts.map +1 -1
  32. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js +7 -1
  33. package/dist/post-steps/audit/auditChecklistFuncxEnvelope.js.map +1 -1
  34. package/dist/post-steps/audit/loadAuditTemplates.d.ts +2 -55
  35. package/dist/post-steps/audit/loadAuditTemplates.d.ts.map +1 -1
  36. package/dist/post-steps/audit/loadAuditTemplates.js +3 -38
  37. package/dist/post-steps/audit/loadAuditTemplates.js.map +1 -1
  38. package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts +8 -0
  39. package/dist/post-steps/audit/parseAuditFuncxOutput.d.ts.map +1 -0
  40. package/dist/post-steps/audit/parseAuditFuncxOutput.js +62 -0
  41. package/dist/post-steps/audit/parseAuditFuncxOutput.js.map +1 -0
  42. package/dist/post-steps/audit/parseAuditOutput.d.ts +2 -0
  43. package/dist/post-steps/audit/parseAuditOutput.d.ts.map +1 -1
  44. package/dist/post-steps/audit/parseAuditOutput.js +56 -0
  45. package/dist/post-steps/audit/parseAuditOutput.js.map +1 -1
  46. package/dist/post-steps/audit/runAudit.d.ts.map +1 -1
  47. package/dist/post-steps/audit/runAudit.js +53 -113
  48. package/dist/post-steps/audit/runAudit.js.map +1 -1
  49. package/dist/post-steps/audit/runAuditFuncxCall.d.ts +18 -0
  50. package/dist/post-steps/audit/runAuditFuncxCall.d.ts.map +1 -0
  51. package/dist/post-steps/audit/runAuditFuncxCall.js +59 -0
  52. package/dist/post-steps/audit/runAuditFuncxCall.js.map +1 -0
  53. package/dist/synthesis/resolveSourceMaterial.d.ts.map +1 -1
  54. package/dist/synthesis/resolveSourceMaterial.js +14 -0
  55. package/dist/synthesis/resolveSourceMaterial.js.map +1 -1
  56. package/dist/types/task-types.d.ts +4 -3
  57. package/dist/types/task-types.d.ts.map +1 -1
  58. package/dist/utils/bridgeRunSkillGatewayMemory.d.ts.map +1 -1
  59. package/dist/utils/bridgeRunSkillGatewayMemory.js +1 -0
  60. package/dist/utils/bridgeRunSkillGatewayMemory.js.map +1 -1
  61. package/dist/utils/executionMemoryInputRecord.d.ts +12 -0
  62. package/dist/utils/executionMemoryInputRecord.d.ts.map +1 -0
  63. package/dist/utils/executionMemoryInputRecord.js +28 -0
  64. package/dist/utils/executionMemoryInputRecord.js.map +1 -0
  65. package/dist/utils/resolveAiProfileModel.d.ts +1 -1
  66. package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
  67. package/dist/utils/skillTemplateVariables.d.ts +3 -2
  68. package/dist/utils/skillTemplateVariables.d.ts.map +1 -1
  69. package/dist/utils/skillTemplateVariables.js +3 -2
  70. package/dist/utils/skillTemplateVariables.js.map +1 -1
  71. package/dist/validation/validateProfessionalAnswerContract.d.ts +8 -0
  72. package/dist/validation/validateProfessionalAnswerContract.d.ts.map +1 -0
  73. package/dist/validation/validateProfessionalAnswerContract.js +45 -0
  74. package/dist/validation/validateProfessionalAnswerContract.js.map +1 -0
  75. package/dist/validation/validateRunTaskConfig.d.ts.map +1 -1
  76. package/dist/validation/validateRunTaskConfig.js +2 -0
  77. package/dist/validation/validateRunTaskConfig.js.map +1 -1
  78. package/documenations/record-and-template-variables.md +21 -13
  79. package/documenations/run-task-execution-flow.md +1 -1
  80. package/documenations/schemas/v1/run-task-request.json +1 -1
  81. package/documenations/upstream-feature-requests/README.md +9 -5
  82. package/documenations/upstream-feature-requests/ai-skills-orchestrator-invoke-contract-5.9.md +1 -1
  83. package/documenations/upstream-feature-requests/funcx-4.9.13-open-items.md +62 -0
  84. package/documenations/upstream-feature-requests/funcx-gap-analysis-cr-fr.md +401 -0
  85. package/documenations/upstream-feature-requests/funcx-pre-post-sidekick-actions.md +1 -0
  86. package/documenations/upstream-feature-requests/graph-engine-runtask-contract-alignment-investigation.md +370 -0
  87. package/documenations/upstream-feature-requests/xynthesis-ai-profiles-2.1-import-break.md +2 -2
  88. package/documenations/upstream-feature-requests/xynthesis-openrouter-wire-model-double-prefix-bug.md +1 -1
  89. package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +1 -1
  90. package/package.json +14 -17
  91. package/.docs/DOWNSTREAM_ENV.md +0 -42
  92. package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +0 -64
  93. package/.docs/INTERMEDIATE_STEPS.md +0 -82
  94. package/.docs/activity-structure.md +0 -31
  95. package/.docs/ai-task-ai-scoping-spec.md +0 -338
  96. package/.docs/ai-tasks-model-profile-aliases-7x.md +0 -96
  97. package/.docs/blockers-and-issues.md +0 -346
  98. package/.docs/building-runTask-sdk.md +0 -659
  99. package/.docs/building-skill-execution-orchestrator.md +0 -968
  100. package/.docs/code-used-before/run-task.txt +0 -39
  101. package/.docs/code-used-before/task-executor.ts.old +0 -57
  102. package/.docs/code-used-before/test-run-task.ts.old +0 -42
  103. package/.docs/code-used-before/types.txt +0 -23
  104. package/.docs/env-ready-policy.md +0 -40
  105. package/.docs/flow-io/flow-README.md +0 -76
  106. package/.docs/flow-io/narrix.md +0 -124
  107. package/.docs/flow-io/web-scoping.md +0 -135
  108. package/.docs/flow-io/xynthesis-post.md +0 -154
  109. package/.docs/flow-io/xynthesis-pre.md +0 -181
  110. package/.docs/gap-analysis.md +0 -201
  111. package/.docs/integration-facts-ai-tasks.md +0 -109
  112. package/.docs/investigation/ai-skills.md +0 -170
  113. package/.docs/investigation/external-packages-assignments.md +0 -66
  114. package/.docs/investigation/integration-summary.md +0 -20
  115. package/.docs/investigation/narrix-catalox.md +0 -29
  116. package/.docs/investigation/workplan-close-graph-engine-gaps.md +0 -101
  117. package/.docs/logging-stack.md +0 -30
  118. package/.docs/memory-narrix-adapter-developer-guide.md +0 -402
  119. package/.docs/memory-narrix-adapter-requirements.md +0 -112
  120. package/.docs/narrix-context-consumption-gap.md +0 -184
  121. package/.docs/narrix-context-downstream-report.md +0 -30
  122. package/.docs/narrix-ingest-and-packs-library-spec.md +0 -240
  123. package/.docs/narrix-record-input-current-design.md +0 -48
  124. package/.docs/pacakge.md +0 -48
  125. package/.docs/possible-components/README.md +0 -11
  126. package/.docs/possible-components/integration/README.md +0 -10
  127. package/.docs/possible-components/integration/gaps-when-merging.md +0 -16
  128. package/.docs/possible-components/integration/platform.md +0 -54
  129. package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +0 -26
  130. package/.docs/possible-components/integration/roadmap-and-checklists.md +0 -54
  131. package/.docs/possible-components/post-component/README.md +0 -18
  132. package/.docs/possible-components/post-component/builder-guide.md +0 -175
  133. package/.docs/possible-components/post-component/gaps-and-artifacts.md +0 -52
  134. package/.docs/possible-components/post-component/handler-audit.md +0 -47
  135. package/.docs/possible-components/post-component/handler-polish.md +0 -41
  136. package/.docs/possible-components/post-component/unified-protocol.md +0 -59
  137. package/.docs/possible-components/pre-component/README.md +0 -22
  138. package/.docs/possible-components/pre-component/builder-guide.md +0 -127
  139. package/.docs/possible-components/pre-component/gaps-and-artifacts.md +0 -35
  140. package/.docs/possible-components/pre-component/handler-ai-scoping.md +0 -45
  141. package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +0 -49
  142. package/.docs/possible-components/pre-component/handler-narrix-system2.md +0 -35
  143. package/.docs/possible-components/pre-component/handler-synthesized-context.md +0 -65
  144. package/.docs/possible-components/pre-component/handler-web-scope.md +0 -29
  145. package/.docs/possible-components/pre-component/unified-protocol.md +0 -89
  146. package/.docs/prefer-openrouter-routing-policy.md +0 -114
  147. package/.docs/questions-for-ai-skills.md +0 -123
  148. package/.docs/realtime-narrixing-gap-analysis.md +0 -40
  149. package/.docs/realtime-narrixing.md +0 -433
  150. package/.docs/run-context-object.md +0 -32
  151. package/.docs/session-id-usage.md +0 -26
  152. package/.docs/skill-library-spec.md +0 -249
  153. package/.docs/synthesized-context-strategy-spec.md +0 -906
  154. package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +0 -46
  155. package/.docs/web-scopper-embed.md +0 -93
  156. package/.docs/xynthesis-wiring-and-io.md +0 -12
  157. package/documenations/activix-feature-request-identity.md +0 -123
  158. package/documenations/bug-report-xynthesis-and-synthesis-call.md +0 -217
  159. package/documenations/feature-request-ai-skills-raw-template-access.md +0 -82
  160. package/documenations/feature-request-athenix-core-directive.md +0 -145
  161. package/documenations/feature-request-athenix-token-extraction.md +0 -124
  162. package/documenations/funcx-upstream-github-issues-draft.md +0 -153
  163. package/documenations/identity-metadata-contract.md +0 -165
  164. package/documenations/run-task-single-run-checklist.md +0 -109
  165. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-1-no-concrete-wire-in-graph-plans.md +0 -93
  166. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-2-skillModel-profile-only-at-storage.md +0 -88
  167. package/documenations/sessions/2026-06-08-subnets-model-resolution/CR-3-reject-concrete-models-in-catalog-rows.md +0 -76
  168. package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-1-suggested-profile-in-catalogs.md +0 -96
  169. package/documenations/sessions/2026-06-08-subnets-model-resolution/FR-2-graph-engine-failure-phase-attribution.md +0 -92
  170. package/documenations/sessions/2026-06-08-subnets-model-resolution/INVESTIGATION-original-bug.md +0 -182
  171. package/documenations/sessions/2026-06-08-subnets-model-resolution/PROBLEM.md +0 -236
  172. package/documenations/sessions/2026-06-08-subnets-model-resolution/README.md +0 -11
  173. package/documenations/sessions/2026-06-08-subnets-model-resolution/funcx-test-resolveModel.cheapDefaultWireSlug.test.ts +0 -117
  174. package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +0 -129
  175. package/documenations/upstream-feedback-request-shape-clarification.md +0 -101
  176. package/documenations/web-context-precedence.md +0 -33
  177. 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