@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.
- package/backup.d.ts +53 -0
- package/backup.d.ts.map +1 -0
- package/detect.d.ts +44 -0
- package/detect.d.ts.map +1 -0
- package/directories.d.ts +113 -0
- package/directories.d.ts.map +1 -0
- package/discovery/binary-scanner.d.ts +44 -0
- package/discovery/binary-scanner.d.ts.map +1 -0
- package/discovery/index.d.ts +7 -0
- package/discovery/index.d.ts.map +1 -0
- package/discovery/scanner.d.ts +12 -0
- package/discovery/scanner.d.ts.map +1 -0
- package/discovery/skill-scanner.d.ts +31 -0
- package/discovery/skill-scanner.d.ts.map +1 -0
- package/guarded-shell.d.ts +34 -0
- package/guarded-shell.d.ts.map +1 -0
- package/index.d.ts +27 -0
- package/index.d.ts.map +1 -0
- package/index.js +6155 -0
- package/launchdaemon.d.ts +76 -0
- package/launchdaemon.d.ts.map +1 -0
- package/macos.d.ts +44 -0
- package/macos.d.ts.map +1 -0
- package/migration.d.ts +49 -0
- package/migration.d.ts.map +1 -0
- package/package.json +24 -0
- package/presets/custom.d.ts +12 -0
- package/presets/custom.d.ts.map +1 -0
- package/presets/dev-harness.d.ts +12 -0
- package/presets/dev-harness.d.ts.map +1 -0
- package/presets/index.d.ts +53 -0
- package/presets/index.d.ts.map +1 -0
- package/presets/openclaw.d.ts +12 -0
- package/presets/openclaw.d.ts.map +1 -0
- package/presets/types.d.ts +106 -0
- package/presets/types.d.ts.map +1 -0
- package/restore.d.ts +38 -0
- package/restore.d.ts.map +1 -0
- package/seatbelt.d.ts +59 -0
- package/seatbelt.d.ts.map +1 -0
- package/security.d.ts +44 -0
- package/security.d.ts.map +1 -0
- package/shield-exec.d.ts +20 -0
- package/shield-exec.d.ts.map +1 -0
- package/skill-injector.d.ts +48 -0
- package/skill-injector.d.ts.map +1 -0
- package/types.d.ts +38 -0
- package/types.d.ts.map +1 -0
- package/users.d.ts +169 -0
- package/users.d.ts.map +1 -0
- package/wrappers.d.ts +217 -0
- package/wrappers.d.ts.map +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Injector
|
|
3
|
+
*
|
|
4
|
+
* Injects security-related skills into OpenClaw's skills directory
|
|
5
|
+
* when AgenShield is set up. This ensures critical security skills
|
|
6
|
+
* are always available to the sandboxed agent.
|
|
7
|
+
*/
|
|
8
|
+
import type { UserConfig } from '@agenshield/ipc';
|
|
9
|
+
export interface SkillInjectionResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
skillsDir: string;
|
|
12
|
+
injectedSkills: string[];
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the OpenClaw skills directory for a user
|
|
17
|
+
*/
|
|
18
|
+
export declare function getSkillsDir(homeDir: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the path to the bundled AgenCo skill
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAgenCoSkillPath(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Inject the AgenCo skill into OpenClaw's skills directory
|
|
25
|
+
*/
|
|
26
|
+
export declare function injectAgenCoSkill(config: UserConfig): Promise<SkillInjectionResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a symlink for the agenco command in the agent's bin directory
|
|
29
|
+
*/
|
|
30
|
+
export declare function createAgenCoSymlink(config: UserConfig, binDir: string): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
error?: string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Remove injected skills (for uninstall)
|
|
36
|
+
*/
|
|
37
|
+
export declare function removeInjectedSkills(homeDir: string): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Update OpenClaw's MCP configuration to include AgenCo
|
|
43
|
+
*/
|
|
44
|
+
export declare function updateOpenClawMcpConfig(homeDir: string): Promise<{
|
|
45
|
+
success: boolean;
|
|
46
|
+
error?: string;
|
|
47
|
+
}>;
|
|
48
|
+
//# sourceMappingURL=skill-injector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-injector.d.ts","sourceRoot":"","sources":["../src/skill-injector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAepD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAmB3C;AA4BD;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,oBAAoB,CAAC,CA2D/B;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA8B/C;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB/C;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAiE/C"}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for sandbox user management
|
|
3
|
+
*/
|
|
4
|
+
export interface SandboxUser {
|
|
5
|
+
username: string;
|
|
6
|
+
uid: number;
|
|
7
|
+
gid: number;
|
|
8
|
+
homeDir: string;
|
|
9
|
+
shell: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SandboxConfig {
|
|
12
|
+
/** Username for the sandbox user */
|
|
13
|
+
username: string;
|
|
14
|
+
/** Home directory path */
|
|
15
|
+
homeDir: string;
|
|
16
|
+
/** Shell to use (should be restricted) */
|
|
17
|
+
shell: string;
|
|
18
|
+
/** Real name for the user */
|
|
19
|
+
realName: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateUserResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
user?: SandboxUser;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DirectoryStructure {
|
|
27
|
+
/** Local binaries */
|
|
28
|
+
binDir: string;
|
|
29
|
+
/** Wrapper scripts for broker */
|
|
30
|
+
wrappersDir: string;
|
|
31
|
+
/** OpenClaw config */
|
|
32
|
+
configDir: string;
|
|
33
|
+
/** OpenClaw package */
|
|
34
|
+
packageDir: string;
|
|
35
|
+
/** npm global packages */
|
|
36
|
+
npmDir: string;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
package/types.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/users.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User and Group Management
|
|
3
|
+
*
|
|
4
|
+
* Creates and manages AgenShield users and groups on macOS.
|
|
5
|
+
* Supports dynamic configuration with optional prefix for testing/multiple instances.
|
|
6
|
+
*/
|
|
7
|
+
import type { UserConfig, UserDefinition } from '@agenshield/ipc';
|
|
8
|
+
/**
|
|
9
|
+
* Default base UIDs/GIDs
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_BASE_UID = 5200;
|
|
12
|
+
export declare const DEFAULT_BASE_GID = 5100;
|
|
13
|
+
/**
|
|
14
|
+
* Default base name for users/groups (the part after ash_ prefix)
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_BASE_NAME = "default";
|
|
17
|
+
/**
|
|
18
|
+
* Required prefix for all AgenShield users/groups
|
|
19
|
+
*/
|
|
20
|
+
export declare const ASH_PREFIX = "ash_";
|
|
21
|
+
/**
|
|
22
|
+
* Create user configuration with optional prefix, base IDs, and base name
|
|
23
|
+
*
|
|
24
|
+
* @param options - Configuration options
|
|
25
|
+
* @param options.prefix - Optional additional prefix for all names (for testing multiple instances)
|
|
26
|
+
* @param options.baseUid - Base UID for users (default: 5200)
|
|
27
|
+
* @param options.baseGid - Base GID for groups (default: 5100)
|
|
28
|
+
* @param options.baseName - Base name for users/groups (default: 'default')
|
|
29
|
+
* @returns Complete UserConfig object
|
|
30
|
+
*
|
|
31
|
+
* Naming pattern: ash_{baseName}_{role} (or {prefix}_ash_{baseName}_{role} with prefix)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Default configuration
|
|
35
|
+
* const config = createUserConfig();
|
|
36
|
+
* // config.agentUser.username === 'ash_default_agent'
|
|
37
|
+
* // config.groups.socket.name === 'ash_default'
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // With custom base name
|
|
41
|
+
* const customConfig = createUserConfig({ baseName: 'myapp' });
|
|
42
|
+
* // customConfig.agentUser.username === 'ash_myapp_agent'
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // With prefix for testing multiple instances
|
|
46
|
+
* const testConfig = createUserConfig({ prefix: 'test1', baseName: 'myapp' });
|
|
47
|
+
* // testConfig.agentUser.username === 'test1_ash_myapp_agent'
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // With custom UIDs
|
|
51
|
+
* const customConfig = createUserConfig({ baseName: 'ci', baseUid: 6200, baseGid: 6100 });
|
|
52
|
+
*/
|
|
53
|
+
export declare function createUserConfig(options?: {
|
|
54
|
+
prefix?: string;
|
|
55
|
+
baseUid?: number;
|
|
56
|
+
baseGid?: number;
|
|
57
|
+
baseName?: string;
|
|
58
|
+
}): UserConfig;
|
|
59
|
+
export interface CreateResult {
|
|
60
|
+
success: boolean;
|
|
61
|
+
message: string;
|
|
62
|
+
error?: Error;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if a group exists
|
|
66
|
+
*/
|
|
67
|
+
export declare function groupExists(name: string): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a user exists
|
|
70
|
+
*/
|
|
71
|
+
export declare function userExists(username: string): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Verbose logging options
|
|
74
|
+
*/
|
|
75
|
+
export interface VerboseOptions {
|
|
76
|
+
verbose?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a group
|
|
80
|
+
*/
|
|
81
|
+
export declare function createGroup(name: string, gid: number, description?: string, options?: VerboseOptions): Promise<CreateResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Create all required groups from config
|
|
84
|
+
*
|
|
85
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
86
|
+
* @param options - Optional verbose options
|
|
87
|
+
*/
|
|
88
|
+
export declare function createGroups(config?: UserConfig, options?: VerboseOptions): Promise<CreateResult[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a user from UserDefinition
|
|
91
|
+
*/
|
|
92
|
+
export declare function createUser(userDef: UserDefinition, options?: VerboseOptions): Promise<CreateResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Create the agent user
|
|
95
|
+
*
|
|
96
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
97
|
+
* @param options - Optional verbose options
|
|
98
|
+
*/
|
|
99
|
+
export declare function createAgentUser(config?: UserConfig, options?: VerboseOptions): Promise<CreateResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Create the broker user
|
|
102
|
+
*
|
|
103
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
104
|
+
* @param options - Optional verbose options
|
|
105
|
+
*/
|
|
106
|
+
export declare function createBrokerUser(config?: UserConfig, options?: VerboseOptions): Promise<CreateResult>;
|
|
107
|
+
/**
|
|
108
|
+
* Create all required users
|
|
109
|
+
*
|
|
110
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
111
|
+
*/
|
|
112
|
+
export declare function createUsers(config?: UserConfig): Promise<CreateResult[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Create all groups and users
|
|
115
|
+
*
|
|
116
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
117
|
+
*/
|
|
118
|
+
export declare function createAllUsersAndGroups(config?: UserConfig): Promise<{
|
|
119
|
+
groups: CreateResult[];
|
|
120
|
+
users: CreateResult[];
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Delete a group
|
|
124
|
+
*/
|
|
125
|
+
export declare function deleteGroup(name: string): Promise<CreateResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Delete a user
|
|
128
|
+
*/
|
|
129
|
+
export declare function deleteUser(username: string): Promise<CreateResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Delete all groups from config
|
|
132
|
+
*
|
|
133
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
134
|
+
*/
|
|
135
|
+
export declare function deleteGroups(config?: UserConfig): Promise<CreateResult[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Delete all users from config
|
|
138
|
+
*
|
|
139
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
140
|
+
*/
|
|
141
|
+
export declare function deleteUsers(config?: UserConfig): Promise<CreateResult[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Delete all users and groups (for uninstall/cleanup)
|
|
144
|
+
*
|
|
145
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
146
|
+
*/
|
|
147
|
+
export declare function deleteAllUsersAndGroups(config?: UserConfig): Promise<{
|
|
148
|
+
users: CreateResult[];
|
|
149
|
+
groups: CreateResult[];
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Get user info
|
|
153
|
+
*/
|
|
154
|
+
export declare function getUserInfo(username: string): Promise<Record<string, string> | null>;
|
|
155
|
+
/**
|
|
156
|
+
* Get group info
|
|
157
|
+
*/
|
|
158
|
+
export declare function getGroupInfo(name: string): Promise<Record<string, string> | null>;
|
|
159
|
+
/**
|
|
160
|
+
* Verify that all required users and groups exist
|
|
161
|
+
*
|
|
162
|
+
* @param config - Optional UserConfig, uses defaults if not provided
|
|
163
|
+
*/
|
|
164
|
+
export declare function verifyUsersAndGroups(config?: UserConfig): Promise<{
|
|
165
|
+
valid: boolean;
|
|
166
|
+
missingGroups: string[];
|
|
167
|
+
missingUsers: string[];
|
|
168
|
+
}>;
|
|
169
|
+
//# sourceMappingURL=users.d.ts.map
|
package/users.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AAInF;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,UAAU,CAoDb;AAOD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOhE;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;G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AAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAQ/E;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAQ9E;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC1E,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB,CAAC,CAKD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAkB1F;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAkBvF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IACvE,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC,CA0BD"}
|
package/wrappers.d.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper Scripts Installation
|
|
3
|
+
*
|
|
4
|
+
* Installs command wrappers that route operations through the broker.
|
|
5
|
+
* Supports dynamic wrapper management based on policy configuration.
|
|
6
|
+
*/
|
|
7
|
+
import type { UserConfig } from '@agenshield/ipc';
|
|
8
|
+
/**
|
|
9
|
+
* Wrapper definition interface
|
|
10
|
+
*/
|
|
11
|
+
export interface WrapperDefinition {
|
|
12
|
+
description: string;
|
|
13
|
+
/** Whether this wrapper requires seatbelt profile */
|
|
14
|
+
usesSeatbelt?: boolean;
|
|
15
|
+
/** Whether this wrapper uses Node.js interceptor */
|
|
16
|
+
usesInterceptor?: boolean;
|
|
17
|
+
/** The content generator function */
|
|
18
|
+
generate: (config: WrapperConfig) => string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for wrapper generation
|
|
22
|
+
*/
|
|
23
|
+
export interface WrapperConfig {
|
|
24
|
+
/** Agent home directory */
|
|
25
|
+
agentHome: string;
|
|
26
|
+
/** Agent username */
|
|
27
|
+
agentUsername: string;
|
|
28
|
+
/** Socket path */
|
|
29
|
+
socketPath: string;
|
|
30
|
+
/** HTTP fallback port */
|
|
31
|
+
httpPort: number;
|
|
32
|
+
/** Path to interceptor module */
|
|
33
|
+
interceptorPath: string;
|
|
34
|
+
/** NODE_OPTIONS flag: '--require' for CJS or '--import' for ESM */
|
|
35
|
+
interceptorFlag: string;
|
|
36
|
+
/** Path to seatbelt profiles */
|
|
37
|
+
seatbeltDir: string;
|
|
38
|
+
/** Path to Python executable */
|
|
39
|
+
pythonPath: string;
|
|
40
|
+
/** Path to Node.js executable */
|
|
41
|
+
nodePath: string;
|
|
42
|
+
/** Path to npm executable */
|
|
43
|
+
npmPath: string;
|
|
44
|
+
/** Path to brew executable */
|
|
45
|
+
brewPath: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Default wrapper configuration
|
|
49
|
+
*/
|
|
50
|
+
export declare function getDefaultWrapperConfig(userConfig?: UserConfig): WrapperConfig;
|
|
51
|
+
/**
|
|
52
|
+
* Wrapper definitions with dynamic content generation
|
|
53
|
+
*/
|
|
54
|
+
export declare const WRAPPER_DEFINITIONS: Record<string, WrapperDefinition>;
|
|
55
|
+
/**
|
|
56
|
+
* Legacy static WRAPPERS export for backward compatibility
|
|
57
|
+
*/
|
|
58
|
+
export declare const WRAPPERS: Record<string, {
|
|
59
|
+
description: string;
|
|
60
|
+
content: string;
|
|
61
|
+
}>;
|
|
62
|
+
export interface WrapperResult {
|
|
63
|
+
success: boolean;
|
|
64
|
+
name: string;
|
|
65
|
+
path: string;
|
|
66
|
+
message: string;
|
|
67
|
+
error?: Error;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generate wrapper content from definition
|
|
71
|
+
*/
|
|
72
|
+
export declare function generateWrapperContent(name: string, config?: WrapperConfig): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Install a single wrapper
|
|
75
|
+
*/
|
|
76
|
+
export declare function installWrapper(name: string, content: string, targetDir: string): Promise<WrapperResult>;
|
|
77
|
+
/**
|
|
78
|
+
* Install a wrapper with sudo (for system directories)
|
|
79
|
+
*/
|
|
80
|
+
export declare function installWrapperWithSudo(name: string, content: string, targetDir: string, owner?: string, group?: string): Promise<WrapperResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Install all wrappers
|
|
83
|
+
*/
|
|
84
|
+
export declare function installWrappers(targetDir?: string, config?: WrapperConfig): Promise<WrapperResult[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Install specific wrappers by name
|
|
87
|
+
*/
|
|
88
|
+
export declare function installSpecificWrappers(names: string[], targetDir: string, config?: WrapperConfig): Promise<WrapperResult[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Uninstall a wrapper
|
|
91
|
+
*/
|
|
92
|
+
export declare function uninstallWrapper(name: string, targetDir: string): Promise<WrapperResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Uninstall all wrappers
|
|
95
|
+
*/
|
|
96
|
+
export declare function uninstallWrappers(targetDir?: string): Promise<WrapperResult[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Verify wrapper installation
|
|
99
|
+
*/
|
|
100
|
+
export declare function verifyWrappers(targetDir?: string): Promise<{
|
|
101
|
+
valid: boolean;
|
|
102
|
+
installed: string[];
|
|
103
|
+
missing: string[];
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Install all wrappers using UserConfig
|
|
107
|
+
*
|
|
108
|
+
* @param userConfig - UserConfig with user information
|
|
109
|
+
* @param directories - Directories configuration
|
|
110
|
+
*/
|
|
111
|
+
export declare function installAllWrappers(userConfig: UserConfig, directories: {
|
|
112
|
+
binDir: string;
|
|
113
|
+
wrappersDir: string;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
success: boolean;
|
|
116
|
+
error?: string;
|
|
117
|
+
installed?: string[];
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Verbose logging options
|
|
121
|
+
*/
|
|
122
|
+
export interface VerboseOptions {
|
|
123
|
+
verbose?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Install guarded shell using the hardened zsh guarded-shell content
|
|
127
|
+
*/
|
|
128
|
+
export declare function installGuardedShell(userConfig?: UserConfig, options?: VerboseOptions): Promise<WrapperResult>;
|
|
129
|
+
/**
|
|
130
|
+
* Install the shield-exec Node.js command proxy and create symlinks.
|
|
131
|
+
*
|
|
132
|
+
* Writes shield-exec to /opt/agenshield/bin/shield-exec (root-owned, mode 755),
|
|
133
|
+
* then creates symlinks in the agent's bin directory for all proxied commands.
|
|
134
|
+
* node/python are kept as separate bash wrappers (they need NODE_OPTIONS/seatbelt).
|
|
135
|
+
*/
|
|
136
|
+
export declare function installShieldExec(userConfig: UserConfig, binDir: string): Promise<{
|
|
137
|
+
success: boolean;
|
|
138
|
+
error?: string;
|
|
139
|
+
installed?: string[];
|
|
140
|
+
}>;
|
|
141
|
+
/**
|
|
142
|
+
* Get list of available wrapper names
|
|
143
|
+
*/
|
|
144
|
+
export declare function getAvailableWrappers(): string[];
|
|
145
|
+
/**
|
|
146
|
+
* Get wrapper definition by name
|
|
147
|
+
*/
|
|
148
|
+
export declare function getWrapperDefinition(name: string): WrapperDefinition | null;
|
|
149
|
+
/**
|
|
150
|
+
* Check if a wrapper uses seatbelt
|
|
151
|
+
*/
|
|
152
|
+
export declare function wrapperUsesSeatbelt(name: string): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Check if a wrapper uses interceptor
|
|
155
|
+
*/
|
|
156
|
+
export declare function wrapperUsesInterceptor(name: string): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Dynamic wrapper management - add a new wrapper at runtime
|
|
159
|
+
*/
|
|
160
|
+
export declare function addDynamicWrapper(name: string, content: string, targetDir: string, useSudo?: boolean, owner?: string, group?: string): Promise<WrapperResult>;
|
|
161
|
+
/**
|
|
162
|
+
* Dynamic wrapper management - remove a wrapper at runtime
|
|
163
|
+
*/
|
|
164
|
+
export declare function removeDynamicWrapper(name: string, targetDir: string, useSudo?: boolean): Promise<WrapperResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Update an existing wrapper with new content
|
|
167
|
+
*/
|
|
168
|
+
export declare function updateWrapper(name: string, targetDir: string, config?: WrapperConfig, useSudo?: boolean): Promise<WrapperResult>;
|
|
169
|
+
/**
|
|
170
|
+
* Deploy the interceptor CJS bundle to the sandbox.
|
|
171
|
+
*
|
|
172
|
+
* Copies `libs/shield-interceptor/dist/register.js` (which is CJS despite the
|
|
173
|
+
* package.json "type":"module") to `/opt/agenshield/lib/interceptor/register.cjs`
|
|
174
|
+
* so that node wrappers can use `--require` to load it.
|
|
175
|
+
*/
|
|
176
|
+
export declare function deployInterceptor(userConfig?: UserConfig): Promise<WrapperResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Copy the broker binary to /opt/agenshield/bin/
|
|
179
|
+
* The broker is the privileged daemon that handles socket communication.
|
|
180
|
+
*/
|
|
181
|
+
export declare function copyBrokerBinary(userConfig?: UserConfig): Promise<WrapperResult>;
|
|
182
|
+
/**
|
|
183
|
+
* Copy the current Node.js binary to the sandbox so the node wrapper
|
|
184
|
+
* can exec a known-good binary without relying on system PATH.
|
|
185
|
+
*/
|
|
186
|
+
export declare function copyNodeBinary(userConfig?: UserConfig): Promise<WrapperResult>;
|
|
187
|
+
export interface PresetInstallResult {
|
|
188
|
+
success: boolean;
|
|
189
|
+
installedWrappers: string[];
|
|
190
|
+
errors: string[];
|
|
191
|
+
seatbeltInstalled: boolean;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Basic system commands that should be available via symlinks (no interception needed)
|
|
195
|
+
*/
|
|
196
|
+
export declare const BASIC_SYSTEM_COMMANDS: string[];
|
|
197
|
+
/**
|
|
198
|
+
* Install symlinks for basic system commands that don't need interception
|
|
199
|
+
*/
|
|
200
|
+
export declare function installBasicCommands(binDir: string, options?: {
|
|
201
|
+
verbose?: boolean;
|
|
202
|
+
}): Promise<{
|
|
203
|
+
success: boolean;
|
|
204
|
+
installed: string[];
|
|
205
|
+
errors: string[];
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Install binaries for a preset: node binary, interceptor, wrappers, seatbelt, ownership lockdown.
|
|
209
|
+
*/
|
|
210
|
+
export declare function installPresetBinaries(options: {
|
|
211
|
+
requiredBins: string[];
|
|
212
|
+
userConfig: UserConfig;
|
|
213
|
+
binDir: string;
|
|
214
|
+
socketGroupName: string;
|
|
215
|
+
verbose?: boolean;
|
|
216
|
+
}): Promise<PresetInstallResult>;
|
|
217
|
+
//# sourceMappingURL=wrappers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../src/wrappers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAOlD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB;IAClB,UAAU,EAAE,M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