@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.
- package/LICENSE +557 -0
- package/lib/bakeParams.d.ts +17 -0
- package/lib/bakeParams.js +182 -0
- package/lib/bench.d.ts +24 -0
- package/lib/bench.js +121 -0
- package/lib/cardsArmError.d.ts +18 -0
- package/lib/cardsArmError.js +33 -0
- package/lib/cardsCompose.d.ts +41 -0
- package/lib/cardsCompose.js +247 -0
- package/lib/cardsDangling.d.ts +16 -0
- package/lib/cardsDangling.js +168 -0
- package/lib/cardsFacts.d.ts +74 -0
- package/lib/cardsFacts.js +64 -0
- package/lib/cardsLanes.d.ts +33 -0
- package/lib/cardsLanes.js +115 -0
- package/lib/cardsRegistry.d.ts +316 -0
- package/lib/cardsRegistry.js +1274 -0
- package/lib/cardsVariant.d.ts +28 -0
- package/lib/cardsVariant.js +190 -0
- package/lib/discloseRegistry.d.ts +94 -0
- package/lib/discloseRegistry.js +154 -0
- package/lib/filmLead.d.ts +4 -0
- package/lib/filmLead.js +17 -0
- package/lib/filmMemoryWarn.d.ts +27 -0
- package/lib/filmMemoryWarn.js +99 -0
- package/lib/flowsData.d.ts +179 -0
- package/lib/flowsData.js +547 -0
- package/lib/flowsFamilyCompose.d.ts +48 -0
- package/lib/flowsFamilyCompose.js +191 -0
- package/lib/flowsRegistryRows.d.ts +10 -0
- package/lib/flowsRegistryRows.js +378 -0
- package/lib/index.d.ts +50 -0
- package/lib/index.js +66 -0
- package/lib/ledgerTail.d.ts +20 -0
- package/lib/ledgerTail.js +123 -0
- package/lib/loadPlane.d.ts +93 -0
- package/lib/loadPlane.js +553 -0
- package/lib/loadRegistry.d.ts +22 -0
- package/lib/loadRegistry.js +55 -0
- package/lib/manageOps.d.ts +21 -0
- package/lib/manageOps.js +142 -0
- package/lib/managePlane.d.ts +120 -0
- package/lib/managePlane.js +1515 -0
- package/lib/manageProbe.d.ts +57 -0
- package/lib/manageProbe.js +154 -0
- package/lib/manageRegistry.d.ts +28 -0
- package/lib/manageRegistry.js +75 -0
- package/lib/managerRail.d.ts +33 -0
- package/lib/managerRail.js +91 -0
- package/lib/mediaKinds.d.ts +3 -0
- package/lib/mediaKinds.js +2 -0
- package/lib/queue.d.ts +9 -0
- package/lib/queue.js +76 -0
- package/lib/queueCore.d.ts +69 -0
- package/lib/queueCore.js +124 -0
- package/lib/queueLifecycle.d.ts +26 -0
- package/lib/queueLifecycle.js +65 -0
- package/lib/queueLock.d.ts +54 -0
- package/lib/queueLock.js +195 -0
- package/lib/queueResurrect.d.ts +59 -0
- package/lib/queueResurrect.js +249 -0
- package/lib/queueRetry.d.ts +36 -0
- package/lib/queueRetry.js +24 -0
- package/lib/queueSidecar.d.ts +145 -0
- package/lib/queueSidecar.js +182 -0
- package/lib/queueSubmit.d.ts +31 -0
- package/lib/queueSubmit.js +117 -0
- package/lib/queueSweep.d.ts +30 -0
- package/lib/queueSweep.js +121 -0
- package/lib/resurrect.d.ts +6 -0
- package/lib/resurrect.js +18 -0
- package/lib/rootsManifest.d.ts +11 -0
- package/lib/rootsManifest.js +11 -0
- package/lib/runStatus.d.ts +7 -0
- package/lib/runStatus.js +21 -0
- package/lib/runsChange.d.ts +53 -0
- package/lib/runsChange.js +63 -0
- package/lib/runsErrorCodes.d.ts +2 -0
- package/lib/runsErrorCodes.js +15 -0
- package/lib/runsExecute.d.ts +26 -0
- package/lib/runsExecute.js +356 -0
- package/lib/runsGates.d.ts +161 -0
- package/lib/runsGates.js +306 -0
- package/lib/runsList.d.ts +78 -0
- package/lib/runsList.js +580 -0
- package/lib/runsRefusalVoices.d.ts +9 -0
- package/lib/runsRefusalVoices.js +44 -0
- package/lib/runsRegistry.d.ts +253 -0
- package/lib/runsRegistry.js +1750 -0
- package/lib/runsSourceEcho.d.ts +54 -0
- package/lib/runsSourceEcho.js +275 -0
- package/lib/runsStart.d.ts +121 -0
- package/lib/runsStart.js +528 -0
- package/lib/runsTypes.d.ts +183 -0
- package/lib/runsTypes.js +282 -0
- package/lib/runsValidate.d.ts +5 -0
- package/lib/runsValidate.js +31 -0
- package/lib/runsValidateArms.d.ts +7 -0
- package/lib/runsValidateArms.js +285 -0
- package/lib/runsValidateInline.d.ts +6 -0
- package/lib/runsValidateInline.js +82 -0
- package/lib/runsValidateRefusals.d.ts +7 -0
- package/lib/runsValidateRefusals.js +18 -0
- package/lib/runsValidateServe.d.ts +15 -0
- package/lib/runsValidateServe.js +254 -0
- package/lib/runsValidateShared.d.ts +84 -0
- package/lib/runsValidateShared.js +88 -0
- package/lib/runsValidateStages.d.ts +25 -0
- package/lib/runsValidateStages.js +491 -0
- package/lib/runsValidateSweeps.d.ts +6 -0
- package/lib/runsValidateSweeps.js +143 -0
- package/lib/service.d.ts +45 -0
- package/lib/service.js +81 -0
- package/lib/skillFrontmatter.d.ts +11 -0
- package/lib/skillFrontmatter.js +46 -0
- package/lib/skillFs.d.ts +19 -0
- package/lib/skillFs.js +80 -0
- package/lib/skillPlane.d.ts +98 -0
- package/lib/skillPlane.js +263 -0
- package/lib/skillRegistry.d.ts +23 -0
- package/lib/skillRegistry.js +55 -0
- package/lib/skillRows.d.ts +126 -0
- package/lib/skillRows.js +466 -0
- package/lib/toolProjection.d.ts +30 -0
- package/lib/toolProjection.js +142 -0
- package/lib/vocab.d.ts +6 -0
- package/lib/vocab.js +18 -0
- package/package.json +47 -4
- package/README.md +0 -3
package/lib/service.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
import { QueueCore } from "./queue.js";
|
|
4
|
+
import type { LedgerTailAnswer } from "./ledgerTail.js";
|
|
5
|
+
/** Provider config: where the estate's run state lives. */
|
|
6
|
+
export interface QueueConfig {
|
|
7
|
+
/** Repo root for the default `data/runs` state root (the
|
|
8
|
+
* MELITE_STATE_ROOT override wins, unchanged). */
|
|
9
|
+
repoRoot?: string;
|
|
10
|
+
}
|
|
11
|
+
declare module "@deepseek-ai/cordis" {
|
|
12
|
+
interface Context {
|
|
13
|
+
queue: QueueService;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** The serial-GPU queue seat: `ctx.queue`. */
|
|
17
|
+
export declare class QueueService extends Service {
|
|
18
|
+
#private;
|
|
19
|
+
static inject: string[];
|
|
20
|
+
/** The run-state root this fiber owns (lock + ledger + outdirs). */
|
|
21
|
+
readonly stateRoot: string;
|
|
22
|
+
/** §23 CROSS-ROOTS manifest (own root first, then
|
|
23
|
+
* MELITE_STATE_ROOTS, colon-separated): the run-resolving doors
|
|
24
|
+
* walk it, and the seat carries it so consumers (the media door)
|
|
25
|
+
* read one law instead of re-deriving their own. */
|
|
26
|
+
readonly stateRoots: string[];
|
|
27
|
+
/** The boot gate's verdict trail (acquired | stolen-from-dead). */
|
|
28
|
+
readonly lockNote: string;
|
|
29
|
+
/** The in-memory serial registry (runs + FIFO order + active). */
|
|
30
|
+
readonly core: QueueCore;
|
|
31
|
+
constructor(ctx: Context, config?: QueueConfig);
|
|
32
|
+
/** The journal path under this service's root (readers + the
|
|
33
|
+
* runs remote's list arm). */
|
|
34
|
+
get ledgerPath(): string;
|
|
35
|
+
/** The journal tail (REBUILD-19; the dead GET /v1/ledger arm —
|
|
36
|
+
* the doors/assets.ts _h_ledger law rides verbatim): limit
|
|
37
|
+
* default 50 / clamp 1..500 / garbage -> 50, event prefix on
|
|
38
|
+
* the raw line, oldest -> newest within the tail. §23
|
|
39
|
+
* CROSS-ROOTS: every manifest root's journal merges into one
|
|
40
|
+
* timeline and the answer names the searched roots. */
|
|
41
|
+
ledger(rawLimit: string, rawEvent: string): LedgerTailAnswer;
|
|
42
|
+
/** Whether dispose already released our lock (test probe). */
|
|
43
|
+
get released(): boolean;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=service.d.ts.map
|
package/lib/service.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// service.ts — the serial run queue as a HOST Cordis service
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
// The queue survives the gateway kill as the estate's own service:
|
|
5
|
+
// the lock-first single-writer law (acquire BEFORE any boot side
|
|
6
|
+
// effect; a second writer exits here, LOUD, having touched nothing)
|
|
7
|
+
// rides the fiber lifecycle — `ctx.effect` releases only OUR pid's
|
|
8
|
+
// lock on dispose (the watcher-storm lesson: a blind unlink steals
|
|
9
|
+
// + boot-sweeps LIVE runs). The door mounts are DEAD: this service
|
|
10
|
+
// mounts nothing, registers no routes, owns no port. The runs
|
|
11
|
+
// remote (a later stroke) exposes the unary lanes over this seat.
|
|
12
|
+
//
|
|
13
|
+
// The service is thin on purpose: it owns the ROOT, the LOCK, and
|
|
14
|
+
// the QueueCore registry; the FIFO's worker/pump wiring lands with
|
|
15
|
+
// the runs remote (LAW 2 — one stroke, one wall).
|
|
16
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
17
|
+
import { QueueCore, bootGate, ledgerPathFor, releaseLock, resolveStateRoot, } from "./queue.js";
|
|
18
|
+
import { tailLedgerAcross } from "./ledgerTail.js";
|
|
19
|
+
import { rootsManifest } from "./rootsManifest.js";
|
|
20
|
+
/** The serial-GPU queue seat: `ctx.queue`. */
|
|
21
|
+
export class QueueService extends Service {
|
|
22
|
+
static inject = ["timer"];
|
|
23
|
+
/** The run-state root this fiber owns (lock + ledger + outdirs). */
|
|
24
|
+
stateRoot;
|
|
25
|
+
/** §23 CROSS-ROOTS manifest (own root first, then
|
|
26
|
+
* MELITE_STATE_ROOTS, colon-separated): the run-resolving doors
|
|
27
|
+
* walk it, and the seat carries it so consumers (the media door)
|
|
28
|
+
* read one law instead of re-deriving their own. */
|
|
29
|
+
stateRoots;
|
|
30
|
+
/** The boot gate's verdict trail (acquired | stolen-from-dead). */
|
|
31
|
+
lockNote;
|
|
32
|
+
/** The in-memory serial registry (runs + FIFO order + active). */
|
|
33
|
+
core = new QueueCore();
|
|
34
|
+
#released = false;
|
|
35
|
+
constructor(ctx, config = {}) {
|
|
36
|
+
super(ctx, "queue");
|
|
37
|
+
// THE ROOT PIN (stroke 45c, the operator's catch): the cwd
|
|
38
|
+
// fallback was the-gateway's accidental law — a lane booted
|
|
39
|
+
// from any other directory silently birthed an EMPTY runs tree
|
|
40
|
+
// (200-empty listings, no error: the exact silent drop this
|
|
41
|
+
// estate refuses). The root must be NAMED: config.repoRoot or
|
|
42
|
+
// MELITE_STATE_ROOT; anything else refuses at boot, loud.
|
|
43
|
+
if ((config.repoRoot ?? "") === "" && (process.env["MELITE_STATE_ROOT"] ?? "") === "") {
|
|
44
|
+
throw new Error("[queue] the runs state root is unpinned — set the queue config's repoRoot (the profile's plugin config) or MELITE_STATE_ROOT; refusing to guess from the process cwd (a wrong cwd silently serves an empty runs tree)");
|
|
45
|
+
}
|
|
46
|
+
this.stateRoot = resolveStateRoot(config.repoRoot ?? process.cwd());
|
|
47
|
+
this.stateRoots = rootsManifest(this.stateRoot);
|
|
48
|
+
// Pre-boot gate (main 4474-4480 heritage): BEFORE any boot side
|
|
49
|
+
// effect. A held-by-live-pid lock refuses HERE — the throw is
|
|
50
|
+
// the loud exit, not a fallback.
|
|
51
|
+
const gate = bootGate(this.stateRoot);
|
|
52
|
+
if (!gate.ok) {
|
|
53
|
+
throw new Error("estate-queue: " + gate.note + " (state root " + this.stateRoot + ")");
|
|
54
|
+
}
|
|
55
|
+
this.lockNote = gate.note;
|
|
56
|
+
// PID-checked release on fiber dispose — only our own lock.
|
|
57
|
+
this.ctx.effect(() => () => {
|
|
58
|
+
this.#released = true;
|
|
59
|
+
releaseLock(this.stateRoot);
|
|
60
|
+
}, "estate-queue.lock");
|
|
61
|
+
}
|
|
62
|
+
/** The journal path under this service's root (readers + the
|
|
63
|
+
* runs remote's list arm). */
|
|
64
|
+
get ledgerPath() {
|
|
65
|
+
return ledgerPathFor(this.stateRoot);
|
|
66
|
+
}
|
|
67
|
+
/** The journal tail (REBUILD-19; the dead GET /v1/ledger arm —
|
|
68
|
+
* the doors/assets.ts _h_ledger law rides verbatim): limit
|
|
69
|
+
* default 50 / clamp 1..500 / garbage -> 50, event prefix on
|
|
70
|
+
* the raw line, oldest -> newest within the tail. §23
|
|
71
|
+
* CROSS-ROOTS: every manifest root's journal merges into one
|
|
72
|
+
* timeline and the answer names the searched roots. */
|
|
73
|
+
ledger(rawLimit, rawEvent) {
|
|
74
|
+
return tailLedgerAcross(rootsManifest(this.stateRoot), rawLimit, rawEvent);
|
|
75
|
+
}
|
|
76
|
+
/** Whether dispose already released our lock (test probe). */
|
|
77
|
+
get released() {
|
|
78
|
+
return this.#released;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SkillRow, StepRow } from "./skillPlane.js";
|
|
2
|
+
export declare function frontmatter(text: string): {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
6
|
+
/** SkillRow constructor (lane_wire 190-226 shapes the row): the
|
|
7
|
+
* callers pre-gate — readDoc builds valid doc rows (exactly one of
|
|
8
|
+
* card/model, paired steps), flowRows pre-checks stages — so the
|
|
9
|
+
* refusal arms have no live caller and are not built here. */
|
|
10
|
+
export declare function gateSkill(id: string, name: string, description: string, scope: string, genre: string | null, card: string | null, model: string | null, steps: StepRow[] | null, stepCount: number | null): SkillRow;
|
|
11
|
+
//# sourceMappingURL=skillFrontmatter.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// frontmatter (lane_disclosure 110-127)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
const FM_RE = /^---\s*\n([\s\S]*?)\n---\s*\n?/;
|
|
5
|
+
const KV_RE = /^(name|description):\s*([\s\S]+?)\s*$/;
|
|
6
|
+
export function frontmatter(text) {
|
|
7
|
+
let name = "";
|
|
8
|
+
let description = "";
|
|
9
|
+
const m = FM_RE.exec(text);
|
|
10
|
+
if (m !== null) {
|
|
11
|
+
for (const line of m[1].split("\n")) {
|
|
12
|
+
const kv = KV_RE.exec(line);
|
|
13
|
+
if (kv !== null) {
|
|
14
|
+
// .strip('"\'') strips ALL leading/trailing quote chars.
|
|
15
|
+
const val = kv[2].replace(/^["']+|["']+$/g, "");
|
|
16
|
+
if (kv[1] === "name")
|
|
17
|
+
name = val;
|
|
18
|
+
else
|
|
19
|
+
description = val;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (name === "") {
|
|
24
|
+
const h = /^#\s+(.+)$/m.exec(text);
|
|
25
|
+
name = h !== null ? h[1].trim() : "";
|
|
26
|
+
}
|
|
27
|
+
return { name, description };
|
|
28
|
+
}
|
|
29
|
+
/** SkillRow constructor (lane_wire 190-226 shapes the row): the
|
|
30
|
+
* callers pre-gate — readDoc builds valid doc rows (exactly one of
|
|
31
|
+
* card/model, paired steps), flowRows pre-checks stages — so the
|
|
32
|
+
* refusal arms have no live caller and are not built here. */
|
|
33
|
+
export function gateSkill(id, name, description, scope, genre, card, model, steps, stepCount) {
|
|
34
|
+
return {
|
|
35
|
+
id,
|
|
36
|
+
name,
|
|
37
|
+
description,
|
|
38
|
+
scope,
|
|
39
|
+
genre,
|
|
40
|
+
card,
|
|
41
|
+
model,
|
|
42
|
+
steps,
|
|
43
|
+
stepCount,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=skillFrontmatter.js.map
|
package/lib/skillFs.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Underscore card dirs bridge to their registry ids here
|
|
2
|
+
* (dead doors/toolProjection.ts:27-31, verbatim — a future dir
|
|
3
|
+
* rename deletes the row). */
|
|
4
|
+
export declare const DIR_ID_ALIASES: Readonly<Record<string, string>>;
|
|
5
|
+
/** Path.stem: strip the last-dot suffix; dotfiles keep theirs. */
|
|
6
|
+
export declare function stem(name: string): string;
|
|
7
|
+
/** Disclosure root (the REPO the doors read): MELITE_REPO_ROOT else
|
|
8
|
+
* file-anchored (the uploads-door pattern).
|
|
9
|
+
* Exported — the catalogs door anchors the same root (one root
|
|
10
|
+
* function, never duplicated). */
|
|
11
|
+
export declare function disclosureRoot(): string;
|
|
12
|
+
export declare function isDir(p: string): boolean;
|
|
13
|
+
export declare function isFile(p: string): boolean;
|
|
14
|
+
/** Sorted subdir names, NO dot filter (the disclosure walks —
|
|
15
|
+
* _model_rows/_card_rows/_model_ids — never filter dots; only
|
|
16
|
+
* catalog._dirs_under does). D4 over non-ASCII. */
|
|
17
|
+
export declare function subdirs(parent: string): string[];
|
|
18
|
+
export declare function readText(p: string): string | null;
|
|
19
|
+
//# sourceMappingURL=skillFs.d.ts.map
|
package/lib/skillFs.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// skillFs.ts — the skill plane's fs walkers (extracted from
|
|
2
|
+
// skillPlane.ts, the god-file cut): directory/file probes, the
|
|
3
|
+
// dir-id alias bridge, and the one disclosure-root resolution.
|
|
4
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
/** Underscore card dirs bridge to their registry ids here
|
|
8
|
+
* (dead doors/toolProjection.ts:27-31, verbatim — a future dir
|
|
9
|
+
* rename deletes the row). */
|
|
10
|
+
export const DIR_ID_ALIASES = {
|
|
11
|
+
img_to_mesh: "img-to-mesh",
|
|
12
|
+
input_prep: "input-prep",
|
|
13
|
+
mask_studio: "mask-studio",
|
|
14
|
+
};
|
|
15
|
+
/** Path.stem: strip the last-dot suffix; dotfiles keep theirs. */
|
|
16
|
+
export function stem(name) {
|
|
17
|
+
const i = name.lastIndexOf(".");
|
|
18
|
+
if (i <= 0)
|
|
19
|
+
return name;
|
|
20
|
+
return name.slice(0, i);
|
|
21
|
+
}
|
|
22
|
+
/** Disclosure root (the REPO the doors read): MELITE_REPO_ROOT else
|
|
23
|
+
* file-anchored (the uploads-door pattern).
|
|
24
|
+
* Exported — the catalogs door anchors the same root (one root
|
|
25
|
+
* function, never duplicated). */
|
|
26
|
+
export function disclosureRoot() {
|
|
27
|
+
const override = process.env["MELITE_REPO_ROOT"] ?? "";
|
|
28
|
+
if (override !== "")
|
|
29
|
+
return override;
|
|
30
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
31
|
+
// 4 up from estate-queue/src/ (the REBUILD-16 re-home shallowed the
|
|
32
|
+
// tree — the ported 5-up anchor read the parent of the repo until
|
|
33
|
+
|
|
34
|
+
return resolve(here, "..", "..", "..", "..");
|
|
35
|
+
}
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// fs helpers (stdlib move-for-move)
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
export function isDir(p) {
|
|
40
|
+
try {
|
|
41
|
+
return statSync(p).isDirectory();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function isFile(p) {
|
|
48
|
+
try {
|
|
49
|
+
return statSync(p).isFile();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Sorted subdir names, NO dot filter (the disclosure walks —
|
|
56
|
+
* _model_rows/_card_rows/_model_ids — never filter dots; only
|
|
57
|
+
* catalog._dirs_under does). D4 over non-ASCII. */
|
|
58
|
+
export function subdirs(parent) {
|
|
59
|
+
let names;
|
|
60
|
+
try {
|
|
61
|
+
names = readdirSync(parent);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
return names
|
|
69
|
+
.filter((n) => isDir(join(parent, n)))
|
|
70
|
+
.sort();
|
|
71
|
+
}
|
|
72
|
+
export function readText(p) {
|
|
73
|
+
try {
|
|
74
|
+
return readFileSync(p, "utf8");
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=skillFs.js.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
|
|
2
|
+
export { disclosureRoot } from "./skillFs.js";
|
|
3
|
+
export { engineDirs, modelRows, cardRows, flowRows } from "./skillRows.js";
|
|
4
|
+
/** A wire-contract refusal the disclosure engine could not
|
|
5
|
+
* construct around — the doors translate it to a structured 500
|
|
6
|
+
* (lane_disclosure.LaneWireError 100-102; the class NAME rides the
|
|
7
|
+
* boot error text via _section, so it stays "LaneWireError"). */
|
|
8
|
+
export declare class LaneWireError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export interface ManifestRow {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly version: number;
|
|
14
|
+
readonly kind: string;
|
|
15
|
+
readonly card: string;
|
|
16
|
+
readonly flow: string;
|
|
17
|
+
readonly model: string | null;
|
|
18
|
+
readonly stageTitle: string;
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly paramsSchema: {
|
|
21
|
+
readonly type: string;
|
|
22
|
+
readonly properties: Record<string, unknown>;
|
|
23
|
+
readonly required?: string[];
|
|
24
|
+
};
|
|
25
|
+
readonly hidden: boolean | null;
|
|
26
|
+
}
|
|
27
|
+
export interface StepRow {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly type: string;
|
|
30
|
+
readonly plugin: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SkillRow {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly description: string;
|
|
36
|
+
readonly scope: string;
|
|
37
|
+
readonly genre: string | null;
|
|
38
|
+
readonly card: string | null;
|
|
39
|
+
readonly model: string | null;
|
|
40
|
+
readonly steps: StepRow[] | null;
|
|
41
|
+
readonly stepCount: number | null;
|
|
42
|
+
}
|
|
43
|
+
/** The served skill shape (SkillRow.wire 224-226): exclude_none in
|
|
44
|
+
* FIELD order. */
|
|
45
|
+
export declare function wireSkill(r: SkillRow): Record<string, unknown>;
|
|
46
|
+
export interface DocRow {
|
|
47
|
+
readonly row: SkillRow;
|
|
48
|
+
readonly path: string;
|
|
49
|
+
/** The inline body for a row that has no file — a flow whose text
|
|
50
|
+
* comes from the registry, and the synthesized family lane
|
|
51
|
+
* (skillRows.modelFamilyLane). Absent means the file is the body. */
|
|
52
|
+
readonly bodyText?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export interface BindingRow {
|
|
70
|
+
readonly id: string;
|
|
71
|
+
readonly genre: string | null;
|
|
72
|
+
readonly skills: number;
|
|
73
|
+
readonly entrance: string | null;
|
|
74
|
+
}
|
|
75
|
+
export declare function buildSkillIndex(repo: string): Record<string, unknown>;
|
|
76
|
+
/** The inline agent block (lane_disclosure._agent_block 780-793):
|
|
77
|
+
|
|
78
|
+
/** Skill lookup across flow + model + card rows
|
|
79
|
+
* (lane_disclosure.melite_skill_read 844-863). Flow rows may carry the
|
|
80
|
+
* rendered registry text (bodyText) instead of a file path. */
|
|
81
|
+
/** @param modelsSeat the context's models service when mounted — the
|
|
82
|
+
* flow rows compose from the seat the runs doors thread (the
|
|
83
|
+
* lane-seat law); the booted singleton otherwise */
|
|
84
|
+
export declare function findSkill(repo: string, sid: string, modelsSeat?: FamilyModelsSeat | null): {
|
|
85
|
+
row: SkillRow;
|
|
86
|
+
path: string | null;
|
|
87
|
+
bodyText: string | null;
|
|
88
|
+
} | null;
|
|
89
|
+
/** GET /v1/skills/*: flow rows first, then model+card rows;
|
|
90
|
+
* success ledgers skill.read (compact envelope — queue.ts
|
|
91
|
+
* appendLedger). */
|
|
92
|
+
/** @param modelsSeat the context's models service when mounted (the
|
|
93
|
+
* same seat-threading law as findSkill) */
|
|
94
|
+
export declare function hSkillRead(repo: string, stateRoot: string, sid: string, modelsSeat?: FamilyModelsSeat | null): {
|
|
95
|
+
status: number;
|
|
96
|
+
payload: unknown;
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=skillPlane.d.ts.map
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// skillPlane.ts — the skills plane, RE-HOMED (REBUILD-16,
|
|
2
|
+
|
|
3
|
+
// with the gateway app) port here BESIDE their peers — the skill
|
|
4
|
+
// INDEX (GET /v1/skills), the skill READ (GET /v1/skills/:id),
|
|
5
|
+
// the doc-tree walkers (modelRows / cardRows / engineDirs), the
|
|
6
|
+
// SkillRow gate + wire shape, and the flow rows (LEVEL 4: one
|
|
7
|
+
// gated row per registry declaration). The contiguous spans
|
|
8
|
+
// planes.ts:151-1090 (errors/fmt/flow decls/fs/walks) and
|
|
9
|
+
// 1195-1260 (FlowRow + registryBody + flowRows) port wholesale
|
|
10
|
+
// the manifest/orientation block between them (the lane-bundle
|
|
11
|
+
// machinery) is the LOAD stroke's
|
|
12
|
+
// meat, not the skills'. The skill.read ledger ride is preserved
|
|
13
|
+
// (appendLedger → the queue core's own seam, gateway ledger
|
|
14
|
+
// 2241-2250).
|
|
15
|
+
//
|
|
16
|
+
// Erasable-syntax TS only (node --experimental-strip-types).
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { benchPicksSync } from "./bench.js";
|
|
20
|
+
import { appendLedger } from "./queue.js";
|
|
21
|
+
import { engineDirs, modelRows, cardRows, flowRows } from "./skillRows.js";
|
|
22
|
+
// the extracted planes re-export through the skill plane's door
|
|
23
|
+
export { disclosureRoot } from "./skillFs.js";
|
|
24
|
+
export { engineDirs, modelRows, cardRows, flowRows } from "./skillRows.js";
|
|
25
|
+
/** A wire-contract refusal the disclosure engine could not
|
|
26
|
+
* construct around — the doors translate it to a structured 500
|
|
27
|
+
* (lane_disclosure.LaneWireError 100-102; the class NAME rides the
|
|
28
|
+
* boot error text via _section, so it stays "LaneWireError"). */
|
|
29
|
+
export class LaneWireError extends Error {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "LaneWireError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The served skill shape (SkillRow.wire 224-226): exclude_none in
|
|
36
|
+
* FIELD order. */
|
|
37
|
+
export function wireSkill(r) {
|
|
38
|
+
const out = {
|
|
39
|
+
id: r.id,
|
|
40
|
+
name: r.name,
|
|
41
|
+
description: r.description,
|
|
42
|
+
scope: r.scope,
|
|
43
|
+
};
|
|
44
|
+
if (r.genre !== null)
|
|
45
|
+
out["genre"] = r.genre;
|
|
46
|
+
if (r.card !== null)
|
|
47
|
+
out["card"] = r.card;
|
|
48
|
+
if (r.model !== null)
|
|
49
|
+
out["model"] = r.model;
|
|
50
|
+
if (r.steps !== null) {
|
|
51
|
+
out["steps"] = r.steps.map((s) => ({
|
|
52
|
+
id: s.id,
|
|
53
|
+
type: s.type,
|
|
54
|
+
plugin: s.plugin,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
if (r.stepCount !== null)
|
|
58
|
+
out["step_count"] = r.stepCount;
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export function buildSkillIndex(repo) {
|
|
62
|
+
const engines = engineDirs(join(repo, "packages", "engines"));
|
|
63
|
+
const families = new Map();
|
|
64
|
+
const cards = new Map();
|
|
65
|
+
let count = 0;
|
|
66
|
+
try {
|
|
67
|
+
|
|
68
|
+
// LIVE BENCH's picks only — the cards composed this session and
|
|
69
|
+
// the families they name. An empty bench lists NOTHING: the
|
|
70
|
+
// vocabulary door is melite_discover (a paid tool call), never
|
|
71
|
+
// this index. The full-catalog dump below was the last leak —
|
|
72
|
+
// it handed the agent every card entrance for one cheap scan.
|
|
73
|
+
void repo;
|
|
74
|
+
const picks = benchPicksSync();
|
|
75
|
+
const pickedCards = new Set(picks.map((p) => p.card).filter((c) => c !== null));
|
|
76
|
+
const pickedModels = new Set(picks.map((p) => p.model).filter((m) => m !== null));
|
|
77
|
+
const selectionEmpty = pickedCards.size === 0 && pickedModels.size === 0;
|
|
78
|
+
// flows ride ONLY from the bench — and bench stages carry cards,
|
|
79
|
+
// never flows; flow discovery is melite_discover's paid plane
|
|
80
|
+
if (selectionEmpty) {
|
|
81
|
+
return {
|
|
82
|
+
count: 0,
|
|
83
|
+
families: [],
|
|
84
|
+
cards: [],
|
|
85
|
+
flows: { count: 0, ids: [] },
|
|
86
|
+
note: "THE CATALOG IS THE SELECTION — nothing is listed while the bench is empty; call melite_discover (the paid door) to find a card or flow",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
for (const engine of engines) {
|
|
90
|
+
for (const r of modelRows(engine)) {
|
|
91
|
+
if (r.row.scope.endsWith("-spawn"))
|
|
92
|
+
continue;
|
|
93
|
+
const mid = r.row.model;
|
|
94
|
+
if (mid === null || !pickedModels.has(mid))
|
|
95
|
+
continue;
|
|
96
|
+
const cell = families.get(mid) ?? { genre: r.row.genre, skills: 0, entrance: null };
|
|
97
|
+
if (r.row.scope === "model-skill")
|
|
98
|
+
cell.skills += 1;
|
|
99
|
+
// A synthesized family lane IS the entrance for a family that
|
|
100
|
+
// authors no row (skillRows.familyLane) — it names the id the
|
|
101
|
+
// compose refusal tells the agent to read, so it rides the same
|
|
102
|
+
// cell an authored agents/AGENT.md row would. It is an entrance,
|
|
103
|
+
// not a skill: only a `model` row counts.
|
|
104
|
+
if (r.row.scope === "model" || r.row.scope === "model-lane")
|
|
105
|
+
cell.entrance = r.row.id;
|
|
106
|
+
if (r.row.scope === "model-lane") {
|
|
107
|
+
families.set(mid, cell);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
count += 1;
|
|
111
|
+
families.set(mid, cell);
|
|
112
|
+
}
|
|
113
|
+
for (const r of cardRows(engine, repo).rows) {
|
|
114
|
+
if (r.row.scope.endsWith("-spawn"))
|
|
115
|
+
continue;
|
|
116
|
+
const cname = r.row.card;
|
|
117
|
+
if (cname === null || !pickedCards.has(cname))
|
|
118
|
+
continue;
|
|
119
|
+
count += 1;
|
|
120
|
+
const cell = cards.get(cname) ?? { genre: r.row.genre, skills: 0, entrance: null };
|
|
121
|
+
if (r.row.scope === "card-skill")
|
|
122
|
+
cell.skills += 1;
|
|
123
|
+
if (r.row.scope === "card")
|
|
124
|
+
cell.entrance = r.row.id;
|
|
125
|
+
cards.set(cname, cell);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const famRows = [...families.entries()]
|
|
129
|
+
.map(([id, c]) => ({ id, genre: c.genre, skills: c.skills, entrance: c.entrance }))
|
|
130
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
131
|
+
const cardRowsOut = [...cards.entries()]
|
|
132
|
+
.map(([id, c]) => ({ id, genre: c.genre, skills: c.skills, entrance: c.entrance }))
|
|
133
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
134
|
+
return {
|
|
135
|
+
count,
|
|
136
|
+
families: famRows,
|
|
137
|
+
cards: cardRowsOut,
|
|
138
|
+
flows: { count: 0, ids: [] },
|
|
139
|
+
note: "skills bind to their owner — open a card or family with melite_load to see its tier-1 skill lines; this index never lists skill rows",
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (!(e instanceof LaneWireError)) {
|
|
146
|
+
throw new LaneWireError("skills envelope refusal: " + (e instanceof Error ? e.message : String(e)));
|
|
147
|
+
}
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** The inline agent block (lane_disclosure._agent_block 780-793):
|
|
152
|
+
|
|
153
|
+
/** Skill lookup across flow + model + card rows
|
|
154
|
+
* (lane_disclosure.melite_skill_read 844-863). Flow rows may carry the
|
|
155
|
+
* rendered registry text (bodyText) instead of a file path. */
|
|
156
|
+
/** @param modelsSeat the context's models service when mounted — the
|
|
157
|
+
* flow rows compose from the seat the runs doors thread (the
|
|
158
|
+
* lane-seat law); the booted singleton otherwise */
|
|
159
|
+
export function findSkill(repo, sid, modelsSeat) {
|
|
160
|
+
for (const fr of flowRows(repo, modelsSeat)) {
|
|
161
|
+
if (fr.row.id === sid) {
|
|
162
|
+
return { row: fr.row, path: fr.bodyPath, bodyText: fr.bodyText };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const engines = engineDirs(join(repo, "packages", "engines"));
|
|
166
|
+
for (const engine of engines) {
|
|
167
|
+
for (const r of modelRows(engine)) {
|
|
168
|
+
if (r.row.id === sid)
|
|
169
|
+
return { row: r.row, path: r.bodyText === undefined ? r.path : null, bodyText: r.bodyText ?? null };
|
|
170
|
+
}
|
|
171
|
+
for (const r of cardRows(engine, repo).rows) {
|
|
172
|
+
if (r.row.id === sid)
|
|
173
|
+
return { row: r.row, path: r.path, bodyText: null };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
/** GET /v1/skills/*: flow rows first, then model+card rows;
|
|
179
|
+
* success ledgers skill.read (compact envelope — queue.ts
|
|
180
|
+
* appendLedger). */
|
|
181
|
+
/** @param modelsSeat the context's models service when mounted (the
|
|
182
|
+
* same seat-threading law as findSkill) */
|
|
183
|
+
export function hSkillRead(repo, stateRoot, sid, modelsSeat) {
|
|
184
|
+
try {
|
|
185
|
+
const found = findSkill(repo, sid, modelsSeat);
|
|
186
|
+
if (found === null) {
|
|
187
|
+
return { status: 404, payload: { error: "no such skill: " + JSON.stringify(sid) } };
|
|
188
|
+
}
|
|
189
|
+
// THE SPAWN PLANE DOOR LAW: `-spawn` scoped leaves are the
|
|
190
|
+
// spawned subagent's private briefs — the HTTP read door
|
|
191
|
+
// (melite_skill_read, the constructor's tool) refuses them by id;
|
|
192
|
+
// the spawn injection reads them through findSkill directly,
|
|
193
|
+
// never through this door. The refusal NAMES THE SCOPE: the row
|
|
194
|
+
// exists and this reader may not have it, which the absent-skill
|
|
195
|
+
// voice denied (the same 404 text answered a found row and a
|
|
196
|
+
// genuine miss alike).
|
|
197
|
+
if (found.row.scope.endsWith("-spawn")) {
|
|
198
|
+
return {
|
|
199
|
+
status: 404,
|
|
200
|
+
payload: {
|
|
201
|
+
error: "skill " + JSON.stringify(sid) + " is scoped " +
|
|
202
|
+
JSON.stringify(found.row.scope) + " — the spawned subagent's own brief; " +
|
|
203
|
+
"this reader (the constructor session) never serves it",
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
let body;
|
|
208
|
+
if (found.bodyText !== null) {
|
|
209
|
+
body = found.bodyText;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if (found.path === null) {
|
|
216
|
+
return { status: 500, payload: { error: "skill row carries neither body nor path" } };
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
body = readFileSync(found.path, "utf8");
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
status: 500,
|
|
226
|
+
payload: {
|
|
227
|
+
error: "unreadable: " + (e instanceof Error ? e.message : String(e)),
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// SkillDocRow gate (id/name/description/scope/content) —
|
|
233
|
+
// refusal is a code bug (the skill doc refusal). The rows ride
|
|
234
|
+
// the walks (never empty) and "" misses 404 above — the fence
|
|
235
|
+
// never fires, but it stays.
|
|
236
|
+
/* v8 ignore next */
|
|
237
|
+
if (sid.length < 1 ||
|
|
238
|
+
found.row.name.length < 1 ||
|
|
239
|
+
found.row.scope.length < 1) {
|
|
240
|
+
throw new LaneWireError("skill doc refusal (" + sid + "): name: Field required");
|
|
241
|
+
}
|
|
242
|
+
appendLedger(stateRoot, "skill.read", { id: sid });
|
|
243
|
+
return {
|
|
244
|
+
status: 200,
|
|
245
|
+
payload: {
|
|
246
|
+
id: sid,
|
|
247
|
+
name: found.row.name,
|
|
248
|
+
description: found.row.description,
|
|
249
|
+
scope: found.row.scope,
|
|
250
|
+
content: body,
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
if (!(e instanceof LaneWireError))
|
|
259
|
+
throw e;
|
|
260
|
+
return { status: 500, payload: { error: e.message } };
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=skillPlane.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
export declare class SkillDirectoryService extends Service {
|
|
4
|
+
static inject: string[];
|
|
5
|
+
constructor(ctx: Context);
|
|
6
|
+
/** GET /v1/skills — the index (count + wire rows, both planes). */
|
|
7
|
+
index(): Record<string, unknown>;
|
|
8
|
+
/** GET /v1/skills/:id — the doc; 404s answer the door's voice
|
|
9
|
+
* ("no such skill: <id>"), the read ledgers skill.read. */
|
|
10
|
+
read(sid: string, signal: AbortSignal): Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/** The skills row: gates on the queue seat (the ledger seam). */
|
|
13
|
+
export declare const skillProvider: {
|
|
14
|
+
name: string;
|
|
15
|
+
inject: readonly ["queue"];
|
|
16
|
+
apply(ctx: Context): void;
|
|
17
|
+
};
|
|
18
|
+
declare module "@deepseek-ai/cordis" {
|
|
19
|
+
interface Context {
|
|
20
|
+
meliteSkills: SkillDirectoryService;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=skillRegistry.d.ts.map
|