@causyne/agent 1.20.124 → 1.20.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/causyne.js +1 -1
- package/docs/THIRD_PARTY_NOTICES.md +36 -2
- package/package.json +6 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +142 -53
- package/src/agentLoop.ts +151 -50
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +61 -3
- package/src/browser/causyneBrowser.ts +65 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +365 -45
- package/src/commands.ts +403 -45
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/memory/episodicStore.js +40 -0
- package/src/memory/episodicStore.ts +46 -0
- package/src/memory.js +67 -0
- package/src/memory.ts +65 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/personalization.js +365 -0
- package/src/personalization.ts +471 -0
- package/src/projectInstructions.js +30 -10
- package/src/projectInstructions.ts +31 -12
- package/src/providers/acp.js +3 -2
- package/src/providers/acp.ts +3 -2
- package/src/providers/antigravity.js +64 -9
- package/src/providers/antigravity.ts +75 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/memoryWrite.js +15 -1
- package/src/tools/memoryWrite.ts +16 -1
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/osSandbox.js +1 -1
- package/src/tools/osSandbox.ts +1 -1
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1108 -0
- package/src/tools/ptyTerminal.ts +1245 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +905 -0
- package/src/web/client/browserPanel.ts +872 -0
- package/src/web/client/chatStream.js +321 -0
- package/src/web/client/chatStream.ts +297 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +271 -0
- package/src/web/client/dom.ts +272 -0
- package/src/web/client/filesAndCanvas.js +233 -0
- package/src/web/client/filesAndCanvas.ts +240 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +316 -0
- package/src/web/client/main.ts +391 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +824 -0
- package/src/web/client/settingsModal.ts +959 -0
- package/src/web/client/state.js +280 -0
- package/src/web/client/state.ts +259 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +89 -0
- package/src/web/client/studioLayout.ts +103 -0
- package/src/web/client/studioShell.js +660 -0
- package/src/web/client/studioShell.ts +672 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +606 -0
- package/src/web/client/terminalPanel.ts +632 -0
- package/src/web/client/terminalTheme.js +249 -0
- package/src/web/client/terminalTheme.ts +258 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +322 -0
- package/src/web/client/validators.js +147 -0
- package/src/web/client/validators.ts +140 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +409 -0
- package/src/web/server/routesBrowser.ts +435 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesSettings.js +344 -0
- package/src/web/server/routesSettings.ts +397 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +104 -0
- package/src/web/server/staticAssets.ts +116 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +78 -2448
- package/src/web/skybridgeServer.ts +120 -2600
- package/src/web/skybridgeUi.js +20 -450
- package/src/web/skybridgeUi.ts +24 -455
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +935 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +951 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +388 -0
- package/src/web/ui/modalsTemplate.ts +388 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +256 -0
- package/src/web/ui/studioTemplate.ts +256 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- package/src/web/skybridgeStyles.ts +0 -828
|
@@ -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) {
|
|
@@ -1461,6 +1488,37 @@ export class CausyneBrowser {
|
|
|
1461
1488
|
async captureLiveFrame(options = {}) {
|
|
1462
1489
|
return this.enqueueOperation(() => this.captureLiveFrameUnlocked(options));
|
|
1463
1490
|
}
|
|
1491
|
+
async closeLiveSession() {
|
|
1492
|
+
return this.enqueueOperation(async () => {
|
|
1493
|
+
await this.close();
|
|
1494
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
async closeLiveTab(tabId) {
|
|
1498
|
+
return this.enqueueOperation(async () => {
|
|
1499
|
+
if (!this.isSessionHealthy()) {
|
|
1500
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1501
|
+
}
|
|
1502
|
+
const target = this.tabs.get(tabId);
|
|
1503
|
+
if (target) {
|
|
1504
|
+
if (!target.page.isClosed()) {
|
|
1505
|
+
await target.page.close().catch(() => { });
|
|
1506
|
+
}
|
|
1507
|
+
this.tabs.delete(tabId);
|
|
1508
|
+
if (this.activeTabId === tabId)
|
|
1509
|
+
this.activeTabId = null;
|
|
1510
|
+
}
|
|
1511
|
+
const liveTabs = [...this.tabs.values()].filter((t) => !t.page.isClosed() && !t.crashed);
|
|
1512
|
+
if (liveTabs.length === 0) {
|
|
1513
|
+
await this.close();
|
|
1514
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1515
|
+
}
|
|
1516
|
+
if (!this.activeTabId || !this.tabs.has(this.activeTabId)) {
|
|
1517
|
+
this.activeTabId = liveTabs[liveTabs.length - 1].id;
|
|
1518
|
+
}
|
|
1519
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1464
1522
|
async captureLiveFrameUnlocked(options = {}) {
|
|
1465
1523
|
const status = this.getRuntimeStatus();
|
|
1466
1524
|
if (!this.isSessionHealthy()) {
|
|
@@ -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[]> {
|
|
@@ -1883,6 +1913,38 @@ export class CausyneBrowser {
|
|
|
1883
1913
|
return this.enqueueOperation(() => this.captureLiveFrameUnlocked(options));
|
|
1884
1914
|
}
|
|
1885
1915
|
|
|
1916
|
+
async closeLiveSession(): Promise<LiveBrowserFrame> {
|
|
1917
|
+
return this.enqueueOperation(async () => {
|
|
1918
|
+
await this.close();
|
|
1919
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
async closeLiveTab(tabId: string): Promise<LiveBrowserFrame> {
|
|
1924
|
+
return this.enqueueOperation(async () => {
|
|
1925
|
+
if (!this.isSessionHealthy()) {
|
|
1926
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1927
|
+
}
|
|
1928
|
+
const target = this.tabs.get(tabId);
|
|
1929
|
+
if (target) {
|
|
1930
|
+
if (!target.page.isClosed()) {
|
|
1931
|
+
await target.page.close().catch(() => {});
|
|
1932
|
+
}
|
|
1933
|
+
this.tabs.delete(tabId);
|
|
1934
|
+
if (this.activeTabId === tabId) this.activeTabId = null;
|
|
1935
|
+
}
|
|
1936
|
+
const liveTabs = [...this.tabs.values()].filter((t) => !t.page.isClosed() && !t.crashed);
|
|
1937
|
+
if (liveTabs.length === 0) {
|
|
1938
|
+
await this.close();
|
|
1939
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1940
|
+
}
|
|
1941
|
+
if (!this.activeTabId || !this.tabs.has(this.activeTabId)) {
|
|
1942
|
+
this.activeTabId = liveTabs[liveTabs.length - 1]!.id;
|
|
1943
|
+
}
|
|
1944
|
+
return this.captureLiveFrameUnlocked({ ensureStarted: false });
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1886
1948
|
private async captureLiveFrameUnlocked(options: { ensureStarted?: boolean | undefined } = {}): Promise<LiveBrowserFrame> {
|
|
1887
1949
|
const status = this.getRuntimeStatus();
|
|
1888
1950
|
if (!this.isSessionHealthy()) {
|
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);
|