@agentsmarket/pipeline-runtime 0.1.0 → 0.1.2
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/adapters/minimax.js +3 -2
- package/dist/adapters/openrouter.js +8 -1
- package/dist/stages.d.ts +7 -0
- package/dist/stages.js +11 -2
- package/dist/types.d.ts +32 -0
- package/package.json +1 -1
package/dist/adapters/minimax.js
CHANGED
|
@@ -37,13 +37,14 @@ export class MiniMaxProvider {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
async generateText(prompt, opts = {}) {
|
|
40
|
-
const model = opts.complexity === 'complex' ? this.complexModel : this.simpleModel;
|
|
40
|
+
const model = opts.model ?? (opts.complexity === 'complex' ? this.complexModel : this.simpleModel);
|
|
41
41
|
const response = await this.client.messages.create({
|
|
42
42
|
model,
|
|
43
43
|
max_tokens: opts.maxTokens ?? 2048,
|
|
44
44
|
temperature: opts.temperature ?? 0.7,
|
|
45
|
+
...(opts.topP !== undefined ? { top_p: opts.topP } : {}),
|
|
45
46
|
system: opts.system,
|
|
46
|
-
stop_sequences: opts.stopSequences,
|
|
47
|
+
...(opts.stopSequences ? { stop_sequences: opts.stopSequences } : {}),
|
|
47
48
|
messages: [{ role: 'user', content: prompt }],
|
|
48
49
|
});
|
|
49
50
|
const text = response.content
|
|
@@ -45,11 +45,18 @@ export class OpenRouterProvider {
|
|
|
45
45
|
model,
|
|
46
46
|
max_tokens: opts.maxTokens ?? 2048,
|
|
47
47
|
temperature: opts.temperature ?? 0.7,
|
|
48
|
+
...(opts.topP !== undefined ? { top_p: opts.topP } : {}),
|
|
49
|
+
...(opts.seed !== undefined ? { seed: opts.seed } : {}),
|
|
50
|
+
...(opts.reasoningEffort !== undefined ? { reasoning_effort: opts.reasoningEffort } : {}),
|
|
51
|
+
...(opts.responseFormat !== undefined
|
|
52
|
+
? { response_format: { type: opts.responseFormat } }
|
|
53
|
+
: {}),
|
|
48
54
|
messages: [
|
|
49
55
|
...(opts.system ? [{ role: 'system', content: opts.system }] : []),
|
|
50
56
|
{ role: 'user', content: prompt },
|
|
51
57
|
],
|
|
52
|
-
stop: opts.stopSequences,
|
|
58
|
+
...(opts.stopSequences ? { stop: opts.stopSequences } : {}),
|
|
59
|
+
...(opts.providerParams ?? {}),
|
|
53
60
|
});
|
|
54
61
|
const text = response.choices[0]?.message?.content ?? '';
|
|
55
62
|
const usage = {
|
package/dist/stages.d.ts
CHANGED
|
@@ -72,6 +72,13 @@ export interface StageExecutorDeps {
|
|
|
72
72
|
* R6.4+R6.6 will make the registry path the default.
|
|
73
73
|
*/
|
|
74
74
|
registry?: LLMProviderRegistry;
|
|
75
|
+
/**
|
|
76
|
+
* Optional. When true, the executor ignores per-stage `provider:`
|
|
77
|
+
* declarations and uses the top-level `provider` (typically the
|
|
78
|
+
* CLI MockProvider) for every LLM stage. Lets `--mock` work for
|
|
79
|
+
* pipelines that declare `provider: minimax` etc. (F12).
|
|
80
|
+
*/
|
|
81
|
+
forceMock?: boolean;
|
|
75
82
|
pricing: PricingResolver;
|
|
76
83
|
modelResolver: ModelResolver;
|
|
77
84
|
fetchSkill: (skillId: string) => Promise<SkillLike | null>;
|
package/dist/stages.js
CHANGED
|
@@ -185,6 +185,12 @@ export class StageBadConfigError extends Error {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
function resolveStageProvider(deps, stage, model) {
|
|
188
|
+
// F12: --mock must override explicit per-stage `provider:` declarations,
|
|
189
|
+
// otherwise canonical seeded pipelines (which all declare
|
|
190
|
+
// `provider: minimax`) would hit the real API and 429 instead of the
|
|
191
|
+
// deterministic mock. forceMock wins over registry resolution.
|
|
192
|
+
if (deps.forceMock)
|
|
193
|
+
return deps.provider;
|
|
188
194
|
if (!stage.provider)
|
|
189
195
|
return deps.provider;
|
|
190
196
|
if (!deps.registry) {
|
|
@@ -192,7 +198,7 @@ function resolveStageProvider(deps, stage, model) {
|
|
|
192
198
|
}
|
|
193
199
|
return deps.registry.resolveWithSupports(stage.provider, model);
|
|
194
200
|
}
|
|
195
|
-
async function invokeSkill(skill, input, previousContext, skillLabel, provider, retry, retryCtx) {
|
|
201
|
+
async function invokeSkill(skill, input, previousContext, skillLabel, provider, retry, retryCtx, outputFormat) {
|
|
196
202
|
const t0 = Date.now();
|
|
197
203
|
const inputStr = JSON.stringify(input ?? {}, null, 2);
|
|
198
204
|
const fullMd = skill.full_md ?? '';
|
|
@@ -202,6 +208,7 @@ async function invokeSkill(skill, input, previousContext, skillLabel, provider,
|
|
|
202
208
|
system: `${skillLabel}\n${description}`,
|
|
203
209
|
complexity: 'complex',
|
|
204
210
|
maxTokens: 4096,
|
|
211
|
+
...(outputFormat ? { outputFormat } : {}),
|
|
205
212
|
}), retry, retryCtx);
|
|
206
213
|
return { result: ran.value, durationMs: Date.now() - t0, attempts: ran.attempts };
|
|
207
214
|
}
|
|
@@ -355,7 +362,7 @@ export async function executeStage(stage, pipeline, ctx, deps) {
|
|
|
355
362
|
const resolvedInput = typeof chainedInput === 'string'
|
|
356
363
|
? resolveStageOutputRefs(chainedInput, ctx.previousOutputs)
|
|
357
364
|
: chainedInput;
|
|
358
|
-
const { result, durationMs } = await invokeSkill(skill, resolvedInput, previousContext, label, stageProvider, stage.retry, retryCtx);
|
|
365
|
+
const { result, durationMs } = await invokeSkill(skill, resolvedInput, previousContext, label, stageProvider, stage.retry, retryCtx, stage.output_format);
|
|
359
366
|
lastResult = result;
|
|
360
367
|
chainedInput = { input_from_previous_skill: result.text };
|
|
361
368
|
nestedCalls.push({
|
|
@@ -396,6 +403,8 @@ export async function executeStage(stage, pipeline, ctx, deps) {
|
|
|
396
403
|
system: resolvedSystem,
|
|
397
404
|
complexity: stage.model?.includes('M3') || stage.model?.includes('opus') ? 'complex' : 'simple',
|
|
398
405
|
maxTokens: 4096,
|
|
406
|
+
fields: stage.fields,
|
|
407
|
+
outputFormat: stage.output_format,
|
|
399
408
|
}), stage.retry, retryCtx);
|
|
400
409
|
const result = ran.value;
|
|
401
410
|
const costMicroUsdc = await deps.pricing.resolveCostMicroUsdc(model, result.usage);
|
package/dist/types.d.ts
CHANGED
|
@@ -21,6 +21,38 @@ export interface GenerateOptions {
|
|
|
21
21
|
stopSequences?: string[];
|
|
22
22
|
/** Provider-specific model id (e.g. "anthropic/claude-3.5-sonnet" for OpenRouter). */
|
|
23
23
|
model?: string;
|
|
24
|
+
/** Nucleus sampling 0-1. Optional. Mutually exclusive with `temperature` per provider. */
|
|
25
|
+
topP?: number;
|
|
26
|
+
/** Seed for reproducibility. Supported by OpenRouter (OpenAI-style models). */
|
|
27
|
+
seed?: number;
|
|
28
|
+
/** Reasoning effort for reasoning models (o1, o3-mini, etc.). OpenRouter-only. */
|
|
29
|
+
reasoningEffort?: 'low' | 'medium' | 'high';
|
|
30
|
+
/** Response format constraint. 'json_object' forces valid JSON output. OpenRouter-only. */
|
|
31
|
+
responseFormat?: 'text' | 'json_object';
|
|
32
|
+
/** Provider-specific escape hatch. Spread into the provider request last. */
|
|
33
|
+
providerParams?: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Required JSON keys when `output_format: structured_json`. Consumed by
|
|
36
|
+
* MockProvider to build a JSON-shaped response that satisfies
|
|
37
|
+
* validateOutputFormat without real LLM calls. Other providers ignore
|
|
38
|
+
* this — they emit JSON based on the real model's output.
|
|
39
|
+
*/
|
|
40
|
+
fields?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Stage-level output_format constraint. MockProvider branches on this to
|
|
43
|
+
* emit a realistic deterministic shape per format (text, markdown, code,
|
|
44
|
+
* structured_json). Other providers ignore this — they emit whatever
|
|
45
|
+
* the real model returns and downstream `validateOutputFormat` checks
|
|
46
|
+
* the result.
|
|
47
|
+
*
|
|
48
|
+
* Added in F13: previously MockProvider echoed the prompt back via
|
|
49
|
+
* `[mock] echo: <preview>` for every non-structured format, which made
|
|
50
|
+
* `pipeline call --local --mock` produce noisy unhelpful output. With
|
|
51
|
+
* `outputFormat` set, each format gets its own deterministic mock
|
|
52
|
+
* (markdown headers, fenced code, plain text summary) — useful for
|
|
53
|
+
* demo/QA without a real LLM.
|
|
54
|
+
*/
|
|
55
|
+
outputFormat?: OutputFormat;
|
|
24
56
|
}
|
|
25
57
|
export interface TokenUsage {
|
|
26
58
|
inputTokens: number;
|
package/package.json
CHANGED