@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.
- package/LICENSE +557 -0
- package/README.md +54 -2
- package/lib/bakeParams.d.ts +17 -0
- package/lib/bakeParams.js +182 -0
- package/lib/bench.d.ts +32 -0
- package/lib/bench.js +111 -0
- package/lib/cardsArmError.d.ts +61 -0
- package/lib/cardsArmError.js +57 -0
- package/lib/cardsCompose.d.ts +53 -0
- package/lib/cardsCompose.js +295 -0
- package/lib/cardsDangling.d.ts +16 -0
- package/lib/cardsDangling.js +213 -0
- package/lib/cardsFacts.d.ts +87 -0
- package/lib/cardsFacts.js +78 -0
- package/lib/cardsLanes.d.ts +43 -0
- package/lib/cardsLanes.js +178 -0
- package/lib/cardsRegistry.d.ts +404 -0
- package/lib/cardsRegistry.js +1543 -0
- package/lib/cardsVariant.d.ts +37 -0
- package/lib/cardsVariant.js +243 -0
- package/lib/discloseRegistry.d.ts +95 -0
- package/lib/discloseRegistry.js +156 -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 +234 -0
- package/lib/flowsData.js +673 -0
- package/lib/flowsFamilyCompose.d.ts +45 -0
- package/lib/flowsFamilyCompose.js +191 -0
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +12 -0
- package/lib/flowsRegistryRows.js +520 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +75 -0
- package/lib/ledgerTail.d.ts +20 -0
- package/lib/ledgerTail.js +123 -0
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +94 -0
- package/lib/loadPlane.js +570 -0
- package/lib/loadRegistry.d.ts +22 -0
- package/lib/loadRegistry.js +55 -0
- package/lib/manageOps.d.ts +27 -0
- package/lib/manageOps.js +162 -0
- package/lib/managePlane.d.ts +151 -0
- package/lib/managePlane.js +1790 -0
- package/lib/manageProbe.d.ts +48 -0
- package/lib/manageProbe.js +165 -0
- package/lib/manageRegistry.d.ts +66 -0
- package/lib/manageRegistry.js +113 -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 +80 -0
- package/lib/queueCore.d.ts +72 -0
- package/lib/queueCore.js +128 -0
- package/lib/queueLifecycle.d.ts +2 -0
- package/lib/queueLifecycle.js +11 -0
- package/lib/queueLock.d.ts +60 -0
- package/lib/queueLock.js +198 -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 +149 -0
- package/lib/queueSidecar.js +183 -0
- package/lib/queueSubmit.d.ts +82 -0
- package/lib/queueSubmit.js +191 -0
- package/lib/queueSweep.d.ts +30 -0
- package/lib/queueSweep.js +132 -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/runsChange.d.ts +61 -0
- package/lib/runsChange.js +79 -0
- package/lib/runsErrorCodes.d.ts +2 -0
- package/lib/runsErrorCodes.js +48 -0
- package/lib/runsExecute.d.ts +52 -0
- package/lib/runsExecute.js +494 -0
- package/lib/runsGates.d.ts +161 -0
- package/lib/runsGates.js +307 -0
- package/lib/runsList.d.ts +78 -0
- package/lib/runsList.js +574 -0
- package/lib/runsRefusalVoices.d.ts +9 -0
- package/lib/runsRefusalVoices.js +96 -0
- package/lib/runsRegistry.d.ts +351 -0
- package/lib/runsRegistry.js +2394 -0
- package/lib/runsSourceEcho.d.ts +81 -0
- package/lib/runsSourceEcho.js +341 -0
- package/lib/runsStart.d.ts +163 -0
- package/lib/runsStart.js +667 -0
- package/lib/runsTypes.d.ts +218 -0
- package/lib/runsTypes.js +289 -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 +339 -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 +276 -0
- package/lib/runsValidateShared.d.ts +84 -0
- package/lib/runsValidateShared.js +88 -0
- package/lib/runsValidateStages.d.ts +32 -0
- package/lib/runsValidateStages.js +511 -0
- package/lib/runsValidateSweeps.d.ts +6 -0
- package/lib/runsValidateSweeps.js +143 -0
- package/lib/service.d.ts +63 -0
- package/lib/service.js +89 -0
- package/lib/skillFrontmatter.d.ts +11 -0
- package/lib/skillFrontmatter.js +46 -0
- package/lib/skillFs.d.ts +24 -0
- package/lib/skillFs.js +78 -0
- package/lib/skillPlane.d.ts +99 -0
- package/lib/skillPlane.js +269 -0
- package/lib/skillRegistry.d.ts +23 -0
- package/lib/skillRegistry.js +55 -0
- package/lib/skillRows.d.ts +127 -0
- package/lib/skillRows.js +468 -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 +48 -4
|
@@ -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
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
// pure plane (skillPlane.ts — the index/read bodies + walkers)
|
|
3
|
+
// answers through a Service. The skill.read ledger ride uses the
|
|
4
|
+
// QUEUE seat's state root (the gateway ledger's own seam).
|
|
5
|
+
//
|
|
6
|
+
// Erasable-syntax TS only (node --experimental-strip-types).
|
|
7
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
8
|
+
import { resolveRepoRoot } from "@melite/comfyui-cordis";
|
|
9
|
+
import { buildSkillIndex, hSkillRead } from "./skillPlane.js";
|
|
10
|
+
// ROLE (cookbook adding-a-package role table): Directory: index/read over skill docs. Key "meliteSkills" —
|
|
11
|
+
|
|
12
|
+
// dsh-skill package registers `super(ctx, "skills")`, and in any
|
|
13
|
+
// dsh-base composition the core service OWNS the name — the tools'
|
|
14
|
+
// ctx.get('skills') probe resolved to the core service and
|
|
15
|
+
// `seats.skills.index is not a function` killed melite_skill_index/melite_skill_read
|
|
16
|
+
// in every real agent mount (the wall's bare composition had no core
|
|
17
|
+
// row, so the collision was invisible there). Namespaced seat names
|
|
18
|
+
// are the law for every estate service that could meet a core twin.
|
|
19
|
+
export class SkillDirectoryService extends Service {
|
|
20
|
+
static inject = ["queue"];
|
|
21
|
+
constructor(ctx) {
|
|
22
|
+
super(ctx, "meliteSkills");
|
|
23
|
+
}
|
|
24
|
+
/** GET /v1/skills — the index (count + wire rows, both planes). */
|
|
25
|
+
index() {
|
|
26
|
+
return buildSkillIndex(resolveRepoRoot());
|
|
27
|
+
}
|
|
28
|
+
/** GET /v1/skills/:id — the doc; 404s answer the door's voice
|
|
29
|
+
* ("no such skill: <id>"), the read ledgers skill.read. */
|
|
30
|
+
read(sid, signal) {
|
|
31
|
+
signal.throwIfAborted();
|
|
32
|
+
const stateRoot = this.ctx.queue.stateRoot;
|
|
33
|
+
// The flow skill bodies compose from the LANE's seat (the
|
|
34
|
+
// lane-seat law): the same read the runs doors thread, so the
|
|
35
|
+
// served body and the composed graph never diverge.
|
|
36
|
+
const answer = hSkillRead(resolveRepoRoot(), stateRoot, sid, this.ctx.get("models"), this.ctx.get("meliteFlows"));
|
|
37
|
+
if (answer.status === 200)
|
|
38
|
+
return answer.payload;
|
|
39
|
+
const err = answer.payload;
|
|
40
|
+
throw new Error(typeof err.error === "string"
|
|
41
|
+
? err.error
|
|
42
|
+
:
|
|
43
|
+
|
|
44
|
+
"skill read failed");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The skills row: gates on the queue seat (the ledger seam). */
|
|
48
|
+
export const skillProvider = {
|
|
49
|
+
name: "estate-skills",
|
|
50
|
+
inject: ["queue"],
|
|
51
|
+
apply(ctx) {
|
|
52
|
+
new SkillDirectoryService(ctx);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=skillRegistry.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { DocRow, SkillRow } from "./skillPlane.js";
|
|
2
|
+
import type { FlowsSeat } from "./flowsData.js";
|
|
3
|
+
import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
|
|
4
|
+
/** One registry headless-tool property, projected to the frozen
|
|
5
|
+
* FlowToolDecl shape (always ptype + description; enum / default /
|
|
6
|
+
* minimum / maximum ride only when the registry declares them —
|
|
7
|
+
* nulls never serve). */
|
|
8
|
+
export declare function projectToolProperties(properties: Record<string, {
|
|
9
|
+
ptype: string;
|
|
10
|
+
description: string;
|
|
11
|
+
default: unknown;
|
|
12
|
+
hasDefault: boolean;
|
|
13
|
+
minimum: number | null;
|
|
14
|
+
maximum: number | null;
|
|
15
|
+
enum: readonly string[] | null;
|
|
16
|
+
}>): Record<string, Record<string, unknown>>;
|
|
17
|
+
interface FlowToolDecl {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly version: number;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly properties: Record<string, Record<string, unknown>>;
|
|
22
|
+
readonly required: string[];
|
|
23
|
+
}
|
|
24
|
+
interface FlowDecl {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly loadError: string | null;
|
|
27
|
+
readonly description: string;
|
|
28
|
+
readonly stages: {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly engine: string;
|
|
31
|
+
}[];
|
|
32
|
+
readonly tool: FlowToolDecl | null;
|
|
33
|
+
readonly skillRefs: string[];
|
|
34
|
+
readonly hasSkillMd: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Flow declarations in registry order (registryFlowNames sorted),
|
|
37
|
+
* with load failures marked (_flow_rows 389-393 skips FlowError
|
|
38
|
+
* silently — the registry is code, so a declaration bug throws LOUD
|
|
39
|
+
* out of expandRegistryFlow instead of marking a row). Skips the
|
|
40
|
+
* registry when flows/ is absent (_flow_rows 387-388: not-a-dir
|
|
41
|
+
* -> []). The headless tool rides the registry declaration
|
|
42
|
+
* verbatim (projected to the frozen row shape); hasSkillMd reads
|
|
43
|
+
* the flows/<id>/SKILL.md leaf live. skillRefs ride the registry
|
|
44
|
+
* declaration (empty today — the frozen refs pointed at the RETIRED flow.py rows and the retired enhance recipes).
|
|
45
|
+
* Those refs resolve nowhere and would only skip-loud. */
|
|
46
|
+
/** @param modelsSeat the context's models service when mounted — the
|
|
47
|
+
* disclosure composes from the SAME seat the runs doors thread (the
|
|
48
|
+
* lane-seat law: the served body and the composed graph must agree;
|
|
49
|
+
* the booted singleton otherwise) */
|
|
50
|
+
export declare function flowDecls(repo: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): FlowDecl[];
|
|
51
|
+
/** One doc -> gated row (lane_disclosure._read_doc 130-152):
|
|
52
|
+
* OSError -> silent None; gate refusal -> LOUD None. */
|
|
53
|
+
export declare function readDoc(path: string, sid: string, scope: string, genre: string | null, card: string | null, model: string | null): DocRow | null;
|
|
54
|
+
/** THE SPAWN PLANE (operator pin, stroke 87): leaves under
|
|
55
|
+
* `agents/spawn/` (dir/SKILL.md, same shape as agents/skills/)
|
|
56
|
+
* are SUBAGENT-ONLY — findSkill resolves their refs for the
|
|
57
|
+
* agent-stage spawn injection (skills[] inlined into the spawned
|
|
58
|
+
* brief at stage start), but buildSkillIndex NEVER lists them:
|
|
59
|
+
* the constructor agent (the main chat session) does not see
|
|
60
|
+
* skills that belong to the spawned doer. The scope suffix
|
|
61
|
+
* `-spawn` is the structural mark; the index filter is the law. */
|
|
62
|
+
export declare function spawnRows(cdir: string, prefix: string, scope: "card-spawn" | "model-spawn", genre: string | null, card: string | null, model: string | null): DocRow[];
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export declare function engineDirs(enginesRoot: string): string[];
|
|
68
|
+
/** LEVEL 1+3 model docs (lane_disclosure._model_rows 259-312):
|
|
69
|
+
* GUIDE.md / agents/AGENT.md / agents/skills/* per model dir. */
|
|
70
|
+
export declare function modelRows(engine: string): DocRow[];
|
|
71
|
+
export interface CardWalk {
|
|
72
|
+
readonly rows: DocRow[];
|
|
73
|
+
readonly buckets: Map<string, {
|
|
74
|
+
dir: string;
|
|
75
|
+
rows: DocRow[];
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export declare function cardUnitDirs(engine: string, repo: string): {
|
|
86
|
+
genre: string;
|
|
87
|
+
cname: string;
|
|
88
|
+
cdir: string;
|
|
89
|
+
}[];
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
export declare function cardRows(engine: string, repo: string): CardWalk;
|
|
98
|
+
export interface FlowRow {
|
|
99
|
+
readonly row: SkillRow;
|
|
100
|
+
readonly bodyPath: string | null;
|
|
101
|
+
readonly bodyText: string | null;
|
|
102
|
+
}
|
|
103
|
+
/** The registry skill body for one flow id (null when the flow
|
|
104
|
+
* has its own SKILL.md or is unknown to the TS registry — the
|
|
105
|
+
* caller falls back to the file path). A registry flow whose
|
|
106
|
+
* declaration fails to expand is an authoring bug: LOUD, never a
|
|
107
|
+
* silent empty body. The family stages compose first (the doors'
|
|
108
|
+
* own order) so the body names the action's derived outputs. */
|
|
109
|
+
/** @param modelsSeat the context's models service when mounted (the
|
|
110
|
+
* same seat-threading law as flowDecls) */
|
|
111
|
+
export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): string | null;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
/** @param modelsSeat the context's models service when mounted (the
|
|
119
|
+
* same seat-threading law as flowDecls) */
|
|
120
|
+
export declare function flowRows(repo: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): FlowRow[];
|
|
121
|
+
export {};
|
|
122
|
+
/** GET /v1/skills body (lane_disclosure.melite_skill_index 633-649). The
|
|
123
|
+
* SPAWN PLANE filter: `-spawn` scoped rows NEVER ride the index —
|
|
124
|
+
* they are the spawned subagent's private leaves (findSkill
|
|
125
|
+
* resolves them for stage-start injection; the constructor's
|
|
126
|
+
* index/listing never sees them — the operator's pin). */
|
|
127
|
+
//# sourceMappingURL=skillRows.d.ts.map
|
package/lib/skillRows.js
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
// skillRows.ts — the skill index's row walkers (extracted from
|
|
2
|
+
// skillPlane.ts): tool properties, flow declarations, doc/spawn
|
|
3
|
+
// rows, engine/model/card/flow rows — module truth over paths.
|
|
4
|
+
import { readdirSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { DIR_ID_ALIASES, isDir, isFile, subdirs, readText, stem } from "./skillFs.js";
|
|
7
|
+
import { frontmatter, gateSkill } from "./skillFrontmatter.js";
|
|
8
|
+
import { LaneWireError } from "./skillPlane.js";
|
|
9
|
+
import { expandRegistryFlow, registrySkillBody, seedFlowsSeat } from "./flowsData.js";
|
|
10
|
+
import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
|
|
11
|
+
/** One registry headless-tool property, projected to the frozen
|
|
12
|
+
* FlowToolDecl shape (always ptype + description; enum / default /
|
|
13
|
+
* minimum / maximum ride only when the registry declares them —
|
|
14
|
+
* nulls never serve). */
|
|
15
|
+
export function projectToolProperties(properties) {
|
|
16
|
+
const out = {};
|
|
17
|
+
for (const [name, p] of Object.entries(properties)) {
|
|
18
|
+
const cell = {
|
|
19
|
+
ptype: p.ptype,
|
|
20
|
+
description: p.description,
|
|
21
|
+
};
|
|
22
|
+
if (p.enum !== null)
|
|
23
|
+
cell["enum"] = [...p.enum];
|
|
24
|
+
if (p.hasDefault)
|
|
25
|
+
cell["default"] = p.default;
|
|
26
|
+
if (p.minimum !== null)
|
|
27
|
+
cell["minimum"] = p.minimum;
|
|
28
|
+
if (p.maximum !== null)
|
|
29
|
+
cell["maximum"] = p.maximum;
|
|
30
|
+
out[name] = cell;
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/** Flow declarations in registry order (registryFlowNames sorted),
|
|
35
|
+
* with load failures marked (_flow_rows 389-393 skips FlowError
|
|
36
|
+
* silently — the registry is code, so a declaration bug throws LOUD
|
|
37
|
+
* out of expandRegistryFlow instead of marking a row). Skips the
|
|
38
|
+
* registry when flows/ is absent (_flow_rows 387-388: not-a-dir
|
|
39
|
+
* -> []). The headless tool rides the registry declaration
|
|
40
|
+
* verbatim (projected to the frozen row shape); hasSkillMd reads
|
|
41
|
+
* the flows/<id>/SKILL.md leaf live. skillRefs ride the registry
|
|
42
|
+
* declaration (empty today — the frozen refs pointed at the RETIRED flow.py rows and the retired enhance recipes).
|
|
43
|
+
* Those refs resolve nowhere and would only skip-loud. */
|
|
44
|
+
/** @param modelsSeat the context's models service when mounted — the
|
|
45
|
+
* disclosure composes from the SAME seat the runs doors thread (the
|
|
46
|
+
* lane-seat law: the served body and the composed graph must agree;
|
|
47
|
+
* the booted singleton otherwise) */
|
|
48
|
+
export function flowDecls(repo, modelsSeat, flowsSeat) {
|
|
49
|
+
const flows = flowsSeat ?? seedFlowsSeat();
|
|
50
|
+
if (!isDir(join(repo, "flows")))
|
|
51
|
+
return [];
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const name of flows.names()) {
|
|
54
|
+
const flow = flows.get(name);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if (flow === undefined)
|
|
58
|
+
continue;
|
|
59
|
+
// Compose before projection (the doors' own order — stroke 4):
|
|
60
|
+
// the family stages' derived outputs and edges render in the
|
|
61
|
+
// served body only when the declarations compose first.
|
|
62
|
+
//
|
|
63
|
+
// A FLOW THAT CANNOT LOAD IS SKIPPED, NOT THROWN (the row's own
|
|
64
|
+
// loadError field, finally written). flowDecls projects EVERY
|
|
65
|
+
|
|
66
|
+
// every skill read on the lane — including a card skill that
|
|
67
|
+
// exists and has nothing to do with it, answered 502 in another
|
|
68
|
+
// flow's words. The broken flow drops out of the index (the
|
|
69
|
+
// discover door will not list what cannot load) and its refusal
|
|
70
|
+
// rides on the row that carries it.
|
|
71
|
+
let expanded;
|
|
72
|
+
try {
|
|
73
|
+
const family = liveFamilySeat(modelsSeat);
|
|
74
|
+
expanded = composeFamilyStages(expandRegistryFlow(flow, flows), family.decls, family.state);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
out.push({
|
|
78
|
+
id: flow.id,
|
|
79
|
+
loadError: e instanceof Error ? e.message : String(e),
|
|
80
|
+
description: flow.description,
|
|
81
|
+
stages: [],
|
|
82
|
+
tool: null,
|
|
83
|
+
skillRefs: [],
|
|
84
|
+
hasSkillMd: false,
|
|
85
|
+
});
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const stages = expanded.stages.map((s) => ({ id: s.id, engine: s.engine }));
|
|
89
|
+
let tool = null;
|
|
90
|
+
if (flow.tool !== null) {
|
|
91
|
+
tool = {
|
|
92
|
+
name: flow.tool.name,
|
|
93
|
+
version: flow.tool.version,
|
|
94
|
+
description: flow.tool.description,
|
|
95
|
+
properties: projectToolProperties(flow.tool.properties),
|
|
96
|
+
required: [...flow.tool.required],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
out.push({
|
|
100
|
+
id: flow.id,
|
|
101
|
+
loadError: null, // composed clean
|
|
102
|
+
description: flow.description,
|
|
103
|
+
stages,
|
|
104
|
+
tool,
|
|
105
|
+
skillRefs: [...flow.skillRefs],
|
|
106
|
+
hasSkillMd: isFile(join(repo, "flows", flow.id, "SKILL.md")),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
/** One doc -> gated row (lane_disclosure._read_doc 130-152):
|
|
112
|
+
* OSError -> silent None; gate refusal -> LOUD None. */
|
|
113
|
+
export function readDoc(path, sid, scope, genre, card, model) {
|
|
114
|
+
const text = readText(path);
|
|
115
|
+
if (text === null)
|
|
116
|
+
return null;
|
|
117
|
+
const fm = frontmatter(text);
|
|
118
|
+
// (split never yields [] — pop is always a string here)
|
|
119
|
+
const leaf = path.split("/").pop();
|
|
120
|
+
const gated = gateSkill(sid, fm.name !== "" ? fm.name : stem(leaf), fm.description.slice(0, 200), scope, genre, card, model, null, null);
|
|
121
|
+
return { row: gated, path };
|
|
122
|
+
}
|
|
123
|
+
/** THE SPAWN PLANE (operator pin, stroke 87): leaves under
|
|
124
|
+
* `agents/spawn/` (dir/SKILL.md, same shape as agents/skills/)
|
|
125
|
+
* are SUBAGENT-ONLY — findSkill resolves their refs for the
|
|
126
|
+
* agent-stage spawn injection (skills[] inlined into the spawned
|
|
127
|
+
* brief at stage start), but buildSkillIndex NEVER lists them:
|
|
128
|
+
* the constructor agent (the main chat session) does not see
|
|
129
|
+
* skills that belong to the spawned doer. The scope suffix
|
|
130
|
+
* `-spawn` is the structural mark; the index filter is the law. */
|
|
131
|
+
export function spawnRows(cdir, prefix, scope, genre, card, model) {
|
|
132
|
+
const out = [];
|
|
133
|
+
let sks;
|
|
134
|
+
try {
|
|
135
|
+
sks = readdirSync(join(cdir, "agents", "spawn")).sort();
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
|
|
139
|
+
// names itself — the spawn surface must not vanish silently.
|
|
140
|
+
if (e.code !== "ENOENT") {
|
|
141
|
+
console.error(`skill rows: spawn dir unreadable (${join(cdir, "agents", "spawn")}): ${String(e)}`);
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
for (const sk of sks) {
|
|
146
|
+
const skp = join(cdir, "agents", "spawn", sk);
|
|
147
|
+
const doc = isDir(skp) ? join(skp, "SKILL.md") : skp;
|
|
148
|
+
if (!isDir(skp) && !doc.endsWith(".md"))
|
|
149
|
+
continue;
|
|
150
|
+
const r = readDoc(doc, prefix + ":" + sk, scope, genre, card, model);
|
|
151
|
+
if (r !== null)
|
|
152
|
+
out.push(r);
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
export function engineDirs(enginesRoot) {
|
|
161
|
+
const marker = (d) => isFile(join(d, "package.json")) ||
|
|
162
|
+
isFile(join(d, "plugin.yaml")) ||
|
|
163
|
+
isDir(join(d, "engines"));
|
|
164
|
+
let tops;
|
|
165
|
+
try {
|
|
166
|
+
tops = readdirSync(enginesRoot).sort();
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
|
|
170
|
+
// failure names itself — the whole skill walk must not degrade
|
|
171
|
+
// to empty invisibly.
|
|
172
|
+
if (e.code !== "ENOENT") {
|
|
173
|
+
console.error(`skill rows: engines root unreadable (${enginesRoot}): ${String(e)}`);
|
|
174
|
+
}
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
const out = [];
|
|
178
|
+
for (const name of tops) {
|
|
179
|
+
const full = join(enginesRoot, name);
|
|
180
|
+
if (!isDir(full))
|
|
181
|
+
continue;
|
|
182
|
+
if (marker(full)) {
|
|
183
|
+
out.push(full);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
let subs;
|
|
187
|
+
try {
|
|
188
|
+
subs = readdirSync(full).sort();
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
for (const sub of subs) {
|
|
196
|
+
const sfull = join(full, sub);
|
|
197
|
+
if (isDir(sfull) && marker(sfull))
|
|
198
|
+
out.push(sfull);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
function familyLane(mdir, mid, genre, skillRows) {
|
|
220
|
+
if (skillRows.length === 0)
|
|
221
|
+
return null;
|
|
222
|
+
const lines = [
|
|
223
|
+
"# " + mid + " — family lane (synthesized: this family ships skills, no agents/AGENT.md)",
|
|
224
|
+
"",
|
|
225
|
+
"Read the rows below with melite_skill_read BEFORE writing a prompt for "
|
|
226
|
+
+ mid + "; every family wants its own prompt shape.",
|
|
227
|
+
"",
|
|
228
|
+
];
|
|
229
|
+
for (const r of skillRows) {
|
|
230
|
+
lines.push("- `" + r.row.id + "` — " + r.row.name + (r.row.description === "" ? "" : ": " + r.row.description));
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
row: gateSkill("model:" + mid, mid, mid + " family lane: " + String(skillRows.length) + " skill row(s) to read before writing a prompt", "model-lane", genre, null, mid, null, null),
|
|
234
|
+
path: join(mdir, "agents", "skills"),
|
|
235
|
+
bodyText: lines.join("\n") + "\n",
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/** LEVEL 1+3 model docs (lane_disclosure._model_rows 259-312):
|
|
239
|
+
* GUIDE.md / agents/AGENT.md / agents/skills/* per model dir. */
|
|
240
|
+
export function modelRows(engine) {
|
|
241
|
+
const rows = [];
|
|
242
|
+
const modelsRoot = join(engine, "models");
|
|
243
|
+
if (!isDir(modelsRoot))
|
|
244
|
+
return rows;
|
|
245
|
+
for (const genre of subdirs(modelsRoot)) {
|
|
246
|
+
for (const mid of subdirs(join(modelsRoot, genre))) {
|
|
247
|
+
const mdir = join(modelsRoot, genre, mid);
|
|
248
|
+
const guide = readDoc(join(mdir, "GUIDE.md"), "guide:" + mid, "guide", genre, null, mid);
|
|
249
|
+
if (guide !== null)
|
|
250
|
+
rows.push(guide);
|
|
251
|
+
const agent = readDoc(join(mdir, "agents", "AGENT.md"), "model:" + mid, "model", genre, null, mid);
|
|
252
|
+
if (agent !== null)
|
|
253
|
+
rows.push(agent);
|
|
254
|
+
// THE SPAWN PLANE (subagent-only; the index filters, the
|
|
255
|
+
// spawn reader resolves — never listed to the constructor).
|
|
256
|
+
// Walked BEFORE the skills loop: a spawn-only model dir (no
|
|
257
|
+
// agents/skills — the blender-door shape) must not be skipped
|
|
258
|
+
// by that loop's readdir catch.
|
|
259
|
+
for (const r of spawnRows(mdir, "model:" + mid, "model-spawn", genre, null, mid)) {
|
|
260
|
+
rows.push(r);
|
|
261
|
+
}
|
|
262
|
+
let sks;
|
|
263
|
+
try {
|
|
264
|
+
sks = readdirSync(join(mdir, "agents", "skills")).sort();
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const own = [];
|
|
270
|
+
for (const sk of sks) {
|
|
271
|
+
const skp = join(mdir, "agents", "skills", sk);
|
|
272
|
+
const doc = isDir(skp) ? join(skp, "SKILL.md") : skp;
|
|
273
|
+
if (!isDir(skp) && !doc.endsWith(".md"))
|
|
274
|
+
continue;
|
|
275
|
+
const r = readDoc(doc, "model:" + mid + ":" + sk, "model-skill", genre, null, mid);
|
|
276
|
+
if (r !== null) {
|
|
277
|
+
own.push(r);
|
|
278
|
+
rows.push(r);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// The family lane, when the family has no row of its own.
|
|
282
|
+
if (guide === null && agent === null) {
|
|
283
|
+
const lane = familyLane(mdir, mid, genre, own);
|
|
284
|
+
if (lane !== null)
|
|
285
|
+
rows.push(lane);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return rows;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
export function cardUnitDirs(engine, repo) {
|
|
299
|
+
const out = [];
|
|
300
|
+
const push = (genre, cname, cdir) => {
|
|
301
|
+
if (cname === "node_modules" || cname.startsWith("."))
|
|
302
|
+
return;
|
|
303
|
+
if (cname.includes("_") && DIR_ID_ALIASES[cname] === undefined) {
|
|
304
|
+
throw new LaneWireError("[tool_projection] card dir " + JSON.stringify(cdir) +
|
|
305
|
+
" has no registry mapping (underscore dirs bridge via " +
|
|
306
|
+
"DIR_ID_ALIASES in toolProjection.ts — add the row or " +
|
|
307
|
+
"rename the dir)");
|
|
308
|
+
}
|
|
309
|
+
out.push({ genre, cname: DIR_ID_ALIASES[cname] ?? cname, cdir });
|
|
310
|
+
};
|
|
311
|
+
// the engine remainder tree: <engine>/src/cards/<genre>/<card>
|
|
312
|
+
const cardsRoot = join(engine, "src", "cards");
|
|
313
|
+
if (isDir(cardsRoot)) {
|
|
314
|
+
for (const genre of subdirs(cardsRoot)) {
|
|
315
|
+
if (genre.startsWith("_"))
|
|
316
|
+
continue;
|
|
317
|
+
for (const c of subdirs(join(cardsRoot, genre))) {
|
|
318
|
+
push(genre, c, join(cardsRoot, genre, c));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// are BARE words — <repo>/packages/<genre>/<card>/; the mapping
|
|
324
|
+
// table died with the prefix, the dir IS the genre). models stays
|
|
325
|
+
// out of this walk by content: model packages carry index.ts, no
|
|
326
|
+
// card.ts — the isFile guard below is the discriminator.
|
|
327
|
+
|
|
328
|
+
// engine-INDEPENDENT (repo-wide packages tree — no engine remainder
|
|
329
|
+
// card trees exist anymore), but every caller merges per-engine
|
|
330
|
+
// (buildCardTools, peek, cardRows). Emitting here for every engine
|
|
331
|
+
// served each card once per engine dir (3× — the picker repeats).
|
|
332
|
+
// Emit under the registry's owner engine ONLY (the manifests()
|
|
333
|
+
// dir-less-cards precedent below) — never once per engine. The
|
|
334
|
+
// owner is comfyui-cordis (factsPath in cardsRegistry.ts hardcodes it;
|
|
335
|
+
// packages/engines/comfyui/src/ holds only action_cards tenants, it is
|
|
336
|
+
// never itself an engine entry).
|
|
337
|
+
// (split never yields [] — pop is always a string here; dir names
|
|
338
|
+
// are unique so the equal arm never fires)
|
|
339
|
+
if (engine.split("/").pop() !== "comfyui-cordis")
|
|
340
|
+
return out.sort((a, b) => (a.cname < b.cname ? -1 : a.cname > b.cname ? 1 : /* v8 ignore next */ 0));
|
|
341
|
+
for (const genre of ["3d", "audio", "image", "motion", "video"]) {
|
|
342
|
+
const droot = join(repo, "packages", genre);
|
|
343
|
+
if (!isDir(droot))
|
|
344
|
+
continue;
|
|
345
|
+
for (const c of subdirs(droot)) {
|
|
346
|
+
// the card unit of a package lives at src/ (card.ts + ui + agents)
|
|
347
|
+
if (!isFile(join(droot, c, "src", "card.ts")))
|
|
348
|
+
continue;
|
|
349
|
+
push(genre, c, join(droot, c, "src"));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return out.sort((a, b) => (a.cname < b.cname ? -1 : a.cname > b.cname ? 1 : /* v8 ignore next */ 0));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
export function cardRows(engine, repo) {
|
|
362
|
+
const rows = [];
|
|
363
|
+
const buckets = new Map();
|
|
364
|
+
{
|
|
365
|
+
for (const { genre, cname, cdir } of cardUnitDirs(engine, repo)) {
|
|
366
|
+
{
|
|
367
|
+
const got = [];
|
|
368
|
+
// Oracle fallback order (lane_disclosure card walk): the
|
|
369
|
+
// top-level AGENT.md wins, agents/AGENT.md orients when the
|
|
370
|
+
// card ships no top-level doc (every estate card today).
|
|
371
|
+
let agent = readDoc(join(cdir, "AGENT.md"), "card:" + cname, "card", genre, cname, null);
|
|
372
|
+
if (agent === null) {
|
|
373
|
+
agent = readDoc(join(cdir, "agents", "AGENT.md"), "card:" + cname, "card", genre, cname, null);
|
|
374
|
+
}
|
|
375
|
+
if (agent !== null)
|
|
376
|
+
got.push(agent);
|
|
377
|
+
let sks;
|
|
378
|
+
try {
|
|
379
|
+
sks = readdirSync(join(cdir, "agents", "skills")).sort();
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
sks = [];
|
|
383
|
+
}
|
|
384
|
+
for (const sk of sks) {
|
|
385
|
+
const skp = join(cdir, "agents", "skills", sk);
|
|
386
|
+
const doc = isDir(skp) ? join(skp, "SKILL.md") : skp;
|
|
387
|
+
if (!isDir(skp) && !doc.endsWith(".md"))
|
|
388
|
+
continue;
|
|
389
|
+
const r = readDoc(doc, "card:" + cname + ":" + sk, "card-skill", genre, cname, null);
|
|
390
|
+
if (r !== null)
|
|
391
|
+
got.push(r);
|
|
392
|
+
}
|
|
393
|
+
// THE SPAWN PLANE (subagent-only; the index filters, the
|
|
394
|
+
// spawn reader resolves — never listed to the constructor).
|
|
395
|
+
for (const r of spawnRows(cdir, "card:" + cname, "card-spawn", genre, cname, null)) {
|
|
396
|
+
got.push(r);
|
|
397
|
+
}
|
|
398
|
+
for (const g of got)
|
|
399
|
+
rows.push(g);
|
|
400
|
+
buckets.set(cname, { dir: cdir, rows: got });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return { rows, buckets };
|
|
405
|
+
}
|
|
406
|
+
/** The registry skill body for one flow id (null when the flow
|
|
407
|
+
* has its own SKILL.md or is unknown to the TS registry — the
|
|
408
|
+
* caller falls back to the file path). A registry flow whose
|
|
409
|
+
* declaration fails to expand is an authoring bug: LOUD, never a
|
|
410
|
+
* silent empty body. The family stages compose first (the doors'
|
|
411
|
+
* own order) so the body names the action's derived outputs. */
|
|
412
|
+
/** @param modelsSeat the context's models service when mounted (the
|
|
413
|
+
* same seat-threading law as flowDecls) */
|
|
414
|
+
export function registryBody(flowId, modelsSeat, flowsSeat) {
|
|
415
|
+
const flows = flowsSeat ?? seedFlowsSeat();
|
|
416
|
+
const decl = flows.get(flowId);
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
if (decl === undefined)
|
|
420
|
+
return null;
|
|
421
|
+
const family = liveFamilySeat(modelsSeat);
|
|
422
|
+
return registrySkillBody(composeFamilyStages(expandRegistryFlow(decl, flows), family.decls, family.state), flows);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
/** @param modelsSeat the context's models service when mounted (the
|
|
431
|
+
* same seat-threading law as flowDecls) */
|
|
432
|
+
export function flowRows(repo, modelsSeat, flowsSeat) {
|
|
433
|
+
const out = [];
|
|
434
|
+
for (const decl of flowDecls(repo, modelsSeat, flowsSeat)) {
|
|
435
|
+
|
|
436
|
+
// (flowDecls carries its refusal on loadError).
|
|
437
|
+
if (decl.loadError !== null)
|
|
438
|
+
continue;
|
|
439
|
+
const steps = [];
|
|
440
|
+
for (const s of decl.stages) {
|
|
441
|
+
// FlowStepRow gate (id/type/plugin min_length=1) — refusal is
|
|
442
|
+
// a code bug (LaneWireError, "flow %s: lane wire refusal").
|
|
443
|
+
// (the static registry carries no empty ids/engines — the fence
|
|
444
|
+
// never fires, but it stays: an authoring bug must throw LOUD)
|
|
445
|
+
/* v8 ignore next */
|
|
446
|
+
if (s.id.length < 1 || s.engine.length < 1) {
|
|
447
|
+
throw new LaneWireError("flow " + decl.id + ": lane wire refusal: id: String " +
|
|
448
|
+
"should have at least 1 character");
|
|
449
|
+
}
|
|
450
|
+
steps.push({ id: s.id, type: s.engine, plugin: s.engine });
|
|
451
|
+
}
|
|
452
|
+
const gated = gateSkill("flow:" + decl.id, decl.id, decl.description.slice(0, 200), "flow", null, null, null, steps, steps.length);
|
|
453
|
+
out.push({
|
|
454
|
+
row: gated,
|
|
455
|
+
bodyPath: decl.hasSkillMd
|
|
456
|
+
? join(repo, "flows", decl.id, "SKILL.md")
|
|
457
|
+
: null,
|
|
458
|
+
bodyText: decl.hasSkillMd ? null : registryBody(decl.id, modelsSeat),
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return out;
|
|
462
|
+
}
|
|
463
|
+
/** GET /v1/skills body (lane_disclosure.melite_skill_index 633-649). The
|
|
464
|
+
* SPAWN PLANE filter: `-spawn` scoped rows NEVER ride the index —
|
|
465
|
+
* they are the spawned subagent's private leaves (findSkill
|
|
466
|
+
* resolves them for stage-start injection; the constructor's
|
|
467
|
+
* index/listing never sees them — the operator's pin). */
|
|
468
|
+
//# sourceMappingURL=skillRows.js.map
|