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,578 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Monitoring API Routes
|
|
3
|
+
*
|
|
4
|
+
* Provides endpoints for:
|
|
5
|
+
* - Real-time memory metrics collection
|
|
6
|
+
* - Crash insights and history
|
|
7
|
+
* - Proactive alerting
|
|
8
|
+
* - System health dashboard
|
|
9
|
+
*/
|
|
10
|
+
import { Router } from 'express';
|
|
11
|
+
import { createHash } from 'crypto';
|
|
12
|
+
import { eq, desc, and, gte, sql } from 'drizzle-orm';
|
|
13
|
+
import { requireAuth } from './auth.js';
|
|
14
|
+
import { db as dbModule } from '../db/index.js';
|
|
15
|
+
import { getDb } from '../db/drizzle.js';
|
|
16
|
+
import { agentMetrics, agentCrashes, memoryAlerts, } from '../db/schema.js';
|
|
17
|
+
export const monitoringRouter = Router();
|
|
18
|
+
/**
|
|
19
|
+
* Hash an API key for lookup
|
|
20
|
+
*/
|
|
21
|
+
function hashApiKey(apiKey) {
|
|
22
|
+
return createHash('sha256').update(apiKey).digest('hex');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Middleware to authenticate daemon by API key
|
|
26
|
+
*/
|
|
27
|
+
async function requireDaemonAuth(req, res, next) {
|
|
28
|
+
const authHeader = req.headers.authorization;
|
|
29
|
+
if (!authHeader || !authHeader.startsWith('Bearer ar_live_')) {
|
|
30
|
+
res.status(401).json({ error: 'Invalid API key format' });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const apiKey = authHeader.replace('Bearer ', '');
|
|
34
|
+
const apiKeyHash = hashApiKey(apiKey);
|
|
35
|
+
try {
|
|
36
|
+
const daemon = await dbModule.linkedDaemons.findByApiKeyHash(apiKeyHash);
|
|
37
|
+
if (!daemon) {
|
|
38
|
+
res.status(401).json({ error: 'Invalid API key' });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
req.daemon = daemon;
|
|
42
|
+
next();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('Daemon auth error:', error);
|
|
46
|
+
res.status(500).json({ error: 'Authentication failed' });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// Daemon API (authenticated with API key)
|
|
51
|
+
// ============================================================================
|
|
52
|
+
/**
|
|
53
|
+
* POST /api/monitoring/metrics
|
|
54
|
+
* Report agent memory metrics from daemon
|
|
55
|
+
*/
|
|
56
|
+
monitoringRouter.post('/metrics', requireDaemonAuth, async (req, res) => {
|
|
57
|
+
const daemon = req.daemon;
|
|
58
|
+
const { agents } = req.body;
|
|
59
|
+
if (!agents || !Array.isArray(agents)) {
|
|
60
|
+
return res.status(400).json({ error: 'agents array is required' });
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const db = getDb();
|
|
64
|
+
const now = new Date();
|
|
65
|
+
// Insert metrics for each agent
|
|
66
|
+
for (const agent of agents) {
|
|
67
|
+
const metricsData = {
|
|
68
|
+
rssBytes: agent.rssBytes || 0,
|
|
69
|
+
heapUsedBytes: agent.heapUsedBytes || 0,
|
|
70
|
+
heapTotalBytes: agent.heapTotalBytes || 0,
|
|
71
|
+
cpuPercent: agent.cpuPercent || 0,
|
|
72
|
+
trend: agent.trend || 'unknown',
|
|
73
|
+
trendRatePerMinute: agent.trendRatePerMinute || 0,
|
|
74
|
+
alertLevel: agent.alertLevel || 'normal',
|
|
75
|
+
highWatermark: agent.highWatermark || 0,
|
|
76
|
+
averageRss: agent.averageRss || 0,
|
|
77
|
+
};
|
|
78
|
+
await db.insert(agentMetrics).values({
|
|
79
|
+
daemonId: daemon.id,
|
|
80
|
+
agentName: agent.name,
|
|
81
|
+
pid: agent.pid,
|
|
82
|
+
status: agent.status || 'unknown',
|
|
83
|
+
rssBytes: agent.rssBytes,
|
|
84
|
+
heapUsedBytes: agent.heapUsedBytes,
|
|
85
|
+
cpuPercent: Math.round(agent.cpuPercent || 0),
|
|
86
|
+
trend: agent.trend,
|
|
87
|
+
trendRatePerMinute: Math.round(agent.trendRatePerMinute || 0),
|
|
88
|
+
alertLevel: agent.alertLevel,
|
|
89
|
+
highWatermark: agent.highWatermark,
|
|
90
|
+
averageRss: Math.round(agent.averageRss || 0),
|
|
91
|
+
metricsData,
|
|
92
|
+
uptimeMs: agent.uptimeMs,
|
|
93
|
+
startedAt: agent.startedAt ? new Date(agent.startedAt) : null,
|
|
94
|
+
recordedAt: now,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
res.json({ success: true, recorded: agents.length });
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error('Error recording metrics:', error);
|
|
101
|
+
res.status(500).json({ error: 'Failed to record metrics' });
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* POST /api/monitoring/crash
|
|
106
|
+
* Report an agent crash from daemon
|
|
107
|
+
*/
|
|
108
|
+
monitoringRouter.post('/crash', requireDaemonAuth, async (req, res) => {
|
|
109
|
+
const daemon = req.daemon;
|
|
110
|
+
const { crash } = req.body;
|
|
111
|
+
if (!crash || !crash.agentName) {
|
|
112
|
+
return res.status(400).json({ error: 'crash object with agentName is required' });
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const db = getDb();
|
|
116
|
+
const insightData = {
|
|
117
|
+
likelyCause: crash.likelyCause || 'unknown',
|
|
118
|
+
confidence: crash.confidence || 'low',
|
|
119
|
+
summary: crash.summary || '',
|
|
120
|
+
details: crash.details || [],
|
|
121
|
+
recommendations: crash.recommendations || [],
|
|
122
|
+
peakMemory: crash.peakMemory || 0,
|
|
123
|
+
lastKnownMemory: crash.lastKnownMemory || null,
|
|
124
|
+
};
|
|
125
|
+
const [inserted] = await db.insert(agentCrashes).values({
|
|
126
|
+
daemonId: daemon.id,
|
|
127
|
+
agentName: crash.agentName,
|
|
128
|
+
pid: crash.pid,
|
|
129
|
+
exitCode: crash.exitCode,
|
|
130
|
+
signal: crash.signal,
|
|
131
|
+
reason: crash.reason,
|
|
132
|
+
likelyCause: crash.likelyCause,
|
|
133
|
+
confidence: crash.confidence,
|
|
134
|
+
summary: crash.summary,
|
|
135
|
+
peakMemory: crash.peakMemory,
|
|
136
|
+
lastKnownMemory: crash.lastKnownMemory,
|
|
137
|
+
memoryTrend: crash.memoryTrend,
|
|
138
|
+
insightData,
|
|
139
|
+
lastOutput: crash.lastOutput?.slice(0, 10000), // Limit to 10KB
|
|
140
|
+
crashedAt: crash.crashedAt ? new Date(crash.crashedAt) : new Date(),
|
|
141
|
+
}).returning();
|
|
142
|
+
res.json({ success: true, crashId: inserted.id });
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error('Error recording crash:', error);
|
|
146
|
+
res.status(500).json({ error: 'Failed to record crash' });
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
/**
|
|
150
|
+
* POST /api/monitoring/alert
|
|
151
|
+
* Report a memory alert from daemon
|
|
152
|
+
*/
|
|
153
|
+
monitoringRouter.post('/alert', requireDaemonAuth, async (req, res) => {
|
|
154
|
+
const daemon = req.daemon;
|
|
155
|
+
const { alert } = req.body;
|
|
156
|
+
if (!alert || !alert.agentName || !alert.alertType) {
|
|
157
|
+
return res.status(400).json({ error: 'alert object with agentName and alertType is required' });
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const db = getDb();
|
|
161
|
+
const [inserted] = await db.insert(memoryAlerts).values({
|
|
162
|
+
daemonId: daemon.id,
|
|
163
|
+
agentName: alert.agentName,
|
|
164
|
+
alertType: alert.alertType,
|
|
165
|
+
currentRss: alert.currentRss,
|
|
166
|
+
threshold: alert.threshold,
|
|
167
|
+
message: alert.message,
|
|
168
|
+
recommendation: alert.recommendation,
|
|
169
|
+
}).returning();
|
|
170
|
+
res.json({ success: true, alertId: inserted.id });
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error('Error recording alert:', error);
|
|
174
|
+
res.status(500).json({ error: 'Failed to record alert' });
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
// ============================================================================
|
|
178
|
+
// Browser API (authenticated with session)
|
|
179
|
+
// ============================================================================
|
|
180
|
+
/**
|
|
181
|
+
* GET /api/monitoring/overview
|
|
182
|
+
* Get monitoring overview for user's daemons
|
|
183
|
+
*/
|
|
184
|
+
monitoringRouter.get('/overview', requireAuth, async (req, res) => {
|
|
185
|
+
const userId = req.session.userId;
|
|
186
|
+
try {
|
|
187
|
+
const db = getDb();
|
|
188
|
+
// Get all user's daemons
|
|
189
|
+
const daemons = await dbModule.linkedDaemons.findByUserId(userId);
|
|
190
|
+
if (daemons.length === 0) {
|
|
191
|
+
return res.json({
|
|
192
|
+
daemons: [],
|
|
193
|
+
summary: {
|
|
194
|
+
totalAgents: 0,
|
|
195
|
+
healthyAgents: 0,
|
|
196
|
+
warningAgents: 0,
|
|
197
|
+
criticalAgents: 0,
|
|
198
|
+
totalCrashes24h: 0,
|
|
199
|
+
totalAlerts24h: 0,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
const daemonIds = daemons.map(d => d.id);
|
|
204
|
+
const last24h = new Date(Date.now() - 24 * 60 * 60 * 1000);
|
|
205
|
+
// Get latest metrics for each agent (subquery to get latest per agent)
|
|
206
|
+
const latestMetrics = await db
|
|
207
|
+
.select()
|
|
208
|
+
.from(agentMetrics)
|
|
209
|
+
.where(and(sql `${agentMetrics.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, gte(agentMetrics.recordedAt, last24h)))
|
|
210
|
+
.orderBy(desc(agentMetrics.recordedAt))
|
|
211
|
+
.limit(100);
|
|
212
|
+
// Get crash count in last 24h
|
|
213
|
+
const crashCount = await db
|
|
214
|
+
.select({ count: sql `count(*)` })
|
|
215
|
+
.from(agentCrashes)
|
|
216
|
+
.where(and(sql `${agentCrashes.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, gte(agentCrashes.crashedAt, last24h)));
|
|
217
|
+
// Get alert count in last 24h
|
|
218
|
+
const alertCount = await db
|
|
219
|
+
.select({ count: sql `count(*)` })
|
|
220
|
+
.from(memoryAlerts)
|
|
221
|
+
.where(and(sql `${memoryAlerts.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, gte(memoryAlerts.createdAt, last24h)));
|
|
222
|
+
// Aggregate by alert level
|
|
223
|
+
const byAlertLevel = {
|
|
224
|
+
normal: 0,
|
|
225
|
+
warning: 0,
|
|
226
|
+
critical: 0,
|
|
227
|
+
oom_imminent: 0,
|
|
228
|
+
};
|
|
229
|
+
// Deduplicate by agent name (keep latest)
|
|
230
|
+
const agentLatest = new Map();
|
|
231
|
+
for (const m of latestMetrics) {
|
|
232
|
+
const key = `${m.daemonId}:${m.agentName}`;
|
|
233
|
+
if (!agentLatest.has(key)) {
|
|
234
|
+
agentLatest.set(key, m);
|
|
235
|
+
byAlertLevel[m.alertLevel] =
|
|
236
|
+
(byAlertLevel[m.alertLevel] || 0) + 1;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
res.json({
|
|
240
|
+
daemons: daemons.map(d => ({
|
|
241
|
+
id: d.id,
|
|
242
|
+
name: d.name,
|
|
243
|
+
machineId: d.machineId,
|
|
244
|
+
status: d.status,
|
|
245
|
+
lastSeenAt: d.lastSeenAt,
|
|
246
|
+
})),
|
|
247
|
+
summary: {
|
|
248
|
+
totalAgents: agentLatest.size,
|
|
249
|
+
healthyAgents: byAlertLevel.normal,
|
|
250
|
+
warningAgents: byAlertLevel.warning,
|
|
251
|
+
criticalAgents: byAlertLevel.critical + byAlertLevel.oom_imminent,
|
|
252
|
+
totalCrashes24h: Number(crashCount[0]?.count || 0),
|
|
253
|
+
totalAlerts24h: Number(alertCount[0]?.count || 0),
|
|
254
|
+
},
|
|
255
|
+
latestMetrics: Array.from(agentLatest.values()),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
console.error('Error fetching monitoring overview:', error);
|
|
260
|
+
res.status(500).json({ error: 'Failed to fetch monitoring overview' });
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
/**
|
|
264
|
+
* GET /api/monitoring/agents/:agentName/metrics
|
|
265
|
+
* Get detailed metrics history for an agent
|
|
266
|
+
*/
|
|
267
|
+
monitoringRouter.get('/agents/:agentName/metrics', requireAuth, async (req, res) => {
|
|
268
|
+
const userId = req.session.userId;
|
|
269
|
+
const { agentName } = req.params;
|
|
270
|
+
const { daemonId, hours = '24' } = req.query;
|
|
271
|
+
try {
|
|
272
|
+
const db = getDb();
|
|
273
|
+
// Verify daemon belongs to user
|
|
274
|
+
if (daemonId) {
|
|
275
|
+
const daemon = await dbModule.linkedDaemons.findById(daemonId);
|
|
276
|
+
if (!daemon || daemon.userId !== userId) {
|
|
277
|
+
return res.status(404).json({ error: 'Daemon not found' });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const since = new Date(Date.now() - parseInt(hours) * 60 * 60 * 1000);
|
|
281
|
+
// Get user's daemons
|
|
282
|
+
const daemons = await dbModule.linkedDaemons.findByUserId(userId);
|
|
283
|
+
const daemonIds = daemonId ? [daemonId] : daemons.map(d => d.id);
|
|
284
|
+
const metrics = await db
|
|
285
|
+
.select()
|
|
286
|
+
.from(agentMetrics)
|
|
287
|
+
.where(and(sql `${agentMetrics.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, eq(agentMetrics.agentName, agentName), gte(agentMetrics.recordedAt, since)))
|
|
288
|
+
.orderBy(desc(agentMetrics.recordedAt))
|
|
289
|
+
.limit(1000);
|
|
290
|
+
// Calculate statistics
|
|
291
|
+
const rssSamples = metrics.map(m => Number(m.rssBytes || 0));
|
|
292
|
+
const stats = {
|
|
293
|
+
count: metrics.length,
|
|
294
|
+
avgRss: rssSamples.length > 0 ? rssSamples.reduce((a, b) => a + b, 0) / rssSamples.length : 0,
|
|
295
|
+
maxRss: rssSamples.length > 0 ? Math.max(...rssSamples) : 0,
|
|
296
|
+
minRss: rssSamples.length > 0 ? Math.min(...rssSamples) : 0,
|
|
297
|
+
latestTrend: metrics[0]?.trend || 'unknown',
|
|
298
|
+
latestAlertLevel: metrics[0]?.alertLevel || 'normal',
|
|
299
|
+
};
|
|
300
|
+
res.json({
|
|
301
|
+
agentName,
|
|
302
|
+
metrics,
|
|
303
|
+
stats,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
console.error('Error fetching agent metrics:', error);
|
|
308
|
+
res.status(500).json({ error: 'Failed to fetch agent metrics' });
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
/**
|
|
312
|
+
* GET /api/monitoring/crashes
|
|
313
|
+
* Get crash history
|
|
314
|
+
*/
|
|
315
|
+
monitoringRouter.get('/crashes', requireAuth, async (req, res) => {
|
|
316
|
+
const userId = req.session.userId;
|
|
317
|
+
const { daemonId, agentName, limit = '50' } = req.query;
|
|
318
|
+
try {
|
|
319
|
+
const db = getDb();
|
|
320
|
+
// Get user's daemons
|
|
321
|
+
const daemons = await dbModule.linkedDaemons.findByUserId(userId);
|
|
322
|
+
const daemonIds = daemonId ? [daemonId] : daemons.map(d => d.id);
|
|
323
|
+
let query = db
|
|
324
|
+
.select()
|
|
325
|
+
.from(agentCrashes)
|
|
326
|
+
.where(sql `${agentCrashes.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`);
|
|
327
|
+
if (agentName) {
|
|
328
|
+
query = db
|
|
329
|
+
.select()
|
|
330
|
+
.from(agentCrashes)
|
|
331
|
+
.where(and(sql `${agentCrashes.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, eq(agentCrashes.agentName, agentName)));
|
|
332
|
+
}
|
|
333
|
+
const crashes = await query
|
|
334
|
+
.orderBy(desc(agentCrashes.crashedAt))
|
|
335
|
+
.limit(parseInt(limit));
|
|
336
|
+
// Get crash statistics by cause
|
|
337
|
+
const byCause = {};
|
|
338
|
+
for (const crash of crashes) {
|
|
339
|
+
const cause = crash.likelyCause || 'unknown';
|
|
340
|
+
byCause[cause] = (byCause[cause] || 0) + 1;
|
|
341
|
+
}
|
|
342
|
+
res.json({
|
|
343
|
+
crashes,
|
|
344
|
+
stats: {
|
|
345
|
+
total: crashes.length,
|
|
346
|
+
byCause,
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
console.error('Error fetching crashes:', error);
|
|
352
|
+
res.status(500).json({ error: 'Failed to fetch crashes' });
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
/**
|
|
356
|
+
* GET /api/monitoring/crashes/:id
|
|
357
|
+
* Get detailed crash information
|
|
358
|
+
*/
|
|
359
|
+
monitoringRouter.get('/crashes/:id', requireAuth, async (req, res) => {
|
|
360
|
+
const userId = req.session.userId;
|
|
361
|
+
const { id } = req.params;
|
|
362
|
+
try {
|
|
363
|
+
const db = getDb();
|
|
364
|
+
const [crash] = await db
|
|
365
|
+
.select()
|
|
366
|
+
.from(agentCrashes)
|
|
367
|
+
.where(eq(agentCrashes.id, id))
|
|
368
|
+
.limit(1);
|
|
369
|
+
if (!crash) {
|
|
370
|
+
return res.status(404).json({ error: 'Crash not found' });
|
|
371
|
+
}
|
|
372
|
+
// Verify user owns this daemon
|
|
373
|
+
const daemon = await dbModule.linkedDaemons.findById(crash.daemonId);
|
|
374
|
+
if (!daemon || daemon.userId !== userId) {
|
|
375
|
+
return res.status(404).json({ error: 'Crash not found' });
|
|
376
|
+
}
|
|
377
|
+
res.json({ crash, daemon: { id: daemon.id, name: daemon.name } });
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
console.error('Error fetching crash:', error);
|
|
381
|
+
res.status(500).json({ error: 'Failed to fetch crash' });
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
/**
|
|
385
|
+
* GET /api/monitoring/alerts
|
|
386
|
+
* Get memory alerts
|
|
387
|
+
*/
|
|
388
|
+
monitoringRouter.get('/alerts', requireAuth, async (req, res) => {
|
|
389
|
+
const userId = req.session.userId;
|
|
390
|
+
const { daemonId, acknowledged, limit = '100' } = req.query;
|
|
391
|
+
try {
|
|
392
|
+
const db = getDb();
|
|
393
|
+
// Get user's daemons
|
|
394
|
+
const daemons = await dbModule.linkedDaemons.findByUserId(userId);
|
|
395
|
+
const daemonIds = daemonId ? [daemonId] : daemons.map(d => d.id);
|
|
396
|
+
const whereConditions = [
|
|
397
|
+
sql `${memoryAlerts.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`
|
|
398
|
+
];
|
|
399
|
+
if (acknowledged !== undefined) {
|
|
400
|
+
whereConditions.push(eq(memoryAlerts.acknowledged, acknowledged === 'true'));
|
|
401
|
+
}
|
|
402
|
+
const alerts = await db
|
|
403
|
+
.select()
|
|
404
|
+
.from(memoryAlerts)
|
|
405
|
+
.where(and(...whereConditions))
|
|
406
|
+
.orderBy(desc(memoryAlerts.createdAt))
|
|
407
|
+
.limit(parseInt(limit));
|
|
408
|
+
// Count unacknowledged
|
|
409
|
+
const unacknowledgedCount = await db
|
|
410
|
+
.select({ count: sql `count(*)` })
|
|
411
|
+
.from(memoryAlerts)
|
|
412
|
+
.where(and(sql `${memoryAlerts.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, eq(memoryAlerts.acknowledged, false)));
|
|
413
|
+
res.json({
|
|
414
|
+
alerts,
|
|
415
|
+
unacknowledgedCount: Number(unacknowledgedCount[0]?.count || 0),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
console.error('Error fetching alerts:', error);
|
|
420
|
+
res.status(500).json({ error: 'Failed to fetch alerts' });
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
/**
|
|
424
|
+
* POST /api/monitoring/alerts/:id/acknowledge
|
|
425
|
+
* Acknowledge an alert
|
|
426
|
+
*/
|
|
427
|
+
monitoringRouter.post('/alerts/:id/acknowledge', requireAuth, async (req, res) => {
|
|
428
|
+
const userId = req.session.userId;
|
|
429
|
+
const { id } = req.params;
|
|
430
|
+
try {
|
|
431
|
+
const db = getDb();
|
|
432
|
+
// Get the alert
|
|
433
|
+
const [alert] = await db
|
|
434
|
+
.select()
|
|
435
|
+
.from(memoryAlerts)
|
|
436
|
+
.where(eq(memoryAlerts.id, id))
|
|
437
|
+
.limit(1);
|
|
438
|
+
if (!alert) {
|
|
439
|
+
return res.status(404).json({ error: 'Alert not found' });
|
|
440
|
+
}
|
|
441
|
+
// Verify user owns this daemon
|
|
442
|
+
const daemon = await dbModule.linkedDaemons.findById(alert.daemonId);
|
|
443
|
+
if (!daemon || daemon.userId !== userId) {
|
|
444
|
+
return res.status(404).json({ error: 'Alert not found' });
|
|
445
|
+
}
|
|
446
|
+
// Update alert
|
|
447
|
+
await db
|
|
448
|
+
.update(memoryAlerts)
|
|
449
|
+
.set({
|
|
450
|
+
acknowledged: true,
|
|
451
|
+
acknowledgedAt: new Date(),
|
|
452
|
+
})
|
|
453
|
+
.where(eq(memoryAlerts.id, id));
|
|
454
|
+
res.json({ success: true });
|
|
455
|
+
}
|
|
456
|
+
catch (error) {
|
|
457
|
+
console.error('Error acknowledging alert:', error);
|
|
458
|
+
res.status(500).json({ error: 'Failed to acknowledge alert' });
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
/**
|
|
462
|
+
* GET /api/monitoring/insights
|
|
463
|
+
* Get overall system insights and recommendations
|
|
464
|
+
*/
|
|
465
|
+
monitoringRouter.get('/insights', requireAuth, async (req, res) => {
|
|
466
|
+
const userId = req.session.userId;
|
|
467
|
+
try {
|
|
468
|
+
const db = getDb();
|
|
469
|
+
// Get user's daemons
|
|
470
|
+
const daemons = await dbModule.linkedDaemons.findByUserId(userId);
|
|
471
|
+
if (daemons.length === 0) {
|
|
472
|
+
return res.json({
|
|
473
|
+
healthScore: 100,
|
|
474
|
+
summary: 'No daemons connected. Link a daemon to start monitoring.',
|
|
475
|
+
issues: [],
|
|
476
|
+
recommendations: ['Connect a local daemon using `agent-relay cloud link`'],
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
const daemonIds = daemons.map(d => d.id);
|
|
480
|
+
const last24h = new Date(Date.now() - 24 * 60 * 60 * 1000);
|
|
481
|
+
const last7d = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
482
|
+
// Get crash stats
|
|
483
|
+
const crashes24h = await db
|
|
484
|
+
.select()
|
|
485
|
+
.from(agentCrashes)
|
|
486
|
+
.where(and(sql `${agentCrashes.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, gte(agentCrashes.crashedAt, last24h)));
|
|
487
|
+
const crashes7d = await db
|
|
488
|
+
.select()
|
|
489
|
+
.from(agentCrashes)
|
|
490
|
+
.where(and(sql `${agentCrashes.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, gte(agentCrashes.crashedAt, last7d)));
|
|
491
|
+
// Get unacknowledged alerts
|
|
492
|
+
const pendingAlerts = await db
|
|
493
|
+
.select()
|
|
494
|
+
.from(memoryAlerts)
|
|
495
|
+
.where(and(sql `${memoryAlerts.daemonId} IN (${sql.join(daemonIds.map(id => sql `${id}`), sql `, `)})`, eq(memoryAlerts.acknowledged, false)))
|
|
496
|
+
.limit(10);
|
|
497
|
+
// Calculate health score
|
|
498
|
+
let healthScore = 100;
|
|
499
|
+
const issues = [];
|
|
500
|
+
const recommendations = [];
|
|
501
|
+
// Deduct for OOM crashes
|
|
502
|
+
const oomCrashes = crashes24h.filter(c => c.likelyCause === 'oom').length;
|
|
503
|
+
if (oomCrashes > 0) {
|
|
504
|
+
healthScore -= oomCrashes * 15;
|
|
505
|
+
issues.push({
|
|
506
|
+
severity: 'critical',
|
|
507
|
+
message: `${oomCrashes} out-of-memory crash${oomCrashes > 1 ? 'es' : ''} in last 24 hours`,
|
|
508
|
+
});
|
|
509
|
+
recommendations.push('Increase memory limits or optimize agent memory usage');
|
|
510
|
+
}
|
|
511
|
+
// Deduct for memory leak crashes
|
|
512
|
+
const leakCrashes = crashes24h.filter(c => c.likelyCause === 'memory_leak').length;
|
|
513
|
+
if (leakCrashes > 0) {
|
|
514
|
+
healthScore -= leakCrashes * 10;
|
|
515
|
+
issues.push({
|
|
516
|
+
severity: 'high',
|
|
517
|
+
message: `${leakCrashes} likely memory leak crash${leakCrashes > 1 ? 'es' : ''} detected`,
|
|
518
|
+
});
|
|
519
|
+
recommendations.push('Investigate agents for memory leaks');
|
|
520
|
+
}
|
|
521
|
+
// Deduct for other crashes
|
|
522
|
+
const otherCrashes = crashes24h.length - oomCrashes - leakCrashes;
|
|
523
|
+
if (otherCrashes > 0) {
|
|
524
|
+
healthScore -= otherCrashes * 5;
|
|
525
|
+
issues.push({
|
|
526
|
+
severity: 'medium',
|
|
527
|
+
message: `${otherCrashes} other crash${otherCrashes > 1 ? 'es' : ''} in last 24 hours`,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
// Deduct for pending critical alerts
|
|
531
|
+
const criticalAlerts = pendingAlerts.filter(a => a.alertType === 'critical' || a.alertType === 'oom_imminent').length;
|
|
532
|
+
if (criticalAlerts > 0) {
|
|
533
|
+
healthScore -= criticalAlerts * 8;
|
|
534
|
+
issues.push({
|
|
535
|
+
severity: 'high',
|
|
536
|
+
message: `${criticalAlerts} unacknowledged critical alert${criticalAlerts > 1 ? 's' : ''}`,
|
|
537
|
+
});
|
|
538
|
+
recommendations.push('Review and acknowledge pending alerts');
|
|
539
|
+
}
|
|
540
|
+
// Clamp health score
|
|
541
|
+
healthScore = Math.max(0, Math.min(100, healthScore));
|
|
542
|
+
// Generate summary
|
|
543
|
+
let summary;
|
|
544
|
+
if (healthScore >= 90) {
|
|
545
|
+
summary = 'System is healthy. All agents operating normally.';
|
|
546
|
+
}
|
|
547
|
+
else if (healthScore >= 70) {
|
|
548
|
+
summary = 'Some issues detected. Review warnings and recommendations.';
|
|
549
|
+
}
|
|
550
|
+
else if (healthScore >= 50) {
|
|
551
|
+
summary = 'Multiple issues detected. Action recommended.';
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
summary = 'Critical issues detected. Immediate action required.';
|
|
555
|
+
}
|
|
556
|
+
res.json({
|
|
557
|
+
healthScore,
|
|
558
|
+
summary,
|
|
559
|
+
issues: issues.sort((a, b) => {
|
|
560
|
+
const order = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
561
|
+
return (order[a.severity] || 4) - (order[b.severity] || 4);
|
|
562
|
+
}),
|
|
563
|
+
recommendations,
|
|
564
|
+
stats: {
|
|
565
|
+
crashes24h: crashes24h.length,
|
|
566
|
+
crashes7d: crashes7d.length,
|
|
567
|
+
pendingAlerts: pendingAlerts.length,
|
|
568
|
+
connectedDaemons: daemons.filter(d => d.status === 'online').length,
|
|
569
|
+
totalDaemons: daemons.length,
|
|
570
|
+
},
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
console.error('Error fetching insights:', error);
|
|
575
|
+
res.status(500).json({ error: 'Failed to fetch insights' });
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
//# sourceMappingURL=monitoring.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nango Auth API Routes
|
|
3
|
+
*
|
|
4
|
+
* Handles GitHub OAuth via Nango with two-connection pattern:
|
|
5
|
+
* - github: User login (identity)
|
|
6
|
+
* - github-app-oauth: Repository access
|
|
7
|
+
*/
|
|
8
|
+
export declare const nangoAuthRouter: import("express-serve-static-core").Router;
|
|
9
|
+
//# sourceMappingURL=nango-auth.d.ts.map
|