Commit 05cd90a
authored
Add @cloudflare/workspace/tools entrypoint (#23)
* workspace: Add AI SDK tools entrypoint
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.
* examples/think: Use workspace AI tools
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.
* docs: Document workspace tool interface
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.
* workspace: Use a function type for remote add
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.
* workspace, examples/think, docs: Rename publish tool
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.
* workspace, examples/think, docs: Add Think compatibility option
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.
* workspace, examples/think, docs: Address tools review feedback
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.1 parent e9e01d8 commit 05cd90a
29 files changed
Lines changed: 1479 additions & 729 deletions
File tree
- docs
- examples/think
- src
- tools
- fs
- packages/workspace
- src
- artifacts
- tools
- fs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
0 commit comments