diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05ff159 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +pr.md +TODO.md diff --git a/README.md b/README.md index 7ec8f24..d6186e9 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ This plugin includes [Cloudflare's remote MCP servers](https://developers.cloudf | Server | Purpose | |--------|---------| +| cloudflare-api | Manage Cloudflare account resources, zones, and settings | | cloudflare-docs | Up-to-date Cloudflare documentation and reference | | cloudflare-bindings | Build Workers applications with storage, AI, and compute primitives | | cloudflare-builds | Manage and get insights into Workers builds | diff --git a/skills/building-ai-agent-on-cloudflare/SKILL.md b/skills/building-ai-agent-on-cloudflare/SKILL.md index f35084a..6ed415d 100644 --- a/skills/building-ai-agent-on-cloudflare/SKILL.md +++ b/skills/building-ai-agent-on-cloudflare/SKILL.md @@ -181,7 +181,7 @@ Clients connect via: `wss://my-agent.workers.dev/agents/MyAgent/session-id` "compatibility_date": "2024-12-01", "ai": { "binding": "AI" }, "durable_objects": { - "bindings": [{ "name": "AGENT", "class_name": "MyAgent" }] + "bindings": [{ "name": "MyAgent", "class_name": "MyAgent" }] }, "migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyAgent"] }] } diff --git a/skills/building-ai-agent-on-cloudflare/references/agent-patterns.md b/skills/building-ai-agent-on-cloudflare/references/agent-patterns.md index 219e825..67db46d 100644 --- a/skills/building-ai-agent-on-cloudflare/references/agent-patterns.md +++ b/skills/building-ai-agent-on-cloudflare/references/agent-patterns.md @@ -194,12 +194,16 @@ export class RAGAgent extends Agent { Coordinate multiple specialized agents: ```typescript +import { Agent, Connection, getAgentByName } from "agents"; + interface Env { - RESEARCHER: DurableObjectNamespace; - WRITER: DurableObjectNamespace; - REVIEWER: DurableObjectNamespace; + ResearcherAgent: DurableObjectNamespace; + WriterAgent: DurableObjectNamespace; + ReviewerAgent: DurableObjectNamespace; } +// --- Orchestrator: coordinates the pipeline via RPC --- + export class OrchestratorAgent extends Agent { async onMessage(connection: Connection, message: string) { const data = JSON.parse(message); @@ -208,29 +212,30 @@ export class OrchestratorAgent extends Agent { connection.send(JSON.stringify({ type: "status", step: "researching" })); // Step 1: Research agent gathers information - const researchResult = await this.callAgent( - this.env.RESEARCHER, - data.topic, - { action: "research", topic: data.topic } - ); + const researcher = await getAgentByName(this.env.ResearcherAgent, data.topic); + const researchResult = await researcher.processTask({ + action: "research", + topic: data.topic, + }); connection.send(JSON.stringify({ type: "status", step: "writing" })); // Step 2: Writer agent creates draft - const draftResult = await this.callAgent( - this.env.WRITER, - data.topic, - { action: "write", research: researchResult, topic: data.topic } - ); + const writer = await getAgentByName(this.env.WriterAgent, data.topic); + const draftResult = await writer.processTask({ + action: "write", + research: researchResult, + topic: data.topic, + }); connection.send(JSON.stringify({ type: "status", step: "reviewing" })); // Step 3: Reviewer agent improves draft - const finalResult = await this.callAgent( - this.env.REVIEWER, - data.topic, - { action: "review", draft: draftResult } - ); + const reviewer = await getAgentByName(this.env.ReviewerAgent, data.topic); + const finalResult = await reviewer.processTask({ + action: "review", + draft: draftResult, + }); connection.send(JSON.stringify({ type: "complete", @@ -238,21 +243,38 @@ export class OrchestratorAgent extends Agent { })); } } +} - private async callAgent( - namespace: DurableObjectNamespace, - id: string, - payload: any - ): Promise { - const agentId = namespace.idFromName(id); - const agent = namespace.get(agentId); - - const response = await agent.fetch("http://agent/task", { - method: "POST", - body: JSON.stringify(payload), - }); +// --- Sub-agents: each exposes an RPC method instead of HTTP routes --- + +export class ResearcherAgent extends Agent { + async processTask(payload: { action: string; topic: string }): Promise { + // Perform research using AI, external APIs, etc. + const result = await this.generateResearch(payload.topic); + return result; + } + + private async generateResearch(topic: string): Promise { + // ... research implementation ... + return `Research results for ${topic}`; + } +} + +export class WriterAgent extends Agent { + async processTask(payload: { + action: string; + research: string; + topic: string; + }): Promise { + // Generate a draft article from the research + return `Draft article on ${payload.topic} based on research`; + } +} - return response.text(); +export class ReviewerAgent extends Agent { + async processTask(payload: { action: string; draft: string }): Promise { + // Review and improve the draft + return `Reviewed and improved: ${payload.draft}`; } } ``` diff --git a/skills/building-ai-agent-on-cloudflare/references/troubleshooting.md b/skills/building-ai-agent-on-cloudflare/references/troubleshooting.md index 5a94578..f5a050d 100644 --- a/skills/building-ai-agent-on-cloudflare/references/troubleshooting.md +++ b/skills/building-ai-agent-on-cloudflare/references/troubleshooting.md @@ -239,7 +239,7 @@ Check `wrangler.jsonc`: ```jsonc { "durable_objects": { - "bindings": [{ "name": "AGENT", "class_name": "MyAgent" }] + "bindings": [{ "name": "MyAgent", "class_name": "MyAgent" }] }, "migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyAgent"] }] } diff --git a/skills/building-mcp-server-on-cloudflare/references/troubleshooting.md b/skills/building-mcp-server-on-cloudflare/references/troubleshooting.md index f1e62e7..c67b9df 100644 --- a/skills/building-mcp-server-on-cloudflare/references/troubleshooting.md +++ b/skills/building-mcp-server-on-cloudflare/references/troubleshooting.md @@ -126,7 +126,7 @@ this.server.tool( ### Tool Timeout -Workers have CPU time limits (10-30ms for free, longer for paid). For long operations: +Workers have CPU time limits (10ms for free, 30s default / 5min max for paid). For long operations: ```typescript this.server.tool( diff --git a/skills/cloudflare/references/agents-sdk/configuration.md b/skills/cloudflare/references/agents-sdk/configuration.md index a99cb03..d0988be 100644 --- a/skills/cloudflare/references/agents-sdk/configuration.md +++ b/skills/cloudflare/references/agents-sdk/configuration.md @@ -58,11 +58,11 @@ npx wrangler secret put OPENAI_API_KEY **Recommended: Use route helpers** ```typescript -import { routeAgent } from "agents"; +import { routeAgentRequest } from "agents"; export default { fetch(request: Request, env: Env) { - return routeAgent(request, env); + return routeAgentRequest(request, env); } } ``` @@ -91,7 +91,7 @@ export default { **Multi-agent setup:** ```typescript -import { routeAgent } from "agents"; +import { routeAgentRequest } from "agents"; export default { fetch(request: Request, env: Env) { @@ -99,10 +99,10 @@ export default { // Route by path if (url.pathname.startsWith("/chat")) { - return routeAgent(request, env, "ChatAgent"); + return routeAgentRequest(request, env, "ChatAgent"); } if (url.pathname.startsWith("/task")) { - return routeAgent(request, env, "TaskAgent"); + return routeAgentRequest(request, env, "TaskAgent"); } return new Response("Not found", { status: 404 }); @@ -118,7 +118,7 @@ export default { import { routeAgentEmail } from "agents"; export default { - fetch: (req: Request, env: Env) => routeAgent(req, env), + fetch: (req: Request, env: Env) => routeAgentRequest(req, env), email: (message: ForwardableEmailMessage, env: Env) => { return routeAgentEmail(message, env); } diff --git a/skills/cloudflare/references/cron-triggers/README.md b/skills/cloudflare/references/cron-triggers/README.md index 67c00f8..e0214ac 100644 --- a/skills/cloudflare/references/cron-triggers/README.md +++ b/skills/cloudflare/references/cron-triggers/README.md @@ -74,7 +74,7 @@ curl "http://localhost:8787/__scheduled?cron=*/5+*+*+*+*" ## Limits - **Free:** 3 triggers/worker, 10ms CPU -- **Paid:** Unlimited triggers, 50ms CPU +- **Paid:** Unlimited triggers, 30s CPU (<1hr interval) / 15min CPU (≥1hr interval) - **Propagation:** 15min global deployment - **Timezone:** UTC only diff --git a/skills/cloudflare/references/cron-triggers/gotchas.md b/skills/cloudflare/references/cron-triggers/gotchas.md index 5906c3a..973eb49 100644 --- a/skills/cloudflare/references/cron-triggers/gotchas.md +++ b/skills/cloudflare/references/cron-triggers/gotchas.md @@ -168,7 +168,7 @@ export default { | Limit | Free | Paid | Notes | |-------|------|------|-------| | Triggers per Worker | 3 | Unlimited | Maximum cron schedules per Worker | -| CPU time | 10ms | 50ms | May need `ctx.waitUntil()` or Workflows | +| CPU time | 10ms | 30s (<1hr interval), 15min (≥1hr interval) | May need `ctx.waitUntil()` or Workflows | | Execution guarantee | At-least-once | At-least-once | Duplicates possible - use idempotency | | Propagation delay | Up to 15 minutes | Up to 15 minutes | Time for changes to take effect globally | | Min interval | 1 minute | 1 minute | Cannot schedule more frequently | diff --git a/skills/cloudflare/references/d1/configuration.md b/skills/cloudflare/references/d1/configuration.md index 8a073fc..05d37d0 100644 --- a/skills/cloudflare/references/d1/configuration.md +++ b/skills/cloudflare/references/d1/configuration.md @@ -166,8 +166,11 @@ wrangler d1 execute --remote --file=./backup.sql ## Plan Tiers -| Feature | Free | Paid | -|---------|------|------| +| Feature | Free (Workers Free) | Paid (Workers Paid) | +|---------|---------------------|---------------------| +| Rows read | 5 million / day | First 25 billion / month included | +| Rows written | 100,000 / day | First 50 million / month included | +| Storage | 5 GB (total) | First 5 GB included | | Database size | 500 MB | 10 GB | | Batch size | 1,000 statements | 10,000 statements | | Time Travel | 7 days | 30 days | @@ -175,7 +178,7 @@ wrangler d1 execute --remote --file=./backup.sql | Sessions API | ❌ | ✅ (up to 15 min) | | Pricing | Free | $5/mo + usage | -**Usage pricing** (paid plans): $0.001 per 1K reads + $1 per 1M writes + $0.75/GB storage/month +**Usage pricing** (paid plans, beyond included allowances): $0.001 per million rows read + $1.00 per million rows written + $0.75/GB-mo storage ## Local Development diff --git a/skills/cloudflare/references/email-routing/gotchas.md b/skills/cloudflare/references/email-routing/gotchas.md index 20ea419..71dcbfc 100644 --- a/skills/cloudflare/references/email-routing/gotchas.md +++ b/skills/cloudflare/references/email-routing/gotchas.md @@ -108,7 +108,7 @@ const subj = message.headers.get("subject")?.toLowerCase() || ""; | Email size | 25 MB | 25 MB | | Rules | 200 | 200 | | Destinations | 200 | 200 | -| CPU time | 10ms | 50ms | +| CPU time | 10ms | 30s (default), 5min (max) | | SendEmail | ~100/min | Higher | ## Debugging diff --git a/skills/cloudflare/references/email-workers/README.md b/skills/cloudflare/references/email-workers/README.md index 5a3e304..8f44197 100644 --- a/skills/cloudflare/references/email-workers/README.md +++ b/skills/cloudflare/references/email-workers/README.md @@ -123,7 +123,7 @@ See [gotchas.md](./gotchas.md#readablestream-can-only-be-consumed-once) for deta | Max routing rules | 200 | | Max destinations | 200 | | CPU time (free tier) | 10ms | -| CPU time (paid tier) | 50ms | +| CPU time (paid tier) | 30s (default), 5min (max) | See [gotchas.md](./gotchas.md#limits-reference) for complete limits table. diff --git a/skills/cloudflare/references/email-workers/gotchas.md b/skills/cloudflare/references/email-workers/gotchas.md index 3700a50..6003038 100644 --- a/skills/cloudflare/references/email-workers/gotchas.md +++ b/skills/cloudflare/references/email-workers/gotchas.md @@ -112,7 +112,7 @@ Monitor: `npx wrangler tail` |-------|-------| | Max message size | 25 MiB | | Max rules/zone | 200 | -| CPU time (free/paid) | 10ms / 50ms | +| CPU time (free/paid) | 10ms / 30s default, 5min max | | Reply References | 100 | ## Common Errors diff --git a/skills/cloudflare/references/kv/gotchas.md b/skills/cloudflare/references/kv/gotchas.md index 5ad3213..92242da 100644 --- a/skills/cloudflare/references/kv/gotchas.md +++ b/skills/cloudflare/references/kv/gotchas.md @@ -125,7 +125,7 @@ const value = await env.KV.get("key") ?? "default-value"; | Propagation time | ≤60s | Global propagation time | | Bulk get max | 100 keys | Maximum keys per bulk operation | | Operations per Worker | 1,000 | Per request (bulk counts as 1) | -| Reads pricing | $0.50 per 10M | Per million reads | +| Reads pricing | $0.50 per 1M | Per million reads | | Writes pricing | $5.00 per 1M | Per million writes | | Deletes pricing | $5.00 per 1M | Per million deletes | | Storage pricing | $0.50 per GB-month | Per GB per month | diff --git a/skills/cloudflare/references/pages-functions/gotchas.md b/skills/cloudflare/references/pages-functions/gotchas.md index f63e608..72be4cf 100644 --- a/skills/cloudflare/references/pages-functions/gotchas.md +++ b/skills/cloudflare/references/pages-functions/gotchas.md @@ -61,7 +61,7 @@ npx wrangler pages deployment tail --status error | Resource | Free | Paid | |----------|------|------| -| CPU time | 10ms | 50ms | +| CPU time | 10ms | 30s (default), 5min (max) | | Memory | 128 MB | 128 MB | | Script size | 10 MB compressed | 10 MB compressed | | Env vars | 5 KB per var, 64 max | 5 KB per var, 64 max | diff --git a/skills/cloudflare/references/pages/configuration.md b/skills/cloudflare/references/pages/configuration.md index 6c317ec..eb4e28e 100644 --- a/skills/cloudflare/references/pages/configuration.md +++ b/skills/cloudflare/references/pages/configuration.md @@ -181,7 +181,7 @@ npx wrangler pages dev -- npm run dev | Resource | Free | Paid | |----------|------|------| | **Functions Requests** | 100k/day | Unlimited (metered) | -| **Function CPU Time** | 10ms/req | 30ms/req (Workers Paid) | +| **Function CPU Time** | 10ms/req | 30s default, 5min max (Workers Paid) | | **Function Memory** | 128MB | 128MB | | **Script Size** | 1MB compressed | 10MB compressed | | **Deployments** | 500/month | 5,000/month | diff --git a/skills/cloudflare/references/pages/gotchas.md b/skills/cloudflare/references/pages/gotchas.md index acb2873..769ff60 100644 --- a/skills/cloudflare/references/pages/gotchas.md +++ b/skills/cloudflare/references/pages/gotchas.md @@ -51,7 +51,7 @@ ## Performance Issues **Problem**: Slow responses or CPU limit errors -**Causes**: Functions invoked for static assets; cold starts; 10ms CPU limit; large bundle +**Causes**: Functions invoked for static assets; cold starts; 10ms CPU limit (free) / 30s default (paid); large bundle **Solution**: Exclude static via `_routes.json`; optimize hot paths; keep bundle < 1MB ## Framework-Specific @@ -185,7 +185,7 @@ console.log('Params:', params); | Resource | Free | Paid | |----------|------|------| | Functions Requests | 100k/day | Unlimited | -| CPU Time | 10ms/req | 30ms/req | +| CPU Time | 10ms/req | 30s default, 5min max | | Memory | 128MB | 128MB | | Script Size | 1MB | 10MB | | Subrequests | 50/req | 10,000/req | diff --git a/skills/cloudflare/references/pulumi/gotchas.md b/skills/cloudflare/references/pulumi/gotchas.md index f01592a..7a0570f 100644 --- a/skills/cloudflare/references/pulumi/gotchas.md +++ b/skills/cloudflare/references/pulumi/gotchas.md @@ -161,7 +161,7 @@ const deployment = new cloudflare.WorkersDeployment("prod", { | Resource | Limit | Notes | |----------|-------|-------| | Worker script size | 10 MB | Includes all dependencies, after compression | -| Worker CPU time | 50ms (free), 30s (paid) | Per request | +| Worker CPU time | 10ms (free), 30s default / 5min max (paid) | Per request | | KV keys per namespace | Unlimited | 1000 ops/sec write, 100k ops/sec read | | R2 storage | Unlimited | Class A ops: 1M/mo free, Class B: 10M/mo free | | D1 databases | 50,000 per account | Free: 10 per account, 5 GB each | diff --git a/skills/cloudflare/references/sandbox/README.md b/skills/cloudflare/references/sandbox/README.md index 8550be4..638f4e9 100644 --- a/skills/cloudflare/references/sandbox/README.md +++ b/skills/cloudflare/references/sandbox/README.md @@ -59,7 +59,7 @@ export default { **Dockerfile**: ```dockerfile -FROM docker.io/cloudflare/sandbox:latest +FROM docker.io/cloudflare/sandbox:0.7.0 RUN pip3 install --no-cache-dir pandas numpy matplotlib EXPOSE 8080 3000 # Required for wrangler dev ``` diff --git a/skills/cloudflare/references/sandbox/api.md b/skills/cloudflare/references/sandbox/api.md index 3eb2fa5..24eb56f 100644 --- a/skills/cloudflare/references/sandbox/api.md +++ b/skills/cloudflare/references/sandbox/api.md @@ -105,16 +105,16 @@ const ctx = await sandbox.createCodeContext({ }); // Execute code with rich outputs -const result = await ctx.runCode(` +const result = await sandbox.runCode(` import matplotlib.pyplot as plt plt.plot(data, [x**2 for x in data]) plt.savefig('plot.png') print(f"Processed {len(data)} points") -`); -// Returns: { outputs: [{ type: 'text'|'image'|'html', content }], error } +`, { context: ctx }); +// Returns: ExecutionResult { code, logs, results: RichOutput[], error, executionCount } // Context persists variables across runs -const result2 = await ctx.runCode('print(data[0])'); // Still has 'data' +const result2 = await sandbox.runCode('print(data[0])', { context: ctx }); // Still has 'data' ``` ## WebSocket Connections diff --git a/skills/cloudflare/references/sandbox/configuration.md b/skills/cloudflare/references/sandbox/configuration.md index 32a3bd9..e804667 100644 --- a/skills/cloudflare/references/sandbox/configuration.md +++ b/skills/cloudflare/references/sandbox/configuration.md @@ -32,14 +32,14 @@ wrangler.jsonc `instance_type`: **Basic**: ```dockerfile -FROM docker.io/cloudflare/sandbox:latest +FROM docker.io/cloudflare/sandbox:0.7.0 RUN pip3 install --no-cache-dir pandas numpy EXPOSE 8080 # Required for wrangler dev ``` **Scientific**: ```dockerfile -FROM docker.io/cloudflare/sandbox:latest +FROM docker.io/cloudflare/sandbox:0.7.0 RUN pip3 install --no-cache-dir \ jupyter-server ipykernel matplotlib \ pandas seaborn plotly scipy scikit-learn @@ -47,7 +47,7 @@ RUN pip3 install --no-cache-dir \ **Node.js**: ```dockerfile -FROM docker.io/cloudflare/sandbox:latest +FROM docker.io/cloudflare/sandbox:0.7.0 RUN npm install -g typescript ts-node ``` diff --git a/skills/cloudflare/references/sandbox/gotchas.md b/skills/cloudflare/references/sandbox/gotchas.md index 856c503..d092fa4 100644 --- a/skills/cloudflare/references/sandbox/gotchas.md +++ b/skills/cloudflare/references/sandbox/gotchas.md @@ -173,7 +173,7 @@ Token changes on each expose operation, preventing unauthorized access. |-----------|----------------|----------| | Container provisioning | 30s | `SANDBOX_INSTANCE_TIMEOUT_MS` | | Port readiness | 90s | `SANDBOX_PORT_TIMEOUT_MS` | -| exec() | 120s | `timeout` option | +| exec() | None (no default) | `timeout` option | | sleepAfter | 10m | `sleepAfter` option | **Performance**: diff --git a/skills/cloudflare/references/sandbox/patterns.md b/skills/cloudflare/references/sandbox/patterns.md index adeb0a0..799e578 100644 --- a/skills/cloudflare/references/sandbox/patterns.md +++ b/skills/cloudflare/references/sandbox/patterns.md @@ -15,10 +15,10 @@ export default { }); // Execute with rich outputs (text, images, HTML) - const result = await ctx.runCode(code); + const result = await sandbox.runCode(code, { context: ctx }); return Response.json({ - outputs: result.outputs, // [{ type: 'text'|'image'|'html', content }] + results: result.results, // RichOutput[] (text, html, png, json, etc.) error: result.error, success: !result.error }); @@ -76,7 +76,7 @@ export default { **Dockerfile**: ```dockerfile -FROM docker.io/cloudflare/sandbox:latest +FROM docker.io/cloudflare/sandbox:0.7.0 RUN npm install -g ws EXPOSE 8080 ``` diff --git a/skills/cloudflare/references/tail-workers/configuration.md b/skills/cloudflare/references/tail-workers/configuration.md index 96fb33f..9f60579 100644 --- a/skills/cloudflare/references/tail-workers/configuration.md +++ b/skills/cloudflare/references/tail-workers/configuration.md @@ -149,7 +149,7 @@ wrangler tail my-producer-worker |-------|-------|-------| | Max tail consumers per producer | 10 | Each receives all events independently | | Events batch size | Up to 100 events per invocation | Larger batches split across invocations | -| Tail Worker CPU time | Same as regular Workers | 10ms (free), 30ms (paid), 50ms (paid bundle) | +| Tail Worker CPU time | Same as regular Workers | 10ms (free), 30s default / 5min max (paid) | | Pricing tier | Workers Paid or Enterprise | Not available on free plan | | Request body size | 100 MB max | When sending to external endpoints | | Event retention | None | Events not retried if tail handler fails | diff --git a/skills/cloudflare/references/vectorize/api.md b/skills/cloudflare/references/vectorize/api.md index e29d87f..778a8d1 100644 --- a/skills/cloudflare/references/vectorize/api.md +++ b/skills/cloudflare/references/vectorize/api.md @@ -41,7 +41,7 @@ await env.VECTORIZE.insert([{ id, values, metadata }]); await env.VECTORIZE.upsert([{ id, values, metadata }]); ``` -**Max 500 vectors per call.** Queryable after 5-10 seconds. +**Max 1,000 vectors per call (Workers) / 5,000 (HTTP API).** Queryable after 5-10 seconds. ## Other Operations @@ -79,10 +79,10 @@ Requires metadata index. Filter operators: | `returnMetadata: "all"` | 20 | Slower | | `returnValues: true` | 20 | Slower | -**Batch operations:** Always batch (500/call) for optimal throughput. +**Batch operations:** Always batch (1,000/call via Workers, 5,000 via HTTP API) for optimal throughput. ```typescript -for (let i = 0; i < vectors.length; i += 500) { - await env.VECTORIZE.upsert(vectors.slice(i, i + 500)); +for (let i = 0; i < vectors.length; i += 1000) { + await env.VECTORIZE.upsert(vectors.slice(i, i + 1000)); } ``` diff --git a/skills/cloudflare/references/vectorize/gotchas.md b/skills/cloudflare/references/vectorize/gotchas.md index 9282771..a8e1544 100644 --- a/skills/cloudflare/references/vectorize/gotchas.md +++ b/skills/cloudflare/references/vectorize/gotchas.md @@ -6,12 +6,12 @@ Insert/upsert/delete return immediately but vectors aren't queryable for 5-10 seconds. ### Batch Size Limit -**Workers API: 500 vectors max per call** (undocumented, silently truncates) +**Workers API: 1,000 vectors max per call (HTTP API: 5,000).** Silently truncates if exceeded. ```typescript -// ✅ Chunk into 500 -for (let i = 0; i < vectors.length; i += 500) { - await env.VECTORIZE.upsert(vectors.slice(i, i + 500)); +// ✅ Chunk into 1000 (Workers API limit; HTTP API allows 5000) +for (let i = 0; i < vectors.length; i += 1000) { + await env.VECTORIZE.upsert(vectors.slice(i, i + 1000)); } ``` @@ -44,7 +44,7 @@ Cannot change dimensions/metric after creation. Must create new index and migrat |----------|-------| | Vectors per index | 10,000,000 | | Max dimensions | 1536 | -| Batch upsert (Workers) | **500** | +| Batch upsert (Workers / HTTP API) | **1,000 / 5,000** | | Indexed string metadata | **64 bytes** | | Metadata indexes | 10 | | Namespaces | 50,000 (paid) / 1,000 (free) | diff --git a/skills/cloudflare/references/workers-playground/README.md b/skills/cloudflare/references/workers-playground/README.md index 6dee4f9..56cb708 100644 --- a/skills/cloudflare/references/workers-playground/README.md +++ b/skills/cloudflare/references/workers-playground/README.md @@ -115,7 +115,7 @@ export default { | Bindings | None | KV, D1, R2, DO, AI, etc. | | Environment vars | None | Full support | | Module format | ES only | ES + Service Worker | -| CPU time | 10ms (Free plan) | 10ms Free / 50ms Paid | +| CPU time | 10ms (Free plan) | 10ms Free / 30s default, 5min max Paid | | Custom domains | No | Yes | | Analytics | No | Yes | diff --git a/skills/cloudflare/references/workers-playground/api.md b/skills/cloudflare/references/workers-playground/api.md index 1382ab4..0d7dd14 100644 --- a/skills/cloudflare/references/workers-playground/api.md +++ b/skills/cloudflare/references/workers-playground/api.md @@ -96,6 +96,6 @@ const hash = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(data | Resource | Limit | |----------|-------| -| CPU time | 10ms | +| CPU time | 10ms (Free plan; Paid: 30s default, 5min max) | | Subrequests | 50 | | Memory | 128 MB | diff --git a/skills/cloudflare/references/workers-playground/configuration.md b/skills/cloudflare/references/workers-playground/configuration.md index 7d747ac..427d53e 100644 --- a/skills/cloudflare/references/workers-playground/configuration.md +++ b/skills/cloudflare/references/workers-playground/configuration.md @@ -160,4 +160,4 @@ Same as production Free plan: | Request size | 100 MB | Incoming | | Response size | Unlimited | Outgoing (streamed) | -**Exceeding CPU time** throws error immediately. Optimize hot paths or upgrade to Paid plan (50ms CPU). +**Exceeding CPU time** throws error immediately. Optimize hot paths or upgrade to Paid plan (30s default, 5min max CPU). diff --git a/skills/cloudflare/references/workers-playground/gotchas.md b/skills/cloudflare/references/workers-playground/gotchas.md index d00a92e..9f5cb93 100644 --- a/skills/cloudflare/references/workers-playground/gotchas.md +++ b/skills/cloudflare/references/workers-playground/gotchas.md @@ -26,7 +26,7 @@ await fetch(url, { body: clone.body }); ### "Worker exceeded CPU time" -**Limit:** 10ms (free), 50ms (paid) +**Limit:** 10ms (free), 30s default / 5min max (paid) ```javascript // ✅ Move slow work to background @@ -66,7 +66,7 @@ try { ... } catch (e) { | Resource | Free | Paid | |----------|------|------| -| CPU time | 10ms | 50ms | +| CPU time | 10ms | 30s (default), 5min (max) | | Memory | 128 MB | 128 MB | | Subrequests | 50 | 10,000 | diff --git a/skills/cloudflare/references/workers/configuration.md b/skills/cloudflare/references/workers/configuration.md index 9eae70b..47c0cd2 100644 --- a/skills/cloudflare/references/workers/configuration.md +++ b/skills/cloudflare/references/workers/configuration.md @@ -154,7 +154,7 @@ interface Env { "placement": { "mode": "smart" }, // Enable Node.js built-ins (Buffer, process, path, etc.) - "compatibility_flags": ["nodejs_compat_v2"], + "compatibility_flags": ["nodejs_compat"], // Observability (10% sampling) "observability": { "enabled": true, "head_sampling_rate": 0.1 } @@ -163,7 +163,7 @@ interface Env { ### Node.js Compatibility -`nodejs_compat_v2` enables: +`nodejs_compat` enables: - `Buffer`, `process.env`, `path`, `stream` - CommonJS `require()` for Node modules - `node:` imports (e.g., `import { Buffer } from 'node:buffer'`) diff --git a/skills/cloudflare/references/workers/gotchas.md b/skills/cloudflare/references/workers/gotchas.md index eda1d4b..3c12907 100644 --- a/skills/cloudflare/references/workers/gotchas.md +++ b/skills/cloudflare/references/workers/gotchas.md @@ -20,7 +20,7 @@ ### "Node.js module not found" **Cause:** Node.js built-ins not available by default -**Solution:** Use Workers APIs (e.g., R2 for file storage) or enable Node.js compat with `"compatibility_flags": ["nodejs_compat_v2"]` +**Solution:** Use Workers APIs (e.g., R2 for file storage) or enable Node.js compat with `"compatibility_flags": ["nodejs_compat"]` ### "Cannot fetch in global scope" @@ -125,7 +125,7 @@ See [frameworks.md](./frameworks.md) for full patterns | CPU time (Paid) | 30s default / 5min max | Configurable via `limits.cpu_ms` | | Subrequests (Free) | 50 | Per invocation | | Subrequests (Paid) | 10,000 | Per invocation | -| KV reads | 1000 | Per request | +| Subrequest operations (KV, R2, Cache API) | 1,000 | Shared across KV reads, R2 ops, Cache API calls per request | | KV value size | 25 MiB | Maximum per key | | Environment variable size | 5 KB | Per variable | diff --git a/skills/cloudflare/references/wrangler/README.md b/skills/cloudflare/references/wrangler/README.md index dc32292..564a3ac 100644 --- a/skills/cloudflare/references/wrangler/README.md +++ b/skills/cloudflare/references/wrangler/README.md @@ -90,8 +90,8 @@ wrangler secret delete NAME # Delete Worker secret wrangler secret bulk FILE.json # Bulk upload from JSON # Secrets Store (centralized, reusable across Workers) -wrangler secret-store:secret put STORE_NAME SECRET_NAME -wrangler secret-store:secret list STORE_NAME +wrangler secrets-store secret create --name SECRET_NAME --scopes workers --remote +wrangler secrets-store secret list --remote ``` ### Monitoring diff --git a/skills/cloudflare/references/wrangler/configuration.md b/skills/cloudflare/references/wrangler/configuration.md index 20dc2f0..4ddcd93 100644 --- a/skills/cloudflare/references/wrangler/configuration.md +++ b/skills/cloudflare/references/wrangler/configuration.md @@ -4,7 +4,7 @@ Configuration reference for wrangler.jsonc (recommended). ## Config Format -**wrangler.jsonc recommended** (v3.91.0+) - provides schema validation. +**wrangler.jsonc recommended** (Wrangler v4+) - provides schema validation. ```jsonc { @@ -90,9 +90,9 @@ Deploy: `wrangler deploy --env production` // Vectorize { "vectorize": [{ "binding": "VECTORS", "index_name": "embeddings" }] } -// Hyperdrive (requires nodejs_compat_v2 for pg/postgres) +// Hyperdrive (requires nodejs_compat for pg/postgres) { "hyperdrive": [{ "binding": "HYPERDRIVE", "id": "hyper-id" }] } -{ "compatibility_flags": ["nodejs_compat_v2"] } // For pg/postgres +{ "compatibility_flags": ["nodejs_compat"] } // For pg/postgres // Workers AI { "ai": { "binding": "AI" } } diff --git a/skills/cloudflare/references/wrangler/gotchas.md b/skills/cloudflare/references/wrangler/gotchas.md index 1d621ce..6e1a355 100644 --- a/skills/cloudflare/references/wrangler/gotchas.md +++ b/skills/cloudflare/references/wrangler/gotchas.md @@ -70,7 +70,7 @@ For local DOs in same Worker, `script_name` is optional. **Cause:** Missing Node.js compatibility flag **Solution:** Some bindings (Hyperdrive with `pg`) require: ```jsonc -{ "compatibility_flags": ["nodejs_compat_v2"] } +{ "compatibility_flags": ["nodejs_compat"] } ``` ### "Workers Assets 404 errors" @@ -131,7 +131,7 @@ const worker = await startWorker({ | Workers Assets size | 25 MB | Per deployment | | Workers Assets files | 20,000 | Max number of files | | Script size (compressed) | 1 MB | Free, 10 MB paid | -| CPU time | 10-50ms | Free, 50-500ms paid | +| CPU time | 10ms | Free, 30s default (5min max) paid | | Subrequest limit | 50 | Free, 10,000 paid | ## Troubleshooting @@ -145,7 +145,7 @@ wrangler whoami ### Configuration Errors ```bash -wrangler check # Validate config +wrangler check startup # Profile Worker startup time and detect scripts exceeding the startup time limit ``` Use wrangler.jsonc with `$schema` for validation. diff --git a/skills/sandbox-sdk/references/api-quick-ref.md b/skills/sandbox-sdk/references/api-quick-ref.md index 1b4b386..34cf760 100644 --- a/skills/sandbox-sdk/references/api-quick-ref.md +++ b/skills/sandbox-sdk/references/api-quick-ref.md @@ -24,7 +24,7 @@ await sandbox.exec(command: string, options?: ExecOptions): Promise interface ExecOptions { cwd?: string; // Working directory env?: Record; // Environment variables - timeout?: number; // Timeout in ms (default: 60000) + timeout?: number; // Timeout in ms (no default; runs without timeout if unset) stdin?: string; // Input to command } diff --git a/skills/web-perf/SKILL.md b/skills/web-perf/SKILL.md index 9bc2e1d..0fb166e 100644 --- a/skills/web-perf/SKILL.md +++ b/skills/web-perf/SKILL.md @@ -1,6 +1,6 @@ --- name: web-perf -description: Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (FCP, LCP, TBT, CLS, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge. +description: Analyzes web performance using Chrome DevTools MCP. Measures Core Web Vitals (LCP, INP, CLS) and supplementary metrics (FCP, TBT, Speed Index), identifies render-blocking resources, network dependency chains, layout shifts, caching issues, and accessibility gaps. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed. Biases towards retrieval from current documentation over pre-trained knowledge. --- # Web Performance Audit diff --git a/skills/wrangler/SKILL.md b/skills/wrangler/SKILL.md index 296fa21..506bfb4 100644 --- a/skills/wrangler/SKILL.md +++ b/skills/wrangler/SKILL.md @@ -34,7 +34,7 @@ npm install -D wrangler@latest - **Set `compatibility_date`**: Use a recent date (within 30 days). Check https://developers.cloudflare.com/workers/configuration/compatibility-dates/ - **Generate types after config changes**: Run `wrangler types` to update TypeScript bindings. - **Local dev defaults to local storage**: Bindings use local simulation unless `remote: true`. -- **Validate config before deploy**: Run `wrangler check` to catch errors early. +- **Profile Worker startup**: Run `wrangler check startup` to measure startup time and detect scripts that exceed the startup time limit. - **Use environments for staging/prod**: Define `env.staging` and `env.production` in config. ## Quick Start: New Worker @@ -55,7 +55,7 @@ npx create-cloudflare@latest my-app | Deploy to Cloudflare | `wrangler deploy` | | Deploy dry run | `wrangler deploy --dry-run` | | Generate TypeScript types | `wrangler types` | -| Validate configuration | `wrangler check` | +| Profile Worker startup time | `wrangler check startup` | | View live logs | `wrangler tail` | | Delete Worker | `wrangler delete` | | Auth status | `wrangler whoami` | @@ -83,7 +83,7 @@ npx create-cloudflare@latest my-app "name": "my-worker", "main": "src/index.ts", "compatibility_date": "2026-01-01", - "compatibility_flags": ["nodejs_compat_v2"], + "compatibility_flags": ["nodejs_compat"], // Environment variables "vars": { @@ -511,7 +511,7 @@ wrangler hyperdrive delete ```jsonc { - "compatibility_flags": ["nodejs_compat_v2"], + "compatibility_flags": ["nodejs_compat"], "hyperdrive": [ { "binding": "HYPERDRIVE", "id": "" } ] @@ -865,7 +865,7 @@ curl http://localhost:8787/__scheduled |-------|----------| | `command not found: wrangler` | Install: `npm install -D wrangler` | | Auth errors | Run `wrangler login` | -| Config validation errors | Run `wrangler check` | +| Startup time limit exceeded | Run `wrangler check startup` to profile startup and generate CPU profiles | | Type errors after config change | Run `wrangler types` | | Local storage not persisting | Check `.wrangler/state` directory | | Binding undefined in Worker | Verify binding name matches config exactly | @@ -876,8 +876,8 @@ curl http://localhost:8787/__scheduled # Check auth status wrangler whoami -# Validate config -wrangler check +# Profile Worker startup time +wrangler check startup # View config schema wrangler docs configuration