@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.
Files changed (129) hide show
  1. package/LICENSE +557 -0
  2. package/lib/bakeParams.d.ts +17 -0
  3. package/lib/bakeParams.js +182 -0
  4. package/lib/bench.d.ts +24 -0
  5. package/lib/bench.js +121 -0
  6. package/lib/cardsArmError.d.ts +18 -0
  7. package/lib/cardsArmError.js +33 -0
  8. package/lib/cardsCompose.d.ts +41 -0
  9. package/lib/cardsCompose.js +247 -0
  10. package/lib/cardsDangling.d.ts +16 -0
  11. package/lib/cardsDangling.js +168 -0
  12. package/lib/cardsFacts.d.ts +74 -0
  13. package/lib/cardsFacts.js +64 -0
  14. package/lib/cardsLanes.d.ts +33 -0
  15. package/lib/cardsLanes.js +115 -0
  16. package/lib/cardsRegistry.d.ts +316 -0
  17. package/lib/cardsRegistry.js +1274 -0
  18. package/lib/cardsVariant.d.ts +28 -0
  19. package/lib/cardsVariant.js +190 -0
  20. package/lib/discloseRegistry.d.ts +94 -0
  21. package/lib/discloseRegistry.js +154 -0
  22. package/lib/filmLead.d.ts +4 -0
  23. package/lib/filmLead.js +17 -0
  24. package/lib/filmMemoryWarn.d.ts +27 -0
  25. package/lib/filmMemoryWarn.js +99 -0
  26. package/lib/flowsData.d.ts +179 -0
  27. package/lib/flowsData.js +547 -0
  28. package/lib/flowsFamilyCompose.d.ts +48 -0
  29. package/lib/flowsFamilyCompose.js +191 -0
  30. package/lib/flowsRegistryRows.d.ts +10 -0
  31. package/lib/flowsRegistryRows.js +378 -0
  32. package/lib/index.d.ts +50 -0
  33. package/lib/index.js +66 -0
  34. package/lib/ledgerTail.d.ts +20 -0
  35. package/lib/ledgerTail.js +123 -0
  36. package/lib/loadPlane.d.ts +93 -0
  37. package/lib/loadPlane.js +553 -0
  38. package/lib/loadRegistry.d.ts +22 -0
  39. package/lib/loadRegistry.js +55 -0
  40. package/lib/manageOps.d.ts +21 -0
  41. package/lib/manageOps.js +142 -0
  42. package/lib/managePlane.d.ts +120 -0
  43. package/lib/managePlane.js +1515 -0
  44. package/lib/manageProbe.d.ts +57 -0
  45. package/lib/manageProbe.js +154 -0
  46. package/lib/manageRegistry.d.ts +28 -0
  47. package/lib/manageRegistry.js +75 -0
  48. package/lib/managerRail.d.ts +33 -0
  49. package/lib/managerRail.js +91 -0
  50. package/lib/mediaKinds.d.ts +3 -0
  51. package/lib/mediaKinds.js +2 -0
  52. package/lib/queue.d.ts +9 -0
  53. package/lib/queue.js +76 -0
  54. package/lib/queueCore.d.ts +69 -0
  55. package/lib/queueCore.js +124 -0
  56. package/lib/queueLifecycle.d.ts +26 -0
  57. package/lib/queueLifecycle.js +65 -0
  58. package/lib/queueLock.d.ts +54 -0
  59. package/lib/queueLock.js +195 -0
  60. package/lib/queueResurrect.d.ts +59 -0
  61. package/lib/queueResurrect.js +249 -0
  62. package/lib/queueRetry.d.ts +36 -0
  63. package/lib/queueRetry.js +24 -0
  64. package/lib/queueSidecar.d.ts +145 -0
  65. package/lib/queueSidecar.js +182 -0
  66. package/lib/queueSubmit.d.ts +31 -0
  67. package/lib/queueSubmit.js +117 -0
  68. package/lib/queueSweep.d.ts +30 -0
  69. package/lib/queueSweep.js +121 -0
  70. package/lib/resurrect.d.ts +6 -0
  71. package/lib/resurrect.js +18 -0
  72. package/lib/rootsManifest.d.ts +11 -0
  73. package/lib/rootsManifest.js +11 -0
  74. package/lib/runStatus.d.ts +7 -0
  75. package/lib/runStatus.js +21 -0
  76. package/lib/runsChange.d.ts +53 -0
  77. package/lib/runsChange.js +63 -0
  78. package/lib/runsErrorCodes.d.ts +2 -0
  79. package/lib/runsErrorCodes.js +15 -0
  80. package/lib/runsExecute.d.ts +26 -0
  81. package/lib/runsExecute.js +356 -0
  82. package/lib/runsGates.d.ts +161 -0
  83. package/lib/runsGates.js +306 -0
  84. package/lib/runsList.d.ts +78 -0
  85. package/lib/runsList.js +580 -0
  86. package/lib/runsRefusalVoices.d.ts +9 -0
  87. package/lib/runsRefusalVoices.js +44 -0
  88. package/lib/runsRegistry.d.ts +253 -0
  89. package/lib/runsRegistry.js +1750 -0
  90. package/lib/runsSourceEcho.d.ts +54 -0
  91. package/lib/runsSourceEcho.js +275 -0
  92. package/lib/runsStart.d.ts +121 -0
  93. package/lib/runsStart.js +528 -0
  94. package/lib/runsTypes.d.ts +183 -0
  95. package/lib/runsTypes.js +282 -0
  96. package/lib/runsValidate.d.ts +5 -0
  97. package/lib/runsValidate.js +31 -0
  98. package/lib/runsValidateArms.d.ts +7 -0
  99. package/lib/runsValidateArms.js +285 -0
  100. package/lib/runsValidateInline.d.ts +6 -0
  101. package/lib/runsValidateInline.js +82 -0
  102. package/lib/runsValidateRefusals.d.ts +7 -0
  103. package/lib/runsValidateRefusals.js +18 -0
  104. package/lib/runsValidateServe.d.ts +15 -0
  105. package/lib/runsValidateServe.js +254 -0
  106. package/lib/runsValidateShared.d.ts +84 -0
  107. package/lib/runsValidateShared.js +88 -0
  108. package/lib/runsValidateStages.d.ts +25 -0
  109. package/lib/runsValidateStages.js +491 -0
  110. package/lib/runsValidateSweeps.d.ts +6 -0
  111. package/lib/runsValidateSweeps.js +143 -0
  112. package/lib/service.d.ts +45 -0
  113. package/lib/service.js +81 -0
  114. package/lib/skillFrontmatter.d.ts +11 -0
  115. package/lib/skillFrontmatter.js +46 -0
  116. package/lib/skillFs.d.ts +19 -0
  117. package/lib/skillFs.js +80 -0
  118. package/lib/skillPlane.d.ts +98 -0
  119. package/lib/skillPlane.js +263 -0
  120. package/lib/skillRegistry.d.ts +23 -0
  121. package/lib/skillRegistry.js +55 -0
  122. package/lib/skillRows.d.ts +126 -0
  123. package/lib/skillRows.js +466 -0
  124. package/lib/toolProjection.d.ts +30 -0
  125. package/lib/toolProjection.js +142 -0
  126. package/lib/vocab.d.ts +6 -0
  127. package/lib/vocab.js +18 -0
  128. package/package.json +47 -4
  129. package/README.md +0 -3
@@ -0,0 +1,28 @@
1
+ import type { CardDeclRow, ModelFactsRow } from "./cardsFacts.js";
2
+ /** One closed [min, max] bound on a stated sampler knob. */
3
+ export type EnvelopeBound = readonly [number, number];
4
+ export interface VariantSelection {
5
+ readonly variantId: string;
6
+ readonly variantRoute: string;
7
+ readonly quant: string;
8
+ readonly resolverDefaults: Record<string, unknown>;
9
+ /** THE ROUTE ENVELOPE (the 25-steps-into-turbo cure): when the
10
+ * selected variant declares one, a caller-STATED steps/cfg
11
+ * outside its closed bounds refuses at the stamp gate — the
12
+ * distilled lane's marriage is not agency territory. */
13
+ readonly samplerEnvelope: Readonly<Record<"steps" | "cfg", EnvelopeBound | undefined>> | null;
14
+ }
15
+ /** Select the matrix cell (R1 wire contract): explicit body
16
+ * variant/quant keys win when stated (matched against facts
17
+ * variant id/route + cell quant); unstated coordinates fall to
18
+ * the FIRST non-Recipe variant / first cell (Model.resolve —
19
+ * the family default). Unknown coordinates refuse LOUD (never a
20
+ * silent neighbor cell). */
21
+ export declare function selectCardVariant(mid: string, famRow: ModelFactsRow, body: Record<string, unknown>, phase: string): VariantSelection;
22
+ export declare function stampCardOverlay(body: Record<string, unknown>, famRow: ModelFactsRow, decl: CardDeclRow, sel: VariantSelection, phase: string): Record<string, unknown>;
23
+ /** The card-compose lift (card_compose_body 363-372): the run body
24
+ * minus the gateway envelope, restaged as the ONE params stanza.
25
+ * variant/quant ride the R1 contract (consumed at selection, never
26
+ * params — no card declares knobs by those names). */
27
+ export declare function liftCardParams(body: Record<string, unknown>): Record<string, unknown>;
28
+ //# sourceMappingURL=cardsVariant.d.ts.map
@@ -0,0 +1,190 @@
1
+ import { samplerEnvelopeCure } from "@melite/contracts/laneRelations";
2
+ import { EnvelopeRefusal, phaseRefusal } from "./cardsArmError.js";
3
+ import { judgeSamplerEnvelope, unknownQuantVoice, unknownVariantVoice } from "@melite/contracts/laneRelations";
4
+ import { CARD_ENVELOPE_KEYS } from "./cardsRegistry.js";
5
+ /** Normalize a facts variant's sampler_envelope declaration (the
6
+ * DECL authors it as {steps?: [min,max], cfg?: [min,max]}); junk
7
+ * shapes contribute nothing (never a crash). */
8
+ function normalizeEnvelope(raw) {
9
+ if (raw === null || typeof raw !== "object")
10
+ return null;
11
+ const r = raw;
12
+ const bound = (v) => {
13
+ if (!Array.isArray(v) || v.length !== 2)
14
+ return undefined;
15
+ const [a, b] = v;
16
+ return typeof a === "number" && typeof b === "number" && b >= a ? [a, b] : undefined;
17
+ };
18
+ const steps = bound(r.steps);
19
+ const cfg = bound(r.cfg);
20
+ return steps === undefined && cfg === undefined ? null : { steps, cfg };
21
+ }
22
+ function knownVariantIds(row) {
23
+ return (row.variants ?? []).map((v) => v.id);
24
+ }
25
+ /** Select the matrix cell (R1 wire contract): explicit body
26
+ * variant/quant keys win when stated (matched against facts
27
+ * variant id/route + cell quant); unstated coordinates fall to
28
+ * the FIRST non-Recipe variant / first cell (Model.resolve —
29
+ * the family default). Unknown coordinates refuse LOUD (never a
30
+ * silent neighbor cell). */
31
+ export function selectCardVariant(mid, famRow, body, phase) {
32
+ const variants = famRow.variants ?? [];
33
+ const offered = variants.filter((v) => v.hide_from_dropdown !== true);
34
+ const hiddenRoute = variants.find((v) => v.hide_from_dropdown === true && (v.route === mid || v.id === mid || (v.cells ?? []).some((c) => c.route === mid)));
35
+ const hiddenCellRoute = variants.some((v) => (v.cells ?? []).some((c) => c.hide_from_dropdown === true && c.route === mid));
36
+ if (hiddenRoute !== undefined || hiddenCellRoute) {
37
+ throw phaseRefusal(phase, "model " + JSON.stringify(mid) +
38
+ " is not offered (the variant route is hidden from the dropdown)");
39
+ }
40
+ const configured = offered.filter((v) => v.group !== "Recipe");
41
+ const pool = configured.length > 0 ? configured : offered;
42
+ if (pool.length === 0 && variants.length > 0) {
43
+ throw phaseRefusal(phase, "model " + JSON.stringify(mid) + " has no offered variants");
44
+ }
45
+ const rawVariant = body["variant"];
46
+ const rawQuant = body["quant"];
47
+ let variant;
48
+ if (rawVariant === undefined || rawVariant === null) {
49
+ variant = pool[0];
50
+ }
51
+ else {
52
+ if (typeof rawVariant !== "string") {
53
+ throw phaseRefusal(phase, "variant must be a string (got " +
54
+ (Array.isArray(rawVariant) ? "list" : typeof rawVariant) + ")");
55
+ }
56
+ const requested = variants.find((v) => v.id === rawVariant || v.route === rawVariant);
57
+ if (requested?.hide_from_dropdown === true) {
58
+ throw phaseRefusal(phase, "variant " + JSON.stringify(rawVariant) +
59
+ " is not offered for model " + JSON.stringify(mid));
60
+ }
61
+ variant = offered.find((v) => v.id === rawVariant || v.route === rawVariant);
62
+ if (variant === undefined) {
63
+ throw phaseRefusal(phase, unknownVariantVoice(rawVariant, mid, knownVariantIds(famRow)));
64
+ }
65
+ }
66
+ let quant = "";
67
+ if (rawQuant !== undefined && rawQuant !== null) {
68
+ if (typeof rawQuant !== "string") {
69
+ throw phaseRefusal(phase, "quant must be a string (got " +
70
+ (Array.isArray(rawQuant) ? "list" : typeof rawQuant) + ")");
71
+ }
72
+ const cells = variant !== undefined
73
+ ? (variant.cells ?? []).filter((c) => c.hide_from_dropdown !== true)
74
+ : [];
75
+ const hit = cells.find((c) => c.quant === rawQuant);
76
+ if (hit === undefined) {
77
+ throw phaseRefusal(phase, unknownQuantVoice(rawQuant, mid, variant !== undefined ? variant.id : "", cells.map((c) => c.quant)));
78
+ }
79
+ quant = hit.quant;
80
+ }
81
+ else if (variant !== undefined) {
82
+ const cells = (variant.cells ?? []).filter((c) => c.hide_from_dropdown !== true);
83
+ if (cells.length > 0)
84
+ quant = String(cells[0]?.quant ?? "");
85
+ }
86
+ return {
87
+ variantId: variant !== undefined ? variant.id : "",
88
+ variantRoute: variant !== undefined ? String(variant.route ?? "") : "",
89
+ quant,
90
+ resolverDefaults: variant !== undefined ? { ...(variant.resolver_defaults ?? {}) } : {},
91
+ samplerEnvelope: variant !== undefined
92
+ ? normalizeEnvelope(variant.sampler_envelope)
93
+ : null,
94
+ };
95
+ }
96
+ /** The route-lens stamp overlay (_route_stamp_overlay 705-751):
97
+ * family defaults + the selected variant's resolver_defaults,
98
+ * injected ONLY for absent keys, filtered to the owning card's
99
+ * field surface (schema keys + admits, exact or trailing-*
100
+ * prefix). None/"" stamps never ride (UNSET markers — riding
101
+ * them would refuse the str fields the row leaves open).
102
+ * variant/quant contract keys are CONSUMED (never ride compose —
103
+ * no card declares them). Returns the STAMPED body (a copy). */
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ function envelopeRefusal(body, sel, phase) {
112
+
113
+ // in @melite/contracts beside the lane judges; the door adds what
114
+ // its seat knows — the phase-consistent frame, the marriage
115
+ // clause, the lane-read tail.
116
+ const off = judgeSamplerEnvelope(body, sel.samplerEnvelope, {
117
+ id: sel.variantId,
118
+ route: sel.variantRoute,
119
+ });
120
+ if (off === null)
121
+ return;
122
+ const married = sel.resolverDefaults[off.knob] ?? "";
123
+ throw new EnvelopeRefusal(400, "card_compose phase " + phase + ": " + off.voice +
124
+ (married !== "" ? " and the lane is married to " + off.knob + " " + String(married) : "") +
125
+ ". " + samplerEnvelopeCure() +
126
+ " (Read the family lane: melite_skill_read model:<family>.)", "card_compose");
127
+ }
128
+ export function stampCardOverlay(body, famRow, decl, sel, phase) {
129
+ envelopeRefusal(body, sel, phase);
130
+ const stamps = { ...(famRow.defaults ?? {}) };
131
+ for (const [k, v] of Object.entries(sel.resolverDefaults))
132
+ stamps[k] = v;
133
+ const names = new Set(decl.schemaNames);
134
+ const admits = decl.admits;
135
+ const onSurface = (k) => {
136
+ if (names.has(k))
137
+ return true;
138
+ return admits.some((a) => a === k || (a.endsWith("*") && k.startsWith(a.slice(0, -1))));
139
+ };
140
+ const out = { ...body };
141
+ for (const [k, v] of Object.entries(stamps)) {
142
+ if (v === null || v === undefined || v === "")
143
+ continue;
144
+ if (!onSurface(k))
145
+ continue;
146
+ if (k in out)
147
+ continue;
148
+ if (CARD_ENVELOPE_KEYS.includes(k))
149
+ continue;
150
+ out[k] = v;
151
+ }
152
+ return out;
153
+ }
154
+ /** The card-compose lift (card_compose_body 363-372): the run body
155
+ * minus the gateway envelope, restaged as the ONE params stanza.
156
+ * variant/quant ride the R1 contract (consumed at selection, never
157
+ * params — no card declares knobs by those names). */
158
+ export function liftCardParams(body) {
159
+ const params = {};
160
+ for (const [k, v] of Object.entries(body)) {
161
+ if (CARD_ENVELOPE_KEYS.includes(k))
162
+ continue;
163
+ if (k === "variant" || k === "quant")
164
+ continue;
165
+
166
+ // BROKEN-B follow-on): the run body's `params` dict IS the stanza
167
+ // (liftStanza merges it over its siblings at compose), so the
168
+ // lane's view must unwrap it the same way — it did not, and a
169
+ // `{model, params:{…}}` body reached the undeclared-key gate
170
+ // still carrying a `params` key. Two lifts of one shape is how
171
+ // the bench and the compose disagreed about what a card sees.
172
+ if (k === "params" && typeof v === "object" && v !== null && !Array.isArray(v)) {
173
+ // SIBLINGS WIN — the stanza fills what they leave out
174
+
175
+ // LAST, so `{text: "sibling", params: {text: "inner"}}` resolved
176
+ // by key ORDER — the inner text won on one lift and the sibling
177
+ // on the other. liftStanza is explicit that siblings override the
178
+ // stanza; the "ONE SPELLING" claim is only true once this
179
+ // matches it.)
180
+ for (const [ik, iv] of Object.entries(v)) {
181
+ if (!(ik in params))
182
+ params[ik] = iv;
183
+ }
184
+ continue;
185
+ }
186
+ params[k] = v;
187
+ }
188
+ return params;
189
+ }
190
+ //# sourceMappingURL=cardsVariant.js.map
@@ -0,0 +1,94 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ import type { Context } from "@deepseek-ai/cordis";
3
+ /** One card summary (the routing layer — no bodies). */
4
+ export interface CardSummary {
5
+ readonly id: string;
6
+ readonly label: string;
7
+ readonly description: string;
8
+ readonly genre: string;
9
+ readonly tags: readonly string[];
10
+ }
11
+ /** One flow summary (the routing layer). */
12
+ export interface FlowSummary {
13
+ readonly name: string;
14
+ readonly title: string;
15
+ readonly description: string;
16
+ readonly stages: number;
17
+ readonly skillRefs: readonly string[];
18
+ }
19
+ /** The search surface a card def offers (the def itself satisfies
20
+ * this — structural, no import of the engine service). */
21
+ export interface SearchableCard {
22
+ readonly identity?: {
23
+ readonly label?: string;
24
+ readonly description?: string;
25
+ readonly genre?: string;
26
+ };
27
+ readonly tags?: readonly string[];
28
+ }
29
+ /** Search the card defs: the q tokens (whitespace-split,
30
+ * case-folded) ALL match (id + label + description + tags); the
31
+ * tags param (comma list) ALL match def.tags. Empty q + tags =
32
+ * all. */
33
+ export declare function searchCards(defs: ReadonlyMap<string, SearchableCard>, q: string, tags: string): CardSummary[];
34
+ /** Search the flow rows (PURE over the merged rows). */
35
+ export declare function searchFlows(rows: ReadonlyArray<FlowSummary>, q: string): FlowSummary[];
36
+ /** The flow rows: REGISTRY (the compile truth) merged with the
37
+ * flows/<name>/tool.json leaf (the agent face: stage_title). */
38
+ export declare function flowSummaryRows(repo: string): FlowSummary[];
39
+
40
+
41
+
42
+
43
+
44
+
45
+ export interface FlowContract {
46
+ readonly id: string;
47
+ readonly description: string;
48
+ readonly stages: ReadonlyArray<{
49
+ readonly id: string;
50
+ readonly engine: string;
51
+ readonly card: string;
52
+ readonly inputs: unknown;
53
+ readonly outputs: unknown;
54
+ readonly params: unknown;
55
+ }>;
56
+ readonly initialValidators: unknown;
57
+ readonly tool: unknown;
58
+ }
59
+ /** The contract rows, one per registry flow, in registry order. */
60
+ export declare function flowContractRows(): FlowContract[];
61
+ /** The disclosure service: ONE disclosure system over both planes.
62
+ * discover(lookup, q, tags) answers {flows?, cards?} — the door's
63
+ * combined body, live-derived. */
64
+ export declare class DiscloseDirectoryService extends Service {
65
+ static inject: string[];
66
+ constructor(ctx: Context);
67
+
68
+
69
+
70
+
71
+ contracts(): {
72
+ flows: FlowContract[];
73
+ };
74
+ /** GET /v1/discover: unknown
75
+ * lookup refuses with the door's own voice; the body carries the
76
+ * requested planes only. */
77
+ discover(lookup: string, q: string, tags: string): {
78
+ flows?: FlowSummary[];
79
+ cards?: CardSummary[];
80
+ };
81
+ }
82
+ /** The disclose row: mounts after the card-registry provider (its
83
+ * hard inject pends on the seat — the loader orders it). */
84
+ export declare const discloseProvider: {
85
+ name: string;
86
+ inject: readonly ["cardRegistry"];
87
+ apply(ctx: Context): void;
88
+ };
89
+ declare module "@deepseek-ai/cordis" {
90
+ interface Context {
91
+ disclose: DiscloseDirectoryService;
92
+ }
93
+ }
94
+ //# sourceMappingURL=discloseRegistry.d.ts.map
@@ -0,0 +1,154 @@
1
+
2
+ // Melite discover re-homed from the dead gateway's disclose door
3
+ // (doors/disclose.ts, killed with the gateway app). The pures port
4
+ // VERBATIM (searchCards / searchFlows / flowSummaryRows — the routing
5
+ // layer, no bodies); the door's HTTP shell dies, the seat answers.
6
+ //
7
+
8
+ // discover grants the progressive disclosure LINES (clamped summary
9
+ // rows — the tier the agent routes on); load opens ONE card or
10
+ // flow — that arm (agents md + tool-call signature + tier-1 skill
11
+ // lines over the melite_skill_index truth) is its own named stroke.
12
+ //
13
+ // QUEUE LANE LAW: no fallbacks (unknown lookup refuses with the
14
+ // door's voice), live derivation (flow rows from the registry at
15
+ // request time; card rows from the primed card registry — never a
16
+ // frozen blob).
17
+ //
18
+ // Erasable-syntax TS only (node --experimental-strip-types).
19
+ import { readFileSync } from "node:fs";
20
+ import { join } from "node:path";
21
+ import { Service } from "@deepseek-ai/cordis";
22
+ import { resolveRepoRoot } from "@melite/comfyui-cordis";
23
+ import { getRegistryFlow, registryFlowNames } from "./flowsData.js";
24
+ /** Search the card defs: the q tokens (whitespace-split,
25
+ * case-folded) ALL match (id + label + description + tags); the
26
+ * tags param (comma list) ALL match def.tags. Empty q + tags =
27
+ * all. */
28
+ export function searchCards(defs, q, tags) {
29
+ const toks = q.toLowerCase().split(/\s+/).filter((t) => t !== "");
30
+ const want = tags.toLowerCase().split(",").map((t) => t.trim()).filter((t) => t !== "");
31
+ const out = [];
32
+ for (const [id, def] of defs) {
33
+ const dtags = def.tags ?? [];
34
+ const low = dtags.map((x) => x.toLowerCase());
35
+ if (!want.every((t) => low.includes(t)))
36
+ continue;
37
+ const label = def.identity?.label ?? id;
38
+ const description = def.identity?.description ?? "";
39
+ const hay = (id + " " + label + " " + description + " " + dtags.join(" ")).toLowerCase();
40
+ if (!toks.every((t) => hay.includes(t)))
41
+ continue;
42
+ out.push({ id, label, description, genre: def.identity?.genre ?? "", tags: dtags });
43
+ }
44
+ // (map keys are unique — the equal arm never fires)
45
+ out.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : /* v8 ignore next */ 0));
46
+ return out;
47
+ }
48
+ /** Search the flow rows (PURE over the merged rows). */
49
+ export function searchFlows(rows, q) {
50
+ const toks = q.toLowerCase().split(/\s+/).filter((t) => t !== "");
51
+ const out = rows.filter((r) => {
52
+ const hay = (r.name + " " + r.title + " " + r.description).toLowerCase();
53
+ return toks.every((t) => hay.includes(t));
54
+ });
55
+ // (registry names are unique — the equal arm never fires)
56
+ out.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : /* v8 ignore next */ 0));
57
+ return out;
58
+ }
59
+ /** The flow rows: REGISTRY (the compile truth) merged with the
60
+ * flows/<name>/tool.json leaf (the agent face: stage_title). */
61
+ export function flowSummaryRows(repo) {
62
+ const out = [];
63
+ for (const name of registryFlowNames()) {
64
+ const flow = getRegistryFlow(name);
65
+
66
+
67
+ if (flow === undefined)
68
+ continue;
69
+ let title = name;
70
+ try {
71
+ const leaf = JSON.parse(readFileSync(join(repo, "flows", name, "tool.json"), "utf8"));
72
+ if (typeof leaf.stage_title === "string" && leaf.stage_title !== "")
73
+ title = leaf.stage_title;
74
+ }
75
+ catch {
76
+ // no leaf — the registry row stands alone
77
+ }
78
+ out.push({ name, title, description: flow.description, stages: flow.stages.length, skillRefs: flow.skillRefs });
79
+ }
80
+ return out;
81
+ }
82
+ /** The contract rows, one per registry flow, in registry order. */
83
+ export function flowContractRows() {
84
+ const out = [];
85
+ for (const name of registryFlowNames()) {
86
+ const flow = getRegistryFlow(name);
87
+
88
+
89
+ if (flow === undefined)
90
+ continue;
91
+ out.push({
92
+ id: flow.id,
93
+ description: flow.description,
94
+ stages: flow.stages.map((st) => ({
95
+ id: st.id,
96
+ engine: st.engine,
97
+ card: st.card,
98
+ inputs: st.inputs,
99
+ outputs: st.outputs,
100
+ params: st.params,
101
+ })),
102
+ initialValidators: flow.initialValidators,
103
+ tool: flow.tool,
104
+ });
105
+ }
106
+ return out;
107
+ }
108
+ // ── the seat ─────────────────────────────────────────────────────
109
+ /** The disclosure service: ONE disclosure system over both planes.
110
+ * discover(lookup, q, tags) answers {flows?, cards?} — the door's
111
+ * combined body, live-derived. */
112
+ // ROLE (cookbook adding-a-package role table): Directory: exposes entries + metadata for discovery/selection. Key "disclose" unchanged.
113
+ export class DiscloseDirectoryService extends Service {
114
+ static inject = ["cardRegistry"];
115
+ constructor(ctx) {
116
+ super(ctx, "disclose");
117
+ }
118
+
119
+
120
+
121
+
122
+ contracts() {
123
+ return { flows: flowContractRows() };
124
+ }
125
+ /** GET /v1/discover: unknown
126
+ * lookup refuses with the door's own voice; the body carries the
127
+ * requested planes only. */
128
+ discover(lookup, q, tags) {
129
+ if (lookup !== "all" && lookup !== "cards" && lookup !== "flows") {
130
+ throw new Error("unknown lookup '" + lookup + "' (all | cards | flows)");
131
+ }
132
+ const body = {};
133
+ if (lookup === "all" || lookup === "flows") {
134
+ body.flows = searchFlows(flowSummaryRows(resolveRepoRoot()), q);
135
+ }
136
+ if (lookup === "all" || lookup === "cards") {
137
+ // property read: the hard inject (above) is the fiber's
138
+ // contract — the legal spelling under the tutorial's law.
139
+ const cards = this.ctx.cardRegistry;
140
+ body.cards = searchCards(cards.defsSync(), q, tags);
141
+ }
142
+ return body;
143
+ }
144
+ }
145
+ /** The disclose row: mounts after the card-registry provider (its
146
+ * hard inject pends on the seat — the loader orders it). */
147
+ export const discloseProvider = {
148
+ name: "estate-disclose",
149
+ inject: ["cardRegistry"],
150
+ apply(ctx) {
151
+ new DiscloseDirectoryService(ctx);
152
+ },
153
+ };
154
+ //# sourceMappingURL=discloseRegistry.js.map
@@ -0,0 +1,4 @@
1
+ /** The engine-composed film's name among a stage's artifacts, if
2
+ * any — presentation order only, never composition. */
3
+ export declare function engineFilmName(names: readonly string[]): string | null;
4
+ //# sourceMappingURL=filmLead.d.ts.map
@@ -0,0 +1,17 @@
1
+
2
+ // disk-stitch valve's death): the harness NEVER composes media —
3
+ // no ffmpeg, no concat, no mix. Every artifact traces to a
4
+ // composition of cards; the film is assembled in-graph (the
5
+ // film-assemble stage's model-free workflow). What survives here
6
+ // is the one pure, filesystem-free decision the gallery needs:
7
+ // when the engine composed the film itself, the film leads the
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$/;
12
+ /** The engine-composed film's name among a stage's artifacts, if
13
+ * any — presentation order only, never composition. */
14
+ export function engineFilmName(names) {
15
+ return names.find((n) => ENGINE_FILM_RE.test(n)) ?? null;
16
+ }
17
+ //# sourceMappingURL=filmLead.js.map
@@ -0,0 +1,27 @@
1
+ /** The admitted film load — exact off the doc, never estimated. */
2
+ export interface FilmLoad {
3
+ windows: number;
4
+ frames: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ /** Live engine memory, bytes (ComfyUI /system_stats units). */
9
+ export interface EngineMem {
10
+ vramFree: number;
11
+ vramTotal: number;
12
+ }
13
+ /** Read the film load off a card body (h3-timeline calls shape).
14
+ * Null when the body carries no computable spans — the warn never
15
+ * refuses on shape (validate owns that); nothing computable means
16
+ * nothing to warn about. */
17
+ export declare function filmLoadOf(body: Record<string, unknown>): FilmLoad | null;
18
+ /** The pressure decision — null mem (telemetry down) or healthy
19
+ * pressure returns null: no warn. Only the pressured side speaks. */
20
+ export declare function filmMemoryWarn(load: FilmLoad, mem: EngineMem | null): string | null;
21
+ /** Live VRAM off the engine (primary device serves the film).
22
+ * Null on ANY failure (unreachable, unparseable, no devices) —
23
+ * the caller skips the warn, never fails admission. The fuse is
24
+ * dsh-timeout's deadline (no timer seat on this path — the manage
25
+ * plane's seat does not reach the start door). */
26
+ export declare function fetchEngineMem(baseUrl: string, fetchFn?: typeof fetch, timeoutMs?: number): Promise<EngineMem | null>;
27
+ //# sourceMappingURL=filmMemoryWarn.d.ts.map
@@ -0,0 +1,99 @@
1
+ // filmMemoryWarn.ts — F-6(b): the film lane warns at admission.
2
+ //
3
+ // The OOM record (attempt002/003): a film admitted under memory
4
+ // pressure burns the render — kernel OOM on host contention (43G +
5
+ // swap, load-264) and VRAM at 23.7/24.5 GiB (96.8%), while the
6
+ // retry that lived ran with 8.7G VRAM free. The TOOL half of the
7
+ // pre-flight (F-6(a) briefs the agent; this warns the run): at film
8
+ // admission the door reads the engine's live VRAM and, under the
9
+ // pressure line, stamps a warning on the run — the warn rides
10
+ // run_status, never a refusal. Admission NEVER blocks on telemetry:
11
+ // an unreachable engine skips the warn (the run is unaffected; the
12
+ // §21 engine-loss arm owns dead engines).
13
+ //
14
+ // The line (20% of device VRAM) interpolates between the two
15
+ // measured points on this box (failure 3%, success 35%) —
16
+ // documented here, not derived: a byte predictor would need
17
+ // measured per-family weight minima that exist nowhere on record,
18
+ // and LAW 2 forbids fabricating them. The warn names the admitted
19
+ // LOAD (windows/frames/geometry — exact, off the doc) against live
20
+ // FREE, so the pressure comparison is real on both sides.
21
+ import { deadline } from "@deepseek-ai/dsh-timeout";
22
+ /** Read the film load off a card body (h3-timeline calls shape).
23
+ * Null when the body carries no computable spans — the warn never
24
+ * refuses on shape (validate owns that); nothing computable means
25
+ * nothing to warn about. */
26
+ export function filmLoadOf(body) {
27
+ const calls = body['calls'];
28
+ if (!Array.isArray(calls) || calls.length === 0)
29
+ return null;
30
+ let frames = 0;
31
+ let counted = 0;
32
+ for (const c of calls) {
33
+ if (typeof c !== 'object' || c === null)
34
+ continue;
35
+ const rec = c;
36
+ const s = rec['start_frame'];
37
+ const e = rec['end_frame'];
38
+ if (typeof s !== 'number' || typeof e !== 'number' ||
39
+ !Number.isInteger(s) || !Number.isInteger(e) || e <= s)
40
+ continue;
41
+ frames += e - s;
42
+ counted++;
43
+ }
44
+ if (counted === 0)
45
+ return null;
46
+ const w = body['width'];
47
+ const h = body['height'];
48
+ return {
49
+ windows: calls.length,
50
+ frames,
51
+ width: typeof w === 'number' && w > 0 ? w : 0,
52
+ height: typeof h === 'number' && h > 0 ? h : 0,
53
+ };
54
+ }
55
+ const GIB = 1024 ** 3;
56
+ const gib = (b) => (b / GIB).toFixed(1);
57
+ /** The pressure decision — null mem (telemetry down) or healthy
58
+ * pressure returns null: no warn. Only the pressured side speaks. */
59
+ export function filmMemoryWarn(load, mem) {
60
+ if (mem === null)
61
+ return null;
62
+ if (!(mem.vramTotal > 0) || !(mem.vramFree >= 0))
63
+ return null;
64
+ if (mem.vramFree >= mem.vramTotal / 5)
65
+ return null;
66
+ const pct = ((mem.vramFree / mem.vramTotal) * 100).toFixed(0);
67
+ const geo = load.width > 0 && load.height > 0 ? `, ${load.width}x${load.height}` : ', unstated geometry';
68
+ return (`film admission: engine VRAM pressured — ${gib(mem.vramFree)} of ${gib(mem.vramTotal)} GiB free ` +
69
+ `(${pct}%) below the 20% line for a ${load.windows}-window film (${load.frames} frames${geo}); ` +
70
+ `a ComfyUI restart before the big film is sanctioned — an identical params/seed rerun rides the node cache.`);
71
+ }
72
+ /** Live VRAM off the engine (primary device serves the film).
73
+ * Null on ANY failure (unreachable, unparseable, no devices) —
74
+ * the caller skips the warn, never fails admission. The fuse is
75
+ * dsh-timeout's deadline (no timer seat on this path — the manage
76
+ * plane's seat does not reach the start door). */
77
+ export async function fetchEngineMem(baseUrl, fetchFn = globalThis.fetch, timeoutMs = 5000) {
78
+ const dl = deadline(undefined, timeoutMs, "ENGINE_MEM");
79
+ try {
80
+ const r = await fetchFn(baseUrl.replace(/\/+$/, '') + '/system_stats', { signal: dl.signal });
81
+ const stats = (await r.json());
82
+ const devices = stats['devices'];
83
+ if (!Array.isArray(devices) || devices.length === 0)
84
+ return null;
85
+ const d = devices[0];
86
+ const free = d['vram_free'];
87
+ const total = d['vram_total'];
88
+ if (typeof free !== 'number' || typeof total !== 'number')
89
+ return null;
90
+ return { vramFree: free, vramTotal: total };
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ finally {
96
+ dl[Symbol.dispose]();
97
+ }
98
+ }
99
+ //# sourceMappingURL=filmMemoryWarn.js.map