@mainwp/control 1.0.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 +674 -0
- package/README.md +583 -0
- package/bin/_exit.js +12 -0
- package/bin/dev.js +7 -0
- package/bin/run.js +7 -0
- package/dist/chat/chat-engine.d.ts +213 -0
- package/dist/chat/chat-engine.d.ts.map +1 -0
- package/dist/chat/chat-engine.js +636 -0
- package/dist/chat/chat-engine.js.map +1 -0
- package/dist/chat/index.d.ts +10 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +14 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/providers/anthropic.d.ts +52 -0
- package/dist/chat/providers/anthropic.d.ts.map +1 -0
- package/dist/chat/providers/anthropic.js +292 -0
- package/dist/chat/providers/anthropic.js.map +1 -0
- package/dist/chat/providers/gemini.d.ts +52 -0
- package/dist/chat/providers/gemini.d.ts.map +1 -0
- package/dist/chat/providers/gemini.js +284 -0
- package/dist/chat/providers/gemini.js.map +1 -0
- package/dist/chat/providers/index.d.ts +19 -0
- package/dist/chat/providers/index.d.ts.map +1 -0
- package/dist/chat/providers/index.js +23 -0
- package/dist/chat/providers/index.js.map +1 -0
- package/dist/chat/providers/local.d.ts +37 -0
- package/dist/chat/providers/local.d.ts.map +1 -0
- package/dist/chat/providers/local.js +130 -0
- package/dist/chat/providers/local.js.map +1 -0
- package/dist/chat/providers/openai-compatible.d.ts +155 -0
- package/dist/chat/providers/openai-compatible.d.ts.map +1 -0
- package/dist/chat/providers/openai-compatible.js +264 -0
- package/dist/chat/providers/openai-compatible.js.map +1 -0
- package/dist/chat/providers/openai.d.ts +24 -0
- package/dist/chat/providers/openai.d.ts.map +1 -0
- package/dist/chat/providers/openai.js +62 -0
- package/dist/chat/providers/openai.js.map +1 -0
- package/dist/chat/providers/openrouter.d.ts +26 -0
- package/dist/chat/providers/openrouter.d.ts.map +1 -0
- package/dist/chat/providers/openrouter.js +65 -0
- package/dist/chat/providers/openrouter.js.map +1 -0
- package/dist/chat/providers/provider-fetch.d.ts +15 -0
- package/dist/chat/providers/provider-fetch.d.ts.map +1 -0
- package/dist/chat/providers/provider-fetch.js +35 -0
- package/dist/chat/providers/provider-fetch.js.map +1 -0
- package/dist/chat/providers/provider.d.ts +214 -0
- package/dist/chat/providers/provider.d.ts.map +1 -0
- package/dist/chat/providers/provider.js +166 -0
- package/dist/chat/providers/provider.js.map +1 -0
- package/dist/chat/providers/sse-reader.d.ts +21 -0
- package/dist/chat/providers/sse-reader.d.ts.map +1 -0
- package/dist/chat/providers/sse-reader.js +48 -0
- package/dist/chat/providers/sse-reader.js.map +1 -0
- package/dist/chat/system-prompt.d.ts +33 -0
- package/dist/chat/system-prompt.d.ts.map +1 -0
- package/dist/chat/system-prompt.js +166 -0
- package/dist/chat/system-prompt.js.map +1 -0
- package/dist/chat/tool-envelope.d.ts +72 -0
- package/dist/chat/tool-envelope.d.ts.map +1 -0
- package/dist/chat/tool-envelope.js +263 -0
- package/dist/chat/tool-envelope.js.map +1 -0
- package/dist/commands/abilities/info.d.ts +21 -0
- package/dist/commands/abilities/info.d.ts.map +1 -0
- package/dist/commands/abilities/info.js +80 -0
- package/dist/commands/abilities/info.js.map +1 -0
- package/dist/commands/abilities/list.d.ts +19 -0
- package/dist/commands/abilities/list.d.ts.map +1 -0
- package/dist/commands/abilities/list.js +98 -0
- package/dist/commands/abilities/list.js.map +1 -0
- package/dist/commands/abilities/run.d.ts +75 -0
- package/dist/commands/abilities/run.d.ts.map +1 -0
- package/dist/commands/abilities/run.js +468 -0
- package/dist/commands/abilities/run.js.map +1 -0
- package/dist/commands/chat.d.ts +54 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +384 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/config/show.d.ts +54 -0
- package/dist/commands/config/show.d.ts.map +1 -0
- package/dist/commands/config/show.js +324 -0
- package/dist/commands/config/show.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +412 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/jobs/watch.d.ts +50 -0
- package/dist/commands/jobs/watch.d.ts.map +1 -0
- package/dist/commands/jobs/watch.js +269 -0
- package/dist/commands/jobs/watch.js.map +1 -0
- package/dist/commands/login.d.ts +25 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +165 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/profile/delete.d.ts +22 -0
- package/dist/commands/profile/delete.d.ts.map +1 -0
- package/dist/commands/profile/delete.js +57 -0
- package/dist/commands/profile/delete.js.map +1 -0
- package/dist/commands/profile/list.d.ts +19 -0
- package/dist/commands/profile/list.d.ts.map +1 -0
- package/dist/commands/profile/list.js +53 -0
- package/dist/commands/profile/list.js.map +1 -0
- package/dist/commands/profile/use.d.ts +22 -0
- package/dist/commands/profile/use.d.ts.map +1 -0
- package/dist/commands/profile/use.js +46 -0
- package/dist/commands/profile/use.js.map +1 -0
- package/dist/config/fs-utils.d.ts +14 -0
- package/dist/config/fs-utils.d.ts.map +1 -0
- package/dist/config/fs-utils.js +31 -0
- package/dist/config/fs-utils.js.map +1 -0
- package/dist/config/keychain.d.ts +53 -0
- package/dist/config/keychain.d.ts.map +1 -0
- package/dist/config/keychain.js +175 -0
- package/dist/config/keychain.js.map +1 -0
- package/dist/config/profile-store.d.ts +85 -0
- package/dist/config/profile-store.d.ts.map +1 -0
- package/dist/config/profile-store.js +228 -0
- package/dist/config/profile-store.js.map +1 -0
- package/dist/config/settings.d.ts +71 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +151 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/core/abilities-executor.d.ts +126 -0
- package/dist/core/abilities-executor.d.ts.map +1 -0
- package/dist/core/abilities-executor.js +264 -0
- package/dist/core/abilities-executor.js.map +1 -0
- package/dist/core/batch-manager.d.ts +113 -0
- package/dist/core/batch-manager.d.ts.map +1 -0
- package/dist/core/batch-manager.js +244 -0
- package/dist/core/batch-manager.js.map +1 -0
- package/dist/core/http-client.d.ts +111 -0
- package/dist/core/http-client.d.ts.map +1 -0
- package/dist/core/http-client.js +329 -0
- package/dist/core/http-client.js.map +1 -0
- package/dist/core/safety-controller.d.ts +114 -0
- package/dist/core/safety-controller.d.ts.map +1 -0
- package/dist/core/safety-controller.js +229 -0
- package/dist/core/safety-controller.js.map +1 -0
- package/dist/hooks/command-not-found.d.ts +12 -0
- package/dist/hooks/command-not-found.d.ts.map +1 -0
- package/dist/hooks/command-not-found.js +58 -0
- package/dist/hooks/command-not-found.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/base-command.d.ts +123 -0
- package/dist/lib/base-command.d.ts.map +1 -0
- package/dist/lib/base-command.js +285 -0
- package/dist/lib/base-command.js.map +1 -0
- package/dist/output/formatter.d.ts +48 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +138 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/json-envelope.d.ts +43 -0
- package/dist/output/json-envelope.d.ts.map +1 -0
- package/dist/output/json-envelope.js +73 -0
- package/dist/output/json-envelope.js.map +1 -0
- package/dist/utils/audit-logger.d.ts +97 -0
- package/dist/utils/audit-logger.d.ts.map +1 -0
- package/dist/utils/audit-logger.js +169 -0
- package/dist/utils/audit-logger.js.map +1 -0
- package/dist/utils/colors.d.ts +29 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/colors.js +36 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/errors.d.ts +107 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +149 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/exit-codes.d.ts +21 -0
- package/dist/utils/exit-codes.d.ts.map +1 -0
- package/dist/utils/exit-codes.js +20 -0
- package/dist/utils/exit-codes.js.map +1 -0
- package/dist/utils/format.d.ts +64 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +69 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/prompt.d.ts +34 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +132 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/retry.d.ts +59 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +96 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/terminal-sanitizer.d.ts +60 -0
- package/dist/utils/terminal-sanitizer.d.ts.map +1 -0
- package/dist/utils/terminal-sanitizer.js +166 -0
- package/dist/utils/terminal-sanitizer.js.map +1 -0
- package/dist/validation/input-sanitizer.d.ts +76 -0
- package/dist/validation/input-sanitizer.d.ts.map +1 -0
- package/dist/validation/input-sanitizer.js +199 -0
- package/dist/validation/input-sanitizer.js.map +1 -0
- package/dist/validation/schema-validator.d.ts +75 -0
- package/dist/validation/schema-validator.d.ts.map +1 -0
- package/dist/validation/schema-validator.js +147 -0
- package/dist/validation/schema-validator.js.map +1 -0
- package/oclif.manifest.json +857 -0
- package/package.json +101 -0
- package/scripts/completions/README.md +221 -0
- package/scripts/completions/mainwpcontrol.bash +193 -0
- package/scripts/completions/mainwpcontrol.zsh +267 -0
- package/scripts/completions/profile-completer.sh +35 -0
- package/scripts/completions/regenerate.sh +78 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent secret masking across all commands.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for customizing secret masking behavior
|
|
8
|
+
*/
|
|
9
|
+
export interface MaskOptions {
|
|
10
|
+
/** Number of characters to show at the start (default: 4) */
|
|
11
|
+
showFirst?: number;
|
|
12
|
+
/** Number of characters to show at the end (default: 4) */
|
|
13
|
+
showLast?: number;
|
|
14
|
+
/** Minimum length before masking applies; shorter secrets return placeholder (default: 8) */
|
|
15
|
+
minLength?: number;
|
|
16
|
+
/** Placeholder string for secrets that are too short to mask (default: '****') */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Masks a secret value by showing only the first and last few characters.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The secret string to mask
|
|
23
|
+
* @param options - Configuration options for masking behavior
|
|
24
|
+
* @returns The masked string in format "xxxx...xxxx" or the placeholder if too short
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* maskSecret('mypassword123') // Returns 'mypa...d123'
|
|
29
|
+
* maskSecret('short') // Returns '****'
|
|
30
|
+
* maskSecret('api-key-12345678', { showFirst: 6, showLast: 4 }) // Returns 'api-ke...5678'
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function maskSecret(value: string, options?: MaskOptions): string;
|
|
34
|
+
/**
|
|
35
|
+
* Masks a password using standard format (4 chars...4 chars).
|
|
36
|
+
*
|
|
37
|
+
* Passwords 8 characters or shorter are fully masked with '****'.
|
|
38
|
+
*
|
|
39
|
+
* @param password - The password to mask
|
|
40
|
+
* @returns The masked password
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* maskPassword('mypassword123') // Returns 'mypa...d123'
|
|
45
|
+
* maskPassword('short') // Returns '****'
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function maskPassword(password: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Masks an API key using standard format (6 chars...4 chars).
|
|
51
|
+
*
|
|
52
|
+
* API keys 10 characters or shorter are fully masked with '****'.
|
|
53
|
+
*
|
|
54
|
+
* @param apiKey - The API key to mask
|
|
55
|
+
* @returns The masked API key
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* maskApiKey('sk-1234567890abcdefghij') // Returns 'sk-123...ghij'
|
|
60
|
+
* maskApiKey('shortkey') // Returns '****'
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function maskApiKey(apiKey: string): string;
|
|
64
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,MAAM,CAa3E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent secret masking across all commands.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Masks a secret value by showing only the first and last few characters.
|
|
8
|
+
*
|
|
9
|
+
* @param value - The secret string to mask
|
|
10
|
+
* @param options - Configuration options for masking behavior
|
|
11
|
+
* @returns The masked string in format "xxxx...xxxx" or the placeholder if too short
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* maskSecret('mypassword123') // Returns 'mypa...d123'
|
|
16
|
+
* maskSecret('short') // Returns '****'
|
|
17
|
+
* maskSecret('api-key-12345678', { showFirst: 6, showLast: 4 }) // Returns 'api-ke...5678'
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function maskSecret(value, options = {}) {
|
|
21
|
+
const { showFirst = 4, showLast = 4, minLength = 8, placeholder = '****', } = options;
|
|
22
|
+
if (!value || value.length <= minLength) {
|
|
23
|
+
return placeholder;
|
|
24
|
+
}
|
|
25
|
+
return `${value.substring(0, showFirst)}...${value.substring(value.length - showLast)}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Masks a password using standard format (4 chars...4 chars).
|
|
29
|
+
*
|
|
30
|
+
* Passwords 8 characters or shorter are fully masked with '****'.
|
|
31
|
+
*
|
|
32
|
+
* @param password - The password to mask
|
|
33
|
+
* @returns The masked password
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* maskPassword('mypassword123') // Returns 'mypa...d123'
|
|
38
|
+
* maskPassword('short') // Returns '****'
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function maskPassword(password) {
|
|
42
|
+
return maskSecret(password, {
|
|
43
|
+
showFirst: 4,
|
|
44
|
+
showLast: 4,
|
|
45
|
+
minLength: 8,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Masks an API key using standard format (6 chars...4 chars).
|
|
50
|
+
*
|
|
51
|
+
* API keys 10 characters or shorter are fully masked with '****'.
|
|
52
|
+
*
|
|
53
|
+
* @param apiKey - The API key to mask
|
|
54
|
+
* @returns The masked API key
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* maskApiKey('sk-1234567890abcdefghij') // Returns 'sk-123...ghij'
|
|
59
|
+
* maskApiKey('shortkey') // Returns '****'
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function maskApiKey(apiKey) {
|
|
63
|
+
return maskSecret(apiKey, {
|
|
64
|
+
showFirst: 6,
|
|
65
|
+
showLast: 4,
|
|
66
|
+
minLength: 10,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,UAAuB,EAAE;IACjE,MAAM,EACJ,SAAS,GAAG,CAAC,EACb,QAAQ,GAAG,CAAC,EACZ,SAAS,GAAG,CAAC,EACb,WAAW,GAAG,MAAM,GACrB,GAAG,OAAO,CAAC;IAEZ,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QACxC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC;AAC1F,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,UAAU,CAAC,QAAQ,EAAE;QAC1B,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,CAAC;KACb,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,UAAU,CAAC,MAAM,EAAE;QACxB,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,EAAE;KACd,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive prompting utilities for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Handles user confirmation for destructive actions.
|
|
5
|
+
* Auto-declines in non-interactive mode unless explicit flags are used.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Check if we're in an interactive terminal
|
|
9
|
+
*/
|
|
10
|
+
export declare function isInteractive(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Prompt for yes/no confirmation
|
|
13
|
+
*
|
|
14
|
+
* @param question - The question to ask
|
|
15
|
+
* @param defaultAnswer - Default answer if user just presses Enter (default: false)
|
|
16
|
+
* @returns true if user confirmed, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare function promptForConfirmation(question: string, defaultAnswer?: boolean): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Prompt for text input
|
|
21
|
+
*
|
|
22
|
+
* @param question - The question to ask
|
|
23
|
+
* @param defaultValue - Default value if user just presses Enter
|
|
24
|
+
* @returns The user's input (or default)
|
|
25
|
+
*/
|
|
26
|
+
export declare function promptForInput(question: string, defaultValue?: string): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Prompt for password input (hidden)
|
|
29
|
+
*
|
|
30
|
+
* @param question - The question to ask
|
|
31
|
+
* @returns The user's input
|
|
32
|
+
*/
|
|
33
|
+
export declare function promptForPassword(question: string): Promise<string>;
|
|
34
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAoBD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,aAAa,UAAQ,GACpB,OAAO,CAAC,OAAO,CAAC,CAalB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsEzE"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive prompting utilities for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Handles user confirmation for destructive actions.
|
|
5
|
+
* Auto-declines in non-interactive mode unless explicit flags are used.
|
|
6
|
+
*/
|
|
7
|
+
import * as readline from 'node:readline';
|
|
8
|
+
import { colors, color } from './colors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Check if we're in an interactive terminal
|
|
11
|
+
*/
|
|
12
|
+
export function isInteractive() {
|
|
13
|
+
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Ask a single question via readline, returning the raw answer.
|
|
17
|
+
* Handles interface creation and cleanup.
|
|
18
|
+
*/
|
|
19
|
+
function ask(promptText) {
|
|
20
|
+
const rl = readline.createInterface({
|
|
21
|
+
input: process.stdin,
|
|
22
|
+
output: process.stdout,
|
|
23
|
+
});
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
rl.question(promptText, (answer) => {
|
|
26
|
+
rl.close();
|
|
27
|
+
resolve(answer);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Prompt for yes/no confirmation
|
|
33
|
+
*
|
|
34
|
+
* @param question - The question to ask
|
|
35
|
+
* @param defaultAnswer - Default answer if user just presses Enter (default: false)
|
|
36
|
+
* @returns true if user confirmed, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
export async function promptForConfirmation(question, defaultAnswer = false) {
|
|
39
|
+
if (!isInteractive()) {
|
|
40
|
+
return defaultAnswer;
|
|
41
|
+
}
|
|
42
|
+
const hint = defaultAnswer ? '[Y/n]' : '[y/N]';
|
|
43
|
+
const prompt = color('? ', colors.yellow) + question + ' ' + color(hint, colors.dim) + ' ';
|
|
44
|
+
const answer = await ask(prompt);
|
|
45
|
+
const normalized = answer.trim().toLowerCase();
|
|
46
|
+
if (normalized === '')
|
|
47
|
+
return defaultAnswer;
|
|
48
|
+
return normalized === 'y' || normalized === 'yes';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Prompt for text input
|
|
52
|
+
*
|
|
53
|
+
* @param question - The question to ask
|
|
54
|
+
* @param defaultValue - Default value if user just presses Enter
|
|
55
|
+
* @returns The user's input (or default)
|
|
56
|
+
*/
|
|
57
|
+
export async function promptForInput(question, defaultValue) {
|
|
58
|
+
if (!isInteractive()) {
|
|
59
|
+
return defaultValue ?? '';
|
|
60
|
+
}
|
|
61
|
+
const defaultHint = defaultValue ? color(` (${defaultValue})`, colors.dim) : '';
|
|
62
|
+
const prompt = color('? ', colors.yellow) + question + defaultHint + ' ';
|
|
63
|
+
const answer = await ask(prompt);
|
|
64
|
+
return answer.trim() || defaultValue || '';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Prompt for password input (hidden)
|
|
68
|
+
*
|
|
69
|
+
* @param question - The question to ask
|
|
70
|
+
* @returns The user's input
|
|
71
|
+
*/
|
|
72
|
+
export async function promptForPassword(question) {
|
|
73
|
+
if (!isInteractive()) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
const rl = readline.createInterface({
|
|
77
|
+
input: process.stdin,
|
|
78
|
+
output: process.stdout,
|
|
79
|
+
});
|
|
80
|
+
// Hide input
|
|
81
|
+
const stdin = process.stdin;
|
|
82
|
+
const originalRawMode = stdin.isRaw;
|
|
83
|
+
return new Promise((resolve) => {
|
|
84
|
+
const prompt = color('? ', colors.yellow) + question + ' ';
|
|
85
|
+
process.stdout.write(prompt);
|
|
86
|
+
let input = '';
|
|
87
|
+
// Enable raw mode to capture individual keystrokes
|
|
88
|
+
if (stdin.isTTY && stdin.setRawMode) {
|
|
89
|
+
stdin.setRawMode(true);
|
|
90
|
+
}
|
|
91
|
+
const onData = (char) => {
|
|
92
|
+
const c = char.toString('utf8');
|
|
93
|
+
switch (c) {
|
|
94
|
+
case '\n':
|
|
95
|
+
case '\r':
|
|
96
|
+
case '\u0004': // Ctrl-D
|
|
97
|
+
// Restore raw mode and cleanup
|
|
98
|
+
if (stdin.isTTY && stdin.setRawMode) {
|
|
99
|
+
stdin.setRawMode(originalRawMode ?? false);
|
|
100
|
+
}
|
|
101
|
+
stdin.removeListener('data', onData);
|
|
102
|
+
rl.close();
|
|
103
|
+
process.stdout.write('\n');
|
|
104
|
+
resolve(input);
|
|
105
|
+
break;
|
|
106
|
+
case '\u0003': // Ctrl-C
|
|
107
|
+
// Restore raw mode and exit
|
|
108
|
+
if (stdin.isTTY && stdin.setRawMode) {
|
|
109
|
+
stdin.setRawMode(originalRawMode ?? false);
|
|
110
|
+
}
|
|
111
|
+
stdin.removeListener('data', onData);
|
|
112
|
+
rl.close();
|
|
113
|
+
process.stdout.write('\n');
|
|
114
|
+
process.exit(1);
|
|
115
|
+
break;
|
|
116
|
+
case '\u007F': // Backspace
|
|
117
|
+
if (input.length > 0) {
|
|
118
|
+
input = input.slice(0, -1);
|
|
119
|
+
// Clear character from display
|
|
120
|
+
process.stdout.write('\b \b');
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
// Regular character - add to input, show asterisk
|
|
125
|
+
input += c;
|
|
126
|
+
process.stdout.write('*');
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
stdin.on('data', onData);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/utils/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,QAAQ,MAAM,eAAe,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oBAChB,MAAM;gBAER,KAAK,QAAQ,EAAE,YAAY;oBACzB,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACrB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;wBAC3B,+BAA+B;wBAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBAChC,CAAC;oBACD,MAAM;gBAER;oBACE,kDAAkD;oBAClD,KAAK,IAAI,CAAC,CAAC;oBACX,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC;QAEF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry utilities for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Provides exponential backoff functionality for polling operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Backoff configuration options
|
|
8
|
+
*/
|
|
9
|
+
export interface BackoffOptions {
|
|
10
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
11
|
+
initialDelay?: number | undefined;
|
|
12
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
13
|
+
maxDelay?: number | undefined;
|
|
14
|
+
/** Delay multiplier (default: 2) */
|
|
15
|
+
multiplier?: number | undefined;
|
|
16
|
+
/** Maximum number of retries (default: Infinity) */
|
|
17
|
+
maxRetries?: number | undefined;
|
|
18
|
+
/** Optional abort signal */
|
|
19
|
+
signal?: AbortSignal | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Exponential backoff delay calculator
|
|
23
|
+
*/
|
|
24
|
+
export declare class ExponentialBackoff {
|
|
25
|
+
private readonly initialDelay;
|
|
26
|
+
private readonly maxDelay;
|
|
27
|
+
private readonly multiplier;
|
|
28
|
+
private readonly maxRetries;
|
|
29
|
+
private readonly signal;
|
|
30
|
+
private currentDelay;
|
|
31
|
+
private retryCount;
|
|
32
|
+
constructor(options?: BackoffOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Get the current retry count
|
|
35
|
+
*/
|
|
36
|
+
get attempts(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Get the current delay
|
|
39
|
+
*/
|
|
40
|
+
get delay(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Check if more retries are allowed
|
|
43
|
+
*/
|
|
44
|
+
get canRetry(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Reset the backoff state
|
|
47
|
+
*/
|
|
48
|
+
reset(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Wait for the current delay, then advance to the next interval
|
|
51
|
+
* Returns false if aborted or max retries exceeded
|
|
52
|
+
*/
|
|
53
|
+
wait(): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Get delay for a specific retry attempt (without advancing state)
|
|
56
|
+
*/
|
|
57
|
+
getDelayForAttempt(attempt: number): number;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,4BAA4B;IAC5B,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAYD;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IAEjD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAK;gBAEX,OAAO,GAAE,cAAmB;IASxC;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAkC9B;;OAEG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAK5C"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry utilities for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Provides exponential backoff functionality for polling operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default backoff configuration
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULTS = {
|
|
10
|
+
initialDelay: 1000,
|
|
11
|
+
maxDelay: 30000,
|
|
12
|
+
multiplier: 2,
|
|
13
|
+
maxRetries: Infinity,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Exponential backoff delay calculator
|
|
17
|
+
*/
|
|
18
|
+
export class ExponentialBackoff {
|
|
19
|
+
initialDelay;
|
|
20
|
+
maxDelay;
|
|
21
|
+
multiplier;
|
|
22
|
+
maxRetries;
|
|
23
|
+
signal;
|
|
24
|
+
currentDelay;
|
|
25
|
+
retryCount = 0;
|
|
26
|
+
constructor(options = {}) {
|
|
27
|
+
this.initialDelay = options.initialDelay ?? DEFAULTS.initialDelay;
|
|
28
|
+
this.maxDelay = options.maxDelay ?? DEFAULTS.maxDelay;
|
|
29
|
+
this.multiplier = options.multiplier ?? DEFAULTS.multiplier;
|
|
30
|
+
this.maxRetries = options.maxRetries ?? DEFAULTS.maxRetries;
|
|
31
|
+
this.signal = options.signal;
|
|
32
|
+
this.currentDelay = this.initialDelay;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the current retry count
|
|
36
|
+
*/
|
|
37
|
+
get attempts() {
|
|
38
|
+
return this.retryCount;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the current delay
|
|
42
|
+
*/
|
|
43
|
+
get delay() {
|
|
44
|
+
return this.currentDelay;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if more retries are allowed
|
|
48
|
+
*/
|
|
49
|
+
get canRetry() {
|
|
50
|
+
return this.retryCount < this.maxRetries;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reset the backoff state
|
|
54
|
+
*/
|
|
55
|
+
reset() {
|
|
56
|
+
this.currentDelay = this.initialDelay;
|
|
57
|
+
this.retryCount = 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Wait for the current delay, then advance to the next interval
|
|
61
|
+
* Returns false if aborted or max retries exceeded
|
|
62
|
+
*/
|
|
63
|
+
async wait() {
|
|
64
|
+
if (!this.canRetry) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (this.signal?.aborted) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const delay = this.currentDelay;
|
|
71
|
+
// Create a promise that resolves after delay or rejects on abort
|
|
72
|
+
await new Promise((resolve, reject) => {
|
|
73
|
+
const timeoutId = setTimeout(resolve, delay);
|
|
74
|
+
if (this.signal) {
|
|
75
|
+
this.signal.addEventListener('abort', () => {
|
|
76
|
+
clearTimeout(timeoutId);
|
|
77
|
+
reject(new Error('Backoff aborted'));
|
|
78
|
+
}, { once: true });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Advance to next interval
|
|
82
|
+
this.retryCount++;
|
|
83
|
+
this.currentDelay = Math.min(this.currentDelay * this.multiplier, this.maxDelay);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get delay for a specific retry attempt (without advancing state)
|
|
88
|
+
*/
|
|
89
|
+
getDelayForAttempt(attempt) {
|
|
90
|
+
if (attempt === 0)
|
|
91
|
+
return 0;
|
|
92
|
+
const delay = this.initialDelay * Math.pow(this.multiplier, attempt - 1);
|
|
93
|
+
return Math.min(delay, this.maxDelay);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,QAAQ;CACZ,CAAC;AAEX;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACZ,YAAY,CAAS;IACrB,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,UAAU,CAAS;IACnB,MAAM,CAA0B;IAEzC,YAAY,CAAS;IACrB,UAAU,GAAG,CAAC,CAAC;IAEvB,YAAY,UAA0B,EAAE;QACtC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC;QAClE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;QACtD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,OA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ACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,2BAA2B;QAC3B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEjF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,OAAe;QAChC,IAAI,OAAO,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal Output Sanitizer for mainwpcontrol
|
|
3
|
+
*
|
|
4
|
+
* Security utility to strip ANSI escape sequences and control characters
|
|
5
|
+
* from untrusted data before rendering to terminal output.
|
|
6
|
+
*
|
|
7
|
+
* Prevents:
|
|
8
|
+
* - Terminal escape sequence injection
|
|
9
|
+
* - Fake prompt attacks
|
|
10
|
+
* - Screen manipulation/overwriting
|
|
11
|
+
* - OSC command execution
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Strip all ANSI escape sequences and control characters from a string.
|
|
15
|
+
*
|
|
16
|
+
* This is the core sanitization function that removes:
|
|
17
|
+
* - ANSI CSI sequences (colors, cursor movement, screen control)
|
|
18
|
+
* - OSC sequences (window titles, clipboard commands)
|
|
19
|
+
* - Other escape sequences (DCS, APC, PM, SOS)
|
|
20
|
+
* - C0 control characters (except tab, newline, carriage return)
|
|
21
|
+
* - C1 control characters
|
|
22
|
+
*
|
|
23
|
+
* @param str - The string to sanitize
|
|
24
|
+
* @returns The sanitized string with all escape sequences removed
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripControlChars(str: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Recursively sanitize a value for safe terminal output.
|
|
29
|
+
*
|
|
30
|
+
* Handles:
|
|
31
|
+
* - Strings: strips control characters
|
|
32
|
+
* - Arrays: recursively sanitizes each element
|
|
33
|
+
* - Objects: recursively sanitizes each value
|
|
34
|
+
* - Other types: converted to string and sanitized
|
|
35
|
+
*
|
|
36
|
+
* @param value - The value to sanitize
|
|
37
|
+
* @returns A sanitized copy of the value (original is not modified)
|
|
38
|
+
*/
|
|
39
|
+
export declare function sanitizeForTerminal(value: unknown): unknown;
|
|
40
|
+
/**
|
|
41
|
+
* Sanitize a string for safe display, preserving safe content.
|
|
42
|
+
*
|
|
43
|
+
* This is a convenience wrapper that handles non-string inputs
|
|
44
|
+
* by converting them to JSON first.
|
|
45
|
+
*
|
|
46
|
+
* @param value - The value to sanitize for display
|
|
47
|
+
* @returns A safe string suitable for terminal output
|
|
48
|
+
*/
|
|
49
|
+
export declare function safeString(value: unknown): string;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a string contains potentially dangerous escape sequences.
|
|
52
|
+
*
|
|
53
|
+
* Useful for logging or debugging when you want to detect
|
|
54
|
+
* but not necessarily remove escape sequences.
|
|
55
|
+
*
|
|
56
|
+
* @param str - The string to check
|
|
57
|
+
* @returns True if the string contains escape sequences
|
|
58
|
+
*/
|
|
59
|
+
export declare function containsEscapeSequences(str: string): boolean;
|
|
60
|
+
//# sourceMappingURL=terminal-sanitizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-sanitizer.d.ts","sourceRoot":"","sources":["../../src/utils/terminal-sanitizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuCH;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAwBrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA6B3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAoBjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAuB5D"}
|