@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.
- 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/CHANGELOG.md +16 -0
- package/README.md +15 -13
- package/dist/core/task-sdk.d.ts.map +1 -1
- package/dist/core/task-sdk.js +40 -15
- package/dist/core/task-sdk.js.map +1 -1
- package/dist/execution-strategies/constants.d.ts +11 -4
- package/dist/execution-strategies/constants.d.ts.map +1 -1
- package/dist/execution-strategies/constants.js +11 -4
- package/dist/execution-strategies/constants.js.map +1 -1
- package/dist/execution-strategies/executionStrategyCatalogMetadata.d.ts +6 -3
- package/dist/execution-strategies/executionStrategyCatalogMetadata.d.ts.map +1 -1
- package/dist/execution-strategies/executionStrategyCatalogMetadata.js +36 -5
- package/dist/execution-strategies/executionStrategyCatalogMetadata.js.map +1 -1
- package/dist/execution-strategies/executionStrategyRequestPayload.d.ts +19 -0
- package/dist/execution-strategies/executionStrategyRequestPayload.d.ts.map +1 -0
- package/dist/execution-strategies/executionStrategyRequestPayload.js +21 -0
- package/dist/execution-strategies/executionStrategyRequestPayload.js.map +1 -0
- package/dist/execution-strategies/runExecutionStrategyViaXynthesis.d.ts +35 -0
- package/dist/execution-strategies/runExecutionStrategyViaXynthesis.d.ts.map +1 -0
- package/dist/execution-strategies/runExecutionStrategyViaXynthesis.js +129 -0
- package/dist/execution-strategies/runExecutionStrategyViaXynthesis.js.map +1 -0
- package/dist/index.d.ts +16 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/resolveLlmCallForXynthesis.d.ts.map +1 -1
- package/dist/internal/resolveLlmCallForXynthesis.js +6 -0
- package/dist/internal/resolveLlmCallForXynthesis.js.map +1 -1
- package/dist/internal/runPostStepLlmCall.d.ts.map +1 -1
- package/dist/internal/runPostStepLlmCall.js +8 -3
- 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/planWebScopeQuestions/index.d.ts +4 -8
- package/dist/planWebScopeQuestions/index.d.ts.map +1 -1
- package/dist/planWebScopeQuestions/index.js +109 -149
- package/dist/planWebScopeQuestions/index.js.map +1 -1
- package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts +21 -21
- package/dist/task-strategies/canonicalInputExecutionStrategies.js +12 -12
- package/dist/task-strategies/canonicalInputExecutionStrategies.js.map +1 -1
- package/dist/task-strategies/types.d.ts +4 -2
- package/dist/task-strategies/types.d.ts.map +1 -1
- package/dist/types/llmCall.d.ts +1 -1
- package/dist/types/llmCall.d.ts.map +1 -1
- package/dist/types/llmCall.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 +3 -2
- package/documenations/upstream-feature-requests/ai-tasks-wrap-up-after-upstream.md +5 -2
- package/documenations/upstream-feature-requests/xynthesis-execution-strategies-option-a.md +637 -0
- package/documenations/upstream-feature-requests/xynthesis-orchestrator-invoke-contract-4.2.md +2 -2
- package/package.json +3 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Downstream / upstream environment variables
|
|
2
|
+
|
|
3
|
+
This document lists which env vars **ai-tasks** uses itself and which are consumed **downstream** (by @woroces/ai-skills, @athenices/ai-gateway, @athenices/ai-provider-router, @athenices/ai-activities-tracking). ai-tasks does **not** read router or Mongo collection env vars; they are used by dependencies. For full reference, see each package’s docs.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Env vars used by ai-tasks
|
|
8
|
+
|
|
9
|
+
| Variable | Purpose | Default |
|
|
10
|
+
|----------|---------|--------|
|
|
11
|
+
| `MONGO_LOGS_DB` | Default database name for activity logs; passed as `bindingDefaultsDb` to the skills client and used downstream for routing. | `logs-db` |
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Env vars consumed downstream (when using ai-tasks)
|
|
16
|
+
|
|
17
|
+
These affect behavior when you run LLM-backed tasks or activity tracking but are **not** read by ai-tasks. They are used by ai-skills → ai-gateway → ai-provider-router and ai-activities-tracking.
|
|
18
|
+
|
|
19
|
+
### Provider / router (ai-gateway, ai-provider-router)
|
|
20
|
+
|
|
21
|
+
| Variable | Purpose |
|
|
22
|
+
|----------|--------|
|
|
23
|
+
| `OPEN_ROUTER_KEY` or `OPENROUTER_API_KEY` | Use OpenRouter for LLM calls; no need to register providers when set. |
|
|
24
|
+
| `USE_OPENROUTER` | Can enable or disable OpenRouter when set. |
|
|
25
|
+
|
|
26
|
+
Other provider keys (e.g. `OPENAI_API_KEY`, `GROK_API_KEY`) are validated by **ai-skills** at init; for OpenRouter-only setups, ai-skills must accept `OPEN_ROUTER_KEY` / `OPENROUTER_API_KEY` in its provider check.
|
|
27
|
+
|
|
28
|
+
### Activity tracking (ai-gateway → ai-activities-tracking)
|
|
29
|
+
|
|
30
|
+
| Variable | Purpose | Default (in ai-activities-tracking) |
|
|
31
|
+
|----------|---------|-------------------------------------|
|
|
32
|
+
| `MONGO_LOGS_COLLECTION` | Main activities collection name. | `cognitive-activities` |
|
|
33
|
+
| `MONGO_BAD_REQUESTS_COLLECTION` | Bad/validation-failure requests collection name. | `ai-bad-requests` |
|
|
34
|
+
|
|
35
|
+
Both are **optional**; safe to leave unset. If unset or unresolved, ai-activities-tracking uses the defaults above and never uses the env var name as the collection name.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Summary
|
|
40
|
+
|
|
41
|
+
- **ai-tasks** only reads `MONGO_LOGS_DB` (for `bindingDefaultsDb`). All other Mongo and router env vars are used by downstream packages.
|
|
42
|
+
- For “No provider specified and no providers registered” and collection-name issues, fixes live in ai-provider-router, ai-gateway, and ai-activities-tracking. Ensure you use versions of `@athenices/ai-gateway` (and thus ai-activities-tracking) that include those fixes.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Feedback to client (worox-graphs): downstream fixes for the two reported issues
|
|
2
|
+
|
|
3
|
+
**Audience:** Consumer of `@woroces/ai-tasks` (e.g. `@woroces/worox-graph`) who reported the router and Mongo collection-name issues.
|
|
4
|
+
**From:** ai-tasks maintainers
|
|
5
|
+
**Date:** 2026-02-23
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Summary
|
|
10
|
+
|
|
11
|
+
Both issues you reported were **downstream** of ai-tasks (in ai-provider-router, ai-gateway, and ai-activities-tracking). They are fixed in those packages. **No change is required in your application (worox-graphs).** After upgrading to versions that include the fixes, the problems should be resolved.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 1. “No provider specified and no providers registered”
|
|
16
|
+
|
|
17
|
+
**What you saw:** The router threw this error even when `OPEN_ROUTER_KEY` was set; your app only calls `ai-tasks.runTask()` and does not register any provider.
|
|
18
|
+
|
|
19
|
+
**Where it was fixed:** In `@athenices/ai-provider-router` and/or `@athenices/ai-gateway`:
|
|
20
|
+
|
|
21
|
+
- OpenRouter is now considered (and can be used) **before** the “no providers registered” check, so when `OPEN_ROUTER_KEY` (or `OPENROUTER_API_KEY`) is set, the router can resolve a provider without your app registering anything.
|
|
22
|
+
- Error messaging was improved to point to setting `OPEN_ROUTER_KEY` or registering a provider when no provider can be used.
|
|
23
|
+
|
|
24
|
+
**What you should do:**
|
|
25
|
+
|
|
26
|
+
- **Upgrade** so your resolved dependency stack includes the **fixed ai-gateway** (and thus the fixed ai-provider-router). That usually means upgrading `@woroces/ai-tasks` to a version that depends on the fixed ai-gateway (e.g. ai-tasks 2.8.x with ai-gateway ^7.3.1 or the version that includes the router fix), then run `npm install`.
|
|
27
|
+
- Ensure **`OPEN_ROUTER_KEY`** (or `OPENROUTER_API_KEY`, depending on what the gateway reads) is set in your environment when you want to use OpenRouter. Load `.env` before the process starts (e.g. via dotenv/dotenvx) as you already do.
|
|
28
|
+
- You do **not** need to create or configure the router or register any provider in your app.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 2. Mongo collection names (ENV.MONGO_BAD_REQUESTS_COLLECTION etc.)
|
|
33
|
+
|
|
34
|
+
**What you saw:** When `MONGO_LOGS_COLLECTION` / `MONGO_BAD_REQUESTS_COLLECTION` were unset, the app used the env var name (or an `ENV.*` token) as the MongoDB collection name, creating collections like `ENV.MONGO_BAD_REQUESTS_COLLECTION`.
|
|
35
|
+
|
|
36
|
+
**Where it was fixed:** In `@athenices/ai-activities-tracking`:
|
|
37
|
+
|
|
38
|
+
- Defaults were added: **`cognitive-activities`** for the main logs collection and **`ai-bad-requests`** for the bad-requests collection.
|
|
39
|
+
- Collection names are normalized so that unset or unresolved `ENV.*` tokens are never used as collection names; the default is used instead.
|
|
40
|
+
|
|
41
|
+
**What you should do:**
|
|
42
|
+
|
|
43
|
+
- **Upgrade** so your resolved stack includes the **fixed ai-activities-tracking** (typically by depending on a version of ai-gateway that depends on the fixed ai-activities-tracking). Upgrading ai-tasks (and ensuring ai-gateway is updated) will pull in the fixed version.
|
|
44
|
+
- You **do not** need to set `MONGO_LOGS_COLLECTION` or `MONGO_BAD_REQUESTS_COLLECTION` unless you want to override the defaults. If they are unset or unresolved, the packages now use `cognitive-activities` and `ai-bad-requests` and never the env var name.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## No changes required in your repo
|
|
49
|
+
|
|
50
|
+
- **worox-graphs** does not need to create or configure the AI router, register providers, or read Mongo collection env vars. The fixes are entirely in the packages that implement that behavior (ai-provider-router, ai-gateway, ai-activities-tracking).
|
|
51
|
+
- Your only required action is to **upgrade** to versions that include these fixes (via `@woroces/ai-tasks` and its dependency tree). Optional: ensure `OPEN_ROUTER_KEY` (or `OPENROUTER_API_KEY`) is set when using OpenRouter.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Upgrade checklist
|
|
56
|
+
|
|
57
|
+
| Step | Action |
|
|
58
|
+
|------|--------|
|
|
59
|
+
| 1 | Upgrade `@woroces/ai-tasks` to a version that depends on the fixed ai-gateway (e.g. ^2.8.x with ai-gateway that includes the router fix). |
|
|
60
|
+
| 2 | Run `npm install` (or your package manager’s equivalent) so the lockfile resolves to the fixed ai-gateway and its transitive deps (ai-provider-router, ai-activities-tracking). |
|
|
61
|
+
| 3 | Ensure `.env` is loaded before the process starts and contains `OPEN_ROUTER_KEY` (or `OPENROUTER_API_KEY`) when using OpenRouter. |
|
|
62
|
+
| 4 | Optionally leave `MONGO_LOGS_COLLECTION` and `MONGO_BAD_REQUESTS_COLLECTION` unset; they now default to `cognitive-activities` and `ai-bad-requests`. |
|
|
63
|
+
|
|
64
|
+
If you still see “No provider specified and no providers registered” after upgrading, confirm that the resolved `@athenices/ai-gateway` (and `@athenices/ai-provider-router`) in your lockfile are the versions that include the OpenRouter fix, and that your env key (`OPEN_ROUTER_KEY` or `OPENROUTER_API_KEY`) is set before any gateway call.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Structured intermediate results for combined / multi-step tasks
|
|
2
|
+
|
|
3
|
+
When a task (or skill) runs multiple logical steps in one invocation (e.g. “to-cni + enrich + triage”), the response can include structured data for each sub-step so consumers can inspect and report what happened “in between” without extra round-trips.
|
|
4
|
+
|
|
5
|
+
## Response shape
|
|
6
|
+
|
|
7
|
+
Task responses may include an optional top-level **`intermediateSteps`** array. When present, it describes each step performed in order.
|
|
8
|
+
|
|
9
|
+
### Type: `IntermediateStep`
|
|
10
|
+
|
|
11
|
+
| Field | Type | Required | Description |
|
|
12
|
+
|-------|------|----------|-------------|
|
|
13
|
+
| `step` | number | yes | 1-based order in the execution chain |
|
|
14
|
+
| `id` | string | yes | Stable identifier (e.g. `"to-cni"`, `"engine-enrich"`, `"triage-q1-q6"`) |
|
|
15
|
+
| `ok` | boolean | yes | Whether this step completed successfully |
|
|
16
|
+
| `summary` | string | no | Short summary (e.g. `"cni built"`, `"enriched"`) |
|
|
17
|
+
| `error` | string | no | Error message when `ok` is false |
|
|
18
|
+
| `inputSummary` | object \| string | no | Summary input (e.g. keys/ids) for reporting |
|
|
19
|
+
| `outputExcerpt` | object | no | Small excerpt of step output for debugging; keep small to avoid payload bloat |
|
|
20
|
+
|
|
21
|
+
### Example response
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"success": true,
|
|
26
|
+
"output": { "answers": {}, "decision": {} },
|
|
27
|
+
"intermediateSteps": [
|
|
28
|
+
{ "step": 1, "id": "to-cni", "summary": "cni built", "ok": true },
|
|
29
|
+
{ "step": 2, "id": "engine-enrich", "summary": "enriched", "ok": true },
|
|
30
|
+
{ "step": 3, "id": "triage-q1-q6", "summary": "answers Q1,Q6", "ok": true }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
With optional excerpts for debugging:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"intermediateSteps": [
|
|
40
|
+
{ "step": 1, "id": "to-cni", "ok": true, "outputExcerpt": { "cni": { "subject": {} } } },
|
|
41
|
+
{ "step": 2, "id": "engine-enrich", "ok": true, "outputExcerpt": { "record": {} } },
|
|
42
|
+
{ "step": 3, "id": "triage-q1-q6", "ok": true }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## How it works in ai-tasks
|
|
48
|
+
|
|
49
|
+
- **Skills/tasks** that perform multiple logical steps may return `intermediateSteps` either:
|
|
50
|
+
- **Top-level** on the response (if the executor passes it through), or
|
|
51
|
+
- **Inside `parsed`** as `parsed.intermediateSteps`.
|
|
52
|
+
- **Task SDK** normalizes so that the **top-level** `response.intermediateSteps` is the canonical place:
|
|
53
|
+
- For **local tasks**: if the handler returns an object with `intermediateSteps`, they are lifted to the response and omitted from `parsed`.
|
|
54
|
+
- For **executor (DIRECT)** results: if `result.parsed.intermediateSteps` is present, it is lifted to `result.intermediateSteps` and removed from `parsed`.
|
|
55
|
+
- **NARRIX_THEN_DIRECT**: the runtime prepends a step `{ step: 1, id: "narrix", ok: true, summary: "narrix run completed" }` and renumbers any steps from the direct phase (step 2, 3, …).
|
|
56
|
+
|
|
57
|
+
## Consumer usage
|
|
58
|
+
|
|
59
|
+
Consumers (e.g. worox-graphs playground reporter) can:
|
|
60
|
+
|
|
61
|
+
1. **Persist or display** the chain (e.g. “Step 1: to-cni → Step 2: engine-enrich → Step 3: triage-q1-q6”).
|
|
62
|
+
2. **Optionally link to or embed** excerpts of intermediate payloads when `outputExcerpt` is present.
|
|
63
|
+
3. Use the list to get visibility equivalent to per-node request/response files, without requiring separate graph nodes for each step.
|
|
64
|
+
|
|
65
|
+
## TypeScript
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import type { RunTaskResponseWithSteps, IntermediateStep, IntermediateSteps } from "@woroces/ai-tasks";
|
|
69
|
+
|
|
70
|
+
const res: RunTaskResponseWithSteps<MyOutput> = await runTask(request);
|
|
71
|
+
if (res.intermediateSteps) {
|
|
72
|
+
for (const s of res.intermediateSteps) {
|
|
73
|
+
console.log(`Step ${s.step}: ${s.id} ${s.ok ? "ok" : s.error}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Acceptance criteria (reference)
|
|
79
|
+
|
|
80
|
+
- A combined task can return an optional list of intermediate steps in execution order.
|
|
81
|
+
- Each step has a stable identifier and success flag; optional summary or excerpt is supported.
|
|
82
|
+
- Consumers can use this list to render a “chain” view (e.g. in reports or playground) equivalent to the current per-node visibility, without requiring separate graph nodes for each step.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Activity Structure (Activix)
|
|
2
|
+
|
|
3
|
+
Activix activity records follow a layered structure:
|
|
4
|
+
|
|
5
|
+
- **Lifecycle-owned fields** (managed by Activix):
|
|
6
|
+
- identifiers (primary key / activity id)
|
|
7
|
+
- `status` and lifecycle transitions
|
|
8
|
+
- timing fields (`startTime`, `endTime`, `duration`)
|
|
9
|
+
- error fields (via `failRecord`)
|
|
10
|
+
- **Integrator-owned fields** (provided by the caller):
|
|
11
|
+
- `runContext` (correlation envelope)
|
|
12
|
+
- `outer` (required I/O payload tier)
|
|
13
|
+
- optional `inner` (structured sub-steps / nested call payload)
|
|
14
|
+
|
|
15
|
+
## `outer` (required)
|
|
16
|
+
|
|
17
|
+
`outer` is the canonical “activity I/O” tier and should include:
|
|
18
|
+
|
|
19
|
+
- `input`: domain input payload
|
|
20
|
+
- `output`: domain output payload (or omitted/null until completion)
|
|
21
|
+
- `metadata`: object for domain tags (type, version, sizes, routing keys, etc.)
|
|
22
|
+
|
|
23
|
+
## `inner` (optional)
|
|
24
|
+
|
|
25
|
+
Use `inner` for nested request/response payloads when you want structured visibility into sub-work (e.g. a tool call inside a broader activity).
|
|
26
|
+
|
|
27
|
+
## Ownership rules
|
|
28
|
+
|
|
29
|
+
- Do **not** manually set lifecycle-owned fields (`status`, timestamps, ids).
|
|
30
|
+
- Avoid duplicating correlation identifiers in multiple places; prefer `runContext`.
|
|
31
|
+
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# AI Task Input Scoping (aiScoping) — Detailed Specification
|
|
2
|
+
|
|
3
|
+
## 1) Purpose
|
|
4
|
+
|
|
5
|
+
Add an **optional** pre-processing mode for `runTask` that can scope large memory content into compact, task-focused snippets before the main AI task call.
|
|
6
|
+
|
|
7
|
+
The mode introduces a new request field:
|
|
8
|
+
|
|
9
|
+
- `aiScoping?: Array<{ source: string; instructions: string; targetToken: string }>`
|
|
10
|
+
|
|
11
|
+
Each `aiScoping` item triggers an **internal AI call** (in parallel), which:
|
|
12
|
+
|
|
13
|
+
1. Reads data from memory using `source`.
|
|
14
|
+
2. Applies `instructions` to that source content.
|
|
15
|
+
3. Writes result into `aiScoped` as:
|
|
16
|
+
- `{ token: targetToken, scopedInfo: string }`
|
|
17
|
+
|
|
18
|
+
The final main AI task then receives `aiScoped` as part of its input/context.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2) Goals
|
|
23
|
+
|
|
24
|
+
- Reduce prompt bloat when memory has large/irrelevant content.
|
|
25
|
+
- Allow targeted extraction/summary/selection from specific memory paths.
|
|
26
|
+
- Run scoping calls in parallel to minimize added latency.
|
|
27
|
+
- Keep this behavior strictly optional and backward compatible.
|
|
28
|
+
|
|
29
|
+
## 3) Non-goals
|
|
30
|
+
|
|
31
|
+
- No changes to existing behavior when `aiScoping` is not provided.
|
|
32
|
+
- No mandatory schema migration for existing callers.
|
|
33
|
+
- No change to current Narrix flow semantics.
|
|
34
|
+
- No implementation in this phase (spec/design only).
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 4) API Contract Changes
|
|
39
|
+
|
|
40
|
+
## 4.1 Request (new optional field)
|
|
41
|
+
|
|
42
|
+
Add to `RunTaskRequest`:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type AIScopingInstruction = {
|
|
46
|
+
source: string; // path to memory value
|
|
47
|
+
instructions: string; // prompt for internal scoping call
|
|
48
|
+
targetToken: string; // label for downstream use
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
interface RunTaskRequest {
|
|
52
|
+
// ...existing fields
|
|
53
|
+
aiScoping?: AIScopingInstruction[];
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Field semantics
|
|
58
|
+
|
|
59
|
+
- `source`
|
|
60
|
+
- Dot-path to a memory value, including nested properties.
|
|
61
|
+
- Must resolve to a value in the memory bundle available during execution.
|
|
62
|
+
- `instructions`
|
|
63
|
+
- Natural-language guidance for the internal scoping call.
|
|
64
|
+
- Should describe desired output format/constraints.
|
|
65
|
+
- `targetToken`
|
|
66
|
+
- Logical name of the scoped result.
|
|
67
|
+
- Used in output as `aiScoped[].token`.
|
|
68
|
+
|
|
69
|
+
## 4.2 Derived runtime output (new runtime data)
|
|
70
|
+
|
|
71
|
+
During execution (when `aiScoping` is provided), construct:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
type AIScopedItem = {
|
|
75
|
+
token: string;
|
|
76
|
+
scopedInfo: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type AIScoped = AIScopedItem[];
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Result is injected into the main task execution input/context as:
|
|
83
|
+
|
|
84
|
+
- `input.aiScoped: AIScoped` (preferred canonical location), and/or
|
|
85
|
+
- equivalent context markdown section (optional, implementation choice).
|
|
86
|
+
|
|
87
|
+
Note: This does **not** require changing external `RunTaskResponse` shape.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 5) Source Resolution Rules
|
|
92
|
+
|
|
93
|
+
`source` must resolve from execution memory roots. Canonical roots:
|
|
94
|
+
|
|
95
|
+
- `jobMemory.*`
|
|
96
|
+
- `taskMemory.*`
|
|
97
|
+
- `executionMemory.*`
|
|
98
|
+
|
|
99
|
+
Examples:
|
|
100
|
+
|
|
101
|
+
- `jobMemory.customerProfile`
|
|
102
|
+
- `jobMemory.records.current.incidents`
|
|
103
|
+
- `taskMemory.previousFindings`
|
|
104
|
+
- `executionMemory.executionLog.steps`
|
|
105
|
+
|
|
106
|
+
### Resolution behavior
|
|
107
|
+
|
|
108
|
+
1. If `source` is missing/invalid/unresolvable:
|
|
109
|
+
- The item is treated as failed scoping item.
|
|
110
|
+
- It does not break full task execution (default tolerant mode).
|
|
111
|
+
2. If resolved value is object/array:
|
|
112
|
+
- Serialize to deterministic JSON string for internal scoping input.
|
|
113
|
+
3. If resolved value is primitive:
|
|
114
|
+
- Convert to string.
|
|
115
|
+
4. If resolved value is empty:
|
|
116
|
+
- Proceed with empty content marker or skip item (implementation choice, see error policy).
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 6) Execution Flow (Normative)
|
|
121
|
+
|
|
122
|
+
When `aiScoping` exists and has items:
|
|
123
|
+
|
|
124
|
+
1. Build the enriched memory bundle as usual (current behavior unchanged).
|
|
125
|
+
2. For each `aiScoping` item:
|
|
126
|
+
- Resolve `source` from memory bundle.
|
|
127
|
+
- Build internal AI call input with:
|
|
128
|
+
- resolved source content
|
|
129
|
+
- item `instructions`
|
|
130
|
+
- output requirement: plain text scoped result
|
|
131
|
+
3. Dispatch all internal AI scoping calls **in parallel**.
|
|
132
|
+
4. Collect all fulfilled results into:
|
|
133
|
+
- `aiScoped: Array<{ token, scopedInfo }>`
|
|
134
|
+
5. Inject `aiScoped` into main task input/context.
|
|
135
|
+
6. Execute main task call as normal.
|
|
136
|
+
|
|
137
|
+
If `aiScoping` is absent or empty:
|
|
138
|
+
|
|
139
|
+
- skip all scoping logic;
|
|
140
|
+
- execute current pipeline exactly as today.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 7) Internal AI Scoping Call Contract
|
|
145
|
+
|
|
146
|
+
Each internal call should be deterministic and constrained:
|
|
147
|
+
|
|
148
|
+
- Input:
|
|
149
|
+
- `instructions` (caller-provided)
|
|
150
|
+
- `sourceContent` (resolved from memory)
|
|
151
|
+
- Expected output:
|
|
152
|
+
- single string (scoped information)
|
|
153
|
+
- Output post-processing:
|
|
154
|
+
- trim surrounding whitespace
|
|
155
|
+
- enforce max length safeguards (implementation-configurable)
|
|
156
|
+
|
|
157
|
+
Suggested prompt policy for internal calls:
|
|
158
|
+
|
|
159
|
+
- "Use only provided source content."
|
|
160
|
+
- "Do not invent missing facts."
|
|
161
|
+
- "Return concise scoped result for downstream AI task."
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 8) Parallelism and Performance
|
|
166
|
+
|
|
167
|
+
### Parallel execution requirement
|
|
168
|
+
|
|
169
|
+
- All scoping items should run concurrently for latency efficiency.
|
|
170
|
+
|
|
171
|
+
### Concurrency limits
|
|
172
|
+
|
|
173
|
+
- Use bounded concurrency (recommended) to avoid overload.
|
|
174
|
+
- Suggested default: 3–8 concurrent calls (configurable).
|
|
175
|
+
|
|
176
|
+
### Ordering
|
|
177
|
+
|
|
178
|
+
- Preserve original `aiScoping` order in final `aiScoped` output.
|
|
179
|
+
- If futures resolve out-of-order, reorder results before injection.
|
|
180
|
+
|
|
181
|
+
### Timeouts
|
|
182
|
+
|
|
183
|
+
- Apply per-item timeout.
|
|
184
|
+
- Timeout should fail only the scoping item, not the main task (default tolerant mode).
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 9) Error Handling Policy
|
|
189
|
+
|
|
190
|
+
Default policy: **tolerant** (recommended for backward compatibility and resilience).
|
|
191
|
+
|
|
192
|
+
- If one scoping item fails (resolution error, timeout, internal AI error):
|
|
193
|
+
- other items continue;
|
|
194
|
+
- successful items still populate `aiScoped`;
|
|
195
|
+
- main task still executes.
|
|
196
|
+
|
|
197
|
+
Failure visibility:
|
|
198
|
+
|
|
199
|
+
- Log/metadata should include failed item info (`targetToken`, failure reason).
|
|
200
|
+
- Avoid leaking sensitive source data into error logs.
|
|
201
|
+
|
|
202
|
+
Optional future extension (not required now):
|
|
203
|
+
|
|
204
|
+
- strict mode that aborts task when any scoping item fails.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 10) Validation Rules
|
|
209
|
+
|
|
210
|
+
Before execution, validate `aiScoping` items:
|
|
211
|
+
|
|
212
|
+
- `source`: non-empty string
|
|
213
|
+
- `instructions`: non-empty string
|
|
214
|
+
- `targetToken`: non-empty string
|
|
215
|
+
- `targetToken` uniqueness recommended within one request
|
|
216
|
+
|
|
217
|
+
If duplicates exist:
|
|
218
|
+
|
|
219
|
+
- recommended behavior: last-write-wins **or** reject request; choose one and document in implementation.
|
|
220
|
+
- preferred for predictability: reject duplicates with clear error.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 11) Security and Privacy
|
|
225
|
+
|
|
226
|
+
- Treat resolved `source` content as sensitive memory material.
|
|
227
|
+
- Do not log raw source payloads in plaintext logs.
|
|
228
|
+
- Internal scoping calls must receive only needed source slice (not entire memory bundle).
|
|
229
|
+
- Respect existing gateway/client auth and model policies.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 12) Integration Points (Current Codebase Guidance)
|
|
234
|
+
|
|
235
|
+
Expected integration in `runTask` DIRECT path:
|
|
236
|
+
|
|
237
|
+
- after memory enrichment (so scoped reads use enriched memory),
|
|
238
|
+
- before final executor call (so `aiScoped` is available to main task input/context).
|
|
239
|
+
|
|
240
|
+
Natural integration area: logic near `_executeDirect(...)` where enriched bundle and context are built.
|
|
241
|
+
|
|
242
|
+
No Narrix-specific branching is required; this feature is generic and optional for any task execution type that reaches DIRECT execution.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 13) Example Request/Derived Output
|
|
247
|
+
|
|
248
|
+
## 13.1 Example request
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"skillKey": "tasks/example",
|
|
253
|
+
"input": {
|
|
254
|
+
"goal": "Produce executive incident summary"
|
|
255
|
+
},
|
|
256
|
+
"jobMemory": {
|
|
257
|
+
"incidentDump": {
|
|
258
|
+
"tickets": ["...large data..."]
|
|
259
|
+
},
|
|
260
|
+
"customerContext": {
|
|
261
|
+
"name": "Acme",
|
|
262
|
+
"tier": "enterprise"
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"aiScoping": [
|
|
266
|
+
{
|
|
267
|
+
"source": "jobMemory.incidentDump",
|
|
268
|
+
"instructions": "Extract only high-severity incidents from last 7 days with one-line impact each.",
|
|
269
|
+
"targetToken": "recentCriticalIncidents"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"source": "jobMemory.customerContext",
|
|
273
|
+
"instructions": "Summarize customer profile relevant to incident communication tone.",
|
|
274
|
+
"targetToken": "customerCommunicationProfile"
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## 13.2 Derived scoped output injected to final task
|
|
281
|
+
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"aiScoped": [
|
|
285
|
+
{
|
|
286
|
+
"token": "recentCriticalIncidents",
|
|
287
|
+
"scopedInfo": "..."
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"token": "customerCommunicationProfile",
|
|
291
|
+
"scopedInfo": "..."
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 14) Backward Compatibility
|
|
300
|
+
|
|
301
|
+
- If `aiScoping` is omitted: execution remains exactly current behavior.
|
|
302
|
+
- Existing clients and builders remain valid.
|
|
303
|
+
- Existing tasks do not need modification.
|
|
304
|
+
- Feature is opt-in per request.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 15) Test Plan (for future implementation)
|
|
309
|
+
|
|
310
|
+
Unit tests:
|
|
311
|
+
|
|
312
|
+
- validation of `aiScoping` items (required fields, duplicate tokens)
|
|
313
|
+
- source path resolution (valid, invalid, nested, primitive/object/array)
|
|
314
|
+
- deterministic output ordering under parallel completion
|
|
315
|
+
- tolerant failure behavior (partial success still runs main task)
|
|
316
|
+
|
|
317
|
+
Integration tests:
|
|
318
|
+
|
|
319
|
+
- end-to-end DIRECT execution with `aiScoping` and injected `input.aiScoped`
|
|
320
|
+
- timeout and internal call failure handling
|
|
321
|
+
- no-regression test: request without `aiScoping` matches current behavior
|
|
322
|
+
|
|
323
|
+
Performance tests:
|
|
324
|
+
|
|
325
|
+
- compare serial vs parallel scoping latency with multiple items
|
|
326
|
+
- verify bounded concurrency behavior under high item counts
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 16) Acceptance Criteria
|
|
331
|
+
|
|
332
|
+
1. `RunTaskRequest` accepts optional `aiScoping`.
|
|
333
|
+
2. Each scoping item triggers internal AI scoping based on memory `source` + `instructions`.
|
|
334
|
+
3. Scoping calls execute in parallel (with bounded concurrency).
|
|
335
|
+
4. Results are available to main task as `aiScoped: [{ token, scopedInfo }]`.
|
|
336
|
+
5. Absence of `aiScoping` preserves current behavior with no output/flow regressions.
|
|
337
|
+
6. Failures in individual scoping items do not break the main task by default.
|
|
338
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Model profile aliases (graph-engine 7.x+ / ai-tasks 8.4+)
|
|
2
|
+
|
|
3
|
+
Wire contract for **`RunTaskRequest.modelConfig`** and per-stage **`llmCall.model`** when using **`@x12i/ai-profiles`** instead of concrete provider ids.
|
|
4
|
+
|
|
5
|
+
## Required triplet (8.4+)
|
|
6
|
+
|
|
7
|
+
Every `runTask()` call must set all three slots:
|
|
8
|
+
|
|
9
|
+
| Slot | Role | xynthesis vs ai-skills |
|
|
10
|
+
|------|------|------------------------|
|
|
11
|
+
| `preActionModel` | PRE synthesis / utility | **ai-profiles alias only** → xynthesis |
|
|
12
|
+
| `skillModel` | MAIN skill | alias **or** concrete id → ai-skills |
|
|
13
|
+
| `postActionModel` | POST audit/polish/scoping | **ai-profiles alias only** → xynthesis |
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"preActionModel": "cheap/default",
|
|
18
|
+
"skillModel": "pro/default",
|
|
19
|
+
"postActionModel": "cheap/default"
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Accepted alias shapes
|
|
24
|
+
|
|
25
|
+
| Shape | Example | Notes |
|
|
26
|
+
|-------|---------|-------|
|
|
27
|
+
| `profile/choice` | `cheap/default`, `json/default` | Preferred — sync-checkable via `isKnownProfileChoice` |
|
|
28
|
+
| Bare profile | `cheap`, `pro` | Expanded to `profile/default` at invoke (`toStrictAiProfileResolveInput`) |
|
|
29
|
+
| `@` form | `cheap@default`, `pro@fast` | Normalized to `profile/choice` before `resolveAIProfile` |
|
|
30
|
+
|
|
31
|
+
**List keys:** `listAiTasksProfileChoiceKeys()` / `listAiTasksProfileChoices()` from `@exellix/ai-tasks` (text lane, bundled or remote registry).
|
|
32
|
+
|
|
33
|
+
## Rejected (legacy)
|
|
34
|
+
|
|
35
|
+
- Graph-era tiers: `weak`, `strong`
|
|
36
|
+
- Deprecated slots: `xynthesisModel`, root `modelConfig.model`
|
|
37
|
+
- Host token caps: `maxTokens`, `maxTokensCap` on task payloads
|
|
38
|
+
- Removed ai-profiles 2.0 shortcuts: `cheapest`, sync `isKnownProfileOrShortcut`
|
|
39
|
+
|
|
40
|
+
Unknown profile keys fail at **`resolveAIProfile`** with a clear error.
|
|
41
|
+
|
|
42
|
+
## Resolution boundaries
|
|
43
|
+
|
|
44
|
+
| Path | Fields | Normalized by |
|
|
45
|
+
|------|--------|---------------|
|
|
46
|
+
| Xynthesis (PRE/POST/scoping/utilities) | `preActionModel`, `postActionModel`, step `llmCall.model` | `resolveModelReferenceForXynthesis` → `toStrictAiProfileResolveInput` |
|
|
47
|
+
| ai-skills MAIN | `skillModel`, `RunTaskRequest.llmCall.model` | `resolveModelReference` → concrete `provider/model` |
|
|
48
|
+
|
|
49
|
+
Concrete ids (`openrouter/...`, `anthropic/claude-...`, `openai/gpt-5`) pass through on **`skillModel`** only. PRE/POST must stay ai-profiles aliases under `@exellix/xynthesis` ≥ 4.3.1.
|
|
50
|
+
|
|
51
|
+
## graph-engine guidance
|
|
52
|
+
|
|
53
|
+
- Send the triplet on every node/task compile — no env defaults, no `"balanced"` fallback.
|
|
54
|
+
- Prefer explicit **`profile/choice`** keys in compiled payloads; bare profile keys are OK (ai-tasks normalizes before xynthesis).
|
|
55
|
+
- Optional: pre-resolve aliases in graph-engine for diagnostics; ai-tasks re-resolves at invoke (idempotent for concrete ids).
|
|
56
|
+
- Do **not** npm-override `@x12i/ai-profiles` or pin `<2.1`.
|
|
57
|
+
|
|
58
|
+
## Stack minimums
|
|
59
|
+
|
|
60
|
+
| Package | Minimum |
|
|
61
|
+
|---------|---------|
|
|
62
|
+
| `@exellix/ai-tasks` | 8.4.x |
|
|
63
|
+
| `@x12i/ai-profiles` | 2.1.0 |
|
|
64
|
+
| `@exellix/xynthesis` | 4.3.1 |
|
|
65
|
+
| `@exellix/ai-skills` | 6.0.0 |
|
|
66
|
+
|
|
67
|
+
## Public helpers (`@exellix/ai-tasks`)
|
|
68
|
+
|
|
69
|
+
- `toStrictAiProfileResolveInput` — bare profile → `profile/default`
|
|
70
|
+
- `resolveModelReference` / `resolveModelReferenceForXynthesis`
|
|
71
|
+
- `isResolvableModelAlias` — true for known **`profile/choice`** keys only
|
|
72
|
+
- `listAiTasksProfileChoices`, `listAiTasksProfiles`, `listAiTasksProfileChoiceKeys`
|
|
73
|
+
|
|
74
|
+
See [README — Model profile aliases](../README.md#model-profile-aliases-x12iai-profiles).
|