@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,154 +0,0 @@
1
- # Calling **xynthesis** — POST (`audit` / `polish`)
2
-
3
- How `@exellix/ai-tasks` invokes the **`@exellix/xynthesis`** component in **POST** pipeline steps after MAIN completes.
4
-
5
- ---
6
-
7
- ## When it runs
8
-
9
- - `executionPipeline` includes `{ phase: "post", type: "audit" | "polish", config: ... }`
10
- - Runs **after** MAIN (`runSkill`) returns
11
- - Only implemented POST types: **`audit`**, **`polish`** (others ignored)
12
-
13
- Does **not** run on local-task paths or requests without POST steps.
14
-
15
- ---
16
-
17
- ## Shared adapter
18
-
19
- All POST LLM calls use the same path as PRE markdown:
20
-
21
- ```
22
- runAuditCall / runPolishCall / audit merge
23
- → runPostStepLlmCall
24
- → resolveLlmCallForXynthesis(stage)
25
- → runSynthesisCall(...)
26
- ```
27
-
28
- Implementation: `src/internal/runPostStepLlmCall.ts`, `src/post-steps/audit/runAuditCall.ts`, `src/post-steps/polish/runPolishCall.ts`.
29
-
30
- ---
31
-
32
- ## Audit
33
-
34
- **Config:** `AuditConfig` on the POST step.
35
-
36
- | Call | `LlmCallStage` | xynthesis `SidekickActionType` | Config |
37
- |------|----------------|--------------------------------|--------|
38
- | Evaluate candidate | `post-audit` | `audit` | `llmCall.audit` |
39
- | Merge / synthesis pass | `post-audit-merge` | `audit` | `llmCall.synthesis` |
40
-
41
- **Inputs:**
42
-
43
- - MAIN output text (candidate cycles)
44
- - `contextMarkdown` captured from MAIN
45
- - Audit templates: `loadAuditTemplates`, `renderAuditSystem`, `renderAuditUser`
46
- - Gateway checks: `config.gateway.must` / `should`
47
-
48
- **Outputs:**
49
-
50
- - Final selected text → response body
51
- - `metadata.postSteps.audit` (scores, cycles, `synthesisUsed`, …)
52
- - `metadata.postSteps.audit.llmCalls` in trace mode
53
-
54
- Orchestration: `src/post-steps/audit/runAudit.ts` (may re-run MAIN via `reRunMain` when audit fails).
55
-
56
- ---
57
-
58
- ## Polish
59
-
60
- **Config:** `PolishConfig` on the POST step.
61
-
62
- | Call | `LlmCallStage` | xynthesis `SidekickActionType` | Config |
63
- |------|----------------|--------------------------------|--------|
64
- | Each pass | `post-polish` | `fix` | `llmCall` |
65
-
66
- **Inputs:**
67
-
68
- - MAIN (or prior POST) output
69
- - `config.checklist`
70
- - Optional original `contextMarkdown` when `includeOriginalContext`
71
-
72
- **Outputs:**
73
-
74
- - Polished text (parsed JSON: `polishedOutput`, `changeNotes`)
75
- - `metadata.postSteps.polish`
76
- - `metadata.postSteps.polish.llmCalls` in trace mode
77
-
78
- Orchestration: `src/post-steps/polish/runPolish.ts`.
79
-
80
- ---
81
-
82
- ## `runSynthesisCall` payload
83
-
84
- Same shape as PRE (see [xynthesis-pre.md](./xynthesis-pre.md)):
85
-
86
- - `gateway`: `agentId`, `sessionId` (= `taskId`), new `aiRequestId` per call
87
- - `prompts`: audit/polish-rendered system + user
88
- - `workScope`: `{ jobId, taskId }`
89
- - `maxTokens` from `resolveLlmCallForXynthesis`
90
- - `executionMode: "trace"` when trace collector present
91
-
92
- ---
93
-
94
- ## LLM config resolution
95
-
96
- | Step | Env prefix | Shared fallback |
97
- |------|------------|-----------------|
98
- | Audit evaluator | `AUDIT_*` | `POST_STEP_*` |
99
- | Audit synthesis merge | `AUDIT_*` (synthesis role) | `POST_STEP_*` |
100
- | Polish | `POLISH_*` | `POST_STEP_*` |
101
-
102
- Order per field: `config.llmCall.*` → step env → `POST_STEP_*` → code fallback (`resolveLlmCall` in `src/post-steps/resolvePostStepConfig.ts`).
103
-
104
- `outputExpectation`: caller `llmCall.outputExpectation` overrides xynthesis defaults for `audit` or `fix`.
105
-
106
- ---
107
-
108
- ## Trace
109
-
110
- `executionMode: "trace"` on the `RunTaskRequest` attaches `LlmCallObservation` per POST call (`source: "xynthesis"`, `stage`, `invokeSummary`).
111
-
112
- ---
113
-
114
- ## TaskNode model (graph authoring)
115
-
116
- POST xynthesis runs only when the compiled `RunTaskRequest` includes POST pipeline steps (or engine-generated equivalents from profile keys).
117
-
118
- | TaskNode field | Role for POST xynthesis |
119
- |----------------|-------------------------|
120
- | `executionPipeline[]` with `phase: "post"`, `type: "audit"` \| `"polish"` | Static `AuditConfig` / `PolishConfig` on the step (`gateway`, `checklist`, `llmCall`, thresholds, …). |
121
- | `taskConfiguration.aiTaskProfile.postStrategyKey` | Graph-engine may emit engine POST utility / pipeline steps before/instead of hand-authored POST; resolved model still comes from node model config (see runtime). |
122
- | `taskConfiguration.modelConfig` | Resolved `xynthesisModel` for audit evaluator, audit merge, and polish passes. |
123
- | `taskConfiguration.llmCall` | Node-level defaults the engine may map into POST step `llmCall` roles (`audit`, `synthesis`, polish). |
124
- | `executionPipeline` MAIN step | Must exist exactly once; POST runs on MAIN output after `runSkill` returns. |
125
- | `node.outputValidation` | Graph-engine **local** check before mappings — **not** the same as `taskConfiguration.aiTasksOutputValidation` (server-side in ai-tasks on MAIN). POST xynthesis is unrelated to either unless audit re-runs MAIN. |
126
-
127
- **Not on the model:** MAIN output text, audit scores, or polish `changeNotes` — those exist only after the run.
128
-
129
- ---
130
-
131
- ## TaskNode runtime (per-run overrides)
132
-
133
- | Runtime field | Role for POST xynthesis |
134
- |---------------|------------------------|
135
- | `runtime.nodes[nodeId].modelConfig` | Same precedence as PRE/MAIN: overrides `xynthesisModel` / `skillModel` for **this node's entire `runTask`**, including POST audit/polish LLM calls inside that invocation. |
136
- | `runtime.nodes[nodeId].aliasConfig` | Per-node alias overlay for POST model resolution. |
137
- | `runtime.executionMemory` | Not written by POST inside ai-tasks for audit/polish metadata (those land on `response.metadata.postSteps`). Downstream mappings use `executionMapping` on the model after the node completes. |
138
-
139
- **Not on node runtime:** POST step definitions, audit checklists, or polish checklists — declare on `node.executionPipeline` or profile-generated pipeline on the model.
140
-
141
- Engine PRE/POST **utility** calls (from `preStrategyKey` / `postStrategyKey`) also receive this node's resolved `modelConfig` when graph-engine owns the `runTask`.
142
-
143
- ---
144
-
145
- ## Source files
146
-
147
- | File | Role |
148
- |------|------|
149
- | `src/post-steps/audit/runAudit.ts` | Audit loop |
150
- | `src/post-steps/audit/runAuditCall.ts` | Single audit LLM |
151
- | `src/post-steps/polish/runPolish.ts` | Polish passes |
152
- | `src/post-steps/polish/runPolishCall.ts` | Single polish LLM |
153
- | `src/post-steps/resolvePostStepConfig.ts` | Model/timeout env resolution |
154
- | `src/internal/runPostStepLlmCall.ts` | xynthesis invoke |
@@ -1,181 +0,0 @@
1
- # Calling **xynthesis** — PRE (`synthesized-context`)
2
-
3
- How `@exellix/ai-tasks` invokes the **`@exellix/xynthesis`** component in the **PRE** pipeline step.
4
-
5
- ---
6
-
7
- ## When it runs
8
-
9
- - `executionPipeline` contains a step: `{ phase: "pre", type: "synthesized-context", config: SynthesisConfig }`
10
- - Requires `includeContextInPrompt: true` **or** `config.autoEnableContext: true`
11
- - At most **one** PRE synthesis step runs (first in list, then pipeline continues)
12
-
13
- Does **not** run on: local-task short-circuit, MAIN-only requests, or requests without that pipeline step.
14
-
15
- ---
16
-
17
- ## What ai-tasks calls in xynthesis
18
-
19
- | Mode | xynthesis entrypoint | ai-tasks wrapper |
20
- |------|----------------------|------------------|
21
- | Markdown (default) | `runSynthesisCall` | `runPostStepLlmCall` → stage `pre-synthesis-markdown` |
22
- | Question-driven | `runSynthesisCall` (per question) | `runPostStepLlmCall` → stage `pre-synthesis-question` |
23
- | Structured | `runStructuredSynthesisGatewayCall` (+ validate) | `runStructuredSynthesisGatewayCallRobust` → stage `pre-synthesis-structured` |
24
-
25
- Supporting xynthesis helpers used in PRE (not separate LLM calls):
26
-
27
- - `loadSynthesisTemplates`, `buildSynthesisSystemPrompt`, `buildSynthesisUserPrompt`
28
- - `getRenderedTemplates`, `discoverTemplateCores`, `resolveSynthesisQuestion`
29
- - `buildSynthesizedContextMarkdown`, `normalizeAndValidateSynthesizedPayload`
30
-
31
- Source material assembly (`resolveSourceMaterial`, `resolveSourceMaterialParts`) is **ai-tasks** code; see [narrix.md](./narrix.md) and [web-scoping.md](./web-scoping.md) for inputs that feed it.
32
-
33
- ---
34
-
35
- ## Call chain (markdown mode)
36
-
37
- ```
38
- runTask pipeline
39
- → _runSynthesizedContextPreStep(request, SynthesisConfig)
40
- → enrichMemoriesWithScoping (ai-skills)
41
- → resolveSourceMaterial* (ai-tasks)
42
- → getRenderedTemplates (xynthesis + bundle)
43
- → runPostStepLlmCall
44
- → resolveLlmCallForXynthesis(stage: pre-synthesis-markdown)
45
- → runSynthesisCall({ gateway, prompts, workScope, maxTokens, ... })
46
- → contextMarkdown + artifact
47
- → overrideContext for MAIN
48
- ```
49
-
50
- Implementation: `src/core/task-sdk.ts` (`_runSynthesizedContextPreStep`), `src/internal/runPostStepLlmCall.ts`.
51
-
52
- ---
53
-
54
- ## `runSynthesisCall` payload (via `runPostStepLlmCall`)
55
-
56
- | Field | Source |
57
- |-------|--------|
58
- | `gateway.agentId` | `request.agentId` |
59
- | `gateway.sessionId` | `request.taskId` |
60
- | `prompts.systemPrompt` / `userPrompt` | xynthesis template builders + source material |
61
- | `workScope.jobId` / `taskId` | `request.jobId`, `request.taskId` |
62
- | `model`, `timeoutMs`, `maxOutputLength` | `SynthesisConfig.llmCall` → `modelConfig` → `SYNTHESIS_*` env |
63
- | `maxTokens` | `resolveLlmCallForXynthesis` → xynthesis `resolveMaxTokens` |
64
- | `tokenResolutionMetadata` | same resolver (Activix) |
65
- | `executionMode: "trace"` | when `request.executionMode === "trace"` |
66
-
67
- `request.identity` may be forwarded separately via `synthesisIdentityFromRequest` where the xynthesis API accepts it.
68
-
69
- ---
70
-
71
- ## `SynthesisConfig` → xynthesis (LLM knobs)
72
-
73
- Resolution order for the PRE LLM call:
74
-
75
- 1. `config.llmCall.*`
76
- 2. `config.modelConfig` / `config.timeoutMs` / `config.maxOutputLength`
77
- 3. Env: `SYNTHESIS_MODEL`, `SYNTHESIS_TIMEOUT_MS`, … (`llmCallEnvPrefix("SYNTHESIS")`)
78
- 4. Fallbacks in `_runSynthesizedContextPreStep` (e.g. model `gpt-5-nano`, timeout 30s)
79
-
80
- `outputExpectation`: caller override wins; else xynthesis `resolveOutputExpectation("synthesis")`.
81
-
82
- ---
83
-
84
- ## Inputs (what reaches the prompts)
85
-
86
- | Input | Role |
87
- |-------|------|
88
- | Enriched `jobMemory`, `taskMemory`, `executionMemory` | Serialized per `contextSourcePolicy` / `synthesisInputStrategy` |
89
- | Narrix attachment | From `executionMemory._narrix` (or `attachToField`) — see [narrix.md](./narrix.md) |
90
- | Web evidence markdown | From `executionMemory.webContext` when policy includes web — see [web-scoping.md](./web-scoping.md) |
91
- | Rendered skill templates | `getRenderedTemplates` with bundle including `xynthesized`, `smartInput` |
92
- | `request.input` | Question for structured mode (`questionPath` / `getQuestion`) |
93
-
94
- `contextSourcePolicy` default `auto` resolves to combined narrix + memory + web layout in `resolveSourceMaterial.ts`.
95
-
96
- ---
97
-
98
- ## Outputs (after xynthesis returns)
99
-
100
- | Output | Where |
101
- |--------|--------|
102
- | `contextMarkdown` | Passed to MAIN as `overrideContext` |
103
- | `executionMemory.synthesizedContext` | Artifact (`mode`: markdown \| structured \| questionDriven) unless `xynthesizedOutput.alsoWriteLegacySynthesizedContext: false` |
104
- | `executionMemory.synthesizedInput` | Source material snapshot (size cap: `SYNTHESIZED_INPUT_MAX_CHARS`) |
105
- | `request.xynthesized[scope][outputKey]` | When `config.xynthesizedOutput` set (`src/utils/xynthesizedWrite.ts`) |
106
- | `response.xynthesizedPatch` | Graph merge slice from PRE write |
107
- | `metadata.synthesizedContextLlmCalls` | Trace mode only (`LlmCallObservation[]`) |
108
-
109
- Empty synthesized context is **not** replaced by Narrix/web fallback when synthesis was authoritative.
110
-
111
- ---
112
-
113
- ## Structured mode extras
114
-
115
- - Requires `{{core:...}}` in raw instructions or prompt (`discoverTemplateCores`).
116
- - Repair path may use AIGateway + stage `structured-repair` (`src/synthesis/runStructuredSynthesisRobust.ts`).
117
- - Optional `getContextSynthesizer()` hook bypasses gateway if registered.
118
-
119
- ---
120
-
121
- ## Cache
122
-
123
- `reuseCachedSynthesizedContext: true` skips all xynthesis LLM calls when `executionMemory.synthesizedContext` already has usable `contextMarkdown`.
124
-
125
- ---
126
-
127
- ## TaskNode model (graph authoring)
128
-
129
- Static fields graph-engine maps into `RunTaskRequest` for PRE xynthesis. Nothing here is executed inside ai-tasks until compiled into a request.
130
-
131
- | TaskNode field | Role for PRE xynthesis |
132
- |----------------|------------------------|
133
- | `taskConfiguration.aiTaskProfile.inputSynthesis` | **Canonical** switch for generated PRE `synthesized-context`. `enabled`, `sources`, `destination` (`job` \| `task` \| `execution` → `xynthesizedOutput.destination`), synthesis mode/policy knobs. Must not conflict with a hand-authored PRE step (`INPUT_SYNTHESIS_PIPELINE_CONFLICT`). |
134
- | `taskConfiguration.aiTaskStrategies.pre: "synthesis"` | **Enable PRE** when forwarded on `RunTaskRequest.taskConfiguration` (compiled by ai-tasks at `runTask`). Use `preInputStrategy` for `synthesisInputStrategy`. |
135
- | `executionPipeline[]` with `phase: "pre"`, `type: "synthesized-context"` | Alternative to profile/strategies: full `SynthesisConfig` on the step (`contextSourcePolicy`, `synthesisMode`, `xynthesizedOutput`, `llmCall`, …). |
136
- | `taskConfiguration.modelConfig` | `ModelConfigSelection` → resolved `xynthesisModel` for the PRE LLM (via graph-engine alias resolution). |
137
- | `taskConfiguration.llmCall` | Optional per-node cap on model / `maxTokensCap` / `outputExpectation` / `timeoutMs` forwarded into pipeline `SynthesisConfig.llmCall` when the engine maps it. |
138
- | `taskConfiguration.timeoutMs` | May surface on the outbound request; PRE also reads step-level `timeoutMs`. |
139
- | `node.taskVariable` | Prompt literals and `$path` refs (`jobVariables.*`, `taskVariables.*`) → materialized **`RunTaskRequest.input`** (question for structured / question-driven synthesis). |
140
- | `node.inputsConfig` | Runtime binding wires only (`executionMemoryPath`) → values available under **`executionMemory`** for `resolveSourceMaterial` / question-driven `record` source. |
141
- | `node.variables` | Node templates → **`executionMemory.taskVariables`** → paths `taskVariables.*` in rendered synthesis templates. |
142
- | `node.smartInput` | Forwarded to **`RunTaskRequest.smartInput`**. Paths may include `xynthesized.job\|task\|execution.*`, `executionMemory.*`, `input.*`, `jobVariables.*`, `taskVariables.*`. Invalid shape throws **`SmartInputValidationError`** at `runTask` entry (before PRE xynthesis). |
143
- | `taskConfiguration.narrix` | Indirect: enables `_narrix` / `webContext` inputs to PRE (see [narrix.md](./narrix.md), [web-scoping.md](./web-scoping.md)). |
144
- | `skillKey` | Selects skill templates passed to `getRenderedTemplates`. |
145
- | `id` | Becomes `RunTaskRequest.nodeId` / correlation. |
146
-
147
- **Not on the model:** active `executionMemory`, resolved `xynthesized` payloads, or synthesis results — those are runtime or response-only.
148
-
149
- **Forbidden:** `metadata.inputSynthesis`, `metadata.modelConfig` — use `taskConfiguration.*`.
150
-
151
- ---
152
-
153
- ## TaskNode runtime (per-run overrides)
154
-
155
- `GraphRuntimeObject.nodes[nodeId]` is **not** where synthesis config or pipelines live. Only fields that change the outbound `runTask` for this node matter.
156
-
157
- | Runtime field | Role for PRE xynthesis |
158
- |---------------|------------------------|
159
- | `runtime.nodes[nodeId].modelConfig` | **Highest-precedence** `xynthesisModel` / `skillModel` for this node's `runTask` (including PRE), after alias resolution with `runtime.aliasConfig` + optional `runtime.nodes[nodeId].aliasConfig`. |
160
- | `runtime.nodes[nodeId].aliasConfig` | Resolves alias keys on that node's `modelConfig` only. |
161
- | `runtime.executionMemory` | Live run state PRE reads: `synthesizedContext` (cache when `reuseCachedSynthesizedContext`), `_narrix`, `webContext`, `input` / `inputs`, `jobVariables` / `taskVariables` mirrors. |
162
- | `runtime.input` / `runtime.inputs` | Entry payloads; mirrored into `executionMemory` before NARRIX / PRE. |
163
- | `runtime.jobMemory` / `runtime.taskMemory` | Fed into memory bundle enrichment and source-material policies. |
164
- | `runtime.variables` / `runtime.jobVariables` | Run-wide template bucket → `jobVariables.*` in synthesis source / templates. |
165
-
166
- **Not on node runtime:** `executionPipeline`, `inputSynthesis`, `smartInput`, or per-node template overrides — use the static `TaskNode` (or graph `model.variables` for job scope).
167
-
168
- Graph-engine builds an ephemeral **ExellixRuntimeObject** per outbound `runTask`; ai-tasks only sees the compiled `RunTaskRequest`.
169
-
170
- ---
171
-
172
- ## Source files
173
-
174
- | File | Role |
175
- |------|------|
176
- | `src/core/task-sdk.ts` | Pipeline + `_runSynthesizedContextPreStep` |
177
- | `src/internal/runPostStepLlmCall.ts` | `runSynthesisCall` adapter |
178
- | `src/internal/resolveLlmCallForXynthesis.ts` | Token sizing |
179
- | `src/synthesis/resolveSourceMaterial.ts` | PRE input text |
180
- | `src/synthesis/runStructuredSynthesisRobust.ts` | Structured branch |
181
- | `src/types/task-types.ts` | `SynthesisConfig` |
@@ -1,201 +0,0 @@
1
- # Gap Analysis: @woroces/ai-tasks SDK Completion
2
-
3
- **Date:** Current
4
- **Status:** Test passes but implementation doesn't match canonical algorithm
5
-
6
- ## Executive Summary
7
-
8
- The current implementation works (test passes), but it **does NOT implement the canonical `runTask` algorithm**. It's currently just a thin wrapper that calls `client.runSkill()` directly, missing all the task-level enrichment and context generation logic.
9
-
10
- ## Critical Gaps
11
-
12
- ### 1. ❌ Missing: Canonical runTask Algorithm
13
-
14
- **Current State:**
15
- - `runTask()` just calls `client.runSkill()` directly
16
- - No task-level memory enrichment
17
- - No context markdown generation
18
- - No taskId extraction from skillKey
19
-
20
- **Required State:**
21
- - Extract `taskId = skillKey.replace(/^tasks\//, '')`
22
- - Build `memoryBundle = { jobMemory, taskMemory }`
23
- - Call `enrichMemoriesWithScoping(taskId, 'task', memoryBundle)`
24
- - Call `generateContextMarkdown(taskId, 'task', enrichedBundle)`
25
- - Create `enrichedInput` with enriched memories and context
26
- - Execute via executor (not `runSkill`)
27
-
28
- **Impact:** HIGH - This is the core functionality
29
-
30
- ---
31
-
32
- ### 2. ❌ Missing: WorexClientTasks Class
33
-
34
- **Current State:**
35
- - Uses `TaskSDK` class (wrong name)
36
- - Constructor takes `WorecesSkillsClientOptions` (wrong signature)
37
-
38
- **Required State:**
39
- - Class name: `WorexClientTasks`
40
- - Constructor: `(skillsClient: WorexClientSkills, executor: { execute(...) })`
41
-
42
- **Impact:** HIGH - API naming and architecture
43
-
44
- ---
45
-
46
- ### 3. ❌ Missing: WorexClientSkills Import
47
-
48
- **Current State:**
49
- - Uses `WorecesSkillsClient` (old/deprecated name)
50
- - Found in: `src/core/task-sdk.ts`, `src/index.ts`, `src/strategies/*.ts`
51
-
52
- **Required State:**
53
- - Use `WorexClientSkills` from `@woroces/ai-skills`
54
-
55
- **Impact:** HIGH - Wrong API usage
56
-
57
- ---
58
-
59
- ### 4. ❌ Missing: RunTaskResponse Type
60
-
61
- **Current State:**
62
- - Only re-exports `RunSkillResponse`
63
- - No `RunTaskResponse` type defined
64
-
65
- **Required State:**
66
- - `RunTaskResponse<TParsed = any>` type (can alias `RunSkillResponse`)
67
- - Exported in public API
68
-
69
- **Impact:** MEDIUM - Type clarity for API consumers
70
-
71
- ---
72
-
73
- ### 5. ❌ Missing: Executor Pattern
74
-
75
- **Current State:**
76
- - No executor passed to constructor
77
- - Directly calls `client.runSkill()`
78
-
79
- **Required State:**
80
- - Executor passed to constructor
81
- - Executor is "no-enrichment execute primitive"
82
- - `executor.execute(enrichedInput, onNotFound)` called for DIRECT execution
83
-
84
- **Impact:** HIGH - Architecture and separation of concerns
85
-
86
- ---
87
-
88
- ### 6. ❌ Missing: Task-Level Enrichment Methods
89
-
90
- **Current State:**
91
- - No calls to `enrichMemoriesWithScoping()`
92
- - No calls to `generateContextMarkdown()`
93
- - No `diagnoseSkillContent()` in not-found callback
94
-
95
- **Required State:**
96
- - Call `skillsClient.enrichMemoriesWithScoping(taskId, 'task', memoryBundle)`
97
- - Call `skillsClient.generateContextMarkdown(taskId, 'task', enrichedBundle)`
98
- - Call `skillsClient.diagnoseSkillContent(key)` in onNotFound callback
99
-
100
- **Impact:** HIGH - Missing core functionality
101
-
102
- ---
103
-
104
- ### 7. ⚠️ Partial: README Documentation
105
-
106
- **Current State:**
107
- - README shows old API (`TaskSDK`, `WorecesSkillsClient`)
108
- - Describes algorithm but doesn't match implementation
109
- - Missing new class-based API examples
110
-
111
- **Required State:**
112
- - Update to show `WorexClientTasks` class
113
- - Show constructor with `skillsClient` and `executor`
114
- - Document canonical algorithm accurately
115
- - Add note about private package and naming leakage acceptance
116
-
117
- **Impact:** MEDIUM - Documentation accuracy
118
-
119
- ---
120
-
121
- ### 8. ⚠️ Partial: Type Exports
122
-
123
- **Current State:**
124
- - Exports `RunTaskRequest`, `RunSkillResponse`, `ExecutionType`
125
- - Missing `RunTaskResponse`
126
-
127
- **Required State:**
128
- - Export `RunTaskResponse` type
129
- - Ensure all types are properly exported
130
-
131
- **Impact:** LOW - Type completeness
132
-
133
- ---
134
-
135
- ## Implementation Status by File
136
-
137
- ### ✅ Working (but needs refactor)
138
- - `.tests/test-run-task.ts` - Test passes with current implementation
139
- - Function-based API (`runTask` function) works
140
-
141
- ### ❌ Needs Complete Rewrite
142
- - `src/core/task-sdk.ts` - Missing canonical algorithm, wrong class name, wrong constructor
143
- - `src/index.ts` - Wrong imports, missing class export
144
-
145
- ### ⚠️ Needs Updates
146
- - `src/types/task-types.ts` - Missing `RunTaskResponse` type
147
- - `src/types/index.ts` - Missing `RunTaskResponse` export
148
- - `README.md` - Outdated API documentation
149
- - `examples/basic-usage.ts` - Uses old API
150
-
151
- ### ✅ Can Keep (with updates)
152
- - `src/strategies/*.ts` - Strategy pattern files (may not be needed if simplified)
153
- - `src/builders/*.ts` - Builder pattern (can keep)
154
- - `src/methods/*.ts` - Convenience methods (can keep)
155
-
156
- ---
157
-
158
- ## Verification Checklist (Current vs Required)
159
-
160
- | Item | Current | Required | Status |
161
- |------|---------|----------|--------|
162
- | Class name | `TaskSDK` | `WorexClientTasks` | ❌ |
163
- | Client import | `WorecesSkillsClient` | `WorexClientSkills` | ❌ |
164
- | Constructor | `(options?)` | `(skillsClient, executor)` | ❌ |
165
- | TaskId extraction | ❌ Missing | ✅ Required | ❌ |
166
- | Memory enrichment | ❌ Missing | ✅ Required (level='task') | ❌ |
167
- | Context generation | ❌ Missing | ✅ Required (level='task') | ❌ |
168
- | Executor pattern | ❌ Missing | ✅ Required | ❌ |
169
- | RunTaskResponse type | ❌ Missing | ✅ Required | ❌ |
170
- | Not-found diagnosis | ❌ Missing | ✅ Required | ❌ |
171
- | README accuracy | ⚠️ Partial | ✅ Complete | ⚠️ |
172
-
173
- ---
174
-
175
- ## Priority Order for Implementation
176
-
177
- 1. **P0 - Critical (Blocks functionality)**
178
- - Implement canonical `runTask` algorithm
179
- - Replace `TaskSDK` with `WorexClientTasks`
180
- - Update to `WorexClientSkills`
181
- - Add executor pattern
182
-
183
- 2. **P1 - High (API correctness)**
184
- - Add `RunTaskResponse` type
185
- - Update constructor signature
186
- - Add task-level enrichment calls
187
- - Add not-found diagnosis callback
188
-
189
- 3. **P2 - Medium (Documentation)**
190
- - Update README with new API
191
- - Update examples
192
- - Add type exports
193
-
194
- ---
195
-
196
- ## Notes
197
-
198
- - Test currently passes because it's using the function-based API that calls `runSkill` directly
199
- - The canonical algorithm is documented in `.docs/code-used-before/run-task.txt`
200
- - All required methods (`enrichMemoriesWithScoping`, `generateContextMarkdown`, `diagnoseSkillContent`) are confirmed to be public on `WorexClientSkills`
201
- - Executor comes from `WorexClientSkills` (method/property on the client)
@@ -1,109 +0,0 @@
1
- # Integration facts: ai-tasks (for clean implementation)
2
-
3
- This doc answers “what you need to know about ai-tasks” for wiring and file paths. It does **not** answer everything; focus is on **(1) how LLMs are called** and **(3) how tasks are invoked** so you can write a tight Cursor brief with exact scaffolding.
4
-
5
- ---
6
-
7
- ## 1. How ai-tasks calls LLMs today
8
-
9
- ### No direct LLM calls in ai-tasks
10
-
11
- - **ai-tasks does not call an LLM API directly.** There is no `getClient()`, `aiGateway`, or provider router in this repo.
12
- - Narrix flows go through **external packages**: `@narrices/narrix-ingest` and `@narrices/narrix-runner`.
13
- - The “completion” from ai-tasks’ perspective is **`runner.run({ cni, datasetId, sourceMeta })`**. The actual LLM calls happen inside the narrix pack/runner (outside ai-tasks).
14
-
15
- ### Where it’s wired
16
-
17
- | Concern | Location | Notes |
18
- |--------|----------|--------|
19
- | Client singleton | `src/narrix/narrixClient.ts` | `getNarrixClient()` returns `{ ingest, runner }`. Singleton `Promise<NarrixClient>`. |
20
- | Ingest | `defaultIngest` from `@narrices/narrix-ingest` | Used as-is. |
21
- | Runner | `createRunner()` from `@narrices/narrix-runner` | Created once with `runtime: { onProcessorNotMatched: "attachError", onMissingMapping: "attachError", deterministicSort: true }`. |
22
- | Usage | `src/narrix/runNarrixForRecord.ts`, `runNarrixForChat.ts`, `runNarrixForText.ts`, `runNarrixForDocs.ts` | Each gets client via `getNarrixClient()`, calls `ingest.toCni(...)` then `runner.run(...)`. |
23
-
24
- ### Function signature that effectively “runs” the AI
25
-
26
- - **Ingest:** `ingest.toCni({ kind, input })` → CNI or error.
27
- - **Run:** `runner.run({ cni, datasetId, sourceMeta })` → `{ entity, signals, stories, passes, meta }`.
28
-
29
- So: **there is no shared “completion” or “getClient” for a generic LLM in ai-tasks.** If you need to add a new path that calls an LLM directly (e.g. OpenAI), you’d introduce that in ai-tasks (or in a separate gateway package) and document it here.
30
-
31
- ### Prompt templates
32
-
33
- - **No prompt-templates system in ai-tasks.** Prompts live inside the narrix packs/runner. The only “template”-like behavior in ai-tasks is in the **task SDK** when running non-local tasks: it uses `generateContextMarkdown` and builds a prompt from skill content + memory (see `task-sdk.ts`). For **local tasks** (e.g. narrix), the handler only receives `{ input, ctx }` and returns a value; no prompt assembly in this repo.
34
-
35
- ---
36
-
37
- ## 2. Where runtime config lives
38
-
39
- - **Env vars:** Primary. Examples:
40
- - `USE_NARRIX_INGEST` → `"1"` to enable narrix (see `src/narrix/flags.ts`).
41
- - `NARRIX_DEBUG` → `"1"` for debug logs (`src/narrix/task.ts`).
42
- - `NARRIX_DATASET_ID`, `NARRIX_PLAYGROUND_IN`, `NARRIX_PLAYGROUND_OUT` for playgrounds (e.g. `narrixSubnetPlayground.ts`).
43
- - `MONGO_LOGS_DB` for task SDK / execution memory (e.g. `task-sdk.ts`, `index.ts`).
44
- - **Flags module:** `src/narrix/flags.ts` — single export `narrixFlags = { useNarrixIngest: process.env.USE_NARRIX_INGEST === "1" }`. No other centralized flags in src.
45
- - **No separate config file or config module** in the repo; everything is env-driven or hardcoded defaults.
46
-
47
- ---
48
-
49
- ## 3. How tasks are invoked
50
-
51
- ### narrixRunHandler: direct vs registry
52
-
53
- - **Registered in the task registry** and also **callable directly**:
54
- - **Registry:** `src/narrix/index.ts` does `registerLocalTask(NARRIX_RUN_SKILL_KEY, narrixRunHandler)` with `NARRIX_RUN_SKILL_KEY = "skills/skill.local:narrixRun"`. So when the SDK looks up the handler by `skillKey`, it gets the handler from the registry and runs it.
55
- - **Direct:** Tests and playground code call `narrixRunHandler({ input, ctx })` directly (e.g. `test/narrix/record.test.ts`, `src/localTasks/narrixSubnetPlayground.ts`).
56
-
57
- ### How the dispatcher invokes the handler
58
-
59
- - **Entry:** `WorexClientTasks.runTask(input)` in `src/core/task-sdk.ts`.
60
- - **Lookup:** `handler = getLocalTask(request.skillKey)` from `src/localTasks/registry.js` (registry is keyed by full skillKey, e.g. `skills/skill.local:narrixRun`).
61
- - **Invocation:** `await handler({ input: input.input, ctx })` where `ctx` is built from the request (see below). So the handler receives **one argument: `{ input, ctx }`**.
62
-
63
- ### Handler signature (what you can rely on)
64
-
65
- ```ts
66
- // src/localTasks/types.ts
67
- type LocalTaskHandler = (args: {
68
- input: any; // ← request.input (RunTaskRequest.input)
69
- ctx: LocalTaskContext;
70
- }) => Promise<any>;
71
- ```
72
-
73
- - **`input`** = `RunTaskRequest.input` (the task payload; for narrix: `medium`, `datasetId`, `record`/`text`/`document`/`thread`, etc.).
74
- - **`ctx`** = `{ skillKey, jobMemory, taskMemory, executionMemory, variables, jobId, agentId, graphId, nodeId, prevNodeId, coreSkillId, masterSkillId, masterSkillActivityId }` (all from the request).
75
-
76
- ### Can arguments include an options object?
77
-
78
- - **Yes, but only via the single `input` object.** The handler does **not** get a second “options” parameter. So any options must be:
79
- - **Inside `request.input`** (e.g. `input.options` or `input.someFlag`), or
80
- - **In `ctx.variables`** (e.g. `ctx.variables.options`).
81
- - `RunTaskRequest` extends `RunSkillRequest` and includes `input`, `variables`, `jobMemory`, `taskMemory`, `executionMemory`, etc. So callers can pass an options object as part of `input` or via `variables`; the handler reads it from `args.input` or `args.ctx.variables`.
82
-
83
- ---
84
-
85
- ## 4. Where you’re allowed to store artifacts (dev/prod)
86
-
87
- - **In repo:** Playgrounds write under **local filesystem** only, e.g. `.tests/test-output/subnets`, `.tests/test-output/assets`, etc., with paths from env or defaults (`NARRIX_PLAYGROUND_IN`, `NARRIX_PLAYGROUND_OUT`).
88
- - **No S3/Blob storage** or artifact service is referenced in `src/`. So for now: **local filesystem only** in dev; prod artifact behavior is undefined in this codebase.
89
- - **Retention:** No retention rules or “store nothing” policy is implemented in ai-tasks. If you need retention or “no persistence,” that would be a new contract (e.g. in a wrapper or platform that calls ai-tasks).
90
-
91
- ---
92
-
93
- ## 5. Downstream contract (who consumes the narrix result)
94
-
95
- - **Who consumes:** Anything that calls `runTask` (or the executor) and gets back a `RunTaskResponse<TParsed>`. For **local tasks**, the response is built in `task-sdk.ts`: the handler’s return value is used as `parsed` and also stringified into `rawText` and `flexMd.payloads.value`.
96
- - **Response shape (local task):**
97
- - `skillKey`, `rawText` (JSON string of handler result), `flexMd: { frame: "localTask.v1", payloads: { value: "<same JSON>" } }`, `parsed` (handler result), `metadata: { instructionVersion: "local", activityId, durationMs, localSkillKey }`.
98
- - **answerMarkdown:** Not present in current narrix types or local-task response. The narrix output types (`NarrixRunOutput`) have `entity`, `signals`, `stories`, `passes`, `meta` — no `answerMarkdown`. If downstream wants markdown:
99
- - Either add it to the handler’s return value (and thus to `parsed` and `flexMd.payloads`) in the same response object, or
100
- - Store it elsewhere and put a ref in the response (would require a new convention and possibly artifact storage).
101
-
102
- ---
103
-
104
- ## Quick reference for (1) and (3)
105
-
106
- - **LLM:** ai-tasks does not call an LLM directly. Narrix uses `getNarrixClient()` → `ingest.toCni()` + `runner.run()`. No shared getClient/aiGateway; no prompt-templates system in repo.
107
- - **Task invocation:** `narrixRunHandler` is registered under `skill.local:narrixRun` and invoked by the SDK with **one argument: `{ input, ctx }`**. `input` = `RunTaskRequest.input`; options only via `input` or `ctx.variables`. No second “options” parameter.
108
-
109
- Use this plus the exact file paths above for a minimal-assumptions Cursor brief and code scaffolding.