ue-mcp-tripo 0.2.2 → 0.2.4

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.
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Loadouts: named bundles of generate settings.
3
+ *
4
+ * ue-mcp merges them for the plugin and hands the result over as
5
+ * `this.config.loadouts`: the built-ins from `config.loadouts` in
6
+ * ue-mcp.plugin.yml, deep-merged with the project's
7
+ * `ue-mcp.pluginConfig.tripo.loadouts` in the project's config. Nothing here reads a file.
8
+ *
9
+ * A call resolves in this order, later winning per field: the loadout (after
10
+ * the loadouts it `extends`), then the explicit options of the call. Every
11
+ * resolved field remembers where it came from.
12
+ */
13
+ /** The generate options a loadout may set. */
14
+ export const LOADOUT_FIELDS = [
15
+ "model",
16
+ "rig",
17
+ "rigType",
18
+ "spec",
19
+ "animation",
20
+ "pbr",
21
+ "format",
22
+ "segmentHint",
23
+ "faceLimit",
24
+ "textureQuality",
25
+ "params",
26
+ "then",
27
+ "kind",
28
+ "destination",
29
+ "importMaterials",
30
+ "importTextures",
31
+ "importAnimations",
32
+ "createPhysicsAsset",
33
+ "nanite",
34
+ "place",
35
+ "onConflict",
36
+ "save",
37
+ ];
38
+ /** Fields that are about the loadout, not generate settings. */
39
+ const META = ["description", "extends", "guidance"];
40
+ /** The plugin's merged config as ue-mcp hands it to a task (`this.config`), or undefined on an older server. */
41
+ export function configOf(task) {
42
+ return task.config;
43
+ }
44
+ /** The loadouts in a plugin config, without removed (null) entries. */
45
+ export function loadoutsFrom(config) {
46
+ const raw = config?.loadouts;
47
+ const out = {};
48
+ if (!raw || typeof raw !== "object")
49
+ return out;
50
+ for (const [name, v] of Object.entries(raw)) {
51
+ if (v && typeof v === "object" && !Array.isArray(v))
52
+ out[name] = v;
53
+ }
54
+ return out;
55
+ }
56
+ /** The chain of loadouts a name resolves through, base first. */
57
+ function chainOf(name, all) {
58
+ const chain = [];
59
+ for (let cur = name; cur; cur = all[cur]?.extends) {
60
+ if (chain.includes(cur))
61
+ throw new Error(`Loadout "${name}" extends itself through ${[...chain, cur].join(" -> ")}.`);
62
+ if (!all[cur]) {
63
+ throw new Error(cur === name
64
+ ? `No loadout named "${name}". ${names(all)}`
65
+ : `Loadout "${chain[chain.length - 1]}" extends "${cur}", which does not exist. ${names(all)}`);
66
+ }
67
+ chain.push(cur);
68
+ }
69
+ return chain.reverse();
70
+ }
71
+ function names(all) {
72
+ const list = Object.keys(all);
73
+ return list.length
74
+ ? `Available: ${list.join(", ")}.`
75
+ : "No loadouts are configured; they need ue-mcp 1.4.16-beta.12 or later, which passes the plugin its config.";
76
+ }
77
+ const PARAM_OF = { faceLimit: "face_limit", textureQuality: "texture_quality" };
78
+ /**
79
+ * Resolve a call's options: loadout fields first, explicit options over them.
80
+ * faceLimit, textureQuality and params all end up as one `params` list of
81
+ * key=value pairs where the last word on a key wins.
82
+ */
83
+ export function resolveOptions(explicit, all) {
84
+ const warnings = [];
85
+ const sources = {};
86
+ const merged = {};
87
+ const paramMap = new Map();
88
+ const paramSource = new Map();
89
+ const name = typeof explicit.loadout === "string" && explicit.loadout ? explicit.loadout : undefined;
90
+ const apply = (values, source) => {
91
+ for (const [k, v] of Object.entries(values)) {
92
+ if (v === undefined || v === null)
93
+ continue;
94
+ if (k === "params") {
95
+ for (const p of Array.isArray(v) ? v : [v]) {
96
+ const [key, ...rest] = String(p).split("=");
97
+ paramMap.set(key, rest.join("="));
98
+ paramSource.set(key, source);
99
+ }
100
+ }
101
+ else if (k in PARAM_OF) {
102
+ paramMap.set(PARAM_OF[k], String(v));
103
+ paramSource.set(PARAM_OF[k], source);
104
+ }
105
+ else {
106
+ merged[k] = v;
107
+ if (LOADOUT_FIELDS.includes(k))
108
+ sources[k] = source;
109
+ }
110
+ }
111
+ };
112
+ let guidance;
113
+ if (name) {
114
+ for (const link of chainOf(name, all)) {
115
+ const def = all[link];
116
+ const settings = {};
117
+ for (const [k, v] of Object.entries(def)) {
118
+ if (META.includes(k))
119
+ continue;
120
+ if (!LOADOUT_FIELDS.includes(k)) {
121
+ warnings.push(`Loadout "${link}" sets "${k}", which generate does not use; ignored.`);
122
+ continue;
123
+ }
124
+ settings[k] = v;
125
+ }
126
+ apply(settings, `loadout:${link}`);
127
+ if (def.guidance)
128
+ guidance = def.guidance;
129
+ }
130
+ }
131
+ const { loadout: _loadout, ...rest } = explicit;
132
+ apply(rest, "option");
133
+ if (paramMap.size) {
134
+ merged.params = [...paramMap].map(([k, v]) => `${k}=${v}`);
135
+ for (const k of paramMap.keys())
136
+ sources[`param:${k}`] = paramSource.get(k);
137
+ }
138
+ return { options: merged, sources, loadout: name, guidance, warnings };
139
+ }
140
+ /** What a loadout resolves to on its own, for the loadouts action. */
141
+ export function describeLoadout(name, all) {
142
+ const r = resolveOptions({ loadout: name }, all);
143
+ const def = all[name];
144
+ const settings = { ...r.options };
145
+ const params = Array.isArray(settings.params) ? settings.params : [];
146
+ delete settings.params;
147
+ return {
148
+ name,
149
+ description: def.description,
150
+ extends: def.extends,
151
+ guidance: r.guidance,
152
+ settings,
153
+ params: Object.fromEntries(params.map((p) => [p.split("=")[0], p.split("=").slice(1).join("=")])),
154
+ sources: r.sources,
155
+ warnings: r.warnings,
156
+ };
157
+ }
158
+ //# sourceMappingURL=loadouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadouts.js","sourceRoot":"","sources":["../../src/shared/loadouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;IACP,KAAK;IACL,SAAS;IACT,MAAM;IACN,WAAW;IACX,KAAK;IACL,QAAQ;IACR,aAAa;IACb,WAAW;IACX,gBAAgB;IAChB,QAAQ;IACR,MAAM;IACN,MAAM;IACN,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,MAAM;CACE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3D,MAAM,CAAC,GAAG,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACjD,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,QAAQ,GAA4B,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,QAAQ,CAAC,MAAmB,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACvB,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,QAAQ;QACR,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjG,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;KACrB,CAAC;AACJ,CAAC"}
@@ -1,4 +1,11 @@
1
1
  import { UeMcpTask, type TaskResult } from "ue-mcp/task";
2
+ /**
3
+ * The generation model when the caller names none. H3.1 is the cheapest model
4
+ * the CLI can price (its dry run estimates it), and no --for scenario is used
5
+ * for non-rigged output because the scenarios raise texture quality and pick
6
+ * the premium P2 model on their own.
7
+ */
8
+ export declare const DEFAULT_MODEL = "H3.1";
2
9
  export interface Vec3 {
3
10
  x: number;
4
11
  y: number;
@@ -7,6 +14,8 @@ export interface Vec3 {
7
14
  interface Options {
8
15
  prompt?: string;
9
16
  images?: string[] | string;
17
+ views?: Record<string, string>;
18
+ prepareImages?: boolean;
10
19
  task?: string;
11
20
  rig?: boolean;
12
21
  rigType?: string;
@@ -39,19 +48,52 @@ interface Options {
39
48
  };
40
49
  onConflict?: string;
41
50
  save?: boolean;
51
+ loadout?: string;
52
+ segmentHint?: string;
53
+ faceLimit?: number;
54
+ textureQuality?: string;
42
55
  }
43
56
  export declare function sanitizeAssetName(raw: string): string;
44
57
  /** "walk" -> "preset:walk"; anything already prefixed passes through. */
45
58
  export declare function presetName(name: string): string;
46
- /** The --then chain for these options, or "" when make needs none. */
59
+ /**
60
+ * The --then chain for these options, or "" when make needs none. With
61
+ * segmentHint the rig and convert steps wait for the segmentation: they run in
62
+ * a second make on the segmented model (see afterSegmentChain).
63
+ */
47
64
  export declare function chainFor(o: Options): string;
48
- /** The full `tripo make` argument list generate runs. */
49
- export declare function makeArgs(o: Options, outDir: string): string[];
65
+ /** The chain that runs on the segmented model: rig, retarget, then the FBX convert. */
66
+ export declare function afterSegmentChain(o: Options): string;
67
+ /**
68
+ * The full `tripo make` argument list generate runs. `views` replaces the
69
+ * images when a turnaround was prepared, in front, left, back, right order.
70
+ */
71
+ export declare function makeArgs(o: Options, outDir: string, views?: string[]): string[];
72
+ /**
73
+ * When the download links of a task stop working: read from the signed URLs
74
+ * the API returned (an expiry timestamp, or a signing date plus a lifetime),
75
+ * else about 8 days from now.
76
+ */
77
+ export declare function linkExpiry(output: unknown, now?: number): {
78
+ expiresAt: string;
79
+ fromApi: boolean;
80
+ };
81
+ /** The asset(import_model) call that imports a file, ready to run. */
82
+ export declare function importCallFor(params: Record<string, unknown>): string;
50
83
  export default class Generate extends UeMcpTask<Options> {
51
84
  get taskName(): string;
52
85
  execute(): Promise<TaskResult>;
53
86
  private resume;
54
87
  private pending;
55
88
  private finish;
89
+ /**
90
+ * Garment separation. make's --then chain has no smartsegment step, so it runs
91
+ * as its own CLI calls: `mesh smartsegment` on the generated GLB, then a make
92
+ * of the segmented file with the rig chain. Credits are already spent by now,
93
+ * so a failure here returns what exists instead of throwing.
94
+ */
95
+ private segmentStage;
96
+ /** `tripo task get <id> --download` into dir. Never throws: the run already succeeded. */
97
+ private saveRaw;
56
98
  }
57
99
  export {};