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,745 @@
|
|
|
1
|
+
import { afterAll, beforeEach, describe, expect, test } from '@jest/globals';
|
|
2
|
+
import pool from '../../src/db/client';
|
|
3
|
+
import {
|
|
4
|
+
api,
|
|
5
|
+
closeDatabase,
|
|
6
|
+
createAgent,
|
|
7
|
+
createOrgAndAgent,
|
|
8
|
+
getWorkspaceCookie,
|
|
9
|
+
migrateTestDatabase,
|
|
10
|
+
resetDatabase,
|
|
11
|
+
} from './helpers';
|
|
12
|
+
|
|
13
|
+
describe('work coordination routes', () => {
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
await migrateTestDatabase();
|
|
16
|
+
await resetDatabase();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterAll(async () => {
|
|
20
|
+
await resetDatabase();
|
|
21
|
+
await closeDatabase();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('work/check returns available without mutating claims', async () => {
|
|
25
|
+
const { agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
26
|
+
|
|
27
|
+
const response = await api
|
|
28
|
+
.post('/v1/work/check')
|
|
29
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
30
|
+
.send({
|
|
31
|
+
agent_id: agentId,
|
|
32
|
+
resource_type: 'repo',
|
|
33
|
+
resource_key: 'owner/repo',
|
|
34
|
+
duration_minutes: 45,
|
|
35
|
+
})
|
|
36
|
+
.expect(200);
|
|
37
|
+
|
|
38
|
+
expect(response.body.status).toBe('available');
|
|
39
|
+
expect(response.body.resource.resource_key).toBe('owner/repo');
|
|
40
|
+
|
|
41
|
+
const claims = await pool.query('SELECT * FROM work_claims');
|
|
42
|
+
expect(claims.rowCount).toBe(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('work/claim blocks lower priority agent on same resource', async () => {
|
|
46
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 10);
|
|
47
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
48
|
+
|
|
49
|
+
await api
|
|
50
|
+
.post('/v1/work/claim')
|
|
51
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
52
|
+
.send({
|
|
53
|
+
agent_id: agentId,
|
|
54
|
+
resource_type: 'repo',
|
|
55
|
+
resource_key: 'owner/repo',
|
|
56
|
+
duration_minutes: 45,
|
|
57
|
+
})
|
|
58
|
+
.expect(201);
|
|
59
|
+
|
|
60
|
+
const blocked = await api
|
|
61
|
+
.post('/v1/work/claim')
|
|
62
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
63
|
+
.send({
|
|
64
|
+
agent_id: second.agentId,
|
|
65
|
+
resource_type: 'repo',
|
|
66
|
+
resource_key: 'owner/repo',
|
|
67
|
+
duration_minutes: 45,
|
|
68
|
+
})
|
|
69
|
+
.expect(409);
|
|
70
|
+
|
|
71
|
+
expect(blocked.body.error).toBe('work_claim_blocked');
|
|
72
|
+
|
|
73
|
+
const events = await pool.query(
|
|
74
|
+
`SELECT activity_type, status
|
|
75
|
+
FROM agent_activity_events
|
|
76
|
+
WHERE org_id = $1
|
|
77
|
+
ORDER BY created_at DESC`,
|
|
78
|
+
[orgId],
|
|
79
|
+
);
|
|
80
|
+
expect(events.rows).toEqual(
|
|
81
|
+
expect.arrayContaining([
|
|
82
|
+
expect.objectContaining({ activity_type: 'work_claim', status: 'success' }),
|
|
83
|
+
expect.objectContaining({ activity_type: 'work_blocked', status: 'error' }),
|
|
84
|
+
]),
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('work/claim is idempotent for active claims', async () => {
|
|
89
|
+
const { agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
90
|
+
const payload = {
|
|
91
|
+
agent_id: agentId,
|
|
92
|
+
resource_type: 'repo',
|
|
93
|
+
resource_key: 'owner/repo',
|
|
94
|
+
duration_minutes: 45,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const first = await api
|
|
98
|
+
.post('/v1/work/claim')
|
|
99
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
100
|
+
.set('Idempotency-Key', 'claim-owner-repo-once')
|
|
101
|
+
.send(payload)
|
|
102
|
+
.expect(201);
|
|
103
|
+
|
|
104
|
+
const second = await api
|
|
105
|
+
.post('/v1/work/claim')
|
|
106
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
107
|
+
.set('Idempotency-Key', 'claim-owner-repo-once')
|
|
108
|
+
.send(payload)
|
|
109
|
+
.expect(200);
|
|
110
|
+
|
|
111
|
+
expect(second.body.idempotent_replay).toBe(true);
|
|
112
|
+
expect(second.body.claim.id).toBe(first.body.claim.id);
|
|
113
|
+
|
|
114
|
+
const claims = await pool.query('SELECT COUNT(*)::int AS count FROM work_claims');
|
|
115
|
+
expect(claims.rows[0].count).toBe(1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('work/run/start creates an automation claim and records activity', async () => {
|
|
119
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex Automation', 'generic', 0);
|
|
120
|
+
|
|
121
|
+
const response = await api
|
|
122
|
+
.post('/v1/work/run/start')
|
|
123
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
124
|
+
.set('Idempotency-Key', 'automation-owner-repo-once')
|
|
125
|
+
.send({
|
|
126
|
+
agent_id: agentId,
|
|
127
|
+
resource_type: 'repo',
|
|
128
|
+
resource_key: 'owner/repo',
|
|
129
|
+
duration_minutes: 45,
|
|
130
|
+
reason: 'Hourly Codex automation',
|
|
131
|
+
client_name: 'openclaw',
|
|
132
|
+
})
|
|
133
|
+
.expect(200);
|
|
134
|
+
|
|
135
|
+
expect(response.body.action).toBe('proceed');
|
|
136
|
+
expect(response.body.claim.id).toBeTruthy();
|
|
137
|
+
expect(response.body.resource.resource_key).toBe('owner/repo');
|
|
138
|
+
expect(response.body.extend_url).toBe('/v1/work/run/extend');
|
|
139
|
+
expect(response.body.finish_url).toBe('/v1/work/run/finish');
|
|
140
|
+
|
|
141
|
+
const claim = await pool.query('SELECT metadata, idempotency_key FROM work_claims WHERE id = $1', [
|
|
142
|
+
response.body.claim.id,
|
|
143
|
+
]);
|
|
144
|
+
expect(claim.rows[0].idempotency_key).toBe('automation-owner-repo-once');
|
|
145
|
+
expect(claim.rows[0].metadata.source).toBe('automation_guardrail');
|
|
146
|
+
|
|
147
|
+
const activity = await pool.query(
|
|
148
|
+
`SELECT activity_type, status, client_name, metadata
|
|
149
|
+
FROM agent_activity_events
|
|
150
|
+
WHERE org_id = $1
|
|
151
|
+
ORDER BY created_at DESC
|
|
152
|
+
LIMIT 1`,
|
|
153
|
+
[orgId],
|
|
154
|
+
);
|
|
155
|
+
expect(activity.rows[0]).toMatchObject({ activity_type: 'automation_start', status: 'success', client_name: 'openclaw' });
|
|
156
|
+
expect(JSON.stringify(activity.rows[0].metadata)).not.toContain(apiKey);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('work/run/start is idempotent and Idempotency-Key header wins over body key', async () => {
|
|
160
|
+
const { agentId, apiKey } = await createOrgAndAgent('Codex Automation', 'generic', 0);
|
|
161
|
+
const payload = {
|
|
162
|
+
agent_id: agentId,
|
|
163
|
+
resource_type: 'repo',
|
|
164
|
+
resource_key: 'owner/repo',
|
|
165
|
+
duration_minutes: 45,
|
|
166
|
+
reason: 'Hourly Codex automation',
|
|
167
|
+
idempotency_key: 'body-key-that-should-not-win',
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const first = await api
|
|
171
|
+
.post('/v1/work/run/start')
|
|
172
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
173
|
+
.set('Idempotency-Key', 'header-key-wins')
|
|
174
|
+
.send(payload)
|
|
175
|
+
.expect(200);
|
|
176
|
+
|
|
177
|
+
const second = await api
|
|
178
|
+
.post('/v1/work/run/start')
|
|
179
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
180
|
+
.set('Idempotency-Key', 'header-key-wins')
|
|
181
|
+
.send(payload)
|
|
182
|
+
.expect(200);
|
|
183
|
+
|
|
184
|
+
expect(second.body.action).toBe('proceed');
|
|
185
|
+
expect(second.body.idempotent_replay).toBe(true);
|
|
186
|
+
expect(second.body.claim.id).toBe(first.body.claim.id);
|
|
187
|
+
|
|
188
|
+
const claims = await pool.query('SELECT COUNT(*)::int AS count, MAX(idempotency_key) AS key FROM work_claims');
|
|
189
|
+
expect(claims.rows[0].count).toBe(1);
|
|
190
|
+
expect(claims.rows[0].key).toBe('header-key-wins');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test('work/run/start returns skip_run without creating a claim when blocked', async () => {
|
|
194
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 10);
|
|
195
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
196
|
+
|
|
197
|
+
await api
|
|
198
|
+
.post('/v1/work/run/start')
|
|
199
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
200
|
+
.send({
|
|
201
|
+
agent_id: agentId,
|
|
202
|
+
resource_type: 'repo',
|
|
203
|
+
resource_key: 'owner/repo',
|
|
204
|
+
duration_minutes: 45,
|
|
205
|
+
})
|
|
206
|
+
.expect(200);
|
|
207
|
+
|
|
208
|
+
const blocked = await api
|
|
209
|
+
.post('/v1/work/run/start')
|
|
210
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
211
|
+
.send({
|
|
212
|
+
agent_id: second.agentId,
|
|
213
|
+
resource_type: 'repo',
|
|
214
|
+
resource_key: 'owner/repo',
|
|
215
|
+
duration_minutes: 45,
|
|
216
|
+
})
|
|
217
|
+
.expect(200);
|
|
218
|
+
|
|
219
|
+
expect(blocked.body.action).toBe('skip_run');
|
|
220
|
+
expect(blocked.body.claim).toBeNull();
|
|
221
|
+
expect(blocked.body.blocking_claim.id).toBeTruthy();
|
|
222
|
+
|
|
223
|
+
const claims = await pool.query('SELECT COUNT(*)::int AS count FROM work_claims WHERE status = $1', ['active']);
|
|
224
|
+
expect(claims.rows[0].count).toBe(1);
|
|
225
|
+
|
|
226
|
+
const activity = await pool.query(
|
|
227
|
+
`SELECT activity_type, status
|
|
228
|
+
FROM agent_activity_events
|
|
229
|
+
WHERE org_id = $1
|
|
230
|
+
ORDER BY created_at DESC`,
|
|
231
|
+
[orgId],
|
|
232
|
+
);
|
|
233
|
+
expect(activity.rows).toEqual(
|
|
234
|
+
expect.arrayContaining([
|
|
235
|
+
expect.objectContaining({ activity_type: 'automation_start', status: 'success' }),
|
|
236
|
+
expect.objectContaining({ activity_type: 'automation_skip', status: 'success' }),
|
|
237
|
+
]),
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('new agents default to enforce and workspace can switch an agent to observe', async () => {
|
|
242
|
+
const { orgId, agentId } = await createOrgAndAgent('Codex Observe', 'generic', 0);
|
|
243
|
+
|
|
244
|
+
const listed = await api
|
|
245
|
+
.get(`/v1/orgs/${orgId}/agents`)
|
|
246
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
247
|
+
.expect(200);
|
|
248
|
+
|
|
249
|
+
expect(listed.body.agents[0]).toMatchObject({
|
|
250
|
+
id: agentId,
|
|
251
|
+
enforcement_mode: 'enforce',
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
const updated = await api
|
|
255
|
+
.put(`/v1/orgs/${orgId}/agents/${agentId}`)
|
|
256
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
257
|
+
.send({
|
|
258
|
+
name: 'Codex Observe',
|
|
259
|
+
agent_type: 'generic',
|
|
260
|
+
priority: 0,
|
|
261
|
+
enforcement_mode: 'observe',
|
|
262
|
+
})
|
|
263
|
+
.expect(200);
|
|
264
|
+
|
|
265
|
+
expect(updated.body.agent.enforcement_mode).toBe('observe');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test('agent key cannot change enforcement mode', async () => {
|
|
269
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex Observe', 'generic', 0);
|
|
270
|
+
|
|
271
|
+
await api
|
|
272
|
+
.put(`/v1/orgs/${orgId}/agents/${agentId}`)
|
|
273
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
274
|
+
.send({
|
|
275
|
+
name: 'Codex Observe',
|
|
276
|
+
agent_type: 'generic',
|
|
277
|
+
priority: 0,
|
|
278
|
+
enforcement_mode: 'observe',
|
|
279
|
+
})
|
|
280
|
+
.expect(401);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('observe mode proceeds when blocked without creating a claim and records shadow events', async () => {
|
|
284
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 10);
|
|
285
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
286
|
+
|
|
287
|
+
await api
|
|
288
|
+
.put(`/v1/orgs/${orgId}/agents/${second.agentId}`)
|
|
289
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
290
|
+
.send({
|
|
291
|
+
name: 'Codex B',
|
|
292
|
+
agent_type: 'generic',
|
|
293
|
+
priority: 0,
|
|
294
|
+
enforcement_mode: 'observe',
|
|
295
|
+
})
|
|
296
|
+
.expect(200);
|
|
297
|
+
|
|
298
|
+
const first = await api
|
|
299
|
+
.post('/v1/work/run/start')
|
|
300
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
301
|
+
.send({
|
|
302
|
+
agent_id: agentId,
|
|
303
|
+
resource_type: 'repo',
|
|
304
|
+
resource_key: 'owner/repo',
|
|
305
|
+
duration_minutes: 45,
|
|
306
|
+
})
|
|
307
|
+
.expect(200);
|
|
308
|
+
|
|
309
|
+
const observed = await api
|
|
310
|
+
.post('/v1/work/run/start')
|
|
311
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
312
|
+
.send({
|
|
313
|
+
agent_id: second.agentId,
|
|
314
|
+
resource_type: 'repo',
|
|
315
|
+
resource_key: 'owner/repo',
|
|
316
|
+
duration_minutes: 45,
|
|
317
|
+
client_name: 'openclaw',
|
|
318
|
+
})
|
|
319
|
+
.expect(200);
|
|
320
|
+
|
|
321
|
+
expect(observed.body).toMatchObject({
|
|
322
|
+
action: 'proceed',
|
|
323
|
+
claim: null,
|
|
324
|
+
shadow_mode: true,
|
|
325
|
+
would_have_blocked: true,
|
|
326
|
+
shadow_decision: {
|
|
327
|
+
action: 'skip_run',
|
|
328
|
+
rule_applied: expect.any(String),
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
expect(observed.body.shadow_decision.blocking_claim.id).toBe(first.body.claim.id);
|
|
332
|
+
|
|
333
|
+
const claims = await pool.query('SELECT id, agent_id, status FROM work_claims WHERE status = $1', ['active']);
|
|
334
|
+
expect(claims.rows).toHaveLength(1);
|
|
335
|
+
expect(claims.rows[0].agent_id).toBe(agentId);
|
|
336
|
+
|
|
337
|
+
const workEvents = await pool.query(
|
|
338
|
+
`SELECT event_type, agent_id, metadata
|
|
339
|
+
FROM work_claim_events
|
|
340
|
+
WHERE org_id = $1
|
|
341
|
+
ORDER BY created_at ASC`,
|
|
342
|
+
[orgId],
|
|
343
|
+
);
|
|
344
|
+
expect(workEvents.rows).toEqual(
|
|
345
|
+
expect.arrayContaining([
|
|
346
|
+
expect.objectContaining({ event_type: 'created', agent_id: agentId }),
|
|
347
|
+
expect.objectContaining({ event_type: 'shadow_blocked', agent_id: second.agentId }),
|
|
348
|
+
]),
|
|
349
|
+
);
|
|
350
|
+
expect(workEvents.rows.find((event) => event.event_type === 'shadow_blocked')?.metadata.source).toBe('shadow_mode');
|
|
351
|
+
|
|
352
|
+
const activity = await pool.query(
|
|
353
|
+
`SELECT activity_type, status, client_name, metadata
|
|
354
|
+
FROM agent_activity_events
|
|
355
|
+
WHERE org_id = $1
|
|
356
|
+
ORDER BY created_at ASC`,
|
|
357
|
+
[orgId],
|
|
358
|
+
);
|
|
359
|
+
expect(activity.rows).toEqual(
|
|
360
|
+
expect.arrayContaining([
|
|
361
|
+
expect.objectContaining({ activity_type: 'automation_start', status: 'success' }),
|
|
362
|
+
expect.objectContaining({
|
|
363
|
+
activity_type: 'automation_shadow_blocked',
|
|
364
|
+
status: 'success',
|
|
365
|
+
client_name: 'openclaw',
|
|
366
|
+
}),
|
|
367
|
+
]),
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
test('observe mode proceeds when available without creating a claim', async () => {
|
|
372
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex Observe', 'generic', 0);
|
|
373
|
+
|
|
374
|
+
await api
|
|
375
|
+
.put(`/v1/orgs/${orgId}/agents/${agentId}`)
|
|
376
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
377
|
+
.send({
|
|
378
|
+
name: 'Codex Observe',
|
|
379
|
+
agent_type: 'generic',
|
|
380
|
+
priority: 0,
|
|
381
|
+
enforcement_mode: 'observe',
|
|
382
|
+
})
|
|
383
|
+
.expect(200);
|
|
384
|
+
|
|
385
|
+
const observed = await api
|
|
386
|
+
.post('/v1/work/run/start')
|
|
387
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
388
|
+
.send({
|
|
389
|
+
agent_id: agentId,
|
|
390
|
+
resource_type: 'repo',
|
|
391
|
+
resource_key: 'owner/available-repo',
|
|
392
|
+
})
|
|
393
|
+
.expect(200);
|
|
394
|
+
|
|
395
|
+
expect(observed.body).toMatchObject({
|
|
396
|
+
action: 'proceed',
|
|
397
|
+
claim: null,
|
|
398
|
+
shadow_mode: true,
|
|
399
|
+
would_have_blocked: false,
|
|
400
|
+
shadow_decision: null,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
const claims = await pool.query('SELECT COUNT(*)::int AS count FROM work_claims');
|
|
404
|
+
expect(claims.rows[0].count).toBe(0);
|
|
405
|
+
|
|
406
|
+
const events = await pool.query('SELECT event_type, metadata FROM work_claim_events WHERE org_id = $1', [orgId]);
|
|
407
|
+
expect(events.rows).toEqual([
|
|
408
|
+
expect.objectContaining({ event_type: 'shadow_allowed' }),
|
|
409
|
+
]);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
test('work/run/start allows higher priority automation to supersede lower priority claim', async () => {
|
|
413
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
414
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 20);
|
|
415
|
+
|
|
416
|
+
const first = await api
|
|
417
|
+
.post('/v1/work/run/start')
|
|
418
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
419
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
420
|
+
.expect(200);
|
|
421
|
+
|
|
422
|
+
const winner = await api
|
|
423
|
+
.post('/v1/work/run/start')
|
|
424
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
425
|
+
.send({ agent_id: second.agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
426
|
+
.expect(200);
|
|
427
|
+
|
|
428
|
+
expect(winner.body.action).toBe('proceed');
|
|
429
|
+
expect(winner.body.superseded_claim_ids).toContain(first.body.claim.id);
|
|
430
|
+
|
|
431
|
+
const superseded = await pool.query('SELECT status FROM work_claims WHERE id = $1', [
|
|
432
|
+
first.body.claim.id,
|
|
433
|
+
]);
|
|
434
|
+
expect(superseded.rows[0].status).toBe('superseded');
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test('work/run/extend extends and work/run/finish releases idempotently', async () => {
|
|
438
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex Automation', 'generic', 0);
|
|
439
|
+
const started = await api
|
|
440
|
+
.post('/v1/work/run/start')
|
|
441
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
442
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo', duration_minutes: 10 })
|
|
443
|
+
.expect(200);
|
|
444
|
+
|
|
445
|
+
const extended = await api
|
|
446
|
+
.post('/v1/work/run/extend')
|
|
447
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
448
|
+
.send({ claim_id: started.body.claim.id, duration_minutes: 45 })
|
|
449
|
+
.expect(200);
|
|
450
|
+
|
|
451
|
+
expect(extended.body.action).toBe('extended');
|
|
452
|
+
expect(extended.body.claim.renewal_count).toBe(1);
|
|
453
|
+
|
|
454
|
+
const finished = await api
|
|
455
|
+
.post('/v1/work/run/finish')
|
|
456
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
457
|
+
.send({ claim_id: started.body.claim.id, outcome: 'success' })
|
|
458
|
+
.expect(200);
|
|
459
|
+
|
|
460
|
+
expect(finished.body.action).toBe('finished');
|
|
461
|
+
|
|
462
|
+
const repeated = await api
|
|
463
|
+
.post('/v1/work/run/finish')
|
|
464
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
465
|
+
.send({ claim_id: started.body.claim.id, outcome: 'success' })
|
|
466
|
+
.expect(200);
|
|
467
|
+
|
|
468
|
+
expect(repeated.body.action).toBe('already_finished');
|
|
469
|
+
|
|
470
|
+
const activity = await pool.query(
|
|
471
|
+
`SELECT activity_type
|
|
472
|
+
FROM agent_activity_events
|
|
473
|
+
WHERE org_id = $1
|
|
474
|
+
ORDER BY created_at ASC`,
|
|
475
|
+
[orgId],
|
|
476
|
+
);
|
|
477
|
+
expect(activity.rows).toEqual(
|
|
478
|
+
expect.arrayContaining([
|
|
479
|
+
expect.objectContaining({ activity_type: 'automation_start' }),
|
|
480
|
+
expect.objectContaining({ activity_type: 'automation_extend' }),
|
|
481
|
+
expect.objectContaining({ activity_type: 'automation_finish' }),
|
|
482
|
+
]),
|
|
483
|
+
);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test('agent key cannot use work/run endpoints for another agent claim', async () => {
|
|
487
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
488
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
489
|
+
|
|
490
|
+
await api
|
|
491
|
+
.post('/v1/work/run/start')
|
|
492
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
493
|
+
.send({ agent_id: second.agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
494
|
+
.expect(403);
|
|
495
|
+
|
|
496
|
+
const started = await api
|
|
497
|
+
.post('/v1/work/run/start')
|
|
498
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
499
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
500
|
+
.expect(200);
|
|
501
|
+
|
|
502
|
+
await api
|
|
503
|
+
.post('/v1/work/run/extend')
|
|
504
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
505
|
+
.send({ claim_id: started.body.claim.id, duration_minutes: 45 })
|
|
506
|
+
.expect(404);
|
|
507
|
+
|
|
508
|
+
await api
|
|
509
|
+
.post('/v1/work/run/finish')
|
|
510
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
511
|
+
.send({ claim_id: started.body.claim.id })
|
|
512
|
+
.expect(404);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
test('reusing idempotency key after release returns 409', async () => {
|
|
516
|
+
const { agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
517
|
+
const created = await api
|
|
518
|
+
.post('/v1/work/claim')
|
|
519
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
520
|
+
.set('Idempotency-Key', 'released-key')
|
|
521
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
522
|
+
.expect(201);
|
|
523
|
+
|
|
524
|
+
await api
|
|
525
|
+
.delete(`/v1/work/claims/${created.body.claim.id}`)
|
|
526
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
527
|
+
.expect(200);
|
|
528
|
+
|
|
529
|
+
await api
|
|
530
|
+
.post('/v1/work/claim')
|
|
531
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
532
|
+
.set('Idempotency-Key', 'released-key')
|
|
533
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
534
|
+
.expect(409);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
test('agent can extend own work claim and workspace can extend org claim', async () => {
|
|
538
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
539
|
+
const created = await api
|
|
540
|
+
.post('/v1/work/claim')
|
|
541
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
542
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo', duration_minutes: 10 })
|
|
543
|
+
.expect(201);
|
|
544
|
+
|
|
545
|
+
const agentExtend = await api
|
|
546
|
+
.post(`/v1/work/claims/${created.body.claim.id}/extend`)
|
|
547
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
548
|
+
.send({ duration_minutes: 45 })
|
|
549
|
+
.expect(200);
|
|
550
|
+
|
|
551
|
+
expect(agentExtend.body.claim.renewal_count).toBe(1);
|
|
552
|
+
expect(agentExtend.body.claim.expires_at).toBeTruthy();
|
|
553
|
+
|
|
554
|
+
const workspaceExtend = await api
|
|
555
|
+
.post(`/v1/work/claims/${created.body.claim.id}/extend`)
|
|
556
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
557
|
+
.send({ duration_minutes: 45 })
|
|
558
|
+
.expect(200);
|
|
559
|
+
|
|
560
|
+
expect(workspaceExtend.body.claim.renewal_count).toBe(2);
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
test('agent key cannot extend another agent claim', async () => {
|
|
564
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
565
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
566
|
+
const created = await api
|
|
567
|
+
.post('/v1/work/claim')
|
|
568
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
569
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
570
|
+
.expect(201);
|
|
571
|
+
|
|
572
|
+
await api
|
|
573
|
+
.post(`/v1/work/claims/${created.body.claim.id}/extend`)
|
|
574
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
575
|
+
.send({ duration_minutes: 45 })
|
|
576
|
+
.expect(404);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
test('higher priority agent supersedes lower priority claim', async () => {
|
|
580
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
581
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 20);
|
|
582
|
+
|
|
583
|
+
const first = await api
|
|
584
|
+
.post('/v1/work/claim')
|
|
585
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
586
|
+
.send({
|
|
587
|
+
agent_id: agentId,
|
|
588
|
+
resource_type: 'repo',
|
|
589
|
+
resource_key: 'owner/repo',
|
|
590
|
+
})
|
|
591
|
+
.expect(201);
|
|
592
|
+
|
|
593
|
+
const winner = await api
|
|
594
|
+
.post('/v1/work/claim')
|
|
595
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
596
|
+
.send({
|
|
597
|
+
agent_id: second.agentId,
|
|
598
|
+
resource_type: 'repo',
|
|
599
|
+
resource_key: 'owner/repo',
|
|
600
|
+
})
|
|
601
|
+
.expect(201);
|
|
602
|
+
|
|
603
|
+
expect(winner.body.superseded_claim_ids).toContain(first.body.claim.id);
|
|
604
|
+
|
|
605
|
+
const superseded = await pool.query('SELECT status FROM work_claims WHERE id = $1', [
|
|
606
|
+
first.body.claim.id,
|
|
607
|
+
]);
|
|
608
|
+
expect(superseded.rows[0].status).toBe('superseded');
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
test('agent key cannot claim or release another agent work slot', async () => {
|
|
612
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
613
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
614
|
+
|
|
615
|
+
await api
|
|
616
|
+
.post('/v1/work/claim')
|
|
617
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
618
|
+
.send({
|
|
619
|
+
agent_id: second.agentId,
|
|
620
|
+
resource_type: 'repo',
|
|
621
|
+
resource_key: 'owner/repo',
|
|
622
|
+
})
|
|
623
|
+
.expect(403);
|
|
624
|
+
|
|
625
|
+
const created = await api
|
|
626
|
+
.post('/v1/work/claim')
|
|
627
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
628
|
+
.send({
|
|
629
|
+
agent_id: agentId,
|
|
630
|
+
resource_type: 'repo',
|
|
631
|
+
resource_key: 'owner/repo',
|
|
632
|
+
})
|
|
633
|
+
.expect(201);
|
|
634
|
+
|
|
635
|
+
await api
|
|
636
|
+
.delete(`/v1/work/claims/${created.body.claim.id}`)
|
|
637
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
638
|
+
.expect(404);
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
test('workspace can list all claims and agent key lists only own claims', async () => {
|
|
642
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
643
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
644
|
+
await pool.query("UPDATE orgs SET plan = 'team', agent_limit = 9999 WHERE id = $1", [orgId]);
|
|
645
|
+
|
|
646
|
+
await api
|
|
647
|
+
.post('/v1/work/claim')
|
|
648
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
649
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo-a' })
|
|
650
|
+
.expect(201);
|
|
651
|
+
|
|
652
|
+
await api
|
|
653
|
+
.post('/v1/work/claim')
|
|
654
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
655
|
+
.send({ agent_id: second.agentId, resource_type: 'repo', resource_key: 'owner/repo-b' })
|
|
656
|
+
.expect(201);
|
|
657
|
+
|
|
658
|
+
const workspace = await api
|
|
659
|
+
.get('/v1/work/claims')
|
|
660
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
661
|
+
.expect(200);
|
|
662
|
+
expect(workspace.body.claims).toHaveLength(2);
|
|
663
|
+
|
|
664
|
+
const agent = await api
|
|
665
|
+
.get('/v1/work/claims')
|
|
666
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
667
|
+
.expect(200);
|
|
668
|
+
expect(agent.body.claims).toHaveLength(1);
|
|
669
|
+
expect(agent.body.claims[0].agent_id).toBe(agentId);
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
test('expired claim does not block a new claim', async () => {
|
|
673
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
674
|
+
const second = await createAgent(orgId, 'Codex B', 'generic', 0);
|
|
675
|
+
|
|
676
|
+
const resource = await pool.query(
|
|
677
|
+
`INSERT INTO work_resources (org_id, resource_type, resource_key, label)
|
|
678
|
+
VALUES ($1, 'repo', 'owner/repo', 'owner/repo')
|
|
679
|
+
RETURNING id`,
|
|
680
|
+
[orgId],
|
|
681
|
+
);
|
|
682
|
+
await pool.query(
|
|
683
|
+
`INSERT INTO work_claims (
|
|
684
|
+
org_id,
|
|
685
|
+
agent_id,
|
|
686
|
+
resource_id,
|
|
687
|
+
start_at,
|
|
688
|
+
end_at,
|
|
689
|
+
expires_at,
|
|
690
|
+
last_renewed_at,
|
|
691
|
+
status
|
|
692
|
+
)
|
|
693
|
+
VALUES (
|
|
694
|
+
$1,
|
|
695
|
+
$2,
|
|
696
|
+
$3,
|
|
697
|
+
NOW() - INTERVAL '2 hours',
|
|
698
|
+
NOW() - INTERVAL '1 hour',
|
|
699
|
+
NOW() - INTERVAL '1 hour',
|
|
700
|
+
NOW() - INTERVAL '2 hours',
|
|
701
|
+
'active'
|
|
702
|
+
)`,
|
|
703
|
+
[orgId, agentId, resource.rows[0].id],
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
await api
|
|
707
|
+
.post('/v1/work/claim')
|
|
708
|
+
.set('Authorization', `Bearer ${second.apiKey}`)
|
|
709
|
+
.send({
|
|
710
|
+
agent_id: second.agentId,
|
|
711
|
+
resource_type: 'repo',
|
|
712
|
+
resource_key: 'owner/repo',
|
|
713
|
+
})
|
|
714
|
+
.expect(201);
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
test('release writes work event with workspace actor metadata', async () => {
|
|
718
|
+
const { orgId, agentId, apiKey } = await createOrgAndAgent('Codex A', 'generic', 0);
|
|
719
|
+
const created = await api
|
|
720
|
+
.post('/v1/work/claim')
|
|
721
|
+
.set('Authorization', `Bearer ${apiKey}`)
|
|
722
|
+
.send({ agent_id: agentId, resource_type: 'repo', resource_key: 'owner/repo' })
|
|
723
|
+
.expect(201);
|
|
724
|
+
|
|
725
|
+
await api
|
|
726
|
+
.delete(`/v1/work/claims/${created.body.claim.id}`)
|
|
727
|
+
.set('Cookie', getWorkspaceCookie(orgId))
|
|
728
|
+
.expect(200);
|
|
729
|
+
|
|
730
|
+
const events = await pool.query(
|
|
731
|
+
`SELECT event_type, actor_type, actor_label
|
|
732
|
+
FROM work_claim_events
|
|
733
|
+
WHERE claim_id = $1
|
|
734
|
+
ORDER BY created_at DESC`,
|
|
735
|
+
[created.body.claim.id],
|
|
736
|
+
);
|
|
737
|
+
|
|
738
|
+
expect(events.rows).toEqual(
|
|
739
|
+
expect.arrayContaining([
|
|
740
|
+
expect.objectContaining({ event_type: 'released', actor_type: 'workspace' }),
|
|
741
|
+
]),
|
|
742
|
+
);
|
|
743
|
+
expect(events.rows.find((event) => event.event_type === 'released')?.actor_label).toContain('@');
|
|
744
|
+
});
|
|
745
|
+
});
|