
Cloudflare Artifacts
Agents know git. Every repository can act as a git repo, allowing agents to interact with Artifacts the way they know best: using the git CLI.
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Agents know git. Every repository can act as a git repo, allowing agents to interact with Artifacts the way they know best: using the git CLI.
Create repos, new branches, commit, diff and search. All programmatically, without waiting.
Create a thousand, a million or ten million repos: one for every agent, for every upstream branch, or every user. No need to plan ahead.
A few lines of code. Millions of repos.
Create, import, fork, and manage access: the full repo lifecycle from a Workers binding.
import type { Artifacts } from 'cloudflare:workers'; interface Env { ARTIFACTS: Artifacts;} export default { async fetch(request: Request, env: Env) { // Create a repo — returns the remote URL and an initial write token const { remote, token, repo } = await env.ARTIFACTS.create('my-project'); // Issue a scoped read token, valid for 1 hour const readToken = await repo.createToken('read', 3600); return Response.json({ remote, token: readToken.plaintext }); },};
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22
import type { Artifacts } from 'cloudflare:workers'; interface Env { ARTIFACTS: Artifacts;} export default { async fetch(request: Request, env: Env) { // Import from GitHub const { repo } = await env.ARTIFACTS.import('workers-sdk', { url: 'https://github.com/cloudflare/workers-sdk', branch: 'main', }); // Fork to an isolated, read-only copy const { remote, token } = await repo.fork('workers-sdk-review', { readOnly: true, }); return Response.json({ remote, token }); },};
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17
Create a repocurl -X POST "https://artifacts.cloudflare.dev/v1/api/namespaces/default/repos" \ -H "Authorization: Bearer $JWT" \ -H "Content-Type: application/json" \ -d '{ "name": "my-project" }'
Issue a scoped read token, valid for 1 hourcurl -X POST "https://artifacts.cloudflare.dev/v1/api/namespaces/default/tokens" \ -H "Authorization: Bearer $JWT" \ -H "Content-Type: application/json" \ -d '{ "repo": "my-project", "scope": "read", "ttl": 3600 }'
Fork to an isolated copycurl -X POST "https://artifacts.cloudflare.dev/v1/api/namespaces/default/repos/my-project/fork" \ -H "Authorization: Bearer $JWT" \ -H "Content-Type: application/json" \ -d '{ "name": "my-project-fork" }'
Create a repo and issue tokens
How Artifacts work
Create a repo in one line of code
Create one. Create one million. One API that scales.
Fork from another repo: in Artifacts, from GitHub, or any other git-compatible upstream.
create() and import() return a remote URL directly. Pass it to your agent, a CLI, an IDE, or another Worker. Standard git clone just works.
Create short-lived tokens for any repo: read for safe inspection, write for agents that need to commit. Tokens expire automatically.
Artifacts
One repo per agent. One per user. One per everything.
See real-world examples of Cloudflare Artifacts
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。