iterate.com / cloud

git clone https://git.iterate.com/repos/cloud

cloud / internal-packages / installer / wrangler.jsoncmain at aacbc74

// THE CLOUD WORKER'S ONE CONFIG: every address, account id, client id and secret's name, for each
// environment. The top level is `dev` (the dev and preview account, a workers.dev address).
// `env.prd` is production (cloud.iterate.com). `pnpm run deploy` deploys dev and
// `pnpm run deploy:prd` production; the environment is chosen at the build (CLOUDFLARE_ENV).
//
// Secrets, the same names in both (`wrangler secret put <NAME> [--env prd]`):
//   CLIENT_SECRET         the Cloudflare OAuth client's
//   CLOUD_KEY             the Cloud's P-256 private key, a JWK
//   OPERATOR_TOKEN        the operator's way in to /access, until a sign-in replaces it
//   CLOUD_CLIENTS         JSON: iterate's clients at GitHub, Google and X (internal-packages/cloud-clients)
//   CLOUD_CLIENT_SECRETS  JSON: those clients' secrets
//   SERVICE_TOKEN         optional: the bearer of the Cloud's app in the iterate mind (worker/service.js).
//                         Without it /service/* answers 404. Its mind is the var SERVICE_MIND.
// The entrypoint `Service` (worker/main.js) is the same operations for a mind's `itx.services`:
// a stack binds it as `{ name: "cloud", worker: "iterate-cloud-prd", entrypoint: "Service" }`.
// It needs enhanced_error_serialization, which the compatibility date below includes, so that a
// refusal's `code` crosses Workers RPC.
// One optional var, when the app is submitted to ChatGPT: OPENAI_APPS_CHALLENGE, the text OpenAI
// asks for at /.well-known/openai-apps-challenge.
{
  "name": "iterate-cloud",
  "main": "worker/main.js",
  "account_id": "376ef7ed81b0573f93524de763666c15",
  "compatibility_date": "2026-11-04",
  // nodejs_compat: Files (@cloudflare/sandbox) resolves Linux errno names through node:os.
  // global_fetch_strictly_public: a deployment in this same account is reached by its public route.
  // webcrypto_modern_algorithms: a deployment's statement is signed with ML-DSA-65, its stack's
  // key (internal-packages/cloud-clients signed.ts).
  "compatibility_flags": [
    "nodejs_compat",
    "global_fetch_strictly_public",
    "webcrypto_modern_algorithms",
  ],
  "workers_dev": true,
  "preview_urls": false,
  "observability": { "enabled": true, "head_sampling_rate": 1 },
  "assets": {
    "not_found_handling": "single-page-application",
    "run_worker_first": [
      "/api/*",
      "/connect",
      "/callback",
      "/logout",
      "/enrol",
      "/enrolled",
      "/kept",
      "/access",
      "/access/*",
      "/service/*",
      // a chat installation's pages (worker/installation-pages.js)
      "/i/*",
      "/clients/*",
      "/.well-known/iterate-cloud",
      // Cap'n Web + OpenAI Responses WebSocket + Voice/Transcription lending (internal-packages/cloud-ai)
      "/ai-ws/*",
      "/openai-voice/*",
      "/capnweb",
      "/capnweb/*",
      // the relay (worker/mcp-relay.js)
      "/mcp",
      "/mcp/*",
      "/oauth2/*",
      "/.well-known/oauth-authorization-server",
      "/.well-known/oauth-protected-resource/*",
      "/.well-known/openai-apps-challenge",
    ],
  },
  "kv_namespaces": [
    { "binding": "SESSIONS", "id": "0390688679854d36bb0ea08716ad0e57" },
    // The relay's rows ("iterate-cloud-relay"). Anybody may register an app at the relay, so its
    // rows are kept apart from the installer's sign-ins. Production has no relay and no such binding.
    { "binding": "RELAY", "id": "68d885c0a77a483ebc699f858960c891" },
  ],
  "vars": {
    // the Cloudflare OAuth client "Iterate Cloud" (public, verified for iterate.com; os.iterate.com
    // uses it too). The wizard never asks for offline_access, so it gets no refresh token.
    "CLIENT_ID": "f76aab325529df0e334a3c4b6820e963",
    // the MCP relay (worker/mcp-relay.js), a prototype: on in dev alone. Production does not set
    // it, so cloud.iterate.com does not answer at /mcp or /oauth2/* until somebody adds it there.
    "MCP_RELAY": "on",
    // the PostHog project "iterate (prd)" (envs.ts ITERATE_POSTHOG_PROJECT_KEY), public by design:
    // the pages report anonymous page views and wizard steps (src/analytics.ts). Dev and production
    // share the project; an event's `$host` says which sent it.
    "POSTHOG_KEY": "phc_2MGb9SEJABGj4sCx4grFIbzMR7NjbcUgP5YmhSXfcr7",
    // the age limit of a GitHub claim (internal-packages/cloud-clients README "What is kept"): on
    // in dev alone. A mind refreshes each person's grant once a day, so a claim that is 14 days
    // old belongs to a deployment that stopped. Production does not set it yet.
    "GITHUB_CLAIM_DAYS": "14",
    // the mind whose app may ask for installs (worker/service.js): the `Service` entrypoint
    // refuses a call of any other mind, and the bearer routes' installations are this mind's
    "SERVICE_MIND": "iterate.com",
    // this Worker's public origin, for the links a `Service` call makes
    "CLOUD_ORIGIN": "https://iterate-cloud.iterate-dev-preview.workers.dev",
    // AI Gateway lending on dev: verified against the dev Cloud mind (`iterate-iterate-preview-1-com-auth`)
    "CLOUD_AI_GATEWAY": "iterate-cloud",
    "CLOUDFLARE_ACCOUNT_ID": "376ef7ed81b0573f93524de763666c15",
    "MIND_HOSTNAME": "iterate.iterate-preview-1.com",
    "MIND_ID": "0832b10a5d7fc6b5bd72d78951f8a7b24bdbeca45fded773dd9a063b697c5660",
    "CLOUD_ENROLMENT": "on",
  },
  "ai": { "binding": "AI" },
  "services": [
    {
      "binding": "ENROLMENTS",
      "service": "iterate-iterate-preview-1-com-auth",
      "entrypoint": "Enrolments",
    },
  ],
  "durable_objects": {
    "bindings": [
      { "name": "DEPLOYER", "class_name": "Deployer" },
      { "name": "ROUTES", "class_name": "Routes" },
      { "name": "OUTBOX", "class_name": "Outbox" },
      { "name": "BOT", "class_name": "Bot" },
      { "name": "USAGE_LEDGER", "class_name": "CloudUsageLedger" },
    ],
  },
  "migrations": [
    { "tag": "v1", "new_sqlite_classes": ["Deployer", "Routes", "Outbox", "Bot"] },
    { "tag": "v2", "new_sqlite_classes": ["CloudUsageLedger"] },
  ],
  "containers": [
    {
      "class_name": "Deployer",
      "image": "./container/Dockerfile",
      "instance_type": "standard-4",
      "max_instances": 10,
      // in one step: a run that starts after a deploy must get the new image
      "rollout_step_percentage": 100,
    },
  ],
  "env": {
    // Wrangler names this Worker `iterate-cloud-prd`. Bindings and vars are not inherited.
    "prd": {
      "account_id": "04b3b57291ef2626c6a8daa9d47065a7",
      "workers_dev": false,
      // ONLY THE CLOUD'S SERVICE PATHS. Every other path of cloud.iterate.com falls to the iterate.com
      // mind's `*.iterate.com/*`, whose app is the Cloud's pages: the wizard (`/`, `/deployments`,
      // `/erase`, `/connect`, `/logout`, the rest of `/api/*`) is not served here. A named route is
      // more specific than the wildcard. A route matches the whole URL WITH its query, so every
      // pattern ends in `*`: `/callback` alone would miss `/callback?code=…&state=…`.
      // test/routes.mjs checks that the list covers the dispatch of worker/main.js.
      "routes": [
        // iterate's clients (cloud-clients `handles`): the mind's auth and secrets Workers read
        // the facts and take tokens; providers send redirects, webhooks and Gmail push here
        { "pattern": "cloud.iterate.com/.well-known/iterate-cloud*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/clients/*", "zone_name": "iterate.com" },
        // Cap'n Web + WebSocket AI Gateway + OpenAI voice/transcription lending (cloud-ai `handles`)
        { "pattern": "cloud.iterate.com/api/cloud-ai*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/ai-ws/*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/openai-voice/*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/capnweb*", "zone_name": "iterate.com" },
        // the bearer routes of the Cloud's app in the iterate mind (service.js)
        { "pattern": "cloud.iterate.com/service/*", "zone_name": "iterate.com" },
        // a deployment's enrolment (`/enrol?domain=…`, `/enrolled?domain=…`), the records page and
        // the operator's pages (access.js)
        { "pattern": "cloud.iterate.com/enrol*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/kept*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/access*", "zone_name": "iterate.com" },
        // a chat installation's pages, the buttons the mind's app hands out (service.js `link`),
        // and the return of their Cloudflare consent (the OAuth client's redirect URI)
        { "pattern": "cloud.iterate.com/i/*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/callback*", "zone_name": "iterate.com" },
        // the SPA's config, its built files and its icon (also the icon of the Cloud's apps,
        // core/configs/default/cloud-accounts.ts). NOT /connected*: the page that `iterate chatgpt
        // connect` opens at its end (core/lib/src/cli/chatgpt.ts `connectedUrl`) is the mind's app
        // since 16 Nov (it opens the AI step on `test=passed`); its route was deleted by API then
        { "pattern": "cloud.iterate.com/api/config*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/assets/*", "zone_name": "iterate.com" },
        { "pattern": "cloud.iterate.com/iterate-logo.svg*", "zone_name": "iterate.com" },
        // NOT /mcp*, /oauth2/* or /.well-known/oauth-*: the relay is off in production, and the
        // mind's app answers /mcp
      ],
      "kv_namespaces": [{ "binding": "SESSIONS", "id": "6d7b857714924660837e2491554813ec" }],
      "vars": {
        "CLIENT_ID": "f76aab325529df0e334a3c4b6820e963",
        "POSTHOG_KEY": "phc_2MGb9SEJABGj4sCx4grFIbzMR7NjbcUgP5YmhSXfcr7",
        // public X post subscriptions (internal-packages/cloud-clients README): two watched
        // accounts, asked for by the iterate mind alone, named by its control plane's hostname. X
        // bills each delivered post to the bot's app, so a deployment is added here by hand.
        "X_POST_SUBSCRIPTIONS": "{\"limit\":2,\"minds\":[\"iterate.iterate.com\"]}",
        "SERVICE_MIND": "iterate.com",
        "CLOUD_ORIGIN": "https://cloud.iterate.com",
        // the Cloud's own mind (cloud-clients README "The Cloud signs as its own mind"), by its
        // name, its control plane's hostname: a delivery reaches a deployment as an event of this
        // mind, signed by MIND_AUTH
        "MIND_HOSTNAME": "iterate.iterate.com",
        // its id, the hash of its genesis (core/configs/default cloud-deliveries.ts `ITERATE_MIND`):
        // only that mind reads every deployment's status (cloud-clients `status`)
        "MIND_ID": "7780b12cd895879475d1b5d01974de09b23b6b9a15d518b534bd7f314b11ac95",
        "CLOUD_AI_GATEWAY": "iterate-cloud",
        "CLOUDFLARE_ACCOUNT_ID": "04b3b57291ef2626c6a8daa9d47065a7",
        // THE HOUSE ACCOUNTS of the AI lending (cloud-ai auth.ts): iterate's own minds, each by its
        // id and its control plane's hostname. A house account needs no enrolment row and has no
        // spend limit of the Cloud's own. One entry today: the iterate mind (`MIND_ID` above),
        // which cannot enrol because a mind does not meld with itself. Add a mind only on a
        // member's word: the entry lets it spend on iterate's account.
        "CLOUD_AI_HOUSE_ACCOUNTS": "{\"7780b12cd895879475d1b5d01974de09b23b6b9a15d518b534bd7f314b11ac95\":{\"hostname\":\"iterate.iterate.com\"}}",
      },
      "ai": { "binding": "AI" },
      // the auth Worker of the iterate mind's stack, in this same account: its `Deliveries`
      // entrypoint signs a delivery as that mind, on /minds/iterate.iterate.com/integrations/… and
      // no other path (core/auth-worker rpc.ts). Dev has none,
      // and there the Cloud signs with its own key alone.
      "services": [
        { "binding": "MIND_AUTH", "service": "iterate-iterate-auth", "entrypoint": "Deliveries" },
        // whether a member of iterate enrolled a mind (cloud-clients `shutOut`). CLOUD_ENROLMENT is
        // not set, so the gate logs `cloud.not-enrolled` and serves: "on" is Jonas's word
        { "binding": "ENROLMENTS", "service": "iterate-iterate-auth", "entrypoint": "Enrolments" },
      ],
      "durable_objects": {
        "bindings": [
          { "name": "DEPLOYER", "class_name": "Deployer" },
          { "name": "ROUTES", "class_name": "Routes" },
          { "name": "OUTBOX", "class_name": "Outbox" },
          { "name": "BOT", "class_name": "Bot" },
          { "name": "USAGE_LEDGER", "class_name": "CloudUsageLedger" },
        ],
      },
      "migrations": [
        { "tag": "v1", "new_sqlite_classes": ["Deployer", "Routes", "Outbox", "Bot"] },
        { "tag": "v2", "new_sqlite_classes": ["CloudUsageLedger"] },
      ],
      "containers": [
        {
          "class_name": "Deployer",
          "image": "./container/Dockerfile",
          "instance_type": "standard-4",
          "max_instances": 10,
          "rollout_step_percentage": 100,
        },
      ],
    },
  },
}