@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,70 @@
1
+ const LOOPBACK_HOSTNAMES = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
2
+
3
+ export const withCors = (headers: Record<string, string>, corsOrigin: string | null) => {
4
+ const nextHeaders: Record<string, string> = {
5
+ ...headers,
6
+ "Access-Control-Allow-Methods": "GET, POST, PATCH, DELETE, OPTIONS",
7
+ "Access-Control-Allow-Headers": "Content-Type",
8
+ };
9
+
10
+ if (corsOrigin) {
11
+ nextHeaders["Access-Control-Allow-Origin"] = corsOrigin;
12
+ nextHeaders.Vary = "Origin";
13
+ }
14
+
15
+ return nextHeaders;
16
+ };
17
+
18
+ const isLoopbackHostname = (hostname: string) => LOOPBACK_HOSTNAMES.has(hostname.toLowerCase());
19
+
20
+ const parseHostname = (value: string, withScheme: boolean): string | null => {
21
+ try {
22
+ const url = new URL(withScheme ? value : `http://${value}`);
23
+ return url.hostname;
24
+ } catch {
25
+ return null;
26
+ }
27
+ };
28
+
29
+ export const isAllowedOriginHeader = (origin: string | undefined, allowRemoteAccess: boolean) => {
30
+ if (allowRemoteAccess || origin === undefined) {
31
+ return true;
32
+ }
33
+
34
+ const hostname = parseHostname(origin, true);
35
+ return hostname !== null && isLoopbackHostname(hostname);
36
+ };
37
+
38
+ export const isAllowedHostHeader = (host: string | undefined, allowRemoteAccess: boolean) => {
39
+ if (allowRemoteAccess) {
40
+ return true;
41
+ }
42
+
43
+ if (!host) {
44
+ return false;
45
+ }
46
+
47
+ const hostname = parseHostname(host, false);
48
+ return hostname !== null && isLoopbackHostname(hostname);
49
+ };
50
+
51
+ export const readHeaderValue = (header: string | string[] | undefined): string | undefined => {
52
+ if (typeof header !== "string") {
53
+ return undefined;
54
+ }
55
+
56
+ const trimmed = header.trim();
57
+ return trimmed.length > 0 ? trimmed : undefined;
58
+ };
59
+
60
+ export const getRequestCorsOrigin = (origin: string | undefined, allowRemoteAccess: boolean) => {
61
+ if (!origin) {
62
+ return null;
63
+ }
64
+
65
+ if (!allowRemoteAccess && !isAllowedOriginHeader(origin, allowRemoteAccess)) {
66
+ return null;
67
+ }
68
+
69
+ return origin;
70
+ };
@@ -0,0 +1,167 @@
1
+ import {
2
+ type TentacleWorkspaceMode,
3
+ type TerminalAgentProvider,
4
+ type TerminalNameOrigin,
5
+ isTerminalAgentProvider,
6
+ } from "../terminalRuntime";
7
+
8
+ const isTerminalNameOrigin = (value: unknown): value is TerminalNameOrigin =>
9
+ value === "generated" || value === "user" || value === "prompt";
10
+
11
+ export const parseTerminalName = (payload: unknown) => {
12
+ if (payload === null || payload === undefined) {
13
+ return {
14
+ provided: false,
15
+ name: undefined as string | undefined,
16
+ error: null as string | null,
17
+ };
18
+ }
19
+
20
+ if (typeof payload !== "object") {
21
+ return {
22
+ provided: true,
23
+ name: undefined as string | undefined,
24
+ error: "Expected a JSON object body.",
25
+ };
26
+ }
27
+
28
+ const rawName = (payload as Record<string, unknown>).name;
29
+ if (rawName === undefined) {
30
+ return {
31
+ provided: false,
32
+ name: undefined as string | undefined,
33
+ error: null as string | null,
34
+ };
35
+ }
36
+
37
+ if (typeof rawName !== "string") {
38
+ return {
39
+ provided: true,
40
+ name: undefined as string | undefined,
41
+ error: "Terminal name must be a string.",
42
+ };
43
+ }
44
+
45
+ const trimmed = rawName.trim();
46
+ if (trimmed.length === 0) {
47
+ return {
48
+ provided: true,
49
+ name: undefined as string | undefined,
50
+ error: "Terminal name cannot be empty.",
51
+ };
52
+ }
53
+
54
+ return {
55
+ provided: true,
56
+ name: trimmed,
57
+ error: null as string | null,
58
+ };
59
+ };
60
+
61
+ export const parseTerminalWorkspaceMode = (payload: unknown) => {
62
+ if (payload === null || payload === undefined) {
63
+ return {
64
+ workspaceMode: "shared" as TentacleWorkspaceMode,
65
+ error: null as string | null,
66
+ };
67
+ }
68
+
69
+ if (typeof payload !== "object") {
70
+ return {
71
+ workspaceMode: "shared" as TentacleWorkspaceMode,
72
+ error: "Expected a JSON object body.",
73
+ };
74
+ }
75
+
76
+ const rawWorkspaceMode = (payload as Record<string, unknown>).workspaceMode;
77
+ if (rawWorkspaceMode === undefined) {
78
+ return {
79
+ workspaceMode: "shared" as TentacleWorkspaceMode,
80
+ error: null as string | null,
81
+ };
82
+ }
83
+
84
+ if (rawWorkspaceMode !== "shared" && rawWorkspaceMode !== "worktree") {
85
+ return {
86
+ workspaceMode: "shared" as TentacleWorkspaceMode,
87
+ error: "Terminal workspace mode must be either 'shared' or 'worktree'.",
88
+ };
89
+ }
90
+
91
+ return {
92
+ workspaceMode: rawWorkspaceMode as TentacleWorkspaceMode,
93
+ error: null as string | null,
94
+ };
95
+ };
96
+
97
+ export const parseTerminalAgentProvider = (payload: unknown) => {
98
+ if (payload === null || payload === undefined) {
99
+ return {
100
+ agentProvider: undefined as TerminalAgentProvider | undefined,
101
+ error: null as string | null,
102
+ };
103
+ }
104
+
105
+ if (typeof payload !== "object") {
106
+ return {
107
+ agentProvider: undefined as TerminalAgentProvider | undefined,
108
+ error: "Expected a JSON object body.",
109
+ };
110
+ }
111
+
112
+ const rawAgentProvider = (payload as Record<string, unknown>).agentProvider;
113
+ if (rawAgentProvider === undefined) {
114
+ return {
115
+ agentProvider: undefined as TerminalAgentProvider | undefined,
116
+ error: null as string | null,
117
+ };
118
+ }
119
+
120
+ if (!isTerminalAgentProvider(rawAgentProvider)) {
121
+ return {
122
+ agentProvider: undefined as TerminalAgentProvider | undefined,
123
+ error: "Terminal agent provider must be either 'codex' or 'claude-code'.",
124
+ };
125
+ }
126
+
127
+ return {
128
+ agentProvider: rawAgentProvider,
129
+ error: null as string | null,
130
+ };
131
+ };
132
+
133
+ export const parseTerminalNameOrigin = (payload: unknown) => {
134
+ if (payload === null || payload === undefined) {
135
+ return {
136
+ nameOrigin: undefined as TerminalNameOrigin | undefined,
137
+ error: null as string | null,
138
+ };
139
+ }
140
+
141
+ if (typeof payload !== "object") {
142
+ return {
143
+ nameOrigin: undefined as TerminalNameOrigin | undefined,
144
+ error: "Expected a JSON object body.",
145
+ };
146
+ }
147
+
148
+ const rawNameOrigin = (payload as Record<string, unknown>).nameOrigin;
149
+ if (rawNameOrigin === undefined) {
150
+ return {
151
+ nameOrigin: undefined as TerminalNameOrigin | undefined,
152
+ error: null as string | null,
153
+ };
154
+ }
155
+
156
+ if (!isTerminalNameOrigin(rawNameOrigin)) {
157
+ return {
158
+ nameOrigin: undefined as TerminalNameOrigin | undefined,
159
+ error: "Terminal name origin must be 'generated', 'user', or 'prompt'.",
160
+ };
161
+ }
162
+
163
+ return {
164
+ nameOrigin: rawNameOrigin,
165
+ error: null as string | null,
166
+ };
167
+ };
@@ -0,0 +1,315 @@
1
+ import { join } from "node:path";
2
+ import { readDeckTentacles } from "../deck/readDeckTentacles";
3
+ import { resolvePrompt } from "../prompts";
4
+ import {
5
+ RuntimeInputError,
6
+ type TentacleWorkspaceMode,
7
+ type TerminalAgentProvider,
8
+ type TerminalNameOrigin,
9
+ } from "../terminalRuntime";
10
+ import type { ApiRouteHandler } from "./routeHelpers";
11
+ import {
12
+ readJsonBodyOrWriteError,
13
+ writeJson,
14
+ writeMethodNotAllowed,
15
+ writeNoContent,
16
+ } from "./routeHelpers";
17
+ import {
18
+ parseTerminalAgentProvider,
19
+ parseTerminalName,
20
+ parseTerminalNameOrigin,
21
+ parseTerminalWorkspaceMode,
22
+ } from "./terminalParsers";
23
+
24
+ const buildTentacleInitialPrompt = (
25
+ promptsDir: string,
26
+ workspaceCwd: string,
27
+ projectStateDir: string,
28
+ tentacleId: string,
29
+ ): Promise<string | undefined> => {
30
+ const tentacle = readDeckTentacles(workspaceCwd, projectStateDir).find(
31
+ (entry) => entry.tentacleId === tentacleId,
32
+ );
33
+ if (!tentacle) {
34
+ return Promise.resolve(undefined);
35
+ }
36
+
37
+ const tentacleFolderPath = join(".octogent", "tentacles", tentacleId);
38
+ return resolvePrompt(promptsDir, "tentacle-context-init", {
39
+ tentacleName: tentacle.displayName,
40
+ tentacleId,
41
+ tentacleContextPath: tentacleFolderPath,
42
+ });
43
+ };
44
+
45
+ export const handleTerminalSnapshotsRoute: ApiRouteHandler = async (
46
+ { request, response, requestUrl, corsOrigin },
47
+ { runtime },
48
+ ) => {
49
+ if (requestUrl.pathname !== "/api/terminal-snapshots") {
50
+ return false;
51
+ }
52
+
53
+ if (request.method !== "GET") {
54
+ writeMethodNotAllowed(response, corsOrigin);
55
+ return true;
56
+ }
57
+
58
+ const payload = runtime.listTerminalSnapshots();
59
+ writeJson(response, 200, payload, corsOrigin);
60
+ return true;
61
+ };
62
+
63
+ export const handleTerminalsCollectionRoute: ApiRouteHandler = async (
64
+ { request, response, requestUrl, corsOrigin },
65
+ { runtime, workspaceCwd, projectStateDir, promptsDir, userPromptsDir, getApiPort },
66
+ ) => {
67
+ if (requestUrl.pathname !== "/api/terminals") {
68
+ return false;
69
+ }
70
+
71
+ if (request.method !== "POST") {
72
+ writeMethodNotAllowed(response, corsOrigin);
73
+ return true;
74
+ }
75
+
76
+ const bodyReadResult = await readJsonBodyOrWriteError(request, response, corsOrigin);
77
+ if (!bodyReadResult.ok) {
78
+ return true;
79
+ }
80
+
81
+ const nameResult = parseTerminalName(bodyReadResult.payload);
82
+ if (nameResult.error) {
83
+ writeJson(response, 400, { error: nameResult.error }, corsOrigin);
84
+ return true;
85
+ }
86
+
87
+ const workspaceModeResult = parseTerminalWorkspaceMode(bodyReadResult.payload);
88
+ if (workspaceModeResult.error) {
89
+ writeJson(response, 400, { error: workspaceModeResult.error }, corsOrigin);
90
+ return true;
91
+ }
92
+
93
+ const agentProviderResult = parseTerminalAgentProvider(bodyReadResult.payload);
94
+ if (agentProviderResult.error) {
95
+ writeJson(response, 400, { error: agentProviderResult.error }, corsOrigin);
96
+ return true;
97
+ }
98
+
99
+ const nameOriginResult = parseTerminalNameOrigin(bodyReadResult.payload);
100
+ if (nameOriginResult.error) {
101
+ writeJson(response, 400, { error: nameOriginResult.error }, corsOrigin);
102
+ return true;
103
+ }
104
+
105
+ try {
106
+ const createTerminalInput: {
107
+ terminalId?: string;
108
+ tentacleId?: string;
109
+ worktreeId?: string;
110
+ tentacleName?: string;
111
+ workspaceMode: TentacleWorkspaceMode;
112
+ agentProvider?: TerminalAgentProvider;
113
+ nameOrigin?: TerminalNameOrigin;
114
+ initialPrompt?: string;
115
+ initialInputDraft?: string;
116
+ autoRenamePromptContext?: string;
117
+ parentTerminalId?: string;
118
+ } = {
119
+ workspaceMode: workspaceModeResult.workspaceMode,
120
+ };
121
+ if (nameResult.name !== undefined) {
122
+ createTerminalInput.tentacleName = nameResult.name;
123
+ }
124
+ if (agentProviderResult.agentProvider !== undefined) {
125
+ createTerminalInput.agentProvider = agentProviderResult.agentProvider;
126
+ }
127
+ if (nameOriginResult.nameOrigin !== undefined) {
128
+ createTerminalInput.nameOrigin = nameOriginResult.nameOrigin;
129
+ }
130
+ const bodyPayload = bodyReadResult.payload as Record<string, unknown> | null;
131
+ if (
132
+ bodyPayload &&
133
+ typeof bodyPayload.terminalId === "string" &&
134
+ bodyPayload.terminalId.trim().length > 0
135
+ ) {
136
+ createTerminalInput.terminalId = bodyPayload.terminalId.trim();
137
+ }
138
+ if (
139
+ bodyPayload &&
140
+ typeof bodyPayload.tentacleId === "string" &&
141
+ bodyPayload.tentacleId.trim().length > 0
142
+ ) {
143
+ createTerminalInput.tentacleId = bodyPayload.tentacleId.trim();
144
+ }
145
+ if (
146
+ bodyPayload &&
147
+ typeof bodyPayload.parentTerminalId === "string" &&
148
+ bodyPayload.parentTerminalId.trim().length > 0
149
+ ) {
150
+ createTerminalInput.parentTerminalId = bodyPayload.parentTerminalId.trim();
151
+ }
152
+ if (
153
+ bodyPayload &&
154
+ typeof bodyPayload.autoRenamePromptContext === "string" &&
155
+ bodyPayload.autoRenamePromptContext.trim().length > 0
156
+ ) {
157
+ createTerminalInput.autoRenamePromptContext = bodyPayload.autoRenamePromptContext.trim();
158
+ }
159
+ if (
160
+ bodyPayload &&
161
+ typeof bodyPayload.worktreeId === "string" &&
162
+ bodyPayload.worktreeId.trim().length > 0
163
+ ) {
164
+ createTerminalInput.worktreeId = bodyPayload.worktreeId.trim();
165
+ }
166
+
167
+ // Support prompt resolution via template name + variables, or a raw string.
168
+ if (
169
+ bodyPayload &&
170
+ typeof bodyPayload.promptTemplate === "string" &&
171
+ bodyPayload.promptTemplate.trim().length > 0
172
+ ) {
173
+ const templateName = bodyPayload.promptTemplate.trim();
174
+ const templateVars: Record<string, string> =
175
+ bodyPayload.promptVariables != null &&
176
+ typeof bodyPayload.promptVariables === "object" &&
177
+ !Array.isArray(bodyPayload.promptVariables)
178
+ ? Object.fromEntries(
179
+ Object.entries(bodyPayload.promptVariables as Record<string, unknown>)
180
+ .filter(([, v]) => typeof v === "string")
181
+ .map(([k, v]) => [k, v as string]),
182
+ )
183
+ : {};
184
+
185
+ // Auto-inject terminalId variable so callers don't have to guess it.
186
+ // The runtime hasn't allocated the ID yet, so we use the tentacle name
187
+ // when provided (sandbox always passes its name).
188
+ if (!templateVars.terminalId && createTerminalInput.tentacleName) {
189
+ templateVars.terminalId = createTerminalInput.tentacleName;
190
+ }
191
+
192
+ // Auto-inject apiPort so prompt templates can reference the local API.
193
+ if (!templateVars.apiPort) {
194
+ templateVars.apiPort = getApiPort();
195
+ }
196
+
197
+ // Auto-inject userPromptsDir so prompt templates know where to save user prompts.
198
+ if (!templateVars.userPromptsDir) {
199
+ templateVars.userPromptsDir = userPromptsDir;
200
+ }
201
+
202
+ // Auto-inject existingTerminals summary so planner-style prompts have context.
203
+ if (!templateVars.existingTerminals) {
204
+ const deckTentacles = readDeckTentacles(workspaceCwd, projectStateDir);
205
+ if (deckTentacles.length > 0) {
206
+ const listing = deckTentacles
207
+ .map(
208
+ (t) =>
209
+ `- **${t.displayName}** (\`${t.tentacleId}\`): ${t.description || "(no description)"}`,
210
+ )
211
+ .join("\n");
212
+ templateVars.existingTerminals = `## Existing Terminals\n\nThe following departments already exist:\n\n${listing}\n\nConsider these when proposing new departments — avoid duplicates and note any gaps.`;
213
+ } else {
214
+ templateVars.existingTerminals =
215
+ "## Existing Terminals\n\nNo department terminals exist yet. You are starting from scratch.";
216
+ }
217
+ }
218
+
219
+ const resolved = await resolvePrompt(promptsDir, templateName, templateVars);
220
+ if (resolved !== undefined) {
221
+ createTerminalInput.initialPrompt = resolved;
222
+ }
223
+ } else if (
224
+ bodyPayload &&
225
+ typeof bodyPayload.initialPrompt === "string" &&
226
+ bodyPayload.initialPrompt.trim().length > 0
227
+ ) {
228
+ createTerminalInput.initialPrompt = bodyPayload.initialPrompt.trim();
229
+ }
230
+
231
+ if (!createTerminalInput.initialPrompt && createTerminalInput.tentacleId) {
232
+ const defaultTentaclePrompt = await buildTentacleInitialPrompt(
233
+ promptsDir,
234
+ workspaceCwd,
235
+ projectStateDir,
236
+ createTerminalInput.tentacleId,
237
+ );
238
+ if (defaultTentaclePrompt) {
239
+ createTerminalInput.initialInputDraft = defaultTentaclePrompt;
240
+ }
241
+ }
242
+
243
+ const snapshot = runtime.createTerminal(createTerminalInput);
244
+ const payload: Record<string, unknown> = { ...snapshot };
245
+ if (createTerminalInput.initialPrompt) {
246
+ payload.initialPrompt = createTerminalInput.initialPrompt;
247
+ }
248
+ writeJson(response, 201, payload, corsOrigin);
249
+ return true;
250
+ } catch (error) {
251
+ if (error instanceof RuntimeInputError) {
252
+ writeJson(response, 400, { error: error.message }, corsOrigin);
253
+ return true;
254
+ }
255
+
256
+ throw error;
257
+ }
258
+ };
259
+
260
+ const TERMINAL_ITEM_PATH_PATTERN = /^\/api\/terminals\/([^/]+)$/;
261
+
262
+ export const handleTerminalItemRoute: ApiRouteHandler = async (
263
+ { request, response, requestUrl, corsOrigin },
264
+ { runtime },
265
+ ) => {
266
+ const renameMatch = requestUrl.pathname.match(TERMINAL_ITEM_PATH_PATTERN);
267
+ if (!renameMatch) {
268
+ return false;
269
+ }
270
+
271
+ if (request.method !== "PATCH" && request.method !== "DELETE") {
272
+ writeMethodNotAllowed(response, corsOrigin);
273
+ return true;
274
+ }
275
+
276
+ const terminalId = decodeURIComponent(renameMatch[1] ?? "");
277
+ if (request.method === "DELETE") {
278
+ try {
279
+ runtime.deleteTerminal(terminalId);
280
+ writeNoContent(response, 204, corsOrigin);
281
+ return true;
282
+ } catch (error) {
283
+ if (error instanceof RuntimeInputError) {
284
+ writeJson(response, 409, { error: error.message }, corsOrigin);
285
+ return true;
286
+ }
287
+ throw error;
288
+ }
289
+ }
290
+
291
+ const bodyReadResult = await readJsonBodyOrWriteError(request, response, corsOrigin);
292
+ if (!bodyReadResult.ok) {
293
+ return true;
294
+ }
295
+
296
+ const nameResult = parseTerminalName(bodyReadResult.payload);
297
+ if (nameResult.error) {
298
+ writeJson(response, 400, { error: nameResult.error }, corsOrigin);
299
+ return true;
300
+ }
301
+
302
+ if (!nameResult.provided || !nameResult.name) {
303
+ writeJson(response, 400, { error: "Terminal name is required." }, corsOrigin);
304
+ return true;
305
+ }
306
+
307
+ const payload = runtime.renameTerminal(terminalId, nameResult.name);
308
+ if (!payload) {
309
+ writeJson(response, 404, { error: "Terminal not found." }, corsOrigin);
310
+ return true;
311
+ }
312
+
313
+ writeJson(response, 200, payload, corsOrigin);
314
+ return true;
315
+ };
@@ -0,0 +1,24 @@
1
+ import type { UsageChartResponse } from "../claudeSessionScanner";
2
+ import type { ClaudeUsageSnapshot } from "../claudeUsage";
3
+ import type { CodexUsageSnapshot } from "../codexUsage";
4
+ import type { GitHubRepoSummarySnapshot } from "../githubRepoSummary";
5
+ import type { MonitorService } from "../monitor";
6
+ import type { GitClient } from "../terminalRuntime";
7
+
8
+ export type CreateApiServerOptions = {
9
+ workspaceCwd?: string | undefined;
10
+ projectStateDir?: string | undefined;
11
+ promptsDir?: string | undefined;
12
+ webDistDir?: string | undefined;
13
+ apiBaseUrl?: string | undefined;
14
+ gitClient?: GitClient;
15
+ readClaudeUsageSnapshot?: () => Promise<ClaudeUsageSnapshot>;
16
+ readClaudeOauthUsageSnapshot?: () => Promise<ClaudeUsageSnapshot>;
17
+ readClaudeCliUsageSnapshot?: () => Promise<ClaudeUsageSnapshot>;
18
+ readCodexUsageSnapshot?: () => Promise<CodexUsageSnapshot>;
19
+ readGithubRepoSummary?: () => Promise<GitHubRepoSummarySnapshot>;
20
+ scanUsageHeatmap?: (scope: "all" | "project") => Promise<UsageChartResponse>;
21
+ monitorService?: MonitorService;
22
+ invalidateClaudeUsageCache?: () => void;
23
+ allowRemoteAccess?: boolean;
24
+ };