@zelari/core 2.4.0 → 2.6.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/dist/core/AgentHarness.d.ts +27 -0
- package/dist/core/AgentHarness.d.ts.map +1 -1
- package/dist/core/AgentHarness.js +43 -0
- package/dist/core/AgentHarness.js.map +1 -1
- package/dist/mission/budgetContinuation.d.ts +36 -0
- package/dist/mission/budgetContinuation.d.ts.map +1 -0
- package/dist/mission/budgetContinuation.js +66 -0
- package/dist/mission/budgetContinuation.js.map +1 -0
- package/dist/runtime/harnessManifest.d.ts +91 -0
- package/dist/runtime/harnessManifest.d.ts.map +1 -0
- package/dist/runtime/harnessManifest.js +113 -0
- package/dist/runtime/harnessManifest.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +4 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/profiles.d.ts +7 -0
- package/dist/runtime/profiles.d.ts.map +1 -1
- package/dist/runtime/profiles.js +10 -0
- package/dist/runtime/profiles.js.map +1 -1
- package/dist/runtime/resourceBudget.d.ts +69 -0
- package/dist/runtime/resourceBudget.d.ts.map +1 -0
- package/dist/runtime/resourceBudget.js +98 -0
- package/dist/runtime/resourceBudget.js.map +1 -0
- package/dist/runtime/resourcePolicy.d.ts +56 -0
- package/dist/runtime/resourcePolicy.d.ts.map +1 -0
- package/dist/runtime/resourcePolicy.js +77 -0
- package/dist/runtime/resourcePolicy.js.map +1 -0
- package/dist/session/agentAdapter.d.ts +2 -2
- package/dist/session/agentAdapter.d.ts.map +1 -1
- package/dist/session/agentAdapter.js +10 -2
- package/dist/session/agentAdapter.js.map +1 -1
- package/dist/session/compaction.d.ts +36 -0
- package/dist/session/compaction.d.ts.map +1 -0
- package/dist/session/compaction.js +120 -0
- package/dist/session/compaction.js.map +1 -0
- package/dist/session/compactionState.d.ts +50 -0
- package/dist/session/compactionState.d.ts.map +1 -0
- package/dist/session/compactionState.js +243 -0
- package/dist/session/compactionState.js.map +1 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -0
- package/dist/session/index.js.map +1 -1
- package/dist/session/invariants.d.ts +5 -0
- package/dist/session/invariants.d.ts.map +1 -1
- package/dist/session/invariants.js +152 -0
- package/dist/session/invariants.js.map +1 -1
- package/dist/session/modelSurface.d.ts +33 -4
- package/dist/session/modelSurface.d.ts.map +1 -1
- package/dist/session/modelSurface.js +98 -4
- package/dist/session/modelSurface.js.map +1 -1
- package/dist/session/taskContract.d.ts +104 -0
- package/dist/session/taskContract.d.ts.map +1 -0
- package/dist/session/taskContract.js +129 -0
- package/dist/session/taskContract.js.map +1 -0
- package/dist/session/types.d.ts +9 -1
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session/types.js +17 -0
- package/dist/session/types.js.map +1 -1
- package/dist/shared/events.d.ts +27 -0
- package/dist/shared/events.d.ts.map +1 -1
- package/dist/shared/events.js.map +1 -1
- package/dist/verification/index.d.ts +1 -0
- package/dist/verification/index.d.ts.map +1 -1
- package/dist/verification/index.js +1 -0
- package/dist/verification/index.js.map +1 -1
- package/dist/verification/metrics.d.ts +20 -0
- package/dist/verification/metrics.d.ts.map +1 -1
- package/dist/verification/metrics.js +18 -0
- package/dist/verification/metrics.js.map +1 -1
- package/dist/verification/resourceReserveGate.d.ts +39 -0
- package/dist/verification/resourceReserveGate.d.ts.map +1 -0
- package/dist/verification/resourceReserveGate.js +56 -0
- package/dist/verification/resourceReserveGate.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime/harnessManifest.ts — canonical harness fingerprint (2.6 Track A, doc §6).
|
|
3
|
+
*
|
|
4
|
+
* The effective behaviour of Zelari depends on more than model+profile:
|
|
5
|
+
* prompts, tool descriptions, skills, routing, verification/completion/
|
|
6
|
+
* compaction/resource policies. Two runs with the same model can be
|
|
7
|
+
* semantically different. The manifest captures that behaviour as a
|
|
8
|
+
* canonical, versioned, hashable object:
|
|
9
|
+
*
|
|
10
|
+
* - behavioural fields carry HASHES, never raw text (stable size, no
|
|
11
|
+
* prompt content leakage into eval reports);
|
|
12
|
+
* - hashing reuses `stableStringify`/`sha256Hex` from requestSnapshot
|
|
13
|
+
* (AGENTS.MD: zero deps; one canonical serializer);
|
|
14
|
+
* - no timestamps, no per-run volatile values — same harness build →
|
|
15
|
+
* same hash (§6.4). Runtime versions are per-build constants and are
|
|
16
|
+
* included on purpose: a release bump IS a harness candidate.
|
|
17
|
+
*
|
|
18
|
+
* Session integration: one state-only `session.harness_manifest` event per
|
|
19
|
+
* session start (payload {manifest, manifestHash}) — never model-surface.
|
|
20
|
+
*/
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { sha256Hex, stableStringify } from '../core/requestSnapshot.js';
|
|
23
|
+
export const HARNESS_MANIFEST_SCHEMA_VERSION = 1;
|
|
24
|
+
/** Hashes of the effective prompts (raw text never enters the manifest). */
|
|
25
|
+
export const HarnessPromptsSchema = z.object({
|
|
26
|
+
kraken: z.string().min(1).optional(),
|
|
27
|
+
gauntlet: z.string().min(1).optional(),
|
|
28
|
+
council: z.string().min(1).optional(),
|
|
29
|
+
mission: z.string().min(1).optional(),
|
|
30
|
+
});
|
|
31
|
+
export const HarnessManifestV1Schema = z.object({
|
|
32
|
+
schemaVersion: z.literal(HARNESS_MANIFEST_SCHEMA_VERSION),
|
|
33
|
+
profile: z.object({
|
|
34
|
+
id: z.string().min(1),
|
|
35
|
+
/** WorkPhase of the session that recorded the manifest. */
|
|
36
|
+
phase: z.enum(['plan', 'build']),
|
|
37
|
+
/** Hash of the full profile (see profileHash in profiles.ts). */
|
|
38
|
+
hash: z.string().min(1),
|
|
39
|
+
}),
|
|
40
|
+
prompts: HarnessPromptsSchema,
|
|
41
|
+
capabilities: z.object({
|
|
42
|
+
toolManifestHash: z.string().min(1),
|
|
43
|
+
skillManifestHash: z.string().min(1),
|
|
44
|
+
}),
|
|
45
|
+
policies: z.object({
|
|
46
|
+
routingHash: z.string().min(1),
|
|
47
|
+
verificationHash: z.string().min(1),
|
|
48
|
+
completionPolicyHash: z.string().min(1),
|
|
49
|
+
compactionHash: z.string().min(1),
|
|
50
|
+
/** Behavioural since 2.6 Track B: budget policy shapes execution. */
|
|
51
|
+
resourcePolicyHash: z.string().min(1),
|
|
52
|
+
}),
|
|
53
|
+
runtime: z.object({
|
|
54
|
+
coreVersion: z.string().min(1),
|
|
55
|
+
cliVersion: z.string().min(1),
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* Deterministic manifest hash: canonical serialization (keys sorted
|
|
60
|
+
* recursively), no timestamps. Same harness build → same hash.
|
|
61
|
+
*/
|
|
62
|
+
export function hashHarnessManifest(manifest) {
|
|
63
|
+
return sha256Hex(stableStringify(manifest));
|
|
64
|
+
}
|
|
65
|
+
/** Hash any behavioural input (prompt text, policy object) canonically. */
|
|
66
|
+
export function harnessInputHash(value) {
|
|
67
|
+
return sha256Hex(stableStringify(value));
|
|
68
|
+
}
|
|
69
|
+
function collectPaths(base, a, b, out, depth = 0) {
|
|
70
|
+
if (depth > 6)
|
|
71
|
+
return;
|
|
72
|
+
if (stableStringify(a) === stableStringify(b))
|
|
73
|
+
return;
|
|
74
|
+
const objA = a && typeof a === 'object' && !Array.isArray(a) ? a : null;
|
|
75
|
+
const objB = b && typeof b === 'object' && !Array.isArray(b) ? b : null;
|
|
76
|
+
if (objA && objB) {
|
|
77
|
+
for (const key of [...new Set([...Object.keys(objA), ...Object.keys(objB)])].sort()) {
|
|
78
|
+
collectPaths(base ? `${base}.${key}` : key, objA[key], objB[key], out, depth + 1);
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
out.push(base);
|
|
83
|
+
}
|
|
84
|
+
/** Diff two manifests into sorted dotted paths (e.g. `prompts.kraken`). */
|
|
85
|
+
export function diffHarnessManifest(oldManifest, newManifest) {
|
|
86
|
+
const changed = [];
|
|
87
|
+
collectPaths('', oldManifest, newManifest, changed);
|
|
88
|
+
return { changed: changed.sort() };
|
|
89
|
+
}
|
|
90
|
+
const FIELD_CLASSES = [
|
|
91
|
+
{ prefix: 'prompts', cls: 'behavioral' },
|
|
92
|
+
{ prefix: 'capabilities.toolManifestHash', cls: 'behavioral' },
|
|
93
|
+
{ prefix: 'capabilities.skillManifestHash', cls: 'behavioral' },
|
|
94
|
+
{ prefix: 'policies.routingHash', cls: 'behavioral' },
|
|
95
|
+
{ prefix: 'policies.verificationHash', cls: 'behavioral' },
|
|
96
|
+
{ prefix: 'policies.completionPolicyHash', cls: 'structural' },
|
|
97
|
+
{ prefix: 'policies.compactionHash', cls: 'behavioral' },
|
|
98
|
+
{ prefix: 'policies.resourcePolicyHash', cls: 'behavioral' },
|
|
99
|
+
{ prefix: 'profile', cls: 'structural' },
|
|
100
|
+
{ prefix: 'runtime', cls: 'structural' },
|
|
101
|
+
{ prefix: 'schemaVersion', cls: 'structural' },
|
|
102
|
+
];
|
|
103
|
+
export function classifyHarnessChanges(diff) {
|
|
104
|
+
const byField = {};
|
|
105
|
+
for (const field of diff.changed) {
|
|
106
|
+
const hit = FIELD_CLASSES.find((m) => field === m.prefix || field.startsWith(m.prefix + '.'));
|
|
107
|
+
byField[field] = hit ? hit.cls : 'cosmetic';
|
|
108
|
+
}
|
|
109
|
+
const order = { behavioral: 3, structural: 2, cosmetic: 1 };
|
|
110
|
+
const overall = Object.values(byField).reduce((acc, cls) => (order[cls] > order[acc] ? cls : acc), 'cosmetic');
|
|
111
|
+
return { overall, byField };
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=harnessManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harnessManifest.js","sourceRoot":"","sources":["../../src/runtime/harnessManifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EA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K,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EACnD,UAAU,CACX,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zelari/core/runtime
|
|
2
|
+
* @zelari/core/runtime - execution seams + profiles (ADR-0022) + harness manifest (2.6).
|
|
3
3
|
*/
|
|
4
4
|
export * from './providers.js';
|
|
5
5
|
export * from './nodeProviders.js';
|
|
6
6
|
export * from './memoryProviders.js';
|
|
7
7
|
export * from './worktreeWorkspace.js';
|
|
8
8
|
export * from './profiles.js';
|
|
9
|
+
export * from './harnessManifest.js';
|
|
9
10
|
export * from './executionContext.js';
|
|
11
|
+
export * from './resourcePolicy.js';
|
|
12
|
+
export * from './resourceBudget.js';
|
|
10
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zelari/core/runtime
|
|
2
|
+
* @zelari/core/runtime - execution seams + profiles (ADR-0022) + harness manifest (2.6).
|
|
3
3
|
*/
|
|
4
4
|
export * from './providers.js';
|
|
5
5
|
export * from './nodeProviders.js';
|
|
6
6
|
export * from './memoryProviders.js';
|
|
7
7
|
export * from './worktreeWorkspace.js';
|
|
8
8
|
export * from './profiles.js';
|
|
9
|
+
export * from './harnessManifest.js';
|
|
9
10
|
export * from './executionContext.js';
|
|
11
|
+
export * from './resourcePolicy.js';
|
|
12
|
+
export * from './resourceBudget.js';
|
|
10
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
|
@@ -41,4 +41,11 @@ export declare class UnknownProfileError extends Error {
|
|
|
41
41
|
export declare function resolveProfile(id: string): Profile;
|
|
42
42
|
/** sha256 of the sorted tool names — recorded in the session header. */
|
|
43
43
|
export declare function toolManifestHash(tools: readonly string[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Stable hash of the FULL profile (capability set + orchestration mounts +
|
|
46
|
+
* verification flags) — the `profile.hash` field of the harness manifest
|
|
47
|
+
* (2.6 Track A). Uses the shared canonical serializer (requestSnapshot) so
|
|
48
|
+
* key order can never flip the hash.
|
|
49
|
+
*/
|
|
50
|
+
export declare function profileHash(profile: Profile): string;
|
|
44
51
|
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/runtime/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/runtime/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;iBAiBxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,aAAa,2EAA4E,CAAC;AAEvG,eAAO,MAAM,UAAU,EAAE,OAOvB,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,OAOtB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,OAOvB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,OAOvB,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAK9D,CAAC;AAEH,qBAAa,mBAAoB,SAAQ,KAAK;aAG1B,SAAS,EAAE,MAAM;aACjB,KAAK,EAAE,MAAM,EAAE;IAHjC,QAAQ,CAAC,IAAI,qBAAqB;gBAEhB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EAAE;CAKlC;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAIlD;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAEpD"}
|
package/dist/runtime/profiles.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { createHash } from 'node:crypto';
|
|
10
10
|
import { z } from 'zod';
|
|
11
|
+
import { stableStringify } from '../core/requestSnapshot.js';
|
|
11
12
|
export const ProfileSchema = z.object({
|
|
12
13
|
/** `<name>/v<N>` — immutable once published. */
|
|
13
14
|
id: z.string().regex(/^[a-z0-9-]+\/v\d+$/, 'profile id must be <name>/v<N>'),
|
|
@@ -88,4 +89,13 @@ export function toolManifestHash(tools) {
|
|
|
88
89
|
const manifest = [...tools].sort().join(',');
|
|
89
90
|
return createHash('sha256').update(manifest).digest('hex');
|
|
90
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Stable hash of the FULL profile (capability set + orchestration mounts +
|
|
94
|
+
* verification flags) — the `profile.hash` field of the harness manifest
|
|
95
|
+
* (2.6 Track A). Uses the shared canonical serializer (requestSnapshot) so
|
|
96
|
+
* key order can never flip the hash.
|
|
97
|
+
*/
|
|
98
|
+
export function profileHash(profile) {
|
|
99
|
+
return createHash('sha256').update(stableStringify(profile)).digest('hex');
|
|
100
|
+
}
|
|
91
101
|
//# sourceMappingURL=profiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/runtime/profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
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AE,MAAM,IAAI,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAChF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,gBAAgB,CAAC,KAAwB;IACvD,MAAM,QAAQ,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime/resourceBudget.ts — central resource budget projection (2.6 Track B,
|
|
3
|
+
* doc §9). PURE functions: the host owns enforcement; nothing here talks to
|
|
4
|
+
* the model or mutates state. Budget state is reconstructible from the
|
|
5
|
+
* session log (ResourceLedger on the CLI side counts `tool.call` events).
|
|
6
|
+
*
|
|
7
|
+
* Invariants (§9.5): used <= limit, remaining = limit - used, reserves >= 0.
|
|
8
|
+
*/
|
|
9
|
+
import type { BudgetPressure, ResourcePolicy, ResourceStage } from './resourcePolicy.js';
|
|
10
|
+
export interface ResourceBudget {
|
|
11
|
+
toolCalls: {
|
|
12
|
+
limit: number;
|
|
13
|
+
used: number;
|
|
14
|
+
remaining: number;
|
|
15
|
+
};
|
|
16
|
+
wallTime: {
|
|
17
|
+
limitMs?: number;
|
|
18
|
+
elapsedMs: number;
|
|
19
|
+
remainingMs?: number;
|
|
20
|
+
};
|
|
21
|
+
tokens?: {
|
|
22
|
+
softLimit?: number;
|
|
23
|
+
used: number;
|
|
24
|
+
remaining?: number;
|
|
25
|
+
};
|
|
26
|
+
reserve: {
|
|
27
|
+
verification: number;
|
|
28
|
+
repair: number;
|
|
29
|
+
};
|
|
30
|
+
stage: ResourceStage;
|
|
31
|
+
}
|
|
32
|
+
export type ResourceLedgerReason = 'tool-call' | 'model-turn' | 'verification' | 'repair' | 'timeout' | 'reservation';
|
|
33
|
+
/** Host-owned ledger entry (append-only; rebuilt from session events on resume). */
|
|
34
|
+
export interface ResourceLedgerEntry {
|
|
35
|
+
seq: number;
|
|
36
|
+
reason: ResourceLedgerReason;
|
|
37
|
+
delta: {
|
|
38
|
+
toolCalls?: number;
|
|
39
|
+
tokens?: number;
|
|
40
|
+
wallMs?: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Compute the budget projection from a policy and cumulative usage. Pure. */
|
|
44
|
+
export declare function computeBudget(policy: ResourcePolicy, usage: {
|
|
45
|
+
toolCallsUsed: number;
|
|
46
|
+
elapsedMs?: number;
|
|
47
|
+
tokensUsed?: number;
|
|
48
|
+
}, stage?: ResourceStage): ResourceBudget;
|
|
49
|
+
/** Reduce the ledger to cumulative usage. Pure; double entries count once by seq. */
|
|
50
|
+
export declare function usageFromLedger(entries: readonly ResourceLedgerEntry[]): {
|
|
51
|
+
toolCallsUsed: number;
|
|
52
|
+
wallMs: number;
|
|
53
|
+
tokensUsed: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Pressure band (§12): usable = remaining - verificationReserve floor.
|
|
57
|
+
* critical < thresholds.critical <= constrained < thresholds.ample <= ample.
|
|
58
|
+
*/
|
|
59
|
+
export declare function budgetPressure(budget: ResourceBudget, policy: ResourcePolicy): BudgetPressure;
|
|
60
|
+
/**
|
|
61
|
+
* Protected verification reserve (§11.3): when true, only the verify/repair
|
|
62
|
+
* tool set may spend — the host enforces, this is the predicate.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isVerificationReserveProtected(budget: ResourceBudget): boolean;
|
|
65
|
+
/** Can the run still afford `calls` outside the protected reserve? */
|
|
66
|
+
export declare function canSpendOutsideReserve(budget: ResourceBudget, calls: number): boolean;
|
|
67
|
+
/** Map an event stream reason onto the ledger delta (single counting point). */
|
|
68
|
+
export declare function ledgerDeltaFor(reason: ResourceLedgerReason, calls?: number): ResourceLedgerEntry['delta'];
|
|
69
|
+
//# sourceMappingURL=resourceBudget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceBudget.d.ts","sourceRoot":"","sources":["../../src/runtime/resourceBudget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzF,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,MAAM,oBAAoB,GAC5B,WAAW,GACX,YAAY,GACZ,cAAc,GACd,QAAQ,GACR,SAAS,GACT,aAAa,CAAC;AAElB,oFAAoF;AACpF,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,oBAAoB,CAAC;IAC7B,KAAK,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE;IACL,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,EACD,KAAK,GAAE,aAAyB,GAC/B,cAAc,CA8BhB;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,GAAG;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAaA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,cAAc,CAS7F;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE9E;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAErF;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,EAAE,KAAK,SAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAapG"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime/resourceBudget.ts — central resource budget projection (2.6 Track B,
|
|
3
|
+
* doc §9). PURE functions: the host owns enforcement; nothing here talks to
|
|
4
|
+
* the model or mutates state. Budget state is reconstructible from the
|
|
5
|
+
* session log (ResourceLedger on the CLI side counts `tool.call` events).
|
|
6
|
+
*
|
|
7
|
+
* Invariants (§9.5): used <= limit, remaining = limit - used, reserves >= 0.
|
|
8
|
+
*/
|
|
9
|
+
/** Compute the budget projection from a policy and cumulative usage. Pure. */
|
|
10
|
+
export function computeBudget(policy, usage, stage = 'explore') {
|
|
11
|
+
const used = Math.max(0, Math.min(usage.toolCallsUsed, policy.maxToolCalls));
|
|
12
|
+
return {
|
|
13
|
+
toolCalls: {
|
|
14
|
+
limit: policy.maxToolCalls,
|
|
15
|
+
used,
|
|
16
|
+
remaining: policy.maxToolCalls - used,
|
|
17
|
+
},
|
|
18
|
+
wallTime: {
|
|
19
|
+
limitMs: policy.wallClockMs,
|
|
20
|
+
elapsedMs: Math.max(0, usage.elapsedMs ?? 0),
|
|
21
|
+
remainingMs: policy.wallClockMs === undefined ? undefined : Math.max(0, policy.wallClockMs - (usage.elapsedMs ?? 0)),
|
|
22
|
+
},
|
|
23
|
+
tokens: usage.tokensUsed === undefined && policy.softMaxTokens === undefined
|
|
24
|
+
? undefined
|
|
25
|
+
: {
|
|
26
|
+
softLimit: policy.softMaxTokens,
|
|
27
|
+
used: usage.tokensUsed ?? 0,
|
|
28
|
+
remaining: policy.softMaxTokens === undefined
|
|
29
|
+
? undefined
|
|
30
|
+
: Math.max(0, policy.softMaxTokens - (usage.tokensUsed ?? 0)),
|
|
31
|
+
},
|
|
32
|
+
reserve: {
|
|
33
|
+
verification: Math.max(0, policy.reserve.verification),
|
|
34
|
+
repair: Math.max(0, policy.reserve.repair),
|
|
35
|
+
},
|
|
36
|
+
stage,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Reduce the ledger to cumulative usage. Pure; double entries count once by seq. */
|
|
40
|
+
export function usageFromLedger(entries) {
|
|
41
|
+
const seen = new Set();
|
|
42
|
+
let toolCallsUsed = 0;
|
|
43
|
+
let wallMs = 0;
|
|
44
|
+
let tokensUsed = 0;
|
|
45
|
+
for (const e of entries) {
|
|
46
|
+
if (seen.has(e.seq))
|
|
47
|
+
continue; // idempotent replay
|
|
48
|
+
seen.add(e.seq);
|
|
49
|
+
toolCallsUsed += e.delta.toolCalls ?? 0;
|
|
50
|
+
wallMs += e.delta.wallMs ?? 0;
|
|
51
|
+
tokensUsed += e.delta.tokens ?? 0;
|
|
52
|
+
}
|
|
53
|
+
return { toolCallsUsed: Math.max(0, toolCallsUsed), wallMs: Math.max(0, wallMs), tokensUsed: Math.max(0, tokensUsed) };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Pressure band (§12): usable = remaining - verificationReserve floor.
|
|
57
|
+
* critical < thresholds.critical <= constrained < thresholds.ample <= ample.
|
|
58
|
+
*/
|
|
59
|
+
export function budgetPressure(budget, policy) {
|
|
60
|
+
const usable = Math.max(0, budget.toolCalls.remaining - budget.reserve.verification);
|
|
61
|
+
const capacity = Math.max(1, budget.toolCalls.limit - budget.reserve.verification);
|
|
62
|
+
const ratio = usable / capacity;
|
|
63
|
+
const t = policy.pressure;
|
|
64
|
+
if (ratio >= t.ample)
|
|
65
|
+
return 'ample';
|
|
66
|
+
if (ratio >= t.constrained)
|
|
67
|
+
return 'normal';
|
|
68
|
+
if (ratio >= t.critical)
|
|
69
|
+
return 'constrained';
|
|
70
|
+
return 'critical';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Protected verification reserve (§11.3): when true, only the verify/repair
|
|
74
|
+
* tool set may spend — the host enforces, this is the predicate.
|
|
75
|
+
*/
|
|
76
|
+
export function isVerificationReserveProtected(budget) {
|
|
77
|
+
return budget.toolCalls.remaining <= budget.reserve.verification;
|
|
78
|
+
}
|
|
79
|
+
/** Can the run still afford `calls` outside the protected reserve? */
|
|
80
|
+
export function canSpendOutsideReserve(budget, calls) {
|
|
81
|
+
return budget.toolCalls.remaining - budget.reserve.verification >= calls;
|
|
82
|
+
}
|
|
83
|
+
/** Map an event stream reason onto the ledger delta (single counting point). */
|
|
84
|
+
export function ledgerDeltaFor(reason, calls = 1) {
|
|
85
|
+
switch (reason) {
|
|
86
|
+
case 'tool-call':
|
|
87
|
+
return { toolCalls: calls };
|
|
88
|
+
case 'model-turn':
|
|
89
|
+
case 'verification':
|
|
90
|
+
case 'repair':
|
|
91
|
+
return { toolCalls: calls };
|
|
92
|
+
case 'timeout':
|
|
93
|
+
return {};
|
|
94
|
+
case 'reservation':
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=resourceBudget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceBudget.js","sourceRoot":"","sources":["../../src/runtime/resourceBudget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA8CH,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAC3B,MAAsB,EACtB,KAIC,EACD,QAAuB,SAAS;IAEhC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAC7E,OAAO;QACL,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,YAAY;YAC1B,IAAI;YACJ,SAAS,EAAE,MAAM,CAAC,YAAY,GAAG,IAAI;SACtC;QACD,QAAQ,EAAE;YACR,OAAO,EAAE,MAAM,CAAC,WAAW;YAC3B,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;YAC5C,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;SACrH;QACD,MAAM,EACJ,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS;YAClE,CAAC,CAAC,SAAS;YACX,CAAC,CAAC;gBACE,SAAS,EAAE,MAAM,CAAC,aAAa;gBAC/B,IAAI,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O,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,KAAK,YAAY,CAAC;QAClB,KAAK,cAAc,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,KAAK,SAAS;YACZ,OAAO,EAAE,CAAC;QACZ,KAAK,aAAa;YAChB,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime/resourcePolicy.ts — host-owned resource policy (2.6 Track B, doc §11-12).
|
|
3
|
+
*
|
|
4
|
+
* The policy is BEHAVIOURAL: it shapes how the agent spends its remaining
|
|
5
|
+
* budget, so its hash feeds the harness manifest (§6.6). Enforcement stays
|
|
6
|
+
* host-side; the model only ever sees a projection (doc §9.2).
|
|
7
|
+
*
|
|
8
|
+
* Pressure thresholds are policy-configurable, NOT copied from other
|
|
9
|
+
* domains (§12.3): defaults below are first-guess values to be replaced by
|
|
10
|
+
* Zelari's own benchmark data.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
export declare const BudgetPressureSchema: z.ZodEnum<{
|
|
14
|
+
critical: "critical";
|
|
15
|
+
ample: "ample";
|
|
16
|
+
normal: "normal";
|
|
17
|
+
constrained: "constrained";
|
|
18
|
+
}>;
|
|
19
|
+
export type BudgetPressure = z.infer<typeof BudgetPressureSchema>;
|
|
20
|
+
/** Operational stage of the run — deliberately NOT named `phase` (WorkPhase collision). */
|
|
21
|
+
export declare const ResourceStageSchema: z.ZodEnum<{
|
|
22
|
+
explore: "explore";
|
|
23
|
+
verify: "verify";
|
|
24
|
+
implement: "implement";
|
|
25
|
+
repair: "repair";
|
|
26
|
+
}>;
|
|
27
|
+
export type ResourceStage = z.infer<typeof ResourceStageSchema>;
|
|
28
|
+
/** Fractions of (limit - reserve floor) at which pressure bands change. */
|
|
29
|
+
export declare const PressureThresholdsSchema: z.ZodObject<{
|
|
30
|
+
ample: z.ZodNumber;
|
|
31
|
+
constrained: z.ZodNumber;
|
|
32
|
+
critical: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type PressureThresholds = z.infer<typeof PressureThresholdsSchema>;
|
|
35
|
+
export declare const DEFAULT_PRESSURE_THRESHOLDS: PressureThresholds;
|
|
36
|
+
export declare const ResourcePolicySchema: z.ZodObject<{
|
|
37
|
+
maxToolCalls: z.ZodNumber;
|
|
38
|
+
reserve: z.ZodObject<{
|
|
39
|
+
verification: z.ZodNumber;
|
|
40
|
+
repair: z.ZodNumber;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
wallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
softMaxTokens: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
pressure: z.ZodDefault<z.ZodObject<{
|
|
45
|
+
ample: z.ZodNumber;
|
|
46
|
+
constrained: z.ZodNumber;
|
|
47
|
+
critical: z.ZodNumber;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type ResourcePolicy = z.infer<typeof ResourcePolicySchema>;
|
|
51
|
+
/** Default policies per profile (doc §11.2 kraken default 40/6/4/900000). */
|
|
52
|
+
export declare const PROFILE_RESOURCE_POLICIES: Readonly<Record<string, ResourcePolicy>>;
|
|
53
|
+
export declare function defaultResourcePolicy(profileId: string): ResourcePolicy;
|
|
54
|
+
/** Canonical behavioural hash — the manifest's `policies.resourcePolicyHash`. */
|
|
55
|
+
export declare function resourcePolicyHash(policy: ResourcePolicy): string;
|
|
56
|
+
//# sourceMappingURL=resourcePolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourcePolicy.d.ts","sourceRoot":"","sources":["../../src/runtime/resourcePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,oBAAoB;;;;;EAAyD,CAAC;AAC3F,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB;;;;;EAAuD,CAAC;AACxF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB;;;;iBAOnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,2BAA2B,EAAE,kBAIxC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;iBAY/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAuB7E,CAAC;AAEH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAEvE;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAEjE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* runtime/resourcePolicy.ts — host-owned resource policy (2.6 Track B, doc §11-12).
|
|
3
|
+
*
|
|
4
|
+
* The policy is BEHAVIOURAL: it shapes how the agent spends its remaining
|
|
5
|
+
* budget, so its hash feeds the harness manifest (§6.6). Enforcement stays
|
|
6
|
+
* host-side; the model only ever sees a projection (doc §9.2).
|
|
7
|
+
*
|
|
8
|
+
* Pressure thresholds are policy-configurable, NOT copied from other
|
|
9
|
+
* domains (§12.3): defaults below are first-guess values to be replaced by
|
|
10
|
+
* Zelari's own benchmark data.
|
|
11
|
+
*/
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { stableStringify } from '../core/requestSnapshot.js';
|
|
15
|
+
export const BudgetPressureSchema = z.enum(['ample', 'normal', 'constrained', 'critical']);
|
|
16
|
+
/** Operational stage of the run — deliberately NOT named `phase` (WorkPhase collision). */
|
|
17
|
+
export const ResourceStageSchema = z.enum(['explore', 'implement', 'verify', 'repair']);
|
|
18
|
+
/** Fractions of (limit - reserve floor) at which pressure bands change. */
|
|
19
|
+
export const PressureThresholdsSchema = z.object({
|
|
20
|
+
/** remaining/usable >= ample → ample. */
|
|
21
|
+
ample: z.number().min(0).max(1),
|
|
22
|
+
/** remaining/usable >= constrained → normal; below → constrained. */
|
|
23
|
+
constrained: z.number().min(0).max(1),
|
|
24
|
+
/** remaining/usable < critical → critical. */
|
|
25
|
+
critical: z.number().min(0).max(1),
|
|
26
|
+
});
|
|
27
|
+
export const DEFAULT_PRESSURE_THRESHOLDS = Object.freeze({
|
|
28
|
+
ample: 0.5,
|
|
29
|
+
constrained: 0.25,
|
|
30
|
+
critical: 0.1,
|
|
31
|
+
});
|
|
32
|
+
export const ResourcePolicySchema = z.object({
|
|
33
|
+
maxToolCalls: z.number().int().positive(),
|
|
34
|
+
reserve: z.object({
|
|
35
|
+
/** Protected: tool budget the non-verification loop may not consume (§11.4). */
|
|
36
|
+
verification: z.number().int().min(0),
|
|
37
|
+
/** Advisory-only by default (§11.4). */
|
|
38
|
+
repair: z.number().int().min(0),
|
|
39
|
+
}),
|
|
40
|
+
wallClockMs: z.number().int().positive().optional(),
|
|
41
|
+
/** Soft token ceiling (advisory telemetry, not enforced). */
|
|
42
|
+
softMaxTokens: z.number().int().positive().optional(),
|
|
43
|
+
pressure: PressureThresholdsSchema.default(DEFAULT_PRESSURE_THRESHOLDS),
|
|
44
|
+
});
|
|
45
|
+
/** Default policies per profile (doc §11.2 kraken default 40/6/4/900000). */
|
|
46
|
+
export const PROFILE_RESOURCE_POLICIES = Object.freeze({
|
|
47
|
+
'minimal/v1': {
|
|
48
|
+
maxToolCalls: 25,
|
|
49
|
+
reserve: { verification: 4, repair: 3 },
|
|
50
|
+
pressure: DEFAULT_PRESSURE_THRESHOLDS,
|
|
51
|
+
},
|
|
52
|
+
'kraken/v1': {
|
|
53
|
+
maxToolCalls: 40,
|
|
54
|
+
reserve: { verification: 6, repair: 4 },
|
|
55
|
+
wallClockMs: 900_000,
|
|
56
|
+
pressure: DEFAULT_PRESSURE_THRESHOLDS,
|
|
57
|
+
},
|
|
58
|
+
'council/v1': {
|
|
59
|
+
maxToolCalls: 30,
|
|
60
|
+
reserve: { verification: 4, repair: 2 },
|
|
61
|
+
pressure: DEFAULT_PRESSURE_THRESHOLDS,
|
|
62
|
+
},
|
|
63
|
+
'mission/v1': {
|
|
64
|
+
maxToolCalls: 60,
|
|
65
|
+
reserve: { verification: 8, repair: 6 },
|
|
66
|
+
wallClockMs: 1_800_000,
|
|
67
|
+
pressure: DEFAULT_PRESSURE_THRESHOLDS,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
export function defaultResourcePolicy(profileId) {
|
|
71
|
+
return PROFILE_RESOURCE_POLICIES[profileId] ?? PROFILE_RESOURCE_POLICIES['kraken/v1'];
|
|
72
|
+
}
|
|
73
|
+
/** Canonical behavioural hash — the manifest's `policies.resourcePolicyHash`. */
|
|
74
|
+
export function resourcePolicyHash(policy) {
|
|
75
|
+
return createHash('sha256').update(stableStringify(ResourcePolicySchema.parse(policy))).digest('hex');
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=resourcePolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourcePolicy.js","sourceRoot":"","sources":["../../src/runtime/resourcePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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WAAW,CAAE,CAAC;AACzF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxG,CAAC"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* history any other way — model-visible ⟺ logged.
|
|
9
9
|
*
|
|
10
10
|
* Field mapping (lossy by design, log keeps the full truth):
|
|
11
|
-
* - `seq`
|
|
12
|
-
*
|
|
11
|
+
* - `seq` is copied as optional provenance so hosts can persist compact
|
|
12
|
+
* ranges; providers never put it on the wire.
|
|
13
13
|
* - `toolName` / `isError` on tool results have no AgentMessage slot; the
|
|
14
14
|
* output text is already in `content`, the semantics stay in the log.
|
|
15
15
|
* - tool calls derived with `includeToolCalls: true` are JSON-encoded
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentAdapter.d.ts","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"agentAdapter.d.ts","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,YAAY,EAAE,CAYhB"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* history any other way — model-visible ⟺ logged.
|
|
9
9
|
*
|
|
10
10
|
* Field mapping (lossy by design, log keeps the full truth):
|
|
11
|
-
* - `seq`
|
|
12
|
-
*
|
|
11
|
+
* - `seq` is copied as optional provenance so hosts can persist compact
|
|
12
|
+
* ranges; providers never put it on the wire.
|
|
13
13
|
* - `toolName` / `isError` on tool results have no AgentMessage slot; the
|
|
14
14
|
* output text is already in `content`, the semantics stay in the log.
|
|
15
15
|
* - tool calls derived with `includeToolCalls: true` are JSON-encoded
|
|
@@ -31,6 +31,14 @@ export function derivedToAgentMessages(messages) {
|
|
|
31
31
|
const agent = { role: m.role, content: m.content };
|
|
32
32
|
if (m.toolCallId !== undefined)
|
|
33
33
|
agent.toolCallId = m.toolCallId;
|
|
34
|
+
if (m.seq !== undefined)
|
|
35
|
+
agent.seq = m.seq;
|
|
36
|
+
if (m.compactedFromSeq !== undefined)
|
|
37
|
+
agent.compactedFromSeq = m.compactedFromSeq;
|
|
38
|
+
if (m.compactedToSeq !== undefined)
|
|
39
|
+
agent.compactedToSeq = m.compactedToSeq;
|
|
40
|
+
if (m.sourceEventSeqs !== undefined)
|
|
41
|
+
agent.sourceEventSeqs = [...m.sourceEventSeqs];
|
|
34
42
|
out.push(agent);
|
|
35
43
|
}
|
|
36
44
|
return out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentAdapter.js","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAmC;IAEnC,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,KAAK,GAAiB,EAAE,IAAI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