@dudko.dev/agent-web-ui 0.0.6 → 0.0.8
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/README.md +52 -0
- package/dist/{chunk-NHU6WQM5.js → chunk-ETYLHTPK.js} +435 -1
- package/dist/{chunk-627OXMFG.js → chunk-HIHUK7YA.js} +5 -0
- package/dist/{chunk-S5AHUAFG.js → chunk-JEW2ZWYX.js} +4 -0
- package/dist/{chunk-VZCQXE3P.js → chunk-UO2Q7AIV.js} +4 -0
- package/dist/{chunk-V33T6VX3.js → chunk-VG5NLFI5.js} +4 -0
- package/dist/controller.cjs +452 -16
- package/dist/controller.d.cts +39 -3
- package/dist/controller.d.ts +39 -3
- package/dist/controller.js +39 -16
- package/dist/{en-Dg2MtzcJ.d.cts → en-CPCAidve.d.cts} +4 -0
- package/dist/{en-Dg2MtzcJ.d.ts → en-CPCAidve.d.ts} +4 -0
- package/dist/index.cjs +458 -4
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +37 -1
- package/dist/{labels-CCPL7t17.d.ts → labels-CeJMN8NU.d.ts} +9 -1
- package/dist/{labels-ipy-ydkp.d.cts → labels-D-NI4hKW.d.cts} +9 -1
- package/dist/locales/be.cjs +9 -0
- package/dist/locales/be.d.cts +2 -2
- package/dist/locales/be.d.ts +2 -2
- package/dist/locales/be.js +5 -1
- package/dist/locales/bg.cjs +9 -0
- package/dist/locales/bg.d.cts +2 -2
- package/dist/locales/bg.d.ts +2 -2
- package/dist/locales/bg.js +5 -1
- package/dist/locales/ca.cjs +9 -0
- package/dist/locales/ca.d.cts +2 -2
- package/dist/locales/ca.d.ts +2 -2
- package/dist/locales/ca.js +5 -1
- package/dist/locales/cs.cjs +9 -0
- package/dist/locales/cs.d.cts +2 -2
- package/dist/locales/cs.d.ts +2 -2
- package/dist/locales/cs.js +5 -1
- package/dist/locales/da.cjs +9 -0
- package/dist/locales/da.d.cts +2 -2
- package/dist/locales/da.d.ts +2 -2
- package/dist/locales/da.js +5 -1
- package/dist/locales/de.cjs +9 -0
- package/dist/locales/de.d.cts +2 -2
- package/dist/locales/de.d.ts +2 -2
- package/dist/locales/de.js +5 -1
- package/dist/locales/el.cjs +9 -0
- package/dist/locales/el.d.cts +2 -2
- package/dist/locales/el.d.ts +2 -2
- package/dist/locales/el.js +5 -1
- package/dist/locales/en.cjs +9 -0
- package/dist/locales/en.d.cts +2 -2
- package/dist/locales/en.d.ts +2 -2
- package/dist/locales/en.js +5 -1
- package/dist/locales/es-419.cjs +9 -0
- package/dist/locales/es-419.d.cts +2 -2
- package/dist/locales/es-419.d.ts +2 -2
- package/dist/locales/es-419.js +2 -2
- package/dist/locales/es.cjs +9 -0
- package/dist/locales/es.d.cts +2 -2
- package/dist/locales/es.d.ts +2 -2
- package/dist/locales/es.js +2 -2
- package/dist/locales/fi.cjs +9 -0
- package/dist/locales/fi.d.cts +2 -2
- package/dist/locales/fi.d.ts +2 -2
- package/dist/locales/fi.js +5 -1
- package/dist/locales/fr-CA.cjs +9 -0
- package/dist/locales/fr-CA.d.cts +2 -2
- package/dist/locales/fr-CA.d.ts +2 -2
- package/dist/locales/fr-CA.js +2 -2
- package/dist/locales/fr.cjs +9 -0
- package/dist/locales/fr.d.cts +2 -2
- package/dist/locales/fr.d.ts +2 -2
- package/dist/locales/fr.js +2 -2
- package/dist/locales/gn.cjs +9 -0
- package/dist/locales/gn.d.cts +2 -2
- package/dist/locales/gn.d.ts +2 -2
- package/dist/locales/gn.js +5 -1
- package/dist/locales/hr.cjs +9 -0
- package/dist/locales/hr.d.cts +2 -2
- package/dist/locales/hr.d.ts +2 -2
- package/dist/locales/hr.js +5 -1
- package/dist/locales/ht.cjs +9 -0
- package/dist/locales/ht.d.cts +2 -2
- package/dist/locales/ht.d.ts +2 -2
- package/dist/locales/ht.js +5 -1
- package/dist/locales/hu.cjs +9 -0
- package/dist/locales/hu.d.cts +2 -2
- package/dist/locales/hu.d.ts +2 -2
- package/dist/locales/hu.js +5 -1
- package/dist/locales/index.cjs +5 -0
- package/dist/locales/index.d.cts +4 -4
- package/dist/locales/index.d.ts +4 -4
- package/dist/locales/index.js +1 -1
- package/dist/locales/it.cjs +9 -0
- package/dist/locales/it.d.cts +2 -2
- package/dist/locales/it.d.ts +2 -2
- package/dist/locales/it.js +5 -1
- package/dist/locales/nb.cjs +9 -0
- package/dist/locales/nb.d.cts +2 -2
- package/dist/locales/nb.d.ts +2 -2
- package/dist/locales/nb.js +5 -1
- package/dist/locales/nl.cjs +9 -0
- package/dist/locales/nl.d.cts +2 -2
- package/dist/locales/nl.d.ts +2 -2
- package/dist/locales/nl.js +5 -1
- package/dist/locales/pl.cjs +9 -0
- package/dist/locales/pl.d.cts +2 -2
- package/dist/locales/pl.d.ts +2 -2
- package/dist/locales/pl.js +5 -1
- package/dist/locales/pt-BR.cjs +9 -0
- package/dist/locales/pt-BR.d.cts +2 -2
- package/dist/locales/pt-BR.d.ts +2 -2
- package/dist/locales/pt-BR.js +5 -1
- package/dist/locales/pt.cjs +9 -0
- package/dist/locales/pt.d.cts +2 -2
- package/dist/locales/pt.d.ts +2 -2
- package/dist/locales/pt.js +5 -1
- package/dist/locales/qu.cjs +9 -0
- package/dist/locales/qu.d.cts +2 -2
- package/dist/locales/qu.d.ts +2 -2
- package/dist/locales/qu.js +5 -1
- package/dist/locales/ro.cjs +9 -0
- package/dist/locales/ro.d.cts +2 -2
- package/dist/locales/ro.d.ts +2 -2
- package/dist/locales/ro.js +5 -1
- package/dist/locales/ru.cjs +9 -0
- package/dist/locales/ru.d.cts +2 -2
- package/dist/locales/ru.d.ts +2 -2
- package/dist/locales/ru.js +5 -1
- package/dist/locales/sk.cjs +9 -0
- package/dist/locales/sk.d.cts +2 -2
- package/dist/locales/sk.d.ts +2 -2
- package/dist/locales/sk.js +5 -1
- package/dist/locales/sq.cjs +9 -0
- package/dist/locales/sq.d.cts +2 -2
- package/dist/locales/sq.d.ts +2 -2
- package/dist/locales/sq.js +5 -1
- package/dist/locales/sr-Latn.cjs +9 -0
- package/dist/locales/sr-Latn.d.cts +2 -2
- package/dist/locales/sr-Latn.d.ts +2 -2
- package/dist/locales/sr-Latn.js +2 -2
- package/dist/locales/sr.cjs +9 -0
- package/dist/locales/sr.d.cts +2 -2
- package/dist/locales/sr.d.ts +2 -2
- package/dist/locales/sr.js +2 -2
- package/dist/locales/sv.cjs +9 -0
- package/dist/locales/sv.d.cts +2 -2
- package/dist/locales/sv.d.ts +2 -2
- package/dist/locales/sv.js +5 -1
- package/dist/locales/tr.cjs +9 -0
- package/dist/locales/tr.d.cts +2 -2
- package/dist/locales/tr.d.ts +2 -2
- package/dist/locales/tr.js +5 -1
- package/dist/locales/uk.cjs +9 -0
- package/dist/locales/uk.d.cts +2 -2
- package/dist/locales/uk.d.ts +2 -2
- package/dist/locales/uk.js +5 -1
- package/dist/page-context-BAmw4p6d.d.cts +244 -0
- package/dist/page-context-BAmw4p6d.d.ts +244 -0
- package/dist/pipeline-format.cjs +842 -0
- package/dist/pipeline-format.d.cts +512 -0
- package/dist/pipeline-format.d.ts +512 -0
- package/dist/pipeline-format.js +788 -0
- package/dist/pipeline.cjs +1 -0
- package/dist/pipeline.d.cts +2 -0
- package/dist/pipeline.d.ts +2 -0
- package/dist/pipeline.js +1 -0
- package/dist/styles.css +59 -0
- package/dist/{types-CQquuZpl.d.cts → types-B5cyqkWY.d.cts} +1 -1
- package/dist/{types-CXZfZVP5.d.ts → types-BgNjWN5Z.d.ts} +1 -1
- package/dist/{types-DnBCok3z.d.ts → types-CHFtTZjl.d.cts} +6 -0
- package/dist/{types-DnBCok3z.d.cts → types-CHFtTZjl.d.ts} +6 -0
- package/package.json +12 -2
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
// src/pipeline-format/types.ts
|
|
2
|
+
var PIPELINE_FORMAT = "agent-pipeline";
|
|
3
|
+
var PIPELINE_SCHEMA_VERSION = 1;
|
|
4
|
+
|
|
5
|
+
// src/pipeline-format/secrets.ts
|
|
6
|
+
var SECRET_SCAN_MAX_CHARS = 1e5;
|
|
7
|
+
var PATTERNS = [
|
|
8
|
+
// Providers' key shapes: OpenAI / Anthropic / OpenRouter / DeepSeek (sk-...), Google (AIza...),
|
|
9
|
+
// GitHub, Slack, AWS access key ids, Stripe, Hugging Face, GitLab.
|
|
10
|
+
["api-key", /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{16,}/],
|
|
11
|
+
["api-key", /\bAIza[0-9A-Za-z_-]{30,}/],
|
|
12
|
+
["api-key", /\b(?:ghp|gho|ghs|ghu|ghr)_[A-Za-z0-9]{30,}/],
|
|
13
|
+
["api-key", /\bgithub_pat_[A-Za-z0-9_]{30,}/],
|
|
14
|
+
["api-key", /\bglpat-[A-Za-z0-9_-]{20,}/],
|
|
15
|
+
["api-key", /\bxox[abprs]-[A-Za-z0-9-]{10,}/],
|
|
16
|
+
["api-key", /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/],
|
|
17
|
+
["api-key", /\b(?:sk|rk|pk)_(?:live|test)_[A-Za-z0-9]{16,}/],
|
|
18
|
+
["api-key", /\bhf_[A-Za-z0-9]{30,}/],
|
|
19
|
+
["private-key", /-----BEGIN [A-Z ]*PRIVATE KEY-----/],
|
|
20
|
+
["jwt", /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/],
|
|
21
|
+
["credential", /\b(?:bearer|basic)[ \t]+[A-Za-z0-9._~+/=-]{16,}/i],
|
|
22
|
+
// `password=...`, `"api_key": "..."`, `token: ...` with a value of 8+ characters.
|
|
23
|
+
[
|
|
24
|
+
"assignment",
|
|
25
|
+
/\b(?:api[_-]?key|access[_-]?token|refresh[_-]?token|auth[_-]?token|client[_-]?secret|secret[_-]?key|token|secret|password|passwd)["']?[ \t]*[:=][ \t]*["']?[^\s"',;}]{8,}/i
|
|
26
|
+
]
|
|
27
|
+
];
|
|
28
|
+
var RUN = /[A-Za-z0-9_+/=-]{32,}/g;
|
|
29
|
+
var randomLooking = (run) => {
|
|
30
|
+
let switches = 0;
|
|
31
|
+
let letterRuns = 0;
|
|
32
|
+
let letters = 0;
|
|
33
|
+
let prev = "o";
|
|
34
|
+
for (const ch of run) {
|
|
35
|
+
const cls = ch >= "0" && ch <= "9" ? "d" : /[A-Za-z]/.test(ch) ? "l" : "o";
|
|
36
|
+
if (cls === "l") {
|
|
37
|
+
letters++;
|
|
38
|
+
if (prev !== "l") letterRuns++;
|
|
39
|
+
}
|
|
40
|
+
if (cls === "l" && prev === "d" || cls === "d" && prev === "l") switches++;
|
|
41
|
+
prev = cls;
|
|
42
|
+
}
|
|
43
|
+
return switches >= 8 && letterRuns > 0 && letters / letterRuns <= 4;
|
|
44
|
+
};
|
|
45
|
+
var secretKindOf = (text) => {
|
|
46
|
+
const t = text.length > SECRET_SCAN_MAX_CHARS ? text.slice(0, SECRET_SCAN_MAX_CHARS) : text;
|
|
47
|
+
for (const [kind, re] of PATTERNS) {
|
|
48
|
+
if (re.test(t)) return kind;
|
|
49
|
+
}
|
|
50
|
+
for (const m of t.matchAll(RUN)) {
|
|
51
|
+
if (randomLooking(m[0])) return "random-token";
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
};
|
|
55
|
+
var looksLikeSecret = (text) => secretKindOf(text) !== void 0;
|
|
56
|
+
var SECRET_KEY = /(?:^|[_-])(?:api[_-]?key|apikey|token|secret|password|passwd|credentials?|private[_-]?key|auth(?:orization)?)$/i;
|
|
57
|
+
var SECRET_KEY_CAMEL = /(?:apiKey|Token|Secret|Password|Credentials?|PrivateKey|Authorization)$/;
|
|
58
|
+
var isSecretKey = (key) => SECRET_KEY.test(key) || SECRET_KEY_CAMEL.test(key);
|
|
59
|
+
var SECRET_NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
60
|
+
|
|
61
|
+
// src/pipeline-format/validate.ts
|
|
62
|
+
var PIPELINE_FORMAT_LIMITS = {
|
|
63
|
+
maxNodes: 200,
|
|
64
|
+
maxEdges: 1e3,
|
|
65
|
+
maxRoutes: 20,
|
|
66
|
+
maxNamesPerList: 100,
|
|
67
|
+
maxSecretsPerNode: 50,
|
|
68
|
+
maxNodeVisits: 100,
|
|
69
|
+
maxRuns: 1e3,
|
|
70
|
+
titleChars: 200,
|
|
71
|
+
descriptionChars: 2e3,
|
|
72
|
+
instructionsChars: 2e4,
|
|
73
|
+
routeLabelChars: 100,
|
|
74
|
+
conditionTextChars: 500,
|
|
75
|
+
settingsChars: 2e4,
|
|
76
|
+
settingsDepth: 8
|
|
77
|
+
};
|
|
78
|
+
var PIPELINE_NAME_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
79
|
+
var PIPELINE_NODE_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
80
|
+
var PIPELINE_EDGE_ID_PATTERN = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
81
|
+
var PIPELINE_TOOL_NAME_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
82
|
+
var PIPELINE_SERVER_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
83
|
+
var PIPELINE_MODEL_PATTERN = /^[A-Za-z0-9._:/@-]{1,200}$/;
|
|
84
|
+
var SECRET_WORDS = {
|
|
85
|
+
"api-key": "an API key",
|
|
86
|
+
"private-key": "a private key",
|
|
87
|
+
jwt: "a signed token (JWT)",
|
|
88
|
+
credential: "a bearer or basic credential",
|
|
89
|
+
assignment: "a secret assigned to a name (key=value)",
|
|
90
|
+
"random-token": "a random token"
|
|
91
|
+
};
|
|
92
|
+
var seg = (key) => `/${String(key).replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
93
|
+
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
94
|
+
var kindOfValue = (v) => v === null ? "null" : Array.isArray(v) ? "an array" : `a ${typeof v}`;
|
|
95
|
+
var Collector = class {
|
|
96
|
+
issues = [];
|
|
97
|
+
add(path, code, message) {
|
|
98
|
+
if (this.issues.length < 500) this.issues.push({ path, code, message });
|
|
99
|
+
}
|
|
100
|
+
// A string, present: its type, length and (optionally) pattern, and no secret in it.
|
|
101
|
+
string(path, v, o = {}) {
|
|
102
|
+
if (typeof v !== "string") {
|
|
103
|
+
this.add(path, "type", `must be a string, not ${kindOfValue(v)}`);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const min = o.min ?? 0;
|
|
107
|
+
if (v.length < min) {
|
|
108
|
+
this.add(path, "required", "must not be empty");
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (o.max !== void 0 && v.length > o.max) {
|
|
112
|
+
this.add(path, "too_long", `must be at most ${o.max} characters (it has ${v.length})`);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
if (o.pattern && !o.pattern.test(v)) {
|
|
116
|
+
this.add(path, "pattern", `must match ${o.patternText ?? String(o.pattern)}`);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
this.secret(path, v);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
secret(path, v) {
|
|
123
|
+
const kind = secretKindOf(v);
|
|
124
|
+
if (kind) {
|
|
125
|
+
this.add(
|
|
126
|
+
path,
|
|
127
|
+
"secret_value",
|
|
128
|
+
`looks like it holds ${SECRET_WORDS[kind]}: never put a secret value in a definition - store it in the executor and reference it by name (a node’s "secrets", or { "$secret": "NAME" } in its settings)`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
known(path, v, allowed) {
|
|
133
|
+
for (const key of Object.keys(v)) {
|
|
134
|
+
if (!allowed.includes(key)) {
|
|
135
|
+
this.add(`${path}${seg(key)}`, "unknown_property", `"${key}" is not a property here`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
int(path, v, min, max) {
|
|
140
|
+
if (typeof v !== "number" || !Number.isInteger(v)) {
|
|
141
|
+
this.add(path, "type", `must be an integer, not ${kindOfValue(v)}`);
|
|
142
|
+
} else if (v < min || v > max) {
|
|
143
|
+
this.add(path, "range", `must be between ${min} and ${max}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
names(path, v, max, pattern, what) {
|
|
147
|
+
if (!Array.isArray(v)) {
|
|
148
|
+
this.add(path, "type", `must be an array of ${what}, not ${kindOfValue(v)}`);
|
|
149
|
+
return void 0;
|
|
150
|
+
}
|
|
151
|
+
if (v.length > max) {
|
|
152
|
+
this.add(path, "too_many", `at most ${max} ${what}`);
|
|
153
|
+
return void 0;
|
|
154
|
+
}
|
|
155
|
+
const seen = /* @__PURE__ */ new Set();
|
|
156
|
+
v.forEach((name, i) => {
|
|
157
|
+
if (this.string(`${path}${seg(i)}`, name, { pattern, patternText: String(pattern) })) {
|
|
158
|
+
if (seen.has(name)) this.add(`${path}${seg(i)}`, "duplicate", `"${name}" is listed twice`);
|
|
159
|
+
seen.add(name);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return v.filter((n) => typeof n === "string");
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var ROOT_KEYS = [
|
|
166
|
+
"$schema",
|
|
167
|
+
"format",
|
|
168
|
+
"schemaVersion",
|
|
169
|
+
"name",
|
|
170
|
+
"title",
|
|
171
|
+
"description",
|
|
172
|
+
"entry",
|
|
173
|
+
"limits",
|
|
174
|
+
"nodes",
|
|
175
|
+
"edges"
|
|
176
|
+
];
|
|
177
|
+
var NODE_KEYS = [
|
|
178
|
+
"id",
|
|
179
|
+
"name",
|
|
180
|
+
"instructions",
|
|
181
|
+
"model",
|
|
182
|
+
"tools",
|
|
183
|
+
"mcpServers",
|
|
184
|
+
"skills",
|
|
185
|
+
"secrets",
|
|
186
|
+
"routes",
|
|
187
|
+
"join",
|
|
188
|
+
"settings",
|
|
189
|
+
"position"
|
|
190
|
+
];
|
|
191
|
+
var EDGE_KEYS = ["id", "from", "to", "when"];
|
|
192
|
+
var isSecretRef = (v) => isObject(v) && Object.keys(v).length === 1 && typeof v.$secret === "string";
|
|
193
|
+
var checkSettings = (c, path, v) => {
|
|
194
|
+
if (!isObject(v)) {
|
|
195
|
+
c.add(path, "type", `must be an object, not ${kindOfValue(v)}`);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let size = 0;
|
|
199
|
+
try {
|
|
200
|
+
size = JSON.stringify(v).length;
|
|
201
|
+
} catch {
|
|
202
|
+
c.add(path, "type", "must be plain JSON");
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (size > PIPELINE_FORMAT_LIMITS.settingsChars) {
|
|
206
|
+
c.add(
|
|
207
|
+
path,
|
|
208
|
+
"too_long",
|
|
209
|
+
`must be at most ${PIPELINE_FORMAT_LIMITS.settingsChars} characters of JSON`
|
|
210
|
+
);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const walk = (p, value, depth, key) => {
|
|
214
|
+
if (depth > PIPELINE_FORMAT_LIMITS.settingsDepth) {
|
|
215
|
+
c.add(p, "too_many", `nested deeper than ${PIPELINE_FORMAT_LIMITS.settingsDepth} levels`);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (isSecretRef(value)) {
|
|
219
|
+
if (!SECRET_NAME.test(value.$secret)) {
|
|
220
|
+
c.add(`${p}/$secret`, "pattern", `a secret's name must match ${String(SECRET_NAME)}`);
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (isObject(value) && "$secret" in value) {
|
|
225
|
+
c.add(p, "type", 'a secret reference is exactly { "$secret": "NAME" }');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (typeof value === "string") {
|
|
229
|
+
if (key !== void 0 && isSecretKey(key) && value.length > 0) {
|
|
230
|
+
c.add(
|
|
231
|
+
p,
|
|
232
|
+
"secret_value",
|
|
233
|
+
`"${key}" names a secret: give { "$secret": "NAME" } here, never the value`
|
|
234
|
+
);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
c.secret(p, value);
|
|
238
|
+
} else if (typeof value === "number") {
|
|
239
|
+
if (!Number.isFinite(value)) c.add(p, "type", "must be a finite number");
|
|
240
|
+
} else if (Array.isArray(value)) {
|
|
241
|
+
value.forEach((x, i) => walk(`${p}${seg(i)}`, x, depth + 1, key));
|
|
242
|
+
} else if (isObject(value)) {
|
|
243
|
+
for (const [k, x] of Object.entries(value)) {
|
|
244
|
+
c.secret(`${p}${seg(k)}`, k);
|
|
245
|
+
walk(`${p}${seg(k)}`, x, depth + 1, k);
|
|
246
|
+
}
|
|
247
|
+
} else if (typeof value !== "boolean" && value !== null) {
|
|
248
|
+
c.add(p, "type", `must be JSON, not ${kindOfValue(value)}`);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
for (const [k, x] of Object.entries(v)) {
|
|
252
|
+
c.secret(`${path}${seg(k)}`, k);
|
|
253
|
+
walk(`${path}${seg(k)}`, x, 1, k);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
var checkCondition = (c, path, v, routesOfSource) => {
|
|
257
|
+
if (!isObject(v)) {
|
|
258
|
+
c.add(path, "type", `must be an object, not ${kindOfValue(v)}`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const kind = v.kind;
|
|
262
|
+
switch (kind) {
|
|
263
|
+
case "always":
|
|
264
|
+
case "otherwise":
|
|
265
|
+
c.known(path, v, ["kind"]);
|
|
266
|
+
return;
|
|
267
|
+
case "contains":
|
|
268
|
+
c.known(path, v, ["kind", "text", "caseSensitive"]);
|
|
269
|
+
c.string(`${path}/text`, v.text, { min: 1, max: PIPELINE_FORMAT_LIMITS.conditionTextChars });
|
|
270
|
+
if (v.caseSensitive !== void 0 && typeof v.caseSensitive !== "boolean") {
|
|
271
|
+
c.add(`${path}/caseSensitive`, "type", "must be true or false");
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
case "matches":
|
|
275
|
+
c.known(path, v, ["kind", "pattern", "flags"]);
|
|
276
|
+
c.string(`${path}/pattern`, v.pattern, {
|
|
277
|
+
min: 1,
|
|
278
|
+
max: PIPELINE_FORMAT_LIMITS.conditionTextChars
|
|
279
|
+
});
|
|
280
|
+
if (v.flags !== void 0) {
|
|
281
|
+
c.string(`${path}/flags`, v.flags, {
|
|
282
|
+
max: 4,
|
|
283
|
+
pattern: /^(?!.*(.).*\1)[imsu]{0,4}$/,
|
|
284
|
+
patternText: "up to one each of i, m, s, u"
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
case "route":
|
|
289
|
+
c.known(path, v, ["kind", "label"]);
|
|
290
|
+
if (c.string(`${path}/label`, v.label, { min: 1, max: PIPELINE_FORMAT_LIMITS.routeLabelChars })) {
|
|
291
|
+
if (routesOfSource && !routesOfSource.has(v.label)) {
|
|
292
|
+
c.add(
|
|
293
|
+
`${path}/label`,
|
|
294
|
+
"unknown_route",
|
|
295
|
+
`the source node has no route "${v.label}" (its routes: ${[...routesOfSource].join(", ") || "none"})`
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
default:
|
|
301
|
+
c.add(`${path}/kind`, "enum", "must be one of always, contains, matches, route, otherwise");
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var validatePipelineDocument = (input) => {
|
|
305
|
+
const c = new Collector();
|
|
306
|
+
const L = PIPELINE_FORMAT_LIMITS;
|
|
307
|
+
if (!isObject(input)) {
|
|
308
|
+
c.add("", "not_an_object", `a pipeline document is a JSON object, not ${kindOfValue(input)}`);
|
|
309
|
+
return { ok: false, errors: c.issues };
|
|
310
|
+
}
|
|
311
|
+
const d = input;
|
|
312
|
+
if (d.format !== PIPELINE_FORMAT) {
|
|
313
|
+
c.add("/format", "format", `must be "${PIPELINE_FORMAT}"`);
|
|
314
|
+
}
|
|
315
|
+
if (d.schemaVersion !== PIPELINE_SCHEMA_VERSION) {
|
|
316
|
+
c.add(
|
|
317
|
+
"/schemaVersion",
|
|
318
|
+
"schema_version",
|
|
319
|
+
typeof d.schemaVersion === "number" && d.schemaVersion > PIPELINE_SCHEMA_VERSION ? `schema version ${d.schemaVersion} is newer than this reader knows (${PIPELINE_SCHEMA_VERSION}): update the editor or the executor` : `must be ${PIPELINE_SCHEMA_VERSION}`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
if (c.issues.length) return { ok: false, errors: c.issues };
|
|
323
|
+
c.known("", d, ROOT_KEYS);
|
|
324
|
+
if (d.$schema !== void 0) c.string("/$schema", d.$schema, { max: 500 });
|
|
325
|
+
if (d.name === void 0) c.add("/name", "required", "a pipeline needs a name");
|
|
326
|
+
else
|
|
327
|
+
c.string("/name", d.name, {
|
|
328
|
+
pattern: PIPELINE_NAME_PATTERN,
|
|
329
|
+
patternText: 'lowercase letters, digits, "_" and "-", starting with a letter (at most 64)'
|
|
330
|
+
});
|
|
331
|
+
if (d.title !== void 0) c.string("/title", d.title, { max: L.titleChars });
|
|
332
|
+
if (d.description !== void 0)
|
|
333
|
+
c.string("/description", d.description, { max: L.descriptionChars });
|
|
334
|
+
if (d.limits !== void 0) {
|
|
335
|
+
if (!isObject(d.limits)) c.add("/limits", "type", "must be an object");
|
|
336
|
+
else {
|
|
337
|
+
c.known("/limits", d.limits, ["maxNodeVisits", "maxRuns"]);
|
|
338
|
+
if (d.limits.maxNodeVisits !== void 0)
|
|
339
|
+
c.int("/limits/maxNodeVisits", d.limits.maxNodeVisits, 1, L.maxNodeVisits);
|
|
340
|
+
if (d.limits.maxRuns !== void 0) c.int("/limits/maxRuns", d.limits.maxRuns, 1, L.maxRuns);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const routes = /* @__PURE__ */ new Map();
|
|
344
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
345
|
+
if (!Array.isArray(d.nodes)) {
|
|
346
|
+
c.add("/nodes", d.nodes === void 0 ? "required" : "type", "must be an array of nodes");
|
|
347
|
+
} else if (d.nodes.length === 0) {
|
|
348
|
+
c.add("/nodes", "required", "a pipeline needs at least one node");
|
|
349
|
+
} else if (d.nodes.length > L.maxNodes) {
|
|
350
|
+
c.add("/nodes", "too_many", `at most ${L.maxNodes} nodes`);
|
|
351
|
+
} else {
|
|
352
|
+
d.nodes.forEach((n, i) => {
|
|
353
|
+
const p = `/nodes${seg(i)}`;
|
|
354
|
+
if (!isObject(n)) {
|
|
355
|
+
c.add(p, "type", `a node is an object, not ${kindOfValue(n)}`);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
c.known(p, n, NODE_KEYS);
|
|
359
|
+
if (n.id === void 0) c.add(`${p}/id`, "required", "a node needs an id");
|
|
360
|
+
else if (c.string(`${p}/id`, n.id, {
|
|
361
|
+
pattern: PIPELINE_NODE_ID_PATTERN,
|
|
362
|
+
patternText: 'letters, digits, "_" and "-" (1 to 64)'
|
|
363
|
+
})) {
|
|
364
|
+
if (nodeIds.has(n.id)) c.add(`${p}/id`, "duplicate", `node id "${n.id}" is used twice`);
|
|
365
|
+
nodeIds.add(n.id);
|
|
366
|
+
}
|
|
367
|
+
if (n.name !== void 0) c.string(`${p}/name`, n.name, { max: L.titleChars });
|
|
368
|
+
if (n.instructions !== void 0)
|
|
369
|
+
c.string(`${p}/instructions`, n.instructions, { max: L.instructionsChars });
|
|
370
|
+
if (n.model !== void 0)
|
|
371
|
+
c.string(`${p}/model`, n.model, {
|
|
372
|
+
pattern: PIPELINE_MODEL_PATTERN,
|
|
373
|
+
patternText: "a model id"
|
|
374
|
+
});
|
|
375
|
+
if (n.tools !== void 0)
|
|
376
|
+
c.names(`${p}/tools`, n.tools, L.maxNamesPerList, PIPELINE_TOOL_NAME_PATTERN, "tool names");
|
|
377
|
+
if (n.mcpServers !== void 0)
|
|
378
|
+
c.names(
|
|
379
|
+
`${p}/mcpServers`,
|
|
380
|
+
n.mcpServers,
|
|
381
|
+
L.maxNamesPerList,
|
|
382
|
+
PIPELINE_SERVER_NAME_PATTERN,
|
|
383
|
+
"MCP server names"
|
|
384
|
+
);
|
|
385
|
+
if (n.skills !== void 0)
|
|
386
|
+
c.names(
|
|
387
|
+
`${p}/skills`,
|
|
388
|
+
n.skills,
|
|
389
|
+
L.maxNamesPerList,
|
|
390
|
+
PIPELINE_TOOL_NAME_PATTERN,
|
|
391
|
+
"skill names"
|
|
392
|
+
);
|
|
393
|
+
if (n.secrets !== void 0)
|
|
394
|
+
c.names(`${p}/secrets`, n.secrets, L.maxSecretsPerNode, SECRET_NAME, "secret names");
|
|
395
|
+
if (n.routes !== void 0) {
|
|
396
|
+
if (!Array.isArray(n.routes)) c.add(`${p}/routes`, "type", "must be an array of routes");
|
|
397
|
+
else if (n.routes.length > L.maxRoutes)
|
|
398
|
+
c.add(`${p}/routes`, "too_many", `at most ${L.maxRoutes} routes`);
|
|
399
|
+
else {
|
|
400
|
+
const labels = /* @__PURE__ */ new Set();
|
|
401
|
+
n.routes.forEach((r, j) => {
|
|
402
|
+
const rp = `${p}/routes${seg(j)}`;
|
|
403
|
+
if (!isObject(r)) {
|
|
404
|
+
c.add(rp, "type", "a route is an object { label, description? }");
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
c.known(rp, r, ["label", "description"]);
|
|
408
|
+
if (c.string(`${rp}/label`, r.label, { min: 1, max: L.routeLabelChars })) {
|
|
409
|
+
if (labels.has(r.label)) c.add(`${rp}/label`, "duplicate", `route "${r.label}" twice`);
|
|
410
|
+
labels.add(r.label);
|
|
411
|
+
}
|
|
412
|
+
if (r.description !== void 0)
|
|
413
|
+
c.string(`${rp}/description`, r.description, { max: L.descriptionChars });
|
|
414
|
+
});
|
|
415
|
+
if (typeof n.id === "string") routes.set(n.id, labels);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
if (n.join !== void 0 && n.join !== "all" && n.join !== "any")
|
|
419
|
+
c.add(`${p}/join`, "enum", 'must be "all" or "any"');
|
|
420
|
+
if (n.settings !== void 0) checkSettings(c, `${p}/settings`, n.settings);
|
|
421
|
+
if (n.position !== void 0) {
|
|
422
|
+
const pos = n.position;
|
|
423
|
+
if (!isObject(pos) || typeof pos.x !== "number" || typeof pos.y !== "number" || !Number.isFinite(pos.x) || !Number.isFinite(pos.y)) {
|
|
424
|
+
c.add(`${p}/position`, "type", "must be { x, y } with finite numbers");
|
|
425
|
+
} else c.known(`${p}/position`, pos, ["x", "y"]);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
if (d.entry === void 0) c.add("/entry", "required", "a pipeline needs an entry node");
|
|
430
|
+
else if (c.string("/entry", d.entry, { min: 1, max: 64 }) && Array.isArray(d.nodes)) {
|
|
431
|
+
if (nodeIds.size && !nodeIds.has(d.entry))
|
|
432
|
+
c.add("/entry", "unknown_node", `there is no node "${d.entry}"`);
|
|
433
|
+
}
|
|
434
|
+
if (!Array.isArray(d.edges)) {
|
|
435
|
+
c.add("/edges", d.edges === void 0 ? "required" : "type", "must be an array of edges");
|
|
436
|
+
} else if (d.edges.length > L.maxEdges) {
|
|
437
|
+
c.add("/edges", "too_many", `at most ${L.maxEdges} edges`);
|
|
438
|
+
} else {
|
|
439
|
+
const edgeIds = /* @__PURE__ */ new Set();
|
|
440
|
+
d.edges.forEach((e, i) => {
|
|
441
|
+
const p = `/edges${seg(i)}`;
|
|
442
|
+
if (!isObject(e)) {
|
|
443
|
+
c.add(p, "type", `an edge is an object, not ${kindOfValue(e)}`);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
c.known(p, e, EDGE_KEYS);
|
|
447
|
+
if (e.id === void 0) c.add(`${p}/id`, "required", "an edge needs an id");
|
|
448
|
+
else if (c.string(`${p}/id`, e.id, {
|
|
449
|
+
pattern: PIPELINE_EDGE_ID_PATTERN,
|
|
450
|
+
patternText: 'letters, digits, ".", "_" and "-" (1 to 64)'
|
|
451
|
+
})) {
|
|
452
|
+
if (edgeIds.has(e.id)) c.add(`${p}/id`, "duplicate", `edge id "${e.id}" is used twice`);
|
|
453
|
+
edgeIds.add(e.id);
|
|
454
|
+
}
|
|
455
|
+
for (const end of ["from", "to"]) {
|
|
456
|
+
if (e[end] === void 0) c.add(`${p}/${end}`, "required", `an edge needs "${end}"`);
|
|
457
|
+
else if (c.string(`${p}/${end}`, e[end], { min: 1, max: 64 }) && nodeIds.size) {
|
|
458
|
+
if (!nodeIds.has(e[end]))
|
|
459
|
+
c.add(`${p}/${end}`, "unknown_node", `there is no node "${e[end]}"`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (e.when !== void 0) {
|
|
463
|
+
const source = typeof e.from === "string" ? e.from : void 0;
|
|
464
|
+
checkCondition(
|
|
465
|
+
c,
|
|
466
|
+
`${p}/when`,
|
|
467
|
+
e.when,
|
|
468
|
+
source && nodeIds.has(source) ? routes.get(source) ?? /* @__PURE__ */ new Set() : void 0
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
return c.issues.length ? { ok: false, errors: c.issues } : { ok: true, document: input, errors: [] };
|
|
474
|
+
};
|
|
475
|
+
var formatPipelineIssues = (issues) => issues.map((i) => `${i.path || "(document)"}: ${i.message}`).join("\n");
|
|
476
|
+
|
|
477
|
+
// src/pipeline-format/references.ts
|
|
478
|
+
var secretRefsIn = (value, path, out) => {
|
|
479
|
+
if (isSecretRef(value)) {
|
|
480
|
+
out.push({ name: value.$secret, path });
|
|
481
|
+
} else if (Array.isArray(value)) {
|
|
482
|
+
value.forEach((v, i) => secretRefsIn(v, `${path}/${i}`, out));
|
|
483
|
+
} else if (value && typeof value === "object") {
|
|
484
|
+
for (const [k, v] of Object.entries(value)) {
|
|
485
|
+
secretRefsIn(v, `${path}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`, out);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
var pipelineReferences = (doc) => {
|
|
490
|
+
const out = [];
|
|
491
|
+
doc.nodes.forEach((n, i) => {
|
|
492
|
+
const at = `/nodes/${i}`;
|
|
493
|
+
if (n.model !== void 0)
|
|
494
|
+
out.push({ kind: "model", name: n.model, path: `${at}/model`, nodeId: n.id });
|
|
495
|
+
const lists = [
|
|
496
|
+
["tool", n.tools, "tools"],
|
|
497
|
+
["mcpServer", n.mcpServers, "mcpServers"],
|
|
498
|
+
["skill", n.skills, "skills"],
|
|
499
|
+
["secret", n.secrets, "secrets"]
|
|
500
|
+
];
|
|
501
|
+
for (const [kind, names2, key] of lists) {
|
|
502
|
+
names2?.forEach((name, j) => out.push({ kind, name, path: `${at}/${key}/${j}`, nodeId: n.id }));
|
|
503
|
+
}
|
|
504
|
+
const refs = [];
|
|
505
|
+
if (n.settings) secretRefsIn(n.settings, `${at}/settings`, refs);
|
|
506
|
+
for (const r of refs) out.push({ kind: "secret", ...r, nodeId: n.id });
|
|
507
|
+
});
|
|
508
|
+
return out;
|
|
509
|
+
};
|
|
510
|
+
var KEY = {
|
|
511
|
+
tool: "tools",
|
|
512
|
+
mcpServer: "mcpServers",
|
|
513
|
+
skill: "skills",
|
|
514
|
+
model: "models",
|
|
515
|
+
secret: "secrets"
|
|
516
|
+
};
|
|
517
|
+
var WORD = {
|
|
518
|
+
tool: "tool",
|
|
519
|
+
mcpServer: "MCP server",
|
|
520
|
+
skill: "skill",
|
|
521
|
+
model: "model",
|
|
522
|
+
secret: "secret"
|
|
523
|
+
};
|
|
524
|
+
var asPredicate = (r) => {
|
|
525
|
+
if (!r) return () => false;
|
|
526
|
+
if (typeof r === "function") return r;
|
|
527
|
+
const set = new Set(r);
|
|
528
|
+
return (name) => set.has(name);
|
|
529
|
+
};
|
|
530
|
+
var unresolvedReferences = (doc, resolvers) => {
|
|
531
|
+
const has = Object.fromEntries(
|
|
532
|
+
Object.keys(KEY).map((k) => [k, asPredicate(resolvers[KEY[k]])])
|
|
533
|
+
);
|
|
534
|
+
return pipelineReferences(doc).filter((r) => !has[r.kind](r.name)).map((r) => ({
|
|
535
|
+
path: r.path,
|
|
536
|
+
code: "unresolved_reference",
|
|
537
|
+
message: `node "${r.nodeId}": ${WORD[r.kind]} "${r.name}" is not available on this executor`
|
|
538
|
+
}));
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
// src/pipeline-format/convert.ts
|
|
542
|
+
var clone = (v) => v === void 0 ? v : JSON.parse(JSON.stringify(v));
|
|
543
|
+
var pick = (from, keys) => {
|
|
544
|
+
const out = {};
|
|
545
|
+
for (const k of keys) {
|
|
546
|
+
if (from[k] !== void 0) out[k] = clone(from[k]);
|
|
547
|
+
}
|
|
548
|
+
return out;
|
|
549
|
+
};
|
|
550
|
+
var SHARED_NODE_KEYS = [
|
|
551
|
+
"id",
|
|
552
|
+
"name",
|
|
553
|
+
"instructions",
|
|
554
|
+
"model",
|
|
555
|
+
"tools",
|
|
556
|
+
"mcpServers",
|
|
557
|
+
"skills",
|
|
558
|
+
"routes",
|
|
559
|
+
"join",
|
|
560
|
+
"settings",
|
|
561
|
+
"position"
|
|
562
|
+
];
|
|
563
|
+
var documentToDefinition = (doc) => ({
|
|
564
|
+
version: 1,
|
|
565
|
+
name: doc.title ?? doc.name,
|
|
566
|
+
entry: doc.entry,
|
|
567
|
+
nodes: doc.nodes.map((n) => pick(n, SHARED_NODE_KEYS)),
|
|
568
|
+
edges: doc.edges.map((e) => pick(e, ["id", "from", "to", "when"])),
|
|
569
|
+
...doc.limits ? { limits: clone(doc.limits) } : {}
|
|
570
|
+
});
|
|
571
|
+
var pipelineNameOf = (text) => {
|
|
572
|
+
const slug = text.toLowerCase().normalize("NFKD").replace(/[^a-z0-9_-]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+/g, "-").replace(/-$/, "").slice(0, 64).replace(/-$/, "");
|
|
573
|
+
return slug || "pipeline";
|
|
574
|
+
};
|
|
575
|
+
var definitionToDocument = (def, options = {}) => {
|
|
576
|
+
const base = options.base;
|
|
577
|
+
const name = options.name ?? base?.name ?? pipelineNameOf(def.name ?? "pipeline");
|
|
578
|
+
const secretsOf = new Map(
|
|
579
|
+
(base?.nodes ?? []).filter((n) => n.secrets).map((n) => [n.id, n.secrets])
|
|
580
|
+
);
|
|
581
|
+
const description = options.description ?? base?.description;
|
|
582
|
+
const title = def.name !== void 0 && def.name !== name ? def.name : void 0;
|
|
583
|
+
const doc = {
|
|
584
|
+
...base?.$schema !== void 0 ? { $schema: base.$schema } : {},
|
|
585
|
+
format: PIPELINE_FORMAT,
|
|
586
|
+
schemaVersion: PIPELINE_SCHEMA_VERSION,
|
|
587
|
+
name,
|
|
588
|
+
...title !== void 0 ? { title } : {},
|
|
589
|
+
...description !== void 0 ? { description } : {},
|
|
590
|
+
entry: def.entry,
|
|
591
|
+
...def.limits ? { limits: clone(def.limits) } : {},
|
|
592
|
+
nodes: def.nodes.map((n) => {
|
|
593
|
+
const node = pick(n, SHARED_NODE_KEYS);
|
|
594
|
+
if (n.settings !== void 0)
|
|
595
|
+
node.settings = clone(n.settings);
|
|
596
|
+
const secrets = secretsOf.get(n.id);
|
|
597
|
+
return secrets ? { ...node, secrets: [...secrets] } : node;
|
|
598
|
+
}),
|
|
599
|
+
edges: def.edges.map((e, i) => ({
|
|
600
|
+
...pick(e, ["from", "to", "when"]),
|
|
601
|
+
id: e.id ?? `e${i}`
|
|
602
|
+
}))
|
|
603
|
+
};
|
|
604
|
+
doc.edges = doc.edges.map((e) => ({
|
|
605
|
+
id: e.id,
|
|
606
|
+
from: e.from,
|
|
607
|
+
to: e.to,
|
|
608
|
+
...e.when ? { when: e.when } : {}
|
|
609
|
+
}));
|
|
610
|
+
return doc;
|
|
611
|
+
};
|
|
612
|
+
var stableJson = (v) => {
|
|
613
|
+
if (Array.isArray(v)) return `[${v.map(stableJson).join(",")}]`;
|
|
614
|
+
if (v !== null && typeof v === "object") {
|
|
615
|
+
const o = v;
|
|
616
|
+
return `{${Object.keys(o).filter((k) => o[k] !== void 0).sort().map((k) => `${JSON.stringify(k)}:${stableJson(o[k])}`).join(",")}}`;
|
|
617
|
+
}
|
|
618
|
+
return JSON.stringify(v);
|
|
619
|
+
};
|
|
620
|
+
var canonicalPipelineDocument = (doc) => definitionToDocument(documentToDefinition(doc), { name: doc.name, base: doc });
|
|
621
|
+
var pipelineDocumentsEqual = (a, b) => stableJson(canonicalPipelineDocument(a)) === stableJson(canonicalPipelineDocument(b));
|
|
622
|
+
var emptyPipelineDocument = (name = "pipeline") => ({
|
|
623
|
+
format: PIPELINE_FORMAT,
|
|
624
|
+
schemaVersion: PIPELINE_SCHEMA_VERSION,
|
|
625
|
+
name,
|
|
626
|
+
entry: "start",
|
|
627
|
+
nodes: [{ id: "start", name: "Start", instructions: "", position: { x: 0, y: 0 } }],
|
|
628
|
+
edges: []
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// src/pipeline-format/schema.ts
|
|
632
|
+
var src = (re) => re.source;
|
|
633
|
+
var names = (re, max) => ({
|
|
634
|
+
type: "array",
|
|
635
|
+
maxItems: max,
|
|
636
|
+
uniqueItems: true,
|
|
637
|
+
items: { type: "string", pattern: src(re) }
|
|
638
|
+
});
|
|
639
|
+
var PIPELINE_DOCUMENT_SCHEMA_ID = `urn:dudko-dev:agent-pipeline:${PIPELINE_SCHEMA_VERSION}`;
|
|
640
|
+
var pipelineDocumentJsonSchema = {
|
|
641
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
642
|
+
$id: PIPELINE_DOCUMENT_SCHEMA_ID,
|
|
643
|
+
title: "Pipeline definition",
|
|
644
|
+
description: "A pipeline of agents: nodes, edges with conditions as data, and references to tools, MCP servers, skills, models and secrets by name. Never a secret value.",
|
|
645
|
+
type: "object",
|
|
646
|
+
additionalProperties: false,
|
|
647
|
+
required: ["format", "schemaVersion", "name", "entry", "nodes", "edges"],
|
|
648
|
+
properties: {
|
|
649
|
+
$schema: { type: "string", maxLength: 500 },
|
|
650
|
+
format: { const: PIPELINE_FORMAT },
|
|
651
|
+
schemaVersion: { const: PIPELINE_SCHEMA_VERSION },
|
|
652
|
+
name: { type: "string", pattern: src(PIPELINE_NAME_PATTERN) },
|
|
653
|
+
title: { type: "string", maxLength: PIPELINE_FORMAT_LIMITS.titleChars },
|
|
654
|
+
description: { type: "string", maxLength: PIPELINE_FORMAT_LIMITS.descriptionChars },
|
|
655
|
+
entry: { type: "string", minLength: 1, maxLength: 64 },
|
|
656
|
+
limits: {
|
|
657
|
+
type: "object",
|
|
658
|
+
additionalProperties: false,
|
|
659
|
+
properties: {
|
|
660
|
+
maxNodeVisits: { type: "integer", minimum: 1, maximum: PIPELINE_FORMAT_LIMITS.maxNodeVisits },
|
|
661
|
+
maxRuns: { type: "integer", minimum: 1, maximum: PIPELINE_FORMAT_LIMITS.maxRuns }
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
nodes: { type: "array", minItems: 1, maxItems: PIPELINE_FORMAT_LIMITS.maxNodes, items: { $ref: "#/$defs/node" } },
|
|
665
|
+
edges: { type: "array", maxItems: PIPELINE_FORMAT_LIMITS.maxEdges, items: { $ref: "#/$defs/edge" } }
|
|
666
|
+
},
|
|
667
|
+
$defs: {
|
|
668
|
+
node: {
|
|
669
|
+
type: "object",
|
|
670
|
+
additionalProperties: false,
|
|
671
|
+
required: ["id"],
|
|
672
|
+
properties: {
|
|
673
|
+
id: { type: "string", pattern: src(PIPELINE_NODE_ID_PATTERN) },
|
|
674
|
+
name: { type: "string", maxLength: PIPELINE_FORMAT_LIMITS.titleChars },
|
|
675
|
+
instructions: { type: "string", maxLength: PIPELINE_FORMAT_LIMITS.instructionsChars },
|
|
676
|
+
model: { type: "string", pattern: src(PIPELINE_MODEL_PATTERN) },
|
|
677
|
+
tools: names(PIPELINE_TOOL_NAME_PATTERN, PIPELINE_FORMAT_LIMITS.maxNamesPerList),
|
|
678
|
+
mcpServers: names(PIPELINE_SERVER_NAME_PATTERN, PIPELINE_FORMAT_LIMITS.maxNamesPerList),
|
|
679
|
+
skills: names(PIPELINE_TOOL_NAME_PATTERN, PIPELINE_FORMAT_LIMITS.maxNamesPerList),
|
|
680
|
+
secrets: names(SECRET_NAME, PIPELINE_FORMAT_LIMITS.maxSecretsPerNode),
|
|
681
|
+
routes: { type: "array", maxItems: PIPELINE_FORMAT_LIMITS.maxRoutes, items: { $ref: "#/$defs/route" } },
|
|
682
|
+
join: { enum: ["all", "any"] },
|
|
683
|
+
settings: { type: "object" },
|
|
684
|
+
position: {
|
|
685
|
+
type: "object",
|
|
686
|
+
additionalProperties: false,
|
|
687
|
+
required: ["x", "y"],
|
|
688
|
+
properties: { x: { type: "number" }, y: { type: "number" } }
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
route: {
|
|
693
|
+
type: "object",
|
|
694
|
+
additionalProperties: false,
|
|
695
|
+
required: ["label"],
|
|
696
|
+
properties: {
|
|
697
|
+
label: { type: "string", minLength: 1, maxLength: PIPELINE_FORMAT_LIMITS.routeLabelChars },
|
|
698
|
+
description: { type: "string", maxLength: PIPELINE_FORMAT_LIMITS.descriptionChars }
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
edge: {
|
|
702
|
+
type: "object",
|
|
703
|
+
additionalProperties: false,
|
|
704
|
+
required: ["id", "from", "to"],
|
|
705
|
+
properties: {
|
|
706
|
+
id: { type: "string", pattern: src(PIPELINE_EDGE_ID_PATTERN) },
|
|
707
|
+
from: { type: "string", minLength: 1, maxLength: 64 },
|
|
708
|
+
to: { type: "string", minLength: 1, maxLength: 64 },
|
|
709
|
+
when: { $ref: "#/$defs/condition" }
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
condition: {
|
|
713
|
+
oneOf: [
|
|
714
|
+
{
|
|
715
|
+
type: "object",
|
|
716
|
+
additionalProperties: false,
|
|
717
|
+
required: ["kind"],
|
|
718
|
+
properties: { kind: { const: "always" } }
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
type: "object",
|
|
722
|
+
additionalProperties: false,
|
|
723
|
+
required: ["kind"],
|
|
724
|
+
properties: { kind: { const: "otherwise" } }
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
type: "object",
|
|
728
|
+
additionalProperties: false,
|
|
729
|
+
required: ["kind", "text"],
|
|
730
|
+
properties: {
|
|
731
|
+
kind: { const: "contains" },
|
|
732
|
+
text: { type: "string", minLength: 1, maxLength: PIPELINE_FORMAT_LIMITS.conditionTextChars },
|
|
733
|
+
caseSensitive: { type: "boolean" }
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
type: "object",
|
|
738
|
+
additionalProperties: false,
|
|
739
|
+
required: ["kind", "pattern"],
|
|
740
|
+
properties: {
|
|
741
|
+
kind: { const: "matches" },
|
|
742
|
+
pattern: { type: "string", minLength: 1, maxLength: PIPELINE_FORMAT_LIMITS.conditionTextChars },
|
|
743
|
+
flags: { type: "string", pattern: "^[imsu]{0,4}$" }
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
type: "object",
|
|
748
|
+
additionalProperties: false,
|
|
749
|
+
required: ["kind", "label"],
|
|
750
|
+
properties: {
|
|
751
|
+
kind: { const: "route" },
|
|
752
|
+
label: { type: "string", minLength: 1, maxLength: PIPELINE_FORMAT_LIMITS.routeLabelChars }
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
]
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
export {
|
|
760
|
+
PIPELINE_DOCUMENT_SCHEMA_ID,
|
|
761
|
+
PIPELINE_EDGE_ID_PATTERN,
|
|
762
|
+
PIPELINE_FORMAT,
|
|
763
|
+
PIPELINE_FORMAT_LIMITS,
|
|
764
|
+
PIPELINE_MODEL_PATTERN,
|
|
765
|
+
PIPELINE_NAME_PATTERN,
|
|
766
|
+
PIPELINE_NODE_ID_PATTERN,
|
|
767
|
+
PIPELINE_SCHEMA_VERSION,
|
|
768
|
+
PIPELINE_SERVER_NAME_PATTERN,
|
|
769
|
+
PIPELINE_TOOL_NAME_PATTERN,
|
|
770
|
+
SECRET_KEY,
|
|
771
|
+
SECRET_NAME,
|
|
772
|
+
SECRET_SCAN_MAX_CHARS,
|
|
773
|
+
canonicalPipelineDocument,
|
|
774
|
+
definitionToDocument,
|
|
775
|
+
documentToDefinition,
|
|
776
|
+
emptyPipelineDocument,
|
|
777
|
+
formatPipelineIssues,
|
|
778
|
+
isSecretKey,
|
|
779
|
+
isSecretRef,
|
|
780
|
+
looksLikeSecret,
|
|
781
|
+
pipelineDocumentJsonSchema,
|
|
782
|
+
pipelineDocumentsEqual,
|
|
783
|
+
pipelineNameOf,
|
|
784
|
+
pipelineReferences,
|
|
785
|
+
secretKindOf,
|
|
786
|
+
unresolvedReferences,
|
|
787
|
+
validatePipelineDocument
|
|
788
|
+
};
|