Conversation
Add the @cloudflare/workspace/artifacts subpath with a session-scoped facade over the Cloudflare Artifacts Workers binding. Repository names are scoped with a legal separator, list walks pages internally, and CLI-shaped commands dispatch through the same typed client. Add tests and a fake Artifacts binding that uses the Workers binding shapes so the client and CLI behavior are covered without relying on remote services.
Add optional Artifacts configuration to Workspace and expose a session-scoped workspace.artifacts client. WorkspaceStub now carries an artifacts target alongside fs, shell, and git, so the worker-backend shell can register a built-in artifacts command without host-specific wiring. Keep the command available when no binding is configured, but make operations fail with a clear configuration error. Also add a small /dev/null virtual path for the worker shell and keep the dynamic worker compatibility date current.
Teach the argv-driven git push command to split a single-colon refspec such as HEAD:main into the local ref and remote ref expected by the underlying git client. This matches the common git push URL HEAD:branch shape used by generated Artifact repositories.
Document the session-scoped Artifacts facade, its CLI surface, and the worker-backend shell command. Cross-link the Artifacts interface from the docs index and Git / worker-backend docs, and describe the Workspace-level binding configuration used by the shell.
Add optional Artifacts support to the think example. When a binding is configured, the workflow can publish a generated review branch to an Artifact repository and return the remote and clone details; without a binding the example keeps running normally.
Add an example Worker that exposes POST /create. The endpoint gets a Workspace from a minimal Durable Object, uses the worker backend shell to clone and rewrite examples/worker, creates a session-scoped Artifact repository through the built-in shell command, pushes the generated project, and returns a short-lived read clone link.
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 pull request adds first-class Cloudflare Artifacts support to
@cloudflare/workspace. A worker can now wrap anARTIFACTSbinding withcreateArtifact(binding, sessionId)and work with local repository names while the library handles session scoping. That gives each agent, task, or user its own isolated set of repositories inside the same Artifacts namespace.The new client covers the repository and token lifecycle: create, get, list, import, delete, create token, list tokens, get token metadata, and revoke token. Repository names are scoped before they touch the binding and unscoped before they come back to the caller. The scoped name uses a legal Artifacts repository name, such as
session123__build-cache, while callers continue to pass and receivebuild-cache.The same implementation is also available as an argv-style interface. That gives shell users and agents a stable command surface with machine-readable JSON output and predictable exit codes.
The worker backend can expose that CLI as an opt-in
artifactsshell command. The command is not registered globally because the Artifacts binding belongs to the consuming worker, not to the workspace package itself.With that command registered, code running through
bash.execcan call the same surface directly:The implementation uses the global Cloudflare Workers Artifacts types from
@cloudflare/workers-typesinstead of redeclaring the binding shape. The in-memory fake used by tests implements the sameArtifactsinterface and validates repository names against the binding's documented character set, so tests catch shape drift and invalid scoped names.The CLI is designed to be safe for agents and logs.
token createis the only token command that prints plaintext.token list,token get, and token revocation print metadata or a constant confirmation, so a caller does not accidentally echo a secret while revoking by plaintext.Documentation is included in
docs/14_artifacts_interface.md, with cross-links from the workspace docs and package README. Theexamples/thinkworker now shows optional typed Artifacts integration: it detects anARTIFACTSbinding when configured and returns an empty list when the binding is absent, so the example still runs without Artifacts.Validation run:
A filtered
npm test --workspace @cloudflare/workspace -- src/artifacts/ ...command is not a useful shortcut for this package because the package test script forwards the filter to every Vitest config, including configs whose include patterns do not contain those files. The unfiltered workspace package test passes.