@agentsmarket/pipeline-runtime 0.5.9 → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agentsmarket.world contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -27,7 +27,7 @@ export interface MiniMaxProviderOptions {
27
27
  }
28
28
  export declare class MiniMaxProvider implements LLMProvider {
29
29
  readonly name = "minimax";
30
- readonly models: readonly ["MiniMax-M2.7", "MiniMax-M2.7-highspeed", "MiniMax-M3"];
30
+ readonly models: readonly string[];
31
31
  readonly simpleModel = "MiniMax-M2.7";
32
32
  readonly complexModel = "MiniMax-M3";
33
33
  private readonly apiKey;
@@ -19,18 +19,21 @@
19
19
  * `assertMultimodalSupported` in provider-registry.ts); this adapter only
20
20
  * shapes the request body.
21
21
  */
22
+ import { supportedModelsFor, supportsModel } from '../provider-registry.js';
22
23
  import { toAnthropicContent, } from './multimodal-convert.js';
23
24
  import { parseJsonLenient } from '../validate-inputs.js';
24
25
  const DEFAULT_BASE_URL = 'https://api.minimax.io/anthropic';
25
26
  export class MiniMaxProvider {
26
27
  name = 'minimax';
27
- models = ['MiniMax-M2.7', 'MiniMax-M2.7-highspeed', 'MiniMax-M3'];
28
+ // The registry is the single source of truth: the adapter used to carry its
29
+ // own list, so the two could promise different models.
30
+ models = supportedModelsFor('minimax');
28
31
  simpleModel = 'MiniMax-M2.7';
29
32
  complexModel = 'MiniMax-M3';
30
33
  apiKey;
31
34
  baseURL;
32
35
  supports(model) {
33
- return this.models.includes(model);
36
+ return supportsModel('minimax', model);
34
37
  }
35
38
  constructor(opts = {}) {
36
39
  const procEnv = typeof process !== 'undefined' ? process.env : undefined;
@@ -23,8 +23,8 @@ export interface OpenRouterProviderOptions {
23
23
  }
24
24
  export declare class OpenRouterProvider implements LLMProvider {
25
25
  readonly name = "openrouter";
26
- readonly models: readonly ["anthropic/claude-3.5-sonnet", "anthropic/claude-3-opus", "openai/gpt-4o", "openai/gpt-4-turbo", "MiniMax/MiniMax-M2.7", "MiniMax/MiniMax-M3"];
27
- readonly simpleModel = "MiniMax/MiniMax-M2.7";
26
+ readonly models: readonly string[];
27
+ readonly simpleModel = "openai/gpt-4o";
28
28
  readonly complexModel = "anthropic/claude-3.5-sonnet";
29
29
  private client;
30
30
  supports(model: string): boolean;
@@ -16,23 +16,26 @@
16
16
  * so we pass messages through unchanged.
17
17
  */
18
18
  import OpenAI from 'openai';
19
+ import { supportedModelsFor, supportsModel } from '../provider-registry.js';
19
20
  import { parseJsonLenient } from '../validate-inputs.js';
20
21
  const DEFAULT_BASE_URL = 'https://openrouter.ai/api/v1';
21
22
  export class OpenRouterProvider {
22
23
  name = 'openrouter';
23
- models = [
24
- 'anthropic/claude-3.5-sonnet',
25
- 'anthropic/claude-3-opus',
26
- 'openai/gpt-4o',
27
- 'openai/gpt-4-turbo',
28
- 'MiniMax/MiniMax-M2.7',
29
- 'MiniMax/MiniMax-M3',
30
- ];
31
- simpleModel = 'MiniMax/MiniMax-M2.7';
24
+ // The registry says openrouter routes ANY model id ('*') — the adapter used
25
+ // to carry six ids of its own, four of which do not exist on OpenRouter, so
26
+ // `minimax/minimax-m3` (the only real MiniMax id there) was refused.
27
+ models = supportedModelsFor('openrouter');
28
+ // A real id — the old default 'MiniMax/MiniMax-M2.7' does not exist on
29
+ // OpenRouter, so a stage without an explicit model called a 404.
30
+ simpleModel = 'openai/gpt-4o';
32
31
  complexModel = 'anthropic/claude-3.5-sonnet';
33
32
  client;
34
33
  supports(model) {
35
- return this.models.includes(model);
34
+ // The registry says openrouter routes ANY model id ('*'), so the adapter
35
+ // does not keep a list of its own — a list of six ids of which four do
36
+ // not exist on OpenRouter, including the only real MiniMax id there
37
+ // ('minimax/minimax-m3'). An empty id is not a model.
38
+ return model.length > 0 && supportsModel('openrouter', model);
36
39
  }
37
40
  constructor(opts = {}) {
38
41
  const procEnv = typeof process !== 'undefined' ? process.env : undefined;
@@ -18,7 +18,16 @@ import type { ZodSchema } from 'zod';
18
18
  * generateText (the only call that can fail at runtime).
19
19
  */
20
20
  export declare class FallbackProvider implements LLMProvider {
21
- readonly name = "fallback";
21
+ /**
22
+ * The primary provider's name.
23
+ *
24
+ * The wrapper used to call itself 'fallback', and a registry built around
25
+ * it could no longer find the provider a stage names: "Provider 'openai'
26
+ * is not registered. Available providers: fallback". The wrapper is the
27
+ * primary with a second chance attached, so it answers to the primary's
28
+ * name — and the fallback is registered under its own.
29
+ */
30
+ readonly name: string;
22
31
  readonly providers: LLMProvider[];
23
32
  readonly models: readonly string[];
24
33
  readonly simpleModel: string;
package/dist/fallback.js CHANGED
@@ -16,7 +16,16 @@
16
16
  * generateText (the only call that can fail at runtime).
17
17
  */
18
18
  export class FallbackProvider {
19
- name = 'fallback';
19
+ /**
20
+ * The primary provider's name.
21
+ *
22
+ * The wrapper used to call itself 'fallback', and a registry built around
23
+ * it could no longer find the provider a stage names: "Provider 'openai'
24
+ * is not registered. Available providers: fallback". The wrapper is the
25
+ * primary with a second chance attached, so it answers to the primary's
26
+ * name — and the fallback is registered under its own.
27
+ */
28
+ name;
20
29
  providers;
21
30
  models;
22
31
  simpleModel;
@@ -27,6 +36,7 @@ export class FallbackProvider {
27
36
  }
28
37
  this.providers = providers;
29
38
  const primary = providers[0];
39
+ this.name = primary.name;
30
40
  const seen = new Set();
31
41
  const all = [];
32
42
  for (const p of providers) {
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export type { PipelineCheckpoint, CheckpointStorage, R2BucketLike, CompletedStag
41
41
  export { createModelResolver, resolveModelSync, DEFAULT_MODEL, type ModelResolver, type ModelResolverOptions, type PipelineLike, type PipelineStageLike, type SkillLike, } from './model-resolver.js';
42
42
  export { sha256Hex, computeSkillContentHash, } from './content-hash.js';
43
43
  export { executeStage, runPipelineV2, makeWhenResolve, parseUsesEntry, parseUsesList, validateOutputFormat, StageNotFoundError, StageForbiddenError, StageBadConfigError, type StageExecutorDeps, type StageContext, type StageExecutionResult, type RunPipelineOptions, type RunPipelineResult, type NestedCallRecord, type ResolvedUse, type SkillInvocationDetail, type MCPValidationResult, type MCPDetail, } from './stages.js';
44
- export { validateInputs, formatInputErrors, type InputDecl, type InputSpec, type InputValidationError, } from './validate-inputs.js';
44
+ export { validateInputs, formatInputErrors, applyInputDefaults, type InputDecl, type InputSpec, type InputValidationError, } from './validate-inputs.js';
45
45
  export { validateMultimodalInput, type MultimodalValidationError, type MultimodalValidationResult, } from './validate-inputs.js';
46
46
  export { parseMediaUrl, detectMime, isImageMime, isAudioMime, isVideoMime, SUPPORTED_IMAGE_MIME, SUPPORTED_AUDIO_MIME, SUPPORTED_VIDEO_MIME, toAnthropicContent, type ParsedMedia, type AnthropicContentBlock, } from './adapters/multimodal-convert.js';
47
47
  export { resolveInputRefs, containsInputRef, inputRefName, resolveSpecialKeys, resolveDoubleBraceRefs, type PipelineRefContext, type DoubleBraceContext, } from './pipeline-refs.js';
@@ -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
@@ -25,7 +25,7 @@ export { buildCheckpoint, restoreFromCheckpoint, R2CheckpointStorage, InMemoryCh
25
25
  export { createModelResolver, resolveModelSync, DEFAULT_MODEL, } from './model-resolver.js';
26
26
  export { sha256Hex, computeSkillContentHash, } from './content-hash.js';
27
27
  export { executeStage, runPipelineV2, makeWhenResolve, parseUsesEntry, parseUsesList, validateOutputFormat, StageNotFoundError, StageForbiddenError, StageBadConfigError, } from './stages.js';
28
- export { validateInputs, formatInputErrors, } from './validate-inputs.js';
28
+ export { validateInputs, formatInputErrors, applyInputDefaults, } from './validate-inputs.js';
29
29
  export { validateMultimodalInput, } from './validate-inputs.js';
30
30
  export { parseMediaUrl, detectMime, isImageMime, isAudioMime, isVideoMime, SUPPORTED_IMAGE_MIME, SUPPORTED_AUDIO_MIME, SUPPORTED_VIDEO_MIME, toAnthropicContent, } from './adapters/multimodal-convert.js';
31
31
  export { resolveInputRefs, containsInputRef, inputRefName, resolveSpecialKeys, resolveDoubleBraceRefs, } from './pipeline-refs.js';
@@ -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';
@@ -51,6 +51,21 @@ export interface ProviderSpec {
51
51
  readonly visionCapableModels?: readonly string[];
52
52
  }
53
53
  export declare const PROVIDER_REGISTRY: Readonly<Record<Provider, ProviderSpec>>;
54
+ /**
55
+ * The models a provider accepts — the ONE list the runtime enforces.
56
+ *
57
+ * The adapters used to carry their own shorter lists, and the two drifted
58
+ * apart: the openai adapter did not know `gpt-4o-mini` (so the Action's
59
+ * default fallback model did not exist), the openrouter adapter listed ids
60
+ * OpenRouter does not have (so MiniMax through OpenRouter was impossible),
61
+ * and the anthropic adapter knew three of the five ids the registry
62
+ * promised. Now the adapters ask the registry, and the registry is the
63
+ * truth — one list, checked by the same function everywhere.
64
+ *
65
+ * `'*'` means "routes any model name" (openrouter): the adapter accepts
66
+ * every id, exactly as the registry promised.
67
+ */
68
+ export declare function supportedModelsFor(providerName: Provider): readonly string[];
54
69
  /**
55
70
  * Look up a provider by name. Returns null for unknown names —
56
71
  * use {@link validateProviderName} when an exception is desired.
@@ -72,6 +72,7 @@ export const PROVIDER_REGISTRY = {
72
72
  supportedModels: [
73
73
  'MiniMax-M3',
74
74
  'MiniMax-M2.7',
75
+ 'MiniMax-M2.7-highspeed',
75
76
  'MiniMax-M1',
76
77
  ],
77
78
  visionCapableModels: ['MiniMax-M3'],
@@ -105,6 +106,23 @@ export const PROVIDER_REGISTRY = {
105
106
  apiKeyEnvVar: 'REPLICATE_API_TOKEN',
106
107
  },
107
108
  };
109
+ /**
110
+ * The models a provider accepts — the ONE list the runtime enforces.
111
+ *
112
+ * The adapters used to carry their own shorter lists, and the two drifted
113
+ * apart: the openai adapter did not know `gpt-4o-mini` (so the Action's
114
+ * default fallback model did not exist), the openrouter adapter listed ids
115
+ * OpenRouter does not have (so MiniMax through OpenRouter was impossible),
116
+ * and the anthropic adapter knew three of the five ids the registry
117
+ * promised. Now the adapters ask the registry, and the registry is the
118
+ * truth — one list, checked by the same function everywhere.
119
+ *
120
+ * `'*'` means "routes any model name" (openrouter): the adapter accepts
121
+ * every id, exactly as the registry promised.
122
+ */
123
+ export function supportedModelsFor(providerName) {
124
+ return PROVIDER_REGISTRY[providerName]?.supportedModels ?? [];
125
+ }
108
126
  /**
109
127
  * Look up a provider by name. Returns null for unknown names —
110
128
  * use {@link validateProviderName} when an exception is desired.
@@ -17,7 +17,7 @@ export interface AnthropicProviderOptions {
17
17
  }
18
18
  export declare class AnthropicProvider implements LLMProvider {
19
19
  readonly name = "anthropic";
20
- readonly models: readonly ["claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307"];
20
+ readonly models: readonly string[];
21
21
  readonly simpleModel = "claude-3-sonnet-20240229";
22
22
  readonly complexModel = "claude-3-opus-20240229";
23
23
  private client;
@@ -10,21 +10,20 @@
10
10
  * multimodal conversion (toAnthropicContent) are shared.
11
11
  */
12
12
  import Anthropic from '@anthropic-ai/sdk';
13
+ import { supportedModelsFor, supportsModel } from '../provider-registry.js';
13
14
  import { toAnthropicContent, } from '../adapters/multimodal-convert.js';
14
15
  import { parseJsonLenient } from '../validate-inputs.js';
15
16
  const DEFAULT_BASE_URL = 'https://api.anthropic.com';
16
17
  export class AnthropicProvider {
17
18
  name = 'anthropic';
18
- models = [
19
- 'claude-3-opus-20240229',
20
- 'claude-3-sonnet-20240229',
21
- 'claude-3-haiku-20240307',
22
- ];
19
+ // The registry is the single source of truth: the adapter used to know
20
+ // three of the five ids the registry promised.
21
+ models = supportedModelsFor('anthropic');
23
22
  simpleModel = 'claude-3-sonnet-20240229';
24
23
  complexModel = 'claude-3-opus-20240229';
25
24
  client;
26
25
  supports(model) {
27
- return this.models.includes(model);
26
+ return supportsModel('anthropic', model);
28
27
  }
29
28
  constructor(opts = {}) {
30
29
  const procEnv = typeof process !== 'undefined' ? process.env : undefined;
@@ -17,7 +17,7 @@ export interface OpenAIChatProviderOptions {
17
17
  }
18
18
  export declare class OpenAIChatProvider implements LLMProvider {
19
19
  readonly name = "openai";
20
- readonly models: readonly ["gpt-4", "gpt-4-turbo", "gpt-3.5-turbo"];
20
+ readonly models: readonly string[];
21
21
  readonly simpleModel = "gpt-4";
22
22
  readonly complexModel = "gpt-4-turbo";
23
23
  private client;
@@ -10,16 +10,20 @@
10
10
  * the OpenAI API accepts image_url parts natively.
11
11
  */
12
12
  import OpenAI from 'openai';
13
+ import { supportedModelsFor, supportsModel } from '../provider-registry.js';
13
14
  import { parseJsonLenient } from '../validate-inputs.js';
14
15
  const DEFAULT_BASE_URL = 'https://api.openai.com/v1';
15
16
  export class OpenAIChatProvider {
16
17
  name = 'openai';
17
- models = ['gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo'];
18
+ // The registry is the single source of truth: the adapter used to carry a
19
+ // shorter list of its own, so `gpt-4o-mini` (the Action's default fallback
20
+ // model) was refused here while the registry promised it.
21
+ models = supportedModelsFor('openai');
18
22
  simpleModel = 'gpt-4';
19
23
  complexModel = 'gpt-4-turbo';
20
24
  client;
21
25
  supports(model) {
22
- return this.models.includes(model);
26
+ return supportsModel('openai', model);
23
27
  }
24
28
  constructor(opts = {}) {
25
29
  const procEnv = typeof process !== 'undefined' ? process.env : undefined;
@@ -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
+ }
@@ -46,6 +46,20 @@ export interface InputValidationError {
46
46
  got?: string;
47
47
  }
48
48
  export declare function validateInputs(specInputs: InputSpec | undefined, provided: Record<string, unknown>): InputValidationError[];
49
+ /**
50
+ * The declared defaults, for the inputs the caller did not give.
51
+ *
52
+ * A spec declares `inputs: { provider: { default: minimax } }` and a stage
53
+ * reads `${input.provider}`. Without this merge the reference stays literal
54
+ * text and the run dies with "Provider '${input.provider}' is not
55
+ * registered" — the exact rollback that killed the review of every consumer
56
+ * with one secret.
57
+ *
58
+ * The CLI, the server and the Action all merge HERE, so the three paths
59
+ * cannot drift apart again. A value the caller gave always wins: the default
60
+ * only fills a hole.
61
+ */
62
+ export declare function applyInputDefaults(provided: Record<string, unknown>, specInputs: InputSpec | undefined): Record<string, unknown>;
49
63
  export declare function formatInputErrors(errors: InputValidationError[], inputs?: InputSpec): string;
50
64
  export interface ValidateOutputOptions {
51
65
  parseJson?: boolean;
@@ -81,6 +81,35 @@ export function validateInputs(specInputs, provided) {
81
81
  }
82
82
  return errors;
83
83
  }
84
+ /**
85
+ * The declared defaults, for the inputs the caller did not give.
86
+ *
87
+ * A spec declares `inputs: { provider: { default: minimax } }` and a stage
88
+ * reads `${input.provider}`. Without this merge the reference stays literal
89
+ * text and the run dies with "Provider '${input.provider}' is not
90
+ * registered" — the exact rollback that killed the review of every consumer
91
+ * with one secret.
92
+ *
93
+ * The CLI, the server and the Action all merge HERE, so the three paths
94
+ * cannot drift apart again. A value the caller gave always wins: the default
95
+ * only fills a hole.
96
+ */
97
+ export function applyInputDefaults(provided, specInputs) {
98
+ // Always a new object: the server keeps the caller's map (it is hashed and
99
+ // stored) next to the merged one, and two names for one object is how a
100
+ // "merged" map ends up holding the raw values.
101
+ const out = { ...provided };
102
+ if (!specInputs)
103
+ return out;
104
+ for (const [key, decl] of Object.entries(specInputs)) {
105
+ if (key in out)
106
+ continue;
107
+ if (!decl || typeof decl !== 'object' || !('default' in decl))
108
+ continue;
109
+ out[key] = decl.default;
110
+ }
111
+ return out;
112
+ }
84
113
  export function formatInputErrors(errors, inputs) {
85
114
  if (errors.length === 0)
86
115
  return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsmarket/pipeline-runtime",
3
- "version": "0.5.9",
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",
@@ -9,14 +9,6 @@
9
9
  "dist",
10
10
  "README.md"
11
11
  ],
12
- "scripts": {
13
- "build": "tsc",
14
- "test": "vitest run",
15
- "test:coverage": "vitest run --coverage",
16
- "dev": "tsx src/index.ts",
17
- "lint": "tsc --noEmit",
18
- "typecheck": "tsc --noEmit -p tsconfig.json"
19
- },
20
12
  "dependencies": {
21
13
  "@anthropic-ai/sdk": "^0.135.0",
22
14
  "@hono/node-server": "^1.13.0",
@@ -42,5 +34,13 @@
42
34
  "publishConfig": {
43
35
  "access": "public"
44
36
  },
45
- "types": "./dist/index.d.ts"
46
- }
37
+ "types": "./dist/index.d.ts",
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "test": "vitest run",
41
+ "test:coverage": "vitest run --coverage",
42
+ "dev": "tsx src/index.ts",
43
+ "lint": "tsc --noEmit",
44
+ "typecheck": "tsc --noEmit -p tsconfig.json"
45
+ }
46
+ }