@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.
Files changed (131) hide show
  1. package/LICENSE +557 -0
  2. package/README.md +54 -2
  3. package/lib/bakeParams.d.ts +17 -0
  4. package/lib/bakeParams.js +182 -0
  5. package/lib/bench.d.ts +32 -0
  6. package/lib/bench.js +111 -0
  7. package/lib/cardsArmError.d.ts +61 -0
  8. package/lib/cardsArmError.js +57 -0
  9. package/lib/cardsCompose.d.ts +53 -0
  10. package/lib/cardsCompose.js +295 -0
  11. package/lib/cardsDangling.d.ts +16 -0
  12. package/lib/cardsDangling.js +213 -0
  13. package/lib/cardsFacts.d.ts +87 -0
  14. package/lib/cardsFacts.js +78 -0
  15. package/lib/cardsLanes.d.ts +43 -0
  16. package/lib/cardsLanes.js +178 -0
  17. package/lib/cardsRegistry.d.ts +404 -0
  18. package/lib/cardsRegistry.js +1543 -0
  19. package/lib/cardsVariant.d.ts +37 -0
  20. package/lib/cardsVariant.js +243 -0
  21. package/lib/discloseRegistry.d.ts +95 -0
  22. package/lib/discloseRegistry.js +156 -0
  23. package/lib/filmLead.d.ts +4 -0
  24. package/lib/filmLead.js +17 -0
  25. package/lib/filmMemoryWarn.d.ts +27 -0
  26. package/lib/filmMemoryWarn.js +99 -0
  27. package/lib/flowsData.d.ts +234 -0
  28. package/lib/flowsData.js +673 -0
  29. package/lib/flowsFamilyCompose.d.ts +45 -0
  30. package/lib/flowsFamilyCompose.js +191 -0
  31. package/lib/flowsParamsOverlay.d.ts +55 -0
  32. package/lib/flowsParamsOverlay.js +197 -0
  33. package/lib/flowsRegistryRows.d.ts +12 -0
  34. package/lib/flowsRegistryRows.js +520 -0
  35. package/lib/index.d.ts +47 -0
  36. package/lib/index.js +75 -0
  37. package/lib/ledgerTail.d.ts +20 -0
  38. package/lib/ledgerTail.js +123 -0
  39. package/lib/lifecycleLatch.d.ts +16 -0
  40. package/lib/lifecycleLatch.js +42 -0
  41. package/lib/loadPlane.d.ts +94 -0
  42. package/lib/loadPlane.js +570 -0
  43. package/lib/loadRegistry.d.ts +22 -0
  44. package/lib/loadRegistry.js +55 -0
  45. package/lib/manageOps.d.ts +27 -0
  46. package/lib/manageOps.js +162 -0
  47. package/lib/managePlane.d.ts +151 -0
  48. package/lib/managePlane.js +1790 -0
  49. package/lib/manageProbe.d.ts +48 -0
  50. package/lib/manageProbe.js +165 -0
  51. package/lib/manageRegistry.d.ts +66 -0
  52. package/lib/manageRegistry.js +113 -0
  53. package/lib/managerRail.d.ts +33 -0
  54. package/lib/managerRail.js +91 -0
  55. package/lib/mediaKinds.d.ts +3 -0
  56. package/lib/mediaKinds.js +2 -0
  57. package/lib/queue.d.ts +9 -0
  58. package/lib/queue.js +80 -0
  59. package/lib/queueCore.d.ts +72 -0
  60. package/lib/queueCore.js +128 -0
  61. package/lib/queueLifecycle.d.ts +2 -0
  62. package/lib/queueLifecycle.js +11 -0
  63. package/lib/queueLock.d.ts +60 -0
  64. package/lib/queueLock.js +198 -0
  65. package/lib/queueResurrect.d.ts +59 -0
  66. package/lib/queueResurrect.js +249 -0
  67. package/lib/queueRetry.d.ts +36 -0
  68. package/lib/queueRetry.js +24 -0
  69. package/lib/queueSidecar.d.ts +149 -0
  70. package/lib/queueSidecar.js +183 -0
  71. package/lib/queueSubmit.d.ts +82 -0
  72. package/lib/queueSubmit.js +191 -0
  73. package/lib/queueSweep.d.ts +30 -0
  74. package/lib/queueSweep.js +132 -0
  75. package/lib/resurrect.d.ts +6 -0
  76. package/lib/resurrect.js +18 -0
  77. package/lib/rootsManifest.d.ts +11 -0
  78. package/lib/rootsManifest.js +11 -0
  79. package/lib/runsChange.d.ts +61 -0
  80. package/lib/runsChange.js +79 -0
  81. package/lib/runsErrorCodes.d.ts +2 -0
  82. package/lib/runsErrorCodes.js +48 -0
  83. package/lib/runsExecute.d.ts +52 -0
  84. package/lib/runsExecute.js +494 -0
  85. package/lib/runsGates.d.ts +161 -0
  86. package/lib/runsGates.js +307 -0
  87. package/lib/runsList.d.ts +78 -0
  88. package/lib/runsList.js +574 -0
  89. package/lib/runsRefusalVoices.d.ts +9 -0
  90. package/lib/runsRefusalVoices.js +96 -0
  91. package/lib/runsRegistry.d.ts +351 -0
  92. package/lib/runsRegistry.js +2394 -0
  93. package/lib/runsSourceEcho.d.ts +81 -0
  94. package/lib/runsSourceEcho.js +341 -0
  95. package/lib/runsStart.d.ts +163 -0
  96. package/lib/runsStart.js +667 -0
  97. package/lib/runsTypes.d.ts +218 -0
  98. package/lib/runsTypes.js +289 -0
  99. package/lib/runsValidate.d.ts +5 -0
  100. package/lib/runsValidate.js +31 -0
  101. package/lib/runsValidateArms.d.ts +7 -0
  102. package/lib/runsValidateArms.js +339 -0
  103. package/lib/runsValidateInline.d.ts +6 -0
  104. package/lib/runsValidateInline.js +82 -0
  105. package/lib/runsValidateRefusals.d.ts +7 -0
  106. package/lib/runsValidateRefusals.js +18 -0
  107. package/lib/runsValidateServe.d.ts +15 -0
  108. package/lib/runsValidateServe.js +276 -0
  109. package/lib/runsValidateShared.d.ts +84 -0
  110. package/lib/runsValidateShared.js +88 -0
  111. package/lib/runsValidateStages.d.ts +32 -0
  112. package/lib/runsValidateStages.js +511 -0
  113. package/lib/runsValidateSweeps.d.ts +6 -0
  114. package/lib/runsValidateSweeps.js +143 -0
  115. package/lib/service.d.ts +63 -0
  116. package/lib/service.js +89 -0
  117. package/lib/skillFrontmatter.d.ts +11 -0
  118. package/lib/skillFrontmatter.js +46 -0
  119. package/lib/skillFs.d.ts +24 -0
  120. package/lib/skillFs.js +78 -0
  121. package/lib/skillPlane.d.ts +99 -0
  122. package/lib/skillPlane.js +269 -0
  123. package/lib/skillRegistry.d.ts +23 -0
  124. package/lib/skillRegistry.js +55 -0
  125. package/lib/skillRows.d.ts +127 -0
  126. package/lib/skillRows.js +468 -0
  127. package/lib/toolProjection.d.ts +30 -0
  128. package/lib/toolProjection.js +142 -0
  129. package/lib/vocab.d.ts +6 -0
  130. package/lib/vocab.js +18 -0
  131. package/package.json +48 -4
@@ -0,0 +1,37 @@
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
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ readonly cellRoute: string;
16
+ readonly cellParams?: readonly string[];
17
+ readonly resolverDefaults: Record<string, unknown>;
18
+ /** THE ROUTE ENVELOPE (the 25-steps-into-turbo cure): when the
19
+ * selected variant declares one, a caller-STATED steps/cfg
20
+ * outside its closed bounds refuses at the stamp gate — the
21
+ * distilled lane's marriage is not agency territory. */
22
+ readonly samplerEnvelope: Readonly<Record<"steps" | "cfg", EnvelopeBound | undefined>> | null;
23
+ }
24
+ /** Select the matrix cell (R1 wire contract): explicit body
25
+ * variant/quant keys win when stated (matched against facts
26
+ * variant id/route + cell quant); unstated coordinates fall to
27
+ * the FIRST non-Recipe variant / first cell (Model.resolve —
28
+ * the family default). Unknown coordinates refuse LOUD (never a
29
+ * silent neighbor cell). */
30
+ export declare function selectCardVariant(mid: string, famRow: ModelFactsRow, body: Record<string, unknown>, phase: string): VariantSelection;
31
+ export declare function stampCardOverlay(body: Record<string, unknown>, famRow: ModelFactsRow, decl: CardDeclRow, sel: VariantSelection, phase: string, fam: string): Record<string, unknown>;
32
+ /** The card-compose lift (card_compose_body 363-372): the run body
33
+ * minus the gateway envelope, restaged as the ONE params stanza.
34
+ * variant/quant ride the R1 contract (consumed at selection, never
35
+ * params — no card declares knobs by those names). */
36
+ export declare function liftCardParams(body: Record<string, unknown>): Record<string, unknown>;
37
+ //# sourceMappingURL=cardsVariant.d.ts.map
@@ -0,0 +1,243 @@
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
+ import { cardAdmits } from "./cardsFacts.js";
6
+ import { theService, owningAtom } from "@melite/comfyui-cordis";
7
+ /** Normalize a facts variant's sampler_envelope declaration (the
8
+ * DECL authors it as {steps?: [min,max], cfg?: [min,max]}); junk
9
+ * shapes contribute nothing (never a crash). */
10
+ function normalizeEnvelope(raw) {
11
+ if (raw === null || typeof raw !== "object")
12
+ return null;
13
+ const r = raw;
14
+ const bound = (v) => {
15
+ if (!Array.isArray(v) || v.length !== 2)
16
+ return undefined;
17
+ const [a, b] = v;
18
+ return typeof a === "number" && typeof b === "number" && b >= a ? [a, b] : undefined;
19
+ };
20
+ const steps = bound(r.steps);
21
+ const cfg = bound(r.cfg);
22
+ return steps === undefined && cfg === undefined ? null : { steps, cfg };
23
+ }
24
+ function knownVariantIds(row) {
25
+ return (row.variants ?? []).map((v) => v.id);
26
+ }
27
+ /** Select the matrix cell (R1 wire contract): explicit body
28
+ * variant/quant keys win when stated (matched against facts
29
+ * variant id/route + cell quant); unstated coordinates fall to
30
+ * the FIRST non-Recipe variant / first cell (Model.resolve —
31
+ * the family default). Unknown coordinates refuse LOUD (never a
32
+ * silent neighbor cell). */
33
+ export function selectCardVariant(mid, famRow, body, phase) {
34
+ const variants = famRow.variants ?? [];
35
+ const offered = variants.filter((v) => v.hide_from_dropdown !== true);
36
+ const hiddenRoute = variants.find((v) => v.hide_from_dropdown === true && (v.route === mid || v.id === mid || (v.cells ?? []).some((c) => c.route === mid)));
37
+ const hiddenCellRoute = variants.some((v) => (v.cells ?? []).some((c) => c.hide_from_dropdown === true && c.route === mid));
38
+ if (hiddenRoute !== undefined || hiddenCellRoute) {
39
+ throw phaseRefusal(phase, "model " + JSON.stringify(mid) +
40
+ " is not offered (the variant route is hidden from the dropdown)");
41
+ }
42
+ const configured = offered.filter((v) => v.group !== "Recipe");
43
+ const pool = configured.length > 0 ? configured : offered;
44
+ if (pool.length === 0 && variants.length > 0) {
45
+ throw phaseRefusal(phase, "model " + JSON.stringify(mid) + " has no offered variants");
46
+ }
47
+ const rawVariant = body["variant"];
48
+ const rawQuant = body["quant"];
49
+ let variant;
50
+ if (rawVariant === undefined || rawVariant === null) {
51
+
52
+ // offered-cells wall's first firing): a doc pinned to a route
53
+ // that names a VARIANT-level lane ('krea-2-raw',
54
+ // 'z-image-base-int8') must compose THAT lane, never pool[0]'s
55
+ // silent neighbor. The address's cell claim below only searches
56
+ // the chosen variant's cells — without this claim a
57
+ // route-addressed draft landed pool[0] + cells[0] and composed
58
+ // the wrong weights while every surface stayed green (variant
59
+ // switching "not working" under an all-green suite).
60
+ variant = pool.find((v) => v.route === mid
61
+ || (v.cells ?? []).some((c) => c.hide_from_dropdown !== true && c.route !== "" && c.route === mid)) ?? pool[0];
62
+ }
63
+ else {
64
+ if (typeof rawVariant !== "string") {
65
+ throw phaseRefusal(phase, "variant must be a string (got " +
66
+ (Array.isArray(rawVariant) ? "list" : typeof rawVariant) + ")");
67
+ }
68
+ const requested = variants.find((v) => v.id === rawVariant || v.route === rawVariant);
69
+ if (requested?.hide_from_dropdown === true) {
70
+ throw phaseRefusal(phase, "variant " + JSON.stringify(rawVariant) +
71
+ " is not offered for model " + JSON.stringify(mid));
72
+ }
73
+ variant = offered.find((v) => v.id === rawVariant || v.route === rawVariant);
74
+ if (variant === undefined) {
75
+ throw phaseRefusal(phase, unknownVariantVoice(rawVariant, mid, knownVariantIds(famRow)));
76
+ }
77
+ }
78
+ let quant = "";
79
+ let cell;
80
+ // THE LEGACY COORDINATE (the size-at-quant fold, operator
81
+
82
+ // 'native' — an old draft carries that coordinate against a
83
+ // family whose cells now name SIZES. 'native' meant "the only
84
+ // size this family ships", which the ADDRESS already says, so it
85
+ // resolves as UNSTATED (the mid's cell claim picks the size —
86
+ // never a silent neighbor cell, never a refusal on a draft the
87
+ // fold promised to keep landing).
88
+ const legacyNative = rawQuant === "native";
89
+ if (rawQuant !== undefined && rawQuant !== null && !legacyNative) {
90
+ if (typeof rawQuant !== "string") {
91
+ throw phaseRefusal(phase, "quant must be a string (got " +
92
+ (Array.isArray(rawQuant) ? "list" : typeof rawQuant) + ")");
93
+ }
94
+ const cells = variant !== undefined
95
+ ? (variant.cells ?? []).filter((c) => c.hide_from_dropdown !== true)
96
+ : [];
97
+ const hit = cells.find((c) => c.quant === rawQuant);
98
+ if (hit === undefined) {
99
+ throw phaseRefusal(phase, unknownQuantVoice(rawQuant, mid, variant !== undefined ? variant.id : "", cells.map((c) => c.quant)));
100
+ }
101
+ cell = hit;
102
+ quant = hit.quant;
103
+ }
104
+ else if (variant !== undefined) {
105
+ const cells = (variant.cells ?? []).filter((c) => c.hide_from_dropdown !== true);
106
+ // Unstated quant: the ADDRESS'S OWN CELL CLAIM wins (the
107
+ // fold's coverage law — a draft pinned to 'qwen3-tts-base'
108
+ // means the 0.6B clone; one pinned to 'qwen3-tts-voicedesign'
109
+ // means the 1.7B persona), else the FIRST cell (Model.resolve's
110
+ // family default — the large rung leads every ladder).
111
+ cell = cells.find((c) => c.route !== "" && c.route === mid) ?? cells[0];
112
+ if (cell !== undefined)
113
+ quant = String(cell.quant ?? "");
114
+ }
115
+ return {
116
+ variantId: variant !== undefined ? variant.id : "",
117
+ variantRoute: variant !== undefined ? String(variant.route ?? "") : "",
118
+ quant,
119
+ cellRoute: cell !== undefined ? String(cell.route ?? "") : "",
120
+ cellParams: cell?.params,
121
+ resolverDefaults: variant !== undefined ? { ...(variant.resolver_defaults ?? {}) } : {},
122
+ samplerEnvelope: variant !== undefined
123
+ ? normalizeEnvelope(variant.sampler_envelope)
124
+ : null,
125
+ };
126
+ }
127
+ /** The route-lens stamp overlay (_route_stamp_overlay 705-751):
128
+ * family defaults + the selected variant's resolver_defaults,
129
+ * injected ONLY for absent keys, filtered to the owning card's
130
+ * field surface (schema keys + admits, exact or trailing-*
131
+ * prefix). None/"" stamps never ride (UNSET markers — riding
132
+ * them would refuse the str fields the row leaves open).
133
+ * variant/quant contract keys are CONSUMED (never ride compose —
134
+ * no card declares them). Returns the STAMPED body (a copy). */
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ function envelopeRefusal(body, sel, phase) {
143
+
144
+ // in @melite/contracts beside the lane judges; the door adds what
145
+ // its seat knows — the phase-consistent frame, the marriage
146
+ // clause, the lane-read tail.
147
+ const off = judgeSamplerEnvelope(body, sel.samplerEnvelope, {
148
+ id: sel.variantId,
149
+ route: sel.variantRoute,
150
+ });
151
+ if (off === null)
152
+ return;
153
+ const married = sel.resolverDefaults[off.knob] ?? "";
154
+ throw new EnvelopeRefusal(400, "card_compose phase " + phase + ": " + off.voice +
155
+ (married !== "" ? " and the lane is married to " + off.knob + " " + String(married) : "") +
156
+ ". " + samplerEnvelopeCure() +
157
+ " (Read the family lane: melite_skill_read model:<family>.)", "card_compose");
158
+ }
159
+ export function stampCardOverlay(body, famRow, decl, sel, phase, fam) {
160
+ envelopeRefusal(body, sel, phase);
161
+ const stamps = { ...(famRow.defaults ?? {}) };
162
+ for (const [k, v] of Object.entries(sel.resolverDefaults))
163
+ stamps[k] = v;
164
+ // THE SHARED SURFACE (audit Y-S2, the third admission seat): the
165
+ // stamp gate judged knobs+admits by hand and omitted the absorbed
166
+ // mod fields — a mod-surfaced default failed to stamp (fail-closed,
167
+ // no live key) while both other seats admitted it. One predicate,
168
+ // three seats; the atom rides in (owningAtom(fam), the same fold
169
+ // admissionRefusal judges).
170
+ const modNames = new Set();
171
+ try {
172
+ // THE ROUTE→ATOM FOLD (same fold admissionRefusal judges): the
173
+ // owning atom scopes the absorbed surface; a not-booted models
174
+ // service degrades the whole fold to knobs+admits.
175
+ const envelopeAtom = owningAtom(fam);
176
+ for (const a of theService().cardModFields(famRow.card)) {
177
+ if (!a.families.includes(envelopeAtom))
178
+ continue;
179
+ for (const n of Object.keys(a.fields.dict ?? {}))
180
+ modNames.add(n);
181
+ }
182
+ }
183
+ catch (modFoldError) {
184
+ // modFoldError: card defs not booted in this fiber — the stamp
185
+ // gate degrades to knobs+admits, the pre-Y-S2 surface.
186
+ }
187
+ const onSurface = (k) => cardAdmits(decl, modNames, k);
188
+ const out = { ...body };
189
+ for (const [k, v] of Object.entries(stamps)) {
190
+ if (v === null || v === undefined || v === "")
191
+ continue;
192
+ if (!onSurface(k))
193
+ continue;
194
+ if (k in out)
195
+ continue;
196
+ if (CARD_ENVELOPE_KEYS.includes(k))
197
+ continue;
198
+ out[k] = v;
199
+ }
200
+ return out;
201
+ }
202
+ /** The card-compose lift (card_compose_body 363-372): the run body
203
+ * minus the gateway envelope, restaged as the ONE params stanza.
204
+ * variant/quant ride the R1 contract (consumed at selection, never
205
+ * params — no card declares knobs by those names). */
206
+ export function liftCardParams(body) {
207
+ const params = {};
208
+ for (const [k, v] of Object.entries(body)) {
209
+ if (CARD_ENVELOPE_KEYS.includes(k))
210
+ continue;
211
+ if (k === "variant" || k === "quant")
212
+ continue;
213
+
214
+ // BROKEN-B follow-on): the run body's `params` dict IS the stanza
215
+ // (liftStanza merges it over its siblings at compose), so the
216
+ // lane's view must unwrap it the same way — it did not, and a
217
+ // `{model, params:{…}}` body reached the undeclared-key gate
218
+ // still carrying a `params` key. Two lifts of one shape is how
219
+ // the bench and the compose disagreed about what a card sees.
220
+ if (k === "params" && typeof v === "object" && v !== null && !Array.isArray(v)) {
221
+ // SIBLINGS WIN — the stanza fills what they leave out
222
+
223
+ // LAST, so `{text: "sibling", params: {text: "inner"}}` resolved
224
+ // by key ORDER — the inner text won on one lift and the sibling
225
+ // on the other. liftStanza is explicit that siblings override the
226
+ // stanza; the "ONE SPELLING" claim is only true once this
227
+ // matches it.)
228
+ for (const [ik, iv] of Object.entries(v)) {
229
+
230
+ // undefined reads as absent, matching what JSON persistence
231
+ // would hand the row.
232
+ if (!(ik in params) && iv !== undefined)
233
+ params[ik] = iv;
234
+ }
235
+ continue;
236
+ }
237
+ if (v === undefined)
238
+ continue;
239
+ params[k] = v;
240
+ }
241
+ return params;
242
+ }
243
+ //# sourceMappingURL=cardsVariant.js.map
@@ -0,0 +1,95 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ import type { Context } from "@deepseek-ai/cordis";
3
+ import type { FlowsSeat } from "./flowsData.js";
4
+ /** One card summary (the routing layer — no bodies). */
5
+ export interface DiscoveredCard {
6
+ readonly id: string;
7
+ readonly label: string;
8
+ readonly description: string;
9
+ readonly genre: string;
10
+ readonly tags: readonly string[];
11
+ }
12
+ /** One flow summary (the routing layer). */
13
+ export interface FlowSummary {
14
+ readonly name: string;
15
+ readonly title: string;
16
+ readonly description: string;
17
+ readonly stages: number;
18
+ readonly skillRefs: readonly string[];
19
+ }
20
+ /** The search surface a card def offers (the def itself satisfies
21
+ * this — structural, no import of the engine service). */
22
+ export interface SearchableCard {
23
+ readonly identity?: {
24
+ readonly label?: string;
25
+ readonly description?: string;
26
+ readonly genre?: string;
27
+ };
28
+ readonly tags?: readonly string[];
29
+ }
30
+ /** Search the card defs: the q tokens (whitespace-split,
31
+ * case-folded) ALL match (id + label + description + tags); the
32
+ * tags param (comma list) ALL match def.tags. Empty q + tags =
33
+ * all. */
34
+ export declare function searchCards(defs: ReadonlyMap<string, SearchableCard>, q: string, tags: string): DiscoveredCard[];
35
+ /** Search the flow rows (PURE over the merged rows). */
36
+ export declare function searchFlows(rows: ReadonlyArray<FlowSummary>, q: string): FlowSummary[];
37
+ /** The flow rows: REGISTRY (the compile truth) merged with the
38
+ * flows/<name>/tool.json leaf (the agent face: stage_title). */
39
+ export declare function flowSummaryRows(repo: string, flowsSeat?: FlowsSeat | null): FlowSummary[];
40
+
41
+
42
+
43
+
44
+
45
+
46
+ export interface FlowContract {
47
+ readonly id: string;
48
+ readonly description: string;
49
+ readonly stages: ReadonlyArray<{
50
+ readonly id: string;
51
+ readonly engine: string;
52
+ readonly card: string;
53
+ readonly inputs: unknown;
54
+ readonly outputs: unknown;
55
+ readonly params: unknown;
56
+ }>;
57
+ readonly initialValidators: unknown;
58
+ readonly tool: unknown;
59
+ }
60
+ /** The contract rows, one per registry flow, in registry order. */
61
+ export declare function flowContractRows(flowsSeat?: FlowsSeat | null): FlowContract[];
62
+ /** The disclosure service: ONE disclosure system over both planes.
63
+ * discover(lookup, q, tags) answers {flows?, cards?} — the door's
64
+ * combined body, live-derived. */
65
+ export declare class DiscloseDirectoryService extends Service {
66
+ static inject: string[];
67
+ constructor(ctx: Context);
68
+
69
+
70
+
71
+
72
+ contracts(): {
73
+ flows: FlowContract[];
74
+ };
75
+ /** GET /v1/discover: unknown
76
+ * lookup refuses with the door's own voice; the body carries the
77
+ * requested planes only. */
78
+ discover(lookup: string, q: string, tags: string): {
79
+ flows?: FlowSummary[];
80
+ cards?: DiscoveredCard[];
81
+ };
82
+ }
83
+ /** The disclose row: mounts after the card-registry provider (its
84
+ * hard inject pends on the seat — the loader orders it). */
85
+ export declare const discloseProvider: {
86
+ name: string;
87
+ inject: readonly ["cardRegistry"];
88
+ apply(ctx: Context): void;
89
+ };
90
+ declare module "@deepseek-ai/cordis" {
91
+ interface Context {
92
+ disclose: DiscloseDirectoryService;
93
+ }
94
+ }
95
+ //# sourceMappingURL=discloseRegistry.d.ts.map
@@ -0,0 +1,156 @@
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 { seedFlowsSeat } 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, flowsSeat) {
62
+ const seat = flowsSeat ?? seedFlowsSeat();
63
+ const out = [];
64
+ for (const name of seat.names()) {
65
+ const flow = seat.get(name);
66
+
67
+
68
+ if (flow === undefined)
69
+ continue;
70
+ let title = name;
71
+ try {
72
+ const leaf = JSON.parse(readFileSync(join(repo, "flows", name, "tool.json"), "utf8"));
73
+ if (typeof leaf.stage_title === "string" && leaf.stage_title !== "")
74
+ title = leaf.stage_title;
75
+ }
76
+ catch {
77
+ // no leaf — the registry row stands alone
78
+ }
79
+ out.push({ name, title, description: flow.description, stages: flow.stages.length, skillRefs: flow.skillRefs });
80
+ }
81
+ return out;
82
+ }
83
+ /** The contract rows, one per registry flow, in registry order. */
84
+ export function flowContractRows(flowsSeat) {
85
+ const seat = flowsSeat ?? seedFlowsSeat();
86
+ const out = [];
87
+ for (const name of seat.names()) {
88
+ const flow = seat.get(name);
89
+
90
+
91
+ if (flow === undefined)
92
+ continue;
93
+ out.push({
94
+ id: flow.id,
95
+ description: flow.description,
96
+ stages: flow.stages.map((st) => ({
97
+ id: st.id,
98
+ engine: st.engine,
99
+ card: st.card,
100
+ inputs: st.inputs,
101
+ outputs: st.outputs,
102
+ params: st.params,
103
+ })),
104
+ initialValidators: flow.initialValidators,
105
+ tool: flow.tool,
106
+ });
107
+ }
108
+ return out;
109
+ }
110
+ // ── the seat ─────────────────────────────────────────────────────
111
+ /** The disclosure service: ONE disclosure system over both planes.
112
+ * discover(lookup, q, tags) answers {flows?, cards?} — the door's
113
+ * combined body, live-derived. */
114
+ // ROLE (cookbook adding-a-package role table): Directory: exposes entries + metadata for discovery/selection. Key "disclose" unchanged.
115
+ export class DiscloseDirectoryService extends Service {
116
+ static inject = ["cardRegistry"];
117
+ constructor(ctx) {
118
+ super(ctx, "disclose");
119
+ }
120
+
121
+
122
+
123
+
124
+ contracts() {
125
+ return { flows: flowContractRows(this.ctx.get("meliteFlows")) };
126
+ }
127
+ /** GET /v1/discover: unknown
128
+ * lookup refuses with the door's own voice; the body carries the
129
+ * requested planes only. */
130
+ discover(lookup, q, tags) {
131
+ if (lookup !== "all" && lookup !== "cards" && lookup !== "flows") {
132
+ throw new Error("unknown lookup '" + lookup + "' (all | cards | flows)");
133
+ }
134
+ const body = {};
135
+ if (lookup === "all" || lookup === "flows") {
136
+ body.flows = searchFlows(flowSummaryRows(resolveRepoRoot(), this.ctx.get("meliteFlows")), q);
137
+ }
138
+ if (lookup === "all" || lookup === "cards") {
139
+ // property read: the hard inject (above) is the fiber's
140
+ // contract — the legal spelling under the tutorial's law.
141
+ const cards = this.ctx.cardRegistry;
142
+ body.cards = searchCards(cards.defsSync(), q, tags);
143
+ }
144
+ return body;
145
+ }
146
+ }
147
+ /** The disclose row: mounts after the card-registry provider (its
148
+ * hard inject pends on the seat — the loader orders it). */
149
+ export const discloseProvider = {
150
+ name: "estate-disclose",
151
+ inject: ["cardRegistry"],
152
+ apply(ctx) {
153
+ new DiscloseDirectoryService(ctx);
154
+ },
155
+ };
156
+ //# 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