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.

fix(export): forward KILN_EXPORT_ROOT under Codex and report kiln_export_to in Discovery (#207) (#242)

Matthew Kissinger8643d47dd0a5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c4986c1..5e5ec5a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ does not publish a package.
## Unreleased
+- Generated Codex workspaces forward `KILN_EXPORT_ROOT` to the MCP server, so
+ `kiln_export_to` is advertised under Codex as under the other harnesses, and Discovery
+ capabilities report the tool as `assets.exportTo` (`null` when absent, never the
+ absolute root) ([#207](https://github.com/instruktlabs/kiln/issues/207)).
+
## 1.4.0 (2026-10-23)
- Encode KTX2 through an optional `ktx2-encoder` peer
diff --git a/dist/agent-run.mjs b/dist/agent-run.mjs
index 221aa512..681c4d04 100644
--- a/dist/agent-run.mjs
+++ b/dist/agent-run.mjs
@@ -45703,6 +45703,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,
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: {
diff --git a/dist/build.json b/dist/build.json
index ab234efc..92a7b14a 100644
--- a/dist/build.json
+++ b/dist/build.json
@@ -2,10 +2,10 @@
"schemaVersion": 1,
"entries": {
"worker": {
- "identity": "sha256:9801b5f76cc19503d89b2156e6fc18cdac3e3a15d9556b71f9af7dd1ccb82abc",
+ "identity": "sha256:5f50fc7e452957c6915ce4850b22fcfdcda17e4ceb936ef4eb5f728f30d74563",
"engineVersion": "1.4.0",
"toolchain": "[email protected]",
- "sourceHash": "87d3d99fdd9afae4f7d71dbafba4233fd58b822af9ac75e7f8071d117a4e8142",
+ "sourceHash": "828e8c90e055d46a43d5e048a54611f4a639ffcd017fc705841c72b6cd5d747a",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -40,10 +40,10 @@
"bundleHash": "sha256:2839cd6aaee99ebea2e55a4f07aa079340b7d281572a7a801484ff489c15624e"
},
"agent-run": {
- "identity": "sha256:9801b5f76cc19503d89b2156e6fc18cdac3e3a15d9556b71f9af7dd1ccb82abc",
+ "identity": "sha256:5f50fc7e452957c6915ce4850b22fcfdcda17e4ceb936ef4eb5f728f30d74563",
"engineVersion": "1.4.0",
"toolchain": "[email protected]",
- "sourceHash": "87d3d99fdd9afae4f7d71dbafba4233fd58b822af9ac75e7f8071d117a4e8142",
+ "sourceHash": "828e8c90e055d46a43d5e048a54611f4a639ffcd017fc705841c72b6cd5d747a",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -75,13 +75,13 @@
},
"target": "node",
"file": "agent-run.mjs",
- "bundleHash": "sha256:a1bc5e24c0467397bba6906e2c22ff4b84a1b3bd31329a3d07a44610d45ec0b6"
+ "bundleHash": "sha256:c19cd3112c743b2b6894856f6384f7fa6cc88ef9ba8144f133ca3646638d2c18"
},
"agent-providers": {
- "identity": "sha256:9801b5f76cc19503d89b2156e6fc18cdac3e3a15d9556b71f9af7dd1ccb82abc",
+ "identity": "sha256:5f50fc7e452957c6915ce4850b22fcfdcda17e4ceb936ef4eb5f728f30d74563",
"engineVersion": "1.4.0",
"toolchain": "[email protected]",
- "sourceHash": "87d3d99fdd9afae4f7d71dbafba4233fd58b822af9ac75e7f8071d117a4e8142",
+ "sourceHash": "828e8c90e055d46a43d5e048a54611f4a639ffcd017fc705841c72b6cd5d747a",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -116,10 +116,10 @@
"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"
},
"mcp": {
- "identity": "sha256:9801b5f76cc19503d89b2156e6fc18cdac3e3a15d9556b71f9af7dd1ccb82abc",
+ "identity": "sha256:5f50fc7e452957c6915ce4850b22fcfdcda17e4ceb936ef4eb5f728f30d74563",
"engineVersion": "1.4.0",
"toolchain": "[email protected]",
- "sourceHash": "87d3d99fdd9afae4f7d71dbafba4233fd58b822af9ac75e7f8071d117a4e8142",
+ "sourceHash": "828e8c90e055d46a43d5e048a54611f4a639ffcd017fc705841c72b6cd5d747a",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -154,10 +154,10 @@
"bundleHash": "sha256:8c2fcbae79116bb20b75e98313f9c5044835b4f8d28def79c8333944748202a9"
},
"cli": {
- "identity": "sha256:9801b5f76cc19503d89b2156e6fc18cdac3e3a15d9556b71f9af7dd1ccb82abc",
+ "identity": "sha256:5f50fc7e452957c6915ce4850b22fcfdcda17e4ceb936ef4eb5f728f30d74563",
"engineVersion": "1.4.0",
"toolchain": "[email protected]",
- "sourceHash": "87d3d99fdd9afae4f7d71dbafba4233fd58b822af9ac75e7f8071d117a4e8142",
+ "sourceHash": "828e8c90e055d46a43d5e048a54611f4a639ffcd017fc705841c72b6cd5d747a",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -189,13 +189,13 @@
},
"target": "node",
"file": "cli.mjs",
- "bundleHash": "sha256:032e75b32f725b6b563428a3c4683614b23b94d2e96bb4d52bfe8a2defc2b360"
+ "bundleHash": "sha256:70eb2146f1811c2bc0bbeb751355d97ec6249d28a1b02be0bdc60d82d9da761f"
},
"engine": {
- "identity": "sha256:9801b5f76cc19503d89b2156e6fc18cdac3e3a15d9556b71f9af7dd1ccb82abc",
+ "identity": "sha256:5f50fc7e452957c6915ce4850b22fcfdcda17e4ceb936ef4eb5f728f30d74563",
"engineVersion": "1.4.0",
"toolchain": "[email protected]",
- "sourceHash": "87d3d99fdd9afae4f7d71dbafba4233fd58b822af9ac75e7f8071d117a4e8142",
+ "sourceHash": "828e8c90e055d46a43d5e048a54611f4a639ffcd017fc705841c72b6cd5d747a",
"rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a",
"dependencyHash": "af916d063d319fe3c11d1acc13211950eea82bb5ebb87ae4eb60008d72fa7f10",
"dependencies": {
@@ -227,7 +227,7 @@
},
"target": "node",
"file": "mcp-engine.mjs",
- "bundleHash": "sha256:10247a3c7e60a0e34087144695fa6bd58122d6c6e50d76193b29a9578954c33e"
+ "bundleHash": "sha256:87d5def460e631d12c9c593ab2dea7013ff828f65eb68b225206dbaf31a68434"
}
}
}
diff --git a/dist/cli.mjs b/dist/cli.mjs
index dc75d8d1..926ed3ba 100644
--- a/dist/cli.mjs
+++ b/dist/cli.mjs
@@ -49205,6 +49205,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,
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: {
diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjs
index 64cd8b3a..793116fc 100644
--- a/dist/mcp-engine.mjs
+++ b/dist/mcp-engine.mjs
@@ -49992,6 +49992,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,
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: {
diff --git a/docs/export-profiles.md b/docs/export-profiles.md
index 1ad341da..46113b28 100644
--- a/docs/export-profiles.md
+++ b/docs/export-profiles.md
@@ -126,6 +126,9 @@ into tool text. To write files, configure an export root (below) or use the loca
When the host sets `KILN_EXPORT_ROOT` on the MCP server, it also advertises
`kiln_export_to`. Without the variable the tool list and `kiln_export` are unchanged.
+Discovery capabilities report it as `assets.exportTo`, which is `null` when the tool is
+absent and never shows the absolute root. Generated Codex workspaces forward the
+variable from the shell that starts Codex, as the other harnesses' servers inherit it.
```js
kiln_export_to({ collection: "project", assetId, revisionId, path: "game/door.glb" })
diff --git a/scripts/create-workspace.mjs b/scripts/create-workspace.mjs
index f9def34a..862283f1 100644
--- a/scripts/create-workspace.mjs
+++ b/scripts/create-workspace.mjs
@@ -204,6 +204,8 @@ function managedFiles(root, runtime, harness, nodeExecutable) {
'KILN_RENDER_SERVICE_PORT',
'KILN_WORK_ITEM',
'KILN_PROJECT',
+ // Without it the server never advertises kiln_export_to (#207).
+ 'KILN_EXPORT_ROOT',
];
// Codex 0.160 reads a project's `.codex/config.toml` only once its own
// $CODEX_HOME/config.toml marks that project trusted (measured 2026-10-01:
diff --git a/skills/kiln-author-asset/references/export-profiles.md b/skills/kiln-author-asset/references/export-profiles.md
index 57b65928..cc7b67e6 100644
--- a/skills/kiln-author-asset/references/export-profiles.md
+++ b/skills/kiln-author-asset/references/export-profiles.md
@@ -151,8 +151,9 @@ otherwise the local CLI pair.
### `kiln_export_to` (host opt-in)
-Present only when the host sets `KILN_EXPORT_ROOT`. It writes one saved revision under
-that root and returns the CLI `--json` receipt with root-relative paths:
+Present only when the host sets `KILN_EXPORT_ROOT`; Discovery capabilities show it as a
+non-null `assets.exportTo`. It writes one saved revision under that root and returns the
+CLI `--json` receipt with root-relative paths:
```js
kiln_export_to({ assetId, revisionId, path: "game/door.glb" }) // runtime pair
diff --git a/src/__tests__/workspace-bootstrap.test.ts b/src/__tests__/workspace-bootstrap.test.ts
index 1d61685e..9d9ecf23 100644
--- a/src/__tests__/workspace-bootstrap.test.ts
+++ b/src/__tests__/workspace-bootstrap.test.ts
@@ -575,6 +575,9 @@ it('emits names-only Codex renderer forwarding for initial and resume launches w
// project that every other harness's server inherits from the shell was
// invisible under Codex alone (finding S7, 2026-10-01).
'KILN_PROJECT',
+ // The same gap hid kiln_export_to, which the server advertises only when
+ // KILN_EXPORT_ROOT reaches it (#207).
+ 'KILN_EXPORT_ROOT',
];
const fixture = {
KILN_RENDER_TOKEN: 'synthetic-client-token-not-a-real-credential',
@@ -583,6 +586,7 @@ it('emits names-only Codex renderer forwarding for initial and resume launches w
KILN_RENDER_SERVICE_PORT: '43123',
KILN_WORK_ITEM: 'cow',
KILN_PROJECT: 'pack-fixture',
+ KILN_EXPORT_ROOT: 'C:/fixture-exports',
};
try {
const task = join(root, 'assets');
@@ -625,6 +629,7 @@ it('emits names-only Codex renderer forwarding for initial and resume launches w
fixture,
{ KILN_RENDER_TOKEN: '', RENDER_SERVICE_TOKEN: fixture.RENDER_SERVICE_TOKEN },
{ KILN_PROJECT: fixture.KILN_PROJECT },
+ { KILN_EXPORT_ROOT: fixture.KILN_EXPORT_ROOT },
];
for (const values of cases) {
const env = { ...process.env };
diff --git a/src/tools/__tests__/export-to.test.ts b/src/tools/__tests__/export-to.test.ts
index cd8616c9..51ace4fb 100644
--- a/src/tools/__tests__/export-to.test.ts
+++ b/src/tools/__tests__/export-to.test.ts
@@ -126,6 +126,25 @@ describe('kiln_export_to advertisement', () => {
await server.close();
}
});
+
+ test('Discovery capabilities name kiln_export_to exactly when it is advertised', async () => {
+ const exportTo = async (context: Parameters<typeof createKilnProgramToolRegistry>[0]) => {
+ const discover = createKilnProgramToolRegistry(context).find(
+ (def) => def.name === 'kiln_discover',
+ )!;
+ const output = (await discover.run({ capabilities: true })) as {
+ capabilities: { assets: { exportTo: unknown } };
+ };
+ return output.capabilities.assets.exportTo;
+ };
+ expect(await exportTo({ assetLibrary: library })).toBeNull();
+ expect(await exportTo({ exportRoot: unusedWriter })).toBeNull();
+ const enabled = await exportTo({ assetLibrary: library, exportRoot: unusedWriter });
+ expect(enabled).toBeString();
+ expect(enabled as string).toStartWith('kiln_export_to ');
+ // Root-relative only: the host's absolute root is never shown to the agent.
+ expect(enabled as string).toContain('relative to the host export root');
+ });
});
describe('kiln_export_to writes', () => {
diff --git a/src/tools/discovery.ts b/src/tools/discovery.ts
index 6d544c8e..44f1c4fe 100644
--- a/src/tools/discovery.ts
+++ b/src/tools/discovery.ts
@@ -156,6 +156,11 @@ async function currentCapabilities(
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',
+ // 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'
+ : 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',
},