everyapp 0.2.2 → 0.3.0-rc.2
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/LICENSE +21 -0
- package/README.md +6 -77
- package/bin/everyapp.js +235 -0
- package/dist/access-LGEN3ABJ.js +1 -0
- package/dist/activity-RSD4D66F.js +12 -0
- package/dist/apps-4RCFXT74.js +13 -0
- package/dist/chunk-23HJ5I2A.js +2 -0
- package/dist/chunk-2Y5Q6A5K.js +6 -0
- package/dist/chunk-4JRIS6S6.js +1 -0
- package/dist/chunk-5PTNYZK6.js +4 -0
- package/dist/chunk-6OGVO7QK.js +6 -0
- package/dist/chunk-6PGUCTJ6.js +11 -0
- package/dist/chunk-AGTCKFRB.js +22 -0
- package/dist/chunk-BHMRY53V.js +2 -0
- package/dist/chunk-CB4U7H2G.js +4 -0
- package/dist/chunk-CCWBPAKH.js +4 -0
- package/dist/chunk-CZTEDWZ2.js +22 -0
- package/dist/chunk-CZXHKPRZ.js +2 -0
- package/dist/chunk-E3EPK27P.js +10 -0
- package/dist/chunk-EGEWRFVY.js +1 -0
- package/dist/chunk-ELK7QZ2M.js +1 -0
- package/dist/chunk-FJJSSVET.js +33 -0
- package/dist/chunk-GKBPYVP3.js +25 -0
- package/dist/chunk-H6QQMY7B.js +18 -0
- package/dist/chunk-H7PDL3X5.js +1 -0
- package/dist/chunk-HOUHG236.js +20 -0
- package/dist/chunk-IFCPALVC.js +46 -0
- package/dist/chunk-IUOBIB5M.js +30 -0
- package/dist/chunk-J35DDCNU.js +1 -0
- package/dist/chunk-J455FAEN.js +7 -0
- package/dist/chunk-JYKRUS5C.js +1 -0
- package/dist/chunk-LXYMDZER.js +1 -0
- package/dist/chunk-LYNBZ7RV.js +57 -0
- package/dist/chunk-M2QQ2UD7.js +132 -0
- package/dist/chunk-N4E5YE4X.js +5 -0
- package/dist/chunk-N5GQLGEC.js +2 -0
- package/dist/chunk-NFU4YFXB.js +1 -0
- package/dist/chunk-OM2HDWVP.js +1 -0
- package/dist/chunk-ONLNJXVQ.js +32 -0
- package/dist/chunk-OP4DYXYI.js +2 -0
- package/dist/chunk-PNLU5U3P.js +1 -0
- package/dist/chunk-PS7S74DG.js +6 -0
- package/dist/chunk-RMF4YGD6.js +98 -0
- package/dist/chunk-T2GD7RHS.js +10 -0
- package/dist/chunk-TLRM3P7V.js +15 -0
- package/dist/chunk-W3JCQHHU.js +1 -0
- package/dist/chunk-WOVS3GV5.js +10 -0
- package/dist/chunk-YHJZMJYZ.js +1 -0
- package/dist/chunk-ZECBN24L.js +15 -0
- package/dist/chunk-ZEXVHB22.js +2 -0
- package/dist/chunk-ZFCUH5PK.js +7 -0
- package/dist/configure-F7UZCJUG.js +8 -0
- package/dist/create-2E5HVWYK.js +22 -0
- package/dist/db-HEQVTDTM.js +9 -0
- package/dist/delete-XCSIQIRS.js +3 -0
- package/dist/deploy-3QOZEZHC.js +1 -0
- package/dist/dev-JL3ZP5BT.js +86 -0
- package/dist/email-RLZFUFUN.js +10 -0
- package/dist/events-2V5VRBWP.js +15 -0
- package/dist/groups-HDG5DVFY.js +8 -0
- package/dist/index.js +97 -1
- package/dist/install-Z5FYXUYM.js +1 -0
- package/dist/login-KHJBC64Z.js +1 -0
- package/dist/mcp-EFDUKJ5V.js +1 -0
- package/dist/provider-EOI5PTFH.js +13 -0
- package/dist/release-74J5ZIL3.js +1 -0
- package/dist/restore-FFGYV7NO.js +3 -0
- package/dist/secret-7FKKTLHB.js +1 -0
- package/dist/setup-PAKRCAFO.js +1 -0
- package/dist/signin-AP3D4XM4.js +12 -0
- package/dist/status-RMWNHOEK.js +4 -0
- package/dist/teardown-E4JNKAZJ.js +22 -0
- package/dist/update-DWVZFNPS.js +1 -0
- package/dist/workspace-CJC5I66L.js +21 -0
- package/package.json +19 -16
- package/skills/build-every-app/SKILL.md +199 -0
- package/skills/build-every-app/patterns.md +140 -0
- package/skills/everyapp/SKILL.md +292 -0
- package/skills/everyapp/mcp.md +350 -0
- package/skills/everyapp/security-review.md +61 -0
- package/skills/everyapp/setup/README.md +274 -0
- package/skills/everyapp/setup/access.md +178 -0
- package/skills/everyapp/setup/context.md +117 -0
- package/skills/everyapp/setup/dataforseo.md +287 -0
- package/skills/everyapp/setup/email.md +366 -0
- package/skills/everyapp/setup/gateway.md +243 -0
- package/skills/everyapp/setup/google.md +360 -0
- package/skills/everyapp/setup/microsoft-365.md +281 -0
- package/skills/everyapp/setup/openai.md +318 -0
- package/skills/everyapp/setup/openrouter.md +309 -0
- package/skills/everyapp/setup/providers.md +1253 -0
- package/skills/everyapp/setup/remote-mcp.md +199 -0
- package/skills/everyapp/setup/signin-apple.md +178 -0
- package/skills/everyapp/setup/signin-cloudflare.md +148 -0
- package/skills/everyapp/setup/signin-github.md +139 -0
- package/skills/everyapp/setup/signin-google.md +178 -0
- package/skills/everyapp/setup/signin-microsoft.md +183 -0
- package/skills/everyapp/setup/signin-oidc.md +163 -0
- package/skills/everyapp/setup/slack.md +344 -0
- package/skills/everyapp/setup/workers-ai.md +138 -0
- package/bin/__everyapp_bash_complete.js +0 -12
- package/dist/bash-complete.js +0 -3
- package/dist/chunk-7BOQJFI5.js +0 -8
- package/dist/chunk-7YVJFS4A.js +0 -1
- package/dist/chunk-BIXKPCDH.js +0 -2
- package/dist/chunk-DLGPLHBH.js +0 -47
- package/dist/chunk-FD6K2YA7.js +0 -9
- package/dist/chunk-GAJEQYJH.js +0 -39
- package/dist/chunk-O2KDOP5R.js +0 -13
- package/dist/chunk-OI2MBGBG.js +0 -4
- package/dist/chunk-POSDLD3G.js +0 -8
- package/dist/chunk-RB5D2R45.js +0 -1
- package/dist/chunk-U4LIQ5VR.js +0 -1
- package/dist/chunk-VEYSNPDH.js +0 -3
- package/dist/chunk-VP6SKW44.js +0 -7
- package/dist/chunk-WO3NE7ZU.js +0 -7
- package/dist/chunk-XTO2VTPY.js +0 -6
- package/dist/chunk-YJ2DKIZS.js +0 -1
- package/dist/create-DYQ3NBWJ.js +0 -22
- package/dist/deploy-PYTCMDGV.js +0 -7
- package/dist/deploy-RMAHOA4Z.js +0 -55
- package/dist/dev-SAE237FS.js +0 -0
- package/dist/generateConfig-46Z3ERF3.js +0 -1
- package/dist/login-B6EF3SMX.js +0 -1
- package/dist/logout-XMKZBLNV.js +0 -1
- package/dist/remoteD1Shell-A67JMO3H.js +0 -6
- package/dist/setupLocal-TZJUW5ES.js +0 -6
- package/gateway/every-app-gateway-build.tar.gz +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var go=Object.defineProperty;var yo=(e,t,s)=>t in e?go(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var q=(e,t,s)=>(yo(e,typeof t!="symbol"?t+"":t,s),s);var ap="everyapp";var ip="0.3.0";var Ts={"@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 wo(e=process.env){let t=e.npm_config_user_agent?.split("/")[0];return t?Eo[t]??"everyapp":"everyapp"}var Eo={pnpm:"pnpm everyapp",npm:"npx everyapp",yarn:"yarn everyapp"},ht=wo();function T(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[ht,...n.map(bo)].join(" ")}function cp(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 T([],{argv:s})}function bo(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var K=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Oe=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`,h=e=>typeof e=="string"&&e.length>0?e:void 0,pp=e=>h(e)??null;function X(...e){return e.join(`
|
|
2
|
+
`).split(/\r?\n/).map(t=>t.trimEnd()).filter(t=>t.trim().length>0).slice(-20)}function mt(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var R=e=>Array.isArray(e)?e.map(String):[];var Ps={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 xs={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 Rs={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 Os={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"],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"],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"],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"],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"],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 Cs={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 Ns={...Ps,...xs,...Rs,...Os,...Cs};var x={openai:{mode:"ai",label:"OpenAI",description:"OpenAI's models: responses, chat, embeddings, audio, images.",auth:{kind:"bearer",secret:"OPENAI_API_KEY"},docs:"https://platform.openai.com/api-keys",api:"https://platform.openai.com/docs/api-reference",setup:"setup/openai.md",origin:"https://api.openai.com",inferenceRoutes:["/v1/responses","/v1/chat/completions","/v1/embeddings","/v1/audio/speech","/v1/audio/transcriptions","/v1/audio/translations","/v1/images/generations","/v1/images/edits","/v1/images/variations"],unstoredRoutes:["/v1/responses","/v1/chat/completions"],extraRoutes:!0,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"],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",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"}},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"]},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"]},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"]},"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"]},...Ns};function Z(e){let t=[e.secret];return e.kind==="basic"&&e.as==="password"&&typeof e.user=="object"&&t.push(e.user.secret),t}function O(e){switch(e.mode){case"api_key":return[...Z(e.auth),...e.hostSetting?[e.hostSetting]:[]];case"ai":return[e.auth.secret,...e.alsoNeeds??[]];case"service":return[...e.settings,...e.optionalSettings];case"oauth_client":return[e.secrets.clientId,...e.secrets.clientSecret?[e.secrets.clientSecret]:[],...e.hostSetting?[e.hostSetting]:[]]}}var D=Object.keys(x);function ft(e){return typeof e=="string"&&Object.hasOwn(x,e)}var Q={get:e=>ft(e)?x[e]:void 0,ids:()=>D};function $s(e){return e.ids().filter(t=>e.get(t)?.mode!=="ai")}function _o(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 Sp(e){return e.token.map(({host:t,path:s,methods:n})=>`${n.join("/")} https://${t??`<${e.hostSetting}>`}${Ao(s)}`).join(", ")}function Ao(e){return typeof e=="string"?e:e.source.replace(/^\^|\$$/g,"").replace(/v\\d\+\\\.\\d\+/g,"v<version>").replace(/\\(.)/g,"$1")}var Ds=["google","microsoft","github","apple","cloudflare","oidc"];function ko(e){return`/api/auth/callback/${e}`}function vp(e,t){return`${e.replace(/\/+$/,"")}${ko(t)}`}function ue(e,t){return`${e.toUpperCase()}_SIGNIN_${t}`}function ee(e,t){return[{name:ue(e,"CLIENT_ID"),role:"clientId",required:!0,plain:!0,what:t.clientId},{name:ue(e,"CLIENT_SECRET"),role:"clientSecret",required:!0,plain:!1,what:t.clientSecret}]}var gt=["openid","email","profile"],So={google:{id:"google",label:"Google",console:"https://console.cloud.google.com/apis/credentials",appNoun:"OAuth client ID (Web application)",settings:ee("google",{clientId:"The OAuth client's Client ID (ends in .apps.googleusercontent.com)",clientSecret:"The OAuth client's Client secret"}),scopes:gt,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:[...ee("microsoft",{clientId:"The app registration's Application (client) ID",clientSecret:"A client secret from Certificates & secrets (it expires; 24 months at most)"}),{name:ue("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:gt,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:ee("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:ee("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:ee("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:ue("oidc","ISSUER"),role:"issuer",required:!0,plain:!0,what:"The issuer URL (https://\u2026), which serves /.well-known/openid-configuration"},...ee("oidc",{clientId:"The client ID",clientSecret:"The client secret"}),{name:ue("oidc","LABEL"),role:"label",required:!1,plain:!0,what:'The button text after "Continue with" (default "SSO")'}],scopes:gt,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, Entra ID, Google Workspace as an OIDC issuer, Keycloak, Auth0 and the like.","ID tokens must be signed with RS256 (every major provider's default)."]}},yt=Ds.map(e=>So[e]);function Tp(e){return Ds.includes(e)}var Ls=yt.flatMap(e=>e.settings.map(t=>t.name)),Ms=yt.flatMap(e=>e.settings.filter(t=>t.plain).map(t=>t.name)),Io=/^[A-Z][A-Z0-9_]*_SIGNIN_(CLIENT_ID|CLIENT_SECRET|ISSUER|LABEL|TENANT)$/;function Ce(e){return Io.test(e)}function Pp(e){for(let t of yt)if(t.settings.some(s=>s.name===e))return t;return null}function xp(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:n,set:s}}var vo=["GATEWAY_URL","APP_BASE_DOMAIN","BETTER_AUTH_SECRET","JWT_PRIVATE_KEY","JWT_PUBLIC_KEY","GATEWAY_DEPLOYMENT_MODE","CLOUDFLARE_ACCOUNT_ID","THIRD_PARTY_DEPLOYS"],Gs=new Set(vo);function le(e){return Gs.has(e)}var To=[...new Set(D.flatMap(e=>{let t=x[e];return t.mode==="service"?[]:O(t)}))].filter(e=>!Gs.has(e)),Po=["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"],xo=[...To,...Po,...Ls],Ro=new Set(xo),Oo=/^[A-Z][A-Z0-9_]*_MCP_TOKEN$/;function he(e){return Oo.test(e)}function H(e){return Ro.has(e)||he(e)}var Co=["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"],No=new Set([...Co,...Ms]);function Np(e){return No.has(e)}var $o=["HOSTED_OPEN_SIGNUP","DISPATCH_NAMESPACE","THIRD_PARTY_DOMAIN"],Do=new Set($o);function $p(e){return Do.has(e)}var Lo=["MCP_ACCESS_TOKEN_TTL","DATAFORSEO_SANDBOX"];function js(e){return Lo.includes(e)}var Mo=new Set(["GATEWAY_URL","CF_VERSION_METADATA"]),Go=["EVERYAPP_","EVERY_APP_","APP__"],Us="GATEWAY_URL, CF_VERSION_METADATA and the EVERYAPP_*, EVERY_APP_* and APP__* names";function Ne(e){let t=e.toUpperCase();return Mo.has(t)||Go.some(s=>t.startsWith(s))}function Ks(e){for(let t of D){let s=x[t];if(O(s).includes(e))return{kind:s.mode==="ai"?"provider":"capability",id:t}}return null}var Mp="provider",$e={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"}},Gp=Object.keys($e).sort();function Hs(e){return Object.hasOwn($e,e)}function jp(e){return Z(x[$e[e].capability].auth)[0]}function Up(e){let t=$e[e];return{id:t.id,name:t.name,description:t.description,capabilities:{[t.capability]:{access:"read",why:t.why}}}}var me="/__everyapp/tools",Hp=`${me}/list`,Wp=`${me}/call`,jo=["read","write","destructive"],zp="mcp:read",Bp="mcp:write";var Ws=/^[a-z][a-z0-9_]{0,47}$/;function zs(e){return typeof e=="string"&&jo.includes(e)}function Fp(e){return JSON.stringify(wt(e))}function wt(e){if(Array.isArray(e))return e.map(wt);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]=wt(n))}return t}var Bs=["none","bearer","header","basic","oauth"],Fs=["annotations","read","write"],qs=/^[a-z]([a-z0-9-]*[a-z0-9])?$/,Et=32,Uo=["everyapp"],Ko=64,Ho=/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$/,Wo=32,Xs=2048,zo=255,Bo=1e3,Ys=500,Fo=256,Yo=new Set(["authorization","cookie","host","content-type","content-length","accept","connection","transfer-encoding","mcp-session-id","mcp-protocol-version","mcp-method","mcp-name"]);function Vo(e){return`${e.toUpperCase().replace(/-/g,"_")}_MCP_TOKEN`}function Jo(e){return typeof e!="string"||!qs.test(e)?"the id must be kebab-case: lowercase letters, digits and hyphens, starting with a letter":e.length>Et?`the id must be at most ${Et} characters`:Uo.includes(e)?`"${e}" is reserved`:Hs(e)?`"${e}" is the Gateway's built-in MCP app; a remote server can't take its id`:null}function Zp(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,Et).replace(/-+$/g,"");return!a||!qs.test(a)||Jo(a)?null:a}function Vs(e,t){return e===t||e.endsWith(`.${t}`)}function qo(){let e=new Set(["api.openai.com","openrouter.ai","gateway.ai.cloudflare.com","api.cloudflare.com"]);for(let t of Object.values(x))if(t.mode==="api_key")for(let s of t.hosts)e.add(s);else if(t.mode==="oauth_client")for(let s of t.token)"host"in s&&typeof s.host=="string"&&e.add(s.host);return[...e].sort()}function Qp(e,t){if(typeof e!="string"||!e.trim())return"give the server's URL";if(e.length>Xs)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:Vs(r,a)))return"the URL is this Gateway's own address";for(let c of[t.appBaseDomain,t.thirdPartyDomain]){let p=(c??"").trim().toLowerCase().replace(/\.$/,"");if(p&&Vs(r,p))return`the URL is on this Gateway's app domain (${p})`}return qo().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 te(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Xo(e){return typeof e!="string"||!e?"give the credential's setting name":e.length>Ko?"the credential's name is too long":he(e)?null:`the credential's name must end in _MCP_TOKEN (letters, digits and underscores), like ${Vo("treg")}`}function Zo(e){if(!te(e)||typeof e.kind!="string")return{ok:!1,problem:"auth must name a kind"};let t=e.kind;if(!Bs.includes(t))return{ok:!1,problem:`auth.kind must be one of ${Bs.join(", ")}`};if(t==="none"||t==="oauth")return{ok:!0,auth:{kind:t}};let s=Xo(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"||!Ho.test(r))return{ok:!1,problem:"auth.header must be an HTTP header name"};if(Yo.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>Wo||/[\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 Qo(e){if(!te(e))return{ok:!1,problem:"remote must be an object"};let t=e.url;if(typeof t!="string"||!t||t.length>Xs)return{ok:!1,problem:"remote.url must be a URL"};let s=Zo(e.auth);if(!s.ok)return s;let n=e.risk??"annotations";if(!Fs.includes(n))return{ok:!1,problem:`remote.risk must be one of ${Fs.join(", ")}`};let r={},o=e.tools??{};if(!te(o))return{ok:!1,problem:"remote.tools must be an object"};let a=Object.entries(o);if(a.length>Ys)return{ok:!1,problem:`remote.tools has more than ${Ys} entries`};for(let[c,p]of a){if(!c||c.length>Fo)return{ok:!1,problem:"remote.tools has a tool name that is empty or too long"};if(!te(p))return{ok:!1,problem:`remote.tools.${c} must be an object`};let l={};if(p.risk!==void 0){if(!zs(p.risk))return{ok:!1,problem:`remote.tools.${c}.risk must be read, write or destructive`};l.risk=p.risk}if(p.enabled!==void 0){if(typeof p.enabled!="boolean")return{ok:!1,problem:`remote.tools.${c}.enabled must be true or false`};l.enabled=p.enabled}r[c]=l}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 Zs(e){if(!te(e)||e.remote===void 0)return null;let t=Qo(e.remote);return t.ok?t.block:null}function eu(e){return te(e)&&e.remote!==void 0}function Qs(e){return"secret"in e?e.secret:null}function ea(e,t){let s="";try{s=new URL(t).origin}catch{s=""}return`${e}'s MCP server${s?` at ${s}`:""}, served to your AI clients through this Gateway.`}function en(e,t){let s=e.tools[t];if(s)return s;let n=Js(t);if(n){for(let[r,o]of Object.entries(e.tools))if(Js(r)===n)return o}}function tu(e){let t=(e.name??"").trim().slice(0,zo)||e.id,s=(e.description??"").trim().slice(0,Bo)||ea(t,e.remote.url);return{id:e.id,name:t,description:s,remote:e.remote}}function su(e,t,s){let n=en(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 nu(e,t){return en(e,t)?.enabled!==!1}function Js(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,""),Ws.test(t)?t:null):null}function tn(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 ta(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 _t(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 De(e){return(e.providers??[]).flatMap(t=>typeof t=="string"?[{id:t}]:t&&typeof t=="object"&&typeof t.id=="string"?[{id:t.id,..._t(t)}]:[])}function cu(e){return De(e).map(t=>t.id)}function Le(e){return(e.secrets??[]).flatMap(t=>typeof t=="string"?[{name:t}]:t&&typeof t=="object"&&typeof t.name=="string"?[{name:t.name,..._t(t)}]:[])}function nn(e){return Le(e).map(t=>t.name)}function rn(e){return O(e).filter(t=>!le(t))}function sa(e){let t=s=>s.filter(n=>H(n)&&!le(n));switch(e.mode){case"api_key":return{names:[...O(e)],alsoReads:[]};case"ai":return{names:rn(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 na(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 sn(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 bt(e,t,s={}){let n=t?.docs??s.docs,r=e.holder==="gateway"?s.setup:t?.setup;return{...e,need:ta(t),...t?.why?{why:t.why}:{},...n?{docs:n}:{},...r?{setup:r}:{},...s.hint?{hint:s.hint}:{}}}function du(e,t=Q){let s=[];for(let r of De(e)){let o=t.get(r.id);if(o?.mode!=="ai")continue;let a=rn(o);s.push(bt({kind:"provider",id:r.id,label:o.label,holder:"gateway",names:a,alsoReads:[]},r,{docs:o.docs,setup:o.setup,...sn(o,a)}))}for(let[r,o]of Object.entries(e.capabilities??{})){let a=t.get(r);if(!a||a.mode==="ai")continue;let{names:i,alsoReads:c}=sa(a);s.push(bt({kind:"capability",id:r,label:a.label,holder:"gateway",names:i,alsoReads:c},_t(o),{docs:na(a),setup:a.setup,...sn(a,i)}))}e.ai?.routes?.length&&s.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 n=Zs(e);if(n){let r=Qs(n.auth);if(r){let o=typeof e.name=="string"&&e.name.trim()?e.name.trim():"the MCP server";s.push({kind:"remote-mcp",id:r,label:`${o} credential`,holder:"gateway",names:[r],alsoReads:[],need:{kind:"required"},why:`What ${o} expects: ${tn(n.auth)}. The Gateway sends it to ${n.url} and nowhere else.`,setup:"setup/remote-mcp.md"})}}for(let r of Le(e))s.push(bt({kind:"secret",id:r.name,label:r.name,holder:"app",names:[r.name],alsoReads:[]},r));return s}function ra(e,t){let s=!1;for(let n of e.names){let r=t(e.holder,n);if(r===!1)return!1;r===null&&(s=!0)}return s?null:!0}function pu(e,t,s={}){let n=e.map(a=>{let i=s.readiness?.(a);return{...a,set:i===void 0?ra(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(p=>p.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 oa(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 uu(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:oa(e,t)}}var hu=["cloudflare","resend"];var Me={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},aa=/^(\*|[a-z0-9._+-]+)@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z][a-z0-9-]*[a-z0-9]$/,ia=/^(\*|[a-z0-9._+-]+)@([a-z0-9-]+\.)+[a-z]{2,}$/,At="everyapp email set";function mu(e,t){let s=[],n=e==="senders"?Me.senders:Me.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>Me.inboundAddressChars?s.push(`${r} is longer than Email Routing's ${Me.inboundAddressChars} characters.`):(e==="senders"?aa:ia).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 fu(e){return e.length===0?null:JSON.stringify(e)}function gu(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 yu(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 Eu(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 St=/^[a-z][a-z0-9-]{1,39}$/,ca=/^[A-Z][A-Z0-9_]{2,63}$/,da=/^(?=.{1,253}$)(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/,kt=["GET","HEAD","POST","PUT","PATCH","DELETE"],pa=/^[a-z0-9_-]{1,64}$/,ua=/^[A-Za-z0-9-]{1,64}$/,la=/^[A-Za-z0-9_.-]{1,64}$/,ha=/^[A-Za-z][A-Za-z0-9-]{0,31}$/,ma=/^[A-Za-z_][A-Za-z0-9_]{0,63}(?:\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/,fa=/^\d{4}-\d{2}-\d{2}$/,ga=/^[a-z][a-z0-9-]{0,31}$/,ya=/[\p{Cc}\p{Cf}]/u,wa=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"]),Ea=20,on=50,ba=new Set(["id","mode","name","description","docs","api","hosts","hostSetting","data","auth","secrets","access","readMethods","writeMethods","accountWidePaths","hint","smoke","cost","rate","example","verified","tags"]);function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(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(ya.test(e)){s.push({path:t,message:"holds a control character"});return}return e}}function an(e,t,s){let n=v(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 Ge(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 cn(e,t,s){return Ge(e,t,s,{max:kt.length,each:(n,r)=>{kt.includes(n)||s.push({path:r,message:`must be one of ${kt.join(", ")}`})}})}function Ue(e,t,s){if(typeof e!="string"||!ca.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 _a(e,t){if(!M(e)){t.push({path:"auth",message:"must be an object with a kind: bearer, header, query or basic"});return}let s=e.kind,n=Ue(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=v(e.scheme,"auth.scheme",t,{max:32});return o!==void 0&&!ha.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=v(e.header,"auth.header",t,{max:64});o!==void 0&&(ua.test(o)?(wa.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=v(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=v(e.param,"auth.param",t,{max:64});return o!==void 0&&!la.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=v(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(M(a)&&Object.keys(a).join()==="secret"){let c=Ue(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 or basic (an OAuth client or an AI provider is a catalog entry, not a spec this gateway takes)"});return}}function Aa(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(!M(r)){s.push({path:a,message:"must be an object"});return}for(let p of Object.keys(r))["name","hint"].includes(p)||s.push({path:`${a}.${p}`,message:"unknown field"});let i=Ue(r.name,`${a}.name`,s);i!==void 0&&!t.includes(i)&&s.push({path:`${a}.name`,message:`auth names no setting ${i}`});let c=v(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 ka(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>on){t.push({path:"accountWidePaths",message:`at most ${on} 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"||!pa.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 Sa(e,t,s){if(e===void 0)return;if(!M(e)){s.push({path:"smoke",message:"must be an object"});return}for(let l of Object.keys(e))["method","host","path","expect","free","note"].includes(l)||s.push({path:`smoke.${l}`,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=v(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=v(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(l=>Number.isInteger(l)&&l>=100&&l<=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 p=v(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,...p===void 0?{}:{note:p}}}function je(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 Ia(e,t){if(e===void 0)return;if(!M(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=je(e.usd,"cost.usd",t),r=v(e.note,"cost.note",t,{max:200}),o=v(e.responseField,"cost.responseField",t,{max:128});if(o!==void 0&&!ma.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 va(e,t){if(e===void 0)return;if(!M(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=je(e.perSecond,"rate.perSecond",t),n=je(e.perMinute,"rate.perMinute",t),r=je(e.perDay,"rate.perDay",t),o=v(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 Ta(e,t){if(e!==void 0){if(e===!1)return!1;if(M(e)&&typeof e.on=="string"&&fa.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 It(e){let t=[];if(!M(e))return{ok:!1,problems:[{path:"(root)",message:"must be a JSON object"}]};for(let $ of Object.keys(e))ba.has($)||t.push({path:$,message:"unknown field"});let s=e.id;(typeof s!="string"||!St.test(s))&&t.push({path:"id",message:"must be lowercase letters, digits and hyphens, a letter first, 2 to 40 characters (stripe)"}),e.mode!==void 0&&e.mode!=="api_key"&&t.push({path:"mode",message:"this gateway registers api_key providers; an AI provider or an OAuth client is a catalog entry"});let n=v(e.name,"name",t,{max:64});e.name===void 0&&t.push({path:"name",message:"required"});let r=v(e.description,"description",t,{max:200}),o=an(e.docs,"docs",t);e.docs===void 0&&t.push({path:"docs",message:"required: where the person gets the key, an https URL"});let a=an(e.api,"api",t),i=Ge(e.hosts,"hosts",t,{max:Ea,each:($,pe)=>{da.test($)||t.push({path:pe,message:"must be a bare lowercase host with a dot and no port, path or scheme (api.stripe.com)"})}}),c=e.hostSetting===void 0?void 0:Ue(e.hostSetting,"hostSetting",t);c===void 0&&(e.hosts===void 0||i&&i.length===0)&&t.push({path:"hosts",message:"required: at least one host, or a hostSetting naming one"});let p=e.data;p!==void 0&&p!=="per-call"&&p!=="account"&&t.push({path:"data",message:"must be per-call or account"});let l=p==="per-call"||p==="account"?p:void 0,f=_a(e.auth,t);e.auth===void 0&&t.push({path:"auth",message:"required"}),c!==void 0&&f&&Z(f).includes(c)&&t.push({path:"hostSetting",message:"must be another setting than the key"});let w=Aa(e.secrets,[...f?Z(f):[],...c===void 0?[]:[c]],t),_=Ge(e.access,"access",t,{max:2,each:($,pe)=>{$!=="read"&&$!=="write"&&t.push({path:pe,message:"must be read or write"})}});_&&_.length===0&&t.push({path:"access",message:"must list read, write or both"});let u=cn(e.readMethods,"readMethods",t);u&&u.length===0&&(!Array.isArray(_)||_.includes("read"))&&t.push({path:"readMethods",message:"must list a method unless access is write alone"});let E=cn(e.writeMethods,"writeMethods",t),g=ka(e.accountWidePaths,t),b=v(e.hint,"hint",t,{max:500}),k=Sa(e.smoke,i??[],t),U=Ia(e.cost,t),ks=va(e.rate,t),Ss=v(e.example,"example",t,{max:200}),Is=Ta(e.verified,t),vs=Ge(e.tags,"tags",t,{max:10,each:($,pe)=>{ga.test($)||t.push({path:pe,message:"must be a lowercase word"})}});if(t.length>0||typeof s!="string"||n===void 0||o===void 0||!i&&c===void 0||!f)return{ok:!1,problems:t};let fo={mode:"api_key",label:n,auth:f,docs:o,hosts:i??[],...c===void 0?{}:{hostSetting:c},...l===void 0?{}:{data:l},access:_??["read"],readMethods:u??["GET","HEAD"],accountWidePaths:g??[],...r===void 0?{}:{description:r},...a===void 0?{}:{api:a},...w===void 0?{}:{secrets:w},...E===void 0?{}:{writeMethods:E},...b===void 0?{}:{hint:b},...k===void 0?{}:{smoke:k},...U===void 0?{}:{cost:U},...ks===void 0?{}:{rate:ks},...Ss===void 0?{}:{example:Ss},...Is===void 0?{}:{verified:Is},...vs===void 0?{}:{tags:vs}};return{ok:!0,id:s,capability:fo}}function vt(e){return e.map(t=>`${t.path}: ${t.message}`).join("; ")}function ku(e,t){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 Pa=".everyapp/providers";function vu(e){return`${Pa}/${e}.json`}var W=new TextEncoder,dn=new TextDecoder,xa=new TextDecoder("utf-8",{fatal:!0}),Pu=2**32;function pn(...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 Ra=/[^\x00-\x7f]/;function Ke(e){if(typeof e=="string"&&e.length>=128){if(Ra.test(e))throw new TypeError("non-ASCII string encountered in encode()");return W.encode(e)}let t=new Uint8Array(e.length);for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);if(n>127)throw new TypeError("non-ASCII string encountered in encode()");t[s]=n}return t}function Tt(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 He(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 z=class extends Error{code="ERR_JOSE_GENERIC";constructor(t,s){super(t,s),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};q(z,"code","ERR_JOSE_GENERIC");var P=class extends z{code="ERR_JOSE_NOT_SUPPORTED"};q(P,"code","ERR_JOSE_NOT_SUPPORTED");var C=class extends z{code="ERR_JWS_INVALID"};q(C,"code","ERR_JWS_INVALID");var fe=class extends z{code="ERR_JWT_INVALID"};q(fe,"code","ERR_JWT_INVALID");var Pt=class extends z{[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)}};q(Pt,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");var Oa="The input to be decoded is not correctly encoded.";function un(e){try{return He(typeof e=="string"?e:dn.decode(e),!0)}catch(t){throw new TypeError(Oa,{cause:t})}}function ge(e){return Tt(typeof e=="string"?W.encode(e):e,!0)}function ye(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 ln(...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 hn(e,t){if(e!==void 0)throw new TypeError(`${t} can only be called once`)}var mn={__proto__:null,b64:!0};function fn(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 gn(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 P(`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 yn(e,t){if(t.includes("b64")){let s=e.b64;if(typeof s!="boolean")throw new C('The "b64" (base64url-encode payload) Header Parameter must be a boolean');return s}return!0}function xt(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(!ye(n))throw new e("JOSE Header is not a JSON object");return[n,s]}var Ca=e=>e[Symbol.toStringTag],Na=(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 En(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(ye(t)){if(a=Ua(t),typeof a.kty!="string")throw wn(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(Na(e,a,s),a.kty==="oct")return un(a.k);if(!Object.isFrozen(t)){let{key_ops:l}=t;Array.isArray(l)&&Object.freeze(l),Object.freeze(t)}}else{if(!Da(t))throw wn(n,t,r);let l=r?"secret":o?"private":"public";if(t.type!==l&&(r||["secret","public","private"].includes(t.type)))throw new TypeError(`${Ca(t)} instances must be of type "${l}" for the ${n} algorithm`);if(Ot(t))return t;if(i=t,i.type==="secret")return i.export()}Rt||=new WeakMap;let c=t,p=Rt.get(c);if(p?.[n])return p[n];if(p||Rt.set(c,p={}),i&&typeof i.toCryptoKey=="function"){let l=i.type==="public",f=$a[i.asymmetricKeyDetails?.namedCurve],w=e.resolve?.({crv:f,asymmetricKeyType:i.asymmetricKeyType})??e.subtle;return p[n]=i.toCryptoKey(w,l,e.usages[l?0:1])}return a??=i.export({format:"jwk"}),a.alg=n,p[n]=await Ka(e,a)}var Rt,$a={__proto__:null,prime256v1:"P-256",secp384r1:"P-384",secp521r1:"P-521"};var Ot=e=>{if(e?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return e instanceof CryptoKey}catch{return!1}},bn=e=>e?.[Symbol.toStringTag]==="KeyObject",Da=e=>Ot(e)||bn(e);function La(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 wn(e,t,s){let n=["CryptoKey","KeyObject","JSON Web Key"];return s&&n.push("Uint8Array"),new TypeError(La(`Key for the ${e} algorithm must be `,t,...n))}var We=(e,t="algorithm.name")=>new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function Ma(e,t){if(t&&!e.usages.includes(t))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function _n(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 Ga(e,t,s){let n=e.algorithm;if(n.name!==t.name)throw We(t.name);if(t.hash&&n.hash?.name!==t.hash)throw We(t.hash,"algorithm.hash");if(t.namedCurve&&n.namedCurve!==t.namedCurve)throw We(t.namedCurve,"algorithm.namedCurve");if(t.length!==void 0&&n.length!==t.length)throw We(t.length,"algorithm.length");Ma(e,s)}function ja(e){return{__proto__:null,...e}}function Ua(e){let t=ja(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 An(e){if(e!==void 0&&typeof e!="boolean")throw new TypeError('"extractable" option must be a boolean');return e}async function Ka(e,t,s){if(!e.kty.includes(t.kty))throw new P('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 kn(e,t,s,n=!1){return e instanceof Uint8Array&&(e=await crypto.subtle.importKey("raw",e,t,n,[s])),Ga(e,t,s),e}function we(e){let t={__proto__:null};for(let s in e)t[s]={...e[s],alg:s};return t}var Ha=[["encrypt","wrapKey"],["decrypt","unwrapKey"]],Wa=[[],["deriveBits"]],Fe=[[],[]];function ze(e){return{kty:["RSA"],mode:"key-encryption",subtle:{name:"RSA-OAEP",hash:`SHA-${e}`},usages:Ha,ops:["wrapKey","unwrapKey"]}}function Be(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 P('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');return{name:"ECDH",namedCurve:s}},usages:Wa,ops:[void 0,"deriveBits"]}}function se(e,t=!1){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:t?"AES-GCM":"AES-KW",length:e},usages:Fe,ops:t?["encrypt","decrypt"]:["wrapKey","unwrapKey"]}}function Ct(){return{kty:["oct"],mode:"key-wrapping",secret:!0,subtle:{name:"PBKDF2"},usages:Fe,ops:["deriveBits","deriveBits"]}}var Sn=we({dir:{kty:["oct"],mode:"direct-encryption",secret:!0,subtle:{name:"AES-GCM"},usages:Fe,ops:["encrypt","decrypt"]},"RSA-OAEP":ze(1),"RSA-OAEP-256":ze(256),"RSA-OAEP-384":ze(384),"RSA-OAEP-512":ze(512),"ECDH-ES":Be("direct-key-agreement"),"ECDH-ES+A128KW":Be("key-agreement-with-key-wrapping"),"ECDH-ES+A192KW":Be("key-agreement-with-key-wrapping"),"ECDH-ES+A256KW":Be("key-agreement-with-key-wrapping"),A128KW:se(128),A192KW:se(192),A256KW:se(256),A128GCMKW:se(128,!0),A192GCMKW:se(192,!0),A256GCMKW:se(256,!0),"PBES2-HS256+A128KW":Ct(),"PBES2-HS384+A192KW":Ct(),"PBES2-HS512+A256KW":Ct()}),za=["encrypt","decrypt"];function ne(e,t=!1){return{kty:["oct"],secret:!0,subtle:{name:t?"AES-CBC":"AES-GCM",length:e},usages:Fe,ops:za,cekBits:e,ivBits:t?128:96,cbc:t}}var Wu=we({A128GCM:ne(128),A192GCM:ne(192),A256GCM:ne(256),"A128CBC-HS256":ne(256,!0),"A192CBC-HS384":ne(384,!0),"A256CBC-HS512":ne(512,!0)});var Ee=[["verify"],["sign"]];function Nt(e){let t={name:"HMAC",hash:`SHA-${e}`};return{kty:["oct"],secret:!0,subtle:t,signing:t,usages:Ee}}function re(e,t){let s={name:t?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:`SHA-${e}`};return{kty:["RSA"],subtle:s,signing:t?{...s,saltLength:t}:s,usages:Ee,minRsaBits:2048}}function $t(e,t){return{kty:["EC"],crv:e,subtle:{name:"ECDSA",namedCurve:e},signing:{name:"ECDSA",hash:`SHA-${t}`},usages:Ee}}function In(){let e={name:"Ed25519"};return{kty:["OKP"],crv:"Ed25519",subtle:e,signing:e,usages:Ee}}function Dt(e){let t={name:`ML-DSA-${e}`};return{kty:["AKP"],subtle:t,signing:t,usages:Ee}}var Lt=we({HS256:Nt(256),HS384:Nt(384),HS512:Nt(512),RS256:re(256),RS384:re(384),RS512:re(512),PS256:re(256,32),PS384:re(384,48),PS512:re(512,64),ES256:$t("P-256",256),ES384:$t("P-384",384),ES512:$t("P-521",512),EdDSA:In(),Ed25519:In(),"ML-DSA-44":Dt(44),"ML-DSA-65":Dt(65),"ML-DSA-87":Dt(87)});function vn(e){let t=typeof e=="string"?Lt[e]:void 0;if(!t)throw new P(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}var Ye=e=>Math.floor(e.getTime()/1e3),Ba={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},Fa=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Mt(){throw new TypeError("Invalid time period format")}function Tn(e){typeof e!="string"&&Mt();let t=Fa.exec(e);(!t||t[4]&&t[1])&&Mt();let s=parseFloat(t[2]),n=Math.round(s*Ba[t[3][0].toLowerCase()]);return Number.isFinite(n)||Mt(),t[1]==="-"||t[4]==="ago"?-n:n}function Ut(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}function Gt(e,t){if(typeof t!="string")throw new TypeError(`"${e}" claim must be a string`)}function Ya(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 jt(e,t){return typeof e=="number"?Ut(t,e):e instanceof Date?Ut(t,Ye(e)):Ye(new Date)+Tn(e)}var Pn;function G(e){return Pn.get(e)}function xn(e){let t=G(e);for(let s of["iat","nbf","exp"]){let n=t[s];if(typeof n=="number"&&!Number.isFinite(n))throw new TypeError(`"${s}" claim must be a finite number`)}return W.encode(JSON.stringify(t))}var Ve=class{constructor(t={}){if(!ye(t))throw new TypeError("JWT Claims Set MUST be an object");(Pn||=new WeakMap).set(this,structuredClone(t))}setIssuer(t){return Gt("iss",t),G(this).iss=t,this}setSubject(t){return Gt("sub",t),G(this).sub=t,this}setAudience(t){return Ya(t),G(this).aud=t,this}setJti(t){return Gt("jti",t),G(this).jti=t,this}setNotBefore(t){return G(this).nbf=jt(t,"setNotBefore"),this}setExpirationTime(t){return G(this).exp=jt(t,"setExpirationTime"),this}setIssuedAt(t){let s=G(this);return t===void 0?s.iat=Ye(new Date):typeof t=="string"?s.iat=Ut("setIssuedAt",Ye(new Date)+Tn(t)):s.iat=jt(t,"setIssuedAt"),this}};async function Va(e,t,s){let[n,r,o,a]=e,i="";if(r!==void 0){let b=xt(C,r);r=b[0],i=ge(b[1])}if(o!==void 0&&(o=xt(C,o)[0]),!r&&!o)throw new C("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!ln(r,o))throw new C("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let c={...r,...o};fn(C,r);let p=yn(r,gn(C,mn,a,r,c));p||s?.();let{alg:l}=c;if(typeof l!="string"||!l)throw new C('JWS "alg" (Algorithm) Header Parameter missing or invalid');let f=vn(l),w="",_=n,u;if(p){let b=e[4];b?(w=b[0]??=ge(n),_=b[1]??=Ke(w)):(w=ge(n),u=W.encode(`${i}.${w}`))}u??=pn(Ke(i),Ke("."),_);let E=await kn(await En(f,t,"sign"),f.subtle,"sign");f.minRsaBits&&_n(f.alg,E);let g={signature:ge(new Uint8Array(await crypto.subtle.sign(f.signing,E,u))),payload:w};return r&&(g.protected=i),o&&(g.header=o),[g,p]}async function Rn(e,t,s,n,r){let[o]=await Va([e,t,void 0,s],n,r);return`${o.protected}.${o.payload}.${o.signature}`}var Ja=Ve,B=class extends Ja{#e;setProtectedHeader(t){return hn(this.#e,"setProtectedHeader"),this.#e=t,this}async sign(t,s){return Rn(xn(this),this.#e,s?.crit,t,()=>{throw new fe("JWTs MUST NOT use unencoded payload")})}};var Kt='"alg" (Algorithm)';function Ht(e='JWK "alg" (Algorithm) Parameter'){throw new P(`Invalid or unsupported ${e} value`)}function On(e,t){return(typeof e=="string"?Lt[e]??Sn[e]:void 0)??Ht(t)}var be=(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},qa=e=>({data:e,pos:0}),Wt=e=>{let t=e.data[e.pos++];if(t===void 0)throw new Error("Unexpected end of ASN.1 input");return t},_e=e=>{let t=Wt(e);if(t&128){let s=t&127,n=0;for(let r=0;r<s;r++)n=n<<8|Wt(e);return n}return t};var Ae=(e,t,s)=>{if(Wt(e)!==t)throw new Error(s)},Cn=(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},Xa=e=>{Ae(e,6,"Expected algorithm OID");let t=_e(e);return Cn(e,t)};function Za(e,t){if(Ae(e,48,`Invalid ${t==="spki"?"SPKI":"PKCS#8"} structure`),_e(e),t==="pkcs8"){Ae(e,2,"Expected version field");let s=_e(e);e.pos+=s}Ae(e,48,"Expected algorithm identifier"),_e(e)}var Qa=e=>{let t=Xa(e);if(be(t,[43,101,110]))return"X25519";if(!be(t,[42,134,72,206,61,2,1]))throw new Error("Unsupported key algorithm");Ae(e,6,"Expected curve OID");let s=_e(e),n=Cn(e,s);if(be(n,[42,134,72,206,61,3,1,7]))return"P-256";if(be(n,[43,129,4,0,34]))return"P-384";if(be(n,[43,129,4,0,35]))return"P-521";throw new Error("Unsupported named curve")},ei=async(e,t,s,n)=>{let r=An(n?.extractable),o=On(s,Kt);o.secret&&Ht(Kt);let a=e==="spki",i;if(o.resolve)try{let c=qa(t);Za(c,e),i=o.resolve({crv:Qa(c)})}catch{throw new P("Invalid or unsupported key format")}else i=o.subtle;return crypto.subtle.importKey(e,t,i,r??a,o.usages[a?0:1])},ti=(e,t)=>He(e.replace(t,"")),Nn=(e,t,s)=>{let n=ti(e,/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);return ei("pkcs8",n,t,s)};async function zt(e,t,s){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return Nn(e,t,s)}var ke="RS256",qe="everyapp-identity",si="everyapp-identity-dev";var ni="x-everyapp-identity",ri="x-everyapp-public",Rl="x-everyapp-system";var $n=120,Bt=60;var Dn="public",oi="system";function ai(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 ii(e){return{typ:"public",pub:!0,jti:e}}var Je=null;async function Ft(e){let t=e.replace(/\\n/g,`
|
|
3
|
+
`);if(Je&&Je.pem===t)return Je.key;let s=await zt(t,ke);return Je={pem:t,key:s},s}async function Ol(e,t){let s=await Ft(e),n=Math.floor((t.now??Date.now())/1e3),r=t.ttlSeconds??$n,o=crypto.randomUUID();return new B(ai(t.subject,{channel:t.channel,actor:t.actor,scopes:t.scopes,toolCall:t.toolCall,jti:o})).setProtectedHeader({alg:ke,kid:t.keyId??qe}).setIssuer(t.issuer).setSubject(t.subject.sub).setAudience(t.audience).setIssuedAt(n).setExpirationTime(n+r).sign(s)}async function Cl(e,t){let s=await Ft(e),n=Math.floor((t.now??Date.now())/1e3),r=t.ttlSeconds??$n;return new B(ii(crypto.randomUUID())).setProtectedHeader({alg:ke,kid:t.keyId??qe}).setIssuer(t.issuer).setSubject(Dn).setAudience(t.audience).setIssuedAt(n).setExpirationTime(n+r).sign(s)}async function Nl(e,t){let s=t.ttlSeconds??Bt;if(s<=0||s>Bt)throw new RangeError(`system tokens live at most ${Bt}s (got ${s})`);let n=await Ft(e),r=Math.floor((t.now??Date.now())/1e3),o={typ:"system",purpose:t.purpose,jti:crypto.randomUUID()};return new B(o).setProtectedHeader({alg:ke,kid:t.keyId??qe}).setIssuer(t.issuer).setSubject(oi).setAudience(t.audience).setIssuedAt(r).setExpirationTime(r+s).sign(n)}function ci(e){let{basePath:t,normalize:s}=e;return{origin:e.origin,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=>di(t,n)??""},...s==="workers-ai"?{normalizeResponse:hi}:{}}}var Ln=Object.fromEntries(D.flatMap(e=>{let t=x[e];return t.mode==="ai"?[[e,ci(t)]]:[]}));function Ll(e){return Object.hasOwn(Ln,e)?Ln[e]:void 0}function Ml(e){return[e.keyEnv,...e.alsoNeeds??[]]}function di(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 pi=new Set(["/v1/chat/completions"]),ui=["content","reasoning_content","reasoning"],li=/"(?:content|reasoning_content|reasoning)"\s*:\s*-?\d/;function hi(e,t){if(!t.body||!pi.has(e))return t;let s=(t.headers.get("content-type")??"").toLowerCase(),n=s.startsWith("text/event-stream")?fi():s.startsWith("application/json")?gi():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 mi(e){if(!Yt(e)||!Array.isArray(e.choices))return!1;let t=!1;for(let s of e.choices)if(Yt(s)){for(let n of[s.delta,s.message])if(Yt(n))for(let r of ui){let o=n[r];typeof o=="number"&&(n[r]=String(o),t=!0)}}return t}function Mn(e){if(!li.test(e))return null;let t;try{t=JSON.parse(e)}catch{return null}return mi(t)?JSON.stringify(t):null}function fi(){let e=new TextDecoder,t=new TextEncoder,s="",n=r=>{let o=/^(data:[ ]?)(.*?)(\r?)$/s.exec(r);if(!o)return r;let a=Mn(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 gi(){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=Mn(n);if(r!==null){t.enqueue(new TextEncoder().encode(r));return}for(let o of e)t.enqueue(o)}})}function Yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Kl=64*1024;var y=(e,t,s,n=1)=>({type:t,version:n,description:s,group:e}),Gn=[y("member","member.invited","Someone was invited to the workspace"),y("member","member.joined","Someone joined the workspace"),y("member","member.role_changed","A member's role changed"),y("member","member.deactivated","A member was deactivated"),y("member","member.reactivated","A member was reactivated"),y("member","member.removed","A member was removed"),y("member","member.password_reset","A member reset their password"),y("app","app.installed","An app was installed on the Gateway"),y("app","app.updated","An app was redeployed"),y("app","app.removed","An app was removed from the Gateway"),y("app","app.needs_setup","An app needs a setting before it opens"),y("app","app.ready","An app has every setting it needs"),y("app","app.paused_cap","An app is paused: its monthly cap is reached"),y("app","app.tools_changed","An app's AI tools changed"),y("cap","cap.warning","An app is at 80% of its monthly cap"),y("cap","cap.reached","An app reached its monthly cap"),y("cap","cap.raised","An app's monthly cap, or the workspace default, was raised or removed"),y("tool","tool.blocked","An AI client's tool call was blocked"),y("tool","tool.error","An AI client's tool call failed"),y("connection","connection.created","An AI app was connected"),y("connection","connection.revoked","An AI app connection was revoked"),y("token","token.created","A personal access token was created"),y("token","token.revoked","A personal access token was revoked"),y("access","access.changed","Cloudflare Access was turned on or off"),y("signin_provider","signin_provider.added","A sign-in provider (Continue with Google, \u2026) was turned on"),y("signin_provider","signin_provider.removed","A sign-in provider was turned off"),y("mcp_app","mcp_app.added","An MCP app was added"),y("mcp_app","mcp_app.removed","An MCP app was removed"),y("mcp_app","mcp_app.enabled","An MCP app is being served again"),y("mcp_app","mcp_app.disabled","An MCP app stopped being served"),y("provider","provider.added","An API provider was registered"),y("provider","provider.removed","An API provider was removed"),y("ping","ping","A test event, sent to one subscription on request")],qt=new Map(Gn.map(e=>[e.type,e]));function zl(e){return qt.get(e)}var Vt="app.";var yi=64;function wi(e){return e.startsWith(Vt)&&!qt.has(e)&&e.slice(Vt.length).includes(".")}var Ei=8*1024,Bl=16*1024,jn=8;var Fl=25,Yl=16,Vl=128,Jl=30,ql=2048,Xl=100,bi=[6e4,3e5,18e5,72e5,288e5,864e5],Zl=bi.length+1;var Ql="EVENTS_ALLOW_PRIVATE_TARGETS",_i=["localhost","local","localdomain","internal","intranet","lan","corp","private","home.arpa","onion"];function eh(e){return e.includes(".")?_i.some(t=>e===t||e.endsWith(`.${t}`)):!0}var th=["owners","admins"];function Ai(e,t){return e==="*"?t!=="ping":e.endsWith(".*")?t.startsWith(e.slice(0,-1)):e===t}function sh(e,t){return e.some(s=>Ai(s,t))}var ki=/^(\*|[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*(\.\*)?)$/;function nh(e){if(!ki.test(e)||e.length>yi+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 Gn.some(s=>s.type.startsWith(t))||e.startsWith(Vt)?null:`"${e}" matches no event type (everyapp events types lists them)`}return wi(e)?null:`"${e}" isn't an event type (everyapp events types lists them)`}var Si=/secret|token|password|passwd|authorization|api[_-]?key|private[_-]?key|credential|cookie|session/i;function Jt(e,t){if(t>jn)return"\0depth";if(Array.isArray(e)){for(let s of e){let n=Jt(s,t+1);if(n)return n}return null}if(e&&typeof e=="object")for(let[s,n]of Object.entries(e)){if(Si.test(s))return s;let r=Jt(n,t+1);if(r)return r}return null}function rh(e,t=Ei){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=Jt(JSON.parse(s),1);return r==="\0depth"?{ok:!1,code:"event_data_invalid",message:`data nests at most ${jn} 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 Ii(e){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 vi=new Set(["everyapp"]),Ti=/^\d{1,3}(\.\d{1,3}){3}$/,Pi=[".localhost",".local",".internal",".arpa"];function xi(e){return`${e.toUpperCase().replace(/-/g,"_")}_`}function Ri(e){return Ti.test(e)?`${e} is an IP address, not a host name`:e==="localhost"||Pi.some(t=>e.endsWith(t))?`${e} is not a public host`:null}function Xt(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 ph(e,t){let s=Xt(t.gatewayHost);if(s&&e===s)return`${e} is this gateway's own host`;let n=Xt(t.appBaseDomain);if(n&&(e===n||e.endsWith(`.${n}`)))return`${e} is under this gateway's app domain ${n}`;let r=Xt(t.thirdPartyDomain);return r&&(e===r||e.endsWith(`.${r}`))?`${e} is under this gateway's third-party domain ${r}`:null}function Oi(e,t,s){let n=xi(e);return t.startsWith(n)?le(t)?`${t} is one of the Gateway's own keys`:js(t)?`${t} is a local-development setting`:Ne(t)?`${t} is a name everyapp sets itself`:Ce(t)?`${t} is a sign-in provider's setting name (every <ID>_SIGNIN_<FIELD> name is the Gateway's, set with \`everyapp signin add\`)`:H(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 Ci(e,t,s){if(vi.has(e)||D.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 O(t)){let r=Oi(e,n,o=>s.rowSettings.has(o));if(r)return{id:e,code:"PROVIDER_SECRET_TAKEN",message:r}}for(let n of t.hosts){let r=Ri(n)??s.refuseHost?.(n);if(r)return{id:e,code:"PROVIDER_HOST_REFUSED",message:r}}return null}function Ni(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=It(s);if(!n.ok)return{ok:!1,refusal:{id:e.id,code:"PROVIDER_SPEC_INVALID",message:vt(n.problems)}};if(n.id!==e.id||!St.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=Ci(n.id,n.capability,t);return r?{ok:!1,refusal:r}:{ok:!0,capability:n.capability}}function $i(e=[],t={}){let s=new Map(D.map(p=>[p,x[p]])),n=new Map,r=[],o=new Set;for(let p of e){if(n.has(p.id)){r.push({id:p.id,code:"PROVIDER_SPEC_INVALID",message:"listed twice"});continue}let l=Ni(p,{rowSettings:o,...t.refuseHost?{refuseHost:t.refuseHost}:{}});if(!l.ok){r.push(l.refusal);continue}n.set(p.id,{id:p.id,capability:l.capability,bound:p.boundTo===Ii(l.capability),addedBy:p.addedBy??null,addedAt:p.addedAt??null});for(let f of O(l.capability))o.add(f)}let a=new Map([...s,...[...n.values()].map(p=>[p.id,p.capability])]),i,c;return{get:p=>a.get(p),ids:()=>[...a.keys()],entries:()=>[...a.entries()],sourceOf:p=>s.has(p)?"catalog":n.has(p)?"row":void 0,settingNames:()=>(i??=new Set([...a.values()].flatMap(p=>O(p))),i),bound:p=>s.has(p)||(n.get(p)?.bound??!1),unboundSettings:()=>(c??=new Set([...n.values()].filter(p=>!p.bound).flatMap(p=>O(p.capability))),c),rows:()=>[...n.values()],rejected:r}}var uh=$i();import{z as d}from"zod";var Un=/[\x00-\x1f\x7f]/,Di=/%2f|%5c/i;function Zt(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(Un.test(e))return{canonical:"/",ambiguous:!0,reason:"control characters"};if(e.includes("\\"))return{canonical:"/",ambiguous:!0,reason:"backslash"};if(Di.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(Un.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 Li(e){return e===F||e.startsWith(F+"/")}function em(e){return Kn(Zt(e).canonical)||Kn(Wn(e))}function Kn(e){let t=e.toLowerCase();return t===me||t.startsWith(`${me}/`)}var Mi=["oauth-protected-resource","oauth-authorization-server","openid-configuration"],Gi=Mi.flatMap(e=>[`/.well-known/${e}`,`/mcp/.well-known/${e}`]);function tm(e){return Hn(Zt(e).canonical)||Hn(Wn(e))}function Hn(e){let t=e.toLowerCase();return Gi.some(s=>t===s||t.startsWith(`${s}/`))}function Wn(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 ji(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 zn(e,t,s){if(!e||e.length===0)return{public:!1,reason:"no public routes declared"};let{canonical:n,ambiguous:r,reason:o}=Zt(s);if(r)return{public:!1,reason:`ambiguous path: ${o}`};if(Li(n))return{public:!1,reason:"internal namespace is never public"};let a=t.toUpperCase();for(let i of e)if((i.methods??["GET"]).map(p=>p.toUpperCase()).includes(a)&&ji(i.path).test(n))return{public:!0,route:i,reason:`matched ${i.path}`};return{public:!1,reason:"no matching public route"}}var Vn=d.object({path:d.string(),methods:d.array(d.string()).optional()}),Xe=d.object({name:d.string(),className:d.string(),worker:d.string().optional()}),Jn=d.object({name:d.string(),worker:d.string().optional(),caching:d.enum(["off","default"]).optional()}),qn=d.object({d1:d.array(d.string()).optional(),kv:d.array(d.string()).optional(),durableObjects:d.array(Xe).optional(),workflows:d.array(Xe).optional(),hyperdrive:d.array(Jn).optional(),r2:d.array(d.string()).optional(),ai:d.array(d.string()).optional()}).passthrough(),Ui=d.string().regex(/^\d{4}-\d{2}-\d{2}$/,"must be YYYY-MM-DD"),Ki=/^[a-z0-9][a-z0-9:_-]{0,63}$/,Qt={when:({value:e})=>typeof e=="object"&&e!==null&&!Array.isArray(e)},Xn=d.record(d.string(),d.string().min(1).max(200)).superRefine((e,t)=>{for(let s of Object.keys(e))s==="*"||s.startsWith("provider:")?t.addIssue({code:d.ZodIssueCode.custom,path:[s],message:"reserved scope id"}):Ki.test(s)||t.addIssue({code:d.ZodIssueCode.custom,path:[s],message:"invalid scope id"})},Qt),Hi=Xn,Wi=d.object({engine:d.enum(["drizzle","d1-sql","prisma"]),dialect:d.enum(["sqlite","postgresql"]).optional(),dir:d.string().optional(),config:d.string().min(1).optional(),binding:d.string().min(1).optional()}).strict().superRefine((e,t)=>{if(e.engine==="prisma"&&e.dialect!=="postgresql"&&t.addIssue({code:d.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:d.ZodIssueCode.custom,path:["engine"],message:'Postgres migrations run on the "drizzle" or "prisma" engine'}),e.binding!==void 0&&t.addIssue({code:d.ZodIssueCode.custom,path:["binding"],message:"binding names a D1 database; Postgres migrations have none"})),e.config!==void 0&&!Yn(e.config)&&t.addIssue({code:d.ZodIssueCode.custom,path:["config"],message:"config must be a relative path without .. segments"}),e.engine==="d1-sql"&&!e.dir?.trim()){t.addIssue({code:d.ZodIssueCode.custom,path:["dir"],message:'dir is required when migrations.engine is "d1-sql"'});return}e.dir&&!Yn(e.dir)&&t.addIssue({code:d.ZodIssueCode.custom,path:["dir"],message:"dir must be a relative path without .. segments"})}),zi=d.union([d.literal(!1),d.string().min(1)]),Zn=/^[a-z][a-z0-9-]*$/,Qn="provider must start with a lowercase letter and contain only lowercase letters, digits, and hyphens",et=d.string().regex(Zn,Qn);function er(e,t){return Zn.test(e)?!1:(t.addIssue({code:d.ZodIssueCode.custom,path:[e],message:Qn}),!0)}var Bi=d.string().url().refine(e=>e.startsWith("https://"),"must be an https URL"),es={why:d.string().min(1).max(200).optional(),docs:Bi.optional(),optional:d.boolean().optional(),anyOf:d.string().trim().min(1).max(40).optional()},Fi=d.object({id:et}).passthrough(),Yi=d.object({id:et,...es}).strict(),tr=(e,t)=>{let s=new Set;e.forEach((n,r)=>{let o=typeof n=="string"?n:n.id;s.has(o)&&t.addIssue({code:d.ZodIssueCode.custom,path:[r],message:"duplicate provider"}),s.add(o)})},Vi=d.array(d.union([et,Fi])).superRefine(tr),Ji=d.array(d.union([et,Yi])).superRefine(tr),Bn=d.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"a secret's name is an identifier").max(64),Ze=d.object({scopes:d.array(d.string()).optional().catch(void 0),access:d.enum(["read","write"]),...es}),qi=Ze.passthrough();function Xi(e,t=Q){let s=t.get(e);if(!s||s.mode==="ai")throw new Error(`capabilityEntrySchema: ${e} is not a capability`);let n=d.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=d.undefined({error:`${s.label} takes no scopes; list it as { access: ..., why }`}).optional();return Ze.extend({access:n,scopes:c}).strict()}let o=Object.keys(r.sets),a=`${s.label} needs scopes: one or more of ${o.join(", ")}`,i=d.array(d.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 Ze.extend({access:n,scopes:i}).strict()}var Zi=d.record(d.string(),qi).superRefine((e,t)=>{for(let s of Object.keys(e))er(s,t)},Qt),Qi=Ze.extend({scopes:d.undefined({error:"a provider registered on the gateway takes no scopes; list it as { access: ..., why }"}).optional()}).strict();function sr(e,t){return d.record(d.string(),d.unknown()).superRefine((s,n)=>{for(let[r,o]of Object.entries(s)){if(er(r,n))continue;let a=e.get(r);if(a?.mode==="ai"){n.addIssue({code:d.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:d.ZodIssueCode.custom,path:[r],message:`unknown capability (the gateway offers: ${$s(e).join(", ")})`});continue}let c=Qi.safeParse(o);if(c.success)continue;for(let p of c.error.issues)n.addIssue({...p,path:[r,...p.path]});continue}if(r==="email"&&o!==null&&typeof o=="object"&&"senders"in o){n.addIssue({code:d.ZodIssueCode.custom,path:[r,"senders"],message:`senders moved out of the manifest: set them with \`${At} --sender <pattern>\` in the app's directory after its first deploy`});continue}let i=Xi(r,e).safeParse(o);if(!i.success)for(let c of i.error.issues)n.addIssue({...c,path:[r,...c.path]})}},Qt).transform(s=>s)}var ec=sr(Q,"refuse"),tc=`inbound is true (the Worker exports an email() handler) or left out; the addresses moved out of the manifest: set them with \`${At} --inbound <address>\` in the app's directory after its first deploy`,sc=d.object({inbound:d.boolean().optional().catch(void 0)}).passthrough(),nc=d.object({inbound:d.boolean({error:tc}).optional()}).strict(),rc="email.inbound: apps in a dispatch namespace don't receive mail",Qe=d.object({cpuMs:d.number().int().min(1).max(3e5).optional()}).passthrough(),nr=d.object({provider:d.enum(["d1","postgres"]),region:d.string().regex(/^[a-z0-9]+:[a-z0-9-]+$/,'region must be a cloud region such as "aws:us-east-1"').optional()}).passthrough(),oc=d.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),rr=d.object({name:oc,binding:d.string().optional(),limits:Qe.optional()}),ac=d.enum(["everyone","admins"]),ic=d.string().regex(/^\/v1(\/[a-z0-9_-]+)+$/,'must be an OpenAI API path such as "/v1/files"'),or=d.object({models:d.array(d.string().min(1).max(200)).optional(),routes:d.array(ic).optional()}).passthrough(),cc=`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`,dc=/^[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}]*$/u,ar=d.object({by:d.enum(["gateway","app"]),why:d.string().min(1,"say why the app needs /mcp on its own host").max(200).regex(dc,"why is plain text: no control characters")},{error:e=>e.code==="invalid_type"?cc:void 0}).passthrough(),ir=d.object({id:d.string().min(1).regex(/^[a-z]([a-z0-9-]*[a-z0-9])?$/,"id must be kebab-case (lowercase, digits, hyphens)"),name:d.string().min(1).optional(),description:d.string().optional(),icon:d.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:d.string().optional(),compatibilityDate:Ui.optional(),resources:qn.optional(),workers:d.array(rr.passthrough()).optional(),database:nr.optional(),limits:Qe.optional(),public:d.array(Vn).optional(),providers:Vi.optional(),capabilities:Zi.optional(),secrets:d.array(d.union([Bn,d.object({name:Bn}).passthrough()])).max(100).optional(),scopes:Xn.optional(),ai:or.optional(),email:sc.optional(),access:ac.optional(),serverFnGuard:d.boolean().optional(),serverFnBase:d.string().regex(/^(\/[A-Za-z0-9_~-][A-Za-z0-9._~-]*)+\/?$/,'must be a path such as "/app/_serverFn"').optional(),build:d.string().min(1).optional(),dev:d.string().min(1).optional(),devPort:d.number().int().positive().optional(),install:zi.optional(),migrations:Wi.optional(),mcp:ar.optional()}).passthrough(),pc=Vn.strict(),L=d.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"binding names must be JavaScript identifiers"),uc=d.string().regex(/^setup\/[a-z0-9][a-z0-9-]*\.md$/,'must be a guide in the everyapp skill, such as "setup/main-secret.md"'),lc=d.object({name:L,...es,setup:uc.optional()}).strict();function hc(e,t){if(!e)return null;for(let s of e.ids()){if(ft(s))continue;let n=e.get(s);if(n&&O(n).includes(t))return{kind:"capability",id:s}}return null}function cr(e){return d.array(d.union([L,lc])).superRefine((t,s)=>{let n=new Set;t.forEach((r,o)=>{let a=typeof r=="string"?r:r.name,i=w=>s.addIssue({code:d.ZodIssueCode.custom,path:[o],message:w});if(n.has(a)&&i(`duplicate secret ${a}`),n.add(a),Ne(a)){i(`${a} is set by everyapp itself (${Us})`);return}let c=a.toUpperCase();if(Ce(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 p=H(c)?null:hc(e,c);if(!H(c)&&!p)return;if(he(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 l=p??Ks(c),f=l?`list \`${l.id}\` under ${l.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; ${f}`)})})}var mc=cr(),fc=qn.extend({d1:d.array(L).optional(),kv:d.array(L).optional(),r2:d.array(L).optional(),ai:d.array(L).optional(),durableObjects:d.array(Xe.strict()).optional(),workflows:d.array(Xe.extend({name:L}).strict()).optional(),hyperdrive:d.array(Jn.extend({name:L}).strict()).optional()}).strict();function dr(e={}){let t=e.capabilities===void 0&&(e.unknownCapabilities??"refuse")==="refuse"?ec:sr(e.capabilities??Q,e.unknownCapabilities??"refuse");return ir.extend({resources:fc.optional(),providers:Ji.optional(),workers:d.array(rr.extend({binding:L.optional(),limits:Qe.strict().optional()}).strict()).optional(),public:d.array(pc).optional(),scopes:Hi.optional(),ai:or.strict().optional(),capabilities:t.optional(),secrets:(e.capabilities?cr(e.capabilities):mc).optional(),email:nc.optional(),database:nr.strict().optional(),limits:Qe.strict().optional(),mcp:ar.strict().optional()}).strict()}var am=dr(),F="/__everyapp",gc=["everyapp"];function yc(e){return gc.includes(e)}var A=class extends Error{constructor(t){super(t),this.name="ManifestError"}};function pr(e){return e.map(t=>`${t.path.map(String).join(".")||"(root)"}: ${t.message}`).join("; ")}function im(e){let t=ir.safeParse(e);if(!t.success)throw new A(`Invalid manifest: ${pr(t.error.issues)}`);let s=t.data;for(let n of s.public??[])hr(n.path);return s}function cm(e,t={}){let s=dr(t).safeParse(e);if(!s.success)throw new A(`Invalid everyapp.config: ${pr(s.error.issues)}`);let n=s.data,r=_c(n),o=nn(n).find(a=>r.has(a));if(o)throw new A(`Invalid everyapp.config: secrets: ${o} is one of the app's bindings; pick another name for the secret`);if(yc(n.id))throw new A(`Invalid everyapp.config: id "${n.id}" is reserved for the platform.`);for(let a of n.public??[]){hr(a.path);let i=a.path==="/mcp"||a.path.startsWith("/mcp/");if(i||(a.methods??["GET"]).some(p=>zn([a],p,"/mcp").public))throw new A(`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 Ec(n),bc(n),wc(n),n}function wc(e){let t=[...De(e).map(n=>({path:`providers: ${n.id}`,need:n})),...Object.entries(e.capabilities??{}).map(([n,r])=>({path:`capabilities.${n}`,need:r})),...Le(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 A(`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 A(`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 Ec(e){let t=new Set;for(let{name:n}of e.workers??[]){if(t.has(n))throw new A(`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 A(`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 A(`Invalid everyapp.config: Hyperdrive ${n.name} is bound by Worker "${n.worker}", which workers doesn't declare.`)}function bc(e){if(e.migrations?.dialect==="postgresql"&&e.database?.provider!=="postgres")throw new A('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??[]]){if(t.has(s))throw new A(`Invalid everyapp.config: the binding ${s} is declared twice in resources.`);t.add(s)}}function _c(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.workers??[]).flatMap(t=>t.binding?[t.binding]:[]),...e.database?["DATABASE_PROVIDER"]:[],"ASSETS"])}function dm(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.email?.inbound===!0&&s.push(rc),e.secrets?.length&&s.push("secrets: third-party apps can't have secrets of their own yet"),s}function pm(e){return e.startsWith("every-")?e:`every-${e}`}var Fn="every-app-gateway",Ac=63;function kc(e){let t=e.toLowerCase();return t===Fn||t.startsWith(`${Fn}-`)}var ur="--";function Sc({appId:e,orgKey:t}){if(!t)throw new Error("An org-scoped Worker name needs an org key.");return`every-${t}-${e}`}function um(e){return kc(e.workerName)||e.workerName.length>Ac||!e.orgKey||e.appId.includes(ur)?!1:e.workerName===Sc(e)}function lm(e,t){return t==="DB"||t==="KV"?e:lr(e,t)}var hm=63;function mm(e,t){return t==="R2"?e:lr(e,t)}function lr(e,t){let s=t.toLowerCase().replaceAll("_","-");return`${e}${ur}${s}`}function hr(e){if(!e.startsWith("/"))throw new A(`Public route path must be absolute (start with "/"): ${JSON.stringify(e)}`);if(e==="/*"||e==="/**"||e==="*"||e==="/")throw new A(`Public route "${e}" exposes the entire app. A catch-all public route is not allowed.`);if(e.includes("%"))throw new A(`Public route "${e}" must not contain percent-encoding; declare the decoded path.`);if(e.includes("\\"))throw new A(`Public route "${e}" must not contain backslashes.`);let t=e.split("/");if(t.some(n=>n==="."||n===".."))throw new A(`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 A(`Public route "${e}" has an invalid named segment "${n}".`);let s="/"+(t[1]??"");if(e===F||e.startsWith(F+"/")||s===F)throw new A(`Public route "${e}" targets the reserved ${F} namespace, which can never be public.`)}function Yn(e){return!e.trim()||e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)?!1:!e.split(/[\\/]+/).some(t=>t==="..")}var Ic="APP__";function gm(e){return`${Ic}${e}`}var ym=Object.freeze({manifest:"manifest",stamp:"stamp",worker:"worker",modulePrefix:"module:",assetPrefix:"asset:",migrationPrefix:"migration:"});var vc={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"},I=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=vc[t];this.rerun=n.rerun??(r?T([r]):this.retryable?T():void 0),this.rerunNote=n.rerunNote,this.authorize=n.authorize??r!==void 0,this.data=n.data}},tt=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?T():r.rerun,this.rerunNote=r.rerunNote,this.data=r.data}},mr=class extends I{constructor(t="Cancelled. Nothing changed."){super("CANCELLED",t),this.name="CancelledError"}},ts=new WeakMap;function km(e,t){return t&&typeof e=="object"&&e!==null&&(ts.has(e)||ts.set(e,t)),e}function fr(e){return typeof e=="object"&&e!==null?ts.get(e):void 0}function Sm(e){return e instanceof Error?e.message:String(e)}var j=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 Se(e,t){return e instanceof j&&e.kind===t}function Tm(e){return Se(e,"r2_not_enabled")||Se(e,"access_not_enabled")}var oe=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"}},Y=class extends Error{constructor(t,s){super(`Unexpected output from \`${t}\`: ${s}`),this.name="CfOutputError"}},Tc=/Aborting the upload operation because of conflicts/,Pc=[["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)||/\balready exists\b/i.test(e)],["not_found",(e,t)=>t.includes(10007)||t.includes(10009)||t.includes(7404)||t.includes(10200)||/\bnot found\b|does not exist/i.test(e)]];function gr(e,t){return/^Aborted\.$/m.test(t)?new j({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 yr(e,t=""){let s=xc(e)??Oc(t,e),n=[...s.matchAll(/\[(?:code: )?(\d{4,})\]/g)].map(o=>Number(o[1])),r=Tc.test(`${t}
|
|
7
|
+
${e}`)?"strict_conflict":Pc.find(([,o])=>o(s,n))?.[0]??"unknown";return{message:s,apiCodes:n,kind:r}}function xc(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=Rc(n);return r.length>0?r:void 0}function Rc(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 Oc(...e){return X(...e).join(`
|
|
11
|
+
`)||"cf failed without an error message"}var ss=new Set;function wr(e){return ss.add(e),()=>ss.delete(e)}function st(){for(let e of ss)e()}function Er(){return!!process.stdout.isTTY&&process.env.TERM!=="dumb"&&!process.env.CI}function xm(e,t=process.env,s=!!process.stdout.isTTY){return!e&&!t.NO_COLOR&&s&&t.TERM!=="dumb"}import{AsyncLocalStorage as Dc}from"node:async_hooks";import Cc from"chalk";import{spawn as Nc}from"node:child_process";import{once as br}from"node:events";var V=process.platform!=="win32",$c=1e3;function _r({command:e,args:t,cwd:s,env:n,shell:r=!1,hold:o}){let a=Nc(e,t,{cwd:s,shell:r,env:o&&Cc.level>0?{...n,FORCE_COLOR:"1"}:n,stdio:["ignore",o?"pipe":"inherit",o?"pipe":"inherit"],detached:V}),i=o?[]:null,c=o?Promise.race([Promise.all([br(a.stdout,"end"),br(a.stderr,"end")]),new Promise(l=>setTimeout(l,1e3).unref())]):Promise.resolve();if(o)for(let[l,f]of[[a.stdout,process.stdout],[a.stderr,process.stderr]])l.on("data",w=>{i?i.push({to:f,chunk:w}):f.write(w)});return{exited:new Promise((l,f)=>{a.once("error",f),a.once("exit",(w,_)=>{c.then(()=>l({code:w,signal:_}))})}),stop:l=>rt(a,V,l),releaseOutput:l=>{let f=i??[];if(i=null,l)for(let{to:w,chunk:_}of f)w.write(_)}}}function rt(e,t,s="SIGTERM"){e.pid!==void 0&&(nt(e,t,s),s!=="SIGKILL"&&setTimeout(()=>nt(e,t,"SIGKILL"),$c).unref())}function nt(e,t,s){let n=e.pid;if(n!==void 0)try{t?process.kill(-n,s):e.kill(s)}catch{}}var Lc=3e3,Mc=1e4,Gc=["SIGINT","SIGTERM"],ae=new Set,it=new Set,J=new Set,Ar=new WeakSet,vr=new Dc,kr=!1,Ie=!1,ot;function Tr(e,t){let s={child:e,group:t,exited:new Promise(n=>{e.exitCode!==null||e.signalCode!==null?n():e.once("close",()=>n())})};return Ie&&!vr.getStore()&&at(s,"SIGKILL"),ae.add(s),ct(),()=>{ae.delete(s),ct()}}function jm(){return Ie}function Um(e){return ot=e,()=>{ot===e&&(ot=void 0)}}function Pr(e){return J.add(e),ct(),()=>{J.delete(e),ct()}}function os(e){return it.add(e),()=>it.delete(e)}function jc(){let e=[...new Set([...J].flatMap(n=>n.label?[n.label]:[]))],t=[...ae.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 Oe(s)}function Uc(e){for(let t of[...e].reverse()){let s=t.closing?.();if(s!==void 0)return s}return"Stopped."}function Sr(e,t){it.size===0&&process.stderr.write(t);for(let s of it)e(s)}function ct(){let e=ae.size>0||J.size>0;if(!(e===kr||Ie)){kr=e;for(let t of Gc)e?process.on(t,Ir):process.off(t,Ir)}}function Ir(e){Kc(e)}async function Kc(e,{exit:t=s=>process.exit(s)}={}){let s=e==="SIGTERM"?143:130;if(Ie){if(e==="SIGTERM")return;for(let c of ae)at(c,"SIGKILL");ns(),t(s);return}Ie=!0,st();let n=ot,r=n===void 0?jc():n?`Stopping ${n}`:"";r&&Sr(c=>c.stopping(r),`
|
|
12
|
+
${r} (Ctrl+C again to quit at once)...
|
|
13
|
+
`);let o=[...J],a=[...ae];for(let c of a)at(c,e);let i=Promise.all(a.map(c=>c.exited));if(!await rs(i,Lc)){for(let c of a)at(c,"SIGKILL");await rs(i,1e3)}if(ns(),await rs(Hc(),Mc),ns(),n===void 0){let c=Uc(o);Sr(p=>p.stopped(c),c?`${c}
|
|
14
|
+
`:"")}t(s)}async function Hc(){for(let e of[...J].reverse())e.async&&await vr.run(!0,()=>e.async()).catch(()=>{})}function ns(){for(let e of[...J])if(!Ar.has(e)){Ar.add(e);try{e.sync?.()}catch{}}}function at({child:e,group:t},s){nt(e,t,s)}async function rs(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 ie="22.18.0",as="--dns-result-order=ipv4first";function xr(e){let t=(e??"").trim();return t.split(/\s+/).includes(as)?t:t?`${t} ${as}`:as}function is(e){return Wc(e,ie)>=0}function zm(e=process.versions){return e.bun?new I("UNSUPPORTED_RUNTIME",`everyapp runs on Node.js, not Bun
|
|
15
|
+
The Cloudflare CLI can't load cloudflare.config.ts under Bun.`,{rerun:T(),rerunNote:`with Node.js ${ie} or newer`}):is(e.node)?null:new I("UNSUPPORTED_RUNTIME",`everyapp needs Node.js ${ie} 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 Wc(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 Bc from"node:path";import{fileURLToPath as Fc}from"node:url";import Rr from"node:fs/promises";import ve from"node:path";async function Or(e,t,s){let n=ve.resolve(e);try{let r=await zc(n,t),o=JSON.parse(await Rr.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:ve.resolve(ve.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 zc(e,t){let s=e;for(;;){let n=ve.join(s,"node_modules",...t.split("/"),"package.json");try{return await Rr.realpath(n)}catch{}let r=ve.dirname(s);if(r===s)break;s=r}throw new Error(`${t} is not installed under ${e} or any directory above it.`)}var Yc=Ts.cf;function Vc(){return Cr(Bc.dirname(Fc(import.meta.url)),"cli")}async function Cr(e,t){let{binPath:s,version:n}=await Or(e,"cf","cf");return{path:s,version:n,source:t}}var Jc="EVERYAPP_CF_BINARY";async function Nr(e){let t=process.env[Jc];if(t)return{path:t,version:Yc,source:"cli"};if(e)try{return await Cr(e,"project")}catch{}return Vc()}import Te from"node:fs/promises";import $r from"node:path";async function qc(e,t,s={}){let n=s.exclude||[];await Te.mkdir(t,{recursive:!0});let r=await Te.readdir(e,{withFileTypes:!0});for(let o of r){let a=$r.join(e,o.name),i=$r.join(t,o.name);n.some(c=>o.name===c)||(o.isDirectory()?await qc(a,i,s):await Te.copyFile(a,i))}}async function sf(e){try{return(await Te.stat(e)).isDirectory()}catch{return!1}}async function nf(e){try{return await Te.access(e),!0}catch{return!1}}function ce(e){return e?.code==="ENOENT"}import Lr from"node:fs/promises";import dt from"node:path";import{execa as rd}from"execa";import Xc from"node:fs";import Dr from"node:fs/promises";import Zc from"node:os";import cs from"node:path";import Qc from"chalk";import{execa as ed}from"execa";async function ds(e,t,s){let n=[e,...t].join(" "),r=await sd(s.logName??n),o=Xc.createWriteStream(r,{flags:"a",mode:384}),a=`$ ${n}
|
|
17
|
+
# in ${s.cwd??process.cwd()}
|
|
18
|
+
|
|
19
|
+
`;o.write(a);let i=s.echo?td(n):null,c=_=>{o.write(_),i?.write(_)},p=ed(e,[...t],{cwd:s.cwd,env:s.env,shell:s.shell,stdin:"ignore",stdout:"pipe",stderr:"pipe",buffer:!1,reject:!1});p.stdout?.on("data",c),p.stderr?.on("data",c);let l=await p;if(i?.end(),await new Promise(_=>o.end(_)),!l.failed)return;let f=await nd(r,a.length),w=l.exitCode!==void 0?`${l.command} exited with code ${l.exitCode}`:l.signal?`${l.command} was stopped by ${l.signal}`:l.shortMessage;throw new I(s.code??"COMMAND_FAILED",[`${s.what} failed`,`${w}.${f.length>0?" Its last lines:":""}`,...f.map(_=>` ${_}`),`Full log: ${r}`].join(`
|
|
20
|
+
`),{...s.fix?{fix:s.fix}:{},data:{command:n,exitCode:l.exitCode??null,tail:f,log:r}})}function td(e){let t=n=>process.stderr.write(`${Qc.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 sd(e){let t=cs.join(Zc.tmpdir(),"everyapp");await Dr.mkdir(t,{recursive:!0,mode:448});let s=e.split(/\s+/).slice(0,2).map(r=>cs.basename(r).replace(/[^\w.-]+/g,"")).filter(Boolean).join("-")||"command",n=new Date().toISOString().replace(/[:.]/g,"-");return cs.join(t,`${s}-${n}-${process.pid}.log`)}async function nd(e,t){return X((await Dr.readFile(e,"utf8").catch(()=>"")).slice(t))}async function od(){try{return await rd("pnpm",["--version"],{stdio:"pipe"}),!0}catch{return!1}}async function bf({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 us(e),{command:a,args:i}=await id(o);await ds(a,i,{cwd:e,echo:n,what:`${r} with ${o}`,code:"INSTALL_FAILED"})}async function us(e){let t=await ad(e);return t||(await ps(dt.join(e,"pnpm-lock.yaml"))?"pnpm":await ps(dt.join(e,"yarn.lock"))?"yarn":await ps(dt.join(e,"package-lock.json"))?"npm":"pnpm")}async function ad(e){let t=dt.join(e,"package.json");try{let n=JSON.parse(await Lr.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(ce(s))return null;throw s}}async function id(e){return e==="yarn"?{command:"yarn",args:["install"]}:e==="npm"?{command:"npm",args:["install"]}:await od()?{command:"pnpm",args:["install"]}:{command:"npx",args:["pnpm","install"]}}async function ps(e){try{return await Lr.access(e),!0}catch(t){if(ce(t))return!1;throw t}}import{spawn as _d}from"node:child_process";import Ad from"node:fs/promises";import pt from"node:path";import{createHash as cd}from"node:crypto";import S from"node:fs/promises";import{rmSync as dd}from"node:fs";import ls from"node:os";import N from"node:path";var pd="cloudflare.config.ts",xe=448,Gr=18;async function jr(){return ms("neutral")}var Ur="files-";async function ud(e){let t=await ms("tmp");return await hd(t),S.mkdtemp(N.join(t,`${e}${process.pid}-`))}async function Kr(e){let t=await ud(e),s=Pr({sync:()=>dd(t,{recursive:!0,force:!0})});return{dir:t,cleanup:async()=>{await S.rm(t,{recursive:!0,force:!0}),s()}}}var ld=24*60*6e4;async function hd(e){let t=Date.now()-ld;for(let s of await S.readdir(e).catch(()=>[])){let n=Number(/-(\d+)-[^-]+$/.exec(s)?.[1]);if(n&&md(n))continue;let r=N.join(e,s),o=await zr(r).catch(()=>null);o&&o.ctimeMs<t&&await S.rm(r,{recursive:!0,force:!0}).catch(()=>{})}}function md(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}async function Hr(){if(process.platform==="win32")return N.dirname(process.execPath);let e=await ms("bin"),t=N.join(e,cd("sha256").update(process.execPath).digest("hex").slice(0,16));await hs(t);let s=N.join(t,"node");if(await S.readlink(s).catch(()=>null)!==process.execPath){await S.rm(s,{force:!0});try{await S.symlink(process.execPath,s)}catch(n){if(n.code!=="EEXIST")throw n}}return t}async function ms(e){await fd();let t=N.join(ls.homedir(),".everyapp");await gd(t);let s=N.join(t,"cf");await hs(s);let n=N.join(s,e);return await hs(n),await yd(n),n}async function fd(){let e=Number(process.env.SUDO_UID);if(process.getuid?.()!==0||!Number.isInteger(e)||e===0)return;if((await S.stat(ls.homedir()).catch(()=>null))?.uid===e)throw new I("UNSAFE_CF_DIRECTORY",`everyapp is running as root (sudo) with your HOME
|
|
22
|
+
It would leave ~/.everyapp in ${ls.homedir()} to root.`,{fix:"run it without sudo"})}async function gd(e){let t;try{t=await S.stat(e)}catch(n){if(!ce(n))throw n;await S.mkdir(e,{recursive:!0,mode:xe});return}if(!t.isDirectory())throw Pe(e,"isn't a directory");let s=Wr(t);if(s){if(t.uid!==process.getuid?.()||!(t.mode&Gr))throw Pe(e,s);for(let n of await S.readdir(e))if((await S.lstat(N.join(e,n))).uid!==t.uid)throw Pe(e,`${s}, and ${n} in it belongs to another user`);await S.chmod(e,xe)}}async function hs(e){try{let t=await zr(e);if(t&&Mr(t))return;t&&await S.rm(e,{recursive:!0,force:!0});try{await S.mkdir(e,{mode:xe})}catch(n){if(n.code!=="EEXIST")throw n}if((await S.lstat(e)).isDirectory()&&await S.chmod(e,xe),!Mr(await S.lstat(e)))throw Pe(e,"can't be made a private directory")}catch(t){throw t instanceof I?t:Pe(e,`can't be made a private directory (${t.message}; was everyapp run with sudo?)`)}}function Mr(e){if(!e.isDirectory())return!1;let t=process.getuid?.();return t===void 0?!0:e.uid===t&&(e.mode&511)===xe}function Wr(e,{uid:t=process.getuid?.(),parent:s=!1}={}){return t===void 0?null:e.uid===t||e.uid===0||s&&t===0?e.mode&Gr?"is writable by other users":null:"is owned by another user"}async function yd(e){for(let t=await S.realpath(e);;t=N.dirname(t)){let s=Wr(await S.lstat(t),{parent:!0});if(s)throw new I("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=N.join(t,pd);if(await wd(n))throw new I("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:T()});if(N.dirname(t)===t)return}}function Pe(e,t){return new I("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:T()})}async function zr(e){try{return await S.lstat(e)}catch(t){if(ce(t))return null;throw t}}async function wd(e){try{return(await S.stat(e)).isFile()}catch{return!1}}import{execa as Ed}from"execa";var bd=6e4;function fs(e){return e[0]==="build"||e[0]==="dev"}async function gs(e,t){let s=["node","-p","process.versions.node"],n,r;try{n=await us(e);let o=n==="yarn"?s:n==="npm"?["exec","--",...s]:["exec",...s],{stdout:a}=await Ed(n,o,{cwd:e,env:t,extendEnv:!1,stdin:"ignore",timeout:bd});r=a.trim().split(`
|
|
26
|
+
`).at(-1)?.trim()??""}catch{return}if(!(!/^\d+\.\d+\.\d+$/.test(r)||is(r)))throw new I("NODE_TOO_OLD",`${n} runs this project's tools on Node.js ${r}; cf needs ${ie} 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 ${ie} or newer to load cloudflare.config.ts.`,{fix:"raise the pin (`volta pin node@22`, for Volta)",rerun:T()})}var kd=12e4,Sd=2e3;function qf(e={}){let t=e.resolveBinary??Nr,s=e.env??process.env,n=e.watchdogIdleMs??Sd,r;async function o(a,i,c={}){let p={...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:xr(s.NODE_OPTIONS)}:{},...c};return r??=Hr(),xd(p,await r)}return{async run(a){let i=await vd(a),c=await t(a.plane==="project"&&!a.cliCf?i:void 0),p=a.files?await Td(a.files):null;try{let l=typeof a.args=="function"?a.args(p?.paths??{}):[...a.args],f=await o(a.plane,a.mode,a.env);return a.plane==="project"&&fs(l)&&await gs(i,f),await Pd({binary:c,args:l,cwd:i,env:f,onOutput:a.onOutput,mode:a.mode,timeoutMs:a.timeoutMs??(a.mode==="interactive"?void 0:kd),watchdogIdleMs:a.local?n:void 0})}finally{await p?.remove()}},async start(a){let i=await t(a.cwd),c=await o("project","interactive",a.env);return fs(a.args)&&await gs(a.cwd,c),_r({command:process.execPath,args:[i.path,...a.args],cwd:a.cwd,env:c,hold:a.holdOutput??!1})}}}async function Id(e,t,s){let n=await e.run({...t,mode:"json"}),r=Br(t.args),o;try{o=JSON.parse(n.stdout)}catch{throw new Y(r,"stdout is not JSON")}let a=s.safeParse(o);if(!a.success)throw new Y(r,a.error.message);return a.data}async function Xf(e,t,s,{perPage:n,maxPages:r}){let o=[];for(let a=1;a<=r;a+=1){let i=await Id(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 vd(e){if(e.plane==="project"){if(!e.cwd)throw new Error("project-plane cf calls need a cwd");return e.cwd}return jr()}async function Td(e){let{dir:t,cleanup:s}=await Kr(Ur),n={};try{for(let[r,o]of Object.entries(e)){let a=pt.join(t,pt.basename(r));await Ad.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 Pd(e){let t=Br(e.args),s=e.mode==="interactive";return s&&st(),new Promise((n,r)=>{let o=_d(process.execPath,[e.binary.path,...e.args],{cwd:e.cwd,env:e.env,stdio:s?"inherit":["ignore","pipe","pipe"],detached:!s&&V}),a=Tr(o,!s&&V),i="",c="",p=!1,l,f=E=>{p||(p=!0,a(),clearTimeout(_),clearTimeout(l),E())},w=e.timeoutMs,_=w===void 0?void 0:setTimeout(()=>{rt(o,!s&&V),f(()=>r(new oe(t,w,X(c).at(-1)?.trim())))},w),u=()=>{e.watchdogIdleMs===void 0||p||!l&&!Rd(i)||(clearTimeout(l),l=setTimeout(()=>{rt(o,V),f(()=>n({stdout:i,stderr:c,stoppedByWatchdog:!0}))},e.watchdogIdleMs))};for(let[E,g]of[[o.stdout,b=>i+=b],[o.stderr,b=>c+=b]])E?.on("data",b=>{g(b.toString()),e.onOutput?.(b.toString()),u()});o.once("error",E=>f(()=>r(E))),o.once("close",E=>{f(()=>{if(E===0){let b=gr(t,c);b?r(b):n({stdout:i,stderr:c,stoppedByWatchdog:!1});return}let g=s?{message:`\`${t}\` exited with code ${E}`,apiCodes:[],kind:"unknown"}:yr(c,i);r(new j(g,{exitCode:E,stderr:c,stdout:i}))})})})}function xd(e,t){let s=Object.keys(e).find(r=>r.toUpperCase()==="PATH")??"PATH",n=(e[s]??"").split(pt.delimiter).filter(r=>r&&r!==t);return{...e,[s]:[t,...n].join(pt.delimiter)}}function Rd(e){let t=e.trim();if(!t)return!1;try{return JSON.parse(t),!0}catch{return!1}}function Br(e){return typeof e=="function"?"cf":["cf",...e].join(" ")}function Fr(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 ut(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 Qf(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 Od from"node:fs";var Yr="EVERYAPP_EVENT_LOG",ys;function ws(){let e=process.env[Yr];return e?(ys?.path!==e&&(ys={path:e,log:Cd(e)}),ys.log):null}function Cd(e){let t=!1;return{append(s){if(!t)try{let n=`${JSON.stringify({...s,pid:process.pid})}
|
|
28
|
+
`;Od.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 ${Yr}=${e} (${r}); not logging
|
|
29
|
+
`)}}}}function sg({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 Vr(e,t){ws()?.append({v:1,ts:t.toISOString(),...e})}function ng(e,t){ws()?.append({type:"exit",ts:new Date().toISOString(),code:(e%256+256)%256,ms:t})}import{stripVTControlCharacters as Nd}from"node:util";import Jr from"chalk";var Es=e=>Nd(e).length,$d=(e,t)=>e+" ".repeat(t-Es(e));function qr(e){let t=Math.max(...e.map(s=>s.label.length));return e.map(s=>`${Jr.dim(s.label.padEnd(t))} ${s.value}`)}function ig(e,t){let s=e.map((r,o)=>Math.max(Es(r),...t.map(a=>Es(a[o]??"")))),n=r=>r.map((o,a)=>a===r.length-1?o:$d(o,s[a])).join(" ");return[Jr.dim(n(e)),...t.map(n)]}import m from"chalk";import Qr from"cli-cursor";function dg(e){return(e?.public??[]).map(t=>Zr(t.path,t.methods))}function pg(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[Zr(r,Array.isArray(o)?o.filter(a=>typeof a=="string"):void 0)]}):[]}catch{return[]}}function ug(e){return e?.mcp?{by:e.mcp.by,why:e.mcp.why}:null}function lg(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 hg=e=>`MCP /mcp (${e.by})`;function Xr(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 Zr(e,t){return{path:e,methods:(t??["GET"]).map(s=>s.toUpperCase())}}function io(e=s=>process.stdout.write(s),t=()=>new Date){let s=po(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 os({stopping:n=>s.emit({type:"progress",step:"interrupt",message:n}),stopped:()=>{}}),s}function co(e={}){let t=e.verbose??!1,s=e.terminal??!1,n=e.now??Date.now,r=n(),o=e.writeProblem??(u=>void process.stderr.write(u)),a=new As(e.write??(u=>void process.stdout.write(u)),s,e.columns??(()=>process.stdout.columns??80),n);s&&wr(()=>a.handOver()),os({stopping:u=>a.interrupt(`${u} (Ctrl+C again to quit at once)`),stopped:u=>{a.finish(),u&&o(`${m.dim(u)}
|
|
31
|
+
`)}});let i=u=>a.aside(()=>o(`${u.join(`
|
|
32
|
+
`)}
|
|
33
|
+
`)),c=new Map,p=new Set,l=[],f=0,w=0,_=(u,E)=>{for(let g of u)if("line"in g)a.lines(g.line);else if("fact"in g)l.splice(g.lead?w++:l.length,0,g.fact);else if("done"in g){let b=g.detail??(E!==void 0&&E>=1e3?ut(E):"");a.lines([Ld(g.done,b),...(g.notes??[]).map(k=>m.dim(` ${k}`))].join(`
|
|
34
|
+
`))}};return po(u=>{switch(u.type){case"step":{for(let k of p)k!==u.step&&(a.drop(k),p.delete(k),c.delete(k));let E=Md[u.step]?.(u,k=>c.has(k)),g=E?[E].flat():[];if(u.status==="start"){c.set(u.step,n());let k=g.find(U=>"spin"in U);g.length===0&&t&&!s&&u.message&&a.lines(m.dim(u.message)),_(g),a.spin(u.step,k?k.spin:g.length>0?"":u.message??"");return}let b=c.get(u.step);c.delete(u.step),p.delete(u.step),a.stopSpinning(u.step),g.length>0?_(g,b===void 0?void 0:n()-b):t&&u.message&&a.lines(m.dim(u.message));return}case"progress":Kd.has(u.step)?a.lines(m.dim(u.message)):Ud[u.step]?.(u.data??{})?(c.has(u.step)||c.set(u.step,n()),s?a.spin(u.step,u.message):p.has(u.step)||a.lines(u.message),p.add(u.step)):t&&a.lines(m.dim(u.message));return;case"warning":{if(Gd.has(u.code)&&!t)return;f+=1,i([...ro(m.yellow("!"),u.message),..._s(u.data,{url:!0})]);return}case"action_required":{let[E="",...g]=u.message.split(`
|
|
35
|
+
`),b=[`${m.cyan("\u2192")} ${E}`,...u.data?.url?[` ${m.cyan(u.data.url)}`]:[],...u.data?.code?[` Code: ${m.bold(u.data.code)}`]:[],...g.map(k=>m.dim(` ${k}`))];if(u.data?.waiting){let k=u.step??u.action;a.lines(b.join(`
|
|
36
|
+
`)),c.set(k,n());let U=h(u.data.waitingFor);a.spin(k,U?`Waiting for ${U}`:"Waiting");return}a.finish(),o(`${[...b,...Wd(u.data?.choices),..._s(u.data)].join(`
|
|
37
|
+
`)}
|
|
38
|
+
`);return}case"error":{if(a.finish(),u.code==="CANCELLED"){o(`${m.dim(u.message)}
|
|
39
|
+
`);return}let E=t?h(u.data?.stack):void 0;o(`${[...ro(m.red("\u2717"),u.message),..._s(u.data,{url:!0}),...E?E.split(`
|
|
40
|
+
`).filter(g=>/^\s+at /.test(g)).map(g=>m.dim(` ${g.trim()}`)):[],...t?[m.dim(` Error code: ${u.code}`)]:[]].join(`
|
|
41
|
+
`)}
|
|
42
|
+
`);return}case"done":{a.finish();let E=n()-r,g=[...l,...zd(u.data?.facts)],b=Jd(u.data?.next),k=[...u.display!==void 0?u.display?[u.display]:[]:u.message?[m.green(u.message)]:[],...g.length>0?["",...qr(g)]:[],...E>=1e4&&u.display===void 0?[m.dim(`Done in ${ut(E)}${f>0?` with ${K(f,"warning")}`:""}`)]:[],...b.length>0?["","Next:",...qd(b)]:[]];k.length>0&&a.lines(k.join(`
|
|
43
|
+
`));return}}},t,n)}function xg(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 Ld(e,t){return`${e} ${m.green("\u2713")}${t?` ${m.dim(t)}`:""}`}function eo(e,t){return s=>s.status==="ok"?{done:e,detail:t}:null}function to(e,t){return s=>s.status==="start"?{spin:e}:s.status==="ok"?{done:t}:null}function de(e){return e.status==="start"?{spin:e.message??""}:e.status==="ok"&&e.message?{done:e.message}:null}var Md={"setup.account":e=>{if(e.status!=="ok")return null;let t=e.data??{};if(t.gateway===!0)return null;let s=h(t.email);return{line:`Setting up Every App in ${h(t.name)??h(t.id)}${s?m.dim(` (${s})`):""}`}},"setup.gateway":e=>{let t=e.data??{},s=h(t.releaseName),n=h(t.account),r=n?`${n}'s Gateway`:"the Gateway";if(e.status==="start"){let o=h(t.gatewayUrl)?.replace(/^https:\/\//,"");switch(t.change){case"install":{let a=Bd(t.expectedMinutes);return{line:`Installing the Gateway at ${o} (${s})${a?m.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=R(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 ${K(a,"app")}`,detail:i!==a?`was ${i}`:""}}return e.status!=="skip"?null:t.upToDate===!0?{done:`${Oe(r)} is up to date with ${s}`,detail:""}:e.message?{line:e.message}:null},"setup.owner":e=>{let t=h(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&&R(e.data?.applied).length===0)return null;let r=no(e,s||n?"Database":"Gateway database");return n?bs(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")?bs({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=h(t.version),n=h(t.organizationName),r=h(t.origin);return{line:[`Deploying ${h(t.appId)}${s?` ${s}`:""} to ${h(t.gatewayHost)}${n?m.dim(` (${n})`):""}`,...r?[m.dim(` From ${r}`)]:[]].join(`
|
|
44
|
+
`)}},"app.register":e=>{let t=e.data??{};if(e.status!=="ok")return null;let s=Fd(t.publicRoutes),n=Yd(t.mcp),r=[...s.length>0?[{fact:{label:"Public",value:Vd(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=h(t.organizationName),a=m.dim(`\xB7 change it at ${h(t.gatewayUrl)}/admin/apps`),i=t.scope==="shared"?`Members of every organization ${m.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
|
+
${m.dim(`The Gateway has no owner yet; its first owner gets the app (${ht} 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":eo("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:m.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"}:no(e,"Database"),"app.helper":e=>{let t=h(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 ${h(t.appId)} ${h(t.version)}`},{fact:{label:"Release",value:h(t.shown)??""}},{fact:{label:"SHA-256",value:h(t.sha256)??""}}]},"app.workflows":e=>e.status==="ok"?{done:`Deleted the Workflow ${h(e.data?.binding)}`}:null,"app.lease":so,"gateway.lease":so,"gateway.release":(e,t)=>{if(e.status!=="ok")return null;let s=e.data??{};if(s.downloaded===!0)return{done:`Downloaded Gateway ${h(s.release)}`};let n=h(s.origin?.path);return n?{done:`Loaded Gateway ${h(s.release)} from ${n}`,detail:""}:s.cached!==!1?null:t("gateway.upgrade")?bs({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=R(t.addresses),n=h(t.replyHint);return[...R(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 ${h(e.data?.appId)}'s public routes through`:`Cloudflare Access lets ${h(e.data?.appId)}'s public routes through`}:null,"app.bind":e=>e.status==="start"?{spin:`Adding ${h(e.data?.appId)} to the Gateway...`}:e.status==="ok"?{done:"Added to the Gateway"}:null,"gateway.upgrade":e=>e.status==="start"?{line:m.bold(`Gateway ${h(e.data?.from)} \u2192 ${h(e.data?.to)}`)}:null,"app.live":e=>{let t=e.data??{},s=h(t.url)??`https://${h(t.hostname)}`;if(e.status==="skip")return Hd(t,s);if(e.status!=="ok")return null;let n={fact:{label:"Live",value:m.cyan(s)},lead:!0},r=h(t.waited);return r?[{done:r==="certificate"?"Certificate issued":"Live"},n]:n},"app.delete":e=>{let t=h(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 ${h(e.data?.hostname)}'s certificate`}:null,"app.purge":e=>{let t=h(e.data?.appId);if(e.status==="start")return{spin:`Deleting ${t}'s Worker and data...`};if(e.status!=="ok")return null;let s=R(e.data?.kinds);return s.length>0?{done:`Deleted ${t}'s ${mt(s)}`}:{line:m.dim(`Nothing of ${t}'s was left to delete in Cloudflare`)}},"create.copy":e=>{let t=e.data??{};return e.status==="start"?[{line:`Creating ${h(t.appId)} in ${h(t.shown)}`},...t.elsewhere===!0?[{line:m.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:de(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=R(t.signIn?.pending);return{done:"Cloudflare Access on",detail:n.length>0?`sign-in with ${n.join(" or ")}`:void 0,notes:r.length>0?[`${mt(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":de,"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:m.dim(e.message)}:null,"events.deliver":de,"create.skill":de,"create.install":to("Installing dependencies...","Installed dependencies"),"create.types":to("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":eo("Worker types generated",".cloudflare/types"),"dev.migrations":e=>{if(e.status==="skip")return e.data?.reason==="flag"?{line:m.dim("Skipped local migrations (--skip-migrations)")}:null;if(e.status!=="ok")return null;let t=R(e.data?.applied);return{done:t.length?`${K(t.length,"local migration")} applied`:"Local database up to date"}},"dev.app":e=>e.status==="ok"?[{done:`${h(e.data?.appId)??"The app"} is running locally`},...e.message?[{line:e.message}]:[]]:null,"dev.stop":e=>{let t=h(e.data?.appId)??"the app";return e.data?.started===!0?{done:`${t} stopped`}:{line:m.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=R(e.data?.applied);return{done:"Set up the local database",...t.length?{detail:K(t.length,"migration")}:{}}},"cloudflare.login":e=>{let t=e.data??{},s=h(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:m.dim(e.message)};if(e.status!=="ok")return null;let t=R(e.data?.applied);return t.length?{done:`${K(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 ${h(e.data?.database)} database...`}:null,"teardown.check":de,"teardown.inventory":e=>e.status==="start"?{spin:e.message??""}:null,"teardown.plan":e=>e.status==="ok"?{done:e.message??"",notes:R(e.data?.lines)}:null,"teardown.delete":de,"db.restore":e=>{if(e.status==="start")return{spin:"Restoring..."};if(e.status!=="ok")return null;let t=e.data??{},s=h(t.appId);return{done:`Restored ${s?`${s}'s`:"the Gateway's"} database`,detail:`before ${R(t.migrations).join(", ")}`}}},Gd=new Set(["CUSTOM_DOMAIN_OWNER_UNCHECKED"]);function so(e){return e.status==="ok"?{done:`Other ${h(e.data?.waitedFor)??"run"} finished`}:null}var Re=()=>!0,jd=e=>e.host===void 0,Ud={"app.release":Re,"app.lease":Re,"gateway.lease":Re,"db.lease":Re,"app.live":Re,"gateway.tls":jd},Kd=new Set(["dev.mcp","dev.session"]);function no(e,t){if(e.status!=="ok")return null;let s=e.data??{},n=R(s.applied);if(n.length===0)return{done:`${t} up to date`};if(s.fresh===!0)return{done:`${t} created`,detail:K(n.length,"migration")};let r=h(s.restoreCommand);return{done:`${t} migrated`,detail:n.join(", "),notes:r?[`Restore point saved. To undo: ${r}`]:[]}}function bs(e){return!e||!("done"in e)?e:{...e,done:` ${e.done}`,...e.notes?{notes:e.notes.map(t=>` ${t}`)}:{}}}function Hd(e,t){if(e.reason==="outside-base")return[{fact:{label:"Live",value:m.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:m.cyan(t)},lead:!0},...s?[{fact:{label:"Status",value:s},lead:!0}]:[]]}function ro(e,t){let[s="",...n]=t.split(`
|
|
46
|
+
`);return[`${e} ${s}`,...n.map(r=>m.dim(` ${r}`))]}function _s(e,{url:t=!1}={}){let s=h(e?.didYouMean),n=h(e?.usage),r=h(e?.fix),o=t?h(e?.url):void 0,a=h(e?.rerun)??h(e?.help),i=h(e?.rerunNote);return[...s?[` Did you mean ${m.bold(s)}?`]:[],...n?[m.dim(` Usage: ${n}`)]:[],...r?[` Fix: ${r}`]:[],...o?[` ${m.cyan(o)}`]:[],...a?[` ${e?.authorize===!0?"To go ahead anyway":"Run"}: ${m.bold(a)}${i?` ${m.dim(i)}`:""}`]:[]]}function Wd(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=>` ${m.bold(n.rerun.padEnd(s))}${n.label?` ${m.dim(n.label)}`:""}`)}function zd(e){return Array.isArray(e)?e.map(t=>({label:t.label,value:`${/^https?:\/\//.test(t.value)?m.cyan(t.value):t.value}${t.note?` ${m.dim(t.note)}`:""}`})):[]}function Bd(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 Fd(e){return Array.isArray(e)?e.map(t=>t):[]}function Yd(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 Vd(e){let{shown:t,more:s}=Xr(e);return`Open to the internet without sign-in: ${t}${s>0?m.dim(` \u2026 and ${s} more (everyapp.config.ts public)`):""}`}function Jd(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?{command:t}:t):[]}function qd(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)} ${m.dim(n.note)}`:` ${t(n)}`)}var oo=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Xd=80,ao=3e4,As=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||(Qr.hide(process.stdout),this.timer=setInterval(()=>{this.frame=(this.frame+1)%oo.length,this.draw()},Xd),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(`${m.dim(t)}
|
|
48
|
+
`)}settle(){this.steps.length===0&&this.stopTimer(),this.draw()}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0,this.terminal&&Qr.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<ao)return;let n=t.label.replace(/\.{3}$|…$/,"");this.write(`${m.dim(`still ${n.charAt(0).toLowerCase()}${n.slice(1)} \xB7 ${Fr(s)}`)}
|
|
49
|
+
`)},ao),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 ${ut(s)} `:""}${oo[this.frame]}`,r=Math.max(this.columns()-1,10);this.write(`\r\x1B[2K${m.dim(n.length>r?`\u2026${n.slice(n.length-r+1)}`:n)}`),this.drawn=!0}};function po(e,t,s){let n=s(),r=new Set,o=!1,a=!1,i=!1;return{emit(c){let p=c;if(p.type==="warning"){let l=`${p.code}
|
|
50
|
+
${p.message}`;if(r.has(l))return;r.add(l)}else p.type==="done"&&(p={...p,data:{...p.data,durationMs:s()-n}});p.type==="error"?o=!0:p.type==="action_required"?p.data?.waiting?i=!0:a=!0:p.type==="done"&&(i=!1),e(p),Vr(p.type==="done"?{...p,display:void 0}:p,new Date(s()))},get exitCode(){return o?1:a||i?2:0},verbose:t}}var uo;function lo(e){uo=e,process.exitCode=e}function Og(){return uo}var Zd="https://dash.cloudflare.com/?to=/:account/workers/plans",Qd="https://dash.cloudflare.com/profile",ep=new Set(["ECONNREFUSED","ECONNRESET","ENOTFOUND","EAI_AGAIN","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_SOCKET"]);function mo(e,t,s){let n=fr(t),r=f=>n?`${f}
|
|
51
|
+
The database stays migrated. To roll it back: ${n.restoreCommand}`:f,o=n?{rollbackCommand:n.rollbackCommand}:{},a=s?{step:s}:{},i=(f,w,_)=>e.emit({type:"action_required",action:f,message:r(w),...a,data:{..._,...o}}),c=(f,w,_,u)=>e.emit({type:"error",code:f,message:r(w),retryable:_,...a,data:{...u,...o}});if(t instanceof tt){i(t.action,t.message,{...t.data,...t.url?{url:t.url}:{},...t.rerun?{rerun:t.rerun}:{},...t.rerunNote?{rerunNote:t.rerunNote}:{}});return}if(Se(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:Zd,rerun:T()});return}if(t instanceof I){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 p=tp(t);if(p){c(p.code,p.message,p.retryable,{...p.data,...p.retryable?{rerun:T()}:{}});return}let l=t instanceof Error?t:new Error(String(t));c("UNEXPECTED",`everyapp hit an unexpected error
|
|
53
|
+
${l.name}: ${l.message}
|
|
54
|
+
This is a bug in everyapp, not something you did.`,!1,{...l.stack?{stack:l.stack}:{},...e.verbose?{}:{rerun:T(["--verbose"]),rerunNote:"for a stack trace to report"}})}function tp(e){if(!(e instanceof Error))return null;if(Se(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:Qd,cloudflare:e.message}};if(e instanceof j)return{code:`CF_${e.kind.toUpperCase()}`,message:e.message,retryable:!1};if(e instanceof oe)return{code:"CF_TIMEOUT",message:e.message,retryable:!0};if(e instanceof Y)return{code:"CF_OUTPUT",message:e.message,retryable:!1};if(e instanceof A)return{code:"INVALID_MANIFEST",message:e.message,retryable:!1};let t=ho(e)??ho(e.cause);return t&&ep.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 ho(e){let t=e?.code;return typeof e=="object"&&typeof t=="string"&&/^[A-Z_]+$/.test(t)?t:void 0}function sp(e,t){return e?io():co({verbose:t,terminal:Er()})}async function np(e,t){try{await t()}catch(s){mo(e,s)}lo(e.exitCode)}async function Hg(e,t){let s=sp(e.json,e.verbose);await np(s,()=>t(s))}export{ap as a,ip as b,ht as c,T as d,cp as e,K as f,Oe as g,h,pp as i,X as j,mt as k,R as l,si as m,ni as n,ri as o,Rl as p,$n as q,Ol as r,Cl as s,Nl as t,Hp as u,Wp as v,jo as w,zp as x,Bp as y,Ws as z,zs as A,Fp as B,x as C,O as D,D as E,ft as F,Q as G,$s as H,_o as I,Sp as J,Ln as K,Ll as L,Ml as M,Ds as N,vp as O,So as P,yt as Q,Tp as R,Ce as S,Pp as T,xp as U,le as V,xo as W,he as X,H as Y,Np as Z,$p as _,js as $,Us as aa,Ne as ba,Mp as ca,$e as da,Gp as ea,Hs as fa,jp as ga,Up as ha,Bs as ia,Fs as ja,Vo as ka,Jo as la,Zp as ma,Qp as na,Zo as oa,Qo as pa,Zs as qa,eu as ra,Qs as sa,tu as ta,su as ua,nu as va,tn as wa,cu as xa,Le as ya,nn as za,du as Aa,pu as Ba,uu as Ca,hu as Da,mu as Ea,fu as Fa,gu as Ga,yu as Ha,Eu as Ia,Gn as Ja,zl as Ka,Bl as La,Fl as Ma,Yl as Na,Vl as Oa,Jl as Pa,ql as Qa,Xl as Ra,Ql as Sa,eh as Ta,th as Ua,sh as Va,nh as Wa,rh as Xa,ca as Ya,It as Za,vt as _a,ku as $a,Ii as ab,ph as bb,Ci as cb,$i as db,Pa as eb,vu as fb,em as gb,tm as hb,zn as ib,ir as jb,yc as kb,A as lb,im as mb,cm as nb,dm as ob,pm as pb,Fn as qb,Ac as rb,kc as sb,ur as tb,Sc as ub,um as vb,lm as wb,hm as xb,mm as yb,Ic as zb,gm as Ab,I as Bb,tt as Cb,mr as Db,km as Eb,Sm as Fb,j as Gb,Se as Hb,Tm as Ib,oe as Jb,_r as Kb,st as Lb,xm as Mb,jm as Nb,Um as Ob,Pr as Pb,xr as Qb,zm as Rb,Or as Sb,Yc as Tb,Nr as Ub,qc as Vb,sf as Wb,nf as Xb,ce as Yb,Kr as Zb,ds as _b,bf as $b,qf as ac,Id as bc,Xf as cc,dg as dc,pg as ec,ug as fc,lg as gc,hg as hc,Xr as ic,Fr as jc,ut as kc,Qf as lc,sg as mc,ng as nc,qr as oc,ig as pc,xg as qc,Ld as rc,Og as sc,mo as tc,sp as uc,np as vc,Hg as wc};
|