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
package/tests/setup.ts
ADDED
package/tests/smoke.sh
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
BASE="http://localhost:3000"
|
|
4
|
+
ERRORS=0
|
|
5
|
+
|
|
6
|
+
check() {
|
|
7
|
+
local desc=$1
|
|
8
|
+
local expected=$2
|
|
9
|
+
local actual=$3
|
|
10
|
+
if [ "$actual" = "$expected" ]; then
|
|
11
|
+
echo "OK: $desc"
|
|
12
|
+
else
|
|
13
|
+
echo "FAIL: $desc (expected $expected, got $actual)"
|
|
14
|
+
ERRORS=$((ERRORS + 1))
|
|
15
|
+
fi
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
echo "=== Availsync Smoke Tests ==="
|
|
19
|
+
|
|
20
|
+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" $BASE/health)
|
|
21
|
+
check "Health endpoint" "200" "$STATUS"
|
|
22
|
+
|
|
23
|
+
ORG_RESPONSE=$(curl -s -X POST $BASE/v1/orgs \
|
|
24
|
+
-H "Content-Type: application/json" \
|
|
25
|
+
-d '{"name": "Test Org"}')
|
|
26
|
+
ORG_ID=$(echo $ORG_RESPONSE | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
|
|
27
|
+
check "Create org returns id" "true" "$([ -n "$ORG_ID" ] && echo true || echo false)"
|
|
28
|
+
|
|
29
|
+
AGENT_RESPONSE=$(curl -s -X POST $BASE/v1/orgs/$ORG_ID/agents \
|
|
30
|
+
-H "Content-Type: application/json" \
|
|
31
|
+
-d '{"name": "Sales Bot", "agent_type": "external_meeting"}')
|
|
32
|
+
API_KEY=$(echo $AGENT_RESPONSE | grep -o '"api_key":"[^"]*"' | cut -d'"' -f4)
|
|
33
|
+
AGENT_ID=$(echo $AGENT_RESPONSE | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
|
|
34
|
+
check "Create agent returns api_key" "true" "$([ -n "$API_KEY" ] && echo true || echo false)"
|
|
35
|
+
|
|
36
|
+
TOMORROW=$(date -d "+1 day" +%Y-%m-%dT09:00:00Z 2>/dev/null || date -v+1d +%Y-%m-%dT09:00:00Z)
|
|
37
|
+
TOMORROW_END=$(date -d "+1 day" +%Y-%m-%dT17:00:00Z 2>/dev/null || date -v+1d +%Y-%m-%dT17:00:00Z)
|
|
38
|
+
WIN_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST $BASE/v1/availability-windows \
|
|
39
|
+
-H "Authorization: Bearer $API_KEY" \
|
|
40
|
+
-H "Content-Type: application/json" \
|
|
41
|
+
-d "{\"agent_id\":\"$AGENT_ID\",\"start_at\":\"$TOMORROW\",\"end_at\":\"$TOMORROW_END\",\"window_type\":\"available\"}")
|
|
42
|
+
check "Create availability window" "201" "$WIN_STATUS"
|
|
43
|
+
|
|
44
|
+
AVAIL_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
45
|
+
"$BASE/v1/availability?agent_id=$AGENT_ID&from=$TOMORROW&to=$TOMORROW_END&duration_minutes=30" \
|
|
46
|
+
-H "Authorization: Bearer $API_KEY")
|
|
47
|
+
check "Get availability" "200" "$AVAIL_STATUS"
|
|
48
|
+
|
|
49
|
+
HOLD_END=$(date -d "+1 day" +%Y-%m-%dT10:00:00Z 2>/dev/null || date -v+1d +%Y-%m-%dT10:00:00Z)
|
|
50
|
+
HOLD_RESPONSE=$(curl -s -X POST $BASE/v1/holds \
|
|
51
|
+
-H "Authorization: Bearer $API_KEY" \
|
|
52
|
+
-H "Content-Type: application/json" \
|
|
53
|
+
-d "{\"agent_id\":\"$AGENT_ID\",\"start_at\":\"$TOMORROW\",\"end_at\":\"$HOLD_END\",\"reason\":\"Test booking\"}")
|
|
54
|
+
HOLD_STATUS=$(echo $HOLD_RESPONSE | grep -o '"status":"[^"]*"' | head -1 | cut -d'"' -f4)
|
|
55
|
+
check "Book hold returns confirmed status" "confirmed" "$HOLD_STATUS"
|
|
56
|
+
|
|
57
|
+
UNAUTH_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $BASE/v1/availability?agent_id=$AGENT_ID)
|
|
58
|
+
check "Unauthenticated request returns 401" "401" "$UNAUTH_STATUS"
|
|
59
|
+
|
|
60
|
+
echo ""
|
|
61
|
+
echo "=== Results: $ERRORS failure(s) ==="
|
|
62
|
+
exit $ERRORS
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, jest, test } from '@jest/globals';
|
|
2
|
+
import type { NextFunction, Response } from 'express';
|
|
3
|
+
import { authMiddleware, type AuthenticatedRequest } from '../../src/middleware/auth';
|
|
4
|
+
import pool from '../../src/db/client';
|
|
5
|
+
import bcrypt from 'bcrypt';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../src/db/client', () => ({
|
|
8
|
+
__esModule: true,
|
|
9
|
+
default: {
|
|
10
|
+
query: jest.fn(),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('bcrypt', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
default: {
|
|
17
|
+
compare: jest.fn(),
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const response = () => {
|
|
22
|
+
const res = {
|
|
23
|
+
status: jest.fn().mockReturnThis(),
|
|
24
|
+
json: jest.fn().mockReturnThis(),
|
|
25
|
+
};
|
|
26
|
+
return res as unknown as Response;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe('authMiddleware', () => {
|
|
30
|
+
const validToken = `avs_live_${'a'.repeat(16)}_${'b'.repeat(64)}`;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
jest.clearAllMocks();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('returns 401 when Authorization header is missing', async () => {
|
|
37
|
+
const req = { header: jest.fn().mockReturnValue(undefined) } as unknown as AuthenticatedRequest;
|
|
38
|
+
const res = response();
|
|
39
|
+
const next = jest.fn() as unknown as NextFunction;
|
|
40
|
+
|
|
41
|
+
await authMiddleware(req, res, next);
|
|
42
|
+
|
|
43
|
+
expect(res.status).toHaveBeenCalledWith(401);
|
|
44
|
+
expect(res.json).toHaveBeenCalledWith({ error: 'missing_auth' });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('returns 401 when prefix lookup misses but still runs dummy bcrypt compare', async () => {
|
|
48
|
+
jest.mocked(pool.query).mockResolvedValueOnce({ rows: [] } as never);
|
|
49
|
+
jest.mocked(bcrypt.compare).mockResolvedValueOnce(false as never);
|
|
50
|
+
const req = { header: jest.fn().mockReturnValue(`Bearer ${validToken}`) } as unknown as AuthenticatedRequest;
|
|
51
|
+
const res = response();
|
|
52
|
+
const next = jest.fn() as unknown as NextFunction;
|
|
53
|
+
|
|
54
|
+
await authMiddleware(req, res, next);
|
|
55
|
+
|
|
56
|
+
expect(res.status).toHaveBeenCalledWith(401);
|
|
57
|
+
expect(res.json).toHaveBeenCalledWith({ error: 'invalid_key' });
|
|
58
|
+
expect(String(jest.mocked(pool.query).mock.calls[0][0])).toContain('agents.api_key_prefix = $1');
|
|
59
|
+
expect(jest.mocked(pool.query).mock.calls[0][1]).toEqual(['a'.repeat(16)]);
|
|
60
|
+
expect(bcrypt.compare).toHaveBeenCalledTimes(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('sets req.agent and req.org for a valid prefixed bearer token using one row lookup', async () => {
|
|
64
|
+
jest.mocked(pool.query).mockResolvedValueOnce({
|
|
65
|
+
rows: [
|
|
66
|
+
{
|
|
67
|
+
agent_id: 'agent-1',
|
|
68
|
+
agent_name: 'Sales Bot',
|
|
69
|
+
api_key_hash: 'hash',
|
|
70
|
+
agent_type: 'external_meeting',
|
|
71
|
+
priority: 10,
|
|
72
|
+
enforcement_mode: 'enforce',
|
|
73
|
+
last_seen_at: null,
|
|
74
|
+
mcp_last_seen_at: null,
|
|
75
|
+
mcp_client_name: null,
|
|
76
|
+
agent_created_at: new Date('2026-01-01T00:00:00Z'),
|
|
77
|
+
org_id: 'org-1',
|
|
78
|
+
org_name: 'Org',
|
|
79
|
+
plan: 'free',
|
|
80
|
+
agent_limit: 3,
|
|
81
|
+
org_created_at: new Date('2026-01-01T00:00:00Z'),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
} as never);
|
|
85
|
+
jest.mocked(bcrypt.compare).mockResolvedValueOnce(true as never);
|
|
86
|
+
const req = { header: jest.fn().mockReturnValue(`Bearer ${validToken}`) } as unknown as AuthenticatedRequest;
|
|
87
|
+
const res = response();
|
|
88
|
+
const next = jest.fn() as unknown as NextFunction;
|
|
89
|
+
|
|
90
|
+
await authMiddleware(req, res, next);
|
|
91
|
+
|
|
92
|
+
expect(req.agent.id).toBe('agent-1');
|
|
93
|
+
expect(req.org.id).toBe('org-1');
|
|
94
|
+
expect(next).toHaveBeenCalledTimes(1);
|
|
95
|
+
expect(jest.mocked(pool.query)).toHaveBeenCalledTimes(2);
|
|
96
|
+
expect(jest.mocked(pool.query).mock.calls[0][1]).toEqual(['a'.repeat(16)]);
|
|
97
|
+
expect(String(jest.mocked(pool.query).mock.calls[1][0])).toContain('last_seen_at');
|
|
98
|
+
expect(jest.mocked(pool.query).mock.calls[1][1]).toEqual(['agent-1']);
|
|
99
|
+
expect(bcrypt.compare).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('invalid key format is rejected before database or bcrypt work', async () => {
|
|
103
|
+
const req = { header: jest.fn().mockReturnValue('Bearer avs_live_bad') } as unknown as AuthenticatedRequest;
|
|
104
|
+
const res = response();
|
|
105
|
+
const next = jest.fn() as unknown as NextFunction;
|
|
106
|
+
|
|
107
|
+
await authMiddleware(req, res, next);
|
|
108
|
+
|
|
109
|
+
expect(pool.query).not.toHaveBeenCalled();
|
|
110
|
+
expect(bcrypt.compare).not.toHaveBeenCalled();
|
|
111
|
+
expect(res.status).toHaveBeenCalledWith(401);
|
|
112
|
+
expect(res.json).toHaveBeenCalledWith({ error: 'invalid_key' });
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { describe, expect, jest, test } from '@jest/globals';
|
|
2
|
+
import { getAvailableSlots } from '../../src/core/availability';
|
|
3
|
+
|
|
4
|
+
type Query = { rows: unknown[] };
|
|
5
|
+
|
|
6
|
+
const mockClient = (results: Query[]) => {
|
|
7
|
+
let index = 0;
|
|
8
|
+
return {
|
|
9
|
+
query: jest.fn(async () => results[index++]),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const defaults = {
|
|
14
|
+
agent_id: 'agent-1',
|
|
15
|
+
buffer_minutes_after: 0,
|
|
16
|
+
buffer_minutes_before: 0,
|
|
17
|
+
focus_blocks: [],
|
|
18
|
+
priority_over_agents: [],
|
|
19
|
+
booking_window_days: 30,
|
|
20
|
+
allow_back_to_back: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const window = {
|
|
24
|
+
id: 'window-1',
|
|
25
|
+
agent_id: 'agent-1',
|
|
26
|
+
start_at: new Date('2026-05-12T09:00:00Z'),
|
|
27
|
+
end_at: new Date('2026-05-12T10:00:00Z'),
|
|
28
|
+
window_type: 'available',
|
|
29
|
+
recurrence: null,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const params = {
|
|
33
|
+
agent_id: 'agent-1',
|
|
34
|
+
org_id: 'org-1',
|
|
35
|
+
from: new Date('2026-05-12T09:00:00Z'),
|
|
36
|
+
to: new Date('2026-05-12T10:00:00Z'),
|
|
37
|
+
duration_minutes: 30,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
describe('getAvailableSlots', () => {
|
|
41
|
+
test('returns slots inside an availability window', async () => {
|
|
42
|
+
const client = mockClient([
|
|
43
|
+
{ rows: [window] },
|
|
44
|
+
{ rows: [defaults] },
|
|
45
|
+
{ rows: [] },
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
const slots = await getAvailableSlots(params, client as never);
|
|
49
|
+
|
|
50
|
+
expect(slots.map((slot) => slot.start.toISOString())).toEqual([
|
|
51
|
+
'2026-05-12T09:00:00.000Z',
|
|
52
|
+
'2026-05-12T09:30:00.000Z',
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('filters slots overlapping a hold', async () => {
|
|
57
|
+
const client = mockClient([
|
|
58
|
+
{ rows: [window] },
|
|
59
|
+
{ rows: [defaults] },
|
|
60
|
+
{
|
|
61
|
+
rows: [
|
|
62
|
+
{
|
|
63
|
+
agent_id: 'agent-1',
|
|
64
|
+
start_at: new Date('2026-05-12T09:30:00Z'),
|
|
65
|
+
end_at: new Date('2026-05-12T10:00:00Z'),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
const slots = await getAvailableSlots(params, client as never);
|
|
72
|
+
|
|
73
|
+
expect(slots).toHaveLength(1);
|
|
74
|
+
expect(slots[0].start.toISOString()).toBe('2026-05-12T09:00:00.000Z');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('buffer time removes slots near holds', async () => {
|
|
78
|
+
const client = mockClient([
|
|
79
|
+
{ rows: [window] },
|
|
80
|
+
{ rows: [{ ...defaults, buffer_minutes_after: 15 }] },
|
|
81
|
+
{
|
|
82
|
+
rows: [
|
|
83
|
+
{
|
|
84
|
+
agent_id: 'agent-1',
|
|
85
|
+
start_at: new Date('2026-05-12T09:00:00Z'),
|
|
86
|
+
end_at: new Date('2026-05-12T09:30:00Z'),
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
const slots = await getAvailableSlots(params, client as never);
|
|
93
|
+
|
|
94
|
+
expect(slots).toHaveLength(0);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('focus block removes overlapping slots', async () => {
|
|
98
|
+
const client = mockClient([
|
|
99
|
+
{ rows: [window] },
|
|
100
|
+
{
|
|
101
|
+
rows: [
|
|
102
|
+
{
|
|
103
|
+
...defaults,
|
|
104
|
+
focus_blocks: [{ weekday: 2, start_time: '09:00', end_time: '09:45' }],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{ rows: [] },
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
const slots = await getAvailableSlots(params, client as never);
|
|
112
|
+
|
|
113
|
+
expect(slots).toHaveLength(0);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('calculates confidence from nearby competing holds', async () => {
|
|
117
|
+
const client = mockClient([
|
|
118
|
+
{ rows: [window] },
|
|
119
|
+
{ rows: [defaults] },
|
|
120
|
+
{
|
|
121
|
+
rows: [
|
|
122
|
+
{
|
|
123
|
+
agent_id: 'agent-2',
|
|
124
|
+
start_at: new Date('2026-05-12T10:00:00Z'),
|
|
125
|
+
end_at: new Date('2026-05-12T10:30:00Z'),
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
|
|
131
|
+
const slots = await getAvailableSlots(
|
|
132
|
+
{ ...params, include_competing_agents: true },
|
|
133
|
+
client as never,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
expect(slots[1]).toMatchObject({
|
|
137
|
+
confidence: 0.85,
|
|
138
|
+
competing_holds_count: 1,
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('returns an empty list when no slots are available', async () => {
|
|
143
|
+
const client = mockClient([{ rows: [] }, { rows: [defaults] }, { rows: [] }]);
|
|
144
|
+
|
|
145
|
+
const slots = await getAvailableSlots(params, client as never);
|
|
146
|
+
|
|
147
|
+
expect(slots).toEqual([]);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { describe, expect, test } from '@jest/globals';
|
|
2
|
+
import { determineWinner } from '../../src/core/conflict';
|
|
3
|
+
import type { Agent, AgentPreferences, Hold } from '../../src/types';
|
|
4
|
+
|
|
5
|
+
const hold = (id: string, agentId: string, createdAt: string): Hold => ({
|
|
6
|
+
id,
|
|
7
|
+
agent_id: agentId,
|
|
8
|
+
org_id: 'org-1',
|
|
9
|
+
start_at: new Date('2026-05-12T10:00:00Z'),
|
|
10
|
+
end_at: new Date('2026-05-12T11:00:00Z'),
|
|
11
|
+
status: 'confirmed',
|
|
12
|
+
created_at: new Date(createdAt),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const agent = (
|
|
16
|
+
id: string,
|
|
17
|
+
agent_type: Agent['agent_type'],
|
|
18
|
+
priority = 0,
|
|
19
|
+
): Agent => ({
|
|
20
|
+
id,
|
|
21
|
+
org_id: 'org-1',
|
|
22
|
+
name: id,
|
|
23
|
+
api_key_hash: 'hash',
|
|
24
|
+
agent_type,
|
|
25
|
+
priority,
|
|
26
|
+
enforcement_mode: 'enforce',
|
|
27
|
+
created_at: new Date('2026-01-01T00:00:00Z'),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const prefs = (
|
|
31
|
+
agentId: string,
|
|
32
|
+
priorityOverAgents: string[] = [],
|
|
33
|
+
): AgentPreferences => ({
|
|
34
|
+
agent_id: agentId,
|
|
35
|
+
buffer_minutes_after: 15,
|
|
36
|
+
buffer_minutes_before: 0,
|
|
37
|
+
focus_blocks: [],
|
|
38
|
+
priority_over_agents: priorityOverAgents,
|
|
39
|
+
booking_window_days: 30,
|
|
40
|
+
allow_back_to_back: false,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('determineWinner', () => {
|
|
44
|
+
test('agent_type hierarchy decides when there is no explicit priority override', () => {
|
|
45
|
+
const external = agent('external', 'external_meeting');
|
|
46
|
+
const generic = agent('generic', 'generic', 10);
|
|
47
|
+
|
|
48
|
+
const winner = determineWinner(
|
|
49
|
+
hold('hold-a', external.id, '2026-05-01T10:00:00Z'),
|
|
50
|
+
external,
|
|
51
|
+
hold('hold-b', generic.id, '2026-05-01T09:00:00Z'),
|
|
52
|
+
generic,
|
|
53
|
+
[prefs(external.id), prefs(generic.id)],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(winner.id).toBe('hold-a');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('external_meeting wins over internal', () => {
|
|
60
|
+
const external = agent('external', 'external_meeting');
|
|
61
|
+
const internal = agent('internal', 'internal');
|
|
62
|
+
|
|
63
|
+
const winner = determineWinner(
|
|
64
|
+
hold('hold-a', internal.id, '2026-05-01T09:00:00Z'),
|
|
65
|
+
internal,
|
|
66
|
+
hold('hold-b', external.id, '2026-05-01T10:00:00Z'),
|
|
67
|
+
external,
|
|
68
|
+
[prefs(internal.id), prefs(external.id)],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(winner.id).toBe('hold-b');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('priority field decides when agent_type is tied', () => {
|
|
75
|
+
const low = agent('low', 'internal', 1);
|
|
76
|
+
const high = agent('high', 'internal', 5);
|
|
77
|
+
|
|
78
|
+
const winner = determineWinner(
|
|
79
|
+
hold('hold-a', low.id, '2026-05-01T09:00:00Z'),
|
|
80
|
+
low,
|
|
81
|
+
hold('hold-b', high.id, '2026-05-01T10:00:00Z'),
|
|
82
|
+
high,
|
|
83
|
+
[prefs(low.id), prefs(high.id)],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(winner.id).toBe('hold-b');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('oldest hold wins a complete tie', () => {
|
|
90
|
+
const first = agent('first', 'internal', 1);
|
|
91
|
+
const second = agent('second', 'internal', 1);
|
|
92
|
+
|
|
93
|
+
const winner = determineWinner(
|
|
94
|
+
hold('hold-a', first.id, '2026-05-01T09:00:00Z'),
|
|
95
|
+
first,
|
|
96
|
+
hold('hold-b', second.id, '2026-05-01T10:00:00Z'),
|
|
97
|
+
second,
|
|
98
|
+
[prefs(first.id), prefs(second.id)],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(winner.id).toBe('hold-a');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('explicit priority_over_agents overrides all other rules', () => {
|
|
105
|
+
const generic = agent('generic', 'generic', 0);
|
|
106
|
+
const external = agent('external', 'external_meeting', 100);
|
|
107
|
+
|
|
108
|
+
const winner = determineWinner(
|
|
109
|
+
hold('hold-a', generic.id, '2026-05-01T10:00:00Z'),
|
|
110
|
+
generic,
|
|
111
|
+
hold('hold-b', external.id, '2026-05-01T09:00:00Z'),
|
|
112
|
+
external,
|
|
113
|
+
[prefs(generic.id, [external.id]), prefs(external.id)],
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
expect(winner.id).toBe('hold-a');
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, expect, test, beforeEach, afterEach } from '@jest/globals';
|
|
2
|
+
import { envReadiness, requiredEnvNames, stripeReadiness } from '../../src/lib/env';
|
|
3
|
+
|
|
4
|
+
describe('environment readiness', () => {
|
|
5
|
+
const originalEnv = process.env;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
process.env = { ...originalEnv };
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
process.env = originalEnv;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('production env requires deploy configuration but not billing when upgrades are disabled', () => {
|
|
16
|
+
delete process.env.BILLING_UPGRADES_ENABLED;
|
|
17
|
+
const names = requiredEnvNames(true);
|
|
18
|
+
|
|
19
|
+
expect(names).toEqual(
|
|
20
|
+
expect.arrayContaining([
|
|
21
|
+
'DATABASE_URL',
|
|
22
|
+
'SESSION_SECRET',
|
|
23
|
+
'API_KEY_SALT_ROUNDS',
|
|
24
|
+
'APP_URL',
|
|
25
|
+
'CORS_ORIGINS',
|
|
26
|
+
'ADMIN_EMAILS',
|
|
27
|
+
]),
|
|
28
|
+
);
|
|
29
|
+
expect(names).not.toEqual(expect.arrayContaining(['STRIPE_SECRET_KEY', 'STRIPE_WEBHOOK_SECRET']));
|
|
30
|
+
expect(names).not.toContain('PORT');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('production env requires Stripe configuration when billing upgrades are enabled', () => {
|
|
34
|
+
process.env.BILLING_UPGRADES_ENABLED = 'true';
|
|
35
|
+
const names = requiredEnvNames(true);
|
|
36
|
+
|
|
37
|
+
expect(names).toEqual(
|
|
38
|
+
expect.arrayContaining([
|
|
39
|
+
'STRIPE_SECRET_KEY',
|
|
40
|
+
'STRIPE_WEBHOOK_SECRET',
|
|
41
|
+
'STRIPE_PRICE_INDIVIDUAL',
|
|
42
|
+
'STRIPE_PRICE_TEAM',
|
|
43
|
+
]),
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('readiness reports missing env names without values', () => {
|
|
48
|
+
delete process.env.DATABASE_URL;
|
|
49
|
+
process.env.SESSION_SECRET = 'secret-value';
|
|
50
|
+
process.env.API_KEY_SALT_ROUNDS = '10';
|
|
51
|
+
|
|
52
|
+
const readiness = envReadiness(false);
|
|
53
|
+
|
|
54
|
+
expect(readiness.ok).toBe(false);
|
|
55
|
+
expect(readiness.missing).toContain('DATABASE_URL');
|
|
56
|
+
expect(JSON.stringify(readiness)).not.toContain('secret-value');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('stripe readiness only reports configured booleans', () => {
|
|
60
|
+
process.env.STRIPE_SECRET_KEY = 'sk_test_hidden';
|
|
61
|
+
delete process.env.STRIPE_WEBHOOK_SECRET;
|
|
62
|
+
|
|
63
|
+
expect(stripeReadiness()).toMatchObject({
|
|
64
|
+
configured: true,
|
|
65
|
+
webhook_configured: false,
|
|
66
|
+
});
|
|
67
|
+
expect(JSON.stringify(stripeReadiness())).not.toContain('sk_test_hidden');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { afterEach, describe, expect, test } from '@jest/globals';
|
|
5
|
+
import type { Pool, PoolClient } from 'pg';
|
|
6
|
+
import { runMigrations } from '../../src/db/migrations';
|
|
7
|
+
|
|
8
|
+
type MigrationRecord = {
|
|
9
|
+
filename: string;
|
|
10
|
+
checksum: string;
|
|
11
|
+
status: 'running' | 'applied' | 'failed';
|
|
12
|
+
error_message: string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function tempMigrationsDir() {
|
|
16
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), 'availsync-migrations-'));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function createMockDb() {
|
|
20
|
+
const records = new Map<string, MigrationRecord>();
|
|
21
|
+
const executedSql: string[] = [];
|
|
22
|
+
const queries: string[] = [];
|
|
23
|
+
|
|
24
|
+
const client = {
|
|
25
|
+
query: jest.fn(async (sql: string, params: unknown[] = []) => {
|
|
26
|
+
const text = String(sql);
|
|
27
|
+
queries.push(text);
|
|
28
|
+
|
|
29
|
+
if (text.includes('SELECT pg_advisory_lock') || text.includes('SELECT pg_advisory_unlock')) {
|
|
30
|
+
return { rows: [] };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (text.includes('CREATE TABLE IF NOT EXISTS schema_migrations')) {
|
|
34
|
+
return { rows: [] };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (text.includes('FROM schema_migrations') && text.includes('WHERE filename = $1')) {
|
|
38
|
+
const record = records.get(params[0] as string);
|
|
39
|
+
return { rows: record ? [record] : [] };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (text.includes('INSERT INTO schema_migrations')) {
|
|
43
|
+
records.set(params[0] as string, {
|
|
44
|
+
filename: params[0] as string,
|
|
45
|
+
checksum: params[1] as string,
|
|
46
|
+
status: 'running',
|
|
47
|
+
error_message: null,
|
|
48
|
+
});
|
|
49
|
+
return { rows: [] };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (text.includes("SET status = 'applied'")) {
|
|
53
|
+
const filename = params[0] as string;
|
|
54
|
+
const record = records.get(filename);
|
|
55
|
+
if (record) {
|
|
56
|
+
record.status = 'applied';
|
|
57
|
+
record.error_message = null;
|
|
58
|
+
}
|
|
59
|
+
return { rows: [] };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (text.includes("SET status = 'failed'")) {
|
|
63
|
+
const filename = params[0] as string;
|
|
64
|
+
const record = records.get(filename);
|
|
65
|
+
if (record) {
|
|
66
|
+
record.status = 'failed';
|
|
67
|
+
record.error_message = params[1] as string;
|
|
68
|
+
}
|
|
69
|
+
return { rows: [] };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (text === 'BEGIN' || text === 'COMMIT' || text === 'ROLLBACK') {
|
|
73
|
+
return { rows: [] };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (text.includes('BROKEN')) {
|
|
77
|
+
throw new Error('syntax error at or near "BROKEN"');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
executedSql.push(text);
|
|
81
|
+
return { rows: [] };
|
|
82
|
+
}),
|
|
83
|
+
release: jest.fn(),
|
|
84
|
+
} as unknown as PoolClient;
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
db: {
|
|
88
|
+
connect: jest.fn(async () => client),
|
|
89
|
+
} as unknown as Pool,
|
|
90
|
+
client,
|
|
91
|
+
records,
|
|
92
|
+
executedSql,
|
|
93
|
+
queries,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
describe('migration runner', () => {
|
|
98
|
+
const dirs: string[] = [];
|
|
99
|
+
|
|
100
|
+
afterEach(() => {
|
|
101
|
+
for (const dir of dirs.splice(0)) {
|
|
102
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('records successful migrations once and skips them on the second run', async () => {
|
|
107
|
+
const dir = tempMigrationsDir();
|
|
108
|
+
dirs.push(dir);
|
|
109
|
+
fs.writeFileSync(path.join(dir, '001_demo.sql'), 'CREATE TABLE demo (id int);');
|
|
110
|
+
const { db, records, executedSql, queries } = createMockDb();
|
|
111
|
+
|
|
112
|
+
await runMigrations(db, dir);
|
|
113
|
+
await runMigrations(db, dir);
|
|
114
|
+
|
|
115
|
+
expect(records.get('001_demo.sql')?.status).toBe('applied');
|
|
116
|
+
expect(executedSql).toEqual(['CREATE TABLE demo (id int);']);
|
|
117
|
+
expect(queries.filter((query) => query.includes('SELECT pg_advisory_lock'))).toHaveLength(2);
|
|
118
|
+
expect(queries.filter((query) => query.includes('SELECT pg_advisory_unlock'))).toHaveLength(2);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('records failed migrations and throws a clear filename-specific error', async () => {
|
|
122
|
+
const dir = tempMigrationsDir();
|
|
123
|
+
dirs.push(dir);
|
|
124
|
+
fs.writeFileSync(path.join(dir, '001_broken.sql'), 'BROKEN');
|
|
125
|
+
const { db, records } = createMockDb();
|
|
126
|
+
|
|
127
|
+
await expect(runMigrations(db, dir)).rejects.toThrow(
|
|
128
|
+
'Migration failed in 001_broken.sql: syntax error at or near "BROKEN"',
|
|
129
|
+
);
|
|
130
|
+
expect(records.get('001_broken.sql')).toMatchObject({
|
|
131
|
+
status: 'failed',
|
|
132
|
+
error_message: 'syntax error at or near "BROKEN"',
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, test } from '@jest/globals';
|
|
2
|
+
import type { Request, Response } from 'express';
|
|
3
|
+
import { requestIdMiddleware, REQUEST_ID_HEADER } from '../../src/middleware/requestId';
|
|
4
|
+
|
|
5
|
+
describe('request id middleware', () => {
|
|
6
|
+
test('sets a response header and local request id', () => {
|
|
7
|
+
const req = {
|
|
8
|
+
header: () => undefined,
|
|
9
|
+
} as unknown as Request;
|
|
10
|
+
const res = {
|
|
11
|
+
locals: {},
|
|
12
|
+
setHeader: jest.fn(),
|
|
13
|
+
} as unknown as Response;
|
|
14
|
+
const next = jest.fn();
|
|
15
|
+
|
|
16
|
+
requestIdMiddleware(req, res, next);
|
|
17
|
+
|
|
18
|
+
expect(next).toHaveBeenCalled();
|
|
19
|
+
expect(res.locals.requestId).toEqual(expect.any(String));
|
|
20
|
+
expect(res.setHeader).toHaveBeenCalledWith(REQUEST_ID_HEADER, res.locals.requestId);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('accepts a bounded incoming request id', () => {
|
|
24
|
+
const req = {
|
|
25
|
+
header: () => 'external-request-id',
|
|
26
|
+
} as unknown as Request;
|
|
27
|
+
const res = {
|
|
28
|
+
locals: {},
|
|
29
|
+
setHeader: jest.fn(),
|
|
30
|
+
} as unknown as Response;
|
|
31
|
+
|
|
32
|
+
requestIdMiddleware(req, res, jest.fn());
|
|
33
|
+
|
|
34
|
+
expect(res.locals.requestId).toBe('external-request-id');
|
|
35
|
+
expect(res.setHeader).toHaveBeenCalledWith(REQUEST_ID_HEADER, 'external-request-id');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
Binary file
|