@gokulvenkatareddy/cortex 0.1.7

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 (299) hide show
  1. package/README.md +1295 -0
  2. package/apps/octogent/.github/workflows/ci.yml +40 -0
  3. package/apps/octogent/.shims/claude +4 -0
  4. package/apps/octogent/AGENTS.md +71 -0
  5. package/apps/octogent/CONTRIBUTING.md +72 -0
  6. package/apps/octogent/LICENSE +21 -0
  7. package/apps/octogent/README.md +184 -0
  8. package/apps/octogent/apps/api/AGENTS.md +32 -0
  9. package/apps/octogent/apps/api/package.json +19 -0
  10. package/apps/octogent/apps/api/src/agentStateDetection.ts +181 -0
  11. package/apps/octogent/apps/api/src/claudeSessionScanner.ts +235 -0
  12. package/apps/octogent/apps/api/src/claudeSkills.ts +182 -0
  13. package/apps/octogent/apps/api/src/claudeUsage.ts +922 -0
  14. package/apps/octogent/apps/api/src/cli.ts +595 -0
  15. package/apps/octogent/apps/api/src/codeIntelStore.ts +46 -0
  16. package/apps/octogent/apps/api/src/codexUsage.ts +278 -0
  17. package/apps/octogent/apps/api/src/createApiServer/codeIntelRoutes.ts +60 -0
  18. package/apps/octogent/apps/api/src/createApiServer/conversationRoutes.ts +128 -0
  19. package/apps/octogent/apps/api/src/createApiServer/deckRoutes.ts +873 -0
  20. package/apps/octogent/apps/api/src/createApiServer/gitParsers.ts +140 -0
  21. package/apps/octogent/apps/api/src/createApiServer/gitRoutes.ts +214 -0
  22. package/apps/octogent/apps/api/src/createApiServer/miscRoutes.ts +316 -0
  23. package/apps/octogent/apps/api/src/createApiServer/monitorParsers.ts +137 -0
  24. package/apps/octogent/apps/api/src/createApiServer/monitorRoutes.ts +95 -0
  25. package/apps/octogent/apps/api/src/createApiServer/requestHandler.ts +311 -0
  26. package/apps/octogent/apps/api/src/createApiServer/requestParsers.ts +25 -0
  27. package/apps/octogent/apps/api/src/createApiServer/routeHelpers.ts +97 -0
  28. package/apps/octogent/apps/api/src/createApiServer/security.ts +70 -0
  29. package/apps/octogent/apps/api/src/createApiServer/terminalParsers.ts +167 -0
  30. package/apps/octogent/apps/api/src/createApiServer/terminalRoutes.ts +315 -0
  31. package/apps/octogent/apps/api/src/createApiServer/types.ts +24 -0
  32. package/apps/octogent/apps/api/src/createApiServer/uiStateParsers.ts +255 -0
  33. package/apps/octogent/apps/api/src/createApiServer/upgradeHandler.ts +38 -0
  34. package/apps/octogent/apps/api/src/createApiServer/usageRoutes.ts +84 -0
  35. package/apps/octogent/apps/api/src/createApiServer.ts +176 -0
  36. package/apps/octogent/apps/api/src/deck/readDeckTentacles.ts +595 -0
  37. package/apps/octogent/apps/api/src/githubRepoSummary.ts +397 -0
  38. package/apps/octogent/apps/api/src/logging.ts +9 -0
  39. package/apps/octogent/apps/api/src/monitor/defaults.ts +3 -0
  40. package/apps/octogent/apps/api/src/monitor/index.ts +8 -0
  41. package/apps/octogent/apps/api/src/monitor/repository.ts +303 -0
  42. package/apps/octogent/apps/api/src/monitor/service.ts +349 -0
  43. package/apps/octogent/apps/api/src/monitor/types.ts +120 -0
  44. package/apps/octogent/apps/api/src/monitor/xProvider.ts +587 -0
  45. package/apps/octogent/apps/api/src/projectPersistence.ts +377 -0
  46. package/apps/octogent/apps/api/src/prompts/index.ts +10 -0
  47. package/apps/octogent/apps/api/src/prompts/promptResolver.ts +145 -0
  48. package/apps/octogent/apps/api/src/runtimeMetadata.ts +69 -0
  49. package/apps/octogent/apps/api/src/server.ts +80 -0
  50. package/apps/octogent/apps/api/src/setupState.ts +80 -0
  51. package/apps/octogent/apps/api/src/setupStatus.ts +174 -0
  52. package/apps/octogent/apps/api/src/startupPrerequisites.ts +146 -0
  53. package/apps/octogent/apps/api/src/terminalRuntime/channelMessaging.ts +87 -0
  54. package/apps/octogent/apps/api/src/terminalRuntime/claudeTranscript.ts +279 -0
  55. package/apps/octogent/apps/api/src/terminalRuntime/constants.ts +15 -0
  56. package/apps/octogent/apps/api/src/terminalRuntime/conversations.ts +492 -0
  57. package/apps/octogent/apps/api/src/terminalRuntime/gitOperations.ts +341 -0
  58. package/apps/octogent/apps/api/src/terminalRuntime/hookProcessor.ts +405 -0
  59. package/apps/octogent/apps/api/src/terminalRuntime/protocol.ts +46 -0
  60. package/apps/octogent/apps/api/src/terminalRuntime/ptyEnvironment.ts +50 -0
  61. package/apps/octogent/apps/api/src/terminalRuntime/registry.ts +423 -0
  62. package/apps/octogent/apps/api/src/terminalRuntime/sessionRuntime.ts +671 -0
  63. package/apps/octogent/apps/api/src/terminalRuntime/systemClients.ts +432 -0
  64. package/apps/octogent/apps/api/src/terminalRuntime/types.ts +157 -0
  65. package/apps/octogent/apps/api/src/terminalRuntime/worktreeManager.ts +135 -0
  66. package/apps/octogent/apps/api/src/terminalRuntime.ts +567 -0
  67. package/apps/octogent/apps/api/src/usageUtils.ts +16 -0
  68. package/apps/octogent/apps/api/src/ws-shim.d.ts +28 -0
  69. package/apps/octogent/apps/api/tests/agentStateDetection.test.ts +67 -0
  70. package/apps/octogent/apps/api/tests/claudeUsage.test.ts +583 -0
  71. package/apps/octogent/apps/api/tests/codexUsage.test.ts +107 -0
  72. package/apps/octogent/apps/api/tests/createApiServer.test.ts +3207 -0
  73. package/apps/octogent/apps/api/tests/githubRepoSummary.test.ts +100 -0
  74. package/apps/octogent/apps/api/tests/logging.test.ts +33 -0
  75. package/apps/octogent/apps/api/tests/monitorApi.test.ts +467 -0
  76. package/apps/octogent/apps/api/tests/monitorCore.test.ts +104 -0
  77. package/apps/octogent/apps/api/tests/promptResolver.test.ts +109 -0
  78. package/apps/octogent/apps/api/tests/protocol.test.ts +14 -0
  79. package/apps/octogent/apps/api/tests/sessionRuntime.test.ts +608 -0
  80. package/apps/octogent/apps/api/tests/startupPrerequisites.test.ts +70 -0
  81. package/apps/octogent/apps/api/tests/upgradeHandler.test.ts +40 -0
  82. package/apps/octogent/apps/api/tests/xMonitorProvider.test.ts +109 -0
  83. package/apps/octogent/apps/api/tsconfig.json +7 -0
  84. package/apps/octogent/apps/api/vitest.config.ts +7 -0
  85. package/apps/octogent/apps/web/AGENTS.md +38 -0
  86. package/apps/octogent/apps/web/index.html +13 -0
  87. package/apps/octogent/apps/web/package.json +32 -0
  88. package/apps/octogent/apps/web/public/octopus-favicon.svg +26 -0
  89. package/apps/octogent/apps/web/src/App.tsx +646 -0
  90. package/apps/octogent/apps/web/src/app/canvas/types.ts +34 -0
  91. package/apps/octogent/apps/web/src/app/codeIntelAggregation.ts +278 -0
  92. package/apps/octogent/apps/web/src/app/constants.ts +28 -0
  93. package/apps/octogent/apps/web/src/app/conversationNormalizers.ts +135 -0
  94. package/apps/octogent/apps/web/src/app/formatTimestamp.ts +18 -0
  95. package/apps/octogent/apps/web/src/app/githubMetrics.ts +76 -0
  96. package/apps/octogent/apps/web/src/app/githubNormalizers.ts +91 -0
  97. package/apps/octogent/apps/web/src/app/hooks/useAgentRuntimeStates.ts +18 -0
  98. package/apps/octogent/apps/web/src/app/hooks/useBackendLivenessPolling.ts +53 -0
  99. package/apps/octogent/apps/web/src/app/hooks/useCanvasGraphData.ts +449 -0
  100. package/apps/octogent/apps/web/src/app/hooks/useCanvasTransform.ts +260 -0
  101. package/apps/octogent/apps/web/src/app/hooks/useClaudeUsagePolling.ts +40 -0
  102. package/apps/octogent/apps/web/src/app/hooks/useClickOutside.ts +30 -0
  103. package/apps/octogent/apps/web/src/app/hooks/useCodeIntelRuntime.ts +83 -0
  104. package/apps/octogent/apps/web/src/app/hooks/useCodexUsagePolling.ts +35 -0
  105. package/apps/octogent/apps/web/src/app/hooks/useConsoleKeyboardShortcuts.ts +31 -0
  106. package/apps/octogent/apps/web/src/app/hooks/useConversationsRuntime.ts +377 -0
  107. package/apps/octogent/apps/web/src/app/hooks/useForceSimulation.ts +319 -0
  108. package/apps/octogent/apps/web/src/app/hooks/useGitHubPrimaryViewModel.ts +143 -0
  109. package/apps/octogent/apps/web/src/app/hooks/useGithubSummaryPolling.ts +28 -0
  110. package/apps/octogent/apps/web/src/app/hooks/useInitialColumnsHydration.ts +64 -0
  111. package/apps/octogent/apps/web/src/app/hooks/useMonitorRuntime.ts +220 -0
  112. package/apps/octogent/apps/web/src/app/hooks/usePersistedUiState.ts +536 -0
  113. package/apps/octogent/apps/web/src/app/hooks/usePollingData.ts +79 -0
  114. package/apps/octogent/apps/web/src/app/hooks/usePromptLibrary.ts +185 -0
  115. package/apps/octogent/apps/web/src/app/hooks/useTentacleGitLifecycle.ts +530 -0
  116. package/apps/octogent/apps/web/src/app/hooks/useTerminalCompletionNotification.ts +94 -0
  117. package/apps/octogent/apps/web/src/app/hooks/useTerminalMutations.ts +266 -0
  118. package/apps/octogent/apps/web/src/app/hooks/useTerminalStateReconciliation.ts +23 -0
  119. package/apps/octogent/apps/web/src/app/hooks/useUsageHeatmapPolling.ts +43 -0
  120. package/apps/octogent/apps/web/src/app/hooks/useWorkspaceSetup.ts +80 -0
  121. package/apps/octogent/apps/web/src/app/hotkeys.ts +31 -0
  122. package/apps/octogent/apps/web/src/app/monitorNormalizers.ts +145 -0
  123. package/apps/octogent/apps/web/src/app/notificationSounds.ts +164 -0
  124. package/apps/octogent/apps/web/src/app/terminalRuntimeStateStore.ts +261 -0
  125. package/apps/octogent/apps/web/src/app/terminalState.ts +21 -0
  126. package/apps/octogent/apps/web/src/app/types.ts +42 -0
  127. package/apps/octogent/apps/web/src/app/uiStateNormalizers.ts +113 -0
  128. package/apps/octogent/apps/web/src/app/usageNormalizers.ts +58 -0
  129. package/apps/octogent/apps/web/src/components/ActiveAgentsSidebar.tsx +60 -0
  130. package/apps/octogent/apps/web/src/components/ActivityPrimaryView.tsx +21 -0
  131. package/apps/octogent/apps/web/src/components/AgentStateBadge.tsx +47 -0
  132. package/apps/octogent/apps/web/src/components/CanvasPrimaryView.tsx +1532 -0
  133. package/apps/octogent/apps/web/src/components/ClearAllConversationsDialog.tsx +33 -0
  134. package/apps/octogent/apps/web/src/components/CodeIntelArcDiagram.tsx +245 -0
  135. package/apps/octogent/apps/web/src/components/CodeIntelPrimaryView.tsx +104 -0
  136. package/apps/octogent/apps/web/src/components/CodeIntelTreemap.tsx +138 -0
  137. package/apps/octogent/apps/web/src/components/ConsolePrimaryNav.tsx +31 -0
  138. package/apps/octogent/apps/web/src/components/ConversationsPrimaryView.tsx +243 -0
  139. package/apps/octogent/apps/web/src/components/DeckPrimaryView.tsx +613 -0
  140. package/apps/octogent/apps/web/src/components/DeleteTentacleDialog.tsx +91 -0
  141. package/apps/octogent/apps/web/src/components/EmptyOctopus.tsx +715 -0
  142. package/apps/octogent/apps/web/src/components/GitHubPrimaryView.tsx +494 -0
  143. package/apps/octogent/apps/web/src/components/MonitorPrimaryView.tsx +475 -0
  144. package/apps/octogent/apps/web/src/components/PrimaryViewRouter.tsx +99 -0
  145. package/apps/octogent/apps/web/src/components/PromptsPrimaryView.tsx +243 -0
  146. package/apps/octogent/apps/web/src/components/RuntimeStatusStrip.tsx +273 -0
  147. package/apps/octogent/apps/web/src/components/SettingsPrimaryView.tsx +92 -0
  148. package/apps/octogent/apps/web/src/components/SidebarActionPanel.tsx +124 -0
  149. package/apps/octogent/apps/web/src/components/SidebarConversationsList.tsx +279 -0
  150. package/apps/octogent/apps/web/src/components/SidebarPromptsList.tsx +116 -0
  151. package/apps/octogent/apps/web/src/components/TelemetryTape.tsx +106 -0
  152. package/apps/octogent/apps/web/src/components/TentacleGitActionsDialog.tsx +341 -0
  153. package/apps/octogent/apps/web/src/components/Terminal.tsx +524 -0
  154. package/apps/octogent/apps/web/src/components/TerminalPromptPicker.tsx +140 -0
  155. package/apps/octogent/apps/web/src/components/UsageHeatmap.tsx +702 -0
  156. package/apps/octogent/apps/web/src/components/canvas/CanvasTentaclePanel.tsx +485 -0
  157. package/apps/octogent/apps/web/src/components/canvas/CanvasTerminalColumn.tsx +89 -0
  158. package/apps/octogent/apps/web/src/components/canvas/DeleteAllTerminalsDialog.tsx +221 -0
  159. package/apps/octogent/apps/web/src/components/canvas/OctopusNode.tsx +307 -0
  160. package/apps/octogent/apps/web/src/components/canvas/SessionNode.tsx +185 -0
  161. package/apps/octogent/apps/web/src/components/deck/ActionCards.tsx +118 -0
  162. package/apps/octogent/apps/web/src/components/deck/AddTentacleForm.tsx +269 -0
  163. package/apps/octogent/apps/web/src/components/deck/DeckBottomActions.tsx +56 -0
  164. package/apps/octogent/apps/web/src/components/deck/TentaclePod.tsx +334 -0
  165. package/apps/octogent/apps/web/src/components/deck/WorkspaceSetupCard.tsx +105 -0
  166. package/apps/octogent/apps/web/src/components/deck/octopusVisuals.ts +72 -0
  167. package/apps/octogent/apps/web/src/components/terminalReplay.ts +62 -0
  168. package/apps/octogent/apps/web/src/components/terminalWheel.ts +54 -0
  169. package/apps/octogent/apps/web/src/components/ui/ActionButton.tsx +34 -0
  170. package/apps/octogent/apps/web/src/components/ui/ConfirmationDialog.tsx +86 -0
  171. package/apps/octogent/apps/web/src/components/ui/MarkdownContent.tsx +43 -0
  172. package/apps/octogent/apps/web/src/components/ui/SettingsToggle.tsx +34 -0
  173. package/apps/octogent/apps/web/src/components/ui/StatusBadge.tsx +24 -0
  174. package/apps/octogent/apps/web/src/main.tsx +17 -0
  175. package/apps/octogent/apps/web/src/runtime/HttpTerminalSnapshotReader.ts +87 -0
  176. package/apps/octogent/apps/web/src/runtime/runtimeEndpoints.ts +412 -0
  177. package/apps/octogent/apps/web/src/styles/chrome-and-buttons.css +272 -0
  178. package/apps/octogent/apps/web/src/styles/console-canvas-activity.css +358 -0
  179. package/apps/octogent/apps/web/src/styles/console-canvas-canvas.css +1843 -0
  180. package/apps/octogent/apps/web/src/styles/console-canvas-code-intel.css +227 -0
  181. package/apps/octogent/apps/web/src/styles/console-canvas-conversations.css +705 -0
  182. package/apps/octogent/apps/web/src/styles/console-canvas-deck.css +1524 -0
  183. package/apps/octogent/apps/web/src/styles/console-canvas-github.css +541 -0
  184. package/apps/octogent/apps/web/src/styles/console-canvas-monitor.css +595 -0
  185. package/apps/octogent/apps/web/src/styles/console-canvas-pixpack.css +81 -0
  186. package/apps/octogent/apps/web/src/styles/console-canvas-prompts.css +474 -0
  187. package/apps/octogent/apps/web/src/styles/console-canvas-settings.css +207 -0
  188. package/apps/octogent/apps/web/src/styles/console-chrome-status-nav.css +441 -0
  189. package/apps/octogent/apps/web/src/styles/console-overrides-telemetry.css +320 -0
  190. package/apps/octogent/apps/web/src/styles/console-theme-tokens.css +25 -0
  191. package/apps/octogent/apps/web/src/styles/cortex-theme.css +412 -0
  192. package/apps/octogent/apps/web/src/styles/foundation.css +100 -0
  193. package/apps/octogent/apps/web/src/styles/sidebar-and-scrollbars.css +447 -0
  194. package/apps/octogent/apps/web/src/styles/terminal-and-status.css +356 -0
  195. package/apps/octogent/apps/web/src/styles.css +25 -0
  196. package/apps/octogent/apps/web/src/types/ws.d.ts +23 -0
  197. package/apps/octogent/apps/web/tests/CanvasPrimaryView.test.tsx +347 -0
  198. package/apps/octogent/apps/web/tests/HttpTerminalSnapshotReader.test.tsx +54 -0
  199. package/apps/octogent/apps/web/tests/RuntimeStatusStrip.test.tsx +70 -0
  200. package/apps/octogent/apps/web/tests/Terminal.test.tsx +87 -0
  201. package/apps/octogent/apps/web/tests/add-tentacle-form.test.tsx +48 -0
  202. package/apps/octogent/apps/web/tests/app-github-runtime.test.tsx +162 -0
  203. package/apps/octogent/apps/web/tests/app-monitor-runtime.test.tsx +657 -0
  204. package/apps/octogent/apps/web/tests/app-shell-navigation.test.tsx +109 -0
  205. package/apps/octogent/apps/web/tests/app-swarm-refresh.test.tsx +268 -0
  206. package/apps/octogent/apps/web/tests/app-ui-state-persistence.test.tsx +116 -0
  207. package/apps/octogent/apps/web/tests/app-workspace-setup.test.tsx +217 -0
  208. package/apps/octogent/apps/web/tests/canvas-tentacle-panel.test.tsx +195 -0
  209. package/apps/octogent/apps/web/tests/delete-all-terminals-dialog.test.tsx +76 -0
  210. package/apps/octogent/apps/web/tests/githubMetrics.test.tsx +52 -0
  211. package/apps/octogent/apps/web/tests/hotkeys.test.tsx +44 -0
  212. package/apps/octogent/apps/web/tests/runtimeEndpoints.test.tsx +240 -0
  213. package/apps/octogent/apps/web/tests/setup.ts +39 -0
  214. package/apps/octogent/apps/web/tests/tentacle-pod.test.tsx +62 -0
  215. package/apps/octogent/apps/web/tests/terminalReplay.test.ts +71 -0
  216. package/apps/octogent/apps/web/tests/terminalState.test.tsx +49 -0
  217. package/apps/octogent/apps/web/tests/terminalWheel.test.tsx +51 -0
  218. package/apps/octogent/apps/web/tests/test-utils/appTestHarness.ts +48 -0
  219. package/apps/octogent/apps/web/tests/uiPrimitives.test.tsx +31 -0
  220. package/apps/octogent/apps/web/tests/useAgentRuntimeStates.test.tsx +47 -0
  221. package/apps/octogent/apps/web/tsconfig.json +8 -0
  222. package/apps/octogent/apps/web/vite.api.bundle.config.mts +32 -0
  223. package/apps/octogent/apps/web/vite.config.ts +22 -0
  224. package/apps/octogent/bin/octogent +3 -0
  225. package/apps/octogent/biome.json +21 -0
  226. package/apps/octogent/docs/concepts/mental-model.md +79 -0
  227. package/apps/octogent/docs/concepts/runtime-and-api.md +60 -0
  228. package/apps/octogent/docs/concepts/tentacles.md +85 -0
  229. package/apps/octogent/docs/getting-started/installation.md +54 -0
  230. package/apps/octogent/docs/getting-started/quickstart.md +79 -0
  231. package/apps/octogent/docs/guides/inter-agent-messaging.md +43 -0
  232. package/apps/octogent/docs/guides/orchestrating-child-agents.md +49 -0
  233. package/apps/octogent/docs/guides/working-with-todos.md +56 -0
  234. package/apps/octogent/docs/index.md +40 -0
  235. package/apps/octogent/docs/reference/api.md +103 -0
  236. package/apps/octogent/docs/reference/cli.md +71 -0
  237. package/apps/octogent/docs/reference/experimental-features.md +28 -0
  238. package/apps/octogent/docs/reference/filesystem-layout.md +62 -0
  239. package/apps/octogent/docs/reference/troubleshooting.md +49 -0
  240. package/apps/octogent/package.json +35 -0
  241. package/apps/octogent/packages/core/AGENTS.md +31 -0
  242. package/apps/octogent/packages/core/package.json +12 -0
  243. package/apps/octogent/packages/core/src/adapters/InMemoryTerminalSnapshotReader.ts +10 -0
  244. package/apps/octogent/packages/core/src/application/buildTerminalList.ts +13 -0
  245. package/apps/octogent/packages/core/src/domain/agentRuntime.ts +18 -0
  246. package/apps/octogent/packages/core/src/domain/channel.ts +8 -0
  247. package/apps/octogent/packages/core/src/domain/completionSound.ts +14 -0
  248. package/apps/octogent/packages/core/src/domain/conversation.ts +48 -0
  249. package/apps/octogent/packages/core/src/domain/deck.ts +33 -0
  250. package/apps/octogent/packages/core/src/domain/git.ts +32 -0
  251. package/apps/octogent/packages/core/src/domain/monitor.ts +62 -0
  252. package/apps/octogent/packages/core/src/domain/setup.ts +27 -0
  253. package/apps/octogent/packages/core/src/domain/terminal.ts +17 -0
  254. package/apps/octogent/packages/core/src/domain/uiState.ts +22 -0
  255. package/apps/octogent/packages/core/src/domain/usage.ts +60 -0
  256. package/apps/octogent/packages/core/src/index.ts +15 -0
  257. package/apps/octogent/packages/core/src/ports/TerminalSnapshotReader.ts +5 -0
  258. package/apps/octogent/packages/core/src/util/typeCoercion.ts +20 -0
  259. package/apps/octogent/packages/core/tests/buildTerminalList.test.ts +75 -0
  260. package/apps/octogent/packages/core/tsconfig.json +7 -0
  261. package/apps/octogent/packages/core/tsconfig.tsbuildinfo +1 -0
  262. package/apps/octogent/packages/core/vitest.config.ts +7 -0
  263. package/apps/octogent/pnpm-lock.yaml +3212 -0
  264. package/apps/octogent/pnpm-workspace.yaml +3 -0
  265. package/apps/octogent/prompts/meta-prompt-generator.md +223 -0
  266. package/apps/octogent/prompts/octoboss-clean-contexts.md +30 -0
  267. package/apps/octogent/prompts/octoboss-reorganize-tentacles.md +29 -0
  268. package/apps/octogent/prompts/octoboss-reorganize-todos.md +27 -0
  269. package/apps/octogent/prompts/sandbox-init.md +3 -0
  270. package/apps/octogent/prompts/swarm-parent.md +83 -0
  271. package/apps/octogent/prompts/swarm-worker.md +50 -0
  272. package/apps/octogent/prompts/tentacle-context-init.md +1 -0
  273. package/apps/octogent/prompts/tentacle-planner.md +110 -0
  274. package/apps/octogent/prompts/tentacle-reorganize-todos.md +20 -0
  275. package/apps/octogent/prompts/tentacle-update-tentacle.md +18 -0
  276. package/apps/octogent/scripts/build-package.mjs +23 -0
  277. package/apps/octogent/scripts/dev.mjs +158 -0
  278. package/apps/octogent/scripts/smoke-public-install.mjs +271 -0
  279. package/apps/octogent/static/images/octogent-header.png +0 -0
  280. package/apps/octogent/static/images/preview_1.jpg +0 -0
  281. package/apps/octogent/static/images/preview_2.jpg +0 -0
  282. package/apps/octogent/static/images/preview_3.jpg +0 -0
  283. package/apps/octogent/static/images/preview_4.jpg +0 -0
  284. package/apps/octogent/static/images/preview_5.jpg +0 -0
  285. package/apps/octogent/static/images/preview_6.jpg +0 -0
  286. package/apps/octogent/tsconfig.base.json +16 -0
  287. package/bin/AGI +3 -0
  288. package/bin/AGI-install-app +71 -0
  289. package/bin/AGI-ui +16 -0
  290. package/bin/AGI-voice +15 -0
  291. package/bin/AGI-web +16 -0
  292. package/bin/cortex +109 -0
  293. package/bin/cortex-octogent +99 -0
  294. package/bin/import-specifier.mjs +13 -0
  295. package/bin/import-specifier.test.mjs +13 -0
  296. package/bin/octo +150 -0
  297. package/dist/cli.mjs +555650 -0
  298. package/package.json +157 -0
  299. package/scripts/setup-wizard.ts +390 -0
@@ -0,0 +1,240 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import {
4
+ buildClaudeUsageUrl,
5
+ buildCodexUsageUrl,
6
+ buildConversationExportUrl,
7
+ buildConversationSessionUrl,
8
+ buildConversationsUrl,
9
+ buildGithubSummaryUrl,
10
+ buildMonitorConfigUrl,
11
+ buildMonitorFeedUrl,
12
+ buildMonitorRefreshUrl,
13
+ buildTentacleGitCommitUrl,
14
+ buildTentacleGitPullRequestMergeUrl,
15
+ buildTentacleGitPullRequestUrl,
16
+ buildTentacleGitPushUrl,
17
+ buildTentacleGitStatusUrl,
18
+ buildTentacleGitSyncUrl,
19
+ buildTentacleRenameUrl,
20
+ buildTerminalEventsSocketUrl,
21
+ buildTerminalSnapshotsUrl,
22
+ buildTerminalSocketUrl,
23
+ buildTerminalsUrl,
24
+ buildUiStateUrl,
25
+ buildWorkspaceSetupStepUrl,
26
+ buildWorkspaceSetupUrl,
27
+ } from "../src/runtime/runtimeEndpoints";
28
+
29
+ describe("runtimeEndpoints", () => {
30
+ it("returns same-origin API path when runtime base URL is not configured", () => {
31
+ expect(buildTerminalSnapshotsUrl()).toBe("/api/terminal-snapshots");
32
+ });
33
+
34
+ it("builds absolute API URL when runtime base URL is configured", () => {
35
+ expect(buildTerminalSnapshotsUrl("https://runtime.example.com")).toBe(
36
+ "https://runtime.example.com/api/terminal-snapshots",
37
+ );
38
+ });
39
+
40
+ it("builds terminal creation URL on same origin by default", () => {
41
+ expect(buildTerminalsUrl()).toBe("/api/terminals");
42
+ });
43
+
44
+ it("builds absolute terminal creation URL when runtime base URL is configured", () => {
45
+ expect(buildTerminalsUrl("https://runtime.example.com")).toBe(
46
+ "https://runtime.example.com/api/terminals",
47
+ );
48
+ });
49
+
50
+ it("builds codex usage URL on same origin by default", () => {
51
+ expect(buildCodexUsageUrl()).toBe("/api/codex/usage");
52
+ });
53
+
54
+ it("builds absolute codex usage URL when runtime base URL is configured", () => {
55
+ expect(buildCodexUsageUrl("https://runtime.example.com")).toBe(
56
+ "https://runtime.example.com/api/codex/usage",
57
+ );
58
+ });
59
+
60
+ it("builds claude usage URL on same origin by default", () => {
61
+ expect(buildClaudeUsageUrl()).toBe("/api/claude/usage");
62
+ });
63
+
64
+ it("builds absolute claude usage URL when runtime base URL is configured", () => {
65
+ expect(buildClaudeUsageUrl("https://runtime.example.com")).toBe(
66
+ "https://runtime.example.com/api/claude/usage",
67
+ );
68
+ });
69
+
70
+ it("builds github summary URL on same origin by default", () => {
71
+ expect(buildGithubSummaryUrl()).toBe("/api/github/summary");
72
+ });
73
+
74
+ it("builds absolute github summary URL when runtime base URL is configured", () => {
75
+ expect(buildGithubSummaryUrl("https://runtime.example.com")).toBe(
76
+ "https://runtime.example.com/api/github/summary",
77
+ );
78
+ });
79
+
80
+ it("builds monitor config URL on same origin by default", () => {
81
+ expect(buildMonitorConfigUrl()).toBe("/api/monitor/config");
82
+ });
83
+
84
+ it("builds monitor feed URL on same origin by default", () => {
85
+ expect(buildMonitorFeedUrl()).toBe("/api/monitor/feed");
86
+ });
87
+
88
+ it("builds monitor refresh URL on same origin by default", () => {
89
+ expect(buildMonitorRefreshUrl()).toBe("/api/monitor/refresh");
90
+ });
91
+
92
+ it("builds conversations URLs on same origin by default", () => {
93
+ expect(buildConversationsUrl()).toBe("/api/conversations");
94
+ expect(buildConversationSessionUrl("tentacle-1-root")).toBe(
95
+ "/api/conversations/tentacle-1-root",
96
+ );
97
+ expect(buildConversationExportUrl("tentacle-1-root", "json")).toBe(
98
+ "/api/conversations/tentacle-1-root/export?format=json",
99
+ );
100
+ expect(buildConversationExportUrl("tentacle-1-root", "md")).toBe(
101
+ "/api/conversations/tentacle-1-root/export?format=md",
102
+ );
103
+ });
104
+
105
+ it("builds absolute conversations URLs when runtime base URL is configured", () => {
106
+ expect(buildConversationsUrl("https://runtime.example.com")).toBe(
107
+ "https://runtime.example.com/api/conversations",
108
+ );
109
+ expect(buildConversationSessionUrl("tentacle-1-root", "https://runtime.example.com")).toBe(
110
+ "https://runtime.example.com/api/conversations/tentacle-1-root",
111
+ );
112
+ expect(
113
+ buildConversationExportUrl("tentacle-1-root", "json", "https://runtime.example.com"),
114
+ ).toBe("https://runtime.example.com/api/conversations/tentacle-1-root/export?format=json");
115
+ });
116
+
117
+ it("builds absolute monitor URLs when runtime base URL is configured", () => {
118
+ expect(buildMonitorConfigUrl("https://runtime.example.com")).toBe(
119
+ "https://runtime.example.com/api/monitor/config",
120
+ );
121
+ expect(buildMonitorFeedUrl("https://runtime.example.com")).toBe(
122
+ "https://runtime.example.com/api/monitor/feed",
123
+ );
124
+ expect(buildMonitorRefreshUrl("https://runtime.example.com")).toBe(
125
+ "https://runtime.example.com/api/monitor/refresh",
126
+ );
127
+ });
128
+
129
+ it("builds ui state URL on same origin by default", () => {
130
+ expect(buildUiStateUrl()).toBe("/api/ui-state");
131
+ });
132
+
133
+ it("builds absolute ui state URL when runtime base URL is configured", () => {
134
+ expect(buildUiStateUrl("https://runtime.example.com")).toBe(
135
+ "https://runtime.example.com/api/ui-state",
136
+ );
137
+ });
138
+
139
+ it("builds workspace setup URLs on same origin by default", () => {
140
+ expect(buildWorkspaceSetupUrl()).toBe("/api/setup");
141
+ expect(buildWorkspaceSetupStepUrl("ensure-gitignore")).toBe(
142
+ "/api/setup/steps/ensure-gitignore",
143
+ );
144
+ });
145
+
146
+ it("builds absolute workspace setup URLs when runtime base URL is configured", () => {
147
+ expect(buildWorkspaceSetupUrl("https://runtime.example.com")).toBe(
148
+ "https://runtime.example.com/api/setup",
149
+ );
150
+ expect(buildWorkspaceSetupStepUrl("ensure-gitignore", "https://runtime.example.com")).toBe(
151
+ "https://runtime.example.com/api/setup/steps/ensure-gitignore",
152
+ );
153
+ });
154
+
155
+ it("builds tentacle rename URL on same origin by default", () => {
156
+ expect(buildTentacleRenameUrl("tentacle-main")).toBe("/api/tentacles/tentacle-main");
157
+ });
158
+
159
+ it("builds absolute tentacle rename URL when runtime base URL is configured", () => {
160
+ expect(buildTentacleRenameUrl("tentacle-main", "https://runtime.example.com")).toBe(
161
+ "https://runtime.example.com/api/tentacles/tentacle-main",
162
+ );
163
+ });
164
+
165
+ it("builds tentacle git lifecycle URLs on same origin by default", () => {
166
+ expect(buildTentacleGitStatusUrl("tentacle-main")).toBe(
167
+ "/api/tentacles/tentacle-main/git/status",
168
+ );
169
+ expect(buildTentacleGitCommitUrl("tentacle-main")).toBe(
170
+ "/api/tentacles/tentacle-main/git/commit",
171
+ );
172
+ expect(buildTentacleGitPushUrl("tentacle-main")).toBe("/api/tentacles/tentacle-main/git/push");
173
+ expect(buildTentacleGitSyncUrl("tentacle-main")).toBe("/api/tentacles/tentacle-main/git/sync");
174
+ expect(buildTentacleGitPullRequestUrl("tentacle-main")).toBe(
175
+ "/api/tentacles/tentacle-main/git/pr",
176
+ );
177
+ expect(buildTentacleGitPullRequestMergeUrl("tentacle-main")).toBe(
178
+ "/api/tentacles/tentacle-main/git/pr/merge",
179
+ );
180
+ });
181
+
182
+ it("builds absolute tentacle git lifecycle URLs when runtime base URL is configured", () => {
183
+ expect(buildTentacleGitStatusUrl("tentacle-main", "https://runtime.example.com")).toBe(
184
+ "https://runtime.example.com/api/tentacles/tentacle-main/git/status",
185
+ );
186
+ expect(buildTentacleGitCommitUrl("tentacle-main", "https://runtime.example.com")).toBe(
187
+ "https://runtime.example.com/api/tentacles/tentacle-main/git/commit",
188
+ );
189
+ expect(buildTentacleGitPushUrl("tentacle-main", "https://runtime.example.com")).toBe(
190
+ "https://runtime.example.com/api/tentacles/tentacle-main/git/push",
191
+ );
192
+ expect(buildTentacleGitSyncUrl("tentacle-main", "https://runtime.example.com")).toBe(
193
+ "https://runtime.example.com/api/tentacles/tentacle-main/git/sync",
194
+ );
195
+ expect(buildTentacleGitPullRequestUrl("tentacle-main", "https://runtime.example.com")).toBe(
196
+ "https://runtime.example.com/api/tentacles/tentacle-main/git/pr",
197
+ );
198
+ expect(
199
+ buildTentacleGitPullRequestMergeUrl("tentacle-main", "https://runtime.example.com"),
200
+ ).toBe("https://runtime.example.com/api/tentacles/tentacle-main/git/pr/merge");
201
+ });
202
+
203
+ it("builds same-origin websocket URL by default", () => {
204
+ expect(
205
+ buildTerminalSocketUrl(
206
+ "tentacle-main",
207
+ undefined,
208
+ new URL("https://workspace.example.com/dashboard") as unknown as Location,
209
+ ),
210
+ ).toBe("wss://workspace.example.com/api/terminals/tentacle-main/ws");
211
+ });
212
+
213
+ it("builds websocket URL from configured runtime base URL", () => {
214
+ expect(
215
+ buildTerminalSocketUrl(
216
+ "tentacle-main",
217
+ "http://127.0.0.1:8787",
218
+ new URL("https://workspace.example.com/dashboard") as unknown as Location,
219
+ ),
220
+ ).toBe("ws://127.0.0.1:8787/api/terminals/tentacle-main/ws");
221
+ });
222
+
223
+ it("builds same-origin terminal events websocket URL by default", () => {
224
+ expect(
225
+ buildTerminalEventsSocketUrl(
226
+ undefined,
227
+ new URL("https://workspace.example.com/dashboard") as unknown as Location,
228
+ ),
229
+ ).toBe("wss://workspace.example.com/api/terminal-events/ws");
230
+ });
231
+
232
+ it("builds terminal events websocket URL from configured runtime base URL", () => {
233
+ expect(
234
+ buildTerminalEventsSocketUrl(
235
+ "http://127.0.0.1:8787",
236
+ new URL("https://workspace.example.com/dashboard") as unknown as Location,
237
+ ),
238
+ ).toBe("ws://127.0.0.1:8787/api/terminal-events/ws");
239
+ });
240
+ });
@@ -0,0 +1,39 @@
1
+ import "@testing-library/jest-dom/vitest";
2
+ import { cleanup } from "@testing-library/react";
3
+ import { afterEach } from "vitest";
4
+
5
+ import { MockWebSocket } from "./test-utils/appTestHarness";
6
+
7
+ afterEach(() => {
8
+ cleanup();
9
+ });
10
+
11
+ globalThis.ResizeObserver = class ResizeObserver {
12
+ observe() {}
13
+ unobserve() {}
14
+ disconnect() {}
15
+ };
16
+
17
+ const canvasContextStub = {
18
+ imageSmoothingEnabled: true,
19
+ clearRect() {},
20
+ fillRect() {},
21
+ save() {},
22
+ restore() {},
23
+ beginPath() {},
24
+ moveTo() {},
25
+ quadraticCurveTo() {},
26
+ lineTo() {},
27
+ closePath() {},
28
+ stroke() {},
29
+ fill() {},
30
+ ellipse() {},
31
+ arc() {},
32
+ };
33
+
34
+ Object.defineProperty(HTMLCanvasElement.prototype, "getContext", {
35
+ configurable: true,
36
+ value: () => canvasContextStub,
37
+ });
38
+
39
+ globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
@@ -0,0 +1,62 @@
1
+ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
2
+ import { describe, expect, it, vi } from "vitest";
3
+
4
+ import { TentaclePod } from "../src/components/deck/TentaclePod";
5
+
6
+ describe("TentaclePod skill editor", () => {
7
+ it("saves suggested skills from the deck pod", async () => {
8
+ const onSaveSuggestedSkills = vi.fn().mockResolvedValue(true);
9
+
10
+ render(
11
+ <TentaclePod
12
+ tentacle={{
13
+ tentacleId: "docs",
14
+ displayName: "Docs",
15
+ description: "Docs and knowledge.",
16
+ status: "idle",
17
+ color: "#ff6b2b",
18
+ octopus: {
19
+ animation: null,
20
+ expression: null,
21
+ accessory: null,
22
+ hairColor: null,
23
+ },
24
+ scope: { paths: [], tags: [] },
25
+ vaultFiles: ["todo.md"],
26
+ todoTotal: 0,
27
+ todoDone: 0,
28
+ todoItems: [],
29
+ suggestedSkills: ["docs-writer"],
30
+ }}
31
+ visuals={{
32
+ color: "#ff6b2b",
33
+ animation: "sway",
34
+ expression: "happy",
35
+ accessory: "none",
36
+ }}
37
+ isFocused={false}
38
+ availableSkills={[
39
+ {
40
+ name: "docs-writer",
41
+ description: "Keeps docs aligned with the product.",
42
+ source: "project",
43
+ },
44
+ {
45
+ name: "release-helper",
46
+ description: "Helps with release coordination.",
47
+ source: "user",
48
+ },
49
+ ]}
50
+ onSaveSuggestedSkills={onSaveSuggestedSkills}
51
+ />,
52
+ );
53
+
54
+ fireEvent.click(screen.getByRole("button", { name: "Skills" }));
55
+ fireEvent.click(screen.getByLabelText(/release-helper/i));
56
+ fireEvent.click(screen.getByRole("button", { name: /save skills/i }));
57
+
58
+ await waitFor(() => {
59
+ expect(onSaveSuggestedSkills).toHaveBeenCalledWith("docs", ["docs-writer", "release-helper"]);
60
+ });
61
+ });
62
+ });
@@ -0,0 +1,71 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+
3
+ import { replayTerminalHistory } from "../src/components/terminalReplay";
4
+
5
+ describe("replayTerminalHistory", () => {
6
+ it("clears selection and restores the previous scroll position after replay", () => {
7
+ const reset = vi.fn();
8
+ const clearSelection = vi.fn();
9
+ const refresh = vi.fn();
10
+ const terminal = {
11
+ reset,
12
+ clearSelection,
13
+ refresh,
14
+ rows: 24,
15
+ write: vi.fn((_: string, callback?: () => void) => {
16
+ callback?.();
17
+ }),
18
+ };
19
+ const viewport = {
20
+ clientHeight: 120,
21
+ scrollHeight: 1_400,
22
+ scrollTop: 360,
23
+ };
24
+ const requestAnimationFrameSpy = vi
25
+ .spyOn(window, "requestAnimationFrame")
26
+ .mockImplementation((callback: FrameRequestCallback) => {
27
+ callback(0);
28
+ return 1;
29
+ });
30
+
31
+ replayTerminalHistory(terminal, "history payload", viewport);
32
+
33
+ expect(clearSelection).toHaveBeenCalledTimes(2);
34
+ expect(reset).toHaveBeenCalledTimes(1);
35
+ expect(terminal.write).toHaveBeenCalledWith("history payload", expect.any(Function));
36
+ expect(refresh).toHaveBeenCalledWith(0, 23);
37
+ expect(viewport.scrollTop).toBe(360);
38
+
39
+ requestAnimationFrameSpy.mockRestore();
40
+ });
41
+
42
+ it("pins the viewport to the bottom when it was already near the bottom", () => {
43
+ const terminal = {
44
+ reset: vi.fn(),
45
+ clearSelection: vi.fn(),
46
+ refresh: vi.fn(),
47
+ rows: 30,
48
+ write: vi.fn((_: string, callback?: () => void) => {
49
+ callback?.();
50
+ }),
51
+ };
52
+ const viewport = {
53
+ clientHeight: 300,
54
+ scrollHeight: 910,
55
+ scrollTop: 604,
56
+ };
57
+ const requestAnimationFrameSpy = vi
58
+ .spyOn(window, "requestAnimationFrame")
59
+ .mockImplementation((callback: FrameRequestCallback) => {
60
+ viewport.scrollHeight = 1_280;
61
+ callback(0);
62
+ return 1;
63
+ });
64
+
65
+ replayTerminalHistory(terminal, "history payload", viewport);
66
+
67
+ expect(viewport.scrollTop).toBe(1_280);
68
+
69
+ requestAnimationFrameSpy.mockRestore();
70
+ });
71
+ });
@@ -0,0 +1,49 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { retainActiveTerminalEntries, retainActiveTerminalIds } from "../src/app/terminalState";
4
+
5
+ describe("terminalState helpers", () => {
6
+ it("retains active terminal ids and preserves reference when unchanged", () => {
7
+ const currentTerminalIds = ["tentacle-1", "tentacle-2"];
8
+ const activeTerminalIds = new Set(["tentacle-1", "tentacle-2", "tentacle-3"]);
9
+
10
+ const nextTerminalIds = retainActiveTerminalIds(currentTerminalIds, activeTerminalIds);
11
+
12
+ expect(nextTerminalIds).toBe(currentTerminalIds);
13
+ });
14
+
15
+ it("filters removed terminal ids", () => {
16
+ const currentTerminalIds = ["tentacle-1", "tentacle-2"];
17
+ const activeTerminalIds = new Set(["tentacle-2"]);
18
+
19
+ const nextTerminalIds = retainActiveTerminalIds(currentTerminalIds, activeTerminalIds);
20
+
21
+ expect(nextTerminalIds).toEqual(["tentacle-2"]);
22
+ });
23
+
24
+ it("retains active terminal state entries and preserves reference when unchanged", () => {
25
+ const currentState = {
26
+ "tentacle-1": "idle",
27
+ "tentacle-2": "processing",
28
+ };
29
+ const activeTerminalIds = new Set(["tentacle-1", "tentacle-2"]);
30
+
31
+ const nextState = retainActiveTerminalEntries(currentState, activeTerminalIds);
32
+
33
+ expect(nextState).toBe(currentState);
34
+ });
35
+
36
+ it("filters removed terminal state entries", () => {
37
+ const currentState = {
38
+ "tentacle-1": "idle",
39
+ "tentacle-2": "processing",
40
+ };
41
+ const activeTerminalIds = new Set(["tentacle-2"]);
42
+
43
+ const nextState = retainActiveTerminalEntries(currentState, activeTerminalIds);
44
+
45
+ expect(nextState).toEqual({
46
+ "tentacle-2": "processing",
47
+ });
48
+ });
49
+ });
@@ -0,0 +1,51 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import {
4
+ readViewportY,
5
+ shouldUseManualWheelScroll,
6
+ wheelDeltaToScrollLines,
7
+ } from "../src/components/terminalWheel";
8
+
9
+ describe("wheelDeltaToScrollLines", () => {
10
+ it("returns zero for invalid or neutral wheel deltas", () => {
11
+ expect(wheelDeltaToScrollLines(0, WheelEvent.DOM_DELTA_PIXEL)).toBe(0);
12
+ expect(wheelDeltaToScrollLines(Number.NaN, WheelEvent.DOM_DELTA_PIXEL)).toBe(0);
13
+ });
14
+
15
+ it("converts pixel wheel delta to signed terminal lines", () => {
16
+ expect(wheelDeltaToScrollLines(120, WheelEvent.DOM_DELTA_PIXEL)).toBe(3);
17
+ expect(wheelDeltaToScrollLines(-120, WheelEvent.DOM_DELTA_PIXEL)).toBe(-3);
18
+ });
19
+
20
+ it("converts line/page delta modes to sensible line movement", () => {
21
+ expect(wheelDeltaToScrollLines(3, WheelEvent.DOM_DELTA_LINE)).toBe(1);
22
+ expect(wheelDeltaToScrollLines(1, WheelEvent.DOM_DELTA_PAGE)).toBe(4);
23
+ });
24
+ });
25
+
26
+ describe("shouldUseManualWheelScroll", () => {
27
+ it("returns false for alternate-screen buffers", () => {
28
+ expect(shouldUseManualWheelScroll({ baseY: 100, type: "alternate" })).toBe(false);
29
+ });
30
+
31
+ it("returns false when there is no scrollback history", () => {
32
+ expect(shouldUseManualWheelScroll({ baseY: 0, type: "normal" })).toBe(false);
33
+ expect(shouldUseManualWheelScroll({ type: "normal" })).toBe(false);
34
+ });
35
+
36
+ it("returns true for normal buffers with scrollback history", () => {
37
+ expect(shouldUseManualWheelScroll({ baseY: 1, type: "normal" })).toBe(true);
38
+ });
39
+ });
40
+
41
+ describe("readViewportY", () => {
42
+ it("returns null for missing or invalid viewport values", () => {
43
+ expect(readViewportY(undefined)).toBeNull();
44
+ expect(readViewportY({ viewportY: Number.NaN })).toBeNull();
45
+ expect(readViewportY({})).toBeNull();
46
+ });
47
+
48
+ it("returns viewport row when available", () => {
49
+ expect(readViewportY({ viewportY: 42 })).toBe(42);
50
+ });
51
+ });
@@ -0,0 +1,48 @@
1
+ import { vi } from "vitest";
2
+
3
+ export class MockWebSocket {
4
+ static instances: MockWebSocket[] = [];
5
+ readonly url: string;
6
+ private listeners = new Map<string, Set<(event: { data: unknown }) => void>>();
7
+
8
+ close = vi.fn();
9
+ send = vi.fn();
10
+
11
+ constructor(url: string) {
12
+ this.url = url;
13
+ MockWebSocket.instances.push(this);
14
+ }
15
+
16
+ addEventListener(type: string, listener: (event: { data: unknown }) => void) {
17
+ const bucket = this.listeners.get(type) ?? new Set<(event: { data: unknown }) => void>();
18
+ bucket.add(listener);
19
+ this.listeners.set(type, bucket);
20
+ }
21
+
22
+ removeEventListener(type: string, listener: (event: { data: unknown }) => void) {
23
+ this.listeners.get(type)?.delete(listener);
24
+ }
25
+
26
+ emit(type: string, data?: unknown) {
27
+ const event = { data };
28
+ for (const listener of this.listeners.get(type) ?? []) {
29
+ listener(event);
30
+ }
31
+ }
32
+ }
33
+
34
+ export const resetAppTestHarness = () => {
35
+ vi.restoreAllMocks();
36
+ vi.unstubAllGlobals();
37
+ MockWebSocket.instances = [];
38
+ };
39
+
40
+ export const jsonResponse = (payload: unknown, status = 200) =>
41
+ new Response(JSON.stringify(payload), {
42
+ status,
43
+ headers: {
44
+ "Content-Type": "application/json",
45
+ },
46
+ });
47
+
48
+ export const notFoundResponse = () => new Response("not-found", { status: 404 });
@@ -0,0 +1,31 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ import { ActionButton } from "../src/components/ui/ActionButton";
5
+ import { StatusBadge } from "../src/components/ui/StatusBadge";
6
+
7
+ describe("UI primitives", () => {
8
+ it("renders action button variants and size classes", () => {
9
+ render(
10
+ <ActionButton size="compact" variant="danger">
11
+ Delete
12
+ </ActionButton>,
13
+ );
14
+
15
+ expect(screen.getByRole("button", { name: "Delete" })).toHaveClass(
16
+ "action-button",
17
+ "action-button--danger",
18
+ "action-button--compact",
19
+ );
20
+ });
21
+
22
+ it("renders status badges with semantic tone classes", () => {
23
+ render(<StatusBadge tone="processing" />);
24
+
25
+ expect(screen.getByText("PROCESSING").closest(".status-badge")).toHaveClass(
26
+ "status-badge",
27
+ "pill",
28
+ "processing",
29
+ );
30
+ });
31
+ });
@@ -0,0 +1,47 @@
1
+ import { render, screen } from "@testing-library/react";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ import { useAgentRuntimeStates } from "../src/app/hooks/useAgentRuntimeStates";
5
+ import { createTerminalRuntimeStateStore } from "../src/app/terminalRuntimeStateStore";
6
+ import type { TerminalView } from "../src/app/types";
7
+
8
+ const HookProbe = ({ columns }: { columns: TerminalView }) => {
9
+ const runtimeStateStore = createTerminalRuntimeStateStore();
10
+ runtimeStateStore.syncFromTerminals(columns);
11
+ const runtimeStates = useAgentRuntimeStates(runtimeStateStore, columns);
12
+ return (
13
+ <output aria-label="runtime-states">
14
+ {JSON.stringify(Array.from(runtimeStates.entries()))}
15
+ </output>
16
+ );
17
+ };
18
+
19
+ describe("useAgentRuntimeStates", () => {
20
+ it("derives per-terminal runtime state from snapshots without opening passive sockets", () => {
21
+ const socketSpy = globalThis.WebSocket;
22
+ const columns = [
23
+ {
24
+ terminalId: "tentacle-idle",
25
+ label: "tentacle-idle",
26
+ state: "live",
27
+ tentacleId: "docs-knowledge",
28
+ createdAt: "2026-04-09T10:00:00.000Z",
29
+ },
30
+ {
31
+ terminalId: "docs-knowledge-swarm-parent",
32
+ label: "docs-knowledge-swarm-parent",
33
+ state: "live",
34
+ tentacleId: "docs-knowledge",
35
+ createdAt: "2026-04-09T10:05:00.000Z",
36
+ agentRuntimeState: "processing",
37
+ },
38
+ ] satisfies TerminalView;
39
+
40
+ render(<HookProbe columns={columns} />);
41
+
42
+ expect(screen.getByLabelText("runtime-states").textContent).toBe(
43
+ JSON.stringify([["docs-knowledge-swarm-parent", { state: "processing" }]]),
44
+ );
45
+ expect(globalThis.WebSocket).toBe(socketSpy);
46
+ });
47
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "types": ["vite/client", "vitest/globals"]
6
+ },
7
+ "include": ["src", "tests", "vite.config.ts"]
8
+ }
@@ -0,0 +1,32 @@
1
+ import { builtinModules } from "node:module";
2
+ import { resolve } from "node:path";
3
+
4
+ import { defineConfig } from "vite";
5
+
6
+ const externals = [
7
+ ...builtinModules,
8
+ ...builtinModules.map((moduleName) => `node:${moduleName}`),
9
+ "node-pty",
10
+ "ws",
11
+ ];
12
+
13
+ export default defineConfig({
14
+ build: {
15
+ outDir: resolve(__dirname, "../../dist/api"),
16
+ emptyOutDir: false,
17
+ lib: {
18
+ entry: resolve(__dirname, "../api/src/cli.ts"),
19
+ formats: ["es"],
20
+ fileName: () => "cli.js",
21
+ },
22
+ minify: false,
23
+ sourcemap: true,
24
+ target: "node22",
25
+ rollupOptions: {
26
+ external: externals,
27
+ output: {
28
+ entryFileNames: "cli.js",
29
+ },
30
+ },
31
+ },
32
+ });