@exellix/ai-tasks 8.4.2 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.docs/DOWNSTREAM_ENV.md +42 -0
  2. package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +64 -0
  3. package/.docs/INTERMEDIATE_STEPS.md +82 -0
  4. package/.docs/activity-structure.md +31 -0
  5. package/.docs/ai-task-ai-scoping-spec.md +338 -0
  6. package/.docs/ai-tasks-model-profile-aliases-7x.md +74 -0
  7. package/.docs/blockers-and-issues.md +346 -0
  8. package/.docs/building-runTask-sdk.md +659 -0
  9. package/.docs/building-skill-execution-orchestrator.md +968 -0
  10. package/.docs/code-used-before/run-task.txt +39 -0
  11. package/.docs/code-used-before/task-executor.ts.old +57 -0
  12. package/.docs/code-used-before/test-run-task.ts.old +42 -0
  13. package/.docs/code-used-before/types.txt +23 -0
  14. package/.docs/env-ready-policy.md +40 -0
  15. package/.docs/flow-io/flow-README.md +76 -0
  16. package/.docs/flow-io/narrix.md +124 -0
  17. package/.docs/flow-io/web-scoping.md +135 -0
  18. package/.docs/flow-io/xynthesis-post.md +154 -0
  19. package/.docs/flow-io/xynthesis-pre.md +181 -0
  20. package/.docs/gap-analysis.md +201 -0
  21. package/.docs/integration-facts-ai-tasks.md +109 -0
  22. package/.docs/investigation/ai-skills.md +170 -0
  23. package/.docs/investigation/external-packages-assignments.md +66 -0
  24. package/.docs/investigation/integration-summary.md +20 -0
  25. package/.docs/investigation/narrix-catalox.md +29 -0
  26. package/.docs/investigation/workplan-close-graph-engine-gaps.md +101 -0
  27. package/.docs/logging-stack.md +30 -0
  28. package/.docs/memory-narrix-adapter-developer-guide.md +402 -0
  29. package/.docs/memory-narrix-adapter-requirements.md +112 -0
  30. package/.docs/narrix-context-consumption-gap.md +184 -0
  31. package/.docs/narrix-context-downstream-report.md +30 -0
  32. package/.docs/narrix-ingest-and-packs-library-spec.md +240 -0
  33. package/.docs/narrix-record-input-current-design.md +48 -0
  34. package/.docs/pacakge.md +48 -0
  35. package/.docs/possible-components/README.md +11 -0
  36. package/.docs/possible-components/integration/README.md +10 -0
  37. package/.docs/possible-components/integration/gaps-when-merging.md +16 -0
  38. package/.docs/possible-components/integration/platform.md +54 -0
  39. package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +26 -0
  40. package/.docs/possible-components/integration/roadmap-and-checklists.md +54 -0
  41. package/.docs/possible-components/post-component/README.md +18 -0
  42. package/.docs/possible-components/post-component/builder-guide.md +175 -0
  43. package/.docs/possible-components/post-component/gaps-and-artifacts.md +52 -0
  44. package/.docs/possible-components/post-component/handler-audit.md +47 -0
  45. package/.docs/possible-components/post-component/handler-polish.md +41 -0
  46. package/.docs/possible-components/post-component/unified-protocol.md +59 -0
  47. package/.docs/possible-components/pre-component/README.md +22 -0
  48. package/.docs/possible-components/pre-component/builder-guide.md +127 -0
  49. package/.docs/possible-components/pre-component/gaps-and-artifacts.md +35 -0
  50. package/.docs/possible-components/pre-component/handler-ai-scoping.md +45 -0
  51. package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +49 -0
  52. package/.docs/possible-components/pre-component/handler-narrix-system2.md +35 -0
  53. package/.docs/possible-components/pre-component/handler-synthesized-context.md +65 -0
  54. package/.docs/possible-components/pre-component/handler-web-scope.md +29 -0
  55. package/.docs/possible-components/pre-component/unified-protocol.md +89 -0
  56. package/.docs/prefer-openrouter-routing-policy.md +132 -0
  57. package/.docs/questions-for-ai-skills.md +123 -0
  58. package/.docs/realtime-narrixing-gap-analysis.md +40 -0
  59. package/.docs/realtime-narrixing.md +433 -0
  60. package/.docs/run-context-object.md +32 -0
  61. package/.docs/session-id-usage.md +26 -0
  62. package/.docs/skill-library-spec.md +249 -0
  63. package/.docs/synthesized-context-strategy-spec.md +906 -0
  64. package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +46 -0
  65. package/.docs/web-scopper-embed.md +93 -0
  66. package/.docs/xynthesis-wiring-and-io.md +12 -0
  67. package/CHANGELOG.md +16 -0
  68. package/README.md +15 -13
  69. package/dist/core/task-sdk.d.ts.map +1 -1
  70. package/dist/core/task-sdk.js +40 -15
  71. package/dist/core/task-sdk.js.map +1 -1
  72. package/dist/execution-strategies/constants.d.ts +11 -4
  73. package/dist/execution-strategies/constants.d.ts.map +1 -1
  74. package/dist/execution-strategies/constants.js +11 -4
  75. package/dist/execution-strategies/constants.js.map +1 -1
  76. package/dist/execution-strategies/executionStrategyCatalogMetadata.d.ts +6 -3
  77. package/dist/execution-strategies/executionStrategyCatalogMetadata.d.ts.map +1 -1
  78. package/dist/execution-strategies/executionStrategyCatalogMetadata.js +36 -5
  79. package/dist/execution-strategies/executionStrategyCatalogMetadata.js.map +1 -1
  80. package/dist/execution-strategies/executionStrategyRequestPayload.d.ts +19 -0
  81. package/dist/execution-strategies/executionStrategyRequestPayload.d.ts.map +1 -0
  82. package/dist/execution-strategies/executionStrategyRequestPayload.js +21 -0
  83. package/dist/execution-strategies/executionStrategyRequestPayload.js.map +1 -0
  84. package/dist/execution-strategies/runExecutionStrategyViaXynthesis.d.ts +35 -0
  85. package/dist/execution-strategies/runExecutionStrategyViaXynthesis.d.ts.map +1 -0
  86. package/dist/execution-strategies/runExecutionStrategyViaXynthesis.js +129 -0
  87. package/dist/execution-strategies/runExecutionStrategyViaXynthesis.js.map +1 -0
  88. package/dist/index.d.ts +16 -5
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +15 -5
  91. package/dist/index.js.map +1 -1
  92. package/dist/internal/resolveLlmCallForXynthesis.d.ts.map +1 -1
  93. package/dist/internal/resolveLlmCallForXynthesis.js +6 -0
  94. package/dist/internal/resolveLlmCallForXynthesis.js.map +1 -1
  95. package/dist/internal/runPostStepLlmCall.d.ts.map +1 -1
  96. package/dist/internal/runPostStepLlmCall.js +8 -3
  97. package/dist/internal/runPostStepLlmCall.js.map +1 -1
  98. package/dist/invocation/resolveProfileInvocationRouting.js +2 -2
  99. package/dist/invocation/resolveProfileInvocationRouting.js.map +1 -1
  100. package/dist/planWebScopeQuestions/index.d.ts +4 -8
  101. package/dist/planWebScopeQuestions/index.d.ts.map +1 -1
  102. package/dist/planWebScopeQuestions/index.js +109 -149
  103. package/dist/planWebScopeQuestions/index.js.map +1 -1
  104. package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts +21 -21
  105. package/dist/task-strategies/canonicalInputExecutionStrategies.js +12 -12
  106. package/dist/task-strategies/canonicalInputExecutionStrategies.js.map +1 -1
  107. package/dist/task-strategies/types.d.ts +4 -2
  108. package/dist/task-strategies/types.d.ts.map +1 -1
  109. package/dist/types/llmCall.d.ts +1 -1
  110. package/dist/types/llmCall.d.ts.map +1 -1
  111. package/dist/types/llmCall.js.map +1 -1
  112. package/dist/utils/aiProfileModelFormat.d.ts +2 -2
  113. package/dist/utils/aiProfileModelFormat.js +2 -2
  114. package/dist/utils/aiProfilesCatalog.d.ts +16 -0
  115. package/dist/utils/aiProfilesCatalog.d.ts.map +1 -0
  116. package/dist/utils/aiProfilesCatalog.js +23 -0
  117. package/dist/utils/aiProfilesCatalog.js.map +1 -0
  118. package/dist/utils/resolveAiProfileModel.d.ts +2 -2
  119. package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
  120. package/dist/utils/resolveAiProfileModel.js +5 -5
  121. package/dist/utils/resolveAiProfileModel.js.map +1 -1
  122. package/dist/utils/routeModelConfigSlots.d.ts +3 -1
  123. package/dist/utils/routeModelConfigSlots.d.ts.map +1 -1
  124. package/dist/utils/routeModelConfigSlots.js +2 -1
  125. package/dist/utils/routeModelConfigSlots.js.map +1 -1
  126. package/documenations/upstream-feature-requests/README.md +3 -2
  127. package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +5 -2
  128. package/documenations/upstream-feature-requests/xynthesis-execution-strategies-option-a.md +637 -0
  129. package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +2 -2
  130. package/package.json +3 -4
@@ -0,0 +1,637 @@
1
+ # `@exellix/xynthesis` — MAIN execution strategies (Option A: absorb FuncX wrappers)
2
+
3
+ Status: **shipped** in `@exellix/xynthesis` ≥ 4.4.0; ai-tasks **8.5.0** consumes via `runExecutionStrategyViaXynthesis`
4
+ Owner: `@exellix/xynthesis`
5
+ Filed by: `@exellix/ai-tasks`
6
+ Consumer: `@exellix/ai-tasks` 8.4+ (sole consumer — no separate package planned)
7
+ Target release: **`@exellix/xynthesis` ≥ 4.4.0** (semver minor; ai-tasks follow-up in 8.5.x)
8
+ Pinned in ai-tasks today: `@exellix/xynthesis@^4.3.1`
9
+
10
+ Related:
11
+
12
+ - [`xynthesis-orchestrator-invoke-contract-4.2.md`](./xynthesis-orchestrator-invoke-contract-4.2.md) — invoke contract this FR extends
13
+ - [`funcx-scoping-integration-gaps.md`](../funcx-scoping-integration-gaps.md) §6 — current FuncX wire contracts (source of truth for shapes)
14
+ - [`funcx-catalog-hosting-checklist.md`](../funcx-catalog-hosting-checklist.md) — what FuncX hosts today (to migrate prompts into xynthesis/Catalox)
15
+ - ai-tasks reference adapters: [`genericExecutionFuncxEnvelope.ts`](../../src/execution-strategies/genericExecutionFuncxEnvelope.ts)
16
+
17
+ ---
18
+
19
+ ## 0. Decision record
20
+
21
+ **Chosen:** Option A — implement planner / optimizer / consolidated web-scope planning as **first-class xynthesis actions**, invoked like audit, polish, and scoping.
22
+
23
+ **Rejected:** Option B — a new `@exellix/*` package for execution strategies. Only `@exellix/ai-tasks` consumes these capabilities; a separate package would add publish/version overhead without reuse.
24
+
25
+ **Goal:** Remove **direct** `@x12i/funcx` usage from `@exellix/ai-tasks` for MAIN wrappers while preserving behavior, catalogs, and observability parity with other xynthesis hops.
26
+
27
+ ---
28
+
29
+ ## 1. Summary
30
+
31
+ Today `@exellix/ai-tasks` calls FuncX **`run(functionId, payload)`** for:
32
+
33
+ | Capability | FuncX `functionId` | When |
34
+ |------------|-------------------|------|
35
+ | Planner | `execution/plan` | Once before first MAIN attempt |
36
+ | Optimizer | `execution/evaluate-result` | After each MAIN attempt (retry loop) |
37
+ | Web-scope questions (optional backend) | `research/plan-questions` | Narrix web-scope preprocessor |
38
+
39
+ These hops **bypass** the 8.4 invoke contract: no `modelConfig` slots, no Optimixer via `outputExpectation`, no `InvokeAttemptSummary`, no unified `LlmCallObservation`.
40
+
41
+ **Ask:** xynthesis exposes three structured actions on the same surface as audit/polish/scoping (`executeXynthesisAction` or thin dedicated wrappers), owns prompts + JSON schemas + Optimixer defaults, and returns typed results ai-tasks merges into `RunTaskRequest` before/after MAIN.
42
+
43
+ | Orchestrator sends (ai-tasks) | xynthesis owns internally |
44
+ |------------------------------|---------------------------|
45
+ | Wire **model** (from `modelConfig` slot — see §4) | — |
46
+ | **outputExpectation** | — |
47
+ | **temperature**, **topP**, **reasoningEffort** | — |
48
+ | Structured **input** payload (§5) | Prompt rendering from Catalox templates |
49
+ | **workScope** (`jobId`, `taskId`, `agentId`, identity) | Correlation / Activix attribution |
50
+ | — | **max completion tokens** (Optimixer) |
51
+ | — | Provider invoke (OpenRouter / gateway) |
52
+ | — | JSON parse + schema validation |
53
+
54
+ **ai-tasks keeps:** `executionStrategies` validation/sort, MAIN retry loop, `applyPlannerOutputToRequest` / `applyOptimizerFeedbackToRequest`, intermediateSteps / trace assembly. xynthesis does **not** call ai-skills or execute MAIN.
55
+
56
+ ---
57
+
58
+ ## 2. Background — current ai-tasks behavior
59
+
60
+ ### 2.1 Planner flow
61
+
62
+ 1. `resolveExecutionStrategies` sorts `executionStrategies[]` rows with `strategyKey: "planner"`, `phase: "before"`.
63
+ 2. For each planner row (typically one), ai-tasks builds `buildExecutionStrategyRequestPayload(...)` and calls `runPlannerFuncx` → FuncX `execution/plan`.
64
+ 3. Response adapted by `adaptExecutionPlanResult` → merged via `applyPlannerOutputToRequest`:
65
+ - `variables` (shallow merge)
66
+ - `templateTokens` (+ `instructions` / `prompt` keys when present)
67
+ - `executionMemory.executionStrategies.lastPlanner` / `plannerChain`
68
+
69
+ ### 2.2 Optimizer flow
70
+
71
+ 1. First `optimizer` row after sort drives retry loop (`maxIterations` default 3, env `AI_TASKS_OPTIMIZER_MAX_ITERATIONS`).
72
+ 2. Each iteration: `runDirect` (MAIN via ai-skills) → build `mainResultSummary` (rawText ≤ 12k, parsed, metadata summarized ≤ 6k) → `runOptimizerFuncx` → FuncX `execution/evaluate-result`.
73
+ 3. If `satisfied === true` or last iteration: return MAIN result.
74
+ 4. Else: `applyOptimizerFeedbackToRequest` sets `variables.optimizerFeedback`, `variables.optimizerIteration`, `variables.optimizerSuggestedChanges`, optional `templateTokens`, then retry MAIN.
75
+
76
+ ### 2.3 Web-scope questions
77
+
78
+ - **Default path (keep):** `runPlanWebScopeQuestions` → `runPostStepLlmCall` → `executeXynthesisAction` with inline system prompt + `parseAndValidatePlanWebScopeQuestionsOutput`.
79
+ - **FuncX path (deprecate):** `backend: "funcx"` → `research/plan-questions` generic envelope.
80
+
81
+ ### 2.4 Problem with FuncX path
82
+
83
+ [`runFuncxExecutionStrategy.ts`](../../src/execution-strategies/runFuncxExecutionStrategy.ts) uses `createClient({ backend: "openrouter" })` with **no** `RunTaskRequest.modelConfig` forwarding. Planner/optimizer ignore `preActionModel` / `postActionModel` and the unified observability stack.
84
+
85
+ ---
86
+
87
+ ## 3. Scope
88
+
89
+ ### 3.1 In scope (xynthesis)
90
+
91
+ - Three new **`SidekickActionType`** values (names provisional — see §4.1).
92
+ - Catalox sidekick templates + Optimixer catalog entries for each action.
93
+ - Public TypeScript request/response types + JSON schemas.
94
+ - Integration with `executeXynthesisAction` (preferred) or dedicated exports that delegate to it.
95
+ - Structured JSON output validation (same shapes ai-tasks adapters expect today).
96
+ - `InvokeAttemptSummary` / token resolution / model routing identical to audit/polish.
97
+ - Test hook: injectable invoker (same pattern as existing synthesis tests).
98
+
99
+ ### 3.2 Out of scope (stays in ai-tasks)
100
+
101
+ - `RunTaskRequest.executionStrategies` array shape and validation.
102
+ - Optimizer **retry loop** and `maxIterations` policy.
103
+ - Merging planner/optimizer outputs into gateway request fields.
104
+ - FuncX catalog hosting for `execution/*` and `research/plan-questions` (deprecated after migration).
105
+ - MAIN skill execution (`@exellix/ai-skills`).
106
+
107
+ ### 3.3 Deprecation
108
+
109
+ After ai-tasks migrates:
110
+
111
+ - ai-tasks removes direct `@x12i/funcx` dependency (may remain transitive via xynthesis/narrix).
112
+ - `backend: "funcx"` on `runPlanWebScopeQuestions` removed in ai-tasks major/minor follow-up.
113
+ - FuncX function ids remain documented for hosts that still call FuncX directly during transition.
114
+
115
+ ---
116
+
117
+ ## 4. Public API
118
+
119
+ ### 4.1 New sidekick actions
120
+
121
+ Add to xynthesis `SidekickActionType`:
122
+
123
+ | Action key | Purpose | ai-tasks `LlmCallStage` |
124
+ |------------|---------|-------------------------|
125
+ | `execution-plan` | Planner before MAIN | `execution-strategy-planner` |
126
+ | `execution-evaluate-result` | Optimizer after MAIN attempt | `execution-strategy-optimizer` |
127
+ | `plan-web-scope-questions` | Web-scope question planner (consolidate inline prompt) | `plan-web-scope-questions` (existing stage) |
128
+
129
+ **Canonical aliases** (for Catalox / docs): mirror former FuncX ids `execution/plan`, `execution/evaluate-result`, `research/plan-questions` as **documentation aliases only** — xynthesis uses sidekick action keys, not FuncX `functionId` routing.
130
+
131
+ ### 4.2 Entry points
132
+
133
+ **Preferred — extend existing hop API:**
134
+
135
+ ```typescript
136
+ import type { OutputExpectation } from "@exellix/xynthesis/ai-actions";
137
+ import type { OptimixerReasoningEffort } from "@x12i/optimixer";
138
+
139
+ /** Shared invoke fields — same contract as audit/polish (see xynthesis-orchestrator-invoke-contract-4.2.md). */
140
+ type ExecutionStrategyInvokeBase = {
141
+ model: string;
142
+ outputExpectation: OutputExpectation;
143
+ temperature?: number;
144
+ topP?: number;
145
+ reasoningEffort?: OptimixerReasoningEffort;
146
+ timeoutMs?: number;
147
+ maxOutputLength?: number;
148
+ gateway?: { agentId?: string; sessionId?: string; temperature?: number };
149
+ workScope?: {
150
+ jobId?: string;
151
+ taskId?: string;
152
+ agentId?: string;
153
+ identity?: Record<string, unknown>;
154
+ };
155
+ /** Strategy row args minus functionId — opaque JSON-safe knobs forwarded into template context. */
156
+ strategyArgs?: Record<string, unknown>;
157
+ };
158
+
159
+ /** Planner — maps from buildPlannerGenericPayload envelope. */
160
+ export type RunExecutionPlanRequest = ExecutionStrategyInvokeBase & {
161
+ sidekickAction: "execution-plan";
162
+ goal: string;
163
+ input?: unknown;
164
+ context: ExecutionStrategyContext;
165
+ };
166
+
167
+ /** Optimizer — maps from buildOptimizerGenericPayload envelope. */
168
+ export type RunExecutionEvaluateResultRequest = ExecutionStrategyInvokeBase & {
169
+ sidekickAction: "execution-evaluate-result";
170
+ goal: string;
171
+ input?: unknown;
172
+ context: ExecutionStrategyContext;
173
+ result: MainResultSummary;
174
+ iterationIndex: number;
175
+ };
176
+
177
+ /** Web-scope — maps from buildResearchPlanQuestionsPayload envelope. */
178
+ export type RunPlanWebScopeQuestionsRequest = ExecutionStrategyInvokeBase & {
179
+ sidekickAction: "plan-web-scope-questions";
180
+ goal: string;
181
+ input: { nodeInput?: unknown; rawRecord?: unknown };
182
+ context?: {
183
+ memorySummary?: unknown;
184
+ xynthesized?: { job?: unknown; task?: unknown };
185
+ };
186
+ args: {
187
+ maxQuestions: number; // 1–20, clamped by xynthesis
188
+ sourceType: "web";
189
+ allowSkip: boolean;
190
+ includeReasons?: boolean;
191
+ };
192
+ };
193
+
194
+ export type ExecutionStrategyContext = {
195
+ skillKey?: string;
196
+ variables?: Record<string, unknown>;
197
+ jobContext?: Record<string, unknown>;
198
+ jobMemory?: unknown;
199
+ taskMemory?: unknown;
200
+ executionMemory?: unknown;
201
+ jobId?: string;
202
+ taskId?: string;
203
+ agentId?: string;
204
+ graphId?: string;
205
+ nodeId?: string;
206
+ prevNodeId?: string;
207
+ coreSkillId?: string;
208
+ includeContextInPrompt?: boolean;
209
+ };
210
+
211
+ export type MainResultSummary = {
212
+ rawText?: string;
213
+ parsed?: unknown;
214
+ skillKey?: string;
215
+ metadata?: unknown;
216
+ };
217
+ ```
218
+
219
+ **Dispatch:** Either overload `executeXynthesisAction` to accept these `sidekickAction` values, or export:
220
+
221
+ ```typescript
222
+ export async function runExecutionPlan(req: RunExecutionPlanRequest): Promise<ExecutionPlanResult>;
223
+ export async function runExecutionEvaluateResult(req: RunExecutionEvaluateResultRequest): Promise<ExecutionEvaluateResult>;
224
+ export async function runPlanWebScopeQuestionsAction(req: RunPlanWebScopeQuestionsRequest): Promise<PlanWebScopeQuestionsResult>;
225
+ ```
226
+
227
+ All three must return `{ result, invokeSummary, debugTrace? }` consistent with other actions.
228
+
229
+ ### 4.3 Model slot mapping (ai-tasks caller policy)
230
+
231
+ ai-tasks resolves model aliases before invoke:
232
+
233
+ | Action | Default `modelConfig` slot | Rationale |
234
+ |--------|---------------------------|-----------|
235
+ | `execution-plan` | **`preActionModel`** | Runs before MAIN; same phase family as PRE synthesis |
236
+ | `execution-evaluate-result` | **`postActionModel`** | Evaluative hop (like audit); judges MAIN output quality |
237
+ | `plan-web-scope-questions` | **`preActionModel`** | Pre-MAIN Narrix web-scope preprocessor |
238
+
239
+ Per-strategy override (ai-tasks follow-up, optional): `executionStrategies[].llmCall?.model` wins over slot default when set.
240
+
241
+ ### 4.4 OutputExpectation defaults (xynthesis Optimixer catalog)
242
+
243
+ Register Catalox defaults per action (ai-tasks may override via `llmCall.outputExpectation`):
244
+
245
+ | Action | Suggested default | Notes |
246
+ |--------|-------------------|-------|
247
+ | `execution-plan` | `{ size: { mode: "absolute", minWords: 80, maxWords: 600 }, density: "concise" }` | Structured plan text + optional variables |
248
+ | `execution-evaluate-result` | `{ size: { mode: "absolute", minWords: 40, maxWords: 400 }, density: "concise" }` | Boolean satisfied + feedback |
249
+ | `plan-web-scope-questions` | `{ size: { mode: "absolute", minWords: 50, maxWords: 800 }, density: "concise" }` | JSON array of questions |
250
+
251
+ Expose via `resolveOutputExpectation("execution-plan" | ...)` when action keys are added.
252
+
253
+ ---
254
+
255
+ ## 5. Input contracts (wire payloads)
256
+
257
+ These mirror today's FuncX generic envelope built in ai-tasks. xynthesis templates receive **`goal`**, **`input`**, **`context`**, optional **`result`** (optimizer only), **`args`**, and **`strategyArgs`**.
258
+
259
+ ### 5.1 Planner input
260
+
261
+ Built by ai-tasks `buildPlannerGenericPayload`:
262
+
263
+ ```json
264
+ {
265
+ "goal": "Plan how to execute the MAIN gateway skill for skillKey \"my.skill\" (coreSkillId: node-1).",
266
+ "input": { "...": "task input — opaque" },
267
+ "context": {
268
+ "skillKey": "my.skill",
269
+ "variables": {},
270
+ "jobContext": {},
271
+ "jobMemory": {},
272
+ "taskMemory": {},
273
+ "executionMemory": {},
274
+ "jobId": "uuid",
275
+ "taskId": "uuid",
276
+ "agentId": "uuid",
277
+ "graphId": "optional",
278
+ "nodeId": "optional",
279
+ "prevNodeId": "optional",
280
+ "coreSkillId": "optional",
281
+ "includeContextInPrompt": false
282
+ },
283
+ "args": { "...": "optional strategy row args except functionId" },
284
+ "attribution": {
285
+ "runId": "jobId",
286
+ "subjectId": "taskId",
287
+ "actorId": "agentId",
288
+ "tags": { "caller": "ai-tasks", "jobId": "...", "taskId": "...", "agentId": "..." }
289
+ }
290
+ }
291
+ ```
292
+
293
+ **Template requirements:**
294
+
295
+ - Must **not** execute MAIN or call ai-skills.
296
+ - Use `goal` as the primary objective line in the user prompt.
297
+ - Render `input` + `context` as JSON-safe sections (truncate large blobs with explicit markers).
298
+ - Forward correlation from `workScope` / `attribution` into provider attribution fields.
299
+
300
+ ### 5.2 Optimizer input
301
+
302
+ Built by ai-tasks `buildOptimizerGenericPayload`. Same as planner plus:
303
+
304
+ ```json
305
+ {
306
+ "result": {
307
+ "rawText": "...(max ~12000 chars from ai-tasks)...",
308
+ "parsed": { "...": "skill parsed output if any" },
309
+ "skillKey": "my.skill",
310
+ "metadata": { "...": "summarized metadata max ~6000 chars" }
311
+ },
312
+ "args": {
313
+ "iterationIndex": 0,
314
+ "...": "optional strategy row args except functionId"
315
+ }
316
+ }
317
+ ```
318
+
319
+ `iterationIndex` is **zero-based** (first MAIN attempt → optimizer call with `iterationIndex: 0`).
320
+
321
+ ### 5.3 Web-scope questions input
322
+
323
+ Built by ai-tasks `buildResearchPlanQuestionsPayload`:
324
+
325
+ ```json
326
+ {
327
+ "goal": "<nodeQuestion trimmed>",
328
+ "input": {
329
+ "nodeInput": null,
330
+ "rawRecord": { "...": "optional" }
331
+ },
332
+ "context": {
333
+ "memorySummary": { "jobMemory": {}, "taskMemory": {}, "executionMemory": {} },
334
+ "xynthesized": { "job": {}, "task": {} }
335
+ },
336
+ "args": {
337
+ "maxQuestions": 5,
338
+ "sourceType": "web",
339
+ "allowSkip": true,
340
+ "includeReasons": true
341
+ }
342
+ }
343
+ ```
344
+
345
+ **Migration note:** Replace ai-tasks inline `PLAN_WEB_SCOPE_SYSTEM` string with xynthesis Catalox template producing **identical** JSON shape (§6.3).
346
+
347
+ ---
348
+
349
+ ## 6. Output contracts (structured JSON)
350
+
351
+ xynthesis validates model JSON **before** returning to ai-tasks. On parse/validation failure: throw `XynthesisResponseParseError` with raw text preserved (same as structured synthesis).
352
+
353
+ ### 6.1 Planner output — `ExecutionPlanResult`
354
+
355
+ Minimum schema (all fields optional except empty object allowed):
356
+
357
+ ```typescript
358
+ type ExecutionPlanResult = {
359
+ /** Primary merge field — preferred over plan/steps. */
360
+ instructions?: string;
361
+ plan?: string;
362
+ steps?: Array<{
363
+ title?: string;
364
+ description?: string;
365
+ reason?: string;
366
+ }>;
367
+ assumptions?: string[];
368
+ missingInputs?: string[];
369
+ suggestedContext?: string[];
370
+ /** Direct gateway overlays (optional). */
371
+ prompt?: string;
372
+ variables?: Record<string, unknown>;
373
+ templateTokens?: Record<string, unknown>;
374
+ /** Alternate nesting — ai-tasks adapters also read metadata.* today. */
375
+ metadata?: {
376
+ variables?: Record<string, unknown>;
377
+ templateTokens?: Record<string, unknown>;
378
+ };
379
+ };
380
+ ```
381
+
382
+ **Normalization (xynthesis or ai-tasks — pick one owner, document):**
383
+
384
+ - ai-tasks today merges `instructions` ← `instructions` || `plan` || rendered `steps`; appends assumptions/missingInputs/suggestedContext into `instructions` text.
385
+ - **Recommendation:** xynthesis returns **raw structured object**; ai-tasks keeps `adaptExecutionPlanResult` unchanged during migration, then optionally deletes adapter once xynthesis guarantees canonical shape.
386
+
387
+ ### 6.2 Optimizer output — `ExecutionEvaluateResult`
388
+
389
+ ```typescript
390
+ type ExecutionEvaluateResult = {
391
+ /** Required — strict boolean; only `true` stops retry loop. */
392
+ satisfied: boolean;
393
+ feedback?: string;
394
+ suggestedChanges?: string[];
395
+ issues?: Array<{
396
+ issue: string;
397
+ severity?: string;
398
+ reason?: string;
399
+ }>;
400
+ variables?: Record<string, unknown>;
401
+ templateTokens?: Record<string, unknown>;
402
+ metadata?: {
403
+ variables?: Record<string, unknown>;
404
+ templateTokens?: Record<string, unknown>;
405
+ };
406
+ };
407
+ ```
408
+
409
+ **ai-tasks merge semantics (unchanged):**
410
+
411
+ - `feedback` + rendered `suggestedChanges` + rendered `issues` → `variables.optimizerFeedback`
412
+ - `suggestedChanges` → `variables.optimizerSuggestedChanges`
413
+ - `templateTokens` shallow-merged into request
414
+ - `satisfied === true` → stop retry loop
415
+
416
+ ### 6.3 Web-scope output — `PlanWebScopeQuestionsResult`
417
+
418
+ Must match ai-tasks [`PlanWebScopeQuestionsOutput`](../../src/planWebScopeQuestions/index.ts):
419
+
420
+ ```typescript
421
+ type PlanWebScopeQuestionsResult = {
422
+ questions: Array<{
423
+ id?: string;
424
+ question: string;
425
+ reason: string;
426
+ source: "ai-driven";
427
+ }>;
428
+ confidence: number; // 0–1 inclusive
429
+ skipped?: boolean;
430
+ reasonCodes?: string[];
431
+ };
432
+ ```
433
+
434
+ **Validation rules** (port from `parseAndValidatePlanWebScopeQuestionsOutput`):
435
+
436
+ - Root must be object; `confidence` finite in [0, 1].
437
+ - `questions` array length ≤ `args.maxQuestions` (1–20).
438
+ - Each question: non-empty `question`, non-empty `reason`, `source` must be `"ai-driven"` when set.
439
+ - Empty questions + `skipped: true` allowed (e.g. `reasonCodes: ["INPUT_TOO_THIN"]`).
440
+ - xynthesis assigns UUID `id` when missing **or** leave to ai-tasks (document choice; ai-tasks can keep id generation).
441
+
442
+ **System prompt content** to migrate into Catalox (currently in ai-tasks):
443
+
444
+ ```
445
+ You are a planning assistant for web evidence collection.
446
+ Return ONLY a single JSON object (no markdown fences, no prose) with this exact shape:
447
+ {
448
+ "questions": Array<{ "id"?: string, "question": string, "reason": string, "source": "ai-driven" }>,
449
+ "confidence": number,
450
+ "skipped"?: boolean,
451
+ "reasonCodes"?: string[]
452
+ }
453
+ Rules:
454
+ - "confidence" is a number from 0 to 1.
455
+ - Each "question" must be a concrete web search or research question (non-empty string).
456
+ - Each "reason" briefly explains why that question helps (non-empty string).
457
+ - "source" must be the literal string "ai-driven" for every question entry.
458
+ - Produce at most the requested maxQuestions items in "questions".
459
+ - If you cannot propose useful questions, set "skipped": true, "questions": [], "confidence" <= 0.5, and include "reasonCodes" such as ["INPUT_TOO_THIN"].
460
+ ```
461
+
462
+ ---
463
+
464
+ ## 7. Invoke contract (must match 4.2+)
465
+
466
+ Every new action **must** follow [`xynthesis-orchestrator-invoke-contract-4.2.md`](./xynthesis-orchestrator-invoke-contract-4.2.md):
467
+
468
+ | Field | Required | Notes |
469
+ |-------|----------|-------|
470
+ | `model` | yes | Resolved alias from ai-tasks |
471
+ | `outputExpectation` | yes | Throws if missing |
472
+ | `reasoningEffort` | optional | Forward to Optimixer |
473
+ | `temperature` / `topP` | optional | Echo in `invokeSummary.executionMetadata` |
474
+ | `maxTokens` on request | optional ceiling only | Do not require hosts to pre-compute |
475
+ | Host pre-resolve via `resolveMaxTokens` | **forbidden** | Internal Optimixer only |
476
+
477
+ **Structured output:** Use JSON mode / schema-constrained generation where provider supports it; otherwise validate parse server-side and throw `XynthesisResponseParseError`.
478
+
479
+ ---
480
+
481
+ ## 8. Observability and correlation
482
+
483
+ ### 8.1 InvokeAttemptSummary
484
+
485
+ Each action returns `invokeSummary` with:
486
+
487
+ - `sidekickAction`: one of the three new keys
488
+ - `tokenResolution` / Optimixer diagnostics
489
+ - `routing` (OpenRouter vs direct)
490
+ - `executionMetadata.temperature`, `executionMetadata.topP`, effective `reasoningEffort`
491
+
492
+ ### 8.2 Activix / workScope
493
+
494
+ Forward `workScope.jobId`, `workScope.taskId`, `workScope.agentId`, and optional `identity` into xynthesis Activix phases:
495
+
496
+ - Suggested activix action types: `execution-strategy-planner`, `execution-strategy-optimizer`, `plan-web-scope-questions`
497
+
498
+ ### 8.3 ai-tasks trace integration
499
+
500
+ ai-tasks will push trace rows (already stubbed for FuncX):
501
+
502
+ - Planner: `phase: "execution_strategy_planner"`, `taskType: "pre-execution"`
503
+ - Optimizer: `phase: "execution_strategy_optimizer"`, metadata `{ iterationIndex, satisfied }`
504
+ - Web-scope: existing `plan-web-scope-questions` stage → `LlmCallObservation`
505
+
506
+ ---
507
+
508
+ ## 9. Catalox / template deliverables
509
+
510
+ For each action, ship:
511
+
512
+ 1. Sidekick template (system + user Handlebars or equivalent).
513
+ 2. Optimixer catalog spec (`reasoningEffort`, `outputIntent`, …).
514
+ 3. JSON schema for structured output validation.
515
+ 4. Studio/catalog id stable across releases (version template, not action key).
516
+
517
+ | Catalox item | Action key | Replaces FuncX id |
518
+ |--------------|------------|-------------------|
519
+ | Execution plan sidekick | `execution-plan` | `execution/plan` |
520
+ | Execution evaluate sidekick | `execution-evaluate-result` | `execution/evaluate-result` |
521
+ | Plan web scope questions sidekick | `plan-web-scope-questions` | `research/plan-questions` |
522
+
523
+ ---
524
+
525
+ ## 10. Test ergonomics
526
+
527
+ Mirror existing xynthesis test patterns:
528
+
529
+ ```typescript
530
+ /** Test-only: replace live provider call for execution-strategy actions. */
531
+ export function setExecutionStrategyActionInvoker(
532
+ fn: ((req: RunExecutionPlanRequest | RunExecutionEvaluateResultRequest) => Promise<unknown>) | null
533
+ ): void;
534
+
535
+ export function setPlanWebScopeQuestionsActionInvoker(
536
+ fn: ((req: RunPlanWebScopeQuestionsRequest) => Promise<PlanWebScopeQuestionsResult>) | null
537
+ ): void;
538
+ ```
539
+
540
+ ai-tasks will migrate `setFuncxExecutionStrategyInvoker` → xynthesis invoker or wrap `setSynthesisInvoker` with action discrimination.
541
+
542
+ ---
543
+
544
+ ## 11. Migration plan
545
+
546
+ ### Phase 1 — xynthesis ships actions (≥ 4.4.0)
547
+
548
+ - Implement three actions + Catalox templates + tests.
549
+ - Export types and schemas.
550
+ - Document in xynthesis CHANGELOG.
551
+
552
+ ### Phase 2 — ai-tasks migration (8.5.x)
553
+
554
+ - Replace `runPlannerFuncx` / `runOptimizerFuncx` with `runPostStepLlmCall`-style wrappers calling new xynthesis actions.
555
+ - Map `modelConfig.preActionModel` / `postActionModel` per §4.3.
556
+ - Add `LlmCallStage`: `execution-strategy-planner`, `execution-strategy-optimizer`.
557
+ - Extend `sidekickActionForStage` mapping in ai-tasks.
558
+ - Wire `LlmCallObservation` / `logLlmProviderInvocation` for new stages.
559
+ - Remove `runFuncxExecutionStrategy.ts`, `runResearchPlanQuestionsFuncx.ts`, direct `@x12i/funcx` imports.
560
+ - Deprecate exports: `setFuncxExecutionStrategyInvoker`, `FUNCX_*_FUNCTION_ID`, `unwrapFuncxRunValue`, `backend: "funcx"`.
561
+ - Keep `adaptExecutionPlanResult` / `adaptEvaluateResultResponse` until xynthesis output is proven stable (then inline or delete).
562
+
563
+ ### Phase 3 — cleanup
564
+
565
+ - Remove `@x12i/funcx` from ai-tasks `dependencies` and `overrides` if no transitive need.
566
+ - Update `CANONICAL_EXECUTION_STRATEGIES` catalog metadata: `runtimeKind: "xynthesis-action"` (replace `funcx-wrapper`).
567
+ - Archive FuncX hosting checklist items as deprecated.
568
+
569
+ ---
570
+
571
+ ## 12. ai-tasks follow-up checklist (after xynthesis ships)
572
+
573
+ - [ ] Bump `"@exellix/xynthesis": "^4.4.0"` (or whatever minor ships this).
574
+ - [ ] Implement `runExecutionPlannerViaXynthesis` / `runExecutionOptimizerViaXynthesis` in `src/execution-strategies/`.
575
+ - [ ] Pass `preActionModel` / `postActionModel` + `llmCall` overlays from `RunTaskRequest`.
576
+ - [ ] Update `runPlanWebScopeQuestions` to call xynthesis action only (remove FuncX backend).
577
+ - [ ] Remove `@x12i/funcx` direct dependency.
578
+ - [ ] Update tests: replace `setFuncxExecutionStrategyInvoker` with xynthesis test invoker.
579
+ - [ ] Update README / BREAKING-CHANGES / RUNTASK_REQUEST.md.
580
+ - [ ] Update task-strategies catalog descriptions and `defaultFunctionId` → `defaultSidekickAction` (or remove functionId concept).
581
+
582
+ ---
583
+
584
+ ## 13. Acceptance criteria (xynthesis PR)
585
+
586
+ ### 13.1 execution-plan
587
+
588
+ - [ ] `runExecutionPlan({ model, outputExpectation, goal, input, context, workScope })` returns valid `ExecutionPlanResult`.
589
+ - [ ] Optimixer runs; no host `maxTokens` required.
590
+ - [ ] `invokeSummary.sidekickAction === "execution-plan"`.
591
+ - [ ] Integration test with mock provider: structured JSON → typed result.
592
+ - [ ] Invalid JSON → `XynthesisResponseParseError`.
593
+
594
+ ### 13.2 execution-evaluate-result
595
+
596
+ - [ ] Accepts `result` + `iterationIndex`; returns `satisfied` boolean.
597
+ - [ ] Handles missing/partial `result.rawText` gracefully (empty string ok).
598
+ - [ ] `invokeSummary` includes iteration metadata when passed in request context.
599
+
600
+ ### 13.3 plan-web-scope-questions
601
+
602
+ - [ ] Output passes ai-tasks validation rules (§6.3).
603
+ - [ ] `maxQuestions` clamped 1–20 server-side.
604
+ - [ ] Parity test: same input → same shape as current ai-tasks inline prompt path (golden fixture).
605
+
606
+ ### 13.4 Cross-cutting
607
+
608
+ - [ ] All three actions accept `reasoningEffort`, `temperature`, `topP`.
609
+ - [ ] Model alias resolution via `@x12i/ai-profiles` consistent with audit/polish.
610
+ - [ ] Activix correlation when diagnostics enabled.
611
+ - [ ] CHANGELOG + README section for orchestrators.
612
+
613
+ ---
614
+
615
+ ## 14. Non-goals / explicit boundaries
616
+
617
+ - xynthesis **must not** implement the optimizer retry loop or call `@exellix/ai-skills`.
618
+ - xynthesis **must not** require `@exellix/ai-tasks` as a dependency.
619
+ - No new npm package — ai-tasks is the only orchestrator consumer.
620
+ - FuncX may remain xynthesis's internal provider adapter; ai-tasks should not call FuncX directly after migration.
621
+
622
+ ---
623
+
624
+ ## 15. Paste-ready GitHub issue (xynthesis repo)
625
+
626
+ **Title:** Add execution-strategy sidekick actions (planner, optimizer, plan-web-scope-questions)
627
+
628
+ **Body:**
629
+
630
+ > `@exellix/ai-tasks` currently invokes FuncX `execution/plan`, `execution/evaluate-result`, and optionally `research/plan-questions` for MAIN wrappers. These bypass `modelConfig`, Optimixer, and `InvokeAttemptSummary`.
631
+ >
632
+ > Please add three first-class xynthesis actions (`execution-plan`, `execution-evaluate-result`, `plan-web-scope-questions`) on the same contract as audit/polish (`executeXynthesisAction`, required `outputExpectation`, optional `reasoningEffort`).
633
+ >
634
+ > Full spec (input/output JSON, model slot policy, Catalox deliverables, acceptance tests):
635
+ > [link to this doc in ai-tasks repo]
636
+ >
637
+ > ai-tasks will migrate in 8.5.x and remove direct `@x12i/funcx` usage. No separate consumer package planned.
@@ -167,8 +167,8 @@ ai-tasks will follow whichever contract is published; default integration is **n
167
167
 
168
168
  ## Verification checklist (for xynthesis PR)
169
169
 
170
- - [ ] Replace `isKnownProfileOrShortcut` → `isKnownProfileChoice` (index re-export + `resolveAiProfileModel` / `assertKnownModelAlias`).
171
- - [ ] `import "@exellix/xynthesis"` succeeds with `@x12i/ai-profiles@2.1.0` installed.
170
+ - [x] Replace `isKnownProfileOrShortcut` → `isKnownProfileChoice` (shipped in **4.3.1** see [xynthesis-ai-profiles-2.1-import-break.md](./xynthesis-ai-profiles-2.1-import-break.md)).
171
+ - [x] `import "@exellix/xynthesis"` succeeds with `@x12i/ai-profiles@2.1.0` installed.
172
172
  - [ ] `ExecuteXynthesisActionRequest.reasoningEffort` (and gateway wrappers).
173
173
  - [ ] Optimixer predict receives resolved `reasoningEffort`.
174
174
  - [ ] `temperature` + `topP` integration tests on `executeXynthesisAction` + structured gateway.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exellix/ai-tasks",
3
- "version": "8.4.2",
3
+ "version": "8.5.0",
4
4
  "description": "Task orchestration for the Exellix stack: runTask() with local handlers or LLM-backed execution, task-scoped memory/context enrichment, and executor dispatch via @exellix/ai-skills. ERC-compliant.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,6 +14,7 @@
14
14
  "CHANGELOG.md",
15
15
  "RUNTASK_REQUEST.md",
16
16
  "documenations",
17
+ ".docs",
17
18
  ".env.example",
18
19
  ".metadata"
19
20
  ],
@@ -62,7 +63,6 @@
62
63
  "@x12i/activix": "$@x12i/activix",
63
64
  "@x12i/ai-profiles": "$@x12i/ai-profiles",
64
65
  "@x12i/catalox": "$@x12i/catalox",
65
- "@x12i/funcx": "$@x12i/funcx",
66
66
  "@x12i/logxer": "$@x12i/logxer"
67
67
  },
68
68
  "dependencies": {
@@ -78,13 +78,12 @@
78
78
  "@exellix/narrix-ingest": "^2.0.0",
79
79
  "@exellix/narrix-runner": "^2.0.0",
80
80
  "@exellix/narrix-web-scoper": "^2.0.0",
81
- "@exellix/xynthesis": "^4.3.1",
81
+ "@exellix/xynthesis": "^4.4.0",
82
82
  "@x12i/activix": "^8.5.0",
83
83
  "@x12i/ai-profiles": "^2.1.0",
84
84
  "@x12i/catalox": "^5.1.3",
85
85
  "@x12i/env": "^4.0.1",
86
86
  "@x12i/execution-memory-manager": "^1.2.0",
87
- "@x12i/funcx": "^4.3.3",
88
87
  "@x12i/logxer": "^4.6.0",
89
88
  "@x12i/rendrix": "^4.3.0",
90
89
  "@x12i/search-adapter": "^1.5.1",