@metamesh/cli 0.0.0-stage → 0.13.0
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/CHANGELOG.md +27 -0
- package/LICENSE +200 -0
- package/README.md +71 -2
- package/dist/authoring/artifacts.d.ts +11 -0
- package/dist/authoring/artifacts.d.ts.map +1 -0
- package/dist/authoring/artifacts.js +343 -0
- package/dist/authoring/artifacts.js.map +1 -0
- package/dist/authoring/capture/render-client.js +4222 -0
- package/dist/authoring/capture/render-client.js.LEGAL.txt +9 -0
- package/dist/authoring/capture/render-client.js.map +7 -0
- package/dist/authoring/check.d.ts +3 -0
- package/dist/authoring/check.d.ts.map +1 -0
- package/dist/authoring/check.js +117 -0
- package/dist/authoring/check.js.map +1 -0
- package/dist/authoring/environment.d.ts +19 -0
- package/dist/authoring/environment.d.ts.map +1 -0
- package/dist/authoring/environment.js +173 -0
- package/dist/authoring/environment.js.map +1 -0
- package/dist/authoring/errors.d.ts +11 -0
- package/dist/authoring/errors.d.ts.map +1 -0
- package/dist/authoring/errors.js +41 -0
- package/dist/authoring/errors.js.map +1 -0
- package/dist/authoring/render-client.d.ts +6 -0
- package/dist/authoring/render-client.d.ts.map +1 -0
- package/dist/authoring/render-client.js +55 -0
- package/dist/authoring/render-client.js.map +1 -0
- package/dist/authoring/render-scene.d.ts +22 -0
- package/dist/authoring/render-scene.d.ts.map +1 -0
- package/dist/authoring/render-scene.js +139 -0
- package/dist/authoring/render-scene.js.map +1 -0
- package/dist/authoring/render-types.d.ts +81 -0
- package/dist/authoring/render-types.d.ts.map +1 -0
- package/dist/authoring/render-types.js +2 -0
- package/dist/authoring/render-types.js.map +1 -0
- package/dist/authoring/render.d.ts +23 -0
- package/dist/authoring/render.d.ts.map +1 -0
- package/dist/authoring/render.js +243 -0
- package/dist/authoring/render.js.map +1 -0
- package/dist/authoring/run.d.ts +3 -0
- package/dist/authoring/run.d.ts.map +1 -0
- package/dist/authoring/run.js +304 -0
- package/dist/authoring/run.js.map +1 -0
- package/dist/authoring/types.d.ts +138 -0
- package/dist/authoring/types.d.ts.map +1 -0
- package/dist/authoring/types.js +2 -0
- package/dist/authoring/types.js.map +1 -0
- package/dist/authoring/worker.d.ts +15 -0
- package/dist/authoring/worker.d.ts.map +1 -0
- package/dist/authoring/worker.js +163 -0
- package/dist/authoring/worker.js.map +1 -0
- package/dist/authoring.d.ts +12 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +9 -0
- package/dist/authoring.js.map +1 -0
- package/dist/docs/guides/agent-authoring.md +183 -0
- package/dist/docs/guides/package.md +72 -0
- package/dist/docs/manifest.json +554 -0
- package/dist/docs/reference/authoring/AUTHORING_PROTOCOL_VERSION.md +9 -0
- package/dist/docs/reference/authoring/AuthoringDiagnostic.md +19 -0
- package/dist/docs/reference/authoring/AuthoringEnvironment.md +14 -0
- package/dist/docs/reference/authoring/AuthoringError.md +15 -0
- package/dist/docs/reference/authoring/AuthoringFailure-type.md +15 -0
- package/dist/docs/reference/authoring/AuthoringKind.md +9 -0
- package/dist/docs/reference/authoring/AuthoringPhase.md +9 -0
- package/dist/docs/reference/authoring/CapturedBuffer.md +13 -0
- package/dist/docs/reference/authoring/CapturedGeometry.md +13 -0
- package/dist/docs/reference/authoring/CapturedPart.md +16 -0
- package/dist/docs/reference/authoring/CapturedResource.md +14 -0
- package/dist/docs/reference/authoring/CapturedRun.md +13 -0
- package/dist/docs/reference/authoring/CapturedRunManifest.md +38 -0
- package/dist/docs/reference/authoring/CheckOptions.md +14 -0
- package/dist/docs/reference/authoring/CheckSuccess.md +15 -0
- package/dist/docs/reference/authoring/DocumentationEntry.md +18 -0
- package/dist/docs/reference/authoring/DocumentationManifest.md +14 -0
- package/dist/docs/reference/authoring/DocumentationSearchResult.md +12 -0
- package/dist/docs/reference/authoring/InstalledAuthoringPackage.md +14 -0
- package/dist/docs/reference/authoring/RenderCamera.md +22 -0
- package/dist/docs/reference/authoring/RenderFormat.md +10 -0
- package/dist/docs/reference/authoring/RenderOptions.md +20 -0
- package/dist/docs/reference/authoring/RenderResult.md +15 -0
- package/dist/docs/reference/authoring/RenderView.md +10 -0
- package/dist/docs/reference/authoring/RenderedImage.md +23 -0
- package/dist/docs/reference/authoring/RunOptions.md +17 -0
- package/dist/docs/reference/authoring/RunSuccess.md +13 -0
- package/dist/docs/reference/authoring/authoringFailure-value.md +9 -0
- package/dist/docs/reference/authoring/checkAuthoringSource.md +9 -0
- package/dist/docs/reference/authoring/discoverAuthoringEnvironment.md +9 -0
- package/dist/docs/reference/authoring/inspectCapturedRun.md +11 -0
- package/dist/docs/reference/authoring/installAuthoringBrowser.md +13 -0
- package/dist/docs/reference/authoring/readCapturedRun.md +10 -0
- package/dist/docs/reference/authoring/renderCapturedRun.md +13 -0
- package/dist/docs/reference/authoring/runAuthoringSource.md +9 -0
- package/dist/docs/reference/authoring/searchAuthoringDocumentation.md +12 -0
- package/dist/docs/reference/authoring/showAuthoringDocumentation.md +11 -0
- package/dist/metamesh.d.ts +3 -0
- package/dist/metamesh.d.ts.map +1 -0
- package/dist/metamesh.js +183 -0
- package/dist/metamesh.js.map +1 -0
- package/package.json +63 -3
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
+
import { builtinModules } from "node:module";
|
|
5
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { build, transform } from "esbuild";
|
|
8
|
+
import { defaultModelingLimits } from "@metamesh/modeling/engine";
|
|
9
|
+
import { sha256, writeAtomicJson } from "./artifacts.js";
|
|
10
|
+
import { checkAuthoringSource } from "./check.js";
|
|
11
|
+
import { discoverAuthoringEnvironment, projectPackageDirectory } from "./environment.js";
|
|
12
|
+
import { AuthoringError, authoringFailure } from "./errors.js";
|
|
13
|
+
const builtin = new Set([...builtinModules, ...builtinModules.map((name) => `node:${name}`)]);
|
|
14
|
+
async function terminateExecution(child) {
|
|
15
|
+
child.stdout?.destroy();
|
|
16
|
+
child.stderr?.destroy();
|
|
17
|
+
if (process.platform !== "win32") {
|
|
18
|
+
try {
|
|
19
|
+
if (child.pid !== undefined)
|
|
20
|
+
process.kill(-child.pid, "SIGKILL");
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
child.kill("SIGKILL");
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (child.pid === undefined)
|
|
28
|
+
return;
|
|
29
|
+
await new Promise((done) => {
|
|
30
|
+
const killer = spawn("taskkill", ["/PID", String(child.pid), "/T", "/F"], {
|
|
31
|
+
stdio: "ignore",
|
|
32
|
+
windowsHide: true,
|
|
33
|
+
});
|
|
34
|
+
const fallback = setTimeout(() => {
|
|
35
|
+
child.kill("SIGKILL");
|
|
36
|
+
killer.kill();
|
|
37
|
+
done();
|
|
38
|
+
}, 1000);
|
|
39
|
+
const finish = () => {
|
|
40
|
+
clearTimeout(fallback);
|
|
41
|
+
child.kill("SIGKILL");
|
|
42
|
+
done();
|
|
43
|
+
};
|
|
44
|
+
killer.once("error", finish);
|
|
45
|
+
killer.once("close", finish);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async function bundleEntry(entry, project, outfile, kind, tsconfig) {
|
|
49
|
+
const imports = {};
|
|
50
|
+
const sourceHashes = new Map();
|
|
51
|
+
const capture = {
|
|
52
|
+
name: "preserve-installed-package-identities",
|
|
53
|
+
setup(builder) {
|
|
54
|
+
builder.onResolve({ filter: /^[^./\\]|^@/ }, async (args) => {
|
|
55
|
+
if (args.pluginData === "resolved" || isAbsolute(args.path) || builtin.has(args.path))
|
|
56
|
+
return undefined;
|
|
57
|
+
const resolved = await builder.resolve(args.path, {
|
|
58
|
+
resolveDir: args.resolveDir || project,
|
|
59
|
+
kind: args.kind,
|
|
60
|
+
pluginData: "resolved",
|
|
61
|
+
});
|
|
62
|
+
if (resolved.errors.length > 0)
|
|
63
|
+
return { errors: resolved.errors };
|
|
64
|
+
if (projectPackageDirectory(args.resolveDir || project, args.path) === undefined)
|
|
65
|
+
return { path: resolved.path };
|
|
66
|
+
imports[args.path] = resolved.path;
|
|
67
|
+
return {
|
|
68
|
+
path: args.kind === "require-call" ? resolved.path : pathToFileURL(resolved.path).href,
|
|
69
|
+
external: true,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
builder.onLoad({ filter: /\.(?:[cm]?[jt]sx?|json)$/ }, async (args) => {
|
|
73
|
+
const contents = await readFile(args.path, "utf8");
|
|
74
|
+
sourceHashes.set(resolve(args.path), sha256(contents));
|
|
75
|
+
const extension = args.path.split(".").at(-1);
|
|
76
|
+
const loader = extension === "tsx" || extension === "jsx" || extension === "json"
|
|
77
|
+
? extension
|
|
78
|
+
: extension.endsWith("ts")
|
|
79
|
+
? "ts"
|
|
80
|
+
: "js";
|
|
81
|
+
if (!contents.includes("import.meta") || loader === "json")
|
|
82
|
+
return { contents, loader, resolveDir: dirname(args.path) };
|
|
83
|
+
const transformed = await transform(contents, {
|
|
84
|
+
loader,
|
|
85
|
+
sourcefile: args.path,
|
|
86
|
+
sourcemap: "inline",
|
|
87
|
+
sourcesContent: true,
|
|
88
|
+
target: "node24",
|
|
89
|
+
format: "esm",
|
|
90
|
+
define: {
|
|
91
|
+
"import.meta.url": JSON.stringify(pathToFileURL(args.path).href),
|
|
92
|
+
"import.meta.dirname": JSON.stringify(dirname(args.path)),
|
|
93
|
+
"import.meta.filename": JSON.stringify(args.path),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
return { contents: transformed.code, loader: "js", resolveDir: dirname(args.path) };
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
const result = await build({
|
|
101
|
+
entryPoints: [entry],
|
|
102
|
+
outfile,
|
|
103
|
+
absWorkingDir: project,
|
|
104
|
+
bundle: true,
|
|
105
|
+
platform: "node",
|
|
106
|
+
format: "esm",
|
|
107
|
+
target: "node24",
|
|
108
|
+
sourcemap: "linked",
|
|
109
|
+
metafile: true,
|
|
110
|
+
logLevel: "silent",
|
|
111
|
+
plugins: [capture],
|
|
112
|
+
...(tsconfig === undefined ? {} : { tsconfig }),
|
|
113
|
+
});
|
|
114
|
+
// Ask the same import-condition resolver for host entry points, independent of author imports.
|
|
115
|
+
await build({
|
|
116
|
+
stdin: {
|
|
117
|
+
contents: [
|
|
118
|
+
"@metamesh/modeling/engine",
|
|
119
|
+
"@metamesh/generator-sdk",
|
|
120
|
+
"@metamesh/generator-sdk/parameters",
|
|
121
|
+
"@metamesh/generator-sdk/packages",
|
|
122
|
+
]
|
|
123
|
+
.filter((name) => name === "@metamesh/modeling/engine" || kind === "generator")
|
|
124
|
+
.map((name) => `import ${JSON.stringify(name)};`)
|
|
125
|
+
.join("\n"),
|
|
126
|
+
resolveDir: project,
|
|
127
|
+
},
|
|
128
|
+
absWorkingDir: project,
|
|
129
|
+
bundle: true,
|
|
130
|
+
platform: "node",
|
|
131
|
+
format: "esm",
|
|
132
|
+
write: false,
|
|
133
|
+
logLevel: "silent",
|
|
134
|
+
plugins: [capture],
|
|
135
|
+
});
|
|
136
|
+
const inputs = Object.keys(result.metafile.inputs).sort();
|
|
137
|
+
const hashes = inputs.map((input) => {
|
|
138
|
+
const file = resolve(project, input);
|
|
139
|
+
const fingerprint = sourceHashes.get(file);
|
|
140
|
+
if (fingerprint === undefined)
|
|
141
|
+
throw new AuthoringError("bundle", "UNTRACKED_SOURCE", `Cannot fingerprint bundled source ${input}.`, 1);
|
|
142
|
+
return `${relative(project, file).replaceAll("\\", "/")}:${fingerprint}`;
|
|
143
|
+
});
|
|
144
|
+
return { fingerprint: sha256(hashes.join("\n")), imports };
|
|
145
|
+
}
|
|
146
|
+
async function executeChild(request, runtimeDirectory, timeoutMs, onLog) {
|
|
147
|
+
const requestFile = join(runtimeDirectory, "request.json");
|
|
148
|
+
const resultFile = join(runtimeDirectory, "result.json");
|
|
149
|
+
await writeFile(requestFile, JSON.stringify(request));
|
|
150
|
+
const child = spawn(process.execPath, [
|
|
151
|
+
"--enable-source-maps",
|
|
152
|
+
fileURLToPath(new URL("./worker.js", import.meta.url)),
|
|
153
|
+
requestFile,
|
|
154
|
+
resultFile,
|
|
155
|
+
], {
|
|
156
|
+
cwd: dirname(request.modulePath),
|
|
157
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
158
|
+
windowsHide: true,
|
|
159
|
+
detached: process.platform !== "win32",
|
|
160
|
+
});
|
|
161
|
+
let logBytes = 0;
|
|
162
|
+
const append = (chunk) => {
|
|
163
|
+
const available = Math.max(0, 64 * 1024 - logBytes);
|
|
164
|
+
if (available > 0)
|
|
165
|
+
onLog?.(chunk.subarray(0, available).toString("utf8"));
|
|
166
|
+
if (logBytes < 64 * 1024 && logBytes + chunk.length > 64 * 1024)
|
|
167
|
+
onLog?.("\n[MetaMesh author logs truncated at 64 KiB]\n");
|
|
168
|
+
logBytes += chunk.length;
|
|
169
|
+
};
|
|
170
|
+
child.stdout.on("data", append);
|
|
171
|
+
child.stderr.on("data", append);
|
|
172
|
+
let timedOut = false;
|
|
173
|
+
let terminated;
|
|
174
|
+
const timer = setTimeout(() => {
|
|
175
|
+
timedOut = true;
|
|
176
|
+
terminated = terminateExecution(child);
|
|
177
|
+
}, timeoutMs);
|
|
178
|
+
try {
|
|
179
|
+
const code = await new Promise((done, reject) => {
|
|
180
|
+
child.once("error", reject);
|
|
181
|
+
child.once("close", done);
|
|
182
|
+
});
|
|
183
|
+
if (timedOut) {
|
|
184
|
+
await terminated;
|
|
185
|
+
return {
|
|
186
|
+
success: false,
|
|
187
|
+
phase: "execute",
|
|
188
|
+
exitCode: 1,
|
|
189
|
+
diagnostics: [
|
|
190
|
+
{
|
|
191
|
+
code: "EXECUTION_TIMEOUT",
|
|
192
|
+
severity: "error",
|
|
193
|
+
message: `Generation exceeded its ${timeoutMs} ms deadline and was terminated.`,
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (code !== 0)
|
|
199
|
+
throw new AuthoringError("execute", "WORKER_FAILED", `Generation process exited with ${code ?? "a signal"}.`);
|
|
200
|
+
return JSON.parse(await readFile(resultFile, "utf8"));
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
clearTimeout(timer);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export async function runAuthoringSource(options) {
|
|
207
|
+
let directory;
|
|
208
|
+
let runtimeDirectory;
|
|
209
|
+
try {
|
|
210
|
+
const project = resolve(options.project ?? process.cwd());
|
|
211
|
+
const timeoutMs = options.timeoutMs ?? 30000;
|
|
212
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 3600000)
|
|
213
|
+
throw new AuthoringError("invocation", "INVALID_TIMEOUT", "Timeout must be an integer from 1 to 3600000 milliseconds.");
|
|
214
|
+
const limits = { ...defaultModelingLimits, ...options.limits };
|
|
215
|
+
for (const [key, value] of Object.entries(limits))
|
|
216
|
+
if (!Object.hasOwn(defaultModelingLimits, key) ||
|
|
217
|
+
!Number.isSafeInteger(value) ||
|
|
218
|
+
value < (key === "maxCircularSegments" ? 3 : 1) ||
|
|
219
|
+
value > defaultModelingLimits[key])
|
|
220
|
+
throw new AuthoringError("invocation", "INVALID_LIMIT", `Resource limit ${key} must be a positive integer no greater than the engine default.`);
|
|
221
|
+
const runId = randomUUID();
|
|
222
|
+
directory = join(resolve(project, options.output ?? ".metamesh/runs"), runId);
|
|
223
|
+
await mkdir(directory, { recursive: true });
|
|
224
|
+
const checked = await checkAuthoringSource(options);
|
|
225
|
+
if (!checked.success) {
|
|
226
|
+
const failure = { ...checked, runDirectory: directory };
|
|
227
|
+
await writeAtomicJson(join(directory, "failure.json"), failure);
|
|
228
|
+
return failure;
|
|
229
|
+
}
|
|
230
|
+
const environment = await discoverAuthoringEnvironment(project);
|
|
231
|
+
runtimeDirectory = join(directory, ".runtime");
|
|
232
|
+
await mkdir(runtimeDirectory);
|
|
233
|
+
const modulePath = join(runtimeDirectory, "model.mjs");
|
|
234
|
+
let bundled;
|
|
235
|
+
try {
|
|
236
|
+
bundled = await bundleEntry(checked.entry, project, modulePath, options.kind, checked.tsconfig);
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
throw new AuthoringError("bundle", "BUNDLE_FAILED", error instanceof Error ? error.message : String(error), 1);
|
|
240
|
+
}
|
|
241
|
+
const enginePath = bundled.imports["@metamesh/modeling/engine"];
|
|
242
|
+
if (enginePath === undefined)
|
|
243
|
+
throw new AuthoringError("environment", "ENGINE_NOT_INSTALLED", "Cannot resolve installed Modeling engine.");
|
|
244
|
+
const request = {
|
|
245
|
+
modulePath,
|
|
246
|
+
directory,
|
|
247
|
+
kind: options.kind,
|
|
248
|
+
params: options.params ?? {},
|
|
249
|
+
export3mf: options.export3mf ?? false,
|
|
250
|
+
enginePath,
|
|
251
|
+
...(options.fontFixtures === undefined
|
|
252
|
+
? {}
|
|
253
|
+
: { fontFixtures: resolve(project, options.fontFixtures) }),
|
|
254
|
+
...(bundled.imports["@metamesh/generator-sdk"] === undefined
|
|
255
|
+
? {}
|
|
256
|
+
: { sdkPath: bundled.imports["@metamesh/generator-sdk"] }),
|
|
257
|
+
...(bundled.imports["@metamesh/generator-sdk/parameters"] === undefined
|
|
258
|
+
? {}
|
|
259
|
+
: { parametersPath: bundled.imports["@metamesh/generator-sdk/parameters"] }),
|
|
260
|
+
...(bundled.imports["@metamesh/generator-sdk/packages"] === undefined
|
|
261
|
+
? {}
|
|
262
|
+
: { packagesPath: bundled.imports["@metamesh/generator-sdk/packages"] }),
|
|
263
|
+
metadata: {
|
|
264
|
+
formatVersion: 1,
|
|
265
|
+
status: "complete",
|
|
266
|
+
runId,
|
|
267
|
+
createdAt: new Date().toISOString(),
|
|
268
|
+
kind: options.kind,
|
|
269
|
+
source: {
|
|
270
|
+
entry: relative(project, checked.entry).replaceAll("\\", "/"),
|
|
271
|
+
fingerprint: bundled.fingerprint,
|
|
272
|
+
},
|
|
273
|
+
packages: Object.fromEntries(environment.packages.map(({ name, version }) => [name, version])),
|
|
274
|
+
policy: { timeoutMs, limits },
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
const result = await executeChild(request, runtimeDirectory, timeoutMs, options.onLog);
|
|
278
|
+
if (!result.success) {
|
|
279
|
+
await rm(join(directory, "manifest.json"), { force: true });
|
|
280
|
+
const failure = { ...result, runDirectory: directory };
|
|
281
|
+
await writeAtomicJson(join(directory, "failure.json"), failure);
|
|
282
|
+
return failure;
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
const failure = {
|
|
288
|
+
...authoringFailure(error),
|
|
289
|
+
...(directory === undefined ? {} : { runDirectory: directory }),
|
|
290
|
+
};
|
|
291
|
+
if (directory !== undefined) {
|
|
292
|
+
await rm(join(directory, "manifest.json"), { force: true }).catch(() => undefined);
|
|
293
|
+
await writeAtomicJson(join(directory, "failure.json"), failure).catch(() => undefined);
|
|
294
|
+
}
|
|
295
|
+
return failure;
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
if (runtimeDirectory !== undefined &&
|
|
299
|
+
directory !== undefined &&
|
|
300
|
+
dirname(resolve(runtimeDirectory)) === resolve(directory))
|
|
301
|
+
await rm(runtimeDirectory, { recursive: true, force: true });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/authoring/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAA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AC;YAC1B,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;SAChE,CAAC;QACF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACnF,MAAM,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,IACE,gBAAgB,KAAK,SAAS;YAC9B,SAAS,KAAK,SAAS;YACvB,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC;YAEzD,MAAM,EAAE,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Bounds3, FinalizedModel, GenerationDiagnostic, ModelingLimits, Vector3 } from "@metamesh/modeling";
|
|
2
|
+
import type { ModelDependencies, SnapshotPart } from "@metamesh/modeling/engine";
|
|
3
|
+
export declare const AUTHORING_PROTOCOL_VERSION = 1;
|
|
4
|
+
export type AuthoringKind = "model" | "generator";
|
|
5
|
+
export type AuthoringPhase = "invocation" | "environment" | "check" | "parameters" | "assets" | "bundle" | "execute" | "artifact" | "render";
|
|
6
|
+
export interface AuthoringDiagnostic {
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly severity: "error" | "warning";
|
|
10
|
+
readonly file?: string;
|
|
11
|
+
readonly line?: number;
|
|
12
|
+
readonly column?: number;
|
|
13
|
+
readonly parameterId?: string;
|
|
14
|
+
readonly path?: readonly (number | string)[];
|
|
15
|
+
readonly context?: Readonly<Record<string, unknown>>;
|
|
16
|
+
}
|
|
17
|
+
export interface AuthoringFailure {
|
|
18
|
+
readonly success: false;
|
|
19
|
+
readonly phase: AuthoringPhase;
|
|
20
|
+
readonly exitCode: 1 | 2;
|
|
21
|
+
readonly diagnostics: readonly AuthoringDiagnostic[];
|
|
22
|
+
readonly runDirectory?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface DocumentationEntry {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly title: string;
|
|
27
|
+
readonly summary: string;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly importPath: string;
|
|
30
|
+
readonly availability: string;
|
|
31
|
+
readonly canonical: string;
|
|
32
|
+
readonly keywords: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
export interface DocumentationManifest {
|
|
35
|
+
readonly formatVersion: 1;
|
|
36
|
+
readonly packageName: string;
|
|
37
|
+
readonly packageVersion: string;
|
|
38
|
+
readonly documents: readonly DocumentationEntry[];
|
|
39
|
+
}
|
|
40
|
+
export interface InstalledAuthoringPackage {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly version: string;
|
|
43
|
+
readonly manifestPath: string;
|
|
44
|
+
readonly documentCount: number;
|
|
45
|
+
}
|
|
46
|
+
export interface AuthoringEnvironment {
|
|
47
|
+
readonly authoringProtocolVersion: typeof AUTHORING_PROTOCOL_VERSION;
|
|
48
|
+
readonly project: string;
|
|
49
|
+
readonly packages: readonly InstalledAuthoringPackage[];
|
|
50
|
+
readonly capabilities: readonly string[];
|
|
51
|
+
}
|
|
52
|
+
export interface CheckOptions {
|
|
53
|
+
readonly entry: string;
|
|
54
|
+
readonly kind: AuthoringKind;
|
|
55
|
+
readonly project?: string;
|
|
56
|
+
readonly tsconfig?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface CheckSuccess {
|
|
59
|
+
readonly success: true;
|
|
60
|
+
readonly entry: string;
|
|
61
|
+
readonly kind: AuthoringKind;
|
|
62
|
+
readonly tsconfig?: string;
|
|
63
|
+
readonly diagnostics: readonly AuthoringDiagnostic[];
|
|
64
|
+
}
|
|
65
|
+
export interface RunOptions extends CheckOptions {
|
|
66
|
+
readonly params?: Readonly<Record<string, unknown>>;
|
|
67
|
+
readonly fontFixtures?: string;
|
|
68
|
+
readonly output?: string;
|
|
69
|
+
readonly timeoutMs?: number;
|
|
70
|
+
readonly limits?: Partial<ModelingLimits>;
|
|
71
|
+
readonly export3mf?: boolean;
|
|
72
|
+
readonly onLog?: (text: string) => void;
|
|
73
|
+
}
|
|
74
|
+
export interface CapturedBuffer {
|
|
75
|
+
readonly path: string;
|
|
76
|
+
readonly bytes: number;
|
|
77
|
+
readonly sha256: string;
|
|
78
|
+
}
|
|
79
|
+
export interface CapturedResource {
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly positions: CapturedBuffer;
|
|
82
|
+
readonly indices: CapturedBuffer;
|
|
83
|
+
readonly measurements: SnapshotPart["measurements"];
|
|
84
|
+
}
|
|
85
|
+
export interface CapturedPart {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly resourceId: string;
|
|
88
|
+
readonly position: Vector3;
|
|
89
|
+
readonly rotation: Vector3;
|
|
90
|
+
readonly color?: string;
|
|
91
|
+
readonly measurements: SnapshotPart["measurements"];
|
|
92
|
+
}
|
|
93
|
+
export interface CapturedRunManifest {
|
|
94
|
+
readonly formatVersion: 1;
|
|
95
|
+
readonly status: "complete";
|
|
96
|
+
readonly runId: string;
|
|
97
|
+
readonly createdAt: string;
|
|
98
|
+
readonly kind: AuthoringKind;
|
|
99
|
+
readonly source: {
|
|
100
|
+
readonly entry: string;
|
|
101
|
+
readonly fingerprint: string;
|
|
102
|
+
};
|
|
103
|
+
readonly packages: Readonly<Record<string, string>>;
|
|
104
|
+
readonly parameters: Readonly<Record<string, unknown>>;
|
|
105
|
+
/** Effective Generator font selections, or declared and byte-verified standalone fixture revisions. */
|
|
106
|
+
readonly assets: readonly {
|
|
107
|
+
readonly faceId: string;
|
|
108
|
+
readonly revision: string;
|
|
109
|
+
readonly weight: number;
|
|
110
|
+
}[];
|
|
111
|
+
readonly policy: {
|
|
112
|
+
readonly timeoutMs: number;
|
|
113
|
+
readonly limits: ModelingLimits;
|
|
114
|
+
};
|
|
115
|
+
readonly diagnostics: readonly GenerationDiagnostic[];
|
|
116
|
+
readonly bounds: Bounds3;
|
|
117
|
+
readonly stats: FinalizedModel["stats"];
|
|
118
|
+
readonly dependencies: ModelDependencies;
|
|
119
|
+
readonly resources: readonly CapturedResource[];
|
|
120
|
+
readonly parts: readonly CapturedPart[];
|
|
121
|
+
readonly export3mf?: CapturedBuffer;
|
|
122
|
+
}
|
|
123
|
+
export interface CapturedGeometry {
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly positions: Float32Array;
|
|
126
|
+
readonly indices: Uint32Array;
|
|
127
|
+
}
|
|
128
|
+
export interface CapturedRun {
|
|
129
|
+
readonly directory: string;
|
|
130
|
+
readonly manifest: CapturedRunManifest;
|
|
131
|
+
readonly resources: readonly CapturedGeometry[];
|
|
132
|
+
}
|
|
133
|
+
export interface RunSuccess {
|
|
134
|
+
readonly success: true;
|
|
135
|
+
readonly runDirectory: string;
|
|
136
|
+
readonly manifest: CapturedRunManifest;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/authoring/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,OAAO,EACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEjF,eAAO,MAAM,0BA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S,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAChD,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;CACrC;AACD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B;AACD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACjD;AACD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/authoring/types.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CapturedRunManifest } from "./types.js";
|
|
2
|
+
export interface WorkerRequest {
|
|
3
|
+
readonly modulePath: string;
|
|
4
|
+
readonly directory: string;
|
|
5
|
+
readonly kind: "model" | "generator";
|
|
6
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
7
|
+
readonly fontFixtures?: string;
|
|
8
|
+
readonly export3mf: boolean;
|
|
9
|
+
readonly metadata: Omit<CapturedRunManifest, "resources" | "parts" | "bounds" | "stats" | "diagnostics" | "dependencies" | "export3mf" | "assets" | "parameters">;
|
|
10
|
+
readonly enginePath: string;
|
|
11
|
+
readonly sdkPath?: string;
|
|
12
|
+
readonly parametersPath?: string;
|
|
13
|
+
readonly packagesPath?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/authoring/worker.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAGV,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CACrB,mBAAmB,EACjB,WAAW,GACX,OAAO,GACP,QAAQ,GACR,OAAO,GACP,aAAa,GACb,cAAc,GACd,WAAW,GACX,QAAQ,GACR,YAAY,CACf,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { captureSnapshot } from "./artifacts.js";
|
|
4
|
+
import { AuthoringError, authoringFailure, isRecord } from "./errors.js";
|
|
5
|
+
function program(value) {
|
|
6
|
+
return isRecord(value) && value.kind === "metamesh-model" && typeof value.generate === "function";
|
|
7
|
+
}
|
|
8
|
+
async function execute(request) {
|
|
9
|
+
let snapshot;
|
|
10
|
+
let dispose;
|
|
11
|
+
let phase = "execute";
|
|
12
|
+
try {
|
|
13
|
+
const entry = await import(pathToFileURL(request.modulePath).href);
|
|
14
|
+
if (!isRecord(entry))
|
|
15
|
+
throw new AuthoringError("execute", "INVALID_ENTRY", "Author entry is not a module.", 1);
|
|
16
|
+
let model;
|
|
17
|
+
let definition;
|
|
18
|
+
let parameters = request.params;
|
|
19
|
+
if (request.kind === "generator") {
|
|
20
|
+
phase = "parameters";
|
|
21
|
+
if (request.packagesPath === undefined || request.parametersPath === undefined)
|
|
22
|
+
throw new AuthoringError("environment", "SDK_NOT_INSTALLED", "Generator execution requires the installed SDK.");
|
|
23
|
+
const packages = (await import(pathToFileURL(request.packagesPath).href));
|
|
24
|
+
const params = (await import(pathToFileURL(request.parametersPath).href));
|
|
25
|
+
definition = packages.parseGeneratorDefinition(entry.definition);
|
|
26
|
+
const parsed = params
|
|
27
|
+
.createParamCodec(definition)
|
|
28
|
+
.safeParse({ ...params.getDefaultParameters(definition), ...request.params });
|
|
29
|
+
if (!parsed.success)
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
phase: "parameters",
|
|
33
|
+
exitCode: 1,
|
|
34
|
+
diagnostics: parsed.issues.map((issue) => ({ ...issue, severity: "error" })),
|
|
35
|
+
};
|
|
36
|
+
parameters = parsed.data;
|
|
37
|
+
const runtime = entry.default;
|
|
38
|
+
if (!isRecord(runtime) ||
|
|
39
|
+
runtime.formatVersion !== packages.GENERATOR_PACKAGE_FORMAT_VERSION ||
|
|
40
|
+
runtime.generatorId !== definition.id ||
|
|
41
|
+
runtime.version !== definition.version ||
|
|
42
|
+
!program(runtime.generate))
|
|
43
|
+
throw new AuthoringError("execute", "INVALID_GENERATOR_MODULE", "Default export must be the Generator module envelope matching definition.", 1);
|
|
44
|
+
model = runtime.generate;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (!program(entry.default))
|
|
48
|
+
throw new AuthoringError("execute", "INVALID_MODEL_PROGRAM", "Default export must be an ordinary ModelProgram.", 1);
|
|
49
|
+
model = entry.default;
|
|
50
|
+
}
|
|
51
|
+
phase = "assets";
|
|
52
|
+
const loaded = request.fontFixtures === undefined
|
|
53
|
+
? undefined
|
|
54
|
+
: await (await import("@metamesh/testkit/font-fixtures")).loadFontFixtures(request.fontFixtures);
|
|
55
|
+
let services;
|
|
56
|
+
if (definition !== undefined) {
|
|
57
|
+
if (loaded !== undefined)
|
|
58
|
+
services = await loaded.prepareServices(definition, parameters);
|
|
59
|
+
else if (definition.parameters.some(({ type }) => type === "font"))
|
|
60
|
+
throw new AuthoringError("assets", "FONT_FIXTURES_REQUIRED", "Generator Font parameters require --font-fixtures <local-descriptors.json>.", 1);
|
|
61
|
+
else {
|
|
62
|
+
if (request.sdkPath === undefined)
|
|
63
|
+
throw new AuthoringError("environment", "SDK_NOT_INSTALLED", "Generator execution requires the installed SDK.");
|
|
64
|
+
services = (await import(pathToFileURL(request.sdkPath).href))
|
|
65
|
+
.UNPREPARED_GENERATOR_SERVICES;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
phase = "execute";
|
|
69
|
+
const { createModelEngine } = (await import(pathToFileURL(request.enginePath).href));
|
|
70
|
+
const engine = await createModelEngine();
|
|
71
|
+
const session = services === undefined
|
|
72
|
+
? engine.createSession(model, {
|
|
73
|
+
limits: request.metadata.policy.limits,
|
|
74
|
+
})
|
|
75
|
+
: engine.createSession(model, {
|
|
76
|
+
services,
|
|
77
|
+
limits: request.metadata.policy.limits,
|
|
78
|
+
});
|
|
79
|
+
dispose = () => session.dispose();
|
|
80
|
+
snapshot = session.run(parameters);
|
|
81
|
+
const exported = request.export3mf ? await engine.export3mf(snapshot.parts) : undefined;
|
|
82
|
+
phase = "artifact";
|
|
83
|
+
const selectedAssets = definition === undefined
|
|
84
|
+
? (loaded?.selections ?? [])
|
|
85
|
+
: definition.parameters
|
|
86
|
+
.filter(({ type }) => type === "font")
|
|
87
|
+
.map(({ id }) => parameters[id])
|
|
88
|
+
.filter((value) => isRecord(value) &&
|
|
89
|
+
typeof value.faceId === "string" &&
|
|
90
|
+
typeof value.revision === "string" &&
|
|
91
|
+
typeof value.weight === "number");
|
|
92
|
+
const manifest = await captureSnapshot(request.directory, snapshot, { ...request.metadata, assets: selectedAssets, parameters }, exported);
|
|
93
|
+
return { success: true, runDirectory: request.directory, manifest };
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error instanceof AuthoringError)
|
|
97
|
+
return authoringFailure(error);
|
|
98
|
+
if (isRecord(error) || error instanceof Error) {
|
|
99
|
+
const shaped = error;
|
|
100
|
+
if (Array.isArray(shaped.issues))
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
phase,
|
|
104
|
+
exitCode: 1,
|
|
105
|
+
diagnostics: shaped.issues.map((issue) => ({
|
|
106
|
+
...issue,
|
|
107
|
+
code: issue.code ?? "INVALID_DEFINITION",
|
|
108
|
+
severity: "error",
|
|
109
|
+
})),
|
|
110
|
+
};
|
|
111
|
+
if (Array.isArray(shaped.diagnostics))
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
phase,
|
|
115
|
+
exitCode: 1,
|
|
116
|
+
diagnostics: shaped.diagnostics.map((issue) => ({
|
|
117
|
+
...issue,
|
|
118
|
+
code: issue.code ?? "GENERATION_ASSERTION",
|
|
119
|
+
})),
|
|
120
|
+
};
|
|
121
|
+
if (typeof shaped.code === "string" && isRecord(shaped.context))
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
phase,
|
|
125
|
+
exitCode: 1,
|
|
126
|
+
diagnostics: [
|
|
127
|
+
{
|
|
128
|
+
code: shaped.code,
|
|
129
|
+
severity: "error",
|
|
130
|
+
message: error instanceof Error ? error.message : "Geometry failure",
|
|
131
|
+
context: shaped.context,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
success: false,
|
|
138
|
+
phase,
|
|
139
|
+
exitCode: phase === "artifact" ? 2 : 1,
|
|
140
|
+
diagnostics: [
|
|
141
|
+
{
|
|
142
|
+
code: phase === "assets" ? "ASSET_PREPARATION_FAILED" : "EXECUTION_FAILED",
|
|
143
|
+
severity: "error",
|
|
144
|
+
message: error instanceof Error ? error.message : String(error),
|
|
145
|
+
...(error instanceof Error && error.stack !== undefined
|
|
146
|
+
? { context: { stack: error.stack } }
|
|
147
|
+
: {}),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
snapshot?.dispose();
|
|
154
|
+
dispose?.();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const requestFile = process.argv[2];
|
|
158
|
+
const resultFile = process.argv[3];
|
|
159
|
+
if (requestFile !== undefined && resultFile !== undefined) {
|
|
160
|
+
const result = await execute(JSON.parse(await readFile(requestFile, "utf8")));
|
|
161
|
+
await writeFile(resultFile, JSON.stringify(result));
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=worker.js.map
|