@godspeedai/cognate-execution-wsl

中文文档
0.10.0发布于 2026/11/16Apache-2.0ES Module构建来源已验证近 30 天下载 2966

WSL distribution as an execution world: filesystem and process ports over wsl.exe -e sh -s. Same contracts as every other provider.

原始使用文档
文档目录7 节
  1. Installation
  2. Quick start
  3. Design: launch wsl.exe as rarely as possible
  4. Options
  5. Limits
  6. Related packages
  7. License

@godspeedai/cognate-execution-wsl

A WSL distribution as a Cognate execution world: filesystem and process ports implemented over wsl.exe, behind the same contracts as every other provider — so an agent's tools run inside Linux while the host stays wherever it is. Roots are POSIX paths inside the distribution; no Windows path ever enters the contract.

Where it works: this provider is exercised on a Linux host running inside WSL with Windows interop (wsl.exe on the PATH). A native Windows host running Bun is untested, and the provider is meaningless without a WSL installation and a distribution to target. If you just need "a Linux box", @godspeedai/cognate-execution-ssh is the more portable remote provider.

Installation

bun add @godspeedai/cognate-execution-wsl

Requires Bun >= 1.4.0, a WSL installation reachable via wsl.exe (override the binary with wslBin), and @godspeedai/cognate-execution, whose contracts this provider implements.

Quick start

import { wslExecutionWorld } from "@godspeedai/cognate-execution-wsl";

const world = wslExecutionWorld({ worldId: "ubuntu", distro: "Ubuntu-24.04" });

const path = world.fileSystem.resolve("/home/me/project", "README.md");
const readme = await world.fileSystem.readText(path);
const result = await world.process.exec({ argv: ["cargo", "test"], cwd: "/home/me/project", timeoutMs: 300_000 });
console.log(result.exitCode, result.stdout, result.timedOut);

await world.dispose();

Design: launch wsl.exe as rarely as possible

wsl.exe is the fragile part of the stack — launching it takes seconds on a cold distribution, and under load the Windows WSL service intermittently stalls or fails launches (a plain wsl.exe -e true has been measured taking 9–20 seconds). The provider therefore keeps a small pool of persistent sh -s sessions per distribution and runs everything through them as framed requests (stdout, stderr, and exit status return between unique markers):

  • In steady state an agent run launches no wsl.exe at all; only session start-up does. A session that fails to come up is replaced once before the world fails closed.
  • A command runs in its own process group (setsid). On timeout or abort the group is killed from a second session, and the busy session is closed as a last resort — closing wsl.exe ends everything it started, so the whole process tree dies.
  • Commands run in parallel in separate sessions; idle sessions return to the pool (up to 4) and close after a short grace period once no world uses them. A session's lifetime is bound to its stdin pipe, so it ends by itself if the host process dies. Holding sessions also keeps the distribution from being idled shut down by WSL.
  • File operations build on commandFileSystem from @godspeedai/cognate-execution, so the same shape fits containers.
  • Failure is never silent and never local: a missing wsl.exe, an unreachable distribution, or a disposed world raises WorldUnavailableError.

Options

OptionMeaning
worldId, distroregistry name and the WSL distribution to target
user?Linux user inside the distribution (wsl.exe -u); omit for the default
wslBin?path to the wsl.exe binary (default: wsl.exe on the PATH)
defaultTimeoutMs?default command timeout (30 s)
fileOpTimeoutMs?stall budget for one file operation on an established session (restarted and retried once)
sessionStartTimeoutMs?how long a fresh session may take to come up
maxOutputBytes?per-command output cap (10 MiB)
shellCommand?test seam replacing the whole launch command (must read the script from stdin like sh -s)

Limits

  • Exercised from inside WSL (Linux host with Windows interop); a native Windows host running Bun is untested.
  • WSL's own service can still fail a session start-up; the error reports wsl.exe's message rather than falling back to local execution.
  • Containment uses realpath-based checks (check-then-use); a concurrently swapped symlink is not prevented.

License

Apache-2.0

版本与发布记录

@godspeedai/cognate-execution-wsl 共发布 20 个版本,首次发布于 2026/10/09;过去 12 个月发布了 20 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.10.0latest2026/11/16今天
0.9.22026/11/152 天前
0.9.12026/11/143 天前
0.9.02026/11/0610 天前
0.8.02026/10/2720 天前
0.7.12026/10/2523 天前

关于 @godspeedai/cognate-execution-wsl 的常见问题

@godspeedai/cognate-execution-wsl 是什么?

WSL distribution as an execution world: filesystem and process ports over wsl.exe -e sh -s. Same contracts as every other provider.

如何安装 @godspeedai/cognate-execution-wsl?

在项目目录运行 npm install @godspeedai/cognate-execution-wsl,或使用 pnpm add / yarn add / bun add。

@godspeedai/cognate-execution-wsl 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/godspeedai__cognate-execution-wsl 是否存在。

@godspeedai/cognate-execution-wsl 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@godspeedai/cognate-execution-wsl 可以商用吗?

@godspeedai/cognate-execution-wsl 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@godspeedai/cognate-execution-wsl 的下载量有多少?

根据 npm 官方下载统计,@godspeedai/cognate-execution-wsl 在 2026/10/17 – 2026/11/15 这 30 天内被下载 2,966 次,日均约 99 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@godspeedai/cognate-execution-wsl 还在维护吗?

最新版本 0.10.0 发布于 2026/11/16(今天);至今共发布 20 个版本,其中过去 12 个月发布了 20 个;首次发布于 2026/10/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。