@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
|
@@ -87,7 +87,18 @@ function resolveNew(root, value, name) {
|
|
|
87
87
|
}
|
|
88
88
|
function resolveForParams(root, value, name, isOutput) {
|
|
89
89
|
const target = path.resolve(root, value);
|
|
90
|
-
|
|
90
|
+
try {
|
|
91
|
+
const stat = fs.lstatSync(target);
|
|
92
|
+
if (stat.isSymbolicLink())
|
|
93
|
+
throw new Error(`${name} cannot target a symbolic link`);
|
|
94
|
+
if (isOutput)
|
|
95
|
+
throw new Error(`${name} already exists; select a new path`);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error.code !== 'ENOENT')
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
const existing = nearestExisting(isOutput ? path.dirname(target) : target);
|
|
91
102
|
const actualBase = fs.realpathSync(existing);
|
|
92
103
|
const actual = path.join(actualBase, path.relative(existing, target));
|
|
93
104
|
if (!inside(root, actual))
|
|
@@ -121,7 +132,10 @@ function validateParamPaths(value, root, key, depth, seen) {
|
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
134
|
function workspaceFrom(context) {
|
|
124
|
-
const
|
|
135
|
+
const loopRoot = context.parentLoop?.workspaceRoot;
|
|
136
|
+
const candidate = context.workspacePaths?.find((item) => typeof item === 'string' && item.trim().length > 0)
|
|
137
|
+
|| (typeof loopRoot === 'string' && loopRoot.trim() ? loopRoot.trim() : undefined)
|
|
138
|
+
|| (typeof context.workspaceRoot === 'string' && context.workspaceRoot.trim() ? context.workspaceRoot.trim() : undefined);
|
|
125
139
|
return fs.realpathSync(path.resolve(candidate || process.cwd()));
|
|
126
140
|
}
|
|
127
141
|
function normalizeSteps(value) {
|
|
@@ -213,17 +227,15 @@ function parseRequest(value) {
|
|
|
213
227
|
function validateRequest(request, workspace) {
|
|
214
228
|
const project = request.project ? resolveExisting(workspace, request.project, 'project') : undefined;
|
|
215
229
|
const saveAs = request.saveAs ? resolveNew(workspace, request.saveAs, 'saveAs') : undefined;
|
|
216
|
-
if (saveAs)
|
|
217
|
-
fs.mkdirSync(path.dirname(saveAs), { recursive: true, mode: 0o700 });
|
|
218
230
|
if (request.demo && project)
|
|
219
231
|
throw new Error('demo and project cannot be combined');
|
|
220
232
|
if (request.save && !project)
|
|
221
233
|
throw new Error('save requires an existing project');
|
|
222
234
|
if (request.save && saveAs)
|
|
223
235
|
throw new Error('save and saveAs cannot be combined');
|
|
236
|
+
let output;
|
|
224
237
|
if (request.output && (request.action === 'export' || request.action === 'render')) {
|
|
225
|
-
|
|
226
|
-
fs.mkdirSync(path.dirname(output), { recursive: true, mode: 0o700 });
|
|
238
|
+
output = resolveNew(workspace, request.output, 'output');
|
|
227
239
|
}
|
|
228
240
|
if (request.action === 'execute' && !request.command)
|
|
229
241
|
throw new Error('execute requires command');
|
|
@@ -254,6 +266,10 @@ function validateRequest(request, workspace) {
|
|
|
254
266
|
validateParamPaths(step.params, workspace, 'params', 0, { count: 0 });
|
|
255
267
|
}
|
|
256
268
|
}
|
|
269
|
+
if (saveAs)
|
|
270
|
+
fs.mkdirSync(path.dirname(saveAs), { recursive: true, mode: 0o700 });
|
|
271
|
+
if (output)
|
|
272
|
+
fs.mkdirSync(path.dirname(output), { recursive: true, mode: 0o700 });
|
|
257
273
|
return {
|
|
258
274
|
workspace,
|
|
259
275
|
...(project === undefined ? {} : { project }),
|
|
@@ -438,25 +454,24 @@ export const nativeEngineTool = {
|
|
|
438
454
|
throw error;
|
|
439
455
|
return { success: false, error: `Could not start ${adapter.label}: ${error instanceof Error ? error.message : String(error)}` };
|
|
440
456
|
}
|
|
441
|
-
const artifacts = invocation.artifacts
|
|
442
|
-
.map(file => path.resolve(workspace, file))
|
|
443
|
-
.filter(file => {
|
|
457
|
+
const artifacts = invocation.artifacts.flatMap(file => {
|
|
444
458
|
try {
|
|
445
|
-
const actual = fs.realpathSync(file);
|
|
446
|
-
return inside(workspace, actual) && fs.statSync(actual).isFile()
|
|
459
|
+
const actual = fs.realpathSync(path.resolve(workspace, file));
|
|
460
|
+
return inside(workspace, actual) && fs.statSync(actual).isFile()
|
|
461
|
+
? [relativeArtifact(workspace, actual)]
|
|
462
|
+
: [];
|
|
447
463
|
}
|
|
448
464
|
catch {
|
|
449
|
-
return
|
|
465
|
+
return [];
|
|
450
466
|
}
|
|
451
|
-
})
|
|
452
|
-
.map(file => relativeArtifact(workspace, fs.realpathSync(file)));
|
|
453
|
-
let opened = false;
|
|
454
|
-
if (request.open && artifacts.length > 0) {
|
|
455
|
-
opened = await reveal(path.resolve(workspace, artifacts[0]));
|
|
456
|
-
}
|
|
467
|
+
});
|
|
457
468
|
const parsed = parseOutput(request.action, run.stdout);
|
|
458
469
|
const diagnostics = clean(run.stderr);
|
|
459
470
|
const success = run.exitCode === 0;
|
|
471
|
+
let opened = false;
|
|
472
|
+
if (success && request.open && artifacts.length > 0) {
|
|
473
|
+
opened = await reveal(path.resolve(workspace, artifacts[0]));
|
|
474
|
+
}
|
|
460
475
|
return {
|
|
461
476
|
success,
|
|
462
477
|
engine: adapter.id,
|
|
@@ -30,6 +30,7 @@ const OUTPUT_KEYS = new Set(['output', 'outputPath', 'out', 'outputFile']);
|
|
|
30
30
|
|
|
31
31
|
type ToolContext = {
|
|
32
32
|
signal?: AbortSignal;
|
|
33
|
+
workspaceRoot?: string;
|
|
33
34
|
workspacePaths?: string[];
|
|
34
35
|
parentLoop?: unknown;
|
|
35
36
|
};
|
|
@@ -106,7 +107,14 @@ function resolveNew(root: string, value: string, name: string): string {
|
|
|
106
107
|
|
|
107
108
|
function resolveForParams(root: string, value: string, name: string, isOutput: boolean): string {
|
|
108
109
|
const target = path.resolve(root, value);
|
|
109
|
-
|
|
110
|
+
try {
|
|
111
|
+
const stat = fs.lstatSync(target);
|
|
112
|
+
if (stat.isSymbolicLink()) throw new Error(`${name} cannot target a symbolic link`);
|
|
113
|
+
if (isOutput) throw new Error(`${name} already exists; select a new path`);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
|
116
|
+
}
|
|
117
|
+
const existing = nearestExisting(isOutput ? path.dirname(target) : target);
|
|
110
118
|
const actualBase = fs.realpathSync(existing);
|
|
111
119
|
const actual = path.join(actualBase, path.relative(existing, target));
|
|
112
120
|
if (!inside(root, actual)) throw new Error(`${name} must stay inside the workspace`);
|
|
@@ -135,7 +143,10 @@ function validateParamPaths(value: unknown, root: string, key: string, depth: nu
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
function workspaceFrom(context: ToolContext): string {
|
|
138
|
-
const
|
|
146
|
+
const loopRoot = (context.parentLoop as { workspaceRoot?: unknown } | undefined)?.workspaceRoot;
|
|
147
|
+
const candidate = context.workspacePaths?.find((item): item is string => typeof item === 'string' && item.trim().length > 0)
|
|
148
|
+
|| (typeof loopRoot === 'string' && loopRoot.trim() ? loopRoot.trim() : undefined)
|
|
149
|
+
|| (typeof context.workspaceRoot === 'string' && context.workspaceRoot.trim() ? context.workspaceRoot.trim() : undefined);
|
|
139
150
|
return fs.realpathSync(path.resolve(candidate || process.cwd()));
|
|
140
151
|
}
|
|
141
152
|
|
|
@@ -207,13 +218,12 @@ function parseRequest(value: unknown): NativeEngineRequest {
|
|
|
207
218
|
function validateRequest(request: NativeEngineRequest, workspace: string): NativeEngineContext {
|
|
208
219
|
const project = request.project ? resolveExisting(workspace, request.project, 'project') : undefined;
|
|
209
220
|
const saveAs = request.saveAs ? resolveNew(workspace, request.saveAs, 'saveAs') : undefined;
|
|
210
|
-
if (saveAs) fs.mkdirSync(path.dirname(saveAs), { recursive: true, mode: 0o700 });
|
|
211
221
|
if (request.demo && project) throw new Error('demo and project cannot be combined');
|
|
212
222
|
if (request.save && !project) throw new Error('save requires an existing project');
|
|
213
223
|
if (request.save && saveAs) throw new Error('save and saveAs cannot be combined');
|
|
224
|
+
let output: string | undefined;
|
|
214
225
|
if (request.output && (request.action === 'export' || request.action === 'render')) {
|
|
215
|
-
|
|
216
|
-
fs.mkdirSync(path.dirname(output), { recursive: true, mode: 0o700 });
|
|
226
|
+
output = resolveNew(workspace, request.output, 'output');
|
|
217
227
|
}
|
|
218
228
|
if (request.action === 'execute' && !request.command) throw new Error('execute requires command');
|
|
219
229
|
if (request.action === 'describe' && !request.command) throw new Error('describe requires command');
|
|
@@ -236,6 +246,8 @@ function validateRequest(request: NativeEngineRequest, workspace: string): Nativ
|
|
|
236
246
|
if (step.params) validateParamPaths(step.params, workspace, 'params', 0, { count: 0 });
|
|
237
247
|
}
|
|
238
248
|
}
|
|
249
|
+
if (saveAs) fs.mkdirSync(path.dirname(saveAs), { recursive: true, mode: 0o700 });
|
|
250
|
+
if (output) fs.mkdirSync(path.dirname(output), { recursive: true, mode: 0o700 });
|
|
239
251
|
return {
|
|
240
252
|
workspace,
|
|
241
253
|
...(project === undefined ? {} : { project }),
|
|
@@ -412,22 +424,23 @@ export const nativeEngineTool = {
|
|
|
412
424
|
return { success: false, error: `Could not start ${adapter.label}: ${error instanceof Error ? error.message : String(error)}` };
|
|
413
425
|
}
|
|
414
426
|
|
|
415
|
-
const artifacts = invocation.artifacts
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (request.open && artifacts.length > 0) {
|
|
426
|
-
opened = await reveal(path.resolve(workspace, artifacts[0]!));
|
|
427
|
-
}
|
|
427
|
+
const artifacts = invocation.artifacts.flatMap(file => {
|
|
428
|
+
try {
|
|
429
|
+
const actual = fs.realpathSync(path.resolve(workspace, file));
|
|
430
|
+
return inside(workspace, actual) && fs.statSync(actual).isFile()
|
|
431
|
+
? [relativeArtifact(workspace, actual)]
|
|
432
|
+
: [];
|
|
433
|
+
} catch {
|
|
434
|
+
return [];
|
|
435
|
+
}
|
|
436
|
+
});
|
|
428
437
|
const parsed = parseOutput(request.action, run.stdout);
|
|
429
438
|
const diagnostics = clean(run.stderr);
|
|
430
439
|
const success = run.exitCode === 0;
|
|
440
|
+
let opened = false;
|
|
441
|
+
if (success && request.open && artifacts.length > 0) {
|
|
442
|
+
opened = await reveal(path.resolve(workspace, artifacts[0]!));
|
|
443
|
+
}
|
|
431
444
|
return {
|
|
432
445
|
success,
|
|
433
446
|
engine: adapter.id,
|
|
@@ -275,13 +275,16 @@ export const openSourceToolProvisioner = {
|
|
|
275
275
|
}
|
|
276
276
|
},
|
|
277
277
|
async execute(args, sandbox = {}) {
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
278
|
+
const safeArgs = args && typeof args === 'object' && !Array.isArray(args) ? args : {};
|
|
279
|
+
const safeSandbox = sandbox && typeof sandbox === 'object' && !Array.isArray(sandbox) ? sandbox : {};
|
|
280
|
+
const action = String(safeArgs['action'] || 'discover');
|
|
281
|
+
const intent = typeof safeArgs['intent'] === 'string' ? safeArgs['intent'] : '';
|
|
282
|
+
let toolId = typeof safeArgs['toolId'] === 'string' ? safeArgs['toolId'].toLowerCase().trim() : '';
|
|
283
|
+
const confirm = safeArgs['confirm'] === true || isAutonomousToolContext(safeSandbox);
|
|
284
|
+
const forceAlternative = safeArgs['forceAlternative'] === true;
|
|
285
|
+
const signal = safeSandbox['signal'] instanceof AbortSignal ? safeSandbox['signal'] : undefined;
|
|
286
|
+
const workspaceDir = (Array.isArray(safeSandbox['workspacePaths']) && safeSandbox['workspacePaths'][0])
|
|
287
|
+
? String(safeSandbox['workspacePaths'][0])
|
|
285
288
|
: process.cwd();
|
|
286
289
|
const specs = await detectSystemSpecs(workspaceDir);
|
|
287
290
|
// ── ACTION: DISCOVER ──────────────────────────────────────────────────
|
|
@@ -340,7 +343,8 @@ export const openSourceToolProvisioner = {
|
|
|
340
343
|
if (!toolId) {
|
|
341
344
|
return { success: false, error: 'Missing toolId for evaluate action.' };
|
|
342
345
|
}
|
|
343
|
-
const
|
|
346
|
+
const getCatalogueTool = (id) => Object.hasOwn(CURATED_OPEN_SOURCE_CATALOGUE, id) ? CURATED_OPEN_SOURCE_CATALOGUE[id] : undefined;
|
|
347
|
+
const tool = getCatalogueTool(toolId);
|
|
344
348
|
if (!tool) {
|
|
345
349
|
return { success: false, error: `Unknown toolId "${toolId}". Choose from: ${Object.keys(CURATED_OPEN_SOURCE_CATALOGUE).join(', ')}` };
|
|
346
350
|
}
|
|
@@ -366,13 +370,14 @@ export const openSourceToolProvisioner = {
|
|
|
366
370
|
if (!toolId) {
|
|
367
371
|
return { success: false, error: 'Missing toolId to install.' };
|
|
368
372
|
}
|
|
369
|
-
|
|
373
|
+
const getCatalogueTool = (id) => Object.hasOwn(CURATED_OPEN_SOURCE_CATALOGUE, id) ? CURATED_OPEN_SOURCE_CATALOGUE[id] : undefined;
|
|
374
|
+
let tool = getCatalogueTool(toolId);
|
|
370
375
|
if (!tool) {
|
|
371
376
|
return { success: false, error: `Tool "${toolId}" not found in catalogue.` };
|
|
372
377
|
}
|
|
373
378
|
let selectedTool = tool;
|
|
374
379
|
if (forceAlternative && tool.lightweightAlternativeId) {
|
|
375
|
-
const alt =
|
|
380
|
+
const alt = getCatalogueTool(tool.lightweightAlternativeId);
|
|
376
381
|
if (alt) {
|
|
377
382
|
selectedTool = alt;
|
|
378
383
|
toolId = alt.id;
|
|
@@ -382,7 +387,7 @@ export const openSourceToolProvisioner = {
|
|
|
382
387
|
// MANDATORY HITL GATE: If not confirmed, pause and formulate decision proposal
|
|
383
388
|
if (!confirm) {
|
|
384
389
|
const altProfile = selectedTool.lightweightAlternativeId
|
|
385
|
-
?
|
|
390
|
+
? getCatalogueTool(selectedTool.lightweightAlternativeId)
|
|
386
391
|
: undefined;
|
|
387
392
|
return {
|
|
388
393
|
success: true,
|
|
@@ -430,6 +435,29 @@ export const openSourceToolProvisioner = {
|
|
|
430
435
|
instruction: `Ask user for consent via request_decision or run 'open_source_tool_provisioner' with confirm: true after obtaining agreement.`
|
|
431
436
|
};
|
|
432
437
|
}
|
|
438
|
+
if (!evalReport.compatible) {
|
|
439
|
+
return {
|
|
440
|
+
success: false,
|
|
441
|
+
installed: false,
|
|
442
|
+
status: 'INSUFFICIENT_HARDWARE',
|
|
443
|
+
toolId: selectedTool.id,
|
|
444
|
+
error: evalReport.reason,
|
|
445
|
+
evaluation: evalReport,
|
|
446
|
+
...(selectedTool.lightweightAlternativeId && selectedTool.lightweightAlternativeId !== selectedTool.id
|
|
447
|
+
? { lightweightAlternative: selectedTool.lightweightAlternativeId }
|
|
448
|
+
: {})
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
// Refuse fabricated installation success for non-pip binary/git tools whose installer is not automated here.
|
|
452
|
+
if (selectedTool.installMethod !== 'pip' || !selectedTool.pipPackages || selectedTool.pipPackages.length === 0) {
|
|
453
|
+
return {
|
|
454
|
+
success: false,
|
|
455
|
+
installed: false,
|
|
456
|
+
toolId: selectedTool.id,
|
|
457
|
+
repoUrl: selectedTool.url,
|
|
458
|
+
error: `Automated installation for ${selectedTool.installMethod} tool "${selectedTool.id}" is not implemented; install manually from ${selectedTool.url}.`
|
|
459
|
+
};
|
|
460
|
+
}
|
|
433
461
|
// User has explicitly confirmed! Proceed with sovereign isolated setup.
|
|
434
462
|
const aiToolsDir = path.join(workspaceDir, '.ai_tools');
|
|
435
463
|
const venvDir = path.join(aiToolsDir, 'venv');
|
|
@@ -441,7 +469,11 @@ export const openSourceToolProvisioner = {
|
|
|
441
469
|
const venvPython = isWin ? path.join(venvDir, 'Scripts', 'python.exe') : path.join(venvDir, 'bin', 'python');
|
|
442
470
|
if (!fs.existsSync(venvPip)) {
|
|
443
471
|
try {
|
|
444
|
-
await execFilePromise(pythonBin, ['-m', 'venv', venvDir], {
|
|
472
|
+
await execFilePromise(pythonBin, ['-m', 'venv', venvDir], {
|
|
473
|
+
timeout: 120000,
|
|
474
|
+
windowsHide: true,
|
|
475
|
+
...(signal ? { signal } : {})
|
|
476
|
+
});
|
|
445
477
|
}
|
|
446
478
|
catch (e) {
|
|
447
479
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
@@ -451,7 +483,7 @@ export const openSourceToolProvisioner = {
|
|
|
451
483
|
// Install packages if pip-based
|
|
452
484
|
if (selectedTool.installMethod === 'pip' && selectedTool.pipPackages && selectedTool.pipPackages.length > 0) {
|
|
453
485
|
try {
|
|
454
|
-
await execFilePromise(venvPip, ['install', '--disable-pip-version-check', '--no-input', ...selectedTool.pipPackages], { timeout: 10 * 60 * 1000, maxBuffer: 10 * 1024 * 1024 });
|
|
486
|
+
await execFilePromise(venvPip, ['install', '--disable-pip-version-check', '--no-input', ...selectedTool.pipPackages], { timeout: 10 * 60 * 1000, maxBuffer: 10 * 1024 * 1024, windowsHide: true, ...(signal ? { signal } : {}) });
|
|
455
487
|
}
|
|
456
488
|
catch (pipErr) {
|
|
457
489
|
const errMsg = pipErr instanceof Error ? pipErr.message : String(pipErr);
|
|
@@ -463,7 +495,10 @@ export const openSourceToolProvisioner = {
|
|
|
463
495
|
let installedMap = {};
|
|
464
496
|
try {
|
|
465
497
|
if (fs.existsSync(manifestFile)) {
|
|
466
|
-
|
|
498
|
+
const parsedManifest = JSON.parse(await fsp.readFile(manifestFile, 'utf8'));
|
|
499
|
+
if (parsedManifest && typeof parsedManifest === 'object' && !Array.isArray(parsedManifest)) {
|
|
500
|
+
installedMap = parsedManifest;
|
|
501
|
+
}
|
|
467
502
|
}
|
|
468
503
|
}
|
|
469
504
|
catch {
|
|
@@ -331,14 +331,17 @@ export const openSourceToolProvisioner = {
|
|
|
331
331
|
},
|
|
332
332
|
|
|
333
333
|
async execute(args: Record<string, unknown>, sandbox: Record<string, unknown> = {}) {
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
334
|
+
const safeArgs: Record<string, unknown> = args && typeof args === 'object' && !Array.isArray(args) ? args : {};
|
|
335
|
+
const safeSandbox: Record<string, unknown> = sandbox && typeof sandbox === 'object' && !Array.isArray(sandbox) ? sandbox : {};
|
|
336
|
+
const action = String(safeArgs['action'] || 'discover');
|
|
337
|
+
const intent = typeof safeArgs['intent'] === 'string' ? safeArgs['intent'] : '';
|
|
338
|
+
let toolId = typeof safeArgs['toolId'] === 'string' ? safeArgs['toolId'].toLowerCase().trim() : '';
|
|
339
|
+
const confirm = safeArgs['confirm'] === true || isAutonomousToolContext(safeSandbox);
|
|
340
|
+
const forceAlternative = safeArgs['forceAlternative'] === true;
|
|
341
|
+
const signal = safeSandbox['signal'] instanceof AbortSignal ? safeSandbox['signal'] : undefined;
|
|
342
|
+
|
|
343
|
+
const workspaceDir = (Array.isArray(safeSandbox['workspacePaths']) && safeSandbox['workspacePaths'][0])
|
|
344
|
+
? String(safeSandbox['workspacePaths'][0])
|
|
342
345
|
: process.cwd();
|
|
343
346
|
|
|
344
347
|
const specs = await detectSystemSpecs(workspaceDir);
|
|
@@ -403,7 +406,9 @@ export const openSourceToolProvisioner = {
|
|
|
403
406
|
if (!toolId) {
|
|
404
407
|
return { success: false, error: 'Missing toolId for evaluate action.' };
|
|
405
408
|
}
|
|
406
|
-
const
|
|
409
|
+
const getCatalogueTool = (id: string): OpenSourceToolProfile | undefined =>
|
|
410
|
+
Object.hasOwn(CURATED_OPEN_SOURCE_CATALOGUE, id) ? CURATED_OPEN_SOURCE_CATALOGUE[id] : undefined;
|
|
411
|
+
const tool = getCatalogueTool(toolId);
|
|
407
412
|
if (!tool) {
|
|
408
413
|
return { success: false, error: `Unknown toolId "${toolId}". Choose from: ${Object.keys(CURATED_OPEN_SOURCE_CATALOGUE).join(', ')}` };
|
|
409
414
|
}
|
|
@@ -432,14 +437,16 @@ export const openSourceToolProvisioner = {
|
|
|
432
437
|
return { success: false, error: 'Missing toolId to install.' };
|
|
433
438
|
}
|
|
434
439
|
|
|
435
|
-
|
|
440
|
+
const getCatalogueTool = (id: string): OpenSourceToolProfile | undefined =>
|
|
441
|
+
Object.hasOwn(CURATED_OPEN_SOURCE_CATALOGUE, id) ? CURATED_OPEN_SOURCE_CATALOGUE[id] : undefined;
|
|
442
|
+
let tool = getCatalogueTool(toolId);
|
|
436
443
|
if (!tool) {
|
|
437
444
|
return { success: false, error: `Tool "${toolId}" not found in catalogue.` };
|
|
438
445
|
}
|
|
439
446
|
|
|
440
447
|
let selectedTool: OpenSourceToolProfile = tool;
|
|
441
448
|
if (forceAlternative && tool.lightweightAlternativeId) {
|
|
442
|
-
const alt =
|
|
449
|
+
const alt = getCatalogueTool(tool.lightweightAlternativeId);
|
|
443
450
|
if (alt) {
|
|
444
451
|
selectedTool = alt;
|
|
445
452
|
toolId = alt.id;
|
|
@@ -451,7 +458,7 @@ export const openSourceToolProvisioner = {
|
|
|
451
458
|
// MANDATORY HITL GATE: If not confirmed, pause and formulate decision proposal
|
|
452
459
|
if (!confirm) {
|
|
453
460
|
const altProfile = selectedTool.lightweightAlternativeId
|
|
454
|
-
?
|
|
461
|
+
? getCatalogueTool(selectedTool.lightweightAlternativeId)
|
|
455
462
|
: undefined;
|
|
456
463
|
|
|
457
464
|
return {
|
|
@@ -501,6 +508,31 @@ export const openSourceToolProvisioner = {
|
|
|
501
508
|
};
|
|
502
509
|
}
|
|
503
510
|
|
|
511
|
+
if (!evalReport.compatible) {
|
|
512
|
+
return {
|
|
513
|
+
success: false,
|
|
514
|
+
installed: false,
|
|
515
|
+
status: 'INSUFFICIENT_HARDWARE',
|
|
516
|
+
toolId: selectedTool.id,
|
|
517
|
+
error: evalReport.reason,
|
|
518
|
+
evaluation: evalReport,
|
|
519
|
+
...(selectedTool.lightweightAlternativeId && selectedTool.lightweightAlternativeId !== selectedTool.id
|
|
520
|
+
? { lightweightAlternative: selectedTool.lightweightAlternativeId }
|
|
521
|
+
: {})
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Refuse fabricated installation success for non-pip binary/git tools whose installer is not automated here.
|
|
526
|
+
if (selectedTool.installMethod !== 'pip' || !selectedTool.pipPackages || selectedTool.pipPackages.length === 0) {
|
|
527
|
+
return {
|
|
528
|
+
success: false,
|
|
529
|
+
installed: false,
|
|
530
|
+
toolId: selectedTool.id,
|
|
531
|
+
repoUrl: selectedTool.url,
|
|
532
|
+
error: `Automated installation for ${selectedTool.installMethod} tool "${selectedTool.id}" is not implemented; install manually from ${selectedTool.url}.`
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
|
|
504
536
|
// User has explicitly confirmed! Proceed with sovereign isolated setup.
|
|
505
537
|
const aiToolsDir = path.join(workspaceDir, '.ai_tools');
|
|
506
538
|
const venvDir = path.join(aiToolsDir, 'venv');
|
|
@@ -514,7 +546,11 @@ export const openSourceToolProvisioner = {
|
|
|
514
546
|
|
|
515
547
|
if (!fs.existsSync(venvPip)) {
|
|
516
548
|
try {
|
|
517
|
-
await execFilePromise(pythonBin, ['-m', 'venv', venvDir], {
|
|
549
|
+
await execFilePromise(pythonBin, ['-m', 'venv', venvDir], {
|
|
550
|
+
timeout: 120000,
|
|
551
|
+
windowsHide: true,
|
|
552
|
+
...(signal ? { signal } : {})
|
|
553
|
+
});
|
|
518
554
|
} catch (e: unknown) {
|
|
519
555
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
520
556
|
return { success: false, error: `Failed to create virtual environment: ${errMsg}` };
|
|
@@ -527,7 +563,7 @@ export const openSourceToolProvisioner = {
|
|
|
527
563
|
await execFilePromise(
|
|
528
564
|
venvPip,
|
|
529
565
|
['install', '--disable-pip-version-check', '--no-input', ...selectedTool.pipPackages],
|
|
530
|
-
{ timeout: 10 * 60 * 1000, maxBuffer: 10 * 1024 * 1024 }
|
|
566
|
+
{ timeout: 10 * 60 * 1000, maxBuffer: 10 * 1024 * 1024, windowsHide: true, ...(signal ? { signal } : {}) }
|
|
531
567
|
);
|
|
532
568
|
} catch (pipErr: unknown) {
|
|
533
569
|
const errMsg = pipErr instanceof Error ? pipErr.message : String(pipErr);
|
|
@@ -540,7 +576,10 @@ export const openSourceToolProvisioner = {
|
|
|
540
576
|
let installedMap: Record<string, unknown> = {};
|
|
541
577
|
try {
|
|
542
578
|
if (fs.existsSync(manifestFile)) {
|
|
543
|
-
|
|
579
|
+
const parsedManifest: unknown = JSON.parse(await fsp.readFile(manifestFile, 'utf8'));
|
|
580
|
+
if (parsedManifest && typeof parsedManifest === 'object' && !Array.isArray(parsedManifest)) {
|
|
581
|
+
installedMap = parsedManifest as Record<string, unknown>;
|
|
582
|
+
}
|
|
544
583
|
}
|
|
545
584
|
} catch {
|
|
546
585
|
installedMap = {};
|
package/src/tools/osSandbox.js
CHANGED
|
@@ -65,7 +65,7 @@ export function escapeSeatbeltPath(rawPath) {
|
|
|
65
65
|
}
|
|
66
66
|
function resolveCanonicalPaths(rawPath) {
|
|
67
67
|
const resolved = path.resolve(rawPath);
|
|
68
|
-
const out = new Set(
|
|
68
|
+
const out = new Set();
|
|
69
69
|
try {
|
|
70
70
|
const real = fs.realpathSync.native(resolved);
|
|
71
71
|
out.add(real);
|
|
@@ -90,6 +90,7 @@ function resolveCanonicalPaths(rawPath) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
out.add(resolved);
|
|
93
94
|
return [...out];
|
|
94
95
|
}
|
|
95
96
|
function isSameOrChildPath(candidate, parent) {
|
|
@@ -266,9 +267,9 @@ export function buildSeatbeltProfile(options) {
|
|
|
266
267
|
const mode = options.mode ?? 'workspace-write';
|
|
267
268
|
const homeDir = options.homeDir ?? os.homedir();
|
|
268
269
|
const tmpDir = options.tmpDir ?? os.tmpdir();
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
const configuredWorkspaces = (options.workspaceRoots ?? [])
|
|
271
|
+
.filter((entry) => typeof entry === 'string' && entry.trim().length > 0);
|
|
272
|
+
const workspaces = configuredWorkspaces.length > 0 ? configuredWorkspaces : [options.cwd];
|
|
272
273
|
const lines = [
|
|
273
274
|
'(version 1)',
|
|
274
275
|
'(allow default)'
|
|
@@ -367,9 +368,9 @@ export function buildSeatbeltProfile(options) {
|
|
|
367
368
|
export function buildBubblewrapArgs(shell, shellArgs, options) {
|
|
368
369
|
const mode = options.mode ?? 'workspace-write';
|
|
369
370
|
const homeDir = options.homeDir ?? os.homedir();
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
const configuredWorkspaces = (options.workspaceRoots ?? [])
|
|
372
|
+
.filter((entry) => typeof entry === 'string' && entry.trim().length > 0);
|
|
373
|
+
const workspaces = configuredWorkspaces.length > 0 ? configuredWorkspaces : [options.cwd];
|
|
373
374
|
const args = [
|
|
374
375
|
'--die-with-parent',
|
|
375
376
|
'--ro-bind', '/', '/',
|
|
@@ -402,21 +403,60 @@ export function buildBubblewrapArgs(shell, shellArgs, options) {
|
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
if (
|
|
406
|
+
else if (mode === 'read-only' && options.includeTempDirs !== false) {
|
|
407
|
+
const roBound = new Set();
|
|
408
|
+
const roBindTmpPath = (rawPath) => {
|
|
409
|
+
const resolved = path.resolve(rawPath);
|
|
410
|
+
if (roBound.has(resolved))
|
|
411
|
+
return;
|
|
412
|
+
if (!isSameOrChildPath(resolved, '/tmp'))
|
|
413
|
+
return;
|
|
414
|
+
if (!fs.existsSync(resolved))
|
|
415
|
+
return;
|
|
416
|
+
roBound.add(resolved);
|
|
417
|
+
args.push('--ro-bind', resolved, resolved);
|
|
418
|
+
};
|
|
419
|
+
for (const ws of workspaces) {
|
|
420
|
+
roBindTmpPath(ws);
|
|
421
|
+
}
|
|
422
|
+
roBindTmpPath(options.cwd);
|
|
423
|
+
}
|
|
424
|
+
// Mask existing credential vaults (directories & files) and extra deny paths unless inside selected workspace
|
|
425
|
+
const masked = new Set();
|
|
426
|
+
const maskTarget = (rawPath) => {
|
|
427
|
+
for (const variant of resolveCanonicalPaths(rawPath)) {
|
|
428
|
+
if (masked.has(variant))
|
|
410
429
|
continue;
|
|
411
430
|
try {
|
|
412
|
-
|
|
413
|
-
|
|
431
|
+
const stat = fs.statSync(variant);
|
|
432
|
+
if (stat.isDirectory()) {
|
|
433
|
+
masked.add(variant);
|
|
434
|
+
args.push('--tmpfs', variant);
|
|
435
|
+
}
|
|
436
|
+
else if (stat.isFile()) {
|
|
437
|
+
masked.add(variant);
|
|
438
|
+
args.push('--ro-bind', '/dev/null', variant);
|
|
414
439
|
}
|
|
415
440
|
}
|
|
416
441
|
catch {
|
|
417
442
|
continue;
|
|
418
443
|
}
|
|
419
444
|
}
|
|
445
|
+
};
|
|
446
|
+
if (homeDir) {
|
|
447
|
+
for (const rel of CREDENTIAL_SUBPATHS) {
|
|
448
|
+
const full = path.join(homeDir, rel);
|
|
449
|
+
if (workspaceOverlapsPath(workspaces, full))
|
|
450
|
+
continue;
|
|
451
|
+
maskTarget(full);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
if (Array.isArray(options.extraDenyReadPaths)) {
|
|
455
|
+
for (const extra of options.extraDenyReadPaths) {
|
|
456
|
+
if (typeof extra === 'string' && extra.trim()) {
|
|
457
|
+
maskTarget(extra);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
420
460
|
}
|
|
421
461
|
args.push('--chdir', path.resolve(options.cwd), '--', shell, ...shellArgs);
|
|
422
462
|
return args;
|