agent-relay 1.1.0 → 1.2.3
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/.gitattributes +3 -0
- package/.nvmrc +1 -0
- package/.trajectories/completed/2026-01/traj_1dviorhnkcb5.json +65 -0
- package/.trajectories/completed/2026-01/traj_1dviorhnkcb5.md +37 -0
- package/.trajectories/completed/2026-01/traj_1k5if5snst2e.json +65 -0
- package/.trajectories/completed/2026-01/traj_1k5if5snst2e.md +37 -0
- package/.trajectories/completed/2026-01/traj_1rp3rges5811.json +49 -0
- package/.trajectories/completed/2026-01/traj_1rp3rges5811.md +31 -0
- package/.trajectories/completed/2026-01/traj_22bhyulruouw.json +113 -0
- package/.trajectories/completed/2026-01/traj_22bhyulruouw.md +57 -0
- package/.trajectories/completed/2026-01/traj_2dao7ddgnta0.json +53 -0
- package/.trajectories/completed/2026-01/traj_2dao7ddgnta0.md +32 -0
- package/.trajectories/completed/2026-01/traj_3t0440mjeunc.json +26 -0
- package/.trajectories/completed/2026-01/traj_3t0440mjeunc.md +6 -0
- package/.trajectories/completed/2026-01/traj_45x9494d9xnr.json +47 -0
- package/.trajectories/completed/2026-01/traj_45x9494d9xnr.md +32 -0
- package/.trajectories/completed/2026-01/traj_4aa0bb77s4nh.json +53 -0
- package/.trajectories/completed/2026-01/traj_4aa0bb77s4nh.md +32 -0
- package/.trajectories/completed/2026-01/traj_5lhmzq8rxpqv.json +59 -0
- package/.trajectories/completed/2026-01/traj_5lhmzq8rxpqv.md +33 -0
- package/.trajectories/completed/2026-01/traj_5vr4e9erb1fs.json +53 -0
- package/.trajectories/completed/2026-01/traj_5vr4e9erb1fs.md +32 -0
- package/.trajectories/completed/2026-01/traj_6fgiwdoklvym.json +48 -0
- package/.trajectories/completed/2026-01/traj_6fgiwdoklvym.md +24 -0
- package/.trajectories/completed/2026-01/traj_7ludwvz45veh.json +209 -0
- package/.trajectories/completed/2026-01/traj_7ludwvz45veh.md +97 -0
- package/.trajectories/completed/2026-01/traj_9921cuhel0pj.json +48 -0
- package/.trajectories/completed/2026-01/traj_9921cuhel0pj.md +24 -0
- package/.trajectories/completed/2026-01/traj_ajs7zqfux4wc.json +49 -0
- package/.trajectories/completed/2026-01/traj_ajs7zqfux4wc.md +23 -0
- package/.trajectories/completed/2026-01/traj_cvtqhlwcq9s0.json +53 -0
- package/.trajectories/completed/2026-01/traj_cvtqhlwcq9s0.md +32 -0
- package/.trajectories/completed/2026-01/traj_cxofprm2m2en.json +49 -0
- package/.trajectories/completed/2026-01/traj_cxofprm2m2en.md +31 -0
- package/.trajectories/completed/2026-01/traj_d2hhz3k0vrhn.json +26 -0
- package/.trajectories/completed/2026-01/traj_d2hhz3k0vrhn.md +6 -0
- package/.trajectories/completed/2026-01/traj_dfuvww9pege5.json +59 -0
- package/.trajectories/completed/2026-01/traj_dfuvww9pege5.md +37 -0
- package/.trajectories/completed/2026-01/traj_g0fisy9h51mf.json +77 -0
- package/.trajectories/completed/2026-01/traj_g0fisy9h51mf.md +42 -0
- package/.trajectories/completed/2026-01/traj_gjdre5voouod.json +53 -0
- package/.trajectories/completed/2026-01/traj_gjdre5voouod.md +32 -0
- package/.trajectories/completed/2026-01/traj_gtlyqtta3x8l.json +25 -0
- package/.trajectories/completed/2026-01/traj_gtlyqtta3x8l.md +15 -0
- package/.trajectories/completed/2026-01/traj_h4xijiuip3w4.json +101 -0
- package/.trajectories/completed/2026-01/traj_h4xijiuip3w4.md +44 -0
- package/.trajectories/completed/2026-01/traj_hhxte7w4gjjx.json +22 -0
- package/.trajectories/completed/2026-01/traj_hhxte7w4gjjx.md +5 -0
- package/.trajectories/completed/2026-01/traj_hpungyhoj6v5.json +53 -0
- package/.trajectories/completed/2026-01/traj_hpungyhoj6v5.md +32 -0
- package/.trajectories/completed/2026-01/traj_m2xkjv0w2sq7.json +25 -0
- package/.trajectories/completed/2026-01/traj_m2xkjv0w2sq7.md +15 -0
- package/.trajectories/completed/2026-01/traj_noq5zbvnrdvz.json +53 -0
- package/.trajectories/completed/2026-01/traj_noq5zbvnrdvz.md +32 -0
- package/.trajectories/completed/2026-01/traj_ntbs6ppopf46.json +53 -0
- package/.trajectories/completed/2026-01/traj_ntbs6ppopf46.md +32 -0
- package/.trajectories/completed/2026-01/traj_ozd98si6a7ns.json +48 -0
- package/.trajectories/completed/2026-01/traj_ozd98si6a7ns.md +24 -0
- package/.trajectories/completed/2026-01/traj_prdza7a5cxp5.json +53 -0
- package/.trajectories/completed/2026-01/traj_prdza7a5cxp5.md +32 -0
- package/.trajectories/completed/2026-01/traj_qb3twvvywfwi.json +77 -0
- package/.trajectories/completed/2026-01/traj_qb3twvvywfwi.md +42 -0
- package/.trajectories/completed/2026-01/traj_qft54mi7nfor.json +53 -0
- package/.trajectories/completed/2026-01/traj_qft54mi7nfor.md +32 -0
- package/.trajectories/completed/2026-01/traj_qx9uhf8whhxo.json +83 -0
- package/.trajectories/completed/2026-01/traj_qx9uhf8whhxo.md +47 -0
- package/.trajectories/completed/2026-01/traj_rd9toccj18a0.json +59 -0
- package/.trajectories/completed/2026-01/traj_rd9toccj18a0.md +37 -0
- package/.trajectories/completed/2026-01/traj_rt4fiw3ecp50.json +48 -0
- package/.trajectories/completed/2026-01/traj_rt4fiw3ecp50.md +16 -0
- package/.trajectories/completed/2026-01/traj_st8j35b0hrlc.json +59 -0
- package/.trajectories/completed/2026-01/traj_st8j35b0hrlc.md +37 -0
- package/.trajectories/completed/2026-01/traj_t1yy8m7hbuxp.json +53 -0
- package/.trajectories/completed/2026-01/traj_t1yy8m7hbuxp.md +32 -0
- package/.trajectories/completed/2026-01/traj_tmux_orchestrator_analysis.json +84 -0
- package/.trajectories/completed/2026-01/traj_tmux_orchestrator_analysis.md +109 -0
- package/.trajectories/completed/2026-01/traj_u9n9eqasw16k.json +53 -0
- package/.trajectories/completed/2026-01/traj_u9n9eqasw16k.md +32 -0
- package/.trajectories/completed/2026-01/traj_v87hypnongqx.json +71 -0
- package/.trajectories/completed/2026-01/traj_v87hypnongqx.md +42 -0
- package/.trajectories/completed/2026-01/traj_wkp2fgzdyinb.json +53 -0
- package/.trajectories/completed/2026-01/traj_wkp2fgzdyinb.md +32 -0
- package/.trajectories/completed/2026-01/traj_x14t8w8rn7xg.json +20 -0
- package/.trajectories/completed/2026-01/traj_x14t8w8rn7xg.md +6 -0
- package/.trajectories/completed/2026-01/traj_xnwbznkvv8ua.json +175 -0
- package/.trajectories/completed/2026-01/traj_xnwbznkvv8ua.md +82 -0
- package/.trajectories/completed/2026-01/traj_ysjc8zaeqtd3.json +47 -0
- package/.trajectories/completed/2026-01/traj_ysjc8zaeqtd3.md +32 -0
- package/.trajectories/completed/2026-01/traj_yvdadtvdgnz3.json +59 -0
- package/.trajectories/completed/2026-01/traj_yvdadtvdgnz3.md +37 -0
- package/.trajectories/completed/2026-01/traj_z0vcw1wrzide.json +53 -0
- package/.trajectories/completed/2026-01/traj_z0vcw1wrzide.md +32 -0
- package/.trajectories/index.json +314 -0
- package/ARCHITECTURE.md +1245 -0
- package/README.md +1 -1
- package/TESTING.md +278 -0
- package/deploy/init-db.sql +5 -0
- package/deploy/scripts/setup-fly-workspaces.sh +69 -0
- package/deploy/scripts/setup-railway.sh +75 -0
- package/deploy/workspace/entrypoint-browser.sh +118 -0
- package/deploy/workspace/entrypoint.sh +348 -0
- package/deploy/workspace/git-credential-relay +111 -0
- package/dist/bridge/spawner.d.ts +53 -0
- package/dist/bridge/spawner.js +203 -19
- package/dist/bridge/types.d.ts +12 -0
- package/dist/cli/index.js +618 -5
- package/dist/cloud/api/auth.d.ts +3 -2
- package/dist/cloud/api/auth.js +10 -98
- package/dist/cloud/api/billing.js +30 -9
- package/dist/cloud/api/cli-pty-runner.d.ts +54 -0
- package/dist/cloud/api/cli-pty-runner.js +119 -0
- package/dist/cloud/api/codex-auth-helper.d.ts +15 -0
- package/dist/cloud/api/codex-auth-helper.js +100 -0
- package/dist/cloud/api/generic-webhooks.d.ts +8 -0
- package/dist/cloud/api/generic-webhooks.js +129 -0
- package/dist/cloud/api/git.d.ts +8 -0
- package/dist/cloud/api/git.js +152 -0
- package/dist/cloud/api/github-app.d.ts +11 -0
- package/dist/cloud/api/github-app.js +189 -0
- package/dist/cloud/api/middleware/planLimits.d.ts +7 -0
- package/dist/cloud/api/middleware/planLimits.js +39 -1
- package/dist/cloud/api/monitoring.d.ts +11 -0
- package/dist/cloud/api/monitoring.js +578 -0
- package/dist/cloud/api/nango-auth.d.ts +9 -0
- package/dist/cloud/api/nango-auth.js +377 -0
- package/dist/cloud/api/onboarding.d.ts +8 -1
- package/dist/cloud/api/onboarding.js +313 -119
- package/dist/cloud/api/policy.d.ts +8 -0
- package/dist/cloud/api/policy.js +229 -0
- package/dist/cloud/api/providers.js +114 -42
- package/dist/cloud/api/repos.d.ts +1 -0
- package/dist/cloud/api/repos.js +186 -0
- package/dist/cloud/api/test-helpers.d.ts +10 -0
- package/dist/cloud/api/test-helpers.js +575 -0
- package/dist/cloud/api/webhooks.d.ts +8 -0
- package/dist/cloud/api/webhooks.js +645 -0
- package/dist/cloud/api/workspaces.js +320 -12
- package/dist/cloud/billing/plans.js +32 -19
- package/dist/cloud/billing/types.d.ts +9 -3
- package/dist/cloud/config.d.ts +9 -2
- package/dist/cloud/config.js +13 -4
- package/dist/cloud/db/drizzle.d.ts +84 -1
- package/dist/cloud/db/drizzle.js +470 -0
- package/dist/cloud/db/index.d.ts +9 -4
- package/dist/cloud/db/index.js +11 -3
- package/dist/cloud/db/schema.d.ts +3283 -556
- package/dist/cloud/db/schema.js +314 -1
- package/dist/cloud/index.d.ts +1 -0
- package/dist/cloud/index.js +2 -0
- package/dist/cloud/provisioner/index.d.ts +56 -0
- package/dist/cloud/provisioner/index.js +676 -34
- package/dist/cloud/server.d.ts +1 -0
- package/dist/cloud/server.js +362 -13
- package/dist/cloud/services/auto-scaler.d.ts +152 -0
- package/dist/cloud/services/auto-scaler.js +439 -0
- package/dist/cloud/services/capacity-manager.d.ts +148 -0
- package/dist/cloud/services/capacity-manager.js +449 -0
- package/dist/cloud/services/ci-agent-spawner.d.ts +49 -0
- package/dist/cloud/services/ci-agent-spawner.js +373 -0
- package/dist/cloud/services/index.d.ts +12 -0
- package/dist/cloud/services/index.js +15 -0
- package/dist/cloud/services/mention-handler.d.ts +65 -0
- package/dist/cloud/services/mention-handler.js +405 -0
- package/dist/cloud/services/nango.d.ts +186 -0
- package/dist/cloud/services/nango.js +344 -0
- package/dist/cloud/services/persistence.d.ts +131 -0
- package/dist/cloud/services/persistence.js +200 -0
- package/dist/cloud/services/planLimits.d.ts +37 -0
- package/dist/cloud/services/planLimits.js +86 -5
- package/dist/cloud/services/scaling-orchestrator.d.ts +159 -0
- package/dist/cloud/services/scaling-orchestrator.js +502 -0
- package/dist/cloud/services/scaling-policy.d.ts +121 -0
- package/dist/cloud/services/scaling-policy.js +415 -0
- package/dist/cloud/vault/index.js +1 -1
- package/dist/cloud/webhooks/index.d.ts +24 -0
- package/dist/cloud/webhooks/index.js +29 -0
- package/dist/cloud/webhooks/parsers/github.d.ts +8 -0
- package/dist/cloud/webhooks/parsers/github.js +234 -0
- package/dist/cloud/webhooks/parsers/index.d.ts +23 -0
- package/dist/cloud/webhooks/parsers/index.js +30 -0
- package/dist/cloud/webhooks/parsers/linear.d.ts +9 -0
- package/dist/cloud/webhooks/parsers/linear.js +258 -0
- package/dist/cloud/webhooks/parsers/slack.d.ts +9 -0
- package/dist/cloud/webhooks/parsers/slack.js +214 -0
- package/dist/cloud/webhooks/responders/github.d.ts +8 -0
- package/dist/cloud/webhooks/responders/github.js +73 -0
- package/dist/cloud/webhooks/responders/index.d.ts +23 -0
- package/dist/cloud/webhooks/responders/index.js +30 -0
- package/dist/cloud/webhooks/responders/linear.d.ts +9 -0
- package/dist/cloud/webhooks/responders/linear.js +149 -0
- package/dist/cloud/webhooks/responders/slack.d.ts +20 -0
- package/dist/cloud/webhooks/responders/slack.js +178 -0
- package/dist/cloud/webhooks/router.d.ts +25 -0
- package/dist/cloud/webhooks/router.js +504 -0
- package/dist/cloud/webhooks/rules-engine.d.ts +24 -0
- package/dist/cloud/webhooks/rules-engine.js +287 -0
- package/dist/cloud/webhooks/types.d.ts +186 -0
- package/dist/cloud/webhooks/types.js +8 -0
- package/dist/continuity/formatter.d.ts +51 -0
- package/dist/continuity/formatter.js +313 -0
- package/dist/continuity/handoff-store.d.ts +67 -0
- package/dist/continuity/handoff-store.js +472 -0
- package/dist/continuity/index.d.ts +45 -0
- package/dist/continuity/index.js +48 -0
- package/dist/continuity/ledger-store.d.ts +110 -0
- package/dist/continuity/ledger-store.js +500 -0
- package/dist/continuity/manager.d.ts +178 -0
- package/dist/continuity/manager.js +562 -0
- package/dist/continuity/parser.d.ts +76 -0
- package/dist/continuity/parser.js +579 -0
- package/dist/continuity/types.d.ts +180 -0
- package/dist/continuity/types.js +9 -0
- package/dist/daemon/agent-manager.d.ts +27 -0
- package/dist/daemon/agent-manager.js +107 -6
- package/dist/daemon/agent-registry.d.ts +32 -0
- package/dist/daemon/agent-registry.js +42 -2
- package/dist/daemon/api.d.ts +12 -0
- package/dist/daemon/api.js +131 -2
- package/dist/daemon/cli-auth.d.ts +67 -0
- package/dist/daemon/cli-auth.js +537 -0
- package/dist/daemon/cloud-sync.js +9 -7
- package/dist/daemon/orchestrator.js +30 -0
- package/dist/daemon/router.d.ts +5 -0
- package/dist/daemon/router.js +78 -26
- package/dist/daemon/server.d.ts +5 -0
- package/dist/daemon/server.js +9 -1
- package/dist/daemon/services/browser-testing.d.ts +88 -0
- package/dist/daemon/services/browser-testing.js +244 -0
- package/dist/daemon/services/container-spawner.d.ts +135 -0
- package/dist/daemon/services/container-spawner.js +313 -0
- package/dist/daemon/types.d.ts +5 -1
- package/dist/dashboard/out/404.html +1 -1
- package/dist/dashboard/out/_next/static/chunks/116-2502180def231162.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/282-980c2eb8fff20123.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/699-3b1cd6618a45d259.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/724-2dae7627550ab88f.js +9 -0
- package/dist/dashboard/out/_next/static/chunks/766-1f2dd8cb7f766b0b.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/app/onboarding/page-3fdfa60e53f2810d.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/app/page-e6381e5a6e1fbcfd.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-3538dfe0ffe984b8.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/history/{page-b6edd4dde8d08194.js → page-abb9ab2d329f56e9.js} +1 -1
- package/dist/dashboard/out/_next/static/chunks/app/layout-c0d118c0f92d969c.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/login/page-c22d080201cbd9fb.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/metrics/page-67a3e98d9a43a6ed.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/page-77e9c65420a06cfb.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/pricing/page-b08ed1c34d14434a.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/providers/page-e88bc117ef7671c3.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/signup/page-68d34f50baa8ab6b.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/e868780c-48e5f147c90a3a41.js +18 -0
- package/dist/dashboard/out/_next/static/chunks/{main-app-5d692157a8eb1fd9.js → main-app-6e8e8d3ef4e0192a.js} +1 -1
- package/dist/dashboard/out/_next/static/chunks/{main-c2f423b9c9f4591b.js → main-ed4e1fb6f29c34cf.js} +1 -1
- package/dist/dashboard/out/_next/static/chunks/webpack-1cdd8ed57114d5e1.js +1 -0
- package/dist/dashboard/out/_next/static/css/29852f26181969a0.css +1 -0
- package/dist/dashboard/out/_next/static/css/7c3ae9e8617d42a5.css +1 -0
- package/dist/dashboard/out/app/onboarding.html +1 -0
- package/dist/dashboard/out/app/onboarding.txt +7 -0
- package/dist/dashboard/out/app.html +1 -14
- package/dist/dashboard/out/app.txt +2 -2
- package/dist/dashboard/out/connect-repos.html +1 -0
- package/dist/dashboard/out/connect-repos.txt +7 -0
- package/dist/dashboard/out/history.html +1 -1
- package/dist/dashboard/out/history.txt +2 -2
- package/dist/dashboard/out/index.html +1 -1
- package/dist/dashboard/out/index.txt +2 -2
- package/dist/dashboard/out/login.html +6 -0
- package/dist/dashboard/out/login.txt +7 -0
- package/dist/dashboard/out/metrics.html +1 -1
- package/dist/dashboard/out/metrics.txt +2 -2
- package/dist/dashboard/out/pricing.html +3 -3
- package/dist/dashboard/out/pricing.txt +2 -2
- package/dist/dashboard/out/providers.html +1 -0
- package/dist/dashboard/out/providers.txt +7 -0
- package/dist/dashboard/out/signup.html +6 -0
- package/dist/dashboard/out/signup.txt +7 -0
- package/dist/dashboard-server/server.js +1308 -8
- package/dist/hooks/emitter.d.ts +40 -0
- package/dist/hooks/emitter.js +63 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/registry.d.ts +173 -0
- package/dist/hooks/registry.js +476 -0
- package/dist/hooks/trajectory-hooks.d.ts +52 -0
- package/dist/hooks/trajectory-hooks.js +183 -0
- package/dist/hooks/types.d.ts +141 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/memory/adapters/index.d.ts +8 -0
- package/dist/memory/adapters/index.js +8 -0
- package/dist/memory/adapters/inmemory.d.ts +59 -0
- package/dist/memory/adapters/inmemory.js +195 -0
- package/dist/memory/adapters/supermemory.d.ts +71 -0
- package/dist/memory/adapters/supermemory.js +338 -0
- package/dist/memory/factory.d.ts +48 -0
- package/dist/memory/factory.js +143 -0
- package/dist/memory/index.d.ts +32 -0
- package/dist/memory/index.js +32 -0
- package/dist/memory/memory-hooks.d.ts +60 -0
- package/dist/memory/memory-hooks.js +313 -0
- package/dist/memory/service.d.ts +49 -0
- package/dist/memory/service.js +146 -0
- package/dist/memory/types.d.ts +195 -0
- package/dist/memory/types.js +8 -0
- package/dist/policy/agent-policy.d.ts +225 -0
- package/dist/policy/agent-policy.js +665 -0
- package/dist/policy/cloud-policy-fetcher.d.ts +12 -0
- package/dist/policy/cloud-policy-fetcher.js +64 -0
- package/dist/resiliency/crash-insights.d.ts +156 -0
- package/dist/resiliency/crash-insights.js +492 -0
- package/dist/resiliency/gossip-health.d.ts +137 -0
- package/dist/resiliency/gossip-health.js +241 -0
- package/dist/resiliency/index.d.ts +5 -0
- package/dist/resiliency/index.js +5 -0
- package/dist/resiliency/leader-watchdog.d.ts +109 -0
- package/dist/resiliency/leader-watchdog.js +189 -0
- package/dist/resiliency/memory-monitor.d.ts +172 -0
- package/dist/resiliency/memory-monitor.js +593 -0
- package/dist/resiliency/stateless-lead.d.ts +149 -0
- package/dist/resiliency/stateless-lead.js +308 -0
- package/dist/resiliency/supervisor.d.ts +38 -0
- package/dist/resiliency/supervisor.js +122 -0
- package/dist/shared/cli-auth-config.d.ts +91 -0
- package/dist/shared/cli-auth-config.js +264 -0
- package/dist/storage/adapter.d.ts +1 -1
- package/dist/trajectory/config.d.ts +84 -0
- package/dist/trajectory/config.js +163 -0
- package/dist/trajectory/index.d.ts +8 -0
- package/dist/trajectory/index.js +8 -0
- package/dist/trajectory/integration.d.ts +292 -0
- package/dist/trajectory/integration.js +834 -0
- package/dist/utils/logger.js +1 -1
- package/dist/utils/project-namespace.d.ts +24 -0
- package/dist/utils/project-namespace.js +84 -0
- package/dist/wrapper/parser.d.ts +10 -0
- package/dist/wrapper/parser.js +100 -33
- package/dist/wrapper/pty-wrapper.d.ts +197 -16
- package/dist/wrapper/pty-wrapper.js +943 -106
- package/dist/wrapper/shared.d.ts +165 -0
- package/dist/wrapper/shared.js +270 -0
- package/dist/wrapper/tmux-wrapper.d.ts +73 -11
- package/dist/wrapper/tmux-wrapper.js +541 -120
- package/package.json +16 -16
- package/scripts/postinstall.js +60 -0
- package/test-push.txt +1 -0
- package/bin/tmux +0 -0
- package/dist/bridge/config.d.ts.map +0 -1
- package/dist/bridge/config.js.map +0 -1
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/index.js.map +0 -1
- package/dist/bridge/multi-project-client.d.ts.map +0 -1
- package/dist/bridge/multi-project-client.js.map +0 -1
- package/dist/bridge/shadow-cli.d.ts.map +0 -1
- package/dist/bridge/shadow-cli.js.map +0 -1
- package/dist/bridge/shadow-config.d.ts.map +0 -1
- package/dist/bridge/shadow-config.js.map +0 -1
- package/dist/bridge/spawner.d.ts.map +0 -1
- package/dist/bridge/spawner.js.map +0 -1
- package/dist/bridge/teams-config.d.ts.map +0 -1
- package/dist/bridge/teams-config.js.map +0 -1
- package/dist/bridge/types.d.ts.map +0 -1
- package/dist/bridge/types.js.map +0 -1
- package/dist/bridge/utils.d.ts.map +0 -1
- package/dist/bridge/utils.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/cloud/api/auth.d.ts.map +0 -1
- package/dist/cloud/api/auth.js.map +0 -1
- package/dist/cloud/api/billing.d.ts.map +0 -1
- package/dist/cloud/api/billing.js.map +0 -1
- package/dist/cloud/api/coordinators.d.ts.map +0 -1
- package/dist/cloud/api/coordinators.js.map +0 -1
- package/dist/cloud/api/daemons.d.ts.map +0 -1
- package/dist/cloud/api/daemons.js.map +0 -1
- package/dist/cloud/api/middleware/planLimits.d.ts.map +0 -1
- package/dist/cloud/api/middleware/planLimits.js.map +0 -1
- package/dist/cloud/api/onboarding.d.ts.map +0 -1
- package/dist/cloud/api/onboarding.js.map +0 -1
- package/dist/cloud/api/providers.d.ts.map +0 -1
- package/dist/cloud/api/providers.js.map +0 -1
- package/dist/cloud/api/repos.d.ts.map +0 -1
- package/dist/cloud/api/repos.js.map +0 -1
- package/dist/cloud/api/teams.d.ts.map +0 -1
- package/dist/cloud/api/teams.js.map +0 -1
- package/dist/cloud/api/usage.d.ts.map +0 -1
- package/dist/cloud/api/usage.js.map +0 -1
- package/dist/cloud/api/workspaces.d.ts.map +0 -1
- package/dist/cloud/api/workspaces.js.map +0 -1
- package/dist/cloud/billing/index.d.ts.map +0 -1
- package/dist/cloud/billing/index.js.map +0 -1
- package/dist/cloud/billing/plans.d.ts.map +0 -1
- package/dist/cloud/billing/plans.js.map +0 -1
- package/dist/cloud/billing/service.d.ts.map +0 -1
- package/dist/cloud/billing/service.js.map +0 -1
- package/dist/cloud/billing/types.d.ts.map +0 -1
- package/dist/cloud/billing/types.js.map +0 -1
- package/dist/cloud/config.d.ts.map +0 -1
- package/dist/cloud/config.js.map +0 -1
- package/dist/cloud/db/drizzle.d.ts.map +0 -1
- package/dist/cloud/db/drizzle.js.map +0 -1
- package/dist/cloud/db/index.d.ts.map +0 -1
- package/dist/cloud/db/index.js.map +0 -1
- package/dist/cloud/db/schema.d.ts.map +0 -1
- package/dist/cloud/db/schema.js.map +0 -1
- package/dist/cloud/index.d.ts.map +0 -1
- package/dist/cloud/index.js.map +0 -1
- package/dist/cloud/provisioner/index.d.ts.map +0 -1
- package/dist/cloud/provisioner/index.js.map +0 -1
- package/dist/cloud/server.d.ts.map +0 -1
- package/dist/cloud/server.js.map +0 -1
- package/dist/cloud/services/coordinator.d.ts.map +0 -1
- package/dist/cloud/services/coordinator.js.map +0 -1
- package/dist/cloud/services/planLimits.d.ts.map +0 -1
- package/dist/cloud/services/planLimits.js.map +0 -1
- package/dist/cloud/vault/index.d.ts.map +0 -1
- package/dist/cloud/vault/index.js.map +0 -1
- package/dist/daemon/agent-manager.d.ts.map +0 -1
- package/dist/daemon/agent-manager.js.map +0 -1
- package/dist/daemon/agent-registry.d.ts.map +0 -1
- package/dist/daemon/agent-registry.js.map +0 -1
- package/dist/daemon/api.d.ts.map +0 -1
- package/dist/daemon/api.js.map +0 -1
- package/dist/daemon/auth.d.ts.map +0 -1
- package/dist/daemon/auth.js.map +0 -1
- package/dist/daemon/cloud-sync.d.ts.map +0 -1
- package/dist/daemon/cloud-sync.js.map +0 -1
- package/dist/daemon/connection.d.ts.map +0 -1
- package/dist/daemon/connection.js.map +0 -1
- package/dist/daemon/index.d.ts.map +0 -1
- package/dist/daemon/index.js.map +0 -1
- package/dist/daemon/orchestrator.d.ts.map +0 -1
- package/dist/daemon/orchestrator.js.map +0 -1
- package/dist/daemon/registry.d.ts.map +0 -1
- package/dist/daemon/registry.js.map +0 -1
- package/dist/daemon/router.d.ts.map +0 -1
- package/dist/daemon/router.js.map +0 -1
- package/dist/daemon/server.d.ts.map +0 -1
- package/dist/daemon/server.js.map +0 -1
- package/dist/daemon/types.d.ts.map +0 -1
- package/dist/daemon/types.js.map +0 -1
- package/dist/daemon/workspace-manager.d.ts.map +0 -1
- package/dist/daemon/workspace-manager.js.map +0 -1
- package/dist/dashboard/out/_next/static/chunks/693-7b3301d8f6bc5014.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/713-f78477eb185f1f4d.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/766-e53e1cfe39b0b5b5.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/900-037c64bfd797fb2a.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/app/page-e3d9e1f4466b9bae.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/layout-2433bb48965f4333.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/metrics/page-e68825a81db67ba1.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/page-cc108bf68c8a657f.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/pricing/page-d80e03a5297f95b6.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/webpack-a5acc2831d094776.js +0 -1
- package/dist/dashboard/out/_next/static/css/79b80143647a07d7.css +0 -1
- package/dist/dashboard/out/_next/static/css/8cf277370ad48cfe.css +0 -1
- package/dist/dashboard-server/metrics.d.ts.map +0 -1
- package/dist/dashboard-server/metrics.js.map +0 -1
- package/dist/dashboard-server/needs-attention.d.ts.map +0 -1
- package/dist/dashboard-server/needs-attention.js.map +0 -1
- package/dist/dashboard-server/server.d.ts.map +0 -1
- package/dist/dashboard-server/server.js.map +0 -1
- package/dist/dashboard-server/start.d.ts.map +0 -1
- package/dist/dashboard-server/start.js.map +0 -1
- package/dist/hooks/inbox-check/hook.d.ts.map +0 -1
- package/dist/hooks/inbox-check/hook.js.map +0 -1
- package/dist/hooks/inbox-check/index.d.ts.map +0 -1
- package/dist/hooks/inbox-check/index.js.map +0 -1
- package/dist/hooks/inbox-check/types.d.ts.map +0 -1
- package/dist/hooks/inbox-check/types.js.map +0 -1
- package/dist/hooks/inbox-check/utils.d.ts.map +0 -1
- package/dist/hooks/inbox-check/utils.js.map +0 -1
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/types.d.ts.map +0 -1
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/protocol/framing.d.ts.map +0 -1
- package/dist/protocol/framing.js.map +0 -1
- package/dist/protocol/index.d.ts.map +0 -1
- package/dist/protocol/index.js.map +0 -1
- package/dist/protocol/types.d.ts.map +0 -1
- package/dist/protocol/types.js.map +0 -1
- package/dist/resiliency/context-persistence.d.ts.map +0 -1
- package/dist/resiliency/context-persistence.js.map +0 -1
- package/dist/resiliency/health-monitor.d.ts.map +0 -1
- package/dist/resiliency/health-monitor.js.map +0 -1
- package/dist/resiliency/index.d.ts.map +0 -1
- package/dist/resiliency/index.js.map +0 -1
- package/dist/resiliency/logger.d.ts.map +0 -1
- package/dist/resiliency/logger.js.map +0 -1
- package/dist/resiliency/metrics.d.ts.map +0 -1
- package/dist/resiliency/metrics.js.map +0 -1
- package/dist/resiliency/provider-context.d.ts.map +0 -1
- package/dist/resiliency/provider-context.js.map +0 -1
- package/dist/resiliency/supervisor.d.ts.map +0 -1
- package/dist/resiliency/supervisor.js.map +0 -1
- package/dist/state/agent-state.d.ts.map +0 -1
- package/dist/state/agent-state.js.map +0 -1
- package/dist/storage/adapter.d.ts.map +0 -1
- package/dist/storage/adapter.js.map +0 -1
- package/dist/storage/sqlite-adapter.d.ts.map +0 -1
- package/dist/storage/sqlite-adapter.js.map +0 -1
- package/dist/utils/agent-config.d.ts.map +0 -1
- package/dist/utils/agent-config.js.map +0 -1
- package/dist/utils/command-resolver.d.ts.map +0 -1
- package/dist/utils/command-resolver.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/name-generator.d.ts.map +0 -1
- package/dist/utils/name-generator.js.map +0 -1
- package/dist/utils/project-namespace.d.ts.map +0 -1
- package/dist/utils/project-namespace.js.map +0 -1
- package/dist/utils/tmux-resolver.d.ts.map +0 -1
- package/dist/utils/tmux-resolver.js.map +0 -1
- package/dist/utils/update-checker.d.ts.map +0 -1
- package/dist/utils/update-checker.js.map +0 -1
- package/dist/wrapper/client.d.ts.map +0 -1
- package/dist/wrapper/client.js.map +0 -1
- package/dist/wrapper/inbox.d.ts.map +0 -1
- package/dist/wrapper/inbox.js.map +0 -1
- package/dist/wrapper/index.d.ts.map +0 -1
- package/dist/wrapper/index.js.map +0 -1
- package/dist/wrapper/parser.d.ts.map +0 -1
- package/dist/wrapper/parser.js.map +0 -1
- package/dist/wrapper/pty-wrapper.d.ts.map +0 -1
- package/dist/wrapper/pty-wrapper.js.map +0 -1
- package/dist/wrapper/tmux-wrapper.d.ts.map +0 -1
- package/dist/wrapper/tmux-wrapper.js.map +0 -1
- package/docs/AGENTS.md +0 -513
- package/docs/ARCHITECTURE_DECISIONS.md +0 -175
- package/docs/CHANGELOG.md +0 -11
- package/docs/CLI-SIMPLIFICATION-COMPLETE.md +0 -48
- package/docs/CLOUD-ARCHITECTURE.md +0 -652
- package/docs/CLOUD-ONBOARDING-DESIGN.md +0 -1983
- package/docs/COMPETITIVE_ANALYSIS.md +0 -897
- package/docs/CONTRIBUTING.md +0 -151
- package/docs/DESIGN_BRIDGE_STAFFING.md +0 -878
- package/docs/DESIGN_V2.md +0 -1079
- package/docs/INTEGRATION-GUIDE.md +0 -926
- package/docs/MONETIZATION.md +0 -1679
- package/docs/PROPOSAL-trajectories.md +0 -1582
- package/docs/PROTOCOL.md +0 -325
- package/docs/SCALING_ANALYSIS.md +0 -280
- package/docs/TESTING_PRESENCE_FEATURES.md +0 -327
- package/docs/TMUX_IMPLEMENTATION_NOTES.md +0 -364
- package/docs/TMUX_IMPROVEMENTS.md +0 -968
- package/docs/agent-relay-snippet.md +0 -168
- package/docs/competitive-analysis-mcp-agent-mail.md +0 -389
- package/docs/dashboard-v2-plan.md +0 -179
- package/docs/guides/CLOUD.md +0 -236
- package/docs/guides/LOCAL.md +0 -535
- package/docs/guides/SELF-HOSTED.md +0 -494
- package/docs/proposals/shadow-as-subagent.md +0 -765
- package/docs/proposals/slack-bot-integration.md +0 -1457
- package/docs/removable-code-analysis.md +0 -24
- package/scripts/dev/PUBLIC_RELEASE_PLAN.md +0 -88
- package/scripts/dev/dev-team-setup.sh +0 -431
- package/scripts/e2e-test.sh +0 -119
- package/scripts/games/game-protocol.md +0 -79
- package/scripts/games/hearts-setup.sh +0 -264
- package/scripts/tictactoe-setup.sh +0 -181
- /package/dist/dashboard/out/_next/static/chunks/{117-b2cd8d6485aacf2b.js → 117-f7b8ab0809342e77.js} +0 -0
- /package/dist/dashboard/out/_next/static/chunks/{648-8f3f26864ce515e5.js → 648-5cc6e1921389a58a.js} +0 -0
- /package/dist/dashboard/out/_next/static/chunks/app/_not-found/{page-0b990dbb71d72a98.js → page-53b8a69f76db17d0.js} +0 -0
- /package/dist/dashboard/out/_next/static/chunks/{fd9d1056-bf46c09eb57e019c.js → fd9d1056-609918ca7b6280bb.js} +0 -0
- /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → wPgKJtcOmTFLpUncDg16A}/_buildManifest.js +0 -0
- /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → wPgKJtcOmTFLpUncDg16A}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Responder
|
|
3
|
+
*
|
|
4
|
+
* Sends responses back to Slack via their Web API.
|
|
5
|
+
* https://api.slack.com/methods
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Call a Slack Web API method
|
|
9
|
+
*/
|
|
10
|
+
async function slackAPI(token, method, body) {
|
|
11
|
+
const response = await fetch(`https://slack.com/api/${method}`, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
15
|
+
'Authorization': `Bearer ${token}`,
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify(body),
|
|
18
|
+
});
|
|
19
|
+
return response.json();
|
|
20
|
+
}
|
|
21
|
+
export const slackResponder = {
|
|
22
|
+
id: 'slack',
|
|
23
|
+
async respond(event, response, config) {
|
|
24
|
+
const botToken = config?.botToken || process.env.SLACK_BOT_TOKEN;
|
|
25
|
+
if (!botToken) {
|
|
26
|
+
return {
|
|
27
|
+
success: false,
|
|
28
|
+
error: 'Slack bot token not configured',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
// Get channel from event metadata or response target
|
|
33
|
+
const channelId = response.metadata?.channel
|
|
34
|
+
|| event.metadata?.channelId
|
|
35
|
+
|| String(response.target);
|
|
36
|
+
if (!channelId) {
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
error: 'Channel ID required',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
switch (response.type) {
|
|
43
|
+
case 'message': {
|
|
44
|
+
// Post a message to a channel
|
|
45
|
+
const threadTs = response.metadata?.threadTs
|
|
46
|
+
|| event.metadata?.threadTs
|
|
47
|
+
|| event.metadata?.ts;
|
|
48
|
+
const result = await slackAPI(botToken, 'chat.postMessage', {
|
|
49
|
+
channel: channelId,
|
|
50
|
+
text: response.body,
|
|
51
|
+
thread_ts: threadTs, // Reply in thread if available
|
|
52
|
+
unfurl_links: false,
|
|
53
|
+
unfurl_media: false,
|
|
54
|
+
});
|
|
55
|
+
if (!result.ok) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
error: result.error || 'Failed to post message',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
id: result.ts,
|
|
64
|
+
// Construct Slack message URL
|
|
65
|
+
url: `https://slack.com/archives/${channelId}/p${result.ts?.replace('.', '')}`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
case 'comment': {
|
|
69
|
+
// Same as message, but explicitly in a thread
|
|
70
|
+
const threadTs = String(response.target);
|
|
71
|
+
const result = await slackAPI(botToken, 'chat.postMessage', {
|
|
72
|
+
channel: channelId,
|
|
73
|
+
text: response.body,
|
|
74
|
+
thread_ts: threadTs,
|
|
75
|
+
reply_broadcast: response.metadata?.broadcast === true,
|
|
76
|
+
});
|
|
77
|
+
if (!result.ok) {
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: result.error || 'Failed to post reply',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
id: result.ts,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
case 'reaction': {
|
|
89
|
+
// Add a reaction to a message
|
|
90
|
+
const ts = String(response.target);
|
|
91
|
+
const emoji = response.metadata?.emoji || response.body.replace(/:/g, '');
|
|
92
|
+
const result = await slackAPI(botToken, 'reactions.add', {
|
|
93
|
+
channel: channelId,
|
|
94
|
+
timestamp: ts,
|
|
95
|
+
name: emoji,
|
|
96
|
+
});
|
|
97
|
+
if (!result.ok && result.error !== 'already_reacted') {
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
error: result.error || 'Failed to add reaction',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
success: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
case 'status': {
|
|
108
|
+
// Update bot status/presence (not commonly used)
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
error: 'Status updates not implemented for Slack',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
error: `Unknown response type: ${response.type}`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Helper to format a message with blocks for richer formatting
|
|
131
|
+
*/
|
|
132
|
+
export function formatSlackBlocks(text, options) {
|
|
133
|
+
const blocks = [];
|
|
134
|
+
if (options?.header) {
|
|
135
|
+
blocks.push({
|
|
136
|
+
type: 'header',
|
|
137
|
+
text: {
|
|
138
|
+
type: 'plain_text',
|
|
139
|
+
text: options.header,
|
|
140
|
+
emoji: true,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
blocks.push({
|
|
145
|
+
type: 'section',
|
|
146
|
+
text: {
|
|
147
|
+
type: 'mrkdwn',
|
|
148
|
+
text,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
if (options?.context) {
|
|
152
|
+
blocks.push({
|
|
153
|
+
type: 'context',
|
|
154
|
+
elements: [
|
|
155
|
+
{
|
|
156
|
+
type: 'mrkdwn',
|
|
157
|
+
text: options.context,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (options?.actions?.length) {
|
|
163
|
+
blocks.push({
|
|
164
|
+
type: 'actions',
|
|
165
|
+
elements: options.actions.map(action => ({
|
|
166
|
+
type: 'button',
|
|
167
|
+
text: {
|
|
168
|
+
type: 'plain_text',
|
|
169
|
+
text: action.text,
|
|
170
|
+
emoji: true,
|
|
171
|
+
},
|
|
172
|
+
url: action.url,
|
|
173
|
+
})),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return blocks;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=slack.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Webhook Router
|
|
3
|
+
*
|
|
4
|
+
* Routes incoming webhooks from any source through the configurable pipeline:
|
|
5
|
+
* 1. Verify signature
|
|
6
|
+
* 2. Parse payload into normalized events
|
|
7
|
+
* 3. Match events against rules
|
|
8
|
+
* 4. Execute actions
|
|
9
|
+
* 5. Send responses
|
|
10
|
+
*/
|
|
11
|
+
import type { WebhookConfig, WebhookSourceConfig, WebhookResult } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Default webhook source configurations
|
|
14
|
+
*/
|
|
15
|
+
export declare const defaultSources: Record<string, WebhookSourceConfig>;
|
|
16
|
+
/**
|
|
17
|
+
* Get webhook configuration
|
|
18
|
+
* In the future, this could load from database per-workspace
|
|
19
|
+
*/
|
|
20
|
+
export declare function getWebhookConfig(): WebhookConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Process a webhook from any source
|
|
23
|
+
*/
|
|
24
|
+
export declare function processWebhook(source: string, payload: string, headers: Record<string, string | string[] | undefined>, config?: WebhookConfig): Promise<WebhookResult>;
|
|
25
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Webhook Router
|
|
3
|
+
*
|
|
4
|
+
* Routes incoming webhooks from any source through the configurable pipeline:
|
|
5
|
+
* 1. Verify signature
|
|
6
|
+
* 2. Parse payload into normalized events
|
|
7
|
+
* 3. Match events against rules
|
|
8
|
+
* 4. Execute actions
|
|
9
|
+
* 5. Send responses
|
|
10
|
+
*/
|
|
11
|
+
import crypto from 'crypto';
|
|
12
|
+
import { getParser } from './parsers/index.js';
|
|
13
|
+
import { getResponder } from './responders/index.js';
|
|
14
|
+
import { findMatchingRules, resolveActionTemplate, defaultRules } from './rules-engine.js';
|
|
15
|
+
import { db } from '../db/index.js';
|
|
16
|
+
/**
|
|
17
|
+
* Default webhook source configurations
|
|
18
|
+
*/
|
|
19
|
+
export const defaultSources = {
|
|
20
|
+
github: {
|
|
21
|
+
id: 'github',
|
|
22
|
+
name: 'GitHub',
|
|
23
|
+
enabled: true,
|
|
24
|
+
signature: {
|
|
25
|
+
header: 'x-hub-signature-256',
|
|
26
|
+
algorithm: 'sha256',
|
|
27
|
+
secretEnvVar: 'GITHUB_WEBHOOK_SECRET',
|
|
28
|
+
signaturePrefix: 'sha256=',
|
|
29
|
+
},
|
|
30
|
+
parser: 'github',
|
|
31
|
+
responder: 'github',
|
|
32
|
+
},
|
|
33
|
+
linear: {
|
|
34
|
+
id: 'linear',
|
|
35
|
+
name: 'Linear',
|
|
36
|
+
enabled: true,
|
|
37
|
+
signature: {
|
|
38
|
+
header: 'linear-signature',
|
|
39
|
+
algorithm: 'sha256',
|
|
40
|
+
secretEnvVar: 'LINEAR_WEBHOOK_SECRET',
|
|
41
|
+
},
|
|
42
|
+
parser: 'linear',
|
|
43
|
+
responder: 'linear',
|
|
44
|
+
},
|
|
45
|
+
slack: {
|
|
46
|
+
id: 'slack',
|
|
47
|
+
name: 'Slack',
|
|
48
|
+
enabled: true,
|
|
49
|
+
signature: {
|
|
50
|
+
header: 'x-slack-signature',
|
|
51
|
+
algorithm: 'slack-v0',
|
|
52
|
+
secretEnvVar: 'SLACK_SIGNING_SECRET',
|
|
53
|
+
},
|
|
54
|
+
parser: 'slack',
|
|
55
|
+
responder: 'slack',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Get webhook configuration
|
|
60
|
+
* In the future, this could load from database per-workspace
|
|
61
|
+
*/
|
|
62
|
+
export function getWebhookConfig() {
|
|
63
|
+
return {
|
|
64
|
+
sources: defaultSources,
|
|
65
|
+
rules: defaultRules,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Verify webhook signature
|
|
70
|
+
*/
|
|
71
|
+
function verifySignature(payload, signature, config, headers) {
|
|
72
|
+
if (config.signature.algorithm === 'none') {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (!signature) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const secret = process.env[config.signature.secretEnvVar];
|
|
79
|
+
if (!secret) {
|
|
80
|
+
console.warn(`[webhook-router] Secret not configured: ${config.signature.secretEnvVar}`);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
let expectedSignature;
|
|
85
|
+
let actualSignature = signature;
|
|
86
|
+
// Remove prefix if configured
|
|
87
|
+
if (config.signature.signaturePrefix && actualSignature.startsWith(config.signature.signaturePrefix)) {
|
|
88
|
+
actualSignature = actualSignature.slice(config.signature.signaturePrefix.length);
|
|
89
|
+
}
|
|
90
|
+
switch (config.signature.algorithm) {
|
|
91
|
+
case 'sha256':
|
|
92
|
+
expectedSignature = crypto
|
|
93
|
+
.createHmac('sha256', secret)
|
|
94
|
+
.update(payload)
|
|
95
|
+
.digest('hex');
|
|
96
|
+
break;
|
|
97
|
+
case 'sha1':
|
|
98
|
+
expectedSignature = crypto
|
|
99
|
+
.createHmac('sha1', secret)
|
|
100
|
+
.update(payload)
|
|
101
|
+
.digest('hex');
|
|
102
|
+
break;
|
|
103
|
+
case 'token':
|
|
104
|
+
// Direct token comparison
|
|
105
|
+
return actualSignature === secret;
|
|
106
|
+
case 'slack-v0': {
|
|
107
|
+
// Slack signature verification
|
|
108
|
+
// Format: v0=<HMAC-SHA256 of v0:timestamp:body>
|
|
109
|
+
const timestamp = headers?.['x-slack-request-timestamp'];
|
|
110
|
+
if (!timestamp)
|
|
111
|
+
return false;
|
|
112
|
+
// Check timestamp is within 5 minutes
|
|
113
|
+
const now = Math.floor(Date.now() / 1000);
|
|
114
|
+
if (Math.abs(now - parseInt(timestamp, 10)) > 300) {
|
|
115
|
+
console.warn('[webhook-router] Slack request timestamp too old');
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const sigBasestring = `v0:${timestamp}:${payload}`;
|
|
119
|
+
expectedSignature = 'v0=' + crypto
|
|
120
|
+
.createHmac('sha256', secret)
|
|
121
|
+
.update(sigBasestring)
|
|
122
|
+
.digest('hex');
|
|
123
|
+
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature));
|
|
124
|
+
}
|
|
125
|
+
default:
|
|
126
|
+
console.warn(`[webhook-router] Unknown signature algorithm: ${config.signature.algorithm}`);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return crypto.timingSafeEqual(Buffer.from(actualSignature), Buffer.from(expectedSignature));
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error('[webhook-router] Signature verification error:', error);
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Execute an action for an event
|
|
138
|
+
*/
|
|
139
|
+
async function executeAction(action, event, responder, responderConfig) {
|
|
140
|
+
const resolvedAction = resolveActionTemplate(action, event);
|
|
141
|
+
switch (resolvedAction.type) {
|
|
142
|
+
case 'spawn_agent': {
|
|
143
|
+
const agentType = resolvedAction.agentType || 'lead';
|
|
144
|
+
const prompt = buildPrompt(resolvedAction.prompt || 'default', event);
|
|
145
|
+
// Find the repository and queue spawn command
|
|
146
|
+
const repository = await db.repositories.findByFullName(event.context.name);
|
|
147
|
+
if (!repository?.userId) {
|
|
148
|
+
return { success: false, error: 'Repository not found or not linked' };
|
|
149
|
+
}
|
|
150
|
+
// Find an available daemon
|
|
151
|
+
const daemons = await db.linkedDaemons.findByUserId(repository.userId);
|
|
152
|
+
const onlineDaemon = daemons.find(d => d.status === 'online');
|
|
153
|
+
if (!onlineDaemon) {
|
|
154
|
+
// Post a response indicating no daemon available
|
|
155
|
+
if (responder && event.item?.number) {
|
|
156
|
+
await responder.respond(event, {
|
|
157
|
+
type: 'comment',
|
|
158
|
+
target: event.item.number,
|
|
159
|
+
body: `⚠️ No Agent Relay daemon is available to handle this request. Please ensure you have a linked daemon running.`,
|
|
160
|
+
}, responderConfig);
|
|
161
|
+
}
|
|
162
|
+
return { success: false, error: 'No available daemon' };
|
|
163
|
+
}
|
|
164
|
+
// Post acknowledgment
|
|
165
|
+
if (responder && event.item?.number) {
|
|
166
|
+
await responder.respond(event, {
|
|
167
|
+
type: 'comment',
|
|
168
|
+
target: event.item.number,
|
|
169
|
+
body: `👋 Routing to **@${agentType}** agent. The agent will respond shortly.`,
|
|
170
|
+
}, responderConfig);
|
|
171
|
+
}
|
|
172
|
+
// Queue spawn command
|
|
173
|
+
const agentName = `${agentType}-${event.id.slice(0, 8)}`;
|
|
174
|
+
await db.linkedDaemons.queueMessage(onlineDaemon.id, {
|
|
175
|
+
from: { daemonId: 'cloud', daemonName: 'Agent Relay Cloud', agent: 'system' },
|
|
176
|
+
to: '__spawner__',
|
|
177
|
+
content: JSON.stringify({
|
|
178
|
+
type: 'spawn_agent',
|
|
179
|
+
agentName,
|
|
180
|
+
cli: 'claude',
|
|
181
|
+
task: prompt,
|
|
182
|
+
metadata: {
|
|
183
|
+
eventId: event.id,
|
|
184
|
+
source: event.source,
|
|
185
|
+
eventType: event.type,
|
|
186
|
+
repository: event.context.name,
|
|
187
|
+
itemNumber: event.item?.number,
|
|
188
|
+
},
|
|
189
|
+
}),
|
|
190
|
+
metadata: { type: 'spawn_command' },
|
|
191
|
+
timestamp: new Date().toISOString(),
|
|
192
|
+
});
|
|
193
|
+
console.log(`[webhook-router] Queued spawn command for ${agentName}`);
|
|
194
|
+
return { success: true };
|
|
195
|
+
}
|
|
196
|
+
case 'message_agent': {
|
|
197
|
+
// Send message to existing agent
|
|
198
|
+
return { success: false, error: 'message_agent not yet implemented' };
|
|
199
|
+
}
|
|
200
|
+
case 'post_comment': {
|
|
201
|
+
if (!responder) {
|
|
202
|
+
return { success: false, error: 'No responder available' };
|
|
203
|
+
}
|
|
204
|
+
const body = resolvedAction.config?.body || 'Action received.';
|
|
205
|
+
const target = event.item?.number || event.item?.id || '';
|
|
206
|
+
const result = await responder.respond(event, {
|
|
207
|
+
type: 'comment',
|
|
208
|
+
target,
|
|
209
|
+
body,
|
|
210
|
+
}, responderConfig);
|
|
211
|
+
return { success: result.success, error: result.error };
|
|
212
|
+
}
|
|
213
|
+
case 'create_issue': {
|
|
214
|
+
return { success: false, error: 'create_issue not yet implemented' };
|
|
215
|
+
}
|
|
216
|
+
case 'custom': {
|
|
217
|
+
// Custom action handler
|
|
218
|
+
const handler = resolvedAction.config?.handler;
|
|
219
|
+
if (handler) {
|
|
220
|
+
await handler(event);
|
|
221
|
+
return { success: true };
|
|
222
|
+
}
|
|
223
|
+
return { success: false, error: 'No custom handler defined' };
|
|
224
|
+
}
|
|
225
|
+
default:
|
|
226
|
+
return { success: false, error: `Unknown action type: ${resolvedAction.type}` };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Build a prompt from a template name and event
|
|
231
|
+
*/
|
|
232
|
+
function buildPrompt(templateName, event) {
|
|
233
|
+
const templates = {
|
|
234
|
+
'ci-failure': (e) => `
|
|
235
|
+
# CI Failure Fix Task
|
|
236
|
+
|
|
237
|
+
A CI check has failed in ${e.context.name}.
|
|
238
|
+
|
|
239
|
+
## Failure Details
|
|
240
|
+
|
|
241
|
+
**Check Name:** ${e.item?.title || 'Unknown'}
|
|
242
|
+
**Branch:** ${e.metadata?.branch || 'unknown'}
|
|
243
|
+
**Commit:** ${e.metadata?.commitSha || 'unknown'}
|
|
244
|
+
|
|
245
|
+
${e.metadata?.failureSummary ? `**Summary:**\n${e.metadata.failureSummary}` : ''}
|
|
246
|
+
|
|
247
|
+
${e.metadata?.annotations ? `## Annotations\n\n${formatAnnotations(e.metadata.annotations)}` : ''}
|
|
248
|
+
|
|
249
|
+
## Your Task
|
|
250
|
+
|
|
251
|
+
1. Analyze the failure
|
|
252
|
+
2. Fix the issues
|
|
253
|
+
3. Push your changes
|
|
254
|
+
4. Report back with a summary
|
|
255
|
+
`.trim(),
|
|
256
|
+
'mention': (e) => `
|
|
257
|
+
# Agent Mention Task
|
|
258
|
+
|
|
259
|
+
You were mentioned in ${e.source} in ${e.context.name}.
|
|
260
|
+
|
|
261
|
+
## Context
|
|
262
|
+
|
|
263
|
+
**Item:** ${e.item?.title || 'N/A'} (#${e.item?.number || e.item?.id || 'N/A'})
|
|
264
|
+
**Author:** @${e.actor.name}
|
|
265
|
+
|
|
266
|
+
## Message
|
|
267
|
+
|
|
268
|
+
${e.item?.body || 'No message content'}
|
|
269
|
+
|
|
270
|
+
## Your Task
|
|
271
|
+
|
|
272
|
+
Respond helpfully to the mention. If code changes are needed, make them and push.
|
|
273
|
+
`.trim(),
|
|
274
|
+
'issue': (e) => `
|
|
275
|
+
# Issue Assignment
|
|
276
|
+
|
|
277
|
+
You've been assigned to work on an issue in ${e.context.name}.
|
|
278
|
+
|
|
279
|
+
## Issue Details
|
|
280
|
+
|
|
281
|
+
**Title:** ${e.item?.title}
|
|
282
|
+
**Priority:** ${e.priority || 'normal'}
|
|
283
|
+
**Labels:** ${e.labels.join(', ') || 'none'}
|
|
284
|
+
|
|
285
|
+
## Description
|
|
286
|
+
|
|
287
|
+
${e.item?.body || 'No description provided.'}
|
|
288
|
+
|
|
289
|
+
## Your Task
|
|
290
|
+
|
|
291
|
+
1. Analyze the issue
|
|
292
|
+
2. Implement a solution
|
|
293
|
+
3. Create a PR
|
|
294
|
+
`.trim(),
|
|
295
|
+
'linear-issue': (e) => `
|
|
296
|
+
# Linear Issue
|
|
297
|
+
|
|
298
|
+
A new issue was created in ${e.context.name}.
|
|
299
|
+
|
|
300
|
+
## Issue Details
|
|
301
|
+
|
|
302
|
+
**Identifier:** ${e.metadata?.identifier || 'N/A'}
|
|
303
|
+
**Title:** ${e.item?.title}
|
|
304
|
+
**Priority:** ${e.priority || 'normal'}
|
|
305
|
+
**State:** ${e.item?.state || 'unknown'}
|
|
306
|
+
|
|
307
|
+
## Description
|
|
308
|
+
|
|
309
|
+
${e.item?.body || 'No description provided.'}
|
|
310
|
+
|
|
311
|
+
## Your Task
|
|
312
|
+
|
|
313
|
+
Analyze and work on this issue if appropriate.
|
|
314
|
+
`.trim(),
|
|
315
|
+
'slack-request': (e) => `
|
|
316
|
+
# Slack Request
|
|
317
|
+
|
|
318
|
+
Someone mentioned you in Slack.
|
|
319
|
+
|
|
320
|
+
## Message
|
|
321
|
+
|
|
322
|
+
${e.item?.body || 'No message content'}
|
|
323
|
+
|
|
324
|
+
## Your Task
|
|
325
|
+
|
|
326
|
+
Respond to the request. Use the Slack API to post your response.
|
|
327
|
+
`.trim(),
|
|
328
|
+
'default': (e) => `
|
|
329
|
+
# Webhook Event
|
|
330
|
+
|
|
331
|
+
A webhook event was received from ${e.source}.
|
|
332
|
+
|
|
333
|
+
## Event Details
|
|
334
|
+
|
|
335
|
+
**Type:** ${e.type}
|
|
336
|
+
**Context:** ${e.context.name}
|
|
337
|
+
**Actor:** ${e.actor.name}
|
|
338
|
+
|
|
339
|
+
## Item
|
|
340
|
+
|
|
341
|
+
${e.item ? `**${e.item.type}:** ${e.item.title || e.item.id}` : 'No item'}
|
|
342
|
+
|
|
343
|
+
## Body
|
|
344
|
+
|
|
345
|
+
${e.item?.body || 'No content'}
|
|
346
|
+
`.trim(),
|
|
347
|
+
};
|
|
348
|
+
const template = templates[templateName] || templates['default'];
|
|
349
|
+
return template(event);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Format annotations for prompt
|
|
353
|
+
*/
|
|
354
|
+
function formatAnnotations(annotations) {
|
|
355
|
+
return annotations
|
|
356
|
+
.slice(0, 20)
|
|
357
|
+
.map(a => `- ${a.path}:${a.startLine} - ${a.message}`)
|
|
358
|
+
.join('\n');
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Process a webhook from any source
|
|
362
|
+
*/
|
|
363
|
+
export async function processWebhook(source, payload, headers, config) {
|
|
364
|
+
const webhookConfig = config || getWebhookConfig();
|
|
365
|
+
const sourceConfig = webhookConfig.sources[source];
|
|
366
|
+
if (!sourceConfig) {
|
|
367
|
+
return {
|
|
368
|
+
success: false,
|
|
369
|
+
eventId: 'unknown',
|
|
370
|
+
source,
|
|
371
|
+
eventType: 'unknown',
|
|
372
|
+
matchedRules: [],
|
|
373
|
+
actions: [],
|
|
374
|
+
responses: [{
|
|
375
|
+
type: 'error',
|
|
376
|
+
success: false,
|
|
377
|
+
error: `Unknown webhook source: ${source}`,
|
|
378
|
+
}],
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
if (!sourceConfig.enabled) {
|
|
382
|
+
return {
|
|
383
|
+
success: false,
|
|
384
|
+
eventId: 'unknown',
|
|
385
|
+
source,
|
|
386
|
+
eventType: 'unknown',
|
|
387
|
+
matchedRules: [],
|
|
388
|
+
actions: [],
|
|
389
|
+
responses: [{
|
|
390
|
+
type: 'error',
|
|
391
|
+
success: false,
|
|
392
|
+
error: `Webhook source disabled: ${source}`,
|
|
393
|
+
}],
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
// Verify signature
|
|
397
|
+
const signature = headers[sourceConfig.signature.header];
|
|
398
|
+
if (!verifySignature(payload, signature, sourceConfig, headers)) {
|
|
399
|
+
console.error(`[webhook-router] Invalid signature for source: ${source}`);
|
|
400
|
+
return {
|
|
401
|
+
success: false,
|
|
402
|
+
eventId: 'unknown',
|
|
403
|
+
source,
|
|
404
|
+
eventType: 'unknown',
|
|
405
|
+
matchedRules: [],
|
|
406
|
+
actions: [],
|
|
407
|
+
responses: [{
|
|
408
|
+
type: 'error',
|
|
409
|
+
success: false,
|
|
410
|
+
error: 'Invalid signature',
|
|
411
|
+
}],
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
// Parse payload
|
|
415
|
+
const parser = getParser(sourceConfig.parser);
|
|
416
|
+
if (!parser) {
|
|
417
|
+
return {
|
|
418
|
+
success: false,
|
|
419
|
+
eventId: 'unknown',
|
|
420
|
+
source,
|
|
421
|
+
eventType: 'unknown',
|
|
422
|
+
matchedRules: [],
|
|
423
|
+
actions: [],
|
|
424
|
+
responses: [{
|
|
425
|
+
type: 'error',
|
|
426
|
+
success: false,
|
|
427
|
+
error: `Parser not found: ${sourceConfig.parser}`,
|
|
428
|
+
}],
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
let parsedPayload;
|
|
432
|
+
try {
|
|
433
|
+
parsedPayload = JSON.parse(payload);
|
|
434
|
+
}
|
|
435
|
+
catch {
|
|
436
|
+
return {
|
|
437
|
+
success: false,
|
|
438
|
+
eventId: 'unknown',
|
|
439
|
+
source,
|
|
440
|
+
eventType: 'unknown',
|
|
441
|
+
matchedRules: [],
|
|
442
|
+
actions: [],
|
|
443
|
+
responses: [{
|
|
444
|
+
type: 'error',
|
|
445
|
+
success: false,
|
|
446
|
+
error: 'Invalid JSON payload',
|
|
447
|
+
}],
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const events = parser.parse(parsedPayload, headers, sourceConfig.parserConfig);
|
|
451
|
+
if (events.length === 0) {
|
|
452
|
+
return {
|
|
453
|
+
success: true,
|
|
454
|
+
eventId: 'none',
|
|
455
|
+
source,
|
|
456
|
+
eventType: 'none',
|
|
457
|
+
matchedRules: [],
|
|
458
|
+
actions: [],
|
|
459
|
+
responses: [],
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
// Get responder
|
|
463
|
+
const responder = getResponder(sourceConfig.responder);
|
|
464
|
+
// Process each event
|
|
465
|
+
const results = [];
|
|
466
|
+
for (const event of events) {
|
|
467
|
+
const matchedRules = findMatchingRules(webhookConfig.rules, event);
|
|
468
|
+
const actionResults = [];
|
|
469
|
+
const responseResults = [];
|
|
470
|
+
console.log(`[webhook-router] Event ${event.id}: type=${event.type}, matched ${matchedRules.length} rules`);
|
|
471
|
+
for (const rule of matchedRules) {
|
|
472
|
+
const result = await executeAction(rule.action, event, responder, sourceConfig.responderConfig);
|
|
473
|
+
actionResults.push({
|
|
474
|
+
ruleId: rule.id,
|
|
475
|
+
action: rule.action,
|
|
476
|
+
success: result.success,
|
|
477
|
+
error: result.error,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
results.push({
|
|
481
|
+
success: actionResults.every(a => a.success),
|
|
482
|
+
eventId: event.id,
|
|
483
|
+
source: event.source,
|
|
484
|
+
eventType: event.type,
|
|
485
|
+
matchedRules: matchedRules.map(r => r.id),
|
|
486
|
+
actions: actionResults,
|
|
487
|
+
responses: responseResults,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// Return combined result
|
|
491
|
+
if (results.length === 1) {
|
|
492
|
+
return results[0];
|
|
493
|
+
}
|
|
494
|
+
return {
|
|
495
|
+
success: results.every(r => r.success),
|
|
496
|
+
eventId: events[0].id,
|
|
497
|
+
source,
|
|
498
|
+
eventType: events.map(e => e.type).join(','),
|
|
499
|
+
matchedRules: results.flatMap(r => r.matchedRules),
|
|
500
|
+
actions: results.flatMap(r => r.actions),
|
|
501
|
+
responses: results.flatMap(r => r.responses),
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
//# sourceMappingURL=router.js.map
|