Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

Name each embedded image in the runtime export sidecar (#287) (#306)

Matthew Kissingerd42342327489
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 82cf5517..abb2083a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,26 @@ does not publish a package.
## Unreleased
+- `kiln_export_to` takes `textures: 'manifest'`, so an MCP author can act on the texture
+ duplication `kiln textures` reports instead of only seeing it. The runtime sidecar gains
+ `textures[]` naming each embedded image by `sha256` and mime type, which lets a destination
+ share one copy across assets rather than loading the embedded copy in every GLB. The option
+ is runtime-only; `editable` publishes the exact saved GLB without calling the exporter, so
+ that combination is refused at the tool rather than accepted and dropped. Exported GLB
+ geometry and images are unchanged, but the GLB is not byte-identical and must not be:
+ provenance binds the sidecar's hash (`kilnProvenanceV1.metadata.sha256`), so adding
+ `textures[]` necessarily moves it and the pair stays verifiable. Discovery capabilities
+ report the option under `assets.exportTo`.
+
+ Two deliberate exclusions. `textures: 'external'` stays a CLI delivery: it writes
+ `x.gltf`, `x.bin` and `textures/<sha256>.<ext>`, while `kiln_export_to` writes one GLB and
+ one sidecar through an atomic pair write, so carrying it would mean new file kinds and a
+ path contract that is not `.glb`. And `kiln_export` does not take the option at all,
+ because it returns resource links that `readAssetResource` re-derives with no options from
+ a fixed filename allowlist -- a link would advertise a `size` that a later `resources/read`
+ of the same URI would not deliver
+ ([#287](https://github.com/instruktlabs/kiln/issues/287)).
+
- Source between the program store's 1 MiB limit and the evaluator transport's 512 KiB is
named as the size problem it is. Such a program saved, edited and validated, then failed
evaluation through the generic invalid-request path, which reported the size as something
diff --git a/dist/agent-run.mjs b/dist/agent-run.mjs
index 9104d630..7a18177a 100644
--- a/dist/agent-run.mjs
+++ b/dist/agent-run.mjs
@@ -47402,7 +47402,7 @@ async function currentCapabilities(context, presentation) {
save: "kiln_save persists exact GLB, source and provenance; draft renders do not populate collections",
resume: `${presentation === "operations" ? "kiln_assets_restore" : "kiln_assets action=restore"} imports a saved revision into the current program store`,
downloads: "kiln_export returns GLB/source/ZIP resource links; client presentation varies",
- exportTo: context.exportRoot && context.assetLibrary ? "kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file" : null,
+ exportTo: context.exportRoot && context.assetLibrary ? "kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file; runtime textures=manifest adds sidecar identities so a host can share images across assets instead of loading each embedded copy" : null,
viewer: "kiln_present opens a saved revision in supporting chat clients with 3D viewing and downloads; kiln view opens a local collection or standalone GLB/ZIP"
},
geometry: {
@@ -50633,7 +50633,8 @@ function createKilnAssetDefs(context, presentation = "grouped") {
const exportToInput = exportInput.extend({
path: z24.string().max(240).describe("Root-relative .glb path with forward slashes, e.g. game/door.glb; runtime adds door.kiln-metadata.json beside it."),
profile: z24.enum(["runtime", "editable"]).default("runtime").describe("runtime: standalone GLB plus metadata sidecar. editable: exact saved GLB only."),
- target: z24.enum(["three"]).optional().describe("Runtime only: a three.js delivery GLB (instancing, quantization, meshopt).")
+ target: z24.enum(["three"]).optional().describe("Runtime only: a three.js delivery GLB (instancing, quantization, meshopt)."),
+ textures: z24.enum(["manifest"]).optional().describe("Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.")
});
const importInput = z24.object({
...selector,
@@ -50843,6 +50844,8 @@ function createKilnExportToDef(writer, inputSchema, library, listCall) {
const input = inputSchema.parse(raw);
if (input.target !== undefined && input.profile !== "runtime")
throw new Error("target requires profile runtime");
+ if (input.textures !== undefined && input.profile !== "runtime")
+ throw new Error("textures requires profile runtime");
await Promise.resolve().then(() => init_export_root());
const destination = validateExportPath(input.path);
await Promise.resolve().then(() => init_asset_export());
@@ -50854,7 +50857,8 @@ function createKilnExportToDef(writer, inputSchema, library, listCall) {
const output = await exportAssetGlb(record, {
profile: "runtime",
metadataFileName: destination.metadataFileName,
- ...input.target ? { target: input.target } : {}
+ ...input.target ? { target: input.target } : {},
+ ...input.textures ? { textures: input.textures } : {}
});
if (output.profile !== "runtime")
throw new Error("Expected runtime export");
diff --git a/dist/build.json b/dist/build.json
index b07ab47d..9018cf73 100644
--- a/dist/build.json
+++ b/dist/build.json
@@ -2,10 +2,10 @@
"schemaVersion": 1,
"entries": {
"worker": {
- "identity": "sha256:63990784c232b14cffe8a4e4f4d88d5a2417eb9de11d820632fb0c3fb90c9006",
+ "identity": "sha256:d5e4f9f962c7264d80419e27427a261512213dc8782675de23aba660a3356421",
"engineVersion": "1.5.0",
"toolchain": "[email protected]",
- "sourceHash": "26c96371d19403636794fb2d7b06d6262980bfedb28f4fd92b41b1c1727a6621",
+ "sourceHash": "b660e9c652ad45c534674f82d4d1e4aa58af404d01b3bb64eff2093524fba4fa",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -40,10 +40,10 @@
"bundleHash": "sha256:395bac1322db31159ac553f054496245315a1473099fd4c6bd0e1e7b339aed66"
},
"agent-run": {
- "identity": "sha256:63990784c232b14cffe8a4e4f4d88d5a2417eb9de11d820632fb0c3fb90c9006",
+ "identity": "sha256:d5e4f9f962c7264d80419e27427a261512213dc8782675de23aba660a3356421",
"engineVersion": "1.5.0",
"toolchain": "[email protected]",
- "sourceHash": "26c96371d19403636794fb2d7b06d6262980bfedb28f4fd92b41b1c1727a6621",
+ "sourceHash": "b660e9c652ad45c534674f82d4d1e4aa58af404d01b3bb64eff2093524fba4fa",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -75,13 +75,13 @@
},
"target": "node",
"file": "agent-run.mjs",
- "bundleHash": "sha256:9a9fa4577619b5a060f2cd113b32b757715678a26e9645a581dccc72ba05dd27"
+ "bundleHash": "sha256:9757bd38ccbb9c8963edaa014fbcac2c950074032234f51f32b7e2f03a4044ca"
},
"agent-providers": {
- "identity": "sha256:63990784c232b14cffe8a4e4f4d88d5a2417eb9de11d820632fb0c3fb90c9006",
+ "identity": "sha256:d5e4f9f962c7264d80419e27427a261512213dc8782675de23aba660a3356421",
"engineVersion": "1.5.0",
"toolchain": "[email protected]",
- "sourceHash": "26c96371d19403636794fb2d7b06d6262980bfedb28f4fd92b41b1c1727a6621",
+ "sourceHash": "b660e9c652ad45c534674f82d4d1e4aa58af404d01b3bb64eff2093524fba4fa",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -116,10 +116,10 @@
"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"
},
"mcp": {
- "identity": "sha256:63990784c232b14cffe8a4e4f4d88d5a2417eb9de11d820632fb0c3fb90c9006",
+ "identity": "sha256:d5e4f9f962c7264d80419e27427a261512213dc8782675de23aba660a3356421",
"engineVersion": "1.5.0",
"toolchain": "[email protected]",
- "sourceHash": "26c96371d19403636794fb2d7b06d6262980bfedb28f4fd92b41b1c1727a6621",
+ "sourceHash": "b660e9c652ad45c534674f82d4d1e4aa58af404d01b3bb64eff2093524fba4fa",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -151,13 +151,13 @@
},
"target": "node",
"file": "mcp-server.mjs",
- "bundleHash": "sha256:deeb947091b693e92337a2081678ed06cd0a2d23f813a375001c31dbf529a815"
+ "bundleHash": "sha256:feca46c85c8813b816fb71c1dea9211ede75eed2403d8a093e511fc3e6d8690a"
},
"cli": {
- "identity": "sha256:63990784c232b14cffe8a4e4f4d88d5a2417eb9de11d820632fb0c3fb90c9006",
+ "identity": "sha256:d5e4f9f962c7264d80419e27427a261512213dc8782675de23aba660a3356421",
"engineVersion": "1.5.0",
"toolchain": "[email protected]",
- "sourceHash": "26c96371d19403636794fb2d7b06d6262980bfedb28f4fd92b41b1c1727a6621",
+ "sourceHash": "b660e9c652ad45c534674f82d4d1e4aa58af404d01b3bb64eff2093524fba4fa",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -189,13 +189,13 @@
},
"target": "node",
"file": "cli.mjs",
- "bundleHash": "sha256:fa19d5e178e7293d707e220628c6b1a361a0e90ddf8dab4ad7c31b1b9630b257"
+ "bundleHash": "sha256:66ba511f41eb4da4d75f1c716980605b0fc8b1ec97265661228924b607cfa411"
},
"engine": {
- "identity": "sha256:63990784c232b14cffe8a4e4f4d88d5a2417eb9de11d820632fb0c3fb90c9006",
+ "identity": "sha256:d5e4f9f962c7264d80419e27427a261512213dc8782675de23aba660a3356421",
"engineVersion": "1.5.0",
"toolchain": "[email protected]",
- "sourceHash": "26c96371d19403636794fb2d7b06d6262980bfedb28f4fd92b41b1c1727a6621",
+ "sourceHash": "b660e9c652ad45c534674f82d4d1e4aa58af404d01b3bb64eff2093524fba4fa",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -227,7 +227,7 @@
},
"target": "node",
"file": "mcp-engine.mjs",
- "bundleHash": "sha256:e090b7f1806ce131c7440847c3056b283eca5d80ab59e9b70958912a8672efde"
+ "bundleHash": "sha256:3fdffe687e4af2b168843b2a4566f4c4bdbe54fa6125c5ee6d7198859387813a"
}
}
}
diff --git a/dist/cli.mjs b/dist/cli.mjs
index 4dd79a83..98a8650e 100644
--- a/dist/cli.mjs
+++ b/dist/cli.mjs
@@ -51376,7 +51376,7 @@ async function currentCapabilities(context, presentation) {
save: "kiln_save persists exact GLB, source and provenance; draft renders do not populate collections",
resume: `${presentation === "operations" ? "kiln_assets_restore" : "kiln_assets action=restore"} imports a saved revision into the current program store`,
downloads: "kiln_export returns GLB/source/ZIP resource links; client presentation varies",
- exportTo: context.exportRoot && context.assetLibrary ? "kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file" : null,
+ exportTo: context.exportRoot && context.assetLibrary ? "kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file; runtime textures=manifest adds sidecar identities so a host can share images across assets instead of loading each embedded copy" : null,
viewer: "kiln_present opens a saved revision in supporting chat clients with 3D viewing and downloads; kiln view opens a local collection or standalone GLB/ZIP"
},
geometry: {
@@ -55604,7 +55604,8 @@ function createKilnAssetDefs(context, presentation = "grouped") {
const exportToInput = exportInput.extend({
path: z25.string().max(240).describe("Root-relative .glb path with forward slashes, e.g. game/door.glb; runtime adds door.kiln-metadata.json beside it."),
profile: z25.enum(["runtime", "editable"]).default("runtime").describe("runtime: standalone GLB plus metadata sidecar. editable: exact saved GLB only."),
- target: z25.enum(["three"]).optional().describe("Runtime only: a three.js delivery GLB (instancing, quantization, meshopt).")
+ target: z25.enum(["three"]).optional().describe("Runtime only: a three.js delivery GLB (instancing, quantization, meshopt)."),
+ textures: z25.enum(["manifest"]).optional().describe("Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.")
});
const importInput = z25.object({
...selector,
@@ -55814,6 +55815,8 @@ function createKilnExportToDef(writer, inputSchema, library, listCall) {
const input = inputSchema.parse(raw);
if (input.target !== undefined && input.profile !== "runtime")
throw new Error("target requires profile runtime");
+ if (input.textures !== undefined && input.profile !== "runtime")
+ throw new Error("textures requires profile runtime");
await Promise.resolve().then(() => init_export_root());
const destination = validateExportPath(input.path);
await Promise.resolve().then(() => init_asset_export());
@@ -55825,7 +55828,8 @@ function createKilnExportToDef(writer, inputSchema, library, listCall) {
const output = await exportAssetGlb(record, {
profile: "runtime",
metadataFileName: destination.metadataFileName,
- ...input.target ? { target: input.target } : {}
+ ...input.target ? { target: input.target } : {},
+ ...input.textures ? { textures: input.textures } : {}
});
if (output.profile !== "runtime")
throw new Error("Expected runtime export");
diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjs
index 9c311666..a4c8fa0f 100644
--- a/dist/mcp-engine.mjs
+++ b/dist/mcp-engine.mjs
@@ -51692,7 +51692,7 @@ async function currentCapabilities(context, presentation) {
save: "kiln_save persists exact GLB, source and provenance; draft renders do not populate collections",
resume: `${presentation === "operations" ? "kiln_assets_restore" : "kiln_assets action=restore"} imports a saved revision into the current program store`,
downloads: "kiln_export returns GLB/source/ZIP resource links; client presentation varies",
- exportTo: context.exportRoot && context.assetLibrary ? "kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file" : null,
+ exportTo: context.exportRoot && context.assetLibrary ? "kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file; runtime textures=manifest adds sidecar identities so a host can share images across assets instead of loading each embedded copy" : null,
viewer: "kiln_present opens a saved revision in supporting chat clients with 3D viewing and downloads; kiln view opens a local collection or standalone GLB/ZIP"
},
geometry: {
@@ -54794,7 +54794,8 @@ function createKilnAssetDefs(context, presentation = "grouped") {
const exportToInput = exportInput.extend({
path: z25.string().max(240).describe("Root-relative .glb path with forward slashes, e.g. game/door.glb; runtime adds door.kiln-metadata.json beside it."),
profile: z25.enum(["runtime", "editable"]).default("runtime").describe("runtime: standalone GLB plus metadata sidecar. editable: exact saved GLB only."),
- target: z25.enum(["three"]).optional().describe("Runtime only: a three.js delivery GLB (instancing, quantization, meshopt).")
+ target: z25.enum(["three"]).optional().describe("Runtime only: a three.js delivery GLB (instancing, quantization, meshopt)."),
+ textures: z25.enum(["manifest"]).optional().describe("Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.")
});
const importInput = z25.object({
...selector,
@@ -55004,6 +55005,8 @@ function createKilnExportToDef(writer, inputSchema, library, listCall) {
const input = inputSchema.parse(raw);
if (input.target !== undefined && input.profile !== "runtime")
throw new Error("target requires profile runtime");
+ if (input.textures !== undefined && input.profile !== "runtime")
+ throw new Error("textures requires profile runtime");
await Promise.resolve().then(() => init_export_root());
const destination = validateExportPath(input.path);
await Promise.resolve().then(() => init_asset_export());
@@ -55015,7 +55018,8 @@ function createKilnExportToDef(writer, inputSchema, library, listCall) {
const output = await exportAssetGlb(record, {
profile: "runtime",
metadataFileName: destination.metadataFileName,
- ...input.target ? { target: input.target } : {}
+ ...input.target ? { target: input.target } : {},
+ ...input.textures ? { textures: input.textures } : {}
});
if (output.profile !== "runtime")
throw new Error("Expected runtime export");
diff --git a/dist/mcp-server.mjs b/dist/mcp-server.mjs
index 28e00ee2..9b3ce30f 100644
--- a/dist/mcp-server.mjs
+++ b/dist/mcp-server.mjs
@@ -2047,6 +2047,13 @@ var mcp_manifest_default = {
enum: [
"three"
]
+ },
+ textures: {
+ description: "Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.",
+ type: "string",
+ enum: [
+ "manifest"
+ ]
}
},
required: [
diff --git a/docs/tools.md b/docs/tools.md
index c053b2c8..4cf5ca52 100644
--- a/docs/tools.md
+++ b/docs/tools.md
@@ -1897,6 +1897,13 @@ Write one saved revision's GLB to a path under the host's export root. Default r
"enum": [
"three"
]
+ },
+ "textures": {
+ "description": "Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.",
+ "type": "string",
+ "enum": [
+ "manifest"
+ ]
}
},
"required": [
diff --git a/src/generated/mcp-manifest.json b/src/generated/mcp-manifest.json
index 2b39f9a5..55376a40 100644
--- a/src/generated/mcp-manifest.json
+++ b/src/generated/mcp-manifest.json
@@ -2031,6 +2031,13 @@
"enum": [
"three"
]
+ },
+ "textures": {
+ "description": "Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.",
+ "type": "string",
+ "enum": [
+ "manifest"
+ ]
}
},
"required": [
diff --git a/src/tools/__tests__/export-to.test.ts b/src/tools/__tests__/export-to.test.ts
index 51ace4fb..019179ce 100644
--- a/src/tools/__tests__/export-to.test.ts
+++ b/src/tools/__tests__/export-to.test.ts
@@ -96,6 +96,7 @@ describe('kiln_export_to advertisement', () => {
'profile',
'revisionId',
'target',
+ 'textures',
]);
// Native: a delivery tool, present only with both host services.
expect(names(createKilnNativeToolRegistry({ exportRoot: unusedWriter }, {}))).not.toContain(
@@ -292,3 +293,104 @@ describe('kiln_export_to refusals', () => {
expect(await readFile(join(root, 'gate.kiln-metadata.json'), 'utf8')).toBe('orphan');
});
});
+
+/**
+ * Runtime texture manifest over MCP (#287). `kiln textures` reports the duplication a
+ * delivered set ships; acting on it needs the option the CLI already has. Only
+ * `kiln_export_to` can carry it: it materializes files at a path the caller names, whereas
+ * `kiln_export` returns resource links that `readAssetResource` re-derives with no options,
+ * so a link's advertised size would not match what `resources/read` later returns.
+ */
+const TEXTURED =
+ "const meta = { name: 'Tex' }; function build() { const root = createRoot('Tex'); const albedo = proceduralTexture({ schemaVersion: 2, size: 8, usage: 'albedo', name: 'A', layers: [{ op: 'checker', colorA: 0xc8321e, colorB: 0x1e4bc8, squares: 2 }] }); const normal = normalMapFromHeight(albedo, { name: 'N' }); createPart('Body', boxGeo(1,1,1), pbrMaterial({ albedo, normal }), { parent: root, position: [0,0.5,0] }); return root; }";
+
+describe('kiln_export_to runtime texture manifest (#287)', () => {
+ /** A textured revision and a fresh export root bound to it. */
+ async function texturedExportTo() {
+ const rendered = await renderGLBInProcess(TEXTURED);
+ const textured = await library.save('project', {
+ name: 'Tex',
+ code: TEXTURED,
+ glb: rendered.glb,
+ });
+ const root = join(base, `tex-exports-${++roots}`);
+ await mkdir(root);
+ const def = createKilnProgramToolRegistry({
+ assetLibrary: library,
+ exportRoot: createExportRootWriter(root),
+ }).find((candidate) => candidate.name === 'kiln_export_to')!;
+ const selector = {
+ collection: 'project',
+ assetId: textured.assetId,
+ revisionId: textured.revisionId,
+ };
+ return { root, run: (input: Record<string, unknown>) => def.run({ ...selector, ...input }) };
+ }
+
+ /** The JSON chunk of a GLB: header is 12 bytes, then an 8-byte chunk header. */
+ const glbJson = (bytes: Uint8Array) => {
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
+ const jsonLength = view.getUint32(12, true);
+ return JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + jsonLength))) as {
+ asset: {
+ extras?: { kilnProvenanceV1?: { metadata: { uri: string; sha256: string } } };
+ };
+ };
+ };
+
+ const sidecar = async (root: string, name: string) =>
+ JSON.parse(await readFile(join(root, name), 'utf8')) as {
+ textures?: { sha256: string; mimeType: string }[];
+ };
+
+ test('textures manifest names each image; omitting it leaves the sidecar unchanged', async () => {
+ const { root, run } = await texturedExportTo();
+
+ // Without the option the sidecar carries no texture identities at all.
+ await run({ path: 'plain.glb' });
+ expect((await sidecar(root, 'plain.kiln-metadata.json')).textures).toBeUndefined();
+
+ // With it, every embedded image is named by its exact bytes, once each.
+ await run({ path: 'named.glb', textures: 'manifest' });
+ const named = (await sidecar(root, 'named.kiln-metadata.json')).textures;
+ expect(named).toBeDefined();
+ expect(named!.length).toBe(2);
+ for (const entry of named!) {
+ expect(entry.sha256).toMatch(/^sha256:[0-9a-f]{64}$/);
+ expect(entry.mimeType).toBe('image/png');
+ }
+ // Distinct images, so a host can share them rather than re-upload each copy.
+ expect(new Set(named!.map((entry) => entry.sha256)).size).toBe(2);
+
+ // The GLB is not byte-identical, and should not be: provenance binds the sidecar's hash,
+ // so adding textures[] necessarily moves it. What must hold is that the pair stays bound
+ // and that nothing else in the GLB moved.
+ const namedGlb = new Uint8Array(await readFile(join(root, 'named.glb')));
+ const plainGlb = new Uint8Array(await readFile(join(root, 'plain.glb')));
+ const bound = (glb: Uint8Array) => glbJson(glb).asset.extras!.kilnProvenanceV1!.metadata;
+ expect(bound(namedGlb).sha256).toBe(
+ sha256(new Uint8Array(await readFile(join(root, 'named.kiln-metadata.json')))),
+ );
+ expect(bound(plainGlb).sha256).toBe(
+ sha256(new Uint8Array(await readFile(join(root, 'plain.kiln-metadata.json')))),
+ );
+ // Strip the provenance both carry and the two deliveries are the same asset.
+ const stripped = (glb: Uint8Array) => {
+ const json = glbJson(glb);
+ delete json.asset.extras;
+ return JSON.stringify(json);
+ };
+ expect(stripped(namedGlb)).toBe(stripped(plainGlb));
+ });
+
+ test('the option is runtime-only, and external stays a CLI delivery', async () => {
+ const { run } = await texturedExportTo();
+ // editable writes the exact saved GLB, so a texture manifest has nothing to describe.
+ await expect(run({ path: 'e.glb', profile: 'editable', textures: 'manifest' })).rejects.toThrow(
+ /runtime/i,
+ );
+ // `external` writes gltf + bin + textures/N files; this tool writes one GLB and one
+ // sidecar, so the schema refuses it rather than failing deeper with a confusing error.
+ await expect(run({ path: 'x.glb', textures: 'external' })).rejects.toThrow();
+ });
+});
diff --git a/src/tools/discovery.ts b/src/tools/discovery.ts
index 44f1c4fe..40e81e66 100644
--- a/src/tools/discovery.ts
+++ b/src/tools/discovery.ts
@@ -159,7 +159,7 @@ async function currentCapabilities(
// Advertised under the registry's own condition (#207); the host's absolute root stays private.
exportTo:
context.exportRoot && context.assetLibrary
- ? 'kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file'
+ ? 'kiln_export_to writes a saved revision as files at a path relative to the host export root and never replaces a file; runtime textures=manifest adds sidecar identities so a host can share images across assets instead of loading each embedded copy'
: null,
viewer:
'kiln_present opens a saved revision in supporting chat clients with 3D viewing and downloads; kiln view opens a local collection or standalone GLB/ZIP',
diff --git a/src/tools/registry.ts b/src/tools/registry.ts
index e76ffbc6..4a7b88bb 100644
--- a/src/tools/registry.ts
+++ b/src/tools/registry.ts
@@ -3076,6 +3076,12 @@ export function createKilnAssetDefs(
.enum(['three'])
.optional()
.describe('Runtime only: a three.js delivery GLB (instancing, quantization, meshopt).'),
+ textures: z
+ .enum(['manifest'])
+ .optional()
+ .describe(
+ 'Runtime only: name each embedded image by sha256 in the sidecar, so a host can share images across assets. CLI --textures external writes them as separate files instead.',
+ ),
});
const importInput = z.object({
...selector,
@@ -3352,6 +3358,7 @@ function createKilnExportToDef(
path: string;
profile: 'runtime' | 'editable';
target?: 'three';
+ textures?: 'manifest';
}>,
library: () => import('../assets').AssetLibrary,
listCall: (collection: string) => string,
@@ -3371,6 +3378,11 @@ function createKilnExportToDef(
const input = inputSchema.parse(raw);
if (input.target !== undefined && input.profile !== 'runtime')
throw new Error('target requires profile runtime');
+ // The editable branch publishes the exact saved GLB without calling the exporter, so
+ // the shared runtime guard never sees this combination: refuse it here instead of
+ // accepting the option and silently dropping it.
+ if (input.textures !== undefined && input.profile !== 'runtime')
+ throw new Error('textures requires profile runtime');
const { validateExportPath } = await import('../export-root');
const destination = validateExportPath(input.path);
const { exportAssetGlb, validateMetadataFileName } = await import('../asset-export');
@@ -3388,6 +3400,7 @@ function createKilnExportToDef(
profile: 'runtime',
metadataFileName: destination.metadataFileName,
...(input.target ? { target: input.target } : {}),
+ ...(input.textures ? { textures: input.textures } : {}),
});
if (output.profile !== 'runtime') throw new Error('Expected runtime export');
files.push(