@melite/estate-queue 0.1.5-pre-alpha → 0.2.2-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.
Files changed (82) hide show
  1. package/LICENSE +561 -457
  2. package/README.md +0 -5
  3. package/lib/cardsArmError.d.ts +52 -3
  4. package/lib/cardsArmError.js +7 -1
  5. package/lib/cardsCompose.d.ts +31 -0
  6. package/lib/cardsCompose.js +98 -7
  7. package/lib/cardsFacts.d.ts +16 -0
  8. package/lib/cardsFacts.js +25 -1
  9. package/lib/cardsLanes.d.ts +51 -3
  10. package/lib/cardsLanes.js +337 -13
  11. package/lib/cardsLanesCopy.d.ts +21 -0
  12. package/lib/cardsLanesCopy.js +22 -0
  13. package/lib/cardsRegistry.d.ts +105 -5
  14. package/lib/cardsRegistry.js +826 -46
  15. package/lib/cardsVariant.d.ts +12 -7
  16. package/lib/cardsVariant.js +196 -58
  17. package/lib/discloseRegistry.d.ts +41 -6
  18. package/lib/discloseRegistry.js +155 -17
  19. package/lib/filmLead.js +5 -3
  20. package/lib/flowsData.d.ts +77 -21
  21. package/lib/flowsData.js +159 -21
  22. package/lib/flowsFamilyCompose.js +12 -1
  23. package/lib/flowsRegistryRows.d.ts +0 -3
  24. package/lib/flowsRegistryRows.js +166 -222
  25. package/lib/index.d.ts +1 -1
  26. package/lib/index.js +6 -4
  27. package/lib/loadPlane.d.ts +46 -4
  28. package/lib/loadPlane.js +116 -7
  29. package/lib/loadRegistry.js +9 -2
  30. package/lib/manageOps.js +2 -1
  31. package/lib/managePlane.d.ts +16 -1
  32. package/lib/managePlane.js +955 -65
  33. package/lib/managePreflight.d.ts +26 -0
  34. package/lib/managePreflight.js +211 -0
  35. package/lib/manageProbe.d.ts +52 -0
  36. package/lib/manageProbe.js +171 -1
  37. package/lib/queueCore.d.ts +14 -1
  38. package/lib/queueCore.js +13 -0
  39. package/lib/queueLock.js +19 -10
  40. package/lib/queueResurrect.d.ts +7 -5
  41. package/lib/queueResurrect.js +25 -9
  42. package/lib/queueRetry.d.ts +12 -10
  43. package/lib/queueRetry.js +2 -4
  44. package/lib/queueSidecar.d.ts +122 -1
  45. package/lib/queueSidecar.js +192 -7
  46. package/lib/queueSubmit.d.ts +70 -4
  47. package/lib/queueSubmit.js +159 -7
  48. package/lib/runsErrorCodes.js +5 -3
  49. package/lib/runsExecute.d.ts +16 -1
  50. package/lib/runsExecute.js +97 -39
  51. package/lib/runsGates.d.ts +16 -4
  52. package/lib/runsGates.js +17 -5
  53. package/lib/runsList.d.ts +100 -4
  54. package/lib/runsList.js +364 -63
  55. package/lib/runsRefusalVoices.js +50 -1
  56. package/lib/runsRegistry.d.ts +142 -9
  57. package/lib/runsRegistry.js +960 -163
  58. package/lib/runsStart.d.ts +30 -7
  59. package/lib/runsStart.js +136 -14
  60. package/lib/runsTypes.d.ts +46 -3
  61. package/lib/runsTypes.js +63 -9
  62. package/lib/runsValidate.d.ts +1 -0
  63. package/lib/runsValidate.js +5 -0
  64. package/lib/runsValidateArms.js +25 -0
  65. package/lib/runsValidateServe.js +25 -12
  66. package/lib/runsValidateShared.d.ts +8 -1
  67. package/lib/runsValidateShared.js +44 -4
  68. package/lib/runsValidateStages.d.ts +1 -1
  69. package/lib/runsValidateStages.js +107 -55
  70. package/lib/runtimeProvision.d.ts +119 -0
  71. package/lib/runtimeProvision.js +243 -0
  72. package/lib/skillAuthored.d.ts +50 -0
  73. package/lib/skillAuthored.js +178 -0
  74. package/lib/skillPlane.d.ts +40 -2
  75. package/lib/skillPlane.js +63 -13
  76. package/lib/skillRegistry.d.ts +24 -1
  77. package/lib/skillRegistry.js +69 -5
  78. package/lib/skillRows.d.ts +13 -3
  79. package/lib/skillRows.js +49 -5
  80. package/package.json +33 -23
  81. package/lib/resurrect.d.ts +0 -6
  82. package/lib/resurrect.js +0 -18
package/lib/filmLead.js CHANGED
@@ -6,9 +6,11 @@
6
6
  // is the one pure, filesystem-free decision the gallery needs:
7
7
  // when the engine composed the film itself, the film leads the
8
8
  // names.
9
- /** The ENGINE FILM artifact — the in-graph assembly's output
10
- * (SaveVideo prefix h3_t4_film + ComfyUI's counter suffix). */
11
- const ENGINE_FILM_RE = /(?:^|\/)h3_t4_film_\d+_\.mp4$/;
9
+
10
+
11
+
12
+
13
+ const ENGINE_FILM_RE = /(?:^|[/_])h3_t4_film_\d+_\.mp4$/;
12
14
  /** The engine-composed film's name among a stage's artifacts, if
13
15
  * any — presentation order only, never composition. */
14
16
  export function engineFilmName(names) {
@@ -43,17 +43,31 @@ export interface RegistryStage {
43
43
  } | null;
44
44
  readonly fromFlow: RegistryFromFlow | null;
45
45
  }
46
- /** The compile-time initial kinds (flow.initial_validators). */
47
- export type RegistryInitialKind = "photo" | "glb" | "bake_params" | "text";
48
- /** One headless-tool overlay (FlowToolOverlay: tool param -> the
49
- * stage doc path it stamps, with the value choices map). */
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+ export type RegistryInitialKind = "photo" | "video" | "glb" | "bake_params" | "text" | "brief" | "number" | "json";
57
+ /** The extracted initial value (F58): strings for the name/file
58
+ * kinds, NUMBERS for number, OBJECTS for json — the run row's
59
+ * initials record is EngineJson-shaped, so the typed values ride to
60
+ * the engine merge unchanged. */
61
+ export type ExtractedInitial = string | number | Record<string, unknown>;
62
+ /** One flow-tool overlay (FlowToolOverlay: the run door's param ->
63
+ * the stage doc path it stamps, with the value choices map). */
50
64
  export interface RegistryToolOverlay {
51
65
  readonly param: string;
52
66
  readonly stage: string;
53
67
  readonly path: readonly string[];
54
68
  readonly choices: Record<string, string> | null;
55
69
  }
56
- /** One headless-tool property (FlowToolProperty). */
70
+ /** One flow-tool property (FlowToolProperty). */
57
71
  export interface RegistryToolProperty {
58
72
  readonly ptype: string;
59
73
  readonly description: string;
@@ -63,8 +77,9 @@ export interface RegistryToolProperty {
63
77
  readonly maximum: number | null;
64
78
  readonly enum: readonly string[] | null;
65
79
  }
66
- /** The headless surface (FlowTool: name + version + schema +
67
- * required + overlays). Absent (null) on flows with no tool=. */
80
+ /** The flow-tool surface (FlowTool: name + version + schema +
81
+ * required + overlays) — the run door's face for a registry flow.
82
+ * Absent (null) on flows with no tool=. */
68
83
  export interface RegistryTool {
69
84
  readonly name: string;
70
85
  readonly version: number;
@@ -89,6 +104,41 @@ export interface RegistryFlow {
89
104
  readonly tool: RegistryTool | null;
90
105
  readonly skillRefs: readonly string[];
91
106
  }
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ export declare function flowInitialKeys(flow: RegistryFlow): readonly string[];
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+ export declare function initialKindGloss(kind: RegistryInitialKind): string;
136
+ /** A flow's initial keys → glosses, the same derivation order the
137
+ * validators hold (the bundle's initials record rides both so the
138
+ * open face renders kinds and shapes from one truth).
139
+ * @param flow the registry row
140
+ * @returns the gloss per declared initial key */
141
+ export declare function flowInitialGlosses(flow: RegistryFlow): Record<string, string>;
92
142
  export declare function initial(key: string): RegistryInitialEdge;
93
143
  export declare function fromStage(stage: string, output: string): RegistryStageEdge;
94
144
  export declare function plainStage(row: {
@@ -198,19 +248,25 @@ export declare function initialFileCandidates(raw: string, roots: InitialsRoots)
198
248
  * passes (absent initials ride — the $channel/branch arms own
199
249
  * them). Runs BEFORE any run registers, on both doors. */
200
250
  export declare function registryInitialsError(flow: RegistryFlow, body: Record<string, unknown>, roots: InitialsRoots): string | null;
201
- /** The initial VALUE one gate-blessed body entry carries, in the
202
- * string form the engine merge links a $spell against: file
203
- * initials give their path ({path: …} unwraps — the two spellings
204
- * the gate blesses), bake_params gives its params_json string
205
- * (objects stringify — the dialect the belt validates). Null
206
- * refuses a shape the gate would have refused, so a mangled
207
- * durable body fails loud at the door instead of shipping an
208
- * "[object Object]" literal to the engine.
209
- * @param key the initial's declared name, for the refusal voice
210
- * @param kind the declared validator kind
211
- * @param value the raw body entry
212
- * @returns the normalized string, or null when the shape is neither */
213
- export declare function normalizedInitialValue(key: string, kind: RegistryInitialKind, value: unknown): string | null;
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+ export declare function normalizedInitialValue(key: string, kind: RegistryInitialKind, value: unknown): ExtractedInitial | null;
214
270
  /** The request initials a body carries for a flow's declared
215
271
  * validators, normalized per {@link normalizedInitialValue}:
216
272
  * declared keys, present values only; absent stays absent (the
@@ -225,7 +281,7 @@ export declare function normalizedInitialValue(key: string, kind: RegistryInitia
225
281
  * @param body the request body
226
282
  * @returns the normalized initials record, or a refusal string */
227
283
  export declare function extractRequestInitials(flow: RegistryFlow, body: Record<string, unknown>): {
228
- initials: Record<string, string>;
284
+ initials: Record<string, ExtractedInitial>;
229
285
  } | {
230
286
  refusal: string;
231
287
  };
package/lib/flowsData.js CHANGED
@@ -22,6 +22,68 @@ import { CARD_PLANE_ENGINE, LEGACY_RUN_MEDIA_PREFIX, RUN_MEDIA_PREFIX } from "@m
22
22
  import { join, resolve } from "node:path";
23
23
  import { mediaVocab } from "./mediaKinds.js";
24
24
  import { validateBakeParams } from "./bakeParams.js";
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ export function flowInitialKeys(flow) {
37
+ const required = flow.requiredInitials ?? [];
38
+ const optional = Object.keys(flow.initialValidators).filter((k) => !required.includes(k));
39
+ return [...required, ...optional];
40
+ }
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ export function initialKindGloss(kind) {
58
+ switch (kind) {
59
+ case "bake_params":
60
+ return "the preset dialect doc {dialect: 'authored'|'estimated', phenotype: number[11 authored|6 estimated], local_changes?: {morph: number} (authored) | scale: number[139] (estimated)} — send the doc as a JSON OBJECT, never a hand-typed string";
61
+ case "photo":
62
+ case "video":
63
+ case "glb":
64
+ return "file path (or {path})";
65
+ case "text":
66
+ return "bare name";
67
+ case "brief":
68
+ return "non-empty prose";
69
+ case "number":
70
+ return "finite JSON number";
71
+ case "json":
72
+ return "JSON object (or its string spelling)";
73
+ }
74
+ }
75
+ /** A flow's initial keys → glosses, the same derivation order the
76
+ * validators hold (the bundle's initials record rides both so the
77
+ * open face renders kinds and shapes from one truth).
78
+ * @param flow the registry row
79
+ * @returns the gloss per declared initial key */
80
+ export function flowInitialGlosses(flow) {
81
+ const out = {};
82
+ for (const [key, kind] of Object.entries(flow.initialValidators)) {
83
+ out[key] = initialKindGloss(kind);
84
+ }
85
+ return out;
86
+ }
25
87
  // ── shared builders ─────────────────────────────────────────────
26
88
  export function initial(key) {
27
89
  return { initial: key };
@@ -81,18 +143,15 @@ export function linkedStage(flow, stage, id, inputs) {
81
143
  * (default unlimited), inputs (the plus-box list). The stage
82
144
  * params carry those fields at DRIVE time; the registry row is
83
145
  * the template + the agent leaf. */
84
- import { BODY_TO_SOMAX, ANNY_HMR_ESTIMATOR, ANNY_PARAMS, AUDIO_NATIVE_TTS, CHARACTER_FACTORY, FIT_SEAT, IMAGE_UPSCALE, MUSIC_NATIVE, CRAFT_LOOP, OBJECT_FORGE, } from "./flowsRegistryRows.js";
146
+ import { ANNY_HMR_ESTIMATOR, ANNY_PARAMS, CHARACTER_FACTORY, FIT_SEAT, IMAGE_UPSCALE, CRAFT_LOOP, OBJECT_FORGE, } from "./flowsRegistryRows.js";
85
147
  import { Service } from "@deepseek-ai/cordis";
86
148
  const REGISTRY = {
87
149
  "craft-loop": CRAFT_LOOP,
88
150
  "anny-hmr-estimator": ANNY_HMR_ESTIMATOR,
89
- "body-to-somax": BODY_TO_SOMAX,
90
151
  "character-factory": CHARACTER_FACTORY,
91
152
  "anny-params": ANNY_PARAMS,
92
- "audio-native-tts": AUDIO_NATIVE_TTS,
93
153
  "fit-seat": FIT_SEAT,
94
154
  "image-upscale": IMAGE_UPSCALE,
95
- "music-native": MUSIC_NATIVE,
96
155
  "object-forge": OBJECT_FORGE,
97
156
  };
98
157
  /** A pure read-only seat over the boot seed (REGISTRY verbatim, no
@@ -386,12 +445,15 @@ function checkFileInitial(key, kind, value, roots) {
386
445
  ? raw.split(/[?#]/)[0].slice(dot + 1).toLowerCase()
387
446
  : "";
388
447
  // The vocab is TYPED DATA now (mediaKinds.ts, REBUILD-7) — no
389
- // repo-anchored kindsPath read survives the re-home.
448
+ // repo-anchored kindsPath read survives the re-home. The video
449
+ // kind rides the same vocab's video list (a prior-clip initial —
450
+ // mp4/webm/mkv/mov/m4v/avi; born on the retired extend-video
451
+ // wrapper).
390
452
  const kinds = mediaVocab();
391
- const allowed = kind === "photo" ? kinds.image : kinds.model;
453
+ const allowed = kind === "photo" ? kinds.image : kind === "video" ? kinds.video : kinds.model;
392
454
  if (!allowed.includes(ext)) {
393
455
  return ("initial " + JSON.stringify(key) + " is not a stageable " +
394
- (kind === "photo" ? "image" : "mesh") + " (got extension " +
456
+ (kind === "photo" ? "image" : kind === "video" ? "video" : "mesh") + " (got extension " +
395
457
  JSON.stringify(ext) + ")");
396
458
  }
397
459
  if (raw.includes("..")) {
@@ -502,6 +564,50 @@ export function registryInitialsError(flow, body, roots) {
502
564
  }
503
565
  continue;
504
566
  }
567
+ // A BRIEF initial is PROSE (F58, the craft-loop binding): the
568
+ // brief is data a critique loop reads — no file door ever opens
569
+ // it, so the path law that guards names would mis-refuse honest
570
+ // prose ("a 3/4 view poster"). The door judges emptiness only;
571
+ // length and sense are the critic's problem.
572
+ if (kind === "brief") {
573
+ if (typeof value !== "string" || value.trim() === "") {
574
+ return "initial " + JSON.stringify(key) +
575
+ " must be a non-empty brief (got " + (typeof value) + ")";
576
+ }
577
+ continue;
578
+ }
579
+ // A NUMBER initial is a finite JSON number (F58): digit-strings
580
+ // REFUSE — the caller sent JSON, and a silent fold would mask the
581
+ // caller's shape bug until the engine's own numeric gate refused
582
+ // it with a stranger's voice.
583
+ if (kind === "number") {
584
+ if (typeof value !== "number" || !Number.isFinite(value)) {
585
+ return "initial " + JSON.stringify(key) +
586
+ " must be a finite number (got " + (typeof value) + " — send JSON numbers, not strings)";
587
+ }
588
+ continue;
589
+ }
590
+ // A JSON initial is an object or its JSON-string spelling (F58):
591
+ // the door judges parseability + objectness only — the consuming
592
+ // engine's gate owns the inner shape (craft's command row:
593
+ // {engine, params}, refused by the engine's own LOUD voice).
594
+ if (kind === "json") {
595
+ let v = value;
596
+ if (typeof v === "string") {
597
+ try {
598
+ v = JSON.parse(v);
599
+ }
600
+ catch {
601
+ return "initial " + JSON.stringify(key) +
602
+ " is a JSON string that does not parse";
603
+ }
604
+ }
605
+ if (typeof v !== "object" || v === null || Array.isArray(v)) {
606
+ return "initial " + JSON.stringify(key) +
607
+ " must be a JSON object or its string spelling (got " + (typeof value) + ")";
608
+ }
609
+ continue;
610
+ }
505
611
  const err = checkFileInitial(key, kind, value, roots);
506
612
  if (err !== null)
507
613
  return err;
@@ -523,18 +629,24 @@ export function registryInitialsError(flow, body, roots) {
523
629
  }
524
630
  return null;
525
631
  }
526
- /** The initial VALUE one gate-blessed body entry carries, in the
527
- * string form the engine merge links a $spell against: file
528
- * initials give their path ({path: …} unwraps — the two spellings
529
- * the gate blesses), bake_params gives its params_json string
530
- * (objects stringify — the dialect the belt validates). Null
531
- * refuses a shape the gate would have refused, so a mangled
532
- * durable body fails loud at the door instead of shipping an
533
- * "[object Object]" literal to the engine.
534
- * @param key the initial's declared name, for the refusal voice
535
- * @param kind the declared validator kind
536
- * @param value the raw body entry
537
- * @returns the normalized string, or null when the shape is neither */
632
+
633
+
634
+
635
+
636
+
637
+
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
538
650
  export function normalizedInitialValue(key, kind, value) {
539
651
  // A TEXT initial is a BARE NAME: nothing unwraps it and nothing
540
652
  // path-shaped reaches it, so the {path: …} arm below never runs
@@ -543,6 +655,26 @@ export function normalizedInitialValue(key, kind, value) {
543
655
  // first — this arm makes the extractor honest on its own.)
544
656
  if (kind === "text")
545
657
  return typeof value === "string" ? value : null;
658
+ if (kind === "brief")
659
+ return typeof value === "string" && value.trim() !== "" ? value : null;
660
+ if (kind === "number")
661
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
662
+ if (kind === "json") {
663
+ if (typeof value === "string") {
664
+ try {
665
+ const parsed = JSON.parse(value);
666
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
667
+ ? parsed
668
+ : null;
669
+ }
670
+ catch {
671
+ return null;
672
+ }
673
+ }
674
+ return typeof value === "object" && value !== null && !Array.isArray(value)
675
+ ? value
676
+ : null;
677
+ }
546
678
  if (typeof value === "string")
547
679
  return value;
548
680
  if (kind === "bake_params") {
@@ -585,8 +717,14 @@ export function extractRequestInitials(flow, body) {
585
717
  (typeof value) + ")"
586
718
  : kind === "text"
587
719
  ? " must be a bare name (got " + (typeof value) + ")"
588
- : " must be a file path string or {path: ...} (got " +
589
- (typeof value) + ")"),
720
+ : kind === "brief"
721
+ ? " must be a non-empty brief (got " + (typeof value) + ")"
722
+ : kind === "number"
723
+ ? " must be a finite number (got " + (typeof value) + " — send JSON numbers, not strings)"
724
+ : kind === "json"
725
+ ? " must be a JSON object or its string spelling (got " + (typeof value) + ")"
726
+ : " must be a file path string or {path: ...} (got " +
727
+ (typeof value) + ")"),
590
728
  };
591
729
  }
592
730
  initials[key] = normalized;
@@ -158,12 +158,23 @@ function composeOne(flowId, st, decls, seatState) {
158
158
  if (firstOutput !== undefined) {
159
159
  producer[firstOutput.name] = handle.nodeId;
160
160
  }
161
+ // THE VRAM BUDGET RIDES THE DECLARATION ("ComfyUI should prevent
162
+
163
+ // VRAM auto): an action that declares vramBudgetMb stamps its
164
+ // composed stage's params with the raw knob — the same channel
165
+ // timeout_s reads — and the execute door gates on it (prove
166
+ // headroom or refuse loud; never a mid-run OOM, never a /free).
167
+ // Stamped ONLY when declared: actions without a budget keep the
168
+ // envelope byte-identical (no key, no gate, no traffic).
169
+ const vramBudget = action.vramBudgetMb;
161
170
  return {
162
171
  ...st,
163
172
  family: "",
164
173
  action: "",
165
174
  outputs: derived,
166
- params: { workflow: g.toJSON(), output_nodes: producer },
175
+ params: vramBudget === undefined
176
+ ? { workflow: g.toJSON(), output_nodes: producer }
177
+ : { workflow: g.toJSON(), output_nodes: producer, vram_budget_mb: vramBudget },
167
178
  };
168
179
  }
169
180
  /** Compose every family-action stage of an expanded flow into its
@@ -1,11 +1,8 @@
1
1
  import type { RegistryFlow } from "./flowsData.js";
2
2
  export declare const ANNY_HMR_ESTIMATOR: RegistryFlow;
3
3
  export declare const ANNY_PARAMS: RegistryFlow;
4
- export declare const AUDIO_NATIVE_TTS: RegistryFlow;
5
- export declare const BODY_TO_SOMAX: RegistryFlow;
6
4
  export declare const FIT_SEAT: RegistryFlow;
7
5
  export declare const IMAGE_UPSCALE: RegistryFlow;
8
- export declare const MUSIC_NATIVE: RegistryFlow;
9
6
  export declare const CRAFT_LOOP: RegistryFlow;
10
7
  export declare const CHARACTER_FACTORY: RegistryFlow;
11
8
  export declare const OBJECT_FORGE: RegistryFlow;