[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ECHN29H5DCSCB4D737GAZK":3,"skill-same:01M7ECHN29H5DCSCB4D737GAZK":49},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":6,"ownerDescription":27,"updatedAt":28,"install":29,"resources":42},"01M7ECHN29H5DCSCB4D737GAZK","cortexcloud-api-category",null,"jonahthan433\u002FCortexOS","jonahthan433","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211465495?v=4","01M7ECH9HPHGA89DCXHHJBTS3C","jonah.ai","01M7ECH9JCEM45DZMWPT7148S1",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fimported\u002F.archive\u002Fcortexcloud-api-category\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# cortexcloud-api-category\n\n# Build a new CortexCloud API category\n\nUse when adding a new endpoint group behind x402\u002FMPP on CortexCloud\n(e.g. the ML and Automation tiers already built this way). Reuse, don't\nrebuild: x402\u002FMPP settlement, `X402RateLimitMiddleware`,\n`InputValidationMiddleware`, `ROUTE_PRICING`\u002F`ROUTE_DESCRIPTIONS`\u002F\n`FREE_ROUTES`, Bazaar `_TOOLS`, OpenAPI regen, `BaseProvider`\u002Fpricing,\nfeature flags.\n\n## Recipe (minimal diff)\n1. `app\u002Fcore\u002Fconfig.py`: master `X_ENABLED` (default **False**) + per-endpoint\n   gates `X_TRANSFORM_ENABLED` etc. (default True) + any secrets.\n2. `app\u002Fx402\u002Fpricing.py`: add `X_FLOOR` dict + `x_price_usd(ep)` using\n   `pegged_price(0.0, floor=...)`; register ROUTE_PRICING \u002F ROUTE_DESCRIPTIONS\n   \u002F FREE_ROUTES entries (incl. a free `\u002Fv1\u002Fx\u002Festimate`).\n3. `app\u002Fmiddleware\u002Fx402.py`: add `elif path.startswith(\"\u002Fv1\u002Fx\u002F\")` branch that\n   (a) returns **503 before the 402 challenge** if disabled (see pitfall),\n   (b) sets `request.state.category=\"x\"` + `provider_cost_usd`.\n4. `app\u002Fapi\u002Fx.py`: router + routes; `_disabled(ep)` returns 503 when master or\n   per-endpoint flag off; free `\u002Festimate` must NOT gate on master flag.\n5. `app\u002Fx402\u002Fbazaar.py`: add `_TOOLS` entries (paid + free).\n6. `app\u002Fmain.py`: `include_router` (one line, in the additive block).\n7. `tests\u002Ftest_x.py` + `scripts\u002Fx_paid_smoke.py` (reuse SDK `sign_payment`).\n8. Branch from `main` (NOT a sibling feature branch — keep others frozen).\n   `X_ENABLED=false`. Do NOT merge\u002Fdeploy without explicit approval.\n\n## Pitfalls (learned the hard way)\n- **MIDDLEWARE PRE-402 GATE (charge-then-fail trap).** The x402 middleware\n  runs OUTER to your route. If you gate only in the route (`_disabled()`),\n  the middleware already emitted a **402 payment challenge** → the client\n  pays, then hits your 503. Gate in the middleware branch BEFORE\n  `usd_to_usdc_atomic(price_str)` \u002F challenge build:\n  `if not settings.X_ENABLED: return JSONResponse(503, {...})`.\n  See `references\u002Fmiddleware-gate.md` for the exact snippet.\n- **Free `\u002Festimate` must bypass the master gate.** If it calls `_disabled()`\n  it 503s when the category is disabled, hiding pricing. Gate only paid routes.\n- **JSONB import**: `from sqlalchemy.dialects.postgresql import JSONB`\n  (NOT `from sqlalchemy import JSONB` — ImportError on SQLAlchemy 2.x).\n- **Self-hosted pricing**: provider cost ~$0 → `pegged_price(0.0, floor=X)`\n  returns exactly X (max(X, 0*1.35+0.0015)). Use per-endpoint floors.\n- **Provider-funding blocker, don't fake green.** If an endpoint can't be\n  validated because the upstream needs credits (OpenRouter 0 credits → paid\n  model 402; free models throttled 429\u002F502; fal TOP_UP-locked; Replicate\n  needs credit — a saved card is NOT credit), **report the blocker honestly**.\n  Do NOT keep trying free providers or hack code to force a green smoke.\n  Self-hosted endpoints (no external provider) validate immediately via paid\n  smoke. This is a standing user preference, not optional.\n- **5xx after x402 settlement charges the customer** — there is no refund\n  mechanism in the platform. Keep provider calls behind payment; fail fast on\n  invalid input. This is a platform-wide limitation, not a per-category fix.\n\n## Reuse pointers\n- Paid smoke: `sdk\u002Fpython\u002Fcortexcloud\u002Fsigning.py: sign_payment(challenge, key)`\n  → resubmit with `payment-signature` header. Same pattern as Data\u002FML smoke.\n- HMAC webhook signatures: `hmac.new(secret, body, sha256).hexdigest()`,\n  header `X-Cortex-Signature: sha256=\u003Csig>`.\n- SSRF guard (for egress endpoints): block private\u002Floopback\u002Flink-local\u002F\n  metadata (169.254.169.254) IPs, re-check resolved IPs (DNS-rebinding),\n  validate redirect targets through the same guard; cap body + timeout.\n- Postgres for durable state (e.g. scheduled jobs): define an ORM model in\n  `app\u002Fmodels\u002F`, register it in `app\u002Fmodels\u002F__init__.py`, create the table\n  with `AsyncEngine.begin() -> conn.run_sync(Model.__table__.create,\n  checkfirst=True)` (not `AsyncEngine.run_sync` — that API doesn't exist).\n",{},"main","38b32c99e7ed0b8e215d638e92cfa452c1ec3079","skills\u002Fimported\u002F.archive\u002Fcortexcloud-api-category","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS","https:\u002F\u002Fgithub.com\u002Fjonahthan433","AI Consultant","2026-10-24 05:13:39",{"source":7,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add jonahthan433\u002FCortexOS --skill cortexcloud-api-category",{"tool":35,"command":36},"bunx","bunx skills add jonahthan433\u002FCortexOS --skill cortexcloud-api-category",{"tool":38,"command":39},"pnpm","pnpm dlx skills add jonahthan433\u002FCortexOS --skill cortexcloud-api-category","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fimported\u002F.archive\u002Fcortexcloud-api-category\u002FSKILL.md",true,[43],{"path":44,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":47,"sourceHtmlUrl":48},"skill.json","REFERENCE","参考文档",368,"https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fimported\u002F.archive\u002Fcortexcloud-api-category\u002Fskill.json",[50,56,62,68,74,80],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M7EDQZDQX3Q8Y7GCQX6KN9V7","opportunity-brief","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fsales\u002Fopportunity-brief\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M7EDQYA0V9Y99VKBREJJ3MRT","morning-intel","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fmorning-intel\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M7EDQVX1JVY0B6PDHKKGM19G","decision-brief","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fdecision-brief\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M7EDQV1GENZAC2SZSD8KZ3GM","weekly-review","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fproductivity\u002Fweekly-review\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7EDQT2KETJ1Y3CGVN9EKW2J","system-health","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fops\u002Fsystem-health\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M7EDQQN2JK3XPWMS1M4T0F3K","backup-restore","https:\u002F\u002Fgithub.com\u002Fjonahthan433\u002FCortexOS\u002Fblob\u002Fmain\u002Fskills\u002Fops\u002Fbackup-restore\u002FSKILL.md",[],[]]