@agentsmarket/pipeline-runtime 0.5.8 → 0.5.10

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.
@@ -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,10 +41,10 @@ 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
- export { resolveInputRefs, containsInputRef, resolveSpecialKeys, resolveDoubleBraceRefs, type PipelineRefContext, type DoubleBraceContext, } from './pipeline-refs.js';
47
+ export { resolveInputRefs, containsInputRef, inputRefName, resolveSpecialKeys, resolveDoubleBraceRefs, type PipelineRefContext, type DoubleBraceContext, } from './pipeline-refs.js';
48
48
  export { isToolSkill, invokeToolSkill, type ToolSkillContext, type ToolSkillResult, type ToolSkillHandler, } from './tools/tool-skills.js';
49
49
  export { validateOutputSpec, DEFAULT_OUTPUT_FORMAT, DEFAULT_OUTPUT_DELIVERY, DEFAULT_OUTPUT_EXPIRES_IN, MIN_OUTPUT_EXPIRES_IN, MAX_OUTPUT_EXPIRES_IN, type PipelineOutputSpec, type PipelineOutputDelivery, type PipelineOutputFormat, type PipelineOutputSpecError, } from './output-spec.js';
50
50
  export { validateJsonSchema, MAX_VALIDATION_DEPTH, type JsonSchema, type JsonSchemaType, type OutputValidationViolation, type OutputValidationResult, } from './output-schema.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, } 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, } 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,10 +25,10 @@ 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
- export { resolveInputRefs, containsInputRef, resolveSpecialKeys, resolveDoubleBraceRefs, } from './pipeline-refs.js';
31
+ export { resolveInputRefs, containsInputRef, inputRefName, resolveSpecialKeys, resolveDoubleBraceRefs, } from './pipeline-refs.js';
32
32
  export { isToolSkill, invokeToolSkill, } from './tools/tool-skills.js';
33
33
  export { validateOutputSpec, DEFAULT_OUTPUT_FORMAT, DEFAULT_OUTPUT_DELIVERY, DEFAULT_OUTPUT_EXPIRES_IN, MIN_OUTPUT_EXPIRES_IN, MAX_OUTPUT_EXPIRES_IN, } from './output-spec.js';
34
34
  export { validateJsonSchema, MAX_VALIDATION_DEPTH, } from './output-schema.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, } 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, } from './testing/index.js';
@@ -59,6 +59,18 @@ export declare function resolveDoubleBraceRefs(value: unknown, ctx: DoubleBraceC
59
59
  * in a consumer would drift the moment either side gains a form.
60
60
  */
61
61
  export declare function containsInputRef(value: unknown): boolean;
62
+ /**
63
+ * The input a value refers to — or null when it is not a reference.
64
+ *
65
+ * `containsInputRef` answers "is this a reference"; this answers "which
66
+ * input". A caller that has the declared defaults (the spec's `inputs:`)
67
+ * can then know what the value will be at run time, without running it.
68
+ *
69
+ * Only a value that IS the reference counts. `MiniMax-${input.suffix}`
70
+ * resolves to something only the runtime can compute, so the answer there
71
+ * is null — and the caller checks what it can and leaves the rest alone.
72
+ */
73
+ export declare function inputRefName(value: unknown): string | null;
62
74
  export declare function resolveInputRefs(value: unknown, ctx: PipelineRefContext): unknown;
63
75
  /**
64
76
  * Substitute built-in special keys (\$today, \$now, \$year, \$month, \$weekday)
@@ -197,6 +197,28 @@ export function resolveDoubleBraceRefs(value, ctx) {
197
197
  export function containsInputRef(value) {
198
198
  return typeof value === 'string' && INPUT_REF_PROBE.test(value);
199
199
  }
200
+ /**
201
+ * The input a value refers to — or null when it is not a reference.
202
+ *
203
+ * `containsInputRef` answers "is this a reference"; this answers "which
204
+ * input". A caller that has the declared defaults (the spec's `inputs:`)
205
+ * can then know what the value will be at run time, without running it.
206
+ *
207
+ * Only a value that IS the reference counts. `MiniMax-${input.suffix}`
208
+ * resolves to something only the runtime can compute, so the answer there
209
+ * is null — and the caller checks what it can and leaves the rest alone.
210
+ */
211
+ export function inputRefName(value) {
212
+ if (typeof value !== 'string')
213
+ return null;
214
+ const match = INPUT_REF_PROBE.exec(value);
215
+ if (!match)
216
+ return null;
217
+ const name = match[1] ?? match[2];
218
+ if (!name)
219
+ return null;
220
+ return match[0].length === value.length ? name : null;
221
+ }
200
222
  // One definition of the ref syntax, two regexes over it. Substitution needs the
201
223
  // global flag; the predicate must NOT have it — a global regex carries
202
224
  // `lastIndex` between `.test()` calls, so `containsInputRef` answered
@@ -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;
package/dist/stages.js CHANGED
@@ -721,6 +721,7 @@ correctionHint) {
721
721
  ...stageModelParams(stage),
722
722
  fields: stage.fields,
723
723
  outputFormat: stage.output_format,
724
+ outputSchema: stage.output_schema,
724
725
  messages: correctionHint
725
726
  ? [
726
727
  ...(ctxPrefix.length > 0 ? [{ role: 'user', content: ctxPrefix }] : []),
@@ -746,6 +747,7 @@ correctionHint) {
746
747
  ...stageModelParams(stage),
747
748
  fields: stage.fields,
748
749
  outputFormat: stage.output_format,
750
+ outputSchema: stage.output_schema,
749
751
  });
750
752
  })(), stage.retry, retryCtx);
751
753
  const result = ran.value;
@@ -1,6 +1,7 @@
1
1
  export { parseTestSpec, loadTestSpecFile, TestSpecParseError, type TestSpec, type Assertion } from './spec-parser.js';
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
+ export { mockValueForSchema } from './mock-schema.js';
4
5
  export { extractStage, StageNotFoundInSpecError, type ExtractedStage } from './stage-extractor.js';
5
6
  export { renderText } from './reporters/text.js';
6
7
  export { renderJson } from './reporters/json.js';
@@ -1,6 +1,7 @@
1
1
  export { parseTestSpec, loadTestSpecFile, TestSpecParseError } from './spec-parser.js';
2
2
  export { runAssertion, getPath } from './assertions.js';
3
3
  export { runSingleTest, runTestSuite, mockValueForField, buildMockProvider } from './runner.js';
4
+ export { mockValueForSchema } from './mock-schema.js';
4
5
  export { extractStage, StageNotFoundInSpecError } from './stage-extractor.js';
5
6
  export { renderText } from './reporters/text.js';
6
7
  export { renderJson } from './reporters/json.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * M9 — the values the mock knows by field name.
3
+ *
4
+ * These are the shapes the published example pipelines assert on
5
+ * (`markdown_report` matches /Mock report/, `summary.test_score >= 1`), so
6
+ * the mock has to answer with them rather than with a generic placeholder.
7
+ *
8
+ * They are also the candidates for a schema-shaped answer: a property named
9
+ * `summary` gets this value when it satisfies that property's schema, and a
10
+ * schema-driven value when it does not.
11
+ */
12
+ /** Field name → the value the mock answers with. */
13
+ export declare const KNOWN_FIELDS: Record<string, unknown>;
14
+ export declare function mockValueForField(field: string): unknown;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * M9 — the values the mock knows by field name.
3
+ *
4
+ * These are the shapes the published example pipelines assert on
5
+ * (`markdown_report` matches /Mock report/, `summary.test_score >= 1`), so
6
+ * the mock has to answer with them rather than with a generic placeholder.
7
+ *
8
+ * They are also the candidates for a schema-shaped answer: a property named
9
+ * `summary` gets this value when it satisfies that property's schema, and a
10
+ * schema-driven value when it does not.
11
+ */
12
+ /** Field name → the value the mock answers with. */
13
+ export const KNOWN_FIELDS = {
14
+ findings: [{ severity: 'high', line: 10, description: 'mock finding: unsanitized input', fix_suggestion: 'sanitize input', cwe_id: 'CWE-89', confidence: 0.9 }],
15
+ summary: { total_findings: 1, critical_count: 0, high_count: 1, medium_count: 0, low_count: 0, overall_risk_score: 7.5, total_packages: 3, vulnerable_count: 1, perf_score: 6.5, estimated_speedup: 'mock 2x speedup', style_score: 7.0, regions_analyzed: 1, doc_score: 7.0, test_score: 7.0, refactor_score: 7.0, design_score: 7.0, endpoints_reviewed: 1, units_analyzed: 1 },
16
+ recommendations: ['mock recommendation: sanitize inputs'],
17
+ markdown_report: '# Mock report\n\nMock summary.\n',
18
+ packages: [{ name: 'mock-pkg', version: '1.0.0', is_vulnerable: true, cves: [{ id: 'CVE-2024-0001', severity: 'high', description: 'mock CVE', fix_version: '1.0.1', confidence: 0.9 }], fix_version: '1.0.1' }],
19
+ stats: { lines_scanned: 10, hunks_scanned: 1 },
20
+ rejected: [],
21
+ new_findings_count: 0,
22
+ };
23
+ export function mockValueForField(field) {
24
+ return field in KNOWN_FIELDS ? KNOWN_FIELDS[field] : `mock-${field}`;
25
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * M9 — a mock answer that satisfies a JSON Schema.
3
+ *
4
+ * The mock used to answer by field name (`mockValueForField`), and a stage
5
+ * that declares `output_schema` without `fields` got `{"result":"mock-output"}`
6
+ * — which no schema accepts. So a spec with an output schema was not
7
+ * executable in mock mode: the stage failed its own validation and the test
8
+ * errored out. The runtime validated the answer correctly; the mock simply
9
+ * did not know what was being asked for.
10
+ *
11
+ * This builds the answer from the schema instead: the same shape the prompt
12
+ * asks the model for, so the mock answer passes the check the model answer
13
+ * has to pass. That is what makes `pipeline test` a gate: a spec whose
14
+ * schema cannot be satisfied fails the test, and a spec that can be
15
+ * satisfied passes.
16
+ *
17
+ * The schema is the draft-07 subset the runtime supports (see
18
+ * `output-schema.ts`). Unsupported keywords are rejected by the runtime's
19
+ * own meta-validation before this ever runs, so the shapes handled here are
20
+ * the ones the runtime accepts.
21
+ */
22
+ import type { JsonSchema } from '../output-schema.js';
23
+ /**
24
+ * A value that satisfies `schema`.
25
+ *
26
+ * Every `properties` entry gets a value — not only the required ones — so
27
+ * that a schema which asks for optional fields is still answered completely.
28
+ * A schema with no `properties` at all yields `{}`, which is the honest
29
+ * answer: there is nothing to produce.
30
+ */
31
+ export declare function mockValueForSchema(schema: JsonSchema | undefined, depth?: number): unknown;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * M9 — a mock answer that satisfies a JSON Schema.
3
+ *
4
+ * The mock used to answer by field name (`mockValueForField`), and a stage
5
+ * that declares `output_schema` without `fields` got `{"result":"mock-output"}`
6
+ * — which no schema accepts. So a spec with an output schema was not
7
+ * executable in mock mode: the stage failed its own validation and the test
8
+ * errored out. The runtime validated the answer correctly; the mock simply
9
+ * did not know what was being asked for.
10
+ *
11
+ * This builds the answer from the schema instead: the same shape the prompt
12
+ * asks the model for, so the mock answer passes the check the model answer
13
+ * has to pass. That is what makes `pipeline test` a gate: a spec whose
14
+ * schema cannot be satisfied fails the test, and a spec that can be
15
+ * satisfied passes.
16
+ *
17
+ * The schema is the draft-07 subset the runtime supports (see
18
+ * `output-schema.ts`). Unsupported keywords are rejected by the runtime's
19
+ * own meta-validation before this ever runs, so the shapes handled here are
20
+ * the ones the runtime accepts.
21
+ */
22
+ import { validateAgainstSchema } from '../output-schema-validate.js';
23
+ import { KNOWN_FIELDS, mockValueForField } from './mock-fields.js';
24
+ /** Depth guard, mirroring the runtime's own validation bound. */
25
+ const MAX_DEPTH = 32;
26
+ /**
27
+ * A value that satisfies `schema`.
28
+ *
29
+ * Every `properties` entry gets a value — not only the required ones — so
30
+ * that a schema which asks for optional fields is still answered completely.
31
+ * A schema with no `properties` at all yields `{}`, which is the honest
32
+ * answer: there is nothing to produce.
33
+ */
34
+ export function mockValueForSchema(schema, depth = 0) {
35
+ if (!schema || depth > MAX_DEPTH)
36
+ return {};
37
+ // An enum is a closed set: the first value is the answer.
38
+ if (Array.isArray(schema.enum) && schema.enum.length > 0)
39
+ return schema.enum[0];
40
+ const type = pickType(schema);
41
+ switch (type) {
42
+ case 'object': {
43
+ const obj = {};
44
+ for (const [key, sub] of Object.entries(schema.properties ?? {})) {
45
+ obj[key] = valueForProperty(key, sub, depth + 1);
46
+ }
47
+ return obj;
48
+ }
49
+ case 'array': {
50
+ const items = schema.items;
51
+ if (!items)
52
+ return [];
53
+ // One element is enough to satisfy `minItems: 1` and to show the shape.
54
+ return [mockValueForSchema(items, depth + 1)];
55
+ }
56
+ case 'string':
57
+ return mockString(schema);
58
+ case 'integer':
59
+ return 1;
60
+ case 'number':
61
+ return 1;
62
+ case 'boolean':
63
+ return true;
64
+ case 'null':
65
+ return null;
66
+ default:
67
+ // No type declared: an object is the safest answer, because a schema
68
+ // without a type accepts an object.
69
+ return {};
70
+ }
71
+ }
72
+ /**
73
+ * The value for one property.
74
+ *
75
+ * A property the mock knows by name gets that value — but only when the
76
+ * value actually satisfies this property's schema. Otherwise the schema
77
+ * decides, because a known value that does not fit the schema is a worse
78
+ * answer than a generic one that does.
79
+ */
80
+ function valueForProperty(key, schema, depth) {
81
+ const known = key in KNOWN_FIELDS ? KNOWN_FIELDS[key] : mockValueForField(key);
82
+ if (validateAgainstSchema(known, schema).length === 0)
83
+ return known;
84
+ return mockValueForSchema(schema, depth);
85
+ }
86
+ function pickType(schema) {
87
+ const declared = schema.type;
88
+ if (Array.isArray(declared)) {
89
+ // The first type that is not null — null alone would answer "nothing".
90
+ return declared.find((t) => t !== 'null') ?? 'null';
91
+ }
92
+ if (typeof declared === 'string')
93
+ return declared;
94
+ if (schema.properties)
95
+ return 'object';
96
+ if (schema.items)
97
+ return 'array';
98
+ return 'object';
99
+ }
100
+ function mockString(schema) {
101
+ const min = schema.minLength ?? 0;
102
+ let value = 'mock';
103
+ if (value.length < min)
104
+ value = value.padEnd(min, 'x');
105
+ if (schema.pattern) {
106
+ // A pattern cannot be satisfied by guessing. The honest answer is a
107
+ // string that at least honours the length, and the test fails on the
108
+ // pattern — which is the point: a schema nobody can satisfy is a spec
109
+ // nobody can run.
110
+ return value;
111
+ }
112
+ return value;
113
+ }
@@ -12,7 +12,7 @@ export interface SingleTestResult {
12
12
  output?: unknown;
13
13
  }
14
14
  export declare function buildMockProvider(): LLMProvider;
15
- export declare function mockValueForField(field: string): unknown;
15
+ export { mockValueForField } from './mock-fields.js';
16
16
  export interface RunTestOptions {
17
17
  baseDir?: string;
18
18
  timeoutMs?: number;
@@ -9,6 +9,8 @@ import { createModelResolver } from '../model-resolver.js';
9
9
  import { StaticPricingResolver } from '../pricing.js';
10
10
  import { LLMProviderRegistry } from '../provider-registry.js';
11
11
  import { runAssertion } from './assertions.js';
12
+ import { mockValueForSchema } from './mock-schema.js';
13
+ import { mockValueForField } from './mock-fields.js';
12
14
  import { extractStage } from './stage-extractor.js';
13
15
  export function buildMockProvider() {
14
16
  return {
@@ -25,13 +27,20 @@ export function buildMockProvider() {
25
27
  async generateText(prompt, opts) {
26
28
  await new Promise((r) => setTimeout(r, 5));
27
29
  const fields = opts?.fields ?? [];
30
+ // A stage that declares an output schema is validated against it, and
31
+ // the mock has to answer the shape the schema asks for — a mock answer
32
+ // that does not satisfy the schema fails the stage's own validation,
33
+ // and the test errors out instead of testing anything.
34
+ if (opts?.outputSchema) {
35
+ const shaped = mockValueForSchema(opts.outputSchema);
36
+ return { text: JSON.stringify(shaped), usage: { inputTokens: 10, outputTokens: 10 } };
37
+ }
28
38
  if (opts?.outputFormat === 'structured_json' || fields.length > 0) {
29
39
  const obj = {};
30
40
  for (const f of fields)
31
41
  obj[f] = mockValueForField(f);
32
42
  if (Object.keys(obj).length === 0)
33
43
  obj['result'] = 'mock-output';
34
- void prompt;
35
44
  return { text: JSON.stringify(obj), usage: { inputTokens: 10, outputTokens: 10 } };
36
45
  }
37
46
  if (opts?.outputFormat === 'markdown')
@@ -42,19 +51,7 @@ export function buildMockProvider() {
42
51
  },
43
52
  };
44
53
  }
45
- export function mockValueForField(field) {
46
- switch (field) {
47
- case 'findings': return [{ severity: 'high', line: 10, description: 'mock finding: unsanitized input', fix_suggestion: 'sanitize input', cwe_id: 'CWE-89', confidence: 0.9 }];
48
- case 'summary': return { total_findings: 1, critical_count: 0, high_count: 1, medium_count: 0, low_count: 0, overall_risk_score: 7.5, total_packages: 3, vulnerable_count: 1, perf_score: 6.5, estimated_speedup: 'mock 2x speedup', style_score: 7.0, regions_analyzed: 1, doc_score: 7.0, test_score: 7.0, refactor_score: 7.0, design_score: 7.0, endpoints_reviewed: 1, units_analyzed: 1 };
49
- case 'recommendations': return ['mock recommendation: sanitize inputs'];
50
- case 'markdown_report': return '# Mock report\n\nMock summary.\n';
51
- case 'packages': return [{ name: 'mock-pkg', version: '1.0.0', is_vulnerable: true, cves: [{ id: 'CVE-2024-0001', severity: 'high', description: 'mock CVE', fix_version: '1.0.1', confidence: 0.9 }], fix_version: '1.0.1' }];
52
- case 'stats': return { lines_scanned: 10, hunks_scanned: 1 };
53
- case 'rejected': return [];
54
- case 'new_findings_count': return 0;
55
- default: return `mock-${field}`;
56
- }
57
- }
54
+ export { mockValueForField } from './mock-fields.js';
58
55
  function buildLocalFetcher(pipelineDir) {
59
56
  return async (id) => {
60
57
  const candidate = path.join(pipelineDir, `${id}.yaml`);
package/dist/types.d.ts CHANGED
@@ -54,6 +54,17 @@ export interface GenerateOptions {
54
54
  * demo/QA without a real LLM.
55
55
  */
56
56
  outputFormat?: OutputFormat;
57
+ /**
58
+ * The stage's `output_schema`, when it has one.
59
+ *
60
+ * The executor validates the answer against this schema before the next
61
+ * stage runs, so a mock that does not know the schema cannot produce a
62
+ * valid answer: the stage fails its own validation and the test errors
63
+ * out instead of testing anything. A provider that can shape its answer
64
+ * (the mock) uses this; a real provider ignores it and answers the
65
+ * prompt, which asks for the same shape.
66
+ */
67
+ outputSchema?: import('./output-schema.js').JsonSchema;
57
68
  /**
58
69
  * M1 NEW — Multimodal messages (image / audio / video parts). When set,
59
70
  * takes precedence over the string `prompt` argument. Adapters transform
@@ -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.8",
3
+ "version": "0.5.10",
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",