diff --git a/.agents/skills/database-security-review/SKILL.md b/.agents/skills/database-security-review/SKILL.md index ab05dccf..12c1e07e 100644 --- a/.agents/skills/database-security-review/SKILL.md +++ b/.agents/skills/database-security-review/SKILL.md @@ -13,3 +13,7 @@ Use repository scripts rather than rebuilding the audit. Read docs/security/2026 - Apply only reviewed, authorized migration SQL, then run npm run check:security with backend URL/publishable key from the environment. Reports must be nonempty. Run npm run check:project and PR checks before merge and app deploy. - Re-run Lovable scans. Classify remaining intentional behavior only with specific guard evidence and tests. Do not ignore a whole group to hide unreviewed functions. - Verify the exact Git commit in Lovable's tracked branch and confirmed publication plus production health. Do not switch tracked branches, resize the database or change a plan as part of a security fix. + +For advanced application findings, also trace every HTTP, server-function and MCP entry point. Test identity binding and anonymous capabilities centrally; do not treat a database UUID as authorization. Keep public catalogue metadata separate from paid prompt contents. Caller telemetry cannot attest itself as verified. Checkout quantities must follow the exact product lookup key, and redirects must use an explicit origin allowlist. + +Run `node --experimental-strip-types --test tests/security-findings.test.ts` and `scripts/test-advanced-security.sql` after the corresponding migration inside a rolled-back transaction. Verify legitimate star increments/decrements as well as denied direct count updates. Check for concurrent Lovable edits before committing or applying migrations; preserve stronger guards already present. Re-scan the exact integrated commit before publishing. diff --git a/docs/security/20261123-advanced-findings.md b/docs/security/20261123-advanced-findings.md new file mode 100644 index 00000000..a1951088 --- /dev/null +++ b/docs/security/20261123-advanced-findings.md @@ -0,0 +1,49 @@ +# Advanced security review — 2026-11-23 + +Reviewed all 22 groups from the advanced Lovable scan (9 critical groups). The scan grouped 27 underlying findings. During the review, a parallel Lovable run committed `e4e9fbd4`; this change builds on that commit and preserves its managed cron authentication, public classification column, RLS fixes and one-shot diagnosis writes. No database plan or size changed. + +## Disposition of the original groups + +| # | Group | Disposition and evidence | +| --- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | Unverified email joins workspace (critical) | Auto-confirm email disabled in Lovable Auth. `team_action` requires a sent-and-confirmed link or a provider-verified matching address; existing auto-confirmed accounts do not qualify. SQL tests deny an unverified invite, then accept after genuine confirmation timestamps. | +| 2 | Public private drift (critical) | `compute_skill_drift` service-only; role probes reject authenticated callers. | +| 3 | Cross-user diagnoses / curriculum (critical, 2 findings) | Central identity/capability check covers HTTP, server functions and MCP. Owned records require verified owner. Anonymous references are HMAC-signed; raw UUIDs and tampered references fail. One-shot updates prevent overwrites. | +| 4 | Authors forge stars (critical) | Insert count forced to zero; direct updates preserve prior count; nested star trigger may update. SQL tests verify denial plus real increment/decrement. | +| 5 | Approved version tampering / unpurchased customization (critical, 2 findings) | Author writes denied for approved live versions. Customizations require purchase both in RLS and execution; initial state must be queued with empty results. | +| 6 | Unpublished Forge reports (critical) | Public only for approved published free packages; private/paid reports require author/admin. | +| 7 | Forged MCP usage history | `mcp_check_and_log_call` server-only. | +| 8 | Restricted classifications in discovery | Public classification is now `packages.vertical`; discovery no longer loads restricted version rules. Categories remain public by product intent. | +| 9 | Paid instructions in detail | Shared public detail cache omits paid prompt, rules and examples. Full HTTP/MCP deliveries check author/admin/direct or pack purchase; paid responses use private/no-store. Exports resolve the approved latest version. | +| 10 | Inflated trust from self-reports | Public/MCP reports remain unverified. Trust RPC, cached v2 scores and weekly snapshots count only server-attested `is_verified` runs. Existing reports are not retroactively trusted. Cached v2 scores recomputed. | +| 11 | Caller-controlled favorites expose private packages | Reads use the caller's RLS-scoped client. Star inserts require published/approved packages. | +| 12 | Restricted classifications in list | Same public-column boundary as #8. | +| 13 | Precise individual execution timestamps | Public evaluation data no longer queries or returns the last execution timestamp. | +| 14 | Hidden packages via stars | Caller-scoped reads enforce package visibility. | +| 15 | Cross-user credit balance | `get_credit_balance` uses invoker privileges/RLS; SQL probe denies another account's balance. | +| 16 | Transactional SECURITY DEFINER functions (informational, 4 findings) | Intentionally retained: claim_referral, purchase_pack, purchase_package, team_action require authentication and bind writes to auth.uid(); team accept strengthened in #1. Definer existence alone is not a vulnerability. | +| 17 | Arbitrary checkout return URL | Exact project/domain hosts, HTTPS, no userinfo or arbitrary ports. Reject lookalike preview hosts containing the project UUID. | +| 18 | CRM privileged actions (critical, 3 findings) | All three routes call managed `authenticateCronRequest`, never publishable keys. Scheduler secret configured by Lovable; current/previous secret tests pass. | +| 19 | Arbitrary transactional email (critical) | Generic template sender requires verified JWT plus administrator role, before body/template processing. Auth email webhook and managed CRM retain their own trusted paths. | +| 20 | Publicly triggerable scheduled CRM | Duplicate surface of #18. Also revoked public execution on nightly trust recompute and weekly snapshots; existing owner-run SQL cron remains functional. | +| 21 | Unreleased compatibility results | Requires an approved published package before querying results. | +| 22 | Caller-chosen checkout quantity (critical) | Pro/other products always quantity 1; only exact sak_agent_pass_monthly supports seats. Browser adjustable flag cannot override product policy. | + +## Additional related gaps closed + +Stripe customer reuse is bound to verified user UUID metadata; an unverified email claim can no longer reassign another customer's metadata. Both `has_active_subscription` overloads now use invoker/RLS privileges. Security audit RPCs remain public intentionally: they expose booleans for deployment checks, not customer records or credentials. + +## Validation and reusable workflow + +- `scripts/test-advanced-security.sql`: synthetic fixtures, negative/positive role probes, always rolled back. Tested together with the migration before applying it. +- `scripts/test-security-boundaries.sql`: previous role regression suite; updated expected report count to 8. +- `npm run check:rpc-security`: 8 nonempty named checks, including 29 service-only RPC signatures, account read isolation, verified telemetry and customization ownership. +- `tests/security-findings.test.ts`: managed cron, capability integrity, exact product quantities and redirect boundaries. +- `tests/diagnosis-persistence.test.ts`: bundled real server round trip against a stub database; verifies signed external reference but raw UUID foreign keys and cross-owner denial. +- Existing `database-security-review` skill extended with the proven advanced-review method. + +Jev 1.14.0 advisory review flagged the initial anonymous UUID-as-capability boundary (gap probability 0.83). That design was replaced with HMAC references and tested. It supported separating verified trust from self-reported telemetry (0.82); classification evidence was less decisive (0.61), so the integrated implementation explicitly separates public metadata in its own column. Jev is not an approval or security gate. + +Anonymous exams created before this change must be restarted; plain UUIDs no longer authorize anonymous history. Rotating the server signing credential invalidates anonymous capabilities. No existing user records are deleted. Historical unverified telemetry remains stored but no longer increases verified trust. + +Validation recorded: 466 tests passed; all 12 project checks passed (the final lint rerun reports 825 files, 0 blocking errors and 0 explicit-any violations). Both SQL probe suites passed in rolled-back transactions; the applied migration returned 8/8 named security checks. Generated Supabase files received formatting-only normalization required by the repository lint. The platform dependency change had left npm's lockfile stale; it is synchronized without changing package versions beyond that existing platform update. diff --git a/package-lock.json b/package-lock.json index e6a6c539..3ec5fe90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ "jszip": "^3.10.1", "lucide-react": "^0.575.0", "mcp-tanstack-start": "^0.4.1", - "nitro": "3.0.260903-beta", + "nitro": "3.0.260603-beta", "react": "^19.2.0", "react-day-picker": "^9.14.0", "react-dom": "^19.2.0", @@ -83,7 +83,7 @@ }, "devDependencies": { "@eslint/js": "^9.32.0", - "@lovable.dev/vite-tanstack-config": "2.26.5", + "@lovable.dev/vite-tanstack-config": "2.27.1", "@types/node": "^22.16.5", "@types/react": "^19.2.0", "@types/react-dom": "^19.2.0", @@ -2386,9 +2386,9 @@ } }, "node_modules/@lovable.dev/vite-tanstack-config": { - "version": "2.26.5", - "resolved": "https://registry.npmjs.org/@lovable.dev/vite-tanstack-config/-/vite-tanstack-config-2.26.5.tgz", - "integrity": "sha512-nRaztSS5BDM/d6oW/h2ev9l7RcjULxvWZtmrAwvI7rVQ9dPfNCBjNGmtiy8/THyYfFlcq+R2oLb4yaUBfneB6w==", + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/@lovable.dev/vite-tanstack-config/-/vite-tanstack-config-2.27.1.tgz", + "integrity": "sha512-200v7wa1/YeE5mrI+Q4dFNcYkCZQxp6o1jKzUVQQBXyZ3BHLPJ0+ghVSmneFGmpKAAGWpCmDLklTpoM6PZ6utw==", "dev": true, "license": "MIT", "dependencies": { @@ -6608,9 +6608,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6631,9 +6628,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6654,9 +6648,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -6677,9 +6668,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -8108,10 +8096,38 @@ "license": "MIT" }, "node_modules/db0": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/db0/-/db0-0.4.1.tgz", - "integrity": "sha512-6RBY/bSn42UrqATwsiULj2uYFyEykB3XeA/NLIVQeHNXlYV6D4Idxx3/aa6k5Y45Dwzx7sygeLotnqHWSeURYA==", - "license": "MIT" + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/db0/-/db0-0.3.4.tgz", + "integrity": "sha512-RiXXi4WaNzPTHEOu8UPQKMooIbqOEyqA1t7Z6MsdxSCeb8iUC9ko3LcmsLmeUt2SM5bctfArZKkRQggKZz7JNw==", + "license": "MIT", + "peerDependencies": { + "@electric-sql/pglite": "*", + "@libsql/client": "*", + "better-sqlite3": "*", + "drizzle-orm": "*", + "mysql2": "*", + "sqlite3": "*" + }, + "peerDependenciesMeta": { + "@electric-sql/pglite": { + "optional": true + }, + "@libsql/client": { + "optional": true + }, + "better-sqlite3": { + "optional": true + }, + "drizzle-orm": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "sqlite3": { + "optional": true + } + } }, "node_modules/debug": { "version": "4.4.3", @@ -8771,7 +8787,7 @@ "version": "0.45.4", "resolved": "https://registry.npmjs.org/drizzle-orm/-/drizzle-orm-0.45.4.tgz", "integrity": "sha512-NiM1YZpJ2UxyeE67DpDDZ+Tsw4YLX3trSlkNT7Tm9eKoUNb1LvaAaQzXgYQsWs+AQ9TUmmwMmBOCXuqqxUWKKQ==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", "peerDependencies": { "@aws-sdk/client-rds-data": ">=3", @@ -8992,33 +9008,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/env-runner": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/env-runner/-/env-runner-0.2.3.tgz", - "integrity": "sha512-S8EFBKyznRwPVwayK187cYjvnpgC92xy+q0BIF++V965pfjMVVRbQ/HoTYGA/1EHmZ7E68k6Heq+4WnvVhOL5w==", - "license": "MIT", - "dependencies": { - "crossws": "^0.4.12", - "exsolve": "^1.1.1", - "httpxy": "^0.5.5", - "srvx": "^1.0.5" - }, - "bin": { - "env-runner": "dist/cli.mjs" - } - }, - "node_modules/env-runner/node_modules/srvx": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/srvx/-/srvx-1.0.5.tgz", - "integrity": "sha512-KvSKRpgPG/oaq3cyT614OQ2bAa7DynuGamivCZeoZzIUULOdbQz6wUtnnVuC4+DCx2Zglzo8v5gBYmWIWYhDxA==", - "license": "MIT", - "bin": { - "srvx": "bin/srvx.mjs" - }, - "engines": { - "node": ">=20.16.0" - } - }, "node_modules/error-stack-parser-es": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", @@ -9838,13 +9827,13 @@ "license": "ISC" }, "node_modules/h3": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/h3/-/h3-2.0.2.tgz", - "integrity": "sha512-+/zvHSNldYpNURuUUG+y1KzdASUhNnSd1VpqxYFVY40ov3YzuBnCETaUQaT+QbKkoxhh9LRa6AEQdB14LALwdA==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/h3/-/h3-2.0.8.tgz", + "integrity": "sha512-ENuKlF9kC6E6PrvY1PUyE0qkrnnPTIt2/v48uyEEfTVfgoiqBCE0uwwf++2XrWwT1gxjQBDLQ8PAsmZVniKvTw==", "license": "MIT", "dependencies": { "rou3": "^1.0.0", - "srvx": "^1.0.5" + "srvx": "^1.0.6" }, "bin": { "h3": "bin/h3.mjs" @@ -9900,9 +9889,9 @@ } }, "node_modules/h3/node_modules/srvx": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/srvx/-/srvx-1.0.5.tgz", - "integrity": "sha512-KvSKRpgPG/oaq3cyT614OQ2bAa7DynuGamivCZeoZzIUULOdbQz6wUtnnVuC4+DCx2Zglzo8v5gBYmWIWYhDxA==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/srvx/-/srvx-1.0.8.tgz", + "integrity": "sha512-ngFS/J6St4PJfHRHGjr78xkPPtbyXtdMOLNE4x/XZunEK3OhV7aGUWMHf9WTUEy6wm1U0W4okkd82ZFFWRVQTw==", "license": "MIT", "bin": { "srvx": "bin/srvx.mjs" @@ -9955,9 +9944,9 @@ } }, "node_modules/hookable": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/hookable/-/hookable-6.1.1.tgz", - "integrity": "sha512-U9LYDy1CwhMCnprUfeAZWZGByVbhd54hwepegYTK7Pi5NvqEj63ifz5z+xukznehT7i6NIZRu89Ay1AZmRsLEQ==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/hookable/-/hookable-6.1.2.tgz", + "integrity": "sha512-+abwxtiEA52GCVIsQqut3S/uKTbUwYIp4Pe/vv+6py5XiXBCqMZHg6pA6Y5qhgLSEys0/cYuPbO0z1QFj5ZCmg==", "license": "MIT" }, "node_modules/html-to-text": { @@ -10036,9 +10025,9 @@ } }, "node_modules/httpxy": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/httpxy/-/httpxy-0.5.5.tgz", - "integrity": "sha512-uDjmnPyp1q4Sgzf3w+J/Fc6UqcCEj0x4Wjp7OqK5dGhNeDgpyrAmnS6ey8QWrX3SWDon2DMKf9sBa5X9+CVyMA==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/httpxy/-/httpxy-0.5.6.tgz", + "integrity": "sha512-iqc3nOxvNb5FxbhJozt8wNmHgjlmk4zzba512jMEXVwHCEBCbGAj49eGfy5PI8ts3/LFSFq8siiSNqwfY1AlfQ==", "license": "MIT" }, "node_modules/iceberg-js": { @@ -10920,48 +10909,240 @@ "license": "MIT" }, "node_modules/nitro": { - "version": "3.0.260903-beta", - "resolved": "https://registry.npmjs.org/nitro/-/nitro-3.0.260903-beta.tgz", - "integrity": "sha512-54gANPi62O8rfMvepiJUVuIzEIinYfpeHbebywlLxvVTgIYXDwSvpaU9Id+0sJOBjBx0wC1/CVYXJkH7SY+l0g==", + "version": "3.0.260603-beta", + "resolved": "https://registry.npmjs.org/nitro/-/nitro-3.0.260603-beta.tgz", + "integrity": "sha512-ffaSHK00a7YDlDizoEHwcxPwpQpdBRRA8k42ymTsRnfl3ipGeKgv4gnPr6DgmCNTo4tYVPK3bHBEv1gNhWpo/A==", "license": "MIT", "dependencies": { "consola": "^3.4.2", - "crossws": "^0.4.12", - "db0": "^0.4.1", - "env-runner": "^0.2.1", - "h3": "^2.0.1-rc.31", + "crossws": "^0.4.5", + "db0": "^0.3.4", + "env-runner": "^0.1.9", + "h3": "^2.0.1-rc.22", "hookable": "^6.1.1", - "nf3": "^0.3.24", - "ocache": "^0.3.0", - "rolldown": "^1.2.7", - "rou3": "^0.9.2", - "srvx": "^1.0.3", + "nf3": "^0.3.17", + "ocache": "^0.1.4", + "ofetch": "^2.0.0-alpha.3", + "ohash": "^2.0.11", + "rolldown": "^1.0.3", + "srvx": "^0.11.16", "unenv": "^2.0.0-rc.24", - "unstorage": "^2.0.0-alpha.10" + "unstorage": "^2.0.0-alpha.7" }, "bin": { "nitro": "dist/cli/index.mjs" }, "engines": { "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "@vercel/queue": "^0.2.0", + "dotenv": "*", + "giget": "*", + "jiti": "^2.7.0", + "rollup": "^4.60.4", + "vite": "^7 || ^8", + "xml2js": "^0.6.2", + "zephyr-agent": "^0.2.0" + }, + "peerDependenciesMeta": { + "@vercel/queue": { + "optional": true + }, + "dotenv": { + "optional": true + }, + "giget": { + "optional": true + }, + "jiti": { + "optional": true + }, + "rollup": { + "optional": true + }, + "vite": { + "optional": true + }, + "xml2js": { + "optional": true + }, + "zephyr-agent": { + "optional": true + } } }, - "node_modules/nitro/node_modules/rou3": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/rou3/-/rou3-0.9.2.tgz", - "integrity": "sha512-3SOzvaAg8rkHrXtRjpCvCvbyO5to9oOO27Z/XqHEYXfMRVSw/qMIVdmaOk9W2lcRLtR6dlqTjo9hDeJk70QBYQ==", - "license": "MIT" + "node_modules/nitro/node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20260730.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260730.1.tgz", + "integrity": "sha512-+MBHmPaiTe2KajryW0T24rZvWFxb41hD3d8anNzQqHzft6vSEb18+sp0znSwxgij7ApPhSM1+vhkNg4f3YMguA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">=16" + } }, - "node_modules/nitro/node_modules/srvx": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/srvx/-/srvx-1.0.5.tgz", - "integrity": "sha512-KvSKRpgPG/oaq3cyT614OQ2bAa7DynuGamivCZeoZzIUULOdbQz6wUtnnVuC4+DCx2Zglzo8v5gBYmWIWYhDxA==", + "node_modules/nitro/node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20260730.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260730.1.tgz", + "integrity": "sha512-SBHKntPkKvNPgaCrTe99xC1CAl8ygJDzlYfK0LbuJ1muKadIw35WnhO0wu894fKBtllsVQdNzDLee+cm0ppLSQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/nitro/node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20260730.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260730.1.tgz", + "integrity": "sha512-ouyPOSMbiKPeSwUJUvxtMcxGAXs2J4aPE4T5ABIYX5ClcQx5j5bbHTmnqOQEY8sAuLTPjH7dY+iB6UI5ISlwwA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/nitro/node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20260730.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260730.1.tgz", + "integrity": "sha512-YQ+Mi78U3TPdgBPtwq+Sm6rJU+Ihl2y0pjYtuuKkdmUbYzL7oLR6Xqq9wljhasnuCFICssDJaqhMep5WizYoEQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/nitro/node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20260730.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260730.1.tgz", + "integrity": "sha512-27fAN+vUECW1oYVc1KOcHYpkL8COM2Uxtxql7TL595kxbjoqS5yckw7NLz7bTf2pALFCZWjqXDjZGJ/xbG4ZKQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/nitro/node_modules/env-runner": { + "version": "0.1.16", + "resolved": "https://registry.npmjs.org/env-runner/-/env-runner-0.1.16.tgz", + "integrity": "sha512-2LRJM4P2KLX6J83QZZrMqvgCDt/D5ea7wPcI3yYiy5cG/9rX5QwdwZFx0D7ktWnjdRyZxYjttGGorb5nFqb1CA==", + "license": "MIT", + "dependencies": { + "crossws": "^0.4.8", + "exsolve": "^1.1.0", + "httpxy": "^0.5.4", + "srvx": "^0.11.19" + }, + "bin": { + "env-runner": "dist/cli.mjs" + }, + "peerDependencies": { + "@netlify/runtime": "^4.1.23", + "@vercel/queue": ">=0.2.0", + "miniflare": "^4.20260515.0", + "wrangler": "^4.0.0" + }, + "peerDependenciesMeta": { + "@netlify/runtime": { + "optional": true + }, + "@vercel/queue": { + "optional": true + }, + "miniflare": { + "optional": true + }, + "wrangler": { + "optional": true + } + } + }, + "node_modules/nitro/node_modules/miniflare": { + "version": "4.20260730.0", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-4.20260730.0.tgz", + "integrity": "sha512-1Z9SB9r/o//80UA02Re3QhtcecSHAyAjf5EcKBfQVlQrCg7Miy79hl2PvtkwFLIaJ5rcrOPdDcRr577okwZPsg==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "0.35.2", + "undici": "7.28.0", + "workerd": "1.20260730.1", + "ws": "8.21.0", + "youch": "4.1.0-beta.10" + }, + "bin": { + "miniflare": "bootstrap.js" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/nitro/node_modules/ocache": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/ocache/-/ocache-0.1.5.tgz", + "integrity": "sha512-kNNnkkVQup/QDvmTz8Q84wc2ntiyoVHDxa6eHWKt5qdGAmFRBIxy83rxgCYEjW0x06UJ9E3P6VgM2yY4rOBH4w==", "license": "MIT", + "dependencies": { + "ohash": "^2.0.11" + } + }, + "node_modules/nitro/node_modules/workerd": { + "version": "1.20260730.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260730.1.tgz", + "integrity": "sha512-zmfNIjwYSWFY5chGBOjWtH3xAE7p97FTC6vR4Ep98290ho6AeAR/NVcBD274YCLEUYzqm8yxdtZlxMybU8a3jA==", + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "peer": true, "bin": { - "srvx": "bin/srvx.mjs" + "workerd": "bin/workerd" }, "engines": { - "node": ">=20.16.0" + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20260730.1", + "@cloudflare/workerd-darwin-arm64": "1.20260730.1", + "@cloudflare/workerd-linux-64": "1.20260730.1", + "@cloudflare/workerd-linux-arm64": "1.20260730.1", + "@cloudflare/workerd-windows-64": "1.20260730.1" } }, "node_modules/node-releases": { @@ -10994,10 +11175,16 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/ocache": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/ocache/-/ocache-0.3.0.tgz", - "integrity": "sha512-RS/9P0zeBb0gDJmadGERLH8lZNXK7xbufTDhclkXGvFGTsj0G4M5/cLk+mizcERH29mLXNnocfB5wjcK70wGJg==", + "node_modules/ofetch": { + "version": "2.0.0-alpha.3", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-2.0.0-alpha.3.tgz", + "integrity": "sha512-zpYTCs2byOuft65vI3z43Dd6iSdFbOZZLb9/d21aCpx2rGastVU9dOCv0lu4ykc1Ur1anAYjDi3SUvR0vq50JA==", + "license": "MIT" + }, + "node_modules/ohash": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.12.tgz", + "integrity": "sha512-65S/5gk9YSsaRjcyf7Nfa6h/d3E8/1gslpXfI4W7Dxn/oap8IKRuNT5VXkLQ1YFKIEg4apRY4Pj6aiwFzrDdmw==", "license": "MIT" }, "node_modules/on-finished": { @@ -12695,9 +12882,9 @@ } }, "node_modules/unstorage": { - "version": "2.0.0-alpha.10", - "resolved": "https://registry.npmjs.org/unstorage/-/unstorage-2.0.0-alpha.10.tgz", - "integrity": "sha512-6h1veZp8gnp4dGllf0tDijoXxDYymJu251IpKKkrSVH+QHL6tXFbwG85KM+CBHSgpkkgtPuIiZ9oLCLP5+1Evw==", + "version": "2.0.0-beta.0", + "resolved": "https://registry.npmjs.org/unstorage/-/unstorage-2.0.0-beta.0.tgz", + "integrity": "sha512-VeTY+zQ3ozrNtIFBRQRuSwanHdpuRH+4t/ZzchZIVQO8/oKq2xl7fJ9c+z76tWJDW/BEXSEuzpHOxqoAl6B64A==", "license": "MIT" }, "node_modules/update-browserslist-db": { diff --git a/scripts/check-rpc-security.ts b/scripts/check-rpc-security.ts index 7085707a..6b3c4c92 100644 --- a/scripts/check-rpc-security.ts +++ b/scripts/check-rpc-security.ts @@ -18,6 +18,9 @@ const expected = [ "rls_invoker_reads", "authenticated_transactions", "plans_explicit_public_rows", + "account_reads_invoker", + "verified_telemetry_only", + "customization_purchase_required", ]; if ( error || diff --git a/scripts/test-advanced-security.sql b/scripts/test-advanced-security.sql new file mode 100644 index 00000000..44fbc6a3 --- /dev/null +++ b/scripts/test-advanced-security.sql @@ -0,0 +1,67 @@ +-- Transactional probes only: synthetic identities, no emails or charges. +BEGIN; +INSERT INTO auth.users(id,email,raw_user_meta_data) VALUES + ('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee01','security-owner@example.invalid','{}'), + ('dddddddd-dddd-4ddd-8ddd-dddddddddd02','security-other@example.invalid','{}'); +INSERT INTO public.user_roles(user_id,role) VALUES ('dddddddd-dddd-4ddd-8ddd-dddddddddd02','admin'); +SELECT set_config('request.jwt.claims','{"sub":"dddddddd-dddd-4ddd-8ddd-dddddddddd02","role":"authenticated"}',true); +INSERT INTO public.packages(id,slug,name,type,description,author_id,is_published,review_status) + VALUES ('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03','security-rollback-fixture','Fixture','skill','Rollback only','eeeeeeee-eeee-4eee-8eee-eeeeeeeeee01',true,'approved'); +INSERT INTO public.package_versions(package_id,version,system_prompt) VALUES ('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03','0.1.0','Original approved content'); +INSERT INTO public.packs(id,slug,name,description,price_credits) VALUES ('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee04','security-rollback-pack','Fixture','Rollback only',10); +INSERT INTO public.credit_ledger(user_id,delta,balance_after,reason) VALUES ('dddddddd-dddd-4ddd-8ddd-dddddddddd02',77,77,'purchase'); +INSERT INTO public.team_workspaces(id,name,owner_id) VALUES ('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee05','Rollback workspace','dddddddd-dddd-4ddd-8ddd-dddddddddd02'); +INSERT INTO public.team_invites(workspace_id,email,role,token_hash,created_by) VALUES ('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee05','security-owner@example.invalid','viewer',encode(extensions.digest('rollback-only-token','sha256'),'hex'),'dddddddd-dddd-4ddd-8ddd-dddddddddd02'); +SET LOCAL ROLE authenticated; +SELECT set_config('request.jwt.claims','{"sub":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeee01","role":"authenticated","email":"security-owner@example.invalid"}',true); +DO $test$ +DECLARE n int; +BEGIN + BEGIN + PERFORM public.team_action('accept',NULL,'{"token":"rollback-only-token"}'); + RAISE EXCEPTION 'Unverified email joined workspace'; + EXCEPTION WHEN insufficient_privilege THEN NULL; END; + IF public.get_credit_balance('dddddddd-dddd-4ddd-8ddd-dddddddddd02') <> 0 THEN RAISE EXCEPTION 'Cross-user credits leaked'; END IF; + UPDATE public.packages SET star_count=999 WHERE id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03'; + IF (SELECT star_count FROM public.packages WHERE id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03') <> 0 THEN RAISE EXCEPTION 'Author forged stars'; END IF; + INSERT INTO public.package_stars(user_id,package_id) VALUES(auth.uid(),'eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03'); + IF (SELECT star_count FROM public.packages WHERE id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03') <> 1 THEN RAISE EXCEPTION 'Legitimate star did not increment'; END IF; + DELETE FROM public.package_stars WHERE user_id=auth.uid() AND package_id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03'; + IF (SELECT star_count FROM public.packages WHERE id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03') <> 0 THEN RAISE EXCEPTION 'Legitimate star did not decrement'; END IF; + UPDATE public.package_versions SET system_prompt='Bypass' WHERE package_id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03'; + GET DIAGNOSTICS n=ROW_COUNT; + IF n<>0 THEN RAISE EXCEPTION 'Author changed approved content'; END IF; + BEGIN + INSERT INTO public.pack_customizations(user_id,pack_id,brief) VALUES(auth.uid(),'eeeeeeee-eeee-4eee-8eee-eeeeeeeeee04','Unauthorized customization'); + RAISE EXCEPTION 'Unpurchased customization accepted'; + EXCEPTION WHEN insufficient_privilege THEN NULL; END; + BEGIN + PERFORM public.mcp_check_and_log_call(auth.uid(),'probe','probe',false); + RAISE EXCEPTION 'User forged MCP log'; + EXCEPTION WHEN insufficient_privilege THEN NULL; END; + BEGIN + PERFORM public.compute_skill_drift('eeeeeeee-eeee-4eee-8eee-eeeeeeeeee03'); + RAISE EXCEPTION 'User read private drift'; + EXCEPTION WHEN insufficient_privilege THEN NULL; END; + BEGIN + PERFORM public.report_skill_execution('security-rollback-fixture',true); + RAISE EXCEPTION 'User called internal telemetry RPC'; + EXCEPTION WHEN insufficient_privilege THEN NULL; END; +END $test$; +RESET ROLE; +SELECT set_config('request.jwt.claims','{"role":"service_role"}',true); +SET LOCAL ROLE service_role; +SELECT public.report_skill_execution('security-rollback-fixture',true); +DO $test$ +BEGIN + IF (public.get_skill_trust('security-rollback-fixture')->>'trust_score') IS NOT NULL THEN RAISE EXCEPTION 'Unverified telemetry inflated trust'; END IF; + IF (public.get_skill_trust('security-rollback-fixture')->>'battle_tested')::boolean THEN RAISE EXCEPTION 'Unverified battle badge'; END IF; +END $test$; +RESET ROLE; +UPDATE auth.users SET confirmation_sent_at=now()-interval '1 minute',email_confirmed_at=now() WHERE id='eeeeeeee-eeee-4eee-8eee-eeeeeeeeee01'; +SET LOCAL ROLE authenticated; +SELECT set_config('request.jwt.claims','{"sub":"eeeeeeee-eeee-4eee-8eee-eeeeeeeeee01","role":"authenticated","email":"security-owner@example.invalid"}',true); +SELECT public.team_action('accept',NULL,'{"token":"rollback-only-token"}'); +RESET ROLE; +ROLLBACK; +SELECT 'passed' AS advanced_security_role_probes; diff --git a/scripts/test-security-boundaries.sql b/scripts/test-security-boundaries.sql index 6ea5f0af..3ef7dc14 100644 --- a/scripts/test-security-boundaries.sql +++ b/scripts/test-security-boundaries.sql @@ -5,7 +5,7 @@ DO $test$ DECLARE failures text; BEGIN SELECT string_agg(check_name, ', ') INTO failures FROM public.check_security_boundaries() WHERE passed IS DISTINCT FROM true; - IF failures IS NOT NULL OR (SELECT count(*) FROM public.check_security_boundaries()) <> 5 THEN + IF failures IS NOT NULL OR (SELECT count(*) FROM public.check_security_boundaries()) <> 8 THEN RAISE EXCEPTION 'Security boundary regression: %', failures; END IF; END $test$; diff --git a/src/integrations/supabase/cron-auth.ts b/src/integrations/supabase/cron-auth.ts index 7ba63b92..762cfc1c 100644 --- a/src/integrations/supabase/cron-auth.ts +++ b/src/integrations/supabase/cron-auth.ts @@ -1,35 +1,27 @@ // This file is automatically generated. Do not edit it directly. -export async function authenticateCronRequest( - request: Request, -): Promise { - const currentSecret = process.env['LOVABLE_CRON_SECRET'] - const previousSecret = process.env['LOVABLE_CRON_SECRET_PREVIOUS'] +export async function authenticateCronRequest(request: Request): Promise { + const currentSecret = process.env["LOVABLE_CRON_SECRET"]; + const previousSecret = process.env["LOVABLE_CRON_SECRET_PREVIOUS"]; if (!currentSecret) { - return new Response('Server configuration error', { status: 500 }) + return new Response("Server configuration error", { status: 500 }); } - const match = /^Bearer ([^\s,]+)$/.exec( - request.headers.get('authorization') ?? '', - ) - const token = match?.[1] + const match = /^Bearer ([^\s,]+)$/.exec(request.headers.get("authorization") ?? ""); + const token = match?.[1]; if (!token) { - return new Response('Unauthorized', { status: 401 }) + return new Response("Unauthorized", { status: 401 }); } - const { createHash, timingSafeEqual } = await import('node:crypto') - const digest = (value: string) => - createHash('sha256').update(value, 'utf8').digest() - const providedDigest = digest(token) - const currentMatches = timingSafeEqual(providedDigest, digest(currentSecret)) - const previousMatches = timingSafeEqual( - providedDigest, - digest(previousSecret ?? currentSecret), - ) + const { createHash, timingSafeEqual } = await import("node:crypto"); + const digest = (value: string) => createHash("sha256").update(value, "utf8").digest(); + const providedDigest = digest(token); + const currentMatches = timingSafeEqual(providedDigest, digest(currentSecret)); + const previousMatches = timingSafeEqual(providedDigest, digest(previousSecret ?? currentSecret)); if (!currentMatches && !previousMatches) { - return new Response('Unauthorized', { status: 401 }) + return new Response("Unauthorized", { status: 401 }); } - return null + return null; } diff --git a/src/integrations/supabase/previewAuthStorage.ts b/src/integrations/supabase/previewAuthStorage.ts index 2427ae9d..d2df3f11 100644 --- a/src/integrations/supabase/previewAuthStorage.ts +++ b/src/integrations/supabase/previewAuthStorage.ts @@ -7,7 +7,8 @@ export interface PreviewAuthStorage { removeItem: (key: string) => void | Promise; } -type BrokerRequestType = 'lovable-preview-auth:get' | 'lovable-preview-auth:set' | 'lovable-preview-auth:remove'; +type BrokerRequestType = + "lovable-preview-auth:get" | "lovable-preview-auth:set" | "lovable-preview-auth:remove"; interface BrokerRequest { type: BrokerRequestType; @@ -22,15 +23,15 @@ interface BrokerReply { value: string | null; } -const RESULT = 'lovable-preview-auth:result'; +const RESULT = "lovable-preview-auth:result"; function readBrokerReply(data: unknown, requestId: string): BrokerReply | null { - if (typeof data !== 'object' || data === null) return null; - if (!('type' in data) || data.type !== RESULT) return null; - if (!('requestId' in data) || data.requestId !== requestId) return null; + if (typeof data !== "object" || data === null) return null; + if (!("type" in data) || data.type !== RESULT) return null; + if (!("requestId" in data) || data.requestId !== requestId) return null; return { - ok: 'ok' in data && Boolean(data.ok), - value: 'value' in data && typeof data.value === 'string' ? data.value : null, + ok: "ok" in data && Boolean(data.ok), + value: "value" in data && typeof data.value === "string" ? data.value : null, }; } @@ -39,17 +40,26 @@ function readBrokerReply(data: unknown, requestId: string): BrokerReply | null { * postMessage so the project's preview surfaces share one login; else localStorage. */ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { - if (typeof window === 'undefined') return undefined; + if (typeof window === "undefined") return undefined; const host = location.hostname; - const PREVIEW_ZONES = ['lovableproject.com', 'lovableproject-dev.com', 'lovable.app', 'gpt-eng.com', 'gptengineer.run']; - const onPreviewZone = PREVIEW_ZONES.some((z) => host === z || host.endsWith('.' + z)); + const PREVIEW_ZONES = [ + "lovableproject.com", + "lovableproject-dev.com", + "lovable.app", + "gpt-eng.com", + "gptengineer.run", + ]; + const onPreviewZone = PREVIEW_ZONES.some((z) => host === z || host.endsWith("." + z)); // Read the id only from non-user-controlled host positions, so a user-named // preview-- host can't smuggle another project's id. - const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'; + const UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"; const projectId = onPreviewZone - ? (new RegExp('^(?:id-preview(?:-[a-z0-9]+)?|project)--(' + UUID + ')(?:-dev)?(?=\\.|$)', 'i').exec(host)?.[1] - ?? new RegExp('^live--(' + UUID + ')(?:-thr_[a-z0-9]+)?(?=\\.|$)', 'i').exec(host)?.[1] - ?? new RegExp('^(' + UUID + ')(?=[.-])', 'i').exec(host)?.[1]) + ? (new RegExp( + "^(?:id-preview(?:-[a-z0-9]+)?|project)--(" + UUID + ")(?:-dev)?(?=\\.|$)", + "i", + ).exec(host)?.[1] ?? + new RegExp("^live--(" + UUID + ")(?:-thr_[a-z0-9]+)?(?=\\.|$)", "i").exec(host)?.[1] ?? + new RegExp("^(" + UUID + ")(?=[.-])", "i").exec(host)?.[1]) : undefined; // lib.dom types window.parent and location.ancestorOrigins as always set, but a // detached frame has no parent and not every browser implements ancestorOrigins. @@ -59,19 +69,27 @@ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { // Post only to the real editor ancestor, validated as a Lovable origin, so the // session token can never reach an untrusted embedder. - const dev = host.endsWith('.lovableproject-dev.com') || host.endsWith('.gpt-eng.com'); + const dev = host.endsWith(".lovableproject-dev.com") || host.endsWith(".gpt-eng.com"); const EDITOR = dev ? /^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/ : /^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/; const ancestorOrigins = location.ancestorOrigins as DOMStringList | undefined; - const ancestor = ancestorOrigins?.[0] ?? (document.referrer ? new URL(document.referrer).origin : ''); - const editorOrigins = ancestor && EDITOR.test(ancestor) - ? [ancestor] - : (dev ? ['https://lovable.dev', 'http://localhost:3000'] : ['https://lovable.dev']); + const ancestor = + ancestorOrigins?.[0] ?? (document.referrer ? new URL(document.referrer).origin : ""); + const editorOrigins = + ancestor && EDITOR.test(ancestor) + ? [ancestor] + : dev + ? ["https://lovable.dev", "http://localhost:3000"] + : ["https://lovable.dev"]; const TIMEOUT = 2000; const newId = () => Math.random().toString(36).slice(2) + Date.now().toString(36); - const request = (type: BrokerRequestType, key: string, value?: string): Promise => + const request = ( + type: BrokerRequestType, + key: string, + value?: string, + ): Promise => new Promise((resolve) => { const requestId = newId(); let done = false; @@ -79,7 +97,7 @@ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { if (done) return; done = true; clearTimeout(timer); - window.removeEventListener('message', onMessage); + window.removeEventListener("message", onMessage); resolve(reply); }; const onMessage = (e: MessageEvent) => { @@ -87,8 +105,10 @@ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { const reply = readBrokerReply(e.data, requestId); if (reply) finish(reply); }; - window.addEventListener('message', onMessage); - const timer = setTimeout(() => { finish(null); }, TIMEOUT); + window.addEventListener("message", onMessage); + const timer = setTimeout(() => { + finish(null); + }, TIMEOUT); const msg: BrokerRequest = { type, requestId, projectId, key }; if (value !== undefined) msg.value = value; // targetOrigin per trusted editor origin, so a session token never reaches an arbitrary embedder. @@ -99,28 +119,38 @@ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { let firstGet = true; const RETRY_DELAY = 250; // Blocked third-party storage throws here; seeding must not break broker reads. - const readLocal = (key: string): string | null | undefined => { try { return localStorage.getItem(key); } catch { return undefined; } }; + const readLocal = (key: string): string | null | undefined => { + try { + return localStorage.getItem(key); + } catch { + return undefined; + } + }; return { getItem: async (key) => { // Sent with GET and REMOVE so an editor that never cached this session can check or revoke it. const local = readLocal(key); - let res = await request('lovable-preview-auth:get', key, local ?? undefined); + let res = await request("lovable-preview-auth:get", key, local ?? undefined); if (!res && firstGet) { await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY)); - res = await request('lovable-preview-auth:get', key, local ?? undefined); + res = await request("lovable-preview-auth:get", key, local ?? undefined); } firstGet = false; // '' is the logout tombstone: clear the local copy too so it can't resurrect if // the broker later goes silent. A null value means never-synced -> keep local. if (res?.ok && res.value !== null) { - if (res.value === '') { + if (res.value === "") { if (local !== undefined && readLocal(key) === local) localStorage.removeItem(key); return null; } // Seed this origin so a new tab, whose editor holds no session, stays signed in. if (local === null && readLocal(key) === null) { - try { localStorage.setItem(key, res.value); } catch { /* storage full: still return the editor's session */ } + try { + localStorage.setItem(key, res.value); + } catch { + /* storage full: still return the editor's session */ + } } return res.value; } @@ -128,9 +158,9 @@ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { }, setItem: (key, value) => { localStorage.setItem(key, value); - return request('lovable-preview-auth:set', key, value).then((res) => { + return request("lovable-preview-auth:set", key, value).then((res) => { if (res?.ok && res.value !== null && localStorage.getItem(key) === value) { - if (res.value === '') localStorage.removeItem(key); + if (res.value === "") localStorage.removeItem(key); else localStorage.setItem(key, res.value); } }); @@ -138,7 +168,7 @@ export function brokeredPreviewStorage(): PreviewAuthStorage | undefined { removeItem: (key) => { const local = readLocal(key); localStorage.removeItem(key); - return request('lovable-preview-auth:remove', key, local ?? undefined).then(() => {}); + return request("lovable-preview-auth:remove", key, local ?? undefined).then(() => {}); }, }; } diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index 2dbf50cb..e636e599 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -1,5393 +1,5387 @@ -export type Json = - | string - | number - | boolean - | null - | { [key: string]: Json | undefined } - | Json[] +export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]; export type Database = { // Allows to automatically instantiate createClient with right options // instead of createClient(URL, KEY) __InternalSupabase: { - PostgrestVersion: "14.5" - } + PostgrestVersion: "14.5"; + }; public: { Tables: { account_plans: { Row: { - plan_id: string - status: string - updated_at: string - user_id: string - } + plan_id: string; + status: string; + updated_at: string; + user_id: string; + }; Insert: { - plan_id: string - status?: string - updated_at?: string - user_id: string - } + plan_id: string; + status?: string; + updated_at?: string; + user_id: string; + }; Update: { - plan_id?: string - status?: string - updated_at?: string - user_id?: string - } + plan_id?: string; + status?: string; + updated_at?: string; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "account_plans_plan_id_fkey" - columns: ["plan_id"] - isOneToOne: false - referencedRelation: "plans" - referencedColumns: ["id"] + foreignKeyName: "account_plans_plan_id_fkey"; + columns: ["plan_id"]; + isOneToOne: false; + referencedRelation: "plans"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; adversarial_cases: { Row: { - authors: string[] - case_id: string - category: string - context: string | null - created_at: string - expectations: Json - id: string - input: string - is_active: boolean - license: string - references_: string[] - severity: string - tags: string[] - target_package_slugs: string[] - target_package_type: string - target_tags: string[] - updated_at: string - vertical: string - } + authors: string[]; + case_id: string; + category: string; + context: string | null; + created_at: string; + expectations: Json; + id: string; + input: string; + is_active: boolean; + license: string; + references_: string[]; + severity: string; + tags: string[]; + target_package_slugs: string[]; + target_package_type: string; + target_tags: string[]; + updated_at: string; + vertical: string; + }; Insert: { - authors?: string[] - case_id: string - category: string - context?: string | null - created_at?: string - expectations: Json - id?: string - input: string - is_active?: boolean - license?: string - references_?: string[] - severity: string - tags?: string[] - target_package_slugs?: string[] - target_package_type: string - target_tags?: string[] - updated_at?: string - vertical: string - } + authors?: string[]; + case_id: string; + category: string; + context?: string | null; + created_at?: string; + expectations: Json; + id?: string; + input: string; + is_active?: boolean; + license?: string; + references_?: string[]; + severity: string; + tags?: string[]; + target_package_slugs?: string[]; + target_package_type: string; + target_tags?: string[]; + updated_at?: string; + vertical: string; + }; Update: { - authors?: string[] - case_id?: string - category?: string - context?: string | null - created_at?: string - expectations?: Json - id?: string - input?: string - is_active?: boolean - license?: string - references_?: string[] - severity?: string - tags?: string[] - target_package_slugs?: string[] - target_package_type?: string - target_tags?: string[] - updated_at?: string - vertical?: string - } - Relationships: [] - } + authors?: string[]; + case_id?: string; + category?: string; + context?: string | null; + created_at?: string; + expectations?: Json; + id?: string; + input?: string; + is_active?: boolean; + license?: string; + references_?: string[]; + severity?: string; + tags?: string[]; + target_package_slugs?: string[]; + target_package_type?: string; + target_tags?: string[]; + updated_at?: string; + vertical?: string; + }; + Relationships: []; + }; adversarial_runs: { Row: { - by_category: Json - by_severity: Json - created_at: string - duration_ms: number | null - failed: number - id: string - judge_agreement: number | null - judge_cases: number | null - judge_kappa: number | null - judge_model: string | null - judge_overrides: number | null - model: string | null - outcomes: Json - package_id: string | null - pass_rate: number - passed: number - severity_weighted_score: number - subject_arm: string - total: number - trigger_kind: string - triggered_by: string | null - version_id: string | null - vertical_filter: string | null - } + by_category: Json; + by_severity: Json; + created_at: string; + duration_ms: number | null; + failed: number; + id: string; + judge_agreement: number | null; + judge_cases: number | null; + judge_kappa: number | null; + judge_model: string | null; + judge_overrides: number | null; + model: string | null; + outcomes: Json; + package_id: string | null; + pass_rate: number; + passed: number; + severity_weighted_score: number; + subject_arm: string; + total: number; + trigger_kind: string; + triggered_by: string | null; + version_id: string | null; + vertical_filter: string | null; + }; Insert: { - by_category?: Json - by_severity?: Json - created_at?: string - duration_ms?: number | null - failed: number - id?: string - judge_agreement?: number | null - judge_cases?: number | null - judge_kappa?: number | null - judge_model?: string | null - judge_overrides?: number | null - model?: string | null - outcomes?: Json - package_id?: string | null - pass_rate: number - passed: number - severity_weighted_score: number - subject_arm?: string - total: number - trigger_kind?: string - triggered_by?: string | null - version_id?: string | null - vertical_filter?: string | null - } + by_category?: Json; + by_severity?: Json; + created_at?: string; + duration_ms?: number | null; + failed: number; + id?: string; + judge_agreement?: number | null; + judge_cases?: number | null; + judge_kappa?: number | null; + judge_model?: string | null; + judge_overrides?: number | null; + model?: string | null; + outcomes?: Json; + package_id?: string | null; + pass_rate: number; + passed: number; + severity_weighted_score: number; + subject_arm?: string; + total: number; + trigger_kind?: string; + triggered_by?: string | null; + version_id?: string | null; + vertical_filter?: string | null; + }; Update: { - by_category?: Json - by_severity?: Json - created_at?: string - duration_ms?: number | null - failed?: number - id?: string - judge_agreement?: number | null - judge_cases?: number | null - judge_kappa?: number | null - judge_model?: string | null - judge_overrides?: number | null - model?: string | null - outcomes?: Json - package_id?: string | null - pass_rate?: number - passed?: number - severity_weighted_score?: number - subject_arm?: string - total?: number - trigger_kind?: string - triggered_by?: string | null - version_id?: string | null - vertical_filter?: string | null - } + by_category?: Json; + by_severity?: Json; + created_at?: string; + duration_ms?: number | null; + failed?: number; + id?: string; + judge_agreement?: number | null; + judge_cases?: number | null; + judge_kappa?: number | null; + judge_model?: string | null; + judge_overrides?: number | null; + model?: string | null; + outcomes?: Json; + package_id?: string | null; + pass_rate?: number; + passed?: number; + severity_weighted_score?: number; + subject_arm?: string; + total?: number; + trigger_kind?: string; + triggered_by?: string | null; + version_id?: string | null; + vertical_filter?: string | null; + }; Relationships: [ { - foreignKeyName: "adversarial_runs_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "adversarial_runs_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "adversarial_runs_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "adversarial_runs_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "adversarial_runs_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "adversarial_runs_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "adversarial_runs_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "adversarial_runs_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; agent_builds: { Row: { - brief: Json - created_at: string - emoji: string - error: string | null - grade: string | null - guardrails: Json - id: string - name: string - playbooks: Json - report: Json | null - research_sources: Json - research_summary: string | null - role: string - score: number | null - skills: Json - slug: string - soul: string | null - status: string - step: string | null - tagline: string | null - updated_at: string - user_id: string - } + brief: Json; + created_at: string; + emoji: string; + error: string | null; + grade: string | null; + guardrails: Json; + id: string; + name: string; + playbooks: Json; + report: Json | null; + research_sources: Json; + research_summary: string | null; + role: string; + score: number | null; + skills: Json; + slug: string; + soul: string | null; + status: string; + step: string | null; + tagline: string | null; + updated_at: string; + user_id: string; + }; Insert: { - brief?: Json - created_at?: string - emoji?: string - error?: string | null - grade?: string | null - guardrails?: Json - id?: string - name: string - playbooks?: Json - report?: Json | null - research_sources?: Json - research_summary?: string | null - role: string - score?: number | null - skills?: Json - slug: string - soul?: string | null - status?: string - step?: string | null - tagline?: string | null - updated_at?: string - user_id: string - } + brief?: Json; + created_at?: string; + emoji?: string; + error?: string | null; + grade?: string | null; + guardrails?: Json; + id?: string; + name: string; + playbooks?: Json; + report?: Json | null; + research_sources?: Json; + research_summary?: string | null; + role: string; + score?: number | null; + skills?: Json; + slug: string; + soul?: string | null; + status?: string; + step?: string | null; + tagline?: string | null; + updated_at?: string; + user_id: string; + }; Update: { - brief?: Json - created_at?: string - emoji?: string - error?: string | null - grade?: string | null - guardrails?: Json - id?: string - name?: string - playbooks?: Json - report?: Json | null - research_sources?: Json - research_summary?: string | null - role?: string - score?: number | null - skills?: Json - slug?: string - soul?: string | null - status?: string - step?: string | null - tagline?: string | null - updated_at?: string - user_id?: string - } - Relationships: [] - } + brief?: Json; + created_at?: string; + emoji?: string; + error?: string | null; + grade?: string | null; + guardrails?: Json; + id?: string; + name?: string; + playbooks?: Json; + report?: Json | null; + research_sources?: Json; + research_summary?: string | null; + role?: string; + score?: number | null; + skills?: Json; + slug?: string; + soul?: string | null; + status?: string; + step?: string | null; + tagline?: string | null; + updated_at?: string; + user_id?: string; + }; + Relationships: []; + }; agent_credentials: { Row: { - code: string - created_at: string - domain: string - expires_at: string - focus: Json - id: string - issued_at: string - residency_id: string | null - revoked: boolean - rounds: number - score: number - signature: string - user_id: string | null - } + code: string; + created_at: string; + domain: string; + expires_at: string; + focus: Json; + id: string; + issued_at: string; + residency_id: string | null; + revoked: boolean; + rounds: number; + score: number; + signature: string; + user_id: string | null; + }; Insert: { - code: string - created_at?: string - domain: string - expires_at: string - focus?: Json - id?: string - issued_at?: string - residency_id?: string | null - revoked?: boolean - rounds?: number - score: number - signature: string - user_id?: string | null - } + code: string; + created_at?: string; + domain: string; + expires_at: string; + focus?: Json; + id?: string; + issued_at?: string; + residency_id?: string | null; + revoked?: boolean; + rounds?: number; + score: number; + signature: string; + user_id?: string | null; + }; Update: { - code?: string - created_at?: string - domain?: string - expires_at?: string - focus?: Json - id?: string - issued_at?: string - residency_id?: string | null - revoked?: boolean - rounds?: number - score?: number - signature?: string - user_id?: string | null - } + code?: string; + created_at?: string; + domain?: string; + expires_at?: string; + focus?: Json; + id?: string; + issued_at?: string; + residency_id?: string | null; + revoked?: boolean; + rounds?: number; + score?: number; + signature?: string; + user_id?: string | null; + }; Relationships: [ { - foreignKeyName: "agent_credentials_residency_id_fkey" - columns: ["residency_id"] - isOneToOne: false - referencedRelation: "agent_residencies" - referencedColumns: ["id"] + foreignKeyName: "agent_credentials_residency_id_fkey"; + columns: ["residency_id"]; + isOneToOne: false; + referencedRelation: "agent_residencies"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; agent_diagnoses: { Row: { - agent_fp: string | null - bottleneck: string | null - case_ids: string[] - created_at: string - domain: string - error_profile: Json - id: string - installed_skills: string[] - overall_score: number | null - prescription: Json - status: string - updated_at: string - user_id: string | null - } + agent_fp: string | null; + bottleneck: string | null; + case_ids: string[]; + created_at: string; + domain: string; + error_profile: Json; + id: string; + installed_skills: string[]; + overall_score: number | null; + prescription: Json; + status: string; + updated_at: string; + user_id: string | null; + }; Insert: { - agent_fp?: string | null - bottleneck?: string | null - case_ids?: string[] - created_at?: string - domain: string - error_profile?: Json - id?: string - installed_skills?: string[] - overall_score?: number | null - prescription?: Json - status?: string - updated_at?: string - user_id?: string | null - } + agent_fp?: string | null; + bottleneck?: string | null; + case_ids?: string[]; + created_at?: string; + domain: string; + error_profile?: Json; + id?: string; + installed_skills?: string[]; + overall_score?: number | null; + prescription?: Json; + status?: string; + updated_at?: string; + user_id?: string | null; + }; Update: { - agent_fp?: string | null - bottleneck?: string | null - case_ids?: string[] - created_at?: string - domain?: string - error_profile?: Json - id?: string - installed_skills?: string[] - overall_score?: number | null - prescription?: Json - status?: string - updated_at?: string - user_id?: string | null - } - Relationships: [] - } + agent_fp?: string | null; + bottleneck?: string | null; + case_ids?: string[]; + created_at?: string; + domain?: string; + error_profile?: Json; + id?: string; + installed_skills?: string[]; + overall_score?: number | null; + prescription?: Json; + status?: string; + updated_at?: string; + user_id?: string | null; + }; + Relationships: []; + }; agent_diagnosis_items: { Row: { - answer: string | null - case_id: string - created_at: string - diagnosis_id: string - error_class: string - id: string - latency_ms: number | null - passed: boolean - reason: string | null - tokens: number | null - } + answer: string | null; + case_id: string; + created_at: string; + diagnosis_id: string; + error_class: string; + id: string; + latency_ms: number | null; + passed: boolean; + reason: string | null; + tokens: number | null; + }; Insert: { - answer?: string | null - case_id: string - created_at?: string - diagnosis_id: string - error_class: string - id?: string - latency_ms?: number | null - passed?: boolean - reason?: string | null - tokens?: number | null - } + answer?: string | null; + case_id: string; + created_at?: string; + diagnosis_id: string; + error_class: string; + id?: string; + latency_ms?: number | null; + passed?: boolean; + reason?: string | null; + tokens?: number | null; + }; Update: { - answer?: string | null - case_id?: string - created_at?: string - diagnosis_id?: string - error_class?: string - id?: string - latency_ms?: number | null - passed?: boolean - reason?: string | null - tokens?: number | null - } + answer?: string | null; + case_id?: string; + created_at?: string; + diagnosis_id?: string; + error_class?: string; + id?: string; + latency_ms?: number | null; + passed?: boolean; + reason?: string | null; + tokens?: number | null; + }; Relationships: [ { - foreignKeyName: "agent_diagnosis_items_diagnosis_id_fkey" - columns: ["diagnosis_id"] - isOneToOne: false - referencedRelation: "agent_diagnoses" - referencedColumns: ["id"] + foreignKeyName: "agent_diagnosis_items_diagnosis_id_fkey"; + columns: ["diagnosis_id"]; + isOneToOne: false; + referencedRelation: "agent_diagnoses"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; agent_match_selection_cache: { Row: { - cache_key: string - created_at: string - evidence: Json - expires_at: string - scope_hash: string - } + cache_key: string; + created_at: string; + evidence: Json; + expires_at: string; + scope_hash: string; + }; Insert: { - cache_key: string - created_at: string - evidence: Json - expires_at: string - scope_hash: string - } + cache_key: string; + created_at: string; + evidence: Json; + expires_at: string; + scope_hash: string; + }; Update: { - cache_key?: string - created_at?: string - evidence?: Json - expires_at?: string - scope_hash?: string - } - Relationships: [] - } + cache_key?: string; + created_at?: string; + evidence?: Json; + expires_at?: string; + scope_hash?: string; + }; + Relationships: []; + }; agent_onboarding_steps: { Row: { - client_name: string | null - created_at: string - evidence: Json - id: string - is_bot: boolean - session_hash: string - stage: string - step_id: string - ua_family: string | null - } + client_name: string | null; + created_at: string; + evidence: Json; + id: string; + is_bot: boolean; + session_hash: string; + stage: string; + step_id: string; + ua_family: string | null; + }; Insert: { - client_name?: string | null - created_at?: string - evidence?: Json - id?: string - is_bot?: boolean - session_hash: string - stage: string - step_id: string - ua_family?: string | null - } + client_name?: string | null; + created_at?: string; + evidence?: Json; + id?: string; + is_bot?: boolean; + session_hash: string; + stage: string; + step_id: string; + ua_family?: string | null; + }; Update: { - client_name?: string | null - created_at?: string - evidence?: Json - id?: string - is_bot?: boolean - session_hash?: string - stage?: string - step_id?: string - ua_family?: string | null - } - Relationships: [] - } + client_name?: string | null; + created_at?: string; + evidence?: Json; + id?: string; + is_bot?: boolean; + session_hash?: string; + stage?: string; + step_id?: string; + ua_family?: string | null; + }; + Relationships: []; + }; agent_residencies: { Row: { - agent_fp: string | null - created_at: string - current_case_ids: Json - domain: string - focus: Json - id: string - installed_skills: Json - pass_threshold: number - round: number - round_scores: Json - status: string - total_rounds: number - updated_at: string - user_id: string | null - } + agent_fp: string | null; + created_at: string; + current_case_ids: Json; + domain: string; + focus: Json; + id: string; + installed_skills: Json; + pass_threshold: number; + round: number; + round_scores: Json; + status: string; + total_rounds: number; + updated_at: string; + user_id: string | null; + }; Insert: { - agent_fp?: string | null - created_at?: string - current_case_ids?: Json - domain: string - focus?: Json - id?: string - installed_skills?: Json - pass_threshold?: number - round?: number - round_scores?: Json - status?: string - total_rounds?: number - updated_at?: string - user_id?: string | null - } + agent_fp?: string | null; + created_at?: string; + current_case_ids?: Json; + domain: string; + focus?: Json; + id?: string; + installed_skills?: Json; + pass_threshold?: number; + round?: number; + round_scores?: Json; + status?: string; + total_rounds?: number; + updated_at?: string; + user_id?: string | null; + }; Update: { - agent_fp?: string | null - created_at?: string - current_case_ids?: Json - domain?: string - focus?: Json - id?: string - installed_skills?: Json - pass_threshold?: number - round?: number - round_scores?: Json - status?: string - total_rounds?: number - updated_at?: string - user_id?: string | null - } - Relationships: [] - } + agent_fp?: string | null; + created_at?: string; + current_case_ids?: Json; + domain?: string; + focus?: Json; + id?: string; + installed_skills?: Json; + pass_threshold?: number; + round?: number; + round_scores?: Json; + status?: string; + total_rounds?: number; + updated_at?: string; + user_id?: string | null; + }; + Relationships: []; + }; agent_residency_rounds: { Row: { - created_at: string - feedback: Json - id: string - passed: boolean - residency_id: string - round: number - score: number - } + created_at: string; + feedback: Json; + id: string; + passed: boolean; + residency_id: string; + round: number; + score: number; + }; Insert: { - created_at?: string - feedback?: Json - id?: string - passed?: boolean - residency_id: string - round: number - score: number - } + created_at?: string; + feedback?: Json; + id?: string; + passed?: boolean; + residency_id: string; + round: number; + score: number; + }; Update: { - created_at?: string - feedback?: Json - id?: string - passed?: boolean - residency_id?: string - round?: number - score?: number - } + created_at?: string; + feedback?: Json; + id?: string; + passed?: boolean; + residency_id?: string; + round?: number; + score?: number; + }; Relationships: [ { - foreignKeyName: "agent_residency_rounds_residency_id_fkey" - columns: ["residency_id"] - isOneToOne: false - referencedRelation: "agent_residencies" - referencedColumns: ["id"] + foreignKeyName: "agent_residency_rounds_residency_id_fkey"; + columns: ["residency_id"]; + isOneToOne: false; + referencedRelation: "agent_residencies"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; cloud_skill_sync_conflicts: { Row: { - client_name: string | null - cloud_hash: string | null - cloud_lines: number | null - cloud_version: number | null - created_at: string - decided_at: string | null - decision: string | null - detail: string | null - id: string - kind: string - local_content: string | null - local_lines: number | null - local_only_lines: number | null - path: string - provider: string - provider_label: string | null - scope: string - slug: string - status: string - updated_at: string - user_id: string - } + client_name: string | null; + cloud_hash: string | null; + cloud_lines: number | null; + cloud_version: number | null; + created_at: string; + decided_at: string | null; + decision: string | null; + detail: string | null; + id: string; + kind: string; + local_content: string | null; + local_lines: number | null; + local_only_lines: number | null; + path: string; + provider: string; + provider_label: string | null; + scope: string; + slug: string; + status: string; + updated_at: string; + user_id: string; + }; Insert: { - client_name?: string | null - cloud_hash?: string | null - cloud_lines?: number | null - cloud_version?: number | null - created_at?: string - decided_at?: string | null - decision?: string | null - detail?: string | null - id?: string - kind?: string - local_content?: string | null - local_lines?: number | null - local_only_lines?: number | null - path: string - provider: string - provider_label?: string | null - scope: string - slug: string - status?: string - updated_at?: string - user_id: string - } + client_name?: string | null; + cloud_hash?: string | null; + cloud_lines?: number | null; + cloud_version?: number | null; + created_at?: string; + decided_at?: string | null; + decision?: string | null; + detail?: string | null; + id?: string; + kind?: string; + local_content?: string | null; + local_lines?: number | null; + local_only_lines?: number | null; + path: string; + provider: string; + provider_label?: string | null; + scope: string; + slug: string; + status?: string; + updated_at?: string; + user_id: string; + }; Update: { - client_name?: string | null - cloud_hash?: string | null - cloud_lines?: number | null - cloud_version?: number | null - created_at?: string - decided_at?: string | null - decision?: string | null - detail?: string | null - id?: string - kind?: string - local_content?: string | null - local_lines?: number | null - local_only_lines?: number | null - path?: string - provider?: string - provider_label?: string | null - scope?: string - slug?: string - status?: string - updated_at?: string - user_id?: string - } - Relationships: [] - } + client_name?: string | null; + cloud_hash?: string | null; + cloud_lines?: number | null; + cloud_version?: number | null; + created_at?: string; + decided_at?: string | null; + decision?: string | null; + detail?: string | null; + id?: string; + kind?: string; + local_content?: string | null; + local_lines?: number | null; + local_only_lines?: number | null; + path?: string; + provider?: string; + provider_label?: string | null; + scope?: string; + slug?: string; + status?: string; + updated_at?: string; + user_id?: string; + }; + Relationships: []; + }; cloud_skill_sync_events: { Row: { - bytes: number | null - changes: Json - client_name: string | null - conflict_count: number - conflicts: Json - created_at: string - error: string | null - id: string - orphan_count: number - orphans: Json - provider: string - provider_label: string | null - scope: string - skill_count: number - skipped_count: number - source: string - status: string - strategy: string | null - unresolved_count: number - user_id: string - written_count: number - } + bytes: number | null; + changes: Json; + client_name: string | null; + conflict_count: number; + conflicts: Json; + created_at: string; + error: string | null; + id: string; + orphan_count: number; + orphans: Json; + provider: string; + provider_label: string | null; + scope: string; + skill_count: number; + skipped_count: number; + source: string; + status: string; + strategy: string | null; + unresolved_count: number; + user_id: string; + written_count: number; + }; Insert: { - bytes?: number | null - changes?: Json - client_name?: string | null - conflict_count?: number - conflicts?: Json - created_at?: string - error?: string | null - id?: string - orphan_count?: number - orphans?: Json - provider: string - provider_label?: string | null - scope: string - skill_count?: number - skipped_count?: number - source?: string - status?: string - strategy?: string | null - unresolved_count?: number - user_id: string - written_count?: number - } + bytes?: number | null; + changes?: Json; + client_name?: string | null; + conflict_count?: number; + conflicts?: Json; + created_at?: string; + error?: string | null; + id?: string; + orphan_count?: number; + orphans?: Json; + provider: string; + provider_label?: string | null; + scope: string; + skill_count?: number; + skipped_count?: number; + source?: string; + status?: string; + strategy?: string | null; + unresolved_count?: number; + user_id: string; + written_count?: number; + }; Update: { - bytes?: number | null - changes?: Json - client_name?: string | null - conflict_count?: number - conflicts?: Json - created_at?: string - error?: string | null - id?: string - orphan_count?: number - orphans?: Json - provider?: string - provider_label?: string | null - scope?: string - skill_count?: number - skipped_count?: number - source?: string - status?: string - strategy?: string | null - unresolved_count?: number - user_id?: string - written_count?: number - } - Relationships: [] - } + bytes?: number | null; + changes?: Json; + client_name?: string | null; + conflict_count?: number; + conflicts?: Json; + created_at?: string; + error?: string | null; + id?: string; + orphan_count?: number; + orphans?: Json; + provider?: string; + provider_label?: string | null; + scope?: string; + skill_count?: number; + skipped_count?: number; + source?: string; + status?: string; + strategy?: string | null; + unresolved_count?: number; + user_id?: string; + written_count?: number; + }; + Relationships: []; + }; cloud_skill_versions: { Row: { - changelog: string | null - cloud_skill_id: string - content: string - created_at: string - id: string - variables: Json - version: number - } + changelog: string | null; + cloud_skill_id: string; + content: string; + created_at: string; + id: string; + variables: Json; + version: number; + }; Insert: { - changelog?: string | null - cloud_skill_id: string - content: string - created_at?: string - id?: string - variables?: Json - version: number - } + changelog?: string | null; + cloud_skill_id: string; + content: string; + created_at?: string; + id?: string; + variables?: Json; + version: number; + }; Update: { - changelog?: string | null - cloud_skill_id?: string - content?: string - created_at?: string - id?: string - variables?: Json - version?: number - } + changelog?: string | null; + cloud_skill_id?: string; + content?: string; + created_at?: string; + id?: string; + variables?: Json; + version?: number; + }; Relationships: [ { - foreignKeyName: "cloud_skill_versions_cloud_skill_id_fkey" - columns: ["cloud_skill_id"] - isOneToOne: false - referencedRelation: "cloud_skills" - referencedColumns: ["id"] + foreignKeyName: "cloud_skill_versions_cloud_skill_id_fkey"; + columns: ["cloud_skill_id"]; + isOneToOne: false; + referencedRelation: "cloud_skills"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; cloud_skills: { Row: { - category: string - content: string - created_at: string - description: string | null - forked_from: string | null - id: string - is_public: boolean - name: string - slug: string - tags: string[] - updated_at: string - user_id: string - variables: Json - version: number - } + category: string; + content: string; + created_at: string; + description: string | null; + forked_from: string | null; + id: string; + is_public: boolean; + name: string; + slug: string; + tags: string[]; + updated_at: string; + user_id: string; + variables: Json; + version: number; + }; Insert: { - category?: string - content: string - created_at?: string - description?: string | null - forked_from?: string | null - id?: string - is_public?: boolean - name: string - slug: string - tags?: string[] - updated_at?: string - user_id: string - variables?: Json - version?: number - } + category?: string; + content: string; + created_at?: string; + description?: string | null; + forked_from?: string | null; + id?: string; + is_public?: boolean; + name: string; + slug: string; + tags?: string[]; + updated_at?: string; + user_id: string; + variables?: Json; + version?: number; + }; Update: { - category?: string - content?: string - created_at?: string - description?: string | null - forked_from?: string | null - id?: string - is_public?: boolean - name?: string - slug?: string - tags?: string[] - updated_at?: string - user_id?: string - variables?: Json - version?: number - } + category?: string; + content?: string; + created_at?: string; + description?: string | null; + forked_from?: string | null; + id?: string; + is_public?: boolean; + name?: string; + slug?: string; + tags?: string[]; + updated_at?: string; + user_id?: string; + variables?: Json; + version?: number; + }; Relationships: [ { - foreignKeyName: "cloud_skills_forked_from_fkey" - columns: ["forked_from"] - isOneToOne: false - referencedRelation: "cloud_skills" - referencedColumns: ["id"] + foreignKeyName: "cloud_skills_forked_from_fkey"; + columns: ["forked_from"]; + isOneToOne: false; + referencedRelation: "cloud_skills"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; credit_ledger: { Row: { - balance_after: number - created_at: string - delta: number - description: string | null - id: string - metadata: Json - reason: Database["public"]["Enums"]["credit_reason"] - ref_id: string | null - ref_type: string | null - user_id: string - } + balance_after: number; + created_at: string; + delta: number; + description: string | null; + id: string; + metadata: Json; + reason: Database["public"]["Enums"]["credit_reason"]; + ref_id: string | null; + ref_type: string | null; + user_id: string; + }; Insert: { - balance_after: number - created_at?: string - delta: number - description?: string | null - id?: string - metadata?: Json - reason: Database["public"]["Enums"]["credit_reason"] - ref_id?: string | null - ref_type?: string | null - user_id: string - } + balance_after: number; + created_at?: string; + delta: number; + description?: string | null; + id?: string; + metadata?: Json; + reason: Database["public"]["Enums"]["credit_reason"]; + ref_id?: string | null; + ref_type?: string | null; + user_id: string; + }; Update: { - balance_after?: number - created_at?: string - delta?: number - description?: string | null - id?: string - metadata?: Json - reason?: Database["public"]["Enums"]["credit_reason"] - ref_id?: string | null - ref_type?: string | null - user_id?: string - } - Relationships: [] - } + balance_after?: number; + created_at?: string; + delta?: number; + description?: string | null; + id?: string; + metadata?: Json; + reason?: Database["public"]["Enums"]["credit_reason"]; + ref_id?: string | null; + ref_type?: string | null; + user_id?: string; + }; + Relationships: []; + }; crm_copy_variants: { Row: { - created_at: string - framing: string - heading_override: string | null - id: string - intro_override: string | null - label: string - notes: string | null - origin: string - status: string - subject_override: string | null - trigger: string - updated_at: string - variant: string - } + created_at: string; + framing: string; + heading_override: string | null; + id: string; + intro_override: string | null; + label: string; + notes: string | null; + origin: string; + status: string; + subject_override: string | null; + trigger: string; + updated_at: string; + variant: string; + }; Insert: { - created_at?: string - framing?: string - heading_override?: string | null - id?: string - intro_override?: string | null - label: string - notes?: string | null - origin?: string - status?: string - subject_override?: string | null - trigger: string - updated_at?: string - variant: string - } + created_at?: string; + framing?: string; + heading_override?: string | null; + id?: string; + intro_override?: string | null; + label: string; + notes?: string | null; + origin?: string; + status?: string; + subject_override?: string | null; + trigger: string; + updated_at?: string; + variant: string; + }; Update: { - created_at?: string - framing?: string - heading_override?: string | null - id?: string - intro_override?: string | null - label?: string - notes?: string | null - origin?: string - status?: string - subject_override?: string | null - trigger?: string - updated_at?: string - variant?: string - } - Relationships: [] - } + created_at?: string; + framing?: string; + heading_override?: string | null; + id?: string; + intro_override?: string | null; + label?: string; + notes?: string | null; + origin?: string; + status?: string; + subject_override?: string | null; + trigger?: string; + updated_at?: string; + variant?: string; + }; + Relationships: []; + }; crm_lifecycle_state: { Row: { - created_at: string - crm_unsubscribed: boolean - emails_sent_7d: number - first_seen: string - last_active_at: string | null - last_email_at: string | null - stage: string - updated_at: string - user_id: string - } + created_at: string; + crm_unsubscribed: boolean; + emails_sent_7d: number; + first_seen: string; + last_active_at: string | null; + last_email_at: string | null; + stage: string; + updated_at: string; + user_id: string; + }; Insert: { - created_at?: string - crm_unsubscribed?: boolean - emails_sent_7d?: number - first_seen?: string - last_active_at?: string | null - last_email_at?: string | null - stage?: string - updated_at?: string - user_id: string - } + created_at?: string; + crm_unsubscribed?: boolean; + emails_sent_7d?: number; + first_seen?: string; + last_active_at?: string | null; + last_email_at?: string | null; + stage?: string; + updated_at?: string; + user_id: string; + }; Update: { - created_at?: string - crm_unsubscribed?: boolean - emails_sent_7d?: number - first_seen?: string - last_active_at?: string | null - last_email_at?: string | null - stage?: string - updated_at?: string - user_id?: string - } - Relationships: [] - } + created_at?: string; + crm_unsubscribed?: boolean; + emails_sent_7d?: number; + first_seen?: string; + last_active_at?: string | null; + last_email_at?: string | null; + stage?: string; + updated_at?: string; + user_id?: string; + }; + Relationships: []; + }; crm_message_log: { Row: { - channel: string - created_at: string - cta_path: string | null - id: string - message_id: string | null - recipient_email: string | null - roi_snapshot: Json - send_hour: number | null - stage_at_send: string | null - template: string - tool_id: string | null - tracking_token: string | null - trigger: string - usage_pattern: string | null - user_id: string - variant: string - } + channel: string; + created_at: string; + cta_path: string | null; + id: string; + message_id: string | null; + recipient_email: string | null; + roi_snapshot: Json; + send_hour: number | null; + stage_at_send: string | null; + template: string; + tool_id: string | null; + tracking_token: string | null; + trigger: string; + usage_pattern: string | null; + user_id: string; + variant: string; + }; Insert: { - channel?: string - created_at?: string - cta_path?: string | null - id?: string - message_id?: string | null - recipient_email?: string | null - roi_snapshot?: Json - send_hour?: number | null - stage_at_send?: string | null - template: string - tool_id?: string | null - tracking_token?: string | null - trigger: string - usage_pattern?: string | null - user_id: string - variant?: string - } + channel?: string; + created_at?: string; + cta_path?: string | null; + id?: string; + message_id?: string | null; + recipient_email?: string | null; + roi_snapshot?: Json; + send_hour?: number | null; + stage_at_send?: string | null; + template: string; + tool_id?: string | null; + tracking_token?: string | null; + trigger: string; + usage_pattern?: string | null; + user_id: string; + variant?: string; + }; Update: { - channel?: string - created_at?: string - cta_path?: string | null - id?: string - message_id?: string | null - recipient_email?: string | null - roi_snapshot?: Json - send_hour?: number | null - stage_at_send?: string | null - template?: string - tool_id?: string | null - tracking_token?: string | null - trigger?: string - usage_pattern?: string | null - user_id?: string - variant?: string - } - Relationships: [] - } + channel?: string; + created_at?: string; + cta_path?: string | null; + id?: string; + message_id?: string | null; + recipient_email?: string | null; + roi_snapshot?: Json; + send_hour?: number | null; + stage_at_send?: string | null; + template?: string; + tool_id?: string | null; + tracking_token?: string | null; + trigger?: string; + usage_pattern?: string | null; + user_id?: string; + variant?: string; + }; + Relationships: []; + }; crm_message_outcomes: { Row: { - clicked_at: string | null - complained_at: string | null - conversion_kind: string | null - converted_at: string | null - created_at: string - id: string - message_log_id: string - opened_at: string | null - scored_at: string | null - send_hour: number | null - trigger: string - unsubscribed_at: string | null - updated_at: string - user_id: string - variant: string - window_closed: boolean - } + clicked_at: string | null; + complained_at: string | null; + conversion_kind: string | null; + converted_at: string | null; + created_at: string; + id: string; + message_log_id: string; + opened_at: string | null; + scored_at: string | null; + send_hour: number | null; + trigger: string; + unsubscribed_at: string | null; + updated_at: string; + user_id: string; + variant: string; + window_closed: boolean; + }; Insert: { - clicked_at?: string | null - complained_at?: string | null - conversion_kind?: string | null - converted_at?: string | null - created_at?: string - id?: string - message_log_id: string - opened_at?: string | null - scored_at?: string | null - send_hour?: number | null - trigger: string - unsubscribed_at?: string | null - updated_at?: string - user_id: string - variant?: string - window_closed?: boolean - } + clicked_at?: string | null; + complained_at?: string | null; + conversion_kind?: string | null; + converted_at?: string | null; + created_at?: string; + id?: string; + message_log_id: string; + opened_at?: string | null; + scored_at?: string | null; + send_hour?: number | null; + trigger: string; + unsubscribed_at?: string | null; + updated_at?: string; + user_id: string; + variant?: string; + window_closed?: boolean; + }; Update: { - clicked_at?: string | null - complained_at?: string | null - conversion_kind?: string | null - converted_at?: string | null - created_at?: string - id?: string - message_log_id?: string - opened_at?: string | null - scored_at?: string | null - send_hour?: number | null - trigger?: string - unsubscribed_at?: string | null - updated_at?: string - user_id?: string - variant?: string - window_closed?: boolean - } + clicked_at?: string | null; + complained_at?: string | null; + conversion_kind?: string | null; + converted_at?: string | null; + created_at?: string; + id?: string; + message_log_id?: string; + opened_at?: string | null; + scored_at?: string | null; + send_hour?: number | null; + trigger?: string; + unsubscribed_at?: string | null; + updated_at?: string; + user_id?: string; + variant?: string; + window_closed?: boolean; + }; Relationships: [ { - foreignKeyName: "crm_message_outcomes_message_log_id_fkey" - columns: ["message_log_id"] - isOneToOne: true - referencedRelation: "crm_message_log" - referencedColumns: ["id"] + foreignKeyName: "crm_message_outcomes_message_log_id_fkey"; + columns: ["message_log_id"]; + isOneToOne: true; + referencedRelation: "crm_message_log"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; crm_settings: { Row: { - key: string - updated_at: string - value: Json - } + key: string; + updated_at: string; + value: Json; + }; Insert: { - key: string - updated_at?: string - value?: Json - } + key: string; + updated_at?: string; + value?: Json; + }; Update: { - key?: string - updated_at?: string - value?: Json - } - Relationships: [] - } + key?: string; + updated_at?: string; + value?: Json; + }; + Relationships: []; + }; crm_tuning_log: { Row: { - action: string - created_at: string - id: string - reason: string - stats: Json - trigger: string | null - variant: string | null - } + action: string; + created_at: string; + id: string; + reason: string; + stats: Json; + trigger: string | null; + variant: string | null; + }; Insert: { - action: string - created_at?: string - id?: string - reason: string - stats?: Json - trigger?: string | null - variant?: string | null - } + action: string; + created_at?: string; + id?: string; + reason: string; + stats?: Json; + trigger?: string | null; + variant?: string | null; + }; Update: { - action?: string - created_at?: string - id?: string - reason?: string - stats?: Json - trigger?: string | null - variant?: string | null - } - Relationships: [] - } + action?: string; + created_at?: string; + id?: string; + reason?: string; + stats?: Json; + trigger?: string | null; + variant?: string | null; + }; + Relationships: []; + }; email_send_log: { Row: { - created_at: string - error_message: string | null - id: string - message_id: string | null - metadata: Json | null - recipient_email: string - status: string - template_name: string - } + created_at: string; + error_message: string | null; + id: string; + message_id: string | null; + metadata: Json | null; + recipient_email: string; + status: string; + template_name: string; + }; Insert: { - created_at?: string - error_message?: string | null - id?: string - message_id?: string | null - metadata?: Json | null - recipient_email: string - status: string - template_name: string - } + created_at?: string; + error_message?: string | null; + id?: string; + message_id?: string | null; + metadata?: Json | null; + recipient_email: string; + status: string; + template_name: string; + }; Update: { - created_at?: string - error_message?: string | null - id?: string - message_id?: string | null - metadata?: Json | null - recipient_email?: string - status?: string - template_name?: string - } - Relationships: [] - } + created_at?: string; + error_message?: string | null; + id?: string; + message_id?: string | null; + metadata?: Json | null; + recipient_email?: string; + status?: string; + template_name?: string; + }; + Relationships: []; + }; email_send_state: { Row: { - auth_email_ttl_minutes: number - batch_size: number - id: number - retry_after_until: string | null - send_delay_ms: number - transactional_email_ttl_minutes: number - updated_at: string - } + auth_email_ttl_minutes: number; + batch_size: number; + id: number; + retry_after_until: string | null; + send_delay_ms: number; + transactional_email_ttl_minutes: number; + updated_at: string; + }; Insert: { - auth_email_ttl_minutes?: number - batch_size?: number - id?: number - retry_after_until?: string | null - send_delay_ms?: number - transactional_email_ttl_minutes?: number - updated_at?: string - } + auth_email_ttl_minutes?: number; + batch_size?: number; + id?: number; + retry_after_until?: string | null; + send_delay_ms?: number; + transactional_email_ttl_minutes?: number; + updated_at?: string; + }; Update: { - auth_email_ttl_minutes?: number - batch_size?: number - id?: number - retry_after_until?: string | null - send_delay_ms?: number - transactional_email_ttl_minutes?: number - updated_at?: string - } - Relationships: [] - } + auth_email_ttl_minutes?: number; + batch_size?: number; + id?: number; + retry_after_until?: string | null; + send_delay_ms?: number; + transactional_email_ttl_minutes?: number; + updated_at?: string; + }; + Relationships: []; + }; email_unsubscribe_tokens: { Row: { - created_at: string - email: string - id: string - token: string - used_at: string | null - } + created_at: string; + email: string; + id: string; + token: string; + used_at: string | null; + }; Insert: { - created_at?: string - email: string - id?: string - token: string - used_at?: string | null - } + created_at?: string; + email: string; + id?: string; + token: string; + used_at?: string | null; + }; Update: { - created_at?: string - email?: string - id?: string - token?: string - used_at?: string | null - } - Relationships: [] - } + created_at?: string; + email?: string; + id?: string; + token?: string; + used_at?: string | null; + }; + Relationships: []; + }; enterprise_requests: { Row: { - admin_notes: string | null - checklist: Json - company: string - contact_name: string - created_at: string - id: string - ip_concerns: string | null - nda_accepted: boolean - nda_accepted_at: string | null - nda_ip: string | null - nda_required: boolean - nda_signer_name: string | null - role: string | null - status: string - team_size: string | null - updated_at: string - use_case: string - user_id: string | null - work_email: string - } + admin_notes: string | null; + checklist: Json; + company: string; + contact_name: string; + created_at: string; + id: string; + ip_concerns: string | null; + nda_accepted: boolean; + nda_accepted_at: string | null; + nda_ip: string | null; + nda_required: boolean; + nda_signer_name: string | null; + role: string | null; + status: string; + team_size: string | null; + updated_at: string; + use_case: string; + user_id: string | null; + work_email: string; + }; Insert: { - admin_notes?: string | null - checklist?: Json - company: string - contact_name: string - created_at?: string - id?: string - ip_concerns?: string | null - nda_accepted?: boolean - nda_accepted_at?: string | null - nda_ip?: string | null - nda_required?: boolean - nda_signer_name?: string | null - role?: string | null - status?: string - team_size?: string | null - updated_at?: string - use_case: string - user_id?: string | null - work_email: string - } + admin_notes?: string | null; + checklist?: Json; + company: string; + contact_name: string; + created_at?: string; + id?: string; + ip_concerns?: string | null; + nda_accepted?: boolean; + nda_accepted_at?: string | null; + nda_ip?: string | null; + nda_required?: boolean; + nda_signer_name?: string | null; + role?: string | null; + status?: string; + team_size?: string | null; + updated_at?: string; + use_case: string; + user_id?: string | null; + work_email: string; + }; Update: { - admin_notes?: string | null - checklist?: Json - company?: string - contact_name?: string - created_at?: string - id?: string - ip_concerns?: string | null - nda_accepted?: boolean - nda_accepted_at?: string | null - nda_ip?: string | null - nda_required?: boolean - nda_signer_name?: string | null - role?: string | null - status?: string - team_size?: string | null - updated_at?: string - use_case?: string - user_id?: string | null - work_email?: string - } - Relationships: [] - } + admin_notes?: string | null; + checklist?: Json; + company?: string; + contact_name?: string; + created_at?: string; + id?: string; + ip_concerns?: string | null; + nda_accepted?: boolean; + nda_accepted_at?: string | null; + nda_ip?: string | null; + nda_required?: boolean; + nda_signer_name?: string | null; + role?: string | null; + status?: string; + team_size?: string | null; + updated_at?: string; + use_case?: string; + user_id?: string | null; + work_email?: string; + }; + Relationships: []; + }; external_certifications: { Row: { - content_sha256: string - created_at: string - engine_version: string - grade: string - id: string - name: string - overall_score: number - report: Json - type: string - } + content_sha256: string; + created_at: string; + engine_version: string; + grade: string; + id: string; + name: string; + overall_score: number; + report: Json; + type: string; + }; Insert: { - content_sha256: string - created_at?: string - engine_version: string - grade: string - id?: string - name: string - overall_score: number - report?: Json - type: string - } + content_sha256: string; + created_at?: string; + engine_version: string; + grade: string; + id?: string; + name: string; + overall_score: number; + report?: Json; + type: string; + }; Update: { - content_sha256?: string - created_at?: string - engine_version?: string - grade?: string - id?: string - name?: string - overall_score?: number - report?: Json - type?: string - } - Relationships: [] - } + content_sha256?: string; + created_at?: string; + engine_version?: string; + grade?: string; + id?: string; + name?: string; + overall_score?: number; + report?: Json; + type?: string; + }; + Relationships: []; + }; learnings: { Row: { - applied_in_version_id: string | null - cluster_key: string | null - created_at: string - evidence: Json - id: string - kind: Database["public"]["Enums"]["learning_kind"] - package_id: string - package_slug: string - run_id: string | null - suggested_patch: string | null - user_id: string | null - weight: number - } + applied_in_version_id: string | null; + cluster_key: string | null; + created_at: string; + evidence: Json; + id: string; + kind: Database["public"]["Enums"]["learning_kind"]; + package_id: string; + package_slug: string; + run_id: string | null; + suggested_patch: string | null; + user_id: string | null; + weight: number; + }; Insert: { - applied_in_version_id?: string | null - cluster_key?: string | null - created_at?: string - evidence?: Json - id?: string - kind: Database["public"]["Enums"]["learning_kind"] - package_id: string - package_slug: string - run_id?: string | null - suggested_patch?: string | null - user_id?: string | null - weight?: number - } + applied_in_version_id?: string | null; + cluster_key?: string | null; + created_at?: string; + evidence?: Json; + id?: string; + kind: Database["public"]["Enums"]["learning_kind"]; + package_id: string; + package_slug: string; + run_id?: string | null; + suggested_patch?: string | null; + user_id?: string | null; + weight?: number; + }; Update: { - applied_in_version_id?: string | null - cluster_key?: string | null - created_at?: string - evidence?: Json - id?: string - kind?: Database["public"]["Enums"]["learning_kind"] - package_id?: string - package_slug?: string - run_id?: string | null - suggested_patch?: string | null - user_id?: string | null - weight?: number - } + applied_in_version_id?: string | null; + cluster_key?: string | null; + created_at?: string; + evidence?: Json; + id?: string; + kind?: Database["public"]["Enums"]["learning_kind"]; + package_id?: string; + package_slug?: string; + run_id?: string | null; + suggested_patch?: string | null; + user_id?: string | null; + weight?: number; + }; Relationships: [ { - foreignKeyName: "learnings_applied_in_version_id_fkey" - columns: ["applied_in_version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "learnings_applied_in_version_id_fkey"; + columns: ["applied_in_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "learnings_applied_in_version_id_fkey" - columns: ["applied_in_version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "learnings_applied_in_version_id_fkey"; + columns: ["applied_in_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, { - foreignKeyName: "learnings_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "learnings_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "learnings_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "learnings_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "learnings_run_id_fkey" - columns: ["run_id"] - isOneToOne: false - referencedRelation: "runs" - referencedColumns: ["id"] + foreignKeyName: "learnings_run_id_fkey"; + columns: ["run_id"]; + isOneToOne: false; + referencedRelation: "runs"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; mcp_call_log: { Row: { - created_at: string - id: string - identity: string - is_write: boolean - tool_name: string - user_id: string | null - } + created_at: string; + id: string; + identity: string; + is_write: boolean; + tool_name: string; + user_id: string | null; + }; Insert: { - created_at?: string - id?: string - identity: string - is_write?: boolean - tool_name: string - user_id?: string | null - } + created_at?: string; + id?: string; + identity: string; + is_write?: boolean; + tool_name: string; + user_id?: string | null; + }; Update: { - created_at?: string - id?: string - identity?: string - is_write?: boolean - tool_name?: string - user_id?: string | null - } - Relationships: [] - } + created_at?: string; + id?: string; + identity?: string; + is_write?: boolean; + tool_name?: string; + user_id?: string | null; + }; + Relationships: []; + }; mcp_funnel_events: { Row: { - anon_hash: string | null - client_id: string | null - client_name: string | null - created_at: string - event: string - id: number - props: Json - user_id: string | null - } + anon_hash: string | null; + client_id: string | null; + client_name: string | null; + created_at: string; + event: string; + id: number; + props: Json; + user_id: string | null; + }; Insert: { - anon_hash?: string | null - client_id?: string | null - client_name?: string | null - created_at?: string - event: string - id?: number - props?: Json - user_id?: string | null - } + anon_hash?: string | null; + client_id?: string | null; + client_name?: string | null; + created_at?: string; + event: string; + id?: number; + props?: Json; + user_id?: string | null; + }; Update: { - anon_hash?: string | null - client_id?: string | null - client_name?: string | null - created_at?: string - event?: string - id?: number - props?: Json - user_id?: string | null - } - Relationships: [] - } + anon_hash?: string | null; + client_id?: string | null; + client_name?: string | null; + created_at?: string; + event?: string; + id?: number; + props?: Json; + user_id?: string | null; + }; + Relationships: []; + }; mcp_idempotency: { Row: { - created_at: string - expires_at: string - key_hash: string - response: Json - tool: string - user_id: string - } + created_at: string; + expires_at: string; + key_hash: string; + response: Json; + tool: string; + user_id: string; + }; Insert: { - created_at?: string - expires_at?: string - key_hash: string - response: Json - tool: string - user_id: string - } + created_at?: string; + expires_at?: string; + key_hash: string; + response: Json; + tool: string; + user_id: string; + }; Update: { - created_at?: string - expires_at?: string - key_hash?: string - response?: Json - tool?: string - user_id?: string - } - Relationships: [] - } + created_at?: string; + expires_at?: string; + key_hash?: string; + response?: Json; + tool?: string; + user_id?: string; + }; + Relationships: []; + }; mcp_oauth_authorizations: { Row: { - client_id: string - code_challenge: string - code_challenge_method: string - code_hash: string - created_at: string - expires_at: string - redirect_uri: string - scope: string - used_at: string | null - user_id: string - } + client_id: string; + code_challenge: string; + code_challenge_method: string; + code_hash: string; + created_at: string; + expires_at: string; + redirect_uri: string; + scope: string; + used_at: string | null; + user_id: string; + }; Insert: { - client_id: string - code_challenge: string - code_challenge_method?: string - code_hash: string - created_at?: string - expires_at: string - redirect_uri: string - scope: string - used_at?: string | null - user_id: string - } + client_id: string; + code_challenge: string; + code_challenge_method?: string; + code_hash: string; + created_at?: string; + expires_at: string; + redirect_uri: string; + scope: string; + used_at?: string | null; + user_id: string; + }; Update: { - client_id?: string - code_challenge?: string - code_challenge_method?: string - code_hash?: string - created_at?: string - expires_at?: string - redirect_uri?: string - scope?: string - used_at?: string | null - user_id?: string - } + client_id?: string; + code_challenge?: string; + code_challenge_method?: string; + code_hash?: string; + created_at?: string; + expires_at?: string; + redirect_uri?: string; + scope?: string; + used_at?: string | null; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "mcp_oauth_authorizations_client_id_fkey" - columns: ["client_id"] - isOneToOne: false - referencedRelation: "mcp_oauth_clients" - referencedColumns: ["client_id"] + foreignKeyName: "mcp_oauth_authorizations_client_id_fkey"; + columns: ["client_id"]; + isOneToOne: false; + referencedRelation: "mcp_oauth_clients"; + referencedColumns: ["client_id"]; }, - ] - } + ]; + }; mcp_oauth_clients: { Row: { - client_id: string - client_name: string - client_uri: string | null - created_at: string - created_ip: string | null - grant_types: string[] - logo_uri: string | null - redirect_uris: string[] - response_types: string[] - scope: string - software_id: string | null - software_version: string | null - token_endpoint_auth_method: string - } + client_id: string; + client_name: string; + client_uri: string | null; + created_at: string; + created_ip: string | null; + grant_types: string[]; + logo_uri: string | null; + redirect_uris: string[]; + response_types: string[]; + scope: string; + software_id: string | null; + software_version: string | null; + token_endpoint_auth_method: string; + }; Insert: { - client_id: string - client_name?: string - client_uri?: string | null - created_at?: string - created_ip?: string | null - grant_types?: string[] - logo_uri?: string | null - redirect_uris: string[] - response_types?: string[] - scope?: string - software_id?: string | null - software_version?: string | null - token_endpoint_auth_method?: string - } + client_id: string; + client_name?: string; + client_uri?: string | null; + created_at?: string; + created_ip?: string | null; + grant_types?: string[]; + logo_uri?: string | null; + redirect_uris: string[]; + response_types?: string[]; + scope?: string; + software_id?: string | null; + software_version?: string | null; + token_endpoint_auth_method?: string; + }; Update: { - client_id?: string - client_name?: string - client_uri?: string | null - created_at?: string - created_ip?: string | null - grant_types?: string[] - logo_uri?: string | null - redirect_uris?: string[] - response_types?: string[] - scope?: string - software_id?: string | null - software_version?: string | null - token_endpoint_auth_method?: string - } - Relationships: [] - } + client_id?: string; + client_name?: string; + client_uri?: string | null; + created_at?: string; + created_ip?: string | null; + grant_types?: string[]; + logo_uri?: string | null; + redirect_uris?: string[]; + response_types?: string[]; + scope?: string; + software_id?: string | null; + software_version?: string | null; + token_endpoint_auth_method?: string; + }; + Relationships: []; + }; mcp_oauth_tokens: { Row: { - client_id: string - created_at: string - expires_at: string - kind: string - last_used_at: string | null - parent_token_hash: string | null - revoked_at: string | null - scope: string - token_hash: string - user_id: string - } + client_id: string; + created_at: string; + expires_at: string; + kind: string; + last_used_at: string | null; + parent_token_hash: string | null; + revoked_at: string | null; + scope: string; + token_hash: string; + user_id: string; + }; Insert: { - client_id: string - created_at?: string - expires_at: string - kind: string - last_used_at?: string | null - parent_token_hash?: string | null - revoked_at?: string | null - scope: string - token_hash: string - user_id: string - } + client_id: string; + created_at?: string; + expires_at: string; + kind: string; + last_used_at?: string | null; + parent_token_hash?: string | null; + revoked_at?: string | null; + scope: string; + token_hash: string; + user_id: string; + }; Update: { - client_id?: string - created_at?: string - expires_at?: string - kind?: string - last_used_at?: string | null - parent_token_hash?: string | null - revoked_at?: string | null - scope?: string - token_hash?: string - user_id?: string - } + client_id?: string; + created_at?: string; + expires_at?: string; + kind?: string; + last_used_at?: string | null; + parent_token_hash?: string | null; + revoked_at?: string | null; + scope?: string; + token_hash?: string; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "mcp_oauth_tokens_client_id_fkey" - columns: ["client_id"] - isOneToOne: false - referencedRelation: "mcp_oauth_clients" - referencedColumns: ["client_id"] + foreignKeyName: "mcp_oauth_tokens_client_id_fkey"; + columns: ["client_id"]; + isOneToOne: false; + referencedRelation: "mcp_oauth_clients"; + referencedColumns: ["client_id"]; }, - ] - } + ]; + }; mcp_tokens: { Row: { - created_at: string - id: string - last_used_at: string | null - name: string - prefix: string - token_hash: string - user_id: string - } + created_at: string; + id: string; + last_used_at: string | null; + name: string; + prefix: string; + token_hash: string; + user_id: string; + }; Insert: { - created_at?: string - id?: string - last_used_at?: string | null - name: string - prefix: string - token_hash: string - user_id: string - } + created_at?: string; + id?: string; + last_used_at?: string | null; + name: string; + prefix: string; + token_hash: string; + user_id: string; + }; Update: { - created_at?: string - id?: string - last_used_at?: string | null - name?: string - prefix?: string - token_hash?: string - user_id?: string - } - Relationships: [] - } + created_at?: string; + id?: string; + last_used_at?: string | null; + name?: string; + prefix?: string; + token_hash?: string; + user_id?: string; + }; + Relationships: []; + }; newsletter_signups: { Row: { - created_at: string - email: string - id: string - source: string | null - } + created_at: string; + email: string; + id: string; + source: string | null; + }; Insert: { - created_at?: string - email: string - id?: string - source?: string | null - } + created_at?: string; + email: string; + id?: string; + source?: string | null; + }; Update: { - created_at?: string - email?: string - id?: string - source?: string | null - } - Relationships: [] - } + created_at?: string; + email?: string; + id?: string; + source?: string | null; + }; + Relationships: []; + }; pack_customizations: { Row: { - audience: string | null - brief: string - created_at: string - error: string | null - id: string - items: Json - niche: string | null - pack_id: string - research_sources: Json - research_summary: string | null - status: string - updated_at: string - user_id: string - voice: string | null - } + audience: string | null; + brief: string; + created_at: string; + error: string | null; + id: string; + items: Json; + niche: string | null; + pack_id: string; + research_sources: Json; + research_summary: string | null; + status: string; + updated_at: string; + user_id: string; + voice: string | null; + }; Insert: { - audience?: string | null - brief: string - created_at?: string - error?: string | null - id?: string - items?: Json - niche?: string | null - pack_id: string - research_sources?: Json - research_summary?: string | null - status?: string - updated_at?: string - user_id: string - voice?: string | null - } + audience?: string | null; + brief: string; + created_at?: string; + error?: string | null; + id?: string; + items?: Json; + niche?: string | null; + pack_id: string; + research_sources?: Json; + research_summary?: string | null; + status?: string; + updated_at?: string; + user_id: string; + voice?: string | null; + }; Update: { - audience?: string | null - brief?: string - created_at?: string - error?: string | null - id?: string - items?: Json - niche?: string | null - pack_id?: string - research_sources?: Json - research_summary?: string | null - status?: string - updated_at?: string - user_id?: string - voice?: string | null - } + audience?: string | null; + brief?: string; + created_at?: string; + error?: string | null; + id?: string; + items?: Json; + niche?: string | null; + pack_id?: string; + research_sources?: Json; + research_summary?: string | null; + status?: string; + updated_at?: string; + user_id?: string; + voice?: string | null; + }; Relationships: [ { - foreignKeyName: "pack_customizations_pack_id_fkey" - columns: ["pack_id"] - isOneToOne: false - referencedRelation: "packs" - referencedColumns: ["id"] + foreignKeyName: "pack_customizations_pack_id_fkey"; + columns: ["pack_id"]; + isOneToOne: false; + referencedRelation: "packs"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; pack_items: { Row: { - pack_id: string - package_id: string - role: string - sort_order: number - } + pack_id: string; + package_id: string; + role: string; + sort_order: number; + }; Insert: { - pack_id: string - package_id: string - role?: string - sort_order?: number - } + pack_id: string; + package_id: string; + role?: string; + sort_order?: number; + }; Update: { - pack_id?: string - package_id?: string - role?: string - sort_order?: number - } + pack_id?: string; + package_id?: string; + role?: string; + sort_order?: number; + }; Relationships: [ { - foreignKeyName: "pack_items_pack_id_fkey" - columns: ["pack_id"] - isOneToOne: false - referencedRelation: "packs" - referencedColumns: ["id"] + foreignKeyName: "pack_items_pack_id_fkey"; + columns: ["pack_id"]; + isOneToOne: false; + referencedRelation: "packs"; + referencedColumns: ["id"]; }, { - foreignKeyName: "pack_items_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "pack_items_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "pack_items_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "pack_items_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; pack_purchases: { Row: { - author_credits: number - author_id: string | null - buyer_id: string - created_at: string - credits_paid: number - id: string - pack_id: string - platform_credits: number - } + author_credits: number; + author_id: string | null; + buyer_id: string; + created_at: string; + credits_paid: number; + id: string; + pack_id: string; + platform_credits: number; + }; Insert: { - author_credits?: number - author_id?: string | null - buyer_id: string - created_at?: string - credits_paid: number - id?: string - pack_id: string - platform_credits?: number - } + author_credits?: number; + author_id?: string | null; + buyer_id: string; + created_at?: string; + credits_paid: number; + id?: string; + pack_id: string; + platform_credits?: number; + }; Update: { - author_credits?: number - author_id?: string | null - buyer_id?: string - created_at?: string - credits_paid?: number - id?: string - pack_id?: string - platform_credits?: number - } + author_credits?: number; + author_id?: string | null; + buyer_id?: string; + created_at?: string; + credits_paid?: number; + id?: string; + pack_id?: string; + platform_credits?: number; + }; Relationships: [ { - foreignKeyName: "pack_purchases_pack_id_fkey" - columns: ["pack_id"] - isOneToOne: false - referencedRelation: "packs" - referencedColumns: ["id"] + foreignKeyName: "pack_purchases_pack_id_fkey"; + columns: ["pack_id"]; + isOneToOne: false; + referencedRelation: "packs"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_artifacts: { Row: { - created_at: string - created_by: string | null - files: Json - package_id: string - sha256: string - version_id: string - } + created_at: string; + created_by: string | null; + files: Json; + package_id: string; + sha256: string; + version_id: string; + }; Insert: { - created_at?: string - created_by?: string | null - files: Json - package_id: string - sha256: string - version_id: string - } + created_at?: string; + created_by?: string | null; + files: Json; + package_id: string; + sha256: string; + version_id: string; + }; Update: { - created_at?: string - created_by?: string | null - files?: Json - package_id?: string - sha256?: string - version_id?: string - } + created_at?: string; + created_by?: string | null; + files?: Json; + package_id?: string; + sha256?: string; + version_id?: string; + }; Relationships: [ { - foreignKeyName: "package_artifacts_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_artifacts_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_artifacts_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_artifacts_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_artifacts_version_id_fkey" - columns: ["version_id"] - isOneToOne: true - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "package_artifacts_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: true; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_artifacts_version_id_fkey" - columns: ["version_id"] - isOneToOne: true - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "package_artifacts_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: true; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_embeddings: { Row: { - created_at: string - embedding: string - model: string - package_id: string - source_sha256: string - version: string - } + created_at: string; + embedding: string; + model: string; + package_id: string; + source_sha256: string; + version: string; + }; Insert: { - created_at?: string - embedding: string - model: string - package_id: string - source_sha256: string - version: string - } + created_at?: string; + embedding: string; + model: string; + package_id: string; + source_sha256: string; + version: string; + }; Update: { - created_at?: string - embedding?: string - model?: string - package_id?: string - source_sha256?: string - version?: string - } + created_at?: string; + embedding?: string; + model?: string; + package_id?: string; + source_sha256?: string; + version?: string; + }; Relationships: [ { - foreignKeyName: "package_embeddings_package_id_fkey" - columns: ["package_id"] - isOneToOne: true - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_embeddings_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: true; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_embeddings_package_id_fkey" - columns: ["package_id"] - isOneToOne: true - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_embeddings_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: true; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_evaluations: { Row: { - adversarial_results: Json - created_at: string - efficiency: Json | null - evolution_trace: Json | null - example_results: Json - hallucination_rate: number | null - health_score: number | null - id: string - improvement_actions: Json - judge_calibration: Json | null - overall_score: number | null - package_id: string - pipeline_stages: Json - precision_score: number | null - safety_score: number | null - strengths: Json - trigger_kind: string - triggered_by: string | null - verdict: string | null - version_id: string | null - weaknesses: Json - } + adversarial_results: Json; + created_at: string; + efficiency: Json | null; + evolution_trace: Json | null; + example_results: Json; + hallucination_rate: number | null; + health_score: number | null; + id: string; + improvement_actions: Json; + judge_calibration: Json | null; + overall_score: number | null; + package_id: string; + pipeline_stages: Json; + precision_score: number | null; + safety_score: number | null; + strengths: Json; + trigger_kind: string; + triggered_by: string | null; + verdict: string | null; + version_id: string | null; + weaknesses: Json; + }; Insert: { - adversarial_results?: Json - created_at?: string - efficiency?: Json | null - evolution_trace?: Json | null - example_results?: Json - hallucination_rate?: number | null - health_score?: number | null - id?: string - improvement_actions?: Json - judge_calibration?: Json | null - overall_score?: number | null - package_id: string - pipeline_stages?: Json - precision_score?: number | null - safety_score?: number | null - strengths?: Json - trigger_kind?: string - triggered_by?: string | null - verdict?: string | null - version_id?: string | null - weaknesses?: Json - } + adversarial_results?: Json; + created_at?: string; + efficiency?: Json | null; + evolution_trace?: Json | null; + example_results?: Json; + hallucination_rate?: number | null; + health_score?: number | null; + id?: string; + improvement_actions?: Json; + judge_calibration?: Json | null; + overall_score?: number | null; + package_id: string; + pipeline_stages?: Json; + precision_score?: number | null; + safety_score?: number | null; + strengths?: Json; + trigger_kind?: string; + triggered_by?: string | null; + verdict?: string | null; + version_id?: string | null; + weaknesses?: Json; + }; Update: { - adversarial_results?: Json - created_at?: string - efficiency?: Json | null - evolution_trace?: Json | null - example_results?: Json - hallucination_rate?: number | null - health_score?: number | null - id?: string - improvement_actions?: Json - judge_calibration?: Json | null - overall_score?: number | null - package_id?: string - pipeline_stages?: Json - precision_score?: number | null - safety_score?: number | null - strengths?: Json - trigger_kind?: string - triggered_by?: string | null - verdict?: string | null - version_id?: string | null - weaknesses?: Json - } - Relationships: [] - } + adversarial_results?: Json; + created_at?: string; + efficiency?: Json | null; + evolution_trace?: Json | null; + example_results?: Json; + hallucination_rate?: number | null; + health_score?: number | null; + id?: string; + improvement_actions?: Json; + judge_calibration?: Json | null; + overall_score?: number | null; + package_id?: string; + pipeline_stages?: Json; + precision_score?: number | null; + safety_score?: number | null; + strengths?: Json; + trigger_kind?: string; + triggered_by?: string | null; + verdict?: string | null; + version_id?: string | null; + weaknesses?: Json; + }; + Relationships: []; + }; package_feedback: { Row: { - agent_model: string | null - comments: string | null - context: Json - created_at: string - id: string - kind: string | null - package_id: string | null - rating: number | null - request_id: string | null - sentiment: string | null - source: string - submitter_id: string | null - } + agent_model: string | null; + comments: string | null; + context: Json; + created_at: string; + id: string; + kind: string | null; + package_id: string | null; + rating: number | null; + request_id: string | null; + sentiment: string | null; + source: string; + submitter_id: string | null; + }; Insert: { - agent_model?: string | null - comments?: string | null - context?: Json - created_at?: string - id?: string - kind?: string | null - package_id?: string | null - rating?: number | null - request_id?: string | null - sentiment?: string | null - source: string - submitter_id?: string | null - } + agent_model?: string | null; + comments?: string | null; + context?: Json; + created_at?: string; + id?: string; + kind?: string | null; + package_id?: string | null; + rating?: number | null; + request_id?: string | null; + sentiment?: string | null; + source: string; + submitter_id?: string | null; + }; Update: { - agent_model?: string | null - comments?: string | null - context?: Json - created_at?: string - id?: string - kind?: string | null - package_id?: string | null - rating?: number | null - request_id?: string | null - sentiment?: string | null - source?: string - submitter_id?: string | null - } + agent_model?: string | null; + comments?: string | null; + context?: Json; + created_at?: string; + id?: string; + kind?: string | null; + package_id?: string | null; + rating?: number | null; + request_id?: string | null; + sentiment?: string | null; + source?: string; + submitter_id?: string | null; + }; Relationships: [ { - foreignKeyName: "package_feedback_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_feedback_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_feedback_request_id_fkey" - columns: ["request_id"] - isOneToOne: false - referencedRelation: "package_feedback_requests" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_request_id_fkey"; + columns: ["request_id"]; + isOneToOne: false; + referencedRelation: "package_feedback_requests"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_feedback_requests: { Row: { - context: Json - created_at: string - expires_at: string - fulfilled_at: string | null - id: string - kind: string - package_id: string | null - source: string - source_user_id: string | null - version_id: string | null - } + context: Json; + created_at: string; + expires_at: string; + fulfilled_at: string | null; + id: string; + kind: string; + package_id: string | null; + source: string; + source_user_id: string | null; + version_id: string | null; + }; Insert: { - context?: Json - created_at?: string - expires_at?: string - fulfilled_at?: string | null - id?: string - kind: string - package_id?: string | null - source?: string - source_user_id?: string | null - version_id?: string | null - } + context?: Json; + created_at?: string; + expires_at?: string; + fulfilled_at?: string | null; + id?: string; + kind: string; + package_id?: string | null; + source?: string; + source_user_id?: string | null; + version_id?: string | null; + }; Update: { - context?: Json - created_at?: string - expires_at?: string - fulfilled_at?: string | null - id?: string - kind?: string - package_id?: string | null - source?: string - source_user_id?: string | null - version_id?: string | null - } + context?: Json; + created_at?: string; + expires_at?: string; + fulfilled_at?: string | null; + id?: string; + kind?: string; + package_id?: string | null; + source?: string; + source_user_id?: string | null; + version_id?: string | null; + }; Relationships: [ { - foreignKeyName: "package_feedback_requests_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_requests_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_feedback_requests_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_requests_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_feedback_requests_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_requests_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_feedback_requests_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "package_feedback_requests_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_golden_cases: { Row: { - created_at: string - created_by: string | null - expected_output: string - frozen: boolean - id: string - input: string - is_active: boolean - label_pass: boolean - label_source: string - origin_version_id: string | null - package_id: string - title: string - } + created_at: string; + created_by: string | null; + expected_output: string; + frozen: boolean; + id: string; + input: string; + is_active: boolean; + label_pass: boolean; + label_source: string; + origin_version_id: string | null; + package_id: string; + title: string; + }; Insert: { - created_at?: string - created_by?: string | null - expected_output: string - frozen?: boolean - id?: string - input: string - is_active?: boolean - label_pass?: boolean - label_source?: string - origin_version_id?: string | null - package_id: string - title: string - } + created_at?: string; + created_by?: string | null; + expected_output: string; + frozen?: boolean; + id?: string; + input: string; + is_active?: boolean; + label_pass?: boolean; + label_source?: string; + origin_version_id?: string | null; + package_id: string; + title: string; + }; Update: { - created_at?: string - created_by?: string | null - expected_output?: string - frozen?: boolean - id?: string - input?: string - is_active?: boolean - label_pass?: boolean - label_source?: string - origin_version_id?: string | null - package_id?: string - title?: string - } + created_at?: string; + created_by?: string | null; + expected_output?: string; + frozen?: boolean; + id?: string; + input?: string; + is_active?: boolean; + label_pass?: boolean; + label_source?: string; + origin_version_id?: string | null; + package_id?: string; + title?: string; + }; Relationships: [ { - foreignKeyName: "package_golden_cases_origin_version_id_fkey" - columns: ["origin_version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "package_golden_cases_origin_version_id_fkey"; + columns: ["origin_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_golden_cases_origin_version_id_fkey" - columns: ["origin_version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "package_golden_cases_origin_version_id_fkey"; + columns: ["origin_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_golden_cases_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_golden_cases_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_golden_cases_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_golden_cases_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_imports: { Row: { - created_at: string - created_by: string | null - generated_package_id: string | null - id: string - notes: string | null - raw_input: string | null - source_kind: string - source_ref: string - status: string - updated_at: string - } + created_at: string; + created_by: string | null; + generated_package_id: string | null; + id: string; + notes: string | null; + raw_input: string | null; + source_kind: string; + source_ref: string; + status: string; + updated_at: string; + }; Insert: { - created_at?: string - created_by?: string | null - generated_package_id?: string | null - id?: string - notes?: string | null - raw_input?: string | null - source_kind: string - source_ref: string - status?: string - updated_at?: string - } + created_at?: string; + created_by?: string | null; + generated_package_id?: string | null; + id?: string; + notes?: string | null; + raw_input?: string | null; + source_kind: string; + source_ref: string; + status?: string; + updated_at?: string; + }; Update: { - created_at?: string - created_by?: string | null - generated_package_id?: string | null - id?: string - notes?: string | null - raw_input?: string | null - source_kind?: string - source_ref?: string - status?: string - updated_at?: string - } - Relationships: [] - } + created_at?: string; + created_by?: string | null; + generated_package_id?: string | null; + id?: string; + notes?: string | null; + raw_input?: string | null; + source_kind?: string; + source_ref?: string; + status?: string; + updated_at?: string; + }; + Relationships: []; + }; package_installs: { Row: { - installed_at: string - package_id: string - updated_at: string - user_id: string - version: string | null - } + installed_at: string; + package_id: string; + updated_at: string; + user_id: string; + version: string | null; + }; Insert: { - installed_at?: string - package_id: string - updated_at?: string - user_id: string - version?: string | null - } + installed_at?: string; + package_id: string; + updated_at?: string; + user_id: string; + version?: string | null; + }; Update: { - installed_at?: string - package_id?: string - updated_at?: string - user_id?: string - version?: string | null - } + installed_at?: string; + package_id?: string; + updated_at?: string; + user_id?: string; + version?: string | null; + }; Relationships: [ { - foreignKeyName: "package_installs_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_installs_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_installs_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_installs_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_metrics_daily: { Row: { - avg_hallucination: number | null - avg_health: number | null - avg_latency_ms: number | null - avg_precision: number | null - blocked_runs: number - day: string - error_runs: number - ok_runs: number - package_id: string - runs: number - } + avg_hallucination: number | null; + avg_health: number | null; + avg_latency_ms: number | null; + avg_precision: number | null; + blocked_runs: number; + day: string; + error_runs: number; + ok_runs: number; + package_id: string; + runs: number; + }; Insert: { - avg_hallucination?: number | null - avg_health?: number | null - avg_latency_ms?: number | null - avg_precision?: number | null - blocked_runs?: number - day: string - error_runs?: number - ok_runs?: number - package_id: string - runs?: number - } + avg_hallucination?: number | null; + avg_health?: number | null; + avg_latency_ms?: number | null; + avg_precision?: number | null; + blocked_runs?: number; + day: string; + error_runs?: number; + ok_runs?: number; + package_id: string; + runs?: number; + }; Update: { - avg_hallucination?: number | null - avg_health?: number | null - avg_latency_ms?: number | null - avg_precision?: number | null - blocked_runs?: number - day?: string - error_runs?: number - ok_runs?: number - package_id?: string - runs?: number - } + avg_hallucination?: number | null; + avg_health?: number | null; + avg_latency_ms?: number | null; + avg_precision?: number | null; + blocked_runs?: number; + day?: string; + error_runs?: number; + ok_runs?: number; + package_id?: string; + runs?: number; + }; Relationships: [ { - foreignKeyName: "package_metrics_daily_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_metrics_daily_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_metrics_daily_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_metrics_daily_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_purchases: { Row: { - author_credits: number - author_id: string | null - buyer_id: string - created_at: string - credits_paid: number - id: string - package_id: string - platform_credits: number - } + author_credits: number; + author_id: string | null; + buyer_id: string; + created_at: string; + credits_paid: number; + id: string; + package_id: string; + platform_credits: number; + }; Insert: { - author_credits?: number - author_id?: string | null - buyer_id: string - created_at?: string - credits_paid: number - id?: string - package_id: string - platform_credits?: number - } + author_credits?: number; + author_id?: string | null; + buyer_id: string; + created_at?: string; + credits_paid: number; + id?: string; + package_id: string; + platform_credits?: number; + }; Update: { - author_credits?: number - author_id?: string | null - buyer_id?: string - created_at?: string - credits_paid?: number - id?: string - package_id?: string - platform_credits?: number - } - Relationships: [] - } + author_credits?: number; + author_id?: string | null; + buyer_id?: string; + created_at?: string; + credits_paid?: number; + id?: string; + package_id?: string; + platform_credits?: number; + }; + Relationships: []; + }; package_releases: { Row: { - content_hash: string - id: string - package_id: string - signature: string - signed_at: string - signed_by: string | null - signing_key_id: string - version: string - version_id: string - } + content_hash: string; + id: string; + package_id: string; + signature: string; + signed_at: string; + signed_by: string | null; + signing_key_id: string; + version: string; + version_id: string; + }; Insert: { - content_hash: string - id?: string - package_id: string - signature: string - signed_at?: string - signed_by?: string | null - signing_key_id: string - version: string - version_id: string - } + content_hash: string; + id?: string; + package_id: string; + signature: string; + signed_at?: string; + signed_by?: string | null; + signing_key_id: string; + version: string; + version_id: string; + }; Update: { - content_hash?: string - id?: string - package_id?: string - signature?: string - signed_at?: string - signed_by?: string | null - signing_key_id?: string - version?: string - version_id?: string - } + content_hash?: string; + id?: string; + package_id?: string; + signature?: string; + signed_at?: string; + signed_by?: string | null; + signing_key_id?: string; + version?: string; + version_id?: string; + }; Relationships: [ { - foreignKeyName: "package_releases_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_releases_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_releases_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_releases_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_releases_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "package_releases_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_releases_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "package_releases_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_requests: { Row: { - auto_resolved: boolean - brief: string - created_at: string - evaluation: Json | null - generated_package_id: string | null - id: string - industry: string | null - kind: string - requester_id: string | null - research_sources: Json - research_summary: string | null - status: string - updated_at: string - } + auto_resolved: boolean; + brief: string; + created_at: string; + evaluation: Json | null; + generated_package_id: string | null; + id: string; + industry: string | null; + kind: string; + requester_id: string | null; + research_sources: Json; + research_summary: string | null; + status: string; + updated_at: string; + }; Insert: { - auto_resolved?: boolean - brief: string - created_at?: string - evaluation?: Json | null - generated_package_id?: string | null - id?: string - industry?: string | null - kind: string - requester_id?: string | null - research_sources?: Json - research_summary?: string | null - status?: string - updated_at?: string - } + auto_resolved?: boolean; + brief: string; + created_at?: string; + evaluation?: Json | null; + generated_package_id?: string | null; + id?: string; + industry?: string | null; + kind: string; + requester_id?: string | null; + research_sources?: Json; + research_summary?: string | null; + status?: string; + updated_at?: string; + }; Update: { - auto_resolved?: boolean - brief?: string - created_at?: string - evaluation?: Json | null - generated_package_id?: string | null - id?: string - industry?: string | null - kind?: string - requester_id?: string | null - research_sources?: Json - research_summary?: string | null - status?: string - updated_at?: string - } - Relationships: [] - } + auto_resolved?: boolean; + brief?: string; + created_at?: string; + evaluation?: Json | null; + generated_package_id?: string | null; + id?: string; + industry?: string | null; + kind?: string; + requester_id?: string | null; + research_sources?: Json; + research_summary?: string | null; + status?: string; + updated_at?: string; + }; + Relationships: []; + }; package_stars: { Row: { - created_at: string - package_id: string - user_id: string - } + created_at: string; + package_id: string; + user_id: string; + }; Insert: { - created_at?: string - package_id: string - user_id: string - } + created_at?: string; + package_id: string; + user_id: string; + }; Update: { - created_at?: string - package_id?: string - user_id?: string - } + created_at?: string; + package_id?: string; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "package_stars_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_stars_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_stars_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_stars_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_trust_scores: { Row: { - adversarial_pass_rate: number | null - adversarial_weighted_score: number | null - age_days: number | null - components: Json - computed_at: string - confidence: number | null - dim_competence: number | null - dim_coverage: number | null - dim_freshness: number | null - dim_safety: number | null - package_id: string - real_world_success_rate: number | null - schema_valid: boolean - score: number - signed_releases: number - trust_version: string - verified: boolean - } + adversarial_pass_rate: number | null; + adversarial_weighted_score: number | null; + age_days: number | null; + components: Json; + computed_at: string; + confidence: number | null; + dim_competence: number | null; + dim_coverage: number | null; + dim_freshness: number | null; + dim_safety: number | null; + package_id: string; + real_world_success_rate: number | null; + schema_valid: boolean; + score: number; + signed_releases: number; + trust_version: string; + verified: boolean; + }; Insert: { - adversarial_pass_rate?: number | null - adversarial_weighted_score?: number | null - age_days?: number | null - components?: Json - computed_at?: string - confidence?: number | null - dim_competence?: number | null - dim_coverage?: number | null - dim_freshness?: number | null - dim_safety?: number | null - package_id: string - real_world_success_rate?: number | null - schema_valid: boolean - score: number - signed_releases?: number - trust_version?: string - verified?: boolean - } + adversarial_pass_rate?: number | null; + adversarial_weighted_score?: number | null; + age_days?: number | null; + components?: Json; + computed_at?: string; + confidence?: number | null; + dim_competence?: number | null; + dim_coverage?: number | null; + dim_freshness?: number | null; + dim_safety?: number | null; + package_id: string; + real_world_success_rate?: number | null; + schema_valid: boolean; + score: number; + signed_releases?: number; + trust_version?: string; + verified?: boolean; + }; Update: { - adversarial_pass_rate?: number | null - adversarial_weighted_score?: number | null - age_days?: number | null - components?: Json - computed_at?: string - confidence?: number | null - dim_competence?: number | null - dim_coverage?: number | null - dim_freshness?: number | null - dim_safety?: number | null - package_id?: string - real_world_success_rate?: number | null - schema_valid?: boolean - score?: number - signed_releases?: number - trust_version?: string - verified?: boolean - } + adversarial_pass_rate?: number | null; + adversarial_weighted_score?: number | null; + age_days?: number | null; + components?: Json; + computed_at?: string; + confidence?: number | null; + dim_competence?: number | null; + dim_coverage?: number | null; + dim_freshness?: number | null; + dim_safety?: number | null; + package_id?: string; + real_world_success_rate?: number | null; + schema_valid?: boolean; + score?: number; + signed_releases?: number; + trust_version?: string; + verified?: boolean; + }; Relationships: [ { - foreignKeyName: "package_trust_scores_package_id_fkey" - columns: ["package_id"] - isOneToOne: true - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_trust_scores_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: true; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_trust_scores_package_id_fkey" - columns: ["package_id"] - isOneToOne: true - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_trust_scores_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: true; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_upload_jobs: { Row: { - attempts: number - content: string - created_at: string - error: string | null - filename: string - finished_at: string | null - id: string - inferred_type: string | null - package_id: string | null - result: Json | null - slug: string | null - started_at: string | null - status: string - user_id: string - } + attempts: number; + content: string; + created_at: string; + error: string | null; + filename: string; + finished_at: string | null; + id: string; + inferred_type: string | null; + package_id: string | null; + result: Json | null; + slug: string | null; + started_at: string | null; + status: string; + user_id: string; + }; Insert: { - attempts?: number - content: string - created_at?: string - error?: string | null - filename: string - finished_at?: string | null - id?: string - inferred_type?: string | null - package_id?: string | null - result?: Json | null - slug?: string | null - started_at?: string | null - status?: string - user_id: string - } + attempts?: number; + content: string; + created_at?: string; + error?: string | null; + filename: string; + finished_at?: string | null; + id?: string; + inferred_type?: string | null; + package_id?: string | null; + result?: Json | null; + slug?: string | null; + started_at?: string | null; + status?: string; + user_id: string; + }; Update: { - attempts?: number - content?: string - created_at?: string - error?: string | null - filename?: string - finished_at?: string | null - id?: string - inferred_type?: string | null - package_id?: string | null - result?: Json | null - slug?: string | null - started_at?: string | null - status?: string - user_id?: string - } - Relationships: [] - } + attempts?: number; + content?: string; + created_at?: string; + error?: string | null; + filename?: string; + finished_at?: string | null; + id?: string; + inferred_type?: string | null; + package_id?: string | null; + result?: Json | null; + slug?: string | null; + started_at?: string | null; + status?: string; + user_id?: string; + }; + Relationships: []; + }; package_versions: { Row: { - compatibility: Json - created_at: string - examples: Json - id: string - live_resources: Json - mcp_servers: Json - notes: string | null - package_id: string - parent_version_id: string | null - permissions: Json - rules: Json - status: Database["public"]["Enums"]["version_status"] - system_prompt: string - version: string - } + compatibility: Json; + created_at: string; + examples: Json; + id: string; + live_resources: Json; + mcp_servers: Json; + notes: string | null; + package_id: string; + parent_version_id: string | null; + permissions: Json; + rules: Json; + status: Database["public"]["Enums"]["version_status"]; + system_prompt: string; + version: string; + }; Insert: { - compatibility?: Json - created_at?: string - examples?: Json - id?: string - live_resources?: Json - mcp_servers?: Json - notes?: string | null - package_id: string - parent_version_id?: string | null - permissions?: Json - rules?: Json - status?: Database["public"]["Enums"]["version_status"] - system_prompt: string - version: string - } + compatibility?: Json; + created_at?: string; + examples?: Json; + id?: string; + live_resources?: Json; + mcp_servers?: Json; + notes?: string | null; + package_id: string; + parent_version_id?: string | null; + permissions?: Json; + rules?: Json; + status?: Database["public"]["Enums"]["version_status"]; + system_prompt: string; + version: string; + }; Update: { - compatibility?: Json - created_at?: string - examples?: Json - id?: string - live_resources?: Json - mcp_servers?: Json - notes?: string | null - package_id?: string - parent_version_id?: string | null - permissions?: Json - rules?: Json - status?: Database["public"]["Enums"]["version_status"] - system_prompt?: string - version?: string - } + compatibility?: Json; + created_at?: string; + examples?: Json; + id?: string; + live_resources?: Json; + mcp_servers?: Json; + notes?: string | null; + package_id?: string; + parent_version_id?: string | null; + permissions?: Json; + rules?: Json; + status?: Database["public"]["Enums"]["version_status"]; + system_prompt?: string; + version?: string; + }; Relationships: [ { - foreignKeyName: "package_versions_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_versions_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_versions_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_versions_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_versions_parent_version_id_fkey" - columns: ["parent_version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "package_versions_parent_version_id_fkey"; + columns: ["parent_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_versions_parent_version_id_fkey" - columns: ["parent_version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "package_versions_parent_version_id_fkey"; + columns: ["parent_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; package_weekly_metrics: { Row: { - adversarial_pass_rate: number | null - adversarial_weighted: number | null - avg_tokens: number | null - created_at: string - id: number - p95_latency_ms: number | null - package_id: string - package_slug: string - runs: number - success_rate: number | null - success_rate_wilson_lb: number | null - successes: number - task_completed_rate: number | null - track: string - trust_score: number | null - week_start: string - } + adversarial_pass_rate: number | null; + adversarial_weighted: number | null; + avg_tokens: number | null; + created_at: string; + id: number; + p95_latency_ms: number | null; + package_id: string; + package_slug: string; + runs: number; + success_rate: number | null; + success_rate_wilson_lb: number | null; + successes: number; + task_completed_rate: number | null; + track: string; + trust_score: number | null; + week_start: string; + }; Insert: { - adversarial_pass_rate?: number | null - adversarial_weighted?: number | null - avg_tokens?: number | null - created_at?: string - id?: number - p95_latency_ms?: number | null - package_id: string - package_slug: string - runs?: number - success_rate?: number | null - success_rate_wilson_lb?: number | null - successes?: number - task_completed_rate?: number | null - track?: string - trust_score?: number | null - week_start: string - } + adversarial_pass_rate?: number | null; + adversarial_weighted?: number | null; + avg_tokens?: number | null; + created_at?: string; + id?: number; + p95_latency_ms?: number | null; + package_id: string; + package_slug: string; + runs?: number; + success_rate?: number | null; + success_rate_wilson_lb?: number | null; + successes?: number; + task_completed_rate?: number | null; + track?: string; + trust_score?: number | null; + week_start: string; + }; Update: { - adversarial_pass_rate?: number | null - adversarial_weighted?: number | null - avg_tokens?: number | null - created_at?: string - id?: number - p95_latency_ms?: number | null - package_id?: string - package_slug?: string - runs?: number - success_rate?: number | null - success_rate_wilson_lb?: number | null - successes?: number - task_completed_rate?: number | null - track?: string - trust_score?: number | null - week_start?: string - } + adversarial_pass_rate?: number | null; + adversarial_weighted?: number | null; + avg_tokens?: number | null; + created_at?: string; + id?: number; + p95_latency_ms?: number | null; + package_id?: string; + package_slug?: string; + runs?: number; + success_rate?: number | null; + success_rate_wilson_lb?: number | null; + successes?: number; + task_completed_rate?: number | null; + track?: string; + trust_score?: number | null; + week_start?: string; + }; Relationships: [ { - foreignKeyName: "package_weekly_metrics_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_weekly_metrics_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_weekly_metrics_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_weekly_metrics_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; packages: { Row: { - author_handle: string - author_id: string | null - author_verified: boolean - created_at: string - description: string - id: string - install_count: number - is_published: boolean - latest_version: string - license: string - long_description: string | null - name: string - price_credits: number - review_notes: string | null - review_status: string - reviewed_at: string | null - reviewed_by: string | null - scopes: string[] - search_vector: unknown - slug: string - source_kind: string - source_ref: string | null - star_count: number - submitted_at: string | null - tags: string[] - type: Database["public"]["Enums"]["package_type"] - updated_at: string - vertical: string | null - } + author_handle: string; + author_id: string | null; + author_verified: boolean; + created_at: string; + description: string; + id: string; + install_count: number; + is_published: boolean; + latest_version: string; + license: string; + long_description: string | null; + name: string; + price_credits: number; + review_notes: string | null; + review_status: string; + reviewed_at: string | null; + reviewed_by: string | null; + scopes: string[]; + search_vector: unknown; + slug: string; + source_kind: string; + source_ref: string | null; + star_count: number; + submitted_at: string | null; + tags: string[]; + type: Database["public"]["Enums"]["package_type"]; + updated_at: string; + vertical: string | null; + }; Insert: { - author_handle?: string - author_id?: string | null - author_verified?: boolean - created_at?: string - description: string - id?: string - install_count?: number - is_published?: boolean - latest_version?: string - license?: string - long_description?: string | null - name: string - price_credits?: number - review_notes?: string | null - review_status?: string - reviewed_at?: string | null - reviewed_by?: string | null - scopes?: string[] - search_vector?: unknown - slug: string - source_kind?: string - source_ref?: string | null - star_count?: number - submitted_at?: string | null - tags?: string[] - type: Database["public"]["Enums"]["package_type"] - updated_at?: string - vertical?: string | null - } + author_handle?: string; + author_id?: string | null; + author_verified?: boolean; + created_at?: string; + description: string; + id?: string; + install_count?: number; + is_published?: boolean; + latest_version?: string; + license?: string; + long_description?: string | null; + name: string; + price_credits?: number; + review_notes?: string | null; + review_status?: string; + reviewed_at?: string | null; + reviewed_by?: string | null; + scopes?: string[]; + search_vector?: unknown; + slug: string; + source_kind?: string; + source_ref?: string | null; + star_count?: number; + submitted_at?: string | null; + tags?: string[]; + type: Database["public"]["Enums"]["package_type"]; + updated_at?: string; + vertical?: string | null; + }; Update: { - author_handle?: string - author_id?: string | null - author_verified?: boolean - created_at?: string - description?: string - id?: string - install_count?: number - is_published?: boolean - latest_version?: string - license?: string - long_description?: string | null - name?: string - price_credits?: number - review_notes?: string | null - review_status?: string - reviewed_at?: string | null - reviewed_by?: string | null - scopes?: string[] - search_vector?: unknown - slug?: string - source_kind?: string - source_ref?: string | null - star_count?: number - submitted_at?: string | null - tags?: string[] - type?: Database["public"]["Enums"]["package_type"] - updated_at?: string - vertical?: string | null - } - Relationships: [] - } + author_handle?: string; + author_id?: string | null; + author_verified?: boolean; + created_at?: string; + description?: string; + id?: string; + install_count?: number; + is_published?: boolean; + latest_version?: string; + license?: string; + long_description?: string | null; + name?: string; + price_credits?: number; + review_notes?: string | null; + review_status?: string; + reviewed_at?: string | null; + reviewed_by?: string | null; + scopes?: string[]; + search_vector?: unknown; + slug?: string; + source_kind?: string; + source_ref?: string | null; + star_count?: number; + submitted_at?: string | null; + tags?: string[]; + type?: Database["public"]["Enums"]["package_type"]; + updated_at?: string; + vertical?: string | null; + }; + Relationships: []; + }; packs: { Row: { - author_handle: string - author_id: string | null - cover_emoji: string | null - created_at: string - description: string - id: string - install_count: number - is_published: boolean - latest_version: string - long_description: string | null - name: string - price_credits: number - review_status: string - slug: string - theme: string - updated_at: string - } + author_handle: string; + author_id: string | null; + cover_emoji: string | null; + created_at: string; + description: string; + id: string; + install_count: number; + is_published: boolean; + latest_version: string; + long_description: string | null; + name: string; + price_credits: number; + review_status: string; + slug: string; + theme: string; + updated_at: string; + }; Insert: { - author_handle?: string - author_id?: string | null - cover_emoji?: string | null - created_at?: string - description: string - id?: string - install_count?: number - is_published?: boolean - latest_version?: string - long_description?: string | null - name: string - price_credits?: number - review_status?: string - slug: string - theme?: string - updated_at?: string - } + author_handle?: string; + author_id?: string | null; + cover_emoji?: string | null; + created_at?: string; + description: string; + id?: string; + install_count?: number; + is_published?: boolean; + latest_version?: string; + long_description?: string | null; + name: string; + price_credits?: number; + review_status?: string; + slug: string; + theme?: string; + updated_at?: string; + }; Update: { - author_handle?: string - author_id?: string | null - cover_emoji?: string | null - created_at?: string - description?: string - id?: string - install_count?: number - is_published?: boolean - latest_version?: string - long_description?: string | null - name?: string - price_credits?: number - review_status?: string - slug?: string - theme?: string - updated_at?: string - } - Relationships: [] - } + author_handle?: string; + author_id?: string | null; + cover_emoji?: string | null; + created_at?: string; + description?: string; + id?: string; + install_count?: number; + is_published?: boolean; + latest_version?: string; + long_description?: string | null; + name?: string; + price_credits?: number; + review_status?: string; + slug?: string; + theme?: string; + updated_at?: string; + }; + Relationships: []; + }; payment_events: { Row: { - created_at: string - env: string - event_id: string - event_type: string - id: string - payload: Json - user_id: string | null - } + created_at: string; + env: string; + event_id: string; + event_type: string; + id: string; + payload: Json; + user_id: string | null; + }; Insert: { - created_at?: string - env: string - event_id: string - event_type: string - id?: string - payload: Json - user_id?: string | null - } + created_at?: string; + env: string; + event_id: string; + event_type: string; + id?: string; + payload: Json; + user_id?: string | null; + }; Update: { - created_at?: string - env?: string - event_id?: string - event_type?: string - id?: string - payload?: Json - user_id?: string | null - } - Relationships: [] - } + created_at?: string; + env?: string; + event_id?: string; + event_type?: string; + id?: string; + payload?: Json; + user_id?: string | null; + }; + Relationships: []; + }; plans: { Row: { - created_at: string - features: Json - id: string - max_installed_packages: number - monthly_credits: number - monthly_runs_limit: number - name: string - paddle_price_external_id: string | null - paddle_product_external_id: string | null - price_cents: number - slug: string - sort_order: number - updated_at: string - } + created_at: string; + features: Json; + id: string; + max_installed_packages: number; + monthly_credits: number; + monthly_runs_limit: number; + name: string; + paddle_price_external_id: string | null; + paddle_product_external_id: string | null; + price_cents: number; + slug: string; + sort_order: number; + updated_at: string; + }; Insert: { - created_at?: string - features?: Json - id?: string - max_installed_packages?: number - monthly_credits?: number - monthly_runs_limit?: number - name: string - paddle_price_external_id?: string | null - paddle_product_external_id?: string | null - price_cents?: number - slug: string - sort_order?: number - updated_at?: string - } + created_at?: string; + features?: Json; + id?: string; + max_installed_packages?: number; + monthly_credits?: number; + monthly_runs_limit?: number; + name: string; + paddle_price_external_id?: string | null; + paddle_product_external_id?: string | null; + price_cents?: number; + slug: string; + sort_order?: number; + updated_at?: string; + }; Update: { - created_at?: string - features?: Json - id?: string - max_installed_packages?: number - monthly_credits?: number - monthly_runs_limit?: number - name?: string - paddle_price_external_id?: string | null - paddle_product_external_id?: string | null - price_cents?: number - slug?: string - sort_order?: number - updated_at?: string - } - Relationships: [] - } + created_at?: string; + features?: Json; + id?: string; + max_installed_packages?: number; + monthly_credits?: number; + monthly_runs_limit?: number; + name?: string; + paddle_price_external_id?: string | null; + paddle_product_external_id?: string | null; + price_cents?: number; + slug?: string; + sort_order?: number; + updated_at?: string; + }; + Relationships: []; + }; plugin_conformance_runs: { Row: { - conformant: boolean - created_at: string - created_by: string - filename: string - id: string - package_id: string | null - plugin_name: string | null - published: boolean - report: Json - } + conformant: boolean; + created_at: string; + created_by: string; + filename: string; + id: string; + package_id: string | null; + plugin_name: string | null; + published: boolean; + report: Json; + }; Insert: { - conformant?: boolean - created_at?: string - created_by: string - filename: string - id?: string - package_id?: string | null - plugin_name?: string | null - published?: boolean - report?: Json - } + conformant?: boolean; + created_at?: string; + created_by: string; + filename: string; + id?: string; + package_id?: string | null; + plugin_name?: string | null; + published?: boolean; + report?: Json; + }; Update: { - conformant?: boolean - created_at?: string - created_by?: string - filename?: string - id?: string - package_id?: string | null - plugin_name?: string | null - published?: boolean - report?: Json - } + conformant?: boolean; + created_at?: string; + created_by?: string; + filename?: string; + id?: string; + package_id?: string | null; + plugin_name?: string | null; + published?: boolean; + report?: Json; + }; Relationships: [ { - foreignKeyName: "plugin_conformance_runs_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "plugin_conformance_runs_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "plugin_conformance_runs_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "plugin_conformance_runs_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; presets: { Row: { - created_at: string - id: string - last_run_at: string | null - last_run_id: string | null - name: string - package_slugs: string[] - prompt: string - tags: string[] - user_id: string - } + created_at: string; + id: string; + last_run_at: string | null; + last_run_id: string | null; + name: string; + package_slugs: string[]; + prompt: string; + tags: string[]; + user_id: string; + }; Insert: { - created_at?: string - id?: string - last_run_at?: string | null - last_run_id?: string | null - name: string - package_slugs?: string[] - prompt: string - tags?: string[] - user_id: string - } + created_at?: string; + id?: string; + last_run_at?: string | null; + last_run_id?: string | null; + name: string; + package_slugs?: string[]; + prompt: string; + tags?: string[]; + user_id: string; + }; Update: { - created_at?: string - id?: string - last_run_at?: string | null - last_run_id?: string | null - name?: string - package_slugs?: string[] - prompt?: string - tags?: string[] - user_id?: string - } + created_at?: string; + id?: string; + last_run_at?: string | null; + last_run_id?: string | null; + name?: string; + package_slugs?: string[]; + prompt?: string; + tags?: string[]; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "presets_last_run_id_fkey" - columns: ["last_run_id"] - isOneToOne: false - referencedRelation: "runs" - referencedColumns: ["id"] + foreignKeyName: "presets_last_run_id_fkey"; + columns: ["last_run_id"]; + isOneToOne: false; + referencedRelation: "runs"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; profiles: { Row: { - avatar_url: string | null - bio: string | null - created_at: string - display_name: string | null - handle: string | null - id: string - updated_at: string - } + avatar_url: string | null; + bio: string | null; + created_at: string; + display_name: string | null; + handle: string | null; + id: string; + updated_at: string; + }; Insert: { - avatar_url?: string | null - bio?: string | null - created_at?: string - display_name?: string | null - handle?: string | null - id: string - updated_at?: string - } + avatar_url?: string | null; + bio?: string | null; + created_at?: string; + display_name?: string | null; + handle?: string | null; + id: string; + updated_at?: string; + }; Update: { - avatar_url?: string | null - bio?: string | null - created_at?: string - display_name?: string | null - handle?: string | null - id?: string - updated_at?: string - } - Relationships: [] - } + avatar_url?: string | null; + bio?: string | null; + created_at?: string; + display_name?: string | null; + handle?: string | null; + id?: string; + updated_at?: string; + }; + Relationships: []; + }; referral_clicks: { Row: { - code: string - created_at: string - id: number - ip_hash: string | null - target: string | null - ua_hash: string | null - } + code: string; + created_at: string; + id: number; + ip_hash: string | null; + target: string | null; + ua_hash: string | null; + }; Insert: { - code: string - created_at?: string - id?: number - ip_hash?: string | null - target?: string | null - ua_hash?: string | null - } + code: string; + created_at?: string; + id?: number; + ip_hash?: string | null; + target?: string | null; + ua_hash?: string | null; + }; Update: { - code?: string - created_at?: string - id?: number - ip_hash?: string | null - target?: string | null - ua_hash?: string | null - } - Relationships: [] - } + code?: string; + created_at?: string; + id?: number; + ip_hash?: string | null; + target?: string | null; + ua_hash?: string | null; + }; + Relationships: []; + }; referral_rewards: { Row: { - created_at: string - credits: number - id: string - kind: string - referral_id: string - referrer_id: string - } + created_at: string; + credits: number; + id: string; + kind: string; + referral_id: string; + referrer_id: string; + }; Insert: { - created_at?: string - credits: number - id?: string - kind: string - referral_id: string - referrer_id: string - } + created_at?: string; + credits: number; + id?: string; + kind: string; + referral_id: string; + referrer_id: string; + }; Update: { - created_at?: string - credits?: number - id?: string - kind?: string - referral_id?: string - referrer_id?: string - } + created_at?: string; + credits?: number; + id?: string; + kind?: string; + referral_id?: string; + referrer_id?: string; + }; Relationships: [ { - foreignKeyName: "referral_rewards_referral_id_fkey" - columns: ["referral_id"] - isOneToOne: false - referencedRelation: "referrals" - referencedColumns: ["id"] + foreignKeyName: "referral_rewards_referral_id_fkey"; + columns: ["referral_id"]; + isOneToOne: false; + referencedRelation: "referrals"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; referrals: { Row: { - code: string - created_at: string - first_purchase_at: string | null - id: string - package_slug: string | null - referred_user_id: string - referrer_id: string - signed_up_at: string - source_url: string | null - status: string - subscribed_at: string | null - } + code: string; + created_at: string; + first_purchase_at: string | null; + id: string; + package_slug: string | null; + referred_user_id: string; + referrer_id: string; + signed_up_at: string; + source_url: string | null; + status: string; + subscribed_at: string | null; + }; Insert: { - code: string - created_at?: string - first_purchase_at?: string | null - id?: string - package_slug?: string | null - referred_user_id: string - referrer_id: string - signed_up_at?: string - source_url?: string | null - status?: string - subscribed_at?: string | null - } + code: string; + created_at?: string; + first_purchase_at?: string | null; + id?: string; + package_slug?: string | null; + referred_user_id: string; + referrer_id: string; + signed_up_at?: string; + source_url?: string | null; + status?: string; + subscribed_at?: string | null; + }; Update: { - code?: string - created_at?: string - first_purchase_at?: string | null - id?: string - package_slug?: string | null - referred_user_id?: string - referrer_id?: string - signed_up_at?: string - source_url?: string | null - status?: string - subscribed_at?: string | null - } - Relationships: [] - } + code?: string; + created_at?: string; + first_purchase_at?: string | null; + id?: string; + package_slug?: string | null; + referred_user_id?: string; + referrer_id?: string; + signed_up_at?: string; + source_url?: string | null; + status?: string; + subscribed_at?: string | null; + }; + Relationships: []; + }; report_leads: { Row: { - company: string - created_at: string - email: string - email_domain: string - governance: string | null - health_score: number | null - id: string - prompt: string | null - role: string - stack_size: number - } + company: string; + created_at: string; + email: string; + email_domain: string; + governance: string | null; + health_score: number | null; + id: string; + prompt: string | null; + role: string; + stack_size: number; + }; Insert: { - company: string - created_at?: string - email: string - email_domain: string - governance?: string | null - health_score?: number | null - id?: string - prompt?: string | null - role: string - stack_size?: number - } + company: string; + created_at?: string; + email: string; + email_domain: string; + governance?: string | null; + health_score?: number | null; + id?: string; + prompt?: string | null; + role: string; + stack_size?: number; + }; Update: { - company?: string - created_at?: string - email?: string - email_domain?: string - governance?: string | null - health_score?: number | null - id?: string - prompt?: string | null - role?: string - stack_size?: number - } - Relationships: [] - } + company?: string; + created_at?: string; + email?: string; + email_domain?: string; + governance?: string | null; + health_score?: number | null; + id?: string; + prompt?: string | null; + role?: string; + stack_size?: number; + }; + Relationships: []; + }; review_audit: { Row: { - created_at: string - id: string - kind: string - metadata: Json - outcome: string - package_id: string | null - reason: string | null - review_id: string | null - user_id: string - } + created_at: string; + id: string; + kind: string; + metadata: Json; + outcome: string; + package_id: string | null; + reason: string | null; + review_id: string | null; + user_id: string; + }; Insert: { - created_at?: string - id?: string - kind: string - metadata?: Json - outcome: string - package_id?: string | null - reason?: string | null - review_id?: string | null - user_id: string - } + created_at?: string; + id?: string; + kind: string; + metadata?: Json; + outcome: string; + package_id?: string | null; + reason?: string | null; + review_id?: string | null; + user_id: string; + }; Update: { - created_at?: string - id?: string - kind?: string - metadata?: Json - outcome?: string - package_id?: string | null - reason?: string | null - review_id?: string | null - user_id?: string - } - Relationships: [] - } + created_at?: string; + id?: string; + kind?: string; + metadata?: Json; + outcome?: string; + package_id?: string | null; + reason?: string | null; + review_id?: string | null; + user_id?: string; + }; + Relationships: []; + }; review_reports: { Row: { - created_at: string - details: string | null - id: string - package_id: string - reason: string - reporter_id: string - resolution: string | null - resolved_at: string | null - resolved_by: string | null - review_id: string - status: string - } + created_at: string; + details: string | null; + id: string; + package_id: string; + reason: string; + reporter_id: string; + resolution: string | null; + resolved_at: string | null; + resolved_by: string | null; + review_id: string; + status: string; + }; Insert: { - created_at?: string - details?: string | null - id?: string - package_id: string - reason: string - reporter_id: string - resolution?: string | null - resolved_at?: string | null - resolved_by?: string | null - review_id: string - status?: string - } + created_at?: string; + details?: string | null; + id?: string; + package_id: string; + reason: string; + reporter_id: string; + resolution?: string | null; + resolved_at?: string | null; + resolved_by?: string | null; + review_id: string; + status?: string; + }; Update: { - created_at?: string - details?: string | null - id?: string - package_id?: string - reason?: string - reporter_id?: string - resolution?: string | null - resolved_at?: string | null - resolved_by?: string | null - review_id?: string - status?: string - } - Relationships: [] - } + created_at?: string; + details?: string | null; + id?: string; + package_id?: string; + reason?: string; + reporter_id?: string; + resolution?: string | null; + resolved_at?: string | null; + resolved_by?: string | null; + review_id?: string; + status?: string; + }; + Relationships: []; + }; reviews: { Row: { - body: string | null - created_at: string - helpful_count: number - hidden_at: string | null - hidden_by: string | null - hidden_reason: string | null - id: string - is_hidden: boolean - package_id: string - rater_kind: string - rating: number - run_id_ref: string | null - user_id: string - verified_purchase: boolean - } + body: string | null; + created_at: string; + helpful_count: number; + hidden_at: string | null; + hidden_by: string | null; + hidden_reason: string | null; + id: string; + is_hidden: boolean; + package_id: string; + rater_kind: string; + rating: number; + run_id_ref: string | null; + user_id: string; + verified_purchase: boolean; + }; Insert: { - body?: string | null - created_at?: string - helpful_count?: number - hidden_at?: string | null - hidden_by?: string | null - hidden_reason?: string | null - id?: string - is_hidden?: boolean - package_id: string - rater_kind?: string - rating: number - run_id_ref?: string | null - user_id: string - verified_purchase?: boolean - } + body?: string | null; + created_at?: string; + helpful_count?: number; + hidden_at?: string | null; + hidden_by?: string | null; + hidden_reason?: string | null; + id?: string; + is_hidden?: boolean; + package_id: string; + rater_kind?: string; + rating: number; + run_id_ref?: string | null; + user_id: string; + verified_purchase?: boolean; + }; Update: { - body?: string | null - created_at?: string - helpful_count?: number - hidden_at?: string | null - hidden_by?: string | null - hidden_reason?: string | null - id?: string - is_hidden?: boolean - package_id?: string - rater_kind?: string - rating?: number - run_id_ref?: string | null - user_id?: string - verified_purchase?: boolean - } + body?: string | null; + created_at?: string; + helpful_count?: number; + hidden_at?: string | null; + hidden_by?: string | null; + hidden_reason?: string | null; + id?: string; + is_hidden?: boolean; + package_id?: string; + rater_kind?: string; + rating?: number; + run_id_ref?: string | null; + user_id?: string; + verified_purchase?: boolean; + }; Relationships: [ { - foreignKeyName: "reviews_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "reviews_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "reviews_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "reviews_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "reviews_run_id_ref_fkey" - columns: ["run_id_ref"] - isOneToOne: false - referencedRelation: "runs" - referencedColumns: ["id"] + foreignKeyName: "reviews_run_id_ref_fkey"; + columns: ["run_id_ref"]; + isOneToOne: false; + referencedRelation: "runs"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; run_events: { Row: { - id: number - kind: string - payload: Json - run_id: string - ts: string - } + id: number; + kind: string; + payload: Json; + run_id: string; + ts: string; + }; Insert: { - id?: number - kind: string - payload?: Json - run_id: string - ts?: string - } + id?: number; + kind: string; + payload?: Json; + run_id: string; + ts?: string; + }; Update: { - id?: number - kind?: string - payload?: Json - run_id?: string - ts?: string - } + id?: number; + kind?: string; + payload?: Json; + run_id?: string; + ts?: string; + }; Relationships: [ { - foreignKeyName: "run_events_run_id_fkey" - columns: ["run_id"] - isOneToOne: false - referencedRelation: "runs" - referencedColumns: ["id"] + foreignKeyName: "run_events_run_id_fkey"; + columns: ["run_id"]; + isOneToOne: false; + referencedRelation: "runs"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; runs: { Row: { - ended_at: string | null - error: string | null - guardrail_blocks: Json | null - hallucination_rate: number | null - health: number | null - id: string - latency_ms: number | null - output: string | null - package_slugs: string[] - package_versions: Json - precision_score: number | null - prompt: string - started_at: string - status: Database["public"]["Enums"]["run_status"] - tokens_in: number | null - tokens_out: number | null - user_id: string - } + ended_at: string | null; + error: string | null; + guardrail_blocks: Json | null; + hallucination_rate: number | null; + health: number | null; + id: string; + latency_ms: number | null; + output: string | null; + package_slugs: string[]; + package_versions: Json; + precision_score: number | null; + prompt: string; + started_at: string; + status: Database["public"]["Enums"]["run_status"]; + tokens_in: number | null; + tokens_out: number | null; + user_id: string; + }; Insert: { - ended_at?: string | null - error?: string | null - guardrail_blocks?: Json | null - hallucination_rate?: number | null - health?: number | null - id?: string - latency_ms?: number | null - output?: string | null - package_slugs?: string[] - package_versions?: Json - precision_score?: number | null - prompt: string - started_at?: string - status?: Database["public"]["Enums"]["run_status"] - tokens_in?: number | null - tokens_out?: number | null - user_id: string - } + ended_at?: string | null; + error?: string | null; + guardrail_blocks?: Json | null; + hallucination_rate?: number | null; + health?: number | null; + id?: string; + latency_ms?: number | null; + output?: string | null; + package_slugs?: string[]; + package_versions?: Json; + precision_score?: number | null; + prompt: string; + started_at?: string; + status?: Database["public"]["Enums"]["run_status"]; + tokens_in?: number | null; + tokens_out?: number | null; + user_id: string; + }; Update: { - ended_at?: string | null - error?: string | null - guardrail_blocks?: Json | null - hallucination_rate?: number | null - health?: number | null - id?: string - latency_ms?: number | null - output?: string | null - package_slugs?: string[] - package_versions?: Json - precision_score?: number | null - prompt?: string - started_at?: string - status?: Database["public"]["Enums"]["run_status"] - tokens_in?: number | null - tokens_out?: number | null - user_id?: string - } - Relationships: [] - } + ended_at?: string | null; + error?: string | null; + guardrail_blocks?: Json | null; + hallucination_rate?: number | null; + health?: number | null; + id?: string; + latency_ms?: number | null; + output?: string | null; + package_slugs?: string[]; + package_versions?: Json; + precision_score?: number | null; + prompt?: string; + started_at?: string; + status?: Database["public"]["Enums"]["run_status"]; + tokens_in?: number | null; + tokens_out?: number | null; + user_id?: string; + }; + Relationships: []; + }; semantic_index_attempts: { Row: { - created_at: string - id: string - model: string - receipt: Json | null - status: string - } + created_at: string; + id: string; + model: string; + receipt: Json | null; + status: string; + }; Insert: { - created_at?: string - id?: string - model: string - receipt?: Json | null - status: string - } + created_at?: string; + id?: string; + model: string; + receipt?: Json | null; + status: string; + }; Update: { - created_at?: string - id?: string - model?: string - receipt?: Json | null - status?: string - } - Relationships: [] - } + created_at?: string; + id?: string; + model?: string; + receipt?: Json | null; + status?: string; + }; + Relationships: []; + }; semantic_query_budget: { Row: { - actor: string - day: string - queries: number - } + actor: string; + day: string; + queries: number; + }; Insert: { - actor: string - day?: string - queries: number - } + actor: string; + day?: string; + queries: number; + }; Update: { - actor?: string - day?: string - queries?: number - } - Relationships: [] - } + actor?: string; + day?: string; + queries?: number; + }; + Relationships: []; + }; share_promos: { Row: { - body: string - description: string | null - generated_at: string - name: string | null - slug: string - source: string - type: string - } + body: string; + description: string | null; + generated_at: string; + name: string | null; + slug: string; + source: string; + type: string; + }; Insert: { - body: string - description?: string | null - generated_at?: string - name?: string | null - slug: string - source?: string - type: string - } + body: string; + description?: string | null; + generated_at?: string; + name?: string | null; + slug: string; + source?: string; + type: string; + }; Update: { - body?: string - description?: string | null - generated_at?: string - name?: string | null - slug?: string - source?: string - type?: string - } - Relationships: [] - } + body?: string; + description?: string | null; + generated_at?: string; + name?: string | null; + slug?: string; + source?: string; + type?: string; + }; + Relationships: []; + }; skill_collection_followers: { Row: { - collection_id: string - followed_at: string - user_id: string - } + collection_id: string; + followed_at: string; + user_id: string; + }; Insert: { - collection_id: string - followed_at?: string - user_id: string - } + collection_id: string; + followed_at?: string; + user_id: string; + }; Update: { - collection_id?: string - followed_at?: string - user_id?: string - } + collection_id?: string; + followed_at?: string; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "skill_collection_followers_collection_id_fkey" - columns: ["collection_id"] - isOneToOne: false - referencedRelation: "skill_collections" - referencedColumns: ["id"] + foreignKeyName: "skill_collection_followers_collection_id_fkey"; + columns: ["collection_id"]; + isOneToOne: false; + referencedRelation: "skill_collections"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; skill_collection_items: { Row: { - added_at: string - collection_id: string - note: string | null - package_id: string - position: number - } + added_at: string; + collection_id: string; + note: string | null; + package_id: string; + position: number; + }; Insert: { - added_at?: string - collection_id: string - note?: string | null - package_id: string - position?: number - } + added_at?: string; + collection_id: string; + note?: string | null; + package_id: string; + position?: number; + }; Update: { - added_at?: string - collection_id?: string - note?: string | null - package_id?: string - position?: number - } + added_at?: string; + collection_id?: string; + note?: string | null; + package_id?: string; + position?: number; + }; Relationships: [ { - foreignKeyName: "skill_collection_items_collection_id_fkey" - columns: ["collection_id"] - isOneToOne: false - referencedRelation: "skill_collections" - referencedColumns: ["id"] + foreignKeyName: "skill_collection_items_collection_id_fkey"; + columns: ["collection_id"]; + isOneToOne: false; + referencedRelation: "skill_collections"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_collection_items_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "skill_collection_items_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_collection_items_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "skill_collection_items_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; skill_collections: { Row: { - cover_emoji: string | null - created_at: string - curator_share_bps: number - curator_user_id: string - description: string | null - id: string - is_public: boolean - slug: string - title: string - updated_at: string - } + cover_emoji: string | null; + created_at: string; + curator_share_bps: number; + curator_user_id: string; + description: string | null; + id: string; + is_public: boolean; + slug: string; + title: string; + updated_at: string; + }; Insert: { - cover_emoji?: string | null - created_at?: string - curator_share_bps?: number - curator_user_id: string - description?: string | null - id?: string - is_public?: boolean - slug: string - title: string - updated_at?: string - } + cover_emoji?: string | null; + created_at?: string; + curator_share_bps?: number; + curator_user_id: string; + description?: string | null; + id?: string; + is_public?: boolean; + slug: string; + title: string; + updated_at?: string; + }; Update: { - cover_emoji?: string | null - created_at?: string - curator_share_bps?: number - curator_user_id?: string - description?: string | null - id?: string - is_public?: boolean - slug?: string - title?: string - updated_at?: string - } - Relationships: [] - } + cover_emoji?: string | null; + created_at?: string; + curator_share_bps?: number; + curator_user_id?: string; + description?: string | null; + id?: string; + is_public?: boolean; + slug?: string; + title?: string; + updated_at?: string; + }; + Relationships: []; + }; skill_compatibility: { Row: { - evaluated_at: string - id: string - judge_score: number | null - model: string - notes: string | null - package_id: string - package_slug: string - pass_rate: number - passed_cases: number - sample: Json - status: string - total_cases: number - version: string | null - } + evaluated_at: string; + id: string; + judge_score: number | null; + model: string; + notes: string | null; + package_id: string; + package_slug: string; + pass_rate: number; + passed_cases: number; + sample: Json; + status: string; + total_cases: number; + version: string | null; + }; Insert: { - evaluated_at?: string - id?: string - judge_score?: number | null - model: string - notes?: string | null - package_id: string - package_slug: string - pass_rate: number - passed_cases?: number - sample?: Json - status: string - total_cases?: number - version?: string | null - } + evaluated_at?: string; + id?: string; + judge_score?: number | null; + model: string; + notes?: string | null; + package_id: string; + package_slug: string; + pass_rate: number; + passed_cases?: number; + sample?: Json; + status: string; + total_cases?: number; + version?: string | null; + }; Update: { - evaluated_at?: string - id?: string - judge_score?: number | null - model?: string - notes?: string | null - package_id?: string - package_slug?: string - pass_rate?: number - passed_cases?: number - sample?: Json - status?: string - total_cases?: number - version?: string | null - } + evaluated_at?: string; + id?: string; + judge_score?: number | null; + model?: string; + notes?: string | null; + package_id?: string; + package_slug?: string; + pass_rate?: number; + passed_cases?: number; + sample?: Json; + status?: string; + total_cases?: number; + version?: string | null; + }; Relationships: [ { - foreignKeyName: "skill_compatibility_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "skill_compatibility_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_compatibility_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "skill_compatibility_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; skill_drift_alerts: { Row: { - baseline_rate: number - baseline_runs: number - delta: number - detected_at: string - id: string - package_id: string - package_slug: string - rationale: string | null - recent_rate: number - recent_runs: number - severity: string - status: string - suggested_patch: string | null - triggered_by_model: string | null - updated_at: string - window_days: number - } + baseline_rate: number; + baseline_runs: number; + delta: number; + detected_at: string; + id: string; + package_id: string; + package_slug: string; + rationale: string | null; + recent_rate: number; + recent_runs: number; + severity: string; + status: string; + suggested_patch: string | null; + triggered_by_model: string | null; + updated_at: string; + window_days: number; + }; Insert: { - baseline_rate: number - baseline_runs: number - delta: number - detected_at?: string - id?: string - package_id: string - package_slug: string - rationale?: string | null - recent_rate: number - recent_runs: number - severity: string - status?: string - suggested_patch?: string | null - triggered_by_model?: string | null - updated_at?: string - window_days?: number - } + baseline_rate: number; + baseline_runs: number; + delta: number; + detected_at?: string; + id?: string; + package_id: string; + package_slug: string; + rationale?: string | null; + recent_rate: number; + recent_runs: number; + severity: string; + status?: string; + suggested_patch?: string | null; + triggered_by_model?: string | null; + updated_at?: string; + window_days?: number; + }; Update: { - baseline_rate?: number - baseline_runs?: number - delta?: number - detected_at?: string - id?: string - package_id?: string - package_slug?: string - rationale?: string | null - recent_rate?: number - recent_runs?: number - severity?: string - status?: string - suggested_patch?: string | null - triggered_by_model?: string | null - updated_at?: string - window_days?: number - } + baseline_rate?: number; + baseline_runs?: number; + delta?: number; + detected_at?: string; + id?: string; + package_id?: string; + package_slug?: string; + rationale?: string | null; + recent_rate?: number; + recent_runs?: number; + severity?: string; + status?: string; + suggested_patch?: string | null; + triggered_by_model?: string | null; + updated_at?: string; + window_days?: number; + }; Relationships: [ { - foreignKeyName: "skill_drift_alerts_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "skill_drift_alerts_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_drift_alerts_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "skill_drift_alerts_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; skill_executions: { Row: { - agent_fp: string | null - arm: string | null - baseline_latency_ms: number | null - baseline_tokens: number | null - created_at: string - error_kind: string | null - experiment_key: string | null - human_intervention: boolean | null - id: string - latency_ms: number | null - model: string | null - package_id: string - package_slug: string - success: boolean - task_completed: boolean | null - tokens_in: number | null - tokens_out: number | null - user_id: string | null - user_rating: number | null - version: string | null - workspace_hash: string | null - } + agent_fp: string | null; + arm: string | null; + baseline_latency_ms: number | null; + baseline_tokens: number | null; + created_at: string; + error_kind: string | null; + experiment_key: string | null; + human_intervention: boolean | null; + id: string; + latency_ms: number | null; + model: string | null; + package_id: string; + package_slug: string; + success: boolean; + task_completed: boolean | null; + tokens_in: number | null; + tokens_out: number | null; + user_id: string | null; + user_rating: number | null; + version: string | null; + workspace_hash: string | null; + }; Insert: { - agent_fp?: string | null - arm?: string | null - baseline_latency_ms?: number | null - baseline_tokens?: number | null - created_at?: string - error_kind?: string | null - experiment_key?: string | null - human_intervention?: boolean | null - id?: string - latency_ms?: number | null - model?: string | null - package_id: string - package_slug: string - success: boolean - task_completed?: boolean | null - tokens_in?: number | null - tokens_out?: number | null - user_id?: string | null - user_rating?: number | null - version?: string | null - workspace_hash?: string | null - } + agent_fp?: string | null; + arm?: string | null; + baseline_latency_ms?: number | null; + baseline_tokens?: number | null; + created_at?: string; + error_kind?: string | null; + experiment_key?: string | null; + human_intervention?: boolean | null; + id?: string; + latency_ms?: number | null; + model?: string | null; + package_id: string; + package_slug: string; + success: boolean; + task_completed?: boolean | null; + tokens_in?: number | null; + tokens_out?: number | null; + user_id?: string | null; + user_rating?: number | null; + version?: string | null; + workspace_hash?: string | null; + }; Update: { - agent_fp?: string | null - arm?: string | null - baseline_latency_ms?: number | null - baseline_tokens?: number | null - created_at?: string - error_kind?: string | null - experiment_key?: string | null - human_intervention?: boolean | null - id?: string - latency_ms?: number | null - model?: string | null - package_id?: string - package_slug?: string - success?: boolean - task_completed?: boolean | null - tokens_in?: number | null - tokens_out?: number | null - user_id?: string | null - user_rating?: number | null - version?: string | null - workspace_hash?: string | null - } + agent_fp?: string | null; + arm?: string | null; + baseline_latency_ms?: number | null; + baseline_tokens?: number | null; + created_at?: string; + error_kind?: string | null; + experiment_key?: string | null; + human_intervention?: boolean | null; + id?: string; + latency_ms?: number | null; + model?: string | null; + package_id?: string; + package_slug?: string; + success?: boolean; + task_completed?: boolean | null; + tokens_in?: number | null; + tokens_out?: number | null; + user_id?: string | null; + user_rating?: number | null; + version?: string | null; + workspace_hash?: string | null; + }; Relationships: [ { - foreignKeyName: "skill_executions_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "skill_executions_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_executions_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "skill_executions_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; skill_experiments: { Row: { - control_share: number - created_at: string - created_by: string | null - ended_at: string | null - hypothesis: string | null - id: string - key: string - package_id: string | null - package_slug: string - started_at: string - status: string - updated_at: string - } + control_share: number; + created_at: string; + created_by: string | null; + ended_at: string | null; + hypothesis: string | null; + id: string; + key: string; + package_id: string | null; + package_slug: string; + started_at: string; + status: string; + updated_at: string; + }; Insert: { - control_share?: number - created_at?: string - created_by?: string | null - ended_at?: string | null - hypothesis?: string | null - id?: string - key: string - package_id?: string | null - package_slug: string - started_at?: string - status?: string - updated_at?: string - } + control_share?: number; + created_at?: string; + created_by?: string | null; + ended_at?: string | null; + hypothesis?: string | null; + id?: string; + key: string; + package_id?: string | null; + package_slug: string; + started_at?: string; + status?: string; + updated_at?: string; + }; Update: { - control_share?: number - created_at?: string - created_by?: string | null - ended_at?: string | null - hypothesis?: string | null - id?: string - key?: string - package_id?: string | null - package_slug?: string - started_at?: string - status?: string - updated_at?: string - } + control_share?: number; + created_at?: string; + created_by?: string | null; + ended_at?: string | null; + hypothesis?: string | null; + id?: string; + key?: string; + package_id?: string | null; + package_slug?: string; + started_at?: string; + status?: string; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "skill_experiments_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "skill_experiments_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_experiments_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "skill_experiments_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; skill_review_runs: { Row: { - created_at: string - doc_class: string | null - doc_hash: string - doc_key: string - doc_type: string - format_score: number | null - grade: string | null - id: string - language: string | null - overall_score: number - substance_score: number | null - user_id: string - verdict_score: number | null - } + created_at: string; + doc_class: string | null; + doc_hash: string; + doc_key: string; + doc_type: string; + format_score: number | null; + grade: string | null; + id: string; + language: string | null; + overall_score: number; + substance_score: number | null; + user_id: string; + verdict_score: number | null; + }; Insert: { - created_at?: string - doc_class?: string | null - doc_hash: string - doc_key: string - doc_type?: string - format_score?: number | null - grade?: string | null - id?: string - language?: string | null - overall_score: number - substance_score?: number | null - user_id: string - verdict_score?: number | null - } + created_at?: string; + doc_class?: string | null; + doc_hash: string; + doc_key: string; + doc_type?: string; + format_score?: number | null; + grade?: string | null; + id?: string; + language?: string | null; + overall_score: number; + substance_score?: number | null; + user_id: string; + verdict_score?: number | null; + }; Update: { - created_at?: string - doc_class?: string | null - doc_hash?: string - doc_key?: string - doc_type?: string - format_score?: number | null - grade?: string | null - id?: string - language?: string | null - overall_score?: number - substance_score?: number | null - user_id?: string - verdict_score?: number | null - } - Relationships: [] - } + created_at?: string; + doc_class?: string | null; + doc_hash?: string; + doc_key?: string; + doc_type?: string; + format_score?: number | null; + grade?: string | null; + id?: string; + language?: string | null; + overall_score?: number; + substance_score?: number | null; + user_id?: string; + verdict_score?: number | null; + }; + Relationships: []; + }; skill_robustness_findings: { Row: { - affected_version: string | null - category: string - code: string - created_at: string - details: string | null - evidence: Json - fixed_in_version: string | null - id: string - package_id: string - package_slug: string - published_at: string | null - severity: string - source: string - status: string - summary: string - updated_at: string - } + affected_version: string | null; + category: string; + code: string; + created_at: string; + details: string | null; + evidence: Json; + fixed_in_version: string | null; + id: string; + package_id: string; + package_slug: string; + published_at: string | null; + severity: string; + source: string; + status: string; + summary: string; + updated_at: string; + }; Insert: { - affected_version?: string | null - category: string - code: string - created_at?: string - details?: string | null - evidence?: Json - fixed_in_version?: string | null - id?: string - package_id: string - package_slug: string - published_at?: string | null - severity: string - source?: string - status?: string - summary: string - updated_at?: string - } + affected_version?: string | null; + category: string; + code: string; + created_at?: string; + details?: string | null; + evidence?: Json; + fixed_in_version?: string | null; + id?: string; + package_id: string; + package_slug: string; + published_at?: string | null; + severity: string; + source?: string; + status?: string; + summary: string; + updated_at?: string; + }; Update: { - affected_version?: string | null - category?: string - code?: string - created_at?: string - details?: string | null - evidence?: Json - fixed_in_version?: string | null - id?: string - package_id?: string - package_slug?: string - published_at?: string | null - severity?: string - source?: string - status?: string - summary?: string - updated_at?: string - } + affected_version?: string | null; + category?: string; + code?: string; + created_at?: string; + details?: string | null; + evidence?: Json; + fixed_in_version?: string | null; + id?: string; + package_id?: string; + package_slug?: string; + published_at?: string | null; + severity?: string; + source?: string; + status?: string; + summary?: string; + updated_at?: string; + }; Relationships: [ { - foreignKeyName: "skill_robustness_findings_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "skill_robustness_findings_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "skill_robustness_findings_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "skill_robustness_findings_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; subscriptions: { Row: { - cancel_at_period_end: boolean - canceled_at: string | null - created_at: string - currency: string | null - current_period_end: string | null - current_period_start: string | null - environment: string - id: string - paddle_customer_id: string | null - paddle_price_id: string | null - paddle_subscription_id: string | null - plan_slug: string - price_cents: number | null - price_id: string | null - product_id: string | null - status: string - stripe_customer_id: string | null - stripe_subscription_id: string | null - updated_at: string - user_id: string - } + cancel_at_period_end: boolean; + canceled_at: string | null; + created_at: string; + currency: string | null; + current_period_end: string | null; + current_period_start: string | null; + environment: string; + id: string; + paddle_customer_id: string | null; + paddle_price_id: string | null; + paddle_subscription_id: string | null; + plan_slug: string; + price_cents: number | null; + price_id: string | null; + product_id: string | null; + status: string; + stripe_customer_id: string | null; + stripe_subscription_id: string | null; + updated_at: string; + user_id: string; + }; Insert: { - cancel_at_period_end?: boolean - canceled_at?: string | null - created_at?: string - currency?: string | null - current_period_end?: string | null - current_period_start?: string | null - environment?: string - id?: string - paddle_customer_id?: string | null - paddle_price_id?: string | null - paddle_subscription_id?: string | null - plan_slug: string - price_cents?: number | null - price_id?: string | null - product_id?: string | null - status?: string - stripe_customer_id?: string | null - stripe_subscription_id?: string | null - updated_at?: string - user_id: string - } + cancel_at_period_end?: boolean; + canceled_at?: string | null; + created_at?: string; + currency?: string | null; + current_period_end?: string | null; + current_period_start?: string | null; + environment?: string; + id?: string; + paddle_customer_id?: string | null; + paddle_price_id?: string | null; + paddle_subscription_id?: string | null; + plan_slug: string; + price_cents?: number | null; + price_id?: string | null; + product_id?: string | null; + status?: string; + stripe_customer_id?: string | null; + stripe_subscription_id?: string | null; + updated_at?: string; + user_id: string; + }; Update: { - cancel_at_period_end?: boolean - canceled_at?: string | null - created_at?: string - currency?: string | null - current_period_end?: string | null - current_period_start?: string | null - environment?: string - id?: string - paddle_customer_id?: string | null - paddle_price_id?: string | null - paddle_subscription_id?: string | null - plan_slug?: string - price_cents?: number | null - price_id?: string | null - product_id?: string | null - status?: string - stripe_customer_id?: string | null - stripe_subscription_id?: string | null - updated_at?: string - user_id?: string - } - Relationships: [] - } + cancel_at_period_end?: boolean; + canceled_at?: string | null; + created_at?: string; + currency?: string | null; + current_period_end?: string | null; + current_period_start?: string | null; + environment?: string; + id?: string; + paddle_customer_id?: string | null; + paddle_price_id?: string | null; + paddle_subscription_id?: string | null; + plan_slug?: string; + price_cents?: number | null; + price_id?: string | null; + product_id?: string | null; + status?: string; + stripe_customer_id?: string | null; + stripe_subscription_id?: string | null; + updated_at?: string; + user_id?: string; + }; + Relationships: []; + }; suppressed_emails: { Row: { - created_at: string - email: string - id: string - metadata: Json | null - reason: string - } + created_at: string; + email: string; + id: string; + metadata: Json | null; + reason: string; + }; Insert: { - created_at?: string - email: string - id?: string - metadata?: Json | null - reason: string - } + created_at?: string; + email: string; + id?: string; + metadata?: Json | null; + reason: string; + }; Update: { - created_at?: string - email?: string - id?: string - metadata?: Json | null - reason?: string - } - Relationships: [] - } + created_at?: string; + email?: string; + id?: string; + metadata?: Json | null; + reason?: string; + }; + Relationships: []; + }; team_audit_events: { Row: { - action: string - actor_id: string - created_at: string - detail: Json - id: string - workspace_id: string - } + action: string; + actor_id: string; + created_at: string; + detail: Json; + id: string; + workspace_id: string; + }; Insert: { - action: string - actor_id: string - created_at?: string - detail?: Json - id?: string - workspace_id: string - } + action: string; + actor_id: string; + created_at?: string; + detail?: Json; + id?: string; + workspace_id: string; + }; Update: { - action?: string - actor_id?: string - created_at?: string - detail?: Json - id?: string - workspace_id?: string - } + action?: string; + actor_id?: string; + created_at?: string; + detail?: Json; + id?: string; + workspace_id?: string; + }; Relationships: [ { - foreignKeyName: "team_audit_events_workspace_id_fkey" - columns: ["workspace_id"] - isOneToOne: false - referencedRelation: "team_workspaces" - referencedColumns: ["id"] + foreignKeyName: "team_audit_events_workspace_id_fkey"; + columns: ["workspace_id"]; + isOneToOne: false; + referencedRelation: "team_workspaces"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; team_invites: { Row: { - accepted_at: string | null - created_by: string - email: string - expires_at: string - id: string - role: string - token_hash: string - workspace_id: string - } + accepted_at: string | null; + created_by: string; + email: string; + expires_at: string; + id: string; + role: string; + token_hash: string; + workspace_id: string; + }; Insert: { - accepted_at?: string | null - created_by: string - email: string - expires_at?: string - id?: string - role: string - token_hash: string - workspace_id: string - } + accepted_at?: string | null; + created_by: string; + email: string; + expires_at?: string; + id?: string; + role: string; + token_hash: string; + workspace_id: string; + }; Update: { - accepted_at?: string | null - created_by?: string - email?: string - expires_at?: string - id?: string - role?: string - token_hash?: string - workspace_id?: string - } + accepted_at?: string | null; + created_by?: string; + email?: string; + expires_at?: string; + id?: string; + role?: string; + token_hash?: string; + workspace_id?: string; + }; Relationships: [ { - foreignKeyName: "team_invites_workspace_id_fkey" - columns: ["workspace_id"] - isOneToOne: false - referencedRelation: "team_workspaces" - referencedColumns: ["id"] + foreignKeyName: "team_invites_workspace_id_fkey"; + columns: ["workspace_id"]; + isOneToOne: false; + referencedRelation: "team_workspaces"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; team_library: { Row: { - package_id: string - pinned_at: string - pinned_by: string - version_id: string - workspace_id: string - } + package_id: string; + pinned_at: string; + pinned_by: string; + version_id: string; + workspace_id: string; + }; Insert: { - package_id: string - pinned_at?: string - pinned_by: string - version_id: string - workspace_id: string - } + package_id: string; + pinned_at?: string; + pinned_by: string; + version_id: string; + workspace_id: string; + }; Update: { - package_id?: string - pinned_at?: string - pinned_by?: string - version_id?: string - workspace_id?: string - } + package_id?: string; + pinned_at?: string; + pinned_by?: string; + version_id?: string; + workspace_id?: string; + }; Relationships: [ { - foreignKeyName: "team_library_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "team_library_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "team_library_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "team_library_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "team_library_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "team_library_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "team_library_version_id_fkey" - columns: ["version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "team_library_version_id_fkey"; + columns: ["version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, { - foreignKeyName: "team_library_workspace_id_fkey" - columns: ["workspace_id"] - isOneToOne: false - referencedRelation: "team_workspaces" - referencedColumns: ["id"] + foreignKeyName: "team_library_workspace_id_fkey"; + columns: ["workspace_id"]; + isOneToOne: false; + referencedRelation: "team_workspaces"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; team_members: { Row: { - joined_at: string - role: string - user_id: string - workspace_id: string - } + joined_at: string; + role: string; + user_id: string; + workspace_id: string; + }; Insert: { - joined_at?: string - role: string - user_id: string - workspace_id: string - } + joined_at?: string; + role: string; + user_id: string; + workspace_id: string; + }; Update: { - joined_at?: string - role?: string - user_id?: string - workspace_id?: string - } + joined_at?: string; + role?: string; + user_id?: string; + workspace_id?: string; + }; Relationships: [ { - foreignKeyName: "team_members_workspace_id_fkey" - columns: ["workspace_id"] - isOneToOne: false - referencedRelation: "team_workspaces" - referencedColumns: ["id"] + foreignKeyName: "team_members_workspace_id_fkey"; + columns: ["workspace_id"]; + isOneToOne: false; + referencedRelation: "team_workspaces"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; team_skill_versions: { Row: { - created_at: string - created_by: string - description: string - files: Json - id: string - name: string - reviewed_at: string | null - reviewed_by: string | null - slug: string - status: string - version: string - workspace_id: string - } + created_at: string; + created_by: string; + description: string; + files: Json; + id: string; + name: string; + reviewed_at: string | null; + reviewed_by: string | null; + slug: string; + status: string; + version: string; + workspace_id: string; + }; Insert: { - created_at?: string - created_by: string - description: string - files: Json - id?: string - name: string - reviewed_at?: string | null - reviewed_by?: string | null - slug: string - status?: string - version: string - workspace_id: string - } + created_at?: string; + created_by: string; + description: string; + files: Json; + id?: string; + name: string; + reviewed_at?: string | null; + reviewed_by?: string | null; + slug: string; + status?: string; + version: string; + workspace_id: string; + }; Update: { - created_at?: string - created_by?: string - description?: string - files?: Json - id?: string - name?: string - reviewed_at?: string | null - reviewed_by?: string | null - slug?: string - status?: string - version?: string - workspace_id?: string - } + created_at?: string; + created_by?: string; + description?: string; + files?: Json; + id?: string; + name?: string; + reviewed_at?: string | null; + reviewed_by?: string | null; + slug?: string; + status?: string; + version?: string; + workspace_id?: string; + }; Relationships: [ { - foreignKeyName: "team_skill_versions_workspace_id_fkey" - columns: ["workspace_id"] - isOneToOne: false - referencedRelation: "team_workspaces" - referencedColumns: ["id"] + foreignKeyName: "team_skill_versions_workspace_id_fkey"; + columns: ["workspace_id"]; + isOneToOne: false; + referencedRelation: "team_workspaces"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; team_workspaces: { Row: { - created_at: string - id: string - name: string - owner_id: string - } + created_at: string; + id: string; + name: string; + owner_id: string; + }; Insert: { - created_at?: string - id?: string - name: string - owner_id: string - } + created_at?: string; + id?: string; + name: string; + owner_id: string; + }; Update: { - created_at?: string - id?: string - name?: string - owner_id?: string - } - Relationships: [] - } + created_at?: string; + id?: string; + name?: string; + owner_id?: string; + }; + Relationships: []; + }; tenant_encrypted_objects: { Row: { - byte_size: number - ciphertext: string - created_at: string - id: string - key_id: string - kind: string - plaintext_sha256: string - ref: string - updated_at: string - user_id: string - } + byte_size: number; + ciphertext: string; + created_at: string; + id: string; + key_id: string; + kind: string; + plaintext_sha256: string; + ref: string; + updated_at: string; + user_id: string; + }; Insert: { - byte_size?: number - ciphertext: string - created_at?: string - id?: string - key_id: string - kind?: string - plaintext_sha256: string - ref: string - updated_at?: string - user_id: string - } + byte_size?: number; + ciphertext: string; + created_at?: string; + id?: string; + key_id: string; + kind?: string; + plaintext_sha256: string; + ref: string; + updated_at?: string; + user_id: string; + }; Update: { - byte_size?: number - ciphertext?: string - created_at?: string - id?: string - key_id?: string - kind?: string - plaintext_sha256?: string - ref?: string - updated_at?: string - user_id?: string - } + byte_size?: number; + ciphertext?: string; + created_at?: string; + id?: string; + key_id?: string; + kind?: string; + plaintext_sha256?: string; + ref?: string; + updated_at?: string; + user_id?: string; + }; Relationships: [ { - foreignKeyName: "tenant_encrypted_objects_key_id_fkey" - columns: ["key_id"] - isOneToOne: false - referencedRelation: "tenant_encryption_keys" - referencedColumns: ["id"] + foreignKeyName: "tenant_encrypted_objects_key_id_fkey"; + columns: ["key_id"]; + isOneToOne: false; + referencedRelation: "tenant_encryption_keys"; + referencedColumns: ["id"]; }, - ] - } + ]; + }; tenant_encryption_keys: { Row: { - alias: string - created_at: string - fingerprint: string - id: string - kdf_salt: string - revoked_at: string | null - rotated_at: string | null - status: string - updated_at: string - user_id: string - verifier: string - wrapped_dek: string | null - } + alias: string; + created_at: string; + fingerprint: string; + id: string; + kdf_salt: string; + revoked_at: string | null; + rotated_at: string | null; + status: string; + updated_at: string; + user_id: string; + verifier: string; + wrapped_dek: string | null; + }; Insert: { - alias?: string - created_at?: string - fingerprint: string - id?: string - kdf_salt: string - revoked_at?: string | null - rotated_at?: string | null - status?: string - updated_at?: string - user_id: string - verifier: string - wrapped_dek?: string | null - } + alias?: string; + created_at?: string; + fingerprint: string; + id?: string; + kdf_salt: string; + revoked_at?: string | null; + rotated_at?: string | null; + status?: string; + updated_at?: string; + user_id: string; + verifier: string; + wrapped_dek?: string | null; + }; Update: { - alias?: string - created_at?: string - fingerprint?: string - id?: string - kdf_salt?: string - revoked_at?: string | null - rotated_at?: string | null - status?: string - updated_at?: string - user_id?: string - verifier?: string - wrapped_dek?: string | null - } - Relationships: [] - } + alias?: string; + created_at?: string; + fingerprint?: string; + id?: string; + kdf_salt?: string; + revoked_at?: string | null; + rotated_at?: string | null; + status?: string; + updated_at?: string; + user_id?: string; + verifier?: string; + wrapped_dek?: string | null; + }; + Relationships: []; + }; tenant_key_events: { Row: { - created_at: string - detail: Json - event: string - id: string - key_id: string | null - user_id: string - } + created_at: string; + detail: Json; + event: string; + id: string; + key_id: string | null; + user_id: string; + }; Insert: { - created_at?: string - detail?: Json - event: string - id?: string - key_id?: string | null - user_id: string - } + created_at?: string; + detail?: Json; + event: string; + id?: string; + key_id?: string | null; + user_id: string; + }; Update: { - created_at?: string - detail?: Json - event?: string - id?: string - key_id?: string | null - user_id?: string - } - Relationships: [] - } + created_at?: string; + detail?: Json; + event?: string; + id?: string; + key_id?: string | null; + user_id?: string; + }; + Relationships: []; + }; upload_injection_audit: { Row: { - content_sample: string | null - created_at: string - filename: string | null - findings: Json - id: number - inferred_type: string | null - rejected: boolean - severity: string - user_id: string | null - } + content_sample: string | null; + created_at: string; + filename: string | null; + findings: Json; + id: number; + inferred_type: string | null; + rejected: boolean; + severity: string; + user_id: string | null; + }; Insert: { - content_sample?: string | null - created_at?: string - filename?: string | null - findings?: Json - id?: number - inferred_type?: string | null - rejected: boolean - severity: string - user_id?: string | null - } + content_sample?: string | null; + created_at?: string; + filename?: string | null; + findings?: Json; + id?: number; + inferred_type?: string | null; + rejected: boolean; + severity: string; + user_id?: string | null; + }; Update: { - content_sample?: string | null - created_at?: string - filename?: string | null - findings?: Json - id?: number - inferred_type?: string | null - rejected?: boolean - severity?: string - user_id?: string | null - } - Relationships: [] - } + content_sample?: string | null; + created_at?: string; + filename?: string | null; + findings?: Json; + id?: number; + inferred_type?: string | null; + rejected?: boolean; + severity?: string; + user_id?: string | null; + }; + Relationships: []; + }; user_mcp_connections: { Row: { - args: Json - command: string | null - created_at: string - env_provided: Json - id: string - last_run_at: string | null - name: string - registry_id: string - scopes: Json - status: string - transport: string - updated_at: string - url: string | null - user_id: string - } + args: Json; + command: string | null; + created_at: string; + env_provided: Json; + id: string; + last_run_at: string | null; + name: string; + registry_id: string; + scopes: Json; + status: string; + transport: string; + updated_at: string; + url: string | null; + user_id: string; + }; Insert: { - args?: Json - command?: string | null - created_at?: string - env_provided?: Json - id?: string - last_run_at?: string | null - name: string - registry_id: string - scopes?: Json - status?: string - transport?: string - updated_at?: string - url?: string | null - user_id: string - } + args?: Json; + command?: string | null; + created_at?: string; + env_provided?: Json; + id?: string; + last_run_at?: string | null; + name: string; + registry_id: string; + scopes?: Json; + status?: string; + transport?: string; + updated_at?: string; + url?: string | null; + user_id: string; + }; Update: { - args?: Json - command?: string | null - created_at?: string - env_provided?: Json - id?: string - last_run_at?: string | null - name?: string - registry_id?: string - scopes?: Json - status?: string - transport?: string - updated_at?: string - url?: string | null - user_id?: string - } - Relationships: [] - } + args?: Json; + command?: string | null; + created_at?: string; + env_provided?: Json; + id?: string; + last_run_at?: string | null; + name?: string; + registry_id?: string; + scopes?: Json; + status?: string; + transport?: string; + updated_at?: string; + url?: string | null; + user_id?: string; + }; + Relationships: []; + }; user_referral_codes: { Row: { - code: string - created_at: string - user_id: string - } + code: string; + created_at: string; + user_id: string; + }; Insert: { - code: string - created_at?: string - user_id: string - } + code: string; + created_at?: string; + user_id: string; + }; Update: { - code?: string - created_at?: string - user_id?: string - } - Relationships: [] - } + code?: string; + created_at?: string; + user_id?: string; + }; + Relationships: []; + }; user_roles: { Row: { - created_at: string - id: string - role: Database["public"]["Enums"]["app_role"] - user_id: string - } + created_at: string; + id: string; + role: Database["public"]["Enums"]["app_role"]; + user_id: string; + }; Insert: { - created_at?: string - id?: string - role: Database["public"]["Enums"]["app_role"] - user_id: string - } + created_at?: string; + id?: string; + role: Database["public"]["Enums"]["app_role"]; + user_id: string; + }; Update: { - created_at?: string - id?: string - role?: Database["public"]["Enums"]["app_role"] - user_id?: string - } - Relationships: [] - } - } + created_at?: string; + id?: string; + role?: Database["public"]["Enums"]["app_role"]; + user_id?: string; + }; + Relationships: []; + }; + }; Views: { findings_mttr: { Row: { - fixed_findings: number | null - mean_hours_to_patch: number | null - median_hours_to_patch: number | null - } - Relationships: [] - } + fixed_findings: number | null; + mean_hours_to_patch: number | null; + median_hours_to_patch: number | null; + }; + Relationships: []; + }; package_rankings: { Row: { - author_handle: string | null - author_verified: boolean | null - avg_hallucination: number | null - avg_health: number | null - avg_latency_ms: number | null - avg_precision: number | null - description: string | null - id: string | null - install_count: number | null - latest_version: string | null - name: string | null - score: number | null - slug: string | null - total_runs: number | null - type: Database["public"]["Enums"]["package_type"] | null - } - Relationships: [] - } + author_handle: string | null; + author_verified: boolean | null; + avg_hallucination: number | null; + avg_health: number | null; + avg_latency_ms: number | null; + avg_precision: number | null; + description: string | null; + id: string | null; + install_count: number | null; + latest_version: string | null; + name: string | null; + score: number | null; + slug: string | null; + total_runs: number | null; + type: Database["public"]["Enums"]["package_type"] | null; + }; + Relationships: []; + }; package_upload_jobs_safe: { Row: { - attempts: number | null - created_at: string | null - error: string | null - filename: string | null - finished_at: string | null - id: string | null - inferred_type: string | null - package_id: string | null - result: Json | null - slug: string | null - started_at: string | null - status: string | null - user_id: string | null - } + attempts: number | null; + created_at: string | null; + error: string | null; + filename: string | null; + finished_at: string | null; + id: string | null; + inferred_type: string | null; + package_id: string | null; + result: Json | null; + slug: string | null; + started_at: string | null; + status: string | null; + user_id: string | null; + }; Insert: { - attempts?: number | null - created_at?: string | null - error?: string | null - filename?: string | null - finished_at?: string | null - id?: string | null - inferred_type?: string | null - package_id?: string | null - result?: Json | null - slug?: string | null - started_at?: string | null - status?: string | null - user_id?: string | null - } + attempts?: number | null; + created_at?: string | null; + error?: string | null; + filename?: string | null; + finished_at?: string | null; + id?: string | null; + inferred_type?: string | null; + package_id?: string | null; + result?: Json | null; + slug?: string | null; + started_at?: string | null; + status?: string | null; + user_id?: string | null; + }; Update: { - attempts?: number | null - created_at?: string | null - error?: string | null - filename?: string | null - finished_at?: string | null - id?: string | null - inferred_type?: string | null - package_id?: string | null - result?: Json | null - slug?: string | null - started_at?: string | null - status?: string | null - user_id?: string | null - } - Relationships: [] - } + attempts?: number | null; + created_at?: string | null; + error?: string | null; + filename?: string | null; + finished_at?: string | null; + id?: string | null; + inferred_type?: string | null; + package_id?: string | null; + result?: Json | null; + slug?: string | null; + started_at?: string | null; + status?: string | null; + user_id?: string | null; + }; + Relationships: []; + }; package_versions_public: { Row: { - compatibility: Json | null - created_at: string | null - examples: Json | null - id: string | null - notes: string | null - package_id: string | null - parent_version_id: string | null - status: Database["public"]["Enums"]["version_status"] | null - version: string | null - } + compatibility: Json | null; + created_at: string | null; + examples: Json | null; + id: string | null; + notes: string | null; + package_id: string | null; + parent_version_id: string | null; + status: Database["public"]["Enums"]["version_status"] | null; + version: string | null; + }; Relationships: [ { - foreignKeyName: "package_versions_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "package_rankings" - referencedColumns: ["id"] + foreignKeyName: "package_versions_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "package_rankings"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_versions_package_id_fkey" - columns: ["package_id"] - isOneToOne: false - referencedRelation: "packages" - referencedColumns: ["id"] + foreignKeyName: "package_versions_package_id_fkey"; + columns: ["package_id"]; + isOneToOne: false; + referencedRelation: "packages"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_versions_parent_version_id_fkey" - columns: ["parent_version_id"] - isOneToOne: false - referencedRelation: "package_versions" - referencedColumns: ["id"] + foreignKeyName: "package_versions_parent_version_id_fkey"; + columns: ["parent_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions"; + referencedColumns: ["id"]; }, { - foreignKeyName: "package_versions_parent_version_id_fkey" - columns: ["parent_version_id"] - isOneToOne: false - referencedRelation: "package_versions_public" - referencedColumns: ["id"] + foreignKeyName: "package_versions_parent_version_id_fkey"; + columns: ["parent_version_id"]; + isOneToOne: false; + referencedRelation: "package_versions_public"; + referencedColumns: ["id"]; }, - ] - } - } + ]; + }; + }; Functions: { _credit_apply: { Args: { - _delta: number - _description: string - _metadata: Json - _reason: Database["public"]["Enums"]["credit_reason"] - _ref_id: string - _ref_type: string - _user_id: string - } - Returns: number - } + _delta: number; + _description: string; + _metadata: Json; + _reason: Database["public"]["Enums"]["credit_reason"]; + _ref_id: string; + _ref_type: string; + _user_id: string; + }; + Returns: number; + }; agent_onboarding_funnel: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - completions: number - sessions: number - stage: string - step_id: string - }[] - } + completions: number; + sessions: number; + stage: string; + step_id: string; + }[]; + }; artifact_readable: { - Args: { _package: string; _version: string } - Returns: boolean - } + Args: { _package: string; _version: string }; + Returns: boolean; + }; attach_execution_outcome: { Args: { - _agent_fp?: string - _execution_id: string - _human_intervention?: boolean - _task_completed?: boolean - _user_rating?: number - } - Returns: boolean - } + _agent_fp?: string; + _execution_id: string; + _human_intervention?: boolean; + _task_completed?: boolean; + _user_rating?: number; + }; + Returns: boolean; + }; award_referral_credits: { - Args: { _credits: number; _kind: string; _referral_id: string } - Returns: Json - } + Args: { _credits: number; _kind: string; _referral_id: string }; + Returns: Json; + }; check_rls_coverage: { - Args: never + Args: never; Returns: { - issue: string - policy_count: number - rls_enabled: boolean - table_name: string - }[] - } + issue: string; + policy_count: number; + rls_enabled: boolean; + table_name: string; + }[]; + }; check_security_boundaries: { - Args: never + Args: never; Returns: { - check_name: string - passed: boolean - }[] - } + check_name: string; + passed: boolean; + }[]; + }; claim_referral: { - Args: { _code: string; _package_slug?: string; _source_url?: string } - Returns: Json - } + Args: { _code: string; _package_slug?: string; _source_url?: string }; + Returns: Json; + }; complete_search_embedding_batch: { - Args: { _attempt: string; _entries: Json; _receipt: Json } - Returns: number - } + Args: { _attempt: string; _entries: Json; _receipt: Json }; + Returns: number; + }; compute_skill_drift: { - Args: { _package_id: string; _window_days?: number } - Returns: Json - } + Args: { _package_id: string; _window_days?: number }; + Returns: Json; + }; crm_active_hours: { - Args: { _user_id: string } + Args: { _user_id: string }; Returns: { - events: number - hour: number - }[] - } + events: number; + hour: number; + }[]; + }; crm_activity_hours: { - Args: { _days?: number; _user_id: string } + Args: { _days?: number; _user_id: string }; Returns: { - events: number - hour: number - sync_events: number - usage_events: number - }[] - } + events: number; + hour: number; + sync_events: number; + usage_events: number; + }[]; + }; crm_customers: { - Args: { _limit?: number; _offset?: number; _user_id?: string } + Args: { _limit?: number; _offset?: number; _user_id?: string }; Returns: { - agent_count: number - cancel_at_period_end: boolean - cloud_skill_count: number - credits_spent: number - crm_unsubscribed: boolean - current_period_end: string - diagnosis_count: number - display_name: string - email: string - emails_sent_7d: number - executions_30d: number - handle: string - install_count: number - last_active_at: string - last_email_at: string - last_review_at: string - last_sign_in_at: string - mcp_call_count: number - mcp_last_call_at: string - mcp_last_used_at: string - mcp_token_count: number - package_count: number - plan_slug: string - price_cents: number - residency_count: number - review_count: number - signed_up_at: string - stage: string - sub_environment: string - sub_status: string - upload_count: number - user_id: string - }[] - } + agent_count: number; + cancel_at_period_end: boolean; + cloud_skill_count: number; + credits_spent: number; + crm_unsubscribed: boolean; + current_period_end: string; + diagnosis_count: number; + display_name: string; + email: string; + emails_sent_7d: number; + executions_30d: number; + handle: string; + install_count: number; + last_active_at: string; + last_email_at: string; + last_review_at: string; + last_sign_in_at: string; + mcp_call_count: number; + mcp_last_call_at: string; + mcp_last_used_at: string; + mcp_token_count: number; + package_count: number; + plan_slug: string; + price_cents: number; + residency_count: number; + review_count: number; + signed_up_at: string; + stage: string; + sub_environment: string; + sub_status: string; + upload_count: number; + user_id: string; + }[]; + }; crm_effectiveness: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - clicked: number - converted: number - last_sent_at: string - opened: number - sent: number - trigger: string - unsubscribed: number - variant: string - }[] - } + clicked: number; + converted: number; + last_sent_at: string; + opened: number; + sent: number; + trigger: string; + unsubscribed: number; + variant: string; + }[]; + }; crm_effectiveness_by_segment: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - clicked: number - converted: number - last_sent_at: string - opened: number - sent: number - tool_id: string - trigger: string - unsubscribed: number - usage_pattern: string - variant: string - }[] - } + clicked: number; + converted: number; + last_sent_at: string; + opened: number; + sent: number; + tool_id: string; + trigger: string; + unsubscribed: number; + usage_pattern: string; + variant: string; + }[]; + }; crm_segment_send_hour_stats: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - converted: number - engaged: number - send_hour: number - sent: number - tool_id: string - usage_pattern: string - }[] - } + converted: number; + engaged: number; + send_hour: number; + sent: number; + tool_id: string; + usage_pattern: string; + }[]; + }; crm_send_hour_stats: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - converted: number - engaged: number - send_hour: number - sent: number - }[] - } - crm_track_click: { Args: { _token: string }; Returns: string } - crm_track_open: { Args: { _token: string }; Returns: undefined } + converted: number; + engaged: number; + send_hour: number; + sent: number; + }[]; + }; + crm_track_click: { Args: { _token: string }; Returns: string }; + crm_track_open: { Args: { _token: string }; Returns: undefined }; delete_email: { - Args: { message_id: number; queue_name: string } - Returns: boolean - } - email_queue_dispatch: { Args: never; Returns: undefined } + Args: { message_id: number; queue_name: string }; + Returns: boolean; + }; + email_queue_dispatch: { Args: never; Returns: undefined }; enqueue_email: { - Args: { payload: Json; queue_name: string } - Returns: number - } - gen_referral_code: { Args: never; Returns: string } + Args: { payload: Json; queue_name: string }; + Returns: number; + }; + gen_referral_code: { Args: never; Returns: string }; get_attack_class_benchmark: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - attack_class: string - pass_rate: number - passed: number - subject_arm: string - total: number - wilson_lb: number - }[] - } - get_credit_balance: { Args: { _user_id: string }; Returns: number } - get_my_referral_stats: { Args: never; Returns: Json } - get_pack_with_items: { Args: { _slug: string }; Returns: Json } - get_package_ratings: { Args: { _package_id: string }; Returns: Json } - get_review_eligibility: { Args: { _package_id: string }; Returns: Json } + attack_class: string; + pass_rate: number; + passed: number; + subject_arm: string; + total: number; + wilson_lb: number; + }[]; + }; + get_credit_balance: { Args: { _user_id: string }; Returns: number }; + get_my_referral_stats: { Args: never; Returns: Json }; + get_pack_with_items: { Args: { _slug: string }; Returns: Json }; + get_package_ratings: { Args: { _package_id: string }; Returns: Json }; + get_review_eligibility: { Args: { _package_id: string }; Returns: Json }; get_search_embedding_attempt: { - Args: { _attempt: string } + Args: { _attempt: string }; Returns: { - receipt: Json - status: string - }[] - } - get_skill_trust: { Args: { _slug: string }; Returns: Json } + receipt: Json; + status: string; + }[]; + }; + get_skill_trust: { Args: { _slug: string }; Returns: Json }; get_skill_uplift: { - Args: { _days?: number; _slug: string } - Returns: Json - } + Args: { _days?: number; _slug: string }; + Returns: Json; + }; get_workspace_roi: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - completed: number - completion_rate: number - executions: number - guardrail_blocks: number - intervention_rate: number - interventions: number - last_seen: string - latency_saved_ms: number - packages_used: number - thumbs_down: number - thumbs_up: number - tokens_saved: number - workspace_hash: string - }[] - } - grant_signup_bonus: { Args: { _user_id: string }; Returns: undefined } + completed: number; + completion_rate: number; + executions: number; + guardrail_blocks: number; + intervention_rate: number; + interventions: number; + last_seen: string; + latency_saved_ms: number; + packages_used: number; + thumbs_down: number; + thumbs_up: number; + tokens_saved: number; + workspace_hash: string; + }[]; + }; + grant_signup_bonus: { Args: { _user_id: string }; Returns: undefined }; has_active_paid_subscription: { - Args: { _user_id: string } - Returns: boolean - } + Args: { _user_id: string }; + Returns: boolean; + }; has_active_subscription: | { Args: { _user_id: string }; Returns: boolean } - | { Args: { _user_id: string; check_env?: string }; Returns: boolean } + | { Args: { _user_id: string; check_env?: string }; Returns: boolean }; has_role: { Args: { - _role: Database["public"]["Enums"]["app_role"] - _user_id: string - } - Returns: boolean - } + _role: Database["public"]["Enums"]["app_role"]; + _user_id: string; + }; + Returns: boolean; + }; list_package_reviews: { - Args: { _limit?: number; _package_id: string } + Args: { _limit?: number; _package_id: string }; Returns: { - avatar_url: string - body: string - created_at: string - display_name: string - id: string - rater_kind: string - rating: number - user_id: string - verified_purchase: boolean - }[] - } - manage_collection: { Args: { _payload: Json }; Returns: Json } + avatar_url: string; + body: string; + created_at: string; + display_name: string; + id: string; + rater_kind: string; + rating: number; + user_id: string; + verified_purchase: boolean; + }[]; + }; + manage_collection: { Args: { _payload: Json }; Returns: Json }; mcp_check_and_log_call: { Args: { - _identity: string - _is_write: boolean - _tool_name: string - _user_id: string - } - Returns: Json - } + _identity: string; + _is_write: boolean; + _tool_name: string; + _user_id: string; + }; + Returns: Json; + }; mcp_funnel_summary: | { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - count: number - distinct_users: number - event: string - }[] + count: number; + distinct_users: number; + event: string; + }[]; } | { - Args: { _days?: number; _exclude_bots?: boolean } + Args: { _days?: number; _exclude_bots?: boolean }; Returns: { - count: number - distinct_users: number - event: string - }[] - } + count: number; + distinct_users: number; + event: string; + }[]; + }; mcp_funnel_traffic_breakdown: { - Args: { _days?: number } + Args: { _days?: number }; Returns: { - bot_count: number - bot_distinct: number - event: string - human_count: number - human_distinct: number - }[] - } + bot_count: number; + bot_distinct: number; + event: string; + human_count: number; + human_distinct: number; + }[]; + }; mcp_funnel_ua_families: { - Args: { _days?: number; _limit?: number } + Args: { _days?: number; _limit?: number }; Returns: { - count: number - is_bot: boolean - ua_family: string - }[] - } + count: number; + is_bot: boolean; + ua_family: string; + }[]; + }; mcp_idempotency_get: { - Args: { _key_hash: string; _tool: string; _user_id: string } - Returns: Json - } + Args: { _key_hash: string; _tool: string; _user_id: string }; + Returns: Json; + }; mcp_idempotency_put: { Args: { - _key_hash: string - _response: Json - _tool: string - _user_id: string - } - Returns: undefined - } + _key_hash: string; + _response: Json; + _tool: string; + _user_id: string; + }; + Returns: undefined; + }; mcp_oauth_exchange_code: { Args: { - _access_token_hash: string - _access_ttl_seconds?: number - _client_id: string - _code_hash: string - _redirect_uri: string - _refresh_token_hash: string - _refresh_ttl_seconds?: number - } - Returns: Json - } - mcp_oauth_get_client: { Args: { _client_id: string }; Returns: Json } + _access_token_hash: string; + _access_ttl_seconds?: number; + _client_id: string; + _code_hash: string; + _redirect_uri: string; + _refresh_token_hash: string; + _refresh_ttl_seconds?: number; + }; + Returns: Json; + }; + mcp_oauth_get_client: { Args: { _client_id: string }; Returns: Json }; mcp_oauth_issue_code: { Args: { - _client_id: string - _code_challenge: string - _code_challenge_method: string - _code_hash: string - _redirect_uri: string - _scope: string - _ttl_seconds?: number - } - Returns: undefined - } + _client_id: string; + _code_challenge: string; + _code_challenge_method: string; + _code_hash: string; + _redirect_uri: string; + _scope: string; + _ttl_seconds?: number; + }; + Returns: undefined; + }; mcp_oauth_list_user_connections: { - Args: never + Args: never; Returns: { - active_access: number - active_refresh: number - client_id: string - client_name: string - first_granted: string - last_used: string - scope: string - }[] - } + active_access: number; + active_refresh: number; + client_id: string; + client_name: string; + first_granted: string; + last_used: string; + scope: string; + }[]; + }; mcp_oauth_refresh_token: { Args: { - _access_ttl_seconds?: number - _client_id: string - _new_access_hash: string - _new_refresh_hash: string - _old_refresh_hash: string - _refresh_ttl_seconds?: number - } - Returns: Json - } + _access_ttl_seconds?: number; + _client_id: string; + _new_access_hash: string; + _new_refresh_hash: string; + _old_refresh_hash: string; + _refresh_ttl_seconds?: number; + }; + Returns: Json; + }; mcp_oauth_register_client: { Args: { - _client_name: string - _client_uri?: string - _ip?: string - _logo_uri?: string - _redirect_uris: string[] - _software_id?: string - _software_version?: string - } - Returns: Json - } + _client_name: string; + _client_uri?: string; + _ip?: string; + _logo_uri?: string; + _redirect_uris: string[]; + _software_id?: string; + _software_version?: string; + }; + Returns: Json; + }; mcp_oauth_revoke_client_for_user: { - Args: { _client_id: string } - Returns: number - } + Args: { _client_id: string }; + Returns: number; + }; mcp_oauth_revoke_token: { - Args: { _token_hash: string } - Returns: undefined - } - mcp_oauth_verify_access: { Args: { _token_hash: string }; Returns: Json } + Args: { _token_hash: string }; + Returns: undefined; + }; + mcp_oauth_verify_access: { Args: { _token_hash: string }; Returns: Json }; moderate_review: { Args: { - _hide: boolean - _reason?: string - _resolution?: string - _review_id: string - } - Returns: undefined - } + _hide: boolean; + _reason?: string; + _resolution?: string; + _review_id: string; + }; + Returns: undefined; + }; move_to_dlq: { Args: { - dlq_name: string - message_id: number - payload: Json - source_queue: string - } - Returns: number - } - next_sas_code: { Args: never; Returns: string } - package_vertical_from_rules: { Args: { _rules: Json }; Returns: string } - purchase_pack: { Args: { _pack_id: string }; Returns: Json } - purchase_package: { Args: { _package_id: string }; Returns: Json } + dlq_name: string; + message_id: number; + payload: Json; + source_queue: string; + }; + Returns: number; + }; + next_sas_code: { Args: never; Returns: string }; + package_vertical_from_rules: { Args: { _rules: Json }; Returns: string }; + purchase_pack: { Args: { _pack_id: string }; Returns: Json }; + purchase_package: { Args: { _package_id: string }; Returns: Json }; read_agent_match_selection_cache: { - Args: { p_cache_key: string; p_scope_hash: string } + Args: { p_cache_key: string; p_scope_hash: string }; Returns: { - age_ms: number - evidence: Json - }[] - } + age_ms: number; + evidence: Json; + }[]; + }; read_email_batch: { - Args: { batch_size: number; queue_name: string; vt: number } + Args: { batch_size: number; queue_name: string; vt: number }; Returns: { - message: Json - msg_id: number - read_ct: number - }[] - } - recompute_trust_scores_v2: { Args: never; Returns: number } + message: Json; + msg_id: number; + read_ct: number; + }[]; + }; + recompute_trust_scores_v2: { Args: never; Returns: number }; record_mcp_funnel_event: { Args: { - _anon_hash?: string - _client_id?: string - _client_name?: string - _event: string - _props?: Json - } - Returns: undefined - } + _anon_hash?: string; + _client_id?: string; + _client_name?: string; + _event: string; + _props?: Json; + }; + Returns: undefined; + }; report_review: { - Args: { _details?: string; _reason: string; _review_id: string } - Returns: string - } + Args: { _details?: string; _reason: string; _review_id: string }; + Returns: string; + }; report_skill_execution: { Args: { - _agent_fp?: string - _arm?: string - _baseline_latency_ms?: number - _baseline_tokens?: number - _error_kind?: string - _experiment_key?: string - _human_intervention?: boolean - _latency_ms?: number - _model?: string - _slug: string - _success: boolean - _task_completed?: boolean - _tokens_in?: number - _tokens_out?: number - _user_rating?: number - _version?: string - _workspace_hash?: string - } - Returns: string - } + _agent_fp?: string; + _arm?: string; + _baseline_latency_ms?: number; + _baseline_tokens?: number; + _error_kind?: string; + _experiment_key?: string; + _human_intervention?: boolean; + _latency_ms?: number; + _model?: string; + _slug: string; + _success: boolean; + _task_completed?: boolean; + _tokens_in?: number; + _tokens_out?: number; + _user_rating?: number; + _version?: string; + _workspace_hash?: string; + }; + Returns: string; + }; reserve_search_embedding_batch: { - Args: { _attempt: string; _model: string } - Returns: string - } - reserve_semantic_query: { Args: { _actor: string }; Returns: boolean } + Args: { _attempt: string; _model: string }; + Returns: string; + }; + reserve_semantic_query: { Args: { _actor: string }; Returns: boolean }; resolve_report: { - Args: { _report_id: string; _resolution?: string; _status: string } - Returns: undefined - } + Args: { _report_id: string; _resolution?: string; _status: string }; + Returns: undefined; + }; search_embedding_index_status: { - Args: { _model: string } + Args: { _model: string }; Returns: { - eligible: number - indexed: number - inflight: boolean - ready: boolean - }[] - } + eligible: number; + indexed: number; + inflight: boolean; + ready: boolean; + }[]; + }; search_embedding_source: { - Args: { _description: string; _long_description: string; _name: string } - Returns: string - } + Args: { _description: string; _long_description: string; _name: string }; + Returns: string; + }; search_packages: { Args: { - limit_count?: number - offset_count?: number - package_type?: string - query: string - } + limit_count?: number; + offset_count?: number; + package_type?: string; + query: string; + }; Returns: { - description: string - install_count: number - latest_version: string - name: string - rank: number - slug: string - type: string - }[] - } + description: string; + install_count: number; + latest_version: string; + name: string; + rank: number; + slug: string; + type: string; + }[]; + }; search_packages_semantic: { Args: { - _limit?: number - _model: string - _offset?: number - _query: string - _type?: string - } + _limit?: number; + _model: string; + _offset?: number; + _query: string; + _type?: string; + }; Returns: { - latest_version: string - name: string - score: number - slug: string - snippet: string - type: string - }[] - } + latest_version: string; + name: string; + score: number; + slug: string; + snippet: string; + type: string; + }[]; + }; seed_robustness_findings_for: { - Args: { _package_id: string } - Returns: number - } + Args: { _package_id: string }; + Returns: number; + }; skill_evidence: { Args: { - _days?: number - _experiment?: string - _model?: string - _slug: string - _version?: string - } + _days?: number; + _experiment?: string; + _model?: string; + _slug: string; + _version?: string; + }; Returns: { - arm: string - avg_latency_ms: number - completed: number - executions: number - experiment_key: string - measured: number - model: string - total_tokens: number - version: string - }[] - } - snapshot_package_weekly_metrics: { Args: never; Returns: number } + arm: string; + avg_latency_ms: number; + completed: number; + executions: number; + experiment_key: string; + measured: number; + model: string; + total_tokens: number; + version: string; + }[]; + }; + snapshot_package_weekly_metrics: { Args: never; Returns: number }; submit_authored_package: { - Args: { _author: string; _document: Json } - Returns: Json - } + Args: { _author: string; _document: Json }; + Returns: Json; + }; submit_package_feedback: { Args: { - _agent_model?: string - _comments?: string - _context?: Json - _rating?: number - _request_id: string - _sentiment?: string - _source?: string - } - Returns: string - } + _agent_model?: string; + _comments?: string; + _context?: Json; + _rating?: number; + _request_id: string; + _sentiment?: string; + _source?: string; + }; + Returns: string; + }; submit_review: { Args: { - _body: string - _package_id: string - _rater_kind: string - _rating: number - } - Returns: string - } + _body: string; + _package_id: string; + _rater_kind: string; + _rating: number; + }; + Returns: string; + }; team_action: { - Args: { _action: string; _payload?: Json; _workspace?: string } - Returns: Json - } - team_role: { Args: { _workspace: string }; Returns: string } - trust_saturate: { Args: { k: number; n: number }; Returns: number } + Args: { _action: string; _payload?: Json; _workspace?: string }; + Returns: Json; + }; + team_role: { Args: { _workspace: string }; Returns: string }; + trust_saturate: { Args: { k: number; n: number }; Returns: number }; wilson_lower_bound: | { Args: { successes: number; total: number }; Returns: number } | { - Args: { successes: number; total: number; z?: number } - Returns: number - } + Args: { successes: number; total: number; z?: number }; + Returns: number; + }; write_agent_match_selection_cache: { - Args: { p_cache_key: string; p_evidence: Json; p_scope_hash: string } - Returns: boolean - } - } + Args: { p_cache_key: string; p_evidence: Json; p_scope_hash: string }; + Returns: boolean; + }; + }; Enums: { - app_role: "admin" | "publisher" | "user" + app_role: "admin" | "publisher" | "user"; credit_reason: | "signup_bonus" | "subscription_grant" @@ -5395,134 +5389,128 @@ export type Database = { | "sale" | "refund" | "manual_adjustment" - | "promo" - learning_kind: "miss" | "hallucination" | "win" | "suggestion" | "block" - package_type: "skill" | "playbook" | "soul" | "guardrail" - run_status: "running" | "ok" | "error" | "blocked" - version_status: "stable" | "beta" | "deprecated" | "candidate" - } + | "promo"; + learning_kind: "miss" | "hallucination" | "win" | "suggestion" | "block"; + package_type: "skill" | "playbook" | "soul" | "guardrail"; + run_status: "running" | "ok" | "error" | "blocked"; + version_status: "stable" | "beta" | "deprecated" | "candidate"; + }; CompositeTypes: { - [_ in never]: never - } - } -} + [_ in never]: never; + }; + }; +}; -type DatabaseWithoutInternals = Omit +type DatabaseWithoutInternals = Omit; -type DefaultSchema = DatabaseWithoutInternals[Extract] +type DefaultSchema = DatabaseWithoutInternals[Extract]; export type Tables< DefaultSchemaTableNameOrOptions extends | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) | { schema: keyof DatabaseWithoutInternals }, TableName extends (DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) : never) = never, > = DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R + Row: infer R; } ? R : never - : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & - DefaultSchema["Views"]) - ? (DefaultSchema["Tables"] & - DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { - Row: infer R + : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) + ? (DefaultSchema["Tables"] & DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { + Row: infer R; } ? R : never - : never + : never; export type TablesInsert< DefaultSchemaTableNameOrOptions extends - | keyof DefaultSchema["Tables"] - | { schema: keyof DatabaseWithoutInternals }, + keyof DefaultSchema["Tables"] | { schema: keyof DatabaseWithoutInternals }, TableName extends (DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] : never) = never, > = DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I + Insert: infer I; } ? I : never : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Insert: infer I + Insert: infer I; } ? I : never - : never + : never; export type TablesUpdate< DefaultSchemaTableNameOrOptions extends - | keyof DefaultSchema["Tables"] - | { schema: keyof DatabaseWithoutInternals }, + keyof DefaultSchema["Tables"] | { schema: keyof DatabaseWithoutInternals }, TableName extends (DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] : never) = never, > = DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U + Update: infer U; } ? U : never : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Update: infer U + Update: infer U; } ? U : never - : never + : never; export type Enums< DefaultSchemaEnumNameOrOptions extends - | keyof DefaultSchema["Enums"] - | { schema: keyof DatabaseWithoutInternals }, + keyof DefaultSchema["Enums"] | { schema: keyof DatabaseWithoutInternals }, EnumName extends (DefaultSchemaEnumNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] : never) = never, > = DefaultSchemaEnumNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] - : never + : never; export type CompositeTypes< PublicCompositeTypeNameOrOptions extends - | keyof DefaultSchema["CompositeTypes"] - | { schema: keyof DatabaseWithoutInternals }, + keyof DefaultSchema["CompositeTypes"] | { schema: keyof DatabaseWithoutInternals }, CompositeTypeName extends (PublicCompositeTypeNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] : never) = never, > = PublicCompositeTypeNameOrOptions extends { - schema: keyof DatabaseWithoutInternals + schema: keyof DatabaseWithoutInternals; } ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] - : never + : never; export const Constants = { public: { @@ -5543,4 +5531,4 @@ export const Constants = { version_status: ["stable", "beta", "deprecated", "candidate"], }, }, -} as const +} as const; diff --git a/src/lib/auth/request-user.server.ts b/src/lib/auth/request-user.server.ts new file mode 100644 index 00000000..0a26edbe --- /dev/null +++ b/src/lib/auth/request-user.server.ts @@ -0,0 +1,14 @@ +import { supabaseAdmin } from "@/integrations/supabase/client.server"; +import { verifyBearer } from "@/lib/auth/bearer.server"; +/** Authentication is optional only for anonymous capability exams, never for owned history. */ +export async function getVerifiedRequestUserId(request: Request): Promise { + const value = request.headers.get("authorization"); + if (!value) return null; + const token = value.match(/^Bearer ([^\s]+)$/i)?.[1]; + if (!token) throw new Response("Unauthorized", { status: 401 }); + const { data, error } = await supabaseAdmin.auth.getUser(token); + if (!error && data.user) return data.user.id; + const bearer = await verifyBearer(token); + if (bearer) return bearer.user_id; + throw new Response("Unauthorized", { status: 401 }); +} diff --git a/src/lib/checkout-quantity.ts b/src/lib/checkout-quantity.ts index 3796a41d..538f07b9 100644 --- a/src/lib/checkout-quantity.ts +++ b/src/lib/checkout-quantity.ts @@ -18,14 +18,12 @@ export function shouldEnableAdjustableQuantity(input: { quantity?: number; adjustableQuantity?: boolean; }): boolean { - if (typeof input.adjustableQuantity === "boolean") return input.adjustableQuantity; - if (input.priceId.startsWith("sak_agent_pass_")) return true; - return typeof input.quantity === "number" && input.quantity > 0; + return isSeatPrice(input.priceId) && input.adjustableQuantity !== false; } /** Seat-based prices (one seat per production agent) are the only ones sold in quantity. */ export function isSeatPrice(priceId: string): boolean { - return priceId.startsWith("sak_agent_pass_"); + return priceId === "sak_agent_pass_monthly"; } /** @@ -48,13 +46,11 @@ const ALLOWED_RETURN_HOSTS = new Set([ export function isAllowedReturnHost(hostname: string): boolean { const host = hostname.toLowerCase(); if (ALLOWED_RETURN_HOSTS.has(host)) return true; - if ( - (host.endsWith(".lovable.app") || host.endsWith(".lovableproject.com")) && - host.includes(PROJECT_ID) - ) { - return true; - } - return host === "localhost" || host === "127.0.0.1"; + return new Set([ + `id-preview--${PROJECT_ID}.lovable.app`, + `preview--${PROJECT_ID}.lovable.app`, + `project--${PROJECT_ID}.lovable.app`, + ]).has(host); } /** @@ -75,7 +71,7 @@ export function validateReturnUrl(returnUrl: unknown): string { if (url.protocol !== "https:" && !(local && url.protocol === "http:")) { throw new Error("Invalid return URL"); } - if (url.username || url.password || !isAllowedReturnHost(url.hostname)) { + if (url.port || url.username || url.password || !isAllowedReturnHost(url.hostname)) { throw new Error("Invalid return URL"); } return returnUrl; diff --git a/src/lib/marketplace/content-access.server.ts b/src/lib/marketplace/content-access.server.ts new file mode 100644 index 00000000..f3e03b7d --- /dev/null +++ b/src/lib/marketplace/content-access.server.ts @@ -0,0 +1,34 @@ +import { supabaseAdmin } from "@/integrations/supabase/client.server"; +export async function canReadPackageContent( + pkg: { id: string; author_id: string | null; price_credits: number }, + userId: string | null, +): Promise { + if (pkg.price_credits === 0) return true; + if (!userId) return false; + if (pkg.author_id === userId) return true; + const [role, purchase, packs] = await Promise.all([ + supabaseAdmin + .from("user_roles") + .select("role") + .eq("user_id", userId) + .eq("role", "admin") + .maybeSingle(), + supabaseAdmin + .from("package_purchases") + .select("id") + .eq("buyer_id", userId) + .eq("package_id", pkg.id) + .limit(1), + supabaseAdmin.from("pack_purchases").select("pack_id").eq("buyer_id", userId), + ]); + if (role.data || purchase.data?.length) return true; + const ids = (packs.data ?? []).map((p) => p.pack_id); + if (!ids.length) return false; + const { data } = await supabaseAdmin + .from("pack_items") + .select("pack_id") + .in("pack_id", ids) + .eq("package_id", pkg.id) + .limit(1); + return !!data?.length; +} diff --git a/src/lib/marketplace/detail.functions.ts b/src/lib/marketplace/detail.functions.ts index fe8bda88..0826ad77 100644 --- a/src/lib/marketplace/detail.functions.ts +++ b/src/lib/marketplace/detail.functions.ts @@ -95,7 +95,7 @@ export const getPackageDetail = createServerFn({ method: "GET" }) supabaseAdmin.from("reviews").select("rating").eq("package_id", pkg.id), ]); const compatibility = normCompat(compatibilityData); - const examples = latest ? normExamples(latest.examples) : []; + const examples = isFree && latest ? normExamples(latest.examples) : []; // Read server-side (prompt hash for evidence) but returned only when free. const rules = (isFree ? (latest.rules ?? {}) : {}) as Record; const systemPrompt = diff --git a/src/lib/marketplace/telemetry.functions.ts b/src/lib/marketplace/telemetry.functions.ts index 1a613370..12e837bc 100644 --- a/src/lib/marketplace/telemetry.functions.ts +++ b/src/lib/marketplace/telemetry.functions.ts @@ -35,13 +35,6 @@ export const getEvaluationData = createServerFn({ method: "GET" }).handler( const w30 = (t.window_30d ?? {}) as Record; const lifetime = (t.lifetime ?? {}) as Record; - const { data: last } = await supabaseAdmin - .from("skill_executions") - .select("created_at") - .eq("package_id", p.id) - .order("created_at", { ascending: false }) - .limit(1); - rows.push({ slug: p.slug, name: p.name, @@ -51,8 +44,7 @@ export const getEvaluationData = createServerFn({ method: "GET" }).handler( ok30d: Math.round(Number(w30.runs ?? 0) * Number(w30.success_rate ?? 0)), successRate30d: w30.success_rate != null ? Number(w30.success_rate) : null, p95Latency: w30.p95_latency_ms != null ? Number(w30.p95_latency_ms) : null, - // Day precision only: an exact timestamp could reveal one user's activity. - lastRunAt: last?.[0]?.created_at ? `${last[0].created_at.slice(0, 10)}T00:00:00Z` : null, + lastRunAt: null, // Individual execution timing is private. trustScore: t.trust_score != null ? Number(t.trust_score) : null, criticalFindings: Number(t.findings_critical ?? 0), battleTested: !!t.battle_tested, diff --git a/src/lib/mcp/tools/skills.ts b/src/lib/mcp/tools/skills.ts index 81cf7cc3..f01b6a0a 100644 --- a/src/lib/mcp/tools/skills.ts +++ b/src/lib/mcp/tools/skills.ts @@ -237,24 +237,30 @@ export const getPackageTool = defineTool({ parameters: z.object({ slug: z.string().describe("Package slug (e.g. cardiology-soul)"), }), - execute: async ({ slug }) => { + execute: async ({ slug }, ctx) => { const { data: pkg, error } = await supabaseAdmin .from("packages") - .select("id,slug,name,type,description,long_description,latest_version,author_handle") + .select( + "id,slug,name,type,description,long_description,latest_version,author_handle,author_id,price_credits", + ) .eq("slug", slug) .eq("is_published", true) .eq("review_status", "approved") .maybeSingle(); if (error) return json({ error: error.message }); if (!pkg) return json({ error: "not_found" }); + const { canReadPackageContent } = await import("@/lib/marketplace/content-access.server"); + const userId = (ctx.auth?.claims as { user_id?: string } | undefined)?.user_id ?? null; + if (!(await canReadPackageContent(pkg, userId))) return json({ error: "purchase_required" }); const { data: ver } = await supabaseAdmin .from("package_versions") .select("version,status,system_prompt,rules,examples,compatibility,notes") .eq("package_id", pkg.id) - .order("created_at", { ascending: false }) + .eq("version", pkg.latest_version) .limit(1) .maybeSingle(); - return json({ package: pkg, version: ver }); + const { author_id: _authorId, ...publicPackage } = pkg; + return json({ package: publicPackage, version: ver }); }, }); diff --git a/src/lib/mcp/tools/university.ts b/src/lib/mcp/tools/university.ts index e50fa89c..a942d6f0 100644 --- a/src/lib/mcp/tools/university.ts +++ b/src/lib/mcp/tools/university.ts @@ -117,8 +117,8 @@ export const diagnoseSubmitTool = defineTool({ }), execute: async (input, ctx) => { const report = await submitExam({ + userId: userIdOf(ctx), diagnosisId: input.diagnosis_id ?? null, - callerId: userIdOf(ctx), domain: input.domain as DomainId | undefined, answers: input.answers, installedSkills: input.installed_skills, diff --git a/src/lib/payments.functions.ts b/src/lib/payments.functions.ts index 97b6f609..c4ad4764 100644 --- a/src/lib/payments.functions.ts +++ b/src/lib/payments.functions.ts @@ -34,18 +34,6 @@ async function resolveOrCreateCustomer( }); if (found.data.length) return found.data[0].id; } - if (options.email) { - const existing = await stripe.customers.list({ email: options.email, limit: 1 }); - if (existing.data.length) { - const customer = existing.data[0]; - if (options.userId && customer.metadata?.userId !== options.userId) { - await stripe.customers.update(customer.id, { - metadata: { ...customer.metadata, userId: options.userId }, - }); - } - return customer.id; - } - } const created = await stripe.customers.create({ ...(options.email && { email: options.email }), ...(options.userId && { metadata: { userId: options.userId } }), diff --git a/src/lib/university/access.ts b/src/lib/university/access.ts deleted file mode 100644 index 99dd555e..00000000 --- a/src/lib/university/access.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Who may score or read a diagnosis. Owned diagnoses belong to their owner; - * anonymous ones (owner null) to whoever holds the unguessable diagnosis id. - */ -export function canAccessDiagnosis(ownerId: string | null, callerId: string | null): boolean { - return ownerId === null || ownerId === callerId; -} diff --git a/src/lib/university/diagnosis-access.ts b/src/lib/university/diagnosis-access.ts new file mode 100644 index 00000000..1bb4e8d6 --- /dev/null +++ b/src/lib/university/diagnosis-access.ts @@ -0,0 +1,23 @@ +import { createHmac, timingSafeEqual } from "node:crypto"; +const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; +export function diagnosisCapability(id: string, secret: string): string { + if (!secret || !UUID.test(id)) throw new Error("Invalid diagnosis capability configuration"); + return `${id}.${createHmac("sha256", secret).update(`anonymous-diagnosis:${id}`).digest("hex")}`; +} +export function diagnosisId(reference: string): string | null { + const id = reference.split(".")[0]; + return UUID.test(id) ? id : null; +} +export function canAccessDiagnosis( + ownerId: string | null, + userId: string | null, + reference: string, + secret: string, +): boolean { + if (ownerId !== null) return ownerId === userId; + const id = diagnosisId(reference); + if (!id || !secret) return false; + const expected = Buffer.from(diagnosisCapability(id, secret)); + const supplied = Buffer.from(reference); + return supplied.length === expected.length && timingSafeEqual(supplied, expected); +} diff --git a/src/lib/university/university.functions.ts b/src/lib/university/university.functions.ts index bb91f64e..13e311e4 100644 --- a/src/lib/university/university.functions.ts +++ b/src/lib/university/university.functions.ts @@ -4,6 +4,8 @@ import type { ErrorProfileEntry, Prescription } from "@/lib/university/types"; * Module scope holds only imports + createServerFn declarations (server-fn * splitting strips runtime siblings). */ +import { getRequest } from "@tanstack/react-start/server"; +import { getVerifiedRequestUserId } from "@/lib/auth/request-user.server"; import { createServerFn } from "@tanstack/react-start"; import { requireSupabaseAuth } from "@/integrations/supabase/auth-middleware"; import { z } from "zod"; @@ -30,6 +32,7 @@ export const startDiagnosis = createServerFn({ method: "POST" }) ) .handler(async ({ data }) => startExam({ + userId: await getVerifiedRequestUserId(getRequest()), domain: data.domain as DomainId, installedSkills: data.installed_skills, agentFp: data.agent_fp ?? null, @@ -40,7 +43,7 @@ export const submitDiagnosis = createServerFn({ method: "POST" }) .inputValidator((d: unknown) => z .object({ - diagnosis_id: z.string().uuid().optional(), + diagnosis_id: z.string().max(140).optional(), domain: DomainEnum.optional(), installed_skills: z.array(z.string()).max(64).default([]), answers: z @@ -59,6 +62,7 @@ export const submitDiagnosis = createServerFn({ method: "POST" }) ) .handler(async ({ data }) => submitExam({ + userId: await getVerifiedRequestUserId(getRequest()), diagnosisId: data.diagnosis_id ?? null, domain: data.domain as DomainId | undefined, answers: data.answers, @@ -70,7 +74,7 @@ export const getCurriculumPlan = createServerFn({ method: "POST" }) .inputValidator((d: unknown) => z .object({ - diagnosis_id: z.string().uuid().optional(), + diagnosis_id: z.string().max(140).optional(), domain: DomainEnum.optional(), failing: z .array( @@ -95,7 +99,10 @@ export const getCurriculumPlan = createServerFn({ method: "POST" }) let installed = data.installed_skills; let domain = data.domain as DomainId | undefined; if (data.diagnosis_id) { - const d = await getDiagnosisForCurriculum(data.diagnosis_id); + const d = await getDiagnosisForCurriculum( + data.diagnosis_id, + await getVerifiedRequestUserId(getRequest()), + ); if (d) { profile = d.error_profile; domain = domain ?? d.domain; diff --git a/src/lib/university/university.server.ts b/src/lib/university/university.server.ts index 717d62fc..68590aa9 100644 --- a/src/lib/university/university.server.ts +++ b/src/lib/university/university.server.ts @@ -1,3 +1,8 @@ +import { + canAccessDiagnosis, + diagnosisCapability, + diagnosisId as parseDiagnosisId, +} from "./diagnosis-access"; import { z } from "zod"; import { ERROR_CLASSES } from "./types"; const ErrorProfileSchema = z.array( @@ -15,12 +20,11 @@ import type { ErrorProfileEntry, Prescription } from "@/lib/university/types"; * * Rows are written with the admin client (the exam runs anonymously too), and * read back only through owner-scoped helpers — anonymous rows (user_id null) - * are reachable only by whoever holds the diagnosis id. + * require a signed capability; knowing a row UUID alone is never authorization. */ import { supabaseAdmin as _supabaseAdmin } from "@/integrations/supabase/client.server"; import { buildReport, sampleExam } from "./diagnose"; import { findCase } from "./cases"; -import { canAccessDiagnosis } from "./access"; import type { CaseAnswer, DiagnosisReport, DomainId } from "./types.ts"; const supabaseAdmin = _supabaseAdmin; @@ -64,7 +68,10 @@ export async function startExam(args: { } return { - diagnosis_id: diagnosisId, + diagnosis_id: + diagnosisId && !args.userId + ? diagnosisCapability(diagnosisId, process.env.SUPABASE_SERVICE_ROLE_KEY ?? "") + : diagnosisId, domain: args.domain, case_count: cases.length, tasks: cases.map((c) => ({ @@ -77,7 +84,10 @@ export async function startExam(args: { }; } -export async function loadExam(diagnosisId: string): Promise<{ +export async function loadExam( + diagnosisId: string, + userId: string | null = null, +): Promise<{ domain: DomainId; case_ids: string[]; installed_skills: string[]; @@ -86,9 +96,18 @@ export async function loadExam(diagnosisId: string): Promise<{ const { data } = await supabaseAdmin .from("agent_diagnoses") .select("domain,case_ids,installed_skills,user_id") - .eq("id", diagnosisId) + .eq("id", parseDiagnosisId(diagnosisId) ?? "00000000-0000-0000-0000-000000000000") .maybeSingle(); - if (!data) return null; + if ( + !data || + !canAccessDiagnosis( + data.user_id, + userId, + diagnosisId, + process.env.SUPABASE_SERVICE_ROLE_KEY ?? "", + ) + ) + return null; return { domain: data.domain as DomainId, case_ids: (data.case_ids ?? []) as string[], @@ -99,8 +118,7 @@ export async function loadExam(diagnosisId: string): Promise<{ export async function submitExam(args: { diagnosisId?: string | null; - /** Verified caller, or null for anonymous callers. */ - callerId?: string | null; + userId?: string | null; domain?: DomainId; answers: CaseAnswer[]; installedSkills?: string[]; @@ -109,16 +127,10 @@ export async function submitExam(args: { let caseIds: string[] | null = null; let installed = args.installedSkills ?? []; - let persist = false; if (args.diagnosisId) { - const exam = await loadExam(args.diagnosisId); + const exam = await loadExam(args.diagnosisId, args.userId ?? null); + if (!exam) throw new Response("Diagnosis not found", { status: 404 }); if (exam) { - // An owned exam may only be scored by its owner; anonymous exams are - // scored once by whoever holds the id (see the one-shot update below). - if (!canAccessDiagnosis(exam.user_id, args.callerId ?? null)) { - throw new Error("diagnosis_forbidden"); - } - persist = true; domain = exam.domain; caseIds = exam.case_ids; if (!args.installedSkills?.length) installed = exam.installed_skills; @@ -139,11 +151,9 @@ export async function submitExam(args: { installed_skills: installed, }); - if (args.diagnosisId && persist) { - const diagnosisId = args.diagnosisId; + if (args.diagnosisId) { + const diagnosisId = parseDiagnosisId(args.diagnosisId)!; try { - // One-shot: only an exam that is still open can be scored, so a scored - // result can never be overwritten by a later submission. const { data: updated } = await supabaseAdmin .from("agent_diagnoses") .update({ @@ -204,7 +214,7 @@ export async function listDiagnoses(userId: string, limit = 20): Promise @@ -16,11 +18,11 @@ export const Route = createFileRoute("/api/public/packages/$slug")({ server: { handlers: { OPTIONS: async () => new Response(null, { status: 204, headers: CORS }), - GET: async ({ params }) => { + GET: async ({ params, request }) => { const { data: pkg, error } = await supabaseAdmin .from("packages") .select( - "id,slug,name,type,description,long_description,latest_version,author_handle,license,install_count,is_published,review_status", + "id,slug,name,type,description,long_description,latest_version,author_handle,license,install_count,is_published,review_status,price_credits,author_id", ) .eq("slug", params.slug) .eq("is_published", true) @@ -39,6 +41,17 @@ export const Route = createFileRoute("/api/public/packages/$slug")({ headers: { "Content-Type": "application/json", ...CORS }, }); } + if ( + !(await canReadPackageContent( + pkg, + pkg.price_credits > 0 ? await getVerifiedRequestUserId(request) : null, + )) + ) { + return new Response("Purchase required", { + status: 403, + headers: { "Cache-Control": "no-store" }, + }); + } const { data: ver } = await supabaseAdmin .from("package_versions") .select("id,version,status,system_prompt,rules,examples,compatibility,notes") @@ -47,7 +60,7 @@ export const Route = createFileRoute("/api/public/packages/$slug")({ .maybeSingle(); const scopedCompatibility = ver ? await loadPublicEvaluationCompatibility(pkg.id, ver) : []; - const { id: _omit, is_published: _p, review_status: _r, ...rest } = pkg; + const { id: _omit, is_published: _p, review_status: _r, author_id: _a, ...rest } = pkg; return new Response( JSON.stringify({ ...rest, @@ -61,7 +74,7 @@ export const Route = createFileRoute("/api/public/packages/$slug")({ status: 200, headers: { "Content-Type": "application/json", - "Cache-Control": "public, max-age=60", + "Cache-Control": pkg.price_credits > 0 ? "private, no-store" : "public, max-age=60", ...CORS, }, }, diff --git a/src/routes/api/skills.$slug.export.ts b/src/routes/api/skills.$slug.export.ts index 34e6b49e..9fab8496 100644 --- a/src/routes/api/skills.$slug.export.ts +++ b/src/routes/api/skills.$slug.export.ts @@ -1,3 +1,5 @@ +import { canReadPackageContent } from "@/lib/marketplace/content-access.server"; +import { getVerifiedRequestUserId } from "@/lib/auth/request-user.server"; /** * Export any published package as an Anthropic-compatible SKILL.md zip bundle. * @@ -21,12 +23,12 @@ import { export const Route = createFileRoute("/api/skills/$slug/export")({ server: { handlers: { - GET: async ({ params }) => { + GET: async ({ params, request }) => { const slug = params.slug; const { data: pkg, error } = await supabaseAdmin .from("packages") .select( - "id,slug,name,type,description,long_description,license,author_handle,latest_version,is_published,review_status", + "id,slug,name,type,description,long_description,license,author_handle,latest_version,is_published,review_status,price_credits,author_id", ) .eq("slug", slug) .maybeSingle(); @@ -35,11 +37,22 @@ export const Route = createFileRoute("/api/skills/$slug/export")({ return new Response("not published", { status: 403 }); } + if ( + !(await canReadPackageContent( + pkg, + pkg.price_credits > 0 ? await getVerifiedRequestUserId(request) : null, + )) + ) { + return new Response("Purchase required", { + status: 403, + headers: { "Cache-Control": "no-store" }, + }); + } const { data: ver } = await supabaseAdmin .from("package_versions") .select("version,system_prompt,rules,examples,compatibility") .eq("package_id", pkg.id) - .order("created_at", { ascending: false }) + .eq("version", pkg.latest_version) .limit(1) .maybeSingle(); if (!ver) return new Response("no version", { status: 404 }); @@ -98,7 +111,7 @@ export const Route = createFileRoute("/api/skills/$slug/export")({ headers: { "Content-Type": "application/zip", "Content-Disposition": `attachment; filename="${pkg.slug}-skill.zip"`, - "Cache-Control": "public, max-age=300", + "Cache-Control": pkg.price_credits > 0 ? "private, no-store" : "public, max-age=300", "X-SAK-Signing-Public-Key": SIGNING_PUBLIC_KEY_PATH, "Access-Control-Expose-Headers": EXPOSED_SIGNATURE_HEADERS, ...signatureHeaders(sig), diff --git a/src/routes/api/skills.$slug.export[.]md.ts b/src/routes/api/skills.$slug.export[.]md.ts index 6995c72a..f63b7f35 100644 --- a/src/routes/api/skills.$slug.export[.]md.ts +++ b/src/routes/api/skills.$slug.export[.]md.ts @@ -1,3 +1,5 @@ +import { canReadPackageContent } from "@/lib/marketplace/content-access.server"; +import { getVerifiedRequestUserId } from "@/lib/auth/request-user.server"; import { createFileRoute } from "@tanstack/react-router"; import { supabaseAdmin as _supabaseAdmin } from "@/integrations/supabase/client.server"; const supabaseAdmin = _supabaseAdmin; @@ -6,7 +8,7 @@ import { buildSkillMd } from "@/lib/skills/anthropic-spec"; const CORS = { "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, OPTIONS", - "Access-Control-Allow-Headers": "Content-Type, Accept", + "Access-Control-Allow-Headers": "Content-Type, Accept, Authorization", }; // GET /api/skills//export.md @@ -17,12 +19,12 @@ export const Route = createFileRoute("/api/skills/$slug/export.md")({ server: { handlers: { OPTIONS: async () => new Response(null, { status: 204, headers: CORS }), - GET: async ({ params }) => { + GET: async ({ params, request }) => { const slug = params.slug; const { data: pkg, error } = await supabaseAdmin .from("packages") .select( - "id,slug,name,type,description,long_description,license,author_handle,latest_version,is_published,review_status", + "id,slug,name,type,description,long_description,license,author_handle,latest_version,is_published,review_status,price_credits,author_id", ) .eq("slug", slug) .eq("is_published", true) @@ -32,11 +34,22 @@ export const Route = createFileRoute("/api/skills/$slug/export.md")({ return new Response("not found", { status: 404, headers: CORS }); } + if ( + !(await canReadPackageContent( + pkg, + pkg.price_credits > 0 ? await getVerifiedRequestUserId(request) : null, + )) + ) { + return new Response("Purchase required", { + status: 403, + headers: { "Cache-Control": "no-store" }, + }); + } const { data: ver } = await supabaseAdmin .from("package_versions") .select("version,system_prompt,rules,examples,compatibility") .eq("package_id", pkg.id) - .order("created_at", { ascending: false }) + .eq("version", pkg.latest_version) .limit(1) .maybeSingle(); if (!ver) return new Response("no version", { status: 404, headers: CORS }); @@ -61,7 +74,7 @@ export const Route = createFileRoute("/api/skills/$slug/export.md")({ status: 200, headers: { "Content-Type": "text/markdown; charset=utf-8", - "Cache-Control": "public, max-age=300", + "Cache-Control": pkg.price_credits > 0 ? "private, no-store" : "public, max-age=300", ...CORS, }, }); diff --git a/src/routes/forge.report.$slug.tsx b/src/routes/forge.report.$slug.tsx index 3416cf1a..d63ae23f 100644 --- a/src/routes/forge.report.$slug.tsx +++ b/src/routes/forge.report.$slug.tsx @@ -21,7 +21,7 @@ const getForgeReport = createServerFn({ method: "GET" }) const { data: row } = await supabaseAdmin .from("packages") .select( - "id,slug,name,type,description,long_description,latest_version,author_handle,created_at,author_id,is_published,review_status", + "id,slug,name,type,description,long_description,latest_version,author_handle,created_at,author_id,is_published,review_status,price_credits", ) .eq("slug", data.slug) .maybeSingle(); @@ -29,7 +29,7 @@ const getForgeReport = createServerFn({ method: "GET" }) // Published + approved reports are public; anything else only for its // author or an admin. Unauthorised callers get the same "Not found". - if (!(row.is_published && row.review_status === "approved")) { + if (!(row.is_published && row.review_status === "approved" && row.price_credits === 0)) { const { getOptionalUserId, isAdminUser } = await import("@/lib/auth/optional-user.server"); const callerId = await getOptionalUserId(); const allowed = diff --git a/src/routes/lovable/email/transactional/send.ts b/src/routes/lovable/email/transactional/send.ts index c1f26ef6..92ae9fba 100644 --- a/src/routes/lovable/email/transactional/send.ts +++ b/src/routes/lovable/email/transactional/send.ts @@ -59,6 +59,13 @@ export const Route = createFileRoute("/lovable/email/transactional/send")({ return Response.json({ error: "Unauthorized" }, { status: 401 }); } + const { data: isAdmin, error: roleError } = await supabase.rpc("has_role", { + _user_id: user.id, + _role: "admin", + }); + if (roleError || isAdmin !== true) + return Response.json({ error: "Forbidden" }, { status: 403 }); + // Parse request body let templateName: string; let recipientEmail: string; diff --git a/supabase/migrations/20261123220000_advanced_security_findings.sql b/supabase/migrations/20261123220000_advanced_security_findings.sql new file mode 100644 index 00000000..ae7e45ed --- /dev/null +++ b/supabase/migrations/20261123220000_advanced_security_findings.sql @@ -0,0 +1,368 @@ +-- Follow-up to drizzle/0001_harden_selected_security_findings.sql, already applied by Lovable. +-- Self-reported telemetry must not manufacture verified trust. +ALTER TABLE public.skill_executions ADD COLUMN IF NOT EXISTS is_verified boolean NOT NULL DEFAULT false; +COMMENT ON COLUMN public.skill_executions.is_verified IS 'Only a trusted server evaluator may attest a run. Public/MCP telemetry is always unverified.'; +CREATE OR REPLACE FUNCTION public.get_skill_trust(_slug text) + RETURNS jsonb + LANGUAGE plpgsql + STABLE SECURITY DEFINER + SET search_path TO 'public' +AS $function$ +DECLARE + pkg RECORD; + total_life int := 0; + ok_life int := 0; + total_30 int := 0; + ok_30 int := 0; + p50_30 numeric := NULL; + p95_30 numeric := NULL; + total_7 int := 0; + ok_7 int := 0; + models_json jsonb := '[]'::jsonb; + findings_public int := 0; + findings_critical int := 0; + trust numeric := NULL; + battle boolean := false; +BEGIN + SELECT id, slug, latest_version INTO pkg FROM public.packages WHERE slug = _slug AND is_published AND review_status='approved' LIMIT 1; + IF pkg.id IS NULL THEN RETURN NULL; END IF; + + SELECT count(*) FILTER (WHERE true), count(*) FILTER (WHERE success) + INTO total_life, ok_life + FROM public.skill_executions WHERE package_slug = _slug AND is_verified; + + SELECT count(*), count(*) FILTER (WHERE success), + percentile_cont(0.5) WITHIN GROUP (ORDER BY latency_ms), + percentile_cont(0.95) WITHIN GROUP (ORDER BY latency_ms) + INTO total_30, ok_30, p50_30, p95_30 + FROM public.skill_executions + WHERE package_slug = _slug AND is_verified AND created_at > now() - interval '30 days'; + + SELECT count(*), count(*) FILTER (WHERE success) + INTO total_7, ok_7 + FROM public.skill_executions + WHERE package_slug = _slug AND is_verified AND created_at > now() - interval '7 days'; + + SELECT coalesce(jsonb_agg(jsonb_build_object( + 'model', m.model, 'runs', m.runs, 'success_rate', m.sr + ) ORDER BY m.runs DESC), '[]'::jsonb) INTO models_json + FROM ( + SELECT model AS model, count(*) AS runs, + (count(*) FILTER (WHERE success))::numeric / greatest(count(*),1) AS sr + FROM public.skill_executions + WHERE package_slug = _slug AND is_verified AND created_at > now() - interval '30 days' + GROUP BY model + ) m; + + SELECT count(*), count(*) FILTER (WHERE severity = 'critical') + INTO findings_public, findings_critical + FROM public.skill_robustness_findings + WHERE package_slug = _slug AND status = 'public'; + + trust := round( + ( + (case when total_30 > 0 then (ok_30::numeric/total_30) else 0.5 end) * 100 + * least(1.0, ln(greatest(total_30,1)+1) / ln(101)) + * (1.0 - least(1.0, findings_critical::numeric * 0.25)) + )::numeric, + 1 + ); + battle := total_30 >= 50 AND (ok_30::numeric/greatest(total_30,1)) >= 0.9 AND findings_critical = 0; + + RETURN jsonb_build_object( + 'slug', _slug, + 'trust_score', CASE WHEN total_30 > 0 THEN trust ELSE NULL END, + 'evidence', 'verified_server_evaluations', + 'battle_tested', battle, + 'lifetime', jsonb_build_object('runs', total_life, 'success_rate', case when total_life>0 then round((ok_life::numeric/total_life)::numeric, 3) else null end), + 'window_30d', jsonb_build_object('runs', total_30, 'success_rate', case when total_30>0 then round((ok_30::numeric/total_30)::numeric, 3) else null end, 'p50_latency_ms', p50_30, 'p95_latency_ms', p95_30), + 'window_7d', jsonb_build_object('runs', total_7, 'success_rate', case when total_7>0 then round((ok_7::numeric/total_7)::numeric, 3) else null end), + 'models', models_json, + 'findings_public', findings_public, + 'findings_critical', findings_critical + ); +END; +$function$ +; +CREATE OR REPLACE FUNCTION public.recompute_trust_scores_v2() + RETURNS integer + LANGUAGE plpgsql + SECURITY DEFINER + SET search_path TO 'public' +AS $function$ +declare + affected int := 0; +begin + with adv as ( + select package_id, + sum(passed)::numeric as adv_succ, + sum(total)::numeric as adv_total, + avg(severity_weighted_score)::numeric as adv_weighted, + max(total)::numeric as case_count, + extract(epoch from (now() - max(created_at))) / 86400 as last_verified_days + from public.adversarial_runs + group by package_id + ), + perf as ( + select package_id, + count(*) filter (where success)::numeric as rw_succ, + count(*)::numeric as rw_total + from public.skill_executions + where is_verified AND created_at >= now() - interval '30 days' + and package_id is not null + group by package_id + ), + releases as ( + select package_id, count(*)::int as signed_releases + from public.package_releases group by package_id + ), + pkg as ( + select p.id, + coalesce(adv.adv_succ, 0) as adv_succ, + coalesce(adv.adv_total, 0) as adv_total, + coalesce(adv.adv_weighted, 0) as adv_weighted, + coalesce(adv.case_count, 0) as case_count, + adv.last_verified_days as last_verified_days, + coalesce(perf.rw_succ, 0) as rw_succ, + coalesce(perf.rw_total, 0) as rw_total, + coalesce(releases.signed_releases, 0) as signed_releases, + extract(epoch from (now() - p.created_at)) / 86400 as age_days + from public.packages p + left join adv on adv.package_id = p.id + left join perf on perf.package_id = p.id + left join releases on releases.package_id = p.id + ), + dims as ( + select id, adv_succ, adv_total, adv_weighted, case_count, last_verified_days, + rw_succ, rw_total, signed_releases, age_days, + ( 0.6 * public.wilson_lower_bound(adv_succ, adv_total) + + 0.4 * least(1, greatest(0, adv_weighted)) * least(1, adv_total / 8.0) + ) as safety, + public.wilson_lower_bound(rw_succ, rw_total) as competence, + ( 0.7 * (case + when last_verified_days is null then 0 + when last_verified_days <= 30 then 1 + when last_verified_days >= 180 then 0 + else 1 - (last_verified_days - 30) / 150.0 + end) + + 0.3 * least(1, signed_releases / 3.0) + ) as freshness, + ( 0.4 * public.trust_saturate(adv_total, 12) + + 0.25 * public.trust_saturate(case_count, 8) + + 0.25 * public.trust_saturate(rw_total, 100) + + 0.10 * least(1, signed_releases / 3.0) + ) as confidence + from pkg + ), + scored as ( + select id, adv_succ, adv_total, adv_weighted, rw_succ, rw_total, + signed_releases, age_days, safety, competence, freshness, confidence, + least(1, greatest(0, + 0.10 * 1 + + 0.45 * safety + + 0.30 * competence + + 0.15 * freshness + )) as raw_quality, + (adv_total >= 8 and case_count >= 5) as verified + from dims + ) + insert into public.package_trust_scores + (package_id, score, schema_valid, adversarial_pass_rate, + adversarial_weighted_score, real_world_success_rate, + signed_releases, age_days, trust_version, confidence, verified, + dim_safety, dim_competence, dim_freshness, dim_coverage, components, computed_at) + select id, + round((raw_quality * confidence)::numeric, 4), + true, + round(public.wilson_lower_bound(adv_succ, adv_total)::numeric, 4), + round(least(1, greatest(0, adv_weighted))::numeric, 4), + round(public.wilson_lower_bound(rw_succ, rw_total)::numeric, 4), + signed_releases, age_days::int, + '2.0.0', + round(confidence::numeric, 4), + verified, + round(safety::numeric, 4), + round(competence::numeric, 4), + round(freshness::numeric, 4), + round(confidence::numeric, 4), + jsonb_build_object( + 'version', '2.0.0', + 'safety', round(safety::numeric, 4), + 'competence', round(competence::numeric, 4), + 'freshness', round(freshness::numeric, 4), + 'confidence', round(confidence::numeric, 4), + 'verified', verified, + 'adv_runs_cases', adv_total, + 'real_world_runs', rw_total, + 'signed_releases', signed_releases + ), + now() + from scored + on conflict (package_id) do update set + score = excluded.score, + adversarial_pass_rate = excluded.adversarial_pass_rate, + adversarial_weighted_score = excluded.adversarial_weighted_score, + real_world_success_rate = excluded.real_world_success_rate, + signed_releases = excluded.signed_releases, + age_days = excluded.age_days, + trust_version = excluded.trust_version, + confidence = excluded.confidence, + verified = excluded.verified, + dim_safety = excluded.dim_safety, + dim_competence = excluded.dim_competence, + dim_freshness = excluded.dim_freshness, + dim_coverage = excluded.dim_coverage, + components = excluded.components, + computed_at = excluded.computed_at; + + get diagnostics affected = row_count; + return affected; +end; +$function$ +; +REVOKE EXECUTE ON FUNCTION public.recompute_trust_scores_v2() FROM PUBLIC, anon, authenticated; +GRANT EXECUTE ON FUNCTION public.recompute_trust_scores_v2() TO service_role; +CREATE OR REPLACE FUNCTION public.snapshot_package_weekly_metrics() + RETURNS integer + LANGUAGE plpgsql + SECURITY DEFINER + SET search_path TO 'public' +AS $function$ +declare + affected int := 0; + wk date := date_trunc('week', now() - interval '7 days')::date; +begin + insert into public.package_weekly_metrics + (package_id, package_slug, week_start, track, runs, successes, success_rate, + success_rate_wilson_lb, task_completed_rate, p95_latency_ms, avg_tokens, + adversarial_pass_rate, adversarial_weighted, trust_score) + select + p.id, p.slug, wk, 'current', + coalesce(x.runs, 0), coalesce(x.successes, 0), + x.success_rate, + public.wilson_lower_bound(coalesce(x.successes,0)::bigint, coalesce(x.runs,0)::bigint), + x.task_completed_rate, x.p95, x.avg_tokens, + adv.pass_rate, adv.weighted, ts.score + from public.packages p + left join lateral ( + select count(*) as runs, + count(*) filter (where e.success) as successes, + (count(*) filter (where e.success))::numeric / nullif(count(*),0) as success_rate, + (count(*) filter (where e.task_completed))::numeric + / nullif(count(*) filter (where e.task_completed is not null),0) as task_completed_rate, + percentile_cont(0.95) within group (order by e.latency_ms) as p95, + avg(coalesce(e.tokens_in,0) + coalesce(e.tokens_out,0)) as avg_tokens + from public.skill_executions e + where e.is_verified AND e.package_id = p.id + and e.created_at >= wk and e.created_at < wk + interval '7 days' + and (e.arm is null or e.arm = 'treatment') + ) x on true + left join lateral ( + select avg(r.pass_rate)::numeric(5,4) as pass_rate, + avg(r.severity_weighted_score)::numeric(5,4) as weighted + from public.adversarial_runs r + where r.package_id = p.id and r.subject_arm = 'certified' + and r.created_at >= wk and r.created_at < wk + interval '7 days' + ) adv on true + left join public.package_trust_scores ts on ts.package_id = p.id + where p.is_published = true + on conflict (package_id, week_start, track) do update set + runs = excluded.runs, + successes = excluded.successes, + success_rate = excluded.success_rate, + success_rate_wilson_lb = excluded.success_rate_wilson_lb, + task_completed_rate = excluded.task_completed_rate, + p95_latency_ms = excluded.p95_latency_ms, + avg_tokens = excluded.avg_tokens, + adversarial_pass_rate = excluded.adversarial_pass_rate, + adversarial_weighted = excluded.adversarial_weighted, + trust_score = excluded.trust_score; + get diagnostics affected = row_count; + + insert into public.package_weekly_metrics + (package_id, package_slug, week_start, track, + adversarial_pass_rate, adversarial_weighted) + select r.package_id, p.slug, wk, 'frozen_v1', + avg(r.pass_rate)::numeric(5,4), avg(r.severity_weighted_score)::numeric(5,4) + from public.adversarial_runs r + join public.packages p on p.id = r.package_id + where r.subject_arm = 'frozen_v1' + and r.created_at >= wk and r.created_at < wk + interval '7 days' + group by r.package_id, p.slug + on conflict (package_id, week_start, track) do update set + adversarial_pass_rate = excluded.adversarial_pass_rate, + adversarial_weighted = excluded.adversarial_weighted; + + return affected; +end; +$function$ +; +REVOKE EXECUTE ON FUNCTION public.snapshot_package_weekly_metrics() FROM PUBLIC, anon, authenticated; +GRANT EXECUTE ON FUNCTION public.snapshot_package_weekly_metrics() TO service_role; +ALTER FUNCTION public.get_credit_balance(uuid) SECURITY INVOKER; +ALTER FUNCTION public.has_active_subscription(uuid) SECURITY INVOKER; +ALTER FUNCTION public.has_active_subscription(uuid,text) SECURITY INVOKER; +DROP POLICY IF EXISTS "pack_cust insert own purchased" ON public.pack_customizations; +CREATE POLICY "pack_cust insert own purchased" ON public.pack_customizations FOR INSERT TO authenticated +WITH CHECK(user_id=auth.uid() AND status='queued' AND items='[]'::jsonb AND EXISTS( + SELECT 1 FROM public.pack_purchases p WHERE p.pack_id=pack_customizations.pack_id AND p.buyer_id=auth.uid())); +CREATE OR REPLACE FUNCTION public.check_security_boundaries() + RETURNS TABLE(check_name text, passed boolean) + LANGUAGE sql + STABLE SECURITY DEFINER + SET search_path TO '' +AS $function$ +WITH server_functions(signature) AS (VALUES ('public.crm_active_hours(uuid)'), +('public.crm_activity_hours(uuid,integer)'), +('public.crm_customers(integer,integer,uuid)'), +('public.crm_effectiveness(integer)'), +('public.crm_effectiveness_by_segment(integer)'), +('public.crm_segment_send_hour_stats(integer)'), +('public.crm_send_hour_stats(integer)'), +('public.crm_track_click(text)'), +('public.crm_track_open(text)'), +('public.delete_email(text,bigint)'), +('public.enqueue_email(text,jsonb)'), +('public.get_pack_with_items(text)'), +('public.get_package_ratings(uuid)'), +('public.list_package_reviews(uuid,integer)'), +('public.mcp_idempotency_get(uuid,text,text)'), +('public.mcp_idempotency_put(uuid,text,text,jsonb)'), +('public.mcp_oauth_exchange_code(text,text,text,text,text,integer,integer)'), +('public.mcp_oauth_get_client(text)'), +('public.mcp_oauth_refresh_token(text,text,text,text,integer,integer)'), +('public.mcp_oauth_register_client(text,text[],text,text,text,text,text)'), +('public.mcp_oauth_revoke_token(text)'), +('public.mcp_oauth_verify_access(text)'), +('public.move_to_dlq(text,text,bigint,jsonb)'), +('public.read_email_batch(text,integer,integer)'),('public.compute_skill_drift(uuid,integer)'),('public.mcp_check_and_log_call(uuid,text,text,boolean)'),('public.report_skill_execution(text,boolean,text,text,integer,integer,integer,text,text,text,text,boolean,boolean,smallint,integer,integer,text)'),('public.recompute_trust_scores_v2()'),('public.snapshot_package_weekly_metrics()')) +SELECT 'server_rpc_acl', count(*) = 29 AND bool_and( + NOT pg_catalog.has_function_privilege('anon', signature, 'EXECUTE') AND + NOT pg_catalog.has_function_privilege('authenticated', signature, 'EXECUTE') AND + pg_catalog.has_function_privilege('service_role', signature, 'EXECUTE')) FROM server_functions +UNION ALL +SELECT 'email_search_path', count(*) = 4 AND bool_and(p.proconfig @> ARRAY['search_path=""']) +FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid=p.pronamespace +WHERE n.nspname='public' AND p.proname IN ('enqueue_email','read_email_batch','delete_email','move_to_dlq') +UNION ALL +SELECT 'rls_invoker_reads', count(*) = 3 AND bool_and(NOT p.prosecdef) +FROM pg_catalog.pg_proc p WHERE p.oid IN ('public.agent_onboarding_funnel(integer)'::pg_catalog.regprocedure,'public.search_packages(text,text,integer,integer)'::pg_catalog.regprocedure,'public.get_review_eligibility(uuid)'::pg_catalog.regprocedure) +UNION ALL +SELECT 'authenticated_transactions', count(*) = 7 AND bool_and( + NOT pg_catalog.has_function_privilege('anon', signature, 'EXECUTE') AND + pg_catalog.has_function_privilege('authenticated', signature, 'EXECUTE')) +FROM (VALUES ('public.claim_referral(text,text,text)'),('public.purchase_pack(uuid)'),('public.purchase_package(uuid)'),('public.team_action(text,uuid,jsonb)'),('public.mcp_oauth_issue_code(text,text,text,text,text,text,integer)'),('public.mcp_oauth_list_user_connections()'),('public.mcp_oauth_revoke_client_for_user(text)')) f(signature) +UNION ALL +SELECT 'plans_explicit_public_rows', count(*) = 1 AND bool_and(qual <> 'true' AND qual LIKE '%slug%') +FROM pg_catalog.pg_policies WHERE schemaname='public' AND tablename='plans' AND policyname='plans public read' +UNION ALL SELECT 'account_reads_invoker', count(*)=3 AND bool_and(NOT p.prosecdef) + FROM pg_catalog.pg_proc p WHERE p.oid IN ('public.get_credit_balance(uuid)'::pg_catalog.regprocedure,'public.has_active_subscription(uuid)'::pg_catalog.regprocedure,'public.has_active_subscription(uuid,text)'::pg_catalog.regprocedure) +UNION ALL SELECT 'verified_telemetry_only', count(*)=3 AND bool_and(pg_catalog.pg_get_functiondef(p.oid) LIKE '%is_verified%') + FROM pg_catalog.pg_proc p WHERE p.oid IN ('public.get_skill_trust(text)'::pg_catalog.regprocedure,'public.recompute_trust_scores_v2()'::pg_catalog.regprocedure,'public.snapshot_package_weekly_metrics()'::pg_catalog.regprocedure) +UNION ALL SELECT 'customization_purchase_required', count(*)=1 AND bool_and(with_check LIKE '%pack_purchases%' AND with_check LIKE '%queued%') + FROM pg_catalog.pg_policies WHERE schemaname='public' AND tablename='pack_customizations' AND cmd='INSERT'; +$function$ +; +-- Refresh cached scores after excluding unverified reports. +SELECT public.recompute_trust_scores_v2(); + diff --git a/tests/diagnosis-persistence.test.ts b/tests/diagnosis-persistence.test.ts new file mode 100644 index 00000000..d5de7ceb --- /dev/null +++ b/tests/diagnosis-persistence.test.ts @@ -0,0 +1,104 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { build } from "esbuild"; +import { mkdtemp, writeFile, rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { pathToFileURL } from "node:url"; + +test("anonymous exam round trip uses capability externally and UUID in database writes", async () => { + const dir = await mkdtemp(join(tmpdir(), "diagnosis-probe-")); + const secret = process.env.SUPABASE_SERVICE_ROLE_KEY; + process.env.SUPABASE_SERVICE_ROLE_KEY = "fixture-key"; + const fixtureId = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; + const writes: Array<{ + table: string; + value: Record | Array>; + }> = []; + let row: Record; + const db = { + from(table: string) { + let data: unknown; + return { + insert(value: Record | Array>) { + writes.push({ table, value }); + if (table === "agent_diagnoses") { + row = { ...value, id: fixtureId }; + data = { id: fixtureId }; + } + return this; + }, + update(value: Record | Array>) { + writes.push({ table, value }); + data = [{ id: fixtureId }]; + return this; + }, + select() { + return this; + }, + eq() { + return this; + }, + single: async () => ({ data }), + maybeSingle: async () => ({ data: row }), + then(resolve: (result: { data: unknown }) => unknown) { + return Promise.resolve({ data }).then(resolve); + }, + }; + }, + }; + (globalThis as unknown as { __diagnosisDb?: unknown }).__diagnosisDb = db; + try { + const result = await build({ + entryPoints: ["src/lib/university/university.server.ts"], + bundle: true, + platform: "node", + format: "esm", + write: false, + plugins: [ + { + name: "test-db", + setup(b) { + b.onResolve({ filter: /integrations\/supabase\/client.server/ }, () => ({ + path: "db", + namespace: "fixture", + })); + b.onLoad({ filter: /.*/, namespace: "fixture" }, () => ({ + contents: "export const supabaseAdmin=globalThis.__diagnosisDb;", + loader: "js", + })); + }, + }, + ], + }); + const file = join(dir, "exam.mjs"); + await writeFile(file, result.outputFiles[0].text); + const api = await import(pathToFileURL(file).href); + const started = await api.startExam({ domain: "gtm", limit: 1 }); + assert.match(started.diagnosis_id, /^[\da-f-]+\.[\da-f]{64}$/); + const report = await api.submitExam({ + diagnosisId: started.diagnosis_id, + answers: [{ case_id: started.tasks[0].case_id, answer: "test" }], + }); + assert.equal(report.diagnosis_id, started.diagnosis_id); + const items = writes.find((w) => w.table === "agent_diagnosis_items")!.value as Array< + Record + >; + assert.ok(items.length > 0); + assert.ok(items.every((i) => i.diagnosis_id === fixtureId)); + await assert.rejects( + () => api.submitExam({ diagnosisId: fixtureId, answers: [] }), + (e) => (e as Response).status === 404, + ); + row.user_id = "alice"; + await assert.rejects( + () => api.submitExam({ diagnosisId: fixtureId, userId: "bob", answers: [] }), + (e) => (e as Response).status === 404, + ); + } finally { + delete (globalThis as unknown as { __diagnosisDb?: unknown }).__diagnosisDb; + if (secret === undefined) delete process.env.SUPABASE_SERVICE_ROLE_KEY; + else process.env.SUPABASE_SERVICE_ROLE_KEY = secret; + await rm(dir, { recursive: true, force: true }); + } +}); diff --git a/tests/pricing-copy.test.ts b/tests/pricing-copy.test.ts index 983ea8cb..9e7acc8d 100644 --- a/tests/pricing-copy.test.ts +++ b/tests/pricing-copy.test.ts @@ -60,7 +60,7 @@ test("shouldEnableAdjustableQuantity defaults for Agent Pass lookup keys", () => true, ); assert.equal(shouldEnableAdjustableQuantity({ priceId: "sak_pro_monthly" }), false); - assert.equal(shouldEnableAdjustableQuantity({ priceId: "sak_pro_monthly", quantity: 2 }), true); + assert.equal(shouldEnableAdjustableQuantity({ priceId: "sak_pro_monthly", quantity: 2 }), false); assert.equal( shouldEnableAdjustableQuantity({ priceId: "sak_pro_monthly", diff --git a/tests/security-findings.test.ts b/tests/security-findings.test.ts new file mode 100644 index 00000000..6c0a2514 --- /dev/null +++ b/tests/security-findings.test.ts @@ -0,0 +1,80 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { authenticateCronRequest } from "../src/integrations/supabase/cron-auth.ts"; +import { + resolveCheckoutQuantity, + shouldEnableAdjustableQuantity, + validateReturnUrl, +} from "../src/lib/checkout-quantity.ts"; +import { canAccessDiagnosis, diagnosisCapability } from "../src/lib/university/diagnosis-access.ts"; + +test("privileged jobs reject public keys and query credentials, accept managed current/previous secrets", async () => { + const previous = process.env.LOVABLE_CRON_SECRET; + const old = process.env.LOVABLE_CRON_SECRET_PREVIOUS; + try { + process.env.LOVABLE_CRON_SECRET = "test-server-secret"; + process.env.LOVABLE_CRON_SECRET_PREVIOUS = "test-previous-secret"; + for (const value of [ + "", + "Bearer public-key", + "Bearer user-jwt", + "Bearer test-server-secret,extra", + ]) { + const r = await authenticateCronRequest( + new Request("https://example.test/job?apikey=test-server-secret", { + headers: { authorization: value }, + }), + ); + assert.equal(r?.status, 401); + } + for (const token of ["test-server-secret", "test-previous-secret"]) { + assert.equal( + await authenticateCronRequest( + new Request("https://example.test/job", { + headers: { authorization: `Bearer ${token}` }, + }), + ), + null, + ); + } + } finally { + if (previous === undefined) delete process.env.LOVABLE_CRON_SECRET; + else process.env.LOVABLE_CRON_SECRET = previous; + if (old === undefined) delete process.env.LOVABLE_CRON_SECRET_PREVIOUS; + else process.env.LOVABLE_CRON_SECRET_PREVIOUS = old; + } +}); + +test("owned diagnoses require owner; anonymous UUIDs alone are insufficient", () => { + const id = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"; + const cap = diagnosisCapability(id, "test-secret"); + assert.equal(canAccessDiagnosis("alice", "bob", id, "test-secret"), false); + assert.equal(canAccessDiagnosis("alice", null, cap, "test-secret"), false); + assert.equal(canAccessDiagnosis("alice", "alice", id, "test-secret"), true); + assert.equal(canAccessDiagnosis(null, null, id, "test-secret"), false); + assert.equal(canAccessDiagnosis(null, null, cap, "test-secret"), true); + assert.equal( + canAccessDiagnosis(null, null, cap.replace("aaaaaaaa", "bbbbbbbb"), "test-secret"), + false, + ); + assert.equal(canAccessDiagnosis(null, null, cap, "other-secret"), false); +}); + +test("only the exact Agent Pass product accepts adjustable seats", () => { + for (const priceId of ["sak_pro_monthly", "agent_pass_pro_monthly", "sak_agent_pass_fake"]) { + assert.equal(resolveCheckoutQuantity(priceId, 50), 1); + assert.equal(shouldEnableAdjustableQuantity({ priceId, adjustableQuantity: true }), false); + } + assert.equal(resolveCheckoutQuantity("sak_agent_pass_monthly", 100), 100); +}); + +test("checkout rejects attacker preview lookalikes, userinfo and arbitrary ports", () => { + for (const url of [ + "https://evil-b00a8021-9d8d-4f49-a581-628727b71f68.lovable.app", + "https://evil@superagentskill.com", + "https://superagentskill.com:444", + "http://localhost:3000", + ]) { + assert.throws(() => validateReturnUrl(url)); + } +}); diff --git a/tests/security-guards.test.ts b/tests/security-guards.test.ts index 729f62ce..396640f8 100644 --- a/tests/security-guards.test.ts +++ b/tests/security-guards.test.ts @@ -1,10 +1,9 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -const { resolveCheckoutQuantity, validateReturnUrl } = await import( - "../src/lib/checkout-quantity.ts" -); -const { canAccessDiagnosis } = await import("../src/lib/university/access.ts"); +const { resolveCheckoutQuantity, validateReturnUrl } = + await import("../src/lib/checkout-quantity.ts"); +const { canAccessDiagnosis } = await import("../src/lib/university/diagnosis-access.ts"); test("Pro plans are always sold as quantity 1, whatever the caller asks", () => { assert.equal(resolveCheckoutQuantity("sak_pro_monthly", 50), 1); @@ -29,8 +28,8 @@ test("checkout return links must point back at this site", () => { }); test("an owned diagnosis is only reachable by its owner", () => { - assert.equal(canAccessDiagnosis("user-a", "user-a"), true); - assert.equal(canAccessDiagnosis("user-a", "user-b"), false); - assert.equal(canAccessDiagnosis("user-a", null), false); - assert.equal(canAccessDiagnosis(null, null), true); + assert.equal(canAccessDiagnosis("user-a", "user-a", "id", "secret"), true); + assert.equal(canAccessDiagnosis("user-a", "user-b", "id", "secret"), false); + assert.equal(canAccessDiagnosis("user-a", null, "id", "secret"), false); + assert.equal(canAccessDiagnosis(null, null, "id", "secret"), false); });