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,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mention Handler Service
|
|
3
|
+
*
|
|
4
|
+
* Handles @mentions of agents in GitHub issues and PR comments.
|
|
5
|
+
* Routes mentions to appropriate agents for response.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. App posts acknowledgment comment
|
|
9
|
+
* 2. Finds a linked daemon for the repository
|
|
10
|
+
* 3. Queues spawn command for the daemon
|
|
11
|
+
* 4. Agent works and posts response comment
|
|
12
|
+
*/
|
|
13
|
+
import { db } from '../db/index.js';
|
|
14
|
+
import { nangoService } from './nango.js';
|
|
15
|
+
/**
|
|
16
|
+
* Known agent types that can be mentioned
|
|
17
|
+
*/
|
|
18
|
+
export const KNOWN_AGENTS = {
|
|
19
|
+
// Generic agents
|
|
20
|
+
'agent-relay': 'General purpose agent for any task',
|
|
21
|
+
'lead': 'Lead agent for coordination and delegation',
|
|
22
|
+
'developer': 'Developer agent for coding tasks',
|
|
23
|
+
'reviewer': 'Code review agent',
|
|
24
|
+
// Specialized agents
|
|
25
|
+
'ci-fix': 'CI failure fixing agent',
|
|
26
|
+
'debugger': 'Bug investigation and fixing agent',
|
|
27
|
+
'docs': 'Documentation agent',
|
|
28
|
+
'test': 'Test writing agent',
|
|
29
|
+
'refactor': 'Code refactoring agent',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Check if a mention is for a known agent type
|
|
33
|
+
*/
|
|
34
|
+
export function isKnownAgent(mention) {
|
|
35
|
+
return mention in KNOWN_AGENTS;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the GitHub App name for comments
|
|
39
|
+
*/
|
|
40
|
+
function getAppName() {
|
|
41
|
+
return process.env.GITHUB_APP_NAME || 'Agent Relay';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Post an acknowledgment comment on GitHub
|
|
45
|
+
*/
|
|
46
|
+
async function postAcknowledgmentComment(repository, issueNumber, mentionedAgent, authorLogin) {
|
|
47
|
+
if (!repository.nangoConnectionId) {
|
|
48
|
+
console.warn(`[mention-handler] Repository ${repository.githubFullName} has no Nango connection`);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const [owner, repo] = repository.githubFullName.split('/');
|
|
52
|
+
const appName = getAppName();
|
|
53
|
+
const agentDescription = isKnownAgent(mentionedAgent)
|
|
54
|
+
? KNOWN_AGENTS[mentionedAgent]
|
|
55
|
+
: 'Custom agent';
|
|
56
|
+
const body = `👋 @${authorLogin}, I've received your request and am routing it to **@${mentionedAgent}** (${agentDescription}).
|
|
57
|
+
|
|
58
|
+
The agent will respond shortly. You can track progress in this thread.
|
|
59
|
+
|
|
60
|
+
_— ${appName}_`;
|
|
61
|
+
try {
|
|
62
|
+
const result = await nangoService.addGithubIssueComment(repository.nangoConnectionId, owner, repo, issueNumber, body);
|
|
63
|
+
console.log(`[mention-handler] Posted acknowledgment comment: ${result.html_url}`);
|
|
64
|
+
return { id: result.id, url: result.html_url };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(`[mention-handler] Failed to post acknowledgment comment:`, error);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Find a linked daemon that can handle this repository
|
|
73
|
+
*/
|
|
74
|
+
async function findAvailableDaemon(repository) {
|
|
75
|
+
// The daemon must belong to the repository owner
|
|
76
|
+
if (!repository.userId) {
|
|
77
|
+
console.warn(`[mention-handler] Repository ${repository.githubFullName} has no userId`);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const daemons = await db.linkedDaemons.findByUserId(repository.userId);
|
|
81
|
+
const onlineDaemon = daemons.find(d => d.status === 'online');
|
|
82
|
+
if (!onlineDaemon) {
|
|
83
|
+
console.warn(`[mention-handler] No online daemon found for user ${repository.userId}`);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return { id: onlineDaemon.id, userId: repository.userId };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Queue a spawn command for a linked daemon
|
|
90
|
+
*/
|
|
91
|
+
async function queueSpawnCommand(daemonId, agentName, prompt, metadata) {
|
|
92
|
+
const command = {
|
|
93
|
+
type: 'spawn_agent',
|
|
94
|
+
agentName,
|
|
95
|
+
cli: 'claude', // Default to Claude CLI
|
|
96
|
+
task: prompt,
|
|
97
|
+
metadata,
|
|
98
|
+
timestamp: new Date().toISOString(),
|
|
99
|
+
};
|
|
100
|
+
await db.linkedDaemons.queueMessage(daemonId, {
|
|
101
|
+
from: { daemonId: 'cloud', daemonName: 'Agent Relay Cloud', agent: 'system' },
|
|
102
|
+
to: '__spawner__',
|
|
103
|
+
content: JSON.stringify(command),
|
|
104
|
+
metadata: { type: 'spawn_command' },
|
|
105
|
+
timestamp: new Date().toISOString(),
|
|
106
|
+
});
|
|
107
|
+
console.log(`[mention-handler] Queued spawn command for daemon ${daemonId}`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Handle a mention record
|
|
111
|
+
*
|
|
112
|
+
* This function:
|
|
113
|
+
* 1. Validates the mention is for a known agent
|
|
114
|
+
* 2. Posts an acknowledgment comment
|
|
115
|
+
* 3. Finds a linked daemon
|
|
116
|
+
* 4. Queues a spawn command for the agent
|
|
117
|
+
*/
|
|
118
|
+
export async function handleMention(mention) {
|
|
119
|
+
console.log(`[mention-handler] Processing mention: @${mention.mentionedAgent} in ${mention.repository}`);
|
|
120
|
+
// Check if this is a known agent type
|
|
121
|
+
if (!isKnownAgent(mention.mentionedAgent)) {
|
|
122
|
+
console.log(`[mention-handler] Unknown agent: @${mention.mentionedAgent}, checking workspace config`);
|
|
123
|
+
// TODO: Check workspace configuration for custom agent names
|
|
124
|
+
// For now, mark as ignored
|
|
125
|
+
await db.commentMentions.markIgnored(mention.id);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// Find the repository to get Nango connection
|
|
129
|
+
const repository = await db.repositories.findByFullName(mention.repository);
|
|
130
|
+
if (!repository) {
|
|
131
|
+
console.error(`[mention-handler] Repository not found: ${mention.repository}`);
|
|
132
|
+
await db.commentMentions.markIgnored(mention.id);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Generate agent info
|
|
136
|
+
const agentId = `mention-${mention.id}`;
|
|
137
|
+
const agentName = `${mention.mentionedAgent}-${mention.issueOrPrNumber}`;
|
|
138
|
+
// Update status to processing
|
|
139
|
+
await db.commentMentions.markProcessing(mention.id, agentId, agentName);
|
|
140
|
+
// Step 1: Post acknowledgment comment
|
|
141
|
+
const ackResult = await postAcknowledgmentComment(repository, mention.issueOrPrNumber, mention.mentionedAgent, mention.authorLogin);
|
|
142
|
+
if (!ackResult) {
|
|
143
|
+
console.warn(`[mention-handler] Could not post acknowledgment, continuing anyway`);
|
|
144
|
+
}
|
|
145
|
+
// Step 2: Find a linked daemon
|
|
146
|
+
const daemon = await findAvailableDaemon(repository);
|
|
147
|
+
if (!daemon) {
|
|
148
|
+
console.warn(`[mention-handler] No available daemon for ${mention.repository}`);
|
|
149
|
+
// Post a comment explaining the situation
|
|
150
|
+
if (repository.nangoConnectionId) {
|
|
151
|
+
const [owner, repo] = repository.githubFullName.split('/');
|
|
152
|
+
try {
|
|
153
|
+
await nangoService.addGithubIssueComment(repository.nangoConnectionId, owner, repo, mention.issueOrPrNumber, `⚠️ @${mention.authorLogin}, I couldn't find an available agent to handle this request. Please ensure you have a linked Agent Relay daemon running.
|
|
154
|
+
|
|
155
|
+
You can set this up by running \`agent-relay cloud link\` on your development machine.
|
|
156
|
+
|
|
157
|
+
_— ${getAppName()}_`);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error(`[mention-handler] Failed to post error comment:`, error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
// Step 3: Build the prompt for the agent
|
|
166
|
+
const prompt = buildMentionPrompt(mention, repository);
|
|
167
|
+
// Step 4: Queue spawn command for the daemon
|
|
168
|
+
await queueSpawnCommand(daemon.id, agentName, prompt, {
|
|
169
|
+
mentionId: mention.id,
|
|
170
|
+
repository: mention.repository,
|
|
171
|
+
issueNumber: mention.issueOrPrNumber,
|
|
172
|
+
authorLogin: mention.authorLogin,
|
|
173
|
+
});
|
|
174
|
+
console.log(`[mention-handler] Spawned agent @${mention.mentionedAgent} for mention ${mention.id}`);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Build a prompt for handling a mention
|
|
178
|
+
*/
|
|
179
|
+
function buildMentionPrompt(mention, _repository) {
|
|
180
|
+
const agentDescription = isKnownAgent(mention.mentionedAgent)
|
|
181
|
+
? KNOWN_AGENTS[mention.mentionedAgent]
|
|
182
|
+
: 'Custom agent';
|
|
183
|
+
const sourceTypeDescription = {
|
|
184
|
+
issue_comment: 'GitHub issue comment',
|
|
185
|
+
pr_comment: 'GitHub PR comment',
|
|
186
|
+
pr_review: 'GitHub PR review comment',
|
|
187
|
+
}[mention.sourceType] || 'GitHub comment';
|
|
188
|
+
const responseInstructions = `
|
|
189
|
+
## Response Instructions
|
|
190
|
+
|
|
191
|
+
When you complete your work:
|
|
192
|
+
1. Post a comment on GitHub to notify @${mention.authorLogin}
|
|
193
|
+
2. Reference specific files and line numbers when relevant
|
|
194
|
+
3. If you made code changes, push them and reference the commit
|
|
195
|
+
|
|
196
|
+
Use the GitHub CLI (\`gh\`) to post your response:
|
|
197
|
+
\`\`\`bash
|
|
198
|
+
gh issue comment ${mention.issueOrPrNumber} --repo ${mention.repository} --body "Your response here @${mention.authorLogin}"
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
Or for PR comments:
|
|
202
|
+
\`\`\`bash
|
|
203
|
+
gh pr comment ${mention.issueOrPrNumber} --repo ${mention.repository} --body "Your response here @${mention.authorLogin}"
|
|
204
|
+
\`\`\`
|
|
205
|
+
`;
|
|
206
|
+
return `
|
|
207
|
+
# Agent Mention Task
|
|
208
|
+
|
|
209
|
+
You (@${mention.mentionedAgent}) have been mentioned in a ${sourceTypeDescription}.
|
|
210
|
+
|
|
211
|
+
## Your Role
|
|
212
|
+
${agentDescription}
|
|
213
|
+
|
|
214
|
+
## Context
|
|
215
|
+
|
|
216
|
+
**Repository:** ${mention.repository}
|
|
217
|
+
**Issue/PR:** #${mention.issueOrPrNumber}
|
|
218
|
+
**Comment by:** @${mention.authorLogin}
|
|
219
|
+
**Comment URL:** ${mention.commentUrl || 'N/A'}
|
|
220
|
+
|
|
221
|
+
## Comment
|
|
222
|
+
|
|
223
|
+
${mention.commentBody}
|
|
224
|
+
|
|
225
|
+
## Your Task
|
|
226
|
+
|
|
227
|
+
Analyze the comment and respond appropriately:
|
|
228
|
+
|
|
229
|
+
1. If a question was asked, provide a helpful answer
|
|
230
|
+
2. If a task was requested, either complete it or explain what's needed
|
|
231
|
+
3. If feedback was given, acknowledge it and act on it if needed
|
|
232
|
+
|
|
233
|
+
${responseInstructions}
|
|
234
|
+
|
|
235
|
+
## Important
|
|
236
|
+
|
|
237
|
+
- Be concise and helpful
|
|
238
|
+
- If you need to make code changes, create a commit and push
|
|
239
|
+
- If the request is unclear, ask for clarification in your response
|
|
240
|
+
- Always @mention ${mention.authorLogin} in your response so they get notified
|
|
241
|
+
`.trim();
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Handle an issue assignment
|
|
245
|
+
*
|
|
246
|
+
* Called when an issue should be assigned to an agent
|
|
247
|
+
*/
|
|
248
|
+
export async function handleIssueAssignment(assignment) {
|
|
249
|
+
console.log(`[mention-handler] Processing issue assignment: #${assignment.issueNumber} in ${assignment.repository}`);
|
|
250
|
+
// Find the repository
|
|
251
|
+
const repository = await db.repositories.findByFullName(assignment.repository);
|
|
252
|
+
if (!repository) {
|
|
253
|
+
console.error(`[mention-handler] Repository not found: ${assignment.repository}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
// Post acknowledgment comment
|
|
257
|
+
if (repository.nangoConnectionId) {
|
|
258
|
+
const [owner, repo] = repository.githubFullName.split('/');
|
|
259
|
+
try {
|
|
260
|
+
await nangoService.addGithubIssueComment(repository.nangoConnectionId, owner, repo, assignment.issueNumber, `🤖 I've been assigned to work on this issue. I'll analyze the problem and get started.
|
|
261
|
+
|
|
262
|
+
You can track my progress in this thread. I'll update you when I have a solution or need more information.
|
|
263
|
+
|
|
264
|
+
_— ${getAppName()}_`);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
console.error(`[mention-handler] Failed to post assignment comment:`, error);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Find a linked daemon
|
|
271
|
+
const daemon = await findAvailableDaemon(repository);
|
|
272
|
+
if (!daemon) {
|
|
273
|
+
console.warn(`[mention-handler] No available daemon for ${assignment.repository}`);
|
|
274
|
+
if (repository.nangoConnectionId) {
|
|
275
|
+
const [owner, repo] = repository.githubFullName.split('/');
|
|
276
|
+
try {
|
|
277
|
+
await nangoService.addGithubIssueComment(repository.nangoConnectionId, owner, repo, assignment.issueNumber, `⚠️ I couldn't start working on this issue because no Agent Relay daemon is available.
|
|
278
|
+
|
|
279
|
+
Please ensure you have a linked daemon running by executing \`agent-relay cloud link\` on your development machine.
|
|
280
|
+
|
|
281
|
+
_— ${getAppName()}_`);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
console.error(`[mention-handler] Failed to post error comment:`, error);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
// Build prompt for the issue
|
|
290
|
+
const prompt = buildIssuePrompt(assignment, repository);
|
|
291
|
+
// Queue spawn command
|
|
292
|
+
const agentName = `issue-${assignment.issueNumber}`;
|
|
293
|
+
await queueSpawnCommand(daemon.id, agentName, prompt, {
|
|
294
|
+
mentionId: assignment.id,
|
|
295
|
+
repository: assignment.repository,
|
|
296
|
+
issueNumber: assignment.issueNumber,
|
|
297
|
+
authorLogin: 'issue-author', // TODO: Get from issue
|
|
298
|
+
});
|
|
299
|
+
// Update assignment status and assign agent
|
|
300
|
+
await db.issueAssignments.assignAgent(assignment.id, agentName, agentName);
|
|
301
|
+
await db.issueAssignments.updateStatus(assignment.id, 'in_progress');
|
|
302
|
+
console.log(`[mention-handler] Spawned agent for issue #${assignment.issueNumber}`);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Build a prompt for an issue assignment
|
|
306
|
+
*/
|
|
307
|
+
function buildIssuePrompt(assignment, _repository) {
|
|
308
|
+
const priorityNote = assignment.priority
|
|
309
|
+
? `\n**Priority:** ${assignment.priority.toUpperCase()}`
|
|
310
|
+
: '';
|
|
311
|
+
const labelsNote = assignment.labels && assignment.labels.length > 0
|
|
312
|
+
? `\n**Labels:** ${assignment.labels.join(', ')}`
|
|
313
|
+
: '';
|
|
314
|
+
return `
|
|
315
|
+
# Issue Assignment
|
|
316
|
+
|
|
317
|
+
You have been assigned to work on GitHub issue #${assignment.issueNumber}.
|
|
318
|
+
|
|
319
|
+
## Issue Details
|
|
320
|
+
|
|
321
|
+
**Repository:** ${assignment.repository}
|
|
322
|
+
**Title:** ${assignment.issueTitle}${priorityNote}${labelsNote}
|
|
323
|
+
**URL:** ${assignment.issueUrl || 'N/A'}
|
|
324
|
+
|
|
325
|
+
## Description
|
|
326
|
+
|
|
327
|
+
${assignment.issueBody || 'No description provided.'}
|
|
328
|
+
|
|
329
|
+
## Your Task
|
|
330
|
+
|
|
331
|
+
1. Analyze the issue and understand what needs to be done
|
|
332
|
+
2. Investigate the codebase to find relevant files
|
|
333
|
+
3. Implement a solution if possible
|
|
334
|
+
4. Create a PR with your changes
|
|
335
|
+
5. Link the PR to this issue
|
|
336
|
+
|
|
337
|
+
## Response Instructions
|
|
338
|
+
|
|
339
|
+
Keep the issue updated with your progress:
|
|
340
|
+
\`\`\`bash
|
|
341
|
+
gh issue comment ${assignment.issueNumber} --repo ${assignment.repository} --body "Your update here"
|
|
342
|
+
\`\`\`
|
|
343
|
+
|
|
344
|
+
When you create a PR:
|
|
345
|
+
\`\`\`bash
|
|
346
|
+
gh pr create --repo ${assignment.repository} --title "Fix #${assignment.issueNumber}: Brief description" --body "Fixes #${assignment.issueNumber}
|
|
347
|
+
|
|
348
|
+
Description of changes..."
|
|
349
|
+
\`\`\`
|
|
350
|
+
|
|
351
|
+
## Important
|
|
352
|
+
|
|
353
|
+
- Start with a comment on the issue acknowledging you're working on it
|
|
354
|
+
- If you need clarification, ask in the issue comments
|
|
355
|
+
- Create a draft PR early if the fix is complex
|
|
356
|
+
- Reference the issue number in your commit messages (e.g., "Fix #${assignment.issueNumber}")
|
|
357
|
+
`.trim();
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Get pending mentions for processing
|
|
361
|
+
*/
|
|
362
|
+
export async function getPendingMentions(limit = 50) {
|
|
363
|
+
return db.commentMentions.findPending(limit);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Get pending issue assignments for processing
|
|
367
|
+
*/
|
|
368
|
+
export async function getPendingIssueAssignments(limit = 50) {
|
|
369
|
+
return db.issueAssignments.findPending(limit);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Process all pending mentions (background job)
|
|
373
|
+
*/
|
|
374
|
+
export async function processPendingMentions() {
|
|
375
|
+
const pending = await getPendingMentions();
|
|
376
|
+
let processed = 0;
|
|
377
|
+
for (const mention of pending) {
|
|
378
|
+
try {
|
|
379
|
+
await handleMention(mention);
|
|
380
|
+
processed++;
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
console.error(`[mention-handler] Failed to process mention ${mention.id}:`, error);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return processed;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Process all pending issue assignments (background job)
|
|
390
|
+
*/
|
|
391
|
+
export async function processPendingIssueAssignments() {
|
|
392
|
+
const pending = await getPendingIssueAssignments();
|
|
393
|
+
let processed = 0;
|
|
394
|
+
for (const assignment of pending) {
|
|
395
|
+
try {
|
|
396
|
+
await handleIssueAssignment(assignment);
|
|
397
|
+
processed++;
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
console.error(`[mention-handler] Failed to process assignment ${assignment.id}:`, error);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return processed;
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=mention-handler.js.map
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
export declare const NANGO_INTEGRATIONS: {
|
|
2
|
+
readonly GITHUB_USER: "github";
|
|
3
|
+
readonly GITHUB_APP: "github-app-oauth";
|
|
4
|
+
};
|
|
5
|
+
export interface GithubUserProfile {
|
|
6
|
+
id: number;
|
|
7
|
+
login: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
avatar_url?: string;
|
|
10
|
+
}
|
|
11
|
+
declare class NangoService {
|
|
12
|
+
private client;
|
|
13
|
+
private secret;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Create a Nango connect session restricted to specific integrations.
|
|
17
|
+
*/
|
|
18
|
+
createConnectSession(allowedIntegrations: string[], endUser: {
|
|
19
|
+
id: string;
|
|
20
|
+
email?: string;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
token: string;
|
|
23
|
+
connect_link: string;
|
|
24
|
+
expires_at: string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch GitHub user profile via Nango proxy.
|
|
28
|
+
*/
|
|
29
|
+
getGithubUser(connectionId: string): Promise<GithubUserProfile>;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve an installation access token from a GitHub App connection.
|
|
32
|
+
* Use this ONLY when you need the raw token (e.g., for git clone URLs).
|
|
33
|
+
* For API calls, use the proxy methods instead.
|
|
34
|
+
*/
|
|
35
|
+
getGithubAppToken(connectionId: string): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve the user's OAuth access token from a GitHub App OAuth connection.
|
|
38
|
+
* This is the user-level token (not the installation token).
|
|
39
|
+
* Use this for operations that require user context (e.g., gh CLI).
|
|
40
|
+
*
|
|
41
|
+
* The user token can be found in:
|
|
42
|
+
* 1. getToken() without installation flag
|
|
43
|
+
* 2. connection_config.access_token in github-app-oauth
|
|
44
|
+
* 3. Separate 'github' user connection
|
|
45
|
+
*/
|
|
46
|
+
getGithubUserOAuthToken(connectionId: string): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve the user's OAuth token from a 'github' user connection.
|
|
49
|
+
* This is for the separate GitHub OAuth login (not the App connection).
|
|
50
|
+
*/
|
|
51
|
+
getGithubUserToken(connectionId: string): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* List repositories available to a GitHub App installation using the Nango Proxy.
|
|
54
|
+
* The proxy automatically handles token injection and refresh.
|
|
55
|
+
* @see https://nango.dev/docs/implementation-guides/requests-proxy/implement-requests-proxy
|
|
56
|
+
*/
|
|
57
|
+
listGithubAppRepos(connectionId: string): Promise<{
|
|
58
|
+
repositories: Array<{
|
|
59
|
+
id: number;
|
|
60
|
+
full_name: string;
|
|
61
|
+
private: boolean;
|
|
62
|
+
default_branch: string;
|
|
63
|
+
}>;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Get the GitHub App installation ID from a connection.
|
|
67
|
+
* The installation ID is stored in connection_config.installation_id
|
|
68
|
+
*/
|
|
69
|
+
getGithubAppInstallationId(connectionId: string): Promise<number | null>;
|
|
70
|
+
/**
|
|
71
|
+
* Create an issue via Nango Proxy.
|
|
72
|
+
*/
|
|
73
|
+
createGithubIssue(connectionId: string, owner: string, repo: string, data: {
|
|
74
|
+
title: string;
|
|
75
|
+
body?: string;
|
|
76
|
+
labels?: string[];
|
|
77
|
+
}): Promise<{
|
|
78
|
+
number: number;
|
|
79
|
+
html_url: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Create a pull request via Nango Proxy.
|
|
83
|
+
*/
|
|
84
|
+
createGithubPullRequest(connectionId: string, owner: string, repo: string, data: {
|
|
85
|
+
title: string;
|
|
86
|
+
body?: string;
|
|
87
|
+
head: string;
|
|
88
|
+
base: string;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
number: number;
|
|
91
|
+
html_url: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Add a comment to an issue via Nango Proxy.
|
|
95
|
+
*/
|
|
96
|
+
addGithubIssueComment(connectionId: string, owner: string, repo: string, issueNumber: number, body: string): Promise<{
|
|
97
|
+
id: number;
|
|
98
|
+
html_url: string;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Update connection end user metadata (e.g., after creating a user record).
|
|
102
|
+
*/
|
|
103
|
+
updateEndUser(connectionId: string, providerConfigKey: string, endUser: {
|
|
104
|
+
id: string;
|
|
105
|
+
email?: string;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Delete a connection from Nango.
|
|
109
|
+
*
|
|
110
|
+
* Used to remove temporary session connections for returning users
|
|
111
|
+
* to prevent duplicate connections in Nango. In the two-connection pattern,
|
|
112
|
+
* new users get a permanent connection but returning users authenticate
|
|
113
|
+
* with a temporary one that gets deleted.
|
|
114
|
+
*
|
|
115
|
+
* @param connectionId - Nango connection ID to delete
|
|
116
|
+
* @param providerConfigKey - The integration key (e.g., 'github')
|
|
117
|
+
*/
|
|
118
|
+
deleteConnection(connectionId: string, providerConfigKey: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Get connection metadata including end_user info.
|
|
121
|
+
* Useful when webhook doesn't include end_user data.
|
|
122
|
+
*/
|
|
123
|
+
getConnection(connectionId: string, providerConfigKey: string): Promise<{
|
|
124
|
+
id: number;
|
|
125
|
+
connection_id: string;
|
|
126
|
+
provider_config_key: string;
|
|
127
|
+
end_user?: {
|
|
128
|
+
id?: string;
|
|
129
|
+
email?: string;
|
|
130
|
+
};
|
|
131
|
+
metadata?: Record<string, unknown>;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Check if user has access to a specific GitHub repository.
|
|
135
|
+
* Uses the user's OAuth connection to query GitHub API.
|
|
136
|
+
* @param connectionId - User's Nango connection ID (github user OAuth)
|
|
137
|
+
* @param owner - Repository owner
|
|
138
|
+
* @param repo - Repository name
|
|
139
|
+
* @returns Access details or null if no access
|
|
140
|
+
*/
|
|
141
|
+
checkUserRepoAccess(connectionId: string, owner: string, repo: string): Promise<{
|
|
142
|
+
hasAccess: boolean;
|
|
143
|
+
permission?: 'admin' | 'write' | 'read' | 'none';
|
|
144
|
+
repository?: {
|
|
145
|
+
id: number;
|
|
146
|
+
fullName: string;
|
|
147
|
+
isPrivate: boolean;
|
|
148
|
+
defaultBranch: string;
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* List all repositories the user has access to via their OAuth connection.
|
|
153
|
+
* Uses the user's personal OAuth token (not the GitHub App).
|
|
154
|
+
* @param connectionId - User's Nango connection ID (github user OAuth)
|
|
155
|
+
* @param options - Pagination and filter options
|
|
156
|
+
* @returns List of accessible repositories
|
|
157
|
+
*/
|
|
158
|
+
listUserAccessibleRepos(connectionId: string, options?: {
|
|
159
|
+
page?: number;
|
|
160
|
+
perPage?: number;
|
|
161
|
+
type?: 'all' | 'owner' | 'public' | 'private' | 'member';
|
|
162
|
+
sort?: 'created' | 'updated' | 'pushed' | 'full_name';
|
|
163
|
+
}): Promise<{
|
|
164
|
+
repositories: Array<{
|
|
165
|
+
id: number;
|
|
166
|
+
fullName: string;
|
|
167
|
+
isPrivate: boolean;
|
|
168
|
+
defaultBranch: string;
|
|
169
|
+
permissions: {
|
|
170
|
+
admin: boolean;
|
|
171
|
+
push: boolean;
|
|
172
|
+
pull: boolean;
|
|
173
|
+
};
|
|
174
|
+
}>;
|
|
175
|
+
hasMore: boolean;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Verify webhook signature sent by Nango.
|
|
179
|
+
* Uses the new verifyIncomingWebhookRequest method.
|
|
180
|
+
* @see https://nango.dev/docs/reference/sdks/node#verify-webhook-signature
|
|
181
|
+
*/
|
|
182
|
+
verifyWebhookSignature(rawBody: string, headers: Record<string, string | string[] | undefined>): boolean;
|
|
183
|
+
}
|
|
184
|
+
export declare const nangoService: NangoService;
|
|
185
|
+
export {};
|
|
186
|
+
//# sourceMappingURL=nango.d.ts.map
|