Skip to content

feat(think): add experimental Computer workspace - #2002

Draft
cjol wants to merge 3 commits into
mainfrom
think-workspace
Draft

feat(think): add experimental Computer workspace#2002
cjol wants to merge 3 commits into
mainfrom
think-workspace

Conversation

@cjol

@cjol cjol commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

This PR adds an opt-in @cloudflare/think/experimental/computer entrypoint for using Cloudflare Computer as a Think workspace. Existing Think agents continue to use @cloudflare/shell and just-bash unless they opt in. It consumes the shared client compatibility added by cloudflare/computer#26.

Why

  • Computer provides a durable filesystem plus native shell execution, while the current Think workspace runs commands through the in-process just-bash fallback.
  • Replacing the default workspace would change execution behavior and hide existing workspace data. There is no migration between the legacy @cloudflare/shell tables and Computer vfs_* tables.
  • The integration therefore lives behind an experimental export and optional peer dependency, so each Think class can opt in independently.
  • Local and remote Computer clients now share the upstream useThink compatibility surface. Keeping a second filesystem adapter in Think would duplicate path, stat, and missing-file translations and allow the two implementations to drift.

Public API Surface

All additions are under the new experimental export.

Symbol Kind Notes
createComputerWorkspace Function Constructs a locally owned Computer with useThink: true
adaptComputer Function Validates and narrows a compatible getWorkspace() client without wrapping it
ComputerWorkspace Type A Computer client intersected with Think WorkspaceLike
LocalComputerWorkspace Type A local Computer intersected with Think WorkspaceLike
Computer Class re-export Alias for the current Computer Workspace class
getWorkspace Function re-export Resolves local and remote Computer clients
withWorkspace Mixin re-export Adds Computer ownership to another Durable Object class
WorkspaceServiceProxy Worker entrypoint re-export Connects the Worker shell backend to the owning Think instance
WorkerBackend Class re-export Worker Loader shell backend
ComputerOptions Type Options accepted by createComputerWorkspace
WorkspaceClient Type Local or remote Computer client type
WorkerBackendOptions Type Worker backend configuration
WorkerShellFetcher Type Fetcher contract used by the Worker backend

Architectural Changes

Think.workspace
├── default: @cloudflare/shell Workspace
│   └── built-in bash tool uses just-bash
└── opt-in override: @cloudflare/computer
    ├── owner enables useThink once
    ├── local and remote clients expose the same Think methods
    ├── native fs, shell, git, assets, and artifacts stay available
    └── built-in bash tool uses Computer shell exec

Code Changes

  • Adds the experimental Computer entrypoint and preserves the native Computer object for both local ownership and remote clients.
  • Makes adaptComputer() a runtime assertion because the owner-side useThink option cannot be inferred across RPC. It returns the original client rather than a compatibility wrapper.
  • Teaches createWorkspaceTools() to use a workspace native shell when available while retaining the existing just-bash fallback.
  • Adds the host bridge that lets WorkspaceServiceProxy obtain the stub for a Computer owned by the Think Durable Object.
  • Adds the optional Computer peer, build entrypoint, package export, changeset, and user documentation.

Compatibility

  • This is an additive minor change. Think default workspace, direct workspace methods, stored data, and just-bash execution remain unchanged.
  • Opting in starts with a separate Computer workspace. Existing legacy files remain untouched but are not visible through Computer, and Computer files are not visible after switching back.
  • Consumers importing the experimental entrypoint need @cloudflare/computer@>=0.1.0-alpha.2 <0.2.0.
  • The development dependency uses the immutable preview from computer: Carry Think methods onto clients computer#26 until 0.1.0-alpha.2 is published; it should be replaced with the released alpha before this PR merges.

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 07ab121

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/think Minor
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

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

@cjol
cjol force-pushed the think-workspace branch from 41f4742 to 7eab151 Compare July 30, 2026 13:42
@pkg-pr-new

pkg-pr-new Bot commented Jul 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2002

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2002

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2002

create-think

npm i https://pkg.pr.new/create-think@2002

hono-agents

npm i https://pkg.pr.new/hono-agents@2002

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2002

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2002

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2002

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2002

commit: 07ab121

@cjol
cjol force-pushed the think-workspace branch from 7eab151 to dc177ef Compare July 30, 2026 13:58
cjol added 2 commits July 30, 2026 21:29
Computer now applies its Think filesystem compatibility methods to local and remote clients when the owner enables useThink. Keeping the same translations in Think creates two implementations that can drift and hides the native Computer client behind an adapter object.

Make ComputerWorkspace an intersection of WorkspaceClient and WorkspaceLike, and reduce adaptComputer() to a runtime assertion that narrows the owner's runtime configuration. The client remains unchanged, so its filesystem, shell, git, artifact, and asset surfaces stay directly available.

Require @cloudflare/computer 0.1.0-alpha.2 as the optional peer. Use the Computer pull request preview as the development dependency until that alpha is published, so fresh installs test the new client contract without a local package link.
@cjol cjol changed the title Add experimental Computer workspace integration to Think feat(think): add experimental Computer workspace Jul 30, 2026
@cjol

cjol commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@aron-cf now that Computer #26 and workspace #24 have merged, could you publish "@cloudflare/computer 0.1.0-alpha.2" from main? Once that's on npm I can swap the PR preview dep, regenerate lockfile, and undraft this PR.

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