@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/providers/xai.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DEFAULT_MODEL_BY_PROVIDER } from '../modelCatalogue.js';
|
|
|
3
3
|
import { LLMProvider } from './base.js';
|
|
4
4
|
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
5
5
|
import { normalizeOpenAIChatChoiceResponse } from './wireNormalizer.js';
|
|
6
|
-
import { requireApiKey, resolveTemperature, safeProviderFetchJson } from './byokHttp.js';
|
|
6
|
+
import { ProviderHttpError, requireApiKey, resolveTemperature, safeProviderFetchJson } from './byokHttp.js';
|
|
7
7
|
import { streamOpenAICompatibleChat, wantsStreaming } from './byokStream.js';
|
|
8
8
|
export class XAIProvider extends LLMProvider {
|
|
9
9
|
allowInsecureHttp;
|
|
@@ -14,8 +14,9 @@ export class XAIProvider extends LLMProvider {
|
|
|
14
14
|
this.baseUrl = customUrl || 'https://api.x.ai/v1/chat/completions';
|
|
15
15
|
this.allowInsecureHttp = config.allowInsecureHttp === true;
|
|
16
16
|
const rawEffort = typeof config.reasoningEffort === 'string' ? config.reasoningEffort.trim().toLowerCase() : '';
|
|
17
|
+
const clampedEffort = (rawEffort === 'max' || rawEffort === 'ultra') ? 'high' : (rawEffort === 'minimal' ? 'low' : rawEffort);
|
|
17
18
|
const allowedEfforts = new Set(['low', 'medium', 'high', 'xhigh']);
|
|
18
|
-
this.reasoningEffort = allowedEfforts.has(
|
|
19
|
+
this.reasoningEffort = allowedEfforts.has(clampedEffort) ? clampedEffort : null;
|
|
19
20
|
this.model = String(canonicalModelId(config.model || DEFAULT_MODEL_BY_PROVIDER['xai']) || '');
|
|
20
21
|
this.visionModels = ['grok-4', 'vision'];
|
|
21
22
|
this.audioModels = [];
|
|
@@ -29,12 +30,12 @@ export class XAIProvider extends LLMProvider {
|
|
|
29
30
|
temperature: resolveTemperature(options.temperature, 0.1)
|
|
30
31
|
};
|
|
31
32
|
const loweredModel = (this.model || '').toLowerCase();
|
|
32
|
-
if (this.reasoningEffort) {
|
|
33
|
-
if (loweredModel.includes('grok-420-reasoning')) {
|
|
33
|
+
if (this.reasoningEffort && !loweredModel.includes('non-reasoning')) {
|
|
34
|
+
if (loweredModel.includes('grok-420-reasoning') || (loweredModel.includes('grok-4') && loweredModel.includes('reasoning'))) {
|
|
34
35
|
payload['reasoning_effort'] = this.reasoningEffort;
|
|
35
36
|
}
|
|
36
|
-
else if (loweredModel.includes('grok-3-mini')
|
|
37
|
-
payload['reasoning_effort'] = this.reasoningEffort;
|
|
37
|
+
else if (loweredModel.includes('grok-3-mini')) {
|
|
38
|
+
payload['reasoning_effort'] = this.reasoningEffort === 'low' ? 'low' : 'high';
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
if (typeof options.maxTokens === 'number' && Number.isFinite(options.maxTokens) && options.maxTokens >= 1) {
|
|
@@ -65,17 +66,32 @@ export class XAIProvider extends LLMProvider {
|
|
|
65
66
|
hasApiKey: true,
|
|
66
67
|
allowInsecureHttp: this.allowInsecureHttp
|
|
67
68
|
};
|
|
68
|
-
const
|
|
69
|
+
const runXaiRequest = async (reqPayload) => (wantsStreaming(options)
|
|
69
70
|
? await streamOpenAICompatibleChat({
|
|
70
71
|
...requestOpts,
|
|
71
|
-
payload,
|
|
72
|
+
payload: reqPayload,
|
|
72
73
|
onChunk: options.onChunk,
|
|
73
74
|
onReasoningChunk: options.onReasoningChunk
|
|
74
75
|
})
|
|
75
76
|
: await safeProviderFetchJson({
|
|
76
77
|
...requestOpts,
|
|
77
|
-
body: JSON.stringify(
|
|
78
|
-
});
|
|
78
|
+
body: JSON.stringify(reqPayload)
|
|
79
|
+
}));
|
|
80
|
+
let data;
|
|
81
|
+
try {
|
|
82
|
+
data = await runXaiRequest(payload);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
const rejectedEffort = 'reasoning_effort' in payload
|
|
86
|
+
&& err instanceof ProviderHttpError
|
|
87
|
+
&& err.status === 400
|
|
88
|
+
&& /(?:reasoning_effort|effort|unsupported|not supported|invalid|unknown)/i.test(err.message);
|
|
89
|
+
if (!rejectedEffort)
|
|
90
|
+
throw err;
|
|
91
|
+
const fallbackPayload = { ...payload };
|
|
92
|
+
delete fallbackPayload['reasoning_effort'];
|
|
93
|
+
data = await runXaiRequest(fallbackPayload);
|
|
94
|
+
}
|
|
79
95
|
const normalized = normalizeOpenAIChatChoiceResponse(data, {
|
|
80
96
|
prefix: 'call_xai',
|
|
81
97
|
freeFormPaths
|
package/src/providers/xai.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { LLMProvider, type ChatOptions, type ChatResponse, type ProviderConfig }
|
|
|
4
4
|
import { scanAndAdaptToolsForProvider } from '../tools/toolScanner.js';
|
|
5
5
|
import { normalizeOpenAIChatChoiceResponse } from './wireNormalizer.js';
|
|
6
6
|
import {
|
|
7
|
+
ProviderHttpError,
|
|
7
8
|
requireApiKey,
|
|
8
9
|
resolveTemperature,
|
|
9
10
|
safeProviderFetchJson
|
|
@@ -20,8 +21,9 @@ export class XAIProvider extends LLMProvider {
|
|
|
20
21
|
this.baseUrl = customUrl || 'https://api.x.ai/v1/chat/completions';
|
|
21
22
|
this.allowInsecureHttp = config.allowInsecureHttp === true;
|
|
22
23
|
const rawEffort = typeof config.reasoningEffort === 'string' ? config.reasoningEffort.trim().toLowerCase() : '';
|
|
24
|
+
const clampedEffort = (rawEffort === 'max' || rawEffort === 'ultra') ? 'high' : (rawEffort === 'minimal' ? 'low' : rawEffort);
|
|
23
25
|
const allowedEfforts = new Set(['low', 'medium', 'high', 'xhigh']);
|
|
24
|
-
this.reasoningEffort = allowedEfforts.has(
|
|
26
|
+
this.reasoningEffort = allowedEfforts.has(clampedEffort) ? clampedEffort : null;
|
|
25
27
|
this.model = String(canonicalModelId(config.model || DEFAULT_MODEL_BY_PROVIDER['xai']) || '');
|
|
26
28
|
this.visionModels = ['grok-4', 'vision'];
|
|
27
29
|
this.audioModels = [];
|
|
@@ -38,11 +40,11 @@ export class XAIProvider extends LLMProvider {
|
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
const loweredModel = (this.model || '').toLowerCase();
|
|
41
|
-
if (this.reasoningEffort) {
|
|
42
|
-
if (loweredModel.includes('grok-420-reasoning')) {
|
|
43
|
-
payload['reasoning_effort'] = this.reasoningEffort;
|
|
44
|
-
} else if (loweredModel.includes('grok-3-mini') && (this.reasoningEffort === 'low' || this.reasoningEffort === 'high')) {
|
|
43
|
+
if (this.reasoningEffort && !loweredModel.includes('non-reasoning')) {
|
|
44
|
+
if (loweredModel.includes('grok-420-reasoning') || (loweredModel.includes('grok-4') && loweredModel.includes('reasoning'))) {
|
|
45
45
|
payload['reasoning_effort'] = this.reasoningEffort;
|
|
46
|
+
} else if (loweredModel.includes('grok-3-mini')) {
|
|
47
|
+
payload['reasoning_effort'] = this.reasoningEffort === 'low' ? 'low' : 'high';
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
if (typeof options.maxTokens === 'number' && Number.isFinite(options.maxTokens) && options.maxTokens >= 1) {
|
|
@@ -77,17 +79,33 @@ export class XAIProvider extends LLMProvider {
|
|
|
77
79
|
allowInsecureHttp: this.allowInsecureHttp
|
|
78
80
|
};
|
|
79
81
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
const runXaiRequest = async (reqPayload: Record<string, any>) => (
|
|
83
|
+
wantsStreaming(options)
|
|
84
|
+
? await streamOpenAICompatibleChat({
|
|
85
|
+
...requestOpts,
|
|
86
|
+
payload: reqPayload,
|
|
87
|
+
onChunk: options.onChunk,
|
|
88
|
+
onReasoningChunk: options.onReasoningChunk
|
|
89
|
+
})
|
|
90
|
+
: await safeProviderFetchJson({
|
|
91
|
+
...requestOpts,
|
|
92
|
+
body: JSON.stringify(reqPayload)
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
let data: Record<string, any>;
|
|
97
|
+
try {
|
|
98
|
+
data = await runXaiRequest(payload);
|
|
99
|
+
} catch (err: unknown) {
|
|
100
|
+
const rejectedEffort = 'reasoning_effort' in payload
|
|
101
|
+
&& err instanceof ProviderHttpError
|
|
102
|
+
&& err.status === 400
|
|
103
|
+
&& /(?:reasoning_effort|effort|unsupported|not supported|invalid|unknown)/i.test(err.message);
|
|
104
|
+
if (!rejectedEffort) throw err;
|
|
105
|
+
const fallbackPayload = { ...payload };
|
|
106
|
+
delete fallbackPayload['reasoning_effort'];
|
|
107
|
+
data = await runXaiRequest(fallbackPayload);
|
|
108
|
+
}
|
|
91
109
|
const normalized = normalizeOpenAIChatChoiceResponse(data, {
|
|
92
110
|
prefix: 'call_xai',
|
|
93
111
|
freeFormPaths
|
package/src/reporting.js
CHANGED
|
@@ -12,6 +12,7 @@ import { terminalWidth, readableWidth } from './tui/theme.js';
|
|
|
12
12
|
import { isAcpProvider } from './providers/acp.js';
|
|
13
13
|
import { isAntigravityProvider } from './providers/antigravity.js';
|
|
14
14
|
import { LICENSE_ENFORCEMENT_ENABLED } from './licensing/policy.js';
|
|
15
|
+
import { getPermissionPresetDescriptor, resolveConfigPermissionPreset } from './permissionPresets.js';
|
|
15
16
|
function resolveDisplayTier(liveConfig, savedConfig) {
|
|
16
17
|
const configured = liveConfig?.tier ?? savedConfig?.tier;
|
|
17
18
|
if (typeof configured === 'string' && configured.trim())
|
|
@@ -358,7 +359,8 @@ export function buildStatusText(options) {
|
|
|
358
359
|
const liveConfig = loop?.config || {};
|
|
359
360
|
const provider = String(liveConfig.provider || config.provider || 'default');
|
|
360
361
|
const model = String(liveConfig.model || config.model || 'default');
|
|
361
|
-
const
|
|
362
|
+
const presetId = resolveConfigPermissionPreset(liveConfig, resolveConfigPermissionPreset(config, 'workspace-write'));
|
|
363
|
+
const presetDesc = getPermissionPresetDescriptor(presetId);
|
|
362
364
|
const tier = resolveDisplayTier(liveConfig, config);
|
|
363
365
|
const lines = ['Status'];
|
|
364
366
|
lines.push(' Runtime : local desktop');
|
|
@@ -366,7 +368,7 @@ export function buildStatusText(options) {
|
|
|
366
368
|
lines.push(` Session : ${safeDisplay(loop.memoryManager.sessionId)}`);
|
|
367
369
|
}
|
|
368
370
|
lines.push(` Provider / model : ${safeDisplay(provider)} / ${safeDisplay(model)}`);
|
|
369
|
-
lines.push(`
|
|
371
|
+
lines.push(` Permission : ${safeDisplay(presetDesc.label)} (${safeDisplay(presetDesc.id)})`);
|
|
370
372
|
lines.push(` Tier : ${safeDisplay(tier)}`);
|
|
371
373
|
if (loop && loop.sandbox) {
|
|
372
374
|
const sandbox = loop.sandbox;
|
package/src/reporting.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { terminalWidth, readableWidth } from './tui/theme.js';
|
|
|
13
13
|
import { isAcpProvider } from './providers/acp.js';
|
|
14
14
|
import { isAntigravityProvider } from './providers/antigravity.js';
|
|
15
15
|
import { LICENSE_ENFORCEMENT_ENABLED } from './licensing/policy.js';
|
|
16
|
+
import { getPermissionPresetDescriptor, resolveConfigPermissionPreset } from './permissionPresets.js';
|
|
16
17
|
|
|
17
18
|
function resolveDisplayTier(liveConfig?: Record<string, unknown> | null, savedConfig?: Record<string, unknown> | null): string {
|
|
18
19
|
const configured = liveConfig?.tier ?? savedConfig?.tier;
|
|
@@ -425,7 +426,8 @@ export function buildStatusText(options?: { loop?: any } | null): string {
|
|
|
425
426
|
const liveConfig = loop?.config || {};
|
|
426
427
|
const provider = String(liveConfig.provider || config.provider || 'default');
|
|
427
428
|
const model = String(liveConfig.model || config.model || 'default');
|
|
428
|
-
const
|
|
429
|
+
const presetId = resolveConfigPermissionPreset(liveConfig, resolveConfigPermissionPreset(config, 'workspace-write'));
|
|
430
|
+
const presetDesc = getPermissionPresetDescriptor(presetId);
|
|
429
431
|
const tier = resolveDisplayTier(liveConfig, config);
|
|
430
432
|
const lines = ['Status'];
|
|
431
433
|
|
|
@@ -435,7 +437,7 @@ export function buildStatusText(options?: { loop?: any } | null): string {
|
|
|
435
437
|
lines.push(` Session : ${safeDisplay(loop.memoryManager.sessionId)}`);
|
|
436
438
|
}
|
|
437
439
|
lines.push(` Provider / model : ${safeDisplay(provider)} / ${safeDisplay(model)}`);
|
|
438
|
-
lines.push(`
|
|
440
|
+
lines.push(` Permission : ${safeDisplay(presetDesc.label)} (${safeDisplay(presetDesc.id)})`);
|
|
439
441
|
lines.push(` Tier : ${safeDisplay(tier)}`);
|
|
440
442
|
|
|
441
443
|
if (loop && loop.sandbox) {
|
package/src/sandbox.js
CHANGED
|
@@ -9,6 +9,7 @@ import { extractPatchTargetPaths } from './tools/applyPatch.js';
|
|
|
9
9
|
import { getMcpToolAnnotations } from './mcp/mcpRegistry.js';
|
|
10
10
|
import { isPhysicalPathAllowed, physicalPath } from './agent/workspaceBoundary.js';
|
|
11
11
|
import { isBlockedWorkspaceRoot, isExtendedCredentialPath, isSensitiveWriteTarget, analyzeShellCommand, isExtremeRemovalSegment, isFetchAndExecPipeline } from './sandboxPolicy.js';
|
|
12
|
+
import { autonomyModeToPreset, normalizePermissionPreset, readOnlyPresetViolation } from './permissionPresets.js';
|
|
12
13
|
const READ_ONLY_INVOCATIONS = {
|
|
13
14
|
brew: /^brew\s+(--version|-v|list|info|search|config|outdated|deps|home|--prefix|--cellar)\b/,
|
|
14
15
|
apt: /^apt\s+(--version|list|show|search|policy)\b/,
|
|
@@ -132,7 +133,14 @@ export class Sandbox {
|
|
|
132
133
|
this.allowedTools = rawAllowed.map((name) => String(name).replace(/\./g, '_'));
|
|
133
134
|
this.deniedTools = new Set((devMode ? [] : (this.config.deniedTools || []))
|
|
134
135
|
.map((name) => String(name).replace(/\./g, '_')));
|
|
136
|
+
this.permissionPreset = normalizePermissionPreset(safeOptions.permissionPreset)
|
|
137
|
+
?? (typeof safeOptions.autonomyMode === 'string' && safeOptions.autonomyMode.trim()
|
|
138
|
+
? autonomyModeToPreset(safeOptions.autonomyMode)
|
|
139
|
+
: null)
|
|
140
|
+
?? normalizePermissionPreset(this.config.permissionPreset)
|
|
141
|
+
?? autonomyModeToPreset(this.config.autonomyMode);
|
|
135
142
|
}
|
|
143
|
+
permissionPreset;
|
|
136
144
|
updateWorkspacePaths(newPaths) {
|
|
137
145
|
if (Array.isArray(newPaths) && newPaths.length > 0) {
|
|
138
146
|
const seen = new Set();
|
|
@@ -172,6 +180,12 @@ export class Sandbox {
|
|
|
172
180
|
return { allowed: false, reason: `Tool ${toolName} not allowed on current tier`, risk: 'forbidden' };
|
|
173
181
|
}
|
|
174
182
|
const safeArgs = args && typeof args === 'object' ? args : {};
|
|
183
|
+
if (this.permissionPreset === 'read-only') {
|
|
184
|
+
const readOnlyErr = readOnlyPresetViolation(canonicalToolName, safeArgs);
|
|
185
|
+
if (readOnlyErr) {
|
|
186
|
+
return { allowed: false, reason: readOnlyErr, risk: 'dangerous' };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
175
189
|
const pathsToCheck = [];
|
|
176
190
|
if (canonicalToolName !== 'fs_read_skill') {
|
|
177
191
|
const PATH_ARGUMENTS = [
|
|
@@ -255,6 +269,26 @@ export class Sandbox {
|
|
|
255
269
|
}
|
|
256
270
|
return withCredentialEscalation({ allowed: true, risk: 'safe' });
|
|
257
271
|
}
|
|
272
|
+
if (canonicalToolName === 'present' || canonicalToolName === 'session_search' || canonicalToolName === 'run_code') {
|
|
273
|
+
return withCredentialEscalation({ allowed: true, risk: 'safe' });
|
|
274
|
+
}
|
|
275
|
+
if (canonicalToolName === 'goal' || canonicalToolName === 'schedule') {
|
|
276
|
+
return withCredentialEscalation({ allowed: true, risk: 'moderate' });
|
|
277
|
+
}
|
|
278
|
+
if (canonicalToolName === 'terminal_pty') {
|
|
279
|
+
const action = String(safeArgs.action || '').trim();
|
|
280
|
+
if (action === 'list' || action === 'read' || action === 'resize') {
|
|
281
|
+
return withCredentialEscalation({ allowed: true, risk: 'safe' });
|
|
282
|
+
}
|
|
283
|
+
if (action === 'send' && typeof safeArgs.input === 'string' && safeArgs.input.trim()) {
|
|
284
|
+
const risk = this.classifyCommandRisk(safeArgs.input);
|
|
285
|
+
if (risk === 'forbidden') {
|
|
286
|
+
return { allowed: false, reason: 'Command is permanently blocked for safety', risk: 'forbidden' };
|
|
287
|
+
}
|
|
288
|
+
return withCredentialEscalation({ allowed: true, risk });
|
|
289
|
+
}
|
|
290
|
+
return withCredentialEscalation({ allowed: true, risk: 'moderate' });
|
|
291
|
+
}
|
|
258
292
|
if (canonicalToolName === 'sysRun' || canonicalToolName === 'sysRunBg' || canonicalToolName === 'terminal_persistent_shell') {
|
|
259
293
|
const command = safeArgs.command || safeArgs.input || safeArgs.cmd;
|
|
260
294
|
if (command) {
|
package/src/sandbox.ts
CHANGED
|
@@ -16,6 +16,12 @@ import {
|
|
|
16
16
|
isExtremeRemovalSegment,
|
|
17
17
|
isFetchAndExecPipeline
|
|
18
18
|
} from './sandboxPolicy.js';
|
|
19
|
+
import {
|
|
20
|
+
autonomyModeToPreset,
|
|
21
|
+
normalizePermissionPreset,
|
|
22
|
+
readOnlyPresetViolation,
|
|
23
|
+
type PermissionPresetId
|
|
24
|
+
} from './permissionPresets.js';
|
|
19
25
|
|
|
20
26
|
export type RiskLevel = 'safe' | 'moderate' | 'dangerous' | 'extreme' | 'forbidden';
|
|
21
27
|
|
|
@@ -158,8 +164,16 @@ export class Sandbox {
|
|
|
158
164
|
(devMode ? [] : (this.config.deniedTools || []))
|
|
159
165
|
.map((name: unknown) => String(name).replace(/\./g, '_'))
|
|
160
166
|
);
|
|
167
|
+
this.permissionPreset = normalizePermissionPreset(safeOptions.permissionPreset)
|
|
168
|
+
?? (typeof safeOptions.autonomyMode === 'string' && safeOptions.autonomyMode.trim()
|
|
169
|
+
? autonomyModeToPreset(safeOptions.autonomyMode)
|
|
170
|
+
: null)
|
|
171
|
+
?? normalizePermissionPreset((this.config as { permissionPreset?: unknown }).permissionPreset)
|
|
172
|
+
?? autonomyModeToPreset(this.config.autonomyMode);
|
|
161
173
|
}
|
|
162
174
|
|
|
175
|
+
permissionPreset: PermissionPresetId;
|
|
176
|
+
|
|
163
177
|
updateWorkspacePaths(newPaths: unknown): { success: boolean; paths?: string[]; reason?: string } {
|
|
164
178
|
if (Array.isArray(newPaths) && newPaths.length > 0) {
|
|
165
179
|
const seen = new Set<string>();
|
|
@@ -202,6 +216,12 @@ export class Sandbox {
|
|
|
202
216
|
}
|
|
203
217
|
|
|
204
218
|
const safeArgs: Record<string, any> = args && typeof args === 'object' ? args : {};
|
|
219
|
+
if (this.permissionPreset === 'read-only') {
|
|
220
|
+
const readOnlyErr = readOnlyPresetViolation(canonicalToolName, safeArgs);
|
|
221
|
+
if (readOnlyErr) {
|
|
222
|
+
return { allowed: false, reason: readOnlyErr, risk: 'dangerous' };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
205
225
|
const pathsToCheck: unknown[] = [];
|
|
206
226
|
if (canonicalToolName !== 'fs_read_skill') {
|
|
207
227
|
const PATH_ARGUMENTS = [
|
|
@@ -285,6 +305,29 @@ export class Sandbox {
|
|
|
285
305
|
return withCredentialEscalation({ allowed: true, risk: 'safe' });
|
|
286
306
|
}
|
|
287
307
|
|
|
308
|
+
if (canonicalToolName === 'present' || canonicalToolName === 'session_search' || canonicalToolName === 'run_code') {
|
|
309
|
+
return withCredentialEscalation({ allowed: true, risk: 'safe' });
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (canonicalToolName === 'goal' || canonicalToolName === 'schedule') {
|
|
313
|
+
return withCredentialEscalation({ allowed: true, risk: 'moderate' });
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (canonicalToolName === 'terminal_pty') {
|
|
317
|
+
const action = String(safeArgs.action || '').trim();
|
|
318
|
+
if (action === 'list' || action === 'read' || action === 'resize') {
|
|
319
|
+
return withCredentialEscalation({ allowed: true, risk: 'safe' });
|
|
320
|
+
}
|
|
321
|
+
if (action === 'send' && typeof safeArgs.input === 'string' && safeArgs.input.trim()) {
|
|
322
|
+
const risk = this.classifyCommandRisk(safeArgs.input);
|
|
323
|
+
if (risk === 'forbidden') {
|
|
324
|
+
return { allowed: false, reason: 'Command is permanently blocked for safety', risk: 'forbidden' };
|
|
325
|
+
}
|
|
326
|
+
return withCredentialEscalation({ allowed: true, risk });
|
|
327
|
+
}
|
|
328
|
+
return withCredentialEscalation({ allowed: true, risk: 'moderate' });
|
|
329
|
+
}
|
|
330
|
+
|
|
288
331
|
if (canonicalToolName === 'sysRun' || canonicalToolName === 'sysRunBg' || canonicalToolName === 'terminal_persistent_shell') {
|
|
289
332
|
const command = safeArgs.command || safeArgs.input || safeArgs.cmd;
|
|
290
333
|
if (command) {
|