Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: share provider settings across CLI and TUI modes
[._.]/ Adam Eivy03f66140c871
diff --git a/client/src/components/providers/ProviderCard.jsx b/client/src/components/providers/ProviderCard.jsxindex 7ea9a45991..223cedf647 100644--- a/client/src/components/providers/ProviderCard.jsx+++ b/client/src/components/providers/ProviderCard.jsx@@ -414,7 +414,7 @@ export default function ProviderCard({)}{unified && (<div className="text-xs text-gray-400 space-y-1">- <p>CLI and TUI share enablement and the model catalog. Edit a mode to configure its arguments and model defaults.</p>+ <p>CLI and TUI share one provider configuration, including the catalog, model defaults, tier pins, effort, fallback, and generation settings. Edit either mode to update it. Arguments, timeouts, TUI timing, and CLI transport consent stay specific to their mode.</p>{modes.filter(mode => mode.id !== provider.id && statuses[mode.id]?.available === false).map(mode => (<p key={mode.id} className="text-port-warning">{mode.type.toUpperCase()} benched: {statuses[mode.id].message || statuses[mode.id].reason}{' '}diff --git a/client/src/components/providers/ProviderForm.jsx b/client/src/components/providers/ProviderForm.jsxindex 184376598c..04e336dcd2 100644--- a/client/src/components/providers/ProviderForm.jsx+++ b/client/src/components/providers/ProviderForm.jsx@@ -648,8 +648,8 @@ export default function ProviderForm({ provider, daemonReadiness = null, onClose<span>This command also runs as a TUI<span className="block text-xs text-gray-500">- Creates the interactive mode alongside this one, sharing the command, endpoint,- credentials and models. Only the arguments differ.+ Creates both modes from these shared provider and model settings. The TUI keeps its+ own arguments and prompt timing.</span></span></label>diff --git a/docs/AI_PROVIDERS.md b/docs/AI_PROVIDERS.mdindex d2c5f169ea..20eff87187 100644--- a/docs/AI_PROVIDERS.md+++ b/docs/AI_PROVIDERS.md@@ -26,6 +26,7 @@ The stored records, **grouped by harness** and ordered within a group by readine- **Add Preset** — the shared compose flow (harness → method → service → optional model, effort, and credential bootstrap), saved through `POST /api/providers/presets`. Choosing it does not contact a provider; the catalog already knows which enabled pairs are compatible. On success the preset editor opens so the preset-owned fields can be set without retyping the service connection.- **Add standalone preset** (overflow menu, and a second control when the list is empty) — the hand-written legacy record, for a backend no definition describes. `/ai/presets/new` is still that form.- The preset editor (`/ai/presets/:presetId`; `/ai/edit/:providerId` is a kept alias) shows a **derived** preset's connection-owned fields — type, command, endpoint, key, inline bootstrap — as *Derived from service …* with a link to the service, because the server re-materializes them from that service on every save and refuses an edit that would move one. Name, arguments, timeouts, model pins, effort and generation settings stay the preset's own. A **legacy** preset is fully hand-editable, as before, and offers *Convert to derived preset* when re-deriving it would change nothing about how it runs.+- A harness with both CLI and TUI modes has one shared provider configuration: catalog, access policy, model and tier pins, effort, fallback, hardware requirements, and generation settings. The mode records remain addressable by their existing ids so saved tasks and peers keep working. When legacy records conflict on a shared setting, the CLI value takes precedence; if CLI is unset, a configured TUI value is retained. Their model catalogs and known context windows are merged. Arguments, headless-only arguments, timeouts, TUI timing, and CLI transport consent remain mode-specific because they control how each mode launches.- **Tiers** (Light / Medium / Heavy / Ultra, [MODEL_TIERS.md](./MODEL_TIERS.md)) are pins on a preset, so a `model: "heavy"` selection resolves on whichever preset the task names.### Harnesses (`/ai/harnesses`)diff --git a/server/lib/aiToolkit/internal/providerModes.js b/server/lib/aiToolkit/internal/providerModes.jsindex 1641b69626..c5a7903c66 100644--- a/server/lib/aiToolkit/internal/providerModes.js+++ b/server/lib/aiToolkit/internal/providerModes.js@@ -23,6 +23,34 @@ const MODE_KEY_DEFAULTS = { endpoint: '', apiKey: '', envVars: {}, credentialBoo*/export const MODE_GROUPED_KEYS = Object.freeze(Object.keys(MODE_KEY_DEFAULTS));+/**+ * Provider settings shared by the CLI and TUI modes of a harness. The records+ * stay separate because saved selections name an execution mode, but a pair+ * must not carry conflicting model and generation policy.+ */+export const MODE_SHARED_SETTINGS_KEYS = Object.freeze([+ 'modelAccess',+ 'defaultModel',+ 'lightModel',+ 'mediumModel',+ 'heavyModel',+ 'ultraModel',+ 'effort',+ 'fallbackProvider',+ 'fallbackModel',+ 'catalogNarrowing',+ 'hardwareRequirements',+ 'modelHardwareRequirements',+ 'secretEnvVars',+ 'ignoreUserConfig',+ 'numCtx',+ 'temperature',+ 'topP',+ 'thinking',+ 'contextWindow',+ 'textTransport',+]);+/** True when a record NAMES a connection-identity value rather than leaving it at the empty default. */function namesModeValue(provider, key) {if (key === 'credentialBootstrap') return hasCredentialBootstrap(provider);@@ -34,6 +62,12 @@ function namesModeValue(provider, key) {/** A fanned-out value must not ALIAS one object across two stored records. */const detachModeValue = value => (value && typeof value === 'object' ? structuredClone(value) : value);+const hasConfiguredModeValue = (value) => {+ if (value === undefined || value === null || value === '') return false;+ if (Array.isArray(value)) return value.length > 0;+ if (typeof value === 'object') return Object.keys(value).length > 0;+ return true;+};/*** Fields belonging to the CLI mode ALONE, which must not ride the shared body@@ -76,8 +110,8 @@ export function providerModeGroups(providers) {return [...groups, ...providers.filter(provider => !paired.has(provider.id)).map(provider => [provider])];}-export function sharedModeUpdates(updates, sibling) {- // Arguments, timeouts, routing consent and model pins remain mode-specific.+export function sharedModeUpdates(updates) {+ // Arguments, timeouts, routing consent and TUI timing remain mode-specific.//// Every `MODE_GROUPED_KEYS` field is shared for the reason the pairing// test above keys on it: endpoint, API key, env vars and bootstrap describe@@ -87,21 +121,12 @@ export function sharedModeUpdates(updates, sibling) {// line and env from — pointed at the old backend with the old credential,// and splits the one card in two on the next load. `unifyProviderModes`// converges a pair that arrived asymmetric by some other route.- // `modelAccess` rides with `models` rather than with the argv: a pair is one- // program on one backend, so the entitlement that scopes that backend's- // catalog cannot differ between the headless and interactive mode without the- // two cards offering different models for the same account. It stays OUT of- // MODE_GROUPED_KEYS, though — it is not connection identity, and pairing on it- // would split a card the moment one mode was edited first.- const shared = Object.fromEntries(['enabled', 'models', 'modelContextWindows', 'modelAccess', ...MODE_GROUPED_KEYS]+ // A paired harness has one provider configuration as well as one connection.+ // Mirror shared settings from whichever mode the user edited; clone their+ // objects so legacy CLI/TUI records don't alias mutable values in memory.+ const shared = Object.fromEntries(['enabled', 'models', 'modelContextWindows', ...MODE_SHARED_SETTINGS_KEYS, ...MODE_GROUPED_KEYS].filter(key => Object.hasOwn(updates, key)).map(key => [key, detachModeValue(updates[key])]));- // A caller deliberately repicking a default with a new catalog (the editor- // or harness discovery) must repair a removed sibling default too. Ordinary- // catalog probes omit defaultModel and retain their existing pin semantics.- if (Array.isArray(updates.models) && Object.hasOwn(updates, 'defaultModel') && sibling?.defaultModel && !updates.models.includes(sibling.defaultModel)) {- shared.defaultModel = updates.models[0] ?? null;- }return shared;}@@ -161,6 +186,47 @@ export function unifyProviderModes(data) {let changed = fillModeSiblingIdentity(providers);for (const group of providerModeGroups(providers)) {if (group.length < 2) continue;+ // The CLI is the long-standing representative of a paired card. When an+ // older install has different shared settings on the two mode records, use+ // its values when present. If the CLI has no value, retain a configured+ // TUI value rather than clearing it during the compatibility reconcile.+ const canonical = group.find(provider => provider.type === 'cli') || group[0];+ for (const key of MODE_SHARED_SETTINGS_KEYS) {+ const source = hasConfiguredModeValue(canonical[key])+ ? canonical+ : group.find(provider => provider.id !== canonical.id && hasConfiguredModeValue(provider[key]));+ for (const provider of group) {+ const value = source?.[key];+ if (isDeepStrictEqual(provider[key], value)) continue;+ if (value === undefined) delete provider[key];+ else provider[key] = detachModeValue(value);+ changed = true;+ }+ }+ // Context-window observations are catalog metadata. Merge them so the+ // compatibility reconcile keeps facts learned from either old mode, then+ // mirror the same detached map to both records.+ const hasContextWindows = group.some(provider =>+ provider.modelContextWindows && Object.keys(provider.modelContextWindows).length > 0);+ if (hasContextWindows) {+ const modelContextWindows = Object.assign(+ {},+ ...group.filter(mode => mode.id !== canonical.id).map(mode => mode.modelContextWindows || {}),+ canonical.modelContextWindows || {},+ );+ for (const provider of group) {+ if (isDeepStrictEqual(provider.modelContextWindows, modelContextWindows)) continue;+ provider.modelContextWindows = { ...modelContextWindows };+ changed = true;+ }+ } else {+ for (const provider of group) {+ if (Object.hasOwn(provider, 'modelContextWindows')) {+ delete provider.modelContextWindows;+ changed = true;+ }+ }+ }const enabled = group.some(provider => provider.enabled === true);const models = [...new Set(group.flatMap(provider => provider.models || []))];for (const provider of group) {diff --git a/server/lib/aiToolkit/providers.js b/server/lib/aiToolkit/providers.jsindex c9caacc947..61c99e15f6 100644--- a/server/lib/aiToolkit/providers.js+++ b/server/lib/aiToolkit/providers.js@@ -981,7 +981,7 @@ export function createProviderService(config = {}) {data.providers[id] = provider;for (const sibling of group || []) {if (sibling.id === id) continue;- Object.assign(sibling, sharedModeUpdates(updates, sibling));+ Object.assign(sibling, sharedModeUpdates(updates));normalizeClearedFields(sibling);}await saveProviders(data);diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.jsindex 3bec3c1760..96461d9af9 100644--- a/server/lib/aiToolkit/providers.test.js+++ b/server/lib/aiToolkit/providers.test.js@@ -23,18 +23,100 @@ describe('Provider Service', () => {if (TEST_DATA_DIR) await rm(TEST_DATA_DIR, { recursive: true, force: true });});- it('shares mode enablement and models while preserving mode-specific arguments, defaults and IDs', async () => {+ it('shares provider settings across modes while preserving mode-specific launch settings and IDs', async () => {await writeFile(join(TEST_DATA_DIR, 'providers.json'), JSON.stringify({ activeProvider: 'example-tui', providers: {- example: { id: 'example', name: 'Example CLI', type: 'cli', command: 'example', enabled: false, models: ['a'], args: ['--print'], defaultModel: 'a' },- 'example-tui': { id: 'example-tui', name: 'Example TUI', type: 'tui', command: 'example', enabled: true, models: ['b'], args: [], defaultModel: 'b' },+ example: {+ id: 'example', name: 'Example CLI', type: 'cli', command: 'example', enabled: false,+ models: ['a'], args: ['--print'], defaultModel: 'a', lightModel: 'cli-light',+ effort: 'high', fallbackProvider: 'remote', fallbackModel: 'fallback-a',+ temperature: 0.5, contextWindow: 64000,+ modelContextWindows: { a: 1024 },+ },+ 'example-tui': {+ id: 'example-tui', name: 'Example TUI', type: 'tui', command: 'example', enabled: true,+ models: ['b'], args: [], defaultModel: 'b', lightModel: 'tui-light', mediumModel: 'tui-medium',+ effort: 'low', fallbackProvider: 'tui-fallback', fallbackModel: 'fallback-b',+ temperature: 0.2, contextWindow: 32000,+ timeout: 600000, modelContextWindows: { b: 2048 },+ },remote: { id: 'remote', type: 'api', enabled: false, models: ['remote'] },} }));expect((await providerService.getProviderById('example')).enabled).toBe(true);+ // Existing pairs with two model configurations converge to the CLI's+ // settings. Runtime launch settings remain attached to their own mode.+ expect(await providerService.getProviderById('example')).toMatchObject({+ models: ['a', 'b'], mediumModel: 'tui-medium', modelContextWindows: { a: 1024, b: 2048 },+ });+ expect(await providerService.getProviderById('example-tui')).toMatchObject({+ models: ['a', 'b'],+ defaultModel: 'a',+ lightModel: 'cli-light',+ mediumModel: 'tui-medium',+ effort: 'high',+ fallbackProvider: 'remote',+ fallbackModel: 'fallback-a',+ temperature: 0.5, contextWindow: 64000,+ modelContextWindows: { a: 1024, b: 2048 },+ args: [], timeout: 600000,+ });expect((await providerService.getActiveProvider()).id).toBe('example-tui');- await providerService.updateProvider('example-tui', { enabled: false, models: ['c'], args: ['--interactive'], defaultModel: 'c' });- expect(await providerService.getProviderById('example')).toMatchObject({ enabled: false, models: ['c'], args: ['--print'], defaultModel: 'c' });+ await providerService.updateProvider('example-tui', {+ enabled: false,+ models: ['first', 'c'],+ args: ['--interactive'],+ defaultModel: 'c',+ lightModel: 'shared-light',+ mediumModel: 'shared-medium',+ effort: 'low',+ fallbackProvider: 'shared-fallback',+ fallbackModel: 'fallback-c',+ secretEnvVars: ['EXAMPLE_TOKEN'],+ ignoreUserConfig: true,+ temperature: 0.7,+ contextWindow: 32768,+ });+ expect(await providerService.getProviderById('example')).toMatchObject({+ enabled: false,+ models: ['first', 'c'],+ args: ['--print'],+ defaultModel: 'c',+ lightModel: 'shared-light',+ mediumModel: 'shared-medium',+ effort: 'low',+ fallbackProvider: 'shared-fallback',+ fallbackModel: 'fallback-c',+ secretEnvVars: ['EXAMPLE_TOKEN'],+ ignoreUserConfig: true,+ temperature: 0.7,+ contextWindow: 32768,+ });+ expect(await providerService.getProviderById('example-tui')).toMatchObject({+ enabled: false,+ models: ['first', 'c'],+ args: ['--interactive'],+ defaultModel: 'c',+ lightModel: 'shared-light',+ mediumModel: 'shared-medium',+ effort: 'low',+ fallbackProvider: 'shared-fallback',+ fallbackModel: 'fallback-c',+ secretEnvVars: ['EXAMPLE_TOKEN'],+ ignoreUserConfig: true,+ temperature: 0.7,+ contextWindow: 32768,+ timeout: 600000,+ });expect(await providerService.getProviderById('remote')).toMatchObject({ enabled: false, models: ['remote'] });- const catalog = vi.spyOn(providerService, 'fetchProviderModelCatalog').mockResolvedValue({ models: ['fresh'], contextWindows: { fresh: 8192 } });+ const catalog = vi.spyOn(providerService, 'fetchProviderModelCatalog').mockResolvedValue({+ models: ['fresh'], contextWindows: { fresh: 8192 },+ });+ // The preset-card path is a single-provider refresh; its catalog and+ // context-window update are applied to both stored modes in one update.+ await providerService.refreshProviderModels('example-tui');+ expect((await providerService.getProviderById('example')).models).toEqual(['fresh']);+ expect((await providerService.getProviderById('example-tui')).models).toEqual(['fresh']);+ expect((await providerService.getProviderById('example')).modelContextWindows).toEqual({ fresh: 8192 });+ expect((await providerService.getProviderById('example-tui')).modelContextWindows).toEqual({ fresh: 8192 });await providerService.refreshProviderModelsBatch(['example-tui']);expect((await providerService.getProviderById('example')).models).toEqual(['fresh']);expect((await providerService.getProviderById('example-tui')).models).toEqual(['fresh']);