@fungi.computer/cordyceps

中文文档
0.4.2发布于 2026/11/09MITTypeScriptESM + CJS近 30 天下载 5646

Cloudflare computerd 0.2.1 and the native apply_patch engine source for Local and the Computer container

原始使用文档
文档目录9 节
  1. Install or set up
  2. Native patch engine
  3. Quick start
  4. Core concepts
  5. API reference
  6. Examples
  7. Limits and errors
  8. Contribute and license
  9. Packed consumer readiness

Cordyceps (@fungi.computer/cordyceps)

@fungi.computer/cordyceps bundles Cloudflare's pinned computerd daemon with its vendored DOFS and computer-rpc sources, and ships the source and builder of the native fungi-apply-patch engine behind the apply_patch tool. Local runs the daemon in shim mode for an attached folder and runs its own build of the engine in its project root; the Computer container copies and starts the same daemon as its workspace daemon and compiles the engine for its own platform.

Install or set up

npm install @fungi.computer/cordyceps

Node 22.13 or newer runs the bundled dist/computerd.cjs. Spore and the Computer image already include Cordyceps; install it directly only when you compose your own Computer host. In the repository, the package build uses esbuild after pnpm install --frozen-lockfile.

Native patch engine

fungi-apply-patch reads one Codex-format patch on stdin and applies it inside its working directory. It wraps the pinned upstream Codex codex-apply-patch crate (native/apply-patch/pin.mjs) with Fungi's rooted, bounded host (native/apply-patch/main.rs): paths stay inside the working directory, input and changes are bounded to 128 KiB, a context mismatch exits 23 and a malformed patch exits 24.

The package ships the engine's source, never a prebuilt binary, so every consumer gets an executable for its own platform:

  • compile.mjs compiles one target inside a prepared builder (Node, rustup with the pinned Rust toolchain, a C toolchain and network access). It verifies the pinned Codex release archive's SHA256, builds with the upstream lock unchanged (--locked), remaps build paths, strips debug information, and writes fungi-apply-patch plus build.json, the license and notice texts of every crate compiled into it.
  • fungi-apply-patch-build --out <dir> [--target <platform>] (build.mjs) builds for a host. Linux targets build in a digest-pinned Ubuntu 22.04 container (glibc 2.35 floor), and macOS targets cross-build from Linux in a pinned cargo-zigbuild container, each as an ordinary docker build --output (docker/). A macOS host builds its own target natively through rustup. One immutable artifact per pin, wrapper and target is shared under ${XDG_CACHE_HOME:-~/.cache}/fungi/native-patch/; concurrent misses serialize on proper-lockfile, publication is atomic, and a cache hit verifies its checksums before restoring the executable and notices. A mismatch is refused rather than silently reused or rebuilt under the same pin.
  • The Computer image's Dockerfile copies this directory and runs compile.mjs in a builder stage, so the image's engine always matches the image's platform.
pnpm --filter @fungi.computer/cordyceps build:native

Quick start

Build the bundle and run its existing shim-mode proof:

pnpm --filter @fungi.computer/cordyceps build
pnpm --filter @fungi.computer/cordyceps test

The bundle test starts computerd with PORT=0, a temporary mount directory, and FUSE_MOUNT=shim, then checks GET /health. It stops the child and removes the fixture directory. See test/computerd-bundle.test.mjs.

Resolve the installed executable before starting it with the host configuration:

import { fileURLToPath } from "node:url";

const cli = fileURLToPath(import.meta.resolve("@fungi.computer/cordyceps/cli"));
console.log(cli);

Core concepts

  • The package composes vendored sources. scripts/build.mjs bundles the pinned upstream/computerd, upstream/dofs, and upstream/rpc trees. upstream/PROVENANCE.md records the source revision and Botanical changes.
  • Local uses the shim. Local selects FUSE_MOUNT=shim, binds the daemon to an available port, and connects through loopback. Its host-side folder is synchronized with the in-memory virtual filesystem.
  • The Computer container owns runtime startup. Its image copies the bundle to /opt/fungi/computerd.cjs; the container init process starts it alongside the terminal service. The configured FUSE backend and container privileges determine whether the mount succeeds.

API reference

The package exports ./cli, which resolves to the built CommonJS daemon, and ./native/apply-patch/*, the engine's source and builder, with the fungi-apply-patch-build bin. It also exports ./native/bwrap/* with the fungi-bwrap-build bin. The daemon's runtime configuration is read from environment variables such as PORT, MOUNT_POINT, FUSE_MOUNT, and optional UPSTREAM_URL. The upstream/computerd/README.md, upstream/dofs/README.md, and upstream/rpc/README.md describe the vendored layers; the build script and upstream/PROVENANCE.md describe this package's composition and local changes.

Examples

The bundle test is the runnable example: it launches the built daemon with the userspace shim, requests its health endpoint, and shuts it down. Local's caller selects the same shim explicitly. The shim supports an attached local folder when FUSE is unavailable; it is not a production-grade replacement for a real mount.

Limits and errors

Computerd requires Node 22.13 or newer. A FUSE mount needs the matching host or container support; the daemon's automatic backend selection can choose the shim when a FUSE device is unavailable. The shim reconciles writes across the host-folder boundary and can have races between writers; it is intended for Local fallback use. The daemon's virtual filesystem is not itself durable on disk. When UPSTREAM_URL is configured, the vendored sync client connects the virtual filesystem to that upstream; persistence and recovery depend on that owner.

Contribute and license

Run pnpm --filter @fungi.computer/cordyceps build and pnpm --filter @fungi.computer/cordyceps test after changing the bundle composition. Review upstream/PROVENANCE.md for attribution and local patches; upstream/LICENSE contains the vendored MIT license. The patch engine is derived from OpenAI Codex under the Apache-2.0 license, which ships in the package tarball; each build's build.json carries the license and notice texts of every crate compiled into it.

Packed consumer readiness

Run pnpm run build, pnpm run pack and pnpm run stranger in this package. The maintained stranger proof installs only package tarballs into a fresh npm consumer, checks the exact shipped files, runs the public runtime fixture and compiles every JavaScript entrypoint with strict NodeNext and no library-check skip. This qualification does not publish npm releases or push a repository split.

版本与发布记录

@fungi.computer/cordyceps 共发布 7 个版本,首次发布于 2026/10/17;过去 12 个月发布了 7 个版本。

版本发布日期距今
0.4.2latest2026/11/097 天前
0.4.12026/11/087 天前
0.4.02026/10/2620 天前
0.3.12026/10/2422 天前
0.3.02026/10/2323 天前
0.2.22026/10/1730 天前

关于 @fungi.computer/cordyceps 的常见问题

@fungi.computer/cordyceps 是什么?

Cloudflare computerd 0.2.1 and the native apply_patch engine source for Local and the Computer container

如何安装 @fungi.computer/cordyceps?

在项目目录运行 npm install @fungi.computer/cordyceps,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 fungi-bwrap-build、fungi-apply-patch-build,可以用 npx fungi-bwrap-build 直接运行。

@fungi.computer/cordyceps 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fungi.computer/cordyceps 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fungi.computer/cordyceps 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fungi.computer/cordyceps 可以商用吗?

@fungi.computer/cordyceps 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fungi.computer/cordyceps 的下载量有多少?

根据 npm 官方下载统计,@fungi.computer/cordyceps 在 2026/10/16 – 2026/11/14 这 30 天内被下载 5,646 次,日均约 188 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fungi.computer/cordyceps 还在维护吗?

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