@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/bin/causyne.js
CHANGED
|
@@ -19,7 +19,7 @@ process.once('exit', restoreTerminal);
|
|
|
19
19
|
function shouldSkipAutoUpdateCheck(argv) {
|
|
20
20
|
const tokens = Array.isArray(argv) ? argv.slice(2) : [];
|
|
21
21
|
const skipTokens = new Set([
|
|
22
|
-
'acp', 'web', 'gui', 'studio', 'browser-mcp',
|
|
22
|
+
'acp', 'web', 'gui', 'studio', 'game', 'browser-mcp',
|
|
23
23
|
'status', 'doctor', 'diff', 'license',
|
|
24
24
|
'context', 'usage', 'checkpoints', 'undo', 'mcp', 'peers',
|
|
25
25
|
'policy', 'audit', 'lsp', 'worktree', 'pr', 'rules', 'map',
|
|
@@ -17,10 +17,12 @@ The lockfile contained 47 dependency entries in total. Development and
|
|
|
17
17
|
platform-specific optional entries account for most of the graph.
|
|
18
18
|
|
|
19
19
|
The direct runtime dependencies are `@modelcontextprotocol/client`,
|
|
20
|
-
`acorn-walk`, and `commander`. Direct development dependencies are
|
|
20
|
+
`@xterm/addon-fit`, `@xterm/xterm`, `acorn-walk`, and `commander`. Direct development dependencies are
|
|
21
21
|
`@babel/parser`, `@modelcontextprotocol/node`, `@modelcontextprotocol/server`,
|
|
22
22
|
`@types/node`, `acorn`, `typescript`, and `zod`. The three direct MCP packages
|
|
23
|
-
are licensed under Apache-2.0
|
|
23
|
+
are licensed under Apache-2.0, and `@xterm/xterm` (6.0.0) and `@xterm/addon-fit`
|
|
24
|
+
(0.11.0) are licensed under MIT with zero transitive dependencies and zero
|
|
25
|
+
install scripts. Exact versions, transitive dependencies, license
|
|
24
26
|
identifiers, and integrity hashes are recorded in `package-lock.json`.
|
|
25
27
|
|
|
26
28
|
No dependency in the reviewed main lockfile was marked with an install script.
|
|
@@ -143,6 +145,38 @@ Tool contracts and headless substrate bindings are adapted under the terms of th
|
|
|
143
145
|
> SOFTWARE.
|
|
144
146
|
|
|
145
147
|
|
|
148
|
+
The interactive workspace terminal UI in `src/web/client/terminalTheme.ts` and
|
|
149
|
+
`src/web/client/terminalPanel.ts` integrates `@xterm/xterm` and `@xterm/addon-fit`
|
|
150
|
+
under the MIT License, and incorporates OSC color tracking, contrast-aware cursor
|
|
151
|
+
rendering, and side-panel dock interaction patterns adapted from MIT-licensed
|
|
152
|
+
open-source terminal and dock UI implementations:
|
|
153
|
+
|
|
154
|
+
> MIT License
|
|
155
|
+
>
|
|
156
|
+
> Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
157
|
+
> Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
158
|
+
> Copyright (c) Microsoft Corporation. All rights reserved.
|
|
159
|
+
> Copyright (c) 2026 DeepSeek
|
|
160
|
+
>
|
|
161
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
162
|
+
> of this software and associated documentation files (the "Software"), to deal
|
|
163
|
+
> in the Software without restriction, including without limitation the rights
|
|
164
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
165
|
+
> copies of the Software, and to permit persons to whom the Software is
|
|
166
|
+
> furnished to do so, subject to the following conditions:
|
|
167
|
+
>
|
|
168
|
+
> The above copyright notice and this permission notice shall be included in all
|
|
169
|
+
> copies or substantial portions of the Software.
|
|
170
|
+
>
|
|
171
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
172
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
173
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
174
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
175
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
176
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
177
|
+
> SOFTWARE.
|
|
178
|
+
|
|
179
|
+
|
|
146
180
|
Repository scanning found no third-party copyright header or license marker in
|
|
147
181
|
the project-authored source and skill files. That negative scan alone cannot
|
|
148
182
|
establish authorship or permission. On 2026-10-19, the licensor confirmed that
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@causyne/agent",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.128",
|
|
4
4
|
"description": "Agentic AI for software, tools, and computer workflows",
|
|
5
5
|
"main": "bin/causyne.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"prestart": "npm run build",
|
|
25
25
|
"start": "node ./bin/causyne.js",
|
|
26
26
|
"test": "node --test --import ./tests/helpers/isolateState.js \"tests/**/*.test.{js,ts}\"",
|
|
27
|
-
"build": "node scripts/compile_skills.js && tsc -p tsconfig.runtime.json",
|
|
27
|
+
"build": "node scripts/compile_skills.js && tsc -p tsconfig.runtime.json && tsc -p tsconfig.web.json",
|
|
28
28
|
"benchmark:plan-cache": "node src/benchmarks/planCache.js",
|
|
29
29
|
"check:release": "node scripts/check_release.js",
|
|
30
30
|
"check:public": "npm run check:release && node scripts/check_public_release.js",
|
|
31
31
|
"prepublishOnly": "npm run check:public && npm test && npm run typecheck:strict",
|
|
32
|
-
"typecheck": "tsc -p tsconfig.strict.json",
|
|
33
|
-
"typecheck:ts": "tsc -p tsconfig.strict.json",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.strict.json && tsc -p tsconfig.web.json --noEmit",
|
|
33
|
+
"typecheck:ts": "tsc -p tsconfig.strict.json && tsc -p tsconfig.web.json --noEmit",
|
|
34
34
|
"typecheck:strict": "npm run typecheck:ts",
|
|
35
35
|
"verify:features": "node scripts/verify-features.mjs",
|
|
36
36
|
"verify:ui": "node scripts/verify-ui.mjs",
|
|
@@ -60,6 +60,8 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@modelcontextprotocol/client": "^2.4.0",
|
|
63
|
+
"@xterm/addon-fit": "^0.11.0",
|
|
64
|
+
"@xterm/xterm": "^6.0.0",
|
|
63
65
|
"acorn-walk": "^8.3.5",
|
|
64
66
|
"commander": "^11.1.0"
|
|
65
67
|
},
|
package/src/acp/protocol.ts
CHANGED
|
@@ -373,7 +373,19 @@ export interface SetSessionModelRequest {
|
|
|
373
373
|
modelId: string;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
export
|
|
376
|
+
export interface SetSessionModelResponse {
|
|
377
|
+
configOptions?: SessionConfigOption[];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface SetSessionConfigOptionRequest {
|
|
381
|
+
sessionId: string;
|
|
382
|
+
configId: string;
|
|
383
|
+
value: string;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export interface SetSessionConfigOptionResponse {
|
|
387
|
+
configOptions?: SessionConfigOption[];
|
|
388
|
+
}
|
|
377
389
|
|
|
378
390
|
export interface AuthenticateRequest {
|
|
379
391
|
methodId: string;
|
|
@@ -534,8 +546,14 @@ export interface CurrentModeUpdateNotification {
|
|
|
534
546
|
currentModeId: string;
|
|
535
547
|
}
|
|
536
548
|
|
|
549
|
+
export interface ConfigOptionUpdateNotification {
|
|
550
|
+
sessionUpdate: 'config_option_update';
|
|
551
|
+
configOptions: SessionConfigOption[];
|
|
552
|
+
}
|
|
553
|
+
|
|
537
554
|
export type SessionUpdate =
|
|
538
555
|
| AgentMessageChunkUpdate
|
|
556
|
+
| ConfigOptionUpdateNotification
|
|
539
557
|
| AgentThoughtChunkUpdate
|
|
540
558
|
| UserMessageChunkUpdate
|
|
541
559
|
| ToolCallUpdateNotification
|
package/src/acp/server.js
CHANGED
|
@@ -4,10 +4,50 @@ import path from 'node:path';
|
|
|
4
4
|
import { StringDecoder } from 'node:string_decoder';
|
|
5
5
|
import { AgentLoop } from '../agentLoop.js';
|
|
6
6
|
import { createApprovalScope } from '../approvalGrants.js';
|
|
7
|
+
import { loadConfig } from '../config.js';
|
|
8
|
+
import { DEFAULT_MODEL_BY_PROVIDER, MODEL_CATALOGUE, PEER_MODEL_CATALOGUE } from '../modelCatalogue.js';
|
|
9
|
+
import { resolveModelVariants } from '../modelVariants.js';
|
|
10
|
+
import { McpClient } from '../mcp/mcpClient.js';
|
|
11
|
+
import { registerSessionMcpServers, unregisterSessionMcpServers } from '../mcp/mcpRegistry.js';
|
|
7
12
|
import { createSession, getSession, saveSessionMessages, forkSession } from '../sessionJournal.js';
|
|
8
13
|
import { isBlockedWorkspaceRoot } from '../sandboxPolicy.js';
|
|
9
14
|
import { safeDisplay } from '../tui/text.js';
|
|
10
15
|
import { ACP_ERROR_CODES, ACP_METHODS, ACP_PROTOCOL_VERSION, isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse } from './protocol.js';
|
|
16
|
+
const FORBIDDEN_ENV_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
17
|
+
const MAX_SESSION_MCP_SERVERS = 16;
|
|
18
|
+
function providerModelsForCatalogue(provider) {
|
|
19
|
+
const norm = provider.trim().toLowerCase();
|
|
20
|
+
if (!norm)
|
|
21
|
+
return [];
|
|
22
|
+
const peerKey = norm.startsWith('acp/') ? norm.slice(4) : norm;
|
|
23
|
+
if (Object.hasOwn(PEER_MODEL_CATALOGUE, peerKey)) {
|
|
24
|
+
return [...(PEER_MODEL_CATALOGUE[peerKey] ?? [])];
|
|
25
|
+
}
|
|
26
|
+
const providerLabelMatch = {
|
|
27
|
+
deepseek: ['DeepSeek'],
|
|
28
|
+
qwen: ['Qwen'],
|
|
29
|
+
dashscope: ['Qwen'],
|
|
30
|
+
'dashscope-byok': ['Qwen'],
|
|
31
|
+
anthropic: ['Anthropic'],
|
|
32
|
+
openai: ['OpenAI'],
|
|
33
|
+
gemini: ['Gemini'],
|
|
34
|
+
'gemini-free': ['Gemini (Free Tier)'],
|
|
35
|
+
moonshot: ['Moonshot'],
|
|
36
|
+
xai: ['xAI'],
|
|
37
|
+
groq: ['Groq (Free Tier)'],
|
|
38
|
+
cerebras: ['Cerebras (Free Tier)'],
|
|
39
|
+
openrouter: ['OpenRouter (Free Tier)'],
|
|
40
|
+
mistral: ['Mistral (Free Tier)']
|
|
41
|
+
};
|
|
42
|
+
const labels = providerLabelMatch[norm] ?? [];
|
|
43
|
+
const models = [];
|
|
44
|
+
for (const label of labels) {
|
|
45
|
+
const entries = MODEL_CATALOGUE[label];
|
|
46
|
+
if (Array.isArray(entries))
|
|
47
|
+
models.push(...entries);
|
|
48
|
+
}
|
|
49
|
+
return models;
|
|
50
|
+
}
|
|
11
51
|
const MODE_TO_AUTONOMY = {
|
|
12
52
|
autonomous: 'C',
|
|
13
53
|
standard: 'B',
|
|
@@ -165,6 +205,7 @@ export class AcpServer {
|
|
|
165
205
|
if (this.input && this.errorListener)
|
|
166
206
|
this.input.off('error', this.errorListener);
|
|
167
207
|
this.buffer = '';
|
|
208
|
+
const closingIds = [...this.sessions.keys()];
|
|
168
209
|
for (const session of this.sessions.values()) {
|
|
169
210
|
session.cancelled = true;
|
|
170
211
|
session.generation++;
|
|
@@ -176,6 +217,7 @@ export class AcpServer {
|
|
|
176
217
|
}
|
|
177
218
|
}
|
|
178
219
|
this.sessions.clear();
|
|
220
|
+
await Promise.allSettled(closingIds.map((id) => unregisterSessionMcpServers(id)));
|
|
179
221
|
for (const [id, pending] of this.pending) {
|
|
180
222
|
clearTimeout(pending.timer);
|
|
181
223
|
pending.reject(new Error('server stopped'));
|
|
@@ -271,6 +313,12 @@ export class AcpServer {
|
|
|
271
313
|
case ACP_METHODS.SET_MODE:
|
|
272
314
|
this.writeResult(request.id, this.setMode(request.params));
|
|
273
315
|
return;
|
|
316
|
+
case ACP_METHODS.SET_MODEL:
|
|
317
|
+
this.writeResult(request.id, this.setModel(request.params));
|
|
318
|
+
return;
|
|
319
|
+
case ACP_METHODS.SET_CONFIG_OPTION:
|
|
320
|
+
this.writeResult(request.id, this.setConfigOption(request.params));
|
|
321
|
+
return;
|
|
274
322
|
case ACP_METHODS.LIST:
|
|
275
323
|
this.writeResult(request.id, this.listSessions(request.params));
|
|
276
324
|
return;
|
|
@@ -316,23 +364,99 @@ export class AcpServer {
|
|
|
316
364
|
error.acpCode = ACP_ERROR_CODES.INVALID_PARAMS;
|
|
317
365
|
return error;
|
|
318
366
|
}
|
|
367
|
+
parseSessionMcpServers(raw, cwd) {
|
|
368
|
+
if (raw === undefined)
|
|
369
|
+
return [];
|
|
370
|
+
if (!Array.isArray(raw)) {
|
|
371
|
+
throw this.paramsError('mcpServers must be an array');
|
|
372
|
+
}
|
|
373
|
+
if (raw.length > MAX_SESSION_MCP_SERVERS) {
|
|
374
|
+
throw this.paramsError(`Maximum ${MAX_SESSION_MCP_SERVERS} MCP servers per session exceeded`);
|
|
375
|
+
}
|
|
376
|
+
const definitions = [];
|
|
377
|
+
for (const entry of raw) {
|
|
378
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
379
|
+
throw this.paramsError('Each MCP server entry must be an object');
|
|
380
|
+
}
|
|
381
|
+
const item = entry;
|
|
382
|
+
const rawType = typeof item.type === 'string' ? item.type.trim().toLowerCase() : '';
|
|
383
|
+
if (rawType === 'http' || rawType === 'sse' || typeof item.url === 'string') {
|
|
384
|
+
throw this.paramsError('HTTP/SSE MCP servers are not supported by this agent');
|
|
385
|
+
}
|
|
386
|
+
if (typeof item.name !== 'string' || !item.name.trim()) {
|
|
387
|
+
throw this.paramsError('Stdio MCP server requires a non-empty name');
|
|
388
|
+
}
|
|
389
|
+
if (typeof item.command !== 'string' || !item.command.trim()) {
|
|
390
|
+
throw this.paramsError('Stdio MCP server requires a non-empty command');
|
|
391
|
+
}
|
|
392
|
+
if (!Array.isArray(item.args) || !item.args.every((arg) => typeof arg === 'string')) {
|
|
393
|
+
throw this.paramsError('Stdio MCP server requires an args string array');
|
|
394
|
+
}
|
|
395
|
+
let env;
|
|
396
|
+
if (item.env !== undefined) {
|
|
397
|
+
const mapped = Object.create(null);
|
|
398
|
+
if (Array.isArray(item.env)) {
|
|
399
|
+
for (const pair of item.env) {
|
|
400
|
+
if (!pair || typeof pair !== 'object' || Array.isArray(pair)) {
|
|
401
|
+
throw this.paramsError('Stdio MCP server env entries must be { name, value } objects');
|
|
402
|
+
}
|
|
403
|
+
const rec = pair;
|
|
404
|
+
if (typeof rec.name !== 'string' || !rec.name || typeof rec.value !== 'string') {
|
|
405
|
+
throw this.paramsError('Stdio MCP server env entries require string name and value');
|
|
406
|
+
}
|
|
407
|
+
if (!FORBIDDEN_ENV_KEYS.has(rec.name))
|
|
408
|
+
mapped[rec.name] = rec.value;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
else if (typeof item.env === 'object' && item.env !== null) {
|
|
412
|
+
for (const [k, v] of Object.entries(item.env)) {
|
|
413
|
+
if (typeof v !== 'string') {
|
|
414
|
+
throw this.paramsError('Stdio MCP server env values must be strings');
|
|
415
|
+
}
|
|
416
|
+
if (!FORBIDDEN_ENV_KEYS.has(k))
|
|
417
|
+
mapped[k] = v;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
throw this.paramsError('Stdio MCP server env must be an array or object');
|
|
422
|
+
}
|
|
423
|
+
if (Object.keys(mapped).length > 0)
|
|
424
|
+
env = { ...mapped };
|
|
425
|
+
}
|
|
426
|
+
const def = {
|
|
427
|
+
name: item.name.trim(),
|
|
428
|
+
command: item.command.trim(),
|
|
429
|
+
args: [...item.args],
|
|
430
|
+
...(env ? { env } : {}),
|
|
431
|
+
cwd
|
|
432
|
+
};
|
|
433
|
+
const problem = McpClient.validateDefinition(def);
|
|
434
|
+
if (problem) {
|
|
435
|
+
throw this.paramsError(`Invalid MCP server "${def.name}": ${problem}`);
|
|
436
|
+
}
|
|
437
|
+
definitions.push(def);
|
|
438
|
+
}
|
|
439
|
+
return definitions;
|
|
440
|
+
}
|
|
319
441
|
newSession(params) {
|
|
320
442
|
if (!params || typeof params.cwd !== 'string' || !params.cwd.trim()) {
|
|
321
443
|
throw this.paramsError('session/new requires cwd');
|
|
322
444
|
}
|
|
323
|
-
if (params.mcpServers !== undefined && (!Array.isArray(params.mcpServers) || params.mcpServers.length > 0)) {
|
|
324
|
-
throw this.paramsError('MCP servers are not supported by this agent');
|
|
325
|
-
}
|
|
326
445
|
if (params.additionalDirectories !== undefined && (!Array.isArray(params.additionalDirectories) || params.additionalDirectories.length > 0)) {
|
|
327
446
|
throw this.paramsError('additionalDirectories is not supported by this agent');
|
|
328
447
|
}
|
|
329
448
|
const cwd = this.resolveWorkspace(params.cwd);
|
|
449
|
+
const mcpServers = this.parseSessionMcpServers(params.mcpServers, cwd);
|
|
330
450
|
this.bindWorkspace(cwd);
|
|
331
451
|
if (this.sessions.size >= MAX_SESSIONS) {
|
|
332
452
|
throw this.paramsError(`Maximum concurrent sessions (${MAX_SESSIONS}) exceeded`);
|
|
333
453
|
}
|
|
334
454
|
const record = createSession(cwd, 'Untitled', false);
|
|
335
455
|
const session = this.addSession(record.id, cwd, record.title, MODES.currentModeId);
|
|
456
|
+
if (mcpServers.length > 0) {
|
|
457
|
+
session.mcpServers = mcpServers;
|
|
458
|
+
registerSessionMcpServers(session.id, mcpServers);
|
|
459
|
+
}
|
|
336
460
|
return this.sessionResponse(session);
|
|
337
461
|
}
|
|
338
462
|
resolveWorkspace(cwd) {
|
|
@@ -389,10 +513,98 @@ export class AcpServer {
|
|
|
389
513
|
availableModes: MODES.availableModes.map((mode) => ({ ...mode }))
|
|
390
514
|
};
|
|
391
515
|
}
|
|
516
|
+
buildSessionCatalog(session) {
|
|
517
|
+
let config = {};
|
|
518
|
+
try {
|
|
519
|
+
config = loadConfig();
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
config = {};
|
|
523
|
+
}
|
|
524
|
+
const provider = typeof config.provider === 'string' && config.provider.trim()
|
|
525
|
+
? config.provider.trim()
|
|
526
|
+
: 'deepseek';
|
|
527
|
+
const configuredModel = typeof config.model === 'string' && config.model.trim()
|
|
528
|
+
? config.model.trim()
|
|
529
|
+
: (DEFAULT_MODEL_BY_PROVIDER[provider.toLowerCase()] || '');
|
|
530
|
+
const activeModel = session.model || configuredModel;
|
|
531
|
+
const seen = new Set();
|
|
532
|
+
const modelIds = [];
|
|
533
|
+
const addModel = (id) => {
|
|
534
|
+
const clean = id.trim();
|
|
535
|
+
if (!clean || seen.has(clean))
|
|
536
|
+
return;
|
|
537
|
+
seen.add(clean);
|
|
538
|
+
modelIds.push(clean);
|
|
539
|
+
};
|
|
540
|
+
if (activeModel)
|
|
541
|
+
addModel(activeModel);
|
|
542
|
+
if (configuredModel)
|
|
543
|
+
addModel(configuredModel);
|
|
544
|
+
for (const candidate of providerModelsForCatalogue(provider)) {
|
|
545
|
+
addModel(candidate);
|
|
546
|
+
if (modelIds.length >= 64)
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
const configOptions = [];
|
|
550
|
+
const primaryModelId = activeModel || modelIds[0];
|
|
551
|
+
if (modelIds.length > 0 && primaryModelId) {
|
|
552
|
+
configOptions.push({
|
|
553
|
+
id: 'model',
|
|
554
|
+
name: 'Model',
|
|
555
|
+
category: 'model',
|
|
556
|
+
type: 'select',
|
|
557
|
+
currentValue: primaryModelId,
|
|
558
|
+
options: modelIds.map((id) => ({ value: id, name: id }))
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
const currentVariant = session.variant
|
|
562
|
+
|| (typeof config.reasoningEffort === 'string' && config.reasoningEffort.trim() ? config.reasoningEffort.trim() : undefined);
|
|
563
|
+
if (activeModel) {
|
|
564
|
+
try {
|
|
565
|
+
const variantSpec = resolveModelVariants({
|
|
566
|
+
provider,
|
|
567
|
+
model: activeModel,
|
|
568
|
+
currentVariant: currentVariant ?? null
|
|
569
|
+
});
|
|
570
|
+
if (variantSpec.supported && variantSpec.options.length > 0) {
|
|
571
|
+
const resolvedVariant = currentVariant || variantSpec.defaultVariant || variantSpec.options[0]?.id;
|
|
572
|
+
configOptions.push({
|
|
573
|
+
id: 'thought_level',
|
|
574
|
+
name: 'Reasoning effort',
|
|
575
|
+
category: 'thought_level',
|
|
576
|
+
type: 'select',
|
|
577
|
+
...(resolvedVariant ? { currentValue: resolvedVariant } : {}),
|
|
578
|
+
options: variantSpec.options.map((opt) => ({
|
|
579
|
+
value: opt.id,
|
|
580
|
+
name: opt.label,
|
|
581
|
+
description: opt.description
|
|
582
|
+
}))
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
catch {
|
|
587
|
+
// Variant discovery is best-effort; never fail session creation.
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const models = modelIds.length > 0 && primaryModelId
|
|
591
|
+
? {
|
|
592
|
+
currentModelId: primaryModelId,
|
|
593
|
+
availableModels: modelIds.map((id) => ({ modelId: id, name: id }))
|
|
594
|
+
}
|
|
595
|
+
: undefined;
|
|
596
|
+
return {
|
|
597
|
+
...(models ? { models } : {}),
|
|
598
|
+
...(configOptions.length > 0 ? { configOptions } : {})
|
|
599
|
+
};
|
|
600
|
+
}
|
|
392
601
|
sessionResponse(session) {
|
|
602
|
+
const catalog = this.buildSessionCatalog(session);
|
|
393
603
|
return {
|
|
394
604
|
sessionId: session.id,
|
|
395
|
-
modes: this.modesFor(session)
|
|
605
|
+
modes: this.modesFor(session),
|
|
606
|
+
...(catalog.models ? { models: catalog.models } : {}),
|
|
607
|
+
...(catalog.configOptions ? { configOptions: catalog.configOptions } : {})
|
|
396
608
|
};
|
|
397
609
|
}
|
|
398
610
|
requireSession(sessionId) {
|
|
@@ -449,10 +661,23 @@ export class AcpServer {
|
|
|
449
661
|
send: (payload) => { if (acceptingEvents && !session.cancelled && this.sessions.get(session.id) === session)
|
|
450
662
|
this.onLoopPayload(session, payload); }
|
|
451
663
|
};
|
|
664
|
+
const peerMcpServers = Array.isArray(session.mcpServers) && session.mcpServers.length > 0
|
|
665
|
+
? session.mcpServers
|
|
666
|
+
.filter((def) => typeof def.command === 'string' && def.command.length > 0)
|
|
667
|
+
.map((def) => ({
|
|
668
|
+
name: def.name,
|
|
669
|
+
command: def.command,
|
|
670
|
+
args: Array.isArray(def.args) ? [...def.args] : [],
|
|
671
|
+
env: Object.entries(def.env ?? {}).map(([name, value]) => ({ name, value }))
|
|
672
|
+
}))
|
|
673
|
+
: [];
|
|
452
674
|
const loopOptions = {
|
|
453
675
|
workspaceRoot: session.cwd,
|
|
454
676
|
memorySessionId: session.memorySessionId,
|
|
455
|
-
approvalScope: session.approvalScope
|
|
677
|
+
approvalScope: session.approvalScope,
|
|
678
|
+
...(session.model ? { model: session.model } : {}),
|
|
679
|
+
...(session.variant ? { variant: session.variant } : {}),
|
|
680
|
+
...(peerMcpServers.length > 0 ? { peerMcpServers } : {})
|
|
456
681
|
};
|
|
457
682
|
let loop;
|
|
458
683
|
try {
|
|
@@ -756,6 +981,47 @@ export class AcpServer {
|
|
|
756
981
|
this.notify(session.id, { sessionUpdate: 'current_mode_update', currentModeId: session.modeId });
|
|
757
982
|
return {};
|
|
758
983
|
}
|
|
984
|
+
setModel(params) {
|
|
985
|
+
if (!params || typeof params.modelId !== 'string' || !params.modelId.trim()) {
|
|
986
|
+
throw this.paramsError('session/set_model requires a non-empty modelId');
|
|
987
|
+
}
|
|
988
|
+
const session = this.requireSession(params.sessionId);
|
|
989
|
+
const modelId = params.modelId.trim();
|
|
990
|
+
if (modelId.length > 200)
|
|
991
|
+
throw this.paramsError('modelId is too long');
|
|
992
|
+
session.model = modelId === 'default' ? undefined : modelId;
|
|
993
|
+
session.updatedAt = Date.now();
|
|
994
|
+
const { configOptions } = this.buildSessionCatalog(session);
|
|
995
|
+
if (configOptions) {
|
|
996
|
+
this.notify(session.id, { sessionUpdate: 'config_option_update', configOptions });
|
|
997
|
+
}
|
|
998
|
+
return configOptions ? { configOptions } : {};
|
|
999
|
+
}
|
|
1000
|
+
setConfigOption(params) {
|
|
1001
|
+
if (!params || typeof params.configId !== 'string' || typeof params.value !== 'string') {
|
|
1002
|
+
throw this.paramsError('session/set_config_option requires configId and value');
|
|
1003
|
+
}
|
|
1004
|
+
const session = this.requireSession(params.sessionId);
|
|
1005
|
+
const configId = params.configId.trim().toLowerCase();
|
|
1006
|
+
const value = params.value.trim();
|
|
1007
|
+
if (!value || value.length > 200)
|
|
1008
|
+
throw this.paramsError('Invalid config option value');
|
|
1009
|
+
if (configId === 'model') {
|
|
1010
|
+
session.model = value === 'default' ? undefined : value;
|
|
1011
|
+
}
|
|
1012
|
+
else if (configId === 'thought_level' || configId === 'reasoning_effort' || configId === 'thinking' || configId === 'effort') {
|
|
1013
|
+
session.variant = value === 'default' || value === 'auto' ? undefined : value;
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
throw this.paramsError(`Unknown config option: ${params.configId}`);
|
|
1017
|
+
}
|
|
1018
|
+
session.updatedAt = Date.now();
|
|
1019
|
+
const { configOptions } = this.buildSessionCatalog(session);
|
|
1020
|
+
if (configOptions) {
|
|
1021
|
+
this.notify(session.id, { sessionUpdate: 'config_option_update', configOptions });
|
|
1022
|
+
}
|
|
1023
|
+
return configOptions ? { configOptions } : {};
|
|
1024
|
+
}
|
|
759
1025
|
canonicalizePath(targetPath) {
|
|
760
1026
|
const resolved = path.resolve(targetPath);
|
|
761
1027
|
try {
|
|
@@ -793,6 +1059,7 @@ export class AcpServer {
|
|
|
793
1059
|
// Closing never blocks on cancellation.
|
|
794
1060
|
}
|
|
795
1061
|
this.sessions.delete(session.id);
|
|
1062
|
+
void unregisterSessionMcpServers(session.id);
|
|
796
1063
|
return {};
|
|
797
1064
|
}
|
|
798
1065
|
/** Resume a persisted conversation, replaying its transcript to the client. */
|
|
@@ -800,9 +1067,6 @@ export class AcpServer {
|
|
|
800
1067
|
if (!params || typeof params.sessionId !== 'string' || !params.sessionId) {
|
|
801
1068
|
throw this.paramsError('session/load requires sessionId');
|
|
802
1069
|
}
|
|
803
|
-
if (params.mcpServers !== undefined && (!Array.isArray(params.mcpServers) || params.mcpServers.length > 0)) {
|
|
804
|
-
throw this.paramsError('MCP servers are not supported by this agent');
|
|
805
|
-
}
|
|
806
1070
|
const live = this.sessions.get(params.sessionId);
|
|
807
1071
|
if (live) {
|
|
808
1072
|
if (params.cwd !== undefined && this.resolveWorkspace(params.cwd) !== live.cwd) {
|
|
@@ -811,7 +1075,12 @@ export class AcpServer {
|
|
|
811
1075
|
if (live.busy || live.pendingPrompts > 0) {
|
|
812
1076
|
throw this.paramsError('session is busy; cancel it before loading');
|
|
813
1077
|
}
|
|
1078
|
+
const mcpServers = this.parseSessionMcpServers(params.mcpServers, live.cwd);
|
|
814
1079
|
this.bindWorkspace(live.cwd);
|
|
1080
|
+
if (mcpServers.length > 0) {
|
|
1081
|
+
live.mcpServers = mcpServers;
|
|
1082
|
+
registerSessionMcpServers(live.id, mcpServers);
|
|
1083
|
+
}
|
|
815
1084
|
this.replayTranscript(live, getSession(live.memorySessionId)?.messages ?? []);
|
|
816
1085
|
return { modes: this.modesFor(live) };
|
|
817
1086
|
}
|
|
@@ -823,8 +1092,13 @@ export class AcpServer {
|
|
|
823
1092
|
if (record.workspace && this.canonicalizePath(record.workspace) !== cwd) {
|
|
824
1093
|
throw this.paramsError('session workspace does not match cwd');
|
|
825
1094
|
}
|
|
1095
|
+
const mcpServers = this.parseSessionMcpServers(params.mcpServers, cwd);
|
|
826
1096
|
this.bindWorkspace(cwd);
|
|
827
1097
|
const session = this.addSession(record.id, cwd, record.title, MODES.currentModeId);
|
|
1098
|
+
if (mcpServers.length > 0) {
|
|
1099
|
+
session.mcpServers = mcpServers;
|
|
1100
|
+
registerSessionMcpServers(session.id, mcpServers);
|
|
1101
|
+
}
|
|
828
1102
|
this.replayTranscript(session, record.messages);
|
|
829
1103
|
return { modes: this.modesFor(session) };
|
|
830
1104
|
}
|