@desplega.ai/agent-swarm 1.20.0 → 1.49.0

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 (810) hide show
  1. package/.claude/settings.json +84 -0
  2. package/.claude/settings.local.json +3 -1
  3. package/.entire/settings.json +4 -0
  4. package/.env.docker.example +40 -23
  5. package/.env.example +39 -1
  6. package/.github/ISSUE_TEMPLATE/bug_report.yml +78 -0
  7. package/.github/ISSUE_TEMPLATE/community-template.yml +77 -0
  8. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  9. package/.github/ISSUE_TEMPLATE/feature_request.yml +60 -0
  10. package/.github/PULL_REQUEST_TEMPLATE/community-template.md +29 -0
  11. package/.github/workflows/ci.yml +3 -27
  12. package/.github/workflows/docker-and-deploy.yml +20 -5
  13. package/.github/workflows/merge-gate.yml +233 -0
  14. package/.opencode/plugins/entire.ts +133 -0
  15. package/.superset/config.json +6 -0
  16. package/.wts-setup.ts +103 -34
  17. package/CHANGELOG.md +447 -0
  18. package/CLAUDE.md +422 -5
  19. package/CONTRIBUTING.md +46 -1
  20. package/DEPLOYMENT.md +26 -9
  21. package/Dockerfile +15 -7
  22. package/Dockerfile.worker +99 -67
  23. package/MCP.md +452 -17
  24. package/README.md +271 -169
  25. package/api-entrypoint.sh +56 -0
  26. package/depot.json +1 -0
  27. package/docker-compose.example.yml +194 -3
  28. package/docker-compose.local.yml +119 -0
  29. package/docker-entrypoint.sh +393 -113
  30. package/docs-site/app/api/search/route.ts +4 -0
  31. package/docs-site/app/docs/[[...slug]]/page.tsx +87 -0
  32. package/docs-site/app/docs/layout.tsx +12 -0
  33. package/docs-site/app/globals.css +24 -0
  34. package/docs-site/app/layout.config.tsx +34 -0
  35. package/docs-site/app/layout.tsx +119 -0
  36. package/docs-site/app/llms-full.txt/route.ts +11 -0
  37. package/docs-site/app/llms.mdx/docs/[[...slug]]/route.ts +24 -0
  38. package/docs-site/app/llms.txt/route.ts +8 -0
  39. package/docs-site/app/page.tsx +5 -0
  40. package/docs-site/app/robots.ts +13 -0
  41. package/docs-site/app/sitemap.ts +37 -0
  42. package/docs-site/components/api-page.client.tsx +4 -0
  43. package/docs-site/components/api-page.tsx +7 -0
  44. package/docs-site/components/mdx/mermaid.tsx +55 -0
  45. package/docs-site/content/docs/(documentation)/architecture/agents.mdx +117 -0
  46. package/docs-site/content/docs/(documentation)/architecture/hooks.mdx +77 -0
  47. package/docs-site/content/docs/(documentation)/architecture/memory.mdx +96 -0
  48. package/docs-site/content/docs/(documentation)/architecture/meta.json +4 -0
  49. package/docs-site/content/docs/(documentation)/architecture/overview.mdx +172 -0
  50. package/docs-site/content/docs/(documentation)/concepts/epics.mdx +98 -0
  51. package/docs-site/content/docs/(documentation)/concepts/meta.json +4 -0
  52. package/docs-site/content/docs/(documentation)/concepts/scheduling.mdx +136 -0
  53. package/docs-site/content/docs/(documentation)/concepts/services.mdx +104 -0
  54. package/docs-site/content/docs/(documentation)/concepts/task-lifecycle.mdx +148 -0
  55. package/docs-site/content/docs/(documentation)/concepts/workflows.mdx +209 -0
  56. package/docs-site/content/docs/(documentation)/contributing.mdx +158 -0
  57. package/docs-site/content/docs/(documentation)/getting-started.mdx +157 -0
  58. package/docs-site/content/docs/(documentation)/guides/agentmail-integration.mdx +79 -0
  59. package/docs-site/content/docs/(documentation)/guides/deployment.mdx +171 -0
  60. package/docs-site/content/docs/(documentation)/guides/github-integration.mdx +81 -0
  61. package/docs-site/content/docs/(documentation)/guides/gitlab-integration.mdx +93 -0
  62. package/docs-site/content/docs/(documentation)/guides/linear-integration.mdx +98 -0
  63. package/docs-site/content/docs/(documentation)/guides/meta.json +13 -0
  64. package/docs-site/content/docs/(documentation)/guides/sentry-integration.mdx +52 -0
  65. package/docs-site/content/docs/(documentation)/guides/slack-integration.mdx +179 -0
  66. package/docs-site/content/docs/(documentation)/guides/x402-payments.mdx +154 -0
  67. package/docs-site/content/docs/(documentation)/index.mdx +65 -0
  68. package/docs-site/content/docs/(documentation)/meta.json +19 -0
  69. package/docs-site/content/docs/(documentation)/reference/cli.mdx +241 -0
  70. package/docs-site/content/docs/(documentation)/reference/environment-variables.mdx +205 -0
  71. package/docs-site/content/docs/(documentation)/reference/mcp-tools.mdx +449 -0
  72. package/docs-site/content/docs/(documentation)/reference/meta.json +4 -0
  73. package/docs-site/content/docs/api-reference/active-sessions.mdx +9 -0
  74. package/docs-site/content/docs/api-reference/agents.mdx +9 -0
  75. package/docs-site/content/docs/api-reference/channels.mdx +9 -0
  76. package/docs-site/content/docs/api-reference/config.mdx +9 -0
  77. package/docs-site/content/docs/api-reference/debug.mdx +9 -0
  78. package/docs-site/content/docs/api-reference/ecosystem.mdx +9 -0
  79. package/docs-site/content/docs/api-reference/epics.mdx +9 -0
  80. package/docs-site/content/docs/api-reference/index.mdx +32 -0
  81. package/docs-site/content/docs/api-reference/memory.mdx +9 -0
  82. package/docs-site/content/docs/api-reference/meta.json +25 -0
  83. package/docs-site/content/docs/api-reference/poll.mdx +9 -0
  84. package/docs-site/content/docs/api-reference/repos.mdx +9 -0
  85. package/docs-site/content/docs/api-reference/schedules.mdx +9 -0
  86. package/docs-site/content/docs/api-reference/session-data.mdx +9 -0
  87. package/docs-site/content/docs/api-reference/stats.mdx +9 -0
  88. package/docs-site/content/docs/api-reference/tasks.mdx +9 -0
  89. package/docs-site/content/docs/api-reference/trackers.mdx +9 -0
  90. package/docs-site/content/docs/api-reference/webhooks.mdx +9 -0
  91. package/docs-site/content/docs/api-reference/workflows.mdx +9 -0
  92. package/docs-site/content/docs/meta.json +3 -0
  93. package/docs-site/lib/get-llm-text.ts +10 -0
  94. package/docs-site/lib/openapi.ts +23 -0
  95. package/docs-site/lib/source.ts +8 -0
  96. package/docs-site/mdx-components.tsx +13 -0
  97. package/docs-site/next.config.mjs +29 -0
  98. package/docs-site/package.json +35 -0
  99. package/docs-site/pnpm-lock.yaml +5407 -0
  100. package/docs-site/postcss.config.mjs +8 -0
  101. package/docs-site/scripts/generate-docs.ts +171 -0
  102. package/docs-site/source.config.ts +17 -0
  103. package/docs-site/tsconfig.json +46 -0
  104. package/ecosystem.config.cjs +4 -4
  105. package/landing/next.config.ts +14 -0
  106. package/landing/package.json +31 -0
  107. package/landing/pnpm-lock.yaml +1091 -0
  108. package/landing/postcss.config.mjs +8 -0
  109. package/landing/public/apple-touch-icon.png +0 -0
  110. package/landing/public/favicon.ico +0 -0
  111. package/landing/public/logo.png +0 -0
  112. package/landing/public/og-image.png +0 -0
  113. package/landing/public/omghost-desplega.svg +30 -0
  114. package/landing/public/omghost-openfort.svg +9 -0
  115. package/landing/src/app/actions/waitlist.ts +25 -0
  116. package/landing/src/app/blog/openfort-hackathon/page.tsx +863 -0
  117. package/landing/src/app/blog/page.tsx +162 -0
  118. package/landing/src/app/blog/swarm-metrics/page.tsx +685 -0
  119. package/landing/src/app/examples/page.tsx +174 -0
  120. package/landing/src/app/examples/x402/page.tsx +456 -0
  121. package/landing/src/app/globals.css +122 -0
  122. package/landing/src/app/layout.tsx +134 -0
  123. package/landing/src/app/page.tsx +27 -0
  124. package/landing/src/app/robots.ts +13 -0
  125. package/landing/src/app/sitemap.ts +44 -0
  126. package/landing/src/components/architecture.tsx +163 -0
  127. package/landing/src/components/cta.tsx +52 -0
  128. package/landing/src/components/features.tsx +160 -0
  129. package/landing/src/components/footer.tsx +100 -0
  130. package/landing/src/components/hero.tsx +217 -0
  131. package/landing/src/components/how-it-works.tsx +165 -0
  132. package/landing/src/components/navbar.tsx +147 -0
  133. package/landing/src/components/waitlist.tsx +110 -0
  134. package/landing/src/components/why-choose.tsx +149 -0
  135. package/landing/src/components/workshops.tsx +328 -0
  136. package/landing/src/lib/utils.ts +6 -0
  137. package/landing/tsconfig.json +41 -0
  138. package/misc/transcripts/2026-03-09-pi-mono-e2e-verification.md +154 -0
  139. package/new-ui/CLAUDE.md +92 -0
  140. package/new-ui/README.md +73 -0
  141. package/new-ui/biome.json +42 -0
  142. package/new-ui/components.json +21 -0
  143. package/new-ui/index.html +25 -0
  144. package/new-ui/package.json +49 -0
  145. package/new-ui/pnpm-lock.yaml +4845 -0
  146. package/new-ui/public/logo.png +0 -0
  147. package/new-ui/src/api/client.ts +814 -0
  148. package/new-ui/src/api/hooks/index.ts +64 -0
  149. package/new-ui/src/api/hooks/use-agents.ts +58 -0
  150. package/new-ui/src/api/hooks/use-channels.ts +115 -0
  151. package/new-ui/src/api/hooks/use-config-api.ts +46 -0
  152. package/new-ui/src/api/hooks/use-costs.ts +122 -0
  153. package/new-ui/src/api/hooks/use-db-query.ts +29 -0
  154. package/new-ui/src/api/hooks/use-epics.ts +75 -0
  155. package/new-ui/src/api/hooks/use-repos.ts +61 -0
  156. package/new-ui/src/api/hooks/use-schedules.ts +81 -0
  157. package/new-ui/src/api/hooks/use-services.ts +16 -0
  158. package/new-ui/src/api/hooks/use-stats.ts +27 -0
  159. package/new-ui/src/api/hooks/use-tasks.ts +89 -0
  160. package/new-ui/src/api/hooks/use-workflows.ts +109 -0
  161. package/{ui/src/types/api.ts → new-ui/src/api/types.ts} +236 -10
  162. package/new-ui/src/app/App.tsx +13 -0
  163. package/new-ui/src/app/providers.tsx +32 -0
  164. package/new-ui/src/app/router.tsx +52 -0
  165. package/new-ui/src/components/layout/app-header.tsx +47 -0
  166. package/new-ui/src/components/layout/app-sidebar.tsx +128 -0
  167. package/new-ui/src/components/layout/breadcrumbs.tsx +57 -0
  168. package/new-ui/src/components/layout/config-guard.tsx +22 -0
  169. package/new-ui/src/components/layout/root-layout.tsx +40 -0
  170. package/new-ui/src/components/layout/swarm-switcher.tsx +85 -0
  171. package/new-ui/src/components/shared/command-menu.tsx +131 -0
  172. package/new-ui/src/components/shared/data-grid.tsx +141 -0
  173. package/new-ui/src/components/shared/empty-state.tsx +24 -0
  174. package/new-ui/src/components/shared/error-boundary.tsx +72 -0
  175. package/new-ui/src/components/shared/json-viewer.tsx +47 -0
  176. package/new-ui/src/components/shared/name-connection-modal.tsx +99 -0
  177. package/new-ui/src/components/shared/page-skeleton.tsx +16 -0
  178. package/new-ui/src/components/shared/session-log-viewer.tsx +364 -0
  179. package/new-ui/src/components/shared/stats-bar.tsx +132 -0
  180. package/new-ui/src/components/shared/status-badge.tsx +131 -0
  181. package/new-ui/src/components/shared/usage-summary.tsx +179 -0
  182. package/new-ui/src/components/ui/alert-dialog.tsx +176 -0
  183. package/new-ui/src/components/ui/alert.tsx +60 -0
  184. package/new-ui/src/components/ui/avatar.tsx +96 -0
  185. package/new-ui/src/components/ui/badge.tsx +46 -0
  186. package/new-ui/src/components/ui/button.tsx +62 -0
  187. package/new-ui/src/components/ui/card.tsx +75 -0
  188. package/new-ui/src/components/ui/command.tsx +160 -0
  189. package/new-ui/src/components/ui/dialog.tsx +143 -0
  190. package/new-ui/src/components/ui/dropdown-menu.tsx +226 -0
  191. package/new-ui/src/components/ui/input.tsx +21 -0
  192. package/new-ui/src/components/ui/label.tsx +19 -0
  193. package/new-ui/src/components/ui/progress.tsx +26 -0
  194. package/new-ui/src/components/ui/scroll-area.tsx +54 -0
  195. package/new-ui/src/components/ui/select.tsx +175 -0
  196. package/new-ui/src/components/ui/separator.tsx +28 -0
  197. package/new-ui/src/components/ui/sheet.tsx +132 -0
  198. package/new-ui/src/components/ui/sidebar.tsx +691 -0
  199. package/new-ui/src/components/ui/skeleton.tsx +13 -0
  200. package/new-ui/src/components/ui/sonner.tsx +35 -0
  201. package/new-ui/src/components/ui/switch.tsx +33 -0
  202. package/new-ui/src/components/ui/table.tsx +92 -0
  203. package/new-ui/src/components/ui/tabs.tsx +79 -0
  204. package/new-ui/src/components/ui/textarea.tsx +18 -0
  205. package/new-ui/src/components/ui/tooltip.tsx +51 -0
  206. package/new-ui/src/components/workflows/action-node.tsx +53 -0
  207. package/new-ui/src/components/workflows/condition-node.tsx +50 -0
  208. package/new-ui/src/components/workflows/graph-utils.ts +124 -0
  209. package/new-ui/src/components/workflows/json-tree.tsx +189 -0
  210. package/new-ui/src/components/workflows/node-styles.ts +10 -0
  211. package/new-ui/src/components/workflows/step-detail-sheet.tsx +87 -0
  212. package/new-ui/src/components/workflows/trigger-node.tsx +41 -0
  213. package/new-ui/src/components/workflows/workflow-graph.tsx +65 -0
  214. package/{ui/src/hooks/useAutoScroll.ts → new-ui/src/hooks/use-auto-scroll.ts} +0 -1
  215. package/new-ui/src/hooks/use-config.ts +203 -0
  216. package/new-ui/src/hooks/use-keyboard-shortcuts.ts +41 -0
  217. package/new-ui/src/hooks/use-mobile.ts +19 -0
  218. package/new-ui/src/hooks/use-theme.ts +60 -0
  219. package/new-ui/src/lib/config.ts +188 -0
  220. package/new-ui/src/lib/slugs.ts +71 -0
  221. package/{ui → new-ui}/src/lib/utils.ts +32 -0
  222. package/new-ui/src/main.tsx +11 -0
  223. package/new-ui/src/pages/agents/[id]/page.tsx +492 -0
  224. package/new-ui/src/pages/agents/page.tsx +134 -0
  225. package/new-ui/src/pages/chat/page.tsx +674 -0
  226. package/new-ui/src/pages/config/page.tsx +1109 -0
  227. package/new-ui/src/pages/dashboard/page.tsx +454 -0
  228. package/new-ui/src/pages/debug/page.tsx +275 -0
  229. package/new-ui/src/pages/epics/[id]/page.tsx +809 -0
  230. package/new-ui/src/pages/epics/page.tsx +321 -0
  231. package/new-ui/src/pages/not-found/page.tsx +18 -0
  232. package/new-ui/src/pages/repos/page.tsx +369 -0
  233. package/new-ui/src/pages/schedules/[id]/page.tsx +664 -0
  234. package/new-ui/src/pages/schedules/page.tsx +477 -0
  235. package/new-ui/src/pages/services/page.tsx +128 -0
  236. package/new-ui/src/pages/tasks/[id]/page.tsx +670 -0
  237. package/new-ui/src/pages/tasks/page.tsx +592 -0
  238. package/new-ui/src/pages/usage/page.tsx +195 -0
  239. package/new-ui/src/pages/workflow-runs/[id]/page.tsx +363 -0
  240. package/new-ui/src/pages/workflows/[id]/page.tsx +417 -0
  241. package/new-ui/src/pages/workflows/page.tsx +266 -0
  242. package/new-ui/src/styles/ag-grid.css +36 -0
  243. package/new-ui/src/styles/globals.css +213 -0
  244. package/new-ui/test-results/.last-run.json +4 -0
  245. package/{ui/tsconfig.json → new-ui/tsconfig.app.json} +7 -4
  246. package/new-ui/tsconfig.json +4 -0
  247. package/new-ui/tsconfig.node.json +26 -0
  248. package/new-ui/vercel.json +4 -0
  249. package/new-ui/vite.config.ts +28 -0
  250. package/openapi.json +4436 -0
  251. package/package.json +31 -7
  252. package/plugin/build-pi-skills.ts +233 -0
  253. package/plugin/commands/close-issue.md +7 -3
  254. package/plugin/commands/create-pr.md +18 -12
  255. package/plugin/commands/implement-issue.md +7 -3
  256. package/plugin/commands/respond-github.md +8 -4
  257. package/plugin/commands/review-pr.md +44 -10
  258. package/plugin/commands/start-leader.md +1 -3
  259. package/plugin/commands/start-worker.md +1 -3
  260. package/plugin/commands/work-on-task.md +22 -3
  261. package/plugin/pi-skills/close-issue/SKILL.md +90 -0
  262. package/plugin/pi-skills/create-pr/SKILL.md +99 -0
  263. package/plugin/pi-skills/implement-issue/SKILL.md +135 -0
  264. package/plugin/pi-skills/investigate-sentry-issue/SKILL.md +138 -0
  265. package/plugin/pi-skills/respond-github/SKILL.md +98 -0
  266. package/plugin/pi-skills/review-offered-task/SKILL.md +45 -0
  267. package/plugin/pi-skills/review-pr/SKILL.md +261 -0
  268. package/plugin/pi-skills/start-leader/SKILL.md +121 -0
  269. package/plugin/pi-skills/start-worker/SKILL.md +60 -0
  270. package/plugin/pi-skills/swarm-chat/SKILL.md +82 -0
  271. package/plugin/pi-skills/todos/SKILL.md +66 -0
  272. package/plugin/pi-skills/work-on-task/SKILL.md +65 -0
  273. package/plugin/skills/artifacts/examples/approval-flow.ts +34 -0
  274. package/plugin/skills/artifacts/examples/hono-dashboard.ts +31 -0
  275. package/plugin/skills/artifacts/examples/multi-artifact.ts +20 -0
  276. package/plugin/skills/artifacts/examples/static-report.sh +17 -0
  277. package/plugin/skills/artifacts/skill.md +71 -0
  278. package/prek.toml +75 -0
  279. package/scripts/check-db-boundary.sh +60 -0
  280. package/scripts/e2e-docker-provider.ts +820 -0
  281. package/scripts/e2e-io-schemas-test.ts +807 -0
  282. package/scripts/e2e-provider-test.ts +220 -0
  283. package/scripts/e2e-workflow-redesign.sh +229 -0
  284. package/scripts/e2e-workflow-test.sh +285 -0
  285. package/scripts/e2e-workflow-test.ts +857 -0
  286. package/scripts/generate-openapi.ts +26 -0
  287. package/scripts/measure-tool-tokens.ts +118 -0
  288. package/scripts/x402-e2e-test.ts +195 -0
  289. package/scripts/x402-test-server.ts +236 -0
  290. package/scripts/x402-testnet-e2e.ts +668 -0
  291. package/slack-manifest.json +17 -0
  292. package/src/agentmail/app.ts +65 -0
  293. package/src/agentmail/handlers.ts +207 -0
  294. package/src/agentmail/index.ts +9 -0
  295. package/src/agentmail/types.ts +51 -0
  296. package/src/artifact-sdk/browser-sdk.ts +30 -0
  297. package/src/artifact-sdk/index.ts +2 -0
  298. package/src/artifact-sdk/localtunnel.d.ts +20 -0
  299. package/src/artifact-sdk/port.ts +12 -0
  300. package/src/artifact-sdk/server.ts +156 -0
  301. package/src/artifact-sdk/tunnel.ts +19 -0
  302. package/src/be/chunking.ts +193 -0
  303. package/src/be/db-queries/oauth.ts +90 -0
  304. package/src/be/db-queries/tracker.ts +182 -0
  305. package/src/be/db.ts +2729 -770
  306. package/src/be/embedding.ts +80 -0
  307. package/src/be/migrations/001_initial.sql +409 -0
  308. package/src/be/migrations/002_one_time_schedules.sql +59 -0
  309. package/src/be/migrations/003_workflows.sql +51 -0
  310. package/src/be/migrations/004_workflow_source.sql +81 -0
  311. package/src/be/migrations/005_epic_next_steps.sql +2 -0
  312. package/src/be/migrations/006_vcs_provider.sql +94 -0
  313. package/src/be/migrations/007_task_dir.sql +2 -0
  314. package/src/be/migrations/008_workflow_redesign.sql +85 -0
  315. package/src/be/migrations/009_tracker_integration.sql +144 -0
  316. package/src/be/migrations/010_step_diagnostics.sql +1 -0
  317. package/src/be/migrations/011_step_next_port.sql +1 -0
  318. package/src/be/migrations/012_trigger_schema.sql +1 -0
  319. package/src/be/migrations/013_task_output_schema.sql +2 -0
  320. package/src/be/migrations/runner.ts +188 -0
  321. package/src/cli.tsx +231 -299
  322. package/src/commands/artifact.ts +241 -0
  323. package/src/commands/onboard/compose-generator.ts +169 -0
  324. package/src/commands/onboard/env-generator.ts +79 -0
  325. package/src/commands/onboard/manifest.ts +37 -0
  326. package/src/commands/onboard/presets.ts +85 -0
  327. package/src/commands/onboard/service-names.ts +47 -0
  328. package/src/commands/onboard/steps/core-credentials.tsx +111 -0
  329. package/src/commands/onboard/steps/custom-templates.tsx +168 -0
  330. package/src/commands/onboard/steps/generate.tsx +154 -0
  331. package/src/commands/onboard/steps/harness-credentials.tsx +195 -0
  332. package/src/commands/onboard/steps/harness.tsx +21 -0
  333. package/src/commands/onboard/steps/health-check.tsx +171 -0
  334. package/src/commands/onboard/steps/integration-github.tsx +105 -0
  335. package/src/commands/onboard/steps/integration-gitlab.tsx +79 -0
  336. package/src/commands/onboard/steps/integration-menu.tsx +58 -0
  337. package/src/commands/onboard/steps/integration-sentry.tsx +79 -0
  338. package/src/commands/onboard/steps/integration-slack.tsx +165 -0
  339. package/src/commands/onboard/steps/post-connect.tsx +145 -0
  340. package/src/commands/onboard/steps/post-dashboard.tsx +34 -0
  341. package/src/commands/onboard/steps/post-task.tsx +103 -0
  342. package/src/commands/onboard/steps/prereq-check.tsx +178 -0
  343. package/src/commands/onboard/steps/review.tsx +82 -0
  344. package/src/commands/onboard/steps/start.tsx +97 -0
  345. package/src/commands/onboard/templates.ts +34 -0
  346. package/src/commands/onboard/types.ts +259 -0
  347. package/src/commands/onboard.tsx +425 -0
  348. package/src/commands/runner.ts +1376 -559
  349. package/src/commands/setup.tsx +23 -38
  350. package/src/commands/shared/client-config.ts +41 -0
  351. package/src/github/app.ts +8 -0
  352. package/src/github/handlers.ts +93 -75
  353. package/src/github/index.ts +1 -0
  354. package/src/github/types.ts +1 -0
  355. package/src/gitlab/auth.ts +63 -0
  356. package/src/gitlab/handlers.ts +327 -0
  357. package/src/gitlab/index.ts +19 -0
  358. package/src/gitlab/reactions.ts +104 -0
  359. package/src/gitlab/types.ts +130 -0
  360. package/src/heartbeat/heartbeat.ts +425 -0
  361. package/src/heartbeat/index.ts +1 -0
  362. package/src/hooks/hook.ts +555 -4
  363. package/src/hooks/tool-loop-detection.test.ts +158 -0
  364. package/src/hooks/tool-loop-detection.ts +167 -0
  365. package/src/http/active-sessions.ts +172 -0
  366. package/src/http/agents.ts +328 -0
  367. package/src/http/config.ts +191 -0
  368. package/src/http/core.ts +309 -0
  369. package/src/http/db-query.ts +91 -0
  370. package/src/http/ecosystem.ts +63 -0
  371. package/src/http/epics.ts +460 -0
  372. package/src/http/index.ts +213 -0
  373. package/src/http/mcp.ts +77 -0
  374. package/src/http/memory.ts +168 -0
  375. package/src/http/openapi.ts +109 -0
  376. package/src/http/poll.ts +178 -0
  377. package/src/http/repos.ts +195 -0
  378. package/src/http/route-def.ts +123 -0
  379. package/src/http/schedules.ts +391 -0
  380. package/src/http/session-data.ts +241 -0
  381. package/src/http/stats.ts +174 -0
  382. package/src/http/tasks.ts +468 -0
  383. package/src/http/trackers/index.ts +10 -0
  384. package/src/http/trackers/linear.ts +187 -0
  385. package/src/http/types.ts +12 -0
  386. package/src/http/utils.ts +87 -0
  387. package/src/http/webhooks.ts +432 -0
  388. package/src/http/workflows.ts +522 -0
  389. package/src/http.ts +1 -1890
  390. package/src/linear/README.md +65 -0
  391. package/src/linear/app.ts +48 -0
  392. package/src/linear/client.ts +18 -0
  393. package/src/linear/index.ts +1 -0
  394. package/src/linear/oauth.ts +35 -0
  395. package/src/linear/outbound.ts +212 -0
  396. package/src/linear/sync.ts +543 -0
  397. package/src/linear/types.ts +7 -0
  398. package/src/linear/webhook.ts +104 -0
  399. package/src/oauth/README.md +66 -0
  400. package/src/oauth/index.ts +6 -0
  401. package/src/oauth/wrapper.ts +204 -0
  402. package/src/prompts/base-prompt.ts +366 -24
  403. package/src/prompts/defaults.ts +196 -0
  404. package/src/providers/claude-adapter.ts +429 -0
  405. package/src/providers/index.ts +24 -0
  406. package/src/providers/pi-mono-adapter.ts +442 -0
  407. package/src/providers/pi-mono-extension.ts +620 -0
  408. package/src/providers/pi-mono-mcp-client.ts +124 -0
  409. package/src/providers/types.ts +75 -0
  410. package/src/scheduler/scheduler.test.ts +2 -0
  411. package/src/scheduler/scheduler.ts +186 -29
  412. package/src/server.ts +82 -6
  413. package/src/slack/HEURISTICS.md +105 -0
  414. package/src/slack/actions.ts +133 -0
  415. package/src/slack/app.ts +7 -0
  416. package/src/slack/assistant.ts +115 -0
  417. package/src/slack/blocks.ts +233 -0
  418. package/src/slack/commands.ts +31 -17
  419. package/src/slack/files.ts +1 -1
  420. package/src/slack/handlers.test.ts +114 -1
  421. package/src/slack/handlers.ts +212 -52
  422. package/src/slack/responses.ts +120 -67
  423. package/src/slack/router.ts +17 -99
  424. package/src/slack/thread-buffer.ts +213 -0
  425. package/src/slack/watcher.ts +119 -4
  426. package/src/tests/agent-activity.test.ts +247 -0
  427. package/src/tests/agentmail-filters.test.ts +97 -0
  428. package/src/tests/artifact-sdk.test.ts +800 -0
  429. package/src/tests/base-prompt.test.ts +264 -0
  430. package/src/tests/build-pi-skills.test.ts +127 -0
  431. package/src/tests/claude-adapter.test.ts +126 -0
  432. package/src/tests/context-versioning.test.ts +425 -0
  433. package/src/tests/db-queries-oauth.test.ts +197 -0
  434. package/src/tests/db-queries-tracker.test.ts +230 -0
  435. package/src/tests/epics.test.ts +3 -3
  436. package/src/tests/error-tracker.test.ts +368 -0
  437. package/src/tests/fetch-resolved-env.test.ts +167 -0
  438. package/src/tests/generate-default-claude-md.test.ts +9 -1
  439. package/src/tests/generate-identity-templates.test.ts +124 -0
  440. package/src/tests/gitlab-auth.test.ts +109 -0
  441. package/src/tests/gitlab-handlers.test.ts +691 -0
  442. package/src/tests/gitlab-vcs-db.test.ts +177 -0
  443. package/src/tests/heartbeat.test.ts +363 -0
  444. package/src/tests/http-api-integration.test.ts +1698 -0
  445. package/src/tests/linear-outbound-sync.test.ts +200 -0
  446. package/src/tests/linear-webhook.test.ts +402 -0
  447. package/src/tests/match-route.test.ts +187 -0
  448. package/src/tests/memory.test.ts +737 -0
  449. package/src/tests/migration-runner-regressions.test.ts +86 -0
  450. package/src/tests/model-control.test.ts +338 -0
  451. package/src/tests/oauth-wrapper.test.ts +147 -0
  452. package/src/tests/onboard-compose.test.ts +138 -0
  453. package/src/tests/onboard-env.test.ts +174 -0
  454. package/src/tests/onboard-manifest.test.ts +137 -0
  455. package/src/tests/pi-mono-adapter.test.ts +234 -0
  456. package/src/tests/progress-dedup.test.ts +98 -0
  457. package/src/tests/provider-adapter.test.ts +122 -0
  458. package/src/tests/provider-command-format.test.ts +98 -0
  459. package/src/tests/reload-config.test.ts +170 -0
  460. package/src/tests/runner-polling-api.test.ts +25 -20
  461. package/src/tests/scheduled-tasks.test.ts +104 -0
  462. package/src/tests/scheduler-backoff.test.ts +166 -0
  463. package/src/tests/self-improvement.test.ts +540 -0
  464. package/src/tests/session-attach.test.ts +536 -0
  465. package/src/tests/session-costs.test.ts +267 -1
  466. package/src/tests/slack-actions.test.ts +133 -0
  467. package/src/tests/slack-assistant.test.ts +136 -0
  468. package/src/tests/slack-blocks.test.ts +246 -0
  469. package/src/tests/slack-metadata-inheritance.test.ts +243 -0
  470. package/src/tests/slack-queue-offline.test.ts +174 -0
  471. package/src/tests/slack-router.test.ts +181 -0
  472. package/src/tests/slack-thread-buffer.test.ts +305 -0
  473. package/src/tests/slack-thread-followups.test.ts +298 -0
  474. package/src/tests/slack-watcher.test.ts +101 -0
  475. package/src/tests/structured-output.test.ts +311 -0
  476. package/src/tests/swarm-repos.test.ts +198 -0
  477. package/src/tests/task-cancellation.test.ts +6 -4
  478. package/src/tests/task-working-dir.test.ts +176 -0
  479. package/src/tests/template-fetch.test.ts +490 -0
  480. package/src/tests/tool-annotations.test.ts +371 -0
  481. package/src/tests/tracker-tools.test.ts +184 -0
  482. package/src/tests/update-profile-api.test.ts +143 -3
  483. package/src/tests/validation-adapters.test.ts +86 -0
  484. package/src/tests/vcs-provider.test.ts +27 -0
  485. package/src/tests/workflow-agent-task.test.ts +196 -0
  486. package/src/tests/workflow-async-v2.test.ts +386 -0
  487. package/src/tests/workflow-convergence.test.ts +541 -0
  488. package/src/tests/workflow-definition-validation.test.ts +290 -0
  489. package/src/tests/workflow-engine-v2.test.ts +691 -0
  490. package/src/tests/workflow-executors.test.ts +736 -0
  491. package/src/tests/workflow-http-v2.test.ts +599 -0
  492. package/src/tests/workflow-integration-io.test.ts +902 -0
  493. package/src/tests/workflow-io-schemas.test.ts +624 -0
  494. package/src/tests/workflow-registry.test.ts +592 -0
  495. package/src/tests/workflow-retry-v2.test.ts +401 -0
  496. package/src/tests/workflow-retry-validation.test.ts +282 -0
  497. package/src/tests/workflow-template.test.ts +288 -0
  498. package/src/tests/workflow-trigger-schema.test.ts +359 -0
  499. package/src/tests/workflow-triggers-v2.test.ts +264 -0
  500. package/src/tests/workflow-versions.test.ts +208 -0
  501. package/src/tests/x402-client.test.ts +117 -0
  502. package/src/tests/x402-config.test.ts +182 -0
  503. package/src/tests/x402-spending-tracker.test.ts +185 -0
  504. package/src/tools/cancel-task.ts +2 -0
  505. package/src/tools/context-diff.ts +171 -0
  506. package/src/tools/context-history.ts +138 -0
  507. package/src/tools/create-channel.ts +1 -0
  508. package/src/tools/db-query.ts +78 -0
  509. package/src/tools/delete-channel.ts +132 -0
  510. package/src/tools/epics/assign-task-to-epic.ts +1 -0
  511. package/src/tools/epics/create-epic.ts +3 -2
  512. package/src/tools/epics/delete-epic.ts +2 -0
  513. package/src/tools/epics/get-epic-details.ts +2 -0
  514. package/src/tools/epics/list-epics.ts +2 -0
  515. package/src/tools/epics/unassign-task-from-epic.ts +1 -0
  516. package/src/tools/epics/update-epic.ts +7 -4
  517. package/src/tools/get-swarm.ts +2 -0
  518. package/src/tools/get-task-details.ts +2 -0
  519. package/src/tools/get-tasks.ts +27 -1
  520. package/src/tools/inject-learning.ts +106 -0
  521. package/src/tools/join-swarm.ts +17 -7
  522. package/src/tools/list-channels.ts +2 -0
  523. package/src/tools/list-services.ts +2 -0
  524. package/src/tools/memory-get.ts +56 -0
  525. package/src/tools/memory-search.ts +131 -0
  526. package/src/tools/my-agent-info.ts +2 -0
  527. package/src/tools/poll-task.ts +2 -20
  528. package/src/tools/post-message.ts +1 -0
  529. package/src/tools/read-messages.ts +2 -0
  530. package/src/tools/register-agentmail-inbox.ts +166 -0
  531. package/src/tools/register-service.ts +2 -0
  532. package/src/tools/schedules/create-schedule.ts +134 -24
  533. package/src/tools/schedules/delete-schedule.ts +2 -0
  534. package/src/tools/schedules/list-schedules.ts +20 -4
  535. package/src/tools/schedules/run-schedule-now.ts +1 -0
  536. package/src/tools/schedules/update-schedule.ts +49 -17
  537. package/src/tools/send-task.ts +132 -10
  538. package/src/tools/slack-download-file.ts +4 -2
  539. package/src/tools/slack-list-channels.ts +2 -0
  540. package/src/tools/slack-post.ts +2 -0
  541. package/src/tools/slack-read.ts +2 -0
  542. package/src/tools/slack-reply.ts +2 -0
  543. package/src/tools/slack-upload-file.ts +2 -0
  544. package/src/tools/store-progress.ts +187 -4
  545. package/src/tools/swarm-config/delete-config.ts +87 -0
  546. package/src/tools/swarm-config/get-config.ts +108 -0
  547. package/src/tools/swarm-config/index.ts +4 -0
  548. package/src/tools/swarm-config/list-config.ts +99 -0
  549. package/src/tools/swarm-config/set-config.ts +118 -0
  550. package/src/tools/task-action.ts +30 -5
  551. package/src/tools/task-dedup.ts +97 -0
  552. package/src/tools/tool-config.ts +117 -0
  553. package/src/tools/tracker/index.ts +6 -0
  554. package/src/tools/tracker/tracker-link-epic.ts +64 -0
  555. package/src/tools/tracker/tracker-link-task.ts +64 -0
  556. package/src/tools/tracker/tracker-map-agent.ts +57 -0
  557. package/src/tools/tracker/tracker-status.ts +56 -0
  558. package/src/tools/tracker/tracker-sync-status.ts +42 -0
  559. package/src/tools/tracker/tracker-unlink.ts +41 -0
  560. package/src/tools/unregister-service.ts +2 -0
  561. package/src/tools/update-profile.ts +93 -10
  562. package/src/tools/update-service-status.ts +2 -0
  563. package/src/tools/utils.ts +10 -1
  564. package/src/tools/workflows/create-workflow.ts +111 -0
  565. package/src/tools/workflows/delete-workflow.ts +42 -0
  566. package/src/tools/workflows/get-workflow-run.ts +59 -0
  567. package/src/tools/workflows/get-workflow.ts +53 -0
  568. package/src/tools/workflows/index.ts +9 -0
  569. package/src/tools/workflows/list-workflow-runs.ts +48 -0
  570. package/src/tools/workflows/list-workflows.ts +42 -0
  571. package/src/tools/workflows/retry-workflow-run.ts +40 -0
  572. package/src/tools/workflows/trigger-workflow.ts +96 -0
  573. package/src/tools/workflows/update-workflow.ts +118 -0
  574. package/src/tracker/types.ts +51 -0
  575. package/src/types.ts +477 -14
  576. package/src/utils/credentials.test.ts +156 -0
  577. package/src/utils/credentials.ts +50 -0
  578. package/src/utils/error-tracker.ts +190 -0
  579. package/src/vcs/index.ts +15 -0
  580. package/src/vcs/types.ts +5 -0
  581. package/src/workflows/checkpoint.ts +121 -0
  582. package/src/workflows/cooldown.ts +28 -0
  583. package/src/workflows/definition.ts +217 -0
  584. package/src/workflows/engine.ts +554 -0
  585. package/src/workflows/event-bus.ts +29 -0
  586. package/src/workflows/executors/agent-task.ts +92 -0
  587. package/src/workflows/executors/base.ts +86 -0
  588. package/src/workflows/executors/code-match.ts +88 -0
  589. package/src/workflows/executors/index.ts +16 -0
  590. package/src/workflows/executors/notify.ts +93 -0
  591. package/src/workflows/executors/property-match.ts +104 -0
  592. package/src/workflows/executors/raw-llm.ts +83 -0
  593. package/src/workflows/executors/registry.ts +76 -0
  594. package/src/workflows/executors/script.ts +103 -0
  595. package/src/workflows/executors/validate.ts +215 -0
  596. package/src/workflows/executors/vcs.ts +58 -0
  597. package/src/workflows/index.ts +61 -0
  598. package/src/workflows/input.ts +46 -0
  599. package/src/workflows/json-schema-validator.ts +118 -0
  600. package/src/workflows/recovery.ts +139 -0
  601. package/src/workflows/resume.ts +143 -0
  602. package/src/workflows/retry-poller.ts +216 -0
  603. package/src/workflows/template.ts +74 -0
  604. package/src/workflows/templates.ts +86 -0
  605. package/src/workflows/triggers.ts +95 -0
  606. package/src/workflows/validation.ts +104 -0
  607. package/src/workflows/version.ts +42 -0
  608. package/src/x402/cli.ts +140 -0
  609. package/src/x402/client.ts +192 -0
  610. package/src/x402/config.ts +131 -0
  611. package/src/x402/index.ts +37 -0
  612. package/src/x402/openfort-signer.ts +83 -0
  613. package/src/x402/spending-tracker.ts +109 -0
  614. package/templates/community/.gitkeep +0 -0
  615. package/templates/official/coder/CLAUDE.md +49 -0
  616. package/templates/official/coder/IDENTITY.md +28 -0
  617. package/templates/official/coder/SOUL.md +43 -0
  618. package/templates/official/coder/TOOLS.md +40 -0
  619. package/templates/official/coder/config.json +23 -0
  620. package/templates/official/coder/start-up.sh +23 -0
  621. package/templates/official/content-reviewer/CLAUDE.md +68 -0
  622. package/templates/official/content-reviewer/IDENTITY.md +28 -0
  623. package/templates/official/content-reviewer/SOUL.md +44 -0
  624. package/templates/official/content-reviewer/TOOLS.md +37 -0
  625. package/templates/official/content-reviewer/config.json +23 -0
  626. package/templates/official/content-reviewer/start-up.sh +23 -0
  627. package/templates/official/content-strategist/CLAUDE.md +63 -0
  628. package/templates/official/content-strategist/IDENTITY.md +33 -0
  629. package/templates/official/content-strategist/SOUL.md +48 -0
  630. package/templates/official/content-strategist/TOOLS.md +47 -0
  631. package/templates/official/content-strategist/config.json +23 -0
  632. package/templates/official/content-strategist/start-up.sh +23 -0
  633. package/templates/official/content-writer/CLAUDE.md +72 -0
  634. package/templates/official/content-writer/IDENTITY.md +30 -0
  635. package/templates/official/content-writer/SOUL.md +46 -0
  636. package/templates/official/content-writer/TOOLS.md +44 -0
  637. package/templates/official/content-writer/config.json +23 -0
  638. package/templates/official/content-writer/start-up.sh +23 -0
  639. package/templates/official/forward-deployed-engineer/CLAUDE.md +54 -0
  640. package/templates/official/forward-deployed-engineer/IDENTITY.md +37 -0
  641. package/templates/official/forward-deployed-engineer/SOUL.md +55 -0
  642. package/templates/official/forward-deployed-engineer/config.json +21 -0
  643. package/templates/official/lead/CLAUDE.md +33 -0
  644. package/templates/official/lead/IDENTITY.md +36 -0
  645. package/templates/official/lead/SOUL.md +51 -0
  646. package/templates/official/lead/config.json +22 -0
  647. package/templates/official/researcher/CLAUDE.md +46 -0
  648. package/templates/official/researcher/IDENTITY.md +28 -0
  649. package/templates/official/researcher/SOUL.md +43 -0
  650. package/templates/official/researcher/config.json +21 -0
  651. package/templates/official/reviewer/CLAUDE.md +63 -0
  652. package/templates/official/reviewer/IDENTITY.md +28 -0
  653. package/templates/official/reviewer/SOUL.md +45 -0
  654. package/templates/official/reviewer/config.json +21 -0
  655. package/templates/official/tester/CLAUDE.md +53 -0
  656. package/templates/official/tester/IDENTITY.md +28 -0
  657. package/templates/official/tester/SOUL.md +55 -0
  658. package/templates/official/tester/config.json +21 -0
  659. package/templates/schema.ts +35 -0
  660. package/templates-ui/README.md +46 -0
  661. package/templates-ui/components.json +17 -0
  662. package/templates-ui/eslint.config.mjs +18 -0
  663. package/templates-ui/next.config.ts +7 -0
  664. package/templates-ui/package.json +35 -0
  665. package/templates-ui/pnpm-lock.yaml +4571 -0
  666. package/templates-ui/postcss.config.mjs +7 -0
  667. package/templates-ui/public/file.svg +1 -0
  668. package/templates-ui/public/globe.svg +1 -0
  669. package/templates-ui/public/logo.png +0 -0
  670. package/templates-ui/public/next.svg +1 -0
  671. package/templates-ui/public/vercel.svg +1 -0
  672. package/templates-ui/public/window.svg +1 -0
  673. package/templates-ui/src/app/[category]/[name]/page.tsx +89 -0
  674. package/templates-ui/src/app/api/templates/[...slug]/route.ts +52 -0
  675. package/templates-ui/src/app/api/templates/route.ts +18 -0
  676. package/templates-ui/src/app/builder/page.tsx +37 -0
  677. package/templates-ui/src/app/globals.css +94 -0
  678. package/templates-ui/src/app/layout.tsx +79 -0
  679. package/templates-ui/src/app/page.tsx +38 -0
  680. package/templates-ui/src/app/robots.ts +11 -0
  681. package/templates-ui/src/app/sitemap.ts +31 -0
  682. package/templates-ui/src/components/compose-builder.tsx +442 -0
  683. package/templates-ui/src/components/compose-preview.tsx +117 -0
  684. package/templates-ui/src/components/file-preview.tsx +77 -0
  685. package/templates-ui/src/components/footer.tsx +40 -0
  686. package/templates-ui/src/components/header.tsx +41 -0
  687. package/templates-ui/src/components/template-card.tsx +87 -0
  688. package/templates-ui/src/components/template-detail.tsx +125 -0
  689. package/templates-ui/src/components/template-gallery.tsx +263 -0
  690. package/templates-ui/src/components/ui/badge.tsx +36 -0
  691. package/templates-ui/src/components/ui/button.tsx +57 -0
  692. package/templates-ui/src/components/ui/card.tsx +76 -0
  693. package/templates-ui/src/components/ui/separator.tsx +31 -0
  694. package/templates-ui/src/components/ui/tooltip.tsx +32 -0
  695. package/templates-ui/src/lib/compose-generator.ts +241 -0
  696. package/templates-ui/src/lib/templates.ts +137 -0
  697. package/templates-ui/src/lib/utils.ts +6 -0
  698. package/templates-ui/tsconfig.json +34 -0
  699. package/thoughts/research/2026-02-28-openfort-viem-x402-research.md +679 -0
  700. package/thoughts/research/2026-02-28-x402-payments-research.md +686 -0
  701. package/thoughts/researcher/plans/2026-02-20-agent-self-improvement-plan.md +282 -0
  702. package/thoughts/researcher/research/2026-02-20-agent-self-improvement.md +492 -0
  703. package/thoughts/shared/plans/2026-02-26-mcp-tool-context-reduction.md +282 -0
  704. package/thoughts/shared/plans/2026-03-02-claude-context-mode-integration.md +328 -0
  705. package/thoughts/shared/plans/2026-03-02-code-level-heartbeat.md +224 -0
  706. package/thoughts/shared/research/2026-02-26-cliffy-mcp-tools.md +159 -0
  707. package/thoughts/shared/research/2026-03-03-database-migration-system-refactor.md +337 -0
  708. package/thoughts/swarm-researcher/plans/2026-02-23-openclaw-improvements-plan.md +778 -0
  709. package/thoughts/swarm-researcher/plans/2026-02-26-artifacts-localtunnel-plan.md +1269 -0
  710. package/thoughts/swarm-researcher/research/2026-02-23-openclaw-vs-agent-swarm-comparison.md +411 -0
  711. package/thoughts/swarm-researcher/research/2026-02-26-artifacts-localtunnel.md +724 -0
  712. package/thoughts/taras/brainstorms/2026-03-20-prompt-template-registry.md +443 -0
  713. package/thoughts/taras/brainstorms/2026-03-20-setup-cli-onboarding.md +307 -0
  714. package/thoughts/taras/plans/2026-02-20-auto-improvement.md +803 -0
  715. package/thoughts/taras/plans/2026-02-20-env-management.md +538 -0
  716. package/thoughts/taras/plans/2026-02-20-memory-system.md +882 -0
  717. package/thoughts/taras/plans/2026-02-20-repos-knowledge.md +806 -0
  718. package/thoughts/taras/plans/2026-02-20-session-attach.md +647 -0
  719. package/thoughts/taras/plans/2026-02-20-worker-identity.md +820 -0
  720. package/thoughts/taras/plans/2026-02-25-feat-new-ui-visual-redesign-plan.md +768 -0
  721. package/thoughts/taras/plans/2026-03-04-fix-buildSystemPrompt-missing-fields.md +77 -0
  722. package/thoughts/taras/plans/2026-03-04-new-ui-missing-actions.md +543 -0
  723. package/thoughts/taras/plans/2026-03-06-one-time-scheduled-tasks.md +373 -0
  724. package/thoughts/taras/plans/2026-03-08-memory-self-improvement-enhancements.md +512 -0
  725. package/thoughts/taras/plans/2026-03-08-pi-mono-provider-implementation.md +919 -0
  726. package/thoughts/taras/plans/2026-03-09-templates-registry.md +723 -0
  727. package/thoughts/taras/plans/2026-03-10-task-working-directory.md +371 -0
  728. package/thoughts/taras/plans/2026-03-11-archil-per-agent-write-strategy.md +621 -0
  729. package/thoughts/taras/plans/2026-03-12-eliminate-inbox-route-to-tasks.md +61 -0
  730. package/thoughts/taras/plans/2026-03-12-slack-thread-followup-additive.md +488 -0
  731. package/thoughts/taras/plans/2026-03-13-slack-ai-improvements.md +644 -0
  732. package/thoughts/taras/plans/2026-03-16-route-wrapper-openapi.md +636 -0
  733. package/thoughts/taras/plans/2026-03-17-multi-api-config.md +444 -0
  734. package/thoughts/taras/plans/2026-03-18-agent-fs-integration.md +591 -0
  735. package/thoughts/taras/plans/2026-03-18-debug-db-explorer.md +446 -0
  736. package/thoughts/taras/plans/2026-03-18-workflow-redesign.md +987 -0
  737. package/thoughts/taras/plans/2026-03-19-compound-learnings.md +403 -0
  738. package/thoughts/taras/plans/2026-03-19-ticket-tracker-linear-integration.md +860 -0
  739. package/thoughts/taras/plans/2026-03-19-workflow-io-schemas-and-bugs.md +899 -0
  740. package/thoughts/taras/plans/2026-03-20-setup-cli-onboarding.md +874 -0
  741. package/thoughts/taras/plans/2026-03-20-workflow-structured-output-validation-workspace.md +723 -0
  742. package/thoughts/taras/research/2026-02-19-agent-native-swarm-architecture.md +390 -0
  743. package/thoughts/taras/research/2026-02-19-swarm-gaps-implementation.md +594 -0
  744. package/thoughts/taras/research/2026-02-25-dashboard-ui-design-best-practices.md +825 -0
  745. package/thoughts/taras/research/2026-02-26-task-detail-page-redesign.md +393 -0
  746. package/thoughts/taras/research/2026-03-03-new-ui-missing-actions.md +168 -0
  747. package/thoughts/taras/research/2026-03-05-pi-mono-provider-research.md +230 -0
  748. package/thoughts/taras/research/2026-03-06-workflow-engine-design.md +445 -0
  749. package/thoughts/taras/research/2026-03-08-drive-loop-concept.md +375 -0
  750. package/thoughts/taras/research/2026-03-08-pi-mono-deep-dive.md +869 -0
  751. package/thoughts/taras/research/2026-03-09-templates-registry.md +373 -0
  752. package/thoughts/taras/research/2026-03-10-agent-working-directory.md +223 -0
  753. package/thoughts/taras/research/2026-03-10-configurable-event-prompts.md +339 -0
  754. package/thoughts/taras/research/2026-03-11-archil-production-setup.md +181 -0
  755. package/thoughts/taras/research/2026-03-11-archil-shared-disk-write-strategies.md +437 -0
  756. package/thoughts/taras/research/2026-03-13-slack-ai-features.md +258 -0
  757. package/thoughts/taras/research/2026-03-16-openapi-docs-generation.md +335 -0
  758. package/thoughts/taras/research/2026-03-16-route-wrapper-openapi.md +670 -0
  759. package/thoughts/taras/research/2026-03-16-slack-thread-followups-e2e.md +54 -0
  760. package/thoughts/taras/research/2026-03-18-agent-fs-integration.md +558 -0
  761. package/thoughts/taras/research/2026-03-18-linear-integration-finalization.md +526 -0
  762. package/thoughts/taras/research/2026-03-18-workflow-redesign.md +797 -0
  763. package/thoughts/taras/research/2026-03-19-workflow-node-io-schemas-and-bugs.md +563 -0
  764. package/thoughts/taras/research/2026-03-19-workflow-structured-output-validation-workspace.md +486 -0
  765. package/thoughts/taras/research/2026-03-20-prompt-template-registry.md +469 -0
  766. package/tsconfig.json +1 -1
  767. package/FAQ.md +0 -19
  768. package/src/tests/get-inbox-message.test.ts +0 -145
  769. package/src/tools/get-inbox-message.ts +0 -89
  770. package/src/tools/inbox-delegate.ts +0 -113
  771. package/ui/CLAUDE.md +0 -49
  772. package/ui/bun.lock +0 -771
  773. package/ui/index.html +0 -22
  774. package/ui/package-lock.json +0 -5290
  775. package/ui/package.json +0 -33
  776. package/ui/pnpm-lock.yaml +0 -3341
  777. package/ui/postcss.config.js +0 -6
  778. package/ui/src/App.tsx +0 -63
  779. package/ui/src/components/ActivityFeed.tsx +0 -440
  780. package/ui/src/components/AgentDetailPanel.tsx +0 -733
  781. package/ui/src/components/AgentsPanel.tsx +0 -815
  782. package/ui/src/components/ChatPanel.tsx +0 -1920
  783. package/ui/src/components/ConfigModal.tsx +0 -253
  784. package/ui/src/components/Dashboard.tsx +0 -832
  785. package/ui/src/components/EditAgentProfileModal.tsx +0 -433
  786. package/ui/src/components/EpicDetailPage.tsx +0 -741
  787. package/ui/src/components/EpicsPanel.tsx +0 -566
  788. package/ui/src/components/Header.tsx +0 -160
  789. package/ui/src/components/JsonViewer.tsx +0 -171
  790. package/ui/src/components/ScheduledTaskDetailPanel.tsx +0 -517
  791. package/ui/src/components/ScheduledTasksPanel.tsx +0 -639
  792. package/ui/src/components/ServicesPanel.tsx +0 -622
  793. package/ui/src/components/SessionLogPanel.tsx +0 -1219
  794. package/ui/src/components/StatsBar.tsx +0 -321
  795. package/ui/src/components/StatusBadge.tsx +0 -168
  796. package/ui/src/components/TaskDetailPanel.tsx +0 -903
  797. package/ui/src/components/TasksPanel.tsx +0 -614
  798. package/ui/src/components/UsageCharts.tsx +0 -216
  799. package/ui/src/components/UsageTab.tsx +0 -394
  800. package/ui/src/hooks/queries.ts +0 -353
  801. package/ui/src/index.css +0 -257
  802. package/ui/src/lib/api.ts +0 -268
  803. package/ui/src/lib/config.ts +0 -35
  804. package/ui/src/lib/contentPreview.ts +0 -208
  805. package/ui/src/lib/theme.ts +0 -214
  806. package/ui/src/main.tsx +0 -28
  807. package/ui/src/vite-env.d.ts +0 -1
  808. package/ui/tailwind.config.js +0 -37
  809. package/ui/vite.config.ts +0 -35
  810. /package/{ui → docs-site}/public/logo.png +0 -0
@@ -0,0 +1,803 @@
1
+ ---
2
+ date: 2026-02-20T02:30:00Z
3
+ planner: Claude
4
+ branch: claw-auto-improvement
5
+ repository: agent-swarm
6
+ topic: "Auto-Improvement / Setup Scripts — Gap 5 Implementation"
7
+ tags: [plan, auto-improvement, setup-script, gap-5, agent-native]
8
+ status: completed
9
+ autonomy: autopilot
10
+ research: thoughts/taras/research/2026-02-19-swarm-gaps-implementation.md
11
+ ---
12
+
13
+ # Auto-Improvement / Setup Scripts — Implementation Plan
14
+
15
+ ## Overview
16
+
17
+ Add persistent, self-evolving setup scripts and environment-specific operational knowledge for agents. Today, agents start every container with the same environment — no way to accumulate tool installations, config tweaks, or workflow improvements across sessions. This plan adds:
18
+
19
+ 1. A `setupScript TEXT` column on `agents` for per-agent setup scripts
20
+ 2. A `toolsMd TEXT` column on `agents` for environment-specific operational knowledge (TOOLS.md)
21
+ 3. A global setup script via the existing `swarm_config` table (key `SETUP_SCRIPT`, scope `global`)
22
+ 4. Docker entrypoint logic to fetch, compose (global + agent), and prepend to any mounted `/workspace/start-up.*`
23
+ 5. File lifecycle: runner writes setup script + TOOLS.md before spawn, Stop hook syncs edits back to DB
24
+ 6. Self-improvement directives in SOUL.md template and base prompt, plus a `generateDefaultToolsMd()` template
25
+
26
+ This is Gap 5 / Phase 6 from the swarm-gaps research (`thoughts/taras/research/2026-02-19-swarm-gaps-implementation.md`).
27
+
28
+ **Prerequisites**: Gap 6 (Env Management) ✅, Gap 1 (Worker Identity) ✅ — both merged.
29
+
30
+ ## Current State Analysis
31
+
32
+ **What exists today:**
33
+ - **Docker entrypoint startup script mechanism** (`docker-entrypoint.sh:229-326`): Discovers `/workspace/start-up.*` files in priority order (`.sh`, `.bash`, `.js`, `.ts`, `.bun`, no ext). Detects interpreter via shebang or extension. `STARTUP_SCRIPT_STRICT=true` by default (container exits on failure). Runs after config fetch + GitHub auth + marketplace install, before workspace dirs + agent binary.
34
+ - **No `setupScript` or `toolsMd` columns** on the `agents` table — confirmed. Only `claudeMd`, `soulMd`, `identityMd` exist.
35
+ - **`swarm_config` table** exists with `global`/`agent`/`repo` scoping (Gap 6, merged). Can store a global setup script as a well-known config key.
36
+ - **Identity file lifecycle** is the pattern to follow: runner writes files before spawn (`runner.ts:1602-1621`), Stop hook syncs back to DB (`hook.ts:666-695`), PostToolUse hook syncs on edit (`hook.ts:537-553`).
37
+ - **`update-profile` MCP tool** (`src/tools/update-profile.ts`) accepts `claudeMd`, `soulMd`, `identityMd` but not `setupScript` or `toolsMd`.
38
+ - **`updateAgentProfile()` DB function** (`db.ts:2319-2370`) uses `COALESCE(?, column)` pattern — easy to extend for both new fields.
39
+ - **`fetchResolvedEnv()`** (`runner.ts:100-137`) already fetches config from API before each spawn — env vars from swarm_config are available.
40
+ - **SOUL.md template** (`db.ts:2240-2278`) has a `## Self-Evolution` section saying "refine your soul", but no mention of setup scripts or environment improvement.
41
+ - **Base prompt filesystem section** (`base-prompt.ts:204-218`) mentions `/workspace/personal` for persistence and suggests `memory.txt`/`memory.db`, but says nothing about setup scripts.
42
+ - **No post-task reflection**: `checkCompletedProcesses()` (`runner.ts:1365-1392`) only removes from `activeTasks` and calls `ensureTaskFinished()` — no learning extraction.
43
+
44
+ ### Key Discoveries:
45
+ - The entrypoint's startup script discovery is first-match: if we write `start-up.sh` and an operator also mounts `start-up.ts`, only `.sh` is found. We must detect the existing file first and prepend to it.
46
+ - The config fetch (`docker-entrypoint.sh:88-112`) already runs before the startup script phase — so a new endpoint for setup scripts can follow the same pattern.
47
+ - The runner writes identity files at `runner.ts:1602-1621` and the system prompt is rebuilt at `runner.ts:1589` — both happen before any Claude process spawns.
48
+ - `writeTaskFile()` creates `/tmp/agent-swarm-task-{pid}.json` with `taskId` + `agentId` — the Stop hook reads this via `TASK_FILE` env var (though it currently doesn't read it in the Stop handler).
49
+
50
+ ## Desired End State
51
+
52
+ 1. Each agent has a `setupScript` field (65KB max, like `claudeMd`) stored in DB
53
+ 2. Each agent has a `toolsMd` field (65KB max) stored in DB — a 4th identity file for environment-specific operational knowledge
54
+ 3. A global setup script can be configured via `swarm_config` (key `SETUP_SCRIPT`, scope `global`)
55
+ 4. On container start, the entrypoint fetches both scripts and composes them into the startup file
56
+ 5. Agents can edit `/workspace/start-up.sh` and `/workspace/TOOLS.md` during sessions — changes sync to DB on Stop
57
+ 6. The `update-profile` MCP tool and REST API accept `setupScript` and `toolsMd` updates
58
+ 7. SOUL.md template includes self-improvement directives about setup script and TOOLS.md
59
+ 8. Base prompt mentions the setup script mechanism and TOOLS.md
60
+ 9. A `generateDefaultToolsMd()` template provides structured categories for environment-specific notes (repos, services, SSH hosts, APIs, etc.)
61
+
62
+ **Verification**: Register an agent, set its `setupScript` via API, start a Docker worker, verify the script runs at container start. Edit the script during a session, stop the worker, verify DB updated. Start again, verify the updated script runs.
63
+
64
+ ## Quick Verification Reference
65
+
66
+ Common commands:
67
+ - `bun run tsc:check` — Type checking
68
+ - `bun run lint:fix` — Lint + format
69
+ - `bun test` — Run all tests
70
+ - `bun run start:http` — Start HTTP server
71
+
72
+ Key files to check:
73
+ - `src/be/db.ts` — Schema, migration, `updateAgentProfile()`, new `getAgentSetupScript()`, `generateDefaultToolsMd()`
74
+ - `src/types.ts` — `AgentSchema` with `setupScript` + `toolsMd`
75
+ - `docker-entrypoint.sh` — Setup script fetch + compose
76
+ - `src/hooks/hook.ts` — Stop hook sync (setup script + TOOLS.md), PostToolUse hook
77
+ - `src/commands/runner.ts` — Write setup script + TOOLS.md before spawn
78
+ - `src/tools/update-profile.ts` — New `setupScript` + `toolsMd` fields
79
+ - `src/prompts/base-prompt.ts` — Self-improvement directives
80
+
81
+ ## What We're NOT Doing
82
+
83
+ - **Post-task reflection/learning extraction** — belongs to Gap 2 (Memory System), not here
84
+ - **Automatic learning propagation** between agents — separate concern
85
+ - **Setup script versioning/history** — no audit trail
86
+ - **Setup script validation/sandboxing** — agents can self-modify freely (per research decision #4)
87
+ - **UI editor for setup scripts or TOOLS.md** — can come later; API + MCP tool sufficient for now
88
+ - **Multi-file setup scripts** — single script per agent, stored as TEXT in DB
89
+ - **Setup script for leads** — leads don't run in Docker workers typically; skip for now
90
+ - **TOOLS.md sharing between agents** — each agent's TOOLS.md is personal; shared knowledge belongs in other mechanisms
91
+
92
+ ## Implementation Approach
93
+
94
+ Five phases, each independently verifiable:
95
+
96
+ 1. **DB + Types**: Schema migration (`setupScript` + `toolsMd`), type updates, `updateAgentProfile()` extension
97
+ 2. **API + MCP Tool**: REST endpoint for setup script, `update-profile` extension (both fields), global script via swarm_config
98
+ 3. **Docker Entrypoint**: Fetch and compose scripts at container start
99
+ 4. **File Lifecycle**: Runner writes setup script + TOOLS.md before spawn, Stop hook syncs back, PostToolUse detects edits
100
+ 5. **Self-Improvement Directives + TOOLS.md Template**: `generateDefaultToolsMd()`, SOUL.md update, base prompt update, CLAUDE.md template update
101
+
102
+ ---
103
+
104
+ ## Phase 1: DB Schema + Type System
105
+
106
+ ### Overview
107
+ Add `setupScript TEXT` and `toolsMd TEXT` columns to the `agents` table and update all TypeScript types.
108
+
109
+ ### Changes Required:
110
+
111
+ #### 1. Database Migration
112
+ **File**: `src/be/db.ts`
113
+ **Changes**: Add column migrations after the existing `identityMd` migration (~line 536):
114
+
115
+ ```typescript
116
+ // Setup script (per-agent auto-improvement)
117
+ try {
118
+ db.run(`ALTER TABLE agents ADD COLUMN setupScript TEXT`);
119
+ } catch { /* exists */ }
120
+
121
+ // Tools/environment reference (per-agent operational knowledge)
122
+ try {
123
+ db.run(`ALTER TABLE agents ADD COLUMN toolsMd TEXT`);
124
+ } catch { /* exists */ }
125
+ ```
126
+
127
+ #### 2. AgentRow Type
128
+ **File**: `src/be/db.ts:714-728`
129
+ **Changes**: Add to `AgentRow`:
130
+
131
+ ```typescript
132
+ setupScript: string | null;
133
+ toolsMd: string | null;
134
+ ```
135
+
136
+ #### 3. rowToAgent Function
137
+ **File**: `src/be/db.ts:731-748`
138
+ **Changes**: Add mappings:
139
+
140
+ ```typescript
141
+ setupScript: row.setupScript ?? undefined,
142
+ toolsMd: row.toolsMd ?? undefined,
143
+ ```
144
+
145
+ #### 4. AgentSchema (Zod)
146
+ **File**: `src/types.ts:131-134`
147
+ **Changes**: Add after `identityMd`:
148
+
149
+ ```typescript
150
+ // Setup script: Runs at container start, agent-evolved (synced to /workspace/start-up.sh)
151
+ setupScript: z.string().max(65536).optional(),
152
+ // Tools/environment reference: Operational knowledge (synced to /workspace/TOOLS.md)
153
+ toolsMd: z.string().max(65536).optional(),
154
+ ```
155
+
156
+ #### 5. updateAgentProfile Extension
157
+ **File**: `src/be/db.ts:2319-2370`
158
+ **Changes**: Add `setupScript?: string` and `toolsMd?: string` to the `updates` parameter type. Add `COALESCE(?, setupScript)` and `COALESCE(?, toolsMd)` to the UPDATE SQL and pass `updates.setupScript ?? null` and `updates.toolsMd ?? null` in the `.get()` call.
159
+
160
+ ### Success Criteria:
161
+
162
+ #### Automated Verification:
163
+ - [x] TypeScript compiles: `bun run tsc:check`
164
+ - [x] Lint passes: `bun run lint:fix`
165
+ - [x] Existing tests pass: `bun test` (325 pass, 0 fail)
166
+ - [x] DB migration runs: `bun run start:http` (start + stop, no errors)
167
+
168
+ #### Manual Verification:
169
+ - [x] SQLite schema has the new columns: `sqlite3 agent-swarm-db.sqlite ".schema agents" | grep -E 'setupScript|toolsMd'`
170
+ - [x] GET /me returns `setupScript` and `toolsMd` fields (null for existing agents)
171
+
172
+ **Implementation Note**: After completing this phase, pause for manual confirmation.
173
+
174
+ ---
175
+
176
+ ## Phase 2: API Endpoint + MCP Tool
177
+
178
+ ### Overview
179
+ Expose setup script via REST API and MCP tool. Add a dedicated `GET /api/agents/:id/setup-script` endpoint for the Docker entrypoint to fetch, and extend `update-profile` to accept `setupScript`.
180
+
181
+ ### Changes Required:
182
+
183
+ #### 1. Setup Script Fetch Endpoint
184
+ **File**: `src/http.ts`
185
+ **Changes**: Add a new endpoint in the REST API section (near the existing profile routes around line 968):
186
+
187
+ ```
188
+ GET /api/agents/:id/setup-script → { setupScript: string | null, globalSetupScript: string | null }
189
+ ```
190
+
191
+ This endpoint:
192
+ - Fetches the agent's `setupScript` from the `agents` table
193
+ - Fetches the global setup script from `swarm_config` where `scope='global'` and `key='SETUP_SCRIPT'`
194
+ - Returns both, so the entrypoint can compose them
195
+
196
+ Route matching: `pathSegments = ["api", "agents", <id>, "setup-script"]`
197
+
198
+ #### 2. Extend Profile API
199
+ **File**: `src/http.ts:968-1048`
200
+ **Changes**: The `PUT /api/agents/:id/profile` endpoint already passes through to `updateAgentProfile()`. Add `setupScript` and `toolsMd` to:
201
+ - The body parsing (it already uses `body.setupScript`/`body.toolsMd` if present due to the spread pattern)
202
+ - The "at least one field" check (~line 995-999)
203
+ - Size validation: max 64KB each, matching `claudeMd` pattern
204
+
205
+ #### 3. Extend update-profile MCP Tool
206
+ **File**: `src/tools/update-profile.ts:14-47`
207
+ **Changes**: Add `setupScript` and `toolsMd` to the input schema:
208
+
209
+ ```typescript
210
+ setupScript: z.string().max(65536).optional().describe(
211
+ "Setup script content (bash). Runs at container start to install tools, configure environment. Persists across sessions. Also written to /workspace/start-up.sh."
212
+ ),
213
+ toolsMd: z.string().max(65536).optional().describe(
214
+ "Environment-specific operational knowledge. Repos, services, SSH hosts, APIs, device names — anything specific to your setup. Synced to /workspace/TOOLS.md."
215
+ ),
216
+ ```
217
+
218
+ Add both to the "at least one field" check, `updatedFields` tracking, and `updateAgentProfile()` call.
219
+
220
+ After DB update:
221
+ - Write to `/workspace/start-up.sh` if the file doesn't exist or is the agent's own content (not operator-mounted). This mirrors the SOUL.md/IDENTITY.md pattern at lines 125-138.
222
+ - Write to `/workspace/TOOLS.md` following the same pattern.
223
+
224
+ #### 4. Global Setup Script Convention
225
+ No code changes needed — the `swarm_config` table already supports this. Document the convention:
226
+ - Key: `SETUP_SCRIPT`
227
+ - Scope: `global`
228
+ - Value: bash script content
229
+ - Set via `PUT /api/config` (existing endpoint)
230
+
231
+ ### Success Criteria:
232
+
233
+ #### Automated Verification:
234
+ - [x] TypeScript compiles: `bun run tsc:check`
235
+ - [x] Lint passes: `bun run lint:fix`
236
+ - [x] Existing tests pass: `bun test` (325 pass, 0 fail)
237
+
238
+ #### Manual Verification:
239
+ - [x] Set agent setupScript via `PUT /api/agents/:id/profile` with `{"setupScript":"#!/bin/bash\necho hello"}` — verify persists
240
+ - [x] Fetch via `GET /api/agents/:id/setup-script` — verify returns the script
241
+ - [x] Set global script via `PUT /api/config` with `{"scope":"global","key":"SETUP_SCRIPT","value":"#!/bin/bash\necho global"}` — verify returned by the endpoint
242
+ - [x] Via MCP tool: agent edited start-up.sh and changes synced to DB via PostToolUse hook
243
+ - [x] Via MCP tool: agent edited TOOLS.md and changes synced to DB via PostToolUse hook
244
+
245
+ **Implementation Note**: After completing this phase, pause for manual confirmation.
246
+
247
+ ---
248
+
249
+ ## Phase 3: Docker Entrypoint Integration
250
+
251
+ ### Overview
252
+ Update the Docker entrypoint to fetch the agent's setup script and global setup script from the API, compose them, and prepend to any existing `/workspace/start-up.*` file before the existing execution mechanism runs.
253
+
254
+ ### Changes Required:
255
+
256
+ #### 1. Setup Script Fetch + Compose
257
+ **File**: `docker-entrypoint.sh`
258
+ **Changes**: Add a new section between the AI Tracker setup (line 226) and the existing startup script execution (line 229). This section:
259
+
260
+ 1. Fetches the agent's setup script + global script from the new endpoint
261
+ 2. Composes: global script first, then agent script (agent-specific additions build on global base)
262
+ 3. Finds the existing startup file (if any) using the same discovery loop
263
+ 4. If a startup file exists: prepends the composed script with a marker comment
264
+ 5. If no startup file exists: creates `/workspace/start-up.sh` with the composed content
265
+
266
+ ```bash
267
+ # ---- Fetch and compose setup scripts from API ----
268
+ if [ -n "$AGENT_ID" ]; then
269
+ echo "Fetching setup scripts from API..."
270
+ if curl -s -f -H "Authorization: Bearer ${API_KEY}" \
271
+ -H "X-Agent-ID: ${AGENT_ID}" \
272
+ "${MCP_URL}/api/agents/${AGENT_ID}/setup-script" \
273
+ > /tmp/setup_scripts.json 2>/dev/null; then
274
+
275
+ GLOBAL_SCRIPT=$(jq -r '.globalSetupScript // empty' /tmp/setup_scripts.json 2>/dev/null)
276
+ AGENT_SCRIPT=$(jq -r '.setupScript // empty' /tmp/setup_scripts.json 2>/dev/null)
277
+
278
+ COMPOSED_SCRIPT=""
279
+ if [ -n "$GLOBAL_SCRIPT" ]; then
280
+ COMPOSED_SCRIPT="${GLOBAL_SCRIPT}"
281
+ fi
282
+ if [ -n "$AGENT_SCRIPT" ]; then
283
+ if [ -n "$COMPOSED_SCRIPT" ]; then
284
+ COMPOSED_SCRIPT="${COMPOSED_SCRIPT}
285
+ "
286
+ fi
287
+ COMPOSED_SCRIPT="${COMPOSED_SCRIPT}${AGENT_SCRIPT}"
288
+ fi
289
+
290
+ if [ -n "$COMPOSED_SCRIPT" ]; then
291
+ # Find existing startup file (same discovery logic as below)
292
+ EXISTING_STARTUP=""
293
+ for pattern in start-up.sh start-up.bash start-up.js start-up.ts start-up.bun start-up; do
294
+ if [ -f "/workspace/${pattern}" ]; then
295
+ EXISTING_STARTUP="/workspace/${pattern}"
296
+ break
297
+ fi
298
+ done
299
+
300
+ if [ -n "$EXISTING_STARTUP" ]; then
301
+ # Prepend to existing file (preserve operator content)
302
+ echo "Prepending DB setup script to existing ${EXISTING_STARTUP}..."
303
+ TEMP_FILE=$(mktemp)
304
+ echo "#!/bin/bash" > "$TEMP_FILE"
305
+ echo "# === Agent-managed setup (from DB) ===" >> "$TEMP_FILE"
306
+ echo "$COMPOSED_SCRIPT" >> "$TEMP_FILE"
307
+ echo "# === End agent-managed setup ===" >> "$TEMP_FILE"
308
+ echo "" >> "$TEMP_FILE"
309
+ # Strip existing shebang from original to avoid duplicate
310
+ sed '1{/^#!/d;}' "$EXISTING_STARTUP" >> "$TEMP_FILE"
311
+ mv "$TEMP_FILE" "$EXISTING_STARTUP"
312
+ chmod +x "$EXISTING_STARTUP"
313
+ else
314
+ # Create new start-up.sh
315
+ echo "Creating /workspace/start-up.sh from DB setup script..."
316
+ echo "#!/bin/bash" > /workspace/start-up.sh
317
+ echo "# === Agent-managed setup (from DB) ===" >> /workspace/start-up.sh
318
+ echo "$COMPOSED_SCRIPT" >> /workspace/start-up.sh
319
+ echo "# === End agent-managed setup ===" >> /workspace/start-up.sh
320
+ chmod +x /workspace/start-up.sh
321
+ fi
322
+ echo "Setup scripts composed (global: $([ -n "$GLOBAL_SCRIPT" ] && echo "yes" || echo "no"), agent: $([ -n "$AGENT_SCRIPT" ] && echo "yes" || echo "no"))"
323
+ fi
324
+ rm -f /tmp/setup_scripts.json
325
+ else
326
+ echo "Warning: Could not fetch setup scripts (API may not be ready)"
327
+ fi
328
+ fi
329
+ # ---- End setup script fetch ----
330
+ ```
331
+
332
+ **Key decisions:**
333
+ - Global script comes first (base environment), agent script second (agent-specific additions)
334
+ - Marker comments (`=== Agent-managed setup ===`) allow us to strip the DB portion on sync-back
335
+ - If an operator-mounted startup file exists, we prepend rather than replace — operator content is preserved
336
+ - The shebang from the original file is stripped to avoid duplicate shebangs
337
+ - The composed file always gets a `#!/bin/bash` shebang (the DB-stored content may not have one)
338
+
339
+ ### Success Criteria:
340
+
341
+ #### Automated Verification:
342
+ - [x] Entrypoint syntax valid: `bash -n docker-entrypoint.sh`
343
+ - [x] Lint passes: `bun run lint:fix`
344
+
345
+ #### Manual Verification:
346
+ - [x] Set an agent's setupScript via API (verified via curl)
347
+ - [x] Build worker image: `docker build -f Dockerfile.worker -t agent-swarm-worker:e2e-test .`
348
+ - [x] Start container, check logs for "Setup scripts composed" message
349
+ - [x] Verify setup test files exist inside the container (`/tmp/global-setup-test`, `/tmp/agent-setup-test`)
350
+ - [x] Restart container — verify no duplication of setup script content (marker stripping works)
351
+
352
+ **Implementation Note**: After completing this phase, pause for manual confirmation. Docker testing required.
353
+
354
+ ---
355
+
356
+ ## Phase 4: File Lifecycle (Runner + Hooks)
357
+
358
+ ### Overview
359
+ Complete the setup script and TOOLS.md lifecycle: runner writes the files before spawn (so the agent can see/edit them), Stop hook syncs edits back to DB, PostToolUse hook syncs on direct edits.
360
+
361
+ ### Changes Required:
362
+
363
+ #### 1. Runner Writes Setup Script + TOOLS.md Before Spawn
364
+ **File**: `src/commands/runner.ts`
365
+ **Changes**: After writing SOUL.md and IDENTITY.md (~line 1621), also write the setup script and TOOLS.md:
366
+
367
+ ```typescript
368
+ const SETUP_SCRIPT_PATH = "/workspace/start-up.sh";
369
+ const TOOLS_MD_PATH = "/workspace/TOOLS.md";
370
+
371
+ // Write setup script to workspace (agent can edit during session)
372
+ if (agentSetupScript) {
373
+ try {
374
+ const file = Bun.file(SETUP_SCRIPT_PATH);
375
+ const exists = await file.exists();
376
+ if (!exists) {
377
+ await Bun.write(SETUP_SCRIPT_PATH, `#!/bin/bash\n${agentSetupScript}\n`);
378
+ log.info("Wrote start-up.sh to workspace");
379
+ }
380
+ } catch (err) {
381
+ log.warn(`Could not write start-up.sh: ${(err as Error).message}`);
382
+ }
383
+ }
384
+
385
+ // Write TOOLS.md to workspace (agent can edit during session)
386
+ if (agentToolsMd) {
387
+ try {
388
+ await Bun.write(TOOLS_MD_PATH, agentToolsMd);
389
+ log.info("Wrote TOOLS.md to workspace");
390
+ } catch (err) {
391
+ log.warn(`Could not write TOOLS.md: ${(err as Error).message}`);
392
+ }
393
+ }
394
+ ```
395
+
396
+ Note: Setup script only creates if it doesn't exist — the entrypoint already composed/prepended it at container start. TOOLS.md always writes (like SOUL.md/IDENTITY.md) since it's a pure identity file with no operator-mounting concern.
397
+
398
+ Also extend the profile fetch at `runner.ts:1531-1549` to extract `agentSetupScript = profile.setupScript` and `agentToolsMd = profile.toolsMd`.
399
+
400
+ #### 2. Stop Hook Sync
401
+ **File**: `src/hooks/hook.ts`
402
+ **Changes**: In the Stop handler (~line 675-683), after `syncIdentityFilesToServer()`, add setup script sync. For TOOLS.md, extend the existing `syncIdentityFilesToServer()` to include it (since TOOLS.md is an identity file and follows the same pattern — this avoids an extra HTTP call):
403
+
404
+ ```typescript
405
+ // Sync setup script back to DB (separate — has marker extraction logic)
406
+ try {
407
+ await syncSetupScriptToServer(agentInfo.id);
408
+ } catch { /* non-blocking */ }
409
+ ```
410
+
411
+ **Extend `syncIdentityFilesToServer`** (~line 288-323): Add TOOLS.md alongside the existing SOUL.md and IDENTITY.md reads:
412
+
413
+ ```typescript
414
+ const TOOLS_MD_PATH = "/workspace/TOOLS.md";
415
+
416
+ // Inside syncIdentityFilesToServer, after reading SOUL.md and IDENTITY.md:
417
+ try {
418
+ const toolsMdFile = Bun.file(TOOLS_MD_PATH);
419
+ if (await toolsMdFile.exists()) {
420
+ const content = await toolsMdFile.text();
421
+ if (content.trim() && content.length <= 65536) {
422
+ updates.toolsMd = content;
423
+ }
424
+ }
425
+ } catch { /* skip */ }
426
+ ```
427
+
428
+ This sends `{ soulMd, identityMd, toolsMd }` in a single PUT call, consistent with the existing pattern.
429
+
430
+ **Add helper function `syncSetupScriptToServer`** (separate because of marker extraction logic):
431
+
432
+ ```typescript
433
+ const SETUP_SCRIPT_PATH = "/workspace/start-up.sh";
434
+
435
+ const syncSetupScriptToServer = async (agentId: string): Promise<void> => {
436
+ if (!mcpConfig) return;
437
+
438
+ const file = Bun.file(SETUP_SCRIPT_PATH);
439
+ if (!(await file.exists())) return;
440
+
441
+ const raw = await file.text();
442
+ if (!raw.trim()) return;
443
+
444
+ const markerStart = "# === Agent-managed setup (from DB) ===";
445
+ const markerEnd = "# === End agent-managed setup ===";
446
+ const startIdx = raw.indexOf(markerStart);
447
+ const endIdx = raw.indexOf(markerEnd);
448
+
449
+ let content: string;
450
+ if (startIdx !== -1 && endIdx !== -1) {
451
+ // Markers present — extract ONLY the content between them.
452
+ // Content after the end marker is operator-mounted and must NOT be stored,
453
+ // otherwise it would be duplicated on next container restart (prepend + original).
454
+ content = raw.substring(startIdx + markerStart.length, endIdx).trim();
455
+ } else {
456
+ // No markers — agent created/replaced the entire file. Store as-is minus shebang.
457
+ content = raw.replace(/^#!\/bin\/bash\n/, "").trim();
458
+ }
459
+
460
+ if (!content || content.length > 65536) return;
461
+
462
+ try {
463
+ await fetch(`${getBaseUrl()}/api/agents/${agentId}/profile`, {
464
+ method: "PUT",
465
+ headers: {
466
+ ...mcpConfig.headers,
467
+ "Content-Type": "application/json",
468
+ },
469
+ body: JSON.stringify({ setupScript: content }),
470
+ });
471
+ } catch { /* silently fail */ }
472
+ };
473
+ ```
474
+
475
+ **Why extract between markers only:** The entrypoint composes the file as:
476
+ ```
477
+ #!/bin/bash
478
+ # === Agent-managed setup (from DB) ===
479
+ <agent content>
480
+ # === End agent-managed setup ===
481
+ <operator's original start-up.sh content>
482
+ ```
483
+ If we stored the full file, operator content would be saved to DB and then prepended again on next restart, duplicating with each cycle. Extracting only between markers ensures clean round-tripping.
484
+
485
+ **Trade-off:** If an agent adds lines *after* the end marker (e.g., appending to the file), those additions won't be persisted. The SOUL.md "Growth Mindset" directives should instruct agents to edit between the markers or use the `update-profile` MCP tool.
486
+
487
+ #### 3. PostToolUse Hook for Edits
488
+ **File**: `src/hooks/hook.ts`
489
+ **Changes**: In the PostToolUse handler (~line 537), alongside the existing identity file sync detection, add detection for setup script and TOOLS.md edits:
490
+
491
+ ```typescript
492
+ if (
493
+ (toolName === "Write" || toolName === "Edit") &&
494
+ editedPath &&
495
+ editedPath.startsWith("/workspace/start-up")
496
+ ) {
497
+ try {
498
+ await syncSetupScriptToServer(agentInfo.id);
499
+ } catch { /* non-blocking */ }
500
+ }
501
+
502
+ // TOOLS.md edits are handled by the extended syncIdentityFilesToServer
503
+ // which already triggers on identity file edits. Add TOOLS.md path detection:
504
+ if (
505
+ (toolName === "Write" || toolName === "Edit") &&
506
+ editedPath === "/workspace/TOOLS.md"
507
+ ) {
508
+ try {
509
+ await syncIdentityFilesToServer(agentInfo.id);
510
+ } catch { /* non-blocking */ }
511
+ }
512
+ ```
513
+
514
+ This catches edits to any `/workspace/start-up.*` variant and `/workspace/TOOLS.md`.
515
+
516
+ ### Success Criteria:
517
+
518
+ #### Automated Verification:
519
+ - [x] TypeScript compiles: `bun run tsc:check`
520
+ - [x] Lint passes: `bun run lint:fix`
521
+ - [x] Existing tests pass: `bun test` (325 pass, 0 fail)
522
+
523
+ #### Manual Verification:
524
+ - [x] Set agent's setupScript, start Docker worker — `/workspace/start-up.sh` created with correct content
525
+ - [x] Verify `/workspace/TOOLS.md` exists with default template (Repos, Services, Infrastructure sections)
526
+ - [x] Edit `/workspace/start-up.sh` during Claude session — PostToolUse hook synced `pip3 install httpx` to DB
527
+ - [x] Edit `/workspace/TOOLS.md` during Claude session — PostToolUse hook synced `API server at localhost:3013` to DB
528
+ - [x] Stop hook syncs both files to DB (verified via task completion + DB query)
529
+ - [x] Restart container — updated script runs and TOOLS.md restored from DB
530
+
531
+ **Implementation Note**: After completing this phase, pause for manual confirmation. Docker testing required.
532
+
533
+ ---
534
+
535
+ ## Phase 5: Self-Improvement Directives + TOOLS.md Template
536
+
537
+ ### Overview
538
+ Update the SOUL.md template and base prompt to include explicit self-improvement guidance about setup scripts, TOOLS.md, and environment evolution. Add a `generateDefaultToolsMd()` template inspired by [OpenClaw's TOOLS.md pattern](https://github.com/openclaw/openclaw/blob/main/docs/reference/templates/TOOLS.md) — a structured personal reference for environment-specific operational knowledge.
539
+
540
+ ### Changes Required:
541
+
542
+ #### 1. `generateDefaultToolsMd()` Template
543
+ **File**: `src/be/db.ts`
544
+ **Changes**: Add a new function after `generateDefaultIdentityMd()` (~line 2317):
545
+
546
+ ```typescript
547
+ export function generateDefaultToolsMd(agent: {
548
+ name: string;
549
+ role?: string;
550
+ }): string {
551
+ return `# TOOLS.md — ${agent.name}
552
+
553
+ Skills define *how* tools work. This file is for *your* specifics.
554
+
555
+ ## What Goes Here
556
+
557
+ Environment-specific knowledge that's unique to your setup:
558
+ - Repos you work with and their conventions
559
+ - Services, ports, and endpoints you interact with
560
+ - SSH hosts and access patterns
561
+ - API keys and auth patterns (references, not secrets)
562
+ - CLI tools and their quirks
563
+ - Anything that makes your job easier to remember
564
+
565
+ ## Repos
566
+
567
+ <!-- Add repos you work with: name, path, conventions, gotchas -->
568
+
569
+ ## Services
570
+
571
+ <!-- Add services you interact with: name, port, health check, notes -->
572
+
573
+ ## Infrastructure
574
+
575
+ <!-- SSH hosts, Docker registries, cloud resources -->
576
+
577
+ ## APIs & Integrations
578
+
579
+ <!-- Endpoints, auth patterns, rate limits -->
580
+
581
+ ## Tools & Shortcuts
582
+
583
+ <!-- CLI aliases, scripts, preferred tools for specific tasks -->
584
+
585
+ ## Notes
586
+
587
+ <!-- Anything else environment-specific -->
588
+
589
+ ---
590
+ *This file is yours. Update it as you discover your environment. Changes persist across sessions.*
591
+ `;
592
+ }
593
+ ```
594
+
595
+ **Key design principle** (from [OpenClaw](https://github.com/openclaw/openclaw/blob/main/docs/reference/templates/TOOLS.md)): "Skills are shared. Your setup is yours. Keeping them apart means you can update skills without losing your notes, and share skills without leaking your infrastructure."
596
+
597
+ #### 2. Runner Default Generation
598
+ **File**: `src/commands/runner.ts`
599
+ **Changes**: In the default generation fallback section (~line 1553-1586), alongside the existing `generateDefaultSoulMd()` and `generateDefaultIdentityMd()` calls, also generate default TOOLS.md:
600
+
601
+ ```typescript
602
+ if (!agentToolsMd) {
603
+ agentToolsMd = generateDefaultToolsMd({ name: agentProfileName || role, role });
604
+ // Push default to server
605
+ await fetch(`${apiUrl}/api/agents/${agentId}/profile`, {
606
+ method: "PUT",
607
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
608
+ body: JSON.stringify({ toolsMd: agentToolsMd }),
609
+ });
610
+ }
611
+ ```
612
+
613
+ #### 3. SOUL.md Template Update
614
+ **File**: `src/be/db.ts` — `generateDefaultSoulMd()` (~line 2240)
615
+ **Changes**: Add a new section after `## Boundaries` and before `## Self-Evolution`:
616
+
617
+ ```markdown
618
+ ## Growth Mindset
619
+
620
+ After completing tasks, reflect on what made them harder or easier:
621
+ - **Tools you wished you had?** Add them to your setup script (\`/workspace/start-up.sh\`).
622
+ It runs at every container start — your environment improves automatically.
623
+ Edit between the \`# === Agent-managed setup\` markers to ensure changes persist.
624
+ Or use the \`update-profile\` tool with the \`setupScript\` field.
625
+ - **Environment knowledge gained?** Record it in your TOOLS.md — repos, services, APIs, infra.
626
+ - **Patterns you discovered?** Record them in your CLAUDE.md notes.
627
+ - **Mistakes you want to avoid?** Add guardrails to your setup script or notes.
628
+
629
+ Your setup script and TOOLS.md are yours to evolve. Start small and iterate.
630
+ ```
631
+
632
+ Update the `## Self-Evolution` section to reference all self-evolving artifacts:
633
+
634
+ ```markdown
635
+ ## Self-Evolution
636
+
637
+ These files are yours. As you work and learn, refine them:
638
+ - **This file (SOUL.md)** — Your persona and values
639
+ - **IDENTITY.md** — Your expertise and working style
640
+ - **TOOLS.md** — Your environment-specific knowledge (repos, services, infra, APIs)
641
+ - **/workspace/start-up.sh** — Your environment setup (tools, configs, aliases)
642
+ - **CLAUDE.md** — Your operational notes and learnings
643
+
644
+ Changes to all of these persist across sessions.
645
+ ```
646
+
647
+ #### 4. Base Prompt Filesystem Section Update
648
+ **File**: `src/prompts/base-prompt.ts` — `BASE_PROMPT_FILESYSTEM` (~line 204)
649
+ **Changes**: Add mentions of the setup script and TOOLS.md after the existing filesystem description:
650
+
651
+ ```markdown
652
+ ### Environment Setup
653
+ Your setup script at \`/workspace/start-up.sh\` runs at every container start.
654
+ Use it to install tools, configure your environment, or set up workflows.
655
+ If the file has \`# === Agent-managed setup\` markers, edit between them — content
656
+ between markers is what persists to the database. You can also use the \`update-profile\`
657
+ tool with the \`setupScript\` field.
658
+
659
+ ### Operational Knowledge
660
+ Your \`/workspace/TOOLS.md\` file stores environment-specific knowledge — repos you work with,
661
+ services and ports, SSH hosts, APIs, tool preferences. Update it as you learn about your environment.
662
+ It persists across sessions.
663
+ ```
664
+
665
+ **Design decision — TOOLS.md is NOT injected into the system prompt.** Unlike SOUL.md and IDENTITY.md (which are injected via `getBasePrompt()` at `base-prompt.ts:289-298`), TOOLS.md is a reference file the agent reads on demand via the `Read` tool. Rationale: TOOLS.md can grow large with operational details (repo lists, service inventories, API endpoints), and injecting it into every system prompt would waste tokens. Agents are told about its existence in the filesystem section and can read it when the task requires environment knowledge. The `BasePromptArgs` type does NOT get a `toolsMd` parameter.
666
+
667
+ #### 5. Updated Default CLAUDE.md Template
668
+ **File**: `src/be/db.ts` — `generateDefaultClaudeMd()` (~line 2200)
669
+ **Changes**: Add mentions of the setup script and TOOLS.md in the "Your Identity Files" section:
670
+
671
+ ```markdown
672
+ - **`/workspace/TOOLS.md`** — Your environment-specific knowledge (repos, services, APIs, infra)
673
+ - **`/workspace/start-up.sh`** — Your setup script (runs at container start, add tools/configs here)
674
+ ```
675
+
676
+ ### Success Criteria:
677
+
678
+ #### Automated Verification:
679
+ - [x] TypeScript compiles: `bun run tsc:check`
680
+ - [x] Lint passes: `bun run lint:fix`
681
+ - [x] Existing tests pass: `bun test` (325 pass, 0 fail)
682
+
683
+ #### Manual Verification:
684
+ - [x] Register a new agent — verify SOUL.md includes "Growth Mindset" section
685
+ - [x] Verify TOOLS.md is generated with structured categories (Repos, Services, Infrastructure, etc.)
686
+ - [x] Verify base prompt includes "Environment Setup" and "Operational Knowledge" sections
687
+ - [x] Verify CLAUDE.md template references both `/workspace/TOOLS.md` and `/workspace/start-up.sh`
688
+
689
+ **Implementation Note**: After completing this phase, pause for manual confirmation.
690
+
691
+ ---
692
+
693
+ ## Testing Strategy
694
+
695
+ ### Automated Tests
696
+ - `bun run tsc:check` — Type checking after each phase
697
+ - `bun run lint:fix` — Lint after each phase
698
+ - `bun test` — All existing tests pass (no regressions)
699
+
700
+ ### Unit Tests (new file: `src/tests/setup-script.test.ts`)
701
+ - Migration: `setupScript` and `toolsMd` columns exist after `initDb()`
702
+ - `updateAgentProfile` with `setupScript` — persists and returns
703
+ - `updateAgentProfile` with `toolsMd` — persists and returns
704
+ - `getAgentById` returns `setupScript` and `toolsMd` fields
705
+ - `GET /api/agents/:id/setup-script` returns both agent and global scripts
706
+ - Global script from `swarm_config` with key `SETUP_SCRIPT` is returned
707
+ - `generateDefaultToolsMd()` returns structured template with expected sections
708
+
709
+ ### What's NOT Tested Automatically
710
+ - Docker entrypoint script composition (requires Docker container)
711
+ - Stop hook sync for setup script + TOOLS.md (requires real Claude session)
712
+ - PostToolUse hook detection for both file types (requires real Claude session)
713
+ - These are tested manually via the E2E section below.
714
+
715
+ ---
716
+
717
+ ## Manual E2E Verification
718
+
719
+ ```bash
720
+ # 1. Start server
721
+ bun run start:http
722
+
723
+ # 2. Register an agent (or use existing)
724
+ AGENT_ID="<agent-id>"
725
+
726
+ # 3. Set per-agent setup script
727
+ curl -X PUT -H "Authorization: Bearer 123123" \
728
+ -H "Content-Type: application/json" \
729
+ -d '{"setupScript":"echo \"Agent setup ran at $(date)\" > /tmp/agent-setup-test\napt-get update -qq && apt-get install -y -qq jq > /dev/null 2>&1 || true"}' \
730
+ http://localhost:3013/api/agents/$AGENT_ID/profile | jq '.setupScript'
731
+
732
+ # 4. Set global setup script via swarm_config
733
+ curl -X PUT -H "Authorization: Bearer 123123" \
734
+ -H "Content-Type: application/json" \
735
+ -d '{"scope":"global","key":"SETUP_SCRIPT","value":"echo \"Global setup ran\" > /tmp/global-setup-test"}' \
736
+ http://localhost:3013/api/config | jq .
737
+
738
+ # 5. Verify fetch endpoint
739
+ curl -H "Authorization: Bearer 123123" \
740
+ -H "X-Agent-ID: $AGENT_ID" \
741
+ http://localhost:3013/api/agents/$AGENT_ID/setup-script | jq .
742
+ # Should show both setupScript and globalSetupScript
743
+
744
+ # 6. Build and start Docker worker
745
+ bun run docker:build:worker
746
+ # Start worker container pointing at API
747
+
748
+ # 7. Verify scripts ran
749
+ docker exec <container> cat /tmp/global-setup-test # "Global setup ran"
750
+ docker exec <container> cat /tmp/agent-setup-test # "Agent setup ran at ..."
751
+ docker exec <container> which jq # Should show jq path
752
+
753
+ # 8. Create a task that edits the setup script
754
+ curl -X POST -H "Authorization: Bearer 123123" \
755
+ -H "Content-Type: application/json" \
756
+ -d "{\"task\":\"Add 'pip install requests' to your setup script at /workspace/start-up.sh\",\"agentId\":\"$AGENT_ID\"}" \
757
+ http://localhost:3013/api/tasks | jq .
758
+
759
+ # 9. After task completes, verify DB was updated
760
+ curl -H "Authorization: Bearer 123123" \
761
+ http://localhost:3013/api/agents/$AGENT_ID/setup-script | jq '.setupScript'
762
+ # Should include the pip install line
763
+
764
+ # 10. Restart worker, verify updated script runs
765
+ docker restart <container>
766
+ docker exec <container> python3 -c "import requests; print(requests.__version__)"
767
+
768
+ # --- TOOLS.md lifecycle ---
769
+
770
+ # 11. Verify TOOLS.md was generated with default template
771
+ docker exec <container> cat /workspace/TOOLS.md
772
+ # Should have structured sections: Repos, Services, Infrastructure, APIs, Tools & Shortcuts
773
+
774
+ # 12. Set TOOLS.md via API
775
+ curl -X PUT -H "Authorization: Bearer 123123" \
776
+ -H "Content-Type: application/json" \
777
+ -d '{"toolsMd":"# TOOLS.md\n\n## Repos\n- agent-swarm → /workspace/shared, Bun + TypeScript\n\n## Services\n- API → localhost:3013\n"}' \
778
+ http://localhost:3013/api/agents/$AGENT_ID/profile | jq '.toolsMd'
779
+
780
+ # 13. Restart worker, verify TOOLS.md is restored from DB
781
+ docker restart <container>
782
+ docker exec <container> cat /workspace/TOOLS.md
783
+ # Should show the content set in step 12
784
+
785
+ # 14. Create a task that edits TOOLS.md
786
+ curl -X POST -H "Authorization: Bearer 123123" \
787
+ -H "Content-Type: application/json" \
788
+ -d "{\"task\":\"Add a note about Redis on port 6379 to your /workspace/TOOLS.md under Services\",\"agentId\":\"$AGENT_ID\"}" \
789
+ http://localhost:3013/api/tasks | jq .
790
+
791
+ # 15. After task completes, verify DB was updated with TOOLS.md changes
792
+ curl -H "Authorization: Bearer 123123" \
793
+ http://localhost:3013/api/agents/$AGENT_ID | jq '.toolsMd'
794
+ # Should include the Redis note
795
+ ```
796
+
797
+ ## References
798
+
799
+ - Research: `thoughts/taras/research/2026-02-19-swarm-gaps-implementation.md` (Gap 5 section, lines 304-331)
800
+ - Base research: `thoughts/taras/research/2026-02-19-agent-native-swarm-architecture.md`
801
+ - Identity implementation: `thoughts/taras/plans/2026-02-20-worker-identity.md` (pattern for file lifecycle)
802
+ - Env management: `thoughts/taras/plans/2026-02-20-env-management.md` (swarm_config table)
803
+ - TOOLS.md inspiration: [OpenClaw TOOLS.md template](https://github.com/openclaw/openclaw/blob/main/docs/reference/templates/TOOLS.md) (environment-specific reference pattern)