@causyne/agent 1.20.121 → 1.20.122
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/README.md +3 -3
- package/package.json +1 -1
- package/src/acp/agentCatalog.js +81 -26
- package/src/acp/agentCatalog.ts +73 -29
- package/src/acp/client.js +210 -53
- package/src/acp/client.ts +202 -52
- package/src/acp/peerProfiles.js +55 -22
- package/src/acp/peerProfiles.ts +51 -22
- package/src/acp/protocol.js +37 -8
- package/src/acp/protocol.ts +30 -8
- package/src/acp/server.js +123 -25
- package/src/acp/server.ts +124 -24
- package/src/agent/errorClassifier.js +6 -2
- package/src/agent/errorClassifier.ts +6 -2
- package/src/agentLoop.js +11 -5
- package/src/agentLoop.ts +11 -5
- package/src/approvalGrants.js +19 -7
- package/src/approvalGrants.ts +20 -7
- package/src/approvalPolicy.js +48 -15
- package/src/approvalPolicy.ts +46 -15
- package/src/autoUpdate.js +5 -2
- package/src/autoUpdate.ts +5 -2
- package/src/browser/causyneBrowser.js +3 -2
- package/src/browser/causyneBrowser.ts +3 -2
- package/src/browser/searchProviders.js +1 -1
- package/src/browser/searchProviders.ts +1 -1
- package/src/config.js +287 -250
- package/src/config.ts +342 -0
- package/src/configVault.js +84 -17
- package/src/configVault.ts +77 -17
- package/src/continuum/compactor.js +2 -1
- package/src/continuum/compactor.ts +2 -1
- package/src/continuum/sanitizer.js +10 -3
- package/src/continuum/sanitizer.ts +9 -3
- package/src/continuum/ui/continuumPickerView.js +3 -2
- package/src/continuum/ui/continuumPickerView.ts +3 -2
- package/src/cortex/vectorDb.js +26 -15
- package/src/cortex/vectorDb.ts +26 -16
- package/src/creative/liveBridge.js +7 -5
- package/src/creative/liveBridge.ts +7 -5
- package/src/creative/studioScripts.js +16 -5
- package/src/creative/studioScripts.ts +14 -5
- package/src/decisionPolicy.js +16 -4
- package/src/decisionPolicy.ts +14 -4
- package/src/documentEngine/antiSlopAuditor.js +10 -5
- package/src/documentEngine/antiSlopAuditor.ts +11 -5
- package/src/documentEngine/documentForge.js +47 -15
- package/src/documentEngine/documentForge.ts +43 -14
- package/src/engines/design.js +2 -1
- package/src/engines/design.ts +2 -1
- package/src/engines/film.js +4 -4
- package/src/engines/film.ts +2 -2
- package/src/engines/light.js +2 -1
- package/src/engines/light.ts +2 -1
- package/src/engines/registry.js +1 -1
- package/src/engines/registry.ts +1 -1
- package/src/engines/reverseHarness.js +4 -3
- package/src/engines/reverseHarness.ts +4 -3
- package/src/headlessCli.js +2 -1
- package/src/headlessCli.ts +2 -1
- package/src/historyPruner.js +3 -2
- package/src/historyPruner.ts +3 -2
- package/src/hooks.js +3 -0
- package/src/hooks.ts +3 -0
- package/src/implementationPlan.js +21 -11
- package/src/implementationPlan.ts +21 -11
- package/src/infra/atomicWriter.js +4 -1
- package/src/infra/atomicWriter.ts +4 -1
- package/src/launchIntent.js +1 -1
- package/src/launchIntent.ts +1 -1
- package/src/memory/scopedFacts.js +1 -1
- package/src/memory/scopedFacts.ts +1 -1
- package/src/memory/symbolFolder.js +1 -1
- package/src/memory/symbolFolder.ts +1 -1
- package/src/modelRouter.js +1 -1
- package/src/modelRouter.ts +1 -1
- package/src/observer/evidence.js +10 -4
- package/src/observer/evidence.ts +10 -4
- package/src/osKeychain.js +62 -8
- package/src/osKeychain.ts +50 -8
- package/src/perception.js +3 -2
- package/src/perception.ts +3 -2
- package/src/planCache.js +2 -2
- package/src/planCache.ts +2 -2
- package/src/pluginsFactory/pluginsFactory.js +19 -11
- package/src/pluginsFactory/pluginsFactory.ts +18 -11
- package/src/promptMentions.js +2 -2
- package/src/promptMentions.ts +2 -2
- package/src/providers/acp.js +1 -1
- package/src/providers/acp.ts +1 -1
- package/src/providers/anthropic.js +327 -401
- package/src/providers/anthropic.ts +386 -0
- package/src/providers/antigravity.js +10 -4
- package/src/providers/antigravity.ts +10 -4
- package/src/providers/base.js +221 -319
- package/src/providers/base.ts +340 -0
- package/src/providers/byokHttp.js +58 -15
- package/src/providers/byokHttp.ts +59 -16
- package/src/providers/byokStream.js +142 -51
- package/src/providers/byokStream.ts +146 -42
- package/src/providers/dashscope-byok.js +97 -89
- package/src/providers/dashscope-byok.ts +114 -0
- package/src/providers/deepseek.js +73 -72
- package/src/providers/deepseek.ts +99 -0
- package/src/providers/factory.js +35 -28
- package/src/providers/factory.ts +40 -0
- package/src/providers/gemini.js +227 -278
- package/src/providers/gemini.ts +261 -0
- package/src/providers/loopGuard.js +9 -5
- package/src/providers/loopGuard.ts +10 -5
- package/src/providers/moonshot.js +70 -72
- package/src/providers/moonshot.ts +93 -0
- package/src/providers/muse.js +82 -152
- package/src/providers/muse.ts +122 -0
- package/src/providers/ollama.js +114 -106
- package/src/providers/ollama.ts +135 -0
- package/src/providers/openai-compatible.js +113 -96
- package/src/providers/openai-compatible.ts +139 -0
- package/src/providers/openai.js +22 -15
- package/src/providers/openai.ts +30 -0
- package/src/providers/openrouter.js +136 -74
- package/src/providers/openrouter.ts +133 -72
- package/src/providers/pi.js +6 -0
- package/src/providers/pi.ts +6 -0
- package/src/providers/qwen-byok.js +96 -87
- package/src/providers/qwen-byok.ts +113 -0
- package/src/providers/toolContracts.js +40 -14
- package/src/providers/toolContracts.ts +35 -14
- package/src/providers/wireNormalizer.js +78 -11
- package/src/providers/wireNormalizer.ts +68 -12
- package/src/providers/xai.js +73 -72
- package/src/providers/xai.ts +97 -0
- package/src/reliability/assetEvidence.js +4 -2
- package/src/reliability/assetEvidence.ts +4 -2
- package/src/sandbox.js +489 -554
- package/src/sandbox.ts +552 -0
- package/src/sandboxPolicy.js +95 -16
- package/src/sandboxPolicy.ts +97 -16
- package/src/sessionJournal.js +8 -3
- package/src/sessionJournal.ts +9 -3
- package/src/skills/skillResourceSafety.js +19 -8
- package/src/skills/skillResourceSafety.ts +16 -7
- package/src/skillsManager.js +3 -3
- package/src/skillsManager.ts +3 -3
- package/src/smartToolsUse.js +28 -4
- package/src/smartToolsUse.ts +29 -7
- package/src/stallGuard.js +45 -22
- package/src/stallGuard.ts +46 -22
- package/src/subagentJournal.js +6 -4
- package/src/subagentJournal.ts +6 -4
- package/src/textDiff.js +6 -1
- package/src/textDiff.ts +6 -1
- package/src/timeMachine.js +7 -1
- package/src/timeMachine.ts +7 -1
- package/src/tokenTracker.js +43 -28
- package/src/tokenTracker.ts +44 -30
- package/src/toolPacks.js +3 -1
- package/src/toolPacks.ts +3 -1
- package/src/tools/archive.js +245 -35
- package/src/tools/archive.ts +244 -35
- package/src/tools/computerUse.js +7 -3
- package/src/tools/computerUse.ts +7 -3
- package/src/tools/creativeApps.js +13 -8
- package/src/tools/creativeApps.ts +22 -9
- package/src/tools/deferredMcpSearch.js +26 -14
- package/src/tools/deferredMcpSearch.ts +26 -14
- package/src/tools/desktopOpen.js +69 -10
- package/src/tools/desktopOpen.ts +70 -11
- package/src/tools/documentForge.js +167 -82
- package/src/tools/documentForge.ts +169 -84
- package/src/tools/fsEdit.js +101 -30
- package/src/tools/fsEdit.ts +105 -32
- package/src/tools/fsFind.js +8 -5
- package/src/tools/fsFind.ts +7 -4
- package/src/tools/fsRead.js +119 -13
- package/src/tools/fsRead.ts +124 -13
- package/src/tools/fsWrite.js +17 -5
- package/src/tools/fsWrite.ts +17 -7
- package/src/tools/generateMediaViaApi.js +82 -19
- package/src/tools/generateMediaViaApi.ts +80 -19
- package/src/tools/memoryRecall.js +62 -11
- package/src/tools/memoryRecall.ts +70 -13
- package/src/tools/memoryWrite.js +27 -14
- package/src/tools/memoryWrite.ts +30 -14
- package/src/tools/multiEdit.js +100 -30
- package/src/tools/multiEdit.ts +104 -32
- package/src/tools/nativeEngine.js +33 -18
- package/src/tools/nativeEngine.ts +31 -18
- package/src/tools/openSourceToolProvisioner.js +49 -14
- package/src/tools/openSourceToolProvisioner.ts +54 -15
- package/src/tools/osSandbox.js +54 -14
- package/src/tools/osSandbox.ts +48 -14
- package/src/tools/payloadSanitizer.js +40 -8
- package/src/tools/payloadSanitizer.ts +39 -8
- package/src/tools/peerAgent.js +96 -34
- package/src/tools/peerAgent.ts +114 -37
- package/src/tools/pluginsFactory.js +38 -6
- package/src/tools/pluginsFactory.ts +42 -6
- package/src/tools/readNativeSkill.js +10 -8
- package/src/tools/readNativeSkill.ts +10 -8
- package/src/tools/requestDecision.js +10 -3
- package/src/tools/requestDecision.ts +10 -3
- package/src/tools/resolveAutomator.js +91 -17
- package/src/tools/resolveAutomator.ts +102 -17
- package/src/tools/reverseEngineering.js +168 -41
- package/src/tools/reverseEngineering.ts +161 -41
- package/src/tools/sysRun.js +69 -29
- package/src/tools/sysRun.ts +66 -24
- package/src/tools/toolDispatch.js +24 -1
- package/src/tools/toolDispatch.ts +21 -1
- package/src/tools/toolOutputStore.js +62 -23
- package/src/tools/toolOutputStore.ts +56 -23
- package/src/tools/toolScanner.js +13 -10
- package/src/tools/toolScanner.ts +13 -10
- package/src/tools/toolSelfRepair.js +94 -28
- package/src/tools/toolSelfRepair.ts +96 -28
- package/src/tools/uiForge.js +71 -6
- package/src/tools/uiForge.ts +74 -6
- package/src/tools/viewImage.js +62 -17
- package/src/tools/viewImage.ts +57 -12
- package/src/tools/visionInspector.js +15 -3
- package/src/tools/visionInspector.ts +15 -3
- package/src/tools/walkerSafety.js +2 -0
- package/src/tools/walkerSafety.ts +1 -0
- package/src/tools/webFetch.js +105 -10
- package/src/tools/webFetch.ts +105 -11
- package/src/tui/banner.js +3 -2
- package/src/tui/banner.ts +3 -2
- package/src/tui/consoleGuard.js +12 -4
- package/src/tui/consoleGuard.ts +9 -4
- package/src/tui/messageInteraction.js +2 -3
- package/src/tui/messageInteraction.ts +2 -3
- package/src/tui/modelPicker.js +1 -0
- package/src/tui/modelPicker.ts +1 -0
- package/src/tui/overlay.js +3 -1
- package/src/tui/overlay.ts +3 -1
- package/src/tui/sessionPicker.js +3 -2
- package/src/tui/sessionPicker.ts +3 -2
- package/src/tui/sessionPickerView.js +7 -1
- package/src/tui/sessionPickerView.ts +6 -1
- package/src/tui/toolOutputNormalizer.js +2 -3
- package/src/tui/toolOutputNormalizer.ts +4 -3
- package/src/tui/viewport.js +4 -4
- package/src/tui/viewport.ts +5 -5
- package/src/tui/workspaceIdentity.js +2 -1
- package/src/tui/workspaceIdentity.ts +2 -1
- package/src/uncertainty.js +8 -3
- package/src/uncertainty.ts +8 -3
- package/src/utils/paths.js +8 -5
- package/src/utils/paths.ts +9 -7
- package/src/vfeTracker.js +9 -3
- package/src/vfeTracker.ts +9 -3
- package/src/config.d.ts +0 -2
- package/src/providers/base.d.ts +0 -94
- package/src/providers/factory.d.ts +0 -1
- package/src/sandbox.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Causyne Agent
|
|
2
2
|
|
|
3
3
|
**Development status:** Causyne Agent is under active development. It is not
|
|
4
|
-
yet a stable release, and its interfaces and behavior may change
|
|
4
|
+
yet a stable release, and its interfaces and behavior may change
|
|
5
5
|
|
|
6
6
|
Causyne Agent is an AI agent harness for complex, multi-step work. It is being
|
|
7
7
|
developed to turn intention into meaningful progress through capable,
|
|
@@ -10,13 +10,13 @@ increasingly autonomous AI, with clear boundaries and human control.
|
|
|
10
10
|
This repository is an early source-available development snapshot. Public
|
|
11
11
|
documentation is intentionally concise while the project is evolving.
|
|
12
12
|
|
|
13
|
-
Learn more at [causyne.com](https://causyne.com/)
|
|
13
|
+
Learn more at [causyne.com](https://causyne.com/)
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
This build is provided specifically for debugging, testing, and architectural evaluation. If you are exploring or debugging the harness, you can install it using the automated script or directly through npm.
|
|
18
18
|
|
|
19
|
-
For macOS, Linux, or WSL:
|
|
19
|
+
For macOS, Linux, or WSL:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
22
|
curl -fsSL https://causyne.com/install.sh | bash
|
package/package.json
CHANGED
package/src/acp/agentCatalog.js
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* Qwen, Copilot, Kimi, and Goose.
|
|
8
8
|
*/
|
|
9
9
|
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
10
11
|
import path from 'node:path';
|
|
11
12
|
import { execFile } from 'node:child_process';
|
|
12
13
|
import { promisify } from 'node:util';
|
|
13
14
|
import { AcpClient } from './client.js';
|
|
15
|
+
import { redactProviderSecrets } from '../providers/byokHttp.js';
|
|
14
16
|
const execFileAsync = promisify(execFile);
|
|
15
17
|
export const BUILTIN_PEER_PRESETS = {
|
|
16
18
|
antigravity: {
|
|
@@ -84,7 +86,7 @@ export const BUILTIN_PEER_PRESETS = {
|
|
|
84
86
|
authType: 'oauth',
|
|
85
87
|
authProbe: {
|
|
86
88
|
type: 'file_exists',
|
|
87
|
-
filePath: path.join(
|
|
89
|
+
filePath: os.homedir() ? path.join(os.homedir(), '.gemini', 'oauth_creds.json') : ''
|
|
88
90
|
},
|
|
89
91
|
setupInstruction: 'Run "gemini auth" or set GEMINI_API_KEY in your environment',
|
|
90
92
|
timeoutSeconds: 240
|
|
@@ -160,34 +162,56 @@ export const BUILTIN_PEER_PRESETS = {
|
|
|
160
162
|
* Check if a command or binary exists in PATH.
|
|
161
163
|
*/
|
|
162
164
|
export function isBinaryOnPath(binaryName) {
|
|
163
|
-
if (
|
|
164
|
-
return
|
|
165
|
+
if (typeof binaryName !== 'string' || !binaryName.trim() || /[\r\n\0]/.test(binaryName)) {
|
|
166
|
+
return false;
|
|
165
167
|
}
|
|
166
|
-
const
|
|
168
|
+
const trimmed = binaryName.trim();
|
|
169
|
+
if (path.isAbsolute(trimmed)) {
|
|
170
|
+
try {
|
|
171
|
+
const stat = fs.statSync(trimmed);
|
|
172
|
+
if (!stat.isFile())
|
|
173
|
+
return false;
|
|
174
|
+
if (process.platform !== 'win32')
|
|
175
|
+
fs.accessSync(trimmed, fs.constants.X_OK);
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (trimmed.includes('..') || trimmed.includes('/') || trimmed.includes('\\')) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
const envPath = process.env.PATH || process.env.Path || '';
|
|
167
186
|
const delimiter = process.platform === 'win32' ? ';' : ':';
|
|
168
|
-
const home =
|
|
187
|
+
const home = os.homedir();
|
|
169
188
|
const fallbackDirs = [
|
|
170
|
-
path.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
...(home && path.isAbsolute(home) ? [
|
|
190
|
+
path.join(home, '.local', 'bin'),
|
|
191
|
+
path.join(home, '.antigravity', 'antigravity', 'bin'),
|
|
192
|
+
path.join(home, '.gemini', 'antigravity-ide', 'bin'),
|
|
193
|
+
path.join(home, '.opencode', 'bin')
|
|
194
|
+
] : []),
|
|
174
195
|
'/Applications/Antigravity.app/Contents/Resources/app/bin',
|
|
175
196
|
'/Applications/Antigravity IDE.app/Contents/Resources/app/bin'
|
|
176
197
|
];
|
|
177
198
|
const dirs = [...envPath.split(delimiter), ...fallbackDirs];
|
|
178
199
|
const extensions = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
179
|
-
for (const
|
|
180
|
-
|
|
200
|
+
for (const rawDir of dirs) {
|
|
201
|
+
const dir = rawDir.trim();
|
|
202
|
+
if (!dir || !path.isAbsolute(dir))
|
|
181
203
|
continue;
|
|
182
204
|
for (const ext of extensions) {
|
|
183
|
-
const full = path.join(dir, `${
|
|
205
|
+
const full = path.join(dir, `${trimmed}${ext}`);
|
|
184
206
|
try {
|
|
185
|
-
if (fs.
|
|
207
|
+
if (fs.statSync(full).isFile()) {
|
|
208
|
+
if (process.platform !== 'win32')
|
|
209
|
+
fs.accessSync(full, fs.constants.X_OK);
|
|
186
210
|
return true;
|
|
187
211
|
}
|
|
188
212
|
}
|
|
189
213
|
catch {
|
|
190
|
-
// Skip inaccessible path segments
|
|
214
|
+
// Skip inaccessible or non-executable path segments
|
|
191
215
|
}
|
|
192
216
|
}
|
|
193
217
|
}
|
|
@@ -201,8 +225,18 @@ export async function probePresetAuth(preset) {
|
|
|
201
225
|
return { authenticated: true };
|
|
202
226
|
}
|
|
203
227
|
const probe = preset.authProbe;
|
|
204
|
-
if (probe.type === 'file_exists'
|
|
205
|
-
|
|
228
|
+
if (probe.type === 'file_exists') {
|
|
229
|
+
if (!probe.filePath || !path.isAbsolute(probe.filePath)) {
|
|
230
|
+
return { authenticated: false, reason: 'Credentials file path unavailable' };
|
|
231
|
+
}
|
|
232
|
+
let exists = false;
|
|
233
|
+
try {
|
|
234
|
+
const stat = fs.lstatSync(probe.filePath);
|
|
235
|
+
exists = !stat.isSymbolicLink() && stat.isFile();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
exists = false;
|
|
239
|
+
}
|
|
206
240
|
return {
|
|
207
241
|
authenticated: exists,
|
|
208
242
|
reason: exists ? 'OAuth credentials file detected' : `Credentials file not found at ${probe.filePath}`
|
|
@@ -213,7 +247,7 @@ export async function probePresetAuth(preset) {
|
|
|
213
247
|
return { authenticated: false, reason: `${probe.command} CLI not found on PATH` };
|
|
214
248
|
}
|
|
215
249
|
try {
|
|
216
|
-
const { stdout } = await execFileAsync(probe.command, probe.args || [], { timeout: 8000 });
|
|
250
|
+
const { stdout } = await execFileAsync(probe.command, probe.args || [], { timeout: 8000, windowsHide: true, maxBuffer: 2 * 1024 * 1024 });
|
|
217
251
|
const parsed = JSON.parse(stdout.trim());
|
|
218
252
|
if (probe.jsonField && typeof parsed === 'object' && parsed !== null) {
|
|
219
253
|
const val = parsed[probe.jsonField];
|
|
@@ -234,7 +268,7 @@ export async function probePresetAuth(preset) {
|
|
|
234
268
|
return { authenticated: false, reason: `${probe.command} CLI not found on PATH` };
|
|
235
269
|
}
|
|
236
270
|
try {
|
|
237
|
-
const result = await execFileAsync(probe.command, probe.args || [], { timeout: 8000 }).catch((e) => e);
|
|
271
|
+
const result = await execFileAsync(probe.command, probe.args || [], { timeout: 8000, windowsHide: true, maxBuffer: 2 * 1024 * 1024 }).catch((e) => e);
|
|
238
272
|
const combined = `${result?.stdout || ''}\n${result?.stderr || ''}`.toLowerCase();
|
|
239
273
|
if (probe.negativeMatch && combined.includes(probe.negativeMatch.toLowerCase())) {
|
|
240
274
|
return { authenticated: false, reason: 'CLI reported not logged in' };
|
|
@@ -256,22 +290,36 @@ export async function probePresetAuth(preset) {
|
|
|
256
290
|
*/
|
|
257
291
|
export async function testPeerHandshake(options) {
|
|
258
292
|
const cwd = options.cwd || process.cwd();
|
|
293
|
+
const rawTimeout = options.timeoutMs;
|
|
294
|
+
const timeoutMs = typeof rawTimeout === 'number' && Number.isFinite(rawTimeout) && rawTimeout > 0
|
|
295
|
+
? Math.max(1_000, Math.min(120_000, Math.round(rawTimeout)))
|
|
296
|
+
: 12_000;
|
|
297
|
+
const handshakeEnv = { ...process.env, CI: '1', BROWSER: 'false', NO_BROWSER: '1' };
|
|
298
|
+
delete handshakeEnv.CAUSYNE_VAULT_KEY;
|
|
299
|
+
delete handshakeEnv.CAUSYNE_DEV_SECRET;
|
|
259
300
|
const clientOptions = {
|
|
260
301
|
command: options.command,
|
|
261
302
|
cwd,
|
|
262
|
-
env:
|
|
263
|
-
promptTimeoutMs:
|
|
303
|
+
env: handshakeEnv,
|
|
304
|
+
promptTimeoutMs: timeoutMs
|
|
264
305
|
};
|
|
265
306
|
if (options.args) {
|
|
266
307
|
clientOptions.args = options.args;
|
|
267
308
|
}
|
|
268
309
|
const client = new AcpClient(clientOptions);
|
|
269
|
-
|
|
310
|
+
let timer;
|
|
270
311
|
try {
|
|
271
312
|
const init = await Promise.race([
|
|
272
313
|
client.start(),
|
|
273
|
-
new Promise((_, reject) =>
|
|
314
|
+
new Promise((_, reject) => {
|
|
315
|
+
timer = setTimeout(() => reject(new Error(`ACP initialization timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
316
|
+
timer.unref?.();
|
|
317
|
+
})
|
|
274
318
|
]);
|
|
319
|
+
if (timer) {
|
|
320
|
+
clearTimeout(timer);
|
|
321
|
+
timer = undefined;
|
|
322
|
+
}
|
|
275
323
|
const agentInfo = init.agentInfo ? { name: init.agentInfo.name, version: init.agentInfo.version } : undefined;
|
|
276
324
|
const authMethods = Array.isArray(init.authMethods)
|
|
277
325
|
? init.authMethods.map((m) => (typeof m === 'object' && m !== null && 'id' in m ? String(m.id) : String(m)))
|
|
@@ -289,7 +337,7 @@ export async function testPeerHandshake(options) {
|
|
|
289
337
|
};
|
|
290
338
|
}
|
|
291
339
|
catch (sessionErr) {
|
|
292
|
-
const msg = sessionErr instanceof Error ? sessionErr.message : String(sessionErr);
|
|
340
|
+
const msg = redactProviderSecrets(sessionErr instanceof Error ? sessionErr.message : String(sessionErr));
|
|
293
341
|
return {
|
|
294
342
|
ready: false,
|
|
295
343
|
...(agentInfo ? { agentInfo } : {}),
|
|
@@ -299,10 +347,12 @@ export async function testPeerHandshake(options) {
|
|
|
299
347
|
}
|
|
300
348
|
}
|
|
301
349
|
catch (initErr) {
|
|
302
|
-
const msg = initErr instanceof Error ? initErr.message : String(initErr);
|
|
350
|
+
const msg = redactProviderSecrets(initErr instanceof Error ? initErr.message : String(initErr));
|
|
303
351
|
return { ready: false, error: msg };
|
|
304
352
|
}
|
|
305
353
|
finally {
|
|
354
|
+
if (timer)
|
|
355
|
+
clearTimeout(timer);
|
|
306
356
|
await client.close().catch(() => { });
|
|
307
357
|
}
|
|
308
358
|
}
|
|
@@ -412,14 +462,19 @@ export async function detectAllPeers(cwd = process.cwd()) {
|
|
|
412
462
|
* Convert a preset to a runnable PeerProfile.
|
|
413
463
|
*/
|
|
414
464
|
export function getPresetProfile(id) {
|
|
415
|
-
|
|
465
|
+
if (typeof id !== 'string')
|
|
466
|
+
return null;
|
|
467
|
+
const key = id.trim().toLowerCase();
|
|
468
|
+
if (!key || !Object.hasOwn(BUILTIN_PEER_PRESETS, key))
|
|
469
|
+
return null;
|
|
470
|
+
const preset = BUILTIN_PEER_PRESETS[key];
|
|
416
471
|
if (!preset)
|
|
417
472
|
return null;
|
|
418
473
|
return {
|
|
419
474
|
id: preset.id,
|
|
420
475
|
label: preset.label,
|
|
421
476
|
command: preset.command,
|
|
422
|
-
args: preset.args,
|
|
477
|
+
args: [...preset.args],
|
|
423
478
|
cwd: null,
|
|
424
479
|
policy: 'workspace',
|
|
425
480
|
timeoutSeconds: preset.timeoutSeconds || 180,
|
package/src/acp/agentCatalog.ts
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import fs from 'node:fs';
|
|
11
|
+
import os from 'node:os';
|
|
11
12
|
import path from 'node:path';
|
|
12
13
|
import { execFile } from 'node:child_process';
|
|
13
14
|
import { promisify } from 'node:util';
|
|
14
15
|
import { AcpClient } from './client.js';
|
|
16
|
+
import { redactProviderSecrets } from '../providers/byokHttp.js';
|
|
15
17
|
import type { PeerProfile } from './peerProfiles.js';
|
|
16
18
|
|
|
17
19
|
const execFileAsync = promisify(execFile);
|
|
@@ -125,7 +127,7 @@ export const BUILTIN_PEER_PRESETS: Record<string, BuiltinPeerPreset> = {
|
|
|
125
127
|
authType: 'oauth',
|
|
126
128
|
authProbe: {
|
|
127
129
|
type: 'file_exists',
|
|
128
|
-
filePath: path.join(
|
|
130
|
+
filePath: os.homedir() ? path.join(os.homedir(), '.gemini', 'oauth_creds.json') : ''
|
|
129
131
|
},
|
|
130
132
|
setupInstruction: 'Run "gemini auth" or set GEMINI_API_KEY in your environment',
|
|
131
133
|
timeoutSeconds: 240
|
|
@@ -202,33 +204,51 @@ export const BUILTIN_PEER_PRESETS: Record<string, BuiltinPeerPreset> = {
|
|
|
202
204
|
* Check if a command or binary exists in PATH.
|
|
203
205
|
*/
|
|
204
206
|
export function isBinaryOnPath(binaryName: string): boolean {
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
207
|
+
if (typeof binaryName !== 'string' || !binaryName.trim() || /[\r\n\0]/.test(binaryName)) {
|
|
208
|
+
return false;
|
|
207
209
|
}
|
|
208
|
-
const
|
|
210
|
+
const trimmed = binaryName.trim();
|
|
211
|
+
if (path.isAbsolute(trimmed)) {
|
|
212
|
+
try {
|
|
213
|
+
const stat = fs.statSync(trimmed);
|
|
214
|
+
if (!stat.isFile()) return false;
|
|
215
|
+
if (process.platform !== 'win32') fs.accessSync(trimmed, fs.constants.X_OK);
|
|
216
|
+
return true;
|
|
217
|
+
} catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (trimmed.includes('..') || trimmed.includes('/') || trimmed.includes('\\')) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
const envPath = process.env.PATH || process.env.Path || '';
|
|
209
225
|
const delimiter = process.platform === 'win32' ? ';' : ':';
|
|
210
|
-
const home =
|
|
226
|
+
const home = os.homedir();
|
|
211
227
|
const fallbackDirs = [
|
|
212
|
-
path.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
228
|
+
...(home && path.isAbsolute(home) ? [
|
|
229
|
+
path.join(home, '.local', 'bin'),
|
|
230
|
+
path.join(home, '.antigravity', 'antigravity', 'bin'),
|
|
231
|
+
path.join(home, '.gemini', 'antigravity-ide', 'bin'),
|
|
232
|
+
path.join(home, '.opencode', 'bin')
|
|
233
|
+
] : []),
|
|
216
234
|
'/Applications/Antigravity.app/Contents/Resources/app/bin',
|
|
217
235
|
'/Applications/Antigravity IDE.app/Contents/Resources/app/bin'
|
|
218
236
|
];
|
|
219
237
|
const dirs = [...envPath.split(delimiter), ...fallbackDirs];
|
|
220
238
|
const extensions = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
221
239
|
|
|
222
|
-
for (const
|
|
223
|
-
|
|
240
|
+
for (const rawDir of dirs) {
|
|
241
|
+
const dir = rawDir.trim();
|
|
242
|
+
if (!dir || !path.isAbsolute(dir)) continue;
|
|
224
243
|
for (const ext of extensions) {
|
|
225
|
-
const full = path.join(dir, `${
|
|
244
|
+
const full = path.join(dir, `${trimmed}${ext}`);
|
|
226
245
|
try {
|
|
227
|
-
if (fs.
|
|
246
|
+
if (fs.statSync(full).isFile()) {
|
|
247
|
+
if (process.platform !== 'win32') fs.accessSync(full, fs.constants.X_OK);
|
|
228
248
|
return true;
|
|
229
249
|
}
|
|
230
250
|
} catch {
|
|
231
|
-
// Skip inaccessible path segments
|
|
251
|
+
// Skip inaccessible or non-executable path segments
|
|
232
252
|
}
|
|
233
253
|
}
|
|
234
254
|
}
|
|
@@ -245,8 +265,17 @@ export async function probePresetAuth(preset: BuiltinPeerPreset): Promise<{ auth
|
|
|
245
265
|
|
|
246
266
|
const probe = preset.authProbe;
|
|
247
267
|
|
|
248
|
-
if (probe.type === 'file_exists'
|
|
249
|
-
|
|
268
|
+
if (probe.type === 'file_exists') {
|
|
269
|
+
if (!probe.filePath || !path.isAbsolute(probe.filePath)) {
|
|
270
|
+
return { authenticated: false, reason: 'Credentials file path unavailable' };
|
|
271
|
+
}
|
|
272
|
+
let exists = false;
|
|
273
|
+
try {
|
|
274
|
+
const stat = fs.lstatSync(probe.filePath);
|
|
275
|
+
exists = !stat.isSymbolicLink() && stat.isFile();
|
|
276
|
+
} catch {
|
|
277
|
+
exists = false;
|
|
278
|
+
}
|
|
250
279
|
return {
|
|
251
280
|
authenticated: exists,
|
|
252
281
|
reason: exists ? 'OAuth credentials file detected' : `Credentials file not found at ${probe.filePath}`
|
|
@@ -258,7 +287,7 @@ export async function probePresetAuth(preset: BuiltinPeerPreset): Promise<{ auth
|
|
|
258
287
|
return { authenticated: false, reason: `${probe.command} CLI not found on PATH` };
|
|
259
288
|
}
|
|
260
289
|
try {
|
|
261
|
-
const { stdout } = await execFileAsync(probe.command, probe.args || [], { timeout: 8000 });
|
|
290
|
+
const { stdout } = await execFileAsync(probe.command, probe.args || [], { timeout: 8000, windowsHide: true, maxBuffer: 2 * 1024 * 1024 });
|
|
262
291
|
const parsed = JSON.parse(stdout.trim());
|
|
263
292
|
if (probe.jsonField && typeof parsed === 'object' && parsed !== null) {
|
|
264
293
|
const val = (parsed as Record<string, unknown>)[probe.jsonField];
|
|
@@ -279,7 +308,7 @@ export async function probePresetAuth(preset: BuiltinPeerPreset): Promise<{ auth
|
|
|
279
308
|
return { authenticated: false, reason: `${probe.command} CLI not found on PATH` };
|
|
280
309
|
}
|
|
281
310
|
try {
|
|
282
|
-
const result = await execFileAsync(probe.command, probe.args || [], { timeout: 8000 }).catch((e) => e);
|
|
311
|
+
const result = await execFileAsync(probe.command, probe.args || [], { timeout: 8000, windowsHide: true, maxBuffer: 2 * 1024 * 1024 }).catch((e) => e);
|
|
283
312
|
const combined = `${result?.stdout || ''}\n${result?.stderr || ''}`.toLowerCase();
|
|
284
313
|
if (probe.negativeMatch && combined.includes(probe.negativeMatch.toLowerCase())) {
|
|
285
314
|
return { authenticated: false, reason: 'CLI reported not logged in' };
|
|
@@ -316,6 +345,13 @@ export async function testPeerHandshake(
|
|
|
316
345
|
error?: string;
|
|
317
346
|
}> {
|
|
318
347
|
const cwd = options.cwd || process.cwd();
|
|
348
|
+
const rawTimeout = options.timeoutMs;
|
|
349
|
+
const timeoutMs = typeof rawTimeout === 'number' && Number.isFinite(rawTimeout) && rawTimeout > 0
|
|
350
|
+
? Math.max(1_000, Math.min(120_000, Math.round(rawTimeout)))
|
|
351
|
+
: 12_000;
|
|
352
|
+
const handshakeEnv: NodeJS.ProcessEnv = { ...process.env, CI: '1', BROWSER: 'false', NO_BROWSER: '1' };
|
|
353
|
+
delete handshakeEnv.CAUSYNE_VAULT_KEY;
|
|
354
|
+
delete handshakeEnv.CAUSYNE_DEV_SECRET;
|
|
319
355
|
const clientOptions: {
|
|
320
356
|
command: string;
|
|
321
357
|
args?: string[];
|
|
@@ -325,22 +361,26 @@ export async function testPeerHandshake(
|
|
|
325
361
|
} = {
|
|
326
362
|
command: options.command,
|
|
327
363
|
cwd,
|
|
328
|
-
env:
|
|
329
|
-
promptTimeoutMs:
|
|
364
|
+
env: handshakeEnv,
|
|
365
|
+
promptTimeoutMs: timeoutMs
|
|
330
366
|
};
|
|
331
367
|
if (options.args) {
|
|
332
368
|
clientOptions.args = options.args;
|
|
333
369
|
}
|
|
334
370
|
const client = new AcpClient(clientOptions);
|
|
335
|
-
|
|
336
|
-
const timeoutMs = options.timeoutMs || 12000;
|
|
371
|
+
let timer: NodeJS.Timeout | undefined;
|
|
337
372
|
try {
|
|
338
373
|
const init = await Promise.race([
|
|
339
374
|
client.start(),
|
|
340
|
-
new Promise<never>((_, reject) =>
|
|
341
|
-
setTimeout(() => reject(new Error(`ACP initialization timed out after ${timeoutMs}ms`)), timeoutMs)
|
|
342
|
-
|
|
375
|
+
new Promise<never>((_, reject) => {
|
|
376
|
+
timer = setTimeout(() => reject(new Error(`ACP initialization timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
377
|
+
timer.unref?.();
|
|
378
|
+
})
|
|
343
379
|
]);
|
|
380
|
+
if (timer) {
|
|
381
|
+
clearTimeout(timer);
|
|
382
|
+
timer = undefined;
|
|
383
|
+
}
|
|
344
384
|
|
|
345
385
|
const agentInfo = init.agentInfo ? { name: init.agentInfo.name, version: init.agentInfo.version } : undefined;
|
|
346
386
|
const authMethods = Array.isArray(init.authMethods)
|
|
@@ -359,7 +399,7 @@ export async function testPeerHandshake(
|
|
|
359
399
|
...(sessionModels.currentModelId ? { currentModelId: sessionModels.currentModelId } : {})
|
|
360
400
|
};
|
|
361
401
|
} catch (sessionErr: unknown) {
|
|
362
|
-
const msg = sessionErr instanceof Error ? sessionErr.message : String(sessionErr);
|
|
402
|
+
const msg = redactProviderSecrets(sessionErr instanceof Error ? sessionErr.message : String(sessionErr));
|
|
363
403
|
return {
|
|
364
404
|
ready: false,
|
|
365
405
|
...(agentInfo ? { agentInfo } : {}),
|
|
@@ -368,9 +408,10 @@ export async function testPeerHandshake(
|
|
|
368
408
|
};
|
|
369
409
|
}
|
|
370
410
|
} catch (initErr: unknown) {
|
|
371
|
-
const msg = initErr instanceof Error ? initErr.message : String(initErr);
|
|
411
|
+
const msg = redactProviderSecrets(initErr instanceof Error ? initErr.message : String(initErr));
|
|
372
412
|
return { ready: false, error: msg };
|
|
373
413
|
} finally {
|
|
414
|
+
if (timer) clearTimeout(timer);
|
|
374
415
|
await client.close().catch(() => {});
|
|
375
416
|
}
|
|
376
417
|
}
|
|
@@ -489,14 +530,17 @@ export async function detectAllPeers(cwd: string = process.cwd()): Promise<PeerD
|
|
|
489
530
|
* Convert a preset to a runnable PeerProfile.
|
|
490
531
|
*/
|
|
491
532
|
export function getPresetProfile(id: string): PeerProfile | null {
|
|
492
|
-
|
|
533
|
+
if (typeof id !== 'string') return null;
|
|
534
|
+
const key = id.trim().toLowerCase();
|
|
535
|
+
if (!key || !Object.hasOwn(BUILTIN_PEER_PRESETS, key)) return null;
|
|
536
|
+
const preset = BUILTIN_PEER_PRESETS[key];
|
|
493
537
|
if (!preset) return null;
|
|
494
538
|
|
|
495
539
|
return {
|
|
496
540
|
id: preset.id,
|
|
497
541
|
label: preset.label,
|
|
498
542
|
command: preset.command,
|
|
499
|
-
args: preset.args,
|
|
543
|
+
args: [...preset.args],
|
|
500
544
|
cwd: null,
|
|
501
545
|
policy: 'workspace',
|
|
502
546
|
timeoutSeconds: preset.timeoutSeconds || 180,
|