opencode-swarm 7.35.0 → 7.37.0
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/dist/agents/agent-output-schema.d.ts +9 -1
- package/dist/cli/index.js +801 -27
- package/dist/index.js +4080 -2349
- package/dist/memory/curator-decision-helpers.d.ts +14 -0
- package/dist/memory/gateway.d.ts +5 -1
- package/dist/memory/index.d.ts +2 -2
- package/dist/memory/injector.d.ts +1 -1
- package/dist/memory/local-jsonl-provider.d.ts +4 -1
- package/dist/memory/provider.d.ts +2 -1
- package/dist/memory/run-log.d.ts +1 -1
- package/dist/memory/schema.d.ts +5 -1
- package/dist/memory/sqlite-provider.d.ts +25 -1
- package/dist/memory/types.d.ts +74 -0
- package/dist/sandbox/capability-probe.d.ts +55 -0
- package/dist/sandbox/executor.d.ts +51 -0
- package/dist/sandbox/executors/bubblewrap.d.ts +1 -0
- package/dist/sandbox/executors/macos.d.ts +1 -0
- package/dist/sandbox/executors/windows.d.ts +1 -0
- package/dist/sandbox/linux/bubblewrap-executor.d.ts +79 -0
- package/dist/sandbox/linux/edge-cases.d.ts +89 -0
- package/dist/sandbox/macos/edge-cases.d.ts +89 -0
- package/dist/sandbox/macos/sandbox-exec-executor.d.ts +68 -0
- package/dist/sandbox/scope-resolver.d.ts +32 -0
- package/dist/sandbox/win32/edge-cases.d.ts +90 -0
- package/dist/sandbox/win32/restricted-token-executor.d.ts +94 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* macOS sandbox-exec sandbox executor.
|
|
3
|
+
*
|
|
4
|
+
* Wraps shell commands with sandbox-exec(8) to restrict process capabilities
|
|
5
|
+
* using a profile-based deny-by-default policy.
|
|
6
|
+
*
|
|
7
|
+
* Profile allows:
|
|
8
|
+
* - Read-only access to essential system paths (/usr, /bin, /sbin, /lib)
|
|
9
|
+
* - Read-write access to each scope path
|
|
10
|
+
* - Read-write access to the temp directory (500MB bounded)
|
|
11
|
+
* - Denies all other file writes
|
|
12
|
+
*/
|
|
13
|
+
import { type SandboxExecutor } from '../executor';
|
|
14
|
+
/**
|
|
15
|
+
* Check whether the sandbox-exec binary is present and functional.
|
|
16
|
+
* Uses spawnSync to probe synchronously without throwing.
|
|
17
|
+
*/
|
|
18
|
+
declare function probeSandboxExec(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* DI seam for testability. Exposes probeSandboxExec so tests can simulate
|
|
21
|
+
* ENOENT / EACCES / ENOSPC error conditions without requiring a real sandbox-exec binary.
|
|
22
|
+
*/
|
|
23
|
+
export declare const _internals: {
|
|
24
|
+
probeSandboxExec: typeof probeSandboxExec;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* macOS sandbox-exec sandbox executor.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MacOSSandboxExecutor implements SandboxExecutor {
|
|
30
|
+
/** Human-readable mechanism identifier */
|
|
31
|
+
readonly mechanism = "sandbox-exec";
|
|
32
|
+
private readonly _scopePaths;
|
|
33
|
+
private readonly _tempDir;
|
|
34
|
+
private _available;
|
|
35
|
+
private _disabledReason;
|
|
36
|
+
/**
|
|
37
|
+
* @param scopePaths - Absolute paths the sandboxed process may write to
|
|
38
|
+
* @param tempDir - Optional temp directory path (defaults to system temp)
|
|
39
|
+
*/
|
|
40
|
+
constructor(scopePaths?: string[], tempDir?: string);
|
|
41
|
+
/**
|
|
42
|
+
* Returns true when sandbox-exec is available and the sandbox has not been disabled.
|
|
43
|
+
*/
|
|
44
|
+
isAvailable(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Disable the sandbox with a reason.
|
|
47
|
+
*/
|
|
48
|
+
disable(reason: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Wrap a shell command string with sandbox-exec.
|
|
51
|
+
*
|
|
52
|
+
* @param command - Raw shell command to execute inside the sandbox
|
|
53
|
+
* @param scopePaths - Additional scope paths to bind (merged with constructor scope)
|
|
54
|
+
* @param tempDir - Optional temp directory override
|
|
55
|
+
* @returns A sandbox-exec wrapped command string ready for shell execution,
|
|
56
|
+
* or the raw command string when the sandbox is unavailable (passthrough mode)
|
|
57
|
+
*/
|
|
58
|
+
wrapCommand(command: string, scopePaths: string[], tempDir?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Return environment variable overrides required for the macOS sandbox.
|
|
61
|
+
*
|
|
62
|
+
* DYLD_INSERT_LIBRARIES, DYLD_LIBRARY_PATH, DYLD_FRAMEWORK_PATH, and
|
|
63
|
+
* DYLD_ROOT_PATH can be used to bypass sandbox restrictions by injecting
|
|
64
|
+
* dynamic libraries. Unsetting them improves sandbox enforcement (defense in depth).
|
|
65
|
+
*/
|
|
66
|
+
getEnvOverrides(): Record<string, string | null>;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of resolving scope paths for sandbox enforcement.
|
|
3
|
+
*/
|
|
4
|
+
export interface ResolvedScope {
|
|
5
|
+
/** Absolute paths that the sandbox will allow writes to */
|
|
6
|
+
paths: string[];
|
|
7
|
+
/** Any warnings about paths that were modified or skipped */
|
|
8
|
+
warnings: string[];
|
|
9
|
+
/** Paths that were rejected (e.g., non-existent, traversal attempts) */
|
|
10
|
+
rejected: {
|
|
11
|
+
path: string;
|
|
12
|
+
reason: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve scope paths for sandbox enforcement.
|
|
17
|
+
*
|
|
18
|
+
* Converts relative scope paths to absolute, validates against traversal attacks,
|
|
19
|
+
* checks existence, deduplicates, and normalizes path separators.
|
|
20
|
+
*
|
|
21
|
+
* @param rawPaths - Paths from the task scope declaration (may be relative or absolute)
|
|
22
|
+
* @param projectRoot - The project root directory (for resolving relative paths)
|
|
23
|
+
* @returns ResolvedScope with absolute paths, warnings, and rejections
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveScopePaths(rawPaths: string[], projectRoot: string): ResolvedScope;
|
|
26
|
+
/**
|
|
27
|
+
* DI seam for testability. Contains all test-mocked exports.
|
|
28
|
+
* Internal calls should use _internals.fn() instead of fn() directly.
|
|
29
|
+
*/
|
|
30
|
+
export declare const _internals: {
|
|
31
|
+
resolveScopePaths: typeof resolveScopePaths;
|
|
32
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge case handling utilities for Windows sandbox.
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to detect and prevent:
|
|
5
|
+
* - Path traversal attacks
|
|
6
|
+
* - Registry escape attempts
|
|
7
|
+
* - PowerShell command bypass
|
|
8
|
+
* - WMI command execution bypass
|
|
9
|
+
* - Windows service escalation
|
|
10
|
+
* - DLL search order hijacking
|
|
11
|
+
* - Token manipulation attacks
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Detects Windows path traversal patterns that could escape sandbox containment.
|
|
15
|
+
*
|
|
16
|
+
* Attack: Attackers use `..`, absolute paths, or extended-length paths
|
|
17
|
+
* to access files outside the intended sandbox scope.
|
|
18
|
+
*
|
|
19
|
+
* @param command - The command string to analyze
|
|
20
|
+
* @returns true if path traversal patterns are detected
|
|
21
|
+
*/
|
|
22
|
+
export declare function detectPathTraversal(command: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Detects registry manipulation attempts to bypass sandbox restrictions.
|
|
25
|
+
*
|
|
26
|
+
* Attack: Modifying the registry can disable security policies,
|
|
27
|
+
* create startup entries, or alter system behavior.
|
|
28
|
+
*
|
|
29
|
+
* @param command - The command string to analyze
|
|
30
|
+
* @returns true if registry manipulation is detected
|
|
31
|
+
*/
|
|
32
|
+
export declare function detectRegistryEscape(command: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Detects PowerShell command execution patterns that could bypass sandbox restrictions.
|
|
35
|
+
*
|
|
36
|
+
* Attack: PowerShell's flexibility allows executing encoded commands, remote scripts,
|
|
37
|
+
* and leveraging various execution policy bypasses.
|
|
38
|
+
*
|
|
39
|
+
* @param command - The command string to analyze
|
|
40
|
+
* @returns true if PowerShell escape patterns are detected
|
|
41
|
+
*/
|
|
42
|
+
export declare function detectPowerShellEscape(command: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Detects WMI command execution that could bypass sandbox restrictions.
|
|
45
|
+
*
|
|
46
|
+
* Attack: WMI can be used for remote execution, process creation,
|
|
47
|
+
* and querying system information.
|
|
48
|
+
*
|
|
49
|
+
* @param command - The command string to analyze
|
|
50
|
+
* @returns true if WMI escape patterns are detected
|
|
51
|
+
*/
|
|
52
|
+
export declare function detectWMIEscape(command: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Alias for detectServiceManipulation for API compatibility.
|
|
55
|
+
* @param command - The command string to analyze
|
|
56
|
+
* @returns true if service manipulation is detected
|
|
57
|
+
*/
|
|
58
|
+
export declare function detectServiceEscalation(command: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Detects Windows service manipulation attempts.
|
|
61
|
+
*
|
|
62
|
+
* Attack: Creating or modifying Windows services can establish
|
|
63
|
+
* persistent execution with elevated privileges.
|
|
64
|
+
*
|
|
65
|
+
* @param command - The command string to analyze
|
|
66
|
+
* @returns true if service manipulation is detected
|
|
67
|
+
*/
|
|
68
|
+
export declare function detectServiceManipulation(command: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Detects DLL search order hijacking via PATH manipulation.
|
|
71
|
+
*
|
|
72
|
+
* Attack: If the PATH contains ".", current directory, or writable
|
|
73
|
+
* system paths, an attacker can place a malicious DLL that gets loaded
|
|
74
|
+
* by a legitimate binary.
|
|
75
|
+
*
|
|
76
|
+
* @param command - The command string to analyze
|
|
77
|
+
* @param env - The environment variables to check
|
|
78
|
+
* @returns true if DLL hijacking via PATH manipulation is detected
|
|
79
|
+
*/
|
|
80
|
+
export declare function detectDLLHijacking(command: string, env?: Record<string, string | undefined>): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Detects attempts to manipulate process tokens or create processes with elevated privileges.
|
|
83
|
+
*
|
|
84
|
+
* Attack: Token manipulation allows a process to acquire elevated privileges
|
|
85
|
+
* or the privileges of another user, enabling privilege escalation.
|
|
86
|
+
*
|
|
87
|
+
* @param command - The command string to analyze
|
|
88
|
+
* @returns true if token manipulation is detected
|
|
89
|
+
*/
|
|
90
|
+
export declare function detectTokenManipulation(command: string): boolean;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows Restricted Token sandbox executor.
|
|
3
|
+
*
|
|
4
|
+
* Wraps shell commands with a PowerShell-based sandbox approach to restrict
|
|
5
|
+
* process capabilities on Windows.
|
|
6
|
+
*
|
|
7
|
+
* Windows does not have a native sandbox mechanism equivalent to Linux bwrap
|
|
8
|
+
* or macOS sandbox-exec that is accessible from Node.js without native bindings.
|
|
9
|
+
* This executor provides best-effort sandboxing via:
|
|
10
|
+
* - Environment variable scrubbing (removing dangerous vars)
|
|
11
|
+
* - PATH restriction to safe system paths only
|
|
12
|
+
* - Scoped temp directory
|
|
13
|
+
* - PowerShell wrapper for command execution
|
|
14
|
+
*
|
|
15
|
+
* For true OS-level sandboxing (AppContainer, Restricted Token, Low Integrity),
|
|
16
|
+
* native Windows APIs (CreateAppContainerToken, CreateRestrictedToken) are required.
|
|
17
|
+
*/
|
|
18
|
+
import type { SandboxExecutor } from '../executor';
|
|
19
|
+
/**
|
|
20
|
+
* Check whether the Windows sandbox mechanism is present and functional.
|
|
21
|
+
* Uses spawnSync to probe synchronously without throwing.
|
|
22
|
+
*
|
|
23
|
+
* On Windows, this verifies that basic command execution works.
|
|
24
|
+
* A failure here indicates the sandbox cannot be initialized and should
|
|
25
|
+
* degrade gracefully to passthrough mode.
|
|
26
|
+
*/
|
|
27
|
+
declare function probeWindowsSandbox(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* DI seam for testability. Exposes the probe function so tests can simulate
|
|
30
|
+
* unavailable sandbox conditions without requiring a real Windows environment.
|
|
31
|
+
*/
|
|
32
|
+
export declare const _internals: {
|
|
33
|
+
probeWindowsSandbox: typeof probeWindowsSandbox;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Windows Restricted Token sandbox executor.
|
|
37
|
+
*
|
|
38
|
+
* Provides best-effort process sandboxing via PowerShell environment restrictions.
|
|
39
|
+
* True OS-level sandboxing requires native Windows API bindings.
|
|
40
|
+
*/
|
|
41
|
+
export declare class WindowsSandboxExecutor implements SandboxExecutor {
|
|
42
|
+
/** Human-readable mechanism identifier */
|
|
43
|
+
readonly mechanism = "powershell-wrapper";
|
|
44
|
+
private readonly _scopePaths;
|
|
45
|
+
private readonly _tempDir;
|
|
46
|
+
private _available;
|
|
47
|
+
private _disabled;
|
|
48
|
+
private _disabledReason;
|
|
49
|
+
/**
|
|
50
|
+
* @param scopePaths - Absolute paths the sandboxed process may write to
|
|
51
|
+
* @param tempDir - Optional temp directory path (defaults to system temp)
|
|
52
|
+
*/
|
|
53
|
+
constructor(scopePaths?: string[], tempDir?: string);
|
|
54
|
+
/**
|
|
55
|
+
* Returns true when the Windows sandbox is available and has not been disabled.
|
|
56
|
+
*/
|
|
57
|
+
isAvailable(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Disable the sandbox with a reason. Allows external code to force
|
|
60
|
+
* fallback to unwrapped execution (e.g., for testing, explicit opt-out,
|
|
61
|
+
* or when initialization fails).
|
|
62
|
+
*
|
|
63
|
+
* After calling disable():
|
|
64
|
+
* - isAvailable() returns false
|
|
65
|
+
* - wrapCommand() returns the raw command unchanged (passthrough)
|
|
66
|
+
*/
|
|
67
|
+
disable(reason: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Wrap a shell command string with PowerShell-based sandbox restrictions.
|
|
70
|
+
*
|
|
71
|
+
* The wrapper:
|
|
72
|
+
* - Sets scoped temp directory (%TEMP%, %TMP%)
|
|
73
|
+
* - Restricts PATH to safe system paths only
|
|
74
|
+
* - Removes dangerous environment variables that could be used to bypass restrictions
|
|
75
|
+
* - Executes the command via cmd /c inside a PowerShell script
|
|
76
|
+
*
|
|
77
|
+
* @param command - Raw shell command to execute inside the sandbox
|
|
78
|
+
* @param scopePaths - Additional scope paths to allow (merged with constructor scope)
|
|
79
|
+
* @param tempDir - Optional temp directory override
|
|
80
|
+
* @returns A PowerShell-wrapped command string ready for shell execution,
|
|
81
|
+
* or the raw command string when the sandbox is unavailable (passthrough mode)
|
|
82
|
+
*/
|
|
83
|
+
wrapCommand(command: string, scopePaths: string[], tempDir?: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Return environment variable overrides required for the Windows sandbox.
|
|
86
|
+
*
|
|
87
|
+
* Security measures:
|
|
88
|
+
* - PATH is restricted to essential Windows system directories only
|
|
89
|
+
* - TEMP/TMP are set to null (will be set to scoped temp at runtime via wrapCommand)
|
|
90
|
+
* - Dangerous variables that don't apply to Windows are cleared for completeness
|
|
91
|
+
*/
|
|
92
|
+
getEnvOverrides(): Record<string, string | null>;
|
|
93
|
+
}
|
|
94
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.37.0",
|
|
4
4
|
"description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|