@agenshield/sandbox 0.1.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.
Files changed (52) hide show
  1. package/backup.d.ts +53 -0
  2. package/backup.d.ts.map +1 -0
  3. package/detect.d.ts +44 -0
  4. package/detect.d.ts.map +1 -0
  5. package/directories.d.ts +113 -0
  6. package/directories.d.ts.map +1 -0
  7. package/discovery/binary-scanner.d.ts +44 -0
  8. package/discovery/binary-scanner.d.ts.map +1 -0
  9. package/discovery/index.d.ts +7 -0
  10. package/discovery/index.d.ts.map +1 -0
  11. package/discovery/scanner.d.ts +12 -0
  12. package/discovery/scanner.d.ts.map +1 -0
  13. package/discovery/skill-scanner.d.ts +31 -0
  14. package/discovery/skill-scanner.d.ts.map +1 -0
  15. package/guarded-shell.d.ts +34 -0
  16. package/guarded-shell.d.ts.map +1 -0
  17. package/index.d.ts +27 -0
  18. package/index.d.ts.map +1 -0
  19. package/index.js +6155 -0
  20. package/launchdaemon.d.ts +76 -0
  21. package/launchdaemon.d.ts.map +1 -0
  22. package/macos.d.ts +44 -0
  23. package/macos.d.ts.map +1 -0
  24. package/migration.d.ts +49 -0
  25. package/migration.d.ts.map +1 -0
  26. package/package.json +24 -0
  27. package/presets/custom.d.ts +12 -0
  28. package/presets/custom.d.ts.map +1 -0
  29. package/presets/dev-harness.d.ts +12 -0
  30. package/presets/dev-harness.d.ts.map +1 -0
  31. package/presets/index.d.ts +53 -0
  32. package/presets/index.d.ts.map +1 -0
  33. package/presets/openclaw.d.ts +12 -0
  34. package/presets/openclaw.d.ts.map +1 -0
  35. package/presets/types.d.ts +106 -0
  36. package/presets/types.d.ts.map +1 -0
  37. package/restore.d.ts +38 -0
  38. package/restore.d.ts.map +1 -0
  39. package/seatbelt.d.ts +59 -0
  40. package/seatbelt.d.ts.map +1 -0
  41. package/security.d.ts +44 -0
  42. package/security.d.ts.map +1 -0
  43. package/shield-exec.d.ts +20 -0
  44. package/shield-exec.d.ts.map +1 -0
  45. package/skill-injector.d.ts +48 -0
  46. package/skill-injector.d.ts.map +1 -0
  47. package/types.d.ts +38 -0
  48. package/types.d.ts.map +1 -0
  49. package/users.d.ts +169 -0
  50. package/users.d.ts.map +1 -0
  51. package/wrappers.d.ts +217 -0
  52. package/wrappers.d.ts.map +1 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * LaunchDaemon Management
3
+ *
4
+ * Creates and manages macOS LaunchDaemon for the broker.
5
+ */
6
+ /**
7
+ * Generate the broker LaunchDaemon plist (with UserConfig)
8
+ */
9
+ export declare function generateBrokerPlist(config: import('@agenshield/ipc').UserConfig, options?: {
10
+ brokerPath?: string;
11
+ configPath?: string;
12
+ socketPath?: string;
13
+ nodeBinPath?: string;
14
+ }): string;
15
+ /**
16
+ * Generate the broker LaunchDaemon plist (legacy - no UserConfig)
17
+ */
18
+ export declare function generateBrokerPlistLegacy(options?: {
19
+ brokerBinary?: string;
20
+ configPath?: string;
21
+ socketPath?: string;
22
+ }): string;
23
+ export interface DaemonResult {
24
+ success: boolean;
25
+ message: string;
26
+ plistPath?: string;
27
+ loaded?: boolean;
28
+ error?: Error;
29
+ }
30
+ /**
31
+ * Install the LaunchDaemon from plist content
32
+ */
33
+ export declare function installLaunchDaemon(plistContent: string): Promise<DaemonResult>;
34
+ /**
35
+ * Install the LaunchDaemon with options (legacy)
36
+ */
37
+ export declare function installLaunchDaemon(options?: {
38
+ brokerBinary?: string;
39
+ configPath?: string;
40
+ socketPath?: string;
41
+ }): Promise<DaemonResult>;
42
+ /**
43
+ * Load the LaunchDaemon
44
+ */
45
+ export declare function loadLaunchDaemon(): Promise<DaemonResult>;
46
+ /**
47
+ * Unload the LaunchDaemon
48
+ */
49
+ export declare function unloadLaunchDaemon(): Promise<DaemonResult>;
50
+ /**
51
+ * Uninstall the LaunchDaemon
52
+ */
53
+ export declare function uninstallLaunchDaemon(): Promise<DaemonResult>;
54
+ /**
55
+ * Check if LaunchDaemon is running
56
+ */
57
+ export declare function isDaemonRunning(): Promise<boolean>;
58
+ /**
59
+ * Get daemon status
60
+ */
61
+ export declare function getDaemonStatus(): Promise<{
62
+ installed: boolean;
63
+ running: boolean;
64
+ pid?: number;
65
+ lastExitStatus?: number;
66
+ }>;
67
+ /**
68
+ * Restart the daemon
69
+ */
70
+ export declare function restartDaemon(): Promise<DaemonResult>;
71
+ /**
72
+ * Fix socket permissions after broker starts
73
+ * This ensures the daemon user can access the broker socket
74
+ */
75
+ export declare function fixSocketPermissions(config?: import('@agenshield/ipc').UserConfig): Promise<DaemonResult>;
76
+ //# sourceMappingURL=launchdaemon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launchdaemon.d.ts","sourceRoot":"","sources":["../src/launchdaemon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,iBAAiB,EAAE,UAAU,EAC5C,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,MAAM,CAkER;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CA8DT;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACvF;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AA+C1B;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAe9D;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,YAAY,CAAC,CAuBhE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,YAAY,CAAC,CAmBnE;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAOxD;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CA6CD;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,CAgB3D;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,iBAAiB,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAsC/G"}
package/macos.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * macOS sandbox user management
3
+ *
4
+ * Creates and configures an unprivileged user for running OpenClaw
5
+ * in an isolated environment.
6
+ */
7
+ import type { SandboxUser, SandboxConfig, CreateUserResult, DirectoryStructure } from './types';
8
+ /**
9
+ * Check if a user exists
10
+ */
11
+ export declare function userExists(username: string): boolean;
12
+ /**
13
+ * Create the guarded shell script
14
+ */
15
+ export declare function createGuardedShell(): {
16
+ success: boolean;
17
+ error?: string;
18
+ };
19
+ /**
20
+ * Create the sandbox user on macOS
21
+ */
22
+ export declare function createSandboxUser(config?: Partial<SandboxConfig>): CreateUserResult;
23
+ /**
24
+ * Create the directory structure for the sandbox user
25
+ */
26
+ export declare function createDirectoryStructure(user: SandboxUser): {
27
+ success: boolean;
28
+ dirs?: DirectoryStructure;
29
+ error?: string;
30
+ };
31
+ /**
32
+ * Delete the sandbox user
33
+ *
34
+ * @param username - The username to delete
35
+ * @param options - Options for deletion
36
+ * @param options.removeHomeDir - Whether to remove the home directory (default: false)
37
+ */
38
+ export declare function deleteSandboxUser(username: string, options?: {
39
+ removeHomeDir?: boolean;
40
+ }): {
41
+ success: boolean;
42
+ error?: string;
43
+ };
44
+ //# sourceMappingURL=macos.d.ts.map
package/macos.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"macos.d.ts","sourceRoot":"","sources":["../src/macos.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAuBhG;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMpD;AAiBD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAsBzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,gBAAgB,CA6FvF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,GAAG;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAqCA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GACxC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAyCtC"}
package/migration.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * File migration utilities for OpenClaw isolation
3
+ *
4
+ * Handles moving OpenClaw installation files from the original
5
+ * user to the sandboxed user.
6
+ */
7
+ import type { SandboxUser, DirectoryStructure } from './types';
8
+ export interface MigrationSource {
9
+ /** Installation method: npm or git */
10
+ method: 'npm' | 'git';
11
+ /** Path to the package directory */
12
+ packagePath: string;
13
+ /** Path to the binary */
14
+ binaryPath?: string;
15
+ /** Path to the config directory */
16
+ configPath?: string;
17
+ /** Path to the git repo (for git installs) */
18
+ gitRepoPath?: string;
19
+ }
20
+ export interface MigrationResult {
21
+ success: boolean;
22
+ error?: string;
23
+ /** New paths after migration */
24
+ newPaths?: {
25
+ packagePath: string;
26
+ binaryPath: string;
27
+ configPath: string;
28
+ };
29
+ }
30
+ /**
31
+ * Migrate npm-based OpenClaw installation to sandbox user
32
+ */
33
+ export declare function migrateNpmInstall(source: MigrationSource, user: SandboxUser, dirs: DirectoryStructure): MigrationResult;
34
+ /**
35
+ * Migrate git-based OpenClaw installation to sandbox user
36
+ */
37
+ export declare function migrateGitInstall(source: MigrationSource, user: SandboxUser, dirs: DirectoryStructure): MigrationResult;
38
+ /**
39
+ * Migrate OpenClaw installation to sandbox user
40
+ */
41
+ export declare function migrateOpenClaw(source: MigrationSource, user: SandboxUser, dirs: DirectoryStructure): MigrationResult;
42
+ /**
43
+ * Create a Node.js wrapper in the sandbox user's bin directory
44
+ */
45
+ export declare function createNodeWrapper(user: SandboxUser, dirs: DirectoryStructure): {
46
+ success: boolean;
47
+ error?: string;
48
+ };
49
+ //# sourceMappingURL=migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names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enshield/sandbox",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "User isolation and sandboxing utilities for AgenShield",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "types": "./index.d.ts",
12
+ "import": "./index.js",
13
+ "default": "./index.js"
14
+ }
15
+ },
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "yaml": "^2.7.1"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^24.0.0",
22
+ "typescript": "^5.9.3"
23
+ }
24
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Custom Preset
3
+ *
4
+ * Preset for sandboxing arbitrary Node.js applications.
5
+ * Requires user to specify the entry point.
6
+ */
7
+ import type { TargetPreset } from './types.js';
8
+ /**
9
+ * Custom preset implementation
10
+ */
11
+ export declare const customPreset: TargetPreset;
12
+ //# sourceMappingURL=custom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/presets/custom.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,YAAY,CAAC;AAsBpB;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YA6F1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Dev Test Harness Preset
3
+ *
4
+ * Preset for detecting and migrating the AgenShield test harness (dummy-openclaw).
5
+ * Auto-detected in dev mode so the setup wizard works without workarounds.
6
+ */
7
+ import type { TargetPreset } from './types.js';
8
+ /**
9
+ * Dev test harness preset implementation
10
+ */
11
+ export declare const devHarnessPreset: TargetPreset;
12
+ //# sourceMappingURL=dev-harness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-harness.d.ts","sourceRoot":"","sources":["../../src/presets/dev-harness.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,YAAY,CAAC;AAmCpB;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAyK9B,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Preset System
3
+ *
4
+ * Provides a registry of target presets for AgenShield.
5
+ * Each preset defines how to detect, migrate, and run a specific application.
6
+ */
7
+ import type { TargetPreset, PresetDetectionResult } from './types.js';
8
+ export * from './types.js';
9
+ export { openclawPreset } from './openclaw.js';
10
+ export { devHarnessPreset } from './dev-harness.js';
11
+ export { customPreset } from './custom.js';
12
+ /**
13
+ * All available presets
14
+ * Order matters: openclaw is preferred over dev-harness when both exist.
15
+ * 'custom' is excluded from auto-detection by listAutoDetectablePresets().
16
+ */
17
+ export declare const PRESETS: Record<string, TargetPreset>;
18
+ /**
19
+ * Get preset by ID
20
+ *
21
+ * @param id - Preset identifier
22
+ * @returns The preset or undefined if not found
23
+ */
24
+ export declare function getPreset(id: string): TargetPreset | undefined;
25
+ /**
26
+ * List all available presets
27
+ *
28
+ * @returns Array of all presets
29
+ */
30
+ export declare function listPresets(): TargetPreset[];
31
+ /**
32
+ * List presets that can auto-detect (excludes 'custom')
33
+ *
34
+ * @returns Array of auto-detectable presets
35
+ */
36
+ export declare function listAutoDetectablePresets(): TargetPreset[];
37
+ /**
38
+ * Auto-detect which preset matches the current system
39
+ * Returns the first matching preset found.
40
+ *
41
+ * @returns Object with preset and detection result, or null if none found
42
+ */
43
+ export declare function autoDetectPreset(): Promise<{
44
+ preset: TargetPreset;
45
+ detection: PresetDetectionResult;
46
+ } | null>;
47
+ /**
48
+ * Format preset list for display
49
+ *
50
+ * @returns Formatted string showing available presets
51
+ */
52
+ export declare function formatPresetList(): string;
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAMtE,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAIhD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,YAAY,EAAE,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,YAAY,EAAE,CAE1D;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC;IAChD,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,qBAAqB,CAAC;CAClC,GAAG,IAAI,CAAC,CAQR;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CASzC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * OpenClaw Preset
3
+ *
4
+ * Preset for detecting and migrating OpenClaw AI coding agent installations.
5
+ * Supports both npm global and git clone installations.
6
+ */
7
+ import type { TargetPreset } from './types.js';
8
+ /**
9
+ * OpenClaw preset implementation
10
+ */
11
+ export declare const openclawPreset: TargetPreset;
12
+ //# sourceMappingURL=openclaw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw.d.ts","sourceRoot":"","sources":["../../src/presets/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EAIb,MAAM,YAAY,CAAC;AAKpB;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,YAmE5B,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Preset System Types
3
+ *
4
+ * A preset defines how to detect, migrate, and run a specific target application.
5
+ * The sandboxing (users, groups, seatbelt, wrappers) is universal for all targets.
6
+ */
7
+ import type { UserDefinition } from '@agenshield/ipc';
8
+ /**
9
+ * Result of detecting a target application
10
+ */
11
+ export interface PresetDetectionResult {
12
+ /** Whether the target was found */
13
+ found: boolean;
14
+ /** Installed version (if detected) */
15
+ version?: string;
16
+ /** Path to the main package/source directory */
17
+ packagePath?: string;
18
+ /** Path to the binary/entry point */
19
+ binaryPath?: string;
20
+ /** Path to the config directory */
21
+ configPath?: string;
22
+ /** How the target was installed */
23
+ method?: 'npm' | 'git' | 'binary' | 'custom';
24
+ }
25
+ /**
26
+ * Directory structure for migration
27
+ */
28
+ export interface MigrationDirectories {
29
+ /** Local binaries directory */
30
+ binDir: string;
31
+ /** Wrapper scripts directory */
32
+ wrappersDir: string;
33
+ /** Config directory */
34
+ configDir: string;
35
+ /** Package/source directory */
36
+ packageDir: string;
37
+ /** npm packages directory */
38
+ npmDir: string;
39
+ }
40
+ /**
41
+ * Context provided to preset migration
42
+ */
43
+ export interface MigrationContext {
44
+ /** Agent user definition */
45
+ agentUser: UserDefinition;
46
+ /** Directory structure for the sandbox */
47
+ directories: MigrationDirectories;
48
+ /** Entry point path (for custom preset) */
49
+ entryPoint?: string;
50
+ /** Detection result from the detect phase */
51
+ detection?: PresetDetectionResult;
52
+ }
53
+ /**
54
+ * Result of migrating a target to the sandbox
55
+ */
56
+ export interface PresetMigrationResult {
57
+ /** Whether migration succeeded */
58
+ success: boolean;
59
+ /** Error message if failed */
60
+ error?: string;
61
+ /** New paths after migration */
62
+ newPaths?: {
63
+ packagePath: string;
64
+ binaryPath: string;
65
+ configPath?: string;
66
+ };
67
+ }
68
+ /**
69
+ * A preset defines how to detect, migrate, and run a specific target application.
70
+ * The sandboxing (users, groups, seatbelt, wrappers) is universal.
71
+ */
72
+ export interface TargetPreset {
73
+ /** Unique preset identifier */
74
+ id: string;
75
+ /** Display name */
76
+ name: string;
77
+ /** Description shown in wizard */
78
+ description: string;
79
+ /**
80
+ * Commands this preset requires in the sandbox.
81
+ * These will be installed as protected wrappers in $HOME/bin.
82
+ * Names must match keys in WRAPPER_DEFINITIONS (e.g. 'node', 'npm', 'git', 'curl').
83
+ */
84
+ requiredBins: string[];
85
+ /**
86
+ * Optional commands the preset can use if available.
87
+ * Installed only when the user opts in or when the full wrapper set is requested.
88
+ */
89
+ optionalBins?: string[];
90
+ /**
91
+ * Detect if this target is installed on the system.
92
+ * Returns detection info or null if not found.
93
+ */
94
+ detect(): Promise<PresetDetectionResult | null>;
95
+ /**
96
+ * Migrate the target to the sandbox user.
97
+ * Copies files, sets permissions, creates entry wrapper.
98
+ */
99
+ migrate(context: MigrationContext): Promise<PresetMigrationResult>;
100
+ /**
101
+ * Get the command to run the target in the sandbox.
102
+ * This is what the wrapper scripts will invoke.
103
+ */
104
+ getEntryCommand(context: MigrationContext): string;
105
+ }
106
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/presets/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,WAAW,EAAE,MAAM,C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,38 @@
1
+ /**
2
+ * Restore utilities for AgenShield uninstall
3
+ *
4
+ * Restores the original OpenClaw installation from backup.
5
+ */
6
+ import type { InstallationBackup } from '@agenshield/ipc';
7
+ export type RestoreStep = 'validate' | 'stop-daemon' | 'stop-broker' | 'kill-processes' | 'restore-config' | 'restore-package' | 'delete-user' | 'remove-shell' | 'cleanup' | 'verify';
8
+ export interface RestoreProgress {
9
+ step: RestoreStep;
10
+ success: boolean;
11
+ message: string;
12
+ error?: string;
13
+ }
14
+ export interface RestoreResult {
15
+ success: boolean;
16
+ steps: RestoreProgress[];
17
+ error?: string;
18
+ }
19
+ /**
20
+ * Perform full restore/uninstall process
21
+ */
22
+ export declare function restoreInstallation(backup: InstallationBackup, onProgress?: (progress: RestoreProgress) => void): RestoreResult;
23
+ /**
24
+ * Check if uninstall is possible
25
+ */
26
+ export declare function canUninstall(): {
27
+ canUninstall: boolean;
28
+ isRoot: boolean;
29
+ hasBackup: boolean;
30
+ backup: InstallationBackup | null;
31
+ error?: string;
32
+ };
33
+ /**
34
+ * Force uninstall without a backup
35
+ * Used when no backup exists but user wants to clean up AgenShield artifacts
36
+ */
37
+ export declare function forceUninstall(onProgress?: (progress: RestoreProgress) => void): RestoreResult;
38
+ //# sourceMappingURL=restore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../src/restore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAmB1D,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,aAAa,GACb,aAAa,GACb,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAyWD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,kBAAkB,EAC1B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAC/C,aAAa,CA+Ef;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAC9B,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CA+BA;AAsCD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAC/C,aAAa,CA+Gf"}
package/seatbelt.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Seatbelt Profile Management
3
+ *
4
+ * Generates and installs macOS sandbox profiles.
5
+ */
6
+ /**
7
+ * Agent seatbelt profile template
8
+ */
9
+ export declare function generateAgentProfile(options: {
10
+ workspacePath: string;
11
+ socketPath: string;
12
+ agentHome?: string;
13
+ additionalReadPaths?: string[];
14
+ }): string;
15
+ /**
16
+ * Per-operation profile template
17
+ */
18
+ export declare function generateOperationProfile(operation: string, target?: string): string;
19
+ export interface ProfileResult {
20
+ success: boolean;
21
+ path: string;
22
+ message: string;
23
+ error?: Error;
24
+ }
25
+ /**
26
+ * Install seatbelt profiles
27
+ */
28
+ export declare function installProfiles(options: {
29
+ workspacePath: string;
30
+ socketPath: string;
31
+ }): Promise<ProfileResult[]>;
32
+ /**
33
+ * Verify seatbelt profile syntax
34
+ */
35
+ export declare function verifyProfile(profilePath: string): Promise<boolean>;
36
+ /**
37
+ * Install seatbelt profiles using UserConfig
38
+ *
39
+ * @param config - UserConfig with user/group information
40
+ * @param profiles - Generated profiles to install
41
+ */
42
+ export declare function installSeatbeltProfiles(config: import('@agenshield/ipc').UserConfig, profiles: {
43
+ agentProfile: string;
44
+ }): Promise<{
45
+ success: boolean;
46
+ error?: string;
47
+ agentProfilePath?: string;
48
+ operationProfilePaths?: string[];
49
+ }>;
50
+ /**
51
+ * Generate agent profile from UserConfig
52
+ */
53
+ export declare function generateAgentProfileFromConfig(config: import('@agenshield/ipc').UserConfig): string;
54
+ export { generateAgentProfileFromConfig as generateAgentProfile_v2 };
55
+ /**
56
+ * Get installed profiles
57
+ */
58
+ export declare function getInstalledProfiles(): Promise<string[]>;
59
+ //# sourceMappingURL=seatbelt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seatbelt.d.ts","sourceRoot":"","sources":["../src/seatbelt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC,GAAG,MAAM,CAuJT;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAaR;AA4DD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAuD3B;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBzE;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,OAAO,iBAAiB,EAAE,UAAU,EAC5C,QAAQ,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GACjC,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC,CAAC,CAyCD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,OAAO,iBAAiB,EAAE,UAAU,GAAG,MAAM,CAMnG;AAGD,OAAO,EAAE,8BAA8B,IAAI,uBAAuB,EAAE,CAAC;AAErE;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAuB9D"}
package/security.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Security status checks for the sandbox
3
+ */
4
+ /**
5
+ * Security status report
6
+ */
7
+ export interface SecurityStatus {
8
+ /** Is the current process running as root? (dangerous!) */
9
+ runningAsRoot: boolean;
10
+ /** Current user */
11
+ currentUser: string;
12
+ /** Is sandbox user created? */
13
+ sandboxUserExists: boolean;
14
+ /** Is OpenClaw isolated to sandbox user? */
15
+ isIsolated: boolean;
16
+ /** Is guarded shell installed? */
17
+ guardedShellInstalled: boolean;
18
+ /** Exposed secrets found in environment */
19
+ exposedSecrets: string[];
20
+ /** Security warnings */
21
+ warnings: string[];
22
+ /** Critical security issues */
23
+ critical: string[];
24
+ /** Recommendations */
25
+ recommendations: string[];
26
+ /** Overall security level */
27
+ level: 'secure' | 'partial' | 'unprotected' | 'critical';
28
+ }
29
+ /**
30
+ * Check if an environment variable name looks like a secret
31
+ */
32
+ export declare function isSecretEnvVar(name: string): boolean;
33
+ /**
34
+ * Options for security status checks
35
+ */
36
+ export interface SecurityCheckOptions {
37
+ /** Environment to scan for secrets (defaults to process.env) */
38
+ env?: Record<string, string | undefined>;
39
+ }
40
+ /**
41
+ * Check full security status
42
+ */
43
+ export declare function checkSecurityStatus(options?: SecurityCheckOptions): SecurityStatus;
44
+ //# sourceMappingURL=security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAC;IACpB,kCAAkC;IAClC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,2CAA2C;IAC3C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sBAAsB;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;CAC1D;AAuBD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AA2DD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,cAAc,CAwElF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shield-Exec: Single Node.js Command Proxy
3
+ *
4
+ * A unified command proxy installed at /opt/agenshield/bin/shield-exec.
5
+ * All command wrappers in $HOME/bin/ are symlinks to this binary.
6
+ * It detects the invoked command name via process.argv[1] (symlink name),
7
+ * then routes the request through the broker via Unix socket JSON-RPC.
8
+ *
9
+ * All commands are routed as `exec` operations through the broker,
10
+ * which handles policy enforcement (workspace boundaries, network policies, etc.).
11
+ */
12
+ /** Path where shield-exec is installed */
13
+ export declare const SHIELD_EXEC_PATH = "/opt/agenshield/bin/shield-exec";
14
+ /** Commands that shield-exec handles (all routed through broker as exec) */
15
+ export declare const PROXIED_COMMANDS: readonly ["curl", "wget", "git", "ssh", "scp", "rsync", "brew", "npm", "npx", "pip", "pip3", "open-url", "shieldctl", "agenco"];
16
+ /**
17
+ * The content of shield-exec as a string, for installation
18
+ */
19
+ export declare const SHIELD_EXEC_CONTENT = "#!/usr/bin/env node\n'use strict';\n\nconst path = require('path');\nconst net = require('net');\n\nconst DEFAULT_SOCKET_PATH = '/var/run/agenshield/agenshield.sock';\n\nfunction sendRequest(socketPath, request) {\n return new Promise((resolve, reject) => {\n const socket = net.createConnection(socketPath, () => {\n socket.write(JSON.stringify(request) + '\\n');\n });\n let data = '';\n socket.on('data', (chunk) => {\n data += chunk.toString();\n const idx = data.indexOf('\\n');\n if (idx >= 0) {\n try {\n const resp = JSON.parse(data.slice(0, idx));\n socket.end();\n resolve(resp);\n } catch (e) {\n socket.end();\n reject(new Error('Invalid JSON response: ' + e.message));\n }\n }\n });\n socket.on('error', (err) => reject(new Error('Socket error: ' + err.message)));\n socket.on('end', () => {\n if (data.trim()) {\n try { resolve(JSON.parse(data.trim())); }\n catch { reject(new Error('Connection closed before response')); }\n } else {\n reject(new Error('Connection closed without response'));\n }\n });\n socket.setTimeout(30000, () => {\n socket.destroy();\n reject(new Error('Request timed out'));\n });\n });\n}\n\nasync function main() {\n const socketPath = process.env.AGENSHIELD_SOCKET || DEFAULT_SOCKET_PATH;\n const invoked = path.basename(process.argv[1] || 'shield-exec');\n const args = process.argv.slice(2);\n const commandName = invoked === 'shield-exec' ? (args.shift() || '') : invoked;\n\n if (!commandName) {\n process.stderr.write('Usage: shield-exec <command> [args...]\\n');\n process.exit(1);\n }\n\n const request = {\n jsonrpc: '2.0',\n id: 'shield-exec-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8),\n method: 'exec',\n params: { command: commandName, args: args, cwd: process.cwd() },\n };\n\n try {\n const response = await sendRequest(socketPath, request);\n if (response.error) {\n process.stderr.write('Error: ' + response.error.message + '\\n');\n process.exit(1);\n }\n const result = response.result;\n if (!result) { process.stderr.write('Error: Empty response\\n'); process.exit(1); }\n if (!result.success) {\n process.stderr.write('Error: ' + (result.error?.message || 'Unknown error') + '\\n');\n process.exit(1);\n }\n const data = result.data;\n if (!data) process.exit(0);\n if (data.stdout) process.stdout.write(data.stdout);\n if (data.stderr) process.stderr.write(data.stderr);\n process.exit(data.exitCode ?? 0);\n } catch (err) {\n process.stderr.write('shield-exec error: ' + err.message + '\\n');\n process.exit(1);\n }\n}\n\nmain().catch((err) => { process.stderr.write('Fatal: ' + err.message + '\\n'); process.exit(1); });\n";
20
+ //# sourceMappingURL=shield-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shield-exec.d.ts","sourceRoot":"","sources":["../src/shield-exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,0CAA0C;AAC1C,eAAO,MAAM,gBAAgB,oCAAoC,CAAC;AAKlE,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,iIAInB,CAAC;AAsKX;;GAEG;AACH,eAAO,MAAM,mBAAmB,wzFAsF/B,CAAC"}