@melite/estate-queue 0.0.0-stage → 0.1.5-pre-alpha
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/LICENSE +557 -0
- package/README.md +54 -2
- package/lib/bakeParams.d.ts +17 -0
- package/lib/bakeParams.js +182 -0
- package/lib/bench.d.ts +32 -0
- package/lib/bench.js +111 -0
- package/lib/cardsArmError.d.ts +61 -0
- package/lib/cardsArmError.js +57 -0
- package/lib/cardsCompose.d.ts +53 -0
- package/lib/cardsCompose.js +295 -0
- package/lib/cardsDangling.d.ts +16 -0
- package/lib/cardsDangling.js +213 -0
- package/lib/cardsFacts.d.ts +87 -0
- package/lib/cardsFacts.js +78 -0
- package/lib/cardsLanes.d.ts +43 -0
- package/lib/cardsLanes.js +178 -0
- package/lib/cardsRegistry.d.ts +404 -0
- package/lib/cardsRegistry.js +1543 -0
- package/lib/cardsVariant.d.ts +37 -0
- package/lib/cardsVariant.js +243 -0
- package/lib/discloseRegistry.d.ts +95 -0
- package/lib/discloseRegistry.js +156 -0
- package/lib/filmLead.d.ts +4 -0
- package/lib/filmLead.js +17 -0
- package/lib/filmMemoryWarn.d.ts +27 -0
- package/lib/filmMemoryWarn.js +99 -0
- package/lib/flowsData.d.ts +234 -0
- package/lib/flowsData.js +673 -0
- package/lib/flowsFamilyCompose.d.ts +45 -0
- package/lib/flowsFamilyCompose.js +191 -0
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +12 -0
- package/lib/flowsRegistryRows.js +520 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +75 -0
- package/lib/ledgerTail.d.ts +20 -0
- package/lib/ledgerTail.js +123 -0
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +94 -0
- package/lib/loadPlane.js +570 -0
- package/lib/loadRegistry.d.ts +22 -0
- package/lib/loadRegistry.js +55 -0
- package/lib/manageOps.d.ts +27 -0
- package/lib/manageOps.js +162 -0
- package/lib/managePlane.d.ts +151 -0
- package/lib/managePlane.js +1790 -0
- package/lib/manageProbe.d.ts +48 -0
- package/lib/manageProbe.js +165 -0
- package/lib/manageRegistry.d.ts +66 -0
- package/lib/manageRegistry.js +113 -0
- package/lib/managerRail.d.ts +33 -0
- package/lib/managerRail.js +91 -0
- package/lib/mediaKinds.d.ts +3 -0
- package/lib/mediaKinds.js +2 -0
- package/lib/queue.d.ts +9 -0
- package/lib/queue.js +80 -0
- package/lib/queueCore.d.ts +72 -0
- package/lib/queueCore.js +128 -0
- package/lib/queueLifecycle.d.ts +2 -0
- package/lib/queueLifecycle.js +11 -0
- package/lib/queueLock.d.ts +60 -0
- package/lib/queueLock.js +198 -0
- package/lib/queueResurrect.d.ts +59 -0
- package/lib/queueResurrect.js +249 -0
- package/lib/queueRetry.d.ts +36 -0
- package/lib/queueRetry.js +24 -0
- package/lib/queueSidecar.d.ts +149 -0
- package/lib/queueSidecar.js +183 -0
- package/lib/queueSubmit.d.ts +82 -0
- package/lib/queueSubmit.js +191 -0
- package/lib/queueSweep.d.ts +30 -0
- package/lib/queueSweep.js +132 -0
- package/lib/resurrect.d.ts +6 -0
- package/lib/resurrect.js +18 -0
- package/lib/rootsManifest.d.ts +11 -0
- package/lib/rootsManifest.js +11 -0
- package/lib/runsChange.d.ts +61 -0
- package/lib/runsChange.js +79 -0
- package/lib/runsErrorCodes.d.ts +2 -0
- package/lib/runsErrorCodes.js +48 -0
- package/lib/runsExecute.d.ts +52 -0
- package/lib/runsExecute.js +494 -0
- package/lib/runsGates.d.ts +161 -0
- package/lib/runsGates.js +307 -0
- package/lib/runsList.d.ts +78 -0
- package/lib/runsList.js +574 -0
- package/lib/runsRefusalVoices.d.ts +9 -0
- package/lib/runsRefusalVoices.js +96 -0
- package/lib/runsRegistry.d.ts +351 -0
- package/lib/runsRegistry.js +2394 -0
- package/lib/runsSourceEcho.d.ts +81 -0
- package/lib/runsSourceEcho.js +341 -0
- package/lib/runsStart.d.ts +163 -0
- package/lib/runsStart.js +667 -0
- package/lib/runsTypes.d.ts +218 -0
- package/lib/runsTypes.js +289 -0
- package/lib/runsValidate.d.ts +5 -0
- package/lib/runsValidate.js +31 -0
- package/lib/runsValidateArms.d.ts +7 -0
- package/lib/runsValidateArms.js +339 -0
- package/lib/runsValidateInline.d.ts +6 -0
- package/lib/runsValidateInline.js +82 -0
- package/lib/runsValidateRefusals.d.ts +7 -0
- package/lib/runsValidateRefusals.js +18 -0
- package/lib/runsValidateServe.d.ts +15 -0
- package/lib/runsValidateServe.js +276 -0
- package/lib/runsValidateShared.d.ts +84 -0
- package/lib/runsValidateShared.js +88 -0
- package/lib/runsValidateStages.d.ts +32 -0
- package/lib/runsValidateStages.js +511 -0
- package/lib/runsValidateSweeps.d.ts +6 -0
- package/lib/runsValidateSweeps.js +143 -0
- package/lib/service.d.ts +63 -0
- package/lib/service.js +89 -0
- package/lib/skillFrontmatter.d.ts +11 -0
- package/lib/skillFrontmatter.js +46 -0
- package/lib/skillFs.d.ts +24 -0
- package/lib/skillFs.js +78 -0
- package/lib/skillPlane.d.ts +99 -0
- package/lib/skillPlane.js +269 -0
- package/lib/skillRegistry.d.ts +23 -0
- package/lib/skillRegistry.js +55 -0
- package/lib/skillRows.d.ts +127 -0
- package/lib/skillRows.js +468 -0
- package/lib/toolProjection.d.ts +30 -0
- package/lib/toolProjection.js +142 -0
- package/lib/vocab.d.ts +6 -0
- package/lib/vocab.js +18 -0
- package/package.json +48 -4
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// runsValidateServe.ts — the shared compile-serve tail split from
|
|
2
|
+
// runsValidate.ts (pure move, zero logic changes): branch prune, to_graph,
|
|
3
|
+
// the $channel gate, cost preview, and the inline/named serve arms.
|
|
4
|
+
import { engineIdOk } from "@melite/engine-contract";
|
|
5
|
+
import { ENGINE_TABLE, FlowError } from "./runsValidateShared.js";
|
|
6
|
+
import { edgeRef } from "./runsValidateInline.js";
|
|
7
|
+
import { flowFromBody, kindsOk, wiresResolve } from "./runsValidateStages.js";
|
|
8
|
+
import { batchRows, sweepWorkflows } from "./runsValidateSweeps.js";
|
|
9
|
+
// ── branch prune (pruned_for — verbatim) ────────────
|
|
10
|
+
export function prunedFor(flow, body, cards) {
|
|
11
|
+
if (!flow.stages.some((st) => st.skipWhen !== null))
|
|
12
|
+
return { flow, pruned: [] };
|
|
13
|
+
const pruned = new Map();
|
|
14
|
+
const kept = [];
|
|
15
|
+
for (const st of flow.stages) {
|
|
16
|
+
const cond = st.skipWhen;
|
|
17
|
+
if (cond === null) {
|
|
18
|
+
kept.push(st);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const present = body[cond.initial] !== undefined && body[cond.initial] !== null;
|
|
22
|
+
const fire = cond.when === "present" ? present : !present;
|
|
23
|
+
if (fire)
|
|
24
|
+
pruned.set(st.id, cond);
|
|
25
|
+
else
|
|
26
|
+
kept.push(st);
|
|
27
|
+
}
|
|
28
|
+
if (kept.length === 0) {
|
|
29
|
+
throw new FlowError("flow " +
|
|
30
|
+
JSON.stringify(flow.id) +
|
|
31
|
+
": the branch pruned every stage (fired: " +
|
|
32
|
+
JSON.stringify([...pruned.keys()].sort()) +
|
|
33
|
+
") — a run with no stages never registers");
|
|
34
|
+
}
|
|
35
|
+
const merged = [];
|
|
36
|
+
for (const st of kept) {
|
|
37
|
+
const hitsPruned = st.inputs.some((i) => i.edge.kind === "stage" && pruned.has(i.edge.stage));
|
|
38
|
+
if (!hitsPruned) {
|
|
39
|
+
merged.push(st);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const newInputs = st.inputs.map((i) => ({ ...i }));
|
|
43
|
+
for (const inp of newInputs) {
|
|
44
|
+
if (inp.edge.kind !== "stage" || !pruned.has(inp.edge.stage))
|
|
45
|
+
continue;
|
|
46
|
+
const cond = pruned.get(inp.edge.stage);
|
|
47
|
+
if (cond.when !== "present") {
|
|
48
|
+
throw new FlowError("flow " +
|
|
49
|
+
JSON.stringify(flow.id) +
|
|
50
|
+
" stage " +
|
|
51
|
+
JSON.stringify(st.id) +
|
|
52
|
+
" input " +
|
|
53
|
+
JSON.stringify(inp.name) +
|
|
54
|
+
" wires FromStage(" +
|
|
55
|
+
JSON.stringify(edgeRef(inp.edge)) +
|
|
56
|
+
") to pruned stage " +
|
|
57
|
+
" (branch " +
|
|
58
|
+
JSON.stringify(cond.initial) +
|
|
59
|
+
" fired) — no request key to merge (absent-trigger prunes " +
|
|
60
|
+
"carry nothing)");
|
|
61
|
+
}
|
|
62
|
+
inp.edge = { kind: "initial", key: cond.initial };
|
|
63
|
+
}
|
|
64
|
+
merged.push({ ...st, inputs: newInputs });
|
|
65
|
+
}
|
|
66
|
+
// RECONSTRUCTED — every construction validator re-runs (TS scope:
|
|
67
|
+
// wires + deferred kinds; card/tool/validators are no-ops here).
|
|
68
|
+
wiresResolve(flow.id, merged);
|
|
69
|
+
kindsOk(flow.id, merged, {}, cards);
|
|
70
|
+
return { flow: { id: flow.id, description: flow.description, stages: merged }, pruned: [...pruned.keys()] };
|
|
71
|
+
}
|
|
72
|
+
export function toGraph(flow) {
|
|
73
|
+
return flow.stages.map((st) => {
|
|
74
|
+
const outputs = [];
|
|
75
|
+
if (st.outputs.length > 0) {
|
|
76
|
+
for (const o of st.outputs)
|
|
77
|
+
outputs.push({ ...o });
|
|
78
|
+
}
|
|
79
|
+
else if (st.cardIo.length > 0) {
|
|
80
|
+
for (const o of st.cardIo)
|
|
81
|
+
outputs.push({ ...o });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// validateEngines already refused unknown engines and the
|
|
85
|
+
// table carries a default for every known one — the
|
|
86
|
+
// try/except-unknown shape of to_graph collapses to the table.
|
|
87
|
+
// validateEngines refused unknown engines upstream — the hit is proven.
|
|
88
|
+
const row = st.engine.startsWith("mcp:") && engineIdOk(st.engine)
|
|
89
|
+
? { plugin: "mcp-client", def: "image" }
|
|
90
|
+
: ENGINE_TABLE[st.engine];
|
|
91
|
+
outputs.push({ name: "default", kind: row.def });
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
id: st.id,
|
|
95
|
+
engine: st.engine,
|
|
96
|
+
description: st.description,
|
|
97
|
+
inputFrom: st.inputs.map((i) => edgeRef(i.edge)),
|
|
98
|
+
inputNames: st.inputs.map((i) => i.name),
|
|
99
|
+
outputs,
|
|
100
|
+
params: st.params,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// dollarTokens (same file): whole-string $-tokens.
|
|
105
|
+
export function dollarTokens(params) {
|
|
106
|
+
const out = [];
|
|
107
|
+
const walk = (v) => {
|
|
108
|
+
if (typeof v === "string") {
|
|
109
|
+
if (v.startsWith("$") && v.length > 1)
|
|
110
|
+
out.push(v.slice(1));
|
|
111
|
+
}
|
|
112
|
+
else if (Array.isArray(v)) {
|
|
113
|
+
for (const item of v)
|
|
114
|
+
walk(item);
|
|
115
|
+
}
|
|
116
|
+
else if (typeof v === "object" && v !== null) {
|
|
117
|
+
for (const val of Object.values(v))
|
|
118
|
+
walk(val);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
walk(params);
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
// compileFlow (same file): prune, then toGraph, then the unresolved $channel gate (per-node pool, ALL bad joined).
|
|
125
|
+
export function compileFlow(flow, body, cards) {
|
|
126
|
+
const { flow: built, pruned } = prunedFor(flow, body, cards);
|
|
127
|
+
const nodes = toGraph(built);
|
|
128
|
+
const bad = [];
|
|
129
|
+
for (const node of nodes) {
|
|
130
|
+
const pool = new Set(node.inputNames);
|
|
131
|
+
for (const ref of node.inputFrom) {
|
|
132
|
+
if (ref.startsWith("__initial__."))
|
|
133
|
+
pool.add(ref.split(".", 2)[1]); // the prefix guarantees [1]
|
|
134
|
+
else
|
|
135
|
+
pool.add(ref);
|
|
136
|
+
}
|
|
137
|
+
const sortedPool = [...pool].sort();
|
|
138
|
+
for (const token of dollarTokens(node.params)) {
|
|
139
|
+
if (!pool.has(token)) {
|
|
140
|
+
bad.push("stage " +
|
|
141
|
+
JSON.stringify(node.id) +
|
|
142
|
+
" references $" +
|
|
143
|
+
token +
|
|
144
|
+
" (available: " +
|
|
145
|
+
(sortedPool.length > 0 ? sortedPool.join(", ") : "nothing") +
|
|
146
|
+
")");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (bad.length > 0) {
|
|
151
|
+
throw new FlowError("unresolved $channel(s): " + bad.join("; "));
|
|
152
|
+
}
|
|
153
|
+
return { nodes, skipped: pruned };
|
|
154
|
+
}
|
|
155
|
+
// ── model facts + model-dir scan (resolve_model's TS mirror) ────
|
|
156
|
+
// (Stroke 2a: the facts/route/mids caches that lived here are
|
|
157
|
+
// CardRegistryLike state now — this door reads them through its
|
|
158
|
+
// injected service. The absent-facts degrade survives at the
|
|
159
|
+
// modelArm call site, which catches the service's strict read.)
|
|
160
|
+
// ── {model} arm (resolve_card_model, ported subset) ─
|
|
161
|
+
export function costPreview(engineTypes) {
|
|
162
|
+
// A fresh Gateway: depth 0, eta null, medians unknown
|
|
163
|
+
// (cost_preview — no engine stats).
|
|
164
|
+
return {
|
|
165
|
+
queue_depth: 0,
|
|
166
|
+
eta_queue_s: null,
|
|
167
|
+
stages: engineTypes.map((et) => ({ engine: et, median_s: null, samples: 0 })),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
export function inlineArm(full, cards, knownEngines) {
|
|
171
|
+
const fullRec = typeof full === "object" && full !== null && !Array.isArray(full)
|
|
172
|
+
? full
|
|
173
|
+
: {};
|
|
174
|
+
const hasInline = typeof full === "object" && full !== null && !Array.isArray(full) && "flow_inline" in fullRec;
|
|
175
|
+
const envelope = hasInline ? fullRec["flow_inline"] : undefined;
|
|
176
|
+
const subject = envelope !== undefined && envelope !== null ? envelope : full;
|
|
177
|
+
return serveSubject(subject, fullRec, cards, knownEngines);
|
|
178
|
+
}
|
|
179
|
+
// ── the shared compile-serve tail (flowFromBody -> compile ->
|
|
180
|
+
// pin sweep -> the 200 shape; the inline arm and the named arm
|
|
181
|
+
// both ride it — one validator, never two) ──────────────────────
|
|
182
|
+
export function serveSubject(subject, fullRec, cards, knownEngines) {
|
|
183
|
+
let flow;
|
|
184
|
+
try {
|
|
185
|
+
flow = flowFromBody(subject, cards, knownEngines);
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
if (e instanceof FlowError) {
|
|
189
|
+
return {
|
|
190
|
+
status: 400,
|
|
191
|
+
payload: {
|
|
192
|
+
error: e.message,
|
|
193
|
+
code: "flow_compile",
|
|
194
|
+
loc: "flow",
|
|
195
|
+
errors: batchRows(subject, e.message, cards),
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
throw e;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// inline compiler refuses skip_when outright ("unported on this
|
|
203
|
+
|
|
204
|
+
// to answer the SAME doc 200 with a skipped receipt: one half
|
|
205
|
+
// said the branch folds, the other said the branch is unported.
|
|
206
|
+
// One law, both doors: the run door's refusal voice is the truth,
|
|
207
|
+
// so validate refuses before the prune arm can serve its 200.
|
|
208
|
+
const skipIds = flow.stages
|
|
209
|
+
.filter((st) => st.skipWhen !== null)
|
|
210
|
+
.map((st) => st.id);
|
|
211
|
+
if (skipIds.length > 0) {
|
|
212
|
+
return {
|
|
213
|
+
status: 400,
|
|
214
|
+
payload: {
|
|
215
|
+
error: "flow_inline stage " +
|
|
216
|
+
JSON.stringify(skipIds[0]) +
|
|
217
|
+
": skip_when is unported on this gateway",
|
|
218
|
+
code: "preview_scope",
|
|
219
|
+
loc: "stages",
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
let compiled;
|
|
224
|
+
try {
|
|
225
|
+
compiled = compileFlow(flow, fullRec, cards);
|
|
226
|
+
}
|
|
227
|
+
catch (e) {
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
if (e instanceof FlowError) {
|
|
233
|
+
return {
|
|
234
|
+
status: 400,
|
|
235
|
+
payload: {
|
|
236
|
+
error: e.message,
|
|
237
|
+
code: "flow_compile",
|
|
238
|
+
loc: "flow",
|
|
239
|
+
errors: batchRows(subject, e.message, cards),
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
throw e;
|
|
245
|
+
}
|
|
246
|
+
const wfRows = sweepWorkflows(subject, cards);
|
|
247
|
+
if (wfRows.length > 0) {
|
|
248
|
+
const first = wfRows[0];
|
|
249
|
+
return {
|
|
250
|
+
status: 400,
|
|
251
|
+
payload: {
|
|
252
|
+
error: first["error"],
|
|
253
|
+
code: "workflow_pin",
|
|
254
|
+
loc: first["stage"], // sweep rows always stamp stage
|
|
255
|
+
errors: wfRows,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
status: 200,
|
|
261
|
+
payload: {
|
|
262
|
+
ok: true,
|
|
263
|
+
skipped: compiled.skipped,
|
|
264
|
+
flow: flow.id,
|
|
265
|
+
cost: costPreview(compiled.nodes.map((n) => n.engine)),
|
|
266
|
+
stages: compiled.nodes.map((n) => ({
|
|
267
|
+
id: n.id,
|
|
268
|
+
engine: n.engine,
|
|
269
|
+
description: n.description,
|
|
270
|
+
inputs: n.inputFrom,
|
|
271
|
+
outputs: Object.fromEntries(n.outputs.map((o) => [o.name, o.kind])),
|
|
272
|
+
})),
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=runsValidateServe.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { CardDefinition } from '@melite/comfyui-card-kit/card-definition';
|
|
2
|
+
/** The door's answer (status folds away at the remote seam; the
|
|
3
|
+
* payload rides verbatim). */
|
|
4
|
+
export interface FlowsValidateAnswer {
|
|
5
|
+
status: number;
|
|
6
|
+
payload: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
/** The card-registry face the pure half touches, STRUCTURAL (the
|
|
9
|
+
* producing service is the cardRegistry stroke's; null = the
|
|
10
|
+
* loud-refusal paths above — never a silent degrade). */
|
|
11
|
+
export interface CardRegistryLike {
|
|
12
|
+
defsSync(): Map<string, CardDefinition>;
|
|
13
|
+
objectInfo(): Record<string, unknown> | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const ENGINE_TABLE: Record<string, {
|
|
16
|
+
plugin: string;
|
|
17
|
+
def: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const KIND_VOCAB: readonly string[];
|
|
20
|
+
export declare const SKIP_VOCAB: readonly string[];
|
|
21
|
+
export declare const INLINE_TOP_SORTED: readonly string[];
|
|
22
|
+
export declare const STAGE_KEYS_SORTED: readonly string[];
|
|
23
|
+
export { FLOW_ID_RE } from "./runsGates.js";
|
|
24
|
+
/** needCardRegistry (start-door-verbatim): the LOUD
|
|
25
|
+
* miswire when the card registry is absent — a card= stage
|
|
26
|
+
* refuses until the cardRegistry stroke slots the defs in. */
|
|
27
|
+
export declare function needCardRegistry(cards: CardRegistryLike | null | undefined, where: string): CardRegistryLike;
|
|
28
|
+
export declare class FlowError extends Error {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
export type Edge = {
|
|
32
|
+
kind: "initial";
|
|
33
|
+
key: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "stage";
|
|
36
|
+
stage: string;
|
|
37
|
+
output: string;
|
|
38
|
+
};
|
|
39
|
+
export interface StageSkip {
|
|
40
|
+
initial: string;
|
|
41
|
+
when: string;
|
|
42
|
+
}
|
|
43
|
+
export interface FlowStageRow {
|
|
44
|
+
id: string;
|
|
45
|
+
engine: string;
|
|
46
|
+
description: string;
|
|
47
|
+
params: Record<string, unknown>;
|
|
48
|
+
inputs: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
edge: Edge;
|
|
51
|
+
}>;
|
|
52
|
+
outputs: Array<{
|
|
53
|
+
name: string;
|
|
54
|
+
kind: string;
|
|
55
|
+
}>;
|
|
56
|
+
expected: Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
kind: string;
|
|
59
|
+
}>;
|
|
60
|
+
card: string;
|
|
61
|
+
cardIo: Array<{
|
|
62
|
+
name: string;
|
|
63
|
+
kind: string;
|
|
64
|
+
}>;
|
|
65
|
+
skipWhen: StageSkip | null;
|
|
66
|
+
}
|
|
67
|
+
export interface Flow {
|
|
68
|
+
id: string;
|
|
69
|
+
description: string;
|
|
70
|
+
stages: FlowStageRow[];
|
|
71
|
+
}
|
|
72
|
+
export interface GraphNode {
|
|
73
|
+
id: string;
|
|
74
|
+
engine: string;
|
|
75
|
+
description: string;
|
|
76
|
+
inputFrom: string[];
|
|
77
|
+
inputNames: string[];
|
|
78
|
+
outputs: Array<{
|
|
79
|
+
name: string;
|
|
80
|
+
kind: string;
|
|
81
|
+
}>;
|
|
82
|
+
params: unknown;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=runsValidateShared.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// runsValidateShared.ts — shared kernel split from runsValidate.ts (pure move,
|
|
2
|
+
// zero logic changes): closed vocabularies, flow-domain types, FlowError,
|
|
3
|
+
// and the card-registry face.
|
|
4
|
+
import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
|
|
5
|
+
import { INLINE_TOP_KEYS } from "./runsGates.js";
|
|
6
|
+
// ENGINE_TABLE: engine_type -> {plugin_id, default_output kind}.
|
|
7
|
+
|
|
8
|
+
// api caller for comfyui, not having engines anymore"): ComfyUI is
|
|
9
|
+
// the only engine. The old engine tiers (cpp/audio-cpp,
|
|
10
|
+
// cpp/skintokens, cpp/autoremesher, node/anycreature, sim —
|
|
11
|
+
// estate-owned subprocess compute, every card decl-only and never
|
|
12
|
+
// composable) are QUARANTINED to vendor/retired-engines/ pending
|
|
13
|
+
// rebirth as vendored ComfyUI custom nodes. Probed live from
|
|
14
|
+
// scan_engines(); re-derived per run.
|
|
15
|
+
export const ENGINE_TABLE = {
|
|
16
|
+
comfyui: { plugin: "comfyui", def: "image" },
|
|
17
|
+
// Stroke 55 (the engine-generics seam): the craft loop engine +
|
|
18
|
+
// the MCP grammar arm — any mcp:<server> id matching the seat's
|
|
19
|
+
// grammar admits (membership stays the runs door's registry arm).
|
|
20
|
+
craft: { plugin: "craft", def: "image" },
|
|
21
|
+
// Stroke 60 (plan §5): the agent engine — the spawner loop. Its
|
|
22
|
+
// stage is validated like any engine stage (params carry the four
|
|
23
|
+
// pinned fields); outputs are arbitrary (artifacts land in the
|
|
24
|
+
// run dir).
|
|
25
|
+
agent: { plugin: "agent", def: "text" },
|
|
26
|
+
};
|
|
27
|
+
// ── closed vocabularies (Kind / SkipWhen order) ──────
|
|
28
|
+
export const KIND_VOCAB = [
|
|
29
|
+
"text",
|
|
30
|
+
"image",
|
|
31
|
+
"video",
|
|
32
|
+
"audio",
|
|
33
|
+
"mesh",
|
|
34
|
+
"num",
|
|
35
|
+
"lora",
|
|
36
|
+
"seg",
|
|
37
|
+
"data",
|
|
38
|
+
];
|
|
39
|
+
export const SKIP_VOCAB = ["present", "absent"];
|
|
40
|
+
// _INLINE_TOP_KEYS sorted (dead/allowed messages) — DERIVED, not
|
|
41
|
+
|
|
42
|
+
// hand-typed copy of runsGates' INLINE_TOP_KEYS: equal today, and a
|
|
43
|
+
// SILENT start-vs-validate disagreement the moment either side grew —
|
|
44
|
+
// proven, not predicted. Adding a top-level key to the start door's
|
|
45
|
+
// list alone left the start verdict `ok`, the validate door refusing
|
|
46
|
+
// `unknown keys ["labels"]`, and 115 tests green. The very next line
|
|
47
|
+
// below already DERIVED its sibling from the contract; this one was
|
|
48
|
+
// the copy the same audit had to be shown twice. The members are
|
|
49
|
+
// runsGates'; only the sort is ours.
|
|
50
|
+
export const INLINE_TOP_SORTED = [...INLINE_TOP_KEYS].sort();
|
|
51
|
+
// sorted(WIRE_STAGE_KEYS) — DERIVED, not retyped (the identity law,
|
|
52
|
+
|
|
53
|
+
// equal today, and a silent start-vs-validate disagreement the moment
|
|
54
|
+
|
|
55
|
+
// enumerated twice will disagree with itself the first time it
|
|
56
|
+
// grows). The sort is the only transformation; the members are the
|
|
57
|
+
// contract's.
|
|
58
|
+
export const STAGE_KEYS_SORTED = [...WIRE_STAGE_KEYS].sort();
|
|
59
|
+
// ── strict-body vocab ───────────────────
|
|
60
|
+
// Owned by the admission gate (runsGates — the SSOT shared with the
|
|
61
|
+
// start door); the envelope lift is prepareCardParams' own (the
|
|
62
|
+
// compose seat, one owner for both doors — validate + start
|
|
63
|
+
// compose identical params). The id REs stay here
|
|
64
|
+
// (flow-construction semantics, not envelope admission).
|
|
65
|
+
// THE STAGE/FLOW ID SHAPE IS runsGates.FLOW_ID_RE — the admission
|
|
66
|
+
// law the flow arms test before asking the registry, re-exported
|
|
67
|
+
// here so this module's importers keep one address. One declaration
|
|
68
|
+
// in the tree: a second copy is a second answer to "is this a legal
|
|
69
|
+
// id", which closure-gate RULE 4d fails.
|
|
70
|
+
export { FLOW_ID_RE } from "./runsGates.js";
|
|
71
|
+
/** needCardRegistry (start-door-verbatim): the LOUD
|
|
72
|
+
* miswire when the card registry is absent — a card= stage
|
|
73
|
+
* refuses until the cardRegistry stroke slots the defs in. */
|
|
74
|
+
export function needCardRegistry(cards, where) {
|
|
75
|
+
if (cards === null || cards === undefined) {
|
|
76
|
+
throw new Error("[card_registry] no CardRegistryService for " + where +
|
|
77
|
+
" — the registry rides the cards stroke (REBUILD ledger)");
|
|
78
|
+
}
|
|
79
|
+
return cards;
|
|
80
|
+
}
|
|
81
|
+
// ── flow errors (FlowError — the door's 400 language) ─
|
|
82
|
+
export class FlowError extends Error {
|
|
83
|
+
constructor(message) {
|
|
84
|
+
super(message);
|
|
85
|
+
this.name = "FlowError";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=runsValidateShared.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CardDefinition } from '@melite/comfyui-card-kit/card-definition';
|
|
2
|
+
import type { CardRegistryLike, Flow, FlowStageRow } from "./runsValidateShared.js";
|
|
3
|
+
export type { FlowStageRow };
|
|
4
|
+
export declare function strictBody(body: Record<string, unknown>): void;
|
|
5
|
+
export declare function buildStageRow(i: number, st: unknown): FlowStageRow;
|
|
6
|
+
export declare function wiresResolve(flowId: string, stages: FlowStageRow[]): void;
|
|
7
|
+
export declare function cardGate(flowId: string, st: FlowStageRow, cards?: CardRegistryLike | null): void;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export declare function coerceSnapshotBody(def: CardDefinition | undefined, body: Record<string, unknown>): Record<string, unknown>;
|
|
22
|
+
export declare function kindsOk(flowId: string, stages: FlowStageRow[], engineDefaults: Record<string, string | null>, cards?: CardRegistryLike | null): void;
|
|
23
|
+
export declare function validateEngines(flow: Flow, cards?: CardRegistryLike | null,
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
knownEngines?: readonly string[]): Flow;
|
|
31
|
+
export declare function flowFromBody(body: unknown, cards?: CardRegistryLike | null, knownEngines?: readonly string[]): Flow;
|
|
32
|
+
//# sourceMappingURL=runsValidateStages.d.ts.map
|