@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
package/backup.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Backup utilities for AgenShield installation
3
+ *
4
+ * Saves installation state before migration to enable safe uninstall.
5
+ * Backup is stored in /etc/agenshield/backup.json (root-owned, mode 600).
6
+ */
7
+ import type { InstallationBackup, OriginalInstallation, SandboxUserInfo, MigratedPaths } from '@agenshield/ipc';
8
+ export interface SaveBackupParams {
9
+ originalInstallation: OriginalInstallation;
10
+ sandboxUser: SandboxUserInfo;
11
+ migratedPaths: MigratedPaths;
12
+ }
13
+ /**
14
+ * Save installation backup before migration
15
+ */
16
+ export declare function saveBackup(params: SaveBackupParams): {
17
+ success: boolean;
18
+ error?: string;
19
+ };
20
+ /**
21
+ * Load installation backup
22
+ * Returns null if no backup exists or if read fails
23
+ */
24
+ export declare function loadBackup(): InstallationBackup | null;
25
+ /**
26
+ * Check if a backup exists
27
+ */
28
+ export declare function backupExists(): boolean;
29
+ /**
30
+ * Delete the backup file (called after successful uninstall)
31
+ */
32
+ export declare function deleteBackup(): {
33
+ success: boolean;
34
+ error?: string;
35
+ };
36
+ /**
37
+ * Rename the original config directory to a backup path
38
+ * Used during setup to preserve the original config
39
+ */
40
+ export declare function backupOriginalConfig(configPath: string): {
41
+ success: boolean;
42
+ backupPath?: string;
43
+ error?: string;
44
+ };
45
+ /**
46
+ * Restore the original config from backup
47
+ * Used during uninstall to restore the original config
48
+ */
49
+ export declare function restoreOriginalConfig(backupPath: string, targetPath: string): {
50
+ success: boolean;
51
+ error?: string;
52
+ };
53
+ //# sourceMappingURL=backup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../src/backup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACd,MAAM,iBAAiB,CAAC;AAyCzB,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,WAAW,EAAE,eAAe,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqDzF;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,kBAAkB,GAAG,IAAI,CAoBtD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAGtC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAGnE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAcA;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAoBA"}
package/detect.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * OpenClaw installation detector
3
+ *
4
+ * Detects existing OpenClaw installations (npm or git method)
5
+ * and gathers information needed for isolation.
6
+ *
7
+ * This module is in shield-sandbox so it can be reused by both
8
+ * the CLI wizard and the daemon for status checks.
9
+ */
10
+ export type InstallMethod = 'npm' | 'git' | 'unknown';
11
+ export interface OpenClawInstallation {
12
+ /** Whether OpenClaw is installed */
13
+ found: boolean;
14
+ /** Installation method */
15
+ method: InstallMethod;
16
+ /** Path to the main package/source directory */
17
+ packagePath?: string;
18
+ /** Path to the openclaw binary/wrapper */
19
+ binaryPath?: string;
20
+ /** Path to the config directory (~/.openclaw/) */
21
+ configPath?: string;
22
+ /** Installed version */
23
+ version?: string;
24
+ /** Path to the git repo (for git installs) */
25
+ gitRepoPath?: string;
26
+ }
27
+ export interface DetectionResult {
28
+ installation: OpenClawInstallation;
29
+ errors: string[];
30
+ warnings: string[];
31
+ }
32
+ export interface PrerequisitesResult {
33
+ ok: boolean;
34
+ missing: string[];
35
+ }
36
+ /**
37
+ * Detect OpenClaw installation
38
+ */
39
+ export declare function detectOpenClaw(): DetectionResult;
40
+ /**
41
+ * Check prerequisites for isolation
42
+ */
43
+ export declare function checkPrerequisites(): PrerequisitesResult;
44
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,0BAA0B;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,oBAAoB,CAAC;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AA8LD;;GAEG;AACH,wBAAgB,cAAc,IAAI,eAAe,CA2DhD;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,CAwBxD"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Directory Structure Management
3
+ *
4
+ * Creates and manages AgenShield directory structure.
5
+ * Supports dynamic configuration based on UserConfig.
6
+ */
7
+ import type { UserConfig, PathsConfig } from '@agenshield/ipc';
8
+ /**
9
+ * Directory definition with ownership and permissions
10
+ */
11
+ export interface DirectoryDefinition {
12
+ mode: number;
13
+ owner: string;
14
+ group: string;
15
+ }
16
+ /**
17
+ * Directory structure type
18
+ */
19
+ export interface DirectoryStructure {
20
+ system: Record<string, DirectoryDefinition>;
21
+ agent: Record<string, DirectoryDefinition>;
22
+ }
23
+ /**
24
+ * Create directory structure based on UserConfig
25
+ *
26
+ * @param config - Optional UserConfig, uses defaults if not provided
27
+ * @returns Directory structure with all paths and permissions
28
+ */
29
+ export declare function createDirectoryStructure(config?: UserConfig): DirectoryStructure;
30
+ /**
31
+ * Create paths configuration based on UserConfig
32
+ *
33
+ * @param config - Optional UserConfig, uses defaults if not provided
34
+ * @returns PathsConfig with all paths
35
+ */
36
+ export declare function createPathsConfig(config?: UserConfig): PathsConfig;
37
+ export interface DirectoryResult {
38
+ success: boolean;
39
+ path: string;
40
+ message: string;
41
+ error?: Error;
42
+ }
43
+ /**
44
+ * Verbose logging options
45
+ */
46
+ export interface VerboseOptions {
47
+ verbose?: boolean;
48
+ }
49
+ /**
50
+ * Create a directory with specific ownership and permissions
51
+ */
52
+ export declare function createDirectory(dirPath: string, options: {
53
+ mode: number;
54
+ owner: string;
55
+ group: string;
56
+ }, verboseOptions?: VerboseOptions): Promise<DirectoryResult>;
57
+ /**
58
+ * Create all system directories
59
+ *
60
+ * @param config - Optional UserConfig, uses defaults if not provided
61
+ * @param options - Optional verbose options
62
+ */
63
+ export declare function createSystemDirectories(config?: UserConfig, options?: VerboseOptions): Promise<DirectoryResult[]>;
64
+ /**
65
+ * Create all agent directories
66
+ *
67
+ * @param config - Optional UserConfig, uses defaults if not provided
68
+ * @param options - Optional verbose options
69
+ */
70
+ export declare function createAgentDirectories(config?: UserConfig, options?: VerboseOptions): Promise<DirectoryResult[]>;
71
+ /**
72
+ * Create all directories
73
+ *
74
+ * @param config - Optional UserConfig, uses defaults if not provided
75
+ * @param options - Optional verbose options
76
+ */
77
+ export declare function createAllDirectories(config?: UserConfig, options?: VerboseOptions): Promise<DirectoryResult[]>;
78
+ /**
79
+ * Verify directory structure
80
+ *
81
+ * @param config - Optional UserConfig, uses defaults if not provided
82
+ */
83
+ export declare function verifyDirectories(config?: UserConfig): Promise<{
84
+ valid: boolean;
85
+ missing: string[];
86
+ incorrect: Array<{
87
+ path: string;
88
+ issue: string;
89
+ }>;
90
+ }>;
91
+ /**
92
+ * Setup socket directory with correct permissions
93
+ *
94
+ * @param config - Optional UserConfig, uses defaults if not provided
95
+ */
96
+ export declare function setupSocketDirectory(config?: UserConfig): Promise<DirectoryResult>;
97
+ /**
98
+ * Get directory info
99
+ */
100
+ export declare function getDirectoryInfo(dirPath: string): Promise<{
101
+ exists: boolean;
102
+ mode?: string;
103
+ owner?: string;
104
+ group?: string;
105
+ } | null>;
106
+ /**
107
+ * Remove all directories (for uninstall/cleanup)
108
+ * WARNING: This is destructive!
109
+ *
110
+ * @param config - Optional UserConfig, uses defaults if not provided
111
+ */
112
+ export declare function removeAllDirectories(config?: UserConfig): Promise<DirectoryResult[]>;
113
+ //# sourceMappingURL=directories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directories.d.ts","sourceRoot":"","sources":["../src/directories.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,WAA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e,EAAE,CAAC,CAUtH;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAKpH;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IACpE,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD,CAAC,CA8DD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAyBxF;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,IAAI,CAAC,CAcR;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA2C1F"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Binary Scanner
3
+ *
4
+ * Scans system directories, PATH, npm/yarn globals, agent bins, and workspace
5
+ * bins to discover all executables, classifying them by source, execution
6
+ * context, and protection status.
7
+ */
8
+ import type { BinarySourceKind, ExecutionContext, ProtectionKind, DiscoveredBinary, BinaryDirectory, DiscoveryOptions } from '@agenshield/ipc';
9
+ /**
10
+ * Detect the npm global bin directory
11
+ */
12
+ export declare function detectNpmGlobalBin(): string | null;
13
+ /**
14
+ * Detect the yarn global bin directory
15
+ */
16
+ export declare function detectYarnGlobalBin(): string | null;
17
+ /**
18
+ * Classify a directory into a BinarySourceKind
19
+ */
20
+ export declare function classifyDirectory(dirPath: string, npmGlobalBin: string | null, yarnGlobalBin: string | null, options: DiscoveryOptions): BinarySourceKind;
21
+ /**
22
+ * Determine execution contexts for a directory
23
+ */
24
+ export declare function getContextsForDir(dirPath: string, sourceKind: BinarySourceKind, _options: DiscoveryOptions): ExecutionContext[];
25
+ /**
26
+ * Determine the protection status of a binary by name
27
+ */
28
+ export declare function getProtection(name: string): ProtectionKind;
29
+ /**
30
+ * Check if a file is a symlink pointing to shield-exec
31
+ */
32
+ export declare function isShieldExecLink(filePath: string): boolean;
33
+ /**
34
+ * Categorize a binary by name
35
+ */
36
+ export declare function categorize(name: string): DiscoveredBinary['category'];
37
+ /**
38
+ * Scan all binary directories and return discovered binaries and directory metadata
39
+ */
40
+ export declare function scanBinaries(options: DiscoveryOptions): {
41
+ binaries: DiscoveredBinary[];
42
+ directories: BinaryDirectory[];
43
+ };
44
+ //# sourceMappingURL=binary-scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-scanner.d.ts","sourceRoot":"","sources":["../../src/discovery/binary-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAgDzB;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAclD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAWnD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,CAgClB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,gBAAgB,EAC5B,QAAQ,EAAE,gBAAgB,GACzB,gBAAgB,EAAE,CAcpB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAK1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAO1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAErE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG;IACvD,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAsGA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Discovery module — binary and skill scanning
3
+ */
4
+ export { scanDiscovery } from './scanner';
5
+ export { scanBinaries, classifyDirectory, detectNpmGlobalBin, detectYarnGlobalBin, getProtection, isShieldExecLink, categorize, } from './binary-scanner';
6
+ export { scanSkills, parseSkillMd, extractCommands, extractSkillInfo, getApprovalStatus, } from './skill-scanner';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Discovery Orchestrator
3
+ *
4
+ * Top-level scan that combines binary scanning, skill scanning,
5
+ * and computes a summary of the system state.
6
+ */
7
+ import type { DiscoveryOptions, DiscoveryResult } from '@agenshield/ipc';
8
+ /**
9
+ * Run a full discovery scan: binaries, skills, and summary
10
+ */
11
+ export declare function scanDiscovery(options: DiscoveryOptions): DiscoveryResult;
12
+ //# sourceMappingURL=scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/discovery/scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAQhB,MAAM,iBAAiB,CAAC;AA4CzB;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAuBxE"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Skill Scanner
3
+ *
4
+ * Scans the OpenClaw skills directory, parses SKILL.md frontmatter,
5
+ * extracts command requirements, and cross-references with discovered binaries.
6
+ */
7
+ import type { SkillMetadata, SkillExtractedInfo, DiscoveredSkill, SkillCommandRequirement, DiscoveredBinary, DiscoveryOptions } from '@agenshield/ipc';
8
+ /**
9
+ * Extract structured info (API keys, bins, config options, install steps) from skill metadata
10
+ */
11
+ export declare function extractSkillInfo(metadata: SkillMetadata | null): SkillExtractedInfo;
12
+ /**
13
+ * Parse SKILL.md content, extracting YAML frontmatter and body
14
+ */
15
+ export declare function parseSkillMd(content: string): {
16
+ metadata: SkillMetadata;
17
+ body: string;
18
+ } | null;
19
+ /**
20
+ * Extract command requirements from metadata and content body
21
+ */
22
+ export declare function extractCommands(metadata: SkillMetadata | null, body: string, binaryLookup: Map<string, DiscoveredBinary>): SkillCommandRequirement[];
23
+ /**
24
+ * Get the approval status of a skill
25
+ */
26
+ export declare function getApprovalStatus(skillName: string): 'approved' | 'quarantined' | 'unknown';
27
+ /**
28
+ * Scan the skills directory and return discovered skills
29
+ */
30
+ export declare function scanSkills(options: DiscoveryOptions, binaryLookup: Map<string, DiscoveredBinary>): DiscoveredSkill[];
31
+ //# sourceMappingURL=skill-scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-scanner.d.ts","sourceRoot":"","sources":["../../src/discovery/skill-scanner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAkCzB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,kBAAkB,CAUnF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkB9F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,aAAa,GAAG,IAAI,EAC9B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC1C,uBAAuB,EAAE,CAiE3B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAChB,UAAU,GAAG,aAAa,GAAG,SAAS,CAyBxC;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC1C,eAAe,EAAE,CAiGnB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Hardened guarded-shell for zsh (ZDOTDIR approach)
3
+ *
4
+ * The guarded-shell is a minimal launcher that sets ZDOTDIR to a root-owned
5
+ * config directory, then execs /bin/zsh. The actual restrictions live in
6
+ * .zshenv and .zshrc inside that ZDOTDIR, which zsh reads on startup.
7
+ *
8
+ * This avoids the previous bug where `exec /bin/zsh -f` discarded all
9
+ * shell-level restrictions (RESTRICTED, preexec hooks, disabled builtins)
10
+ * and macOS /etc/zshenv restored the full system PATH via path_helper.
11
+ *
12
+ * ZDOTDIR approach guarantees:
13
+ * - .zshenv runs AFTER /etc/zshenv, so we override path_helper's PATH
14
+ * - .zshrc applies RESTRICTED mode, hooks, and builtin lockdown
15
+ * - Both files are root-owned (0644) so the agent cannot modify them
16
+ */
17
+ export declare const GUARDED_SHELL_PATH = "/usr/local/bin/guarded-shell";
18
+ export declare const ZDOT_DIR = "/etc/agenshield/zdot";
19
+ /**
20
+ * Guarded shell launcher — minimal, just sets ZDOTDIR and execs zsh.
21
+ * Restrictions are applied by ZDOT_ZSHENV_CONTENT and ZDOT_ZSHRC_CONTENT.
22
+ */
23
+ export declare const GUARDED_SHELL_CONTENT = "#!/bin/zsh\n# guarded-shell: launcher for restricted agent shell.\n# All restrictions live in ZDOTDIR files (root-owned, immutable to agent).\nemulate -LR zsh\n\n# Prevent inherited env tricks before handing off to zsh\nunset HOME\nunset DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH DYLD_INSERT_LIBRARIES\nunset PYTHONPATH NODE_PATH RUBYLIB PERL5LIB\nunset SSH_ASKPASS LD_PRELOAD\n\n# Point zsh at our restricted config directory\nexport ZDOTDIR=\"/etc/agenshield/zdot\"\n\n# Start zsh \u2014 it will read ZDOTDIR/.zshenv then ZDOTDIR/.zshrc\nexec /bin/zsh\n";
24
+ /**
25
+ * ZDOTDIR .zshenv — runs after /etc/zshenv (which calls path_helper on macOS).
26
+ * Overrides PATH to only include $HOME/bin.
27
+ */
28
+ export declare const ZDOT_ZSHENV_CONTENT = "# AgenShield restricted .zshenv\n# Runs AFTER /etc/zshenv \u2014 overrides path_helper's full system PATH.\n\n# ALWAYS set HOME based on actual user, never inherit\nexport HOME=\"/Users/$(id -un)\"\nexport PATH=\"$HOME/bin\"\nexport SHELL=\"/usr/local/bin/guarded-shell\"\n\n# Clear any leftover env tricks\nunset DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH DYLD_INSERT_LIBRARIES\nunset PYTHONPATH NODE_PATH RUBYLIB PERL5LIB\nunset SSH_ASKPASS LD_PRELOAD\n";
29
+ /**
30
+ * ZDOTDIR .zshrc — interactive shell restrictions.
31
+ * Applies RESTRICTED mode, locks variables, disables builtins, installs hooks.
32
+ */
33
+ export declare const ZDOT_ZSHRC_CONTENT = "# AgenShield restricted .zshrc\n# Applied to every interactive shell for the agent user.\n\nemulate -LR zsh\n\n# ---- Shell options ----\n# Note: NOT using setopt RESTRICTED as it disables cd entirely.\n# Instead we use preexec hooks and builtin disable for enforcement.\nsetopt NO_CASE_GLOB\nsetopt NO_BEEP\n\n# ---- Lock critical variables (readonly) ----\ntypeset -r PATH HOME SHELL\n\n# ---- Enforcement helpers ----\ndeny() {\n print -r -- \"Denied by policy\"\n return 126\n}\n\nis_allowed_cmd() {\n local cmd=\"$1\"\n\n # Allow shell builtins we explicitly permit\n case \"\\$cmd\" in\n cd|pwd|echo|printf|test|true|false|exit|return|break|continue|shift|set|unset|export|typeset|local|declare|readonly|let|read|print|pushd|popd|dirs|jobs|fg|bg|kill|wait|times|ulimit|umask|history|fc|type|whence|which|where|rehash)\n return 0\n ;;\n esac\n\n # Deny path execution outright\n [[ \"$cmd\" == */* ]] && return 1\n\n # Resolve command path\n local resolved\n resolved=\"\\$(whence -p -- \"\\$cmd\" 2>/dev/null)\" || return 1\n\n # Must live under HOME/bin exactly\n [[ \"\\$resolved\" == \"$HOME/bin/\"* ]] && return 0\n return 1\n}\n\n# ---- Block dangerous builtins ----\ndisable -r builtin command exec eval hash nohup setopt source unfunction functions alias unalias 2>/dev/null || true\n\n# ---- Intercept every interactive command before execution ----\npreexec() {\n local line=\"$1\"\n local cmd=\"${line%%[[:space:]]*}\"\n\n # Empty / whitespace lines\n [[ -z \"\\$cmd\" ]] && return 0\n\n # Deny anything with slash in the command token (direct path execution)\n [[ \"\\$cmd\" == */* ]] && { print -r -- \"Denied: direct path execution\"; kill -KILL $$; }\n\n # Deny anything not allowed\n if ! is_allowed_cmd \"\\$cmd\"; then\n print -r -- \"Denied: \\$cmd (not in \\$HOME/bin)\"\n kill -KILL $$\n fi\n}\n\n# ---- Also intercept non-interactive \\`zsh -c\\` cases ----\nTRAPDEBUG() {\n local line=\"${ZSH_DEBUG_CMD:-$1}\"\n local cmd=\"${line%%[[:space:]]*}\"\n [[ -z \"\\$cmd\" ]] && return 0\n\n [[ \"\\$cmd\" == */* ]] && { print -r -- \"Denied: direct path execution\"; return 126; }\n is_allowed_cmd \"\\$cmd\" || { print -r -- \"Denied: \\$cmd\"; return 126; }\n return 0\n}\n\n# ---- Ensure accessible working directory ----\ncd \"$HOME\" 2>/dev/null || cd /\n";
34
+ //# sourceMappingURL=guarded-shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guarded-shell.d.ts","sourceRoot":"","sources":["../src/guarded-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,kBAAkB,iCAAiC,CAAC;AACjE,eAAO,MAAM,QAAQ,yBAAyB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mjBAgBjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,8cAY/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gyEA4E9B,CAAC"}
package/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * AgenShield Sandbox Library
3
+ *
4
+ * User isolation and sandboxing utilities for OpenClaw.
5
+ * Handles creation of restricted users, guarded shells,
6
+ * and directory structures for sandboxed execution.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ export type { SandboxUser, SandboxConfig, CreateUserResult, DirectoryStructure as SandboxDirectoryStructure } from './types';
11
+ export * from './guarded-shell';
12
+ export { createGuardedShell, createSandboxUser, deleteSandboxUser, } from './macos';
13
+ export { createUserConfig, createGroups, createGroup, createUser, createAgentUser, createBrokerUser, createUsers, createAllUsersAndGroups, deleteGroup, deleteUser, deleteGroups, deleteUsers, deleteAllUsersAndGroups, groupExists, userExists, getUserInfo, getGroupInfo, verifyUsersAndGroups, DEFAULT_BASE_UID, DEFAULT_BASE_GID, DEFAULT_BASE_NAME, ASH_PREFIX, type CreateResult, } from './users';
14
+ export { createDirectoryStructure, createPathsConfig, createDirectory, createSystemDirectories, createAgentDirectories, createAllDirectories, verifyDirectories, setupSocketDirectory, getDirectoryInfo, removeAllDirectories, type DirectoryDefinition, type DirectoryStructure, type DirectoryResult, } from './directories';
15
+ export * from './migration';
16
+ export * from './security';
17
+ export * from './detect';
18
+ export * from './backup';
19
+ export * from './restore';
20
+ export { SHIELD_EXEC_CONTENT, SHIELD_EXEC_PATH, PROXIED_COMMANDS, } from './shield-exec';
21
+ export { WRAPPERS, WRAPPER_DEFINITIONS, installWrapper, installWrappers, installSpecificWrappers, installWrapperWithSudo, uninstallWrapper, uninstallWrappers, verifyWrappers, installGuardedShell, installAllWrappers, installShieldExec, deployInterceptor, copyNodeBinary, copyBrokerBinary, installPresetBinaries, installBasicCommands, BASIC_SYSTEM_COMMANDS, type PresetInstallResult, getAvailableWrappers, getWrapperDefinition, generateWrapperContent, getDefaultWrapperConfig, wrapperUsesSeatbelt, wrapperUsesInterceptor, addDynamicWrapper, removeDynamicWrapper, updateWrapper, type WrapperResult, type WrapperDefinition, type WrapperConfig, } from './wrappers';
22
+ export { generateAgentProfile, generateOperationProfile, installProfiles, installSeatbeltProfiles, verifyProfile, getInstalledProfiles, type ProfileResult, } from './seatbelt';
23
+ export { generateBrokerPlist, generateBrokerPlistLegacy, installLaunchDaemon, loadLaunchDaemon, unloadLaunchDaemon, uninstallLaunchDaemon, isDaemonRunning, getDaemonStatus, restartDaemon, fixSocketPermissions, type DaemonResult, } from './launchdaemon';
24
+ export { getPreset, listPresets, listAutoDetectablePresets, autoDetectPreset, formatPresetList, openclawPreset, devHarnessPreset, customPreset, PRESETS, type TargetPreset, type PresetDetectionResult, type MigrationContext, type MigrationDirectories, type PresetMigrationResult, } from './presets';
25
+ export { scanDiscovery, scanBinaries, scanSkills, parseSkillMd, extractSkillInfo, classifyDirectory, } from './discovery';
26
+ export { injectAgenCoSkill, createAgenCoSymlink, removeInjectedSkills, updateOpenClawMcpConfig, getSkillsDir, getAgenCoSkillPath, type SkillInjectionResult, } from './skill-injector';
27
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,IAAI,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAG7H,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,uBAAuB,EACvB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AAGvB,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cA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