@dudko.dev/agent-web-ui 0.0.5 → 0.0.7

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.
Files changed (164) hide show
  1. package/README.md +81 -3
  2. package/dist/{chunk-NHU6WQM5.js → chunk-3TMUUU3O.js} +424 -0
  3. package/dist/{chunk-627OXMFG.js → chunk-HIHUK7YA.js} +5 -0
  4. package/dist/{chunk-S5AHUAFG.js → chunk-JEW2ZWYX.js} +4 -0
  5. package/dist/{chunk-VZCQXE3P.js → chunk-UO2Q7AIV.js} +4 -0
  6. package/dist/{chunk-V33T6VX3.js → chunk-VG5NLFI5.js} +4 -0
  7. package/dist/controller.cjs +460 -16
  8. package/dist/controller.d.cts +53 -5
  9. package/dist/controller.d.ts +53 -5
  10. package/dist/controller.js +58 -17
  11. package/dist/{en-Dg2MtzcJ.d.cts → en-CPCAidve.d.cts} +4 -0
  12. package/dist/{en-Dg2MtzcJ.d.ts → en-CPCAidve.d.ts} +4 -0
  13. package/dist/index.cjs +447 -3
  14. package/dist/index.d.cts +2 -1
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.js +37 -1
  17. package/dist/{labels-ipy-ydkp.d.cts → labels-Dnh2tn8S.d.cts} +8 -0
  18. package/dist/{labels-CCPL7t17.d.ts → labels-h-grbo5N.d.ts} +8 -0
  19. package/dist/locales/be.cjs +9 -0
  20. package/dist/locales/be.d.cts +1 -1
  21. package/dist/locales/be.d.ts +1 -1
  22. package/dist/locales/be.js +5 -1
  23. package/dist/locales/bg.cjs +9 -0
  24. package/dist/locales/bg.d.cts +1 -1
  25. package/dist/locales/bg.d.ts +1 -1
  26. package/dist/locales/bg.js +5 -1
  27. package/dist/locales/ca.cjs +9 -0
  28. package/dist/locales/ca.d.cts +1 -1
  29. package/dist/locales/ca.d.ts +1 -1
  30. package/dist/locales/ca.js +5 -1
  31. package/dist/locales/cs.cjs +9 -0
  32. package/dist/locales/cs.d.cts +1 -1
  33. package/dist/locales/cs.d.ts +1 -1
  34. package/dist/locales/cs.js +5 -1
  35. package/dist/locales/da.cjs +9 -0
  36. package/dist/locales/da.d.cts +1 -1
  37. package/dist/locales/da.d.ts +1 -1
  38. package/dist/locales/da.js +5 -1
  39. package/dist/locales/de.cjs +9 -0
  40. package/dist/locales/de.d.cts +1 -1
  41. package/dist/locales/de.d.ts +1 -1
  42. package/dist/locales/de.js +5 -1
  43. package/dist/locales/el.cjs +9 -0
  44. package/dist/locales/el.d.cts +1 -1
  45. package/dist/locales/el.d.ts +1 -1
  46. package/dist/locales/el.js +5 -1
  47. package/dist/locales/en.cjs +9 -0
  48. package/dist/locales/en.d.cts +1 -1
  49. package/dist/locales/en.d.ts +1 -1
  50. package/dist/locales/en.js +5 -1
  51. package/dist/locales/es-419.cjs +9 -0
  52. package/dist/locales/es-419.d.cts +1 -1
  53. package/dist/locales/es-419.d.ts +1 -1
  54. package/dist/locales/es-419.js +2 -2
  55. package/dist/locales/es.cjs +9 -0
  56. package/dist/locales/es.d.cts +1 -1
  57. package/dist/locales/es.d.ts +1 -1
  58. package/dist/locales/es.js +2 -2
  59. package/dist/locales/fi.cjs +9 -0
  60. package/dist/locales/fi.d.cts +1 -1
  61. package/dist/locales/fi.d.ts +1 -1
  62. package/dist/locales/fi.js +5 -1
  63. package/dist/locales/fr-CA.cjs +9 -0
  64. package/dist/locales/fr-CA.d.cts +1 -1
  65. package/dist/locales/fr-CA.d.ts +1 -1
  66. package/dist/locales/fr-CA.js +2 -2
  67. package/dist/locales/fr.cjs +9 -0
  68. package/dist/locales/fr.d.cts +1 -1
  69. package/dist/locales/fr.d.ts +1 -1
  70. package/dist/locales/fr.js +2 -2
  71. package/dist/locales/gn.cjs +9 -0
  72. package/dist/locales/gn.d.cts +1 -1
  73. package/dist/locales/gn.d.ts +1 -1
  74. package/dist/locales/gn.js +5 -1
  75. package/dist/locales/hr.cjs +9 -0
  76. package/dist/locales/hr.d.cts +1 -1
  77. package/dist/locales/hr.d.ts +1 -1
  78. package/dist/locales/hr.js +5 -1
  79. package/dist/locales/ht.cjs +9 -0
  80. package/dist/locales/ht.d.cts +1 -1
  81. package/dist/locales/ht.d.ts +1 -1
  82. package/dist/locales/ht.js +5 -1
  83. package/dist/locales/hu.cjs +9 -0
  84. package/dist/locales/hu.d.cts +1 -1
  85. package/dist/locales/hu.d.ts +1 -1
  86. package/dist/locales/hu.js +5 -1
  87. package/dist/locales/index.cjs +5 -0
  88. package/dist/locales/index.d.cts +3 -3
  89. package/dist/locales/index.d.ts +3 -3
  90. package/dist/locales/index.js +1 -1
  91. package/dist/locales/it.cjs +9 -0
  92. package/dist/locales/it.d.cts +1 -1
  93. package/dist/locales/it.d.ts +1 -1
  94. package/dist/locales/it.js +5 -1
  95. package/dist/locales/nb.cjs +9 -0
  96. package/dist/locales/nb.d.cts +1 -1
  97. package/dist/locales/nb.d.ts +1 -1
  98. package/dist/locales/nb.js +5 -1
  99. package/dist/locales/nl.cjs +9 -0
  100. package/dist/locales/nl.d.cts +1 -1
  101. package/dist/locales/nl.d.ts +1 -1
  102. package/dist/locales/nl.js +5 -1
  103. package/dist/locales/pl.cjs +9 -0
  104. package/dist/locales/pl.d.cts +1 -1
  105. package/dist/locales/pl.d.ts +1 -1
  106. package/dist/locales/pl.js +5 -1
  107. package/dist/locales/pt-BR.cjs +9 -0
  108. package/dist/locales/pt-BR.d.cts +1 -1
  109. package/dist/locales/pt-BR.d.ts +1 -1
  110. package/dist/locales/pt-BR.js +5 -1
  111. package/dist/locales/pt.cjs +9 -0
  112. package/dist/locales/pt.d.cts +1 -1
  113. package/dist/locales/pt.d.ts +1 -1
  114. package/dist/locales/pt.js +5 -1
  115. package/dist/locales/qu.cjs +9 -0
  116. package/dist/locales/qu.d.cts +1 -1
  117. package/dist/locales/qu.d.ts +1 -1
  118. package/dist/locales/qu.js +5 -1
  119. package/dist/locales/ro.cjs +9 -0
  120. package/dist/locales/ro.d.cts +1 -1
  121. package/dist/locales/ro.d.ts +1 -1
  122. package/dist/locales/ro.js +5 -1
  123. package/dist/locales/ru.cjs +9 -0
  124. package/dist/locales/ru.d.cts +1 -1
  125. package/dist/locales/ru.d.ts +1 -1
  126. package/dist/locales/ru.js +5 -1
  127. package/dist/locales/sk.cjs +9 -0
  128. package/dist/locales/sk.d.cts +1 -1
  129. package/dist/locales/sk.d.ts +1 -1
  130. package/dist/locales/sk.js +5 -1
  131. package/dist/locales/sq.cjs +9 -0
  132. package/dist/locales/sq.d.cts +1 -1
  133. package/dist/locales/sq.d.ts +1 -1
  134. package/dist/locales/sq.js +5 -1
  135. package/dist/locales/sr-Latn.cjs +9 -0
  136. package/dist/locales/sr-Latn.d.cts +1 -1
  137. package/dist/locales/sr-Latn.d.ts +1 -1
  138. package/dist/locales/sr-Latn.js +2 -2
  139. package/dist/locales/sr.cjs +9 -0
  140. package/dist/locales/sr.d.cts +1 -1
  141. package/dist/locales/sr.d.ts +1 -1
  142. package/dist/locales/sr.js +2 -2
  143. package/dist/locales/sv.cjs +9 -0
  144. package/dist/locales/sv.d.cts +1 -1
  145. package/dist/locales/sv.d.ts +1 -1
  146. package/dist/locales/sv.js +5 -1
  147. package/dist/locales/tr.cjs +9 -0
  148. package/dist/locales/tr.d.cts +1 -1
  149. package/dist/locales/tr.d.ts +1 -1
  150. package/dist/locales/tr.js +5 -1
  151. package/dist/locales/uk.cjs +9 -0
  152. package/dist/locales/uk.d.cts +1 -1
  153. package/dist/locales/uk.d.ts +1 -1
  154. package/dist/locales/uk.js +5 -1
  155. package/dist/page-context-BAmw4p6d.d.cts +244 -0
  156. package/dist/page-context-BAmw4p6d.d.ts +244 -0
  157. package/dist/pipeline-format.cjs +842 -0
  158. package/dist/pipeline-format.d.cts +512 -0
  159. package/dist/pipeline-format.d.ts +512 -0
  160. package/dist/pipeline-format.js +788 -0
  161. package/dist/styles.css +55 -0
  162. package/dist/{types-CQquuZpl.d.cts → types-B5cyqkWY.d.cts} +1 -1
  163. package/dist/{types-CXZfZVP5.d.ts → types-BgNjWN5Z.d.ts} +1 -1
  164. 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
+ };