fix(vscode): preserve seccomp license resources

This commit is contained in:
marius-kilocode
2026-07-10 18:20:29 +02:00
parent 202ed66527
commit 26f573d441
2 changed files with 38 additions and 9 deletions
@@ -65,15 +65,6 @@ export async function copySandboxResources(source: string, target: string): Prom
await Promise.all(sandboxNetworkFiles.map((file) => fs.promises.rm(path.join(to, file), { force: true })))
await fs.promises.rm(path.join(to, sandboxRuntimeLicense), { recursive: true, force: true })
const executable = path.join(from, bwrap)
if (!fs.existsSync(executable)) return
await fs.promises.copyFile(executable, helper)
await fs.promises.chmod(helper, 0o755)
const licenses = path.join(from, bwrapLicense)
if (!fs.existsSync(licenses)) return
await fs.promises.cp(licenses, destination, { recursive: true })
for (const file of sandboxNetworkFiles) {
const input = path.join(from, file)
if (!fs.existsSync(input)) continue
@@ -85,6 +76,15 @@ export async function copySandboxResources(source: string, target: string): Prom
if (fs.existsSync(runtimeLicense)) {
await fs.promises.cp(runtimeLicense, path.join(to, sandboxRuntimeLicense), { recursive: true })
}
const executable = path.join(from, bwrap)
if (!fs.existsSync(executable)) return
await fs.promises.copyFile(executable, helper)
await fs.promises.chmod(helper, 0o755)
const licenses = path.join(from, bwrapLicense)
if (!fs.existsSync(licenses)) return
await fs.promises.cp(licenses, destination, { recursive: true })
}
export async function copyKiloSandboxWorker(source: string, target: string): Promise<void> {
@@ -175,6 +175,35 @@ describe("cli tree-sitter resources", () => {
}
})
it("copies seccomp licensing when bundled Bubblewrap is omitted", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "kilo-vscode-seccomp-license-"))
try {
const source = path.join(root, "dist", "bin", "kilo")
const target = path.join(root, "extension", "bin", "kilo")
const relay = path.join(path.dirname(source), "kilo-sandbox-network-relay.js")
const seccomp = path.join(path.dirname(source), "kilo-sandbox-seccomp")
const license = path.join(path.dirname(source), "licenses", "sandbox-runtime", "LICENSE")
await fs.mkdir(path.dirname(license), { recursive: true })
await fs.mkdir(path.dirname(target), { recursive: true })
await fs.writeFile(source, "binary")
await fs.writeFile(target, "binary")
await fs.writeFile(relay, "relay")
await fs.writeFile(seccomp, "seccomp")
await fs.writeFile(license, "Apache-2.0")
await copySandboxResources(source, target)
expect(await fs.readFile(path.join(path.dirname(target), "kilo-sandbox-network-relay.js"), "utf8")).toBe("relay")
expect(await fs.readFile(path.join(path.dirname(target), "kilo-sandbox-seccomp"), "utf8")).toBe("seccomp")
expect(await fs.readFile(path.join(path.dirname(target), "licenses", "sandbox-runtime", "LICENSE"), "utf8")).toBe(
"Apache-2.0",
)
} finally {
await fs.rm(root, { recursive: true, force: true })
}
})
it("removes stale sandbox resources when the source has none", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "kilo-vscode-sandbox-stale-"))
try {