availsync 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.adal/skills/stripe-best-practices/SKILL.md +42 -0
- package/.adal/skills/stripe-best-practices/references/billing.md +36 -0
- package/.adal/skills/stripe-best-practices/references/connect.md +48 -0
- package/.adal/skills/stripe-best-practices/references/payments.md +79 -0
- package/.adal/skills/stripe-best-practices/references/security.md +109 -0
- package/.adal/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.adal/skills/stripe-projects/SKILL.md +139 -0
- package/.adal/skills/upgrade-stripe/SKILL.md +185 -0
- package/.agents/skills/stripe-best-practices/SKILL.md +42 -0
- package/.agents/skills/stripe-best-practices/references/billing.md +36 -0
- package/.agents/skills/stripe-best-practices/references/connect.md +48 -0
- package/.agents/skills/stripe-best-practices/references/payments.md +79 -0
- package/.agents/skills/stripe-best-practices/references/security.md +109 -0
- package/.agents/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.agents/skills/stripe-projects/SKILL.md +139 -0
- package/.agents/skills/upgrade-stripe/SKILL.md +185 -0
- package/.augment/skills/stripe-best-practices/SKILL.md +42 -0
- package/.augment/skills/stripe-best-practices/references/billing.md +36 -0
- package/.augment/skills/stripe-best-practices/references/connect.md +48 -0
- package/.augment/skills/stripe-best-practices/references/payments.md +79 -0
- package/.augment/skills/stripe-best-practices/references/security.md +109 -0
- package/.augment/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.augment/skills/stripe-projects/SKILL.md +139 -0
- package/.augment/skills/upgrade-stripe/SKILL.md +185 -0
- package/.bob/skills/stripe-best-practices/SKILL.md +42 -0
- package/.bob/skills/stripe-best-practices/references/billing.md +36 -0
- package/.bob/skills/stripe-best-practices/references/connect.md +48 -0
- package/.bob/skills/stripe-best-practices/references/payments.md +79 -0
- package/.bob/skills/stripe-best-practices/references/security.md +109 -0
- package/.bob/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.bob/skills/stripe-projects/SKILL.md +139 -0
- package/.bob/skills/upgrade-stripe/SKILL.md +185 -0
- package/.claude/settings.local.json +7 -0
- package/.claude/skills/stripe-best-practices/SKILL.md +42 -0
- package/.claude/skills/stripe-best-practices/references/billing.md +36 -0
- package/.claude/skills/stripe-best-practices/references/connect.md +48 -0
- package/.claude/skills/stripe-best-practices/references/payments.md +79 -0
- package/.claude/skills/stripe-best-practices/references/security.md +109 -0
- package/.claude/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.claude/skills/stripe-projects/SKILL.md +139 -0
- package/.claude/skills/upgrade-stripe/SKILL.md +185 -0
- package/.codebuddy/skills/stripe-best-practices/SKILL.md +42 -0
- package/.codebuddy/skills/stripe-best-practices/references/billing.md +36 -0
- package/.codebuddy/skills/stripe-best-practices/references/connect.md +48 -0
- package/.codebuddy/skills/stripe-best-practices/references/payments.md +79 -0
- package/.codebuddy/skills/stripe-best-practices/references/security.md +109 -0
- package/.codebuddy/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.codebuddy/skills/stripe-projects/SKILL.md +139 -0
- package/.codebuddy/skills/upgrade-stripe/SKILL.md +185 -0
- package/.commandcode/skills/stripe-best-practices/SKILL.md +42 -0
- package/.commandcode/skills/stripe-best-practices/references/billing.md +36 -0
- package/.commandcode/skills/stripe-best-practices/references/connect.md +48 -0
- package/.commandcode/skills/stripe-best-practices/references/payments.md +79 -0
- package/.commandcode/skills/stripe-best-practices/references/security.md +109 -0
- package/.commandcode/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.commandcode/skills/stripe-projects/SKILL.md +139 -0
- package/.commandcode/skills/upgrade-stripe/SKILL.md +185 -0
- package/.continue/skills/stripe-best-practices/SKILL.md +42 -0
- package/.continue/skills/stripe-best-practices/references/billing.md +36 -0
- package/.continue/skills/stripe-best-practices/references/connect.md +48 -0
- package/.continue/skills/stripe-best-practices/references/payments.md +79 -0
- package/.continue/skills/stripe-best-practices/references/security.md +109 -0
- package/.continue/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.continue/skills/stripe-projects/SKILL.md +139 -0
- package/.continue/skills/upgrade-stripe/SKILL.md +185 -0
- package/.cortex/skills/stripe-best-practices/SKILL.md +42 -0
- package/.cortex/skills/stripe-best-practices/references/billing.md +36 -0
- package/.cortex/skills/stripe-best-practices/references/connect.md +48 -0
- package/.cortex/skills/stripe-best-practices/references/payments.md +79 -0
- package/.cortex/skills/stripe-best-practices/references/security.md +109 -0
- package/.cortex/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.cortex/skills/stripe-projects/SKILL.md +139 -0
- package/.cortex/skills/upgrade-stripe/SKILL.md +185 -0
- package/.crush/skills/stripe-best-practices/SKILL.md +42 -0
- package/.crush/skills/stripe-best-practices/references/billing.md +36 -0
- package/.crush/skills/stripe-best-practices/references/connect.md +48 -0
- package/.crush/skills/stripe-best-practices/references/payments.md +79 -0
- package/.crush/skills/stripe-best-practices/references/security.md +109 -0
- package/.crush/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.crush/skills/stripe-projects/SKILL.md +139 -0
- package/.crush/skills/upgrade-stripe/SKILL.md +185 -0
- package/.env.example +20 -0
- package/.factory/skills/stripe-best-practices/SKILL.md +42 -0
- package/.factory/skills/stripe-best-practices/references/billing.md +36 -0
- package/.factory/skills/stripe-best-practices/references/connect.md +48 -0
- package/.factory/skills/stripe-best-practices/references/payments.md +79 -0
- package/.factory/skills/stripe-best-practices/references/security.md +109 -0
- package/.factory/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.factory/skills/stripe-projects/SKILL.md +139 -0
- package/.factory/skills/upgrade-stripe/SKILL.md +185 -0
- package/.goose/skills/stripe-best-practices/SKILL.md +42 -0
- package/.goose/skills/stripe-best-practices/references/billing.md +36 -0
- package/.goose/skills/stripe-best-practices/references/connect.md +48 -0
- package/.goose/skills/stripe-best-practices/references/payments.md +79 -0
- package/.goose/skills/stripe-best-practices/references/security.md +109 -0
- package/.goose/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.goose/skills/stripe-projects/SKILL.md +139 -0
- package/.goose/skills/upgrade-stripe/SKILL.md +185 -0
- package/.iflow/skills/stripe-best-practices/SKILL.md +42 -0
- package/.iflow/skills/stripe-best-practices/references/billing.md +36 -0
- package/.iflow/skills/stripe-best-practices/references/connect.md +48 -0
- package/.iflow/skills/stripe-best-practices/references/payments.md +79 -0
- package/.iflow/skills/stripe-best-practices/references/security.md +109 -0
- package/.iflow/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.iflow/skills/stripe-projects/SKILL.md +139 -0
- package/.iflow/skills/upgrade-stripe/SKILL.md +185 -0
- package/.junie/skills/stripe-best-practices/SKILL.md +42 -0
- package/.junie/skills/stripe-best-practices/references/billing.md +36 -0
- package/.junie/skills/stripe-best-practices/references/connect.md +48 -0
- package/.junie/skills/stripe-best-practices/references/payments.md +79 -0
- package/.junie/skills/stripe-best-practices/references/security.md +109 -0
- package/.junie/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.junie/skills/stripe-projects/SKILL.md +139 -0
- package/.junie/skills/upgrade-stripe/SKILL.md +185 -0
- package/.kilocode/skills/stripe-best-practices/SKILL.md +42 -0
- package/.kilocode/skills/stripe-best-practices/references/billing.md +36 -0
- package/.kilocode/skills/stripe-best-practices/references/connect.md +48 -0
- package/.kilocode/skills/stripe-best-practices/references/payments.md +79 -0
- package/.kilocode/skills/stripe-best-practices/references/security.md +109 -0
- package/.kilocode/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.kilocode/skills/stripe-projects/SKILL.md +139 -0
- package/.kilocode/skills/upgrade-stripe/SKILL.md +185 -0
- package/.kiro/skills/stripe-best-practices/SKILL.md +42 -0
- package/.kiro/skills/stripe-best-practices/references/billing.md +36 -0
- package/.kiro/skills/stripe-best-practices/references/connect.md +48 -0
- package/.kiro/skills/stripe-best-practices/references/payments.md +79 -0
- package/.kiro/skills/stripe-best-practices/references/security.md +109 -0
- package/.kiro/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.kiro/skills/stripe-projects/SKILL.md +139 -0
- package/.kiro/skills/upgrade-stripe/SKILL.md +185 -0
- package/.kode/skills/stripe-best-practices/SKILL.md +42 -0
- package/.kode/skills/stripe-best-practices/references/billing.md +36 -0
- package/.kode/skills/stripe-best-practices/references/connect.md +48 -0
- package/.kode/skills/stripe-best-practices/references/payments.md +79 -0
- package/.kode/skills/stripe-best-practices/references/security.md +109 -0
- package/.kode/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.kode/skills/stripe-projects/SKILL.md +139 -0
- package/.kode/skills/upgrade-stripe/SKILL.md +185 -0
- package/.mcpjam/skills/stripe-best-practices/SKILL.md +42 -0
- package/.mcpjam/skills/stripe-best-practices/references/billing.md +36 -0
- package/.mcpjam/skills/stripe-best-practices/references/connect.md +48 -0
- package/.mcpjam/skills/stripe-best-practices/references/payments.md +79 -0
- package/.mcpjam/skills/stripe-best-practices/references/security.md +109 -0
- package/.mcpjam/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.mcpjam/skills/stripe-projects/SKILL.md +139 -0
- package/.mcpjam/skills/upgrade-stripe/SKILL.md +185 -0
- package/.mux/skills/stripe-best-practices/SKILL.md +42 -0
- package/.mux/skills/stripe-best-practices/references/billing.md +36 -0
- package/.mux/skills/stripe-best-practices/references/connect.md +48 -0
- package/.mux/skills/stripe-best-practices/references/payments.md +79 -0
- package/.mux/skills/stripe-best-practices/references/security.md +109 -0
- package/.mux/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.mux/skills/stripe-projects/SKILL.md +139 -0
- package/.mux/skills/upgrade-stripe/SKILL.md +185 -0
- package/.neovate/skills/stripe-best-practices/SKILL.md +42 -0
- package/.neovate/skills/stripe-best-practices/references/billing.md +36 -0
- package/.neovate/skills/stripe-best-practices/references/connect.md +48 -0
- package/.neovate/skills/stripe-best-practices/references/payments.md +79 -0
- package/.neovate/skills/stripe-best-practices/references/security.md +109 -0
- package/.neovate/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.neovate/skills/stripe-projects/SKILL.md +139 -0
- package/.neovate/skills/upgrade-stripe/SKILL.md +185 -0
- package/.nixpacksignore +14 -0
- package/.openhands/skills/stripe-best-practices/SKILL.md +42 -0
- package/.openhands/skills/stripe-best-practices/references/billing.md +36 -0
- package/.openhands/skills/stripe-best-practices/references/connect.md +48 -0
- package/.openhands/skills/stripe-best-practices/references/payments.md +79 -0
- package/.openhands/skills/stripe-best-practices/references/security.md +109 -0
- package/.openhands/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.openhands/skills/stripe-projects/SKILL.md +139 -0
- package/.openhands/skills/upgrade-stripe/SKILL.md +185 -0
- package/.pi/skills/stripe-best-practices/SKILL.md +42 -0
- package/.pi/skills/stripe-best-practices/references/billing.md +36 -0
- package/.pi/skills/stripe-best-practices/references/connect.md +48 -0
- package/.pi/skills/stripe-best-practices/references/payments.md +79 -0
- package/.pi/skills/stripe-best-practices/references/security.md +109 -0
- package/.pi/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.pi/skills/stripe-projects/SKILL.md +139 -0
- package/.pi/skills/upgrade-stripe/SKILL.md +185 -0
- package/.pochi/skills/stripe-best-practices/SKILL.md +42 -0
- package/.pochi/skills/stripe-best-practices/references/billing.md +36 -0
- package/.pochi/skills/stripe-best-practices/references/connect.md +48 -0
- package/.pochi/skills/stripe-best-practices/references/payments.md +79 -0
- package/.pochi/skills/stripe-best-practices/references/security.md +109 -0
- package/.pochi/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.pochi/skills/stripe-projects/SKILL.md +139 -0
- package/.pochi/skills/upgrade-stripe/SKILL.md +185 -0
- package/.qoder/skills/stripe-best-practices/SKILL.md +42 -0
- package/.qoder/skills/stripe-best-practices/references/billing.md +36 -0
- package/.qoder/skills/stripe-best-practices/references/connect.md +48 -0
- package/.qoder/skills/stripe-best-practices/references/payments.md +79 -0
- package/.qoder/skills/stripe-best-practices/references/security.md +109 -0
- package/.qoder/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.qoder/skills/stripe-projects/SKILL.md +139 -0
- package/.qoder/skills/upgrade-stripe/SKILL.md +185 -0
- package/.qwen/skills/stripe-best-practices/SKILL.md +42 -0
- package/.qwen/skills/stripe-best-practices/references/billing.md +36 -0
- package/.qwen/skills/stripe-best-practices/references/connect.md +48 -0
- package/.qwen/skills/stripe-best-practices/references/payments.md +79 -0
- package/.qwen/skills/stripe-best-practices/references/security.md +109 -0
- package/.qwen/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.qwen/skills/stripe-projects/SKILL.md +139 -0
- package/.qwen/skills/upgrade-stripe/SKILL.md +185 -0
- package/.roo/skills/stripe-best-practices/SKILL.md +42 -0
- package/.roo/skills/stripe-best-practices/references/billing.md +36 -0
- package/.roo/skills/stripe-best-practices/references/connect.md +48 -0
- package/.roo/skills/stripe-best-practices/references/payments.md +79 -0
- package/.roo/skills/stripe-best-practices/references/security.md +109 -0
- package/.roo/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.roo/skills/stripe-projects/SKILL.md +139 -0
- package/.roo/skills/upgrade-stripe/SKILL.md +185 -0
- package/.trae/skills/stripe-best-practices/SKILL.md +42 -0
- package/.trae/skills/stripe-best-practices/references/billing.md +36 -0
- package/.trae/skills/stripe-best-practices/references/connect.md +48 -0
- package/.trae/skills/stripe-best-practices/references/payments.md +79 -0
- package/.trae/skills/stripe-best-practices/references/security.md +109 -0
- package/.trae/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.trae/skills/stripe-projects/SKILL.md +139 -0
- package/.trae/skills/upgrade-stripe/SKILL.md +185 -0
- package/.vibe/skills/stripe-best-practices/SKILL.md +42 -0
- package/.vibe/skills/stripe-best-practices/references/billing.md +36 -0
- package/.vibe/skills/stripe-best-practices/references/connect.md +48 -0
- package/.vibe/skills/stripe-best-practices/references/payments.md +79 -0
- package/.vibe/skills/stripe-best-practices/references/security.md +109 -0
- package/.vibe/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.vibe/skills/stripe-projects/SKILL.md +139 -0
- package/.vibe/skills/upgrade-stripe/SKILL.md +185 -0
- package/.windsurf/skills/stripe-best-practices/SKILL.md +42 -0
- package/.windsurf/skills/stripe-best-practices/references/billing.md +36 -0
- package/.windsurf/skills/stripe-best-practices/references/connect.md +48 -0
- package/.windsurf/skills/stripe-best-practices/references/payments.md +79 -0
- package/.windsurf/skills/stripe-best-practices/references/security.md +109 -0
- package/.windsurf/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.windsurf/skills/stripe-projects/SKILL.md +139 -0
- package/.windsurf/skills/upgrade-stripe/SKILL.md +185 -0
- package/.zencoder/skills/stripe-best-practices/SKILL.md +42 -0
- package/.zencoder/skills/stripe-best-practices/references/billing.md +36 -0
- package/.zencoder/skills/stripe-best-practices/references/connect.md +48 -0
- package/.zencoder/skills/stripe-best-practices/references/payments.md +79 -0
- package/.zencoder/skills/stripe-best-practices/references/security.md +109 -0
- package/.zencoder/skills/stripe-best-practices/references/treasury.md +16 -0
- package/.zencoder/skills/stripe-projects/SKILL.md +139 -0
- package/.zencoder/skills/upgrade-stripe/SKILL.md +185 -0
- package/AUDIT.md +95 -0
- package/BLOCKERS.md +0 -0
- package/COOLIFY.md +51 -0
- package/MCP_SETUP.md +23 -0
- package/PRODUCTION_CHECKLIST.md +246 -0
- package/README.md +47 -0
- package/ROADMAP.md +91 -0
- package/docs/superpowers/plans/2026-05-11-availsync-frontend-sales-flow.md +2445 -0
- package/frontend/.env.example +2 -0
- package/frontend/app/admin/layout.tsx +13 -0
- package/frontend/app/admin/page.tsx +747 -0
- package/frontend/app/app/activity/page.tsx +257 -0
- package/frontend/app/app/agents/[agentId]/page.tsx +21 -0
- package/frontend/app/app/agents/page.tsx +1155 -0
- package/frontend/app/app/audit/page.tsx +225 -0
- package/frontend/app/app/availability/page.tsx +840 -0
- package/frontend/app/app/holds/page.tsx +262 -0
- package/frontend/app/app/layout.tsx +19 -0
- package/frontend/app/app/onboarding/page.tsx +10 -0
- package/frontend/app/app/onboarding/verify/page.tsx +309 -0
- package/frontend/app/app/page.tsx +508 -0
- package/frontend/app/app/settings/page.tsx +399 -0
- package/frontend/app/app/work/page.tsx +426 -0
- package/frontend/app/changelog/page.tsx +93 -0
- package/frontend/app/checkout/page.tsx +25 -0
- package/frontend/app/docs/api/page.tsx +157 -0
- package/frontend/app/docs/page.tsx +296 -0
- package/frontend/app/docs/pilot/page.tsx +127 -0
- package/frontend/app/docs/quickstart/page.tsx +318 -0
- package/frontend/app/docs/reliability/page.tsx +78 -0
- package/frontend/app/docs/sdk/node/page.tsx +166 -0
- package/frontend/app/globals.css +57 -0
- package/frontend/app/icon.png +0 -0
- package/frontend/app/layout.tsx +87 -0
- package/frontend/app/login/page.tsx +14 -0
- package/frontend/app/page.tsx +47 -0
- package/frontend/app/pricing/page.tsx +66 -0
- package/frontend/app/privacy/page.tsx +52 -0
- package/frontend/app/robots.ts +26 -0
- package/frontend/app/security/page.tsx +74 -0
- package/frontend/app/signup/page.tsx +14 -0
- package/frontend/app/sitemap.ts +14 -0
- package/frontend/app/terms/page.tsx +51 -0
- package/frontend/components/brand/AvailsyncLogo.tsx +56 -0
- package/frontend/components/checkout/CheckoutClient.tsx +100 -0
- package/frontend/components/dashboard/AgentForm.tsx +59 -0
- package/frontend/components/dashboard/AppShell.tsx +291 -0
- package/frontend/components/dashboard/AvailabilityChecker.tsx +117 -0
- package/frontend/components/dashboard/AvailabilityWindowForm.tsx +40 -0
- package/frontend/components/dashboard/HoldForm.tsx +133 -0
- package/frontend/components/dashboard/MetricCard.tsx +10 -0
- package/frontend/components/login/LoginForm.tsx +95 -0
- package/frontend/components/marketing/AgentCoordinationStory.tsx +1530 -0
- package/frontend/components/marketing/Faq.tsx +41 -0
- package/frontend/components/marketing/Hero.tsx +73 -0
- package/frontend/components/marketing/HowItWorks.tsx +28 -0
- package/frontend/components/marketing/ObserveModeTeaser.tsx +41 -0
- package/frontend/components/marketing/PricingTeaser.tsx +23 -0
- package/frontend/components/marketing/ProblemSolution.tsx +36 -0
- package/frontend/components/marketing/SiteFooter.tsx +59 -0
- package/frontend/components/marketing/SiteHeader.tsx +45 -0
- package/frontend/components/marketing/UseCases.tsx +27 -0
- package/frontend/components/onboarding/OnboardingClient.tsx +278 -0
- package/frontend/components/pricing/PricingCards.tsx +65 -0
- package/frontend/components/privacy/CookieConsent.tsx +230 -0
- package/frontend/components/privacy/CookieSettingsButton.tsx +15 -0
- package/frontend/components/seo/JsonLd.tsx +10 -0
- package/frontend/components/signup/SignupForm.tsx +55 -0
- package/frontend/components/ui/Badge.tsx +23 -0
- package/frontend/components/ui/Button.tsx +37 -0
- package/frontend/components/ui/Card.tsx +11 -0
- package/frontend/components/ui/ConfirmDialog.tsx +77 -0
- package/frontend/components/ui/EmptyState.tsx +24 -0
- package/frontend/components/ui/Input.tsx +14 -0
- package/frontend/components/ui/KeyDisplay.tsx +49 -0
- package/frontend/components/ui/Select.tsx +14 -0
- package/frontend/components/ui/Skeleton.tsx +24 -0
- package/frontend/components/ui/Tabs.tsx +19 -0
- package/frontend/components/ui/Textarea.tsx +14 -0
- package/frontend/components/ui/Toast.tsx +78 -0
- package/frontend/components/waitlist/WaitlistDialog.tsx +128 -0
- package/frontend/lib/api.ts +1282 -0
- package/frontend/lib/billing.ts +6 -0
- package/frontend/lib/cookieConsent.ts +113 -0
- package/frontend/lib/format.ts +16 -0
- package/frontend/lib/plans.ts +62 -0
- package/frontend/lib/schemas.ts +108 -0
- package/frontend/lib/seo.ts +376 -0
- package/frontend/lib/setupGuides.ts +630 -0
- package/frontend/lib/storage.ts +30 -0
- package/frontend/next-env.d.ts +6 -0
- package/frontend/next.config.mjs +13 -0
- package/frontend/package-lock.json +14409 -0
- package/frontend/package.json +41 -0
- package/frontend/playwright.config.ts +20 -0
- package/frontend/postcss.config.mjs +8 -0
- package/frontend/public/.gitkeep +0 -0
- package/frontend/public/brand/availsync-logo-board.png +0 -0
- package/frontend/public/brand/availsync-logo-dark.png +0 -0
- package/frontend/public/brand/availsync-mark-dark.png +0 -0
- package/frontend/public/brand/availsync-wordmark-dark.png +0 -0
- package/frontend/public/marketing/hero-agent-coordination.png +0 -0
- package/frontend/tailwind.config.ts +53 -0
- package/frontend/tests/smoke.spec.ts +89 -0
- package/frontend/tsconfig.json +23 -0
- package/jest.config.js +7 -0
- package/nixpacks.toml +11 -0
- package/package.json +53 -0
- package/packages/mcp/LICENSE +21 -0
- package/packages/mcp/README.md +60 -0
- package/packages/mcp/jest.config.cjs +8 -0
- package/packages/mcp/package.json +54 -0
- package/packages/mcp/src/helpers.ts +38 -0
- package/packages/mcp/src/index.test.ts +60 -0
- package/packages/mcp/src/index.ts +387 -0
- package/packages/mcp/tsconfig.json +20 -0
- package/packages/mcp/tsconfig.test.json +12 -0
- package/packages/node/LICENSE +21 -0
- package/packages/node/README.md +120 -0
- package/packages/node/jest.config.cjs +8 -0
- package/packages/node/package.json +46 -0
- package/packages/node/src/index.test.ts +360 -0
- package/packages/node/src/index.ts +402 -0
- package/packages/node/tsconfig.json +20 -0
- package/packages/node/tsconfig.test.json +12 -0
- package/plan.md +923 -0
- package/skills/stripe-best-practices/SKILL.md +42 -0
- package/skills/stripe-best-practices/references/billing.md +36 -0
- package/skills/stripe-best-practices/references/connect.md +48 -0
- package/skills/stripe-best-practices/references/payments.md +79 -0
- package/skills/stripe-best-practices/references/security.md +109 -0
- package/skills/stripe-best-practices/references/treasury.md +16 -0
- package/skills/stripe-projects/SKILL.md +139 -0
- package/skills/upgrade-stripe/SKILL.md +185 -0
- package/skills-lock.json +20 -0
- package/src/core/availability.ts +178 -0
- package/src/core/conflict.ts +209 -0
- package/src/core/work.ts +490 -0
- package/src/db/client.ts +17 -0
- package/src/db/migrations/001_init.sql +88 -0
- package/src/db/migrations/002_stripe.sql +2 -0
- package/src/db/migrations/003_workspace_auth.sql +19 -0
- package/src/db/migrations/004_agent_mcp_status.sql +2 -0
- package/src/db/migrations/005_hold_event_actor.sql +4 -0
- package/src/db/migrations/006_agent_activity.sql +35 -0
- package/src/db/migrations/007_work_coordination.sql +60 -0
- package/src/db/migrations/008_work_claim_leases.sql +20 -0
- package/src/db/migrations/009_billing_subscription_state.sql +23 -0
- package/src/db/migrations/010_agent_api_key_prefix.sql +10 -0
- package/src/db/migrations/011_org_verified_and_work_event_retention.sql +11 -0
- package/src/db/migrations/012_agent_enforcement_mode.sql +12 -0
- package/src/db/migrations/013_support_tickets.sql +21 -0
- package/src/db/migrations/014_paid_plan_waitlist.sql +23 -0
- package/src/db/migrations/015_agent_last_seen.sql +2 -0
- package/src/db/migrations.ts +164 -0
- package/src/db/run-migrations.ts +13 -0
- package/src/index.ts +183 -0
- package/src/lib/activity.ts +137 -0
- package/src/lib/apiKeys.ts +32 -0
- package/src/lib/appInfo.ts +26 -0
- package/src/lib/billingConfig.ts +3 -0
- package/src/lib/env.ts +75 -0
- package/src/lib/logger.ts +8 -0
- package/src/lib/plans.ts +204 -0
- package/src/mcp/server.js +5 -0
- package/src/mcp/server.ts +350 -0
- package/src/middleware/auth.ts +342 -0
- package/src/middleware/requestId.ts +16 -0
- package/src/routes/account.ts +168 -0
- package/src/routes/activity.ts +126 -0
- package/src/routes/admin.ts +514 -0
- package/src/routes/audit.ts +68 -0
- package/src/routes/auth.ts +203 -0
- package/src/routes/availability.ts +325 -0
- package/src/routes/billing.ts +406 -0
- package/src/routes/conflicts.ts +131 -0
- package/src/routes/holds.ts +437 -0
- package/src/routes/mcp.ts +57 -0
- package/src/routes/metrics.ts +39 -0
- package/src/routes/onboarding.ts +273 -0
- package/src/routes/orgs.ts +981 -0
- package/src/routes/preferences.ts +132 -0
- package/src/routes/session.ts +16 -0
- package/src/routes/support.ts +77 -0
- package/src/routes/value.ts +186 -0
- package/src/routes/waitlist.ts +63 -0
- package/src/routes/work.ts +1578 -0
- package/src/server.ts +36 -0
- package/src/types/index.ts +109 -0
- package/tests/integration/activity.route.test.ts +103 -0
- package/tests/integration/admin.route.test.ts +143 -0
- package/tests/integration/agent-keys.route.test.ts +237 -0
- package/tests/integration/availability.route.test.ts +125 -0
- package/tests/integration/billing.route.test.ts +393 -0
- package/tests/integration/conflicts.route.test.ts +131 -0
- package/tests/integration/flows.test.ts +154 -0
- package/tests/integration/helpers.ts +134 -0
- package/tests/integration/holds.route.test.ts +185 -0
- package/tests/integration/metrics.route.test.ts +100 -0
- package/tests/integration/onboarding.verify.route.test.ts +163 -0
- package/tests/integration/preferences.route.test.ts +53 -0
- package/tests/integration/session.route.test.ts +97 -0
- package/tests/integration/system.route.test.ts +92 -0
- package/tests/integration/value.route.test.ts +235 -0
- package/tests/integration/work.route.test.ts +745 -0
- package/tests/setup.ts +4 -0
- package/tests/smoke.sh +62 -0
- package/tests/unit/auth.test.ts +114 -0
- package/tests/unit/availability.test.ts +149 -0
- package/tests/unit/conflict.test.ts +118 -0
- package/tests/unit/env.test.ts +69 -0
- package/tests/unit/migrations.test.ts +135 -0
- package/tests/unit/request-id.test.ts +37 -0
- package/tmp-mobile-agents.png +0 -0
- package/tmp-next-mobile.err.log +10 -0
- package/tmp-next-mobile.log +5 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from '@jest/globals';
|
|
2
|
+
import {
|
|
3
|
+
api,
|
|
4
|
+
closeDatabase,
|
|
5
|
+
createAgent,
|
|
6
|
+
createOrgAndAgent,
|
|
7
|
+
createWindow,
|
|
8
|
+
migrateTestDatabase,
|
|
9
|
+
resetDatabase,
|
|
10
|
+
} from './helpers';
|
|
11
|
+
|
|
12
|
+
describe('availability routes', () => {
|
|
13
|
+
let orgId: string;
|
|
14
|
+
let agentId: string;
|
|
15
|
+
let apiKey: string;
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
await migrateTestDatabase();
|
|
19
|
+
await resetDatabase();
|
|
20
|
+
const created = await createOrgAndAgent();
|
|
21
|
+
orgId = created.orgId;
|
|
22
|
+
agentId = created.agentId;
|
|
23
|
+
apiKey = created.apiKey;
|
|
24
|
+
await createWindow(agentId, apiKey, '2026-05-18T09:00:00Z', '2026-05-18T11:00:00Z');
|
|
25
|
+
await createWindow(agentId, apiKey, '2030-01-03T09:00:00Z', '2030-01-03T11:00:00Z');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(async () => {
|
|
29
|
+
await resetDatabase();
|
|
30
|
+
await closeDatabase();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('GET /v1/availability with valid params returns slots', async () => {
|
|
34
|
+
const response = await api
|
|
35
|
+
.get('/v1/availability')
|
|
36
|
+
.query({
|
|
37
|
+
agent_id: agentId,
|
|
38
|
+
from: '2026-05-18T09:00:00Z',
|
|
39
|
+
to: '2026-05-18T11:00:00Z',
|
|
40
|
+
duration_minutes: 30,
|
|
41
|
+
})
|
|
42
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
43
|
+
.expect(200);
|
|
44
|
+
|
|
45
|
+
expect(response.body.total_slots).toBeGreaterThan(0);
|
|
46
|
+
expect(response.body.slots[0]).toHaveProperty('confidence');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('GET /v1/availability excludes competing agent holds by default', async () => {
|
|
50
|
+
const competing = await createAgent(orgId, 'Competing Bot', 'internal');
|
|
51
|
+
await createWindow(competing.agentId, competing.apiKey, '2030-01-03T09:00:00Z', '2030-01-03T11:00:00Z');
|
|
52
|
+
await api
|
|
53
|
+
.post('/v1/holds')
|
|
54
|
+
.set('Authorization', `Bearer ${competing.apiKey}`)
|
|
55
|
+
.send({
|
|
56
|
+
agent_id: competing.agentId,
|
|
57
|
+
start_at: '2030-01-03T09:30:00Z',
|
|
58
|
+
end_at: '2030-01-03T10:00:00Z',
|
|
59
|
+
})
|
|
60
|
+
.expect(201);
|
|
61
|
+
|
|
62
|
+
const response = await api
|
|
63
|
+
.get('/v1/availability')
|
|
64
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
65
|
+
.query({
|
|
66
|
+
agent_id: agentId,
|
|
67
|
+
from: '2030-01-03T09:00:00Z',
|
|
68
|
+
to: '2030-01-03T11:00:00Z',
|
|
69
|
+
duration_minutes: 30,
|
|
70
|
+
})
|
|
71
|
+
.expect(200);
|
|
72
|
+
|
|
73
|
+
expect(response.body.slots.map((slot: { start: string }) => slot.start)).not.toContain(
|
|
74
|
+
'2030-01-03T09:30:00.000Z',
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('GET /v1/availability can ignore competing agent holds for debugging', async () => {
|
|
79
|
+
const response = await api
|
|
80
|
+
.get('/v1/availability')
|
|
81
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
82
|
+
.query({
|
|
83
|
+
agent_id: agentId,
|
|
84
|
+
from: '2030-01-03T09:00:00Z',
|
|
85
|
+
to: '2030-01-03T11:00:00Z',
|
|
86
|
+
duration_minutes: 30,
|
|
87
|
+
include_competing_agents: 'false',
|
|
88
|
+
})
|
|
89
|
+
.expect(200);
|
|
90
|
+
|
|
91
|
+
expect(response.body.slots.map((slot: { start: string }) => slot.start)).toContain(
|
|
92
|
+
'2030-01-03T09:30:00.000Z',
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('GET /v1/availability without auth returns 401', async () => {
|
|
97
|
+
await api.get('/v1/availability').query({ agent_id: agentId }).expect(401);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('GET /v1/availability with invalid agent_id returns 403', async () => {
|
|
101
|
+
await api
|
|
102
|
+
.get('/v1/availability')
|
|
103
|
+
.query({
|
|
104
|
+
agent_id: '00000000-0000-0000-0000-000000000000',
|
|
105
|
+
from: '2026-05-18T09:00:00Z',
|
|
106
|
+
to: '2026-05-18T11:00:00Z',
|
|
107
|
+
duration_minutes: 30,
|
|
108
|
+
})
|
|
109
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
110
|
+
.expect(403);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('GET /v1/availability with from in the past returns 400', async () => {
|
|
114
|
+
await api
|
|
115
|
+
.get('/v1/availability')
|
|
116
|
+
.query({
|
|
117
|
+
agent_id: agentId,
|
|
118
|
+
from: '2020-01-01T09:00:00Z',
|
|
119
|
+
to: '2020-01-01T11:00:00Z',
|
|
120
|
+
duration_minutes: 30,
|
|
121
|
+
})
|
|
122
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
123
|
+
.expect(400);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test } from '@jest/globals';
|
|
2
|
+
import Stripe from 'stripe';
|
|
3
|
+
import {
|
|
4
|
+
api,
|
|
5
|
+
closeDatabase,
|
|
6
|
+
createAgent,
|
|
7
|
+
createOrgAndAgent,
|
|
8
|
+
getWorkspaceCookie,
|
|
9
|
+
migrateTestDatabase,
|
|
10
|
+
resetDatabase,
|
|
11
|
+
} from './helpers';
|
|
12
|
+
import pool from '../../src/db/client';
|
|
13
|
+
|
|
14
|
+
describe('billing routes', () => {
|
|
15
|
+
let orgId: string;
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
await migrateTestDatabase();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
delete process.env.STRIPE_SECRET_KEY;
|
|
23
|
+
delete process.env.STRIPE_WEBHOOK_SECRET;
|
|
24
|
+
delete process.env.BILLING_UPGRADES_ENABLED;
|
|
25
|
+
delete process.env.NEXT_PUBLIC_BILLING_UPGRADES_ENABLED;
|
|
26
|
+
await resetDatabase();
|
|
27
|
+
const created = await api.post('/v1/orgs').send({ name: `Billing Org ${Date.now()}` }).expect(201);
|
|
28
|
+
orgId = created.body.org.id;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
afterAll(async () => {
|
|
32
|
+
await resetDatabase();
|
|
33
|
+
await closeDatabase();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('checkout returns 401 without auth', async () => {
|
|
37
|
+
await api
|
|
38
|
+
.post('/v1/billing/checkout')
|
|
39
|
+
.send({ plan: 'individual' })
|
|
40
|
+
.expect(401);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('checkout is waitlist-only when paid upgrades are disabled', async () => {
|
|
44
|
+
const workspace = await createOrgAndAgent('Billing Agent', 'generic', 0);
|
|
45
|
+
|
|
46
|
+
const response = await api
|
|
47
|
+
.post('/v1/billing/checkout')
|
|
48
|
+
.set('Cookie', getWorkspaceCookie(workspace.orgId))
|
|
49
|
+
.send({ plan: 'individual' })
|
|
50
|
+
.expect(403);
|
|
51
|
+
|
|
52
|
+
expect(response.body).toMatchObject({ error: 'billing_upgrades_disabled' });
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('checkout returns safe not-configured response when upgrades are enabled without Stripe', async () => {
|
|
56
|
+
process.env.BILLING_UPGRADES_ENABLED = 'true';
|
|
57
|
+
const workspace = await createOrgAndAgent('Billing Agent', 'generic', 0);
|
|
58
|
+
|
|
59
|
+
const response = await api
|
|
60
|
+
.post('/v1/billing/checkout')
|
|
61
|
+
.set('Cookie', getWorkspaceCookie(workspace.orgId))
|
|
62
|
+
.send({ plan: 'individual' })
|
|
63
|
+
.expect(501);
|
|
64
|
+
|
|
65
|
+
expect(response.body).toMatchObject({ error: 'billing_not_configured' });
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('billing status returns limits and usage for the current workspace', async () => {
|
|
69
|
+
const workspace = await createOrgAndAgent('Billing Usage', 'generic', 0);
|
|
70
|
+
const claim = await api
|
|
71
|
+
.post('/v1/work/claim')
|
|
72
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
73
|
+
.send({
|
|
74
|
+
agent_id: workspace.agentId,
|
|
75
|
+
resource_type: 'repo',
|
|
76
|
+
resource_key: 'owner/repo',
|
|
77
|
+
})
|
|
78
|
+
.expect(201);
|
|
79
|
+
|
|
80
|
+
const response = await api
|
|
81
|
+
.get('/v1/billing/status')
|
|
82
|
+
.set('Cookie', getWorkspaceCookie(workspace.orgId))
|
|
83
|
+
.expect(200);
|
|
84
|
+
|
|
85
|
+
expect(response.body).toMatchObject({
|
|
86
|
+
plan: 'free',
|
|
87
|
+
subscription_status: 'free',
|
|
88
|
+
billing_upgrades_enabled: false,
|
|
89
|
+
limits: {
|
|
90
|
+
agents: 3,
|
|
91
|
+
protected_resources: 2,
|
|
92
|
+
active_work_claims: 1,
|
|
93
|
+
api_calls_month: 1000,
|
|
94
|
+
activity_retention_days: 7,
|
|
95
|
+
},
|
|
96
|
+
usage: {
|
|
97
|
+
agents: 1,
|
|
98
|
+
protected_resources: 1,
|
|
99
|
+
active_work_claims: 1,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
expect(response.body.upgrade_reasons).toEqual(
|
|
103
|
+
expect.arrayContaining([
|
|
104
|
+
expect.objectContaining({ limit_type: 'active_work_claims', state: 'reached' }),
|
|
105
|
+
]),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
await api
|
|
109
|
+
.delete(`/v1/work/claims/${claim.body.claim.id}`)
|
|
110
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
111
|
+
.expect(200);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('free plan enforces agent limit with upgrade payload', async () => {
|
|
115
|
+
const workspace = await createOrgAndAgent('Agent Limit', 'generic', 0);
|
|
116
|
+
await createAgent(workspace.orgId, 'Second', 'generic', 0);
|
|
117
|
+
await createAgent(workspace.orgId, 'Third', 'generic', 0);
|
|
118
|
+
|
|
119
|
+
const response = await api
|
|
120
|
+
.post(`/v1/orgs/${workspace.orgId}/agents`)
|
|
121
|
+
.set('Cookie', getWorkspaceCookie(workspace.orgId))
|
|
122
|
+
.send({ name: 'Fourth', agent_type: 'generic', priority: 0 })
|
|
123
|
+
.expect(402);
|
|
124
|
+
|
|
125
|
+
expect(response.body).toMatchObject({
|
|
126
|
+
error: 'plan_limit_reached',
|
|
127
|
+
limit_type: 'agents',
|
|
128
|
+
plan: 'free',
|
|
129
|
+
limit: 3,
|
|
130
|
+
usage: 3,
|
|
131
|
+
upgrade_plan: 'individual',
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('free plan enforces protected resource and active work claim limits', async () => {
|
|
136
|
+
const workspace = await createOrgAndAgent('Work Limits', 'generic', 0);
|
|
137
|
+
|
|
138
|
+
const active = await api
|
|
139
|
+
.post('/v1/work/claim')
|
|
140
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
141
|
+
.send({ agent_id: workspace.agentId, resource_type: 'repo', resource_key: 'owner/active' })
|
|
142
|
+
.expect(201);
|
|
143
|
+
|
|
144
|
+
const activeBlocked = await api
|
|
145
|
+
.post('/v1/work/claim')
|
|
146
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
147
|
+
.send({ agent_id: workspace.agentId, resource_type: 'repo', resource_key: 'owner/blocked' })
|
|
148
|
+
.expect(402);
|
|
149
|
+
|
|
150
|
+
expect(activeBlocked.body).toMatchObject({
|
|
151
|
+
error: 'plan_limit_reached',
|
|
152
|
+
limit_type: 'active_work_claims',
|
|
153
|
+
usage: 1,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
await api
|
|
157
|
+
.delete(`/v1/work/claims/${active.body.claim.id}`)
|
|
158
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
159
|
+
.expect(200);
|
|
160
|
+
|
|
161
|
+
const second = await api
|
|
162
|
+
.post('/v1/work/claim')
|
|
163
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
164
|
+
.send({ agent_id: workspace.agentId, resource_type: 'repo', resource_key: 'owner/second' })
|
|
165
|
+
.expect(201);
|
|
166
|
+
await api
|
|
167
|
+
.delete(`/v1/work/claims/${second.body.claim.id}`)
|
|
168
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
169
|
+
.expect(200);
|
|
170
|
+
|
|
171
|
+
const resourceBlocked = await api
|
|
172
|
+
.post('/v1/work/claim')
|
|
173
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
174
|
+
.send({ agent_id: workspace.agentId, resource_type: 'repo', resource_key: 'owner/third' })
|
|
175
|
+
.expect(402);
|
|
176
|
+
|
|
177
|
+
expect(resourceBlocked.body).toMatchObject({
|
|
178
|
+
error: 'plan_limit_reached',
|
|
179
|
+
limit_type: 'protected_resources',
|
|
180
|
+
usage: 2,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('free plan enforces monthly runtime API call limit', async () => {
|
|
185
|
+
const workspace = await createOrgAndAgent('API Limit', 'generic', 0);
|
|
186
|
+
await pool.query(
|
|
187
|
+
`INSERT INTO agent_activity_events (org_id, agent_id, activity_type, status, created_at)
|
|
188
|
+
SELECT $1, $2, 'availability_check', 'success', NOW()
|
|
189
|
+
FROM generate_series(1, 1000)`,
|
|
190
|
+
[workspace.orgId, workspace.agentId],
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const response = await api
|
|
194
|
+
.get('/v1/availability')
|
|
195
|
+
.set('Authorization', `Bearer ${workspace.apiKey}`)
|
|
196
|
+
.query({
|
|
197
|
+
agent_id: workspace.agentId,
|
|
198
|
+
from: '2030-05-01T09:00:00Z',
|
|
199
|
+
to: '2030-05-01T10:00:00Z',
|
|
200
|
+
duration_minutes: 30,
|
|
201
|
+
})
|
|
202
|
+
.expect(402);
|
|
203
|
+
|
|
204
|
+
expect(response.body).toMatchObject({
|
|
205
|
+
error: 'plan_limit_reached',
|
|
206
|
+
limit_type: 'api_calls_month',
|
|
207
|
+
usage: 1000,
|
|
208
|
+
upgrade_plan: 'individual',
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('subscription endpoint returns the current org plan', async () => {
|
|
213
|
+
await pool.query('UPDATE orgs SET plan = $1, agent_limit = $2 WHERE id = $3', [
|
|
214
|
+
'team',
|
|
215
|
+
50,
|
|
216
|
+
orgId,
|
|
217
|
+
]);
|
|
218
|
+
|
|
219
|
+
const response = await api.get(`/v1/billing/subscription/${orgId}`).expect(200);
|
|
220
|
+
|
|
221
|
+
expect(response.body).toMatchObject({
|
|
222
|
+
org_id: orgId,
|
|
223
|
+
status: 'active',
|
|
224
|
+
plan: 'team',
|
|
225
|
+
agent_limit: 50,
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('signed checkout webhook upgrades the organization plan', async () => {
|
|
230
|
+
process.env.STRIPE_SECRET_KEY = 'sk_test_123';
|
|
231
|
+
process.env.STRIPE_WEBHOOK_SECRET = 'whsec_test_123';
|
|
232
|
+
|
|
233
|
+
const payload = JSON.stringify({
|
|
234
|
+
id: 'evt_test_checkout',
|
|
235
|
+
object: 'event',
|
|
236
|
+
type: 'checkout.session.completed',
|
|
237
|
+
data: {
|
|
238
|
+
object: {
|
|
239
|
+
id: 'cs_test_123',
|
|
240
|
+
object: 'checkout.session',
|
|
241
|
+
metadata: {
|
|
242
|
+
org_id: orgId,
|
|
243
|
+
plan: 'team',
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
|
249
|
+
const signature = stripe.webhooks.generateTestHeaderString({
|
|
250
|
+
payload,
|
|
251
|
+
secret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
await api
|
|
255
|
+
.post('/v1/billing/webhook')
|
|
256
|
+
.set('stripe-signature', signature)
|
|
257
|
+
.set('Content-Type', 'application/json')
|
|
258
|
+
.send(payload)
|
|
259
|
+
.expect(200);
|
|
260
|
+
|
|
261
|
+
const updated = await pool.query(
|
|
262
|
+
'SELECT plan, agent_limit, subscription_status, stripe_customer_id, stripe_subscription_id FROM orgs WHERE id = $1',
|
|
263
|
+
[orgId],
|
|
264
|
+
);
|
|
265
|
+
expect(updated.rows[0]).toMatchObject({
|
|
266
|
+
plan: 'team',
|
|
267
|
+
agent_limit: 9999,
|
|
268
|
+
subscription_status: 'active',
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test('subscription updated webhook stores status and period fields', async () => {
|
|
273
|
+
process.env.STRIPE_SECRET_KEY = 'sk_test_123';
|
|
274
|
+
process.env.STRIPE_WEBHOOK_SECRET = 'whsec_test_123';
|
|
275
|
+
const now = Math.floor(Date.now() / 1000);
|
|
276
|
+
|
|
277
|
+
const payload = JSON.stringify({
|
|
278
|
+
id: 'evt_test_subscription_updated',
|
|
279
|
+
object: 'event',
|
|
280
|
+
type: 'customer.subscription.updated',
|
|
281
|
+
data: {
|
|
282
|
+
object: {
|
|
283
|
+
id: 'sub_test',
|
|
284
|
+
object: 'subscription',
|
|
285
|
+
customer: 'cus_test',
|
|
286
|
+
status: 'past_due',
|
|
287
|
+
current_period_start: now,
|
|
288
|
+
current_period_end: now + 86400,
|
|
289
|
+
cancel_at_period_end: true,
|
|
290
|
+
metadata: {
|
|
291
|
+
org_id: orgId,
|
|
292
|
+
plan: 'individual',
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
|
298
|
+
const signature = stripe.webhooks.generateTestHeaderString({
|
|
299
|
+
payload,
|
|
300
|
+
secret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
await api
|
|
304
|
+
.post('/v1/billing/webhook')
|
|
305
|
+
.set('stripe-signature', signature)
|
|
306
|
+
.set('Content-Type', 'application/json')
|
|
307
|
+
.send(payload)
|
|
308
|
+
.expect(200);
|
|
309
|
+
|
|
310
|
+
const updated = await pool.query(
|
|
311
|
+
`SELECT plan, agent_limit, subscription_status, stripe_customer_id, stripe_subscription_id, current_period_end, cancel_at_period_end
|
|
312
|
+
FROM orgs
|
|
313
|
+
WHERE id = $1`,
|
|
314
|
+
[orgId],
|
|
315
|
+
);
|
|
316
|
+
expect(updated.rows[0]).toMatchObject({
|
|
317
|
+
plan: 'individual',
|
|
318
|
+
agent_limit: 15,
|
|
319
|
+
subscription_status: 'past_due',
|
|
320
|
+
stripe_customer_id: 'cus_test',
|
|
321
|
+
stripe_subscription_id: 'sub_test',
|
|
322
|
+
cancel_at_period_end: true,
|
|
323
|
+
});
|
|
324
|
+
expect(updated.rows[0].current_period_end).toBeTruthy();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test('subscription deleted webhook downgrades to free', async () => {
|
|
328
|
+
process.env.STRIPE_SECRET_KEY = 'sk_test_123';
|
|
329
|
+
process.env.STRIPE_WEBHOOK_SECRET = 'whsec_test_123';
|
|
330
|
+
await pool.query(
|
|
331
|
+
`UPDATE orgs
|
|
332
|
+
SET plan = 'team',
|
|
333
|
+
agent_limit = 9999,
|
|
334
|
+
subscription_status = 'active',
|
|
335
|
+
stripe_subscription_id = 'sub_test'
|
|
336
|
+
WHERE id = $1`,
|
|
337
|
+
[orgId],
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
const payload = JSON.stringify({
|
|
341
|
+
id: 'evt_test_subscription_deleted',
|
|
342
|
+
object: 'event',
|
|
343
|
+
type: 'customer.subscription.deleted',
|
|
344
|
+
data: {
|
|
345
|
+
object: {
|
|
346
|
+
id: 'sub_test',
|
|
347
|
+
object: 'subscription',
|
|
348
|
+
metadata: {
|
|
349
|
+
org_id: orgId,
|
|
350
|
+
plan: 'team',
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
|
|
356
|
+
const signature = stripe.webhooks.generateTestHeaderString({
|
|
357
|
+
payload,
|
|
358
|
+
secret: process.env.STRIPE_WEBHOOK_SECRET,
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
await api
|
|
362
|
+
.post('/v1/billing/webhook')
|
|
363
|
+
.set('stripe-signature', signature)
|
|
364
|
+
.set('Content-Type', 'application/json')
|
|
365
|
+
.send(payload)
|
|
366
|
+
.expect(200);
|
|
367
|
+
|
|
368
|
+
const updated = await pool.query(
|
|
369
|
+
'SELECT plan, agent_limit, subscription_status, stripe_subscription_id FROM orgs WHERE id = $1',
|
|
370
|
+
[orgId],
|
|
371
|
+
);
|
|
372
|
+
expect(updated.rows[0]).toMatchObject({
|
|
373
|
+
plan: 'free',
|
|
374
|
+
agent_limit: 3,
|
|
375
|
+
subscription_status: 'canceled',
|
|
376
|
+
stripe_subscription_id: null,
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test('webhook rejects invalid signatures', async () => {
|
|
381
|
+
process.env.STRIPE_SECRET_KEY = 'sk_test_123';
|
|
382
|
+
process.env.STRIPE_WEBHOOK_SECRET = 'whsec_test_123';
|
|
383
|
+
|
|
384
|
+
const response = await api
|
|
385
|
+
.post('/v1/billing/webhook')
|
|
386
|
+
.set('stripe-signature', 'invalid')
|
|
387
|
+
.set('Content-Type', 'application/json')
|
|
388
|
+
.send(JSON.stringify({}))
|
|
389
|
+
.expect(400);
|
|
390
|
+
|
|
391
|
+
expect(response.body).toEqual({ error: 'invalid_signature' });
|
|
392
|
+
});
|
|
393
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from '@jest/globals';
|
|
2
|
+
import {
|
|
3
|
+
api,
|
|
4
|
+
closeDatabase,
|
|
5
|
+
createAgent,
|
|
6
|
+
createOrgAndAgent,
|
|
7
|
+
createWindow,
|
|
8
|
+
migrateTestDatabase,
|
|
9
|
+
resetDatabase,
|
|
10
|
+
} from './helpers';
|
|
11
|
+
import pool from '../../src/db/client';
|
|
12
|
+
|
|
13
|
+
describe('conflict preview routes', () => {
|
|
14
|
+
let orgId: string;
|
|
15
|
+
let externalAgentId: string;
|
|
16
|
+
let externalApiKey: string;
|
|
17
|
+
let internalAgentId: string;
|
|
18
|
+
let internalApiKey: string;
|
|
19
|
+
|
|
20
|
+
beforeAll(async () => {
|
|
21
|
+
await migrateTestDatabase();
|
|
22
|
+
await resetDatabase();
|
|
23
|
+
const external = await createOrgAndAgent('External', 'external_meeting');
|
|
24
|
+
orgId = external.orgId;
|
|
25
|
+
externalAgentId = external.agentId;
|
|
26
|
+
externalApiKey = external.apiKey;
|
|
27
|
+
const internal = await createAgent(orgId, 'Internal', 'internal');
|
|
28
|
+
internalAgentId = internal.agentId;
|
|
29
|
+
internalApiKey = internal.apiKey;
|
|
30
|
+
await createWindow(externalAgentId, externalApiKey, '2030-02-01T09:00:00Z', '2030-02-01T17:00:00Z');
|
|
31
|
+
await createWindow(internalAgentId, internalApiKey, '2030-02-01T09:00:00Z', '2030-02-01T17:00:00Z');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterAll(async () => {
|
|
35
|
+
await resetDatabase();
|
|
36
|
+
await closeDatabase();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('returns available and does not mutate when no overlap exists', async () => {
|
|
40
|
+
const before = await pool.query('SELECT COUNT(*)::int AS count FROM holds');
|
|
41
|
+
|
|
42
|
+
const response = await api
|
|
43
|
+
.post('/v1/conflicts/check')
|
|
44
|
+
.set('Authorization', `Bearer ${externalApiKey}`)
|
|
45
|
+
.send({
|
|
46
|
+
agent_id: externalAgentId,
|
|
47
|
+
start_at: '2030-02-01T09:00:00Z',
|
|
48
|
+
end_at: '2030-02-01T09:30:00Z',
|
|
49
|
+
})
|
|
50
|
+
.expect(200);
|
|
51
|
+
|
|
52
|
+
const after = await pool.query('SELECT COUNT(*)::int AS count FROM holds');
|
|
53
|
+
expect(response.body).toMatchObject({
|
|
54
|
+
status: 'available',
|
|
55
|
+
would_create_hold: true,
|
|
56
|
+
winning_hold_id: null,
|
|
57
|
+
losing_hold_ids: [],
|
|
58
|
+
rule_applied: 'none',
|
|
59
|
+
});
|
|
60
|
+
expect(after.rows[0].count).toBe(before.rows[0].count);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('returns would_lose when an existing higher-priority hold wins', async () => {
|
|
64
|
+
const created = await api
|
|
65
|
+
.post('/v1/holds')
|
|
66
|
+
.set('Authorization', `Bearer ${externalApiKey}`)
|
|
67
|
+
.send({
|
|
68
|
+
agent_id: externalAgentId,
|
|
69
|
+
start_at: '2030-02-01T10:00:00Z',
|
|
70
|
+
end_at: '2030-02-01T10:30:00Z',
|
|
71
|
+
})
|
|
72
|
+
.expect(201);
|
|
73
|
+
|
|
74
|
+
const response = await api
|
|
75
|
+
.post('/v1/conflicts/check')
|
|
76
|
+
.set('Authorization', `Bearer ${internalApiKey}`)
|
|
77
|
+
.send({
|
|
78
|
+
agent_id: internalAgentId,
|
|
79
|
+
start_at: '2030-02-01T10:00:00Z',
|
|
80
|
+
end_at: '2030-02-01T10:30:00Z',
|
|
81
|
+
})
|
|
82
|
+
.expect(200);
|
|
83
|
+
|
|
84
|
+
expect(response.body).toMatchObject({
|
|
85
|
+
status: 'would_lose',
|
|
86
|
+
would_create_hold: false,
|
|
87
|
+
winning_hold_id: created.body.hold.id,
|
|
88
|
+
losing_hold_ids: [],
|
|
89
|
+
rule_applied: 'agent_type',
|
|
90
|
+
});
|
|
91
|
+
expect(response.body.suggested_alternatives).toHaveLength(3);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('returns would_win without superseding existing holds', async () => {
|
|
95
|
+
const created = await api
|
|
96
|
+
.post('/v1/holds')
|
|
97
|
+
.set('Authorization', `Bearer ${internalApiKey}`)
|
|
98
|
+
.send({
|
|
99
|
+
agent_id: internalAgentId,
|
|
100
|
+
start_at: '2030-02-01T11:00:00Z',
|
|
101
|
+
end_at: '2030-02-01T11:30:00Z',
|
|
102
|
+
})
|
|
103
|
+
.expect(201);
|
|
104
|
+
|
|
105
|
+
const response = await api
|
|
106
|
+
.post('/v1/conflicts/check')
|
|
107
|
+
.set('Authorization', `Bearer ${externalApiKey}`)
|
|
108
|
+
.send({
|
|
109
|
+
agent_id: externalAgentId,
|
|
110
|
+
start_at: '2030-02-01T11:00:00Z',
|
|
111
|
+
end_at: '2030-02-01T11:30:00Z',
|
|
112
|
+
})
|
|
113
|
+
.expect(200);
|
|
114
|
+
|
|
115
|
+
const existing = await pool.query('SELECT status FROM holds WHERE id = $1', [created.body.hold.id]);
|
|
116
|
+
const eventCount = await pool.query(
|
|
117
|
+
'SELECT COUNT(*)::int AS count FROM hold_events WHERE hold_id = $1',
|
|
118
|
+
[created.body.hold.id],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
expect(response.body).toMatchObject({
|
|
122
|
+
status: 'would_win',
|
|
123
|
+
would_create_hold: true,
|
|
124
|
+
winning_hold_id: null,
|
|
125
|
+
losing_hold_ids: [created.body.hold.id],
|
|
126
|
+
rule_applied: 'agent_type',
|
|
127
|
+
});
|
|
128
|
+
expect(existing.rows[0].status).toBe('confirmed');
|
|
129
|
+
expect(eventCount.rows[0].count).toBe(1);
|
|
130
|
+
});
|
|
131
|
+
});
|