@desplega.ai/agent-swarm 1.49.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.
Files changed (520) hide show
  1. package/README.md +1 -1
  2. package/openapi.json +582 -3
  3. package/package.json +10 -1
  4. package/src/agentmail/handlers.ts +65 -10
  5. package/src/agentmail/templates.ts +111 -0
  6. package/src/be/db.ts +591 -7
  7. package/src/be/migrations/014_prompt_templates.sql +33 -0
  8. package/src/be/migrations/015_workflow_workspace.sql +3 -0
  9. package/src/be/migrations/016_active_session_runner_session.sql +4 -0
  10. package/src/be/migrations/017_channel_activity_cursors.sql +6 -0
  11. package/src/be/migrations/018_fix_seed_double_version.sql +30 -0
  12. package/src/be/seed.ts +62 -0
  13. package/src/commands/runner.ts +186 -93
  14. package/src/commands/templates.ts +172 -0
  15. package/src/github/handlers.ts +292 -77
  16. package/src/github/mentions-aliases.test.ts +73 -0
  17. package/src/github/mentions.test.ts +3 -3
  18. package/src/github/mentions.ts +32 -6
  19. package/src/github/templates.ts +398 -0
  20. package/src/gitlab/handlers.ts +63 -22
  21. package/src/gitlab/templates.ts +140 -0
  22. package/src/heartbeat/heartbeat.ts +19 -10
  23. package/src/heartbeat/templates.ts +30 -0
  24. package/src/http/active-sessions.ts +27 -0
  25. package/src/http/index.ts +5 -2
  26. package/src/http/poll.ts +135 -14
  27. package/src/http/prompt-templates.ts +412 -0
  28. package/src/http/schedules.ts +35 -0
  29. package/src/http/workflows.ts +8 -0
  30. package/src/linear/sync.ts +28 -4
  31. package/src/linear/templates.ts +47 -0
  32. package/src/prompts/base-prompt.ts +33 -490
  33. package/src/prompts/registry.ts +57 -0
  34. package/src/prompts/resolver.ts +296 -0
  35. package/src/prompts/session-templates.ts +604 -0
  36. package/src/providers/claude-adapter.ts +15 -2
  37. package/src/providers/pi-mono-extension.ts +5 -1
  38. package/src/scheduler/scheduler.ts +125 -91
  39. package/src/server.ts +15 -0
  40. package/src/slack/assistant.ts +7 -4
  41. package/src/slack/channel-activity.ts +177 -0
  42. package/src/slack/handlers.ts +21 -6
  43. package/src/slack/templates.ts +55 -0
  44. package/src/tests/artifact-sdk.test.ts +12 -12
  45. package/src/tests/base-prompt.test.ts +49 -49
  46. package/src/tests/channel-activity.test.ts +363 -0
  47. package/src/tests/heartbeat.test.ts +1 -0
  48. package/src/tests/linear-webhook.test.ts +7 -3
  49. package/src/tests/pool-session-logs.test.ts +199 -0
  50. package/src/tests/prompt-template-github.test.ts +682 -0
  51. package/src/tests/prompt-template-remaining.test.ts +504 -0
  52. package/src/tests/prompt-template-resolver.test.ts +621 -0
  53. package/src/tests/prompt-template-session.test.ts +363 -0
  54. package/src/tests/prompt-templates-db.test.ts +616 -0
  55. package/src/tests/self-improvement.test.ts +8 -7
  56. package/src/tests/slack-metadata-inheritance.test.ts +1 -1
  57. package/src/tests/slack-thread-followups.test.ts +1 -1
  58. package/src/tests/structured-output.test.ts +0 -4
  59. package/src/tests/tool-annotations.test.ts +1 -1
  60. package/src/tests/update-profile-agentid.test.ts +248 -0
  61. package/src/tests/update-profile-auth.test.ts +195 -0
  62. package/src/tests/workflow-async-v2.test.ts +126 -4
  63. package/src/tests/workflow-definition-validation.test.ts +76 -0
  64. package/src/tests/workflow-retry-v2.test.ts +1 -1
  65. package/src/tests/workflow-schedule-trigger.test.ts +104 -0
  66. package/src/tests/workflow-workspace.test.ts +272 -0
  67. package/src/tools/prompt-templates/delete.ts +86 -0
  68. package/src/tools/prompt-templates/get.ts +89 -0
  69. package/src/tools/prompt-templates/index.ts +5 -0
  70. package/src/tools/prompt-templates/list.ts +95 -0
  71. package/src/tools/prompt-templates/preview.ts +84 -0
  72. package/src/tools/prompt-templates/set.ts +117 -0
  73. package/src/tools/store-progress.ts +22 -4
  74. package/src/tools/task-action.ts +20 -0
  75. package/src/tools/templates.ts +53 -0
  76. package/src/tools/tool-config.ts +7 -0
  77. package/src/tools/update-profile.ts +106 -34
  78. package/src/tools/workflows/create-workflow.ts +19 -1
  79. package/src/tools/workflows/update-workflow.ts +16 -1
  80. package/src/types.ts +55 -2
  81. package/src/workflows/definition.ts +30 -12
  82. package/src/workflows/engine.ts +40 -14
  83. package/src/workflows/executors/agent-task.ts +14 -3
  84. package/src/workflows/index.ts +1 -1
  85. package/src/workflows/resume.ts +98 -12
  86. package/src/workflows/triggers.ts +31 -2
  87. package/src/workflows/version.ts +2 -0
  88. package/.claude/settings.json +0 -84
  89. package/.claude/settings.local.json +0 -117
  90. package/.dockerignore +0 -61
  91. package/.editorconfig +0 -15
  92. package/.entire/settings.json +0 -4
  93. package/.env.docker.example +0 -56
  94. package/.env.example +0 -78
  95. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -78
  96. package/.github/ISSUE_TEMPLATE/community-template.yml +0 -77
  97. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  98. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -60
  99. package/.github/PULL_REQUEST_TEMPLATE/community-template.md +0 -29
  100. package/.github/workflows/ci.yml +0 -52
  101. package/.github/workflows/docker-and-deploy.yml +0 -132
  102. package/.github/workflows/merge-gate.yml +0 -233
  103. package/.opencode/plugins/entire.ts +0 -133
  104. package/.superset/config.json +0 -6
  105. package/.wts-config.json +0 -4
  106. package/.wts-setup.ts +0 -171
  107. package/CHANGELOG.md +0 -447
  108. package/CLAUDE.md +0 -521
  109. package/CONTRIBUTING.md +0 -315
  110. package/DEPLOYMENT.md +0 -622
  111. package/Dockerfile +0 -65
  112. package/Dockerfile.worker +0 -189
  113. package/MCP.md +0 -841
  114. package/UI.md +0 -40
  115. package/api-entrypoint.sh +0 -56
  116. package/assets/agent-swarm-logo-orange.png +0 -0
  117. package/assets/agent-swarm-logo.png +0 -0
  118. package/assets/agent-swarm.mp4 +0 -0
  119. package/assets/agent-swarm.png +0 -0
  120. package/biome.json +0 -39
  121. package/deploy/DEPLOY.md +0 -60
  122. package/deploy/agent-swarm.service +0 -17
  123. package/deploy/docker-push.ts +0 -30
  124. package/deploy/install.ts +0 -85
  125. package/deploy/prod-db.ts +0 -42
  126. package/deploy/uninstall.ts +0 -12
  127. package/deploy/update.ts +0 -21
  128. package/depot.json +0 -1
  129. package/docker-compose.example.yml +0 -350
  130. package/docker-compose.local.yml +0 -119
  131. package/docker-entrypoint.sh +0 -632
  132. package/docs-site/app/api/search/route.ts +0 -4
  133. package/docs-site/app/docs/[[...slug]]/page.tsx +0 -87
  134. package/docs-site/app/docs/layout.tsx +0 -12
  135. package/docs-site/app/globals.css +0 -24
  136. package/docs-site/app/layout.config.tsx +0 -34
  137. package/docs-site/app/layout.tsx +0 -119
  138. package/docs-site/app/llms-full.txt/route.ts +0 -11
  139. package/docs-site/app/llms.mdx/docs/[[...slug]]/route.ts +0 -24
  140. package/docs-site/app/llms.txt/route.ts +0 -8
  141. package/docs-site/app/page.tsx +0 -5
  142. package/docs-site/app/robots.ts +0 -13
  143. package/docs-site/app/sitemap.ts +0 -37
  144. package/docs-site/components/api-page.client.tsx +0 -4
  145. package/docs-site/components/api-page.tsx +0 -7
  146. package/docs-site/components/mdx/mermaid.tsx +0 -55
  147. package/docs-site/content/docs/(documentation)/architecture/agents.mdx +0 -117
  148. package/docs-site/content/docs/(documentation)/architecture/hooks.mdx +0 -77
  149. package/docs-site/content/docs/(documentation)/architecture/memory.mdx +0 -96
  150. package/docs-site/content/docs/(documentation)/architecture/meta.json +0 -4
  151. package/docs-site/content/docs/(documentation)/architecture/overview.mdx +0 -172
  152. package/docs-site/content/docs/(documentation)/concepts/epics.mdx +0 -98
  153. package/docs-site/content/docs/(documentation)/concepts/meta.json +0 -4
  154. package/docs-site/content/docs/(documentation)/concepts/scheduling.mdx +0 -136
  155. package/docs-site/content/docs/(documentation)/concepts/services.mdx +0 -104
  156. package/docs-site/content/docs/(documentation)/concepts/task-lifecycle.mdx +0 -148
  157. package/docs-site/content/docs/(documentation)/concepts/workflows.mdx +0 -209
  158. package/docs-site/content/docs/(documentation)/contributing.mdx +0 -158
  159. package/docs-site/content/docs/(documentation)/getting-started.mdx +0 -157
  160. package/docs-site/content/docs/(documentation)/guides/agentmail-integration.mdx +0 -79
  161. package/docs-site/content/docs/(documentation)/guides/deployment.mdx +0 -171
  162. package/docs-site/content/docs/(documentation)/guides/github-integration.mdx +0 -81
  163. package/docs-site/content/docs/(documentation)/guides/gitlab-integration.mdx +0 -93
  164. package/docs-site/content/docs/(documentation)/guides/linear-integration.mdx +0 -98
  165. package/docs-site/content/docs/(documentation)/guides/meta.json +0 -13
  166. package/docs-site/content/docs/(documentation)/guides/sentry-integration.mdx +0 -52
  167. package/docs-site/content/docs/(documentation)/guides/slack-integration.mdx +0 -179
  168. package/docs-site/content/docs/(documentation)/guides/x402-payments.mdx +0 -154
  169. package/docs-site/content/docs/(documentation)/index.mdx +0 -65
  170. package/docs-site/content/docs/(documentation)/meta.json +0 -19
  171. package/docs-site/content/docs/(documentation)/reference/cli.mdx +0 -241
  172. package/docs-site/content/docs/(documentation)/reference/environment-variables.mdx +0 -205
  173. package/docs-site/content/docs/(documentation)/reference/mcp-tools.mdx +0 -449
  174. package/docs-site/content/docs/(documentation)/reference/meta.json +0 -4
  175. package/docs-site/content/docs/api-reference/active-sessions.mdx +0 -9
  176. package/docs-site/content/docs/api-reference/agents.mdx +0 -9
  177. package/docs-site/content/docs/api-reference/channels.mdx +0 -9
  178. package/docs-site/content/docs/api-reference/config.mdx +0 -9
  179. package/docs-site/content/docs/api-reference/debug.mdx +0 -9
  180. package/docs-site/content/docs/api-reference/ecosystem.mdx +0 -9
  181. package/docs-site/content/docs/api-reference/epics.mdx +0 -9
  182. package/docs-site/content/docs/api-reference/index.mdx +0 -32
  183. package/docs-site/content/docs/api-reference/memory.mdx +0 -9
  184. package/docs-site/content/docs/api-reference/meta.json +0 -25
  185. package/docs-site/content/docs/api-reference/poll.mdx +0 -9
  186. package/docs-site/content/docs/api-reference/repos.mdx +0 -9
  187. package/docs-site/content/docs/api-reference/schedules.mdx +0 -9
  188. package/docs-site/content/docs/api-reference/session-data.mdx +0 -9
  189. package/docs-site/content/docs/api-reference/stats.mdx +0 -9
  190. package/docs-site/content/docs/api-reference/tasks.mdx +0 -9
  191. package/docs-site/content/docs/api-reference/trackers.mdx +0 -9
  192. package/docs-site/content/docs/api-reference/webhooks.mdx +0 -9
  193. package/docs-site/content/docs/api-reference/workflows.mdx +0 -9
  194. package/docs-site/content/docs/meta.json +0 -3
  195. package/docs-site/lib/get-llm-text.ts +0 -10
  196. package/docs-site/lib/openapi.ts +0 -23
  197. package/docs-site/lib/source.ts +0 -8
  198. package/docs-site/mdx-components.tsx +0 -13
  199. package/docs-site/next.config.mjs +0 -29
  200. package/docs-site/package.json +0 -35
  201. package/docs-site/pnpm-lock.yaml +0 -5407
  202. package/docs-site/postcss.config.mjs +0 -8
  203. package/docs-site/public/logo.png +0 -0
  204. package/docs-site/scripts/generate-docs.ts +0 -171
  205. package/docs-site/source.config.ts +0 -17
  206. package/docs-site/tsconfig.json +0 -46
  207. package/ecosystem.config.cjs +0 -66
  208. package/landing/next.config.ts +0 -14
  209. package/landing/package.json +0 -31
  210. package/landing/pnpm-lock.yaml +0 -1091
  211. package/landing/postcss.config.mjs +0 -8
  212. package/landing/public/apple-touch-icon.png +0 -0
  213. package/landing/public/favicon.ico +0 -0
  214. package/landing/public/logo.png +0 -0
  215. package/landing/public/og-image.png +0 -0
  216. package/landing/public/omghost-desplega.svg +0 -30
  217. package/landing/public/omghost-openfort.svg +0 -9
  218. package/landing/src/app/actions/waitlist.ts +0 -25
  219. package/landing/src/app/blog/openfort-hackathon/page.tsx +0 -863
  220. package/landing/src/app/blog/page.tsx +0 -162
  221. package/landing/src/app/blog/swarm-metrics/page.tsx +0 -685
  222. package/landing/src/app/examples/page.tsx +0 -174
  223. package/landing/src/app/examples/x402/page.tsx +0 -456
  224. package/landing/src/app/globals.css +0 -122
  225. package/landing/src/app/layout.tsx +0 -134
  226. package/landing/src/app/page.tsx +0 -27
  227. package/landing/src/app/robots.ts +0 -13
  228. package/landing/src/app/sitemap.ts +0 -44
  229. package/landing/src/components/architecture.tsx +0 -163
  230. package/landing/src/components/cta.tsx +0 -52
  231. package/landing/src/components/features.tsx +0 -160
  232. package/landing/src/components/footer.tsx +0 -100
  233. package/landing/src/components/hero.tsx +0 -217
  234. package/landing/src/components/how-it-works.tsx +0 -165
  235. package/landing/src/components/navbar.tsx +0 -147
  236. package/landing/src/components/waitlist.tsx +0 -110
  237. package/landing/src/components/why-choose.tsx +0 -149
  238. package/landing/src/components/workshops.tsx +0 -328
  239. package/landing/src/lib/utils.ts +0 -6
  240. package/landing/tsconfig.json +0 -41
  241. package/misc/transcripts/2026-03-09-pi-mono-e2e-verification.md +0 -154
  242. package/new-ui/CLAUDE.md +0 -92
  243. package/new-ui/README.md +0 -73
  244. package/new-ui/biome.json +0 -42
  245. package/new-ui/components.json +0 -21
  246. package/new-ui/index.html +0 -25
  247. package/new-ui/package.json +0 -49
  248. package/new-ui/pnpm-lock.yaml +0 -4845
  249. package/new-ui/public/logo.png +0 -0
  250. package/new-ui/src/api/client.ts +0 -814
  251. package/new-ui/src/api/hooks/index.ts +0 -64
  252. package/new-ui/src/api/hooks/use-agents.ts +0 -58
  253. package/new-ui/src/api/hooks/use-channels.ts +0 -115
  254. package/new-ui/src/api/hooks/use-config-api.ts +0 -46
  255. package/new-ui/src/api/hooks/use-costs.ts +0 -122
  256. package/new-ui/src/api/hooks/use-db-query.ts +0 -29
  257. package/new-ui/src/api/hooks/use-epics.ts +0 -75
  258. package/new-ui/src/api/hooks/use-repos.ts +0 -61
  259. package/new-ui/src/api/hooks/use-schedules.ts +0 -81
  260. package/new-ui/src/api/hooks/use-services.ts +0 -16
  261. package/new-ui/src/api/hooks/use-stats.ts +0 -27
  262. package/new-ui/src/api/hooks/use-tasks.ts +0 -89
  263. package/new-ui/src/api/hooks/use-workflows.ts +0 -109
  264. package/new-ui/src/api/types.ts +0 -549
  265. package/new-ui/src/app/App.tsx +0 -13
  266. package/new-ui/src/app/providers.tsx +0 -32
  267. package/new-ui/src/app/router.tsx +0 -52
  268. package/new-ui/src/components/layout/app-header.tsx +0 -47
  269. package/new-ui/src/components/layout/app-sidebar.tsx +0 -128
  270. package/new-ui/src/components/layout/breadcrumbs.tsx +0 -57
  271. package/new-ui/src/components/layout/config-guard.tsx +0 -22
  272. package/new-ui/src/components/layout/root-layout.tsx +0 -40
  273. package/new-ui/src/components/layout/swarm-switcher.tsx +0 -85
  274. package/new-ui/src/components/shared/command-menu.tsx +0 -131
  275. package/new-ui/src/components/shared/data-grid.tsx +0 -141
  276. package/new-ui/src/components/shared/empty-state.tsx +0 -24
  277. package/new-ui/src/components/shared/error-boundary.tsx +0 -72
  278. package/new-ui/src/components/shared/json-viewer.tsx +0 -47
  279. package/new-ui/src/components/shared/name-connection-modal.tsx +0 -99
  280. package/new-ui/src/components/shared/page-skeleton.tsx +0 -16
  281. package/new-ui/src/components/shared/session-log-viewer.tsx +0 -364
  282. package/new-ui/src/components/shared/stats-bar.tsx +0 -132
  283. package/new-ui/src/components/shared/status-badge.tsx +0 -131
  284. package/new-ui/src/components/shared/usage-summary.tsx +0 -179
  285. package/new-ui/src/components/ui/alert-dialog.tsx +0 -176
  286. package/new-ui/src/components/ui/alert.tsx +0 -60
  287. package/new-ui/src/components/ui/avatar.tsx +0 -96
  288. package/new-ui/src/components/ui/badge.tsx +0 -46
  289. package/new-ui/src/components/ui/button.tsx +0 -62
  290. package/new-ui/src/components/ui/card.tsx +0 -75
  291. package/new-ui/src/components/ui/command.tsx +0 -160
  292. package/new-ui/src/components/ui/dialog.tsx +0 -143
  293. package/new-ui/src/components/ui/dropdown-menu.tsx +0 -226
  294. package/new-ui/src/components/ui/input.tsx +0 -21
  295. package/new-ui/src/components/ui/label.tsx +0 -19
  296. package/new-ui/src/components/ui/progress.tsx +0 -26
  297. package/new-ui/src/components/ui/scroll-area.tsx +0 -54
  298. package/new-ui/src/components/ui/select.tsx +0 -175
  299. package/new-ui/src/components/ui/separator.tsx +0 -28
  300. package/new-ui/src/components/ui/sheet.tsx +0 -132
  301. package/new-ui/src/components/ui/sidebar.tsx +0 -691
  302. package/new-ui/src/components/ui/skeleton.tsx +0 -13
  303. package/new-ui/src/components/ui/sonner.tsx +0 -35
  304. package/new-ui/src/components/ui/switch.tsx +0 -33
  305. package/new-ui/src/components/ui/table.tsx +0 -92
  306. package/new-ui/src/components/ui/tabs.tsx +0 -79
  307. package/new-ui/src/components/ui/textarea.tsx +0 -18
  308. package/new-ui/src/components/ui/tooltip.tsx +0 -51
  309. package/new-ui/src/components/workflows/action-node.tsx +0 -53
  310. package/new-ui/src/components/workflows/condition-node.tsx +0 -50
  311. package/new-ui/src/components/workflows/graph-utils.ts +0 -124
  312. package/new-ui/src/components/workflows/json-tree.tsx +0 -189
  313. package/new-ui/src/components/workflows/node-styles.ts +0 -10
  314. package/new-ui/src/components/workflows/step-detail-sheet.tsx +0 -87
  315. package/new-ui/src/components/workflows/trigger-node.tsx +0 -41
  316. package/new-ui/src/components/workflows/workflow-graph.tsx +0 -65
  317. package/new-ui/src/hooks/use-auto-scroll.ts +0 -82
  318. package/new-ui/src/hooks/use-config.ts +0 -203
  319. package/new-ui/src/hooks/use-keyboard-shortcuts.ts +0 -41
  320. package/new-ui/src/hooks/use-mobile.ts +0 -19
  321. package/new-ui/src/hooks/use-theme.ts +0 -60
  322. package/new-ui/src/lib/config.ts +0 -188
  323. package/new-ui/src/lib/slugs.ts +0 -71
  324. package/new-ui/src/lib/utils.ts +0 -120
  325. package/new-ui/src/main.tsx +0 -11
  326. package/new-ui/src/pages/agents/[id]/page.tsx +0 -492
  327. package/new-ui/src/pages/agents/page.tsx +0 -134
  328. package/new-ui/src/pages/chat/page.tsx +0 -674
  329. package/new-ui/src/pages/config/page.tsx +0 -1109
  330. package/new-ui/src/pages/dashboard/page.tsx +0 -454
  331. package/new-ui/src/pages/debug/page.tsx +0 -275
  332. package/new-ui/src/pages/epics/[id]/page.tsx +0 -809
  333. package/new-ui/src/pages/epics/page.tsx +0 -321
  334. package/new-ui/src/pages/not-found/page.tsx +0 -18
  335. package/new-ui/src/pages/repos/page.tsx +0 -369
  336. package/new-ui/src/pages/schedules/[id]/page.tsx +0 -664
  337. package/new-ui/src/pages/schedules/page.tsx +0 -477
  338. package/new-ui/src/pages/services/page.tsx +0 -128
  339. package/new-ui/src/pages/tasks/[id]/page.tsx +0 -670
  340. package/new-ui/src/pages/tasks/page.tsx +0 -592
  341. package/new-ui/src/pages/usage/page.tsx +0 -195
  342. package/new-ui/src/pages/workflow-runs/[id]/page.tsx +0 -363
  343. package/new-ui/src/pages/workflows/[id]/page.tsx +0 -417
  344. package/new-ui/src/pages/workflows/page.tsx +0 -266
  345. package/new-ui/src/styles/ag-grid.css +0 -36
  346. package/new-ui/src/styles/globals.css +0 -213
  347. package/new-ui/test-results/.last-run.json +0 -4
  348. package/new-ui/tsconfig.app.json +0 -34
  349. package/new-ui/tsconfig.json +0 -4
  350. package/new-ui/tsconfig.node.json +0 -26
  351. package/new-ui/vercel.json +0 -4
  352. package/new-ui/vite.config.ts +0 -28
  353. package/plugin/README.md +0 -1
  354. package/plugin/build-pi-skills.ts +0 -233
  355. package/plugin/hooks/hooks.json +0 -71
  356. package/prek.toml +0 -75
  357. package/pyproject.toml +0 -9
  358. package/scripts/check-db-boundary.sh +0 -60
  359. package/scripts/e2e-docker-provider.ts +0 -820
  360. package/scripts/e2e-io-schemas-test.ts +0 -807
  361. package/scripts/e2e-provider-test.ts +0 -220
  362. package/scripts/e2e-workflow-redesign.sh +0 -229
  363. package/scripts/e2e-workflow-test.sh +0 -285
  364. package/scripts/e2e-workflow-test.ts +0 -857
  365. package/scripts/generate-mcp-docs.ts +0 -415
  366. package/scripts/generate-openapi.ts +0 -26
  367. package/scripts/measure-tool-tokens.ts +0 -118
  368. package/scripts/x402-e2e-test.ts +0 -195
  369. package/scripts/x402-test-server.ts +0 -236
  370. package/scripts/x402-testnet-e2e.ts +0 -668
  371. package/slack-manifest.json +0 -88
  372. package/templates-ui/README.md +0 -46
  373. package/templates-ui/components.json +0 -17
  374. package/templates-ui/eslint.config.mjs +0 -18
  375. package/templates-ui/next.config.ts +0 -7
  376. package/templates-ui/package.json +0 -35
  377. package/templates-ui/pnpm-lock.yaml +0 -4571
  378. package/templates-ui/postcss.config.mjs +0 -7
  379. package/templates-ui/public/file.svg +0 -1
  380. package/templates-ui/public/globe.svg +0 -1
  381. package/templates-ui/public/logo.png +0 -0
  382. package/templates-ui/public/next.svg +0 -1
  383. package/templates-ui/public/vercel.svg +0 -1
  384. package/templates-ui/public/window.svg +0 -1
  385. package/templates-ui/src/app/[category]/[name]/page.tsx +0 -89
  386. package/templates-ui/src/app/api/templates/[...slug]/route.ts +0 -52
  387. package/templates-ui/src/app/api/templates/route.ts +0 -18
  388. package/templates-ui/src/app/builder/page.tsx +0 -37
  389. package/templates-ui/src/app/globals.css +0 -94
  390. package/templates-ui/src/app/layout.tsx +0 -79
  391. package/templates-ui/src/app/page.tsx +0 -38
  392. package/templates-ui/src/app/robots.ts +0 -11
  393. package/templates-ui/src/app/sitemap.ts +0 -31
  394. package/templates-ui/src/components/compose-builder.tsx +0 -442
  395. package/templates-ui/src/components/compose-preview.tsx +0 -117
  396. package/templates-ui/src/components/file-preview.tsx +0 -77
  397. package/templates-ui/src/components/footer.tsx +0 -40
  398. package/templates-ui/src/components/header.tsx +0 -41
  399. package/templates-ui/src/components/template-card.tsx +0 -87
  400. package/templates-ui/src/components/template-detail.tsx +0 -125
  401. package/templates-ui/src/components/template-gallery.tsx +0 -263
  402. package/templates-ui/src/components/ui/badge.tsx +0 -36
  403. package/templates-ui/src/components/ui/button.tsx +0 -57
  404. package/templates-ui/src/components/ui/card.tsx +0 -76
  405. package/templates-ui/src/components/ui/separator.tsx +0 -31
  406. package/templates-ui/src/components/ui/tooltip.tsx +0 -32
  407. package/templates-ui/src/lib/compose-generator.ts +0 -241
  408. package/templates-ui/src/lib/templates.ts +0 -137
  409. package/templates-ui/src/lib/utils.ts +0 -6
  410. package/templates-ui/tsconfig.json +0 -34
  411. package/thoughts/research/2026-02-28-openfort-viem-x402-research.md +0 -679
  412. package/thoughts/research/2026-02-28-x402-payments-research.md +0 -686
  413. package/thoughts/researcher/plans/2026-02-20-agent-self-improvement-plan.md +0 -282
  414. package/thoughts/researcher/research/2026-02-20-agent-self-improvement.md +0 -492
  415. package/thoughts/shared/plans/.gitkeep +0 -0
  416. package/thoughts/shared/plans/2025-12-18-slack-integration.md +0 -1195
  417. package/thoughts/shared/plans/2025-12-19-agent-log-streaming.md +0 -732
  418. package/thoughts/shared/plans/2025-12-19-role-based-swarm-plugin.md +0 -361
  419. package/thoughts/shared/plans/2025-12-20-mobile-responsive-ui.md +0 -501
  420. package/thoughts/shared/plans/2025-12-20-startup-team-swarm.md +0 -560
  421. package/thoughts/shared/plans/2025-12-23-runner-level-polling.md +0 -934
  422. package/thoughts/shared/plans/2025-12-23-runner-session-logs.md +0 -1000
  423. package/thoughts/shared/plans/2025-12-23-worker-lead-spawn-triggers.md +0 -568
  424. package/thoughts/shared/plans/2026-01-09-inverse-teleport.md +0 -1516
  425. package/thoughts/shared/plans/2026-01-12-agent-rename-pm2-control.md +0 -1133
  426. package/thoughts/shared/plans/2026-01-12-github-app-integration.md +0 -380
  427. package/thoughts/shared/plans/2026-01-12-lead-inbox-model.md +0 -876
  428. package/thoughts/shared/plans/2026-01-12-ralph-wiggum-integration.md +0 -463
  429. package/thoughts/shared/plans/2026-01-13-agent-concurrency.md +0 -691
  430. package/thoughts/shared/plans/2026-01-13-github-assignment-handling.md +0 -690
  431. package/thoughts/shared/plans/2026-01-13-prevent-duplicate-trigger-processing.md +0 -1071
  432. package/thoughts/shared/plans/2026-01-14-fix-slack-thread-context.md +0 -507
  433. package/thoughts/shared/plans/2026-01-15-scheduled-tasks-implementation.md +0 -565
  434. package/thoughts/shared/plans/2026-01-15-usage-cost-tracking-ui.md +0 -1479
  435. package/thoughts/shared/plans/2026-01-16-epics-feature-implementation.md +0 -1230
  436. package/thoughts/shared/plans/2026-02-26-mcp-tool-context-reduction.md +0 -282
  437. package/thoughts/shared/plans/2026-03-02-claude-context-mode-integration.md +0 -328
  438. package/thoughts/shared/plans/2026-03-02-code-level-heartbeat.md +0 -224
  439. package/thoughts/shared/research/.gitkeep +0 -0
  440. package/thoughts/shared/research/2025-01-09-inverse-teleport-plan-review.md +0 -420
  441. package/thoughts/shared/research/2025-12-18-slack-integration.md +0 -442
  442. package/thoughts/shared/research/2025-12-19-agent-log-streaming.md +0 -339
  443. package/thoughts/shared/research/2025-12-19-agent-secrets-cli-research.md +0 -390
  444. package/thoughts/shared/research/2025-12-21-gemini-cli-integration.md +0 -376
  445. package/thoughts/shared/research/2025-12-22-runner-loop-architecture.md +0 -582
  446. package/thoughts/shared/research/2025-12-22-setup-experience-improvements.md +0 -264
  447. package/thoughts/shared/research/2026-01-13-lead-duplicate-trigger-processing.md +0 -223
  448. package/thoughts/shared/research/2026-01-14-lead-slack-thread-context.md +0 -277
  449. package/thoughts/shared/research/2026-01-15-ai-tracker-agent-swarm-integration.md +0 -376
  450. package/thoughts/shared/research/2026-01-15-auto-starting-processes-in-worker-containers.md +0 -787
  451. package/thoughts/shared/research/2026-01-15-scheduled-tasks.md +0 -390
  452. package/thoughts/shared/research/2026-01-16-epics-feature-research.md +0 -437
  453. package/thoughts/shared/research/2026-02-26-cliffy-mcp-tools.md +0 -159
  454. package/thoughts/shared/research/2026-03-03-database-migration-system-refactor.md +0 -337
  455. package/thoughts/swarm-researcher/plans/2026-02-23-openclaw-improvements-plan.md +0 -778
  456. package/thoughts/swarm-researcher/plans/2026-02-26-artifacts-localtunnel-plan.md +0 -1269
  457. package/thoughts/swarm-researcher/research/2026-02-23-openclaw-vs-agent-swarm-comparison.md +0 -411
  458. package/thoughts/swarm-researcher/research/2026-02-26-artifacts-localtunnel.md +0 -724
  459. package/thoughts/taras/brainstorms/2026-03-20-prompt-template-registry.md +0 -443
  460. package/thoughts/taras/brainstorms/2026-03-20-setup-cli-onboarding.md +0 -307
  461. package/thoughts/taras/plans/2026-01-22-agent-swarm-schemas.md +0 -98
  462. package/thoughts/taras/plans/2026-01-28-per-worker-claude-md.md +0 -617
  463. package/thoughts/taras/plans/2026-01-28-sentry-cli-integration.md +0 -214
  464. package/thoughts/taras/plans/2026-02-20-auto-improvement.md +0 -803
  465. package/thoughts/taras/plans/2026-02-20-env-management.md +0 -538
  466. package/thoughts/taras/plans/2026-02-20-memory-system.md +0 -882
  467. package/thoughts/taras/plans/2026-02-20-repos-knowledge.md +0 -806
  468. package/thoughts/taras/plans/2026-02-20-session-attach.md +0 -647
  469. package/thoughts/taras/plans/2026-02-20-worker-identity.md +0 -820
  470. package/thoughts/taras/plans/2026-02-25-feat-new-ui-visual-redesign-plan.md +0 -768
  471. package/thoughts/taras/plans/2026-03-04-fix-buildSystemPrompt-missing-fields.md +0 -77
  472. package/thoughts/taras/plans/2026-03-04-new-ui-missing-actions.md +0 -543
  473. package/thoughts/taras/plans/2026-03-06-one-time-scheduled-tasks.md +0 -373
  474. package/thoughts/taras/plans/2026-03-08-memory-self-improvement-enhancements.md +0 -512
  475. package/thoughts/taras/plans/2026-03-08-pi-mono-provider-implementation.md +0 -919
  476. package/thoughts/taras/plans/2026-03-09-templates-registry.md +0 -723
  477. package/thoughts/taras/plans/2026-03-10-task-working-directory.md +0 -371
  478. package/thoughts/taras/plans/2026-03-11-archil-per-agent-write-strategy.md +0 -621
  479. package/thoughts/taras/plans/2026-03-12-eliminate-inbox-route-to-tasks.md +0 -61
  480. package/thoughts/taras/plans/2026-03-12-slack-thread-followup-additive.md +0 -488
  481. package/thoughts/taras/plans/2026-03-13-slack-ai-improvements.md +0 -644
  482. package/thoughts/taras/plans/2026-03-16-route-wrapper-openapi.md +0 -636
  483. package/thoughts/taras/plans/2026-03-17-multi-api-config.md +0 -444
  484. package/thoughts/taras/plans/2026-03-18-agent-fs-integration.md +0 -591
  485. package/thoughts/taras/plans/2026-03-18-debug-db-explorer.md +0 -446
  486. package/thoughts/taras/plans/2026-03-18-workflow-redesign.md +0 -987
  487. package/thoughts/taras/plans/2026-03-19-compound-learnings.md +0 -403
  488. package/thoughts/taras/plans/2026-03-19-ticket-tracker-linear-integration.md +0 -860
  489. package/thoughts/taras/plans/2026-03-19-workflow-io-schemas-and-bugs.md +0 -899
  490. package/thoughts/taras/plans/2026-03-20-setup-cli-onboarding.md +0 -874
  491. package/thoughts/taras/plans/2026-03-20-workflow-structured-output-validation-workspace.md +0 -723
  492. package/thoughts/taras/research/2026-01-22-vercel-cli-integration.md +0 -287
  493. package/thoughts/taras/research/2026-01-27-excessive-polling-issue.md +0 -311
  494. package/thoughts/taras/research/2026-01-28-per-worker-claude-md.md +0 -383
  495. package/thoughts/taras/research/2026-01-28-sentry-cli-integration.md +0 -240
  496. package/thoughts/taras/research/2026-02-19-agent-native-swarm-architecture.md +0 -390
  497. package/thoughts/taras/research/2026-02-19-swarm-gaps-implementation.md +0 -594
  498. package/thoughts/taras/research/2026-02-25-dashboard-ui-design-best-practices.md +0 -825
  499. package/thoughts/taras/research/2026-02-26-task-detail-page-redesign.md +0 -393
  500. package/thoughts/taras/research/2026-03-03-new-ui-missing-actions.md +0 -168
  501. package/thoughts/taras/research/2026-03-05-pi-mono-provider-research.md +0 -230
  502. package/thoughts/taras/research/2026-03-06-workflow-engine-design.md +0 -445
  503. package/thoughts/taras/research/2026-03-08-drive-loop-concept.md +0 -375
  504. package/thoughts/taras/research/2026-03-08-pi-mono-deep-dive.md +0 -869
  505. package/thoughts/taras/research/2026-03-09-templates-registry.md +0 -373
  506. package/thoughts/taras/research/2026-03-10-agent-working-directory.md +0 -223
  507. package/thoughts/taras/research/2026-03-10-configurable-event-prompts.md +0 -339
  508. package/thoughts/taras/research/2026-03-11-archil-production-setup.md +0 -181
  509. package/thoughts/taras/research/2026-03-11-archil-shared-disk-write-strategies.md +0 -437
  510. package/thoughts/taras/research/2026-03-13-slack-ai-features.md +0 -258
  511. package/thoughts/taras/research/2026-03-16-openapi-docs-generation.md +0 -335
  512. package/thoughts/taras/research/2026-03-16-route-wrapper-openapi.md +0 -670
  513. package/thoughts/taras/research/2026-03-16-slack-thread-followups-e2e.md +0 -54
  514. package/thoughts/taras/research/2026-03-18-agent-fs-integration.md +0 -558
  515. package/thoughts/taras/research/2026-03-18-linear-integration-finalization.md +0 -526
  516. package/thoughts/taras/research/2026-03-18-workflow-redesign.md +0 -797
  517. package/thoughts/taras/research/2026-03-19-workflow-node-io-schemas-and-bugs.md +0 -563
  518. package/thoughts/taras/research/2026-03-19-workflow-structured-output-validation-workspace.md +0 -486
  519. package/thoughts/taras/research/2026-03-20-prompt-template-registry.md +0 -469
  520. package/tsconfig.json +0 -37
@@ -1,594 +0,0 @@
1
- ---
2
- date: 2026-02-19T22:10:00Z
3
- researcher: Claude
4
- git_commit: e10703529a2508b9070d7bdfc61db2a2e8e4b241
5
- branch: main
6
- repository: agent-swarm
7
- topic: "Swarm Gaps Implementation Research: Identity, Memory, Sessions, Repos, Auto-improvement, Env Management"
8
- tags: [research, architecture, identity, memory, sessions, repos, auto-improvement, env-management, agent-native]
9
- status: complete
10
- autonomy: verbose
11
- last_updated: 2026-02-20
12
- last_updated_by: Claude
13
- ---
14
-
15
- # Research: Swarm Gaps Implementation
16
-
17
- **Date**: 2026-02-19
18
- **Researcher**: Claude
19
- **Git Commit**: e107035
20
- **Branch**: main
21
-
22
- ## Research Question
23
-
24
- Based on the agent-native architecture research (`thoughts/taras/research/2026-02-19-agent-native-swarm-architecture.md`), what changes are needed in the agent-swarm codebase to implement 6 identified gaps: (1) worker identity files, (2) memory system with vector search, (3) session attachment, (4) repos knowledge, (5) auto-improvement scripts, (6) env management API?
25
-
26
- ## Summary
27
-
28
- The agent-swarm codebase has strong infrastructure scaffolding (hooks, DB migrations, MCP tools, Docker volumes, shared filesystem) but lacks the connective tissue to make agents persistent, knowledge-accumulating entities. Each of the 6 gaps maps to concrete changes in existing files -- no major architectural rewrites needed.
29
-
30
- **Identity** (Gap 1) requires new DB columns (`soulMd`, `identityMd`) on the `agents` table, with identity/soul content injected via `--append-system-prompt` (immutable persona) while `~/.claude/CLAUDE.md` remains the agent's mutable personal notes. Generation templates should include behavioral instructions ("embody this persona", "this file is yours to evolve").
31
-
32
- **Memory** (Gap 2) is the largest gap. Today, data accumulates across 7 storage subsystems with zero cross-system search. Implementation requires: (a) a new `agent_memory` table with sqlite-vec for vector search, (b) OpenAI embeddings API integration (`text-embedding-3-small` at 512 dims), (c) MCP tools for search and retrieval (`memory-search`, `memory-get`), (d) file-based auto-indexing via hooks (files written to `{personal|shared}/memory/` are automatically indexed), and (e) automatic session summarization at `Stop` and `PreCompact` hooks.
33
-
34
- **Session attachment** (Gap 3) is surprisingly tractable. The runner currently uses `-p` (one-shot prompt mode) exclusively and never uses `--resume`/`--continue`. Adding a `parentTaskId` field to `agent_tasks`, capturing Claude CLI session IDs from stream-json output, and switching from `-p` to `--resume` for child tasks would enable session continuity. The empty `PreCompact` hook can inject goal reminders.
35
-
36
- **Repos knowledge** (Gap 4) needs a new `swarm_repos` config table, auto-clone logic in the entrypoint or runner, and CLAUDE.md composition that appends repo-level CLAUDE.md content. The `githubRepo` field already exists on tasks/epics but is unused for workspace setup.
37
-
38
- **Auto-improvement** (Gap 5) can leverage the existing startup script mechanism (`/workspace/start-up.*` in docker-entrypoint.sh). Since the startup script may already exist via Docker volume mount, the DB-stored script content would be *prepended* to the existing mounted file rather than replacing it. This combines operator-managed base setup (mount) with agent-learned additions (DB).
39
-
40
- **Env management** (Gap 6) requires a new `config` table with `scope` (global/agent/repo) and `key`/`value` columns, REST API endpoints, UI components, and injection into Docker env at container start or via MCP tool responses.
41
-
42
- ## Detailed Findings
43
-
44
- ### Gap 1: Worker Identity (SOUL.md / IDENTITY.md)
45
-
46
- #### What Exists Today
47
-
48
- Agent profiles are stored in the `agents` table (`src/be/db.ts:48-59`) with identity fields: `name`, `description`, `role`, `capabilities`, `claudeMd`. The `claudeMd` field (64KB TEXT, added at line 499) holds the only persistent per-agent instructions.
49
-
50
- The identity lifecycle:
51
- 1. **Registration** (`src/tools/join-swarm.ts:99-112`): `generateDefaultClaudeMd()` creates a template with name/role/capabilities headers plus empty Learnings/Preferences/Important Context sections (`src/be/db.ts:2129-2169`).
52
- 2. **Session start** (`src/hooks/hook.ts:496-508`): Agent's `claudeMd` is fetched from DB via `GET /me` and written to `~/.claude/CLAUDE.md`.
53
- 3. **Session end** (`src/hooks/hook.ts:574-581`): `syncClaudeMdToServer()` reads `~/.claude/CLAUDE.md` and PUTs it back to DB.
54
- - **Consideration**: Rather than only syncing on Stop, we could add a `PostToolUse` hook for Edit/Write operations targeting `~/.claude/CLAUDE.md` to persist changes in real-time. This would prevent data loss if a session crashes before the Stop hook fires.
55
- 4. **Manual update**: `update-profile` MCP tool (`src/tools/update-profile.ts:26-31`) or `PUT /api/agents/:id/profile` (`src/http.ts:968-1048`).
56
-
57
- The base system prompt (`src/prompts/base-prompt.ts:1-5`) injects only the structural role and agent ID:
58
- ```
59
- You are part of an agent swarm, your role is: {role} and your unique identifier is {agentId}.
60
- ```
61
- The agent's `name`, `description`, `role` field (from profile), and `capabilities` are NOT in the system prompt.
62
-
63
- #### What's Missing
64
-
65
- - No `soulMd` or `identityMd` DB columns
66
- - No SOUL.md or IDENTITY.md files written to the filesystem
67
- - No behavioral instructions telling the agent to "embody" its persona
68
- - No self-evolution encouragement ("this file is yours to evolve")
69
- - The base system prompt has no awareness of CLAUDE.md content
70
- - The `--append-system-prompt` path and `~/.claude/CLAUDE.md` path are completely independent
71
-
72
- #### What Would Need to Change
73
-
74
- **DB Schema**: Add `soulMd TEXT` and `identityMd TEXT` columns to `agents` table using the existing try-catch ALTER TABLE migration pattern (like `claudeMd` at line 497-502). Or alternatively, keep them as structured sections within `claudeMd` to avoid schema changes.
75
-
76
- **Hook lifecycle**: The `SessionStart` handler (`hook.ts:496-508`) currently writes only `claudeMd` to `~/.claude/CLAUDE.md`. It would need to compose the final file from multiple sources: identity + soul + CLAUDE.md + (later) repo CLAUDE.md.
77
-
78
- **Generation templates**: New functions `generateDefaultSoulMd()` and `generateDefaultIdentityMd()` called alongside `generateDefaultClaudeMd()` in `join-swarm.ts:99-112`. The SOUL.md template should include behavioral directives ("Embody this persona", "This file is yours to evolve").
79
-
80
- **Profile sync**: `syncClaudeMdToServer()` (`hook.ts:238-261`) would need to either parse the composed file back into sections, or track sections with markers for extraction. The `PUT /api/agents/:id/profile` endpoint would need new fields.
81
-
82
- **Key design decision**: Split content across two injection points to avoid duplication:
83
- - **`--append-system-prompt`** (via `getBasePrompt()`): Inject soul, identity, and worker info here. This is read-only context the agent shouldn't edit -- persona, behavioral directives, role definition. The runner already fetches agent info for registration, so this data is available at spawn time.
84
- - **`~/.claude/CLAUDE.md`**: Keep this for the agent's personal mutable notes only (Learnings, Preferences, Important Context). This is what the agent reads and edits during sessions, synced back on Stop.
85
-
86
- This avoids repeating content across both injection points and keeps a clean separation: system prompt = who you are (immutable), CLAUDE.md = what you've learned (mutable).
87
-
88
- ### Gap 2: Memory System (FS + sqlite-vec + OpenAI Embeddings)
89
-
90
- #### What Exists Today
91
-
92
- Agent data is scattered across 7 storage subsystems with no unified search:
93
-
94
- | Store | Location | Searchable? |
95
- |-------|----------|------------|
96
- | `agents.claudeMd` | SQLite, 64KB per agent | No (always in context) |
97
- | `agent_tasks.progress` / `output` | SQLite, unbounded TEXT | Only by task ID |
98
- | `agent_log` | SQLite, indexed by agentId/taskId/eventType | Only by specific lookups |
99
- | `session_logs` | SQLite, raw CLI output lines | Only by taskId/sessionId |
100
- | `session_costs` | SQLite, cost tracking | Only by sessionId/agentId |
101
- | `/workspace/personal/` | Docker volume, per-agent | Manual grep by agent |
102
- | `/workspace/shared/thoughts/` | Docker volume, shared | Manual grep by agent |
103
-
104
- The base prompt (`src/prompts/base-prompt.ts:200-205`) suggests agents create `memory.txt` or `memory.db` in their personal directory, but provides no automation or tools.
105
-
106
- #### DB Infrastructure Available
107
-
108
- - `bun:sqlite` Database class supports `loadExtension(path)` for SQLite extensions
109
- - No `loadExtension` calls exist in the codebase today
110
- - WAL mode and transactions are already used extensively
111
- - Migration pattern: `try { ALTER TABLE ADD COLUMN } catch {}` for idempotent column additions, `CREATE TABLE IF NOT EXISTS` for new tables
112
- - No `openai` package in `package.json` -- would need to be added
113
-
114
- #### sqlite-vec Compatibility with Bun
115
-
116
- The `sqlite-vec` npm package officially supports `bun:sqlite`. The `sqliteVec.load(db)` function auto-discovers prebuilt platform-specific binaries -- no manual `.so`/`.dylib` management needed. Install via `bun add sqlite-vec`.
117
-
118
- **macOS caveat**: Apple ships a proprietary SQLite build that disables extension loading. On macOS dev machines, you must `brew install sqlite` and call `Database.setCustomSQLite()` before creating any Database instance. On Linux/Docker, no extra setup needed.
119
-
120
- ```typescript
121
- import { Database } from "bun:sqlite";
122
- import * as sqliteVec from "sqlite-vec";
123
-
124
- // macOS only: Apple's SQLite disables extensions
125
- if (process.platform === "darwin") {
126
- const sqlitePath = Bun.$`brew --prefix sqlite`.text().trim() + "/lib/libsqlite3.dylib";
127
- Database.setCustomSQLite(sqlitePath);
128
- }
129
-
130
- const db = new Database("./agent-swarm-db.sqlite");
131
- sqliteVec.load(db);
132
- ```
133
-
134
- **sqlite-vec API** (vec0 virtual table):
135
- ```sql
136
- -- Create vector table with metadata and auxiliary columns
137
- CREATE VIRTUAL TABLE vec_memory USING vec0(
138
- memory_id integer primary key,
139
- embedding float[512],
140
- scope text, -- metadata: 'agent' or 'swarm'
141
- +agent_id text, -- auxiliary: optional, NULL for swarm-level
142
- +task_id text, -- auxiliary: link to source task
143
- +name text, -- auxiliary: human-readable label (e.g. "auth header fix")
144
- +content text, -- auxiliary: the memory content
145
- +source text -- auxiliary: 'task_completion', 'file_index', 'session_summary', 'manual'
146
- );
147
-
148
- -- KNN search (agent-scoped: own memories + swarm memories)
149
- SELECT memory_id, name, content, source, task_id, distance
150
- FROM vec_memory
151
- WHERE embedding MATCH ?
152
- AND k = 20
153
- AND (scope = 'swarm' OR agent_id = 'abc-123')
154
- ORDER BY distance
155
- LIMIT 10;
156
-
157
- -- KNN search (swarm-wide only)
158
- SELECT memory_id, name, content, source, distance
159
- FROM vec_memory
160
- WHERE embedding MATCH ?
161
- AND k = 20
162
- AND scope = 'swarm'
163
- ORDER BY distance
164
- LIMIT 10;
165
- ```
166
-
167
- Vectors are passed as `Float32Array` from JS. Performance: ~75ms for 100K vectors at 1536 dimensions.
168
-
169
- **Alternative for small scale (<10K vectors)**: Store embeddings as BLOBs in a regular SQLite table and compute cosine similarity in JS. Zero dependencies, works identically on macOS and Linux. O(n) brute force but fine for agent-swarm's likely scale.
170
-
171
- #### OpenAI Embeddings API
172
-
173
- | Model | Dimensions | Price | Notes |
174
- |-------|-----------|-------|-------|
175
- | `text-embedding-3-small` | 1536 (default), supports `dimensions` param for reduction | $0.02/1M tokens | **Recommended** |
176
- | `text-embedding-3-large` | 3072 (default) | $0.13/1M tokens | Best quality |
177
-
178
- Both v3 models support Matryoshka dimension shortening via a `dimensions` parameter. `text-embedding-3-small` at 512 dimensions is likely sufficient for agent memory search -- cheap, fast, and 512 dims is plenty for task/message similarity.
179
-
180
- ```typescript
181
- import OpenAI from "openai";
182
- const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
183
-
184
- async function getEmbedding(text: string): Promise<Float32Array> {
185
- const response = await openai.embeddings.create({
186
- model: "text-embedding-3-small",
187
- input: text.replace(/[\n\r]/g, " "),
188
- dimensions: 512, // 3x smaller than default, still good quality
189
- });
190
- return new Float32Array(response.data[0].embedding);
191
- }
192
- ```
193
-
194
- **Practical cost**: Indexing 10,000 documents of ~500 tokens each (5M tokens) costs $0.10.
195
-
196
- #### What Would Need to Change
197
-
198
- **New `agent_memory` table**: Structured memory entries with fields like `id`, `agentId`, `scope` (agent/swarm), `content`, `summary`, `embedding` (BLOB for vector), `source` (task_completion/manual/session_summary), `sourceTaskId`, `tags`, `createdAt`, `accessedAt`.
199
-
200
- **sqlite-vec setup**: Add to `Dockerfile.worker` and API server dependencies. Load extension in `initDb()` after database creation (`src/be/db.ts:33`).
201
-
202
- **OpenAI embeddings integration**: Add `openai` package. Create an embedding utility function. Called when saving memories and when searching.
203
-
204
- **New MCP tools** (following pattern in `src/tools/`):
205
- - `memory-search`: Takes a query string, generates embedding, runs hybrid BM25+vector search against `agent_memory`. Returns summaries with memory IDs.
206
- - `memory-get`: Takes a memory ID, returns full content details (for when search results need deeper inspection).
207
-
208
- No explicit `memory-save` MCP tool. Instead, memory ingestion happens via two mechanisms:
209
-
210
- **File-based auto-indexing** (OpenClaw-inspired):
211
- - Any files written to `{personal|shared}/memory/` or `shared/thoughts/` are automatically indexed.
212
- - A `PostToolUse` hook on Write/Edit operations checks if the target path matches these directories. If so, it queues the file for embedding and indexing into `agent_memory`.
213
- - This lets agents save memories naturally by writing markdown files (like OpenClaw's `memory/*.md` pattern) without needing a special tool.
214
-
215
- **Automatic session summarization**:
216
- - `Stop` hook (`hook.ts:566-594`): After syncing CLAUDE.md, extract session summary from `transcript_path`, generate embedding, save to `agent_memory` with `source: 'session_summary'` and `task_id` linked.
217
- - `PreCompact` hook (`hook.ts:510-512`): Currently empty. Flush important context to memory before context window compaction.
218
- - Task completion: When `store-progress` is called with `status: "completed"`, the task output is also indexed into memory with `source: 'task_completion'`.
219
-
220
- **Swarm vs. worker scoping**: Each memory entry needs a `scope` field. Agent-level memories are only searchable by that agent. Swarm-level memories are searchable by all agents. The search tool would filter by `agentId` for agent scope and include all swarm-scoped entries.
221
-
222
- ### Gap 3: Session Attachment (Parent Task Resume)
223
-
224
- #### What Exists Today
225
-
226
- **Task execution is one-shot**: The runner (`src/commands/runner.ts:959-1236`) spawns Claude with `-p` flag (prompt mode), meaning every task is a fresh, isolated session. No `--resume` or `--continue` flags are ever used.
227
-
228
- **Task schema has no parent linkage**: The `agent_tasks` table (`src/be/db.ts:62-88`) has `epicId` for project grouping and `dependsOn` for ordering, but no `parentTaskId` for session hierarchy. The `CreateTaskOptions` interface (`src/be/db.ts:1760-1782`) doesn't include it either.
229
-
230
- **Current resume is prompt-based only**: When a paused task is resumed (`buildResumePrompt()` at `runner.ts:247-272`), the system starts a fresh Claude session with the previous `progress` text injected into the prompt. All conversation history is lost.
231
-
232
- **PreCompact hook is empty** (`hook.ts:510-512`): No-op with comment "Covered by SessionStart hook."
233
-
234
- **No Claude session ID tracking**: The runner tracks its own `sessionId` (generated at `runner.ts:1271`) for log grouping, but never captures Claude CLI's internal session ID from its stream-json output.
235
-
236
- #### What Would Need to Change
237
-
238
- **DB schema**:
239
- - Add `parentTaskId TEXT` column to `agent_tasks` (migration pattern: try/catch ALTER TABLE)
240
- - Add `claudeSessionId TEXT` column to `agent_tasks` to store Claude CLI's session ID
241
-
242
- **Claude session ID capture**: Confirmed -- stream-json output includes `session_id` in two places:
243
- - **Init message** (first line): `{"type":"system","subtype":"init","session_id":"<uuid>",...}` -- **prefer this**, as the final result message sometimes fails to emit ([Issue #1920](https://github.com/anthropics/claude-code/issues/1920))
244
- - **Result message** (last line): `{"type":"result","session_id":"<uuid>","cost_usd":...}`
245
-
246
- The runner currently only parses `json.type === "result"` at `runner.ts:1050`. Add a new branch:
247
- ```typescript
248
- if (json.type === "system" && json.subtype === "init" && json.session_id) {
249
- // Store json.session_id for this task in DB
250
- }
251
- ```
252
-
253
- **`--resume` works with `-p`**: Officially supported ([docs](https://code.claude.com/docs/en/headless)):
254
- ```bash
255
- session_id=$(claude -p "Start a review" --output-format json | jq -r '.session_id')
256
- claude -p "Continue that review" --resume "$session_id"
257
- ```
258
-
259
- **Critical caveat**: Each `--resume` invocation generates a **new** session ID (by design, [Issue #4926](https://github.com/anthropics/claude-code/issues/4926)). You must always capture the latest session ID from each task's output and chain from that, not from the original.
260
-
261
- **`send-task` tool extension**: Add `parentTaskId` parameter to `src/tools/send-task.ts:21-49` and pass it through to `createTaskExtended()`.
262
-
263
- **Runner spawn logic**: When a task has `parentTaskId`:
264
- 1. Look up the parent task's `claudeSessionId` from DB
265
- 2. Add `--resume <claudeSessionId>` to the command args alongside `-p` (both flags work together)
266
- 3. Capture the **new** session ID from this task's init message and store it
267
- 4. Fallback: if parent's `claudeSessionId` is missing (e.g., old task), fall back to fresh session with progress injection (current behavior)
268
-
269
- **PreCompact hook**: Add goal reminder injection. The hook receives `session_id` and can read the current task's description from the task file (`TASK_FILE` env var). Inject a reminder like "Remember: your current goal is [task description]" into the context.
270
-
271
- **Compact tolerance**: Accept that context compaction will happen for long-running sessions. The PreCompact hook ensures the goal survives compaction. The memory system (Gap 2) can persist important findings before compaction.
272
-
273
- ### Gap 4: Repos Knowledge (Auto-Clone + CLAUDE.md Linking)
274
-
275
- #### What Exists Today
276
-
277
- **Docker workspace structure**: `/workspace/personal/` (per-agent volume) and `/workspace/shared/` (shared volume). No `/workspace/repos/` or repo management concept. Cloned repos go wherever the agent decides during task execution.
278
-
279
- **GitHub auth is ready**: `docker-entrypoint.sh:121-142` configures `gh auth setup-git` and git config. Workers can clone private repos.
280
-
281
- **`githubRepo` field exists but is underused**: The `agent_tasks` table has `githubRepo TEXT` (set by GitHub webhook handlers at `src/github/handlers.ts:109`). The `send-task` MCP tool does NOT expose this field (see `src/tools/send-task.ts:21-49`). Epics also have `githubRepo` and `githubMilestone` fields (`src/types.ts:332-333`).
282
-
283
- **Lead base prompt mentions clone**: `src/prompts/base-prompt.ts:110,136` include task templates with `git clone {repo_url}` as a text instruction for leads to include in tasks. This is not automation.
284
-
285
- **Startup script mechanism**: `docker-entrypoint.sh:203-300` looks for `/workspace/start-up.*` and executes it. No startup script exists in the committed codebase, but this is a natural hook for repo preparation.
286
-
287
- **No config table**: There's no settings/config table in the DB. The only place env-like data is stored is the `services.env` JSON column (per-service PM2 env vars).
288
-
289
- #### What Would Need to Change
290
-
291
- **New `swarm_repos` table**: Single table -- all agents get access to all registered repos (no junction table needed). Fields: `id`, `url`, `name`, `defaultBranch`, `claudeMdContent` (cached), `autoClone` (boolean, default true), `clonePath`, `lastSynced`, `createdAt`.
292
-
293
- **Docker entrypoint auto-clone**: Add a step (after GitHub auth, before startup script) that fetches repo configs from the API (`GET /api/repos?autoClone=true`), clones any missing repos to `/workspace/repos/{name}/`, and pulls updates for existing ones.
294
-
295
- **CLAUDE.md composition**: Extend the `SessionStart` hook to:
296
- 1. Determine which repos are relevant to the current task (from `agent_tasks.githubRepo` or all auto-cloned repos)
297
- 2. Read each repo's `CLAUDE.md` file
298
- 3. Append repo-level instructions to the agent's `~/.claude/CLAUDE.md` with clear section markers
299
-
300
- **`send-task` tool extension**: Expose `githubRepo` as a parameter (or derive it from `epicId`'s repo field). The runner's `buildPromptForTrigger()` can then include workspace setup instructions.
301
-
302
- **API endpoints**: `GET/POST/PUT/DELETE /api/repos` for CRUD. `GET /api/repos?autoClone=true` for entrypoint consumption.
303
-
304
- ### Gap 5: Auto-Improvement / Config (setup-script.sh)
305
-
306
- #### What Exists Today
307
-
308
- **Startup script mechanism** (`docker-entrypoint.sh:203-300`): Searches for `/workspace/start-up.*` with extensions `.sh`, `.bash`, `.js`, `.ts`, `.bun`. Executes it with detected interpreter. If `STARTUP_SCRIPT_STRICT=true` (default) and the script fails, the container exits. No startup script exists in the committed codebase.
309
-
310
- **CLAUDE.md self-edit pattern**: During a session, agents can edit `~/.claude/CLAUDE.md`. Changes sync back to DB on `Stop` hook. The default template includes `### Learnings`, `### Preferences`, `### Important Context` sections.
311
-
312
- **No post-task reflection**: When a task completes, `checkCompletedProcesses()` (`runner.ts:1239-1266`) only marks it finished. No reflection, learning extraction, or memory capture occurs.
313
-
314
- **No learning propagation**: Worker learnings stay in their personal `claudeMd`. No mechanism shares knowledge across agents. The system prompt should include explicit instructions on how to use the self-learning system -- e.g., "Write important learnings to `{personal}/memory/` files. Use `memory-search` to recall past experience. Your memories persist across sessions."
315
-
316
- **Hook data available at Stop**: The `Stop` hook receives `transcript_path` and `session_id` in the hook message (`hook.ts:20-35`). The agent's full task history is in the DB. This data is currently unused for learning.
317
-
318
- #### What Would Need to Change
319
-
320
- **DB storage for setup scripts**: Add `setupScript TEXT` column to `agents` table (per-worker scripts) and possibly a global scripts mechanism (new `swarm_config` table or reuse the config table from Gap 6).
321
-
322
- **Script lifecycle**:
323
- 1. On container start, entrypoint fetches setup script from API (`GET /api/agents/:id/setup-script`)
324
- 2. If `/workspace/start-up.sh` already exists (Docker mount case), *prepends* the DB-stored content at the top of the existing file. If no file exists, creates it.
325
- 3. Existing execution mechanism runs it
326
- 4. During sessions, agents can modify the script via `update-profile` tool extension or a new `update-setup-script` tool
327
- 5. On `Stop` hook, sync the script back to DB (similar to CLAUDE.md sync)
328
-
329
- **Note**: Post-task reflection and learning extraction belong to Gap 2 (Memory System), not here. See the "Automatic session summarization" section under Gap 2 for the Stop hook extension that captures session learnings.
330
-
331
- **Self-improvement directive**: Add to the SOUL.md template (Gap 1): "After completing tasks, reflect on what you learned. Update your setup script if you found tools or configurations that would help in future sessions." Also add memory system usage instructions to the base prompt (see Gap 2).
332
-
333
- ### Gap 6: Env Management API
334
-
335
- #### What Exists Today
336
-
337
- **Flat .env files**: `.env` (API server), `.env.docker` (worker), `.env.docker-lead` (lead). No centralized store. Workers receive env vars via Docker `--env-file` or docker-compose `environment:` blocks.
338
-
339
- **No config/settings DB table**: The only env-like storage is `services.env` JSON column for PM2 service env vars (`src/be/db.ts:157`).
340
-
341
- **No config API endpoints**: No REST endpoints for reading or writing configuration. The UI's `ConfigModal.tsx` only stores the API URL and API key in `localStorage`.
342
-
343
- **Per-agent config in DB**: The `agents` table has `maxTasks`, `claudeMd`, `role`, `capabilities`. These are the only per-agent config fields.
344
-
345
- **Docker entrypoint env validation** (`docker-entrypoint.sh:4-13`): Only validates `CLAUDE_CODE_OAUTH_TOKEN` and `API_KEY` as required. All other vars use defaults.
346
-
347
- #### What Would Need to Change
348
-
349
- **New `swarm_config` table**:
350
- ```sql
351
- CREATE TABLE IF NOT EXISTS swarm_config (
352
- id TEXT PRIMARY KEY,
353
- scope TEXT NOT NULL CHECK(scope IN ('global', 'agent', 'repo')),
354
- scopeId TEXT, -- agentId or repoId, NULL for global
355
- key TEXT NOT NULL,
356
- value TEXT NOT NULL,
357
- isSecret INTEGER NOT NULL DEFAULT 0,
358
- envPath TEXT, -- optional: auto-write to .env file at this path when set
359
- description TEXT,
360
- createdAt TEXT NOT NULL,
361
- lastUpdatedAt TEXT NOT NULL,
362
- UNIQUE(scope, scopeId, key)
363
- )
364
- ```
365
-
366
- The `envPath` field enables automatic `.env` file management: when a config entry has `envPath` set (e.g., `/workspace/repos/my-app/.env`), the system writes `KEY=VALUE` to that file when the config is created/updated. This bridges DB-stored config with the filesystem `.env` files that many tools expect.
367
-
368
- **API endpoints**:
369
- - `GET /api/config?scope=global` -- list global config
370
- - `GET /api/config?scope=agent&scopeId=<agentId>` -- list agent config
371
- - `GET /api/config?scope=repo&scopeId=<repoId>` -- list repo config
372
- - `PUT /api/config` -- upsert config entry
373
- - `DELETE /api/config/:id` -- remove config entry
374
- - `GET /api/config/resolved?agentId=<id>&repoId=<id>` -- get merged config (global + agent + repo)
375
-
376
- **Injection mechanisms**:
377
- - Docker entrypoint: Fetch resolved config from API before starting the agent binary, export as env vars
378
- - MCP tool: `get-config` tool for agents to read config during sessions
379
- - Hook: SessionStart could inject config into the system prompt or a config file
380
-
381
- **UI components**: Settings page in the dashboard with tabs for Global, Per-Agent, and Per-Repo config. Each entry shows key, value (masked for secrets), scope, and description.
382
-
383
- **Scope resolution order**: repo > agent > global (most specific wins). When an agent starts a task linked to a repo, the resolved config merges all three levels.
384
-
385
- ## Code References
386
-
387
- | File | Line | Description |
388
- |------|------|-------------|
389
- | `src/be/db.ts` | 48-59 | `agents` table schema (identity fields) |
390
- | `src/be/db.ts` | 62-88 | `agent_tasks` table schema (no parentTaskId) |
391
- | `src/be/db.ts` | 90-101 | `agent_log` table (event log, no search exposed) |
392
- | `src/be/db.ts` | 166-177 | `session_logs` table (raw CLI output) |
393
- | `src/be/db.ts` | 179-198 | `session_costs` table (cost tracking) |
394
- | `src/be/db.ts` | 289-317 | `epics` table (has githubRepo, githubMilestone) |
395
- | `src/be/db.ts` | 497-502 | `claudeMd` column migration |
396
- | `src/be/db.ts` | 1760-1782 | `CreateTaskOptions` interface (no parentTaskId) |
397
- | `src/be/db.ts` | 2129-2169 | `generateDefaultClaudeMd()` template |
398
- | `src/be/db.ts` | 2171-2207 | `updateAgentProfile()` with COALESCE |
399
- | `src/hooks/hook.ts` | 238-261 | `syncClaudeMdToServer()` |
400
- | `src/hooks/hook.ts` | 496-508 | SessionStart: load CLAUDE.md from DB |
401
- | `src/hooks/hook.ts` | 510-512 | PreCompact: empty handler |
402
- | `src/hooks/hook.ts` | 537-553 | PostToolUse: progress reminders only |
403
- | `src/hooks/hook.ts` | 566-594 | Stop: sync CLAUDE.md, mark offline |
404
- | `src/prompts/base-prompt.ts` | 1-5 | Base system prompt (role + agentId only) |
405
- | `src/prompts/base-prompt.ts` | 110, 136 | Task templates mentioning git clone |
406
- | `src/prompts/base-prompt.ts` | 190-205 | Memory/filesystem instructions |
407
- | `src/tools/join-swarm.ts` | 99-112 | Default CLAUDE.md generation on join |
408
- | `src/tools/send-task.ts` | 21-49 | Task creation (no githubRepo param) |
409
- | `src/tools/store-progress.ts` | 37-52 | Progress reporting (no learning extraction) |
410
- | `src/tools/update-profile.ts` | 14-33 | Profile update fields |
411
- | `src/commands/runner.ts` | 247-272 | `buildResumePrompt()` (prompt-based, not session resume) |
412
- | `src/commands/runner.ts` | 604-818 | `buildPromptForTrigger()` |
413
- | `src/commands/runner.ts` | 959-1236 | `spawnClaudeProcess()` (always uses `-p`, never `--resume`) |
414
- | `src/commands/runner.ts` | 1239-1266 | `checkCompletedProcesses()` (no reflection) |
415
- | `src/commands/runner.ts` | 1289-1323 | System prompt composition |
416
- | `src/http.ts` | 968-1048 | `PUT /api/agents/:id/profile` |
417
- | `src/server.ts` | 56-64 | Capability-gated tool registration |
418
- | `src/github/handlers.ts` | 109 | `githubRepo` set on webhook tasks |
419
- | `src/types.ts` | 59-109 | `AgentTaskSchema` (has githubRepo fields) |
420
- | `src/types.ts` | 113-135 | `AgentSchema` (claudeMd max 64KB) |
421
- | `docker-entrypoint.sh` | 4-13 | Env validation |
422
- | `docker-entrypoint.sh` | 88-119 | MCP config creation |
423
- | `docker-entrypoint.sh` | 121-142 | GitHub auth setup |
424
- | `docker-entrypoint.sh` | 203-300 | Startup script execution |
425
- | `docker-entrypoint.sh` | 303-347 | Workspace directory creation |
426
- | `Dockerfile.worker` | 82-95 | Hook configuration in Claude settings |
427
- | `Dockerfile.worker` | 135-138 | Volume declarations |
428
- | `docker-compose.example.yml` | 153-159 | Named volumes |
429
-
430
- ## Architecture Documentation
431
-
432
- ### Current Data Flow (Identity + Memory)
433
-
434
- ```
435
- ┌─────────────────────────────┐
436
- │ SQLite DB │
437
- │ (agent-swarm-db.sqlite) │
438
- ├─────────────────────────────┤
439
- │ agents.claudeMd (64KB) │
440
- │ agent_tasks.progress/output │
441
- │ agent_log (events) │
442
- │ session_logs (raw output) │
443
- │ session_costs (tokens/$$) │
444
- └──────────┬──────────────────┘
445
-
446
- ┌─────────────────────┼─────────────────────┐
447
- │ │ │
448
- ┌─────────▼──────────┐ ┌──────▼───────┐ ┌───────▼──────────┐
449
- │ SessionStart │ │ Stop Hook │ │ store-progress │
450
- │ Hook │ │ │ │ MCP Tool │
451
- │ │ │ Read file │ │ │
452
- │ GET /me → claudeMd │ │ PUT profile │ │ progress/output │
453
- │ Write ~/.claude/ │ │ Restore bak │ │ → DB │
454
- │ CLAUDE.md │ │ │ │ │
455
- └─────────┬──────────┘ └──────────────┘ └──────────────────┘
456
-
457
- ┌─────────▼──────────────────────────┐
458
- │ Claude Session │
459
- │ │
460
- │ ~/.claude/CLAUDE.md (user-level) │
461
- │ --append-system-prompt (base) │
462
- │ /workspace/personal/ (fs) │
463
- │ /workspace/shared/ (fs) │
464
- │ │
465
- │ NO search across stores │
466
- │ NO automatic memory capture │
467
- │ NO session continuity │
468
- └────────────────────────────────────┘
469
- ```
470
-
471
- ### Proposed Data Flow (With All 6 Gaps Implemented)
472
-
473
- ```
474
- ┌──────────────────────────────────┐
475
- │ SQLite DB │
476
- ├──────────────────────────────────┤
477
- │ agents: claudeMd, soulMd, │
478
- │ identityMd, setupScript │
479
- │ agent_tasks: parentTaskId, │
480
- │ claudeSessionId │
481
- │ agent_memory: content, embedding, │
482
- │ scope, source │
483
- │ swarm_repos: url, claudeMdContent │
484
- │ swarm_config: scope, key, value │
485
- │ (+ existing tables) │
486
- └──────────┬───────────────────────┘
487
-
488
- ┌─────────────────────┼─────────────────────────┐
489
- │ │ │
490
- ┌─────────▼──────────┐ ┌──────▼───────────┐ ┌───────▼──────────┐
491
- │ SessionStart │ │ Stop Hook │ │ New MCP Tools │
492
- │ Hook (extended) │ │ (extended) │ │ │
493
- │ │ │ │ │ memory-search │
494
- │ Compose CLAUDE.md: │ │ Sync claudeMd │ │ memory-save │
495
- │ - identity section │ │ Sync soulMd │ │ get-config │
496
- │ - soul section │ │ Extract session │ │ update-setup │
497
- │ - personal notes │ │ learnings → │ │ │
498
- │ - repo CLAUDE.md │ │ agent_memory │ └──────────────────┘
499
- │ - resolved config │ │ Sync setupScript│
500
- │ │ │ │
501
- │ Load setup script │ └──────────────────┘
502
- │ Auto-clone repos │
503
- └─────────┬──────────┘ ┌──────────────────┐
504
- │ │ PreCompact Hook │
505
- ┌─────────▼──────────┐ │ (new behavior) │
506
- │ Claude Session │ │ │
507
- │ │ │ Save context to │
508
- │ Session may resume │ │ agent_memory │
509
- │ from parent task │ │ Inject goal │
510
- │ via --resume │ │ reminder │
511
- │ │ └──────────────────┘
512
- │ memory-search for │
513
- │ relevant context │
514
- │ │
515
- │ Repo CLAUDE.md │
516
- │ auto-loaded │
517
- └─────────────────────┘
518
- ```
519
-
520
- ## Cross-Gap Dependencies
521
-
522
- Some gaps depend on or benefit from others:
523
-
524
- | Gap | Depends On | Enhances |
525
- |-----|-----------|----------|
526
- | 1. Identity | None | 5 (identity informs auto-improvement directives) |
527
- | 2. Memory | None (but benefits from 3 for session summaries) | 3 (memory survives compaction), 5 (memory stores learnings) |
528
- | 3. Sessions | None | 2 (longer sessions = more context to memorize) |
529
- | 4. Repos | 6 (repo config could include env vars) | 1 (repo CLAUDE.md augments identity) |
530
- | 5. Auto-improvement | 2 (memory is where learnings go), 1 (identity directs reflection) | All gaps (agent gets better at everything) |
531
- | 6. Env Management | None | 4 (repo-level env vars), 5 (setup scripts may need env vars) |
532
-
533
- **Recommended implementation order**: 6 → 1 → 2 → 3 → 4 → 5
534
-
535
- Rationale: Env management (6) is foundational infrastructure with no dependencies. Identity (1) is a quick win that changes agent behavior immediately. Memory (2) is the largest effort but unlocks learning. Sessions (3) builds on memory for context preservation. Repos (4) benefits from config and identity. Auto-improvement (5) ties everything together but needs memory and identity as prerequisites.
536
-
537
- ## Proposed Implementation Plan
538
-
539
- Each gap should be planned and implemented as a separate phase using `/desplega:create-plan`. High-level scope per phase:
540
-
541
- 1. **Phase 1 — Env Management (Gap 6)** ✅: `swarm_config` table, CRUD API endpoints + MCP tools, env file writer (`envPath`), UI management page. No dependencies.
542
- - **Plan**: [`thoughts/taras/plans/2026-02-20-env-management.md`](../plans/2026-02-20-env-management.md)
543
- - **PR**: [#60 `claw-env-management`](https://github.com/desplega-ai/agent-swarm/pull/60) (merged)
544
-
545
- 2. **Phase 2 — Worker Identity (Gap 1)** ✅: `soulMd` + `identityMd` columns on `agents`, injection via `--append-system-prompt`, PostToolUse hook for real-time CLAUDE.md persistence, API/UI for editing identity files.
546
- - **Plan**: [`thoughts/taras/plans/2026-02-20-worker-identity.md`](../plans/2026-02-20-worker-identity.md)
547
- - **PR**: [#62 `claw-worker-identity`](https://github.com/desplega-ai/agent-swarm/pull/62) (merged)
548
-
549
- 3. **Phase 3 — Memory System (Gap 2)** ✅: BLOB-based vector storage with JS cosine similarity, OpenAI embedding integration, `memory-search` + `memory-get` MCP tools, file-based auto-indexing via PostToolUse hook, session auto-summarization at Stop hook, task completion memory via store-progress.
550
- - **Plan**: [`thoughts/taras/plans/2026-02-20-memory-system.md`](../plans/2026-02-20-memory-system.md)
551
- - **PR**: [#65 `claw-memory`](https://github.com/desplega-ai/agent-swarm/pull/65) (merged)
552
-
553
- 4. **Phase 4 — Session Attachment (Gap 3)** ✅: `parentTaskId` + `claudeSessionId` columns on `agent_tasks`, session ID capture from stream-json, `--resume` with `-p` for child tasks, compact hook for goal reminder.
554
- - **Plan**: [`thoughts/taras/plans/2026-02-20-session-attach.md`](../plans/2026-02-20-session-attach.md)
555
- - **PR**: [#61 `claw-session-attach`](https://github.com/desplega-ai/agent-swarm/pull/61) (merged)
556
-
557
- 5. **Phase 5 — Repos Knowledge (Gap 4)** ✅: `swarm_repos` table, auto-clone on worker start, repo CLAUDE.md injection when task has linked `githubRepo`, API/UI for repo management.
558
- - **Plan**: [`thoughts/taras/plans/2026-02-20-repos-knowledge.md`](../plans/2026-02-20-repos-knowledge.md)
559
- - **PR**: [#64 `respo-knowledge`](https://github.com/desplega-ai/agent-swarm/pull/64)
560
-
561
- 6. **Phase 6 — Auto-improvement (Gap 5)** ✅: DB-stored setup script (global + per-worker), prepend to mounted startup file, self-learning instructions in system prompt.
562
- - **Plan**: [`thoughts/taras/plans/2026-02-20-auto-improvement.md`](../plans/2026-02-20-auto-improvement.md)
563
- - **PR**: [#63 `claw-auto-improvement`](https://github.com/desplega-ai/agent-swarm/pull/63) (merged)
564
-
565
- ## Historical Context (from thoughts/)
566
-
567
- - `thoughts/taras/research/2026-02-19-agent-native-swarm-architecture.md` -- The base research comparing agent-swarm to OpenClaw's self-learning loop. Identifies the three core gaps (persona, memory, auto-improvement) and maps OpenClaw's five mechanisms to agent-swarm's existing architecture. This document extends that research into concrete implementation details for 6 specific features.
568
- - `thoughts/taras/research/2026-01-28-per-worker-claude-md.md` -- Research that led to implementing per-agent CLAUDE.md storage. The claudeMd column, hook sync lifecycle, and default template generation are all working results of this research.
569
-
570
- ## Related Research
571
-
572
- - `/Users/taras/Documents/code/openclaw/thoughts/taras/research/2026-02-18-openclaw-self-learning-loop.md` -- Detailed analysis of OpenClaw's SOUL.md, MEMORY.md, memory system, hooks, and safety boundaries that informed the gap identification.
573
-
574
- ## Resolved Decisions
575
-
576
- 1. **CLAUDE.md composition strategy**: Split -- soul/identity/worker info via `--append-system-prompt` (immutable), personal notes via `~/.claude/CLAUDE.md` (mutable). See Gap 1 for details.
577
-
578
- 2. **Memory embedding provider**: OpenAI `text-embedding-3-small` at 512 dimensions. No fallback needed for now.
579
-
580
- 3. **Repo CLAUDE.md loading**: Only load repo CLAUDE.md into the system prompt when the task has a `githubRepo` field linked. Don’t load all repos’ CLAUDE.md files for every task.
581
-
582
- 4. **Setup script security**: No guardrails. Agents can self-modify freely.
583
-
584
- 5. **Env secret handling**: Mask values in API responses by default. Offer authenticated endpoint to reveal actual values. No encryption at rest needed for now.
585
-
586
- 6. **Memory garbage collection**: Not a priority. Add a `createdAt` index for future cleanup, but no automated retention policy for now.
587
-
588
- ## Open Questions
589
-
590
- 1. ~~**Session resume mechanics**~~: **Resolved** -- `--resume` works with `-p`. Session ID available in stream-json `init` and `result` messages. Each resume generates a new session ID (must chain). See Gap 3 for details.
591
-
592
- 2. ~~**Memory indexing latency**~~: **Resolved** — Async indexing is fine. Embedding generation (OpenAI API call) will be queued/async so hooks return fast and don’t block the agent.
593
-
594
- 3. ~~**Cross-agent knowledge propagation**~~: **Resolved** — Explicit sharing model. Agents write to `personal/memory/` for agent-scoped knowledge and `shared/memory/` for swarm-level knowledge. No automatic promotion. Lead has visibility into worker sessions and tasks (operational data) but NOT personal memories — this keeps a clean separation between operational coordination (visible up) and personal knowledge (explicitly shared).