@lesliechan721/agent-skill-eval 0.1.0-beta.1

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.
Files changed (50) hide show
  1. package/dist/bin.d.ts +2 -0
  2. package/dist/bin.js +80 -0
  3. package/dist/bin.js.map +1 -0
  4. package/dist/bundle.d.ts +93 -0
  5. package/dist/bundle.js +216 -0
  6. package/dist/bundle.js.map +1 -0
  7. package/dist/capabilities.d.ts +2 -0
  8. package/dist/capabilities.js +38 -0
  9. package/dist/capabilities.js.map +1 -0
  10. package/dist/common.d.ts +8 -0
  11. package/dist/common.js +22 -0
  12. package/dist/common.js.map +1 -0
  13. package/dist/corpus-digest.d.ts +3 -0
  14. package/dist/corpus-digest.js +19 -0
  15. package/dist/corpus-digest.js.map +1 -0
  16. package/dist/index.d.ts +16 -0
  17. package/dist/index.js +11 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/json-schema.d.ts +3 -0
  20. package/dist/json-schema.js +70 -0
  21. package/dist/json-schema.js.map +1 -0
  22. package/dist/output-path.d.ts +1 -0
  23. package/dist/output-path.js +34 -0
  24. package/dist/output-path.js.map +1 -0
  25. package/dist/plan.d.ts +79 -0
  26. package/dist/plan.js +285 -0
  27. package/dist/plan.js.map +1 -0
  28. package/dist/process-tree.d.ts +25 -0
  29. package/dist/process-tree.js +385 -0
  30. package/dist/process-tree.js.map +1 -0
  31. package/dist/process.d.ts +14 -0
  32. package/dist/process.js +301 -0
  33. package/dist/process.js.map +1 -0
  34. package/dist/run.d.ts +2 -0
  35. package/dist/run.js +592 -0
  36. package/dist/run.js.map +1 -0
  37. package/dist/runtime-skill.d.ts +18 -0
  38. package/dist/runtime-skill.js +135 -0
  39. package/dist/runtime-skill.js.map +1 -0
  40. package/dist/schemas/aw-skill-eval-execution-plan.schema.json +220 -0
  41. package/dist/schemas/digests.json +5 -0
  42. package/dist/schemas/eval-run-bundle.schema.json +408 -0
  43. package/dist/schemas/eval-runtime-capabilities.schema.json +85 -0
  44. package/dist/schemas.d.ts +5 -0
  45. package/dist/schemas.js +27 -0
  46. package/dist/schemas.js.map +1 -0
  47. package/dist/types.d.ts +86 -0
  48. package/dist/types.js +2 -0
  49. package/dist/types.js.map +1 -0
  50. package/package.json +34 -0
@@ -0,0 +1,70 @@
1
+ function matchesType(value, type) {
2
+ if (type === 'null')
3
+ return value === null;
4
+ if (type === 'array')
5
+ return Array.isArray(value);
6
+ if (type === 'object')
7
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
8
+ if (type === 'integer')
9
+ return Number.isInteger(value);
10
+ return typeof value === type;
11
+ }
12
+ function validateNode(schema, value, pointer, errors) {
13
+ if (schema.const !== undefined && !Object.is(value, schema.const))
14
+ errors.push(`${pointer}: must equal ${JSON.stringify(schema.const)}`);
15
+ if (Array.isArray(schema.enum) && !schema.enum.some((entry) => Object.is(entry, value)))
16
+ errors.push(`${pointer}: must be one of ${schema.enum.map((entry) => JSON.stringify(entry)).join(', ')}`);
17
+ const types = schema.type === undefined
18
+ ? []
19
+ : Array.isArray(schema.type)
20
+ ? schema.type
21
+ : [schema.type];
22
+ if (types.length > 0 && !types.some((type) => matchesType(value, type))) {
23
+ errors.push(`${pointer}: must have type ${types.join(' or ')}`);
24
+ return;
25
+ }
26
+ if (typeof value === 'string') {
27
+ if (typeof schema.minLength === 'number' && value.length < schema.minLength)
28
+ errors.push(`${pointer}: must have length >= ${schema.minLength}`);
29
+ if (typeof schema.pattern === 'string' && !new RegExp(schema.pattern, 'u').test(value))
30
+ errors.push(`${pointer}: must match ${schema.pattern}`);
31
+ }
32
+ if (typeof value === 'number') {
33
+ if (typeof schema.minimum === 'number' && value < schema.minimum)
34
+ errors.push(`${pointer}: must be >= ${schema.minimum}`);
35
+ if (typeof schema.maximum === 'number' && value > schema.maximum)
36
+ errors.push(`${pointer}: must be <= ${schema.maximum}`);
37
+ if (typeof schema.multipleOf === 'number' &&
38
+ Math.abs(value / schema.multipleOf - Math.round(value / schema.multipleOf)) > 1e-9)
39
+ errors.push(`${pointer}: must be a multiple of ${schema.multipleOf}`);
40
+ }
41
+ if (Array.isArray(value)) {
42
+ if (typeof schema.minItems === 'number' && value.length < schema.minItems)
43
+ errors.push(`${pointer}: must contain at least ${schema.minItems} items`);
44
+ if (schema.uniqueItems === true && new Set(value.map((entry) => JSON.stringify(entry))).size !== value.length)
45
+ errors.push(`${pointer}: must contain unique items`);
46
+ if (schema.items && typeof schema.items === 'object')
47
+ value.forEach((entry, index) => validateNode(schema.items, entry, `${pointer}/${index}`, errors));
48
+ }
49
+ if (matchesType(value, 'object')) {
50
+ const object = value;
51
+ for (const key of schema.required ?? [])
52
+ if (!Object.hasOwn(object, key))
53
+ errors.push(`${pointer}: missing required property ${key}`);
54
+ const properties = schema.properties;
55
+ for (const [key, entry] of Object.entries(object)) {
56
+ if (properties?.[key])
57
+ validateNode(properties[key], entry, `${pointer}/${key}`, errors);
58
+ else if (schema.additionalProperties === false)
59
+ errors.push(`${pointer}: unknown property ${key}`);
60
+ else if (schema.additionalProperties && typeof schema.additionalProperties === 'object')
61
+ validateNode(schema.additionalProperties, entry, `${pointer}/${key}`, errors);
62
+ }
63
+ }
64
+ }
65
+ export function validateJsonSchema(schema, value) {
66
+ const errors = [];
67
+ validateNode(schema, value, '$', errors);
68
+ return errors;
69
+ }
70
+ //# sourceMappingURL=json-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAEA,SAAS,WAAW,CAAC,KAAc,EAAE,IAAY;IAC/C,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,KAAK,KAAK,IAAI,CAAA;IAC1C,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACjD,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KA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AC,UAAoD,CAAA;QAC9E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC;gBAAE,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,IAAI,GAAG,EAAE,EAAE,MAAM,CAAC,CAAA;iBACnF,IAAI,MAAM,CAAC,oBAAoB,KAAK,KAAK;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,sBAAsB,GAAG,EAAE,CAAC,CAAA;iBAC7F,IAAI,MAAM,CAAC,oBAAoB,IAAI,OAAO,MAAM,CAAC,oBAAoB,KAAK,QAAQ;gBACrF,YAAY,CAAC,MAAM,CAAC,oBAAkC,EAAE,KAAK,EAAE,GAAG,OAAO,IAAI,GAAG,EAAE,EAAE,MAAM,CAAC,CAAA;QAC/F,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAkB,EAAE,KAAc;IACnE,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;IACxC,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function assertSafeOutputPath(base: string, target: string): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { lstat, realpath } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { isPathInside } from './common.js';
4
+ function isMissing(error) {
5
+ return error.code === 'ENOENT';
6
+ }
7
+ export async function assertSafeOutputPath(base, target) {
8
+ const canonicalBase = await realpath(base);
9
+ const resolvedTarget = path.resolve(canonicalBase, target);
10
+ if (!isPathInside(canonicalBase, resolvedTarget) || resolvedTarget === canonicalBase)
11
+ throw new Error('output path must be a non-root child inside the plan directory');
12
+ const relative = path.relative(canonicalBase, resolvedTarget);
13
+ let candidate = canonicalBase;
14
+ for (const segment of relative.split(path.sep)) {
15
+ candidate = path.join(candidate, segment);
16
+ let info;
17
+ try {
18
+ info = await lstat(candidate);
19
+ }
20
+ catch (error) {
21
+ if (isMissing(error))
22
+ return;
23
+ throw error;
24
+ }
25
+ if (info.isSymbolicLink())
26
+ throw new Error(`output path component cannot be a symlink: ${candidate}`);
27
+ if (!info.isDirectory())
28
+ throw new Error(`output path component must be a directory: ${candidate}`);
29
+ const actual = await realpath(candidate);
30
+ if (!isPathInside(canonicalBase, actual))
31
+ throw new Error('output path leaves the plan directory');
32
+ }
33
+ }
34
+ //# sourceMappingURL=output-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-path.js","sourceRoot":"","sources":["../src/output-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAQ,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAA;AAC3D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAY,EAAE,MAAc;IACrE,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC1D,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,cAAc,CAAC,IAAI,cAAc,KAAK,aAAa;QAClF,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;IAEnF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;IAC7D,IAAI,SAAS,GAAG,aAAa,CAAA;IAC7B,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QACzC,IAAI,IAAI,CAAA;QACR,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAA;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,SAAS,CAAC,KAAK,CAAC;gBAAE,OAAM;YAC5B,MAAM,KAAK,CAAA;QACb,CAAC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,SAAS,EAAE,CAAC,CAAA;QACrG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,SAAS,EAAE,CAAC,CAAA;QACnG,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,SAAS,CAAC,CAAA;QACxC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IACpG,CAAC;AACH,CAAC"}
package/dist/plan.d.ts ADDED
@@ -0,0 +1,79 @@
1
+ export { computeCaseCorpusDigest } from './corpus-digest.js';
2
+ import { type CapturedRuntimeSkill } from './runtime-skill.js';
3
+ import type { Digest, RuntimeCapabilities, ValidationResult } from './types.js';
4
+ export interface EvalConfiguration {
5
+ id: string;
6
+ skillMode: 'with-skill' | 'without-skill' | 'previous-version';
7
+ comparisonId: string | null;
8
+ skillPath?: string | null;
9
+ skillDigest?: Digest | null;
10
+ env?: Record<string, string>;
11
+ }
12
+ export interface AwSkillEvalExecutionPlan {
13
+ schemaVersion: 3;
14
+ planId: string;
15
+ minimumEvidenceLevel?: 'executed' | 'comparative';
16
+ target: {
17
+ name: string;
18
+ path: string;
19
+ digest: Digest;
20
+ };
21
+ cases: {
22
+ paths: string[];
23
+ corpusDigest: Digest;
24
+ };
25
+ provider: {
26
+ id: string;
27
+ command: string[];
28
+ cwd?: string | null;
29
+ env?: Record<string, string>;
30
+ capabilitiesPath: string;
31
+ capabilitiesDigest: Digest;
32
+ inheritEnvironment: boolean;
33
+ };
34
+ configurations: EvalConfiguration[];
35
+ runsPerCase: number;
36
+ timeoutMs: number;
37
+ outputRoot: string;
38
+ capture: {
39
+ outputs: boolean;
40
+ trace: boolean;
41
+ timing: boolean;
42
+ usage: boolean;
43
+ };
44
+ }
45
+ export interface EvalCase extends Record<string, unknown> {
46
+ id?: string | number;
47
+ }
48
+ export interface PlanCalculated {
49
+ targetSkillDigest: Digest | null;
50
+ caseCorpusDigest: Digest | null;
51
+ capabilitiesDigest: Digest | null;
52
+ configurationSkillDigests: Record<string, Digest | null>;
53
+ }
54
+ export interface CapturedPlanFile {
55
+ label: string;
56
+ requestedPath: string;
57
+ canonicalPath: string;
58
+ digest: Digest;
59
+ raw: string;
60
+ }
61
+ export interface CapturedExecutionPlan {
62
+ plan: AwSkillEvalExecutionPlan;
63
+ base: string;
64
+ outputRoot: string;
65
+ planFile: CapturedPlanFile;
66
+ caseFiles: CapturedPlanFile[];
67
+ capabilitiesFile: CapturedPlanFile;
68
+ cases: EvalCase[];
69
+ capabilities: RuntimeCapabilities;
70
+ skills: Map<string, CapturedRuntimeSkill | null>;
71
+ boundSkills: Map<string, CapturedRuntimeSkill>;
72
+ }
73
+ export interface CapturedExecutionPlanResult extends ValidationResult<PlanCalculated> {
74
+ captured: CapturedExecutionPlan | null;
75
+ }
76
+ export declare function casesFrom(document: unknown): EvalCase[];
77
+ export declare function promptOf(evalCase: EvalCase): string;
78
+ export declare function captureAndValidateExecutionPlan(planPath: string): Promise<CapturedExecutionPlanResult>;
79
+ export declare function validateExecutionPlan(planPath: string): Promise<ValidationResult<PlanCalculated>>;
package/dist/plan.js ADDED
@@ -0,0 +1,285 @@
1
+ import { lstat, readFile, realpath } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { getRuntimeCapabilities } from './capabilities.js';
4
+ import { isPathInside, pathsOverlap, safeSegment, sha256, stable } from './common.js';
5
+ export { computeCaseCorpusDigest } from './corpus-digest.js';
6
+ import { validateJsonSchema } from './json-schema.js';
7
+ import { captureRuntimeSkill } from './runtime-skill.js';
8
+ import { getSchema } from './schemas.js';
9
+ import { assertSafeOutputPath } from './output-path.js';
10
+ export function casesFrom(document) {
11
+ if (Array.isArray(document))
12
+ return document;
13
+ if (document && typeof document === 'object') {
14
+ const record = document;
15
+ if (Array.isArray(record.cases))
16
+ return record.cases;
17
+ if (Array.isArray(record.evals))
18
+ return record.evals;
19
+ }
20
+ throw new Error('case document must be an array or contain cases/evals');
21
+ }
22
+ export function promptOf(evalCase) {
23
+ for (const key of ['query', 'prompt', 'input']) {
24
+ if (typeof evalCase[key] === 'string')
25
+ return evalCase[key];
26
+ }
27
+ if (Array.isArray(evalCase.messages)) {
28
+ const message = [...evalCase.messages].reverse().find((entry) => {
29
+ if (!entry || typeof entry !== 'object')
30
+ return false;
31
+ const record = entry;
32
+ return record.role === 'user' && typeof record.content === 'string';
33
+ });
34
+ if (typeof message?.content === 'string')
35
+ return message.content;
36
+ }
37
+ throw new Error(`case ${String(evalCase.id ?? '?')} has no prompt/query/input`);
38
+ }
39
+ async function readFencedJson(base, value, label, outputRoot) {
40
+ const candidate = path.resolve(base, value);
41
+ const actual = await realpath(candidate);
42
+ if (!isPathInside(base, actual))
43
+ throw new Error(`${label} leaves the plan directory`);
44
+ if ((await lstat(candidate)).isSymbolicLink())
45
+ throw new Error(`${label} cannot be a symlink`);
46
+ if (outputRoot && isPathInside(outputRoot, actual))
47
+ throw new Error(`${label} must not be inside outputRoot`);
48
+ const raw = await readFile(actual, 'utf8');
49
+ return {
50
+ file: { label, requestedPath: candidate, canonicalPath: actual, digest: sha256(raw), raw },
51
+ value: JSON.parse(raw),
52
+ };
53
+ }
54
+ export async function captureAndValidateExecutionPlan(planPath) {
55
+ const errors = [];
56
+ const calculated = {
57
+ targetSkillDigest: null,
58
+ caseCorpusDigest: null,
59
+ capabilitiesDigest: null,
60
+ configurationSkillDigests: {},
61
+ };
62
+ let plan;
63
+ let planFile;
64
+ try {
65
+ const requestedPath = path.resolve(planPath);
66
+ const info = await lstat(requestedPath);
67
+ if (info.isSymbolicLink() || !info.isFile())
68
+ throw new Error('execution plan must be a regular non-symlink file');
69
+ const canonicalPath = await realpath(requestedPath);
70
+ const raw = await readFile(canonicalPath, 'utf8');
71
+ planFile = {
72
+ label: 'execution plan',
73
+ requestedPath,
74
+ canonicalPath,
75
+ digest: sha256(raw),
76
+ raw,
77
+ };
78
+ const value = JSON.parse(raw);
79
+ errors.push(...validateJsonSchema(await getSchema('aw-skill-eval-execution-plan'), value));
80
+ if (errors.length > 0)
81
+ return { valid: false, errors, calculated, captured: null };
82
+ plan = value;
83
+ }
84
+ catch (error) {
85
+ return {
86
+ valid: false,
87
+ errors: [`plan is unavailable or invalid: ${error.message}`],
88
+ calculated,
89
+ captured: null,
90
+ };
91
+ }
92
+ const base = await realpath(path.dirname(planFile.requestedPath));
93
+ const outputRoot = path.resolve(base, plan.outputRoot);
94
+ try {
95
+ await assertSafeOutputPath(base, outputRoot);
96
+ }
97
+ catch (error) {
98
+ errors.push(`outputRoot is unavailable or unsafe: ${error.message}`);
99
+ }
100
+ try {
101
+ if (isPathInside(outputRoot, planFile.canonicalPath))
102
+ errors.push('execution plan must not be inside outputRoot');
103
+ }
104
+ catch (error) {
105
+ errors.push(`execution plan path is unavailable or unsafe: ${error.message}`);
106
+ }
107
+ if (new Set(plan.configurations.map((entry) => entry.id)).size !== plan.configurations.length)
108
+ errors.push('configuration ids must be unique');
109
+ if (plan.configurations.some((entry) => !safeSegment(entry.id)))
110
+ errors.push('configuration ids must be safe path segments');
111
+ const comparisonGroups = new Map();
112
+ for (const configuration of plan.configurations) {
113
+ if (configuration.comparisonId === null)
114
+ continue;
115
+ const group = comparisonGroups.get(configuration.comparisonId) ?? [];
116
+ group.push(configuration);
117
+ comparisonGroups.set(configuration.comparisonId, group);
118
+ }
119
+ for (const [comparisonId, configurations] of comparisonGroups) {
120
+ if (!configurations.some((entry) => entry.skillMode === 'with-skill'))
121
+ errors.push(`${comparisonId} comparison requires a with-skill configuration`);
122
+ if (!configurations.some((entry) => entry.skillMode !== 'with-skill'))
123
+ errors.push(`${comparisonId} comparison requires a baseline configuration`);
124
+ }
125
+ if ((plan.minimumEvidenceLevel ?? 'executed') === 'comparative' && comparisonGroups.size === 0)
126
+ errors.push('minimumEvidenceLevel comparative requires at least one comparison');
127
+ let capabilities = null;
128
+ let capabilitiesFile = null;
129
+ try {
130
+ const loaded = await readFencedJson(base, plan.provider.capabilitiesPath, 'capabilities path', outputRoot);
131
+ capabilitiesFile = loaded.file;
132
+ calculated.capabilitiesDigest = loaded.file.digest;
133
+ errors.push(...validateJsonSchema(await getSchema('eval-runtime-capabilities'), loaded.value).map((entry) => `capabilities: ${entry}`));
134
+ capabilities = loaded.value;
135
+ const runtimeCapabilities = getRuntimeCapabilities();
136
+ if (capabilities.provider !== plan.provider.id)
137
+ errors.push('provider id does not match capability document');
138
+ if (capabilities.provider !== runtimeCapabilities.provider)
139
+ errors.push('capability provider does not match the current aw-skill-eval runtime');
140
+ if (capabilities.providerVersion !== runtimeCapabilities.providerVersion)
141
+ errors.push('capability providerVersion does not match the current aw-skill-eval runtime');
142
+ for (const configuration of plan.configurations) {
143
+ if (configuration.skillMode === 'with-skill' && !capabilities.capabilities.skillPathExecution)
144
+ errors.push('provider does not support with-skill execution');
145
+ if (configuration.skillMode === 'without-skill' && !capabilities.capabilities.withoutSkillBaseline)
146
+ errors.push('provider does not support without-skill baseline');
147
+ if (configuration.skillMode === 'previous-version' && !capabilities.capabilities.previousVersionBaseline)
148
+ errors.push('provider does not support previous-version baseline');
149
+ }
150
+ if (!plan.capture.outputs)
151
+ errors.push('capture.outputs must be true for portable evidence');
152
+ if (!plan.capture.timing)
153
+ errors.push('capture.timing must be true for portable evidence');
154
+ if (plan.capture.trace && !capabilities.capabilities.toolTrace)
155
+ errors.push('provider does not support requested tool trace capture');
156
+ if (plan.capture.usage && !capabilities.capabilities.tokenUsage)
157
+ errors.push('provider does not support requested token usage capture');
158
+ }
159
+ catch (error) {
160
+ errors.push(`provider capabilities are unavailable or invalid: ${error.message}`);
161
+ }
162
+ let targetSkill = null;
163
+ const configurationRoots = new Map();
164
+ const capturedSkills = new Map();
165
+ const boundSkills = new Map();
166
+ try {
167
+ const target = path.resolve(base, plan.target.path);
168
+ if ((await lstat(target)).isSymbolicLink())
169
+ throw new Error('symlink');
170
+ targetSkill = await captureRuntimeSkill(target);
171
+ calculated.targetSkillDigest = targetSkill.digest;
172
+ if (pathsOverlap(targetSkill.sourceRoot, outputRoot))
173
+ errors.push('outputRoot must not overlap the target Skill tree');
174
+ configurationRoots.set('with-skill', targetSkill.sourceRoot);
175
+ boundSkills.set('target', targetSkill);
176
+ }
177
+ catch (error) {
178
+ errors.push(`target path is unavailable or unsafe: ${error.message}`);
179
+ }
180
+ for (const configuration of plan.configurations) {
181
+ if (configuration.skillMode === 'with-skill' || configuration.skillMode === 'without-skill') {
182
+ if (configuration.skillPath !== undefined && configuration.skillPath !== null)
183
+ errors.push(`${configuration.id} must not set skillPath for ${configuration.skillMode}`);
184
+ if (configuration.skillDigest !== undefined && configuration.skillDigest !== null)
185
+ errors.push(`${configuration.id} must not set skillDigest for ${configuration.skillMode}`);
186
+ calculated.configurationSkillDigests[configuration.id] = configuration.skillMode === 'with-skill'
187
+ ? calculated.targetSkillDigest
188
+ : null;
189
+ capturedSkills.set(configuration.id, configuration.skillMode === 'with-skill' ? targetSkill : null);
190
+ continue;
191
+ }
192
+ if (!configuration.skillPath || !configuration.skillDigest) {
193
+ errors.push(`${configuration.id} previous-version requires skillPath and skillDigest`);
194
+ continue;
195
+ }
196
+ try {
197
+ const previousPath = path.resolve(base, configuration.skillPath);
198
+ if ((await lstat(previousPath)).isSymbolicLink())
199
+ throw new Error('symlink');
200
+ const captured = await captureRuntimeSkill(previousPath);
201
+ if (!isPathInside(base, captured.sourceRoot))
202
+ throw new Error('previous-version path leaves the plan directory');
203
+ if (pathsOverlap(captured.sourceRoot, outputRoot))
204
+ throw new Error('previous-version path overlaps outputRoot');
205
+ calculated.configurationSkillDigests[configuration.id] = captured.digest;
206
+ configurationRoots.set(configuration.id, captured.sourceRoot);
207
+ capturedSkills.set(configuration.id, captured);
208
+ boundSkills.set(configuration.id, captured);
209
+ if (captured.digest !== configuration.skillDigest)
210
+ errors.push(`${configuration.id} skillDigest does not match previous-version content`);
211
+ }
212
+ catch (error) {
213
+ errors.push(`${configuration.id} previous-version path is unavailable or unsafe: ${error.message}`);
214
+ }
215
+ }
216
+ const caseIds = new Set();
217
+ const caseFiles = [];
218
+ const capturedCases = [];
219
+ try {
220
+ const canonicalDocuments = [];
221
+ const evalTypes = new Set();
222
+ for (const caseEntry of plan.cases.paths) {
223
+ const loaded = await readFencedJson(base, caseEntry, 'case path', outputRoot);
224
+ caseFiles.push({ ...loaded.file, label: `case corpus file ${caseFiles.length + 1}` });
225
+ canonicalDocuments.push(stable(loaded.value));
226
+ for (const evalCase of casesFrom(loaded.value)) {
227
+ const id = String(evalCase.id ?? '');
228
+ if (!safeSegment(id) || caseIds.has(id))
229
+ throw new Error('case ids must be unique safe path segments');
230
+ caseIds.add(id);
231
+ evalTypes.add(String(evalCase.eval_type ?? evalCase.type ?? 'unknown'));
232
+ capturedCases.push(evalCase);
233
+ }
234
+ }
235
+ if (caseIds.size === 0)
236
+ throw new Error('case corpus must contain at least one case');
237
+ calculated.caseCorpusDigest = sha256(canonicalDocuments.sort().join('\n'));
238
+ if (evalTypes.has('trigger') && capabilities && !capabilities.capabilities.triggerDiscovery)
239
+ errors.push('provider does not support trigger discovery');
240
+ }
241
+ catch (error) {
242
+ errors.push(`case corpus is unavailable or invalid: ${error.message}`);
243
+ }
244
+ if (calculated.targetSkillDigest && calculated.targetSkillDigest !== plan.target.digest)
245
+ errors.push('target digest does not match target content');
246
+ if (calculated.caseCorpusDigest && calculated.caseCorpusDigest !== plan.cases.corpusDigest)
247
+ errors.push('case corpus digest does not match case documents');
248
+ if (calculated.capabilitiesDigest && calculated.capabilitiesDigest !== plan.provider.capabilitiesDigest)
249
+ errors.push('capabilitiesDigest does not match capability document');
250
+ if (plan.provider.command.some((value) => value.includes('\0')))
251
+ errors.push('provider command contains invalid argv');
252
+ if (plan.provider.cwd !== null && plan.provider.cwd !== undefined) {
253
+ const providerCwd = path.resolve(base, plan.provider.cwd);
254
+ if (!isPathInside(base, providerCwd))
255
+ errors.push('provider cwd must stay inside the plan directory');
256
+ for (const [configurationId, skillRoot] of configurationRoots)
257
+ if (pathsOverlap(skillRoot, providerCwd))
258
+ errors.push(`provider cwd must not overlap ${configurationId} Skill content`);
259
+ }
260
+ if (errors.length > 0 || !capabilities || !capabilitiesFile || !targetSkill) {
261
+ return { valid: false, errors, calculated, captured: null };
262
+ }
263
+ return {
264
+ valid: true,
265
+ errors,
266
+ calculated,
267
+ captured: {
268
+ plan,
269
+ base,
270
+ outputRoot,
271
+ planFile,
272
+ caseFiles,
273
+ capabilitiesFile: { ...capabilitiesFile, label: 'provider capabilities' },
274
+ cases: capturedCases,
275
+ capabilities,
276
+ skills: capturedSkills,
277
+ boundSkills,
278
+ },
279
+ };
280
+ }
281
+ export async function validateExecutionPlan(planPath) {
282
+ const { captured: _captured, ...validation } = await captureAndValidateExecutionPlan(planPath);
283
+ return validation;
284
+ }
285
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAA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I,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QACzD,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;QACrG,KAAK,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,IAAI,kBAAkB;YAC3D,IAAI,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,iCAAiC,eAAe,gBAAgB,CAAC,CAAA;IAC3H,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,gBAAgB,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC7D,CAAC;IACD,OAAO;QACL,KAAK,EAAE,IAAI;QACX,MAAM;QACN,UAAU;QACV,QAAQ,EAAE;YACR,IAAI;YACJ,IAAI;YACJ,UAAU;YACV,QAAQ;YACR,SAAS;YACT,gBAAgB,EAAE,EAAE,GAAG,gBAAgB,EAAE,KAAK,EAAE,uBAAuB,EAAE;YACzE,KAAK,EAAE,aAAa;YACpB,YAAY;YACZ,MAAM,EAAE,cAAc;YACtB,WAAW;SACZ;KACF,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,QAAgB;IAEhB,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,+BAA+B,CAAC,QAAQ,CAAC,CAAA;IAC9F,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -0,0 +1,25 @@
1
+ type KillSignal = 'SIGTERM' | 'SIGKILL';
2
+ type PosixSignal = KillSignal | 'SIGSTOP';
3
+ export interface ProcessTreeDependencies {
4
+ platform?: NodeJS.Platform;
5
+ markerEnvironmentVariable?: string;
6
+ kill?: (pid: number, signal: PosixSignal) => void;
7
+ execFile?: (command: string, args: string[], options: {
8
+ timeout: number;
9
+ windowsHide: boolean;
10
+ maxBuffer: number;
11
+ }, callback: (error: Error | null, stdout: string) => void) => unknown;
12
+ }
13
+ export interface ProcessTreeObservation {
14
+ readonly pid: number;
15
+ dispose(): void;
16
+ }
17
+ export interface ProcessTreeTerminationOptions {
18
+ observation?: ProcessTreeObservation;
19
+ requireConfirmedCleanup?: boolean;
20
+ allowInspectionUnavailable?: boolean;
21
+ }
22
+ export declare function observeProcessTree(pid: number, marker: string | undefined, dependencies?: ProcessTreeDependencies): ProcessTreeObservation;
23
+ export declare function assertProcessTreeInspectionAvailable(dependencies?: ProcessTreeDependencies): Promise<void>;
24
+ export declare function terminateProcessTree(pid: number, killDirectChild: (signal: KillSignal) => void, dependencies?: ProcessTreeDependencies, options?: ProcessTreeTerminationOptions): Promise<void>;
25
+ export {};