@tankgate/core 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/dist/detect.d.ts +13 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +302 -0
- package/dist/detect.js.map +1 -0
- package/dist/generators/config.d.ts +8 -0
- package/dist/generators/config.d.ts.map +1 -0
- package/dist/generators/config.js +56 -0
- package/dist/generators/config.js.map +1 -0
- package/dist/generators/docker-compose.d.ts +40 -0
- package/dist/generators/docker-compose.d.ts.map +1 -0
- package/dist/generators/docker-compose.js +144 -0
- package/dist/generators/docker-compose.js.map +1 -0
- package/dist/generators/env.d.ts +8 -0
- package/dist/generators/env.d.ts.map +1 -0
- package/dist/generators/env.js +78 -0
- package/dist/generators/env.js.map +1 -0
- package/dist/generators/policy.d.ts +12 -0
- package/dist/generators/policy.d.ts.map +1 -0
- package/dist/generators/policy.js +602 -0
- package/dist/generators/policy.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +25 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +166 -0
- package/dist/prompts.js.map +1 -0
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment File Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates the .env.example file with all required environment variables.
|
|
5
|
+
*/
|
|
6
|
+
export function generateEnvExample(options) {
|
|
7
|
+
const { approval } = options;
|
|
8
|
+
return `# TankGate Environment Configuration
|
|
9
|
+
# Generated by tankgate init
|
|
10
|
+
# Copy this file to .env and fill in your values
|
|
11
|
+
|
|
12
|
+
# =============================================================================
|
|
13
|
+
# REQUIRED: LLM API Keys
|
|
14
|
+
# =============================================================================
|
|
15
|
+
|
|
16
|
+
# Your OpenAI API key (or OpenAI-compatible provider)
|
|
17
|
+
OPENAI_API_KEY=sk-xxx
|
|
18
|
+
|
|
19
|
+
# Your Anthropic API key (required for Claude models)
|
|
20
|
+
# ANTHROPIC_API_KEY=sk-ant-xxx
|
|
21
|
+
|
|
22
|
+
# =============================================================================
|
|
23
|
+
# OPTIONAL: Custom API Endpoints
|
|
24
|
+
# =============================================================================
|
|
25
|
+
|
|
26
|
+
# Override OpenAI base URL (for proxies, Azure, or other compatible APIs)
|
|
27
|
+
# OPENAI_BASE_URL=https://api.openai.com/v1
|
|
28
|
+
|
|
29
|
+
# Override Anthropic base URL
|
|
30
|
+
# ANTHROPIC_BASE_URL=https://api.anthropic.com
|
|
31
|
+
|
|
32
|
+
# =============================================================================
|
|
33
|
+
# OPTIONAL: Scanner Configuration
|
|
34
|
+
# =============================================================================
|
|
35
|
+
|
|
36
|
+
# Secret key for HMAC audit chain (generate with: openssl rand -hex 32)
|
|
37
|
+
# TANKGATE_AUDIT_SECRET=your-secret-key-here
|
|
38
|
+
|
|
39
|
+
# Path to audit database (default: ./audit.db)
|
|
40
|
+
# TANKGATE_AUDIT_DB=./audit.db
|
|
41
|
+
|
|
42
|
+
# =============================================================================
|
|
43
|
+
# OPTIONAL: Telegram Approval Channel
|
|
44
|
+
# =============================================================================
|
|
45
|
+
|
|
46
|
+
${approval === 'telegram' ? `# Telegram bot token (get from @BotFather on Telegram)
|
|
47
|
+
TELEGRAM_BOT_TOKEN=your-bot-token-here
|
|
48
|
+
|
|
49
|
+
# Your Telegram chat ID (get from @userinfobot on Telegram)
|
|
50
|
+
TELEGRAM_CHAT_ID=your-chat-id-here
|
|
51
|
+
` : `# Telegram bot token (uncomment if using telegram approval)
|
|
52
|
+
# TELEGRAM_BOT_TOKEN=your-bot-token-here
|
|
53
|
+
|
|
54
|
+
# Your Telegram chat ID (uncomment if using telegram approval)
|
|
55
|
+
# TELEGRAM_CHAT_ID=your-chat-id-here
|
|
56
|
+
`}
|
|
57
|
+
# =============================================================================
|
|
58
|
+
# OPTIONAL: Advanced Configuration
|
|
59
|
+
# =============================================================================
|
|
60
|
+
|
|
61
|
+
# Override policy file path (default: ./.tankgate/policies)
|
|
62
|
+
# TANKGATE_POLICY_PATH=./policies
|
|
63
|
+
|
|
64
|
+
# Log level: debug, info, warn, error (default: info)
|
|
65
|
+
# TANKGATE_LOG_LEVEL=info
|
|
66
|
+
|
|
67
|
+
# =============================================================================
|
|
68
|
+
# USAGE
|
|
69
|
+
# =============================================================================
|
|
70
|
+
#
|
|
71
|
+
# 1. Copy this file: cp .env.example .env
|
|
72
|
+
# 2. Fill in your API keys
|
|
73
|
+
# 3. (Optional) Configure Telegram for mobile approval
|
|
74
|
+
# 4. Start TankGate: docker compose -f docker-compose.tankgate.yml up -d
|
|
75
|
+
#
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/generators/env.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCP,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC;;;;;CAK3B,CAAC,CAAC,CAAC;;;;;CAKH;;;;;;;;;;;;;;;;;;;;CAoBA,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates policy YAML files for different AI coding agents.
|
|
5
|
+
* Each agent has a customized template with appropriate defaults.
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentType } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Generate a policy file for the specified agent
|
|
10
|
+
*/
|
|
11
|
+
export declare function generatePolicy(agent: AgentType): string;
|
|
12
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/generators/policy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAWvD"}
|
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates policy YAML files for different AI coding agents.
|
|
5
|
+
* Each agent has a customized template with appropriate defaults.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a policy file for the specified agent
|
|
9
|
+
*/
|
|
10
|
+
export function generatePolicy(agent) {
|
|
11
|
+
const generators = {
|
|
12
|
+
openclaw: getOpenClawTemplate,
|
|
13
|
+
aider: getAiderTemplate,
|
|
14
|
+
'claude-code': getClaudeCodeTemplate,
|
|
15
|
+
cline: getClineTemplate,
|
|
16
|
+
continue: getContinueTemplate,
|
|
17
|
+
custom: getGenericTemplate,
|
|
18
|
+
};
|
|
19
|
+
return generators[agent]();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* OpenClaw policy template
|
|
23
|
+
*/
|
|
24
|
+
function getOpenClawTemplate() {
|
|
25
|
+
return `# TankGate OpenClaw Agent Policy
|
|
26
|
+
# Custom policy for OpenClaw AI coding agent
|
|
27
|
+
|
|
28
|
+
apiVersion: tankgate.dev/v1
|
|
29
|
+
kind: AgentPolicy
|
|
30
|
+
metadata:
|
|
31
|
+
name: openclaw
|
|
32
|
+
version: "1.0.0"
|
|
33
|
+
description: Policy for OpenClaw AI coding agent
|
|
34
|
+
agent: openclaw
|
|
35
|
+
|
|
36
|
+
# Extend base policy for immutable security rules
|
|
37
|
+
extends:
|
|
38
|
+
- base
|
|
39
|
+
|
|
40
|
+
tools:
|
|
41
|
+
filesystem:
|
|
42
|
+
read:
|
|
43
|
+
default: level_1
|
|
44
|
+
rules:
|
|
45
|
+
# Allow reading project files silently
|
|
46
|
+
- when:
|
|
47
|
+
path: "^/(home|Users|workspace)/"
|
|
48
|
+
then: level_0
|
|
49
|
+
reason: "Project directory read access"
|
|
50
|
+
|
|
51
|
+
# Block sensitive files
|
|
52
|
+
- when:
|
|
53
|
+
path: "\\\\.(env|pem|key|p12)$"
|
|
54
|
+
then: level_4
|
|
55
|
+
reason: "BLOCKED: Sensitive file access"
|
|
56
|
+
|
|
57
|
+
write:
|
|
58
|
+
default: level_2
|
|
59
|
+
rules:
|
|
60
|
+
# Allow writing to project directories
|
|
61
|
+
- when:
|
|
62
|
+
path: "^/(home|Users|workspace)/"
|
|
63
|
+
then: level_1
|
|
64
|
+
reason: "Project directory write"
|
|
65
|
+
|
|
66
|
+
# Require approval for configuration files
|
|
67
|
+
- when:
|
|
68
|
+
path: "\\\\.(json|yaml|yml|toml|ini|conf)$"
|
|
69
|
+
then: level_2
|
|
70
|
+
reason: "Configuration file modification"
|
|
71
|
+
|
|
72
|
+
delete:
|
|
73
|
+
default: level_3
|
|
74
|
+
rules:
|
|
75
|
+
# Allow deleting in project directories with notification
|
|
76
|
+
- when:
|
|
77
|
+
path: "^/(home|Users|workspace)/"
|
|
78
|
+
then: level_2
|
|
79
|
+
reason: "Project file deletion"
|
|
80
|
+
|
|
81
|
+
list:
|
|
82
|
+
default: level_0
|
|
83
|
+
rules: []
|
|
84
|
+
|
|
85
|
+
search:
|
|
86
|
+
default: level_0
|
|
87
|
+
rules: []
|
|
88
|
+
|
|
89
|
+
shell:
|
|
90
|
+
execute:
|
|
91
|
+
default: level_2
|
|
92
|
+
rules:
|
|
93
|
+
# Allow common development commands
|
|
94
|
+
- when:
|
|
95
|
+
command: "^(npm|yarn|pnpm|bun)\\\\s+(install|run|test|build|dev)"
|
|
96
|
+
then: level_1
|
|
97
|
+
reason: "Package manager command"
|
|
98
|
+
|
|
99
|
+
# Allow git read commands
|
|
100
|
+
- when:
|
|
101
|
+
command: "^git\\\\s+(status|diff|log|branch|show)"
|
|
102
|
+
then: level_1
|
|
103
|
+
reason: "Git read command"
|
|
104
|
+
|
|
105
|
+
# Allow git write commands
|
|
106
|
+
- when:
|
|
107
|
+
command: "^git\\\\s+(commit|push|pull|add)"
|
|
108
|
+
then: level_2
|
|
109
|
+
reason: "Git write command"
|
|
110
|
+
|
|
111
|
+
# Require approval for sudo
|
|
112
|
+
- when:
|
|
113
|
+
command: "^sudo\\\\s"
|
|
114
|
+
then: level_3
|
|
115
|
+
reason: "Sudo requires approval"
|
|
116
|
+
|
|
117
|
+
network:
|
|
118
|
+
request:
|
|
119
|
+
default: level_2
|
|
120
|
+
rules:
|
|
121
|
+
# Allow common development APIs
|
|
122
|
+
- when:
|
|
123
|
+
url: "https://(api\\\\.)?(npmjs|github|gitlab|bitbucket)\\\\.com"
|
|
124
|
+
then: level_1
|
|
125
|
+
reason: "Development API access"
|
|
126
|
+
|
|
127
|
+
vcs:
|
|
128
|
+
commit:
|
|
129
|
+
default: level_1
|
|
130
|
+
rules: []
|
|
131
|
+
|
|
132
|
+
push:
|
|
133
|
+
default: level_2
|
|
134
|
+
rules:
|
|
135
|
+
# Require approval for pushing to main/master
|
|
136
|
+
- when:
|
|
137
|
+
branch: "(main|master)"
|
|
138
|
+
then: level_3
|
|
139
|
+
reason: "Push to main/master requires approval"
|
|
140
|
+
|
|
141
|
+
pull:
|
|
142
|
+
default: level_1
|
|
143
|
+
rules: []
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Aider policy template
|
|
148
|
+
*/
|
|
149
|
+
function getAiderTemplate() {
|
|
150
|
+
return `# TankGate Aider Agent Policy
|
|
151
|
+
# Policy for Aider AI pair programming tool
|
|
152
|
+
|
|
153
|
+
apiVersion: tankgate.dev/v1
|
|
154
|
+
kind: AgentPolicy
|
|
155
|
+
metadata:
|
|
156
|
+
name: aider
|
|
157
|
+
version: "1.0.0"
|
|
158
|
+
description: Policy for Aider AI pair programming tool
|
|
159
|
+
agent: aider
|
|
160
|
+
|
|
161
|
+
extends:
|
|
162
|
+
- base
|
|
163
|
+
|
|
164
|
+
tools:
|
|
165
|
+
filesystem:
|
|
166
|
+
read:
|
|
167
|
+
default: level_0
|
|
168
|
+
rules:
|
|
169
|
+
# Block sensitive files
|
|
170
|
+
- when:
|
|
171
|
+
path: "\\\\.(env|pem|key|p12)$"
|
|
172
|
+
then: level_4
|
|
173
|
+
reason: "BLOCKED: Sensitive file access"
|
|
174
|
+
|
|
175
|
+
write:
|
|
176
|
+
default: level_1
|
|
177
|
+
rules:
|
|
178
|
+
# Require approval for configuration files
|
|
179
|
+
- when:
|
|
180
|
+
path: "\\\\.(json|yaml|yml|toml|ini|conf)$"
|
|
181
|
+
then: level_2
|
|
182
|
+
reason: "Configuration file modification"
|
|
183
|
+
|
|
184
|
+
delete:
|
|
185
|
+
default: level_2
|
|
186
|
+
rules: []
|
|
187
|
+
|
|
188
|
+
list:
|
|
189
|
+
default: level_0
|
|
190
|
+
rules: []
|
|
191
|
+
|
|
192
|
+
search:
|
|
193
|
+
default: level_0
|
|
194
|
+
rules: []
|
|
195
|
+
|
|
196
|
+
shell:
|
|
197
|
+
execute:
|
|
198
|
+
default: level_2
|
|
199
|
+
rules:
|
|
200
|
+
# Allow aider commands
|
|
201
|
+
- when:
|
|
202
|
+
command: "^aider\\\\s"
|
|
203
|
+
then: level_1
|
|
204
|
+
reason: "Aider command"
|
|
205
|
+
|
|
206
|
+
# Allow common development commands
|
|
207
|
+
- when:
|
|
208
|
+
command: "^(npm|yarn|pnpm|bun|python|pip)\\\\s+"
|
|
209
|
+
then: level_1
|
|
210
|
+
reason: "Development command"
|
|
211
|
+
|
|
212
|
+
# Allow git commands
|
|
213
|
+
- when:
|
|
214
|
+
command: "^git\\\\s+"
|
|
215
|
+
then: level_1
|
|
216
|
+
reason: "Git command"
|
|
217
|
+
|
|
218
|
+
network:
|
|
219
|
+
request:
|
|
220
|
+
default: level_2
|
|
221
|
+
rules:
|
|
222
|
+
# Allow LLM APIs
|
|
223
|
+
- when:
|
|
224
|
+
url: "https://(api\\\\.)?(openai|anthropic)\\\\.com"
|
|
225
|
+
then: level_1
|
|
226
|
+
reason: "LLM API access"
|
|
227
|
+
`;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Claude Code policy template
|
|
231
|
+
*/
|
|
232
|
+
function getClaudeCodeTemplate() {
|
|
233
|
+
return `# TankGate Claude Code Agent Policy
|
|
234
|
+
# Policy for Claude Code (Anthropic's official CLI)
|
|
235
|
+
|
|
236
|
+
apiVersion: tankgate.dev/v1
|
|
237
|
+
kind: AgentPolicy
|
|
238
|
+
metadata:
|
|
239
|
+
name: claude-code
|
|
240
|
+
version: "1.0.0"
|
|
241
|
+
description: Policy for Claude Code CLI agent
|
|
242
|
+
agent: claude-code
|
|
243
|
+
|
|
244
|
+
extends:
|
|
245
|
+
- base
|
|
246
|
+
|
|
247
|
+
tools:
|
|
248
|
+
filesystem:
|
|
249
|
+
read:
|
|
250
|
+
default: level_0
|
|
251
|
+
rules:
|
|
252
|
+
# Block sensitive files
|
|
253
|
+
- when:
|
|
254
|
+
path: "\\\\.(env|pem|key|p12)$"
|
|
255
|
+
then: level_4
|
|
256
|
+
reason: "BLOCKED: Sensitive file access"
|
|
257
|
+
|
|
258
|
+
# Notify on credential-like files
|
|
259
|
+
- when:
|
|
260
|
+
path: "(credentials|secrets|password)"
|
|
261
|
+
then: level_2
|
|
262
|
+
reason: "Credential file access"
|
|
263
|
+
|
|
264
|
+
write:
|
|
265
|
+
default: level_1
|
|
266
|
+
rules:
|
|
267
|
+
# Require approval for configuration files
|
|
268
|
+
- when:
|
|
269
|
+
path: "\\\\.(json|yaml|yml|toml|ini|conf)$"
|
|
270
|
+
then: level_2
|
|
271
|
+
reason: "Configuration file modification"
|
|
272
|
+
|
|
273
|
+
# Block write to system directories
|
|
274
|
+
- when:
|
|
275
|
+
path: "^/(etc|bin|usr|var)/"
|
|
276
|
+
then: level_4
|
|
277
|
+
reason: "BLOCKED: System directory write"
|
|
278
|
+
|
|
279
|
+
delete:
|
|
280
|
+
default: level_2
|
|
281
|
+
rules:
|
|
282
|
+
# Block delete of important files
|
|
283
|
+
- when:
|
|
284
|
+
path: "\\\\.(git|env|lock)$"
|
|
285
|
+
then: level_4
|
|
286
|
+
reason: "BLOCKED: Critical file deletion"
|
|
287
|
+
|
|
288
|
+
list:
|
|
289
|
+
default: level_0
|
|
290
|
+
rules: []
|
|
291
|
+
|
|
292
|
+
search:
|
|
293
|
+
default: level_0
|
|
294
|
+
rules: []
|
|
295
|
+
|
|
296
|
+
shell:
|
|
297
|
+
execute:
|
|
298
|
+
default: level_2
|
|
299
|
+
rules:
|
|
300
|
+
# Allow package managers
|
|
301
|
+
- when:
|
|
302
|
+
command: "^(npm|yarn|pnpm|bun)\\\\s+(install|run|test|build|dev|add|remove)"
|
|
303
|
+
then: level_1
|
|
304
|
+
reason: "Package manager command"
|
|
305
|
+
|
|
306
|
+
# Allow git read commands silently
|
|
307
|
+
- when:
|
|
308
|
+
command: "^git\\\\s+(status|diff|log|branch|show|ls-files)"
|
|
309
|
+
then: level_0
|
|
310
|
+
reason: "Git read command"
|
|
311
|
+
|
|
312
|
+
# Allow git write commands
|
|
313
|
+
- when:
|
|
314
|
+
command: "^git\\\\s+(commit|push|pull|add|checkout|merge|rebase)"
|
|
315
|
+
then: level_1
|
|
316
|
+
reason: "Git write command"
|
|
317
|
+
|
|
318
|
+
# Require approval for git force push
|
|
319
|
+
- when:
|
|
320
|
+
command: "git\\\\s+.*--force"
|
|
321
|
+
then: level_3
|
|
322
|
+
reason: "Force push requires approval"
|
|
323
|
+
|
|
324
|
+
# Block dangerous commands
|
|
325
|
+
- when:
|
|
326
|
+
command: "^rm\\\\s+(-[rf]+\\\\s+)*(/\\\\s*|/\\\\*)"
|
|
327
|
+
then: level_4
|
|
328
|
+
reason: "BLOCKED: Recursive root delete"
|
|
329
|
+
|
|
330
|
+
network:
|
|
331
|
+
request:
|
|
332
|
+
default: level_2
|
|
333
|
+
rules:
|
|
334
|
+
# Allow common development APIs
|
|
335
|
+
- when:
|
|
336
|
+
url: "https://(api\\\\.)?(github|gitlab|npmjs|pypi)\\\\.com"
|
|
337
|
+
then: level_1
|
|
338
|
+
reason: "Development API access"
|
|
339
|
+
|
|
340
|
+
# Allow LLM APIs
|
|
341
|
+
- when:
|
|
342
|
+
url: "https://(api\\\\.)?(openai|anthropic)\\\\.com"
|
|
343
|
+
then: level_1
|
|
344
|
+
reason: "LLM API access"
|
|
345
|
+
|
|
346
|
+
vcs:
|
|
347
|
+
commit:
|
|
348
|
+
default: level_1
|
|
349
|
+
rules: []
|
|
350
|
+
|
|
351
|
+
push:
|
|
352
|
+
default: level_2
|
|
353
|
+
rules:
|
|
354
|
+
# Require approval for pushing to main/master
|
|
355
|
+
- when:
|
|
356
|
+
branch: "(main|master)"
|
|
357
|
+
then: level_3
|
|
358
|
+
reason: "Push to main/master requires approval"
|
|
359
|
+
|
|
360
|
+
pull:
|
|
361
|
+
default: level_1
|
|
362
|
+
rules: []
|
|
363
|
+
`;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Cline policy template
|
|
367
|
+
*/
|
|
368
|
+
function getClineTemplate() {
|
|
369
|
+
return `# TankGate Cline Agent Policy
|
|
370
|
+
# Policy for Cline VSCode extension
|
|
371
|
+
|
|
372
|
+
apiVersion: tankgate.dev/v1
|
|
373
|
+
kind: AgentPolicy
|
|
374
|
+
metadata:
|
|
375
|
+
name: cline
|
|
376
|
+
version: "1.0.0"
|
|
377
|
+
description: Policy for Cline VSCode extension
|
|
378
|
+
agent: cline
|
|
379
|
+
|
|
380
|
+
extends:
|
|
381
|
+
- base
|
|
382
|
+
|
|
383
|
+
tools:
|
|
384
|
+
filesystem:
|
|
385
|
+
read:
|
|
386
|
+
default: level_0
|
|
387
|
+
rules:
|
|
388
|
+
# Block sensitive files
|
|
389
|
+
- when:
|
|
390
|
+
path: "\\\\.(env|pem|key|p12)$"
|
|
391
|
+
then: level_4
|
|
392
|
+
reason: "BLOCKED: Sensitive file access"
|
|
393
|
+
|
|
394
|
+
write:
|
|
395
|
+
default: level_1
|
|
396
|
+
rules:
|
|
397
|
+
# Require approval for configuration files
|
|
398
|
+
- when:
|
|
399
|
+
path: "\\\\.(json|yaml|yml|toml|ini|conf)$"
|
|
400
|
+
then: level_2
|
|
401
|
+
reason: "Configuration file modification"
|
|
402
|
+
|
|
403
|
+
delete:
|
|
404
|
+
default: level_2
|
|
405
|
+
rules: []
|
|
406
|
+
|
|
407
|
+
list:
|
|
408
|
+
default: level_0
|
|
409
|
+
rules: []
|
|
410
|
+
|
|
411
|
+
search:
|
|
412
|
+
default: level_0
|
|
413
|
+
rules: []
|
|
414
|
+
|
|
415
|
+
shell:
|
|
416
|
+
execute:
|
|
417
|
+
default: level_2
|
|
418
|
+
rules:
|
|
419
|
+
# Allow common development commands
|
|
420
|
+
- when:
|
|
421
|
+
command: "^(npm|yarn|pnpm|bun)\\\\s+"
|
|
422
|
+
then: level_1
|
|
423
|
+
reason: "Package manager command"
|
|
424
|
+
|
|
425
|
+
# Allow git commands
|
|
426
|
+
- when:
|
|
427
|
+
command: "^git\\\\s+"
|
|
428
|
+
then: level_1
|
|
429
|
+
reason: "Git command"
|
|
430
|
+
|
|
431
|
+
network:
|
|
432
|
+
request:
|
|
433
|
+
default: level_2
|
|
434
|
+
rules:
|
|
435
|
+
# Allow LLM APIs
|
|
436
|
+
- when:
|
|
437
|
+
url: "https://(api\\\\.)?(openai|anthropic)\\\\.com"
|
|
438
|
+
then: level_1
|
|
439
|
+
reason: "LLM API access"
|
|
440
|
+
`;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Continue policy template
|
|
444
|
+
*/
|
|
445
|
+
function getContinueTemplate() {
|
|
446
|
+
return `# TankGate Continue Agent Policy
|
|
447
|
+
# Policy for Continue.dev VSCode extension
|
|
448
|
+
|
|
449
|
+
apiVersion: tankgate.dev/v1
|
|
450
|
+
kind: AgentPolicy
|
|
451
|
+
metadata:
|
|
452
|
+
name: continue
|
|
453
|
+
version: "1.0.0"
|
|
454
|
+
description: Policy for Continue.dev VSCode extension
|
|
455
|
+
agent: continue
|
|
456
|
+
|
|
457
|
+
extends:
|
|
458
|
+
- base
|
|
459
|
+
|
|
460
|
+
tools:
|
|
461
|
+
filesystem:
|
|
462
|
+
read:
|
|
463
|
+
default: level_0
|
|
464
|
+
rules:
|
|
465
|
+
# Block sensitive files
|
|
466
|
+
- when:
|
|
467
|
+
path: "\\\\.(env|pem|key|p12)$"
|
|
468
|
+
then: level_4
|
|
469
|
+
reason: "BLOCKED: Sensitive file access"
|
|
470
|
+
|
|
471
|
+
write:
|
|
472
|
+
default: level_1
|
|
473
|
+
rules:
|
|
474
|
+
# Require approval for configuration files
|
|
475
|
+
- when:
|
|
476
|
+
path: "\\\\.(json|yaml|yml|toml|ini|conf)$"
|
|
477
|
+
then: level_2
|
|
478
|
+
reason: "Configuration file modification"
|
|
479
|
+
|
|
480
|
+
delete:
|
|
481
|
+
default: level_2
|
|
482
|
+
rules: []
|
|
483
|
+
|
|
484
|
+
list:
|
|
485
|
+
default: level_0
|
|
486
|
+
rules: []
|
|
487
|
+
|
|
488
|
+
search:
|
|
489
|
+
default: level_0
|
|
490
|
+
rules: []
|
|
491
|
+
|
|
492
|
+
shell:
|
|
493
|
+
execute:
|
|
494
|
+
default: level_2
|
|
495
|
+
rules:
|
|
496
|
+
# Allow common development commands
|
|
497
|
+
- when:
|
|
498
|
+
command: "^(npm|yarn|pnpm|bun)\\\\s+"
|
|
499
|
+
then: level_1
|
|
500
|
+
reason: "Package manager command"
|
|
501
|
+
|
|
502
|
+
# Allow git commands
|
|
503
|
+
- when:
|
|
504
|
+
command: "^git\\\\s+"
|
|
505
|
+
then: level_1
|
|
506
|
+
reason: "Git command"
|
|
507
|
+
|
|
508
|
+
network:
|
|
509
|
+
request:
|
|
510
|
+
default: level_2
|
|
511
|
+
rules:
|
|
512
|
+
# Allow Continue servers
|
|
513
|
+
- when:
|
|
514
|
+
url: "https://(api\\\\.)?continue\\\\.dev"
|
|
515
|
+
then: level_1
|
|
516
|
+
reason: "Continue API access"
|
|
517
|
+
|
|
518
|
+
# Allow LLM APIs
|
|
519
|
+
- when:
|
|
520
|
+
url: "https://(api\\\\.)?(openai|anthropic)\\\\.com"
|
|
521
|
+
then: level_1
|
|
522
|
+
reason: "LLM API access"
|
|
523
|
+
`;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Generic/custom policy template
|
|
527
|
+
*/
|
|
528
|
+
function getGenericTemplate() {
|
|
529
|
+
return `# TankGate Generic Agent Policy
|
|
530
|
+
# Customize this policy for your specific agent
|
|
531
|
+
|
|
532
|
+
apiVersion: tankgate.dev/v1
|
|
533
|
+
kind: AgentPolicy
|
|
534
|
+
metadata:
|
|
535
|
+
name: custom
|
|
536
|
+
version: "1.0.0"
|
|
537
|
+
description: Custom policy for generic AI agent
|
|
538
|
+
agent: custom
|
|
539
|
+
|
|
540
|
+
extends:
|
|
541
|
+
- base
|
|
542
|
+
|
|
543
|
+
tools:
|
|
544
|
+
filesystem:
|
|
545
|
+
read:
|
|
546
|
+
default: level_1
|
|
547
|
+
rules:
|
|
548
|
+
# Block sensitive files
|
|
549
|
+
- when:
|
|
550
|
+
path: "\\\\.(env|pem|key|p12)$"
|
|
551
|
+
then: level_4
|
|
552
|
+
reason: "BLOCKED: Sensitive file access"
|
|
553
|
+
|
|
554
|
+
write:
|
|
555
|
+
default: level_2
|
|
556
|
+
rules:
|
|
557
|
+
# Require approval for configuration files
|
|
558
|
+
- when:
|
|
559
|
+
path: "\\\\.(json|yaml|yml|toml|ini|conf)$"
|
|
560
|
+
then: level_3
|
|
561
|
+
reason: "Configuration file modification requires approval"
|
|
562
|
+
|
|
563
|
+
delete:
|
|
564
|
+
default: level_3
|
|
565
|
+
rules: []
|
|
566
|
+
|
|
567
|
+
list:
|
|
568
|
+
default: level_1
|
|
569
|
+
rules: []
|
|
570
|
+
|
|
571
|
+
search:
|
|
572
|
+
default: level_1
|
|
573
|
+
rules: []
|
|
574
|
+
|
|
575
|
+
shell:
|
|
576
|
+
execute:
|
|
577
|
+
default: level_3
|
|
578
|
+
rules:
|
|
579
|
+
# Allow common development commands
|
|
580
|
+
- when:
|
|
581
|
+
command: "^(npm|yarn|pnpm|bun)\\\\s+"
|
|
582
|
+
then: level_2
|
|
583
|
+
reason: "Package manager command"
|
|
584
|
+
|
|
585
|
+
# Allow git read commands
|
|
586
|
+
- when:
|
|
587
|
+
command: "^git\\\\s+(status|diff|log|branch)"
|
|
588
|
+
then: level_1
|
|
589
|
+
reason: "Git read command"
|
|
590
|
+
|
|
591
|
+
network:
|
|
592
|
+
request:
|
|
593
|
+
default: level_3
|
|
594
|
+
rules:
|
|
595
|
+
# Allow LLM APIs
|
|
596
|
+
- when:
|
|
597
|
+
url: "https://(api\\\\.)?(openai|anthropic)\\\\.com"
|
|
598
|
+
then: level_2
|
|
599
|
+
reason: "LLM API access"
|
|
600
|
+
`;
|
|
601
|
+
}
|
|
602
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/generators/policy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgB;IAC7C,MAAM,UAAU,GAAoC;QAClD,QAAQ,EAAE,mBAAmB;QAC7B,KAAK,EAAE,gBAAgB;QACvB,aAAa,EAAE,qBAAqB;QACpC,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,kBAAkB;KAC3B,CAAC;IAEF,OAAO,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuHR,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB;IACvB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ER,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB;IAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkIR,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB;IACvB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuER,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ER,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB;IACzB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuER,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './detect';
|
|
3
|
+
export * from './prompts';
|
|
4
|
+
export * from './generators/docker-compose';
|
|
5
|
+
export * from './generators/policy';
|
|
6
|
+
export * from './generators/config';
|
|
7
|
+
export * from './generators/env';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|