@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/approvalPolicy.ts
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import {
|
|
3
|
+
normalizePermissionPreset,
|
|
4
|
+
presetToAutonomyMode,
|
|
5
|
+
resolveConfigPermissionPreset,
|
|
6
|
+
type PermissionPresetId
|
|
7
|
+
} from './permissionPresets.js';
|
|
2
8
|
|
|
3
9
|
export type AutonomyMode = 'A' | 'B' | 'C' | string;
|
|
4
10
|
|
|
5
11
|
const toolAutonomy = new AsyncLocalStorage<AutonomyMode>();
|
|
12
|
+
const toolPreset = new AsyncLocalStorage<PermissionPresetId>();
|
|
6
13
|
|
|
7
|
-
/** Session-scoped context for
|
|
14
|
+
/** Session-scoped context for tools whose execute signature has no context parameter. */
|
|
15
|
+
export function withToolPermissionPreset<T>(preset: PermissionPresetId, run: () => Promise<T>): Promise<T> {
|
|
16
|
+
const mode = presetToAutonomyMode(preset);
|
|
17
|
+
return toolPreset.run(preset, () => toolAutonomy.run(mode, run));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function currentToolPermissionPreset(): PermissionPresetId | undefined {
|
|
21
|
+
const direct = toolPreset.getStore();
|
|
22
|
+
if (direct) return direct;
|
|
23
|
+
const legacy = toolAutonomy.getStore();
|
|
24
|
+
return legacy ? (normalizePermissionPreset(legacy) ?? undefined) : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Legacy compatibility wrapper delegating to permission presets. */
|
|
8
28
|
export function withToolAutonomyMode<T>(mode: AutonomyMode, run: () => Promise<T>): Promise<T> {
|
|
29
|
+
const preset = normalizePermissionPreset(mode);
|
|
30
|
+
if (preset) {
|
|
31
|
+
return toolPreset.run(preset, () => toolAutonomy.run(mode, run));
|
|
32
|
+
}
|
|
9
33
|
return toolAutonomy.run(mode, run);
|
|
10
34
|
}
|
|
11
35
|
|
|
12
36
|
export function currentToolAutonomyMode(): AutonomyMode | undefined {
|
|
13
|
-
|
|
37
|
+
const direct = toolAutonomy.getStore();
|
|
38
|
+
if (direct !== undefined) return direct;
|
|
39
|
+
const preset = toolPreset.getStore();
|
|
40
|
+
return preset ? presetToAutonomyMode(preset) : undefined;
|
|
14
41
|
}
|
|
15
42
|
|
|
16
43
|
export interface ToolApprovalInput {
|
|
17
|
-
|
|
44
|
+
permissionPreset?: PermissionPresetId | string | undefined;
|
|
45
|
+
mode?: AutonomyMode | undefined;
|
|
18
46
|
tool: string;
|
|
19
47
|
args: Record<string, unknown>;
|
|
20
48
|
risk: string;
|
|
@@ -23,18 +51,17 @@ export interface ToolApprovalInput {
|
|
|
23
51
|
reason?: string | undefined;
|
|
24
52
|
}
|
|
25
53
|
|
|
26
|
-
/** Read the live session
|
|
54
|
+
/** Read the live session permission preset from the tool context; never infer it from a tool argument. */
|
|
27
55
|
export function isAutonomousToolContext(context: unknown): boolean {
|
|
28
56
|
if (!context || typeof context !== 'object' || Array.isArray(context)) return false;
|
|
29
57
|
const parentLoop = (context as { parentLoop?: unknown }).parentLoop;
|
|
30
58
|
if (!parentLoop || typeof parentLoop !== 'object' || Array.isArray(parentLoop)) return false;
|
|
31
59
|
const config = (parentLoop as { config?: unknown }).config;
|
|
32
60
|
if (!config || typeof config !== 'object' || Array.isArray(config)) return false;
|
|
33
|
-
|
|
34
|
-
return mode === 'C' || mode === undefined;
|
|
61
|
+
return resolveConfigPermissionPreset(config as Record<string, unknown>, 'danger-full-access') === 'danger-full-access';
|
|
35
62
|
}
|
|
36
63
|
|
|
37
|
-
const SHELL_TOOLS = new Set(['sysRun', 'sysRunBg', 'terminal_persistent_shell', 'task_bg']);
|
|
64
|
+
const SHELL_TOOLS = new Set(['sysRun', 'sysRunBg', 'terminal_persistent_shell', 'terminal_pty', 'task_bg']);
|
|
38
65
|
const WHOLE_FILE_DELETE = /(?:^|[;&|\n(]\s*)(?:(?:sudo|doas|pkexec|command|env)\s+)*(?:rm|unlink|rmdir|shred|srm|del|erase|Remove-Item)\b|\bgit\s+rm\b/i;
|
|
39
66
|
const DELETE_API_CALL = /\b(?:os\.(?:remove|unlink)|shutil\.rmtree|fs\.(?:rm|unlink)(?:Sync)?|\.unlink|\.rmdir)\s*\(/i;
|
|
40
67
|
const NESTED_SHELL_DELETE = /\b(?:bash|sh|zsh|dash)\s+-c\s+['"]\s*(?:rm|unlink|rmdir|shred|srm)\b|\b(?:powershell|pwsh)\s+(?:-Command|-c)\s+['"]?\s*Remove-Item\b/i;
|
|
@@ -84,7 +111,7 @@ export function isWholeFileDeletion(tool: string, args: Record<string, unknown>)
|
|
|
84
111
|
|| NESTED_SHELL_DELETE.test(command));
|
|
85
112
|
}
|
|
86
113
|
|
|
87
|
-
/** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in
|
|
114
|
+
/** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Workspace Write or Full access unless uploading or downloading files. */
|
|
88
115
|
export function isRoutineBrowserVerification(tool: string, args: Record<string, unknown>): boolean {
|
|
89
116
|
if (canonicalPolicyTool(tool) !== 'browser_act') return false;
|
|
90
117
|
const actions = Array.isArray(args?.actions) ? args.actions : [];
|
|
@@ -120,7 +147,11 @@ function touchesCredentialMaterial(input: ToolApprovalInput): boolean {
|
|
|
120
147
|
export function requiresToolApproval(input: ToolApprovalInput): boolean {
|
|
121
148
|
if (!input || typeof input !== 'object') return true;
|
|
122
149
|
const canonical = canonicalPolicyTool(input.tool);
|
|
123
|
-
|
|
150
|
+
const preset = normalizePermissionPreset(input.permissionPreset)
|
|
151
|
+
?? normalizePermissionPreset(input.mode)
|
|
152
|
+
?? 'danger-full-access';
|
|
153
|
+
|
|
154
|
+
if (preset === 'danger-full-access') {
|
|
124
155
|
if (touchesCredentialMaterial(input)) {
|
|
125
156
|
return true;
|
|
126
157
|
}
|
|
@@ -132,11 +163,11 @@ export function requiresToolApproval(input: ToolApprovalInput): boolean {
|
|
|
132
163
|
return canonical !== 'fs_delete' || !input.standingApproval;
|
|
133
164
|
}
|
|
134
165
|
if (input.standingApproval) return false;
|
|
135
|
-
if (
|
|
166
|
+
if (preset !== 'read-only' && isRoutineBrowserVerification(input.tool, input.args)) {
|
|
136
167
|
return false;
|
|
137
168
|
}
|
|
138
169
|
return input.risk === 'extreme'
|
|
139
170
|
|| input.heavyDownload
|
|
140
171
|
|| input.risk === 'dangerous'
|
|
141
|
-
||
|
|
172
|
+
|| preset === 'read-only';
|
|
142
173
|
}
|
|
@@ -754,13 +754,40 @@ export class CausyneBrowser {
|
|
|
754
754
|
getWorkspace() {
|
|
755
755
|
return this.workspace;
|
|
756
756
|
}
|
|
757
|
-
async enqueueOperation(operation) {
|
|
757
|
+
async enqueueOperation(operation, signal) {
|
|
758
|
+
if (signal?.aborted) {
|
|
759
|
+
throw new Error('Browser operation aborted.');
|
|
760
|
+
}
|
|
758
761
|
this.queuedOperations++;
|
|
759
762
|
const previous = this.operationTail;
|
|
760
763
|
let release;
|
|
761
764
|
this.operationTail = new Promise(resolve => { release = resolve; });
|
|
762
|
-
await previous;
|
|
763
765
|
try {
|
|
766
|
+
if (signal) {
|
|
767
|
+
await new Promise((resolve, reject) => {
|
|
768
|
+
const onAbort = () => {
|
|
769
|
+
reject(new Error('Browser operation aborted while waiting in queue.'));
|
|
770
|
+
};
|
|
771
|
+
if (signal.aborted) {
|
|
772
|
+
onAbort();
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
776
|
+
previous.then(() => {
|
|
777
|
+
signal.removeEventListener('abort', onAbort);
|
|
778
|
+
resolve();
|
|
779
|
+
}, () => {
|
|
780
|
+
signal.removeEventListener('abort', onAbort);
|
|
781
|
+
resolve();
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
await previous;
|
|
787
|
+
}
|
|
788
|
+
if (signal?.aborted) {
|
|
789
|
+
throw new Error('Browser operation aborted.');
|
|
790
|
+
}
|
|
764
791
|
return await operation();
|
|
765
792
|
}
|
|
766
793
|
finally {
|
|
@@ -769,7 +796,7 @@ export class CausyneBrowser {
|
|
|
769
796
|
}
|
|
770
797
|
}
|
|
771
798
|
async run(actions, options = {}) {
|
|
772
|
-
return this.enqueueOperation(() => this.runUnlocked(actions, options));
|
|
799
|
+
return this.enqueueOperation(() => this.runUnlocked(actions, options), options.signal);
|
|
773
800
|
}
|
|
774
801
|
async runUnlocked(actions, options = {}) {
|
|
775
802
|
if (!Array.isArray(actions) || actions.length === 0 || actions.length > 40) {
|
|
@@ -644,6 +644,7 @@ export interface BrowserActionResult {
|
|
|
644
644
|
|
|
645
645
|
export interface BrowserRunOptions {
|
|
646
646
|
workspace?: string;
|
|
647
|
+
signal?: AbortSignal | undefined;
|
|
647
648
|
}
|
|
648
649
|
|
|
649
650
|
interface RuntimeOptions {
|
|
@@ -1166,13 +1167,42 @@ export class CausyneBrowser {
|
|
|
1166
1167
|
return this.workspace;
|
|
1167
1168
|
}
|
|
1168
1169
|
|
|
1169
|
-
private async enqueueOperation<T>(operation: () => Promise<T
|
|
1170
|
+
private async enqueueOperation<T>(operation: () => Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
1171
|
+
if (signal?.aborted) {
|
|
1172
|
+
throw new Error('Browser operation aborted.');
|
|
1173
|
+
}
|
|
1170
1174
|
this.queuedOperations++;
|
|
1171
1175
|
const previous = this.operationTail;
|
|
1172
1176
|
let release!: () => void;
|
|
1173
1177
|
this.operationTail = new Promise<void>(resolve => { release = resolve; });
|
|
1174
|
-
await previous;
|
|
1175
1178
|
try {
|
|
1179
|
+
if (signal) {
|
|
1180
|
+
await new Promise<void>((resolve, reject) => {
|
|
1181
|
+
const onAbort = (): void => {
|
|
1182
|
+
reject(new Error('Browser operation aborted while waiting in queue.'));
|
|
1183
|
+
};
|
|
1184
|
+
if (signal.aborted) {
|
|
1185
|
+
onAbort();
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
1189
|
+
previous.then(
|
|
1190
|
+
() => {
|
|
1191
|
+
signal.removeEventListener('abort', onAbort);
|
|
1192
|
+
resolve();
|
|
1193
|
+
},
|
|
1194
|
+
() => {
|
|
1195
|
+
signal.removeEventListener('abort', onAbort);
|
|
1196
|
+
resolve();
|
|
1197
|
+
}
|
|
1198
|
+
);
|
|
1199
|
+
});
|
|
1200
|
+
} else {
|
|
1201
|
+
await previous;
|
|
1202
|
+
}
|
|
1203
|
+
if (signal?.aborted) {
|
|
1204
|
+
throw new Error('Browser operation aborted.');
|
|
1205
|
+
}
|
|
1176
1206
|
return await operation();
|
|
1177
1207
|
} finally {
|
|
1178
1208
|
this.queuedOperations--;
|
|
@@ -1181,7 +1211,7 @@ export class CausyneBrowser {
|
|
|
1181
1211
|
}
|
|
1182
1212
|
|
|
1183
1213
|
async run(actions: BrowserAction[], options: BrowserRunOptions = {}): Promise<BrowserActionResult[]> {
|
|
1184
|
-
return this.enqueueOperation(() => this.runUnlocked(actions, options));
|
|
1214
|
+
return this.enqueueOperation(() => this.runUnlocked(actions, options), options.signal);
|
|
1185
1215
|
}
|
|
1186
1216
|
|
|
1187
1217
|
private async runUnlocked(actions: BrowserAction[], options: BrowserRunOptions = {}): Promise<BrowserActionResult[]> {
|
package/src/browser/urlPolicy.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lookup } from 'node:dns/promises';
|
|
2
2
|
import { isIP } from 'node:net';
|
|
3
3
|
const DNS_CACHE_MS = 5 * 60_000;
|
|
4
|
+
const MAX_DNS_CACHE_ENTRIES = 512;
|
|
4
5
|
const hostCache = new Map();
|
|
5
6
|
function isPrivateIpv4(address) {
|
|
6
7
|
const parts = address.split('.').map(Number);
|
|
@@ -75,7 +76,19 @@ async function resolvedAddresses(hostname) {
|
|
|
75
76
|
return cached.addresses;
|
|
76
77
|
const results = await lookup(hostname, { all: true, verbatim: true });
|
|
77
78
|
const addresses = [...new Set(results.map(result => result.address))];
|
|
78
|
-
|
|
79
|
+
const now = Date.now();
|
|
80
|
+
for (const [key, value] of hostCache) {
|
|
81
|
+
if (value.expiresAt <= now)
|
|
82
|
+
hostCache.delete(key);
|
|
83
|
+
}
|
|
84
|
+
hostCache.delete(hostname);
|
|
85
|
+
while (hostCache.size >= MAX_DNS_CACHE_ENTRIES) {
|
|
86
|
+
const oldest = hostCache.keys().next();
|
|
87
|
+
if (oldest.done)
|
|
88
|
+
break;
|
|
89
|
+
hostCache.delete(oldest.value);
|
|
90
|
+
}
|
|
91
|
+
hostCache.set(hostname, { expiresAt: now + DNS_CACHE_MS, addresses });
|
|
79
92
|
return addresses;
|
|
80
93
|
}
|
|
81
94
|
export function isLoopbackHost(hostname) {
|
package/src/browser/urlPolicy.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { lookup } from 'node:dns/promises';
|
|
|
2
2
|
import { isIP } from 'node:net';
|
|
3
3
|
|
|
4
4
|
const DNS_CACHE_MS = 5 * 60_000;
|
|
5
|
+
const MAX_DNS_CACHE_ENTRIES = 512;
|
|
5
6
|
const hostCache = new Map<string, { expiresAt: number; addresses: string[] }>();
|
|
6
7
|
|
|
7
8
|
function isPrivateIpv4(address: string): boolean {
|
|
@@ -72,7 +73,17 @@ async function resolvedAddresses(hostname: string): Promise<string[]> {
|
|
|
72
73
|
if (cached && cached.expiresAt > Date.now()) return cached.addresses;
|
|
73
74
|
const results = await lookup(hostname, { all: true, verbatim: true });
|
|
74
75
|
const addresses = [...new Set(results.map(result => result.address))];
|
|
75
|
-
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
for (const [key, value] of hostCache) {
|
|
78
|
+
if (value.expiresAt <= now) hostCache.delete(key);
|
|
79
|
+
}
|
|
80
|
+
hostCache.delete(hostname);
|
|
81
|
+
while (hostCache.size >= MAX_DNS_CACHE_ENTRIES) {
|
|
82
|
+
const oldest = hostCache.keys().next();
|
|
83
|
+
if (oldest.done) break;
|
|
84
|
+
hostCache.delete(oldest.value);
|
|
85
|
+
}
|
|
86
|
+
hostCache.set(hostname, { expiresAt: now + DNS_CACHE_MS, addresses });
|
|
76
87
|
return addresses;
|
|
77
88
|
}
|
|
78
89
|
|
package/src/cliMode.js
CHANGED
|
@@ -25,7 +25,9 @@ import { auditLog } from './auditLog.js';
|
|
|
25
25
|
import { isAcpProvider } from './providers/acp.js';
|
|
26
26
|
import { isPiProvider } from './providers/pi.js';
|
|
27
27
|
import { isAntigravityProvider } from './providers/antigravity.js';
|
|
28
|
-
import { runHeadlessTask,
|
|
28
|
+
import { runHeadlessTask, parsePermissionPreset, parseMaxTurns, parseVariantOption } from './headlessCli.js';
|
|
29
|
+
import { resolveConfigPermissionPreset } from './permissionPresets.js';
|
|
30
|
+
import { reconcileConfigVariant } from './modelVariants.js';
|
|
29
31
|
import { closeAll as closeAllMcpServers, setActiveWorkspace as setActiveMcpWorkspace } from './mcp/mcpRegistry.js';
|
|
30
32
|
import { lspSessionManager } from './lsp/lspClient.js';
|
|
31
33
|
import { backgroundTaskManager } from './backgroundTasks.js';
|
|
@@ -242,9 +244,9 @@ export async function runTask(task, options = {}) {
|
|
|
242
244
|
if (parsedVariant)
|
|
243
245
|
loopOptions.variant = parsedVariant;
|
|
244
246
|
const loop = new AgentLoop(conn, taskId, task, loopOptions);
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
loop.
|
|
247
|
+
const permPreset = parsePermissionPreset(options?.permissionMode);
|
|
248
|
+
if (permPreset)
|
|
249
|
+
loop.setPermissionPreset(permPreset);
|
|
248
250
|
const maxTurns = parseMaxTurns(options?.maxTurns);
|
|
249
251
|
if (maxTurns !== undefined)
|
|
250
252
|
loop.maxStepsCeiling = maxTurns;
|
|
@@ -301,17 +303,27 @@ export async function chatMode(options) {
|
|
|
301
303
|
if (parsedVariant)
|
|
302
304
|
loopOptions.variant = parsedVariant;
|
|
303
305
|
let loop = new AgentLoop(conn, taskId, null, loopOptions);
|
|
304
|
-
const
|
|
305
|
-
if (
|
|
306
|
-
loop.
|
|
306
|
+
const permPreset = parsePermissionPreset(options?.permissionMode);
|
|
307
|
+
if (permPreset) {
|
|
308
|
+
loop.setPermissionPreset(permPreset);
|
|
307
309
|
loop.updateTierLimits();
|
|
308
310
|
}
|
|
309
311
|
const config = loop.config || loadConfig();
|
|
312
|
+
const prevSavedEffort = typeof config.reasoningEffort === 'string' ? config.reasoningEffort : '';
|
|
313
|
+
const reconciledVariant = reconcileConfigVariant(config);
|
|
314
|
+
if (prevSavedEffort && reconciledVariant !== prevSavedEffort && !options?.variant) {
|
|
315
|
+
const persisted = loadConfig();
|
|
316
|
+
reconcileConfigVariant(persisted);
|
|
317
|
+
saveConfig(persisted);
|
|
318
|
+
loop.updateTierLimits?.();
|
|
319
|
+
}
|
|
320
|
+
const activePreset = resolveConfigPermissionPreset(config);
|
|
310
321
|
const headerInfo = {
|
|
311
322
|
version: `v${getPackageVersion()}`,
|
|
312
323
|
provider: config.provider,
|
|
313
324
|
model: config.model,
|
|
314
|
-
variant:
|
|
325
|
+
variant: reconciledVariant,
|
|
326
|
+
permissionPreset: activePreset,
|
|
315
327
|
autonomyMode: config.autonomyMode,
|
|
316
328
|
tier: config.tier,
|
|
317
329
|
workspace: loop.sandbox && loop.sandbox.grantAllAccess
|
|
@@ -370,7 +382,7 @@ export async function chatMode(options) {
|
|
|
370
382
|
surface,
|
|
371
383
|
messageActionLoop: loop,
|
|
372
384
|
onInterrupt: () => loop.abort(),
|
|
373
|
-
getMode: () => loop.config
|
|
385
|
+
getMode: () => resolveConfigPermissionPreset(loop.config || config),
|
|
374
386
|
onOpenMode: async () => {
|
|
375
387
|
await openModeControl(prompt, loop);
|
|
376
388
|
prompt?.refreshPinnedPanels?.(loop);
|
package/src/cliMode.ts
CHANGED
|
@@ -25,7 +25,9 @@ import { auditLog } from './auditLog.js';
|
|
|
25
25
|
import { isAcpProvider } from './providers/acp.js';
|
|
26
26
|
import { isPiProvider } from './providers/pi.js';
|
|
27
27
|
import { isAntigravityProvider } from './providers/antigravity.js';
|
|
28
|
-
import { runHeadlessTask,
|
|
28
|
+
import { runHeadlessTask, parsePermissionPreset, parseMaxTurns, parseVariantOption } from './headlessCli.js';
|
|
29
|
+
import { resolveConfigPermissionPreset } from './permissionPresets.js';
|
|
30
|
+
import { reconcileConfigVariant } from './modelVariants.js';
|
|
29
31
|
import { closeAll as closeAllMcpServers, setActiveWorkspace as setActiveMcpWorkspace } from './mcp/mcpRegistry.js';
|
|
30
32
|
import { lspSessionManager } from './lsp/lspClient.js';
|
|
31
33
|
import { backgroundTaskManager } from './backgroundTasks.js';
|
|
@@ -272,8 +274,8 @@ export async function runTask(task: string, options: RunTaskOptions = {}): Promi
|
|
|
272
274
|
if (parsedVariant) loopOptions.variant = parsedVariant;
|
|
273
275
|
const loop = new AgentLoop(conn, taskId, task, loopOptions);
|
|
274
276
|
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
+
const permPreset = parsePermissionPreset(options?.permissionMode);
|
|
278
|
+
if (permPreset) loop.setPermissionPreset(permPreset);
|
|
277
279
|
const maxTurns = parseMaxTurns(options?.maxTurns);
|
|
278
280
|
if (maxTurns !== undefined) loop.maxStepsCeiling = maxTurns;
|
|
279
281
|
|
|
@@ -329,18 +331,28 @@ export async function chatMode(options?: ChatModeOptions | null): Promise<void>
|
|
|
329
331
|
const parsedVariant = parseVariantOption(options?.variant);
|
|
330
332
|
if (parsedVariant) loopOptions.variant = parsedVariant;
|
|
331
333
|
let loop: any = new AgentLoop(conn, taskId, null, loopOptions);
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
334
|
-
loop.
|
|
334
|
+
const permPreset = parsePermissionPreset(options?.permissionMode);
|
|
335
|
+
if (permPreset) {
|
|
336
|
+
loop.setPermissionPreset(permPreset);
|
|
335
337
|
loop.updateTierLimits();
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
const config = loop.config || loadConfig();
|
|
341
|
+
const prevSavedEffort = typeof config.reasoningEffort === 'string' ? config.reasoningEffort : '';
|
|
342
|
+
const reconciledVariant = reconcileConfigVariant(config);
|
|
343
|
+
if (prevSavedEffort && reconciledVariant !== prevSavedEffort && !options?.variant) {
|
|
344
|
+
const persisted = loadConfig();
|
|
345
|
+
reconcileConfigVariant(persisted);
|
|
346
|
+
saveConfig(persisted);
|
|
347
|
+
loop.updateTierLimits?.();
|
|
348
|
+
}
|
|
349
|
+
const activePreset = resolveConfigPermissionPreset(config);
|
|
339
350
|
const headerInfo: Record<string, any> = {
|
|
340
351
|
version: `v${getPackageVersion()}`,
|
|
341
352
|
provider: config.provider,
|
|
342
353
|
model: config.model,
|
|
343
|
-
variant:
|
|
354
|
+
variant: reconciledVariant,
|
|
355
|
+
permissionPreset: activePreset,
|
|
344
356
|
autonomyMode: config.autonomyMode,
|
|
345
357
|
tier: config.tier,
|
|
346
358
|
workspace: loop.sandbox && loop.sandbox.grantAllAccess
|
|
@@ -401,7 +413,7 @@ export async function chatMode(options?: ChatModeOptions | null): Promise<void>
|
|
|
401
413
|
surface,
|
|
402
414
|
messageActionLoop: loop,
|
|
403
415
|
onInterrupt: () => loop.abort(),
|
|
404
|
-
getMode: () => loop.config
|
|
416
|
+
getMode: () => resolveConfigPermissionPreset(loop.config || config),
|
|
405
417
|
onOpenMode: async () => {
|
|
406
418
|
await openModeControl(prompt, loop);
|
|
407
419
|
prompt?.refreshPinnedPanels?.(loop);
|