Skip to content
Reference

Fix RPC types and runtime imports with Fungi's npm forks

Why Fungi maintains forks of Cap'n Web, Cloudflare Computer, Worker Bundler and ts-webp, which upstream revisions they start from, and when to drop them.

These npm forks carry specific changes Fungi needs. They are not claims that the upstream projects are generally broken. Start with the symptom below, check the runtime requirement, and use the fork only if you need its change. Upstream versions below name the imported source, not the fork’s npm version.

Cap’n Web: TS2574 and tuple types with skipLibCheck false

Section titled “Cap’n Web: TS2574 and tuple types with skipLibCheck false”

Upstream: cloudflare/capnweb, release 0.12.0, commit 7702075.

The exact TypeScript diagnostic is:

TEXT
TS2574: A rest element type must be an array type.

With skipLibCheck: false, upstream’s UnstubifyInner spreads a tuple tail through Unstubify<Tail>, a union that includes Promise. The fork uses UnstubifyAll<Tail> instead, preserving tuple parameter types rather than skipping declaration checks.

TERMINAL
npm install @fungi.computer/capnweb

The fork also fixes idle stream cancellation. Exported stubs report breakage through the existing onBroken and broken-reference reject machinery; writable proxies observe that callback. Cancelling a received readable can then interrupt an idle sender without waiting for another chunk.

Immediate idle cancellation requires the fix at both ends. Upstream 0.12.0 and older Fungi peers keep normal streaming with their previous cancellation latency. This does not add wire messages or peer negotiation.

Drop condition: upstream includes both the tuple declaration and idle cancellation fixes.

MIT · README · LICENSE.txt · NOTICE

Cloudflare Computer: shell state lost between commands

Section titled “Cloudflare Computer: shell state lost between commands”

Upstream: cloudflare/computer, @cloudflare/computer@0.2.1, commit 849759bbfc23eafbe989b6b158e31ef60a4afb68.

Cloudflare Computer provides a SQLite virtual filesystem in a Durable Object for agents, with pluggable execution backends. Files survive Durable Object restarts. That is separate from carrying a shell’s working directory and environment into its next command.

TERMINAL
npm install @fungi.computer/cloudflare-computer

The fork’s worker shell emits a final state event before exit, containing { cwd, env }. The runtime result exposes it as WorkspaceRuntimeResult.state, and the type surface exports WorkspaceShellState. A host can retain that state and carry it into its next execution. This is not a persistent running shell process, and the worker-javascript backend never emits shell state.

The loss of cwd/environment is a behavioral symptom, not a fixed error string. For a malformed state event, the worker-shell decoder does emit the exact message WorkerShellBackend received a malformed shell state frame.

Preview only. Upstream marks the package unsuitable for production use. The fork does not remove that warning. The Worker shell needs a Worker Loader binding and the experimental flag, in addition to the package’s nodejs_compat requirement.

Drop condition: an upstream release exposes equivalent final shell state through the runtime event and result contracts, and the host has moved its state handling to that release. Recheck the fork’s vendored build and shared Cap’n Web dependency before switching.

MIT · Upstream README at the imported revision · LICENSE · NOTICE

Worker Bundler: serve static assets without esbuild-wasm

Section titled “Worker Bundler: serve static assets without esbuild-wasm”

Upstream: @cloudflare/worker-bundler@0.2.3 from cloudflare/agents, commit d42494503efe836a073fbf911fae1fbd12253198.

The full bundler imports an esbuild-wasm WebAssembly module that only the Workers module loader can resolve. It runs in workerd or wrangler dev, not plain Node.js or a default-pool Vitest/Jest test. There is no single documented error string for every unsupported loader.

TERMINAL
npm install @fungi.computer/cloudflare-worker-bundler

If you only need to serve prebuilt assets, import the fork’s @fungi.computer/cloudflare-worker-bundler/assets entry. It exports handleAssetRequest, buildAssetManifest, buildAssets, createMemoryStorage, inferContentType and isTextContentType without the esbuild/Sucrase bundler graph. This entry runs outside Workers too; it does not make the full bundler Node-compatible.

The fork also imports DurableObjectStorage in its declarations so consumers do not need ambient Workers types. The package remains experimental and is not recommended for production use.

Drop condition: upstream offers the independent asset-serving entry and resolvable declarations, and consumers no longer need these fork changes.

MIT · README · LICENSE · NOTICE

Upstream: stacksjs/ts-webp, release v0.1.6, commit dfd79c9.

Upstream’s published declarations omit extensions on relative imports. Under NodeNext resolution, exports fail to resolve and their types degrade to any. This is the symptom; the fork’s README does not prescribe a single compiler diagnostic string.

TERMINAL
npm install @fungi.computer/ts-webp

The fork names every relative import’s .js file and builds with tsc for NodeNext. It does not change the codec implementation.

The package decodes and encodes WebP in TypeScript through decode, decodeAnimation, encode and encodeWithAlpha, with RIFF helpers. This is the TypeScript path for encoding without a native codec dependency. encodeViaCwebp is a separate, optional path through the native cwebp command-line encoder; do not confuse the two.

Drop condition: upstream publishes NodeNext-resolvable declarations.

MIT · README · LICENSE · NOTICE

The package index lists these forks alongside Fungi’s other libraries. Their NOTICE files retain upstream attribution; the fork scope does not imply a new license for upstream code.