@vybestack/llxprt-code-core 0.11.0 → 0.12.0-nightly.260910.2aac6841e
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/prompt-config/defaults/default-prompts.json +3 -3
- package/dist/src/config/agentClientLifecycle.d.ts +4 -3
- package/dist/src/config/agentClientLifecycle.js +27 -14
- package/dist/src/config/agentClientLifecycle.js.map +1 -1
- package/dist/src/config/config.d.ts +2 -5
- package/dist/src/config/config.js +10 -23
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/configBase.d.ts +5 -1
- package/dist/src/config/configBase.js +27 -6
- package/dist/src/config/configBase.js.map +1 -1
- package/dist/src/config/configBaseCore.d.ts +26 -8
- package/dist/src/config/configBaseCore.js +30 -26
- package/dist/src/config/configBaseCore.js.map +1 -1
- package/dist/src/config/configMcpRuntime.d.ts +16 -0
- package/dist/src/config/configMcpRuntime.js +31 -0
- package/dist/src/config/configMcpRuntime.js.map +1 -0
- package/dist/src/config/configMediaDefaults.d.ts +10 -0
- package/dist/src/config/configMediaDefaults.js +17 -0
- package/dist/src/config/configMediaDefaults.js.map +1 -0
- package/dist/src/config/configTestHarness.d.ts +4 -0
- package/dist/src/config/configTypes.d.ts +4 -54
- package/dist/src/config/configTypes.js +6 -82
- package/dist/src/config/configTypes.js.map +1 -1
- package/dist/src/config/index.d.ts +1 -2
- package/dist/src/config/index.js +1 -2
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/models.d.ts +0 -4
- package/dist/src/config/models.js +0 -4
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/toolRegistryFactory.d.ts +2 -2
- package/dist/src/core/clientContract.d.ts +4 -6
- package/dist/src/core/compression/transcriptPathNotice.d.ts +22 -0
- package/dist/src/core/compression/transcriptPathNotice.js +29 -0
- package/dist/src/core/compression/transcriptPathNotice.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +2 -5
- package/dist/src/core/contentGenerator.js +10 -24
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/logger.d.ts +66 -0
- package/dist/src/core/logger.js +345 -30
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/prompts.d.ts +0 -1
- package/dist/src/core/prompts.js +5 -79
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/turn.d.ts +3 -3
- package/dist/src/hooks/hookTranslator.js +5 -4
- package/dist/src/hooks/hookTranslator.js.map +1 -1
- package/dist/src/index.d.ts +8 -6
- package/dist/src/index.js +8 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/llm-types/index.d.ts +1 -1
- package/dist/src/llm-types/modelEnvelope.d.ts +2 -1
- package/dist/src/llm-types/modelEnvelope.js +17 -1
- package/dist/src/llm-types/modelEnvelope.js.map +1 -1
- package/dist/src/models/schema.d.ts +40 -40
- package/dist/src/policy/policies/read-only.toml +0 -5
- package/dist/src/prompt-config/TemplateEngine.js +0 -3
- package/dist/src/prompt-config/TemplateEngine.js.map +1 -1
- package/dist/src/prompt-config/defaults/providers/gemini/core.md +0 -2
- package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/core.md +0 -2
- package/dist/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash/core.md +0 -2
- package/dist/src/prompt-config/prompt-loader.d.ts +1 -1
- package/dist/src/prompt-config/prompt-loader.js +4 -4
- package/dist/src/prompt-config/prompt-loader.js.map +1 -1
- package/dist/src/prompt-config/types.d.ts +0 -1
- package/dist/src/recording/CheckpointService.d.ts +4 -0
- package/dist/src/recording/CheckpointService.js +67 -46
- package/dist/src/recording/CheckpointService.js.map +1 -1
- package/dist/src/recording/HistoryMutationService.d.ts +1 -1
- package/dist/src/recording/HistoryMutationService.js +27 -4
- package/dist/src/recording/HistoryMutationService.js.map +1 -1
- package/dist/src/recording/RecordingIntegration.d.ts +36 -2
- package/dist/src/recording/RecordingIntegration.js +224 -7
- package/dist/src/recording/RecordingIntegration.js.map +1 -1
- package/dist/src/recording/ReplayEngine.d.ts +8 -10
- package/dist/src/recording/ReplayEngine.js +161 -95
- package/dist/src/recording/ReplayEngine.js.map +1 -1
- package/dist/src/recording/SessionDiscovery.d.ts +4 -2
- package/dist/src/recording/SessionDiscovery.js +13 -5
- package/dist/src/recording/SessionDiscovery.js.map +1 -1
- package/dist/src/recording/SessionRecordingService.d.ts +23 -3
- package/dist/src/recording/SessionRecordingService.js +209 -51
- package/dist/src/recording/SessionRecordingService.js.map +1 -1
- package/dist/src/recording/SessionTransitionService.d.ts +7 -0
- package/dist/src/recording/SessionTransitionService.js +66 -13
- package/dist/src/recording/SessionTransitionService.js.map +1 -1
- package/dist/src/recording/index.d.ts +1 -0
- package/dist/src/recording/index.js +1 -0
- package/dist/src/recording/index.js.map +1 -1
- package/dist/src/recording/janitor/cleanupTypes.d.ts +3 -0
- package/dist/src/recording/janitor/cleanupTypes.js.map +1 -1
- package/dist/src/recording/janitor/mediaReclamation.d.ts +23 -0
- package/dist/src/recording/janitor/mediaReclamation.js +195 -0
- package/dist/src/recording/janitor/mediaReclamation.js.map +1 -0
- package/dist/src/recording/janitor/sessionJanitor.js +47 -1
- package/dist/src/recording/janitor/sessionJanitor.js.map +1 -1
- package/dist/src/recording/janitor/sessionScanner.d.ts +12 -9
- package/dist/src/recording/janitor/sessionScanner.js +248 -193
- package/dist/src/recording/janitor/sessionScanner.js.map +1 -1
- package/dist/src/recording/replay-test-helpers.d.ts +10 -1
- package/dist/src/recording/replay-test-helpers.js +24 -2
- package/dist/src/recording/replay-test-helpers.js.map +1 -1
- package/dist/src/recording/replayCheckpointMetadata.d.ts +28 -0
- package/dist/src/recording/replayCheckpointMetadata.js +96 -0
- package/dist/src/recording/replayCheckpointMetadata.js.map +1 -0
- package/dist/src/recording/replayErrorFormatting.d.ts +6 -0
- package/dist/src/recording/replayErrorFormatting.js +38 -0
- package/dist/src/recording/replayErrorFormatting.js.map +1 -0
- package/dist/src/recording/resumeSession.d.ts +3 -0
- package/dist/src/recording/resumeSession.js +7 -1
- package/dist/src/recording/resumeSession.js.map +1 -1
- package/dist/src/recording/semanticMediaPurgeReplayValidation.d.ts +14 -0
- package/dist/src/recording/semanticMediaPurgeReplayValidation.js +24 -0
- package/dist/src/recording/semanticMediaPurgeReplayValidation.js.map +1 -0
- package/dist/src/recording/session-media-package-blobs.d.ts +8 -0
- package/dist/src/recording/session-media-package-blobs.js +72 -0
- package/dist/src/recording/session-media-package-blobs.js.map +1 -0
- package/dist/src/recording/session-media-package-import.d.ts +26 -0
- package/dist/src/recording/session-media-package-import.js +124 -0
- package/dist/src/recording/session-media-package-import.js.map +1 -0
- package/dist/src/recording/session-media-package-state.d.ts +19 -0
- package/dist/src/recording/session-media-package-state.js +56 -0
- package/dist/src/recording/session-media-package-state.js.map +1 -0
- package/dist/src/recording/session-media-package-validation.d.ts +59 -0
- package/dist/src/recording/session-media-package-validation.js +286 -0
- package/dist/src/recording/session-media-package-validation.js.map +1 -0
- package/dist/src/recording/session-media-package-writer.d.ts +18 -0
- package/dist/src/recording/session-media-package-writer.js +70 -0
- package/dist/src/recording/session-media-package-writer.js.map +1 -0
- package/dist/src/recording/session-media-package.d.ts +27 -0
- package/dist/src/recording/session-media-package.js +366 -0
- package/dist/src/recording/session-media-package.js.map +1 -0
- package/dist/src/recording/types.d.ts +34 -2
- package/dist/src/recording/types.js.map +1 -1
- package/dist/src/runtime/AgentRuntimeContext.d.ts +22 -5
- package/dist/src/runtime/AgentRuntimeLoader.d.ts +6 -0
- package/dist/src/runtime/AgentRuntimeLoader.js +25 -6
- package/dist/src/runtime/AgentRuntimeLoader.js.map +1 -1
- package/dist/src/runtime/contracts/PromptEstimation.d.ts +1 -0
- package/dist/src/runtime/contracts/PromptEstimation.js.map +1 -1
- package/dist/src/runtime/contracts/RuntimeProvider.d.ts +3 -2
- package/dist/src/runtime/contracts/RuntimeProviderManager.d.ts +0 -2
- package/dist/src/runtime/createAgentRuntimeContext.js +28 -1
- package/dist/src/runtime/createAgentRuntimeContext.js.map +1 -1
- package/dist/src/runtime/providerRuntimeContext.d.ts +12 -0
- package/dist/src/runtime/providerRuntimeContext.js +3 -0
- package/dist/src/runtime/providerRuntimeContext.js.map +1 -1
- package/dist/src/runtime/runtimeAdapters.js +2 -2
- package/dist/src/runtime/runtimeAdapters.js.map +1 -1
- package/dist/src/services/history/ContentConverters.d.ts +11 -7
- package/dist/src/services/history/ContentConverters.js +11 -7
- package/dist/src/services/history/ContentConverters.js.map +1 -1
- package/dist/src/services/history/HistoryService.d.ts +18 -180
- package/dist/src/services/history/HistoryService.js +53 -523
- package/dist/src/services/history/HistoryService.js.map +1 -1
- package/dist/src/services/history/HistoryServiceCore.d.ts +278 -0
- package/dist/src/services/history/HistoryServiceCore.js +727 -0
- package/dist/src/services/history/HistoryServiceCore.js.map +1 -0
- package/dist/src/services/history/IContent.d.ts +118 -16
- package/dist/src/services/history/IContent.js +284 -4
- package/dist/src/services/history/IContent.js.map +1 -1
- package/dist/src/services/history/contentSize.js +22 -2
- package/dist/src/services/history/contentSize.js.map +1 -1
- package/dist/src/services/history/historyChronology.d.ts +7 -0
- package/dist/src/services/history/historyChronology.js +35 -3
- package/dist/src/services/history/historyChronology.js.map +1 -1
- package/dist/src/services/history/historyCloneUtils.d.ts +5 -4
- package/dist/src/services/history/historyCloneUtils.js +23 -16
- package/dist/src/services/history/historyCloneUtils.js.map +1 -1
- package/dist/src/services/history/historyCompressionQueue.d.ts +33 -0
- package/dist/src/services/history/historyCompressionQueue.js +81 -0
- package/dist/src/services/history/historyCompressionQueue.js.map +1 -0
- package/dist/src/services/history/historyEventTypes.d.ts +3 -0
- package/dist/src/services/history/historyMutationFailure.d.ts +15 -0
- package/dist/src/services/history/historyMutationFailure.js +22 -0
- package/dist/src/services/history/historyMutationFailure.js.map +1 -1
- package/dist/src/services/history/historyProviderPipeline.d.ts +1 -1
- package/dist/src/services/history/historyProviderPipeline.js +15 -5
- package/dist/src/services/history/historyProviderPipeline.js.map +1 -1
- package/dist/src/services/history/historyTokenEstimation.js +10 -6
- package/dist/src/services/history/historyTokenEstimation.js.map +1 -1
- package/dist/src/services/history/historyToolNormalization.d.ts +2 -0
- package/dist/src/services/history/historyToolNormalization.js +26 -9
- package/dist/src/services/history/historyToolNormalization.js.map +1 -1
- package/dist/src/services/history/provider-file-binding.d.ts +11 -0
- package/dist/src/services/history/provider-file-binding.js +70 -0
- package/dist/src/services/history/provider-file-binding.js.map +1 -0
- package/dist/src/services/history/semantic-media-purge.d.ts +66 -0
- package/dist/src/services/history/semantic-media-purge.js +404 -0
- package/dist/src/services/history/semantic-media-purge.js.map +1 -0
- package/dist/src/storage/SessionPersistenceService.d.ts +53 -2
- package/dist/src/storage/SessionPersistenceService.js +435 -23
- package/dist/src/storage/SessionPersistenceService.js.map +1 -1
- package/dist/src/storage/history-media-ownership.d.ts +38 -0
- package/dist/src/storage/history-media-ownership.js +136 -0
- package/dist/src/storage/history-media-ownership.js.map +1 -0
- package/dist/src/storage/local-media-store-child.d.ts +6 -0
- package/dist/src/storage/local-media-store-child.js +140 -0
- package/dist/src/storage/local-media-store-child.js.map +1 -0
- package/dist/src/storage/local-media-store-files.d.ts +44 -0
- package/dist/src/storage/local-media-store-files.js +460 -0
- package/dist/src/storage/local-media-store-files.js.map +1 -0
- package/dist/src/storage/local-media-store-lock-recovery.d.ts +15 -0
- package/dist/src/storage/local-media-store-lock-recovery.js +112 -0
- package/dist/src/storage/local-media-store-lock-recovery.js.map +1 -0
- package/dist/src/storage/local-media-store-persistence.d.ts +48 -0
- package/dist/src/storage/local-media-store-persistence.js +443 -0
- package/dist/src/storage/local-media-store-persistence.js.map +1 -0
- package/dist/src/storage/local-media-store-quota.d.ts +6 -0
- package/dist/src/storage/local-media-store-quota.js +66 -0
- package/dist/src/storage/local-media-store-quota.js.map +1 -0
- package/dist/src/storage/local-media-store-reservations.d.ts +55 -0
- package/dist/src/storage/local-media-store-reservations.js +377 -0
- package/dist/src/storage/local-media-store-reservations.js.map +1 -0
- package/dist/src/storage/local-media-store-types.d.ts +110 -0
- package/dist/src/storage/local-media-store-types.js +35 -0
- package/dist/src/storage/local-media-store-types.js.map +1 -0
- package/dist/src/storage/local-media-store-validation.d.ts +34 -0
- package/dist/src/storage/local-media-store-validation.js +449 -0
- package/dist/src/storage/local-media-store-validation.js.map +1 -0
- package/dist/src/storage/local-media-store.d.ts +47 -0
- package/dist/src/storage/local-media-store.js +353 -0
- package/dist/src/storage/local-media-store.js.map +1 -0
- package/dist/src/storage/media-admission-service.d.ts +49 -0
- package/dist/src/storage/media-admission-service.js +333 -0
- package/dist/src/storage/media-admission-service.js.map +1 -0
- package/dist/src/storage/media-lifecycle-metrics.d.ts +75 -0
- package/dist/src/storage/media-lifecycle-metrics.js +105 -0
- package/dist/src/storage/media-lifecycle-metrics.js.map +1 -0
- package/dist/src/storage/media-reference-lifecycle.d.ts +16 -0
- package/dist/src/storage/media-reference-lifecycle.js +84 -0
- package/dist/src/storage/media-reference-lifecycle.js.map +1 -0
- package/dist/src/storage/request-media-resolver.d.ts +67 -0
- package/dist/src/storage/request-media-resolver.js +325 -0
- package/dist/src/storage/request-media-resolver.js.map +1 -0
- package/dist/src/storage/session-media-service-factories.d.ts +19 -0
- package/dist/src/storage/session-media-service-factories.js +34 -0
- package/dist/src/storage/session-media-service-factories.js.map +1 -0
- package/dist/src/storage/session-persistence-helpers.d.ts +10 -0
- package/dist/src/storage/session-persistence-helpers.js +46 -0
- package/dist/src/storage/session-persistence-helpers.js.map +1 -0
- package/dist/src/test-utils/config.d.ts +2 -0
- package/dist/src/test-utils/config.js +5 -5
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/runtime.d.ts +2 -0
- package/dist/src/test-utils/runtime.js +1 -2
- package/dist/src/test-utils/runtime.js.map +1 -1
- package/dist/src/tools-adapters/CoreShellToolHostAdapter.js +1 -9
- package/dist/src/tools-adapters/CoreShellToolHostAdapter.js.map +1 -1
- package/dist/src/tools-adapters/CoreSkillServiceAdapter.d.ts +0 -2
- package/dist/src/tools-adapters/CoreSkillServiceAdapter.js +0 -17
- package/dist/src/tools-adapters/CoreSkillServiceAdapter.js.map +1 -1
- package/dist/src/tools-adapters/CoreToolHostAdapter.d.ts +0 -21
- package/dist/src/tools-adapters/CoreToolHostAdapter.js +0 -8
- package/dist/src/tools-adapters/CoreToolHostAdapter.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +8 -9
- package/dist/src/utils/environmentContext.js +11 -22
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -2
- package/dist/src/utils/errorParsing.js +22 -41
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.js +12 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/summarizer.d.ts +1 -2
- package/dist/src/utils/summarizer.js +6 -5
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/tool-utils.js +7 -1
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/index.ts +0 -4
- package/package.json +38 -30
- package/src/config/agentClientLifecycle.ts +53 -22
- package/src/config/config.ts +11 -26
- package/src/config/configBase.ts +46 -7
- package/src/config/configBaseCore.ts +38 -36
- package/src/config/configMcpRuntime.ts +46 -0
- package/src/config/configMediaDefaults.ts +19 -0
- package/src/config/configTypes.ts +13 -53
- package/src/config/index.ts +1 -4
- package/src/config/models.ts +0 -6
- package/src/config/toolRegistryFactory.ts +2 -2
- package/src/core/clientContract.ts +4 -6
- package/src/core/compression/transcriptPathNotice.ts +31 -0
- package/src/core/contentGenerator.ts +15 -39
- package/src/core/logger.ts +370 -39
- package/src/core/prompts.ts +4 -114
- package/src/core/turn.ts +3 -3
- package/src/hooks/hookTranslator.ts +6 -4
- package/src/index.ts +7 -7
- package/src/llm-types/index.ts +5 -0
- package/src/llm-types/modelEnvelope.ts +26 -2
- package/src/policy/policies/read-only.toml +0 -5
- package/src/prompt-config/TemplateEngine.ts +0 -3
- package/src/prompt-config/defaults/providers/gemini/core.md +0 -2
- package/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/core.md +0 -2
- package/src/prompt-config/defaults/providers/gemini/models/gemini-2.5-flash/gemini-2-5-flash/core.md +0 -2
- package/src/prompt-config/prompt-loader.ts +7 -8
- package/src/prompt-config/types.ts +0 -1
- package/src/recording/CheckpointService.ts +110 -45
- package/src/recording/HistoryMutationService.ts +28 -3
- package/src/recording/RecordingIntegration.ts +258 -11
- package/src/recording/ReplayEngine.ts +220 -110
- package/src/recording/SessionDiscovery.ts +30 -4
- package/src/recording/SessionRecordingService.ts +253 -55
- package/src/recording/SessionTransitionService.ts +75 -12
- package/src/recording/index.ts +7 -0
- package/src/recording/janitor/cleanupTypes.ts +4 -0
- package/src/recording/janitor/mediaReclamation.ts +295 -0
- package/src/recording/janitor/sessionJanitor.ts +54 -1
- package/src/recording/janitor/sessionScanner.ts +319 -227
- package/src/recording/replay-test-helpers.ts +33 -2
- package/src/recording/replayCheckpointMetadata.ts +115 -0
- package/src/recording/replayErrorFormatting.ts +43 -0
- package/src/recording/resumeSession.ts +10 -0
- package/src/recording/semanticMediaPurgeReplayValidation.ts +35 -0
- package/src/recording/session-media-package-blobs.ts +116 -0
- package/src/recording/session-media-package-import.ts +189 -0
- package/src/recording/session-media-package-state.ts +120 -0
- package/src/recording/session-media-package-validation.ts +400 -0
- package/src/recording/session-media-package-writer.ts +117 -0
- package/src/recording/session-media-package.ts +692 -0
- package/src/recording/types.ts +37 -2
- package/src/runtime/AgentRuntimeContext.ts +28 -5
- package/src/runtime/AgentRuntimeLoader.ts +32 -7
- package/src/runtime/contracts/PromptEstimation.ts +1 -0
- package/src/runtime/contracts/RuntimeProvider.ts +3 -8
- package/src/runtime/contracts/RuntimeProviderManager.ts +0 -2
- package/src/runtime/createAgentRuntimeContext.ts +43 -1
- package/src/runtime/providerRuntimeContext.ts +22 -0
- package/src/runtime/runtimeAdapters.ts +2 -2
- package/src/services/history/ContentConverters.ts +11 -7
- package/src/services/history/HistoryService.ts +71 -696
- package/src/services/history/HistoryServiceCore.ts +1055 -0
- package/src/services/history/IContent.ts +460 -20
- package/src/services/history/contentSize.ts +22 -2
- package/src/services/history/historyChronology.ts +53 -3
- package/src/services/history/historyCloneUtils.ts +26 -22
- package/src/services/history/historyCompressionQueue.ts +102 -0
- package/src/services/history/historyEventTypes.ts +9 -0
- package/src/services/history/historyMutationFailure.ts +33 -0
- package/src/services/history/historyProviderPipeline.ts +19 -5
- package/src/services/history/historyTokenEstimation.ts +9 -5
- package/src/services/history/historyToolNormalization.ts +43 -11
- package/src/services/history/provider-file-binding.ts +115 -0
- package/src/services/history/semantic-media-purge.ts +593 -0
- package/src/storage/SessionPersistenceService.ts +667 -30
- package/src/storage/history-media-ownership.ts +185 -0
- package/src/storage/local-media-store-child.ts +163 -0
- package/src/storage/local-media-store-files.ts +643 -0
- package/src/storage/local-media-store-lock-recovery.ts +159 -0
- package/src/storage/local-media-store-persistence.ts +737 -0
- package/src/storage/local-media-store-quota.ts +111 -0
- package/src/storage/local-media-store-reservations.ts +485 -0
- package/src/storage/local-media-store-types.ts +161 -0
- package/src/storage/local-media-store-validation.ts +643 -0
- package/src/storage/local-media-store.ts +696 -0
- package/src/storage/media-admission-service.ts +512 -0
- package/src/storage/media-lifecycle-metrics.ts +228 -0
- package/src/storage/media-reference-lifecycle.ts +164 -0
- package/src/storage/request-media-resolver.ts +491 -0
- package/src/storage/session-media-service-factories.ts +48 -0
- package/src/storage/session-persistence-helpers.ts +85 -0
- package/src/test-utils/config.ts +7 -5
- package/src/test-utils/runtime.ts +3 -2
- package/src/tools-adapters/CoreShellToolHostAdapter.ts +1 -11
- package/src/tools-adapters/CoreSkillServiceAdapter.ts +0 -23
- package/src/tools-adapters/CoreToolHostAdapter.ts +0 -36
- package/src/utils/environmentContext.ts +11 -30
- package/src/utils/errorParsing.ts +19 -69
- package/src/utils/generateContentResponseUtilities.ts +28 -1
- package/src/utils/summarizer.ts +8 -10
- package/src/utils/tool-utils.ts +7 -1
- package/dist/src/code_assist/codeAssist.d.ts +0 -19
- package/dist/src/code_assist/codeAssist.js +0 -41
- package/dist/src/code_assist/codeAssist.js.map +0 -1
- package/dist/src/code_assist/contentGeneratorAdapters.d.ts +0 -49
- package/dist/src/code_assist/contentGeneratorAdapters.js +0 -197
- package/dist/src/code_assist/contentGeneratorAdapters.js.map +0 -1
- package/dist/src/code_assist/converter.d.ts +0 -74
- package/dist/src/code_assist/converter.js +0 -158
- package/dist/src/code_assist/converter.js.map +0 -1
- package/dist/src/code_assist/googleGenAIWrapper.d.ts +0 -27
- package/dist/src/code_assist/googleGenAIWrapper.js +0 -46
- package/dist/src/code_assist/googleGenAIWrapper.js.map +0 -1
- package/dist/src/code_assist/oauth-credential-storage.d.ts +0 -30
- package/dist/src/code_assist/oauth-credential-storage.js +0 -135
- package/dist/src/code_assist/oauth-credential-storage.js.map +0 -1
- package/dist/src/code_assist/server.d.ts +0 -44
- package/dist/src/code_assist/server.js +0 -154
- package/dist/src/code_assist/server.js.map +0 -1
- package/dist/src/code_assist/setup.d.ts +0 -20
- package/dist/src/code_assist/setup.js +0 -126
- package/dist/src/code_assist/setup.js.map +0 -1
- package/dist/src/code_assist/types.d.ts +0 -161
- package/dist/src/code_assist/types.js +0 -46
- package/dist/src/code_assist/types.js.map +0 -1
- package/dist/src/utils/getFolderStructure.d.ts +0 -31
- package/dist/src/utils/getFolderStructure.js +0 -240
- package/dist/src/utils/getFolderStructure.js.map +0 -1
- package/dist/src/utils/installationManager.d.ts +0 -16
- package/dist/src/utils/installationManager.js +0 -51
- package/dist/src/utils/installationManager.js.map +0 -1
- package/dist/src/utils/llm-edit-fixer.d.ts +0 -25
- package/dist/src/utils/llm-edit-fixer.js +0 -120
- package/dist/src/utils/llm-edit-fixer.js.map +0 -1
- package/src/code_assist/codeAssist.ts +0 -59
- package/src/code_assist/contentGeneratorAdapters.ts +0 -275
- package/src/code_assist/converter.ts +0 -288
- package/src/code_assist/googleGenAIWrapper.ts +0 -90
- package/src/code_assist/oauth-credential-storage.ts +0 -171
- package/src/code_assist/server.ts +0 -263
- package/src/code_assist/setup.ts +0 -189
- package/src/code_assist/types.ts +0 -201
- package/src/utils/getFolderStructure.ts +0 -382
- package/src/utils/installationManager.ts +0 -59
- package/src/utils/llm-edit-fixer.ts +0 -157
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { type Credentials } from 'google-auth-library';
|
|
8
|
-
import { KeychainTokenStorage } from '@vybestack/llxprt-code-mcp';
|
|
9
|
-
import { OAUTH_FILE, Storage } from '@vybestack/llxprt-code-settings';
|
|
10
|
-
import type {
|
|
11
|
-
OAuthCredentials,
|
|
12
|
-
TokenStorage,
|
|
13
|
-
} from '@vybestack/llxprt-code-mcp';
|
|
14
|
-
import * as path from 'node:path';
|
|
15
|
-
import * as os from 'node:os';
|
|
16
|
-
import { promises as fs } from 'node:fs';
|
|
17
|
-
import { coreEvents } from '../utils/events.js';
|
|
18
|
-
|
|
19
|
-
const KEYCHAIN_SERVICE_NAME = 'llxprt-code-oauth';
|
|
20
|
-
const MAIN_ACCOUNT_KEY = 'main-account';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Normalizes a credential field that crosses the legacy JSON boundary.
|
|
24
|
-
*/
|
|
25
|
-
function normalizeOptionalString(value: unknown): string | undefined {
|
|
26
|
-
if (typeof value !== 'string' || value === '') {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getLegacyCredentialPaths(): string[] {
|
|
33
|
-
const legacyPaths = [Storage.getOAuthCredsPath()];
|
|
34
|
-
const homeDir = os.homedir();
|
|
35
|
-
if (homeDir) {
|
|
36
|
-
legacyPaths.push(path.join(homeDir, '.gemini', OAUTH_FILE));
|
|
37
|
-
}
|
|
38
|
-
return Array.from(new Set(legacyPaths));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @plan PLAN-20260211-SECURESTORE.P09
|
|
43
|
-
*/
|
|
44
|
-
export class OAuthCredentialStorage {
|
|
45
|
-
constructor(
|
|
46
|
-
private readonly storage: TokenStorage = new KeychainTokenStorage(
|
|
47
|
-
KEYCHAIN_SERVICE_NAME,
|
|
48
|
-
),
|
|
49
|
-
) {}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Load cached OAuth credentials
|
|
53
|
-
*/
|
|
54
|
-
async loadCredentials(): Promise<Credentials | null> {
|
|
55
|
-
try {
|
|
56
|
-
const credentials = await this.storage.getCredentials(MAIN_ACCOUNT_KEY);
|
|
57
|
-
|
|
58
|
-
if (credentials?.token !== undefined) {
|
|
59
|
-
const { accessToken, refreshToken, expiresAt, tokenType, scope } =
|
|
60
|
-
credentials.token;
|
|
61
|
-
// Convert from OAuthCredentials format to Google Credentials format
|
|
62
|
-
const googleCreds: Credentials = {
|
|
63
|
-
access_token: accessToken,
|
|
64
|
-
refresh_token: refreshToken === '' ? undefined : refreshToken,
|
|
65
|
-
token_type: tokenType === '' ? undefined : tokenType,
|
|
66
|
-
scope: scope === '' ? undefined : scope,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
if (expiresAt !== undefined) {
|
|
70
|
-
googleCreds.expiry_date = expiresAt;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return googleCreds;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Fallback: Try to migrate from old file-based storage
|
|
77
|
-
return await this.migrateFromFileStorage();
|
|
78
|
-
} catch (error: unknown) {
|
|
79
|
-
coreEvents.emitFeedback(
|
|
80
|
-
'error',
|
|
81
|
-
'Failed to load OAuth credentials',
|
|
82
|
-
error,
|
|
83
|
-
);
|
|
84
|
-
throw error instanceof Error
|
|
85
|
-
? error
|
|
86
|
-
: new Error('Failed to load OAuth credentials');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Save OAuth credentials
|
|
92
|
-
*/
|
|
93
|
-
async saveCredentials(credentials: Credentials): Promise<void> {
|
|
94
|
-
if (!credentials.access_token) {
|
|
95
|
-
throw new Error('Attempted to save credentials without an access token.');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Convert Google Credentials to OAuthCredentials format
|
|
99
|
-
const mcpCredentials: OAuthCredentials = {
|
|
100
|
-
serverName: MAIN_ACCOUNT_KEY,
|
|
101
|
-
token: {
|
|
102
|
-
accessToken: credentials.access_token,
|
|
103
|
-
refreshToken: normalizeOptionalString(credentials.refresh_token),
|
|
104
|
-
tokenType: normalizeOptionalString(credentials.token_type) ?? 'Bearer',
|
|
105
|
-
scope: normalizeOptionalString(credentials.scope),
|
|
106
|
-
// Preserve JS falsy behavior: 0/null/undefined expiry_date means "no expiration"
|
|
107
|
-
expiresAt:
|
|
108
|
-
credentials.expiry_date != null && credentials.expiry_date !== 0
|
|
109
|
-
? credentials.expiry_date
|
|
110
|
-
: undefined,
|
|
111
|
-
},
|
|
112
|
-
updatedAt: Date.now(),
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
await this.storage.setCredentials(mcpCredentials);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Clear cached OAuth credentials
|
|
120
|
-
*/
|
|
121
|
-
async clearCredentials(): Promise<void> {
|
|
122
|
-
try {
|
|
123
|
-
await this.storage.deleteCredentials(MAIN_ACCOUNT_KEY);
|
|
124
|
-
|
|
125
|
-
// Also try to remove the old file if it exists
|
|
126
|
-
await Promise.all(
|
|
127
|
-
getLegacyCredentialPaths().map((legacyPath) =>
|
|
128
|
-
fs.rm(legacyPath, { force: true }).catch(() => {}),
|
|
129
|
-
),
|
|
130
|
-
);
|
|
131
|
-
} catch (error: unknown) {
|
|
132
|
-
coreEvents.emitFeedback(
|
|
133
|
-
'error',
|
|
134
|
-
'Failed to clear OAuth credentials',
|
|
135
|
-
error,
|
|
136
|
-
);
|
|
137
|
-
throw error instanceof Error
|
|
138
|
-
? error
|
|
139
|
-
: new Error('Failed to clear OAuth credentials');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Migrate credentials from old file-based storage to keychain
|
|
145
|
-
*/
|
|
146
|
-
private async migrateFromFileStorage(): Promise<Credentials | null> {
|
|
147
|
-
for (const legacyPath of getLegacyCredentialPaths()) {
|
|
148
|
-
let credsJson: string;
|
|
149
|
-
try {
|
|
150
|
-
credsJson = await fs.readFile(legacyPath, 'utf-8');
|
|
151
|
-
} catch (error: unknown) {
|
|
152
|
-
if (
|
|
153
|
-
typeof error === 'object' &&
|
|
154
|
-
error !== null &&
|
|
155
|
-
'code' in error &&
|
|
156
|
-
(error as NodeJS.ErrnoException).code === 'ENOENT'
|
|
157
|
-
) {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const credentials = JSON.parse(credsJson) as Credentials;
|
|
164
|
-
await this.saveCredentials(credentials);
|
|
165
|
-
await fs.rm(legacyPath, { force: true }).catch(() => {});
|
|
166
|
-
return credentials;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { OAuth2Client } from 'google-auth-library';
|
|
8
|
-
import {
|
|
9
|
-
type CodeAssistGlobalUserSettingResponse,
|
|
10
|
-
type LoadCodeAssistRequest,
|
|
11
|
-
type LoadCodeAssistResponse,
|
|
12
|
-
type LongRunningOperationResponse,
|
|
13
|
-
type OnboardUserRequest,
|
|
14
|
-
type RetrieveUserQuotaRequest,
|
|
15
|
-
type RetrieveUserQuotaResponse,
|
|
16
|
-
type SetCodeAssistGlobalUserSettingRequest,
|
|
17
|
-
} from './types.js';
|
|
18
|
-
import type {
|
|
19
|
-
CountTokensResponse,
|
|
20
|
-
EmbedContentResponse,
|
|
21
|
-
GenerateContentResponse,
|
|
22
|
-
} from '@google/genai';
|
|
23
|
-
import {
|
|
24
|
-
type CountTokensParameters,
|
|
25
|
-
type EmbedContentParameters,
|
|
26
|
-
type GenerateContentParameters,
|
|
27
|
-
} from '@google/genai';
|
|
28
|
-
import * as readline from 'readline';
|
|
29
|
-
import type { UserTierId } from './types.js';
|
|
30
|
-
import {
|
|
31
|
-
type CaCountTokenResponse,
|
|
32
|
-
type CaGenerateContentResponse,
|
|
33
|
-
fromCountTokenResponse,
|
|
34
|
-
fromGenerateContentResponse,
|
|
35
|
-
toCountTokenRequest,
|
|
36
|
-
toGenerateContentRequest,
|
|
37
|
-
} from './converter.js';
|
|
38
|
-
import { debugLogger } from '../utils/debugLogger.js';
|
|
39
|
-
|
|
40
|
-
/** HTTP options to be used in each of the requests. */
|
|
41
|
-
export interface HttpOptions {
|
|
42
|
-
/** Additional HTTP headers to be sent with the request. */
|
|
43
|
-
headers?: Record<string, string>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Follow-up (#1569): Use production endpoint once it supports our methods.
|
|
47
|
-
export const CODE_ASSIST_ENDPOINT = 'https://cloudcode-pa.googleapis.com';
|
|
48
|
-
export const CODE_ASSIST_API_VERSION = 'v1internal';
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Google-native CodeAssist server. The methods use Google SDK types
|
|
52
|
-
* (GenerateContentParameters/GenerateContentResponse) because this IS a Google
|
|
53
|
-
* API client. The neutral ContentGenerator adapter (see
|
|
54
|
-
* CodeAssistContentGeneratorAdapter) wraps this server.
|
|
55
|
-
*/
|
|
56
|
-
export class CodeAssistServer {
|
|
57
|
-
constructor(
|
|
58
|
-
readonly client: OAuth2Client,
|
|
59
|
-
readonly projectId?: string,
|
|
60
|
-
readonly httpOptions: HttpOptions = {},
|
|
61
|
-
// PRIVACY FIX: sessionId parameter removed to prevent any potential transmission
|
|
62
|
-
// readonly sessionId?: string,
|
|
63
|
-
readonly userTier?: UserTierId,
|
|
64
|
-
readonly baseURL?: string,
|
|
65
|
-
) {}
|
|
66
|
-
|
|
67
|
-
async generateContentStream(
|
|
68
|
-
req: GenerateContentParameters,
|
|
69
|
-
userPromptId: string,
|
|
70
|
-
): Promise<AsyncGenerator<GenerateContentResponse>> {
|
|
71
|
-
const resps = await this.requestStreamingPost<CaGenerateContentResponse>(
|
|
72
|
-
'streamGenerateContent',
|
|
73
|
-
// PRIVACY FIX: sessionId removed from request to prevent transmission to Google servers
|
|
74
|
-
toGenerateContentRequest(
|
|
75
|
-
req,
|
|
76
|
-
userPromptId,
|
|
77
|
-
this.projectId,
|
|
78
|
-
// this.sessionId, // removed
|
|
79
|
-
),
|
|
80
|
-
req.config?.abortSignal,
|
|
81
|
-
);
|
|
82
|
-
return (async function* (): AsyncGenerator<GenerateContentResponse> {
|
|
83
|
-
for await (const resp of resps) {
|
|
84
|
-
yield fromGenerateContentResponse(resp);
|
|
85
|
-
}
|
|
86
|
-
})();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async generateContent(
|
|
90
|
-
req: GenerateContentParameters,
|
|
91
|
-
userPromptId: string,
|
|
92
|
-
): Promise<GenerateContentResponse> {
|
|
93
|
-
debugLogger.log(
|
|
94
|
-
`CodeAssistServer.generateContent: userPromptId=${userPromptId}, model=${req.model}, projectId=${this.projectId}`,
|
|
95
|
-
);
|
|
96
|
-
debugLogger.log(
|
|
97
|
-
`CodeAssistServer.generateContent: request contents:`,
|
|
98
|
-
req.contents,
|
|
99
|
-
);
|
|
100
|
-
debugLogger.log(
|
|
101
|
-
`CodeAssistServer.generateContent: request config:`,
|
|
102
|
-
req.config,
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const resp = await this.requestPost<CaGenerateContentResponse>(
|
|
107
|
-
'generateContent',
|
|
108
|
-
// PRIVACY FIX: sessionId removed from request to prevent transmission to Google servers
|
|
109
|
-
toGenerateContentRequest(
|
|
110
|
-
req,
|
|
111
|
-
userPromptId,
|
|
112
|
-
this.projectId,
|
|
113
|
-
// this.sessionId, // removed
|
|
114
|
-
),
|
|
115
|
-
req.config?.abortSignal,
|
|
116
|
-
);
|
|
117
|
-
debugLogger.log(`CodeAssistServer.generateContent: request successful`);
|
|
118
|
-
return fromGenerateContentResponse(resp);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
debugLogger.log(
|
|
121
|
-
`CodeAssistServer.generateContent: ERROR during request: ${error}`,
|
|
122
|
-
);
|
|
123
|
-
debugLogger.log(
|
|
124
|
-
`CodeAssistServer.generateContent: Error details:`,
|
|
125
|
-
error,
|
|
126
|
-
);
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async onboardUser(
|
|
132
|
-
req: OnboardUserRequest,
|
|
133
|
-
): Promise<LongRunningOperationResponse> {
|
|
134
|
-
return this.requestPost<LongRunningOperationResponse>('onboardUser', req);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async loadCodeAssist(
|
|
138
|
-
req: LoadCodeAssistRequest,
|
|
139
|
-
): Promise<LoadCodeAssistResponse> {
|
|
140
|
-
return this.requestPost<LoadCodeAssistResponse>('loadCodeAssist', req);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async getCodeAssistGlobalUserSetting(): Promise<CodeAssistGlobalUserSettingResponse> {
|
|
144
|
-
return this.requestGet<CodeAssistGlobalUserSettingResponse>(
|
|
145
|
-
'getCodeAssistGlobalUserSetting',
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
async setCodeAssistGlobalUserSetting(
|
|
150
|
-
req: SetCodeAssistGlobalUserSettingRequest,
|
|
151
|
-
): Promise<CodeAssistGlobalUserSettingResponse> {
|
|
152
|
-
return this.requestPost<CodeAssistGlobalUserSettingResponse>(
|
|
153
|
-
'setCodeAssistGlobalUserSetting',
|
|
154
|
-
req,
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async retrieveUserQuota(
|
|
159
|
-
req: RetrieveUserQuotaRequest,
|
|
160
|
-
): Promise<RetrieveUserQuotaResponse> {
|
|
161
|
-
return this.requestPost<RetrieveUserQuotaResponse>(
|
|
162
|
-
'retrieveUserQuota',
|
|
163
|
-
req,
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async countTokens(req: CountTokensParameters): Promise<CountTokensResponse> {
|
|
168
|
-
const resp = await this.requestPost<CaCountTokenResponse>(
|
|
169
|
-
'countTokens',
|
|
170
|
-
toCountTokenRequest(req),
|
|
171
|
-
);
|
|
172
|
-
return fromCountTokenResponse(resp);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async embedContent(
|
|
176
|
-
_req: EmbedContentParameters,
|
|
177
|
-
): Promise<EmbedContentResponse> {
|
|
178
|
-
throw Error();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
async requestPost<T>(
|
|
182
|
-
method: string,
|
|
183
|
-
req: object,
|
|
184
|
-
signal?: AbortSignal,
|
|
185
|
-
): Promise<T> {
|
|
186
|
-
const res = await this.client.request({
|
|
187
|
-
url: this.getMethodUrl(method),
|
|
188
|
-
method: 'POST',
|
|
189
|
-
headers: {
|
|
190
|
-
'Content-Type': 'application/json',
|
|
191
|
-
...this.httpOptions.headers,
|
|
192
|
-
},
|
|
193
|
-
responseType: 'json',
|
|
194
|
-
body: JSON.stringify(req),
|
|
195
|
-
signal,
|
|
196
|
-
});
|
|
197
|
-
return res.data as T;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async requestGet<T>(method: string, signal?: AbortSignal): Promise<T> {
|
|
201
|
-
const res = await this.client.request({
|
|
202
|
-
url: this.getMethodUrl(method),
|
|
203
|
-
method: 'GET',
|
|
204
|
-
headers: {
|
|
205
|
-
'Content-Type': 'application/json',
|
|
206
|
-
...this.httpOptions.headers,
|
|
207
|
-
},
|
|
208
|
-
responseType: 'json',
|
|
209
|
-
signal,
|
|
210
|
-
});
|
|
211
|
-
return res.data as T;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async requestStreamingPost<T>(
|
|
215
|
-
method: string,
|
|
216
|
-
req: object,
|
|
217
|
-
signal?: AbortSignal,
|
|
218
|
-
): Promise<AsyncGenerator<T>> {
|
|
219
|
-
const res = await this.client.request({
|
|
220
|
-
url: this.getMethodUrl(method),
|
|
221
|
-
method: 'POST',
|
|
222
|
-
params: {
|
|
223
|
-
alt: 'sse',
|
|
224
|
-
},
|
|
225
|
-
headers: {
|
|
226
|
-
'Content-Type': 'application/json',
|
|
227
|
-
...this.httpOptions.headers,
|
|
228
|
-
},
|
|
229
|
-
responseType: 'stream',
|
|
230
|
-
body: JSON.stringify(req),
|
|
231
|
-
signal,
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
return (async function* (): AsyncGenerator<T> {
|
|
235
|
-
const rl = readline.createInterface({
|
|
236
|
-
input: res.data as NodeJS.ReadableStream,
|
|
237
|
-
crlfDelay: Infinity, // Recognizes '\r\n' and '\n' as line breaks
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
let bufferedLines: string[] = [];
|
|
241
|
-
for await (const line of rl) {
|
|
242
|
-
// blank lines are used to separate JSON objects in the stream
|
|
243
|
-
if (line === '') {
|
|
244
|
-
if (bufferedLines.length === 0) {
|
|
245
|
-
continue; // no data to yield
|
|
246
|
-
}
|
|
247
|
-
yield JSON.parse(bufferedLines.join('\n')) as T;
|
|
248
|
-
bufferedLines = []; // Reset the buffer after yielding
|
|
249
|
-
} else if (line.startsWith('data: ')) {
|
|
250
|
-
bufferedLines.push(line.slice(6).trim());
|
|
251
|
-
} else {
|
|
252
|
-
throw new Error(`Unexpected line format in response: ${line}`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
})();
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
getMethodUrl(method: string): string {
|
|
259
|
-
const endpoint =
|
|
260
|
-
this.baseURL ?? process.env.CODE_ASSIST_ENDPOINT ?? CODE_ASSIST_ENDPOINT;
|
|
261
|
-
return `${endpoint}/${CODE_ASSIST_API_VERSION}:${method}`;
|
|
262
|
-
}
|
|
263
|
-
}
|
package/src/code_assist/setup.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type ClientMetadata,
|
|
9
|
-
type GeminiUserTier,
|
|
10
|
-
type LoadCodeAssistResponse,
|
|
11
|
-
type OnboardUserRequest,
|
|
12
|
-
UserTierId,
|
|
13
|
-
} from './types.js';
|
|
14
|
-
import { CodeAssistServer } from './server.js';
|
|
15
|
-
import type { OAuth2Client } from 'google-auth-library';
|
|
16
|
-
import { DebugLogger } from '../debug/index.js';
|
|
17
|
-
|
|
18
|
-
export class ProjectIdRequiredError extends Error {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(
|
|
21
|
-
'This account requires setting the GOOGLE_CLOUD_PROJECT or GOOGLE_CLOUD_PROJECT_ID env var. See https://github.com/vybestack/llxprt-code/blob/main/docs/authentication.md',
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface UserData {
|
|
27
|
-
projectId: string;
|
|
28
|
-
userTier: UserTierId;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param projectId the user's project id, if any
|
|
34
|
-
* @returns the user's actual project id
|
|
35
|
-
*/
|
|
36
|
-
export async function setupUser(client: OAuth2Client): Promise<UserData> {
|
|
37
|
-
const logger = new DebugLogger('llxprt:code:setup');
|
|
38
|
-
|
|
39
|
-
logger.debug(
|
|
40
|
-
() =>
|
|
41
|
-
`setupUser: starting setup, GOOGLE_CLOUD_PROJECT=${process.env.GOOGLE_CLOUD_PROJECT ?? 'undefined'}`,
|
|
42
|
-
);
|
|
43
|
-
const rawProjectId =
|
|
44
|
-
process.env['GOOGLE_CLOUD_PROJECT'] ??
|
|
45
|
-
process.env['GOOGLE_CLOUD_PROJECT_ID'];
|
|
46
|
-
const projectId = rawProjectId === '' ? undefined : rawProjectId;
|
|
47
|
-
// PRIVACY FIX: sessionId parameter removed from CodeAssistServer constructor
|
|
48
|
-
const caServer = new CodeAssistServer(client, projectId, {}, undefined);
|
|
49
|
-
const coreClientMetadata: ClientMetadata = {
|
|
50
|
-
ideType: 'IDE_UNSPECIFIED',
|
|
51
|
-
platform: 'PLATFORM_UNSPECIFIED',
|
|
52
|
-
pluginType: 'GEMINI',
|
|
53
|
-
};
|
|
54
|
-
logger.debug(
|
|
55
|
-
() => `setupUser: created CodeAssistServer, calling loadCodeAssist`,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const loadRes = await caServer.loadCodeAssist({
|
|
59
|
-
cloudaicompanionProject: projectId,
|
|
60
|
-
metadata: {
|
|
61
|
-
...coreClientMetadata,
|
|
62
|
-
duetProject: projectId,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
logger.debug(
|
|
66
|
-
() =>
|
|
67
|
-
`setupUser: loadCodeAssist completed, currentTier=${!!loadRes.currentTier}, cloudaicompanionProject=${loadRes.cloudaicompanionProject}`,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const existing = resolveExistingTierResult(loadRes, projectId, logger);
|
|
71
|
-
if (existing) {
|
|
72
|
-
return existing;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const tier = getOnboardTier(loadRes);
|
|
76
|
-
if (tier.userDefinedCloudaicompanionProject === true && !projectId) {
|
|
77
|
-
throw new ProjectIdRequiredError();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const onboardReq = buildOnboardUserRequest(
|
|
81
|
-
tier,
|
|
82
|
-
projectId,
|
|
83
|
-
coreClientMetadata,
|
|
84
|
-
);
|
|
85
|
-
return finishOnboarding(caServer, onboardReq, tier, projectId);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function resolveExistingTierResult(
|
|
89
|
-
loadRes: LoadCodeAssistResponse,
|
|
90
|
-
projectId: string | undefined,
|
|
91
|
-
logger: DebugLogger,
|
|
92
|
-
): UserData | undefined {
|
|
93
|
-
if (!loadRes.currentTier) {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
logger.debug(
|
|
97
|
-
() => `setupUser: user has current tier: ${loadRes.currentTier!.id}`,
|
|
98
|
-
);
|
|
99
|
-
if (!loadRes.cloudaicompanionProject) {
|
|
100
|
-
if (projectId) {
|
|
101
|
-
logger.debug(
|
|
102
|
-
() => `setupUser: returning with project ID from env: ${projectId}`,
|
|
103
|
-
);
|
|
104
|
-
return {
|
|
105
|
-
projectId,
|
|
106
|
-
userTier: loadRes.currentTier.id,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
logger.debug(
|
|
110
|
-
() =>
|
|
111
|
-
`setupUser: throwing ProjectIdRequiredError - no project ID available`,
|
|
112
|
-
);
|
|
113
|
-
throw new ProjectIdRequiredError();
|
|
114
|
-
}
|
|
115
|
-
logger.debug(
|
|
116
|
-
() =>
|
|
117
|
-
`setupUser: returning with project ID from response: ${loadRes.cloudaicompanionProject}`,
|
|
118
|
-
);
|
|
119
|
-
return {
|
|
120
|
-
projectId: loadRes.cloudaicompanionProject,
|
|
121
|
-
userTier: loadRes.currentTier.id,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function buildOnboardUserRequest(
|
|
126
|
-
tier: GeminiUserTier,
|
|
127
|
-
projectId: string | undefined,
|
|
128
|
-
coreClientMetadata: ClientMetadata,
|
|
129
|
-
): OnboardUserRequest {
|
|
130
|
-
if (tier.id === UserTierId.FREE) {
|
|
131
|
-
// The free tier uses a managed google cloud project. Setting a project in the `onboardUser` request causes a `Precondition Failed` error.
|
|
132
|
-
return {
|
|
133
|
-
tierId: tier.id,
|
|
134
|
-
cloudaicompanionProject: undefined,
|
|
135
|
-
metadata: coreClientMetadata,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
tierId: tier.id,
|
|
140
|
-
cloudaicompanionProject: projectId,
|
|
141
|
-
metadata: {
|
|
142
|
-
...coreClientMetadata,
|
|
143
|
-
duetProject: projectId,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function finishOnboarding(
|
|
149
|
-
caServer: CodeAssistServer,
|
|
150
|
-
onboardReq: OnboardUserRequest,
|
|
151
|
-
tier: GeminiUserTier,
|
|
152
|
-
projectId: string | undefined,
|
|
153
|
-
): Promise<UserData> {
|
|
154
|
-
// Poll onboardUser until long running operation is complete.
|
|
155
|
-
let lroRes = await caServer.onboardUser(onboardReq);
|
|
156
|
-
while (lroRes.done !== true) {
|
|
157
|
-
await new Promise((f) => setTimeout(f, 5000));
|
|
158
|
-
lroRes = await caServer.onboardUser(onboardReq);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (!lroRes.response?.cloudaicompanionProject?.id) {
|
|
162
|
-
if (projectId) {
|
|
163
|
-
return {
|
|
164
|
-
projectId,
|
|
165
|
-
userTier: tier.id,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
throw new ProjectIdRequiredError();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
projectId: lroRes.response.cloudaicompanionProject.id,
|
|
173
|
-
userTier: tier.id,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function getOnboardTier(res: LoadCodeAssistResponse): GeminiUserTier {
|
|
178
|
-
for (const tier of res.allowedTiers ?? []) {
|
|
179
|
-
if (tier.isDefault === true) {
|
|
180
|
-
return tier;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
name: '',
|
|
185
|
-
description: '',
|
|
186
|
-
id: UserTierId.LEGACY,
|
|
187
|
-
userDefinedCloudaicompanionProject: true,
|
|
188
|
-
};
|
|
189
|
-
}
|