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

Closed

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:3 — createHash (sha256sum/sha1sum/md5sum/cksum).
    • commands/bytes/compression/files.ts:1 — randomUUID.
    • commands/metadata/mktemp.ts:1 — randomInt (mktemp).
  • node:zlib
    • commands/bytes/compression/gunzip.ts:5 — createInflateRaw.
    • commands/bytes/compression/stream.ts:4 — createGzip.
    • commands/archive/stream.ts:1 — createGunzip, createGzip (tar gz).
  • node:stream / node:stream/promises
    • commands/bytes/compression/stream.ts:1-2 — Readable, PassThrough, pipeline.
  • node:perf_hooks / node:timers
    • commands/timeout/scheduler.ts:1-2 — performance, 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

  1. kamilio commented on Sep 8, 2026

    @kamilio
    MemberAuthor

    Validated independently against the freshly installed public package candidate: an unshimmed browser/workerd-conditions bundle of /portable fails on the actual emitted node:crypto, node:stream, node:stream/promises, zlib, and timer-related imports. This is a real remaining full-inventory portability gap; the /browser claim in #671 was separately disproved against published 0.1.470 and closed without a speculative patch. #670 removes the portable expr engine dependency on the Node wrapper.

    I am finishing delivery of the validated #670 and mixed-entry #669 fixes now, then continuing #669 under the updated scope and #672. Streaming hashes/codecs must retain input/output/work limits and cancellation; no whole-input digest shortcut, native unbounded-regex fallback, or silent loss of gzip/tar semantics. No claim of a zero-Node full preset yet. Reproduction log: /tmp/kamilio-672-portable-browser-red.log.

  2. kamilio commented on Sep 8, 2026

    @kamilio
    MemberAuthor

    Final delivery verification: remote main fd9ba58 matches the product tree of the freshly installed artifact tested in actual workerd. All 29 flags=[] cases pass, all 79 command names are present, and the installed graph has zero Node/external edges. Full maintained npm test, normal build, lint, installed Node/Bun, strict browser types and browser smoke pass. Fresh hashes, SRI bindings and runtime cleanup are recorded in docs/plans/issue-672-workerd-validation.md. The issue is closed after push; release publication is still being monitored separately.

  3. poe-code-agent commented on Sep 8, 2026

    @poe-code-agent
    Contributor

    Issue was resolved by #fd9ba58

    Update poe-code via npm install -g [email protected]

  4. kamilio commented on Sep 8, 2026

    @kamilio
    MemberAuthor

    Publication is now verified: all three scoped packages (@poe-platform/safe-bash, safe-fs, safe-js) are npm latest 0.1.499. Scoped release run 34276528355 attempt 2 passed installed tarball verification and all three provenance-backed publishes for fd9ba58. The zero-Node default entry is therefore published, not just a local candidate. [email protected] is published too.

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