@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/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // @tankgate/core - Shared utilities for TankGate CLI
2
+ // This package provides agent detection, generators, and prompts
3
+ // Types
4
+ export * from './types';
5
+ // Detection
6
+ export * from './detect';
7
+ // Prompts
8
+ export * from './prompts';
9
+ // Generators
10
+ export * from './generators/docker-compose';
11
+ export * from './generators/policy';
12
+ export * from './generators/config';
13
+ export * from './generators/env';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,QAAQ;AACR,cAAc,SAAS,CAAC;AAExB,YAAY;AACZ,cAAc,UAAU,CAAC;AAEzB,UAAU;AACV,cAAc,WAAW,CAAC;AAE1B,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Prompt Wizard Module
3
+ *
4
+ * Interactive prompts for tankgate init command.
5
+ * Uses @inquirer/prompts for a clean CLI experience.
6
+ */
7
+ import type { AgentType, InitOptions } from './types';
8
+ export type { InitOptions } from './types';
9
+ /**
10
+ * Default options for non-interactive mode
11
+ */
12
+ export declare const DEFAULT_OPTIONS: InitOptions;
13
+ /**
14
+ * Run the interactive wizard to collect init options
15
+ *
16
+ * @param detected - Auto-detected agent type (used as default)
17
+ * @param options - Pre-filled options (from CLI flags)
18
+ * @returns Complete InitOptions
19
+ */
20
+ export declare function runWizard(detected: AgentType | null, options: Partial<InitOptions>): Promise<InitOptions>;
21
+ /**
22
+ * Non-interactive mode: merge CLI options with defaults
23
+ */
24
+ export declare function mergeWithDefaults(options: Partial<InitOptions>): InitOptions;
25
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,WAK7B,CAAC;AAmBF;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,SAAS,GAAG,IAAI,EAC1B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAC5B,OAAO,CAAC,WAAW,CAAC,CAmCtB;AAuGD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAE5E"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Prompt Wizard Module
3
+ *
4
+ * Interactive prompts for tankgate init command.
5
+ * Uses @inquirer/prompts for a clean CLI experience.
6
+ */
7
+ import { select } from '@inquirer/prompts';
8
+ /**
9
+ * Default options for non-interactive mode
10
+ */
11
+ export const DEFAULT_OPTIONS = {
12
+ agent: 'claude-code',
13
+ mode: 'convenience',
14
+ profile: 'fast',
15
+ approval: 'none',
16
+ };
17
+ /**
18
+ * Agents that support contained mode (Docker isolation)
19
+ */
20
+ const CONTAINABLE_AGENTS = ['openclaw', 'custom'];
21
+ /**
22
+ * Agent display names for prompts
23
+ */
24
+ const AGENT_CHOICES = [
25
+ { value: 'openclaw', name: 'OpenClaw (contained, recommended)' },
26
+ { value: 'aider', name: 'Aider (convenience mode)' },
27
+ { value: 'claude-code', name: 'Claude Code (convenience mode)' },
28
+ { value: 'cline', name: 'Cline (convenience mode)' },
29
+ { value: 'continue', name: 'Continue (convenience mode)' },
30
+ { value: 'custom', name: 'Other / Custom' },
31
+ ];
32
+ /**
33
+ * Run the interactive wizard to collect init options
34
+ *
35
+ * @param detected - Auto-detected agent type (used as default)
36
+ * @param options - Pre-filled options (from CLI flags)
37
+ * @returns Complete InitOptions
38
+ */
39
+ export async function runWizard(detected, options) {
40
+ // If all options are provided, skip prompts
41
+ if (options.agent && options.mode && options.profile && options.approval) {
42
+ return options;
43
+ }
44
+ // Start with defaults and override with provided options
45
+ const result = { ...DEFAULT_OPTIONS, ...options };
46
+ // Agent selection
47
+ if (!options.agent) {
48
+ result.agent = await promptAgent(detected);
49
+ }
50
+ // Mode selection (only for containable agents)
51
+ if (!options.mode) {
52
+ if (CONTAINABLE_AGENTS.includes(result.agent)) {
53
+ result.mode = await promptMode(result.agent === 'openclaw');
54
+ }
55
+ else {
56
+ // Non-containable agents always use convenience mode
57
+ result.mode = 'convenience';
58
+ }
59
+ }
60
+ // Scanner profile
61
+ if (!options.profile) {
62
+ result.profile = await promptProfile();
63
+ }
64
+ // Approval channel
65
+ if (!options.approval) {
66
+ result.approval = await promptApproval();
67
+ }
68
+ return result;
69
+ }
70
+ /**
71
+ * Prompt for agent type
72
+ */
73
+ async function promptAgent(detected) {
74
+ // Find the default choice index
75
+ const defaultIndex = detected
76
+ ? AGENT_CHOICES.findIndex((c) => c.value === detected)
77
+ : -1;
78
+ // Reorder choices to put detected agent first
79
+ const choices = defaultIndex > 0
80
+ ? [AGENT_CHOICES[defaultIndex], ...AGENT_CHOICES.filter((_, i) => i !== defaultIndex)]
81
+ : [...AGENT_CHOICES];
82
+ const answer = await select({
83
+ message: 'Which AI agent will you use?',
84
+ choices: choices.map((c) => ({ value: c.value, name: c.name })),
85
+ default: detected ?? 'claude-code',
86
+ });
87
+ return answer;
88
+ }
89
+ /**
90
+ * Prompt for security mode
91
+ */
92
+ async function promptMode(defaultContained) {
93
+ const answer = await select({
94
+ message: 'Security mode?',
95
+ choices: [
96
+ {
97
+ value: 'contained',
98
+ name: 'Contained (Docker isolation, no internet access)',
99
+ description: 'Best security - agent runs in isolated container',
100
+ },
101
+ {
102
+ value: 'convenience',
103
+ name: 'Convenience (runs on host, has internet)',
104
+ description: 'Easier setup - agent runs directly on your machine',
105
+ },
106
+ ],
107
+ default: defaultContained ? 'contained' : 'convenience',
108
+ });
109
+ return answer;
110
+ }
111
+ /**
112
+ * Prompt for scanner profile
113
+ */
114
+ async function promptProfile() {
115
+ const answer = await select({
116
+ message: 'Scanner profile?',
117
+ choices: [
118
+ {
119
+ value: 'fast',
120
+ name: 'Fast (regex only, ~1ms)',
121
+ description: 'Quick pattern matching for common attacks',
122
+ },
123
+ {
124
+ value: 'standard',
125
+ name: 'Standard (regex + ML on suspicious)',
126
+ description: 'Balanced security and performance',
127
+ },
128
+ {
129
+ value: 'paranoid',
130
+ name: 'Paranoid (always ML scan)',
131
+ description: 'Maximum security with ML scanning on all requests',
132
+ },
133
+ ],
134
+ default: 'fast',
135
+ });
136
+ return answer;
137
+ }
138
+ /**
139
+ * Prompt for approval channel
140
+ */
141
+ async function promptApproval() {
142
+ const answer = await select({
143
+ message: 'How to handle dangerous actions?',
144
+ choices: [
145
+ {
146
+ value: 'telegram',
147
+ name: 'Telegram (approve on phone)',
148
+ description: 'Get approval requests on your phone via Telegram',
149
+ },
150
+ {
151
+ value: 'none',
152
+ name: 'Block (no approval channel)',
153
+ description: 'Dangerous actions are blocked automatically',
154
+ },
155
+ ],
156
+ default: 'none',
157
+ });
158
+ return answer;
159
+ }
160
+ /**
161
+ * Non-interactive mode: merge CLI options with defaults
162
+ */
163
+ export function mergeWithDefaults(options) {
164
+ return { ...DEFAULT_OPTIONS, ...options };
165
+ }
166
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,KAAK,EAAE,aAAa;IACpB,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E,MAAM;gBACb,IAAI,EAAE,6BAA6B;gBACnC,WAAW,EAAE,6CAA6C;aAC3D;SACF;QACD,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC;IAEH,OAAO,MAA6B,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA6B;IAC7D,OAAO,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Shared type definitions for TankGate Core
3
+ */
4
+ /**
5
+ * Supported AI agent types
6
+ */
7
+ export type AgentType = 'openclaw' | 'aider' | 'claude-code' | 'cline' | 'continue' | 'custom';
8
+ /**
9
+ * Agent detection result
10
+ */
11
+ export interface DetectionResult {
12
+ agent: AgentType;
13
+ confidence: 'high' | 'medium' | 'low';
14
+ evidence: string[];
15
+ }
16
+ /**
17
+ * Security mode for agent execution
18
+ */
19
+ export type SecurityMode = 'contained' | 'convenience';
20
+ /**
21
+ * Scanner profile for security scanning
22
+ */
23
+ export type ScannerProfile = 'fast' | 'standard' | 'paranoid';
24
+ /**
25
+ * Approval channel for dangerous actions
26
+ */
27
+ export type ApprovalChannel = 'telegram' | 'none';
28
+ /**
29
+ * Complete initialization options
30
+ */
31
+ export interface InitOptions {
32
+ agent: AgentType;
33
+ mode: SecurityMode;
34
+ profile: ScannerProfile;
35
+ approval: ApprovalChannel;
36
+ }
37
+ /**
38
+ * Docker image configuration
39
+ */
40
+ export interface DockerImages {
41
+ tankgate: string;
42
+ openclaw: string;
43
+ scanner: string;
44
+ }
45
+ /**
46
+ * Default Docker images
47
+ */
48
+ export declare const DEFAULT_DOCKER_IMAGES: DockerImages;
49
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,aAAa,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,MAAM,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAInC,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared type definitions for TankGate Core
3
+ */
4
+ /**
5
+ * Default Docker images
6
+ */
7
+ export const DEFAULT_DOCKER_IMAGES = {
8
+ tankgate: 'ghcr.io/tankpkg/tankgate:latest',
9
+ openclaw: 'minimus/openclaw:latest',
10
+ scanner: 'protectai/llm-guard:latest',
11
+ };
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkDH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,QAAQ,EAAE,iCAAiC;IAC3C,QAAQ,EAAE,yBAAyB;IACnC,OAAO,EAAE,4BAA4B;CACtC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@tankgate/core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist/",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch"
20
+ },
21
+ "dependencies": {
22
+ "@inquirer/prompts": "^8.3.0",
23
+ "yaml": "^2.8.2",
24
+ "zod": "^4.3.6"
25
+ },
26
+ "devDependencies": {
27
+ "@types/bun": "latest",
28
+ "typescript": "^5"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "registry": "https://registry.npmjs.org/"
33
+ }
34
+ }