@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/src/approvalPolicy.js
CHANGED
|
@@ -9,38 +9,68 @@ export function currentToolAutonomyMode() {
|
|
|
9
9
|
}
|
|
10
10
|
/** Read the live session mode from the tool context; never infer it from a tool argument. */
|
|
11
11
|
export function isAutonomousToolContext(context) {
|
|
12
|
-
if (!context || typeof context !== 'object')
|
|
12
|
+
if (!context || typeof context !== 'object' || Array.isArray(context))
|
|
13
13
|
return false;
|
|
14
14
|
const parentLoop = context.parentLoop;
|
|
15
|
-
if (!parentLoop || typeof parentLoop !== 'object')
|
|
15
|
+
if (!parentLoop || typeof parentLoop !== 'object' || Array.isArray(parentLoop))
|
|
16
16
|
return false;
|
|
17
17
|
const config = parentLoop.config;
|
|
18
|
-
if (!config || typeof config !== 'object')
|
|
18
|
+
if (!config || typeof config !== 'object' || Array.isArray(config))
|
|
19
19
|
return false;
|
|
20
20
|
const mode = config.autonomyMode;
|
|
21
21
|
return mode === 'C' || mode === undefined;
|
|
22
22
|
}
|
|
23
23
|
const SHELL_TOOLS = new Set(['sysRun', 'sysRunBg', 'terminal_persistent_shell']);
|
|
24
|
-
const WHOLE_FILE_DELETE = /(?:^|[;&|\n(]\s*)(?:(?:sudo|command|env)\s+)*(?:rm|unlink|rmdir|del|erase|Remove-Item)\b|\
|
|
24
|
+
const WHOLE_FILE_DELETE = /(?:^|[;&|\n(]\s*)(?:(?:sudo|doas|pkexec|command|env)\s+)*(?:rm|unlink|rmdir|shred|srm|del|erase|Remove-Item)\b|\bgit\s+rm\b/i;
|
|
25
25
|
const DELETE_API_CALL = /\b(?:os\.(?:remove|unlink)|shutil\.rmtree|fs\.(?:rm|unlink)(?:Sync)?|\.unlink|\.rmdir)\s*\(/i;
|
|
26
|
-
const NESTED_SHELL_DELETE = /\b(?:bash|sh|zsh|dash)\s+-c\s+['"]\s*(?:rm|unlink|rmdir)\b|\b(?:powershell|pwsh)\s+(?:-Command|-c)\s+['"]?\s*Remove-Item\b/i;
|
|
26
|
+
const NESTED_SHELL_DELETE = /\b(?:bash|sh|zsh|dash)\s+-c\s+['"]\s*(?:rm|unlink|rmdir|shred|srm)\b|\b(?:powershell|pwsh)\s+(?:-Command|-c)\s+['"]?\s*Remove-Item\b/i;
|
|
27
|
+
function hasFindDelete(command) {
|
|
28
|
+
for (const segment of command.split(/[\n;]/)) {
|
|
29
|
+
const findMatch = /\bfind\b/i.exec(segment);
|
|
30
|
+
if (!findMatch)
|
|
31
|
+
continue;
|
|
32
|
+
if (/\s-delete\b/i.test(segment.slice(findMatch.index + findMatch[0].length)))
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
function hasGitForceClean(command) {
|
|
38
|
+
for (const segment of command.split(/[\n;&|]/)) {
|
|
39
|
+
const cleanMatch = /\bgit\s+clean\b/i.exec(segment);
|
|
40
|
+
if (!cleanMatch)
|
|
41
|
+
continue;
|
|
42
|
+
const tail = segment.slice(cleanMatch.index + cleanMatch[0].length);
|
|
43
|
+
if (/(?:^|\s)(?:-[a-zA-Z0-9]*f[a-zA-Z0-9]*|--force)\b/i.test(tail))
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
27
48
|
/** A deletion is a whole filesystem entry, not removal of lines in an edit. */
|
|
49
|
+
function canonicalPolicyTool(tool) {
|
|
50
|
+
return typeof tool === 'string' ? tool.trim().replace(/\./g, '_') : '';
|
|
51
|
+
}
|
|
28
52
|
export function isWholeFileDeletion(tool, args) {
|
|
29
|
-
|
|
53
|
+
const canonical = canonicalPolicyTool(tool);
|
|
54
|
+
if (canonical === 'fs_delete')
|
|
30
55
|
return true;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
const safeArgs = args && typeof args === 'object' ? args : {};
|
|
57
|
+
const command = canonical === 'gitOp'
|
|
58
|
+
? `git ${String(safeArgs.command ?? safeArgs.action ?? '')}`
|
|
59
|
+
: SHELL_TOOLS.has(canonical)
|
|
60
|
+
? String(safeArgs.command ?? safeArgs.input ?? safeArgs.cmd ?? '')
|
|
35
61
|
: '';
|
|
36
|
-
if (/^\s*git\s+rm\s+--cached\b
|
|
62
|
+
if (/^\s*git\s+rm\s+--cached\b[^;&|\n`$()]*$/i.test(command))
|
|
37
63
|
return false;
|
|
38
64
|
return command.length > 0
|
|
39
|
-
&& (WHOLE_FILE_DELETE.test(command)
|
|
65
|
+
&& (WHOLE_FILE_DELETE.test(command)
|
|
66
|
+
|| hasFindDelete(command)
|
|
67
|
+
|| hasGitForceClean(command)
|
|
68
|
+
|| DELETE_API_CALL.test(command)
|
|
69
|
+
|| NESTED_SHELL_DELETE.test(command));
|
|
40
70
|
}
|
|
41
71
|
/** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Mode B or C unless uploading or downloading files. */
|
|
42
72
|
export function isRoutineBrowserVerification(tool, args) {
|
|
43
|
-
if (tool !== 'browser_act')
|
|
73
|
+
if (canonicalPolicyTool(tool) !== 'browser_act')
|
|
44
74
|
return false;
|
|
45
75
|
const actions = Array.isArray(args?.actions) ? args.actions : [];
|
|
46
76
|
if (actions.length === 0) {
|
|
@@ -56,11 +86,14 @@ export function isRoutineBrowserVerification(tool, args) {
|
|
|
56
86
|
}
|
|
57
87
|
/** Prompt policy only. Sandbox denial, workspace checks, and observer veto run separately. */
|
|
58
88
|
export function requiresToolApproval(input) {
|
|
89
|
+
if (!input || typeof input !== 'object')
|
|
90
|
+
return true;
|
|
91
|
+
const canonical = canonicalPolicyTool(input.tool);
|
|
59
92
|
if (input.mode === 'C') {
|
|
60
|
-
if (!isWholeFileDeletion(
|
|
93
|
+
if (!isWholeFileDeletion(canonical, input.args))
|
|
61
94
|
return false;
|
|
62
95
|
// A general shell or git grant must not authorize future deletions.
|
|
63
|
-
return
|
|
96
|
+
return canonical !== 'fs_delete' || !input.standingApproval;
|
|
64
97
|
}
|
|
65
98
|
if (input.standingApproval)
|
|
66
99
|
return false;
|
package/src/approvalPolicy.ts
CHANGED
|
@@ -24,36 +24,65 @@ export interface ToolApprovalInput {
|
|
|
24
24
|
|
|
25
25
|
/** Read the live session mode from the tool context; never infer it from a tool argument. */
|
|
26
26
|
export function isAutonomousToolContext(context: unknown): boolean {
|
|
27
|
-
if (!context || typeof context !== 'object') return false;
|
|
27
|
+
if (!context || typeof context !== 'object' || Array.isArray(context)) return false;
|
|
28
28
|
const parentLoop = (context as { parentLoop?: unknown }).parentLoop;
|
|
29
|
-
if (!parentLoop || typeof parentLoop !== 'object') return false;
|
|
29
|
+
if (!parentLoop || typeof parentLoop !== 'object' || Array.isArray(parentLoop)) return false;
|
|
30
30
|
const config = (parentLoop as { config?: unknown }).config;
|
|
31
|
-
if (!config || typeof config !== 'object') return false;
|
|
31
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) return false;
|
|
32
32
|
const mode = (config as { autonomyMode?: unknown }).autonomyMode;
|
|
33
33
|
return mode === 'C' || mode === undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const SHELL_TOOLS = new Set(['sysRun', 'sysRunBg', 'terminal_persistent_shell']);
|
|
37
|
-
const WHOLE_FILE_DELETE = /(?:^|[;&|\n(]\s*)(?:(?:sudo|command|env)\s+)*(?:rm|unlink|rmdir|del|erase|Remove-Item)\b|\
|
|
37
|
+
const WHOLE_FILE_DELETE = /(?:^|[;&|\n(]\s*)(?:(?:sudo|doas|pkexec|command|env)\s+)*(?:rm|unlink|rmdir|shred|srm|del|erase|Remove-Item)\b|\bgit\s+rm\b/i;
|
|
38
38
|
const DELETE_API_CALL = /\b(?:os\.(?:remove|unlink)|shutil\.rmtree|fs\.(?:rm|unlink)(?:Sync)?|\.unlink|\.rmdir)\s*\(/i;
|
|
39
|
-
const NESTED_SHELL_DELETE = /\b(?:bash|sh|zsh|dash)\s+-c\s+['"]\s*(?:rm|unlink|rmdir)\b|\b(?:powershell|pwsh)\s+(?:-Command|-c)\s+['"]?\s*Remove-Item\b/i;
|
|
39
|
+
const NESTED_SHELL_DELETE = /\b(?:bash|sh|zsh|dash)\s+-c\s+['"]\s*(?:rm|unlink|rmdir|shred|srm)\b|\b(?:powershell|pwsh)\s+(?:-Command|-c)\s+['"]?\s*Remove-Item\b/i;
|
|
40
|
+
|
|
41
|
+
function hasFindDelete(command: string): boolean {
|
|
42
|
+
for (const segment of command.split(/[\n;]/)) {
|
|
43
|
+
const findMatch = /\bfind\b/i.exec(segment);
|
|
44
|
+
if (!findMatch) continue;
|
|
45
|
+
if (/\s-delete\b/i.test(segment.slice(findMatch.index + findMatch[0].length))) return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hasGitForceClean(command: string): boolean {
|
|
51
|
+
for (const segment of command.split(/[\n;&|]/)) {
|
|
52
|
+
const cleanMatch = /\bgit\s+clean\b/i.exec(segment);
|
|
53
|
+
if (!cleanMatch) continue;
|
|
54
|
+
const tail = segment.slice(cleanMatch.index + cleanMatch[0].length);
|
|
55
|
+
if (/(?:^|\s)(?:-[a-zA-Z0-9]*f[a-zA-Z0-9]*|--force)\b/i.test(tail)) return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
40
59
|
|
|
41
60
|
/** A deletion is a whole filesystem entry, not removal of lines in an edit. */
|
|
61
|
+
function canonicalPolicyTool(tool: unknown): string {
|
|
62
|
+
return typeof tool === 'string' ? tool.trim().replace(/\./g, '_') : '';
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
export function isWholeFileDeletion(tool: string, args: Record<string, unknown>): boolean {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
const canonical = canonicalPolicyTool(tool);
|
|
67
|
+
if (canonical === 'fs_delete') return true;
|
|
68
|
+
const safeArgs = args && typeof args === 'object' ? args : {};
|
|
69
|
+
const command = canonical === 'gitOp'
|
|
70
|
+
? `git ${String(safeArgs.command ?? safeArgs.action ?? '')}`
|
|
71
|
+
: SHELL_TOOLS.has(canonical)
|
|
72
|
+
? String(safeArgs.command ?? safeArgs.input ?? safeArgs.cmd ?? '')
|
|
48
73
|
: '';
|
|
49
|
-
if (/^\s*git\s+rm\s+--cached\b
|
|
74
|
+
if (/^\s*git\s+rm\s+--cached\b[^;&|\n`$()]*$/i.test(command)) return false;
|
|
50
75
|
return command.length > 0
|
|
51
|
-
&& (WHOLE_FILE_DELETE.test(command)
|
|
76
|
+
&& (WHOLE_FILE_DELETE.test(command)
|
|
77
|
+
|| hasFindDelete(command)
|
|
78
|
+
|| hasGitForceClean(command)
|
|
79
|
+
|| DELETE_API_CALL.test(command)
|
|
80
|
+
|| NESTED_SHELL_DELETE.test(command));
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
/** Routine browser verification inside the isolated agent browser (preview, snapshot, click, fill, screenshot, etc.) does not require HITL in Mode B or C unless uploading or downloading files. */
|
|
55
84
|
export function isRoutineBrowserVerification(tool: string, args: Record<string, unknown>): boolean {
|
|
56
|
-
if (tool !== 'browser_act') return false;
|
|
85
|
+
if (canonicalPolicyTool(tool) !== 'browser_act') return false;
|
|
57
86
|
const actions = Array.isArray(args?.actions) ? args.actions : [];
|
|
58
87
|
if (actions.length === 0) {
|
|
59
88
|
const singleType = typeof args?.action === 'string' ? args.action : typeof args?.type === 'string' ? args.type : '';
|
|
@@ -68,10 +97,12 @@ export function isRoutineBrowserVerification(tool: string, args: Record<string,
|
|
|
68
97
|
|
|
69
98
|
/** Prompt policy only. Sandbox denial, workspace checks, and observer veto run separately. */
|
|
70
99
|
export function requiresToolApproval(input: ToolApprovalInput): boolean {
|
|
100
|
+
if (!input || typeof input !== 'object') return true;
|
|
101
|
+
const canonical = canonicalPolicyTool(input.tool);
|
|
71
102
|
if (input.mode === 'C') {
|
|
72
|
-
if (!isWholeFileDeletion(
|
|
103
|
+
if (!isWholeFileDeletion(canonical, input.args)) return false;
|
|
73
104
|
// A general shell or git grant must not authorize future deletions.
|
|
74
|
-
return
|
|
105
|
+
return canonical !== 'fs_delete' || !input.standingApproval;
|
|
75
106
|
}
|
|
76
107
|
if (input.standingApproval) return false;
|
|
77
108
|
if (input.mode !== 'A' && isRoutineBrowserVerification(input.tool, input.args)) {
|
package/src/autoUpdate.js
CHANGED
|
@@ -85,8 +85,11 @@ function managedPrefix(packageRoot = PACKAGE_ROOT, env = process.env) {
|
|
|
85
85
|
];
|
|
86
86
|
for (const marker of markers) {
|
|
87
87
|
const index = packageRoot.lastIndexOf(marker);
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
const atBoundary = index === 0 || packageRoot[index - 1] === '/' || packageRoot[index - 1] === '\\';
|
|
89
|
+
if (index >= 0 && atBoundary && index + marker.length === packageRoot.length) {
|
|
90
|
+
const rawPrefix = packageRoot.slice(0, index);
|
|
91
|
+
const root = path.parse(rawPrefix).root;
|
|
92
|
+
return rawPrefix === root ? rawPrefix : rawPrefix.replace(/[\\/]$/, '');
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
return null;
|
package/src/autoUpdate.ts
CHANGED
|
@@ -153,8 +153,11 @@ function managedPrefix(packageRoot: string = PACKAGE_ROOT, env: NodeJS.ProcessEn
|
|
|
153
153
|
];
|
|
154
154
|
for (const marker of markers) {
|
|
155
155
|
const index = packageRoot.lastIndexOf(marker);
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
const atBoundary = index === 0 || packageRoot[index - 1] === '/' || packageRoot[index - 1] === '\\';
|
|
157
|
+
if (index >= 0 && atBoundary && index + marker.length === packageRoot.length) {
|
|
158
|
+
const rawPrefix = packageRoot.slice(0, index);
|
|
159
|
+
const root = path.parse(rawPrefix).root;
|
|
160
|
+
return rawPrefix === root ? rawPrefix : rawPrefix.replace(/[\\/]$/, '');
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
return null;
|
|
@@ -72,7 +72,8 @@ const SEARCH_MACROS = {
|
|
|
72
72
|
'@twitch_search': query => `https://www.twitch.tv/search?term=${encodeURIComponent(query || '')}`
|
|
73
73
|
};
|
|
74
74
|
export function expandSearchMacro(macro, query = '') {
|
|
75
|
-
const
|
|
75
|
+
const key = String(macro || '').trim();
|
|
76
|
+
const fn = Object.hasOwn(SEARCH_MACROS, key) ? SEARCH_MACROS[key] : undefined;
|
|
76
77
|
return fn ? fn(String(query ?? '')) : null;
|
|
77
78
|
}
|
|
78
79
|
export function getSupportedSearchMacros() {
|
|
@@ -579,7 +580,7 @@ const SEARCH_EXTRACT_SCRIPT = `(() => {
|
|
|
579
580
|
if (parsed.hostname.includes('google.') && parsed.pathname === '/url') {
|
|
580
581
|
href = parsed.searchParams.get('q') || parsed.searchParams.get('url') || href;
|
|
581
582
|
}
|
|
582
|
-
if (/(
|
|
583
|
+
if (/(^|\\.)duckduckgo\\.com$/i.test(parsed.hostname) && parsed.pathname.startsWith('/l/')) {
|
|
583
584
|
href = parsed.searchParams.get('uddg') || href;
|
|
584
585
|
}
|
|
585
586
|
const clean = new URL(href, document.baseURI);
|
|
@@ -86,7 +86,8 @@ const SEARCH_MACROS: Record<string, (query: string) => string> = {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export function expandSearchMacro(macro: string, query = ''): string | null {
|
|
89
|
-
const
|
|
89
|
+
const key = String(macro || '').trim();
|
|
90
|
+
const fn = Object.hasOwn(SEARCH_MACROS, key) ? SEARCH_MACROS[key] : undefined;
|
|
90
91
|
return fn ? fn(String(query ?? '')) : null;
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -845,7 +846,7 @@ const SEARCH_EXTRACT_SCRIPT = `(() => {
|
|
|
845
846
|
if (parsed.hostname.includes('google.') && parsed.pathname === '/url') {
|
|
846
847
|
href = parsed.searchParams.get('q') || parsed.searchParams.get('url') || href;
|
|
847
848
|
}
|
|
848
|
-
if (/(
|
|
849
|
+
if (/(^|\\.)duckduckgo\\.com$/i.test(parsed.hostname) && parsed.pathname.startsWith('/l/')) {
|
|
849
850
|
href = parsed.searchParams.get('uddg') || href;
|
|
850
851
|
}
|
|
851
852
|
const clean = new URL(href, document.baseURI);
|
|
@@ -14,7 +14,7 @@ function decodeEntities(value) {
|
|
|
14
14
|
return Number.isInteger(point) && point > 0 && point <= 0x10ffff && !(point >= 0xd800 && point <= 0xdfff)
|
|
15
15
|
? String.fromCodePoint(point) : full;
|
|
16
16
|
}
|
|
17
|
-
return named[normalized]
|
|
17
|
+
return Object.hasOwn(named, normalized) ? named[normalized] : full;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
function cleanMarkup(value) {
|
|
@@ -27,7 +27,7 @@ function decodeEntities(value: string): string {
|
|
|
27
27
|
return Number.isInteger(point) && point > 0 && point <= 0x10ffff && !(point >= 0xd800 && point <= 0xdfff)
|
|
28
28
|
? String.fromCodePoint(point) : full;
|
|
29
29
|
}
|
|
30
|
-
return named[normalized]
|
|
30
|
+
return Object.hasOwn(named, normalized) ? named[normalized]! : full;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|