everyapp 0.3.0-rc.2 → 0.3.0-rc.3
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/dist/access-FZ2ARRET.js +1 -0
- package/dist/activity-2RGC4KBA.js +14 -0
- package/dist/ai-ZGVUY7AM.js +5 -0
- package/dist/apps-IKTWTDHD.js +14 -0
- package/dist/{chunk-4JRIS6S6.js → chunk-36VCEEIH.js} +1 -1
- package/dist/{chunk-N5GQLGEC.js → chunk-3GZA6EEZ.js} +1 -1
- package/dist/{chunk-ONLNJXVQ.js → chunk-475IB5UG.js} +3 -3
- package/dist/chunk-4MMHVIHT.js +20 -0
- package/dist/{chunk-W3JCQHHU.js → chunk-52NQ23OH.js} +1 -1
- package/dist/chunk-6ILATTGU.js +34 -0
- package/dist/{chunk-CZXHKPRZ.js → chunk-7BC42ZUS.js} +1 -1
- package/dist/{chunk-CB4U7H2G.js → chunk-7SCPBFKI.js} +1 -1
- package/dist/{chunk-5PTNYZK6.js → chunk-AEYRJ3TD.js} +3 -3
- package/dist/{chunk-23HJ5I2A.js → chunk-AIDX5IYA.js} +1 -1
- package/dist/{chunk-OM2HDWVP.js → chunk-CGFABBZA.js} +1 -1
- package/dist/{chunk-PNLU5U3P.js → chunk-DB5CMXEV.js} +1 -1
- package/dist/{chunk-ELK7QZ2M.js → chunk-DONNKBKB.js} +1 -1
- package/dist/{chunk-AGTCKFRB.js → chunk-EEF4FY26.js} +1 -1
- package/dist/chunk-EJE6K5GO.js +146 -0
- package/dist/chunk-HHVABFYD.js +1 -0
- package/dist/chunk-HT76NR3O.js +1 -0
- package/dist/chunk-IWP4Q3KV.js +15 -0
- package/dist/{chunk-ZFCUH5PK.js → chunk-J2XKGQO7.js} +1 -1
- package/dist/{chunk-OP4DYXYI.js → chunk-JBTV62V7.js} +1 -1
- package/dist/chunk-JT3R24Y7.js +1 -0
- package/dist/{chunk-ZEXVHB22.js → chunk-KS7DIYIJ.js} +1 -1
- package/dist/{chunk-H7PDL3X5.js → chunk-KTX5YGBL.js} +1 -1
- package/dist/{chunk-J35DDCNU.js → chunk-LKI3XV7I.js} +1 -1
- package/dist/{chunk-T2GD7RHS.js → chunk-LTMQP62I.js} +1 -1
- package/dist/{chunk-WOVS3GV5.js → chunk-LTYAIGEB.js} +4 -4
- package/dist/{chunk-CCWBPAKH.js → chunk-MLZJBYSY.js} +1 -1
- package/dist/chunk-NXO2BC3M.js +57 -0
- package/dist/{chunk-RMF4YGD6.js → chunk-OHDR7JWQ.js} +39 -38
- package/dist/{chunk-6OGVO7QK.js → chunk-ONGI463M.js} +1 -1
- package/dist/chunk-Q44H7KLY.js +1 -0
- package/dist/{chunk-6PGUCTJ6.js → chunk-RXSJENSN.js} +1 -1
- package/dist/{chunk-CZTEDWZ2.js → chunk-SMCUCFS4.js} +1 -1
- package/dist/{chunk-2Y5Q6A5K.js → chunk-TQWCYF2T.js} +1 -1
- package/dist/chunk-U4ATZJEU.js +6 -0
- package/dist/{chunk-YHJZMJYZ.js → chunk-UEQMNXMZ.js} +1 -1
- package/dist/{chunk-LXYMDZER.js → chunk-VX4Z3D7A.js} +1 -1
- package/dist/{chunk-IFCPALVC.js → chunk-WTKBB5HE.js} +23 -23
- package/dist/{chunk-PS7S74DG.js → chunk-WV4G6E4T.js} +1 -1
- package/dist/{chunk-IUOBIB5M.js → chunk-WY2V27RK.js} +1 -1
- package/dist/{chunk-TLRM3P7V.js → chunk-XEPXX3AI.js} +1 -1
- package/dist/chunk-Y6CGMZEB.js +1 -0
- package/dist/{chunk-J455FAEN.js → chunk-YCADEJVJ.js} +5 -5
- package/dist/{chunk-HOUHG236.js → chunk-ZCJTJDAI.js} +1 -1
- package/dist/{chunk-H6QQMY7B.js → chunk-ZH6IAPVK.js} +1 -1
- package/dist/{configure-F7UZCJUG.js → configure-EJKUEVYS.js} +1 -1
- package/dist/{create-2E5HVWYK.js → create-BKEFXQ5N.js} +1 -1
- package/dist/{db-HEQVTDTM.js → db-66QZCKMG.js} +1 -1
- package/dist/delete-JR5R2OHE.js +3 -0
- package/dist/deploy-G4NB5R2P.js +1 -0
- package/dist/{dev-JL3ZP5BT.js → dev-EFDXNBFY.js} +43 -43
- package/dist/{email-RLZFUFUN.js → email-LAQDDSYC.js} +1 -1
- package/dist/{events-2V5VRBWP.js → events-RRF7OOCI.js} +1 -1
- package/dist/{groups-HDG5DVFY.js → groups-CFTGDYZU.js} +1 -1
- package/dist/index.js +89 -83
- package/dist/install-GXMHD5XS.js +1 -0
- package/dist/{login-KHJBC64Z.js → login-YWNHPSC2.js} +1 -1
- package/dist/mcp-72WLLKTK.js +1 -0
- package/dist/provider-IPV6BDP3.js +13 -0
- package/dist/release-4T7BVUZ5.js +1 -0
- package/dist/{restore-FFGYV7NO.js → restore-BWPOK4UP.js} +1 -1
- package/dist/secret-NLQQNZMK.js +1 -0
- package/dist/setup-6PNOX4NZ.js +1 -0
- package/dist/{signin-AP3D4XM4.js → signin-X4Z42R7E.js} +1 -1
- package/dist/status-VEUCYFRY.js +4 -0
- package/dist/teardown-J4CP2EI5.js +22 -0
- package/dist/update-NU2SFDNF.js +1 -0
- package/dist/{workspace-CJC5I66L.js → workspace-ZLKGLW35.js} +1 -1
- package/package.json +4 -4
- package/skills/build-every-app/SKILL.md +4 -1
- package/skills/build-every-app/patterns.md +6 -0
- package/skills/everyapp/SKILL.md +18 -8
- package/skills/everyapp/mcp.md +4 -2
- package/skills/everyapp/setup/README.md +2 -0
- package/skills/everyapp/setup/ai-gateway.md +117 -0
- package/skills/everyapp/setup/ai.md +139 -0
- package/skills/everyapp/setup/providers.md +26 -8
- package/dist/access-LGEN3ABJ.js +0 -1
- package/dist/activity-RSD4D66F.js +0 -12
- package/dist/apps-4RCFXT74.js +0 -13
- package/dist/chunk-EGEWRFVY.js +0 -1
- package/dist/chunk-FJJSSVET.js +0 -33
- package/dist/chunk-GKBPYVP3.js +0 -25
- package/dist/chunk-JYKRUS5C.js +0 -1
- package/dist/chunk-LYNBZ7RV.js +0 -57
- package/dist/chunk-M2QQ2UD7.js +0 -132
- package/dist/chunk-NFU4YFXB.js +0 -1
- package/dist/chunk-ZECBN24L.js +0 -15
- package/dist/delete-XCSIQIRS.js +0 -3
- package/dist/deploy-3QOZEZHC.js +0 -1
- package/dist/install-Z5FYXUYM.js +0 -1
- package/dist/mcp-EFDUKJ5V.js +0 -1
- package/dist/provider-EOI5PTFH.js +0 -13
- package/dist/release-74J5ZIL3.js +0 -1
- package/dist/secret-7FKKTLHB.js +0 -1
- package/dist/setup-PAKRCAFO.js +0 -1
- package/dist/status-RMWNHOEK.js +0 -4
- package/dist/teardown-E4JNKAZJ.js +0 -22
- package/dist/update-DWVZFNPS.js +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var ca=Object.defineProperty;var da=(e,t,s)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ne=(e,t,s)=>(da(e,typeof t!="symbol"?t+"":t,s),s);var vu="everyapp";var Iu="0.3.0";var en={"@cloudflare/config":"0.24.1","@inquirer/prompts":"^8.7.3","@stricli/core":"^1.3.0",cf:"1.0.0-beta.14",chalk:"^5.6.2","cli-cursor":"^5.0.0",execa:"^9.6.0",jiti:"^2.6.1",undici:"^7.30.1",zod:"^4.2.0"};function pa(e=process.env){let t=e.npm_config_user_agent?.split("/")[0];return t?ua[t]??"everyapp":"everyapp"}var ua={pnpm:"pnpm everyapp",npm:"npx everyapp",yarn:"yarn everyapp"},Mt=pa();function x(e=[],{terminal:t=!1,argv:s=process.argv.slice(2)}={}){let n=t?s.filter(r=>r!=="--json"):[...s];for(let r of e)n.includes(r)||n.push(r);return[Mt,...n.map(la)].join(" ")}function Tu(e,t=process.argv.slice(2)){let s=[];for(let n=0;n<t.length;n++){let r=t[n];r===e?n++:r.startsWith(`${e}=`)||s.push(r)}return x([],{argv:s})}function la(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var B=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Fe=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`,f=e=>typeof e=="string"&&e.length>0?e:void 0,xu=e=>f(e)??null;function re(...e){return e.join(`
|
|
2
|
+
`).split(/\r?\n/).map(t=>t.trimEnd()).filter(t=>t.trim().length>0).slice(-20)}function Gt(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var N=e=>Array.isArray(e)?e.map(String):[];var tn={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 sn={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 nn={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 rn={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, so no call needs an anthropic-workspace-id header."}],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 on={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 an={...tn,...sn,...nn,...rn,...on};var C={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"}}},...an};function oe(e){let t=[e.secret];return e.kind==="basic"&&e.as==="password"&&typeof e.user=="object"&&t.push(e.user.secret),t}function D(e){switch(e.mode){case"api_key":return[...oe(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 j=Object.keys(C);function Ut(e){return typeof e=="string"&&Object.hasOwn(C,e)}var G={get:e=>Ut(e)?C[e]:void 0,ids:()=>j};function cn(e){return e.ids().filter(t=>e.get(t)?.mode!=="ai")}function ha(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 r;try{r=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)?n:`https://${n}`)}catch{return null}let o=r.pathname==="/"&&!r.search&&!r.hash&&!r.username&&!r.password;return r.protocol==="https:"&&o?r.origin:null}function Hu(e){return e.token.map(({host:t,path:s,methods:n})=>`${n.join("/")} https://${t??`<${e.hostSetting}>`}${ma(s)}`).join(", ")}function ma(e){return typeof e=="string"?e:e.source.replace(/^\^|\$$/g,"").replace(/v\\d\+\\\.\\d\+/g,"v<version>").replace(/\\(.)/g,"$1")}var fa=["AI_GATEWAY_ID","CLOUDFLARE_ACCOUNT_ID"],dn=["openrouter","workers-ai","openai","anthropic","groq","mistral","gemini"];var ga=/^([a-z][a-z0-9-]{1,39})(?:\/(.{1,200}))?$/;function Fu(e){if(typeof e!="string")return null;let t=ga.exec(e.trim());if(!t)return null;let s=t[2]?.trim();return s?{provider:t[1],model:s}:{provider:t[1]}}function Yu(e){return e.model?`${e.provider}/${e.model}`:e.provider}function jt(e){return e?.mode==="ai"&&e.kind!=="proxy"&&e.chat!==void 0}function be(e){return[...e.authOptional?[]:[e.auth.secret],...e.alsoNeeds??[]]}function pn(e,t){return be(e).every(s=>t(s))}function ya(e){return fa.every(t=>e(t))}function un(e,t){return e.aig!==void 0&&ya(t)}function wa(e,t,s){return{id:e,label:t.label,settings:be(t),configured:pn(t,s),model:t.chat.model,viaAiGateway:un(t,s),embeddings:t.embeddings!==void 0}}function Ea(e,t=G){return[...dn,...t.ids().filter(n=>!dn.includes(n))].flatMap(n=>{let r=t.get(n);return jt(r)?[wa(n,r,e)]:[]})}function ba(e,t=G){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 ln(e){let t=e.lookup??G,{isSet:s}=e,n=Ea(s,t),r=(d,u,h,y,m)=>({provider:d,label:u.label,model:y??u.chat.model,source:h,configured:pn(u,s),settings:be(u),via:un(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)],...m?{problem:m}:{}}),o;if(e.choice){let d=t.get(e.choice.provider),u=ba(e.choice,t);if(!u&&jt(d))return r(e.choice.provider,d,"setting",e.choice.model);o=u??void 0}let a=n.find(d=>d.configured),i=a??n[0];if(!i)throw new Error("the catalog has no AI provider with a chat route");let c=t.get(i.id);if(!jt(c))throw new Error("unreachable");return r(i.id,c,a?"order":"none",void 0,o)}function hn(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 mn=["google","microsoft","github","apple","cloudflare","oidc"];function _a(e){return`/api/auth/callback/${e}`}function qu(e,t){return`${e.replace(/\/+$/,"")}${_a(t)}`}function _e(e,t){return`${e.toUpperCase()}_SIGNIN_${t}`}function ae(e,t){return[{name:_e(e,"CLIENT_ID"),role:"clientId",required:!0,plain:!0,what:t.clientId},{name:_e(e,"CLIENT_SECRET"),role:"clientSecret",required:!0,plain:!1,what:t.clientSecret}]}var zt=["openid","email","profile"],Aa={google:{id:"google",label:"Google",console:"https://console.cloud.google.com/apis/credentials",appNoun:"OAuth client ID (Web application)",settings:ae("google",{clientId:"The OAuth client's Client ID (ends in .apps.googleusercontent.com)",clientSecret:"The OAuth client's Client secret"}),scopes:zt,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:[...ae("microsoft",{clientId:"The app registration's Application (client) ID",clientSecret:"A client secret from Certificates & secrets (it expires; 24 months at most)"}),{name:_e("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:zt,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:ae("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:ae("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:ae("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:_e("oidc","ISSUER"),role:"issuer",required:!0,plain:!0,what:"The issuer URL (https://\u2026), which serves /.well-known/openid-configuration"},...ae("oidc",{clientId:"The client ID",clientSecret:"The client secret"}),{name:_e("oidc","LABEL"),role:"label",required:!1,plain:!0,what:'The button text after "Continue with" (default "SSO")'}],scopes:zt,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)."]}},Kt=mn.map(e=>Aa[e]);function Ju(e){return mn.includes(e)}var fn=Kt.flatMap(e=>e.settings.map(t=>t.name)),gn=Kt.flatMap(e=>e.settings.filter(t=>t.plain).map(t=>t.name)),ka=/^[A-Z][A-Z0-9_]*_SIGNIN_(CLIENT_ID|CLIENT_SECRET|ISSUER|LABEL|TENANT)$/;function Ye(e){return ka.test(e)}function Xu(e){for(let t of Kt)if(t.settings.some(s=>s.name===e))return t;return null}function Zu(e,t){let s=e.settings.filter(o=>t(o.name)).map(o=>o.name),n=e.settings.filter(o=>o.required&&!t(o.name)).map(o=>o.name),r=n.length===0?"on":s.length===0?"off":"incomplete";return{id:e.id,status:r,missing:r==="incomplete"?n:[],set:s}}var Sa=["GATEWAY_URL","APP_BASE_DOMAIN","BETTER_AUTH_SECRET","JWT_PRIVATE_KEY","JWT_PUBLIC_KEY","GATEWAY_DEPLOYMENT_MODE","CLOUDFLARE_ACCOUNT_ID","THIRD_PARTY_DEPLOYS"],yn=new Set(Sa);function ie(e){return yn.has(e)}var va=[...new Set(j.flatMap(e=>{let t=C[e];return t.mode==="service"?[]:D(t)}))].filter(e=>!yn.has(e)),Ia=["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"],Ta=[...va,...Ia,...fn],Pa=new Set(Ta),xa=/^[A-Z][A-Z0-9_]*_MCP_TOKEN$/;function Ae(e){return xa.test(e)}function F(e){return Pa.has(e)||Ae(e)}var Oa=["EMAIL_FROM","EMAIL_FROM_NAME","EMAIL_PROVIDER","EMAIL_PASSWORD_SIGN_IN","MASTODON_URL","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"],Ra=new Set([...Oa,...gn]);function sl(e){return Ra.has(e)}var Ca=["HOSTED_OPEN_SIGNUP","DISPATCH_NAMESPACE","THIRD_PARTY_DOMAIN"],Na=new Set(Ca);function nl(e){return Na.has(e)}var $a=["MCP_ACCESS_TOKEN_TTL","DATAFORSEO_SANDBOX"];function wn(e){return $a.includes(e)}var Da=new Set(["GATEWAY_URL","CF_VERSION_METADATA"]),La=["EVERYAPP_","EVERY_APP_","APP__"],En="GATEWAY_URL, CF_VERSION_METADATA and the EVERYAPP_*, EVERY_APP_* and APP__* names";function Ve(e){let t=e.toUpperCase();return Da.has(t)||La.some(s=>t.startsWith(s))}function bn(e){for(let t of j){let s=C[t];if(D(s).includes(e))return{kind:s.mode==="ai"?"provider":"capability",id:t}}return null}var al="provider",qe={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"}},il=Object.keys(qe).sort();function _n(e){return Object.hasOwn(qe,e)}function cl(e){return oe(C[qe[e].capability].auth)[0]}function dl(e){let t=qe[e];return{id:t.id,name:t.name,description:t.description,capabilities:{[t.capability]:{access:"read",why:t.why}}}}var ke="/__everyapp/tools",ul=`${ke}/list`,ll=`${ke}/call`,Ma=["read","write","destructive"],hl="mcp:read",ml="mcp:write";var An=/^[a-z][a-z0-9_]{0,47}$/;function kn(e){return typeof e=="string"&&Ma.includes(e)}function fl(e){return JSON.stringify(Ht(e))}function Ht(e){if(Array.isArray(e))return e.map(Ht);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]=Ht(n))}return t}var Sn=["none","bearer","header","basic","oauth"],vn=["annotations","read","write"],xn=/^[a-z]([a-z0-9-]*[a-z0-9])?$/,Wt=32,Ga=["everyapp"],Ua=64,ja=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$/,za=32,On=2048,Ka=255,Ha=1e3,In=500,Wa=256,Ba=new Set(["authorization","cookie","host","content-type","content-length","accept","connection","transfer-encoding","mcp-session-id","mcp-protocol-version","mcp-method","mcp-name"]);function Fa(e){return`${e.toUpperCase().replace(/-/g,"_")}_MCP_TOKEN`}function Ya(e){return typeof e!="string"||!xn.test(e)?"the id must be kebab-case: lowercase letters, digits and hyphens, starting with a letter":e.length>Wt?`the id must be at most ${Wt} characters`:Ga.includes(e)?`"${e}" is reserved`:_n(e)?`"${e}" is the Gateway's built-in MCP app; a remote server can't take its id`:null}function _l(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(i=>i.length>0);if(s.length<2)return null;let n=new Set(["co","com","net","org","gov","edu","ac"]),r=s.length-2;r>0&&n.has(s[r])&&s[r+1].length===2&&(r-=1);let a=(s[r]??"").replace(/[^a-z0-9-]/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-").slice(0,Wt).replace(/-+$/g,"");return!a||!xn.test(a)||Ya(a)?null:a}function Tn(e,t){return e===t||e.endsWith(`.${t}`)}function Va(){let e=new Set(["api.openai.com","openrouter.ai","gateway.ai.cloudflare.com","api.cloudflare.com"]);for(let t of Object.values(C))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 Al(e,t){if(typeof e!="string"||!e.trim())return"give the server's URL";if(e.length>On)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 r=s.hostname.toLowerCase().replace(/\.$/,""),o=r==="localhost"||r.endsWith(".localhost")||r==="127.0.0.1"||r==="[::1]"||r==="::1";if(s.protocol!=="https:"&&!(s.protocol==="http:"&&n&&o))return n?"the URL must be https://, or http:// on localhost while the Gateway runs locally":"the URL must be https://";if(!r)return"the URL has no host";if(!o&&(/^[\d.]+$/.test(r)||r.startsWith("[")))return"the URL must name a host, not an IP address";if(o&&!n)return"the URL must name a public host";let a="",i="";try{let c=new URL(t.gatewayUrl);a=c.hostname.toLowerCase().replace(/\.$/,""),i=c.origin.toLowerCase()}catch{a=""}if(a&&(n?s.origin.toLowerCase()===i:Tn(r,a)))return"the URL is this Gateway's own address";for(let c of[t.appBaseDomain,t.thirdPartyDomain]){let d=(c??"").trim().toLowerCase().replace(/\.$/,"");if(d&&Tn(r,d))return`the URL is on this Gateway's app domain (${d})`}return Va().includes(r)?`${r} is a provider this Gateway holds a key for; apps reach it through the Gateway's capabilities, not as an MCP app`:null}function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qa(e){return typeof e!="string"||!e?"give the credential's setting name":e.length>Ua?"the credential's name is too long":Ae(e)?null:`the credential's name must end in _MCP_TOKEN (letters, digits and underscores), like ${Fa("treg")}`}function Ja(e){if(!ce(e)||typeof e.kind!="string")return{ok:!1,problem:"auth must name a kind"};let t=e.kind;if(!Sn.includes(t))return{ok:!1,problem:`auth.kind must be one of ${Sn.join(", ")}`};if(t==="none"||t==="oauth")return{ok:!0,auth:{kind:t}};let s=qa(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 r=e.header;if(typeof r!="string"||!ja.test(r))return{ok:!1,problem:"auth.header must be an HTTP header name"};if(Ba.has(r.toLowerCase()))return{ok:!1,problem:`auth.header can't be ${r}; use kind "bearer" or "basic" for Authorization`};let o=e.prefix;return o!==void 0&&(typeof o!="string"||o.length>za||/[\r\n]/.test(o))?{ok:!1,problem:"auth.prefix must be a short string"}:{ok:!0,auth:{kind:"header",secret:n,header:r,...typeof o=="string"&&o?{prefix:o}:{}}}}function Xa(e){if(!ce(e))return{ok:!1,problem:"remote must be an object"};let t=e.url;if(typeof t!="string"||!t||t.length>On)return{ok:!1,problem:"remote.url must be a URL"};let s=Ja(e.auth);if(!s.ok)return s;let n=e.risk??"annotations";if(!vn.includes(n))return{ok:!1,problem:`remote.risk must be one of ${vn.join(", ")}`};let r={},o=e.tools??{};if(!ce(o))return{ok:!1,problem:"remote.tools must be an object"};let a=Object.entries(o);if(a.length>In)return{ok:!1,problem:`remote.tools has more than ${In} entries`};for(let[c,d]of a){if(!c||c.length>Wa)return{ok:!1,problem:"remote.tools has a tool name that is empty or too long"};if(!ce(d))return{ok:!1,problem:`remote.tools.${c} must be an object`};let u={};if(d.risk!==void 0){if(!kn(d.risk))return{ok:!1,problem:`remote.tools.${c}.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.${c}.enabled must be true or false`};u.enabled=d.enabled}r[c]=u}let i=e.rev??1;return typeof i!="number"||!Number.isInteger(i)||i<1?{ok:!1,problem:"remote.rev must be a positive integer"}:{ok:!0,block:{url:t,auth:s.auth,risk:n,tools:r,rev:i}}}function Rn(e){if(!ce(e)||e.remote===void 0)return null;let t=Xa(e.remote);return t.ok?t.block:null}function kl(e){return ce(e)&&e.remote!==void 0}function Cn(e){return"secret"in e?e.secret:null}function Za(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 Nn(e,t){let s=e.tools[t];if(s)return s;let n=Pn(t);if(n){for(let[r,o]of Object.entries(e.tools))if(Pn(r)===n)return o}}function Sl(e){let t=(e.name??"").trim().slice(0,Ka)||e.id,s=(e.description??"").trim().slice(0,Ha)||Za(t,e.remote.url);return{id:e.id,name:t,description:s,remote:e.remote}}function vl(e,t,s){let n=Nn(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 Il(e,t){return Nn(e,t)?.enabled!==!1}function Pn(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,""),An.test(t)?t:null):null}function $n(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 Qa(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 Bt(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 Xe(e){return(e.providers??[]).flatMap(t=>typeof t=="string"?[{id:t}]:t&&typeof t=="object"&&typeof t.id=="string"?[{id:t.id,...Bt(t)}]:[])}function Cl(e){return Xe(e).map(t=>t.id)}function Ze(e){return(e.secrets??[]).flatMap(t=>typeof t=="string"?[{name:t}]:t&&typeof t=="object"&&typeof t.name=="string"?[{name:t.name,...Bt(t)}]:[])}function Ln(e){return Ze(e).map(t=>t.name)}function Mn(e){return be(e).filter(t=>!ie(t))}function ei(e){let t=s=>s.filter(n=>F(n)&&!ie(n));switch(e.mode){case"api_key":return{names:[...D(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 ti(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 Dn(e,t){if(e.mode==="service"||e.mode==="oauth_client")return{};let s=e.secrets??[],n=[...e.hint?[e.hint]:[],...s.filter(r=>r.hint&&t.includes(r.name)).map(r=>t.length>1?`${r.name}: ${r.hint}`:r.hint)];return n.length>0?{hint:n.join(" ")}:{}}function Je(e,t,s={}){let n=t?.docs??s.docs,r=e.holder==="gateway"?s.setup:t?.setup;return{...e,need:Qa(t),...t?.why?{why:t.why}:{},...n?{docs:n}:{},...r?{setup:r}:{},...s.hint?{hint:s.hint}:{}}}function Nl(e,t=G,s={}){let n=[],r=e.ai?.chat;if(r===!0||r&&typeof r=="object"){let a=ln({choice:s.aiDefault??null,isSet:s.isSet??(()=>!1),lookup:t}),i=d=>d.filter(u=>!ie(u)),c=t.get(a.provider);n.push(Je({kind:"ai-default",id:"ai-default",label:`A chat model (${a.label})`,holder:"gateway",names:i(a.settings),alsoReads:[],alternatives:a.candidates.map(d=>i(d.settings)).filter(d=>d.length>0)},r===!0?void 0:r,{...c?.mode==="ai"?{docs:c.docs}:{},setup:"setup/ai.md",hint:hn(a)}))}for(let a of Xe(e)){let i=t.get(a.id);if(i?.mode!=="ai")continue;let c=Mn(i);n.push(Je({kind:"provider",id:a.id,label:i.label,holder:"gateway",names:c,alsoReads:[]},a,{docs:i.docs,setup:i.setup,...Dn(i,c)}))}for(let[a,i]of Object.entries(e.capabilities??{})){let c=t.get(a);if(!c||c.mode==="ai")continue;let{names:d,alsoReads:u}=ei(c);n.push(Je({kind:"capability",id:a,label:c.label,holder:"gateway",names:d,alsoReads:u},Bt(i),{docs:ti(c),setup:c.setup,...Dn(c,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 o=Rn(e);if(o){let a=Cn(o.auth);if(a){let i=typeof e.name=="string"&&e.name.trim()?e.name.trim():"the MCP server";n.push({kind:"remote-mcp",id:a,label:`${i} credential`,holder:"gateway",names:[a],alsoReads:[],need:{kind:"required"},why:`What ${i} expects: ${$n(o.auth)}. The Gateway sends it to ${o.url} and nowhere else.`,setup:"setup/remote-mcp.md"})}}for(let a of Ze(e))n.push(Je({kind:"secret",id:a.name,label:a.name,holder:"app",names:[a.name],alsoReads:[]},a));return n}function si(e,t){let s=r=>{let o=!1;for(let a of r){let i=t(e.holder,a);if(i===!1)return!1;i===null&&(o=!0)}return o?null:!0};if(!e.alternatives?.length)return s(e.names);let n=!1;for(let r of e.alternatives){let o=s(r);if(o===!0)return!0;o===null&&(n=!0)}return n?null:!1}function $l(e,t,s={}){let n=e.map(a=>{let i=s.readiness?.(a);return{...a,set:i===void 0?si(a,t):i,blocking:!1}}),r=[];for(let a of n){if(a.need.kind!=="anyOf")continue;let i=a.need.group,c=r.find(d=>d.group===i);c||(c={group:i,members:[],met:!1},r.push(c)),c.members.push(a)}for(let a of r){a.met=a.members.some(c=>c.set===!0);let i=a.members.some(c=>c.set===null);if(!a.met&&!i)for(let c of a.members)c.blocking=!0}for(let a of n)a.need.kind==="required"&&a.set===!1&&(a.blocking=!0);let o=n.filter(a=>a.blocking);return{ready:o.length===0,settings:n,groups:r,unmet:o}}function ni(e,{cli:t,appId:s,provider:n=!1}){if(e.unmet.length===0)return null;if(!n)return{command:`${t} configure ${s}`};let r=[],o=a=>{for(let i of a.names)r.includes(i)||r.push(i)};for(let a of e.unmet)a.need.kind==="required"&&o(a);for(let a of e.groups){let i=a.members.find(c=>c.blocking);i&&o(i)}return{command:`${t} secret set ${r.join(" ")}`}}function Dl(e,t){let s=({alsoReads:n,...r})=>r;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(r=>r.id)})),command:t.withCommand===!1?null:ni(e,t)}}var Ml=["cloudflare","resend"];var Qe={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},ri=/^(\*|[a-z0-9._+-]+)@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/,oi=/^(\*|[a-z0-9._+-]+)@([a-z0-9-]+\.)+[a-z]{2,}$/,Ft="everyapp email set";function Gl(e,t){let s=[],n=e==="senders"?Qe.senders:Qe.inbound;t.length>n&&s.push(`At most ${n} ${e==="senders"?"senders":"inbound addresses"}, not ${t.length}.`);for(let r of t)e==="inbound"&&r.length>Qe.inboundAddressChars?s.push(`${r} is longer than Email Routing's ${Qe.inboundAddressChars} characters.`):(e==="senders"?ri:oi).test(r)||s.push(e==="senders"?`"${r}" isn't a sender: a sender is "*@<domain>" or "<local>@<domain>", in lowercase.`:`"${r}" isn't an inbound address: an inbound address is "*@<domain>" or "<local>@<domain>", in lowercase.`);for(let r of new Set(t.filter((o,a)=>t.indexOf(o)!==a)))s.push(`${r} is listed twice.`);return s}function Ul(e){return e.length===0?null:JSON.stringify(e)}function jl(e,t){let s=e?.trim();if(!s)return null;let n=/^(.*?)\s*<([^<>]+)>$/.exec(s),r=(n?.[2]??s).trim(),o=n?.[1]?.trim().replace(/^(["'])(.*)\1$/,"$2").trim(),a=t?.trim()||o;return r&&a?{address:r,name:a}:null}function zl(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 Hl(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 ii=/^[a-z][a-z0-9-]{0,31}(?:\.[a-z][a-z0-9-]{0,31})?$/,Yt=["space","comma","google","microsoft","slack"],Gn=["form","basic"],ci=/^[A-Za-z0-9-]{1,64}$/,di=new Set(["authorization","content-type","content-length","host","cookie"]),pi=/^[A-Za-z0-9_.-]{1,64}$/,Un=/^[A-Za-z_][A-Za-z0-9_]{0,63}(?:\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/,ui=/[\p{Cc}\p{Cf}]/u,jn=20,zn=40,Kn=20,et=50,Hn=10,li=["batch","$batch"],hi=["kind","authorizeUrl","tokenUrl","revokeUrl","revokeMethod","clientId","clientSecret","inject","pkce","scopeDialect","authorizeParams","tokenHeaders","identity"];function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function z(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(ui.test(e)){s.push({path:t,message:"holds a control character"});return}return e}}function tt(e,t,s,{query:n}){if(e===void 0)return;let r=z(e,t,s,500);if(r===void 0)return;let o;try{o=new URL(r)}catch{s.push({path:t,message:"must be an https URL"});return}if(o.protocol!=="https:"||o.username||o.password||o.port||o.hash){s.push({path:t,message:"must be an https URL with no port, credentials or fragment"});return}if(!n&&o.search){s.push({path:t,message:"may not carry a query string"});return}return{url:r,host:o.hostname.toLowerCase()}}function mi(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 Wn(e,t,s,n){if(e===void 0)return;if(!Se(e)){s.push({path:t,message:"must be an object of strings"});return}let r=Object.entries(e);if(r.length>Hn){s.push({path:t,message:`at most ${Hn} entries`});return}let o={};for(let[a,i]of r){let c=`${t}.${a}`;n(a,c);let d=z(i,c,s,200);d!==void 0&&(o[a]=d)}return o}function st(e,t,s){if(e===void 0)return;if(!Array.isArray(e)||e.length>zn){s.push({path:t,message:`must be a list of at most ${zn} scopes`});return}let n=[];return e.forEach((r,o)=>{let a=z(r,`${t}.${o}`,s,200);if(a!==void 0){if(/\s/.test(a)||a.includes(",")){s.push({path:`${t}.${o}`,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 fi(e,t,s,n){if(e===void 0)return;if(!Array.isArray(e)||e.length>Kn){n.push({path:t,message:`must be a list of at most ${Kn} routes`});return}let r=[];return e.forEach((o,a)=>{let i=`${t}.${a}`;if(!Se(o)){n.push({path:i,message:"must be { host, paths, posts? }"});return}for(let h of Object.keys(o))["host","paths","posts"].includes(h)||n.push({path:`${i}.${h}`,message:"unknown field"});let c=z(o.host,`${i}.host`,n,253);c!==void 0&&!s.includes(c)&&n.push({path:`${i}.host`,message:"must be one of hosts"});let d=[];!Array.isArray(o.paths)||o.paths.length>et?n.push({path:`${i}.paths`,message:`must be a list of at most ${et} paths`}):o.paths.forEach((h,y)=>{let m=z(h,`${i}.paths.${y}`,n,500);if(m!==void 0){if(!m.startsWith("/")||m.includes("//")||m.includes("\\")||m.includes("%")||/(^|\/)\.\.?(\/|$)/.test(m)){n.push({path:`${i}.paths.${y}`,message:"must start with / and hold no //, backslash, percent-escape or dot segment"});return}d.push(m)}});let u=[];o.posts!==void 0&&(!Array.isArray(o.posts)||o.posts.length>et?n.push({path:`${i}.posts`,message:`must be a list of at most ${et} anchored patterns`}):o.posts.forEach((h,y)=>{let m=z(h,`${i}.posts.${y}`,n,500);if(m!==void 0){if(!m.startsWith("^")||!m.endsWith("$")){n.push({path:`${i}.posts.${y}`,message:"must be anchored: start with ^ and end with $"});return}try{u.push(new RegExp(m))}catch{n.push({path:`${i}.posts.${y}`,message:"is not a valid pattern"})}}})),c!==void 0&&r.push({host:c,paths:d,...o.posts===void 0?{}:{posts:u}})}),r}function gi(e,t,s){if(!Se(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>jn){s.push({path:"scopeSets",message:`must name 1 to ${jn} sets`});return}let r={};for(let[o,a]of n){let i=`scopeSets.${o}`;if(!ii.test(o)){s.push({path:i,message:"a set is named identity, or <area>.<access> in lowercase (repo.read)"});continue}if(!Se(a)){s.push({path:i,message:"must be { label, access, scopes }"});continue}for(let m of Object.keys(a))["label","access","scopes","userScopes","routes"].includes(m)||s.push({path:`${i}.${m}`,message:"unknown field"});let c=z(a.label,`${i}.label`,s,80);a.label===void 0&&s.push({path:`${i}.label`,message:"required"});let d=a.access;d!=="read"&&d!=="write"&&s.push({path:`${i}.access`,message:"must be read or write"});let u=st(a.scopes,`${i}.scopes`,s);a.scopes===void 0&&s.push({path:`${i}.scopes`,message:"required"});let h=st(a.userScopes,`${i}.userScopes`,s),y=fi(a.routes,`${i}.routes`,t,s);c===void 0||d!=="read"&&d!=="write"||u===void 0||(r[o]={label:c,access:d,scopes:u,...h===void 0?{}:{userScopes:h},routes:y??[]})}return r}function yi(e,t,s){if(e===void 0)return;if(!Se(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=tt(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 r=z(e.label,"auth.identity.label",s,128);r!==void 0&&!Un.test(r)&&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 o=z(e.id,"auth.identity.id",s,128);if(o!==void 0&&!Un.test(o)&&s.push({path:"auth.identity.id",message:"must be a JSON field name, or a dotted path to a nested one"}),!(!n||r===void 0))return{url:n.url,label:r,...o===void 0?{}:{id:o}}}function Bn(e,t,s){let n=(_,O,Be)=>mi(_,O,Be,/^[A-Z][A-Z0-9_]{2,63}$/),r=e.auth;for(let _ of Object.keys(r))hi.includes(_)||s.push({path:`auth.${_}`,message:"not a field of auth.kind oauth2-user"});let o=tt(r.authorizeUrl,"auth.authorizeUrl",s,{query:!0});r.authorizeUrl===void 0&&s.push({path:"auth.authorizeUrl",message:"required"});let a=tt(r.tokenUrl,"auth.tokenUrl",s,{query:!1});r.tokenUrl===void 0&&s.push({path:"auth.tokenUrl",message:"required"});let i=tt(r.revokeUrl,"auth.revokeUrl",s,{query:!1}),c=r.revokeMethod;c!==void 0&&c!=="POST"&&c!=="DELETE"&&s.push({path:"auth.revokeMethod",message:"must be POST or DELETE"}),c!==void 0&&i===void 0&&s.push({path:"auth.revokeMethod",message:"needs a revokeUrl"});let d=n(r.clientId,"auth.clientId",s),u=r.clientSecret===void 0?void 0:n(r.clientSecret,"auth.clientSecret",s);u!==void 0&&u===d&&s.push({path:"auth.clientSecret",message:"must be another setting than auth.clientId"});let h=r.inject??"form";Gn.includes(h)||s.push({path:"auth.inject",message:"must be form (the client in the body) or basic (HTTP Basic)"});let y=r.pkce??!0;typeof y!="boolean"&&s.push({path:"auth.pkce",message:"must be true or false"});let m=r.scopeDialect??"space";Yt.includes(m)||s.push({path:"auth.scopeDialect",message:`must be one of ${Yt.join(", ")}`});let l=Wn(r.authorizeParams,"auth.authorizeParams",s,(_,O)=>{pi.test(_)||s.push({path:O,message:"must be a query parameter name"}),["client_id","redirect_uri","response_type","scope","state","code_challenge","code_challenge_method"].includes(_)&&s.push({path:O,message:`${_} is a parameter the Gateway sets itself`})}),A=Wn(r.tokenHeaders,"auth.tokenHeaders",s,(_,O)=>{ci.test(_)?(di.has(_.toLowerCase())||_.toLowerCase().startsWith("x-everyapp-"))&&s.push({path:O,message:`${_} is a header the Gateway sets itself`}):s.push({path:O,message:"must be a header name"})}),w=yi(r.identity,t.hosts,s),b=gi(e.scopeSets,t.hosts,s),k=st(e.alwaysRequested,"alwaysRequested",s),U=st(e.tolerated,"tolerated",s);if(!o||!a||d===void 0||!b||typeof y!="boolean"||!Yt.includes(m)||!Gn.includes(h))return;let te=[],se=_=>{for(let O of _)te.includes(O)||te.push(O)};for(let _ of Object.values(b))se(_.scopes),se(_.userScopes??[]);se(k??[]);let ze={sets:b,tolerated:U??[],alwaysRequested:k??[],dialect:m,grantTypes:["authorization_code","refresh_token"],requestScope:"keep",deniedSegments:[...li]},Ke={tokenUrl:a.url,...i===void 0?{}:{revokeUrl:i.url},...c===void 0?{}:{revokeMethod:c},pkce:y,scopeDialect:m,...l===void 0?{}:{authorizeParams:l},...A===void 0?{}:{tokenHeaders:A},...w===void 0?{}:{identity:w}},He=new URL(a.url).pathname,We={mode:"oauth_client",label:t.name,secrets:{clientId:d,...u===void 0?{}:{clientSecret:u}},token:[{host:a.host,path:He,methods:["POST"],inject:h}],access:t.access??["read"],console:t.docs,authorize:{url:o.url,scopes:te},scopePolicy:ze,api:[...t.hosts],redirectPaths:[],flow:Ke,...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}},Ee=[...t.hosts];for(let _ of[o.host,a.host,i?.host])_&&!Ee.includes(_)&&Ee.push(_);return{capability:We,hosts:Ee}}function Fn(e,t){let s=t.flow,n=t.scopePolicy;if(!s||!n)return null;let r=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:r,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(([o,a])=>[o,{label:a.label,access:a.access,scopes:[...a.scopes],...a.userScopes===void 0?{}:{userScopes:[...a.userScopes]},...a.routes.length===0?{}:{routes:a.routes.map(i=>({host:i.host,paths:[...i.paths],...i.posts===void 0?{}:{posts:i.posts.map(c=>c.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 qt=/^[a-z][a-z0-9-]{1,39}$/,wi=/^[A-Z][A-Z0-9_]{2,63}$/,Ei=/^(?=.{1,253}$)(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/,Vt=["GET","HEAD","POST","PUT","PATCH","DELETE"],bi=/^[a-z0-9_-]{1,64}$/,_i=/^[A-Za-z0-9-]{1,64}$/,Ai=/^[A-Za-z0-9_.-]{1,64}$/,ki=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,Si=/^[A-Za-z_][A-Za-z0-9_]{0,63}(?:\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/,vi=/^\d{4}-\d{2}-\d{2}$/,Ii=/^[a-z][a-z0-9-]{0,31}$/,Ti=/[\p{Cc}\p{Cf}]/u,Pi=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"]),xi=20,Yn=50,Oi=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"]),Ri=["hostSetting","data","secrets","accountWidePaths","smoke","cost","rate","verified"],Ci=["scopeSets","alwaysRequested","tolerated"];function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e,t,s,{max:n,min:r=1}){if(e!==void 0){if(typeof e!="string"){s.push({path:t,message:"must be a string"});return}if(e.length<r||e.length>n){s.push({path:t,message:`must be ${r} to ${n} characters`});return}if(Ti.test(e)){s.push({path:t,message:"holds a control character"});return}return e}}function Vn(e,t,s){let n=I(e,t,s,{max:500});if(n===void 0)return;let r;try{r=new URL(n)}catch{s.push({path:t,message:"must be an https URL"});return}if(r.protocol!=="https:"){s.push({path:t,message:"must be an https URL"});return}return n}function ot(e,t,s,{max:n,each:r}){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 o=[];return e.forEach((a,i)=>{if(typeof a!="string"){s.push({path:`${t}.${i}`,message:"must be a string"});return}r(a,`${t}.${i}`),o.push(a)}),new Set(o).size!==o.length&&s.push({path:t,message:"lists an entry twice"}),o}function qn(e,t,s){return ot(e,t,s,{max:Vt.length,each:(n,r)=>{Vt.includes(n)||s.push({path:r,message:`must be one of ${Vt.join(", ")}`})}})}function rt(e,t,s){if(typeof e!="string"||!wi.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 Ni(e,t){if(!K(e)){t.push({path:"auth",message:"must be an object with a kind: bearer, header, query or basic"});return}let s=e.kind,n=rt(e.secret,"auth.secret",t),r=o=>{for(let a of Object.keys(e))o.includes(a)||t.push({path:`auth.${a}`,message:`not a field of auth.kind ${String(s)}`})};switch(s){case"bearer":{r(["kind","secret","scheme"]);let o=I(e.scheme,"auth.scheme",t,{max:32});return o!==void 0&&!ki.test(o)&&t.push({path:"auth.scheme",message:"must be a token such as Bearer, Token or Api-Key"}),n?{kind:s,secret:n,...o===void 0?{}:{scheme:o}}:void 0}case"header":{r(["kind","secret","header","prefix"]);let o=I(e.header,"auth.header",t,{max:64});o!==void 0&&(_i.test(o)?(Pi.has(o.toLowerCase())||o.toLowerCase().startsWith("x-everyapp-"))&&t.push({path:"auth.header",message:`${o} 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||o===void 0?void 0:{kind:s,secret:n,header:o,...a===void 0?{}:{prefix:a}}}case"query":{r(["kind","secret","param"]);let o=I(e.param,"auth.param",t,{max:64});return o!==void 0&&!Ai.test(o)&&t.push({path:"auth.param",message:"must be a query parameter name"}),!n||o===void 0?void 0:{kind:s,secret:n,param:o}}case"basic":{r(["kind","secret","as","user"]);let o=e.as;if(o!=="password"&&o!=="username"&&o!=="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(o!=="password")return e.user!==void 0&&t.push({path:"auth.user",message:`not a field of auth.as ${o}`}),n?{kind:s,secret:n,as:o}:void 0;let a=e.user,i;if(typeof a=="string"){let c=I(a,"auth.user",t,{max:128});c!==void 0&&c.includes(":")&&t.push({path:"auth.user",message:"may not hold a colon"}),i=c}else if(K(a)&&Object.keys(a).join()==="secret"){let c=rt(a.secret,"auth.user.secret",t);c!==void 0&&c===n&&t.push({path:"auth.user.secret",message:"must be another setting than auth.secret"}),i=c===void 0?void 0:{secret:c}}else t.push({path:"auth.user",message:"required with as: password: a string, or { secret: NAME }"});return!n||i===void 0?void 0:{kind:s,secret:n,as:o,user:i}}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 $i(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((r,o)=>{let a=`secrets.${o}`;if(!K(r)){s.push({path:a,message:"must be an object"});return}for(let d of Object.keys(r))["name","hint"].includes(d)||s.push({path:`${a}.${d}`,message:"unknown field"});let i=rt(r.name,`${a}.name`,s);i!==void 0&&!t.includes(i)&&s.push({path:`${a}.name`,message:`auth names no setting ${i}`});let c=I(r.hint,`${a}.hint`,s,{max:300});i!==void 0&&n.push({name:i,...c===void 0?{}:{hint:c}})}),new Set(n.map(r=>r.name)).size!==n.length&&s.push({path:"secrets",message:"names a setting twice"}),n}function Di(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>Yn){t.push({path:"accountWidePaths",message:`at most ${Yn} entries`});return}let s=[];return e.forEach((n,r)=>{let o=`accountWidePaths.${r}`;if(!Array.isArray(n)||n.length===0){t.push({path:o,message:"must be a non-empty list of segments"});return}let a=[];n.forEach((i,c)=>{if(typeof i!="string"||!bi.test(i)){t.push({path:`${o}.${c}`,message:"must be a lowercase path segment (letters, digits, _ and -)"});return}a.push(i)}),a.length===n.length&&s.push(a)}),s}function Li(e,t,s){if(e===void 0)return;if(!K(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 r=I(e.host,"smoke.host",s,{max:253});r!==void 0&&!t.includes(r)&&s.push({path:"smoke.host",message:"must be one of hosts"});let o=I(e.path,"smoke.path",s,{max:500});o!==void 0&&(!o.startsWith("/")||o.startsWith("//"))&&s.push({path:"smoke.path",message:"must start with one /"});let a=e.expect,i=Array.isArray(a)&&a.length>0&&a.every(u=>Number.isInteger(u)&&u>=100&&u<=599)?a:void 0;i||s.push({path:"smoke.expect",message:"must list the HTTP statuses that mean the key works"});let c=e.free;typeof c!="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"||o===void 0||!i||typeof c!="boolean"))return{method:n,...r===void 0?{}:{host:r},path:o,expect:i,free:c,...d===void 0?{}:{note:d}}}function nt(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 Mi(e,t){if(e===void 0)return;if(!K(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=nt(e.usd,"cost.usd",t),r=I(e.note,"cost.note",t,{max:200}),o=I(e.responseField,"cost.responseField",t,{max:128});if(o!==void 0&&!Si.test(o)&&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},...r===void 0?{}:{note:r},...o===void 0?{}:{responseField:o}}}function Gi(e,t){if(e===void 0)return;if(!K(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=nt(e.perSecond,"rate.perSecond",t),n=nt(e.perMinute,"rate.perMinute",t),r=nt(e.perDay,"rate.perDay",t),o=I(e.note,"rate.note",t,{max:200});return{...s===void 0?{}:{perSecond:s},...n===void 0?{}:{perMinute:n},...r===void 0?{}:{perDay:r},...o===void 0?{}:{note:o}}}function Ui(e,t){if(e!==void 0){if(e===!1)return!1;if(K(e)&&typeof e.on=="string"&&vi.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 Jn(e,t){let s=ot(e.access,"access",t,{max:2,each:(o,a)=>{o!=="read"&&o!=="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=qn(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 r=qn(e.writeMethods,"writeMethods",t);return{access:s,readMethods:n,writeMethods:r}}function Xn(e,t){return ot(e,"tags",t,{max:10,each:(s,n)=>{Ii.test(s)||t.push({path:n,message:"must be a lowercase word"})}})}function at(e){let t=[];if(!K(e))return{ok:!1,problems:[{path:"(root)",message:"must be a JSON object"}]};for(let _ of Object.keys(e))Oi.has(_)||t.push({path:_,message:"unknown field"});let s=e.id;(typeof s!="string"||!qt.test(s))&&t.push({path:"id",message:"must be lowercase letters, digits and hyphens, a letter first, 2 to 40 characters (stripe)"});let n=K(e.auth)&&e.auth.kind==="oauth2-user",r=n?"oauth_client":"api_key";e.mode!==void 0&&e.mode!==r&&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 o=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}),i=Vn(e.docs,"docs",t);e.docs===void 0&&t.push({path:"docs",message:"required: where the person gets the key, an https URL"});let c=Vn(e.api,"api",t),d=ot(e.hosts,"hosts",t,{max:xi,each:(_,O)=>{Ei.test(_)||t.push({path:O,message:"must be a bare lowercase host with a dot and no port, path or scheme (api.stripe.com)"})}});if(n){let{access:_,readMethods:O,writeMethods:Be}=Jn(e,t),qs=I(e.hint,"hint",t,{max:500}),Js=I(e.example,"example",t,{max:200}),Xs=Xn(e.tags,t);for(let Qs of Ri)e[Qs]!==void 0&&t.push({path:Qs,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 Zs=typeof s=="string"&&o!==void 0&&i!==void 0&&d!==void 0?Bn(e,{id:s,name:o,docs:i,hosts:d,...a===void 0?{}:{description:a},...c===void 0?{}:{reference:c},..._===void 0?{}:{access:_},...O===void 0?{}:{readMethods:O},...Be===void 0?{}:{writeMethods:Be},...qs===void 0?{}:{hint:qs},...Js===void 0?{}:{example:Js},...Xs===void 0?{}:{tags:Xs}},t):void 0;return t.length>0||!Zs||typeof s!="string"?{ok:!1,problems:t}:{ok:!0,id:s,capability:Zs.capability}}for(let _ of Ci)e[_]!==void 0&&t.push({path:_,message:"only an oauth2-user spec has it"});let u=e.hostSetting===void 0?void 0:rt(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 h=e.data;h!==void 0&&h!=="per-call"&&h!=="account"&&t.push({path:"data",message:"must be per-call or account"});let y=h==="per-call"||h==="account"?h:void 0,m=Ni(e.auth,t);e.auth===void 0&&t.push({path:"auth",message:"required"}),u!==void 0&&m&&oe(m).includes(u)&&t.push({path:"hostSetting",message:"must be another setting than the key"});let l=$i(e.secrets,[...m?oe(m):[],...u===void 0?[]:[u]],t),{access:A,readMethods:w,writeMethods:b}=Jn(e,t),k=Di(e.accountWidePaths,t),U=I(e.hint,"hint",t,{max:500}),te=Li(e.smoke,d??[],t),se=Mi(e.cost,t),ze=Gi(e.rate,t),Ke=I(e.example,"example",t,{max:200}),He=Ui(e.verified,t),We=Xn(e.tags,t);if(t.length>0||typeof s!="string"||o===void 0||i===void 0||!d&&u===void 0||!m)return{ok:!1,problems:t};let Ee={mode:"api_key",label:o,auth:m,docs:i,hosts:d??[],...u===void 0?{}:{hostSetting:u},...y===void 0?{}:{data:y},access:A??["read"],readMethods:w??["GET","HEAD"],accountWidePaths:k??[],...a===void 0?{}:{description:a},...c===void 0?{}:{api:c},...l===void 0?{}:{secrets:l},...b===void 0?{}:{writeMethods:b},...U===void 0?{}:{hint:U},...te===void 0?{}:{smoke:te},...se===void 0?{}:{cost:se},...ze===void 0?{}:{rate:ze},...Ke===void 0?{}:{example:Ke},...He===void 0?{}:{verified:He},...We===void 0?{}:{tags:We}};return{ok:!0,id:s,capability:Ee}}function Jt(e){return e.map(t=>`${t.path}: ${t.message}`).join("; ")}function ql(e,t){if(t.mode==="oauth_client"){let s=Fn(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 E=(e,t,s,n=1)=>({type:t,version:n,description:s,group:e}),Zt=[E("member","member.invited","Someone was invited to the workspace"),E("member","member.joined","Someone joined the workspace"),E("member","member.role_changed","A member's role changed"),E("member","member.deactivated","A member was deactivated"),E("member","member.reactivated","A member was reactivated"),E("member","member.removed","A member was removed"),E("member","member.password_reset","A member reset their password"),E("app","app.installed","An app was installed on the Gateway"),E("app","app.updated","An app was redeployed"),E("app","app.removed","An app was removed from the Gateway"),E("app","app.needs_setup","An app needs a setting before it opens"),E("app","app.ready","An app has every setting it needs"),E("app","app.paused_cap","An app is paused: its monthly cap is reached"),E("app","app.tools_changed","An app's AI tools changed"),E("cap","cap.warning","An app is at 80% of its monthly cap"),E("cap","cap.reached","An app reached its monthly cap"),E("cap","cap.raised","An app's monthly cap, or the workspace default, was raised or removed"),E("tool","tool.blocked","An AI client's tool call was blocked"),E("tool","tool.error","An AI client's tool call failed"),E("connection","connection.created","An AI app was connected"),E("connection","connection.revoked","An AI app connection was revoked"),E("token","token.created","A personal access token was created"),E("token","token.revoked","A personal access token was revoked"),E("access","access.changed","Cloudflare Access was turned on or off"),E("signin_provider","signin_provider.added","A sign-in provider (Continue with Google, \u2026) was turned on"),E("signin_provider","signin_provider.removed","A sign-in provider was turned off"),E("mcp_app","mcp_app.added","An MCP app was added"),E("mcp_app","mcp_app.removed","An MCP app was removed"),E("mcp_app","mcp_app.enabled","An MCP app is being served again"),E("mcp_app","mcp_app.disabled","An MCP app stopped being served"),E("provider","provider.added","A provider was registered"),E("provider","provider.removed","A provider was removed"),E("provider","provider.updated","A provider's spec or OAuth client was replaced"),E("provider","provider.connected","Someone connected an account at an OAuth provider"),E("provider","provider.disconnected","An OAuth provider account was disconnected"),E("provider","provider.connection_expired","An OAuth provider refused to refresh a connection; it needs reconnecting"),E("ai","ai.default_changed","The default model provider changed"),E("ping","ping","A test event, sent to one subscription on request")],Qt=new Map(Zt.map(e=>[e.type,e]));function Zn(e){return Qt.get(e)}var de="app.";var ji=64;function it(e){return e.startsWith(de)&&!Qt.has(e)&&e.slice(de.length).includes(".")}var zi=8*1024,Xl=16*1024,Qn=8;var Zl=25,Ql=16,eh=128,th=30;var sh=200,nh=2048,rh=100,Ki=[6e4,3e5,18e5,72e5,288e5,864e5],oh=Ki.length+1;var ah="EVENTS_ALLOW_PRIVATE_TARGETS",Hi=["localhost","local","localdomain","internal","intranet","lan","corp","private","home.arpa","onion"];function ih(e){return e.includes(".")?Hi.some(t=>e===t||e.endsWith(`.${t}`)):!0}var ch=["owners","admins"];function er(e,t){return e==="*"?t!=="ping":e.endsWith(".*")?t.startsWith(e.slice(0,-1)):e===t}function dh(e,t){return e.some(s=>er(s,t))}var Wi=/^(\*|[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*(\.\*)?)$/;function ph(e){if(!Wi.test(e)||e.length>ji+8)return`"${e}" isn't an event type or pattern (member.joined, member.*, app.crm.*, *)`;if(e==="*"||Qt.has(e))return null;if(e.endsWith(".*")){let t=e.slice(0,-1);return Zt.some(s=>s.type.startsWith(t))||e.startsWith(de)?null:`"${e}" matches no event type (everyapp events types lists them)`}return it(e)?null:`"${e}" isn't an event type (everyapp events types lists them)`}var Bi=/secret|token|password|passwd|authorization|api[_-]?key|private[_-]?key|credential|cookie|session/i;function Xt(e,t){if(t>Qn)return"\0depth";if(Array.isArray(e)){for(let s of e){let n=Xt(s,t+1);if(n)return n}return null}if(e&&typeof e=="object")for(let[s,n]of Object.entries(e)){if(Bi.test(s))return s;let r=Xt(n,t+1);if(r)return r}return null}function uh(e,t=zi){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 r=Xt(JSON.parse(s),1);return r==="\0depth"?{ok:!1,code:"event_data_invalid",message:`data nests at most ${Qn} levels deep`}:r?{ok:!1,code:"event_data_refused",message:`data must not carry a credential: the key "${r}" reads like one (secret, token, password, authorization, api key, private key, credential, cookie, session)`,key:r}:{ok:!0,bytes:n}}function Y(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function T(e){return typeof e=="string"&&e.length>0?e:null}function ct(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function mh(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{t={}}let s=Y(t);return{kind:T(s.kind)??"gateway",id:T(s.id),email:T(s.email),name:T(s.name)}}function fh(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 gh(e){let t=Zn(e);if(t)return t.description;if(it(e)){let s=e.slice(de.length);return`App event: ${s.slice(s.indexOf(".")+1)}`}return e}function dt(e){let t=Y(e),s=T(t.id)??T(t.rowId);return s?{id:s,name:T(t.name)}:void 0}function yh(e,t){let s=Y(t),n={},r=dt(s.app);if(r)e.startsWith("mcp_app.")?n.mcpApp=r:n.app=r;else if(it(e)){let m=e.slice(de.length);n.app={id:m.slice(0,m.indexOf(".")),name:null}}let o=Y(s.user);T(o.id)&&(n.user={id:T(o.id),email:T(o.email),name:T(o.name)});let a=dt(s.group);a&&(n.group=a);let i=dt(s.provider);i&&(n.provider=i);let c=dt(s.subscription);c&&(n.subscription=c);let d=Y(s.invitation);T(d.email)&&(n.invitation={email:T(d.email),role:T(d.role)});let u=[...ct(s.settings),...ct(s.unmet),...ct(s.changed),...ct(s.names)];u.length>0&&(n.settings=[...new Set(u)]);let h=T(s.tool);h&&(n.tool=h);let y=T(Y(s.client).name)??T(Y(s.connection).clientName);return y&&(n.client=y),e.startsWith("token.")&&T(s.name)&&(n.token=T(s.name)),n}function wh(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 Eh(e){return e==="*"?null:e.endsWith(".*")?{op:"prefix",value:e.slice(0,-1)}:{op:"eq",value:e}}var Fi=".everyapp/providers";function Ah(e){return`${Fi}/${e}.json`}var V=new TextEncoder,tr=new TextDecoder,Yi=new TextDecoder("utf-8",{fatal:!0}),Sh=2**32;function sr(...e){let t=e.reduce((r,{length:o})=>r+o,0),s=new Uint8Array(t),n=0;for(let r of e)s.set(r,n),n+=r.length;return s}var Vi=/[^\x00-\x7f]/;function pt(e){if(typeof e=="string"&&e.length>=128){if(Vi.test(e))throw new TypeError("non-ASCII string encountered in encode()");return V.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 es(e,t=!1){if(Uint8Array.prototype.toBase64)return e.toBase64({alphabet:t?"base64url":"base64",omitPadding:t});let s=32768,n=[];for(let o=0;o<e.length;o+=s)n.push(String.fromCharCode.apply(null,e.subarray(o,o+s)));let r=btoa(n.join(""));return t?r.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"):r}function ut(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 r=0;r<s.length;r++)n[r]=s.charCodeAt(r);return n}var q=class extends Error{code="ERR_JOSE_GENERIC";constructor(t,s){super(t,s),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};ne(q,"code","ERR_JOSE_GENERIC");var R=class extends q{code="ERR_JOSE_NOT_SUPPORTED"};ne(R,"code","ERR_JOSE_NOT_SUPPORTED");var $=class extends q{code="ERR_JWS_INVALID"};ne($,"code","ERR_JWS_INVALID");var ve=class extends q{code="ERR_JWT_INVALID"};ne(ve,"code","ERR_JWT_INVALID");var ts=class extends q{[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)}};ne(ts,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var qi="The input to be decoded is not correctly encoded.";function nr(e){try{return ut(typeof e=="string"?e:tr.decode(e),!0)}catch(t){throw new TypeError(qi,{cause:t})}}function Ie(e){return es(typeof e=="string"?V.encode(e):e,!0)}function Te(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 rr(...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 or(e,t){if(e!==void 0)throw new TypeError(`${t} can only be called once`)}var ar={__proto__:null,b64:!0};function ir(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 cr(e,t,s,n,r){if(r.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 o=s===void 0?t:{__proto__:null,...s,...t};for(let a of n.crit){if(!(a in o))throw new R(`Extension Header Parameter "${a}" is not recognized`);if(!Object.hasOwn(r,a)||r[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(o[a]&&(!Object.hasOwn(n,a)||n[a]===void 0))throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return n.crit}function dr(e,t){if(t.includes("b64")){let s=e.b64;if(typeof s!="boolean")throw new $('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return s}return!0}function ss(e,t){let s,n;try{s=JSON.stringify(t),n=JSON.parse(s)}catch(r){throw new e("JOSE Header is not valid JSON",{cause:r})}if(!Te(n))throw new e("JOSE Header is not a JSON object");return[n,s]}var Ji=e=>e[Symbol.toStringTag],Xi=(e,t,s)=>{let{alg:n}=e;if(t.use!==void 0){let r=s==="sign"||s==="verify"?"sig":"enc";if(t.use!==r)throw new TypeError(`Invalid key for this operation, its "use" must be "${r}" 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 r=s==="encrypt"||s==="decrypt"?e.ops?.[s==="encrypt"?0:1]:s;if(r&&!t.key_ops.includes(r))throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${r}" when present`)}};async function ur(e,t,s){let{alg:n,secret:r}=e,o=s==="decrypt"||s==="sign";if(r&&t instanceof Uint8Array)return t;let a,i;if(Te(t)){if(a=rc(t),typeof a.kty!="string")throw pr(n,t,r);if(!(r?a.kty==="oct"&&typeof a.k=="string":a.kty!=="oct"&&(o?a.kty==="AKP"&&typeof a.priv=="string"||typeof a.d=="string":a.d===void 0&&a.priv===void 0)))throw new TypeError(r?'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 ${o?"private":"public"} JWK`);if(Xi(e,a,s),a.kty==="oct")return nr(a.k);if(!Object.isFrozen(t)){let{key_ops:u}=t;Array.isArray(u)&&Object.freeze(u),Object.freeze(t)}}else{if(!Qi(t))throw pr(n,t,r);let u=r?"secret":o?"private":"public";if(t.type!==u&&(r||["secret","public","private"].includes(t.type)))throw new TypeError(`${Ji(t)} instances must be of type "${u}" for the ${n} algorithm`);if(rs(t))return t;if(i=t,i.type==="secret")return i.export()}ns||=new WeakMap;let c=t,d=ns.get(c);if(d?.[n])return d[n];if(d||ns.set(c,d={}),i&&typeof i.toCryptoKey=="function"){let u=i.type==="public",h=Zi[i.asymmetricKeyDetails?.namedCurve],y=e.resolve?.({crv:h,asymmetricKeyType:i.asymmetricKeyType})??e.subtle;return d[n]=i.toCryptoKey(y,u,e.usages[u?0:1])}return a??=i.export({format:"jwk"}),a.alg=n,d[n]=await oc(e,a)}var ns,Zi={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};var rs=e=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},lr=e=>e?.[Symbol.toStringTag]==="KeyObject",Qi=e=>rs(e)||lr(e);function ec(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 pr(e,t,s){let n=["CryptoKey","KeyObject","JSON Web Key"];return s&&n.push("Uint8Array"),new TypeError(ec(`Key for the ${e} algorithm must be `,t,...n))}var lt=(e,t="algorithm.name")=>new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function tc(e,t){if(t&&!e.usages.includes(t))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function hr(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 sc(e,t,s){let n=e.algorithm;if(n.name!==t.name)throw lt(t.name);if(t.hash&&n.hash?.name!==t.hash)throw lt(t.hash,"algorithm.hash");if(t.namedCurve&&n.namedCurve!==t.namedCurve)throw lt(t.namedCurve,"algorithm.namedCurve");if(t.length!==void 0&&n.length!==t.length)throw lt(t.length,"algorithm.length");tc(e,s)}function nc(e){return{__proto__:null,...e}}function rc(e){let t=nc(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(r=>typeof r!="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 mr(e){if(e!==void 0&&typeof e!="boolean")throw new TypeError('"extractable" option must be a boolean');return e}async function oc(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,r=!!(t.d||t.priv),o={...t,ext:s??t.ext};return o.kty!=="AKP"&&delete o.alg,delete o.use,crypto.subtle.importKey("jwk",o,n,o.ext??!r,t.key_ops??e.usages[r?1:0])}async function fr(e,t,s,n=!1){return e instanceof Uint8Array&&(e=await crypto.subtle.importKey("raw",e,t,n,[s])),sc(e,t,s),e}function Pe(e){let t={__proto__:null};for(let s in e)t[s]={...e[s],alg:s};return t}var ac=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],ic=[[],["deriveBits"]],ft=[[],[]];function ht(e){return{kty:["RSA"],mode:"key-encryption",subtle:{name:"RSA-OAEP",hash:`SHA-${e}`},usages:ac,ops:["wrapKey","unwrapKey"]}}function mt(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:ic,ops:[void 0,"deriveBits"]}}function pe(e,t=!1){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:ft,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function os(){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:"PBKDF2"},usages:ft,ops:["deriveBits","deriveBits"]}}var gr=Pe({dir:{kty:["oct"],mode:"direct-encryption",secret:!0,subtle:{name:"AES-GCM"},usages:ft,ops:["encrypt","decrypt"]},"RSA-OAEP":ht(1),"RSA-OAEP-256":ht(256),"RSA-OAEP-384":ht(384),"RSA-OAEP-512":ht(512),"ECDH-ES":mt("direct-key-agreement"),"ECDH-ES+A128KW":mt("key-agreement-with-key-wrapping"),"ECDH-ES+A192KW":mt("key-agreement-with-key-wrapping"),"ECDH-ES+A256KW":mt("key-agreement-with-key-wrapping"),A128KW:pe(128),A192KW:pe(192),A256KW:pe(256),A128GCMKW:pe(128,!0),A192GCMKW:pe(192,!0),A256GCMKW:pe(256,!0),"PBES2-HS256+A128KW":os(),"PBES2-HS384+A192KW":os(),"PBES2-HS512+A256KW":os()}),cc=["encrypt","decrypt"];function ue(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:ft,ops:cc,cekBits:e,ivBits:t?128:96,cbc:t}}var Uh=Pe({A128GCM:ue(128),A192GCM:ue(192),A256GCM:ue(256),"A128CBC-HS256":ue(256,!0),"A192CBC-HS384":ue(384,!0),"A256CBC-HS512":ue(512,!0)});var xe=[["verify"],["sign"]];function as(e){let t={name:"HMAC",hash:`SHA-${e}`};return{kty:["oct"],secret:!0,subtle:t,signing:t,usages:xe}}function le(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:xe,minRsaBits:2048}}function is(e,t){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:`SHA-${t}`},usages:xe}}function yr(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:xe}}function cs(e){let t={name:`ML-DSA-${e}`};return{kty:["AKP"],subtle:t,signing:t,usages:xe}}var ds=Pe({HS256:as(256),HS384:as(384),HS512:as(512),RS256:le(256),RS384:le(384),RS512:le(512),PS256:le(256,32),PS384:le(384,48),PS512:le(512,64),ES256:is("P-256",256),ES384:is("P-384",384),ES512:is("P-521",512),EdDSA:yr(),Ed25519:yr(),"ML-DSA-44":cs(44),"ML-DSA-65":cs(65),"ML-DSA-87":cs(87)});function wr(e){let t=typeof e=="string"?ds[e]:void 0;if(!t)throw new R(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}var gt=e=>Math.floor(e.getTime()/1e3),dc={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},pc=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function ps(){throw new TypeError("Invalid time period format")}function Er(e){typeof e!="string"&&ps();let t=pc.exec(e);(!t||t[4]&&t[1])&&ps();let s=parseFloat(t[2]),n=Math.round(s*dc[t[3][0].toLowerCase()]);return Number.isFinite(n)||ps(),t[1]==="-"||t[4]==="ago"?-n:n}function hs(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}function us(e,t){if(typeof t!="string")throw new TypeError(`"${e}" claim must be a string`)}function uc(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 ls(e,t){return typeof e=="number"?hs(t,e):e instanceof Date?hs(t,gt(e)):gt(new Date)+Er(e)}var br;function H(e){return br.get(e)}function _r(e){let t=H(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 V.encode(JSON.stringify(t))}var yt=class{constructor(t={}){if(!Te(t))throw new TypeError("JWT Claims Set MUST be an object");(br||=new WeakMap).set(this,structuredClone(t))}setIssuer(t){return us("iss",t),H(this).iss=t,this}setSubject(t){return us("sub",t),H(this).sub=t,this}setAudience(t){return uc(t),H(this).aud=t,this}setJti(t){return us("jti",t),H(this).jti=t,this}setNotBefore(t){return H(this).nbf=ls(t,"setNotBefore"),this}setExpirationTime(t){return H(this).exp=ls(t,"setExpirationTime"),this}setIssuedAt(t){let s=H(this);return t===void 0?s.iat=gt(new Date):typeof t=="string"?s.iat=hs("setIssuedAt",gt(new Date)+Er(t)):s.iat=ls(t,"setIssuedAt"),this}};async function lc(e,t,s){let[n,r,o,a]=e,i="";if(r!==void 0){let b=ss($,r);r=b[0],i=Ie(b[1])}if(o!==void 0&&(o=ss($,o)[0]),!r&&!o)throw new $("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!rr(r,o))throw new $("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let c={...r,...o};ir($,r);let d=dr(r,cr($,ar,a,r,c));d||s?.();let{alg:u}=c;if(typeof u!="string"||!u)throw new $('JWS "alg" (Algorithm) Header Parameter missing or invalid');let h=wr(u),y="",m=n,l;if(d){let b=e[4];b?(y=b[0]??=Ie(n),m=b[1]??=pt(y)):(y=Ie(n),l=V.encode(`${i}.${y}`))}l??=sr(pt(i),pt("."),m);let A=await fr(await ur(h,t,"sign"),h.subtle,"sign");h.minRsaBits&&hr(h.alg,A);let w={signature:Ie(new Uint8Array(await crypto.subtle.sign(h.signing,A,l))),payload:y};return r&&(w.protected=i),o&&(w.header=o),[w,d]}async function Ar(e,t,s,n,r){let[o]=await lc([e,t,void 0,s],n,r);return`${o.protected}.${o.payload}.${o.signature}`}var hc=yt,J=class extends hc{#e;setProtectedHeader(t){return or(this.#e,"setProtectedHeader"),this.#e=t,this}async sign(t,s){return Ar(_r(this),this.#e,s?.crit,t,()=>{throw new ve("JWTs MUST NOT use unencoded payload")})}};var ms='"alg" (Algorithm)';function fs(e='JWK "alg" (Algorithm) Parameter'){throw new R(`Invalid or unsupported ${e} value`)}function kr(e,t){return(typeof e=="string"?ds[e]??gr[e]:void 0)??fs(t)}var Oe=(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},mc=e=>({data:e,pos:0}),gs=e=>{let t=e.data[e.pos++];if(t===void 0)throw new Error("Unexpected end of ASN.1 input");return t},Re=e=>{let t=gs(e);if(t&128){let s=t&127,n=0;for(let r=0;r<s;r++)n=n<<8|gs(e);return n}return t};var Ce=(e,t,s)=>{if(gs(e)!==t)throw new Error(s)},Sr=(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},fc=e=>{Ce(e,6,"Expected algorithm OID");let t=Re(e);return Sr(e,t)};function gc(e,t){if(Ce(e,48,`Invalid ${t==="spki"?"SPKI":"PKCS#8"} structure`),Re(e),t==="pkcs8"){Ce(e,2,"Expected version field");let s=Re(e);e.pos+=s}Ce(e,48,"Expected algorithm identifier"),Re(e)}var yc=e=>{let t=fc(e);if(Oe(t,[43,101,110]))return"X25519";if(!Oe(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");Ce(e,6,"Expected curve OID");let s=Re(e),n=Sr(e,s);if(Oe(n,[42,134,72,206,61,3,1,7]))return"P-256";if(Oe(n,[43,129,4,0,34]))return"P-384";if(Oe(n,[43,129,4,0,35]))return"P-521";throw new Error("Unsupported named curve")},wc=async(e,t,s,n)=>{let r=mr(n?.extractable),o=kr(s,ms);o.secret&&fs(ms);let a=e==="spki",i;if(o.resolve)try{let c=mc(t);gc(c,e),i=o.resolve({crv:yc(c)})}catch{throw new R("Invalid or unsupported key format")}else i=o.subtle;return crypto.subtle.importKey(e,t,i,r??a,o.usages[a?0:1])},Ec=(e,t)=>ut(e.replace(t,"")),vr=(e,t,s)=>{let n=Ec(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return wc("pkcs8",n,t,s)};async function ys(e,t,s){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return vr(e,t,s)}var Ne="RS256",Et="everyapp-identity",bc="everyapp-identity-dev";var _c="x-everyapp-identity",Ac="x-everyapp-public",Im="x-everyapp-system";var Ir=120,ws=60;var Tr="public",kc="system";function Sc(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 vc(e){return{typ:"public",pub:!0,jti:e}}var wt=null;async function Es(e){let t=e.replace(/\\n/g,`
|
|
3
|
+
`);if(wt&&wt.pem===t)return wt.key;let s=await ys(t,Ne);return wt={pem:t,key:s},s}async function Tm(e,t){let s=await Es(e),n=Math.floor((t.now??Date.now())/1e3),r=t.ttlSeconds??Ir,o=crypto.randomUUID();return new J(Sc(t.subject,{channel:t.channel,actor:t.actor,scopes:t.scopes,toolCall:t.toolCall,jti:o})).setProtectedHeader({alg:Ne,kid:t.keyId??Et}).setIssuer(t.issuer).setSubject(t.subject.sub).setAudience(t.audience).setIssuedAt(n).setExpirationTime(n+r).sign(s)}async function Pm(e,t){let s=await Es(e),n=Math.floor((t.now??Date.now())/1e3),r=t.ttlSeconds??Ir;return new J(vc(crypto.randomUUID())).setProtectedHeader({alg:Ne,kid:t.keyId??Et}).setIssuer(t.issuer).setSubject(Tr).setAudience(t.audience).setIssuedAt(n).setExpirationTime(n+r).sign(s)}async function xm(e,t){let s=t.ttlSeconds??ws;if(s<=0||s>ws)throw new RangeError(`system tokens live at most ${ws}s (got ${s})`);let n=await Es(e),r=Math.floor((t.now??Date.now())/1e3),o={typ:"system",purpose:t.purpose,jti:crypto.randomUUID()};return new J(o).setProtectedHeader({alg:Ne,kid:t.keyId??Et}).setIssuer(t.issuer).setSubject(kc).setAudience(t.audience).setIssuedAt(r).setExpirationTime(r+s).sign(n)}function Ic(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=>Tc(t,n)??""},...s==="workers-ai"?{normalizeResponse:Rc}:{}}}var Pr=Object.fromEntries(j.flatMap(e=>{let t=C[e];return t.mode==="ai"&&!("kind"in t&&t.kind==="proxy")?[[e,Ic(t)]]:[]}));function Cm(e){return Object.hasOwn(Pr,e)?Pr[e]:void 0}function Nm(e){return[e.keyEnv,...e.alsoNeeds??[]]}function Tc(e,t){let s=!1,n=e.replace(/\{([A-Z][A-Z0-9_]*)\}/g,(r,o)=>{let a=t[o];return typeof a!="string"||!a.trim()?(s=!0,""):encodeURIComponent(a.trim())});return s?null:n}var Pc=new Set(["/v1/chat/completions"]),xc=["content","reasoning_content","reasoning"],Oc=/"(?:content|reasoning_content|reasoning)"\s*:\s*-?\d/;function Rc(e,t){if(!t.body||!Pc.has(e))return t;let s=(t.headers.get("content-type")??"").toLowerCase(),n=s.startsWith("text/event-stream")?Nc():s.startsWith("application/json")?$c():null;if(!n)return t;let r=new Headers(t.headers);return r.delete("content-length"),new Response(t.body.pipeThrough(n),{status:t.status,statusText:t.statusText,headers:r})}function Cc(e){if(!bs(e)||!Array.isArray(e.choices))return!1;let t=!1;for(let s of e.choices)if(bs(s)){for(let n of[s.delta,s.message])if(bs(n))for(let r of xc){let o=n[r];typeof o=="number"&&(n[r]=String(o),t=!0)}}return t}function xr(e){if(!Oc.test(e))return null;let t;try{t=JSON.parse(e)}catch{return null}return Cc(t)?JSON.stringify(t):null}function Nc(){let e=new TextDecoder,t=new TextEncoder,s="",n=r=>{let o=/^(data:[ ]?)(.*?)(\r?)$/s.exec(r);if(!o)return r;let a=xr(o[2]);return a===null?r:`${o[1]}${a}${o[3]}`};return new TransformStream({transform(r,o){s+=e.decode(r,{stream:!0});let a=s.lastIndexOf(`
|
|
4
|
+
`);if(a===-1)return;let i=s.slice(0,a+1);s=s.slice(a+1),o.enqueue(t.encode(i.split(`
|
|
5
|
+
`).map(n).join(`
|
|
6
|
+
`)))},flush(r){s+=e.decode(),s&&r.enqueue(t.encode(n(s)))}})}function $c(){let e=[];return new TransformStream({transform(t){e.push(t)},flush(t){let s=new TextDecoder,n=e.map(o=>s.decode(o,{stream:!0})).join("")+s.decode(),r=xr(n);if(r!==null){t.enqueue(new TextEncoder().encode(r));return}for(let o of e)t.enqueue(o)}})}function bs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Mm=64*1024;function Dc(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(([r],[o])=>r<o?-1:r>o?1:0)):n]));return JSON.stringify({auth:t,hostSetting:e.hostSetting??null,hosts:[...e.hosts].sort()})}var Lc=new Set(["everyapp"]),Mc=/^\d{1,3}(\.\d{1,3}){3}$/,Gc=[".localhost",".local",".internal",".arpa"];function Uc(e){return`${e.toUpperCase().replace(/-/g,"_")}_`}function jc(e){return Mc.test(e)?`${e} is an IP address, not a host name`:e==="localhost"||Gc.some(t=>e.endsWith(t))?`${e} is not a public host`:null}function _s(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 Fm(e,t){let s=_s(t.gatewayHost);if(s&&e===s)return`${e} is this gateway's own host`;let n=_s(t.appBaseDomain);if(n&&(e===n||e.endsWith(`.${n}`)))return`${e} is under this gateway's app domain ${n}`;let r=_s(t.thirdPartyDomain);return r&&(e===r||e.endsWith(`.${r}`))?`${e} is under this gateway's third-party domain ${r}`:null}function zc(e,t,s){let n=Uc(e);return t.startsWith(n)?ie(t)?`${t} is one of the Gateway's own keys`:wn(t)?`${t} is a local-development setting`:Ve(t)?`${t} is a name everyapp sets itself`:Ye(t)?`${t} is a sign-in provider's setting name (every <ID>_SIGNIN_<FIELD> name is the Gateway's, set with \`everyapp signin add\`)`:F(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 Kc(e,t,s){if(Lc.has(e)||j.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 D(t)){let r=zc(e,n,o=>s.rowSettings.has(o));if(r)return{id:e,code:"PROVIDER_SECRET_TAKEN",message:r}}for(let n of Hc(t)){let r=jc(n)??s.refuseHost?.(n);if(r)return{id:e,code:"PROVIDER_HOST_REFUSED",message:r}}return null}function Hc(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 r=new URL(n).hostname.toLowerCase();t.includes(r)||t.push(r)}catch{}return t}function Wc(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=at(s);if(!n.ok)return{ok:!1,refusal:{id:e.id,code:"PROVIDER_SPEC_INVALID",message:Jt(n.problems)}};if(n.id!==e.id||!qt.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 r=Kc(n.id,n.capability,t);return r?{ok:!1,refusal:r}:{ok:!0,capability:n.capability}}function Bc(e=[],t={}){let s=new Map(j.map(d=>[d,C[d]])),n=new Map,r=[],o=new Set;for(let d of e){if(n.has(d.id)){r.push({id:d.id,code:"PROVIDER_SPEC_INVALID",message:"listed twice"});continue}let u=Wc(d,{rowSettings:o,...t.refuseHost?{refuseHost:t.refuseHost}:{}});if(!u.ok){r.push(u.refusal);continue}n.set(d.id,{id:d.id,capability:u.capability,bound:d.boundTo===Dc(u.capability),addedBy:d.addedBy??null,addedAt:d.addedAt??null});for(let h of D(u.capability))o.add(h)}let a=new Map([...s,...[...n.values()].map(d=>[d.id,d.capability])]),i,c;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:()=>(i??=new Set([...a.values()].flatMap(d=>D(d))),i),bound:d=>s.has(d)||(n.get(d)?.bound??!1),unboundSettings:()=>(c??=new Set([...n.values()].filter(d=>!d.bound).flatMap(d=>D(d.capability))),c),rows:()=>[...n.values()],rejected:r}}var Ym=Bc();import{z as p}from"zod";var Or=/[\x00-\x1f\x7f]/,Fc=/%2f|%5c/i;function As(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(Or.test(e))return{canonical:"/",ambiguous:!0,reason:"control characters"};if(e.includes("\\"))return{canonical:"/",ambiguous:!0,reason:"backslash"};if(Fc.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(Or.test(t)||t.includes("\\"))return{canonical:"/",ambiguous:!0,reason:"decoded to unsafe characters"};let s=[],n=!1;for(let o of t.split("/"))if(!(o===""||o===".")){if(o===".."){if(s.length===0)return{canonical:"/",ambiguous:!0,reason:"path traversal above root"};s.pop(),n=!0;continue}s.push(o)}let r="/"+s.join("/");return n&&/%2e/i.test(e)?{canonical:r,ambiguous:!0,reason:"encoded traversal"}:{canonical:r,ambiguous:!1}}function Yc(e){return e===X||e.startsWith(X+"/")}function zf(e){return Rr(As(e).canonical)||Rr(Nr(e))}function Rr(e){let t=e.toLowerCase();return t===ke||t.startsWith(`${ke}/`)}var Vc=["oauth-protected-resource","oauth-authorization-server","openid-configuration"],qc=Vc.flatMap(e=>[`/.well-known/${e}`,`/mcp/.well-known/${e}`]);function Kf(e){return Cr(As(e).canonical)||Cr(Nr(e))}function Cr(e){let t=e.toLowerCase();return qc.some(s=>t===s||t.startsWith(`${s}/`))}function Nr(e){let t=e;for(let n=0;n<3;n+=1){let r;try{r=decodeURIComponent(t)}catch{break}if(r===t)break;t=r}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 Jc(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 r=e.slice(s+1).match(/^[A-Za-z_][A-Za-z0-9_]*/)?.[0],o=r?e[s+1+r.length]:void 0;r&&(o===void 0||o==="/")?(t+="[^/]+",s+=1+r.length):(t+="\\:",s+=1)}else t+=n.replace(/[.+?^${}()|[\]\\]/g,"\\$&"),s+=1}return t+="$",new RegExp(t)}function $r(e,t,s){if(!e||e.length===0)return{public:!1,reason:"no public routes declared"};let{canonical:n,ambiguous:r,reason:o}=As(s);if(r)return{public:!1,reason:`ambiguous path: ${o}`};if(Yc(n))return{public:!1,reason:"internal namespace is never public"};let a=t.toUpperCase();for(let i of e)if((i.methods??["GET"]).map(d=>d.toUpperCase()).includes(a)&&Jc(i.path).test(n))return{public:!0,route:i,reason:`matched ${i.path}`};return{public:!1,reason:"no matching public route"}}var Ur=p.object({path:p.string(),methods:p.array(p.string()).optional()}),bt=p.object({name:p.string(),className:p.string(),worker:p.string().optional()}),jr=p.object({name:p.string(),worker:p.string().optional(),caching:p.enum(["off","default"]).optional()}),Xc=["cosine","euclidean","dot-product"],Zc=["@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"],he={min:32,max:1536},zr=p.object({name:p.string(),dimensions:p.number().optional(),metric:p.string().optional(),preset:p.string().optional()}),Kr=p.object({name:p.string(),collectLogs:p.boolean().optional(),cacheTtl:p.number().int().min(0).optional()}),Hr=p.object({d1:p.array(p.string()).optional(),kv:p.array(p.string()).optional(),durableObjects:p.array(bt).optional(),workflows:p.array(bt).optional(),hyperdrive:p.array(jr).optional(),r2:p.array(p.string()).optional(),ai:p.array(p.string()).optional(),browser:p.array(p.string()).optional(),images:p.array(p.string()).optional(),vectorize:p.array(zr).optional(),aiGateway:p.array(Kr).optional()}).passthrough(),Qc=p.string().regex(/^\d{4}-\d{2}-\d{2}$/,"must be YYYY-MM-DD"),ed=/^[a-z0-9][a-z0-9:_-]{0,63}$/,vs={when:({value:e})=>typeof e=="object"&&e!==null&&!Array.isArray(e)},Wr=p.record(p.string(),p.string().min(1).max(200)).superRefine((e,t)=>{for(let s of Object.keys(e))s==="*"||s.startsWith("provider:")?t.addIssue({code:p.ZodIssueCode.custom,path:[s],message:"reserved scope id"}):ed.test(s)||t.addIssue({code:p.ZodIssueCode.custom,path:[s],message:"invalid scope id"})},vs),td=Wr,sd=p.object({engine:p.enum(["drizzle","d1-sql","prisma"]),dialect:p.enum(["sqlite","postgresql"]).optional(),dir:p.string().optional(),config:p.string().min(1).optional(),binding:p.string().min(1).optional()}).strict().superRefine((e,t)=>{if(e.engine==="prisma"&&e.dialect!=="postgresql"&&t.addIssue({code:p.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:p.ZodIssueCode.custom,path:["engine"],message:'Postgres migrations run on the "drizzle" or "prisma" engine'}),e.binding!==void 0&&t.addIssue({code:p.ZodIssueCode.custom,path:["binding"],message:"binding names a D1 database; Postgres migrations have none"})),e.config!==void 0&&!Gr(e.config)&&t.addIssue({code:p.ZodIssueCode.custom,path:["config"],message:"config must be a relative path without .. segments"}),e.engine==="d1-sql"&&!e.dir?.trim()){t.addIssue({code:p.ZodIssueCode.custom,path:["dir"],message:'dir is required when migrations.engine is "d1-sql"'});return}e.dir&&!Gr(e.dir)&&t.addIssue({code:p.ZodIssueCode.custom,path:["dir"],message:"dir must be a relative path without .. segments"})}),nd=p.union([p.literal(!1),p.string().min(1)]),Br=/^[a-z][a-z0-9-]*$/,Fr="provider must start with a lowercase letter and contain only lowercase letters, digits, and hyphens",kt=p.string().regex(Br,Fr);function Yr(e,t){return Br.test(e)?!1:(t.addIssue({code:p.ZodIssueCode.custom,path:[e],message:Fr}),!0)}var rd=p.string().url().refine(e=>e.startsWith("https://"),"must be an https URL"),St={why:p.string().min(1).max(200).optional(),docs:rd.optional(),optional:p.boolean().optional(),anyOf:p.string().trim().min(1).max(40).optional()},od=p.object({id:kt}).passthrough(),ad=p.object({id:kt,...St}).strict(),Vr=(e,t)=>{let s=new Set;e.forEach((n,r)=>{let o=typeof n=="string"?n:n.id;s.has(o)&&t.addIssue({code:p.ZodIssueCode.custom,path:[r],message:"duplicate provider"}),s.add(o)})},id=p.array(p.union([kt,od])).superRefine(Vr),cd=p.array(p.union([kt,ad])).superRefine(Vr),Dr=p.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"a secret's name is an identifier").max(64),_t=p.object({scopes:p.array(p.string()).optional().catch(void 0),access:p.enum(["read","write"]),...St}),dd=_t.passthrough();function pd(e,t=G){let s=t.get(e);if(!s||s.mode==="ai")throw new Error(`capabilityEntrySchema: ${e} is not a capability`);let n=p.enum(["read","write"]).refine(c=>s.access.includes(c),`${s.label} offers ${s.access.join(" or ")} access`),r="scopePolicy"in s?s.scopePolicy:void 0;if(!r){let c=p.undefined({error:`${s.label} takes no scopes; list it as { access: ..., why }`}).optional();return _t.extend({access:n,scopes:c}).strict()}let o=Object.keys(r.sets),a=`${s.label} needs scopes: one or more of ${o.join(", ")}`,i=p.array(p.enum(o,{error:`unknown scope set (${s.label} offers: ${o.join(", ")})`}),{error:a}).min(1,a).refine(c=>new Set(c).size===c.length,"a scope set is listed twice");return _t.extend({access:n,scopes:i}).strict()}var ud=p.record(p.string(),dd).superRefine((e,t)=>{for(let s of Object.keys(e))Yr(s,t)},vs),ld=_t.extend({scopes:p.array(p.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 qr(e,t){return p.record(p.string(),p.unknown()).superRefine((s,n)=>{for(let[r,o]of Object.entries(s)){if(Yr(r,n))continue;let a=e.get(r);if(a?.mode==="ai"){n.addIssue({code:p.ZodIssueCode.custom,path:[r],message:`${r} is an AI provider: list it under providers, not capabilities`});continue}if(!a){if(t==="refuse"){n.addIssue({code:p.ZodIssueCode.custom,path:[r],message:`unknown capability (the gateway offers: ${cn(e).join(", ")})`});continue}let c=ld.safeParse(o);if(c.success)continue;for(let d of c.error.issues)n.addIssue({...d,path:[r,...d.path]});continue}if(r==="email"&&o!==null&&typeof o=="object"&&"senders"in o){n.addIssue({code:p.ZodIssueCode.custom,path:[r,"senders"],message:`senders moved out of the manifest: set them with \`${Ft} --sender <pattern>\` in the app's directory after its first deploy`});continue}let i=pd(r,e).safeParse(o);if(!i.success)for(let c of i.error.issues)n.addIssue({...c,path:[r,...c.path]})}},vs).transform(s=>s)}var hd=qr(G,"refuse"),md=`inbound is true (the Worker exports an email() handler) or left out; the addresses moved out of the manifest: set them with \`${Ft} --inbound <address>\` in the app's directory after its first deploy`,fd=p.object({inbound:p.boolean().optional().catch(void 0)}).passthrough(),gd=p.object({inbound:p.boolean({error:md}).optional()}).strict(),yd="email.inbound: apps in a dispatch namespace don't receive mail",At=p.object({cpuMs:p.number().int().min(1).max(3e5).optional()}).passthrough(),Jr=p.object({provider:p.enum(["d1","postgres"]),region:p.string().regex(/^[a-z0-9]+:[a-z0-9-]+$/,'region must be a cloud region such as "aws:us-east-1"').optional()}).passthrough(),wd=p.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),Xr=p.object({name:wd,binding:p.string().optional(),limits:At.optional()}),Ed=p.enum(["everyone","admins"]),Zr=p.string().regex(/^\/v1(\/[a-z0-9_-]+)+$/,'must be an OpenAI API path such as "/v1/files"'),Qr=p.object({...St}),bd=Qr.strict(),_d=p.object({models:p.array(p.string().min(1).max(200)).optional(),routes:p.array(Zr).optional(),chat:p.union([p.boolean(),Qr]).optional()}).passthrough(),Ad=p.object({models:p.array(p.string().min(1).max(200)).optional(),routes:p.array(Zr).optional(),chat:p.union([p.boolean(),bd]).optional()}).strict(),kd=`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`,Sd=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,eo=p.object({by:p.enum(["gateway","app"]),why:p.string().min(1,"say why the app needs /mcp on its own host").max(200).regex(Sd,"why is plain text: no control characters")},{error:e=>e.code==="invalid_type"?kd:void 0}).passthrough(),to=p.object({id:p.string().min(1).regex(/^[a-z]([a-z0-9-]*[a-z0-9])?$/,"id must be kebab-case (lowercase, digits, hyphens)"),name:p.string().min(1).optional(),description:p.string().optional(),icon:p.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:p.string().optional(),compatibilityDate:Qc.optional(),resources:Hr.optional(),workers:p.array(Xr.passthrough()).optional(),database:Jr.optional(),limits:At.optional(),public:p.array(Ur).optional(),providers:id.optional(),capabilities:ud.optional(),secrets:p.array(p.union([Dr,p.object({name:Dr}).passthrough()])).max(100).optional(),scopes:Wr.optional(),ai:_d.optional(),email:fd.optional(),access:Ed.optional(),serverFnGuard:p.boolean().optional(),serverFnBase:p.string().regex(/^(\/[A-Za-z0-9_~-][A-Za-z0-9._~-]*)+\/?$/,'must be a path such as "/app/_serverFn"').optional(),build:p.string().min(1).optional(),dev:p.string().min(1).optional(),devPort:p.number().int().positive().optional(),install:nd.optional(),migrations:sd.optional(),mcp:eo.optional()}).passthrough(),vd=Ur.strict(),L=p.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"binding names must be JavaScript identifiers"),Id=p.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)"),Td=p.string().regex(/^setup\/[a-z0-9][a-z0-9-]*\.md$/,'must be a guide in the everyapp skill, such as "setup/main-secret.md"'),Pd=p.object({name:L,...St,setup:Td.optional()}).strict();function xd(e,t){if(!e)return null;for(let s of e.ids()){if(Ut(s))continue;let n=e.get(s);if(n&&D(n).includes(t))return{kind:"capability",id:s}}return null}function so(e){return p.array(p.union([L,Pd])).superRefine((t,s)=>{let n=new Set;t.forEach((r,o)=>{let a=typeof r=="string"?r:r.name,i=y=>s.addIssue({code:p.ZodIssueCode.custom,path:[o],message:y});if(n.has(a)&&i(`duplicate secret ${a}`),n.add(a),Ve(a)){i(`${a} is set by everyapp itself (${En})`);return}let c=a.toUpperCase();if(Ye(c)){i(`${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=F(c)?null:xd(e,c);if(!F(c)&&!d)return;if(Ae(c)){i(`${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??bn(c),h=u?`list \`${u.id}\` under ${u.kind==="provider"?"providers":"capabilities"} instead`:"give the app's secret another name";i(`${a} is a Gateway setting, which \`everyapp secret set ${c}\` sets on the Gateway for every app; ${h}`)})})}var Od=so(),Rd=zr.extend({name:L,dimensions:p.number().int("a Vectorize index's dimensions are a whole number").min(he.min,`a Vectorize index has ${he.min} to ${he.max} dimensions`).max(he.max,`a Vectorize index has ${he.min} to ${he.max} dimensions`).optional(),metric:p.enum(Xc).optional(),preset:p.enum(Zc).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")`})}),Cd=Hr.extend({d1:p.array(L).optional(),kv:p.array(L).optional(),r2:p.array(L).optional(),ai:p.array(L).optional(),browser:p.array(L).optional(),images:p.array(L).optional(),durableObjects:p.array(bt.strict()).optional(),workflows:p.array(bt.extend({name:L}).strict()).optional(),hyperdrive:p.array(jr.extend({name:L}).strict()).optional(),vectorize:p.array(Rd).optional(),aiGateway:p.array(Kr.extend({name:Id}).strict()).optional()}).strict();function no(e={}){let t=e.capabilities===void 0&&(e.unknownCapabilities??"refuse")==="refuse"?hd:qr(e.capabilities??G,e.unknownCapabilities??"refuse");return to.extend({resources:Cd.optional(),providers:cd.optional(),workers:p.array(Xr.extend({binding:L.optional(),limits:At.strict().optional()}).strict()).optional(),public:p.array(vd).optional(),scopes:td.optional(),ai:Ad.optional(),capabilities:t.optional(),secrets:(e.capabilities?so(e.capabilities):Od).optional(),email:gd.optional(),database:Jr.strict().optional(),limits:At.strict().optional(),mcp:eo.strict().optional()}).strict()}var Yf=no(),X="/__everyapp",Nd=["everyapp"];function $d(e){return Nd.includes(e)}var S=class extends Error{constructor(t){super(t),this.name="ManifestError"}};function ro(e){return e.map(t=>`${t.path.map(String).join(".")||"(root)"}: ${t.message}`).join("; ")}function Vf(e){let t=to.safeParse(e);if(!t.success)throw new S(`Invalid manifest: ${ro(t.error.issues)}`);let s=t.data;for(let n of s.public??[])ao(n.path);return s}function qf(e,t={}){let s=no(t).safeParse(e);if(!s.success)throw new S(`Invalid everyapp.config: ${ro(s.error.issues)}`);let n=s.data,r=Ud(n),o=Ln(n).find(a=>r.has(a));if(o)throw new S(`Invalid everyapp.config: secrets: ${o} is one of the app's bindings; pick another name for the secret`);if($d(n.id))throw new S(`Invalid everyapp.config: id "${n.id}" is reserved for the platform.`);for(let a of n.public??[]){ao(a.path);let i=a.path==="/mcp"||a.path.startsWith("/mcp/");if(i||(a.methods??["GET"]).some(d=>$r([a],d,"/mcp").public))throw new S(`Invalid everyapp.config: public: ${a.path} can't be public${i?"":" (it covers /mcp)"}; an app that runs its own MCP server sets mcp: { by: "app", why: "..." }`)}return Md(n),Gd(n),Dd(n),Ld(n),n}function Dd(e){let t=ks({appId:e.id,orgKey:"k".repeat(Kd)});for(let{name:s}of e.resources?.aiGateway??[]){let n=Mr(t,s);if(n.length>Ss)throw new S(`Invalid everyapp.config: resources.aiGateway: ${s} would make an AI Gateway id of up to ${n.length} characters (${Mr(ks({appId:e.id,orgKey:"<orgKey>"}),s)}), longer than Cloudflare's ${Ss}; shorten the binding name.`)}}function Ld(e){let t=[...Xe(e).map(n=>({path:`providers: ${n.id}`,need:n})),...Object.entries(e.capabilities??{}).map(([n,r])=>({path:`capabilities.${n}`,need:r})),...Ze(e).map(n=>({path:`secrets: ${n.name}`,need:n}))],s=new Map;for(let{path:n,need:r}of t){let o=r.anyOf?.trim();if(r.optional===!0&&o)throw new S(`Invalid everyapp.config: ${n} is both optional and in the any-of group "${o}"; a group's member is optional by itself, so drop one of them.`);o&&s.set(o,[...s.get(o)??[],n])}for(let[n,r]of s)if(r.length<2)throw new S(`Invalid everyapp.config: the any-of group "${n}" has one member (${r[0]}); an any-of group needs two or more. Drop anyOf, or mark it optional.`)}function Md(e){let t=new Set;for(let{name:n}of e.workers??[]){if(t.has(n))throw new S(`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 S(`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 S(`Invalid everyapp.config: Hyperdrive ${n.name} is bound by Worker "${n.worker}", which workers doesn't declare.`)}function Gd(e){if(e.migrations?.dialect==="postgresql"&&e.database?.provider!=="postgres")throw new S('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?.ai??[],...e.resources?.browser??[],...e.resources?.images??[],...(e.resources?.vectorize??[]).map(n=>n.name),...(e.resources?.aiGateway??[]).map(n=>n.name)]){if(t.has(s))throw new S(`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?.ai??[],...e.resources?.browser??[],...e.resources?.images??[],...(e.resources?.vectorize??[]).map(t=>t.name),...(e.resources?.aiGateway??[]).map(t=>t.name),...(e.workers??[]).flatMap(t=>t.binding?[t.binding]:[]),...e.database?["DATABASE_PROVIDER"]:[],"ASSETS"])}function Jf(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?.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.email?.inbound===!0&&s.push(yd),e.secrets?.length&&s.push("secrets: third-party apps can't have secrets of their own yet"),s}function Xf(e){return e.startsWith("every-")?e:`every-${e}`}var Lr="every-app-gateway",jd=63;function zd(e){let t=e.toLowerCase();return t===Lr||t.startsWith(`${Lr}-`)}var oo="--";function ks({appId:e,orgKey:t}){if(!t)throw new Error("An org-scoped Worker name needs an org key.");return`every-${t}-${e}`}function Zf(e){return zd(e.workerName)||e.workerName.length>jd||!e.orgKey||e.appId.includes(oo)?!1:e.workerName===ks(e)}function Qf(e,t){return t==="DB"||t==="KV"?e:Is(e,t)}var eg=63;function tg(e,t){return t==="R2"?e:Is(e,t)}var sg=64;function ng(e,t){return Is(e,t)}var Ss=64,Kd=12,Hd=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function rg(e){return e.length<=Ss&&Hd.test(e)}function Mr(e,t){return`${e}-${t.toLowerCase().replaceAll("_","-")}`}function Is(e,t){let s=t.toLowerCase().replaceAll("_","-");return`${e}${oo}${s}`}function ao(e){if(!e.startsWith("/"))throw new S(`Public route path must be absolute (start with "/"): ${JSON.stringify(e)}`);if(e==="/*"||e==="/**"||e==="*"||e==="/")throw new S(`Public route "${e}" exposes the entire app. A catch-all public route is not allowed.`);if(e.includes("%"))throw new S(`Public route "${e}" must not contain percent-encoding; declare the decoded path.`);if(e.includes("\\"))throw new S(`Public route "${e}" must not contain backslashes.`);let t=e.split("/");if(t.some(n=>n==="."||n===".."))throw new S(`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 S(`Public route "${e}" has an invalid named segment "${n}".`);let s="/"+(t[1]??"");if(e===X||e.startsWith(X+"/")||s===X)throw new S(`Public route "${e}" targets the reserved ${X} namespace, which can never be public.`)}function Gr(e){return!e.trim()||e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)?!1:!e.split(/[\\/]+/).some(t=>t==="..")}var Wd="APP__";function ag(e){return`${Wd}${e}`}var ig=Object.freeze({manifest:"manifest",stamp:"stamp",worker:"worker",modulePrefix:"module:",assetPrefix:"asset:",migrationPrefix:"migration:"});var Bd={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"},P=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 r=Bd[t];this.rerun=n.rerun??(r?x([r]):this.retryable?x():void 0),this.rerunNote=n.rerunNote,this.authorize=n.authorize??r!==void 0,this.data=n.data}},vt=class extends Error{action;url;rerun;rerunNote;data;constructor(t,s,n,r={}){super(s),this.name="ActionRequiredError",this.action=t,this.url=n,this.rerun=r.rerun===void 0?x():r.rerun,this.rerunNote=r.rerunNote,this.data=r.data}},io=class extends P{constructor(t="Cancelled. Nothing changed."){super("CANCELLED",t),this.name="CancelledError"}},Ts=new WeakMap;function hg(e,t){return t&&typeof e=="object"&&e!==null&&(Ts.has(e)||Ts.set(e,t)),e}function co(e){return typeof e=="object"&&e!==null?Ts.get(e):void 0}function mg(e){return e instanceof Error?e.message:String(e)}var W=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 $e(e,t){return e instanceof W&&e.kind===t}function yg(e){return $e(e,"r2_not_enabled")||$e(e,"access_not_enabled")}var me=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"}},Z=class extends Error{constructor(t,s){super(`Unexpected output from \`${t}\`: ${s}`),this.name="CfOutputError"}},Fd=/Aborting the upload operation because of conflicts/,Yd=[["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)],["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)||/\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)||/\bvectorize\.index\.(not_found|deleted)\b/.test(e)||/\bnot found\b|does not exist/i.test(e)]];function po(e,t){return/^Aborted\.$/m.test(t)?new W({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 uo(e,t=""){let s=Vd(e)??Jd(t,e),n=[...s.matchAll(/\[(?:code: )?(\d{4,})\]/g)].map(o=>Number(o[1])),r=Fd.test(`${t}
|
|
7
|
+
${e}`)?"strict_conflict":Yd.find(([,o])=>o(s,n))?.[0]??"unknown";return{message:s,apiCodes:n,kind:r}}function Vd(e){let t=e.split(/\r?\n/),s=t.findIndex(o=>/^┌\s*(API)?Error/.test(o.trim()));if(s<0)return;let n=[];for(let o of t.slice(s+1)){let a=o.trim();if(a.startsWith("\u2514"))break;n.push(a.replace(/^│ ?/,""))}let r=qd(n);return r.length>0?r:void 0}function qd(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 Jd(...e){return re(...e).join(`
|
|
11
|
+
`)||"cf failed without an error message"}var Ps=new Set;function lo(e){return Ps.add(e),()=>Ps.delete(e)}function It(){for(let e of Ps)e()}function ho(){return!!process.stdout.isTTY&&process.env.TERM!=="dumb"&&!process.env.CI}function Eg(e,t=process.env,s=!!process.stdout.isTTY){return!e&&!t.NO_COLOR&&s&&t.TERM!=="dumb"}import{AsyncLocalStorage as ep}from"node:async_hooks";import Xd from"chalk";import{spawn as Zd}from"node:child_process";import{once as mo}from"node:events";var Q=process.platform!=="win32",Qd=1e3;function fo({command:e,args:t,cwd:s,env:n,shell:r=!1,hold:o}){let a=Zd(e,t,{cwd:s,shell:r,env:o&&Xd.level>0?{...n,FORCE_COLOR:"1"}:n,stdio:["ignore",o?"pipe":"inherit",o?"pipe":"inherit"],detached:Q}),i=o?[]:null,c=o?Promise.race([Promise.all([mo(a.stdout,"end"),mo(a.stderr,"end")]),new Promise(u=>setTimeout(u,1e3).unref())]):Promise.resolve();if(o)for(let[u,h]of[[a.stdout,process.stdout],[a.stderr,process.stderr]])u.on("data",y=>{i?i.push({to:h,chunk:y}):h.write(y)});return{exited:new Promise((u,h)=>{a.once("error",h),a.once("exit",(y,m)=>{c.then(()=>u({code:y,signal:m}))})}),stop:u=>Pt(a,Q,u),releaseOutput:u=>{let h=i??[];if(i=null,u)for(let{to:y,chunk:m}of h)y.write(m)}}}function Pt(e,t,s="SIGTERM"){e.pid!==void 0&&(Tt(e,t,s),s!=="SIGKILL"&&setTimeout(()=>Tt(e,t,"SIGKILL"),Qd).unref())}function Tt(e,t,s){let n=e.pid;if(n!==void 0)try{t?process.kill(-n,s):e.kill(s)}catch{}}var tp=3e3,sp=1e4,np=["SIGINT","SIGTERM"],fe=new Set,Rt=new Set,ee=new Set,go=new WeakSet,bo=new ep,yo=!1,De=!1,xt;function _o(e,t){let s={child:e,group:t,exited:new Promise(n=>{e.exitCode!==null||e.signalCode!==null?n():e.once("close",()=>n())})};return De&&!bo.getStore()&&Ot(s,"SIGKILL"),fe.add(s),Ct(),()=>{fe.delete(s),Ct()}}function xg(){return De}function Og(e){return xt=e,()=>{xt===e&&(xt=void 0)}}function Ao(e){return ee.add(e),Ct(),()=>{ee.delete(e),Ct()}}function Rs(e){return Rt.add(e),()=>Rt.delete(e)}function rp(){let e=[...new Set([...ee].flatMap(n=>n.label?[n.label]:[]))],t=[...fe.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 Fe(s)}function op(e){for(let t of[...e].reverse()){let s=t.closing?.();if(s!==void 0)return s}return"Stopped."}function wo(e,t){Rt.size===0&&process.stderr.write(t);for(let s of Rt)e(s)}function Ct(){let e=fe.size>0||ee.size>0;if(!(e===yo||De)){yo=e;for(let t of np)e?process.on(t,Eo):process.off(t,Eo)}}function Eo(e){ap(e)}async function ap(e,{exit:t=s=>process.exit(s)}={}){let s=e==="SIGTERM"?143:130;if(De){if(e==="SIGTERM")return;for(let c of fe)Ot(c,"SIGKILL");xs(),t(s);return}De=!0,It();let n=xt,r=n===void 0?rp():n?`Stopping ${n}`:"";r&&wo(c=>c.stopping(r),`
|
|
12
|
+
${r} (Ctrl+C again to quit at once)...
|
|
13
|
+
`);let o=[...ee],a=[...fe];for(let c of a)Ot(c,e);let i=Promise.all(a.map(c=>c.exited));if(!await Os(i,tp)){for(let c of a)Ot(c,"SIGKILL");await Os(i,1e3)}if(xs(),await Os(ip(),sp),xs(),n===void 0){let c=op(o);wo(d=>d.stopped(c),c?`${c}
|
|
14
|
+
`:"")}t(s)}async function ip(){for(let e of[...ee].reverse())e.async&&await bo.run(!0,()=>e.async()).catch(()=>{})}function xs(){for(let e of[...ee])if(!go.has(e)){go.add(e);try{e.sync?.()}catch{}}}function Ot({child:e,group:t},s){Tt(e,t,s)}async function Os(e,t){let s,n=new Promise(r=>{s=setTimeout(()=>r(!1),t)});try{return await Promise.race([e.then(()=>!0),n])}finally{clearTimeout(s)}}var ge="22.18.0",Cs="--dns-result-order=ipv4first";function ko(e){let t=(e??"").trim();return t.split(/\s+/).includes(Cs)?t:t?`${t} ${Cs}`:Cs}function Ns(e){return cp(e,ge)>=0}function $g(e=process.versions){return e.bun?new P("UNSUPPORTED_RUNTIME",`everyapp runs on Node.js, not Bun
|
|
15
|
+
The Cloudflare CLI can't load cloudflare.config.ts under Bun.`,{rerun:x(),rerunNote:`with Node.js ${ge} or newer`}):Ns(e.node)?null:new P("UNSUPPORTED_RUNTIME",`everyapp needs Node.js ${ge} or newer; this is ${e.node}
|
|
16
|
+
The Cloudflare CLI loads cloudflare.config.ts with Node's built-in TypeScript support.`,{fix:"install Node 22 or 24, then run the command again"})}function cp(e,t){let s=o=>o.replace(/^v/,"").split(/[.-]/).slice(0,3).map(a=>Number.parseInt(a,10)||0),[n,r]=[s(e),s(t)];for(let o=0;o<3;o+=1){let a=(n[o]??0)-(r[o]??0);if(a!==0)return a}return 0}import pp from"node:path";import{fileURLToPath as up}from"node:url";import So from"node:fs/promises";import Le from"node:path";async function vo(e,t,s){let n=Le.resolve(e);try{let r=await dp(n,t),o=JSON.parse(await So.readFile(r,"utf-8")),a=typeof o.bin=="string"?o.bin:o.bin?.[s];if(!a)throw new Error(`Package does not declare the "${s}" binary.`);return{version:o.version??"unknown",binPath:Le.resolve(Le.dirname(r),a)}}catch(r){throw new Error(`Could not resolve the project-local "${s}" binary from project root "${n}". Install the project's declared ${t} dependency and try again. (If the install skipped devDependencies, include them; Yarn Plug'n'Play projects are not supported \u2014 use nodeLinker: node-modules.)`,{cause:r})}}async function dp(e,t){let s=e;for(;;){let n=Le.join(s,"node_modules",...t.split("/"),"package.json");try{return await So.realpath(n)}catch{}let r=Le.dirname(s);if(r===s)break;s=r}throw new Error(`${t} is not installed under ${e} or any directory above it.`)}var lp=en.cf;function hp(){return Io(pp.dirname(up(import.meta.url)),"cli")}async function Io(e,t){let{binPath:s,version:n}=await vo(e,"cf","cf");return{path:s,version:n,source:t}}var mp="EVERYAPP_CF_BINARY";async function To(e){let t=process.env[mp];if(t)return{path:t,version:lp,source:"cli"};if(e)try{return await Io(e,"project")}catch{}return hp()}import Me from"node:fs/promises";import Po from"node:path";async function fp(e,t,s={}){let n=s.exclude||[];await Me.mkdir(t,{recursive:!0});let r=await Me.readdir(e,{withFileTypes:!0});for(let o of r){let a=Po.join(e,o.name),i=Po.join(t,o.name);n.some(c=>o.name===c)||(o.isDirectory()?await fp(a,i,s):await Me.copyFile(a,i))}}async function Fg(e){try{return(await Me.stat(e)).isDirectory()}catch{return!1}}async function Yg(e){try{return await Me.access(e),!0}catch{return!1}}function ye(e){return e?.code==="ENOENT"}import Oo from"node:fs/promises";import Nt from"node:path";import{execa as kp}from"execa";import gp from"node:fs";import xo from"node:fs/promises";import yp from"node:os";import $s from"node:path";import wp from"chalk";import{execa as Ep}from"execa";async function Ds(e,t,s){let n=[e,...t].join(" "),r=await _p(s.logName??n),o=gp.createWriteStream(r,{flags:"a",mode:384}),a=`$ ${n}
|
|
17
|
+
# in ${s.cwd??process.cwd()}
|
|
18
|
+
|
|
19
|
+
`;o.write(a);let i=s.echo?bp(n):null,c=m=>{o.write(m),i?.write(m)},d=Ep(e,[...t],{cwd:s.cwd,env:s.env,shell:s.shell,stdin:"ignore",stdout:"pipe",stderr:"pipe",buffer:!1,reject:!1});d.stdout?.on("data",c),d.stderr?.on("data",c);let u=await d;if(i?.end(),await new Promise(m=>o.end(m)),!u.failed)return;let h=await Ap(r,a.length),y=u.exitCode!==void 0?`${u.command} exited with code ${u.exitCode}`:u.signal?`${u.command} was stopped by ${u.signal}`:u.shortMessage;throw new P(s.code??"COMMAND_FAILED",[`${s.what} failed`,`${y}.${h.length>0?" Its last lines:":""}`,...h.map(m=>` ${m}`),`Full log: ${r}`].join(`
|
|
20
|
+
`),{...s.fix?{fix:s.fix}:{},data:{command:n,exitCode:u.exitCode??null,tail:h,log:r}})}function bp(e){let t=n=>process.stderr.write(`${wp.dim(` ${n}`)}
|
|
21
|
+
`);t(`$ ${e}`);let s="";return{write:n=>{let r=`${s}${n.toString("utf8")}`.split(/\r?\n/);s=r.pop()??"";for(let o of r)t(o)},end:()=>{s&&t(s),s=""}}}async function _p(e){let t=$s.join(yp.tmpdir(),"everyapp");await xo.mkdir(t,{recursive:!0,mode:448});let s=e.split(/\s+/).slice(0,2).map(r=>$s.basename(r).replace(/[^\w.-]+/g,"")).filter(Boolean).join("-")||"command",n=new Date().toISOString().replace(/[:.]/g,"-");return $s.join(t,`${s}-${n}-${process.pid}.log`)}async function Ap(e,t){return re((await xo.readFile(e,"utf8").catch(()=>"")).slice(t))}async function Sp(){try{return await kp("pnpm",["--version"],{stdio:"pipe"}),!0}catch{return!1}}async function dy({cwd:e,description:t,install:s,verbose:n=!1}){if(s===!1)return;let r=t.replace(/\.+$/,"");if(typeof s=="string"){await Ds(s,[],{cwd:e,shell:!0,echo:n,what:r,code:"INSTALL_FAILED"});return}let o=await Ms(e),{command:a,args:i}=await Ip(o);await Ds(a,i,{cwd:e,echo:n,what:`${r} with ${o}`,code:"INSTALL_FAILED"})}async function Ms(e){let t=await vp(e);return t||(await Ls(Nt.join(e,"pnpm-lock.yaml"))?"pnpm":await Ls(Nt.join(e,"yarn.lock"))?"yarn":await Ls(Nt.join(e,"package-lock.json"))?"npm":"pnpm")}async function vp(e){let t=Nt.join(e,"package.json");try{let n=JSON.parse(await Oo.readFile(t,"utf-8")).packageManager;return typeof n!="string"?null:n.startsWith("pnpm")?"pnpm":n.startsWith("yarn")?"yarn":n.startsWith("npm")?"npm":null}catch(s){if(ye(s))return null;throw s}}async function Ip(e){return e==="yarn"?{command:"yarn",args:["install"]}:e==="npm"?{command:"npm",args:["install"]}:await Sp()?{command:"pnpm",args:["install"]}:{command:"npx",args:["pnpm","install"]}}async function Ls(e){try{return await Oo.access(e),!0}catch(t){if(ye(t))return!1;throw t}}import{spawn as jp}from"node:child_process";import zp from"node:fs/promises";import $t from"node:path";import{createHash as Tp}from"node:crypto";import v from"node:fs/promises";import{rmSync as Pp}from"node:fs";import Gs from"node:os";import M from"node:path";var xp="cloudflare.config.ts",Ue=448,Co=18;async function No(){return js("neutral")}var $o="files-";async function Op(e){let t=await js("tmp");return await Cp(t),v.mkdtemp(M.join(t,`${e}${process.pid}-`))}async function Do(e){let t=await Op(e),s=Ao({sync:()=>Pp(t,{recursive:!0,force:!0})});return{dir:t,cleanup:async()=>{await v.rm(t,{recursive:!0,force:!0}),s()}}}var Rp=24*60*6e4;async function Cp(e){let t=Date.now()-Rp;for(let s of await v.readdir(e).catch(()=>[])){let n=Number(/-(\d+)-[^-]+$/.exec(s)?.[1]);if(n&&Np(n))continue;let r=M.join(e,s),o=await Go(r).catch(()=>null);o&&o.ctimeMs<t&&await v.rm(r,{recursive:!0,force:!0}).catch(()=>{})}}function Np(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}async function Lo(){if(process.platform==="win32")return M.dirname(process.execPath);let e=await js("bin"),t=M.join(e,Tp("sha256").update(process.execPath).digest("hex").slice(0,16));await Us(t);let s=M.join(t,"node");if(await v.readlink(s).catch(()=>null)!==process.execPath){await v.rm(s,{force:!0});try{await v.symlink(process.execPath,s)}catch(n){if(n.code!=="EEXIST")throw n}}return t}async function js(e){await $p();let t=M.join(Gs.homedir(),".everyapp");await Dp(t);let s=M.join(t,"cf");await Us(s);let n=M.join(s,e);return await Us(n),await Lp(n),n}async function $p(){let e=Number(process.env.SUDO_UID);if(process.getuid?.()!==0||!Number.isInteger(e)||e===0)return;if((await v.stat(Gs.homedir()).catch(()=>null))?.uid===e)throw new P("UNSAFE_CF_DIRECTORY",`everyapp is running as root (sudo) with your HOME
|
|
22
|
+
It would leave ~/.everyapp in ${Gs.homedir()} to root.`,{fix:"run it without sudo"})}async function Dp(e){let t;try{t=await v.stat(e)}catch(n){if(!ye(n))throw n;await v.mkdir(e,{recursive:!0,mode:Ue});return}if(!t.isDirectory())throw Ge(e,"isn't a directory");let s=Mo(t);if(s){if(t.uid!==process.getuid?.()||!(t.mode&Co))throw Ge(e,s);for(let n of await v.readdir(e))if((await v.lstat(M.join(e,n))).uid!==t.uid)throw Ge(e,`${s}, and ${n} in it belongs to another user`);await v.chmod(e,Ue)}}async function Us(e){try{let t=await Go(e);if(t&&Ro(t))return;t&&await v.rm(e,{recursive:!0,force:!0});try{await v.mkdir(e,{mode:Ue})}catch(n){if(n.code!=="EEXIST")throw n}if((await v.lstat(e)).isDirectory()&&await v.chmod(e,Ue),!Ro(await v.lstat(e)))throw Ge(e,"can't be made a private directory")}catch(t){throw t instanceof P?t:Ge(e,`can't be made a private directory (${t.message}; was everyapp run with sudo?)`)}}function Ro(e){if(!e.isDirectory())return!1;let t=process.getuid?.();return t===void 0?!0:e.uid===t&&(e.mode&511)===Ue}function Mo(e,{uid:t=process.getuid?.(),parent:s=!1}={}){return t===void 0?null:e.uid===t||e.uid===0||s&&t===0?e.mode&Co?"is writable by other users":null:"is owned by another user"}async function Lp(e){for(let t=await v.realpath(e);;t=M.dirname(t)){let s=Mo(await v.lstat(t),{parent:!0});if(s)throw new P("UNSAFE_CF_DIRECTORY",`${t} ${s}, so everyapp won't run cf below it
|
|
23
|
+
cf runs any cloudflare.config.ts it finds in a parent of its working directory (here ${e}).`,{fix:`make it writable only by you (chmod go-w "${t}"), or run everyapp with a HOME that is`});let n=M.join(t,xp);if(await Mp(n))throw new P("UNSAFE_CF_DIRECTORY",`cf would run ${n} in every command everyapp starts
|
|
24
|
+
cf loads a cloudflare.config.ts from any parent of its working directory (here ${e}).`,{fix:"move that file into a project directory",rerun:x()});if(M.dirname(t)===t)return}}function Ge(e,t){return new P("UNSAFE_CF_DIRECTORY",`${e} ${t}
|
|
25
|
+
everyapp runs cf and keeps the files it hands to cf (secrets among them) there, so only you may be able to write to it.`,{fix:"fix or remove it",rerun:x()})}async function Go(e){try{return await v.lstat(e)}catch(t){if(ye(t))return null;throw t}}async function Mp(e){try{return(await v.stat(e)).isFile()}catch{return!1}}import{execa as Gp}from"execa";var Up=6e4;function zs(e){return e[0]==="build"||e[0]==="dev"}async function Ks(e,t){let s=["node","-p","process.versions.node"],n,r;try{n=await Ms(e);let o=n==="yarn"?s:n==="npm"?["exec","--",...s]:["exec",...s],{stdout:a}=await Gp(n,o,{cwd:e,env:t,extendEnv:!1,stdin:"ignore",timeout:Up});r=a.trim().split(`
|
|
26
|
+
`).at(-1)?.trim()??""}catch{return}if(!(!/^\d+\.\d+\.\d+$/.test(r)||Ns(r)))throw new P("NODE_TOO_OLD",`${n} runs this project's tools on Node.js ${r}; cf needs ${ge} or newer
|
|
27
|
+
everyapp runs on ${process.versions.node}, but something pins this project's (a Volta \`volta.node\` in package.json, pnpm's use-node-version). cf needs ${ge} or newer to load cloudflare.config.ts.`,{fix:"raise the pin (`volta pin node@22`, for Volta)",rerun:x()})}var Kp=12e4,Hp=2e3;function Uy(e={}){let t=e.resolveBinary??To,s=e.env??process.env,n=e.watchdogIdleMs??Hp,r;async function o(a,i,c={}){let d={...s,CF_DELEGATION:"1",...i==="interactive"?{}:{NO_COLOR:"1"},...i==="json"?{CF_QUIET:"1"}:{},...e.accountId?{CLOUDFLARE_ACCOUNT_ID:e.accountId}:{},...a==="project"?{NODE_OPTIONS:ko(s.NODE_OPTIONS)}:{},...c};return r??=Lo(),Vp(d,await r)}return{async run(a){let i=await Bp(a),c=await t(a.plane==="project"&&!a.cliCf?i:void 0),d=a.files?await Fp(a.files):null;try{let u=typeof a.args=="function"?a.args(d?.paths??{}):[...a.args],h=await o(a.plane,a.mode,a.env);return a.plane==="project"&&zs(u)&&await Ks(i,h),await Yp({binary:c,args:u,cwd:i,env:h,onOutput:a.onOutput,mode:a.mode,timeoutMs:a.timeoutMs??(a.mode==="interactive"?void 0:Kp),watchdogIdleMs:a.local?n:void 0})}finally{await d?.remove()}},async start(a){let i=await t(a.cwd),c=await o("project","interactive",a.env);return zs(a.args)&&await Ks(a.cwd,c),fo({command:process.execPath,args:[i.path,...a.args],cwd:a.cwd,env:c,hold:a.holdOutput??!1})}}}async function Wp(e,t,s){let n=await e.run({...t,mode:"json"}),r=Uo(t.args),o;try{o=JSON.parse(n.stdout)}catch{throw new Z(r,"stdout is not JSON")}let a=s.safeParse(o);if(!a.success)throw new Z(r,a.error.message);return a.data}async function jy(e,t,s,{perPage:n,maxPages:r}){let o=[];for(let a=1;a<=r;a+=1){let i=await Wp(e,{plane:"account",args:[...t,"--per-page",String(n),"--page",String(a)]},s);if(o.push(...i),i.length<n)break}return o}async function Bp(e){if(e.plane==="project"){if(!e.cwd)throw new Error("project-plane cf calls need a cwd");return e.cwd}return No()}async function Fp(e){let{dir:t,cleanup:s}=await Do($o),n={};try{for(let[r,o]of Object.entries(e)){let a=$t.join(t,$t.basename(r));await zp.writeFile(a,typeof o=="string"?o:JSON.stringify(o),{mode:384}),n[r]=a}}catch(r){throw await s(),r}return{paths:n,remove:s}}function Yp(e){let t=Uo(e.args),s=e.mode==="interactive";return s&&It(),new Promise((n,r)=>{let o=jp(process.execPath,[e.binary.path,...e.args],{cwd:e.cwd,env:e.env,stdio:s?"inherit":["ignore","pipe","pipe"],detached:!s&&Q}),a=_o(o,!s&&Q),i="",c="",d=!1,u,h=A=>{d||(d=!0,a(),clearTimeout(m),clearTimeout(u),A())},y=e.timeoutMs,m=y===void 0?void 0:setTimeout(()=>{Pt(o,!s&&Q),h(()=>r(new me(t,y,re(c).at(-1)?.trim())))},y),l=()=>{e.watchdogIdleMs===void 0||d||!u&&!qp(i)||(clearTimeout(u),u=setTimeout(()=>{Pt(o,Q),h(()=>n({stdout:i,stderr:c,stoppedByWatchdog:!0}))},e.watchdogIdleMs))};for(let[A,w]of[[o.stdout,b=>i+=b],[o.stderr,b=>c+=b]])A?.on("data",b=>{w(b.toString()),e.onOutput?.(b.toString()),l()});o.once("error",A=>h(()=>r(A))),o.once("close",A=>{h(()=>{if(A===0){let b=po(t,c);b?r(b):n({stdout:i,stderr:c,stoppedByWatchdog:!1});return}let w=s?{message:`\`${t}\` exited with code ${A}`,apiCodes:[],kind:"unknown"}:uo(c,i);r(new W(w,{exitCode:A,stderr:c,stdout:i}))})})})}function Vp(e,t){let s=Object.keys(e).find(r=>r.toUpperCase()==="PATH")??"PATH",n=(e[s]??"").split($t.delimiter).filter(r=>r&&r!==t);return{...e,[s]:[t,...n].join($t.delimiter)}}function qp(e){let t=e.trim();if(!t)return!1;try{return JSON.parse(t),!0}catch{return!1}}function Uo(e){return typeof e=="function"?"cf":["cf",...e].join(" ")}function jo(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 Dt(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 Ky(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 Jp from"node:fs";var zo="EVERYAPP_EVENT_LOG",Hs;function Ws(){let e=process.env[zo];return e?(Hs?.path!==e&&(Hs={path:e,log:Xp(e)}),Hs.log):null}function Xp(e){let t=!1;return{append(s){if(!t)try{let n=`${JSON.stringify({...s,pid:process.pid})}
|
|
28
|
+
`;Jp.appendFileSync(e,n,{mode:384})}catch(n){t=!0;let r=n instanceof Error?n.message:String(n);process.stderr.write(`everyapp: can't write ${zo}=${e} (${r}); not logging
|
|
29
|
+
`)}}}}function By({argv:e,json:t}){Ws()?.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 Ko(e,t){Ws()?.append({v:1,ts:t.toISOString(),...e})}function Fy(e,t){Ws()?.append({type:"exit",ts:new Date().toISOString(),code:(e%256+256)%256,ms:t})}import{stripVTControlCharacters as Zp}from"node:util";import Ho from"chalk";var Bs=e=>Zp(e).length,Qp=(e,t)=>e+" ".repeat(t-Bs(e));function Wo(e){let t=Math.max(...e.map(s=>s.label.length));return e.map(s=>`${Ho.dim(s.label.padEnd(t))} ${s.value}`)}function Jy(e,t){let s=e.map((r,o)=>Math.max(Bs(r),...t.map(a=>Bs(a[o]??"")))),n=r=>r.map((o,a)=>a===r.length-1?o:Qp(o,s[a])).join(" ");return[Ho.dim(n(e)),...t.map(n)]}import g from"chalk";import Yo from"cli-cursor";function Zy(e){return(e?.public??[]).map(t=>Fo(t.path,t.methods))}function Qy(e){if(typeof e!="string")return[];try{let s=JSON.parse(e)?.public;return Array.isArray(s)?s.flatMap(n=>{let r=n?.path;if(typeof r!="string")return[];let o=n.methods;return[Fo(r,Array.isArray(o)?o.filter(a=>typeof a=="string"):void 0)]}):[]}catch{return[]}}function ew(e){return e?.mcp?{by:e.mcp.by,why:e.mcp.why}:null}function tw(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:r}=s;return n!=="gateway"&&n!=="app"||typeof r!="string"?null:{by:n,why:r}}catch{return null}}var sw=e=>`MCP /mcp (${e.by})`;function Bo(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 Fo(e,t){return{path:e,methods:(t??["GET"]).map(s=>s.toUpperCase())}}function ta(e=s=>process.stdout.write(s),t=()=>new Date){let s=na(n=>{let r=n.type==="done"?{...n,display:void 0}:n;e(`${JSON.stringify({v:1,ts:t().toISOString(),...r})}
|
|
30
|
+
`)},!1,()=>t().getTime());return Rs({stopping:n=>s.emit({type:"progress",step:"interrupt",message:n}),stopped:()=>{}}),s}function sa(e={}){let t=e.verbose??!1,s=e.terminal??!1,n=e.now??Date.now,r=n(),o=e.writeProblem??(l=>void process.stderr.write(l)),a=new Vs(e.write??(l=>void process.stdout.write(l)),s,e.columns??(()=>process.stdout.columns??80),n);s&&lo(()=>a.handOver()),Rs({stopping:l=>a.interrupt(`${l} (Ctrl+C again to quit at once)`),stopped:l=>{a.finish(),l&&o(`${g.dim(l)}
|
|
31
|
+
`)}});let i=l=>a.aside(()=>o(`${l.join(`
|
|
32
|
+
`)}
|
|
33
|
+
`)),c=new Map,d=new Set,u=[],h=0,y=0,m=(l,A)=>{for(let w of l)if("line"in w)a.lines(w.line);else if("fact"in w)u.splice(w.lead?y++:u.length,0,w.fact);else if("done"in w){let b=w.detail??(A!==void 0&&A>=1e3?Dt(A):"");a.lines([tu(w.done,b),...(w.notes??[]).map(k=>g.dim(` ${k}`))].join(`
|
|
34
|
+
`))}};return na(l=>{switch(l.type){case"step":{for(let k of d)k!==l.step&&(a.drop(k),d.delete(k),c.delete(k));let A=su[l.step]?.(l,k=>c.has(k)),w=A?[A].flat():[];if(l.status==="start"){c.set(l.step,n());let k=w.find(U=>"spin"in U);w.length===0&&t&&!s&&l.message&&a.lines(g.dim(l.message)),m(w),a.spin(l.step,k?k.spin:w.length>0?"":l.message??"");return}let b=c.get(l.step);c.delete(l.step),d.delete(l.step),a.stopSpinning(l.step),w.length>0?m(w,b===void 0?void 0:n()-b):t&&l.message&&a.lines(g.dim(l.message));return}case"progress":au.has(l.step)?a.lines(g.dim(l.message)):ou[l.step]?.(l.data??{})?(c.has(l.step)||c.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(nu.has(l.code)&&!t)return;h+=1,i([...Zo(g.yellow("!"),l.message),...Ys(l.data,{url:!0})]);return}case"action_required":{let[A="",...w]=l.message.split(`
|
|
35
|
+
`),b=[`${g.cyan("\u2192")} ${A}`,...l.data?.url?[` ${g.cyan(l.data.url)}`]:[],...l.data?.code?[` Code: ${g.bold(l.data.code)}`]:[],...w.map(k=>g.dim(` ${k}`))];if(l.data?.waiting){let k=l.step??l.action;a.lines(b.join(`
|
|
36
|
+
`)),c.set(k,n());let U=f(l.data.waitingFor);a.spin(k,U?`Waiting for ${U}`:"Waiting");return}a.finish(),o(`${[...b,...cu(l.data?.choices),...Ys(l.data)].join(`
|
|
37
|
+
`)}
|
|
38
|
+
`);return}case"error":{if(a.finish(),l.code==="CANCELLED"){o(`${g.dim(l.message)}
|
|
39
|
+
`);return}let A=t?f(l.data?.stack):void 0;o(`${[...Zo(g.red("\u2717"),l.message),...Ys(l.data,{url:!0}),...A?A.split(`
|
|
40
|
+
`).filter(w=>/^\s+at /.test(w)).map(w=>g.dim(` ${w.trim()}`)):[],...t?[g.dim(` Error code: ${l.code}`)]:[]].join(`
|
|
41
|
+
`)}
|
|
42
|
+
`);return}case"done":{a.finish();let A=n()-r,w=[...u,...du(l.data?.facts)],b=mu(l.data?.next),k=[...l.display!==void 0?l.display?[l.display]:[]:l.message?[g.green(l.message)]:[],...w.length>0?["",...Wo(w)]:[],...A>=1e4&&l.display===void 0?[g.dim(`Done in ${Dt(A)}${h>0?` with ${B(h,"warning")}`:""}`)]:[],...b.length>0?["","Next:",...fu(b)]:[]];k.length>0&&a.lines(k.join(`
|
|
43
|
+
`));return}}},t,n)}function ww(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 tu(e,t){return`${e} ${g.green("\u2713")}${t?` ${g.dim(t)}`:""}`}function Vo(e,t){return s=>s.status==="ok"?{done:e,detail:t}:null}function qo(e,t){return s=>s.status==="start"?{spin:e}:s.status==="ok"?{done:t}:null}function we(e){return e.status==="start"?{spin:e.message??""}:e.status==="ok"&&e.message?{done:e.message}:null}var su={"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 Every App in ${f(t.name)??f(t.id)}${s?g.dim(` (${s})`):""}`}},"setup.gateway":e=>{let t=e.data??{},s=f(t.releaseName),n=f(t.account),r=n?`${n}'s Gateway`:"the Gateway";if(e.status==="start"){let o=f(t.gatewayUrl)?.replace(/^https:\/\//,"");switch(t.change){case"install":{let a=pu(t.expectedMinutes);return{line:`Installing the Gateway at ${o} (${s})${a?g.dim(` (usually ${a.min}\u2013${a.max} minutes, then the owner link)`):""}`}}case"resume":return{line:`Resuming the Gateway install at ${o} (${s})`};case"upgrade":return{line:`Upgrading ${r} to ${s}`};case"repair":return{line:`Repairing ${r} (${s})`};case"redeploy":return{line:`Redeploying ${r} (${s})`};default:return null}}if(e.status==="ok"&&t.repaired===!0){let o=N(t.added);if(o.length>0)return{done:`Gateway now routes ${o.join(", ")}`};let a=Number(t.apps??0),i=Number(t.was??a);return{done:`Gateway routes ${B(a,"app")}`,detail:i!==a?`was ${i}`:""}}return e.status!=="skip"?null:t.upToDate===!0?{done:`${Fe(r)} 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&&N(e.data?.applied).length===0)return null;let r=Xo(e,s||n?"Database":"Gateway database");return n?Fs(r):r},"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")?Fs({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),r=f(t.origin);return{line:[`Deploying ${f(t.appId)}${s?` ${s}`:""} to ${f(t.gatewayHost)}${n?g.dim(` (${n})`):""}`,...r?[g.dim(` From ${r}`)]:[]].join(`
|
|
44
|
+
`)}},"app.register":e=>{let t=e.data??{};if(e.status!=="ok")return null;let s=uu(t.publicRoutes),n=lu(t.mcp),r=[...s.length>0?[{fact:{label:"Public",value:hu(s)}}]:[],...n?[{fact:{label:"MCP",value:`Serves /mcp on its own host (${n.by}): ${n.why}`}}]:[]];if(t.firstDeploy!==!0)return r.length>0?r:null;let o=f(t.organizationName),a=g.dim(`\xB7 change it at ${f(t.gatewayUrl)}/admin/apps`),i=t.scope==="shared"?`Members of every organization ${g.dim("(shared app)")}`:t.defaultAccess===!0?`Everyone${o?` in ${o}`:""} ${a}`:t.deployerAccess===!1?`Private to owners and admins ${a}`:`Private to you, owners and admins ${a}`,c=t.hasOwner===!1?`
|
|
45
|
+
${g.dim(`The Gateway has no owner yet; its first owner gets the app (${Mt} setup).`)}`:"";return[{fact:{label:"Who can open",value:`${i}${c}`}},...r]},"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":Vo("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"}:Xo(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":Jo,"gateway.lease":Jo,"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")?Fs({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=N(t.addresses),n=f(t.replyHint);return[...N(t.enabled).map(r=>({done:`Email Routing turned on for ${r}`})),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,"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 iu(t,s);if(e.status!=="ok")return null;let n={fact:{label:"Live",value:g.cyan(s)},lead:!0},r=f(t.waited);return r?[{done:r==="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=N(e.data?.kinds);return s.length>0?{done:`Deleted ${t}'s ${Gt(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:we(e),"setup.access":e=>{if(e.status!=="ok")return null;let t=e.data??{},s=Array.isArray(t.signInMethods)?t.signInMethods.map(o=>o.type):[],n=[...s.includes("cloudflare")?["a Cloudflare account"]:[],...s.includes("onetimepin")?["a one-time PIN"]:[]],r=N(t.signIn?.pending);return{done:"Cloudflare Access on",detail:n.length>0?`sign-in with ${n.join(" or ")}`:void 0,notes:r.length>0?[`${Gt(r)} ${r.length===1?"signs":"sign"} in once with ${r.length===1?"their":"their own"} password; Access asks them to sign in first.`]:[]}},"secrets.app":we,"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":we,"create.skill":we,"create.install":qo("Installing dependencies...","Installed dependencies"),"create.types":qo("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":Vo("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=N(e.data?.applied);return{done:t.length?`${B(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=N(e.data?.applied);return{done:"Set up the local database",...t.length?{detail:B(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=N(e.data?.applied);return t.length?{done:`${B(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":we,"teardown.inventory":e=>e.status==="start"?{spin:e.message??""}:null,"teardown.plan":e=>e.status==="ok"?{done:e.message??"",notes:N(e.data?.lines)}:null,"teardown.delete":we,"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 ${N(t.migrations).join(", ")}`}}},nu=new Set(["CUSTOM_DOMAIN_OWNER_UNCHECKED"]);function Jo(e){return e.status==="ok"?{done:`Other ${f(e.data?.waitedFor)??"run"} finished`}:null}var je=()=>!0,ru=e=>e.host===void 0,ou={"app.release":je,"app.lease":je,"gateway.lease":je,"db.lease":je,"app.live":je,"gateway.tls":ru},au=new Set(["dev.mcp","dev.session"]);function Xo(e,t){if(e.status!=="ok")return null;let s=e.data??{},n=N(s.applied);if(n.length===0)return{done:`${t} up to date`};if(s.fresh===!0)return{done:`${t} created`,detail:B(n.length,"migration")};let r=f(s.restoreCommand);return{done:`${t} migrated`,detail:n.join(", "),notes:r?[`Restore point saved. To undo: ${r}`]:[]}}function Fs(e){return!e||!("done"in e)?e:{...e,done:` ${e.done}`,...e.notes?{notes:e.notes.map(t=>` ${t}`)}:{}}}function iu(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 Zo(e,t){let[s="",...n]=t.split(`
|
|
46
|
+
`);return[`${e} ${s}`,...n.map(r=>g.dim(` ${r}`))]}function Ys(e,{url:t=!1}={}){let s=f(e?.didYouMean),n=f(e?.usage),r=f(e?.fix),o=t?f(e?.url):void 0,a=f(e?.rerun)??f(e?.help),i=f(e?.rerunNote);return[...s?[` Did you mean ${g.bold(s)}?`]:[],...n?[g.dim(` Usage: ${n}`)]:[],...r?[` Fix: ${r}`]:[],...o?[` ${g.cyan(o)}`]:[],...a?[` ${e?.authorize===!0?"To go ahead anyway":"Run"}: ${g.bold(a)}${i?` ${g.dim(i)}`:""}`]:[]]}function cu(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 du(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 pu(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 uu(e){return Array.isArray(e)?e.map(t=>t):[]}function lu(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 hu(e){let{shown:t,more:s}=Bo(e);return`Open to the internet without sign-in: ${t}${s>0?g.dim(` \u2026 and ${s} more (everyapp.config.ts public)`):""}`}function mu(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{command:t}:t):[]}function fu(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 Qo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],gu=80,ea=3e4,Vs=class{constructor(t,s,n,r){this.write=t;this.terminal=s;this.columns=n;this.now=r}steps=[];frame=0;timer;drawn=!1;lines(t){this.erase(),this.write(`${t}
|
|
47
|
+
`),this.draw()}spin(t,s){let n=this.steps.find(r=>r.step===t);if(n?n.label=s:this.steps.push({step:t,label:s,since:this.now()}),!this.terminal){this.keepAlive();return}this.timer||(Yo.hide(process.stdout),this.timer=setInterval(()=>{this.frame=(this.frame+1)%Qo.length,this.draw()},gu),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)}
|
|
48
|
+
`)}settle(){this.steps.length===0&&this.stopTimer(),this.draw()}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0,this.terminal&&Yo.show(process.stdout))}keepAlive(){this.timer||(this.timer=setInterval(()=>{let t=this.steps.findLast(r=>r.label);if(!t)return;let s=this.now()-t.since;if(s<ea)return;let n=t.label.replace(/\.{3}$|…$/,"");this.write(`${g.dim(`still ${n.charAt(0).toLowerCase()}${n.slice(1)} \xB7 ${jo(s)}`)}
|
|
49
|
+
`)},ea),this.timer.unref())}erase(){this.drawn&&(this.write("\r\x1B[2K"),this.drawn=!1)}draw(){if(!this.terminal)return;let t=this.steps.findLast(o=>o.label)??this.steps.at(-1);if(!t){this.erase();return}let s=this.now()-t.since,n=`${t.label?`${t.label} `:""}${s>=5e3?`\xB7 ${Dt(s)} `:""}${Qo[this.frame]}`,r=Math.max(this.columns()-1,10);this.write(`\r\x1B[2K${g.dim(n.length>r?`\u2026${n.slice(n.length-r+1)}`:n)}`),this.drawn=!0}};function na(e,t,s){let n=s(),r=new Set,o=!1,a=!1,i=!1;return{emit(c){let d=c;if(d.type==="warning"){let u=`${d.code}
|
|
50
|
+
${d.message}`;if(r.has(u))return;r.add(u)}else d.type==="done"&&(d={...d,data:{...d.data,durationMs:s()-n}});d.type==="error"?o=!0:d.type==="action_required"?d.data?.waiting?i=!0:a=!0:d.type==="done"&&(i=!1),e(d),Ko(d.type==="done"?{...d,display:void 0}:d,new Date(s()))},get exitCode(){return o?1:a||i?2:0},verbose:t}}var ra;function oa(e){ra=e,process.exitCode=e}function bw(){return ra}var yu="https://dash.cloudflare.com/?to=/:account/workers/plans",wu="https://dash.cloudflare.com/profile",Eu=new Set(["ECONNREFUSED","ECONNRESET","ENOTFOUND","EAI_AGAIN","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]);function ia(e,t,s){let n=co(t),r=h=>n?`${h}
|
|
51
|
+
The database stays migrated. To roll it back: ${n.restoreCommand}`:h,o=n?{rollbackCommand:n.rollbackCommand}:{},a=s?{step:s}:{},i=(h,y,m)=>e.emit({type:"action_required",action:h,message:r(y),...a,data:{...m,...o}}),c=(h,y,m,l)=>e.emit({type:"error",code:h,message:r(y),retryable:m,...a,data:{...l,...o}});if(t instanceof vt){i(t.action,t.message,{...t.data,...t.url?{url:t.url}:{},...t.rerun?{rerun:t.rerun}:{},...t.rerunNote?{rerunNote:t.rerunNote}:{}});return}if($e(t,"free_plan")){i("upgrade_workers_paid",`Cloudflare refused, for the Free plan: ${t.message}
|
|
52
|
+
Every App needs Workers Paid ($5 a month, then usage). Subscribe, then run this command again.`,{url:yu,rerun:x()});return}if(t instanceof P){c(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=bu(t);if(d){c(d.code,d.message,d.retryable,{...d.data,...d.retryable?{rerun:x()}:{}});return}let u=t instanceof Error?t:new Error(String(t));c("UNEXPECTED",`everyapp hit an unexpected error
|
|
53
|
+
${u.name}: ${u.message}
|
|
54
|
+
This is a bug in everyapp, not something you did.`,!1,{...u.stack?{stack:u.stack}:{},...e.verbose?{}:{rerun:x(["--verbose"]),rerunNote:"for a stack trace to report"}})}function bu(e){if(!(e instanceof Error))return null;if($e(e,"email_unverified"))return{code:"CF_EMAIL_UNVERIFIED",message:`Verify your Cloudflare account's email address first
|
|
55
|
+
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:wu,cloudflare:e.message}};if(e instanceof W)return{code:`CF_${e.kind.toUpperCase()}`,message:e.message,retryable:!1};if(e instanceof me)return{code:"CF_TIMEOUT",message:e.message,retryable:!0};if(e instanceof Z)return{code:"CF_OUTPUT",message:e.message,retryable:!1};if(e instanceof S)return{code:"INVALID_MANIFEST",message:e.message,retryable:!1};let t=aa(e)??aa(e.cause);return t&&Eu.has(t)?{code:"NETWORK_ERROR",message:`The network failed (${t})
|
|
56
|
+
${e.message}`,retryable:!0}:e instanceof TypeError&&e.message==="fetch failed"?{code:"NETWORK_ERROR",message:`The network failed
|
|
57
|
+
fetch failed`,retryable:!0}:t?{code:"SYSTEM_ERROR",message:e.message,retryable:!1}:null}function aa(e){let t=e?.code;return typeof e=="object"&&typeof t=="string"&&/^[A-Z_]+$/.test(t)?t:void 0}function _u(e,t){return e?ta():sa({verbose:t,terminal:ho()})}async function Au(e,t){try{await t()}catch(s){ia(e,s)}oa(e.exitCode)}async function Rw(e,t){let s=_u(e.json,e.verbose);await Au(s,()=>t(s))}export{vu as a,Iu as b,Mt as c,x as d,Tu as e,B as f,Fe as g,f as h,xu as i,re as j,Gt as k,N as l,bc as m,_c as n,Ac as o,Im as p,Ir as q,Tm as r,Pm as s,xm as t,ul as u,ll as v,Ma as w,hl as x,ml as y,An as z,kn as A,fl as B,C,D,j as E,Ut as F,G,cn as H,ha as I,Hu as J,Pr as K,Cm as L,Nm as M,fa as N,Fu as O,Yu as P,ba as Q,ln as R,mn as S,qu as T,Aa as U,Kt as V,Ju as W,Ye as X,Xu as Y,Zu as Z,ie as _,Ta as $,Ae as aa,F as ba,sl as ca,nl as da,wn as ea,En as fa,Ve as ga,al as ha,qe as ia,il as ja,_n as ka,cl as la,dl as ma,Sn as na,vn as oa,Fa as pa,Ya as qa,_l as ra,Al as sa,Ja as ta,Xa as ua,Rn as va,kl as wa,Cn as xa,Sl as ya,vl as za,Il as Aa,$n as Ba,Cl as Ca,Ze as Da,Ln as Ea,Nl as Fa,$l as Ga,Dl as Ha,Ml as Ia,Gl as Ja,Ul as Ka,jl as La,zl as Ma,Hl as Na,wi as Oa,at as Pa,Jt as Qa,ql as Ra,Zt as Sa,Zn as Ta,it as Ua,Xl as Va,Zl as Wa,Ql as Xa,eh as Ya,th as Za,sh as _a,nh as $a,rh as ab,ah as bb,ih as cb,ch as db,dh as eb,ph as fb,uh as gb,mh as hb,fh as ib,gh as jb,yh as kb,wh as lb,Eh as mb,Dc as nb,Fm as ob,Kc as pb,Bc as qb,Fi as rb,Ah as sb,zf as tb,Kf as ub,$r as vb,to as wb,$d as xb,S as yb,Vf as zb,qf as Ab,Jf as Bb,Xf as Cb,Lr as Db,jd as Eb,zd as Fb,oo as Gb,ks as Hb,Zf as Ib,Qf as Jb,eg as Kb,tg as Lb,sg as Mb,ng as Nb,Ss as Ob,Kd as Pb,rg as Qb,Mr as Rb,Wd as Sb,ag as Tb,P as Ub,vt as Vb,io as Wb,hg as Xb,mg as Yb,W as Zb,$e as _b,yg as $b,me as ac,fo as bc,It as cc,Eg as dc,xg as ec,Og as fc,Ao as gc,ko as hc,$g as ic,vo as jc,lp as kc,To as lc,fp as mc,Fg as nc,Yg as oc,ye as pc,Do as qc,Ds as rc,dy as sc,Uy as tc,Wp as uc,jy as vc,Zy as wc,Qy as xc,ew as yc,tw as zc,sw as Ac,Bo as Bc,jo as Cc,Dt as Dc,Ky as Ec,By as Fc,Fy as Gc,Wo as Hc,Jy as Ic,ww as Jc,tu as Kc,bw as Lc,ia as Mc,_u as Nc,Au as Oc,Rw as Pc};
|