Skip to content

feat: durable REPL sessions - core eval loop - #152

Draft
ben-reitz wants to merge 1 commit into
mainfrom
feat/durable-repl
Draft

ben-reitz wants to merge 1 commit into
mainfrom
feat/durable-repl

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Sep 23, 2026 •

Copy link
Copy Markdown

Adds workspace.repl(name): a persistent JavaScript session backed by the Workspace Durable Object.

  • Each eval runs in a fresh dynamic isolate that replays the committed cell log from SQLite, so variables and functions survive across calls, restarts, and eviction.
  • Failed cells roll back and never commit.
  • Nondeterminism (Date, Math.random, crypto) is recorded and replayed so state rebuilds identically.
  • Ambient egress is blocked.

workspace.repl(name).eval(code) gives agents a durable JavaScript REPL:
a session is a replayable log in the workspace DO SQLite, not a
process. Every eval builds a fresh dynamic isolate (runtime eval is
banned there), replays committed cells against recorded effects, and
records the new cell. Failed cells never enter the log; sessions
survive DO eviction with state rebuilt exactly and effects never
re-fired.

- acorn cell transform: top-level declarations persist via globalThis,
  value = explicit return or trailing expression
- recorded nondeterminism (audited against a live dynamic isolate):
  Math.random, Date.now, no-arg new Date() / Date(), crypto.randomUUID,
  crypto.getRandomValues, performance.now; WeakRef/FinalizationRegistry/
  caches removed so use fails loudly instead of silently diverging
- result follows the common interpreter convention plus a structured
  "value" field; logs are one ordered stream with console levels kept
  (logs.entries + logs.dropped); unclonable successes render into
  results[] instead of failing
- replay divergence is a hard, structured error (kind mismatch and
  unconsumed-effects both covered by tests); evals serialize per
  session; deny-by-default egress (globalOutbound: null); wall-clock
  timeout maps to a structured timeout error
@changeset-bot

changeset-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5e53aad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ben-reitz
ben-reitz added this pull request to stack #155 September 23, 2026 09:13
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your interest in Cloudflare Computer.

This repository does not accept unsolicited pull requests. Please use one of the accepted contribution paths instead:

If a maintainer asked you to open this pull request, they can add the allow-pr label and reopen it.

@github-actions github-actions Bot closed this Sep 23, 2026

@devin-ai-integration devin-ai-integration 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.

Devin Review found 6 potential issues.

Devin Review

Comment thread packages/computer/src/repl/session.ts
Comment thread packages/computer/src/repl/runner.ts
Comment thread packages/computer/src/repl/session.ts
Comment thread packages/computer/src/repl/transform.ts
Comment thread packages/computer/src/index.ts
Comment thread packages/computer/src/workspace.ts
@ben-reitz ben-reitz added the allow-pr Allow a PR to remain open. label Sep 23, 2026
@ben-reitz ben-reitz changed the title feat: durable REPL sessions — core eval loop feat: durable REPL sessions - core eval loop Sep 23, 2026
@ben-reitz ben-reitz reopened this Sep 23, 2026
@ben-reitz
ben-reitz marked this pull request as draft September 23, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-pr Allow a PR to remain open.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant