@causyne/agent 1.20.124 → 1.20.128
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/docs/THIRD_PARTY_NOTICES.md +36 -2
- package/package.json +6 -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 +142 -53
- package/src/agentLoop.ts +151 -50
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +61 -3
- package/src/browser/causyneBrowser.ts +65 -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 +365 -45
- package/src/commands.ts +403 -45
- 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/memory/episodicStore.js +40 -0
- package/src/memory/episodicStore.ts +46 -0
- package/src/memory.js +67 -0
- package/src/memory.ts +65 -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/personalization.js +365 -0
- package/src/personalization.ts +471 -0
- package/src/projectInstructions.js +30 -10
- package/src/projectInstructions.ts +31 -12
- package/src/providers/acp.js +3 -2
- package/src/providers/acp.ts +3 -2
- package/src/providers/antigravity.js +64 -9
- package/src/providers/antigravity.ts +75 -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/memoryWrite.js +15 -1
- package/src/tools/memoryWrite.ts +16 -1
- 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/osSandbox.js +1 -1
- package/src/tools/osSandbox.ts +1 -1
- 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 +1108 -0
- package/src/tools/ptyTerminal.ts +1245 -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 +905 -0
- package/src/web/client/browserPanel.ts +872 -0
- package/src/web/client/chatStream.js +321 -0
- package/src/web/client/chatStream.ts +297 -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 +271 -0
- package/src/web/client/dom.ts +272 -0
- package/src/web/client/filesAndCanvas.js +233 -0
- package/src/web/client/filesAndCanvas.ts +240 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +316 -0
- package/src/web/client/main.ts +391 -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 +824 -0
- package/src/web/client/settingsModal.ts +959 -0
- package/src/web/client/state.js +280 -0
- package/src/web/client/state.ts +259 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +89 -0
- package/src/web/client/studioLayout.ts +103 -0
- package/src/web/client/studioShell.js +660 -0
- package/src/web/client/studioShell.ts +672 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +606 -0
- package/src/web/client/terminalPanel.ts +632 -0
- package/src/web/client/terminalTheme.js +249 -0
- package/src/web/client/terminalTheme.ts +258 -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 +322 -0
- package/src/web/client/validators.js +147 -0
- package/src/web/client/validators.ts +140 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +409 -0
- package/src/web/server/routesBrowser.ts +435 -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/routesSettings.js +344 -0
- package/src/web/server/routesSettings.ts +397 -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 +104 -0
- package/src/web/server/staticAssets.ts +116 -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 +78 -2448
- package/src/web/skybridgeServer.ts +120 -2600
- package/src/web/skybridgeUi.js +20 -450
- package/src/web/skybridgeUi.ts +24 -455
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +935 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +951 -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 +388 -0
- package/src/web/ui/modalsTemplate.ts +388 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +256 -0
- package/src/web/ui/studioTemplate.ts +256 -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/banner.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* CAUSYNE_ASCII=1 (7-bit only), and CAUSYNE_NO_ANIM=1.
|
|
8
8
|
*/
|
|
9
9
|
import { homedir } from 'node:os';
|
|
10
|
+
import { formatPermissionPresetLabel } from '../permissionPresets.js';
|
|
10
11
|
import { safeDisplay } from './text.js';
|
|
11
12
|
|
|
12
13
|
function cleanMeta(value: unknown): string {
|
|
@@ -24,6 +25,7 @@ export interface BannerInfo {
|
|
|
24
25
|
model?: string;
|
|
25
26
|
mode?: string;
|
|
26
27
|
cwd?: string;
|
|
28
|
+
permissionPreset?: string;
|
|
27
29
|
autonomyMode?: string;
|
|
28
30
|
tier?: string;
|
|
29
31
|
workspace?: string;
|
|
@@ -356,8 +358,11 @@ export function providerLabel(provider: unknown): string {
|
|
|
356
358
|
|
|
357
359
|
function sessionInfo(info: BannerInfo): BannerInfo {
|
|
358
360
|
const provider = providerLabel(info.provider);
|
|
361
|
+
const permDisplay = info.permissionPreset
|
|
362
|
+
? formatPermissionPresetLabel(info.permissionPreset)
|
|
363
|
+
: (info.autonomyMode ? formatPermissionPresetLabel(info.autonomyMode) : info.mode);
|
|
359
364
|
const modeParts = [
|
|
360
|
-
|
|
365
|
+
permDisplay,
|
|
361
366
|
info.tier ? `tier ${info.tier}` : undefined
|
|
362
367
|
].filter((part): part is string => Boolean(part));
|
|
363
368
|
return {
|
package/src/tui/chatRenderer.js
CHANGED
|
@@ -25,8 +25,7 @@ import { formatMarkdownMath } from './markdownMath.js';
|
|
|
25
25
|
import { renderThinkingFrame } from './thinkingBox.js';
|
|
26
26
|
import { measureMessages, resolveCharPool } from '../contextManager.js';
|
|
27
27
|
// Bound the preview AFTER wrapping, not by source newlines: one 400 KB line of
|
|
28
|
-
// minified output would otherwise become thousands of rows and lock the
|
|
29
|
-
// terminal. (The failure openclaw's tool-execution component documents.)
|
|
28
|
+
// minified output would otherwise become thousands of rows and lock the terminal.
|
|
30
29
|
const PREVIEW_LINES = 12;
|
|
31
30
|
// Cut the SOURCE before sanitising it, not after.
|
|
32
31
|
const PREVIEW_SOURCE_BUDGET = PREVIEW_LINES * 256;
|
package/src/tui/chatRenderer.ts
CHANGED
|
@@ -55,8 +55,7 @@ export interface ChatRendererOptions {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Bound the preview AFTER wrapping, not by source newlines: one 400 KB line of
|
|
58
|
-
// minified output would otherwise become thousands of rows and lock the
|
|
59
|
-
// terminal. (The failure openclaw's tool-execution component documents.)
|
|
58
|
+
// minified output would otherwise become thousands of rows and lock the terminal.
|
|
60
59
|
const PREVIEW_LINES = 12;
|
|
61
60
|
|
|
62
61
|
// Cut the SOURCE before sanitising it, not after.
|
package/src/tui/completion.js
CHANGED
package/src/tui/completion.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loadConfig, saveConfig } from '../config.js';
|
|
2
|
+
import { PERMISSION_PRESET_CATALOG, getDefaultPermissionPreset, getPermissionPresetDescriptor, normalizePermissionPreset, setDefaultPermissionPreset } from '../permissionPresets.js';
|
|
2
3
|
import { getAvailableProvidersOverview, getLiveAntigravityModels, getModelVariantsForPeer } from '../dynamicCatalogue.js';
|
|
3
4
|
import { resolveModelVariants } from '../modelVariants.js';
|
|
4
5
|
import { isAcpProvider } from '../providers/acp.js';
|
|
@@ -6,24 +7,30 @@ import { writeClipboardSync } from './clipboardSync.js';
|
|
|
6
7
|
import { SelectLayer } from './dialogs.js';
|
|
7
8
|
import { looksSensitive } from './history.js';
|
|
8
9
|
export function openModeControl(prompt, loop) {
|
|
9
|
-
const
|
|
10
|
-
const current = String(config.autonomyMode || 'B').toUpperCase();
|
|
10
|
+
const current = getDefaultPermissionPreset();
|
|
11
11
|
prompt.openLayer(new SelectLayer({
|
|
12
|
-
title: '
|
|
13
|
-
items:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
title: 'Permission preset',
|
|
13
|
+
items: PERMISSION_PRESET_CATALOG.map((preset) => ({
|
|
14
|
+
id: preset.id,
|
|
15
|
+
label: `${preset.label}${preset.id === current ? ' (active)' : ''}`,
|
|
16
|
+
description: preset.description,
|
|
17
|
+
value: preset.id
|
|
18
|
+
})),
|
|
18
19
|
onPick: (item) => {
|
|
19
|
-
|
|
20
|
+
const chosen = normalizePermissionPreset(item?.value);
|
|
21
|
+
if (!chosen)
|
|
20
22
|
return;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
loop.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const desc = getPermissionPresetDescriptor(chosen);
|
|
24
|
+
setDefaultPermissionPreset(chosen);
|
|
25
|
+
if (typeof loop.setPermissionPreset === 'function') {
|
|
26
|
+
loop.setPermissionPreset(chosen);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
loop.setAutonomyMode(desc.autonomyMode);
|
|
30
|
+
}
|
|
31
|
+
prompt.renderer?.status?.setSession?.({ permissionPreset: chosen, autonomyMode: desc.autonomyMode });
|
|
32
|
+
prompt.surface?.setSessionInfo?.({ permissionPreset: chosen, autonomyMode: desc.autonomyMode });
|
|
33
|
+
prompt.notice = `${desc.label} active`;
|
|
27
34
|
prompt.scheduleDraw();
|
|
28
35
|
}
|
|
29
36
|
}));
|
|
@@ -55,18 +62,23 @@ export function availableModelVariants(config) {
|
|
|
55
62
|
return advertised.filter(model => splitModelVariant(model)?.base === parsed.base);
|
|
56
63
|
}
|
|
57
64
|
export function cycleModeControl(prompt, loop) {
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
65
|
+
const order = ['read-only', 'workspace-write', 'danger-full-access'];
|
|
66
|
+
const current = normalizePermissionPreset(loop?.config?.permissionPreset)
|
|
67
|
+
?? normalizePermissionPreset(loop?.config?.autonomyMode)
|
|
68
|
+
?? getDefaultPermissionPreset();
|
|
61
69
|
const idx = order.indexOf(current);
|
|
62
70
|
const next = order[(idx + 1) % order.length];
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
loop.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
const desc = getPermissionPresetDescriptor(next);
|
|
72
|
+
setDefaultPermissionPreset(next);
|
|
73
|
+
if (typeof loop.setPermissionPreset === 'function') {
|
|
74
|
+
loop.setPermissionPreset(next);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
loop.setAutonomyMode(desc.autonomyMode);
|
|
78
|
+
}
|
|
79
|
+
prompt.renderer?.status?.setSession?.({ permissionPreset: next, autonomyMode: desc.autonomyMode });
|
|
80
|
+
prompt.surface?.setSessionInfo?.({ permissionPreset: next, autonomyMode: desc.autonomyMode });
|
|
81
|
+
prompt.notice = `${desc.label} · Shift+Tab cycle · Ctrl+G menu`;
|
|
70
82
|
prompt.scheduleDraw();
|
|
71
83
|
}
|
|
72
84
|
function resolveVariantSpecForControl(config, loop) {
|
|
@@ -100,6 +112,78 @@ function resolveVariantSpecForControl(config, loop) {
|
|
|
100
112
|
availableAgyModels: liveAgyModels && liveAgyModels.length > 0 ? liveAgyModels : undefined
|
|
101
113
|
});
|
|
102
114
|
}
|
|
115
|
+
function applyVariantSilently(rawChoice, spec, config, prompt, loop) {
|
|
116
|
+
const isAuto = rawChoice.toLowerCase() === 'auto';
|
|
117
|
+
if (isAuto) {
|
|
118
|
+
delete config.reasoningEffort;
|
|
119
|
+
delete config.reasoningBudgetTokens;
|
|
120
|
+
saveConfig(config);
|
|
121
|
+
const liveAcp = typeof loop?.llm?.getLiveVariantOption === 'function'
|
|
122
|
+
? loop.llm.getLiveVariantOption()
|
|
123
|
+
: null;
|
|
124
|
+
if (liveAcp
|
|
125
|
+
&& Array.isArray(liveAcp.options)
|
|
126
|
+
&& liveAcp.options.some((opt) => String(opt?.value || '').toLowerCase() === 'default')
|
|
127
|
+
&& typeof loop?.llm?.applyVariant === 'function') {
|
|
128
|
+
void Promise.resolve(loop.llm.applyVariant('default', liveAcp.configOptionId || spec.acpConfigId)).catch(() => { });
|
|
129
|
+
}
|
|
130
|
+
if (loop) {
|
|
131
|
+
loop.config = loadConfig();
|
|
132
|
+
if (typeof loop.updateTierLimits === 'function')
|
|
133
|
+
loop.updateTierLimits();
|
|
134
|
+
}
|
|
135
|
+
if (typeof prompt.updateModel === 'function') {
|
|
136
|
+
prompt.updateModel(config.provider || spec.provider, config.model || spec.model, '');
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
prompt.renderer?.status?.setSession?.({ variant: '' });
|
|
140
|
+
prompt.surface?.setSessionInfo?.({ variant: '' });
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const matched = spec.options.find((o) => o.id.toLowerCase() === rawChoice.toLowerCase());
|
|
145
|
+
if (!matched)
|
|
146
|
+
return;
|
|
147
|
+
const modelChanged = Boolean(matched.targetModelId && matched.targetModelId !== config.model);
|
|
148
|
+
if (matched.targetModelId) {
|
|
149
|
+
config.model = matched.targetModelId;
|
|
150
|
+
}
|
|
151
|
+
if (spec.source === 'agy_models') {
|
|
152
|
+
delete config.reasoningEffort;
|
|
153
|
+
delete config.reasoningBudgetTokens;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
config.reasoningEffort = matched.id;
|
|
157
|
+
}
|
|
158
|
+
saveConfig(config);
|
|
159
|
+
const displayedVariant = spec.source === 'agy_models' ? '' : matched.id;
|
|
160
|
+
if (typeof loop?.llm?.applyVariant === 'function' && !modelChanged) {
|
|
161
|
+
void Promise.resolve(loop.llm.applyVariant(matched.id, matched.acpConfigId)).then(() => {
|
|
162
|
+
if (loop)
|
|
163
|
+
loop.config = loadConfig();
|
|
164
|
+
}).catch(() => { });
|
|
165
|
+
}
|
|
166
|
+
else if (loop) {
|
|
167
|
+
loop.config = loadConfig();
|
|
168
|
+
if (typeof loop.updateTierLimits === 'function')
|
|
169
|
+
loop.updateTierLimits();
|
|
170
|
+
}
|
|
171
|
+
if (typeof prompt.updateModel === 'function') {
|
|
172
|
+
prompt.updateModel(config.provider || spec.provider, config.model || spec.model, displayedVariant);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
prompt.renderer?.status?.setSession?.({
|
|
176
|
+
provider: config.provider || spec.provider,
|
|
177
|
+
model: config.model || spec.model,
|
|
178
|
+
variant: displayedVariant
|
|
179
|
+
});
|
|
180
|
+
prompt.surface?.setSessionInfo?.({
|
|
181
|
+
provider: config.provider || spec.provider,
|
|
182
|
+
model: config.model || spec.model,
|
|
183
|
+
variant: displayedVariant
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
103
187
|
export function cycleVariantControl(prompt, loop) {
|
|
104
188
|
const config = loadConfig();
|
|
105
189
|
const spec = resolveVariantSpecForControl(config, loop);
|
|
@@ -117,7 +201,7 @@ export function cycleVariantControl(prompt, loop) {
|
|
|
117
201
|
const currentIdx = cycleValues.findIndex((v) => v.toLowerCase() === currentId);
|
|
118
202
|
const nextIdx = (currentIdx + 1) % cycleValues.length;
|
|
119
203
|
const nextVal = cycleValues[nextIdx];
|
|
120
|
-
|
|
204
|
+
applyVariantSilently(nextVal, spec, config, prompt, loop);
|
|
121
205
|
const positionLabel = nextVal === 'auto'
|
|
122
206
|
? 'auto (default)'
|
|
123
207
|
: `${nextVal} (${nextIdx + 1}/${spec.options.length})`;
|
|
@@ -163,7 +247,7 @@ export function openVariantControl(prompt, loop) {
|
|
|
163
247
|
onPick: (item) => {
|
|
164
248
|
if (!item?.value)
|
|
165
249
|
return;
|
|
166
|
-
|
|
250
|
+
applyVariantSilently(item.value, spec, loadConfig(), prompt, loop);
|
|
167
251
|
prompt.notice = item.value === 'auto' ? 'Variant reset to auto' : `Variant set to ${item.value}`;
|
|
168
252
|
prompt.scheduleDraw();
|
|
169
253
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { loadConfig, saveConfig } from '../config.js';
|
|
2
|
+
import {
|
|
3
|
+
PERMISSION_PRESET_CATALOG,
|
|
4
|
+
getDefaultPermissionPreset,
|
|
5
|
+
getPermissionPresetDescriptor,
|
|
6
|
+
normalizePermissionPreset,
|
|
7
|
+
setDefaultPermissionPreset,
|
|
8
|
+
type PermissionPresetId
|
|
9
|
+
} from '../permissionPresets.js';
|
|
2
10
|
import { getAvailableProvidersOverview, getLiveAntigravityModels, getModelVariantsForPeer } from '../dynamicCatalogue.js';
|
|
3
11
|
import { resolveModelVariants } from '../modelVariants.js';
|
|
4
12
|
import { isAcpProvider } from '../providers/acp.js';
|
|
@@ -16,26 +24,32 @@ interface ControlPrompt {
|
|
|
16
24
|
interface ControlLoop {
|
|
17
25
|
config: Record<string, unknown>;
|
|
18
26
|
setAutonomyMode(mode: string): void;
|
|
27
|
+
setPermissionPreset?(preset: string): void;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
export function openModeControl(prompt: ControlPrompt, loop: ControlLoop): void {
|
|
22
|
-
const
|
|
23
|
-
const current = String(config.autonomyMode || 'B').toUpperCase();
|
|
31
|
+
const current = getDefaultPermissionPreset();
|
|
24
32
|
prompt.openLayer(new SelectLayer({
|
|
25
|
-
title: '
|
|
26
|
-
items:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
title: 'Permission preset',
|
|
34
|
+
items: PERMISSION_PRESET_CATALOG.map((preset) => ({
|
|
35
|
+
id: preset.id,
|
|
36
|
+
label: `${preset.label}${preset.id === current ? ' (active)' : ''}`,
|
|
37
|
+
description: preset.description,
|
|
38
|
+
value: preset.id
|
|
39
|
+
})),
|
|
31
40
|
onPick: (item: { value?: string } | null) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
const chosen = normalizePermissionPreset(item?.value);
|
|
42
|
+
if (!chosen) return;
|
|
43
|
+
const desc = getPermissionPresetDescriptor(chosen);
|
|
44
|
+
setDefaultPermissionPreset(chosen);
|
|
45
|
+
if (typeof loop.setPermissionPreset === 'function') {
|
|
46
|
+
loop.setPermissionPreset(chosen);
|
|
47
|
+
} else {
|
|
48
|
+
loop.setAutonomyMode(desc.autonomyMode);
|
|
49
|
+
}
|
|
50
|
+
(prompt as any).renderer?.status?.setSession?.({ permissionPreset: chosen, autonomyMode: desc.autonomyMode });
|
|
51
|
+
(prompt as any).surface?.setSessionInfo?.({ permissionPreset: chosen, autonomyMode: desc.autonomyMode });
|
|
52
|
+
prompt.notice = `${desc.label} active`;
|
|
39
53
|
prompt.scheduleDraw();
|
|
40
54
|
}
|
|
41
55
|
}));
|
|
@@ -65,18 +79,22 @@ export function availableModelVariants(config: Record<string, unknown>): string[
|
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
export function cycleModeControl(prompt: ControlPrompt, loop: ControlLoop): void {
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
const order: readonly PermissionPresetId[] = ['read-only', 'workspace-write', 'danger-full-access'];
|
|
83
|
+
const current = normalizePermissionPreset(loop?.config?.permissionPreset)
|
|
84
|
+
?? normalizePermissionPreset(loop?.config?.autonomyMode)
|
|
85
|
+
?? getDefaultPermissionPreset();
|
|
86
|
+
const idx = order.indexOf(current);
|
|
72
87
|
const next = order[(idx + 1) % order.length]!;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
loop.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
const desc = getPermissionPresetDescriptor(next);
|
|
89
|
+
setDefaultPermissionPreset(next);
|
|
90
|
+
if (typeof loop.setPermissionPreset === 'function') {
|
|
91
|
+
loop.setPermissionPreset(next);
|
|
92
|
+
} else {
|
|
93
|
+
loop.setAutonomyMode(desc.autonomyMode);
|
|
94
|
+
}
|
|
95
|
+
(prompt as any).renderer?.status?.setSession?.({ permissionPreset: next, autonomyMode: desc.autonomyMode });
|
|
96
|
+
(prompt as any).surface?.setSessionInfo?.({ permissionPreset: next, autonomyMode: desc.autonomyMode });
|
|
97
|
+
prompt.notice = `${desc.label} · Shift+Tab cycle · Ctrl+G menu`;
|
|
80
98
|
prompt.scheduleDraw();
|
|
81
99
|
}
|
|
82
100
|
|
|
@@ -113,6 +131,84 @@ function resolveVariantSpecForControl(config: Record<string, any>, loop?: any) {
|
|
|
113
131
|
});
|
|
114
132
|
}
|
|
115
133
|
|
|
134
|
+
function applyVariantSilently(
|
|
135
|
+
rawChoice: string,
|
|
136
|
+
spec: ReturnType<typeof resolveModelVariants>,
|
|
137
|
+
config: Record<string, any>,
|
|
138
|
+
prompt: ControlPrompt,
|
|
139
|
+
loop?: any
|
|
140
|
+
): void {
|
|
141
|
+
const isAuto = rawChoice.toLowerCase() === 'auto';
|
|
142
|
+
if (isAuto) {
|
|
143
|
+
delete config.reasoningEffort;
|
|
144
|
+
delete config.reasoningBudgetTokens;
|
|
145
|
+
saveConfig(config);
|
|
146
|
+
const liveAcp = typeof loop?.llm?.getLiveVariantOption === 'function'
|
|
147
|
+
? loop.llm.getLiveVariantOption()
|
|
148
|
+
: null;
|
|
149
|
+
if (
|
|
150
|
+
liveAcp
|
|
151
|
+
&& Array.isArray(liveAcp.options)
|
|
152
|
+
&& liveAcp.options.some((opt: { value?: string }) => String(opt?.value || '').toLowerCase() === 'default')
|
|
153
|
+
&& typeof loop?.llm?.applyVariant === 'function'
|
|
154
|
+
) {
|
|
155
|
+
void Promise.resolve(loop.llm.applyVariant('default', liveAcp.configOptionId || spec.acpConfigId)).catch(() => {});
|
|
156
|
+
}
|
|
157
|
+
if (loop) {
|
|
158
|
+
loop.config = loadConfig();
|
|
159
|
+
if (typeof loop.updateTierLimits === 'function') loop.updateTierLimits();
|
|
160
|
+
}
|
|
161
|
+
if (typeof (prompt as any).updateModel === 'function') {
|
|
162
|
+
(prompt as any).updateModel(config.provider || spec.provider, config.model || spec.model, '');
|
|
163
|
+
} else {
|
|
164
|
+
(prompt as any).renderer?.status?.setSession?.({ variant: '' });
|
|
165
|
+
(prompt as any).surface?.setSessionInfo?.({ variant: '' });
|
|
166
|
+
}
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const matched = spec.options.find((o) => o.id.toLowerCase() === rawChoice.toLowerCase());
|
|
171
|
+
if (!matched) return;
|
|
172
|
+
|
|
173
|
+
const modelChanged = Boolean(matched.targetModelId && matched.targetModelId !== config.model);
|
|
174
|
+
if (matched.targetModelId) {
|
|
175
|
+
config.model = matched.targetModelId;
|
|
176
|
+
}
|
|
177
|
+
if (spec.source === 'agy_models') {
|
|
178
|
+
delete config.reasoningEffort;
|
|
179
|
+
delete config.reasoningBudgetTokens;
|
|
180
|
+
} else {
|
|
181
|
+
config.reasoningEffort = matched.id;
|
|
182
|
+
}
|
|
183
|
+
saveConfig(config);
|
|
184
|
+
|
|
185
|
+
const displayedVariant = spec.source === 'agy_models' ? '' : matched.id;
|
|
186
|
+
|
|
187
|
+
if (typeof loop?.llm?.applyVariant === 'function' && !modelChanged) {
|
|
188
|
+
void Promise.resolve(loop.llm.applyVariant(matched.id, matched.acpConfigId)).then(() => {
|
|
189
|
+
if (loop) loop.config = loadConfig();
|
|
190
|
+
}).catch(() => {});
|
|
191
|
+
} else if (loop) {
|
|
192
|
+
loop.config = loadConfig();
|
|
193
|
+
if (typeof loop.updateTierLimits === 'function') loop.updateTierLimits();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (typeof (prompt as any).updateModel === 'function') {
|
|
197
|
+
(prompt as any).updateModel(config.provider || spec.provider, config.model || spec.model, displayedVariant);
|
|
198
|
+
} else {
|
|
199
|
+
(prompt as any).renderer?.status?.setSession?.({
|
|
200
|
+
provider: config.provider || spec.provider,
|
|
201
|
+
model: config.model || spec.model,
|
|
202
|
+
variant: displayedVariant
|
|
203
|
+
});
|
|
204
|
+
(prompt as any).surface?.setSessionInfo?.({
|
|
205
|
+
provider: config.provider || spec.provider,
|
|
206
|
+
model: config.model || spec.model,
|
|
207
|
+
variant: displayedVariant
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
116
212
|
export function cycleVariantControl(prompt: ControlPrompt, loop?: any): void {
|
|
117
213
|
const config = loadConfig();
|
|
118
214
|
const spec = resolveVariantSpecForControl(config, loop);
|
|
@@ -133,7 +229,7 @@ export function cycleVariantControl(prompt: ControlPrompt, loop?: any): void {
|
|
|
133
229
|
const nextIdx = (currentIdx + 1) % cycleValues.length;
|
|
134
230
|
const nextVal = cycleValues[nextIdx]!;
|
|
135
231
|
|
|
136
|
-
|
|
232
|
+
applyVariantSilently(nextVal, spec, config, prompt, loop);
|
|
137
233
|
const positionLabel = nextVal === 'auto'
|
|
138
234
|
? 'auto (default)'
|
|
139
235
|
: `${nextVal} (${nextIdx + 1}/${spec.options.length})`;
|
|
@@ -183,7 +279,7 @@ export function openVariantControl(prompt: ControlPrompt, loop?: any): void {
|
|
|
183
279
|
showFilter: items.length > 6,
|
|
184
280
|
onPick: (item: { value?: string } | null) => {
|
|
185
281
|
if (!item?.value) return;
|
|
186
|
-
|
|
282
|
+
applyVariantSilently(item.value, spec, loadConfig(), prompt, loop);
|
|
187
283
|
prompt.notice = item.value === 'auto' ? 'Variant reset to auto' : `Variant set to ${item.value}`;
|
|
188
284
|
prompt.scheduleDraw();
|
|
189
285
|
}
|
package/src/tui/dialogs.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// That is the payoff of building the primitives properly: opencode needs twenty
|
|
5
|
-
// `dialog-*.tsx` files because each one re-declares its own layout; here a
|
|
6
|
-
// picker is a title, a list of items and a callback.
|
|
7
|
-
//
|
|
8
|
-
// The one that is not a picker is ApprovalLayer, and it is the reason this file
|
|
9
|
-
// exists at all. Causyne's approval used inquirer, which means the question is
|
|
10
|
-
// asked in the scrollback, below whatever the agent last printed, with the diff
|
|
11
|
-
// already scrolled away above it. As a modal the risk badge, the tool, the
|
|
12
|
-
// arguments and the full scrollable diff sit in one frame that the user cannot
|
|
13
|
-
// lose — and neither reference does this: openclaw approves in a plain prompt,
|
|
14
|
-
// opencode's permission dialog does not scroll its diff by keyboard.
|
|
15
|
-
//
|
|
1
|
+
// Concrete TUI modal dialogs built over SelectList and scrolling Layer panes.
|
|
2
|
+
// ApprovalLayer keeps the risk badge, tool, arguments, and scrollable diff in
|
|
3
|
+
// one focused modal frame instead of losing them in terminal scrollback.
|
|
16
4
|
// Pure Node over ./selectList.js, ./overlay.js, ./theme.js, ./text.js.
|
|
17
|
-
// No dependency, no shell.
|
|
18
5
|
import { Layer, dialogHint } from './overlay.js';
|
|
19
6
|
import { SelectList } from './selectList.js';
|
|
20
7
|
import { LineEditor } from './lineEditor.js';
|
package/src/tui/dialogs.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// That is the payoff of building the primitives properly: opencode needs twenty
|
|
5
|
-
// `dialog-*.tsx` files because each one re-declares its own layout; here a
|
|
6
|
-
// picker is a title, a list of items and a callback.
|
|
7
|
-
//
|
|
8
|
-
// The one that is not a picker is ApprovalLayer, and it is the reason this file
|
|
9
|
-
// exists at all. Causyne's approval used inquirer, which means the question is
|
|
10
|
-
// asked in the scrollback, below whatever the agent last printed, with the diff
|
|
11
|
-
// already scrolled away above it. As a modal the risk badge, the tool, the
|
|
12
|
-
// arguments and the full scrollable diff sit in one frame that the user cannot
|
|
13
|
-
// lose — and neither reference does this: openclaw approves in a plain prompt,
|
|
14
|
-
// opencode's permission dialog does not scroll its diff by keyboard.
|
|
15
|
-
//
|
|
1
|
+
// Concrete TUI modal dialogs built over SelectList and scrolling Layer panes.
|
|
2
|
+
// ApprovalLayer keeps the risk badge, tool, arguments, and scrollable diff in
|
|
3
|
+
// one focused modal frame instead of losing them in terminal scrollback.
|
|
16
4
|
// Pure Node over ./selectList.js, ./overlay.js, ./theme.js, ./text.js.
|
|
17
|
-
// No dependency, no shell.
|
|
18
5
|
|
|
19
6
|
import { Layer, dialogHint, type LayerOptions } from './overlay.js';
|
|
20
7
|
import { SelectList, type SelectListItem } from './selectList.js';
|
package/src/tui/home.js
CHANGED
|
@@ -42,6 +42,7 @@ export function homeStatusLine(arg = {}) {
|
|
|
42
42
|
export const PRIMARY_ACTIONS = [
|
|
43
43
|
{ id: 'chat', label: 'chat', hint: 'talk to the agent here', kind: 'chat' },
|
|
44
44
|
{ id: 'gui', label: 'web studio', hint: 'open local browser GUI workspace (/gui)', kind: 'command', command: '/gui' },
|
|
45
|
+
{ id: 'game', label: 'causyne game', hint: 'open Causyne Game studio workspace (/game)', kind: 'command', command: '/game' },
|
|
45
46
|
{
|
|
46
47
|
id: 'status',
|
|
47
48
|
label: 'status',
|
package/src/tui/home.ts
CHANGED
|
@@ -64,6 +64,7 @@ export function homeStatusLine(arg: Record<string, any> | null | undefined = {})
|
|
|
64
64
|
export const PRIMARY_ACTIONS: HomeAction[] = [
|
|
65
65
|
{ id: 'chat', label: 'chat', hint: 'talk to the agent here', kind: 'chat' },
|
|
66
66
|
{ id: 'gui', label: 'web studio', hint: 'open local browser GUI workspace (/gui)', kind: 'command', command: '/gui' },
|
|
67
|
+
{ id: 'game', label: 'causyne game', hint: 'open Causyne Game studio workspace (/game)', kind: 'command', command: '/game' },
|
|
67
68
|
{
|
|
68
69
|
id: 'status',
|
|
69
70
|
label: 'status',
|
package/src/tui/invocation.js
CHANGED
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
// goes to Commander so Commander can report it, exactly as it does today.
|
|
20
20
|
// 2. `--` ends the scan. Anything after it is operands, not a command path.
|
|
21
21
|
//
|
|
22
|
-
//
|
|
23
|
-
// same reason: `openclaw --profile foo` must still launch the TUI.
|
|
22
|
+
// Ensures bare root options like `--profile foo` still launch the TUI cleanly.
|
|
24
23
|
/**
|
|
25
24
|
* Root options, and how many argv slots each consumes AFTER itself.
|
|
26
25
|
*
|
package/src/tui/invocation.ts
CHANGED
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
// goes to Commander so Commander can report it, exactly as it does today.
|
|
20
20
|
// 2. `--` ends the scan. Anything after it is operands, not a command path.
|
|
21
21
|
//
|
|
22
|
-
//
|
|
23
|
-
// same reason: `openclaw --profile foo` must still launch the TUI.
|
|
22
|
+
// Ensures bare root options like `--profile foo` still launch the TUI cleanly.
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Root options, and how many argv slots each consumes AFTER itself.
|