Skip to content

safe-bash: remove remaining node: builtins from the default agentCommands graph (crypto/zlib/stream/perf_hooks/timers) for a zero-nodejs_compat Workers bundle #672

Description

@kamilio

Goal

Make the default agentCommands() graph loadable on Cloudflare Workers and browsers without nodejs_compat — a true zero-node:-builtin bundle. Today the full command inventory runs on workerd with nodejs_compat (verified on real workerd, 2026-09-08), but the eager node: imports below mean the ordinary entry cannot load when compatibility_flags = [].

This is the sibling of #669 (portable-by-default agentCommands / injectable regexExecutor, which removes node:worker_threads) and #671 (the two contracts/ leaks). #669 gets the default entry onto workerd-with-compat; this issue removes the remaining Node builtins so no compat flag is needed.

Node builtins in the createAgentCommands graph (beyond #669/#671)

Verified against current src (all reached from plugins/composition.ts):

  • node:crypto
    • commands/bytes/checksums/index.ts:3createHash (sha256sum/sha1sum/md5sum/cksum).
    • commands/bytes/compression/files.ts:1randomUUID.
    • commands/metadata/mktemp.ts:1randomInt (mktemp).
  • node:zlib
    • commands/bytes/compression/gunzip.ts:5createInflateRaw.
    • commands/bytes/compression/stream.ts:4createGzip.
    • commands/archive/stream.ts:1createGunzip, createGzip (tar gz).
  • node:stream / node:stream/promises
    • commands/bytes/compression/stream.ts:1-2Readable, PassThrough, pipeline.
  • node:perf_hooks / node:timers
    • commands/timeout/scheduler.ts:1-2performance, setTimeout/clearTimeout.
  • node:worker_threads (expr BRE path)

Portable replacements (all have Workers/browser-standard equivalents)

Acceptance

  • Bundle the default entry with esbuild --conditions=workerd,worker,browser and assert zero node: specifiers.
  • Load and run representative commands (sha256sum, gzip/zcat, tar, mktemp, timeout, expr) on real workerd with compatibility_flags = [].
  • Preserve current budgets, cancellation, gzip-bomb caps, and explicit unsupported-mode errors; no unbounded native fallbacks.
  • Where a portable primitive forces a tradeoff (e.g. async digest, restricted zlib), document it rather than weakening a guarantee.

Depends on / pairs with #669 and #671.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not workingreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions