@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
package/lib/index.js ADDED
@@ -0,0 +1,66 @@
1
+ import { QueueService } from "./service.js";
2
+ import { RunsRuntimeService } from "./runsRegistry.js";
3
+ export { QueueService } from "./service.js";
4
+
5
+ // remotes each re-declared `runs`/`manage` on Context with a
6
+ // hand-rolled structural interface while this package declared the
7
+ // same keys with the real classes — TS2717, a conflict no program
8
+ // had ever composed before the walls plane typechecked. ONE owner
9
+ // per key, typed with what actually mounts.)
10
+ export { RunsRuntimeService } from "./runsRegistry.js";
11
+ export { ManageGatewayService } from "./manageRegistry.js";
12
+ export * from "./vocab.js";
13
+ export * from "./queue.js";
14
+ export * from "./runStatus.js";
15
+ // bootSweep twins (queue.ts core impl + resurrect.ts QueueRoots
16
+ // wrapper): the explicit export wins over the stars — the wrapper
17
+ // is the domain seam.
18
+ export { bootSweep } from "./resurrect.js";
19
+ export const name = "estate-queue";
20
+ export const inject = ["timer"];
21
+ export function apply(ctx, config = {}) {
22
+ new QueueService(ctx, config);
23
+ }
24
+ const plugin = { name, inject, apply };
25
+ export default plugin;
26
+ export * from "./runsGates.js";
27
+ // The skill-serving path (stroke 62): findSkill + disclosureRoot —
28
+ // the agent engine's spawn-injection reader rides these over the
29
+ // SAME storage melite_load serves (never a second skill tree).
30
+ export { findSkill, disclosureRoot } from "./skillPlane.js";
31
+ // THE LIVE BENCH (the selection's only source — the catalog law):
32
+ // every selection-serving surface reads through these, never its
33
+ // own glob (drift between readers is how stale docs leak back).
34
+ export { benchPicks, benchFingerprint, benchBootMs, benchDir } from "./bench.js";
35
+ export * from "./runsList.js";
36
+ export * from "./mediaKinds.js";
37
+ export * from "./runsTypes.js";
38
+ export * from "./runsStart.js";
39
+ export * from "./rootsManifest.js";
40
+ export * from "./discloseRegistry.js";
41
+ export * from "./skillPlane.js";
42
+ export * from "./skillRegistry.js";
43
+ export * from "./loadPlane.js";
44
+ export * from "./loadRegistry.js";
45
+ export * from "./toolProjection.js";
46
+ export * from "./ledgerTail.js";
47
+ export * from "./managePlane.js";
48
+ export * from "./manageRegistry.js";
49
+ export * from "./flowsData.js";
50
+ export * from "./runsValidate.js";
51
+ export * from "./cardsRegistry.js";
52
+ export { factsPath } from "./cardsFacts.js";
53
+ /** The runs registry row: mounts the live-run service (REBUILD-6).
54
+ * Inject gates on the queue + drafts + card-registry seats (the
55
+ * fiber's read contract — loader-mounted fibers enforce the
56
+ * tutorial's inject law on property reads; the service class's own
57
+ * static inject lists the same three); the estate-runs adapters
58
+ * (Typert) ride after this row. */
59
+ export const runsRegistryPlugin = {
60
+ name: "estate-runs-registry",
61
+ inject: ["queue", "draftsRemote", "cardRegistry"],
62
+ apply(ctx) {
63
+ new RunsRuntimeService(ctx);
64
+ },
65
+ };
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,20 @@
1
+ /** The parsed tail answer (the seat serves the object; the door
2
+ * serialized it — the HTTP rim is dead). */
3
+ export interface LedgerTailAnswer {
4
+ entries: unknown[];
5
+ shown: number;
6
+ matched: number;
7
+ /** §23: the roots whose journals merged into this tail (exact
8
+ * manifest order; absent only in the single-root legacy call). */
9
+ searched?: string[];
10
+ }
11
+ export declare function tailLedger(ledgerPath: string, rawLimit: string, rawEvent: string): LedgerTailAnswer;
12
+ /** §23 CROSS-ROOTS: every root's journal, one merged timeline. The
13
+ * per-file law rides VERBATIM first (match + last-N window per
14
+ * root — an unparseable line still occupies its slot); the
15
+ * per-file TAILS then merge by ts (stable — a tie keeps manifest
16
+ * order, own root first) and the last N merged serve. matched
17
+ * counts every root's matches. The answer names the searched
18
+ * roots. A single root degenerates to tailLedger exactly. */
19
+ export declare function tailLedgerAcross(roots: string[], rawLimit: string, rawEvent: string): LedgerTailAnswer;
20
+ //# sourceMappingURL=ledgerTail.d.ts.map
@@ -0,0 +1,123 @@
1
+ // ledgerTail.ts — the journal tail, RE-HOMED (REBUILD-19,
2
+
3
+ // doors/assets.ts _h_ledger, killed with the gateway app) ports
4
+ // verbatim as a pure over the state root — the queue seat's own
5
+ // journal (appendLedger writes it; this reads it back).
6
+ //
7
+ // The door's law rides EXACTLY (assets.ts 698-764): limit default
8
+ // 50, clamp 1..500, garbage -> 50 (NEVER a 400); event truncated
9
+ // to 64 chars, matched on the RAW line substring
10
+ // '"event":"<ev>'; the tail keeps the LAST N lines; unparseable
11
+ // lines count as matched but never as entries; output oldest ->
12
+ // newest within the tail; a missing journal reads empty.
13
+ //
14
+
15
+ // manifest root's journal into ONE timeline (ts-ordered, own root
16
+ // first on ties) and names the searched roots — a two-roots box
17
+ // answers "what happened" across both processes, not just the
18
+ // tree the seat happens to own.
19
+ import { readFileSync } from "node:fs";
20
+ import { join } from "node:path";
21
+ const parseLimit = (rawLimit) => {
22
+ if (/^\s*[+-]?\d+\s*$/.test(rawLimit)) {
23
+ return Math.max(1, Math.min(500, Number(rawLimit.trim())));
24
+ }
25
+ return 50;
26
+ };
27
+ /** Per-file scan (the door's law, intact): every line matched on
28
+ * the RAW substring, unparseables counted, a missing journal
29
+ * reading empty. */
30
+ const matchedLines = (ledgerPath, ev) => {
31
+ const needle = '"event":"' + ev;
32
+ const lines = [];
33
+ let matched = 0;
34
+ try {
35
+ const text = readFileSync(ledgerPath, "utf8");
36
+ // File iteration (`for line in f`): a trailing newline is NOT
37
+ // a phantom line, but a real blank line mid-file IS iterated
38
+ // (matched, then parse-skipped below).
39
+ const split = text.split("\n");
40
+ if (split.length > 0 && split[split.length - 1] === "" && text.endsWith("\n")) {
41
+ split.pop();
42
+ }
43
+ for (const line of split) {
44
+ if (ev !== "" && !line.includes(needle))
45
+ continue;
46
+ matched++;
47
+ lines.push(line);
48
+ }
49
+ }
50
+ catch {
51
+ // Missing journal reads empty (OSError -> pass).
52
+ }
53
+ return { lines, matched };
54
+ };
55
+ /** The entry ts (seconds) for the merge sort; 0 when absent —
56
+ * malformed rows sort oldest, and they parse-skip at the end
57
+ * anyway (never entries). */
58
+ const lineTs = (line) => {
59
+ const at = line.indexOf('"ts":');
60
+ if (at < 0)
61
+ return 0;
62
+ const rest = line.slice(at + 5);
63
+ const m = rest.match(/^\s*(-?\d+)/);
64
+ return m === null ? 0 : Number(m[1]);
65
+ };
66
+ const parseTail = (lines) => {
67
+ const out = [];
68
+ for (const e of lines) {
69
+ try {
70
+ out.push(JSON.parse(e));
71
+ }
72
+ catch {
73
+ continue;
74
+ }
75
+ }
76
+ return out;
77
+ };
78
+ /** The per-file tail (the door's law, byte-pinned by the REBUILD-19
79
+ * wall): every matched line, last-N window kept, unparseables
80
+ * occupy slots (they parse-skip at the end, never entries). */
81
+ const fileTail = (ledgerPath, ev, limit) => {
82
+ const { lines, matched } = matchedLines(ledgerPath, ev);
83
+ const tail = [];
84
+ for (const line of lines) {
85
+ tail.push(line);
86
+ if (tail.length > limit)
87
+ tail.shift();
88
+ }
89
+ return { tail, matched };
90
+ };
91
+ export function tailLedger(ledgerPath, rawLimit, rawEvent) {
92
+ const limit = parseLimit(rawLimit);
93
+ const ev = rawEvent.slice(0, 64);
94
+ const { tail, matched } = fileTail(ledgerPath, ev, limit);
95
+ const out = parseTail(tail);
96
+ return { entries: out, shown: out.length, matched };
97
+ }
98
+ /** §23 CROSS-ROOTS: every root's journal, one merged timeline. The
99
+ * per-file law rides VERBATIM first (match + last-N window per
100
+ * root — an unparseable line still occupies its slot); the
101
+ * per-file TAILS then merge by ts (stable — a tie keeps manifest
102
+ * order, own root first) and the last N merged serve. matched
103
+ * counts every root's matches. The answer names the searched
104
+ * roots. A single root degenerates to tailLedger exactly. */
105
+ export function tailLedgerAcross(roots, rawLimit, rawEvent) {
106
+ const limit = parseLimit(rawLimit);
107
+ const ev = rawEvent.slice(0, 64);
108
+ const merged = [];
109
+ let matched = 0;
110
+ for (const root of roots) {
111
+ const { tail, matched: m } = fileTail(join(root, "output", "_ledger.jsonl"), ev, limit);
112
+ matched += m;
113
+ for (const line of tail)
114
+ merged.push({ line, ts: lineTs(line) });
115
+ }
116
+ merged.sort((a, b) => a.ts - b.ts);
117
+ const tail = merged
118
+ .slice(Math.max(0, merged.length - limit))
119
+ .map((e) => e.line);
120
+ const out = parseTail(tail);
121
+ return { entries: out, shown: out.length, matched, searched: roots };
122
+ }
123
+ //# sourceMappingURL=ledgerTail.js.map
@@ -0,0 +1,93 @@
1
+ import { emitModifierKinds } from "@melite/comfyui-cordis";
2
+ import type { ModelsService } from "@melite/comfyui-cordis";
3
+ import type { CardRegistryService } from "./cardsRegistry.js";
4
+ import { toolBaseRows } from "./toolProjection.js";
5
+ import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
6
+ /** A card id → its package dir. The cardPackages rows are package
7
+ * NAMES ('@melite/<genre>-<card>'); the id is the row's tail past
8
+ * the genre prefix, which is NOT reparseable from the string alone
9
+ * (ids carry dashes) — so match rows ending in '-' + id, split the
10
+ * genre against the LIVE domain tier (readdir packages/), and keep
11
+ * the ones whose dir carries src/card.ts (the cardUnitDirs guard).
12
+ * Node resolution is the WRONG tool (pnpm links only dependents —
13
+ * require.resolve starves); the repo tree is the truth.
14
+ * Zero hits = unknown id; two = a data bug — both refuse LOUD at
15
+ * the door, never a silent pick. */
16
+ export declare function resolveCardPackageDir(repo: string, cardId: string): string;
17
+ /** The card's agents md (src/agents/**, AGENT.md first, sorted,
18
+ * capped — the cap is the contract: lines route, bodies stay
19
+ * bounded). */
20
+ export declare function cardSkillDocs(pkgDir: string): Array<{
21
+ path: string;
22
+ text: string;
23
+ }>;
24
+ /** The card's tool-call signature — the /v1/tools row
25
+ * envelope (ROW_KEYS mirror toolsEmit — one projection, the
26
+ * emitter imported, the envelope shared by construction). */
27
+ export declare function toolRowFor(id: string, def: {
28
+ schemaCarrier?: unknown;
29
+ schema: unknown;
30
+ boarded: readonly string[];
31
+ mods?: Parameters<typeof emitModifierKinds>[0];
32
+ }, rows: ReturnType<typeof toolBaseRows>): Record<string, unknown>;
33
+ /** The bundle digest (the DSH session-catalog half we CAN own:
34
+ * their catalog is digest-diffed "stable, never duplicated" — we
35
+ * don't own the loop so we can't clear the agent's context, but a
36
+ * stable content hash lets the agent dedupe its own reloads: quote
37
+ * the digests you hold, skip reload on a match). sha16 of the
38
+ * canonical bundle JSON (the asset pipeline's sha16 convention). */
39
+ export declare function bundleDigest(bundle: Record<string, unknown>): string;
40
+ /** Tier-1 skill LINES for one card id (the melite_skill_index truth —
41
+ * wireSkill rows over the planes buckets, card-skill scope only;
42
+ * the card's AGENT.md rides full under agents, never as a line).
43
+ * Merged across engines, id-deduped; unknown cards line nothing
44
+ * (the walk is the truth — never a refusal). */
45
+ export declare function skillLinesForCard(repo: string, cardId: string): Array<Record<string, unknown>>;
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+ export declare function skillLinesForFamilies(repo: string, fams: readonly string[]): Array<Record<string, unknown>>;
57
+ export declare function flowLeafDocs(repo: string, flowName: string): Array<{
58
+ path: string;
59
+ text: string;
60
+ }>;
61
+ /** Resolve one skill ref (a card:/model:/flow: sid) to its tier-1
62
+ * line through the planes registry (the melite_skill_index truth).
63
+ * Dangling refs line null — visible drift, never a refusal. */
64
+ /** @param modelsSeat the context's models service when mounted (the
65
+ * same seat-threading law the runs doors ride) */
66
+ export declare function skillLineForRef(repo: string, ref: string, modelsSeat?: FamilyModelsSeat | null): Record<string, unknown>;
67
+ /** The lane's models seat as the CARD arm reads it: the four
68
+ * disclosure methods (family rows, path/file presence, catalog
69
+ * artifacts). ModelsService satisfies it structurally; ctx.get
70
+ * returns the same service, so the card arm discloses from the
71
+ * lane that serves the run (the lane-seat law). */
72
+ export type CardModelsSeat = Pick<ModelsService, "allDecls" | "checkModelPresent" | "checkModelPathPresent" | "resolveCatalogArtifact">;
73
+ /** Melite load for a CARD: agents md + tool-call signature +
74
+ * tier-1 skill lines (the card's own AND every boarded family's
75
+ * model skills — ONE load hands the agent the whole craft: loading
76
+ * image-gen serves model:anima:prompt-enhance beside the card
77
+ * lines, so the prompt guide is read before compose, never hunted
78
+ * after) + model hints (the boarded families' DECL identity —
79
+ * presence-marked, never a run-time surprise; LLM-powered enhance
80
+ * stays the user's ✦ door, never served here). Throws LOUD
81
+ * on unknown ids (the door maps to 404). */
82
+ export declare function loadCard(repo: string, cards: CardRegistryService, modelsSeat: CardModelsSeat | null | undefined, cardId: string): Record<string, unknown>;
83
+ /** Melite load for a FLOW: the leaf agents md + the registry
84
+ * signature (the tool overlay verbatim — ONE spelling, the same
85
+ * object validate/start enforce; null when the row declares
86
+ * none) + slim stages + the author's skill refs (verbatim) with
87
+ * their tier-1 lines. Throws LOUD on unknown flows. */
88
+ /** @param modelsSeat the context's models service when mounted — the
89
+ * flow's skill lines resolve through the seat the runs doors
90
+ * thread (the lane-seat law); the booted singleton otherwise */
91
+ export declare function loadFlow(repo: string, flowName: string, modelsSeat?: FamilyModelsSeat | null): Record<string, unknown>;
92
+ /** First-non-blank query value (the catalogs qFirst shape). */
93
+ //# sourceMappingURL=loadPlane.d.ts.map