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.
Files changed (226) hide show
  1. package/README.md +13 -0
  2. package/dist/agents/coding-agent/coding-agent.yml +17 -0
  3. package/dist/agents/coding-agent/skills/code-review.md +46 -0
  4. package/dist/agents/explore-agent/explore-agent.yml +2 -0
  5. package/dist/analytics/events.d.ts +1 -1
  6. package/dist/analytics/events.d.ts.map +1 -1
  7. package/dist/api/server-hono.d.ts.map +1 -1
  8. package/dist/api/server-hono.js +55 -10
  9. package/dist/cli/assets/dexto-logo.svg +31 -0
  10. package/dist/cli/auth/api-client.d.ts +49 -0
  11. package/dist/cli/auth/api-client.d.ts.map +1 -0
  12. package/dist/cli/auth/api-client.js +127 -0
  13. package/dist/cli/auth/constants.d.ts +27 -0
  14. package/dist/cli/auth/constants.d.ts.map +1 -0
  15. package/dist/cli/auth/constants.js +28 -0
  16. package/dist/cli/auth/index.d.ts +5 -0
  17. package/dist/cli/auth/index.d.ts.map +1 -0
  18. package/dist/cli/auth/index.js +6 -0
  19. package/dist/cli/auth/oauth.d.ts +26 -0
  20. package/dist/cli/auth/oauth.d.ts.map +1 -0
  21. package/dist/cli/auth/oauth.js +327 -0
  22. package/dist/cli/auth/service.d.ts +20 -0
  23. package/dist/cli/auth/service.d.ts.map +1 -0
  24. package/dist/cli/auth/service.js +147 -0
  25. package/dist/cli/commands/auth/index.d.ts +4 -0
  26. package/dist/cli/commands/auth/index.d.ts.map +1 -0
  27. package/dist/cli/commands/auth/index.js +4 -0
  28. package/dist/cli/commands/auth/login.d.ts +9 -0
  29. package/dist/cli/commands/auth/login.d.ts.map +1 -0
  30. package/dist/cli/commands/auth/login.js +255 -0
  31. package/dist/cli/commands/auth/logout.d.ts +5 -0
  32. package/dist/cli/commands/auth/logout.d.ts.map +1 -0
  33. package/dist/cli/commands/auth/logout.js +51 -0
  34. package/dist/cli/commands/auth/status.d.ts +2 -0
  35. package/dist/cli/commands/auth/status.d.ts.map +1 -0
  36. package/dist/cli/commands/auth/status.js +22 -0
  37. package/dist/cli/commands/billing/index.d.ts +2 -0
  38. package/dist/cli/commands/billing/index.d.ts.map +1 -0
  39. package/dist/cli/commands/billing/index.js +2 -0
  40. package/dist/cli/commands/billing/status.d.ts +8 -0
  41. package/dist/cli/commands/billing/status.d.ts.map +1 -0
  42. package/dist/cli/commands/billing/status.js +82 -0
  43. package/dist/cli/commands/index.d.ts +3 -0
  44. package/dist/cli/commands/index.d.ts.map +1 -1
  45. package/dist/cli/commands/index.js +8 -0
  46. package/dist/cli/commands/interactive-commands/auth/index.d.ts +12 -0
  47. package/dist/cli/commands/interactive-commands/auth/index.d.ts.map +1 -0
  48. package/dist/cli/commands/interactive-commands/auth/index.js +20 -0
  49. package/dist/cli/commands/interactive-commands/command-parser.d.ts +5 -0
  50. package/dist/cli/commands/interactive-commands/command-parser.d.ts.map +1 -1
  51. package/dist/cli/commands/interactive-commands/command-parser.js +6 -0
  52. package/dist/cli/commands/interactive-commands/commands.d.ts +1 -0
  53. package/dist/cli/commands/interactive-commands/commands.d.ts.map +1 -1
  54. package/dist/cli/commands/interactive-commands/commands.js +8 -0
  55. package/dist/cli/commands/interactive-commands/mcp/index.d.ts +2 -2
  56. package/dist/cli/commands/interactive-commands/mcp/index.d.ts.map +1 -1
  57. package/dist/cli/commands/interactive-commands/mcp/index.js +4 -7
  58. package/dist/cli/commands/interactive-commands/model/index.d.ts +2 -2
  59. package/dist/cli/commands/interactive-commands/model/index.d.ts.map +1 -1
  60. package/dist/cli/commands/interactive-commands/model/index.js +4 -7
  61. package/dist/cli/commands/interactive-commands/plugin/index.d.ts +13 -0
  62. package/dist/cli/commands/interactive-commands/plugin/index.d.ts.map +1 -0
  63. package/dist/cli/commands/interactive-commands/plugin/index.js +18 -0
  64. package/dist/cli/commands/interactive-commands/prompt-commands.d.ts +3 -1
  65. package/dist/cli/commands/interactive-commands/prompt-commands.d.ts.map +1 -1
  66. package/dist/cli/commands/interactive-commands/prompt-commands.js +88 -36
  67. package/dist/cli/commands/list-agents.d.ts.map +1 -1
  68. package/dist/cli/commands/list-agents.js +3 -2
  69. package/dist/cli/commands/plugin.d.ts +161 -0
  70. package/dist/cli/commands/plugin.d.ts.map +1 -0
  71. package/dist/cli/commands/plugin.js +376 -0
  72. package/dist/cli/commands/setup.d.ts +9 -9
  73. package/dist/cli/commands/setup.d.ts.map +1 -1
  74. package/dist/cli/commands/setup.js +944 -176
  75. package/dist/cli/ink-cli/InkCLIRefactored.d.ts.map +1 -1
  76. package/dist/cli/ink-cli/InkCLIRefactored.js +13 -2
  77. package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts +1 -1
  78. package/dist/cli/ink-cli/components/ApprovalPrompt.d.ts.map +1 -1
  79. package/dist/cli/ink-cli/components/ApprovalPrompt.js +80 -12
  80. package/dist/cli/ink-cli/components/BackgroundTasksPanel.d.ts +18 -0
  81. package/dist/cli/ink-cli/components/BackgroundTasksPanel.d.ts.map +1 -0
  82. package/dist/cli/ink-cli/components/BackgroundTasksPanel.js +48 -0
  83. package/dist/cli/ink-cli/components/ErrorBoundary.js +1 -1
  84. package/dist/cli/ink-cli/components/Footer.d.ts +2 -1
  85. package/dist/cli/ink-cli/components/Footer.d.ts.map +1 -1
  86. package/dist/cli/ink-cli/components/Footer.js +6 -2
  87. package/dist/cli/ink-cli/components/ResourceAutocomplete.d.ts.map +1 -1
  88. package/dist/cli/ink-cli/components/ResourceAutocomplete.js +150 -41
  89. package/dist/cli/ink-cli/components/SlashCommandAutocomplete.d.ts.map +1 -1
  90. package/dist/cli/ink-cli/components/SlashCommandAutocomplete.js +15 -7
  91. package/dist/cli/ink-cli/components/StatusBar.d.ts +7 -1
  92. package/dist/cli/ink-cli/components/StatusBar.d.ts.map +1 -1
  93. package/dist/cli/ink-cli/components/StatusBar.js +18 -2
  94. package/dist/cli/ink-cli/components/chat/MessageItem.d.ts.map +1 -1
  95. package/dist/cli/ink-cli/components/chat/MessageItem.js +23 -6
  96. package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.d.ts.map +1 -1
  97. package/dist/cli/ink-cli/components/modes/AlternateBufferCLI.js +5 -1
  98. package/dist/cli/ink-cli/components/modes/StaticCLI.d.ts.map +1 -1
  99. package/dist/cli/ink-cli/components/modes/StaticCLI.js +5 -1
  100. package/dist/cli/ink-cli/components/overlays/ContextStatsOverlay.js +1 -1
  101. package/dist/cli/ink-cli/components/overlays/CustomModelWizard.d.ts.map +1 -1
  102. package/dist/cli/ink-cli/components/overlays/CustomModelWizard.js +8 -4
  103. package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts +1 -0
  104. package/dist/cli/ink-cli/components/overlays/LogLevelSelector.d.ts.map +1 -1
  105. package/dist/cli/ink-cli/components/overlays/LogLevelSelector.js +31 -20
  106. package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.d.ts +20 -0
  107. package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.d.ts.map +1 -0
  108. package/dist/cli/ink-cli/components/overlays/MarketplaceAddPrompt.js +81 -0
  109. package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.d.ts +31 -0
  110. package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.d.ts.map +1 -0
  111. package/dist/cli/ink-cli/components/overlays/MarketplaceBrowser.js +297 -0
  112. package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.d.ts.map +1 -1
  113. package/dist/cli/ink-cli/components/overlays/McpRemoveSelector.js +8 -2
  114. package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts +1 -1
  115. package/dist/cli/ink-cli/components/overlays/McpServerActions.d.ts.map +1 -1
  116. package/dist/cli/ink-cli/components/overlays/McpServerActions.js +9 -0
  117. package/dist/cli/ink-cli/components/overlays/McpServerList.d.ts.map +1 -1
  118. package/dist/cli/ink-cli/components/overlays/McpServerList.js +9 -2
  119. package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts +1 -0
  120. package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.d.ts.map +1 -1
  121. package/dist/cli/ink-cli/components/overlays/ModelSelectorRefactored.js +150 -34
  122. package/dist/cli/ink-cli/components/overlays/PluginActions.d.ts +27 -0
  123. package/dist/cli/ink-cli/components/overlays/PluginActions.d.ts.map +1 -0
  124. package/dist/cli/ink-cli/components/overlays/PluginActions.js +66 -0
  125. package/dist/cli/ink-cli/components/overlays/PluginList.d.ts +21 -0
  126. package/dist/cli/ink-cli/components/overlays/PluginList.d.ts.map +1 -0
  127. package/dist/cli/ink-cli/components/overlays/PluginList.js +70 -0
  128. package/dist/cli/ink-cli/components/overlays/PluginManager.d.ts +21 -0
  129. package/dist/cli/ink-cli/components/overlays/PluginManager.d.ts.map +1 -0
  130. package/dist/cli/ink-cli/components/overlays/PluginManager.js +63 -0
  131. package/dist/cli/ink-cli/components/overlays/PromptList.d.ts.map +1 -1
  132. package/dist/cli/ink-cli/components/overlays/PromptList.js +4 -1
  133. package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts +1 -0
  134. package/dist/cli/ink-cli/components/overlays/ToolBrowser.d.ts.map +1 -1
  135. package/dist/cli/ink-cli/components/overlays/ToolBrowser.js +281 -39
  136. package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts +10 -1
  137. package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.d.ts.map +1 -1
  138. package/dist/cli/ink-cli/components/overlays/custom-model-wizard/provider-config.js +87 -2
  139. package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts +4 -2
  140. package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.d.ts.map +1 -1
  141. package/dist/cli/ink-cli/components/renderers/FilePreviewRenderer.js +4 -4
  142. package/dist/cli/ink-cli/containers/InputContainer.d.ts.map +1 -1
  143. package/dist/cli/ink-cli/containers/InputContainer.js +32 -5
  144. package/dist/cli/ink-cli/containers/OverlayContainer.d.ts.map +1 -1
  145. package/dist/cli/ink-cli/containers/OverlayContainer.js +384 -28
  146. package/dist/cli/ink-cli/hooks/index.d.ts +1 -0
  147. package/dist/cli/ink-cli/hooks/index.d.ts.map +1 -1
  148. package/dist/cli/ink-cli/hooks/index.js +1 -0
  149. package/dist/cli/ink-cli/hooks/useAgentEvents.d.ts.map +1 -1
  150. package/dist/cli/ink-cli/hooks/useAgentEvents.js +61 -0
  151. package/dist/cli/ink-cli/hooks/useCLIState.d.ts.map +1 -1
  152. package/dist/cli/ink-cli/hooks/useCLIState.js +5 -0
  153. package/dist/cli/ink-cli/hooks/useGitBranch.d.ts +13 -0
  154. package/dist/cli/ink-cli/hooks/useGitBranch.d.ts.map +1 -0
  155. package/dist/cli/ink-cli/hooks/useGitBranch.js +35 -0
  156. package/dist/cli/ink-cli/hooks/useInputOrchestrator.d.ts.map +1 -1
  157. package/dist/cli/ink-cli/hooks/useInputOrchestrator.js +53 -6
  158. package/dist/cli/ink-cli/services/processStream.d.ts.map +1 -1
  159. package/dist/cli/ink-cli/services/processStream.js +92 -12
  160. package/dist/cli/ink-cli/state/initialState.d.ts.map +1 -1
  161. package/dist/cli/ink-cli/state/initialState.js +5 -0
  162. package/dist/cli/ink-cli/state/types.d.ts +12 -1
  163. package/dist/cli/ink-cli/state/types.d.ts.map +1 -1
  164. package/dist/cli/ink-cli/utils/commandOverlays.d.ts.map +1 -1
  165. package/dist/cli/ink-cli/utils/commandOverlays.js +1 -0
  166. package/dist/cli/ink-cli/utils/llm-provider-display.d.ts +3 -0
  167. package/dist/cli/ink-cli/utils/llm-provider-display.d.ts.map +1 -0
  168. package/dist/cli/ink-cli/utils/llm-provider-display.js +22 -0
  169. package/dist/cli/ink-cli/utils/messageFormatting.d.ts +18 -7
  170. package/dist/cli/ink-cli/utils/messageFormatting.d.ts.map +1 -1
  171. package/dist/cli/ink-cli/utils/messageFormatting.js +143 -15
  172. package/dist/cli/ink-cli/utils/toolUtils.d.ts +11 -0
  173. package/dist/cli/ink-cli/utils/toolUtils.d.ts.map +1 -1
  174. package/dist/cli/ink-cli/utils/toolUtils.js +17 -0
  175. package/dist/cli/mcp/index.d.ts +8 -0
  176. package/dist/cli/mcp/index.d.ts.map +1 -0
  177. package/dist/cli/mcp/index.js +7 -0
  178. package/dist/cli/mcp/oauth-factory.d.ts +6 -0
  179. package/dist/cli/mcp/oauth-factory.d.ts.map +1 -0
  180. package/dist/cli/mcp/oauth-factory.js +25 -0
  181. package/dist/cli/mcp/oauth-provider.d.ts +10 -0
  182. package/dist/cli/mcp/oauth-provider.d.ts.map +1 -0
  183. package/dist/cli/mcp/oauth-provider.js +77 -0
  184. package/dist/cli/mcp/oauth-redirect.d.ts +3 -0
  185. package/dist/cli/mcp/oauth-redirect.d.ts.map +1 -0
  186. package/dist/cli/mcp/oauth-redirect.js +4 -0
  187. package/dist/cli/mcp/oauth-server.d.ts +2 -0
  188. package/dist/cli/mcp/oauth-server.d.ts.map +1 -0
  189. package/dist/cli/mcp/oauth-server.js +70 -0
  190. package/dist/cli/mcp/oauth-store.d.ts +10 -0
  191. package/dist/cli/mcp/oauth-store.d.ts.map +1 -0
  192. package/dist/cli/mcp/oauth-store.js +27 -0
  193. package/dist/cli/mcp/oauth-ui.d.ts +2 -0
  194. package/dist/cli/mcp/oauth-ui.d.ts.map +1 -0
  195. package/dist/cli/mcp/oauth-ui.js +12 -0
  196. package/dist/cli/mcp/oauth-utils.d.ts +2 -0
  197. package/dist/cli/mcp/oauth-utils.d.ts.map +1 -0
  198. package/dist/cli/mcp/oauth-utils.js +17 -0
  199. package/dist/cli/utils/api-key-verification.d.ts.map +1 -1
  200. package/dist/cli/utils/api-key-verification.js +36 -0
  201. package/dist/cli/utils/config-validation.d.ts +3 -1
  202. package/dist/cli/utils/config-validation.d.ts.map +1 -1
  203. package/dist/cli/utils/config-validation.js +42 -19
  204. package/dist/cli/utils/dexto-auth-check.d.ts +53 -0
  205. package/dist/cli/utils/dexto-auth-check.d.ts.map +1 -0
  206. package/dist/cli/utils/dexto-auth-check.js +104 -0
  207. package/dist/cli/utils/dexto-setup.d.ts +8 -0
  208. package/dist/cli/utils/dexto-setup.d.ts.map +1 -0
  209. package/dist/cli/utils/dexto-setup.js +17 -0
  210. package/dist/cli/utils/options.d.ts.map +1 -1
  211. package/dist/cli/utils/options.js +5 -1
  212. package/dist/cli/utils/provider-setup.d.ts +5 -1
  213. package/dist/cli/utils/provider-setup.d.ts.map +1 -1
  214. package/dist/cli/utils/provider-setup.js +29 -1
  215. package/dist/config/cli-overrides.d.ts +17 -8
  216. package/dist/config/cli-overrides.d.ts.map +1 -1
  217. package/dist/config/cli-overrides.js +36 -22
  218. package/dist/config/effective-llm.d.ts +123 -0
  219. package/dist/config/effective-llm.d.ts.map +1 -0
  220. package/dist/config/effective-llm.js +171 -0
  221. package/dist/index.js +404 -99
  222. package/dist/webui/assets/index-C9JXwpvo.css +1 -0
  223. package/dist/webui/assets/{index-DVQWNLpT.js → index-Cz2z7NQ8.js} +218 -218
  224. package/dist/webui/index.html +2 -2
  225. package/package.json +9 -8
  226. 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
- * TODO: Future preference system enhancement
6
- * Currently, global preferences are only applied to the coding-agent at runtime.
7
- * Future improvements could include:
8
- * - Per-agent preference overrides (~/.dexto/agents/{id}/preferences.yml)
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 (global > agent, agent > global, field-specific)
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 for the coding-agent to ensure user's LLM preferences are applied.
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
- // Apply LLM preferences (user preferences override agent defaults)
74
- if (preferences.llm) {
75
- mergedConfig.llm = {
76
- ...mergedConfig.llm,
77
- provider: preferences.llm.provider,
78
- model: preferences.llm.model,
79
- };
80
- // Only override apiKey if user has one configured
81
- if (preferences.llm.apiKey) {
82
- mergedConfig.llm.apiKey = preferences.llm.apiKey;
83
- }
84
- // Only override baseURL if user has one configured
85
- if (preferences.llm.baseURL) {
86
- mergedConfig.llm.baseURL = preferences.llm.baseURL;
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
+ }