@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,278 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { type CodexUsageSnapshot, asNumber, asRecord, asString } from "@octogent/core";
|
|
6
|
+
import { toResetIso } from "./usageUtils";
|
|
7
|
+
|
|
8
|
+
const EIGHT_DAYS_MS = 8 * 24 * 60 * 60 * 1000;
|
|
9
|
+
const OAUTH_REFRESH_URL = "https://auth.openai.com/oauth/token";
|
|
10
|
+
const OAUTH_REFRESH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
11
|
+
const OAUTH_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
|
|
12
|
+
|
|
13
|
+
const resolveCodexHome = (env: NodeJS.ProcessEnv): string => {
|
|
14
|
+
const codexHome = env.CODEX_HOME?.trim();
|
|
15
|
+
if (codexHome && codexHome.length > 0) {
|
|
16
|
+
return codexHome;
|
|
17
|
+
}
|
|
18
|
+
return join(homedir(), ".codex");
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type CodexCredentials = {
|
|
22
|
+
accessToken: string;
|
|
23
|
+
refreshToken: string | null;
|
|
24
|
+
accountId: string | null;
|
|
25
|
+
lastRefresh: Date | null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type CodexUsageApiResponse = {
|
|
29
|
+
plan_type?: unknown;
|
|
30
|
+
rate_limit?: unknown;
|
|
31
|
+
credits?: unknown;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type RefreshTokenResponse = {
|
|
35
|
+
access_token?: unknown;
|
|
36
|
+
refresh_token?: unknown;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type { CodexUsageSnapshot };
|
|
40
|
+
|
|
41
|
+
type CodexUsageStatus = CodexUsageSnapshot["status"];
|
|
42
|
+
|
|
43
|
+
type CodexUsageDependencies = {
|
|
44
|
+
env?: NodeJS.ProcessEnv;
|
|
45
|
+
now?: () => Date;
|
|
46
|
+
readFileText?: (path: string) => Promise<string>;
|
|
47
|
+
writeFileText?: (path: string, contents: string) => Promise<void>;
|
|
48
|
+
fetchImpl?: typeof fetch;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const unavailableSnapshot = (
|
|
52
|
+
now: Date,
|
|
53
|
+
message: string,
|
|
54
|
+
status: CodexUsageStatus = "unavailable",
|
|
55
|
+
): CodexUsageSnapshot => ({
|
|
56
|
+
status,
|
|
57
|
+
source: "none",
|
|
58
|
+
fetchedAt: now.toISOString(),
|
|
59
|
+
message,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const mapUsageResponse = (response: CodexUsageApiResponse, now: Date): CodexUsageSnapshot => {
|
|
63
|
+
const rateLimit = asRecord(response.rate_limit);
|
|
64
|
+
const primaryWindow = asRecord(rateLimit?.primary_window);
|
|
65
|
+
const secondaryWindow = asRecord(rateLimit?.secondary_window);
|
|
66
|
+
const credits = asRecord(response.credits);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
status: "ok",
|
|
70
|
+
source: "oauth-api",
|
|
71
|
+
fetchedAt: now.toISOString(),
|
|
72
|
+
planType: asString(response.plan_type),
|
|
73
|
+
primaryUsedPercent: asNumber(primaryWindow?.used_percent),
|
|
74
|
+
primaryResetAt: toResetIso(primaryWindow?.reset_at),
|
|
75
|
+
secondaryUsedPercent: asNumber(secondaryWindow?.used_percent),
|
|
76
|
+
secondaryResetAt: toResetIso(secondaryWindow?.reset_at),
|
|
77
|
+
creditsBalance: asNumber(credits?.balance),
|
|
78
|
+
creditsUnlimited: typeof credits?.unlimited === "boolean" ? credits.unlimited : null,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const loadCredentials = (authJson: unknown): CodexCredentials | null => {
|
|
83
|
+
const auth = asRecord(authJson);
|
|
84
|
+
if (!auth) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const apiKey = auth.OPENAI_API_KEY;
|
|
89
|
+
if (typeof apiKey === "string" && apiKey.trim().length > 0) {
|
|
90
|
+
return {
|
|
91
|
+
accessToken: apiKey.trim(),
|
|
92
|
+
refreshToken: null,
|
|
93
|
+
accountId: null,
|
|
94
|
+
lastRefresh: null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const tokens = asRecord(auth.tokens);
|
|
99
|
+
const accessToken = asString(tokens?.access_token)?.trim();
|
|
100
|
+
if (!accessToken) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const refreshToken = asString(tokens?.refresh_token)?.trim() ?? null;
|
|
105
|
+
const accountId = asString(tokens?.account_id)?.trim() ?? null;
|
|
106
|
+
const lastRefreshRaw = asString(auth.last_refresh);
|
|
107
|
+
const lastRefresh = lastRefreshRaw ? new Date(lastRefreshRaw) : null;
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
accessToken,
|
|
111
|
+
refreshToken: refreshToken && refreshToken.length > 0 ? refreshToken : null,
|
|
112
|
+
accountId: accountId && accountId.length > 0 ? accountId : null,
|
|
113
|
+
lastRefresh: lastRefresh && Number.isFinite(lastRefresh.getTime()) ? lastRefresh : null,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const shouldRefreshToken = (credentials: CodexCredentials, now: Date) => {
|
|
118
|
+
if (!credentials.refreshToken) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!credentials.lastRefresh) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return now.getTime() - credentials.lastRefresh.getTime() > EIGHT_DAYS_MS;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const refreshCredentials = async (
|
|
130
|
+
authPath: string,
|
|
131
|
+
authJson: Record<string, unknown>,
|
|
132
|
+
credentials: CodexCredentials,
|
|
133
|
+
now: Date,
|
|
134
|
+
dependencies: Required<Omit<CodexUsageDependencies, "env" | "now">>,
|
|
135
|
+
): Promise<CodexCredentials> => {
|
|
136
|
+
if (!credentials.refreshToken) {
|
|
137
|
+
return credentials;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const refreshResponse = await dependencies.fetchImpl(OAUTH_REFRESH_URL, {
|
|
141
|
+
method: "POST",
|
|
142
|
+
headers: {
|
|
143
|
+
"Content-Type": "application/json",
|
|
144
|
+
},
|
|
145
|
+
body: JSON.stringify({
|
|
146
|
+
client_id: OAUTH_REFRESH_CLIENT_ID,
|
|
147
|
+
grant_type: "refresh_token",
|
|
148
|
+
refresh_token: credentials.refreshToken,
|
|
149
|
+
scope: "openid profile email",
|
|
150
|
+
}),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (!refreshResponse.ok) {
|
|
154
|
+
throw new Error(`oauth_refresh_failed_${refreshResponse.status}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const refreshPayload = (await refreshResponse.json()) as RefreshTokenResponse;
|
|
158
|
+
const refreshedAccessToken = asString(refreshPayload.access_token)?.trim();
|
|
159
|
+
if (!refreshedAccessToken) {
|
|
160
|
+
throw new Error("oauth_refresh_missing_access_token");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const refreshedRefreshToken =
|
|
164
|
+
asString(refreshPayload.refresh_token)?.trim() || credentials.refreshToken;
|
|
165
|
+
|
|
166
|
+
const mergedTokens = {
|
|
167
|
+
...(asRecord(authJson.tokens) ?? {}),
|
|
168
|
+
access_token: refreshedAccessToken,
|
|
169
|
+
refresh_token: refreshedRefreshToken,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const nextAuthJson = {
|
|
173
|
+
...authJson,
|
|
174
|
+
tokens: mergedTokens,
|
|
175
|
+
last_refresh: now.toISOString(),
|
|
176
|
+
};
|
|
177
|
+
await dependencies.writeFileText(authPath, `${JSON.stringify(nextAuthJson, null, 2)}\n`);
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
...credentials,
|
|
181
|
+
accessToken: refreshedAccessToken,
|
|
182
|
+
refreshToken: refreshedRefreshToken,
|
|
183
|
+
lastRefresh: now,
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const readCodexUsageSnapshot = async (
|
|
188
|
+
dependencies: CodexUsageDependencies = {},
|
|
189
|
+
): Promise<CodexUsageSnapshot> => {
|
|
190
|
+
const env = dependencies.env ?? process.env;
|
|
191
|
+
const now = dependencies.now?.() ?? new Date();
|
|
192
|
+
const readFileText = dependencies.readFileText ?? ((path: string) => readFile(path, "utf8"));
|
|
193
|
+
const writeFileText =
|
|
194
|
+
dependencies.writeFileText ??
|
|
195
|
+
((path: string, contents: string) => writeFile(path, contents, "utf8"));
|
|
196
|
+
const fetchImpl = dependencies.fetchImpl ?? fetch;
|
|
197
|
+
|
|
198
|
+
const authPath = join(resolveCodexHome(env), "auth.json");
|
|
199
|
+
|
|
200
|
+
let authText: string;
|
|
201
|
+
try {
|
|
202
|
+
authText = await readFileText(authPath);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
const errorCode =
|
|
205
|
+
typeof error === "object" && error && "code" in error ? String(error.code) : "";
|
|
206
|
+
if (errorCode === "ENOENT") {
|
|
207
|
+
return unavailableSnapshot(now, "Codex auth not found. Run `codex login`.");
|
|
208
|
+
}
|
|
209
|
+
return unavailableSnapshot(now, "Unable to read Codex auth file.", "error");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let authJson: unknown;
|
|
213
|
+
try {
|
|
214
|
+
authJson = JSON.parse(authText) as unknown;
|
|
215
|
+
} catch {
|
|
216
|
+
return unavailableSnapshot(now, "Codex auth file is not valid JSON.", "error");
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const authRecord = asRecord(authJson);
|
|
220
|
+
const credentials = loadCredentials(authRecord);
|
|
221
|
+
if (!credentials) {
|
|
222
|
+
return unavailableSnapshot(
|
|
223
|
+
now,
|
|
224
|
+
"Codex auth file is missing OAuth credentials. Re-run `codex login`.",
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
let nextCredentials = credentials;
|
|
229
|
+
try {
|
|
230
|
+
if (shouldRefreshToken(credentials, now) && authRecord) {
|
|
231
|
+
nextCredentials = await refreshCredentials(authPath, authRecord, credentials, now, {
|
|
232
|
+
readFileText,
|
|
233
|
+
writeFileText,
|
|
234
|
+
fetchImpl,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
} catch {
|
|
238
|
+
return unavailableSnapshot(
|
|
239
|
+
now,
|
|
240
|
+
"Unable to refresh Codex OAuth credentials. Re-run `codex login`.",
|
|
241
|
+
"error",
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
const headers = new Headers({
|
|
247
|
+
Authorization: `Bearer ${nextCredentials.accessToken}`,
|
|
248
|
+
Accept: "application/json",
|
|
249
|
+
"User-Agent": "Octogent",
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (nextCredentials.accountId) {
|
|
253
|
+
headers.set("ChatGPT-Account-Id", nextCredentials.accountId);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const usageResponse = await fetchImpl(OAUTH_USAGE_URL, {
|
|
257
|
+
method: "GET",
|
|
258
|
+
headers,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
if (usageResponse.status === 401 || usageResponse.status === 403) {
|
|
262
|
+
return unavailableSnapshot(now, "Codex OAuth session expired. Re-run `codex login`.");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (!usageResponse.ok) {
|
|
266
|
+
return unavailableSnapshot(
|
|
267
|
+
now,
|
|
268
|
+
`Codex usage request failed (${usageResponse.status}).`,
|
|
269
|
+
"error",
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const usagePayload = (await usageResponse.json()) as CodexUsageApiResponse;
|
|
274
|
+
return mapUsageResponse(usagePayload, now);
|
|
275
|
+
} catch {
|
|
276
|
+
return unavailableSnapshot(now, "Unable to reach Codex usage service.", "error");
|
|
277
|
+
}
|
|
278
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ApiRouteHandler } from "./routeHelpers";
|
|
2
|
+
import { readJsonBodyOrWriteError, writeJson, writeMethodNotAllowed } from "./routeHelpers";
|
|
3
|
+
|
|
4
|
+
export const handleCodeIntelEventsRoute: ApiRouteHandler = async (
|
|
5
|
+
{ request, response, requestUrl, corsOrigin },
|
|
6
|
+
{ codeIntelStore },
|
|
7
|
+
) => {
|
|
8
|
+
if (requestUrl.pathname !== "/api/code-intel/events") {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (request.method === "POST") {
|
|
13
|
+
const body = await readJsonBodyOrWriteError(request, response, corsOrigin);
|
|
14
|
+
if (!body.ok) return true;
|
|
15
|
+
|
|
16
|
+
const payload = body.payload as Record<string, unknown> | null;
|
|
17
|
+
const toolName = payload && typeof payload.tool_name === "string" ? payload.tool_name : "";
|
|
18
|
+
const toolInput =
|
|
19
|
+
payload && typeof payload.tool_input === "object" && payload.tool_input !== null
|
|
20
|
+
? (payload.tool_input as Record<string, unknown>)
|
|
21
|
+
: {};
|
|
22
|
+
const filePath = typeof toolInput.file_path === "string" ? toolInput.file_path : "";
|
|
23
|
+
|
|
24
|
+
if (filePath.length === 0) {
|
|
25
|
+
writeJson(response, 200, { ok: true, skipped: true }, corsOrigin);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Prefer Octogent session ID from header, fall back to Claude Code's own session_id from payload
|
|
30
|
+
const octogentSession =
|
|
31
|
+
typeof request.headers["x-octogent-session"] === "string" &&
|
|
32
|
+
request.headers["x-octogent-session"].length > 0
|
|
33
|
+
? request.headers["x-octogent-session"]
|
|
34
|
+
: undefined;
|
|
35
|
+
const claudeSession =
|
|
36
|
+
payload && typeof payload.session_id === "string" && payload.session_id.length > 0
|
|
37
|
+
? payload.session_id
|
|
38
|
+
: undefined;
|
|
39
|
+
const sessionId = octogentSession ?? claudeSession ?? "unknown";
|
|
40
|
+
|
|
41
|
+
await codeIntelStore.append({
|
|
42
|
+
ts: new Date().toISOString(),
|
|
43
|
+
sessionId,
|
|
44
|
+
tool: toolName,
|
|
45
|
+
file: filePath,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
writeJson(response, 200, { ok: true }, corsOrigin);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (request.method === "GET") {
|
|
53
|
+
const events = await codeIntelStore.readAll();
|
|
54
|
+
writeJson(response, 200, { events }, corsOrigin);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
writeMethodNotAllowed(response, corsOrigin);
|
|
59
|
+
return true;
|
|
60
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { ApiRouteHandler } from "./routeHelpers";
|
|
2
|
+
import { writeJson, writeMethodNotAllowed, writeNoContent, writeText } from "./routeHelpers";
|
|
3
|
+
|
|
4
|
+
const CONVERSATION_SEARCH_PATH = "/api/conversations/search";
|
|
5
|
+
const CONVERSATION_ITEM_PATH_PATTERN = /^\/api\/conversations\/([^/]+)$/;
|
|
6
|
+
const CONVERSATION_EXPORT_PATH_PATTERN = /^\/api\/conversations\/([^/]+)\/export$/;
|
|
7
|
+
|
|
8
|
+
export const handleConversationsCollectionRoute: ApiRouteHandler = async (
|
|
9
|
+
{ request, response, requestUrl, corsOrigin },
|
|
10
|
+
{ runtime },
|
|
11
|
+
) => {
|
|
12
|
+
if (requestUrl.pathname !== "/api/conversations") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (request.method === "DELETE") {
|
|
17
|
+
runtime.deleteAllConversationSessions();
|
|
18
|
+
writeNoContent(response, 204, corsOrigin);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (request.method !== "GET") {
|
|
23
|
+
writeMethodNotAllowed(response, corsOrigin);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const payload = runtime.listConversationSessions();
|
|
28
|
+
writeJson(response, 200, payload, corsOrigin);
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const handleConversationSearchRoute: ApiRouteHandler = async (
|
|
33
|
+
{ request, response, requestUrl, corsOrigin },
|
|
34
|
+
{ runtime },
|
|
35
|
+
) => {
|
|
36
|
+
if (requestUrl.pathname !== CONVERSATION_SEARCH_PATH) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (request.method !== "GET") {
|
|
41
|
+
writeMethodNotAllowed(response, corsOrigin);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const query = requestUrl.searchParams.get("q") ?? "";
|
|
46
|
+
if (query.trim().length === 0) {
|
|
47
|
+
writeJson(response, 400, { error: "Missing search query parameter 'q'." }, corsOrigin);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const payload = runtime.searchConversations(query);
|
|
52
|
+
writeJson(response, 200, payload, corsOrigin);
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const handleConversationItemRoute: ApiRouteHandler = async (
|
|
57
|
+
{ request, response, requestUrl, corsOrigin },
|
|
58
|
+
{ runtime },
|
|
59
|
+
) => {
|
|
60
|
+
const match = requestUrl.pathname.match(CONVERSATION_ITEM_PATH_PATTERN);
|
|
61
|
+
if (!match) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const sessionId = decodeURIComponent(match[1] ?? "");
|
|
66
|
+
|
|
67
|
+
if (request.method === "DELETE") {
|
|
68
|
+
runtime.deleteConversationSession(sessionId);
|
|
69
|
+
writeNoContent(response, 204, corsOrigin);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (request.method !== "GET") {
|
|
74
|
+
writeMethodNotAllowed(response, corsOrigin);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const payload = runtime.readConversationSession(sessionId);
|
|
79
|
+
if (!payload) {
|
|
80
|
+
writeJson(response, 404, { error: "Conversation session not found." }, corsOrigin);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
writeJson(response, 200, payload, corsOrigin);
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const handleConversationExportRoute: ApiRouteHandler = async (
|
|
89
|
+
{ request, response, requestUrl, corsOrigin },
|
|
90
|
+
{ runtime },
|
|
91
|
+
) => {
|
|
92
|
+
const match = requestUrl.pathname.match(CONVERSATION_EXPORT_PATH_PATTERN);
|
|
93
|
+
if (!match) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (request.method !== "GET") {
|
|
98
|
+
writeMethodNotAllowed(response, corsOrigin);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const sessionId = decodeURIComponent(match[1] ?? "");
|
|
103
|
+
const format = requestUrl.searchParams.get("format");
|
|
104
|
+
if (format !== "json" && format !== "md") {
|
|
105
|
+
writeJson(response, 400, { error: "Unsupported conversation export format." }, corsOrigin);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (format === "json") {
|
|
110
|
+
const payload = runtime.readConversationSession(sessionId);
|
|
111
|
+
if (!payload) {
|
|
112
|
+
writeJson(response, 404, { error: "Conversation session not found." }, corsOrigin);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
writeJson(response, 200, payload, corsOrigin);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const payload = runtime.exportConversationSession(sessionId, "md");
|
|
121
|
+
if (payload === null) {
|
|
122
|
+
writeJson(response, 404, { error: "Conversation session not found." }, corsOrigin);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
writeText(response, 200, payload, "text/markdown; charset=utf-8", corsOrigin);
|
|
127
|
+
return true;
|
|
128
|
+
};
|