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.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
Let kiln_export build a programRef, so an audit can read bytes before a save (#309) (#321)
Matthew Kissinger6bf1e5f1acfe
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f02bbb5c..ee8aff9c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,8 +33,15 @@ does not publish a package.generator or prove the bytes came from it. `external` still requires an HTTP(S) URL and existingrecords keep their revision ids. A record with this source is refused by an engine older thanthis one.-||||||| 8e08b9c-||||||| cde4dfe++- `kiln_export` takes a `programRef`, so a destination audit can read the built GLB before a save+ instead of after one (#309). It returns a `kiln://programs/{program}/{sha256}/asset.glb` resource+ with the size, hash, triangle count and draw diagnostics, and writes nothing. The bytes are the+ ones `kiln_save` then persists. The URI pins the hash it was issued for and the build runs again+ on read, so a program this host now builds differently is refused rather than served as the same+ bytes. The `runtime` profile still needs a saved revision. This changes `kiln_export`'s input+ schema: `assetId` and `revisionId` are now optional in the advertised shape and checked when the+ tool runs. `kiln_present` and `kiln_export_to` are unchanged.## 1.6.0 (2026-10-27)@@ -175,8 +182,6 @@ does not publish a package.both list — so an author whose call failed for an unrelated reason was told those fields didnot exist. A test now asserts the advice names every field the validator accepts, so the textand the validator cannot drift apart again.-||||||| 24bc8fd-## 1.5.0 (2026-10-25)diff --git a/dist/agent-run.mjs b/dist/agent-run.mjsindex 98a25a96..fc7c844b 100644--- a/dist/agent-run.mjs+++ b/dist/agent-run.mjs@@ -41921,6 +41921,7 @@ var init_draw_diagnostics = __esm(() => {var exports_assets_resources = {};__export(exports_assets_resources, {assetLinks: () => assetLinks,+ programBuildLink: () => programBuildLink,runtimeAssetLinks: () => runtimeAssetLinks});function assetLinks(collection, manifest) {@@ -41956,6 +41957,16 @@ async function runtimeAssetLinks(collection, record, derived) {annotations: { audience: ["user"], priority: name.endsWith(".glb") ? 0.9 : 0.3 }}));}+function programBuildLink(programRef, rendered) {+ return {+ type: "resource_link",+ name: "asset.glb",+ uri: `kiln://programs/${encodeURIComponent(programRef)}/${rendered.artifactGlbSha256.replace("sha256:", "")}/asset.glb`,+ mimeType: "model/gltf-binary",+ size: rendered.glb.byteLength,+ annotations: { audience: ["user"], priority: priorities["asset.glb"] }+ };+}var audiences, priorities;var init_assets_resources = __esm(() => {init_assets();@@ -50562,6 +50573,16 @@ async function parentRevisionComparison(parent, child) {};}}+async function buildProgramGlb(programRef, context) {+ if (!context.programStore)+ throw new Error("Building a programRef requires a program store.");+ const code = await context.programStore.get(programRef);+ await context.prepareBuildProvenance?.();+ return evaluateGeneratedSource(code, {+ ...context,+ requirements: toolRequirements(context).binding+ });+}async function buildProgramAssetDraft(code, context, backdrop) {await context.prepareBuildProvenance?.();const callContext = {@@ -50681,6 +50702,9 @@ function createKilnAssetDefs(context, presentation = "grouped") {});const exportInput = z24.object(selector);const profileExportInput = exportInput.extend({+ assetId: selector.assetId.optional(),+ revisionId: selector.revisionId.optional(),+ programRef: z24.string().regex(programRefPattern).optional().describe("A program to build instead of a saved revision; assetId and revisionId stay unset."),profile: z24.enum(["editable", "runtime"]).default("editable").describe("editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.")});const exportToInput = exportInput.extend({@@ -50836,10 +50860,31 @@ function createKilnAssetDefs(context, presentation = "grouped") {},{name: "kiln_export",- description: "Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",+ description: "Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",inputSchema: profileExportInput,run: async (raw) => {const input = profileExportInput.parse(raw);+ if (input.programRef) {+ if (input.assetId || input.revisionId)+ throw new Error("kiln_export takes programRef or assetId and revisionId, not both: programRef builds a program, the others select a saved revision.");+ if (input.profile === "runtime")+ throw new Error("The runtime profile exports a saved revision. Call kiln_save with this programRef first, or omit profile for the built GLB.");+ const rendered = await buildProgramGlb(input.programRef, context);+ await Promise.resolve().then(() => init_draw_diagnostics());+ return {+ ok: true,+ programRef: input.programRef,+ profile: input.profile,+ sha256: rendered.artifactGlbSha256,+ triangles: rendered.tris,+ drawDiagnostics: await inspectDrawDiagnostics(rendered.glb),+ resources: [+ (await Promise.resolve().then(() => (init_assets_resources(), exports_assets_resources))).programBuildLink(input.programRef, rendered)+ ]+ };+ }+ if (!input.assetId || !input.revisionId)+ throw new Error("kiln_export requires assetId and revisionId for a saved revision, or programRef for a built program.");const record = await readSavedRevision(library(), input.collection, input.assetId, input.revisionId, listCall(input.collection));await Promise.resolve().then(() => init_draw_diagnostics());if (input.profile === "runtime") {diff --git a/dist/build.json b/dist/build.jsonindex 72566cd9..2fc4acdd 100644--- a/dist/build.json+++ b/dist/build.json@@ -2,10 +2,10 @@"schemaVersion": 1,"entries": {"worker": {- "identity": "sha256:34f79b576bec07a5eb9944495cd4926260346b7d57df7a8eee52ef30ea752447",+ "identity": "sha256:20096a0f76f451db878ce17903d33be602452af6c732c6df93843ce6d90ffbf5","engineVersion": "1.6.0","toolchain": "[email protected]",- "sourceHash": "f34719998cf3aceed4e9d29a9e29e3093338af2c26835af59f38ad2ae7ac0048",+ "sourceHash": "d82abaac51497bb95ebdf349b61ce27cff7ecdccbeec79bab7f2ee0a5b480b85","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {@@ -40,10 +40,10 @@"bundleHash": "sha256:99c009df78ef1da11fa1232eedf6b97da6792b9dfe4852196fcb0dcabdea23eb"},"agent-run": {- "identity": "sha256:34f79b576bec07a5eb9944495cd4926260346b7d57df7a8eee52ef30ea752447",+ "identity": "sha256:20096a0f76f451db878ce17903d33be602452af6c732c6df93843ce6d90ffbf5","engineVersion": "1.6.0","toolchain": "[email protected]",- "sourceHash": "f34719998cf3aceed4e9d29a9e29e3093338af2c26835af59f38ad2ae7ac0048",+ "sourceHash": "d82abaac51497bb95ebdf349b61ce27cff7ecdccbeec79bab7f2ee0a5b480b85","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {@@ -75,13 +75,13 @@},"target": "node","file": "agent-run.mjs",- "bundleHash": "sha256:258794a0ac9f55380be4f268eac6d3693545155f254e868fa57723f93b62996c"+ "bundleHash": "sha256:70ade618edc49cbf09615733a23c45deb68504f263753c013df28c9f2b68e597"},"agent-providers": {- "identity": "sha256:34f79b576bec07a5eb9944495cd4926260346b7d57df7a8eee52ef30ea752447",+ "identity": "sha256:20096a0f76f451db878ce17903d33be602452af6c732c6df93843ce6d90ffbf5","engineVersion": "1.6.0","toolchain": "[email protected]",- "sourceHash": "f34719998cf3aceed4e9d29a9e29e3093338af2c26835af59f38ad2ae7ac0048",+ "sourceHash": "d82abaac51497bb95ebdf349b61ce27cff7ecdccbeec79bab7f2ee0a5b480b85","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {@@ -116,10 +116,10 @@"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"},"mcp": {- "identity": "sha256:34f79b576bec07a5eb9944495cd4926260346b7d57df7a8eee52ef30ea752447",+ "identity": "sha256:20096a0f76f451db878ce17903d33be602452af6c732c6df93843ce6d90ffbf5","engineVersion": "1.6.0","toolchain": "[email protected]",- "sourceHash": "f34719998cf3aceed4e9d29a9e29e3093338af2c26835af59f38ad2ae7ac0048",+ "sourceHash": "d82abaac51497bb95ebdf349b61ce27cff7ecdccbeec79bab7f2ee0a5b480b85","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {@@ -151,13 +151,13 @@},"target": "node","file": "mcp-server.mjs",- "bundleHash": "sha256:4c8f00a36bcc57be3ff7afb3df03646ffebdc355e7bb42478112aa2ac4c1319f"+ "bundleHash": "sha256:ec8ccc0d1f25184650191131ad5dcd25e1434408f92bdf8d2ef150e1bf5f266b"},"cli": {- "identity": "sha256:34f79b576bec07a5eb9944495cd4926260346b7d57df7a8eee52ef30ea752447",+ "identity": "sha256:20096a0f76f451db878ce17903d33be602452af6c732c6df93843ce6d90ffbf5","engineVersion": "1.6.0","toolchain": "[email protected]",- "sourceHash": "f34719998cf3aceed4e9d29a9e29e3093338af2c26835af59f38ad2ae7ac0048",+ "sourceHash": "d82abaac51497bb95ebdf349b61ce27cff7ecdccbeec79bab7f2ee0a5b480b85","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {@@ -189,13 +189,13 @@},"target": "node","file": "cli.mjs",- "bundleHash": "sha256:49f500e23d45bf835b538c33c0f21f8474c02d71f914b599365ec5c0b2a8cdec"+ "bundleHash": "sha256:4bd432be5ccad7711c89aedae8f4ca355cd13962da9ab9e9cf993cf6fdc6d7bf"},"engine": {- "identity": "sha256:34f79b576bec07a5eb9944495cd4926260346b7d57df7a8eee52ef30ea752447",+ "identity": "sha256:20096a0f76f451db878ce17903d33be602452af6c732c6df93843ce6d90ffbf5","engineVersion": "1.6.0","toolchain": "[email protected]",- "sourceHash": "f34719998cf3aceed4e9d29a9e29e3093338af2c26835af59f38ad2ae7ac0048",+ "sourceHash": "d82abaac51497bb95ebdf349b61ce27cff7ecdccbeec79bab7f2ee0a5b480b85","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10","dependencies": {@@ -227,7 +227,7 @@},"target": "node","file": "mcp-engine.mjs",- "bundleHash": "sha256:5dbd9e34a3f9e980874c850128dc192f9115c4345839165f364620889419f82e"+ "bundleHash": "sha256:8f1663acee54d91c408e066e0facc28a69738fb350a0f23138169489143ed4ca"}}}diff --git a/dist/cli.mjs b/dist/cli.mjsindex cedd34c1..9f1b35e5 100644--- a/dist/cli.mjs+++ b/dist/cli.mjs@@ -54155,6 +54155,7 @@ var exports_assets_resources = {};__export(exports_assets_resources, {assetLinks: () => assetLinks,exportLibraryAssetBundle: () => exportLibraryAssetBundle,+ programBuildLink: () => programBuildLink,readAssetResource: () => readAssetResource,runtimeAssetLinks: () => runtimeAssetLinks});@@ -54191,6 +54192,16 @@ async function runtimeAssetLinks(collection, record, derived) {annotations: { audience: ["user"], priority: name.endsWith(".glb") ? 0.9 : 0.3 }}));}+function programBuildLink(programRef, rendered) {+ return {+ type: "resource_link",+ name: "asset.glb",+ uri: `kiln://programs/${encodeURIComponent(programRef)}/${rendered.artifactGlbSha256.replace("sha256:", "")}/asset.glb`,+ mimeType: "model/gltf-binary",+ size: rendered.glb.byteLength,+ annotations: { audience: ["user"], priority: priorities["asset.glb"] }+ };+}async function readAssetResource(library, uri) {const match = /^kiln:\/\/assets\/([a-z][a-z0-9_-]{0,79})\/([a-z][a-z0-9_-]{0,79})\/([a-z][a-z0-9_-]{0,79})\/(asset\.glb|runtime\.glb|runtime\.kiln-metadata\.json|source\.kiln\.js|preview\.png|manifest\.json|editable\.zip)$/.exec(uri);if (!match)@@ -55547,6 +55558,16 @@ async function parentRevisionComparison(parent, child) {};}}+async function buildProgramGlb(programRef, context) {+ if (!context.programStore)+ throw new Error("Building a programRef requires a program store.");+ const code = await context.programStore.get(programRef);+ await context.prepareBuildProvenance?.();+ return evaluateGeneratedSource(code, {+ ...context,+ requirements: toolRequirements(context).binding+ });+}async function buildProgramAssetDraft(code, context, backdrop) {await context.prepareBuildProvenance?.();const callContext = {@@ -55666,6 +55687,9 @@ function createKilnAssetDefs(context, presentation = "grouped") {});const exportInput = z25.object(selector);const profileExportInput = exportInput.extend({+ assetId: selector.assetId.optional(),+ revisionId: selector.revisionId.optional(),+ programRef: z25.string().regex(programRefPattern).optional().describe("A program to build instead of a saved revision; assetId and revisionId stay unset."),profile: z25.enum(["editable", "runtime"]).default("editable").describe("editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.")});const exportToInput = exportInput.extend({@@ -55821,10 +55845,31 @@ function createKilnAssetDefs(context, presentation = "grouped") {},{name: "kiln_export",- description: "Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",+ description: "Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",inputSchema: profileExportInput,run: async (raw) => {const input = profileExportInput.parse(raw);+ if (input.programRef) {+ if (input.assetId || input.revisionId)+ throw new Error("kiln_export takes programRef or assetId and revisionId, not both: programRef builds a program, the others select a saved revision.");+ if (input.profile === "runtime")+ throw new Error("The runtime profile exports a saved revision. Call kiln_save with this programRef first, or omit profile for the built GLB.");+ const rendered = await buildProgramGlb(input.programRef, context);+ await Promise.resolve().then(() => init_draw_diagnostics());+ return {+ ok: true,+ programRef: input.programRef,+ profile: input.profile,+ sha256: rendered.artifactGlbSha256,+ triangles: rendered.tris,+ drawDiagnostics: await inspectDrawDiagnostics(rendered.glb),+ resources: [+ (await Promise.resolve().then(() => (init_assets_resources(), exports_assets_resources))).programBuildLink(input.programRef, rendered)+ ]+ };+ }+ if (!input.assetId || !input.revisionId)+ throw new Error("kiln_export requires assetId and revisionId for a saved revision, or programRef for a built program.");const record = await readSavedRevision(library(), input.collection, input.assetId, input.revisionId, listCall(input.collection));await Promise.resolve().then(() => init_draw_diagnostics());if (input.profile === "runtime") {diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjsindex 1cea2a0f..7cec0453 100644--- a/dist/mcp-engine.mjs+++ b/dist/mcp-engine.mjs@@ -10879,6 +10879,7 @@ var init_asset_export = __esm(() => {var exports_assets_resources = {};__export(exports_assets_resources, {assetLinks: () => assetLinks,+ programBuildLink: () => programBuildLink,readAssetResource: () => readAssetResource,runtimeAssetLinks: () => runtimeAssetLinks});@@ -10915,6 +10916,16 @@ async function runtimeAssetLinks(collection, record, derived) {annotations: { audience: ["user"], priority: name.endsWith(".glb") ? 0.9 : 0.3 }}));}+function programBuildLink(programRef, rendered) {+ return {+ type: "resource_link",+ name: "asset.glb",+ uri: `kiln://programs/${encodeURIComponent(programRef)}/${rendered.artifactGlbSha256.replace("sha256:", "")}/asset.glb`,+ mimeType: "model/gltf-binary",+ size: rendered.glb.byteLength,+ annotations: { audience: ["user"], priority: priorities["asset.glb"] }+ };+}async function readAssetResource(library, uri) {const match = /^kiln:\/\/assets\/([a-z][a-z0-9_-]{0,79})\/([a-z][a-z0-9_-]{0,79})\/([a-z][a-z0-9_-]{0,79})\/(asset\.glb|runtime\.glb|runtime\.kiln-metadata\.json|source\.kiln\.js|preview\.png|manifest\.json|editable\.zip)$/.exec(uri);if (!match)@@ -46452,6 +46463,11 @@ var KILN_RESOURCE_TEMPLATES = {name: "project-package",uriTemplate: "kiln://projects/{project}/{revision}/{profile}",description: "Exact editable project bundle or runtime derivative ZIP."+ },+ programBuild: {+ name: "program-build",+ uriTemplate: "kiln://programs/{program}/{sha256}/asset.glb",+ description: "The GLB a program builds, from kiln_export with a programRef; nothing is saved."}};var DEFINITION_TTL_MS = 86400000;@@ -54736,6 +54752,16 @@ async function parentRevisionComparison(parent, child) {};}}+async function buildProgramGlb(programRef, context) {+ if (!context.programStore)+ throw new Error("Building a programRef requires a program store.");+ const code = await context.programStore.get(programRef);+ await context.prepareBuildProvenance?.();+ return evaluateGeneratedSource(code, {+ ...context,+ requirements: toolRequirements(context).binding+ });+}async function buildProgramAssetDraft(code, context, backdrop) {await context.prepareBuildProvenance?.();const callContext = {@@ -54855,6 +54881,9 @@ function createKilnAssetDefs(context, presentation = "grouped") {});const exportInput = z25.object(selector);const profileExportInput = exportInput.extend({+ assetId: selector.assetId.optional(),+ revisionId: selector.revisionId.optional(),+ programRef: z25.string().regex(programRefPattern).optional().describe("A program to build instead of a saved revision; assetId and revisionId stay unset."),profile: z25.enum(["editable", "runtime"]).default("editable").describe("editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.")});const exportToInput = exportInput.extend({@@ -55010,10 +55039,31 @@ function createKilnAssetDefs(context, presentation = "grouped") {},{name: "kiln_export",- description: "Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",+ description: "Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",inputSchema: profileExportInput,run: async (raw) => {const input = profileExportInput.parse(raw);+ if (input.programRef) {+ if (input.assetId || input.revisionId)+ throw new Error("kiln_export takes programRef or assetId and revisionId, not both: programRef builds a program, the others select a saved revision.");+ if (input.profile === "runtime")+ throw new Error("The runtime profile exports a saved revision. Call kiln_save with this programRef first, or omit profile for the built GLB.");+ const rendered = await buildProgramGlb(input.programRef, context);+ await Promise.resolve().then(() => init_draw_diagnostics());+ return {+ ok: true,+ programRef: input.programRef,+ profile: input.profile,+ sha256: rendered.artifactGlbSha256,+ triangles: rendered.tris,+ drawDiagnostics: await inspectDrawDiagnostics(rendered.glb),+ resources: [+ (await Promise.resolve().then(() => (init_assets_resources(), exports_assets_resources))).programBuildLink(input.programRef, rendered)+ ]+ };+ }+ if (!input.assetId || !input.revisionId)+ throw new Error("kiln_export requires assetId and revisionId for a saved revision, or programRef for a built program.");const record = await readSavedRevision(library(), input.collection, input.assetId, input.revisionId, listCall(input.collection));await Promise.resolve().then(() => init_draw_diagnostics());if (input.profile === "runtime") {@@ -55150,7 +55200,8 @@ function toolManifestEntry(def) {function resourceTemplatesFor(context) {return [...context.assetLibrary ? [KILN_RESOURCE_TEMPLATES.assetFile] : [],- ...context.projectBundleReader ? [KILN_RESOURCE_TEMPLATES.projectPackage] : []+ ...context.projectBundleReader ? [KILN_RESOURCE_TEMPLATES.projectPackage] : [],+ ...context.assetLibrary ? [KILN_RESOURCE_TEMPLATES.programBuild] : []];}function buildMcpManifest(defs, context) {@@ -55281,6 +55332,19 @@ function createKilnToolHost(context = {}, options = {}) {const bytes = await context.projectBundleReader(project, revision, file === "editable.zip" ? "editable" : "runtime");return { uri, mimeType: "application/zip", blob: Buffer.from(bytes).toString("base64") };}+ if (uri.startsWith("kiln://programs/")) {+ const [program, sha256, file, ...extra] = new URL(uri).pathname.split("/").filter(Boolean).map(decodeURIComponent);+ if (extra.length || !program || !sha256 || file !== "asset.glb")+ throw new Error("Invalid program build URI");+ const rendered = await buildProgramGlb(program, requestContext);+ if (rendered.artifactGlbSha256 !== `sha256:${sha256}`)+ throw new Error(`${program} no longer builds to ${sha256} on this host. Call kiln_export with this programRef again for the current bytes.`);+ return {+ uri,+ mimeType: "model/gltf-binary",+ blob: Buffer.from(rendered.glb).toString("base64")+ };+ }throw new Error(`Resource not found: ${uri}`);}};diff --git a/dist/mcp-server.mjs b/dist/mcp-server.mjsindex c6bd7944..fcd5e245 100644--- a/dist/mcp-server.mjs+++ b/dist/mcp-server.mjs@@ -1967,7 +1967,7 @@ var mcp_manifest_default = {},{name: "kiln_export",- description: "Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",+ description: "Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",inputSchema: {type: "object",properties: {@@ -1985,6 +1985,11 @@ var mcp_manifest_default = {type: "string",pattern: "^[a-z][a-z0-9_-]{0,79}$"},+ programRef: {+ description: "A program to build instead of a saved revision; assetId and revisionId stay unset.",+ type: "string",+ pattern: "^(?:sha256:[a-f0-9]{64}|p_[a-f0-9]{12}(?:[a-f0-9]{4}){0,13})(?![\\s\\S])"+ },profile: {default: "editable",description: "editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.",@@ -1994,11 +1999,7 @@ var mcp_manifest_default = {"runtime"]}- },- required: [- "assetId",- "revisionId"- ]+ }},annotations: {readOnlyHint: true,@@ -2138,6 +2139,11 @@ var mcp_manifest_default = {name: "project-package",uriTemplate: "kiln://projects/{project}/{revision}/{profile}",description: "Exact editable project bundle or runtime derivative ZIP."+ },+ {+ name: "program-build",+ uriTemplate: "kiln://programs/{program}/{sha256}/asset.glb",+ description: "The GLB a program builds, from kiln_export with a programRef; nothing is saved."}]};diff --git a/docs/export-profiles.md b/docs/export-profiles.mdindex 391ce0c2..41f987d9 100644--- a/docs/export-profiles.md+++ b/docs/export-profiles.md@@ -122,6 +122,10 @@ Runtime results do not reuse configured canonical download URLs: those would delthe wrong GLB. Client support for saving MCP resources varies. No binary data is putinto tool text. To write files, configure an export root (below) or use the local CLI.+### Bytes before a save: `programRef`++`kiln_export` also takes a `programRef` in place of `assetId` and `revisionId`. It builds the program, saves nothing, and returns a `kiln://programs/{program}/{sha256}/asset.glb` resource with the size, hash, triangle count and draw diagnostics. A destination whose audit reads geometry can run before the save this way, so a repair lands before the revision exists rather than as its child. The bytes are the ones `kiln_save` then persists. The build runs again on read, and a program this host now builds to different bytes is refused rather than served under the old hash; export again for the current ones. The `runtime` profile needs a saved revision. The CLI's `kiln render REF --out x.glb` reaches the same bytes.+### Writing files: `kiln_export_to`When the host sets `KILN_EXPORT_ROOT` on the MCP server, it also advertisesdiff --git a/docs/tools-operations.md b/docs/tools-operations.mdindex a766fd1f..fa6fb316 100644--- a/docs/tools-operations.md+++ b/docs/tools-operations.md@@ -1443,7 +1443,7 @@ Present one exact saved revision. Supporting MCP App clients show an interactive## kiln_export-Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.+Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.<details><summary>Input JSON Schema</summary>@@ -1467,6 +1467,11 @@ Export one saved revision. Default editable returns exact GLB, source, preview,"type": "string","pattern": "^[a-z][a-z0-9_-]{0,79}$"},+ "programRef": {+ "description": "A program to build instead of a saved revision; assetId and revisionId stay unset.",+ "type": "string",+ "pattern": "^(?:sha256:[a-f0-9]{64}|p_[a-f0-9]{12}(?:[a-f0-9]{4}){0,13})(?![\\s\\S])"+ },"profile": {"default": "editable","description": "editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.",@@ -1476,11 +1481,7 @@ Export one saved revision. Default editable returns exact GLB, source, preview,"runtime"]}- },- "required": [- "assetId",- "revisionId"- ]+ }}```diff --git a/docs/tools.md b/docs/tools.mdindex 4cf5ca52..97b6d140 100644--- a/docs/tools.md+++ b/docs/tools.md@@ -1808,7 +1808,7 @@ Present one exact saved revision. Supporting MCP App clients show an interactive## kiln_export-Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.+Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.<details><summary>Input JSON Schema</summary>@@ -1832,6 +1832,11 @@ Export one saved revision. Default editable returns exact GLB, source, preview,"type": "string","pattern": "^[a-z][a-z0-9_-]{0,79}$"},+ "programRef": {+ "description": "A program to build instead of a saved revision; assetId and revisionId stay unset.",+ "type": "string",+ "pattern": "^(?:sha256:[a-f0-9]{64}|p_[a-f0-9]{12}(?:[a-f0-9]{4}){0,13})(?![\\s\\S])"+ },"profile": {"default": "editable","description": "editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.",@@ -1841,11 +1846,7 @@ Export one saved revision. Default editable returns exact GLB, source, preview,"runtime"]}- },- "required": [- "assetId",- "revisionId"- ]+ }}```diff --git a/skills/kiln-qa-asset/references/integration-checks.md b/skills/kiln-qa-asset/references/integration-checks.mdindex a2f6f812..857a2535 100644--- a/skills/kiln-qa-asset/references/integration-checks.md+++ b/skills/kiln-qa-asset/references/integration-checks.md@@ -25,6 +25,11 @@ renaming nodes so nothing matches is reported aschange the profile. Without a declared profile these checks do not exist; do notapply another destination's checks to a standalone asset.+A destination audit that reads geometry can run before a save: `kiln_export` with a `programRef`+returns a resource for the bytes `kiln_save` would persist and writes nothing, and the CLI's+`render REF --out x.glb` reaches the same bytes. A part summary cannot stand in for them, because one+merged mesh reports as one box whatever it contains.+## What to measure| Question | Evidence |diff --git a/src/__tests__/mcp-manifest.test.ts b/src/__tests__/mcp-manifest.test.tsindex 3f59ab30..4209d5c2 100644--- a/src/__tests__/mcp-manifest.test.ts+++ b/src/__tests__/mcp-manifest.test.ts@@ -60,6 +60,7 @@ describe('generated MCP manifest', () => {expect(manifest.resourceTemplates).toEqual([KILN_RESOURCE_TEMPLATES.assetFile,KILN_RESOURCE_TEMPLATES.projectPackage,+ KILN_RESOURCE_TEMPLATES.programBuild,]);});});diff --git a/src/assets-resources.ts b/src/assets-resources.tsindex 89615b18..2ea62ad1 100644--- a/src/assets-resources.ts+++ b/src/assets-resources.ts@@ -95,6 +95,21 @@ export async function runtimeAssetLinks(annotations: { audience: ['user'], priority: name.endsWith('.glb') ? 0.9 : 0.3 },}));}+/** The built GLB of a program that may never be saved. The URI pins the bytes it was issued for. */+export function programBuildLink(+ programRef: string,+ rendered: { glb: Uint8Array; artifactGlbSha256: string },+): AssetLink {+ return {+ type: 'resource_link',+ name: 'asset.glb',+ uri: `kiln://programs/${encodeURIComponent(programRef)}/${rendered.artifactGlbSha256.replace('sha256:', '')}/asset.glb`,+ mimeType: 'model/gltf-binary',+ size: rendered.glb.byteLength,+ annotations: { audience: ['user'], priority: priorities['asset.glb']! },+ };+}+export async function readAssetResource(library: AssetLibrary,uri: string,diff --git a/src/generated/mcp-manifest.json b/src/generated/mcp-manifest.jsonindex 55376a40..333e5743 100644--- a/src/generated/mcp-manifest.json+++ b/src/generated/mcp-manifest.json@@ -1951,7 +1951,7 @@},{"name": "kiln_export",- "description": "Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.",+ "description": "Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.","inputSchema": {"type": "object","properties": {@@ -1969,6 +1969,11 @@"type": "string","pattern": "^[a-z][a-z0-9_-]{0,79}$"},+ "programRef": {+ "description": "A program to build instead of a saved revision; assetId and revisionId stay unset.",+ "type": "string",+ "pattern": "^(?:sha256:[a-f0-9]{64}|p_[a-f0-9]{12}(?:[a-f0-9]{4}){0,13})(?![\\s\\S])"+ },"profile": {"default": "editable","description": "editable preserves canonical source/GLB/build resources. runtime returns a standalone GLB and versioned review-metadata sidecar; no source bundle or geometry optimization.",@@ -1978,11 +1983,7 @@"runtime"]}- },- "required": [- "assetId",- "revisionId"- ]+ }},"annotations": {"readOnlyHint": true,@@ -2122,6 +2123,11 @@"name": "project-package","uriTemplate": "kiln://projects/{project}/{revision}/{profile}","description": "Exact editable project bundle or runtime derivative ZIP."+ },+ {+ "name": "program-build",+ "uriTemplate": "kiln://programs/{program}/{sha256}/asset.glb",+ "description": "The GLB a program builds, from kiln_export with a programRef; nothing is saved."}]}diff --git a/src/mcp-core.ts b/src/mcp-core.tsindex 7f05d0ef..fce0a95c 100644--- a/src/mcp-core.ts+++ b/src/mcp-core.ts@@ -180,6 +180,11 @@ export const KILN_RESOURCE_TEMPLATES = {uriTemplate: 'kiln://projects/{project}/{revision}/{profile}',description: 'Exact editable project bundle or runtime derivative ZIP.',},+ programBuild: {+ name: 'program-build',+ uriTemplate: 'kiln://programs/{program}/{sha256}/asset.glb',+ description: 'The GLB a program builds, from kiln_export with a programRef; nothing is saved.',+ },} as const satisfies Record<string, KilnMcpManifestTemplate>;/**diff --git a/src/mcp-engine.ts b/src/mcp-engine.tsindex a0fa51bb..6921aefe 100644--- a/src/mcp-engine.ts+++ b/src/mcp-engine.ts@@ -34,6 +34,7 @@ import { localProgramStore } from './program-store-node';import { validateRequirementsBinding } from './requirements-context';import { describeInputError, schemaFields } from './tools/actions';import {+ buildProgramGlb,createKilnProgramToolRegistry,createKilnOperationToolRegistry,type KilnToolContext,@@ -237,6 +238,25 @@ export function createKilnToolHost();return { uri, mimeType: 'application/zip', blob: Buffer.from(bytes).toString('base64') };}+ if (uri.startsWith('kiln://programs/')) {+ const [program, sha256, file, ...extra] = new URL(uri).pathname+ .split('/')+ .filter(Boolean)+ .map(decodeURIComponent);+ if (extra.length || !program || !sha256 || file !== 'asset.glb')+ throw new Error('Invalid program build URI');+ const rendered = await buildProgramGlb(program, requestContext);+ // Rebuilt on read, so this host's policy or engine can have moved since the export.+ if (rendered.artifactGlbSha256 !== `sha256:${sha256}`)+ throw new Error(+ `${program} no longer builds to ${sha256} on this host. Call kiln_export with this programRef again for the current bytes.`,+ );+ return {+ uri,+ mimeType: 'model/gltf-binary',+ blob: Buffer.from(rendered.glb).toString('base64'),+ };+ }throw new Error(`Resource not found: ${uri}`);},};diff --git a/src/mcp-manifest.ts b/src/mcp-manifest.tsindex 042e97cb..8075a782 100644--- a/src/mcp-manifest.ts+++ b/src/mcp-manifest.ts@@ -82,6 +82,8 @@ export function resourceTemplatesFor(context: KilnToolContext): KilnMcpManifestTreturn [...(context.assetLibrary ? [KILN_RESOURCE_TEMPLATES.assetFile] : []),...(context.projectBundleReader ? [KILN_RESOURCE_TEMPLATES.projectPackage] : []),+ // kiln_export issues these, and it comes with the library whether or not a program is saved.+ ...(context.assetLibrary ? [KILN_RESOURCE_TEMPLATES.programBuild] : []),];}diff --git a/src/tools/__tests__/export-program-ref.test.ts b/src/tools/__tests__/export-program-ref.test.tsnew file mode 100644index 00000000..853a9032--- /dev/null+++ b/src/tools/__tests__/export-program-ref.test.ts@@ -0,0 +1,146 @@+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { createHash } from 'node:crypto';+import { mkdtemp, rm } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { FileAssetLibrary } from '../../assets-node';+import { KILN_RESOURCE_TEMPLATES } from '../../mcp-core';+import { createKilnToolHost } from '../../mcp-engine';+import { MemoryProgramStore } from '../../program-store';+import { createKilnProgramToolRegistry } from '../registry';++const CODE = `const meta = { name: 'Bracket' };+function build() {+ const root = createRoot('Bracket');+ createPart('plate', new THREE.BoxGeometry(1, 0.1, 1), gameMaterial(0x808080), { parent: root });+ createPart('post', new THREE.BoxGeometry(0.1, 1, 0.1), gameMaterial(0x404040), {+ parent: root,+ position: [0, 0.55, 0],+ });+ return root;+}`;++interface ExportResult {+ ok: boolean;+ programRef: string;+ profile: string;+ sha256: string;+ triangles: number;+ drawDiagnostics?: { currentDraws: number };+ resources: { name: string; uri: string; mimeType: string; size: number }[];+}++let root: string;+let assetLibrary: FileAssetLibrary;+let programStore: MemoryProgramStore;+let ref: string;+const tool = (name: string) =>+ createKilnProgramToolRegistry({ assetLibrary, programStore }).find((def) => def.name === name)!;+const host = () => createKilnToolHost({ assetLibrary, programStore });+const blob = async (uri: string) => {+ const read = (await host().readResource(uri)) as { mimeType: string; blob: string };+ return { mimeType: read.mimeType, bytes: Buffer.from(read.blob, 'base64') };+};++beforeAll(async () => {+ root = await mkdtemp(join(tmpdir(), 'kiln-export-program-'));+ assetLibrary = new FileAssetLibrary({ project: root });+ programStore = new MemoryProgramStore();+ ref = await programStore.put(CODE);+});+afterAll(() => rm(root, { recursive: true, force: true }));++describe('kiln_export by programRef (#309)', () => {+ test('returns readable bytes and writes nothing to the library', async () => {+ const output = (await tool('kiln_export').run({ programRef: ref })) as ExportResult;+ expect(output).toMatchObject({ ok: true, programRef: ref, profile: 'editable' });+ expect(output.triangles).toBeGreaterThan(0);+ expect(output.drawDiagnostics?.currentDraws).toBe(2);+ const [link] = output.resources;+ expect(link).toMatchObject({ name: 'asset.glb', mimeType: 'model/gltf-binary' });+ const { bytes, mimeType } = await blob(link!.uri);+ expect(mimeType).toBe('model/gltf-binary');+ expect(bytes.subarray(0, 4).toString()).toBe('glTF');+ expect(bytes.byteLength).toBe(link!.size);+ expect(`sha256:${createHash('sha256').update(bytes).digest('hex')}`).toBe(output.sha256);+ expect(await assetLibrary.list('project')).toEqual([]);+ });++ test('the bytes are the ones kiln_save then persists', async () => {+ const output = (await tool('kiln_export').run({ programRef: ref })) as ExportResult;+ const { bytes } = await blob(output.resources[0]!.uri);+ const saved = (await tool('kiln_save').run({+ programRef: ref,+ name: 'Bracket',+ collection: 'project',+ })) as { asset: { assetId: string; revisionId: string } };+ const record = await assetLibrary.read('project', saved.asset.assetId, saved.asset.revisionId);+ expect(Buffer.from(record.files['asset.glb']!).equals(bytes)).toBe(true);+ });++ test('a saved revision is still selected as before', async () => {+ const saved = (await tool('kiln_save').run({+ programRef: ref,+ name: 'Bracket again',+ collection: 'project',+ })) as { asset: { assetId: string; revisionId: string } };+ const output = (await tool('kiln_export').run({+ assetId: saved.asset.assetId,+ revisionId: saved.asset.revisionId,+ })) as { ok: boolean; asset: { revisionId: string } };+ expect(output.ok).toBe(true);+ expect(output.asset.revisionId).toBe(saved.asset.revisionId);+ });++ test('both selectors are refused by name', async () => {+ await expect(+ tool('kiln_export').run({ programRef: ref, assetId: 'a_x', revisionId: 'r_x' }),+ ).rejects.toThrow(/programRef.*assetId|assetId.*programRef/);+ });++ test('no selector is refused by name', async () => {+ await expect(tool('kiln_export').run({})).rejects.toThrow(/assetId.*programRef/);+ await expect(tool('kiln_export').run({ assetId: 'a_x' })).rejects.toThrow(/revisionId/);+ });++ test('the runtime profile needs a saved revision, and says so', async () => {+ await expect(tool('kiln_export').run({ programRef: ref, profile: 'runtime' })).rejects.toThrow(+ /runtime.*kiln_save/,+ );+ });++ test('kiln_present still requires a saved revision', () => {+ const schema = tool('kiln_present').inputSchema as unknown as {+ safeParse(value: unknown): { success: boolean };+ };+ expect(schema.safeParse({ programRef: ref }).success).toBe(false);+ });+});++describe('the program build resource (#309)', () => {+ test('is advertised as a template', () => {+ expect(KILN_RESOURCE_TEMPLATES.programBuild.uriTemplate).toBe(+ 'kiln://programs/{program}/{sha256}/asset.glb',+ );+ });++ test('refuses a URI whose hash the program no longer builds to', async () => {+ const encoded = encodeURIComponent(ref);+ await expect(+ host().readResource(`kiln://programs/${encoded}/${'a'.repeat(64)}/asset.glb`),+ ).rejects.toThrow(/kiln_export/);+ });++ test.each(['other.glb', 'asset.glb/extra'])('refuses the file %s', async (file) => {+ await expect(+ host().readResource(`kiln://programs/${encodeURIComponent(ref)}/${'a'.repeat(64)}/${file}`),+ ).rejects.toThrow('Invalid program build URI');+ });++ test('without a program store it says what is missing', async () => {+ const bare = createKilnToolHost({ assetLibrary });+ await expect(+ bare.readResource(`kiln://programs/${encodeURIComponent(ref)}/${'a'.repeat(64)}/asset.glb`),+ ).rejects.toThrow(/program store/);+ });+});diff --git a/src/tools/registry.ts b/src/tools/registry.tsindex 4a7b88bb..2dbee4e6 100644--- a/src/tools/registry.ts+++ b/src/tools/registry.ts@@ -2892,6 +2892,23 @@ async function parentRevisionComparison(}}+/**+ * The evaluation `kiln_save` persists, without its preview and with nothing written: a destination+ * audit reads these bytes before a save, not after one (#309).+ */+export async function buildProgramGlb(+ programRef: string,+ context: KilnToolContext,+): Promise<RenderResult> {+ if (!context.programStore) throw new Error('Building a programRef requires a program store.');+ const code = await context.programStore.get(programRef);+ await context.prepareBuildProvenance?.();+ return evaluateGeneratedSource(code, {+ ...context,+ requirements: toolRequirements(context).binding,+ });+}+/** Build one current-policy revision for ordinary save or explicit migration. */export async function buildProgramAssetDraft(code: string,@@ -3054,6 +3071,15 @@ export function createKilnAssetDefs(});const exportInput = z.object(selector);const profileExportInput = exportInput.extend({+ assetId: selector.assetId.optional(),+ revisionId: selector.revisionId.optional(),+ programRef: z+ .string()+ .regex(programRefPattern)+ .optional()+ .describe(+ 'A program to build instead of a saved revision; assetId and revisionId stay unset.',+ ),profile: z.enum(['editable', 'runtime']).default('editable')@@ -3283,10 +3309,37 @@ export function createKilnAssetDefs({name: 'kiln_export',description:- 'Export one saved revision. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.',+ 'Export one saved revision, or the GLB a programRef builds. With programRef, nothing is saved: it returns a resource for the bytes kiln_save would persist, so a destination audit can read them before a save. Default editable returns exact GLB, source, preview, and manifest descriptors; configured hosts may include portable editable ZIP download URLs. Opt-in runtime returns a standalone GLB plus a versioned metadata sidecar, moving only Kiln review clips out of GLB extras while preserving native animation and application metadata. Resource URIs remain readable through resources/read. Canonical revisions never change; no binary bytes are placed in tool text.',inputSchema: profileExportInput,run: async (raw) => {const input = profileExportInput.parse(raw);+ if (input.programRef) {+ if (input.assetId || input.revisionId)+ throw new Error(+ 'kiln_export takes programRef or assetId and revisionId, not both: programRef builds a program, the others select a saved revision.',+ );+ if (input.profile === 'runtime')+ throw new Error(+ 'The runtime profile exports a saved revision. Call kiln_save with this programRef first, or omit profile for the built GLB.',+ );+ const rendered = await buildProgramGlb(input.programRef, context);+ const { inspectDrawDiagnostics } = await import('../draw-diagnostics');+ return {+ ok: true,+ programRef: input.programRef,+ profile: input.profile,+ sha256: rendered.artifactGlbSha256,+ triangles: rendered.tris,+ drawDiagnostics: await inspectDrawDiagnostics(rendered.glb),+ resources: [+ (await import('../assets-resources')).programBuildLink(input.programRef, rendered),+ ],+ };+ }+ if (!input.assetId || !input.revisionId)+ throw new Error(+ 'kiln_export requires assetId and revisionId for a saved revision, or programRef for a built program.',+ );const record = await readSavedRevision(library(),input.collection,