@causyne/agent 1.20.118 → 1.20.121
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/package.json +1 -1
- package/src/agent/errorClassifier.js +113 -0
- package/src/agent/errorClassifier.ts +161 -0
- package/src/agent/promptIntent.js +200 -0
- package/src/agent/promptIntent.ts +203 -0
- package/src/agent/toolArgValidator.js +97 -0
- package/src/agent/toolArgValidator.ts +112 -0
- package/src/agentLoop.js +51 -351
- package/src/agentLoop.ts +69 -363
- package/src/autoUpdate.js +111 -8
- package/src/autoUpdate.ts +144 -8
- package/src/browser/causyneBrowser.js +231 -136
- package/src/browser/causyneBrowser.ts +229 -140
- package/src/browser/searchProviders.js +41 -30
- package/src/browser/searchProviders.ts +24 -14
- package/src/browser/workspacePathSafety.js +50 -0
- package/src/browser/workspacePathSafety.ts +50 -0
- package/src/browser/workspacePreview.js +27 -4
- package/src/browser/workspacePreview.ts +28 -4
- package/src/cliMode.js +17 -3
- package/src/commands.js +15 -22
- package/src/config.js +42 -63
- package/src/configVault.js +204 -0
- package/src/configVault.ts +213 -0
- package/src/core/contextCompactor.js +70 -11
- package/src/core/contextCompactor.ts +83 -11
- package/src/creative/liveBridge.js +34 -1
- package/src/creative/liveBridge.ts +28 -1
- package/src/dynamicCatalogue.js +42 -73
- package/src/dynamicCatalogue.ts +74 -60
- package/src/entrypoint.js +77 -4
- package/src/headlessCli.js +304 -0
- package/src/headlessCli.ts +380 -0
- package/src/mcp/mcpClient.js +38 -11
- package/src/mcp/mcpClient.ts +44 -11
- package/src/mcp/mcpRegistry.js +2 -5
- package/src/mcp/mcpRegistry.ts +2 -5
- package/src/mcp/mcpSecurity.js +189 -0
- package/src/mcp/mcpSecurity.ts +190 -0
- package/src/observer/evidence.js +23 -0
- package/src/observer/evidence.ts +21 -0
- package/src/osKeychain.js +209 -0
- package/src/osKeychain.ts +245 -0
- package/src/providers/anthropic.js +61 -28
- package/src/providers/base.js +14 -0
- package/src/providers/byokHttp.js +354 -0
- package/src/providers/byokHttp.ts +454 -0
- package/src/providers/byokStream.js +657 -0
- package/src/providers/byokStream.ts +759 -0
- package/src/providers/dashscope-byok.js +47 -32
- package/src/providers/deepseek.js +43 -39
- package/src/providers/gemini.js +73 -38
- package/src/providers/moonshot.js +43 -33
- package/src/providers/muse.js +10 -10
- package/src/providers/ollama.js +46 -31
- package/src/providers/openai-compatible.js +57 -32
- package/src/providers/openrouter.js +77 -113
- package/src/providers/openrouter.ts +99 -118
- package/src/providers/qwen-byok.js +46 -23
- package/src/providers/toolContracts.js +9 -3
- package/src/providers/toolContracts.ts +9 -3
- package/src/providers/wireNormalizer.js +238 -0
- package/src/providers/wireNormalizer.ts +279 -0
- package/src/providers/xai.js +43 -33
- package/src/sandbox.js +77 -56
- package/src/sandboxPolicy.js +1208 -0
- package/src/sandboxPolicy.ts +1300 -0
- package/src/sessionJournal.js +47 -0
- package/src/sessionJournal.ts +49 -0
- package/src/tools/browserAutomator.js +13 -1
- package/src/tools/browserAutomator.ts +13 -0
- package/src/tools/creativeApps.js +2 -1
- package/src/tools/creativeApps.ts +2 -1
- package/src/tools/gameAssetFetcher.js +130 -26
- package/src/tools/gameAssetHarvester.js +80 -58
- package/src/tools/nativeEngine.js +1 -1
- package/src/tools/nativeEngine.ts +1 -1
- package/src/tools/osSandbox.js +473 -0
- package/src/tools/osSandbox.ts +554 -0
- package/src/tools/persistentShell.js +8 -3
- package/src/tools/registry.js +13 -0
- package/src/tools/subprocessEnv.js +197 -0
- package/src/tools/subprocessEnv.ts +212 -0
- package/src/tools/sysRun.js +39 -6
- package/src/tools/sysRun.ts +53 -7
- package/src/tools/toolScanner.js +596 -140
- package/src/tools/toolScanner.ts +665 -147
- package/src/tools/toolSelfRepair.js +243 -114
- package/src/tools/toolSelfRepair.ts +262 -111
- package/src/tools/webFetch.js +161 -24
- package/src/tools/webFetch.ts +157 -22
- package/src/tools/webSearch.js +33 -4
- package/src/tools/webSearch.ts +27 -4
- package/src/tui/sessionPicker.js +132 -35
- package/src/tui/sessionPicker.ts +153 -32
- package/src/tui/sessionPickerView.js +277 -34
- package/src/tui/sessionPickerView.ts +328 -34
- package/src/tui/statusLine.js +3 -0
- package/src/tui/statusLine.ts +5 -0
- package/src/tui/workspaceIdentity.js +133 -0
- package/src/tui/workspaceIdentity.ts +146 -0
package/src/sandbox.js
CHANGED
|
@@ -5,29 +5,14 @@ import { loadConfig } from './config.js';
|
|
|
5
5
|
import { isDevEmulator } from './devMode.js';
|
|
6
6
|
import { validateBrowserActSandbox } from './browser/causyneBrowser.js';
|
|
7
7
|
import { isPhysicalPathAllowed } from './agent/workspaceBoundary.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Split a command line into the individual commands the shell will run.
|
|
19
|
-
*
|
|
20
|
-
* Prefix matching only ever inspected the FIRST word of the whole line, so any
|
|
21
|
-
* leading token disguised everything after it: `cd ~/Documents && rm -f x` was
|
|
22
|
-
* classified from `cd` and auto-executed with no approval. Each segment must be
|
|
23
|
-
* judged on its own.
|
|
24
|
-
*/
|
|
25
|
-
function splitShellSegments(text) {
|
|
26
|
-
return text
|
|
27
|
-
.split(/&&|\|\||[;\n|&]/)
|
|
28
|
-
.map((segment) => segment.trim())
|
|
29
|
-
.filter((segment) => segment.length > 0);
|
|
30
|
-
}
|
|
8
|
+
import {
|
|
9
|
+
isBlockedWorkspaceRoot,
|
|
10
|
+
isExtendedCredentialPath,
|
|
11
|
+
isSensitiveWriteTarget,
|
|
12
|
+
analyzeShellCommand,
|
|
13
|
+
isExtremeRemovalSegment,
|
|
14
|
+
isFetchAndExecPipeline
|
|
15
|
+
} from './sandboxPolicy.js';
|
|
31
16
|
|
|
32
17
|
/**
|
|
33
18
|
* Read-only invocations of tools whose NAME is dangerous but whose subcommand
|
|
@@ -115,13 +100,18 @@ const CREDENTIAL_PATHS = [
|
|
|
115
100
|
/(^|\/)Library\/Keychains(\/|$)/i,
|
|
116
101
|
// Causyne's own vault: config.json holds the encrypted provider key and
|
|
117
102
|
// .vault_key is the key that decrypts it.
|
|
118
|
-
/(^|\/)\.causyne(\/|$)
|
|
103
|
+
/(^|\/)\.causyne(\/|$)/,
|
|
104
|
+
/(^|\/)\.envrc$/i,
|
|
105
|
+
/(^|\/)\.git-credentials$/i,
|
|
106
|
+
/(^|\/)\.pypirc$/i,
|
|
107
|
+
/(^|\/)\.pgpass$/i,
|
|
108
|
+
/(^|\/)\.my\.cnf$/i
|
|
119
109
|
];
|
|
120
110
|
|
|
121
111
|
export function isCredentialPath(targetPath) {
|
|
122
112
|
if (typeof targetPath !== 'string' || targetPath.length === 0) return false;
|
|
123
113
|
const normalized = targetPath.replace(/\\/g, '/');
|
|
124
|
-
return CREDENTIAL_PATHS.some(pattern => pattern.test(normalized));
|
|
114
|
+
return CREDENTIAL_PATHS.some(pattern => pattern.test(normalized)) || isExtendedCredentialPath(normalized);
|
|
125
115
|
}
|
|
126
116
|
|
|
127
117
|
const SENSITIVE_WRITE_TARGETS = [
|
|
@@ -130,6 +120,13 @@ const SENSITIVE_WRITE_TARGETS = [
|
|
|
130
120
|
/(^|\/)\.config\/fish\/config\.fish$/,
|
|
131
121
|
// Remote session routing profiles and authentication credentials.
|
|
132
122
|
/(^|\/)\.ssh\//,
|
|
123
|
+
/(^|\/)\.aws\//,
|
|
124
|
+
/(^|\/)\.kube\//,
|
|
125
|
+
/(^|\/)\.gnupg\//,
|
|
126
|
+
/(^|\/)\.docker\/config\.json$/,
|
|
127
|
+
/(^|\/)\.(npmrc|netrc|git-credentials|pypirc|envrc)$/,
|
|
128
|
+
// Git hooks and repository config can execute arbitrary commands on next git invocation.
|
|
129
|
+
/(^|\/)\.git\/(hooks(\/|$)|config$)/,
|
|
133
130
|
// Scheduled execution.
|
|
134
131
|
/(^|\/)(crontab|cron\.d)(\/|$)/,
|
|
135
132
|
/\/etc\//,
|
|
@@ -195,13 +192,11 @@ export class Sandbox {
|
|
|
195
192
|
|
|
196
193
|
updateWorkspacePaths(newPaths) {
|
|
197
194
|
if (Array.isArray(newPaths) && newPaths.length > 0) {
|
|
198
|
-
// Validate: reject any system-critical
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
204
|
-
|
|
195
|
+
// Validate: reject any system-critical roots, filesystem roots, or symlinks to them
|
|
196
|
+
const safePaths = newPaths
|
|
197
|
+
.filter(p => typeof p === 'string' && !isBlockedWorkspaceRoot(p))
|
|
198
|
+
.map(p => path.resolve(p));
|
|
199
|
+
|
|
205
200
|
if (safePaths.length > 0) {
|
|
206
201
|
this.workspacePaths = safePaths;
|
|
207
202
|
return { success: true, paths: this.workspacePaths };
|
|
@@ -210,8 +205,11 @@ export class Sandbox {
|
|
|
210
205
|
return { success: false, reason: 'Invalid or blocked paths provided' };
|
|
211
206
|
}
|
|
212
207
|
|
|
213
|
-
// V5: Add a single workspace path
|
|
208
|
+
// V5: Add a single workspace path (enforces the same blocked-root checks as updateWorkspacePaths)
|
|
214
209
|
addWorkspacePath(newPath) {
|
|
210
|
+
if (typeof newPath !== 'string' || isBlockedWorkspaceRoot(newPath)) {
|
|
211
|
+
return this.workspacePaths;
|
|
212
|
+
}
|
|
215
213
|
const resolved = path.resolve(newPath);
|
|
216
214
|
if (!this.workspacePaths.includes(resolved)) {
|
|
217
215
|
this.workspacePaths.push(resolved);
|
|
@@ -467,25 +465,34 @@ export class Sandbox {
|
|
|
467
465
|
// several of these patterns deliberately span shell separators (the fork
|
|
468
466
|
// bomb contains ; and |, the pipe-to-shell patterns contain |), so
|
|
469
467
|
// splitting first would stop them matching at all.
|
|
468
|
+
const analyzed = analyzeShellCommand(command);
|
|
470
469
|
for (const pattern of FORBIDDEN_PATTERNS) {
|
|
471
470
|
if (pattern.test(normalized)) return 'forbidden';
|
|
471
|
+
for (const rawUnit of analyzed.allRawUnits) {
|
|
472
|
+
if (pattern.test(rawUnit.toLowerCase())) return 'forbidden';
|
|
473
|
+
}
|
|
472
474
|
}
|
|
475
|
+
if (isFetchAndExecPipeline(analyzed.normalizedPipelines)) return 'forbidden';
|
|
473
476
|
|
|
474
477
|
// Everything below judges what the shell will actually execute.
|
|
475
|
-
const masked =
|
|
476
|
-
|
|
478
|
+
const masked = analyzed.maskedTopLevel;
|
|
477
479
|
|
|
478
|
-
// L3 (local-path audit): classify the redirection target, not just the verb.
|
|
480
|
+
// L3 (local-path audit): classify the redirection / tee write target, not just the verb.
|
|
479
481
|
// Tool argument validation enforces boundaries on named arguments, but
|
|
480
|
-
// shell redirection targets appended via operators (>> or >) require independent
|
|
481
|
-
// audit
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
482
|
+
// shell redirection targets appended via operators (>> or >) or `tee` require independent
|
|
483
|
+
// audit — including quoted targets, `$HOME` expansions, and command substitutions.
|
|
484
|
+
if (
|
|
485
|
+
redirectsIntoSensitiveTarget(masked) ||
|
|
486
|
+
analyzed.writeTargets.some(target => isSensitiveWriteTarget(target))
|
|
487
|
+
) {
|
|
488
|
+
return 'extreme';
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const executesQuotedText = analyzed.allMaskedUnits.some(unit => INTERPRETER_INVOCATION.test(unit));
|
|
492
|
+
const scanUnits = executesQuotedText
|
|
493
|
+
? analyzed.allRawUnits.map(u => u.toLowerCase())
|
|
494
|
+
: analyzed.allMaskedUnits;
|
|
487
495
|
|
|
488
|
-
|
|
489
496
|
const EXTREME_PATTERNS = [
|
|
490
497
|
/rm\s+(-rf|-fr)\s+[\/~]/,
|
|
491
498
|
/rm\s+(-rf|-fr)\s+\*/,
|
|
@@ -498,8 +505,16 @@ export class Sandbox {
|
|
|
498
505
|
/diskpart/i
|
|
499
506
|
];
|
|
500
507
|
|
|
501
|
-
for (const
|
|
502
|
-
|
|
508
|
+
for (const unit of scanUnits) {
|
|
509
|
+
for (const pattern of EXTREME_PATTERNS) {
|
|
510
|
+
if (pattern.test(unit)) return 'extreme';
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
for (const seg of analyzed.normalizedSegments) {
|
|
514
|
+
if (isExtremeRemovalSegment(seg)) return 'extreme';
|
|
515
|
+
}
|
|
516
|
+
for (const seg of analyzed.unwrappedRawSegments) {
|
|
517
|
+
if (isExtremeRemovalSegment(seg)) return 'extreme';
|
|
503
518
|
}
|
|
504
519
|
|
|
505
520
|
// DANGEROUS — requires approval in Mode B, auto-executes in Mode C
|
|
@@ -512,13 +527,16 @@ export class Sandbox {
|
|
|
512
527
|
'mv ', 'crontab ', 'systemctl ', 'service '
|
|
513
528
|
];
|
|
514
529
|
|
|
515
|
-
// Prefix rules are per
|
|
516
|
-
//
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
530
|
+
// Prefix rules are evaluated per normalized segment (including env-prefixed,
|
|
531
|
+
// wrapper-prefixed, absolute-path, and `$(...)`/backtick substituted commands).
|
|
532
|
+
// Highest risk across all segments wins.
|
|
533
|
+
for (const seg of analyzed.normalizedSegments) {
|
|
534
|
+
if (seg.isReadOnlyLookup) continue;
|
|
535
|
+
if (seg.executable === 'su') return 'dangerous';
|
|
520
536
|
for (const prefix of DANGEROUS_PREFIXES) {
|
|
521
|
-
if (
|
|
537
|
+
if (seg.normalized.startsWith(prefix) && !isReadOnlyInvocation(seg.normalized)) {
|
|
538
|
+
return 'dangerous';
|
|
539
|
+
}
|
|
522
540
|
}
|
|
523
541
|
}
|
|
524
542
|
|
|
@@ -528,8 +546,10 @@ export class Sandbox {
|
|
|
528
546
|
const DANGEROUS_PATTERNS = [
|
|
529
547
|
/\bfind\b[\s\S]*\s-(exec|execdir|delete)\b/,
|
|
530
548
|
];
|
|
531
|
-
for (const
|
|
532
|
-
|
|
549
|
+
for (const unit of scanUnits) {
|
|
550
|
+
for (const pattern of DANGEROUS_PATTERNS) {
|
|
551
|
+
if (pattern.test(unit)) return 'dangerous';
|
|
552
|
+
}
|
|
533
553
|
}
|
|
534
554
|
|
|
535
555
|
// MODERATE — auto-execute + notify in Mode B
|
|
@@ -548,9 +568,10 @@ export class Sandbox {
|
|
|
548
568
|
'curl ', 'wget '
|
|
549
569
|
];
|
|
550
570
|
|
|
551
|
-
for (const
|
|
571
|
+
for (const seg of analyzed.normalizedSegments) {
|
|
572
|
+
if (seg.isReadOnlyLookup) continue;
|
|
552
573
|
for (const prefix of MODERATE_PREFIXES) {
|
|
553
|
-
if (
|
|
574
|
+
if (seg.normalized.startsWith(prefix)) return 'moderate';
|
|
554
575
|
}
|
|
555
576
|
}
|
|
556
577
|
|