Skip to content

Implement Sandbox code mode runtime - #2

Merged
ggoodman merged 6 commits into
mainfrom
codex/implement-sandbox-runtime
Jul 16, 2026
Merged

Implement Sandbox code mode runtime#2
ggoodman merged 6 commits into
mainfrom
codex/implement-sandbox-runtime

Conversation

@ggoodman

@ggoodman ggoodman commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Why

@torkbot/code-mode@0.2.0 exposes a substrate-neutral Node24RuntimeHost contract and models runtime channels as standard Web Streams. This package can therefore own the complete Sandbox integration without copying code-mode internals, adapting between equivalent stream shapes, or teaching code mode about Sandbox.

The integration starts with the composable primitive: a Sandbox implementation of Node24RuntimeHost for a caller-owned, already booted SandboxInstance. Callers compose that host with Node24Runtime; booting, lifecycle ownership, and any future convenience API remain separate policy layers.

What changed

  • add createSandboxNodeRuntimeHost(), which returns the public structural Node24RuntimeHost contract
  • compose the host explicitly with Node24Runtime; do not add a runtime subclass or inheritance-only wrapper
  • require a caller-owned SandboxInstance, absolute guest cwd, and guest nodePath
  • leave booting, pooling, reuse, persistence, and VM disposal with the caller
  • own only the guest processes launched through the host
  • implement the Sandbox-backed Node host contract:
    • Node version checks through the selected guest executable and working directory
    • bootstrap delivery over stdin
    • the dedicated full-duplex process pipe requested by code mode
    • direct use of the pipe's ReadableStream and WritableStream, preserving their identity
    • launch readiness, stderr diagnostics, aborts, graceful termination, and forced termination
    • runtime termination without a local channel lifecycle abstraction
  • remove the custom byte writer and readable-stream adapter made obsolete by the upstream Web Streams contract
  • depend on the released @torkbot/code-mode@^0.2.0 and @torkbot/sandbox@^0.14.0 contracts
  • document the caller-owned lifecycle contract and direct composition with Sandbox

Validation

  • clean npm ci with zero audit findings
  • npm run typecheck
  • npm test — 8 passing launch, exact stream pass-through, path validation, ownership, failure, abort, and package-surface tests
  • npm run build
  • built declaration and runtime export inspection — the package has one value export, createSandboxNodeRuntimeHost
  • npm pack --dry-run
  • real tarball install and ESM import from an isolated consumer
  • downstream TypeScript declaration compile from the installed tarball
  • git diff --check

Known external test boundary

The currently published @torkbot/sandbox-image-alpine-3.23-agent package declares a peer dependency on @torkbot/sandbox@^0.13.0, while process pipes require Sandbox 0.14. A real-image conformance test would therefore require overriding an upstream package constraint. This PR does not add that workaround; its tests exercise the exact released Sandbox 0.14 process contract directly.

@ggoodman
ggoodman marked this pull request as ready for review July 15, 2026 20:47
@ggoodman

Copy link
Copy Markdown
Contributor Author

@codex PTAL

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83f83bee06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts
@ggoodman

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 40987bc45d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ggoodman

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8470a0e63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts Outdated
@ggoodman

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 06dcd930bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ggoodman
ggoodman merged commit 2da0cfd into main Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant