@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,164 @@
|
|
|
1
|
+
import { type TerminalCompletionSoundId, isTerminalCompletionSoundId } from "@octogent/core";
|
|
2
|
+
|
|
3
|
+
export { type TerminalCompletionSoundId, isTerminalCompletionSoundId };
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_TERMINAL_COMPLETION_SOUND: TerminalCompletionSoundId = "pop";
|
|
6
|
+
|
|
7
|
+
export const TERMINAL_COMPLETION_SOUND_OPTIONS: Array<{
|
|
8
|
+
id: TerminalCompletionSoundId;
|
|
9
|
+
label: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}> = [
|
|
12
|
+
{
|
|
13
|
+
id: "soft-chime",
|
|
14
|
+
label: "Soft chime",
|
|
15
|
+
description: "Subtle short chime.",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "retro-beep",
|
|
19
|
+
label: "Retro beep",
|
|
20
|
+
description: "Classic terminal-style beep.",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "double-beep",
|
|
24
|
+
label: "Double beep",
|
|
25
|
+
description: "Two quick confirmation beeps.",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "bell",
|
|
29
|
+
label: "Bell",
|
|
30
|
+
description: "Bright bell-like ding.",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "pop",
|
|
34
|
+
label: "Pop",
|
|
35
|
+
description: "Very short soft pop.",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "silent",
|
|
39
|
+
label: "Silent",
|
|
40
|
+
description: "No completion sound.",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
type WaveformType = "sine" | "square";
|
|
45
|
+
|
|
46
|
+
type ToneStep = {
|
|
47
|
+
durationMs: number;
|
|
48
|
+
frequencyHz: number;
|
|
49
|
+
gain: number;
|
|
50
|
+
waveform: WaveformType;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const SAMPLE_RATE = 8_000;
|
|
54
|
+
|
|
55
|
+
const SOUND_PATTERNS: Record<TerminalCompletionSoundId, ToneStep[]> = {
|
|
56
|
+
"soft-chime": [
|
|
57
|
+
{ durationMs: 120, frequencyHz: 660, gain: 0.28, waveform: "sine" },
|
|
58
|
+
{ durationMs: 95, frequencyHz: 880, gain: 0.24, waveform: "sine" },
|
|
59
|
+
],
|
|
60
|
+
"retro-beep": [{ durationMs: 130, frequencyHz: 740, gain: 0.24, waveform: "square" }],
|
|
61
|
+
"double-beep": [
|
|
62
|
+
{ durationMs: 70, frequencyHz: 760, gain: 0.24, waveform: "square" },
|
|
63
|
+
{ durationMs: 45, frequencyHz: 0, gain: 0, waveform: "sine" },
|
|
64
|
+
{ durationMs: 70, frequencyHz: 920, gain: 0.24, waveform: "square" },
|
|
65
|
+
],
|
|
66
|
+
bell: [
|
|
67
|
+
{ durationMs: 115, frequencyHz: 988, gain: 0.24, waveform: "sine" },
|
|
68
|
+
{ durationMs: 150, frequencyHz: 1_320, gain: 0.12, waveform: "sine" },
|
|
69
|
+
],
|
|
70
|
+
pop: [{ durationMs: 58, frequencyHz: 520, gain: 0.24, waveform: "sine" }],
|
|
71
|
+
silent: [],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const writeWavHeader = (buffer: DataView, payloadByteLength: number) => {
|
|
75
|
+
const writeAscii = (offset: number, value: string) => {
|
|
76
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
77
|
+
buffer.setUint8(offset + index, value.charCodeAt(index));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
writeAscii(0, "RIFF");
|
|
82
|
+
buffer.setUint32(4, 36 + payloadByteLength, true);
|
|
83
|
+
writeAscii(8, "WAVE");
|
|
84
|
+
writeAscii(12, "fmt ");
|
|
85
|
+
buffer.setUint32(16, 16, true);
|
|
86
|
+
buffer.setUint16(20, 1, true);
|
|
87
|
+
buffer.setUint16(22, 1, true);
|
|
88
|
+
buffer.setUint32(24, SAMPLE_RATE, true);
|
|
89
|
+
buffer.setUint32(28, SAMPLE_RATE * 2, true);
|
|
90
|
+
buffer.setUint16(32, 2, true);
|
|
91
|
+
buffer.setUint16(34, 16, true);
|
|
92
|
+
writeAscii(36, "data");
|
|
93
|
+
buffer.setUint32(40, payloadByteLength, true);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const encodeBase64 = (bytes: Uint8Array): string | null => {
|
|
97
|
+
if (typeof btoa !== "function") {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let binary = "";
|
|
102
|
+
const chunkSize = 8_192;
|
|
103
|
+
for (let index = 0; index < bytes.length; index += chunkSize) {
|
|
104
|
+
const chunk = bytes.subarray(index, index + chunkSize);
|
|
105
|
+
binary += String.fromCharCode(...chunk);
|
|
106
|
+
}
|
|
107
|
+
return btoa(binary);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const buildStepSamples = (step: ToneStep): Int16Array => {
|
|
111
|
+
const sampleCount = Math.max(1, Math.round((SAMPLE_RATE * step.durationMs) / 1_000));
|
|
112
|
+
const attackSamples = Math.max(1, Math.round(sampleCount * 0.08));
|
|
113
|
+
const releaseSamples = Math.max(1, Math.round(sampleCount * 0.2));
|
|
114
|
+
const samples = new Int16Array(sampleCount);
|
|
115
|
+
|
|
116
|
+
if (step.frequencyHz <= 0 || step.gain <= 0) {
|
|
117
|
+
return samples;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
for (let sampleIndex = 0; sampleIndex < sampleCount; sampleIndex += 1) {
|
|
121
|
+
const time = sampleIndex / SAMPLE_RATE;
|
|
122
|
+
const phase = 2 * Math.PI * step.frequencyHz * time;
|
|
123
|
+
const waveformValue =
|
|
124
|
+
step.waveform === "square" ? (Math.sin(phase) >= 0 ? 1 : -1) : Math.sin(phase);
|
|
125
|
+
|
|
126
|
+
const attackLevel = Math.min(1, sampleIndex / attackSamples);
|
|
127
|
+
const releaseLevel = Math.min(1, (sampleCount - sampleIndex) / releaseSamples);
|
|
128
|
+
const envelope = Math.min(attackLevel, releaseLevel);
|
|
129
|
+
const amplitude = waveformValue * step.gain * envelope;
|
|
130
|
+
samples[sampleIndex] = Math.round(amplitude * 32_767);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return samples;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const buildTerminalCompletionSoundDataUrl = (
|
|
137
|
+
soundId: TerminalCompletionSoundId,
|
|
138
|
+
): string | null => {
|
|
139
|
+
const pattern = SOUND_PATTERNS[soundId];
|
|
140
|
+
if (pattern.length === 0) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const sampleParts = pattern.map((step) => buildStepSamples(step));
|
|
145
|
+
const totalSampleCount = sampleParts.reduce((count, part) => count + part.length, 0);
|
|
146
|
+
const payloadByteLength = totalSampleCount * 2;
|
|
147
|
+
const wavBytes = new Uint8Array(44 + payloadByteLength);
|
|
148
|
+
const wavView = new DataView(wavBytes.buffer);
|
|
149
|
+
writeWavHeader(wavView, payloadByteLength);
|
|
150
|
+
|
|
151
|
+
let writeOffset = 44;
|
|
152
|
+
for (const part of sampleParts) {
|
|
153
|
+
for (let sampleIndex = 0; sampleIndex < part.length; sampleIndex += 1) {
|
|
154
|
+
wavView.setInt16(writeOffset, part[sampleIndex] ?? 0, true);
|
|
155
|
+
writeOffset += 2;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const base64 = encodeBase64(wavBytes);
|
|
160
|
+
if (!base64) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return `data:audio/wav;base64,${base64}`;
|
|
164
|
+
};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import type { AgentRuntimeState } from "@octogent/core";
|
|
4
|
+
|
|
5
|
+
import type { TerminalView } from "./types";
|
|
6
|
+
|
|
7
|
+
export type TerminalRuntimeStateInfo = {
|
|
8
|
+
state: AgentRuntimeState;
|
|
9
|
+
toolName?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Listener = () => void;
|
|
13
|
+
type TerminalRuntimeStateMap = Record<string, TerminalRuntimeStateInfo>;
|
|
14
|
+
|
|
15
|
+
const areRuntimeStatesEqual = (
|
|
16
|
+
left: TerminalRuntimeStateInfo | undefined,
|
|
17
|
+
right: TerminalRuntimeStateInfo | undefined,
|
|
18
|
+
) => left?.state === right?.state && left?.toolName === right?.toolName;
|
|
19
|
+
|
|
20
|
+
const areRuntimeStateMapsEqual = (
|
|
21
|
+
left: ReadonlyMap<string, TerminalRuntimeStateInfo>,
|
|
22
|
+
right: ReadonlyMap<string, TerminalRuntimeStateInfo>,
|
|
23
|
+
) => {
|
|
24
|
+
if (left.size !== right.size) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const [terminalId, leftState] of left) {
|
|
29
|
+
if (!areRuntimeStatesEqual(leftState, right.get(terminalId))) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const sanitizeRuntimeState = (
|
|
38
|
+
state: TerminalRuntimeStateInfo | undefined,
|
|
39
|
+
): TerminalRuntimeStateInfo | undefined => {
|
|
40
|
+
if (!state) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
state: state.state,
|
|
46
|
+
...(state.toolName ? { toolName: state.toolName } : {}),
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const buildRuntimeStateMap = (terminals: TerminalView): TerminalRuntimeStateMap =>
|
|
51
|
+
terminals.reduce<TerminalRuntimeStateMap>((acc, terminal) => {
|
|
52
|
+
const state = getTerminalRuntimeStateInfo(terminal);
|
|
53
|
+
if (state) {
|
|
54
|
+
acc[terminal.terminalId] = state;
|
|
55
|
+
}
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
|
|
59
|
+
export const getTerminalRuntimeStateInfo = (
|
|
60
|
+
terminal: Pick<TerminalView[number], "agentRuntimeState">,
|
|
61
|
+
toolName?: string,
|
|
62
|
+
): TerminalRuntimeStateInfo | undefined => {
|
|
63
|
+
if (!terminal.agentRuntimeState) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
state: terminal.agentRuntimeState,
|
|
69
|
+
...(toolName ? { toolName } : {}),
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const stripTerminalRuntimeState = (terminal: TerminalView[number]): TerminalView[number] => {
|
|
74
|
+
const { agentRuntimeState: _agentRuntimeState, ...structuralTerminal } = terminal;
|
|
75
|
+
return structuralTerminal;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const stripTerminalRuntimeStates = (terminals: TerminalView): TerminalView =>
|
|
79
|
+
terminals.map((terminal) => stripTerminalRuntimeState(terminal));
|
|
80
|
+
|
|
81
|
+
export const createTerminalRuntimeStateStore = () => {
|
|
82
|
+
let stateByTerminalId: TerminalRuntimeStateMap = {};
|
|
83
|
+
const globalListeners = new Set<Listener>();
|
|
84
|
+
const listenersByTerminalId = new Map<string, Set<Listener>>();
|
|
85
|
+
|
|
86
|
+
const notifyListeners = (terminalIds: Iterable<string>) => {
|
|
87
|
+
const listeners = new Set(globalListeners);
|
|
88
|
+
for (const terminalId of terminalIds) {
|
|
89
|
+
const terminalListeners = listenersByTerminalId.get(terminalId);
|
|
90
|
+
if (!terminalListeners) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
for (const listener of terminalListeners) {
|
|
94
|
+
listeners.add(listener);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
for (const listener of listeners) {
|
|
99
|
+
listener();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const subscribe = (listener: Listener, terminalIds?: Iterable<string>) => {
|
|
104
|
+
if (!terminalIds) {
|
|
105
|
+
globalListeners.add(listener);
|
|
106
|
+
return () => {
|
|
107
|
+
globalListeners.delete(listener);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const trackedIds = [...terminalIds];
|
|
112
|
+
if (trackedIds.length === 0) {
|
|
113
|
+
return () => {};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const terminalId of trackedIds) {
|
|
117
|
+
const listeners = listenersByTerminalId.get(terminalId);
|
|
118
|
+
if (listeners) {
|
|
119
|
+
listeners.add(listener);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
listenersByTerminalId.set(terminalId, new Set([listener]));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return () => {
|
|
127
|
+
for (const terminalId of trackedIds) {
|
|
128
|
+
const listeners = listenersByTerminalId.get(terminalId);
|
|
129
|
+
if (!listeners) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
listeners.delete(listener);
|
|
134
|
+
if (listeners.size === 0) {
|
|
135
|
+
listenersByTerminalId.delete(terminalId);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const getRuntimeState = (terminalId: string) => stateByTerminalId[terminalId];
|
|
142
|
+
|
|
143
|
+
const getRuntimeStates = (terminalIds: Iterable<string>) => {
|
|
144
|
+
const next = new Map<string, TerminalRuntimeStateInfo>();
|
|
145
|
+
for (const terminalId of terminalIds) {
|
|
146
|
+
const state = stateByTerminalId[terminalId];
|
|
147
|
+
if (state) {
|
|
148
|
+
next.set(terminalId, state);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return next;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
subscribe,
|
|
156
|
+
|
|
157
|
+
getSnapshot() {
|
|
158
|
+
return stateByTerminalId;
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
getRuntimeState,
|
|
162
|
+
|
|
163
|
+
getRuntimeStates,
|
|
164
|
+
|
|
165
|
+
syncFromTerminals(terminals: TerminalView) {
|
|
166
|
+
const nextStateByTerminalId = buildRuntimeStateMap(terminals);
|
|
167
|
+
const changedTerminalIds = new Set<string>();
|
|
168
|
+
const activeTerminalIds = new Set(Object.keys(nextStateByTerminalId));
|
|
169
|
+
|
|
170
|
+
for (const [terminalId, nextState] of Object.entries(nextStateByTerminalId)) {
|
|
171
|
+
if (!areRuntimeStatesEqual(stateByTerminalId[terminalId], nextState)) {
|
|
172
|
+
changedTerminalIds.add(terminalId);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
for (const terminalId of Object.keys(stateByTerminalId)) {
|
|
177
|
+
if (!activeTerminalIds.has(terminalId)) {
|
|
178
|
+
changedTerminalIds.add(terminalId);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (changedTerminalIds.size === 0) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
stateByTerminalId = nextStateByTerminalId;
|
|
187
|
+
notifyListeners(changedTerminalIds);
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
setRuntimeState(terminalId: string, state: TerminalRuntimeStateInfo | undefined) {
|
|
191
|
+
const nextState = sanitizeRuntimeState(state);
|
|
192
|
+
if (areRuntimeStatesEqual(stateByTerminalId[terminalId], nextState)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (nextState) {
|
|
197
|
+
stateByTerminalId = {
|
|
198
|
+
...stateByTerminalId,
|
|
199
|
+
[terminalId]: nextState,
|
|
200
|
+
};
|
|
201
|
+
} else {
|
|
202
|
+
const { [terminalId]: _removedState, ...remainingStates } = stateByTerminalId;
|
|
203
|
+
stateByTerminalId = remainingStates;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
notifyListeners([terminalId]);
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
retainTerminalIds(activeTerminalIds: ReadonlySet<string>) {
|
|
210
|
+
const nextEntries = Object.entries(stateByTerminalId).filter(([terminalId]) =>
|
|
211
|
+
activeTerminalIds.has(terminalId),
|
|
212
|
+
);
|
|
213
|
+
if (nextEntries.length === Object.keys(stateByTerminalId).length) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const removedTerminalIds = Object.keys(stateByTerminalId).filter(
|
|
218
|
+
(terminalId) => !activeTerminalIds.has(terminalId),
|
|
219
|
+
);
|
|
220
|
+
stateByTerminalId = Object.fromEntries(nextEntries);
|
|
221
|
+
notifyListeners(removedTerminalIds);
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
removeTerminal(terminalId: string) {
|
|
225
|
+
if (!(terminalId in stateByTerminalId)) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const { [terminalId]: _removedState, ...remainingStates } = stateByTerminalId;
|
|
230
|
+
stateByTerminalId = remainingStates;
|
|
231
|
+
notifyListeners([terminalId]);
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export type TerminalRuntimeStateStore = ReturnType<typeof createTerminalRuntimeStateStore>;
|
|
237
|
+
|
|
238
|
+
export const useTerminalRuntimeStates = (
|
|
239
|
+
runtimeStateStore: TerminalRuntimeStateStore,
|
|
240
|
+
terminalIds: string[],
|
|
241
|
+
): Map<string, TerminalRuntimeStateInfo> => {
|
|
242
|
+
const [runtimeStates, setRuntimeStates] = useState(() =>
|
|
243
|
+
runtimeStateStore.getRuntimeStates(terminalIds),
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
useEffect(() => {
|
|
247
|
+
setRuntimeStates((current) => {
|
|
248
|
+
const next = runtimeStateStore.getRuntimeStates(terminalIds);
|
|
249
|
+
return areRuntimeStateMapsEqual(current, next) ? current : next;
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
return runtimeStateStore.subscribe(() => {
|
|
253
|
+
setRuntimeStates((current) => {
|
|
254
|
+
const next = runtimeStateStore.getRuntimeStates(terminalIds);
|
|
255
|
+
return areRuntimeStateMapsEqual(current, next) ? current : next;
|
|
256
|
+
});
|
|
257
|
+
}, terminalIds);
|
|
258
|
+
}, [runtimeStateStore, terminalIds]);
|
|
259
|
+
|
|
260
|
+
return runtimeStates;
|
|
261
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const retainActiveTerminalIds = (
|
|
2
|
+
terminalIds: string[],
|
|
3
|
+
activeTerminalIds: ReadonlySet<string>,
|
|
4
|
+
) => {
|
|
5
|
+
const nextTerminalIds = terminalIds.filter((terminalId) => activeTerminalIds.has(terminalId));
|
|
6
|
+
return nextTerminalIds.length === terminalIds.length ? terminalIds : nextTerminalIds;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const retainActiveTerminalEntries = <TState>(
|
|
10
|
+
state: Record<string, TState>,
|
|
11
|
+
activeTerminalIds: ReadonlySet<string>,
|
|
12
|
+
) => {
|
|
13
|
+
const retainedStateEntries = Object.entries(state).filter(([terminalId]) =>
|
|
14
|
+
activeTerminalIds.has(terminalId),
|
|
15
|
+
);
|
|
16
|
+
if (retainedStateEntries.length === Object.keys(state).length) {
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return Object.fromEntries(retainedStateEntries);
|
|
21
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { GitHubCommitPoint, buildTerminalList } from "@octogent/core";
|
|
2
|
+
|
|
3
|
+
export type TerminalView = Awaited<ReturnType<typeof buildTerminalList>>;
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
CodexUsageSnapshot,
|
|
7
|
+
ClaudeUsageSnapshot,
|
|
8
|
+
GitHubCommitPoint,
|
|
9
|
+
GitHubRecentCommit,
|
|
10
|
+
GitHubRepoSummarySnapshot,
|
|
11
|
+
TerminalAgentProvider,
|
|
12
|
+
TentacleGitStatusSnapshot,
|
|
13
|
+
TentaclePullRequestSnapshot,
|
|
14
|
+
MonitorUsageSnapshot,
|
|
15
|
+
MonitorPost,
|
|
16
|
+
MonitorConfigSnapshot,
|
|
17
|
+
MonitorFeedSnapshot,
|
|
18
|
+
ConversationTurn,
|
|
19
|
+
ConversationTranscriptEvent,
|
|
20
|
+
ConversationSessionSummary,
|
|
21
|
+
ConversationSessionDetail,
|
|
22
|
+
ConversationSearchHit,
|
|
23
|
+
} from "@octogent/core";
|
|
24
|
+
|
|
25
|
+
export type { PersistedUiState as FrontendUiStateSnapshot } from "@octogent/core";
|
|
26
|
+
export type { TentacleWorkspaceMode as TerminalWorkspaceMode } from "@octogent/core";
|
|
27
|
+
|
|
28
|
+
export type GitHubCommitSparkPoint = GitHubCommitPoint & {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type PromptLibraryEntry = {
|
|
34
|
+
name: string;
|
|
35
|
+
source: "builtin" | "user";
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type PromptDetail = {
|
|
39
|
+
name: string;
|
|
40
|
+
source: "builtin" | "user";
|
|
41
|
+
content: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { asRecord } from "@octogent/core";
|
|
2
|
+
|
|
3
|
+
import { MAX_SIDEBAR_WIDTH, MIN_SIDEBAR_WIDTH, PRIMARY_NAV_MAX } from "./constants";
|
|
4
|
+
import { isTerminalCompletionSoundId } from "./notificationSounds";
|
|
5
|
+
import type { FrontendUiStateSnapshot } from "./types";
|
|
6
|
+
|
|
7
|
+
export const clampSidebarWidth = (width: number) =>
|
|
8
|
+
Math.min(MAX_SIDEBAR_WIDTH, Math.max(MIN_SIDEBAR_WIDTH, width));
|
|
9
|
+
|
|
10
|
+
export const normalizeFrontendUiStateSnapshot = (
|
|
11
|
+
value: unknown,
|
|
12
|
+
): FrontendUiStateSnapshot | null => {
|
|
13
|
+
const record = asRecord(value);
|
|
14
|
+
if (!record) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const nextState: FrontendUiStateSnapshot = {};
|
|
19
|
+
if (
|
|
20
|
+
typeof record.activePrimaryNav === "number" &&
|
|
21
|
+
Number.isInteger(record.activePrimaryNav) &&
|
|
22
|
+
record.activePrimaryNav >= 1 &&
|
|
23
|
+
record.activePrimaryNav <= PRIMARY_NAV_MAX
|
|
24
|
+
) {
|
|
25
|
+
nextState.activePrimaryNav = record.activePrimaryNav;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof record.isAgentsSidebarVisible === "boolean") {
|
|
29
|
+
nextState.isAgentsSidebarVisible = record.isAgentsSidebarVisible;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof record.sidebarWidth === "number" && Number.isFinite(record.sidebarWidth)) {
|
|
33
|
+
nextState.sidebarWidth = clampSidebarWidth(record.sidebarWidth);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (typeof record.isActiveAgentsSectionExpanded === "boolean") {
|
|
37
|
+
nextState.isActiveAgentsSectionExpanded = record.isActiveAgentsSectionExpanded;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof record.isRuntimeStatusStripVisible === "boolean") {
|
|
41
|
+
nextState.isRuntimeStatusStripVisible = record.isRuntimeStatusStripVisible;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (typeof record.isMonitorVisible === "boolean") {
|
|
45
|
+
nextState.isMonitorVisible = record.isMonitorVisible;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof record.isBottomTelemetryVisible === "boolean") {
|
|
49
|
+
nextState.isBottomTelemetryVisible = record.isBottomTelemetryVisible;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof record.isCodexUsageVisible === "boolean") {
|
|
53
|
+
nextState.isCodexUsageVisible = record.isCodexUsageVisible;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof record.isClaudeUsageVisible === "boolean") {
|
|
57
|
+
nextState.isClaudeUsageVisible = record.isClaudeUsageVisible;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (typeof record.isCodexUsageSectionExpanded === "boolean") {
|
|
61
|
+
nextState.isCodexUsageSectionExpanded = record.isCodexUsageSectionExpanded;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (typeof record.isClaudeUsageSectionExpanded === "boolean") {
|
|
65
|
+
nextState.isClaudeUsageSectionExpanded = record.isClaudeUsageSectionExpanded;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const completionSoundValue = record.terminalCompletionSound;
|
|
69
|
+
if (isTerminalCompletionSoundId(completionSoundValue)) {
|
|
70
|
+
nextState.terminalCompletionSound = completionSoundValue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const minimizedIdsValue = record.minimizedTerminalIds;
|
|
74
|
+
if (Array.isArray(minimizedIdsValue)) {
|
|
75
|
+
nextState.minimizedTerminalIds = [...new Set(minimizedIdsValue)].filter(
|
|
76
|
+
(id): id is string => typeof id === "string",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const rawTerminalWidths = asRecord(record.terminalWidths);
|
|
81
|
+
if (rawTerminalWidths) {
|
|
82
|
+
nextState.terminalWidths = Object.entries(rawTerminalWidths).reduce<Record<string, number>>(
|
|
83
|
+
(acc, [terminalId, width]) => {
|
|
84
|
+
if (typeof width === "number" && Number.isFinite(width)) {
|
|
85
|
+
acc[terminalId] = width;
|
|
86
|
+
}
|
|
87
|
+
return acc;
|
|
88
|
+
},
|
|
89
|
+
{},
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (Array.isArray(record.canvasOpenTerminalIds)) {
|
|
94
|
+
nextState.canvasOpenTerminalIds = record.canvasOpenTerminalIds.filter(
|
|
95
|
+
(id): id is string => typeof id === "string",
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (Array.isArray(record.canvasOpenTentacleIds)) {
|
|
100
|
+
nextState.canvasOpenTentacleIds = record.canvasOpenTentacleIds.filter(
|
|
101
|
+
(id): id is string => typeof id === "string",
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
typeof record.canvasTerminalsPanelWidth === "number" &&
|
|
107
|
+
Number.isFinite(record.canvasTerminalsPanelWidth)
|
|
108
|
+
) {
|
|
109
|
+
nextState.canvasTerminalsPanelWidth = record.canvasTerminalsPanelWidth;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return nextState;
|
|
113
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { asNumber, asRecord, asString } from "@octogent/core";
|
|
2
|
+
|
|
3
|
+
import type { ClaudeUsageSnapshot, CodexUsageSnapshot } from "./types";
|
|
4
|
+
|
|
5
|
+
export const normalizeCodexUsageSnapshot = (value: unknown): CodexUsageSnapshot | null => {
|
|
6
|
+
const record = asRecord(value);
|
|
7
|
+
if (!record) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const status = record.status;
|
|
12
|
+
if (status !== "ok" && status !== "unavailable" && status !== "error") {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const source = record.source === "oauth-api" ? "oauth-api" : "none";
|
|
17
|
+
return {
|
|
18
|
+
status,
|
|
19
|
+
source,
|
|
20
|
+
fetchedAt: asString(record.fetchedAt) ?? new Date().toISOString(),
|
|
21
|
+
message: asString(record.message),
|
|
22
|
+
planType: asString(record.planType),
|
|
23
|
+
primaryUsedPercent: asNumber(record.primaryUsedPercent),
|
|
24
|
+
secondaryUsedPercent: asNumber(record.secondaryUsedPercent),
|
|
25
|
+
creditsBalance: asNumber(record.creditsBalance),
|
|
26
|
+
creditsUnlimited: typeof record.creditsUnlimited === "boolean" ? record.creditsUnlimited : null,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const normalizeClaudeUsageSnapshot = (value: unknown): ClaudeUsageSnapshot | null => {
|
|
31
|
+
const record = asRecord(value);
|
|
32
|
+
if (!record) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const status = record.status;
|
|
37
|
+
if (status !== "ok" && status !== "unavailable" && status !== "error") {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const source =
|
|
42
|
+
record.source === "cli-pty" ? "cli-pty" : record.source === "oauth-api" ? "oauth-api" : "none";
|
|
43
|
+
return {
|
|
44
|
+
status,
|
|
45
|
+
source,
|
|
46
|
+
fetchedAt: asString(record.fetchedAt) ?? new Date().toISOString(),
|
|
47
|
+
message: asString(record.message),
|
|
48
|
+
planType: asString(record.planType),
|
|
49
|
+
primaryUsedPercent: asNumber(record.primaryUsedPercent),
|
|
50
|
+
primaryResetAt: asString(record.primaryResetAt),
|
|
51
|
+
secondaryUsedPercent: asNumber(record.secondaryUsedPercent),
|
|
52
|
+
secondaryResetAt: asString(record.secondaryResetAt),
|
|
53
|
+
sonnetUsedPercent: asNumber(record.sonnetUsedPercent),
|
|
54
|
+
sonnetResetAt: asString(record.sonnetResetAt),
|
|
55
|
+
extraUsageCostUsed: asNumber(record.extraUsageCostUsed),
|
|
56
|
+
extraUsageCostLimit: asNumber(record.extraUsageCostLimit),
|
|
57
|
+
};
|
|
58
|
+
};
|