Conversation
Add @cloudflare/workspace/tools as a separate package subpath for AI SDK tool wrappers. The entrypoint exposes createAITools() plus the underlying read, write, edit, ls, exec, and share helpers, while keeping ai and zod as optional peers so the main Workspace entrypoint stays independent of the AI SDK. Cover the tool set with focused tests for read-only mode, file operations, byte caps, backend routing, UTF-8-safe exec truncation, and asset sharing.
Replace the example's local workspace tool wrappers with createAITools() from @cloudflare/workspace/tools. The example keeps its report_update tool, passes the same backend guidance to the shared exec tool, and relies on Workspace assets for optional sharing. Remove the now-unused diff dependencies and update the example README so the documented tool sources match the migrated wiring.
Update the tool interface guide for the shipped @cloudflare/workspace/tools entrypoint. The docs now cover createAITools(), fixed tool names, read-only mode, opt-in exec, asset sharing, FileStore ranges, and the validation commands for the change.
Represent RemoteAddFn as a function type instead of an interface with only a call signature. This keeps the artifacts CLI type shape the same while satisfying the workspace lint rule.
Expose the assets-backed AI tool as publish instead of share while keeping the underlying Workspace assets client unchanged. Update the package exports, tests, Think documentation, and tool interface docs so the model-facing name is consistent.
commit: |
Add a useThink constructor option that attaches Think's WorkspaceLike filesystem methods to the Workspace instance. This lets Think consumers assign the Workspace directly while keeping the primary API on workspace.fs. Update the Think example to use the option, remove its local compatibility adapter, and document the new constructor option.
Restore model-facing exec fallback guidance, return structured exec errors, omit the publish prefix when no session id is configured, and cancel file read streams when byte-range reads stop before EOF. Keep diff bundled as an implementation detail by removing its optional peer declaration, and fix the assets README wording and Think tools table alignment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change adds a reusable
@cloudflare/workspace/toolsentrypoint for agents that want ready-made AI SDK tools backed by aWorkspace. The Think example had its own local copies of these tools, which made it easy for behavior to drift from the package. Moving the tools into@cloudflare/workspacegives examples and package consumers the same file, shell, and publishing behavior.The new entrypoint exposes
createAITools()and lower-level helpers for the fixed tool namesread,write,edit,ls, optionalexec, and optionalpublish. The main@cloudflare/workspaceentrypoint stays independent of the AI SDK becauseaiandzodare optional peers only for the tools subpath.execis opt-in through shell backend configuration,readonly: trueexposes onlyreadandls, andpublishappears only whenworkspace.assetsis configured unless callers disable it withassets: false.Workspacenow also acceptsuseThink: true. That option adds Think's string-oriented filesystem compatibility methods directly to the instance, so aWorkspacecan be assigned toThink.workspacewithout a local adapter. The compatibility methods are only added when the option is set; the primary file API remainsworkspace.fs.The Think example now imports
createAITools()from@cloudflare/workspace/tools, constructs itsWorkspacewithuseThink: true, and keeps only its example-specificreport_updatetool locally. It passes the same backend guidance to the sharedexectool, keepsworkspaceBashdisabled, uses thepublishtool name for assets, and drops the local duplicate filesystem, shell, and asset tool implementations.Manual verification is to build the workspace package, run the focused tests, and typecheck both the package and the Think example:
The Think local setup can also be checked with:
wrangler devrequires Cloudflare credentials because the example uses a remote Workers AI binding. With credentials and Docker available, the example should start with local durable objects, workflows, R2 buckets, Worker Loader, and the container definition.The documentation now describes the shipped tools interface, documents
useThink, lists the tools subpath in the docs index, and updates the package and Think READMEs to point at the shared implementation. Follow-up work can add provider-specific adapters beyond the AI SDK if another tool format needs first-class support.