@agentsmarket/pipeline-runtime 0.5.11 → 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.
@@ -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 { cappedArray } from './capped-array.js';
88
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 { cappedArray } from './capped-array.js';
81
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';
@@ -1,7 +1,7 @@
1
1
  /**
2
- * One mock answer for every path that runs a pipeline without a model.
2
+ * One mock answer for the runner paths — the CLI and the Action.
3
3
  *
4
- * There were three mocks, and they answered differently:
4
+ * There were three mocks on the runner side, and they answered differently:
5
5
  *
6
6
  * - the runtime's schema mock (`pipeline test`) built an answer that
7
7
  * satisfies the stage's `output_schema`;
@@ -14,7 +14,7 @@
14
14
  * echo is not JSON, so `mock: true` could not run any of them — the dry run
15
15
  * was the one thing that did not work.
16
16
  *
17
- * The answer is now built in one order, and every path uses it:
17
+ * The answer is now built in one order, and both runner paths use it:
18
18
  *
19
19
  * 1. a schema, if the stage declares one — the answer satisfies it;
20
20
  * 2. the field paths, if the stage declares them — the answer has them;
@@ -22,6 +22,11 @@
22
22
  * 4. anything else — the caller answers with its own prose (a mock is a
23
23
  * provider, and prose is the caller's business).
24
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
+ *
25
30
  * The honest limit: a mock answer satisfies a schema **by construction**, so
26
31
  * a mock run proves the spec is executable — it does not prove the model can
27
32
  * satisfy the schema. That is what a dry run is for.
@@ -1,7 +1,7 @@
1
1
  /**
2
- * One mock answer for every path that runs a pipeline without a model.
2
+ * One mock answer for the runner paths — the CLI and the Action.
3
3
  *
4
- * There were three mocks, and they answered differently:
4
+ * There were three mocks on the runner side, and they answered differently:
5
5
  *
6
6
  * - the runtime's schema mock (`pipeline test`) built an answer that
7
7
  * satisfies the stage's `output_schema`;
@@ -14,7 +14,7 @@
14
14
  * echo is not JSON, so `mock: true` could not run any of them — the dry run
15
15
  * was the one thing that did not work.
16
16
  *
17
- * The answer is now built in one order, and every path uses it:
17
+ * The answer is now built in one order, and both runner paths use it:
18
18
  *
19
19
  * 1. a schema, if the stage declares one — the answer satisfies it;
20
20
  * 2. the field paths, if the stage declares them — the answer has them;
@@ -22,6 +22,11 @@
22
22
  * 4. anything else — the caller answers with its own prose (a mock is a
23
23
  * provider, and prose is the caller's business).
24
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
+ *
25
30
  * The honest limit: a mock answer satisfies a schema **by construction**, so
26
31
  * a mock run proves the spec is executable — it does not prove the model can
27
32
  * satisfy the schema. That is what a dry run is for.
@@ -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
- pipeline?: string | undefined;
236
- description?: string | undefined;
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
- inputs?: Record<string, unknown> | undefined;
242
- pipeline?: string | undefined;
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
- })[] | undefined;
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: z.array(AssertionSchema).default([]),
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.11",
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.135.0",
14
- "@hono/node-server": "^1.13.0",
13
+ "@anthropic-ai/sdk": "^0.137.0",
14
+ "@hono/node-server": "^2.1.5",
15
15
  "ethers": "^6.17.0",
16
- "hono": "^4.13.13",
16
+ "hono": "^4.13.14",
17
17
  "js-yaml": "^4.1.0",
18
- "openai": "^7.37.0",
18
+ "openai": "^7.43.0",
19
19
  "zod": "^3.25"
20
20
  },
21
21
  "devDependencies": {