@exellix/ai-tasks 10.0.9 → 10.0.11
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/CHANGELOG.md +25 -0
- package/README.md +32 -35
- package/RUNTASK_REQUEST.md +4 -4
- package/dist/activix/phaseTracking.d.ts +1 -1
- package/dist/activix/phaseTracking.d.ts.map +1 -1
- package/dist/activix/phaseTracking.js.map +1 -1
- package/dist/builders/task-request-builder.d.ts +1 -54
- package/dist/builders/task-request-builder.d.ts.map +1 -1
- package/dist/builders/task-request-builder.js +1 -180
- package/dist/builders/task-request-builder.js.map +1 -1
- package/dist/core/task-sdk.d.ts +4 -10
- package/dist/core/task-sdk.d.ts.map +1 -1
- package/dist/core/task-sdk.js +35 -117
- package/dist/core/task-sdk.js.map +1 -1
- package/dist/errors/runTaskExecutionError.d.ts +1 -1
- package/dist/errors/runTaskExecutionError.d.ts.map +1 -1
- package/dist/errors/runTaskExecutionError.js +0 -2
- package/dist/errors/runTaskExecutionError.js.map +1 -1
- package/dist/errors/smartInputValidationError.d.ts +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/resolveRunTaskRuntimeKnobs.d.ts +2 -5
- package/dist/internal/resolveRunTaskRuntimeKnobs.d.ts.map +1 -1
- package/dist/internal/resolveRunTaskRuntimeKnobs.js +3 -36
- package/dist/internal/resolveRunTaskRuntimeKnobs.js.map +1 -1
- package/dist/localTasks/collectEvidence.d.ts.map +1 -1
- package/dist/localTasks/collectEvidence.js +13 -23
- package/dist/localTasks/collectEvidence.js.map +1 -1
- package/dist/localTasks/decideWebScope.js +1 -1
- package/dist/localTasks/decideWebScope.js.map +1 -1
- package/dist/localTasks/index.d.ts +0 -1
- package/dist/localTasks/index.d.ts.map +1 -1
- package/dist/localTasks/index.js +2 -4
- package/dist/localTasks/index.js.map +1 -1
- package/dist/localTasks/playgroundSeedMain.d.ts +4 -0
- package/dist/localTasks/playgroundSeedMain.d.ts.map +1 -0
- package/dist/localTasks/playgroundSeedMain.js +26 -0
- package/dist/localTasks/playgroundSeedMain.js.map +1 -0
- package/dist/logxer/aiTasksDiagnosticCodes.d.ts +1 -1
- package/dist/logxer/aiTasksDiagnosticCodes.js +1 -1
- package/dist/logxer/aiTasksDiagnosticCodes.js.map +1 -1
- package/dist/narrix/narrixUnitExecution.d.ts.map +1 -1
- package/dist/narrix/narrixUnitExecution.js +1 -6
- package/dist/narrix/narrixUnitExecution.js.map +1 -1
- package/dist/narrix/webContextMarkdown.d.ts +2 -25
- package/dist/narrix/webContextMarkdown.d.ts.map +1 -1
- package/dist/narrix/webContextMarkdown.js +33 -57
- package/dist/narrix/webContextMarkdown.js.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.d.ts.map +1 -1
- package/dist/node-execution/buildRequestFromNodePlan.js +0 -12
- package/dist/node-execution/buildRequestFromNodePlan.js.map +1 -1
- package/dist/node-execution/createNodeExecutionHost.d.ts.map +1 -1
- package/dist/node-execution/createNodeExecutionHost.js +1 -26
- package/dist/node-execution/createNodeExecutionHost.js.map +1 -1
- package/dist/node-execution/dispatchExecutionUnit.d.ts.map +1 -1
- package/dist/node-execution/dispatchExecutionUnit.js +0 -15
- package/dist/node-execution/dispatchExecutionUnit.js.map +1 -1
- package/dist/node-execution/executeNodeFromPlan.d.ts.map +1 -1
- package/dist/node-execution/executeNodeFromPlan.js +0 -15
- package/dist/node-execution/executeNodeFromPlan.js.map +1 -1
- package/dist/node-execution/executePlaygroundElement.d.ts +23 -0
- package/dist/node-execution/executePlaygroundElement.d.ts.map +1 -0
- package/dist/node-execution/executePlaygroundElement.js +80 -0
- package/dist/node-execution/executePlaygroundElement.js.map +1 -0
- package/dist/node-execution/index.d.ts +2 -0
- package/dist/node-execution/index.d.ts.map +1 -1
- package/dist/node-execution/index.js +1 -0
- package/dist/node-execution/index.js.map +1 -1
- package/dist/node-execution/types.d.ts +0 -2
- package/dist/node-execution/types.d.ts.map +1 -1
- package/dist/observability/classifyRunTaskFailure.d.ts +1 -1
- package/dist/observability/classifyRunTaskFailure.d.ts.map +1 -1
- package/dist/observability/classifyRunTaskFailure.js +0 -3
- package/dist/observability/classifyRunTaskFailure.js.map +1 -1
- package/dist/observability/extractAiTasksObservability.d.ts.map +1 -1
- package/dist/observability/extractAiTasksObservability.js +0 -8
- package/dist/observability/extractAiTasksObservability.js.map +1 -1
- package/dist/planWebScopeQuestions/index.d.ts +1 -1
- package/dist/planWebScopeQuestions/index.js +1 -1
- package/dist/rendrixUpstreamExports.d.ts +1 -1
- package/dist/rendrixUpstreamExports.d.ts.map +1 -1
- package/dist/rendrixUpstreamExports.js +1 -1
- package/dist/rendrixUpstreamExports.js.map +1 -1
- package/dist/synthesis/index.d.ts +1 -1
- package/dist/synthesis/index.js +1 -1
- package/dist/synthesis/resolveSourceMaterial.d.ts +3 -7
- package/dist/synthesis/resolveSourceMaterial.d.ts.map +1 -1
- package/dist/synthesis/resolveSourceMaterial.js +15 -78
- package/dist/synthesis/resolveSourceMaterial.js.map +1 -1
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.d.ts +0 -1
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.d.ts.map +1 -1
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.js +1 -9
- package/dist/task-strategies/buildTaskStrategyCatalogDescriptor.js.map +1 -1
- package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts +3 -4
- package/dist/task-strategies/canonicalInputExecutionStrategies.d.ts.map +1 -1
- package/dist/task-strategies/canonicalInputExecutionStrategies.js +3 -4
- package/dist/task-strategies/canonicalInputExecutionStrategies.js.map +1 -1
- package/dist/task-strategies/canonicalTaskStrategies.d.ts +2 -2
- package/dist/task-strategies/canonicalTaskStrategies.js +1 -1
- package/dist/task-strategies/canonicalTaskStrategies.js.map +1 -1
- package/dist/task-strategies/cataloxCatalogViews.d.ts +2 -5
- package/dist/task-strategies/cataloxCatalogViews.d.ts.map +1 -1
- package/dist/task-strategies/cataloxCatalogViews.js +3 -6
- package/dist/task-strategies/cataloxCatalogViews.js.map +1 -1
- package/dist/task-strategies/constants.d.ts +0 -4
- package/dist/task-strategies/constants.d.ts.map +1 -1
- package/dist/task-strategies/constants.js +0 -4
- package/dist/task-strategies/constants.js.map +1 -1
- package/dist/task-strategies/index.d.ts +4 -6
- package/dist/task-strategies/index.d.ts.map +1 -1
- package/dist/task-strategies/index.js +4 -5
- package/dist/task-strategies/index.js.map +1 -1
- package/dist/task-strategies/listAiTaskStrategies.d.ts +0 -2
- package/dist/task-strategies/listAiTaskStrategies.d.ts.map +1 -1
- package/dist/task-strategies/listAiTaskStrategies.js +1 -5
- package/dist/task-strategies/listAiTaskStrategies.js.map +1 -1
- package/dist/types/index.d.ts +1 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/task-types.d.ts +9 -133
- package/dist/types/task-types.d.ts.map +1 -1
- package/dist/types/task-types.js +0 -4
- package/dist/types/task-types.js.map +1 -1
- package/dist/types/web-scope-types.d.ts +20 -0
- package/dist/types/web-scope-types.d.ts.map +1 -0
- package/dist/types/web-scope-types.js +2 -0
- package/dist/types/web-scope-types.js.map +1 -0
- package/dist/utils/runTaskRequestShape.d.ts +1 -5
- package/dist/utils/runTaskRequestShape.d.ts.map +1 -1
- package/dist/utils/runTaskRequestShape.js +0 -26
- package/dist/utils/runTaskRequestShape.js.map +1 -1
- package/dist/utils/templateContext.d.ts +16 -0
- package/dist/utils/templateContext.d.ts.map +1 -0
- package/dist/utils/templateContext.js +35 -0
- package/dist/utils/templateContext.js.map +1 -0
- package/dist/validation/helpers.d.ts.map +1 -1
- package/dist/validation/helpers.js +3 -22
- package/dist/validation/helpers.js.map +1 -1
- package/dist/validation/validateRunTaskConfig.d.ts.map +1 -1
- package/dist/validation/validateRunTaskConfig.js +2 -0
- package/dist/validation/validateRunTaskConfig.js.map +1 -1
- package/dist/validation/validateRunTaskInvoke.d.ts.map +1 -1
- package/dist/validation/validateRunTaskInvoke.js +2 -0
- package/dist/validation/validateRunTaskInvoke.js.map +1 -1
- package/dist/validation/validateWebScopeUnit.d.ts +16 -0
- package/dist/validation/validateWebScopeUnit.d.ts.map +1 -0
- package/dist/validation/validateWebScopeUnit.js +107 -0
- package/dist/validation/validateWebScopeUnit.js.map +1 -0
- package/dist/web-scope/applyWebScopeToRequest.d.ts +11 -0
- package/dist/web-scope/applyWebScopeToRequest.d.ts.map +1 -0
- package/dist/web-scope/applyWebScopeToRequest.js +42 -0
- package/dist/web-scope/applyWebScopeToRequest.js.map +1 -0
- package/dist/web-scope/buildSearchInput.d.ts +22 -0
- package/dist/web-scope/buildSearchInput.d.ts.map +1 -0
- package/dist/web-scope/buildSearchInput.js +108 -0
- package/dist/web-scope/buildSearchInput.js.map +1 -0
- package/dist/web-scope/client.d.ts +12 -0
- package/dist/web-scope/client.d.ts.map +1 -0
- package/dist/web-scope/client.js +72 -0
- package/dist/web-scope/client.js.map +1 -0
- package/dist/web-scope/renderWebQueryTemplate.d.ts +14 -0
- package/dist/web-scope/renderWebQueryTemplate.d.ts.map +1 -0
- package/dist/web-scope/renderWebQueryTemplate.js +44 -0
- package/dist/web-scope/renderWebQueryTemplate.js.map +1 -0
- package/dist/web-scope/webContextMarkdown.d.ts +22 -0
- package/dist/web-scope/webContextMarkdown.d.ts.map +1 -0
- package/dist/web-scope/webContextMarkdown.js +163 -0
- package/dist/web-scope/webContextMarkdown.js.map +1 -0
- package/documenations/run-task-execution-flow.md +3 -7
- package/documenations/web-scoping-in-ai-tasks.md +88 -428
- package/package.json +16 -33
- package/dist/narrix/applyWebScopeToRequest.d.ts +0 -9
- package/dist/narrix/applyWebScopeToRequest.d.ts.map +0 -1
- package/dist/narrix/applyWebScopeToRequest.js +0 -156
- package/dist/narrix/applyWebScopeToRequest.js.map +0 -1
- package/dist/narrix/buildWebScopeScopeInput.d.ts +0 -39
- package/dist/narrix/buildWebScopeScopeInput.d.ts.map +0 -1
- package/dist/narrix/buildWebScopeScopeInput.js +0 -193
- package/dist/narrix/buildWebScopeScopeInput.js.map +0 -1
- package/dist/narrix/webScoper.d.ts +0 -43
- package/dist/narrix/webScoper.d.ts.map +0 -1
- package/dist/narrix/webScoper.js +0 -144
- package/dist/narrix/webScoper.js.map +0 -1
- package/documenations/activix.md +0 -187
package/dist/narrix/webScoper.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { createWebScoper } from "@exellix/narrix-web-scoper";
|
|
2
|
-
import { createSearchAdapter } from "@x12i/search-adapter";
|
|
3
|
-
let searchAdapterInstance = null;
|
|
4
|
-
let defaultScoper = null;
|
|
5
|
-
let testOverride = null;
|
|
6
|
-
function getSearchAdapter() {
|
|
7
|
-
if (!searchAdapterInstance) {
|
|
8
|
-
searchAdapterInstance = createSearchAdapter({
|
|
9
|
-
provider: "tavily",
|
|
10
|
-
tavily: {
|
|
11
|
-
apiKey: process.env.TAVILY_API_KEY,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return searchAdapterInstance;
|
|
16
|
-
}
|
|
17
|
-
/** Returns (and lazily creates) the shared NarrixWebScoper instance (default @exellix/narrix-web-scoper config). */
|
|
18
|
-
export function getWebScoper() {
|
|
19
|
-
if (testOverride)
|
|
20
|
-
return testOverride;
|
|
21
|
-
if (!defaultScoper) {
|
|
22
|
-
defaultScoper = createWebScoper({ enabled: true, searchAdapter: getSearchAdapter() });
|
|
23
|
-
}
|
|
24
|
-
return defaultScoper;
|
|
25
|
-
}
|
|
26
|
-
/** Reset singletons (test helper). */
|
|
27
|
-
export function resetWebScoperSingleton() {
|
|
28
|
-
searchAdapterInstance = null;
|
|
29
|
-
defaultScoper = null;
|
|
30
|
-
testOverride = null;
|
|
31
|
-
}
|
|
32
|
-
/** Override singleton with a mock (test helper). */
|
|
33
|
-
export function setWebScoperForTesting(mock) {
|
|
34
|
-
testOverride = mock;
|
|
35
|
-
}
|
|
36
|
-
function hasRequestScoping(scoping) {
|
|
37
|
-
if (!scoping)
|
|
38
|
-
return false;
|
|
39
|
-
return Object.keys(scoping).length > 0;
|
|
40
|
-
}
|
|
41
|
-
function scoperForCall(scoping) {
|
|
42
|
-
if (testOverride)
|
|
43
|
-
return testOverride;
|
|
44
|
-
if (hasRequestScoping(scoping)) {
|
|
45
|
-
return createWebScoper({
|
|
46
|
-
enabled: true,
|
|
47
|
-
searchAdapter: getSearchAdapter(),
|
|
48
|
-
scoping,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return getWebScoper();
|
|
52
|
-
}
|
|
53
|
-
function isWebContextLike(v) {
|
|
54
|
-
if (!v || typeof v !== "object")
|
|
55
|
-
return false;
|
|
56
|
-
const o = v;
|
|
57
|
-
return Array.isArray(o.findings) && Array.isArray(o.sources) && Array.isArray(o.queriesUsed);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Map `scopeQuestionPack` output to the legacy `WebScoperResult` shape stored in `executionMemory.webContext`
|
|
61
|
-
* so `buildWebContextEvidenceMarkdown` and synthesis paths stay compatible.
|
|
62
|
-
*/
|
|
63
|
-
export function mapWebScopePackResultToWebScoperResult(pack) {
|
|
64
|
-
if (!pack.available) {
|
|
65
|
-
return { available: false, reason: "notEligible" };
|
|
66
|
-
}
|
|
67
|
-
const pc = pack.context;
|
|
68
|
-
const findings = Array.isArray(pc.findings) ? pc.findings : [];
|
|
69
|
-
const sources = Array.isArray(pc.sources) ? pc.sources : [];
|
|
70
|
-
const queriesUsed = Array.isArray(pc.queriesUsed) ? pc.queriesUsed : [];
|
|
71
|
-
const summary = typeof pc.summary === "string" ? pc.summary.trim() : "";
|
|
72
|
-
const hasLegacy = findings.length > 0 ||
|
|
73
|
-
sources.length > 0 ||
|
|
74
|
-
queriesUsed.length > 0 ||
|
|
75
|
-
summary.length > 0;
|
|
76
|
-
if (hasLegacy) {
|
|
77
|
-
return {
|
|
78
|
-
available: true,
|
|
79
|
-
context: {
|
|
80
|
-
findings,
|
|
81
|
-
...(summary ? { summary } : {}),
|
|
82
|
-
queriesUsed,
|
|
83
|
-
evidenceCount: findings.length,
|
|
84
|
-
sources,
|
|
85
|
-
retrievedAt: new Date().toISOString(),
|
|
86
|
-
},
|
|
87
|
-
cached: false,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
const scopes = pc.scopes;
|
|
91
|
-
if (scopes && typeof scopes === "object") {
|
|
92
|
-
for (const s of Object.values(scopes)) {
|
|
93
|
-
if (s?.available === true && s.context && isWebContextLike(s.context)) {
|
|
94
|
-
return {
|
|
95
|
-
available: true,
|
|
96
|
-
context: s.context,
|
|
97
|
-
cached: Boolean(s.cached),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return { available: false, reason: "noQueries" };
|
|
103
|
-
}
|
|
104
|
-
/** Non-empty trimmed strings only; omits unset/blank ids. */
|
|
105
|
-
export function webScopeActivixCorrelationPatch(parts) {
|
|
106
|
-
const out = {};
|
|
107
|
-
const jobId = typeof parts.jobId === "string" ? parts.jobId.trim() : "";
|
|
108
|
-
const taskId = typeof parts.taskId === "string" ? parts.taskId.trim() : "";
|
|
109
|
-
const sessionId = typeof parts.sessionId === "string" ? parts.sessionId.trim() : "";
|
|
110
|
-
if (jobId)
|
|
111
|
-
out.jobId = jobId;
|
|
112
|
-
if (taskId)
|
|
113
|
-
out.taskId = taskId;
|
|
114
|
-
if (sessionId)
|
|
115
|
-
out.sessionId = sessionId;
|
|
116
|
-
return out;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Run scopeGeneric and return the result. On any thrown error, returns an available:false result
|
|
120
|
-
* so callers can apply lenient fallback without try/catch boilerplate.
|
|
121
|
-
*/
|
|
122
|
-
export async function runWebScope(input, options) {
|
|
123
|
-
try {
|
|
124
|
-
return await scoperForCall(options?.scoping).scopeGeneric(input);
|
|
125
|
-
}
|
|
126
|
-
catch (err) {
|
|
127
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
128
|
-
return { available: false, reason: "error", error: message };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Run `scopeQuestionPack` and normalize to {@link WebScoperResult} for `executionMemory.webContext`.
|
|
133
|
-
*/
|
|
134
|
-
export async function runWebScopeQuestionPack(input, options) {
|
|
135
|
-
try {
|
|
136
|
-
const pack = await scoperForCall(options?.scoping).scopeQuestionPack(input);
|
|
137
|
-
return mapWebScopePackResultToWebScoperResult(pack);
|
|
138
|
-
}
|
|
139
|
-
catch (err) {
|
|
140
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
141
|
-
return { available: false, reason: "error", error: message };
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=webScoper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webScoper.js","sourceRoot":"","sources":["../../src/narrix/webScoper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAW3D,IAAI,qBAAqB,GAAkD,IAAI,CAAC;AAChF,IAAI,aAAa,GAA2B,IAAI,CAAC;AACjD,IAAI,YAAY,GAA2B,IAAI,CAAC;AAEhD,SAAS,gBAAgB;IACvB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG,mBAAmB,CAAC;YAC1C,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE;gBACN,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;aACnC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,YAAY;IAC1B,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IACtC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,a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c summarizes task-activity tracking via `@x12i/activix`.
|
|
4
|
-
|
|
5
|
-
## Activix Integration Best Practices Checklist
|
|
6
|
-
|
|
7
|
-
Use this as the operational checklist for integrating `@x12i/activix` correctly and consistently.
|
|
8
|
-
|
|
9
|
-
### 1) Ownership and boundaries
|
|
10
|
-
|
|
11
|
-
- Treat **Activix** as the activity-domain layer:
|
|
12
|
-
- lifecycle semantics (`start` / `in_progress` / `complete` / `fail`)
|
|
13
|
-
- activity contract validation
|
|
14
|
-
- run-context correlation persistence
|
|
15
|
-
- Treat **xronox-store** as the data tier:
|
|
16
|
-
- cache, write mode, retry policy, Mongo persistence behavior
|
|
17
|
-
- collection/index management
|
|
18
|
-
- generic primary-key storage mechanics
|
|
19
|
-
|
|
20
|
-
### 2) Construct once, reuse instance
|
|
21
|
-
|
|
22
|
-
- Prefer one `Activix` instance per service process (or one shared `XronoxStore` with `skipStoreInit: true`).
|
|
23
|
-
- Do not create a new `Activix` per tiny unit of work unless architecture requires it.
|
|
24
|
-
- If multi-instance is expected, pass `diagnostics` metadata so logs are self-identifying.
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
const ax = new Activix({
|
|
28
|
-
storageMode: 'automatic', // or 'database'
|
|
29
|
-
mongoUri: process.env.MONGO_URI!,
|
|
30
|
-
collection: 'task-activities',
|
|
31
|
-
diagnostics: {
|
|
32
|
-
owner: '@your-org/your-service',
|
|
33
|
-
component: 'graph-executor',
|
|
34
|
-
instanceLabel: 'worker-main',
|
|
35
|
-
workerId: process.pid.toString(),
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
await ax.init();
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 3) Define collection contract explicitly
|
|
42
|
-
|
|
43
|
-
- Set collection names in code (`collection` or `collections`).
|
|
44
|
-
- Keep `primaryKey` and `primaryKeyPrefix` intentional.
|
|
45
|
-
- If you index `activityId` uniquely, Activix must always persist a non-null `activityId` (current behavior).
|
|
46
|
-
- Ensure store-side visibility matches `purgeAtField` if using soft purge.
|
|
47
|
-
|
|
48
|
-
### 4) Always pass run context at write time
|
|
49
|
-
|
|
50
|
-
- `runContext` is runtime context, not constructor config.
|
|
51
|
-
- Always pass a real `sessionId` from true upstream when available.
|
|
52
|
-
- Forward run context through layers; do not replace inherited correlation IDs.
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
const { activityId } = await ax.startRecord({
|
|
56
|
-
runContext: {
|
|
57
|
-
sessionId: request.sessionId,
|
|
58
|
-
jobId: request.jobId,
|
|
59
|
-
taskId: request.taskId,
|
|
60
|
-
},
|
|
61
|
-
outer: {
|
|
62
|
-
input: payload,
|
|
63
|
-
output: null,
|
|
64
|
-
metadata: { type: 'task' },
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 5) Use lifecycle APIs as intended
|
|
70
|
-
|
|
71
|
-
- `startRecord()` first; keep returned `activityId`.
|
|
72
|
-
- Use the same `activityId` for all follow-ups:
|
|
73
|
-
- `markInProgress(activityId, ...)`
|
|
74
|
-
- `completeRecord(activityId, ...)`
|
|
75
|
-
- `failRecord(activityId, ...)`
|
|
76
|
-
- `patchRecord(activityId, ...)`
|
|
77
|
-
- `getRecord(activityId)`
|
|
78
|
-
- Never pass empty IDs; treat missing ID as integration bug and fail fast.
|
|
79
|
-
|
|
80
|
-
### 6) Respect payload ownership rules
|
|
81
|
-
|
|
82
|
-
- Integrators should provide domain payload (`outer`/`inner`/`runContext`).
|
|
83
|
-
- Do not provide lifecycle-owned fields manually:
|
|
84
|
-
- `activityId` / configured primary key
|
|
85
|
-
- `status`, `startTime`, `endTime`, `duration`
|
|
86
|
-
- `createdAt`, `updatedAt`
|
|
87
|
-
- `error` (except via `failRecord`)
|
|
88
|
-
|
|
89
|
-
### 6b) Collection tracking state (Activix 8.4+) — always call, let Activix persist
|
|
90
|
-
|
|
91
|
-
- **Always call** Activix lifecycle APIs on every AI activity phase (`startRecord`, `completeRecord`, `failRecord`, …).
|
|
92
|
-
- **Do not** branch in ai-tasks (or other integrators) on whether to write to Mongo.
|
|
93
|
-
- Activix reads the **`activix-collections`** legend row for your collection and its **`state`**:
|
|
94
|
-
- **`track`** (default) — rows are persisted
|
|
95
|
-
- **`off`** — same API and return shapes; Mongo writes are skipped
|
|
96
|
-
- Toggle persistence at runtime: `setCollectionTrackingState('task-activities', 'off' | 'track')`.
|
|
97
|
-
- ai-tasks constructs Activix when **`MONGO_URI`** or **`MONGO_LOGS_URI`** is set; set **`ACTIVIX_ENABLED=false`** only to skip client construction entirely (dev/CI zero-overhead escape hatch).
|
|
98
|
-
- Package collection name is **`task-activities`** (hard-coded in `src/activix/activixClient.ts`).
|
|
99
|
-
|
|
100
|
-
### 7) Validate shape and observability expectations
|
|
101
|
-
|
|
102
|
-
- `outer` is required and must contain:
|
|
103
|
-
- `input`
|
|
104
|
-
- `output` (or omitted initially and normalized)
|
|
105
|
-
- `metadata` object
|
|
106
|
-
- Optional `inner` must follow request/response/metadata shape.
|
|
107
|
-
- Enable logs during rollout:
|
|
108
|
-
- `ACTIVIX_LOGS_LEVEL=debug`
|
|
109
|
-
- `XRONOX_STORE_LOG=1`
|
|
110
|
-
|
|
111
|
-
### 8) Multi-instance init diagnostics
|
|
112
|
-
|
|
113
|
-
If `storageMode: 'automatic'`, each Activix instance performs:
|
|
114
|
-
|
|
115
|
-
1. one Mongo probe
|
|
116
|
-
2. one store init
|
|
117
|
-
|
|
118
|
-
Use these fields to distinguish healthy multi-instance behavior from bugs:
|
|
119
|
-
|
|
120
|
-
- `activixInstanceId`
|
|
121
|
-
- `alreadyInitialized`
|
|
122
|
-
- `usingInitPromise`
|
|
123
|
-
- `initCallCount`
|
|
124
|
-
|
|
125
|
-
Expected pattern: one probe + one store init per `activixInstanceId`.
|
|
126
|
-
|
|
127
|
-
### 9) Reliability and retry expectations
|
|
128
|
-
|
|
129
|
-
- Retry/classification policy belongs to xronox-store.
|
|
130
|
-
- For deterministic Mongo failures (e.g. duplicate key), rely on current store behavior/version policy.
|
|
131
|
-
- Keep `@xronoces/xronox-store` up to date and pin known-good versions in CI.
|
|
132
|
-
|
|
133
|
-
### 10) Minimum production readiness checklist
|
|
134
|
-
|
|
135
|
-
- [ ] Single shared Activix instance (or intentional multi-instance with diagnostics metadata)
|
|
136
|
-
- [ ] Stable collection configuration committed in code
|
|
137
|
-
- [ ] `runContext.sessionId` passed from upstream for correlated runs
|
|
138
|
-
- [ ] `startRecord` return value (`activityId`) propagated through full lifecycle
|
|
139
|
-
- [ ] Logging flags documented for operations team
|
|
140
|
-
- [ ] Integration test path covers start -> progress -> complete/fail
|
|
141
|
-
- [ ] Dependency version policy defined for `@xronoces/xronox-store`
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
For deeper reference, see:
|
|
146
|
-
|
|
147
|
-
- `README.md`
|
|
148
|
-
- `.docs/run-context-object.md`
|
|
149
|
-
- `.docs/session-id-usage.md`
|
|
150
|
-
- `.docs/activity-structure.md`
|
|
151
|
-
- `.docs/logging-stack.md`
|
|
152
|
-
|
|
153
|
-
## What it tracks
|
|
154
|
-
|
|
155
|
-
A single `runTask()` call can emit phase records such as:
|
|
156
|
-
|
|
157
|
-
- `local`
|
|
158
|
-
- `narrix`
|
|
159
|
-
- `pipeline_pre`
|
|
160
|
-
- `direct`
|
|
161
|
-
- `audit`
|
|
162
|
-
- `polish`
|
|
163
|
-
- `narrix_then_direct`
|
|
164
|
-
|
|
165
|
-
All records for a run share a correlation id for grouping.
|
|
166
|
-
|
|
167
|
-
## Enablement
|
|
168
|
-
|
|
169
|
-
- **Client wiring:** Activix is constructed when `MONGO_URI` or `MONGO_LOGS_URI` is set. Set `ACTIVIX_ENABLED=false` to opt out (no client, no lifecycle API calls).
|
|
170
|
-
- **Mongo persistence:** Controlled by Activix collection legend **`state`** (`track` | `off`) in `activix-collections`, not by a required `ACTIVIX_ENABLED=true` flag. ai-tasks always calls lifecycle APIs when wired; Activix decides whether rows reach Mongo.
|
|
171
|
-
- Activix failures are treated as non-fatal to task execution.
|
|
172
|
-
|
|
173
|
-
## Typical metadata
|
|
174
|
-
|
|
175
|
-
- `skillKey`, `executionStrategiesSummary`, `narrixMode`, `jobId`, `agentId`
|
|
176
|
-
- graph/node identity fields
|
|
177
|
-
- start/end/duration, status transitions
|
|
178
|
-
- success metadata and error details
|
|
179
|
-
|
|
180
|
-
## Stale cleanup
|
|
181
|
-
|
|
182
|
-
Use stale-marking (for example periodic `markStaleRecords`) to convert stuck `started` records to `timeout`.
|
|
183
|
-
|
|
184
|
-
## Related
|
|
185
|
-
|
|
186
|
-
- `README.md` (Activix section)
|
|
187
|
-
- `documenations/run-task-execution-flow.md`
|