@pipelex/mthds-ui 0.11.0 → 0.13.0
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 +22 -0
- package/dist/chunk-IMQ7MVYL.js +163 -0
- package/dist/chunk-IMQ7MVYL.js.map +1 -0
- package/dist/{chunk-R34J4GFM.js → chunk-XCZLRCEJ.js} +54 -144
- package/dist/chunk-XCZLRCEJ.js.map +1 -0
- package/dist/graph/index.d.ts +4 -4
- package/dist/graph/index.js +33 -21
- package/dist/graph/react/graph-core.css +34 -0
- package/dist/graph/react/index.css +173 -0
- package/dist/graph/react/index.css.map +1 -1
- package/dist/graph/react/index.d.ts +54 -3
- package/dist/graph/react/index.js +514 -187
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/stuff/StuffViewer.css +12 -0
- package/dist/graph/react/viewer/GraphToolbar.css +201 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -21
- package/dist/standalone/graph-standalone.html +256 -9
- package/dist/standalone/graph-viewer.css +247 -0
- package/dist/standalone/graph-viewer.js +9 -9
- package/dist/static-graph/index.d.ts +118 -0
- package/dist/static-graph/index.js +1278 -0
- package/dist/static-graph/index.js.map +1 -0
- package/dist/{types-B3nefYpV.d.ts → types-Cm4147S5.d.ts} +59 -4
- package/package.json +7 -2
- package/dist/chunk-R34J4GFM.js.map +0 -1
|
@@ -0,0 +1,1278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KNOWN_PIPE_TYPES
|
|
3
|
+
} from "../chunk-IMQ7MVYL.js";
|
|
4
|
+
import {
|
|
5
|
+
__spreadProps,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "../chunk-2NMEKWO5.js";
|
|
8
|
+
|
|
9
|
+
// src/static-graph/types.ts
|
|
10
|
+
var UNKNOWN_DOMAIN = "unknown";
|
|
11
|
+
function isPlainObject(value) {
|
|
12
|
+
if (typeof value !== "object" || value === null) return false;
|
|
13
|
+
const proto = Object.getPrototypeOf(value);
|
|
14
|
+
return proto === Object.prototype || proto === null;
|
|
15
|
+
}
|
|
16
|
+
function strOrNull(value) {
|
|
17
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
18
|
+
}
|
|
19
|
+
function intOrNull(value) {
|
|
20
|
+
return typeof value === "number" && Number.isInteger(value) ? value : null;
|
|
21
|
+
}
|
|
22
|
+
function boolOrNull(value) {
|
|
23
|
+
return typeof value === "boolean" ? value : null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/static-graph/conceptRefs.ts
|
|
27
|
+
var NATIVE_DOMAIN = "native";
|
|
28
|
+
var NATIVE_CONCEPT_DESCRIPTIONS = {
|
|
29
|
+
Dynamic: "Dynamically typed content",
|
|
30
|
+
Text: "A text",
|
|
31
|
+
Image: "An image",
|
|
32
|
+
Document: "A document",
|
|
33
|
+
Html: "HTML content",
|
|
34
|
+
TextAndImages: "A text with images",
|
|
35
|
+
Number: "A number",
|
|
36
|
+
Page: "The content of a page of a document",
|
|
37
|
+
JSON: "JSON content",
|
|
38
|
+
SearchResult: "A search result",
|
|
39
|
+
Anything: "Anything",
|
|
40
|
+
Composite: "A named composition of multiple contents"
|
|
41
|
+
};
|
|
42
|
+
var NATIVE_CONCEPT_CODES = new Set(
|
|
43
|
+
Object.keys(NATIVE_CONCEPT_DESCRIPTIONS)
|
|
44
|
+
);
|
|
45
|
+
var CONCEPT_REF_RE = /^(?:([A-Za-z0-9_][A-Za-z0-9_.]*)\.)?([A-Za-z0-9_]+)(?:\[(\d*)\])?$/;
|
|
46
|
+
function parseConceptRef(raw) {
|
|
47
|
+
if (typeof raw !== "string") return null;
|
|
48
|
+
const match = CONCEPT_REF_RE.exec(raw.trim());
|
|
49
|
+
if (!match) return null;
|
|
50
|
+
const [, domain, code, multiplicity] = match;
|
|
51
|
+
return {
|
|
52
|
+
domain: domain != null ? domain : null,
|
|
53
|
+
code,
|
|
54
|
+
multiplicity: multiplicity === void 0 ? null : multiplicity === "" ? true : Number.parseInt(multiplicity, 10)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function qualifiedStructureClassName(domain, code) {
|
|
58
|
+
return `${domain.replaceAll(".", "\xB7")}__${code}`;
|
|
59
|
+
}
|
|
60
|
+
function nativeConceptInfo(code) {
|
|
61
|
+
var _a;
|
|
62
|
+
return {
|
|
63
|
+
code,
|
|
64
|
+
domain_code: NATIVE_DOMAIN,
|
|
65
|
+
description: (_a = NATIVE_CONCEPT_DESCRIPTIONS[code]) != null ? _a : code,
|
|
66
|
+
structure_class_name: `${code}Content`,
|
|
67
|
+
refines: null
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function stubConceptInfo(code, domain) {
|
|
71
|
+
return {
|
|
72
|
+
code,
|
|
73
|
+
domain_code: domain,
|
|
74
|
+
description: "",
|
|
75
|
+
structure_class_name: qualifiedStructureClassName(domain, code),
|
|
76
|
+
refines: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function resolveConceptInfo(parts, currentDomain, localConcepts) {
|
|
80
|
+
if (parts.domain === NATIVE_DOMAIN) {
|
|
81
|
+
return NATIVE_CONCEPT_CODES.has(parts.code) ? nativeConceptInfo(parts.code) : stubConceptInfo(parts.code, NATIVE_DOMAIN);
|
|
82
|
+
}
|
|
83
|
+
if (parts.domain !== null && parts.domain !== currentDomain) {
|
|
84
|
+
return stubConceptInfo(parts.code, parts.domain);
|
|
85
|
+
}
|
|
86
|
+
const local = localConcepts[parts.code];
|
|
87
|
+
if (local) return local;
|
|
88
|
+
if (parts.domain === null && NATIVE_CONCEPT_CODES.has(parts.code)) {
|
|
89
|
+
return nativeConceptInfo(parts.code);
|
|
90
|
+
}
|
|
91
|
+
return stubConceptInfo(parts.code, currentDomain);
|
|
92
|
+
}
|
|
93
|
+
function resolveStuffSpec(raw, currentDomain, localConcepts) {
|
|
94
|
+
const parts = parseConceptRef(raw);
|
|
95
|
+
if (parts === null) return null;
|
|
96
|
+
return {
|
|
97
|
+
concept: resolveConceptInfo(parts, currentDomain, localConcepts),
|
|
98
|
+
multiplicity: parts.multiplicity
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/static-graph/parseMthdsBundle.ts
|
|
103
|
+
import { parse as parseToml } from "smol-toml";
|
|
104
|
+
|
|
105
|
+
// src/static-graph/normalizePipe.ts
|
|
106
|
+
function makeTemplate(template, category) {
|
|
107
|
+
return { template, templating_style: null, category, extra_context: null };
|
|
108
|
+
}
|
|
109
|
+
function modelToString(value) {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
if (typeof value === "string") return strOrNull(value);
|
|
112
|
+
if (isPlainObject(value)) {
|
|
113
|
+
return (_b = (_a = strOrNull(value.model)) != null ? _a : strOrNull(value.raw)) != null ? _b : strOrNull(value.name);
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function stringArrayOrNull(value) {
|
|
118
|
+
if (!Array.isArray(value)) return null;
|
|
119
|
+
return value.filter((item) => typeof item === "string");
|
|
120
|
+
}
|
|
121
|
+
function normalizeInputs(raw, pipeCode, ctx) {
|
|
122
|
+
const inputs = {};
|
|
123
|
+
if (raw === void 0 || raw === null) return inputs;
|
|
124
|
+
if (!isPlainObject(raw)) {
|
|
125
|
+
ctx.diagnostics.push({
|
|
126
|
+
severity: "warning",
|
|
127
|
+
code: "invalid-pipe-entry",
|
|
128
|
+
message: `pipe "${pipeCode}": inputs is not a table \u2014 ignored`,
|
|
129
|
+
path: `pipe.${pipeCode}.inputs`
|
|
130
|
+
});
|
|
131
|
+
return inputs;
|
|
132
|
+
}
|
|
133
|
+
for (const [name, ref] of Object.entries(raw)) {
|
|
134
|
+
const spec = resolveStuffSpec(ref, ctx.domain, ctx.concepts);
|
|
135
|
+
if (spec === null) {
|
|
136
|
+
ctx.diagnostics.push({
|
|
137
|
+
severity: "warning",
|
|
138
|
+
code: "invalid-concept-ref",
|
|
139
|
+
message: `pipe "${pipeCode}": input "${name}" has an uninterpretable concept ref \u2014 skipped`,
|
|
140
|
+
path: `pipe.${pipeCode}.inputs.${name}`
|
|
141
|
+
});
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
inputs[name] = spec;
|
|
145
|
+
}
|
|
146
|
+
return inputs;
|
|
147
|
+
}
|
|
148
|
+
function normalizeOutput(raw, pipeCode, ctx) {
|
|
149
|
+
const spec = resolveStuffSpec(raw, ctx.domain, ctx.concepts);
|
|
150
|
+
if (spec !== null) return spec;
|
|
151
|
+
ctx.diagnostics.push({
|
|
152
|
+
severity: "warning",
|
|
153
|
+
code: "missing-pipe-output",
|
|
154
|
+
message: `pipe "${pipeCode}": missing or uninterpretable output \u2014 assuming native.Anything`,
|
|
155
|
+
path: `pipe.${pipeCode}.output`
|
|
156
|
+
});
|
|
157
|
+
return { concept: nativeConceptInfo("Anything"), multiplicity: null };
|
|
158
|
+
}
|
|
159
|
+
function normalizeSubPipe(raw, pipeCode, path, ctx) {
|
|
160
|
+
var _a;
|
|
161
|
+
if (!isPlainObject(raw) || strOrNull(raw.pipe) === null) {
|
|
162
|
+
ctx.diagnostics.push({
|
|
163
|
+
severity: "warning",
|
|
164
|
+
code: "invalid-sub-pipe",
|
|
165
|
+
message: `pipe "${pipeCode}": sub-pipe entry without a "pipe" ref \u2014 skipped`,
|
|
166
|
+
path
|
|
167
|
+
});
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const batchOver = strOrNull(raw.batch_over);
|
|
171
|
+
const batchAs = strOrNull(raw.batch_as);
|
|
172
|
+
let batchParams = null;
|
|
173
|
+
if (batchOver !== null && batchAs !== null) {
|
|
174
|
+
batchParams = { input_list_stuff_name: batchOver, input_item_stuff_name: batchAs };
|
|
175
|
+
} else if (batchOver !== null || batchAs !== null) {
|
|
176
|
+
ctx.diagnostics.push({
|
|
177
|
+
severity: "warning",
|
|
178
|
+
code: "incomplete-batch-spec",
|
|
179
|
+
message: `pipe "${pipeCode}": sub-pipe "${raw.pipe}" sets only one of batch_over/batch_as \u2014 batching ignored`,
|
|
180
|
+
path
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
let outputMultiplicity = (_a = intOrNull(raw.nb_output)) != null ? _a : raw.multiple_output === true ? true : null;
|
|
184
|
+
if (batchParams !== null && outputMultiplicity === null) outputMultiplicity = true;
|
|
185
|
+
return {
|
|
186
|
+
pipe_code: raw.pipe,
|
|
187
|
+
output_name: strOrNull(raw.result),
|
|
188
|
+
output_multiplicity: outputMultiplicity,
|
|
189
|
+
batch_params: batchParams
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function normalizeSubPipeList(raw, pipeCode, key, ctx) {
|
|
193
|
+
if (!Array.isArray(raw)) {
|
|
194
|
+
if (raw !== void 0) {
|
|
195
|
+
ctx.diagnostics.push({
|
|
196
|
+
severity: "warning",
|
|
197
|
+
code: "invalid-pipe-entry",
|
|
198
|
+
message: `pipe "${pipeCode}": ${key} is not an array \u2014 treated as empty`,
|
|
199
|
+
path: `pipe.${pipeCode}.${key}`
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
return raw.map(
|
|
205
|
+
(entry, index) => normalizeSubPipe(entry, pipeCode, `pipe.${pipeCode}.${key}[${index}]`, ctx)
|
|
206
|
+
).filter((entry) => entry !== null);
|
|
207
|
+
}
|
|
208
|
+
function normalizeConstructField(value) {
|
|
209
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value)) {
|
|
210
|
+
return { method: "fixed", fixed_value: value };
|
|
211
|
+
}
|
|
212
|
+
if (isPlainObject(value)) {
|
|
213
|
+
if (typeof value.from === "string") {
|
|
214
|
+
return {
|
|
215
|
+
method: "from_var",
|
|
216
|
+
from_path: value.from,
|
|
217
|
+
list_to_dict_keyed_by: strOrNull(value.list_to_dict_keyed_by)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (typeof value.template === "string") {
|
|
221
|
+
return { method: "template", template: value.template };
|
|
222
|
+
}
|
|
223
|
+
const nested = normalizeConstruct(value);
|
|
224
|
+
if (nested !== null) return { method: "nested", nested };
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
function normalizeConstruct(raw) {
|
|
229
|
+
if (!isPlainObject(raw)) return null;
|
|
230
|
+
const fields = {};
|
|
231
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
232
|
+
const field = normalizeConstructField(value);
|
|
233
|
+
if (field !== null) fields[name] = field;
|
|
234
|
+
}
|
|
235
|
+
return Object.keys(fields).length > 0 ? { fields } : null;
|
|
236
|
+
}
|
|
237
|
+
function normalizePipe(code, raw, ctx) {
|
|
238
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
239
|
+
const typeValue = raw.type;
|
|
240
|
+
if (typeof typeValue !== "string" || !KNOWN_PIPE_TYPES.has(typeValue)) {
|
|
241
|
+
ctx.diagnostics.push({
|
|
242
|
+
severity: "error",
|
|
243
|
+
code: "unknown-pipe-type",
|
|
244
|
+
message: `pipe "${code}": unknown pipe type ${JSON.stringify(typeValue)} \u2014 pipe skipped`,
|
|
245
|
+
path: `pipe.${code}.type`
|
|
246
|
+
});
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
const type = typeValue;
|
|
250
|
+
const base = {
|
|
251
|
+
code,
|
|
252
|
+
domain_code: ctx.domain,
|
|
253
|
+
description: (_a = strOrNull(raw.description)) != null ? _a : "",
|
|
254
|
+
inputs: normalizeInputs(raw.inputs, code, ctx),
|
|
255
|
+
output: normalizeOutput(raw.output, code, ctx)
|
|
256
|
+
};
|
|
257
|
+
switch (type) {
|
|
258
|
+
case "PipeSequence":
|
|
259
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
260
|
+
type,
|
|
261
|
+
pipe_category: "PipeController",
|
|
262
|
+
sequential_sub_pipes: normalizeSubPipeList(raw.steps, code, "steps", ctx)
|
|
263
|
+
});
|
|
264
|
+
case "PipeParallel":
|
|
265
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
266
|
+
type,
|
|
267
|
+
pipe_category: "PipeController",
|
|
268
|
+
parallel_sub_pipes: normalizeSubPipeList(raw.branches, code, "branches", ctx),
|
|
269
|
+
add_each_output: raw.add_each_output === true,
|
|
270
|
+
combined_output: strOrNull(raw.combined_output)
|
|
271
|
+
});
|
|
272
|
+
case "PipeCondition": {
|
|
273
|
+
const outcomeMap = {};
|
|
274
|
+
if (isPlainObject(raw.outcomes)) {
|
|
275
|
+
for (const [outcome, pipeRef] of Object.entries(raw.outcomes)) {
|
|
276
|
+
if (typeof pipeRef === "string" && pipeRef.length > 0) {
|
|
277
|
+
outcomeMap[outcome] = pipeRef;
|
|
278
|
+
} else {
|
|
279
|
+
ctx.diagnostics.push({
|
|
280
|
+
severity: "warning",
|
|
281
|
+
code: "invalid-pipe-entry",
|
|
282
|
+
message: `pipe "${code}": outcome "${outcome}" is not a pipe ref \u2014 skipped`,
|
|
283
|
+
path: `pipe.${code}.outcomes.${outcome}`
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
289
|
+
type,
|
|
290
|
+
pipe_category: "PipeController",
|
|
291
|
+
expression: (_c = (_b = strOrNull(raw.expression)) != null ? _b : strOrNull(raw.expression_template)) != null ? _c : "",
|
|
292
|
+
outcome_map: outcomeMap,
|
|
293
|
+
default_outcome: (_d = strOrNull(raw.default_outcome)) != null ? _d : "",
|
|
294
|
+
add_alias_from_expression_to: strOrNull(raw.add_alias_from_expression_to)
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
case "PipeBatch": {
|
|
298
|
+
const branchPipeCode = strOrNull(raw.branch_pipe_code);
|
|
299
|
+
if (branchPipeCode === null) {
|
|
300
|
+
ctx.diagnostics.push({
|
|
301
|
+
severity: "warning",
|
|
302
|
+
code: "invalid-pipe-entry",
|
|
303
|
+
message: `pipe "${code}": PipeBatch without branch_pipe_code`,
|
|
304
|
+
path: `pipe.${code}.branch_pipe_code`
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
308
|
+
type,
|
|
309
|
+
pipe_category: "PipeController",
|
|
310
|
+
branch_pipe_code: branchPipeCode != null ? branchPipeCode : "",
|
|
311
|
+
batch_params: {
|
|
312
|
+
input_list_stuff_name: (_e = strOrNull(raw.input_list_name)) != null ? _e : "",
|
|
313
|
+
input_item_stuff_name: (_f = strOrNull(raw.input_item_name)) != null ? _f : ""
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
case "PipeLLM": {
|
|
318
|
+
const systemPrompt = strOrNull(raw.system_prompt);
|
|
319
|
+
const prompt = strOrNull(raw.prompt);
|
|
320
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
321
|
+
type,
|
|
322
|
+
pipe_category: "PipeOperator",
|
|
323
|
+
llm_prompt_spec: {
|
|
324
|
+
templating_style: null,
|
|
325
|
+
system_prompt_blueprint: systemPrompt === null ? null : makeTemplate(systemPrompt, "llm_prompt"),
|
|
326
|
+
prompt_blueprint: prompt === null ? null : makeTemplate(prompt, "llm_prompt"),
|
|
327
|
+
user_image_references: null,
|
|
328
|
+
user_document_references: null,
|
|
329
|
+
system_image_references: null,
|
|
330
|
+
system_document_references: null
|
|
331
|
+
},
|
|
332
|
+
llm_choices: {
|
|
333
|
+
for_text: modelToString(raw.model),
|
|
334
|
+
for_object: modelToString(raw.model_to_structure)
|
|
335
|
+
},
|
|
336
|
+
structuring_method: strOrNull(raw.structuring_method),
|
|
337
|
+
output_multiplicity: null
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
case "PipeStructure": {
|
|
341
|
+
const inputNames = Object.keys(base.inputs);
|
|
342
|
+
const llmChoice = isPlainObject(raw.model) ? raw.model : strOrNull(raw.model);
|
|
343
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
344
|
+
type,
|
|
345
|
+
pipe_category: "PipeOperator",
|
|
346
|
+
llm_choice: llmChoice,
|
|
347
|
+
text_input_name: (_g = inputNames[0]) != null ? _g : "text",
|
|
348
|
+
output_multiplicity: null
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
case "PipeExtract": {
|
|
352
|
+
const isImageLike = (spec) => spec.concept.domain_code === NATIVE_DOMAIN && spec.concept.code === "Image" || spec.concept.refines === `${NATIVE_DOMAIN}.Image`;
|
|
353
|
+
const inputEntries = Object.entries(base.inputs);
|
|
354
|
+
const imageInput = inputEntries.find(([, spec]) => isImageLike(spec));
|
|
355
|
+
const documentInput = imageInput === void 0 ? inputEntries[0] : void 0;
|
|
356
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
357
|
+
type,
|
|
358
|
+
pipe_category: "PipeOperator",
|
|
359
|
+
extract_choice: modelToString(raw.model),
|
|
360
|
+
should_caption_images: raw.page_image_captions === true,
|
|
361
|
+
max_page_images: intOrNull(raw.max_page_images),
|
|
362
|
+
should_include_page_views: raw.page_views === true,
|
|
363
|
+
page_views_dpi: intOrNull(raw.page_views_dpi),
|
|
364
|
+
render_js: boolOrNull(raw.render_js),
|
|
365
|
+
include_raw_html: boolOrNull(raw.include_raw_html),
|
|
366
|
+
image_stuff_name: (_h = imageInput == null ? void 0 : imageInput[0]) != null ? _h : null,
|
|
367
|
+
document_stuff_name: (_i = documentInput == null ? void 0 : documentInput[0]) != null ? _i : null
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
case "PipeSearch":
|
|
371
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
372
|
+
type,
|
|
373
|
+
pipe_category: "PipeOperator",
|
|
374
|
+
search_choice: modelToString(raw.model),
|
|
375
|
+
prompt_blueprint: makeTemplate((_j = strOrNull(raw.prompt)) != null ? _j : "", "basic"),
|
|
376
|
+
include_images_override: boolOrNull(raw.include_images),
|
|
377
|
+
max_results_override: intOrNull(raw.max_results),
|
|
378
|
+
from_date: strOrNull(raw.from_date),
|
|
379
|
+
to_date: strOrNull(raw.to_date),
|
|
380
|
+
include_domains: stringArrayOrNull(raw.include_domains),
|
|
381
|
+
exclude_domains: stringArrayOrNull(raw.exclude_domains),
|
|
382
|
+
is_structured_output: false
|
|
383
|
+
});
|
|
384
|
+
case "PipeImgGen": {
|
|
385
|
+
const prompt = strOrNull(raw.prompt);
|
|
386
|
+
const negativePrompt = strOrNull(raw.negative_prompt);
|
|
387
|
+
const seed = (_k = intOrNull(raw.seed)) != null ? _k : raw.seed === "auto" ? "auto" : null;
|
|
388
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
389
|
+
type,
|
|
390
|
+
pipe_category: "PipeOperator",
|
|
391
|
+
img_gen_prompt_blueprint: {
|
|
392
|
+
prompt_blueprint: prompt === null ? null : makeTemplate(prompt, "img_gen_prompt"),
|
|
393
|
+
negative_prompt_blueprint: negativePrompt === null ? null : makeTemplate(negativePrompt, "img_gen_prompt"),
|
|
394
|
+
image_references: null
|
|
395
|
+
},
|
|
396
|
+
img_gen_choice: modelToString(raw.model),
|
|
397
|
+
aspect_ratio: strOrNull(raw.aspect_ratio),
|
|
398
|
+
is_raw: boolOrNull(raw.is_raw),
|
|
399
|
+
seed,
|
|
400
|
+
background: strOrNull(raw.background),
|
|
401
|
+
output_format: strOrNull(raw.output_format),
|
|
402
|
+
output_multiplicity: typeof base.output.multiplicity === "number" ? base.output.multiplicity : 1
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
case "PipeCompose": {
|
|
406
|
+
const rawTemplate = raw.template;
|
|
407
|
+
let template = null;
|
|
408
|
+
let templatingStyle = null;
|
|
409
|
+
let category = "basic";
|
|
410
|
+
let extraContext = null;
|
|
411
|
+
if (typeof rawTemplate === "string") {
|
|
412
|
+
template = rawTemplate;
|
|
413
|
+
} else if (isPlainObject(rawTemplate)) {
|
|
414
|
+
template = strOrNull(rawTemplate.template);
|
|
415
|
+
templatingStyle = strOrNull(rawTemplate.templating_style);
|
|
416
|
+
category = (_l = strOrNull(rawTemplate.category)) != null ? _l : category;
|
|
417
|
+
extraContext = isPlainObject(rawTemplate.extra_context) ? rawTemplate.extra_context : null;
|
|
418
|
+
}
|
|
419
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
420
|
+
type,
|
|
421
|
+
pipe_category: "PipeOperator",
|
|
422
|
+
template,
|
|
423
|
+
templating_style: templatingStyle,
|
|
424
|
+
category,
|
|
425
|
+
extra_context: extraContext,
|
|
426
|
+
construct_blueprint: normalizeConstruct(raw.construct)
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
case "PipeFunc":
|
|
430
|
+
return __spreadProps(__spreadValues({}, base), { type, pipe_category: "PipeOperator" });
|
|
431
|
+
case "PipeSignature": {
|
|
432
|
+
const signatureFor = strOrNull(raw.signature_for);
|
|
433
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
434
|
+
type,
|
|
435
|
+
pipe_category: null,
|
|
436
|
+
signature_for: signatureFor !== null && KNOWN_PIPE_TYPES.has(signatureFor) ? signatureFor : null
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
default: {
|
|
440
|
+
const _exhaustive = type;
|
|
441
|
+
return _exhaustive;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// src/static-graph/parseMthdsBundle.ts
|
|
447
|
+
var FIELD_TYPE_TO_JSON = {
|
|
448
|
+
text: { type: "string" },
|
|
449
|
+
integer: { type: "integer" },
|
|
450
|
+
number: { type: "number" },
|
|
451
|
+
boolean: { type: "boolean" },
|
|
452
|
+
date: { type: "string", format: "date-time" },
|
|
453
|
+
list: { type: "array" },
|
|
454
|
+
dict: { type: "object" },
|
|
455
|
+
concept: { type: "object" }
|
|
456
|
+
};
|
|
457
|
+
function fieldSchema(spec) {
|
|
458
|
+
var _a, _b, _c;
|
|
459
|
+
const typeName = (_a = strOrNull(spec.type)) != null ? _a : "text";
|
|
460
|
+
const schema = __spreadValues({}, (_b = FIELD_TYPE_TO_JSON[typeName]) != null ? _b : { type: "string" });
|
|
461
|
+
const description = strOrNull(spec.description);
|
|
462
|
+
if (description !== null) schema.description = description;
|
|
463
|
+
if (typeName === "list") {
|
|
464
|
+
const itemType = strOrNull(spec.item_type);
|
|
465
|
+
schema.items = itemType !== null ? __spreadValues({}, (_c = FIELD_TYPE_TO_JSON[itemType]) != null ? _c : {}) : {};
|
|
466
|
+
}
|
|
467
|
+
if (Array.isArray(spec.choices)) {
|
|
468
|
+
schema.enum = spec.choices.filter((choice) => typeof choice === "string");
|
|
469
|
+
}
|
|
470
|
+
if (spec.default_value !== void 0 && spec.default_value !== null) {
|
|
471
|
+
schema.default = spec.default_value;
|
|
472
|
+
}
|
|
473
|
+
return schema;
|
|
474
|
+
}
|
|
475
|
+
function deriveJsonSchema(structure, title, description) {
|
|
476
|
+
if (!isPlainObject(structure)) return void 0;
|
|
477
|
+
const properties = {};
|
|
478
|
+
const required = [];
|
|
479
|
+
for (const [name, spec] of Object.entries(structure)) {
|
|
480
|
+
if (typeof spec === "string") {
|
|
481
|
+
properties[name] = { type: "string", description: spec };
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
if (!isPlainObject(spec)) continue;
|
|
485
|
+
properties[name] = fieldSchema(spec);
|
|
486
|
+
if (spec.required === true) required.push(name);
|
|
487
|
+
}
|
|
488
|
+
return __spreadValues({
|
|
489
|
+
title,
|
|
490
|
+
type: "object",
|
|
491
|
+
description,
|
|
492
|
+
properties
|
|
493
|
+
}, required.length > 0 ? { required } : {});
|
|
494
|
+
}
|
|
495
|
+
function qualifyRefines(raw, domain, declaredCodes) {
|
|
496
|
+
const parts = parseConceptRef(raw);
|
|
497
|
+
if (parts === null) return null;
|
|
498
|
+
if (parts.domain !== null) return `${parts.domain}.${parts.code}`;
|
|
499
|
+
if (!declaredCodes.has(parts.code) && NATIVE_CONCEPT_CODES.has(parts.code)) {
|
|
500
|
+
return `${NATIVE_DOMAIN}.${parts.code}`;
|
|
501
|
+
}
|
|
502
|
+
return `${domain}.${parts.code}`;
|
|
503
|
+
}
|
|
504
|
+
function parseConcepts(raw, domain, diagnostics) {
|
|
505
|
+
var _a, _b;
|
|
506
|
+
const concepts = {};
|
|
507
|
+
if (raw === void 0) return concepts;
|
|
508
|
+
if (!isPlainObject(raw)) {
|
|
509
|
+
diagnostics.push({
|
|
510
|
+
severity: "warning",
|
|
511
|
+
code: "invalid-bundle-shape",
|
|
512
|
+
message: "concept section is not a table \u2014 ignored",
|
|
513
|
+
path: "concept"
|
|
514
|
+
});
|
|
515
|
+
return concepts;
|
|
516
|
+
}
|
|
517
|
+
const declaredCodes = new Set(Object.keys(raw));
|
|
518
|
+
for (const [code, entry] of Object.entries(raw)) {
|
|
519
|
+
if (typeof entry === "string") {
|
|
520
|
+
concepts[code] = {
|
|
521
|
+
code,
|
|
522
|
+
domain_code: domain,
|
|
523
|
+
description: entry,
|
|
524
|
+
structure_class_name: qualifiedStructureClassName(domain, code),
|
|
525
|
+
refines: null
|
|
526
|
+
};
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
if (!isPlainObject(entry)) {
|
|
530
|
+
diagnostics.push({
|
|
531
|
+
severity: "warning",
|
|
532
|
+
code: "invalid-concept-entry",
|
|
533
|
+
message: `concept "${code}" is neither a table nor a description string \u2014 skipped`,
|
|
534
|
+
path: `concept.${code}`
|
|
535
|
+
});
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
const description = (_a = strOrNull(entry.description)) != null ? _a : "";
|
|
539
|
+
const structureClassName = (_b = strOrNull(entry.structure)) != null ? _b : qualifiedStructureClassName(domain, code);
|
|
540
|
+
concepts[code] = {
|
|
541
|
+
code,
|
|
542
|
+
domain_code: domain,
|
|
543
|
+
description,
|
|
544
|
+
structure_class_name: structureClassName,
|
|
545
|
+
refines: qualifyRefines(entry.refines, domain, declaredCodes),
|
|
546
|
+
json_schema: deriveJsonSchema(entry.structure, structureClassName, description)
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
return concepts;
|
|
550
|
+
}
|
|
551
|
+
function emptyBundle() {
|
|
552
|
+
return {
|
|
553
|
+
domain: null,
|
|
554
|
+
description: null,
|
|
555
|
+
main_pipe: null,
|
|
556
|
+
system_prompt: null,
|
|
557
|
+
concepts: {},
|
|
558
|
+
pipes: {}
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
function parseMthdsBundle(tomlText) {
|
|
562
|
+
var _a;
|
|
563
|
+
const diagnostics = [];
|
|
564
|
+
let root;
|
|
565
|
+
try {
|
|
566
|
+
root = parseToml(tomlText);
|
|
567
|
+
} catch (error) {
|
|
568
|
+
diagnostics.push({
|
|
569
|
+
severity: "error",
|
|
570
|
+
code: "toml-parse-error",
|
|
571
|
+
message: error instanceof Error ? error.message : String(error)
|
|
572
|
+
});
|
|
573
|
+
return { bundle: emptyBundle(), diagnostics };
|
|
574
|
+
}
|
|
575
|
+
const bundle = emptyBundle();
|
|
576
|
+
bundle.domain = strOrNull(root.domain);
|
|
577
|
+
bundle.description = strOrNull(root.description);
|
|
578
|
+
bundle.main_pipe = strOrNull(root.main_pipe);
|
|
579
|
+
bundle.system_prompt = strOrNull(root.system_prompt);
|
|
580
|
+
if (bundle.domain === null) {
|
|
581
|
+
diagnostics.push({
|
|
582
|
+
severity: "warning",
|
|
583
|
+
code: "missing-domain",
|
|
584
|
+
message: `bundle declares no domain \u2014 using "${UNKNOWN_DOMAIN}"`,
|
|
585
|
+
path: "domain"
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
const domain = (_a = bundle.domain) != null ? _a : UNKNOWN_DOMAIN;
|
|
589
|
+
bundle.concepts = parseConcepts(root.concept, domain, diagnostics);
|
|
590
|
+
const pipeTable = root.pipe;
|
|
591
|
+
if (pipeTable !== void 0) {
|
|
592
|
+
if (!isPlainObject(pipeTable)) {
|
|
593
|
+
diagnostics.push({
|
|
594
|
+
severity: "warning",
|
|
595
|
+
code: "invalid-bundle-shape",
|
|
596
|
+
message: "pipe section is not a table \u2014 ignored",
|
|
597
|
+
path: "pipe"
|
|
598
|
+
});
|
|
599
|
+
} else {
|
|
600
|
+
const ctx = { domain, concepts: bundle.concepts, diagnostics };
|
|
601
|
+
for (const [code, entry] of Object.entries(pipeTable)) {
|
|
602
|
+
if (!isPlainObject(entry)) {
|
|
603
|
+
diagnostics.push({
|
|
604
|
+
severity: "error",
|
|
605
|
+
code: "invalid-pipe-entry",
|
|
606
|
+
message: `pipe "${code}" is not a table \u2014 skipped`,
|
|
607
|
+
path: `pipe.${code}`
|
|
608
|
+
});
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
const pipe = normalizePipe(code, entry, ctx);
|
|
612
|
+
if (pipe !== null) bundle.pipes[code] = pipe;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return { bundle, diagnostics };
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/static-graph/mergeBundles.ts
|
|
620
|
+
function enrichPipeConcepts(pipe, domains) {
|
|
621
|
+
const enrichSpec = (spec) => {
|
|
622
|
+
var _a;
|
|
623
|
+
const declared = (_a = domains[spec.concept.domain_code]) == null ? void 0 : _a.concepts[spec.concept.code];
|
|
624
|
+
return declared !== void 0 && declared !== spec.concept ? __spreadProps(__spreadValues({}, spec), { concept: declared }) : spec;
|
|
625
|
+
};
|
|
626
|
+
const inputs = {};
|
|
627
|
+
for (const [name, spec] of Object.entries(pipe.inputs)) {
|
|
628
|
+
inputs[name] = enrichSpec(spec);
|
|
629
|
+
}
|
|
630
|
+
return __spreadProps(__spreadValues({}, pipe), { inputs, output: enrichSpec(pipe.output) });
|
|
631
|
+
}
|
|
632
|
+
function mergeBundles(bundles) {
|
|
633
|
+
var _a, _b;
|
|
634
|
+
const diagnostics = [];
|
|
635
|
+
const domains = {};
|
|
636
|
+
let mainDomain = null;
|
|
637
|
+
let mainPipe = null;
|
|
638
|
+
let description = null;
|
|
639
|
+
for (const bundle of bundles) {
|
|
640
|
+
const domain = (_a = bundle.domain) != null ? _a : UNKNOWN_DOMAIN;
|
|
641
|
+
const namespace = (_b = domains[domain]) != null ? _b : domains[domain] = { domain, concepts: {}, pipes: {} };
|
|
642
|
+
if (mainDomain === null && bundle.domain !== null) mainDomain = bundle.domain;
|
|
643
|
+
if (mainPipe === null && bundle.main_pipe !== null) {
|
|
644
|
+
mainPipe = bundle.main_pipe;
|
|
645
|
+
mainDomain = domain;
|
|
646
|
+
}
|
|
647
|
+
if (description === null && bundle.description !== null) description = bundle.description;
|
|
648
|
+
for (const [code, concept] of Object.entries(bundle.concepts)) {
|
|
649
|
+
if (code in namespace.concepts) {
|
|
650
|
+
diagnostics.push({
|
|
651
|
+
severity: "warning",
|
|
652
|
+
code: "duplicate-concept",
|
|
653
|
+
message: `concept "${domain}.${code}" declared more than once \u2014 keeping the first declaration`,
|
|
654
|
+
path: `concept.${code}`
|
|
655
|
+
});
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
namespace.concepts[code] = concept;
|
|
659
|
+
}
|
|
660
|
+
for (const [code, pipe] of Object.entries(bundle.pipes)) {
|
|
661
|
+
if (code in namespace.pipes) {
|
|
662
|
+
diagnostics.push({
|
|
663
|
+
severity: "warning",
|
|
664
|
+
code: "duplicate-pipe",
|
|
665
|
+
message: `pipe "${domain}.${code}" declared more than once \u2014 keeping the first declaration`,
|
|
666
|
+
path: `pipe.${code}`
|
|
667
|
+
});
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
namespace.pipes[code] = pipe;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
for (const namespace of Object.values(domains)) {
|
|
674
|
+
for (const [code, pipe] of Object.entries(namespace.pipes)) {
|
|
675
|
+
namespace.pipes[code] = enrichPipeConcepts(pipe, domains);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return { domains, mainDomain, mainPipe, description, diagnostics };
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// src/static-graph/buildStaticGraphSpec.ts
|
|
682
|
+
function buildStaticGraphSpec(set, options = {}) {
|
|
683
|
+
var _a;
|
|
684
|
+
const diagnostics = [];
|
|
685
|
+
const ctx = {
|
|
686
|
+
set,
|
|
687
|
+
nodes: [],
|
|
688
|
+
edges: [],
|
|
689
|
+
pipeRegistry: {},
|
|
690
|
+
conceptRegistry: {},
|
|
691
|
+
stuffByDigest: /* @__PURE__ */ new Map(),
|
|
692
|
+
diagnostics,
|
|
693
|
+
stack: [],
|
|
694
|
+
edgeSeq: 0
|
|
695
|
+
};
|
|
696
|
+
for (const namespace of Object.values(set.domains)) {
|
|
697
|
+
for (const concept of Object.values(namespace.concepts)) registerConcept(ctx, concept);
|
|
698
|
+
for (const pipe of Object.values(namespace.pipes)) {
|
|
699
|
+
ctx.pipeRegistry[`${pipe.domain_code}.${pipe.code}`] = pipe;
|
|
700
|
+
for (const spec2 of Object.values(pipe.inputs)) registerConcept(ctx, spec2.concept);
|
|
701
|
+
registerConcept(ctx, pipe.output.concept);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const entry = pickEntryPipe(set, (_a = options.entryPipe) != null ? _a : null, diagnostics);
|
|
705
|
+
if (entry !== null) {
|
|
706
|
+
walkPipe(ctx, entry.code, entry.domain, `${entry.domain}.${entry.code}`, null, /* @__PURE__ */ new Map(), {
|
|
707
|
+
resultName: null,
|
|
708
|
+
outputMultiplicity: null
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
const spec = {
|
|
712
|
+
nodes: ctx.nodes,
|
|
713
|
+
edges: ctx.edges,
|
|
714
|
+
meta: { format: "mthds", mode: "static" },
|
|
715
|
+
pipe_registry: ctx.pipeRegistry,
|
|
716
|
+
concept_registry: ctx.conceptRegistry
|
|
717
|
+
};
|
|
718
|
+
if (entry !== null) {
|
|
719
|
+
spec.pipeline_ref = { domain: entry.domain, main_pipe: entry.code };
|
|
720
|
+
}
|
|
721
|
+
return { spec, diagnostics };
|
|
722
|
+
}
|
|
723
|
+
function buildStaticGraphSpecFromToml(tomlTexts, options = {}) {
|
|
724
|
+
const texts = Array.isArray(tomlTexts) ? tomlTexts : [tomlTexts];
|
|
725
|
+
const parsed = texts.map((text) => parseMthdsBundle(text));
|
|
726
|
+
const merged = mergeBundles(parsed.map((result) => result.bundle));
|
|
727
|
+
const built = buildStaticGraphSpec(merged, options);
|
|
728
|
+
return {
|
|
729
|
+
spec: built.spec,
|
|
730
|
+
diagnostics: [
|
|
731
|
+
...parsed.flatMap((result) => result.diagnostics),
|
|
732
|
+
...merged.diagnostics,
|
|
733
|
+
...built.diagnostics
|
|
734
|
+
]
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function resolvePipeRef(set, ref, currentDomain) {
|
|
738
|
+
var _a;
|
|
739
|
+
if (ref.includes("->")) return { kind: "opaque" };
|
|
740
|
+
const dot = ref.lastIndexOf(".");
|
|
741
|
+
const domain = dot === -1 ? currentDomain : ref.slice(0, dot);
|
|
742
|
+
const code = dot === -1 ? ref : ref.slice(dot + 1);
|
|
743
|
+
const blueprint = (_a = set.domains[domain]) == null ? void 0 : _a.pipes[code];
|
|
744
|
+
if (blueprint === void 0) return { kind: "unresolved" };
|
|
745
|
+
return { kind: "resolved", blueprint, domain, code };
|
|
746
|
+
}
|
|
747
|
+
function referencedPipeCodes(namespace) {
|
|
748
|
+
const refs = /* @__PURE__ */ new Set();
|
|
749
|
+
const add = (ref) => {
|
|
750
|
+
if (ref === "" || ref.includes("->")) return;
|
|
751
|
+
const dot = ref.lastIndexOf(".");
|
|
752
|
+
if (dot === -1) refs.add(ref);
|
|
753
|
+
else if (ref.slice(0, dot) === namespace.domain) refs.add(ref.slice(dot + 1));
|
|
754
|
+
};
|
|
755
|
+
for (const pipe of Object.values(namespace.pipes)) {
|
|
756
|
+
switch (pipe.type) {
|
|
757
|
+
case "PipeSequence":
|
|
758
|
+
for (const sub of pipe.sequential_sub_pipes) add(sub.pipe_code);
|
|
759
|
+
break;
|
|
760
|
+
case "PipeParallel":
|
|
761
|
+
for (const sub of pipe.parallel_sub_pipes) add(sub.pipe_code);
|
|
762
|
+
break;
|
|
763
|
+
case "PipeCondition":
|
|
764
|
+
for (const target of Object.values(pipe.outcome_map)) add(target);
|
|
765
|
+
add(pipe.default_outcome);
|
|
766
|
+
break;
|
|
767
|
+
case "PipeBatch":
|
|
768
|
+
add(pipe.branch_pipe_code);
|
|
769
|
+
break;
|
|
770
|
+
default:
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return refs;
|
|
775
|
+
}
|
|
776
|
+
function pickEntryPipe(set, explicitRef, diagnostics) {
|
|
777
|
+
var _a, _b;
|
|
778
|
+
const domainsInOrder = Object.keys(set.domains);
|
|
779
|
+
const fallbackDomain = (_a = set.mainDomain) != null ? _a : domainsInOrder[0];
|
|
780
|
+
if (fallbackDomain === void 0) {
|
|
781
|
+
diagnostics.push({
|
|
782
|
+
severity: "error",
|
|
783
|
+
code: "no-entry-pipe",
|
|
784
|
+
message: "no bundles to build a graph from"
|
|
785
|
+
});
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
const resolveEntry = (ref) => {
|
|
789
|
+
const resolution = resolvePipeRef(set, ref, fallbackDomain);
|
|
790
|
+
return resolution.kind === "resolved" ? { domain: resolution.domain, code: resolution.code } : null;
|
|
791
|
+
};
|
|
792
|
+
if (explicitRef !== null) {
|
|
793
|
+
const entry = resolveEntry(explicitRef);
|
|
794
|
+
if (entry === null) {
|
|
795
|
+
diagnostics.push({
|
|
796
|
+
severity: "error",
|
|
797
|
+
code: "unresolved-pipe-ref",
|
|
798
|
+
message: `entry pipe "${explicitRef}" not found in the method set`
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
return entry;
|
|
802
|
+
}
|
|
803
|
+
if (set.mainPipe !== null) {
|
|
804
|
+
const entry = resolveEntry(set.mainPipe);
|
|
805
|
+
if (entry !== null) return entry;
|
|
806
|
+
diagnostics.push({
|
|
807
|
+
severity: "warning",
|
|
808
|
+
code: "unresolved-pipe-ref",
|
|
809
|
+
message: `main_pipe "${set.mainPipe}" not found \u2014 falling back to a root heuristic`
|
|
810
|
+
});
|
|
811
|
+
} else {
|
|
812
|
+
diagnostics.push({
|
|
813
|
+
severity: "warning",
|
|
814
|
+
code: "missing-main-pipe",
|
|
815
|
+
message: "no main_pipe declared \u2014 falling back to a root heuristic"
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
const domainWithPipes = [fallbackDomain, ...domainsInOrder].find(
|
|
819
|
+
(domain) => {
|
|
820
|
+
var _a2, _b2;
|
|
821
|
+
return Object.keys((_b2 = (_a2 = set.domains[domain]) == null ? void 0 : _a2.pipes) != null ? _b2 : {}).length > 0;
|
|
822
|
+
}
|
|
823
|
+
);
|
|
824
|
+
if (domainWithPipes === void 0) {
|
|
825
|
+
diagnostics.push({
|
|
826
|
+
severity: "error",
|
|
827
|
+
code: "no-entry-pipe",
|
|
828
|
+
message: "no pipes found in any bundle"
|
|
829
|
+
});
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
const namespace = set.domains[domainWithPipes];
|
|
833
|
+
const referenced = referencedPipeCodes(namespace);
|
|
834
|
+
const codes = Object.keys(namespace.pipes);
|
|
835
|
+
const root = (_b = codes.find((code) => !referenced.has(code))) != null ? _b : codes[0];
|
|
836
|
+
return { domain: domainWithPipes, code: root };
|
|
837
|
+
}
|
|
838
|
+
function snakeCase(code) {
|
|
839
|
+
return code.replace(/([A-Z]+)([A-Z][a-z0-9])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
840
|
+
}
|
|
841
|
+
function registerConcept(ctx, concept) {
|
|
842
|
+
var _a, _b, _c;
|
|
843
|
+
(_c = (_a = ctx.conceptRegistry)[_b = `${concept.domain_code}.${concept.code}`]) != null ? _c : _a[_b] = concept;
|
|
844
|
+
}
|
|
845
|
+
function mintStuff(ctx, digest, name, concept, multiplicity) {
|
|
846
|
+
const existing = ctx.stuffByDigest.get(digest);
|
|
847
|
+
if (existing !== void 0) return existing;
|
|
848
|
+
const record = { digest, name, concept, multiplicity };
|
|
849
|
+
ctx.stuffByDigest.set(digest, record);
|
|
850
|
+
registerConcept(ctx, concept);
|
|
851
|
+
return record;
|
|
852
|
+
}
|
|
853
|
+
function ioItem(stuff, slotName) {
|
|
854
|
+
return { name: slotName != null ? slotName : stuff.name, digest: stuff.digest, concept: stuff.concept.code };
|
|
855
|
+
}
|
|
856
|
+
function addEdge(ctx, kind, source, target, extras) {
|
|
857
|
+
const edge = { id: `static:edge_${ctx.edgeSeq++}`, source, target, kind };
|
|
858
|
+
if ((extras == null ? void 0 : extras.label) !== void 0) edge.label = extras.label;
|
|
859
|
+
if ((extras == null ? void 0 : extras.sourceStuff) !== void 0) edge.source_stuff_digest = extras.sourceStuff;
|
|
860
|
+
if ((extras == null ? void 0 : extras.targetStuff) !== void 0) edge.target_stuff_digest = extras.targetStuff;
|
|
861
|
+
ctx.edges.push(edge);
|
|
862
|
+
}
|
|
863
|
+
function addNodeTag(node, key, value) {
|
|
864
|
+
var _a;
|
|
865
|
+
node.tags = __spreadProps(__spreadValues({}, (_a = node.tags) != null ? _a : {}), { [key]: value });
|
|
866
|
+
}
|
|
867
|
+
function formatBatchMultiplicity(multiplicity) {
|
|
868
|
+
if (typeof multiplicity === "number") return `x${multiplicity}`;
|
|
869
|
+
if (multiplicity === true) return "xmany";
|
|
870
|
+
return "x?";
|
|
871
|
+
}
|
|
872
|
+
function lookupScope(scope, name) {
|
|
873
|
+
let candidate = name;
|
|
874
|
+
for (; ; ) {
|
|
875
|
+
const found = scope.get(candidate);
|
|
876
|
+
if (found !== void 0) return found;
|
|
877
|
+
const dot = candidate.lastIndexOf(".");
|
|
878
|
+
if (dot <= 0) return void 0;
|
|
879
|
+
candidate = candidate.slice(0, dot);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function conceptKey(concept) {
|
|
883
|
+
return `${concept.domain_code}.${concept.code}`;
|
|
884
|
+
}
|
|
885
|
+
function bindInputs(ctx, blueprint, scope) {
|
|
886
|
+
const ioInputs = [];
|
|
887
|
+
for (const [name, spec] of Object.entries(blueprint.inputs)) {
|
|
888
|
+
let bound = lookupScope(scope, name);
|
|
889
|
+
if (bound === void 0) {
|
|
890
|
+
bound = mintStuff(ctx, `input:${name}`, name, spec.concept, spec.multiplicity);
|
|
891
|
+
scope.set(name, bound);
|
|
892
|
+
if (conceptKey(bound.concept) !== conceptKey(spec.concept)) {
|
|
893
|
+
ctx.diagnostics.push({
|
|
894
|
+
severity: "warning",
|
|
895
|
+
code: "conflicting-input-concept",
|
|
896
|
+
message: `pipe "${blueprint.code}": dangling input "${name}" is declared as ${conceptKey(spec.concept)} here but was first seen as ${conceptKey(bound.concept)} \u2014 keeping the first`,
|
|
897
|
+
path: `pipe.${blueprint.code}.inputs.${name}`
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
ioInputs.push(ioItem(bound));
|
|
902
|
+
}
|
|
903
|
+
return ioInputs;
|
|
904
|
+
}
|
|
905
|
+
function emitNode(ctx, args) {
|
|
906
|
+
const node = {
|
|
907
|
+
id: args.id,
|
|
908
|
+
kind: args.kind,
|
|
909
|
+
pipe_code: args.pipeCode,
|
|
910
|
+
pipe_type: args.pipeType,
|
|
911
|
+
// validateGraphSpec requires a non-empty description; WIP pipes may lack one.
|
|
912
|
+
description: args.description.length > 0 ? args.description : args.pipeCode,
|
|
913
|
+
domain_code: args.domainCode,
|
|
914
|
+
status: "scheduled",
|
|
915
|
+
io: { inputs: args.ioInputs, outputs: [] }
|
|
916
|
+
};
|
|
917
|
+
if (args.inv.outcomeValue !== void 0) node.tags = { outcome: args.inv.outcomeValue };
|
|
918
|
+
ctx.nodes.push(node);
|
|
919
|
+
if (args.parentId !== null) {
|
|
920
|
+
addEdge(
|
|
921
|
+
ctx,
|
|
922
|
+
"contains",
|
|
923
|
+
args.parentId,
|
|
924
|
+
args.id,
|
|
925
|
+
args.inv.outcomeValue !== void 0 ? { label: args.inv.outcomeValue } : void 0
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
return node;
|
|
929
|
+
}
|
|
930
|
+
function walkPipe(ctx, ref, currentDomain, nodeId, parentId, scope, inv) {
|
|
931
|
+
const resolution = resolvePipeRef(ctx.set, ref, currentDomain);
|
|
932
|
+
if (resolution.kind === "unresolved") {
|
|
933
|
+
ctx.diagnostics.push({
|
|
934
|
+
severity: "warning",
|
|
935
|
+
code: "unresolved-pipe-ref",
|
|
936
|
+
message: `pipe ref "${ref}" cannot be resolved \u2014 node skipped`,
|
|
937
|
+
path: nodeId
|
|
938
|
+
});
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
if (resolution.kind === "opaque") {
|
|
942
|
+
return emitOpaqueLeaf(ctx, ref, currentDomain, nodeId, parentId, inv);
|
|
943
|
+
}
|
|
944
|
+
const { blueprint, domain, code } = resolution;
|
|
945
|
+
const qualified = `${domain}.${code}`;
|
|
946
|
+
const ioInputs = bindInputs(ctx, blueprint, scope);
|
|
947
|
+
const node = emitNode(ctx, {
|
|
948
|
+
id: nodeId,
|
|
949
|
+
kind: blueprint.pipe_category === "PipeController" ? "controller" : "operator",
|
|
950
|
+
pipeCode: code,
|
|
951
|
+
pipeType: blueprint.type,
|
|
952
|
+
description: blueprint.description,
|
|
953
|
+
domainCode: blueprint.domain_code,
|
|
954
|
+
ioInputs,
|
|
955
|
+
parentId,
|
|
956
|
+
inv
|
|
957
|
+
});
|
|
958
|
+
if (ctx.stack.includes(qualified)) {
|
|
959
|
+
ctx.diagnostics.push({
|
|
960
|
+
severity: "warning",
|
|
961
|
+
code: "cyclic-pipe-ref",
|
|
962
|
+
message: `pipe "${qualified}" is invoked recursively \u2014 rendered as a leaf`,
|
|
963
|
+
path: nodeId
|
|
964
|
+
});
|
|
965
|
+
return finishLeaf(ctx, node, blueprint, nodeId, inv);
|
|
966
|
+
}
|
|
967
|
+
ctx.stack.push(qualified);
|
|
968
|
+
try {
|
|
969
|
+
switch (blueprint.type) {
|
|
970
|
+
case "PipeSequence":
|
|
971
|
+
return finishSequence(ctx, node, blueprint, nodeId, scope, inv);
|
|
972
|
+
case "PipeParallel":
|
|
973
|
+
return finishParallel(ctx, node, blueprint, nodeId, scope, inv);
|
|
974
|
+
case "PipeCondition":
|
|
975
|
+
return finishCondition(ctx, node, blueprint, nodeId, scope, inv);
|
|
976
|
+
case "PipeBatch":
|
|
977
|
+
return finishBatch(ctx, node, blueprint, nodeId, scope, inv);
|
|
978
|
+
default:
|
|
979
|
+
return finishLeaf(ctx, node, blueprint, nodeId, inv);
|
|
980
|
+
}
|
|
981
|
+
} finally {
|
|
982
|
+
ctx.stack.pop();
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
function walkSubPipe(ctx, sub, domain, nodeId, parentId, scope) {
|
|
986
|
+
if (sub.batch_params !== null) {
|
|
987
|
+
return walkInlineBatch(ctx, sub, domain, nodeId, parentId, scope);
|
|
988
|
+
}
|
|
989
|
+
return walkPipe(ctx, sub.pipe_code, domain, nodeId, parentId, scope, {
|
|
990
|
+
resultName: sub.output_name,
|
|
991
|
+
outputMultiplicity: sub.output_multiplicity
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function finishLeaf(ctx, node, blueprint, nodeId, inv) {
|
|
995
|
+
var _a;
|
|
996
|
+
const name = (_a = inv.resultName) != null ? _a : snakeCase(blueprint.output.concept.code);
|
|
997
|
+
const multiplicity = typeof inv.outputMultiplicity === "number" || inv.outputMultiplicity === true ? inv.outputMultiplicity : blueprint.output.multiplicity;
|
|
998
|
+
const output = mintStuff(ctx, `${nodeId}:${name}`, name, blueprint.output.concept, multiplicity);
|
|
999
|
+
node.io.outputs = [ioItem(output)];
|
|
1000
|
+
return { nodeId, output, eachOutputs: [] };
|
|
1001
|
+
}
|
|
1002
|
+
function emitOpaqueLeaf(ctx, ref, currentDomain, nodeId, parentId, inv) {
|
|
1003
|
+
var _a;
|
|
1004
|
+
const alias = ref.slice(0, ref.indexOf("->"));
|
|
1005
|
+
const tail = ref.slice(ref.lastIndexOf("->") + 2);
|
|
1006
|
+
const codeTail = tail.slice(tail.lastIndexOf(".") + 1);
|
|
1007
|
+
const node = emitNode(ctx, {
|
|
1008
|
+
id: nodeId,
|
|
1009
|
+
kind: "operator",
|
|
1010
|
+
pipeCode: codeTail.length > 0 ? codeTail : ref,
|
|
1011
|
+
pipeType: "PipeSignature",
|
|
1012
|
+
description: `External pipe from dependency "${alias}"`,
|
|
1013
|
+
domainCode: alias.length > 0 ? alias : currentDomain,
|
|
1014
|
+
ioInputs: [],
|
|
1015
|
+
parentId,
|
|
1016
|
+
inv
|
|
1017
|
+
});
|
|
1018
|
+
const name = (_a = inv.resultName) != null ? _a : "output";
|
|
1019
|
+
const output = mintStuff(ctx, `${nodeId}:${name}`, name, nativeConceptInfo("Anything"), null);
|
|
1020
|
+
node.io.outputs = [ioItem(output)];
|
|
1021
|
+
return { nodeId, output, eachOutputs: [] };
|
|
1022
|
+
}
|
|
1023
|
+
function finishSequence(ctx, node, blueprint, nodeId, scope, inv) {
|
|
1024
|
+
let lastOutput = null;
|
|
1025
|
+
blueprint.sequential_sub_pipes.forEach((sub, index) => {
|
|
1026
|
+
const result = walkSubPipe(
|
|
1027
|
+
ctx,
|
|
1028
|
+
sub,
|
|
1029
|
+
blueprint.domain_code,
|
|
1030
|
+
`${nodeId}/step_${index + 1}`,
|
|
1031
|
+
nodeId,
|
|
1032
|
+
scope
|
|
1033
|
+
);
|
|
1034
|
+
if (result === null) return;
|
|
1035
|
+
if (result.output !== null) {
|
|
1036
|
+
if (sub.output_name !== null) scope.set(sub.output_name, result.output);
|
|
1037
|
+
lastOutput = result.output;
|
|
1038
|
+
}
|
|
1039
|
+
for (const [name, stuff] of result.eachOutputs) scope.set(name, stuff);
|
|
1040
|
+
});
|
|
1041
|
+
node.io.outputs = lastOutput === null ? [] : [ioItem(lastOutput, inv.resultName)];
|
|
1042
|
+
return { nodeId, output: lastOutput, eachOutputs: [] };
|
|
1043
|
+
}
|
|
1044
|
+
function finishParallel(ctx, node, blueprint, nodeId, scope, inv) {
|
|
1045
|
+
var _a, _b;
|
|
1046
|
+
const branchResults = [];
|
|
1047
|
+
blueprint.parallel_sub_pipes.forEach((sub, index) => {
|
|
1048
|
+
const result = walkSubPipe(
|
|
1049
|
+
ctx,
|
|
1050
|
+
sub,
|
|
1051
|
+
blueprint.domain_code,
|
|
1052
|
+
`${nodeId}/branch_${index + 1}`,
|
|
1053
|
+
nodeId,
|
|
1054
|
+
new Map(scope)
|
|
1055
|
+
);
|
|
1056
|
+
if (result !== null) branchResults.push({ sub, result });
|
|
1057
|
+
});
|
|
1058
|
+
const eachOutputs = [];
|
|
1059
|
+
if (blueprint.add_each_output) {
|
|
1060
|
+
for (const { sub, result } of branchResults) {
|
|
1061
|
+
if (sub.output_name !== null && result.output !== null) {
|
|
1062
|
+
eachOutputs.push([sub.output_name, result.output]);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
const combinedName = (_b = (_a = blueprint.combined_output) != null ? _a : inv.resultName) != null ? _b : snakeCase(blueprint.output.concept.code);
|
|
1067
|
+
const combined = mintStuff(
|
|
1068
|
+
ctx,
|
|
1069
|
+
`${nodeId}:${combinedName}`,
|
|
1070
|
+
combinedName,
|
|
1071
|
+
blueprint.output.concept,
|
|
1072
|
+
blueprint.output.multiplicity
|
|
1073
|
+
);
|
|
1074
|
+
for (const { result } of branchResults) {
|
|
1075
|
+
if (result.output !== null) {
|
|
1076
|
+
addEdge(ctx, "parallel_combine", result.nodeId, nodeId, {
|
|
1077
|
+
sourceStuff: result.output.digest,
|
|
1078
|
+
targetStuff: combined.digest
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
node.io.outputs = [ioItem(combined, inv.resultName)];
|
|
1083
|
+
return { nodeId, output: combined, eachOutputs };
|
|
1084
|
+
}
|
|
1085
|
+
function finishCondition(ctx, node, blueprint, nodeId, scope, inv) {
|
|
1086
|
+
var _a, _b, _c, _d;
|
|
1087
|
+
const conditionScope = new Map(scope);
|
|
1088
|
+
if (blueprint.add_alias_from_expression_to !== null) {
|
|
1089
|
+
const alias = blueprint.add_alias_from_expression_to;
|
|
1090
|
+
conditionScope.set(
|
|
1091
|
+
alias,
|
|
1092
|
+
mintStuff(ctx, `${nodeId}:${alias}`, alias, nativeConceptInfo("Dynamic"), null)
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
const targets = [];
|
|
1096
|
+
const byRef = /* @__PURE__ */ new Map();
|
|
1097
|
+
const addRoute = (value, ref, isDefault) => {
|
|
1098
|
+
if (ref === "" || ref === "fail" || ref === "continue") return;
|
|
1099
|
+
const existing = byRef.get(ref);
|
|
1100
|
+
if (existing !== void 0) {
|
|
1101
|
+
existing.values.push(value);
|
|
1102
|
+
existing.viaDefault || (existing.viaDefault = isDefault);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
const entry = { values: [value], ref, viaDefault: isDefault };
|
|
1106
|
+
byRef.set(ref, entry);
|
|
1107
|
+
targets.push(entry);
|
|
1108
|
+
};
|
|
1109
|
+
for (const [value, target] of Object.entries(blueprint.outcome_map)) {
|
|
1110
|
+
addRoute(value, target, false);
|
|
1111
|
+
}
|
|
1112
|
+
addRoute("default", blueprint.default_outcome, true);
|
|
1113
|
+
const results = [];
|
|
1114
|
+
for (const entry of targets) {
|
|
1115
|
+
const idSegment = entry.viaDefault && entry.values.length === 1 ? "default" : `outcome_${entry.values[0]}`;
|
|
1116
|
+
const result = walkPipe(
|
|
1117
|
+
ctx,
|
|
1118
|
+
entry.ref,
|
|
1119
|
+
blueprint.domain_code,
|
|
1120
|
+
`${nodeId}/${idSegment}`,
|
|
1121
|
+
nodeId,
|
|
1122
|
+
new Map(conditionScope),
|
|
1123
|
+
{
|
|
1124
|
+
// The runtime stores whichever branch runs under the condition's own
|
|
1125
|
+
// slot name, so every branch's output carries it (dry-run parity).
|
|
1126
|
+
resultName: inv.resultName,
|
|
1127
|
+
outputMultiplicity: null,
|
|
1128
|
+
outcomeValue: entry.values.join(" | ")
|
|
1129
|
+
}
|
|
1130
|
+
);
|
|
1131
|
+
if (result !== null) results.push({ entry, result });
|
|
1132
|
+
}
|
|
1133
|
+
const primary = (_d = (_c = (_a = results.find(({ entry, result }) => entry.viaDefault && result.output !== null)) == null ? void 0 : _a.result.output) != null ? _c : (_b = results.find(({ result }) => result.output !== null)) == null ? void 0 : _b.result.output) != null ? _d : null;
|
|
1134
|
+
node.io.outputs = primary === null ? [] : [ioItem(primary, inv.resultName)];
|
|
1135
|
+
return { nodeId, output: primary, eachOutputs: [] };
|
|
1136
|
+
}
|
|
1137
|
+
function finishBatch(ctx, node, blueprint, nodeId, scope, inv) {
|
|
1138
|
+
var _a, _b, _c;
|
|
1139
|
+
const params = blueprint.batch_params;
|
|
1140
|
+
let listStuff = null;
|
|
1141
|
+
if (params.input_list_stuff_name !== "") {
|
|
1142
|
+
const bound = lookupScope(scope, params.input_list_stuff_name);
|
|
1143
|
+
if (bound !== void 0) {
|
|
1144
|
+
listStuff = bound;
|
|
1145
|
+
} else {
|
|
1146
|
+
listStuff = mintStuff(
|
|
1147
|
+
ctx,
|
|
1148
|
+
`input:${params.input_list_stuff_name}`,
|
|
1149
|
+
params.input_list_stuff_name,
|
|
1150
|
+
nativeConceptInfo("Anything"),
|
|
1151
|
+
true
|
|
1152
|
+
);
|
|
1153
|
+
node.io.inputs.push(ioItem(listStuff));
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
let itemStuff = null;
|
|
1157
|
+
const branchScope = new Map(scope);
|
|
1158
|
+
if (params.input_item_stuff_name !== "" && listStuff !== null) {
|
|
1159
|
+
itemStuff = mintStuff(
|
|
1160
|
+
ctx,
|
|
1161
|
+
`${nodeId}:${params.input_item_stuff_name}`,
|
|
1162
|
+
params.input_item_stuff_name,
|
|
1163
|
+
listStuff.concept,
|
|
1164
|
+
null
|
|
1165
|
+
);
|
|
1166
|
+
branchScope.set(params.input_item_stuff_name, itemStuff);
|
|
1167
|
+
}
|
|
1168
|
+
const batchMultiplicity = formatBatchMultiplicity(listStuff == null ? void 0 : listStuff.multiplicity);
|
|
1169
|
+
addNodeTag(node, "batch_multiplicity", batchMultiplicity);
|
|
1170
|
+
let branchResult = null;
|
|
1171
|
+
if (blueprint.branch_pipe_code !== "") {
|
|
1172
|
+
branchResult = walkPipe(
|
|
1173
|
+
ctx,
|
|
1174
|
+
blueprint.branch_pipe_code,
|
|
1175
|
+
blueprint.domain_code,
|
|
1176
|
+
`${nodeId}/batch_branch`,
|
|
1177
|
+
nodeId,
|
|
1178
|
+
branchScope,
|
|
1179
|
+
{ resultName: null, outputMultiplicity: null }
|
|
1180
|
+
);
|
|
1181
|
+
const branchNode = ctx.nodes.find((candidate) => candidate.id === (branchResult == null ? void 0 : branchResult.nodeId));
|
|
1182
|
+
if (branchNode !== void 0) {
|
|
1183
|
+
addNodeTag(branchNode, "batch_multiplicity", batchMultiplicity);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
const aggConcept = (_b = (_a = branchResult == null ? void 0 : branchResult.output) == null ? void 0 : _a.concept) != null ? _b : blueprint.output.concept;
|
|
1187
|
+
const aggName = (_c = inv.resultName) != null ? _c : snakeCase(aggConcept.code);
|
|
1188
|
+
const aggregate = mintStuff(ctx, `${nodeId}:${aggName}`, aggName, aggConcept, true);
|
|
1189
|
+
if (branchResult !== null && listStuff !== null && itemStuff !== null) {
|
|
1190
|
+
addEdge(ctx, "batch_item", nodeId, branchResult.nodeId, {
|
|
1191
|
+
sourceStuff: listStuff.digest,
|
|
1192
|
+
targetStuff: itemStuff.digest
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
if ((branchResult == null ? void 0 : branchResult.output) != null) {
|
|
1196
|
+
addEdge(ctx, "batch_aggregate", branchResult.nodeId, nodeId, {
|
|
1197
|
+
sourceStuff: branchResult.output.digest,
|
|
1198
|
+
targetStuff: aggregate.digest
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
node.io.outputs = [ioItem(aggregate)];
|
|
1202
|
+
return { nodeId, output: aggregate, eachOutputs: [] };
|
|
1203
|
+
}
|
|
1204
|
+
function walkInlineBatch(ctx, sub, domain, nodeId, parentId, scope) {
|
|
1205
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1206
|
+
const params = sub.batch_params;
|
|
1207
|
+
const aliasIdx = sub.pipe_code.lastIndexOf("->");
|
|
1208
|
+
const refTail = aliasIdx === -1 ? sub.pipe_code : sub.pipe_code.slice(aliasIdx + 2);
|
|
1209
|
+
const branchTail = refTail.slice(refTail.lastIndexOf(".") + 1);
|
|
1210
|
+
const branchResolution = resolvePipeRef(ctx.set, sub.pipe_code, domain);
|
|
1211
|
+
const branchBlueprint = branchResolution.kind === "resolved" ? branchResolution.blueprint : null;
|
|
1212
|
+
const listBinding = lookupScope(scope, params.input_list_stuff_name);
|
|
1213
|
+
const listConcept = (_c = (_b = listBinding == null ? void 0 : listBinding.concept) != null ? _b : (_a = branchBlueprint == null ? void 0 : branchBlueprint.inputs[params.input_item_stuff_name]) == null ? void 0 : _a.concept) != null ? _c : nativeConceptInfo("Anything");
|
|
1214
|
+
const outputSpec = (_d = branchBlueprint == null ? void 0 : branchBlueprint.output) != null ? _d : {
|
|
1215
|
+
concept: nativeConceptInfo("Anything"),
|
|
1216
|
+
multiplicity: null
|
|
1217
|
+
};
|
|
1218
|
+
const baseCode = `${branchTail}_batch`;
|
|
1219
|
+
let code = baseCode;
|
|
1220
|
+
for (let suffix = 2; ; suffix++) {
|
|
1221
|
+
const existing = ctx.pipeRegistry[`${domain}.${code}`];
|
|
1222
|
+
if (existing === void 0 || existing.type === "PipeBatch" && existing.branch_pipe_code === sub.pipe_code && existing.batch_params.input_list_stuff_name === params.input_list_stuff_name && existing.batch_params.input_item_stuff_name === params.input_item_stuff_name) {
|
|
1223
|
+
break;
|
|
1224
|
+
}
|
|
1225
|
+
code = `${baseCode}_${suffix}`;
|
|
1226
|
+
}
|
|
1227
|
+
const blueprint = {
|
|
1228
|
+
type: "PipeBatch",
|
|
1229
|
+
pipe_category: "PipeController",
|
|
1230
|
+
code,
|
|
1231
|
+
domain_code: domain,
|
|
1232
|
+
description: `Batch processing for ${branchTail}`,
|
|
1233
|
+
inputs: { [params.input_list_stuff_name]: { concept: listConcept, multiplicity: null } },
|
|
1234
|
+
output: { concept: outputSpec.concept, multiplicity: null },
|
|
1235
|
+
branch_pipe_code: sub.pipe_code,
|
|
1236
|
+
batch_params: params
|
|
1237
|
+
};
|
|
1238
|
+
(_g = (_e = ctx.pipeRegistry)[_f = `${domain}.${code}`]) != null ? _g : _e[_f] = blueprint;
|
|
1239
|
+
const ioInputs = bindInputs(ctx, blueprint, scope);
|
|
1240
|
+
const inv = {
|
|
1241
|
+
resultName: sub.output_name,
|
|
1242
|
+
outputMultiplicity: sub.output_multiplicity
|
|
1243
|
+
};
|
|
1244
|
+
const node = emitNode(ctx, {
|
|
1245
|
+
id: nodeId,
|
|
1246
|
+
kind: "controller",
|
|
1247
|
+
pipeCode: code,
|
|
1248
|
+
pipeType: "PipeBatch",
|
|
1249
|
+
description: blueprint.description,
|
|
1250
|
+
domainCode: domain,
|
|
1251
|
+
ioInputs,
|
|
1252
|
+
parentId,
|
|
1253
|
+
inv
|
|
1254
|
+
});
|
|
1255
|
+
return finishBatch(ctx, node, blueprint, nodeId, scope, inv);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// src/static-graph/validationIssues.ts
|
|
1259
|
+
function staticDiagnosticsToValidationIssues(diagnostics) {
|
|
1260
|
+
return diagnostics.map((diagnostic) => ({
|
|
1261
|
+
severity: diagnostic.severity,
|
|
1262
|
+
message: diagnostic.message,
|
|
1263
|
+
context: diagnostic.path,
|
|
1264
|
+
origin: "static"
|
|
1265
|
+
}));
|
|
1266
|
+
}
|
|
1267
|
+
export {
|
|
1268
|
+
NATIVE_CONCEPT_CODES,
|
|
1269
|
+
NATIVE_DOMAIN,
|
|
1270
|
+
UNKNOWN_DOMAIN,
|
|
1271
|
+
buildStaticGraphSpec,
|
|
1272
|
+
buildStaticGraphSpecFromToml,
|
|
1273
|
+
mergeBundles,
|
|
1274
|
+
parseConceptRef,
|
|
1275
|
+
parseMthdsBundle,
|
|
1276
|
+
staticDiagnosticsToValidationIssues
|
|
1277
|
+
};
|
|
1278
|
+
//# sourceMappingURL=index.js.map
|