@melite/image-tagger 0.2.3-rc.4 → 0.3.0-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/lib/card.d.ts +1 -3
- package/lib/card.js +28 -31
- package/lib/family-seats.d.ts +16 -0
- package/lib/family-seats.js +42 -0
- package/package.json +9 -9
- package/src/card.ts +35 -32
package/lib/card.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Context } from '@melite/comfyui-card-kit/card-definition';
|
|
2
|
-
|
|
3
|
-
import type { GraphBuilder } from '@melite/comfyui-card-kit/graph';
|
|
4
|
-
export declare const ACTION_BINDINGS: Record<string, (p: Record<string, unknown>, model: ModelFacts, g: GraphBuilder, runId: string) => void>;
|
|
2
|
+
export declare const BOARDED: readonly ["wd14", "joytag", "florence2", "joycaption"];
|
|
5
3
|
export declare const inject: string[];
|
|
6
4
|
export declare const identity: {
|
|
7
5
|
label: string;
|
package/lib/card.js
CHANGED
|
@@ -2,30 +2,27 @@ import z from '@deepseek-ai/schemastery';
|
|
|
2
2
|
import { declaredAction, finalizeTagger, TAGGER_CAPTION_TASKS, TAGGER_CAPTION_TYPES, TAGGER_CAPTION_LENGTHS, TAGGER_EXTRA_OPTIONS, instantiateAction } from '@melite/comfyui-card-kit';
|
|
3
3
|
import { vocabulary } from '@melite/comfyui-card-kit/vocab';
|
|
4
4
|
import { bag } from '@melite/contracts/extraKeys';
|
|
5
|
-
import { DECL as wd14Decl } from '@melite/models-wd14';
|
|
6
|
-
import { DECL as joytagDecl } from '@melite/models-joytag';
|
|
7
|
-
import { DECL as florence2Decl } from '@melite/models-florence2';
|
|
8
|
-
import { DECL as joycaptionDecl } from '@melite/models-joycaption';
|
|
9
5
|
import { inputImageExtra } from '@melite/comfyui-card-kit/fields';
|
|
10
6
|
import { callableSchema, gatedResolve } from '@melite/comfyui-card-kit/admission';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
7
|
+
import { primeFamilySeats, seatOf } from "./family-seats.js";
|
|
8
|
+
|
|
9
|
+
// four boarded families live as id literals; their DECLs arrive
|
|
10
|
+
// through the guarded seat loader (src/family-seats.ts — the card's
|
|
11
|
+
// only family bridge, zero static imports). A family package absent
|
|
12
|
+
// from the install costs its own seat: the card still registers and
|
|
13
|
+
// the compose door below refuses loud, by name.
|
|
14
|
+
export const BOARDED = ['wd14', 'joytag', 'florence2', 'joycaption'];
|
|
15
|
+
// THE COMPOSE DOOR (the family dispatch): each boarded family's
|
|
16
|
+
// declared action composes — the card delegates, never authors
|
|
17
|
+
// nodes. Keyed by OWNING FAMILY (`model.family ?? model.id` at
|
|
18
|
+
// dispatch — a route id keys nothing, the derived-row law); an
|
|
19
|
+
// unseated family refuses loud at the door.
|
|
20
|
+
const composeFamilyAction = (p, model, g, runId) => {
|
|
21
|
+
const seat = seatOf(String(model.family ?? model.id));
|
|
22
|
+
if (seat === undefined) {
|
|
23
|
+
throw new Error(`no declared action for family '${String(model.family ?? model.id)}' on the tagger card — every boarded family (${BOARDED.join(', ')}) composes its own declared segment; this address owns none (a family package absent from the install refuses here, by name)`);
|
|
24
|
+
}
|
|
25
|
+
instantiateAction(declaredAction(seat.decl, 'tag'), p, model, g, runId);
|
|
29
26
|
};
|
|
30
27
|
// requiresByFamily: declared on the seam owner
|
|
31
28
|
|
|
@@ -109,14 +106,19 @@ export const identity = {
|
|
|
109
106
|
],
|
|
110
107
|
};
|
|
111
108
|
export function apply(ctx) {
|
|
109
|
+
|
|
110
|
+
// family seats before the card boards — fire-and-forget (the
|
|
111
|
+
// guards absorb an absent family; the registration never waits).
|
|
112
|
+
void primeFamilySeats();
|
|
112
113
|
ctx.effect(() => ctx.comfyui.registerCard({
|
|
113
114
|
id: 'tagger',
|
|
114
115
|
// stage-row id the compose emits (purge S-decls verdict: the
|
|
115
116
|
// retired row carried "" — engine truth wins).
|
|
116
117
|
skeleton: 'tagger',
|
|
117
|
-
// the four boarded families (
|
|
118
|
-
// one spelling; RULE 5).
|
|
119
|
-
|
|
118
|
+
// the four boarded families (the BOARDED literal above — the
|
|
119
|
+
// one spelling; RULE 5). The DECLs ride the seat loader, so a
|
|
120
|
+
// pruned family package removes only its own boarding here.
|
|
121
|
+
boarded: [...BOARDED],
|
|
120
122
|
tags: ['image', 'tag', 'analyze'],
|
|
121
123
|
identity,
|
|
122
124
|
|
|
@@ -167,12 +169,7 @@ export function apply(ctx) {
|
|
|
167
169
|
if (!img.trim()) {
|
|
168
170
|
throw new Error("required param 'input_image' missing or blank on the tagger card (the tagger inverts an image; nothing to tag is a refusal)");
|
|
169
171
|
}
|
|
170
|
-
|
|
171
|
-
if (bound)
|
|
172
|
-
bound(doc, model, g, runId);
|
|
173
|
-
else {
|
|
174
|
-
throw new Error(`no declared action for family '${String(model.family ?? model.id)}' on the tagger card — every boarded family (wd14, joytag, florence2, joycaption) composes its own declared segment; this address owns none`);
|
|
175
|
-
}
|
|
172
|
+
composeFamilyAction(doc, model, g, runId);
|
|
176
173
|
},
|
|
177
174
|
finalize: finalizeTagger,
|
|
178
175
|
}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ModelDecl } from '@melite/comfyui-card-kit/model-contract';
|
|
2
|
+
/** One family's runtime seat: its DECL (the four tagger families
|
|
3
|
+
* ship no craft face today; the seat is the pattern any future
|
|
4
|
+
* one rides). */
|
|
5
|
+
export type FamilySeat = {
|
|
6
|
+
decl: ModelDecl;
|
|
7
|
+
};
|
|
8
|
+
/** Prime every family seat (idempotent; absent packages degrade to
|
|
9
|
+
* their own absence — the card never dies for a family). Fired
|
|
10
|
+
* fire-and-forget at registration; the post-boot compose dispatch
|
|
11
|
+
* reads the filled table synchronously. */
|
|
12
|
+
export declare const primeFamilySeats: () => Promise<void>;
|
|
13
|
+
/** A family's seat — undefined when the package is absent (the
|
|
14
|
+
* compose door's own loud refusal names the family there). */
|
|
15
|
+
export declare const seatOf: (id: string) => FamilySeat | undefined;
|
|
16
|
+
//# sourceMappingURL=family-seats.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
/** The boarded family modules, by package — ids live in card.ts's
|
|
10
|
+
* BOARDED literal (the family-coverage wall judges the binding on
|
|
11
|
+
* the dev tree; a typo'd id reds it there). */
|
|
12
|
+
const FAMILY_MODULES = [
|
|
13
|
+
'@melite/models-wd14',
|
|
14
|
+
'@melite/models-joytag',
|
|
15
|
+
'@melite/models-florence2',
|
|
16
|
+
'@melite/models-joycaption',
|
|
17
|
+
];
|
|
18
|
+
const seats = new Map();
|
|
19
|
+
let priming = null;
|
|
20
|
+
/** Prime every family seat (idempotent; absent packages degrade to
|
|
21
|
+
* their own absence — the card never dies for a family). Fired
|
|
22
|
+
* fire-and-forget at registration; the post-boot compose dispatch
|
|
23
|
+
* reads the filled table synchronously. */
|
|
24
|
+
export const primeFamilySeats = () => {
|
|
25
|
+
priming ??= Promise.allSettled(FAMILY_MODULES.map((spec) => import(__rewriteRelativeImportExtension(spec))))
|
|
26
|
+
.then((results) => {
|
|
27
|
+
for (const result of results) {
|
|
28
|
+
if (result.status !== 'fulfilled')
|
|
29
|
+
continue;
|
|
30
|
+
const mod = result.value;
|
|
31
|
+
const decl = mod?.DECL;
|
|
32
|
+
if (decl?.id === undefined || typeof decl.id !== 'string')
|
|
33
|
+
continue;
|
|
34
|
+
seats.set(decl.id, { decl });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return priming;
|
|
38
|
+
};
|
|
39
|
+
/** A family's seat — undefined when the package is absent (the
|
|
40
|
+
* compose door's own loud refusal names the family there). */
|
|
41
|
+
export const seatOf = (id) => seats.get(id);
|
|
42
|
+
//# sourceMappingURL=family-seats.js.map
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.3.0-alpha",
|
|
3
3
|
"license": "AGPL-3.0-or-later",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Caption-and-tag card over four tagger families — wd14, joytag, florence2, and joycaption.",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@deepseek-ai/schemastery": "^3.
|
|
19
|
-
"@melite/comfyui-card-kit": "0.
|
|
20
|
-
"@melite/
|
|
21
|
-
"@melite/models-
|
|
22
|
-
"@melite/models-
|
|
23
|
-
"@melite/
|
|
24
|
-
"@melite/models-
|
|
18
|
+
"@deepseek-ai/schemastery": "^3.19.0",
|
|
19
|
+
"@melite/comfyui-card-kit": "0.3.0-alpha",
|
|
20
|
+
"@melite/contracts": "0.3.0-alpha",
|
|
21
|
+
"@melite/models-florence2": "0.3.0-alpha",
|
|
22
|
+
"@melite/models-joycaption": "0.3.0-alpha",
|
|
23
|
+
"@melite/models-joytag": "0.3.0-alpha",
|
|
24
|
+
"@melite/models-wd14": "0.3.0-alpha"
|
|
25
25
|
},
|
|
26
26
|
"name": "@melite/image-tagger",
|
|
27
27
|
"files": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"src/agents"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/cordis": "^4.0
|
|
35
|
+
"@deepseek-ai/cordis": "^4.1.0"
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
package/src/card.ts
CHANGED
|
@@ -13,33 +13,37 @@ import z from '@deepseek-ai/schemastery'
|
|
|
13
13
|
import { declaredAction, finalizeTagger, TAGGER_CAPTION_TASKS, TAGGER_CAPTION_TYPES, TAGGER_CAPTION_LENGTHS, TAGGER_EXTRA_OPTIONS, instantiateAction } from '@melite/comfyui-card-kit'
|
|
14
14
|
import { vocabulary } from '@melite/comfyui-card-kit/vocab'
|
|
15
15
|
import { bag } from '@melite/contracts/extraKeys'
|
|
16
|
-
import { DECL as wd14Decl } from '@melite/models-wd14'
|
|
17
|
-
import { DECL as joytagDecl } from '@melite/models-joytag'
|
|
18
|
-
import { DECL as florence2Decl } from '@melite/models-florence2'
|
|
19
|
-
import { DECL as joycaptionDecl } from '@melite/models-joycaption'
|
|
20
16
|
import type { ModelFacts } from '@melite/comfyui-card-kit/facts'
|
|
21
17
|
import type { GraphBuilder } from '@melite/comfyui-card-kit/graph'
|
|
22
18
|
import { inputImageExtra } from '@melite/comfyui-card-kit/fields'
|
|
23
19
|
import { callableSchema, gatedResolve } from '@melite/comfyui-card-kit/admission'
|
|
20
|
+
import { primeFamilySeats, seatOf } from './family-seats.ts'
|
|
24
21
|
|
|
25
|
-
// THE FAMILY
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
// THE FAMILY SEATS (the plugin law — the L3 cure, 2026-11-16): the
|
|
23
|
+
// four boarded families live as id literals; their DECLs arrive
|
|
24
|
+
// through the guarded seat loader (src/family-seats.ts — the card's
|
|
25
|
+
// only family bridge, zero static imports). A family package absent
|
|
26
|
+
// from the install costs its own seat: the card still registers and
|
|
27
|
+
// the compose door below refuses loud, by name.
|
|
28
|
+
export const BOARDED = ['wd14', 'joytag', 'florence2', 'joycaption'] as const
|
|
29
|
+
|
|
30
|
+
// THE COMPOSE DOOR (the family dispatch): each boarded family's
|
|
31
|
+
// declared action composes — the card delegates, never authors
|
|
32
|
+
// nodes. Keyed by OWNING FAMILY (`model.family ?? model.id` at
|
|
33
|
+
// dispatch — a route id keys nothing, the derived-row law); an
|
|
34
|
+
// unseated family refuses loud at the door.
|
|
35
|
+
const composeFamilyAction = (
|
|
36
|
+
p: Record<string, unknown>,
|
|
37
|
+
model: ModelFacts,
|
|
38
|
+
g: GraphBuilder,
|
|
39
|
+
runId: string,
|
|
40
|
+
): void => {
|
|
41
|
+
const seat = seatOf(String(model.family ?? model.id))
|
|
42
|
+
if (seat === undefined) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`no declared action for family '${String(model.family ?? model.id)}' on the tagger card — every boarded family (${BOARDED.join(', ')}) composes its own declared segment; this address owns none (a family package absent from the install refuses here, by name)`)
|
|
45
|
+
}
|
|
46
|
+
instantiateAction(declaredAction(seat.decl, 'tag'), p, model, g, runId)
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
// requiresByFamily: declared on the seam owner
|
|
@@ -129,14 +133,19 @@ export const identity = {
|
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
export function apply(ctx: Context): void {
|
|
136
|
+
// THE PLUGIN LAW'S FIRE (the L3 cure, 2026-11-16): prime the
|
|
137
|
+
// family seats before the card boards — fire-and-forget (the
|
|
138
|
+
// guards absorb an absent family; the registration never waits).
|
|
139
|
+
void primeFamilySeats()
|
|
132
140
|
ctx.effect(() => ctx.comfyui.registerCard({
|
|
133
141
|
id: 'tagger',
|
|
134
142
|
// stage-row id the compose emits (purge S-decls verdict: the
|
|
135
143
|
// retired row carried "" — engine truth wins).
|
|
136
144
|
skeleton: 'tagger',
|
|
137
|
-
// the four boarded families (
|
|
138
|
-
// one spelling; RULE 5).
|
|
139
|
-
|
|
145
|
+
// the four boarded families (the BOARDED literal above — the
|
|
146
|
+
// one spelling; RULE 5). The DECLs ride the seat loader, so a
|
|
147
|
+
// pruned family package removes only its own boarding here.
|
|
148
|
+
boarded: [...BOARDED],
|
|
140
149
|
tags: ['image', 'tag', 'analyze'],
|
|
141
150
|
identity,
|
|
142
151
|
// THE DISCOVERY ROWS (migrated 2026-09-10 from the frozen
|
|
@@ -187,13 +196,7 @@ export function apply(ctx: Context): void {
|
|
|
187
196
|
if (!img.trim()) {
|
|
188
197
|
throw new Error("required param 'input_image' missing or blank on the tagger card (the tagger inverts an image; nothing to tag is a refusal)")
|
|
189
198
|
}
|
|
190
|
-
|
|
191
|
-
if (bound) bound(doc, model, g, runId)
|
|
192
|
-
else {
|
|
193
|
-
throw new Error(
|
|
194
|
-
`no declared action for family '${String(model.family ?? model.id)}' on the tagger card — every boarded family (wd14, joytag, florence2, joycaption) composes its own declared segment; this address owns none`)
|
|
195
|
-
}
|
|
196
|
-
},
|
|
199
|
+
composeFamilyAction(doc, model, g, runId) },
|
|
197
200
|
finalize: finalizeTagger,
|
|
198
201
|
}))
|
|
199
202
|
}
|