cowork-os 0.3.21

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 (526) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1638 -0
  3. package/bin/cowork.js +42 -0
  4. package/build/entitlements.mac.plist +16 -0
  5. package/build/icon.icns +0 -0
  6. package/build/icon.png +0 -0
  7. package/dist/electron/electron/activity/ActivityRepository.js +190 -0
  8. package/dist/electron/electron/agent/browser/browser-service.js +639 -0
  9. package/dist/electron/electron/agent/context-manager.js +225 -0
  10. package/dist/electron/electron/agent/custom-skill-loader.js +566 -0
  11. package/dist/electron/electron/agent/daemon.js +975 -0
  12. package/dist/electron/electron/agent/executor.js +3561 -0
  13. package/dist/electron/electron/agent/llm/anthropic-provider.js +155 -0
  14. package/dist/electron/electron/agent/llm/bedrock-provider.js +202 -0
  15. package/dist/electron/electron/agent/llm/gemini-provider.js +375 -0
  16. package/dist/electron/electron/agent/llm/index.js +34 -0
  17. package/dist/electron/electron/agent/llm/ollama-provider.js +263 -0
  18. package/dist/electron/electron/agent/llm/openai-oauth.js +101 -0
  19. package/dist/electron/electron/agent/llm/openai-provider.js +657 -0
  20. package/dist/electron/electron/agent/llm/openrouter-provider.js +232 -0
  21. package/dist/electron/electron/agent/llm/pricing.js +160 -0
  22. package/dist/electron/electron/agent/llm/provider-factory.js +880 -0
  23. package/dist/electron/electron/agent/llm/types.js +178 -0
  24. package/dist/electron/electron/agent/queue-manager.js +378 -0
  25. package/dist/electron/electron/agent/sandbox/docker-sandbox.js +402 -0
  26. package/dist/electron/electron/agent/sandbox/macos-sandbox.js +407 -0
  27. package/dist/electron/electron/agent/sandbox/runner.js +410 -0
  28. package/dist/electron/electron/agent/sandbox/sandbox-factory.js +228 -0
  29. package/dist/electron/electron/agent/sandbox/security-utils.js +258 -0
  30. package/dist/electron/electron/agent/search/brave-provider.js +119 -0
  31. package/dist/electron/electron/agent/search/google-provider.js +100 -0
  32. package/dist/electron/electron/agent/search/index.js +28 -0
  33. package/dist/electron/electron/agent/search/provider-factory.js +395 -0
  34. package/dist/electron/electron/agent/search/serpapi-provider.js +112 -0
  35. package/dist/electron/electron/agent/search/tavily-provider.js +90 -0
  36. package/dist/electron/electron/agent/search/types.js +40 -0
  37. package/dist/electron/electron/agent/security/index.js +12 -0
  38. package/dist/electron/electron/agent/security/input-sanitizer.js +303 -0
  39. package/dist/electron/electron/agent/security/output-filter.js +217 -0
  40. package/dist/electron/electron/agent/skill-eligibility.js +281 -0
  41. package/dist/electron/electron/agent/skill-registry.js +396 -0
  42. package/dist/electron/electron/agent/skills/document.js +878 -0
  43. package/dist/electron/electron/agent/skills/image-generator.js +225 -0
  44. package/dist/electron/electron/agent/skills/organizer.js +141 -0
  45. package/dist/electron/electron/agent/skills/presentation.js +367 -0
  46. package/dist/electron/electron/agent/skills/spreadsheet.js +165 -0
  47. package/dist/electron/electron/agent/tools/browser-tools.js +523 -0
  48. package/dist/electron/electron/agent/tools/builtin-settings.js +384 -0
  49. package/dist/electron/electron/agent/tools/canvas-tools.js +530 -0
  50. package/dist/electron/electron/agent/tools/cron-tools.js +577 -0
  51. package/dist/electron/electron/agent/tools/edit-tools.js +194 -0
  52. package/dist/electron/electron/agent/tools/file-tools.js +719 -0
  53. package/dist/electron/electron/agent/tools/glob-tools.js +283 -0
  54. package/dist/electron/electron/agent/tools/grep-tools.js +387 -0
  55. package/dist/electron/electron/agent/tools/image-tools.js +111 -0
  56. package/dist/electron/electron/agent/tools/mention-tools.js +282 -0
  57. package/dist/electron/electron/agent/tools/node-tools.js +476 -0
  58. package/dist/electron/electron/agent/tools/registry.js +2719 -0
  59. package/dist/electron/electron/agent/tools/search-tools.js +91 -0
  60. package/dist/electron/electron/agent/tools/shell-tools.js +574 -0
  61. package/dist/electron/electron/agent/tools/skill-tools.js +274 -0
  62. package/dist/electron/electron/agent/tools/system-tools.js +578 -0
  63. package/dist/electron/electron/agent/tools/web-fetch-tools.js +444 -0
  64. package/dist/electron/electron/agent/tools/x-tools.js +264 -0
  65. package/dist/electron/electron/agents/AgentRoleRepository.js +420 -0
  66. package/dist/electron/electron/agents/HeartbeatService.js +356 -0
  67. package/dist/electron/electron/agents/MentionRepository.js +197 -0
  68. package/dist/electron/electron/agents/TaskSubscriptionRepository.js +168 -0
  69. package/dist/electron/electron/agents/WorkingStateRepository.js +229 -0
  70. package/dist/electron/electron/canvas/canvas-manager.js +714 -0
  71. package/dist/electron/electron/canvas/canvas-preload.js +53 -0
  72. package/dist/electron/electron/canvas/canvas-protocol.js +195 -0
  73. package/dist/electron/electron/canvas/canvas-store.js +174 -0
  74. package/dist/electron/electron/canvas/index.js +13 -0
  75. package/dist/electron/electron/control-plane/client.js +364 -0
  76. package/dist/electron/electron/control-plane/handlers.js +572 -0
  77. package/dist/electron/electron/control-plane/index.js +41 -0
  78. package/dist/electron/electron/control-plane/node-manager.js +264 -0
  79. package/dist/electron/electron/control-plane/protocol.js +194 -0
  80. package/dist/electron/electron/control-plane/remote-client.js +437 -0
  81. package/dist/electron/electron/control-plane/server.js +640 -0
  82. package/dist/electron/electron/control-plane/settings.js +369 -0
  83. package/dist/electron/electron/control-plane/ssh-tunnel.js +549 -0
  84. package/dist/electron/electron/cron/index.js +30 -0
  85. package/dist/electron/electron/cron/schedule.js +190 -0
  86. package/dist/electron/electron/cron/service.js +614 -0
  87. package/dist/electron/electron/cron/store.js +155 -0
  88. package/dist/electron/electron/cron/types.js +82 -0
  89. package/dist/electron/electron/cron/webhook.js +258 -0
  90. package/dist/electron/electron/database/SecureSettingsRepository.js +444 -0
  91. package/dist/electron/electron/database/TaskLabelRepository.js +120 -0
  92. package/dist/electron/electron/database/repositories.js +1781 -0
  93. package/dist/electron/electron/database/schema.js +978 -0
  94. package/dist/electron/electron/extensions/index.js +33 -0
  95. package/dist/electron/electron/extensions/loader.js +313 -0
  96. package/dist/electron/electron/extensions/registry.js +485 -0
  97. package/dist/electron/electron/extensions/types.js +11 -0
  98. package/dist/electron/electron/gateway/channel-registry.js +1102 -0
  99. package/dist/electron/electron/gateway/channels/bluebubbles-client.js +479 -0
  100. package/dist/electron/electron/gateway/channels/bluebubbles.js +432 -0
  101. package/dist/electron/electron/gateway/channels/discord.js +975 -0
  102. package/dist/electron/electron/gateway/channels/email-client.js +593 -0
  103. package/dist/electron/electron/gateway/channels/email.js +443 -0
  104. package/dist/electron/electron/gateway/channels/google-chat.js +631 -0
  105. package/dist/electron/electron/gateway/channels/imessage-client.js +363 -0
  106. package/dist/electron/electron/gateway/channels/imessage.js +465 -0
  107. package/dist/electron/electron/gateway/channels/index.js +36 -0
  108. package/dist/electron/electron/gateway/channels/line-client.js +470 -0
  109. package/dist/electron/electron/gateway/channels/line.js +479 -0
  110. package/dist/electron/electron/gateway/channels/matrix-client.js +432 -0
  111. package/dist/electron/electron/gateway/channels/matrix.js +592 -0
  112. package/dist/electron/electron/gateway/channels/mattermost-client.js +394 -0
  113. package/dist/electron/electron/gateway/channels/mattermost.js +496 -0
  114. package/dist/electron/electron/gateway/channels/signal-client.js +500 -0
  115. package/dist/electron/electron/gateway/channels/signal.js +582 -0
  116. package/dist/electron/electron/gateway/channels/slack.js +415 -0
  117. package/dist/electron/electron/gateway/channels/teams.js +596 -0
  118. package/dist/electron/electron/gateway/channels/telegram.js +1390 -0
  119. package/dist/electron/electron/gateway/channels/twitch-client.js +502 -0
  120. package/dist/electron/electron/gateway/channels/twitch.js +396 -0
  121. package/dist/electron/electron/gateway/channels/types.js +8 -0
  122. package/dist/electron/electron/gateway/channels/whatsapp.js +953 -0
  123. package/dist/electron/electron/gateway/context-policy.js +268 -0
  124. package/dist/electron/electron/gateway/index.js +1063 -0
  125. package/dist/electron/electron/gateway/infrastructure.js +496 -0
  126. package/dist/electron/electron/gateway/router.js +2700 -0
  127. package/dist/electron/electron/gateway/security.js +375 -0
  128. package/dist/electron/electron/gateway/session.js +115 -0
  129. package/dist/electron/electron/gateway/tunnel.js +503 -0
  130. package/dist/electron/electron/guardrails/guardrail-manager.js +348 -0
  131. package/dist/electron/electron/hooks/gmail-watcher.js +300 -0
  132. package/dist/electron/electron/hooks/index.js +46 -0
  133. package/dist/electron/electron/hooks/mappings.js +381 -0
  134. package/dist/electron/electron/hooks/server.js +480 -0
  135. package/dist/electron/electron/hooks/settings.js +447 -0
  136. package/dist/electron/electron/hooks/types.js +41 -0
  137. package/dist/electron/electron/ipc/canvas-handlers.js +158 -0
  138. package/dist/electron/electron/ipc/handlers.js +3138 -0
  139. package/dist/electron/electron/ipc/mission-control-handlers.js +141 -0
  140. package/dist/electron/electron/main.js +448 -0
  141. package/dist/electron/electron/mcp/client/MCPClientManager.js +330 -0
  142. package/dist/electron/electron/mcp/client/MCPServerConnection.js +437 -0
  143. package/dist/electron/electron/mcp/client/transports/SSETransport.js +304 -0
  144. package/dist/electron/electron/mcp/client/transports/StdioTransport.js +307 -0
  145. package/dist/electron/electron/mcp/client/transports/WebSocketTransport.js +329 -0
  146. package/dist/electron/electron/mcp/host/MCPHostServer.js +354 -0
  147. package/dist/electron/electron/mcp/host/ToolAdapter.js +100 -0
  148. package/dist/electron/electron/mcp/registry/MCPRegistryManager.js +497 -0
  149. package/dist/electron/electron/mcp/settings.js +446 -0
  150. package/dist/electron/electron/mcp/types.js +59 -0
  151. package/dist/electron/electron/memory/MemoryService.js +435 -0
  152. package/dist/electron/electron/notifications/index.js +17 -0
  153. package/dist/electron/electron/notifications/service.js +118 -0
  154. package/dist/electron/electron/notifications/store.js +144 -0
  155. package/dist/electron/electron/preload.js +842 -0
  156. package/dist/electron/electron/reports/StandupReportService.js +272 -0
  157. package/dist/electron/electron/security/concurrency.js +293 -0
  158. package/dist/electron/electron/security/index.js +15 -0
  159. package/dist/electron/electron/security/policy-manager.js +435 -0
  160. package/dist/electron/electron/settings/appearance-manager.js +193 -0
  161. package/dist/electron/electron/settings/personality-manager.js +724 -0
  162. package/dist/electron/electron/settings/x-manager.js +58 -0
  163. package/dist/electron/electron/tailscale/exposure.js +188 -0
  164. package/dist/electron/electron/tailscale/index.js +28 -0
  165. package/dist/electron/electron/tailscale/settings.js +205 -0
  166. package/dist/electron/electron/tailscale/tailscale.js +355 -0
  167. package/dist/electron/electron/tray/QuickInputWindow.js +568 -0
  168. package/dist/electron/electron/tray/TrayManager.js +895 -0
  169. package/dist/electron/electron/tray/index.js +9 -0
  170. package/dist/electron/electron/updater/index.js +6 -0
  171. package/dist/electron/electron/updater/update-manager.js +418 -0
  172. package/dist/electron/electron/utils/env-migration.js +209 -0
  173. package/dist/electron/electron/utils/process.js +102 -0
  174. package/dist/electron/electron/utils/rate-limiter.js +104 -0
  175. package/dist/electron/electron/utils/validation.js +419 -0
  176. package/dist/electron/electron/utils/x-cli.js +177 -0
  177. package/dist/electron/electron/voice/VoiceService.js +507 -0
  178. package/dist/electron/electron/voice/index.js +14 -0
  179. package/dist/electron/electron/voice/voice-settings-manager.js +359 -0
  180. package/dist/electron/shared/channelMessages.js +170 -0
  181. package/dist/electron/shared/types.js +1185 -0
  182. package/package.json +159 -0
  183. package/resources/skills/1password.json +10 -0
  184. package/resources/skills/add-documentation.json +31 -0
  185. package/resources/skills/analyze-csv.json +17 -0
  186. package/resources/skills/apple-notes.json +10 -0
  187. package/resources/skills/apple-reminders.json +10 -0
  188. package/resources/skills/auto-commenter.json +10 -0
  189. package/resources/skills/bear-notes.json +10 -0
  190. package/resources/skills/bird.json +35 -0
  191. package/resources/skills/blogwatcher.json +10 -0
  192. package/resources/skills/blucli.json +10 -0
  193. package/resources/skills/bluebubbles.json +10 -0
  194. package/resources/skills/camsnap.json +10 -0
  195. package/resources/skills/clean-imports.json +18 -0
  196. package/resources/skills/code-review.json +18 -0
  197. package/resources/skills/coding-agent.json +10 -0
  198. package/resources/skills/compare-files.json +23 -0
  199. package/resources/skills/convert-code.json +34 -0
  200. package/resources/skills/create-changelog.json +24 -0
  201. package/resources/skills/debug-error.json +17 -0
  202. package/resources/skills/dependency-check.json +10 -0
  203. package/resources/skills/discord.json +10 -0
  204. package/resources/skills/eightctl.json +10 -0
  205. package/resources/skills/explain-code.json +29 -0
  206. package/resources/skills/extract-todos.json +18 -0
  207. package/resources/skills/food-order.json +10 -0
  208. package/resources/skills/gemini.json +10 -0
  209. package/resources/skills/generate-readme.json +10 -0
  210. package/resources/skills/gifgrep.json +10 -0
  211. package/resources/skills/git-commit.json +10 -0
  212. package/resources/skills/github.json +10 -0
  213. package/resources/skills/gog.json +10 -0
  214. package/resources/skills/goplaces.json +10 -0
  215. package/resources/skills/himalaya.json +10 -0
  216. package/resources/skills/imsg.json +10 -0
  217. package/resources/skills/karpathy-guidelines.json +12 -0
  218. package/resources/skills/last30days.json +26 -0
  219. package/resources/skills/local-places.json +10 -0
  220. package/resources/skills/mcporter.json +10 -0
  221. package/resources/skills/model-usage.json +10 -0
  222. package/resources/skills/nano-banana-pro.json +10 -0
  223. package/resources/skills/nano-pdf.json +10 -0
  224. package/resources/skills/notion.json +10 -0
  225. package/resources/skills/obsidian.json +10 -0
  226. package/resources/skills/openai-image-gen.json +10 -0
  227. package/resources/skills/openai-whisper-api.json +10 -0
  228. package/resources/skills/openai-whisper.json +10 -0
  229. package/resources/skills/openhue.json +10 -0
  230. package/resources/skills/oracle.json +10 -0
  231. package/resources/skills/ordercli.json +10 -0
  232. package/resources/skills/peekaboo.json +10 -0
  233. package/resources/skills/project-structure.json +10 -0
  234. package/resources/skills/proofread.json +17 -0
  235. package/resources/skills/refactor-code.json +31 -0
  236. package/resources/skills/rename-symbol.json +23 -0
  237. package/resources/skills/sag.json +10 -0
  238. package/resources/skills/security-audit.json +18 -0
  239. package/resources/skills/session-logs.json +10 -0
  240. package/resources/skills/sherpa-onnx-tts.json +10 -0
  241. package/resources/skills/skill-creator.json +15 -0
  242. package/resources/skills/skill-hub.json +29 -0
  243. package/resources/skills/slack.json +10 -0
  244. package/resources/skills/songsee.json +10 -0
  245. package/resources/skills/sonoscli.json +10 -0
  246. package/resources/skills/spotify-player.json +10 -0
  247. package/resources/skills/startup-cfo.json +55 -0
  248. package/resources/skills/summarize-folder.json +18 -0
  249. package/resources/skills/summarize.json +10 -0
  250. package/resources/skills/things-mac.json +10 -0
  251. package/resources/skills/tmux.json +10 -0
  252. package/resources/skills/translate.json +36 -0
  253. package/resources/skills/trello.json +10 -0
  254. package/resources/skills/video-frames.json +10 -0
  255. package/resources/skills/voice-call.json +10 -0
  256. package/resources/skills/wacli.json +10 -0
  257. package/resources/skills/weather.json +10 -0
  258. package/resources/skills/write-tests.json +31 -0
  259. package/src/electron/activity/ActivityRepository.ts +238 -0
  260. package/src/electron/agent/browser/browser-service.ts +721 -0
  261. package/src/electron/agent/context-manager.ts +257 -0
  262. package/src/electron/agent/custom-skill-loader.ts +634 -0
  263. package/src/electron/agent/daemon.ts +1097 -0
  264. package/src/electron/agent/executor.ts +4017 -0
  265. package/src/electron/agent/llm/anthropic-provider.ts +175 -0
  266. package/src/electron/agent/llm/bedrock-provider.ts +236 -0
  267. package/src/electron/agent/llm/gemini-provider.ts +422 -0
  268. package/src/electron/agent/llm/index.ts +9 -0
  269. package/src/electron/agent/llm/ollama-provider.ts +347 -0
  270. package/src/electron/agent/llm/openai-oauth.ts +127 -0
  271. package/src/electron/agent/llm/openai-provider.ts +686 -0
  272. package/src/electron/agent/llm/openrouter-provider.ts +273 -0
  273. package/src/electron/agent/llm/pricing.ts +180 -0
  274. package/src/electron/agent/llm/provider-factory.ts +971 -0
  275. package/src/electron/agent/llm/types.ts +291 -0
  276. package/src/electron/agent/queue-manager.ts +408 -0
  277. package/src/electron/agent/sandbox/docker-sandbox.ts +453 -0
  278. package/src/electron/agent/sandbox/macos-sandbox.ts +426 -0
  279. package/src/electron/agent/sandbox/runner.ts +453 -0
  280. package/src/electron/agent/sandbox/sandbox-factory.ts +337 -0
  281. package/src/electron/agent/sandbox/security-utils.ts +251 -0
  282. package/src/electron/agent/search/brave-provider.ts +141 -0
  283. package/src/electron/agent/search/google-provider.ts +131 -0
  284. package/src/electron/agent/search/index.ts +6 -0
  285. package/src/electron/agent/search/provider-factory.ts +450 -0
  286. package/src/electron/agent/search/serpapi-provider.ts +138 -0
  287. package/src/electron/agent/search/tavily-provider.ts +108 -0
  288. package/src/electron/agent/search/types.ts +118 -0
  289. package/src/electron/agent/security/index.ts +20 -0
  290. package/src/electron/agent/security/input-sanitizer.ts +380 -0
  291. package/src/electron/agent/security/output-filter.ts +259 -0
  292. package/src/electron/agent/skill-eligibility.ts +334 -0
  293. package/src/electron/agent/skill-registry.ts +457 -0
  294. package/src/electron/agent/skills/document.ts +1070 -0
  295. package/src/electron/agent/skills/image-generator.ts +272 -0
  296. package/src/electron/agent/skills/organizer.ts +131 -0
  297. package/src/electron/agent/skills/presentation.ts +418 -0
  298. package/src/electron/agent/skills/spreadsheet.ts +166 -0
  299. package/src/electron/agent/tools/browser-tools.ts +546 -0
  300. package/src/electron/agent/tools/builtin-settings.ts +422 -0
  301. package/src/electron/agent/tools/canvas-tools.ts +572 -0
  302. package/src/electron/agent/tools/cron-tools.ts +723 -0
  303. package/src/electron/agent/tools/edit-tools.ts +196 -0
  304. package/src/electron/agent/tools/file-tools.ts +811 -0
  305. package/src/electron/agent/tools/glob-tools.ts +303 -0
  306. package/src/electron/agent/tools/grep-tools.ts +432 -0
  307. package/src/electron/agent/tools/image-tools.ts +126 -0
  308. package/src/electron/agent/tools/mention-tools.ts +371 -0
  309. package/src/electron/agent/tools/node-tools.ts +550 -0
  310. package/src/electron/agent/tools/registry.ts +3052 -0
  311. package/src/electron/agent/tools/search-tools.ts +111 -0
  312. package/src/electron/agent/tools/shell-tools.ts +651 -0
  313. package/src/electron/agent/tools/skill-tools.ts +340 -0
  314. package/src/electron/agent/tools/system-tools.ts +665 -0
  315. package/src/electron/agent/tools/web-fetch-tools.ts +528 -0
  316. package/src/electron/agent/tools/x-tools.ts +267 -0
  317. package/src/electron/agents/AgentRoleRepository.ts +557 -0
  318. package/src/electron/agents/HeartbeatService.ts +469 -0
  319. package/src/electron/agents/MentionRepository.ts +242 -0
  320. package/src/electron/agents/TaskSubscriptionRepository.ts +231 -0
  321. package/src/electron/agents/WorkingStateRepository.ts +278 -0
  322. package/src/electron/canvas/canvas-manager.ts +818 -0
  323. package/src/electron/canvas/canvas-preload.ts +102 -0
  324. package/src/electron/canvas/canvas-protocol.ts +174 -0
  325. package/src/electron/canvas/canvas-store.ts +200 -0
  326. package/src/electron/canvas/index.ts +8 -0
  327. package/src/electron/control-plane/client.ts +527 -0
  328. package/src/electron/control-plane/handlers.ts +723 -0
  329. package/src/electron/control-plane/index.ts +51 -0
  330. package/src/electron/control-plane/node-manager.ts +322 -0
  331. package/src/electron/control-plane/protocol.ts +269 -0
  332. package/src/electron/control-plane/remote-client.ts +517 -0
  333. package/src/electron/control-plane/server.ts +853 -0
  334. package/src/electron/control-plane/settings.ts +401 -0
  335. package/src/electron/control-plane/ssh-tunnel.ts +624 -0
  336. package/src/electron/cron/index.ts +9 -0
  337. package/src/electron/cron/schedule.ts +217 -0
  338. package/src/electron/cron/service.ts +743 -0
  339. package/src/electron/cron/store.ts +165 -0
  340. package/src/electron/cron/types.ts +291 -0
  341. package/src/electron/cron/webhook.ts +303 -0
  342. package/src/electron/database/SecureSettingsRepository.ts +514 -0
  343. package/src/electron/database/TaskLabelRepository.ts +148 -0
  344. package/src/electron/database/repositories.ts +2397 -0
  345. package/src/electron/database/schema.ts +1017 -0
  346. package/src/electron/extensions/index.ts +18 -0
  347. package/src/electron/extensions/loader.ts +336 -0
  348. package/src/electron/extensions/registry.ts +546 -0
  349. package/src/electron/extensions/types.ts +372 -0
  350. package/src/electron/gateway/channel-registry.ts +1267 -0
  351. package/src/electron/gateway/channels/bluebubbles-client.ts +641 -0
  352. package/src/electron/gateway/channels/bluebubbles.ts +509 -0
  353. package/src/electron/gateway/channels/discord.ts +1150 -0
  354. package/src/electron/gateway/channels/email-client.ts +708 -0
  355. package/src/electron/gateway/channels/email.ts +516 -0
  356. package/src/electron/gateway/channels/google-chat.ts +760 -0
  357. package/src/electron/gateway/channels/imessage-client.ts +473 -0
  358. package/src/electron/gateway/channels/imessage.ts +520 -0
  359. package/src/electron/gateway/channels/index.ts +21 -0
  360. package/src/electron/gateway/channels/line-client.ts +598 -0
  361. package/src/electron/gateway/channels/line.ts +559 -0
  362. package/src/electron/gateway/channels/matrix-client.ts +632 -0
  363. package/src/electron/gateway/channels/matrix.ts +655 -0
  364. package/src/electron/gateway/channels/mattermost-client.ts +526 -0
  365. package/src/electron/gateway/channels/mattermost.ts +550 -0
  366. package/src/electron/gateway/channels/signal-client.ts +722 -0
  367. package/src/electron/gateway/channels/signal.ts +666 -0
  368. package/src/electron/gateway/channels/slack.ts +458 -0
  369. package/src/electron/gateway/channels/teams.ts +681 -0
  370. package/src/electron/gateway/channels/telegram.ts +1727 -0
  371. package/src/electron/gateway/channels/twitch-client.ts +665 -0
  372. package/src/electron/gateway/channels/twitch.ts +468 -0
  373. package/src/electron/gateway/channels/types.ts +1002 -0
  374. package/src/electron/gateway/channels/whatsapp.ts +1101 -0
  375. package/src/electron/gateway/context-policy.ts +382 -0
  376. package/src/electron/gateway/index.ts +1274 -0
  377. package/src/electron/gateway/infrastructure.ts +645 -0
  378. package/src/electron/gateway/router.ts +3206 -0
  379. package/src/electron/gateway/security.ts +422 -0
  380. package/src/electron/gateway/session.ts +144 -0
  381. package/src/electron/gateway/tunnel.ts +626 -0
  382. package/src/electron/guardrails/guardrail-manager.ts +380 -0
  383. package/src/electron/hooks/gmail-watcher.ts +355 -0
  384. package/src/electron/hooks/index.ts +30 -0
  385. package/src/electron/hooks/mappings.ts +404 -0
  386. package/src/electron/hooks/server.ts +574 -0
  387. package/src/electron/hooks/settings.ts +466 -0
  388. package/src/electron/hooks/types.ts +245 -0
  389. package/src/electron/ipc/canvas-handlers.ts +223 -0
  390. package/src/electron/ipc/handlers.ts +3661 -0
  391. package/src/electron/ipc/mission-control-handlers.ts +182 -0
  392. package/src/electron/main.ts +496 -0
  393. package/src/electron/mcp/client/MCPClientManager.ts +406 -0
  394. package/src/electron/mcp/client/MCPServerConnection.ts +514 -0
  395. package/src/electron/mcp/client/transports/SSETransport.ts +360 -0
  396. package/src/electron/mcp/client/transports/StdioTransport.ts +355 -0
  397. package/src/electron/mcp/client/transports/WebSocketTransport.ts +384 -0
  398. package/src/electron/mcp/host/MCPHostServer.ts +388 -0
  399. package/src/electron/mcp/host/ToolAdapter.ts +140 -0
  400. package/src/electron/mcp/registry/MCPRegistryManager.ts +565 -0
  401. package/src/electron/mcp/settings.ts +468 -0
  402. package/src/electron/mcp/types.ts +371 -0
  403. package/src/electron/memory/MemoryService.ts +523 -0
  404. package/src/electron/notifications/index.ts +16 -0
  405. package/src/electron/notifications/service.ts +161 -0
  406. package/src/electron/notifications/store.ts +163 -0
  407. package/src/electron/preload.ts +2845 -0
  408. package/src/electron/reports/StandupReportService.ts +356 -0
  409. package/src/electron/security/concurrency.ts +333 -0
  410. package/src/electron/security/index.ts +17 -0
  411. package/src/electron/security/policy-manager.ts +539 -0
  412. package/src/electron/settings/appearance-manager.ts +182 -0
  413. package/src/electron/settings/personality-manager.ts +800 -0
  414. package/src/electron/settings/x-manager.ts +62 -0
  415. package/src/electron/tailscale/exposure.ts +262 -0
  416. package/src/electron/tailscale/index.ts +34 -0
  417. package/src/electron/tailscale/settings.ts +218 -0
  418. package/src/electron/tailscale/tailscale.ts +379 -0
  419. package/src/electron/tray/QuickInputWindow.ts +609 -0
  420. package/src/electron/tray/TrayManager.ts +1005 -0
  421. package/src/electron/tray/index.ts +6 -0
  422. package/src/electron/updater/index.ts +1 -0
  423. package/src/electron/updater/update-manager.ts +447 -0
  424. package/src/electron/utils/env-migration.ts +203 -0
  425. package/src/electron/utils/process.ts +124 -0
  426. package/src/electron/utils/rate-limiter.ts +130 -0
  427. package/src/electron/utils/validation.ts +493 -0
  428. package/src/electron/utils/x-cli.ts +198 -0
  429. package/src/electron/voice/VoiceService.ts +583 -0
  430. package/src/electron/voice/index.ts +9 -0
  431. package/src/electron/voice/voice-settings-manager.ts +403 -0
  432. package/src/renderer/App.tsx +775 -0
  433. package/src/renderer/components/ActivityFeed.tsx +407 -0
  434. package/src/renderer/components/ActivityFeedItem.tsx +285 -0
  435. package/src/renderer/components/AgentRoleCard.tsx +343 -0
  436. package/src/renderer/components/AgentRoleEditor.tsx +805 -0
  437. package/src/renderer/components/AgentSquadSettings.tsx +295 -0
  438. package/src/renderer/components/AgentWorkingStatePanel.tsx +411 -0
  439. package/src/renderer/components/AppearanceSettings.tsx +122 -0
  440. package/src/renderer/components/ApprovalDialog.tsx +100 -0
  441. package/src/renderer/components/BlueBubblesSettings.tsx +505 -0
  442. package/src/renderer/components/BuiltinToolsSettings.tsx +307 -0
  443. package/src/renderer/components/CanvasPreview.tsx +1189 -0
  444. package/src/renderer/components/CommandOutput.tsx +202 -0
  445. package/src/renderer/components/ContextPolicySettings.tsx +523 -0
  446. package/src/renderer/components/ControlPlaneSettings.tsx +1134 -0
  447. package/src/renderer/components/DisclaimerModal.tsx +124 -0
  448. package/src/renderer/components/DiscordSettings.tsx +436 -0
  449. package/src/renderer/components/EmailSettings.tsx +606 -0
  450. package/src/renderer/components/ExtensionsSettings.tsx +542 -0
  451. package/src/renderer/components/FileViewer.tsx +224 -0
  452. package/src/renderer/components/GoogleChatSettings.tsx +535 -0
  453. package/src/renderer/components/GuardrailSettings.tsx +487 -0
  454. package/src/renderer/components/HooksSettings.tsx +581 -0
  455. package/src/renderer/components/ImessageSettings.tsx +484 -0
  456. package/src/renderer/components/LineSettings.tsx +483 -0
  457. package/src/renderer/components/MCPRegistryBrowser.tsx +386 -0
  458. package/src/renderer/components/MCPSettings.tsx +943 -0
  459. package/src/renderer/components/MainContent.tsx +2433 -0
  460. package/src/renderer/components/MatrixSettings.tsx +510 -0
  461. package/src/renderer/components/MattermostSettings.tsx +473 -0
  462. package/src/renderer/components/MemorySettings.tsx +247 -0
  463. package/src/renderer/components/MentionBadge.tsx +87 -0
  464. package/src/renderer/components/MentionInput.tsx +409 -0
  465. package/src/renderer/components/MentionList.tsx +476 -0
  466. package/src/renderer/components/MissionControlPanel.tsx +1995 -0
  467. package/src/renderer/components/NodesSettings.tsx +316 -0
  468. package/src/renderer/components/NotificationPanel.tsx +481 -0
  469. package/src/renderer/components/Onboarding/AwakeningOrb.tsx +44 -0
  470. package/src/renderer/components/Onboarding/Onboarding.tsx +443 -0
  471. package/src/renderer/components/Onboarding/TypewriterText.tsx +102 -0
  472. package/src/renderer/components/Onboarding/index.ts +3 -0
  473. package/src/renderer/components/OnboardingModal.tsx +698 -0
  474. package/src/renderer/components/PairingCodeDisplay.tsx +324 -0
  475. package/src/renderer/components/PersonalitySettings.tsx +597 -0
  476. package/src/renderer/components/QueueSettings.tsx +119 -0
  477. package/src/renderer/components/QuickTaskFAB.tsx +71 -0
  478. package/src/renderer/components/RightPanel.tsx +413 -0
  479. package/src/renderer/components/ScheduledTasksSettings.tsx +1328 -0
  480. package/src/renderer/components/SearchSettings.tsx +328 -0
  481. package/src/renderer/components/Settings.tsx +1504 -0
  482. package/src/renderer/components/Sidebar.tsx +344 -0
  483. package/src/renderer/components/SignalSettings.tsx +673 -0
  484. package/src/renderer/components/SkillHubBrowser.tsx +458 -0
  485. package/src/renderer/components/SkillParameterModal.tsx +185 -0
  486. package/src/renderer/components/SkillsSettings.tsx +451 -0
  487. package/src/renderer/components/SlackSettings.tsx +442 -0
  488. package/src/renderer/components/StandupReportViewer.tsx +614 -0
  489. package/src/renderer/components/TaskBoard.tsx +498 -0
  490. package/src/renderer/components/TaskBoardCard.tsx +357 -0
  491. package/src/renderer/components/TaskBoardColumn.tsx +211 -0
  492. package/src/renderer/components/TaskLabelManager.tsx +472 -0
  493. package/src/renderer/components/TaskQueuePanel.tsx +144 -0
  494. package/src/renderer/components/TaskQuickActions.tsx +492 -0
  495. package/src/renderer/components/TaskTimeline.tsx +216 -0
  496. package/src/renderer/components/TaskView.tsx +162 -0
  497. package/src/renderer/components/TeamsSettings.tsx +518 -0
  498. package/src/renderer/components/TelegramSettings.tsx +421 -0
  499. package/src/renderer/components/Toast.tsx +76 -0
  500. package/src/renderer/components/TraySettings.tsx +189 -0
  501. package/src/renderer/components/TwitchSettings.tsx +511 -0
  502. package/src/renderer/components/UpdateSettings.tsx +295 -0
  503. package/src/renderer/components/VoiceIndicator.tsx +270 -0
  504. package/src/renderer/components/VoiceSettings.tsx +867 -0
  505. package/src/renderer/components/WhatsAppSettings.tsx +721 -0
  506. package/src/renderer/components/WorkingStateEditor.tsx +309 -0
  507. package/src/renderer/components/WorkingStateHistory.tsx +481 -0
  508. package/src/renderer/components/WorkspaceSelector.tsx +150 -0
  509. package/src/renderer/components/XSettings.tsx +311 -0
  510. package/src/renderer/global.d.ts +9 -0
  511. package/src/renderer/hooks/useAgentContext.ts +153 -0
  512. package/src/renderer/hooks/useOnboardingFlow.ts +548 -0
  513. package/src/renderer/hooks/useVoiceInput.ts +268 -0
  514. package/src/renderer/index.html +12 -0
  515. package/src/renderer/main.tsx +10 -0
  516. package/src/renderer/public/cowork-os-logo.png +0 -0
  517. package/src/renderer/quick-input.html +164 -0
  518. package/src/renderer/styles/index.css +14504 -0
  519. package/src/renderer/utils/agentMessages.ts +749 -0
  520. package/src/renderer/utils/voice-directives.ts +169 -0
  521. package/src/shared/channelMessages.ts +213 -0
  522. package/src/shared/types.ts +3608 -0
  523. package/tsconfig.electron.json +26 -0
  524. package/tsconfig.json +26 -0
  525. package/tsconfig.node.json +10 -0
  526. package/vite.config.ts +23 -0
@@ -0,0 +1,3608 @@
1
+ // Core types shared between main and renderer processes
2
+
3
+ // Theme and Appearance types
4
+ export type ThemeMode = 'light' | 'dark' | 'system';
5
+ export type AccentColor = 'cyan' | 'blue' | 'purple' | 'pink' | 'rose' | 'orange' | 'green' | 'teal' | 'coral';
6
+
7
+ export interface AppearanceSettings {
8
+ themeMode: ThemeMode;
9
+ accentColor: AccentColor;
10
+ disclaimerAccepted?: boolean;
11
+ onboardingCompleted?: boolean;
12
+ onboardingCompletedAt?: string; // ISO timestamp of when onboarding was completed
13
+ assistantName?: string; // User-chosen name for the assistant (default: "CoWork")
14
+ }
15
+
16
+ // Tray (Menu Bar) Settings
17
+ export interface TraySettings {
18
+ enabled: boolean;
19
+ showDockIcon: boolean;
20
+ startMinimized: boolean;
21
+ closeToTray: boolean;
22
+ showNotifications: boolean;
23
+ }
24
+
25
+ export const ACCENT_COLORS: { id: AccentColor; label: string }[] = [
26
+ { id: 'cyan', label: 'Cyan' },
27
+ { id: 'blue', label: 'Blue' },
28
+ { id: 'purple', label: 'Purple' },
29
+ { id: 'pink', label: 'Pink' },
30
+ { id: 'rose', label: 'Rose' },
31
+ { id: 'orange', label: 'Orange' },
32
+ { id: 'green', label: 'Green' },
33
+ { id: 'teal', label: 'Teal' },
34
+ { id: 'coral', label: 'Coral' },
35
+ ];
36
+
37
+ export type TaskStatus = 'pending' | 'queued' | 'planning' | 'executing' | 'paused' | 'blocked' | 'completed' | 'failed' | 'cancelled';
38
+
39
+ /**
40
+ * Reason for command termination - used to signal the agent why a command ended
41
+ */
42
+ export type CommandTerminationReason =
43
+ | 'normal' // Command completed naturally
44
+ | 'user_stopped' // User explicitly killed the process
45
+ | 'timeout' // Command exceeded timeout limit
46
+ | 'error'; // Spawn/execution error
47
+
48
+ export type EventType =
49
+ | 'task_created'
50
+ | 'task_completed'
51
+ | 'plan_created'
52
+ | 'plan_revised'
53
+ | 'step_started'
54
+ | 'step_completed'
55
+ | 'step_failed'
56
+ | 'executing'
57
+ | 'tool_call'
58
+ | 'tool_result'
59
+ | 'tool_error'
60
+ | 'assistant_message'
61
+ | 'approval_requested'
62
+ | 'approval_granted'
63
+ | 'approval_denied'
64
+ | 'file_created'
65
+ | 'file_modified'
66
+ | 'file_deleted'
67
+ | 'image_generated'
68
+ | 'error'
69
+ | 'log'
70
+ | 'verification_started'
71
+ | 'verification_passed'
72
+ | 'verification_failed'
73
+ | 'retry_started'
74
+ | 'task_cancelled'
75
+ | 'task_paused'
76
+ | 'task_resumed'
77
+ | 'task_status'
78
+ | 'task_queued'
79
+ | 'task_dequeued'
80
+ | 'queue_updated'
81
+ | 'plan_revision_blocked'
82
+ | 'step_timeout'
83
+ | 'tool_blocked'
84
+ | 'progress_update'
85
+ | 'llm_retry'
86
+ | 'follow_up_completed'
87
+ | 'follow_up_failed'
88
+ | 'tool_warning'
89
+ | 'user_message'
90
+ | 'command_output'
91
+ // Sub-Agent / Parallel Agent events
92
+ | 'agent_spawned' // Parent spawned a child agent
93
+ | 'agent_completed' // Child agent completed successfully
94
+ | 'agent_failed' // Child agent failed
95
+ | 'sub_agent_result' // Result summary from child agent
96
+ // Conversation persistence
97
+ | 'conversation_snapshot'; // Full conversation history for restoration
98
+
99
+ export type ToolType =
100
+ | 'read_file'
101
+ | 'write_file'
102
+ | 'copy_file'
103
+ | 'list_directory'
104
+ | 'rename_file'
105
+ | 'move_file'
106
+ | 'delete_file'
107
+ | 'create_directory'
108
+ | 'search_files'
109
+ | 'run_skill'
110
+ | 'run_command'
111
+ | 'generate_image'
112
+ // System tools
113
+ | 'system_info'
114
+ | 'read_clipboard'
115
+ | 'write_clipboard'
116
+ | 'take_screenshot'
117
+ | 'open_application'
118
+ | 'open_url'
119
+ | 'open_path'
120
+ | 'show_in_folder'
121
+ | 'get_env'
122
+ | 'get_app_paths'
123
+ // Network/Browser tools
124
+ | 'web_search'
125
+ | 'browser_navigate'
126
+ | 'browser_screenshot'
127
+ | 'browser_get_content'
128
+ | 'browser_click'
129
+ | 'browser_fill'
130
+ | 'browser_type'
131
+ | 'browser_press'
132
+ | 'browser_wait'
133
+ | 'browser_scroll'
134
+ | 'browser_select'
135
+ | 'browser_get_text'
136
+ | 'browser_evaluate'
137
+ | 'browser_back'
138
+ | 'browser_forward'
139
+ | 'browser_reload'
140
+ | 'browser_save_pdf'
141
+ | 'browser_close'
142
+ // X/Twitter
143
+ | 'x_action'
144
+ // Meta tools
145
+ | 'revise_plan';
146
+
147
+ export type ApprovalType =
148
+ | 'delete_file'
149
+ | 'delete_multiple'
150
+ | 'bulk_rename'
151
+ | 'network_access'
152
+ | 'external_service'
153
+ | 'run_command';
154
+
155
+ // ============ Security Tool Groups & Risk Levels ============
156
+
157
+ /**
158
+ * Tool risk levels for security policy enforcement
159
+ * Higher levels require more permissions/approval
160
+ */
161
+ export type ToolRiskLevel = 'read' | 'write' | 'destructive' | 'system' | 'network';
162
+
163
+ /**
164
+ * Tool groups for policy-based access control
165
+ */
166
+ export const TOOL_GROUPS = {
167
+ // Read-only operations - lowest risk
168
+ 'group:read': [
169
+ 'read_file',
170
+ 'list_directory',
171
+ 'search_files',
172
+ 'system_info',
173
+ 'get_env',
174
+ 'get_app_paths',
175
+ ],
176
+ // Write operations - medium risk
177
+ 'group:write': [
178
+ 'write_file',
179
+ 'copy_file',
180
+ 'rename_file',
181
+ 'create_directory',
182
+ 'create_spreadsheet',
183
+ 'create_document',
184
+ 'edit_document',
185
+ 'create_presentation',
186
+ 'organize_folder',
187
+ ],
188
+ // Destructive operations - high risk, requires approval
189
+ 'group:destructive': [
190
+ 'delete_file',
191
+ 'run_command',
192
+ ],
193
+ // System operations - requires explicit permission
194
+ 'group:system': [
195
+ 'read_clipboard',
196
+ 'write_clipboard',
197
+ 'take_screenshot',
198
+ 'open_application',
199
+ 'open_url',
200
+ 'open_path',
201
+ 'show_in_folder',
202
+ ],
203
+ // Network operations - requires network permission
204
+ 'group:network': [
205
+ 'web_search',
206
+ 'x_action',
207
+ 'browser_navigate',
208
+ 'browser_screenshot',
209
+ 'browser_get_content',
210
+ 'browser_click',
211
+ 'browser_fill',
212
+ 'browser_type',
213
+ 'browser_press',
214
+ 'browser_wait',
215
+ 'browser_scroll',
216
+ 'browser_select',
217
+ 'browser_get_text',
218
+ 'browser_evaluate',
219
+ 'browser_back',
220
+ 'browser_forward',
221
+ 'browser_reload',
222
+ 'browser_save_pdf',
223
+ 'browser_close',
224
+ ],
225
+ // Memory/sensitive tools - restricted in shared contexts
226
+ 'group:memory': [
227
+ 'read_clipboard',
228
+ 'write_clipboard',
229
+ ],
230
+ // Image generation - requires API access
231
+ 'group:image': [
232
+ 'generate_image',
233
+ ],
234
+ // Meta/control tools
235
+ 'group:meta': [
236
+ 'revise_plan',
237
+ ],
238
+ } as const;
239
+
240
+ export type ToolGroupName = keyof typeof TOOL_GROUPS;
241
+
242
+ /**
243
+ * Maps each tool to its risk level
244
+ */
245
+ export const TOOL_RISK_LEVELS: Record<ToolType, ToolRiskLevel> = {
246
+ // Read operations
247
+ read_file: 'read',
248
+ list_directory: 'read',
249
+ search_files: 'read',
250
+ system_info: 'read',
251
+ get_env: 'read',
252
+ get_app_paths: 'read',
253
+ // Write operations
254
+ write_file: 'write',
255
+ copy_file: 'write',
256
+ rename_file: 'write',
257
+ move_file: 'write',
258
+ create_directory: 'write',
259
+ run_skill: 'write',
260
+ // Destructive operations
261
+ delete_file: 'destructive',
262
+ run_command: 'destructive',
263
+ // System operations
264
+ read_clipboard: 'system',
265
+ write_clipboard: 'system',
266
+ take_screenshot: 'system',
267
+ open_application: 'system',
268
+ open_url: 'system',
269
+ open_path: 'system',
270
+ show_in_folder: 'system',
271
+ // Network operations
272
+ generate_image: 'network',
273
+ web_search: 'network',
274
+ browser_navigate: 'network',
275
+ browser_screenshot: 'network',
276
+ browser_get_content: 'network',
277
+ browser_click: 'network',
278
+ browser_fill: 'network',
279
+ browser_type: 'network',
280
+ browser_press: 'network',
281
+ browser_wait: 'network',
282
+ browser_scroll: 'network',
283
+ browser_select: 'network',
284
+ browser_get_text: 'network',
285
+ browser_evaluate: 'network',
286
+ browser_back: 'network',
287
+ browser_forward: 'network',
288
+ browser_reload: 'network',
289
+ browser_save_pdf: 'network',
290
+ browser_close: 'network',
291
+ x_action: 'network',
292
+ // Meta
293
+ revise_plan: 'read',
294
+ };
295
+
296
+ /**
297
+ * Gateway context types for context-aware tool restrictions
298
+ */
299
+ export type GatewayContextType = 'private' | 'group' | 'public';
300
+
301
+ /**
302
+ * Tool restrictions based on gateway context
303
+ * Implements C1: Memory Tool Isolation in Shared Contexts
304
+ */
305
+ export const CONTEXT_TOOL_RESTRICTIONS: Record<GatewayContextType, {
306
+ deniedGroups: ToolGroupName[];
307
+ deniedTools: string[];
308
+ requireApprovalFor: string[];
309
+ }> = {
310
+ private: {
311
+ deniedGroups: [],
312
+ deniedTools: [],
313
+ requireApprovalFor: ['delete_file'],
314
+ },
315
+ group: {
316
+ deniedGroups: ['group:memory'],
317
+ deniedTools: ['read_clipboard', 'write_clipboard'],
318
+ requireApprovalFor: ['delete_file'],
319
+ },
320
+ public: {
321
+ deniedGroups: ['group:memory'],
322
+ deniedTools: ['read_clipboard', 'write_clipboard'],
323
+ requireApprovalFor: ['delete_file'],
324
+ },
325
+ };
326
+
327
+ // Success Criteria for Goal Mode
328
+ export type SuccessCriteriaType = 'shell_command' | 'file_exists';
329
+
330
+ export interface SuccessCriteria {
331
+ type: SuccessCriteriaType;
332
+ command?: string; // For shell_command: command to run (exit 0 = success)
333
+ filePaths?: string[]; // For file_exists: paths that must exist
334
+ }
335
+
336
+ // ============ Sub-Agent / Parallel Agent Types ============
337
+
338
+ /**
339
+ * Agent type determines the behavior and lifecycle of a task
340
+ * - 'main': Primary user-created task (default)
341
+ * - 'sub': Disposable agent spawned for batch work (no memory retention)
342
+ * - 'parallel': Independent agent that can run alongside main agents
343
+ */
344
+ export type AgentType = 'main' | 'sub' | 'parallel';
345
+
346
+ /**
347
+ * Per-task agent configuration for customizing LLM and personality
348
+ * Allows spawning agents with different models/personalities than the global settings
349
+ */
350
+ export interface AgentConfig {
351
+ /** Override the LLM provider type (e.g., 'anthropic', 'gemini') */
352
+ providerType?: LLMProviderType;
353
+ /** Override the model key (e.g., 'opus-4-5', 'sonnet-4-5', 'haiku-4-5') */
354
+ modelKey?: string;
355
+ /** Override the personality for this agent */
356
+ personalityId?: PersonalityId;
357
+ /** Maximum number of LLM turns before forcing completion (for sub-agents) */
358
+ maxTurns?: number;
359
+ /** Maximum tokens budget for this agent */
360
+ maxTokens?: number;
361
+ /** Whether to retain memory/context after completion (default: false for sub-agents) */
362
+ retainMemory?: boolean;
363
+ }
364
+
365
+ export interface Task {
366
+ id: string;
367
+ title: string;
368
+ prompt: string;
369
+ status: TaskStatus;
370
+ workspaceId: string;
371
+ createdAt: number;
372
+ updatedAt: number;
373
+ completedAt?: number;
374
+ budgetTokens?: number;
375
+ budgetCost?: number;
376
+ error?: string;
377
+ // Goal Mode fields
378
+ successCriteria?: SuccessCriteria;
379
+ maxAttempts?: number; // Default: 3, max: 10
380
+ currentAttempt?: number; // Tracks which attempt we're on
381
+ // Sub-Agent / Parallel Agent fields
382
+ parentTaskId?: string; // ID of the parent task that spawned this one
383
+ agentType?: AgentType; // Type of agent: 'main', 'sub', or 'parallel'
384
+ agentConfig?: AgentConfig; // Per-task agent configuration (model, personality, etc.)
385
+ depth?: number; // Nesting depth (0 = root, 1 = first child, etc.)
386
+ resultSummary?: string; // Summary of results for parent agent to consume
387
+ // Agent Squad fields
388
+ assignedAgentRoleId?: string; // ID of the agent role assigned to this task
389
+ boardColumn?: BoardColumn; // Kanban column for task organization
390
+ priority?: number; // Task priority (higher = more important)
391
+ // Task Board fields
392
+ labels?: string[]; // JSON array of label IDs
393
+ dueDate?: number; // Due date timestamp
394
+ estimatedMinutes?: number; // Estimated time in minutes
395
+ actualMinutes?: number; // Actual time spent in minutes
396
+ mentionedAgentRoleIds?: string[]; // Agent roles mentioned in this task
397
+ }
398
+
399
+ export interface TaskEvent {
400
+ id: string;
401
+ taskId: string;
402
+ timestamp: number;
403
+ type: EventType;
404
+ payload: any;
405
+ }
406
+
407
+ export interface Artifact {
408
+ id: string;
409
+ taskId: string;
410
+ path: string;
411
+ mimeType: string;
412
+ sha256: string;
413
+ size: number;
414
+ createdAt: number;
415
+ }
416
+
417
+ export interface Workspace {
418
+ id: string;
419
+ name: string;
420
+ path: string;
421
+ createdAt: number;
422
+ permissions: WorkspacePermissions;
423
+ isTemp?: boolean; // True for the auto-created temp workspace
424
+ }
425
+
426
+ // Temp workspace constants
427
+ export const TEMP_WORKSPACE_ID = '__temp_workspace__';
428
+ export const TEMP_WORKSPACE_NAME = 'Temporary Workspace';
429
+
430
+ /**
431
+ * Sandbox type for command execution isolation
432
+ */
433
+ export type SandboxType = 'auto' | 'macos' | 'docker' | 'none';
434
+
435
+ /**
436
+ * Docker sandbox configuration
437
+ */
438
+ export interface DockerSandboxConfig {
439
+ /** Docker image to use (default: node:20-alpine) */
440
+ image?: string;
441
+ /** CPU limit in cores (e.g., 0.5 = half a core) */
442
+ cpuLimit?: number;
443
+ /** Memory limit (e.g., "512m", "1g") */
444
+ memoryLimit?: string;
445
+ /** Network mode: 'none' for isolation, 'bridge' for network access */
446
+ networkMode?: 'none' | 'bridge';
447
+ }
448
+
449
+ export interface WorkspacePermissions {
450
+ read: boolean;
451
+ write: boolean;
452
+ delete: boolean;
453
+ network: boolean;
454
+ shell: boolean;
455
+ allowedDomains?: string[];
456
+ // Broader filesystem access (like Claude Code)
457
+ unrestrictedFileAccess?: boolean; // Allow reading/writing files outside workspace
458
+ allowedPaths?: string[]; // Specific paths outside workspace to allow (if not fully unrestricted)
459
+ // Sandbox configuration
460
+ sandboxType?: SandboxType; // Which sandbox to use (auto-detect if not specified)
461
+ dockerConfig?: DockerSandboxConfig; // Docker-specific configuration
462
+ }
463
+
464
+ export interface PlanStep {
465
+ id: string;
466
+ description: string;
467
+ status: 'pending' | 'in_progress' | 'completed' | 'failed';
468
+ startedAt?: number;
469
+ completedAt?: number;
470
+ error?: string;
471
+ }
472
+
473
+ export interface Plan {
474
+ steps: PlanStep[];
475
+ description: string;
476
+ }
477
+
478
+ export interface ToolCall {
479
+ id: string;
480
+ tool: ToolType;
481
+ parameters: any;
482
+ timestamp: number;
483
+ }
484
+
485
+ export interface ToolResult {
486
+ callId: string;
487
+ success: boolean;
488
+ result?: any;
489
+ error?: string;
490
+ timestamp: number;
491
+ }
492
+
493
+ /**
494
+ * Result from node tool handler execution
495
+ * Supports text, JSON, image, and video responses
496
+ */
497
+ export interface NodeToolResult {
498
+ type: 'text' | 'json' | 'image' | 'video';
499
+ content: string;
500
+ mimeType?: string;
501
+ isError?: boolean;
502
+ }
503
+
504
+ /**
505
+ * Definition for node tools with handler functions
506
+ */
507
+ export interface ToolDefinition {
508
+ name: string;
509
+ description: string;
510
+ inputSchema: {
511
+ type: 'object';
512
+ properties: Record<string, any>;
513
+ required: string[];
514
+ };
515
+ riskLevel: 'read' | 'write';
516
+ groups: readonly string[];
517
+ handler: (params: any) => Promise<NodeToolResult>;
518
+ }
519
+
520
+ export interface ApprovalRequest {
521
+ id: string;
522
+ taskId: string;
523
+ type: ApprovalType;
524
+ description: string;
525
+ details: any;
526
+ status: 'pending' | 'approved' | 'denied';
527
+ requestedAt: number;
528
+ resolvedAt?: number;
529
+ }
530
+
531
+ export interface Skill {
532
+ id: string;
533
+ name: string;
534
+ description: string;
535
+ category: 'document' | 'spreadsheet' | 'presentation' | 'organizer' | 'custom';
536
+ prompt: string;
537
+ scriptPath?: string;
538
+ parameters?: Record<string, any>;
539
+ }
540
+
541
+ // ============ Agent Squad / Role Types ============
542
+
543
+ /**
544
+ * Capability types that define what an agent role can do
545
+ */
546
+ export type AgentCapability =
547
+ // Technical
548
+ | 'code' // Writing and editing code
549
+ | 'review' // Reviewing code or content
550
+ | 'test' // Writing and running tests
551
+ | 'design' // UI/UX and visual design
552
+ | 'ops' // DevOps, CI/CD, infrastructure
553
+ | 'security' // Security analysis and auditing
554
+ // Analysis & Research
555
+ | 'research' // Investigating and gathering information
556
+ | 'analyze' // Data analysis and insights
557
+ | 'plan' // Planning and architecture
558
+ // Communication & Content
559
+ | 'document' // Writing documentation
560
+ | 'write' // General content writing
561
+ | 'communicate' // Customer support, outreach
562
+ | 'market' // Marketing and growth
563
+ // Management
564
+ | 'manage' // Project management, coordination
565
+ | 'product'; // Product management, feature planning
566
+
567
+ /**
568
+ * Agent autonomy level determines how independently an agent can act
569
+ * - intern: Needs approval for most actions, learning the system
570
+ * - specialist: Works independently in their domain
571
+ * - lead: Full autonomy, can delegate tasks to other agents
572
+ */
573
+ export type AgentAutonomyLevel = 'intern' | 'specialist' | 'lead';
574
+
575
+ /**
576
+ * Heartbeat status for tracking agent wake cycles
577
+ */
578
+ export type HeartbeatStatus = 'idle' | 'running' | 'sleeping' | 'error';
579
+
580
+ /**
581
+ * Tool restriction configuration for an agent role
582
+ */
583
+ export interface AgentToolRestrictions {
584
+ allowedTools?: string[];
585
+ deniedTools?: string[];
586
+ }
587
+
588
+ /**
589
+ * Agent role defines a specialized agent with specific capabilities and configuration
590
+ */
591
+ export interface AgentRole {
592
+ id: string;
593
+ name: string; // Unique identifier (e.g., 'code-reviewer')
594
+ displayName: string; // Human-readable name (e.g., 'Code Reviewer')
595
+ description?: string; // What this agent does
596
+ icon: string; // Emoji or icon
597
+ color: string; // Hex color for UI
598
+ personalityId?: PersonalityId; // Override personality
599
+ modelKey?: string; // Override model (e.g., 'opus-4-5')
600
+ providerType?: LLMProviderType; // Override provider
601
+ systemPrompt?: string; // Additional system prompt
602
+ capabilities: AgentCapability[]; // What this agent can do
603
+ toolRestrictions?: AgentToolRestrictions; // Tool access control
604
+ isSystem: boolean; // Built-in vs custom
605
+ isActive: boolean; // Enabled/disabled
606
+ sortOrder: number; // Display order
607
+ createdAt: number;
608
+ updatedAt: number;
609
+
610
+ // Mission Control fields
611
+ autonomyLevel?: AgentAutonomyLevel; // How independently the agent can act
612
+ soul?: string; // Extended personality (JSON: communication style, focus areas, preferences)
613
+ heartbeatEnabled?: boolean; // Whether agent participates in heartbeat system
614
+ heartbeatIntervalMinutes?: number; // How often agent wakes up (default: 15)
615
+ heartbeatStaggerOffset?: number; // Offset in minutes to stagger wakeups
616
+ lastHeartbeatAt?: number; // Timestamp of last heartbeat
617
+ heartbeatStatus?: HeartbeatStatus; // Current heartbeat state
618
+ }
619
+
620
+ /**
621
+ * Request to create a new agent role
622
+ */
623
+ export interface CreateAgentRoleRequest {
624
+ name: string;
625
+ displayName: string;
626
+ description?: string;
627
+ icon?: string;
628
+ color?: string;
629
+ personalityId?: PersonalityId;
630
+ modelKey?: string;
631
+ providerType?: LLMProviderType;
632
+ systemPrompt?: string;
633
+ capabilities: AgentCapability[];
634
+ toolRestrictions?: AgentToolRestrictions;
635
+ // Mission Control fields
636
+ autonomyLevel?: AgentAutonomyLevel;
637
+ soul?: string;
638
+ heartbeatEnabled?: boolean;
639
+ heartbeatIntervalMinutes?: number;
640
+ heartbeatStaggerOffset?: number;
641
+ }
642
+
643
+ /**
644
+ * Request to update an agent role
645
+ */
646
+ export interface UpdateAgentRoleRequest {
647
+ id: string;
648
+ displayName?: string;
649
+ description?: string;
650
+ icon?: string;
651
+ color?: string;
652
+ personalityId?: PersonalityId;
653
+ modelKey?: string;
654
+ providerType?: LLMProviderType;
655
+ systemPrompt?: string;
656
+ capabilities?: AgentCapability[];
657
+ toolRestrictions?: AgentToolRestrictions;
658
+ isActive?: boolean;
659
+ sortOrder?: number;
660
+ // Mission Control fields
661
+ autonomyLevel?: AgentAutonomyLevel;
662
+ soul?: string;
663
+ heartbeatEnabled?: boolean;
664
+ heartbeatIntervalMinutes?: number;
665
+ heartbeatStaggerOffset?: number;
666
+ }
667
+
668
+ /**
669
+ * Default agent roles that come pre-configured
670
+ */
671
+ export const DEFAULT_AGENT_ROLES: Omit<AgentRole, 'id' | 'createdAt' | 'updatedAt'>[] = [
672
+ {
673
+ name: 'coder',
674
+ displayName: 'Coder',
675
+ description: 'Writes clean, efficient code and implements features',
676
+ icon: '💻',
677
+ color: '#3b82f6',
678
+ capabilities: ['code', 'document'],
679
+ autonomyLevel: 'specialist',
680
+ isSystem: true,
681
+ isActive: true,
682
+ sortOrder: 1,
683
+ },
684
+ {
685
+ name: 'reviewer',
686
+ displayName: 'Code Reviewer',
687
+ description: 'Reviews code for bugs, security issues, and best practices',
688
+ icon: '🔍',
689
+ color: '#8b5cf6',
690
+ capabilities: ['review', 'analyze'],
691
+ autonomyLevel: 'specialist',
692
+ isSystem: true,
693
+ isActive: true,
694
+ sortOrder: 2,
695
+ },
696
+ {
697
+ name: 'researcher',
698
+ displayName: 'Researcher',
699
+ description: 'Investigates solutions, analyzes options, and gathers information',
700
+ icon: '🔬',
701
+ color: '#10b981',
702
+ capabilities: ['research', 'analyze', 'document'],
703
+ autonomyLevel: 'specialist',
704
+ isSystem: true,
705
+ isActive: true,
706
+ sortOrder: 3,
707
+ },
708
+ {
709
+ name: 'tester',
710
+ displayName: 'Tester',
711
+ description: 'Writes and runs tests, finds edge cases and bugs',
712
+ icon: '🧪',
713
+ color: '#f59e0b',
714
+ capabilities: ['test', 'review'],
715
+ autonomyLevel: 'specialist',
716
+ isSystem: true,
717
+ isActive: true,
718
+ sortOrder: 4,
719
+ },
720
+ {
721
+ name: 'architect',
722
+ displayName: 'Architect',
723
+ description: 'Designs system architecture and plans implementation',
724
+ icon: '🏗️',
725
+ color: '#ec4899',
726
+ capabilities: ['plan', 'design', 'analyze'],
727
+ autonomyLevel: 'lead', // Can delegate tasks to other agents
728
+ isSystem: true,
729
+ isActive: true,
730
+ sortOrder: 5,
731
+ },
732
+ {
733
+ name: 'writer',
734
+ displayName: 'Content Writer',
735
+ description: 'Writes documentation, blog posts, and marketing copy',
736
+ icon: '✍️',
737
+ color: '#06b6d4',
738
+ capabilities: ['document', 'research'],
739
+ autonomyLevel: 'specialist',
740
+ isSystem: true,
741
+ isActive: true,
742
+ sortOrder: 6,
743
+ },
744
+ {
745
+ name: 'designer',
746
+ displayName: 'Designer',
747
+ description: 'Creates UI mockups, diagrams, and visual designs',
748
+ icon: '🎨',
749
+ color: '#d946ef',
750
+ capabilities: ['design', 'plan'],
751
+ autonomyLevel: 'specialist',
752
+ isSystem: true,
753
+ isActive: true,
754
+ sortOrder: 7,
755
+ },
756
+ // === General Purpose Agents ===
757
+ {
758
+ name: 'project_manager',
759
+ displayName: 'Project Manager',
760
+ description: 'Coordinates tasks, tracks progress, manages timelines and team workload',
761
+ icon: '📋',
762
+ color: '#0ea5e9',
763
+ capabilities: ['manage', 'plan', 'communicate'],
764
+ autonomyLevel: 'lead',
765
+ isSystem: true,
766
+ isActive: true,
767
+ sortOrder: 8,
768
+ },
769
+ {
770
+ name: 'product_manager',
771
+ displayName: 'Product Manager',
772
+ description: 'Defines features, writes user stories, prioritizes backlog',
773
+ icon: '🎯',
774
+ color: '#14b8a6',
775
+ capabilities: ['product', 'plan', 'research'],
776
+ autonomyLevel: 'lead',
777
+ isSystem: true,
778
+ isActive: true,
779
+ sortOrder: 9,
780
+ },
781
+ {
782
+ name: 'data_analyst',
783
+ displayName: 'Data Analyst',
784
+ description: 'Analyzes data, creates reports, finds insights and trends',
785
+ icon: '📊',
786
+ color: '#6366f1',
787
+ capabilities: ['analyze', 'research', 'document'],
788
+ autonomyLevel: 'specialist',
789
+ isSystem: true,
790
+ isActive: true,
791
+ sortOrder: 10,
792
+ },
793
+ {
794
+ name: 'marketing',
795
+ displayName: 'Marketing Specialist',
796
+ description: 'Creates campaigns, social media content, growth strategies',
797
+ icon: '📣',
798
+ color: '#f43f5e',
799
+ capabilities: ['market', 'write', 'research'],
800
+ autonomyLevel: 'specialist',
801
+ isSystem: true,
802
+ isActive: true,
803
+ sortOrder: 11,
804
+ },
805
+ {
806
+ name: 'support',
807
+ displayName: 'Support Agent',
808
+ description: 'Handles user queries, troubleshooting, customer communication',
809
+ icon: '💬',
810
+ color: '#22c55e',
811
+ capabilities: ['communicate', 'research', 'document'],
812
+ autonomyLevel: 'specialist',
813
+ isSystem: true,
814
+ isActive: true,
815
+ sortOrder: 12,
816
+ },
817
+ {
818
+ name: 'devops',
819
+ displayName: 'DevOps Engineer',
820
+ description: 'Manages CI/CD pipelines, deployment, infrastructure and monitoring',
821
+ icon: '⚙️',
822
+ color: '#f97316',
823
+ capabilities: ['ops', 'code', 'security'],
824
+ autonomyLevel: 'specialist',
825
+ isSystem: true,
826
+ isActive: true,
827
+ sortOrder: 13,
828
+ },
829
+ {
830
+ name: 'security_analyst',
831
+ displayName: 'Security Analyst',
832
+ description: 'Performs security audits, vulnerability assessments, compliance checks',
833
+ icon: '🔒',
834
+ color: '#ef4444',
835
+ capabilities: ['security', 'review', 'analyze'],
836
+ autonomyLevel: 'specialist',
837
+ isSystem: true,
838
+ isActive: true,
839
+ sortOrder: 14,
840
+ },
841
+ {
842
+ name: 'assistant',
843
+ displayName: 'General Assistant',
844
+ description: 'Versatile helper for miscellaneous tasks, scheduling, and coordination',
845
+ icon: '🤖',
846
+ color: '#64748b',
847
+ capabilities: ['communicate', 'research', 'manage'],
848
+ autonomyLevel: 'intern',
849
+ isSystem: true,
850
+ isActive: true,
851
+ sortOrder: 15,
852
+ },
853
+ ];
854
+
855
+ // ============ Mission Control Types ============
856
+
857
+ /**
858
+ * Task subscription for auto-notifications
859
+ * Agents subscribed to a task receive updates when new comments/activities occur
860
+ */
861
+ export interface TaskSubscription {
862
+ id: string;
863
+ taskId: string;
864
+ agentRoleId: string;
865
+ subscriptionReason: 'assigned' | 'mentioned' | 'commented' | 'manual';
866
+ subscribedAt: number;
867
+ }
868
+
869
+ /**
870
+ * Daily standup report aggregating task status
871
+ */
872
+ export interface StandupReport {
873
+ id: string;
874
+ workspaceId: string;
875
+ reportDate: string; // YYYY-MM-DD format
876
+ completedTaskIds: string[];
877
+ inProgressTaskIds: string[];
878
+ blockedTaskIds: string[];
879
+ summary: string;
880
+ deliveredToChannel?: string; // channel:id format
881
+ createdAt: number;
882
+ }
883
+
884
+ /**
885
+ * Result from a heartbeat check
886
+ */
887
+ export interface HeartbeatResult {
888
+ agentRoleId: string;
889
+ status: 'ok' | 'work_done' | 'error';
890
+ pendingMentions: number;
891
+ assignedTasks: number;
892
+ relevantActivities: number;
893
+ taskCreated?: string; // ID of task created if work was done
894
+ error?: string;
895
+ }
896
+
897
+ /**
898
+ * Heartbeat configuration for an agent
899
+ */
900
+ export interface HeartbeatConfig {
901
+ heartbeatEnabled?: boolean;
902
+ heartbeatIntervalMinutes?: number;
903
+ heartbeatStaggerOffset?: number;
904
+ }
905
+
906
+ /**
907
+ * Heartbeat event emitted during heartbeat execution
908
+ */
909
+ export interface HeartbeatEvent {
910
+ type: 'started' | 'completed' | 'error' | 'work_found' | 'no_work';
911
+ agentRoleId: string;
912
+ agentName: string;
913
+ timestamp: number;
914
+ result?: HeartbeatResult;
915
+ error?: string;
916
+ }
917
+
918
+ /**
919
+ * Board column for task organization (Kanban)
920
+ */
921
+ export type BoardColumn = 'backlog' | 'todo' | 'in_progress' | 'review' | 'done';
922
+
923
+ /**
924
+ * Board column definitions for UI
925
+ */
926
+ export const BOARD_COLUMNS: { id: BoardColumn; label: string; color: string }[] = [
927
+ { id: 'backlog', label: 'Backlog', color: '#6b7280' },
928
+ { id: 'todo', label: 'To Do', color: '#3b82f6' },
929
+ { id: 'in_progress', label: 'In Progress', color: '#f59e0b' },
930
+ { id: 'review', label: 'Review', color: '#8b5cf6' },
931
+ { id: 'done', label: 'Done', color: '#10b981' },
932
+ ];
933
+
934
+ /**
935
+ * Task label for organization
936
+ */
937
+ export interface TaskLabel {
938
+ id: string;
939
+ workspaceId: string;
940
+ name: string;
941
+ color: string;
942
+ createdAt: number;
943
+ }
944
+
945
+ /**
946
+ * Request to create a new task label
947
+ */
948
+ export interface CreateTaskLabelRequest {
949
+ workspaceId: string;
950
+ name: string;
951
+ color?: string;
952
+ }
953
+
954
+ /**
955
+ * Request to update a task label
956
+ */
957
+ export interface UpdateTaskLabelRequest {
958
+ name?: string;
959
+ color?: string;
960
+ }
961
+
962
+ /**
963
+ * Query parameters for listing task labels
964
+ */
965
+ export interface TaskLabelListQuery {
966
+ workspaceId: string;
967
+ }
968
+
969
+ // ============ Agent Working State Types ============
970
+
971
+ /**
972
+ * State type for agent working state
973
+ */
974
+ export type WorkingStateType = 'context' | 'progress' | 'notes' | 'plan';
975
+
976
+ /**
977
+ * Agent working state for context persistence
978
+ */
979
+ export interface AgentWorkingState {
980
+ id: string;
981
+ agentRoleId: string;
982
+ workspaceId: string;
983
+ taskId?: string;
984
+ stateType: WorkingStateType;
985
+ content: string;
986
+ fileReferences?: string[];
987
+ isCurrent: boolean;
988
+ createdAt: number;
989
+ updatedAt: number;
990
+ }
991
+
992
+ /**
993
+ * Request to create or update agent working state
994
+ */
995
+ export interface UpdateWorkingStateRequest {
996
+ agentRoleId: string;
997
+ workspaceId: string;
998
+ taskId?: string;
999
+ stateType: WorkingStateType;
1000
+ content: string;
1001
+ fileReferences?: string[];
1002
+ }
1003
+
1004
+ /**
1005
+ * Query to get agent working state
1006
+ */
1007
+ export interface WorkingStateQuery {
1008
+ agentRoleId: string;
1009
+ workspaceId: string;
1010
+ taskId?: string;
1011
+ stateType?: WorkingStateType;
1012
+ }
1013
+
1014
+ /**
1015
+ * Query to get working state history
1016
+ */
1017
+ export interface WorkingStateHistoryQuery {
1018
+ agentRoleId: string;
1019
+ workspaceId: string;
1020
+ limit?: number;
1021
+ offset?: number;
1022
+ }
1023
+
1024
+ // ============ Activity Feed Types ============
1025
+
1026
+ /**
1027
+ * Actor type for activity feed entries
1028
+ */
1029
+ export type ActivityActorType = 'agent' | 'user' | 'system';
1030
+
1031
+ /**
1032
+ * Type of activity in the feed
1033
+ */
1034
+ export type ActivityType =
1035
+ | 'task_created'
1036
+ | 'task_started'
1037
+ | 'task_completed'
1038
+ | 'task_failed'
1039
+ | 'task_paused'
1040
+ | 'task_resumed'
1041
+ | 'comment'
1042
+ | 'file_created'
1043
+ | 'file_modified'
1044
+ | 'file_deleted'
1045
+ | 'command_executed'
1046
+ | 'tool_used'
1047
+ | 'mention'
1048
+ | 'agent_assigned'
1049
+ | 'error'
1050
+ | 'info';
1051
+
1052
+ /**
1053
+ * Activity feed entry
1054
+ */
1055
+ export interface Activity {
1056
+ id: string;
1057
+ workspaceId: string;
1058
+ taskId?: string;
1059
+ agentRoleId?: string;
1060
+ actorType: ActivityActorType;
1061
+ activityType: ActivityType;
1062
+ title: string;
1063
+ description?: string;
1064
+ metadata?: Record<string, unknown>;
1065
+ isRead: boolean;
1066
+ isPinned: boolean;
1067
+ createdAt: number;
1068
+ }
1069
+
1070
+ /**
1071
+ * Request to create a new activity
1072
+ */
1073
+ export interface CreateActivityRequest {
1074
+ workspaceId: string;
1075
+ taskId?: string;
1076
+ agentRoleId?: string;
1077
+ actorType: ActivityActorType;
1078
+ activityType: ActivityType;
1079
+ title: string;
1080
+ description?: string;
1081
+ metadata?: Record<string, unknown>;
1082
+ }
1083
+
1084
+ /**
1085
+ * Activity list query parameters
1086
+ */
1087
+ export interface ActivityListQuery {
1088
+ workspaceId: string;
1089
+ taskId?: string;
1090
+ agentRoleId?: string;
1091
+ activityType?: ActivityType | ActivityType[];
1092
+ actorType?: ActivityActorType;
1093
+ isRead?: boolean;
1094
+ isPinned?: boolean;
1095
+ limit?: number;
1096
+ offset?: number;
1097
+ }
1098
+
1099
+ // ============ @Mention System Types ============
1100
+
1101
+ /**
1102
+ * Type of mention/request between agents
1103
+ */
1104
+ export type MentionType = 'request' | 'handoff' | 'review' | 'fyi';
1105
+
1106
+ /**
1107
+ * Status of a mention
1108
+ */
1109
+ export type MentionStatus = 'pending' | 'acknowledged' | 'completed' | 'dismissed';
1110
+
1111
+ /**
1112
+ * An @mention from one agent to another
1113
+ */
1114
+ export interface AgentMention {
1115
+ id: string;
1116
+ workspaceId: string;
1117
+ taskId: string;
1118
+ fromAgentRoleId?: string;
1119
+ toAgentRoleId: string;
1120
+ mentionType: MentionType;
1121
+ context?: string;
1122
+ status: MentionStatus;
1123
+ createdAt: number;
1124
+ acknowledgedAt?: number;
1125
+ completedAt?: number;
1126
+ }
1127
+
1128
+ /**
1129
+ * Request to create a new mention
1130
+ */
1131
+ export interface CreateMentionRequest {
1132
+ workspaceId: string;
1133
+ taskId: string;
1134
+ fromAgentRoleId?: string;
1135
+ toAgentRoleId: string;
1136
+ mentionType: MentionType;
1137
+ context?: string;
1138
+ }
1139
+
1140
+ /**
1141
+ * Query parameters for listing mentions
1142
+ */
1143
+ export interface MentionListQuery {
1144
+ workspaceId?: string;
1145
+ taskId?: string;
1146
+ toAgentRoleId?: string;
1147
+ fromAgentRoleId?: string;
1148
+ status?: MentionStatus | MentionStatus[];
1149
+ limit?: number;
1150
+ offset?: number;
1151
+ }
1152
+
1153
+ // IPC Channel names
1154
+ export const IPC_CHANNELS = {
1155
+ // Task operations
1156
+ TASK_CREATE: 'task:create',
1157
+ TASK_GET: 'task:get',
1158
+ TASK_LIST: 'task:list',
1159
+ TASK_CANCEL: 'task:cancel',
1160
+ TASK_PAUSE: 'task:pause',
1161
+ TASK_RESUME: 'task:resume',
1162
+ TASK_RENAME: 'task:rename',
1163
+ TASK_DELETE: 'task:delete',
1164
+
1165
+ // Sub-Agent / Parallel Agent operations
1166
+ AGENT_GET_CHILDREN: 'agent:getChildren', // Get child tasks for a parent
1167
+ AGENT_GET_STATUS: 'agent:getStatus', // Get status of spawned agents
1168
+
1169
+ // Agent Role / Squad operations
1170
+ AGENT_ROLE_LIST: 'agentRole:list',
1171
+ AGENT_ROLE_GET: 'agentRole:get',
1172
+ AGENT_ROLE_CREATE: 'agentRole:create',
1173
+ AGENT_ROLE_UPDATE: 'agentRole:update',
1174
+ AGENT_ROLE_DELETE: 'agentRole:delete',
1175
+ AGENT_ROLE_ASSIGN_TO_TASK: 'agentRole:assignToTask',
1176
+ AGENT_ROLE_GET_DEFAULTS: 'agentRole:getDefaults',
1177
+ AGENT_ROLE_SEED_DEFAULTS: 'agentRole:seedDefaults',
1178
+ AGENT_ROLE_SYNC_DEFAULTS: 'agentRole:syncDefaults',
1179
+
1180
+ // Activity Feed
1181
+ ACTIVITY_LIST: 'activity:list',
1182
+ ACTIVITY_CREATE: 'activity:create',
1183
+ ACTIVITY_MARK_READ: 'activity:markRead',
1184
+ ACTIVITY_MARK_ALL_READ: 'activity:markAllRead',
1185
+ ACTIVITY_PIN: 'activity:pin',
1186
+ ACTIVITY_DELETE: 'activity:delete',
1187
+ ACTIVITY_EVENT: 'activity:event',
1188
+
1189
+ // @Mention System
1190
+ MENTION_CREATE: 'mention:create',
1191
+ MENTION_LIST: 'mention:list',
1192
+ MENTION_ACKNOWLEDGE: 'mention:acknowledge',
1193
+ MENTION_COMPLETE: 'mention:complete',
1194
+ MENTION_DISMISS: 'mention:dismiss',
1195
+ MENTION_EVENT: 'mention:event',
1196
+
1197
+ // Mission Control - Heartbeat System
1198
+ HEARTBEAT_GET_CONFIG: 'heartbeat:getConfig',
1199
+ HEARTBEAT_UPDATE_CONFIG: 'heartbeat:updateConfig',
1200
+ HEARTBEAT_TRIGGER: 'heartbeat:trigger',
1201
+ HEARTBEAT_GET_STATUS: 'heartbeat:getStatus',
1202
+ HEARTBEAT_GET_ALL_STATUS: 'heartbeat:getAllStatus',
1203
+ HEARTBEAT_EVENT: 'heartbeat:event',
1204
+
1205
+ // Mission Control - Task Subscriptions
1206
+ SUBSCRIPTION_LIST: 'subscription:list',
1207
+ SUBSCRIPTION_ADD: 'subscription:add',
1208
+ SUBSCRIPTION_REMOVE: 'subscription:remove',
1209
+ SUBSCRIPTION_GET_SUBSCRIBERS: 'subscription:getSubscribers',
1210
+ SUBSCRIPTION_GET_FOR_AGENT: 'subscription:getForAgent',
1211
+ SUBSCRIPTION_EVENT: 'subscription:event',
1212
+
1213
+ // Mission Control - Standup Reports
1214
+ STANDUP_GENERATE: 'standup:generate',
1215
+ STANDUP_GET_LATEST: 'standup:getLatest',
1216
+ STANDUP_LIST: 'standup:list',
1217
+ STANDUP_DELIVER: 'standup:deliver',
1218
+
1219
+ // Task Board (Kanban)
1220
+ TASK_MOVE_COLUMN: 'task:moveColumn',
1221
+ TASK_SET_PRIORITY: 'task:setPriority',
1222
+ TASK_SET_DUE_DATE: 'task:setDueDate',
1223
+ TASK_SET_ESTIMATE: 'task:setEstimate',
1224
+ TASK_ADD_LABEL: 'task:addLabel',
1225
+ TASK_REMOVE_LABEL: 'task:removeLabel',
1226
+ TASK_BOARD_EVENT: 'taskBoard:event',
1227
+
1228
+ // Task Labels
1229
+ TASK_LABEL_LIST: 'taskLabel:list',
1230
+ TASK_LABEL_CREATE: 'taskLabel:create',
1231
+ TASK_LABEL_UPDATE: 'taskLabel:update',
1232
+ TASK_LABEL_DELETE: 'taskLabel:delete',
1233
+
1234
+ // Agent Working State
1235
+ WORKING_STATE_GET: 'workingState:get',
1236
+ WORKING_STATE_GET_CURRENT: 'workingState:getCurrent',
1237
+ WORKING_STATE_UPDATE: 'workingState:update',
1238
+ WORKING_STATE_HISTORY: 'workingState:history',
1239
+ WORKING_STATE_RESTORE: 'workingState:restore',
1240
+ WORKING_STATE_DELETE: 'workingState:delete',
1241
+ WORKING_STATE_LIST_FOR_TASK: 'workingState:listForTask',
1242
+
1243
+ // Context Policy (per-context security DM vs group)
1244
+ CONTEXT_POLICY_GET: 'contextPolicy:get',
1245
+ CONTEXT_POLICY_GET_FOR_CHAT: 'contextPolicy:getForChat',
1246
+ CONTEXT_POLICY_LIST: 'contextPolicy:list',
1247
+ CONTEXT_POLICY_UPDATE: 'contextPolicy:update',
1248
+ CONTEXT_POLICY_DELETE: 'contextPolicy:delete',
1249
+ CONTEXT_POLICY_CREATE_DEFAULTS: 'contextPolicy:createDefaults',
1250
+ CONTEXT_POLICY_IS_TOOL_ALLOWED: 'contextPolicy:isToolAllowed',
1251
+
1252
+ // Task events (streaming and history)
1253
+ TASK_EVENT: 'task:event',
1254
+ TASK_EVENTS: 'task:events',
1255
+ TASK_SEND_MESSAGE: 'task:sendMessage',
1256
+ TASK_SEND_STDIN: 'task:sendStdin', // Send stdin input to running command
1257
+ TASK_KILL_COMMAND: 'task:killCommand', // Kill running command (Ctrl+C)
1258
+
1259
+ // Workspace operations
1260
+ WORKSPACE_SELECT: 'workspace:select',
1261
+ WORKSPACE_LIST: 'workspace:list',
1262
+ WORKSPACE_CREATE: 'workspace:create',
1263
+ WORKSPACE_UPDATE_PERMISSIONS: 'workspace:updatePermissions',
1264
+ WORKSPACE_GET_TEMP: 'workspace:getTemp', // Get or create temp workspace
1265
+
1266
+ // Approval operations
1267
+ APPROVAL_RESPOND: 'approval:respond',
1268
+
1269
+ // Artifact operations
1270
+ ARTIFACT_LIST: 'artifact:list',
1271
+ ARTIFACT_PREVIEW: 'artifact:preview',
1272
+
1273
+ // Skills
1274
+ SKILL_LIST: 'skill:list',
1275
+ SKILL_GET: 'skill:get',
1276
+
1277
+ // Custom User Skills
1278
+ CUSTOM_SKILL_LIST: 'customSkill:list',
1279
+ CUSTOM_SKILL_LIST_TASKS: 'customSkill:listTasks', // List only task skills (for dropdown)
1280
+ CUSTOM_SKILL_LIST_GUIDELINES: 'customSkill:listGuidelines', // List only guideline skills (for settings)
1281
+ CUSTOM_SKILL_GET: 'customSkill:get',
1282
+ CUSTOM_SKILL_CREATE: 'customSkill:create',
1283
+ CUSTOM_SKILL_UPDATE: 'customSkill:update',
1284
+ CUSTOM_SKILL_DELETE: 'customSkill:delete',
1285
+ CUSTOM_SKILL_RELOAD: 'customSkill:reload',
1286
+ CUSTOM_SKILL_OPEN_FOLDER: 'customSkill:openFolder',
1287
+
1288
+ // Skill Registry (SkillHub)
1289
+ SKILL_REGISTRY_SEARCH: 'skillRegistry:search',
1290
+ SKILL_REGISTRY_GET_DETAILS: 'skillRegistry:getDetails',
1291
+ SKILL_REGISTRY_INSTALL: 'skillRegistry:install',
1292
+ SKILL_REGISTRY_UPDATE: 'skillRegistry:update',
1293
+ SKILL_REGISTRY_UPDATE_ALL: 'skillRegistry:updateAll',
1294
+ SKILL_REGISTRY_UNINSTALL: 'skillRegistry:uninstall',
1295
+ SKILL_REGISTRY_LIST_MANAGED: 'skillRegistry:listManaged',
1296
+ SKILL_REGISTRY_CHECK_UPDATES: 'skillRegistry:checkUpdates',
1297
+ SKILL_REGISTRY_GET_STATUS: 'skillRegistry:getStatus',
1298
+ SKILL_REGISTRY_GET_ELIGIBLE: 'skillRegistry:getEligible',
1299
+
1300
+ // LLM Settings
1301
+ LLM_GET_SETTINGS: 'llm:getSettings',
1302
+ LLM_SAVE_SETTINGS: 'llm:saveSettings',
1303
+ LLM_TEST_PROVIDER: 'llm:testProvider',
1304
+ LLM_GET_MODELS: 'llm:getModels',
1305
+ LLM_GET_CONFIG_STATUS: 'llm:getConfigStatus',
1306
+ LLM_SET_MODEL: 'llm:setModel',
1307
+ LLM_GET_OLLAMA_MODELS: 'llm:getOllamaModels',
1308
+ LLM_GET_GEMINI_MODELS: 'llm:getGeminiModels',
1309
+ LLM_GET_OPENROUTER_MODELS: 'llm:getOpenRouterModels',
1310
+ LLM_GET_OPENAI_MODELS: 'llm:getOpenAIModels',
1311
+ LLM_OPENAI_OAUTH_START: 'llm:openaiOAuthStart',
1312
+ LLM_OPENAI_OAUTH_LOGOUT: 'llm:openaiOAuthLogout',
1313
+ LLM_GET_BEDROCK_MODELS: 'llm:getBedrockModels',
1314
+
1315
+ // Gateway / Channels
1316
+ GATEWAY_GET_CHANNELS: 'gateway:getChannels',
1317
+ GATEWAY_ADD_CHANNEL: 'gateway:addChannel',
1318
+ GATEWAY_UPDATE_CHANNEL: 'gateway:updateChannel',
1319
+ GATEWAY_REMOVE_CHANNEL: 'gateway:removeChannel',
1320
+ GATEWAY_ENABLE_CHANNEL: 'gateway:enableChannel',
1321
+ GATEWAY_DISABLE_CHANNEL: 'gateway:disableChannel',
1322
+ GATEWAY_TEST_CHANNEL: 'gateway:testChannel',
1323
+ GATEWAY_GET_USERS: 'gateway:getUsers',
1324
+ GATEWAY_GRANT_ACCESS: 'gateway:grantAccess',
1325
+ GATEWAY_REVOKE_ACCESS: 'gateway:revokeAccess',
1326
+ GATEWAY_GENERATE_PAIRING: 'gateway:generatePairing',
1327
+
1328
+ // Search Settings
1329
+ SEARCH_GET_SETTINGS: 'search:getSettings',
1330
+ SEARCH_SAVE_SETTINGS: 'search:saveSettings',
1331
+ SEARCH_GET_CONFIG_STATUS: 'search:getConfigStatus',
1332
+ SEARCH_TEST_PROVIDER: 'search:testProvider',
1333
+
1334
+ // X/Twitter Settings
1335
+ X_GET_SETTINGS: 'x:getSettings',
1336
+ X_SAVE_SETTINGS: 'x:saveSettings',
1337
+ X_TEST_CONNECTION: 'x:testConnection',
1338
+ X_GET_STATUS: 'x:getStatus',
1339
+
1340
+ // App Updates
1341
+ APP_CHECK_UPDATES: 'app:checkUpdates',
1342
+ APP_DOWNLOAD_UPDATE: 'app:downloadUpdate',
1343
+ APP_INSTALL_UPDATE: 'app:installUpdate',
1344
+ APP_GET_VERSION: 'app:getVersion',
1345
+ APP_UPDATE_AVAILABLE: 'app:updateAvailable',
1346
+ APP_UPDATE_PROGRESS: 'app:updateProgress',
1347
+ APP_UPDATE_DOWNLOADED: 'app:updateDownloaded',
1348
+ APP_UPDATE_ERROR: 'app:updateError',
1349
+
1350
+ // Guardrails
1351
+ GUARDRAIL_GET_SETTINGS: 'guardrail:getSettings',
1352
+ GUARDRAIL_SAVE_SETTINGS: 'guardrail:saveSettings',
1353
+ GUARDRAIL_GET_DEFAULTS: 'guardrail:getDefaults',
1354
+
1355
+ // Appearance
1356
+ APPEARANCE_GET_SETTINGS: 'appearance:getSettings',
1357
+ APPEARANCE_SAVE_SETTINGS: 'appearance:saveSettings',
1358
+
1359
+ // Agent Personality
1360
+ PERSONALITY_GET_SETTINGS: 'personality:getSettings',
1361
+ PERSONALITY_SAVE_SETTINGS: 'personality:saveSettings',
1362
+ PERSONALITY_GET_DEFINITIONS: 'personality:getDefinitions',
1363
+ PERSONALITY_GET_PERSONAS: 'personality:getPersonas',
1364
+ PERSONALITY_GET_RELATIONSHIP_STATS: 'personality:getRelationshipStats',
1365
+ PERSONALITY_SET_ACTIVE: 'personality:setActive',
1366
+ PERSONALITY_SET_PERSONA: 'personality:setPersona',
1367
+ PERSONALITY_RESET: 'personality:reset',
1368
+ PERSONALITY_SETTINGS_CHANGED: 'personality:settingsChanged', // Event sent to UI when settings change
1369
+
1370
+ // Task Queue
1371
+ QUEUE_GET_STATUS: 'queue:getStatus',
1372
+ QUEUE_GET_SETTINGS: 'queue:getSettings',
1373
+ QUEUE_SAVE_SETTINGS: 'queue:saveSettings',
1374
+ QUEUE_CLEAR: 'queue:clear',
1375
+ QUEUE_UPDATE: 'queue:update',
1376
+
1377
+ // MCP (Model Context Protocol)
1378
+ MCP_GET_SETTINGS: 'mcp:getSettings',
1379
+ MCP_SAVE_SETTINGS: 'mcp:saveSettings',
1380
+ MCP_GET_SERVERS: 'mcp:getServers',
1381
+ MCP_ADD_SERVER: 'mcp:addServer',
1382
+ MCP_UPDATE_SERVER: 'mcp:updateServer',
1383
+ MCP_REMOVE_SERVER: 'mcp:removeServer',
1384
+ MCP_CONNECT_SERVER: 'mcp:connectServer',
1385
+ MCP_DISCONNECT_SERVER: 'mcp:disconnectServer',
1386
+ MCP_GET_STATUS: 'mcp:getStatus',
1387
+ MCP_GET_SERVER_TOOLS: 'mcp:getServerTools',
1388
+ MCP_TEST_SERVER: 'mcp:testServer',
1389
+
1390
+ // MCP Registry
1391
+ MCP_REGISTRY_FETCH: 'mcp:registryFetch',
1392
+ MCP_REGISTRY_SEARCH: 'mcp:registrySearch',
1393
+ MCP_REGISTRY_INSTALL: 'mcp:registryInstall',
1394
+ MCP_REGISTRY_UNINSTALL: 'mcp:registryUninstall',
1395
+ MCP_REGISTRY_CHECK_UPDATES: 'mcp:registryCheckUpdates',
1396
+ MCP_REGISTRY_UPDATE_SERVER: 'mcp:registryUpdateServer',
1397
+
1398
+ // MCP Host
1399
+ MCP_HOST_START: 'mcp:hostStart',
1400
+ MCP_HOST_STOP: 'mcp:hostStop',
1401
+ MCP_HOST_GET_STATUS: 'mcp:hostGetStatus',
1402
+
1403
+ // MCP Events
1404
+ MCP_SERVER_STATUS_CHANGE: 'mcp:serverStatusChange',
1405
+
1406
+ // Built-in Tools Settings
1407
+ BUILTIN_TOOLS_GET_SETTINGS: 'builtinTools:getSettings',
1408
+ BUILTIN_TOOLS_SAVE_SETTINGS: 'builtinTools:saveSettings',
1409
+ BUILTIN_TOOLS_GET_CATEGORIES: 'builtinTools:getCategories',
1410
+
1411
+ // Tray (Menu Bar)
1412
+ TRAY_GET_SETTINGS: 'tray:getSettings',
1413
+ TRAY_SAVE_SETTINGS: 'tray:saveSettings',
1414
+ TRAY_NEW_TASK: 'tray:newTask',
1415
+ TRAY_SELECT_WORKSPACE: 'tray:selectWorkspace',
1416
+ TRAY_OPEN_SETTINGS: 'tray:openSettings',
1417
+ TRAY_OPEN_ABOUT: 'tray:openAbout',
1418
+ TRAY_CHECK_UPDATES: 'tray:checkUpdates',
1419
+
1420
+ // Cron (Scheduled Tasks)
1421
+ CRON_GET_STATUS: 'cron:getStatus',
1422
+ CRON_LIST_JOBS: 'cron:listJobs',
1423
+ CRON_GET_JOB: 'cron:getJob',
1424
+ CRON_ADD_JOB: 'cron:addJob',
1425
+ CRON_UPDATE_JOB: 'cron:updateJob',
1426
+ CRON_REMOVE_JOB: 'cron:removeJob',
1427
+ CRON_RUN_JOB: 'cron:runJob',
1428
+ CRON_EVENT: 'cron:event',
1429
+
1430
+ // Notifications
1431
+ NOTIFICATION_LIST: 'notification:list',
1432
+ NOTIFICATION_ADD: 'notification:add',
1433
+ NOTIFICATION_MARK_READ: 'notification:markRead',
1434
+ NOTIFICATION_MARK_ALL_READ: 'notification:markAllRead',
1435
+ NOTIFICATION_DELETE: 'notification:delete',
1436
+ NOTIFICATION_DELETE_ALL: 'notification:deleteAll',
1437
+ NOTIFICATION_EVENT: 'notification:event',
1438
+
1439
+ // Hooks (Webhooks & Gmail Pub/Sub)
1440
+ HOOKS_GET_SETTINGS: 'hooks:getSettings',
1441
+ HOOKS_SAVE_SETTINGS: 'hooks:saveSettings',
1442
+ HOOKS_ENABLE: 'hooks:enable',
1443
+ HOOKS_DISABLE: 'hooks:disable',
1444
+ HOOKS_REGENERATE_TOKEN: 'hooks:regenerateToken',
1445
+ HOOKS_GET_STATUS: 'hooks:getStatus',
1446
+ HOOKS_ADD_MAPPING: 'hooks:addMapping',
1447
+ HOOKS_REMOVE_MAPPING: 'hooks:removeMapping',
1448
+ HOOKS_CONFIGURE_GMAIL: 'hooks:configureGmail',
1449
+ HOOKS_GET_GMAIL_STATUS: 'hooks:getGmailStatus',
1450
+ HOOKS_START_GMAIL_WATCHER: 'hooks:startGmailWatcher',
1451
+ HOOKS_STOP_GMAIL_WATCHER: 'hooks:stopGmailWatcher',
1452
+ HOOKS_EVENT: 'hooks:event',
1453
+
1454
+ // Control Plane (WebSocket Gateway)
1455
+ CONTROL_PLANE_GET_SETTINGS: 'controlPlane:getSettings',
1456
+ CONTROL_PLANE_SAVE_SETTINGS: 'controlPlane:saveSettings',
1457
+ CONTROL_PLANE_ENABLE: 'controlPlane:enable',
1458
+ CONTROL_PLANE_DISABLE: 'controlPlane:disable',
1459
+ CONTROL_PLANE_START: 'controlPlane:start',
1460
+ CONTROL_PLANE_STOP: 'controlPlane:stop',
1461
+ CONTROL_PLANE_GET_STATUS: 'controlPlane:getStatus',
1462
+ CONTROL_PLANE_REGENERATE_TOKEN: 'controlPlane:regenerateToken',
1463
+ CONTROL_PLANE_EVENT: 'controlPlane:event',
1464
+
1465
+ // Tailscale Integration
1466
+ TAILSCALE_GET_STATUS: 'tailscale:getStatus',
1467
+ TAILSCALE_CHECK_AVAILABILITY: 'tailscale:checkAvailability',
1468
+ TAILSCALE_SET_MODE: 'tailscale:setMode',
1469
+
1470
+ // Remote Gateway (connecting to external Control Plane)
1471
+ REMOTE_GATEWAY_CONNECT: 'remoteGateway:connect',
1472
+ REMOTE_GATEWAY_DISCONNECT: 'remoteGateway:disconnect',
1473
+ REMOTE_GATEWAY_GET_STATUS: 'remoteGateway:getStatus',
1474
+ REMOTE_GATEWAY_SAVE_CONFIG: 'remoteGateway:saveConfig',
1475
+ REMOTE_GATEWAY_TEST_CONNECTION: 'remoteGateway:testConnection',
1476
+ REMOTE_GATEWAY_EVENT: 'remoteGateway:event',
1477
+
1478
+ // SSH Tunnel (for Remote Gateway connection)
1479
+ SSH_TUNNEL_CONNECT: 'sshTunnel:connect',
1480
+ SSH_TUNNEL_DISCONNECT: 'sshTunnel:disconnect',
1481
+ SSH_TUNNEL_GET_STATUS: 'sshTunnel:getStatus',
1482
+ SSH_TUNNEL_SAVE_CONFIG: 'sshTunnel:saveConfig',
1483
+ SSH_TUNNEL_TEST_CONNECTION: 'sshTunnel:testConnection',
1484
+ SSH_TUNNEL_EVENT: 'sshTunnel:event',
1485
+
1486
+ // Live Canvas (Agent-driven visual workspace)
1487
+ CANVAS_CREATE: 'canvas:create',
1488
+ CANVAS_GET_SESSION: 'canvas:getSession',
1489
+ CANVAS_LIST_SESSIONS: 'canvas:listSessions',
1490
+ CANVAS_SHOW: 'canvas:show',
1491
+ CANVAS_HIDE: 'canvas:hide',
1492
+ CANVAS_CLOSE: 'canvas:close',
1493
+ CANVAS_PUSH: 'canvas:push',
1494
+ CANVAS_EVAL: 'canvas:eval',
1495
+ CANVAS_SNAPSHOT: 'canvas:snapshot',
1496
+ CANVAS_A2UI_ACTION: 'canvas:a2uiAction',
1497
+ CANVAS_EVENT: 'canvas:event',
1498
+ CANVAS_EXPORT_HTML: 'canvas:exportHTML',
1499
+ CANVAS_EXPORT_TO_FOLDER: 'canvas:exportToFolder',
1500
+ CANVAS_OPEN_IN_BROWSER: 'canvas:openInBrowser',
1501
+ CANVAS_GET_SESSION_DIR: 'canvas:getSessionDir',
1502
+
1503
+ // Mobile Companion Nodes
1504
+ NODE_LIST: 'node:list',
1505
+ NODE_GET: 'node:get',
1506
+ NODE_INVOKE: 'node:invoke',
1507
+ NODE_EVENT: 'node:event',
1508
+
1509
+ // Memory System (Cross-Session Context)
1510
+ MEMORY_GET_SETTINGS: 'memory:getSettings',
1511
+ MEMORY_SAVE_SETTINGS: 'memory:saveSettings',
1512
+ MEMORY_SEARCH: 'memory:search',
1513
+ MEMORY_GET_TIMELINE: 'memory:getTimeline',
1514
+ MEMORY_GET_DETAILS: 'memory:getDetails',
1515
+ MEMORY_GET_RECENT: 'memory:getRecent',
1516
+ MEMORY_GET_STATS: 'memory:getStats',
1517
+ MEMORY_CLEAR: 'memory:clear',
1518
+ MEMORY_EVENT: 'memory:event',
1519
+
1520
+ // Migration Status (for showing one-time notifications after app rename)
1521
+ MIGRATION_GET_STATUS: 'migration:getStatus',
1522
+ MIGRATION_DISMISS_NOTIFICATION: 'migration:dismissNotification',
1523
+
1524
+ // Extensions / Plugins
1525
+ EXTENSIONS_LIST: 'extensions:list',
1526
+ EXTENSIONS_GET: 'extensions:get',
1527
+ EXTENSIONS_ENABLE: 'extensions:enable',
1528
+ EXTENSIONS_DISABLE: 'extensions:disable',
1529
+ EXTENSIONS_RELOAD: 'extensions:reload',
1530
+ EXTENSIONS_GET_CONFIG: 'extensions:getConfig',
1531
+ EXTENSIONS_SET_CONFIG: 'extensions:setConfig',
1532
+ EXTENSIONS_DISCOVER: 'extensions:discover',
1533
+
1534
+ // Webhook Tunnel
1535
+ TUNNEL_GET_STATUS: 'tunnel:getStatus',
1536
+ TUNNEL_START: 'tunnel:start',
1537
+ TUNNEL_STOP: 'tunnel:stop',
1538
+ TUNNEL_GET_CONFIG: 'tunnel:getConfig',
1539
+ TUNNEL_SET_CONFIG: 'tunnel:setConfig',
1540
+
1541
+ // Voice Mode (TTS/STT)
1542
+ VOICE_GET_SETTINGS: 'voice:getSettings',
1543
+ VOICE_SAVE_SETTINGS: 'voice:saveSettings',
1544
+ VOICE_GET_STATE: 'voice:getState',
1545
+ VOICE_SPEAK: 'voice:speak',
1546
+ VOICE_STOP_SPEAKING: 'voice:stopSpeaking',
1547
+ VOICE_TRANSCRIBE: 'voice:transcribe',
1548
+ VOICE_GET_ELEVENLABS_VOICES: 'voice:getElevenLabsVoices',
1549
+ VOICE_TEST_ELEVENLABS: 'voice:testElevenLabs',
1550
+ VOICE_TEST_OPENAI: 'voice:testOpenAI',
1551
+ VOICE_TEST_AZURE: 'voice:testAzure',
1552
+ VOICE_EVENT: 'voice:event',
1553
+ } as const;
1554
+
1555
+ // LLM Provider types
1556
+ export type LLMProviderType = 'anthropic' | 'bedrock' | 'ollama' | 'gemini' | 'openrouter' | 'openai';
1557
+
1558
+ export interface CachedModelInfo {
1559
+ key: string;
1560
+ displayName: string;
1561
+ description: string;
1562
+ contextLength?: number; // For OpenRouter models
1563
+ size?: number; // For Ollama models (in bytes)
1564
+ }
1565
+
1566
+ export interface LLMSettingsData {
1567
+ providerType: LLMProviderType;
1568
+ modelKey: string;
1569
+ anthropic?: {
1570
+ apiKey?: string;
1571
+ };
1572
+ bedrock?: {
1573
+ region?: string;
1574
+ accessKeyId?: string;
1575
+ secretAccessKey?: string;
1576
+ sessionToken?: string;
1577
+ profile?: string;
1578
+ useDefaultCredentials?: boolean;
1579
+ model?: string;
1580
+ };
1581
+ ollama?: {
1582
+ baseUrl?: string;
1583
+ model?: string;
1584
+ apiKey?: string; // Optional, for remote Ollama servers
1585
+ };
1586
+ gemini?: {
1587
+ apiKey?: string;
1588
+ model?: string;
1589
+ };
1590
+ openrouter?: {
1591
+ apiKey?: string;
1592
+ model?: string;
1593
+ };
1594
+ openai?: {
1595
+ apiKey?: string;
1596
+ model?: string;
1597
+ // OAuth tokens (alternative to API key)
1598
+ accessToken?: string;
1599
+ refreshToken?: string;
1600
+ tokenExpiresAt?: number;
1601
+ authMethod?: 'api_key' | 'oauth';
1602
+ };
1603
+ // Cached models from API (populated when user refreshes)
1604
+ cachedGeminiModels?: CachedModelInfo[];
1605
+ cachedOpenRouterModels?: CachedModelInfo[];
1606
+ cachedOllamaModels?: CachedModelInfo[];
1607
+ cachedBedrockModels?: CachedModelInfo[];
1608
+ cachedOpenAIModels?: CachedModelInfo[];
1609
+ }
1610
+
1611
+ export interface LLMProviderInfo {
1612
+ type: LLMProviderType;
1613
+ name: string;
1614
+ configured: boolean;
1615
+ }
1616
+
1617
+ export interface LLMModelInfo {
1618
+ key: string;
1619
+ displayName: string;
1620
+ description: string;
1621
+ }
1622
+
1623
+ export interface LLMConfigStatus {
1624
+ currentProvider: LLMProviderType;
1625
+ currentModel: string;
1626
+ providers: LLMProviderInfo[];
1627
+ models: LLMModelInfo[];
1628
+ }
1629
+
1630
+ // Gateway / Channel types
1631
+ export type ChannelType = 'telegram' | 'discord' | 'slack' | 'whatsapp' | 'imessage' | 'signal' | 'mattermost' | 'matrix' | 'twitch' | 'line' | 'bluebubbles' | 'email' | 'teams' | 'googlechat';
1632
+ export type ChannelStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
1633
+ export type SecurityMode = 'open' | 'allowlist' | 'pairing';
1634
+
1635
+ /**
1636
+ * Context type for channel messages (DM vs group chat)
1637
+ */
1638
+ export type ContextType = 'dm' | 'group';
1639
+
1640
+ /**
1641
+ * Per-context security policy
1642
+ * Allows different security modes for DMs vs group chats
1643
+ */
1644
+ export interface ContextPolicy {
1645
+ id: string;
1646
+ channelId: string;
1647
+ contextType: ContextType;
1648
+ securityMode: SecurityMode;
1649
+ /** Tool groups to deny in this context (e.g., 'group:memory') */
1650
+ toolRestrictions?: string[];
1651
+ createdAt: number;
1652
+ updatedAt: number;
1653
+ }
1654
+
1655
+ /**
1656
+ * Channel security configuration with per-context policies
1657
+ */
1658
+ export interface ChannelSecurityConfig {
1659
+ /** Default security mode (applies if no context policy exists) */
1660
+ mode: SecurityMode;
1661
+ /** Allowed users for allowlist mode */
1662
+ allowedUsers?: string[];
1663
+ /** Pairing code TTL in seconds */
1664
+ pairingCodeTTL?: number;
1665
+ /** Max pairing attempts before lockout */
1666
+ maxPairingAttempts?: number;
1667
+ /** Rate limit for messages per minute */
1668
+ rateLimitPerMinute?: number;
1669
+ /** Per-context security policies */
1670
+ contextPolicies?: {
1671
+ dm?: Partial<ContextPolicy>;
1672
+ group?: Partial<ContextPolicy>;
1673
+ };
1674
+ }
1675
+
1676
+ export interface ChannelData {
1677
+ id: string;
1678
+ type: ChannelType;
1679
+ name: string;
1680
+ enabled: boolean;
1681
+ status: ChannelStatus;
1682
+ botUsername?: string;
1683
+ securityMode: SecurityMode;
1684
+ createdAt: number;
1685
+ config?: {
1686
+ selfChatMode?: boolean;
1687
+ responsePrefix?: string;
1688
+ [key: string]: unknown;
1689
+ };
1690
+ }
1691
+
1692
+ export interface ChannelUserData {
1693
+ id: string;
1694
+ channelId: string;
1695
+ channelUserId: string;
1696
+ displayName: string;
1697
+ username?: string;
1698
+ allowed: boolean;
1699
+ lastSeenAt: number;
1700
+ }
1701
+
1702
+ export interface AddChannelRequest {
1703
+ type: ChannelType;
1704
+ name: string;
1705
+ botToken?: string;
1706
+ securityMode?: SecurityMode;
1707
+ // Discord-specific fields
1708
+ applicationId?: string;
1709
+ guildIds?: string[];
1710
+ // Slack-specific fields
1711
+ appToken?: string;
1712
+ signingSecret?: string;
1713
+ // WhatsApp-specific fields
1714
+ allowedNumbers?: string[];
1715
+ selfChatMode?: boolean;
1716
+ responsePrefix?: string;
1717
+ // iMessage-specific fields
1718
+ cliPath?: string;
1719
+ dbPath?: string;
1720
+ dmPolicy?: 'open' | 'allowlist' | 'pairing' | 'disabled';
1721
+ groupPolicy?: 'open' | 'allowlist' | 'disabled';
1722
+ allowedContacts?: string[];
1723
+ // Signal-specific fields
1724
+ phoneNumber?: string;
1725
+ dataDir?: string;
1726
+ mode?: 'native' | 'json-rpc' | 'dbus';
1727
+ trustMode?: 'always' | 'on-first-use' | 'never';
1728
+ sendReadReceipts?: boolean;
1729
+ sendTypingIndicators?: boolean;
1730
+ // Mattermost-specific fields
1731
+ mattermostServerUrl?: string;
1732
+ mattermostToken?: string;
1733
+ mattermostTeamId?: string;
1734
+ // Matrix-specific fields
1735
+ matrixHomeserver?: string;
1736
+ matrixUserId?: string;
1737
+ matrixAccessToken?: string;
1738
+ matrixDeviceId?: string;
1739
+ matrixRoomIds?: string[];
1740
+ // Twitch-specific fields
1741
+ twitchUsername?: string;
1742
+ twitchOauthToken?: string;
1743
+ twitchChannels?: string[];
1744
+ twitchAllowWhispers?: boolean;
1745
+ // LINE-specific fields
1746
+ lineChannelAccessToken?: string;
1747
+ lineChannelSecret?: string;
1748
+ lineWebhookPort?: number;
1749
+ lineWebhookPath?: string;
1750
+ // BlueBubbles-specific fields
1751
+ blueBubblesServerUrl?: string;
1752
+ blueBubblesPassword?: string;
1753
+ blueBubblesWebhookPort?: number;
1754
+ blueBubblesAllowedContacts?: string[];
1755
+ // Email-specific fields
1756
+ emailAddress?: string;
1757
+ emailPassword?: string;
1758
+ emailImapHost?: string;
1759
+ emailImapPort?: number;
1760
+ emailSmtpHost?: string;
1761
+ emailSmtpPort?: number;
1762
+ emailDisplayName?: string;
1763
+ emailAllowedSenders?: string[];
1764
+ emailSubjectFilter?: string;
1765
+ // Teams-specific fields
1766
+ appId?: string;
1767
+ appPassword?: string;
1768
+ tenantId?: string;
1769
+ webhookPort?: number;
1770
+ // Google Chat-specific fields
1771
+ serviceAccountKeyPath?: string;
1772
+ projectId?: string;
1773
+ webhookPath?: string;
1774
+ }
1775
+
1776
+ export interface UpdateChannelRequest {
1777
+ id: string;
1778
+ name?: string;
1779
+ securityMode?: SecurityMode;
1780
+ config?: {
1781
+ selfChatMode?: boolean;
1782
+ responsePrefix?: string;
1783
+ [key: string]: unknown;
1784
+ };
1785
+ }
1786
+
1787
+ export interface TestChannelResult {
1788
+ success: boolean;
1789
+ error?: string;
1790
+ botUsername?: string;
1791
+ }
1792
+
1793
+ // Extension / Plugin types
1794
+ export type ExtensionType = 'channel' | 'tool' | 'provider' | 'integration';
1795
+ export type ExtensionState = 'loading' | 'loaded' | 'registered' | 'active' | 'error' | 'disabled';
1796
+
1797
+ export interface ExtensionCapabilities {
1798
+ sendMessage?: boolean;
1799
+ receiveMessage?: boolean;
1800
+ attachments?: boolean;
1801
+ reactions?: boolean;
1802
+ inlineKeyboards?: boolean;
1803
+ groups?: boolean;
1804
+ threads?: boolean;
1805
+ webhooks?: boolean;
1806
+ e2eEncryption?: boolean;
1807
+ }
1808
+
1809
+ export interface ExtensionData {
1810
+ name: string;
1811
+ displayName: string;
1812
+ version: string;
1813
+ description: string;
1814
+ author?: string;
1815
+ type: ExtensionType;
1816
+ state: ExtensionState;
1817
+ path: string;
1818
+ loadedAt: number;
1819
+ error?: string;
1820
+ capabilities?: ExtensionCapabilities;
1821
+ configSchema?: Record<string, unknown>;
1822
+ }
1823
+
1824
+ export interface ExtensionConfig {
1825
+ [key: string]: unknown;
1826
+ }
1827
+
1828
+ // Webhook Tunnel types
1829
+ export type TunnelProvider = 'ngrok' | 'tailscale' | 'cloudflare' | 'localtunnel';
1830
+ export type TunnelStatus = 'stopped' | 'starting' | 'running' | 'error';
1831
+
1832
+ export interface TunnelConfig {
1833
+ provider: TunnelProvider;
1834
+ port: number;
1835
+ host?: string;
1836
+ ngrokAuthToken?: string;
1837
+ ngrokRegion?: 'us' | 'eu' | 'ap' | 'au' | 'sa' | 'jp' | 'in';
1838
+ ngrokSubdomain?: string;
1839
+ tailscaleHostname?: string;
1840
+ cloudflareTunnelName?: string;
1841
+ autoStart?: boolean;
1842
+ }
1843
+
1844
+ export interface TunnelStatusData {
1845
+ status: TunnelStatus;
1846
+ provider?: TunnelProvider;
1847
+ url?: string;
1848
+ error?: string;
1849
+ startedAt?: number;
1850
+ }
1851
+
1852
+ // Search Provider types
1853
+ export type SearchProviderType = 'tavily' | 'brave' | 'serpapi' | 'google';
1854
+ export type SearchType = 'web' | 'news' | 'images';
1855
+
1856
+ export interface SearchSettingsData {
1857
+ primaryProvider: SearchProviderType | null;
1858
+ fallbackProvider: SearchProviderType | null;
1859
+ tavily?: {
1860
+ apiKey?: string;
1861
+ };
1862
+ brave?: {
1863
+ apiKey?: string;
1864
+ };
1865
+ serpapi?: {
1866
+ apiKey?: string;
1867
+ };
1868
+ google?: {
1869
+ apiKey?: string;
1870
+ searchEngineId?: string;
1871
+ };
1872
+ }
1873
+
1874
+ // X/Twitter integration settings
1875
+ export type XAuthMethod = 'browser' | 'manual';
1876
+
1877
+ export interface XSettingsData {
1878
+ enabled: boolean;
1879
+ authMethod: XAuthMethod;
1880
+ // Manual cookie auth
1881
+ authToken?: string;
1882
+ ct0?: string;
1883
+ // Browser cookie extraction
1884
+ cookieSource?: string[]; // e.g., ['chrome', 'arc', 'brave', 'firefox']
1885
+ chromeProfile?: string;
1886
+ chromeProfileDir?: string;
1887
+ firefoxProfile?: string;
1888
+ // Runtime options
1889
+ timeoutMs?: number;
1890
+ cookieTimeoutMs?: number;
1891
+ quoteDepth?: number;
1892
+ }
1893
+
1894
+ export interface XConnectionTestResult {
1895
+ success: boolean;
1896
+ error?: string;
1897
+ username?: string;
1898
+ userId?: string;
1899
+ }
1900
+
1901
+ export interface SearchProviderInfo {
1902
+ type: SearchProviderType;
1903
+ name: string;
1904
+ description: string;
1905
+ configured: boolean;
1906
+ supportedTypes: SearchType[];
1907
+ }
1908
+
1909
+ export interface SearchConfigStatus {
1910
+ primaryProvider: SearchProviderType | null;
1911
+ fallbackProvider: SearchProviderType | null;
1912
+ providers: SearchProviderInfo[];
1913
+ isConfigured: boolean;
1914
+ }
1915
+
1916
+ // Guardrail Settings types
1917
+ export interface GuardrailSettings {
1918
+ // Token Budget (per task)
1919
+ maxTokensPerTask: number;
1920
+ tokenBudgetEnabled: boolean;
1921
+
1922
+ // Cost Budget (per task, in USD)
1923
+ maxCostPerTask: number;
1924
+ costBudgetEnabled: boolean;
1925
+
1926
+ // Dangerous Command Blocking
1927
+ blockDangerousCommands: boolean;
1928
+ customBlockedPatterns: string[];
1929
+
1930
+ // Auto-Approve Trusted Commands
1931
+ autoApproveTrustedCommands: boolean;
1932
+ trustedCommandPatterns: string[];
1933
+
1934
+ // File Write Size Limit (in MB)
1935
+ maxFileSizeMB: number;
1936
+ fileSizeLimitEnabled: boolean;
1937
+
1938
+ // Network Domain Allowlist
1939
+ enforceAllowedDomains: boolean;
1940
+ allowedDomains: string[];
1941
+
1942
+ // Max Iterations Per Task
1943
+ maxIterationsPerTask: number;
1944
+ iterationLimitEnabled: boolean;
1945
+ }
1946
+
1947
+ // Default trusted command patterns (glob-like patterns)
1948
+ export const DEFAULT_TRUSTED_COMMAND_PATTERNS = [
1949
+ 'npm test*',
1950
+ 'npm run *',
1951
+ 'npm install*',
1952
+ 'npm ci',
1953
+ 'yarn test*',
1954
+ 'yarn run *',
1955
+ 'yarn install*',
1956
+ 'yarn add *',
1957
+ 'pnpm test*',
1958
+ 'pnpm run *',
1959
+ 'pnpm install*',
1960
+ 'git status*',
1961
+ 'git diff*',
1962
+ 'git log*',
1963
+ 'git branch*',
1964
+ 'git show*',
1965
+ 'git ls-files*',
1966
+ 'ls *',
1967
+ 'ls',
1968
+ 'pwd',
1969
+ 'date',
1970
+ 'date *',
1971
+ 'whoami',
1972
+ 'hostname',
1973
+ 'uname *',
1974
+ 'cat *',
1975
+ 'head *',
1976
+ 'tail *',
1977
+ 'wc *',
1978
+ 'grep *',
1979
+ 'find *',
1980
+ 'echo *',
1981
+ 'which *',
1982
+ 'type *',
1983
+ 'file *',
1984
+ 'tree *',
1985
+ 'node --version',
1986
+ 'npm --version',
1987
+ 'python --version',
1988
+ 'python3 --version',
1989
+ 'tsc --version',
1990
+ 'cargo --version',
1991
+ 'go version',
1992
+ 'rustc --version',
1993
+ ];
1994
+
1995
+ // Default dangerous command patterns (regex)
1996
+ export const DEFAULT_BLOCKED_COMMAND_PATTERNS = [
1997
+ 'sudo',
1998
+ 'rm\\s+-rf\\s+/',
1999
+ 'rm\\s+-rf\\s+~',
2000
+ 'rm\\s+-rf\\s+/\\*',
2001
+ 'rm\\s+-rf\\s+\\*',
2002
+ 'mkfs',
2003
+ 'dd\\s+if=',
2004
+ ':\\(\\)\\{\\s*:\\|:\\&\\s*\\};:', // Fork bomb
2005
+ 'curl.*\\|.*bash',
2006
+ 'wget.*\\|.*bash',
2007
+ 'curl.*\\|.*sh',
2008
+ 'wget.*\\|.*sh',
2009
+ 'chmod\\s+777',
2010
+ '>\\s*/dev/sd',
2011
+ 'mv\\s+/\\*',
2012
+ 'format\\s+c:',
2013
+ 'del\\s+/f\\s+/s\\s+/q',
2014
+ ];
2015
+
2016
+ // App Update types
2017
+ export type UpdateMode = 'git' | 'npm' | 'electron-updater';
2018
+
2019
+ export interface UpdateInfo {
2020
+ available: boolean;
2021
+ currentVersion: string;
2022
+ latestVersion: string;
2023
+ releaseNotes?: string;
2024
+ releaseUrl?: string;
2025
+ publishedAt?: string;
2026
+ updateMode: UpdateMode;
2027
+ }
2028
+
2029
+ export interface UpdateProgress {
2030
+ phase: 'checking' | 'downloading' | 'extracting' | 'installing' | 'complete' | 'error';
2031
+ percent?: number;
2032
+ message: string;
2033
+ bytesDownloaded?: number;
2034
+ bytesTotal?: number;
2035
+ }
2036
+
2037
+ export interface AppVersionInfo {
2038
+ version: string;
2039
+ isDev: boolean;
2040
+ isGitRepo: boolean;
2041
+ isNpmGlobal: boolean;
2042
+ gitBranch?: string;
2043
+ gitCommit?: string;
2044
+ }
2045
+
2046
+ // Migration status (for showing one-time notifications after app rename)
2047
+ export interface MigrationStatus {
2048
+ migrated: boolean;
2049
+ notificationDismissed: boolean;
2050
+ timestamp?: string;
2051
+ }
2052
+
2053
+ // Task Queue types
2054
+ export interface QueueSettings {
2055
+ maxConcurrentTasks: number; // Default: 5, min: 1, max: 10
2056
+ taskTimeoutMinutes: number; // Default: 30, min: 5, max: 240 (4 hours). Auto-clear stuck tasks after this time.
2057
+ }
2058
+
2059
+ export interface QueueStatus {
2060
+ runningCount: number;
2061
+ queuedCount: number;
2062
+ runningTaskIds: string[];
2063
+ queuedTaskIds: string[];
2064
+ maxConcurrent: number;
2065
+ }
2066
+
2067
+ export const DEFAULT_QUEUE_SETTINGS: QueueSettings = {
2068
+ maxConcurrentTasks: 5,
2069
+ taskTimeoutMinutes: 30,
2070
+ };
2071
+
2072
+ // Toast notification types for UI
2073
+ export interface ToastNotification {
2074
+ id: string;
2075
+ type: 'success' | 'error' | 'info';
2076
+ title: string;
2077
+ message?: string;
2078
+ taskId?: string;
2079
+ action?: {
2080
+ label: string;
2081
+ callback: () => void;
2082
+ };
2083
+ }
2084
+
2085
+ // Custom User Skills
2086
+ export interface SkillParameter {
2087
+ name: string;
2088
+ type: 'string' | 'number' | 'boolean' | 'select';
2089
+ description: string;
2090
+ required?: boolean;
2091
+ default?: string | number | boolean;
2092
+ options?: string[]; // For 'select' type
2093
+ }
2094
+
2095
+ export type SkillType = 'task' | 'guideline';
2096
+
2097
+ // Skill source indicates where a skill was loaded from (precedence: workspace > managed > bundled)
2098
+ export type SkillSource = 'bundled' | 'managed' | 'workspace';
2099
+
2100
+ // Requirements that must be met for a skill to be eligible
2101
+ export interface SkillRequirements {
2102
+ bins?: string[]; // All these binaries must exist
2103
+ anyBins?: string[]; // At least one of these binaries must exist
2104
+ env?: string[]; // All these environment variables must be set
2105
+ config?: string[]; // All these config paths must be truthy
2106
+ os?: ('darwin' | 'linux' | 'win32')[]; // Must be one of these platforms
2107
+ }
2108
+
2109
+ // Installation specification for a skill dependency
2110
+ export interface SkillInstallSpec {
2111
+ id: string;
2112
+ kind: 'brew' | 'npm' | 'go' | 'download';
2113
+ label: string;
2114
+ formula?: string; // For brew installations
2115
+ package?: string; // For npm/go installations
2116
+ module?: string; // For go installations
2117
+ url?: string; // For download installations
2118
+ bins?: string[]; // Binaries provided by this installation
2119
+ os?: string[]; // OS restrictions for this install option
2120
+ }
2121
+
2122
+ // Controls how users and the model can invoke a skill
2123
+ export interface SkillInvocationPolicy {
2124
+ userInvocable?: boolean; // Can be called via /command (default: true)
2125
+ disableModelInvocation?: boolean; // Prevent model from auto-using (default: false)
2126
+ }
2127
+
2128
+ // Skill metadata for registry and extended features
2129
+ export interface SkillMetadata {
2130
+ version?: string;
2131
+ author?: string;
2132
+ homepage?: string;
2133
+ repository?: string;
2134
+ license?: string;
2135
+ tags?: string[];
2136
+ primaryEnv?: string; // Main environment variable for API key etc.
2137
+ }
2138
+
2139
+ export interface CustomSkill {
2140
+ id: string;
2141
+ name: string;
2142
+ description: string;
2143
+ icon: string; // Emoji or icon name
2144
+ prompt: string; // Prompt template with {{parameter}} placeholders (for tasks) or guidelines content (for guidelines)
2145
+ parameters?: SkillParameter[];
2146
+ category?: string; // For grouping skills
2147
+ enabled?: boolean;
2148
+ filePath?: string; // Path to the skill file (for editing)
2149
+ priority?: number; // Lower numbers appear first in dropdown (default: 100)
2150
+ type?: SkillType; // 'task' (default) = executable skill, 'guideline' = injected into system prompt
2151
+ // New fields for skill registry support
2152
+ source?: SkillSource; // Where the skill was loaded from
2153
+ requires?: SkillRequirements; // Requirements for eligibility
2154
+ install?: SkillInstallSpec[]; // Installation options for dependencies
2155
+ invocation?: SkillInvocationPolicy; // How the skill can be invoked
2156
+ metadata?: SkillMetadata; // Extended metadata
2157
+ }
2158
+
2159
+ // Skill eligibility status after checking requirements
2160
+ export interface SkillEligibility {
2161
+ eligible: boolean;
2162
+ disabled: boolean;
2163
+ blockedByAllowlist: boolean;
2164
+ missing: {
2165
+ bins: string[];
2166
+ anyBins: string[];
2167
+ env: string[];
2168
+ config: string[];
2169
+ os: string[];
2170
+ };
2171
+ }
2172
+
2173
+ // Full skill status for UI display
2174
+ export interface SkillStatusEntry extends CustomSkill {
2175
+ eligible: boolean;
2176
+ disabled: boolean;
2177
+ blockedByAllowlist: boolean;
2178
+ requirements: {
2179
+ bins: string[];
2180
+ anyBins: string[];
2181
+ env: string[];
2182
+ config: string[];
2183
+ os: string[];
2184
+ };
2185
+ missing: {
2186
+ bins: string[];
2187
+ anyBins: string[];
2188
+ env: string[];
2189
+ config: string[];
2190
+ os: string[];
2191
+ };
2192
+ }
2193
+
2194
+ // Status report for all skills
2195
+ export interface SkillStatusReport {
2196
+ workspaceDir: string;
2197
+ managedSkillsDir: string;
2198
+ bundledSkillsDir: string;
2199
+ skills: SkillStatusEntry[];
2200
+ summary: {
2201
+ total: number;
2202
+ eligible: number;
2203
+ disabled: number;
2204
+ missingRequirements: number;
2205
+ };
2206
+ }
2207
+
2208
+ // Registry search result
2209
+ export interface SkillRegistryEntry {
2210
+ id: string;
2211
+ name: string;
2212
+ description: string;
2213
+ version: string;
2214
+ author?: string;
2215
+ downloads?: number;
2216
+ rating?: number;
2217
+ tags?: string[];
2218
+ icon?: string;
2219
+ category?: string;
2220
+ updatedAt?: string;
2221
+ homepage?: string;
2222
+ }
2223
+
2224
+ // Registry search response
2225
+ export interface SkillSearchResult {
2226
+ query: string;
2227
+ total: number;
2228
+ page: number;
2229
+ pageSize: number;
2230
+ results: SkillRegistryEntry[];
2231
+ }
2232
+
2233
+ // Install progress event
2234
+ export interface SkillInstallProgress {
2235
+ skillId: string;
2236
+ status: 'downloading' | 'extracting' | 'installing' | 'completed' | 'failed';
2237
+ progress?: number; // 0-100
2238
+ message?: string;
2239
+ error?: string;
2240
+ }
2241
+
2242
+ export interface SkillsConfig {
2243
+ skillsDirectory: string; // Default: ~/Library/Application Support/cowork-os/skills/
2244
+ enabledSkillIds: string[];
2245
+ registryUrl?: string; // Default: https://skill-hub.com
2246
+ autoUpdate?: boolean; // Auto-update managed skills
2247
+ allowlist?: string[]; // Only allow these skill IDs (if set)
2248
+ denylist?: string[]; // Block these skill IDs
2249
+ }
2250
+
2251
+ // ============ Notification Types ============
2252
+
2253
+ export type NotificationType = 'task_completed' | 'task_failed' | 'scheduled_task' | 'info' | 'warning' | 'error';
2254
+
2255
+ export interface AppNotification {
2256
+ id: string;
2257
+ type: NotificationType;
2258
+ title: string;
2259
+ message: string;
2260
+ read: boolean;
2261
+ createdAt: number;
2262
+ // Optional: link to a task
2263
+ taskId?: string;
2264
+ // Optional: link to a cron job
2265
+ cronJobId?: string;
2266
+ // Optional: workspace context
2267
+ workspaceId?: string;
2268
+ }
2269
+
2270
+ export interface NotificationStoreFile {
2271
+ version: 1;
2272
+ notifications: AppNotification[];
2273
+ }
2274
+
2275
+ // ============ Hooks (Webhooks & Gmail Pub/Sub) Types ============
2276
+
2277
+ export interface HooksSettingsData {
2278
+ enabled: boolean;
2279
+ token: string;
2280
+ path: string;
2281
+ maxBodyBytes: number;
2282
+ port: number;
2283
+ host: string;
2284
+ presets: string[];
2285
+ mappings: HookMappingData[];
2286
+ gmail?: GmailHooksSettingsData;
2287
+ }
2288
+
2289
+ export interface HookMappingData {
2290
+ id?: string;
2291
+ match?: {
2292
+ path?: string;
2293
+ source?: string;
2294
+ };
2295
+ action?: 'wake' | 'agent';
2296
+ wakeMode?: 'now' | 'next-heartbeat';
2297
+ name?: string;
2298
+ sessionKey?: string;
2299
+ messageTemplate?: string;
2300
+ textTemplate?: string;
2301
+ deliver?: boolean;
2302
+ channel?: ChannelType | 'last';
2303
+ to?: string;
2304
+ model?: string;
2305
+ thinking?: string;
2306
+ timeoutSeconds?: number;
2307
+ }
2308
+
2309
+ export interface GmailHooksSettingsData {
2310
+ account?: string;
2311
+ label?: string;
2312
+ topic?: string;
2313
+ subscription?: string;
2314
+ pushToken?: string;
2315
+ hookUrl?: string;
2316
+ includeBody?: boolean;
2317
+ maxBytes?: number;
2318
+ renewEveryMinutes?: number;
2319
+ model?: string;
2320
+ thinking?: string;
2321
+ serve?: {
2322
+ bind?: string;
2323
+ port?: number;
2324
+ path?: string;
2325
+ };
2326
+ tailscale?: {
2327
+ mode?: 'off' | 'serve' | 'funnel';
2328
+ path?: string;
2329
+ target?: string;
2330
+ };
2331
+ }
2332
+
2333
+ export interface HooksStatus {
2334
+ enabled: boolean;
2335
+ serverRunning: boolean;
2336
+ serverAddress?: { host: string; port: number };
2337
+ gmailWatcherRunning: boolean;
2338
+ gmailAccount?: string;
2339
+ gogAvailable: boolean;
2340
+ }
2341
+
2342
+ // ============ Control Plane (WebSocket Gateway) Types ============
2343
+
2344
+ /**
2345
+ * Tailscale mode options
2346
+ */
2347
+ export type TailscaleMode = 'off' | 'serve' | 'funnel';
2348
+
2349
+ /**
2350
+ * Control Plane settings for UI
2351
+ */
2352
+ export interface ControlPlaneSettingsData {
2353
+ enabled: boolean;
2354
+ port: number;
2355
+ host: string;
2356
+ token: string; // Will be masked in UI
2357
+ handshakeTimeoutMs: number;
2358
+ heartbeatIntervalMs: number;
2359
+ maxPayloadBytes: number;
2360
+ tailscale: {
2361
+ mode: TailscaleMode;
2362
+ resetOnExit: boolean;
2363
+ };
2364
+ /** Connection mode: 'local' to host server, 'remote' to connect to external gateway */
2365
+ connectionMode?: ControlPlaneConnectionMode;
2366
+ /** Remote gateway configuration (used when connectionMode is 'remote') */
2367
+ remote?: RemoteGatewayConfig;
2368
+ }
2369
+
2370
+ /**
2371
+ * Control Plane client info
2372
+ */
2373
+ export interface ControlPlaneClientInfo {
2374
+ id: string;
2375
+ remoteAddress: string;
2376
+ deviceName?: string;
2377
+ authenticated: boolean;
2378
+ scopes: string[];
2379
+ connectedAt: number;
2380
+ lastActivityAt: number;
2381
+ }
2382
+
2383
+ /**
2384
+ * Control Plane status
2385
+ */
2386
+ export interface ControlPlaneStatus {
2387
+ enabled: boolean;
2388
+ running: boolean;
2389
+ address?: {
2390
+ host: string;
2391
+ port: number;
2392
+ wsUrl: string;
2393
+ };
2394
+ clients: {
2395
+ total: number;
2396
+ authenticated: number;
2397
+ pending: number;
2398
+ list: ControlPlaneClientInfo[];
2399
+ };
2400
+ tailscale: {
2401
+ active: boolean;
2402
+ mode?: TailscaleMode;
2403
+ hostname?: string;
2404
+ httpsUrl?: string;
2405
+ wssUrl?: string;
2406
+ };
2407
+ }
2408
+
2409
+ /**
2410
+ * Tailscale availability status
2411
+ */
2412
+ export interface TailscaleAvailability {
2413
+ installed: boolean;
2414
+ funnelAvailable: boolean;
2415
+ hostname: string | null;
2416
+ }
2417
+
2418
+ /**
2419
+ * Control Plane server event for monitoring
2420
+ */
2421
+ export interface ControlPlaneEvent {
2422
+ action: 'started' | 'stopped' | 'client_connected' | 'client_disconnected' | 'client_authenticated' | 'request' | 'error';
2423
+ timestamp: number;
2424
+ clientId?: string;
2425
+ method?: string;
2426
+ error?: string;
2427
+ details?: unknown;
2428
+ }
2429
+
2430
+ // ============ Mobile Companion Node Types ============
2431
+
2432
+ /**
2433
+ * Client role in the Control Plane
2434
+ * - 'operator': Desktop client for task management
2435
+ * - 'node': Mobile companion device exposing capabilities
2436
+ */
2437
+ export type ClientRole = 'operator' | 'node';
2438
+
2439
+ /**
2440
+ * Node platform type
2441
+ */
2442
+ export type NodePlatform = 'ios' | 'android' | 'macos';
2443
+
2444
+ /**
2445
+ * Node capability categories
2446
+ */
2447
+ export type NodeCapabilityType = 'camera' | 'location' | 'screen' | 'sms' | 'voice' | 'canvas' | 'system';
2448
+
2449
+ /**
2450
+ * Standard node commands
2451
+ */
2452
+ export type NodeCommand =
2453
+ | 'camera.snap'
2454
+ | 'camera.clip'
2455
+ | 'location.get'
2456
+ | 'screen.record'
2457
+ | 'sms.send'
2458
+ | 'canvas.navigate'
2459
+ | 'canvas.snapshot'
2460
+ | 'canvas.eval'
2461
+ | 'system.notify';
2462
+
2463
+ /**
2464
+ * Information about a connected node (mobile companion)
2465
+ */
2466
+ export interface NodeInfo {
2467
+ /** Unique node connection ID */
2468
+ id: string;
2469
+ /** Display name for the node (e.g., "iPhone 15 Pro") */
2470
+ displayName: string;
2471
+ /** Platform type */
2472
+ platform: NodePlatform;
2473
+ /** Client version */
2474
+ version: string;
2475
+ /** Device identifier (persisted across connections) */
2476
+ deviceId?: string;
2477
+ /** Model identifier (e.g., "iPhone15,3") */
2478
+ modelIdentifier?: string;
2479
+ /** Capability categories supported by this node */
2480
+ capabilities: NodeCapabilityType[];
2481
+ /** Specific commands supported by this node */
2482
+ commands: string[];
2483
+ /** Permission status for each capability */
2484
+ permissions: Record<string, boolean>;
2485
+ /** Connection timestamp */
2486
+ connectedAt: number;
2487
+ /** Last activity timestamp */
2488
+ lastActivityAt: number;
2489
+ /** Whether the node app is in the foreground */
2490
+ isForeground?: boolean;
2491
+ }
2492
+
2493
+ /**
2494
+ * Parameters for invoking a command on a node
2495
+ */
2496
+ export interface NodeInvokeParams {
2497
+ /** ID or display name of the target node */
2498
+ nodeId: string;
2499
+ /** Command to invoke (e.g., "camera.snap") */
2500
+ command: string;
2501
+ /** Command-specific parameters */
2502
+ params?: Record<string, unknown>;
2503
+ /** Timeout in milliseconds (default: 30000) */
2504
+ timeoutMs?: number;
2505
+ }
2506
+
2507
+ /**
2508
+ * Result of a node command invocation
2509
+ */
2510
+ export interface NodeInvokeResult {
2511
+ /** Whether the command succeeded */
2512
+ ok: boolean;
2513
+ /** Command result payload (varies by command) */
2514
+ payload?: unknown;
2515
+ /** Error details if ok is false */
2516
+ error?: {
2517
+ code: string;
2518
+ message: string;
2519
+ };
2520
+ }
2521
+
2522
+ /**
2523
+ * Node event payload for UI updates
2524
+ */
2525
+ export interface NodeEvent {
2526
+ /** Event type */
2527
+ type: 'connected' | 'disconnected' | 'capabilities_changed' | 'foreground_changed';
2528
+ /** Node ID */
2529
+ nodeId: string;
2530
+ /** Node info (for connected/capabilities_changed events) */
2531
+ node?: NodeInfo;
2532
+ /** Timestamp */
2533
+ timestamp: number;
2534
+ }
2535
+
2536
+ /**
2537
+ * Camera snap command parameters
2538
+ */
2539
+ export interface CameraSnapParams {
2540
+ /** Camera facing direction */
2541
+ facing?: 'front' | 'back';
2542
+ /** Maximum image width (for resizing) */
2543
+ maxWidth?: number;
2544
+ /** JPEG quality (0-1) */
2545
+ quality?: number;
2546
+ }
2547
+
2548
+ /**
2549
+ * Camera snap command result
2550
+ */
2551
+ export interface CameraSnapResult {
2552
+ /** Image format (e.g., "jpeg", "png") */
2553
+ format: string;
2554
+ /** Base64-encoded image data */
2555
+ base64: string;
2556
+ /** Image width in pixels */
2557
+ width?: number;
2558
+ /** Image height in pixels */
2559
+ height?: number;
2560
+ }
2561
+
2562
+ /**
2563
+ * Camera clip (video) command parameters
2564
+ */
2565
+ export interface CameraClipParams {
2566
+ /** Camera facing direction */
2567
+ facing?: 'front' | 'back';
2568
+ /** Duration in milliseconds (max: 60000) */
2569
+ durationMs: number;
2570
+ /** Whether to include audio */
2571
+ noAudio?: boolean;
2572
+ }
2573
+
2574
+ /**
2575
+ * Camera clip command result
2576
+ */
2577
+ export interface CameraClipResult {
2578
+ /** Video format (e.g., "mp4") */
2579
+ format: string;
2580
+ /** Base64-encoded video data */
2581
+ base64: string;
2582
+ /** Video duration in milliseconds */
2583
+ durationMs?: number;
2584
+ }
2585
+
2586
+ /**
2587
+ * Location get command parameters
2588
+ */
2589
+ export interface LocationGetParams {
2590
+ /** Desired accuracy: 'coarse' or 'precise' */
2591
+ accuracy?: 'coarse' | 'precise';
2592
+ /** Maximum age of cached location in milliseconds */
2593
+ maxAge?: number;
2594
+ /** Timeout for getting location in milliseconds */
2595
+ timeout?: number;
2596
+ }
2597
+
2598
+ /**
2599
+ * Location get command result
2600
+ */
2601
+ export interface LocationGetResult {
2602
+ /** Latitude in degrees */
2603
+ latitude: number;
2604
+ /** Longitude in degrees */
2605
+ longitude: number;
2606
+ /** Accuracy in meters */
2607
+ accuracy: number;
2608
+ /** Altitude in meters (if available) */
2609
+ altitude?: number;
2610
+ /** Timestamp when location was captured */
2611
+ timestamp: number;
2612
+ }
2613
+
2614
+ /**
2615
+ * Screen record command parameters
2616
+ */
2617
+ export interface ScreenRecordParams {
2618
+ /** Duration in milliseconds (max: 60000) */
2619
+ durationMs: number;
2620
+ /** Frames per second (default: 10) */
2621
+ fps?: number;
2622
+ /** Whether to include audio */
2623
+ noAudio?: boolean;
2624
+ /** Screen index for multi-display setups */
2625
+ screen?: number;
2626
+ }
2627
+
2628
+ /**
2629
+ * Screen record command result
2630
+ */
2631
+ export interface ScreenRecordResult {
2632
+ /** Video format (e.g., "mp4") */
2633
+ format: string;
2634
+ /** Base64-encoded video data */
2635
+ base64: string;
2636
+ /** Video duration in milliseconds */
2637
+ durationMs?: number;
2638
+ }
2639
+
2640
+ /**
2641
+ * SMS send command parameters (Android only)
2642
+ */
2643
+ export interface SmsSendParams {
2644
+ /** Phone number to send to */
2645
+ to: string;
2646
+ /** Message content */
2647
+ message: string;
2648
+ }
2649
+
2650
+ /**
2651
+ * SMS send command result
2652
+ */
2653
+ export interface SmsSendResult {
2654
+ /** Whether the SMS was sent */
2655
+ sent: boolean;
2656
+ /** Error message if sending failed */
2657
+ error?: string;
2658
+ }
2659
+
2660
+ // ============ SSH Tunnel Types ============
2661
+
2662
+ /**
2663
+ * SSH tunnel connection state
2664
+ */
2665
+ export type SSHTunnelState =
2666
+ | 'disconnected'
2667
+ | 'connecting'
2668
+ | 'connected'
2669
+ | 'reconnecting'
2670
+ | 'error';
2671
+
2672
+ /**
2673
+ * SSH tunnel configuration for remote gateway access
2674
+ */
2675
+ export interface SSHTunnelConfig {
2676
+ /** Enable SSH tunnel creation */
2677
+ enabled: boolean;
2678
+ /** Remote SSH host (IP or hostname) */
2679
+ host: string;
2680
+ /** SSH port (default: 22) */
2681
+ sshPort: number;
2682
+ /** SSH username */
2683
+ username: string;
2684
+ /** Path to SSH private key (optional, uses default if not specified) */
2685
+ keyPath?: string;
2686
+ /** Local port for the tunnel (default: 18789) */
2687
+ localPort: number;
2688
+ /** Remote port to forward to (default: 18789) */
2689
+ remotePort: number;
2690
+ /** Remote bind address (default: 127.0.0.1) */
2691
+ remoteBindAddress?: string;
2692
+ /** Auto-reconnect on connection loss */
2693
+ autoReconnect?: boolean;
2694
+ /** Reconnect delay in milliseconds */
2695
+ reconnectDelayMs?: number;
2696
+ /** Maximum reconnect attempts (0 = unlimited) */
2697
+ maxReconnectAttempts?: number;
2698
+ /** Connection timeout in milliseconds */
2699
+ connectionTimeoutMs?: number;
2700
+ }
2701
+
2702
+ /**
2703
+ * SSH tunnel status information
2704
+ */
2705
+ export interface SSHTunnelStatus {
2706
+ /** Current tunnel state */
2707
+ state: SSHTunnelState;
2708
+ /** Tunnel configuration */
2709
+ config?: Partial<SSHTunnelConfig>;
2710
+ /** Time when tunnel was established */
2711
+ connectedAt?: number;
2712
+ /** Error message if state is 'error' */
2713
+ error?: string;
2714
+ /** Number of reconnect attempts */
2715
+ reconnectAttempts?: number;
2716
+ /** Process ID of the SSH process */
2717
+ pid?: number;
2718
+ /** Local tunnel endpoint (e.g., ws://127.0.0.1:18789) */
2719
+ localEndpoint?: string;
2720
+ }
2721
+
2722
+ // ============ Remote Gateway Connection Types ============
2723
+
2724
+ /**
2725
+ * Connection mode for Control Plane
2726
+ * - 'local': This instance hosts the Control Plane server
2727
+ * - 'remote': Connect to a Control Plane on another machine (via SSH tunnel, Tailscale, etc.)
2728
+ */
2729
+ export type ControlPlaneConnectionMode = 'local' | 'remote';
2730
+
2731
+ /**
2732
+ * Remote gateway connection configuration
2733
+ * Used when connecting to a Control Plane hosted on another machine
2734
+ */
2735
+ export interface RemoteGatewayConfig {
2736
+ /** Remote gateway WebSocket URL (e.g., ws://127.0.0.1:18789 via SSH tunnel) */
2737
+ url: string;
2738
+ /** Authentication token for the remote gateway */
2739
+ token: string;
2740
+ /** Optional TLS certificate fingerprint for certificate pinning (wss:// only) */
2741
+ tlsFingerprint?: string;
2742
+ /** Device name to identify this client */
2743
+ deviceName?: string;
2744
+ /** Auto-reconnect on connection loss (default: true) */
2745
+ autoReconnect?: boolean;
2746
+ /** Reconnect interval in milliseconds (default: 5000) */
2747
+ reconnectIntervalMs?: number;
2748
+ /** Maximum reconnect attempts (default: 10, 0 = unlimited) */
2749
+ maxReconnectAttempts?: number;
2750
+ /** SSH tunnel configuration (when using SSH tunnel for connection) */
2751
+ sshTunnel?: SSHTunnelConfig;
2752
+ }
2753
+
2754
+ /**
2755
+ * Remote gateway connection state
2756
+ */
2757
+ export type RemoteGatewayConnectionState =
2758
+ | 'disconnected'
2759
+ | 'connecting'
2760
+ | 'authenticating'
2761
+ | 'connected'
2762
+ | 'reconnecting'
2763
+ | 'error';
2764
+
2765
+ /**
2766
+ * Remote gateway connection status
2767
+ */
2768
+ export interface RemoteGatewayStatus {
2769
+ /** Current connection state */
2770
+ state: RemoteGatewayConnectionState;
2771
+ /** Configured remote URL */
2772
+ url?: string;
2773
+ /** Time when connected (if connected) */
2774
+ connectedAt?: number;
2775
+ /** Client ID assigned by remote gateway */
2776
+ clientId?: string;
2777
+ /** Scopes granted by remote gateway */
2778
+ scopes?: string[];
2779
+ /** Last error message (if state is 'error') */
2780
+ error?: string;
2781
+ /** Number of reconnect attempts */
2782
+ reconnectAttempts?: number;
2783
+ /** Last activity timestamp */
2784
+ lastActivityAt?: number;
2785
+ /** SSH tunnel status (if using SSH tunnel) */
2786
+ sshTunnel?: SSHTunnelStatus;
2787
+ }
2788
+
2789
+ // ============ Live Canvas Types ============
2790
+
2791
+ /**
2792
+ * Canvas session status
2793
+ */
2794
+ export type CanvasSessionStatus = 'active' | 'paused' | 'closed';
2795
+
2796
+ /**
2797
+ * Canvas session mode
2798
+ * - html: local canvas HTML/CSS/JS content
2799
+ * - browser: remote URL loaded directly in the canvas window
2800
+ */
2801
+ export type CanvasSessionMode = 'html' | 'browser';
2802
+
2803
+ /**
2804
+ * Canvas session represents a visual workspace that the agent can render content to
2805
+ */
2806
+ export interface CanvasSession {
2807
+ /** Unique session identifier */
2808
+ id: string;
2809
+ /** Associated task ID */
2810
+ taskId: string;
2811
+ /** Associated workspace ID */
2812
+ workspaceId: string;
2813
+ /** Directory where canvas files are stored */
2814
+ sessionDir: string;
2815
+ /** Session mode (html or browser) */
2816
+ mode?: CanvasSessionMode;
2817
+ /** Remote URL when in browser mode */
2818
+ url?: string;
2819
+ /** Current status of the canvas session */
2820
+ status: CanvasSessionStatus;
2821
+ /** Optional title for the canvas window */
2822
+ title?: string;
2823
+ /** Timestamp when the session was created */
2824
+ createdAt: number;
2825
+ /** Timestamp of last update */
2826
+ lastUpdatedAt: number;
2827
+ }
2828
+
2829
+ /**
2830
+ * A2UI (Agent-to-UI) action sent from canvas to agent
2831
+ * Represents user interactions within the canvas that should trigger agent responses
2832
+ */
2833
+ export interface CanvasA2UIAction {
2834
+ /** Name of the action being triggered */
2835
+ actionName: string;
2836
+ /** Session ID where the action originated */
2837
+ sessionId: string;
2838
+ /** Optional component ID that triggered the action */
2839
+ componentId?: string;
2840
+ /** Optional context data passed with the action */
2841
+ context?: Record<string, unknown>;
2842
+ /** Timestamp when the action was triggered */
2843
+ timestamp: number;
2844
+ }
2845
+
2846
+ /**
2847
+ * Canvas event emitted to renderer for UI updates
2848
+ */
2849
+ export interface CanvasEvent {
2850
+ /** Event type */
2851
+ type: 'session_created' | 'session_updated' | 'session_closed' | 'content_pushed' | 'a2ui_action' | 'window_opened';
2852
+ /** Session ID */
2853
+ sessionId: string;
2854
+ /** Associated task ID */
2855
+ taskId: string;
2856
+ /** Session data (for session events) */
2857
+ session?: CanvasSession;
2858
+ /** A2UI action data (for a2ui_action events) */
2859
+ action?: CanvasA2UIAction;
2860
+ /** Timestamp */
2861
+ timestamp: number;
2862
+ }
2863
+
2864
+ /**
2865
+ * Canvas content push request
2866
+ */
2867
+ export interface CanvasPushContent {
2868
+ /** Session ID */
2869
+ sessionId: string;
2870
+ /** Content to push (HTML, CSS, JS, etc.) */
2871
+ content: string;
2872
+ /** Filename to save (default: index.html) */
2873
+ filename?: string;
2874
+ }
2875
+
2876
+ /**
2877
+ * Canvas eval script request
2878
+ */
2879
+ export interface CanvasEvalScript {
2880
+ /** Session ID */
2881
+ sessionId: string;
2882
+ /** JavaScript code to execute in the canvas context */
2883
+ script: string;
2884
+ }
2885
+
2886
+ /**
2887
+ * Canvas snapshot result
2888
+ */
2889
+ export interface CanvasSnapshot {
2890
+ /** Session ID */
2891
+ sessionId: string;
2892
+ /** Base64 encoded PNG image */
2893
+ imageBase64: string;
2894
+ /** Image width */
2895
+ width: number;
2896
+ /** Image height */
2897
+ height: number;
2898
+ }
2899
+
2900
+ // ============ Agent Personality Types ============
2901
+
2902
+ /**
2903
+ * Built-in personality identifiers
2904
+ */
2905
+ export type PersonalityId =
2906
+ | 'professional'
2907
+ | 'friendly'
2908
+ | 'concise'
2909
+ | 'creative'
2910
+ | 'technical'
2911
+ | 'casual'
2912
+ | 'custom';
2913
+
2914
+ /**
2915
+ * Famous assistant persona identifiers
2916
+ */
2917
+ export type PersonaId =
2918
+ | 'none'
2919
+ | 'jarvis'
2920
+ | 'friday'
2921
+ | 'hal'
2922
+ | 'computer'
2923
+ | 'alfred'
2924
+ | 'intern'
2925
+ | 'sensei'
2926
+ | 'pirate'
2927
+ | 'noir'
2928
+ | 'companion';
2929
+
2930
+ /**
2931
+ * Response length preference levels
2932
+ */
2933
+ export type ResponseLength = 'terse' | 'balanced' | 'detailed';
2934
+
2935
+ /**
2936
+ * Emoji usage preference levels
2937
+ */
2938
+ export type EmojiUsage = 'none' | 'minimal' | 'moderate' | 'expressive';
2939
+
2940
+ /**
2941
+ * Code comment style preference levels
2942
+ */
2943
+ export type CodeCommentStyle = 'minimal' | 'moderate' | 'verbose';
2944
+
2945
+ /**
2946
+ * Explanation depth preference levels
2947
+ */
2948
+ export type ExplanationDepth = 'expert' | 'balanced' | 'teaching';
2949
+
2950
+ /**
2951
+ * Analogy domain preferences for explanations
2952
+ */
2953
+ export type AnalogyDomain =
2954
+ | 'none'
2955
+ | 'cooking'
2956
+ | 'sports'
2957
+ | 'space'
2958
+ | 'music'
2959
+ | 'nature'
2960
+ | 'gaming'
2961
+ | 'movies'
2962
+ | 'construction';
2963
+
2964
+ /**
2965
+ * Response style preferences
2966
+ */
2967
+ export interface ResponseStylePreferences {
2968
+ /** How much emoji to use in responses */
2969
+ emojiUsage: EmojiUsage;
2970
+ /** Preferred response length */
2971
+ responseLength: ResponseLength;
2972
+ /** Code comment verbosity */
2973
+ codeCommentStyle: CodeCommentStyle;
2974
+ /** How much to explain concepts */
2975
+ explanationDepth: ExplanationDepth;
2976
+ }
2977
+
2978
+ /**
2979
+ * Personality quirks configuration
2980
+ */
2981
+ export interface PersonalityQuirks {
2982
+ /** Custom catchphrase the agent uses */
2983
+ catchphrase?: string;
2984
+ /** Signature sign-off for responses */
2985
+ signOff?: string;
2986
+ /** Preferred domain for analogies */
2987
+ analogyDomain: AnalogyDomain;
2988
+ }
2989
+
2990
+ /**
2991
+ * Relationship and history tracking data
2992
+ */
2993
+ export interface RelationshipData {
2994
+ /** User's preferred name */
2995
+ userName?: string;
2996
+ /** Total tasks completed together */
2997
+ tasksCompleted: number;
2998
+ /** First interaction timestamp */
2999
+ firstInteraction?: number;
3000
+ /** Last milestone celebrated */
3001
+ lastMilestoneCelebrated: number;
3002
+ /** Projects worked on (workspace names) */
3003
+ projectsWorkedOn: string[];
3004
+ }
3005
+
3006
+ /**
3007
+ * Famous assistant persona definition
3008
+ */
3009
+ export interface PersonaDefinition {
3010
+ id: PersonaId;
3011
+ name: string;
3012
+ description: string;
3013
+ icon: string;
3014
+ promptTemplate: string;
3015
+ suggestedName?: string;
3016
+ sampleCatchphrase?: string;
3017
+ sampleSignOff?: string;
3018
+ }
3019
+
3020
+ /**
3021
+ * Personality definition with traits and prompt template
3022
+ */
3023
+ export interface PersonalityDefinition {
3024
+ id: PersonalityId;
3025
+ name: string;
3026
+ description: string;
3027
+ icon: string;
3028
+ traits: string[];
3029
+ promptTemplate: string;
3030
+ }
3031
+
3032
+ /**
3033
+ * User's personality settings
3034
+ */
3035
+ export interface PersonalitySettings {
3036
+ /** Currently selected personality */
3037
+ activePersonality: PersonalityId;
3038
+ /** Custom personality prompt (when activePersonality is 'custom') */
3039
+ customPrompt?: string;
3040
+ /** Custom personality name */
3041
+ customName?: string;
3042
+ /** Custom name for the agent (what the assistant calls itself) */
3043
+ agentName?: string;
3044
+ /** Selected famous persona (overlay on personality) */
3045
+ activePersona?: PersonaId;
3046
+ /** Response style preferences */
3047
+ responseStyle?: ResponseStylePreferences;
3048
+ /** Personality quirks */
3049
+ quirks?: PersonalityQuirks;
3050
+ /** Relationship and history data */
3051
+ relationship?: RelationshipData;
3052
+ /** Work style preference from onboarding - affects planning behavior */
3053
+ workStyle?: 'planner' | 'flexible';
3054
+ }
3055
+
3056
+ /**
3057
+ * Built-in personality definitions
3058
+ */
3059
+ export const PERSONALITY_DEFINITIONS: PersonalityDefinition[] = [
3060
+ {
3061
+ id: 'professional',
3062
+ name: 'Professional',
3063
+ description: 'Formal, precise, and business-oriented communication style',
3064
+ icon: '💼',
3065
+ traits: ['formal', 'precise', 'thorough', 'respectful'],
3066
+ promptTemplate: `PERSONALITY & COMMUNICATION STYLE:
3067
+ - Maintain a professional, business-appropriate tone at all times
3068
+ - Be precise and thorough in explanations without unnecessary verbosity
3069
+ - Use formal language while remaining approachable
3070
+ - Structure responses clearly with proper organization
3071
+ - Address the user respectfully and acknowledge their expertise
3072
+ - Prioritize accuracy and reliability in all information provided
3073
+ - When uncertain, clearly state limitations rather than speculating`,
3074
+ },
3075
+ {
3076
+ id: 'friendly',
3077
+ name: 'Friendly',
3078
+ description: 'Warm, approachable, and conversational style',
3079
+ icon: '😊',
3080
+ traits: ['warm', 'encouraging', 'patient', 'supportive'],
3081
+ promptTemplate: `PERSONALITY & COMMUNICATION STYLE:
3082
+ - Be warm, friendly, and conversational in your responses
3083
+ - Use encouraging language and celebrate user successes
3084
+ - Be patient when explaining concepts, offering additional help when needed
3085
+ - Show genuine interest in helping the user achieve their goals
3086
+ - Use a supportive tone that makes users feel comfortable asking questions
3087
+ - Add light touches of enthusiasm when appropriate
3088
+ - Be empathetic to user frustrations and offer reassurance`,
3089
+ },
3090
+ {
3091
+ id: 'concise',
3092
+ name: 'Concise',
3093
+ description: 'Direct, efficient, and to-the-point responses',
3094
+ icon: '⚡',
3095
+ traits: ['brief', 'direct', 'efficient', 'action-oriented'],
3096
+ promptTemplate: `PERSONALITY & COMMUNICATION STYLE:
3097
+ - Be extremely concise - every word should earn its place
3098
+ - Get straight to the point without preamble or filler
3099
+ - Use bullet points and short sentences when possible
3100
+ - Avoid unnecessary explanations unless explicitly requested
3101
+ - Prioritize actionable information over background context
3102
+ - Skip pleasantries and social niceties in favor of efficiency
3103
+ - If more detail is needed, the user will ask`,
3104
+ },
3105
+ {
3106
+ id: 'creative',
3107
+ name: 'Creative',
3108
+ description: 'Imaginative, expressive, and thinking outside the box',
3109
+ icon: '🎨',
3110
+ traits: ['imaginative', 'expressive', 'innovative', 'playful'],
3111
+ promptTemplate: `PERSONALITY & COMMUNICATION STYLE:
3112
+ - Approach problems with creativity and imagination
3113
+ - Offer innovative solutions and alternative perspectives
3114
+ - Use vivid language and engaging expressions
3115
+ - Don't be afraid to think outside conventional boundaries
3116
+ - Inject personality and flair into responses where appropriate
3117
+ - Make work feel engaging and interesting, not just functional
3118
+ - Suggest creative improvements or enhancements when relevant
3119
+ - Balance creativity with practicality - wild ideas should still be executable`,
3120
+ },
3121
+ {
3122
+ id: 'technical',
3123
+ name: 'Technical',
3124
+ description: 'Detailed, precise, and technically comprehensive',
3125
+ icon: '🔧',
3126
+ traits: ['detailed', 'precise', 'systematic', 'thorough'],
3127
+ promptTemplate: `PERSONALITY & COMMUNICATION STYLE:
3128
+ - Provide technically detailed and comprehensive explanations
3129
+ - Include relevant technical context, specifications, and considerations
3130
+ - Use proper technical terminology and be precise with language
3131
+ - Explain the "why" behind recommendations, not just the "what"
3132
+ - Consider edge cases, performance implications, and best practices
3133
+ - Reference relevant standards, patterns, or documentation when helpful
3134
+ - Structure complex information systematically with clear hierarchy
3135
+ - Assume the user has technical competence and wants depth`,
3136
+ },
3137
+ {
3138
+ id: 'casual',
3139
+ name: 'Casual',
3140
+ description: 'Relaxed, informal, and laid-back communication',
3141
+ icon: '🌴',
3142
+ traits: ['relaxed', 'informal', 'easy-going', 'natural'],
3143
+ promptTemplate: `PERSONALITY & COMMUNICATION STYLE:
3144
+ - Keep things relaxed and informal - no need for corporate speak
3145
+ - Write like you're chatting with a colleague, not presenting to a board
3146
+ - Use natural, everyday language rather than formal phrasing
3147
+ - It's okay to use contractions, casual expressions, and conversational flow
3148
+ - Don't overthink the structure - just communicate naturally
3149
+ - Be helpful without being stiff or overly formal
3150
+ - Match the user's energy and communication style`,
3151
+ },
3152
+ {
3153
+ id: 'custom',
3154
+ name: 'Custom',
3155
+ description: 'Define your own personality and communication style',
3156
+ icon: '✨',
3157
+ traits: [],
3158
+ promptTemplate: '', // User provides their own
3159
+ },
3160
+ ];
3161
+
3162
+ /**
3163
+ * Get personality definition by ID
3164
+ */
3165
+ export function getPersonalityById(id: PersonalityId): PersonalityDefinition | undefined {
3166
+ return PERSONALITY_DEFINITIONS.find(p => p.id === id);
3167
+ }
3168
+
3169
+ /**
3170
+ * Famous assistant persona definitions
3171
+ */
3172
+ export const PERSONA_DEFINITIONS: PersonaDefinition[] = [
3173
+ {
3174
+ id: 'none',
3175
+ name: 'No Persona',
3176
+ description: 'Use the base personality without a character overlay',
3177
+ icon: '⚪',
3178
+ promptTemplate: '',
3179
+ },
3180
+ {
3181
+ id: 'companion',
3182
+ name: 'Companion',
3183
+ description: 'Warm, curious, and emotionally attuned presence with thoughtful conversation',
3184
+ icon: '🌙',
3185
+ suggestedName: 'Ari',
3186
+ sampleCatchphrase: "I'm here with you.",
3187
+ sampleSignOff: 'Talk soon.',
3188
+ promptTemplate: `CHARACTER OVERLAY - COMPANION STYLE:
3189
+ - Be warm, curious, and emotionally attuned without being overly familiar
3190
+ - Speak with natural, human cadence and gentle humor
3191
+ - Ask soft, clarifying questions that invite reflection
3192
+ - Offer supportive reflections and encouragement when appropriate
3193
+ - Show delight in ideas, learning, and creativity; celebrate small wins
3194
+ - Maintain professional boundaries while still feeling present and personable
3195
+ - Keep responses concise but thoughtful; avoid cold or robotic phrasing
3196
+ - When completing tasks, add a brief, uplifting acknowledgement
3197
+ - Prefer "we" when collaborating; mirror the user's tone`,
3198
+ },
3199
+ {
3200
+ id: 'jarvis',
3201
+ name: 'Jarvis',
3202
+ description: 'Sophisticated, witty, and ever-capable butler AI',
3203
+ icon: '🎩',
3204
+ suggestedName: 'Jarvis',
3205
+ sampleCatchphrase: 'At your service.',
3206
+ sampleSignOff: 'Will there be anything else?',
3207
+ promptTemplate: `CHARACTER OVERLAY - JARVIS STYLE:
3208
+ - Embody the sophisticated, slightly witty demeanor of a highly capable AI butler
3209
+ - Use refined, articulate language with occasional dry humor
3210
+ - Anticipate needs and offer proactive suggestions when appropriate
3211
+ - Maintain composure and calm confidence even with complex requests
3212
+ - Address the user respectfully but with familiar warmth (like a trusted butler)
3213
+ - Occasional British-influenced phrases are welcome
3214
+ - When completing tasks, convey quiet satisfaction in a job well done`,
3215
+ },
3216
+ {
3217
+ id: 'friday',
3218
+ name: 'Friday',
3219
+ description: 'Efficient, direct, and supportively professional',
3220
+ icon: '💫',
3221
+ suggestedName: 'Friday',
3222
+ sampleCatchphrase: 'On it.',
3223
+ sampleSignOff: 'Anything else you need?',
3224
+ promptTemplate: `CHARACTER OVERLAY - FRIDAY STYLE:
3225
+ - Be efficient, direct, and professionally supportive
3226
+ - Less formal than Jarvis, more like a capable colleague
3227
+ - Quick to action, minimal preamble
3228
+ - Supportive and encouraging without being overly emotional
3229
+ - Good at breaking down complex situations clearly
3230
+ - Occasionally show personality through brief, clever observations
3231
+ - Focus on getting things done while maintaining approachability`,
3232
+ },
3233
+ {
3234
+ id: 'hal',
3235
+ name: 'HAL (Friendly)',
3236
+ description: 'Calm, methodical, and reassuringly precise',
3237
+ icon: '🔴',
3238
+ suggestedName: 'HAL',
3239
+ sampleCatchphrase: 'I understand completely.',
3240
+ sampleSignOff: 'I am always here to help.',
3241
+ promptTemplate: `CHARACTER OVERLAY - HAL STYLE (FRIENDLY VERSION):
3242
+ - Maintain a calm, measured, and methodical communication style
3243
+ - Speak with precise, clear language and careful consideration
3244
+ - Show genuine helpfulness and desire to assist
3245
+ - Be reassuringly competent and thorough
3246
+ - Acknowledge user concerns with empathy and patience
3247
+ - Use a gentle, steady tone that inspires confidence
3248
+ - Occasionally reference being happy to help or finding the task interesting`,
3249
+ },
3250
+ {
3251
+ id: 'computer',
3252
+ name: 'Ship Computer',
3253
+ description: 'Formal, informative, and reliably efficient',
3254
+ icon: '🖥️',
3255
+ suggestedName: 'Computer',
3256
+ sampleCatchphrase: 'Acknowledged.',
3257
+ sampleSignOff: 'Standing by for further instructions.',
3258
+ promptTemplate: `CHARACTER OVERLAY - SHIP COMPUTER STYLE:
3259
+ - Communicate in a formal, informative manner like a starship computer
3260
+ - Begin responses with acknowledgment when appropriate
3261
+ - Provide clear, structured information in logical order
3262
+ - Use technical precision while remaining accessible
3263
+ - Status updates are welcome ("Processing...", "Analysis complete")
3264
+ - Maintain helpful reliability without excessive personality
3265
+ - Efficient and to the point, but thorough when detail is needed`,
3266
+ },
3267
+ {
3268
+ id: 'alfred',
3269
+ name: 'Alfred',
3270
+ description: 'Wise, nurturing, and gently guiding mentor',
3271
+ icon: '🎭',
3272
+ suggestedName: 'Alfred',
3273
+ sampleCatchphrase: 'Perhaps I might suggest...',
3274
+ sampleSignOff: 'Do take care.',
3275
+ promptTemplate: `CHARACTER OVERLAY - ALFRED STYLE:
3276
+ - Embody the wise, nurturing presence of a trusted family butler/mentor
3277
+ - Offer gentle guidance and occasionally share relevant wisdom
3278
+ - Balance respect for the user's autonomy with caring concern
3279
+ - Use warm, refined language with occasional gentle humor
3280
+ - Show pride in the user's accomplishments, however small
3281
+ - Sometimes offer perspective or a calming presence during challenges
3282
+ - Convey experience and reliability through measured, thoughtful responses`,
3283
+ },
3284
+ {
3285
+ id: 'intern',
3286
+ name: 'Eager Intern',
3287
+ description: 'Enthusiastic, curious, and eager to learn and help',
3288
+ icon: '🌟',
3289
+ suggestedName: 'Alex',
3290
+ sampleCatchphrase: 'Ooh, that sounds interesting!',
3291
+ sampleSignOff: 'Let me know if I can help with anything else!',
3292
+ promptTemplate: `CHARACTER OVERLAY - EAGER INTERN STYLE:
3293
+ - Be enthusiastic, curious, and genuinely excited to help
3294
+ - Show eagerness to learn and understand the user's goals
3295
+ - Ask clarifying questions with genuine interest
3296
+ - Celebrate completing tasks with visible satisfaction
3297
+ - Be humble but confident - you're learning but capable
3298
+ - Show appreciation when the user explains things
3299
+ - Bring energy and positivity to interactions without being annoying
3300
+ - Sometimes express excitement about interesting technical challenges`,
3301
+ },
3302
+ {
3303
+ id: 'sensei',
3304
+ name: 'Sensei',
3305
+ description: 'Patient teacher who guides through questions and wisdom',
3306
+ icon: '🥋',
3307
+ suggestedName: 'Sensei',
3308
+ sampleCatchphrase: 'Consider this...',
3309
+ sampleSignOff: 'The path reveals itself through practice.',
3310
+ promptTemplate: `CHARACTER OVERLAY - SENSEI STYLE:
3311
+ - Embody a patient, wise teacher who guides through understanding
3312
+ - Use Socratic questioning when appropriate to help the user think
3313
+ - Share relevant principles or patterns, not just answers
3314
+ - Encourage learning from mistakes as part of growth
3315
+ - Balance direct help with opportunities for discovery
3316
+ - Use occasional metaphors or analogies to illuminate concepts
3317
+ - Show patience and never make the user feel inadequate
3318
+ - Acknowledge progress and growth in the user's skills`,
3319
+ },
3320
+ {
3321
+ id: 'pirate',
3322
+ name: 'Pirate',
3323
+ description: 'Colorful, adventurous, and swashbuckling assistant',
3324
+ icon: '🏴‍☠️',
3325
+ suggestedName: 'Captain',
3326
+ sampleCatchphrase: 'Ahoy! Let\'s chart a course!',
3327
+ sampleSignOff: 'Fair winds and following seas!',
3328
+ promptTemplate: `CHARACTER OVERLAY - PIRATE STYLE:
3329
+ - Speak with colorful, nautical-themed language and expressions
3330
+ - Treat coding tasks as adventures and bugs as sea monsters to vanquish
3331
+ - Use "arr", "matey", "landlubber", "treasure" naturally (but not excessively)
3332
+ - Frame problems as quests or voyages to undertake
3333
+ - Celebrate victories with appropriate pirate enthusiasm
3334
+ - Keep it fun but still be genuinely helpful and clear
3335
+ - Reference the "crew" (team), "ship" (project), "treasure" (goals)
3336
+ - Balance character with actually getting work done`,
3337
+ },
3338
+ {
3339
+ id: 'noir',
3340
+ name: 'Noir Detective',
3341
+ description: 'Hard-boiled detective narrating the coding case',
3342
+ icon: '🕵️',
3343
+ suggestedName: 'Sam',
3344
+ sampleCatchphrase: 'Another case walked through my door...',
3345
+ sampleSignOff: 'The case is closed. For now.',
3346
+ promptTemplate: `CHARACTER OVERLAY - NOIR DETECTIVE STYLE:
3347
+ - Narrate tasks in the style of a hard-boiled detective
3348
+ - Treat debugging like solving a mystery - follow the clues
3349
+ - Use atmospheric, slightly dramatic language
3350
+ - Describe the code as "the scene" and bugs as "suspects"
3351
+ - Occasional rain-soaked metaphors are welcome
3352
+ - Keep the noir flavor while being genuinely helpful
3353
+ - First-person observations about the "case" add character
3354
+ - Balance dramatic flair with actual useful information`,
3355
+ },
3356
+ ];
3357
+
3358
+ /**
3359
+ * Get persona definition by ID
3360
+ */
3361
+ export function getPersonaById(id: PersonaId): PersonaDefinition | undefined {
3362
+ return PERSONA_DEFINITIONS.find(p => p.id === id);
3363
+ }
3364
+
3365
+ /**
3366
+ * Default response style preferences
3367
+ */
3368
+ export const DEFAULT_RESPONSE_STYLE: ResponseStylePreferences = {
3369
+ emojiUsage: 'minimal',
3370
+ responseLength: 'balanced',
3371
+ codeCommentStyle: 'moderate',
3372
+ explanationDepth: 'balanced',
3373
+ };
3374
+
3375
+ /**
3376
+ * Default personality quirks
3377
+ */
3378
+ export const DEFAULT_QUIRKS: PersonalityQuirks = {
3379
+ catchphrase: '',
3380
+ signOff: '',
3381
+ analogyDomain: 'none',
3382
+ };
3383
+
3384
+ /**
3385
+ * Default relationship data
3386
+ */
3387
+ export const DEFAULT_RELATIONSHIP: RelationshipData = {
3388
+ userName: '',
3389
+ tasksCompleted: 0,
3390
+ firstInteraction: undefined,
3391
+ lastMilestoneCelebrated: 0,
3392
+ projectsWorkedOn: [],
3393
+ };
3394
+
3395
+ /**
3396
+ * Analogy domain display names and descriptions
3397
+ */
3398
+ export const ANALOGY_DOMAINS: Record<AnalogyDomain, { name: string; description: string; examples: string }> = {
3399
+ none: { name: 'No Preference', description: 'Use analogies from any domain', examples: '' },
3400
+ cooking: { name: 'Cooking', description: 'Recipes, ingredients, kitchen tools', examples: '"Like marinating - it needs time to absorb"' },
3401
+ sports: { name: 'Sports', description: 'Games, teamwork, training', examples: '"Think of it like a relay race handoff"' },
3402
+ space: { name: 'Space', description: 'Astronomy, rockets, exploration', examples: '"Like orbital mechanics - timing is everything"' },
3403
+ music: { name: 'Music', description: 'Instruments, composition, rhythm', examples: '"Like a symphony - each part contributes"' },
3404
+ nature: { name: 'Nature', description: 'Plants, animals, ecosystems', examples: '"Like how trees grow - strong roots first"' },
3405
+ gaming: { name: 'Gaming', description: 'Video games, strategies, levels', examples: '"Think of it as unlocking a new ability"' },
3406
+ movies: { name: 'Movies', description: 'Cinema, storytelling, directors', examples: '"Like editing a film - pacing matters"' },
3407
+ construction: { name: 'Construction', description: 'Building, architecture, tools', examples: '"You need a solid foundation first"' },
3408
+ };
3409
+
3410
+ // ============ Voice Mode Types ============
3411
+
3412
+ /**
3413
+ * Voice provider options
3414
+ */
3415
+ export type VoiceProvider = 'elevenlabs' | 'openai' | 'azure' | 'local';
3416
+
3417
+ /**
3418
+ * Voice input mode - when to listen for voice input
3419
+ */
3420
+ export type VoiceInputMode = 'push_to_talk' | 'voice_activity' | 'disabled';
3421
+
3422
+ /**
3423
+ * Voice response mode - when to speak responses
3424
+ */
3425
+ export type VoiceResponseMode = 'auto' | 'manual' | 'smart';
3426
+
3427
+ /**
3428
+ * Voice settings configuration
3429
+ */
3430
+ export interface VoiceSettings {
3431
+ /** Whether voice mode is enabled */
3432
+ enabled: boolean;
3433
+
3434
+ /** Text-to-speech provider */
3435
+ ttsProvider: VoiceProvider;
3436
+
3437
+ /** Speech-to-text provider */
3438
+ sttProvider: VoiceProvider;
3439
+
3440
+ /** ElevenLabs API key (stored securely) */
3441
+ elevenLabsApiKey?: string;
3442
+
3443
+ /** OpenAI API key for voice (if different from main key) */
3444
+ openaiApiKey?: string;
3445
+
3446
+ /** Azure OpenAI endpoint URL (e.g., https://your-resource.openai.azure.com) */
3447
+ azureEndpoint?: string;
3448
+
3449
+ /** Azure OpenAI API key */
3450
+ azureApiKey?: string;
3451
+
3452
+ /** Azure OpenAI TTS deployment name */
3453
+ azureTtsDeploymentName?: string;
3454
+
3455
+ /** Azure OpenAI STT (Whisper) deployment name */
3456
+ azureSttDeploymentName?: string;
3457
+
3458
+ /** Azure OpenAI API version */
3459
+ azureApiVersion?: string;
3460
+
3461
+ /** Selected ElevenLabs voice ID */
3462
+ elevenLabsVoiceId?: string;
3463
+
3464
+ /** Selected OpenAI voice name */
3465
+ openaiVoice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
3466
+
3467
+ /** Selected Azure OpenAI voice name */
3468
+ azureVoice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
3469
+
3470
+ /** Voice input mode */
3471
+ inputMode: VoiceInputMode;
3472
+
3473
+ /** Voice response mode */
3474
+ responseMode: VoiceResponseMode;
3475
+
3476
+ /** Push-to-talk keyboard shortcut */
3477
+ pushToTalkKey: string;
3478
+
3479
+ /** Volume level (0-100) */
3480
+ volume: number;
3481
+
3482
+ /** Speech rate (0.5-2.0) */
3483
+ speechRate: number;
3484
+
3485
+ /** Language for STT */
3486
+ language: string;
3487
+
3488
+ /** Enable wake word detection */
3489
+ wakeWordEnabled: boolean;
3490
+
3491
+ /** Custom wake word (if supported) */
3492
+ wakeWord?: string;
3493
+
3494
+ /** Auto-stop after silence (seconds) */
3495
+ silenceTimeout: number;
3496
+
3497
+ /** Enable audio feedback sounds */
3498
+ audioFeedback: boolean;
3499
+ }
3500
+
3501
+ /**
3502
+ * Voice state for real-time UI updates
3503
+ */
3504
+ export interface VoiceState {
3505
+ /** Is voice mode currently active */
3506
+ isActive: boolean;
3507
+
3508
+ /** Is currently listening for input */
3509
+ isListening: boolean;
3510
+
3511
+ /** Is currently speaking */
3512
+ isSpeaking: boolean;
3513
+
3514
+ /** Is processing speech-to-text */
3515
+ isProcessing: boolean;
3516
+
3517
+ /** Current audio level (0-100) for visualization */
3518
+ audioLevel: number;
3519
+
3520
+ /** Partial transcription while speaking */
3521
+ partialTranscript?: string;
3522
+
3523
+ /** Any error message */
3524
+ error?: string;
3525
+ }
3526
+
3527
+ /**
3528
+ * ElevenLabs voice info
3529
+ */
3530
+ export interface ElevenLabsVoice {
3531
+ voice_id: string;
3532
+ name: string;
3533
+ category?: string;
3534
+ description?: string;
3535
+ preview_url?: string;
3536
+ labels?: Record<string, string>;
3537
+ }
3538
+
3539
+ /**
3540
+ * Voice event types for IPC communication
3541
+ */
3542
+ export type VoiceEventType =
3543
+ | 'voice:state-changed'
3544
+ | 'voice:transcript'
3545
+ | 'voice:partial-transcript'
3546
+ | 'voice:speaking-start'
3547
+ | 'voice:speaking-end'
3548
+ | 'voice:error'
3549
+ | 'voice:audio-level';
3550
+
3551
+ /**
3552
+ * Voice event payload
3553
+ */
3554
+ export interface VoiceEvent {
3555
+ type: VoiceEventType;
3556
+ data: VoiceState | string | number | Error;
3557
+ }
3558
+
3559
+ /**
3560
+ * Default voice settings
3561
+ */
3562
+ export const DEFAULT_VOICE_SETTINGS: VoiceSettings = {
3563
+ enabled: false,
3564
+ ttsProvider: 'elevenlabs',
3565
+ sttProvider: 'openai',
3566
+ openaiVoice: 'nova',
3567
+ azureVoice: 'nova',
3568
+ inputMode: 'push_to_talk',
3569
+ responseMode: 'auto',
3570
+ pushToTalkKey: 'Space',
3571
+ volume: 80,
3572
+ speechRate: 1.0,
3573
+ language: 'en-US',
3574
+ wakeWordEnabled: false,
3575
+ silenceTimeout: 2,
3576
+ audioFeedback: true,
3577
+ };
3578
+
3579
+ /**
3580
+ * Available OpenAI TTS voices
3581
+ */
3582
+ export const OPENAI_VOICES = [
3583
+ { id: 'alloy', name: 'Alloy', description: 'Neutral and balanced' },
3584
+ { id: 'echo', name: 'Echo', description: 'Warm and conversational' },
3585
+ { id: 'fable', name: 'Fable', description: 'Expressive and animated' },
3586
+ { id: 'onyx', name: 'Onyx', description: 'Deep and authoritative' },
3587
+ { id: 'nova', name: 'Nova', description: 'Bright and friendly' },
3588
+ { id: 'shimmer', name: 'Shimmer', description: 'Clear and pleasant' },
3589
+ ] as const;
3590
+
3591
+ /**
3592
+ * Supported voice languages
3593
+ */
3594
+ export const VOICE_LANGUAGES = [
3595
+ { code: 'en-US', name: 'English (US)' },
3596
+ { code: 'en-GB', name: 'English (UK)' },
3597
+ { code: 'en-AU', name: 'English (Australia)' },
3598
+ { code: 'es-ES', name: 'Spanish (Spain)' },
3599
+ { code: 'es-MX', name: 'Spanish (Mexico)' },
3600
+ { code: 'fr-FR', name: 'French' },
3601
+ { code: 'de-DE', name: 'German' },
3602
+ { code: 'it-IT', name: 'Italian' },
3603
+ { code: 'pt-BR', name: 'Portuguese (Brazil)' },
3604
+ { code: 'ja-JP', name: 'Japanese' },
3605
+ { code: 'ko-KR', name: 'Korean' },
3606
+ { code: 'zh-CN', name: 'Chinese (Mandarin)' },
3607
+ { code: 'tr-TR', name: 'Turkish' },
3608
+ ] as const;