@causyne/agent 1.20.124 → 1.20.127
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/bin/causyne.js +1 -1
- package/package.json +4 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +83 -27
- package/src/agentLoop.ts +92 -26
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +30 -3
- package/src/browser/causyneBrowser.ts +33 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +188 -32
- package/src/commands.ts +209 -32
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/providers/antigravity.js +62 -9
- package/src/providers/antigravity.ts +73 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1096 -0
- package/src/tools/ptyTerminal.ts +1231 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +702 -0
- package/src/web/client/browserPanel.ts +663 -0
- package/src/web/client/chatStream.js +309 -0
- package/src/web/client/chatStream.ts +289 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +220 -0
- package/src/web/client/dom.ts +221 -0
- package/src/web/client/filesAndCanvas.js +231 -0
- package/src/web/client/filesAndCanvas.ts +238 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +301 -0
- package/src/web/client/main.ts +368 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +191 -0
- package/src/web/client/settingsModal.ts +176 -0
- package/src/web/client/state.js +250 -0
- package/src/web/client/state.ts +233 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +54 -0
- package/src/web/client/studioLayout.ts +60 -0
- package/src/web/client/studioShell.js +327 -0
- package/src/web/client/studioShell.ts +340 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +357 -0
- package/src/web/client/terminalPanel.ts +345 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +319 -0
- package/src/web/client/validators.js +106 -0
- package/src/web/client/validators.ts +96 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +355 -0
- package/src/web/server/routesBrowser.ts +386 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +80 -0
- package/src/web/server/staticAssets.ts +91 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +76 -2449
- package/src/web/skybridgeServer.ts +118 -2600
- package/src/web/skybridgeUi.js +16 -450
- package/src/web/skybridgeUi.ts +16 -454
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +436 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +723 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +139 -0
- package/src/web/ui/modalsTemplate.ts +139 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +258 -0
- package/src/web/ui/studioTemplate.ts +258 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- package/src/web/skybridgeStyles.ts +0 -828
package/src/tui/modelPicker.js
CHANGED
|
@@ -6,6 +6,7 @@ import { SelectLayer, InputLayer } from './dialogs.js';
|
|
|
6
6
|
import { paint, bold, dim, GLYPHS } from './theme.js';
|
|
7
7
|
import { fuzzyFilter } from './selectList.js';
|
|
8
8
|
import { loadConfig, saveConfig } from '../config.js';
|
|
9
|
+
import { reconcileConfigVariant } from '../modelVariants.js';
|
|
9
10
|
import { startLoopbackAuth, saveOpenRouterKey, disconnectOpenRouter } from '../auth/openrouterAuth.js';
|
|
10
11
|
import { setTransientNotice } from './consoleGuard.js';
|
|
11
12
|
import { truncate } from './text.js';
|
|
@@ -457,12 +458,13 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
457
458
|
}).catch(() => { });
|
|
458
459
|
}
|
|
459
460
|
});
|
|
460
|
-
const notifyPrompt = (providerId, modelId) => {
|
|
461
|
+
const notifyPrompt = (providerId, modelId, variant = '') => {
|
|
461
462
|
if (typeof prompt.updateModel === 'function') {
|
|
462
|
-
prompt.updateModel(providerId, modelId);
|
|
463
|
+
prompt.updateModel(providerId, modelId, variant);
|
|
463
464
|
}
|
|
464
465
|
else if (prompt.renderer?.status) {
|
|
465
|
-
prompt.renderer.status.setSession({ provider: providerId, model: modelId });
|
|
466
|
+
prompt.renderer.status.setSession({ provider: providerId, model: modelId, variant });
|
|
467
|
+
prompt.surface?.setSessionInfo?.({ provider: providerId, model: modelId, variant });
|
|
466
468
|
if (typeof prompt.scheduleDraw === 'function')
|
|
467
469
|
prompt.scheduleDraw();
|
|
468
470
|
}
|
|
@@ -482,6 +484,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
482
484
|
config['model'] = target.modelId;
|
|
483
485
|
config['apiKey'] = '';
|
|
484
486
|
delete config['baseUrl'];
|
|
487
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
485
488
|
store.saveConfig(config);
|
|
486
489
|
if (options.loop) {
|
|
487
490
|
options.loop.config = config;
|
|
@@ -489,19 +492,21 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
489
492
|
options.loop.updateTierLimits();
|
|
490
493
|
}
|
|
491
494
|
}
|
|
492
|
-
notifyPrompt(target.providerId, target.modelId);
|
|
495
|
+
notifyPrompt(target.providerId, target.modelId, nextVariant);
|
|
493
496
|
return `Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
494
497
|
}
|
|
495
498
|
// Case 2: Disconnect / Unlink action (e.g. Disconnect OpenRouter)
|
|
496
499
|
if (target.action === 'disconnect' || target.modelId === 'disconnect') {
|
|
497
500
|
const updatedConfig = disconnectOpenRouter(store);
|
|
501
|
+
const nextVariant = reconcileConfigVariant(updatedConfig);
|
|
502
|
+
store.saveConfig(updatedConfig);
|
|
498
503
|
if (options.loop) {
|
|
499
504
|
options.loop.config = updatedConfig;
|
|
500
505
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
501
506
|
options.loop.updateTierLimits();
|
|
502
507
|
}
|
|
503
508
|
}
|
|
504
|
-
notifyPrompt(updatedConfig.provider || 'antigravity', updatedConfig.model || 'Gemini 3.8 Flash (Low)');
|
|
509
|
+
notifyPrompt(updatedConfig.provider || 'antigravity', updatedConfig.model || 'Gemini 3.8 Flash (Low)', nextVariant);
|
|
505
510
|
return (`✓ Disconnected OpenRouter. Account and API credentials have been unlinked from Causyne Agent.\n` +
|
|
506
511
|
`Active model reverted to ${updatedConfig.provider || 'antigravity'} / ${updatedConfig.model || 'Gemini 3.8 Flash (Low)'}.`);
|
|
507
512
|
}
|
|
@@ -524,6 +529,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
524
529
|
config['apiKey'] = existingKey;
|
|
525
530
|
config['providerKeys'] = providerKeys;
|
|
526
531
|
config['providerKeys']['openrouter'] = existingKey;
|
|
532
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
527
533
|
store.saveConfig(config);
|
|
528
534
|
void resolveAvailableModels('openrouter', { ...config, apiKey: existingKey }, true).catch(() => { });
|
|
529
535
|
if (options.loop) {
|
|
@@ -532,7 +538,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
532
538
|
options.loop.updateTierLimits();
|
|
533
539
|
}
|
|
534
540
|
}
|
|
535
|
-
notifyPrompt('openrouter', target.modelId);
|
|
541
|
+
notifyPrompt('openrouter', target.modelId, nextVariant);
|
|
536
542
|
return `Now using OpenRouter Free / ${target.modelId}.`;
|
|
537
543
|
}
|
|
538
544
|
// Unconfigured OpenRouter: prompt where pressing Enter once immediately starts OAuth redirect
|
|
@@ -563,15 +569,16 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
563
569
|
const updatedConfig = store.loadConfig();
|
|
564
570
|
if (target.modelId && updatedConfig.model !== target.modelId) {
|
|
565
571
|
updatedConfig.model = target.modelId;
|
|
566
|
-
store.saveConfig(updatedConfig);
|
|
567
572
|
}
|
|
573
|
+
const nextVariant = reconcileConfigVariant(updatedConfig);
|
|
574
|
+
store.saveConfig(updatedConfig);
|
|
568
575
|
if (options.loop) {
|
|
569
576
|
options.loop.config = updatedConfig;
|
|
570
577
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
571
578
|
options.loop.updateTierLimits();
|
|
572
579
|
}
|
|
573
580
|
}
|
|
574
|
-
notifyPrompt('openrouter', target.modelId);
|
|
581
|
+
notifyPrompt('openrouter', target.modelId, nextVariant);
|
|
575
582
|
setTransientNotice(prompt, `✓ Connected to OpenRouter successfully! Using OpenRouter Free / ${target.modelId}.`, 5000);
|
|
576
583
|
if (prompt.surface?.stage) {
|
|
577
584
|
prompt.surface.stage.invalidate();
|
|
@@ -597,15 +604,16 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
597
604
|
const updatedConfig = store.loadConfig();
|
|
598
605
|
if (target.modelId && updatedConfig.model !== target.modelId) {
|
|
599
606
|
updatedConfig.model = target.modelId;
|
|
600
|
-
store.saveConfig(updatedConfig);
|
|
601
607
|
}
|
|
608
|
+
const nextVariant = reconcileConfigVariant(updatedConfig);
|
|
609
|
+
store.saveConfig(updatedConfig);
|
|
602
610
|
if (options.loop) {
|
|
603
611
|
options.loop.config = updatedConfig;
|
|
604
612
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
605
613
|
options.loop.updateTierLimits();
|
|
606
614
|
}
|
|
607
615
|
}
|
|
608
|
-
notifyPrompt('openrouter', target.modelId);
|
|
616
|
+
notifyPrompt('openrouter', target.modelId, nextVariant);
|
|
609
617
|
return `✓ Saved API key. Now using OpenRouter Free / ${target.modelId}.`;
|
|
610
618
|
}
|
|
611
619
|
// Case 3: BYOK Provider (Cloud or Local API)
|
|
@@ -629,6 +637,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
629
637
|
config['providerKeys'] = providerKeys;
|
|
630
638
|
config['providerKeys'][target.providerId] = existingKey;
|
|
631
639
|
}
|
|
640
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
632
641
|
store.saveConfig(config);
|
|
633
642
|
// Proactively refresh live models in the background for this active provider
|
|
634
643
|
if (existingKey || target.providerId === 'ollama') {
|
|
@@ -640,7 +649,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
640
649
|
options.loop.updateTierLimits();
|
|
641
650
|
}
|
|
642
651
|
}
|
|
643
|
-
notifyPrompt(target.providerId, target.modelId);
|
|
652
|
+
notifyPrompt(target.providerId, target.modelId, nextVariant);
|
|
644
653
|
return `Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
645
654
|
}
|
|
646
655
|
// Key is required: open modal input dialog (InputLayer)
|
|
@@ -668,6 +677,7 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
668
677
|
config['apiKey'] = cleanKey;
|
|
669
678
|
config['providerKeys'] = providerKeys;
|
|
670
679
|
config['providerKeys'][target.providerId] = cleanKey;
|
|
680
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
671
681
|
store.saveConfig(config);
|
|
672
682
|
// Proactively refresh live models in the background with the newly saved key
|
|
673
683
|
void resolveAvailableModels(target.providerId, { ...config, apiKey: cleanKey }, true).catch(() => { });
|
|
@@ -677,6 +687,6 @@ export async function runInteractiveModelPicker(prompt, store = { loadConfig, sa
|
|
|
677
687
|
options.loop.updateTierLimits();
|
|
678
688
|
}
|
|
679
689
|
}
|
|
680
|
-
notifyPrompt(target.providerId, target.modelId);
|
|
690
|
+
notifyPrompt(target.providerId, target.modelId, nextVariant);
|
|
681
691
|
return `Saved API key. Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
682
692
|
}
|
package/src/tui/modelPicker.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { SelectLayer, InputLayer } from './dialogs.js';
|
|
|
7
7
|
import { paint, bold, dim, GLYPHS } from './theme.js';
|
|
8
8
|
import { fuzzyFilter } from './selectList.js';
|
|
9
9
|
import { loadConfig, saveConfig } from '../config.js';
|
|
10
|
+
import { reconcileConfigVariant } from '../modelVariants.js';
|
|
10
11
|
import { startLoopbackAuth, saveOpenRouterKey, disconnectOpenRouter } from '../auth/openrouterAuth.js';
|
|
11
12
|
import { setTransientNotice } from './consoleGuard.js';
|
|
12
13
|
import { truncate } from './text.js';
|
|
@@ -558,11 +559,12 @@ export async function runInteractiveModelPicker(
|
|
|
558
559
|
}
|
|
559
560
|
});
|
|
560
561
|
|
|
561
|
-
const notifyPrompt = (providerId: string, modelId: string) => {
|
|
562
|
+
const notifyPrompt = (providerId: string, modelId: string, variant = '') => {
|
|
562
563
|
if (typeof (prompt as any).updateModel === 'function') {
|
|
563
|
-
(prompt as any).updateModel(providerId, modelId);
|
|
564
|
+
(prompt as any).updateModel(providerId, modelId, variant);
|
|
564
565
|
} else if ((prompt as any).renderer?.status) {
|
|
565
|
-
(prompt as any).renderer.status.setSession({ provider: providerId, model: modelId });
|
|
566
|
+
(prompt as any).renderer.status.setSession({ provider: providerId, model: modelId, variant });
|
|
567
|
+
(prompt as any).surface?.setSessionInfo?.({ provider: providerId, model: modelId, variant });
|
|
566
568
|
if (typeof (prompt as any).scheduleDraw === 'function') (prompt as any).scheduleDraw();
|
|
567
569
|
}
|
|
568
570
|
};
|
|
@@ -587,6 +589,7 @@ export async function runInteractiveModelPicker(
|
|
|
587
589
|
config['model'] = target.modelId;
|
|
588
590
|
config['apiKey'] = '';
|
|
589
591
|
delete config['baseUrl'];
|
|
592
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
590
593
|
store.saveConfig(config);
|
|
591
594
|
|
|
592
595
|
if (options.loop) {
|
|
@@ -595,20 +598,22 @@ export async function runInteractiveModelPicker(
|
|
|
595
598
|
options.loop.updateTierLimits();
|
|
596
599
|
}
|
|
597
600
|
}
|
|
598
|
-
notifyPrompt(target.providerId, target.modelId);
|
|
601
|
+
notifyPrompt(target.providerId, target.modelId, nextVariant);
|
|
599
602
|
return `Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
600
603
|
}
|
|
601
604
|
|
|
602
605
|
// Case 2: Disconnect / Unlink action (e.g. Disconnect OpenRouter)
|
|
603
606
|
if (target.action === 'disconnect' || target.modelId === 'disconnect') {
|
|
604
607
|
const updatedConfig = disconnectOpenRouter(store);
|
|
608
|
+
const nextVariant = reconcileConfigVariant(updatedConfig);
|
|
609
|
+
store.saveConfig(updatedConfig);
|
|
605
610
|
if (options.loop) {
|
|
606
611
|
options.loop.config = updatedConfig;
|
|
607
612
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
608
613
|
options.loop.updateTierLimits();
|
|
609
614
|
}
|
|
610
615
|
}
|
|
611
|
-
notifyPrompt(updatedConfig.provider || 'antigravity', updatedConfig.model || 'Gemini 3.8 Flash (Low)');
|
|
616
|
+
notifyPrompt(updatedConfig.provider || 'antigravity', updatedConfig.model || 'Gemini 3.8 Flash (Low)', nextVariant);
|
|
612
617
|
return (
|
|
613
618
|
`✓ Disconnected OpenRouter. Account and API credentials have been unlinked from Causyne Agent.\n` +
|
|
614
619
|
`Active model reverted to ${updatedConfig.provider || 'antigravity'} / ${updatedConfig.model || 'Gemini 3.8 Flash (Low)'}.`
|
|
@@ -634,6 +639,7 @@ export async function runInteractiveModelPicker(
|
|
|
634
639
|
config['apiKey'] = existingKey;
|
|
635
640
|
config['providerKeys'] = providerKeys;
|
|
636
641
|
config['providerKeys']['openrouter'] = existingKey;
|
|
642
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
637
643
|
store.saveConfig(config);
|
|
638
644
|
|
|
639
645
|
void resolveAvailableModels('openrouter', { ...config, apiKey: existingKey }, true).catch(() => {});
|
|
@@ -644,7 +650,7 @@ export async function runInteractiveModelPicker(
|
|
|
644
650
|
options.loop.updateTierLimits();
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
|
-
notifyPrompt('openrouter', target.modelId);
|
|
653
|
+
notifyPrompt('openrouter', target.modelId, nextVariant);
|
|
648
654
|
return `Now using OpenRouter Free / ${target.modelId}.`;
|
|
649
655
|
}
|
|
650
656
|
|
|
@@ -679,15 +685,16 @@ export async function runInteractiveModelPicker(
|
|
|
679
685
|
const updatedConfig = store.loadConfig();
|
|
680
686
|
if (target.modelId && updatedConfig.model !== target.modelId) {
|
|
681
687
|
updatedConfig.model = target.modelId;
|
|
682
|
-
store.saveConfig(updatedConfig);
|
|
683
688
|
}
|
|
689
|
+
const nextVariant = reconcileConfigVariant(updatedConfig);
|
|
690
|
+
store.saveConfig(updatedConfig);
|
|
684
691
|
if (options.loop) {
|
|
685
692
|
options.loop.config = updatedConfig;
|
|
686
693
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
687
694
|
options.loop.updateTierLimits();
|
|
688
695
|
}
|
|
689
696
|
}
|
|
690
|
-
notifyPrompt('openrouter', target.modelId);
|
|
697
|
+
notifyPrompt('openrouter', target.modelId, nextVariant);
|
|
691
698
|
setTransientNotice(prompt as any, `✓ Connected to OpenRouter successfully! Using OpenRouter Free / ${target.modelId}.`, 5000);
|
|
692
699
|
if ((prompt as any).surface?.stage) {
|
|
693
700
|
(prompt as any).surface.stage.invalidate();
|
|
@@ -715,15 +722,16 @@ export async function runInteractiveModelPicker(
|
|
|
715
722
|
const updatedConfig = store.loadConfig();
|
|
716
723
|
if (target.modelId && updatedConfig.model !== target.modelId) {
|
|
717
724
|
updatedConfig.model = target.modelId;
|
|
718
|
-
store.saveConfig(updatedConfig);
|
|
719
725
|
}
|
|
726
|
+
const nextVariant = reconcileConfigVariant(updatedConfig);
|
|
727
|
+
store.saveConfig(updatedConfig);
|
|
720
728
|
if (options.loop) {
|
|
721
729
|
options.loop.config = updatedConfig;
|
|
722
730
|
if (typeof options.loop.updateTierLimits === 'function') {
|
|
723
731
|
options.loop.updateTierLimits();
|
|
724
732
|
}
|
|
725
733
|
}
|
|
726
|
-
notifyPrompt('openrouter', target.modelId);
|
|
734
|
+
notifyPrompt('openrouter', target.modelId, nextVariant);
|
|
727
735
|
return `✓ Saved API key. Now using OpenRouter Free / ${target.modelId}.`;
|
|
728
736
|
}
|
|
729
737
|
|
|
@@ -747,6 +755,7 @@ export async function runInteractiveModelPicker(
|
|
|
747
755
|
config['providerKeys'] = providerKeys;
|
|
748
756
|
config['providerKeys'][target.providerId] = existingKey;
|
|
749
757
|
}
|
|
758
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
750
759
|
store.saveConfig(config);
|
|
751
760
|
|
|
752
761
|
// Proactively refresh live models in the background for this active provider
|
|
@@ -760,7 +769,7 @@ export async function runInteractiveModelPicker(
|
|
|
760
769
|
options.loop.updateTierLimits();
|
|
761
770
|
}
|
|
762
771
|
}
|
|
763
|
-
notifyPrompt(target.providerId, target.modelId);
|
|
772
|
+
notifyPrompt(target.providerId, target.modelId, nextVariant);
|
|
764
773
|
return `Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
765
774
|
}
|
|
766
775
|
|
|
@@ -792,6 +801,7 @@ export async function runInteractiveModelPicker(
|
|
|
792
801
|
config['apiKey'] = cleanKey;
|
|
793
802
|
config['providerKeys'] = providerKeys;
|
|
794
803
|
config['providerKeys'][target.providerId] = cleanKey;
|
|
804
|
+
const nextVariant = reconcileConfigVariant(config);
|
|
795
805
|
store.saveConfig(config);
|
|
796
806
|
|
|
797
807
|
// Proactively refresh live models in the background with the newly saved key
|
|
@@ -804,6 +814,6 @@ export async function runInteractiveModelPicker(
|
|
|
804
814
|
}
|
|
805
815
|
}
|
|
806
816
|
|
|
807
|
-
notifyPrompt(target.providerId, target.modelId);
|
|
817
|
+
notifyPrompt(target.providerId, target.modelId, nextVariant);
|
|
808
818
|
return `Saved API key. Now using ${target.providerLabel} / ${target.modelId}.`;
|
|
809
819
|
}
|
package/src/tui/overlay.js
CHANGED
|
@@ -239,11 +239,8 @@ export class OverlayStack {
|
|
|
239
239
|
/**
|
|
240
240
|
* A layer as framed rows, for a normal-buffer live region.
|
|
241
241
|
*
|
|
242
|
-
* drawPanel() paints
|
|
243
|
-
*
|
|
244
|
-
* same panel expressed as styled `string[]`, which is all a live region can
|
|
245
|
-
* append. It is the shape openclaw draws its pickers in: extra lines in the
|
|
246
|
-
* composed frame, not a floating window.
|
|
242
|
+
* drawPanel() paints into a cell grid, while live-region rendering expresses
|
|
243
|
+
* the same panel as styled `string[]` rows inside the composed frame.
|
|
247
244
|
*
|
|
248
245
|
* Every row is wrapped with `fill('surface', ...)` so that when a panel (such as
|
|
249
246
|
* Message Actions) is overlaid onto the transcript viewport, its interior has an
|
package/src/tui/overlay.ts
CHANGED
|
@@ -301,11 +301,8 @@ export class OverlayStack {
|
|
|
301
301
|
/**
|
|
302
302
|
* A layer as framed rows, for a normal-buffer live region.
|
|
303
303
|
*
|
|
304
|
-
* drawPanel() paints
|
|
305
|
-
*
|
|
306
|
-
* same panel expressed as styled `string[]`, which is all a live region can
|
|
307
|
-
* append. It is the shape openclaw draws its pickers in: extra lines in the
|
|
308
|
-
* composed frame, not a floating window.
|
|
304
|
+
* drawPanel() paints into a cell grid, while live-region rendering expresses
|
|
305
|
+
* the same panel as styled `string[]` rows inside the composed frame.
|
|
309
306
|
*
|
|
310
307
|
* Every row is wrapped with `fill('surface', ...)` so that when a panel (such as
|
|
311
308
|
* Message Actions) is overlaid onto the transcript viewport, its interior has an
|
package/src/tui/prompt.js
CHANGED
|
@@ -30,6 +30,7 @@ import { pickExample, fitHints } from './banner.js';
|
|
|
30
30
|
import { panelRows } from './overlay.js';
|
|
31
31
|
import { renderUsageCardRows, renderStatusCardRows, collectUsageCardData } from './usageCard.js';
|
|
32
32
|
import { buildStatusText } from '../reporting.js';
|
|
33
|
+
import { formatPermissionPresetLabel } from '../permissionPresets.js';
|
|
33
34
|
import { commandPalette, skillPicker, ApprovalLayer, DecisionLayer, ConfirmLayer, HomeLayer, TextLayer } from './dialogs.js';
|
|
34
35
|
import { describeTool } from './toolDisplay.js';
|
|
35
36
|
import { writeClipboardSync } from './clipboardSync.js';
|
|
@@ -131,7 +132,7 @@ export class ChatPrompt {
|
|
|
131
132
|
this.onOpenVariant = opts.onOpenVariant || null;
|
|
132
133
|
this.onOpenVariantList = opts.onOpenVariantList || null;
|
|
133
134
|
this.messageActionLoop = opts.messageActionLoop || null;
|
|
134
|
-
this.getMode = opts.getMode || (() => '
|
|
135
|
+
this.getMode = opts.getMode || (() => 'workspace-write');
|
|
135
136
|
this.editor = new LineEditor();
|
|
136
137
|
this.history = opts.history || new PromptHistory();
|
|
137
138
|
this.index = new FileIndex(this.root);
|
|
@@ -434,7 +435,8 @@ export class ChatPrompt {
|
|
|
434
435
|
const status = this.renderer && this.renderer.status;
|
|
435
436
|
if (!status)
|
|
436
437
|
return null;
|
|
437
|
-
const
|
|
438
|
+
const presetLabel = formatPermissionPresetLabel(this.getMode());
|
|
439
|
+
const mode = this.busy ? `Working · ${presetLabel}` : presetLabel;
|
|
438
440
|
const parts = [bold(paint('accent', mode))];
|
|
439
441
|
if (status.model)
|
|
440
442
|
parts.push(bold(paint('ink', status.model)));
|
|
@@ -450,7 +452,7 @@ export class ChatPrompt {
|
|
|
450
452
|
details.push(`${this.editor.lines.length} lines`);
|
|
451
453
|
const extra = details.length ? dim(` ${GLYPHS.dot} ${details.join(' · ')}`) : '';
|
|
452
454
|
const withMeta = visibleWidth(base) + visibleWidth(extra) <= width ? base + extra : base;
|
|
453
|
-
const hints = dim(' Ctrl+G/⇧Tab
|
|
455
|
+
const hints = dim(' Ctrl+G/⇧Tab permissions · Alt+M model · Ctrl+T variant');
|
|
454
456
|
const full = visibleWidth(withMeta) + visibleWidth(hints) <= width ? withMeta + hints : withMeta;
|
|
455
457
|
return visibleWidth(full) > width ? truncate(full, width, GLYPHS.ellipsis) : full;
|
|
456
458
|
}
|
|
@@ -898,7 +900,7 @@ export class ChatPrompt {
|
|
|
898
900
|
const isControlCommand = this.isCommand(text) && new Set([
|
|
899
901
|
'/stop', '/interrupt', '/new', '/model', '/models',
|
|
900
902
|
'/variant', '/effort', '/reasoning', '/cortex',
|
|
901
|
-
'/gui', '/web', '/studio',
|
|
903
|
+
'/gui', '/web', '/studio', '/game',
|
|
902
904
|
'/session', '/sessions', '/continuum', '/clear'
|
|
903
905
|
]).has(commandToken);
|
|
904
906
|
if ((trimmedLower === '/stop' || trimmedLower === '/interrupt') && this.busy) {
|
package/src/tui/prompt.ts
CHANGED
|
@@ -31,6 +31,7 @@ import { pickExample, fitHints } from './banner.js';
|
|
|
31
31
|
import { panelRows } from './overlay.js';
|
|
32
32
|
import { renderUsageCardRows, renderStatusCardRows, collectUsageCardData, type UsageCardData } from './usageCard.js';
|
|
33
33
|
import { buildStatusText } from '../reporting.js';
|
|
34
|
+
import { formatPermissionPresetLabel } from '../permissionPresets.js';
|
|
34
35
|
import { commandPalette, skillPicker, ApprovalLayer, DecisionLayer, ConfirmLayer, HomeLayer, TextLayer } from './dialogs.js';
|
|
35
36
|
import { describeTool } from './toolDisplay.js';
|
|
36
37
|
import { writeClipboardSync } from './clipboardSync.js';
|
|
@@ -174,7 +175,7 @@ export class ChatPrompt {
|
|
|
174
175
|
this.onOpenVariant = opts.onOpenVariant || null;
|
|
175
176
|
this.onOpenVariantList = opts.onOpenVariantList || null;
|
|
176
177
|
this.messageActionLoop = opts.messageActionLoop || null;
|
|
177
|
-
this.getMode = opts.getMode || (() => '
|
|
178
|
+
this.getMode = opts.getMode || (() => 'workspace-write');
|
|
178
179
|
|
|
179
180
|
this.editor = new LineEditor();
|
|
180
181
|
this.history = opts.history || new PromptHistory();
|
|
@@ -452,7 +453,8 @@ export class ChatPrompt {
|
|
|
452
453
|
const status = this.renderer && this.renderer.status;
|
|
453
454
|
if (!status) return null;
|
|
454
455
|
|
|
455
|
-
const
|
|
456
|
+
const presetLabel = formatPermissionPresetLabel(this.getMode());
|
|
457
|
+
const mode = this.busy ? `Working · ${presetLabel}` : presetLabel;
|
|
456
458
|
const parts = [bold(paint('accent', mode))];
|
|
457
459
|
if (status.model) parts.push(bold(paint('ink', status.model)));
|
|
458
460
|
if (status.variant) parts.push(paint('accent', `[${status.variant}]`));
|
|
@@ -464,7 +466,7 @@ export class ChatPrompt {
|
|
|
464
466
|
if (this.editor.lines.length > 1) details.push(`${this.editor.lines.length} lines`);
|
|
465
467
|
const extra = details.length ? dim(` ${GLYPHS.dot} ${details.join(' · ')}`) : '';
|
|
466
468
|
const withMeta = visibleWidth(base) + visibleWidth(extra) <= width ? base + extra : base;
|
|
467
|
-
const hints = dim(' Ctrl+G/⇧Tab
|
|
469
|
+
const hints = dim(' Ctrl+G/⇧Tab permissions · Alt+M model · Ctrl+T variant');
|
|
468
470
|
const full = visibleWidth(withMeta) + visibleWidth(hints) <= width ? withMeta + hints : withMeta;
|
|
469
471
|
return visibleWidth(full) > width ? truncate(full, width, GLYPHS.ellipsis) : full;
|
|
470
472
|
}
|
|
@@ -909,7 +911,7 @@ export class ChatPrompt {
|
|
|
909
911
|
const isControlCommand = this.isCommand(text) && new Set([
|
|
910
912
|
'/stop', '/interrupt', '/new', '/model', '/models',
|
|
911
913
|
'/variant', '/effort', '/reasoning', '/cortex',
|
|
912
|
-
'/gui', '/web', '/studio',
|
|
914
|
+
'/gui', '/web', '/studio', '/game',
|
|
913
915
|
'/session', '/sessions', '/continuum', '/clear'
|
|
914
916
|
]).has(commandToken);
|
|
915
917
|
|
package/src/tui/selectList.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Filterable, fuzzy-scored list primitive shared across all TUI pickers
|
|
2
|
+
// (command palette, model picker, session list, theme list, agent list, MCP list).
|
|
2
3
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// session list, theme list, agent list and MCP list are all that one component
|
|
6
|
-
// with different options. The lesson is the component, not the dialogs: build
|
|
7
|
-
// this once and well, and every dialog after it costs twenty lines.
|
|
8
|
-
//
|
|
9
|
-
// The fuzzy matcher is the part that decides whether a palette feels sharp or
|
|
10
|
-
// useless. A plain `includes()` cannot find "session list" from "sesl", and an
|
|
11
|
-
// unscored subsequence match ranks garbage first. This scores the way people
|
|
12
|
-
// expect: consecutive letters and word starts win, and a match at the beginning
|
|
13
|
-
// of the label beats the same letters buried in the middle.
|
|
4
|
+
// Scores consecutive letters and word starts higher than scattered matches so
|
|
5
|
+
// short queries jump directly to the intended item.
|
|
14
6
|
//
|
|
15
7
|
// Pure Node over ./theme.js and ./text.js. No dependency, no shell.
|
|
16
8
|
import { paint, bold, dim, GLYPHS } from './theme.js';
|
package/src/tui/selectList.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Filterable, fuzzy-scored list primitive shared across all TUI pickers
|
|
2
|
+
// (command palette, model picker, session list, theme list, agent list, MCP list).
|
|
2
3
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// session list, theme list, agent list and MCP list are all that one component
|
|
6
|
-
// with different options. The lesson is the component, not the dialogs: build
|
|
7
|
-
// this once and well, and every dialog after it costs twenty lines.
|
|
8
|
-
//
|
|
9
|
-
// The fuzzy matcher is the part that decides whether a palette feels sharp or
|
|
10
|
-
// useless. A plain `includes()` cannot find "session list" from "sesl", and an
|
|
11
|
-
// unscored subsequence match ranks garbage first. This scores the way people
|
|
12
|
-
// expect: consecutive letters and word starts win, and a match at the beginning
|
|
13
|
-
// of the label beats the same letters buried in the middle.
|
|
4
|
+
// Scores consecutive letters and word starts higher than scattered matches so
|
|
5
|
+
// short queries jump directly to the intended item.
|
|
14
6
|
//
|
|
15
7
|
// Pure Node over ./theme.js and ./text.js. No dependency, no shell.
|
|
16
8
|
|
package/src/tui/setup.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Shared setup transaction for the home panel and standalone CLI. */
|
|
2
2
|
import { resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
3
|
+
import { getPermissionPresetDescriptor, normalizePermissionPreset, presetToAutonomyMode } from '../permissionPresets.js';
|
|
4
|
+
import { reconcileConfigVariant } from '../modelVariants.js';
|
|
3
5
|
import { safeDisplay } from './text.js';
|
|
4
6
|
const string = (value) => typeof value === 'string' ? value : '';
|
|
5
7
|
const customProviders = new Set(['openai-compatible', 'dashscope-byok', 'ollama']);
|
|
@@ -122,14 +124,17 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
|
|
|
122
124
|
return null;
|
|
123
125
|
apiKey = answer || oldKey;
|
|
124
126
|
}
|
|
125
|
-
const
|
|
126
|
-
{ id: '
|
|
127
|
-
{ id: '
|
|
128
|
-
{ id: '
|
|
127
|
+
const selectedPerm = await ui.select({ title: 'Setup 4/5 · permissions', items: [
|
|
128
|
+
{ id: 'workspace-write', label: 'Workspace Write (Recommended)', description: 'Read and edit files within the workspace; confirm risky or external actions.' },
|
|
129
|
+
{ id: 'read-only', label: 'Read Only', description: 'Inspect files and search code without modifying workspace files.' },
|
|
130
|
+
{ id: 'danger-full-access', label: 'Full access', description: 'Direct workspace edits and commands; destructive and credential safeguards remain.' }
|
|
129
131
|
] });
|
|
130
|
-
|
|
132
|
+
const chosenPreset = normalizePermissionPreset(selectedPerm?.id);
|
|
133
|
+
if (!chosenPreset)
|
|
131
134
|
return null;
|
|
132
|
-
|
|
135
|
+
const chosenDesc = getPermissionPresetDescriptor(chosenPreset);
|
|
136
|
+
const chosenAutonomy = presetToAutonomyMode(chosenPreset);
|
|
137
|
+
draft = { ...draft, provider: provider.id, model, apiKey, permissionPreset: chosenPreset, autonomyMode: chosenAutonomy };
|
|
133
138
|
if (baseUrl)
|
|
134
139
|
draft.baseUrl = baseUrl;
|
|
135
140
|
else
|
|
@@ -138,7 +143,7 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
|
|
|
138
143
|
const cleanLabel = safeDisplay(provider.label).replace(/\s+/g, ' ').trim();
|
|
139
144
|
const cleanModel = safeDisplay(model).replace(/\s+/g, ' ').trim();
|
|
140
145
|
const review = await ui.select({ title: 'Setup 5/5 · review', items: [
|
|
141
|
-
{ id: 'save', label: 'Save configuration', description: `${cleanLabel} · ${cleanModel} ·
|
|
146
|
+
{ id: 'save', label: 'Save configuration', description: `${cleanLabel} · ${cleanModel} · ${chosenDesc.label}` },
|
|
142
147
|
{ id: 'edit', label: 'Edit choices', description: baseUrl || 'Provider default endpoint' },
|
|
143
148
|
{ id: 'cancel', label: 'Cancel without saving', description: `Workspace: ${cleanWorkspace}` }
|
|
144
149
|
] });
|
|
@@ -148,8 +153,16 @@ export async function runSetup(ui, providers, store, workspace = process.cwd())
|
|
|
148
153
|
continue;
|
|
149
154
|
if (review.id !== 'save')
|
|
150
155
|
return null;
|
|
151
|
-
// Preserve unrelated settings changed while the dialog was open
|
|
152
|
-
|
|
156
|
+
// Preserve unrelated settings changed while the dialog was open, while clearing
|
|
157
|
+
// stale reasoning variants when switching provider or model.
|
|
158
|
+
const existingCfg = store.loadConfig();
|
|
159
|
+
const providerOrModelChanged = existingCfg.provider !== draft.provider || existingCfg.model !== model;
|
|
160
|
+
const next = { ...existingCfg, provider: draft.provider, model, apiKey, permissionPreset: chosenPreset, autonomyMode: chosenAutonomy };
|
|
161
|
+
if (providerOrModelChanged) {
|
|
162
|
+
delete next.reasoningEffort;
|
|
163
|
+
delete next.reasoningBudgetTokens;
|
|
164
|
+
}
|
|
165
|
+
reconcileConfigVariant(next);
|
|
153
166
|
const saved = next;
|
|
154
167
|
if (baseUrl)
|
|
155
168
|
saved.baseUrl = baseUrl;
|
package/src/tui/setup.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/** Shared setup transaction for the home panel and standalone CLI. */
|
|
2
2
|
import { resolveAvailableModels } from '../dynamicCatalogue.js';
|
|
3
|
+
import {
|
|
4
|
+
getPermissionPresetDescriptor,
|
|
5
|
+
normalizePermissionPreset,
|
|
6
|
+
presetToAutonomyMode
|
|
7
|
+
} from '../permissionPresets.js';
|
|
8
|
+
import { reconcileConfigVariant } from '../modelVariants.js';
|
|
3
9
|
import { safeDisplay } from './text.js';
|
|
4
10
|
|
|
5
11
|
export interface SetupChoice { id: string; label: string; description?: string }
|
|
@@ -128,27 +134,38 @@ export async function runSetup(ui: SetupUI, providers: SetupProvider[], store: {
|
|
|
128
134
|
if (answer === null) return null;
|
|
129
135
|
apiKey = answer || oldKey;
|
|
130
136
|
}
|
|
131
|
-
const
|
|
132
|
-
{ id: '
|
|
133
|
-
{ id: '
|
|
134
|
-
{ id: '
|
|
137
|
+
const selectedPerm = await ui.select({ title: 'Setup 4/5 · permissions', items: [
|
|
138
|
+
{ id: 'workspace-write', label: 'Workspace Write (Recommended)', description: 'Read and edit files within the workspace; confirm risky or external actions.' },
|
|
139
|
+
{ id: 'read-only', label: 'Read Only', description: 'Inspect files and search code without modifying workspace files.' },
|
|
140
|
+
{ id: 'danger-full-access', label: 'Full access', description: 'Direct workspace edits and commands; destructive and credential safeguards remain.' }
|
|
135
141
|
] });
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
const chosenPreset = normalizePermissionPreset(selectedPerm?.id);
|
|
143
|
+
if (!chosenPreset) return null;
|
|
144
|
+
const chosenDesc = getPermissionPresetDescriptor(chosenPreset);
|
|
145
|
+
const chosenAutonomy = presetToAutonomyMode(chosenPreset);
|
|
146
|
+
draft = { ...draft, provider: provider.id, model, apiKey, permissionPreset: chosenPreset, autonomyMode: chosenAutonomy };
|
|
138
147
|
if (baseUrl) draft.baseUrl = baseUrl; else delete draft.baseUrl;
|
|
139
148
|
const cleanWorkspace = safeDisplay(workspace).replace(/\s+/g, ' ').trim();
|
|
140
149
|
const cleanLabel = safeDisplay(provider.label).replace(/\s+/g, ' ').trim();
|
|
141
150
|
const cleanModel = safeDisplay(model).replace(/\s+/g, ' ').trim();
|
|
142
151
|
const review = await ui.select({ title: 'Setup 5/5 · review', items: [
|
|
143
|
-
{ id: 'save', label: 'Save configuration', description: `${cleanLabel} · ${cleanModel} ·
|
|
152
|
+
{ id: 'save', label: 'Save configuration', description: `${cleanLabel} · ${cleanModel} · ${chosenDesc.label}` },
|
|
144
153
|
{ id: 'edit', label: 'Edit choices', description: baseUrl || 'Provider default endpoint' },
|
|
145
154
|
{ id: 'cancel', label: 'Cancel without saving', description: `Workspace: ${cleanWorkspace}` }
|
|
146
155
|
] });
|
|
147
156
|
if (!review || review.id === 'cancel') return null;
|
|
148
157
|
if (review.id === 'edit') continue;
|
|
149
158
|
if (review.id !== 'save') return null;
|
|
150
|
-
// Preserve unrelated settings changed while the dialog was open
|
|
151
|
-
|
|
159
|
+
// Preserve unrelated settings changed while the dialog was open, while clearing
|
|
160
|
+
// stale reasoning variants when switching provider or model.
|
|
161
|
+
const existingCfg = store.loadConfig();
|
|
162
|
+
const providerOrModelChanged = existingCfg.provider !== draft.provider || existingCfg.model !== model;
|
|
163
|
+
const next: Config = { ...existingCfg, provider: draft.provider, model, apiKey, permissionPreset: chosenPreset, autonomyMode: chosenAutonomy };
|
|
164
|
+
if (providerOrModelChanged) {
|
|
165
|
+
delete next.reasoningEffort;
|
|
166
|
+
delete next.reasoningBudgetTokens;
|
|
167
|
+
}
|
|
168
|
+
reconcileConfigVariant(next);
|
|
152
169
|
const saved: Config = next;
|
|
153
170
|
if (baseUrl) saved.baseUrl = baseUrl; else delete saved.baseUrl;
|
|
154
171
|
if (provider.id !== 'ollama' && !isLocalAgent(provider.id)) {
|
package/src/tui/statusLine.ts
CHANGED
|
@@ -79,6 +79,8 @@ export interface StatusLineSessionInfo {
|
|
|
79
79
|
model?: string | undefined;
|
|
80
80
|
provider?: string | undefined;
|
|
81
81
|
variant?: string | undefined;
|
|
82
|
+
permissionPreset?: string | undefined;
|
|
83
|
+
autonomyMode?: string | undefined;
|
|
82
84
|
tier?: string | undefined;
|
|
83
85
|
cwd?: string | undefined;
|
|
84
86
|
contextLimit?: number | string | undefined;
|