@clinebot/core 0.0.20 → 0.0.21
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/account/cline-account-service.d.ts +3 -2
- package/dist/account/cline-account-service.d.ts.map +1 -0
- package/dist/account/index.d.ts +1 -0
- package/dist/account/index.d.ts.map +1 -0
- package/dist/account/rpc.d.ts +1 -0
- package/dist/account/rpc.d.ts.map +1 -0
- package/dist/account/types.d.ts +1 -0
- package/dist/account/types.d.ts.map +1 -0
- package/dist/agents/agent-config-loader.d.ts +1 -0
- package/dist/agents/agent-config-loader.d.ts.map +1 -0
- package/dist/agents/agent-config-parser.d.ts +1 -0
- package/dist/agents/agent-config-parser.d.ts.map +1 -0
- package/dist/agents/hooks-config-loader.d.ts +1 -0
- package/dist/agents/hooks-config-loader.d.ts.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/plugin-config-loader.d.ts +1 -0
- package/dist/agents/plugin-config-loader.d.ts.map +1 -0
- package/dist/agents/plugin-loader.d.ts +1 -0
- package/dist/agents/plugin-loader.d.ts.map +1 -0
- package/dist/agents/plugin-sandbox.d.ts +1 -0
- package/dist/agents/plugin-sandbox.d.ts.map +1 -0
- package/dist/agents/unified-config-file-watcher.d.ts +1 -0
- package/dist/agents/unified-config-file-watcher.d.ts.map +1 -0
- package/dist/agents/user-instruction-config-loader.d.ts +1 -0
- package/dist/agents/user-instruction-config-loader.d.ts.map +1 -0
- package/dist/auth/client.d.ts +1 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/cline.d.ts +1 -0
- package/dist/auth/cline.d.ts.map +1 -0
- package/dist/auth/codex.d.ts +1 -0
- package/dist/auth/codex.d.ts.map +1 -0
- package/dist/auth/oca.d.ts +1 -0
- package/dist/auth/oca.d.ts.map +1 -0
- package/dist/auth/server.d.ts +1 -0
- package/dist/auth/server.d.ts.map +1 -0
- package/dist/auth/types.d.ts +1 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/utils.d.ts +1 -0
- package/dist/auth/utils.d.ts.map +1 -0
- package/dist/chat/chat-schema.d.ts +13 -12
- package/dist/chat/chat-schema.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.node.d.ts +2 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +303 -302
- package/dist/input/file-indexer.d.ts +1 -0
- package/dist/input/file-indexer.d.ts.map +1 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/mention-enricher.d.ts +1 -0
- package/dist/input/mention-enricher.d.ts.map +1 -0
- package/dist/mcp/config-loader.d.ts +1 -0
- package/dist/mcp/config-loader.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/manager.d.ts +1 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/types.d.ts +1 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/providers/local-provider-registry.d.ts +36 -0
- package/dist/providers/local-provider-registry.d.ts.map +1 -0
- package/dist/providers/local-provider-service.d.ts +2 -1
- package/dist/providers/local-provider-service.d.ts.map +1 -0
- package/dist/runtime/commands.d.ts +1 -0
- package/dist/runtime/commands.d.ts.map +1 -0
- package/dist/runtime/hook-file-hooks.d.ts +1 -0
- package/dist/runtime/hook-file-hooks.d.ts.map +1 -0
- package/dist/runtime/rules.d.ts +1 -0
- package/dist/runtime/rules.d.ts.map +1 -0
- package/dist/runtime/runtime-builder.d.ts +1 -0
- package/dist/runtime/runtime-builder.d.ts.map +1 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts +1 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts.map +1 -0
- package/dist/runtime/session-runtime.d.ts +2 -0
- package/dist/runtime/session-runtime.d.ts.map +1 -0
- package/dist/runtime/skills.d.ts +1 -0
- package/dist/runtime/skills.d.ts.map +1 -0
- package/dist/runtime/tool-approval.d.ts +1 -0
- package/dist/runtime/tool-approval.d.ts.map +1 -0
- package/dist/runtime/workflows.d.ts +1 -0
- package/dist/runtime/workflows.d.ts.map +1 -0
- package/dist/session/default-session-manager.d.ts +4 -0
- package/dist/session/default-session-manager.d.ts.map +1 -0
- package/dist/session/file-session-service.d.ts +1 -0
- package/dist/session/file-session-service.d.ts.map +1 -0
- package/dist/session/rpc-session-service.d.ts +1 -0
- package/dist/session/rpc-session-service.d.ts.map +1 -0
- package/dist/session/rpc-spawn-lease.d.ts +1 -0
- package/dist/session/rpc-spawn-lease.d.ts.map +1 -0
- package/dist/session/runtime-oauth-token-manager.d.ts +1 -0
- package/dist/session/runtime-oauth-token-manager.d.ts.map +1 -0
- package/dist/session/session-agent-events.d.ts +20 -1
- package/dist/session/session-agent-events.d.ts.map +1 -0
- package/dist/session/session-artifacts.d.ts +1 -0
- package/dist/session/session-artifacts.d.ts.map +1 -0
- package/dist/session/session-config-builder.d.ts +1 -0
- package/dist/session/session-config-builder.d.ts.map +1 -0
- package/dist/session/session-graph.d.ts +1 -0
- package/dist/session/session-graph.d.ts.map +1 -0
- package/dist/session/session-host.d.ts +1 -0
- package/dist/session/session-host.d.ts.map +1 -0
- package/dist/session/session-manager.d.ts +1 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manifest.d.ts +2 -1
- package/dist/session/session-manifest.d.ts.map +1 -0
- package/dist/session/session-service.d.ts +1 -0
- package/dist/session/session-service.d.ts.map +1 -0
- package/dist/session/session-team-coordination.d.ts +1 -0
- package/dist/session/session-team-coordination.d.ts.map +1 -0
- package/dist/session/session-telemetry.d.ts +3 -1
- package/dist/session/session-telemetry.d.ts.map +1 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts +1 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts.map +1 -0
- package/dist/session/unified-session-persistence-service.d.ts +1 -0
- package/dist/session/unified-session-persistence-service.d.ts.map +1 -0
- package/dist/session/utils/helpers.d.ts +1 -0
- package/dist/session/utils/helpers.d.ts.map +1 -0
- package/dist/session/utils/types.d.ts +1 -0
- package/dist/session/utils/types.d.ts.map +1 -0
- package/dist/session/utils/usage.d.ts +1 -0
- package/dist/session/utils/usage.d.ts.map +1 -0
- package/dist/session/workspace-manager.d.ts +1 -0
- package/dist/session/workspace-manager.d.ts.map +1 -0
- package/dist/session/workspace-manifest.d.ts +1 -0
- package/dist/session/workspace-manifest.d.ts.map +1 -0
- package/dist/storage/file-team-store.d.ts +1 -0
- package/dist/storage/file-team-store.d.ts.map +1 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts +1 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts.map +1 -0
- package/dist/storage/provider-settings-manager.d.ts +1 -0
- package/dist/storage/provider-settings-manager.d.ts.map +1 -0
- package/dist/storage/sqlite-session-store.d.ts +1 -0
- package/dist/storage/sqlite-session-store.d.ts.map +1 -0
- package/dist/storage/sqlite-team-store.d.ts +1 -0
- package/dist/storage/sqlite-team-store.d.ts.map +1 -0
- package/dist/storage/team-store.d.ts +1 -0
- package/dist/storage/team-store.d.ts.map +1 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/projections.d.ts +1 -0
- package/dist/team/projections.d.ts.map +1 -0
- package/dist/telemetry/ITelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/ITelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/OpenTelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -0
- package/dist/telemetry/TelemetryService.d.ts +1 -0
- package/dist/telemetry/TelemetryService.d.ts.map +1 -0
- package/dist/telemetry/core-events.d.ts +55 -22
- package/dist/telemetry/core-events.d.ts.map +1 -0
- package/dist/telemetry/opentelemetry.d.ts +1 -0
- package/dist/telemetry/opentelemetry.d.ts.map +1 -0
- package/dist/tools/constants.d.ts +1 -0
- package/dist/tools/constants.d.ts.map +1 -0
- package/dist/tools/definitions.d.ts +8 -1
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/executors/apply-patch-parser.d.ts +1 -0
- package/dist/tools/executors/apply-patch-parser.d.ts.map +1 -0
- package/dist/tools/executors/apply-patch.d.ts +1 -0
- package/dist/tools/executors/apply-patch.d.ts.map +1 -0
- package/dist/tools/executors/bash.d.ts +2 -1
- package/dist/tools/executors/bash.d.ts.map +1 -0
- package/dist/tools/executors/editor.d.ts +1 -0
- package/dist/tools/executors/editor.d.ts.map +1 -0
- package/dist/tools/executors/file-read.d.ts +1 -0
- package/dist/tools/executors/file-read.d.ts.map +1 -0
- package/dist/tools/executors/index.d.ts +14 -7
- package/dist/tools/executors/index.d.ts.map +1 -0
- package/dist/tools/executors/search.d.ts +1 -0
- package/dist/tools/executors/search.d.ts.map +1 -0
- package/dist/tools/executors/web-fetch.d.ts +1 -0
- package/dist/tools/executors/web-fetch.d.ts.map +1 -0
- package/dist/tools/helpers.d.ts +15 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/model-tool-routing.d.ts +1 -0
- package/dist/tools/model-tool-routing.d.ts.map +1 -0
- package/dist/tools/presets.d.ts +1 -0
- package/dist/tools/presets.d.ts.map +1 -0
- package/dist/tools/schemas.d.ts +41 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/types.d.ts +3 -2
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/types/common.d.ts +1 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/events.d.ts +1 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/provider-settings.d.ts +1 -0
- package/dist/types/provider-settings.d.ts.map +1 -0
- package/dist/types/sessions.d.ts +1 -0
- package/dist/types/sessions.d.ts.map +1 -0
- package/dist/types/storage.d.ts +1 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +6 -4
- package/src/account/cline-account-service.test.ts +0 -101
- package/src/account/cline-account-service.ts +0 -287
- package/src/account/index.ts +0 -22
- package/src/account/rpc.test.ts +0 -62
- package/src/account/rpc.ts +0 -172
- package/src/account/types.ts +0 -98
- package/src/agents/agent-config-loader.test.ts +0 -236
- package/src/agents/agent-config-loader.ts +0 -108
- package/src/agents/agent-config-parser.ts +0 -198
- package/src/agents/hooks-config-loader.test.ts +0 -20
- package/src/agents/hooks-config-loader.ts +0 -118
- package/src/agents/index.ts +0 -85
- package/src/agents/plugin-config-loader.test.ts +0 -140
- package/src/agents/plugin-config-loader.ts +0 -97
- package/src/agents/plugin-loader.test.ts +0 -228
- package/src/agents/plugin-loader.ts +0 -172
- package/src/agents/plugin-sandbox-bootstrap.ts +0 -445
- package/src/agents/plugin-sandbox.test.ts +0 -317
- package/src/agents/plugin-sandbox.ts +0 -341
- package/src/agents/unified-config-file-watcher.test.ts +0 -196
- package/src/agents/unified-config-file-watcher.ts +0 -483
- package/src/agents/user-instruction-config-loader.test.ts +0 -158
- package/src/agents/user-instruction-config-loader.ts +0 -438
- package/src/auth/client.test.ts +0 -40
- package/src/auth/client.ts +0 -25
- package/src/auth/cline.test.ts +0 -130
- package/src/auth/cline.ts +0 -420
- package/src/auth/codex.test.ts +0 -170
- package/src/auth/codex.ts +0 -491
- package/src/auth/oca.test.ts +0 -215
- package/src/auth/oca.ts +0 -573
- package/src/auth/server.ts +0 -216
- package/src/auth/types.ts +0 -81
- package/src/auth/utils.test.ts +0 -128
- package/src/auth/utils.ts +0 -247
- package/src/chat/chat-schema.ts +0 -82
- package/src/index.node.ts +0 -285
- package/src/index.ts +0 -211
- package/src/input/file-indexer.d.ts +0 -11
- package/src/input/file-indexer.test.ts +0 -127
- package/src/input/file-indexer.ts +0 -327
- package/src/input/index.ts +0 -7
- package/src/input/mention-enricher.test.ts +0 -85
- package/src/input/mention-enricher.ts +0 -122
- package/src/mcp/config-loader.test.ts +0 -238
- package/src/mcp/config-loader.ts +0 -219
- package/src/mcp/index.ts +0 -26
- package/src/mcp/manager.test.ts +0 -106
- package/src/mcp/manager.ts +0 -262
- package/src/mcp/types.ts +0 -88
- package/src/providers/local-provider-service.ts +0 -608
- package/src/runtime/commands.test.ts +0 -98
- package/src/runtime/commands.ts +0 -83
- package/src/runtime/hook-file-hooks.test.ts +0 -237
- package/src/runtime/hook-file-hooks.ts +0 -859
- package/src/runtime/index.ts +0 -37
- package/src/runtime/rules.ts +0 -34
- package/src/runtime/runtime-builder.team-persistence.test.ts +0 -202
- package/src/runtime/runtime-builder.test.ts +0 -371
- package/src/runtime/runtime-builder.ts +0 -589
- package/src/runtime/runtime-parity.test.ts +0 -143
- package/src/runtime/sandbox/subprocess-sandbox.ts +0 -231
- package/src/runtime/session-runtime.ts +0 -46
- package/src/runtime/skills.ts +0 -44
- package/src/runtime/tool-approval.ts +0 -104
- package/src/runtime/workflows.test.ts +0 -119
- package/src/runtime/workflows.ts +0 -45
- package/src/session/default-session-manager.e2e.test.ts +0 -384
- package/src/session/default-session-manager.test.ts +0 -1741
- package/src/session/default-session-manager.ts +0 -1233
- package/src/session/file-session-service.ts +0 -280
- package/src/session/index.ts +0 -42
- package/src/session/rpc-session-service.ts +0 -107
- package/src/session/rpc-spawn-lease.test.ts +0 -49
- package/src/session/rpc-spawn-lease.ts +0 -122
- package/src/session/runtime-oauth-token-manager.test.ts +0 -137
- package/src/session/runtime-oauth-token-manager.ts +0 -272
- package/src/session/session-agent-events.ts +0 -159
- package/src/session/session-artifacts.ts +0 -106
- package/src/session/session-config-builder.ts +0 -113
- package/src/session/session-graph.ts +0 -92
- package/src/session/session-host.test.ts +0 -29
- package/src/session/session-host.ts +0 -242
- package/src/session/session-manager.ts +0 -69
- package/src/session/session-manifest.ts +0 -29
- package/src/session/session-service.team-persistence.test.ts +0 -48
- package/src/session/session-service.ts +0 -673
- package/src/session/session-team-coordination.ts +0 -229
- package/src/session/session-telemetry.ts +0 -95
- package/src/session/sqlite-rpc-session-backend.ts +0 -303
- package/src/session/unified-session-persistence-service.test.ts +0 -85
- package/src/session/unified-session-persistence-service.ts +0 -996
- package/src/session/utils/helpers.ts +0 -139
- package/src/session/utils/types.ts +0 -57
- package/src/session/utils/usage.ts +0 -32
- package/src/session/workspace-manager.ts +0 -98
- package/src/session/workspace-manifest.ts +0 -100
- package/src/storage/artifact-store.ts +0 -1
- package/src/storage/file-team-store.ts +0 -257
- package/src/storage/index.ts +0 -11
- package/src/storage/provider-settings-legacy-migration.test.ts +0 -307
- package/src/storage/provider-settings-legacy-migration.ts +0 -689
- package/src/storage/provider-settings-manager.test.ts +0 -145
- package/src/storage/provider-settings-manager.ts +0 -150
- package/src/storage/session-store.ts +0 -1
- package/src/storage/sqlite-session-store.ts +0 -275
- package/src/storage/sqlite-team-store.ts +0 -454
- package/src/storage/team-store.ts +0 -40
- package/src/team/index.ts +0 -4
- package/src/team/projections.ts +0 -285
- package/src/telemetry/ITelemetryAdapter.ts +0 -94
- package/src/telemetry/LoggerTelemetryAdapter.test.ts +0 -42
- package/src/telemetry/LoggerTelemetryAdapter.ts +0 -114
- package/src/telemetry/OpenTelemetryAdapter.test.ts +0 -157
- package/src/telemetry/OpenTelemetryAdapter.ts +0 -348
- package/src/telemetry/OpenTelemetryProvider.test.ts +0 -113
- package/src/telemetry/OpenTelemetryProvider.ts +0 -322
- package/src/telemetry/TelemetryService.test.ts +0 -134
- package/src/telemetry/TelemetryService.ts +0 -141
- package/src/telemetry/core-events.ts +0 -344
- package/src/telemetry/opentelemetry.ts +0 -20
- package/src/tools/constants.ts +0 -35
- package/src/tools/definitions.test.ts +0 -658
- package/src/tools/definitions.ts +0 -726
- package/src/tools/executors/apply-patch-parser.ts +0 -520
- package/src/tools/executors/apply-patch.ts +0 -359
- package/src/tools/executors/bash.ts +0 -205
- package/src/tools/executors/editor.test.ts +0 -35
- package/src/tools/executors/editor.ts +0 -219
- package/src/tools/executors/file-read.test.ts +0 -49
- package/src/tools/executors/file-read.ts +0 -110
- package/src/tools/executors/index.ts +0 -75
- package/src/tools/executors/search.ts +0 -278
- package/src/tools/executors/web-fetch.ts +0 -259
- package/src/tools/index.ts +0 -168
- package/src/tools/model-tool-routing.test.ts +0 -86
- package/src/tools/model-tool-routing.ts +0 -132
- package/src/tools/presets.test.ts +0 -62
- package/src/tools/presets.ts +0 -168
- package/src/tools/schemas.ts +0 -284
- package/src/tools/types.ts +0 -328
- package/src/types/common.ts +0 -14
- package/src/types/config.ts +0 -84
- package/src/types/events.ts +0 -74
- package/src/types/index.ts +0 -24
- package/src/types/provider-settings.ts +0 -43
- package/src/types/sessions.ts +0 -16
- package/src/types/storage.ts +0 -64
- package/src/types/workspace.ts +0 -7
- package/src/types.ts +0 -128
|
@@ -1,689 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { LlmsModels, LlmsProviders } from "@clinebot/llms";
|
|
4
|
-
import { resolveClineDataDir } from "@clinebot/shared/storage";
|
|
5
|
-
import type { ProviderSettings } from "../types/provider-settings";
|
|
6
|
-
import { emptyStoredProviderSettings } from "../types/provider-settings";
|
|
7
|
-
import type { ProviderSettingsManager } from "./provider-settings-manager";
|
|
8
|
-
|
|
9
|
-
type LegacyMode = "plan" | "act";
|
|
10
|
-
|
|
11
|
-
interface LegacyGlobalState {
|
|
12
|
-
mode?: LegacyMode;
|
|
13
|
-
planModeApiProvider?: string;
|
|
14
|
-
actModeApiProvider?: string;
|
|
15
|
-
planModeApiModelId?: string;
|
|
16
|
-
actModeApiModelId?: string;
|
|
17
|
-
planModeReasoningEffort?: string;
|
|
18
|
-
actModeReasoningEffort?: string;
|
|
19
|
-
planModeThinkingBudgetTokens?: number;
|
|
20
|
-
actModeThinkingBudgetTokens?: number;
|
|
21
|
-
geminiPlanModeThinkingLevel?: string;
|
|
22
|
-
geminiActModeThinkingLevel?: string;
|
|
23
|
-
anthropicBaseUrl?: string;
|
|
24
|
-
openAiBaseUrl?: string;
|
|
25
|
-
ollamaBaseUrl?: string;
|
|
26
|
-
lmStudioBaseUrl?: string;
|
|
27
|
-
liteLlmBaseUrl?: string;
|
|
28
|
-
geminiBaseUrl?: string;
|
|
29
|
-
requestyBaseUrl?: string;
|
|
30
|
-
asksageApiUrl?: string;
|
|
31
|
-
difyBaseUrl?: string;
|
|
32
|
-
ocaBaseUrl?: string;
|
|
33
|
-
aihubmixBaseUrl?: string;
|
|
34
|
-
openAiHeaders?: Record<string, string>;
|
|
35
|
-
requestTimeoutMs?: number;
|
|
36
|
-
awsRegion?: string;
|
|
37
|
-
awsAuthentication?: "iam" | "api-key" | "profile";
|
|
38
|
-
awsUseProfile?: boolean;
|
|
39
|
-
awsProfile?: string;
|
|
40
|
-
awsUseCrossRegionInference?: boolean;
|
|
41
|
-
awsUseGlobalInference?: boolean;
|
|
42
|
-
awsBedrockUsePromptCache?: boolean;
|
|
43
|
-
awsBedrockEndpoint?: string;
|
|
44
|
-
planModeAwsBedrockCustomModelBaseId?: string;
|
|
45
|
-
actModeAwsBedrockCustomModelBaseId?: string;
|
|
46
|
-
vertexProjectId?: string;
|
|
47
|
-
vertexRegion?: string;
|
|
48
|
-
azureApiVersion?: string;
|
|
49
|
-
azureIdentity?: boolean;
|
|
50
|
-
sapAiCoreTokenUrl?: string;
|
|
51
|
-
sapAiCoreBaseUrl?: string;
|
|
52
|
-
sapAiResourceGroup?: string;
|
|
53
|
-
sapAiCoreUseOrchestrationMode?: boolean;
|
|
54
|
-
ocaMode?: "internal" | "external";
|
|
55
|
-
qwenApiLine?: "china" | "international";
|
|
56
|
-
moonshotApiLine?: "china" | "international";
|
|
57
|
-
zaiApiLine?: "china" | "international";
|
|
58
|
-
minimaxApiLine?: "china" | "international";
|
|
59
|
-
planModeOpenRouterModelId?: string;
|
|
60
|
-
actModeOpenRouterModelId?: string;
|
|
61
|
-
planModeClineModelId?: string;
|
|
62
|
-
actModeClineModelId?: string;
|
|
63
|
-
planModeOpenAiModelId?: string;
|
|
64
|
-
actModeOpenAiModelId?: string;
|
|
65
|
-
planModeOllamaModelId?: string;
|
|
66
|
-
actModeOllamaModelId?: string;
|
|
67
|
-
planModeLmStudioModelId?: string;
|
|
68
|
-
actModeLmStudioModelId?: string;
|
|
69
|
-
planModeLiteLlmModelId?: string;
|
|
70
|
-
actModeLiteLlmModelId?: string;
|
|
71
|
-
planModeRequestyModelId?: string;
|
|
72
|
-
actModeRequestyModelId?: string;
|
|
73
|
-
planModeTogetherModelId?: string;
|
|
74
|
-
actModeTogetherModelId?: string;
|
|
75
|
-
planModeFireworksModelId?: string;
|
|
76
|
-
actModeFireworksModelId?: string;
|
|
77
|
-
planModeSapAiCoreModelId?: string;
|
|
78
|
-
actModeSapAiCoreModelId?: string;
|
|
79
|
-
planModeSapAiCoreDeploymentId?: string;
|
|
80
|
-
actModeSapAiCoreDeploymentId?: string;
|
|
81
|
-
planModeGroqModelId?: string;
|
|
82
|
-
actModeGroqModelId?: string;
|
|
83
|
-
planModeBasetenModelId?: string;
|
|
84
|
-
actModeBasetenModelId?: string;
|
|
85
|
-
planModeHuggingFaceModelId?: string;
|
|
86
|
-
actModeHuggingFaceModelId?: string;
|
|
87
|
-
planModeHuaweiCloudMaasModelId?: string;
|
|
88
|
-
actModeHuaweiCloudMaasModelId?: string;
|
|
89
|
-
planModeOcaModelId?: string;
|
|
90
|
-
actModeOcaModelId?: string;
|
|
91
|
-
planModeAihubmixModelId?: string;
|
|
92
|
-
actModeAihubmixModelId?: string;
|
|
93
|
-
planModeHicapModelId?: string;
|
|
94
|
-
actModeHicapModelId?: string;
|
|
95
|
-
planModeNousResearchModelId?: string;
|
|
96
|
-
actModeNousResearchModelId?: string;
|
|
97
|
-
planModeVercelAiGatewayModelId?: string;
|
|
98
|
-
actModeVercelAiGatewayModelId?: string;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
interface LegacySecrets {
|
|
102
|
-
apiKey?: string;
|
|
103
|
-
clineApiKey?: string;
|
|
104
|
-
"cline:clineAccountId"?: string;
|
|
105
|
-
clineAccountId?: string;
|
|
106
|
-
openRouterApiKey?: string;
|
|
107
|
-
awsAccessKey?: string;
|
|
108
|
-
awsSecretKey?: string;
|
|
109
|
-
awsSessionToken?: string;
|
|
110
|
-
awsBedrockApiKey?: string;
|
|
111
|
-
openAiApiKey?: string;
|
|
112
|
-
geminiApiKey?: string;
|
|
113
|
-
openAiNativeApiKey?: string;
|
|
114
|
-
ollamaApiKey?: string;
|
|
115
|
-
deepSeekApiKey?: string;
|
|
116
|
-
requestyApiKey?: string;
|
|
117
|
-
togetherApiKey?: string;
|
|
118
|
-
fireworksApiKey?: string;
|
|
119
|
-
qwenApiKey?: string;
|
|
120
|
-
doubaoApiKey?: string;
|
|
121
|
-
mistralApiKey?: string;
|
|
122
|
-
liteLlmApiKey?: string;
|
|
123
|
-
asksageApiKey?: string;
|
|
124
|
-
xaiApiKey?: string;
|
|
125
|
-
moonshotApiKey?: string;
|
|
126
|
-
zaiApiKey?: string;
|
|
127
|
-
huggingFaceApiKey?: string;
|
|
128
|
-
nebiusApiKey?: string;
|
|
129
|
-
sambanovaApiKey?: string;
|
|
130
|
-
cerebrasApiKey?: string;
|
|
131
|
-
sapAiCoreClientId?: string;
|
|
132
|
-
sapAiCoreClientSecret?: string;
|
|
133
|
-
groqApiKey?: string;
|
|
134
|
-
huaweiCloudMaasApiKey?: string;
|
|
135
|
-
basetenApiKey?: string;
|
|
136
|
-
vercelAiGatewayApiKey?: string;
|
|
137
|
-
difyApiKey?: string;
|
|
138
|
-
minimaxApiKey?: string;
|
|
139
|
-
hicapApiKey?: string;
|
|
140
|
-
aihubmixApiKey?: string;
|
|
141
|
-
nousResearchApiKey?: string;
|
|
142
|
-
ocaApiKey?: string;
|
|
143
|
-
ocaRefreshToken?: string;
|
|
144
|
-
"openai-codex-oauth-credentials"?: string;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
interface LegacyProviderStorage {
|
|
148
|
-
globalState: LegacyGlobalState;
|
|
149
|
-
secrets: LegacySecrets;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface MigrateLegacyProviderSettingsOptions {
|
|
153
|
-
providerSettingsManager: ProviderSettingsManager;
|
|
154
|
-
dataDir?: string;
|
|
155
|
-
globalStatePath?: string;
|
|
156
|
-
secretsPath?: string;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface MigrateLegacyProviderSettingsResult {
|
|
160
|
-
migrated: boolean;
|
|
161
|
-
providerCount: number;
|
|
162
|
-
lastUsedProvider?: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export type LegacyClineUserInfo = {
|
|
166
|
-
idToken: string;
|
|
167
|
-
expiresAt: number;
|
|
168
|
-
refreshToken: string;
|
|
169
|
-
userInfo: {
|
|
170
|
-
id: string;
|
|
171
|
-
email: string;
|
|
172
|
-
displayName: string;
|
|
173
|
-
termsAcceptedAt: string;
|
|
174
|
-
clineBenchConsent: boolean;
|
|
175
|
-
createdAt: string;
|
|
176
|
-
updatedAt: string;
|
|
177
|
-
};
|
|
178
|
-
provider: string;
|
|
179
|
-
startedAt: number;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Resolves legacy Cline account auth data from the raw `cline:clineAccountId`
|
|
184
|
-
* secret string into the auth fields used by `ProviderSettings`.
|
|
185
|
-
*
|
|
186
|
-
* Returns `undefined` when the input is missing, empty, whitespace-only, or
|
|
187
|
-
* unparseable JSON.
|
|
188
|
-
*/
|
|
189
|
-
export function resolveLegacyClineAuth(
|
|
190
|
-
rawAccountData: string | undefined,
|
|
191
|
-
): ProviderSettings["auth"] | undefined {
|
|
192
|
-
const trimmed = rawAccountData?.trim();
|
|
193
|
-
if (!trimmed) {
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
const data = JSON.parse(trimmed) as LegacyClineUserInfo;
|
|
198
|
-
if (!data) {
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
accessToken: data.idToken,
|
|
203
|
-
refreshToken: data.refreshToken,
|
|
204
|
-
expiresAt: data.expiresAt,
|
|
205
|
-
accountId: data.userInfo?.id,
|
|
206
|
-
};
|
|
207
|
-
} catch {
|
|
208
|
-
return undefined;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function trimNonEmpty(value: string | undefined): string | undefined {
|
|
213
|
-
const trimmed = value?.trim();
|
|
214
|
-
return trimmed ? trimmed : undefined;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function readJsonObject<T extends object>(filePath: string): T | undefined {
|
|
218
|
-
if (!existsSync(filePath)) {
|
|
219
|
-
return undefined;
|
|
220
|
-
}
|
|
221
|
-
try {
|
|
222
|
-
const raw = readFileSync(filePath, "utf8");
|
|
223
|
-
const parsed = JSON.parse(raw) as unknown;
|
|
224
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
225
|
-
return parsed as T;
|
|
226
|
-
}
|
|
227
|
-
} catch {
|
|
228
|
-
// Invalid legacy file should not block startup.
|
|
229
|
-
}
|
|
230
|
-
return undefined;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function resolveLegacyStorage(
|
|
234
|
-
options: MigrateLegacyProviderSettingsOptions,
|
|
235
|
-
): LegacyProviderStorage | undefined {
|
|
236
|
-
const dataDir = options.dataDir ?? resolveClineDataDir();
|
|
237
|
-
const globalStatePath =
|
|
238
|
-
options.globalStatePath ?? join(dataDir, "globalState.json");
|
|
239
|
-
const secretsPath = options.secretsPath ?? join(dataDir, "secrets.json");
|
|
240
|
-
const globalState = readJsonObject<LegacyGlobalState>(globalStatePath);
|
|
241
|
-
const secrets = readJsonObject<LegacySecrets>(secretsPath);
|
|
242
|
-
if (!globalState && !secrets) {
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
return {
|
|
246
|
-
globalState: globalState ?? {},
|
|
247
|
-
secrets: secrets ?? {},
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function resolveModelForProvider(
|
|
252
|
-
legacy: LegacyGlobalState,
|
|
253
|
-
providerId: string,
|
|
254
|
-
mode: LegacyMode,
|
|
255
|
-
activeProviderForMode: string | undefined,
|
|
256
|
-
): string | undefined {
|
|
257
|
-
const modePrefix = mode === "plan" ? "planMode" : "actMode";
|
|
258
|
-
const fallbackModel =
|
|
259
|
-
providerId === activeProviderForMode
|
|
260
|
-
? trimNonEmpty(
|
|
261
|
-
mode === "plan"
|
|
262
|
-
? legacy.planModeApiModelId
|
|
263
|
-
: legacy.actModeApiModelId,
|
|
264
|
-
)
|
|
265
|
-
: undefined;
|
|
266
|
-
const providerModelKeyById: Record<string, keyof LegacyGlobalState> = {
|
|
267
|
-
openrouter: `${modePrefix}OpenRouterModelId` as keyof LegacyGlobalState,
|
|
268
|
-
cline: `${modePrefix}ClineModelId` as keyof LegacyGlobalState,
|
|
269
|
-
openai: `${modePrefix}OpenAiModelId` as keyof LegacyGlobalState,
|
|
270
|
-
ollama: `${modePrefix}OllamaModelId` as keyof LegacyGlobalState,
|
|
271
|
-
lmstudio: `${modePrefix}LmStudioModelId` as keyof LegacyGlobalState,
|
|
272
|
-
litellm: `${modePrefix}LiteLlmModelId` as keyof LegacyGlobalState,
|
|
273
|
-
requesty: `${modePrefix}RequestyModelId` as keyof LegacyGlobalState,
|
|
274
|
-
together: `${modePrefix}TogetherModelId` as keyof LegacyGlobalState,
|
|
275
|
-
fireworks: `${modePrefix}FireworksModelId` as keyof LegacyGlobalState,
|
|
276
|
-
sapaicore: `${modePrefix}SapAiCoreModelId` as keyof LegacyGlobalState,
|
|
277
|
-
groq: `${modePrefix}GroqModelId` as keyof LegacyGlobalState,
|
|
278
|
-
baseten: `${modePrefix}BasetenModelId` as keyof LegacyGlobalState,
|
|
279
|
-
huggingface: `${modePrefix}HuggingFaceModelId` as keyof LegacyGlobalState,
|
|
280
|
-
"huawei-cloud-maas":
|
|
281
|
-
`${modePrefix}HuaweiCloudMaasModelId` as keyof LegacyGlobalState,
|
|
282
|
-
oca: `${modePrefix}OcaModelId` as keyof LegacyGlobalState,
|
|
283
|
-
aihubmix: `${modePrefix}AihubmixModelId` as keyof LegacyGlobalState,
|
|
284
|
-
hicap: `${modePrefix}HicapModelId` as keyof LegacyGlobalState,
|
|
285
|
-
nousResearch: `${modePrefix}NousResearchModelId` as keyof LegacyGlobalState,
|
|
286
|
-
"vercel-ai-gateway":
|
|
287
|
-
`${modePrefix}VercelAiGatewayModelId` as keyof LegacyGlobalState,
|
|
288
|
-
};
|
|
289
|
-
const providerModelKey = providerModelKeyById[providerId];
|
|
290
|
-
const providerModel = providerModelKey
|
|
291
|
-
? trimNonEmpty(
|
|
292
|
-
typeof legacy[providerModelKey] === "string"
|
|
293
|
-
? (legacy[providerModelKey] as string)
|
|
294
|
-
: undefined,
|
|
295
|
-
)
|
|
296
|
-
: undefined;
|
|
297
|
-
return providerModel ?? fallbackModel;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function resolveReasoning(
|
|
301
|
-
legacy: LegacyGlobalState,
|
|
302
|
-
providerId: string,
|
|
303
|
-
mode: LegacyMode,
|
|
304
|
-
): ProviderSettings["reasoning"] | undefined {
|
|
305
|
-
const effortCandidate =
|
|
306
|
-
mode === "plan"
|
|
307
|
-
? legacy.planModeReasoningEffort
|
|
308
|
-
: legacy.actModeReasoningEffort;
|
|
309
|
-
const geminiLevel =
|
|
310
|
-
mode === "plan"
|
|
311
|
-
? legacy.geminiPlanModeThinkingLevel
|
|
312
|
-
: legacy.geminiActModeThinkingLevel;
|
|
313
|
-
const budgetTokens =
|
|
314
|
-
mode === "plan"
|
|
315
|
-
? legacy.planModeThinkingBudgetTokens
|
|
316
|
-
: legacy.actModeThinkingBudgetTokens;
|
|
317
|
-
const rawEffort =
|
|
318
|
-
(providerId === "gemini" ? geminiLevel : undefined) ?? effortCandidate;
|
|
319
|
-
const effort =
|
|
320
|
-
rawEffort === "none" ||
|
|
321
|
-
rawEffort === "low" ||
|
|
322
|
-
rawEffort === "medium" ||
|
|
323
|
-
rawEffort === "high"
|
|
324
|
-
? rawEffort
|
|
325
|
-
: undefined;
|
|
326
|
-
const normalizedBudget =
|
|
327
|
-
typeof budgetTokens === "number" &&
|
|
328
|
-
Number.isInteger(budgetTokens) &&
|
|
329
|
-
budgetTokens > 0
|
|
330
|
-
? budgetTokens
|
|
331
|
-
: undefined;
|
|
332
|
-
if (!effort && normalizedBudget === undefined) {
|
|
333
|
-
return undefined;
|
|
334
|
-
}
|
|
335
|
-
return {
|
|
336
|
-
...(effort ? { effort } : {}),
|
|
337
|
-
...(normalizedBudget !== undefined
|
|
338
|
-
? { budgetTokens: normalizedBudget }
|
|
339
|
-
: {}),
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function resolveLegacyCodexAuth(
|
|
344
|
-
legacySecrets: LegacySecrets,
|
|
345
|
-
): Pick<ProviderSettings, "apiKey" | "auth"> | undefined {
|
|
346
|
-
const raw = legacySecrets["openai-codex-oauth-credentials"];
|
|
347
|
-
if (!raw) {
|
|
348
|
-
return undefined;
|
|
349
|
-
}
|
|
350
|
-
try {
|
|
351
|
-
const parsed = JSON.parse(raw) as {
|
|
352
|
-
access_token?: string;
|
|
353
|
-
refresh_token?: string;
|
|
354
|
-
accountId?: string;
|
|
355
|
-
};
|
|
356
|
-
const access = trimNonEmpty(parsed.access_token);
|
|
357
|
-
const refresh = trimNonEmpty(parsed.refresh_token);
|
|
358
|
-
const accountId = trimNonEmpty(parsed.accountId);
|
|
359
|
-
if (!access && !refresh && !accountId) {
|
|
360
|
-
return undefined;
|
|
361
|
-
}
|
|
362
|
-
return {
|
|
363
|
-
...(access ? { apiKey: access } : {}),
|
|
364
|
-
auth: {
|
|
365
|
-
...(access ? { accessToken: access } : {}),
|
|
366
|
-
...(refresh ? { refreshToken: refresh } : {}),
|
|
367
|
-
...(accountId ? { accountId } : {}),
|
|
368
|
-
},
|
|
369
|
-
};
|
|
370
|
-
} catch {
|
|
371
|
-
return undefined;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
function getDefaultModelForProvider(providerId: string): string | undefined {
|
|
376
|
-
const builtInModels = LlmsModels.getGeneratedModelsForProvider(providerId);
|
|
377
|
-
const firstModelId = Object.keys(builtInModels)[0];
|
|
378
|
-
return firstModelId ?? undefined;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
function buildLegacyProviderSettings(
|
|
382
|
-
providerId: string,
|
|
383
|
-
legacyGlobalState: LegacyGlobalState,
|
|
384
|
-
legacySecrets: LegacySecrets,
|
|
385
|
-
mode: LegacyMode,
|
|
386
|
-
): ProviderSettings | undefined {
|
|
387
|
-
const activeProviderForMode = trimNonEmpty(
|
|
388
|
-
mode === "plan"
|
|
389
|
-
? legacyGlobalState.planModeApiProvider
|
|
390
|
-
: legacyGlobalState.actModeApiProvider,
|
|
391
|
-
);
|
|
392
|
-
const model =
|
|
393
|
-
resolveModelForProvider(
|
|
394
|
-
legacyGlobalState,
|
|
395
|
-
providerId,
|
|
396
|
-
mode,
|
|
397
|
-
activeProviderForMode,
|
|
398
|
-
) ?? getDefaultModelForProvider(providerId);
|
|
399
|
-
const reasoning = resolveReasoning(legacyGlobalState, providerId, mode);
|
|
400
|
-
const timeout =
|
|
401
|
-
typeof legacyGlobalState.requestTimeoutMs === "number" &&
|
|
402
|
-
Number.isInteger(legacyGlobalState.requestTimeoutMs) &&
|
|
403
|
-
legacyGlobalState.requestTimeoutMs > 0
|
|
404
|
-
? legacyGlobalState.requestTimeoutMs
|
|
405
|
-
: undefined;
|
|
406
|
-
|
|
407
|
-
const secretByProvider: Record<string, string | undefined> = {
|
|
408
|
-
anthropic: legacySecrets.apiKey,
|
|
409
|
-
cline: legacySecrets.clineApiKey,
|
|
410
|
-
openai: legacySecrets.openAiApiKey,
|
|
411
|
-
"openai-native": legacySecrets.openAiNativeApiKey,
|
|
412
|
-
openrouter: legacySecrets.openRouterApiKey,
|
|
413
|
-
bedrock: legacySecrets.awsBedrockApiKey,
|
|
414
|
-
gemini: legacySecrets.geminiApiKey,
|
|
415
|
-
ollama: legacySecrets.ollamaApiKey,
|
|
416
|
-
deepseek: legacySecrets.deepSeekApiKey,
|
|
417
|
-
requesty: legacySecrets.requestyApiKey,
|
|
418
|
-
together: legacySecrets.togetherApiKey,
|
|
419
|
-
fireworks: legacySecrets.fireworksApiKey,
|
|
420
|
-
qwen: legacySecrets.qwenApiKey,
|
|
421
|
-
doubao: legacySecrets.doubaoApiKey,
|
|
422
|
-
mistral: legacySecrets.mistralApiKey,
|
|
423
|
-
litellm: legacySecrets.liteLlmApiKey,
|
|
424
|
-
asksage: legacySecrets.asksageApiKey,
|
|
425
|
-
xai: legacySecrets.xaiApiKey,
|
|
426
|
-
moonshot: legacySecrets.moonshotApiKey,
|
|
427
|
-
zai: legacySecrets.zaiApiKey,
|
|
428
|
-
huggingface: legacySecrets.huggingFaceApiKey,
|
|
429
|
-
nebius: legacySecrets.nebiusApiKey,
|
|
430
|
-
sambanova: legacySecrets.sambanovaApiKey,
|
|
431
|
-
cerebras: legacySecrets.cerebrasApiKey,
|
|
432
|
-
groq: legacySecrets.groqApiKey,
|
|
433
|
-
"huawei-cloud-maas": legacySecrets.huaweiCloudMaasApiKey,
|
|
434
|
-
baseten: legacySecrets.basetenApiKey,
|
|
435
|
-
"vercel-ai-gateway": legacySecrets.vercelAiGatewayApiKey,
|
|
436
|
-
dify: legacySecrets.difyApiKey,
|
|
437
|
-
minimax: legacySecrets.minimaxApiKey,
|
|
438
|
-
hicap: legacySecrets.hicapApiKey,
|
|
439
|
-
aihubmix: legacySecrets.aihubmixApiKey,
|
|
440
|
-
nousResearch: legacySecrets.nousResearchApiKey,
|
|
441
|
-
oca: legacySecrets.ocaApiKey,
|
|
442
|
-
sapaicore: legacySecrets.sapAiCoreClientId,
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
const providerSpecific: Partial<ProviderSettings> = {};
|
|
446
|
-
if (providerId === "openai-codex") {
|
|
447
|
-
Object.assign(providerSpecific, resolveLegacyCodexAuth(legacySecrets));
|
|
448
|
-
}
|
|
449
|
-
if (providerId === "cline") {
|
|
450
|
-
try {
|
|
451
|
-
const legacyAuthString = trimNonEmpty(
|
|
452
|
-
legacySecrets["cline:clineAccountId"],
|
|
453
|
-
);
|
|
454
|
-
|
|
455
|
-
if (legacyAuthString) {
|
|
456
|
-
providerSpecific.auth = {
|
|
457
|
-
...(providerSpecific.auth ?? {}),
|
|
458
|
-
...resolveLegacyClineAuth(legacyAuthString),
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
} catch {
|
|
462
|
-
// Failed to parse stored cline auth data
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
if (providerId === "openai" && legacyGlobalState.openAiHeaders) {
|
|
466
|
-
providerSpecific.headers = legacyGlobalState.openAiHeaders;
|
|
467
|
-
}
|
|
468
|
-
if (providerId === "bedrock") {
|
|
469
|
-
providerSpecific.aws = {
|
|
470
|
-
accessKey: trimNonEmpty(legacySecrets.awsAccessKey),
|
|
471
|
-
secretKey: trimNonEmpty(legacySecrets.awsSecretKey),
|
|
472
|
-
sessionToken: trimNonEmpty(legacySecrets.awsSessionToken),
|
|
473
|
-
region: trimNonEmpty(legacyGlobalState.awsRegion),
|
|
474
|
-
authentication: legacyGlobalState.awsAuthentication,
|
|
475
|
-
profile: legacyGlobalState.awsUseProfile
|
|
476
|
-
? trimNonEmpty(legacyGlobalState.awsProfile)
|
|
477
|
-
: undefined,
|
|
478
|
-
usePromptCache: legacyGlobalState.awsBedrockUsePromptCache,
|
|
479
|
-
useCrossRegionInference: legacyGlobalState.awsUseCrossRegionInference,
|
|
480
|
-
useGlobalInference: legacyGlobalState.awsUseGlobalInference,
|
|
481
|
-
endpoint: trimNonEmpty(legacyGlobalState.awsBedrockEndpoint),
|
|
482
|
-
customModelBaseId: trimNonEmpty(
|
|
483
|
-
mode === "plan"
|
|
484
|
-
? legacyGlobalState.planModeAwsBedrockCustomModelBaseId
|
|
485
|
-
: legacyGlobalState.actModeAwsBedrockCustomModelBaseId,
|
|
486
|
-
),
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
if (providerId === "vertex") {
|
|
490
|
-
providerSpecific.gcp = {
|
|
491
|
-
projectId: trimNonEmpty(legacyGlobalState.vertexProjectId),
|
|
492
|
-
region: trimNonEmpty(legacyGlobalState.vertexRegion),
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
if (
|
|
496
|
-
providerId === "openai" &&
|
|
497
|
-
(legacyGlobalState.azureApiVersion ||
|
|
498
|
-
legacyGlobalState.azureIdentity !== undefined)
|
|
499
|
-
) {
|
|
500
|
-
providerSpecific.azure = {
|
|
501
|
-
apiVersion: trimNonEmpty(legacyGlobalState.azureApiVersion),
|
|
502
|
-
useIdentity: legacyGlobalState.azureIdentity,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
if (providerId === "sapaicore") {
|
|
506
|
-
providerSpecific.sap = {
|
|
507
|
-
clientId: trimNonEmpty(legacySecrets.sapAiCoreClientId),
|
|
508
|
-
clientSecret: trimNonEmpty(legacySecrets.sapAiCoreClientSecret),
|
|
509
|
-
tokenUrl: trimNonEmpty(legacyGlobalState.sapAiCoreTokenUrl),
|
|
510
|
-
resourceGroup: trimNonEmpty(legacyGlobalState.sapAiResourceGroup),
|
|
511
|
-
deploymentId: trimNonEmpty(
|
|
512
|
-
mode === "plan"
|
|
513
|
-
? legacyGlobalState.planModeSapAiCoreDeploymentId
|
|
514
|
-
: legacyGlobalState.actModeSapAiCoreDeploymentId,
|
|
515
|
-
),
|
|
516
|
-
useOrchestrationMode: legacyGlobalState.sapAiCoreUseOrchestrationMode,
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
if (providerId === "oca") {
|
|
520
|
-
providerSpecific.oca = {
|
|
521
|
-
mode: legacyGlobalState.ocaMode,
|
|
522
|
-
};
|
|
523
|
-
const refreshToken = trimNonEmpty(legacySecrets.ocaRefreshToken);
|
|
524
|
-
if (refreshToken) {
|
|
525
|
-
providerSpecific.auth = {
|
|
526
|
-
...(providerSpecific.auth ?? {}),
|
|
527
|
-
refreshToken,
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
if (providerId === "qwen") {
|
|
532
|
-
providerSpecific.apiLine = legacyGlobalState.qwenApiLine;
|
|
533
|
-
}
|
|
534
|
-
if (providerId === "moonshot") {
|
|
535
|
-
providerSpecific.apiLine = legacyGlobalState.moonshotApiLine;
|
|
536
|
-
}
|
|
537
|
-
if (providerId === "zai") {
|
|
538
|
-
providerSpecific.apiLine = legacyGlobalState.zaiApiLine;
|
|
539
|
-
}
|
|
540
|
-
if (providerId === "minimax") {
|
|
541
|
-
providerSpecific.apiLine = legacyGlobalState.minimaxApiLine;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
const baseUrlByProvider: Record<string, string | undefined> = {
|
|
545
|
-
anthropic: legacyGlobalState.anthropicBaseUrl,
|
|
546
|
-
openai: legacyGlobalState.openAiBaseUrl,
|
|
547
|
-
ollama: legacyGlobalState.ollamaBaseUrl,
|
|
548
|
-
lmstudio: legacyGlobalState.lmStudioBaseUrl,
|
|
549
|
-
litellm: legacyGlobalState.liteLlmBaseUrl,
|
|
550
|
-
gemini: legacyGlobalState.geminiBaseUrl,
|
|
551
|
-
requesty: legacyGlobalState.requestyBaseUrl,
|
|
552
|
-
asksage: legacyGlobalState.asksageApiUrl,
|
|
553
|
-
dify: legacyGlobalState.difyBaseUrl,
|
|
554
|
-
oca: legacyGlobalState.ocaBaseUrl,
|
|
555
|
-
aihubmix: legacyGlobalState.aihubmixBaseUrl,
|
|
556
|
-
sapaicore: legacyGlobalState.sapAiCoreBaseUrl,
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
const apiKey = trimNonEmpty(secretByProvider[providerId]);
|
|
560
|
-
const baseUrl = trimNonEmpty(baseUrlByProvider[providerId]);
|
|
561
|
-
|
|
562
|
-
const settings: ProviderSettings = {
|
|
563
|
-
provider: providerId as ProviderSettings["provider"],
|
|
564
|
-
...(apiKey ? { apiKey } : {}),
|
|
565
|
-
...(model ? { model } : {}),
|
|
566
|
-
...(baseUrl ? { baseUrl } : {}),
|
|
567
|
-
...(reasoning ? { reasoning } : {}),
|
|
568
|
-
...(timeout ? { timeout } : {}),
|
|
569
|
-
...providerSpecific,
|
|
570
|
-
};
|
|
571
|
-
const parsed = LlmsProviders.ProviderSettingsSchema.safeParse(settings);
|
|
572
|
-
if (!parsed.success) {
|
|
573
|
-
return undefined;
|
|
574
|
-
}
|
|
575
|
-
const hasNonProviderFields =
|
|
576
|
-
Object.keys(settings).filter((key) => key !== "provider").length > 0;
|
|
577
|
-
return hasNonProviderFields ? parsed.data : undefined;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
function collectCandidateProviderIds(
|
|
581
|
-
legacyGlobalState: LegacyGlobalState,
|
|
582
|
-
legacySecrets: LegacySecrets,
|
|
583
|
-
): Set<string> {
|
|
584
|
-
const candidates = new Set<string>();
|
|
585
|
-
for (const maybeProvider of [
|
|
586
|
-
legacyGlobalState.actModeApiProvider,
|
|
587
|
-
legacyGlobalState.planModeApiProvider,
|
|
588
|
-
]) {
|
|
589
|
-
const provider = trimNonEmpty(maybeProvider);
|
|
590
|
-
if (provider) {
|
|
591
|
-
candidates.add(provider);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
if (trimNonEmpty(legacySecrets.apiKey)) candidates.add("anthropic");
|
|
595
|
-
if (trimNonEmpty(legacySecrets.openRouterApiKey))
|
|
596
|
-
candidates.add("openrouter");
|
|
597
|
-
if (trimNonEmpty(legacySecrets.openAiApiKey)) candidates.add("openai");
|
|
598
|
-
if (trimNonEmpty(legacySecrets.openAiNativeApiKey))
|
|
599
|
-
candidates.add("openai-native");
|
|
600
|
-
if (trimNonEmpty(legacySecrets["openai-codex-oauth-credentials"]))
|
|
601
|
-
candidates.add("openai-codex");
|
|
602
|
-
if (trimNonEmpty(legacySecrets.geminiApiKey)) candidates.add("gemini");
|
|
603
|
-
if (trimNonEmpty(legacySecrets.ollamaApiKey)) candidates.add("ollama");
|
|
604
|
-
if (
|
|
605
|
-
trimNonEmpty(legacySecrets.awsAccessKey) ||
|
|
606
|
-
trimNonEmpty(legacySecrets.awsBedrockApiKey)
|
|
607
|
-
)
|
|
608
|
-
candidates.add("bedrock");
|
|
609
|
-
if (
|
|
610
|
-
trimNonEmpty(legacyGlobalState.vertexProjectId) ||
|
|
611
|
-
trimNonEmpty(legacyGlobalState.vertexRegion)
|
|
612
|
-
) {
|
|
613
|
-
candidates.add("vertex");
|
|
614
|
-
}
|
|
615
|
-
if (trimNonEmpty(legacySecrets.clineApiKey)) candidates.add("cline");
|
|
616
|
-
if (trimNonEmpty(legacySecrets.ocaApiKey)) candidates.add("oca");
|
|
617
|
-
return candidates;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
export function migrateLegacyProviderSettings(
|
|
621
|
-
options: MigrateLegacyProviderSettingsOptions,
|
|
622
|
-
): MigrateLegacyProviderSettingsResult {
|
|
623
|
-
const existing = options.providerSettingsManager.read();
|
|
624
|
-
const legacyStorage = resolveLegacyStorage(options);
|
|
625
|
-
if (!legacyStorage) {
|
|
626
|
-
return {
|
|
627
|
-
migrated: false,
|
|
628
|
-
providerCount: Object.keys(existing.providers).length,
|
|
629
|
-
lastUsedProvider: existing.lastUsedProvider,
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
const { globalState, secrets } = legacyStorage;
|
|
634
|
-
const mode: LegacyMode = globalState.mode === "plan" ? "plan" : "act";
|
|
635
|
-
const candidates = collectCandidateProviderIds(globalState, secrets);
|
|
636
|
-
const next = emptyStoredProviderSettings();
|
|
637
|
-
next.providers = { ...existing.providers };
|
|
638
|
-
next.lastUsedProvider = existing.lastUsedProvider;
|
|
639
|
-
const now = new Date().toISOString();
|
|
640
|
-
let addedProviderCount = 0;
|
|
641
|
-
|
|
642
|
-
for (const providerId of candidates) {
|
|
643
|
-
if (next.providers[providerId]) {
|
|
644
|
-
continue;
|
|
645
|
-
}
|
|
646
|
-
const settings = buildLegacyProviderSettings(
|
|
647
|
-
providerId,
|
|
648
|
-
globalState,
|
|
649
|
-
secrets,
|
|
650
|
-
mode,
|
|
651
|
-
);
|
|
652
|
-
if (!settings) {
|
|
653
|
-
continue;
|
|
654
|
-
}
|
|
655
|
-
next.providers[providerId] = {
|
|
656
|
-
settings,
|
|
657
|
-
updatedAt: now,
|
|
658
|
-
tokenSource: "migration",
|
|
659
|
-
};
|
|
660
|
-
addedProviderCount += 1;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
if (addedProviderCount === 0) {
|
|
664
|
-
return {
|
|
665
|
-
migrated: false,
|
|
666
|
-
providerCount: Object.keys(existing.providers).length,
|
|
667
|
-
lastUsedProvider: existing.lastUsedProvider,
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
const preferredProvider = trimNonEmpty(
|
|
672
|
-
mode === "plan"
|
|
673
|
-
? globalState.planModeApiProvider
|
|
674
|
-
: globalState.actModeApiProvider,
|
|
675
|
-
);
|
|
676
|
-
next.lastUsedProvider =
|
|
677
|
-
existing.lastUsedProvider ??
|
|
678
|
-
(preferredProvider && next.providers[preferredProvider]
|
|
679
|
-
? preferredProvider
|
|
680
|
-
: Object.keys(next.providers)[0]);
|
|
681
|
-
|
|
682
|
-
options.providerSettingsManager.write(next);
|
|
683
|
-
|
|
684
|
-
return {
|
|
685
|
-
migrated: true,
|
|
686
|
-
providerCount: Object.keys(next.providers).length,
|
|
687
|
-
lastUsedProvider: next.lastUsedProvider,
|
|
688
|
-
};
|
|
689
|
-
}
|