@agentsmarket/pipeline-runtime 0.5.2 → 0.5.3
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 +2 -2
- package/dist/index.js +2 -2
- package/dist/pipeline-refs.d.ts +12 -0
- package/dist/pipeline-refs.js +22 -1
- package/dist/provider-registry.d.ts +9 -0
- package/dist/provider-registry.js +19 -3
- package/dist/stages.js +27 -2
- package/dist/webhook.js +0 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type { OpenAIChatProviderOptions } from './providers/openai-chat.js';
|
|
|
17
17
|
export { AnthropicProvider } from './providers/anthropic.js';
|
|
18
18
|
export type { AnthropicProviderOptions } from './providers/anthropic.js';
|
|
19
19
|
export { FallbackProvider, createFallbackProvider } from './fallback.js';
|
|
20
|
-
export { PROVIDER_REGISTRY, getProvider, validateProviderName, supportsModel, validateProviderModel, listProviders, listSupportedModels, listVisionCapableModels, isVisionCapable, assertMultimodalSupported, validateR6Spec, migrateProviderField, ProviderSpecNotFoundError, ProviderModelMismatchError, LLMProviderRegistry, ProviderMismatchError, UnknownProviderError, type Provider, type ProviderSpec, type R6StageInput, type R6SpecInput, type R6ValidationResult, } from './provider-registry.js';
|
|
20
|
+
export { PROVIDER_REGISTRY, getProvider, validateProviderName, supportsModel, validateProviderModel, listProviders, listSupportedModels, listVisionCapableModels, isVisionCapable, assertMultimodalSupported, validateR6Spec, R6_PROVIDER_REQUIRED, migrateProviderField, ProviderSpecNotFoundError, ProviderModelMismatchError, LLMProviderRegistry, ProviderMismatchError, UnknownProviderError, type Provider, type ProviderSpec, type R6StageInput, type R6SpecInput, type R6ValidationResult, } from './provider-registry.js';
|
|
21
21
|
export { expandPipelineText, resolveEnvVars, resolveEnvVarsInObject, loadPipelineYaml, parseVariableSpec, MissingEnvVarError, } from './resolve-vars.js';
|
|
22
22
|
export type { EnvLike } from './resolve-vars.js';
|
|
23
23
|
export { isRetryableStatus, computeBackoffMs, RetryExhaustedError, RetryAttemptError, DEFAULT_RETRY, DEFAULT_RETRYABLE_STATUSES, } from './retry.js';
|
|
@@ -44,7 +44,7 @@ export { executeStage, runPipelineV2, makeWhenResolve, parseUsesEntry, parseUses
|
|
|
44
44
|
export { validateInputs, formatInputErrors, 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, resolveSpecialKeys, resolveDoubleBraceRefs, type PipelineRefContext, type DoubleBraceContext, } from './pipeline-refs.js';
|
|
47
|
+
export { resolveInputRefs, containsInputRef, 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';
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { OpenRouterProvider } from './adapters/openrouter.js';
|
|
|
11
11
|
export { OpenAIChatProvider } from './providers/openai-chat.js';
|
|
12
12
|
export { AnthropicProvider } from './providers/anthropic.js';
|
|
13
13
|
export { FallbackProvider, createFallbackProvider } from './fallback.js';
|
|
14
|
-
export { PROVIDER_REGISTRY, getProvider, validateProviderName, supportsModel, validateProviderModel, listProviders, listSupportedModels, listVisionCapableModels, isVisionCapable, assertMultimodalSupported, validateR6Spec, migrateProviderField, ProviderSpecNotFoundError, ProviderModelMismatchError, LLMProviderRegistry, ProviderMismatchError, UnknownProviderError, } from './provider-registry.js';
|
|
14
|
+
export { PROVIDER_REGISTRY, getProvider, validateProviderName, supportsModel, validateProviderModel, listProviders, listSupportedModels, listVisionCapableModels, isVisionCapable, assertMultimodalSupported, validateR6Spec, R6_PROVIDER_REQUIRED, migrateProviderField, ProviderSpecNotFoundError, ProviderModelMismatchError, LLMProviderRegistry, ProviderMismatchError, UnknownProviderError, } from './provider-registry.js';
|
|
15
15
|
export { expandPipelineText, resolveEnvVars, resolveEnvVarsInObject, loadPipelineYaml, parseVariableSpec, MissingEnvVarError, } from './resolve-vars.js';
|
|
16
16
|
export { isRetryableStatus, computeBackoffMs, RetryExhaustedError, RetryAttemptError, DEFAULT_RETRY, DEFAULT_RETRYABLE_STATUSES, } from './retry.js';
|
|
17
17
|
export { parseComparison, parseWhenLiteral, evaluateComparison, evaluateWhen, shouldSkipStage, validateWhenShape, WhenParseError, } from './when.js';
|
|
@@ -28,7 +28,7 @@ export { executeStage, runPipelineV2, makeWhenResolve, parseUsesEntry, parseUses
|
|
|
28
28
|
export { validateInputs, formatInputErrors, } 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, resolveSpecialKeys, resolveDoubleBraceRefs, } from './pipeline-refs.js';
|
|
31
|
+
export { resolveInputRefs, containsInputRef, 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';
|
package/dist/pipeline-refs.d.ts
CHANGED
|
@@ -47,6 +47,18 @@ export interface DoubleBraceContext {
|
|
|
47
47
|
visiting?: Set<string>;
|
|
48
48
|
}
|
|
49
49
|
export declare function resolveDoubleBraceRefs(value: unknown, ctx: DoubleBraceContext): unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a value carries an input reference (`$input.X` / `${input.X}`).
|
|
52
|
+
*
|
|
53
|
+
* Callers that must inspect a value BEFORE inputs are known use this to tell
|
|
54
|
+
* "this is a literal" from "this will be substituted later". Spec validation is
|
|
55
|
+
* the case that matters: `provider: ${input.provider}` cannot be checked against
|
|
56
|
+
* the provider registry at that point, because the actual value is not known yet.
|
|
57
|
+
*
|
|
58
|
+
* Lives here so the ref syntax has one definition — a second copy of the pattern
|
|
59
|
+
* in a consumer would drift the moment either side gains a form.
|
|
60
|
+
*/
|
|
61
|
+
export declare function containsInputRef(value: unknown): boolean;
|
|
50
62
|
export declare function resolveInputRefs(value: unknown, ctx: PipelineRefContext): unknown;
|
|
51
63
|
/**
|
|
52
64
|
* Substitute built-in special keys (\$today, \$now, \$year, \$month, \$weekday)
|
package/dist/pipeline-refs.js
CHANGED
|
@@ -183,7 +183,28 @@ export function resolveDoubleBraceRefs(value, ctx) {
|
|
|
183
183
|
}
|
|
184
184
|
return value;
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Whether a value carries an input reference (`$input.X` / `${input.X}`).
|
|
188
|
+
*
|
|
189
|
+
* Callers that must inspect a value BEFORE inputs are known use this to tell
|
|
190
|
+
* "this is a literal" from "this will be substituted later". Spec validation is
|
|
191
|
+
* the case that matters: `provider: ${input.provider}` cannot be checked against
|
|
192
|
+
* the provider registry at that point, because the actual value is not known yet.
|
|
193
|
+
*
|
|
194
|
+
* Lives here so the ref syntax has one definition — a second copy of the pattern
|
|
195
|
+
* in a consumer would drift the moment either side gains a form.
|
|
196
|
+
*/
|
|
197
|
+
export function containsInputRef(value) {
|
|
198
|
+
return typeof value === 'string' && INPUT_REF_PROBE.test(value);
|
|
199
|
+
}
|
|
200
|
+
// One definition of the ref syntax, two regexes over it. Substitution needs the
|
|
201
|
+
// global flag; the predicate must NOT have it — a global regex carries
|
|
202
|
+
// `lastIndex` between `.test()` calls, so `containsInputRef` answered
|
|
203
|
+
// true/false/true for the same string and every second stage that used
|
|
204
|
+
// `${input.provider}` was validated as a literal.
|
|
205
|
+
const INPUT_REF_SRC = String.raw `\$\{\s*input\.([A-Za-z_][A-Za-z0-9_]*)\s*\}|\$input\.([A-Za-z_][A-Za-z0-9_]*)`;
|
|
206
|
+
const INPUT_REF_PATTERN = new RegExp(INPUT_REF_SRC, 'g');
|
|
207
|
+
const INPUT_REF_PROBE = new RegExp(INPUT_REF_SRC);
|
|
187
208
|
const STAGE_OUTPUT_REF_PATTERN = /\$\{\s*stages\.([A-Za-z_][A-Za-z0-9_.-]*)\.output\s*\}|\$stages\.([A-Za-z_][A-Za-z0-9_.-]*)\.output/g;
|
|
188
209
|
const SPECIAL_KEYS = {
|
|
189
210
|
today: () => new Date().toISOString().slice(0, 10),
|
|
@@ -153,6 +153,15 @@ export interface R6ValidationResult {
|
|
|
153
153
|
* 3. The stage's effective model = `stage.model ?? spec.defaults?.model ?? 'MiniMax-M3'`.
|
|
154
154
|
* Stages using `uses:` (skill invocation) skip the gate entirely.
|
|
155
155
|
*/
|
|
156
|
+
/**
|
|
157
|
+
* The R6 remedy text, in one place.
|
|
158
|
+
*
|
|
159
|
+
* It used to name only `provider: minimax`, and that is how all six canonical
|
|
160
|
+
* pipelines came to hardcode it — the message was followed literally. Since a
|
|
161
|
+
* stage can now take its provider from a pipeline input, the message has to say
|
|
162
|
+
* so, otherwise the same trap is re-set for the next author.
|
|
163
|
+
*/
|
|
164
|
+
export declare const R6_PROVIDER_REQUIRED: string;
|
|
156
165
|
export declare function validateR6Spec(spec: R6SpecInput): R6ValidationResult;
|
|
157
166
|
/**
|
|
158
167
|
* One-shot migration: adds `provider: minimax` to every LLM stage
|
|
@@ -226,6 +226,17 @@ export function listSupportedModels(providerName) {
|
|
|
226
226
|
* 3. The stage's effective model = `stage.model ?? spec.defaults?.model ?? 'MiniMax-M3'`.
|
|
227
227
|
* Stages using `uses:` (skill invocation) skip the gate entirely.
|
|
228
228
|
*/
|
|
229
|
+
/**
|
|
230
|
+
* The R6 remedy text, in one place.
|
|
231
|
+
*
|
|
232
|
+
* It used to name only `provider: minimax`, and that is how all six canonical
|
|
233
|
+
* pipelines came to hardcode it — the message was followed literally. Since a
|
|
234
|
+
* stage can now take its provider from a pipeline input, the message has to say
|
|
235
|
+
* so, otherwise the same trap is re-set for the next author.
|
|
236
|
+
*/
|
|
237
|
+
export const R6_PROVIDER_REQUIRED = `R6 requires explicit 'provider:' field (auto-dispatch by model name removed). ` +
|
|
238
|
+
`Add 'provider: minimax' (or openrouter/openai/anthropic/replicate), or pick it ` +
|
|
239
|
+
`per run with provider: \${input.provider} and a declared default under inputs:.`;
|
|
229
240
|
export function validateR6Spec(spec) {
|
|
230
241
|
const errors = [];
|
|
231
242
|
const stages = spec.stages ?? [];
|
|
@@ -240,14 +251,18 @@ export function validateR6Spec(spec) {
|
|
|
240
251
|
continue;
|
|
241
252
|
const stageLabel = `Stage '${stage.id ?? '<no-id>'}'`;
|
|
242
253
|
if (typeof stage.provider !== 'string' || stage.provider.length === 0) {
|
|
243
|
-
errors.push(`${stageLabel}:
|
|
244
|
-
`(auto-dispatch by model name removed). Add 'provider: minimax' ` +
|
|
245
|
-
`(or openrouter/openai/anthropic/replicate).`);
|
|
254
|
+
errors.push(`${stageLabel}: ${R6_PROVIDER_REQUIRED}`);
|
|
246
255
|
continue;
|
|
247
256
|
}
|
|
248
257
|
const effectiveModel = hasModel
|
|
249
258
|
? stage.model
|
|
250
259
|
: (spec.defaults?.model ?? 'MiniMax-M3');
|
|
260
|
+
// A provider or model that will be substituted from pipeline inputs has no
|
|
261
|
+
// value yet at spec-validation time — this function only sees the spec. The
|
|
262
|
+
// runtime resolves both fields before dispatch and rejects an unknown
|
|
263
|
+
// provider there, against the real value.
|
|
264
|
+
if (containsInputRef(stage.provider) || containsInputRef(effectiveModel))
|
|
265
|
+
continue;
|
|
251
266
|
try {
|
|
252
267
|
validateProviderModel(stage.provider, effectiveModel);
|
|
253
268
|
}
|
|
@@ -324,6 +339,7 @@ export class ProviderModelMismatchError extends Error {
|
|
|
324
339
|
}
|
|
325
340
|
}
|
|
326
341
|
import { MultimodalModelUnsupportedError } from './multimodal.js';
|
|
342
|
+
import { containsInputRef } from './pipeline-refs.js';
|
|
327
343
|
/**
|
|
328
344
|
* Thrown when a stage declares `provider: X` but X is not in the
|
|
329
345
|
* registry passed to the executor.
|
package/dist/stages.js
CHANGED
|
@@ -260,6 +260,26 @@ export class StageBadConfigError extends Error {
|
|
|
260
260
|
this.name = 'BAD_STAGE';
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Substitute `${input.X}` / `$input.X` references in `stage.provider` and
|
|
265
|
+
* `stage.model` before they reach the resolver. Same walking strategy that
|
|
266
|
+
* already runs over `chainedInput` (stage arguments) at line ~830; literals
|
|
267
|
+
* pass through unchanged and unresolved references stay as their text form
|
|
268
|
+
* (matching resolveInputRefs:266 — pipeline-refs.ts).
|
|
269
|
+
*
|
|
270
|
+
* Returns a shallow clone when at least one field actually changes; returns
|
|
271
|
+
* the same `stage` object otherwise so we don't allocate per-call.
|
|
272
|
+
*/
|
|
273
|
+
function resolveStageMetaRefs(stage, inputs) {
|
|
274
|
+
const resolvedProvider = resolveInputRefs(stage.provider, { inputs, previousOutputs: {} });
|
|
275
|
+
const resolvedModelRaw = resolveInputRefs(stage.model, { inputs, previousOutputs: {} });
|
|
276
|
+
const resolvedModel = typeof resolvedModelRaw === 'string' ? resolvedModelRaw : stage.model;
|
|
277
|
+
const providerChanged = typeof resolvedProvider === 'string' && resolvedProvider !== stage.provider;
|
|
278
|
+
const modelChanged = typeof stage.model === 'string' && resolvedModel !== stage.model;
|
|
279
|
+
if (!providerChanged && !modelChanged)
|
|
280
|
+
return stage;
|
|
281
|
+
return { ...stage, provider: resolvedProvider, model: resolvedModel };
|
|
282
|
+
}
|
|
263
283
|
function resolveStageProvider(deps, stage, model) {
|
|
264
284
|
// F12: --mock must override explicit per-stage `provider:` declarations,
|
|
265
285
|
// otherwise canonical seeded pipelines (which all declare
|
|
@@ -717,16 +737,21 @@ async function runOneStage(stage, shared) {
|
|
|
717
737
|
for (const w of collectRuntimeWarnings(stage, shared.constraints)) {
|
|
718
738
|
shared.emit({ type: 'stage.started', at: new Date().toISOString(), stageId, reason: 'normal' });
|
|
719
739
|
}
|
|
740
|
+
// Substitute `${input.X}` references in provider/model before the resolver
|
|
741
|
+
// sees them. Without this a stage like `provider: ${input.provider}` reaches
|
|
742
|
+
// the registry with the verbatim string and throws
|
|
743
|
+
// `Provider '${input.provider}' is not registered`. Literals pass through.
|
|
744
|
+
const effectiveStage = resolveStageMetaRefs(stage, shared.opts.inputs);
|
|
720
745
|
const t0 = Date.now();
|
|
721
746
|
try {
|
|
722
|
-
const stageModel =
|
|
747
|
+
const stageModel = effectiveStage.model ?? shared.opts.spec.defaults?.model ?? 'MiniMax-M3';
|
|
723
748
|
const stageDeps = shared.opts.providerResolver
|
|
724
749
|
? { ...shared.opts.deps, provider: shared.opts.providerResolver(stageModel) }
|
|
725
750
|
: shared.opts.deps;
|
|
726
751
|
const stageDepsWithSink = shared.opts.eventSink
|
|
727
752
|
? { ...stageDeps, eventSink: shared.opts.eventSink }
|
|
728
753
|
: stageDeps;
|
|
729
|
-
const result = await runStageWithOutputValidation(
|
|
754
|
+
const result = await runStageWithOutputValidation(effectiveStage, shared.opts.spec, { inputs: shared.opts.inputs, previousOutputs: shared.outputs }, stageDepsWithSink);
|
|
730
755
|
const ms = Date.now() - t0;
|
|
731
756
|
shared.outputs[stageId] = result.output;
|
|
732
757
|
shared.stageTimings.push({
|
package/dist/webhook.js
CHANGED
|
File without changes
|
package/package.json
CHANGED