-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathwrangler.example.jsonc
More file actions
151 lines (151 loc) · 5.99 KB
/
Copy pathwrangler.example.jsonc
File metadata and controls
151 lines (151 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copy this file to wrangler.jsonc and fill in the <YOUR_*> placeholders.
// wrangler.jsonc is gitignored so that each contributor's own Cloudflare
// account id, D1 database id, and Worker name stay local. Every concrete
// value here is load-bearing — `scripts/require-wrangler-config.ts`
// gates dev and deploy on real wrangler.jsonc mirroring this example
// exactly in both directions, except that <YOUR_*> placeholders may
// (and must) be replaced with your own values, and `account_id` may
// additionally appear only in wrangler.jsonc since it is
// per-contributor. Anything else the real config needs (extra bindings,
// extra compat flags, `vars` blocks) belongs in this example first so
// every contributor and the deploy gate agree on the Worker's shape.
//
// 1. Optionally set CLOUDFLARE_ACCOUNT_ID in the environment, or run
// `pnpm wrangler login`. If neither is in place, add an `account_id`
// field to wrangler.jsonc — it is the one personal-only key the
// check gate accepts in the real config without a matching example
// entry.
// 2. Pick a unique `name` for your Worker; it becomes the deployed
// workers.dev subdomain.
// 3. Run `pnpm wrangler d1 create <database_name>` and paste the returned
// `database_id` below; `database_name` is the same value you passed.
// 4. Run `pnpm wrangler r2 bucket create <bucket_name>` for the FILES
// bucket. It stores file-backed request/response dump bodies and oversized
// Stateful OpenAI Responses item payloads. Put its name in `bucket_name` below.
// 5. Run `pnpm wrangler kv namespace create <name>` and paste the returned
// id into `kv_namespaces[0].id`.
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "<YOUR_WORKER_NAME>",
"main": "apps/platform-cloudflare/entry.ts",
"compatibility_date": "2025-01-01",
// `@reclaimprotocol/tls/webcrypto` (used by packages/http and the proxy
// REALITY dialer) still imports `webcrypto` from `crypto`, so the Worker
// cannot resolve those modules at cold start without the Node compat flag.
// `ctx.exports` needs an explicit flag at this compatibility date:
// https://developers.cloudflare.com/workers/configuration/compatibility-flags/#enable-ctxexports
"compatibility_flags": ["nodejs_compat", "enable_ctx_exports"],
"triggers": {
// Minute scheduling provides catch-up throughput while bounded deletion
// and collection batches keep each tick's D1 write load predictable.
"crons": ["* * * * *"]
},
"assets": {
"directory": "apps/web/dist/client",
"html_handling": "auto-trailing-slash",
"not_found_handling": "single-page-application",
// The path set that diverts to the Worker (rather than being served by
// Workers Static Assets as a SPA fallback) restates, for production on
// Cloudflare, the set two other files restate for their topologies:
//
// - `isGatewayPath` in apps/platform-node/src/static-web.ts (the Node
// self-host topology).
// - `wranglerProxiedPaths` in apps/web/gateway-paths.ts (the `vite dev`
// proxy-to-wrangler-dev topology).
//
// All three describe the same concept: every path the gateway owns; the
// rest is the SPA. Bare data-plane paths are listed when the gateway also
// accepts a root form. Drift is silent and surfaces only as a 404 the SPA
// fallback served for a real gateway endpoint, so
// apps/web/__tests__/gateway-paths_test.ts replays the public data-plane
// route table through all three.
"run_worker_first": [
"/api/*",
"/auth",
"/auth/*",
"/favicon.ico",
"/v1/*",
"/v2/*",
"/v1beta/*",
"/jina/*",
"/voyage/*",
"/alpha/search",
"/completions",
"/chat/*",
"/responses",
"/responses/*",
"/messages",
"/messages/*",
"/embeddings",
"/images/*",
"/models",
"/azure-api.codex/*"
]
},
"d1_databases": [
{
"binding": "DB",
"database_name": "<YOUR_D1_DATABASE_NAME>",
"database_id": "<YOUR_D1_DATABASE_ID>",
"migrations_dir": "packages/gateway/migrations"
}
],
"r2_buckets": [
{
"binding": "FILES",
"bucket_name": "<YOUR_R2_BUCKET_NAME>"
}
],
// Cloudflare Images binding. Inline base64 images on the Copilot egress are
// recompressed to WebP through this binding before the upstream call. No
// account-specific id is required; the binding name is all the Worker needs.
"images": {
"binding": "IMAGES"
},
// KV namespace backing the platform `ImageCacheStore` abstraction (cache for
// compressed WebP results — the Images binding bills every transformation
// and does not deduplicate, so this turns a repeated inline image into a
// single KV read).
"kv_namespaces": [
{
"binding": "KV",
"id": "<YOUR_KV_NAMESPACE_ID>"
}
],
// Per-use execution cells. The initial broadcast protocol provides
// hibernatable WebSocket fan-out; model refresh operations share this
// actor host without placing provider data in Durable Object storage.
"durable_objects": {
"bindings": [
{
"name": "EXECUTION_DO",
"class_name": "ExecutionDO"
}
]
},
// CF requires every DO class to declare a storage backend at create time,
// even when the actor body never calls `ctx.storage.*`. `new_sqlite_classes`
// picks the SQLite backend (CF's recommendation for all new classes, the
// only backend Workers Free supports, and ~12 KB per empty instance). The
// alternative `new_classes` picks the legacy KV-backed storage path which
// CF is phasing out and which Workers Free cannot create.
//
// ExecutionDO has no `ctx.storage.*` calls — the SQLite db is provisioned
// but unused. The name reflects the BACKEND choice, not whether the actor
// touches it.
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["BroadcastDO"]
},
{
"tag": "v2",
"renamed_classes": [
{
"from": "BroadcastDO",
"to": "ExecutionDO"
}
]
}
]
}