everyapp 0.3.0-rc.3 → 0.3.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/access-Z4V433V3.js +1 -0
- package/dist/{activity-2RGC4KBA.js → activity-DI4EQK5D.js} +1 -1
- package/dist/ai-2CSPD7BE.js +5 -0
- package/dist/{apps-IKTWTDHD.js → apps-ZRJ4E67Y.js} +1 -1
- package/dist/chunk-237YEYW3.js +9 -0
- package/dist/chunk-2R4OIXLG.js +2 -0
- package/dist/{chunk-3GZA6EEZ.js → chunk-2TJPAUI2.js} +1 -1
- package/dist/chunk-3N3EVZIL.js +1 -0
- package/dist/chunk-4HAZIQNG.js +2 -0
- package/dist/chunk-4PL6QFR7.js +8 -0
- package/dist/chunk-4YVIPUTR.js +45 -0
- package/dist/chunk-5D7AKUE4.js +5 -0
- package/dist/chunk-5XZAJC2Z.js +37 -0
- package/dist/chunk-7JWJE5CC.js +1 -0
- package/dist/chunk-7QXX37OH.js +26 -0
- package/dist/{chunk-HT76NR3O.js → chunk-7WF744VP.js} +1 -1
- package/dist/chunk-AH6OKF3W.js +1 -0
- package/dist/chunk-AKXMJN76.js +1 -0
- package/dist/{chunk-LTMQP62I.js → chunk-BLBD5NRZ.js} +1 -1
- package/dist/chunk-BWNZ6F4F.js +2 -0
- package/dist/chunk-CDTGQRJK.js +9 -0
- package/dist/chunk-CQH4GPRR.js +14 -0
- package/dist/chunk-D5HKHQTL.js +1 -0
- package/dist/{chunk-52NQ23OH.js → chunk-DCUHPZ7L.js} +1 -1
- package/dist/chunk-DUC3C3VQ.js +20 -0
- package/dist/{chunk-CGFABBZA.js → chunk-FMEACXUH.js} +1 -1
- package/dist/{chunk-WV4G6E4T.js → chunk-GZSHACXB.js} +1 -1
- package/dist/chunk-IC3GMQUY.js +8 -0
- package/dist/chunk-KD7Z3NZM.js +19 -0
- package/dist/{chunk-RXSJENSN.js → chunk-KG5PJBQO.js} +1 -1
- package/dist/{chunk-VX4Z3D7A.js → chunk-KJVVTOL3.js} +1 -1
- package/dist/{chunk-LKI3XV7I.js → chunk-KOMQQDE4.js} +1 -1
- package/dist/chunk-L5OM5ERO.js +1 -0
- package/dist/chunk-L7P5IFQO.js +93 -0
- package/dist/chunk-LPXDP2TG.js +15 -0
- package/dist/{chunk-MLZJBYSY.js → chunk-N7J2Y6YM.js} +3 -3
- package/dist/{chunk-KTX5YGBL.js → chunk-NSDEURVV.js} +1 -1
- package/dist/chunk-O7TM3TQQ.js +15 -0
- package/dist/{chunk-E3EPK27P.js → chunk-QJRZFIYC.js} +2 -2
- package/dist/chunk-QWBCJXRO.js +2 -0
- package/dist/chunk-RJW7E7KW.js +1 -0
- package/dist/chunk-ROVVRUPW.js +47 -0
- package/dist/chunk-RQBSTNL7.js +1 -0
- package/dist/{chunk-475IB5UG.js → chunk-SSDMYDPY.js} +3 -3
- package/dist/chunk-SSHOF4SN.js +1 -0
- package/dist/chunk-TBFAT4IO.js +10 -0
- package/dist/chunk-TMJCBQDC.js +18 -0
- package/dist/{chunk-ZCJTJDAI.js → chunk-TPRTRAMO.js} +1 -1
- package/dist/{chunk-AEYRJ3TD.js → chunk-TTRQFVAM.js} +3 -3
- package/dist/chunk-UORW6LDA.js +2 -0
- package/dist/chunk-V6YIWV7B.js +2 -0
- package/dist/chunk-W7YJMRYJ.js +14 -0
- package/dist/chunk-YHLXCGDS.js +8 -0
- package/dist/{chunk-WY2V27RK.js → chunk-YRVHVI5U.js} +2 -2
- package/dist/chunk-YUHQSSAS.js +146 -0
- package/dist/chunk-ZCGZPCNA.js +4 -0
- package/dist/chunk-ZNQCJL74.js +1 -0
- package/dist/{configure-EJKUEVYS.js → chunk-ZWD6IOFM.js} +2 -2
- package/dist/configure-M52NNYON.js +1 -0
- package/dist/create-KXSWFSHW.js +15 -0
- package/dist/{db-66QZCKMG.js → db-ECRVCE3X.js} +1 -1
- package/dist/delete-T7NUPMGS.js +3 -0
- package/dist/deploy-GTTVOFEL.js +1 -0
- package/dist/dev-DYR4EJG5.js +86 -0
- package/dist/{email-LAQDDSYC.js → email-5WYLGMB3.js} +1 -1
- package/dist/{events-RRF7OOCI.js → events-RTGGQ5AC.js} +13 -13
- package/dist/{groups-CFTGDYZU.js → groups-QKSGV4S5.js} +1 -1
- package/dist/index.js +105 -101
- package/dist/install-ZBKQD6ON.js +1 -0
- package/dist/login-OY4PIWPD.js +1 -0
- package/dist/mcp-S24EVYO7.js +1 -0
- package/dist/provider-RYICILOF.js +29 -0
- package/dist/release-BL36NMEE.js +1 -0
- package/dist/restore-DGPJTJJ7.js +3 -0
- package/dist/secret-S7AI7QK5.js +1 -0
- package/dist/setup-BA3IKUNN.js +1 -0
- package/dist/{signin-X4Z42R7E.js → signin-ZQBMQKPM.js} +2 -2
- package/dist/skills-QKFZPA6Y.js +2 -0
- package/dist/status-QB4N64YZ.js +5 -0
- package/dist/teardown-WS6FJFM3.js +22 -0
- package/dist/update-7UICSOEW.js +1 -0
- package/dist/{workspace-ZLKGLW35.js → workspace-EX5XC2J4.js} +3 -3
- package/package.json +7 -6
- package/skills/build-every-app/SKILL.md +32 -22
- package/skills/build-every-app/patterns.md +37 -30
- package/skills/everyapp/SKILL.md +20 -11
- package/skills/everyapp/mcp.md +18 -6
- package/skills/everyapp/security-review.md +1 -1
- package/skills/everyapp/setup/README.md +20 -5
- package/skills/everyapp/setup/access.md +12 -8
- package/skills/everyapp/setup/ai-gateway.md +1 -1
- package/skills/everyapp/setup/ai.md +2 -2
- package/skills/everyapp/setup/context.md +2 -2
- package/skills/everyapp/setup/dataforseo.md +3 -3
- package/skills/everyapp/setup/email.md +6 -6
- package/skills/everyapp/setup/gateway.md +8 -9
- package/skills/everyapp/setup/google.md +24 -17
- package/skills/everyapp/setup/microsoft-365.md +4 -2
- package/skills/everyapp/setup/openai.md +1 -1
- package/skills/everyapp/setup/openrouter.md +16 -16
- package/skills/everyapp/setup/providers.md +1 -1
- package/skills/everyapp/setup/remote-mcp.md +1 -1
- package/skills/everyapp/setup/signin-apple.md +3 -3
- package/skills/everyapp/setup/signin-cloudflare.md +1 -1
- package/skills/everyapp/setup/signin-github.md +1 -1
- package/skills/everyapp/setup/signin-google.md +2 -2
- package/skills/everyapp/setup/signin-microsoft.md +1 -1
- package/skills/everyapp/setup/slack.md +2 -0
- package/skills/everyapp/setup/workers-ai.md +11 -11
- package/starter/.prettierignore +8 -0
- package/starter/AGENTS.md +34 -0
- package/starter/CLAUDE.md +1 -0
- package/starter/README.md +35 -0
- package/starter/cloudflare.config.ts +11 -0
- package/starter/drizzle/0000_todos.sql +7 -0
- package/starter/drizzle/meta/0000_snapshot.json +65 -0
- package/starter/drizzle/meta/_journal.json +13 -0
- package/starter/drizzle.config.ts +7 -0
- package/starter/everyapp.config.ts +15 -0
- package/starter/gitignore +23 -0
- package/starter/knip.jsonc +20 -0
- package/starter/package.json +48 -0
- package/starter/public/apple-touch-icon.png +0 -0
- package/starter/public/favicon.ico +0 -0
- package/starter/src/db/index.ts +5 -0
- package/starter/src/db/schema.ts +13 -0
- package/starter/src/entry.worker.ts +9 -0
- package/starter/src/env.d.ts +8 -0
- package/starter/src/middleware/ensureUser.ts +13 -0
- package/starter/src/routeTree.gen.ts +86 -0
- package/starter/src/router.tsx +6 -0
- package/starter/src/routes/__root.tsx +35 -0
- package/starter/src/routes/health.ts +18 -0
- package/starter/src/routes/index.tsx +260 -0
- package/starter/src/server/events.test.ts +53 -0
- package/starter/src/server/events.ts +31 -0
- package/starter/src/server/todos.test.ts +49 -0
- package/starter/src/server/todos.ts +74 -0
- package/starter/src/serverFunctions/home.ts +72 -0
- package/starter/src/serverFunctions/todos.ts +31 -0
- package/starter/src/styles/app.css +5 -0
- package/starter/src/tools.ts +59 -0
- package/starter/tsconfig.json +18 -0
- package/starter/vite.config.ts +33 -0
- package/starter/vitest.config.ts +8 -0
- package/dist/access-FZ2ARRET.js +0 -1
- package/dist/ai-ZGVUY7AM.js +0 -5
- package/dist/chunk-36VCEEIH.js +0 -1
- package/dist/chunk-4MMHVIHT.js +0 -20
- package/dist/chunk-6ILATTGU.js +0 -34
- package/dist/chunk-7BC42ZUS.js +0 -2
- package/dist/chunk-7SCPBFKI.js +0 -4
- package/dist/chunk-AIDX5IYA.js +0 -2
- package/dist/chunk-BHMRY53V.js +0 -2
- package/dist/chunk-DB5CMXEV.js +0 -1
- package/dist/chunk-DONNKBKB.js +0 -1
- package/dist/chunk-EEF4FY26.js +0 -22
- package/dist/chunk-EJE6K5GO.js +0 -146
- package/dist/chunk-HHVABFYD.js +0 -1
- package/dist/chunk-IWP4Q3KV.js +0 -15
- package/dist/chunk-J2XKGQO7.js +0 -7
- package/dist/chunk-JBTV62V7.js +0 -2
- package/dist/chunk-JT3R24Y7.js +0 -1
- package/dist/chunk-KS7DIYIJ.js +0 -2
- package/dist/chunk-LTYAIGEB.js +0 -10
- package/dist/chunk-NXO2BC3M.js +0 -57
- package/dist/chunk-OHDR7JWQ.js +0 -99
- package/dist/chunk-ONGI463M.js +0 -6
- package/dist/chunk-Q44H7KLY.js +0 -1
- package/dist/chunk-SMCUCFS4.js +0 -22
- package/dist/chunk-TQWCYF2T.js +0 -6
- package/dist/chunk-UEQMNXMZ.js +0 -1
- package/dist/chunk-WTKBB5HE.js +0 -46
- package/dist/chunk-XEPXX3AI.js +0 -15
- package/dist/chunk-Y6CGMZEB.js +0 -1
- package/dist/chunk-YCADEJVJ.js +0 -7
- package/dist/chunk-ZH6IAPVK.js +0 -18
- package/dist/create-BKEFXQ5N.js +0 -22
- package/dist/delete-JR5R2OHE.js +0 -3
- package/dist/deploy-G4NB5R2P.js +0 -1
- package/dist/dev-EFDXNBFY.js +0 -86
- package/dist/install-GXMHD5XS.js +0 -1
- package/dist/login-YWNHPSC2.js +0 -1
- package/dist/mcp-72WLLKTK.js +0 -1
- package/dist/provider-IPV6BDP3.js +0 -13
- package/dist/release-4T7BVUZ5.js +0 -1
- package/dist/restore-BWPOK4UP.js +0 -3
- package/dist/secret-NLQQNZMK.js +0 -1
- package/dist/setup-6PNOX4NZ.js +0 -1
- package/dist/status-VEUCYFRY.js +0 -4
- package/dist/teardown-J4CP2EI5.js +0 -22
- package/dist/update-NU2SFDNF.js +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var Pr=Object.defineProperty;var xr=(e,t,s)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var X=(e,t,s)=>(xr(e,typeof t!="symbol"?t+"":t,s),s);function Rr(e=process.env){let t=e.npm_config_user_agent?.split("/")[0];return t?Or[t]??"everyapp":"everyapp"}var Or={pnpm:"pnpm everyapp",npm:"npx everyapp",yarn:"yarn everyapp"},St=Rr();function M(e=[],{terminal:t=!1,argv:s=process.argv.slice(2)}={}){let n=t?s.filter(o=>o!=="--json"):[...s];for(let o of e)n.includes(o)||n.push(o);return[St,...n.map(Cr)].join(" ")}function hp(e,t=process.argv.slice(2)){let s=[];for(let n=0;n<t.length;n++){let o=t[n];o===e?n++:o.startsWith(`${e}=`)||s.push(o)}return M([],{argv:s})}function Cr(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var z=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Me=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`,f=e=>typeof e=="string"&&e.length>0?e:void 0,fp=e=>f(e)??null;function Os(...e){return e.join(`
|
|
2
|
+
`).split(/\r?\n/).map(t=>t.trimEnd()).filter(t=>t.trim().length>0).slice(-20)}function It(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var O=e=>Array.isArray(e)?e.map(String):[];var Cs={stripe:{mode:"api_key",label:"Stripe",description:"Payments: customers, subscriptions, invoices, charges and payouts.",auth:{kind:"bearer",secret:"STRIPE_API_KEY"},docs:"https://dashboard.stripe.com/apikeys",api:"https://docs.stripe.com/api",hosts:["api.stripe.com","files.stripe.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","DELETE"],accountWidePaths:[["v1","account"],["v1","accounts"],["v2","core","accounts"],["v1","webhook_endpoints"],["v2","core","event_destinations"],["v1","apps","secrets"]],hint:"A restricted API key from the API keys page of the Stripe dashboard, with only the permissions the app needs. The Gateway sends it as a bearer token.",secrets:[{name:"STRIPE_API_KEY",hint:"A restricted key (rk_live_...) with only the permissions the app needs; a sandbox key (rk_test_... or sk_test_...) to try it."}],smoke:{method:"GET",path:"/v1/balance",expect:[200],free:!0,note:"A restricted key needs Balance read for this one."},cost:{unit:"call",note:"No per-call price; reads should average under 500 per transaction over 30 days, with at least 10,000 a month allowed."},rate:{perSecond:100,note:"Live mode, per account; sandbox 25/s; most single endpoints 25/s; Search 20/s."},example:"list my latest customers and their subscriptions",verified:{on:"2026-10-25",how:"docs"},tags:["payments","billing"]},lemonsqueezy:{mode:"api_key",label:"Lemon Squeezy",description:"Merchant of record for software: stores, products, orders, subscriptions, license keys.",auth:{kind:"bearer",secret:"LEMONSQUEEZY_API_KEY"},docs:"https://app.lemonsqueezy.com/settings/api",api:"https://docs.lemonsqueezy.com/api",hosts:["api.lemonsqueezy.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PATCH","DELETE"],accountWidePaths:[["v1","users"],["v1","webhooks"]],hint:"An API key from Settings > API in Lemon Squeezy; the Gateway sends it as a bearer token. The API is JSON:API, so the app sends Accept and Content-Type application/vnd.api+json.",secrets:[{name:"LEMONSQUEEZY_API_KEY",hint:"An API key from Settings > API; a test mode key reaches test mode store data only."}],smoke:{method:"GET",path:"/v1/users/me",expect:[200],free:!0,note:"Account-wide, so the Gateway refuses it for apps; run it from the person's terminal."},rate:{perMinute:300,note:"300 API calls per minute."},example:"list this month's orders and active subscriptions",verified:{on:"2026-10-25",how:"docs"},tags:["payments","billing"]},paddle:{mode:"api_key",label:"Paddle",description:"Paddle Billing: products, prices, customers, subscriptions and transactions.",auth:{kind:"bearer",secret:"PADDLE_API_KEY"},docs:"https://developer.paddle.com/api-reference/about/authentication/",api:"https://developer.paddle.com/api-reference/",hosts:["api.paddle.com","sandbox-api.paddle.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PATCH","DELETE"],accountWidePaths:[["account"],["settings"],["notification-settings"],["notifications"],["simulations"],["simulation-runs"],["client-tokens"],["checkout-domains"],["verifications"]],hint:"An API key from Paddle > My account > Settings > Authentication (API keys tab), with only the permissions the app needs; the Gateway sends it as a bearer token. Live and sandbox are separate hosts with separate keys.",secrets:[{name:"PADDLE_API_KEY",hint:"An API key (pdl_live_apikey_... or pdl_sdbx_apikey_...) with only the permissions the app needs; a sandbox key works on the sandbox host only."}],smoke:{method:"GET",path:"/event-types",expect:[200],free:!0,note:"Paddle's own first request: needs no permissions. Send it to sandbox-api.paddle.com with a sandbox key."},rate:{perMinute:240,note:"Per IP address; pricing previews 1,000 a minute; 20 immediate-charge updates per subscription an hour."},example:"list the active subscriptions that renew this week",verified:{on:"2026-10-25",how:"docs"},tags:["payments","billing"]},shopify:{mode:"api_key",label:"Shopify",description:"One store's Admin API (GraphQL): products, orders, customers and inventory.",auth:{kind:"header",secret:"SHOPIFY_API_TOKEN",header:"X-Shopify-Access-Token"},docs:"https://shopify.dev/docs/apps/build/authentication-authorization/legacy/admin-custom-apps",api:"https://shopify.dev/docs/api/admin-graphql",hosts:[],hostSetting:"SHOPIFY_HOST",data:"account",access:["write"],readMethods:[],writeMethods:["POST"],accountWidePaths:[["webhooks"],["storefront_access_tokens"]],hint:"An Admin API access token from a custom app created in the store's admin, sent in the X-Shopify-Access-Token header to the store's myshopify.com host. Shopify no longer lets stores create new admin custom apps, and Dev Dashboard tokens expire after 24 hours, which the Gateway can't refresh yet.",secrets:[{name:"SHOPIFY_API_TOKEN",hint:"The Admin API access token of a custom app made in the store's admin (Apps > Develop apps > the app > API credentials); it is shown once."},{name:"SHOPIFY_HOST",hint:"The store's own host, like your-store.myshopify.com."}],smoke:{method:"GET",path:"/admin/api/2026-10/shop.json",expect:[200],free:!0,note:"The legacy REST read of the store; the Gateway forwards no GET for this entry, so run it from the person's terminal."},rate:{note:"GraphQL cost points per second by plan: Standard 100, Advanced 200, Plus 1,000, enterprise 2,000."},example:"list the ten newest orders and what was in them",verified:{on:"2026-10-25",how:"docs"},tags:["ecommerce"]},plaid:{mode:"api_key",label:"Plaid",description:"Bank data: accounts, balances, transactions and identity, for the Items an app links.",auth:{kind:"header",secret:"PLAID_SECRET",header:"PLAID-SECRET"},docs:"https://dashboard.plaid.com/developers/keys",api:"https://plaid.com/docs/api/",hosts:["sandbox.plaid.com","production.plaid.com"],data:"account",access:["read"],readMethods:["POST"],accountWidePaths:[["item","webhook","update"],["item","access_token","invalidate"],["item","remove"],["webhook_verification_key"],["dashboard_user"],["transfer"],["payment_initiation"]],hint:"Plaid needs a client_id and a secret on every call, in the JSON body or in the PLAID-CLIENT-ID and PLAID-SECRET headers. The Gateway puts on one header, so the app would have to send PLAID-CLIENT-ID itself. Every endpoint is a POST.",secrets:[{name:"PLAID_SECRET",hint:"The secret for one environment (Sandbox or Production) from the Keys page of the Plaid Dashboard."}],rate:{note:"Set per endpoint and per Item: /accounts/get allows 15 a minute per Item and 15,000 a minute per client."},example:"list the last 30 days of transactions on a linked account",verified:!1,tags:["finance","banking"]},attio:{mode:"api_key",label:"Attio",description:"CRM: people, companies, deals, lists, notes and tasks in one Attio workspace.",auth:{kind:"bearer",secret:"ATTIO_API_KEY"},docs:"https://attio.com/help/reference/apps/generating-an-api-key",api:"https://docs.attio.com/rest-api/overview",hosts:["api.attio.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["v2","self"],["v2","webhooks"],["v2","workspace_members"]],hint:"An access token a workspace admin makes under Workspace settings > Developers, scoped to what the app needs; the Gateway sends it as a bearer token. Listing and searching records are POSTs, so an app that lists records needs write access.",secrets:[{name:"ATTIO_API_KEY",hint:"An access token from Workspace settings > Developers, with only the scopes the app needs."}],smoke:{method:"GET",path:"/v2/objects",expect:[200],free:!0,note:"Lists the workspace's objects; needs the object_configuration:read scope. /v2/self answers 200 even for a revoked token."},rate:{perSecond:100,note:"100 reads and 25 writes per second; listing records and entries also has score-based limits."},example:"find the companies we added this week and their open deals",verified:{on:"2026-10-25",how:"docs"},tags:["crm"]},hubspot:{mode:"api_key",label:"HubSpot",description:"CRM and marketing: contacts, companies, deals, tickets and more in one HubSpot account.",auth:{kind:"bearer",secret:"HUBSPOT_API_TOKEN"},docs:"https://developers.hubspot.com/docs/apps/legacy-apps/private-apps/overview",api:"https://developers.hubspot.com/docs/api-reference/latest/overview",hosts:["api.hubapi.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["account-info"],["settings","users"],["settings","v3","users"],["settings","teams"],["app-webhooks"],["webhooks"],["webhooks-journal"],["oauth"]],hint:"An access token from a HubSpot legacy private app (Development > Legacy apps > Create legacy app > Private), scoped to what the app needs; the Gateway sends it as a bearer token. CRM search is a POST, so an app that searches needs write access.",secrets:[{name:"HUBSPOT_API_TOKEN",hint:"The access token of a legacy private app (Development > Legacy apps > the app > Auth), with only the scopes the app needs."}],smoke:{method:"GET",path:"/account-info/2026-09/details",expect:[200],free:!0,note:"Account-wide, so the Gateway refuses it for apps; run it from the person's terminal."},rate:{perDay:25e4,note:"Private apps on Free and Starter: 100 per 10 seconds per app and 250,000 a day per account; Pro 190 and 625,000; Enterprise 190 and 1,000,000."},example:"list the deals that moved to closed won this month",verified:{on:"2026-10-25",how:"docs"},tags:["crm","marketing"]},pipedrive:{mode:"api_key",label:"Pipedrive",description:"Sales CRM: deals, persons, organizations, activities and pipelines.",auth:{kind:"header",secret:"PIPEDRIVE_API_TOKEN",header:"x-api-token"},docs:"https://app.pipedrive.com/settings/api",api:"https://developers.pipedrive.com/docs/api/v1",hosts:["api.pipedrive.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["v1","users"],["v1","webhooks"],["v1","billing"],["v1","permissionsets"],["v1","roles"],["v1","usersettings"],["v1","userconnections"],["v1","legacyteams"]],hint:"A personal API token from Settings > Personal preferences > API in Pipedrive; the Gateway sends it in the x-api-token header. If API is missing there, an admin enables it for the person's permission set.",secrets:[{name:"PIPEDRIVE_API_TOKEN",hint:"Your personal API token from Settings > Personal preferences > API; it acts as you, and each company you belong to has its own."}],smoke:{method:"GET",path:"/v1/users/me",expect:[200],free:!0,note:"Account-wide, so the Gateway refuses it for apps; run it from the person's terminal."},cost:{unit:"call",note:"Each endpoint spends API tokens from a daily company budget of 30,000 x plan multiplier (1 to 7) x seats."},rate:{note:"Per API token: 20 (Lite) to 120 (Ultimate) requests per 2 seconds; Search 10 per 2 seconds."},example:"list the open deals in my main pipeline",verified:{on:"2026-10-25",how:"docs"},tags:["crm","sales"]},airtable:{mode:"api_key",label:"Airtable",description:"Bases, tables and records in the Airtable workspaces a token can reach.",auth:{kind:"bearer",secret:"AIRTABLE_API_TOKEN"},docs:"https://airtable.com/create/tokens",api:"https://airtable.com/developers/web/api/introduction",hosts:["api.airtable.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["v0","meta","whoami"],["v0","meta","enterpriseaccounts"],["v0","meta","workspaces"],["v0","meta","groups"],["v0","bases"],["scim"],["collaborators"],["invites"],["shares"],["blockinstallations"]],hint:"A personal access token from airtable.com/create/tokens, limited to the scopes and bases the app needs; the Gateway sends it as a bearer token. Listing records by POST (listRecords) needs write access; the GET form doesn't.",secrets:[{name:"AIRTABLE_API_TOKEN",hint:"A personal access token limited to the scopes and bases the app needs."}],smoke:{method:"GET",path:"/v0/meta/whoami",expect:[200],free:!0,note:"Account-wide, so the Gateway refuses it for apps; run it from the person's terminal."},rate:{perSecond:5,note:"5 requests per second per base; 50 per second across all of one user's personal access tokens."},example:"list this week's new rows in my Leads table",verified:{on:"2026-10-25",how:"docs"},tags:["database","spreadsheet"]},notion:{mode:"api_key",label:"Notion",description:"Pages, databases and blocks that a Notion connection has been given.",auth:{kind:"bearer",secret:"NOTION_API_TOKEN"},docs:"https://app.notion.com/developers/connections",api:"https://developers.notion.com/reference/intro",hosts:["api.notion.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PATCH","DELETE"],accountWidePaths:[["v1","users"],["v1","oauth"],["admin"]],hint:"An internal connection's API token (a workspace owner creates the connection in Notion's developer portal), sent as a bearer token; it reaches only pages shared with it. The app sends the Notion-Version header itself. Search and data source queries are POSTs, so an app that queries needs write access.",secrets:[{name:"NOTION_API_TOKEN",hint:"The API token on an internal connection's Configuration tab; share the pages it should reach with the connection."}],smoke:{method:"GET",path:"/v1/users/me",expect:[200],free:!0,note:"Send Notion-Version: 2026-03-11 with it; account-wide, so run it from the person's terminal."},rate:{perMinute:180,note:"Per connection: 180 a minute, 600 on Business and Enterprise; data source queries about 3 per second."},example:"find the pages in my Projects database that are due this week",verified:{on:"2026-10-25",how:"docs"},tags:["docs","notes","database"]}};var Ns={postmark:{mode:"api_key",label:"Postmark",description:"Transactional email: single, batch and templated messages from one Postmark server.",auth:{kind:"header",secret:"POSTMARK_API_TOKEN",header:"X-Postmark-Server-Token"},docs:"https://postmarkapp.com/support/article/1008-what-are-the-account-and-server-api-tokens",api:"https://postmarkapp.com/developer/api/overview",hosts:["api.postmarkapp.com"],data:"account",access:["write"],readMethods:[],writeMethods:["POST"],accountWidePaths:[["server"],["servers"],["domains"],["senders"],["webhooks"],["message-streams"],["triggers"],["data-removals"]],hint:"A Server API token from the API Tokens tab of the Postmark server the app sends from; the Gateway sends it in the X-Postmark-Server-Token header.",secrets:[{name:"POSTMARK_API_TOKEN",hint:"A Server API token from the server's API Tokens tab, never the Account API token."}],smoke:{method:"GET",path:"/server",expect:[200],free:!0,note:"Returns the server's settings; account-wide, so run it from a terminal."},example:"send a password reset email",verified:{on:"2026-10-25",how:"docs"},tags:["email","transactional"]},sendgrid:{mode:"api_key",label:"SendGrid",description:"Twilio SendGrid email: send transactional and marketing mail through the v3 Mail Send API.",auth:{kind:"bearer",secret:"SENDGRID_API_KEY"},docs:"https://app.sendgrid.com/settings/api_keys",api:"https://www.twilio.com/docs/sendgrid/api-reference",hosts:["api.sendgrid.com","api.eu.sendgrid.com"],data:"account",access:["write"],readMethods:[],writeMethods:["POST"],accountWidePaths:[["api_keys"],["scopes"],["user"],["subusers"],["teammates"],["sso"],["access_settings"],["whitelabel"],["ips"],["send_ips"],["partners"],["partner_settings"],["alerts"],["mail_settings"],["tracking_settings"],["verified_senders"],["senders"],["marketing","integrations"],["recipients","erasejob"]],hint:"An API key from Settings > API Keys in SendGrid, sent as a bearer token; Custom Access with Mail Send alone is enough to send. EU regional subusers call api.eu.sendgrid.com.",secrets:[{name:"SENDGRID_API_KEY",hint:"A Custom Access key with Mail Send only, never a Full Access key."}],smoke:{method:"GET",path:"/v3/scopes",expect:[200],free:!0,note:"Lists the key's own scopes (the docs don't say whether a Mail-Send-only key may call it); account-wide, so run it from a terminal."},rate:{note:"Each endpoint has its own limit; answers carry X-RateLimit-Limit, -Remaining and -Reset."},example:"send an order confirmation email",verified:{on:"2026-10-25",how:"docs"},tags:["email","transactional","marketing"]},twilio:{mode:"api_key",label:"Twilio",description:"SMS, MMS and voice: send text messages and place calls from your Twilio numbers.",auth:{kind:"basic",secret:"TWILIO_API_SECRET",as:"password",user:{secret:"TWILIO_API_KEY"}},docs:"https://www.twilio.com/docs/iam/api-keys/keys-in-console",api:"https://www.twilio.com/docs/usage/requests-to-twilio",hosts:["api.twilio.com"],data:"account",access:["write"],readMethods:[],writeMethods:["POST"],accountWidePaths:[["keys"],["signingkeys"],["incomingphonenumbers"],["outgoingcallerids"],["applications"],["connectapps"],["authorizedconnectapps"],["addresses"],["sip"],["usage"],["balance"]],hint:"A Standard or Restricted API key from Account settings > API keys & auth tokens in the Twilio Console, sent as HTTP Basic (the key's SID and secret); a Standard key can't reach the Accounts or Keys resources. Every path names the account, so the app puts its Account SID in it: /2010-04-01/Accounts/<Account SID>/Messages.json, with a form-encoded body.",secrets:[{name:"TWILIO_API_SECRET",hint:"The API key's secret, shown once when the key is created."},{name:"TWILIO_API_KEY",hint:"The SID of a Standard or Restricted API key, never a Main key or the Auth Token."}],example:"text a reminder to a customer's phone number",verified:{on:"2026-10-25",how:"docs"},tags:["sms","voice","messaging"]},intercom:{mode:"api_key",label:"Intercom",description:"Customer messaging: contacts, companies, conversations, tickets and help center articles.",auth:{kind:"bearer",secret:"INTERCOM_API_TOKEN"},docs:"https://app.intercom.com/a/apps/_/developer-hub",api:"https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis",hosts:["api.intercom.io","api.eu.intercom.io","api.au.intercom.io"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["me"],["admins"],["teams"],["export"],["download"],["ip_allowlist"]],hint:"The Access Token of a private app in your workspace's Developer Hub, sent as a bearer token. Searching contacts, conversations or tickets is a POST, so an app that searches asks for write.",secrets:[{name:"INTERCOM_API_TOKEN",hint:"The Access Token on your private app's Configure > Authentication page in the Developer Hub."}],smoke:{method:"GET",path:"/me",expect:[200],free:!0,note:"Returns the admin behind the token; account-wide, so run it from a terminal."},rate:{perMinute:1e4,note:"Per workspace, shared by its private apps; 25,000 a minute across all apps; counted in 10-second windows."},example:"list the latest open conversations",verified:{on:"2026-10-25",how:"docs"},tags:["support","crm","messaging"]},crisp:{mode:"api_key",label:"Crisp",description:"Customer chat: conversations, messages, people and visitors of one Crisp workspace.",auth:{kind:"basic",secret:"CRISP_API_KEY",as:"password",user:{secret:"CRISP_API_IDENTIFIER"}},docs:"https://docs.crisp.chat/guides/rest-api/authentication/website-token/",api:"https://docs.crisp.chat/references/rest-api/v1/",hosts:["api.crisp.chat"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["operators"],["operator"],["teams"],["team"],["settings"],["verify"],["audit"],["plans"],["plugins"],["plugin"],["connect"]],hint:"A website token, which the workspace owner generates under Settings > Workspace Settings > Advanced configuration > API Token. The Gateway sends the identifier and key as HTTP Basic; the app sends X-Crisp-Tier: website on every call.",secrets:[{name:"CRISP_API_KEY",hint:"The token's key, shown once when the workspace owner generates it."},{name:"CRISP_API_IDENTIFIER",hint:"The token's identifier, shown beside the key."}],rate:{perDay:1e4,note:"The website token's daily quota."},example:"list the latest chat conversations on my website",verified:{on:"2026-10-25",how:"docs"},tags:["support","chat","messaging"]},linear:{mode:"api_key",label:"Linear",description:"Issue tracking over GraphQL: issues, projects, cycles, comments and teams.",auth:{kind:"header",secret:"LINEAR_API_KEY",header:"Authorization"},docs:"https://linear.app/settings/account/security",api:"https://linear.app/developers/graphql",hosts:["api.linear.app"],data:"account",access:["write"],readMethods:[],writeMethods:["POST"],accountWidePaths:[],hint:"A personal API key from Settings > Account > Security & access; the Gateway sends it as the Authorization header with no Bearer word. Every call is a POST to /graphql, queries included, so the app asks for write.",secrets:[{name:"LINEAR_API_KEY",hint:"A personal API key, restricted to the permissions and teams the app needs."}],rate:{note:"2,500 requests and 3,000,000 complexity points an hour per API key."},example:"create an issue for this bug in the Engineering team",verified:{on:"2026-10-25",how:"docs"},tags:["issues","project-management","graphql"]},github:{mode:"api_key",label:"GitHub",description:"Code hosting: repositories, issues, pull requests, Actions and releases through the REST API.",auth:{kind:"bearer",secret:"GITHUB_API_TOKEN"},docs:"https://github.com/settings/personal-access-tokens/new",api:"https://docs.github.com/en/rest",hosts:["api.github.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["user","email"],["user","emails"],["user","public_emails"],["user","gpg_keys"],["user","ssh_signing_keys"],["user","social_accounts"],["keys"],["hooks"],["secrets"],["members"],["memberships"],["invitations"],["failed_invitations"],["collaborators"],["outside_collaborators"],["blocks"],["installations"],["personal-access-tokens"],["personal-access-token-requests"],["credential-authorizations"],["audit-log"],["billing"]],hint:"A fine-grained personal access token from Settings > Developer settings, limited to one owner, the repositories the app needs and the least permissions; sent as a bearer token. GraphQL is a POST to /graphql, so it needs write.",secrets:[{name:"GITHUB_API_TOKEN",hint:"A fine-grained personal access token limited to the repositories and permissions the app needs."}],smoke:{method:"GET",path:"/user",expect:[200],free:!0,note:"Returns the token's owner; 401 means the token is wrong."},rate:{note:"5,000 requests an hour per token; at most 100 concurrent requests and 900 points a minute across REST endpoints."},example:"list the open pull requests in my repository",verified:{on:"2026-10-25",how:"docs"},tags:["code","git","issues"]},gitlab:{mode:"api_key",label:"GitLab",description:"Code hosting on GitLab.com: projects, issues, merge requests, pipelines and releases.",auth:{kind:"header",secret:"GITLAB_API_TOKEN",header:"PRIVATE-TOKEN"},docs:"https://gitlab.com/-/user_settings/personal_access_tokens",api:"https://docs.gitlab.com/api/rest/",hosts:["gitlab.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["user"],["personal_access_tokens"],["access_tokens"],["deploy_tokens"],["deploy_keys"],["project_deploy_keys"],["hooks"],["members"],["pending_members"],["billable_members"],["invitations"],["variables"],["audit_events"]],hint:"A personal, project or group access token from GitLab.com, sent in the PRIVATE-TOKEN header; read_api is enough to read. Paths start with /api/v4. A self-managed GitLab needs its own registered provider.",secrets:[{name:"GITLAB_API_TOKEN",hint:"A personal, project or group access token with read_api, or api when the app writes."}],smoke:{method:"GET",path:"/api/v4/personal_access_tokens/self",expect:[200],free:!0,note:"Describes a personal access token itself (401 when it is wrong or revoked); account-wide, so run it from a terminal."},rate:{perMinute:2e3,note:"Authenticated API traffic per user on GitLab.com."},example:"list the open merge requests in my project",verified:{on:"2026-10-25",how:"docs"},tags:["code","git","ci"]},vercel:{mode:"api_key",label:"Vercel",description:"Frontend hosting: projects, deployments, domains and logs through the Vercel REST API.",auth:{kind:"bearer",secret:"VERCEL_API_TOKEN"},docs:"https://vercel.com/account/tokens",api:"https://vercel.com/docs/rest-api",hosts:["api.vercel.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["user"],["teams"],["members"],["organizations"],["access-groups"],["billing"],["webhooks"],["drains"],["env"],["v3","events"],["v1","events"],["v1","integrations"],["installations"],["connect"],["kms"],["api-keys"],["ai-gateway"],["token"],["tokens"],["registrar"],["transfer-request"]],hint:"An access token from your account's Tokens page, sent as a bearer token; scope it to one team or one project. A team- or project-scoped token needs no teamId parameter.",secrets:[{name:"VERCEL_API_TOKEN",hint:"An access token scoped to one team or one project, never Full Account."}],smoke:{method:"GET",path:"/v10/projects",expect:[200],free:!0,note:"Lists the projects the token can reach."},rate:{note:"Limits are per action (deployments, domains, teams), listed on Vercel's limits page."},example:"list the latest deployments of my project",verified:{on:"2026-10-25",how:"docs"},tags:["hosting","deploy","frontend"]}};var $s={cloudflare:{mode:"api_key",label:"Cloudflare",description:"Cloudflare's API: zones, DNS, Workers, R2, D1, KV and the rest of an account.",auth:{kind:"bearer",secret:"CLOUDFLARE_PROVIDER_API_TOKEN"},docs:"https://dash.cloudflare.com/profile/api-tokens",api:"https://developers.cloudflare.com/api/",hosts:["api.cloudflare.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["client","v4","user"],["client","v4","memberships"],["client","v4","organizations"],["client","v4","tenants"],["members"],["tokens"],["roles"],["iam"],["subscriptions"],["payment-methods"],["pay-invoice"],["receipts"],["invoices"],["client-secret"],["billing"],["logs","audit"],["audit_logs"],["alerting","v3","destinations","webhooks"],["ai","run"],["ai","v1"]],hint:"An API token from My Profile > API Tokens with only the permissions the app needs; the Gateway sends it as a bearer token. A token on the Gateway's own account can read and change the Gateway, so keep it narrow or use another account.",secrets:[{name:"CLOUDFLARE_PROVIDER_API_TOKEN",hint:"A user or account-owned API token scoped to the zones and permissions the app needs, never a Global API Key."}],smoke:{method:"GET",path:"/client/v4/user/tokens/verify",expect:[200],free:!0,note:"For a user token; account-owned tokens use /client/v4/accounts/<id>/tokens/verify. Account-wide, so run it from the person's terminal."},rate:{note:"1,200 requests per 5 minutes per user or account token; 200 a second per IP; GraphQL by query cost, at most 320 per 5 minutes."},example:"list the DNS records for my domain",verified:{on:"2026-10-25",how:"docs"},tags:["infrastructure","dns","hosting"]},posthog:{mode:"api_key",label:"PostHog",description:"Product analytics: insights, feature flags, persons, cohorts, experiments and HogQL queries.",auth:{kind:"bearer",secret:"POSTHOG_PERSONAL_API_KEY"},docs:"https://us.posthog.com/settings/user-api-keys",api:"https://posthog.com/docs/api",hosts:["us.posthog.com","eu.posthog.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["api","users"],["api","user"],["api","organizations"],["api","billing"],["api","revoke_leaked_key"],["project_secret_api_keys"],["billing"],["activity_log"],["advanced_activity_logs"],["hog_functions"],["batch_exports"],["integrations"]],hint:"A personal API key from Settings > Personal API keys, with only the scopes the app needs; the Gateway sends it as a bearer token to us.posthog.com or eu.posthog.com. HogQL queries are POSTs, so an app that runs them asks for write.",secrets:[{name:"POSTHOG_PERSONAL_API_KEY",hint:"A personal API key (phx_...) with only the scopes the app needs, from the region the project lives in; never the project token."}],smoke:{method:"GET",host:"us.posthog.com",path:"/api/users/@me/",expect:[200],free:!0,note:"Needs the user:read scope; use eu.posthog.com for an EU project. Account-wide, so run it from the person's terminal."},rate:{perMinute:480,note:"Create, read, update and delete endpoints 480 a minute and 4,800 an hour; analytics endpoints 240 a minute; the query endpoint 2,400 an hour."},example:"list the feature flags in my project and whether each is on",verified:{on:"2026-10-25",how:"docs"},tags:["analytics","product","feature-flags"]},mixpanel:{mode:"api_key",label:"Mixpanel",description:"Product analytics: saved reports, profiles, raw event export and event import.",auth:{kind:"basic",secret:"MIXPANEL_SERVICE_ACCOUNT_SECRET",as:"password",user:{secret:"MIXPANEL_SERVICE_ACCOUNT_USERNAME"}},docs:"https://mixpanel.com/settings/org#serviceaccounts",api:"https://docs.mixpanel.com/reference/overview",hosts:["mixpanel.com","eu.mixpanel.com","in.mixpanel.com","data.mixpanel.com","data-eu.mixpanel.com","data-in.mixpanel.com","api.mixpanel.com","api-eu.mixpanel.com","api-in.mixpanel.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["api","app","me"],["api","app","organizations"],["service-accounts"],["data-retrievals"],["data-deletions"],["nessie"]],hint:"A service account from Organization Settings > Service Accounts; the Gateway sends its username and secret as HTTP Basic. Most calls also need the project_id parameter, and an EU or India project uses its own hosts.",secrets:[{name:"MIXPANEL_SERVICE_ACCOUNT_USERNAME",hint:"The service account's username, shown when it is created in Organization Settings > Service Accounts."},{name:"MIXPANEL_SERVICE_ACCOUNT_SECRET",hint:"The service account's secret, shown once when it is created; give the account the narrowest role and only the projects the app needs."}],smoke:{method:"GET",host:"mixpanel.com",path:"/api/app/me",expect:[200],free:!0,note:"Lists the organizations and projects the service account reaches. Account-wide, so run it from the person's terminal."},rate:{note:"Per project: Query API 60 queries an hour, 5 at once; Raw Data Export 60 an hour, 3 a second, 100 at once; ingestion about 2 GB a minute."},example:"pull last week's numbers from my saved Insights report",verified:{on:"2026-10-25",how:"docs"},tags:["analytics","product"]},segment:{mode:"api_key",label:"Segment",description:"Sends identify, track, page, group and alias events to a Segment source.",auth:{kind:"basic",secret:"SEGMENT_WRITE_KEY",as:"username"},docs:"https://www.twilio.com/docs/segment/connections/find-writekey",api:"https://www.twilio.com/docs/segment/connections/sources/catalog/libraries/server/http-api",hosts:["api.segment.io","events.eu1.segmentapis.com"],data:"account",access:["write"],readMethods:[],writeMethods:["POST"],accountWidePaths:[],hint:"The write key of an HTTP API source, from the source's Settings > API Keys; the Gateway sends it as the Basic username with an empty password. It only sends events; an EU workspace uses events.eu1.segmentapis.com.",secrets:[{name:"SEGMENT_WRITE_KEY",hint:"The write key of an HTTP API source, from the source's Settings > API Keys."}],rate:{perSecond:1e3,note:"Recommended ceiling per workspace; 32 KB per call, 500 KB and 2,500 events per batch."},example:"record a Signed Up event for a new user",verified:{on:"2026-10-25",how:"docs"},tags:["analytics","events","cdp"]},supabase:{mode:"api_key",label:"Supabase",description:"A Supabase project's Postgres REST API and Storage, with its secret key.",auth:{kind:"header",secret:"SUPABASE_SECRET_KEY",header:"apikey"},docs:"https://supabase.com/dashboard/project/_/settings/api-keys",api:"https://supabase.com/docs/guides/api",hosts:[],hostSetting:"SUPABASE_HOST",data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["auth","v1","admin"],["pg"]],hint:"A secret key (sb_secret_...) from Settings > API Keys and the project's host; the Gateway sends the key in the apikey header. The key bypasses Row Level Security, and RPC calls are POSTs, so they need write.",secrets:[{name:"SUPABASE_SECRET_KEY",hint:"A secret key (sb_secret_...) from Settings > API Keys, made for this Gateway alone; it bypasses Row Level Security."},{name:"SUPABASE_HOST",hint:"The project's host, <project-ref>.supabase.co, from the project URL."}],smoke:{method:"GET",path:"/rest/v1/",expect:[200],free:!0,note:"The REST API's OpenAPI root, which only a secret key may read; sent to the host in SUPABASE_HOST."},example:"list the ten newest rows in my orders table",verified:{on:"2026-10-25",how:"docs"},tags:["database","postgres","storage"]},turso:{mode:"api_key",label:"Turso",description:"Turso's Platform API: databases, groups, locations and usage for one organization.",auth:{kind:"bearer",secret:"TURSO_API_TOKEN"},docs:"https://docs.turso.tech/api-reference/authentication",api:"https://docs.turso.tech/api-reference/introduction",hosts:["api.turso.tech"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PATCH","DELETE"],accountWidePaths:[["auth"],["api-tokens"],["members"],["invites"],["invoices"],["subscription"],["plans"],["audit-logs"],["v1","user"]],hint:"An organization-scoped Platform API token (turso auth api-tokens mint <name> --org <org>); the Gateway sends it as a bearer token to api.turso.tech. It manages databases and cannot query them: that is the turso-db entry.",secrets:[{name:"TURSO_API_TOKEN",hint:"An organization-scoped or group-scoped Platform API token from turso auth api-tokens mint <name> --org <org>; never an unrestricted one."}],smoke:{method:"GET",path:"/v1/auth/validate",expect:[200],free:!0,note:"Account-wide, so run it from the person's terminal."},example:"list the databases in my Turso organization",verified:{on:"2026-10-25",how:"docs"},tags:["database","sqlite"]},"turso-db":{mode:"api_key",label:"Turso database",description:"SQL over HTTP to one Turso database: queries, dumps and migration status.",auth:{kind:"bearer",secret:"TURSO_DB_AUTH_TOKEN"},docs:"https://docs.turso.tech/sdk/authorization/tokens",api:"https://docs.turso.tech/sdk/http/reference",hosts:[],hostSetting:"TURSO_DB_HOST",data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST"],accountWidePaths:[],hint:"A database token (turso db tokens create <db>) and the database's HTTP host; the Gateway sends the token as a bearer token. Every query is a POST to /v2/pipeline, so an app that queries asks for write; a --read-only token keeps it to reads.",secrets:[{name:"TURSO_DB_AUTH_TOKEN",hint:"A database token from turso db tokens create <db>, with --read-only or fine-grained permissions when the app only reads."},{name:"TURSO_DB_HOST",hint:"The database's HTTP host, <db>-<org>.turso.io, from turso db show <db> --http-url."}],example:"count the rows in my users table",verified:{on:"2026-10-25",how:"docs"},tags:["database","sqlite","sql"]},neon:{mode:"api_key",label:"Neon",description:"Neon's management API: Postgres projects, branches, databases, roles and endpoints.",auth:{kind:"bearer",secret:"NEON_API_KEY"},docs:"https://neon.com/docs/manage/api-keys",api:"https://neon.com/docs/reference/api",hosts:["console.neon.tech"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["api","v2","auth"],["api","v2","organizations"],["users","me"],["api_keys"],["members"],["invitations"],["permissions"],["transfer_requests"],["billing"],["consumption_history"],["connection_uri"],["reveal_password"],["reset_password"],["credentials"],["realtime","secret"],["rotate_secret"],["auth","keys"],["auth","webhooks"],["oauth_providers"],["email_server"],["email_provider"],["auth","plugins"]],hint:"A project-scoped or organization API key from Settings > API keys; the Gateway sends it as a bearer token to console.neon.tech. It manages projects and branches; the database itself takes Postgres credentials, not this key.",secrets:[{name:"NEON_API_KEY",hint:"A project-scoped or organization API key from Settings > API keys; a project-scoped key reaches one project only."}],smoke:{method:"GET",path:"/api/v2/auth",expect:[200],free:!0,note:"Says which credential and identity the key is. Account-wide, so run it from the person's terminal."},rate:{perMinute:700,note:"About 11 a second, with bursts of 40 a second per route."},example:"list my Neon projects and their branches",verified:{on:"2026-10-25",how:"docs"},tags:["database","postgres"]},pinecone:{mode:"api_key",label:"Pinecone",description:"Vector database: indexes, namespaces, vectors and documents, plus hosted embedding and rerank.",auth:{kind:"header",secret:"PINECONE_API_KEY",header:"Api-Key"},docs:"https://app.pinecone.io/organizations/-/projects/-/keys",api:"https://docs.pinecone.io/reference/api/introduction",hosts:["api.pinecone.io"],hostSetting:"PINECONE_HOST",data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PATCH","DELETE"],accountWidePaths:[["admin"],["api-keys"]],hint:"An API key from the project's API keys page and the host of the index the app uses; the Gateway sends the key in the Api-Key header to api.pinecone.io and that host. Query, search, embed and rerank are POSTs, so an app that uses them asks for write.",secrets:[{name:"PINECONE_API_KEY",hint:"An API key from the project's API keys page in the Pinecone console."},{name:"PINECONE_HOST",hint:"The host of the index the app uses, <index>-<id>.svc.<env>.pinecone.io, from describe_index or the console."}],smoke:{method:"GET",host:"api.pinecone.io",path:"/indexes",expect:[200],free:!0,note:"Lists the project's indexes; the app sends X-Pinecone-Api-Version itself."},example:"list my Pinecone indexes and their dimensions",verified:{on:"2026-10-25",how:"docs"},tags:["vector","database","search"]},mapbox:{mode:"api_key",label:"Mapbox",description:"Maps and location: geocoding, directions, styles, tilesets and datasets.",auth:{kind:"query",secret:"MAPBOX_ACCESS_TOKEN",param:"access_token"},docs:"https://console.mapbox.com/account/access-tokens/",api:"https://docs.mapbox.com/api/overview/",hosts:["api.mapbox.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","PATCH","DELETE"],accountWidePaths:[["tokens"]],hint:"An access token from Access tokens in the Mapbox console, with only the scopes the app needs; the Gateway adds it to every call as the access_token parameter.",secrets:[{name:"MAPBOX_ACCESS_TOKEN",hint:"An access token with only the scopes the app needs, from Access tokens in the Mapbox console."}],rate:{note:"Per token and per API: Geocoding 1,000 a minute, Directions 300, Static Images 1,250; the Tokens API 100 a minute per account."},example:"turn a street address into map coordinates",verified:{on:"2026-10-25",how:"docs"},tags:["maps","geocoding","location"]},openweather:{mode:"api_key",label:"OpenWeather",description:"Weather data: current conditions, forecasts, One Call, history and weather map tiles.",auth:{kind:"query",secret:"OPENWEATHER_API_KEY",param:"appid"},docs:"https://home.openweathermap.org/api_keys",api:"https://openweathermap.org/api",hosts:["api.openweathermap.org","pro.openweathermap.org","history.openweathermap.org","tile.openweathermap.org","maps.openweathermap.org"],data:"per-call",access:["read"],readMethods:["GET","HEAD"],accountWidePaths:[["data","3","stations"],["data","3","measurements"]],hint:"An API key from the API keys tab of your OpenWeather account; the Gateway adds it to every call as the appid parameter. Paid products (hourly forecast, history, Weather Maps 2.0) need a plan that includes them.",secrets:[{name:"OPENWEATHER_API_KEY",hint:"An API key from the API keys tab of the OpenWeather account; a new key can take up to two hours to activate."}],smoke:{method:"GET",host:"api.openweathermap.org",path:"/data/2.5/weather?lat=51.51&lon=-0.13",expect:[200],free:!0,note:"Counts one call against the plan's quota; free within it. A bad or not yet active key answers 401."},cost:{unit:"call",note:"One Call API 3.0 includes 1,000 calls a day free, then is paid per call."},rate:{perMinute:60,note:"The Free plan answers 429 past 60 calls a minute."},example:"get the current weather in Lisbon",verified:{on:"2026-10-25",how:"docs"},tags:["weather","forecast"]}};var Ds={anthropic:{mode:"ai",label:"Anthropic",description:"Claude models through the Messages API.",auth:{kind:"bearer",secret:"ANTHROPIC_API_KEY"},docs:"https://platform.claude.com/settings/keys",api:"https://platform.claude.com/docs/en/api/overview",origin:"https://api.anthropic.com",inferenceRoutes:["/v1/messages","/v1/messages/count_tokens","/v1/chat/completions"],unstoredRoutes:["/v1/chat/completions"],shape:"anthropic",chat:{path:"/v1/chat/completions",model:"claude-haiku-5-5"},aig:{slug:"anthropic"},hint:"An API key from the Claude Console's API keys page; the Gateway sends it as a bearer token. Apps send the anthropic-version header themselves.",secrets:[{name:"ANTHROPIC_API_KEY",hint:"A key scoped to one workspace; the Gateway strips any anthropic-workspace-id header an app sends, so the key alone decides the workspace."}],smoke:{method:"GET",path:"/v1/models",expect:[200],free:!0,note:"Send an anthropic-version header, as every call does."},rate:{note:"Requests and tokens per minute by usage tier, on the Console's Rate limits page; token counting is free, with its own per-minute limit."},example:"summarize this support thread in three bullet points",verified:{on:"2026-10-25",how:"docs"},tags:["ai","llm"]},gemini:{mode:"ai",label:"Google Gemini",description:"Google's Gemini models through their OpenAI-compatible endpoint: chat, embeddings, images.",auth:{kind:"bearer",secret:"GEMINI_API_KEY"},docs:"https://aistudio.google.com/apikey",api:"https://ai.google.dev/gemini-api/docs/openai",origin:"https://generativelanguage.googleapis.com",inferenceRoutes:["/v1beta/openai/chat/completions","/v1beta/openai/embeddings","/v1beta/openai/images/generations"],chat:{path:"/v1beta/openai/chat/completions",model:"gemini-3.1-flash-lite"},embeddings:{path:"/v1beta/openai/embeddings",model:"gemini-embedding-001"},hint:"An API key from Google AI Studio; the Gateway sends it as a bearer token. Apps call Gemini's OpenAI-shaped paths under /v1beta/openai.",secrets:[{name:"GEMINI_API_KEY",hint:"A Google AI Studio key restricted to the Gemini API only."}],smoke:{method:"GET",path:"/v1beta/openai/models",expect:[200],free:!0},rate:{note:"Per project, not per key: requests and tokens per minute and requests per day, by tier (Free, then Tiers 1 to 3)."},example:"describe what is in this product photo",verified:{on:"2026-10-25",how:"docs"},tags:["ai","llm","embeddings","images"]},mistral:{mode:"ai",label:"Mistral AI",description:"Mistral's models: chat, code completion, embeddings, moderation, OCR, speech.",auth:{kind:"bearer",secret:"MISTRAL_API_KEY"},docs:"https://console.mistral.ai",api:"https://docs.mistral.ai/api/",origin:"https://api.mistral.ai",inferenceRoutes:["/v1/chat/completions","/v1/fim/completions","/v1/embeddings","/v1/moderations","/v1/chat/moderations","/v1/classifications","/v1/chat/classifications","/v1/ocr","/v1/audio/transcriptions","/v1/audio/speech"],chat:{path:"/v1/chat/completions",model:"mistral-small-latest"},embeddings:{path:"/v1/embeddings",model:"mistral-embed"},aig:{slug:"mistral"},hint:"An API key from API Keys in the Mistral Studio console; the Gateway sends it as a bearer token. Free mode needs no card; usage and rate limits apply.",secrets:[{name:"MISTRAL_API_KEY",hint:"A key from API Keys in the Studio console, with an expiry date."}],smoke:{method:"GET",path:"/v1/models",expect:[200],free:!0},example:"extract the text from this scanned invoice",verified:{on:"2026-10-25",how:"docs"},tags:["ai","llm","ocr","embeddings"]},groq:{mode:"ai",label:"Groq",description:"Open models on Groq through OpenAI's API shape: chat, responses, transcription, speech.",auth:{kind:"bearer",secret:"GROQ_API_KEY"},docs:"https://console.groq.com/keys",api:"https://console.groq.com/docs/api-reference",origin:"https://api.groq.com",inferenceRoutes:["/openai/v1/chat/completions","/openai/v1/responses","/openai/v1/audio/transcriptions","/openai/v1/audio/translations","/openai/v1/audio/speech"],chat:{path:"/openai/v1/chat/completions",model:"openai/gpt-oss-20b"},aig:{slug:"groq",trim:"/openai/v1"},hint:"An API key from the Groq console; the Gateway sends it as a bearer token. Apps call the OpenAI-shaped paths under /openai/v1.",secrets:[{name:"GROQ_API_KEY",hint:"A key from the API Keys page of the Groq console."}],smoke:{method:"GET",path:"/openai/v1/models",expect:[200],free:!0},rate:{note:"Requests and tokens per minute and per day, per model and plan, for the whole organization; the console Limits page shows them."},example:"transcribe this voice memo",verified:{on:"2026-10-25",how:"docs"},tags:["ai","llm","speech"]},cohere:{mode:"ai",label:"Cohere",description:"Cohere's models: chat, embeddings, reranking, classification, transcription, document parsing.",auth:{kind:"bearer",secret:"COHERE_API_KEY"},docs:"https://dashboard.cohere.com/api-keys",api:"https://docs.cohere.com/reference/about",origin:"https://api.cohere.com",inferenceRoutes:["/v2/chat","/v2/embed","/v2/rerank","/v1/classify","/v2/audio/transcriptions","/v2/parse","/v1/tokenize","/v1/detokenize"],shape:"other",hint:"An API key from the Cohere dashboard; the Gateway sends it as a bearer token. Trial keys are free and limited; production keys are paid.",secrets:[{name:"COHERE_API_KEY",hint:"A production key; a trial key is limited to 1,000 calls a month."}],smoke:{method:"GET",path:"/v1/models",expect:[200],free:!0},rate:{note:"Production: 500 calls a minute for Command A chat and most endpoints, rerank 1,000. Trial: 20 chat calls a minute, 1,000 calls a month."},example:"rerank these search results for the query refund policy",verified:{on:"2026-10-25",how:"docs"},tags:["ai","llm","embeddings","rerank"]},voyage:{mode:"api_key",label:"Voyage AI",description:"Embeddings and rerankers for search and retrieval: text, code, multimodal, contextualized chunks.",auth:{kind:"bearer",secret:"VOYAGE_API_KEY"},docs:"https://dashboard.voyageai.com/organization/api-keys",api:"https://docs.voyageai.com/reference/embeddings-api",hosts:["api.voyageai.com"],data:"per-call",access:["read"],readMethods:["POST"],accountWidePaths:[["v1","files"],["v1","batches"]],hint:"A secret key from the Voyage dashboard; the Gateway sends it as a bearer token. Apps POST to /v1/embeddings, /v1/multimodalembeddings, /v1/contextualizedembeddings and /v1/rerank.",secrets:[{name:"VOYAGE_API_KEY",hint:"A secret key from API keys in the Voyage dashboard."}],smoke:{method:"GET",path:"/v1/batches",expect:[200],free:!0,note:"Lists the organization's batches, so the Gateway refuses it for apps; run it from the person's terminal."},cost:{unit:"token",note:"voyage-4 $0.06 per million tokens; the first 200 million tokens of the voyage-4 family are free per account."},rate:{perMinute:2e3,note:"2,000 requests a minute at tier 1, doubled at tier 2, tripled at tier 3; tokens per minute vary by model."},example:"embed these product descriptions for semantic search",verified:{on:"2026-10-25",how:"docs"},tags:["embeddings","rerank","search"]},perplexity:{mode:"api_key",label:"Perplexity",description:"Web-grounded answers from the Agent API, raw web search results, and embeddings.",auth:{kind:"bearer",secret:"PERPLEXITY_API_KEY"},docs:"https://console.perplexity.ai/project/keys",api:"https://docs.perplexity.ai/api-reference/agent-post",hosts:["api.perplexity.ai"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[["v1","batches"],["v1","files"],["v1","skills"],["v1","analytics"],["v2","analytics"],["generate_auth_token"],["revoke_auth_token"]],hint:"An API key from the Perplexity console; the Gateway sends it as a bearer token. Apps POST to /v1/agent for researched answers and /search for result lists, and GET /v1/agent/{id} to poll a background run.",secrets:[{name:"PERPLEXITY_API_KEY",hint:"An API key from the project's API keys page in the Perplexity console."}],smoke:{method:"GET",path:"/orchestrator/v1/models",expect:[200],free:!0},cost:{unit:"token",note:"Agent API per token plus tool fees (web_search $0.0025 a call); Search API $5 per 1,000 requests."},example:"research the latest pricing changes from our three main competitors",verified:{on:"2026-10-25",how:"docs"},tags:["search","ai","research"]},jina:{mode:"api_key",label:"Jina AI",description:"Reads web pages as Markdown, searches the web, and embeds and reranks text and images.",auth:{kind:"bearer",secret:"JINA_API_KEY"},docs:"https://jina.ai/api-dashboard/key-manager",api:"https://docs.jina.ai/",hosts:["api.jina.ai","r.jina.ai","s.jina.ai"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[["v1","batches"],["echo"]],hint:'An API key from the Jina API dashboard; the Gateway sends it as a bearer token. Reader is r.jina.ai (POST {"url": ...}), Search is s.jina.ai, and embeddings and rerank are on api.jina.ai.',secrets:[{name:"JINA_API_KEY",hint:"A key starting jina_, from Manage API Key in the Jina API dashboard."}],smoke:{method:"GET",host:"api.jina.ai",path:"/v1/batches",expect:[200],free:!0,note:"Lists the account's batch jobs, so the Gateway refuses it for apps; run it from the person's terminal."},cost:{unit:"token",note:"Billed in tokens against the account balance; GET /v1/models lists each model's price."},rate:{note:"Reader 500 requests a minute, Search 100, embeddings and rerank 500; premium keys get ten times more."},example:"read this article as Markdown and pull out the key claims",verified:{on:"2026-10-25",how:"docs"},tags:["scrape","search","embeddings","rerank"]},replicate:{mode:"api_key",label:"Replicate",description:"Runs open-source and official models by API: images, video, audio and language.",auth:{kind:"bearer",secret:"REPLICATE_API_TOKEN"},docs:"https://replicate.com/account/api-tokens",api:"https://replicate.com/docs/reference/http",hosts:["api.replicate.com"],data:"per-call",access:["read"],readMethods:["POST"],accountWidePaths:[["v1","account"],["v1","deployments"],["v1","files"],["v1","webhooks"],["trainings"]],hint:"An API token from Replicate's API tokens page; the Gateway sends it as a bearer token. Apps POST to /v1/models/{owner}/{name}/predictions or /v1/predictions with Prefer: wait (up to 60 seconds), or pass a webhook URL for longer runs.",secrets:[{name:"REPLICATE_API_TOKEN",hint:"An API token from the API tokens page of the Replicate account."}],smoke:{method:"GET",path:"/v1/account",expect:[200],free:!0,note:"Account-wide, so the Gateway refuses it for apps; run it from the person's terminal."},rate:{perMinute:600,note:"Creating predictions 600 a minute; every other endpoint 3,000 a minute."},example:"generate a product photo of a ceramic mug on a wooden table",verified:{on:"2026-10-25",how:"docs"},tags:["ai","images","video","audio"]},huggingface:{mode:"api_key",label:"Hugging Face Inference",description:"Open models from Hugging Face's inference providers through one router: chat, embeddings, images, speech.",auth:{kind:"bearer",secret:"HUGGINGFACE_API_TOKEN"},docs:"https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained",api:"https://huggingface.co/docs/inference-providers/index",hosts:["router.huggingface.co"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[],hint:"A fine-grained access token from Hugging Face settings with the Inference Providers permission; the Gateway sends it as a bearer token. Apps POST OpenAI-style chat to /v1/chat/completions, or other tasks under /<provider>/, such as /hf-inference/models/<model>.",secrets:[{name:"HUGGINGFACE_API_TOKEN",hint:"A fine-grained token with only the Make calls to Inference Providers permission."}],cost:{unit:"call",note:"Pay as you go at each provider's own rate with no markup; PRO accounts get $2 of compute credits a month."},example:"embed these support articles for semantic search",verified:{on:"2026-10-25",how:"docs"},tags:["ai","llm","embeddings","images"]}};var Ls={firecrawl:{mode:"api_key",label:"Firecrawl",description:"Scrapes, crawls, maps and searches the web, returning clean markdown or structured data.",auth:{kind:"bearer",secret:"FIRECRAWL_API_KEY"},docs:"https://www.firecrawl.dev/app/api-keys",api:"https://docs.firecrawl.dev/api-reference/introduction",hosts:["api.firecrawl.dev"],data:"per-call",access:["read","write"],readMethods:["GET","POST"],writeMethods:["DELETE"],accountWidePaths:[["team"],["crawl","active"],["monitor"],["agent"],["interact"],["support","ask"]],hint:"An API key from Firecrawl's API keys page; the Gateway sends it as a bearer token. Scrape, crawl, map, search and extract are POSTs and job status is a GET; cancelling a crawl or batch (DELETE) needs write.",secrets:[{name:"FIRECRAWL_API_KEY",hint:"An API key from Firecrawl's API keys page; it starts with fc-."}],smoke:{method:"GET",path:"/v2/team/credit-usage",expect:[200],free:!0,note:"Remaining credits; account-wide, so the Gateway refuses it for apps: run it from the person's terminal."},cost:{unit:"result",note:"Credits: 1 per page scraped or crawled, 1 per map call, 2 per 10 search results; JSON extraction and other options add more."},rate:{note:"Per team per minute, by plan: /scrape 10 on Free, 100 Hobby, 500 Standard, 5,000 Growth; /crawl 2, 20, 100, 1,000."},example:"scrape https://example.com/pricing into markdown",verified:{on:"2026-10-25",how:"docs"},tags:["scrape","crawl","search"]},exa:{mode:"api_key",label:"Exa",description:"Web search built for AI: search results, page contents, similar links and cited answers.",auth:{kind:"header",secret:"EXA_API_KEY",header:"x-api-key"},docs:"https://dashboard.exa.ai/api-keys",api:"https://exa.ai/docs/reference/search",hosts:["api.exa.ai"],data:"per-call",access:["read"],readMethods:["POST"],accountWidePaths:[["websets"],["monitors"],["agent"],["batches"]],hint:"An API key from the Exa dashboard (the free tier gives $10 of credit a month); the Gateway sends it in the x-api-key header. Search, contents, find-similar and answer are POSTs.",secrets:[{name:"EXA_API_KEY",hint:"An API key from the API keys page of the Exa dashboard."}],smoke:{method:"GET",path:"/websets/v0/teams/me",expect:[200],free:!0,note:"Team info under the Websets API (the docs page leaves out the /websets prefix); account-wide, so run it from the person's terminal."},cost:{unit:"call",usd:.007,note:"Search $7 per 1k (auto and fast; lite $4), contents $1 per 1k pages, answer $5 per 1k; up to 10 results included."},rate:{perSecond:10,note:"Per team: /search and /answer 10 QPS, deep search 5, /contents 100."},example:"find recent articles about solid-state batteries",verified:{on:"2026-10-25",how:"docs"},tags:["search"]},tavily:{mode:"api_key",label:"Tavily",description:"Web search, page extraction, crawling and site maps for AI agents, plus research reports.",auth:{kind:"bearer",secret:"TAVILY_API_KEY"},docs:"https://app.tavily.com",api:"https://docs.tavily.com/documentation/api-reference/endpoint/search",hosts:["api.tavily.com"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[["usage"],["logs"],["org-usage"]],hint:"An API key from app.tavily.com (1,000 free credits a month); the Gateway sends it as a bearer token. Search, extract, crawl, map and research are POSTs; a research result is a GET.",secrets:[{name:"TAVILY_API_KEY",hint:"An API key from the Tavily dashboard; it starts with tvly-."}],smoke:{method:"GET",path:"/usage",expect:[200],free:!0,note:"Key and account usage, not an endpoint that costs credits; account-wide, so run it from the person's terminal (10 calls per 10 minutes)."},cost:{unit:"call",usd:.008,note:"Pay as you go $0.008 per credit: basic search 1 credit, advanced 2; extract 1 credit per 5 URLs; map 1 per 10 pages."},rate:{perMinute:100,note:"Development keys 100 per minute, production keys 1,000; crawl 100 and research 20 per minute for both."},example:"search the web for this week's news on EU AI rules",verified:{on:"2026-10-25",how:"docs"},tags:["search","scrape"]},serper:{mode:"api_key",label:"Serper",description:"Google search results as JSON: web, news, images, places, shopping, scholar and patents.",auth:{kind:"header",secret:"SERPER_API_KEY",header:"X-API-KEY"},docs:"https://serper.dev/api-keys",api:"https://serper.dev/playground",hosts:["google.serper.dev","scrape.serper.dev"],data:"per-call",access:["read"],readMethods:["POST"],accountWidePaths:[],hint:'An API key from serper.dev (2,500 free queries to start); the Gateway sends it in the X-API-KEY header. Every search is a POST to google.serper.dev/<type> (search, news, images, places, \u2026) with a JSON body such as {"q": "\u2026"}.',secrets:[{name:"SERPER_API_KEY",hint:"The API key on serper.dev's API keys page."}],cost:{unit:"call",usd:.001,note:"Prepaid credits, one per successful query: $1.00 per 1k on the 50k pack, down to $0.30 per 1k on the largest."},rate:{perSecond:50,note:"Starter credits 50 queries per second; Standard 100, Scale 200, Ultimate 300."},example:"get the top Google results for best project management software",verified:!1,tags:["search","serp"]},"brave-search":{mode:"api_key",label:"Brave Search",description:"Brave's independent web index: web, news, images, videos, places, LLM context and answers.",auth:{kind:"header",secret:"BRAVE_SEARCH_API_KEY",header:"X-Subscription-Token"},docs:"https://api-dashboard.search.brave.com/app/keys",api:"https://api-dashboard.search.brave.com/documentation",hosts:["api.search.brave.com"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[],hint:"Activate a plan (it includes $5 of free credit a month), then create a key under API Keys; the Gateway sends it in the X-Subscription-Token header. Searches are GETs (POST works too); answers are a POST to /res/v1/chat/completions.",secrets:[{name:"BRAVE_SEARCH_API_KEY",hint:"A key from the API Keys section of the Brave Search API dashboard, made after activating a plan."}],cost:{unit:"call",usd:.005,note:"Search $5 per 1k requests; Answers $4 per 1k plus $5 per million tokens; $5 free credit a month; only successful calls count."},rate:{perSecond:50,note:"Search plan 50 queries per second; Answers 2 per second."},example:"search the web for the latest Cloudflare Workers release notes",verified:{on:"2026-10-25",how:"docs"},tags:["search"]},apify:{mode:"api_key",label:"Apify",description:"Runs Apify Actors (ready-made scrapers and automations) and reads their datasets and stores.",auth:{kind:"bearer",secret:"APIFY_API_TOKEN"},docs:"https://console.apify.com/settings/integrations",api:"https://docs.apify.com/api/v2",hosts:["api.apify.com"],data:"account",access:["read","write"],readMethods:["GET","HEAD"],writeMethods:["POST","PUT","DELETE"],accountWidePaths:[["users"],["webhooks"],["webhook-dispatches"],["env-vars"]],hint:"The API token from Apify Console, Settings > API & Integrations; the Gateway sends it as a bearer token. Reading Actors, runs and datasets needs read; starting a run is a POST, so it needs write.",secrets:[{name:"APIFY_API_TOKEN",hint:"The API token under Settings > API & Integrations in Apify Console."}],smoke:{method:"GET",path:"/v2/users/me",expect:[200],free:!0,note:"The docs' verify call; account-wide, so the Gateway refuses it for apps: run it from the person's terminal."},rate:{perSecond:60,note:"60 requests per second per resource (one Actor, run, dataset or store); 250,000 requests per minute per user overall."},example:"run the Google Maps scraper Actor for coffee shops in Austin and list the results",verified:{on:"2026-10-25",how:"docs"},tags:["scrape","automation"]},deepgram:{mode:"api_key",label:"Deepgram",description:"Speech to text, text to speech and text analysis.",auth:{kind:"bearer",secret:"DEEPGRAM_API_KEY",scheme:"Token"},docs:"https://console.deepgram.com/",api:"https://developers.deepgram.com/reference/deepgram-api-overview",hosts:["api.deepgram.com","api.eu.deepgram.com","api.au.deepgram.com","api.in.deepgram.com"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[["projects"],["auth","grant"]],hint:"An API key from the Deepgram Console; the Gateway sends it as Authorization: Token <key>, and the EU, Australia and India hosts take the same key. Transcription (/v1/listen), speech (/v1/speak) and text analysis (/v1/read) are POSTs.",secrets:[{name:"DEEPGRAM_API_KEY",hint:"A project API key created in the Deepgram Console."}],smoke:{method:"GET",path:"/v1/models",expect:[200],free:!0,note:"Lists the public models; it needs the key and processes no audio."},cost:{unit:"call",note:"Nova-3 pre-recorded $0.0043 per audio minute (pay as you go); Aura-2 speech $0.030 per 1k characters; $200 free credit."},rate:{note:"Concurrency per project on pay as you go: 50 pre-recorded transcriptions, 15 text-to-speech requests."},example:"transcribe this podcast episode and label the speakers",verified:{on:"2026-10-25",how:"docs"},tags:["speech","transcription"]},elevenlabs:{mode:"api_key",label:"ElevenLabs",description:"Text to speech, speech to text, sound effects, music and voice changing.",auth:{kind:"header",secret:"ELEVENLABS_API_KEY",header:"xi-api-key"},docs:"https://elevenlabs.io/app/settings/api-keys",api:"https://elevenlabs.io/docs/api-reference/introduction",hosts:["api.elevenlabs.io"],data:"per-call",access:["read"],readMethods:["GET","POST"],accountWidePaths:[["v1","user"],["v1","usage"],["v1","workspace"],["v1","workspaces"],["v1","service-accounts"],["v1","history"],["v1","single-use-token"],["v1","convai"],["v1","dubbing"],["v1","studio"],["v1","pronunciation-dictionaries"],["v1","voices","add"],["v1","voices","pvc"],["v1","voices","collections"],["edit"],["replicate-to-isolated-environment"],["v1","text-to-voice"],["v1","audio-native"],["v1","productions"],["v1","speech-engine"],["v1","music","finetunes"],["v1","flows"],["v1","assets"],["v1","audio-isolation","history"]],hint:"An API key from ElevenLabs' API keys page; the Gateway sends it in the xi-api-key header. Speech, transcription and sound generation are POSTs; listing voices and models are GETs.",secrets:[{name:"ELEVENLABS_API_KEY",hint:"An API key from ElevenLabs' API keys page; it can be scoped to the endpoints the app uses and given a credit cap."}],smoke:{method:"GET",path:"/v1/models",expect:[200],free:!0,note:"The first request in ElevenLabs' authentication docs; it generates nothing."},example:"read this paragraph aloud in a calm narrator voice",verified:{on:"2026-10-25",how:"docs"},tags:["speech","audio"]},assemblyai:{mode:"api_key",label:"AssemblyAI",description:"Transcribes recorded audio and video, with speaker labels, redaction and subtitles.",auth:{kind:"header",secret:"ASSEMBLYAI_API_KEY",header:"Authorization"},docs:"https://www.assemblyai.com/dashboard/home",api:"https://www.assemblyai.com/docs",hosts:["api.assemblyai.com","api.eu.assemblyai.com"],data:"account",access:["read","write"],readMethods:["GET","POST"],writeMethods:["DELETE"],accountWidePaths:[],hint:"The API key from your AssemblyAI dashboard; the Gateway sends it as the whole Authorization header, with no Bearer word. Audio is submitted with a POST to /v2/transcript and the app polls GET /v2/transcript/<id>; deleting a transcript needs write.",secrets:[{name:"ASSEMBLYAI_API_KEY",hint:"The API key on your AssemblyAI dashboard."}],smoke:{method:"GET",path:"/v2/transcript?limit=1",expect:[200],free:!0,note:"Lists the account's latest transcript; it transcribes nothing."},cost:{unit:"call",note:"Per hour of audio submitted: Universal-3.5 Pro $0.21, Universal-2 $0.15; the free tier covers up to 185 hours of pre-recorded audio."},rate:{perMinute:4e3,note:"20,000 requests per 5 minutes per account; 5 transcriptions in parallel on free accounts, 200 or more on paid."},example:"transcribe this sales call recording with speaker labels",verified:{on:"2026-10-25",how:"docs"},tags:["speech","transcription"]},newsapi:{mode:"api_key",label:"NewsAPI",description:"Searches news articles and live headlines from over 150,000 sources.",auth:{kind:"header",secret:"NEWSAPI_API_KEY",header:"X-Api-Key"},docs:"https://newsapi.org/register",api:"https://newsapi.org/docs",hosts:["newsapi.org"],data:"per-call",access:["read"],readMethods:["GET"],accountWidePaths:[],hint:"An API key from newsapi.org/register; the Gateway sends it in the X-Api-Key header. The free Developer plan allows 100 requests a day, delays articles by 24 hours and is for development only; production needs a paid plan.",secrets:[{name:"NEWSAPI_API_KEY",hint:"The API key NewsAPI shows after you register."}],cost:{unit:"call",usd:.0018,note:"Developer plan free (100 requests a day, development only); Business $449 a month for 250,000 requests, then $0.0018 each."},rate:{perDay:100,note:"Developer plan; Business includes 250,000 requests a month, Advanced 2,000,000."},example:"find today's top business headlines in the US",verified:{on:"2026-10-25",how:"docs"},tags:["news"]}};var Ms={...Cs,...Ns,...$s,...Ds,...Ls};var x={openai:{mode:"ai",label:"OpenAI",description:"OpenAI's models: responses, chat, embeddings, audio, images.",auth:{kind:"bearer",secret:"OPENAI_API_KEY"},docs:"https://platform.openai.com/api-keys",api:"https://platform.openai.com/docs/api-reference",setup:"setup/openai.md",origin:"https://api.openai.com",inferenceRoutes:["/v1/responses","/v1/chat/completions","/v1/embeddings","/v1/audio/speech","/v1/audio/transcriptions","/v1/audio/translations","/v1/images/generations","/v1/images/edits","/v1/images/variations"],unstoredRoutes:["/v1/responses","/v1/chat/completions"],extraRoutes:!0,chat:{path:"/v1/chat/completions",model:"gpt-6-luna"},embeddings:{path:"/v1/embeddings",model:"text-embedding-3-small"},aig:{slug:"openai",trim:"/v1"},hint:"A secret key from the API keys page; the Gateway puts it on every call as a bearer token.",verified:{on:"2026-10-25",how:"live"}},openrouter:{mode:"ai",label:"OpenRouter",description:"One key for many models, through OpenAI's API shape.",auth:{kind:"bearer",secret:"OPENROUTER_API_KEY"},docs:"https://openrouter.ai/settings/keys",api:"https://openrouter.ai/docs",setup:"setup/openrouter.md",origin:"https://openrouter.ai",inferenceRoutes:["/api/v1/chat/completions","/api/v1/completions","/api/v1/responses","/api/v1/embeddings"],chat:{path:"/api/v1/chat/completions",model:"anthropic/claude-haiku-5.5"},embeddings:{path:"/api/v1/embeddings",model:"openai/text-embedding-3-small"},aig:{slug:"openrouter",trim:"/api"},hint:"An API key from OpenRouter's keys page; the Gateway puts it on every call as a bearer token.",cost:{unit:"token",responseField:"usage.cost",note:"The answer's usage.cost is the call's price in USD, per model."},verified:{on:"2026-10-25",how:"live"}},"workers-ai":{mode:"ai",label:"Workers AI",description:"Cloudflare's models, in the Gateway's own account.",auth:{kind:"bearer",secret:"WORKERS_AI_API_TOKEN"},docs:"https://dash.cloudflare.com/profile/api-tokens",api:"https://developers.cloudflare.com/workers-ai/",setup:"setup/workers-ai.md",origin:"https://api.cloudflare.com",alsoNeeds:["CLOUDFLARE_ACCOUNT_ID"],basePath:"/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai",inferenceRoutes:["/v1/chat/completions","/v1/embeddings","/v1/responses"],normalize:"workers-ai",chat:{path:"/v1/chat/completions",model:"@cf/meta/llama-4-scout-17b-16e-instruct"},embeddings:{path:"/v1/embeddings",model:"@cf/baai/bge-m3"},aig:{slug:"workers-ai",header:!0},hint:"A Cloudflare API token with Workers AI Read (the Workers AI page's prefilled token); the account is the Gateway's own.",verified:{on:"2026-10-25",how:"live"}},"ai-gateway":{mode:"ai",kind:"proxy",label:"Cloudflare AI Gateway",description:"Cloudflare's proxy in front of the other AI providers: logs, caching, rate limits and spend, with each provider's own key.",auth:{kind:"header",header:"cf-aig-authorization",prefix:"Bearer ",secret:"AI_GATEWAY_API_KEY"},authOptional:!0,docs:"https://dash.cloudflare.com/?to=/:account/ai/ai-gateway",api:"https://developers.cloudflare.com/ai-gateway/",setup:"setup/ai-gateway.md",origin:"https://gateway.ai.cloudflare.com",alsoNeeds:["CLOUDFLARE_ACCOUNT_ID","AI_GATEWAY_ID"],basePath:"/v1/{CLOUDFLARE_ACCOUNT_ID}/{AI_GATEWAY_ID}",inferenceRoutes:[],hint:"The gateway's id from the AI Gateway page (everyapp ai gateway on makes one named everyapp); AI_GATEWAY_API_KEY only for an authenticated gateway, sent as cf-aig-authorization.",secrets:[{name:"AI_GATEWAY_ID",hint:"The AI Gateway's id (its name in the dashboard), in the Gateway's own Cloudflare account."},{name:"AI_GATEWAY_API_KEY",hint:"An AI Gateway token with Run permission, only when the gateway is authenticated; leave unset for an open gateway."}],verified:{on:"2026-10-25",how:"docs"}},dataforseo:{mode:"api_key",label:"DataForSEO",description:"SEO data: keyword metrics, live search results, domain rankings, backlinks.",auth:{kind:"basic",secret:"DATAFORSEO_API_KEY",as:"pair"},docs:"https://app.dataforseo.com/api-access",api:"https://docs.dataforseo.com/v3/",setup:"setup/dataforseo.md",hosts:["api.dataforseo.com","sandbox.dataforseo.com"],access:["read"],readMethods:["GET","POST"],accountWidePaths:[["tasks_ready"],["tasks_fixed"],["id_list"],["errors"],["appendix","user_data"],["appendix","webhook_resend"]],hint:"The API login and password from API Access, as login:password (or that pair base64-encoded); the Gateway sends them as HTTP Basic.",secrets:[{name:"DATAFORSEO_API_KEY",hint:"login:password, or its base64; never the dashboard sign-in password."}],cost:{unit:"call",responseField:"cost",note:"A Google SERP $0.002 per 10 results; a Labs task $0.012 plus $0.00012 per item."},smoke:{method:"GET",path:"/v3/appendix/user_data",expect:[200],free:!0,note:"Account-wide, so the Gateway refuses it for apps; run it from the person's terminal."},example:"find keyword ideas for a page about running shoes",verified:{on:"2026-10-25",how:"live"}},context:{mode:"api_key",label:"Context.dev",description:"Scrapes and renders web pages, JavaScript included.",auth:{kind:"bearer",secret:"CONTEXT_API_KEY"},docs:"https://context.dev/",setup:"setup/context.md",hosts:["api.context.dev"],access:["read"],readMethods:["GET","POST"],accountWidePaths:[],hint:"An API key from the Context.dev dashboard; the Gateway puts it on every call as a bearer token.",verified:{on:"2026-10-25",how:"live"}},email:{mode:"service",label:"Email",access:["write"],routes:{send:["POST"]},settings:["EMAIL_FROM","EMAIL_FROM_NAME"],optionalSettings:["EMAIL_REST_API_TOKEN","CLOUDFLARE_ACCOUNT_ID","RESEND_API_KEY","EMAIL_PROVIDER"],setup:"setup/email.md"},members:{mode:"service",label:"Members",access:["read"],routes:{list:["GET"]},settings:[],optionalSettings:[]},linkedin:{mode:"oauth_client",label:"LinkedIn",secrets:{clientId:"LINKEDIN_CLIENT_ID",clientSecret:"LINKEDIN_CLIENT_SECRET"},token:[{host:"www.linkedin.com",path:"/oauth/v2/accessToken",methods:["POST"],inject:"form"}],access:["write"],console:"https://www.linkedin.com/developers/apps",authorize:{url:"https://www.linkedin.com/oauth/v2/authorization",scopes:["openid","profile","w_member_social","r_basicprofile","rw_organization_admin","w_organization_social","r_organization_social"]},api:["api.linkedin.com"],redirectPaths:["/integrations/social/linkedin","/integrations/social/linkedin-page"]},facebook:{mode:"oauth_client",label:"Facebook",secrets:{clientId:"FACEBOOK_APP_ID",clientSecret:"FACEBOOK_APP_SECRET"},token:[{host:"graph.facebook.com",path:/^\/v\d+\.\d+\/oauth\/access_token$/,methods:["GET","POST"],inject:"query"}],access:["write"],console:"https://developers.facebook.com/apps",authorize:{url:"https://www.facebook.com/v25.0/dialog/oauth",scopes:["pages_show_list","business_management","pages_manage_posts","pages_manage_engagement","pages_read_engagement","read_insights","instagram_basic","instagram_content_publish","instagram_manage_comments","instagram_manage_insights"]},api:["graph.facebook.com","graph.instagram.com"],redirectPaths:["/integrations/social/facebook","/integrations/social/instagram"]},instagram:{mode:"oauth_client",label:"Instagram",secrets:{clientId:"INSTAGRAM_APP_ID",clientSecret:"INSTAGRAM_APP_SECRET"},token:[{host:"api.instagram.com",path:"/oauth/access_token",methods:["POST"],inject:"form"},{host:"graph.instagram.com",path:"/access_token",methods:["GET"],inject:"query"}],access:["write"],console:"https://developers.facebook.com/apps",authorize:{url:"https://www.instagram.com/oauth/authorize",scopes:["instagram_business_basic","instagram_business_content_publish","instagram_business_manage_comments","instagram_business_manage_insights"]},api:["graph.instagram.com"],redirectPaths:["/integrations/social/instagram-standalone"]},threads:{mode:"oauth_client",label:"Threads",secrets:{clientId:"THREADS_APP_ID",clientSecret:"THREADS_APP_SECRET"},token:[{host:"graph.threads.net",path:"/oauth/access_token",methods:["GET","POST"],inject:"query"},{host:"graph.threads.net",path:"/access_token",methods:["GET"],inject:"query"}],access:["write"],console:"https://developers.facebook.com/apps",authorize:{url:"https://threads.net/oauth/authorize",scopes:["threads_basic","threads_content_publish","threads_manage_replies","threads_manage_insights"]},api:["graph.threads.net"],redirectPaths:["/integrations/social/threads"]},youtube:{mode:"oauth_client",label:"YouTube",secrets:{clientId:"YOUTUBE_CLIENT_ID",clientSecret:"YOUTUBE_CLIENT_SECRET"},token:[{host:"oauth2.googleapis.com",path:"/token",methods:["POST"],inject:"form"}],access:["write"],console:"https://console.cloud.google.com/apis/credentials",setup:"setup/google.md",authorize:{url:"https://accounts.google.com/o/oauth2/v2/auth",scopes:["https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/youtube","https://www.googleapis.com/auth/youtube.force-ssl","https://www.googleapis.com/auth/youtube.readonly","https://www.googleapis.com/auth/youtube.upload","https://www.googleapis.com/auth/youtubepartner","https://www.googleapis.com/auth/yt-analytics.readonly","https://www.googleapis.com/auth/business.manage"]},api:["www.googleapis.com","youtubeanalytics.googleapis.com","mybusinessaccountmanagement.googleapis.com","mybusinessbusinessinformation.googleapis.com","mybusiness.googleapis.com","businessprofileperformance.googleapis.com"],redirectPaths:["/integrations/social/youtube","/integrations/social/gmb"]},tiktok:{mode:"oauth_client",label:"TikTok",secrets:{clientId:"TIKTOK_CLIENT_ID",clientSecret:"TIKTOK_CLIENT_SECRET"},token:[{host:"open.tiktokapis.com",path:"/v2/oauth/token/",methods:["POST"],inject:"form",params:{clientId:"client_key"}}],access:["write"],console:"https://developers.tiktok.com/apps",authorize:{url:"https://www.tiktok.com/v2/auth/authorize/",scopes:["video.list","user.info.basic","video.publish","video.upload","user.info.profile","user.info.stats"]},api:["open.tiktokapis.com"],redirectPaths:["/integrations/social/tiktok"]},"tiktok-business":{mode:"oauth_client",label:"TikTok Business",secrets:{clientId:"TIKTOK_BUSINESS_CLIENT_ID",clientSecret:"TIKTOK_BUSINESS_CLIENT_SECRET"},token:[{host:"business-api.tiktok.com",path:"/open_api/v1.3/tt_user/oauth2/token/",methods:["POST"],inject:"json"},{host:"business-api.tiktok.com",path:"/open_api/v1.3/tt_user/oauth2/refresh_token/",methods:["POST"],inject:"json"}],access:["write"],console:"https://business-api.tiktok.com/portal/apps",authorize:{url:"https://www.tiktok.com/v2/auth/authorize/",scopes:["user.info.basic","user.info.username","user.info.stats","video.list","video.upload","video.publish"]},api:["business-api.tiktok.com"],redirectPaths:["/integrations/social/tiktok-business/"]},reddit:{mode:"oauth_client",label:"Reddit",secrets:{clientId:"REDDIT_CLIENT_ID",clientSecret:"REDDIT_CLIENT_SECRET"},token:[{host:"www.reddit.com",path:"/api/v1/access_token",methods:["POST"],inject:"basic"}],access:["write"],console:"https://www.reddit.com/prefs/apps",authorize:{url:"https://www.reddit.com/api/v1/authorize",scopes:["read","identity","submit","flair"]},api:["oauth.reddit.com"],redirectPaths:["/integrations/social/reddit"]},pinterest:{mode:"oauth_client",label:"Pinterest",secrets:{clientId:"PINTEREST_CLIENT_ID",clientSecret:"PINTEREST_CLIENT_SECRET"},token:[{host:"api.pinterest.com",path:"/v5/oauth/token",methods:["POST"],inject:"basic"}],access:["write"],console:"https://developers.pinterest.com/apps/",authorize:{url:"https://www.pinterest.com/oauth/",scopes:["boards:read","boards:write","pins:read","pins:write","user_accounts:read"]},api:["api.pinterest.com"],redirectPaths:["/integrations/social/pinterest"]},discord:{mode:"oauth_client",label:"Discord",secrets:{clientId:"DISCORD_CLIENT_ID",clientSecret:"DISCORD_CLIENT_SECRET"},token:[{host:"discord.com",path:"/api/oauth2/token",methods:["POST"],inject:"basic"}],access:["write"],console:"https://discord.com/developers/applications",authorize:{url:"https://discord.com/oauth2/authorize",scopes:["bot","identify","guilds"]},api:["discord.com"],redirectPaths:["/integrations/social/discord"],flow:{tokenUrl:"https://discord.com/api/oauth2/token",revokeUrl:"https://discord.com/api/oauth2/token/revoke",pkce:!0,scopeDialect:"space",identity:{url:"https://discord.com/api/users/@me",label:"username",id:"id"}}},slack:{mode:"oauth_client",label:"Slack",secrets:{clientId:"SLACK_CLIENT_ID",clientSecret:"SLACK_CLIENT_SECRET"},token:[{host:"slack.com",path:"/api/oauth.v2.access",methods:["POST"],inject:"form"}],access:["write"],console:"https://api.slack.com/apps",setup:"setup/slack.md",authorize:{url:"https://slack.com/oauth/v2/authorize",scopes:["channels:read","groups:read","users:read","users:read.email","chat:write","chat:write.public","chat:write.customize","channels:join","channels:manage","groups:write","channels:write.invites","groups:write.invites","im:write","files:write","channels:write"]},scopePolicy:{dialect:"slack",grantTypes:[null,"refresh_token"],requestScope:"keep",alwaysRequested:[],tolerated:[],deniedSegments:[],sets:{"channels.read":{label:"Channels (read-only)",access:"read",scopes:["channels:read","groups:read"],routes:[{host:"slack.com",paths:["/api/conversations.list","/api/conversations.info","/api/conversations.members","/api/users.conversations"],posts:[/^\/api\/conversations\.(list|info|members)$/,/^\/api\/users\.conversations$/]}]},"users.read":{label:"Members (read-only)",access:"read",scopes:["users:read"],routes:[{host:"slack.com",paths:["/api/users.list","/api/users.info","/api/users.getPresence","/api/bots.info"],posts:[/^\/api\/users\.(list|info|getPresence)$/,/^\/api\/bots\.info$/]}]},"users.email":{label:"Members' email addresses (read-only)",access:"read",scopes:["users:read.email"],routes:[{host:"slack.com",paths:["/api/users.lookupByEmail"],posts:[/^\/api\/users\.lookupByEmail$/]}]},"messages.write":{label:"Messages (post as the app)",access:"write",scopes:["chat:write","chat:write.public","chat:write.customize"],routes:[{host:"slack.com",paths:["/api/chat.scheduledMessages.list"],posts:[/^\/api\/chat\.(postMessage|postEphemeral|update|delete|scheduleMessage|deleteScheduledMessage|scheduledMessages\.list)$/]}]},"channels.join":{label:"Channels (join public ones)",access:"write",scopes:["channels:join"],routes:[{host:"slack.com",paths:[],posts:[/^\/api\/conversations\.join$/]}]},"channels.manage":{label:"Channels (create, manage and invite to; open DMs)",access:"write",scopes:["channels:manage","groups:write","channels:write.invites","groups:write.invites","im:write"],routes:[{host:"slack.com",paths:[],posts:[/^\/api\/conversations\.(create|rename|archive|unarchive|invite|open|kick|leave|setTopic|setPurpose|mark)$/]}]},"files.write":{label:"Files (upload)",access:"write",scopes:["files:write"],routes:[{host:"slack.com",paths:[],posts:[/^\/api\/files\.(getUploadURLExternal|completeUploadExternal)$/]}]},"user-channels.manage":{label:"Channels (as the installing person: read, manage, invite to)",access:"write",scopes:[],userScopes:["channels:read","channels:write","groups:read","groups:write"],routes:[{host:"slack.com",paths:["/api/conversations.list","/api/conversations.info","/api/conversations.members","/api/users.conversations"],posts:[/^\/api\/conversations\.(list|info|members|create|rename|archive|unarchive|invite|kick|leave|setTopic|setPurpose|mark)$/,/^\/api\/users\.conversations$/]}]}}},api:["slack.com"],redirectPaths:["/integrations/social/slack","/integrations/slack/callback"],flow:{tokenUrl:"https://slack.com/api/oauth.v2.access",revokeUrl:"https://slack.com/api/auth.revoke",pkce:!1,scopeDialect:"slack",identity:{url:"https://slack.com/api/auth.test",label:"team",id:"user_id"}}},mastodon:{mode:"oauth_client",label:"Mastodon",secrets:{clientId:"MASTODON_CLIENT_ID",clientSecret:"MASTODON_CLIENT_SECRET"},token:[{path:"/oauth/token",methods:["POST"],inject:"form"}],hostSetting:"MASTODON_URL",defaultOrigin:"https://mastodon.social",access:["write"],console:"/settings/applications",authorize:{url:"/oauth/authorize",scopes:["write:statuses","profile","write:media"]},api:[],redirectPaths:["/integrations/social/mastodon"]},kick:{mode:"oauth_client",label:"Kick",secrets:{clientId:"KICK_CLIENT_ID",clientSecret:"KICK_CLIENT_SECRET"},token:[{host:"id.kick.com",path:"/oauth/token",methods:["POST"],inject:"form"}],access:["write"],console:"https://kick.com/settings/developer",authorize:{url:"https://id.kick.com/oauth/authorize",scopes:["chat:write","user:read","channel:read"]},api:["api.kick.com"],redirectPaths:["/integrations/social/kick"]},twitch:{mode:"oauth_client",label:"Twitch",secrets:{clientId:"TWITCH_CLIENT_ID",clientSecret:"TWITCH_CLIENT_SECRET"},token:[{host:"id.twitch.tv",path:"/oauth2/token",methods:["POST"],inject:"form"}],access:["write"],console:"https://dev.twitch.tv/console/apps",authorize:{url:"https://id.twitch.tv/oauth2/authorize",scopes:["user:write:chat","user:read:chat","moderator:manage:announcements"]},api:["api.twitch.tv"],redirectPaths:["/integrations/social/twitch"]},tumblr:{mode:"oauth_client",label:"Tumblr",secrets:{clientId:"TUMBLR_CLIENT_ID",clientSecret:"TUMBLR_CLIENT_SECRET"},token:[{host:"api.tumblr.com",path:"/v2/oauth2/token",methods:["POST"],inject:"form"}],access:["write"],console:"https://www.tumblr.com/oauth/apps",authorize:{url:"https://www.tumblr.com/oauth2/authorize",scopes:["write","offline_access"]},api:["api.tumblr.com"],redirectPaths:["/integrations/social/tumblr"]},dribbble:{mode:"oauth_client",label:"Dribbble",secrets:{clientId:"DRIBBBLE_CLIENT_ID",clientSecret:"DRIBBBLE_CLIENT_SECRET"},token:[{host:"dribbble.com",path:"/oauth/token",methods:["POST"],inject:"query"}],access:["write"],console:"https://dribbble.com/account/applications",authorize:{url:"https://dribbble.com/oauth/authorize",scopes:["public","upload"]},api:["api.dribbble.com"],redirectPaths:["/integrations/social/dribbble"]},"google-workspace":{mode:"oauth_client",label:"Google (Gmail, Calendar, Search Console and Analytics)",secrets:{clientId:"GOOGLE_WORKSPACE_CLIENT_ID",clientSecret:"GOOGLE_WORKSPACE_CLIENT_SECRET"},token:[{host:"oauth2.googleapis.com",path:"/token",methods:["POST"],inject:"form"}],access:["write"],console:"https://console.cloud.google.com/apis/credentials",setup:"setup/google.md",authorize:{url:"https://accounts.google.com/o/oauth2/v2/auth",scopes:["openid","email","profile","https://www.googleapis.com/auth/gmail.readonly","https://www.googleapis.com/auth/calendar.readonly","https://www.googleapis.com/auth/webmasters.readonly","https://www.googleapis.com/auth/analytics.readonly"]},scopePolicy:{dialect:"google",grantTypes:["authorization_code","refresh_token"],requestScope:"drop",alwaysRequested:[],tolerated:["openid","email","profile","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile"],deniedSegments:["batch","measurementProtocolSecrets"],sets:{identity:{label:"Google account (who you are)",access:"read",scopes:["openid","email","profile"],routes:[{host:"openidconnect.googleapis.com",paths:["/v1/userinfo"]},{host:"www.googleapis.com",paths:["/oauth2/v2/userinfo","/oauth2/v3/userinfo","/userinfo/v2/me"]}]},"gmail.read":{label:"Gmail (read-only)",access:"read",scopes:["https://www.googleapis.com/auth/gmail.readonly"],routes:[{host:"gmail.googleapis.com",paths:["/gmail/v1/users/"],posts:[/^\/gmail\/v1\/users\/[^/]+\/(watch|stop)$/]}]},"calendar.read":{label:"Google Calendar (read-only)",access:"read",scopes:["https://www.googleapis.com/auth/calendar.readonly"],routes:[{host:"www.googleapis.com",paths:["/calendar/v3/"],posts:[/^\/calendar\/v3\/freeBusy$/,/^\/calendar\/v3\/calendars\/[^/]+\/events\/watch$/,/^\/calendar\/v3\/users\/me\/calendarList\/watch$/,/^\/calendar\/v3\/channels\/stop$/]}]},"search-console.read":{label:"Search Console (read-only)",access:"read",scopes:["https://www.googleapis.com/auth/webmasters.readonly"],routes:[{host:"www.googleapis.com",paths:["/webmasters/v3/"],posts:[/^\/webmasters\/v3\/sites\/[^/]+\/searchAnalytics\/query$/]},{host:"searchconsole.googleapis.com",paths:["/webmasters/v3/"],posts:[/^\/webmasters\/v3\/sites\/[^/]+\/searchAnalytics\/query$/,/^\/v1\/urlInspection\/index:inspect$/]}]},"analytics.read":{label:"Google Analytics (read-only)",access:"read",scopes:["https://www.googleapis.com/auth/analytics.readonly"],routes:[{host:"analyticsdata.googleapis.com",paths:["/v1beta/properties/"],posts:[/^\/v1beta\/properties\/[^/]+:(runReport|batchRunReports|runPivotReport|batchRunPivotReports|runRealtimeReport|checkCompatibility)$/]},{host:"analyticsadmin.googleapis.com",paths:["/v1beta/accountSummaries","/v1beta/accounts","/v1beta/accounts/","/v1beta/properties","/v1beta/properties/","/v1alpha/properties/"]}]}}},api:["gmail.googleapis.com","www.googleapis.com","searchconsole.googleapis.com","analyticsdata.googleapis.com","analyticsadmin.googleapis.com","openidconnect.googleapis.com"],redirectPaths:["/integrations/google/callback"],flow:{tokenUrl:"https://oauth2.googleapis.com/token",pkce:!0,scopeDialect:"google",authorizeParams:{access_type:"offline",prompt:"consent"},identity:{url:"https://openidconnect.googleapis.com/v1/userinfo",label:"email",id:"sub"}}},"microsoft-365":{mode:"oauth_client",label:"Microsoft 365 (Outlook mail and calendar)",secrets:{clientId:"MICROSOFT_365_CLIENT_ID",clientSecret:"MICROSOFT_365_CLIENT_SECRET"},token:[{host:"login.microsoftonline.com",path:"/common/oauth2/v2.0/token",methods:["POST"],inject:"form"}],access:["write"],console:"https://entra.microsoft.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",setup:"setup/microsoft-365.md",authorize:{url:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",scopes:["offline_access","User.Read","Mail.Read","Calendars.Read"]},scopePolicy:{dialect:"microsoft",grantTypes:["authorization_code","refresh_token"],requestScope:"replace",alwaysRequested:["offline_access"],tolerated:["openid","profile","email","offline_access","User.Read"],deniedSegments:["$batch","beta"],sets:{identity:{label:"Microsoft account (who you are)",access:"read",scopes:["User.Read"],routes:[{host:"graph.microsoft.com",paths:["/v1.0/me","/oidc/userinfo"]}]},"mail.read":{label:"Outlook mail (read-only)",access:"read",scopes:["Mail.Read"],routes:[{host:"graph.microsoft.com",paths:["/v1.0/me/messages","/v1.0/me/messages/","/v1.0/me/mailFolders","/v1.0/me/mailFolders/"]}]},"calendar.read":{label:"Outlook calendar (read-only)",access:"read",scopes:["Calendars.Read"],routes:[{host:"graph.microsoft.com",paths:["/v1.0/me/calendar","/v1.0/me/calendar/","/v1.0/me/calendars","/v1.0/me/calendars/","/v1.0/me/events","/v1.0/me/events/","/v1.0/me/calendarView","/v1.0/me/calendarView/"],posts:[/^\/v1\.0\/me\/calendar\/getSchedule$/]}]}}},api:["graph.microsoft.com"],redirectPaths:["/integrations/microsoft/callback"],flow:{tokenUrl:"https://login.microsoftonline.com/common/oauth2/v2.0/token",pkce:!0,scopeDialect:"microsoft",identity:{url:"https://graph.microsoft.com/v1.0/me",label:"userPrincipalName",id:"id"}}},...Ms};function Z(e){let t=[e.secret];return e.kind==="basic"&&e.as==="password"&&typeof e.user=="object"&&t.push(e.user.secret),t}function N(e){switch(e.mode){case"api_key":return[...Z(e.auth),...e.hostSetting?[e.hostSetting]:[]];case"ai":return[e.auth.secret,...e.alsoNeeds??[]];case"service":return[...e.settings,...e.optionalSettings];case"oauth_client":return[e.secrets.clientId,...e.secrets.clientSecret?[e.secrets.clientSecret]:[],...e.hostSetting?[e.hostSetting]:[]]}}var $=Object.keys(x);function Tt(e){return typeof e=="string"&&Object.hasOwn(x,e)}var D={get:e=>Tt(e)?x[e]:void 0,ids:()=>$};function Gs(e){return e.ids().filter(t=>e.get(t)?.mode!=="ai")}function Nr(e,t){if(!e.hostSetting)return null;let s=t?.[e.hostSetting],n=typeof s=="string"&&s.trim()?s.trim():e.defaultOrigin;if(!n)return null;let o;try{o=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)?n:`https://${n}`)}catch{return null}let r=o.pathname==="/"&&!o.search&&!o.hash&&!o.username&&!o.password;return o.protocol==="https:"&&r?o.origin:null}function xp(e){return e.token.map(({host:t,path:s,methods:n})=>`${n.join("/")} https://${t??`<${e.hostSetting}>`}${$r(s)}`).join(", ")}function $r(e){return typeof e=="string"?e:e.source.replace(/^\^|\$$/g,"").replace(/v\\d\+\\\.\\d\+/g,"v<version>").replace(/\\(.)/g,"$1")}var Dr=["AI_GATEWAY_ID","CLOUDFLARE_ACCOUNT_ID"],Us=["openrouter","workers-ai","openai","anthropic","groq","mistral","gemini"];var Lr=/^([a-z][a-z0-9-]{1,39})(?:\/(.{1,200}))?$/;function Cp(e){if(typeof e!="string")return null;let t=Lr.exec(e.trim());if(!t)return null;let s=t[2]?.trim();return s?{provider:t[1],model:s}:{provider:t[1]}}function Np(e){return e.model?`${e.provider}/${e.model}`:e.provider}function vt(e){return e?.mode==="ai"&&e.kind!=="proxy"&&e.chat!==void 0}function le(e){return[...e.authOptional?[]:[e.auth.secret],...e.alsoNeeds??[]]}function js(e,t){return le(e).every(s=>t(s))}function Mr(e){return Dr.every(t=>e(t))}function zs(e,t){return e.aig!==void 0&&Mr(t)}function Gr(e,t,s){return{id:e,label:t.label,settings:le(t),configured:js(t,s),model:t.chat.model,viaAiGateway:zs(t,s),embeddings:t.embeddings!==void 0}}function Ur(e,t=D){return[...Us,...t.ids().filter(n=>!Us.includes(n))].flatMap(n=>{let o=t.get(n);return vt(o)?[Gr(n,o,e)]:[]})}function jr(e,t=D){let s=t.get(e.provider);return s?s.mode!=="ai"?`${e.provider} is an API provider, not a model provider`:s.kind==="proxy"?`${s.label} fronts the model providers and serves no models of its own; set a provider, and turn the gateway on with everyapp ai gateway on`:s.chat?null:`${s.label} has no OpenAI-shaped chat route, so it can't serve the default; an app pins it by listing it under providers`:`${e.provider} isn't a provider this Gateway knows`}function Ks(e){let t=e.lookup??D,{isSet:s}=e,n=Ur(s,t),o=(d,u,m,w,y)=>({provider:d,label:u.label,model:w??u.chat.model,source:m,configured:js(u,s),settings:le(u),via:zs(u,s)?"ai-gateway":"direct",chat:u.chat,...u.embeddings?{embeddings:u.embeddings}:{},candidates:[...n.filter(l=>l.id===d),...n.filter(l=>l.id!==d)],...y?{problem:y}:{}}),r;if(e.choice){let d=t.get(e.choice.provider),u=jr(e.choice,t);if(!u&&vt(d))return o(e.choice.provider,d,"setting",e.choice.model);r=u??void 0}let a=n.find(d=>d.configured),c=a??n[0];if(!c)throw new Error("the catalog has no AI provider with a chat route");let p=t.get(c.id);if(!vt(p))throw new Error("unreachable");return o(c.id,p,a?"order":"none",void 0,r)}function Hs(e){let t=e.candidates.filter(n=>n.id!==e.provider).slice(0,3).map(n=>`${n.label} (${n.settings.join(" and ")})`),s=e.source==="setting"?`The Gateway's default model provider is ${e.label}; set ${e.settings.join(" and ")}.`:`Any one model provider's key makes the app work; ${e.label} is first in the order: set ${e.settings.join(" and ")}.`;return t.length>0?`${s} Or another: ${t.join(", ")}; pick one with everyapp ai default <provider>.`:s}var Ws=["google","microsoft","github","apple","cloudflare","oidc"];function zr(e){return`/api/auth/callback/${e}`}function Dp(e,t){return`${e.replace(/\/+$/,"")}${zr(t)}`}function he(e,t){return`${e.toUpperCase()}_SIGNIN_${t}`}function Q(e,t){return[{name:he(e,"CLIENT_ID"),role:"clientId",required:!0,plain:!0,what:t.clientId},{name:he(e,"CLIENT_SECRET"),role:"clientSecret",required:!0,plain:!1,what:t.clientSecret}]}var Pt=["openid","email","profile"],Kr={google:{id:"google",label:"Google",console:"https://console.cloud.google.com/apis/credentials",appNoun:"OAuth client ID (Web application)",settings:Q("google",{clientId:"The OAuth client's Client ID (ends in .apps.googleusercontent.com)",clientSecret:"The OAuth client's Client secret"}),scopes:Pt,emailClaim:"the ID token's `email`, counted as verified only when its `email_verified` is true (every Google account's own address is)",setup:"setup/signin-google.md",notes:["An OAuth consent screen still in Testing only signs in the test users listed on it; publish it for everyone else."]},microsoft:{id:"microsoft",label:"Microsoft",console:"https://entra.microsoft.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",appNoun:"App registration",settings:[...Q("microsoft",{clientId:"The app registration's Application (client) ID",clientSecret:"A client secret from Certificates & secrets (it expires; 24 months at most)"}),{name:he("microsoft","TENANT"),role:"tenant",required:!1,plain:!0,what:"The Directory (tenant) ID to pin sign-in to your own directory; unset means any Microsoft account (common), which then needs the xms_edov claim"}],scopes:Pt,emailClaim:"the ID token's `email`, counted as verified when MICROSOFT_SIGNIN_TENANT pins your own directory, or the token carries `xms_edov: true` (the optional claim that says the domain's owner verified it), `email_verified: true`, a matching `verified_primary_email`, or comes from a personal Microsoft account",setup:"setup/signin-microsoft.md",notes:["Without MICROSOFT_SIGNIN_TENANT, add the optional claims `email` and `xms_edov` under Token configuration, or every sign-in is refused as unverified: any tenant's admin can put any address on their users."]},github:{id:"github",label:"GitHub",console:"https://github.com/settings/developers",appNoun:"OAuth App",settings:Q("github",{clientId:"The OAuth App's Client ID",clientSecret:"A client secret generated on the OAuth App"}),scopes:["read:user","user:email"],emailClaim:"the primary address from GitHub's emails API, counted as verified only when GitHub marks it verified",setup:"setup/signin-github.md",notes:["GitHub Apps are something else: make an OAuth App (Settings \u2192 Developer settings \u2192 OAuth Apps)."]},apple:{id:"apple",label:"Apple",console:"https://developer.apple.com/account/resources/identifiers/list/serviceId",appNoun:"Services ID",settings:Q("apple",{clientId:"The Services ID's identifier (com.example.gateway)",clientSecret:"The client secret JWT you generate from your Sign in with Apple key (ES256; valid six months at most, then generate it again)"}),scopes:["email","name"],emailClaim:"the ID token's `email`, counted as verified only when its `email_verified` is true; someone who chose Hide My Email arrives as a @privaterelay.appleid.com address, which no invitation names",setup:"setup/signin-apple.md",notes:["Apple returns to the Gateway with a POST; behind the outer ring, `everyapp access on` leaves /api/auth/callback/apple public (it only redirects to the same URL as a GET, which Access then checks).","The client secret is a JWT that expires within six months: generate a new one before then or sign-in stops."]},cloudflare:{id:"cloudflare",label:"Cloudflare",console:"https://dash.cloudflare.com/?to=/:account/oauth-clients",appNoun:"OAuth client (Manage Account \u2192 OAuth clients)",settings:Q("cloudflare",{clientId:"The OAuth client's Client ID",clientSecret:"The OAuth client's Client secret"}),scopes:["user-details.read"],emailClaim:"the Cloudflare API's /user `email` (the account's sign-in address). Cloudflare reports no verified flag, so the email counts as verified on the strength of the client being private: only members of your Cloudflare account can authorize it, and they got in by accepting an invitation sent to that address",setup:"setup/signin-cloudflare.md",notes:["Keep the client private (the default): a public client lets any Cloudflare user sign in, and Cloudflare says nothing about whether their address is verified. Making a client public is permanent.","The Cloudflare account's members sign in; for everyone else use Cloudflare Access's one-time PIN (`everyapp access on`) or another provider."]},oidc:{id:"oidc",label:"SSO",console:"your identity provider's admin console",appNoun:"OpenID Connect client (web application, authorization code)",settings:[{name:he("oidc","ISSUER"),role:"issuer",required:!0,plain:!0,what:"The issuer URL (https://\u2026), which serves /.well-known/openid-configuration"},...Q("oidc",{clientId:"The client ID",clientSecret:"The client secret"}),{name:he("oidc","LABEL"),role:"label",required:!1,plain:!0,what:'The button text after "Continue with" (default "SSO")'}],scopes:Pt,emailClaim:"the ID token's `email` (else the userinfo endpoint's), counted as verified only when `email_verified` is true",setup:"setup/signin-oidc.md",notes:["Cloudflare Access has its own settings (CLOUDFLARE_ACCESS_OIDC_*, `everyapp access`): use those for Access, this for Okta, Keycloak, Auth0, Authentik, Google Workspace as an OIDC issuer and the like. For Microsoft Entra ID use the `microsoft` provider: Entra's ID tokens carry no `email_verified`, so through this entry every sign-in would be refused as unverified.","ID tokens must be signed with RS256 (every major provider's default)."]}},xt=Ws.map(e=>Kr[e]);function Lp(e){return Ws.includes(e)}var Bs=xt.flatMap(e=>e.settings.map(t=>t.name)),Ys=xt.flatMap(e=>e.settings.filter(t=>t.plain).map(t=>t.name)),Hr=/^[A-Z][A-Z0-9_]*_SIGNIN_(CLIENT_ID|CLIENT_SECRET|ISSUER|LABEL|TENANT)$/;function Ge(e){return Hr.test(e)}function Mp(e){for(let t of xt)if(t.settings.some(s=>s.name===e))return t;return null}function Gp(e,t){let s=e.settings.filter(r=>t(r.name)).map(r=>r.name),n=e.settings.filter(r=>r.required&&!t(r.name)).map(r=>r.name),o=n.length===0?"on":s.length===0?"off":"incomplete";return{id:e.id,status:o,missing:o==="incomplete"?n:[],set:s}}var Wr=["GATEWAY_URL","APP_BASE_DOMAIN","BETTER_AUTH_SECRET","JWT_PRIVATE_KEY","JWT_PUBLIC_KEY","GATEWAY_DEPLOYMENT_MODE","CLOUDFLARE_ACCOUNT_ID","THIRD_PARTY_DEPLOYS"],Vs=new Set(Wr);function ee(e){return Vs.has(e)}var Br=[...new Set($.flatMap(e=>{let t=x[e];return t.mode==="service"?[]:N(t)}))].filter(e=>!Vs.has(e)),Yr=["AI_PROXY_EXTRA_ROUTES","EMAIL_REST_API_TOKEN","RESEND_API_KEY","EMAIL_PROVIDER","EMAIL_FROM","EMAIL_FROM_NAME","MCP_OAUTH_ENABLED","MCP_DCR_ENABLED","MCP_ALLOWED_ORIGINS","MCP_AUDIT_RETENTION_DAYS","CLOUDFLARE_ACCESS_OIDC_ISSUER","CLOUDFLARE_ACCESS_OIDC_CLIENT_ID","CLOUDFLARE_ACCESS_OIDC_CLIENT_SECRET","CLOUDFLARE_ACCESS_OIDC_LABEL","CLOUDFLARE_ACCESS_TEAM_DOMAIN","CLOUDFLARE_ACCESS_AUD","CLOUDFLARE_ACCESS_APPS_AUD","CLOUDFLARE_ACCESS_AUTO_JOIN_DOMAINS","CLOUDFLARE_ACCESS_OUTER_RING_AUTO_JOIN","EMAIL_PASSWORD_SIGN_IN","HOSTED_OPEN_SIGNUP","CF_DEPLOY_TOKEN","BROWSER_APP_INSTALLS","DISPATCH_NAMESPACE","THIRD_PARTY_DOMAIN","EVENTS_ALLOW_PRIVATE_TARGETS"],Vr=[...Br,...Yr,...Bs],qr=new Set(Vr),Fr=/^[A-Z][A-Z0-9_]*_MCP_TOKEN$/;function me(e){return Fr.test(e)}function K(e){return qr.has(e)||me(e)}var Jr=["EMAIL_FROM","EMAIL_FROM_NAME","EMAIL_PROVIDER","EMAIL_PASSWORD_SIGN_IN","AI_PROXY_EXTRA_ROUTES","MCP_OAUTH_ENABLED","MCP_DCR_ENABLED","MCP_ALLOWED_ORIGINS","MCP_AUDIT_RETENTION_DAYS","CLOUDFLARE_ACCESS_OIDC_ISSUER","CLOUDFLARE_ACCESS_OIDC_CLIENT_ID","CLOUDFLARE_ACCESS_OIDC_LABEL","CLOUDFLARE_ACCESS_TEAM_DOMAIN","CLOUDFLARE_ACCESS_AUD","CLOUDFLARE_ACCESS_APPS_AUD","CLOUDFLARE_ACCESS_AUTO_JOIN_DOMAINS","CLOUDFLARE_ACCESS_OUTER_RING_AUTO_JOIN","HOSTED_OPEN_SIGNUP","BROWSER_APP_INSTALLS","DISPATCH_NAMESPACE","THIRD_PARTY_DOMAIN","EVENTS_ALLOW_PRIVATE_TARGETS"],Xr=$.flatMap(e=>{let t=x[e];return t.mode==="oauth_client"&&t.hostSetting?[t.hostSetting]:[]}),Zr=new Set([...Jr,...Xr,...Ys]);function Kp(e){return Zr.has(e)}var Qr=["HOSTED_OPEN_SIGNUP","DISPATCH_NAMESPACE","THIRD_PARTY_DOMAIN"],ea=new Set(Qr);function Hp(e){return ea.has(e)}var ta=["MCP_ACCESS_TOKEN_TTL","DATAFORSEO_SANDBOX"];function qs(e){return ta.includes(e)}var sa=new Set(["GATEWAY_URL","CF_VERSION_METADATA"]),na=["EVERYAPP_","EVERY_APP_","APP__"],Fs="GATEWAY_URL, CF_VERSION_METADATA and the EVERYAPP_*, EVERY_APP_* and APP__* names";function Ue(e){let t=e.toUpperCase();return sa.has(t)||na.some(s=>t.startsWith(s))}function Js(e){for(let t of $){let s=x[t];if(N(s).includes(e))return{kind:s.mode==="ai"?"provider":"capability",id:t}}return null}var Yp="provider",je={dataforseo:{id:"dataforseo",name:"DataForSEO",description:"SEO data for your agent: keyword metrics and suggestions, live Google results, domain rankings, competitors and backlinks, through the Gateway's DataForSEO key.",capability:"dataforseo",why:"Serves DataForSEO's keyword, search-result, domain and backlink data to members' AI clients.",example:"find keyword ideas for a page about running shoes"}},Vp=Object.keys(je).sort();function Xs(e){return Object.hasOwn(je,e)}function qp(e){return Z(x[je[e].capability].auth)[0]}function Fp(e){let t=je[e];return{id:t.id,name:t.name,description:t.description,capabilities:{[t.capability]:{access:"read",why:t.why}}}}var fe="/__everyapp/tools",Xp=`${fe}/list`,Zp=`${fe}/call`,oa=["read","write","destructive"],Qp="mcp:read",eu="mcp:write";var Zs=/^[a-z][a-z0-9_]{0,47}$/;function Qs(e){return typeof e=="string"&&oa.includes(e)}function tu(e){return JSON.stringify(Rt(e))}function Rt(e){if(Array.isArray(e))return e.map(Rt);if(!e||typeof e!="object")return e;let t={};for(let s of Object.keys(e).sort()){let n=e[s];n!==void 0&&(t[s]=Rt(n))}return t}var en=["none","bearer","header","basic","oauth"],tn=["annotations","read","write"],rn=/^[a-z]([a-z0-9-]*[a-z0-9])?$/,Ot=32,ra=["everyapp"],aa=64,ia=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$/,ca=32,an=2048,da=255,pa=1e3,sn=500,ua=256,la=new Set(["authorization","cookie","host","content-type","content-length","accept","connection","transfer-encoding","mcp-session-id","mcp-protocol-version","mcp-method","mcp-name"]);function ha(e){return`${e.toUpperCase().replace(/-/g,"_")}_MCP_TOKEN`}function ma(e){return typeof e!="string"||!rn.test(e)?"the id must be kebab-case: lowercase letters, digits and hyphens, starting with a letter":e.length>Ot?`the id must be at most ${Ot} characters`:ra.includes(e)?`"${e}" is reserved`:Xs(e)?`"${e}" is the Gateway's built-in MCP app; a remote server can't take its id`:null}function iu(e){let t;try{t=new URL(e).hostname.toLowerCase().replace(/\.$/,"")}catch{return null}if(!t||/^[\d.]+$/.test(t)||t.includes(":"))return null;let s=t.split(".").filter(c=>c.length>0);if(s.length<2)return null;let n=new Set(["co","com","net","org","gov","edu","ac"]),o=s.length-2;o>0&&n.has(s[o])&&s[o+1].length===2&&(o-=1);let a=(s[o]??"").replace(/[^a-z0-9-]/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-").slice(0,Ot).replace(/-+$/g,"");return!a||!rn.test(a)||ma(a)?null:a}function nn(e,t){return e===t||e.endsWith(`.${t}`)}function fa(){let e=new Set(["api.openai.com","openrouter.ai","gateway.ai.cloudflare.com","api.cloudflare.com"]);for(let t of Object.values(x))if(t.mode==="api_key")for(let s of t.hosts)e.add(s);else if(t.mode==="oauth_client")for(let s of t.token)"host"in s&&typeof s.host=="string"&&e.add(s.host);return[...e].sort()}function cu(e,t){if(typeof e!="string"||!e.trim())return"give the server's URL";if(e.length>an)return"the URL is too long";let s;try{s=new URL(e)}catch{return"the URL doesn't parse"}let n=t.gatewayUrl.trim().toLowerCase().startsWith("http://");if(s.username||s.password)return"the URL must not carry credentials; the Gateway sends the credential from its own setting";if(s.hash)return"the URL must not have a fragment";let o=s.hostname.toLowerCase().replace(/\.$/,""),r=o==="localhost"||o.endsWith(".localhost")||o==="127.0.0.1"||o==="[::1]"||o==="::1";if(s.protocol!=="https:"&&!(s.protocol==="http:"&&n&&r))return n?"the URL must be https://, or http:// on localhost while the Gateway runs locally":"the URL must be https://";if(!o)return"the URL has no host";if(!r&&(/^[\d.]+$/.test(o)||o.startsWith("[")))return"the URL must name a host, not an IP address";if(r&&!n)return"the URL must name a public host";let a="",c="";try{let p=new URL(t.gatewayUrl);a=p.hostname.toLowerCase().replace(/\.$/,""),c=p.origin.toLowerCase()}catch{a=""}if(a&&(n?s.origin.toLowerCase()===c:nn(o,a)))return"the URL is this Gateway's own address";for(let p of[t.appBaseDomain,t.thirdPartyDomain]){let d=(p??"").trim().toLowerCase().replace(/\.$/,"");if(d&&nn(o,d))return`the URL is on this Gateway's app domain (${d})`}return fa().includes(o)?`${o} is a provider this Gateway holds a key for; apps reach it through the Gateway's capabilities, not as an MCP app`:null}function te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ga(e){return typeof e!="string"||!e?"give the credential's setting name":e.length>aa?"the credential's name is too long":me(e)?null:`the credential's name must end in _MCP_TOKEN (letters, digits and underscores), like ${ha("treg")}`}function ya(e){if(!te(e)||typeof e.kind!="string")return{ok:!1,problem:"auth must name a kind"};let t=e.kind;if(!en.includes(t))return{ok:!1,problem:`auth.kind must be one of ${en.join(", ")}`};if(t==="none"||t==="oauth")return{ok:!0,auth:{kind:t}};let s=ga(e.secret);if(s)return{ok:!1,problem:`auth.secret: ${s}`};let n=e.secret;if(t==="bearer"||t==="basic")return{ok:!0,auth:{kind:t,secret:n}};let o=e.header;if(typeof o!="string"||!ia.test(o))return{ok:!1,problem:"auth.header must be an HTTP header name"};if(la.has(o.toLowerCase()))return{ok:!1,problem:`auth.header can't be ${o}; use kind "bearer" or "basic" for Authorization`};let r=e.prefix;return r!==void 0&&(typeof r!="string"||r.length>ca||/[\r\n]/.test(r))?{ok:!1,problem:"auth.prefix must be a short string"}:{ok:!0,auth:{kind:"header",secret:n,header:o,...typeof r=="string"&&r?{prefix:r}:{}}}}function wa(e){if(!te(e))return{ok:!1,problem:"remote must be an object"};let t=e.url;if(typeof t!="string"||!t||t.length>an)return{ok:!1,problem:"remote.url must be a URL"};let s=ya(e.auth);if(!s.ok)return s;let n=e.risk??"annotations";if(!tn.includes(n))return{ok:!1,problem:`remote.risk must be one of ${tn.join(", ")}`};let o={},r=e.tools??{};if(!te(r))return{ok:!1,problem:"remote.tools must be an object"};let a=Object.entries(r);if(a.length>sn)return{ok:!1,problem:`remote.tools has more than ${sn} entries`};for(let[p,d]of a){if(!p||p.length>ua)return{ok:!1,problem:"remote.tools has a tool name that is empty or too long"};if(!te(d))return{ok:!1,problem:`remote.tools.${p} must be an object`};let u={};if(d.risk!==void 0){if(!Qs(d.risk))return{ok:!1,problem:`remote.tools.${p}.risk must be read, write or destructive`};u.risk=d.risk}if(d.enabled!==void 0){if(typeof d.enabled!="boolean")return{ok:!1,problem:`remote.tools.${p}.enabled must be true or false`};u.enabled=d.enabled}o[p]=u}let c=e.rev??1;return typeof c!="number"||!Number.isInteger(c)||c<1?{ok:!1,problem:"remote.rev must be a positive integer"}:{ok:!0,block:{url:t,auth:s.auth,risk:n,tools:o,rev:c}}}function cn(e){if(!te(e)||e.remote===void 0)return null;let t=wa(e.remote);return t.ok?t.block:null}function du(e){return te(e)&&e.remote!==void 0}function dn(e){return"secret"in e?e.secret:null}function Ea(e,t){let s="";try{s=new URL(t).origin}catch{s=""}return`${e}'s MCP server${s?` at ${s}`:""}, served to your AI clients through this Gateway.`}function pn(e,t){let s=e.tools[t];if(s)return s;let n=on(t);if(n){for(let[o,r]of Object.entries(e.tools))if(on(o)===n)return r}}function pu(e){let t=(e.name??"").trim().slice(0,da)||e.id,s=(e.description??"").trim().slice(0,pa)||Ea(t,e.remote.url);return{id:e.id,name:t,description:s,remote:e.remote}}function uu(e,t,s){let n=pn(t,s)?.risk;return n?{risk:n,source:"override"}:t.risk==="read"||t.risk==="write"?{risk:t.risk,source:"app"}:e?.readOnlyHint===!0?{risk:"read",source:"hint"}:e?.destructiveHint===!0?{risk:"destructive",source:"hint"}:{risk:"write",source:"default"}}function lu(e,t){return pn(e,t)?.enabled!==!1}function on(e){if(typeof e!="string")return null;let t=e.trim().replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase().replace(/[\s./:-]+/g,"_").replace(/[^a-z0-9_]/g,"").replace(/_{2,}/g,"_").replace(/^_+|_+$/g,"");return t?(/^[0-9]/.test(t)&&(t=`t_${t}`),t=t.slice(0,48).replace(/_+$/g,""),Zs.test(t)?t:null):null}function un(e){switch(e.kind){case"none":return"no credential";case"bearer":return"bearer token";case"basic":return"user and password";case"header":return`header ${e.header}`;case"oauth":return"OAuth (not supported yet)"}}function ba(e){return e?typeof e.anyOf=="string"&&e.anyOf.trim()?{kind:"anyOf",group:e.anyOf.trim()}:e.optional===!0?{kind:"optional"}:{kind:"required"}:{kind:"required"}}function Ct(e){if(!e||typeof e!="object")return{};let t=e;return{...typeof t.why=="string"?{why:t.why}:{},...typeof t.docs=="string"?{docs:t.docs}:{},...typeof t.optional=="boolean"?{optional:t.optional}:{},...typeof t.setup=="string"?{setup:t.setup}:{},...typeof t.anyOf=="string"?{anyOf:t.anyOf}:{}}}function Ke(e){return(e.providers??[]).flatMap(t=>typeof t=="string"?[{id:t}]:t&&typeof t=="object"&&typeof t.id=="string"?[{id:t.id,...Ct(t)}]:[])}function wu(e){return Ke(e).map(t=>t.id)}function He(e){return(e.secrets??[]).flatMap(t=>typeof t=="string"?[{name:t}]:t&&typeof t=="object"&&typeof t.name=="string"?[{name:t.name,...Ct(t)}]:[])}function hn(e){return He(e).map(t=>t.name)}function mn(e){return le(e).filter(t=>!ee(t))}function _a(e){let t=s=>s.filter(n=>K(n)&&!ee(n));switch(e.mode){case"api_key":return{names:[...N(e)],alsoReads:[]};case"ai":return{names:mn(e),alsoReads:[]};case"service":return{names:t(e.settings),alsoReads:t(e.optionalSettings)};case"oauth_client":{let s=[e.secrets.clientId,...e.secrets.clientSecret?[e.secrets.clientSecret]:[]],n=e.hostSetting?[e.hostSetting]:[];return e.defaultOrigin?{names:s,alsoReads:n}:{names:[...s,...n],alsoReads:[]}}}}function Aa(e){switch(e.mode){case"api_key":case"ai":return e.docs;case"oauth_client":return e.console.startsWith("https://")?e.console:e.defaultOrigin?`${e.defaultOrigin}${e.console}`:void 0;case"service":return}}function ln(e,t){if(e.mode==="service"||e.mode==="oauth_client")return{};let s=e.secrets??[],n=[...e.hint?[e.hint]:[],...s.filter(o=>o.hint&&t.includes(o.name)).map(o=>t.length>1?`${o.name}: ${o.hint}`:o.hint)];return n.length>0?{hint:n.join(" ")}:{}}function ze(e,t,s={}){let n=t?.docs??s.docs,o=e.holder==="gateway"?s.setup:t?.setup;return{...e,need:ba(t),...t?.why?{why:t.why}:{},...n?{docs:n}:{},...o?{setup:o}:{},...s.hint?{hint:s.hint}:{}}}function Eu(e,t=D,s={}){let n=[],o=e.ai?.chat;if(o===!0||o&&typeof o=="object"){let a=Ks({choice:s.aiDefault??null,isSet:s.isSet??(()=>!1),lookup:t}),c=d=>d.filter(u=>!ee(u)),p=t.get(a.provider);n.push(ze({kind:"ai-default",id:"ai-default",label:`A chat model (${a.label})`,holder:"gateway",names:c(a.settings),alsoReads:[],alternatives:a.candidates.map(d=>c(d.settings)).filter(d=>d.length>0)},o===!0?void 0:o,{...p?.mode==="ai"?{docs:p.docs}:{},setup:"setup/ai.md",hint:Hs(a)}))}for(let a of Ke(e)){let c=t.get(a.id);if(c?.mode!=="ai")continue;let p=mn(c);n.push(ze({kind:"provider",id:a.id,label:c.label,holder:"gateway",names:p,alsoReads:[]},a,{docs:c.docs,setup:c.setup,...ln(c,p)}))}for(let[a,c]of Object.entries(e.capabilities??{})){let p=t.get(a);if(!p||p.mode==="ai")continue;let{names:d,alsoReads:u}=_a(p);n.push(ze({kind:"capability",id:a,label:p.label,holder:"gateway",names:d,alsoReads:u},Ct(c),{docs:Aa(p),setup:p.setup,...ln(p,d)}))}e.ai?.routes?.length&&n.push({kind:"ai-routes",id:"ai-routes",label:"AI proxy routes",holder:"gateway",names:["AI_PROXY_EXTRA_ROUTES"],alsoReads:[],need:{kind:"required"},why:`Lets the app call ${e.ai.routes.join(", ")} through the AI proxy.`,setup:"setup/openai.md"});let r=cn(e);if(r){let a=dn(r.auth);if(a){let c=typeof e.name=="string"&&e.name.trim()?e.name.trim():"the MCP server";n.push({kind:"remote-mcp",id:a,label:`${c} credential`,holder:"gateway",names:[a],alsoReads:[],need:{kind:"required"},why:`What ${c} expects: ${un(r.auth)}. The Gateway sends it to ${r.url} and nowhere else.`,setup:"setup/remote-mcp.md"})}}for(let a of He(e))n.push(ze({kind:"secret",id:a.name,label:a.name,holder:"app",names:[a.name],alsoReads:[]},a));return n}function ka(e,t){let s=o=>{let r=!1;for(let a of o){let c=t(e.holder,a);if(c===!1)return!1;c===null&&(r=!0)}return r?null:!0};if(!e.alternatives?.length)return s(e.names);let n=!1;for(let o of e.alternatives){let r=s(o);if(r===!0)return!0;r===null&&(n=!0)}return n?null:!1}function bu(e,t,s={}){let n=e.map(a=>{let c=s.readiness?.(a);return{...a,set:c===void 0?ka(a,t):c,blocking:!1}}),o=[];for(let a of n){if(a.need.kind!=="anyOf")continue;let c=a.need.group,p=o.find(d=>d.group===c);p||(p={group:c,members:[],met:!1},o.push(p)),p.members.push(a)}for(let a of o){a.met=a.members.some(p=>p.set===!0);let c=a.members.some(p=>p.set===null);if(!a.met&&!c)for(let p of a.members)p.blocking=!0}for(let a of n)a.need.kind==="required"&&a.set===!1&&(a.blocking=!0);let r=n.filter(a=>a.blocking);return{ready:r.length===0,settings:n,groups:o,unmet:r}}function Sa(e,{cli:t,appId:s,provider:n=!1}){if(e.unmet.length===0)return null;if(!n)return{command:`${t} configure ${s}`};let o=[],r=a=>{for(let c of a.names)o.includes(c)||o.push(c)};for(let a of e.unmet)a.need.kind==="required"&&r(a);for(let a of e.groups){let c=a.members.find(p=>p.blocking);c&&r(c)}return{command:`${t} secret set ${o.join(" ")}`}}function _u(e,t){let s=({alsoReads:n,...o})=>o;return{ready:e.ready,settings:e.settings.map(s),unmet:e.unmet.map(s),groups:e.groups.map(n=>({group:n.group,met:n.met,members:n.members.map(o=>o.id)})),command:t.withCommand===!1?null:Sa(e,t)}}var ku=["cloudflare","resend"];var We={bodyBytes:5*1024*1024,recipients:50,subjectChars:998,headers:20,headerValueBytes:2048,headerNameBytes:100,headersTotalBytes:16*1024,attachments:32,senders:20,inbound:50,inboundAddressChars:90},Ia=/^(\*|[a-z0-9._+-]+)@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/,Ta=/^(\*|[a-z0-9._+-]+)@([a-z0-9-]+\.)+[a-z]{2,}$/,Nt="everyapp email set";function Su(e,t){let s=[],n=e==="senders"?We.senders:We.inbound;t.length>n&&s.push(`At most ${n} ${e==="senders"?"senders":"inbound addresses"}, not ${t.length}.`);for(let o of t)e==="inbound"&&o.length>We.inboundAddressChars?s.push(`${o} is longer than Email Routing's ${We.inboundAddressChars} characters.`):(e==="senders"?Ia:Ta).test(o)||s.push(e==="senders"?`"${o}" isn't a sender: a sender is "*@<domain>" or "<local>@<domain>", in lowercase.`:`"${o}" isn't an inbound address: an inbound address is "*@<domain>" or "<local>@<domain>", in lowercase.`);for(let o of new Set(t.filter((r,a)=>t.indexOf(r)!==a)))s.push(`${o} is listed twice.`);return s}function Iu(e){return e.length===0?null:JSON.stringify(e)}function Tu(e,t){let s=e?.trim();if(!s)return null;let n=/^(.*?)\s*<([^<>]+)>$/.exec(s),o=(n?.[2]??s).trim(),r=n?.[1]?.trim().replace(/^(["'])(.*)\1$/,"$2").trim(),a=t?.trim()||r;return o&&a?{address:o,name:a}:null}function vu(e){if(typeof e!="string"||!e.trim())return[];let t=e.trim();if(t.startsWith("["))try{let s=JSON.parse(t);return Array.isArray(s)?s.filter(n=>typeof n=="string"):[]}catch{return[]}return t.split(/[\s,]+/).filter(Boolean)}function xu(e){if(/[\p{Cc}\p{Cf}\u2028\u2029]/u.test(e))return null;let t=e.trim().replace(/\s+/g," ");return!t||[...t].length>64?null:t}var Pa=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31})?$/,$t=["space","comma","google","microsoft","slack"],fn=["form","basic"],xa=/^[A-Za-z0-9-]{1,64}$/,Ra=new Set(["authorization","content-type","content-length","host","cookie"]),Oa=/^[A-Za-z0-9_.-]{1,64}$/,gn=/^[A-Za-z_][A-Za-z0-9_]{0,63}(?:\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/,Ca=/[\p{Cc}\p{Cf}]/u,yn=20,wn=40,En=20,Be=50,bn=10,Na=["batch","$batch"],$a=["kind","authorizeUrl","tokenUrl","revokeUrl","revokeMethod","clientId","clientSecret","inject","pkce","scopeDialect","authorizeParams","tokenHeaders","identity"];function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e,t,s,n){if(e!==void 0){if(typeof e!="string"||e.length===0||e.length>n){s.push({path:t,message:`must be a string of 1 to ${n} characters`});return}if(Ca.test(e)){s.push({path:t,message:"holds a control character"});return}return e}}function Ye(e,t,s,{query:n}){if(e===void 0)return;let o=G(e,t,s,500);if(o===void 0)return;let r;try{r=new URL(o)}catch{s.push({path:t,message:"must be an https URL"});return}if(r.protocol!=="https:"||r.username||r.password||r.port||r.hash){s.push({path:t,message:"must be an https URL with no port, credentials or fragment"});return}if(!n&&r.search){s.push({path:t,message:"may not carry a query string"});return}return{url:o,host:r.hostname.toLowerCase()}}function Da(e,t,s,n){if(typeof e!="string"||!n.test(e)){s.push({path:t,message:"must name a Gateway setting: upper case letters, digits and underscores, a letter first, 3 to 64 characters (GITHUB_CLIENT_ID)"});return}return e}function _n(e,t,s,n){if(e===void 0)return;if(!ge(e)){s.push({path:t,message:"must be an object of strings"});return}let o=Object.entries(e);if(o.length>bn){s.push({path:t,message:`at most ${bn} entries`});return}let r={};for(let[a,c]of o){let p=`${t}.${a}`;n(a,p);let d=G(c,p,s,200);d!==void 0&&(r[a]=d)}return r}function Ve(e,t,s){if(e===void 0)return;if(!Array.isArray(e)||e.length>wn){s.push({path:t,message:`must be a list of at most ${wn} scopes`});return}let n=[];return e.forEach((o,r)=>{let a=G(o,`${t}.${r}`,s,200);if(a!==void 0){if(/\s/.test(a)||a.includes(",")){s.push({path:`${t}.${r}`,message:"one scope, with no space or comma"});return}n.push(a)}}),new Set(n).size!==n.length&&s.push({path:t,message:"lists a scope twice"}),n}function La(e,t,s,n){if(e===void 0)return;if(!Array.isArray(e)||e.length>En){n.push({path:t,message:`must be a list of at most ${En} routes`});return}let o=[];return e.forEach((r,a)=>{let c=`${t}.${a}`;if(!ge(r)){n.push({path:c,message:"must be { host, paths, posts? }"});return}for(let m of Object.keys(r))["host","paths","posts"].includes(m)||n.push({path:`${c}.${m}`,message:"unknown field"});let p=G(r.host,`${c}.host`,n,253);p!==void 0&&!s.includes(p)&&n.push({path:`${c}.host`,message:"must be one of hosts"});let d=[];!Array.isArray(r.paths)||r.paths.length>Be?n.push({path:`${c}.paths`,message:`must be a list of at most ${Be} paths`}):r.paths.forEach((m,w)=>{let y=G(m,`${c}.paths.${w}`,n,500);if(y!==void 0){if(!y.startsWith("/")||y.includes("//")||y.includes("\\")||y.includes("%")||/(^|\/)\.\.?(\/|$)/.test(y)){n.push({path:`${c}.paths.${w}`,message:"must start with / and hold no //, backslash, percent-escape or dot segment"});return}d.push(y)}});let u=[];r.posts!==void 0&&(!Array.isArray(r.posts)||r.posts.length>Be?n.push({path:`${c}.posts`,message:`must be a list of at most ${Be} anchored patterns`}):r.posts.forEach((m,w)=>{let y=G(m,`${c}.posts.${w}`,n,500);if(y!==void 0){if(!y.startsWith("^")||!y.endsWith("$")){n.push({path:`${c}.posts.${w}`,message:"must be anchored: start with ^ and end with $"});return}try{u.push(new RegExp(y))}catch{n.push({path:`${c}.posts.${w}`,message:"is not a valid pattern"})}}})),p!==void 0&&o.push({host:p,paths:d,...r.posts===void 0?{}:{posts:u}})}),o}function Ma(e,t,s){if(!ge(e)){s.push({path:"scopeSets",message:'required: at least one named set, { "repo.read": { "label", "access", "scopes" } }'});return}let n=Object.entries(e);if(n.length===0||n.length>yn){s.push({path:"scopeSets",message:`must name 1 to ${yn} sets`});return}let o={};for(let[r,a]of n){let c=`scopeSets.${r}`;if(!Pa.test(r)){s.push({path:c,message:"a set is named identity, or <area>.<access> in lowercase (repo.read)"});continue}if(!ge(a)){s.push({path:c,message:"must be { label, access, scopes }"});continue}for(let y of Object.keys(a))["label","access","scopes","userScopes","routes"].includes(y)||s.push({path:`${c}.${y}`,message:"unknown field"});let p=G(a.label,`${c}.label`,s,80);a.label===void 0&&s.push({path:`${c}.label`,message:"required"});let d=a.access;d!=="read"&&d!=="write"&&s.push({path:`${c}.access`,message:"must be read or write"});let u=Ve(a.scopes,`${c}.scopes`,s);a.scopes===void 0&&s.push({path:`${c}.scopes`,message:"required"});let m=Ve(a.userScopes,`${c}.userScopes`,s),w=La(a.routes,`${c}.routes`,t,s);p===void 0||d!=="read"&&d!=="write"||u===void 0||(o[r]={label:p,access:d,scopes:u,...m===void 0?{}:{userScopes:m},routes:w??[]})}return o}function Ga(e,t,s){if(e===void 0)return;if(!ge(e)){s.push({path:"auth.identity",message:"must be { url, label, id? }"});return}for(let a of Object.keys(e))["url","label","id"].includes(a)||s.push({path:`auth.identity.${a}`,message:"unknown field"});let n=Ye(e.url,"auth.identity.url",s,{query:!0});e.url===void 0?s.push({path:"auth.identity.url",message:"required"}):n&&!t.includes(n.host)&&s.push({path:"auth.identity.url",message:"must be on one of hosts (the token is sent there)"});let o=G(e.label,"auth.identity.label",s,128);o!==void 0&&!gn.test(o)&&s.push({path:"auth.identity.label",message:"must be a JSON field name, or a dotted path to a nested one"}),e.label===void 0&&s.push({path:"auth.identity.label",message:"required"});let r=G(e.id,"auth.identity.id",s,128);if(r!==void 0&&!gn.test(r)&&s.push({path:"auth.identity.id",message:"must be a JSON field name, or a dotted path to a nested one"}),!(!n||o===void 0))return{url:n.url,label:o,...r===void 0?{}:{id:r}}}function An(e,t,s){let n=(b,P,Le)=>Da(b,P,Le,/^[A-Z][A-Z0-9_]{2,63}$/),o=e.auth;for(let b of Object.keys(o))$a.includes(b)||s.push({path:`auth.${b}`,message:"not a field of auth.kind oauth2-user"});let r=Ye(o.authorizeUrl,"auth.authorizeUrl",s,{query:!0});o.authorizeUrl===void 0&&s.push({path:"auth.authorizeUrl",message:"required"});let a=Ye(o.tokenUrl,"auth.tokenUrl",s,{query:!1});o.tokenUrl===void 0&&s.push({path:"auth.tokenUrl",message:"required"});let c=Ye(o.revokeUrl,"auth.revokeUrl",s,{query:!1}),p=o.revokeMethod;p!==void 0&&p!=="POST"&&p!=="DELETE"&&s.push({path:"auth.revokeMethod",message:"must be POST or DELETE"}),p!==void 0&&c===void 0&&s.push({path:"auth.revokeMethod",message:"needs a revokeUrl"});let d=n(o.clientId,"auth.clientId",s),u=o.clientSecret===void 0?void 0:n(o.clientSecret,"auth.clientSecret",s);u!==void 0&&u===d&&s.push({path:"auth.clientSecret",message:"must be another setting than auth.clientId"});let m=o.inject??"form";fn.includes(m)||s.push({path:"auth.inject",message:"must be form (the client in the body) or basic (HTTP Basic)"});let w=o.pkce??!0;typeof w!="boolean"&&s.push({path:"auth.pkce",message:"must be true or false"});let y=o.scopeDialect??"space";$t.includes(y)||s.push({path:"auth.scopeDialect",message:`must be one of ${$t.join(", ")}`});let l=_n(o.authorizeParams,"auth.authorizeParams",s,(b,P)=>{Oa.test(b)||s.push({path:P,message:"must be a query parameter name"}),["client_id","redirect_uri","response_type","scope","state","code_challenge","code_challenge_method"].includes(b)&&s.push({path:P,message:`${b} is a parameter the Gateway sets itself`})}),S=_n(o.tokenHeaders,"auth.tokenHeaders",s,(b,P)=>{xa.test(b)?(Ra.has(b.toLowerCase())||b.toLowerCase().startsWith("x-everyapp-"))&&s.push({path:P,message:`${b} is a header the Gateway sets itself`}):s.push({path:P,message:"must be a header name"})}),E=Ga(o.identity,t.hosts,s),A=Ma(e.scopeSets,t.hosts,s),k=Ve(e.alwaysRequested,"alwaysRequested",s),L=Ve(e.tolerated,"tolerated",s);if(!r||!a||d===void 0||!A||typeof w!="boolean"||!$t.includes(y)||!fn.includes(m))return;let F=[],J=b=>{for(let P of b)F.includes(P)||F.push(P)};for(let b of Object.values(A))J(b.scopes),J(b.userScopes??[]);J(k??[]);let Ce={sets:A,tolerated:L??[],alwaysRequested:k??[],dialect:y,grantTypes:["authorization_code","refresh_token"],requestScope:"keep",deniedSegments:[...Na]},Ne={tokenUrl:a.url,...c===void 0?{}:{revokeUrl:c.url},...p===void 0?{}:{revokeMethod:p},pkce:w,scopeDialect:y,...l===void 0?{}:{authorizeParams:l},...S===void 0?{}:{tokenHeaders:S},...E===void 0?{}:{identity:E}},$e=new URL(a.url).pathname,De={mode:"oauth_client",label:t.name,secrets:{clientId:d,...u===void 0?{}:{clientSecret:u}},token:[{host:a.host,path:$e,methods:["POST"],inject:m}],access:t.access??["read"],console:t.docs,authorize:{url:r.url,scopes:F},scopePolicy:Ce,api:[...t.hosts],redirectPaths:[],flow:Ne,...t.readMethods===void 0?{}:{readMethods:t.readMethods},...t.writeMethods===void 0?{}:{writeMethods:t.writeMethods},...t.description===void 0?{}:{description:t.description},...t.reference===void 0?{}:{reference:t.reference},...t.hint===void 0?{}:{hint:t.hint},...t.example===void 0?{}:{example:t.example},...t.tags===void 0?{}:{tags:t.tags}},ue=[...t.hosts];for(let b of[r.host,a.host,c?.host])b&&!ue.includes(b)&&ue.push(b);return{capability:De,hosts:ue}}function kn(e,t){let s=t.flow,n=t.scopePolicy;if(!s||!n)return null;let o=t.token[0]?.inject??"form";return{id:e,name:t.label,...t.description===void 0?{}:{description:t.description},docs:t.console,...t.reference===void 0?{}:{api:t.reference},hosts:[...t.api],auth:{kind:"oauth2-user",authorizeUrl:t.authorize.url,tokenUrl:s.tokenUrl,...s.revokeUrl===void 0?{}:{revokeUrl:s.revokeUrl},...s.revokeMethod===void 0?{}:{revokeMethod:s.revokeMethod},clientId:t.secrets.clientId,...t.secrets.clientSecret===void 0?{}:{clientSecret:t.secrets.clientSecret},inject:o,pkce:s.pkce,scopeDialect:s.scopeDialect,...s.authorizeParams===void 0?{}:{authorizeParams:{...s.authorizeParams}},...s.tokenHeaders===void 0?{}:{tokenHeaders:{...s.tokenHeaders}},...s.identity===void 0?{}:{identity:{...s.identity}}},scopeSets:Object.fromEntries(Object.entries(n.sets).map(([r,a])=>[r,{label:a.label,access:a.access,scopes:[...a.scopes],...a.userScopes===void 0?{}:{userScopes:[...a.userScopes]},...a.routes.length===0?{}:{routes:a.routes.map(c=>({host:c.host,paths:[...c.paths],...c.posts===void 0?{}:{posts:c.posts.map(p=>p.source.replace(/\\\//g,"/"))}}))}}])),...n.alwaysRequested.length===0?{}:{alwaysRequested:[...n.alwaysRequested]},...n.tolerated.length===0?{}:{tolerated:[...n.tolerated]},access:[...t.access],...t.readMethods===void 0?{}:{readMethods:[...t.readMethods]},...t.writeMethods===void 0?{}:{writeMethods:[...t.writeMethods]},...t.hint===void 0?{}:{hint:t.hint},...t.example===void 0?{}:{example:t.example},...t.tags===void 0?{}:{tags:[...t.tags]}}}var Lt=/^[a-z][a-z0-9-]{1,39}$/,Ua=/^[A-Z][A-Z0-9_]{2,63}$/,ja=/^(?=.{1,253}$)(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/,Dt=["GET","HEAD","POST","PUT","PATCH","DELETE"],za=/^[a-z0-9_-]{1,64}$/,Ka=/^[A-Za-z0-9-]{1,64}$/,Ha=/^[A-Za-z0-9_.-]{1,64}$/,Wa=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,Ba=/^[A-Za-z_][A-Za-z0-9_]{0,63}(?:\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/,Ya=/^\d{4}-\d{2}-\d{2}$/,Va=/^[a-z][a-z0-9-]{0,31}$/,qa=/[\p{Cc}\p{Cf}]/u,Fa=new Set(["host","cookie","content-length","content-type","transfer-encoding","connection","upgrade","te","trailer","keep-alive","proxy-authorization","proxy-authenticate","forwarded","x-forwarded-for","x-forwarded-host","x-forwarded-proto"]),Ja=20,Sn=50,Xa=new Set(["id","mode","name","description","docs","api","hosts","hostSetting","data","auth","secrets","access","readMethods","writeMethods","accountWidePaths","hint","smoke","cost","rate","example","verified","tags","scopeSets","alwaysRequested","tolerated"]),Za=["hostSetting","data","secrets","accountWidePaths","smoke","cost","rate","verified"],Qa=["scopeSets","alwaysRequested","tolerated"];function U(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,s,{max:n,min:o=1}){if(e!==void 0){if(typeof e!="string"){s.push({path:t,message:"must be a string"});return}if(e.length<o||e.length>n){s.push({path:t,message:`must be ${o} to ${n} characters`});return}if(qa.test(e)){s.push({path:t,message:"holds a control character"});return}return e}}function In(e,t,s){let n=I(e,t,s,{max:500});if(n===void 0)return;let o;try{o=new URL(n)}catch{s.push({path:t,message:"must be an https URL"});return}if(o.protocol!=="https:"){s.push({path:t,message:"must be an https URL"});return}return n}function Je(e,t,s,{max:n,each:o}){if(e===void 0)return;if(!Array.isArray(e)){s.push({path:t,message:"must be a list"});return}if(e.length>n){s.push({path:t,message:`at most ${n} entries`});return}let r=[];return e.forEach((a,c)=>{if(typeof a!="string"){s.push({path:`${t}.${c}`,message:"must be a string"});return}o(a,`${t}.${c}`),r.push(a)}),new Set(r).size!==r.length&&s.push({path:t,message:"lists an entry twice"}),r}function Tn(e,t,s){return Je(e,t,s,{max:Dt.length,each:(n,o)=>{Dt.includes(n)||s.push({path:o,message:`must be one of ${Dt.join(", ")}`})}})}function Fe(e,t,s){if(typeof e!="string"||!Ua.test(e)){s.push({path:t,message:"must name a Gateway setting: upper case letters, digits and underscores, a letter first, 3 to 64 characters (STRIPE_API_KEY)"});return}return e}function ei(e,t){if(!U(e)){t.push({path:"auth",message:"must be an object with a kind: bearer, header, query or basic"});return}let s=e.kind,n=Fe(e.secret,"auth.secret",t),o=r=>{for(let a of Object.keys(e))r.includes(a)||t.push({path:`auth.${a}`,message:`not a field of auth.kind ${String(s)}`})};switch(s){case"bearer":{o(["kind","secret","scheme"]);let r=I(e.scheme,"auth.scheme",t,{max:32});return r!==void 0&&!Wa.test(r)&&t.push({path:"auth.scheme",message:"must be a token such as Bearer, Token or Api-Key"}),n?{kind:s,secret:n,...r===void 0?{}:{scheme:r}}:void 0}case"header":{o(["kind","secret","header","prefix"]);let r=I(e.header,"auth.header",t,{max:64});r!==void 0&&(Ka.test(r)?(Fa.has(r.toLowerCase())||r.toLowerCase().startsWith("x-everyapp-"))&&t.push({path:"auth.header",message:`${r} is a header the Gateway sets or strips itself`}):t.push({path:"auth.header",message:"must be a header name (letters, digits, hyphens)"}));let a=I(e.prefix,"auth.prefix",t,{max:32,min:0});return!n||r===void 0?void 0:{kind:s,secret:n,header:r,...a===void 0?{}:{prefix:a}}}case"query":{o(["kind","secret","param"]);let r=I(e.param,"auth.param",t,{max:64});return r!==void 0&&!Ha.test(r)&&t.push({path:"auth.param",message:"must be a query parameter name"}),!n||r===void 0?void 0:{kind:s,secret:n,param:r}}case"basic":{o(["kind","secret","as","user"]);let r=e.as;if(r!=="password"&&r!=="username"&&r!=="pair"){t.push({path:"auth.as",message:'must say where the key goes: "password" (beside user), "username" (with an empty password), or "pair" (the key is login:password)'});return}if(r!=="password")return e.user!==void 0&&t.push({path:"auth.user",message:`not a field of auth.as ${r}`}),n?{kind:s,secret:n,as:r}:void 0;let a=e.user,c;if(typeof a=="string"){let p=I(a,"auth.user",t,{max:128});p!==void 0&&p.includes(":")&&t.push({path:"auth.user",message:"may not hold a colon"}),c=p}else if(U(a)&&Object.keys(a).join()==="secret"){let p=Fe(a.secret,"auth.user.secret",t);p!==void 0&&p===n&&t.push({path:"auth.user.secret",message:"must be another setting than auth.secret"}),c=p===void 0?void 0:{secret:p}}else t.push({path:"auth.user",message:"required with as: password: a string, or { secret: NAME }"});return!n||c===void 0?void 0:{kind:s,secret:n,as:r,user:c}}default:t.push({path:"auth.kind",message:"must be bearer, header, query, basic or oauth2-user (an AI provider is a catalog entry, not a spec this gateway takes)"});return}}function ti(e,t,s){if(e===void 0)return;if(!Array.isArray(e)){s.push({path:"secrets",message:"must be a list"});return}let n=[];return e.forEach((o,r)=>{let a=`secrets.${r}`;if(!U(o)){s.push({path:a,message:"must be an object"});return}for(let d of Object.keys(o))["name","hint"].includes(d)||s.push({path:`${a}.${d}`,message:"unknown field"});let c=Fe(o.name,`${a}.name`,s);c!==void 0&&!t.includes(c)&&s.push({path:`${a}.name`,message:`auth names no setting ${c}`});let p=I(o.hint,`${a}.hint`,s,{max:300});c!==void 0&&n.push({name:c,...p===void 0?{}:{hint:p}})}),new Set(n.map(o=>o.name)).size!==n.length&&s.push({path:"secrets",message:"names a setting twice"}),n}function si(e,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:"accountWidePaths",message:'must be a list of segment runs: [["v1", "account"]]'});return}if(e.length>Sn){t.push({path:"accountWidePaths",message:`at most ${Sn} entries`});return}let s=[];return e.forEach((n,o)=>{let r=`accountWidePaths.${o}`;if(!Array.isArray(n)||n.length===0){t.push({path:r,message:"must be a non-empty list of segments"});return}let a=[];n.forEach((c,p)=>{if(typeof c!="string"||!za.test(c)){t.push({path:`${r}.${p}`,message:"must be a lowercase path segment (letters, digits, _ and -)"});return}a.push(c)}),a.length===n.length&&s.push(a)}),s}function ni(e,t,s){if(e===void 0)return;if(!U(e)){s.push({path:"smoke",message:"must be an object"});return}for(let u of Object.keys(e))["method","host","path","expect","free","note"].includes(u)||s.push({path:`smoke.${u}`,message:"unknown field"});let n=e.method;n!=="GET"&&n!=="HEAD"&&n!=="POST"&&s.push({path:"smoke.method",message:"must be GET, HEAD or POST"});let o=I(e.host,"smoke.host",s,{max:253});o!==void 0&&!t.includes(o)&&s.push({path:"smoke.host",message:"must be one of hosts"});let r=I(e.path,"smoke.path",s,{max:500});r!==void 0&&(!r.startsWith("/")||r.startsWith("//"))&&s.push({path:"smoke.path",message:"must start with one /"});let a=e.expect,c=Array.isArray(a)&&a.length>0&&a.every(u=>Number.isInteger(u)&&u>=100&&u<=599)?a:void 0;c||s.push({path:"smoke.expect",message:"must list the HTTP statuses that mean the key works"});let p=e.free;typeof p!="boolean"&&s.push({path:"smoke.free",message:"must be true or false"});let d=I(e.note,"smoke.note",s,{max:200});if(!(n!=="GET"&&n!=="HEAD"&&n!=="POST"||r===void 0||!c||typeof p!="boolean"))return{method:n,...o===void 0?{}:{host:o},path:r,expect:c,free:p,...d===void 0?{}:{note:d}}}function qe(e,t,s){if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e)||e<0){s.push({path:t,message:"must be a number, zero or more"});return}return e}}function oi(e,t){if(e===void 0)return;if(!U(e)){t.push({path:"cost",message:"must be an object"});return}for(let a of Object.keys(e))["unit","usd","note","responseField"].includes(a)||t.push({path:`cost.${a}`,message:"unknown field"});let s=e.unit;s!=="call"&&s!=="result"&&s!=="token"&&t.push({path:"cost.unit",message:"must be call, result or token"});let n=qe(e.usd,"cost.usd",t),o=I(e.note,"cost.note",t,{max:200}),r=I(e.responseField,"cost.responseField",t,{max:128});if(r!==void 0&&!Ba.test(r)&&t.push({path:"cost.responseField",message:"must be a JSON field name, or a dotted path to a nested one"}),!(s!=="call"&&s!=="result"&&s!=="token"))return{unit:s,...n===void 0?{}:{usd:n},...o===void 0?{}:{note:o},...r===void 0?{}:{responseField:r}}}function ri(e,t){if(e===void 0)return;if(!U(e)){t.push({path:"rate",message:"must be an object"});return}for(let a of Object.keys(e))["perSecond","perMinute","perDay","note"].includes(a)||t.push({path:`rate.${a}`,message:"unknown field"});let s=qe(e.perSecond,"rate.perSecond",t),n=qe(e.perMinute,"rate.perMinute",t),o=qe(e.perDay,"rate.perDay",t),r=I(e.note,"rate.note",t,{max:200});return{...s===void 0?{}:{perSecond:s},...n===void 0?{}:{perMinute:n},...o===void 0?{}:{perDay:o},...r===void 0?{}:{note:r}}}function ai(e,t){if(e!==void 0){if(e===!1)return!1;if(U(e)&&typeof e.on=="string"&&Ya.test(e.on)&&(e.how==="docs"||e.how==="live")&&Object.keys(e).length===2)return{on:e.on,how:e.how};t.push({path:"verified",message:'must be false, or { "on": "YYYY-MM-DD", "how": "docs" | "live" }'})}}function vn(e,t){let s=Je(e.access,"access",t,{max:2,each:(r,a)=>{r!=="read"&&r!=="write"&&t.push({path:a,message:"must be read or write"})}});s&&s.length===0&&t.push({path:"access",message:"must list read, write or both"});let n=Tn(e.readMethods,"readMethods",t);n&&n.length===0&&(!Array.isArray(s)||s.includes("read"))&&t.push({path:"readMethods",message:"must list a method unless access is write alone"});let o=Tn(e.writeMethods,"writeMethods",t);return{access:s,readMethods:n,writeMethods:o}}function Pn(e,t){return Je(e,"tags",t,{max:10,each:(s,n)=>{Va.test(s)||t.push({path:n,message:"must be a lowercase word"})}})}function ye(e){let t=[];if(!U(e))return{ok:!1,problems:[{path:"(root)",message:"must be a JSON object"}]};for(let b of Object.keys(e))Xa.has(b)||t.push({path:b,message:"unknown field"});let s=e.id;(typeof s!="string"||!Lt.test(s))&&t.push({path:"id",message:"must be lowercase letters, digits and hyphens, a letter first, 2 to 40 characters (stripe)"});let n=U(e.auth)&&e.auth.kind==="oauth2-user",o=n?"oauth_client":"api_key";e.mode!==void 0&&e.mode!==o&&t.push({path:"mode",message:n?"an oauth2-user spec's mode is oauth_client (or left out)":"this gateway registers api_key and oauth_client (auth.kind oauth2-user) providers; an AI provider is a catalog entry"});let r=I(e.name,"name",t,{max:64});e.name===void 0&&t.push({path:"name",message:"required"});let a=I(e.description,"description",t,{max:200}),c=In(e.docs,"docs",t);e.docs===void 0&&t.push({path:"docs",message:"required: where the person gets the key, an https URL"});let p=In(e.api,"api",t),d=Je(e.hosts,"hosts",t,{max:Ja,each:(b,P)=>{ja.test(b)||t.push({path:P,message:"must be a bare lowercase host with a dot and no port, path or scheme (api.stripe.com)"})}});if(n){let{access:b,readMethods:P,writeMethods:Le}=vn(e,t),Ts=I(e.hint,"hint",t,{max:500}),vs=I(e.example,"example",t,{max:200}),Ps=Pn(e.tags,t);for(let Rs of Za)e[Rs]!==void 0&&t.push({path:Rs,message:"not a field of an oauth2-user spec"});(e.hosts===void 0||d&&d.length===0)&&t.push({path:"hosts",message:"required: at least one API host the token is sent to"});let xs=typeof s=="string"&&r!==void 0&&c!==void 0&&d!==void 0?An(e,{id:s,name:r,docs:c,hosts:d,...a===void 0?{}:{description:a},...p===void 0?{}:{reference:p},...b===void 0?{}:{access:b},...P===void 0?{}:{readMethods:P},...Le===void 0?{}:{writeMethods:Le},...Ts===void 0?{}:{hint:Ts},...vs===void 0?{}:{example:vs},...Ps===void 0?{}:{tags:Ps}},t):void 0;return t.length>0||!xs||typeof s!="string"?{ok:!1,problems:t}:{ok:!0,id:s,capability:xs.capability}}for(let b of Qa)e[b]!==void 0&&t.push({path:b,message:"only an oauth2-user spec has it"});let u=e.hostSetting===void 0?void 0:Fe(e.hostSetting,"hostSetting",t);u===void 0&&(e.hosts===void 0||d&&d.length===0)&&t.push({path:"hosts",message:"required: at least one host, or a hostSetting naming one"});let m=e.data;m!==void 0&&m!=="per-call"&&m!=="account"&&t.push({path:"data",message:"must be per-call or account"});let w=m==="per-call"||m==="account"?m:void 0,y=ei(e.auth,t);e.auth===void 0&&t.push({path:"auth",message:"required"}),u!==void 0&&y&&Z(y).includes(u)&&t.push({path:"hostSetting",message:"must be another setting than the key"});let l=ti(e.secrets,[...y?Z(y):[],...u===void 0?[]:[u]],t),{access:S,readMethods:E,writeMethods:A}=vn(e,t),k=si(e.accountWidePaths,t),L=I(e.hint,"hint",t,{max:500}),F=ni(e.smoke,d??[],t),J=oi(e.cost,t),Ce=ri(e.rate,t),Ne=I(e.example,"example",t,{max:200}),$e=ai(e.verified,t),De=Pn(e.tags,t);if(t.length>0||typeof s!="string"||r===void 0||c===void 0||!d&&u===void 0||!y)return{ok:!1,problems:t};let ue={mode:"api_key",label:r,auth:y,docs:c,hosts:d??[],...u===void 0?{}:{hostSetting:u},...w===void 0?{}:{data:w},access:S??["read"],readMethods:E??["GET","HEAD"],accountWidePaths:k??[],...a===void 0?{}:{description:a},...p===void 0?{}:{api:p},...l===void 0?{}:{secrets:l},...A===void 0?{}:{writeMethods:A},...L===void 0?{}:{hint:L},...F===void 0?{}:{smoke:F},...J===void 0?{}:{cost:J},...Ce===void 0?{}:{rate:Ce},...Ne===void 0?{}:{example:Ne},...$e===void 0?{}:{verified:$e},...De===void 0?{}:{tags:De}};return{ok:!0,id:s,capability:ue}}function Mt(e){return e.map(t=>`${t.path}: ${t.message}`).join("; ")}function Du(e,t){if(t.mode==="oauth_client"){let s=kn(e,t);if(!s)throw new Error(`${e} is a catalog OAuth client without a Gateway-owned flow: it has no spec`);return s}return{id:e,name:t.label,...t.description===void 0?{}:{description:t.description},docs:t.docs,...t.api===void 0?{}:{api:t.api},hosts:[...t.hosts],...t.hostSetting===void 0?{}:{hostSetting:t.hostSetting},...t.data===void 0?{}:{data:t.data},auth:{...t.auth},...t.secrets===void 0?{}:{secrets:t.secrets.map(s=>({...s}))},access:[...t.access],readMethods:[...t.readMethods],...t.writeMethods===void 0?{}:{writeMethods:[...t.writeMethods]},accountWidePaths:t.accountWidePaths.map(s=>[...s]),...t.hint===void 0?{}:{hint:t.hint},...t.smoke===void 0?{}:{smoke:{...t.smoke,expect:[...t.smoke.expect]}},...t.cost===void 0?{}:{cost:{...t.cost}},...t.rate===void 0?{}:{rate:{...t.rate}},...t.example===void 0?{}:{example:t.example},...t.verified===void 0?{}:{verified:t.verified},...t.tags===void 0?{}:{tags:[...t.tags]}}}var h=(e,t,s,n=1)=>({type:t,version:n,description:s,group:e}),Ut=[h("member","member.invited","Someone was invited to the workspace"),h("member","member.joined","Someone joined the workspace"),h("member","member.role_changed","A member's role changed"),h("member","member.deactivated","A member was deactivated"),h("member","member.reactivated","A member was reactivated"),h("member","member.removed","A member was removed"),h("member","member.password_reset","A member reset their password"),h("member","member.invitation_cancelled","A pending invitation was cancelled"),h("organization","organization.renamed","The workspace was renamed"),h("app","app.installed","An app was installed on the Gateway"),h("app","app.updated","An app was redeployed"),h("app","app.live","An app went live on the Gateway"),h("app","app.removed","An app was removed from the Gateway"),h("app","app.needs_setup","An app needs a setting before it opens"),h("app","app.ready","An app has every setting it needs"),h("app","app.paused_cap","An app is paused: its monthly cap is reached"),h("app","app.tools_changed","An app's AI tools changed"),h("app","app.renamed","An app's name or description changed"),h("app","app.settings_changed","An app's settings were set or unset (names only)"),h("app","app.access_changed","Who can open an app changed"),h("app","app.email_changed","An app's email senders or inbound changed"),h("cap","cap.warning","An app is at 80% of its monthly cap"),h("cap","cap.reached","An app reached its monthly cap"),h("cap","cap.raised","An app's monthly cap, or the workspace default, was raised or removed"),h("cap","cap.changed","An app's monthly cap, or the workspace default, was set or lowered"),h("group","group.created","A group was created"),h("group","group.updated","A group was renamed or described"),h("group","group.removed","A group was removed"),h("group","group.members_changed","A group's members changed"),h("group","group.apps_changed","The apps a group opens changed"),h("tool","tool.blocked","An AI client's tool call was blocked"),h("tool","tool.error","An AI client's tool call failed"),h("connection","connection.created","An AI app was connected"),h("connection","connection.revoked","An AI app connection was revoked"),h("token","token.created","A personal access token was created"),h("token","token.revoked","A personal access token was revoked"),h("access","access.changed","Cloudflare Access was turned on or off"),h("signin_provider","signin_provider.added","A sign-in provider (Continue with Google, \u2026) was turned on"),h("signin_provider","signin_provider.removed","A sign-in provider was turned off"),h("mcp_app","mcp_app.added","An MCP app was added"),h("mcp_app","mcp_app.removed","An MCP app was removed"),h("mcp_app","mcp_app.enabled","An MCP app is being served again"),h("mcp_app","mcp_app.disabled","An MCP app stopped being served"),h("mcp_app","mcp_app.updated","An MCP app's risk default, name or description changed"),h("mcp_app","mcp_app.tool_changed","One tool of an MCP app was overridden: its risk, or on/off"),h("provider","provider.added","A provider was registered"),h("provider","provider.removed","A provider was removed"),h("provider","provider.updated","A provider's spec or OAuth client was replaced"),h("provider","provider.connected","Someone connected an account at an OAuth provider"),h("provider","provider.disconnected","An OAuth provider account was disconnected"),h("provider","provider.connection_expired","An OAuth provider refused to refresh a connection; it needs reconnecting"),h("subscription","subscription.created","An event subscription was added"),h("subscription","subscription.updated","An event subscription was changed, paused or resumed"),h("subscription","subscription.removed","An event subscription was removed"),h("subscription","subscription.redelivered","A delivery was queued again by hand"),h("ai","ai.default_changed","The default model provider changed"),h("ping","ping","A test event, sent to one subscription on request")],jt=new Map(Ut.map(e=>[e.type,e]));function xn(e){return jt.get(e)}var se="app.";var ii=64;function Xe(e){return e.startsWith(se)&&!jt.has(e)&&e.slice(se.length).includes(".")}var ci=8*1024,Mu=16*1024,Rn=8;var Gu=25,Uu=16,ju=128,zu=30;var Ku=200,Hu=2048,Wu=100,di=[6e4,3e5,18e5,72e5,288e5,864e5],Bu=di.length+1;var Yu="EVENTS_ALLOW_PRIVATE_TARGETS",pi=["localhost","local","localdomain","internal","intranet","lan","corp","private","home.arpa","onion"];function Vu(e){return e.includes(".")?pi.some(t=>e===t||e.endsWith(`.${t}`)):!0}var qu=["owners","admins"];function On(e,t){return e==="*"?t!=="ping"&&!t.startsWith("subscription."):e.endsWith(".*")?t.startsWith(e.slice(0,-1)):e===t}function Fu(e,t){return e.some(s=>On(s,t))}var ui=/^(\*|[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*(\.\*)?)$/;function Ju(e){if(!ui.test(e)||e.length>ii+8)return`"${e}" isn't an event type or pattern (member.joined, member.*, app.crm.*, *)`;if(e==="*"||jt.has(e))return null;if(e.endsWith(".*")){let t=e.slice(0,-1);return Ut.some(s=>s.type.startsWith(t))||e.startsWith(se)?null:`"${e}" matches no event type (everyapp events types lists them)`}return Xe(e)?null:`"${e}" isn't an event type (everyapp events types lists them)`}var li=/secret|token|password|passwd|authorization|api[_-]?key|private[_-]?key|credential|cookie|session/i;function Gt(e,t){if(t>Rn)return"\0depth";if(Array.isArray(e)){for(let s of e){let n=Gt(s,t+1);if(n)return n}return null}if(e&&typeof e=="object")for(let[s,n]of Object.entries(e)){if(li.test(s))return s;let o=Gt(n,t+1);if(o)return o}return null}function Xu(e,t=ci){if(e===null||typeof e!="object"||Array.isArray(e))return{ok:!1,code:"event_data_invalid",message:"data is a JSON object"};let s;try{s=JSON.stringify(e)}catch{return{ok:!1,code:"event_data_invalid",message:"data must serialize as JSON"}}if(s===void 0)return{ok:!1,code:"event_data_invalid",message:"data is a JSON object"};let n=new TextEncoder().encode(s).length;if(n>t)return{ok:!1,code:"event_data_too_large",message:`data is at most ${t.toLocaleString("en-US")} bytes as JSON (this is ${n.toLocaleString("en-US")})`,bytes:n};let o=Gt(JSON.parse(s),1);return o==="\0depth"?{ok:!1,code:"event_data_invalid",message:`data nests at most ${Rn} levels deep`}:o?{ok:!1,code:"event_data_refused",message:`data must not carry a credential: the key "${o}" reads like one (secret, token, password, authorization, api key, private key, credential, cookie, session)`,key:o}:{ok:!0,bytes:n}}function H(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function T(e){return typeof e=="string"&&e.length>0?e:null}function Ze(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function el(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{t={}}let s=H(t);return{kind:T(s.kind)??"gateway",id:T(s.id),email:T(s.email),name:T(s.name)}}function tl(e){switch(e.kind){case"user":return e.name??e.email??e.id??"a member";case"agent":return`agent \xB7 ${e.name??e.id??"AI app"}`;case"operator":return`CLI \xB7 ${e.email??e.id??"operator"}`;case"app":return`app \xB7 ${e.id??"app"}`;case"gateway":return"Gateway";default:return e.name??e.email??e.id??e.kind}}function sl(e){let t=xn(e);if(t)return t.description;if(Xe(e)){let s=e.slice(se.length);return`App event: ${s.slice(s.indexOf(".")+1)}`}return e}function Qe(e){let t=H(e),s=T(t.id)??T(t.rowId);return s?{id:s,name:T(t.name)}:void 0}function nl(e,t){let s=H(t),n={},o=Qe(s.app);if(o)e.startsWith("mcp_app.")?n.mcpApp=o:n.app=o;else if(Xe(e)){let y=e.slice(se.length);n.app={id:y.slice(0,y.indexOf(".")),name:null}}let r=H(s.user);T(r.id)&&(n.user={id:T(r.id),email:T(r.email),name:T(r.name)});let a=Qe(s.group);a&&(n.group=a);let c=Qe(s.provider);c&&(n.provider=c);let p=Qe(s.subscription);p&&(n.subscription=p);let d=H(s.invitation);T(d.email)&&(n.invitation={email:T(d.email),role:T(d.role)});let u=[...Ze(s.settings),...Ze(s.unmet),...Ze(s.changed),...Ze(s.names)];u.length>0&&(n.settings=[...new Set(u)]);let m=T(s.tool);m&&(n.tool=m);let w=T(H(s.client).name)??T(H(s.connection).clientName);return w&&(n.client=w),e.startsWith("token.")&&T(s.name)&&(n.token=T(s.name)),n}function ol(e){let t=[],s=e.app??e.mcpApp;return s&&t.push(s.name??s.id),e.user&&t.push(e.user.name??e.user.email??e.user.id),e.invitation&&t.push(e.invitation.email),e.group&&t.push(e.group.name??e.group.id),e.provider&&t.push(e.provider.name??e.provider.id),e.subscription&&t.push(e.subscription.name??e.subscription.id),e.token&&t.push(e.token),e.tool&&t.push(e.tool),e.client&&t.push(e.client),e.settings&&t.push(e.settings.join(", ")),t.join(" \xB7 ")}function rl(e){return e==="*"?null:e.endsWith(".*")?{op:"prefix",value:e.slice(0,-1)}:{op:"eq",value:e}}var hi=".everyapp/providers";function cl(e){return`${hi}/${e}.json`}var W=new TextEncoder,Cn=new TextDecoder,mi=new TextDecoder("utf-8",{fatal:!0}),pl=2**32;function Nn(...e){let t=e.reduce((o,{length:r})=>o+r,0),s=new Uint8Array(t),n=0;for(let o of e)s.set(o,n),n+=o.length;return s}var fi=/[^\x00-\x7f]/;function et(e){if(typeof e=="string"&&e.length>=128){if(fi.test(e))throw new TypeError("non-ASCII string encountered in encode()");return W.encode(e)}let t=new Uint8Array(e.length);for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);if(n>127)throw new TypeError("non-ASCII string encountered in encode()");t[s]=n}return t}function zt(e,t=!1){if(Uint8Array.prototype.toBase64)return e.toBase64({alphabet:t?"base64url":"base64",omitPadding:t});let s=32768,n=[];for(let r=0;r<e.length;r+=s)n.push(String.fromCharCode.apply(null,e.subarray(r,r+s)));let o=btoa(n.join(""));return t?o.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"):o}function tt(e,t=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:t?"base64url":"base64"});if(t){if(e.includes("+")||e.includes("/"))throw new TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let s=atob(e),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return n}var B=class extends Error{code="ERR_JOSE_GENERIC";constructor(t,s){super(t,s),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};X(B,"code","ERR_JOSE_GENERIC");var R=class extends B{code="ERR_JOSE_NOT_SUPPORTED"};X(R,"code","ERR_JOSE_NOT_SUPPORTED");var C=class extends B{code="ERR_JWS_INVALID"};X(C,"code","ERR_JWS_INVALID");var we=class extends B{code="ERR_JWT_INVALID"};X(we,"code","ERR_JWT_INVALID");var Kt=class extends B{[Symbol.asyncIterator]=async function*(){};code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";constructor(t="multiple matching keys found in the JSON Web Key Set",s){super(t,s)}};X(Kt,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var gi="The input to be decoded is not correctly encoded.";function $n(e){try{return tt(typeof e=="string"?e:Cn.decode(e),!0)}catch(t){throw new TypeError(gi,{cause:t})}}function Ee(e){return zt(typeof e=="string"?W.encode(e):e,!0)}function be(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function Dn(...e){let t=new Set;for(let s of e)if(s)for(let n of Object.keys(s)){if(t.has(n))return!1;t.add(n)}return!0}function Ln(e,t){if(e!==void 0)throw new TypeError(`${t} can only be called once`)}var Mn={__proto__:null,b64:!0};function Gn(e,t){let{crit:s}=t??{};if(Array.isArray(s)&&new Set(s).size!==s.length)throw new e('"crit" (Critical) Header Parameter MUST NOT contain duplicate values')}function Un(e,t,s,n,o){if(o.crit!==void 0&&n?.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return[];if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let r=s===void 0?t:{__proto__:null,...s,...t};for(let a of n.crit){if(!(a in r))throw new R(`Extension Header Parameter "${a}" is not recognized`);if(!Object.hasOwn(o,a)||o[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(r[a]&&(!Object.hasOwn(n,a)||n[a]===void 0))throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return n.crit}function jn(e,t){if(t.includes("b64")){let s=e.b64;if(typeof s!="boolean")throw new C('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return s}return!0}function Ht(e,t){let s,n;try{s=JSON.stringify(t),n=JSON.parse(s)}catch(o){throw new e("JOSE Header is not valid JSON",{cause:o})}if(!be(n))throw new e("JOSE Header is not a JSON object");return[n,s]}var yi=e=>e[Symbol.toStringTag],wi=(e,t,s)=>{let{alg:n}=e;if(t.use!==void 0){let o=s==="sign"||s==="verify"?"sig":"enc";if(t.use!==o)throw new TypeError(`Invalid key for this operation, its "use" must be "${o}" when present`)}if(t.alg!==void 0&&t.alg!==n)throw new TypeError(`Invalid key for this operation, its "alg" must be "${n}" when present`);if(Array.isArray(t.key_ops)){let o=s==="encrypt"||s==="decrypt"?e.ops?.[s==="encrypt"?0:1]:s;if(o&&!t.key_ops.includes(o))throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${o}" when present`)}};async function Kn(e,t,s){let{alg:n,secret:o}=e,r=s==="decrypt"||s==="sign";if(o&&t instanceof Uint8Array)return t;let a,c;if(be(t)){if(a=Ii(t),typeof a.kty!="string")throw zn(n,t,o);if(!(o?a.kty==="oct"&&typeof a.k=="string":a.kty!=="oct"&&(r?a.kty==="AKP"&&typeof a.priv=="string"||typeof a.d=="string":a.d===void 0&&a.priv===void 0)))throw new TypeError(o?'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present':`JSON Web Key for this operation must be a ${r?"private":"public"} JWK`);if(wi(e,a,s),a.kty==="oct")return $n(a.k);if(!Object.isFrozen(t)){let{key_ops:u}=t;Array.isArray(u)&&Object.freeze(u),Object.freeze(t)}}else{if(!bi(t))throw zn(n,t,o);let u=o?"secret":r?"private":"public";if(t.type!==u&&(o||["secret","public","private"].includes(t.type)))throw new TypeError(`${yi(t)} instances must be of type "${u}" for the ${n} algorithm`);if(Bt(t))return t;if(c=t,c.type==="secret")return c.export()}Wt||=new WeakMap;let p=t,d=Wt.get(p);if(d?.[n])return d[n];if(d||Wt.set(p,d={}),c&&typeof c.toCryptoKey=="function"){let u=c.type==="public",m=Ei[c.asymmetricKeyDetails?.namedCurve],w=e.resolve?.({crv:m,asymmetricKeyType:c.asymmetricKeyType})??e.subtle;return d[n]=c.toCryptoKey(w,u,e.usages[u?0:1])}return a??=c.export({format:"jwk"}),a.alg=n,d[n]=await Ti(e,a)}var Wt,Ei={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};var Bt=e=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},Hn=e=>e?.[Symbol.toStringTag]==="KeyObject",bi=e=>Bt(e)||Hn(e);function _i(e,t,...s){if(s.length>2){let n=s.pop();e+=`one of type ${s.join(", ")}, or ${n}.`}else s.length===2?e+=`one of type ${s[0]} or ${s[1]}.`:e+=`of type ${s[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}function zn(e,t,s){let n=["CryptoKey","KeyObject","JSON Web Key"];return s&&n.push("Uint8Array"),new TypeError(_i(`Key for the ${e} algorithm must be `,t,...n))}var st=(e,t="algorithm.name")=>new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function Ai(e,t){if(t&&!e.usages.includes(t))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function Wn(e,t){let{modulusLength:s}=t.algorithm;if(typeof s!="number"||s<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}function ki(e,t,s){let n=e.algorithm;if(n.name!==t.name)throw st(t.name);if(t.hash&&n.hash?.name!==t.hash)throw st(t.hash,"algorithm.hash");if(t.namedCurve&&n.namedCurve!==t.namedCurve)throw st(t.namedCurve,"algorithm.namedCurve");if(t.length!==void 0&&n.length!==t.length)throw st(t.length,"algorithm.length");Ai(e,s)}function Si(e){return{__proto__:null,...e}}function Ii(e){let t=Si(e);if(t.ext!==void 0&&typeof t.ext!="boolean")throw new TypeError('"ext" (Extractable) Parameter must be a boolean');if(t.key_ops!==void 0){let s=t.key_ops,n=Array.isArray(s)?[...s]:void 0;if(!n||n.some(o=>typeof o!="string")||new Set(n).size!==n.length)throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');t.key_ops=n}return t}function Bn(e){if(e!==void 0&&typeof e!="boolean")throw new TypeError('"extractable" option must be a boolean');return e}async function Ti(e,t,s){if(!e.kty.includes(t.kty))throw new R('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');let n=e.resolve?.({kty:t.kty,crv:t.crv})??e.subtle,o=!!(t.d||t.priv),r={...t,ext:s??t.ext};return r.kty!=="AKP"&&delete r.alg,delete r.use,crypto.subtle.importKey("jwk",r,n,r.ext??!o,t.key_ops??e.usages[o?1:0])}async function Yn(e,t,s,n=!1){return e instanceof Uint8Array&&(e=await crypto.subtle.importKey("raw",e,t,n,[s])),ki(e,t,s),e}function _e(e){let t={__proto__:null};for(let s in e)t[s]={...e[s],alg:s};return t}var vi=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Pi=[[],["deriveBits"]],rt=[[],[]];function nt(e){return{kty:["RSA"],mode:"key-encryption",subtle:{name:"RSA-OAEP",hash:`SHA-${e}`},usages:vi,ops:["wrapKey","unwrapKey"]}}function ot(e){return{kty:["EC","OKP"],mode:e,subtle:{name:"ECDH"},resolve:({kty:t,crv:s,asymmetricKeyType:n})=>{if(s==="X25519"||n==="x25519")return{name:"X25519"};if(t==="OKP")throw new R('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return{name:"ECDH",namedCurve:s}},usages:Pi,ops:[void 0,"deriveBits"]}}function ne(e,t=!1){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:rt,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function Yt(){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:"PBKDF2"},usages:rt,ops:["deriveBits","deriveBits"]}}var Vn=_e({dir:{kty:["oct"],mode:"direct-encryption",secret:!0,subtle:{name:"AES-GCM"},usages:rt,ops:["encrypt","decrypt"]},"RSA-OAEP":nt(1),"RSA-OAEP-256":nt(256),"RSA-OAEP-384":nt(384),"RSA-OAEP-512":nt(512),"ECDH-ES":ot("direct-key-agreement"),"ECDH-ES+A128KW":ot("key-agreement-with-key-wrapping"),"ECDH-ES+A192KW":ot("key-agreement-with-key-wrapping"),"ECDH-ES+A256KW":ot("key-agreement-with-key-wrapping"),A128KW:ne(128),A192KW:ne(192),A256KW:ne(256),A128GCMKW:ne(128,!0),A192GCMKW:ne(192,!0),A256GCMKW:ne(256,!0),"PBES2-HS256+A128KW":Yt(),"PBES2-HS384+A192KW":Yt(),"PBES2-HS512+A256KW":Yt()}),xi=["encrypt","decrypt"];function oe(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:rt,ops:xi,cekBits:e,ivBits:t?128:96,cbc:t}}var Il=_e({A128GCM:oe(128),A192GCM:oe(192),A256GCM:oe(256),"A128CBC-HS256":oe(256,!0),"A192CBC-HS384":oe(384,!0),"A256CBC-HS512":oe(512,!0)});var Ae=[["verify"],["sign"]];function Vt(e){let t={name:"HMAC",hash:`SHA-${e}`};return{kty:["oct"],secret:!0,subtle:t,signing:t,usages:Ae}}function re(e,t){let s={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:`SHA-${e}`};return{kty:["RSA"],subtle:s,signing:t?{...s,saltLength:t}:s,usages:Ae,minRsaBits:2048}}function qt(e,t){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:`SHA-${t}`},usages:Ae}}function qn(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:Ae}}function Ft(e){let t={name:`ML-DSA-${e}`};return{kty:["AKP"],subtle:t,signing:t,usages:Ae}}var Jt=_e({HS256:Vt(256),HS384:Vt(384),HS512:Vt(512),RS256:re(256),RS384:re(384),RS512:re(512),PS256:re(256,32),PS384:re(384,48),PS512:re(512,64),ES256:qt("P-256",256),ES384:qt("P-384",384),ES512:qt("P-521",512),EdDSA:qn(),Ed25519:qn(),"ML-DSA-44":Ft(44),"ML-DSA-65":Ft(65),"ML-DSA-87":Ft(87)});function Fn(e){let t=typeof e=="string"?Jt[e]:void 0;if(!t)throw new R(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}var at=e=>Math.floor(e.getTime()/1e3),Ri={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Oi=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Xt(){throw new TypeError("Invalid time period format")}function Jn(e){typeof e!="string"&&Xt();let t=Oi.exec(e);(!t||t[4]&&t[1])&&Xt();let s=parseFloat(t[2]),n=Math.round(s*Ri[t[3][0].toLowerCase()]);return Number.isFinite(n)||Xt(),t[1]==="-"||t[4]==="ago"?-n:n}function es(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}function Zt(e,t){if(typeof t!="string")throw new TypeError(`"${e}" claim must be a string`)}function Ci(e){if(typeof e!="string"&&(!Array.isArray(e)||Array.from(e).some(t=>typeof t!="string")))throw new TypeError('"aud" claim must be a string or an array of strings')}function Qt(e,t){return typeof e=="number"?es(t,e):e instanceof Date?es(t,at(e)):at(new Date)+Jn(e)}var Xn;function j(e){return Xn.get(e)}function Zn(e){let t=j(e);for(let s of["iat","nbf","exp"]){let n=t[s];if(typeof n=="number"&&!Number.isFinite(n))throw new TypeError(`"${s}" claim must be a finite number`)}return W.encode(JSON.stringify(t))}var it=class{constructor(t={}){if(!be(t))throw new TypeError("JWT Claims Set MUST be an object");(Xn||=new WeakMap).set(this,structuredClone(t))}setIssuer(t){return Zt("iss",t),j(this).iss=t,this}setSubject(t){return Zt("sub",t),j(this).sub=t,this}setAudience(t){return Ci(t),j(this).aud=t,this}setJti(t){return Zt("jti",t),j(this).jti=t,this}setNotBefore(t){return j(this).nbf=Qt(t,"setNotBefore"),this}setExpirationTime(t){return j(this).exp=Qt(t,"setExpirationTime"),this}setIssuedAt(t){let s=j(this);return t===void 0?s.iat=at(new Date):typeof t=="string"?s.iat=es("setIssuedAt",at(new Date)+Jn(t)):s.iat=Qt(t,"setIssuedAt"),this}};async function Ni(e,t,s){let[n,o,r,a]=e,c="";if(o!==void 0){let A=Ht(C,o);o=A[0],c=Ee(A[1])}if(r!==void 0&&(r=Ht(C,r)[0]),!o&&!r)throw new C("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Dn(o,r))throw new C("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let p={...o,...r};Gn(C,o);let d=jn(o,Un(C,Mn,a,o,p));d||s?.();let{alg:u}=p;if(typeof u!="string"||!u)throw new C('JWS "alg" (Algorithm) Header Parameter missing or invalid');let m=Fn(u),w="",y=n,l;if(d){let A=e[4];A?(w=A[0]??=Ee(n),y=A[1]??=et(w)):(w=Ee(n),l=W.encode(`${c}.${w}`))}l??=Nn(et(c),et("."),y);let S=await Yn(await Kn(m,t,"sign"),m.subtle,"sign");m.minRsaBits&&Wn(m.alg,S);let E={signature:Ee(new Uint8Array(await crypto.subtle.sign(m.signing,S,l))),payload:w};return o&&(E.protected=c),r&&(E.header=r),[E,d]}async function Qn(e,t,s,n,o){let[r]=await Ni([e,t,void 0,s],n,o);return`${r.protected}.${r.payload}.${r.signature}`}var $i=it,Y=class extends $i{#e;setProtectedHeader(t){return Ln(this.#e,"setProtectedHeader"),this.#e=t,this}async sign(t,s){return Qn(Zn(this),this.#e,s?.crit,t,()=>{throw new we("JWTs MUST NOT use unencoded payload")})}};var ts='"alg" (Algorithm)';function ss(e='JWK "alg" (Algorithm) Parameter'){throw new R(`Invalid or unsupported ${e} value`)}function eo(e,t){return(typeof e=="string"?Jt[e]??Vn[e]:void 0)??ss(t)}var ke=(e,t)=>{if(e.byteLength!==t.length)return!1;for(let s=0;s<e.byteLength;s++)if(e[s]!==t[s])return!1;return!0},Di=e=>({data:e,pos:0}),ns=e=>{let t=e.data[e.pos++];if(t===void 0)throw new Error("Unexpected end of ASN.1 input");return t},Se=e=>{let t=ns(e);if(t&128){let s=t&127,n=0;for(let o=0;o<s;o++)n=n<<8|ns(e);return n}return t};var Ie=(e,t,s)=>{if(ns(e)!==t)throw new Error(s)},to=(e,t)=>{if(t<0||e.pos+t>e.data.length)throw new Error("Unexpected end of ASN.1 input");let s=e.data.subarray(e.pos,e.pos+t);return e.pos+=t,s},Li=e=>{Ie(e,6,"Expected algorithm OID");let t=Se(e);return to(e,t)};function Mi(e,t){if(Ie(e,48,`Invalid ${t==="spki"?"SPKI":"PKCS#8"} structure`),Se(e),t==="pkcs8"){Ie(e,2,"Expected version field");let s=Se(e);e.pos+=s}Ie(e,48,"Expected algorithm identifier"),Se(e)}var Gi=e=>{let t=Li(e);if(ke(t,[43,101,110]))return"X25519";if(!ke(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");Ie(e,6,"Expected curve OID");let s=Se(e),n=to(e,s);if(ke(n,[42,134,72,206,61,3,1,7]))return"P-256";if(ke(n,[43,129,4,0,34]))return"P-384";if(ke(n,[43,129,4,0,35]))return"P-521";throw new Error("Unsupported named curve")},Ui=async(e,t,s,n)=>{let o=Bn(n?.extractable),r=eo(s,ts);r.secret&&ss(ts);let a=e==="spki",c;if(r.resolve)try{let p=Di(t);Mi(p,e),c=r.resolve({crv:Gi(p)})}catch{throw new R("Invalid or unsupported key format")}else c=r.subtle;return crypto.subtle.importKey(e,t,c,o??a,r.usages[a?0:1])},ji=(e,t)=>tt(e.replace(t,"")),so=(e,t,s)=>{let n=ji(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return Ui("pkcs8",n,t,s)};async function os(e,t,s){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return so(e,t,s)}var Te="RS256",dt="everyapp-identity",zi="everyapp-identity-dev";var Ki="x-everyapp-identity",Hi="x-everyapp-public",lh="x-everyapp-system";var no=120,rs=60;var oo="public",Wi="system";function Bi(e,t){return{typ:"user",email:e.email,org_id:e.orgId,org_role:e.orgRole,chan:t.channel??"web",act:t.actor??{sub:e.sub},scopes:t.scopes??["*"],jti:t.jti,...t.toolCall?{tc:{id:t.toolCall.id,name:t.toolCall.name}}:{}}}function Yi(e){return{typ:"public",pub:!0,jti:e}}var ct=null;async function as(e){let t=e.replace(/\\n/g,`
|
|
3
|
+
`);if(ct&&ct.pem===t)return ct.key;let s=await os(t,Te);return ct={pem:t,key:s},s}async function hh(e,t){let s=await as(e),n=Math.floor((t.now??Date.now())/1e3),o=t.ttlSeconds??no,r=crypto.randomUUID();return new Y(Bi(t.subject,{channel:t.channel,actor:t.actor,scopes:t.scopes,toolCall:t.toolCall,jti:r})).setProtectedHeader({alg:Te,kid:t.keyId??dt}).setIssuer(t.issuer).setSubject(t.subject.sub).setAudience(t.audience).setIssuedAt(n).setExpirationTime(n+o).sign(s)}async function mh(e,t){let s=await as(e),n=Math.floor((t.now??Date.now())/1e3),o=t.ttlSeconds??no;return new Y(Yi(crypto.randomUUID())).setProtectedHeader({alg:Te,kid:t.keyId??dt}).setIssuer(t.issuer).setSubject(oo).setAudience(t.audience).setIssuedAt(n).setExpirationTime(n+o).sign(s)}async function fh(e,t){let s=t.ttlSeconds??rs;if(s<=0||s>rs)throw new RangeError(`system tokens live at most ${rs}s (got ${s})`);let n=await as(e),o=Math.floor((t.now??Date.now())/1e3),r={typ:"system",purpose:t.purpose,jti:crypto.randomUUID()};return new Y(r).setProtectedHeader({alg:Te,kid:t.keyId??dt}).setIssuer(t.issuer).setSubject(Wi).setAudience(t.audience).setIssuedAt(o).setExpirationTime(o+s).sign(n)}function Vi(e){let{basePath:t,normalize:s}=e;return{origin:e.origin,...e.chat?{chat:e.chat}:{},...e.embeddings?{embeddings:e.embeddings}:{},keyEnv:e.auth.secret,auth:e.auth,docs:e.docs,...e.setup===void 0?{}:{setup:e.setup},...e.alsoNeeds===void 0?{}:{alsoNeeds:e.alsoNeeds},...t===void 0?{}:{basePath:n=>qi(t,n)??""},...s==="workers-ai"?{normalizeResponse:Zi}:{}}}var ro=Object.fromEntries($.flatMap(e=>{let t=x[e];return t.mode==="ai"&&!("kind"in t&&t.kind==="proxy")?[[e,Vi(t)]]:[]}));function wh(e){return Object.hasOwn(ro,e)?ro[e]:void 0}function Eh(e){return[e.keyEnv,...e.alsoNeeds??[]]}function qi(e,t){let s=!1,n=e.replace(/\{([A-Z][A-Z0-9_]*)\}/g,(o,r)=>{let a=t[r];return typeof a!="string"||!a.trim()?(s=!0,""):encodeURIComponent(a.trim())});return s?null:n}var Fi=new Set(["/v1/chat/completions"]),Ji=["content","reasoning_content","reasoning"],Xi=/"(?:content|reasoning_content|reasoning)"\s*:\s*-?\d/;function Zi(e,t){if(!t.body||!Fi.has(e))return t;let s=(t.headers.get("content-type")??"").toLowerCase(),n=s.startsWith("text/event-stream")?ec():s.startsWith("application/json")?tc():null;if(!n)return t;let o=new Headers(t.headers);return o.delete("content-length"),new Response(t.body.pipeThrough(n),{status:t.status,statusText:t.statusText,headers:o})}function Qi(e){if(!is(e)||!Array.isArray(e.choices))return!1;let t=!1;for(let s of e.choices)if(is(s)){for(let n of[s.delta,s.message])if(is(n))for(let o of Ji){let r=n[o];typeof r=="number"&&(n[o]=String(r),t=!0)}}return t}function ao(e){if(!Xi.test(e))return null;let t;try{t=JSON.parse(e)}catch{return null}return Qi(t)?JSON.stringify(t):null}function ec(){let e=new TextDecoder,t=new TextEncoder,s="",n=o=>{let r=/^(data:[ ]?)(.*?)(\r?)$/s.exec(o);if(!r)return o;let a=ao(r[2]);return a===null?o:`${r[1]}${a}${r[3]}`};return new TransformStream({transform(o,r){s+=e.decode(o,{stream:!0});let a=s.lastIndexOf(`
|
|
4
|
+
`);if(a===-1)return;let c=s.slice(0,a+1);s=s.slice(a+1),r.enqueue(t.encode(c.split(`
|
|
5
|
+
`).map(n).join(`
|
|
6
|
+
`)))},flush(o){s+=e.decode(),s&&o.enqueue(t.encode(n(s)))}})}function tc(){let e=[];return new TransformStream({transform(t){e.push(t)},flush(t){let s=new TextDecoder,n=e.map(r=>s.decode(r,{stream:!0})).join("")+s.decode(),o=ao(n);if(o!==null){t.enqueue(new TextEncoder().encode(o));return}for(let r of e)t.enqueue(r)}})}function is(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var kh=64*1024;var io={"github-oauth":{id:"github-oauth",name:"GitHub",description:"Repositories, issues, pull requests and the person's profile.",docs:"https://github.com/settings/developers",api:"https://docs.github.com/rest",hosts:["api.github.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",revokeUrl:"https://api.github.com/applications/{client_id}/grant",revokeMethod:"DELETE",clientId:"GITHUB_OAUTH_CLIENT_ID",clientSecret:"GITHUB_OAUTH_CLIENT_SECRET",inject:"form",pkce:!0,scopeDialect:"comma",tokenHeaders:{Accept:"application/json"},identity:{url:"https://api.github.com/user",label:"login",id:"id"}},scopeSets:{identity:{label:"GitHub account (who you are)",access:"read",scopes:["read:user","user:email"]},"repo.read":{label:"Repositories (read, private ones included)",access:"read",scopes:["repo"]},"repo.write":{label:"Repositories (read and write)",access:"write",scopes:["repo"]},"org.read":{label:"Organizations and teams (read)",access:"read",scopes:["read:org"]}},access:["read","write"],hint:"Register an OAuth App (not a GitHub App) and paste its client id and secret. GitHub's `repo` scope is read and write; a read set with it still lets the Gateway refuse writes."},"notion-oauth":{id:"notion-oauth",name:"Notion",description:"Pages and databases the person shares with the integration.",docs:"https://www.notion.so/my-integrations",api:"https://developers.notion.com/reference",hosts:["api.notion.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://api.notion.com/v1/oauth/authorize",tokenUrl:"https://api.notion.com/v1/oauth/token",clientId:"NOTION_OAUTH_CLIENT_ID",clientSecret:"NOTION_OAUTH_CLIENT_SECRET",inject:"basic",pkce:!1,scopeDialect:"space",authorizeParams:{owner:"user"}},scopeSets:{"workspace.read":{label:"Shared pages and databases (read)",access:"read",scopes:[],routes:[{host:"api.notion.com",paths:["/v1/users","/v1/users/","/v1/pages/","/v1/databases/","/v1/blocks/","/v1/comments"],posts:["^/v1/search$","^/v1/databases/[^/]+/query$"]}]},"workspace.write":{label:"Shared pages and databases (read and write)",access:"write",scopes:[]}},access:["read","write"],hint:"Notion has no scopes: the person picks the pages to share on Notion's consent screen. Make the integration public to get a client id and secret. Apps send `Notion-Version` on every call."},"linear-oauth":{id:"linear-oauth",name:"Linear",description:"Issues, projects and teams, over Linear's GraphQL API.",docs:"https://linear.app/settings/api/applications",api:"https://developers.linear.app/docs/oauth/authentication",hosts:["api.linear.app"],auth:{kind:"oauth2-user",authorizeUrl:"https://linear.app/oauth/authorize",tokenUrl:"https://api.linear.app/oauth/token",revokeUrl:"https://api.linear.app/oauth/revoke",clientId:"LINEAR_OAUTH_CLIENT_ID",clientSecret:"LINEAR_OAUTH_CLIENT_SECRET",inject:"form",pkce:!1,scopeDialect:"comma"},scopeSets:{"workspace.write":{label:"Issues, projects and teams (read and write)",access:"write",scopes:["read","write"]}},access:["write"],readMethods:[],writeMethods:["POST"],hint:`Linear's API is GraphQL over POST, so every call needs access: "write"; a token's scopes decide what a query may change.`},"gitlab-oauth":{id:"gitlab-oauth",name:"GitLab",description:"Projects, merge requests and issues on gitlab.com.",docs:"https://gitlab.com/-/user_settings/applications",api:"https://docs.gitlab.com/api/rest/",hosts:["gitlab.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://gitlab.com/oauth/authorize",tokenUrl:"https://gitlab.com/oauth/token",revokeUrl:"https://gitlab.com/oauth/revoke",clientId:"GITLAB_OAUTH_CLIENT_ID",clientSecret:"GITLAB_OAUTH_CLIENT_SECRET",inject:"form",pkce:!0,scopeDialect:"space",identity:{url:"https://gitlab.com/api/v4/user",label:"username",id:"id"}},scopeSets:{identity:{label:"GitLab account (who you are)",access:"read",scopes:["read_user"]},"api.read":{label:"Projects, issues and merge requests (read)",access:"read",scopes:["read_api"]},"api.write":{label:"Projects, issues and merge requests (read and write)",access:"write",scopes:["api"]}},access:["read","write"],hint:"A self-managed GitLab needs a custom provider with its own host in place of gitlab.com."},atlassian:{id:"atlassian",name:"Atlassian (Jira and Confluence)",description:"Jira issues and Confluence pages on the sites the person grants.",docs:"https://developer.atlassian.com/console/myapps/",api:"https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/",hosts:["api.atlassian.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://auth.atlassian.com/authorize",tokenUrl:"https://auth.atlassian.com/oauth/token",clientId:"ATLASSIAN_CLIENT_ID",clientSecret:"ATLASSIAN_CLIENT_SECRET",inject:"form",pkce:!1,scopeDialect:"space",authorizeParams:{audience:"api.atlassian.com",prompt:"consent"},identity:{url:"https://api.atlassian.com/me",label:"email",id:"account_id"}},scopeSets:{identity:{label:"Atlassian account (who you are)",access:"read",scopes:["read:me"]},"jira.read":{label:"Jira issues and projects (read)",access:"read",scopes:["read:jira-work","read:jira-user"]},"jira.write":{label:"Jira issues (read and write)",access:"write",scopes:["read:jira-work","write:jira-work"]},"confluence.read":{label:"Confluence pages (read)",access:"read",scopes:["read:confluence-content.all","read:confluence-space.summary"]}},alwaysRequested:["offline_access"],access:["read","write"],hint:"Calls go to api.atlassian.com/ex/jira/<cloud id>/\u2026 ; the cloud id comes from /oauth/token/accessible-resources."},"hubspot-oauth":{id:"hubspot-oauth",name:"HubSpot",description:"CRM contacts, companies and deals.",docs:"https://developers.hubspot.com/",api:"https://developers.hubspot.com/docs/reference/api",hosts:["api.hubapi.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://app.hubspot.com/oauth/authorize",tokenUrl:"https://api.hubapi.com/oauth/v1/token",clientId:"HUBSPOT_OAUTH_CLIENT_ID",clientSecret:"HUBSPOT_OAUTH_CLIENT_SECRET",inject:"form",pkce:!1,scopeDialect:"space"},scopeSets:{"contacts.read":{label:"Contacts (read)",access:"read",scopes:["crm.objects.contacts.read"]},"contacts.write":{label:"Contacts (read and write)",access:"write",scopes:["crm.objects.contacts.read","crm.objects.contacts.write"]},"companies.read":{label:"Companies (read)",access:"read",scopes:["crm.objects.companies.read"]},"deals.read":{label:"Deals (read)",access:"read",scopes:["crm.objects.deals.read"]}},access:["read","write"],hint:"The app's scopes in HubSpot's developer console must match the sets apps declare, or HubSpot refuses the authorize URL."},zoom:{id:"zoom",name:"Zoom",description:"The person's meetings and recordings.",docs:"https://marketplace.zoom.us/develop/create",api:"https://developers.zoom.us/docs/api/",hosts:["api.zoom.us"],auth:{kind:"oauth2-user",authorizeUrl:"https://zoom.us/oauth/authorize",tokenUrl:"https://zoom.us/oauth/token",revokeUrl:"https://zoom.us/oauth/revoke",clientId:"ZOOM_CLIENT_ID",clientSecret:"ZOOM_CLIENT_SECRET",inject:"basic",pkce:!0,scopeDialect:"space",identity:{url:"https://api.zoom.us/v2/users/me",label:"email",id:"id"}},scopeSets:{identity:{label:"Zoom account (who you are)",access:"read",scopes:["user:read:user"]},"meetings.read":{label:"Meetings (read)",access:"read",scopes:["meeting:read:meeting","meeting:read:list_meetings"]},"meetings.write":{label:"Meetings (read, create and change)",access:"write",scopes:["meeting:read:meeting","meeting:write:meeting","meeting:update:meeting"]},"recordings.read":{label:"Cloud recordings (read)",access:"read",scopes:["cloud_recording:read:list_user_recordings"]}},access:["read","write"],hint:"A General app with user-managed OAuth; Zoom's granular scope names are the ones listed here."},dropbox:{id:"dropbox",name:"Dropbox",description:"Files and folders in the person's Dropbox.",docs:"https://www.dropbox.com/developers/apps",api:"https://www.dropbox.com/developers/documentation/http/documentation",hosts:["api.dropboxapi.com","content.dropboxapi.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://www.dropbox.com/oauth2/authorize",tokenUrl:"https://api.dropboxapi.com/oauth2/token",revokeUrl:"https://api.dropboxapi.com/2/auth/token/revoke",clientId:"DROPBOX_OAUTH_CLIENT_ID",clientSecret:"DROPBOX_OAUTH_CLIENT_SECRET",inject:"form",pkce:!0,scopeDialect:"space",authorizeParams:{token_access_type:"offline"}},scopeSets:{identity:{label:"Dropbox account (who you are)",access:"read",scopes:["account_info.read"],routes:[{host:"api.dropboxapi.com",paths:[],posts:["^/2/users/get_current_account$","^/2/users/get_space_usage$"]}]},"files.read":{label:"Files and folders (read)",access:"read",scopes:["files.metadata.read","files.content.read"],routes:[{host:"api.dropboxapi.com",paths:[],posts:["^/2/files/list_folder$","^/2/files/list_folder/continue$","^/2/files/get_metadata$","^/2/files/search_v2$","^/2/files/search/continue_v2$","^/2/files/get_temporary_link$","^/2/files/list_revisions$"]},{host:"content.dropboxapi.com",paths:[],posts:["^/2/files/download$","^/2/files/get_thumbnail_v2$","^/2/files/export$"]}]},"files.write":{label:"Files and folders (read and write)",access:"write",scopes:["files.metadata.read","files.content.read","files.metadata.write","files.content.write"]}},access:["read","write"],hint:'Dropbox\'s API is POST throughout: a read set unlocks its listed read calls, anything else needs access: "write". `token_access_type=offline` is what yields a refresh token.'},spotify:{id:"spotify",name:"Spotify",description:"The person's library, playlists and listening.",docs:"https://developer.spotify.com/dashboard",api:"https://developer.spotify.com/documentation/web-api",hosts:["api.spotify.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://accounts.spotify.com/authorize",tokenUrl:"https://accounts.spotify.com/api/token",clientId:"SPOTIFY_CLIENT_ID",clientSecret:"SPOTIFY_CLIENT_SECRET",inject:"basic",pkce:!0,scopeDialect:"space",identity:{url:"https://api.spotify.com/v1/me",label:"display_name",id:"id"}},scopeSets:{identity:{label:"Spotify account (who you are)",access:"read",scopes:["user-read-email","user-read-private"]},"library.read":{label:"Saved tracks and albums (read)",access:"read",scopes:["user-library-read"]},"playlists.read":{label:"Playlists (read)",access:"read",scopes:["playlist-read-private","playlist-read-collaborative"]},"playlists.write":{label:"Playlists (read and change)",access:"write",scopes:["playlist-read-private","playlist-modify-private","playlist-modify-public"]}},access:["read","write"]},"x-oauth":{id:"x-oauth",name:"X (OAuth 2)",description:"Posts and the person's profile on X, over the v2 API.",docs:"https://developer.x.com/en/portal/dashboard",api:"https://docs.x.com/x-api",hosts:["api.x.com"],auth:{kind:"oauth2-user",authorizeUrl:"https://x.com/i/oauth2/authorize",tokenUrl:"https://api.x.com/2/oauth2/token",revokeUrl:"https://api.x.com/2/oauth2/revoke",clientId:"X_OAUTH_CLIENT_ID",clientSecret:"X_OAUTH_CLIENT_SECRET",inject:"basic",pkce:!0,scopeDialect:"space",identity:{url:"https://api.x.com/2/users/me",label:"data.username",id:"data.id"}},scopeSets:{identity:{label:"X account (who you are)",access:"read",scopes:["users.read","tweet.read"]},"posts.read":{label:"Posts and timelines (read)",access:"read",scopes:["tweet.read","users.read"]},"posts.write":{label:"Posts (read and publish)",access:"write",scopes:["tweet.read","users.read","tweet.write"]}},alwaysRequested:["offline.access"],access:["read","write"],hint:"OAuth 2 with PKCE on X's v2 API; X's OAuth 1.0a (the v1.1 media upload) stays an app secret."}};function vh(){return Object.keys(io)}function Ph(e){let t=io[e];if(!t)return null;let s=ye(t);if(!s.ok)throw new Error(`preset ${e} doesn't parse: ${JSON.stringify(s.problems)}`);return s.capability}function co(e){return e?.mode==="oauth_client"&&e.flow!==void 0}function sc(e){if(e.mode==="oauth_client")return JSON.stringify({kind:"oauth2-user",authorizeUrl:e.authorize.url,tokenUrl:e.flow?.tokenUrl??null,revokeUrl:e.flow?.revokeUrl??null,inject:e.token[0]?.inject??"form",clientId:e.secrets.clientId,clientSecret:e.secrets.clientSecret??null,hosts:[...e.api].sort()});let t=Object.fromEntries(Object.entries(e.auth).sort(([s],[n])=>s<n?-1:s>n?1:0).map(([s,n])=>[s,typeof n=="object"&&n!==null?Object.fromEntries(Object.entries(n).sort(([o],[r])=>o<r?-1:o>r?1:0)):n]));return JSON.stringify({auth:t,hostSetting:e.hostSetting??null,hosts:[...e.hosts].sort()})}var nc=new Set(["everyapp"]),oc=/^\d{1,3}(\.\d{1,3}){3}$/,rc=[".localhost",".local",".internal",".arpa"];function ac(e){return`${e.toUpperCase().replace(/-/g,"_")}_`}function ic(e){return oc.test(e)?`${e} is an IP address, not a host name`:e==="localhost"||rc.some(t=>e.endsWith(t))?`${e} is not a public host`:null}function cs(e){let t=e?.trim().toLowerCase().replace(/\.$/,"");if(!t)return null;if(!t.includes("/"))return t;try{return new URL(t).hostname.toLowerCase()}catch{return null}}function $h(e,t){let s=cs(t.gatewayHost);if(s&&e===s)return`${e} is this gateway's own host`;let n=cs(t.appBaseDomain);if(n&&(e===n||e.endsWith(`.${n}`)))return`${e} is under this gateway's app domain ${n}`;let o=cs(t.thirdPartyDomain);return o&&(e===o||e.endsWith(`.${o}`))?`${e} is under this gateway's third-party domain ${o}`:null}function cc(e,t,s){let n=ac(e);return t.startsWith(n)?ee(t)?`${t} is one of the Gateway's own keys`:qs(t)?`${t} is a local-development setting`:Ue(t)?`${t} is a name everyapp sets itself`:Ge(t)?`${t} is a sign-in provider's setting name (every <ID>_SIGNIN_<FIELD> name is the Gateway's, set with \`everyapp signin add\`)`:K(t)?`${t} is a Gateway setting another provider or the Gateway reads`:s(t)?`${t} is another registered provider's`:null:`${t} doesn't start with ${n}: a provider's settings carry its own id`}function dc(e,t,s){if(nc.has(e)||$.includes(e))return{id:e,code:"PROVIDER_BUILTIN",message:`${e} is a built-in provider; a registered one can't take its id`};for(let n of N(t)){let o=cc(e,n,r=>s.rowSettings.has(r));if(o)return{id:e,code:"PROVIDER_SECRET_TAKEN",message:o}}for(let n of pc(t)){let o=ic(n)??s.refuseHost?.(n);if(o)return{id:e,code:"PROVIDER_HOST_REFUSED",message:o}}return null}function pc(e){if(e.mode==="api_key")return[...e.hosts];let t=[...e.api],s=[e.authorize.url,e.flow?.tokenUrl,e.flow?.revokeUrl,e.flow?.identity?.url];for(let n of s)if(n)try{let o=new URL(n).hostname.toLowerCase();t.includes(o)||t.push(o)}catch{}return t}function uc(e,t){let s=e.spec;if(typeof s=="string")try{s=JSON.parse(s)}catch{return{ok:!1,refusal:{id:e.id,code:"PROVIDER_SPEC_INVALID",message:"the stored spec isn't JSON"}}}let n=ye(s);if(!n.ok)return{ok:!1,refusal:{id:e.id,code:"PROVIDER_SPEC_INVALID",message:Mt(n.problems)}};if(n.id!==e.id||!Lt.test(e.id))return{ok:!1,refusal:{id:e.id,code:"PROVIDER_SPEC_INVALID",message:`the row is ${e.id} but its spec says ${n.id}`}};let o=dc(n.id,n.capability,t);return o?{ok:!1,refusal:o}:{ok:!0,capability:n.capability}}function lc(e=[],t={}){let s=new Map($.map(d=>[d,x[d]])),n=new Map,o=[],r=new Set;for(let d of e){if(n.has(d.id)){o.push({id:d.id,code:"PROVIDER_SPEC_INVALID",message:"listed twice"});continue}let u=uc(d,{rowSettings:r,...t.refuseHost?{refuseHost:t.refuseHost}:{}});if(!u.ok){o.push(u.refusal);continue}n.set(d.id,{id:d.id,capability:u.capability,bound:d.boundTo===sc(u.capability),addedBy:d.addedBy??null,addedAt:d.addedAt??null});for(let m of N(u.capability))r.add(m)}let a=new Map([...s,...[...n.values()].map(d=>[d.id,d.capability])]),c,p;return{get:d=>a.get(d),ids:()=>[...a.keys()],entries:()=>[...a.entries()],sourceOf:d=>s.has(d)?"catalog":n.has(d)?"row":void 0,settingNames:()=>(c??=new Set([...a.values()].flatMap(d=>N(d))),c),bound:d=>s.has(d)||(n.get(d)?.bound??!1),unboundSettings:()=>(p??=new Set([...n.values()].filter(d=>!d.bound).flatMap(d=>N(d.capability))),p),rows:()=>[...n.values()],rejected:o}}var Dh=lc();import{z as i}from"zod";var po=/[\x00-\x1f\x7f]/,hc=/%2f|%5c/i;function ds(e){if(typeof e!="string"||e.length===0)return{canonical:"/",ambiguous:!0,reason:"empty path"};if(!e.startsWith("/"))return{canonical:"/",ambiguous:!0,reason:"non-absolute path"};if(po.test(e))return{canonical:"/",ambiguous:!0,reason:"control characters"};if(e.includes("\\"))return{canonical:"/",ambiguous:!0,reason:"backslash"};if(hc.test(e))return{canonical:"/",ambiguous:!0,reason:"encoded path separator"};let t;try{t=decodeURIComponent(e)}catch{return{canonical:"/",ambiguous:!0,reason:"invalid percent-encoding"}}if(t.includes("%"))return{canonical:"/",ambiguous:!0,reason:"double-encoded"};if(po.test(t)||t.includes("\\"))return{canonical:"/",ambiguous:!0,reason:"decoded to unsafe characters"};let s=[],n=!1;for(let r of t.split("/"))if(!(r===""||r===".")){if(r===".."){if(s.length===0)return{canonical:"/",ambiguous:!0,reason:"path traversal above root"};s.pop(),n=!0;continue}s.push(r)}let o="/"+s.join("/");return n&&/%2e/i.test(e)?{canonical:o,ambiguous:!0,reason:"encoded traversal"}:{canonical:o,ambiguous:!1}}function mc(e){return e===V||e.startsWith(V+"/")}function Om(e){return uo(ds(e).canonical)||uo(ho(e))}function uo(e){let t=e.toLowerCase();return t===fe||t.startsWith(`${fe}/`)}var fc=["oauth-protected-resource","oauth-authorization-server","openid-configuration"],gc=fc.flatMap(e=>[`/.well-known/${e}`,`/mcp/.well-known/${e}`]);function Cm(e){return lo(ds(e).canonical)||lo(ho(e))}function lo(e){let t=e.toLowerCase();return gc.some(s=>t===s||t.startsWith(`${s}/`))}function ho(e){let t=e;for(let n=0;n<3;n+=1){let o;try{o=decodeURIComponent(t)}catch{break}if(o===t)break;t=o}let s=[];for(let n of t.replace(/\\/g,"/").split("/"))if(!(n===""||n===".")){if(n===".."){s.pop();continue}s.push(n)}return"/"+s.join("/")}function yc(e){let t="^",s=0;for(;s<e.length;){let n=e[s];if(n==="*")e[s+1]==="*"?(t+=".*",s+=2):(t+="[^/]*",s+=1);else if(n===":"&&e[s-1]==="/"){let o=e.slice(s+1).match(/^[A-Za-z_][A-Za-z0-9_]*/)?.[0],r=o?e[s+1+o.length]:void 0;o&&(r===void 0||r==="/")?(t+="[^/]+",s+=1+o.length):(t+="\\:",s+=1)}else t+=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&"),s+=1}return t+="$",new RegExp(t)}function mo(e,t,s){if(!e||e.length===0)return{public:!1,reason:"no public routes declared"};let{canonical:n,ambiguous:o,reason:r}=ds(s);if(o)return{public:!1,reason:`ambiguous path: ${r}`};if(mc(n))return{public:!1,reason:"internal namespace is never public"};let a=t.toUpperCase();for(let c of e)if((c.methods??["GET"]).map(d=>d.toUpperCase()).includes(a)&&yc(c.path).test(n))return{public:!0,route:c,reason:`matched ${c.path}`};return{public:!1,reason:"no matching public route"}}var bo=i.object({path:i.string(),methods:i.array(i.string()).optional()}),pt=i.object({name:i.string(),className:i.string(),worker:i.string().optional()}),_o=i.object({name:i.string(),worker:i.string().optional(),caching:i.enum(["off","default"]).optional()}),Ao=i.object({worker:i.string().optional(),maxBatchSize:i.number().optional(),maxBatchTimeout:i.number().optional(),maxRetries:i.number().optional(),maxConcurrency:i.number().nullable().optional(),retryDelay:i.number().optional(),visibilityTimeoutMs:i.number().optional(),deadLetterQueue:i.string().optional()}),ko=i.object({name:i.string(),consumer:i.union([i.literal(!0),Ao]).optional()}),wc=["cosine","euclidean","dot-product"],Ec=["@cf/baai/bge-small-en-v1.5","@cf/baai/bge-base-en-v1.5","@cf/baai/bge-large-en-v1.5","openai/text-embedding-ada-002","cohere/embed-multilingual-v2.0"],ae={min:32,max:1536},So=i.object({name:i.string(),dimensions:i.number().optional(),metric:i.string().optional(),preset:i.string().optional()}),Io=i.object({name:i.string(),collectLogs:i.boolean().optional(),cacheTtl:i.number().int().min(0).optional()}),To=i.object({name:i.string(),allowedSenderAddresses:i.array(i.string()).optional(),destinationAddress:i.string().optional(),allowedDestinationAddresses:i.array(i.string()).optional()}),vo=i.object({name:i.string()}),ps=128,Po=i.object({name:i.string(),dataset:i.string().optional()}),xo=i.object({d1:i.array(i.string()).optional(),kv:i.array(i.string()).optional(),durableObjects:i.array(pt).optional(),workflows:i.array(pt).optional(),hyperdrive:i.array(_o).optional(),r2:i.array(i.string()).optional(),queues:i.array(ko).optional(),ai:i.array(i.string()).optional(),browser:i.array(i.string()).optional(),images:i.array(i.string()).optional(),vectorize:i.array(So).optional(),aiGateway:i.array(Io).optional(),sendEmail:i.array(To).optional(),secretsStore:i.array(vo).optional(),analyticsEngine:i.array(Po).optional()}).passthrough(),bc=i.string().regex(/^\d{4}-\d{2}-\d{2}$/,"must be YYYY-MM-DD"),_c=/^[a-z0-9][a-z0-9:_-]{0,63}$/,ms={when:({value:e})=>typeof e=="object"&&e!==null&&!Array.isArray(e)},Ro=i.record(i.string(),i.string().min(1).max(200)).superRefine((e,t)=>{for(let s of Object.keys(e))s==="*"||s.startsWith("provider:")?t.addIssue({code:i.ZodIssueCode.custom,path:[s],message:"reserved scope id"}):_c.test(s)||t.addIssue({code:i.ZodIssueCode.custom,path:[s],message:"invalid scope id"})},ms),Ac=Ro,kc=i.object({engine:i.enum(["drizzle","d1-sql","prisma"]),dialect:i.enum(["sqlite","postgresql"]).optional(),dir:i.string().optional(),config:i.string().min(1).optional(),binding:i.string().min(1).optional()}).strict().superRefine((e,t)=>{if(e.engine==="prisma"&&e.dialect!=="postgresql"&&t.addIssue({code:i.ZodIssueCode.custom,path:["engine"],message:'Prisma migrations run on Postgres (dialect "postgresql"); D1 takes the generated SQL through "d1-sql"'}),e.dialect==="postgresql"&&(e.engine==="d1-sql"&&t.addIssue({code:i.ZodIssueCode.custom,path:["engine"],message:'Postgres migrations run on the "drizzle" or "prisma" engine'}),e.binding!==void 0&&t.addIssue({code:i.ZodIssueCode.custom,path:["binding"],message:"binding names a D1 database; Postgres migrations have none"})),e.config!==void 0&&!Eo(e.config)&&t.addIssue({code:i.ZodIssueCode.custom,path:["config"],message:"config must be a relative path without .. segments"}),e.engine==="d1-sql"&&!e.dir?.trim()){t.addIssue({code:i.ZodIssueCode.custom,path:["dir"],message:'dir is required when migrations.engine is "d1-sql"'});return}e.dir&&!Eo(e.dir)&&t.addIssue({code:i.ZodIssueCode.custom,path:["dir"],message:"dir must be a relative path without .. segments"})}),Sc=i.union([i.literal(!1),i.string().min(1)]),Oo=/^[a-z][a-z0-9-]*$/,Co="provider must start with a lowercase letter and contain only lowercase letters, digits, and hyphens",ht=i.string().regex(Oo,Co);function No(e,t){return Oo.test(e)?!1:(t.addIssue({code:i.ZodIssueCode.custom,path:[e],message:Co}),!0)}var Ic=i.string().url().refine(e=>e.startsWith("https://"),"must be an https URL"),mt={why:i.string().min(1).max(200).optional(),docs:Ic.optional(),optional:i.boolean().optional(),anyOf:i.string().trim().min(1).max(40).optional()},Tc=i.object({id:ht}).passthrough(),vc=i.object({id:ht,...mt}).strict(),$o=(e,t)=>{let s=new Set;e.forEach((n,o)=>{let r=typeof n=="string"?n:n.id;s.has(r)&&t.addIssue({code:i.ZodIssueCode.custom,path:[o],message:"duplicate provider"}),s.add(r)})},Pc=i.array(i.union([ht,Tc])).superRefine($o),xc=i.array(i.union([ht,vc])).superRefine($o),fo=i.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"a secret's name is an identifier").max(64),ut=i.object({scopes:i.array(i.string()).optional().catch(void 0),access:i.enum(["read","write"]),...mt}),Rc=ut.passthrough();function Oc(e,t=D){let s=t.get(e);if(!s||s.mode==="ai")throw new Error(`capabilityEntrySchema: ${e} is not a capability`);let n=co(s)&&!s.access.includes("read")?["read",...s.access]:s.access,o=i.enum(["read","write"]).refine(d=>n.includes(d),`${s.label} offers ${n.join(" or ")} access`),r="scopePolicy"in s?s.scopePolicy:void 0;if(!r){let d=i.undefined({error:`${s.label} takes no scopes; list it as { access: ..., why }`}).optional();return ut.extend({access:o,scopes:d}).strict()}let a=Object.keys(r.sets),c=`${s.label} needs scopes: one or more of ${a.join(", ")}`,p=i.array(i.enum(a,{error:`unknown scope set (${s.label} offers: ${a.join(", ")})`}),{error:c}).min(1,c).refine(d=>new Set(d).size===d.length,"a scope set is listed twice");return ut.extend({access:o,scopes:p}).strict()}var Cc=i.record(i.string(),Rc).superRefine((e,t)=>{for(let s of Object.keys(e))No(s,t)},ms),Nc=ut.extend({scopes:i.array(i.string().regex(/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31})?$/,"a scope set is named identity, or <area>.<access> (repo.read)"),{error:"scopes lists the scope sets of a registered OAuth provider (the gateway's registry names them); an API-key provider takes none"}).min(1,"scopes lists at least one set, or is left out").refine(e=>new Set(e).size===e.length,"a scope set is listed twice").optional()}).strict();function Do(e,t){return i.record(i.string(),i.unknown()).superRefine((s,n)=>{for(let[o,r]of Object.entries(s)){if(No(o,n))continue;let a=e.get(o);if(a?.mode==="ai"){n.addIssue({code:i.ZodIssueCode.custom,path:[o],message:`${o} is an AI provider: list it under providers, not capabilities`});continue}if(!a){if(t==="refuse"){n.addIssue({code:i.ZodIssueCode.custom,path:[o],message:`unknown capability (the gateway offers: ${Gs(e).join(", ")})`});continue}let p=Nc.safeParse(r);if(p.success)continue;for(let d of p.error.issues)n.addIssue({...d,path:[o,...d.path]});continue}if(o==="email"&&r!==null&&typeof r=="object"&&"senders"in r){n.addIssue({code:i.ZodIssueCode.custom,path:[o,"senders"],message:`senders moved out of the manifest: set them with \`${Nt} --sender <pattern>\` in the app's directory after its first deploy`});continue}let c=Oc(o,e).safeParse(r);if(!c.success)for(let p of c.error.issues)n.addIssue({...p,path:[o,...p.path]})}},ms).transform(s=>s)}var $c=Do(D,"refuse"),Dc=`inbound is true (the Worker exports an email() handler) or left out; the addresses moved out of the manifest: set them with \`${Nt} --inbound <address>\` in the app's directory after its first deploy`,Lc=i.object({inbound:i.boolean().optional().catch(void 0)}).passthrough(),Mc=i.object({inbound:i.boolean({error:Dc}).optional()}).strict(),Gc="email.inbound: apps in a dispatch namespace don't receive mail",lt=i.object({cpuMs:i.number().int().min(1).max(3e5).optional()}).passthrough(),Lo=i.object({provider:i.enum(["d1","postgres"]),region:i.string().regex(/^[a-z0-9]+:[a-z0-9-]+$/,'region must be a cloud region such as "aws:us-east-1"').optional()}).passthrough(),Uc=i.string().regex(/^[a-z]([a-z0-9]|-(?!-))*[a-z0-9]$|^[a-z]$/,"helper Worker names are kebab-case (lowercase letters, digits, single hyphens)").max(20),Mo=i.object({name:Uc,binding:i.string().optional(),limits:lt.optional()}),jc=i.enum(["everyone","admins"]),Go=i.string().regex(/^\/v1(\/[a-z0-9_-]+)+$/,'must be an OpenAI API path such as "/v1/files"'),Uo=i.object({...mt}),zc=Uo.strict(),Kc=i.object({models:i.array(i.string().min(1).max(200)).optional(),routes:i.array(Go).optional(),chat:i.union([i.boolean(),Uo]).optional()}).passthrough(),Hc=i.object({models:i.array(i.string().min(1).max(200)).optional(),routes:i.array(Go).optional(),chat:i.union([i.boolean(),zc]).optional()}).strict(),Wc=`mcp is { by: "gateway" | "app", why: "..." }: "gateway" serves the app's defineTools() at <app-host>/mcp, "app" leaves the path to the app's own MCP server; left out, the Gateway's own /mcp is the one connector`,Bc=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,jo=i.object({by:i.enum(["gateway","app"]),why:i.string().min(1,"say why the app needs /mcp on its own host").max(200).regex(Bc,"why is plain text: no control characters")},{error:e=>e.code==="invalid_type"?Wc:void 0}).passthrough(),zo=i.object({id:i.string().min(1).regex(/^[a-z]([a-z0-9-]*[a-z0-9])?$/,"id must be kebab-case (lowercase, digits, hyphens)"),name:i.string().min(1).optional(),description:i.string().optional(),icon:i.string().regex(/^(\/[A-Za-z0-9_~-][A-Za-z0-9._~-]*)*\/[A-Za-z0-9_~-][A-Za-z0-9._~-]*\.svg$/,'icon must be the path of an SVG the app serves, such as "/everyapp-icon.svg"').optional(),main:i.string().optional(),compatibilityDate:bc.optional(),resources:xo.optional(),workers:i.array(Mo.passthrough()).optional(),database:Lo.optional(),limits:lt.optional(),public:i.array(bo).optional(),providers:Pc.optional(),capabilities:Cc.optional(),secrets:i.array(i.union([fo,i.object({name:fo}).passthrough()])).max(100).optional(),scopes:Ro.optional(),ai:Kc.optional(),email:Lc.optional(),access:jc.optional(),serverFnGuard:i.boolean().optional(),serverFnBase:i.string().regex(/^(\/[A-Za-z0-9_~-][A-Za-z0-9._~-]*)+\/?$/,'must be a path such as "/app/_serverFn"').optional(),build:i.string().min(1).optional(),dev:i.string().min(1).optional(),devPort:i.number().int().positive().optional(),install:Sc.optional(),migrations:kc.optional(),mcp:jo.optional()}).passthrough(),Yc=bo.strict(),v=i.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"binding names must be JavaScript identifiers"),Vc=v.refine(e=>!e.endsWith("_"),"a queue's binding can't end with _ (its queue's name would end with a hyphen, which Cloudflare refuses)"),qc=i.string().regex(/^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/,"an AI Gateway's binding is letters and digits joined by single underscores (it ends the gateway's id, which takes single hyphens only)"),Fc=i.string().regex(/^setup\/[a-z0-9][a-z0-9-]*\.md$/,'must be a guide in the everyapp skill, such as "setup/main-secret.md"'),Jc=i.object({name:v,...mt,setup:Fc.optional()}).strict();function Xc(e,t){if(!e)return null;for(let s of e.ids()){if(Tt(s))continue;let n=e.get(s);if(n&&N(n).includes(t))return{kind:"capability",id:s}}return null}function Ko(e){return i.array(i.union([v,Jc])).superRefine((t,s)=>{let n=new Set;t.forEach((o,r)=>{let a=typeof o=="string"?o:o.name,c=w=>s.addIssue({code:i.ZodIssueCode.custom,path:[r],message:w});if(n.has(a)&&c(`duplicate secret ${a}`),n.add(a),Ue(a)){c(`${a} is set by everyapp itself (${Fs})`);return}let p=a.toUpperCase();if(Ge(p)){c(`${a} is a sign-in provider's setting name (every <ID>_SIGNIN_<FIELD> name is the Gateway's, set with \`everyapp signin add\`); give the app's secret another name`);return}let d=K(p)?null:Xc(e,p);if(!K(p)&&!d)return;if(me(p)){c(`${a} is a remote MCP app's credential name (every name ending in _MCP_TOKEN is the Gateway's, set with \`everyapp secret set\`); give the app's secret another name`);return}let u=d??Js(p),m=u?`list \`${u.id}\` under ${u.kind==="provider"?"providers":"capabilities"} instead`:"give the app's secret another name";c(`${a} is a Gateway setting, which \`everyapp secret set ${p}\` sets on the Gateway for every app; ${m}`)})})}var Zc=Ko(),Qc=So.extend({name:v,dimensions:i.number().int("a Vectorize index's dimensions are a whole number").min(ae.min,`a Vectorize index has ${ae.min} to ${ae.max} dimensions`).max(ae.max,`a Vectorize index has ${ae.min} to ${ae.max} dimensions`).optional(),metric:i.enum(wc).optional(),preset:i.enum(Ec).optional()}).strict().superRefine((e,t)=>{let s=e.dimensions!==void 0||e.metric!==void 0;e.preset!==void 0&&s?t.addIssue({code:"custom",message:`${e.name}: a preset sets the index's dimensions and metric itself; give either preset, or dimensions and metric`}):e.preset===void 0&&(e.dimensions===void 0||e.metric===void 0)&&t.addIssue({code:"custom",message:`${e.name} needs dimensions and metric (e.g. 768 and "cosine"), or a preset (e.g. "@cf/baai/bge-base-en-v1.5")`})}),ed=/^[A-Za-z0-9.!#$%&'+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+$/,us=i.string().max(254,"an email address is at most 254 characters").regex(ed,"must be an email address such as noreply@example.com, not a pattern"),td=i.array(us).min(1,"list at least one address, or leave the list out"),go="list the addresses the binding may send as: without allowedSenderAddresses it could send as any address on the account's Email Sending domains, the Gateway's own sender included",sd=To.extend({name:v,allowedSenderAddresses:i.array(us,{error:e=>e.input===void 0?go:void 0}).min(1,go),destinationAddress:us.optional(),allowedDestinationAddresses:td.optional()}).strict().refine(e=>e.destinationAddress===void 0||e.allowedDestinationAddresses===void 0,{message:"destinationAddress and allowedDestinationAddresses can't both be set: one destination, or a list of them",path:["allowedDestinationAddresses"]}),nd=xo.extend({d1:i.array(v).optional(),kv:i.array(v).optional(),r2:i.array(v).optional(),ai:i.array(v).optional(),browser:i.array(v).optional(),images:i.array(v).optional(),analyticsEngine:i.array(Po.extend({name:v.max(63,`Analytics Engine binding names are at most 63 characters, so the dataset named after the Worker fits Cloudflare's ${ps}`),dataset:i.string().regex(new RegExp(`^[A-Za-z0-9_-]{1,${ps}}$`),`dataset names are letters, digits, dashes and underscores, at most ${ps} characters (Cloudflare's rule)`).optional()}).strict()).optional(),durableObjects:i.array(pt.strict()).optional(),workflows:i.array(pt.extend({name:v}).strict()).optional(),hyperdrive:i.array(_o.extend({name:v}).strict()).optional(),queues:i.array(ko.extend({name:Vc,consumer:i.union([i.literal(!0),Ao.extend({maxBatchSize:i.number().int().positive().optional(),maxBatchTimeout:i.number().nonnegative().optional(),maxRetries:i.number().int().nonnegative().optional(),maxConcurrency:i.number().int().positive().nullable().optional(),retryDelay:i.number().int().nonnegative().optional(),visibilityTimeoutMs:i.number().int().nonnegative().optional()}).strict()]).optional()}).strict()).optional(),vectorize:i.array(Qc).optional(),aiGateway:i.array(Io.extend({name:qc}).strict()).optional(),sendEmail:i.array(sd).optional(),secretsStore:i.array(vo.extend({name:v}).strict()).optional()}).strict();function Ho(e={}){let t=e.capabilities===void 0&&(e.unknownCapabilities??"refuse")==="refuse"?$c:Do(e.capabilities??D,e.unknownCapabilities??"refuse");return zo.extend({resources:nd.optional(),providers:xc.optional(),workers:i.array(Mo.extend({binding:v.optional(),limits:lt.strict().optional()}).strict()).optional(),public:i.array(Yc).optional(),scopes:Ac.optional(),ai:Hc.optional(),capabilities:t.optional(),secrets:(e.capabilities?Ko(e.capabilities):Zc).optional(),email:Mc.optional(),database:Lo.strict().optional(),limits:lt.strict().optional(),mcp:jo.strict().optional()}).strict()}var Mm=Ho(),V="/__everyapp",od=["everyapp"];function rd(e){return od.includes(e)}var _=class extends Error{constructor(t){super(t),this.name="ManifestError"}};function Wo(e){return e.map(t=>`${t.path.map(String).join(".")||"(root)"}: ${t.message}`).join("; ")}function Gm(e){let t=zo.safeParse(e);if(!t.success)throw new _(`Invalid manifest: ${Wo(t.error.issues)}`);let s=t.data;for(let n of s.public??[])Yo(n.path);return s}function Um(e,t={}){let s=Ho(t).safeParse(e);if(!s.success)throw new _(`Invalid everyapp.config: ${Wo(s.error.issues)}`);let n=s.data,o=ud(n),r=hn(n).find(a=>o.has(a));if(r)throw new _(`Invalid everyapp.config: secrets: ${r} is one of the app's bindings; pick another name for the secret`);if(rd(n.id))throw new _(`Invalid everyapp.config: id "${n.id}" is reserved for the platform.`);for(let a of n.public??[]){Yo(a.path);let c=a.path==="/mcp"||a.path.startsWith("/mcp/");if(c||(a.methods??["GET"]).some(d=>mo([a],d,"/mcp").public))throw new _(`Invalid everyapp.config: public: ${a.path} can't be public${c?"":" (it covers /mcp)"}; an app that runs its own MCP server sets mcp: { by: "app", why: "..." }`)}return cd(n),dd(n),pd(n),ad(n),id(n),n}function ad(e){let t=ls({appId:e.id,orgKey:"k".repeat(gd)});for(let{name:s}of e.resources?.aiGateway??[]){let n=wo(t,s);if(n.length>hs)throw new _(`Invalid everyapp.config: resources.aiGateway: ${s} would make an AI Gateway id of up to ${n.length} characters (${wo(ls({appId:e.id,orgKey:"<orgKey>"}),s)}), longer than Cloudflare's ${hs}; shorten the binding name.`)}}function id(e){let t=[...Ke(e).map(n=>({path:`providers: ${n.id}`,need:n})),...Object.entries(e.capabilities??{}).map(([n,o])=>({path:`capabilities.${n}`,need:o})),...He(e).map(n=>({path:`secrets: ${n.name}`,need:n}))],s=new Map;for(let{path:n,need:o}of t){let r=o.anyOf?.trim();if(o.optional===!0&&r)throw new _(`Invalid everyapp.config: ${n} is both optional and in the any-of group "${r}"; a group's member is optional by itself, so drop one of them.`);r&&s.set(r,[...s.get(r)??[],n])}for(let[n,o]of s)if(o.length<2)throw new _(`Invalid everyapp.config: the any-of group "${n}" has one member (${o[0]}); an any-of group needs two or more. Drop anyOf, or mark it optional.`)}function cd(e){let t=new Set;for(let{name:n}of e.workers??[]){if(t.has(n))throw new _(`Invalid everyapp.config: workers lists "${n}" twice.`);t.add(n)}let s=e.resources;for(let n of[...s?.durableObjects??[],...s?.workflows??[]])if(n.worker!==void 0&&!t.has(n.worker))throw new _(`Invalid everyapp.config: ${n.name} is defined by Worker "${n.worker}", which workers doesn't declare.`);for(let n of s?.hyperdrive??[])if(n.worker!==void 0&&!t.has(n.worker))throw new _(`Invalid everyapp.config: Hyperdrive ${n.name} is bound by Worker "${n.worker}", which workers doesn't declare.`)}function dd(e){let t=e.resources?.queues??[],s=new Set((e.workers??[]).map(({name:o})=>o)),n=new Set(t.map(({name:o})=>o));for(let o of t){if(o.consumer===void 0||o.consumer===!0)continue;let{worker:r,deadLetterQueue:a}=o.consumer;if(r!==void 0&&!s.has(r))throw new _(`Invalid everyapp.config: Queue ${o.name} is consumed by Worker "${r}", which workers doesn't declare.`);if(a!==void 0){if(a===o.name)throw new _(`Invalid everyapp.config: Queue ${o.name} can't be its own dead-letter queue; name another of resources.queues.`);if(!n.has(a))throw new _(`Invalid everyapp.config: Queue ${o.name}'s deadLetterQueue "${a}" isn't one of resources.queues; declare it there and name its binding.`)}}}function pd(e){if(e.migrations?.dialect==="postgresql"&&e.database?.provider!=="postgres")throw new _('Invalid everyapp.config: Postgres migrations (migrations.dialect "postgresql") need database: { provider: "postgres" }.');let t=new Set;for(let s of[...e.resources?.d1??[],...e.resources?.kv??[],...e.resources?.r2??[],...(e.resources?.hyperdrive??[]).map(n=>n.name),...(e.resources?.queues??[]).map(n=>n.name),...e.resources?.ai??[],...e.resources?.browser??[],...e.resources?.images??[],...(e.resources?.vectorize??[]).map(n=>n.name),...(e.resources?.aiGateway??[]).map(n=>n.name),...(e.resources?.sendEmail??[]).map(n=>n.name),...(e.resources?.secretsStore??[]).map(n=>n.name),...(e.resources?.analyticsEngine??[]).map(n=>n.name)]){if(t.has(s))throw new _(`Invalid everyapp.config: the binding ${s} is declared twice in resources.`);t.add(s)}}function ud(e){return new Set([...e.resources?.d1??[],...e.resources?.kv??[],...e.resources?.r2??[],...(e.resources?.durableObjects??[]).map(t=>t.name),...(e.resources?.workflows??[]).map(t=>t.name),...(e.resources?.hyperdrive??[]).map(t=>t.name),...(e.resources?.queues??[]).map(t=>t.name),...e.resources?.ai??[],...e.resources?.browser??[],...e.resources?.images??[],...(e.resources?.vectorize??[]).map(t=>t.name),...(e.resources?.aiGateway??[]).map(t=>t.name),...(e.resources?.sendEmail??[]).map(t=>t.name),...(e.resources?.secretsStore??[]).map(t=>t.name),...(e.resources?.analyticsEngine??[]).map(t=>t.name),...(e.workers??[]).flatMap(t=>t.binding?[t.binding]:[]),...e.database?["DATABASE_PROVIDER"]:[],"ASSETS"])}function jm(e,t){if(t==="service_binding")return[];if(t!=="dispatch")return[`apps on tier "${t}" can't be deployed`];let s=[];return e.resources?.hyperdrive?.length&&s.push("resources.hyperdrive: Hyperdrive isn't available to apps in a dispatch namespace (an account holds at most 25 configs)"),e.resources?.r2?.length&&s.push("resources.r2: R2 buckets aren't available to apps in a dispatch namespace yet"),e.resources?.queues?.length&&s.push("resources.queues: Queues aren't available to apps in a dispatch namespace yet"),e.resources?.ai?.length&&s.push("resources.ai: the Workers AI binding isn't available to apps in a dispatch namespace (it bills the platform's account); list the workers-ai provider instead"),e.resources?.browser?.length&&s.push("resources.browser: Browser Rendering isn't available to apps in a dispatch namespace (it bills the platform's account)"),e.resources?.images?.length&&s.push("resources.images: the Images binding isn't available to apps in a dispatch namespace (it bills the platform's account)"),e.resources?.vectorize?.length&&s.push("resources.vectorize: Vectorize indexes aren't available to apps in a dispatch namespace yet"),e.resources?.aiGateway?.length&&s.push("resources.aiGateway: AI Gateways aren't available to apps in a dispatch namespace yet"),e.resources?.sendEmail?.length&&s.push("resources.sendEmail: Email sending bindings aren't available to apps in a dispatch namespace (they send through the Gateway's email capability)"),e.resources?.secretsStore?.length&&s.push("resources.secretsStore: Secrets Store secrets aren't available to apps in a dispatch namespace (the store is the platform account's)"),e.resources?.analyticsEngine?.length&&s.push("resources.analyticsEngine: Analytics Engine datasets aren't available to apps in a dispatch namespace (their names are account-wide and their writes bill the platform's account)"),e.email?.inbound===!0&&s.push(Gc),e.secrets?.length&&s.push("secrets: third-party apps can't have secrets of their own yet"),s}function zm(e){return e.startsWith("every-")?e:`every-${e}`}var yo="every-app-gateway",ld=63;function hd(e){let t=e.toLowerCase();return t===yo||t.startsWith(`${yo}-`)}var Bo="--";function ls({appId:e,orgKey:t}){if(!t)throw new Error("An org-scoped Worker name needs an org key.");return`every-${t}-${e}`}function Km(e){return hd(e.workerName)||e.workerName.length>ld||!e.orgKey||e.appId.includes(Bo)?!1:e.workerName===ls(e)}function Hm(e,t){return t==="DB"||t==="KV"?e:ie(e,t)}var Wm=63;function Bm(e,t){return t==="R2"?e:ie(e,t)}var md=63,fd=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;function Ym(e,t){return ie(e,t)}function Vm(e){return e.length<=md&&fd.test(e)}var qm=64;function Fm(e,t){return ie(e,t)}var hs=64,gd=12,yd=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function Jm(e){return e.length<=hs&&yd.test(e)}function wo(e,t){return`${e}-${t.toLowerCase().replaceAll("_","-")}`}function Xm(e,t){return ie(e,t)}function Zm(e,t){return ie(e,t)}function ie(e,t){let s=t.toLowerCase().replaceAll("_","-");return`${e}${Bo}${s}`}function Yo(e){if(!e.startsWith("/"))throw new _(`Public route path must be absolute (start with "/"): ${JSON.stringify(e)}`);if(e==="/*"||e==="/**"||e==="*"||e==="/")throw new _(`Public route "${e}" exposes the entire app. A catch-all public route is not allowed.`);if(e.includes("%"))throw new _(`Public route "${e}" must not contain percent-encoding; declare the decoded path.`);if(e.includes("\\"))throw new _(`Public route "${e}" must not contain backslashes.`);let t=e.split("/");if(t.some(n=>n==="."||n===".."))throw new _(`Public route "${e}" must not contain "." or ".." segments.`);for(let n of t)if(n.startsWith(":")&&!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new _(`Public route "${e}" has an invalid named segment "${n}".`);let s="/"+(t[1]??"");if(e===V||e.startsWith(V+"/")||s===V)throw new _(`Public route "${e}" targets the reserved ${V} namespace, which can never be public.`)}function Eo(e){return!e.trim()||e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)?!1:!e.split(/[\\/]+/).some(t=>t==="..")}var wd="APP__";function ef(e){return`${wd}${e}`}var tf=Object.freeze({manifest:"manifest",stamp:"stamp",worker:"worker",modulePrefix:"module:",assetPrefix:"asset:",migrationPrefix:"migration:"});var Ed={DNS_RECORD_CONFLICT:"--force-dns",DNS_UNREADABLE:"--force-dns",CAA_BLOCKS_ISSUANCE:"--force-dns",DURABLE_OBJECT_REMOVED:"--allow-delete-durable-object-data",WORKFLOW_REMOVED:"--allow-delete-workflows",EMAIL_ROUTING_DISABLED:"--enable-email-routing",CONFIRMATION_REQUIRED:"--yes"},ve=class extends Error{code;retryable;fix;rerun;rerunNote;authorize;data;constructor(t,s,n={}){super(s),this.name="EveryAppError",this.code=t,this.retryable=n.retryable??!1,this.fix=n.fix;let o=Ed[t];this.rerun=n.rerun??(o?M([o]):this.retryable?M():void 0),this.rerunNote=n.rerunNote,this.authorize=n.authorize??o!==void 0,this.data=n.data}},ft=class extends Error{action;url;rerun;rerunNote;data;constructor(t,s,n,o={}){super(s),this.name="ActionRequiredError",this.action=t,this.url=n,this.rerun=o.rerun===void 0?M():o.rerun,this.rerunNote=o.rerunNote,this.data=o.data}},Vo=class extends ve{constructor(t="Cancelled. Nothing changed."){super("CANCELLED",t),this.name="CancelledError"}},fs=new WeakMap;function cf(e,t){return t&&typeof e=="object"&&e!==null&&(fs.has(e)||fs.set(e,t)),e}function qo(e){return typeof e=="object"&&e!==null?fs.get(e):void 0}function df(e){return e instanceof Error?e.message:String(e)}var ce=class extends Error{kind;apiCodes;exitCode;stderr;stdout;constructor(t,s){super(t.message),this.name="CfError",this.kind=t.kind,this.apiCodes=t.apiCodes,this.exitCode=s.exitCode,this.stderr=s.stderr,this.stdout=s.stdout??""}};function Pe(e,t){return e instanceof ce&&e.kind===t}function lf(e){return Pe(e,"r2_not_enabled")||Pe(e,"access_not_enabled")}var gt=class extends Error{constructor(t,s,n){super(`\`${t}\` did not finish within ${Math.round(s/1e3)}s`+(n?` (last output: ${n})`:"")),this.name="CfTimeoutError"}},yt=class extends Error{constructor(t,s){super(`Unexpected output from \`${t}\`: ${s}`),this.name="CfOutputError"}},bd=/Aborting the upload operation because of conflicts/,_d=[["d1_id_rejected",e=>/Expected a D1 database ID/.test(e)],["subdomain_missing",e=>/workers\.dev subdomain|\/workers\/onboarding/.test(e)],["email_unverified",(e,t)=>t.includes(10034)],["r2_not_enabled",(e,t)=>t.includes(10042)],["access_not_enabled",e=>/access\.api\.error\.not_enabled/.test(e)],["queue_consumer_worker",(e,t)=>t.includes(10064)],["queue_in_use",(e,t)=>t.includes(11005)],["free_plan",e=>/Workers Paid|paid plan/i.test(e)],["auth",(e,t)=>t.includes(1e4)||t.includes(9109)||/No authentication token found|Not logged in|cf auth login/.test(e)],["already_exists",(e,t)=>t.includes(7502)||t.includes(10014)||t.includes(11009)||/\bvectorize\.index\.duplicate_name\b/.test(e)||/\balready exists\b/i.test(e)],["not_found",(e,t)=>t.includes(10007)||t.includes(10009)||t.includes(7404)||t.includes(10200)||t.includes(11e3)||/\bvectorize\.index\.(not_found|deleted)\b/.test(e)||/\bnot found\b|does not exist/i.test(e)]];function hf(e,t){return/^Aborted\.$/m.test(t)?new ce({message:`\`${e}\` asked for a confirmation no one could give, and did nothing (it printed "Aborted.").`,apiCodes:[],kind:"aborted"},{exitCode:0,stderr:t}):null}function mf(e,t=""){let s=Ad(e)??Sd(t,e),n=[...s.matchAll(/\[(?:code: )?(\d{4,})\]/g)].map(r=>Number(r[1])),o=bd.test(`${t}
|
|
7
|
+
${e}`)?"strict_conflict":_d.find(([,r])=>r(s,n))?.[0]??"unknown";return{message:s,apiCodes:n,kind:o}}function Ad(e){let t=e.split(/\r?\n/),s=t.findIndex(r=>/^┌\s*(API)?Error/.test(r.trim()));if(s<0)return;let n=[];for(let r of t.slice(s+1)){let a=r.trim();if(a.startsWith("\u2514"))break;n.push(a.replace(/^│ ?/,""))}let o=kd(n);return o.length>0?o:void 0}function kd(e){let t=[],s="";for(let n of e)n.trim().length===0?(s&&t.push(s),t.push(""),s=""):/^\s/.test(n)||/^\d+\./.test(n.trim())?(s&&t.push(s),s=n.trimEnd()):s=s?`${s} ${n.trim()}`:n.trim();return s&&t.push(s),t.join(`
|
|
8
|
+
`).replace(/\n{3,}/g,`
|
|
9
|
+
|
|
10
|
+
`).trim()}function Sd(...e){return Os(...e).join(`
|
|
11
|
+
`)||"cf failed without an error message"}var gs=new Set;function Fo(e){return gs.add(e),()=>gs.delete(e)}function Jo(){for(let e of gs)e()}function Xo(){return!!process.stdout.isTTY&&process.env.TERM!=="dumb"&&!process.env.CI}function gf(e,t=process.env,s=!!process.stdout.isTTY){return!e&&!t.NO_COLOR&&s&&t.TERM!=="dumb"}import{AsyncLocalStorage as xd}from"node:async_hooks";import Id from"chalk";import{spawn as Td}from"node:child_process";import{once as Zo}from"node:events";var Qo=process.platform!=="win32",vd=1e3;function _f({command:e,args:t,cwd:s,env:n,shell:o=!1,hold:r}){let a=Td(e,t,{cwd:s,shell:o,env:r&&Id.level>0?{...n,FORCE_COLOR:"1"}:n,stdio:["ignore",r?"pipe":"inherit",r?"pipe":"inherit"],detached:Qo}),c=r?[]:null,p=r?Promise.race([Promise.all([Zo(a.stdout,"end"),Zo(a.stderr,"end")]),new Promise(u=>setTimeout(u,1e3).unref())]):Promise.resolve();if(r)for(let[u,m]of[[a.stdout,process.stdout],[a.stderr,process.stderr]])u.on("data",w=>{c?c.push({to:m,chunk:w}):m.write(w)});return{exited:new Promise((u,m)=>{a.once("error",m),a.once("exit",(w,y)=>{p.then(()=>u({code:w,signal:y}))})}),stop:u=>Pd(a,Qo,u),releaseOutput:u=>{let m=c??[];if(c=null,u)for(let{to:w,chunk:y}of m)w.write(y)}}}function Pd(e,t,s="SIGTERM"){e.pid!==void 0&&(wt(e,t,s),s!=="SIGKILL"&&setTimeout(()=>wt(e,t,"SIGKILL"),vd).unref())}function wt(e,t,s){let n=e.pid;if(n!==void 0)try{t?process.kill(-n,s):e.kill(s)}catch{}}var Rd=3e3,Od=1e4,Cd=["SIGINT","SIGTERM"],de=new Set,_t=new Set,q=new Set,er=new WeakSet,or=new xd,tr=!1,xe=!1,Et;function vf(e,t){let s={child:e,group:t,exited:new Promise(n=>{e.exitCode!==null||e.signalCode!==null?n():e.once("close",()=>n())})};return xe&&!or.getStore()&&bt(s,"SIGKILL"),de.add(s),At(),()=>{de.delete(s),At()}}function Pf(){return xe}function xf(e){return Et=e,()=>{Et===e&&(Et=void 0)}}function Rf(e){return q.add(e),At(),()=>{q.delete(e),At()}}function Es(e){return _t.add(e),()=>_t.delete(e)}function Nd(){let e=[...new Set([...q].flatMap(n=>n.label?[n.label]:[]))],t=[...de.size>0&&!e.some(n=>n.startsWith("stopping "))?["stopping cf"]:[],...e];if(t.length===0)return"Stopping";let s=t.length===1?t[0]:`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`;return Me(s)}function $d(e){for(let t of[...e].reverse()){let s=t.closing?.();if(s!==void 0)return s}return"Stopped."}function sr(e,t){_t.size===0&&process.stderr.write(t);for(let s of _t)e(s)}function At(){let e=de.size>0||q.size>0;if(!(e===tr||xe)){tr=e;for(let t of Cd)e?process.on(t,nr):process.off(t,nr)}}function nr(e){Dd(e)}async function Dd(e,{exit:t=s=>process.exit(s)}={}){let s=e==="SIGTERM"?143:130;if(xe){if(e==="SIGTERM")return;for(let p of de)bt(p,"SIGKILL");ys(),t(s);return}xe=!0,Jo();let n=Et,o=n===void 0?Nd():n?`Stopping ${n}`:"";o&&sr(p=>p.stopping(o),`
|
|
12
|
+
${o} (Ctrl+C again to quit at once)...
|
|
13
|
+
`);let r=[...q],a=[...de];for(let p of a)bt(p,e);let c=Promise.all(a.map(p=>p.exited));if(!await ws(c,Rd)){for(let p of a)bt(p,"SIGKILL");await ws(c,1e3)}if(ys(),await ws(Ld(),Od),ys(),n===void 0){let p=$d(r);sr(d=>d.stopped(p),p?`${p}
|
|
14
|
+
`:"")}t(s)}async function Ld(){for(let e of[...q].reverse())e.async&&await or.run(!0,()=>e.async()).catch(()=>{})}function ys(){for(let e of[...q])if(!er.has(e)){er.add(e);try{e.sync?.()}catch{}}}function bt({child:e,group:t},s){wt(e,t,s)}async function ws(e,t){let s,n=new Promise(o=>{s=setTimeout(()=>o(!1),t)});try{return await Promise.race([e.then(()=>!0),n])}finally{clearTimeout(s)}}import Re from"node:fs/promises";import rr from"node:path";async function Md(e,t,s={}){let n=s.exclude||[];await Re.mkdir(t,{recursive:!0});let o=await Re.readdir(e,{withFileTypes:!0});for(let r of o){let a=rr.join(e,r.name),c=rr.join(t,r.name);n.some(p=>r.name===p)||(r.isDirectory()?await Md(a,c,s):await Re.copyFile(a,c))}}async function $f(e){try{return(await Re.stat(e)).isDirectory()}catch{return!1}}async function Df(e){try{return await Re.access(e),!0}catch{return!1}}function Lf(e){return e?.code==="ENOENT"}function ar(e){let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:t<3600?`${Math.round(t/60)}m`:`${Math.round(t/3600)}h`}function kt(e){let t=e/1e3;if(t<10)return`${t.toFixed(1)}s`;if(t<60)return`${Math.round(t)}s`;let s=Math.round(t);return`${Math.floor(s/60)}m ${s%60}s`}function Gf(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`}import Gd from"node:fs";var ir="EVERYAPP_EVENT_LOG",bs;function _s(){let e=process.env[ir];return e?(bs?.path!==e&&(bs={path:e,log:Ud(e)}),bs.log):null}function Ud(e){let t=!1;return{append(s){if(!t)try{let n=`${JSON.stringify({...s,pid:process.pid})}
|
|
15
|
+
`;Gd.appendFileSync(e,n,{mode:384})}catch(n){t=!0;let o=n instanceof Error?n.message:String(n);process.stderr.write(`everyapp: can't write ${ir}=${e} (${o}); not logging
|
|
16
|
+
`)}}}}function zf({argv:e,json:t}){_s()?.append({type:"invocation",ts:new Date().toISOString(),argv:[...e],cwd:process.cwd(),json:t,isatty:{stdin:!!process.stdin.isTTY,stdout:!!process.stdout.isTTY,stderr:!!process.stderr.isTTY},ci:!!process.env.CI})}function cr(e,t){_s()?.append({v:1,ts:t.toISOString(),...e})}function Kf(e,t){_s()?.append({type:"exit",ts:new Date().toISOString(),code:(e%256+256)%256,ms:t})}import{stripVTControlCharacters as jd}from"node:util";import dr from"chalk";var As=e=>jd(e).length,zd=(e,t)=>e+" ".repeat(t-As(e));function pr(e){let t=Math.max(...e.map(s=>s.label.length));return e.map(s=>`${dr.dim(s.label.padEnd(t))} ${s.value}`)}function Yf(e,t){let s=e.map((o,r)=>Math.max(As(o),...t.map(a=>As(a[r]??"")))),n=o=>o.map((r,a)=>a===o.length-1?r:zd(r,s[a])).join(" ");return[dr.dim(n(e)),...t.map(n)]}import g from"chalk";import hr from"cli-cursor";function qf(e){return(e?.public??[]).map(t=>lr(t.path,t.methods))}function Ff(e){if(typeof e!="string")return[];try{let s=JSON.parse(e)?.public;return Array.isArray(s)?s.flatMap(n=>{let o=n?.path;if(typeof o!="string")return[];let r=n.methods;return[lr(o,Array.isArray(r)?r.filter(a=>typeof a=="string"):void 0)]}):[]}catch{return[]}}function Jf(e){return e?.mcp?{by:e.mcp.by,why:e.mcp.why}:null}function Xf(e){if(typeof e!="string")return null;try{let s=JSON.parse(e)?.mcp;if(!s||typeof s!="object")return null;let{by:n,why:o}=s;return n!=="gateway"&&n!=="app"||typeof o!="string"?null:{by:n,why:o}}catch{return null}}var Zf=e=>`MCP /mcp (${e.by})`;function ur(e,t=6){return{shown:e.slice(0,t).map(s=>`${s.methods.join("/")} ${s.path}`).join(", "),more:Math.max(0,e.length-t)}}function lr(e,t){return{path:e,methods:(t??["GET"]).map(s=>s.toUpperCase())}}function _r(e=s=>process.stdout.write(s),t=()=>new Date){let s=kr(n=>{let o=n.type==="done"?{...n,display:void 0}:n;e(`${JSON.stringify({v:1,ts:t().toISOString(),...o})}
|
|
17
|
+
`)},!1,()=>t().getTime());return Es({stopping:n=>s.emit({type:"progress",step:"interrupt",message:n}),stopped:()=>{}}),s}function Ar(e={}){let t=e.verbose??!1,s=e.terminal??!1,n=e.now??Date.now,o=n(),r=e.writeProblem??(l=>void process.stderr.write(l)),a=new Is(e.write??(l=>void process.stdout.write(l)),s,e.columns??(()=>process.stdout.columns??80),n);s&&Fo(()=>a.handOver()),Es({stopping:l=>a.interrupt(`${l} (Ctrl+C again to quit at once)`),stopped:l=>{a.finish(),l&&r(`${g.dim(l)}
|
|
18
|
+
`)}});let c=l=>a.aside(()=>r(`${l.join(`
|
|
19
|
+
`)}
|
|
20
|
+
`)),p=new Map,d=new Set,u=[],m=0,w=0,y=(l,S)=>{for(let E of l)if("line"in E)a.lines(E.line);else if("fact"in E)u.splice(E.lead?w++:u.length,0,E.fact);else if("done"in E){let A=E.detail??(S!==void 0&&S>=1e3?kt(S):"");a.lines([Hd(E.done,A),...(E.notes??[]).map(k=>g.dim(` ${k}`))].join(`
|
|
21
|
+
`))}};return kr(l=>{switch(l.type){case"step":{for(let k of d)k!==l.step&&(a.drop(k),d.delete(k),p.delete(k));let S=Bd[l.step]?.(l,k=>p.has(k)),E=S?[S].flat():[];if(l.status==="start"){p.set(l.step,n());let k=E.find(L=>"spin"in L);E.length===0&&t&&!s&&l.message&&a.lines(g.dim(l.message)),y(E),a.spin(l.step,k?k.spin:E.length>0?"":l.message??"");return}let A=p.get(l.step);p.delete(l.step),d.delete(l.step),a.stopSpinning(l.step),E.length>0?y(E,A===void 0?void 0:n()-A):t&&l.message&&a.lines(g.dim(l.message));return}case"progress":Fd.has(l.step)?a.lines(g.dim(l.message)):qd[l.step]?.(l.data??{})?(p.has(l.step)||p.set(l.step,n()),s?a.spin(l.step,l.message):d.has(l.step)||a.lines(l.message),d.add(l.step)):t&&a.lines(g.dim(l.message));return;case"warning":{if(Yd.has(l.code)&&!t)return;m+=1,c([...wr(g.yellow("!"),l.message),...Ss(l.data,{url:!0})]);return}case"action_required":{let[S="",...E]=l.message.split(`
|
|
22
|
+
`),A=[`${g.cyan("\u2192")} ${S}`,...l.data?.url?[` ${g.cyan(l.data.url)}`]:[],...l.data?.code?[` Code: ${g.bold(l.data.code)}`]:[],...E.map(k=>g.dim(` ${k}`))];if(l.data?.waiting){let k=l.step??l.action;a.lines(A.join(`
|
|
23
|
+
`)),p.set(k,n());let L=f(l.data.waitingFor);a.spin(k,L?`Waiting for ${L}`:"Waiting");return}a.finish(),r(`${[...A,...Xd(l.data?.choices),...Ss(l.data)].join(`
|
|
24
|
+
`)}
|
|
25
|
+
`);return}case"error":{if(a.finish(),l.code==="CANCELLED"){r(`${g.dim(l.message)}
|
|
26
|
+
`);return}let S=t?f(l.data?.stack):void 0;r(`${[...wr(g.red("\u2717"),l.message),...Ss(l.data,{url:!0}),...S?S.split(`
|
|
27
|
+
`).filter(E=>/^\s+at /.test(E)).map(E=>g.dim(` ${E.trim()}`)):[],...t?[g.dim(` Error code: ${l.code}`)]:[]].join(`
|
|
28
|
+
`)}
|
|
29
|
+
`);return}case"done":{a.finish();let S=n()-o,E=[...u,...Zd(l.data?.facts)],A=np(l.data?.next),k=[...l.display!==void 0?l.display?[l.display]:[]:l.message?[g.green(l.message)]:[],...E.length>0?["",...pr(E)]:[],...S>=1e4&&l.display===void 0?[g.dim(`Done in ${kt(S)}${m>0?` with ${z(m,"warning")}`:""}`)]:[],...A.length>0?["","Next:",...op(A)]:[]];k.length>0&&a.lines(k.join(`
|
|
30
|
+
`));return}}},t,n)}function mg(e,t){return{emit(s){if(s.type!=="done"){e.emit(s);return}e.emit({type:"step",step:t,status:"ok",...s.message?{message:s.message}:{},...s.data?{data:s.data}:{}})},get exitCode(){return e.exitCode},get verbose(){return e.verbose}}}function Hd(e,t){return`${e} ${g.green("\u2713")}${t?` ${g.dim(t)}`:""}`}function mr(e,t){return s=>s.status==="ok"?{done:e,detail:t}:null}function fr(e,t){return s=>s.status==="start"?{spin:e}:s.status==="ok"?{done:t}:null}function pe(e){return e.status==="start"?{spin:e.message??""}:e.status==="ok"&&e.message?{done:e.message}:null}var Wd="EveryApp is in early development, so expect some rough edges: https://everyapp.com/docs/early-adopters",Bd={"setup.account":e=>{if(e.status!=="ok")return null;let t=e.data??{};if(t.gateway===!0)return null;let s=f(t.email);return{line:`Setting up EveryApp in ${f(t.name)??f(t.id)}${s?g.dim(` (${s})`):""}
|
|
31
|
+
${g.dim(Wd)}`}},"setup.gateway":e=>{let t=e.data??{},s=f(t.releaseName),n=f(t.account),o=n?`${n}'s Gateway`:"the Gateway";if(e.status==="start"){let r=f(t.gatewayUrl)?.replace(/^https:\/\//,"");switch(t.change){case"install":{let a=Qd(t.expectedMinutes);return{line:`Installing the Gateway at ${r} (${s})${a?g.dim(` (usually ${a.min}\u2013${a.max} minutes, then the owner link)`):""}`}}case"resume":return{line:`Resuming the Gateway install at ${r} (${s})`};case"upgrade":return{line:`Upgrading ${o} to ${s}`};case"repair":return{line:`Repairing ${o} (${s})`};case"redeploy":return{line:`Redeploying ${o} (${s})`};default:return null}}if(e.status==="ok"&&t.repaired===!0){let r=O(t.added);if(r.length>0)return{done:`Gateway now routes ${r.join(", ")}`};let a=Number(t.apps??0),c=Number(t.was??a);return{done:`Gateway routes ${z(a,"app")}`,detail:c!==a?`was ${c}`:""}}return e.status!=="skip"?null:t.upToDate===!0?{done:`${Me(o)} is up to date with ${s}`,detail:""}:e.message?{line:e.message}:null},"setup.owner":e=>{let t=f(e.data?.email);return t?e.status==="skip"?{done:`Owner account is ${t}`,detail:""}:e.status==="ok"?{done:`Owner account created for ${t}`}:null:null},"gateway.migrations":(e,t)=>{let s=t("setup.gateway"),n=t("gateway.upgrade");if(e.status==="start")return s?null:{spin:""};if(!s&&!n&&O(e.data?.applied).length===0)return null;let o=yr(e,s||n?"Database":"Gateway database");return n?ks(o):o},"gateway.deploy":(e,t)=>e.status==="start"?{spin:t("setup.gateway")?"Uploading...":t("app.bind")||t("app.delete")?"":"Updating the Gateway..."}:e.status!=="ok"?null:t("gateway.upgrade")?ks({done:"Uploaded"}):t("setup.gateway")?{done:"Uploaded"}:null,"gateway.reconcile":e=>e.status==="skip"&&e.message?{line:e.message}:null,"app.deploy":e=>{if(e.status!=="ok")return null;let t=e.data??{},s=f(t.version),n=f(t.organizationName),o=f(t.origin);return{line:[`Deploying ${f(t.appId)}${s?` ${s}`:""} to ${f(t.gatewayHost)}${n?g.dim(` (${n})`):""}`,...o?[g.dim(` From ${o}`)]:[]].join(`
|
|
32
|
+
`)}},"app.register":e=>{let t=e.data??{};if(e.status!=="ok")return null;let s=ep(t.publicRoutes),n=tp(t.mcp),o=[...s.length>0?[{fact:{label:"Public",value:sp(s)}}]:[],...n?[{fact:{label:"MCP",value:`Serves /mcp on its own host (${n.by}): ${n.why}`}}]:[]];if(t.firstDeploy!==!0)return o.length>0?o:null;let r=f(t.organizationName),a=g.dim(`\xB7 change it at ${f(t.gatewayUrl)}/admin/apps`),c=t.scope==="shared"?`Members of every organization ${g.dim("(shared app)")}`:t.defaultAccess===!0?`Everyone${r?` in ${r}`:""} ${a}`:t.deployerAccess===!1?`Private to owners and admins ${a}`:`Private to you, owners and admins ${a}`,p=t.hasOwner===!1?`
|
|
33
|
+
${g.dim(`The Gateway has no owner yet; its first owner gets the app (${St} setup).`)}`:"";return[{fact:{label:"Who can open",value:`${c}${p}`}},...o]},"app.hyperdrive":e=>e.status==="ok"?{done:"Connected to Postgres through Hyperdrive",notes:e.data?.caching==="off"?['Query caching is off; caching: "default" in everyapp.config.ts turns it on.']:[]}:null,"app.install":mr("Installed dependencies"),"app.build":e=>e.status==="start"?{spin:"Building..."}:e.status!=="ok"?null:{done:e.data?.release===!0?"Release checked":"Built"},"app.schema":e=>e.status==="start"?{spin:"Checking the schema..."}:e.status==="skip"&&e.message?{line:g.dim(e.message)}:e.status==="ok"?{done:"Schema matches the migrations"}:null,"app.migrations":e=>e.status==="start"?{spin:e.data?.dialect==="postgresql"?"Migrating the Postgres database...":"Migrating the database..."}:e.status==="ok"&&e.data?.applied===void 0?{done:"Database migrated"}:yr(e,"Database"),"app.helper":e=>{let t=f(e.data?.name);return e.status==="start"?{spin:`Uploading ${t}...`}:e.status==="ok"?{done:`Uploaded helper Worker ${t}`}:null},"app.upload":e=>e.status==="start"?{spin:"Uploading..."}:e.status==="ok"?{done:"Uploaded"}:null,"app.release":e=>{if(e.status!=="ok")return null;let t=e.data??{};return[{done:`Packed ${f(t.appId)} ${f(t.version)}`},{fact:{label:"Release",value:f(t.shown)??""}},{fact:{label:"SHA-256",value:f(t.sha256)??""}}]},"app.workflows":e=>e.status==="ok"?{done:`Deleted the Workflow ${f(e.data?.binding)}`}:null,"app.lease":gr,"gateway.lease":gr,"gateway.release":(e,t)=>{if(e.status!=="ok")return null;let s=e.data??{};if(s.downloaded===!0)return{done:`Downloaded Gateway ${f(s.release)}`};let n=f(s.origin?.path);return n?{done:`Loaded Gateway ${f(s.release)} from ${n}`,detail:""}:s.cached!==!1?null:t("gateway.upgrade")?ks({done:"Built"}):{done:"Built from this checkout"}},"app.email":e=>{let t=e.data??{};if(e.status==="start")return{spin:t.removing===!0?"Removing mail routes...":"Routing mail..."};if(e.status!=="ok")return null;let s=O(t.addresses),n=f(t.replyHint);return[...O(t.enabled).map(o=>({done:`Email Routing turned on for ${o}`})),s.length?{done:`Mail to ${s.join(", ")} routed`,...n?{notes:[n]}:{}}:{done:"Mail routes removed"}]},"app.access":e=>e.status==="ok"?{done:e.data?.removed===!0?`Cloudflare Access no longer lets ${f(e.data?.appId)}'s public routes through`:`Cloudflare Access lets ${f(e.data?.appId)}'s public routes through`}:null,"gateway.access":e=>e.status==="ok"?{done:"Cloudflare Access brought in step with this Gateway"}:null,"app.bind":e=>e.status==="start"?{spin:`Adding ${f(e.data?.appId)} to the Gateway...`}:e.status==="ok"?{done:"Added to the Gateway"}:null,"gateway.upgrade":e=>e.status==="start"?{line:g.bold(`Gateway ${f(e.data?.from)} \u2192 ${f(e.data?.to)}`)}:null,"app.live":e=>{let t=e.data??{},s=f(t.url)??`https://${f(t.hostname)}`;if(e.status==="skip")return Jd(t,s);if(e.status!=="ok")return null;let n={fact:{label:"Live",value:g.cyan(s)},lead:!0},o=f(t.waited);return o?[{done:o==="certificate"?"Certificate issued":"Live"},n]:n},"app.delete":e=>{let t=f(e.data?.appId);return e.status==="start"?{spin:`Removing ${t} from the Gateway...`}:e.status!=="ok"?null:e.data?.alreadyDeleted===!0?{line:`${t} was already removed from the Gateway`}:{done:`Removed ${t} from the Gateway`}},"app.certificate":e=>e.status==="ok"?{done:`Removed ${f(e.data?.hostname)}'s certificate`}:null,"app.purge":e=>{let t=f(e.data?.appId);if(e.status==="start")return{spin:`Deleting ${t}'s Worker and data...`};if(e.status!=="ok")return null;let s=O(e.data?.kinds);return s.length>0?{done:`Deleted ${t}'s ${It(s)}`}:{line:g.dim(`Nothing of ${t}'s was left to delete in Cloudflare`)}},"create.copy":e=>{let t=e.data??{};return e.status==="start"?[{line:`Creating ${f(t.appId)} in ${f(t.shown)}`},...t.elsewhere===!0?[{line:g.dim("New apps go in the checkout's apps/ folder, wherever you run create.")}]:[]]:e.status==="ok"?{done:"Copied the starter template"}:null},"secrets.gateway":(e,t)=>t("access.update")||t("access.off")?null:pe(e),"setup.access":e=>{if(e.status!=="ok")return null;let t=e.data??{},s=Array.isArray(t.signInMethods)?t.signInMethods.map(r=>r.type):[],n=[...s.includes("cloudflare")?["a Cloudflare account"]:[],...s.includes("onetimepin")?["a one-time PIN"]:[]],o=O(t.signIn?.pending);return{done:"Cloudflare Access on",detail:n.length>0?`sign-in with ${n.join(" or ")}`:void 0,notes:o.length>0?[`${It(o)} ${o.length===1?"signs":"sign"} in once with ${o.length===1?"their":"their own"} password; Access asks them to sign in first.`]:[]}},"secrets.app":pe,"secrets.provider":e=>e.status==="ok"&&e.message?{line:e.message}:null,"provider.add":e=>e.status==="start"?{spin:e.message??"Registering..."}:null,"provider.remove":e=>e.status==="start"?{spin:e.message??"Removing..."}:null,"provider.alias":e=>e.status==="ok"&&e.message?{line:g.dim(e.message)}:null,"events.deliver":pe,"create.skill":pe,"create.install":fr("Installing dependencies...","Installed dependencies"),"create.types":fr("Generating types...","Generated types"),"create.git":e=>e.status==="start"?{spin:"Starting a git repository..."}:e.status==="ok"?{done:"Started a git repository",detail:"first commit: Starter template"}:null,"create.done":e=>e.status==="ok"?{line:""}:null,"dev.types":mr("Worker types generated",".cloudflare/types"),"dev.migrations":e=>{if(e.status==="skip")return e.data?.reason==="flag"?{line:g.dim("Skipped local migrations (--skip-migrations)")}:null;if(e.status!=="ok")return null;let t=O(e.data?.applied);return{done:t.length?`${z(t.length,"local migration")} applied`:"Local database up to date"}},"dev.app":e=>e.status==="ok"?[{done:`${f(e.data?.appId)??"The app"} is running locally`},...e.message?[{line:e.message}]:[]]:null,"dev.stop":e=>{let t=f(e.data?.appId)??"the app";return e.data?.started===!0?{done:`${t} stopped`}:{line:g.dim(`Stopped before ${t} started.`)}},"migrations.local":e=>{if(e.status==="start")return{spin:"Setting up the local database..."};if(e.status==="skip"&&e.message)return{line:e.message};if(e.status!=="ok")return null;let t=O(e.data?.applied);return{done:"Set up the local database",...t.length?{detail:z(t.length,"migration")}:{}}},"cloudflare.login":e=>{let t=e.data??{},s=f(t.email),n=s?` as ${s}`:t.token===!0?" with CLOUDFLARE_API_TOKEN":"";return e.status==="skip"?{line:`Already logged in to Cloudflare${n}`}:e.status==="ok"?{done:`Logged in to Cloudflare${n}`}:null},"db.migrate":e=>{if(e.status==="start")return{spin:"Applying migrations to the local database..."};if(e.status==="skip"&&e.message)return{line:g.dim(e.message)};if(e.status!=="ok")return null;let t=O(e.data?.applied);return t.length?{done:`${z(t.length,"migration")} applied to the local database`,detail:"",notes:t}:{done:"Local database up to date",detail:""}},"db.query":e=>e.status==="start"?{spin:`Querying the ${f(e.data?.database)} database...`}:null,"teardown.check":pe,"teardown.inventory":e=>e.status==="start"?{spin:e.message??""}:null,"teardown.plan":e=>e.status==="ok"?{done:e.message??"",notes:O(e.data?.lines)}:null,"teardown.delete":pe,"db.restore":e=>{if(e.status==="start")return{spin:"Restoring..."};if(e.status!=="ok")return null;let t=e.data??{},s=f(t.appId);return{done:`Restored ${s?`${s}'s`:"the Gateway's"} database`,detail:`before ${O(t.migrations).join(", ")}`}}},Yd=new Set(["CUSTOM_DOMAIN_OWNER_UNCHECKED"]);function gr(e){return e.status==="ok"?{done:`Other ${f(e.data?.waitedFor)??"run"} finished`}:null}var Oe=()=>!0,Vd=e=>e.host===void 0,qd={"app.release":Oe,"app.lease":Oe,"gateway.lease":Oe,"db.lease":Oe,"app.live":Oe,"gateway.tls":Vd},Fd=new Set(["dev.mcp","dev.session"]);function yr(e,t){if(e.status!=="ok")return null;let s=e.data??{},n=O(s.applied);if(n.length===0)return{done:`${t} up to date`};if(s.fresh===!0)return{done:`${t} created`,detail:z(n.length,"migration")};let o=f(s.restoreCommand);return{done:`${t} migrated`,detail:n.join(", "),notes:o?[`Restore point saved. To undo: ${o}`]:[]}}function ks(e){return!e||!("done"in e)?e:{...e,done:` ${e.done}`,...e.notes?{notes:e.notes.map(t=>` ${t}`)}:{}}}function Jd(e,t){if(e.reason==="outside-base")return[{fact:{label:"Live",value:g.yellow("Not routed")},lead:!0}];let s=e.reason==="certificate"?"Goes live on its first visit, once its certificate comes (a few minutes)":e.reason==="first-visit"?"Goes live on its first visit":void 0;return[{fact:{label:"URL",value:g.cyan(t)},lead:!0},...s?[{fact:{label:"Status",value:s},lead:!0}]:[]]}function wr(e,t){let[s="",...n]=t.split(`
|
|
34
|
+
`);return[`${e} ${s}`,...n.map(o=>g.dim(` ${o}`))]}function Ss(e,{url:t=!1}={}){let s=f(e?.didYouMean),n=f(e?.usage),o=f(e?.fix),r=t?f(e?.url):void 0,a=f(e?.rerun)??f(e?.help),c=f(e?.rerunNote);return[...s?[` Did you mean ${g.bold(s)}?`]:[],...n?[g.dim(` Usage: ${n}`)]:[],...o?[` Fix: ${o}`]:[],...r?[` ${g.cyan(r)}`]:[],...a?[` ${e?.authorize===!0?"To go ahead anyway":"Run"}: ${g.bold(a)}${c?` ${g.dim(c)}`:""}`]:[]]}function Xd(e){if(!Array.isArray(e))return[];let t=e.map(n=>n),s=Math.max(...t.map(n=>n.rerun.length));return t.map(n=>` ${g.bold(n.rerun.padEnd(s))}${n.label?` ${g.dim(n.label)}`:""}`)}function Zd(e){return Array.isArray(e)?e.map(t=>({label:t.label,value:`${/^https?:\/\//.test(t.value)?g.cyan(t.value):t.value}${t.note?` ${g.dim(t.note)}`:""}`})):[]}function Qd(e){if(typeof e!="object"||e===null)return;let{min:t,max:s}=e;return typeof t=="number"&&typeof s=="number"?{min:t,max:s}:void 0}function ep(e){return Array.isArray(e)?e.map(t=>t):[]}function tp(e){if(!e||typeof e!="object")return null;let{by:t,why:s}=e;return(t==="gateway"||t==="app")&&typeof s=="string"?{by:t,why:s}:null}function sp(e){let{shown:t,more:s}=ur(e);return`Open to the internet without sign-in: ${t}${s>0?g.dim(` \u2026 and ${s} more (everyapp.config.ts public)`):""}`}function np(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{command:t}:t):[]}function op(e){let t=n=>n.command??n.url??"",s=Math.max(...e.map(n=>t(n).length));return e.map(n=>n.note?` ${t(n).padEnd(s)} ${g.dim(n.note)}`:` ${t(n)}`)}var Er=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],rp=80,br=3e4,Is=class{constructor(t,s,n,o){this.write=t;this.terminal=s;this.columns=n;this.now=o}steps=[];frame=0;timer;drawn=!1;lines(t){this.erase(),this.write(`${t}
|
|
35
|
+
`),this.draw()}spin(t,s){let n=this.steps.find(o=>o.step===t);if(n?n.label=s:this.steps.push({step:t,label:s,since:this.now()}),!this.terminal){this.keepAlive();return}this.timer||(hr.hide(process.stdout),this.timer=setInterval(()=>{this.frame=(this.frame+1)%Er.length,this.draw()},rp),this.timer.unref()),this.draw()}stopSpinning(t){let s=this.steps.findIndex(n=>n.step===t);s<0||(this.steps=this.steps.slice(0,s),this.settle())}drop(t){this.steps=this.steps.filter(s=>s.step!==t),this.settle()}aside(t){this.terminal&&this.erase(),t(),this.draw()}handOver(){this.steps=[],this.stopTimer(),this.erase()}finish(){this.handOver()}interrupt(t){this.handOver(),this.terminal?this.spin("interrupt",t):this.write(`${g.dim(t)}
|
|
36
|
+
`)}settle(){this.steps.length===0&&this.stopTimer(),this.draw()}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0,this.terminal&&hr.show(process.stdout))}keepAlive(){this.timer||(this.timer=setInterval(()=>{let t=this.steps.findLast(o=>o.label);if(!t)return;let s=this.now()-t.since;if(s<br)return;let n=t.label.replace(/\.{3}$|…$/,"");this.write(`${g.dim(`still ${n.charAt(0).toLowerCase()}${n.slice(1)} \xB7 ${ar(s)}`)}
|
|
37
|
+
`)},br),this.timer.unref())}erase(){this.drawn&&(this.write("\r\x1B[2K"),this.drawn=!1)}draw(){if(!this.terminal)return;let t=this.steps.findLast(r=>r.label)??this.steps.at(-1);if(!t){this.erase();return}let s=this.now()-t.since,n=`${t.label?`${t.label} `:""}${s>=5e3?`\xB7 ${kt(s)} `:""}${Er[this.frame]}`,o=Math.max(this.columns()-1,10);this.write(`\r\x1B[2K${g.dim(n.length>o?`\u2026${n.slice(n.length-o+1)}`:n)}`),this.drawn=!0}};function kr(e,t,s){let n=s(),o=new Set,r=!1,a=!1,c=!1;return{emit(p){let d=p;if(d.type==="warning"){let u=`${d.code}
|
|
38
|
+
${d.message}`;if(o.has(u))return;o.add(u)}else d.type==="done"&&(d={...d,data:{...d.data,durationMs:s()-n}});d.type==="error"?r=!0:d.type==="action_required"?d.data?.waiting?c=!0:a=!0:d.type==="done"&&(c=!1),e(d),cr(d.type==="done"?{...d,display:void 0}:d,new Date(s()))},get exitCode(){return r?1:a||c?2:0},verbose:t}}var Sr;function Ir(e){Sr=e,process.exitCode=e}function gg(){return Sr}var ap="https://dash.cloudflare.com/?to=/:account/workers/plans",ip="https://dash.cloudflare.com/profile",cp=new Set(["ECONNREFUSED","ECONNRESET","ENOTFOUND","EAI_AGAIN","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]);function vr(e,t,s){let n=qo(t),o=m=>n?`${m}
|
|
39
|
+
The database stays migrated. To roll it back: ${n.restoreCommand}`:m,r=n?{rollbackCommand:n.rollbackCommand}:{},a=s?{step:s}:{},c=(m,w,y)=>e.emit({type:"action_required",action:m,message:o(w),...a,data:{...y,...r}}),p=(m,w,y,l)=>e.emit({type:"error",code:m,message:o(w),retryable:y,...a,data:{...l,...r}});if(t instanceof ft){c(t.action,t.message,{...t.data,...t.url?{url:t.url}:{},...t.rerun?{rerun:t.rerun}:{},...t.rerunNote?{rerunNote:t.rerunNote}:{}});return}if(Pe(t,"free_plan")){c("upgrade_workers_paid",`Cloudflare refused, for the Free plan: ${t.message}
|
|
40
|
+
EveryApp needs Workers Paid ($5 a month, then usage). Subscribe, then run this command again.`,{url:ap,rerun:M()});return}if(t instanceof ve){p(t.code,t.message,t.retryable,{...t.data,...t.fix?{fix:t.fix}:{},...t.rerun?{rerun:t.rerun}:{},...t.rerunNote?{rerunNote:t.rerunNote}:{},...t.authorize?{authorize:!0}:{}});return}let d=dp(t);if(d){p(d.code,d.message,d.retryable,{...d.data,...d.retryable?{rerun:M()}:{}});return}let u=t instanceof Error?t:new Error(String(t));p("UNEXPECTED",`everyapp hit an unexpected error
|
|
41
|
+
${u.name}: ${u.message}
|
|
42
|
+
This is a bug in everyapp, not something you did.`,!1,{...u.stack?{stack:u.stack}:{},...e.verbose?{}:{rerun:M(["--verbose"]),rerunNote:"for a stack trace to report"}})}function dp(e){if(!(e instanceof Error))return null;if(Pe(e,"email_unverified"))return{code:"CF_EMAIL_UNVERIFIED",message:`Verify your Cloudflare account's email address first
|
|
43
|
+
Cloudflare refuses to create anything until the address on the account is verified. Open the message Cloudflare sent you, then run this command again.`,retryable:!0,data:{url:ip,cloudflare:e.message}};if(e instanceof ce)return{code:`CF_${e.kind.toUpperCase()}`,message:e.message,retryable:!1};if(e instanceof gt)return{code:"CF_TIMEOUT",message:e.message,retryable:!0};if(e instanceof yt)return{code:"CF_OUTPUT",message:e.message,retryable:!1};if(e instanceof _)return{code:"INVALID_MANIFEST",message:e.message,retryable:!1};let t=Tr(e)??Tr(e.cause);return t&&cp.has(t)?{code:"NETWORK_ERROR",message:`The network failed (${t})
|
|
44
|
+
${e.message}`,retryable:!0}:e instanceof TypeError&&e.message==="fetch failed"?{code:"NETWORK_ERROR",message:`The network failed
|
|
45
|
+
fetch failed`,retryable:!0}:t?{code:"SYSTEM_ERROR",message:e.message,retryable:!1}:null}function Tr(e){let t=e?.code;return typeof e=="object"&&typeof t=="string"&&/^[A-Z_]+$/.test(t)?t:void 0}function pp(e,t){return e?_r():Ar({verbose:t,terminal:Xo()})}async function up(e,t){try{await t()}catch(s){vr(e,s)}Ir(e.exitCode)}async function vg(e,t){let s=pp(e.json,e.verbose);await up(s,()=>t(s))}export{St as a,M as b,hp as c,z as d,Me as e,f,fp as g,Os as h,It as i,O as j,zi as k,Ki as l,Hi as m,lh as n,no as o,hh as p,mh as q,fh as r,Xp as s,Zp as t,oa as u,Qp as v,eu as w,Zs as x,Qs as y,tu as z,x as A,N as B,$ as C,Tt as D,D as E,Gs as F,Nr as G,xp as H,ro as I,wh as J,Eh as K,Dr as L,Cp as M,Np as N,jr as O,Ks as P,Ws as Q,Dp as R,Kr as S,xt as T,Lp as U,Ge as V,Mp as W,Gp as X,ee as Y,Vr as Z,me as _,K as $,Kp as aa,Hp as ba,qs as ca,Fs as da,Ue as ea,Yp as fa,je as ga,Vp as ha,Xs as ia,qp as ja,Fp as ka,en as la,tn as ma,ha as na,ma as oa,iu as pa,cu as qa,ya as ra,wa as sa,cn as ta,du as ua,dn as va,pu as wa,uu as xa,lu as ya,un as za,wu as Aa,He as Ba,hn as Ca,Eu as Da,bu as Ea,_u as Fa,ku as Ga,Su as Ha,Iu as Ia,Tu as Ja,vu as Ka,xu as La,Ua as Ma,ye as Na,Mt as Oa,Du as Pa,io as Qa,vh as Ra,Ph as Sa,co as Ta,Ut as Ua,xn as Va,Xe as Wa,Mu as Xa,Gu as Ya,Uu as Za,ju as _a,zu as $a,Ku as ab,Hu as bb,Wu as cb,Yu as db,Vu as eb,qu as fb,Fu as gb,Ju as hb,Xu as ib,el as jb,tl as kb,sl as lb,nl as mb,ol as nb,rl as ob,sc as pb,$h as qb,dc as rb,lc as sb,hi as tb,cl as ub,Om as vb,Cm as wb,mo as xb,zo as yb,rd as zb,_ as Ab,Gm as Bb,Um as Cb,jm as Db,zm as Eb,yo as Fb,ld as Gb,hd as Hb,Bo as Ib,ls as Jb,Km as Kb,Hm as Lb,Wm as Mb,Bm as Nb,md as Ob,Ym as Pb,Vm as Qb,qm as Rb,Fm as Sb,hs as Tb,gd as Ub,Jm as Vb,wo as Wb,Xm as Xb,Zm as Yb,wd as Zb,ef as _b,ve as $b,ft as ac,Vo as bc,cf as cc,df as dc,ce as ec,Pe as fc,lf as gc,gt as hc,yt as ic,hf as jc,mf as kc,Qo as lc,_f as mc,Pd as nc,Jo as oc,gf as pc,vf as qc,Pf as rc,xf as sc,Rf as tc,Md as uc,$f as vc,Df as wc,Lf as xc,ar as yc,kt as zc,Gf as Ac,qf as Bc,Ff as Cc,Jf as Dc,Xf as Ec,Zf as Fc,ur as Gc,zf as Hc,Kf as Ic,pr as Jc,Yf as Kc,mg as Lc,Hd as Mc,gg as Nc,vr as Oc,pp as Pc,up as Qc,vg as Rc};
|