dexto 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/agents/coding-agent/coding-agent.yml +17 -0
- package/dist/agents/coding-agent/skills/code-review.md +46 -0
- package/dist/agents/explore-agent/explore-agent.yml +2 -0
- package/dist/analytics/events.d.ts +1 -1
- package/dist/analytics/events.d.ts.map +1 -1
- package/dist/api/server-hono.d.ts.map +1 -1
- package/dist/api/server-hono.js +55 -10
- package/dist/cli/assets/dexto-logo.svg +31 -0
- package/dist/cli/auth/api-client.d.ts +49 -0
- package/dist/cli/auth/api-client.d.ts.map +1 -0
- package/dist/cli/auth/api-client.js +127 -0
- package/dist/cli/auth/constants.d.ts +27 -0
- package/dist/cli/auth/constants.d.ts.map +1 -0
- package/dist/cli/auth/constants.js +28 -0
- package/dist/cli/auth/index.d.ts +5 -0
- package/dist/cli/auth/index.d.ts.map +1 -0
- package/dist/cli/auth/index.js +6 -0
- package/dist/cli/auth/oauth.d.ts +26 -0
- package/dist/cli/auth/oauth.d.ts.map +1 -0
- package/dist/cli/auth/oauth.js +327 -0
- package/dist/cli/auth/service.d.ts +20 -0
- package/dist/cli/auth/service.d.ts.map +1 -0
- package/dist/cli/auth/service.js +147 -0
- package/dist/cli/commands/auth/index.d.ts +4 -0
- package/dist/cli/commands/auth/index.d.ts.map +1 -0
- package/dist/cli/commands/auth/index.js +4 -0
- package/dist/cli/commands/auth/login.d.ts +9 -0
- package/dist/cli/commands/auth/login.d.ts.map +1 -0
- package/dist/cli/commands/auth/login.js +255 -0
- package/dist/cli/commands/auth/logout.d.ts +5 -0
- package/dist/cli/commands/auth/logout.d.ts.map +1 -0
- package/dist/cli/commands/auth/logout.js +51 -0
- package/dist/cli/commands/auth/status.d.ts +2 -0
- package/dist/cli/commands/auth/status.d.ts.map +1 -0
- package/dist/cli/commands/auth/status.js +22 -0
- package/dist/cli/commands/billing/index.d.ts +2 -0
- package/dist/cli/commands/billing/index.d.ts.map +1 -0
- package/dist/cli/commands/billing/index.js +2 -0
- package/dist/cli/commands/billing/status.d.ts +8 -0
- package/dist/cli/commands/billing/status.d.ts.map +1 -0
- package/dist/cli/commands/billing/status.js +82 -0
- package/dist/cli/commands/index.d.ts +3 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +8 -0
- package/dist/cli/commands/interactive-commands/auth/index.d.ts +12 -0
- package/dist/cli/commands/interactive-commands/auth/index.d.ts.map +1 -0
- package/dist/cli/commands/interactive-commands/auth/index.js +20 -0
- package/dist/cli/commands/interactive-commands/command-parser.d.ts +5 -0
- package/dist/cli/commands/interactive-commands/command-parser.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/command-parser.js +6 -0
- package/dist/cli/commands/interactive-commands/commands.d.ts +1 -0
- package/dist/cli/commands/interactive-commands/commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/commands.js +8 -0
- package/dist/cli/commands/interactive-commands/mcp/index.d.ts +2 -2
- package/dist/cli/commands/interactive-commands/mcp/index.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/mcp/index.js +4 -7
- package/dist/cli/commands/interactive-commands/model/index.d.ts +2 -2
- package/dist/cli/commands/interactive-commands/model/index.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/model/index.js +4 -7
- package/dist/cli/commands/interactive-commands/plugin/index.d.ts +13 -0
- package/dist/cli/commands/interactive-commands/plugin/index.d.ts.map +1 -0
- package/dist/cli/commands/interactive-commands/plugin/index.js +18 -0
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts +3 -1
- package/dist/cli/commands/interactive-commands/prompt-commands.d.ts.map +1 -1
- package/dist/cli/commands/interactive-commands/prompt-commands.js +88 -36
- package/dist/cli/commands/list-agents.d.ts.map +1 -1
- package/dist/cli/commands/list-agents.js +3 -2
- package/dist/cli/commands/plugin.d.ts +161 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +376 -0
- package/dist/cli/commands/setup.d.ts +9 -9
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +944 -176
- package/dist/cli/ink-cli/InkCLIRefactored.d.ts.map +1 -1
- package/dist/cli/ink-cli/InkCLIRefactored.js +13 -2
- package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts +1 -1
- package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/ApprovalPrompt.js +80 -12
- package/dist/cli/ink-cli/components/BackgroundTasksPanel.d.ts +18 -0
- package/dist/cli/ink-cli/components/BackgroundTasksPanel.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/BackgroundTasksPanel.js +48 -0
- package/dist/cli/ink-cli/components/ErrorBoundary.js +1 -1
- package/dist/cli/ink-cli/components/Footer.d.ts +2 -1
- package/dist/cli/ink-cli/components/Footer.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/Footer.js +6 -2
- package/dist/cli/ink-cli/components/ResourceAutocomplete.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/ResourceAutocomplete.js +150 -41
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/SlashCommandAutocomplete.js +15 -7
- package/dist/cli/ink-cli/components/StatusBar.d.ts +7 -1
- package/dist/cli/ink-cli/components/StatusBar.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/StatusBar.js +18 -2
- package/dist/cli/ink-cli/components/chat/MessageItem.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/chat/MessageItem.js +23 -6
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.js +5 -1
- package/dist/cli/ink-cli/components/modes/StaticCLI.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/modes/StaticCLI.js +5 -1
- package/dist/cli/ink-cli/components/overlays/ContextStatsOverlay.js +1 -1
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/CustomModelWizard.js +8 -4
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts +1 -0
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/LogLevelSelector.js +31 -20
- package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.d.ts +20 -0
- package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.js +81 -0
- package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.d.ts +31 -0
- package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.js +297 -0
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.js +8 -2
- package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts +1 -1
- package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/McpServerActions.js +9 -0
- package/dist/cli/ink-cli/components/overlays/McpServerList.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/McpServerList.js +9 -2
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts +1 -0
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.js +150 -34
- package/dist/cli/ink-cli/components/overlays/PluginActions.d.ts +27 -0
- package/dist/cli/ink-cli/components/overlays/PluginActions.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PluginActions.js +66 -0
- package/dist/cli/ink-cli/components/overlays/PluginList.d.ts +21 -0
- package/dist/cli/ink-cli/components/overlays/PluginList.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PluginList.js +70 -0
- package/dist/cli/ink-cli/components/overlays/PluginManager.d.ts +21 -0
- package/dist/cli/ink-cli/components/overlays/PluginManager.d.ts.map +1 -0
- package/dist/cli/ink-cli/components/overlays/PluginManager.js +63 -0
- package/dist/cli/ink-cli/components/overlays/PromptList.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/PromptList.js +4 -1
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts +1 -0
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/ToolBrowser.js +281 -39
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts +10 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.js +87 -2
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts +4 -2
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts.map +1 -1
- package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.js +4 -4
- package/dist/cli/ink-cli/containers/InputContainer.d.ts.map +1 -1
- package/dist/cli/ink-cli/containers/InputContainer.js +32 -5
- package/dist/cli/ink-cli/containers/OverlayContainer.d.ts.map +1 -1
- package/dist/cli/ink-cli/containers/OverlayContainer.js +384 -28
- package/dist/cli/ink-cli/hooks/index.d.ts +1 -0
- package/dist/cli/ink-cli/hooks/index.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/index.js +1 -0
- package/dist/cli/ink-cli/hooks/useAgentEvents.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/useAgentEvents.js +61 -0
- package/dist/cli/ink-cli/hooks/useCLIState.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/useCLIState.js +5 -0
- package/dist/cli/ink-cli/hooks/useGitBranch.d.ts +13 -0
- package/dist/cli/ink-cli/hooks/useGitBranch.d.ts.map +1 -0
- package/dist/cli/ink-cli/hooks/useGitBranch.js +35 -0
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.d.ts.map +1 -1
- package/dist/cli/ink-cli/hooks/useInputOrchestrator.js +53 -6
- package/dist/cli/ink-cli/services/processStream.d.ts.map +1 -1
- package/dist/cli/ink-cli/services/processStream.js +92 -12
- package/dist/cli/ink-cli/state/initialState.d.ts.map +1 -1
- package/dist/cli/ink-cli/state/initialState.js +5 -0
- package/dist/cli/ink-cli/state/types.d.ts +12 -1
- package/dist/cli/ink-cli/state/types.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/commandOverlays.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/commandOverlays.js +1 -0
- package/dist/cli/ink-cli/utils/llm-provider-display.d.ts +3 -0
- package/dist/cli/ink-cli/utils/llm-provider-display.d.ts.map +1 -0
- package/dist/cli/ink-cli/utils/llm-provider-display.js +22 -0
- package/dist/cli/ink-cli/utils/messageFormatting.d.ts +18 -7
- package/dist/cli/ink-cli/utils/messageFormatting.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/messageFormatting.js +143 -15
- package/dist/cli/ink-cli/utils/toolUtils.d.ts +11 -0
- package/dist/cli/ink-cli/utils/toolUtils.d.ts.map +1 -1
- package/dist/cli/ink-cli/utils/toolUtils.js +17 -0
- package/dist/cli/mcp/index.d.ts +8 -0
- package/dist/cli/mcp/index.d.ts.map +1 -0
- package/dist/cli/mcp/index.js +7 -0
- package/dist/cli/mcp/oauth-factory.d.ts +6 -0
- package/dist/cli/mcp/oauth-factory.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-factory.js +25 -0
- package/dist/cli/mcp/oauth-provider.d.ts +10 -0
- package/dist/cli/mcp/oauth-provider.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-provider.js +77 -0
- package/dist/cli/mcp/oauth-redirect.d.ts +3 -0
- package/dist/cli/mcp/oauth-redirect.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-redirect.js +4 -0
- package/dist/cli/mcp/oauth-server.d.ts +2 -0
- package/dist/cli/mcp/oauth-server.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-server.js +70 -0
- package/dist/cli/mcp/oauth-store.d.ts +10 -0
- package/dist/cli/mcp/oauth-store.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-store.js +27 -0
- package/dist/cli/mcp/oauth-ui.d.ts +2 -0
- package/dist/cli/mcp/oauth-ui.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-ui.js +12 -0
- package/dist/cli/mcp/oauth-utils.d.ts +2 -0
- package/dist/cli/mcp/oauth-utils.d.ts.map +1 -0
- package/dist/cli/mcp/oauth-utils.js +17 -0
- package/dist/cli/utils/api-key-verification.d.ts.map +1 -1
- package/dist/cli/utils/api-key-verification.js +36 -0
- package/dist/cli/utils/config-validation.d.ts +3 -1
- package/dist/cli/utils/config-validation.d.ts.map +1 -1
- package/dist/cli/utils/config-validation.js +42 -19
- package/dist/cli/utils/dexto-auth-check.d.ts +53 -0
- package/dist/cli/utils/dexto-auth-check.d.ts.map +1 -0
- package/dist/cli/utils/dexto-auth-check.js +104 -0
- package/dist/cli/utils/dexto-setup.d.ts +8 -0
- package/dist/cli/utils/dexto-setup.d.ts.map +1 -0
- package/dist/cli/utils/dexto-setup.js +17 -0
- package/dist/cli/utils/options.d.ts.map +1 -1
- package/dist/cli/utils/options.js +5 -1
- package/dist/cli/utils/provider-setup.d.ts +5 -1
- package/dist/cli/utils/provider-setup.d.ts.map +1 -1
- package/dist/cli/utils/provider-setup.js +29 -1
- package/dist/config/cli-overrides.d.ts +17 -8
- package/dist/config/cli-overrides.d.ts.map +1 -1
- package/dist/config/cli-overrides.js +36 -22
- package/dist/config/effective-llm.d.ts +123 -0
- package/dist/config/effective-llm.d.ts.map +1 -0
- package/dist/config/effective-llm.js +171 -0
- package/dist/index.js +404 -99
- package/dist/webui/assets/index-C9JXwpvo.css +1 -0
- package/dist/webui/assets/{index-DVQWNLpT.js → index-Cz2z7NQ8.js} +218 -218
- package/dist/webui/index.html +2 -2
- package/package.json +9 -8
- package/dist/webui/assets/index-BglIVTSG.css +0 -1
|
@@ -2,13 +2,21 @@
|
|
|
2
2
|
* CLI-specific configuration types and utilities
|
|
3
3
|
* This file handles CLI argument processing and config merging logic
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Current behavior (Three-Layer LLM Resolution):
|
|
6
|
+
* Global preferences from preferences.yml are applied to ALL agents at runtime.
|
|
7
|
+
* See feature-plans/auto-update.md section 8.11 for the resolution order:
|
|
8
|
+
* 1. agent.local.yml llm section → Agent-specific override (NOT YET IMPLEMENTED)
|
|
9
|
+
* 2. preferences.yml llm section → User's global default (CURRENT)
|
|
10
|
+
* 3. agent.yml llm section → Bundled fallback
|
|
11
|
+
*
|
|
12
|
+
* Note: Sub-agents spawned via RuntimeService have separate LLM resolution logic
|
|
13
|
+
* that tries to preserve the sub-agent's intended model when possible.
|
|
14
|
+
* See packages/agent-management/src/tool-provider/llm-resolution.ts
|
|
15
|
+
*
|
|
16
|
+
* TODO: Future enhancements
|
|
17
|
+
* - Per-agent local overrides (~/.dexto/agents/{id}/{id}.local.yml)
|
|
9
18
|
* - Agent capability requirements (requires: { vision: true, toolUse: true })
|
|
10
|
-
* - Merge strategy configuration
|
|
11
|
-
* - User-controlled preference scopes via CLI flags (--prefer-global-llm)
|
|
19
|
+
* - Merge strategy configuration for non-LLM fields
|
|
12
20
|
*/
|
|
13
21
|
/**
|
|
14
22
|
* Applies CLI overrides to an agent configuration
|
|
@@ -59,9 +67,10 @@ export function applyCLIOverrides(baseConfig, cliOverrides) {
|
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
61
69
|
* Applies global user preferences to an agent configuration at runtime.
|
|
62
|
-
* This is used
|
|
70
|
+
* This is used to ensure user's LLM preferences are applied to all agents.
|
|
63
71
|
*
|
|
64
72
|
* Unlike writeLLMPreferences() which modifies files, this performs an in-memory merge.
|
|
73
|
+
* User preferences fully override agent defaults for provider, model, and apiKey.
|
|
65
74
|
*
|
|
66
75
|
* @param baseConfig The configuration loaded from agent file
|
|
67
76
|
* @param preferences Global user preferences
|
|
@@ -70,21 +79,22 @@ export function applyCLIOverrides(baseConfig, cliOverrides) {
|
|
|
70
79
|
export function applyUserPreferences(baseConfig, preferences) {
|
|
71
80
|
// Create a deep copy to avoid mutating the original
|
|
72
81
|
const mergedConfig = JSON.parse(JSON.stringify(baseConfig));
|
|
73
|
-
//
|
|
74
|
-
if (preferences.llm) {
|
|
75
|
-
mergedConfig
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
// No LLM preferences to apply
|
|
83
|
+
if (!preferences.llm) {
|
|
84
|
+
return mergedConfig;
|
|
85
|
+
}
|
|
86
|
+
// Apply user preferences - only override if defined (preferences is Partial)
|
|
87
|
+
if (preferences.llm.provider) {
|
|
88
|
+
mergedConfig.llm.provider = preferences.llm.provider;
|
|
89
|
+
}
|
|
90
|
+
if (preferences.llm.model) {
|
|
91
|
+
mergedConfig.llm.model = preferences.llm.model;
|
|
92
|
+
}
|
|
93
|
+
if (preferences.llm.apiKey) {
|
|
94
|
+
mergedConfig.llm.apiKey = preferences.llm.apiKey;
|
|
95
|
+
}
|
|
96
|
+
if (preferences.llm.baseURL) {
|
|
97
|
+
mergedConfig.llm.baseURL = preferences.llm.baseURL;
|
|
88
98
|
}
|
|
89
99
|
return mergedConfig;
|
|
90
100
|
}
|
|
@@ -140,6 +150,8 @@ function getEnvVarForProvider(provider) {
|
|
|
140
150
|
groq: 'GROQ_API_KEY',
|
|
141
151
|
xai: 'XAI_API_KEY',
|
|
142
152
|
cohere: 'COHERE_API_KEY',
|
|
153
|
+
minimax: 'MINIMAX_API_KEY',
|
|
154
|
+
glm: 'ZHIPU_API_KEY',
|
|
143
155
|
openrouter: 'OPENROUTER_API_KEY',
|
|
144
156
|
litellm: 'LITELLM_API_KEY',
|
|
145
157
|
glama: 'GLAMA_API_KEY',
|
|
@@ -148,6 +160,8 @@ function getEnvVarForProvider(provider) {
|
|
|
148
160
|
// Local providers don't require API keys (empty string signals no key needed)
|
|
149
161
|
local: '',
|
|
150
162
|
ollama: '',
|
|
163
|
+
// Dexto gateway uses DEXTO_API_KEY from `dexto login`
|
|
164
|
+
'dexto-nova': 'DEXTO_API_KEY',
|
|
151
165
|
};
|
|
152
166
|
return envVarMap[provider];
|
|
153
167
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective LLM Configuration Resolution
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities to determine the effective LLM configuration
|
|
5
|
+
* at runtime, considering the layered config approach.
|
|
6
|
+
*
|
|
7
|
+
* ## Configuration Layers (Priority Order)
|
|
8
|
+
*
|
|
9
|
+
* 1. **agent.local.yml** (highest priority) - Agent-specific user overrides
|
|
10
|
+
* - Path: `~/.dexto/agents/{agent-id}/{agent-id}.local.yml`
|
|
11
|
+
* - Use case: User wants a specific agent to use a different LLM
|
|
12
|
+
* - NOT YET IMPLEMENTED - see feature-plans/auto-update.md section 8.9-8.11
|
|
13
|
+
*
|
|
14
|
+
* 2. **preferences.yml** - User's global default LLM
|
|
15
|
+
* - Path: `~/.dexto/preferences.yml`
|
|
16
|
+
* - Use case: User's default choice from setup wizard or `/model` command
|
|
17
|
+
* - This is where most users' LLM config comes from
|
|
18
|
+
*
|
|
19
|
+
* 3. **agent.yml** (lowest priority) - Bundled agent defaults
|
|
20
|
+
* - Path: `~/.dexto/agents/{agent-id}/{agent-id}.yml`
|
|
21
|
+
* - Use case: Fallback for users who skip setup or power users with BYOK
|
|
22
|
+
* - This file is managed by Dexto and replaced on CLI updates
|
|
23
|
+
*
|
|
24
|
+
* ## Usage
|
|
25
|
+
*
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { getEffectiveLLMConfig } from './config/effective-llm.js';
|
|
28
|
+
*
|
|
29
|
+
* const llm = await getEffectiveLLMConfig();
|
|
30
|
+
* if (llm?.provider === 'dexto-nova') {
|
|
31
|
+
* // User is configured to use Dexto Nova credits
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* console.log(`Using ${llm.model} via ${llm.provider} (from ${llm.source})`);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ## Related Documentation
|
|
38
|
+
*
|
|
39
|
+
* - feature-plans/auto-update.md - Layered config and .local.yml design
|
|
40
|
+
* - feature-plans/holistic-dexto-auth-analysis/ - Explicit provider routing
|
|
41
|
+
*
|
|
42
|
+
* @module effective-llm
|
|
43
|
+
*/
|
|
44
|
+
import type { LLMProvider } from '@dexto/core';
|
|
45
|
+
/**
|
|
46
|
+
* Source of the effective LLM configuration
|
|
47
|
+
*/
|
|
48
|
+
export type LLMConfigSource = 'local' | 'preferences' | 'bundled';
|
|
49
|
+
/**
|
|
50
|
+
* The resolved effective LLM configuration with source tracking
|
|
51
|
+
*/
|
|
52
|
+
export interface EffectiveLLMConfig {
|
|
53
|
+
/** LLM provider (e.g., 'dexto-nova', 'anthropic', 'openai') */
|
|
54
|
+
provider: LLMProvider;
|
|
55
|
+
/** Model identifier (format depends on provider) */
|
|
56
|
+
model: string;
|
|
57
|
+
/** API key or environment variable reference (e.g., '$DEXTO_API_KEY') */
|
|
58
|
+
apiKey?: string;
|
|
59
|
+
/** Base URL for custom endpoints */
|
|
60
|
+
baseURL?: string;
|
|
61
|
+
/** Where this config came from */
|
|
62
|
+
source: LLMConfigSource;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Options for getEffectiveLLMConfig
|
|
66
|
+
*/
|
|
67
|
+
export interface GetEffectiveLLMConfigOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Agent ID to resolve config for.
|
|
70
|
+
* @default 'coding-agent'
|
|
71
|
+
*/
|
|
72
|
+
agentId?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to include the bundled agent config as fallback.
|
|
75
|
+
* Set to false if you only want user-configured LLM.
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
includeBundledFallback?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the effective LLM configuration considering all config layers.
|
|
82
|
+
*
|
|
83
|
+
* This function resolves which LLM config will actually be used at runtime
|
|
84
|
+
* by checking each layer in priority order:
|
|
85
|
+
*
|
|
86
|
+
* 1. agent.local.yml (NOT YET IMPLEMENTED)
|
|
87
|
+
* 2. preferences.yml
|
|
88
|
+
* 3. bundled agent.yml (if includeBundledFallback is true)
|
|
89
|
+
*
|
|
90
|
+
* @param options - Configuration options
|
|
91
|
+
* @returns The effective LLM config with source, or null if none found
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Get effective LLM for default agent
|
|
96
|
+
* const llm = await getEffectiveLLMConfig();
|
|
97
|
+
*
|
|
98
|
+
* // Get effective LLM for a specific agent
|
|
99
|
+
* const llm = await getEffectiveLLMConfig({ agentId: 'explore-agent' });
|
|
100
|
+
*
|
|
101
|
+
* // Only get user-configured LLM (no bundled fallback)
|
|
102
|
+
* const llm = await getEffectiveLLMConfig({ includeBundledFallback: false });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function getEffectiveLLMConfig(options?: GetEffectiveLLMConfigOptions): Promise<EffectiveLLMConfig | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Check if the effective LLM config uses Dexto credits.
|
|
108
|
+
*
|
|
109
|
+
* Convenience function that checks if the user is configured to use
|
|
110
|
+
* the Dexto provider (which requires authentication).
|
|
111
|
+
*
|
|
112
|
+
* @param options - Same options as getEffectiveLLMConfig
|
|
113
|
+
* @returns true if using provider: dexto-nova, false otherwise
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* if (await isUsingDextoCredits()) {
|
|
118
|
+
* // Check authentication, show billing info, etc.
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function isUsingDextoCredits(options?: GetEffectiveLLMConfigOptions): Promise<boolean>;
|
|
123
|
+
//# sourceMappingURL=effective-llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effective-llm.d.ts","sourceRoot":"","sources":["../../src/config/effective-llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAS/C;;GAEG;AACH,MAAM,MAAM,eAAe,GACrB,OAAO,GACP,aAAa,GACb,SAAS,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,+DAA+D;IAC/D,QAAQ,EAAE,WAAW,CAAC;IACtB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,MAAM,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,qBAAqB,CACvC,OAAO,GAAE,4BAAiC,GAC3C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAsFpC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CACrC,OAAO,GAAE,4BAAiC,GAC3C,OAAO,CAAC,OAAO,CAAC,CAGlB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective LLM Configuration Resolution
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities to determine the effective LLM configuration
|
|
5
|
+
* at runtime, considering the layered config approach.
|
|
6
|
+
*
|
|
7
|
+
* ## Configuration Layers (Priority Order)
|
|
8
|
+
*
|
|
9
|
+
* 1. **agent.local.yml** (highest priority) - Agent-specific user overrides
|
|
10
|
+
* - Path: `~/.dexto/agents/{agent-id}/{agent-id}.local.yml`
|
|
11
|
+
* - Use case: User wants a specific agent to use a different LLM
|
|
12
|
+
* - NOT YET IMPLEMENTED - see feature-plans/auto-update.md section 8.9-8.11
|
|
13
|
+
*
|
|
14
|
+
* 2. **preferences.yml** - User's global default LLM
|
|
15
|
+
* - Path: `~/.dexto/preferences.yml`
|
|
16
|
+
* - Use case: User's default choice from setup wizard or `/model` command
|
|
17
|
+
* - This is where most users' LLM config comes from
|
|
18
|
+
*
|
|
19
|
+
* 3. **agent.yml** (lowest priority) - Bundled agent defaults
|
|
20
|
+
* - Path: `~/.dexto/agents/{agent-id}/{agent-id}.yml`
|
|
21
|
+
* - Use case: Fallback for users who skip setup or power users with BYOK
|
|
22
|
+
* - This file is managed by Dexto and replaced on CLI updates
|
|
23
|
+
*
|
|
24
|
+
* ## Usage
|
|
25
|
+
*
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { getEffectiveLLMConfig } from './config/effective-llm.js';
|
|
28
|
+
*
|
|
29
|
+
* const llm = await getEffectiveLLMConfig();
|
|
30
|
+
* if (llm?.provider === 'dexto-nova') {
|
|
31
|
+
* // User is configured to use Dexto Nova credits
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* console.log(`Using ${llm.model} via ${llm.provider} (from ${llm.source})`);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ## Related Documentation
|
|
38
|
+
*
|
|
39
|
+
* - feature-plans/auto-update.md - Layered config and .local.yml design
|
|
40
|
+
* - feature-plans/holistic-dexto-auth-analysis/ - Explicit provider routing
|
|
41
|
+
*
|
|
42
|
+
* @module effective-llm
|
|
43
|
+
*/
|
|
44
|
+
import { loadGlobalPreferences, globalPreferencesExist, loadAgentConfig, resolveAgentPath, } from '@dexto/agent-management';
|
|
45
|
+
import { logger } from '@dexto/core';
|
|
46
|
+
/**
|
|
47
|
+
* Get the effective LLM configuration considering all config layers.
|
|
48
|
+
*
|
|
49
|
+
* This function resolves which LLM config will actually be used at runtime
|
|
50
|
+
* by checking each layer in priority order:
|
|
51
|
+
*
|
|
52
|
+
* 1. agent.local.yml (NOT YET IMPLEMENTED)
|
|
53
|
+
* 2. preferences.yml
|
|
54
|
+
* 3. bundled agent.yml (if includeBundledFallback is true)
|
|
55
|
+
*
|
|
56
|
+
* @param options - Configuration options
|
|
57
|
+
* @returns The effective LLM config with source, or null if none found
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* // Get effective LLM for default agent
|
|
62
|
+
* const llm = await getEffectiveLLMConfig();
|
|
63
|
+
*
|
|
64
|
+
* // Get effective LLM for a specific agent
|
|
65
|
+
* const llm = await getEffectiveLLMConfig({ agentId: 'explore-agent' });
|
|
66
|
+
*
|
|
67
|
+
* // Only get user-configured LLM (no bundled fallback)
|
|
68
|
+
* const llm = await getEffectiveLLMConfig({ includeBundledFallback: false });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export async function getEffectiveLLMConfig(options = {}) {
|
|
72
|
+
const { agentId = 'coding-agent', includeBundledFallback = true } = options;
|
|
73
|
+
// -------------------------------------------------------------------------
|
|
74
|
+
// Layer 1: agent.local.yml (NOT YET IMPLEMENTED)
|
|
75
|
+
// -------------------------------------------------------------------------
|
|
76
|
+
// TODO: Implement .local.yml loading when the feature is built
|
|
77
|
+
// See feature-plans/auto-update.md section 8.9-8.11 for the design
|
|
78
|
+
//
|
|
79
|
+
// The implementation would look something like:
|
|
80
|
+
//
|
|
81
|
+
// const localConfig = await loadLocalAgentConfig(agentId);
|
|
82
|
+
// if (localConfig?.llm?.provider && localConfig?.llm?.model) {
|
|
83
|
+
// logger.debug(`Using LLM config from ${agentId}.local.yml`);
|
|
84
|
+
// return {
|
|
85
|
+
// provider: localConfig.llm.provider,
|
|
86
|
+
// model: localConfig.llm.model,
|
|
87
|
+
// apiKey: localConfig.llm.apiKey,
|
|
88
|
+
// baseURL: localConfig.llm.baseURL,
|
|
89
|
+
// source: 'local',
|
|
90
|
+
// };
|
|
91
|
+
// }
|
|
92
|
+
// -------------------------------------------------------------------------
|
|
93
|
+
// -------------------------------------------------------------------------
|
|
94
|
+
// Layer 2: preferences.yml (user's global default)
|
|
95
|
+
// -------------------------------------------------------------------------
|
|
96
|
+
if (globalPreferencesExist()) {
|
|
97
|
+
try {
|
|
98
|
+
const preferences = await loadGlobalPreferences();
|
|
99
|
+
if (preferences?.llm?.provider && preferences?.llm?.model) {
|
|
100
|
+
logger.debug('Using LLM config from preferences.yml');
|
|
101
|
+
const result = {
|
|
102
|
+
provider: preferences.llm.provider,
|
|
103
|
+
model: preferences.llm.model,
|
|
104
|
+
source: 'preferences',
|
|
105
|
+
};
|
|
106
|
+
// Only set optional fields if they have values
|
|
107
|
+
if (preferences.llm.apiKey) {
|
|
108
|
+
result.apiKey = preferences.llm.apiKey;
|
|
109
|
+
}
|
|
110
|
+
if (preferences.llm.baseURL) {
|
|
111
|
+
result.baseURL = preferences.llm.baseURL;
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
logger.debug(`Could not load preferences: ${error instanceof Error ? error.message : String(error)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// -------------------------------------------------------------------------
|
|
121
|
+
// Layer 3: Bundled agent.yml (fallback)
|
|
122
|
+
// -------------------------------------------------------------------------
|
|
123
|
+
if (includeBundledFallback) {
|
|
124
|
+
try {
|
|
125
|
+
const agentPath = await resolveAgentPath(agentId);
|
|
126
|
+
if (agentPath) {
|
|
127
|
+
const agentConfig = await loadAgentConfig(agentPath);
|
|
128
|
+
if (agentConfig?.llm?.provider && agentConfig?.llm?.model) {
|
|
129
|
+
logger.debug(`Using LLM config from bundled ${agentId}.yml`);
|
|
130
|
+
const result = {
|
|
131
|
+
provider: agentConfig.llm.provider,
|
|
132
|
+
model: agentConfig.llm.model,
|
|
133
|
+
source: 'bundled',
|
|
134
|
+
};
|
|
135
|
+
// Only set optional fields if they have values
|
|
136
|
+
if (agentConfig.llm.apiKey) {
|
|
137
|
+
result.apiKey = agentConfig.llm.apiKey;
|
|
138
|
+
}
|
|
139
|
+
if (agentConfig.llm.baseURL) {
|
|
140
|
+
result.baseURL = agentConfig.llm.baseURL;
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
logger.debug(`Could not load agent config: ${error instanceof Error ? error.message : String(error)}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Check if the effective LLM config uses Dexto credits.
|
|
154
|
+
*
|
|
155
|
+
* Convenience function that checks if the user is configured to use
|
|
156
|
+
* the Dexto provider (which requires authentication).
|
|
157
|
+
*
|
|
158
|
+
* @param options - Same options as getEffectiveLLMConfig
|
|
159
|
+
* @returns true if using provider: dexto-nova, false otherwise
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* if (await isUsingDextoCredits()) {
|
|
164
|
+
* // Check authentication, show billing info, etc.
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export async function isUsingDextoCredits(options = {}) {
|
|
169
|
+
const config = await getEffectiveLLMConfig(options);
|
|
170
|
+
return config?.provider === 'dexto-nova';
|
|
171
|
+
}
|