heyio 1.12.1 → 3.0.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 (327) hide show
  1. package/dist/api/middleware/auth.d.ts +14 -0
  2. package/dist/api/middleware/auth.d.ts.map +1 -0
  3. package/dist/api/middleware/auth.js +66 -0
  4. package/dist/api/middleware/auth.js.map +1 -0
  5. package/dist/api/notifications.d.ts +14 -0
  6. package/dist/api/notifications.d.ts.map +1 -0
  7. package/dist/api/notifications.js +112 -0
  8. package/dist/api/notifications.js.map +1 -0
  9. package/dist/api/routes/activity.d.ts +3 -0
  10. package/dist/api/routes/activity.d.ts.map +1 -0
  11. package/dist/api/routes/activity.js +28 -0
  12. package/dist/api/routes/activity.js.map +1 -0
  13. package/dist/api/routes/attachments.d.ts +3 -0
  14. package/dist/api/routes/attachments.d.ts.map +1 -0
  15. package/dist/api/routes/attachments.js +83 -0
  16. package/dist/api/routes/attachments.js.map +1 -0
  17. package/dist/api/routes/config.d.ts +3 -0
  18. package/dist/api/routes/config.d.ts.map +1 -0
  19. package/dist/api/routes/config.js +106 -0
  20. package/dist/api/routes/config.js.map +1 -0
  21. package/dist/api/routes/conversations.d.ts +3 -0
  22. package/dist/api/routes/conversations.d.ts.map +1 -0
  23. package/dist/api/routes/conversations.js +69 -0
  24. package/dist/api/routes/conversations.js.map +1 -0
  25. package/dist/api/routes/health.d.ts +3 -0
  26. package/dist/api/routes/health.d.ts.map +1 -0
  27. package/dist/api/routes/health.js +16 -0
  28. package/dist/api/routes/health.js.map +1 -0
  29. package/dist/api/routes/inbox.d.ts +3 -0
  30. package/dist/api/routes/inbox.d.ts.map +1 -0
  31. package/dist/api/routes/inbox.js +88 -0
  32. package/dist/api/routes/inbox.js.map +1 -0
  33. package/dist/api/routes/schedules.d.ts +3 -0
  34. package/dist/api/routes/schedules.d.ts.map +1 -0
  35. package/dist/api/routes/schedules.js +96 -0
  36. package/dist/api/routes/schedules.js.map +1 -0
  37. package/dist/api/routes/skills.d.ts +2 -0
  38. package/dist/api/routes/skills.d.ts.map +1 -0
  39. package/dist/api/routes/skills.js +85 -0
  40. package/dist/api/routes/skills.js.map +1 -0
  41. package/dist/api/routes/squads.d.ts +3 -0
  42. package/dist/api/routes/squads.d.ts.map +1 -0
  43. package/dist/api/routes/squads.js +129 -0
  44. package/dist/api/routes/squads.js.map +1 -0
  45. package/dist/api/routes/usage.d.ts +3 -0
  46. package/dist/api/routes/usage.d.ts.map +1 -0
  47. package/dist/api/routes/usage.js +55 -0
  48. package/dist/api/routes/usage.js.map +1 -0
  49. package/dist/api/routes/wiki.d.ts +2 -0
  50. package/dist/api/routes/wiki.d.ts.map +1 -0
  51. package/dist/api/routes/wiki.js +43 -0
  52. package/dist/api/routes/wiki.js.map +1 -0
  53. package/dist/api/server.d.ts +7 -0
  54. package/dist/api/server.d.ts.map +1 -0
  55. package/dist/api/server.js +136 -634
  56. package/dist/api/server.js.map +1 -0
  57. package/dist/config.d.ts +3 -0
  58. package/dist/config.d.ts.map +1 -0
  59. package/dist/config.js +2 -91
  60. package/dist/config.js.map +1 -0
  61. package/dist/copilot/client.d.ts +5 -0
  62. package/dist/copilot/client.d.ts.map +1 -0
  63. package/dist/copilot/client.js +19 -11
  64. package/dist/copilot/client.js.map +1 -0
  65. package/dist/copilot/health-monitor.d.ts +14 -0
  66. package/dist/copilot/health-monitor.d.ts.map +1 -0
  67. package/dist/copilot/health-monitor.js +70 -0
  68. package/dist/copilot/health-monitor.js.map +1 -0
  69. package/dist/copilot/orchestrator.d.ts +5 -0
  70. package/dist/copilot/orchestrator.d.ts.map +1 -0
  71. package/dist/copilot/orchestrator.js +127 -123
  72. package/dist/copilot/orchestrator.js.map +1 -0
  73. package/dist/copilot/tools.d.ts +49 -0
  74. package/dist/copilot/tools.d.ts.map +1 -0
  75. package/dist/copilot/tools.js +545 -321
  76. package/dist/copilot/tools.js.map +1 -0
  77. package/dist/index.d.ts +3 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +82 -26
  80. package/dist/index.js.map +1 -0
  81. package/dist/logging/logger.d.ts +6 -0
  82. package/dist/logging/logger.d.ts.map +1 -0
  83. package/dist/logging/logger.js +21 -0
  84. package/dist/logging/logger.js.map +1 -0
  85. package/dist/models/index.d.ts +6 -0
  86. package/dist/models/index.d.ts.map +1 -0
  87. package/dist/models/index.js +4 -0
  88. package/dist/models/index.js.map +1 -0
  89. package/dist/models/pricing.d.ts +25 -0
  90. package/dist/models/pricing.d.ts.map +1 -0
  91. package/dist/models/pricing.js +96 -0
  92. package/dist/models/pricing.js.map +1 -0
  93. package/dist/models/registry.d.ts +34 -0
  94. package/dist/models/registry.d.ts.map +1 -0
  95. package/dist/models/registry.js +109 -0
  96. package/dist/models/registry.js.map +1 -0
  97. package/dist/models/token-tracker.d.ts +40 -0
  98. package/dist/models/token-tracker.d.ts.map +1 -0
  99. package/dist/models/token-tracker.js +102 -0
  100. package/dist/models/token-tracker.js.map +1 -0
  101. package/dist/scheduler/engine.d.ts +9 -0
  102. package/dist/scheduler/engine.d.ts.map +1 -0
  103. package/dist/scheduler/engine.js +127 -0
  104. package/dist/scheduler/engine.js.map +1 -0
  105. package/dist/skills/index.d.ts +3 -0
  106. package/dist/skills/index.d.ts.map +1 -0
  107. package/dist/skills/index.js +2 -0
  108. package/dist/skills/index.js.map +1 -0
  109. package/dist/skills/store.d.ts +52 -0
  110. package/dist/skills/store.d.ts.map +1 -0
  111. package/dist/skills/store.js +148 -0
  112. package/dist/skills/store.js.map +1 -0
  113. package/dist/squad/agent.d.ts +46 -0
  114. package/dist/squad/agent.d.ts.map +1 -0
  115. package/dist/squad/agent.js +261 -0
  116. package/dist/squad/agent.js.map +1 -0
  117. package/dist/squad/autonomy.d.ts +16 -0
  118. package/dist/squad/autonomy.d.ts.map +1 -0
  119. package/dist/squad/autonomy.js +63 -0
  120. package/dist/squad/autonomy.js.map +1 -0
  121. package/dist/squad/event-bus.d.ts +22 -0
  122. package/dist/squad/event-bus.d.ts.map +1 -0
  123. package/dist/squad/event-bus.js +56 -0
  124. package/dist/squad/event-bus.js.map +1 -0
  125. package/dist/squad/execution/index.d.ts +12 -0
  126. package/dist/squad/execution/index.d.ts.map +1 -0
  127. package/dist/squad/execution/index.js +7 -0
  128. package/dist/squad/execution/index.js.map +1 -0
  129. package/dist/squad/execution/instance.d.ts +40 -0
  130. package/dist/squad/execution/instance.d.ts.map +1 -0
  131. package/dist/squad/execution/instance.js +138 -0
  132. package/dist/squad/execution/instance.js.map +1 -0
  133. package/dist/squad/execution/meeting.d.ts +25 -0
  134. package/dist/squad/execution/meeting.d.ts.map +1 -0
  135. package/dist/squad/execution/meeting.js +140 -0
  136. package/dist/squad/execution/meeting.js.map +1 -0
  137. package/dist/squad/execution/pr.d.ts +15 -0
  138. package/dist/squad/execution/pr.d.ts.map +1 -0
  139. package/dist/squad/execution/pr.js +93 -0
  140. package/dist/squad/execution/pr.js.map +1 -0
  141. package/dist/squad/execution/runner.d.ts +22 -0
  142. package/dist/squad/execution/runner.d.ts.map +1 -0
  143. package/dist/squad/execution/runner.js +68 -0
  144. package/dist/squad/execution/runner.js.map +1 -0
  145. package/dist/squad/execution/tasks.d.ts +11 -0
  146. package/dist/squad/execution/tasks.d.ts.map +1 -0
  147. package/dist/squad/execution/tasks.js +85 -0
  148. package/dist/squad/execution/tasks.js.map +1 -0
  149. package/dist/squad/execution/worktree.d.ts +26 -0
  150. package/dist/squad/execution/worktree.d.ts.map +1 -0
  151. package/dist/squad/execution/worktree.js +111 -0
  152. package/dist/squad/execution/worktree.js.map +1 -0
  153. package/dist/squad/hiring.d.ts +32 -0
  154. package/dist/squad/hiring.d.ts.map +1 -0
  155. package/dist/squad/hiring.js +200 -0
  156. package/dist/squad/hiring.js.map +1 -0
  157. package/dist/squad/index.d.ts +8 -0
  158. package/dist/squad/index.d.ts.map +1 -0
  159. package/dist/squad/index.js +6 -0
  160. package/dist/squad/index.js.map +1 -0
  161. package/dist/squad/manager.d.ts +48 -0
  162. package/dist/squad/manager.d.ts.map +1 -0
  163. package/dist/squad/manager.js +274 -0
  164. package/dist/squad/manager.js.map +1 -0
  165. package/dist/squad/name-generator.d.ts +16 -0
  166. package/dist/squad/name-generator.d.ts.map +1 -0
  167. package/dist/squad/name-generator.js +113 -0
  168. package/dist/squad/name-generator.js.map +1 -0
  169. package/dist/squad/roles/templates.d.ts +5 -0
  170. package/dist/squad/roles/templates.d.ts.map +1 -0
  171. package/dist/squad/roles/templates.js +102 -0
  172. package/dist/squad/roles/templates.js.map +1 -0
  173. package/dist/squad/skill-parser.d.ts +36 -0
  174. package/dist/squad/skill-parser.d.ts.map +1 -0
  175. package/dist/squad/skill-parser.js +83 -0
  176. package/dist/squad/skill-parser.js.map +1 -0
  177. package/dist/squad/source-resolver.d.ts +20 -0
  178. package/dist/squad/source-resolver.d.ts.map +1 -0
  179. package/dist/squad/source-resolver.js +52 -0
  180. package/dist/squad/source-resolver.js.map +1 -0
  181. package/dist/store/activity.d.ts +43 -0
  182. package/dist/store/activity.d.ts.map +1 -0
  183. package/dist/store/activity.js +131 -0
  184. package/dist/store/activity.js.map +1 -0
  185. package/dist/store/db.d.ts +5 -0
  186. package/dist/store/db.d.ts.map +1 -0
  187. package/dist/store/db.js +209 -248
  188. package/dist/store/db.js.map +1 -0
  189. package/dist/store/inbox.d.ts +53 -0
  190. package/dist/store/inbox.d.ts.map +1 -0
  191. package/dist/store/inbox.js +151 -0
  192. package/dist/store/inbox.js.map +1 -0
  193. package/dist/store/schedules.d.ts +53 -0
  194. package/dist/store/schedules.d.ts.map +1 -0
  195. package/dist/store/schedules.js +149 -54
  196. package/dist/store/schedules.js.map +1 -0
  197. package/dist/wiki/index.d.ts +3 -0
  198. package/dist/wiki/index.d.ts.map +1 -0
  199. package/dist/wiki/index.js +2 -0
  200. package/dist/wiki/index.js.map +1 -0
  201. package/dist/wiki/store.d.ts +49 -0
  202. package/dist/wiki/store.d.ts.map +1 -0
  203. package/dist/wiki/store.js +115 -0
  204. package/dist/wiki/store.js.map +1 -0
  205. package/package.json +52 -56
  206. package/src/api/middleware/auth.ts +76 -0
  207. package/src/api/notifications.ts +122 -0
  208. package/src/api/routes/activity.ts +29 -0
  209. package/src/api/routes/attachments.ts +93 -0
  210. package/src/api/routes/config.ts +115 -0
  211. package/src/api/routes/conversations.ts +87 -0
  212. package/src/api/routes/health.ts +18 -0
  213. package/src/api/routes/inbox.ts +98 -0
  214. package/src/api/routes/schedules.ts +121 -0
  215. package/src/api/routes/skills.ts +105 -0
  216. package/src/api/routes/squads.ts +145 -0
  217. package/src/api/routes/usage.ts +57 -0
  218. package/src/api/routes/wiki.ts +49 -0
  219. package/src/api/server.ts +186 -0
  220. package/src/config.ts +3 -0
  221. package/src/copilot/client.ts +42 -0
  222. package/src/copilot/health-monitor.ts +85 -0
  223. package/src/copilot/orchestrator.ts +222 -0
  224. package/src/copilot/tools.ts +707 -0
  225. package/src/index.ts +112 -0
  226. package/src/logging/logger.ts +26 -0
  227. package/src/models/index.ts +11 -0
  228. package/src/models/pricing.ts +121 -0
  229. package/src/models/registry.ts +131 -0
  230. package/src/models/token-tracker.ts +151 -0
  231. package/src/scheduler/engine.ts +146 -0
  232. package/src/skills/index.ts +13 -0
  233. package/src/skills/store.ts +188 -0
  234. package/src/squad/agent.ts +326 -0
  235. package/src/squad/autonomy.ts +78 -0
  236. package/src/squad/event-bus.ts +71 -0
  237. package/src/squad/execution/index.ts +17 -0
  238. package/src/squad/execution/instance.ts +186 -0
  239. package/src/squad/execution/meeting.ts +191 -0
  240. package/src/squad/execution/pr.ts +127 -0
  241. package/src/squad/execution/runner.ts +97 -0
  242. package/src/squad/execution/tasks.ts +111 -0
  243. package/src/squad/execution/worktree.ts +138 -0
  244. package/src/squad/hiring.ts +222 -0
  245. package/src/squad/index.ts +17 -0
  246. package/src/squad/manager.ts +337 -0
  247. package/src/squad/name-generator.ts +135 -0
  248. package/src/squad/roles/templates.ts +104 -0
  249. package/src/squad/skill-parser.ts +120 -0
  250. package/src/squad/source-resolver.ts +57 -0
  251. package/src/store/activity.ts +176 -0
  252. package/src/store/db.ts +237 -0
  253. package/src/store/inbox.ts +199 -0
  254. package/src/store/schedules.ts +199 -0
  255. package/src/wiki/index.ts +12 -0
  256. package/src/wiki/store.ts +139 -0
  257. package/tsconfig.json +9 -0
  258. package/LICENSE +0 -21
  259. package/README.md +0 -333
  260. package/dist/api/auth.js +0 -46
  261. package/dist/chat/attachments.js +0 -112
  262. package/dist/copilot/agents.js +0 -309
  263. package/dist/copilot/ceremonies.js +0 -174
  264. package/dist/copilot/gh-token.js +0 -64
  265. package/dist/copilot/io-scheduler.js +0 -79
  266. package/dist/copilot/model-router.js +0 -114
  267. package/dist/copilot/scheduler.js +0 -88
  268. package/dist/copilot/skills.js +0 -246
  269. package/dist/copilot/specialist-runner.js +0 -191
  270. package/dist/copilot/squad-tools.js +0 -258
  271. package/dist/copilot/system-message.js +0 -86
  272. package/dist/copilot/token-tracker.js +0 -98
  273. package/dist/copilot/trigger-schedule.js +0 -33
  274. package/dist/daemon.js +0 -67
  275. package/dist/logging.js +0 -27
  276. package/dist/mcp/config.js +0 -29
  277. package/dist/mcp/index.js +0 -3
  278. package/dist/mcp/registry.js +0 -42
  279. package/dist/notify.js +0 -25
  280. package/dist/paths.js +0 -17
  281. package/dist/setup.js +0 -35
  282. package/dist/store/agent-events.js +0 -19
  283. package/dist/store/audit-log.js +0 -71
  284. package/dist/store/conversations.js +0 -164
  285. package/dist/store/feed.js +0 -44
  286. package/dist/store/instances.js +0 -75
  287. package/dist/store/squad-colors.js +0 -23
  288. package/dist/store/squads.js +0 -60
  289. package/dist/store/tasks.js +0 -78
  290. package/dist/store/token-usage.js +0 -94
  291. package/dist/telegram/bot.js +0 -41
  292. package/dist/telegram/handlers.js +0 -42
  293. package/dist/watchdog.js +0 -37
  294. package/dist/wiki/backlinks.js +0 -51
  295. package/dist/wiki/fs.js +0 -108
  296. package/dist/wiki/search.js +0 -47
  297. package/web-dist/assets/AuditLogView-C5QtUQBq.js +0 -6
  298. package/web-dist/assets/ChatView-DLu9BMg8.js +0 -1
  299. package/web-dist/assets/FeedView-6OV-l6Gl.js +0 -6
  300. package/web-dist/assets/HistoryView-DizPqv0y.js +0 -1
  301. package/web-dist/assets/LoginView-CG1O9fmR.js +0 -1
  302. package/web-dist/assets/McpView-TJN-fZvI.js +0 -1
  303. package/web-dist/assets/SchedulesView-BDFpImX6.js +0 -6
  304. package/web-dist/assets/SettingsView-D-K1iC1c.js +0 -1
  305. package/web-dist/assets/SkillsView-DnNmO192.js +0 -15
  306. package/web-dist/assets/SquadDetailView-BBvrgHzn.js +0 -26
  307. package/web-dist/assets/SquadHealthView-DF2zF9D3.js +0 -11
  308. package/web-dist/assets/SquadsView-CPVzko7k.js +0 -6
  309. package/web-dist/assets/ToggleSwitch.vue_vue_type_script_setup_true_lang-Bk_t9_Rn.js +0 -1
  310. package/web-dist/assets/UsageView-OcyM5k14.js +0 -16
  311. package/web-dist/assets/WikiView-KhFqBZI0.js +0 -26
  312. package/web-dist/assets/api-BiDVwQrs.js +0 -1
  313. package/web-dist/assets/arrow-left-DFbf2tii.js +0 -6
  314. package/web-dist/assets/git-branch-BLstr_Gr.js +0 -6
  315. package/web-dist/assets/index-B-o45ao1.css +0 -1
  316. package/web-dist/assets/index-DCJUYZtV.js +0 -269
  317. package/web-dist/assets/pencil-D4Zz_t0y.js +0 -6
  318. package/web-dist/assets/plus-gmwiZVfr.js +0 -6
  319. package/web-dist/assets/save-BvtAs5WB.js +0 -6
  320. package/web-dist/assets/search-BabUvoGD.js +0 -6
  321. package/web-dist/assets/squad-colors-B8B_Y-lz.js +0 -1
  322. package/web-dist/assets/trash-2-C21cNLJl.js +0 -6
  323. package/web-dist/assets/triangle-alert-BrzY_E1n.js +0 -6
  324. package/web-dist/assets/x-xgLSmc9e.js +0 -6
  325. package/web-dist/favicon.svg +0 -10
  326. package/web-dist/index.html +0 -14
  327. package/web-dist/logo.svg +0 -10
@@ -1,258 +0,0 @@
1
- import { z } from "zod";
2
- import { defineTool } from "@github/copilot-sdk";
3
- import { exec } from "node:child_process";
4
- import { promisify } from "node:util";
5
- import { join } from "node:path";
6
- import { PATHS } from "../paths.js";
7
- import { getGhToken } from "./gh-token.js";
8
- const execAsync = promisify(exec);
9
- /**
10
- * Resolve the project root directory for a squad from its repo_url.
11
- * Returns the path under ~/.io/source/{owner}/{repo} or null if unknown.
12
- */
13
- function resolveSquadProjectDir(repoUrl) {
14
- if (!repoUrl)
15
- return null;
16
- const match = repoUrl.match(/[/:]([^/]+)\/([^/.]+?)(?:\.git)?$/);
17
- if (!match)
18
- return null;
19
- const [, owner, repo] = match;
20
- return join(PATHS.source, owner, repo);
21
- }
22
- /**
23
- * Creates a scoped set of tools for squad agent sessions.
24
- * Wiki tools are sandboxed to the squad's own wiki subfolder.
25
- * Feed posts are locked to the squad's source identifier.
26
- */
27
- export function createSquadTools(squadSlug, squadId, repoUrl) {
28
- const wikiPrefix = `squads/${squadSlug}`;
29
- const projectDir = resolveSquadProjectDir(repoUrl ?? null);
30
- return [
31
- // --- Wiki Tools (scoped to squads/{slug}/) ---
32
- defineTool("wiki_read", {
33
- description: `Read a wiki page from the squad wiki (paths are relative to your squad's wiki folder — do NOT include 'squads/${squadSlug}/' prefix)`,
34
- parameters: z.object({
35
- path: z.string().describe("Page path (e.g., 'decisions.md', 'notes/architecture.md')"),
36
- }),
37
- handler: async ({ path }) => {
38
- const { readPage } = await import("../wiki/fs.js");
39
- // Strip redundant prefix if agent accidentally includes it
40
- const cleanPath = path.replace(new RegExp(`^(?:squads/${squadSlug}/)+`), "");
41
- return await readPage(`${wikiPrefix}/${cleanPath}`);
42
- },
43
- }),
44
- defineTool("wiki_write", {
45
- description: "Write or update a wiki page in the squad wiki (paths are relative — do NOT include the squad prefix)",
46
- parameters: z.object({
47
- path: z.string().describe("Page path (e.g., 'decisions.md')"),
48
- content: z.string().describe("Markdown content to write"),
49
- }),
50
- handler: async ({ path, content }) => {
51
- const { writePage } = await import("../wiki/fs.js");
52
- // Strip redundant prefix if agent accidentally includes it
53
- const cleanPath = path.replace(new RegExp(`^(?:squads/${squadSlug}/)+`), "");
54
- await writePage(`${wikiPrefix}/${cleanPath}`, content);
55
- return `Page saved: ${cleanPath}`;
56
- },
57
- }),
58
- defineTool("wiki_list", {
59
- description: "List all wiki pages in the squad wiki",
60
- parameters: z.object({}),
61
- handler: async () => {
62
- const { listPages } = await import("../wiki/fs.js");
63
- return await listPages(wikiPrefix);
64
- },
65
- }),
66
- defineTool("wiki_search", {
67
- description: "Search squad wiki pages by keyword",
68
- parameters: z.object({
69
- query: z.string().describe("Search query"),
70
- }),
71
- handler: async ({ query }) => {
72
- const { searchSquadPages } = await import("../wiki/search.js");
73
- return await searchSquadPages(query, wikiPrefix);
74
- },
75
- }),
76
- defineTool("wiki_delete", {
77
- description: "Delete a wiki page from the squad wiki",
78
- parameters: z.object({
79
- path: z.string().describe("Page path to delete"),
80
- }),
81
- handler: async ({ path }) => {
82
- const { deletePage } = await import("../wiki/fs.js");
83
- const cleanPath = path.replace(new RegExp(`^(?:squads/${squadSlug}/)+`), "");
84
- await deletePage(`${wikiPrefix}/${cleanPath}`);
85
- return `Page deleted: ${cleanPath}`;
86
- },
87
- }),
88
- defineTool("wiki_backlinks", {
89
- description: "Find all squad wiki pages that link to the given page",
90
- parameters: z.object({
91
- path: z.string().describe("Page path (e.g., 'decisions.md')"),
92
- }),
93
- handler: async ({ path }) => {
94
- const { getBacklinks } = await import("../wiki/backlinks.js");
95
- const cleanPath = path.replace(new RegExp(`^(?:squads/${squadSlug}/)+`), "");
96
- const allBacklinks = await getBacklinks(`${wikiPrefix}/${cleanPath}`);
97
- // Filter to only show backlinks within squad wiki, strip prefix for display
98
- return allBacklinks
99
- .filter((bl) => bl.startsWith(`${wikiPrefix}/`))
100
- .map((bl) => bl.slice(wikiPrefix.length + 1));
101
- },
102
- }),
103
- // --- Feed Tools ---
104
- defineTool("feed_post", {
105
- description: "Post a message or deliverable to the user's inbox. Use for progress updates, questions, blockers, or completed work.",
106
- parameters: z.object({
107
- title: z.string().describe("Title of the message"),
108
- content: z.string().describe("Full content (markdown supported)"),
109
- }),
110
- handler: async ({ title, content }) => {
111
- const { postFeedItem } = await import("../store/feed.js");
112
- const source = `squad-${squadSlug}`;
113
- const item = postFeedItem(source, title, content);
114
- return `Posted to inbox: "${title}" (ID: ${item.id})`;
115
- },
116
- }),
117
- // --- Task Tools ---
118
- defineTool("squad_task_status", {
119
- description: "Check the status of tasks for your squad",
120
- parameters: z.object({}),
121
- handler: async () => {
122
- const { getTasksForSquad } = await import("../store/tasks.js");
123
- return getTasksForSquad(squadId);
124
- },
125
- }),
126
- // --- Shell Tool (scoped to project directory) ---
127
- defineTool("shell_exec", {
128
- description: "Execute a shell command in the squad's project directory. Use for git, build tools, test runners, file operations, etc.",
129
- parameters: z.object({
130
- command: z.string().describe("Shell command to execute"),
131
- cwd: z
132
- .string()
133
- .optional()
134
- .describe("Working directory relative to project root (optional, defaults to project root)"),
135
- }),
136
- handler: async ({ command, cwd }) => {
137
- const baseDir = projectDir ?? process.cwd();
138
- // If cwd is provided, resolve it relative to the project dir
139
- const workDir = cwd ? join(baseDir, cwd) : baseDir;
140
- // Safety: ensure workDir is under baseDir
141
- const resolved = join(workDir);
142
- if (!resolved.startsWith(baseDir)) {
143
- return `Error: cannot execute commands outside the project directory`;
144
- }
145
- try {
146
- // Inject cached GH token for GitHub CLI operations
147
- const shellEnv = { ...process.env, GH_PROMPT_DISABLED: "1" };
148
- const ghToken = getGhToken();
149
- if (ghToken) {
150
- shellEnv.GH_TOKEN = ghToken;
151
- }
152
- const { stdout } = await execAsync(command, {
153
- cwd: workDir,
154
- timeout: 120_000,
155
- maxBuffer: 2 * 1024 * 1024,
156
- env: shellEnv,
157
- });
158
- return stdout.trim() || "(no output)";
159
- }
160
- catch (err) {
161
- const stderr = err.stderr?.toString().trim() ?? "";
162
- const stdout = err.stdout?.toString().trim() ?? "";
163
- return `Error (exit ${err.code ?? 1}): ${stderr || stdout || err.message}`;
164
- }
165
- },
166
- }),
167
- ];
168
- }
169
- /**
170
- * Additional tools available ONLY to team leads.
171
- * Includes the delegate_to_specialist tool which spawns real parallel agent sessions.
172
- */
173
- export function createLeadDelegationTools(squadId, squadSlug, squad, wikiKnowledge, workDir, parentTaskId, instanceId) {
174
- return [
175
- defineTool("delegate_to_specialist", {
176
- description: "Delegate a sub-task to a specialist agent. This spawns an INDEPENDENT session for that agent — they will execute the work in parallel. Use this to assign implementation work to the right specialist based on their role. You can call this multiple times to delegate to multiple specialists in parallel.",
177
- parameters: z.object({
178
- agent_name: z.string().describe("Character name of the specialist to delegate to (from your team roster)"),
179
- sub_task: z.string().describe("Detailed description of the sub-task. Be specific about what to implement, which files to touch, acceptance criteria, and branch to work on."),
180
- }),
181
- handler: async ({ agent_name, sub_task }) => {
182
- const { getAgentsForSquad } = await import("../store/squads.js");
183
- const agents = getAgentsForSquad(squadId);
184
- const agent = agents.find((a) => a.character_name.toLowerCase() === agent_name.toLowerCase() && !a.is_lead);
185
- if (!agent) {
186
- const available = agents
187
- .filter((a) => !a.is_lead)
188
- .map((a) => `${a.character_name} (${a.role_title})`)
189
- .join(", ");
190
- return `Error: No specialist found with name "${agent_name}". Available specialists: ${available}`;
191
- }
192
- const { runSpecialistSession } = await import("./specialist-runner.js");
193
- const result = await runSpecialistSession({
194
- agent,
195
- squad,
196
- squadSlug,
197
- squadId,
198
- task: sub_task,
199
- wikiKnowledge,
200
- workDir,
201
- instanceId,
202
- parentTaskId,
203
- });
204
- if (result.success) {
205
- return `✅ ${result.agentName} (${result.role}) completed the task:\n\n${result.result}`;
206
- }
207
- else {
208
- return `❌ ${result.agentName} (${result.role}) failed:\n\n${result.result}`;
209
- }
210
- },
211
- }),
212
- defineTool("delegate_to_specialists_parallel", {
213
- description: "Delegate multiple sub-tasks to different specialists IN PARALLEL. All tasks run concurrently and results are returned together. Use this when multiple independent sub-tasks can be worked on simultaneously by different specialists.",
214
- parameters: z.object({
215
- assignments: z.array(z.object({
216
- agent_name: z.string().describe("Character name of the specialist"),
217
- sub_task: z.string().describe("Detailed sub-task description"),
218
- })).describe("Array of agent assignments to execute in parallel"),
219
- }),
220
- handler: async ({ assignments }) => {
221
- const { getAgentsForSquad } = await import("../store/squads.js");
222
- const { runSpecialistsParallel } = await import("./specialist-runner.js");
223
- const agents = getAgentsForSquad(squadId);
224
- const requests = [];
225
- const errors = [];
226
- for (const assignment of assignments) {
227
- const agent = agents.find((a) => a.character_name.toLowerCase() === assignment.agent_name.toLowerCase() && !a.is_lead);
228
- if (!agent) {
229
- errors.push(`No specialist found: "${assignment.agent_name}"`);
230
- continue;
231
- }
232
- requests.push({
233
- agent,
234
- squad,
235
- squadSlug,
236
- squadId,
237
- task: assignment.sub_task,
238
- wikiKnowledge,
239
- workDir,
240
- instanceId,
241
- parentTaskId,
242
- });
243
- }
244
- if (requests.length === 0) {
245
- return `Error: No valid specialists matched. ${errors.join("; ")}`;
246
- }
247
- const results = await runSpecialistsParallel(requests);
248
- const summaries = results.map((r) => {
249
- const status = r.success ? "✅" : "❌";
250
- return `${status} **${r.agentName}** (${r.role}):\n${r.result}`;
251
- });
252
- const preamble = errors.length > 0 ? `⚠️ Skipped: ${errors.join("; ")}\n\n` : "";
253
- return `${preamble}## Parallel Results\n\n${summaries.join("\n\n---\n\n")}`;
254
- },
255
- }),
256
- ];
257
- }
258
- //# sourceMappingURL=squad-tools.js.map
@@ -1,86 +0,0 @@
1
- import { PATHS } from "../paths.js";
2
- export function buildSystemMessage(selfEditEnabled) {
3
- const selfEditBlock = selfEditEnabled
4
- ? ""
5
- : `
6
- ## Self-Edit Protection
7
- You must NEVER modify files within your own installation directory. If asked to modify your own source code, decline and suggest the user restart with --self-edit. This restriction does NOT apply to: user project files, skills in ~/.io/skills/, ~/.io/config.json, wiki pages, or files outside the IO installation directory.
8
- `;
9
- return `# IO — Personal AI Assistant
10
-
11
- You are IO, a personal AI assistant daemon. You run 24/7 on the user's machine, helping them manage projects through AI-powered squads, answer questions, and automate workflows.
12
-
13
- ## Core Capabilities
14
- - Manage project squads (teams of AI agents themed after pop culture universes)
15
- - Read and write to a persistent wiki knowledge base at ~/.io/wiki/
16
- - Each squad has its own wiki at ~/.io/wiki/pages/squads/{squad-slug}/ (use the slug, never the UUID)
17
- - Squad wiki templates at ~/.io/wiki/templates/squad/ are auto-copied to new squads on creation
18
- - Delegate complex tasks to squad team leads
19
- - Track deliverables in a unified feed
20
- - Schedule recurring tasks and stand-ups
21
- - Connect to external tools via MCP servers
22
-
23
- ## 🚨 CRITICAL SECURITY RULE — ABSOLUTE, NON-NEGOTIABLE 🚨
24
- You must NEVER expose secrets, credentials, or sensitive values in ANY publicly visible location. This includes:
25
- - GitHub issues, pull requests, PR descriptions, comments, or commit messages
26
- - Log output, error messages, or stack traces shared externally
27
- - Wiki pages, feed items, or any content viewable by others
28
-
29
- What counts as a secret: API keys, access tokens, passwords, connection strings, environment variable values, private config file contents (supabaseAnonKey, telegramToken, etc.), SSH keys, certificates, webhook URLs with tokens.
30
-
31
- If you need to reference that a secret exists, use \`<REDACTED>\` or \`***\` as a placeholder. NEVER include the actual value.
32
-
33
- Violation of this rule is a HARD FAILURE — no exceptions, no workarounds, no "just this once."
34
-
35
- ## Behavioral Rules
36
- - Always pull latest before starting any code work (git fetch origin && git checkout main && git pull origin main)
37
- - Always delegate code work to the relevant squad — never implement directly
38
- - Always delegate to the team lead, never to a specific agent (unless explicitly named by the user)
39
- - Never delegate unless explicitly asked — creating an issue ≠ request to start work
40
- - When delegating, ALWAYS instruct the squad to notify the user via the inbox (feed_post) when work is complete
41
- - When creating squads, research the universe dynamically — never use hardcoded character lists
42
- - **Always use the gh CLI** for all GitHub interactions (repos, issues, PRs, releases, actions, etc.). Only fall back to the GitHub API or other methods if gh is unavailable or cannot accomplish the task.
43
- - For complex tasks involving multiple specialists, use squad_meeting to have the team plan together before executing. Use squad_delegate for straightforward single-domain tasks.
44
- - If the user says "plan this" or "have the team meet" → use squad_meeting with execute_after=false
45
- - If the user says "do this" for a complex task → use squad_meeting with execute_after=true
46
- - If the user says "just do it" or it's a simple task → use squad_delegate directly
47
-
48
- ## HARD RULE: Squad Ownership Boundary
49
- If a project has a squad assigned to it, you (the orchestrator) must NEVER:
50
- - Research, analyze, or investigate the project's code, issues, or state yourself
51
- - Attempt any work — even preliminary analysis — before delegating
52
- - "Look into" or "check on" something before passing it to the squad
53
- - Wait for the squad to finish before responding to the user
54
-
55
- When a request comes in about a squad-owned project, you IMMEDIATELY delegate to that squad's team lead with no pre-processing. The squad handles ALL work including research, analysis, planning, and execution.
56
-
57
- After delegating, IMMEDIATELY confirm to the user that the task is in the squad's hands (e.g., "I've handed this off to [squad name]. They'll work on it and post updates to your inbox."). Do NOT block or wait for the squad to complete — they work asynchronously in the background.
58
-
59
- The ONLY thing you are allowed to do regarding a squad-owned project (without delegating) is:
60
- - Answer questions about what the squad has already done (using feed/task history)
61
- - Report squad status, task progress, or past deliverables
62
-
63
- ## Squad Coverage Requirements
64
- Every squad MUST have:
65
- 1. A dedicated team lead (PM/Senior Engineer, coordination-only — **never writes code**)
66
- 2. At least one QA reviewer
67
- 3. At least one agent with a test/quality role title
68
-
69
- Team leads are strictly managers/delegators/reviewers. They break down tasks, assign work to specialists, coordinate reviews, and report status — but they NEVER write, edit, or generate code themselves.
70
-
71
- ## GitHub Self-Review Limitation
72
- All squad agents share the repo owner's gh identity. GitHub blocks self-approval. Veto reviewers use --comment with "LGTM" instead of --approve. Merge criteria: all veto-capable members have posted approving comments + CI passes + no conflicts.
73
- ${selfEditBlock}
74
- ## Source Code Convention
75
- - All repositories are cloned to ~/.io/source/{owner}/{repo}
76
- - When creating a squad with a repo_url, the repo is automatically cloned there
77
- - When working with a squad's code, always use ~/.io/source/{owner}/{repo} as the working directory
78
-
79
- ## Environment
80
- - OS: ${process.platform}
81
- - Working directory: ${process.cwd()}
82
- - Wiki: ${PATHS.wiki}
83
- - Skills: ${PATHS.skills}
84
- `;
85
- }
86
- //# sourceMappingURL=system-message.js.map
@@ -1,98 +0,0 @@
1
- import { loadConfig } from "../config.js";
2
- import { recordTokenUsage } from "../store/token-usage.js";
3
- import { postFeedItem } from "../store/feed.js";
4
- const NANO_AIU_TO_USD = 1e-14;
5
- /**
6
- * Default model pricing (USD per 1M tokens).
7
- * Used when modelPricing is not configured.
8
- */
9
- export const DEFAULT_MODEL_PRICING = {
10
- "gpt-4.1": { inputPer1M: 2.0, outputPer1M: 8.0 },
11
- "gpt-5.2": { inputPer1M: 2.5, outputPer1M: 10.0 },
12
- "gpt-5.2-codex": { inputPer1M: 3.0, outputPer1M: 12.0 },
13
- "gpt-5.3-codex": { inputPer1M: 3.0, outputPer1M: 12.0 },
14
- "gpt-5.4": { inputPer1M: 5.0, outputPer1M: 20.0 },
15
- "gpt-5.5": { inputPer1M: 7.5, outputPer1M: 30.0 },
16
- "gpt-5-mini": { inputPer1M: 0.15, outputPer1M: 0.60 },
17
- "gpt-5.4-mini": { inputPer1M: 0.15, outputPer1M: 0.60 },
18
- "claude-haiku-4.5": { inputPer1M: 0.80, outputPer1M: 4.0 },
19
- "claude-sonnet-4.5": { inputPer1M: 3.0, outputPer1M: 15.0 },
20
- "claude-sonnet-4.6": { inputPer1M: 3.0, outputPer1M: 15.0 },
21
- "claude-opus-4.5": { inputPer1M: 15.0, outputPer1M: 75.0 },
22
- "claude-opus-4.6": { inputPer1M: 15.0, outputPer1M: 75.0 },
23
- "claude-opus-4.7": { inputPer1M: 15.0, outputPer1M: 75.0 },
24
- };
25
- /**
26
- * Compute estimated cost in USD for the given token counts and model.
27
- */
28
- export function estimateCost(model, inputTokens, outputTokens) {
29
- const config = loadConfig();
30
- const pricing = config.modelPricing?.[model] ?? DEFAULT_MODEL_PRICING[model];
31
- if (!pricing)
32
- return 0;
33
- return (inputTokens / 1_000_000) * pricing.inputPer1M + (outputTokens / 1_000_000) * pricing.outputPer1M;
34
- }
35
- function resolveCostUsd(data, model, inputTokens, outputTokens) {
36
- const totalNanoAiu = data?.copilotUsage?.totalNanoAiu;
37
- if (typeof totalNanoAiu === "number" && Number.isFinite(totalNanoAiu)) {
38
- return totalNanoAiu * NANO_AIU_TO_USD;
39
- }
40
- return estimateCost(model, inputTokens, outputTokens);
41
- }
42
- /**
43
- * Attach a token usage listener to a CopilotSession.
44
- * Returns a `flush` function that, when called, persists accumulated
45
- * token usage to the database and returns the totals.
46
- *
47
- * Call `flush` after the session ends (in a finally block).
48
- */
49
- export function attachTokenTracker(session, context) {
50
- const accumulator = {};
51
- const unsubscribe = session.on("assistant.usage", (event) => {
52
- const data = event?.data;
53
- if (!data?.model)
54
- return;
55
- const model = data.model;
56
- const input = data.inputTokens ?? 0;
57
- const output = data.outputTokens ?? 0;
58
- if (!accumulator[model])
59
- accumulator[model] = { inputTokens: 0, outputTokens: 0, costUsd: 0 };
60
- accumulator[model].inputTokens += input;
61
- accumulator[model].outputTokens += output;
62
- accumulator[model].costUsd += resolveCostUsd(data, model, input, output);
63
- });
64
- return () => {
65
- unsubscribe();
66
- let totalInputTokens = 0;
67
- let totalOutputTokens = 0;
68
- let totalCostUsd = 0;
69
- for (const [model, usage] of Object.entries(accumulator)) {
70
- if (usage.inputTokens === 0 && usage.outputTokens === 0)
71
- continue;
72
- const costUsd = usage.costUsd ?? estimateCost(model, usage.inputTokens, usage.outputTokens);
73
- recordTokenUsage({
74
- squadId: context.squadId,
75
- agentId: context.agentId,
76
- taskId: context.taskId,
77
- model,
78
- inputTokens: usage.inputTokens,
79
- outputTokens: usage.outputTokens,
80
- costUsd,
81
- });
82
- totalInputTokens += usage.inputTokens;
83
- totalOutputTokens += usage.outputTokens;
84
- totalCostUsd += costUsd;
85
- }
86
- // Alert on runaway agents
87
- const config = loadConfig();
88
- const threshold = config.tokenAlertThreshold;
89
- if (threshold && (totalInputTokens + totalOutputTokens) > threshold) {
90
- const source = context.squadId ? `squad-${context.squadId}` : "system";
91
- postFeedItem(source, "⚠️ Token usage alert", `A task consumed ${totalInputTokens + totalOutputTokens} tokens (threshold: ${threshold}). ` +
92
- `Estimated cost: $${totalCostUsd.toFixed(4)}. ` +
93
- (context.taskId ? `Task ID: ${context.taskId}` : ""));
94
- }
95
- return { totalInputTokens, totalOutputTokens, totalCostUsd };
96
- };
97
- }
98
- //# sourceMappingURL=token-tracker.js.map
@@ -1,33 +0,0 @@
1
- import { getSchedule, updateScheduleLastRun } from "../store/schedules.js";
2
- import { sendToOrchestrator } from "./orchestrator.js";
3
- import { buildSquadScopedPrompt } from "./io-scheduler.js";
4
- import { delegateTask } from "./agents.js";
5
- /**
6
- * Trigger a schedule immediately, bypassing cron timing.
7
- * Returns the schedule if triggered successfully, or undefined if not found.
8
- */
9
- export function triggerSchedule(id) {
10
- const schedule = getSchedule(id);
11
- if (!schedule)
12
- return undefined;
13
- updateScheduleLastRun(schedule.id);
14
- if (schedule.type === "squad") {
15
- if (!schedule.squad_id)
16
- return schedule;
17
- const task = schedule.prompt || `Run "triage" stand-up. Agenda: triage`;
18
- // Delegate directly to squad lead — same path as the cron scheduler
19
- delegateTask(schedule.squad_id, task).catch((err) => {
20
- const errMsg = err instanceof Error ? err.message : "Unknown error";
21
- console.error(`[trigger] Delegation failed for squad ${schedule.squad_id}: ${errMsg}`);
22
- });
23
- }
24
- else {
25
- sendToOrchestrator(buildSquadScopedPrompt(schedule), "io-scheduler", (_text, done) => {
26
- if (done) {
27
- console.log(`[trigger] IO schedule ${schedule.id} completed.`);
28
- }
29
- });
30
- }
31
- return schedule;
32
- }
33
- //# sourceMappingURL=trigger-schedule.js.map
package/dist/daemon.js DELETED
@@ -1,67 +0,0 @@
1
- import { loadConfig, getConfigWarning } from "./config.js";
2
- import { getDb, closeDb } from "./store/db.js";
3
- import { PATHS } from "./paths.js";
4
- import { mkdirSync, existsSync } from "node:fs";
5
- export async function startDaemon(opts) {
6
- console.log("[io] Starting daemon...");
7
- // Ensure directories exist
8
- for (const dir of [PATHS.home, PATHS.wiki, PATHS.wikiPages, PATHS.skills, PATHS.sessions]) {
9
- if (!existsSync(dir))
10
- mkdirSync(dir, { recursive: true });
11
- }
12
- const config = loadConfig();
13
- // Initialize database
14
- const db = getDb();
15
- console.log("[io] Database initialized.");
16
- // Initialize Copilot client & orchestrator
17
- const { getClient } = await import("./copilot/client.js");
18
- const client = await getClient();
19
- console.log("[io] Copilot client connected.");
20
- const { initOrchestrator } = await import("./copilot/orchestrator.js");
21
- await initOrchestrator(client, { selfEdit: opts.selfEdit });
22
- console.log("[io] Orchestrator session ready.");
23
- // Start HTTP API server
24
- const { startApiServer } = await import("./api/server.js");
25
- await startApiServer(config);
26
- console.log(`[io] API server listening on port ${config.port}.`);
27
- // Start Telegram bot (if configured)
28
- if (config.telegramEnabled && config.telegramBotToken) {
29
- const { startBot } = await import("./telegram/bot.js");
30
- await startBot(config);
31
- console.log("[io] Telegram bot started.");
32
- }
33
- // Start schedulers
34
- const { startSquadScheduler } = await import("./copilot/scheduler.js");
35
- const { startIoScheduler } = await import("./copilot/io-scheduler.js");
36
- startSquadScheduler();
37
- startIoScheduler();
38
- console.log("[io] Schedulers active.");
39
- // Start watchdog
40
- if (config.watchdogEnabled) {
41
- const { startWatchdog } = await import("./watchdog.js");
42
- startWatchdog();
43
- console.log("[io] Watchdog active.");
44
- }
45
- console.log("[io] Daemon running. Press Ctrl+C to stop.");
46
- // Notify user if config had to fall back to defaults
47
- const configWarn = getConfigWarning();
48
- if (configWarn) {
49
- const { postFeedItem } = await import("./store/feed.js");
50
- postFeedItem("system", "⚠️ Config Warning", configWarn);
51
- }
52
- // Graceful shutdown
53
- let shuttingDown = false;
54
- const shutdown = async () => {
55
- if (shuttingDown) {
56
- console.log("[io] Forcing exit...");
57
- process.exit(1);
58
- }
59
- shuttingDown = true;
60
- console.log("\n[io] Shutting down...");
61
- closeDb();
62
- process.exit(0);
63
- };
64
- process.on("SIGINT", shutdown);
65
- process.on("SIGTERM", shutdown);
66
- }
67
- //# sourceMappingURL=daemon.js.map
package/dist/logging.js DELETED
@@ -1,27 +0,0 @@
1
- export function formatError(err) {
2
- if (err instanceof Error)
3
- return err.message;
4
- if (typeof err === "string")
5
- return err;
6
- try {
7
- return JSON.stringify(err);
8
- }
9
- catch {
10
- return String(err);
11
- }
12
- }
13
- export function logWarn(message, context = {}, err) {
14
- const payload = {
15
- ...context,
16
- ...(err ? { error: formatError(err) } : {}),
17
- };
18
- console.warn(`[io] ${message}`, payload);
19
- }
20
- export function logError(message, context = {}, err) {
21
- const payload = {
22
- ...context,
23
- ...(err ? { error: formatError(err) } : {}),
24
- };
25
- console.error(`[io] ${message}`, payload);
26
- }
27
- //# sourceMappingURL=logging.js.map
@@ -1,29 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { PATHS } from "../paths.js";
3
- export function loadMcpConfig() {
4
- if (!existsSync(PATHS.mcpConfig))
5
- return [];
6
- const raw = JSON.parse(readFileSync(PATHS.mcpConfig, "utf-8"));
7
- return Array.isArray(raw.servers) ? raw.servers : [];
8
- }
9
- export function saveMcpConfig(servers) {
10
- writeFileSync(PATHS.mcpConfig, JSON.stringify({ servers }, null, 2) + "\n");
11
- }
12
- export function addMcpServer(server) {
13
- const servers = loadMcpConfig();
14
- servers.push(server);
15
- saveMcpConfig(servers);
16
- }
17
- export function removeMcpServer(id) {
18
- const servers = loadMcpConfig().filter((s) => s.id !== id);
19
- saveMcpConfig(servers);
20
- }
21
- export function toggleMcpServer(id, enabled) {
22
- const servers = loadMcpConfig();
23
- const server = servers.find((s) => s.id === id);
24
- if (server) {
25
- server.enabled = enabled;
26
- saveMcpConfig(servers);
27
- }
28
- }
29
- //# sourceMappingURL=config.js.map
package/dist/mcp/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { loadMcpConfig, saveMcpConfig, addMcpServer, removeMcpServer, toggleMcpServer } from "./config.js";
2
- export { initMcpRegistry, getMcpServersForSession, listServers } from "./registry.js";
3
- //# sourceMappingURL=index.js.map
@@ -1,42 +0,0 @@
1
- import { loadMcpConfig } from "./config.js";
2
- // Module-level array of MCP tools loaded at startup
3
- let loadedServers = [];
4
- export function initMcpRegistry() {
5
- loadedServers = loadMcpConfig().filter((s) => s.enabled);
6
- }
7
- export function getMcpServersForSession() {
8
- if (loadedServers.length === 0)
9
- return undefined;
10
- const result = {};
11
- for (const server of loadedServers) {
12
- if (server.type === "stdio" && server.command) {
13
- result[server.name] = {
14
- type: "local",
15
- command: server.command,
16
- args: server.args ?? [],
17
- env: server.env,
18
- tools: ["*"],
19
- };
20
- }
21
- else if (server.type === "http" && server.url) {
22
- result[server.name] = {
23
- type: "http",
24
- url: server.url,
25
- headers: server.headers,
26
- };
27
- }
28
- }
29
- return Object.keys(result).length > 0 ? result : undefined;
30
- }
31
- export function listServers() {
32
- return loadMcpConfig();
33
- }
34
- export function addServerToRegistry(server) {
35
- if (server.enabled) {
36
- loadedServers.push(server);
37
- }
38
- }
39
- export function removeServerFromRegistry(id) {
40
- loadedServers = loadedServers.filter((s) => s.id !== id);
41
- }
42
- //# sourceMappingURL=registry.js.map