@exellix/ai-tasks 8.4.2 → 8.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/DOWNSTREAM_ENV.md +42 -0
- package/.docs/FEEDBACK_TO_CLIENT_DOWNSTREAM_FIXES.md +64 -0
- package/.docs/INTERMEDIATE_STEPS.md +82 -0
- package/.docs/activity-structure.md +31 -0
- package/.docs/ai-task-ai-scoping-spec.md +338 -0
- package/.docs/ai-tasks-model-profile-aliases-7x.md +74 -0
- package/.docs/blockers-and-issues.md +346 -0
- package/.docs/building-runTask-sdk.md +659 -0
- package/.docs/building-skill-execution-orchestrator.md +968 -0
- package/.docs/code-used-before/run-task.txt +39 -0
- package/.docs/code-used-before/task-executor.ts.old +57 -0
- package/.docs/code-used-before/test-run-task.ts.old +42 -0
- package/.docs/code-used-before/types.txt +23 -0
- package/.docs/env-ready-policy.md +40 -0
- package/.docs/flow-io/flow-README.md +76 -0
- package/.docs/flow-io/narrix.md +124 -0
- package/.docs/flow-io/web-scoping.md +135 -0
- package/.docs/flow-io/xynthesis-post.md +154 -0
- package/.docs/flow-io/xynthesis-pre.md +181 -0
- package/.docs/gap-analysis.md +201 -0
- package/.docs/integration-facts-ai-tasks.md +109 -0
- package/.docs/investigation/ai-skills.md +170 -0
- package/.docs/investigation/external-packages-assignments.md +66 -0
- package/.docs/investigation/integration-summary.md +20 -0
- package/.docs/investigation/narrix-catalox.md +29 -0
- package/.docs/investigation/workplan-close-graph-engine-gaps.md +101 -0
- package/.docs/logging-stack.md +30 -0
- package/.docs/memory-narrix-adapter-developer-guide.md +402 -0
- package/.docs/memory-narrix-adapter-requirements.md +112 -0
- package/.docs/narrix-context-consumption-gap.md +184 -0
- package/.docs/narrix-context-downstream-report.md +30 -0
- package/.docs/narrix-ingest-and-packs-library-spec.md +240 -0
- package/.docs/narrix-record-input-current-design.md +48 -0
- package/.docs/pacakge.md +48 -0
- package/.docs/possible-components/README.md +11 -0
- package/.docs/possible-components/integration/README.md +10 -0
- package/.docs/possible-components/integration/gaps-when-merging.md +16 -0
- package/.docs/possible-components/integration/platform.md +54 -0
- package/.docs/possible-components/integration/reintegrate-into-ai-tasks.md +26 -0
- package/.docs/possible-components/integration/roadmap-and-checklists.md +54 -0
- package/.docs/possible-components/post-component/README.md +18 -0
- package/.docs/possible-components/post-component/builder-guide.md +175 -0
- package/.docs/possible-components/post-component/gaps-and-artifacts.md +52 -0
- package/.docs/possible-components/post-component/handler-audit.md +47 -0
- package/.docs/possible-components/post-component/handler-polish.md +41 -0
- package/.docs/possible-components/post-component/unified-protocol.md +59 -0
- package/.docs/possible-components/pre-component/README.md +22 -0
- package/.docs/possible-components/pre-component/builder-guide.md +127 -0
- package/.docs/possible-components/pre-component/gaps-and-artifacts.md +35 -0
- package/.docs/possible-components/pre-component/handler-ai-scoping.md +45 -0
- package/.docs/possible-components/pre-component/handler-narrix-preprocessor.md +49 -0
- package/.docs/possible-components/pre-component/handler-narrix-system2.md +35 -0
- package/.docs/possible-components/pre-component/handler-synthesized-context.md +65 -0
- package/.docs/possible-components/pre-component/handler-web-scope.md +29 -0
- package/.docs/possible-components/pre-component/unified-protocol.md +89 -0
- package/.docs/prefer-openrouter-routing-policy.md +132 -0
- package/.docs/questions-for-ai-skills.md +123 -0
- package/.docs/realtime-narrixing-gap-analysis.md +40 -0
- package/.docs/realtime-narrixing.md +433 -0
- package/.docs/run-context-object.md +32 -0
- package/.docs/session-id-usage.md +26 -0
- package/.docs/skill-library-spec.md +249 -0
- package/.docs/synthesized-context-strategy-spec.md +906 -0
- package/.docs/upstream-issue/2026-03-21_woroces-ai-tasks_ISSUE-006_web-scope-question-from-cni-entity.md +46 -0
- package/.docs/web-scopper-embed.md +93 -0
- package/.docs/xynthesis-wiring-and-io.md +12 -0
- package/README.md +15 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/runPostStepLlmCall.d.ts.map +1 -1
- package/dist/internal/runPostStepLlmCall.js +4 -2
- package/dist/internal/runPostStepLlmCall.js.map +1 -1
- package/dist/invocation/resolveProfileInvocationRouting.js +2 -2
- package/dist/invocation/resolveProfileInvocationRouting.js.map +1 -1
- package/dist/utils/aiProfileModelFormat.d.ts +2 -2
- package/dist/utils/aiProfileModelFormat.js +2 -2
- package/dist/utils/aiProfilesCatalog.d.ts +16 -0
- package/dist/utils/aiProfilesCatalog.d.ts.map +1 -0
- package/dist/utils/aiProfilesCatalog.js +23 -0
- package/dist/utils/aiProfilesCatalog.js.map +1 -0
- package/dist/utils/resolveAiProfileModel.d.ts +2 -2
- package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
- package/dist/utils/resolveAiProfileModel.js +5 -5
- package/dist/utils/resolveAiProfileModel.js.map +1 -1
- package/dist/utils/routeModelConfigSlots.d.ts +3 -1
- package/dist/utils/routeModelConfigSlots.d.ts.map +1 -1
- package/dist/utils/routeModelConfigSlots.js +2 -1
- package/dist/utils/routeModelConfigSlots.js.map +1 -1
- package/documenations/upstream-feature-requests/README.md +2 -2
- package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +5 -2
- package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
taken from client.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Executes a task with a specific execution strategy.
|
|
7
|
+
*
|
|
8
|
+
* WHY: Allows for more complex execution logic (e.g. multi-step,
|
|
9
|
+
* tool-calling, direct pass-through) while maintaining a consistent API.
|
|
10
|
+
* Now includes two-step context enrichment: memory scoping + context generation.
|
|
11
|
+
*/
|
|
12
|
+
async runTask<TParsed = any>(input: RunTaskRequest): Promise<RunSkillResponse<TParsed>> {
|
|
13
|
+
// Extract taskId from skillKey (remove "tasks/" prefix if present, or use skillKey as-is)
|
|
14
|
+
const taskId = input.skillKey.replace(/^tasks\//, '');
|
|
15
|
+
|
|
16
|
+
// Build memory bundle
|
|
17
|
+
const memoryBundle = {
|
|
18
|
+
jobMemory: input.jobMemory,
|
|
19
|
+
taskMemory: input.taskMemory
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Step 1: Enrich memories with scoping data
|
|
23
|
+
const enrichedBundle = await this.enrichMemoriesWithScoping(taskId, 'task', memoryBundle);
|
|
24
|
+
|
|
25
|
+
// Step 2: Generate context markdown
|
|
26
|
+
const contextMarkdown = await this.generateContextMarkdown(taskId, 'task', enrichedBundle);
|
|
27
|
+
|
|
28
|
+
// Create enriched input
|
|
29
|
+
const enrichedInput: RunTaskRequest = {
|
|
30
|
+
...input,
|
|
31
|
+
jobMemory: enrichedBundle.jobMemory,
|
|
32
|
+
taskMemory: enrichedBundle.taskMemory,
|
|
33
|
+
context: contextMarkdown
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return this.taskExecutor.execute<TParsed>(enrichedInput, async (key) => {
|
|
37
|
+
await this.registry.diagnose(key);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseClient } from "./base-client";
|
|
2
|
+
import { SkillExecutor } from "./skill-executor";
|
|
3
|
+
import { ExecutionType, RunTaskRequest, RunSkillResponse } from "../types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TaskExecutor
|
|
7
|
+
*
|
|
8
|
+
* WHY: This class handles the "orchestration" of tasks which can have
|
|
9
|
+
* different execution strategies (ExecutionType). It currently supports
|
|
10
|
+
* 'direct' execution which simply delegates to the SkillExecutor.
|
|
11
|
+
*/
|
|
12
|
+
export class TaskExecutor extends BaseClient {
|
|
13
|
+
private skillExecutor: SkillExecutor;
|
|
14
|
+
|
|
15
|
+
constructor(gateway: any, logger: any, skillExecutor: SkillExecutor) {
|
|
16
|
+
super(gateway, logger);
|
|
17
|
+
this.skillExecutor = skillExecutor;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Executes a task based on its execution type.
|
|
22
|
+
*
|
|
23
|
+
* WHY: Centralized entry point for task-based execution.
|
|
24
|
+
*/
|
|
25
|
+
async execute<TParsed = any>(
|
|
26
|
+
taskRequest: RunTaskRequest,
|
|
27
|
+
onNotFound?: (skillKey: string) => Promise<void>
|
|
28
|
+
): Promise<RunSkillResponse<TParsed>> {
|
|
29
|
+
const { executionType, taskMemory, jobMemory, ...rest } = taskRequest;
|
|
30
|
+
|
|
31
|
+
this.logger.info("[AI-SKILLS] runTask() entry", {
|
|
32
|
+
skillKey: taskRequest.skillKey,
|
|
33
|
+
executionType,
|
|
34
|
+
jobId: taskRequest.jobId,
|
|
35
|
+
identity: "runTask execute"
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
switch (executionType) {
|
|
39
|
+
case ExecutionType.DIRECT:
|
|
40
|
+
this.logger.info("[AI-SKILLS] Executing direct task (pass-through to skill)", {
|
|
41
|
+
skillKey: taskRequest.skillKey,
|
|
42
|
+
identity: "runTask direct"
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return this.skillExecutor.execute<TParsed>({
|
|
46
|
+
...rest,
|
|
47
|
+
taskMemory,
|
|
48
|
+
jobMemory
|
|
49
|
+
}, onNotFound);
|
|
50
|
+
|
|
51
|
+
default:
|
|
52
|
+
const errorMsg = `[AI-SKILLS] Unsupported execution type: ${executionType}`;
|
|
53
|
+
this.logger.error(errorMsg, { identity: "runTask execute" });
|
|
54
|
+
throw new Error(errorMsg);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { XeonoxSkillsClient } from "./src/client";
|
|
2
|
+
import { ExecutionType } from "./src/types";
|
|
3
|
+
import * as dotenv from "dotenv";
|
|
4
|
+
|
|
5
|
+
dotenv.config();
|
|
6
|
+
|
|
7
|
+
async function testRunTask() {
|
|
8
|
+
console.log("Starting runTask verification...");
|
|
9
|
+
|
|
10
|
+
const client = new XeonoxSkillsClient({
|
|
11
|
+
packageName: "TEST-TASK",
|
|
12
|
+
enableContentRegistry: true,
|
|
13
|
+
contentRegistryLocalPath: ".metadata"
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
console.log("Calling runTask with ExecutionType.DIRECT...");
|
|
18
|
+
const response = await client.runTask({
|
|
19
|
+
skillKey: "skills/professional-answer",
|
|
20
|
+
executionType: ExecutionType.DIRECT,
|
|
21
|
+
input: {
|
|
22
|
+
question: "What is the capital of France?"
|
|
23
|
+
},
|
|
24
|
+
variables: {
|
|
25
|
+
orgName: "TestOrg"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log("Response received:");
|
|
30
|
+
console.log(JSON.stringify(response, null, 2));
|
|
31
|
+
|
|
32
|
+
if (response.skillKey === "skills/professional-answer") {
|
|
33
|
+
console.log("SUCCESS: runTask returned the correct skillKey.");
|
|
34
|
+
} else {
|
|
35
|
+
console.log("FAILURE: runTask returned an incorrect skillKey.");
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("Error during runTask execution:", error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
testRunTask();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
export interface RunTaskRequest {
|
|
3
|
+
skillKey: string; // "skills/professional-answer"
|
|
4
|
+
input: Record<string, any> | string;
|
|
5
|
+
/**
|
|
6
|
+
* WHY: Alias for 'memory'. Contextual variables for the skill (e.g. orgName, tone).
|
|
7
|
+
* Aligns with SkillMetadata concepts of required/optional variables.
|
|
8
|
+
*/
|
|
9
|
+
variables?: Record<string, any>;
|
|
10
|
+
context?: Record<string, any> | string;
|
|
11
|
+
knowledge?: Record<string, any>;
|
|
12
|
+
jobMemory?: JobHistory; // the history of all the tasks results so far from previous steps up to this task being executed ---> to the short term memory of the skill called
|
|
13
|
+
taskMemory?: TaskHistory; // the skills that were exuectuted up to this task---> to the temporary memory of the skill called
|
|
14
|
+
|
|
15
|
+
jobId?: string;
|
|
16
|
+
agentId?: string;
|
|
17
|
+
skillId?: string;
|
|
18
|
+
masterSkillId?: string;
|
|
19
|
+
masterSkillActivityId?: string;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
executionType: ExecutionType;
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Standard: Env-Ready Component (ERC)
|
|
2
|
+
|
|
3
|
+
**Version**: 1.0.0
|
|
4
|
+
**Drafting Agency**: Xeonox Architecture Team
|
|
5
|
+
**Goal**: Zero-Config "Plug & Play" across the entire AI ecosystem.
|
|
6
|
+
|
|
7
|
+
## 1. Philosophy: "Plug & Play" (Zero-Config)
|
|
8
|
+
|
|
9
|
+
Every component (SDK, Gateway, Provider) must be operational immediately upon installation if the host environment provides the necessary configuration. Explicit code-based configuration is the **Advanced Mode** fallback.
|
|
10
|
+
|
|
11
|
+
## 2. Mandatory Internal Behaviors
|
|
12
|
+
|
|
13
|
+
### 2.1 Auto-Discovery
|
|
14
|
+
- Constructors **MUST** attempt to resolve state from `process.env` when no explicit configuration object is passed.
|
|
15
|
+
- **Example**: `new AIGateway()` should find its own keys, database URIs, and registry settings without being told where they are in code.
|
|
16
|
+
|
|
17
|
+
### 2.2 Transitive Configuration (The Sum Principle)
|
|
18
|
+
- A component's environment requirement is the **UNION** of its own required variables and the required variables of all components it utilizes.
|
|
19
|
+
- **Example**: If `@xeonoces/ai-skills` uses `@athenices/ai-gateway`, the `ai-skills` `.env.example` must include all `GITHUB_*` keys (from gateway) AND its own unique keys.
|
|
20
|
+
|
|
21
|
+
### 2.3 Built-in Validation
|
|
22
|
+
- Components **MUST** validate their configuration (whether from object or env) during initialization.
|
|
23
|
+
- If a mandatory requirement is missing, it must throw a named error:
|
|
24
|
+
- `[NAME] ERC_VALIDATION_ERROR: Missing [VARIABLE_NAME].`
|
|
25
|
+
|
|
26
|
+
## 3. Mandatory Documentation
|
|
27
|
+
|
|
28
|
+
### 3.1 The `.env.example` Standard
|
|
29
|
+
Every repository **MUST** maintain a `.env.example` root file following this structure:
|
|
30
|
+
- **Marker**: `[REQUIRED]` or `[OPTIONAL]`.
|
|
31
|
+
- **Purpose**: Short description of the variable's impact.
|
|
32
|
+
- **Source**: If the variable is required by a *dependency*, note which one (e.g., `[REQUIRED by AI-GATEWAY]`).
|
|
33
|
+
|
|
34
|
+
### 3.2 The README "Env-Ready" Badge
|
|
35
|
+
READMEs must explicitly claim compliance:
|
|
36
|
+
> 🚀 **Env-Ready (ERC)**: This component supports automatic zero-config initialization via environment variables.
|
|
37
|
+
|
|
38
|
+
## 4. Compliance Check (The "Bug" Rule)
|
|
39
|
+
|
|
40
|
+
Failure of a component to auto-initialize when `.env` is correctly populated is no longer a "feature gap"—it is a **High-Priority Bug** (ERC Policy Violation). Reports should be filed with the `erc-violation` label.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# `runTask` architecture (ai-tasks)
|
|
2
|
+
|
|
3
|
+
High-level map only. Details live in the linked docs below.
|
|
4
|
+
|
|
5
|
+
**Component:** [`@exellix/xynthesis`](https://www.npmjs.com/package/@exellix/xynthesis) is the LLM package ai-tasks calls for PRE/POST pipeline steps. It is **not** the same as the request field `xynthesized` (graph memory buckets).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Block diagram
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
RunTaskRequest
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
┌─────────────────┐
|
|
16
|
+
│ runTask() │
|
|
17
|
+
└────────┬────────┘
|
|
18
|
+
│
|
|
19
|
+
┌────┴────┐
|
|
20
|
+
│ │
|
|
21
|
+
▼ ▼
|
|
22
|
+
local continue
|
|
23
|
+
task (LLM path)
|
|
24
|
+
│ │
|
|
25
|
+
│ ┌────┴────────────────────────────────────┐
|
|
26
|
+
│ │ │
|
|
27
|
+
│ ▼ │
|
|
28
|
+
│ NARRIX pre-processor (optional) │ → [narrix.md](./narrix.md)
|
|
29
|
+
│ │ may include web scoping │ → [web-scoping.md](./web-scoping.md)
|
|
30
|
+
│ ▼ │
|
|
31
|
+
│ executionPipeline PRE (optional) │
|
|
32
|
+
│ └─ synthesized-context │ → [xynthesis-pre.md](./xynthesis-pre.md)
|
|
33
|
+
│ calls @exellix/xynthesis │
|
|
34
|
+
│ ▼ │
|
|
35
|
+
│ MAIN — @exellix/ai-skills runSkill │ (not documented here)
|
|
36
|
+
│ ▼ │
|
|
37
|
+
│ executionPipeline POST (optional) │
|
|
38
|
+
│ └─ audit / polish │ → [xynthesis-post.md](./xynthesis-post.md)
|
|
39
|
+
│ calls @exellix/xynthesis │
|
|
40
|
+
│ ▼ │
|
|
41
|
+
└────┴─────────────────────────────────────────┘
|
|
42
|
+
│
|
|
43
|
+
▼
|
|
44
|
+
RunTaskResponse
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Focused documentation
|
|
50
|
+
|
|
51
|
+
| Doc | Scope |
|
|
52
|
+
|-----|--------|
|
|
53
|
+
| [xynthesis-pre.md](./xynthesis-pre.md) | PRE `synthesized-context` — how ai-tasks calls **xynthesis** before MAIN |
|
|
54
|
+
| [xynthesis-post.md](./xynthesis-post.md) | POST `audit` / `polish` — how ai-tasks calls **xynthesis** after MAIN |
|
|
55
|
+
| [narrix.md](./narrix.md) | NARRIX pre-processor — ingest, runner, `_narrix` attachment (no xynthesis) |
|
|
56
|
+
| [web-scoping.md](./web-scoping.md) | Web scoper — `executionMemory.webContext` (no xynthesis) |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Graph-engine authoring (model vs runtime)
|
|
61
|
+
|
|
62
|
+
Each flow doc ends with two sections:
|
|
63
|
+
|
|
64
|
+
| Section | Contract |
|
|
65
|
+
|---------|----------|
|
|
66
|
+
| **TaskNode model** | Static `TaskNode` / `taskConfiguration` fields graph-engine compiles into `RunTaskRequest` |
|
|
67
|
+
| **TaskNode runtime** | Per-run `GraphRuntimeObject.nodes[nodeId]` and run-scoped memory that affect that step |
|
|
68
|
+
|
|
69
|
+
Full graph contracts (graph-engine repo): **Task Node Model Object Format**, **Task Node Runtime Object Format**.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Normative contracts (outside `.docs`)
|
|
74
|
+
|
|
75
|
+
- [RUNTASK_REQUEST.md](../../RUNTASK_REQUEST.md) — request/response wire shape
|
|
76
|
+
- [documenations/synthesized-context-guide.md](../../documenations/synthesized-context-guide.md) — PRE step config reference
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# NARRIX pre-processor
|
|
2
|
+
|
|
3
|
+
How `@exellix/ai-tasks` runs **NARRIX** before MAIN. This path does **not** call **xynthesis**.
|
|
4
|
+
|
|
5
|
+
For web enrichment after NARRIX, see [web-scoping.md](./web-scoping.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When it runs
|
|
10
|
+
|
|
11
|
+
- `RunTaskRequest.narrix` is set (`NarrixPreProcessorConfig`)
|
|
12
|
+
- Runs early in `runTask()`, before local-task check’s LLM path and before pipeline PRE
|
|
13
|
+
- Separate path: `narrixMode: "handler"` + `narrixInput` (structured handler, not the same as `request.narrix` pre-processor)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Request
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
narrix?: {
|
|
21
|
+
datasetId: string; // required
|
|
22
|
+
attachToField?: string; // default "_narrix"
|
|
23
|
+
enableWebScope?: boolean; // default false → see web-scoping.md
|
|
24
|
+
deterministicSort?: boolean;
|
|
25
|
+
// web scope templates / questions when enableWebScope: true
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Record source: adapted from `jobMemory` / `executionMemory` / `input` via `@exellix/xmemory-narrix-adapter`.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Execution flow
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
runTask()
|
|
37
|
+
→ adaptMemoryToNarrixInput(...)
|
|
38
|
+
→ narrixRunHandler({ input, ctx })
|
|
39
|
+
→ @exellix/narrix-ingest (CNI)
|
|
40
|
+
→ @exellix/narrix-runner
|
|
41
|
+
→ buildNarrixAttachment(result)
|
|
42
|
+
→ executionMemory[attachToField] = attachment
|
|
43
|
+
→ jobMemory._narrix = attachment (mirror)
|
|
44
|
+
→ optional web scoping → executionMemory.webContext
|
|
45
|
+
→ continue with same RunTaskRequest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Implementation: `src/core/task-sdk.ts` (NARRIX block), `src/narrix/task.ts`, `src/narrix/buildNarrixAttachment.ts`.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Context passed to handler
|
|
53
|
+
|
|
54
|
+
`ctx` includes: `skillKey`, memories, `variables`, `xynthesized`, `smartInput`, graph ids — same top-level fields as the request (no xynthesis).
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Downstream use
|
|
59
|
+
|
|
60
|
+
| Consumer | Uses NARRIX output |
|
|
61
|
+
|----------|-------------------|
|
|
62
|
+
| MAIN context generation | `buildNarrixPreProcessorContextMarkdown` from `executionMemory._narrix` when `includeContextInPrompt` |
|
|
63
|
+
| PRE xynthesis | Narrix markdown in `resolveSourceMaterial*` when `contextSourcePolicy` includes narrix — [xynthesis-pre.md](./xynthesis-pre.md) |
|
|
64
|
+
| `taskMemory.narrix` | Handler mode / legacy narrix-then-direct |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Failure
|
|
69
|
+
|
|
70
|
+
NARRIX pre-processor failure **throws** (task does not continue). Web scoping failure is **non-fatal** (see [web-scoping.md](./web-scoping.md)).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Packages (not xynthesis)
|
|
75
|
+
|
|
76
|
+
- `@exellix/narrix-ingest`, `@exellix/narrix-runner`, `@exellix/narrix-cni`
|
|
77
|
+
- `@exellix/xmemory-narrix-adapter`
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## TaskNode model (graph authoring)
|
|
82
|
+
|
|
83
|
+
NARRIX config belongs on **`taskConfiguration`**, not `metadata`.
|
|
84
|
+
|
|
85
|
+
| TaskNode field | Role for NARRIX |
|
|
86
|
+
|----------------|-----------------|
|
|
87
|
+
| `taskConfiguration.narrix` | **`RunTaskRequest.narrix`**: `datasetId`, `attachToField`, `enableWebScope`, web scope templates/questions, `deterministicSort`, … |
|
|
88
|
+
| `taskConfiguration.narrixMode` | `"preprocessor"` (default path: `request.narrix`) vs `"handler"` (`narrixInput` + handler pipeline). |
|
|
89
|
+
| `taskConfiguration.narrixInput` | Handler mode structured input (may use `$path` into `jobMemory`). |
|
|
90
|
+
| `taskConfiguration.aiTaskProfile.webScoping` | Canonical authoring intent for web; graph-engine forwards into resolved `narrix` payload (see [web-scoping.md](./web-scoping.md)). |
|
|
91
|
+
| `node.inputsConfig` | Binds runtime payload paths (e.g. `executionMemoryPath: "input.raw"`) that the adapter prefers when locating a record. |
|
|
92
|
+
| `node.taskVariable` | May supply `question` / literals compiled into `RunTaskRequest.input` for web question templates. |
|
|
93
|
+
| `node.taskKnowledge` | Static refs → outbound `taskMemory.knowledge` copy for this node (not NARRIX ingest itself). |
|
|
94
|
+
| `node.memory` | Rare per-node memory override on the model; forwarded if graph-engine maps it. |
|
|
95
|
+
|
|
96
|
+
**Forbidden:** `metadata.narrix` — use `taskConfiguration.narrix`.
|
|
97
|
+
|
|
98
|
+
NARRIX does **not** read `node.executionPipeline` or `modelConfig` (no LLM in the ingest/runner path).
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## TaskNode runtime (per-run overrides)
|
|
103
|
+
|
|
104
|
+
| Runtime field | Role for NARRIX |
|
|
105
|
+
|---------------|-----------------|
|
|
106
|
+
| `runtime.jobMemory` | Record discovery via `@exellix/xmemory-narrix-adapter` (`jobMemory.record`, `currentRecord`, …). |
|
|
107
|
+
| `runtime.taskMemory` | Handler / legacy paths; may hold prior `narrix` entries. |
|
|
108
|
+
| `runtime.executionMemory` | **Written by ai-tasks:** `executionMemory[attachToField]` (`_narrix`), optional `webContext`. **Read:** `input`, `inputs`, paths from `inputsConfig`. |
|
|
109
|
+
| `runtime.input` / `runtime.inputs` | Mirrored into `executionMemory` before the pre-processor runs. |
|
|
110
|
+
| `runtime.nodes[nodeId].modelConfig` | **Does not affect NARRIX** (ingest/runner are deterministic; no xynthesis call). |
|
|
111
|
+
|
|
112
|
+
**Not on node runtime:** `datasetId`, `enableWebScope`, or attach field — those are model/`taskConfiguration` only.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Source files
|
|
117
|
+
|
|
118
|
+
| File | Role |
|
|
119
|
+
|------|------|
|
|
120
|
+
| `src/core/task-sdk.ts` | Pre-processor orchestration |
|
|
121
|
+
| `src/narrix/task.ts` | `narrixRunHandler` |
|
|
122
|
+
| `src/narrix/narrixContextMarkdown.ts` | Context markdown for MAIN / synthesis |
|
|
123
|
+
| `src/narrix/buildNarrixAttachment.ts` | Attachment shape |
|
|
124
|
+
| `src/types/task-types.ts` | `NarrixPreProcessorConfig` |
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Web scoping
|
|
2
|
+
|
|
3
|
+
How `@exellix/ai-tasks` fills **`executionMemory.webContext`** using **`@exellix/narrix-web-scoper`**. This path does **not** call **xynthesis**.
|
|
4
|
+
|
|
5
|
+
For how web markdown is consumed in PRE synthesis, see [xynthesis-pre.md](./xynthesis-pre.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When it runs
|
|
10
|
+
|
|
11
|
+
- Inside the **NARRIX pre-processor** path (`request.narrix` set)
|
|
12
|
+
- `narrix.enableWebScope === true`
|
|
13
|
+
- After NARRIX runner succeeds (CNI + entity)
|
|
14
|
+
- Requires **`TAVILY_API_KEY`** (via `@x12i/search-adapter`)
|
|
15
|
+
|
|
16
|
+
Skipped when:
|
|
17
|
+
|
|
18
|
+
- `enableWebScope` is false or omitted
|
|
19
|
+
- `skipWebScopeWhenExternalWebMarkdownPresent === true` and caller already set `executionMemory.webContextMarkdown`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Request knobs
|
|
24
|
+
|
|
25
|
+
On `RunTaskRequest.narrix`:
|
|
26
|
+
|
|
27
|
+
| Field | Role |
|
|
28
|
+
|-------|------|
|
|
29
|
+
| `enableWebScope` | Opt-in boolean |
|
|
30
|
+
| `webScoping` | Per-request scoper config (snippets, caps) |
|
|
31
|
+
| `webScopeTemplates` | Template-driven scope |
|
|
32
|
+
| `webScopeQuestionTemplate` | Question template for AI-driven questions |
|
|
33
|
+
| `webScopeObjects` | Scope targets |
|
|
34
|
+
| `webScopeQuestions` | Explicit question-pack mode |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Execution flow
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
NARRIX success
|
|
42
|
+
→ resolveWebScopeQuestionAndTemplates(...)
|
|
43
|
+
→ runWebScope / runWebScopeQuestionPack (src/narrix/webScoper.ts)
|
|
44
|
+
→ createWebScoper({ searchAdapter: Tavily })
|
|
45
|
+
→ @exellix/narrix-web-scoper
|
|
46
|
+
→ executionMemory.webContext = WebScoperResult
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Implementation: `src/core/task-sdk.ts`, `src/narrix/webScoper.ts`, `src/narrix/buildWebScopeScopeInput.ts`.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Result shape
|
|
54
|
+
|
|
55
|
+
Stored at **`executionMemory.webContext`**:
|
|
56
|
+
|
|
57
|
+
- `available: true` → `context` with `sources`, `findings`, `scopes`, …
|
|
58
|
+
- `available: false` → `reason` / `error` (task still continues)
|
|
59
|
+
|
|
60
|
+
Always written when scoping was attempted (lenient — NARRIX attachment is kept).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Downstream consumers
|
|
65
|
+
|
|
66
|
+
| Consumer | Behavior |
|
|
67
|
+
|----------|----------|
|
|
68
|
+
| MAIN context | `buildWebContextEvidenceMarkdown` appended when web hit |
|
|
69
|
+
| PRE xynthesis | Web section in `resolveSourceMaterial` / question-driven `web` source |
|
|
70
|
+
| Question-driven PRE | Per-question `source: "web"` reads `executionMemory.webContext` |
|
|
71
|
+
|
|
72
|
+
Raw `webContext` JSON is **not** dumped into memory JSON for synthesis; it is rendered to markdown excerpts (`SynthesisConfig.webEvidence` caps dedupe/clean text).
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Activix
|
|
77
|
+
|
|
78
|
+
`webScopeActivixCorrelationPatch` links scoping to `jobId` / `taskId` for telemetry.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Failure stance
|
|
83
|
+
|
|
84
|
+
Web scoping errors are logged; NARRIX output and task execution continue. Synthesis may record `webUnavailableReason` in question-driven answers.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## TaskNode model (graph authoring)
|
|
89
|
+
|
|
90
|
+
Web scoping is configured on the **NARRIX** block graph-engine forwards to `RunTaskRequest.narrix`.
|
|
91
|
+
|
|
92
|
+
| TaskNode field | Role for web scoping |
|
|
93
|
+
|----------------|----------------------|
|
|
94
|
+
| `taskConfiguration.aiTaskProfile.webScoping` | **Canonical** authoring path for web intent; engine merges into outbound `narrix` / scoping options. |
|
|
95
|
+
| `taskConfiguration.narrix.enableWebScope` | Opt-in boolean on the forwarded `RunTaskRequest.narrix` (default false). |
|
|
96
|
+
| `taskConfiguration.narrix.webScoping` | Per-request scoper caps/snippets (`WebScoperConfig.scoping`). |
|
|
97
|
+
| `taskConfiguration.narrix.webScopeTemplates` | Template-driven scope when set. |
|
|
98
|
+
| `taskConfiguration.narrix.webScopeQuestionTemplate` | AI-driven question generation template. |
|
|
99
|
+
| `taskConfiguration.narrix.webScopeObjects` | Scope targets for the scoper. |
|
|
100
|
+
| `taskConfiguration.narrix.webScopeQuestions` | Explicit question-pack mode (`{ id?, question, source? }[]`). |
|
|
101
|
+
| `node.taskVariable.question` | Feeds scope question resolution when templates reference the task question. |
|
|
102
|
+
| `taskConfiguration.narrix.skipWebScopeWhenExternalWebMarkdownPresent` | Skip scoper when caller already supplies external web markdown at runtime. |
|
|
103
|
+
|
|
104
|
+
Requires `taskConfiguration.narrix` (or equivalent forwarded `request.narrix`) with NARRIX pre-processor enabled — web scoping does not run standalone.
|
|
105
|
+
|
|
106
|
+
**Forbidden:** `metadata.webScoping` — use `taskConfiguration.aiTaskProfile.webScoping` / `taskConfiguration.narrix`.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## TaskNode runtime (per-run overrides)
|
|
111
|
+
|
|
112
|
+
| Runtime field | Role for web scoping |
|
|
113
|
+
|---------------|------------------------|
|
|
114
|
+
| `runtime.executionMemory.webContext` | **Output** of the scoper for this run (`WebScoperResult`: `available`, `context` \| `reason`). |
|
|
115
|
+
| `runtime.executionMemory.webContextMarkdown` | Caller-provided markdown; when set + `skipWebScopeWhenExternalWebMarkdownPresent`, scoper may be skipped. |
|
|
116
|
+
| `runtime.executionMemory` (entity context) | NARRIX entity/CNI from prior step in the same `runTask` — scoper input after NARRIX success. |
|
|
117
|
+
| `runtime.input` | Question/entity hints via `resolveWebScopeQuestionAndTemplates`. |
|
|
118
|
+
| `runtime.nodes[nodeId].modelConfig` | **Does not affect** web scoping (Tavily search + scoper, no xynthesis). |
|
|
119
|
+
|
|
120
|
+
**Not on node runtime:** `enableWebScope`, templates, or question packs — model only.
|
|
121
|
+
|
|
122
|
+
Host must supply **`TAVILY_API_KEY`** in the environment; not a TaskNode field.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Source files
|
|
127
|
+
|
|
128
|
+
| File | Role |
|
|
129
|
+
|------|------|
|
|
130
|
+
| `src/narrix/webScoper.ts` | Scoper singleton, `runWebScope*` |
|
|
131
|
+
| `src/narrix/webContextMarkdown.ts` | Markdown for context / synthesis |
|
|
132
|
+
| `src/narrix/buildWebScopeScopeInput.ts` | Question/template resolution |
|
|
133
|
+
| `src/synthesis/resolveSourceMaterial.ts` | Policy includes web markdown |
|
|
134
|
+
|
|
135
|
+
Extended reference: [documenations/web-scoping-in-ai-tasks.md](../documenations/web-scoping-in-ai-tasks.md).
|