@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.
Files changed (254) hide show
  1. package/bin/causyne.js +1 -1
  2. package/docs/THIRD_PARTY_NOTICES.md +36 -2
  3. package/package.json +6 -4
  4. package/src/acp/protocol.ts +19 -1
  5. package/src/acp/server.js +282 -8
  6. package/src/acp/server.ts +284 -8
  7. package/src/agent/abortableDelay.js +2 -2
  8. package/src/agent/abortableDelay.ts +2 -2
  9. package/src/agent/errorClassifier.js +9 -1
  10. package/src/agent/errorClassifier.ts +8 -1
  11. package/src/agentLoop.js +142 -53
  12. package/src/agentLoop.ts +151 -50
  13. package/src/approvalPolicy.js +34 -10
  14. package/src/approvalPolicy.ts +42 -11
  15. package/src/browser/causyneBrowser.js +61 -3
  16. package/src/browser/causyneBrowser.ts +65 -3
  17. package/src/browser/urlPolicy.js +14 -1
  18. package/src/browser/urlPolicy.ts +12 -1
  19. package/src/cliMode.js +21 -9
  20. package/src/cliMode.ts +20 -8
  21. package/src/commands.js +365 -45
  22. package/src/commands.ts +403 -45
  23. package/src/config.js +19 -4
  24. package/src/config.ts +18 -4
  25. package/src/core/contextCompactor.js +54 -7
  26. package/src/core/contextCompactor.ts +63 -7
  27. package/src/core/goalLoop.js +257 -0
  28. package/src/core/goalLoop.ts +310 -0
  29. package/src/entrypoint.js +135 -3
  30. package/src/entrypoint.ts +136 -3
  31. package/src/game/causyneCoreBridge.js +686 -0
  32. package/src/game/causyneCoreBridge.ts +702 -0
  33. package/src/game/gameLauncher.js +287 -0
  34. package/src/game/gameLauncher.ts +352 -0
  35. package/src/game/gameProvisioner.js +425 -0
  36. package/src/game/gameProvisioner.ts +488 -0
  37. package/src/headlessCli.js +19 -12
  38. package/src/headlessCli.ts +22 -8
  39. package/src/infra/atomicWriter.js +40 -4
  40. package/src/infra/atomicWriter.ts +36 -4
  41. package/src/launchIntent.js +73 -3
  42. package/src/launchIntent.ts +76 -3
  43. package/src/lsp/lspClient.js +83 -12
  44. package/src/lsp/lspClient.ts +75 -12
  45. package/src/mcp/mcpRegistry.js +75 -8
  46. package/src/mcp/mcpRegistry.ts +70 -7
  47. package/src/memory/contextBudget.js +2 -0
  48. package/src/memory/contextBudget.ts +1 -0
  49. package/src/memory/episodicStore.js +40 -0
  50. package/src/memory/episodicStore.ts +46 -0
  51. package/src/memory.js +67 -0
  52. package/src/memory.ts +65 -0
  53. package/src/modelVariants.js +45 -0
  54. package/src/modelVariants.ts +54 -0
  55. package/src/outputRecovery.js +3 -2
  56. package/src/outputRecovery.ts +4 -2
  57. package/src/permissionPresets.js +327 -0
  58. package/src/permissionPresets.ts +361 -0
  59. package/src/personalization.js +365 -0
  60. package/src/personalization.ts +471 -0
  61. package/src/projectInstructions.js +30 -10
  62. package/src/projectInstructions.ts +31 -12
  63. package/src/providers/acp.js +3 -2
  64. package/src/providers/acp.ts +3 -2
  65. package/src/providers/antigravity.js +64 -9
  66. package/src/providers/antigravity.ts +75 -9
  67. package/src/providers/byokHttp.js +7 -1
  68. package/src/providers/byokHttp.ts +6 -1
  69. package/src/providers/byokStream.js +21 -8
  70. package/src/providers/byokStream.ts +17 -7
  71. package/src/providers/dashscope-byok.js +21 -5
  72. package/src/providers/dashscope-byok.ts +29 -11
  73. package/src/providers/moonshot.js +26 -7
  74. package/src/providers/moonshot.ts +34 -13
  75. package/src/providers/muse.js +6 -0
  76. package/src/providers/muse.ts +8 -0
  77. package/src/providers/ollama.js +39 -7
  78. package/src/providers/ollama.ts +36 -7
  79. package/src/providers/openai-compatible.js +16 -3
  80. package/src/providers/openai-compatible.ts +13 -3
  81. package/src/providers/openai.js +62 -4
  82. package/src/providers/openai.ts +50 -4
  83. package/src/providers/openrouter.js +19 -4
  84. package/src/providers/openrouter.ts +21 -4
  85. package/src/providers/qwen-byok.js +21 -5
  86. package/src/providers/qwen-byok.ts +29 -11
  87. package/src/providers/xai.js +26 -10
  88. package/src/providers/xai.ts +34 -16
  89. package/src/reporting.js +4 -2
  90. package/src/reporting.ts +4 -2
  91. package/src/sandbox.js +34 -0
  92. package/src/sandbox.ts +43 -0
  93. package/src/scheduler/scheduler.js +372 -0
  94. package/src/scheduler/scheduler.ts +433 -0
  95. package/src/sessionSearchIndex.js +267 -0
  96. package/src/sessionSearchIndex.ts +311 -0
  97. package/src/skillsManager.js +2 -3
  98. package/src/skillsManager.ts +2 -3
  99. package/src/toolPacks.js +6 -0
  100. package/src/toolPacks.ts +6 -0
  101. package/src/tools/applyPatch.js +1 -1
  102. package/src/tools/applyPatch.ts +1 -1
  103. package/src/tools/generateMediaViaApi.js +4 -3
  104. package/src/tools/generateMediaViaApi.ts +4 -3
  105. package/src/tools/memoryWrite.js +15 -1
  106. package/src/tools/memoryWrite.ts +16 -1
  107. package/src/tools/nativeEngine.js +2 -2
  108. package/src/tools/nativeEngine.ts +2 -2
  109. package/src/tools/openSourceToolProvisioner.js +2 -2
  110. package/src/tools/openSourceToolProvisioner.ts +2 -2
  111. package/src/tools/osSandbox.js +1 -1
  112. package/src/tools/osSandbox.ts +1 -1
  113. package/src/tools/payloadSanitizer.js +0 -1
  114. package/src/tools/payloadSanitizer.ts +0 -1
  115. package/src/tools/pdfReader.js +122 -20
  116. package/src/tools/pdfReader.ts +111 -20
  117. package/src/tools/presentDeliverable.js +103 -0
  118. package/src/tools/presentDeliverable.ts +127 -0
  119. package/src/tools/ptcRuntime.js +444 -0
  120. package/src/tools/ptcRuntime.ts +490 -0
  121. package/src/tools/ptyTerminal.js +1108 -0
  122. package/src/tools/ptyTerminal.ts +1245 -0
  123. package/src/tools/registry.js +21 -12
  124. package/src/tools/registry.ts +21 -12
  125. package/src/tools/toolOutputStore.js +26 -4
  126. package/src/tools/toolOutputStore.ts +22 -4
  127. package/src/tools/webFetch.js +158 -11
  128. package/src/tools/webFetch.ts +145 -11
  129. package/src/tools/webSearch.js +123 -36
  130. package/src/tools/webSearch.ts +124 -33
  131. package/src/tui/banner.js +5 -1
  132. package/src/tui/banner.ts +6 -1
  133. package/src/tui/chatRenderer.js +1 -2
  134. package/src/tui/chatRenderer.ts +1 -2
  135. package/src/tui/completion.js +1 -0
  136. package/src/tui/completion.ts +1 -0
  137. package/src/tui/composerControls.js +111 -27
  138. package/src/tui/composerControls.ts +124 -28
  139. package/src/tui/dialogs.js +3 -16
  140. package/src/tui/dialogs.ts +3 -16
  141. package/src/tui/home.js +1 -0
  142. package/src/tui/home.ts +1 -0
  143. package/src/tui/invocation.js +1 -2
  144. package/src/tui/invocation.ts +1 -2
  145. package/src/tui/modelPicker.js +22 -12
  146. package/src/tui/modelPicker.ts +22 -12
  147. package/src/tui/overlay.js +2 -5
  148. package/src/tui/overlay.ts +2 -5
  149. package/src/tui/prompt.js +6 -4
  150. package/src/tui/prompt.ts +6 -4
  151. package/src/tui/selectList.js +4 -12
  152. package/src/tui/selectList.ts +4 -12
  153. package/src/tui/setup.js +22 -9
  154. package/src/tui/setup.ts +26 -9
  155. package/src/tui/statusLine.ts +2 -0
  156. package/src/web/client/browserPanel.js +905 -0
  157. package/src/web/client/browserPanel.ts +872 -0
  158. package/src/web/client/chatStream.js +321 -0
  159. package/src/web/client/chatStream.ts +297 -0
  160. package/src/web/client/cliPanel.js +165 -0
  161. package/src/web/client/cliPanel.ts +171 -0
  162. package/src/web/client/composer.js +204 -0
  163. package/src/web/client/composer.ts +209 -0
  164. package/src/web/client/diffPanel.js +176 -0
  165. package/src/web/client/diffPanel.ts +203 -0
  166. package/src/web/client/dom.js +271 -0
  167. package/src/web/client/dom.ts +272 -0
  168. package/src/web/client/filesAndCanvas.js +233 -0
  169. package/src/web/client/filesAndCanvas.ts +240 -0
  170. package/src/web/client/gameLauncherUi.js +78 -0
  171. package/src/web/client/gameLauncherUi.ts +78 -0
  172. package/src/web/client/main.js +316 -0
  173. package/src/web/client/main.ts +391 -0
  174. package/src/web/client/markdown.js +364 -0
  175. package/src/web/client/markdown.ts +373 -0
  176. package/src/web/client/modelPicker.js +455 -0
  177. package/src/web/client/modelPicker.ts +451 -0
  178. package/src/web/client/permissionPresetsUi.js +307 -0
  179. package/src/web/client/permissionPresetsUi.ts +333 -0
  180. package/src/web/client/sessions.js +353 -0
  181. package/src/web/client/sessions.ts +372 -0
  182. package/src/web/client/settingsModal.js +824 -0
  183. package/src/web/client/settingsModal.ts +959 -0
  184. package/src/web/client/state.js +280 -0
  185. package/src/web/client/state.ts +259 -0
  186. package/src/web/client/streamSmoother.js +127 -0
  187. package/src/web/client/streamSmoother.ts +119 -0
  188. package/src/web/client/studioLayout.js +89 -0
  189. package/src/web/client/studioLayout.ts +103 -0
  190. package/src/web/client/studioShell.js +660 -0
  191. package/src/web/client/studioShell.ts +672 -0
  192. package/src/web/client/studioStart.js +77 -0
  193. package/src/web/client/studioStart.ts +89 -0
  194. package/src/web/client/terminalPanel.js +606 -0
  195. package/src/web/client/terminalPanel.ts +632 -0
  196. package/src/web/client/terminalTheme.js +249 -0
  197. package/src/web/client/terminalTheme.ts +258 -0
  198. package/src/web/client/turnView.js +934 -0
  199. package/src/web/client/turnView.ts +981 -0
  200. package/src/web/client/types.js +1 -0
  201. package/src/web/client/types.ts +322 -0
  202. package/src/web/client/validators.js +147 -0
  203. package/src/web/client/validators.ts +140 -0
  204. package/src/web/server/activeRuns.js +152 -0
  205. package/src/web/server/activeRuns.ts +171 -0
  206. package/src/web/server/routesBrowser.js +409 -0
  207. package/src/web/server/routesBrowser.ts +435 -0
  208. package/src/web/server/routesChat.js +304 -0
  209. package/src/web/server/routesChat.ts +347 -0
  210. package/src/web/server/routesCore.js +472 -0
  211. package/src/web/server/routesCore.ts +522 -0
  212. package/src/web/server/routesSettings.js +344 -0
  213. package/src/web/server/routesSettings.ts +397 -0
  214. package/src/web/server/routesTerminal.js +162 -0
  215. package/src/web/server/routesTerminal.ts +182 -0
  216. package/src/web/server/routesWorkspace.js +510 -0
  217. package/src/web/server/routesWorkspace.ts +546 -0
  218. package/src/web/server/security.js +98 -0
  219. package/src/web/server/security.ts +108 -0
  220. package/src/web/server/sessionTranscript.js +586 -0
  221. package/src/web/server/sessionTranscript.ts +566 -0
  222. package/src/web/server/staticAssets.js +104 -0
  223. package/src/web/server/staticAssets.ts +116 -0
  224. package/src/web/server/types.js +1 -0
  225. package/src/web/server/types.ts +135 -0
  226. package/src/web/server/workspaceFiles.js +368 -0
  227. package/src/web/server/workspaceFiles.ts +363 -0
  228. package/src/web/skybridgeServer.js +78 -2448
  229. package/src/web/skybridgeServer.ts +120 -2600
  230. package/src/web/skybridgeUi.js +20 -450
  231. package/src/web/skybridgeUi.ts +24 -455
  232. package/src/web/styles/agent.css +380 -0
  233. package/src/web/styles/composer.css +193 -0
  234. package/src/web/styles/overlays.css +935 -0
  235. package/src/web/styles/shell.css +387 -0
  236. package/src/web/styles/studio.css +951 -0
  237. package/src/web/styles/thread.css +221 -0
  238. package/src/web/styles/tokens.css +94 -0
  239. package/src/web/ui/brandMark.js +73 -0
  240. package/src/web/ui/brandMark.ts +82 -0
  241. package/src/web/ui/modalsTemplate.js +388 -0
  242. package/src/web/ui/modalsTemplate.ts +388 -0
  243. package/src/web/ui/sidebarTemplate.js +63 -0
  244. package/src/web/ui/sidebarTemplate.ts +64 -0
  245. package/src/web/ui/studioTemplate.js +256 -0
  246. package/src/web/ui/studioTemplate.ts +256 -0
  247. package/src/web/ui/workspaceTemplate.js +72 -0
  248. package/src/web/ui/workspaceTemplate.ts +73 -0
  249. package/src/worktreeManager.js +16 -1
  250. package/src/worktreeManager.ts +22 -1
  251. package/src/web/skybridgeClientScript.js +0 -3951
  252. package/src/web/skybridgeClientScript.ts +0 -3952
  253. package/src/web/skybridgeStyles.js +0 -827
  254. 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
- info.autonomyMode ? `mode ${info.autonomyMode}` : info.mode,
365
+ permDisplay,
361
366
  info.tier ? `tier ${info.tier}` : undefined
362
367
  ].filter((part): part is string => Boolean(part));
363
368
  return {
@@ -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;
@@ -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.
@@ -147,6 +147,7 @@ function commandItems(query = '') {
147
147
  'plugins',
148
148
  'cortex',
149
149
  'gui',
150
+ 'game',
150
151
  'compact',
151
152
  'undo',
152
153
  'diff',
@@ -192,6 +192,7 @@ function commandItems(query = ''): CompletionItem[] {
192
192
  'plugins',
193
193
  'cortex',
194
194
  'gui',
195
+ 'game',
195
196
  'compact',
196
197
  'undo',
197
198
  'diff',
@@ -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 config = loadConfig();
10
- const current = String(config.autonomyMode || 'B').toUpperCase();
10
+ const current = getDefaultPermissionPreset();
11
11
  prompt.openLayer(new SelectLayer({
12
- title: 'Autonomy mode',
13
- items: [
14
- { id: 'A', label: 'A · Ask', description: 'Review actions before execution', value: 'A' },
15
- { id: 'B', label: 'B · Balanced', description: 'Work independently within permission boundaries', value: 'B' },
16
- { id: 'C', label: 'C · Autonomous', description: 'Continue within the selected workspace and policy', value: 'C' }
17
- ].map(item => ({ ...item, label: `${item.label}${item.value === current ? ' (active)' : ''}` })),
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
- if (!item?.value)
20
+ const chosen = normalizePermissionPreset(item?.value);
21
+ if (!chosen)
20
22
  return;
21
- config.autonomyMode = item.value;
22
- saveConfig(config);
23
- loop.setAutonomyMode(item.value);
24
- prompt.renderer?.status?.setSession?.({ autonomyMode: item.value });
25
- prompt.surface?.setSessionInfo?.({ autonomyMode: item.value });
26
- prompt.notice = `Mode ${item.value} active`;
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 config = loadConfig();
59
- const order = ['A', 'B', 'C'];
60
- const current = String(loop?.config?.autonomyMode || config.autonomyMode || 'B').toUpperCase();
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
- config.autonomyMode = next;
64
- saveConfig(config);
65
- loop.setAutonomyMode(next);
66
- prompt.renderer?.status?.setSession?.({ autonomyMode: next });
67
- prompt.surface?.setSessionInfo?.({ autonomyMode: next });
68
- const labels = { A: 'Ask', B: 'Balanced', C: 'Autonomous' };
69
- prompt.notice = `Mode ${next} · ${labels[next]} (Shift+Tab cycle · Ctrl+G menu)`;
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
- prompt.deliver(`/variant ${nextVal}`);
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
- prompt.deliver(`/variant ${item.value}`);
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 config = loadConfig();
23
- const current = String(config.autonomyMode || 'B').toUpperCase();
31
+ const current = getDefaultPermissionPreset();
24
32
  prompt.openLayer(new SelectLayer({
25
- title: 'Autonomy mode',
26
- items: [
27
- { id: 'A', label: 'A · Ask', description: 'Review actions before execution', value: 'A' },
28
- { id: 'B', label: 'B · Balanced', description: 'Work independently within permission boundaries', value: 'B' },
29
- { id: 'C', label: 'C · Autonomous', description: 'Continue within the selected workspace and policy', value: 'C' }
30
- ].map(item => ({ ...item, label: `${item.label}${item.value === current ? ' (active)' : ''}` })),
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
- if (!item?.value) return;
33
- config.autonomyMode = item.value;
34
- saveConfig(config);
35
- loop.setAutonomyMode(item.value);
36
- (prompt as any).renderer?.status?.setSession?.({ autonomyMode: item.value });
37
- (prompt as any).surface?.setSessionInfo?.({ autonomyMode: item.value });
38
- prompt.notice = `Mode ${item.value} active`;
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 config = loadConfig();
69
- const order = ['A', 'B', 'C'] as const;
70
- const current = String(loop?.config?.autonomyMode || config.autonomyMode || 'B').toUpperCase();
71
- const idx = order.indexOf(current as (typeof order)[number]);
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
- config.autonomyMode = next;
74
- saveConfig(config);
75
- loop.setAutonomyMode(next);
76
- (prompt as any).renderer?.status?.setSession?.({ autonomyMode: next });
77
- (prompt as any).surface?.setSessionInfo?.({ autonomyMode: next });
78
- const labels: Record<string, string> = { A: 'Ask', B: 'Balanced', C: 'Autonomous' };
79
- prompt.notice = `Mode ${next} · ${labels[next]} (Shift+Tab cycle · Ctrl+G menu)`;
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
- prompt.deliver(`/variant ${nextVal}`);
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
- prompt.deliver(`/variant ${item.value}`);
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
  }
@@ -1,20 +1,7 @@
1
- // The concrete dialogs.
2
- //
3
- // Every one of these is the SelectList or a scrolling text pane inside a Layer.
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';
@@ -1,20 +1,7 @@
1
- // The concrete dialogs.
2
- //
3
- // Every one of these is the SelectList or a scrolling text pane inside a Layer.
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',
@@ -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
- // Modelled on openclaw's getRootOptionAwareCommandPath, which exists for the
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
  *
@@ -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
- // Modelled on openclaw's getRootOptionAwareCommandPath, which exists for the
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.