@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.
- package/README.md +1295 -0
- package/apps/octogent/.github/workflows/ci.yml +40 -0
- package/apps/octogent/.shims/claude +4 -0
- package/apps/octogent/AGENTS.md +71 -0
- package/apps/octogent/CONTRIBUTING.md +72 -0
- package/apps/octogent/LICENSE +21 -0
- package/apps/octogent/README.md +184 -0
- package/apps/octogent/apps/api/AGENTS.md +32 -0
- package/apps/octogent/apps/api/package.json +19 -0
- package/apps/octogent/apps/api/src/agentStateDetection.ts +181 -0
- package/apps/octogent/apps/api/src/claudeSessionScanner.ts +235 -0
- package/apps/octogent/apps/api/src/claudeSkills.ts +182 -0
- package/apps/octogent/apps/api/src/claudeUsage.ts +922 -0
- package/apps/octogent/apps/api/src/cli.ts +595 -0
- package/apps/octogent/apps/api/src/codeIntelStore.ts +46 -0
- package/apps/octogent/apps/api/src/codexUsage.ts +278 -0
- package/apps/octogent/apps/api/src/createApiServer/codeIntelRoutes.ts +60 -0
- package/apps/octogent/apps/api/src/createApiServer/conversationRoutes.ts +128 -0
- package/apps/octogent/apps/api/src/createApiServer/deckRoutes.ts +873 -0
- package/apps/octogent/apps/api/src/createApiServer/gitParsers.ts +140 -0
- package/apps/octogent/apps/api/src/createApiServer/gitRoutes.ts +214 -0
- package/apps/octogent/apps/api/src/createApiServer/miscRoutes.ts +316 -0
- package/apps/octogent/apps/api/src/createApiServer/monitorParsers.ts +137 -0
- package/apps/octogent/apps/api/src/createApiServer/monitorRoutes.ts +95 -0
- package/apps/octogent/apps/api/src/createApiServer/requestHandler.ts +311 -0
- package/apps/octogent/apps/api/src/createApiServer/requestParsers.ts +25 -0
- package/apps/octogent/apps/api/src/createApiServer/routeHelpers.ts +97 -0
- package/apps/octogent/apps/api/src/createApiServer/security.ts +70 -0
- package/apps/octogent/apps/api/src/createApiServer/terminalParsers.ts +167 -0
- package/apps/octogent/apps/api/src/createApiServer/terminalRoutes.ts +315 -0
- package/apps/octogent/apps/api/src/createApiServer/types.ts +24 -0
- package/apps/octogent/apps/api/src/createApiServer/uiStateParsers.ts +255 -0
- package/apps/octogent/apps/api/src/createApiServer/upgradeHandler.ts +38 -0
- package/apps/octogent/apps/api/src/createApiServer/usageRoutes.ts +84 -0
- package/apps/octogent/apps/api/src/createApiServer.ts +176 -0
- package/apps/octogent/apps/api/src/deck/readDeckTentacles.ts +595 -0
- package/apps/octogent/apps/api/src/githubRepoSummary.ts +397 -0
- package/apps/octogent/apps/api/src/logging.ts +9 -0
- package/apps/octogent/apps/api/src/monitor/defaults.ts +3 -0
- package/apps/octogent/apps/api/src/monitor/index.ts +8 -0
- package/apps/octogent/apps/api/src/monitor/repository.ts +303 -0
- package/apps/octogent/apps/api/src/monitor/service.ts +349 -0
- package/apps/octogent/apps/api/src/monitor/types.ts +120 -0
- package/apps/octogent/apps/api/src/monitor/xProvider.ts +587 -0
- package/apps/octogent/apps/api/src/projectPersistence.ts +377 -0
- package/apps/octogent/apps/api/src/prompts/index.ts +10 -0
- package/apps/octogent/apps/api/src/prompts/promptResolver.ts +145 -0
- package/apps/octogent/apps/api/src/runtimeMetadata.ts +69 -0
- package/apps/octogent/apps/api/src/server.ts +80 -0
- package/apps/octogent/apps/api/src/setupState.ts +80 -0
- package/apps/octogent/apps/api/src/setupStatus.ts +174 -0
- package/apps/octogent/apps/api/src/startupPrerequisites.ts +146 -0
- package/apps/octogent/apps/api/src/terminalRuntime/channelMessaging.ts +87 -0
- package/apps/octogent/apps/api/src/terminalRuntime/claudeTranscript.ts +279 -0
- package/apps/octogent/apps/api/src/terminalRuntime/constants.ts +15 -0
- package/apps/octogent/apps/api/src/terminalRuntime/conversations.ts +492 -0
- package/apps/octogent/apps/api/src/terminalRuntime/gitOperations.ts +341 -0
- package/apps/octogent/apps/api/src/terminalRuntime/hookProcessor.ts +405 -0
- package/apps/octogent/apps/api/src/terminalRuntime/protocol.ts +46 -0
- package/apps/octogent/apps/api/src/terminalRuntime/ptyEnvironment.ts +50 -0
- package/apps/octogent/apps/api/src/terminalRuntime/registry.ts +423 -0
- package/apps/octogent/apps/api/src/terminalRuntime/sessionRuntime.ts +671 -0
- package/apps/octogent/apps/api/src/terminalRuntime/systemClients.ts +432 -0
- package/apps/octogent/apps/api/src/terminalRuntime/types.ts +157 -0
- package/apps/octogent/apps/api/src/terminalRuntime/worktreeManager.ts +135 -0
- package/apps/octogent/apps/api/src/terminalRuntime.ts +567 -0
- package/apps/octogent/apps/api/src/usageUtils.ts +16 -0
- package/apps/octogent/apps/api/src/ws-shim.d.ts +28 -0
- package/apps/octogent/apps/api/tests/agentStateDetection.test.ts +67 -0
- package/apps/octogent/apps/api/tests/claudeUsage.test.ts +583 -0
- package/apps/octogent/apps/api/tests/codexUsage.test.ts +107 -0
- package/apps/octogent/apps/api/tests/createApiServer.test.ts +3207 -0
- package/apps/octogent/apps/api/tests/githubRepoSummary.test.ts +100 -0
- package/apps/octogent/apps/api/tests/logging.test.ts +33 -0
- package/apps/octogent/apps/api/tests/monitorApi.test.ts +467 -0
- package/apps/octogent/apps/api/tests/monitorCore.test.ts +104 -0
- package/apps/octogent/apps/api/tests/promptResolver.test.ts +109 -0
- package/apps/octogent/apps/api/tests/protocol.test.ts +14 -0
- package/apps/octogent/apps/api/tests/sessionRuntime.test.ts +608 -0
- package/apps/octogent/apps/api/tests/startupPrerequisites.test.ts +70 -0
- package/apps/octogent/apps/api/tests/upgradeHandler.test.ts +40 -0
- package/apps/octogent/apps/api/tests/xMonitorProvider.test.ts +109 -0
- package/apps/octogent/apps/api/tsconfig.json +7 -0
- package/apps/octogent/apps/api/vitest.config.ts +7 -0
- package/apps/octogent/apps/web/AGENTS.md +38 -0
- package/apps/octogent/apps/web/index.html +13 -0
- package/apps/octogent/apps/web/package.json +32 -0
- package/apps/octogent/apps/web/public/octopus-favicon.svg +26 -0
- package/apps/octogent/apps/web/src/App.tsx +646 -0
- package/apps/octogent/apps/web/src/app/canvas/types.ts +34 -0
- package/apps/octogent/apps/web/src/app/codeIntelAggregation.ts +278 -0
- package/apps/octogent/apps/web/src/app/constants.ts +28 -0
- package/apps/octogent/apps/web/src/app/conversationNormalizers.ts +135 -0
- package/apps/octogent/apps/web/src/app/formatTimestamp.ts +18 -0
- package/apps/octogent/apps/web/src/app/githubMetrics.ts +76 -0
- package/apps/octogent/apps/web/src/app/githubNormalizers.ts +91 -0
- package/apps/octogent/apps/web/src/app/hooks/useAgentRuntimeStates.ts +18 -0
- package/apps/octogent/apps/web/src/app/hooks/useBackendLivenessPolling.ts +53 -0
- package/apps/octogent/apps/web/src/app/hooks/useCanvasGraphData.ts +449 -0
- package/apps/octogent/apps/web/src/app/hooks/useCanvasTransform.ts +260 -0
- package/apps/octogent/apps/web/src/app/hooks/useClaudeUsagePolling.ts +40 -0
- package/apps/octogent/apps/web/src/app/hooks/useClickOutside.ts +30 -0
- package/apps/octogent/apps/web/src/app/hooks/useCodeIntelRuntime.ts +83 -0
- package/apps/octogent/apps/web/src/app/hooks/useCodexUsagePolling.ts +35 -0
- package/apps/octogent/apps/web/src/app/hooks/useConsoleKeyboardShortcuts.ts +31 -0
- package/apps/octogent/apps/web/src/app/hooks/useConversationsRuntime.ts +377 -0
- package/apps/octogent/apps/web/src/app/hooks/useForceSimulation.ts +319 -0
- package/apps/octogent/apps/web/src/app/hooks/useGitHubPrimaryViewModel.ts +143 -0
- package/apps/octogent/apps/web/src/app/hooks/useGithubSummaryPolling.ts +28 -0
- package/apps/octogent/apps/web/src/app/hooks/useInitialColumnsHydration.ts +64 -0
- package/apps/octogent/apps/web/src/app/hooks/useMonitorRuntime.ts +220 -0
- package/apps/octogent/apps/web/src/app/hooks/usePersistedUiState.ts +536 -0
- package/apps/octogent/apps/web/src/app/hooks/usePollingData.ts +79 -0
- package/apps/octogent/apps/web/src/app/hooks/usePromptLibrary.ts +185 -0
- package/apps/octogent/apps/web/src/app/hooks/useTentacleGitLifecycle.ts +530 -0
- package/apps/octogent/apps/web/src/app/hooks/useTerminalCompletionNotification.ts +94 -0
- package/apps/octogent/apps/web/src/app/hooks/useTerminalMutations.ts +266 -0
- package/apps/octogent/apps/web/src/app/hooks/useTerminalStateReconciliation.ts +23 -0
- package/apps/octogent/apps/web/src/app/hooks/useUsageHeatmapPolling.ts +43 -0
- package/apps/octogent/apps/web/src/app/hooks/useWorkspaceSetup.ts +80 -0
- package/apps/octogent/apps/web/src/app/hotkeys.ts +31 -0
- package/apps/octogent/apps/web/src/app/monitorNormalizers.ts +145 -0
- package/apps/octogent/apps/web/src/app/notificationSounds.ts +164 -0
- package/apps/octogent/apps/web/src/app/terminalRuntimeStateStore.ts +261 -0
- package/apps/octogent/apps/web/src/app/terminalState.ts +21 -0
- package/apps/octogent/apps/web/src/app/types.ts +42 -0
- package/apps/octogent/apps/web/src/app/uiStateNormalizers.ts +113 -0
- package/apps/octogent/apps/web/src/app/usageNormalizers.ts +58 -0
- package/apps/octogent/apps/web/src/components/ActiveAgentsSidebar.tsx +60 -0
- package/apps/octogent/apps/web/src/components/ActivityPrimaryView.tsx +21 -0
- package/apps/octogent/apps/web/src/components/AgentStateBadge.tsx +47 -0
- package/apps/octogent/apps/web/src/components/CanvasPrimaryView.tsx +1532 -0
- package/apps/octogent/apps/web/src/components/ClearAllConversationsDialog.tsx +33 -0
- package/apps/octogent/apps/web/src/components/CodeIntelArcDiagram.tsx +245 -0
- package/apps/octogent/apps/web/src/components/CodeIntelPrimaryView.tsx +104 -0
- package/apps/octogent/apps/web/src/components/CodeIntelTreemap.tsx +138 -0
- package/apps/octogent/apps/web/src/components/ConsolePrimaryNav.tsx +31 -0
- package/apps/octogent/apps/web/src/components/ConversationsPrimaryView.tsx +243 -0
- package/apps/octogent/apps/web/src/components/DeckPrimaryView.tsx +613 -0
- package/apps/octogent/apps/web/src/components/DeleteTentacleDialog.tsx +91 -0
- package/apps/octogent/apps/web/src/components/EmptyOctopus.tsx +715 -0
- package/apps/octogent/apps/web/src/components/GitHubPrimaryView.tsx +494 -0
- package/apps/octogent/apps/web/src/components/MonitorPrimaryView.tsx +475 -0
- package/apps/octogent/apps/web/src/components/PrimaryViewRouter.tsx +99 -0
- package/apps/octogent/apps/web/src/components/PromptsPrimaryView.tsx +243 -0
- package/apps/octogent/apps/web/src/components/RuntimeStatusStrip.tsx +273 -0
- package/apps/octogent/apps/web/src/components/SettingsPrimaryView.tsx +92 -0
- package/apps/octogent/apps/web/src/components/SidebarActionPanel.tsx +124 -0
- package/apps/octogent/apps/web/src/components/SidebarConversationsList.tsx +279 -0
- package/apps/octogent/apps/web/src/components/SidebarPromptsList.tsx +116 -0
- package/apps/octogent/apps/web/src/components/TelemetryTape.tsx +106 -0
- package/apps/octogent/apps/web/src/components/TentacleGitActionsDialog.tsx +341 -0
- package/apps/octogent/apps/web/src/components/Terminal.tsx +524 -0
- package/apps/octogent/apps/web/src/components/TerminalPromptPicker.tsx +140 -0
- package/apps/octogent/apps/web/src/components/UsageHeatmap.tsx +702 -0
- package/apps/octogent/apps/web/src/components/canvas/CanvasTentaclePanel.tsx +485 -0
- package/apps/octogent/apps/web/src/components/canvas/CanvasTerminalColumn.tsx +89 -0
- package/apps/octogent/apps/web/src/components/canvas/DeleteAllTerminalsDialog.tsx +221 -0
- package/apps/octogent/apps/web/src/components/canvas/OctopusNode.tsx +307 -0
- package/apps/octogent/apps/web/src/components/canvas/SessionNode.tsx +185 -0
- package/apps/octogent/apps/web/src/components/deck/ActionCards.tsx +118 -0
- package/apps/octogent/apps/web/src/components/deck/AddTentacleForm.tsx +269 -0
- package/apps/octogent/apps/web/src/components/deck/DeckBottomActions.tsx +56 -0
- package/apps/octogent/apps/web/src/components/deck/TentaclePod.tsx +334 -0
- package/apps/octogent/apps/web/src/components/deck/WorkspaceSetupCard.tsx +105 -0
- package/apps/octogent/apps/web/src/components/deck/octopusVisuals.ts +72 -0
- package/apps/octogent/apps/web/src/components/terminalReplay.ts +62 -0
- package/apps/octogent/apps/web/src/components/terminalWheel.ts +54 -0
- package/apps/octogent/apps/web/src/components/ui/ActionButton.tsx +34 -0
- package/apps/octogent/apps/web/src/components/ui/ConfirmationDialog.tsx +86 -0
- package/apps/octogent/apps/web/src/components/ui/MarkdownContent.tsx +43 -0
- package/apps/octogent/apps/web/src/components/ui/SettingsToggle.tsx +34 -0
- package/apps/octogent/apps/web/src/components/ui/StatusBadge.tsx +24 -0
- package/apps/octogent/apps/web/src/main.tsx +17 -0
- package/apps/octogent/apps/web/src/runtime/HttpTerminalSnapshotReader.ts +87 -0
- package/apps/octogent/apps/web/src/runtime/runtimeEndpoints.ts +412 -0
- package/apps/octogent/apps/web/src/styles/chrome-and-buttons.css +272 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-activity.css +358 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-canvas.css +1843 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-code-intel.css +227 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-conversations.css +705 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-deck.css +1524 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-github.css +541 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-monitor.css +595 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-pixpack.css +81 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-prompts.css +474 -0
- package/apps/octogent/apps/web/src/styles/console-canvas-settings.css +207 -0
- package/apps/octogent/apps/web/src/styles/console-chrome-status-nav.css +441 -0
- package/apps/octogent/apps/web/src/styles/console-overrides-telemetry.css +320 -0
- package/apps/octogent/apps/web/src/styles/console-theme-tokens.css +25 -0
- package/apps/octogent/apps/web/src/styles/cortex-theme.css +412 -0
- package/apps/octogent/apps/web/src/styles/foundation.css +100 -0
- package/apps/octogent/apps/web/src/styles/sidebar-and-scrollbars.css +447 -0
- package/apps/octogent/apps/web/src/styles/terminal-and-status.css +356 -0
- package/apps/octogent/apps/web/src/styles.css +25 -0
- package/apps/octogent/apps/web/src/types/ws.d.ts +23 -0
- package/apps/octogent/apps/web/tests/CanvasPrimaryView.test.tsx +347 -0
- package/apps/octogent/apps/web/tests/HttpTerminalSnapshotReader.test.tsx +54 -0
- package/apps/octogent/apps/web/tests/RuntimeStatusStrip.test.tsx +70 -0
- package/apps/octogent/apps/web/tests/Terminal.test.tsx +87 -0
- package/apps/octogent/apps/web/tests/add-tentacle-form.test.tsx +48 -0
- package/apps/octogent/apps/web/tests/app-github-runtime.test.tsx +162 -0
- package/apps/octogent/apps/web/tests/app-monitor-runtime.test.tsx +657 -0
- package/apps/octogent/apps/web/tests/app-shell-navigation.test.tsx +109 -0
- package/apps/octogent/apps/web/tests/app-swarm-refresh.test.tsx +268 -0
- package/apps/octogent/apps/web/tests/app-ui-state-persistence.test.tsx +116 -0
- package/apps/octogent/apps/web/tests/app-workspace-setup.test.tsx +217 -0
- package/apps/octogent/apps/web/tests/canvas-tentacle-panel.test.tsx +195 -0
- package/apps/octogent/apps/web/tests/delete-all-terminals-dialog.test.tsx +76 -0
- package/apps/octogent/apps/web/tests/githubMetrics.test.tsx +52 -0
- package/apps/octogent/apps/web/tests/hotkeys.test.tsx +44 -0
- package/apps/octogent/apps/web/tests/runtimeEndpoints.test.tsx +240 -0
- package/apps/octogent/apps/web/tests/setup.ts +39 -0
- package/apps/octogent/apps/web/tests/tentacle-pod.test.tsx +62 -0
- package/apps/octogent/apps/web/tests/terminalReplay.test.ts +71 -0
- package/apps/octogent/apps/web/tests/terminalState.test.tsx +49 -0
- package/apps/octogent/apps/web/tests/terminalWheel.test.tsx +51 -0
- package/apps/octogent/apps/web/tests/test-utils/appTestHarness.ts +48 -0
- package/apps/octogent/apps/web/tests/uiPrimitives.test.tsx +31 -0
- package/apps/octogent/apps/web/tests/useAgentRuntimeStates.test.tsx +47 -0
- package/apps/octogent/apps/web/tsconfig.json +8 -0
- package/apps/octogent/apps/web/vite.api.bundle.config.mts +32 -0
- package/apps/octogent/apps/web/vite.config.ts +22 -0
- package/apps/octogent/bin/octogent +3 -0
- package/apps/octogent/biome.json +21 -0
- package/apps/octogent/docs/concepts/mental-model.md +79 -0
- package/apps/octogent/docs/concepts/runtime-and-api.md +60 -0
- package/apps/octogent/docs/concepts/tentacles.md +85 -0
- package/apps/octogent/docs/getting-started/installation.md +54 -0
- package/apps/octogent/docs/getting-started/quickstart.md +79 -0
- package/apps/octogent/docs/guides/inter-agent-messaging.md +43 -0
- package/apps/octogent/docs/guides/orchestrating-child-agents.md +49 -0
- package/apps/octogent/docs/guides/working-with-todos.md +56 -0
- package/apps/octogent/docs/index.md +40 -0
- package/apps/octogent/docs/reference/api.md +103 -0
- package/apps/octogent/docs/reference/cli.md +71 -0
- package/apps/octogent/docs/reference/experimental-features.md +28 -0
- package/apps/octogent/docs/reference/filesystem-layout.md +62 -0
- package/apps/octogent/docs/reference/troubleshooting.md +49 -0
- package/apps/octogent/package.json +35 -0
- package/apps/octogent/packages/core/AGENTS.md +31 -0
- package/apps/octogent/packages/core/package.json +12 -0
- package/apps/octogent/packages/core/src/adapters/InMemoryTerminalSnapshotReader.ts +10 -0
- package/apps/octogent/packages/core/src/application/buildTerminalList.ts +13 -0
- package/apps/octogent/packages/core/src/domain/agentRuntime.ts +18 -0
- package/apps/octogent/packages/core/src/domain/channel.ts +8 -0
- package/apps/octogent/packages/core/src/domain/completionSound.ts +14 -0
- package/apps/octogent/packages/core/src/domain/conversation.ts +48 -0
- package/apps/octogent/packages/core/src/domain/deck.ts +33 -0
- package/apps/octogent/packages/core/src/domain/git.ts +32 -0
- package/apps/octogent/packages/core/src/domain/monitor.ts +62 -0
- package/apps/octogent/packages/core/src/domain/setup.ts +27 -0
- package/apps/octogent/packages/core/src/domain/terminal.ts +17 -0
- package/apps/octogent/packages/core/src/domain/uiState.ts +22 -0
- package/apps/octogent/packages/core/src/domain/usage.ts +60 -0
- package/apps/octogent/packages/core/src/index.ts +15 -0
- package/apps/octogent/packages/core/src/ports/TerminalSnapshotReader.ts +5 -0
- package/apps/octogent/packages/core/src/util/typeCoercion.ts +20 -0
- package/apps/octogent/packages/core/tests/buildTerminalList.test.ts +75 -0
- package/apps/octogent/packages/core/tsconfig.json +7 -0
- package/apps/octogent/packages/core/tsconfig.tsbuildinfo +1 -0
- package/apps/octogent/packages/core/vitest.config.ts +7 -0
- package/apps/octogent/pnpm-lock.yaml +3212 -0
- package/apps/octogent/pnpm-workspace.yaml +3 -0
- package/apps/octogent/prompts/meta-prompt-generator.md +223 -0
- package/apps/octogent/prompts/octoboss-clean-contexts.md +30 -0
- package/apps/octogent/prompts/octoboss-reorganize-tentacles.md +29 -0
- package/apps/octogent/prompts/octoboss-reorganize-todos.md +27 -0
- package/apps/octogent/prompts/sandbox-init.md +3 -0
- package/apps/octogent/prompts/swarm-parent.md +83 -0
- package/apps/octogent/prompts/swarm-worker.md +50 -0
- package/apps/octogent/prompts/tentacle-context-init.md +1 -0
- package/apps/octogent/prompts/tentacle-planner.md +110 -0
- package/apps/octogent/prompts/tentacle-reorganize-todos.md +20 -0
- package/apps/octogent/prompts/tentacle-update-tentacle.md +18 -0
- package/apps/octogent/scripts/build-package.mjs +23 -0
- package/apps/octogent/scripts/dev.mjs +158 -0
- package/apps/octogent/scripts/smoke-public-install.mjs +271 -0
- package/apps/octogent/static/images/octogent-header.png +0 -0
- package/apps/octogent/static/images/preview_1.jpg +0 -0
- package/apps/octogent/static/images/preview_2.jpg +0 -0
- package/apps/octogent/static/images/preview_3.jpg +0 -0
- package/apps/octogent/static/images/preview_4.jpg +0 -0
- package/apps/octogent/static/images/preview_5.jpg +0 -0
- package/apps/octogent/static/images/preview_6.jpg +0 -0
- package/apps/octogent/tsconfig.base.json +16 -0
- package/bin/AGI +3 -0
- package/bin/AGI-install-app +71 -0
- package/bin/AGI-ui +16 -0
- package/bin/AGI-voice +15 -0
- package/bin/AGI-web +16 -0
- package/bin/cortex +109 -0
- package/bin/cortex-octogent +99 -0
- package/bin/import-specifier.mjs +13 -0
- package/bin/import-specifier.test.mjs +13 -0
- package/bin/octo +150 -0
- package/dist/cli.mjs +555650 -0
- package/package.json +157 -0
- package/scripts/setup-wizard.ts +390 -0
package/bin/cortex
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CORTEX — Global CLI entry point
|
|
4
|
+
*
|
|
5
|
+
* Works anywhere — even when installed via:
|
|
6
|
+
* npm install -g @gokul77898/cortex
|
|
7
|
+
* npx @gokul77898/cortex
|
|
8
|
+
*
|
|
9
|
+
* Config lives in ~/.cortex/.env (the user's machine, NOT this package).
|
|
10
|
+
* API keys are NEVER stored in the npm package folder.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { execFileSync, spawn } from 'child_process'
|
|
14
|
+
import * as fs from 'fs'
|
|
15
|
+
import * as os from 'os'
|
|
16
|
+
import * as path from 'path'
|
|
17
|
+
import { fileURLToPath } from 'url'
|
|
18
|
+
|
|
19
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
20
|
+
const ROOT = path.resolve(__dirname, '..')
|
|
21
|
+
const CLI_PATH = path.join(ROOT, 'dist', 'cli.mjs')
|
|
22
|
+
const WIZARD = path.join(ROOT, 'scripts', 'setup-wizard.ts')
|
|
23
|
+
|
|
24
|
+
// Config lives in the user's home dir, NOT the package folder
|
|
25
|
+
const CONFIG_DIR = path.join(os.homedir(), '.cortex')
|
|
26
|
+
const CONFIG_ENV = path.join(CONFIG_DIR, '.env')
|
|
27
|
+
|
|
28
|
+
const args = process.argv.slice(2)
|
|
29
|
+
|
|
30
|
+
// ─── Load ~/.cortex/.env into the environment ──────────────────────────────
|
|
31
|
+
function loadUserConfig(): Record<string, string> {
|
|
32
|
+
if (!fs.existsSync(CONFIG_ENV)) return {}
|
|
33
|
+
const lines = fs.readFileSync(CONFIG_ENV, 'utf8').split('\n')
|
|
34
|
+
const env: Record<string, string> = {}
|
|
35
|
+
for (const line of lines) {
|
|
36
|
+
const m = line.match(/^([A-Z_]+)=(.+)$/)
|
|
37
|
+
if (m) env[m[1]] = m[2]
|
|
38
|
+
}
|
|
39
|
+
return env
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isConfigured(): boolean {
|
|
43
|
+
const env = loadUserConfig()
|
|
44
|
+
return !!(
|
|
45
|
+
env['NVIDIA_API_KEY'] ||
|
|
46
|
+
env['OPENAI_API_KEY'] ||
|
|
47
|
+
env['GEMINI_API_KEY'] ||
|
|
48
|
+
env['GROQ_API_KEY'] ||
|
|
49
|
+
env['HUGGINGFACE_API_KEY'] ||
|
|
50
|
+
env['CORTEX_PROVIDER'] === 'ollama'
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ─── Run the setup wizard ──────────────────────────────────────────────────
|
|
55
|
+
function runWizard() {
|
|
56
|
+
// Try bun first (fastest), fall back to npx tsx
|
|
57
|
+
const runners = [
|
|
58
|
+
['bun', [WIZARD]],
|
|
59
|
+
['npx', ['--yes', 'tsx', WIZARD]],
|
|
60
|
+
['node', ['--loader', 'ts-node/esm', WIZARD]],
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
for (const [cmd, cmdArgs] of runners) {
|
|
64
|
+
try {
|
|
65
|
+
execFileSync(cmd as string, cmdArgs as string[], { stdio: 'inherit', cwd: ROOT })
|
|
66
|
+
return
|
|
67
|
+
} catch {
|
|
68
|
+
continue
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.error('\n❌ Could not run setup wizard.')
|
|
73
|
+
console.error(' Install bun first: https://bun.sh\n')
|
|
74
|
+
process.exit(1)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ─── Launch CORTEX with user config injected ───────────────────────────────
|
|
78
|
+
function launchCortex(extraEnv: Record<string, string> = {}) {
|
|
79
|
+
if (!fs.existsSync(CLI_PATH)) {
|
|
80
|
+
console.error(`\n❌ dist/cli.mjs not found. Run: npm run build\n`)
|
|
81
|
+
process.exit(1)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const userConfig = loadUserConfig()
|
|
85
|
+
const mergedEnv = { ...process.env, ...userConfig, ...extraEnv }
|
|
86
|
+
|
|
87
|
+
const proc = spawn('node', [CLI_PATH, ...args], {
|
|
88
|
+
stdio: 'inherit',
|
|
89
|
+
cwd: ROOT,
|
|
90
|
+
env: mergedEnv,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
proc.on('exit', code => process.exit(code ?? 0))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ─── Entry point ───────────────────────────────────────────────────────────
|
|
97
|
+
if (args[0] === 'setup' || args[0] === 'init' || args[0] === 'configure' || args[0] === 'login') {
|
|
98
|
+
// Force re-run wizard
|
|
99
|
+
runWizard()
|
|
100
|
+
launchCortex()
|
|
101
|
+
} else if (!isConfigured()) {
|
|
102
|
+
// First time — run wizard then launch
|
|
103
|
+
console.log('\n Welcome to CORTEX! Running first-time setup...\n')
|
|
104
|
+
runWizard()
|
|
105
|
+
launchCortex()
|
|
106
|
+
} else {
|
|
107
|
+
// Already configured — launch directly
|
|
108
|
+
launchCortex()
|
|
109
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cortex-octogent — launch the bundled Octogent multi-agent orchestrator
|
|
4
|
+
* (apps/octogent/) with CORTEX wired in as the `claude` backend.
|
|
5
|
+
*
|
|
6
|
+
* Octogent is MIT-licensed and vendored at apps/octogent/. This wrapper:
|
|
7
|
+
* 1. Builds octogent on first run if dist/ is missing.
|
|
8
|
+
* 2. Prepends apps/octogent/.shims to PATH so its `claude` probe resolves
|
|
9
|
+
* to the CORTEX CLI.
|
|
10
|
+
* 3. Execs apps/octogent/bin/octogent with whatever args the user passes.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { dirname, resolve } from 'node:path'
|
|
14
|
+
import { existsSync } from 'node:fs'
|
|
15
|
+
import { spawnSync, spawn } from 'node:child_process'
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
import { platform } from 'node:os'
|
|
18
|
+
|
|
19
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
20
|
+
const REPO_ROOT = resolve(__dirname, '..')
|
|
21
|
+
const OCTOGENT_DIR = resolve(REPO_ROOT, 'apps/octogent')
|
|
22
|
+
const OCTOGENT_BIN = resolve(OCTOGENT_DIR, 'bin/octogent')
|
|
23
|
+
const OCTOGENT_DIST = resolve(OCTOGENT_DIR, 'dist/api/cli.js')
|
|
24
|
+
const SHIM_DIR = resolve(OCTOGENT_DIR, '.shims')
|
|
25
|
+
|
|
26
|
+
if (!existsSync(OCTOGENT_BIN)) {
|
|
27
|
+
console.error(`cortex-octogent: apps/octogent is missing at ${OCTOGENT_DIR}`)
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Build on first run
|
|
32
|
+
if (!existsSync(OCTOGENT_DIST)) {
|
|
33
|
+
console.log('cortex-octogent: building apps/octogent (first run, ~30s) ...')
|
|
34
|
+
const pnpm = spawnSync('pnpm', ['install'], { cwd: OCTOGENT_DIR, stdio: 'inherit' })
|
|
35
|
+
if (pnpm.status !== 0) {
|
|
36
|
+
console.error('cortex-octogent: pnpm install failed')
|
|
37
|
+
process.exit(pnpm.status || 1)
|
|
38
|
+
}
|
|
39
|
+
const build = spawnSync('pnpm', ['build'], { cwd: OCTOGENT_DIR, stdio: 'inherit' })
|
|
40
|
+
if (build.status !== 0) {
|
|
41
|
+
console.error('cortex-octogent: pnpm build failed')
|
|
42
|
+
process.exit(build.status || 1)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Make the shim executable and ensure it's in PATH
|
|
47
|
+
spawnSync('chmod', ['+x', resolve(SHIM_DIR, 'claude')], { stdio: 'ignore' })
|
|
48
|
+
|
|
49
|
+
// Enforce venv — same as cortex.mjs so every subprocess runs inside .venv
|
|
50
|
+
const VENV_BIN = resolve(REPO_ROOT, '.venv/bin')
|
|
51
|
+
const env = {
|
|
52
|
+
...process.env,
|
|
53
|
+
CORTEX_REPO_ROOT: REPO_ROOT,
|
|
54
|
+
VIRTUAL_ENV: resolve(REPO_ROOT, '.venv'),
|
|
55
|
+
PATH: `${SHIM_DIR}:${VENV_BIN}:${process.env.PATH || ''}`,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Pipe octogent's stdout so we can detect the "API: http://..." line AND
|
|
59
|
+
// still forward output to the user's terminal unchanged.
|
|
60
|
+
const child = spawn('node', [OCTOGENT_BIN, ...process.argv.slice(2)], {
|
|
61
|
+
cwd: process.cwd(),
|
|
62
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
63
|
+
env,
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const AUTO_OPEN = process.env.CORTEX_NO_OPEN !== '1' && process.env.OCTOGENT_NO_OPEN !== '1'
|
|
67
|
+
const openCmd = platform() === 'darwin' ? '/usr/bin/open'
|
|
68
|
+
: platform() === 'win32' ? 'start'
|
|
69
|
+
: 'xdg-open'
|
|
70
|
+
|
|
71
|
+
let opened = false
|
|
72
|
+
const openBrowser = (url) => {
|
|
73
|
+
if (opened || !AUTO_OPEN) return
|
|
74
|
+
opened = true
|
|
75
|
+
console.error(`\n🚀 Opening Cortex UI in your browser: ${url}\n`)
|
|
76
|
+
const args = platform() === 'win32' ? ['', url] : [url]
|
|
77
|
+
try {
|
|
78
|
+
spawn(openCmd, args, { stdio: 'ignore', detached: true }).unref()
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error('cortex-octogent: failed to open browser —', err.message)
|
|
81
|
+
console.error(` Open manually: ${url}`)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Watch both stdout and stderr for the API URL pattern
|
|
86
|
+
const urlRegex = /https?:\/\/(?:127\.0\.0\.1|localhost)(?::\d+)?/
|
|
87
|
+
const watch = (stream, sink) => {
|
|
88
|
+
stream.on('data', (buf) => {
|
|
89
|
+
sink.write(buf)
|
|
90
|
+
if (!opened) {
|
|
91
|
+
const match = buf.toString().match(urlRegex)
|
|
92
|
+
if (match) openBrowser(match[0])
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
watch(child.stdout, process.stdout)
|
|
97
|
+
watch(child.stderr, process.stderr)
|
|
98
|
+
|
|
99
|
+
child.on('exit', (code) => process.exit(code ?? 0))
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { join, win32 } from 'path'
|
|
2
|
+
import { pathToFileURL } from 'url'
|
|
3
|
+
|
|
4
|
+
export function getDistImportSpecifier(baseDir) {
|
|
5
|
+
if (/^[A-Za-z]:\\/.test(baseDir)) {
|
|
6
|
+
const distPath = win32.join(baseDir, '..', 'dist', 'cli.mjs')
|
|
7
|
+
return `file:///${distPath.replace(/\\/g, '/')}`
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const joinImpl = join
|
|
11
|
+
const distPath = joinImpl(baseDir, '..', 'dist', 'cli.mjs')
|
|
12
|
+
return pathToFileURL(distPath).href
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import test from 'node:test'
|
|
3
|
+
|
|
4
|
+
import { getDistImportSpecifier } from './import-specifier.mjs'
|
|
5
|
+
|
|
6
|
+
test('builds a file URL import specifier for dist/cli.mjs', () => {
|
|
7
|
+
const specifier = getDistImportSpecifier('C:\\repo\\bin')
|
|
8
|
+
|
|
9
|
+
assert.equal(
|
|
10
|
+
specifier,
|
|
11
|
+
'file:///C:/repo/dist/cli.mjs',
|
|
12
|
+
)
|
|
13
|
+
})
|
package/bin/octo
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* octo — open the Cortex (Octogent) multi-agent UI in your browser.
|
|
4
|
+
*
|
|
5
|
+
* If Octogent isn't running, this launches it first and then opens the
|
|
6
|
+
* browser once the API is responsive.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* octo # launch (if needed) + open browser
|
|
10
|
+
* octo --no-open # launch without opening browser
|
|
11
|
+
* octo --status # print status only
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, readFileSync, readdirSync, mkdirSync, openSync } from 'node:fs'
|
|
14
|
+
import { dirname, resolve, join } from 'node:path'
|
|
15
|
+
import { fileURLToPath } from 'node:url'
|
|
16
|
+
import { spawn } from 'node:child_process'
|
|
17
|
+
import { homedir, platform } from 'node:os'
|
|
18
|
+
import http from 'node:http'
|
|
19
|
+
|
|
20
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
21
|
+
const REPO_ROOT = resolve(__dirname, '..')
|
|
22
|
+
|
|
23
|
+
const args = new Set(process.argv.slice(2))
|
|
24
|
+
const NO_OPEN = args.has('--no-open') || process.env.CORTEX_NO_OPEN === '1'
|
|
25
|
+
const STATUS_ONLY = args.has('--status')
|
|
26
|
+
|
|
27
|
+
const detectRunning = () => {
|
|
28
|
+
const root = join(homedir(), '.octogent', 'projects')
|
|
29
|
+
if (!existsSync(root)) return null
|
|
30
|
+
try {
|
|
31
|
+
for (const entry of readdirSync(root)) {
|
|
32
|
+
const metaPath = join(root, entry, 'state', 'runtime.json')
|
|
33
|
+
if (!existsSync(metaPath)) continue
|
|
34
|
+
try {
|
|
35
|
+
const meta = JSON.parse(readFileSync(metaPath, 'utf-8'))
|
|
36
|
+
if (meta?.apiBaseUrl && meta?.pid) {
|
|
37
|
+
try {
|
|
38
|
+
process.kill(meta.pid, 0)
|
|
39
|
+
return meta.apiBaseUrl
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
} catch {}
|
|
43
|
+
}
|
|
44
|
+
} catch {}
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const launch = () => {
|
|
49
|
+
const launcher = resolve(REPO_ROOT, 'bin/cortex-octogent')
|
|
50
|
+
const dist = resolve(REPO_ROOT, 'apps/octogent/dist/api/cli.js')
|
|
51
|
+
if (!existsSync(launcher) || !existsSync(dist)) {
|
|
52
|
+
console.error('✗ Octogent is not built.')
|
|
53
|
+
console.error(' Run: cd apps/octogent && pnpm install && pnpm build')
|
|
54
|
+
process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const logsDir = resolve(REPO_ROOT, 'logs')
|
|
58
|
+
try { mkdirSync(logsDir, { recursive: true }) } catch {}
|
|
59
|
+
const outLog = openSync(join(logsDir, 'octogent.out.log'), 'a')
|
|
60
|
+
const errLog = openSync(join(logsDir, 'octogent.err.log'), 'a')
|
|
61
|
+
|
|
62
|
+
const blockedBin = resolve(REPO_ROOT, '.bin')
|
|
63
|
+
const cleanPath = (process.env.PATH || '')
|
|
64
|
+
.split(':')
|
|
65
|
+
.filter(p => p && p !== blockedBin)
|
|
66
|
+
.join(':')
|
|
67
|
+
|
|
68
|
+
const child = spawn('node', [launcher], {
|
|
69
|
+
cwd: REPO_ROOT,
|
|
70
|
+
detached: true,
|
|
71
|
+
stdio: ['ignore', outLog, errLog],
|
|
72
|
+
env: {
|
|
73
|
+
...process.env,
|
|
74
|
+
PATH: cleanPath,
|
|
75
|
+
CORTEX_ALLOW_OPEN: '1',
|
|
76
|
+
OCTOGENT_NO_OPEN: '1',
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
child.unref()
|
|
80
|
+
return child.pid
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const waitReady = (url, timeoutMs = 30000) =>
|
|
84
|
+
new Promise(resolve => {
|
|
85
|
+
const deadline = Date.now() + timeoutMs
|
|
86
|
+
const tryOnce = () => {
|
|
87
|
+
const req = http.get(url, res => {
|
|
88
|
+
res.resume()
|
|
89
|
+
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 500) resolve(true)
|
|
90
|
+
else schedule()
|
|
91
|
+
})
|
|
92
|
+
req.on('error', schedule)
|
|
93
|
+
req.setTimeout(1500, () => { req.destroy(); schedule() })
|
|
94
|
+
}
|
|
95
|
+
const schedule = () => {
|
|
96
|
+
if (Date.now() > deadline) return resolve(false)
|
|
97
|
+
setTimeout(tryOnce, 400)
|
|
98
|
+
}
|
|
99
|
+
tryOnce()
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const openUrl = (url) => {
|
|
103
|
+
const plat = platform()
|
|
104
|
+
const [cmd, cmdArgs] =
|
|
105
|
+
plat === 'darwin' ? ['/usr/bin/open', [url]]
|
|
106
|
+
: plat === 'win32' ? ['cmd', ['/c', 'start', '', url]]
|
|
107
|
+
: ['xdg-open', [url]]
|
|
108
|
+
try {
|
|
109
|
+
spawn(cmd, cmdArgs, { stdio: 'ignore', detached: true }).unref()
|
|
110
|
+
return true
|
|
111
|
+
} catch {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ---- main ----
|
|
117
|
+
let url = detectRunning()
|
|
118
|
+
|
|
119
|
+
if (STATUS_ONLY) {
|
|
120
|
+
if (url) console.log(`✓ Octogent is running @ ${url}`)
|
|
121
|
+
else console.log('● Octogent is not running')
|
|
122
|
+
process.exit(0)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let launched = false
|
|
126
|
+
if (!url) {
|
|
127
|
+
console.error('🚀 Launching Octogent in the background...')
|
|
128
|
+
launch()
|
|
129
|
+
launched = true
|
|
130
|
+
url = 'http://127.0.0.1:8787'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const ready = await waitReady(url)
|
|
134
|
+
if (!ready) {
|
|
135
|
+
console.error(`⚠ Octogent did not respond within 30s — check logs/octogent.err.log`)
|
|
136
|
+
console.error(` URL: ${url}`)
|
|
137
|
+
process.exit(1)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (NO_OPEN) {
|
|
141
|
+
console.log(`✓ Cortex UI ready: ${url}`)
|
|
142
|
+
} else {
|
|
143
|
+
const bust = `${url}${url.includes('?') ? '&' : '?'}v=${Date.now()}`
|
|
144
|
+
const opened = openUrl(bust)
|
|
145
|
+
if (opened) console.log(`🌐 Opened Cortex UI: ${bust}`)
|
|
146
|
+
else console.log(`⚠ Could not auto-open browser — visit ${url}`)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (launched) console.log(' (Octogent started in background; logs/octogent.out.log)')
|
|
150
|
+
else console.log(' (Octogent was already running)')
|