@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
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { TERMINAL_REGISTRY_VERSION } from "./constants";
|
|
6
|
+
|
|
7
|
+
import { toErrorMessage } from "./systemClients";
|
|
8
|
+
import type {
|
|
9
|
+
PersistedTerminal,
|
|
10
|
+
PersistedUiState,
|
|
11
|
+
TentacleWorkspaceMode,
|
|
12
|
+
TerminalNameOrigin,
|
|
13
|
+
TerminalRegistryDocument,
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { isTerminalAgentProvider, isTerminalCompletionSoundId } from "./types";
|
|
16
|
+
|
|
17
|
+
const REGISTRY_PERSIST_DEBOUNCE_MS = 100;
|
|
18
|
+
|
|
19
|
+
type TerminalRegistryState = {
|
|
20
|
+
terminals: Map<string, PersistedTerminal>;
|
|
21
|
+
uiState: PersistedUiState;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
25
|
+
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
26
|
+
|
|
27
|
+
const isTerminalNameOrigin = (value: unknown): value is TerminalNameOrigin =>
|
|
28
|
+
value === "generated" || value === "user" || value === "prompt";
|
|
29
|
+
|
|
30
|
+
const inferTerminalNameOrigin = (terminalId: string, tentacleName: string): TerminalNameOrigin => {
|
|
31
|
+
if (tentacleName === terminalId || /^Octogent Terminal \d+$/.test(tentacleName)) {
|
|
32
|
+
return "generated";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return "user";
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const parsePersistedUiState = (value: unknown): PersistedUiState => {
|
|
39
|
+
if (!isRecord(value)) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const nextState: PersistedUiState = {};
|
|
44
|
+
|
|
45
|
+
if (typeof value.isAgentsSidebarVisible === "boolean") {
|
|
46
|
+
nextState.isAgentsSidebarVisible = value.isAgentsSidebarVisible;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (typeof value.sidebarWidth === "number" && Number.isFinite(value.sidebarWidth)) {
|
|
50
|
+
nextState.sidebarWidth = value.sidebarWidth;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof value.isActiveAgentsSectionExpanded === "boolean") {
|
|
54
|
+
nextState.isActiveAgentsSectionExpanded = value.isActiveAgentsSectionExpanded;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof value.isRuntimeStatusStripVisible === "boolean") {
|
|
58
|
+
nextState.isRuntimeStatusStripVisible = value.isRuntimeStatusStripVisible;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof value.isMonitorVisible === "boolean") {
|
|
62
|
+
nextState.isMonitorVisible = value.isMonitorVisible;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (typeof value.isBottomTelemetryVisible === "boolean") {
|
|
66
|
+
nextState.isBottomTelemetryVisible = value.isBottomTelemetryVisible;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof value.isCodexUsageVisible === "boolean") {
|
|
70
|
+
nextState.isCodexUsageVisible = value.isCodexUsageVisible;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (typeof value.isClaudeUsageVisible === "boolean") {
|
|
74
|
+
nextState.isClaudeUsageVisible = value.isClaudeUsageVisible;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (typeof value.isClaudeUsageSectionExpanded === "boolean") {
|
|
78
|
+
nextState.isClaudeUsageSectionExpanded = value.isClaudeUsageSectionExpanded;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof value.isCodexUsageSectionExpanded === "boolean") {
|
|
82
|
+
nextState.isCodexUsageSectionExpanded = value.isCodexUsageSectionExpanded;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const completionSoundValue = value.terminalCompletionSound;
|
|
86
|
+
if (isTerminalCompletionSoundId(completionSoundValue)) {
|
|
87
|
+
nextState.terminalCompletionSound = completionSoundValue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const minimizedIds = value.minimizedTerminalIds;
|
|
91
|
+
if (Array.isArray(minimizedIds)) {
|
|
92
|
+
const ids = minimizedIds.filter((id): id is string => typeof id === "string");
|
|
93
|
+
nextState.minimizedTerminalIds = [...new Set(ids)];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const widths = value.terminalWidths;
|
|
97
|
+
if (isRecord(widths)) {
|
|
98
|
+
const terminalWidths = Object.entries(widths).reduce<Record<string, number>>(
|
|
99
|
+
(acc, [id, width]) => {
|
|
100
|
+
if (typeof width === "number" && Number.isFinite(width)) {
|
|
101
|
+
acc[id] = width;
|
|
102
|
+
}
|
|
103
|
+
return acc;
|
|
104
|
+
},
|
|
105
|
+
{},
|
|
106
|
+
);
|
|
107
|
+
nextState.terminalWidths = terminalWidths;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (Array.isArray(value.canvasOpenTerminalIds)) {
|
|
111
|
+
nextState.canvasOpenTerminalIds = value.canvasOpenTerminalIds.filter(
|
|
112
|
+
(id): id is string => typeof id === "string",
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (Array.isArray(value.canvasOpenTentacleIds)) {
|
|
117
|
+
nextState.canvasOpenTentacleIds = value.canvasOpenTentacleIds.filter(
|
|
118
|
+
(id): id is string => typeof id === "string",
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (
|
|
123
|
+
typeof value.canvasTerminalsPanelWidth === "number" &&
|
|
124
|
+
Number.isFinite(value.canvasTerminalsPanelWidth)
|
|
125
|
+
) {
|
|
126
|
+
nextState.canvasTerminalsPanelWidth = value.canvasTerminalsPanelWidth;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return nextState;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const pruneUiStateTerminalReferences = (
|
|
133
|
+
uiState: PersistedUiState,
|
|
134
|
+
terminals: Map<string, PersistedTerminal>,
|
|
135
|
+
): PersistedUiState => {
|
|
136
|
+
const activeTerminalIds = new Set(terminals.keys());
|
|
137
|
+
const nextState: PersistedUiState = {
|
|
138
|
+
...uiState,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
if (nextState.minimizedTerminalIds) {
|
|
142
|
+
nextState.minimizedTerminalIds = nextState.minimizedTerminalIds.filter((id) =>
|
|
143
|
+
activeTerminalIds.has(id),
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (nextState.terminalWidths) {
|
|
148
|
+
nextState.terminalWidths = Object.entries(nextState.terminalWidths).reduce<
|
|
149
|
+
Record<string, number>
|
|
150
|
+
>((acc, [id, width]) => {
|
|
151
|
+
if (activeTerminalIds.has(id)) {
|
|
152
|
+
acc[id] = width;
|
|
153
|
+
}
|
|
154
|
+
return acc;
|
|
155
|
+
}, {});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return nextState;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Migrate a v1/v2 registry document to v3 terminal format.
|
|
163
|
+
* Each old tentacle entry becomes a terminal where terminalId = tentacleId.
|
|
164
|
+
* Child agents are dropped.
|
|
165
|
+
*/
|
|
166
|
+
const migrateV2ToV3 = (
|
|
167
|
+
record: Record<string, unknown>,
|
|
168
|
+
registryPath: string,
|
|
169
|
+
): Map<string, PersistedTerminal> => {
|
|
170
|
+
const rawTentacles = record.tentacles;
|
|
171
|
+
if (!Array.isArray(rawTentacles)) {
|
|
172
|
+
throw new Error(`Invalid registry tentacles array (${registryPath}).`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const terminals = new Map<string, PersistedTerminal>();
|
|
176
|
+
for (const item of rawTentacles) {
|
|
177
|
+
if (item === null || typeof item !== "object") {
|
|
178
|
+
throw new Error(`Invalid tentacle entry in registry (${registryPath}).`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const entry = item as Record<string, unknown>;
|
|
182
|
+
const tentacleId = typeof entry.tentacleId === "string" ? entry.tentacleId : null;
|
|
183
|
+
const tentacleName = typeof entry.tentacleName === "string" ? entry.tentacleName : null;
|
|
184
|
+
const createdAt = typeof entry.createdAt === "string" ? entry.createdAt : null;
|
|
185
|
+
|
|
186
|
+
if (!tentacleId || !tentacleName || !createdAt) {
|
|
187
|
+
throw new Error(`Incomplete tentacle entry in registry (${registryPath}).`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const rawWorkspaceMode = entry.workspaceMode;
|
|
191
|
+
const workspaceMode: TentacleWorkspaceMode =
|
|
192
|
+
rawWorkspaceMode === "worktree" || rawWorkspaceMode === "shared"
|
|
193
|
+
? rawWorkspaceMode
|
|
194
|
+
: "shared";
|
|
195
|
+
|
|
196
|
+
if (terminals.has(tentacleId)) {
|
|
197
|
+
throw new Error(`Duplicate tentacle id in registry (${registryPath}): ${tentacleId}`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
terminals.set(tentacleId, {
|
|
201
|
+
terminalId: tentacleId,
|
|
202
|
+
tentacleId,
|
|
203
|
+
tentacleName,
|
|
204
|
+
nameOrigin: inferTerminalNameOrigin(tentacleId, tentacleName),
|
|
205
|
+
createdAt,
|
|
206
|
+
workspaceMode,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return terminals;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const parseV3Terminals = (
|
|
214
|
+
record: Record<string, unknown>,
|
|
215
|
+
registryPath: string,
|
|
216
|
+
): Map<string, PersistedTerminal> => {
|
|
217
|
+
const rawTerminals = record.terminals;
|
|
218
|
+
if (!Array.isArray(rawTerminals)) {
|
|
219
|
+
throw new Error(`Invalid registry terminals array (${registryPath}).`);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const terminals = new Map<string, PersistedTerminal>();
|
|
223
|
+
for (const item of rawTerminals) {
|
|
224
|
+
if (item === null || typeof item !== "object") {
|
|
225
|
+
throw new Error(`Invalid terminal entry in registry (${registryPath}).`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const entry = item as Record<string, unknown>;
|
|
229
|
+
const terminalId = typeof entry.terminalId === "string" ? entry.terminalId : null;
|
|
230
|
+
const tentacleId = typeof entry.tentacleId === "string" ? entry.tentacleId : null;
|
|
231
|
+
const tentacleName = typeof entry.tentacleName === "string" ? entry.tentacleName : null;
|
|
232
|
+
const createdAt = typeof entry.createdAt === "string" ? entry.createdAt : null;
|
|
233
|
+
|
|
234
|
+
if (!terminalId || !tentacleId || !tentacleName || !createdAt) {
|
|
235
|
+
throw new Error(`Incomplete terminal entry in registry (${registryPath}).`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const rawWorkspaceMode = entry.workspaceMode;
|
|
239
|
+
const workspaceMode: TentacleWorkspaceMode =
|
|
240
|
+
rawWorkspaceMode === "worktree" || rawWorkspaceMode === "shared"
|
|
241
|
+
? rawWorkspaceMode
|
|
242
|
+
: "shared";
|
|
243
|
+
|
|
244
|
+
if (terminals.has(terminalId)) {
|
|
245
|
+
throw new Error(`Duplicate terminal id in registry (${registryPath}): ${terminalId}`);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const terminal: PersistedTerminal = {
|
|
249
|
+
terminalId,
|
|
250
|
+
tentacleId,
|
|
251
|
+
tentacleName,
|
|
252
|
+
nameOrigin: isTerminalNameOrigin(entry.nameOrigin)
|
|
253
|
+
? entry.nameOrigin
|
|
254
|
+
: inferTerminalNameOrigin(terminalId, tentacleName),
|
|
255
|
+
createdAt,
|
|
256
|
+
workspaceMode,
|
|
257
|
+
};
|
|
258
|
+
if (typeof entry.worktreeId === "string") terminal.worktreeId = entry.worktreeId;
|
|
259
|
+
if (typeof entry.parentTerminalId === "string")
|
|
260
|
+
terminal.parentTerminalId = entry.parentTerminalId;
|
|
261
|
+
if (isTerminalAgentProvider(entry.agentProvider)) terminal.agentProvider = entry.agentProvider;
|
|
262
|
+
if (typeof entry.initialPrompt === "string") terminal.initialPrompt = entry.initialPrompt;
|
|
263
|
+
if (typeof entry.initialInputDraft === "string") {
|
|
264
|
+
terminal.initialInputDraft = entry.initialInputDraft;
|
|
265
|
+
}
|
|
266
|
+
if (typeof entry.autoRenamePromptContext === "string") {
|
|
267
|
+
terminal.autoRenamePromptContext = entry.autoRenamePromptContext;
|
|
268
|
+
}
|
|
269
|
+
if (typeof entry.lastActiveAt === "string") terminal.lastActiveAt = entry.lastActiveAt;
|
|
270
|
+
terminals.set(terminalId, terminal);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return terminals;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const parseRegistryDocument = (
|
|
277
|
+
raw: string,
|
|
278
|
+
registryPath: string,
|
|
279
|
+
): {
|
|
280
|
+
terminals: Map<string, PersistedTerminal>;
|
|
281
|
+
uiState: PersistedUiState;
|
|
282
|
+
} => {
|
|
283
|
+
let parsed: unknown;
|
|
284
|
+
try {
|
|
285
|
+
parsed = JSON.parse(raw);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
throw new Error(`Invalid terminal registry JSON (${registryPath}): ${toErrorMessage(error)}`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (parsed === null || typeof parsed !== "object") {
|
|
291
|
+
throw new Error(`Invalid terminal registry shape (${registryPath}).`);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const record = parsed as Record<string, unknown>;
|
|
295
|
+
const version = record.version;
|
|
296
|
+
|
|
297
|
+
if (version !== 1 && version !== 2 && version !== TERMINAL_REGISTRY_VERSION) {
|
|
298
|
+
throw new Error(`Unsupported terminal registry version in ${registryPath}: ${String(version)}`);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const terminals =
|
|
302
|
+
version === 1 || version === 2
|
|
303
|
+
? migrateV2ToV3(record, registryPath)
|
|
304
|
+
: parseV3Terminals(record, registryPath);
|
|
305
|
+
|
|
306
|
+
return {
|
|
307
|
+
terminals,
|
|
308
|
+
uiState: pruneUiStateTerminalReferences(parsePersistedUiState(record.uiState), terminals),
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export const loadTerminalRegistry = (registryPath: string) => {
|
|
313
|
+
if (!existsSync(registryPath)) {
|
|
314
|
+
return {
|
|
315
|
+
terminals: new Map<string, PersistedTerminal>(),
|
|
316
|
+
uiState: {} as PersistedUiState,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const raw = readFileSync(registryPath, "utf8");
|
|
321
|
+
return parseRegistryDocument(raw, registryPath);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const serializeTerminalRegistry = (state: TerminalRegistryState) => {
|
|
325
|
+
const document: TerminalRegistryDocument = {
|
|
326
|
+
version: TERMINAL_REGISTRY_VERSION,
|
|
327
|
+
terminals: [...state.terminals.values()],
|
|
328
|
+
uiState: state.uiState,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
return `${JSON.stringify(document, null, 2)}\n`;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const writeSerializedRegistrySync = (registryPath: string, serialized: string) => {
|
|
335
|
+
mkdirSync(dirname(registryPath), { recursive: true });
|
|
336
|
+
writeFileSync(registryPath, serialized, "utf8");
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const writeSerializedRegistry = async (registryPath: string, serialized: string) => {
|
|
340
|
+
mkdirSync(dirname(registryPath), { recursive: true });
|
|
341
|
+
await writeFile(registryPath, serialized, "utf8");
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export const persistTerminalRegistry = (registryPath: string, state: TerminalRegistryState) => {
|
|
345
|
+
writeSerializedRegistrySync(registryPath, serializeTerminalRegistry(state));
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export const createTerminalRegistryPersistence = (registryPath: string) => {
|
|
349
|
+
let pendingSerialized: string | null = null;
|
|
350
|
+
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
351
|
+
let writeLoopPromise: Promise<void> | null = null;
|
|
352
|
+
let lastPersistedSerialized: string | null = null;
|
|
353
|
+
|
|
354
|
+
const runWriteLoop = (): Promise<void> => {
|
|
355
|
+
if (writeLoopPromise) {
|
|
356
|
+
return writeLoopPromise;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (pendingSerialized === null) {
|
|
360
|
+
return Promise.resolve();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
writeLoopPromise = (async () => {
|
|
364
|
+
while (pendingSerialized !== null) {
|
|
365
|
+
const serialized = pendingSerialized;
|
|
366
|
+
pendingSerialized = null;
|
|
367
|
+
|
|
368
|
+
try {
|
|
369
|
+
await writeSerializedRegistry(registryPath, serialized);
|
|
370
|
+
lastPersistedSerialized = serialized;
|
|
371
|
+
} catch (error) {
|
|
372
|
+
console.warn("[terminal-registry] Failed to persist registry:", error);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
})().finally(() => {
|
|
376
|
+
writeLoopPromise = null;
|
|
377
|
+
if (pendingSerialized !== null) {
|
|
378
|
+
void runWriteLoop();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
return writeLoopPromise;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const clearDebounceTimer = () => {
|
|
386
|
+
if (debounceTimer !== null) {
|
|
387
|
+
clearTimeout(debounceTimer);
|
|
388
|
+
debounceTimer = null;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const flush = async () => {
|
|
393
|
+
clearDebounceTimer();
|
|
394
|
+
await runWriteLoop();
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
return {
|
|
398
|
+
schedulePersist(state: TerminalRegistryState) {
|
|
399
|
+
const serialized = serializeTerminalRegistry(state);
|
|
400
|
+
if (
|
|
401
|
+
serialized === pendingSerialized ||
|
|
402
|
+
(pendingSerialized === null &&
|
|
403
|
+
writeLoopPromise === null &&
|
|
404
|
+
serialized === lastPersistedSerialized)
|
|
405
|
+
) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
pendingSerialized = serialized;
|
|
410
|
+
clearDebounceTimer();
|
|
411
|
+
debounceTimer = setTimeout(() => {
|
|
412
|
+
debounceTimer = null;
|
|
413
|
+
void runWriteLoop();
|
|
414
|
+
}, REGISTRY_PERSIST_DEBOUNCE_MS);
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
flush,
|
|
418
|
+
|
|
419
|
+
async close() {
|
|
420
|
+
await flush();
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
};
|