ai-runtime-engine 2.7.0 → 2.9.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/CHANGELOG.md +108 -0
- package/dist/agents/roles.d.ts +36 -0
- package/dist/agents/roles.js +44 -0
- package/dist/agents/synthesize.d.ts +44 -0
- package/dist/agents/synthesize.js +60 -0
- package/dist/agents/task.d.ts +95 -6
- package/dist/agents/task.js +40 -2
- package/dist/agents/worker.d.ts +32 -1
- package/dist/agents/worker.js +150 -19
- package/dist/cli/cli.js +1 -1
- package/dist/cli/interactive/lanes.d.ts +69 -0
- package/dist/cli/interactive/lanes.js +181 -0
- package/dist/cli/interactive/repl.js +52 -0
- package/dist/cli/interactive/session.d.ts +8 -1
- package/dist/cli/interactive/session.js +62 -10
- package/dist/executions/agentTasks.d.ts +628 -0
- package/dist/executions/agentTasks.js +149 -0
- package/dist/executions/checkpoint.d.ts +5 -1
- package/dist/executions/checkpoint.js +13 -1
- package/dist/executions/execution.d.ts +23 -0
- package/dist/executions/store.d.ts +37 -0
- package/dist/executions/store.js +33 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -0
- package/dist/orchestration/executor.d.ts +26 -1
- package/dist/orchestration/executor.js +50 -9
- package/dist/orchestration/orchestrator.d.ts +6 -0
- package/dist/orchestration/orchestrator.js +18 -1
- package/dist/runtime/events.d.ts +44 -0
- package/dist/runtime/events.js +4 -0
- package/dist/runtime/runtime.d.ts +90 -0
- package/dist/runtime/runtime.js +510 -20
- package/dist/security/redact.js +22 -10
- package/dist/util/hash.d.ts +19 -0
- package/dist/util/hash.js +39 -0
- package/package.json +1 -1
package/dist/security/redact.js
CHANGED
|
@@ -37,21 +37,33 @@ export function redactString(input) {
|
|
|
37
37
|
}
|
|
38
38
|
/** Deep-redact any value, returning a scrubbed clone. Non-plain objects are stringified defensively. */
|
|
39
39
|
export function redact(value) {
|
|
40
|
-
return redactValue(value, new
|
|
40
|
+
return redactValue(value, new Set());
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The `ancestors` set holds the objects on the CURRENT PATH, and each is removed on the way back out.
|
|
44
|
+
* A global visited-set would be wrong: it cannot tell a cycle from a DAG, so the second appearance of a
|
|
45
|
+
* merely SHARED object becomes the string `'[circular]'`. That is not cosmetic — a shared array turning
|
|
46
|
+
* into a string changes the shape of redacted data, and anything that then validates it (the persisted
|
|
47
|
+
* agent-task schema does) rejects the whole record. Only a genuine cycle reports `[circular]`.
|
|
48
|
+
*/
|
|
49
|
+
function redactValue(value, ancestors) {
|
|
43
50
|
if (typeof value === 'string')
|
|
44
51
|
return redactString(value);
|
|
45
52
|
if (value === null || typeof value !== 'object')
|
|
46
53
|
return value;
|
|
47
|
-
if (
|
|
54
|
+
if (ancestors.has(value))
|
|
48
55
|
return '[circular]';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
ancestors.add(value);
|
|
57
|
+
try {
|
|
58
|
+
if (Array.isArray(value))
|
|
59
|
+
return value.map((v) => redactValue(v, ancestors));
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const [k, v] of Object.entries(value)) {
|
|
62
|
+
out[k] = redactValue(v, ancestors);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
ancestors.delete(value);
|
|
55
68
|
}
|
|
56
|
-
return out;
|
|
57
69
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One short content hash, shared by everything that needs to ask "is this the same thing it was?".
|
|
3
|
+
*
|
|
4
|
+
* Phase 3.5 resume decisions turn on identity comparisons — is this the same agent definition, the same
|
|
5
|
+
* narrowed envelope, the same step input, the same MCP tool declaration — and each of those was about to
|
|
6
|
+
* grow its own hashing. They must agree, so there is exactly one implementation and one canonical JSON
|
|
7
|
+
* form: keys sorted at every depth, so `{a,b}` and `{b,a}` are the same object, which is the whole point
|
|
8
|
+
* when the thing being hashed came back from `JSON.parse`.
|
|
9
|
+
*/
|
|
10
|
+
/** 16 hex chars — the same width `checkpoint.ts` uses for file hashes. Identity, never security. */
|
|
11
|
+
export declare function hash16(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Stable JSON: object keys sorted at every depth, `undefined` dropped. Arrays keep their order (order is
|
|
14
|
+
* meaning in a plan's steps). Cycles are impossible in the persisted shapes this serves, and a stray one
|
|
15
|
+
* throws rather than hashing something arbitrary.
|
|
16
|
+
*/
|
|
17
|
+
export declare function canonicalJson(value: unknown): string;
|
|
18
|
+
/** `hash16(canonicalJson(value))` — the form every identity check in Phase 3.5 uses. */
|
|
19
|
+
export declare function hashOf(value: unknown): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One short content hash, shared by everything that needs to ask "is this the same thing it was?".
|
|
3
|
+
*
|
|
4
|
+
* Phase 3.5 resume decisions turn on identity comparisons — is this the same agent definition, the same
|
|
5
|
+
* narrowed envelope, the same step input, the same MCP tool declaration — and each of those was about to
|
|
6
|
+
* grow its own hashing. They must agree, so there is exactly one implementation and one canonical JSON
|
|
7
|
+
* form: keys sorted at every depth, so `{a,b}` and `{b,a}` are the same object, which is the whole point
|
|
8
|
+
* when the thing being hashed came back from `JSON.parse`.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
11
|
+
/** 16 hex chars — the same width `checkpoint.ts` uses for file hashes. Identity, never security. */
|
|
12
|
+
export function hash16(text) {
|
|
13
|
+
return createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Stable JSON: object keys sorted at every depth, `undefined` dropped. Arrays keep their order (order is
|
|
17
|
+
* meaning in a plan's steps). Cycles are impossible in the persisted shapes this serves, and a stray one
|
|
18
|
+
* throws rather than hashing something arbitrary.
|
|
19
|
+
*/
|
|
20
|
+
export function canonicalJson(value) {
|
|
21
|
+
const walk = (v) => {
|
|
22
|
+
if (v === null || typeof v !== 'object')
|
|
23
|
+
return v;
|
|
24
|
+
if (Array.isArray(v))
|
|
25
|
+
return v.map(walk);
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const k of Object.keys(v).sort()) {
|
|
28
|
+
const child = v[k];
|
|
29
|
+
if (child !== undefined)
|
|
30
|
+
out[k] = walk(child);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
};
|
|
34
|
+
return JSON.stringify(walk(value)) ?? 'null';
|
|
35
|
+
}
|
|
36
|
+
/** `hash16(canonicalJson(value))` — the form every identity check in Phase 3.5 uses. */
|
|
37
|
+
export function hashOf(value) {
|
|
38
|
+
return hash16(canonicalJson(value));
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-runtime-engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "AI Runtime \u2014 a provider-agnostic AI runtime and orchestration platform. Point it at whatever AI providers you have; it routes each task to the best available model. Ships the `ai-runtime` CLI and the `Runtime`/`AI` library API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "ISC",
|