@agentsmarket/pipeline-runtime 0.5.10 → 0.5.11

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/index.d.ts CHANGED
@@ -85,5 +85,5 @@ 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 { parseTestSpec, loadTestSpecFile, TestSpecParseError, runAssertion, getPath, runSingleTest, runTestSuite, mockValueForField, buildMockProvider, extractStage, StageNotFoundInSpecError, renderText, renderJson, renderJunit, computeCoverage, renderCoverageText, loadCoverageForPipeline, discoverTestFiles, runConformanceDir, mockValueForSchema, } from './testing/index.js';
88
+ 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
89
  export type { TestSpec, Assertion, AssertionResult, AssertionContext, SingleTestResult, RunTestOptions, RunSuiteOptions, ExtractedStage, CoverageReport, } from './testing/index.js';
package/dist/index.js CHANGED
@@ -78,4 +78,4 @@ 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 { parseTestSpec, loadTestSpecFile, TestSpecParseError, runAssertion, getPath, runSingleTest, runTestSuite, mockValueForField, buildMockProvider, extractStage, StageNotFoundInSpecError, renderText, renderJson, renderJunit, computeCoverage, renderCoverageText, loadCoverageForPipeline, discoverTestFiles, runConformanceDir, mockValueForSchema, } from './testing/index.js';
81
+ 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';
@@ -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';
@@ -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,53 @@
1
+ /**
2
+ * One mock answer for every path that runs a pipeline without a model.
3
+ *
4
+ * There were three mocks, 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 every path uses 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 honest limit: a mock answer satisfies a schema **by construction**, so
26
+ * a mock run proves the spec is executable — it does not prove the model can
27
+ * satisfy the schema. That is what a dry run is for.
28
+ */
29
+ /** The answer for a stage that asks for JSON but declares neither a schema nor fields. */
30
+ export declare const MOCK_STRUCTURED_JSON_EMPTY = "{\"_mock\":true,\"output\":\"<replace with real LLM JSON>\"}";
31
+ /**
32
+ * A JSON object that has every field path the stage asks for.
33
+ *
34
+ * The paths are the ones the runtime's own check resolves — `name`,
35
+ * `name[0]`, `name[*]` — because a mock answer that the check cannot find is
36
+ * a mock answer that fails. The old builder answered dotted numeric paths
37
+ * (`findings.0.title`) as nested OBJECTS, and the check looks for an array
38
+ * index there, so the mock and the check disagreed about the same path.
39
+ */
40
+ export declare function buildMockStructuredJson(fields: string[]): string;
41
+ export interface MockAnswerOptions {
42
+ /** The stage's `output_format`. */
43
+ outputFormat?: string;
44
+ /** The stage's `fields` — the JSON keys the answer must have. */
45
+ fields?: string[];
46
+ /** The stage's `output_schema` — the shape the answer must satisfy. */
47
+ outputSchema?: unknown;
48
+ }
49
+ /**
50
+ * The mock's answer to a stage, or `undefined` when the stage does not ask
51
+ * for JSON (the caller answers with prose then).
52
+ */
53
+ export declare function mockStageAnswer(opts: MockAnswerOptions): string | undefined;
@@ -0,0 +1,115 @@
1
+ /**
2
+ * One mock answer for every path that runs a pipeline without a model.
3
+ *
4
+ * There were three mocks, 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 every path uses 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 honest limit: a mock answer satisfies a schema **by construction**, so
26
+ * a mock run proves the spec is executable — it does not prove the model can
27
+ * satisfy the schema. That is what a dry run is for.
28
+ */
29
+ import { mockValueForSchema } from './mock-schema.js';
30
+ /** The answer for a stage that asks for JSON but declares neither a schema nor fields. */
31
+ export const MOCK_STRUCTURED_JSON_EMPTY = '{"_mock":true,"output":"<replace with real LLM JSON>"}';
32
+ /**
33
+ * A JSON object that has every field path the stage asks for.
34
+ *
35
+ * The paths are the ones the runtime's own check resolves — `name`,
36
+ * `name[0]`, `name[*]` — because a mock answer that the check cannot find is
37
+ * a mock answer that fails. The old builder answered dotted numeric paths
38
+ * (`findings.0.title`) as nested OBJECTS, and the check looks for an array
39
+ * index there, so the mock and the check disagreed about the same path.
40
+ */
41
+ export function buildMockStructuredJson(fields) {
42
+ const root = { _mock: true };
43
+ for (const field of fields) {
44
+ const steps = parseFieldSteps(field);
45
+ if (steps.length === 0)
46
+ continue;
47
+ setSteps(root, steps, 'mock');
48
+ }
49
+ return JSON.stringify(root);
50
+ }
51
+ /** The steps of a field path, or [] for a path the runtime's check cannot resolve either. */
52
+ function parseFieldSteps(field) {
53
+ const steps = [];
54
+ for (const raw of field.replace(/^\$\.?/, '').split('.')) {
55
+ if (!raw)
56
+ continue;
57
+ const m = raw.match(/^([A-Za-z_][A-Za-z0-9_]*)((?:\[\d+\]|\[\*\])*)$/);
58
+ if (!m)
59
+ return [];
60
+ steps.push({ kind: 'key', key: m[1] });
61
+ for (const im of (m[2] ?? '').matchAll(/\[(\d+|\*)\]/g)) {
62
+ steps.push({ kind: 'index', index: im[1] === '*' ? 0 : Number(im[1]) });
63
+ }
64
+ }
65
+ return steps;
66
+ }
67
+ function setSteps(root, steps, value) {
68
+ let cur = root;
69
+ for (let i = 0; i < steps.length; i++) {
70
+ const step = steps[i];
71
+ const last = i === steps.length - 1;
72
+ if (step.kind === 'key') {
73
+ const holder = cur;
74
+ if (last) {
75
+ holder[step.key] = value;
76
+ return;
77
+ }
78
+ // The next step decides what the container is: an index needs an array.
79
+ const nextIsIndex = steps[i + 1].kind === 'index';
80
+ if (typeof holder[step.key] !== 'object' || holder[step.key] === null) {
81
+ holder[step.key] = nextIsIndex ? [] : {};
82
+ }
83
+ cur = holder[step.key];
84
+ continue;
85
+ }
86
+ if (!Array.isArray(cur))
87
+ return;
88
+ while (cur.length <= step.index)
89
+ cur.push({});
90
+ if (last) {
91
+ cur[step.index] = value;
92
+ return;
93
+ }
94
+ if (typeof cur[step.index] !== 'object' || cur[step.index] === null)
95
+ cur[step.index] = {};
96
+ cur = cur[step.index];
97
+ }
98
+ }
99
+ /**
100
+ * The mock's answer to a stage, or `undefined` when the stage does not ask
101
+ * for JSON (the caller answers with prose then).
102
+ */
103
+ export function mockStageAnswer(opts) {
104
+ const { outputFormat, fields, outputSchema } = opts;
105
+ if (outputSchema) {
106
+ return JSON.stringify(mockValueForSchema(outputSchema));
107
+ }
108
+ if (Array.isArray(fields) && fields.length > 0) {
109
+ return buildMockStructuredJson(fields);
110
+ }
111
+ if (outputFormat === 'structured_json') {
112
+ return MOCK_STRUCTURED_JSON_EMPTY;
113
+ }
114
+ return undefined;
115
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsmarket/pipeline-runtime",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
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",