@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,306 @@
1
+ // runsGates.ts — the gateway-plane admission gate.
2
+ //
3
+
4
+ // Python-era paths it names (core/params.ts, doors/*, runs.ts,
5
+ // bridges.ts) are gone with the gateway itself; the gates they
6
+ // described are the ones implemented here, and the path references
7
+ // are provenance, not addresses.
8
+ //
9
+ // CORDIS CORE law: the card plane
10
+ // admits params through schemastery (the card plane's Schemastery
11
+ // schemas, direct — the knob vocabulary; cli.ts's admission-contract
12
+ // gate refuses unknown keys
13
+ // LOUD). The gateway plane admits request bodies through THIS module:
14
+ // schemastery owns STRUCTURE (which keys, which types), the doors
15
+ // keep the pinned VOICE (shaped refusal bytes), and the refusal
16
+ // envelope rides the door plugins — structure moves, bytes do
17
+ // not.
18
+ //
19
+ // THE SPLIT (why schemastery cannot own the voice): schemastery
20
+ // ValidationError messages differ from the texts the walls pin
21
+ // byte-exact. So every helper returns a STRUCTURE verdict (boolean
22
+ // or a `kind`-tagged union) and the door maps it to its existing
23
+ // refusal text VERBATIM — no ValidationError message ever reaches
24
+ // the wire. Fully static mappings live HERE as voice tables (one
25
+ // door lookup); interpolating texts stay door if-chains.
26
+ //
27
+ // WHAT LIVES HERE vs WHAT STAYS:
28
+ // - HERE: the strict-body vocab SSOT (was duplicated across
29
+ // the old doors — one list now),
30
+ // the strict-wire decode (route() 4335-4340 — was triplicated),
31
+ // the draft_id_ok shape (was triplicated; the law now lives
32
+ // in @melite/estate-drafts),
33
+ // schemastery field/composite STRUCTURE verdicts for the
34
+ // pure-JSON-domain doors, and the static verdict→voice DATA
35
+ // tables (UPLOADS_VOICE, DRAFT_PATCH_VOICE,
36
+ // FLOW_INLINE_TOP_VOICE, DRAFT_PATCH_FIELDS).
37
+ // - STAYS in the doors (byte-pinned): value-content checks,
38
+ // mirroring coercions, dynamic refusal STRINGS, every refusal
39
+ // STRING (a formatting mini-language would be new machinery
40
+ // for zero byte gain — named residual).
41
+ // - STAYS hand-rolled by necessity (documented, not ported):
42
+ // isRecord — cosmokit's isPlainObject (which schemastery's
43
+ // object resolver uses) returns true for CLASS INSTANCES, so
44
+ // the prototype check stays estate-owned.
45
+ // runs.ts parseIntOrNull, the studios lax-coercion family, and
46
+ // bridges.ts manageActionName's .get-crash 500 leg likewise.
47
+ //
48
+ // Schemas are side-effect-free: no transforms, no autofix, results
49
+ // discarded except where returned — input docs are never mutated
50
+ // (the doors reuse `doc` after the verdict).
51
+ //
52
+ // Erasable-syntax TS only (node --experimental-strip-types): no
53
+ // enums, .ts specifiers for relative imports.
54
+ import z from "@deepseek-ai/schemastery";
55
+ // ── shared vocab SSOT ──────────
56
+ // The retired-runner-knob + pipe-carry + door-key sets were
57
+ // copy-pasted across the old doors (and
58
+ // draft_id_ok thrice). One list now — drift fails at the import,
59
+ // never silently at one door.
60
+ // Vocab SSOT (ledger row 27): the knob/carry/door sets live ONCE in
61
+ // ./vocab.ts — re-exported here for the gates' callers.
62
+ export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
63
+ import { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
64
+ import { WIRE_STAGE_KEYS, STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
65
+ export { STAGE_PATCH_KEYS };
66
+ /** flow_inline top-level keys (the served shape). */
67
+ export const INLINE_TOP_KEYS = ["description", "id", "stages"];
68
+ /** flow_inline stage keys (extra=forbid at the door) — the
69
+ * CONTRACT'S list now (benchStage.ts WIRE_STAGE_KEYS): the agent's
70
+ * bench projection needs the same rule to build a wire row, and two
71
+ * copies of a door's key list is how a reader and a writer drift. */
72
+ export const STAGE_KEYS = WIRE_STAGE_KEYS;
73
+ /** Stage/flow identifier shape. */
74
+ export const FLOW_ID_RE = /^[a-z_][a-z0-9_-]*$/;
75
+
76
+
77
+
78
+ /** Draft id shape (DRAFT_ID_RE in @melite/estate-drafts spec.ts): 1..96 chars of [A-Za-z0-9_-]. */
79
+ // THE DRAFT ID GRAMMAR MIRRORS ITS OWNER (the census's H13: this copy
80
+ // had NO length cap, so a 200-char id passed this door and was
81
+ // refused by the next with a different voice). The drafts package
82
+ // OWNS the rule (DRAFT_ID_RE, 1..96) and this module re-exports that
83
+ // exact object — the drafts spec's own JSDoc says the queue
84
+ // re-exports it, which was false while the queue kept its own
85
+ // byte-identical copy. draft-id-grammar.spec.ts still pins the two
86
+ // as equal, and now that equality is the identity of one object
87
+ // rather than the luck of two copies.
88
+ export { DRAFT_ID_RE };
89
+ /** Decode one strict body: "" decodes as {} (body.decode() or
90
+ * "{}"). The TEXT embeds the host parser's message — walls assert
91
+ * status + code + prefix, never bytes. */
92
+ export function decodeStrictBody(body) {
93
+ const text = Buffer.from(body).toString("utf-8");
94
+ const src = text === "" ? "{}" : text;
95
+ try {
96
+ JSON.parse(src);
97
+ }
98
+ catch (exc) {
99
+ const msg = exc instanceof Error ? exc.message : String(exc);
100
+ return {
101
+ status: 400,
102
+ payload: { error: "bad JSON: " + msg, code: "bad_json" },
103
+ };
104
+ }
105
+ return { text: src };
106
+ }
107
+ /** The strict JSON body parse — mirrors route() 4335-4340. Owned
108
+ * here; doors/uploads.ts re-exports it (wall-pinned address). */
109
+ export function parseStrictJson(body) {
110
+ const wire = decodeStrictBody(body);
111
+ if (!("text" in wire))
112
+ return { status: wire.status, payload: wire.payload };
113
+ return { doc: JSON.parse(wire.text) };
114
+ }
115
+ // ── the object gate schemastery cannot own ──────────────────────
116
+ // See header: cosmokit isPlainObject accepts class instances, so a
117
+ // bare z.object() would take a class instance for a record.
118
+ // The prototype check excludes class instances; on the pure-JSON
119
+ // wire domain it agrees with typeof exactly (JSON.parse yields
120
+ // only plain-prototype values).
121
+ /** Estate record check: a plain-prototype mapping, never an array,
122
+ * never null, never a class instance. */
123
+ export function isRecord(v) {
124
+ if (typeof v !== "object" || v === null || Array.isArray(v))
125
+ return false;
126
+ const proto = Object.getPrototypeOf(v);
127
+ return proto === Object.prototype || proto === null;
128
+ }
129
+ // ── schemastery leaf schemas (STRUCTURE owners) ─────────────────
130
+ // `.required()` matters: without it, absent/undefined PASSES (the
131
+ // doors treat absent as a refusal, so the schema must too). Voices
132
+ // never escape — verdicts are booleans, messages stay in the doors.
133
+ /** The leaf vocabulary as data: gate name → required schema. One
134
+ * table, one runner — the five isXField helpers below are thin
135
+ * typed addresses over it (wall-pinned call sites). */
136
+ const LEAF = {
137
+ string: z.string().required(),
138
+ boolean: z.boolean().required(),
139
+ number: z.number().required(),
140
+ list: z.array(z.any()).required(),
141
+ dict: z.object({}).required(),
142
+ };
143
+ /** Run one leaf schema, returning the structure verdict only. */
144
+ function tryLeaf(schema, v) {
145
+ try {
146
+ z.resolve(v, schema, {});
147
+ return true;
148
+ }
149
+ catch {
150
+ return false;
151
+ }
152
+ }
153
+ /** typeof v === "string" (absent/null/non-strings refuse). */
154
+ export function isStringField(v) {
155
+ return tryLeaf(LEAF.string, v);
156
+ }
157
+ /** typeof v === "boolean" — strict: 0/1/"true" refuse (gate). */
158
+ export function isBoolField(v) {
159
+ return tryLeaf(LEAF.boolean, v);
160
+ }
161
+ /** typeof v === "number" — pure-JSON domain only. */
162
+ export function isNumberField(v) {
163
+ return tryLeaf(LEAF.number, v);
164
+ }
165
+ /** Array.isArray — the closed-list shape gate. */
166
+ export function isListField(v) {
167
+ return tryLeaf(LEAF.list, v);
168
+ }
169
+ /** Dict gate: the estate isRecord FIRST (class-instance exclusion), then the
170
+ * schema (intent declaration — the guard carries the invariant). */
171
+ export function isDictField(v) {
172
+ if (!isRecord(v))
173
+ return false;
174
+ return tryLeaf(LEAF.dict, v);
175
+ }
176
+ // draft_id_ok: the ONE address is @melite/estate-drafts (spec.ts —
177
+ // the SSOT re-home; the dead core's own copy is gone). Re-exported
178
+ // for the gates' callers.
179
+ import { draftIdOk, DRAFT_ID_RE } from "@melite/estate-drafts";
180
+ export { draftIdOk };
181
+ // ── shared key-set helper ───────────────────────────────────────
182
+ // Three composite gates refuse sorted unknown-key lists (flow top,
183
+ // stage, draft patch) — one helper, three tables.
184
+ /** Sorted keys of `v` outside `allowed`. */
185
+ function unknownKeys(v, allowed) {
186
+ return Object.keys(v).filter((k) => !allowed.includes(k)).sort();
187
+ }
188
+ /** Split one body's keys into retired-knob vs pipe-carry offenses. */
189
+ export function checkStrictBody(body) {
190
+ const bad = Object.keys(body).filter((k) => RETIRED_RUNNER_KNOBS.includes(k) ||
191
+ (k.startsWith("_") && !DOOR_KEYS.includes(k)));
192
+ const carry = Object.keys(body).filter((k) => RETIRED_CARRY_KEYS.includes(k));
193
+ return { bad, carry };
194
+ }
195
+ /** Structure-gate one uploads doc (content rules stay in the door). */
196
+ export function checkUploadsStructure(doc) {
197
+ if (!isRecord(doc))
198
+ return { kind: "not-object" };
199
+ const rawName = doc["filename"];
200
+ const dataUrl = doc["data"];
201
+ if (!isStringField(rawName))
202
+ return { kind: "bad-filename" };
203
+ if (!isStringField(dataUrl))
204
+ return { kind: "bad-data" };
205
+ return { kind: "ok", filename: rawName, dataUrl: dataUrl };
206
+ }
207
+ /** Static verdict→voice table for the uploads door (every arm is
208
+ * fully static — the door does one lookup, no if-chain). */
209
+ export const UPLOADS_VOICE = {
210
+ "not-object": "uploads: body must be a JSON object {filename, data}",
211
+ "bad-filename": "uploads: filename is required",
212
+ "bad-data": "uploads: data must be a FileReader data: URL",
213
+ };
214
+ /** Structure-gate one start doc (draft lookup stays in the door). */
215
+ export function checkFlowsStartEnvelope(doc) {
216
+ if (!isRecord(doc))
217
+ return { kind: "not-object", doc };
218
+ const testFlag = doc["test"] ?? false;
219
+ if (!isBoolField(testFlag))
220
+ return { kind: "bad-test", testFlag };
221
+ const draftId = doc["draft_id"];
222
+ if (typeof draftId !== "string" || draftId === "")
223
+ return { kind: "missing-draft" };
224
+ if (!draftIdOk(draftId))
225
+ return { kind: "malformed-draft", draftId };
226
+ return { kind: "ok", body: doc, testFlag };
227
+ }
228
+ /** Structure-gate one flow_inline value. */
229
+ export function checkFlowInlineTop(inline) {
230
+ if (!isRecord(inline))
231
+ return { kind: "not-object" };
232
+ const dead = unknownKeys(inline, INLINE_TOP_KEYS);
233
+ if (dead.length > 0)
234
+ return { kind: "unknown-keys", dead };
235
+ if (!("id" in inline) || !("stages" in inline)) {
236
+ return { kind: "missing-id-stages", keys: Object.keys(inline).sort() };
237
+ }
238
+ if (!Array.isArray(inline["stages"]) || inline["stages"].length === 0) {
239
+ return { kind: "bad-stages" };
240
+ }
241
+ return { kind: "ok", rec: inline };
242
+ }
243
+ /** Static verdict→voice table for the flow_inline top gate (the
244
+ * two fully static arms — unknown-keys and missing-id-stages
245
+ * interpolate request values, so their mapping stays in the
246
+ * door). */
247
+ export const FLOW_INLINE_TOP_VOICE = {
248
+ "not-object": "flow body must be a JSON object",
249
+ "bad-stages": "flow stages must be a non-empty list",
250
+ };
251
+ /** Structure-gate one stage row (id legality via FLOW_ID_RE). */
252
+ export function checkFlowStage(st) {
253
+ if (!isRecord(st))
254
+ return { kind: "not-object" };
255
+ const extras = unknownKeys(st, STAGE_KEYS);
256
+ if (extras.length > 0)
257
+ return { kind: "unknown-fields", st, extras };
258
+ const sid = String(st["id"] ?? "");
259
+ if (!FLOW_ID_RE.test(sid))
260
+ return { kind: "bad-id", st };
261
+ return { kind: "ok", st };
262
+ }
263
+ /** Per-field gates as data: key → leaf gate → refusal verdict, in
264
+ * the door's fixed shape-check order. The loop below walks this
265
+ * table; the isRecord pre-guard + unknown-keys arm stay explicit
266
+ * (different shapes, not table rows). */
267
+ const DRAFT_PATCH_FIELDS = [
268
+ ["result", "dict", "bad-result"],
269
+ ["runStatus", "string", "bad-runStatus"],
270
+ ["params", "dict", "bad-params"],
271
+ ["inputs", "list", "bad-inputs"],
272
+ ["inputOutputs", "list", "bad-inputOutputs"],
273
+ ];
274
+ /** Leaf gate by table name. */
275
+ const FIELD_GATES = {
276
+ string: isStringField,
277
+ list: isListField,
278
+ dict: isDictField,
279
+ };
280
+ /** Structure-gate one stage patch value. */
281
+ export function checkDraftPatch(patch) {
282
+ if (!isRecord(patch))
283
+ return { kind: "not-object" };
284
+ const unknown = unknownKeys(patch, STAGE_PATCH_KEYS);
285
+ if (unknown.length > 0)
286
+ return { kind: "unknown-keys", unknown };
287
+ for (const [key, gate, verdict] of DRAFT_PATCH_FIELDS) {
288
+ if (key in patch && !FIELD_GATES[gate](patch[key])) {
289
+ return { kind: verdict };
290
+ }
291
+ }
292
+ return { kind: "ok", patch };
293
+ }
294
+ /** Static verdict→voice table for the stage-patch gate (every arm
295
+ * but unknown-keys is fully static — the door does one lookup for
296
+ * those; unknown-keys interpolates the request keys, so its
297
+ * mapping stays in the door). */
298
+ export const DRAFT_PATCH_VOICE = {
299
+ "not-object": "patch body must be an object",
300
+ "bad-result": "stage patch 'result' must be dict",
301
+ "bad-runStatus": "stage patch 'runStatus' must be str",
302
+ "bad-params": "stage patch 'params' must be dict",
303
+ "bad-inputs": "stage patch 'inputs' must be list",
304
+ "bad-inputOutputs": "stage patch 'inputOutputs' must be list",
305
+ };
306
+ //# sourceMappingURL=runsGates.js.map
@@ -0,0 +1,78 @@
1
+ /** Leading-int read (sidecar tails): optional space, optional
2
+ * sign, then digits; 0 when no digits lead. */
3
+ export declare function parseLeadingInt(s: string): number;
4
+ /** sidecar_num: first `"key":`, strtol the tail, default when the key is absent. */
5
+ export declare function sidecarNum(text: string, key: string, dflt: number): number;
6
+ /** sidecar_str: BYTE-wise exact — first `"key":`, skip spaces/tabs, expect `"`, decode \\n \\r \\t \" \\ (any other escape lands literally — \u stays "u"), stop at cap-1 BYTES. Operates on the UTF-8 bytes (D5). */
7
+ export declare function sidecarStr(raw: Uint8Array, key: string, cap: number): string;
8
+ /** _sidecar_str_impl found-ness: only the runs-list status site reads it — a present-but-empty "status" serves "" (the gate then skips the row), while an absent/non-string key serves "unknown". */
9
+ export declare function sidecarStrFound(raw: Uint8Array, key: string, cap: number): [boolean, string];
10
+ export declare function artifactType(name: string): string;
11
+ interface MediaCand {
12
+ readonly rel: string;
13
+ readonly full: string;
14
+ }
15
+ /** _media_candidates: top-level files (non-underscore) then ONE level down (underscore + deeper dirs skipped), each tier byte-sorted. */
16
+ export declare function mediaCandidates(runDir: string): MediaCand[];
17
+ /** run_artifacts: image/video/audio/model rows (image capped at _MAX_IMGS — counted but unlisted past it), everything else skipped; the {truncated,listed,total} marker when entries went unlisted. */
18
+ /** path keeps the "./output/<run>/" literal. */
19
+ export declare function runArtifacts(runDir: string, outDirLiteral: string): Record<string, unknown>[];
20
+ /** _run_thumbnail: cached poster wins, else the first image candidate (same one-level rule, so nested-only runs still get a poster). */
21
+ export declare function runThumbnail(runDir: string, runId: string): string;
22
+ /** _run_dir_has_media: the media-FIRST sort key — top-level names, then one level down. */
23
+ /** NOTE the absences: NO `_` skip (a lone `_poster.jpg` counts), NO inner isdir check (a nested DIR named x.mp4 counts) — probed live, mirrored exactly. */
24
+ /** Gallery sets only (svg/bmp classify but do not list — the media-kinds.json contract). */
25
+ export declare function runDirHasMedia(runDir: string): boolean;
26
+ /** The RunRow gate — the row dict, or null when the gate refuses it (the caller logs LOUD and skips). */
27
+ /** Key order is the RunRow field order. */
28
+ export declare function runRowOrNull(row: {
29
+ run_id: string;
30
+ name: string;
31
+ flow: string;
32
+ status: string;
33
+ created_at: number;
34
+ prompt: string;
35
+ seed: number;
36
+ thumbnail: string;
37
+ artifacts: Record<string, unknown>[];
38
+ params: Record<string, unknown>;
39
+ draft_id: string;
40
+ /** THE STAGE-ID DIGEST (commission 015, §6 finding 6): the ids
41
+ * of the stages the run composed. Optional — older sidecars
42
+ * predate the digest, and such runs cannot name their stages. */
43
+ stage_ids?: string[];
44
+ /** THE EXPORT NAME (023's self-critique #4/#6): optional —
45
+ * older sidecars predate it, and only export lanes stamp it. */
46
+ export_name?: string;
47
+ /** THE EXPORT PATH (the export FULL PATH): optional — the
48
+ * engine-reported minted .qvoice absolute path; older sidecars
49
+ * predate it, load lanes stamp nothing. */
50
+ export_path?: string;
51
+ }): Record<string, unknown> | null;
52
+ /** Strict int parse: surrounding whitespace stripped, one optional
53
+ * sign, ASCII digits with single internal underscores ("1_0" ->
54
+ * 10). null = not an int (the 400 arm). */
55
+ export declare function parseIntOrNull(s: string): number | null;
56
+ /** parse_qs (drops blank values): first non-blank
57
+ * value wins; the shared ctx parseQuery keeps blanks, so the
58
+ * filter lives here (parse_qs default). */
59
+ export declare function firstQuery(qs: Record<string, string[]>, name: string, dflt: string): string;
60
+ /** The runs-list envelope (the restore port): the output-root scan, media-first + newest sort, the limit parse (raw STRING — the lane/remote pass the raw text; underscores parse, non-ints refuse), refused cards SKIPPED but counted. */
61
+ /** url/thumbnail are run-RELATIVE (the /v1/assets prefix died with the app — the header's law). */
62
+ export declare function listRuns(stateRoot: string, limit: number, hasDraft: (draftId: string) => Promise<boolean>): Promise<{
63
+ count: number;
64
+ runs: Record<string, unknown>[];
65
+ }>;
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+ export declare function listRunsAcross(roots: string[], limit: number, hasDraft: (draftId: string) => Promise<boolean>): Promise<{
74
+ count: number;
75
+ runs: Record<string, unknown>[];
76
+ }>;
77
+ export {};
78
+ //# sourceMappingURL=runsList.d.ts.map