@agentsmarket/pipeline-runtime 0.1.7 → 0.1.9

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 CHANGED
@@ -37,6 +37,7 @@ 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
39
  export { resolveInputRefs, type PipelineRefContext, } from './pipeline-refs.js';
40
+ export { isToolSkill, invokeToolSkill, type ToolSkillContext, type ToolSkillResult, type ToolSkillHandler, } from './tools/tool-skills.js';
40
41
  export interface PipelineStageSpec {
41
42
  id: string;
42
43
  model: string;
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ 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
26
  export { resolveInputRefs, } from './pipeline-refs.js';
27
+ export { isToolSkill, invokeToolSkill, } from './tools/tool-skills.js';
27
28
  export async function runStage(stage, ctx) {
28
29
  const vars = [];
29
30
  for (const [key, val] of Object.entries(ctx.outputs)) {
@@ -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 isSingleInputRef = inputMatches.length === 1
54
- && stageMatches.length === 0
55
- && inputMatches[0][0] === trimmed;
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 (isSingleStageRef) {
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsmarket/pipeline-runtime",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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",