wyrm-mcp 3.2.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/LICENSE +667 -0
- package/README.md +384 -0
- package/dist/analytics.d.ts +100 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +368 -0
- package/dist/analytics.js.map +1 -0
- package/dist/auto-orchestrator.d.ts +118 -0
- package/dist/auto-orchestrator.d.ts.map +1 -0
- package/dist/auto-orchestrator.js +325 -0
- package/dist/auto-orchestrator.js.map +1 -0
- package/dist/autoconfig.d.ts +89 -0
- package/dist/autoconfig.d.ts.map +1 -0
- package/dist/autoconfig.js +576 -0
- package/dist/autoconfig.js.map +1 -0
- package/dist/cli.d.ts +148 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +281 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud-backup.d.ts +100 -0
- package/dist/cloud-backup.d.ts.map +1 -0
- package/dist/cloud-backup.js +545 -0
- package/dist/cloud-backup.js.map +1 -0
- package/dist/crypto.d.ts +72 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +164 -0
- package/dist/crypto.js.map +1 -0
- package/dist/database.d.ts +218 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +1058 -0
- package/dist/database.js.map +1 -0
- package/dist/http-auth.d.ts +68 -0
- package/dist/http-auth.d.ts.map +1 -0
- package/dist/http-auth.js +296 -0
- package/dist/http-auth.js.map +1 -0
- package/dist/http-fast.d.ts +13 -0
- package/dist/http-fast.d.ts.map +1 -0
- package/dist/http-fast.js +325 -0
- package/dist/http-fast.js.map +1 -0
- package/dist/http-server.d.ts +12 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +383 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1695 -0
- package/dist/index.js.map +1 -0
- package/dist/license.d.ts +177 -0
- package/dist/license.d.ts.map +1 -0
- package/dist/license.js +405 -0
- package/dist/license.js.map +1 -0
- package/dist/logger.d.ts +76 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +195 -0
- package/dist/logger.js.map +1 -0
- package/dist/performance.d.ts +114 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/performance.js +228 -0
- package/dist/performance.js.map +1 -0
- package/dist/resilience.d.ts +146 -0
- package/dist/resilience.d.ts.map +1 -0
- package/dist/resilience.js +563 -0
- package/dist/resilience.js.map +1 -0
- package/dist/security.d.ts +68 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +215 -0
- package/dist/security.js.map +1 -0
- package/dist/setup.d.ts +21 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +261 -0
- package/dist/setup.js.map +1 -0
- package/dist/summarizer.d.ts +30 -0
- package/dist/summarizer.d.ts.map +1 -0
- package/dist/summarizer.js +139 -0
- package/dist/summarizer.js.map +1 -0
- package/dist/sync.d.ts +39 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +356 -0
- package/dist/sync.js.map +1 -0
- package/dist/types.d.ts +267 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/dist/vectors.d.ts +103 -0
- package/dist/vectors.d.ts.map +1 -0
- package/dist/vectors.js +311 -0
- package/dist/vectors.js.map +1 -0
- package/package.json +73 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wyrm CLI - Beautiful command-line interface
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2026 Ghost Protocol (Pvt) Ltd. All Rights Reserved.
|
|
5
|
+
* @license Proprietary - See LICENSE file for details.
|
|
6
|
+
* @module cli
|
|
7
|
+
* @version 3.0.0
|
|
8
|
+
*/
|
|
9
|
+
export declare const colors: {
|
|
10
|
+
reset: string;
|
|
11
|
+
bold: string;
|
|
12
|
+
dim: string;
|
|
13
|
+
italic: string;
|
|
14
|
+
underline: string;
|
|
15
|
+
black: string;
|
|
16
|
+
red: string;
|
|
17
|
+
green: string;
|
|
18
|
+
yellow: string;
|
|
19
|
+
blue: string;
|
|
20
|
+
magenta: string;
|
|
21
|
+
cyan: string;
|
|
22
|
+
white: string;
|
|
23
|
+
brightRed: string;
|
|
24
|
+
brightGreen: string;
|
|
25
|
+
brightYellow: string;
|
|
26
|
+
brightBlue: string;
|
|
27
|
+
brightMagenta: string;
|
|
28
|
+
brightCyan: string;
|
|
29
|
+
bgRed: string;
|
|
30
|
+
bgGreen: string;
|
|
31
|
+
bgYellow: string;
|
|
32
|
+
bgBlue: string;
|
|
33
|
+
bgMagenta: string;
|
|
34
|
+
bgCyan: string;
|
|
35
|
+
};
|
|
36
|
+
export declare const c: {
|
|
37
|
+
bold: (s: string) => string;
|
|
38
|
+
dim: (s: string) => string;
|
|
39
|
+
red: (s: string) => string;
|
|
40
|
+
green: (s: string) => string;
|
|
41
|
+
yellow: (s: string) => string;
|
|
42
|
+
blue: (s: string) => string;
|
|
43
|
+
magenta: (s: string) => string;
|
|
44
|
+
cyan: (s: string) => string;
|
|
45
|
+
primary: (s: string) => string;
|
|
46
|
+
success: (s: string) => string;
|
|
47
|
+
warning: (s: string) => string;
|
|
48
|
+
error: (s: string) => string;
|
|
49
|
+
};
|
|
50
|
+
export declare const icons: {
|
|
51
|
+
dragon: string;
|
|
52
|
+
fire: string;
|
|
53
|
+
scroll: string;
|
|
54
|
+
sword: string;
|
|
55
|
+
shield: string;
|
|
56
|
+
treasure: string;
|
|
57
|
+
quest: string;
|
|
58
|
+
check: string;
|
|
59
|
+
cross: string;
|
|
60
|
+
arrow: string;
|
|
61
|
+
bullet: string;
|
|
62
|
+
star: string;
|
|
63
|
+
warning: string;
|
|
64
|
+
error: string;
|
|
65
|
+
success: string;
|
|
66
|
+
info: string;
|
|
67
|
+
clock: string;
|
|
68
|
+
folder: string;
|
|
69
|
+
file: string;
|
|
70
|
+
lock: string;
|
|
71
|
+
unlock: string;
|
|
72
|
+
sync: string;
|
|
73
|
+
search: string;
|
|
74
|
+
sparkle: string;
|
|
75
|
+
};
|
|
76
|
+
export declare const priorityIcons: Record<string, string>;
|
|
77
|
+
export declare const BANNER: string;
|
|
78
|
+
export declare const MINI_BANNER: string;
|
|
79
|
+
/**
|
|
80
|
+
* Progress spinner
|
|
81
|
+
*/
|
|
82
|
+
export declare class Spinner {
|
|
83
|
+
private frames;
|
|
84
|
+
private current;
|
|
85
|
+
private interval;
|
|
86
|
+
private text;
|
|
87
|
+
constructor(text?: string);
|
|
88
|
+
start(): void;
|
|
89
|
+
update(text: string): void;
|
|
90
|
+
succeed(text?: string): void;
|
|
91
|
+
fail(text?: string): void;
|
|
92
|
+
warn(text?: string): void;
|
|
93
|
+
stop(): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Progress bar
|
|
97
|
+
*/
|
|
98
|
+
export declare class ProgressBar {
|
|
99
|
+
private total;
|
|
100
|
+
private current;
|
|
101
|
+
private width;
|
|
102
|
+
private label;
|
|
103
|
+
constructor(total: number, label?: string, width?: number);
|
|
104
|
+
update(current: number, label?: string): void;
|
|
105
|
+
increment(label?: string): void;
|
|
106
|
+
private render;
|
|
107
|
+
complete(): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Table formatter
|
|
111
|
+
*/
|
|
112
|
+
export declare function formatTable(headers: string[], rows: string[][], options?: {
|
|
113
|
+
padding?: number;
|
|
114
|
+
border?: boolean;
|
|
115
|
+
}): string;
|
|
116
|
+
/**
|
|
117
|
+
* Box formatter
|
|
118
|
+
*/
|
|
119
|
+
export declare function formatBox(title: string, content: string, width?: number): string;
|
|
120
|
+
/**
|
|
121
|
+
* Format bytes to human readable
|
|
122
|
+
*/
|
|
123
|
+
export declare function formatBytes(bytes: number): string;
|
|
124
|
+
/**
|
|
125
|
+
* Format duration
|
|
126
|
+
*/
|
|
127
|
+
export declare function formatDuration(ms: number): string;
|
|
128
|
+
/**
|
|
129
|
+
* Print section header
|
|
130
|
+
*/
|
|
131
|
+
export declare function printSection(title: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* Print success message
|
|
134
|
+
*/
|
|
135
|
+
export declare function printSuccess(message: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Print error message
|
|
138
|
+
*/
|
|
139
|
+
export declare function printError(message: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Print warning message
|
|
142
|
+
*/
|
|
143
|
+
export declare function printWarning(message: string): void;
|
|
144
|
+
/**
|
|
145
|
+
* Print info message
|
|
146
|
+
*/
|
|
147
|
+
export declare function printInfo(message: string): void;
|
|
148
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;CAmClB,CAAC;AAGF,eAAO,MAAM,CAAC;cACF,MAAM;aACP,MAAM;aACN,MAAM;eACJ,MAAM;gBACL,MAAM;cACR,MAAM;iBACH,MAAM;cACT,MAAM;iBACH,MAAM;iBACN,MAAM;iBACN,MAAM;eACR,MAAM;CAClB,CAAC;AAGF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjB,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKhD,CAAC;AAGF,eAAO,MAAM,MAAM,QASlB,CAAC;AAEF,eAAO,MAAM,WAAW,QAAyD,CAAC;AAElF;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,SAAe;IAI/B,KAAK,IAAI,IAAI;IAOb,MAAM,CAAC,IAA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AAM,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wyrm CLI - Beautiful command-line interface
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2026 Ghost Protocol (Pvt) Ltd. All Rights Reserved.
|
|
5
|
+
* @license Proprietary - See LICENSE file for details.
|
|
6
|
+
* @module cli
|
|
7
|
+
* @version 3.0.0
|
|
8
|
+
*/
|
|
9
|
+
// ANSI color codes
|
|
10
|
+
export const colors = {
|
|
11
|
+
// Reset
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
// Styles
|
|
14
|
+
bold: '\x1b[1m',
|
|
15
|
+
dim: '\x1b[2m',
|
|
16
|
+
italic: '\x1b[3m',
|
|
17
|
+
underline: '\x1b[4m',
|
|
18
|
+
// Colors
|
|
19
|
+
black: '\x1b[30m',
|
|
20
|
+
red: '\x1b[31m',
|
|
21
|
+
green: '\x1b[32m',
|
|
22
|
+
yellow: '\x1b[33m',
|
|
23
|
+
blue: '\x1b[34m',
|
|
24
|
+
magenta: '\x1b[35m',
|
|
25
|
+
cyan: '\x1b[36m',
|
|
26
|
+
white: '\x1b[37m',
|
|
27
|
+
// Bright colors
|
|
28
|
+
brightRed: '\x1b[91m',
|
|
29
|
+
brightGreen: '\x1b[92m',
|
|
30
|
+
brightYellow: '\x1b[93m',
|
|
31
|
+
brightBlue: '\x1b[94m',
|
|
32
|
+
brightMagenta: '\x1b[95m',
|
|
33
|
+
brightCyan: '\x1b[96m',
|
|
34
|
+
// Background
|
|
35
|
+
bgRed: '\x1b[41m',
|
|
36
|
+
bgGreen: '\x1b[42m',
|
|
37
|
+
bgYellow: '\x1b[43m',
|
|
38
|
+
bgBlue: '\x1b[44m',
|
|
39
|
+
bgMagenta: '\x1b[45m',
|
|
40
|
+
bgCyan: '\x1b[46m',
|
|
41
|
+
};
|
|
42
|
+
// Helper functions
|
|
43
|
+
export const c = {
|
|
44
|
+
bold: (s) => `${colors.bold}${s}${colors.reset}`,
|
|
45
|
+
dim: (s) => `${colors.dim}${s}${colors.reset}`,
|
|
46
|
+
red: (s) => `${colors.red}${s}${colors.reset}`,
|
|
47
|
+
green: (s) => `${colors.green}${s}${colors.reset}`,
|
|
48
|
+
yellow: (s) => `${colors.yellow}${s}${colors.reset}`,
|
|
49
|
+
blue: (s) => `${colors.blue}${s}${colors.reset}`,
|
|
50
|
+
magenta: (s) => `${colors.magenta}${s}${colors.reset}`,
|
|
51
|
+
cyan: (s) => `${colors.cyan}${s}${colors.reset}`,
|
|
52
|
+
primary: (s) => `${colors.brightMagenta}${s}${colors.reset}`,
|
|
53
|
+
success: (s) => `${colors.brightGreen}${s}${colors.reset}`,
|
|
54
|
+
warning: (s) => `${colors.brightYellow}${s}${colors.reset}`,
|
|
55
|
+
error: (s) => `${colors.brightRed}${s}${colors.reset}`,
|
|
56
|
+
};
|
|
57
|
+
// Icons
|
|
58
|
+
export const icons = {
|
|
59
|
+
dragon: '🐉',
|
|
60
|
+
fire: '🔥',
|
|
61
|
+
scroll: '📜',
|
|
62
|
+
sword: '⚔️',
|
|
63
|
+
shield: '🛡️',
|
|
64
|
+
treasure: '💎',
|
|
65
|
+
quest: '🎯',
|
|
66
|
+
check: '✓',
|
|
67
|
+
cross: '✗',
|
|
68
|
+
arrow: '→',
|
|
69
|
+
bullet: '•',
|
|
70
|
+
star: '★',
|
|
71
|
+
warning: '⚠️',
|
|
72
|
+
error: '❌',
|
|
73
|
+
success: '✅',
|
|
74
|
+
info: 'ℹ️',
|
|
75
|
+
clock: '🕐',
|
|
76
|
+
folder: '📁',
|
|
77
|
+
file: '📄',
|
|
78
|
+
lock: '🔒',
|
|
79
|
+
unlock: '🔓',
|
|
80
|
+
sync: '🔄',
|
|
81
|
+
search: '🔍',
|
|
82
|
+
sparkle: '✨',
|
|
83
|
+
};
|
|
84
|
+
// Priority icons
|
|
85
|
+
export const priorityIcons = {
|
|
86
|
+
critical: '🔴',
|
|
87
|
+
high: '🟠',
|
|
88
|
+
medium: '🟡',
|
|
89
|
+
low: '🟢',
|
|
90
|
+
};
|
|
91
|
+
// ASCII art banner
|
|
92
|
+
export const BANNER = `
|
|
93
|
+
${colors.brightMagenta}██╗ ██╗██╗ ██╗██████╗ ███╗ ███╗${colors.reset}
|
|
94
|
+
${colors.brightMagenta}██║ ██║╚██╗ ██╔╝██╔══██╗████╗ ████║${colors.reset}
|
|
95
|
+
${colors.brightMagenta}██║ █╗ ██║ ╚████╔╝ ██████╔╝██╔████╔██║${colors.reset}
|
|
96
|
+
${colors.brightMagenta}██║███╗██║ ╚██╔╝ ██╔══██╗██║╚██╔╝██║${colors.reset}
|
|
97
|
+
${colors.brightMagenta}╚███╔███╔╝ ██║ ██║ ██║██║ ╚═╝ ██║${colors.reset}
|
|
98
|
+
${colors.brightMagenta} ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝${colors.reset}
|
|
99
|
+
${colors.dim} Persistent AI Memory System v3.0.0${colors.reset}
|
|
100
|
+
${colors.dim} ghosts.lk${colors.reset}
|
|
101
|
+
`;
|
|
102
|
+
export const MINI_BANNER = `${colors.brightMagenta}🐉 Wyrm v3.0.0${colors.reset}`;
|
|
103
|
+
/**
|
|
104
|
+
* Progress spinner
|
|
105
|
+
*/
|
|
106
|
+
export class Spinner {
|
|
107
|
+
frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
108
|
+
current = 0;
|
|
109
|
+
interval = null;
|
|
110
|
+
text;
|
|
111
|
+
constructor(text = 'Loading...') {
|
|
112
|
+
this.text = text;
|
|
113
|
+
}
|
|
114
|
+
start() {
|
|
115
|
+
this.interval = setInterval(() => {
|
|
116
|
+
process.stdout.write(`\r${colors.cyan}${this.frames[this.current]}${colors.reset} ${this.text}`);
|
|
117
|
+
this.current = (this.current + 1) % this.frames.length;
|
|
118
|
+
}, 80);
|
|
119
|
+
}
|
|
120
|
+
update(text) {
|
|
121
|
+
this.text = text;
|
|
122
|
+
}
|
|
123
|
+
succeed(text) {
|
|
124
|
+
this.stop();
|
|
125
|
+
console.log(`\r${c.success('✓')} ${text || this.text}`);
|
|
126
|
+
}
|
|
127
|
+
fail(text) {
|
|
128
|
+
this.stop();
|
|
129
|
+
console.log(`\r${c.error('✗')} ${text || this.text}`);
|
|
130
|
+
}
|
|
131
|
+
warn(text) {
|
|
132
|
+
this.stop();
|
|
133
|
+
console.log(`\r${c.warning('!')} ${text || this.text}`);
|
|
134
|
+
}
|
|
135
|
+
stop() {
|
|
136
|
+
if (this.interval) {
|
|
137
|
+
clearInterval(this.interval);
|
|
138
|
+
this.interval = null;
|
|
139
|
+
process.stdout.write('\r\x1b[K'); // Clear line
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Progress bar
|
|
145
|
+
*/
|
|
146
|
+
export class ProgressBar {
|
|
147
|
+
total;
|
|
148
|
+
current = 0;
|
|
149
|
+
width;
|
|
150
|
+
label;
|
|
151
|
+
constructor(total, label = 'Progress', width = 30) {
|
|
152
|
+
this.total = total;
|
|
153
|
+
this.width = width;
|
|
154
|
+
this.label = label;
|
|
155
|
+
}
|
|
156
|
+
update(current, label) {
|
|
157
|
+
this.current = current;
|
|
158
|
+
if (label)
|
|
159
|
+
this.label = label;
|
|
160
|
+
this.render();
|
|
161
|
+
}
|
|
162
|
+
increment(label) {
|
|
163
|
+
this.update(this.current + 1, label);
|
|
164
|
+
}
|
|
165
|
+
render() {
|
|
166
|
+
const percent = Math.min(100, Math.floor((this.current / this.total) * 100));
|
|
167
|
+
const filled = Math.floor((this.current / this.total) * this.width);
|
|
168
|
+
const empty = this.width - filled;
|
|
169
|
+
const bar = `${colors.brightMagenta}${'█'.repeat(filled)}${colors.dim}${'░'.repeat(empty)}${colors.reset}`;
|
|
170
|
+
const percentStr = `${percent}%`.padStart(4);
|
|
171
|
+
process.stdout.write(`\r${this.label} ${bar} ${percentStr} (${this.current}/${this.total})`);
|
|
172
|
+
}
|
|
173
|
+
complete() {
|
|
174
|
+
this.update(this.total);
|
|
175
|
+
console.log(); // New line
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Table formatter
|
|
180
|
+
*/
|
|
181
|
+
export function formatTable(headers, rows, options = {}) {
|
|
182
|
+
const { padding = 2, border = true } = options;
|
|
183
|
+
// Calculate column widths
|
|
184
|
+
const widths = headers.map((h, i) => {
|
|
185
|
+
const maxRow = Math.max(...rows.map(r => (r[i] || '').length));
|
|
186
|
+
return Math.max(h.length, maxRow);
|
|
187
|
+
});
|
|
188
|
+
const pad = (s, w) => s.padEnd(w);
|
|
189
|
+
const sep = widths.map(w => '─'.repeat(w + padding)).join(border ? '┼' : ' ');
|
|
190
|
+
let output = '';
|
|
191
|
+
// Header
|
|
192
|
+
if (border) {
|
|
193
|
+
output += `${colors.dim}┌${widths.map(w => '─'.repeat(w + padding)).join('┬')}┐${colors.reset}\n`;
|
|
194
|
+
}
|
|
195
|
+
output += (border ? `${colors.dim}│${colors.reset}` : '') +
|
|
196
|
+
headers.map((h, i) => ` ${c.bold(pad(h, widths[i]))} `).join(border ? `${colors.dim}│${colors.reset}` : '') +
|
|
197
|
+
(border ? `${colors.dim}│${colors.reset}` : '') + '\n';
|
|
198
|
+
if (border) {
|
|
199
|
+
output += `${colors.dim}├${sep}┤${colors.reset}\n`;
|
|
200
|
+
}
|
|
201
|
+
// Rows
|
|
202
|
+
for (const row of rows) {
|
|
203
|
+
output += (border ? `${colors.dim}│${colors.reset}` : '') +
|
|
204
|
+
row.map((cell, i) => ` ${pad(cell || '', widths[i])} `).join(border ? `${colors.dim}│${colors.reset}` : '') +
|
|
205
|
+
(border ? `${colors.dim}│${colors.reset}` : '') + '\n';
|
|
206
|
+
}
|
|
207
|
+
if (border) {
|
|
208
|
+
output += `${colors.dim}└${widths.map(w => '─'.repeat(w + padding)).join('┴')}┘${colors.reset}`;
|
|
209
|
+
}
|
|
210
|
+
return output;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Box formatter
|
|
214
|
+
*/
|
|
215
|
+
export function formatBox(title, content, width = 50) {
|
|
216
|
+
const lines = content.split('\n');
|
|
217
|
+
const maxLen = Math.max(title.length, ...lines.map(l => l.length), width);
|
|
218
|
+
let output = `${colors.dim}╭${'─'.repeat(maxLen + 2)}╮${colors.reset}\n`;
|
|
219
|
+
output += `${colors.dim}│${colors.reset} ${c.bold(title.padEnd(maxLen))} ${colors.dim}│${colors.reset}\n`;
|
|
220
|
+
output += `${colors.dim}├${'─'.repeat(maxLen + 2)}┤${colors.reset}\n`;
|
|
221
|
+
for (const line of lines) {
|
|
222
|
+
output += `${colors.dim}│${colors.reset} ${line.padEnd(maxLen)} ${colors.dim}│${colors.reset}\n`;
|
|
223
|
+
}
|
|
224
|
+
output += `${colors.dim}╰${'─'.repeat(maxLen + 2)}╯${colors.reset}`;
|
|
225
|
+
return output;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Format bytes to human readable
|
|
229
|
+
*/
|
|
230
|
+
export function formatBytes(bytes) {
|
|
231
|
+
if (bytes === 0)
|
|
232
|
+
return '0 B';
|
|
233
|
+
const k = 1024;
|
|
234
|
+
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
235
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
236
|
+
return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Format duration
|
|
240
|
+
*/
|
|
241
|
+
export function formatDuration(ms) {
|
|
242
|
+
if (ms < 1000)
|
|
243
|
+
return `${ms}ms`;
|
|
244
|
+
if (ms < 60000)
|
|
245
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
246
|
+
if (ms < 3600000)
|
|
247
|
+
return `${Math.floor(ms / 60000)}m ${Math.floor((ms % 60000) / 1000)}s`;
|
|
248
|
+
return `${Math.floor(ms / 3600000)}h ${Math.floor((ms % 3600000) / 60000)}m`;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Print section header
|
|
252
|
+
*/
|
|
253
|
+
export function printSection(title) {
|
|
254
|
+
console.log(`\n${c.bold(c.primary(`▶ ${title}`))}`);
|
|
255
|
+
console.log(`${colors.dim}${'─'.repeat(title.length + 4)}${colors.reset}`);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Print success message
|
|
259
|
+
*/
|
|
260
|
+
export function printSuccess(message) {
|
|
261
|
+
console.log(`${icons.success} ${c.success(message)}`);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Print error message
|
|
265
|
+
*/
|
|
266
|
+
export function printError(message) {
|
|
267
|
+
console.log(`${icons.error} ${c.error(message)}`);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Print warning message
|
|
271
|
+
*/
|
|
272
|
+
export function printWarning(message) {
|
|
273
|
+
console.log(`${icons.warning} ${c.warning(message)}`);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Print info message
|
|
277
|
+
*/
|
|
278
|
+
export function printInfo(message) {
|
|
279
|
+
console.log(`${icons.info} ${message}`);
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mBAAmB;AACnB,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,QAAQ;I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AAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wyrm Cloud Backup — Encrypted backup/restore to Cloudflare R2
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2026 Ghost Protocol (Pvt) Ltd. All Rights Reserved.
|
|
5
|
+
* @license Proprietary - See LICENSE file for details.
|
|
6
|
+
* @module cloud-backup
|
|
7
|
+
* @version 3.2.0
|
|
8
|
+
*/
|
|
9
|
+
export interface CloudConfig {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
bucket: string;
|
|
12
|
+
accessKeyId: string;
|
|
13
|
+
secretAccessKey: string;
|
|
14
|
+
region?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BackupMetadata {
|
|
17
|
+
version: number;
|
|
18
|
+
wyrm_version: string;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
db_size: number;
|
|
21
|
+
compressed_size: number;
|
|
22
|
+
encrypted: boolean;
|
|
23
|
+
machine_id: string;
|
|
24
|
+
checksum: string;
|
|
25
|
+
}
|
|
26
|
+
interface S3ListObject {
|
|
27
|
+
key: string;
|
|
28
|
+
size: number;
|
|
29
|
+
lastModified: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Encrypt a buffer with AES-256-GCM using a password.
|
|
33
|
+
* Output format: [16-byte IV][32-byte salt][16-byte auth tag][encrypted data]
|
|
34
|
+
*/
|
|
35
|
+
declare function encryptBuffer(data: Buffer, password: string): Buffer;
|
|
36
|
+
/**
|
|
37
|
+
* Decrypt a buffer encrypted by encryptBuffer.
|
|
38
|
+
* Parses the [IV][salt][tag][data] header, derives key, decrypts.
|
|
39
|
+
*/
|
|
40
|
+
declare function decryptBuffer(encrypted: Buffer, password: string): Buffer;
|
|
41
|
+
export declare class WyrmCloudBackup {
|
|
42
|
+
private config;
|
|
43
|
+
private encryptionKey;
|
|
44
|
+
private s3;
|
|
45
|
+
constructor();
|
|
46
|
+
/** Configure cloud storage credentials and optional encryption key */
|
|
47
|
+
configure(config: CloudConfig, encryptionKey?: string): void;
|
|
48
|
+
/** Check if cloud backup is configured */
|
|
49
|
+
isConfigured(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Backup: SQLite DB → gzip → AES-256-GCM encrypt → upload to R2
|
|
52
|
+
*
|
|
53
|
+
* Pipeline:
|
|
54
|
+
* 1. Copy SQLite file to a temp snapshot (safe point-in-time copy)
|
|
55
|
+
* 2. Gzip compress
|
|
56
|
+
* 3. If encryption key set: AES-256-GCM encrypt the gzipped blob
|
|
57
|
+
* 4. Upload encrypted/compressed blob to R2
|
|
58
|
+
* 5. Upload metadata JSON alongside
|
|
59
|
+
* 6. Clean up temp files
|
|
60
|
+
*
|
|
61
|
+
* Key format: backups/{machine_id}/{YYYY-MM-DD_HHmmss}.wyrm.bak
|
|
62
|
+
*/
|
|
63
|
+
backup(dbPath: string): Promise<{
|
|
64
|
+
key: string;
|
|
65
|
+
metadata: BackupMetadata;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* List available backups for this machine, sorted newest-first.
|
|
69
|
+
* Fetches metadata JSON for each backup.
|
|
70
|
+
*/
|
|
71
|
+
listBackups(): Promise<BackupMetadata[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Restore: Download from R2 → decrypt → gunzip → write to target path.
|
|
74
|
+
*
|
|
75
|
+
* If the target file already exists, it is renamed to `{target}.bak` before overwriting.
|
|
76
|
+
* Verifies checksum of the downloaded blob against metadata.
|
|
77
|
+
*/
|
|
78
|
+
restore(backupKey: string, targetPath: string): Promise<{
|
|
79
|
+
restored: boolean;
|
|
80
|
+
size: number;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete old backups, keeping the most recent `keepCount`.
|
|
84
|
+
* Deletes both the .wyrm.bak blob and its .wyrm.meta.json sidecar.
|
|
85
|
+
*/
|
|
86
|
+
pruneBackups(keepCount?: number): Promise<{
|
|
87
|
+
deleted: number;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Get a deterministic machine fingerprint for device tracking.
|
|
91
|
+
* Hash of: hostname + platform + arch + first CPU model.
|
|
92
|
+
* Stable across reboots, unique per machine.
|
|
93
|
+
*/
|
|
94
|
+
private getMachineId;
|
|
95
|
+
/** Throw if not configured */
|
|
96
|
+
private assertConfigured;
|
|
97
|
+
}
|
|
98
|
+
export { encryptBuffer, decryptBuffer };
|
|
99
|
+
export type { S3ListObject };
|
|
100
|
+
//# sourceMappingURL=cloud-backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-backup.d.ts","sourceRoot":"","sources":["../src/cloud-backup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,E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