@desplega.ai/agent-swarm 1.20.0 → 1.49.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/.claude/settings.json +84 -0
- package/.claude/settings.local.json +3 -1
- package/.entire/settings.json +4 -0
- package/.env.docker.example +40 -23
- package/.env.example +39 -1
- package/.github/ISSUE_TEMPLATE/bug_report.yml +78 -0
- package/.github/ISSUE_TEMPLATE/community-template.yml +77 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +60 -0
- package/.github/PULL_REQUEST_TEMPLATE/community-template.md +29 -0
- package/.github/workflows/ci.yml +3 -27
- package/.github/workflows/docker-and-deploy.yml +20 -5
- package/.github/workflows/merge-gate.yml +233 -0
- package/.opencode/plugins/entire.ts +133 -0
- package/.superset/config.json +6 -0
- package/.wts-setup.ts +103 -34
- package/CHANGELOG.md +447 -0
- package/CLAUDE.md +422 -5
- package/CONTRIBUTING.md +46 -1
- package/DEPLOYMENT.md +26 -9
- package/Dockerfile +15 -7
- package/Dockerfile.worker +99 -67
- package/MCP.md +452 -17
- package/README.md +271 -169
- package/api-entrypoint.sh +56 -0
- package/depot.json +1 -0
- package/docker-compose.example.yml +194 -3
- package/docker-compose.local.yml +119 -0
- package/docker-entrypoint.sh +393 -113
- package/docs-site/app/api/search/route.ts +4 -0
- package/docs-site/app/docs/[[...slug]]/page.tsx +87 -0
- package/docs-site/app/docs/layout.tsx +12 -0
- package/docs-site/app/globals.css +24 -0
- package/docs-site/app/layout.config.tsx +34 -0
- package/docs-site/app/layout.tsx +119 -0
- package/docs-site/app/llms-full.txt/route.ts +11 -0
- package/docs-site/app/llms.mdx/docs/[[...slug]]/route.ts +24 -0
- package/docs-site/app/llms.txt/route.ts +8 -0
- package/docs-site/app/page.tsx +5 -0
- package/docs-site/app/robots.ts +13 -0
- package/docs-site/app/sitemap.ts +37 -0
- package/docs-site/components/api-page.client.tsx +4 -0
- package/docs-site/components/api-page.tsx +7 -0
- package/docs-site/components/mdx/mermaid.tsx +55 -0
- package/docs-site/content/docs/(documentation)/architecture/agents.mdx +117 -0
- package/docs-site/content/docs/(documentation)/architecture/hooks.mdx +77 -0
- package/docs-site/content/docs/(documentation)/architecture/memory.mdx +96 -0
- package/docs-site/content/docs/(documentation)/architecture/meta.json +4 -0
- package/docs-site/content/docs/(documentation)/architecture/overview.mdx +172 -0
- package/docs-site/content/docs/(documentation)/concepts/epics.mdx +98 -0
- package/docs-site/content/docs/(documentation)/concepts/meta.json +4 -0
- package/docs-site/content/docs/(documentation)/concepts/scheduling.mdx +136 -0
- package/docs-site/content/docs/(documentation)/concepts/services.mdx +104 -0
- package/docs-site/content/docs/(documentation)/concepts/task-lifecycle.mdx +148 -0
- package/docs-site/content/docs/(documentation)/concepts/workflows.mdx +209 -0
- package/docs-site/content/docs/(documentation)/contributing.mdx +158 -0
- package/docs-site/content/docs/(documentation)/getting-started.mdx +157 -0
- package/docs-site/content/docs/(documentation)/guides/agentmail-integration.mdx +79 -0
- package/docs-site/content/docs/(documentation)/guides/deployment.mdx +171 -0
- package/docs-site/content/docs/(documentation)/guides/github-integration.mdx +81 -0
- package/docs-site/content/docs/(documentation)/guides/gitlab-integration.mdx +93 -0
- package/docs-site/content/docs/(documentation)/guides/linear-integration.mdx +98 -0
- package/docs-site/content/docs/(documentation)/guides/meta.json +13 -0
- package/docs-site/content/docs/(documentation)/guides/sentry-integration.mdx +52 -0
- package/docs-site/content/docs/(documentation)/guides/slack-integration.mdx +179 -0
- package/docs-site/content/docs/(documentation)/guides/x402-payments.mdx +154 -0
- package/docs-site/content/docs/(documentation)/index.mdx +65 -0
- package/docs-site/content/docs/(documentation)/meta.json +19 -0
- package/docs-site/content/docs/(documentation)/reference/cli.mdx +241 -0
- package/docs-site/content/docs/(documentation)/reference/environment-variables.mdx +205 -0
- package/docs-site/content/docs/(documentation)/reference/mcp-tools.mdx +449 -0
- package/docs-site/content/docs/(documentation)/reference/meta.json +4 -0
- package/docs-site/content/docs/api-reference/active-sessions.mdx +9 -0
- package/docs-site/content/docs/api-reference/agents.mdx +9 -0
- package/docs-site/content/docs/api-reference/channels.mdx +9 -0
- package/docs-site/content/docs/api-reference/config.mdx +9 -0
- package/docs-site/content/docs/api-reference/debug.mdx +9 -0
- package/docs-site/content/docs/api-reference/ecosystem.mdx +9 -0
- package/docs-site/content/docs/api-reference/epics.mdx +9 -0
- package/docs-site/content/docs/api-reference/index.mdx +32 -0
- package/docs-site/content/docs/api-reference/memory.mdx +9 -0
- package/docs-site/content/docs/api-reference/meta.json +25 -0
- package/docs-site/content/docs/api-reference/poll.mdx +9 -0
- package/docs-site/content/docs/api-reference/repos.mdx +9 -0
- package/docs-site/content/docs/api-reference/schedules.mdx +9 -0
- package/docs-site/content/docs/api-reference/session-data.mdx +9 -0
- package/docs-site/content/docs/api-reference/stats.mdx +9 -0
- package/docs-site/content/docs/api-reference/tasks.mdx +9 -0
- package/docs-site/content/docs/api-reference/trackers.mdx +9 -0
- package/docs-site/content/docs/api-reference/webhooks.mdx +9 -0
- package/docs-site/content/docs/api-reference/workflows.mdx +9 -0
- package/docs-site/content/docs/meta.json +3 -0
- package/docs-site/lib/get-llm-text.ts +10 -0
- package/docs-site/lib/openapi.ts +23 -0
- package/docs-site/lib/source.ts +8 -0
- package/docs-site/mdx-components.tsx +13 -0
- package/docs-site/next.config.mjs +29 -0
- package/docs-site/package.json +35 -0
- package/docs-site/pnpm-lock.yaml +5407 -0
- package/docs-site/postcss.config.mjs +8 -0
- package/docs-site/scripts/generate-docs.ts +171 -0
- package/docs-site/source.config.ts +17 -0
- package/docs-site/tsconfig.json +46 -0
- package/ecosystem.config.cjs +4 -4
- package/landing/next.config.ts +14 -0
- package/landing/package.json +31 -0
- package/landing/pnpm-lock.yaml +1091 -0
- package/landing/postcss.config.mjs +8 -0
- package/landing/public/apple-touch-icon.png +0 -0
- package/landing/public/favicon.ico +0 -0
- package/landing/public/logo.png +0 -0
- package/landing/public/og-image.png +0 -0
- package/landing/public/omghost-desplega.svg +30 -0
- package/landing/public/omghost-openfort.svg +9 -0
- package/landing/src/app/actions/waitlist.ts +25 -0
- package/landing/src/app/blog/openfort-hackathon/page.tsx +863 -0
- package/landing/src/app/blog/page.tsx +162 -0
- package/landing/src/app/blog/swarm-metrics/page.tsx +685 -0
- package/landing/src/app/examples/page.tsx +174 -0
- package/landing/src/app/examples/x402/page.tsx +456 -0
- package/landing/src/app/globals.css +122 -0
- package/landing/src/app/layout.tsx +134 -0
- package/landing/src/app/page.tsx +27 -0
- package/landing/src/app/robots.ts +13 -0
- package/landing/src/app/sitemap.ts +44 -0
- package/landing/src/components/architecture.tsx +163 -0
- package/landing/src/components/cta.tsx +52 -0
- package/landing/src/components/features.tsx +160 -0
- package/landing/src/components/footer.tsx +100 -0
- package/landing/src/components/hero.tsx +217 -0
- package/landing/src/components/how-it-works.tsx +165 -0
- package/landing/src/components/navbar.tsx +147 -0
- package/landing/src/components/waitlist.tsx +110 -0
- package/landing/src/components/why-choose.tsx +149 -0
- package/landing/src/components/workshops.tsx +328 -0
- package/landing/src/lib/utils.ts +6 -0
- package/landing/tsconfig.json +41 -0
- package/misc/transcripts/2026-03-09-pi-mono-e2e-verification.md +154 -0
- package/new-ui/CLAUDE.md +92 -0
- package/new-ui/README.md +73 -0
- package/new-ui/biome.json +42 -0
- package/new-ui/components.json +21 -0
- package/new-ui/index.html +25 -0
- package/new-ui/package.json +49 -0
- package/new-ui/pnpm-lock.yaml +4845 -0
- package/new-ui/public/logo.png +0 -0
- package/new-ui/src/api/client.ts +814 -0
- package/new-ui/src/api/hooks/index.ts +64 -0
- package/new-ui/src/api/hooks/use-agents.ts +58 -0
- package/new-ui/src/api/hooks/use-channels.ts +115 -0
- package/new-ui/src/api/hooks/use-config-api.ts +46 -0
- package/new-ui/src/api/hooks/use-costs.ts +122 -0
- package/new-ui/src/api/hooks/use-db-query.ts +29 -0
- package/new-ui/src/api/hooks/use-epics.ts +75 -0
- package/new-ui/src/api/hooks/use-repos.ts +61 -0
- package/new-ui/src/api/hooks/use-schedules.ts +81 -0
- package/new-ui/src/api/hooks/use-services.ts +16 -0
- package/new-ui/src/api/hooks/use-stats.ts +27 -0
- package/new-ui/src/api/hooks/use-tasks.ts +89 -0
- package/new-ui/src/api/hooks/use-workflows.ts +109 -0
- package/{ui/src/types/api.ts → new-ui/src/api/types.ts} +236 -10
- package/new-ui/src/app/App.tsx +13 -0
- package/new-ui/src/app/providers.tsx +32 -0
- package/new-ui/src/app/router.tsx +52 -0
- package/new-ui/src/components/layout/app-header.tsx +47 -0
- package/new-ui/src/components/layout/app-sidebar.tsx +128 -0
- package/new-ui/src/components/layout/breadcrumbs.tsx +57 -0
- package/new-ui/src/components/layout/config-guard.tsx +22 -0
- package/new-ui/src/components/layout/root-layout.tsx +40 -0
- package/new-ui/src/components/layout/swarm-switcher.tsx +85 -0
- package/new-ui/src/components/shared/command-menu.tsx +131 -0
- package/new-ui/src/components/shared/data-grid.tsx +141 -0
- package/new-ui/src/components/shared/empty-state.tsx +24 -0
- package/new-ui/src/components/shared/error-boundary.tsx +72 -0
- package/new-ui/src/components/shared/json-viewer.tsx +47 -0
- package/new-ui/src/components/shared/name-connection-modal.tsx +99 -0
- package/new-ui/src/components/shared/page-skeleton.tsx +16 -0
- package/new-ui/src/components/shared/session-log-viewer.tsx +364 -0
- package/new-ui/src/components/shared/stats-bar.tsx +132 -0
- package/new-ui/src/components/shared/status-badge.tsx +131 -0
- package/new-ui/src/components/shared/usage-summary.tsx +179 -0
- package/new-ui/src/components/ui/alert-dialog.tsx +176 -0
- package/new-ui/src/components/ui/alert.tsx +60 -0
- package/new-ui/src/components/ui/avatar.tsx +96 -0
- package/new-ui/src/components/ui/badge.tsx +46 -0
- package/new-ui/src/components/ui/button.tsx +62 -0
- package/new-ui/src/components/ui/card.tsx +75 -0
- package/new-ui/src/components/ui/command.tsx +160 -0
- package/new-ui/src/components/ui/dialog.tsx +143 -0
- package/new-ui/src/components/ui/dropdown-menu.tsx +226 -0
- package/new-ui/src/components/ui/input.tsx +21 -0
- package/new-ui/src/components/ui/label.tsx +19 -0
- package/new-ui/src/components/ui/progress.tsx +26 -0
- package/new-ui/src/components/ui/scroll-area.tsx +54 -0
- package/new-ui/src/components/ui/select.tsx +175 -0
- package/new-ui/src/components/ui/separator.tsx +28 -0
- package/new-ui/src/components/ui/sheet.tsx +132 -0
- package/new-ui/src/components/ui/sidebar.tsx +691 -0
- package/new-ui/src/components/ui/skeleton.tsx +13 -0
- package/new-ui/src/components/ui/sonner.tsx +35 -0
- package/new-ui/src/components/ui/switch.tsx +33 -0
- package/new-ui/src/components/ui/table.tsx +92 -0
- package/new-ui/src/components/ui/tabs.tsx +79 -0
- package/new-ui/src/components/ui/textarea.tsx +18 -0
- package/new-ui/src/components/ui/tooltip.tsx +51 -0
- package/new-ui/src/components/workflows/action-node.tsx +53 -0
- package/new-ui/src/components/workflows/condition-node.tsx +50 -0
- package/new-ui/src/components/workflows/graph-utils.ts +124 -0
- package/new-ui/src/components/workflows/json-tree.tsx +189 -0
- package/new-ui/src/components/workflows/node-styles.ts +10 -0
- package/new-ui/src/components/workflows/step-detail-sheet.tsx +87 -0
- package/new-ui/src/components/workflows/trigger-node.tsx +41 -0
- package/new-ui/src/components/workflows/workflow-graph.tsx +65 -0
- package/{ui/src/hooks/useAutoScroll.ts → new-ui/src/hooks/use-auto-scroll.ts} +0 -1
- package/new-ui/src/hooks/use-config.ts +203 -0
- package/new-ui/src/hooks/use-keyboard-shortcuts.ts +41 -0
- package/new-ui/src/hooks/use-mobile.ts +19 -0
- package/new-ui/src/hooks/use-theme.ts +60 -0
- package/new-ui/src/lib/config.ts +188 -0
- package/new-ui/src/lib/slugs.ts +71 -0
- package/{ui → new-ui}/src/lib/utils.ts +32 -0
- package/new-ui/src/main.tsx +11 -0
- package/new-ui/src/pages/agents/[id]/page.tsx +492 -0
- package/new-ui/src/pages/agents/page.tsx +134 -0
- package/new-ui/src/pages/chat/page.tsx +674 -0
- package/new-ui/src/pages/config/page.tsx +1109 -0
- package/new-ui/src/pages/dashboard/page.tsx +454 -0
- package/new-ui/src/pages/debug/page.tsx +275 -0
- package/new-ui/src/pages/epics/[id]/page.tsx +809 -0
- package/new-ui/src/pages/epics/page.tsx +321 -0
- package/new-ui/src/pages/not-found/page.tsx +18 -0
- package/new-ui/src/pages/repos/page.tsx +369 -0
- package/new-ui/src/pages/schedules/[id]/page.tsx +664 -0
- package/new-ui/src/pages/schedules/page.tsx +477 -0
- package/new-ui/src/pages/services/page.tsx +128 -0
- package/new-ui/src/pages/tasks/[id]/page.tsx +670 -0
- package/new-ui/src/pages/tasks/page.tsx +592 -0
- package/new-ui/src/pages/usage/page.tsx +195 -0
- package/new-ui/src/pages/workflow-runs/[id]/page.tsx +363 -0
- package/new-ui/src/pages/workflows/[id]/page.tsx +417 -0
- package/new-ui/src/pages/workflows/page.tsx +266 -0
- package/new-ui/src/styles/ag-grid.css +36 -0
- package/new-ui/src/styles/globals.css +213 -0
- package/new-ui/test-results/.last-run.json +4 -0
- package/{ui/tsconfig.json → new-ui/tsconfig.app.json} +7 -4
- package/new-ui/tsconfig.json +4 -0
- package/new-ui/tsconfig.node.json +26 -0
- package/new-ui/vercel.json +4 -0
- package/new-ui/vite.config.ts +28 -0
- package/openapi.json +4436 -0
- package/package.json +31 -7
- package/plugin/build-pi-skills.ts +233 -0
- package/plugin/commands/close-issue.md +7 -3
- package/plugin/commands/create-pr.md +18 -12
- package/plugin/commands/implement-issue.md +7 -3
- package/plugin/commands/respond-github.md +8 -4
- package/plugin/commands/review-pr.md +44 -10
- package/plugin/commands/start-leader.md +1 -3
- package/plugin/commands/start-worker.md +1 -3
- package/plugin/commands/work-on-task.md +22 -3
- package/plugin/pi-skills/close-issue/SKILL.md +90 -0
- package/plugin/pi-skills/create-pr/SKILL.md +99 -0
- package/plugin/pi-skills/implement-issue/SKILL.md +135 -0
- package/plugin/pi-skills/investigate-sentry-issue/SKILL.md +138 -0
- package/plugin/pi-skills/respond-github/SKILL.md +98 -0
- package/plugin/pi-skills/review-offered-task/SKILL.md +45 -0
- package/plugin/pi-skills/review-pr/SKILL.md +261 -0
- package/plugin/pi-skills/start-leader/SKILL.md +121 -0
- package/plugin/pi-skills/start-worker/SKILL.md +60 -0
- package/plugin/pi-skills/swarm-chat/SKILL.md +82 -0
- package/plugin/pi-skills/todos/SKILL.md +66 -0
- package/plugin/pi-skills/work-on-task/SKILL.md +65 -0
- package/plugin/skills/artifacts/examples/approval-flow.ts +34 -0
- package/plugin/skills/artifacts/examples/hono-dashboard.ts +31 -0
- package/plugin/skills/artifacts/examples/multi-artifact.ts +20 -0
- package/plugin/skills/artifacts/examples/static-report.sh +17 -0
- package/plugin/skills/artifacts/skill.md +71 -0
- package/prek.toml +75 -0
- package/scripts/check-db-boundary.sh +60 -0
- package/scripts/e2e-docker-provider.ts +820 -0
- package/scripts/e2e-io-schemas-test.ts +807 -0
- package/scripts/e2e-provider-test.ts +220 -0
- package/scripts/e2e-workflow-redesign.sh +229 -0
- package/scripts/e2e-workflow-test.sh +285 -0
- package/scripts/e2e-workflow-test.ts +857 -0
- package/scripts/generate-openapi.ts +26 -0
- package/scripts/measure-tool-tokens.ts +118 -0
- package/scripts/x402-e2e-test.ts +195 -0
- package/scripts/x402-test-server.ts +236 -0
- package/scripts/x402-testnet-e2e.ts +668 -0
- package/slack-manifest.json +17 -0
- package/src/agentmail/app.ts +65 -0
- package/src/agentmail/handlers.ts +207 -0
- package/src/agentmail/index.ts +9 -0
- package/src/agentmail/types.ts +51 -0
- package/src/artifact-sdk/browser-sdk.ts +30 -0
- package/src/artifact-sdk/index.ts +2 -0
- package/src/artifact-sdk/localtunnel.d.ts +20 -0
- package/src/artifact-sdk/port.ts +12 -0
- package/src/artifact-sdk/server.ts +156 -0
- package/src/artifact-sdk/tunnel.ts +19 -0
- package/src/be/chunking.ts +193 -0
- package/src/be/db-queries/oauth.ts +90 -0
- package/src/be/db-queries/tracker.ts +182 -0
- package/src/be/db.ts +2729 -770
- package/src/be/embedding.ts +80 -0
- package/src/be/migrations/001_initial.sql +409 -0
- package/src/be/migrations/002_one_time_schedules.sql +59 -0
- package/src/be/migrations/003_workflows.sql +51 -0
- package/src/be/migrations/004_workflow_source.sql +81 -0
- package/src/be/migrations/005_epic_next_steps.sql +2 -0
- package/src/be/migrations/006_vcs_provider.sql +94 -0
- package/src/be/migrations/007_task_dir.sql +2 -0
- package/src/be/migrations/008_workflow_redesign.sql +85 -0
- package/src/be/migrations/009_tracker_integration.sql +144 -0
- package/src/be/migrations/010_step_diagnostics.sql +1 -0
- package/src/be/migrations/011_step_next_port.sql +1 -0
- package/src/be/migrations/012_trigger_schema.sql +1 -0
- package/src/be/migrations/013_task_output_schema.sql +2 -0
- package/src/be/migrations/runner.ts +188 -0
- package/src/cli.tsx +231 -299
- package/src/commands/artifact.ts +241 -0
- package/src/commands/onboard/compose-generator.ts +169 -0
- package/src/commands/onboard/env-generator.ts +79 -0
- package/src/commands/onboard/manifest.ts +37 -0
- package/src/commands/onboard/presets.ts +85 -0
- package/src/commands/onboard/service-names.ts +47 -0
- package/src/commands/onboard/steps/core-credentials.tsx +111 -0
- package/src/commands/onboard/steps/custom-templates.tsx +168 -0
- package/src/commands/onboard/steps/generate.tsx +154 -0
- package/src/commands/onboard/steps/harness-credentials.tsx +195 -0
- package/src/commands/onboard/steps/harness.tsx +21 -0
- package/src/commands/onboard/steps/health-check.tsx +171 -0
- package/src/commands/onboard/steps/integration-github.tsx +105 -0
- package/src/commands/onboard/steps/integration-gitlab.tsx +79 -0
- package/src/commands/onboard/steps/integration-menu.tsx +58 -0
- package/src/commands/onboard/steps/integration-sentry.tsx +79 -0
- package/src/commands/onboard/steps/integration-slack.tsx +165 -0
- package/src/commands/onboard/steps/post-connect.tsx +145 -0
- package/src/commands/onboard/steps/post-dashboard.tsx +34 -0
- package/src/commands/onboard/steps/post-task.tsx +103 -0
- package/src/commands/onboard/steps/prereq-check.tsx +178 -0
- package/src/commands/onboard/steps/review.tsx +82 -0
- package/src/commands/onboard/steps/start.tsx +97 -0
- package/src/commands/onboard/templates.ts +34 -0
- package/src/commands/onboard/types.ts +259 -0
- package/src/commands/onboard.tsx +425 -0
- package/src/commands/runner.ts +1376 -559
- package/src/commands/setup.tsx +23 -38
- package/src/commands/shared/client-config.ts +41 -0
- package/src/github/app.ts +8 -0
- package/src/github/handlers.ts +93 -75
- package/src/github/index.ts +1 -0
- package/src/github/types.ts +1 -0
- package/src/gitlab/auth.ts +63 -0
- package/src/gitlab/handlers.ts +327 -0
- package/src/gitlab/index.ts +19 -0
- package/src/gitlab/reactions.ts +104 -0
- package/src/gitlab/types.ts +130 -0
- package/src/heartbeat/heartbeat.ts +425 -0
- package/src/heartbeat/index.ts +1 -0
- package/src/hooks/hook.ts +555 -4
- package/src/hooks/tool-loop-detection.test.ts +158 -0
- package/src/hooks/tool-loop-detection.ts +167 -0
- package/src/http/active-sessions.ts +172 -0
- package/src/http/agents.ts +328 -0
- package/src/http/config.ts +191 -0
- package/src/http/core.ts +309 -0
- package/src/http/db-query.ts +91 -0
- package/src/http/ecosystem.ts +63 -0
- package/src/http/epics.ts +460 -0
- package/src/http/index.ts +213 -0
- package/src/http/mcp.ts +77 -0
- package/src/http/memory.ts +168 -0
- package/src/http/openapi.ts +109 -0
- package/src/http/poll.ts +178 -0
- package/src/http/repos.ts +195 -0
- package/src/http/route-def.ts +123 -0
- package/src/http/schedules.ts +391 -0
- package/src/http/session-data.ts +241 -0
- package/src/http/stats.ts +174 -0
- package/src/http/tasks.ts +468 -0
- package/src/http/trackers/index.ts +10 -0
- package/src/http/trackers/linear.ts +187 -0
- package/src/http/types.ts +12 -0
- package/src/http/utils.ts +87 -0
- package/src/http/webhooks.ts +432 -0
- package/src/http/workflows.ts +522 -0
- package/src/http.ts +1 -1890
- package/src/linear/README.md +65 -0
- package/src/linear/app.ts +48 -0
- package/src/linear/client.ts +18 -0
- package/src/linear/index.ts +1 -0
- package/src/linear/oauth.ts +35 -0
- package/src/linear/outbound.ts +212 -0
- package/src/linear/sync.ts +543 -0
- package/src/linear/types.ts +7 -0
- package/src/linear/webhook.ts +104 -0
- package/src/oauth/README.md +66 -0
- package/src/oauth/index.ts +6 -0
- package/src/oauth/wrapper.ts +204 -0
- package/src/prompts/base-prompt.ts +366 -24
- package/src/prompts/defaults.ts +196 -0
- package/src/providers/claude-adapter.ts +429 -0
- package/src/providers/index.ts +24 -0
- package/src/providers/pi-mono-adapter.ts +442 -0
- package/src/providers/pi-mono-extension.ts +620 -0
- package/src/providers/pi-mono-mcp-client.ts +124 -0
- package/src/providers/types.ts +75 -0
- package/src/scheduler/scheduler.test.ts +2 -0
- package/src/scheduler/scheduler.ts +186 -29
- package/src/server.ts +82 -6
- package/src/slack/HEURISTICS.md +105 -0
- package/src/slack/actions.ts +133 -0
- package/src/slack/app.ts +7 -0
- package/src/slack/assistant.ts +115 -0
- package/src/slack/blocks.ts +233 -0
- package/src/slack/commands.ts +31 -17
- package/src/slack/files.ts +1 -1
- package/src/slack/handlers.test.ts +114 -1
- package/src/slack/handlers.ts +212 -52
- package/src/slack/responses.ts +120 -67
- package/src/slack/router.ts +17 -99
- package/src/slack/thread-buffer.ts +213 -0
- package/src/slack/watcher.ts +119 -4
- package/src/tests/agent-activity.test.ts +247 -0
- package/src/tests/agentmail-filters.test.ts +97 -0
- package/src/tests/artifact-sdk.test.ts +800 -0
- package/src/tests/base-prompt.test.ts +264 -0
- package/src/tests/build-pi-skills.test.ts +127 -0
- package/src/tests/claude-adapter.test.ts +126 -0
- package/src/tests/context-versioning.test.ts +425 -0
- package/src/tests/db-queries-oauth.test.ts +197 -0
- package/src/tests/db-queries-tracker.test.ts +230 -0
- package/src/tests/epics.test.ts +3 -3
- package/src/tests/error-tracker.test.ts +368 -0
- package/src/tests/fetch-resolved-env.test.ts +167 -0
- package/src/tests/generate-default-claude-md.test.ts +9 -1
- package/src/tests/generate-identity-templates.test.ts +124 -0
- package/src/tests/gitlab-auth.test.ts +109 -0
- package/src/tests/gitlab-handlers.test.ts +691 -0
- package/src/tests/gitlab-vcs-db.test.ts +177 -0
- package/src/tests/heartbeat.test.ts +363 -0
- package/src/tests/http-api-integration.test.ts +1698 -0
- package/src/tests/linear-outbound-sync.test.ts +200 -0
- package/src/tests/linear-webhook.test.ts +402 -0
- package/src/tests/match-route.test.ts +187 -0
- package/src/tests/memory.test.ts +737 -0
- package/src/tests/migration-runner-regressions.test.ts +86 -0
- package/src/tests/model-control.test.ts +338 -0
- package/src/tests/oauth-wrapper.test.ts +147 -0
- package/src/tests/onboard-compose.test.ts +138 -0
- package/src/tests/onboard-env.test.ts +174 -0
- package/src/tests/onboard-manifest.test.ts +137 -0
- package/src/tests/pi-mono-adapter.test.ts +234 -0
- package/src/tests/progress-dedup.test.ts +98 -0
- package/src/tests/provider-adapter.test.ts +122 -0
- package/src/tests/provider-command-format.test.ts +98 -0
- package/src/tests/reload-config.test.ts +170 -0
- package/src/tests/runner-polling-api.test.ts +25 -20
- package/src/tests/scheduled-tasks.test.ts +104 -0
- package/src/tests/scheduler-backoff.test.ts +166 -0
- package/src/tests/self-improvement.test.ts +540 -0
- package/src/tests/session-attach.test.ts +536 -0
- package/src/tests/session-costs.test.ts +267 -1
- package/src/tests/slack-actions.test.ts +133 -0
- package/src/tests/slack-assistant.test.ts +136 -0
- package/src/tests/slack-blocks.test.ts +246 -0
- package/src/tests/slack-metadata-inheritance.test.ts +243 -0
- package/src/tests/slack-queue-offline.test.ts +174 -0
- package/src/tests/slack-router.test.ts +181 -0
- package/src/tests/slack-thread-buffer.test.ts +305 -0
- package/src/tests/slack-thread-followups.test.ts +298 -0
- package/src/tests/slack-watcher.test.ts +101 -0
- package/src/tests/structured-output.test.ts +311 -0
- package/src/tests/swarm-repos.test.ts +198 -0
- package/src/tests/task-cancellation.test.ts +6 -4
- package/src/tests/task-working-dir.test.ts +176 -0
- package/src/tests/template-fetch.test.ts +490 -0
- package/src/tests/tool-annotations.test.ts +371 -0
- package/src/tests/tracker-tools.test.ts +184 -0
- package/src/tests/update-profile-api.test.ts +143 -3
- package/src/tests/validation-adapters.test.ts +86 -0
- package/src/tests/vcs-provider.test.ts +27 -0
- package/src/tests/workflow-agent-task.test.ts +196 -0
- package/src/tests/workflow-async-v2.test.ts +386 -0
- package/src/tests/workflow-convergence.test.ts +541 -0
- package/src/tests/workflow-definition-validation.test.ts +290 -0
- package/src/tests/workflow-engine-v2.test.ts +691 -0
- package/src/tests/workflow-executors.test.ts +736 -0
- package/src/tests/workflow-http-v2.test.ts +599 -0
- package/src/tests/workflow-integration-io.test.ts +902 -0
- package/src/tests/workflow-io-schemas.test.ts +624 -0
- package/src/tests/workflow-registry.test.ts +592 -0
- package/src/tests/workflow-retry-v2.test.ts +401 -0
- package/src/tests/workflow-retry-validation.test.ts +282 -0
- package/src/tests/workflow-template.test.ts +288 -0
- package/src/tests/workflow-trigger-schema.test.ts +359 -0
- package/src/tests/workflow-triggers-v2.test.ts +264 -0
- package/src/tests/workflow-versions.test.ts +208 -0
- package/src/tests/x402-client.test.ts +117 -0
- package/src/tests/x402-config.test.ts +182 -0
- package/src/tests/x402-spending-tracker.test.ts +185 -0
- package/src/tools/cancel-task.ts +2 -0
- package/src/tools/context-diff.ts +171 -0
- package/src/tools/context-history.ts +138 -0
- package/src/tools/create-channel.ts +1 -0
- package/src/tools/db-query.ts +78 -0
- package/src/tools/delete-channel.ts +132 -0
- package/src/tools/epics/assign-task-to-epic.ts +1 -0
- package/src/tools/epics/create-epic.ts +3 -2
- package/src/tools/epics/delete-epic.ts +2 -0
- package/src/tools/epics/get-epic-details.ts +2 -0
- package/src/tools/epics/list-epics.ts +2 -0
- package/src/tools/epics/unassign-task-from-epic.ts +1 -0
- package/src/tools/epics/update-epic.ts +7 -4
- package/src/tools/get-swarm.ts +2 -0
- package/src/tools/get-task-details.ts +2 -0
- package/src/tools/get-tasks.ts +27 -1
- package/src/tools/inject-learning.ts +106 -0
- package/src/tools/join-swarm.ts +17 -7
- package/src/tools/list-channels.ts +2 -0
- package/src/tools/list-services.ts +2 -0
- package/src/tools/memory-get.ts +56 -0
- package/src/tools/memory-search.ts +131 -0
- package/src/tools/my-agent-info.ts +2 -0
- package/src/tools/poll-task.ts +2 -20
- package/src/tools/post-message.ts +1 -0
- package/src/tools/read-messages.ts +2 -0
- package/src/tools/register-agentmail-inbox.ts +166 -0
- package/src/tools/register-service.ts +2 -0
- package/src/tools/schedules/create-schedule.ts +134 -24
- package/src/tools/schedules/delete-schedule.ts +2 -0
- package/src/tools/schedules/list-schedules.ts +20 -4
- package/src/tools/schedules/run-schedule-now.ts +1 -0
- package/src/tools/schedules/update-schedule.ts +49 -17
- package/src/tools/send-task.ts +132 -10
- package/src/tools/slack-download-file.ts +4 -2
- package/src/tools/slack-list-channels.ts +2 -0
- package/src/tools/slack-post.ts +2 -0
- package/src/tools/slack-read.ts +2 -0
- package/src/tools/slack-reply.ts +2 -0
- package/src/tools/slack-upload-file.ts +2 -0
- package/src/tools/store-progress.ts +187 -4
- package/src/tools/swarm-config/delete-config.ts +87 -0
- package/src/tools/swarm-config/get-config.ts +108 -0
- package/src/tools/swarm-config/index.ts +4 -0
- package/src/tools/swarm-config/list-config.ts +99 -0
- package/src/tools/swarm-config/set-config.ts +118 -0
- package/src/tools/task-action.ts +30 -5
- package/src/tools/task-dedup.ts +97 -0
- package/src/tools/tool-config.ts +117 -0
- package/src/tools/tracker/index.ts +6 -0
- package/src/tools/tracker/tracker-link-epic.ts +64 -0
- package/src/tools/tracker/tracker-link-task.ts +64 -0
- package/src/tools/tracker/tracker-map-agent.ts +57 -0
- package/src/tools/tracker/tracker-status.ts +56 -0
- package/src/tools/tracker/tracker-sync-status.ts +42 -0
- package/src/tools/tracker/tracker-unlink.ts +41 -0
- package/src/tools/unregister-service.ts +2 -0
- package/src/tools/update-profile.ts +93 -10
- package/src/tools/update-service-status.ts +2 -0
- package/src/tools/utils.ts +10 -1
- package/src/tools/workflows/create-workflow.ts +111 -0
- package/src/tools/workflows/delete-workflow.ts +42 -0
- package/src/tools/workflows/get-workflow-run.ts +59 -0
- package/src/tools/workflows/get-workflow.ts +53 -0
- package/src/tools/workflows/index.ts +9 -0
- package/src/tools/workflows/list-workflow-runs.ts +48 -0
- package/src/tools/workflows/list-workflows.ts +42 -0
- package/src/tools/workflows/retry-workflow-run.ts +40 -0
- package/src/tools/workflows/trigger-workflow.ts +96 -0
- package/src/tools/workflows/update-workflow.ts +118 -0
- package/src/tracker/types.ts +51 -0
- package/src/types.ts +477 -14
- package/src/utils/credentials.test.ts +156 -0
- package/src/utils/credentials.ts +50 -0
- package/src/utils/error-tracker.ts +190 -0
- package/src/vcs/index.ts +15 -0
- package/src/vcs/types.ts +5 -0
- package/src/workflows/checkpoint.ts +121 -0
- package/src/workflows/cooldown.ts +28 -0
- package/src/workflows/definition.ts +217 -0
- package/src/workflows/engine.ts +554 -0
- package/src/workflows/event-bus.ts +29 -0
- package/src/workflows/executors/agent-task.ts +92 -0
- package/src/workflows/executors/base.ts +86 -0
- package/src/workflows/executors/code-match.ts +88 -0
- package/src/workflows/executors/index.ts +16 -0
- package/src/workflows/executors/notify.ts +93 -0
- package/src/workflows/executors/property-match.ts +104 -0
- package/src/workflows/executors/raw-llm.ts +83 -0
- package/src/workflows/executors/registry.ts +76 -0
- package/src/workflows/executors/script.ts +103 -0
- package/src/workflows/executors/validate.ts +215 -0
- package/src/workflows/executors/vcs.ts +58 -0
- package/src/workflows/index.ts +61 -0
- package/src/workflows/input.ts +46 -0
- package/src/workflows/json-schema-validator.ts +118 -0
- package/src/workflows/recovery.ts +139 -0
- package/src/workflows/resume.ts +143 -0
- package/src/workflows/retry-poller.ts +216 -0
- package/src/workflows/template.ts +74 -0
- package/src/workflows/templates.ts +86 -0
- package/src/workflows/triggers.ts +95 -0
- package/src/workflows/validation.ts +104 -0
- package/src/workflows/version.ts +42 -0
- package/src/x402/cli.ts +140 -0
- package/src/x402/client.ts +192 -0
- package/src/x402/config.ts +131 -0
- package/src/x402/index.ts +37 -0
- package/src/x402/openfort-signer.ts +83 -0
- package/src/x402/spending-tracker.ts +109 -0
- package/templates/community/.gitkeep +0 -0
- package/templates/official/coder/CLAUDE.md +49 -0
- package/templates/official/coder/IDENTITY.md +28 -0
- package/templates/official/coder/SOUL.md +43 -0
- package/templates/official/coder/TOOLS.md +40 -0
- package/templates/official/coder/config.json +23 -0
- package/templates/official/coder/start-up.sh +23 -0
- package/templates/official/content-reviewer/CLAUDE.md +68 -0
- package/templates/official/content-reviewer/IDENTITY.md +28 -0
- package/templates/official/content-reviewer/SOUL.md +44 -0
- package/templates/official/content-reviewer/TOOLS.md +37 -0
- package/templates/official/content-reviewer/config.json +23 -0
- package/templates/official/content-reviewer/start-up.sh +23 -0
- package/templates/official/content-strategist/CLAUDE.md +63 -0
- package/templates/official/content-strategist/IDENTITY.md +33 -0
- package/templates/official/content-strategist/SOUL.md +48 -0
- package/templates/official/content-strategist/TOOLS.md +47 -0
- package/templates/official/content-strategist/config.json +23 -0
- package/templates/official/content-strategist/start-up.sh +23 -0
- package/templates/official/content-writer/CLAUDE.md +72 -0
- package/templates/official/content-writer/IDENTITY.md +30 -0
- package/templates/official/content-writer/SOUL.md +46 -0
- package/templates/official/content-writer/TOOLS.md +44 -0
- package/templates/official/content-writer/config.json +23 -0
- package/templates/official/content-writer/start-up.sh +23 -0
- package/templates/official/forward-deployed-engineer/CLAUDE.md +54 -0
- package/templates/official/forward-deployed-engineer/IDENTITY.md +37 -0
- package/templates/official/forward-deployed-engineer/SOUL.md +55 -0
- package/templates/official/forward-deployed-engineer/config.json +21 -0
- package/templates/official/lead/CLAUDE.md +33 -0
- package/templates/official/lead/IDENTITY.md +36 -0
- package/templates/official/lead/SOUL.md +51 -0
- package/templates/official/lead/config.json +22 -0
- package/templates/official/researcher/CLAUDE.md +46 -0
- package/templates/official/researcher/IDENTITY.md +28 -0
- package/templates/official/researcher/SOUL.md +43 -0
- package/templates/official/researcher/config.json +21 -0
- package/templates/official/reviewer/CLAUDE.md +63 -0
- package/templates/official/reviewer/IDENTITY.md +28 -0
- package/templates/official/reviewer/SOUL.md +45 -0
- package/templates/official/reviewer/config.json +21 -0
- package/templates/official/tester/CLAUDE.md +53 -0
- package/templates/official/tester/IDENTITY.md +28 -0
- package/templates/official/tester/SOUL.md +55 -0
- package/templates/official/tester/config.json +21 -0
- package/templates/schema.ts +35 -0
- package/templates-ui/README.md +46 -0
- package/templates-ui/components.json +17 -0
- package/templates-ui/eslint.config.mjs +18 -0
- package/templates-ui/next.config.ts +7 -0
- package/templates-ui/package.json +35 -0
- package/templates-ui/pnpm-lock.yaml +4571 -0
- package/templates-ui/postcss.config.mjs +7 -0
- package/templates-ui/public/file.svg +1 -0
- package/templates-ui/public/globe.svg +1 -0
- package/templates-ui/public/logo.png +0 -0
- package/templates-ui/public/next.svg +1 -0
- package/templates-ui/public/vercel.svg +1 -0
- package/templates-ui/public/window.svg +1 -0
- package/templates-ui/src/app/[category]/[name]/page.tsx +89 -0
- package/templates-ui/src/app/api/templates/[...slug]/route.ts +52 -0
- package/templates-ui/src/app/api/templates/route.ts +18 -0
- package/templates-ui/src/app/builder/page.tsx +37 -0
- package/templates-ui/src/app/globals.css +94 -0
- package/templates-ui/src/app/layout.tsx +79 -0
- package/templates-ui/src/app/page.tsx +38 -0
- package/templates-ui/src/app/robots.ts +11 -0
- package/templates-ui/src/app/sitemap.ts +31 -0
- package/templates-ui/src/components/compose-builder.tsx +442 -0
- package/templates-ui/src/components/compose-preview.tsx +117 -0
- package/templates-ui/src/components/file-preview.tsx +77 -0
- package/templates-ui/src/components/footer.tsx +40 -0
- package/templates-ui/src/components/header.tsx +41 -0
- package/templates-ui/src/components/template-card.tsx +87 -0
- package/templates-ui/src/components/template-detail.tsx +125 -0
- package/templates-ui/src/components/template-gallery.tsx +263 -0
- package/templates-ui/src/components/ui/badge.tsx +36 -0
- package/templates-ui/src/components/ui/button.tsx +57 -0
- package/templates-ui/src/components/ui/card.tsx +76 -0
- package/templates-ui/src/components/ui/separator.tsx +31 -0
- package/templates-ui/src/components/ui/tooltip.tsx +32 -0
- package/templates-ui/src/lib/compose-generator.ts +241 -0
- package/templates-ui/src/lib/templates.ts +137 -0
- package/templates-ui/src/lib/utils.ts +6 -0
- package/templates-ui/tsconfig.json +34 -0
- package/thoughts/research/2026-02-28-openfort-viem-x402-research.md +679 -0
- package/thoughts/research/2026-02-28-x402-payments-research.md +686 -0
- package/thoughts/researcher/plans/2026-02-20-agent-self-improvement-plan.md +282 -0
- package/thoughts/researcher/research/2026-02-20-agent-self-improvement.md +492 -0
- package/thoughts/shared/plans/2026-02-26-mcp-tool-context-reduction.md +282 -0
- package/thoughts/shared/plans/2026-03-02-claude-context-mode-integration.md +328 -0
- package/thoughts/shared/plans/2026-03-02-code-level-heartbeat.md +224 -0
- package/thoughts/shared/research/2026-02-26-cliffy-mcp-tools.md +159 -0
- package/thoughts/shared/research/2026-03-03-database-migration-system-refactor.md +337 -0
- package/thoughts/swarm-researcher/plans/2026-02-23-openclaw-improvements-plan.md +778 -0
- package/thoughts/swarm-researcher/plans/2026-02-26-artifacts-localtunnel-plan.md +1269 -0
- package/thoughts/swarm-researcher/research/2026-02-23-openclaw-vs-agent-swarm-comparison.md +411 -0
- package/thoughts/swarm-researcher/research/2026-02-26-artifacts-localtunnel.md +724 -0
- package/thoughts/taras/brainstorms/2026-03-20-prompt-template-registry.md +443 -0
- package/thoughts/taras/brainstorms/2026-03-20-setup-cli-onboarding.md +307 -0
- package/thoughts/taras/plans/2026-02-20-auto-improvement.md +803 -0
- package/thoughts/taras/plans/2026-02-20-env-management.md +538 -0
- package/thoughts/taras/plans/2026-02-20-memory-system.md +882 -0
- package/thoughts/taras/plans/2026-02-20-repos-knowledge.md +806 -0
- package/thoughts/taras/plans/2026-02-20-session-attach.md +647 -0
- package/thoughts/taras/plans/2026-02-20-worker-identity.md +820 -0
- package/thoughts/taras/plans/2026-02-25-feat-new-ui-visual-redesign-plan.md +768 -0
- package/thoughts/taras/plans/2026-03-04-fix-buildSystemPrompt-missing-fields.md +77 -0
- package/thoughts/taras/plans/2026-03-04-new-ui-missing-actions.md +543 -0
- package/thoughts/taras/plans/2026-03-06-one-time-scheduled-tasks.md +373 -0
- package/thoughts/taras/plans/2026-03-08-memory-self-improvement-enhancements.md +512 -0
- package/thoughts/taras/plans/2026-03-08-pi-mono-provider-implementation.md +919 -0
- package/thoughts/taras/plans/2026-03-09-templates-registry.md +723 -0
- package/thoughts/taras/plans/2026-03-10-task-working-directory.md +371 -0
- package/thoughts/taras/plans/2026-03-11-archil-per-agent-write-strategy.md +621 -0
- package/thoughts/taras/plans/2026-03-12-eliminate-inbox-route-to-tasks.md +61 -0
- package/thoughts/taras/plans/2026-03-12-slack-thread-followup-additive.md +488 -0
- package/thoughts/taras/plans/2026-03-13-slack-ai-improvements.md +644 -0
- package/thoughts/taras/plans/2026-03-16-route-wrapper-openapi.md +636 -0
- package/thoughts/taras/plans/2026-03-17-multi-api-config.md +444 -0
- package/thoughts/taras/plans/2026-03-18-agent-fs-integration.md +591 -0
- package/thoughts/taras/plans/2026-03-18-debug-db-explorer.md +446 -0
- package/thoughts/taras/plans/2026-03-18-workflow-redesign.md +987 -0
- package/thoughts/taras/plans/2026-03-19-compound-learnings.md +403 -0
- package/thoughts/taras/plans/2026-03-19-ticket-tracker-linear-integration.md +860 -0
- package/thoughts/taras/plans/2026-03-19-workflow-io-schemas-and-bugs.md +899 -0
- package/thoughts/taras/plans/2026-03-20-setup-cli-onboarding.md +874 -0
- package/thoughts/taras/plans/2026-03-20-workflow-structured-output-validation-workspace.md +723 -0
- package/thoughts/taras/research/2026-02-19-agent-native-swarm-architecture.md +390 -0
- package/thoughts/taras/research/2026-02-19-swarm-gaps-implementation.md +594 -0
- package/thoughts/taras/research/2026-02-25-dashboard-ui-design-best-practices.md +825 -0
- package/thoughts/taras/research/2026-02-26-task-detail-page-redesign.md +393 -0
- package/thoughts/taras/research/2026-03-03-new-ui-missing-actions.md +168 -0
- package/thoughts/taras/research/2026-03-05-pi-mono-provider-research.md +230 -0
- package/thoughts/taras/research/2026-03-06-workflow-engine-design.md +445 -0
- package/thoughts/taras/research/2026-03-08-drive-loop-concept.md +375 -0
- package/thoughts/taras/research/2026-03-08-pi-mono-deep-dive.md +869 -0
- package/thoughts/taras/research/2026-03-09-templates-registry.md +373 -0
- package/thoughts/taras/research/2026-03-10-agent-working-directory.md +223 -0
- package/thoughts/taras/research/2026-03-10-configurable-event-prompts.md +339 -0
- package/thoughts/taras/research/2026-03-11-archil-production-setup.md +181 -0
- package/thoughts/taras/research/2026-03-11-archil-shared-disk-write-strategies.md +437 -0
- package/thoughts/taras/research/2026-03-13-slack-ai-features.md +258 -0
- package/thoughts/taras/research/2026-03-16-openapi-docs-generation.md +335 -0
- package/thoughts/taras/research/2026-03-16-route-wrapper-openapi.md +670 -0
- package/thoughts/taras/research/2026-03-16-slack-thread-followups-e2e.md +54 -0
- package/thoughts/taras/research/2026-03-18-agent-fs-integration.md +558 -0
- package/thoughts/taras/research/2026-03-18-linear-integration-finalization.md +526 -0
- package/thoughts/taras/research/2026-03-18-workflow-redesign.md +797 -0
- package/thoughts/taras/research/2026-03-19-workflow-node-io-schemas-and-bugs.md +563 -0
- package/thoughts/taras/research/2026-03-19-workflow-structured-output-validation-workspace.md +486 -0
- package/thoughts/taras/research/2026-03-20-prompt-template-registry.md +469 -0
- package/tsconfig.json +1 -1
- package/FAQ.md +0 -19
- package/src/tests/get-inbox-message.test.ts +0 -145
- package/src/tools/get-inbox-message.ts +0 -89
- package/src/tools/inbox-delegate.ts +0 -113
- package/ui/CLAUDE.md +0 -49
- package/ui/bun.lock +0 -771
- package/ui/index.html +0 -22
- package/ui/package-lock.json +0 -5290
- package/ui/package.json +0 -33
- package/ui/pnpm-lock.yaml +0 -3341
- package/ui/postcss.config.js +0 -6
- package/ui/src/App.tsx +0 -63
- package/ui/src/components/ActivityFeed.tsx +0 -440
- package/ui/src/components/AgentDetailPanel.tsx +0 -733
- package/ui/src/components/AgentsPanel.tsx +0 -815
- package/ui/src/components/ChatPanel.tsx +0 -1920
- package/ui/src/components/ConfigModal.tsx +0 -253
- package/ui/src/components/Dashboard.tsx +0 -832
- package/ui/src/components/EditAgentProfileModal.tsx +0 -433
- package/ui/src/components/EpicDetailPage.tsx +0 -741
- package/ui/src/components/EpicsPanel.tsx +0 -566
- package/ui/src/components/Header.tsx +0 -160
- package/ui/src/components/JsonViewer.tsx +0 -171
- package/ui/src/components/ScheduledTaskDetailPanel.tsx +0 -517
- package/ui/src/components/ScheduledTasksPanel.tsx +0 -639
- package/ui/src/components/ServicesPanel.tsx +0 -622
- package/ui/src/components/SessionLogPanel.tsx +0 -1219
- package/ui/src/components/StatsBar.tsx +0 -321
- package/ui/src/components/StatusBadge.tsx +0 -168
- package/ui/src/components/TaskDetailPanel.tsx +0 -903
- package/ui/src/components/TasksPanel.tsx +0 -614
- package/ui/src/components/UsageCharts.tsx +0 -216
- package/ui/src/components/UsageTab.tsx +0 -394
- package/ui/src/hooks/queries.ts +0 -353
- package/ui/src/index.css +0 -257
- package/ui/src/lib/api.ts +0 -268
- package/ui/src/lib/config.ts +0 -35
- package/ui/src/lib/contentPreview.ts +0 -208
- package/ui/src/lib/theme.ts +0 -214
- package/ui/src/main.tsx +0 -28
- package/ui/src/vite-env.d.ts +0 -1
- package/ui/tailwind.config.js +0 -37
- package/ui/vite.config.ts +0 -35
- /package/{ui → docs-site}/public/logo.png +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { generateOpenApiSpec } from "../src/http/openapi";
|
|
2
|
+
// Import all handler files to trigger route() registrations
|
|
3
|
+
import "../src/http/active-sessions";
|
|
4
|
+
import "../src/http/agents";
|
|
5
|
+
import "../src/http/config";
|
|
6
|
+
import "../src/http/db-query";
|
|
7
|
+
import "../src/http/ecosystem";
|
|
8
|
+
import "../src/http/epics";
|
|
9
|
+
import "../src/http/memory";
|
|
10
|
+
import "../src/http/poll";
|
|
11
|
+
import "../src/http/repos";
|
|
12
|
+
import "../src/http/schedules";
|
|
13
|
+
import "../src/http/session-data";
|
|
14
|
+
import "../src/http/stats";
|
|
15
|
+
import "../src/http/tasks";
|
|
16
|
+
import "../src/http/trackers/linear";
|
|
17
|
+
import "../src/http/webhooks";
|
|
18
|
+
import "../src/http/workflows";
|
|
19
|
+
|
|
20
|
+
const version = (await Bun.file("package.json").json()).version;
|
|
21
|
+
const spec = generateOpenApiSpec({ version, serverUrl: "http://localhost:3013" });
|
|
22
|
+
await Bun.write("openapi.json", spec);
|
|
23
|
+
console.log(`Generated openapi.json (${(spec.length / 1024).toFixed(1)}KB)`);
|
|
24
|
+
|
|
25
|
+
// Auto-generate docs-site API reference from the new spec
|
|
26
|
+
await Bun.$`bun docs-site/scripts/generate-docs.ts`;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Measures token overhead from MCP tool definitions.
|
|
4
|
+
*
|
|
5
|
+
* Uses a simple heuristic: ~4 characters per token (GPT/Claude approximation).
|
|
6
|
+
* For exact counts, use tiktoken or the Anthropic tokenizer.
|
|
7
|
+
*
|
|
8
|
+
* Usage: bun scripts/measure-tool-tokens.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { closeDb, initDb } from "../src/be/db";
|
|
12
|
+
import { createServer } from "../src/server";
|
|
13
|
+
import { CORE_TOOLS, DEFERRED_TOOLS } from "../src/tools/tool-config";
|
|
14
|
+
|
|
15
|
+
const DB_PATH = "./measure-tokens-temp.sqlite";
|
|
16
|
+
|
|
17
|
+
// Simple token estimation: ~4 chars per token for English text + JSON
|
|
18
|
+
function estimateTokens(text: string): number {
|
|
19
|
+
return Math.ceil(text.length / 4);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function main() {
|
|
23
|
+
// Initialize DB and server to get registered tools
|
|
24
|
+
initDb(DB_PATH);
|
|
25
|
+
const server = createServer();
|
|
26
|
+
|
|
27
|
+
const tools = (server as unknown as { _registeredTools: Record<string, unknown> })
|
|
28
|
+
._registeredTools;
|
|
29
|
+
|
|
30
|
+
const toolNames = Object.keys(tools);
|
|
31
|
+
|
|
32
|
+
// Build tool definitions as they'd appear in the tools/list response
|
|
33
|
+
let totalChars = 0;
|
|
34
|
+
let coreChars = 0;
|
|
35
|
+
let deferredChars = 0;
|
|
36
|
+
let coreCount = 0;
|
|
37
|
+
let deferredCount = 0;
|
|
38
|
+
|
|
39
|
+
const toolSizes: { name: string; chars: number; tokens: number; classification: string }[] = [];
|
|
40
|
+
|
|
41
|
+
for (const name of toolNames) {
|
|
42
|
+
const tool = tools[name] as Record<string, unknown>;
|
|
43
|
+
// Serialize the tool definition as it would appear in the MCP response
|
|
44
|
+
const definition = JSON.stringify({
|
|
45
|
+
name,
|
|
46
|
+
title: tool.title,
|
|
47
|
+
description: tool.description,
|
|
48
|
+
inputSchema: tool.inputSchema,
|
|
49
|
+
annotations: tool.annotations,
|
|
50
|
+
});
|
|
51
|
+
const chars = definition.length;
|
|
52
|
+
const tokens = estimateTokens(definition);
|
|
53
|
+
const isCore = CORE_TOOLS.has(name);
|
|
54
|
+
const isDeferred = DEFERRED_TOOLS.has(name);
|
|
55
|
+
|
|
56
|
+
totalChars += chars;
|
|
57
|
+
if (isCore) {
|
|
58
|
+
coreChars += chars;
|
|
59
|
+
coreCount++;
|
|
60
|
+
} else if (isDeferred) {
|
|
61
|
+
deferredChars += chars;
|
|
62
|
+
deferredCount++;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
toolSizes.push({
|
|
66
|
+
name,
|
|
67
|
+
chars,
|
|
68
|
+
tokens,
|
|
69
|
+
classification: isCore ? "CORE" : isDeferred ? "DEFERRED" : "UNCLASSIFIED",
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Sort by size descending
|
|
74
|
+
toolSizes.sort((a, b) => b.chars - a.chars);
|
|
75
|
+
|
|
76
|
+
console.log("=== MCP Tool Token Measurement ===\n");
|
|
77
|
+
console.log(`Total registered tools: ${toolNames.length}`);
|
|
78
|
+
console.log(`Core tools: ${coreCount}`);
|
|
79
|
+
console.log(`Deferred tools: ${deferredCount}`);
|
|
80
|
+
console.log();
|
|
81
|
+
|
|
82
|
+
const allTokens = Math.ceil(totalChars / 4);
|
|
83
|
+
const coreOnlyTokens = Math.ceil(coreChars / 4);
|
|
84
|
+
const deferredOnlyTokens = Math.ceil(deferredChars / 4);
|
|
85
|
+
const reduction = ((allTokens - coreOnlyTokens) / allTokens) * 100;
|
|
86
|
+
|
|
87
|
+
console.log("--- Token Estimates (JSON serialized, ~4 chars/token) ---\n");
|
|
88
|
+
console.log(`All tools: ~${allTokens.toLocaleString()} tokens (${totalChars.toLocaleString()} chars)`);
|
|
89
|
+
console.log(`Core only: ~${coreOnlyTokens.toLocaleString()} tokens (${coreChars.toLocaleString()} chars)`);
|
|
90
|
+
console.log(`Deferred only: ~${deferredOnlyTokens.toLocaleString()} tokens (${deferredChars.toLocaleString()} chars)`);
|
|
91
|
+
console.log(`\nSavings: ~${(allTokens - coreOnlyTokens).toLocaleString()} tokens (${reduction.toFixed(1)}% reduction)`);
|
|
92
|
+
|
|
93
|
+
console.log("\n--- Per-Tool Breakdown (sorted by size) ---\n");
|
|
94
|
+
console.log(" Tool Name".padEnd(35) + "Chars".padStart(8) + "Tokens".padStart(8) + " Class");
|
|
95
|
+
console.log("-".repeat(70));
|
|
96
|
+
for (const t of toolSizes) {
|
|
97
|
+
const marker = t.classification === "CORE" ? "●" : "○";
|
|
98
|
+
console.log(
|
|
99
|
+
` ${marker} ${t.name}`.padEnd(35) +
|
|
100
|
+
String(t.chars).padStart(8) +
|
|
101
|
+
String(t.tokens).padStart(8) +
|
|
102
|
+
` ${t.classification}`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Cleanup
|
|
107
|
+
closeDb();
|
|
108
|
+
const { unlink } = await import("node:fs/promises");
|
|
109
|
+
for (const suffix of ["", "-wal", "-shm"]) {
|
|
110
|
+
try {
|
|
111
|
+
await unlink(DB_PATH + suffix);
|
|
112
|
+
} catch {
|
|
113
|
+
// ignore
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* x402 End-to-End Test
|
|
4
|
+
*
|
|
5
|
+
* Tests the full x402 payment flow:
|
|
6
|
+
* 1. Starts the dummy x402 test server
|
|
7
|
+
* 2. Creates an x402 client (with viem signer using a test key)
|
|
8
|
+
* 3. Makes a request to the paid endpoint
|
|
9
|
+
* 4. Verifies the 402 → sign → retry → 200 flow works
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* bun scripts/x402-e2e-test.ts
|
|
13
|
+
*
|
|
14
|
+
* Environment:
|
|
15
|
+
* Set EVM_PRIVATE_KEY or OPENFORT_API_KEY + OPENFORT_WALLET_SECRET
|
|
16
|
+
* If none set, uses a hardcoded test key (viem signer).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createX402Client } from "../src/x402/client.ts";
|
|
20
|
+
import type { Subprocess } from "bun";
|
|
21
|
+
|
|
22
|
+
const TEST_PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
|
|
23
|
+
const SERVER_PORT = 4021;
|
|
24
|
+
const BASE_URL = `http://localhost:${SERVER_PORT}`;
|
|
25
|
+
|
|
26
|
+
let serverProcess: Subprocess | null = null;
|
|
27
|
+
|
|
28
|
+
async function startServer(): Promise<void> {
|
|
29
|
+
serverProcess = Bun.spawn(["bun", "scripts/x402-test-server.ts", String(SERVER_PORT)], {
|
|
30
|
+
stdout: "pipe",
|
|
31
|
+
stderr: "pipe",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Wait for server to be ready
|
|
35
|
+
for (let i = 0; i < 30; i++) {
|
|
36
|
+
try {
|
|
37
|
+
const res = await fetch(`${BASE_URL}/health`);
|
|
38
|
+
if (res.ok) return;
|
|
39
|
+
} catch {
|
|
40
|
+
// Server not ready yet
|
|
41
|
+
}
|
|
42
|
+
await Bun.sleep(100);
|
|
43
|
+
}
|
|
44
|
+
throw new Error("Server failed to start within 3 seconds");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function stopServer(): void {
|
|
48
|
+
if (serverProcess) {
|
|
49
|
+
serverProcess.kill();
|
|
50
|
+
serverProcess = null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function log(msg: string): void {
|
|
55
|
+
console.log(` ${msg}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function pass(name: string): void {
|
|
59
|
+
console.log(` PASS ${name}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function fail(name: string, error: unknown): void {
|
|
63
|
+
console.log(` FAIL ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function runTests(): Promise<{ passed: number; failed: number }> {
|
|
67
|
+
let passed = 0;
|
|
68
|
+
let failed = 0;
|
|
69
|
+
|
|
70
|
+
// Determine signer type
|
|
71
|
+
const hasOpenfort = !!process.env.OPENFORT_API_KEY;
|
|
72
|
+
const hasViem = !!process.env.EVM_PRIVATE_KEY;
|
|
73
|
+
|
|
74
|
+
if (!hasOpenfort && !hasViem) {
|
|
75
|
+
log(`No signer env vars set. Using test private key (viem signer).`);
|
|
76
|
+
process.env.EVM_PRIVATE_KEY = TEST_PRIVATE_KEY;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Test 1: Free endpoint works
|
|
80
|
+
try {
|
|
81
|
+
const res = await fetch(`${BASE_URL}/`);
|
|
82
|
+
const body = await res.json();
|
|
83
|
+
if (res.status !== 200 || body.status !== "ok") throw new Error(`Expected 200 ok, got ${res.status}`);
|
|
84
|
+
pass("Free endpoint returns 200");
|
|
85
|
+
passed++;
|
|
86
|
+
} catch (e) {
|
|
87
|
+
fail("Free endpoint returns 200", e);
|
|
88
|
+
failed++;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Test 2: Paid endpoint returns 402 without payment
|
|
92
|
+
try {
|
|
93
|
+
const res = await fetch(`${BASE_URL}/paid`);
|
|
94
|
+
if (res.status !== 402) throw new Error(`Expected 402, got ${res.status}`);
|
|
95
|
+
const body = await res.json();
|
|
96
|
+
if (!body.accepts || body.x402Version !== 2) throw new Error("Missing x402 payment requirements");
|
|
97
|
+
pass("Paid endpoint returns 402 without payment");
|
|
98
|
+
passed++;
|
|
99
|
+
} catch (e) {
|
|
100
|
+
fail("Paid endpoint returns 402 without payment", e);
|
|
101
|
+
failed++;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Test 3: Full x402 flow with viem/openfort signer
|
|
105
|
+
try {
|
|
106
|
+
const client = await createX402Client();
|
|
107
|
+
log(`Using ${client.config.signerType} signer, wallet: ${client.walletAddress}`);
|
|
108
|
+
|
|
109
|
+
const res = await client.fetch(`${BASE_URL}/paid`);
|
|
110
|
+
const body = await res.json();
|
|
111
|
+
|
|
112
|
+
if (res.status !== 200) {
|
|
113
|
+
throw new Error(`Expected 200 after payment, got ${res.status}: ${JSON.stringify(body)}`);
|
|
114
|
+
}
|
|
115
|
+
if (!body.paymentAccepted) {
|
|
116
|
+
throw new Error("Server did not acknowledge payment acceptance");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
pass(`Full x402 flow (${client.config.signerType} signer) → 200 with payment accepted`);
|
|
120
|
+
log(` Payer: ${body.payer}`);
|
|
121
|
+
log(` Amount: ${body.amount}`);
|
|
122
|
+
passed++;
|
|
123
|
+
} catch (e) {
|
|
124
|
+
fail("Full x402 flow", e);
|
|
125
|
+
failed++;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Test 4: Spending tracker records payment
|
|
129
|
+
try {
|
|
130
|
+
const client = await createX402Client();
|
|
131
|
+
const summaryBefore = client.getSpendingSummary();
|
|
132
|
+
const countBefore = summaryBefore.todayCount;
|
|
133
|
+
|
|
134
|
+
await client.fetch(`${BASE_URL}/paid`);
|
|
135
|
+
|
|
136
|
+
const summaryAfter = client.getSpendingSummary();
|
|
137
|
+
if (summaryAfter.todayCount !== countBefore + 1) {
|
|
138
|
+
throw new Error(`Expected ${countBefore + 1} payments, got ${summaryAfter.todayCount}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
pass("Spending tracker records payment");
|
|
142
|
+
log(` Spent today: $${summaryAfter.todaySpent.toFixed(4)}`);
|
|
143
|
+
passed++;
|
|
144
|
+
} catch (e) {
|
|
145
|
+
fail("Spending tracker records payment", e);
|
|
146
|
+
failed++;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Test 5: Expensive endpoint blocked by spending limit (default $1.00/request)
|
|
150
|
+
try {
|
|
151
|
+
const client = await createX402Client();
|
|
152
|
+
|
|
153
|
+
const res = await client.fetch(`${BASE_URL}/paid/expensive`);
|
|
154
|
+
// The spending tracker should block this since $5 > $1 per-request limit
|
|
155
|
+
// The x402 client will throw or return an error
|
|
156
|
+
// Actually, the abort happens in the hook which throws
|
|
157
|
+
fail("Expensive endpoint should be blocked by spending limit", "No error thrown");
|
|
158
|
+
failed++;
|
|
159
|
+
} catch (e) {
|
|
160
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
161
|
+
if (msg.includes("exceeds per-request limit") || msg.includes("abort") || msg.includes("Failed to create payment")) {
|
|
162
|
+
pass("Expensive endpoint blocked by spending limit ($5 > $1 max)");
|
|
163
|
+
passed++;
|
|
164
|
+
} else {
|
|
165
|
+
fail("Expensive endpoint blocked by spending limit", e);
|
|
166
|
+
failed++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return { passed, failed };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function main() {
|
|
174
|
+
console.log("x402 End-to-End Test");
|
|
175
|
+
console.log("====================\n");
|
|
176
|
+
|
|
177
|
+
console.log("Starting test server...");
|
|
178
|
+
await startServer();
|
|
179
|
+
console.log(`Server running on ${BASE_URL}\n`);
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const { passed, failed } = await runTests();
|
|
183
|
+
console.log(`\nResults: ${passed} passed, ${failed} failed`);
|
|
184
|
+
process.exitCode = failed > 0 ? 1 : 0;
|
|
185
|
+
} finally {
|
|
186
|
+
stopServer();
|
|
187
|
+
console.log("Server stopped.");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
main().catch((error) => {
|
|
192
|
+
console.error("Fatal:", error instanceof Error ? error.message : String(error));
|
|
193
|
+
stopServer();
|
|
194
|
+
process.exit(1);
|
|
195
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Dummy x402 Test Server
|
|
4
|
+
*
|
|
5
|
+
* A minimal HTTP server with an x402-protected endpoint for testing the payment flow.
|
|
6
|
+
* Does NOT settle on-chain — just verifies the EIP-712 signature from the payment header.
|
|
7
|
+
*
|
|
8
|
+
* Endpoints:
|
|
9
|
+
* GET / — Free endpoint (returns 200)
|
|
10
|
+
* GET /paid — x402-protected endpoint (returns 402, then 200 with valid payment)
|
|
11
|
+
* GET /paid/expensive — x402-protected with higher price ($5 USDC)
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* bun scripts/x402-test-server.ts [port]
|
|
15
|
+
*
|
|
16
|
+
* Default port: 4020
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { getAddress, verifyTypedData } from "viem";
|
|
20
|
+
import { encodePaymentRequiredHeader } from "@x402/core/http";
|
|
21
|
+
|
|
22
|
+
const PORT = Number.parseInt(process.argv[2] || "4020", 10);
|
|
23
|
+
|
|
24
|
+
// A well-known test address to use as payTo (doesn't need to be real for testing)
|
|
25
|
+
const PAY_TO = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // vitalik.eth
|
|
26
|
+
|
|
27
|
+
// USDC on Base Sepolia — EIP-712 domain params
|
|
28
|
+
const USDC_ADDRESS = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
29
|
+
const USDC_NAME = "USD Coin";
|
|
30
|
+
const USDC_VERSION = "2";
|
|
31
|
+
const CHAIN_ID = 84532; // Base Sepolia
|
|
32
|
+
|
|
33
|
+
// EIP-3009 TransferWithAuthorization types
|
|
34
|
+
const authorizationTypes = {
|
|
35
|
+
TransferWithAuthorization: [
|
|
36
|
+
{ name: "from", type: "address" },
|
|
37
|
+
{ name: "to", type: "address" },
|
|
38
|
+
{ name: "value", type: "uint256" },
|
|
39
|
+
{ name: "validAfter", type: "uint256" },
|
|
40
|
+
{ name: "validBefore", type: "uint256" },
|
|
41
|
+
{ name: "nonce", type: "bytes32" },
|
|
42
|
+
],
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
interface PaymentRequired {
|
|
46
|
+
x402Version: number;
|
|
47
|
+
resource: { url: string; description: string; mimeType: string };
|
|
48
|
+
accepts: Array<{
|
|
49
|
+
scheme: string;
|
|
50
|
+
network: string;
|
|
51
|
+
asset: string;
|
|
52
|
+
amount: string;
|
|
53
|
+
payTo: string;
|
|
54
|
+
maxTimeoutSeconds: number;
|
|
55
|
+
extra: Record<string, unknown>;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function buildPaymentRequired(url: string, amount: string): PaymentRequired {
|
|
60
|
+
return {
|
|
61
|
+
x402Version: 2,
|
|
62
|
+
resource: {
|
|
63
|
+
url,
|
|
64
|
+
description: "Premium test content",
|
|
65
|
+
mimeType: "application/json",
|
|
66
|
+
},
|
|
67
|
+
accepts: [
|
|
68
|
+
{
|
|
69
|
+
scheme: "exact",
|
|
70
|
+
network: "eip155:84532", // Base Sepolia
|
|
71
|
+
asset: USDC_ADDRESS,
|
|
72
|
+
amount,
|
|
73
|
+
payTo: PAY_TO,
|
|
74
|
+
maxTimeoutSeconds: 86400,
|
|
75
|
+
extra: {
|
|
76
|
+
// EIP-712 domain params required by the x402 exact EVM scheme
|
|
77
|
+
name: USDC_NAME,
|
|
78
|
+
version: USDC_VERSION,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Decode a base64-encoded payment payload from the PAYMENT-SIGNATURE header.
|
|
87
|
+
*/
|
|
88
|
+
function decodePaymentHeader(headerValue: string): Record<string, unknown> | null {
|
|
89
|
+
try {
|
|
90
|
+
const json = atob(headerValue);
|
|
91
|
+
return JSON.parse(json);
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Verify the EIP-3009 TransferWithAuthorization signature in the payment payload.
|
|
99
|
+
*
|
|
100
|
+
* The x402 exact EVM scheme creates a payload like:
|
|
101
|
+
* { authorization: { from, to, value, validAfter, validBefore, nonce }, signature: "0x..." }
|
|
102
|
+
*/
|
|
103
|
+
async function verifyPayment(paymentPayload: Record<string, unknown>): Promise<{
|
|
104
|
+
valid: boolean;
|
|
105
|
+
payer?: string;
|
|
106
|
+
reason?: string;
|
|
107
|
+
}> {
|
|
108
|
+
try {
|
|
109
|
+
const payload = paymentPayload.payload as Record<string, unknown>;
|
|
110
|
+
if (!payload) {
|
|
111
|
+
return { valid: false, reason: "missing payload" };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const signature = payload.signature as `0x${string}`;
|
|
115
|
+
const authorization = payload.authorization as Record<string, unknown>;
|
|
116
|
+
|
|
117
|
+
if (!signature) {
|
|
118
|
+
return { valid: false, reason: "missing signature in payload" };
|
|
119
|
+
}
|
|
120
|
+
if (!authorization) {
|
|
121
|
+
// No authorization data — accept the payment header as-is (basic test mode)
|
|
122
|
+
return { valid: true, payer: "unknown (signature present, no authorization data)" };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Reconstruct the EIP-712 typed data and verify the signature
|
|
126
|
+
const domain = {
|
|
127
|
+
name: USDC_NAME,
|
|
128
|
+
version: USDC_VERSION,
|
|
129
|
+
chainId: BigInt(CHAIN_ID),
|
|
130
|
+
verifyingContract: getAddress(USDC_ADDRESS),
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const message = {
|
|
134
|
+
from: getAddress(authorization.from as string),
|
|
135
|
+
to: getAddress(authorization.to as string),
|
|
136
|
+
value: BigInt(authorization.value as string),
|
|
137
|
+
validAfter: BigInt(authorization.validAfter as string),
|
|
138
|
+
validBefore: BigInt(authorization.validBefore as string),
|
|
139
|
+
nonce: authorization.nonce as `0x${string}`,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const valid = await verifyTypedData({
|
|
143
|
+
address: message.from,
|
|
144
|
+
domain,
|
|
145
|
+
types: authorizationTypes,
|
|
146
|
+
primaryType: "TransferWithAuthorization",
|
|
147
|
+
message,
|
|
148
|
+
signature,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return { valid, payer: message.from };
|
|
152
|
+
} catch (error) {
|
|
153
|
+
return {
|
|
154
|
+
valid: false,
|
|
155
|
+
reason: `verification error: ${error instanceof Error ? error.message : String(error)}`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const server = Bun.serve({
|
|
161
|
+
port: PORT,
|
|
162
|
+
async fetch(req) {
|
|
163
|
+
const url = new URL(req.url);
|
|
164
|
+
|
|
165
|
+
// Free endpoint
|
|
166
|
+
if (url.pathname === "/" || url.pathname === "/health") {
|
|
167
|
+
return Response.json({ status: "ok", message: "x402 test server running" });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Paid endpoints
|
|
171
|
+
if (url.pathname.startsWith("/paid")) {
|
|
172
|
+
const isExpensive = url.pathname === "/paid/expensive";
|
|
173
|
+
const amount = isExpensive ? "5000000" : "10000"; // $5.00 or $0.01 USDC (6 decimals)
|
|
174
|
+
|
|
175
|
+
// Check for payment header
|
|
176
|
+
const paymentHeader =
|
|
177
|
+
req.headers.get("PAYMENT-SIGNATURE") || req.headers.get("X-PAYMENT");
|
|
178
|
+
|
|
179
|
+
if (!paymentHeader) {
|
|
180
|
+
// No payment — return 402 with payment requirements
|
|
181
|
+
const paymentRequired = buildPaymentRequired(
|
|
182
|
+
`${url.origin}${url.pathname}`,
|
|
183
|
+
amount,
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
// x402 v2 requires the PAYMENT-REQUIRED header (base64-encoded PaymentRequired)
|
|
187
|
+
const encoded = encodePaymentRequiredHeader(
|
|
188
|
+
paymentRequired as Parameters<typeof encodePaymentRequiredHeader>[0],
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
return new Response(JSON.stringify(paymentRequired), {
|
|
192
|
+
status: 402,
|
|
193
|
+
headers: {
|
|
194
|
+
"Content-Type": "application/json",
|
|
195
|
+
"PAYMENT-REQUIRED": encoded,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Has payment header — decode and verify
|
|
201
|
+
const paymentPayload = decodePaymentHeader(paymentHeader);
|
|
202
|
+
if (!paymentPayload) {
|
|
203
|
+
return Response.json(
|
|
204
|
+
{ error: "Invalid payment header (could not decode base64/JSON)" },
|
|
205
|
+
{ status: 400 },
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const verification = await verifyPayment(paymentPayload);
|
|
210
|
+
|
|
211
|
+
if (!verification.valid) {
|
|
212
|
+
return Response.json(
|
|
213
|
+
{ error: `Payment verification failed: ${verification.reason}` },
|
|
214
|
+
{ status: 402 },
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Payment accepted — return the premium content
|
|
219
|
+
return Response.json({
|
|
220
|
+
content: isExpensive ? "This is expensive premium content!" : "This is paid content!",
|
|
221
|
+
paymentAccepted: true,
|
|
222
|
+
payer: verification.payer,
|
|
223
|
+
amount: isExpensive ? "$5.00" : "$0.01",
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return Response.json({ error: "Not found" }, { status: 404 });
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
console.log(`x402 test server running on http://localhost:${server.port}`);
|
|
232
|
+
console.log("Endpoints:");
|
|
233
|
+
console.log(" GET / Free endpoint");
|
|
234
|
+
console.log(" GET /paid x402-protected ($0.01 USDC)");
|
|
235
|
+
console.log(" GET /paid/expensive x402-protected ($5.00 USDC)");
|
|
236
|
+
console.log("\nPress Ctrl+C to stop.");
|