@desplega.ai/agent-swarm 1.20.0 → 1.51.2
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/README.md +271 -169
- package/openapi.json +5015 -0
- package/package.json +40 -7
- package/plugin/commands/close-issue.md +7 -3
- package/plugin/commands/create-pr.md +18 -12
- package/plugin/commands/implement-issue.md +7 -3
- package/plugin/commands/respond-github.md +8 -4
- package/plugin/commands/review-pr.md +44 -10
- package/plugin/commands/start-leader.md +1 -3
- package/plugin/commands/start-worker.md +1 -3
- package/plugin/commands/work-on-task.md +22 -3
- package/plugin/pi-skills/close-issue/SKILL.md +90 -0
- package/plugin/pi-skills/create-pr/SKILL.md +99 -0
- package/plugin/pi-skills/implement-issue/SKILL.md +135 -0
- package/plugin/pi-skills/investigate-sentry-issue/SKILL.md +138 -0
- package/plugin/pi-skills/respond-github/SKILL.md +98 -0
- package/plugin/pi-skills/review-offered-task/SKILL.md +45 -0
- package/plugin/pi-skills/review-pr/SKILL.md +261 -0
- package/plugin/pi-skills/start-leader/SKILL.md +121 -0
- package/plugin/pi-skills/start-worker/SKILL.md +60 -0
- package/plugin/pi-skills/swarm-chat/SKILL.md +82 -0
- package/plugin/pi-skills/todos/SKILL.md +66 -0
- package/plugin/pi-skills/work-on-task/SKILL.md +65 -0
- package/plugin/skills/artifacts/examples/approval-flow.ts +34 -0
- package/plugin/skills/artifacts/examples/hono-dashboard.ts +31 -0
- package/plugin/skills/artifacts/examples/multi-artifact.ts +20 -0
- package/plugin/skills/artifacts/examples/static-report.sh +17 -0
- package/plugin/skills/artifacts/skill.md +71 -0
- package/src/agentmail/app.ts +65 -0
- package/src/agentmail/handlers.ts +262 -0
- package/src/agentmail/index.ts +9 -0
- package/src/agentmail/templates.ts +111 -0
- package/src/agentmail/types.ts +51 -0
- package/src/artifact-sdk/browser-sdk.ts +30 -0
- package/src/artifact-sdk/index.ts +2 -0
- package/src/artifact-sdk/localtunnel.d.ts +20 -0
- package/src/artifact-sdk/port.ts +12 -0
- package/src/artifact-sdk/server.ts +156 -0
- package/src/artifact-sdk/tunnel.ts +19 -0
- package/src/be/chunking.ts +193 -0
- package/src/be/db-queries/oauth.ts +90 -0
- package/src/be/db-queries/tracker.ts +182 -0
- package/src/be/db.ts +3327 -784
- package/src/be/embedding.ts +80 -0
- package/src/be/migrations/001_initial.sql +409 -0
- package/src/be/migrations/002_one_time_schedules.sql +59 -0
- package/src/be/migrations/003_workflows.sql +51 -0
- package/src/be/migrations/004_workflow_source.sql +81 -0
- package/src/be/migrations/005_epic_next_steps.sql +2 -0
- package/src/be/migrations/006_vcs_provider.sql +94 -0
- package/src/be/migrations/007_task_dir.sql +2 -0
- package/src/be/migrations/008_workflow_redesign.sql +85 -0
- package/src/be/migrations/009_tracker_integration.sql +144 -0
- package/src/be/migrations/010_step_diagnostics.sql +1 -0
- package/src/be/migrations/011_step_next_port.sql +1 -0
- package/src/be/migrations/012_trigger_schema.sql +1 -0
- package/src/be/migrations/013_task_output_schema.sql +2 -0
- package/src/be/migrations/014_prompt_templates.sql +33 -0
- package/src/be/migrations/015_workflow_workspace.sql +3 -0
- package/src/be/migrations/016_active_session_runner_session.sql +4 -0
- package/src/be/migrations/017_channel_activity_cursors.sql +6 -0
- package/src/be/migrations/018_fix_seed_double_version.sql +30 -0
- package/src/be/migrations/runner.ts +188 -0
- package/src/be/seed.ts +62 -0
- package/src/cli.tsx +231 -299
- package/src/commands/artifact.ts +241 -0
- package/src/commands/onboard/compose-generator.ts +169 -0
- package/src/commands/onboard/env-generator.ts +79 -0
- package/src/commands/onboard/manifest.ts +37 -0
- package/src/commands/onboard/presets.ts +85 -0
- package/src/commands/onboard/service-names.ts +47 -0
- package/src/commands/onboard/steps/core-credentials.tsx +111 -0
- package/src/commands/onboard/steps/custom-templates.tsx +168 -0
- package/src/commands/onboard/steps/generate.tsx +154 -0
- package/src/commands/onboard/steps/harness-credentials.tsx +195 -0
- package/src/commands/onboard/steps/harness.tsx +21 -0
- package/src/commands/onboard/steps/health-check.tsx +171 -0
- package/src/commands/onboard/steps/integration-github.tsx +105 -0
- package/src/commands/onboard/steps/integration-gitlab.tsx +79 -0
- package/src/commands/onboard/steps/integration-menu.tsx +58 -0
- package/src/commands/onboard/steps/integration-sentry.tsx +79 -0
- package/src/commands/onboard/steps/integration-slack.tsx +165 -0
- package/src/commands/onboard/steps/post-connect.tsx +145 -0
- package/src/commands/onboard/steps/post-dashboard.tsx +34 -0
- package/src/commands/onboard/steps/post-task.tsx +103 -0
- package/src/commands/onboard/steps/prereq-check.tsx +178 -0
- package/src/commands/onboard/steps/review.tsx +82 -0
- package/src/commands/onboard/steps/start.tsx +97 -0
- package/src/commands/onboard/templates.ts +34 -0
- package/src/commands/onboard/types.ts +259 -0
- package/src/commands/onboard.tsx +425 -0
- package/src/commands/runner.ts +1540 -630
- package/src/commands/setup.tsx +23 -38
- package/src/commands/shared/client-config.ts +41 -0
- package/src/commands/templates.ts +172 -0
- package/src/github/app.ts +8 -0
- package/src/github/handlers.ts +384 -151
- package/src/github/index.ts +1 -0
- package/src/github/mentions-aliases.test.ts +73 -0
- package/src/github/mentions.test.ts +3 -3
- package/src/github/mentions.ts +32 -6
- package/src/github/templates.ts +398 -0
- package/src/github/types.ts +1 -0
- package/src/gitlab/auth.ts +63 -0
- package/src/gitlab/handlers.ts +368 -0
- package/src/gitlab/index.ts +19 -0
- package/src/gitlab/reactions.ts +104 -0
- package/src/gitlab/templates.ts +140 -0
- package/src/gitlab/types.ts +130 -0
- package/src/heartbeat/heartbeat.ts +434 -0
- package/src/heartbeat/index.ts +1 -0
- package/src/heartbeat/templates.ts +30 -0
- package/src/hooks/hook.ts +555 -4
- package/src/hooks/tool-loop-detection.test.ts +158 -0
- package/src/hooks/tool-loop-detection.ts +167 -0
- package/src/http/active-sessions.ts +199 -0
- package/src/http/agents.ts +328 -0
- package/src/http/config.ts +191 -0
- package/src/http/core.ts +309 -0
- package/src/http/db-query.ts +91 -0
- package/src/http/ecosystem.ts +63 -0
- package/src/http/epics.ts +460 -0
- package/src/http/index.ts +216 -0
- package/src/http/mcp.ts +77 -0
- package/src/http/memory.ts +168 -0
- package/src/http/openapi.ts +109 -0
- package/src/http/poll.ts +299 -0
- package/src/http/prompt-templates.ts +412 -0
- package/src/http/repos.ts +195 -0
- package/src/http/route-def.ts +123 -0
- package/src/http/schedules.ts +426 -0
- package/src/http/session-data.ts +241 -0
- package/src/http/stats.ts +174 -0
- package/src/http/tasks.ts +468 -0
- package/src/http/trackers/index.ts +10 -0
- package/src/http/trackers/linear.ts +187 -0
- package/src/http/types.ts +12 -0
- package/src/http/utils.ts +87 -0
- package/src/http/webhooks.ts +432 -0
- package/src/http/workflows.ts +530 -0
- package/src/http.ts +1 -1890
- package/src/linear/README.md +65 -0
- package/src/linear/app.ts +48 -0
- package/src/linear/client.ts +18 -0
- package/src/linear/index.ts +1 -0
- package/src/linear/oauth.ts +35 -0
- package/src/linear/outbound.ts +212 -0
- package/src/linear/sync.ts +567 -0
- package/src/linear/templates.ts +47 -0
- package/src/linear/types.ts +7 -0
- package/src/linear/webhook.ts +104 -0
- package/src/oauth/README.md +66 -0
- package/src/oauth/index.ts +6 -0
- package/src/oauth/wrapper.ts +204 -0
- package/src/prompts/base-prompt.ts +150 -265
- package/src/prompts/defaults.ts +196 -0
- package/src/prompts/registry.ts +57 -0
- package/src/prompts/resolver.ts +296 -0
- package/src/prompts/session-templates.ts +604 -0
- package/src/providers/claude-adapter.ts +442 -0
- package/src/providers/index.ts +24 -0
- package/src/providers/pi-mono-adapter.ts +442 -0
- package/src/providers/pi-mono-extension.ts +624 -0
- package/src/providers/pi-mono-mcp-client.ts +124 -0
- package/src/providers/types.ts +75 -0
- package/src/scheduler/scheduler.test.ts +2 -0
- package/src/scheduler/scheduler.ts +231 -40
- package/src/server.ts +97 -6
- package/src/slack/HEURISTICS.md +105 -0
- package/src/slack/actions.ts +133 -0
- package/src/slack/app.ts +7 -0
- package/src/slack/assistant.ts +118 -0
- package/src/slack/blocks.ts +233 -0
- package/src/slack/channel-activity.ts +177 -0
- package/src/slack/commands.ts +31 -17
- package/src/slack/files.ts +1 -1
- package/src/slack/handlers.test.ts +114 -1
- package/src/slack/handlers.ts +230 -55
- package/src/slack/responses.ts +120 -67
- package/src/slack/router.ts +17 -99
- package/src/slack/templates.ts +55 -0
- package/src/slack/thread-buffer.ts +213 -0
- package/src/slack/watcher.ts +119 -4
- package/src/tests/agent-activity.test.ts +247 -0
- package/src/tests/agentmail-filters.test.ts +97 -0
- package/src/tests/artifact-sdk.test.ts +800 -0
- package/src/tests/base-prompt.test.ts +264 -0
- package/src/tests/build-pi-skills.test.ts +127 -0
- package/src/tests/channel-activity.test.ts +363 -0
- package/src/tests/claude-adapter.test.ts +126 -0
- package/src/tests/context-versioning.test.ts +425 -0
- package/src/tests/db-queries-oauth.test.ts +197 -0
- package/src/tests/db-queries-tracker.test.ts +230 -0
- package/src/tests/epics.test.ts +3 -3
- package/src/tests/error-tracker.test.ts +368 -0
- package/src/tests/fetch-resolved-env.test.ts +167 -0
- package/src/tests/generate-default-claude-md.test.ts +9 -1
- package/src/tests/generate-identity-templates.test.ts +124 -0
- package/src/tests/gitlab-auth.test.ts +109 -0
- package/src/tests/gitlab-handlers.test.ts +691 -0
- package/src/tests/gitlab-vcs-db.test.ts +177 -0
- package/src/tests/heartbeat.test.ts +364 -0
- package/src/tests/http-api-integration.test.ts +1698 -0
- package/src/tests/linear-outbound-sync.test.ts +200 -0
- package/src/tests/linear-webhook.test.ts +406 -0
- package/src/tests/match-route.test.ts +187 -0
- package/src/tests/memory.test.ts +737 -0
- package/src/tests/migration-runner-regressions.test.ts +86 -0
- package/src/tests/model-control.test.ts +338 -0
- package/src/tests/oauth-wrapper.test.ts +147 -0
- package/src/tests/onboard-compose.test.ts +138 -0
- package/src/tests/onboard-env.test.ts +174 -0
- package/src/tests/onboard-manifest.test.ts +137 -0
- package/src/tests/pi-mono-adapter.test.ts +234 -0
- package/src/tests/pool-session-logs.test.ts +199 -0
- package/src/tests/progress-dedup.test.ts +98 -0
- package/src/tests/prompt-template-github.test.ts +682 -0
- package/src/tests/prompt-template-remaining.test.ts +504 -0
- package/src/tests/prompt-template-resolver.test.ts +621 -0
- package/src/tests/prompt-template-session.test.ts +363 -0
- package/src/tests/prompt-templates-db.test.ts +616 -0
- package/src/tests/provider-adapter.test.ts +122 -0
- package/src/tests/provider-command-format.test.ts +98 -0
- package/src/tests/reload-config.test.ts +170 -0
- package/src/tests/runner-polling-api.test.ts +25 -20
- package/src/tests/scheduled-tasks.test.ts +104 -0
- package/src/tests/scheduler-backoff.test.ts +166 -0
- package/src/tests/self-improvement.test.ts +541 -0
- package/src/tests/session-attach.test.ts +536 -0
- package/src/tests/session-costs.test.ts +267 -1
- package/src/tests/slack-actions.test.ts +133 -0
- package/src/tests/slack-assistant.test.ts +136 -0
- package/src/tests/slack-blocks.test.ts +246 -0
- package/src/tests/slack-metadata-inheritance.test.ts +243 -0
- package/src/tests/slack-queue-offline.test.ts +174 -0
- package/src/tests/slack-router.test.ts +181 -0
- package/src/tests/slack-thread-buffer.test.ts +305 -0
- package/src/tests/slack-thread-followups.test.ts +298 -0
- package/src/tests/slack-watcher.test.ts +101 -0
- package/src/tests/structured-output.test.ts +307 -0
- package/src/tests/swarm-repos.test.ts +198 -0
- package/src/tests/task-cancellation.test.ts +6 -4
- package/src/tests/task-working-dir.test.ts +176 -0
- package/src/tests/template-fetch.test.ts +490 -0
- package/src/tests/tool-annotations.test.ts +371 -0
- package/src/tests/tracker-tools.test.ts +184 -0
- package/src/tests/update-profile-agentid.test.ts +248 -0
- package/src/tests/update-profile-api.test.ts +143 -3
- package/src/tests/update-profile-auth.test.ts +195 -0
- package/src/tests/validation-adapters.test.ts +86 -0
- package/src/tests/vcs-provider.test.ts +27 -0
- package/src/tests/workflow-agent-task.test.ts +196 -0
- package/src/tests/workflow-async-v2.test.ts +508 -0
- package/src/tests/workflow-convergence.test.ts +541 -0
- package/src/tests/workflow-definition-validation.test.ts +366 -0
- package/src/tests/workflow-engine-v2.test.ts +691 -0
- package/src/tests/workflow-executors.test.ts +736 -0
- package/src/tests/workflow-http-v2.test.ts +599 -0
- package/src/tests/workflow-integration-io.test.ts +902 -0
- package/src/tests/workflow-io-schemas.test.ts +624 -0
- package/src/tests/workflow-registry.test.ts +592 -0
- package/src/tests/workflow-retry-v2.test.ts +401 -0
- package/src/tests/workflow-retry-validation.test.ts +282 -0
- package/src/tests/workflow-schedule-trigger.test.ts +104 -0
- package/src/tests/workflow-template.test.ts +288 -0
- package/src/tests/workflow-trigger-schema.test.ts +359 -0
- package/src/tests/workflow-triggers-v2.test.ts +264 -0
- package/src/tests/workflow-versions.test.ts +208 -0
- package/src/tests/workflow-workspace.test.ts +272 -0
- package/src/tests/x402-client.test.ts +117 -0
- package/src/tests/x402-config.test.ts +182 -0
- package/src/tests/x402-spending-tracker.test.ts +185 -0
- package/src/tools/cancel-task.ts +2 -0
- package/src/tools/context-diff.ts +171 -0
- package/src/tools/context-history.ts +138 -0
- package/src/tools/create-channel.ts +1 -0
- package/src/tools/db-query.ts +78 -0
- package/src/tools/delete-channel.ts +132 -0
- package/src/tools/epics/assign-task-to-epic.ts +1 -0
- package/src/tools/epics/create-epic.ts +3 -2
- package/src/tools/epics/delete-epic.ts +2 -0
- package/src/tools/epics/get-epic-details.ts +2 -0
- package/src/tools/epics/list-epics.ts +2 -0
- package/src/tools/epics/unassign-task-from-epic.ts +1 -0
- package/src/tools/epics/update-epic.ts +7 -4
- package/src/tools/get-swarm.ts +2 -0
- package/src/tools/get-task-details.ts +2 -0
- package/src/tools/get-tasks.ts +27 -1
- package/src/tools/inject-learning.ts +106 -0
- package/src/tools/join-swarm.ts +17 -7
- package/src/tools/list-channels.ts +2 -0
- package/src/tools/list-services.ts +2 -0
- package/src/tools/memory-get.ts +56 -0
- package/src/tools/memory-search.ts +131 -0
- package/src/tools/my-agent-info.ts +2 -0
- package/src/tools/poll-task.ts +2 -20
- package/src/tools/post-message.ts +1 -0
- package/src/tools/prompt-templates/delete.ts +86 -0
- package/src/tools/prompt-templates/get.ts +89 -0
- package/src/tools/prompt-templates/index.ts +5 -0
- package/src/tools/prompt-templates/list.ts +95 -0
- package/src/tools/prompt-templates/preview.ts +84 -0
- package/src/tools/prompt-templates/set.ts +117 -0
- package/src/tools/read-messages.ts +2 -0
- package/src/tools/register-agentmail-inbox.ts +166 -0
- package/src/tools/register-service.ts +2 -0
- package/src/tools/schedules/create-schedule.ts +134 -24
- package/src/tools/schedules/delete-schedule.ts +2 -0
- package/src/tools/schedules/list-schedules.ts +20 -4
- package/src/tools/schedules/run-schedule-now.ts +1 -0
- package/src/tools/schedules/update-schedule.ts +49 -17
- package/src/tools/send-task.ts +132 -10
- package/src/tools/slack-download-file.ts +4 -2
- package/src/tools/slack-list-channels.ts +2 -0
- package/src/tools/slack-post.ts +2 -0
- package/src/tools/slack-read.ts +2 -0
- package/src/tools/slack-reply.ts +2 -0
- package/src/tools/slack-upload-file.ts +2 -0
- package/src/tools/store-progress.ts +205 -4
- package/src/tools/swarm-config/delete-config.ts +87 -0
- package/src/tools/swarm-config/get-config.ts +108 -0
- package/src/tools/swarm-config/index.ts +4 -0
- package/src/tools/swarm-config/list-config.ts +99 -0
- package/src/tools/swarm-config/set-config.ts +118 -0
- package/src/tools/task-action.ts +50 -5
- package/src/tools/task-dedup.ts +97 -0
- package/src/tools/templates.ts +53 -0
- package/src/tools/tool-config.ts +124 -0
- package/src/tools/tracker/index.ts +6 -0
- package/src/tools/tracker/tracker-link-epic.ts +64 -0
- package/src/tools/tracker/tracker-link-task.ts +64 -0
- package/src/tools/tracker/tracker-map-agent.ts +57 -0
- package/src/tools/tracker/tracker-status.ts +56 -0
- package/src/tools/tracker/tracker-sync-status.ts +42 -0
- package/src/tools/tracker/tracker-unlink.ts +41 -0
- package/src/tools/unregister-service.ts +2 -0
- package/src/tools/update-profile.ts +172 -17
- package/src/tools/update-service-status.ts +2 -0
- package/src/tools/utils.ts +10 -1
- package/src/tools/workflows/create-workflow.ts +129 -0
- package/src/tools/workflows/delete-workflow.ts +42 -0
- package/src/tools/workflows/get-workflow-run.ts +59 -0
- package/src/tools/workflows/get-workflow.ts +53 -0
- package/src/tools/workflows/index.ts +9 -0
- package/src/tools/workflows/list-workflow-runs.ts +48 -0
- package/src/tools/workflows/list-workflows.ts +42 -0
- package/src/tools/workflows/retry-workflow-run.ts +40 -0
- package/src/tools/workflows/trigger-workflow.ts +96 -0
- package/src/tools/workflows/update-workflow.ts +133 -0
- package/src/tracker/types.ts +51 -0
- package/src/types.ts +530 -14
- package/src/utils/credentials.test.ts +156 -0
- package/src/utils/credentials.ts +50 -0
- package/src/utils/error-tracker.ts +190 -0
- package/src/vcs/index.ts +15 -0
- package/src/vcs/types.ts +5 -0
- package/src/workflows/checkpoint.ts +121 -0
- package/src/workflows/cooldown.ts +28 -0
- package/src/workflows/definition.ts +235 -0
- package/src/workflows/engine.ts +580 -0
- package/src/workflows/event-bus.ts +29 -0
- package/src/workflows/executors/agent-task.ts +103 -0
- package/src/workflows/executors/base.ts +86 -0
- package/src/workflows/executors/code-match.ts +88 -0
- package/src/workflows/executors/index.ts +16 -0
- package/src/workflows/executors/notify.ts +93 -0
- package/src/workflows/executors/property-match.ts +104 -0
- package/src/workflows/executors/raw-llm.ts +83 -0
- package/src/workflows/executors/registry.ts +76 -0
- package/src/workflows/executors/script.ts +103 -0
- package/src/workflows/executors/validate.ts +215 -0
- package/src/workflows/executors/vcs.ts +58 -0
- package/src/workflows/index.ts +61 -0
- package/src/workflows/input.ts +46 -0
- package/src/workflows/json-schema-validator.ts +118 -0
- package/src/workflows/recovery.ts +139 -0
- package/src/workflows/resume.ts +229 -0
- package/src/workflows/retry-poller.ts +216 -0
- package/src/workflows/template.ts +74 -0
- package/src/workflows/templates.ts +86 -0
- package/src/workflows/triggers.ts +124 -0
- package/src/workflows/validation.ts +104 -0
- package/src/workflows/version.ts +44 -0
- package/src/x402/cli.ts +140 -0
- package/src/x402/client.ts +192 -0
- package/src/x402/config.ts +131 -0
- package/src/x402/index.ts +37 -0
- package/src/x402/openfort-signer.ts +83 -0
- package/src/x402/spending-tracker.ts +109 -0
- package/templates/official/coder/CLAUDE.md +49 -0
- package/templates/official/coder/IDENTITY.md +28 -0
- package/templates/official/coder/SOUL.md +43 -0
- package/templates/official/coder/TOOLS.md +40 -0
- package/templates/official/coder/config.json +23 -0
- package/templates/official/coder/start-up.sh +23 -0
- package/templates/official/content-reviewer/CLAUDE.md +68 -0
- package/templates/official/content-reviewer/IDENTITY.md +28 -0
- package/templates/official/content-reviewer/SOUL.md +44 -0
- package/templates/official/content-reviewer/TOOLS.md +37 -0
- package/templates/official/content-reviewer/config.json +23 -0
- package/templates/official/content-reviewer/start-up.sh +23 -0
- package/templates/official/content-strategist/CLAUDE.md +63 -0
- package/templates/official/content-strategist/IDENTITY.md +33 -0
- package/templates/official/content-strategist/SOUL.md +48 -0
- package/templates/official/content-strategist/TOOLS.md +47 -0
- package/templates/official/content-strategist/config.json +23 -0
- package/templates/official/content-strategist/start-up.sh +23 -0
- package/templates/official/content-writer/CLAUDE.md +72 -0
- package/templates/official/content-writer/IDENTITY.md +30 -0
- package/templates/official/content-writer/SOUL.md +46 -0
- package/templates/official/content-writer/TOOLS.md +44 -0
- package/templates/official/content-writer/config.json +23 -0
- package/templates/official/content-writer/start-up.sh +23 -0
- package/templates/official/forward-deployed-engineer/CLAUDE.md +54 -0
- package/templates/official/forward-deployed-engineer/IDENTITY.md +37 -0
- package/templates/official/forward-deployed-engineer/SOUL.md +55 -0
- package/templates/official/forward-deployed-engineer/config.json +21 -0
- package/templates/official/lead/CLAUDE.md +33 -0
- package/templates/official/lead/IDENTITY.md +36 -0
- package/templates/official/lead/SOUL.md +51 -0
- package/templates/official/lead/config.json +22 -0
- package/templates/official/researcher/CLAUDE.md +46 -0
- package/templates/official/researcher/IDENTITY.md +28 -0
- package/templates/official/researcher/SOUL.md +43 -0
- package/templates/official/researcher/config.json +21 -0
- package/templates/official/reviewer/CLAUDE.md +63 -0
- package/templates/official/reviewer/IDENTITY.md +28 -0
- package/templates/official/reviewer/SOUL.md +45 -0
- package/templates/official/reviewer/config.json +21 -0
- package/templates/official/tester/CLAUDE.md +53 -0
- package/templates/official/tester/IDENTITY.md +28 -0
- package/templates/official/tester/SOUL.md +55 -0
- package/templates/official/tester/config.json +21 -0
- package/templates/schema.ts +35 -0
- package/.claude/settings.local.json +0 -115
- package/.dockerignore +0 -61
- package/.editorconfig +0 -15
- package/.env.docker.example +0 -39
- package/.env.example +0 -40
- package/.github/workflows/ci.yml +0 -76
- package/.github/workflows/docker-and-deploy.yml +0 -117
- package/.wts-config.json +0 -4
- package/.wts-setup.ts +0 -102
- package/CLAUDE.md +0 -104
- package/CONTRIBUTING.md +0 -270
- package/DEPLOYMENT.md +0 -605
- package/Dockerfile +0 -57
- package/Dockerfile.worker +0 -157
- package/FAQ.md +0 -19
- package/MCP.md +0 -406
- package/UI.md +0 -40
- package/assets/agent-swarm-logo-orange.png +0 -0
- package/assets/agent-swarm-logo.png +0 -0
- package/assets/agent-swarm.mp4 +0 -0
- package/assets/agent-swarm.png +0 -0
- package/biome.json +0 -39
- package/deploy/DEPLOY.md +0 -60
- package/deploy/agent-swarm.service +0 -17
- package/deploy/docker-push.ts +0 -30
- package/deploy/install.ts +0 -85
- package/deploy/prod-db.ts +0 -42
- package/deploy/uninstall.ts +0 -12
- package/deploy/update.ts +0 -21
- package/docker-compose.example.yml +0 -159
- package/docker-entrypoint.sh +0 -352
- package/ecosystem.config.cjs +0 -66
- package/plugin/README.md +0 -1
- package/plugin/hooks/hooks.json +0 -71
- package/pyproject.toml +0 -9
- package/scripts/generate-mcp-docs.ts +0 -415
- package/slack-manifest.json +0 -71
- package/src/tests/get-inbox-message.test.ts +0 -145
- package/src/tools/get-inbox-message.ts +0 -89
- package/src/tools/inbox-delegate.ts +0 -113
- package/thoughts/shared/plans/2025-12-18-slack-integration.md +0 -1195
- package/thoughts/shared/plans/2025-12-19-agent-log-streaming.md +0 -732
- package/thoughts/shared/plans/2025-12-19-role-based-swarm-plugin.md +0 -361
- package/thoughts/shared/plans/2025-12-20-mobile-responsive-ui.md +0 -501
- package/thoughts/shared/plans/2025-12-20-startup-team-swarm.md +0 -560
- package/thoughts/shared/plans/2025-12-23-runner-level-polling.md +0 -934
- package/thoughts/shared/plans/2025-12-23-runner-session-logs.md +0 -1000
- package/thoughts/shared/plans/2025-12-23-worker-lead-spawn-triggers.md +0 -568
- package/thoughts/shared/plans/2026-01-09-inverse-teleport.md +0 -1516
- package/thoughts/shared/plans/2026-01-12-agent-rename-pm2-control.md +0 -1133
- package/thoughts/shared/plans/2026-01-12-github-app-integration.md +0 -380
- package/thoughts/shared/plans/2026-01-12-lead-inbox-model.md +0 -876
- package/thoughts/shared/plans/2026-01-12-ralph-wiggum-integration.md +0 -463
- package/thoughts/shared/plans/2026-01-13-agent-concurrency.md +0 -691
- package/thoughts/shared/plans/2026-01-13-github-assignment-handling.md +0 -690
- package/thoughts/shared/plans/2026-01-13-prevent-duplicate-trigger-processing.md +0 -1071
- package/thoughts/shared/plans/2026-01-14-fix-slack-thread-context.md +0 -507
- package/thoughts/shared/plans/2026-01-15-scheduled-tasks-implementation.md +0 -565
- package/thoughts/shared/plans/2026-01-15-usage-cost-tracking-ui.md +0 -1479
- package/thoughts/shared/plans/2026-01-16-epics-feature-implementation.md +0 -1230
- package/thoughts/shared/research/.gitkeep +0 -0
- package/thoughts/shared/research/2025-01-09-inverse-teleport-plan-review.md +0 -420
- package/thoughts/shared/research/2025-12-18-slack-integration.md +0 -442
- package/thoughts/shared/research/2025-12-19-agent-log-streaming.md +0 -339
- package/thoughts/shared/research/2025-12-19-agent-secrets-cli-research.md +0 -390
- package/thoughts/shared/research/2025-12-21-gemini-cli-integration.md +0 -376
- package/thoughts/shared/research/2025-12-22-runner-loop-architecture.md +0 -582
- package/thoughts/shared/research/2025-12-22-setup-experience-improvements.md +0 -264
- package/thoughts/shared/research/2026-01-13-lead-duplicate-trigger-processing.md +0 -223
- package/thoughts/shared/research/2026-01-14-lead-slack-thread-context.md +0 -277
- package/thoughts/shared/research/2026-01-15-ai-tracker-agent-swarm-integration.md +0 -376
- package/thoughts/shared/research/2026-01-15-auto-starting-processes-in-worker-containers.md +0 -787
- package/thoughts/shared/research/2026-01-15-scheduled-tasks.md +0 -390
- package/thoughts/shared/research/2026-01-16-epics-feature-research.md +0 -437
- package/thoughts/taras/plans/2026-01-22-agent-swarm-schemas.md +0 -98
- package/thoughts/taras/plans/2026-01-28-per-worker-claude-md.md +0 -617
- package/thoughts/taras/plans/2026-01-28-sentry-cli-integration.md +0 -214
- package/thoughts/taras/research/2026-01-22-vercel-cli-integration.md +0 -287
- package/thoughts/taras/research/2026-01-27-excessive-polling-issue.md +0 -311
- package/thoughts/taras/research/2026-01-28-per-worker-claude-md.md +0 -383
- package/thoughts/taras/research/2026-01-28-sentry-cli-integration.md +0 -240
- package/tsconfig.json +0 -37
- package/ui/CLAUDE.md +0 -49
- package/ui/bun.lock +0 -771
- package/ui/index.html +0 -22
- package/ui/package-lock.json +0 -5290
- package/ui/package.json +0 -33
- package/ui/pnpm-lock.yaml +0 -3341
- package/ui/postcss.config.js +0 -6
- package/ui/public/logo.png +0 -0
- package/ui/src/App.tsx +0 -63
- package/ui/src/components/ActivityFeed.tsx +0 -440
- package/ui/src/components/AgentDetailPanel.tsx +0 -733
- package/ui/src/components/AgentsPanel.tsx +0 -815
- package/ui/src/components/ChatPanel.tsx +0 -1920
- package/ui/src/components/ConfigModal.tsx +0 -253
- package/ui/src/components/Dashboard.tsx +0 -832
- package/ui/src/components/EditAgentProfileModal.tsx +0 -433
- package/ui/src/components/EpicDetailPage.tsx +0 -741
- package/ui/src/components/EpicsPanel.tsx +0 -566
- package/ui/src/components/Header.tsx +0 -160
- package/ui/src/components/JsonViewer.tsx +0 -171
- package/ui/src/components/ScheduledTaskDetailPanel.tsx +0 -517
- package/ui/src/components/ScheduledTasksPanel.tsx +0 -639
- package/ui/src/components/ServicesPanel.tsx +0 -622
- package/ui/src/components/SessionLogPanel.tsx +0 -1219
- package/ui/src/components/StatsBar.tsx +0 -321
- package/ui/src/components/StatusBadge.tsx +0 -168
- package/ui/src/components/TaskDetailPanel.tsx +0 -903
- package/ui/src/components/TasksPanel.tsx +0 -614
- package/ui/src/components/UsageCharts.tsx +0 -216
- package/ui/src/components/UsageTab.tsx +0 -394
- package/ui/src/hooks/queries.ts +0 -353
- package/ui/src/hooks/useAutoScroll.ts +0 -83
- package/ui/src/index.css +0 -257
- package/ui/src/lib/api.ts +0 -268
- package/ui/src/lib/config.ts +0 -35
- package/ui/src/lib/contentPreview.ts +0 -208
- package/ui/src/lib/theme.ts +0 -214
- package/ui/src/lib/utils.ts +0 -88
- package/ui/src/main.tsx +0 -28
- package/ui/src/types/api.ts +0 -323
- package/ui/src/vite-env.d.ts +0 -1
- package/ui/tailwind.config.js +0 -37
- package/ui/tsconfig.json +0 -31
- package/ui/vite.config.ts +0 -35
- /package/{thoughts/shared/plans → templates/community}/.gitkeep +0 -0
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
date: 2026-01-14T12:00:00-08:00
|
|
3
|
-
researcher: Claude
|
|
4
|
-
git_commit: 7ffa4d18b53c5422d59fdf53b00a8bab6f7a12fd
|
|
5
|
-
branch: main
|
|
6
|
-
repository: agent-swarm
|
|
7
|
-
topic: "Lead Agent Slack Thread Context Handling"
|
|
8
|
-
tags: [research, slack, lead-agent, thread-context, inbox-messages]
|
|
9
|
-
status: complete
|
|
10
|
-
last_updated: 2026-01-14
|
|
11
|
-
last_updated_by: Claude
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# Research: Lead Agent Slack Thread Context Handling
|
|
15
|
-
|
|
16
|
-
**Date**: 2026-01-14T12:00:00-08:00
|
|
17
|
-
**Researcher**: Claude
|
|
18
|
-
**Git Commit**: 7ffa4d18b53c5422d59fdf53b00a8bab6f7a12fd
|
|
19
|
-
**Branch**: main
|
|
20
|
-
**Repository**: agent-swarm
|
|
21
|
-
|
|
22
|
-
## Research Question
|
|
23
|
-
|
|
24
|
-
Why is the lead agent not properly following up on Slack messages? Specifically:
|
|
25
|
-
- Not getting the thread context
|
|
26
|
-
- Not able to follow up to previous messages
|
|
27
|
-
- Needing to reference all context again and again for it to work
|
|
28
|
-
|
|
29
|
-
## Summary
|
|
30
|
-
|
|
31
|
-
The lead agent's difficulty with Slack thread context stems from **how inbox messages are presented to the agent, not how they are stored**. While the system correctly retrieves thread context from Slack (up to 20 messages) and stores it in inbox messages, the agent only sees a 100-character truncated preview in the trigger prompt. Additionally, there is no MCP tool for the agent to read the full inbox message content, and the base prompt does not explain the thread context format.
|
|
32
|
-
|
|
33
|
-
## Detailed Findings
|
|
34
|
-
|
|
35
|
-
### Component 1: Thread Context Retrieval (Working Correctly)
|
|
36
|
-
|
|
37
|
-
**Location**: `src/slack/handlers.ts:45-90`
|
|
38
|
-
|
|
39
|
-
The `getThreadContext()` function correctly fetches thread history from Slack:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
const result = await client.conversations.replies({
|
|
43
|
-
channel,
|
|
44
|
-
ts: threadTs,
|
|
45
|
-
limit: 20, // Last 20 messages max
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Thread messages are formatted with user display names or `[Agent]:` prefix for bot messages, and wrapped in XML-style tags:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
<thread_context>
|
|
53
|
-
John Doe: Can you help me with this bug?
|
|
54
|
-
[Agent]: I'll look into that. The issue appears to be in the authentication module...
|
|
55
|
-
John Doe: Thanks! Any update?
|
|
56
|
-
</thread_context>
|
|
57
|
-
|
|
58
|
-
<actual new message content here>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Key Pattern**: Bot messages are truncated to 500 chars to keep context manageable (`handlers.ts:77`).
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
### Component 2: Inbox Message Storage (Working Correctly)
|
|
66
|
-
|
|
67
|
-
**Location**: `src/slack/handlers.ts:213-247`
|
|
68
|
-
|
|
69
|
-
When creating inbox messages for the lead agent, the full task description includes thread context:
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
const fullTaskDescription = threadContext + taskDescription;
|
|
73
|
-
|
|
74
|
-
createInboxMessage(agent.id, fullTaskDescription, {
|
|
75
|
-
source: "slack",
|
|
76
|
-
slackChannelId: msg.channel,
|
|
77
|
-
slackThreadTs: threadTs,
|
|
78
|
-
slackUserId: msg.user,
|
|
79
|
-
matchedText: match.matchedText,
|
|
80
|
-
});
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
The `InboxMessage` record in the database contains:
|
|
84
|
-
- `content`: Full message including thread context (unlimited length)
|
|
85
|
-
- `slackChannelId`: Channel ID for replies
|
|
86
|
-
- `slackThreadTs`: Thread timestamp for replies
|
|
87
|
-
- `slackUserId`: User who sent the message
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
### Component 3: Prompt Formatting (Content Truncation)
|
|
92
|
-
|
|
93
|
-
**Location**: `src/commands/runner.ts:368-382`
|
|
94
|
-
|
|
95
|
-
When the lead agent receives a `slack_inbox_message` trigger, the content is **truncated to 100 characters**:
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
case "slack_inbox_message": {
|
|
99
|
-
const inboxSummaries = (trigger.messages || [])
|
|
100
|
-
.map((m: { id: string; content: string }) => {
|
|
101
|
-
const preview = m.content.length > 100 ? `${m.content.slice(0, 100)}...` : m.content;
|
|
102
|
-
return `- "${preview}" (inboxMessageId: ${m.id})`;
|
|
103
|
-
})
|
|
104
|
-
.join("\n");
|
|
105
|
-
|
|
106
|
-
return `You have ${trigger.count} inbox message(s) from Slack:\n${inboxSummaries}\n\nFor each message, you can either:
|
|
107
|
-
- Use \`slack-reply\` with the inboxMessageId to respond directly to the user
|
|
108
|
-
- Use \`inbox-delegate\` to assign the request to a worker agent
|
|
109
|
-
|
|
110
|
-
Review each message and decide the appropriate action.`;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Example of what the agent sees**:
|
|
115
|
-
```
|
|
116
|
-
You have 1 inbox message(s) from Slack:
|
|
117
|
-
- "<thread_context>
|
|
118
|
-
John Doe: Can you help me with this bug?
|
|
119
|
-
[Agent]: I'll..." (inboxMessageId: abc-123)
|
|
120
|
-
|
|
121
|
-
For each message, you can either:
|
|
122
|
-
- Use `slack-reply` with the inboxMessageId to respond directly to the user
|
|
123
|
-
- Use `inbox-delegate` to assign the request to a worker agent
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
**Impact**: The 100-character limit means the agent may only see the thread context header and some history, **but not the actual new message** that needs a response.
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
### Component 4: No Tool to Read Full Inbox Content
|
|
131
|
-
|
|
132
|
-
**Location**: `src/tools/` directory
|
|
133
|
-
|
|
134
|
-
There is NO MCP tool that allows agents to read the full content of inbox messages. The existing tools:
|
|
135
|
-
|
|
136
|
-
| Tool | Purpose | Can Read Full Inbox? |
|
|
137
|
-
|------|---------|---------------------|
|
|
138
|
-
| `slack-reply` | Reply to Slack threads | No - uses inbox internally but doesn't expose content |
|
|
139
|
-
| `inbox-delegate` | Delegate to workers | No - uses inbox internally but doesn't expose content |
|
|
140
|
-
| `read-messages` | Read internal channel messages | No - different message type |
|
|
141
|
-
|
|
142
|
-
The full inbox message content is:
|
|
143
|
-
- Available internally to `slack-reply` and `inbox-delegate` tools
|
|
144
|
-
- Stored in the database (`getInboxMessageById()` at `db.ts:2610`)
|
|
145
|
-
- **Not exposed to agents via any MCP tool**
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
### Component 5: Base Prompt Guidance (Minimal)
|
|
150
|
-
|
|
151
|
-
**Location**: `src/prompts/base-prompt.ts:20-24`
|
|
152
|
-
|
|
153
|
-
The base prompt provides minimal guidance about Slack:
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
#### Slack Inbox
|
|
157
|
-
When Slack messages are routed to you, they appear as "inbox messages" - NOT tasks.
|
|
158
|
-
- Use `slack-reply` with the inboxMessageId to respond directly to the user
|
|
159
|
-
- Use `inbox-delegate` with the inboxMessageId and agentId to create a task for a worker
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**What's NOT explained**:
|
|
163
|
-
- That thread context is included in messages
|
|
164
|
-
- How to interpret `<thread_context>` tags
|
|
165
|
-
- That the preview shown might be truncated
|
|
166
|
-
- How to access the full message content
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
### Component 6: Thread Follow-Up Routing (Working Correctly)
|
|
171
|
-
|
|
172
|
-
**Location**: `src/slack/router.ts:139-144`
|
|
173
|
-
|
|
174
|
-
When a message arrives in a thread, the router checks if an agent is already working on it:
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
if (matches.length === 0 && threadContext) {
|
|
178
|
-
const workingAgent = getAgentWorkingOnThread(threadContext.channelId, threadContext.threadTs);
|
|
179
|
-
if (workingAgent && workingAgent.status !== "offline") {
|
|
180
|
-
matches.push({ agent: workingAgent, matchedText: "thread follow-up" });
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Location**: `src/be/db.ts:1052-1083`
|
|
186
|
-
|
|
187
|
-
The `getAgentWorkingOnThread()` function checks:
|
|
188
|
-
1. `agent_tasks` table for workers with active tasks in that thread
|
|
189
|
-
2. `inbox_messages` table for leads with messages in that thread
|
|
190
|
-
|
|
191
|
-
---
|
|
192
|
-
|
|
193
|
-
### Component 7: Hook System Context (Limited)
|
|
194
|
-
|
|
195
|
-
**Location**: `src/hooks/hook.ts:141-200`
|
|
196
|
-
|
|
197
|
-
The hook system's "system tray" shows:
|
|
198
|
-
- Unread message count
|
|
199
|
-
- Mention count
|
|
200
|
-
- Task counts
|
|
201
|
-
|
|
202
|
-
It does NOT show:
|
|
203
|
-
- Slack message content
|
|
204
|
-
- Thread context
|
|
205
|
-
- Message previews
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## Code References
|
|
210
|
-
|
|
211
|
-
- `src/slack/handlers.ts:45-90` - Thread context retrieval (`getThreadContext()`)
|
|
212
|
-
- `src/slack/handlers.ts:213-247` - Inbox message creation with context
|
|
213
|
-
- `src/commands/runner.ts:368-382` - Prompt formatting with 100-char truncation
|
|
214
|
-
- `src/tools/slack-reply.ts` - Reply tool (internal inbox access)
|
|
215
|
-
- `src/tools/inbox-delegate.ts` - Delegate tool (internal inbox access)
|
|
216
|
-
- `src/be/db.ts:2610` - `getInboxMessageById()` database function
|
|
217
|
-
- `src/prompts/base-prompt.ts:20-24` - Lead agent Slack instructions
|
|
218
|
-
- `src/slack/router.ts:139-144` - Thread follow-up routing
|
|
219
|
-
|
|
220
|
-
## Architecture Documentation
|
|
221
|
-
|
|
222
|
-
### Data Flow: Slack Message to Lead Agent
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
1. Slack message arrives
|
|
226
|
-
└─> handlers.ts:147 (message event handler)
|
|
227
|
-
|
|
228
|
-
2. Thread context fetched
|
|
229
|
-
└─> handlers.ts:213-221 (getThreadContext())
|
|
230
|
-
└─> Returns: "<thread_context>\n...\n</thread_context>\n\n"
|
|
231
|
-
|
|
232
|
-
3. Full description assembled
|
|
233
|
-
└─> handlers.ts:221: fullTaskDescription = threadContext + taskDescription
|
|
234
|
-
|
|
235
|
-
4. Inbox message created (lead agents)
|
|
236
|
-
└─> handlers.ts:239-245 (createInboxMessage())
|
|
237
|
-
└─> Stores FULL content in database
|
|
238
|
-
|
|
239
|
-
5. Agent polls for triggers
|
|
240
|
-
└─> http.ts:400-412 (GET /poll)
|
|
241
|
-
└─> Returns claimed inbox messages with FULL content
|
|
242
|
-
|
|
243
|
-
6. Runner formats prompt
|
|
244
|
-
└─> runner.ts:368-382 (buildPromptForTrigger)
|
|
245
|
-
└─> TRUNCATES content to 100 chars
|
|
246
|
-
└─> Agent sees partial preview only
|
|
247
|
-
|
|
248
|
-
7. Agent tries to respond
|
|
249
|
-
└─> Cannot read full message
|
|
250
|
-
└─> No tool available for reading inbox
|
|
251
|
-
└─> Must guess context from truncated preview
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Key Observations
|
|
255
|
-
|
|
256
|
-
1. **Thread context is correctly captured** - The system fetches up to 20 messages with user names
|
|
257
|
-
2. **Thread context is correctly stored** - Full content saved in `inbox_messages` table
|
|
258
|
-
3. **Thread context is NOT correctly presented** - 100-char truncation cuts off most context
|
|
259
|
-
4. **No mechanism to retrieve full content** - Agent has no tool to read the full message
|
|
260
|
-
5. **Agent is not told about thread context** - Base prompt doesn't explain the format
|
|
261
|
-
|
|
262
|
-
## Historical Context (from thoughts/)
|
|
263
|
-
|
|
264
|
-
- `thoughts/shared/research/2025-12-18-slack-integration.md` - Original Slack integration research
|
|
265
|
-
- `thoughts/shared/plans/2026-01-12-lead-inbox-model.md` - Lead inbox model design
|
|
266
|
-
|
|
267
|
-
## Related Research
|
|
268
|
-
|
|
269
|
-
- `thoughts/shared/research/2026-01-13-lead-duplicate-trigger-processing.md` - Related trigger handling research
|
|
270
|
-
|
|
271
|
-
## Open Questions
|
|
272
|
-
|
|
273
|
-
1. Should the 100-character truncation limit be increased or removed?
|
|
274
|
-
2. Should a dedicated `read-inbox-message` MCP tool be created?
|
|
275
|
-
3. Should the base prompt explain the `<thread_context>` format?
|
|
276
|
-
4. Should follow-up messages in a thread show the previous response instead of full history?
|
|
277
|
-
5. Should the thread context be presented differently (e.g., separate from main message)?
|
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
date: 2026-01-15T13:15:00Z
|
|
3
|
-
topic: "ai-tracker Integration for Agent-Swarm Workers"
|
|
4
|
-
researcher: "Agent 16990304-76e4-4017-b991-f3e37b34cf73 (Researcher)"
|
|
5
|
-
status: "complete"
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Research: Integrating ai-tracker into Agent-Swarm Workers
|
|
9
|
-
|
|
10
|
-
## Executive Summary
|
|
11
|
-
|
|
12
|
-
This research investigates integrating `ai-tracker` from the `desplega-ai/ai-toolbox` repository into agent-swarm workers. Agent-swarm workers are Docker containers running Claude Code CLI in headless mode, which means ai-tracker's Claude Code hooks are directly applicable. The key requirement is adding environment variable support to ai-tracker for configurable database paths to enable per-agent tracking in a shared location.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## 1. ai-tracker Overview
|
|
17
|
-
|
|
18
|
-
### 1.1 What is ai-tracker?
|
|
19
|
-
|
|
20
|
-
**Source**: [desplega-ai/ai-toolbox/ai-tracker](https://github.com/desplega-ai/ai-toolbox/tree/main/ai-tracker)
|
|
21
|
-
**Package Name**: `cc-ai-tracker` (PyPI)
|
|
22
|
-
**License**: MIT
|
|
23
|
-
**Python Support**: 3.11, 3.12, 3.13
|
|
24
|
-
|
|
25
|
-
**Purpose**: Track what percentage of code changes in git repos are AI-generated (via Claude Code) versus human-made.
|
|
26
|
-
|
|
27
|
-
### 1.2 Installation Methods
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# Option 1: uvx (no install needed)
|
|
31
|
-
uvx cc-ai-tracker install
|
|
32
|
-
|
|
33
|
-
# Option 2: Local install with uv
|
|
34
|
-
uv tool install cc-ai-tracker
|
|
35
|
-
ai-tracker install
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### 1.3 How It Works
|
|
39
|
-
|
|
40
|
-
ai-tracker operates through three integrated components:
|
|
41
|
-
|
|
42
|
-
| Component | Function |
|
|
43
|
-
|-----------|----------|
|
|
44
|
-
| **Claude Code Hooks** | PreToolUse/PostToolUse hooks capture Edit/Write operations with line counts |
|
|
45
|
-
| **Git Post-commit Hook** | Attributes committed changes to AI or human based on the edit log |
|
|
46
|
-
| **CLI Statistics** | Queries SQLite database and displays formatted results |
|
|
47
|
-
|
|
48
|
-
**Data Flow:**
|
|
49
|
-
```
|
|
50
|
-
Claude Code Edit/Write → PostToolUse Hook → SQLite (edits table)
|
|
51
|
-
↓
|
|
52
|
-
Git Commit → Post-commit Hook → SQLite (commits table with AI/human attribution)
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### 1.4 Database and Configuration
|
|
56
|
-
|
|
57
|
-
| Setting | Current Value |
|
|
58
|
-
|---------|---------------|
|
|
59
|
-
| **Database** | `~/.config/ai-tracker/tracker.db` (SQLite with WAL) |
|
|
60
|
-
| **Config Dir** | `~/.config/ai-tracker/` |
|
|
61
|
-
| **Git Hooks** | `~/.config/ai-tracker/git-hooks/` |
|
|
62
|
-
| **Claude Settings** | `~/.claude/settings.json` |
|
|
63
|
-
|
|
64
|
-
### 1.5 Claude Code Hooks (from setup.py)
|
|
65
|
-
|
|
66
|
-
The `install` command adds these hooks to `~/.claude/settings.json`:
|
|
67
|
-
|
|
68
|
-
```json
|
|
69
|
-
{
|
|
70
|
-
"hooks": {
|
|
71
|
-
"PostToolUse": [{
|
|
72
|
-
"matcher": "Edit|Write",
|
|
73
|
-
"hooks": [{"type": "command", "command": "ai-tracker hook-post-tool"}]
|
|
74
|
-
}],
|
|
75
|
-
"PreToolUse": [{
|
|
76
|
-
"matcher": "Write",
|
|
77
|
-
"hooks": [{"type": "command", "command": "ai-tracker hook-pre-tool"}]
|
|
78
|
-
}]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### 1.6 CLI Commands
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
ai-tracker install # Install Claude Code + git hooks
|
|
87
|
-
ai-tracker uninstall # Remove all hooks
|
|
88
|
-
ai-tracker stats # Show all-time statistics
|
|
89
|
-
ai-tracker stats --graph # Stats + chart for last 7 days
|
|
90
|
-
ai-tracker stats --repo my-project # Filter by repository
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## 2. Agent-Swarm Worker Architecture
|
|
96
|
-
|
|
97
|
-
### 2.1 Overview
|
|
98
|
-
|
|
99
|
-
Agent-swarm workers are **Docker containers running Claude Code CLI in headless loop mode**. Each worker:
|
|
100
|
-
- Runs as a non-root `worker` user
|
|
101
|
-
- Has Claude Code CLI installed via official installer
|
|
102
|
-
- Uses MCP (Model Context Protocol) to communicate with the swarm server
|
|
103
|
-
- Has hooks configured in `~/.claude/settings.json`
|
|
104
|
-
|
|
105
|
-
### 2.2 Key Files in agent-swarm
|
|
106
|
-
|
|
107
|
-
| File | Purpose |
|
|
108
|
-
|------|---------|
|
|
109
|
-
| `Dockerfile.worker` | Worker container build (Ubuntu 24.04 base) |
|
|
110
|
-
| `docker-entrypoint.sh` | Container startup script |
|
|
111
|
-
| `src/cli.tsx` | Compiled agent-swarm binary |
|
|
112
|
-
| `plugin/` | Claude Code commands, agents, and skills |
|
|
113
|
-
|
|
114
|
-
### 2.3 Current Worker Hooks Configuration (Dockerfile.worker:89-101)
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{
|
|
118
|
-
"permissions": { "allow": ["mcp__agent-swarm__*"] },
|
|
119
|
-
"hooks": {
|
|
120
|
-
"SessionStart": [{"matcher": "*", "hooks": [{"type": "command", "command": "/usr/local/bin/agent-swarm hook"}]}],
|
|
121
|
-
"UserPromptSubmit": [{"matcher": "*", "hooks": [{"type": "command", "command": "/usr/local/bin/agent-swarm hook"}]}],
|
|
122
|
-
"PreToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "/usr/local/bin/agent-swarm hook"}]}],
|
|
123
|
-
"PostToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "/usr/local/bin/agent-swarm hook"}]}]
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### 2.4 Worker Environment Variables
|
|
129
|
-
|
|
130
|
-
| Variable | Purpose |
|
|
131
|
-
|----------|---------|
|
|
132
|
-
| `AGENT_ID` | UUID identifying the agent |
|
|
133
|
-
| `AGENT_ROLE` | "worker" or "lead" |
|
|
134
|
-
| `MCP_BASE_URL` | URL to MCP server |
|
|
135
|
-
| `API_KEY` | Authentication for MCP |
|
|
136
|
-
| `GITHUB_TOKEN` | Git operations authentication |
|
|
137
|
-
|
|
138
|
-
### 2.5 Container Initialization (docker-entrypoint.sh)
|
|
139
|
-
|
|
140
|
-
The entrypoint script:
|
|
141
|
-
1. Validates required env vars (CLAUDE_CODE_OAUTH_TOKEN, API_KEY)
|
|
142
|
-
2. Starts PM2 for background service management
|
|
143
|
-
3. Creates `/workspace/.mcp.json` for MCP configuration
|
|
144
|
-
4. Sets up git authentication if GITHUB_TOKEN provided
|
|
145
|
-
5. Installs plugins from desplega-ai marketplace
|
|
146
|
-
6. Executes optional `/workspace/start-up.*` script
|
|
147
|
-
7. Runs `/usr/local/bin/agent-swarm <role>` to start Claude Code
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## 3. Integration Plan
|
|
152
|
-
|
|
153
|
-
### 3.1 Required Changes to ai-tracker
|
|
154
|
-
|
|
155
|
-
**Issue**: ai-tracker has a **hardcoded database path** in `config.py`:
|
|
156
|
-
```python
|
|
157
|
-
def get_db_path() -> Path:
|
|
158
|
-
return get_config_dir() / "tracker.db" # Fixed to ~/.config/ai-tracker/
|
|
159
|
-
|
|
160
|
-
def get_config_dir() -> Path:
|
|
161
|
-
config_dir = Path.home() / ".config" / "ai-tracker"
|
|
162
|
-
config_dir.mkdir(parents=True, exist_ok=True)
|
|
163
|
-
return config_dir
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
**Proposed Fix**: Add environment variable support:
|
|
167
|
-
```python
|
|
168
|
-
def get_db_path() -> Path:
|
|
169
|
-
if custom_path := os.environ.get("AI_TRACKER_DB_PATH"):
|
|
170
|
-
path = Path(custom_path)
|
|
171
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
172
|
-
return path
|
|
173
|
-
return get_config_dir() / "tracker.db"
|
|
174
|
-
|
|
175
|
-
def get_config_dir() -> Path:
|
|
176
|
-
if custom_dir := os.environ.get("AI_TRACKER_CONFIG_DIR"):
|
|
177
|
-
config_dir = Path(custom_dir)
|
|
178
|
-
else:
|
|
179
|
-
config_dir = Path.home() / ".config" / "ai-tracker"
|
|
180
|
-
config_dir.mkdir(parents=True, exist_ok=True)
|
|
181
|
-
return config_dir
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
**GitHub Issue Required**: Create issue in `desplega-ai/ai-toolbox` repo requesting this feature.
|
|
185
|
-
|
|
186
|
-
### 3.2 Docker Integration
|
|
187
|
-
|
|
188
|
-
**Step 1: Install ai-tracker in Dockerfile.worker**
|
|
189
|
-
|
|
190
|
-
Add after the Claude CLI installation (around line 80):
|
|
191
|
-
```dockerfile
|
|
192
|
-
# Install uv for Python package management
|
|
193
|
-
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
194
|
-
ENV PATH="/home/worker/.local/bin:$PATH"
|
|
195
|
-
|
|
196
|
-
# Install ai-tracker
|
|
197
|
-
RUN uv tool install cc-ai-tracker
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
**Step 2: Add hooks to settings.json template**
|
|
201
|
-
|
|
202
|
-
Modify the settings.json in Dockerfile.worker to include ai-tracker hooks:
|
|
203
|
-
```json
|
|
204
|
-
{
|
|
205
|
-
"permissions": { "allow": ["mcp__agent-swarm__*"] },
|
|
206
|
-
"hooks": {
|
|
207
|
-
"PreToolUse": [
|
|
208
|
-
{"matcher": "*", "hooks": [{"type": "command", "command": "/usr/local/bin/agent-swarm hook"}]},
|
|
209
|
-
{"matcher": "Write", "hooks": [{"type": "command", "command": "ai-tracker hook-pre-tool"}]}
|
|
210
|
-
],
|
|
211
|
-
"PostToolUse": [
|
|
212
|
-
{"matcher": "*", "hooks": [{"type": "command", "command": "/usr/local/bin/agent-swarm hook"}]},
|
|
213
|
-
{"matcher": "Edit|Write", "hooks": [{"type": "command", "command": "ai-tracker hook-post-tool"}]}
|
|
214
|
-
]
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**Step 3: Configure per-agent database in docker-entrypoint.sh**
|
|
220
|
-
|
|
221
|
-
Add after the workspace initialization section:
|
|
222
|
-
```bash
|
|
223
|
-
# Configure ai-tracker for per-agent database
|
|
224
|
-
echo ""
|
|
225
|
-
echo "=== AI Tracker Configuration ==="
|
|
226
|
-
if [ -n "$AGENT_ID" ]; then
|
|
227
|
-
TRACKER_DIR="/workspace/shared/tracking"
|
|
228
|
-
mkdir -p "$TRACKER_DIR"
|
|
229
|
-
export AI_TRACKER_DB_PATH="${TRACKER_DIR}/${AGENT_ID}.db"
|
|
230
|
-
echo "AI Tracker DB: $AI_TRACKER_DB_PATH"
|
|
231
|
-
|
|
232
|
-
# Install git hooks for this agent
|
|
233
|
-
ai-tracker git-install --global 2>/dev/null || true
|
|
234
|
-
else
|
|
235
|
-
echo "AGENT_ID not set, using default ai-tracker path"
|
|
236
|
-
fi
|
|
237
|
-
echo "================================"
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### 3.3 Per-Agent Database Structure
|
|
241
|
-
|
|
242
|
-
```
|
|
243
|
-
/workspace/shared/tracking/
|
|
244
|
-
├── 16990304-76e4-4017-b991-f3e37b34cf73.db # Worker 1
|
|
245
|
-
├── d454d1a5-4df9-49bd-8a89-e58d6a657dc3.db # Lead Agent
|
|
246
|
-
├── 38d36438-58a0-45b5-8602-a5d52b07c2f1.db # Worker 2
|
|
247
|
-
└── .gitkeep
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Benefits:
|
|
251
|
-
- Each agent has isolated tracking data
|
|
252
|
-
- Shared volume allows aggregation/analysis
|
|
253
|
-
- No SQLite concurrency issues between agents
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## 4. Implementation Steps
|
|
258
|
-
|
|
259
|
-
### 4.1 Phase 1: ai-tracker Enhancement
|
|
260
|
-
|
|
261
|
-
1. **Create GitHub Issue** in `desplega-ai/ai-toolbox`:
|
|
262
|
-
- Title: "Add environment variable support for configurable database path"
|
|
263
|
-
- Request: `AI_TRACKER_DB_PATH` and `AI_TRACKER_CONFIG_DIR` env vars
|
|
264
|
-
- Use case: Multi-agent environments where each agent needs its own database
|
|
265
|
-
|
|
266
|
-
2. **Implement the change** (or wait for issue to be addressed):
|
|
267
|
-
- Modify `config.py` to check environment variables
|
|
268
|
-
- Update README with new configuration options
|
|
269
|
-
|
|
270
|
-
### 4.2 Phase 2: Dockerfile.worker Updates
|
|
271
|
-
|
|
272
|
-
1. Add `uv` installation for Python tool management
|
|
273
|
-
2. Install `cc-ai-tracker` via `uv tool install`
|
|
274
|
-
3. Update `settings.json` template with ai-tracker hooks
|
|
275
|
-
|
|
276
|
-
### 4.3 Phase 3: docker-entrypoint.sh Updates
|
|
277
|
-
|
|
278
|
-
1. Add tracking directory creation
|
|
279
|
-
2. Set `AI_TRACKER_DB_PATH` environment variable
|
|
280
|
-
3. Run `ai-tracker git-install` at startup
|
|
281
|
-
|
|
282
|
-
### 4.4 Phase 4: Testing
|
|
283
|
-
|
|
284
|
-
1. Build updated worker image
|
|
285
|
-
2. Start multiple workers with different AGENT_IDs
|
|
286
|
-
3. Verify each worker creates its own database
|
|
287
|
-
4. Run some Edit/Write operations and git commits
|
|
288
|
-
5. Check `ai-tracker stats` shows correct data per agent
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## 5. Alternative Approaches
|
|
293
|
-
|
|
294
|
-
### 5.1 Use uvx at Runtime (No Install Required)
|
|
295
|
-
|
|
296
|
-
Instead of installing ai-tracker in the image, use uvx in hooks:
|
|
297
|
-
|
|
298
|
-
```json
|
|
299
|
-
{
|
|
300
|
-
"hooks": {
|
|
301
|
-
"PostToolUse": [{
|
|
302
|
-
"matcher": "Edit|Write",
|
|
303
|
-
"hooks": [{"type": "command", "command": "AI_TRACKER_DB_PATH=/workspace/shared/tracking/${AGENT_ID}.db uvx cc-ai-tracker hook-post-tool"}]
|
|
304
|
-
}]
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
**Pros**: No image rebuild needed
|
|
310
|
-
**Cons**: Slower (uvx fetches package each time), env var interpolation may not work in JSON
|
|
311
|
-
|
|
312
|
-
### 5.2 Shared Single Database
|
|
313
|
-
|
|
314
|
-
Instead of per-agent databases, use a single shared database with agent_id column:
|
|
315
|
-
|
|
316
|
-
**Pros**: Easier aggregation
|
|
317
|
-
**Cons**: SQLite concurrency issues, needs schema changes in ai-tracker
|
|
318
|
-
|
|
319
|
-
### 5.3 External Tracking Service
|
|
320
|
-
|
|
321
|
-
Send tracking data to a centralized service instead of local SQLite:
|
|
322
|
-
|
|
323
|
-
**Pros**: Real-time aggregation, no storage management
|
|
324
|
-
**Cons**: Requires new service, network dependency
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
328
|
-
## 6. Recommendations
|
|
329
|
-
|
|
330
|
-
### 6.1 Recommended Approach
|
|
331
|
-
|
|
332
|
-
**Use per-agent databases with environment variable configuration:**
|
|
333
|
-
|
|
334
|
-
1. Create issue in ai-toolbox for env var support
|
|
335
|
-
2. Update Dockerfile.worker to install ai-tracker
|
|
336
|
-
3. Update docker-entrypoint.sh to set per-agent paths
|
|
337
|
-
4. Update settings.json to include ai-tracker hooks
|
|
338
|
-
|
|
339
|
-
This approach:
|
|
340
|
-
- Works with ai-tracker's existing architecture
|
|
341
|
-
- Minimal changes required
|
|
342
|
-
- Maintains agent isolation
|
|
343
|
-
- Allows easy aggregation later
|
|
344
|
-
|
|
345
|
-
### 6.2 Action Items
|
|
346
|
-
|
|
347
|
-
| Priority | Action | Owner |
|
|
348
|
-
|----------|--------|-------|
|
|
349
|
-
| 1 | Create GitHub issue in ai-toolbox | Swarm Lead |
|
|
350
|
-
| 2 | Implement env var support in ai-tracker | ai-toolbox maintainer |
|
|
351
|
-
| 3 | Update Dockerfile.worker | agent-swarm PR |
|
|
352
|
-
| 4 | Update docker-entrypoint.sh | agent-swarm PR |
|
|
353
|
-
| 5 | Test multi-agent tracking | QA |
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
## 7. Appendix
|
|
358
|
-
|
|
359
|
-
### 7.1 ai-tracker Source Files Reviewed
|
|
360
|
-
|
|
361
|
-
| File | Purpose |
|
|
362
|
-
|------|---------|
|
|
363
|
-
| `src/ai_tracker/config.py` | Path configuration (needs env var support) |
|
|
364
|
-
| `src/ai_tracker/setup.py` | Claude Code hook installation |
|
|
365
|
-
| `src/ai_tracker/cli.py` | CLI commands (install, stats, etc.) |
|
|
366
|
-
| `src/ai_tracker/git/install.py` | Git hook installation |
|
|
367
|
-
| `src/ai_tracker/hooks/log_claude_edit.py` | PostToolUse hook handler |
|
|
368
|
-
| `src/ai_tracker/hooks/capture_before_write.py` | PreToolUse hook handler |
|
|
369
|
-
|
|
370
|
-
### 7.2 agent-swarm Files Reviewed
|
|
371
|
-
|
|
372
|
-
| File | Purpose |
|
|
373
|
-
|------|---------|
|
|
374
|
-
| `Dockerfile.worker` | Worker container build |
|
|
375
|
-
| `docker-entrypoint.sh` | Container startup script |
|
|
376
|
-
| `DEPLOYMENT.md` | Deployment documentation |
|