@causyne/agent 1.20.124 → 1.20.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/causyne.js +1 -1
- package/package.json +4 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +83 -27
- package/src/agentLoop.ts +92 -26
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +30 -3
- package/src/browser/causyneBrowser.ts +33 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +188 -32
- package/src/commands.ts +209 -32
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/providers/antigravity.js +62 -9
- package/src/providers/antigravity.ts +73 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1096 -0
- package/src/tools/ptyTerminal.ts +1231 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +702 -0
- package/src/web/client/browserPanel.ts +663 -0
- package/src/web/client/chatStream.js +309 -0
- package/src/web/client/chatStream.ts +289 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +220 -0
- package/src/web/client/dom.ts +221 -0
- package/src/web/client/filesAndCanvas.js +231 -0
- package/src/web/client/filesAndCanvas.ts +238 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +301 -0
- package/src/web/client/main.ts +368 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +191 -0
- package/src/web/client/settingsModal.ts +176 -0
- package/src/web/client/state.js +250 -0
- package/src/web/client/state.ts +233 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +54 -0
- package/src/web/client/studioLayout.ts +60 -0
- package/src/web/client/studioShell.js +327 -0
- package/src/web/client/studioShell.ts +340 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +357 -0
- package/src/web/client/terminalPanel.ts +345 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +319 -0
- package/src/web/client/validators.js +106 -0
- package/src/web/client/validators.ts +96 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +355 -0
- package/src/web/server/routesBrowser.ts +386 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +80 -0
- package/src/web/server/staticAssets.ts +91 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +76 -2449
- package/src/web/skybridgeServer.ts +118 -2600
- package/src/web/skybridgeUi.js +16 -450
- package/src/web/skybridgeUi.ts +16 -454
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +436 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +723 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +139 -0
- package/src/web/ui/modalsTemplate.ts +139 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +258 -0
- package/src/web/ui/studioTemplate.ts +258 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- package/src/web/skybridgeStyles.ts +0 -828
package/src/mcp/mcpRegistry.js
CHANGED
|
@@ -18,6 +18,7 @@ const pendingClients = new Map();
|
|
|
18
18
|
const statuses = new Map();
|
|
19
19
|
const connectionEpochs = new Map();
|
|
20
20
|
const failureBackoff = new Map();
|
|
21
|
+
const sessionServers = new Map();
|
|
21
22
|
let activeWorkspaceRoot = null;
|
|
22
23
|
export function setActiveWorkspace(workspace) {
|
|
23
24
|
if (typeof workspace !== 'string' || !workspace.trim() || workspace.includes('\0'))
|
|
@@ -282,6 +283,66 @@ export function configuredServers() {
|
|
|
282
283
|
return [];
|
|
283
284
|
return servers.map(normalizeDefinition).filter((server) => server !== null);
|
|
284
285
|
}
|
|
286
|
+
function findSessionServer(name) {
|
|
287
|
+
for (const map of sessionServers.values()) {
|
|
288
|
+
const found = map.get(name);
|
|
289
|
+
if (found)
|
|
290
|
+
return found;
|
|
291
|
+
}
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
function effectiveServers() {
|
|
295
|
+
const base = configuredServers();
|
|
296
|
+
if (sessionServers.size === 0)
|
|
297
|
+
return base;
|
|
298
|
+
const seen = new Set(base.map(server => server.name));
|
|
299
|
+
const merged = [...base];
|
|
300
|
+
for (const map of sessionServers.values()) {
|
|
301
|
+
for (const def of map.values()) {
|
|
302
|
+
if (seen.has(def.name))
|
|
303
|
+
continue;
|
|
304
|
+
seen.add(def.name);
|
|
305
|
+
merged.push(def);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return merged;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Register in-memory, session-scoped MCP servers passed by a trusted ACP host
|
|
312
|
+
* (such as Causyne Game). Never written to user config.json; disconnected when
|
|
313
|
+
* the ACP session closes.
|
|
314
|
+
*/
|
|
315
|
+
export function registerSessionMcpServers(sessionId, definitions) {
|
|
316
|
+
if (!sessionId || !Array.isArray(definitions) || definitions.length === 0)
|
|
317
|
+
return [];
|
|
318
|
+
const bucket = sessionServers.get(sessionId) ?? new Map();
|
|
319
|
+
const added = [];
|
|
320
|
+
for (const raw of definitions) {
|
|
321
|
+
const normalized = normalizeDefinition(raw);
|
|
322
|
+
if (!normalized)
|
|
323
|
+
continue;
|
|
324
|
+
bucket.set(normalized.name, normalized);
|
|
325
|
+
failureBackoff.delete(normalized.name);
|
|
326
|
+
added.push(normalized.name);
|
|
327
|
+
}
|
|
328
|
+
if (bucket.size > 0)
|
|
329
|
+
sessionServers.set(sessionId, bucket);
|
|
330
|
+
return added;
|
|
331
|
+
}
|
|
332
|
+
export async function unregisterSessionMcpServers(sessionId) {
|
|
333
|
+
const bucket = sessionServers.get(sessionId);
|
|
334
|
+
if (!bucket)
|
|
335
|
+
return;
|
|
336
|
+
const names = [...bucket.keys()];
|
|
337
|
+
sessionServers.delete(sessionId);
|
|
338
|
+
const configured = new Set(configuredServers().map(server => server.name));
|
|
339
|
+
await Promise.allSettled(names.map(async (name) => {
|
|
340
|
+
if (configured.has(name) || findSessionServer(name))
|
|
341
|
+
return;
|
|
342
|
+
await disconnectServer(name);
|
|
343
|
+
statuses.delete(name);
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
285
346
|
export function addServer(value) {
|
|
286
347
|
const problem = McpClient.validateDefinition(value);
|
|
287
348
|
if (problem)
|
|
@@ -319,10 +380,14 @@ export function removeServer(name) {
|
|
|
319
380
|
}
|
|
320
381
|
export function isServerGranted(name) {
|
|
321
382
|
const definition = configuredServers().find(server => server.name === name);
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
383
|
+
if (definition) {
|
|
384
|
+
if (definition.enabled === false)
|
|
385
|
+
return false;
|
|
386
|
+
const consent = consentRecord(config().mcpConsent?.[name]);
|
|
387
|
+
return consent?.digest === definitionDigest(definition);
|
|
388
|
+
}
|
|
389
|
+
const sessionDef = findSessionServer(name);
|
|
390
|
+
return Boolean(sessionDef && sessionDef.enabled !== false);
|
|
326
391
|
}
|
|
327
392
|
export function grantServer(name) {
|
|
328
393
|
const definition = configuredServers().find(server => server.name === name);
|
|
@@ -368,7 +433,7 @@ export function parseToolName(name) {
|
|
|
368
433
|
return { server, tool };
|
|
369
434
|
}
|
|
370
435
|
export async function connectServer(name) {
|
|
371
|
-
const definition =
|
|
436
|
+
const definition = effectiveServers().find(server => server.name === name);
|
|
372
437
|
if (!definition)
|
|
373
438
|
throw new Error(`no MCP server named "${name}" is configured`);
|
|
374
439
|
if (definition.enabled === false) {
|
|
@@ -403,7 +468,7 @@ export async function connectServer(name) {
|
|
|
403
468
|
statuses.set(name, { state: 'connecting' });
|
|
404
469
|
try {
|
|
405
470
|
await client.connect();
|
|
406
|
-
const current =
|
|
471
|
+
const current = effectiveServers().find(server => server.name === name);
|
|
407
472
|
const connectionIsCurrent = connectionEpoch(name) === startedAtEpoch
|
|
408
473
|
&& current !== undefined
|
|
409
474
|
&& definitionDigest(current) === definitionDigest(definition)
|
|
@@ -463,7 +528,7 @@ export async function refreshServer(name) {
|
|
|
463
528
|
return client.refreshTools();
|
|
464
529
|
}
|
|
465
530
|
export async function discoverTools() {
|
|
466
|
-
const granted =
|
|
531
|
+
const granted = effectiveServers().filter(server => isServerGranted(server.name));
|
|
467
532
|
const now = Date.now();
|
|
468
533
|
const results = await Promise.all(granted.map(async (server) => {
|
|
469
534
|
const backoff = failureBackoff.get(server.name);
|
|
@@ -495,7 +560,7 @@ export function resolveMcpTool(name) {
|
|
|
495
560
|
const parsed = parseToolName(name);
|
|
496
561
|
if (!parsed)
|
|
497
562
|
return null;
|
|
498
|
-
const definition =
|
|
563
|
+
const definition = effectiveServers().find(server => server.name === parsed.server);
|
|
499
564
|
if (!definition)
|
|
500
565
|
return null;
|
|
501
566
|
return {
|
|
@@ -575,6 +640,7 @@ export function closeAllSync() {
|
|
|
575
640
|
connecting.clear();
|
|
576
641
|
pendingClients.clear();
|
|
577
642
|
failureBackoff.clear();
|
|
643
|
+
sessionServers.clear();
|
|
578
644
|
for (const client of all) {
|
|
579
645
|
try {
|
|
580
646
|
client.closeSync();
|
|
@@ -591,6 +657,7 @@ export async function closeAll() {
|
|
|
591
657
|
connecting.clear();
|
|
592
658
|
pendingClients.clear();
|
|
593
659
|
failureBackoff.clear();
|
|
660
|
+
sessionServers.clear();
|
|
594
661
|
await Promise.allSettled(clients.map(client => client.close()));
|
|
595
662
|
statuses.clear();
|
|
596
663
|
connectionEpochs.clear();
|
package/src/mcp/mcpRegistry.ts
CHANGED
|
@@ -27,6 +27,7 @@ const pendingClients = new Map<string, McpClient>();
|
|
|
27
27
|
const statuses = new Map<string, McpConnectionStatus>();
|
|
28
28
|
const connectionEpochs = new Map<string, number>();
|
|
29
29
|
const failureBackoff = new Map<string, { failures: number; retryAfter: number }>();
|
|
30
|
+
const sessionServers = new Map<string, Map<string, McpServerDefinition>>();
|
|
30
31
|
let activeWorkspaceRoot: string | null = null;
|
|
31
32
|
|
|
32
33
|
export function setActiveWorkspace(workspace: string): void {
|
|
@@ -305,6 +306,62 @@ export function configuredServers(): McpServerDefinition[] {
|
|
|
305
306
|
return servers.map(normalizeDefinition).filter((server): server is McpServerDefinition => server !== null);
|
|
306
307
|
}
|
|
307
308
|
|
|
309
|
+
function findSessionServer(name: string): McpServerDefinition | undefined {
|
|
310
|
+
for (const map of sessionServers.values()) {
|
|
311
|
+
const found = map.get(name);
|
|
312
|
+
if (found) return found;
|
|
313
|
+
}
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function effectiveServers(): McpServerDefinition[] {
|
|
318
|
+
const base = configuredServers();
|
|
319
|
+
if (sessionServers.size === 0) return base;
|
|
320
|
+
const seen = new Set(base.map(server => server.name));
|
|
321
|
+
const merged = [...base];
|
|
322
|
+
for (const map of sessionServers.values()) {
|
|
323
|
+
for (const def of map.values()) {
|
|
324
|
+
if (seen.has(def.name)) continue;
|
|
325
|
+
seen.add(def.name);
|
|
326
|
+
merged.push(def);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return merged;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Register in-memory, session-scoped MCP servers passed by a trusted ACP host
|
|
334
|
+
* (such as Causyne Game). Never written to user config.json; disconnected when
|
|
335
|
+
* the ACP session closes.
|
|
336
|
+
*/
|
|
337
|
+
export function registerSessionMcpServers(sessionId: string, definitions: readonly McpServerDefinition[]): string[] {
|
|
338
|
+
if (!sessionId || !Array.isArray(definitions) || definitions.length === 0) return [];
|
|
339
|
+
const bucket = sessionServers.get(sessionId) ?? new Map<string, McpServerDefinition>();
|
|
340
|
+
const added: string[] = [];
|
|
341
|
+
for (const raw of definitions) {
|
|
342
|
+
const normalized = normalizeDefinition(raw);
|
|
343
|
+
if (!normalized) continue;
|
|
344
|
+
bucket.set(normalized.name, normalized);
|
|
345
|
+
failureBackoff.delete(normalized.name);
|
|
346
|
+
added.push(normalized.name);
|
|
347
|
+
}
|
|
348
|
+
if (bucket.size > 0) sessionServers.set(sessionId, bucket);
|
|
349
|
+
return added;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export async function unregisterSessionMcpServers(sessionId: string): Promise<void> {
|
|
353
|
+
const bucket = sessionServers.get(sessionId);
|
|
354
|
+
if (!bucket) return;
|
|
355
|
+
const names = [...bucket.keys()];
|
|
356
|
+
sessionServers.delete(sessionId);
|
|
357
|
+
const configured = new Set(configuredServers().map(server => server.name));
|
|
358
|
+
await Promise.allSettled(names.map(async name => {
|
|
359
|
+
if (configured.has(name) || findSessionServer(name)) return;
|
|
360
|
+
await disconnectServer(name);
|
|
361
|
+
statuses.delete(name);
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
|
|
308
365
|
export function addServer(value: unknown): { ok: boolean; error?: string } {
|
|
309
366
|
const problem = McpClient.validateDefinition(value);
|
|
310
367
|
if (problem) return { ok: false, error: problem };
|
|
@@ -345,9 +402,13 @@ export function removeServer(name: string): { ok: boolean; error?: string } {
|
|
|
345
402
|
|
|
346
403
|
export function isServerGranted(name: string): boolean {
|
|
347
404
|
const definition = configuredServers().find(server => server.name === name);
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
|
|
405
|
+
if (definition) {
|
|
406
|
+
if (definition.enabled === false) return false;
|
|
407
|
+
const consent = consentRecord(config().mcpConsent?.[name]);
|
|
408
|
+
return consent?.digest === definitionDigest(definition);
|
|
409
|
+
}
|
|
410
|
+
const sessionDef = findSessionServer(name);
|
|
411
|
+
return Boolean(sessionDef && sessionDef.enabled !== false);
|
|
351
412
|
}
|
|
352
413
|
|
|
353
414
|
export function grantServer(name: string): { ok: boolean; error?: string } {
|
|
@@ -395,7 +456,7 @@ export function parseToolName(name: unknown): { server: string; tool: string } |
|
|
|
395
456
|
}
|
|
396
457
|
|
|
397
458
|
export async function connectServer(name: string): Promise<McpClient> {
|
|
398
|
-
const definition =
|
|
459
|
+
const definition = effectiveServers().find(server => server.name === name);
|
|
399
460
|
if (!definition) throw new Error(`no MCP server named "${name}" is configured`);
|
|
400
461
|
if (definition.enabled === false) {
|
|
401
462
|
statuses.set(name, { state: 'disabled' });
|
|
@@ -426,7 +487,7 @@ export async function connectServer(name: string): Promise<McpClient> {
|
|
|
426
487
|
statuses.set(name, { state: 'connecting' });
|
|
427
488
|
try {
|
|
428
489
|
await client.connect();
|
|
429
|
-
const current =
|
|
490
|
+
const current = effectiveServers().find(server => server.name === name);
|
|
430
491
|
const connectionIsCurrent = connectionEpoch(name) === startedAtEpoch
|
|
431
492
|
&& current !== undefined
|
|
432
493
|
&& definitionDigest(current) === definitionDigest(definition)
|
|
@@ -481,7 +542,7 @@ export async function refreshServer(name: string): Promise<McpToolDefinition[]>
|
|
|
481
542
|
}
|
|
482
543
|
|
|
483
544
|
export async function discoverTools(): Promise<DynamicToolDefinition[]> {
|
|
484
|
-
const granted =
|
|
545
|
+
const granted = effectiveServers().filter(server => isServerGranted(server.name));
|
|
485
546
|
const now = Date.now();
|
|
486
547
|
const results = await Promise.all(granted.map(async server => {
|
|
487
548
|
const backoff = failureBackoff.get(server.name);
|
|
@@ -512,7 +573,7 @@ export async function discoverTools(): Promise<DynamicToolDefinition[]> {
|
|
|
512
573
|
export function resolveMcpTool(name: unknown): { schema: DynamicToolDefinition; execute: (args: Record<string, unknown>, context?: { signal?: AbortSignal }) => Promise<ToolResult> } | null {
|
|
513
574
|
const parsed = parseToolName(name);
|
|
514
575
|
if (!parsed) return null;
|
|
515
|
-
const definition =
|
|
576
|
+
const definition = effectiveServers().find(server => server.name === parsed.server);
|
|
516
577
|
if (!definition) return null;
|
|
517
578
|
|
|
518
579
|
return {
|
|
@@ -597,6 +658,7 @@ export function closeAllSync(): void {
|
|
|
597
658
|
connecting.clear();
|
|
598
659
|
pendingClients.clear();
|
|
599
660
|
failureBackoff.clear();
|
|
661
|
+
sessionServers.clear();
|
|
600
662
|
for (const client of all) {
|
|
601
663
|
try { client.closeSync(); } catch { /* ignore */ }
|
|
602
664
|
}
|
|
@@ -611,6 +673,7 @@ export async function closeAll(): Promise<void> {
|
|
|
611
673
|
connecting.clear();
|
|
612
674
|
pendingClients.clear();
|
|
613
675
|
failureBackoff.clear();
|
|
676
|
+
sessionServers.clear();
|
|
614
677
|
await Promise.allSettled(clients.map(client => client.close()));
|
|
615
678
|
statuses.clear();
|
|
616
679
|
connectionEpochs.clear();
|
|
@@ -20,6 +20,8 @@ const MAX_REDUCTION_ITERATIONS = 16;
|
|
|
20
20
|
function formatShortTime(epochMs) {
|
|
21
21
|
try {
|
|
22
22
|
const d = new Date(epochMs);
|
|
23
|
+
if (!Number.isFinite(d.getTime()))
|
|
24
|
+
return 'recent';
|
|
23
25
|
const yyyy = d.getUTCFullYear();
|
|
24
26
|
const mm = String(d.getUTCMonth() + 1).padStart(2, '0');
|
|
25
27
|
const dd = String(d.getUTCDate()).padStart(2, '0');
|
|
@@ -34,6 +34,7 @@ const MAX_REDUCTION_ITERATIONS = 16;
|
|
|
34
34
|
function formatShortTime(epochMs: number): string {
|
|
35
35
|
try {
|
|
36
36
|
const d = new Date(epochMs);
|
|
37
|
+
if (!Number.isFinite(d.getTime())) return 'recent';
|
|
37
38
|
const yyyy = d.getUTCFullYear();
|
|
38
39
|
const mm = String(d.getUTCMonth() + 1).padStart(2, '0');
|
|
39
40
|
const dd = String(d.getUTCDate()).padStart(2, '0');
|
package/src/modelVariants.js
CHANGED
|
@@ -598,3 +598,48 @@ export function resolveModelVariants(input) {
|
|
|
598
598
|
: family.note
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Reconcile a saved `reasoningEffort` against the currently selected `(provider, model)`
|
|
603
|
+
* so stale variants from a previous provider/model (e.g. OpenCode `max` after switching
|
|
604
|
+
* to Antigravity `Gemini 4 Neon (XHigh)`) are cleared cleanly instead of leaking into
|
|
605
|
+
* CLI flags or status indicators.
|
|
606
|
+
*/
|
|
607
|
+
export function reconcileConfigVariant(config, options = {}) {
|
|
608
|
+
if (!config || typeof config !== 'object')
|
|
609
|
+
return '';
|
|
610
|
+
const raw = typeof config.reasoningEffort === 'string' ? config.reasoningEffort.trim() : '';
|
|
611
|
+
if (!raw) {
|
|
612
|
+
delete config.reasoningEffort;
|
|
613
|
+
return '';
|
|
614
|
+
}
|
|
615
|
+
const provider = typeof config.provider === 'string' ? config.provider.trim() : '';
|
|
616
|
+
const model = typeof config.model === 'string' ? config.model.trim() : '';
|
|
617
|
+
// Antigravity encodes effort inside each model slug (e.g. `Gemini 4 Neon (XHigh)`),
|
|
618
|
+
// and unsuffixed orchestrator models reject `--effort`. Never retain a separate
|
|
619
|
+
// `reasoningEffort` override across Antigravity models.
|
|
620
|
+
if (isAntigravityProvider(provider)) {
|
|
621
|
+
delete config.reasoningEffort;
|
|
622
|
+
delete config.reasoningBudgetTokens;
|
|
623
|
+
return '';
|
|
624
|
+
}
|
|
625
|
+
const spec = resolveModelVariants({
|
|
626
|
+
provider,
|
|
627
|
+
model,
|
|
628
|
+
currentVariant: raw,
|
|
629
|
+
peerModelVariants: options.peerModelVariants,
|
|
630
|
+
availableAgyModels: options.liveAgyModels
|
|
631
|
+
});
|
|
632
|
+
if (spec.source === 'agy_models' || !spec.supported) {
|
|
633
|
+
delete config.reasoningEffort;
|
|
634
|
+
delete config.reasoningBudgetTokens;
|
|
635
|
+
return '';
|
|
636
|
+
}
|
|
637
|
+
const matched = matchVariantOption(spec, raw);
|
|
638
|
+
if (!matched) {
|
|
639
|
+
delete config.reasoningEffort;
|
|
640
|
+
delete config.reasoningBudgetTokens;
|
|
641
|
+
return '';
|
|
642
|
+
}
|
|
643
|
+
config.reasoningEffort = matched.id;
|
|
644
|
+
return matched.id;
|
|
645
|
+
}
|
package/src/modelVariants.ts
CHANGED
|
@@ -661,3 +661,57 @@ export function resolveModelVariants(input: ResolveModelVariantsInput): ModelVar
|
|
|
661
661
|
: family.note
|
|
662
662
|
};
|
|
663
663
|
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Reconcile a saved `reasoningEffort` against the currently selected `(provider, model)`
|
|
667
|
+
* so stale variants from a previous provider/model (e.g. OpenCode `max` after switching
|
|
668
|
+
* to Antigravity `Gemini 4 Neon (XHigh)`) are cleared cleanly instead of leaking into
|
|
669
|
+
* CLI flags or status indicators.
|
|
670
|
+
*/
|
|
671
|
+
export function reconcileConfigVariant(
|
|
672
|
+
config: Record<string, any>,
|
|
673
|
+
options: {
|
|
674
|
+
liveAgyModels?: readonly string[] | undefined;
|
|
675
|
+
peerModelVariants?: readonly string[] | null | undefined;
|
|
676
|
+
} = {}
|
|
677
|
+
): string {
|
|
678
|
+
if (!config || typeof config !== 'object') return '';
|
|
679
|
+
const raw = typeof config.reasoningEffort === 'string' ? config.reasoningEffort.trim() : '';
|
|
680
|
+
if (!raw) {
|
|
681
|
+
delete config.reasoningEffort;
|
|
682
|
+
return '';
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const provider = typeof config.provider === 'string' ? config.provider.trim() : '';
|
|
686
|
+
const model = typeof config.model === 'string' ? config.model.trim() : '';
|
|
687
|
+
|
|
688
|
+
// Antigravity encodes effort inside each model slug (e.g. `Gemini 4 Neon (XHigh)`),
|
|
689
|
+
// and unsuffixed orchestrator models reject `--effort`. Never retain a separate
|
|
690
|
+
// `reasoningEffort` override across Antigravity models.
|
|
691
|
+
if (isAntigravityProvider(provider)) {
|
|
692
|
+
delete config.reasoningEffort;
|
|
693
|
+
delete config.reasoningBudgetTokens;
|
|
694
|
+
return '';
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const spec = resolveModelVariants({
|
|
698
|
+
provider,
|
|
699
|
+
model,
|
|
700
|
+
currentVariant: raw,
|
|
701
|
+
peerModelVariants: options.peerModelVariants,
|
|
702
|
+
availableAgyModels: options.liveAgyModels
|
|
703
|
+
});
|
|
704
|
+
if (spec.source === 'agy_models' || !spec.supported) {
|
|
705
|
+
delete config.reasoningEffort;
|
|
706
|
+
delete config.reasoningBudgetTokens;
|
|
707
|
+
return '';
|
|
708
|
+
}
|
|
709
|
+
const matched = matchVariantOption(spec, raw);
|
|
710
|
+
if (!matched) {
|
|
711
|
+
delete config.reasoningEffort;
|
|
712
|
+
delete config.reasoningBudgetTokens;
|
|
713
|
+
return '';
|
|
714
|
+
}
|
|
715
|
+
config.reasoningEffort = matched.id;
|
|
716
|
+
return matched.id;
|
|
717
|
+
}
|
package/src/outputRecovery.js
CHANGED
|
@@ -5,9 +5,10 @@ function normalizePathKey(filePath) {
|
|
|
5
5
|
const resolved = path.resolve(filePath);
|
|
6
6
|
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const RECOVERY_READ_TOOLS = new Set(['fs_read', 'code_search_ripgrep', 'fs_search']);
|
|
9
|
+
/** Read or search only an exact output file already attached to this session's history. */
|
|
9
10
|
export function isOutputRecoveryRead(tool, target, knownPaths) {
|
|
10
|
-
if (tool
|
|
11
|
+
if (!RECOVERY_READ_TOOLS.has(tool) || typeof target !== 'string')
|
|
11
12
|
return false;
|
|
12
13
|
const targetKey = normalizePathKey(target);
|
|
13
14
|
const isKnown = Array.from(knownPaths).some(known => normalizePathKey(known) === targetKey);
|
package/src/outputRecovery.ts
CHANGED
|
@@ -7,9 +7,11 @@ function normalizePathKey(filePath: string): string {
|
|
|
7
7
|
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const RECOVERY_READ_TOOLS = new Set(['fs_read', 'code_search_ripgrep', 'fs_search']);
|
|
11
|
+
|
|
12
|
+
/** Read or search only an exact output file already attached to this session's history. */
|
|
11
13
|
export function isOutputRecoveryRead(tool: string, target: unknown, knownPaths: ReadonlySet<string>): boolean {
|
|
12
|
-
if (tool
|
|
14
|
+
if (!RECOVERY_READ_TOOLS.has(tool) || typeof target !== 'string') return false;
|
|
13
15
|
const targetKey = normalizePathKey(target);
|
|
14
16
|
const isKnown = Array.from(knownPaths).some(known => normalizePathKey(known) === targetKey);
|
|
15
17
|
if (!isKnown) return false;
|