@agentsmarket/pipeline-runtime 0.1.8 → 0.1.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/pipeline-refs.d.ts +18 -0
- package/dist/pipeline-refs.js +63 -8
- package/dist/stages.js +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export { createModelResolver, resolveModelSync, DEFAULT_MODEL, type ModelResolve
|
|
|
36
36
|
export { sha256Hex, computeSkillContentHash, } from './content-hash.js';
|
|
37
37
|
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';
|
|
38
38
|
export { validateInputs, formatInputErrors, type InputDecl, type InputSpec, type InputValidationError, } from './validate-inputs.js';
|
|
39
|
-
export { resolveInputRefs, type PipelineRefContext, } from './pipeline-refs.js';
|
|
39
|
+
export { resolveInputRefs, resolveSpecialKeys, type PipelineRefContext, } from './pipeline-refs.js';
|
|
40
40
|
export { isToolSkill, invokeToolSkill, type ToolSkillContext, type ToolSkillResult, type ToolSkillHandler, } from './tools/tool-skills.js';
|
|
41
41
|
export interface PipelineStageSpec {
|
|
42
42
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { createModelResolver, resolveModelSync, DEFAULT_MODEL, } from './model-r
|
|
|
23
23
|
export { sha256Hex, computeSkillContentHash, } from './content-hash.js';
|
|
24
24
|
export { executeStage, runPipelineV2, makeWhenResolve, parseUsesEntry, parseUsesList, validateOutputFormat, StageNotFoundError, StageForbiddenError, StageBadConfigError, } from './stages.js';
|
|
25
25
|
export { validateInputs, formatInputErrors, } from './validate-inputs.js';
|
|
26
|
-
export { resolveInputRefs, } from './pipeline-refs.js';
|
|
26
|
+
export { resolveInputRefs, resolveSpecialKeys, } from './pipeline-refs.js';
|
|
27
27
|
export { isToolSkill, invokeToolSkill, } from './tools/tool-skills.js';
|
|
28
28
|
export async function runStage(stage, ctx) {
|
|
29
29
|
const vars = [];
|
package/dist/pipeline-refs.d.ts
CHANGED
|
@@ -33,3 +33,21 @@ export interface PipelineRefContext {
|
|
|
33
33
|
previousOutputs: Record<string, string>;
|
|
34
34
|
}
|
|
35
35
|
export declare function resolveInputRefs(value: unknown, ctx: PipelineRefContext): unknown;
|
|
36
|
+
/**
|
|
37
|
+
* Substitute built-in special keys (\$today, \$now, \$year, \$month, \$weekday)
|
|
38
|
+
* anywhere they appear in text. Used for LLM prompts / system messages where
|
|
39
|
+
* \$input.X / \$stages.X.output are NOT resolved (they would inflate prompts
|
|
40
|
+
* with raw arrays or huge prior outputs). Special keys are small strings —
|
|
41
|
+
* safe to substitute everywhere.
|
|
42
|
+
*
|
|
43
|
+
* Bare and braced forms both work:
|
|
44
|
+
* \$today / \${today} → '2026-09-22'
|
|
45
|
+
* \$now / \${now} → '2026-09-22T00:00:00Z'
|
|
46
|
+
* \$year / \${year} → '2026'
|
|
47
|
+
* \$month / \${month} → '2026-09'
|
|
48
|
+
* \$weekday / \${weekday} → 'Monday'
|
|
49
|
+
*
|
|
50
|
+
* Unknown \$keys are left literal (no false-matching — only the 5 known
|
|
51
|
+
* keys trigger substitution).
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveSpecialKeys(text: string): string;
|
package/dist/pipeline-refs.js
CHANGED
|
@@ -30,6 +30,13 @@
|
|
|
30
30
|
*/
|
|
31
31
|
const INPUT_REF_PATTERN = /\$\{\s*input\.([A-Za-z_][A-Za-z0-9_]*)\s*\}|\$input\.([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
32
32
|
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;
|
|
33
|
+
const SPECIAL_KEYS = {
|
|
34
|
+
today: () => new Date().toISOString().slice(0, 10),
|
|
35
|
+
now: () => new Date().toISOString(),
|
|
36
|
+
year: () => String(new Date().getFullYear()),
|
|
37
|
+
month: () => new Date().toISOString().slice(0, 7),
|
|
38
|
+
weekday: () => new Date().toLocaleDateString('en-US', { weekday: 'long' }),
|
|
39
|
+
};
|
|
33
40
|
export function resolveInputRefs(value, ctx) {
|
|
34
41
|
if (typeof value === 'string') {
|
|
35
42
|
return resolveStringRefs(value, ctx);
|
|
@@ -46,17 +53,14 @@ export function resolveInputRefs(value, ctx) {
|
|
|
46
53
|
}
|
|
47
54
|
return value;
|
|
48
55
|
}
|
|
56
|
+
const SPECIAL_KEY_PATTERN = /\$(today|now|year|month|weekday)\b|\$\{\s*(today|now|year|month|weekday)\s*\}/g;
|
|
49
57
|
function resolveStringRefs(text, ctx) {
|
|
50
58
|
const trimmed = text.trim();
|
|
51
59
|
const inputMatches = [...trimmed.matchAll(/\$input\.([A-Za-z_][A-Za-z0-9_]*)|\$\{\s*input\.([A-Za-z_][A-Za-z0-9_]*)\s*\}/g)];
|
|
52
60
|
const stageMatches = [...trimmed.matchAll(/\$stages\.([A-Za-z_][A-Za-z0-9_.-]*)\.output|\$\{\s*stages\.([A-Za-z_][A-Za-z0-9_.-]*)\.output\s*\}/g)];
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const isSingleStageRef = stageMatches.length === 1
|
|
57
|
-
&& inputMatches.length === 0
|
|
58
|
-
&& stageMatches[0][0] === trimmed;
|
|
59
|
-
if (isSingleInputRef) {
|
|
61
|
+
const specialMatches = [...trimmed.matchAll(SPECIAL_KEY_PATTERN)];
|
|
62
|
+
const allMatches = inputMatches.length + stageMatches.length + specialMatches.length;
|
|
63
|
+
if (inputMatches.length === 1 && allMatches === 1 && inputMatches[0][0] === trimmed) {
|
|
60
64
|
const m = inputMatches[0];
|
|
61
65
|
const key = m[1] ?? m[2];
|
|
62
66
|
if (key !== undefined && Object.prototype.hasOwnProperty.call(ctx.inputs, key)) {
|
|
@@ -64,7 +68,7 @@ function resolveStringRefs(text, ctx) {
|
|
|
64
68
|
}
|
|
65
69
|
return text;
|
|
66
70
|
}
|
|
67
|
-
if (
|
|
71
|
+
if (stageMatches.length === 1 && allMatches === 1 && stageMatches[0][0] === trimmed) {
|
|
68
72
|
const m = stageMatches[0];
|
|
69
73
|
const stageId = m[1] ?? m[2];
|
|
70
74
|
if (stageId !== undefined && Object.prototype.hasOwnProperty.call(ctx.previousOutputs, stageId)) {
|
|
@@ -72,6 +76,19 @@ function resolveStringRefs(text, ctx) {
|
|
|
72
76
|
}
|
|
73
77
|
return text;
|
|
74
78
|
}
|
|
79
|
+
if (specialMatches.length === 1 && allMatches === 1 && specialMatches[0][0] === trimmed) {
|
|
80
|
+
const m = specialMatches[0];
|
|
81
|
+
const key = m[1] ?? m[2];
|
|
82
|
+
if (key !== undefined) {
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(ctx.inputs, key)) {
|
|
84
|
+
return ctx.inputs[key];
|
|
85
|
+
}
|
|
86
|
+
if (Object.prototype.hasOwnProperty.call(SPECIAL_KEYS, key)) {
|
|
87
|
+
return SPECIAL_KEYS[key]();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return text;
|
|
91
|
+
}
|
|
75
92
|
let out = text;
|
|
76
93
|
out = out.replace(INPUT_REF_PATTERN, (match, key1, key2) => {
|
|
77
94
|
const key = key1 ?? key2;
|
|
@@ -88,6 +105,18 @@ function resolveStringRefs(text, ctx) {
|
|
|
88
105
|
}
|
|
89
106
|
return match;
|
|
90
107
|
});
|
|
108
|
+
out = out.replace(SPECIAL_KEY_PATTERN, (match, k1, k2) => {
|
|
109
|
+
const key = k1 ?? k2;
|
|
110
|
+
if (key !== undefined) {
|
|
111
|
+
if (Object.prototype.hasOwnProperty.call(ctx.inputs, key)) {
|
|
112
|
+
return stringifyValue(ctx.inputs[key]);
|
|
113
|
+
}
|
|
114
|
+
if (Object.prototype.hasOwnProperty.call(SPECIAL_KEYS, key)) {
|
|
115
|
+
return SPECIAL_KEYS[key]();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return match;
|
|
119
|
+
});
|
|
91
120
|
return out;
|
|
92
121
|
}
|
|
93
122
|
function stringifyValue(v) {
|
|
@@ -97,3 +126,29 @@ function stringifyValue(v) {
|
|
|
97
126
|
return '';
|
|
98
127
|
return JSON.stringify(v);
|
|
99
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Substitute built-in special keys (\$today, \$now, \$year, \$month, \$weekday)
|
|
131
|
+
* anywhere they appear in text. Used for LLM prompts / system messages where
|
|
132
|
+
* \$input.X / \$stages.X.output are NOT resolved (they would inflate prompts
|
|
133
|
+
* with raw arrays or huge prior outputs). Special keys are small strings —
|
|
134
|
+
* safe to substitute everywhere.
|
|
135
|
+
*
|
|
136
|
+
* Bare and braced forms both work:
|
|
137
|
+
* \$today / \${today} → '2026-09-22'
|
|
138
|
+
* \$now / \${now} → '2026-09-22T00:00:00Z'
|
|
139
|
+
* \$year / \${year} → '2026'
|
|
140
|
+
* \$month / \${month} → '2026-09'
|
|
141
|
+
* \$weekday / \${weekday} → 'Monday'
|
|
142
|
+
*
|
|
143
|
+
* Unknown \$keys are left literal (no false-matching — only the 5 known
|
|
144
|
+
* keys trigger substitution).
|
|
145
|
+
*/
|
|
146
|
+
export function resolveSpecialKeys(text) {
|
|
147
|
+
return text.replace(SPECIAL_KEY_PATTERN, (match, k1, k2) => {
|
|
148
|
+
const key = k1 ?? k2;
|
|
149
|
+
if (key !== undefined && Object.prototype.hasOwnProperty.call(SPECIAL_KEYS, key)) {
|
|
150
|
+
return SPECIAL_KEYS[key]();
|
|
151
|
+
}
|
|
152
|
+
return match;
|
|
153
|
+
});
|
|
154
|
+
}
|
package/dist/stages.js
CHANGED
|
@@ -16,7 +16,7 @@ import { StageOutputFormatError, StageSkillVersionMismatchError, StageMCPConfigE
|
|
|
16
16
|
import { createModelResolver, } from './model-resolver.js';
|
|
17
17
|
import { computeSkillContentHash } from './content-hash.js';
|
|
18
18
|
import { shouldSkipStage } from './when.js';
|
|
19
|
-
import { resolveInputRefs } from './pipeline-refs.js';
|
|
19
|
+
import { resolveInputRefs, resolveSpecialKeys } from './pipeline-refs.js';
|
|
20
20
|
import { isToolSkill, invokeToolSkill } from './tools/tool-skills.js';
|
|
21
21
|
import { isRetryableStatus, computeBackoffMs, RetryExhaustedError, DEFAULT_RETRY, } from './retry.js';
|
|
22
22
|
import { NoopEventSink, makeStartedEvent as makePipelineStartedEvent, makeCompletedEvent as makePipelineCompletedEvent, makeFailedEvent as makePipelineFailedEvent, makeStageStartedEvent, makeStageCompletedEvent, makeStageSkippedEvent, makeStageFailedEvent, makeStageRetriedEvent, } from './streaming-events.js';
|
|
@@ -417,9 +417,9 @@ export async function executeStage(stage, pipeline, ctx, deps) {
|
|
|
417
417
|
const model = deps.modelResolver.resolveSync(stage, pipeline);
|
|
418
418
|
const stageProvider = resolveStageProvider(deps, stage, model);
|
|
419
419
|
const resolvedSystem = stage.system
|
|
420
|
-
? resolveStageOutputRefs(stage.system, ctx.previousOutputs)
|
|
420
|
+
? resolveSpecialKeys(resolveStageOutputRefs(stage.system, ctx.previousOutputs))
|
|
421
421
|
: stage.system;
|
|
422
|
-
const resolvedPrompt = resolveStageOutputRefs(stage.prompt ?? '', ctx.previousOutputs);
|
|
422
|
+
const resolvedPrompt = resolveSpecialKeys(resolveStageOutputRefs(stage.prompt ?? '', ctx.previousOutputs));
|
|
423
423
|
const prompt = previousContext + `Inputs:\n${inputsString}\n---\n\n${resolvedPrompt}`;
|
|
424
424
|
const ran = await runWithRetry(() => stageProvider.generateText(prompt, {
|
|
425
425
|
model,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentsmarket/pipeline-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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",
|