@melite/estate-queue 0.0.0-stage → 0.1.4-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/lib/bakeParams.d.ts +17 -0
- package/lib/bakeParams.js +182 -0
- package/lib/bench.d.ts +24 -0
- package/lib/bench.js +121 -0
- package/lib/cardsArmError.d.ts +18 -0
- package/lib/cardsArmError.js +33 -0
- package/lib/cardsCompose.d.ts +41 -0
- package/lib/cardsCompose.js +247 -0
- package/lib/cardsDangling.d.ts +16 -0
- package/lib/cardsDangling.js +168 -0
- package/lib/cardsFacts.d.ts +74 -0
- package/lib/cardsFacts.js +64 -0
- package/lib/cardsLanes.d.ts +33 -0
- package/lib/cardsLanes.js +115 -0
- package/lib/cardsRegistry.d.ts +316 -0
- package/lib/cardsRegistry.js +1274 -0
- package/lib/cardsVariant.d.ts +28 -0
- package/lib/cardsVariant.js +190 -0
- package/lib/discloseRegistry.d.ts +94 -0
- package/lib/discloseRegistry.js +154 -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 +179 -0
- package/lib/flowsData.js +547 -0
- package/lib/flowsFamilyCompose.d.ts +48 -0
- package/lib/flowsFamilyCompose.js +191 -0
- package/lib/flowsRegistryRows.d.ts +10 -0
- package/lib/flowsRegistryRows.js +378 -0
- package/lib/index.d.ts +50 -0
- package/lib/index.js +66 -0
- package/lib/ledgerTail.d.ts +20 -0
- package/lib/ledgerTail.js +123 -0
- package/lib/loadPlane.d.ts +93 -0
- package/lib/loadPlane.js +553 -0
- package/lib/loadRegistry.d.ts +22 -0
- package/lib/loadRegistry.js +55 -0
- package/lib/manageOps.d.ts +21 -0
- package/lib/manageOps.js +142 -0
- package/lib/managePlane.d.ts +120 -0
- package/lib/managePlane.js +1515 -0
- package/lib/manageProbe.d.ts +57 -0
- package/lib/manageProbe.js +154 -0
- package/lib/manageRegistry.d.ts +28 -0
- package/lib/manageRegistry.js +75 -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 +76 -0
- package/lib/queueCore.d.ts +69 -0
- package/lib/queueCore.js +124 -0
- package/lib/queueLifecycle.d.ts +26 -0
- package/lib/queueLifecycle.js +65 -0
- package/lib/queueLock.d.ts +54 -0
- package/lib/queueLock.js +195 -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 +145 -0
- package/lib/queueSidecar.js +182 -0
- package/lib/queueSubmit.d.ts +31 -0
- package/lib/queueSubmit.js +117 -0
- package/lib/queueSweep.d.ts +30 -0
- package/lib/queueSweep.js +121 -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/runStatus.d.ts +7 -0
- package/lib/runStatus.js +21 -0
- package/lib/runsChange.d.ts +53 -0
- package/lib/runsChange.js +63 -0
- package/lib/runsErrorCodes.d.ts +2 -0
- package/lib/runsErrorCodes.js +15 -0
- package/lib/runsExecute.d.ts +26 -0
- package/lib/runsExecute.js +356 -0
- package/lib/runsGates.d.ts +161 -0
- package/lib/runsGates.js +306 -0
- package/lib/runsList.d.ts +78 -0
- package/lib/runsList.js +580 -0
- package/lib/runsRefusalVoices.d.ts +9 -0
- package/lib/runsRefusalVoices.js +44 -0
- package/lib/runsRegistry.d.ts +253 -0
- package/lib/runsRegistry.js +1750 -0
- package/lib/runsSourceEcho.d.ts +54 -0
- package/lib/runsSourceEcho.js +275 -0
- package/lib/runsStart.d.ts +121 -0
- package/lib/runsStart.js +528 -0
- package/lib/runsTypes.d.ts +183 -0
- package/lib/runsTypes.js +282 -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 +285 -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 +254 -0
- package/lib/runsValidateShared.d.ts +84 -0
- package/lib/runsValidateShared.js +88 -0
- package/lib/runsValidateStages.d.ts +25 -0
- package/lib/runsValidateStages.js +491 -0
- package/lib/runsValidateSweeps.d.ts +6 -0
- package/lib/runsValidateSweeps.js +143 -0
- package/lib/service.d.ts +45 -0
- package/lib/service.js +81 -0
- package/lib/skillFrontmatter.d.ts +11 -0
- package/lib/skillFrontmatter.js +46 -0
- package/lib/skillFs.d.ts +19 -0
- package/lib/skillFs.js +80 -0
- package/lib/skillPlane.d.ts +98 -0
- package/lib/skillPlane.js +263 -0
- package/lib/skillRegistry.d.ts +23 -0
- package/lib/skillRegistry.js +55 -0
- package/lib/skillRows.d.ts +126 -0
- package/lib/skillRows.js +466 -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 +47 -4
- package/README.md +0 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** The serving prefixes the estate owns (comfyui-upload's
|
|
2
|
+
* MEDIA/ASSET_ROUTE_PREFIX twins — detection is case-insensitive
|
|
3
|
+
* like the engine's; the sliced tail keeps its case). */
|
|
4
|
+
export declare const MEDIA_RUNS_PREFIX: string;
|
|
5
|
+
export declare const ASSET_RUNS_PREFIX: string;
|
|
6
|
+
export type SourceFace = "run" | "abs";
|
|
7
|
+
/** A collected pointer: the VERBATIM string (history stamps what
|
|
8
|
+
* the params held — the engine trims for staging, the record
|
|
9
|
+
* keeps the author's spelling) plus its parsed face. */
|
|
10
|
+
export interface ParsedSource {
|
|
11
|
+
readonly url: string;
|
|
12
|
+
readonly face: SourceFace;
|
|
13
|
+
readonly runId: string;
|
|
14
|
+
readonly rel: string;
|
|
15
|
+
readonly abs: string;
|
|
16
|
+
}
|
|
17
|
+
/** Collect every source pointer in a params tree (deep walk over
|
|
18
|
+
* objects/arrays — card params nest refs inside calls, clips,
|
|
19
|
+
* stanzas). Verbatim strings, order of discovery, deduped.
|
|
20
|
+
* Detection runs on the trimmed string (the engine trims); the
|
|
21
|
+
* stamped URL keeps the author's spelling. */
|
|
22
|
+
export declare function collectSourceRefs(value: unknown): string[];
|
|
23
|
+
/** Backward face (the first law's name): the media-prefix sweep.
|
|
24
|
+
* New code prefers collectSourceRefs. */
|
|
25
|
+
export declare function collectMediaRefs(value: unknown): string[];
|
|
26
|
+
/** Parse a collected pointer. Throws naming the violation when the
|
|
27
|
+
* shape or a segment breaks confinement — an unservable pointer
|
|
28
|
+
* refuses here, loud. */
|
|
29
|
+
export declare function parseSourceRef(ref: string): ParsedSource;
|
|
30
|
+
/** Backward face: parse a media-prefix URL. */
|
|
31
|
+
export declare function parseMediaRef(ref: string): {
|
|
32
|
+
runId: string;
|
|
33
|
+
rel: string;
|
|
34
|
+
};
|
|
35
|
+
export interface SourceEchoRef {
|
|
36
|
+
readonly url: string;
|
|
37
|
+
readonly file: string;
|
|
38
|
+
}
|
|
39
|
+
/** Resolve every pointer the way the engine stages it — run faces
|
|
40
|
+
* walk the manifest trees (first root holding the RUN DIR wins,
|
|
41
|
+
* the file rides under it — the server's and the stager's shared
|
|
42
|
+
* walk), tails fall through to cwd (the stager's own order),
|
|
43
|
+
* absolute paths stage verbatim. A pointer at selfRunId (the run
|
|
44
|
+
* being registered — the compose writes its OWN future output
|
|
45
|
+
* path, `${runId}/gen`, into the graph) is a forward reference,
|
|
46
|
+
* not a source: it passes unstamped, never refused. Returns the
|
|
47
|
+
* resolved rows in collection order. Throws ONE error naming EVERY
|
|
48
|
+
* unresolvable source plus the roots searched — the run refuses
|
|
49
|
+
* before it registers, never mid-render. */
|
|
50
|
+
export declare function resolveSourceRefs(refs: readonly string[], roots: readonly string[], cwd?: string, selfRunId?: string): SourceEchoRef[];
|
|
51
|
+
/** Backward face (roots-only walk — the first law's signature).
|
|
52
|
+
* New code prefers resolveSourceRefs. */
|
|
53
|
+
export declare function resolveMediaRefs(refs: readonly string[], roots: readonly string[]): SourceEchoRef[];
|
|
54
|
+
//# sourceMappingURL=runsSourceEcho.d.ts.map
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { segmentConfined, servableLeaf } from "@melite/contracts/mediaKinds";
|
|
2
|
+
|
|
3
|
+
// every generation run carries history pointing at the files that
|
|
4
|
+
// created it, and a break in that chain refuses LOUD — never silent.
|
|
5
|
+
//
|
|
6
|
+
// The compose-echo (runsStart registerCompiledRun) is the read-side
|
|
7
|
+
// model (what the engine received, stamped on the record + console +
|
|
8
|
+
// ledger). This is the source-side twin: collect every source
|
|
9
|
+
// pointer in the compiled stage params, resolve each the way the
|
|
10
|
+
// engine's submit-time walk stages it (comfyui-upload stageOne —
|
|
11
|
+
// the engine TRIMS, matches both estate prefixes case-insensitively,
|
|
12
|
+
// walks candidateTrees, falls a run-tail through to cwd), refuse
|
|
13
|
+
// naming the dead, stamp the resolved on the run record.
|
|
14
|
+
//
|
|
15
|
+
// Faces swept (anything else — data: URLs, bare artifact names,
|
|
16
|
+
// http(s) linked inputs, prose — rides untouched; the engine owns
|
|
17
|
+
// those arms and refuses them loud itself):
|
|
18
|
+
// /melite-media/runs/<run>/<rel> (the media route)
|
|
19
|
+
// /v1/assets/runs/<run>/<rel> (the assets route — same trees)
|
|
20
|
+
// <run-id>/<rel> (runs-relative tails; the first
|
|
21
|
+
// segment must match the mint
|
|
22
|
+
// grammar — prose with slashes
|
|
23
|
+
// never qualifies)
|
|
24
|
+
// /abs/path (absolute disk paths — the cwd
|
|
25
|
+
// arm stages them verbatim)
|
|
26
|
+
// The parse is a TWIN of the server's parseTarget (RUN_ID grammar +
|
|
27
|
+
// segment confinement + the _poster.jpg servable exception),
|
|
28
|
+
// cross-linked, not shared — the server's parser is route-local and
|
|
29
|
+
// unexported; a twin with the same laws cannot drift silently
|
|
30
|
+
// because the walls pin both faces.
|
|
31
|
+
// Erasable-syntax TS only (node --experimental-strip-types): no
|
|
32
|
+
// enums, import type for types, .ts specifiers for relative imports.
|
|
33
|
+
import { LEGACY_RUN_MEDIA_PREFIX, RUN_MEDIA_PREFIX, RUN_ID_RE } from "@melite/contracts/benchStage";
|
|
34
|
+
import { statSync } from "node:fs";
|
|
35
|
+
import { join } from "node:path";
|
|
36
|
+
/** The serving prefixes the estate owns (comfyui-upload's
|
|
37
|
+
* MEDIA/ASSET_ROUTE_PREFIX twins — detection is case-insensitive
|
|
38
|
+
* like the engine's; the sliced tail keeps its case). */
|
|
39
|
+
// THE CONTRACT'S TWO NAMES (benchStage.ts) with the trailing slash
|
|
40
|
+
// these readers index by — derived, never retyped, so a change of
|
|
41
|
+
// the live prefix or the legacy set reaches every reader at once.
|
|
42
|
+
export const MEDIA_RUNS_PREFIX = RUN_MEDIA_PREFIX + "/";
|
|
43
|
+
export const ASSET_RUNS_PREFIX = LEGACY_RUN_MEDIA_PREFIX + "/";
|
|
44
|
+
/** The run-dir basename grammar (the mint law — media index.ts). */
|
|
45
|
+
const RUN_ID = RUN_ID_RE;
|
|
46
|
+
/** The detection grammar (runs on the trimmed string — the engine
|
|
47
|
+
* trims before every arm, so detection sees what staging sees):
|
|
48
|
+
* either estate prefix (either case), an absolute path, or a
|
|
49
|
+
* run-tail whose first segment matches the mint grammar. Prose
|
|
50
|
+
* with slashes never qualifies — no false refusals on prompts. */
|
|
51
|
+
function detectFace(t) {
|
|
52
|
+
const lower = t.toLowerCase();
|
|
53
|
+
// Both estate prefixes end in "/runs/" — one slice serves both
|
|
54
|
+
// faces (detection is case-insensitive like the engine's; the
|
|
55
|
+
// tail keeps its case).
|
|
56
|
+
if (lower.startsWith(MEDIA_RUNS_PREFIX) || lower.startsWith(ASSET_RUNS_PREFIX)) {
|
|
57
|
+
return { face: "run", rest: t.slice(lower.indexOf("/runs/") + "/runs/".length) };
|
|
58
|
+
}
|
|
59
|
+
if (t.startsWith("/"))
|
|
60
|
+
return { face: "abs", rest: t };
|
|
61
|
+
|
|
62
|
+
// `t.includes("..")` substring ban refused a LEGAL name the engine
|
|
63
|
+
// mints (`still..frame.png`) while judging the whole string —
|
|
64
|
+
// traversal is a property of SEGMENTS, not substrings. The
|
|
65
|
+
// contracts' own grammar (dots-only and NUL and empty refused,
|
|
66
|
+
// every other name legal) judges each segment.
|
|
67
|
+
if (!t.includes("/"))
|
|
68
|
+
return null;
|
|
69
|
+
if (t.split("/").some((seg) => !segmentConfined(seg)))
|
|
70
|
+
return null;
|
|
71
|
+
const head = t.split("/", 1)[0];
|
|
72
|
+
let decodedHead;
|
|
73
|
+
try {
|
|
74
|
+
decodedHead = decodeURIComponent(head);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!RUN_ID.test(decodedHead))
|
|
80
|
+
return null;
|
|
81
|
+
return { face: "run", rest: t };
|
|
82
|
+
}
|
|
83
|
+
/** Collect every source pointer in a params tree (deep walk over
|
|
84
|
+
* objects/arrays — card params nest refs inside calls, clips,
|
|
85
|
+
* stanzas). Verbatim strings, order of discovery, deduped.
|
|
86
|
+
* Detection runs on the trimmed string (the engine trims); the
|
|
87
|
+
* stamped URL keeps the author's spelling. */
|
|
88
|
+
export function collectSourceRefs(value) {
|
|
89
|
+
const found = [];
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
const seenObjs = new Set();
|
|
92
|
+
const stack = [value];
|
|
93
|
+
while (stack.length > 0) {
|
|
94
|
+
const cur = stack.pop();
|
|
95
|
+
if (typeof cur === "string") {
|
|
96
|
+
const t = cur.trim();
|
|
97
|
+
if (t !== "" && detectFace(t) !== null && !seen.has(cur)) {
|
|
98
|
+
seen.add(cur);
|
|
99
|
+
found.push(cur);
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (typeof cur !== "object" || cur === null)
|
|
104
|
+
continue;
|
|
105
|
+
if (seenObjs.has(cur))
|
|
106
|
+
continue;
|
|
107
|
+
seenObjs.add(cur);
|
|
108
|
+
if (Array.isArray(cur)) {
|
|
109
|
+
for (let i = cur.length - 1; i >= 0; i--)
|
|
110
|
+
stack.push(cur[i]);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const rec = cur;
|
|
114
|
+
const keys = Object.keys(rec);
|
|
115
|
+
for (let i = keys.length - 1; i >= 0; i--)
|
|
116
|
+
stack.push(rec[keys[i]]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return found;
|
|
120
|
+
}
|
|
121
|
+
/** Backward face (the first law's name): the media-prefix sweep.
|
|
122
|
+
* New code prefers collectSourceRefs. */
|
|
123
|
+
export function collectMediaRefs(value) {
|
|
124
|
+
return collectSourceRefs(value).filter((s) => s.trim().toLowerCase().startsWith(MEDIA_RUNS_PREFIX));
|
|
125
|
+
}
|
|
126
|
+
/** Parse a collected pointer. Throws naming the violation when the
|
|
127
|
+
* shape or a segment breaks confinement — an unservable pointer
|
|
128
|
+
* refuses here, loud. */
|
|
129
|
+
export function parseSourceRef(ref) {
|
|
130
|
+
const t = ref.trim();
|
|
131
|
+
const det = detectFace(t);
|
|
132
|
+
if (det === null) {
|
|
133
|
+
throw new Error("not a source pointer: " + JSON.stringify(ref));
|
|
134
|
+
}
|
|
135
|
+
if (det.face === "abs") {
|
|
136
|
+
if (t.includes("\0")) {
|
|
137
|
+
throw new Error("media source refuses NUL: " + JSON.stringify(ref));
|
|
138
|
+
}
|
|
139
|
+
return { url: ref, face: "abs", runId: "", rel: "", abs: t };
|
|
140
|
+
}
|
|
141
|
+
const parts = det.rest.split("/");
|
|
142
|
+
if (parts.length < 2) {
|
|
143
|
+
throw new Error("malformed media source (want <prefix>/<run_id>/<file>): " +
|
|
144
|
+
JSON.stringify(ref));
|
|
145
|
+
}
|
|
146
|
+
const runId = parts[0];
|
|
147
|
+
if (!RUN_ID.test(runId)) {
|
|
148
|
+
throw new Error("malformed media source (run dir breaks the mint grammar): " +
|
|
149
|
+
JSON.stringify(ref));
|
|
150
|
+
}
|
|
151
|
+
const relParts = [];
|
|
152
|
+
for (const seg of parts.slice(1)) {
|
|
153
|
+
let decoded;
|
|
154
|
+
try {
|
|
155
|
+
decoded = decodeURIComponent(seg);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
throw new Error("malformed media source (bad percent-escape): " + JSON.stringify(ref));
|
|
159
|
+
}
|
|
160
|
+
if (!segmentConfined(decoded)) {
|
|
161
|
+
throw new Error("media source refuses traversal: " + JSON.stringify(ref));
|
|
162
|
+
}
|
|
163
|
+
relParts.push(decoded);
|
|
164
|
+
}
|
|
165
|
+
// THE SERVABLE-MEDIA FENCE (media index.ts relServable twin):
|
|
166
|
+
// run STATE files are not sources (the server 404s them) —
|
|
167
|
+
// _poster.jpg excepted (a legit thumbnail source).
|
|
168
|
+
const base = relParts[relParts.length - 1];
|
|
169
|
+
if (base.startsWith("_") && !servableLeaf(base)) {
|
|
170
|
+
throw new Error("media source is a run-state file, not servable media: " +
|
|
171
|
+
JSON.stringify(ref));
|
|
172
|
+
}
|
|
173
|
+
return { url: ref, face: "run", runId, rel: relParts.join("/"), abs: "" };
|
|
174
|
+
}
|
|
175
|
+
/** Backward face: parse a media-prefix URL. */
|
|
176
|
+
export function parseMediaRef(ref) {
|
|
177
|
+
const p = parseSourceRef(ref);
|
|
178
|
+
if (p.face !== "run")
|
|
179
|
+
throw new Error("not a run source: " + JSON.stringify(ref));
|
|
180
|
+
return { runId: p.runId, rel: p.rel };
|
|
181
|
+
}
|
|
182
|
+
function isDir(p) {
|
|
183
|
+
try {
|
|
184
|
+
return statSync(p).isDirectory();
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function isFile(p) {
|
|
191
|
+
try {
|
|
192
|
+
return statSync(p).isFile();
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/** Resolve every pointer the way the engine stages it — run faces
|
|
199
|
+
* walk the manifest trees (first root holding the RUN DIR wins,
|
|
200
|
+
* the file rides under it — the server's and the stager's shared
|
|
201
|
+
* walk), tails fall through to cwd (the stager's own order),
|
|
202
|
+
* absolute paths stage verbatim. A pointer at selfRunId (the run
|
|
203
|
+
* being registered — the compose writes its OWN future output
|
|
204
|
+
* path, `${runId}/gen`, into the graph) is a forward reference,
|
|
205
|
+
* not a source: it passes unstamped, never refused. Returns the
|
|
206
|
+
* resolved rows in collection order. Throws ONE error naming EVERY
|
|
207
|
+
* unresolvable source plus the roots searched — the run refuses
|
|
208
|
+
* before it registers, never mid-render. */
|
|
209
|
+
export function resolveSourceRefs(refs, roots, cwd = process.cwd(), selfRunId = "") {
|
|
210
|
+
const dead = [];
|
|
211
|
+
const rows = [];
|
|
212
|
+
for (const ref of refs) {
|
|
213
|
+
let parsed;
|
|
214
|
+
try {
|
|
215
|
+
parsed = parseSourceRef(ref);
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
dead.push(ref + " (" + e.message + ")");
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
let file = "";
|
|
222
|
+
if (parsed.face === "abs") {
|
|
223
|
+
if (isFile(parsed.abs))
|
|
224
|
+
file = parsed.abs;
|
|
225
|
+
}
|
|
226
|
+
else if (selfRunId !== "" && parsed.runId === selfRunId) {
|
|
227
|
+
|
|
228
|
+
// it: krea-2's composed graph carries `${runId}/gen`, its OWN
|
|
229
|
+
// SaveImage prefix, inside stage params; refusing it refuses
|
|
230
|
+
// every generation). Forward reference — passes unstamped.
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
for (const root of roots) {
|
|
235
|
+
const runDir = join(root, "output", parsed.runId);
|
|
236
|
+
if (!isDir(runDir))
|
|
237
|
+
continue;
|
|
238
|
+
const cand = join(runDir, parsed.rel);
|
|
239
|
+
if (isFile(cand)) {
|
|
240
|
+
file = cand;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// THE CWD FALL-THROUGH (the stager's own order — a tail the
|
|
245
|
+
// trees miss still stages from the lane's cwd, so the guard
|
|
246
|
+
// honors it too; same process, same cwd, no drift).
|
|
247
|
+
if (file === "" && !parsed.url.trim().startsWith("/")) {
|
|
248
|
+
const cand = join(cwd, parsed.rel);
|
|
249
|
+
if (isFile(cand))
|
|
250
|
+
file = cand;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (file === "")
|
|
254
|
+
dead.push(ref);
|
|
255
|
+
else
|
|
256
|
+
rows.push({ url: ref, file });
|
|
257
|
+
}
|
|
258
|
+
if (dead.length > 0) {
|
|
259
|
+
throw new Error("run sources resolve nowhere (" +
|
|
260
|
+
dead.length +
|
|
261
|
+
" dead: " +
|
|
262
|
+
dead.join("; ") +
|
|
263
|
+
") — searched roots " +
|
|
264
|
+
JSON.stringify(roots) +
|
|
265
|
+
" (+ lane cwd for run-tails). " +
|
|
266
|
+
"Re-link or regenerate the sources; the run refuses rather than render sourceless");
|
|
267
|
+
}
|
|
268
|
+
return rows;
|
|
269
|
+
}
|
|
270
|
+
/** Backward face (roots-only walk — the first law's signature).
|
|
271
|
+
* New code prefers resolveSourceRefs. */
|
|
272
|
+
export function resolveMediaRefs(refs, roots) {
|
|
273
|
+
return resolveSourceRefs(refs, roots);
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=runsSourceEcho.js.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { EngineJson } from "@melite/comfyui-cordis";
|
|
2
|
+
import type { QueueRefusal } from "./queue.js";
|
|
3
|
+
import type { RunId } from "./queueCore.js";
|
|
4
|
+
import type { RunRecord } from "./runsTypes.js";
|
|
5
|
+
/** The door's refusal shape (status carries the HTTP class; the
|
|
6
|
+
* remote folds it into RemoteError details). */
|
|
7
|
+
export type StartRefusal = QueueRefusal;
|
|
8
|
+
/** One compiled stage (the rim the worker splices). */
|
|
9
|
+
export interface CompiledStage {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** The stage's engine id (stroke 53): the card plane's engine or 'mcp:<server>'
|
|
12
|
+
* — the door's engine gate admits exactly these; carried through
|
|
13
|
+
* to the run rows so the worker dispatches by it. */
|
|
14
|
+
readonly engine: string;
|
|
15
|
+
readonly params: Record<string, EngineJson>;
|
|
16
|
+
readonly outputs: Record<string, EngineJson>;
|
|
17
|
+
readonly expected: Record<string, EngineJson>;
|
|
18
|
+
readonly outputNodes: Record<string, EngineJson>;
|
|
19
|
+
readonly inputNames: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
/** flow_inline structural compile — door-verbatim (structure via
|
|
22
|
+
* the admission verdicts, voice here; the engine policy +
|
|
23
|
+
* default-fills below are value-domain, not type structure).
|
|
24
|
+
*
|
|
25
|
+
* THE ENGINE GATE (stroke 53, the engine-generics seam): the
|
|
26
|
+
* engine id must be GRAMMATICAL (the card plane's engine or 'mcp:<server>',
|
|
27
|
+
* engine-contract's engineIdOk) AND known to the caller. The
|
|
28
|
+
* caller passes the live registry ids (the 'engines' seat when
|
|
29
|
+
* mounted); the default (CARD_PLANE_ENGINE) keeps every seat-less boot
|
|
30
|
+
* (fixtures, walls) on the pre-seam voice. */
|
|
31
|
+
export declare function compileFlowInline(inline: unknown, knownEngines?: readonly string[]): {
|
|
32
|
+
stages: CompiledStage[];
|
|
33
|
+
} | StartRefusal;
|
|
34
|
+
/** The door-selection gate: exactly one of flow / flow_inline /
|
|
35
|
+
* model, in DOOR order for the ambiguity text (resolve_request
|
|
36
|
+
* 302). Returns the selected door key, or the refusal. */
|
|
37
|
+
export declare function selectSubmitDoor(body: Record<string, unknown>): {
|
|
38
|
+
door: "flow" | "flow_inline" | "model";
|
|
39
|
+
} | StartRefusal;
|
|
40
|
+
/** The envelope refusal texts (door-verbatim, for the remote's
|
|
41
|
+
* envelope walk). Kept as a table — one voice each, like the
|
|
42
|
+
* admission gate's static tables. */
|
|
43
|
+
export declare function envelopeRefusal(kind: "not-object" | "bad-test" | "missing-draft" | "malformed-draft", doc: unknown, detail?: {
|
|
44
|
+
testFlag?: unknown;
|
|
45
|
+
draftId?: string;
|
|
46
|
+
}): StartRefusal;
|
|
47
|
+
/** The unknown-draft refusal (door-verbatim; the probe rides the
|
|
48
|
+
* caller's drafts domain — the remote hops the ctx seat). */
|
|
49
|
+
export declare function unknownDraftRefusal(draftId: string): StartRefusal;
|
|
50
|
+
/** The registration tail (door-verbatim): mint the id, route the
|
|
51
|
+
* out root on the test flag, build the rich run row. The caller
|
|
52
|
+
* (the remote) enqueues it on the queue core + kicks the pump.
|
|
53
|
+
* Returns the row and its queue position. */
|
|
54
|
+
export declare function registerCompiledRun(args: {
|
|
55
|
+
compiled: {
|
|
56
|
+
stages: CompiledStage[];
|
|
57
|
+
};
|
|
58
|
+
testFlag: boolean;
|
|
59
|
+
draftId: string;
|
|
60
|
+
stateRoot: string;
|
|
61
|
+
enqueue: (row: {
|
|
62
|
+
runId: RunId;
|
|
63
|
+
status: string;
|
|
64
|
+
error: string;
|
|
65
|
+
createdAt: number;
|
|
66
|
+
draftId: string;
|
|
67
|
+
testFlag: boolean;
|
|
68
|
+
stopFlag: boolean;
|
|
69
|
+
}) => number;
|
|
70
|
+
/** F-6(b) admission warnings (computed pre-registration by the
|
|
71
|
+
* start door — the film lane's VRAM-pressure warn): stamped on
|
|
72
|
+
* the record and the queued sidecar. Absent means none. */
|
|
73
|
+
warnings?: string[];
|
|
74
|
+
/** The {model:} card door carries its own run identity (minted
|
|
75
|
+
* BEFORE phase-2 compose — a refusal names its field, never a
|
|
76
|
+
* zombie slot) + the pipeline/cardId/request body for the
|
|
77
|
+
* registration writes. */
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
door: {
|
|
97
|
+
runId: RunId;
|
|
98
|
+
pipeline: string;
|
|
99
|
+
/** The card arm's identity (card snapshot law). The inline
|
|
100
|
+
* REPLAY arm (stroke 83 boot resurrect) reuses a run id with
|
|
101
|
+
* NO card identity — cardId undefined means no snapshot is
|
|
102
|
+
* stamped and pipeline still rides the door. */
|
|
103
|
+
cardId?: string;
|
|
104
|
+
requestBody: Record<string, unknown>;
|
|
105
|
+
/** The flow arms' request initials (the start body's values for
|
|
106
|
+
* the flow's declared initial validators, extracted after the
|
|
107
|
+
* compile-time gate passed): threaded to the engine merge so
|
|
108
|
+
* `$spell` params resolve. Absent when the flow declares no
|
|
109
|
+
* initials, on the card arm, and on a hand-authored or
|
|
110
|
+
* bench-composed inline doc. */
|
|
111
|
+
initials?: Record<string, EngineJson>;
|
|
112
|
+
/** The bench doc read at submit (stroke 45d) — the FULL workflow
|
|
113
|
+
* the run was born from (all stages + intent), stamped verbatim
|
|
114
|
+
* so the wand restores the whole flow, not just the ran card. */
|
|
115
|
+
benchDoc?: Record<string, unknown>;
|
|
116
|
+
};
|
|
117
|
+
}): Promise<{
|
|
118
|
+
run: RunRecord;
|
|
119
|
+
queuePosition: number;
|
|
120
|
+
} | StartRefusal>;
|
|
121
|
+
//# sourceMappingURL=runsStart.d.ts.map
|