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,834 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory Integration Module
|
|
3
|
+
*
|
|
4
|
+
* Integrates with the agent-trajectories package to provide
|
|
5
|
+
* PDERO paradigm tracking within agent-relay.
|
|
6
|
+
*
|
|
7
|
+
* This module provides a bridge between agent-relay and the
|
|
8
|
+
* external `trail` CLI / agent-trajectories library.
|
|
9
|
+
*
|
|
10
|
+
* Key integration points:
|
|
11
|
+
* - Auto-starts trajectory when agent is instantiated with a task
|
|
12
|
+
* - Records all inter-agent messages
|
|
13
|
+
* - Auto-detects PDERO phase transitions from output
|
|
14
|
+
* - Provides hooks for key agent lifecycle events
|
|
15
|
+
*/
|
|
16
|
+
import { spawn, execSync } from 'node:child_process';
|
|
17
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { getProjectPaths } from '../utils/project-namespace.js';
|
|
20
|
+
import { getPrimaryTrajectoriesDir, getAllTrajectoriesDirs, getTrajectoryEnvVars, } from './config.js';
|
|
21
|
+
/**
|
|
22
|
+
* Read a single trajectory index file from a directory
|
|
23
|
+
*/
|
|
24
|
+
function readSingleTrajectoryIndex(trajectoriesDir) {
|
|
25
|
+
try {
|
|
26
|
+
const indexPath = join(trajectoriesDir, 'index.json');
|
|
27
|
+
if (!existsSync(indexPath)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const content = readFileSync(indexPath, 'utf-8');
|
|
31
|
+
return JSON.parse(content);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read and merge trajectory indexes from all locations (repo + user-level)
|
|
39
|
+
* This allows reading trajectories from both places
|
|
40
|
+
*/
|
|
41
|
+
function readTrajectoryIndex() {
|
|
42
|
+
const dirs = getAllTrajectoriesDirs();
|
|
43
|
+
if (dirs.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
// Read and merge all indexes
|
|
47
|
+
let mergedIndex = null;
|
|
48
|
+
for (const dir of dirs) {
|
|
49
|
+
const index = readSingleTrajectoryIndex(dir);
|
|
50
|
+
if (!index)
|
|
51
|
+
continue;
|
|
52
|
+
if (!mergedIndex) {
|
|
53
|
+
mergedIndex = index;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Merge trajectories, preferring more recent entries
|
|
57
|
+
for (const [id, entry] of Object.entries(index.trajectories)) {
|
|
58
|
+
const existing = mergedIndex.trajectories[id];
|
|
59
|
+
if (!existing) {
|
|
60
|
+
mergedIndex.trajectories[id] = entry;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// Keep the more recently updated one
|
|
64
|
+
const existingTime = new Date(existing.completedAt || existing.startedAt).getTime();
|
|
65
|
+
const newTime = new Date(entry.completedAt || entry.startedAt).getTime();
|
|
66
|
+
if (newTime > existingTime) {
|
|
67
|
+
mergedIndex.trajectories[id] = entry;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Update lastUpdated to most recent
|
|
72
|
+
if (new Date(index.lastUpdated) > new Date(mergedIndex.lastUpdated)) {
|
|
73
|
+
mergedIndex.lastUpdated = index.lastUpdated;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return mergedIndex;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Read a specific trajectory file directly from filesystem
|
|
81
|
+
*/
|
|
82
|
+
function readTrajectoryFile(trajectoryPath) {
|
|
83
|
+
try {
|
|
84
|
+
if (!existsSync(trajectoryPath)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const content = readFileSync(trajectoryPath, 'utf-8');
|
|
88
|
+
return JSON.parse(content);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Run a trail CLI command
|
|
96
|
+
* Uses config-based environment to control trajectory storage location
|
|
97
|
+
*/
|
|
98
|
+
async function runTrail(args) {
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
// Get trajectory env vars to set correct storage location
|
|
101
|
+
const trajectoryEnv = getTrajectoryEnvVars();
|
|
102
|
+
const proc = spawn('trail', args, {
|
|
103
|
+
cwd: getProjectPaths().projectRoot,
|
|
104
|
+
env: { ...process.env, ...trajectoryEnv },
|
|
105
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
106
|
+
});
|
|
107
|
+
let stdout = '';
|
|
108
|
+
let stderr = '';
|
|
109
|
+
proc.stdout?.on('data', (data) => {
|
|
110
|
+
stdout += data.toString();
|
|
111
|
+
});
|
|
112
|
+
proc.stderr?.on('data', (data) => {
|
|
113
|
+
stderr += data.toString();
|
|
114
|
+
});
|
|
115
|
+
proc.on('error', (err) => {
|
|
116
|
+
resolve({ success: false, output: '', error: `Failed to run trail: ${err.message}` });
|
|
117
|
+
});
|
|
118
|
+
proc.on('close', (code) => {
|
|
119
|
+
if (code === 0) {
|
|
120
|
+
resolve({ success: true, output: stdout.trim() });
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
resolve({ success: false, output: stdout.trim(), error: stderr.trim() || `Exit code: ${code}` });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check if trail CLI is available
|
|
130
|
+
*/
|
|
131
|
+
export async function isTrailAvailable() {
|
|
132
|
+
const result = await runTrail(['--version']);
|
|
133
|
+
return result.success;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Start a new trajectory
|
|
137
|
+
*/
|
|
138
|
+
export async function startTrajectory(options) {
|
|
139
|
+
const args = ['start', options.task];
|
|
140
|
+
if (options.taskId) {
|
|
141
|
+
args.push('--task-id', options.taskId);
|
|
142
|
+
}
|
|
143
|
+
if (options.source) {
|
|
144
|
+
args.push('--source', options.source);
|
|
145
|
+
}
|
|
146
|
+
if (options.agentName) {
|
|
147
|
+
args.push('--agent', options.agentName);
|
|
148
|
+
}
|
|
149
|
+
if (options.phase) {
|
|
150
|
+
args.push('--phase', options.phase);
|
|
151
|
+
}
|
|
152
|
+
const result = await runTrail(args);
|
|
153
|
+
if (result.success) {
|
|
154
|
+
// Parse trajectory ID from output like "✓ Trajectory started: traj_xxx"
|
|
155
|
+
const match = result.output.match(/traj_[a-z0-9]+/i);
|
|
156
|
+
return { success: true, trajectoryId: match?.[0] };
|
|
157
|
+
}
|
|
158
|
+
return { success: false, error: result.error };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get current trajectory status
|
|
162
|
+
* Reads directly from .trajectories/index.json instead of using CLI
|
|
163
|
+
*/
|
|
164
|
+
export async function getTrajectoryStatus() {
|
|
165
|
+
const index = readTrajectoryIndex();
|
|
166
|
+
if (!index) {
|
|
167
|
+
return { active: false };
|
|
168
|
+
}
|
|
169
|
+
// Find an active trajectory
|
|
170
|
+
for (const [id, entry] of Object.entries(index.trajectories)) {
|
|
171
|
+
if (entry.status === 'active') {
|
|
172
|
+
// Read the full trajectory file to get phase info
|
|
173
|
+
const trajectory = readTrajectoryFile(entry.path);
|
|
174
|
+
let currentPhase;
|
|
175
|
+
if (trajectory?.chapters?.length) {
|
|
176
|
+
const lastChapter = trajectory.chapters[trajectory.chapters.length - 1];
|
|
177
|
+
// Check events for phase transitions
|
|
178
|
+
for (const event of [...(lastChapter.events || [])].reverse()) {
|
|
179
|
+
if (event.type === 'phase_transition' || event.type === 'phase') {
|
|
180
|
+
const phaseMatch = event.content?.match(/phase[:\s]+(\w+)/i);
|
|
181
|
+
if (phaseMatch) {
|
|
182
|
+
currentPhase = phaseMatch[1].toLowerCase();
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
active: true,
|
|
190
|
+
trajectoryId: id,
|
|
191
|
+
phase: currentPhase,
|
|
192
|
+
task: entry.title,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return { active: false };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Transition to a new PDERO phase
|
|
200
|
+
*/
|
|
201
|
+
export async function transitionPhase(phase, reason, agentName) {
|
|
202
|
+
const args = ['phase', phase];
|
|
203
|
+
if (reason) {
|
|
204
|
+
args.push('--reason', reason);
|
|
205
|
+
}
|
|
206
|
+
if (agentName) {
|
|
207
|
+
args.push('--agent', agentName);
|
|
208
|
+
}
|
|
209
|
+
const result = await runTrail(args);
|
|
210
|
+
return { success: result.success, error: result.error };
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Record a decision
|
|
214
|
+
*/
|
|
215
|
+
export async function recordDecision(options) {
|
|
216
|
+
const args = ['decision', options.choice];
|
|
217
|
+
if (options.question) {
|
|
218
|
+
args.push('--question', options.question);
|
|
219
|
+
}
|
|
220
|
+
if (options.alternatives && options.alternatives.length > 0) {
|
|
221
|
+
args.push('--alternatives', options.alternatives.join(','));
|
|
222
|
+
}
|
|
223
|
+
if (options.reasoning) {
|
|
224
|
+
args.push('--reasoning', options.reasoning);
|
|
225
|
+
}
|
|
226
|
+
if (options.confidence !== undefined) {
|
|
227
|
+
args.push('--confidence', options.confidence.toString());
|
|
228
|
+
}
|
|
229
|
+
const result = await runTrail(args);
|
|
230
|
+
return { success: result.success, error: result.error };
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Record an event/observation
|
|
234
|
+
*/
|
|
235
|
+
export async function recordEvent(content, type = 'observation', agentName) {
|
|
236
|
+
const args = ['event', content, '--type', type];
|
|
237
|
+
if (agentName) {
|
|
238
|
+
args.push('--agent', agentName);
|
|
239
|
+
}
|
|
240
|
+
const result = await runTrail(args);
|
|
241
|
+
return { success: result.success, error: result.error };
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Record a message (sent or received)
|
|
245
|
+
*/
|
|
246
|
+
export async function recordMessage(direction, from, to, body) {
|
|
247
|
+
const content = `Message ${direction}: ${direction === 'sent' ? `→ ${to}` : `← ${from}`}: ${body.slice(0, 100)}${body.length > 100 ? '...' : ''}`;
|
|
248
|
+
return recordEvent(content, 'observation');
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Complete the current trajectory
|
|
252
|
+
*/
|
|
253
|
+
export async function completeTrajectory(options = {}) {
|
|
254
|
+
const args = ['complete'];
|
|
255
|
+
if (options.summary) {
|
|
256
|
+
args.push('--summary', options.summary);
|
|
257
|
+
}
|
|
258
|
+
if (options.confidence !== undefined) {
|
|
259
|
+
args.push('--confidence', options.confidence.toString());
|
|
260
|
+
}
|
|
261
|
+
if (options.challenges && options.challenges.length > 0) {
|
|
262
|
+
args.push('--challenges', options.challenges.join(','));
|
|
263
|
+
}
|
|
264
|
+
if (options.learnings && options.learnings.length > 0) {
|
|
265
|
+
args.push('--learnings', options.learnings.join(','));
|
|
266
|
+
}
|
|
267
|
+
const result = await runTrail(args);
|
|
268
|
+
return { success: result.success, error: result.error };
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Abandon the current trajectory
|
|
272
|
+
*/
|
|
273
|
+
export async function abandonTrajectory(reason) {
|
|
274
|
+
const args = ['abandon'];
|
|
275
|
+
if (reason) {
|
|
276
|
+
args.push('--reason', reason);
|
|
277
|
+
}
|
|
278
|
+
const result = await runTrail(args);
|
|
279
|
+
return { success: result.success, error: result.error };
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* List trajectory steps/events
|
|
283
|
+
* Returns steps for the current or specified trajectory
|
|
284
|
+
* Reads directly from filesystem instead of using CLI
|
|
285
|
+
*/
|
|
286
|
+
export async function listTrajectorySteps(trajectoryId) {
|
|
287
|
+
const index = readTrajectoryIndex();
|
|
288
|
+
if (!index) {
|
|
289
|
+
return { success: true, steps: [] };
|
|
290
|
+
}
|
|
291
|
+
// Find the trajectory to load
|
|
292
|
+
let trajectoryPath;
|
|
293
|
+
if (trajectoryId) {
|
|
294
|
+
// Use specified trajectory
|
|
295
|
+
const entry = index.trajectories[trajectoryId];
|
|
296
|
+
if (entry) {
|
|
297
|
+
trajectoryPath = entry.path;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
// Find active trajectory
|
|
302
|
+
for (const [_id, entry] of Object.entries(index.trajectories)) {
|
|
303
|
+
if (entry.status === 'active') {
|
|
304
|
+
trajectoryPath = entry.path;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (!trajectoryPath) {
|
|
310
|
+
return { success: true, steps: [] };
|
|
311
|
+
}
|
|
312
|
+
const trajectory = readTrajectoryFile(trajectoryPath);
|
|
313
|
+
if (!trajectory) {
|
|
314
|
+
return { success: true, steps: [] };
|
|
315
|
+
}
|
|
316
|
+
// Extract events from all chapters
|
|
317
|
+
const steps = [];
|
|
318
|
+
let stepIndex = 0;
|
|
319
|
+
for (const chapter of trajectory.chapters || []) {
|
|
320
|
+
for (const event of chapter.events || []) {
|
|
321
|
+
steps.push({
|
|
322
|
+
id: `step-${stepIndex++}`,
|
|
323
|
+
timestamp: event.ts || Date.now(),
|
|
324
|
+
type: mapEventType(event.type),
|
|
325
|
+
title: event.content?.slice(0, 50) || event.type || 'Event',
|
|
326
|
+
description: event.content,
|
|
327
|
+
metadata: event.raw,
|
|
328
|
+
status: mapEventStatus(trajectory.status),
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return { success: true, steps };
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Get trajectory history - list all trajectories
|
|
336
|
+
* Reads directly from filesystem
|
|
337
|
+
*/
|
|
338
|
+
export async function getTrajectoryHistory() {
|
|
339
|
+
const index = readTrajectoryIndex();
|
|
340
|
+
if (!index) {
|
|
341
|
+
return { success: true, trajectories: [] };
|
|
342
|
+
}
|
|
343
|
+
const trajectories = [];
|
|
344
|
+
for (const [id, entry] of Object.entries(index.trajectories)) {
|
|
345
|
+
const historyEntry = {
|
|
346
|
+
id,
|
|
347
|
+
title: entry.title,
|
|
348
|
+
status: entry.status,
|
|
349
|
+
startedAt: entry.startedAt,
|
|
350
|
+
completedAt: entry.completedAt,
|
|
351
|
+
};
|
|
352
|
+
// Try to read full trajectory for additional details
|
|
353
|
+
if (entry.path) {
|
|
354
|
+
const trajectory = readTrajectoryFile(entry.path);
|
|
355
|
+
if (trajectory) {
|
|
356
|
+
historyEntry.agents = trajectory.agents?.map(a => a.name);
|
|
357
|
+
if (trajectory.retrospective) {
|
|
358
|
+
historyEntry.summary = trajectory.retrospective.summary;
|
|
359
|
+
historyEntry.confidence = trajectory.retrospective.confidence;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
trajectories.push(historyEntry);
|
|
364
|
+
}
|
|
365
|
+
// Sort by startedAt descending (most recent first)
|
|
366
|
+
trajectories.sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime());
|
|
367
|
+
return { success: true, trajectories };
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Map trail event type to dashboard type
|
|
371
|
+
*/
|
|
372
|
+
function mapEventType(type) {
|
|
373
|
+
switch (type?.toLowerCase()) {
|
|
374
|
+
case 'tool':
|
|
375
|
+
case 'tool_call':
|
|
376
|
+
case 'tool_use':
|
|
377
|
+
return 'tool_call';
|
|
378
|
+
case 'decision':
|
|
379
|
+
case 'choice':
|
|
380
|
+
return 'decision';
|
|
381
|
+
case 'message':
|
|
382
|
+
case 'observation':
|
|
383
|
+
return 'message';
|
|
384
|
+
case 'phase':
|
|
385
|
+
case 'phase_change':
|
|
386
|
+
case 'phase_transition':
|
|
387
|
+
return 'phase_transition';
|
|
388
|
+
case 'error':
|
|
389
|
+
case 'failure':
|
|
390
|
+
return 'error';
|
|
391
|
+
default:
|
|
392
|
+
return 'state_change';
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Map trail status to dashboard status
|
|
397
|
+
*/
|
|
398
|
+
function mapEventStatus(status) {
|
|
399
|
+
switch (status?.toLowerCase()) {
|
|
400
|
+
case 'running':
|
|
401
|
+
case 'in_progress':
|
|
402
|
+
case 'active':
|
|
403
|
+
return 'running';
|
|
404
|
+
case 'success':
|
|
405
|
+
case 'completed':
|
|
406
|
+
case 'done':
|
|
407
|
+
return 'success';
|
|
408
|
+
case 'error':
|
|
409
|
+
case 'failed':
|
|
410
|
+
case 'abandoned':
|
|
411
|
+
return 'error';
|
|
412
|
+
case 'pending':
|
|
413
|
+
case 'queued':
|
|
414
|
+
return 'pending';
|
|
415
|
+
default:
|
|
416
|
+
return undefined;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Detect PDERO phase from content
|
|
421
|
+
*/
|
|
422
|
+
export function detectPhaseFromContent(content) {
|
|
423
|
+
const lowerContent = content.toLowerCase();
|
|
424
|
+
const phasePatterns = [
|
|
425
|
+
{ phase: 'plan', patterns: ['planning', 'analyzing requirements', 'breaking down', 'creating plan', 'task list', 'todo', 'outline'] },
|
|
426
|
+
{ phase: 'design', patterns: ['designing', 'architecting', 'choosing pattern', 'interface design', 'schema design', 'architecture'] },
|
|
427
|
+
{ phase: 'execute', patterns: ['implementing', 'writing', 'coding', 'building', 'creating file', 'modifying', 'editing'] },
|
|
428
|
+
{ phase: 'review', patterns: ['testing', 'reviewing', 'validating', 'checking', 'verifying', 'running tests', 'test passed', 'test failed'] },
|
|
429
|
+
{ phase: 'observe', patterns: ['observing', 'monitoring', 'reflecting', 'documenting', 'retrospective', 'learnings', 'summary'] },
|
|
430
|
+
];
|
|
431
|
+
for (const { phase, patterns } of phasePatterns) {
|
|
432
|
+
for (const pattern of patterns) {
|
|
433
|
+
if (lowerContent.includes(pattern)) {
|
|
434
|
+
return phase;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return undefined;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* All known Claude Code tool names
|
|
442
|
+
*/
|
|
443
|
+
const TOOL_NAMES = [
|
|
444
|
+
'Read', 'Write', 'Edit', 'Bash', 'Glob', 'Grep', 'Task', 'TaskOutput',
|
|
445
|
+
'WebFetch', 'WebSearch', 'NotebookEdit', 'TodoWrite', 'AskUserQuestion',
|
|
446
|
+
'KillShell', 'EnterPlanMode', 'ExitPlanMode', 'Skill', 'SlashCommand',
|
|
447
|
+
];
|
|
448
|
+
const TOOL_NAME_PATTERN = TOOL_NAMES.join('|');
|
|
449
|
+
/**
|
|
450
|
+
* Tool call patterns for Claude Code and similar AI CLIs
|
|
451
|
+
*/
|
|
452
|
+
const TOOL_PATTERNS = [
|
|
453
|
+
// Claude Code tool invocations (displayed in output with parenthesis/braces)
|
|
454
|
+
new RegExp(`(?:^|\\n)\\s*(?:${TOOL_NAME_PATTERN})\\s*[({]`, 'i'),
|
|
455
|
+
// Tool completion markers (checkmarks, spinners)
|
|
456
|
+
new RegExp(`(?:^|\\n)\\s*(?:✓|✔|⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏)\\s*(${TOOL_NAME_PATTERN})`, 'i'),
|
|
457
|
+
// Function call patterns (explicit mentions)
|
|
458
|
+
new RegExp(`(?:^|\\n)\\s*(?:Calling|Using|Invoking)\\s+(?:tool\\s+)?['"]?(${TOOL_NAME_PATTERN})['"]?`, 'i'),
|
|
459
|
+
// Tool result patterns
|
|
460
|
+
new RegExp(`(?:^|\\n)\\s*(?:Tool result|Result from)\\s*:?\\s*(${TOOL_NAME_PATTERN})`, 'i'),
|
|
461
|
+
];
|
|
462
|
+
/**
|
|
463
|
+
* Error patterns for detecting failures in output
|
|
464
|
+
* Note: Patterns are ordered from most specific to least specific
|
|
465
|
+
*/
|
|
466
|
+
const ERROR_PATTERNS = [
|
|
467
|
+
// JavaScript/TypeScript runtime errors (most specific)
|
|
468
|
+
/(?:^|\n)((?:TypeError|ReferenceError|SyntaxError|RangeError|EvalError|URIError):\s*.+)/i,
|
|
469
|
+
// Named Error with message (e.g., "Error: Something went wrong")
|
|
470
|
+
/(?:^|\n)(Error:\s+.+)/,
|
|
471
|
+
// Failed assertions
|
|
472
|
+
/(?:^|\n)\s*(AssertionError:\s*.+)/i,
|
|
473
|
+
// Test failures (Vitest, Jest patterns)
|
|
474
|
+
/(?:^|\n)\s*(FAIL\s+\S+\.(?:ts|js|tsx|jsx))/i,
|
|
475
|
+
/(?:^|\n)\s*(✗|✘|×)\s+(.+)/,
|
|
476
|
+
// Command/process failures
|
|
477
|
+
/(?:^|\n)\s*(Command failed[^\n]+)/i,
|
|
478
|
+
/(?:^|\n)\s*((?:Exit|exit)\s+code[:\s]+[1-9]\d*)/i,
|
|
479
|
+
/(?:^|\n)\s*(exited with (?:code\s+)?[1-9]\d*)/i,
|
|
480
|
+
// Node.js/system errors
|
|
481
|
+
/(?:^|\n)\s*(EACCES|EPERM|ENOENT|ECONNREFUSED|ETIMEDOUT|ENOTFOUND)(?::\s*.+)?/,
|
|
482
|
+
// Build/compile errors (webpack, tsc, etc.)
|
|
483
|
+
/(?:^|\n)\s*(error TS\d+:\s*.+)/i,
|
|
484
|
+
/(?:^|\n)\s*(error\[\S+\]:\s*.+)/i,
|
|
485
|
+
];
|
|
486
|
+
/**
|
|
487
|
+
* Warning patterns for detecting potential issues
|
|
488
|
+
*/
|
|
489
|
+
const WARNING_PATTERNS = [
|
|
490
|
+
/(?:^|\n)\s*(?:warning|WARN|⚠️?)\s*[:\[]?\s*(.+)/i,
|
|
491
|
+
/(?:^|\n)\s*(?:deprecated|DEPRECATED):\s*(.+)/i,
|
|
492
|
+
];
|
|
493
|
+
/**
|
|
494
|
+
* Detect tool calls from agent output
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* const tools = detectToolCalls(output);
|
|
499
|
+
* // Returns: [{ tool: 'Read', args: 'file.ts' }, { tool: 'Bash', status: 'completed' }]
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
export function detectToolCalls(content) {
|
|
503
|
+
const detected = [];
|
|
504
|
+
const seenTools = new Set();
|
|
505
|
+
const toolNameExtractor = new RegExp(`\\b(${TOOL_NAME_PATTERN})\\b`, 'i');
|
|
506
|
+
for (const pattern of TOOL_PATTERNS) {
|
|
507
|
+
const matches = content.matchAll(new RegExp(pattern.source, 'gi'));
|
|
508
|
+
for (const match of matches) {
|
|
509
|
+
// Extract tool name from the match
|
|
510
|
+
const fullMatch = match[0];
|
|
511
|
+
const toolNameMatch = fullMatch.match(toolNameExtractor);
|
|
512
|
+
if (toolNameMatch) {
|
|
513
|
+
const tool = toolNameMatch[1];
|
|
514
|
+
// Avoid duplicates by position (same tool at same position)
|
|
515
|
+
const key = `${tool}:${match.index}`;
|
|
516
|
+
if (!seenTools.has(key)) {
|
|
517
|
+
seenTools.add(key);
|
|
518
|
+
detected.push({
|
|
519
|
+
tool,
|
|
520
|
+
status: fullMatch.includes('✓') || fullMatch.includes('✔') ? 'completed' : 'started',
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return detected;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Detect errors from agent output
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```typescript
|
|
533
|
+
* const errors = detectErrors(output);
|
|
534
|
+
* // Returns: [{ type: 'error', message: 'TypeError: Cannot read property...' }]
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
export function detectErrors(content) {
|
|
538
|
+
const detected = [];
|
|
539
|
+
const seenMessages = new Set();
|
|
540
|
+
// Check for error patterns
|
|
541
|
+
for (const pattern of ERROR_PATTERNS) {
|
|
542
|
+
const matches = content.matchAll(new RegExp(pattern, 'gi'));
|
|
543
|
+
for (const match of matches) {
|
|
544
|
+
const message = match[1] || match[0];
|
|
545
|
+
const cleanMessage = message.trim().slice(0, 200); // Limit length
|
|
546
|
+
if (!seenMessages.has(cleanMessage)) {
|
|
547
|
+
seenMessages.add(cleanMessage);
|
|
548
|
+
detected.push({
|
|
549
|
+
type: 'error',
|
|
550
|
+
message: cleanMessage,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// Check for warning patterns
|
|
556
|
+
for (const pattern of WARNING_PATTERNS) {
|
|
557
|
+
const matches = content.matchAll(new RegExp(pattern, 'gi'));
|
|
558
|
+
for (const match of matches) {
|
|
559
|
+
const message = match[1] || match[0];
|
|
560
|
+
const cleanMessage = message.trim().slice(0, 200);
|
|
561
|
+
if (!seenMessages.has(cleanMessage)) {
|
|
562
|
+
seenMessages.add(cleanMessage);
|
|
563
|
+
detected.push({
|
|
564
|
+
type: 'warning',
|
|
565
|
+
message: cleanMessage,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return detected;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* TrajectoryIntegration class for managing trajectory state
|
|
574
|
+
*
|
|
575
|
+
* This class enforces trajectory tracking during agent lifecycle:
|
|
576
|
+
* - Auto-starts trajectory when agent is instantiated with a task
|
|
577
|
+
* - Records all inter-agent messages
|
|
578
|
+
* - Auto-detects PDERO phase transitions
|
|
579
|
+
* - Provides lifecycle hooks for tmux/pty wrappers
|
|
580
|
+
*/
|
|
581
|
+
export class TrajectoryIntegration {
|
|
582
|
+
projectId;
|
|
583
|
+
agentName;
|
|
584
|
+
trailAvailable = null;
|
|
585
|
+
currentPhase = null;
|
|
586
|
+
trajectoryId = null;
|
|
587
|
+
initialized = false;
|
|
588
|
+
task = null;
|
|
589
|
+
constructor(projectId, agentName) {
|
|
590
|
+
this.projectId = projectId;
|
|
591
|
+
this.agentName = agentName;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Check if trail is available (cached)
|
|
595
|
+
*/
|
|
596
|
+
async isAvailable() {
|
|
597
|
+
if (this.trailAvailable === null) {
|
|
598
|
+
this.trailAvailable = await isTrailAvailable();
|
|
599
|
+
}
|
|
600
|
+
return this.trailAvailable;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Check if trail CLI is installed synchronously
|
|
604
|
+
*/
|
|
605
|
+
isTrailInstalledSync() {
|
|
606
|
+
try {
|
|
607
|
+
execSync('which trail', { stdio: 'pipe' });
|
|
608
|
+
return true;
|
|
609
|
+
}
|
|
610
|
+
catch {
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Initialize trajectory tracking for agent lifecycle
|
|
616
|
+
* Called automatically when agent starts with a task
|
|
617
|
+
*/
|
|
618
|
+
async initialize(task, taskId, source) {
|
|
619
|
+
if (this.initialized)
|
|
620
|
+
return true;
|
|
621
|
+
if (!(await this.isAvailable())) {
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
// If task provided, auto-start trajectory
|
|
625
|
+
if (task) {
|
|
626
|
+
const success = await this.start(task, taskId, source);
|
|
627
|
+
if (success) {
|
|
628
|
+
this.initialized = true;
|
|
629
|
+
this.task = task;
|
|
630
|
+
}
|
|
631
|
+
return success;
|
|
632
|
+
}
|
|
633
|
+
this.initialized = true;
|
|
634
|
+
return true;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Start tracking a trajectory
|
|
638
|
+
*/
|
|
639
|
+
async start(task, taskId, source) {
|
|
640
|
+
if (!(await this.isAvailable()))
|
|
641
|
+
return false;
|
|
642
|
+
const result = await startTrajectory({
|
|
643
|
+
task,
|
|
644
|
+
taskId,
|
|
645
|
+
source,
|
|
646
|
+
agentName: this.agentName,
|
|
647
|
+
phase: 'plan',
|
|
648
|
+
});
|
|
649
|
+
if (result.success) {
|
|
650
|
+
this.currentPhase = 'plan';
|
|
651
|
+
this.trajectoryId = result.trajectoryId || null;
|
|
652
|
+
this.task = task;
|
|
653
|
+
}
|
|
654
|
+
return result.success;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Check if there's an active trajectory
|
|
658
|
+
*/
|
|
659
|
+
hasActiveTrajectory() {
|
|
660
|
+
return this.currentPhase !== null;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Get the current task
|
|
664
|
+
*/
|
|
665
|
+
getTask() {
|
|
666
|
+
return this.task;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Get trajectory ID
|
|
670
|
+
*/
|
|
671
|
+
getTrajectoryId() {
|
|
672
|
+
return this.trajectoryId;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Record a message
|
|
676
|
+
*/
|
|
677
|
+
async message(direction, from, to, body) {
|
|
678
|
+
if (!(await this.isAvailable()))
|
|
679
|
+
return;
|
|
680
|
+
await recordMessage(direction, from, to, body);
|
|
681
|
+
// Check for phase transition based on content
|
|
682
|
+
const detectedPhase = detectPhaseFromContent(body);
|
|
683
|
+
if (detectedPhase && detectedPhase !== this.currentPhase) {
|
|
684
|
+
await this.transition(detectedPhase, 'Auto-detected from message content');
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Transition to a new phase
|
|
689
|
+
*/
|
|
690
|
+
async transition(phase, reason) {
|
|
691
|
+
if (!(await this.isAvailable()))
|
|
692
|
+
return false;
|
|
693
|
+
if (phase === this.currentPhase)
|
|
694
|
+
return true;
|
|
695
|
+
const result = await transitionPhase(phase, reason, this.agentName);
|
|
696
|
+
if (result.success) {
|
|
697
|
+
this.currentPhase = phase;
|
|
698
|
+
}
|
|
699
|
+
return result.success;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Record a decision
|
|
703
|
+
*/
|
|
704
|
+
async decision(choice, options) {
|
|
705
|
+
if (!(await this.isAvailable()))
|
|
706
|
+
return false;
|
|
707
|
+
const result = await recordDecision({
|
|
708
|
+
choice,
|
|
709
|
+
...options,
|
|
710
|
+
});
|
|
711
|
+
return result.success;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Record an event
|
|
715
|
+
*/
|
|
716
|
+
async event(content, type = 'observation') {
|
|
717
|
+
if (!(await this.isAvailable()))
|
|
718
|
+
return false;
|
|
719
|
+
const result = await recordEvent(content, type, this.agentName);
|
|
720
|
+
// Check for phase transition
|
|
721
|
+
const detectedPhase = detectPhaseFromContent(content);
|
|
722
|
+
if (detectedPhase && detectedPhase !== this.currentPhase) {
|
|
723
|
+
await this.transition(detectedPhase, 'Auto-detected from event content');
|
|
724
|
+
}
|
|
725
|
+
return result.success;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Complete the trajectory
|
|
729
|
+
*/
|
|
730
|
+
async complete(options) {
|
|
731
|
+
if (!(await this.isAvailable()))
|
|
732
|
+
return false;
|
|
733
|
+
const result = await completeTrajectory(options);
|
|
734
|
+
if (result.success) {
|
|
735
|
+
this.currentPhase = null;
|
|
736
|
+
}
|
|
737
|
+
return result.success;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Abandon the trajectory
|
|
741
|
+
*/
|
|
742
|
+
async abandon(reason) {
|
|
743
|
+
if (!(await this.isAvailable()))
|
|
744
|
+
return false;
|
|
745
|
+
const result = await abandonTrajectory(reason);
|
|
746
|
+
if (result.success) {
|
|
747
|
+
this.currentPhase = null;
|
|
748
|
+
}
|
|
749
|
+
return result.success;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Get current phase
|
|
753
|
+
*/
|
|
754
|
+
getPhase() {
|
|
755
|
+
return this.currentPhase;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Global trajectory integration instances
|
|
760
|
+
*/
|
|
761
|
+
const instances = new Map();
|
|
762
|
+
/**
|
|
763
|
+
* Get or create a TrajectoryIntegration instance
|
|
764
|
+
*/
|
|
765
|
+
export function getTrajectoryIntegration(projectId, agentName) {
|
|
766
|
+
const key = `${projectId}:${agentName}`;
|
|
767
|
+
let instance = instances.get(key);
|
|
768
|
+
if (!instance) {
|
|
769
|
+
instance = new TrajectoryIntegration(projectId, agentName);
|
|
770
|
+
instances.set(key, instance);
|
|
771
|
+
}
|
|
772
|
+
return instance;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Generate trail usage instructions for agents
|
|
776
|
+
*/
|
|
777
|
+
export function getTrailInstructions() {
|
|
778
|
+
return [
|
|
779
|
+
'📍 TRAJECTORY TRACKING (PDERO Paradigm)',
|
|
780
|
+
'',
|
|
781
|
+
'You MUST use trail commands to track your work:',
|
|
782
|
+
'',
|
|
783
|
+
'PHASES: plan → design → execute → review → observe',
|
|
784
|
+
'',
|
|
785
|
+
'COMMANDS:',
|
|
786
|
+
' trail start "task" Start trajectory for a task',
|
|
787
|
+
' trail phase <phase> Transition to new phase',
|
|
788
|
+
' trail decision "choice" Record key decisions',
|
|
789
|
+
' trail event "what happened" Log significant events',
|
|
790
|
+
' trail complete Complete with summary',
|
|
791
|
+
'',
|
|
792
|
+
'WHEN TO USE:',
|
|
793
|
+
' - Start: At beginning of any task',
|
|
794
|
+
' - Phase: When shifting focus (planning→implementing, etc.)',
|
|
795
|
+
' - Decision: For architecture/approach choices',
|
|
796
|
+
' - Event: For tool calls, errors, milestones',
|
|
797
|
+
' - Complete: When task is done',
|
|
798
|
+
'',
|
|
799
|
+
'Example workflow:',
|
|
800
|
+
' trail start "Implement auth feature"',
|
|
801
|
+
' trail phase design',
|
|
802
|
+
' trail decision "Use JWT" --reasoning "Stateless, scalable"',
|
|
803
|
+
' trail phase execute',
|
|
804
|
+
' trail event "Created auth middleware"',
|
|
805
|
+
' trail phase review',
|
|
806
|
+
' trail event "All tests passing"',
|
|
807
|
+
' trail complete --summary "Auth implemented" --confidence 0.9',
|
|
808
|
+
];
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Get a compact trail instruction string for injection
|
|
812
|
+
*/
|
|
813
|
+
export function getCompactTrailInstructions() {
|
|
814
|
+
return [
|
|
815
|
+
'[TRAIL] Track work with PDERO: plan→design→execute→review→observe.',
|
|
816
|
+
'Commands: trail start "task" | trail phase <phase> | trail decision "choice" | trail event "log" | trail complete',
|
|
817
|
+
'Use trail often to document your thought process.',
|
|
818
|
+
].join(' ');
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Get environment variables for trail CLI
|
|
822
|
+
* If dataDir is not provided, uses config-based storage location
|
|
823
|
+
*/
|
|
824
|
+
export function getTrailEnvVars(projectId, agentName, dataDir) {
|
|
825
|
+
// Use config-based path if dataDir not explicitly provided
|
|
826
|
+
const effectiveDataDir = dataDir ?? getPrimaryTrajectoriesDir();
|
|
827
|
+
return {
|
|
828
|
+
TRAJECTORIES_PROJECT: projectId,
|
|
829
|
+
TRAJECTORIES_DATA_DIR: effectiveDataDir,
|
|
830
|
+
TRAJECTORIES_AGENT: agentName,
|
|
831
|
+
TRAIL_AUTO_PHASE: '1', // Enable auto phase detection
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
//# sourceMappingURL=integration.js.map
|