@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.
Files changed (235) hide show
  1. package/bin/causyne.js +1 -1
  2. package/package.json +4 -4
  3. package/src/acp/protocol.ts +19 -1
  4. package/src/acp/server.js +282 -8
  5. package/src/acp/server.ts +284 -8
  6. package/src/agent/abortableDelay.js +2 -2
  7. package/src/agent/abortableDelay.ts +2 -2
  8. package/src/agent/errorClassifier.js +9 -1
  9. package/src/agent/errorClassifier.ts +8 -1
  10. package/src/agentLoop.js +83 -27
  11. package/src/agentLoop.ts +92 -26
  12. package/src/approvalPolicy.js +34 -10
  13. package/src/approvalPolicy.ts +42 -11
  14. package/src/browser/causyneBrowser.js +30 -3
  15. package/src/browser/causyneBrowser.ts +33 -3
  16. package/src/browser/urlPolicy.js +14 -1
  17. package/src/browser/urlPolicy.ts +12 -1
  18. package/src/cliMode.js +21 -9
  19. package/src/cliMode.ts +20 -8
  20. package/src/commands.js +188 -32
  21. package/src/commands.ts +209 -32
  22. package/src/config.js +19 -4
  23. package/src/config.ts +18 -4
  24. package/src/core/contextCompactor.js +54 -7
  25. package/src/core/contextCompactor.ts +63 -7
  26. package/src/core/goalLoop.js +257 -0
  27. package/src/core/goalLoop.ts +310 -0
  28. package/src/entrypoint.js +135 -3
  29. package/src/entrypoint.ts +136 -3
  30. package/src/game/causyneCoreBridge.js +686 -0
  31. package/src/game/causyneCoreBridge.ts +702 -0
  32. package/src/game/gameLauncher.js +287 -0
  33. package/src/game/gameLauncher.ts +352 -0
  34. package/src/game/gameProvisioner.js +425 -0
  35. package/src/game/gameProvisioner.ts +488 -0
  36. package/src/headlessCli.js +19 -12
  37. package/src/headlessCli.ts +22 -8
  38. package/src/infra/atomicWriter.js +40 -4
  39. package/src/infra/atomicWriter.ts +36 -4
  40. package/src/launchIntent.js +73 -3
  41. package/src/launchIntent.ts +76 -3
  42. package/src/lsp/lspClient.js +83 -12
  43. package/src/lsp/lspClient.ts +75 -12
  44. package/src/mcp/mcpRegistry.js +75 -8
  45. package/src/mcp/mcpRegistry.ts +70 -7
  46. package/src/memory/contextBudget.js +2 -0
  47. package/src/memory/contextBudget.ts +1 -0
  48. package/src/modelVariants.js +45 -0
  49. package/src/modelVariants.ts +54 -0
  50. package/src/outputRecovery.js +3 -2
  51. package/src/outputRecovery.ts +4 -2
  52. package/src/permissionPresets.js +327 -0
  53. package/src/permissionPresets.ts +361 -0
  54. package/src/providers/antigravity.js +62 -9
  55. package/src/providers/antigravity.ts +73 -9
  56. package/src/providers/byokHttp.js +7 -1
  57. package/src/providers/byokHttp.ts +6 -1
  58. package/src/providers/byokStream.js +21 -8
  59. package/src/providers/byokStream.ts +17 -7
  60. package/src/providers/dashscope-byok.js +21 -5
  61. package/src/providers/dashscope-byok.ts +29 -11
  62. package/src/providers/moonshot.js +26 -7
  63. package/src/providers/moonshot.ts +34 -13
  64. package/src/providers/muse.js +6 -0
  65. package/src/providers/muse.ts +8 -0
  66. package/src/providers/ollama.js +39 -7
  67. package/src/providers/ollama.ts +36 -7
  68. package/src/providers/openai-compatible.js +16 -3
  69. package/src/providers/openai-compatible.ts +13 -3
  70. package/src/providers/openai.js +62 -4
  71. package/src/providers/openai.ts +50 -4
  72. package/src/providers/openrouter.js +19 -4
  73. package/src/providers/openrouter.ts +21 -4
  74. package/src/providers/qwen-byok.js +21 -5
  75. package/src/providers/qwen-byok.ts +29 -11
  76. package/src/providers/xai.js +26 -10
  77. package/src/providers/xai.ts +34 -16
  78. package/src/reporting.js +4 -2
  79. package/src/reporting.ts +4 -2
  80. package/src/sandbox.js +34 -0
  81. package/src/sandbox.ts +43 -0
  82. package/src/scheduler/scheduler.js +372 -0
  83. package/src/scheduler/scheduler.ts +433 -0
  84. package/src/sessionSearchIndex.js +267 -0
  85. package/src/sessionSearchIndex.ts +311 -0
  86. package/src/skillsManager.js +2 -3
  87. package/src/skillsManager.ts +2 -3
  88. package/src/toolPacks.js +6 -0
  89. package/src/toolPacks.ts +6 -0
  90. package/src/tools/applyPatch.js +1 -1
  91. package/src/tools/applyPatch.ts +1 -1
  92. package/src/tools/generateMediaViaApi.js +4 -3
  93. package/src/tools/generateMediaViaApi.ts +4 -3
  94. package/src/tools/nativeEngine.js +2 -2
  95. package/src/tools/nativeEngine.ts +2 -2
  96. package/src/tools/openSourceToolProvisioner.js +2 -2
  97. package/src/tools/openSourceToolProvisioner.ts +2 -2
  98. package/src/tools/payloadSanitizer.js +0 -1
  99. package/src/tools/payloadSanitizer.ts +0 -1
  100. package/src/tools/pdfReader.js +122 -20
  101. package/src/tools/pdfReader.ts +111 -20
  102. package/src/tools/presentDeliverable.js +103 -0
  103. package/src/tools/presentDeliverable.ts +127 -0
  104. package/src/tools/ptcRuntime.js +444 -0
  105. package/src/tools/ptcRuntime.ts +490 -0
  106. package/src/tools/ptyTerminal.js +1096 -0
  107. package/src/tools/ptyTerminal.ts +1231 -0
  108. package/src/tools/registry.js +21 -12
  109. package/src/tools/registry.ts +21 -12
  110. package/src/tools/toolOutputStore.js +26 -4
  111. package/src/tools/toolOutputStore.ts +22 -4
  112. package/src/tools/webFetch.js +158 -11
  113. package/src/tools/webFetch.ts +145 -11
  114. package/src/tools/webSearch.js +123 -36
  115. package/src/tools/webSearch.ts +124 -33
  116. package/src/tui/banner.js +5 -1
  117. package/src/tui/banner.ts +6 -1
  118. package/src/tui/chatRenderer.js +1 -2
  119. package/src/tui/chatRenderer.ts +1 -2
  120. package/src/tui/completion.js +1 -0
  121. package/src/tui/completion.ts +1 -0
  122. package/src/tui/composerControls.js +111 -27
  123. package/src/tui/composerControls.ts +124 -28
  124. package/src/tui/dialogs.js +3 -16
  125. package/src/tui/dialogs.ts +3 -16
  126. package/src/tui/home.js +1 -0
  127. package/src/tui/home.ts +1 -0
  128. package/src/tui/invocation.js +1 -2
  129. package/src/tui/invocation.ts +1 -2
  130. package/src/tui/modelPicker.js +22 -12
  131. package/src/tui/modelPicker.ts +22 -12
  132. package/src/tui/overlay.js +2 -5
  133. package/src/tui/overlay.ts +2 -5
  134. package/src/tui/prompt.js +6 -4
  135. package/src/tui/prompt.ts +6 -4
  136. package/src/tui/selectList.js +4 -12
  137. package/src/tui/selectList.ts +4 -12
  138. package/src/tui/setup.js +22 -9
  139. package/src/tui/setup.ts +26 -9
  140. package/src/tui/statusLine.ts +2 -0
  141. package/src/web/client/browserPanel.js +702 -0
  142. package/src/web/client/browserPanel.ts +663 -0
  143. package/src/web/client/chatStream.js +309 -0
  144. package/src/web/client/chatStream.ts +289 -0
  145. package/src/web/client/cliPanel.js +165 -0
  146. package/src/web/client/cliPanel.ts +171 -0
  147. package/src/web/client/composer.js +204 -0
  148. package/src/web/client/composer.ts +209 -0
  149. package/src/web/client/diffPanel.js +176 -0
  150. package/src/web/client/diffPanel.ts +203 -0
  151. package/src/web/client/dom.js +220 -0
  152. package/src/web/client/dom.ts +221 -0
  153. package/src/web/client/filesAndCanvas.js +231 -0
  154. package/src/web/client/filesAndCanvas.ts +238 -0
  155. package/src/web/client/gameLauncherUi.js +78 -0
  156. package/src/web/client/gameLauncherUi.ts +78 -0
  157. package/src/web/client/main.js +301 -0
  158. package/src/web/client/main.ts +368 -0
  159. package/src/web/client/markdown.js +364 -0
  160. package/src/web/client/markdown.ts +373 -0
  161. package/src/web/client/modelPicker.js +455 -0
  162. package/src/web/client/modelPicker.ts +451 -0
  163. package/src/web/client/permissionPresetsUi.js +307 -0
  164. package/src/web/client/permissionPresetsUi.ts +333 -0
  165. package/src/web/client/sessions.js +353 -0
  166. package/src/web/client/sessions.ts +372 -0
  167. package/src/web/client/settingsModal.js +191 -0
  168. package/src/web/client/settingsModal.ts +176 -0
  169. package/src/web/client/state.js +250 -0
  170. package/src/web/client/state.ts +233 -0
  171. package/src/web/client/streamSmoother.js +127 -0
  172. package/src/web/client/streamSmoother.ts +119 -0
  173. package/src/web/client/studioLayout.js +54 -0
  174. package/src/web/client/studioLayout.ts +60 -0
  175. package/src/web/client/studioShell.js +327 -0
  176. package/src/web/client/studioShell.ts +340 -0
  177. package/src/web/client/studioStart.js +77 -0
  178. package/src/web/client/studioStart.ts +89 -0
  179. package/src/web/client/terminalPanel.js +357 -0
  180. package/src/web/client/terminalPanel.ts +345 -0
  181. package/src/web/client/turnView.js +934 -0
  182. package/src/web/client/turnView.ts +981 -0
  183. package/src/web/client/types.js +1 -0
  184. package/src/web/client/types.ts +319 -0
  185. package/src/web/client/validators.js +106 -0
  186. package/src/web/client/validators.ts +96 -0
  187. package/src/web/server/activeRuns.js +152 -0
  188. package/src/web/server/activeRuns.ts +171 -0
  189. package/src/web/server/routesBrowser.js +355 -0
  190. package/src/web/server/routesBrowser.ts +386 -0
  191. package/src/web/server/routesChat.js +304 -0
  192. package/src/web/server/routesChat.ts +347 -0
  193. package/src/web/server/routesCore.js +472 -0
  194. package/src/web/server/routesCore.ts +522 -0
  195. package/src/web/server/routesTerminal.js +162 -0
  196. package/src/web/server/routesTerminal.ts +182 -0
  197. package/src/web/server/routesWorkspace.js +510 -0
  198. package/src/web/server/routesWorkspace.ts +546 -0
  199. package/src/web/server/security.js +98 -0
  200. package/src/web/server/security.ts +108 -0
  201. package/src/web/server/sessionTranscript.js +586 -0
  202. package/src/web/server/sessionTranscript.ts +566 -0
  203. package/src/web/server/staticAssets.js +80 -0
  204. package/src/web/server/staticAssets.ts +91 -0
  205. package/src/web/server/types.js +1 -0
  206. package/src/web/server/types.ts +135 -0
  207. package/src/web/server/workspaceFiles.js +368 -0
  208. package/src/web/server/workspaceFiles.ts +363 -0
  209. package/src/web/skybridgeServer.js +76 -2449
  210. package/src/web/skybridgeServer.ts +118 -2600
  211. package/src/web/skybridgeUi.js +16 -450
  212. package/src/web/skybridgeUi.ts +16 -454
  213. package/src/web/styles/agent.css +380 -0
  214. package/src/web/styles/composer.css +193 -0
  215. package/src/web/styles/overlays.css +436 -0
  216. package/src/web/styles/shell.css +387 -0
  217. package/src/web/styles/studio.css +723 -0
  218. package/src/web/styles/thread.css +221 -0
  219. package/src/web/styles/tokens.css +94 -0
  220. package/src/web/ui/brandMark.js +73 -0
  221. package/src/web/ui/brandMark.ts +82 -0
  222. package/src/web/ui/modalsTemplate.js +139 -0
  223. package/src/web/ui/modalsTemplate.ts +139 -0
  224. package/src/web/ui/sidebarTemplate.js +63 -0
  225. package/src/web/ui/sidebarTemplate.ts +64 -0
  226. package/src/web/ui/studioTemplate.js +258 -0
  227. package/src/web/ui/studioTemplate.ts +258 -0
  228. package/src/web/ui/workspaceTemplate.js +72 -0
  229. package/src/web/ui/workspaceTemplate.ts +73 -0
  230. package/src/worktreeManager.js +16 -1
  231. package/src/worktreeManager.ts +22 -1
  232. package/src/web/skybridgeClientScript.js +0 -3951
  233. package/src/web/skybridgeClientScript.ts +0 -3952
  234. package/src/web/skybridgeStyles.js +0 -827
  235. package/src/web/skybridgeStyles.ts +0 -828
package/src/commands.js CHANGED
@@ -15,6 +15,7 @@ import { readCompiledSkill, listCompiledSkills, invalidateUserSkills, userSkillP
15
15
  import { userSkillsRoot, parseSkillId, writeUserSkill, deleteUserSkill, skillTemplate } from './userSkills.js';
16
16
  import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
17
17
  import { loadConfig, saveConfig } from './config.js';
18
+ import { getDefaultPermissionPreset, getPermissionPresetDescriptor, normalizePermissionPreset, setDefaultPermissionPreset } from './permissionPresets.js';
18
19
  import { resolveAvailableModels, getCuratedModels, getLiveAntigravityModels, getModelVariantsForPeer, getAvailableProvidersOverview, resolveAvailableProvidersOverview, pickDefaultPeerModel } from './dynamicCatalogue.js';
19
20
  import { DEFAULT_MODEL_BY_PROVIDER, PEER_MODEL_CATALOGUE } from './modelCatalogue.js';
20
21
  import { isAcpProvider } from './providers/acp.js';
@@ -61,6 +62,8 @@ import { buildRepoMap } from './codebase/repoMap.js';
61
62
  import { backgroundTaskManager } from './backgroundTasks.js';
62
63
  import { resolveModelVariants, matchVariantOption, normalizeVariantToken } from './modelVariants.js';
63
64
  import { launchGuiServer, getGuiServerStatus, stopGuiServer } from './web/guiLauncher.js';
65
+ import { launchGameStudio, getGameStudioStatus, stopGameStudio } from './game/gameLauncher.js';
66
+ import { defaultGameManifestUrl, installGameStudio, locateGameStudio } from './game/gameProvisioner.js';
64
67
  export const SCOPES = ['local'];
65
68
  function ok(output, extra = {}) {
66
69
  return { ok: true, output, ...extra };
@@ -203,12 +206,19 @@ async function applySelectedVariant(rawChoice, spec, config, ctx = {}) {
203
206
  const allowed = spec.options.map((o) => o.id).join(', ');
204
207
  return fail(`Variant "${safeDisplay(rawChoice)}" is not supported by ${safeDisplay(spec.model || spec.provider)}.\nSupported variants: ${allowed}, auto`);
205
208
  }
206
- config.reasoningEffort = matched.id;
207
209
  const modelChanged = Boolean(matched.targetModelId && matched.targetModelId !== config.model);
208
210
  if (matched.targetModelId) {
209
211
  config.model = matched.targetModelId;
210
212
  }
213
+ if (spec.source === 'agy_models') {
214
+ delete config.reasoningEffort;
215
+ delete config.reasoningBudgetTokens;
216
+ }
217
+ else {
218
+ config.reasoningEffort = matched.id;
219
+ }
211
220
  saveConfig(config);
221
+ const displayedVariant = spec.source === 'agy_models' ? '' : matched.id;
212
222
  let liveSynced = false;
213
223
  if (typeof ctx.loop?.llm?.applyVariant === 'function' && !modelChanged) {
214
224
  liveSynced = Boolean(await ctx.loop.llm.applyVariant(matched.id, matched.acpConfigId));
@@ -224,18 +234,18 @@ async function applySelectedVariant(rawChoice, spec, config, ctx = {}) {
224
234
  }
225
235
  if (ctx.prompt) {
226
236
  if (typeof ctx.prompt.updateModel === 'function') {
227
- ctx.prompt.updateModel(config.provider || spec.provider, config.model || spec.model, matched.id);
237
+ ctx.prompt.updateModel(config.provider || spec.provider, config.model || spec.model, displayedVariant);
228
238
  }
229
239
  else if (ctx.prompt.renderer?.status) {
230
240
  ctx.prompt.renderer.status.setSession({
231
241
  provider: config.provider || spec.provider,
232
242
  model: config.model || spec.model,
233
- variant: matched.id
243
+ variant: displayedVariant
234
244
  });
235
245
  ctx.prompt.surface?.setSessionInfo?.({
236
246
  provider: config.provider || spec.provider,
237
247
  model: config.model || spec.model,
238
- variant: matched.id
248
+ variant: displayedVariant
239
249
  });
240
250
  if (typeof ctx.prompt.scheduleDraw === 'function')
241
251
  ctx.prompt.scheduleDraw();
@@ -501,12 +511,10 @@ export const COMMANDS = [
501
511
  /**
502
512
  * Argument suggestions, offered as the user types `/skills <prefix>`.
503
513
  *
504
- * openclaw's contract (src/tui/commands.ts getArgumentCompletions): the
505
- * command owns its argument vocabulary and the prompt asks for it. Ranking
506
- * and filtering are the prompt's job — this returns the whole vocabulary and
507
- * completion.js scores it with the same function it uses for commands and
508
- * filenames, so `/skills doc` reaches devops/docker-multi-stage-builds by a
509
- * basename-prefix match rather than needing the domain typed first.
514
+ * The command owns its argument vocabulary and the prompt ranks and filters
515
+ * candidates using the shared fuzzy scorer, so `/skills doc` reaches
516
+ * `devops/docker-multi-stage-builds` by a basename-prefix match rather than
517
+ * requiring the domain to be typed first.
510
518
  *
511
519
  * Domains are offered alongside skills because `/skills devops` is a valid
512
520
  * argument in its own right.
@@ -2111,6 +2119,142 @@ export const COMMANDS = [
2111
2119
  return ok(outLines.join('\n'), { effect: 'inline' });
2112
2120
  }
2113
2121
  },
2122
+ {
2123
+ name: 'game',
2124
+ aliases: ['gamestudio', 'causyne-game'],
2125
+ scope: 'local',
2126
+ usage: '/game [open | status | stop | install [--yes] | --port <n> | --no-open]',
2127
+ description: 'Launch, inspect, stop, or install Causyne Game (official separate AI Game Studio)',
2128
+ complete: () => [
2129
+ { value: 'open', label: 'open', description: 'launch and open Causyne Game Studio in your browser' },
2130
+ { value: 'status', label: 'status', description: 'show Causyne Game installation and running server status' },
2131
+ { value: 'stop', label: 'stop', description: 'shut down the local Causyne Game server' },
2132
+ { value: 'install', label: 'install', description: 'check or download Causyne Game from the release manifest' },
2133
+ { value: '--no-open', label: '--no-open', description: 'start Causyne Game without automatically opening a browser tab' }
2134
+ ],
2135
+ run: async (argv, ctx = {}) => {
2136
+ const tokens = argv.map((t) => String(t || '').trim()).filter(Boolean);
2137
+ const first = (tokens[0] || 'open').toLowerCase();
2138
+ if (first === 'status') {
2139
+ const located = locateGameStudio();
2140
+ const status = getGameStudioStatus();
2141
+ const lines = ['Causyne Game Studio'];
2142
+ if (located) {
2143
+ lines.push(` Installed : yes (${located.source}${located.version ? ` · v${located.version}` : ''})`);
2144
+ lines.push(` Location : ${safeDisplay(located.dir)}`);
2145
+ lines.push(` Build : ${located.hasNodeModules && located.hasStudioBuild ? 'ready' : 'incomplete (run npm ci && npm run build:studio)'}`);
2146
+ }
2147
+ else {
2148
+ lines.push(' Installed : no (run /game install --yes or set CAUSYNE_GAME_DIR)');
2149
+ }
2150
+ lines.push(` Manifest : ${defaultGameManifestUrl()}`);
2151
+ if (status.running) {
2152
+ lines.push(` Server : running at ${status.url} (127.0.0.1 loopback only)`);
2153
+ lines.push(' Control : /game stop (also stops automatically on CLI exit)');
2154
+ }
2155
+ else {
2156
+ lines.push(' Server : not running (run /game to launch)');
2157
+ }
2158
+ return ok(lines.join('\n'), { effect: 'inline' });
2159
+ }
2160
+ if (first === 'stop' || first === 'close' || first === 'off') {
2161
+ const stopped = await stopGameStudio();
2162
+ if (ctx.prompt) {
2163
+ ctx.prompt.notice = stopped ? 'Causyne Game stopped' : 'Causyne Game was not running';
2164
+ ctx.prompt.scheduleDraw?.();
2165
+ }
2166
+ return ok(stopped ? 'Stopped local Causyne Game Studio server.' : 'Causyne Game Studio is not currently running.', { effect: 'inline' });
2167
+ }
2168
+ if (first === 'install') {
2169
+ const confirm = tokens.some((tok) => tok === '--yes' || tok === '-y' || tok === '--confirm');
2170
+ let manifestUrl;
2171
+ for (let i = 1; i < tokens.length; i++) {
2172
+ const tok = tokens[i];
2173
+ if (tok === '--manifest' && i + 1 < tokens.length) {
2174
+ manifestUrl = tokens[++i];
2175
+ }
2176
+ else if (tok.startsWith('--manifest=')) {
2177
+ manifestUrl = tok.slice('--manifest='.length);
2178
+ }
2179
+ }
2180
+ const res = await installGameStudio({ confirm, manifestUrl });
2181
+ if (res.requiresConsent) {
2182
+ const lines = [
2183
+ `Causyne Game v${res.version ?? 'latest'} is ready to install from ${safeDisplay(res.manifestUrl)}.`
2184
+ ];
2185
+ if (res.license)
2186
+ lines.push(` License : ${safeDisplay(res.license)}`);
2187
+ if (res.size)
2188
+ lines.push(` Size : ${(res.size / (1024 * 1024)).toFixed(1)} MB (SHA-256 verified)`);
2189
+ lines.push(' Confirm : run /game install --yes to download and install into ~/.causyne/game/');
2190
+ return ok(lines.join('\n'), { effect: 'inline' });
2191
+ }
2192
+ if (!res.success) {
2193
+ return fail(`Causyne Game install failed: ${safeDisplay(res.error || 'unknown error')}`);
2194
+ }
2195
+ return ok(res.alreadyInstalled
2196
+ ? `Causyne Game v${res.version ?? ''} is already installed at ${safeDisplay(res.path || '')}. Run /game to launch.`
2197
+ : `Installed Causyne Game v${res.version ?? ''} to ${safeDisplay(res.path || '')}. Run /game to launch.`, { effect: 'inline' });
2198
+ }
2199
+ let port = 0;
2200
+ let noOpen = false;
2201
+ for (let i = 0; i < tokens.length; i++) {
2202
+ const tok = tokens[i];
2203
+ const lower = tok.toLowerCase();
2204
+ if (lower === 'open' || lower === 'start')
2205
+ continue;
2206
+ if (lower === '--no-open' || lower === '--no-browser') {
2207
+ noOpen = true;
2208
+ continue;
2209
+ }
2210
+ if (lower === '--port' && i + 1 < tokens.length) {
2211
+ const parsed = Number.parseInt(tokens[++i], 10);
2212
+ if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) {
2213
+ return fail(`Invalid port "${safeDisplay(tokens[i])}". Expected 0-65535.`);
2214
+ }
2215
+ port = parsed;
2216
+ continue;
2217
+ }
2218
+ if (lower.startsWith('--port=')) {
2219
+ const rawPort = tok.slice('--port='.length);
2220
+ const parsed = Number.parseInt(rawPort, 10);
2221
+ if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) {
2222
+ return fail(`Invalid port "${safeDisplay(rawPort)}". Expected 0-65535.`);
2223
+ }
2224
+ port = parsed;
2225
+ continue;
2226
+ }
2227
+ return fail(`Unknown /game option "${safeDisplay(tok)}". Usage: /game [open | status | stop | install [--yes] | --port <n> | --no-open]`);
2228
+ }
2229
+ let launched;
2230
+ try {
2231
+ launched = await launchGameStudio({
2232
+ port,
2233
+ openBrowser: !noOpen
2234
+ });
2235
+ }
2236
+ catch (error) {
2237
+ return fail(error instanceof Error ? error.message : String(error));
2238
+ }
2239
+ if (ctx.prompt) {
2240
+ ctx.prompt.notice = `Causyne Game live at ${launched.origin}`;
2241
+ ctx.prompt.scheduleDraw?.();
2242
+ }
2243
+ const outLines = [
2244
+ launched.reused
2245
+ ? 'Causyne Game Studio is already running (127.0.0.1 loopback only):'
2246
+ : 'Causyne Game Studio started (127.0.0.1 loopback only · primary agent: Causyne Agent):',
2247
+ ` Open URL : ${launched.url}${launched.copiedToClipboard ? ' (copied to clipboard)' : ''}`,
2248
+ ` Source : ${launched.source}${launched.version ? ` (v${launched.version})` : ''} · ${safeDisplay(launched.dir)}`,
2249
+ ` Browser : ${launched.openedBrowser ? 'Opened in your default browser' : 'Open the URL above in your browser'}`
2250
+ ];
2251
+ if (launched.browserHint) {
2252
+ outLines.push(` Remote : ${safeDisplay(launched.browserHint)}`);
2253
+ }
2254
+ outLines.push(' Control : /game status | /game stop (auto-stops when CLI exits)');
2255
+ return ok(outLines.join('\n'), { effect: 'inline' });
2256
+ }
2257
+ },
2114
2258
  {
2115
2259
  name: 'openrouter',
2116
2260
  aliases: ['free'],
@@ -2917,46 +3061,58 @@ export const COMMANDS = [
2917
3061
  },
2918
3062
  {
2919
3063
  name: 'mode',
2920
- aliases: ['autonomy'],
3064
+ aliases: ['autonomy', 'permissions', 'permission'],
2921
3065
  scope: 'local',
2922
- usage: '/mode [A | B | C]',
2923
- description: 'View or switch autonomy mode (A: Ask, B: Balanced, C: Autonomous)',
2924
- dialogTitle: 'Autonomy Mode',
3066
+ usage: '/mode [read-only | workspace-write | full-access]',
3067
+ description: 'View or switch permission preset (Read Only, Workspace Write, Full access)',
3068
+ dialogTitle: 'Permission Preset',
2925
3069
  complete: () => [
2926
- { value: 'A', label: 'A', description: 'Ask — review actions before execution' },
2927
- { value: 'B', label: 'B', description: 'Balanced — normal supervised autonomy' },
2928
- { value: 'C', label: 'C', description: 'Autonomous — maximum runway within policy' }
3070
+ { value: 'read-only', label: 'Read Only', description: 'Inspect files and search without modifying workspace files' },
3071
+ { value: 'workspace-write', label: 'Workspace Write', description: 'Edit files inside workspace with approval for risky actions' },
3072
+ { value: 'full-access', label: 'Full access', description: 'Direct workspace edits and commands within safety guardrails' }
2929
3073
  ],
2930
3074
  run: async (argv, ctx = {}) => {
2931
3075
  const config = loadConfig();
2932
- const target = (argv[0] || '').toUpperCase().trim();
2933
- if (!target) {
3076
+ const rawTarget = (argv[0] || '').trim();
3077
+ if (!rawTarget) {
2934
3078
  if (ctx.prompt) {
2935
3079
  const { openModeControl } = await import('./tui/composerControls.js');
2936
3080
  if (ctx.loop) {
2937
3081
  openModeControl(ctx.prompt, ctx.loop);
2938
- return ok('Opened mode selector.', { effect: 'silent' });
3082
+ return ok('Opened permission preset selector.', { effect: 'silent' });
2939
3083
  }
2940
3084
  }
2941
- return ok(`Current autonomy mode: ${config.autonomyMode || 'B'}\nModes:\n A: Ask (confirm gated actions)\n B: Balanced (supervised execution)\n C: Autonomous (independent execution)`);
3085
+ const curPreset = getDefaultPermissionPreset();
3086
+ const curDesc = getPermissionPresetDescriptor(curPreset);
3087
+ return ok(`Current permission preset: ${curDesc.label} (${curPreset})\n`
3088
+ + `Presets:\n`
3089
+ + ` read-only Read Only — inspect and search without workspace writes\n`
3090
+ + ` workspace-write Workspace Write — edits scoped to workspace with approval gates\n`
3091
+ + ` full-access Full access — direct execution within safety guardrails`);
3092
+ }
3093
+ const preset = normalizePermissionPreset(rawTarget);
3094
+ if (!preset) {
3095
+ return fail(`Invalid permission preset "${rawTarget}". Choose read-only, workspace-write, or full-access.`);
2942
3096
  }
2943
- if (!['A', 'B', 'C'].includes(target)) {
2944
- return fail(`Invalid mode "${target}". Choose A, B, or C.`);
3097
+ const desc = getPermissionPresetDescriptor(preset);
3098
+ setDefaultPermissionPreset(preset);
3099
+ config.permissionPreset = preset;
3100
+ config.autonomyMode = desc.autonomyMode;
3101
+ if (ctx.loop && typeof ctx.loop.setPermissionPreset === 'function') {
3102
+ ctx.loop.setPermissionPreset(preset);
2945
3103
  }
2946
- config.autonomyMode = target;
2947
- saveConfig(config);
2948
- if (ctx.loop && typeof ctx.loop.setAutonomyMode === 'function') {
2949
- ctx.loop.setAutonomyMode(target);
3104
+ else if (ctx.loop && typeof ctx.loop.setAutonomyMode === 'function') {
3105
+ ctx.loop.setAutonomyMode(desc.autonomyMode);
2950
3106
  }
2951
3107
  if (ctx.prompt) {
2952
- ctx.prompt.renderer?.status?.setSession?.({ autonomyMode: target });
2953
- ctx.prompt.surface?.setSessionInfo?.({ autonomyMode: target });
2954
- ctx.prompt.notice = `Mode ${target} active`;
3108
+ ctx.prompt.renderer?.status?.setSession?.({ permissionPreset: preset, autonomyMode: desc.autonomyMode });
3109
+ ctx.prompt.surface?.setSessionInfo?.({ permissionPreset: preset, autonomyMode: desc.autonomyMode });
3110
+ ctx.prompt.notice = `${desc.label} active`;
2955
3111
  if (ctx.prompt.scheduleDraw)
2956
3112
  ctx.prompt.scheduleDraw();
2957
- return ok(`Autonomy mode switched to ${target}.`, { effect: 'inline' });
3113
+ return ok(`Permission preset switched to ${desc.label} (${preset}).`, { effect: 'inline' });
2958
3114
  }
2959
- return ok(`Autonomy mode switched to ${target}.`);
3115
+ return ok(`Permission preset switched to ${desc.label} (${preset}).`);
2960
3116
  }
2961
3117
  },
2962
3118
  {
package/src/commands.ts CHANGED
@@ -20,6 +20,12 @@ import {
20
20
  } from './userSkills.js';
21
21
  import { buildContextText, buildUsageText, buildCheckpointsText, buildUndoText, buildStatusText } from './reporting.js';
22
22
  import { loadConfig, saveConfig } from './config.js';
23
+ import {
24
+ getDefaultPermissionPreset,
25
+ getPermissionPresetDescriptor,
26
+ normalizePermissionPreset,
27
+ setDefaultPermissionPreset
28
+ } from './permissionPresets.js';
23
29
  import {
24
30
  resolveAvailableModels,
25
31
  getCuratedModels,
@@ -111,6 +117,16 @@ import {
111
117
  getGuiServerStatus,
112
118
  stopGuiServer
113
119
  } from './web/guiLauncher.js';
120
+ import {
121
+ launchGameStudio,
122
+ getGameStudioStatus,
123
+ stopGameStudio
124
+ } from './game/gameLauncher.js';
125
+ import {
126
+ defaultGameManifestUrl,
127
+ installGameStudio,
128
+ locateGameStudio
129
+ } from './game/gameProvisioner.js';
114
130
 
115
131
  export interface CommandCompletionItem {
116
132
  value: string;
@@ -313,13 +329,20 @@ async function applySelectedVariant(
313
329
  );
314
330
  }
315
331
 
316
- config.reasoningEffort = matched.id;
317
332
  const modelChanged = Boolean(matched.targetModelId && matched.targetModelId !== config.model);
318
333
  if (matched.targetModelId) {
319
334
  config.model = matched.targetModelId;
320
335
  }
336
+ if (spec.source === 'agy_models') {
337
+ delete config.reasoningEffort;
338
+ delete config.reasoningBudgetTokens;
339
+ } else {
340
+ config.reasoningEffort = matched.id;
341
+ }
321
342
  saveConfig(config);
322
343
 
344
+ const displayedVariant = spec.source === 'agy_models' ? '' : matched.id;
345
+
323
346
  let liveSynced = false;
324
347
  if (typeof ctx.loop?.llm?.applyVariant === 'function' && !modelChanged) {
325
348
  liveSynced = Boolean(await ctx.loop.llm.applyVariant(matched.id, matched.acpConfigId));
@@ -335,17 +358,17 @@ async function applySelectedVariant(
335
358
 
336
359
  if (ctx.prompt) {
337
360
  if (typeof ctx.prompt.updateModel === 'function') {
338
- ctx.prompt.updateModel(config.provider || spec.provider, config.model || spec.model, matched.id);
361
+ ctx.prompt.updateModel(config.provider || spec.provider, config.model || spec.model, displayedVariant);
339
362
  } else if (ctx.prompt.renderer?.status) {
340
363
  ctx.prompt.renderer.status.setSession({
341
364
  provider: config.provider || spec.provider,
342
365
  model: config.model || spec.model,
343
- variant: matched.id
366
+ variant: displayedVariant
344
367
  });
345
368
  ctx.prompt.surface?.setSessionInfo?.({
346
369
  provider: config.provider || spec.provider,
347
370
  model: config.model || spec.model,
348
- variant: matched.id
371
+ variant: displayedVariant
349
372
  });
350
373
  if (typeof ctx.prompt.scheduleDraw === 'function') ctx.prompt.scheduleDraw();
351
374
  }
@@ -615,12 +638,10 @@ export const COMMANDS: SlashCommandDefinition[] = [
615
638
  /**
616
639
  * Argument suggestions, offered as the user types `/skills <prefix>`.
617
640
  *
618
- * openclaw's contract (src/tui/commands.ts getArgumentCompletions): the
619
- * command owns its argument vocabulary and the prompt asks for it. Ranking
620
- * and filtering are the prompt's job — this returns the whole vocabulary and
621
- * completion.js scores it with the same function it uses for commands and
622
- * filenames, so `/skills doc` reaches devops/docker-multi-stage-builds by a
623
- * basename-prefix match rather than needing the domain typed first.
641
+ * The command owns its argument vocabulary and the prompt ranks and filters
642
+ * candidates using the shared fuzzy scorer, so `/skills doc` reaches
643
+ * `devops/docker-multi-stage-builds` by a basename-prefix match rather than
644
+ * requiring the domain to be typed first.
624
645
  *
625
646
  * Domains are offered alongside skills because `/skills devops` is a valid
626
647
  * argument in its own right.
@@ -2316,6 +2337,149 @@ export const COMMANDS: SlashCommandDefinition[] = [
2316
2337
  }
2317
2338
  },
2318
2339
 
2340
+ {
2341
+ name: 'game',
2342
+ aliases: ['gamestudio', 'causyne-game'],
2343
+ scope: 'local',
2344
+ usage: '/game [open | status | stop | install [--yes] | --port <n> | --no-open]',
2345
+ description: 'Launch, inspect, stop, or install Causyne Game (official separate AI Game Studio)',
2346
+ complete: () => [
2347
+ { value: 'open', label: 'open', description: 'launch and open Causyne Game Studio in your browser' },
2348
+ { value: 'status', label: 'status', description: 'show Causyne Game installation and running server status' },
2349
+ { value: 'stop', label: 'stop', description: 'shut down the local Causyne Game server' },
2350
+ { value: 'install', label: 'install', description: 'check or download Causyne Game from the release manifest' },
2351
+ { value: '--no-open', label: '--no-open', description: 'start Causyne Game without automatically opening a browser tab' }
2352
+ ],
2353
+ run: async (argv, ctx = {}) => {
2354
+ const tokens = argv.map((t) => String(t || '').trim()).filter(Boolean);
2355
+ const first = (tokens[0] || 'open').toLowerCase();
2356
+
2357
+ if (first === 'status') {
2358
+ const located = locateGameStudio();
2359
+ const status = getGameStudioStatus();
2360
+ const lines = ['Causyne Game Studio'];
2361
+ if (located) {
2362
+ lines.push(` Installed : yes (${located.source}${located.version ? ` · v${located.version}` : ''})`);
2363
+ lines.push(` Location : ${safeDisplay(located.dir)}`);
2364
+ lines.push(` Build : ${located.hasNodeModules && located.hasStudioBuild ? 'ready' : 'incomplete (run npm ci && npm run build:studio)'}`);
2365
+ } else {
2366
+ lines.push(' Installed : no (run /game install --yes or set CAUSYNE_GAME_DIR)');
2367
+ }
2368
+ lines.push(` Manifest : ${defaultGameManifestUrl()}`);
2369
+ if (status.running) {
2370
+ lines.push(` Server : running at ${status.url} (127.0.0.1 loopback only)`);
2371
+ lines.push(' Control : /game stop (also stops automatically on CLI exit)');
2372
+ } else {
2373
+ lines.push(' Server : not running (run /game to launch)');
2374
+ }
2375
+ return ok(lines.join('\n'), { effect: 'inline' });
2376
+ }
2377
+
2378
+ if (first === 'stop' || first === 'close' || first === 'off') {
2379
+ const stopped = await stopGameStudio();
2380
+ if (ctx.prompt) {
2381
+ ctx.prompt.notice = stopped ? 'Causyne Game stopped' : 'Causyne Game was not running';
2382
+ ctx.prompt.scheduleDraw?.();
2383
+ }
2384
+ return ok(
2385
+ stopped ? 'Stopped local Causyne Game Studio server.' : 'Causyne Game Studio is not currently running.',
2386
+ { effect: 'inline' }
2387
+ );
2388
+ }
2389
+
2390
+ if (first === 'install') {
2391
+ const confirm = tokens.some((tok) => tok === '--yes' || tok === '-y' || tok === '--confirm');
2392
+ let manifestUrl: string | undefined;
2393
+ for (let i = 1; i < tokens.length; i++) {
2394
+ const tok = tokens[i]!;
2395
+ if (tok === '--manifest' && i + 1 < tokens.length) {
2396
+ manifestUrl = tokens[++i];
2397
+ } else if (tok.startsWith('--manifest=')) {
2398
+ manifestUrl = tok.slice('--manifest='.length);
2399
+ }
2400
+ }
2401
+ const res = await installGameStudio({ confirm, manifestUrl });
2402
+ if (res.requiresConsent) {
2403
+ const lines = [
2404
+ `Causyne Game v${res.version ?? 'latest'} is ready to install from ${safeDisplay(res.manifestUrl)}.`
2405
+ ];
2406
+ if (res.license) lines.push(` License : ${safeDisplay(res.license)}`);
2407
+ if (res.size) lines.push(` Size : ${(res.size / (1024 * 1024)).toFixed(1)} MB (SHA-256 verified)`);
2408
+ lines.push(' Confirm : run /game install --yes to download and install into ~/.causyne/game/');
2409
+ return ok(lines.join('\n'), { effect: 'inline' });
2410
+ }
2411
+ if (!res.success) {
2412
+ return fail(`Causyne Game install failed: ${safeDisplay(res.error || 'unknown error')}`);
2413
+ }
2414
+ return ok(
2415
+ res.alreadyInstalled
2416
+ ? `Causyne Game v${res.version ?? ''} is already installed at ${safeDisplay(res.path || '')}. Run /game to launch.`
2417
+ : `Installed Causyne Game v${res.version ?? ''} to ${safeDisplay(res.path || '')}. Run /game to launch.`,
2418
+ { effect: 'inline' }
2419
+ );
2420
+ }
2421
+
2422
+ let port = 0;
2423
+ let noOpen = false;
2424
+ for (let i = 0; i < tokens.length; i++) {
2425
+ const tok = tokens[i]!;
2426
+ const lower = tok.toLowerCase();
2427
+ if (lower === 'open' || lower === 'start') continue;
2428
+ if (lower === '--no-open' || lower === '--no-browser') {
2429
+ noOpen = true;
2430
+ continue;
2431
+ }
2432
+ if (lower === '--port' && i + 1 < tokens.length) {
2433
+ const parsed = Number.parseInt(tokens[++i]!, 10);
2434
+ if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) {
2435
+ return fail(`Invalid port "${safeDisplay(tokens[i]!)}". Expected 0-65535.`);
2436
+ }
2437
+ port = parsed;
2438
+ continue;
2439
+ }
2440
+ if (lower.startsWith('--port=')) {
2441
+ const rawPort = tok.slice('--port='.length);
2442
+ const parsed = Number.parseInt(rawPort, 10);
2443
+ if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65535) {
2444
+ return fail(`Invalid port "${safeDisplay(rawPort)}". Expected 0-65535.`);
2445
+ }
2446
+ port = parsed;
2447
+ continue;
2448
+ }
2449
+ return fail(`Unknown /game option "${safeDisplay(tok)}". Usage: /game [open | status | stop | install [--yes] | --port <n> | --no-open]`);
2450
+ }
2451
+
2452
+ let launched;
2453
+ try {
2454
+ launched = await launchGameStudio({
2455
+ port,
2456
+ openBrowser: !noOpen
2457
+ });
2458
+ } catch (error) {
2459
+ return fail(error instanceof Error ? error.message : String(error));
2460
+ }
2461
+
2462
+ if (ctx.prompt) {
2463
+ ctx.prompt.notice = `Causyne Game live at ${launched.origin}`;
2464
+ ctx.prompt.scheduleDraw?.();
2465
+ }
2466
+
2467
+ const outLines = [
2468
+ launched.reused
2469
+ ? 'Causyne Game Studio is already running (127.0.0.1 loopback only):'
2470
+ : 'Causyne Game Studio started (127.0.0.1 loopback only · primary agent: Causyne Agent):',
2471
+ ` Open URL : ${launched.url}${launched.copiedToClipboard ? ' (copied to clipboard)' : ''}`,
2472
+ ` Source : ${launched.source}${launched.version ? ` (v${launched.version})` : ''} · ${safeDisplay(launched.dir)}`,
2473
+ ` Browser : ${launched.openedBrowser ? 'Opened in your default browser' : 'Open the URL above in your browser'}`
2474
+ ];
2475
+ if (launched.browserHint) {
2476
+ outLines.push(` Remote : ${safeDisplay(launched.browserHint)}`);
2477
+ }
2478
+ outLines.push(' Control : /game status | /game stop (auto-stops when CLI exits)');
2479
+ return ok(outLines.join('\n'), { effect: 'inline' });
2480
+ }
2481
+ },
2482
+
2319
2483
  {
2320
2484
  name: 'openrouter',
2321
2485
  aliases: ['free'],
@@ -3146,47 +3310,60 @@ export const COMMANDS: SlashCommandDefinition[] = [
3146
3310
 
3147
3311
  {
3148
3312
  name: 'mode',
3149
- aliases: ['autonomy'],
3313
+ aliases: ['autonomy', 'permissions', 'permission'],
3150
3314
  scope: 'local',
3151
- usage: '/mode [A | B | C]',
3152
- description: 'View or switch autonomy mode (A: Ask, B: Balanced, C: Autonomous)',
3153
- dialogTitle: 'Autonomy Mode',
3315
+ usage: '/mode [read-only | workspace-write | full-access]',
3316
+ description: 'View or switch permission preset (Read Only, Workspace Write, Full access)',
3317
+ dialogTitle: 'Permission Preset',
3154
3318
  complete: () => [
3155
- { value: 'A', label: 'A', description: 'Ask — review actions before execution' },
3156
- { value: 'B', label: 'B', description: 'Balanced — normal supervised autonomy' },
3157
- { value: 'C', label: 'C', description: 'Autonomous — maximum runway within policy' }
3319
+ { value: 'read-only', label: 'Read Only', description: 'Inspect files and search without modifying workspace files' },
3320
+ { value: 'workspace-write', label: 'Workspace Write', description: 'Edit files inside workspace with approval for risky actions' },
3321
+ { value: 'full-access', label: 'Full access', description: 'Direct workspace edits and commands within safety guardrails' }
3158
3322
  ],
3159
3323
  run: async (argv, ctx = {}) => {
3160
3324
  const config = loadConfig();
3161
- const target = (argv[0] || '').toUpperCase().trim();
3162
- if (!target) {
3325
+ const rawTarget = (argv[0] || '').trim();
3326
+ if (!rawTarget) {
3163
3327
  if (ctx.prompt) {
3164
3328
  const { openModeControl } = await import('./tui/composerControls.js');
3165
3329
  if (ctx.loop) {
3166
3330
  openModeControl(ctx.prompt, ctx.loop);
3167
- return ok('Opened mode selector.', { effect: 'silent' });
3331
+ return ok('Opened permission preset selector.', { effect: 'silent' });
3168
3332
  }
3169
3333
  }
3170
- return ok(`Current autonomy mode: ${config.autonomyMode || 'B'}\nModes:\n A: Ask (confirm gated actions)\n B: Balanced (supervised execution)\n C: Autonomous (independent execution)`);
3334
+ const curPreset = getDefaultPermissionPreset();
3335
+ const curDesc = getPermissionPresetDescriptor(curPreset);
3336
+ return ok(
3337
+ `Current permission preset: ${curDesc.label} (${curPreset})\n`
3338
+ + `Presets:\n`
3339
+ + ` read-only Read Only — inspect and search without workspace writes\n`
3340
+ + ` workspace-write Workspace Write — edits scoped to workspace with approval gates\n`
3341
+ + ` full-access Full access — direct execution within safety guardrails`
3342
+ );
3171
3343
  }
3172
3344
 
3173
- if (!['A', 'B', 'C'].includes(target)) {
3174
- return fail(`Invalid mode "${target}". Choose A, B, or C.`);
3345
+ const preset = normalizePermissionPreset(rawTarget);
3346
+ if (!preset) {
3347
+ return fail(`Invalid permission preset "${rawTarget}". Choose read-only, workspace-write, or full-access.`);
3175
3348
  }
3176
3349
 
3177
- config.autonomyMode = target;
3178
- saveConfig(config);
3179
- if (ctx.loop && typeof ctx.loop.setAutonomyMode === 'function') {
3180
- ctx.loop.setAutonomyMode(target);
3350
+ const desc = getPermissionPresetDescriptor(preset);
3351
+ setDefaultPermissionPreset(preset);
3352
+ config.permissionPreset = preset;
3353
+ config.autonomyMode = desc.autonomyMode;
3354
+ if (ctx.loop && typeof ctx.loop.setPermissionPreset === 'function') {
3355
+ ctx.loop.setPermissionPreset(preset);
3356
+ } else if (ctx.loop && typeof ctx.loop.setAutonomyMode === 'function') {
3357
+ ctx.loop.setAutonomyMode(desc.autonomyMode);
3181
3358
  }
3182
3359
  if (ctx.prompt) {
3183
- ctx.prompt.renderer?.status?.setSession?.({ autonomyMode: target });
3184
- ctx.prompt.surface?.setSessionInfo?.({ autonomyMode: target });
3185
- ctx.prompt.notice = `Mode ${target} active`;
3360
+ ctx.prompt.renderer?.status?.setSession?.({ permissionPreset: preset, autonomyMode: desc.autonomyMode });
3361
+ ctx.prompt.surface?.setSessionInfo?.({ permissionPreset: preset, autonomyMode: desc.autonomyMode });
3362
+ ctx.prompt.notice = `${desc.label} active`;
3186
3363
  if (ctx.prompt.scheduleDraw) ctx.prompt.scheduleDraw();
3187
- return ok(`Autonomy mode switched to ${target}.`, { effect: 'inline' });
3364
+ return ok(`Permission preset switched to ${desc.label} (${preset}).`, { effect: 'inline' });
3188
3365
  }
3189
- return ok(`Autonomy mode switched to ${target}.`);
3366
+ return ok(`Permission preset switched to ${desc.label} (${preset}).`);
3190
3367
  }
3191
3368
  },
3192
3369