@agentsmarket/pipeline-runtime 0.5.10 → 0.5.12
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/capped-array.d.ts +16 -0
- package/dist/capped-array.js +30 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/mock-answer.d.ts +58 -0
- package/dist/testing/mock-answer.js +120 -0
- package/dist/testing/spec-parser.d.ts +22 -53
- package/dist/testing/spec-parser.js +8 -1
- package/package.json +5 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A zod array schema that cannot be turned into a memory bomb.
|
|
3
|
+
*
|
|
4
|
+
* GHSA-mrhx-c7xc-m3w5 (zod < 4.6.6, high): the array parse pushes one issue
|
|
5
|
+
* per failing element into the result with no cap, so a request carrying a
|
|
6
|
+
* million wrong-typed array members makes the process allocate a million
|
|
7
|
+
* issue objects and die. `.max()` does NOT help — zod v3 parses every element
|
|
8
|
+
* first and only then reports the length violation (measured here: 200 001
|
|
9
|
+
* issues for a 200 000-element array with `.max(10)`).
|
|
10
|
+
*
|
|
11
|
+
* So the length is checked BEFORE the element parse, and only the first `max`
|
|
12
|
+
* elements are handed to zod. A hostile array then costs one issue plus at
|
|
13
|
+
* most `max` element issues, however long it is.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
export declare function cappedArray<T extends z.ZodTypeAny>(element: T, max: number): z.ZodEffects<z.ZodArray<T>, z.ZodArray<T>['_output'], unknown>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A zod array schema that cannot be turned into a memory bomb.
|
|
3
|
+
*
|
|
4
|
+
* GHSA-mrhx-c7xc-m3w5 (zod < 4.6.6, high): the array parse pushes one issue
|
|
5
|
+
* per failing element into the result with no cap, so a request carrying a
|
|
6
|
+
* million wrong-typed array members makes the process allocate a million
|
|
7
|
+
* issue objects and die. `.max()` does NOT help — zod v3 parses every element
|
|
8
|
+
* first and only then reports the length violation (measured here: 200 001
|
|
9
|
+
* issues for a 200 000-element array with `.max(10)`).
|
|
10
|
+
*
|
|
11
|
+
* So the length is checked BEFORE the element parse, and only the first `max`
|
|
12
|
+
* elements are handed to zod. A hostile array then costs one issue plus at
|
|
13
|
+
* most `max` element issues, however long it is.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
export function cappedArray(element, max) {
|
|
17
|
+
return z.preprocess((value, ctx) => {
|
|
18
|
+
if (Array.isArray(value) && value.length > max) {
|
|
19
|
+
ctx.addIssue({
|
|
20
|
+
code: z.ZodIssueCode.too_big,
|
|
21
|
+
maximum: max,
|
|
22
|
+
type: 'array',
|
|
23
|
+
inclusive: true,
|
|
24
|
+
message: `must contain at most ${max} item(s)`,
|
|
25
|
+
});
|
|
26
|
+
return value.slice(0, max);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}, z.array(element));
|
|
30
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -85,5 +85,6 @@ export declare function runPipeline(spec: PipelineSpec, inputs: Record<string, u
|
|
|
85
85
|
}): Promise<Record<string, string>>;
|
|
86
86
|
export { LOOP_SCHEMA_VERSION, DEFAULT_MAX_ITERATIONS, ABSOLUTE_MAX_ITERATIONS, LoopConfigError, LoopMaxIterationsExceededError, parseExitExpression, evaluateExitExpression, executeLoop, type LoopOperator, type LoopExitExpression, type LoopSpec, type LoopIteration, type LoopTrace, type RunBodyStage, type LoopExecutionOptions, } from './loop.js';
|
|
87
87
|
export { MEMORY_SCHEMA_VERSION, MAX_MEMORY_VALUE_BYTES, InMemoryMemoryStore, R2MemoryStore, createMemoryStore, type MemoryScope, type MemoryPartition, type MemoryEntry, type MemoryStore, type MemoryR2Like, } from './memory.js';
|
|
88
|
-
export {
|
|
88
|
+
export { cappedArray } from './capped-array.js';
|
|
89
|
+
export { parseTestSpec, loadTestSpecFile, TestSpecParseError, runAssertion, getPath, runSingleTest, runTestSuite, mockValueForField, buildMockProvider, extractStage, StageNotFoundInSpecError, renderText, renderJson, renderJunit, computeCoverage, renderCoverageText, loadCoverageForPipeline, discoverTestFiles, runConformanceDir, mockValueForSchema, mockStageAnswer, buildMockStructuredJson, MOCK_STRUCTURED_JSON_EMPTY, } from './testing/index.js';
|
|
89
90
|
export type { TestSpec, Assertion, AssertionResult, AssertionContext, SingleTestResult, RunTestOptions, RunSuiteOptions, ExtractedStage, CoverageReport, } from './testing/index.js';
|
package/dist/index.js
CHANGED
|
@@ -78,4 +78,5 @@ export async function runPipeline(spec, inputs, opts) {
|
|
|
78
78
|
}
|
|
79
79
|
export { LOOP_SCHEMA_VERSION, DEFAULT_MAX_ITERATIONS, ABSOLUTE_MAX_ITERATIONS, LoopConfigError, LoopMaxIterationsExceededError, parseExitExpression, evaluateExitExpression, executeLoop, } from './loop.js';
|
|
80
80
|
export { MEMORY_SCHEMA_VERSION, MAX_MEMORY_VALUE_BYTES, InMemoryMemoryStore, R2MemoryStore, createMemoryStore, } from './memory.js';
|
|
81
|
-
export {
|
|
81
|
+
export { cappedArray } from './capped-array.js';
|
|
82
|
+
export { parseTestSpec, loadTestSpecFile, TestSpecParseError, runAssertion, getPath, runSingleTest, runTestSuite, mockValueForField, buildMockProvider, extractStage, StageNotFoundInSpecError, renderText, renderJson, renderJunit, computeCoverage, renderCoverageText, loadCoverageForPipeline, discoverTestFiles, runConformanceDir, mockValueForSchema, mockStageAnswer, buildMockStructuredJson, MOCK_STRUCTURED_JSON_EMPTY, } from './testing/index.js';
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { parseTestSpec, loadTestSpecFile, TestSpecParseError, type TestSpec, typ
|
|
|
2
2
|
export { runAssertion, getPath, type AssertionResult, type AssertionContext } from './assertions.js';
|
|
3
3
|
export { runSingleTest, runTestSuite, mockValueForField, buildMockProvider, type SingleTestResult, type RunTestOptions, type RunSuiteOptions } from './runner.js';
|
|
4
4
|
export { mockValueForSchema } from './mock-schema.js';
|
|
5
|
+
export { mockStageAnswer, buildMockStructuredJson, MOCK_STRUCTURED_JSON_EMPTY, type MockAnswerOptions } from './mock-answer.js';
|
|
5
6
|
export { extractStage, StageNotFoundInSpecError, type ExtractedStage } from './stage-extractor.js';
|
|
6
7
|
export { renderText } from './reporters/text.js';
|
|
7
8
|
export { renderJson } from './reporters/json.js';
|
package/dist/testing/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { parseTestSpec, loadTestSpecFile, TestSpecParseError } from './spec-pars
|
|
|
2
2
|
export { runAssertion, getPath } from './assertions.js';
|
|
3
3
|
export { runSingleTest, runTestSuite, mockValueForField, buildMockProvider } from './runner.js';
|
|
4
4
|
export { mockValueForSchema } from './mock-schema.js';
|
|
5
|
+
export { mockStageAnswer, buildMockStructuredJson, MOCK_STRUCTURED_JSON_EMPTY } from './mock-answer.js';
|
|
5
6
|
export { extractStage, StageNotFoundInSpecError } from './stage-extractor.js';
|
|
6
7
|
export { renderText } from './reporters/text.js';
|
|
7
8
|
export { renderJson } from './reporters/json.js';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One mock answer for the runner paths — the CLI and the Action.
|
|
3
|
+
*
|
|
4
|
+
* There were three mocks on the runner side, and they answered differently:
|
|
5
|
+
*
|
|
6
|
+
* - the runtime's schema mock (`pipeline test`) built an answer that
|
|
7
|
+
* satisfies the stage's `output_schema`;
|
|
8
|
+
* - the CLI's mock (`--mock`) built an answer from the stage's `fields`;
|
|
9
|
+
* - the Action's mock (`mock: true`) echoed the prompt.
|
|
10
|
+
*
|
|
11
|
+
* So the same spec passed in one place and failed in another, and the
|
|
12
|
+
* failure looked like a defect in the spec. The Action's mock was the worst
|
|
13
|
+
* of the three: every published spec answers in `structured_json`, and an
|
|
14
|
+
* echo is not JSON, so `mock: true` could not run any of them — the dry run
|
|
15
|
+
* was the one thing that did not work.
|
|
16
|
+
*
|
|
17
|
+
* The answer is now built in one order, and both runner paths use it:
|
|
18
|
+
*
|
|
19
|
+
* 1. a schema, if the stage declares one — the answer satisfies it;
|
|
20
|
+
* 2. the field paths, if the stage declares them — the answer has them;
|
|
21
|
+
* 3. `structured_json` with neither — an empty placeholder;
|
|
22
|
+
* 4. anything else — the caller answers with its own prose (a mock is a
|
|
23
|
+
* provider, and prose is the caller's business).
|
|
24
|
+
*
|
|
25
|
+
* The test framework of `pipeline test` keeps its own mock
|
|
26
|
+
* (`buildMockProvider`): it answers by the schema too, but it has its own
|
|
27
|
+
* contract for a stage that asks for JSON without a schema — `{result:
|
|
28
|
+
* "mock-output"}` — and that contract has its own test.
|
|
29
|
+
*
|
|
30
|
+
* The honest limit: a mock answer satisfies a schema **by construction**, so
|
|
31
|
+
* a mock run proves the spec is executable — it does not prove the model can
|
|
32
|
+
* satisfy the schema. That is what a dry run is for.
|
|
33
|
+
*/
|
|
34
|
+
/** The answer for a stage that asks for JSON but declares neither a schema nor fields. */
|
|
35
|
+
export declare const MOCK_STRUCTURED_JSON_EMPTY = "{\"_mock\":true,\"output\":\"<replace with real LLM JSON>\"}";
|
|
36
|
+
/**
|
|
37
|
+
* A JSON object that has every field path the stage asks for.
|
|
38
|
+
*
|
|
39
|
+
* The paths are the ones the runtime's own check resolves — `name`,
|
|
40
|
+
* `name[0]`, `name[*]` — because a mock answer that the check cannot find is
|
|
41
|
+
* a mock answer that fails. The old builder answered dotted numeric paths
|
|
42
|
+
* (`findings.0.title`) as nested OBJECTS, and the check looks for an array
|
|
43
|
+
* index there, so the mock and the check disagreed about the same path.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildMockStructuredJson(fields: string[]): string;
|
|
46
|
+
export interface MockAnswerOptions {
|
|
47
|
+
/** The stage's `output_format`. */
|
|
48
|
+
outputFormat?: string;
|
|
49
|
+
/** The stage's `fields` — the JSON keys the answer must have. */
|
|
50
|
+
fields?: string[];
|
|
51
|
+
/** The stage's `output_schema` — the shape the answer must satisfy. */
|
|
52
|
+
outputSchema?: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The mock's answer to a stage, or `undefined` when the stage does not ask
|
|
56
|
+
* for JSON (the caller answers with prose then).
|
|
57
|
+
*/
|
|
58
|
+
export declare function mockStageAnswer(opts: MockAnswerOptions): string | undefined;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One mock answer for the runner paths — the CLI and the Action.
|
|
3
|
+
*
|
|
4
|
+
* There were three mocks on the runner side, and they answered differently:
|
|
5
|
+
*
|
|
6
|
+
* - the runtime's schema mock (`pipeline test`) built an answer that
|
|
7
|
+
* satisfies the stage's `output_schema`;
|
|
8
|
+
* - the CLI's mock (`--mock`) built an answer from the stage's `fields`;
|
|
9
|
+
* - the Action's mock (`mock: true`) echoed the prompt.
|
|
10
|
+
*
|
|
11
|
+
* So the same spec passed in one place and failed in another, and the
|
|
12
|
+
* failure looked like a defect in the spec. The Action's mock was the worst
|
|
13
|
+
* of the three: every published spec answers in `structured_json`, and an
|
|
14
|
+
* echo is not JSON, so `mock: true` could not run any of them — the dry run
|
|
15
|
+
* was the one thing that did not work.
|
|
16
|
+
*
|
|
17
|
+
* The answer is now built in one order, and both runner paths use it:
|
|
18
|
+
*
|
|
19
|
+
* 1. a schema, if the stage declares one — the answer satisfies it;
|
|
20
|
+
* 2. the field paths, if the stage declares them — the answer has them;
|
|
21
|
+
* 3. `structured_json` with neither — an empty placeholder;
|
|
22
|
+
* 4. anything else — the caller answers with its own prose (a mock is a
|
|
23
|
+
* provider, and prose is the caller's business).
|
|
24
|
+
*
|
|
25
|
+
* The test framework of `pipeline test` keeps its own mock
|
|
26
|
+
* (`buildMockProvider`): it answers by the schema too, but it has its own
|
|
27
|
+
* contract for a stage that asks for JSON without a schema — `{result:
|
|
28
|
+
* "mock-output"}` — and that contract has its own test.
|
|
29
|
+
*
|
|
30
|
+
* The honest limit: a mock answer satisfies a schema **by construction**, so
|
|
31
|
+
* a mock run proves the spec is executable — it does not prove the model can
|
|
32
|
+
* satisfy the schema. That is what a dry run is for.
|
|
33
|
+
*/
|
|
34
|
+
import { mockValueForSchema } from './mock-schema.js';
|
|
35
|
+
/** The answer for a stage that asks for JSON but declares neither a schema nor fields. */
|
|
36
|
+
export const MOCK_STRUCTURED_JSON_EMPTY = '{"_mock":true,"output":"<replace with real LLM JSON>"}';
|
|
37
|
+
/**
|
|
38
|
+
* A JSON object that has every field path the stage asks for.
|
|
39
|
+
*
|
|
40
|
+
* The paths are the ones the runtime's own check resolves — `name`,
|
|
41
|
+
* `name[0]`, `name[*]` — because a mock answer that the check cannot find is
|
|
42
|
+
* a mock answer that fails. The old builder answered dotted numeric paths
|
|
43
|
+
* (`findings.0.title`) as nested OBJECTS, and the check looks for an array
|
|
44
|
+
* index there, so the mock and the check disagreed about the same path.
|
|
45
|
+
*/
|
|
46
|
+
export function buildMockStructuredJson(fields) {
|
|
47
|
+
const root = { _mock: true };
|
|
48
|
+
for (const field of fields) {
|
|
49
|
+
const steps = parseFieldSteps(field);
|
|
50
|
+
if (steps.length === 0)
|
|
51
|
+
continue;
|
|
52
|
+
setSteps(root, steps, 'mock');
|
|
53
|
+
}
|
|
54
|
+
return JSON.stringify(root);
|
|
55
|
+
}
|
|
56
|
+
/** The steps of a field path, or [] for a path the runtime's check cannot resolve either. */
|
|
57
|
+
function parseFieldSteps(field) {
|
|
58
|
+
const steps = [];
|
|
59
|
+
for (const raw of field.replace(/^\$\.?/, '').split('.')) {
|
|
60
|
+
if (!raw)
|
|
61
|
+
continue;
|
|
62
|
+
const m = raw.match(/^([A-Za-z_][A-Za-z0-9_]*)((?:\[\d+\]|\[\*\])*)$/);
|
|
63
|
+
if (!m)
|
|
64
|
+
return [];
|
|
65
|
+
steps.push({ kind: 'key', key: m[1] });
|
|
66
|
+
for (const im of (m[2] ?? '').matchAll(/\[(\d+|\*)\]/g)) {
|
|
67
|
+
steps.push({ kind: 'index', index: im[1] === '*' ? 0 : Number(im[1]) });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return steps;
|
|
71
|
+
}
|
|
72
|
+
function setSteps(root, steps, value) {
|
|
73
|
+
let cur = root;
|
|
74
|
+
for (let i = 0; i < steps.length; i++) {
|
|
75
|
+
const step = steps[i];
|
|
76
|
+
const last = i === steps.length - 1;
|
|
77
|
+
if (step.kind === 'key') {
|
|
78
|
+
const holder = cur;
|
|
79
|
+
if (last) {
|
|
80
|
+
holder[step.key] = value;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// The next step decides what the container is: an index needs an array.
|
|
84
|
+
const nextIsIndex = steps[i + 1].kind === 'index';
|
|
85
|
+
if (typeof holder[step.key] !== 'object' || holder[step.key] === null) {
|
|
86
|
+
holder[step.key] = nextIsIndex ? [] : {};
|
|
87
|
+
}
|
|
88
|
+
cur = holder[step.key];
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (!Array.isArray(cur))
|
|
92
|
+
return;
|
|
93
|
+
while (cur.length <= step.index)
|
|
94
|
+
cur.push({});
|
|
95
|
+
if (last) {
|
|
96
|
+
cur[step.index] = value;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (typeof cur[step.index] !== 'object' || cur[step.index] === null)
|
|
100
|
+
cur[step.index] = {};
|
|
101
|
+
cur = cur[step.index];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The mock's answer to a stage, or `undefined` when the stage does not ask
|
|
106
|
+
* for JSON (the caller answers with prose then).
|
|
107
|
+
*/
|
|
108
|
+
export function mockStageAnswer(opts) {
|
|
109
|
+
const { outputFormat, fields, outputSchema } = opts;
|
|
110
|
+
if (outputSchema) {
|
|
111
|
+
return JSON.stringify(mockValueForSchema(outputSchema));
|
|
112
|
+
}
|
|
113
|
+
if (Array.isArray(fields) && fields.length > 0) {
|
|
114
|
+
return buildMockStructuredJson(fields);
|
|
115
|
+
}
|
|
116
|
+
if (outputFormat === 'structured_json') {
|
|
117
|
+
return MOCK_STRUCTURED_JSON_EMPTY;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
@@ -102,7 +102,7 @@ declare const TestSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
102
102
|
inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
103
103
|
mock: z.ZodDefault<z.ZodBoolean>;
|
|
104
104
|
expect_error: z.ZodOptional<z.ZodString>;
|
|
105
|
-
assertions: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
105
|
+
assertions: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
106
106
|
type: z.ZodLiteral<"equality">;
|
|
107
107
|
path: z.ZodString;
|
|
108
108
|
value: z.ZodUnknown;
|
|
@@ -195,12 +195,7 @@ declare const TestSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
195
195
|
path: string;
|
|
196
196
|
type: "schema";
|
|
197
197
|
schema_file: string;
|
|
198
|
-
}>]>, "many"
|
|
199
|
-
}, "strip", z.ZodTypeAny, {
|
|
200
|
-
inputs: Record<string, unknown>;
|
|
201
|
-
name: string;
|
|
202
|
-
mock: boolean;
|
|
203
|
-
assertions: ({
|
|
198
|
+
}>]>, "many">, ({
|
|
204
199
|
path: string;
|
|
205
200
|
type: "equality";
|
|
206
201
|
value?: unknown;
|
|
@@ -231,20 +226,12 @@ declare const TestSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
231
226
|
path: string;
|
|
232
227
|
type: "schema";
|
|
233
228
|
schema_file: string;
|
|
234
|
-
})[]
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
stage?: string | undefined;
|
|
238
|
-
expect_error?: string | undefined;
|
|
239
|
-
}, {
|
|
229
|
+
})[], unknown>>;
|
|
230
|
+
}, "strip", z.ZodTypeAny, {
|
|
231
|
+
inputs: Record<string, unknown>;
|
|
240
232
|
name: string;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
description?: string | undefined;
|
|
244
|
-
mock?: boolean | undefined;
|
|
245
|
-
stage?: string | undefined;
|
|
246
|
-
expect_error?: string | undefined;
|
|
247
|
-
assertions?: ({
|
|
233
|
+
mock: boolean;
|
|
234
|
+
assertions: ({
|
|
248
235
|
path: string;
|
|
249
236
|
type: "equality";
|
|
250
237
|
value?: unknown;
|
|
@@ -275,7 +262,20 @@ declare const TestSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
275
262
|
path: string;
|
|
276
263
|
type: "schema";
|
|
277
264
|
schema_file: string;
|
|
278
|
-
})[]
|
|
265
|
+
})[];
|
|
266
|
+
pipeline?: string | undefined;
|
|
267
|
+
description?: string | undefined;
|
|
268
|
+
stage?: string | undefined;
|
|
269
|
+
expect_error?: string | undefined;
|
|
270
|
+
}, {
|
|
271
|
+
name: string;
|
|
272
|
+
inputs?: Record<string, unknown> | undefined;
|
|
273
|
+
pipeline?: string | undefined;
|
|
274
|
+
description?: string | undefined;
|
|
275
|
+
mock?: boolean | undefined;
|
|
276
|
+
stage?: string | undefined;
|
|
277
|
+
expect_error?: string | undefined;
|
|
278
|
+
assertions?: unknown;
|
|
279
279
|
}>, {
|
|
280
280
|
inputs: Record<string, unknown>;
|
|
281
281
|
name: string;
|
|
@@ -324,38 +324,7 @@ declare const TestSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
324
324
|
mock?: boolean | undefined;
|
|
325
325
|
stage?: string | undefined;
|
|
326
326
|
expect_error?: string | undefined;
|
|
327
|
-
assertions?:
|
|
328
|
-
path: string;
|
|
329
|
-
type: "equality";
|
|
330
|
-
value?: unknown;
|
|
331
|
-
} | {
|
|
332
|
-
value: string | number | boolean;
|
|
333
|
-
path: string;
|
|
334
|
-
type: "contains";
|
|
335
|
-
} | {
|
|
336
|
-
path: string;
|
|
337
|
-
type: "regex";
|
|
338
|
-
pattern: string;
|
|
339
|
-
flags?: string | undefined;
|
|
340
|
-
} | {
|
|
341
|
-
value: number;
|
|
342
|
-
path: string;
|
|
343
|
-
type: "gte" | "lte" | "gt" | "lt";
|
|
344
|
-
} | {
|
|
345
|
-
path: string;
|
|
346
|
-
type: "exists";
|
|
347
|
-
} | {
|
|
348
|
-
path: string;
|
|
349
|
-
type: "absent";
|
|
350
|
-
} | {
|
|
351
|
-
path: string;
|
|
352
|
-
type: "jsonpath";
|
|
353
|
-
value?: unknown;
|
|
354
|
-
} | {
|
|
355
|
-
path: string;
|
|
356
|
-
type: "schema";
|
|
357
|
-
schema_file: string;
|
|
358
|
-
})[] | undefined;
|
|
327
|
+
assertions?: unknown;
|
|
359
328
|
}>;
|
|
360
329
|
export type TestSpec = z.infer<typeof TestSpecSchema>;
|
|
361
330
|
export declare class TestSpecParseError extends Error {
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import yaml from 'js-yaml';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import { cappedArray } from '../capped-array.js';
|
|
9
|
+
/**
|
|
10
|
+
* GHSA-mrhx-c7xc-m3w5: an unbounded array of failing members makes zod
|
|
11
|
+
* allocate one issue per member. A test spec is author-supplied YAML, and the
|
|
12
|
+
* CLI/MCP parse whatever they hand over — so the assertion list is capped.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_ASSERTIONS = 500;
|
|
8
15
|
const EqualityAssertion = z.object({ type: z.literal('equality'), path: z.string(), value: z.unknown() });
|
|
9
16
|
const ContainsAssertion = z.object({ type: z.literal('contains'), path: z.string(), value: z.union([z.string(), z.number(), z.boolean()]) });
|
|
10
17
|
const RegexAssertion = z.object({ type: z.literal('regex'), path: z.string(), pattern: z.string(), flags: z.string().optional() });
|
|
@@ -25,7 +32,7 @@ const TestSpecSchema = z.object({
|
|
|
25
32
|
inputs: z.record(z.unknown()).default({}),
|
|
26
33
|
mock: z.boolean().default(true),
|
|
27
34
|
expect_error: z.string().optional(),
|
|
28
|
-
assertions:
|
|
35
|
+
assertions: cappedArray(AssertionSchema, MAX_ASSERTIONS).default([]),
|
|
29
36
|
}).refine((s) => s.pipeline !== undefined || s.stage !== undefined || s.expect_error !== undefined, {
|
|
30
37
|
message: 'test spec requires one of: pipeline, stage, or expect_error',
|
|
31
38
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentsmarket/pipeline-runtime",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"description": "Runtime for executing PIPELINE.md workflows (multi-skill orchestration). Provider-agnostic (MiniMax, Claude, OpenAI).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@anthropic-ai/sdk": "^0.
|
|
14
|
-
"@hono/node-server": "^1.
|
|
13
|
+
"@anthropic-ai/sdk": "^0.137.0",
|
|
14
|
+
"@hono/node-server": "^2.1.5",
|
|
15
15
|
"ethers": "^6.17.0",
|
|
16
|
-
"hono": "^4.13.
|
|
16
|
+
"hono": "^4.13.14",
|
|
17
17
|
"js-yaml": "^4.1.0",
|
|
18
|
-
"openai": "^7.
|
|
18
|
+
"openai": "^7.43.0",
|
|
19
19
|
"zod": "^3.25"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|