@yu_robotics/remote-cli 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 +21 -0
- package/README.md +94 -0
- package/bin/remote-cli.js +2 -0
- package/dist/client/MessageHandler.d.ts +92 -0
- package/dist/client/MessageHandler.d.ts.map +1 -0
- package/dist/client/MessageHandler.js +496 -0
- package/dist/client/MessageHandler.js.map +1 -0
- package/dist/client/WebSocketClient.d.ts +109 -0
- package/dist/client/WebSocketClient.d.ts.map +1 -0
- package/dist/client/WebSocketClient.js +234 -0
- package/dist/client/WebSocketClient.js.map +1 -0
- package/dist/commands/config.d.ts +35 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +195 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/init.d.ts +25 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +112 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/start.d.ts +20 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +108 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +37 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +71 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +23 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +52 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/config/ConfigManager.d.ts +109 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/config/ConfigManager.js +262 -0
- package/dist/config/ConfigManager.js.map +1 -0
- package/dist/executor/ClaudeExecutor.d.ts +89 -0
- package/dist/executor/ClaudeExecutor.d.ts.map +1 -0
- package/dist/executor/ClaudeExecutor.js +365 -0
- package/dist/executor/ClaudeExecutor.js.map +1 -0
- package/dist/executor/ClaudePersistentExecutor.d.ts +175 -0
- package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -0
- package/dist/executor/ClaudePersistentExecutor.js +958 -0
- package/dist/executor/ClaudePersistentExecutor.js.map +1 -0
- package/dist/executor/index.d.ts +20 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +48 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/hooks/ClaudeCodeHooks.d.ts +281 -0
- package/dist/hooks/ClaudeCodeHooks.d.ts.map +1 -0
- package/dist/hooks/ClaudeCodeHooks.js +350 -0
- package/dist/hooks/ClaudeCodeHooks.js.map +1 -0
- package/dist/hooks/FeishuNotificationAdapter.d.ts +87 -0
- package/dist/hooks/FeishuNotificationAdapter.d.ts.map +1 -0
- package/dist/hooks/FeishuNotificationAdapter.js +280 -0
- package/dist/hooks/FeishuNotificationAdapter.js.map +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +333 -0
- package/dist/index.js.map +1 -0
- package/dist/security/DirectoryGuard.d.ts +54 -0
- package/dist/security/DirectoryGuard.d.ts.map +1 -0
- package/dist/security/DirectoryGuard.js +143 -0
- package/dist/security/DirectoryGuard.js.map +1 -0
- package/dist/types/config.d.ts +46 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +22 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +110 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/FeishuMessageFormatter.d.ts +84 -0
- package/dist/utils/FeishuMessageFormatter.d.ts.map +1 -0
- package/dist/utils/FeishuMessageFormatter.js +395 -0
- package/dist/utils/FeishuMessageFormatter.js.map +1 -0
- package/dist/utils/stripAnsi.d.ts +21 -0
- package/dist/utils/stripAnsi.d.ts.map +1 -0
- package/dist/utils/stripAnsi.js +30 -0
- package/dist/utils/stripAnsi.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfigManager = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const config_1 = require("../types/config");
|
|
11
|
+
/**
|
|
12
|
+
* Configuration Manager
|
|
13
|
+
* Responsible for reading, writing and managing configuration files
|
|
14
|
+
*/
|
|
15
|
+
class ConfigManager {
|
|
16
|
+
config;
|
|
17
|
+
configDir;
|
|
18
|
+
configFile;
|
|
19
|
+
constructor(config, configDir, configFile) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.configDir = configDir;
|
|
22
|
+
this.configFile = configFile;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize configuration manager
|
|
26
|
+
* @returns ConfigManager instance
|
|
27
|
+
*/
|
|
28
|
+
static async initialize() {
|
|
29
|
+
const homeDir = os_1.default.homedir();
|
|
30
|
+
const configDir = path_1.default.join(homeDir, '.remote-cli');
|
|
31
|
+
const configFile = path_1.default.join(configDir, 'config.json');
|
|
32
|
+
// Ensure config directory exists
|
|
33
|
+
try {
|
|
34
|
+
await promises_1.default.access(configDir);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
await promises_1.default.mkdir(configDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
// Read or create config file
|
|
40
|
+
let config;
|
|
41
|
+
try {
|
|
42
|
+
const content = await promises_1.default.readFile(configFile, 'utf-8');
|
|
43
|
+
config = JSON.parse(content);
|
|
44
|
+
// Validate config structure
|
|
45
|
+
if (!ConfigManager.isValidConfig(config)) {
|
|
46
|
+
throw new Error('Invalid config structure');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// Config file does not exist or is invalid, use default config
|
|
51
|
+
config = { ...config_1.DEFAULT_CONFIG };
|
|
52
|
+
await promises_1.default.writeFile(configFile, JSON.stringify(config, null, 2), 'utf-8');
|
|
53
|
+
}
|
|
54
|
+
return new ConfigManager(config, configDir, configFile);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validate configuration structure
|
|
58
|
+
* @param config Configuration object
|
|
59
|
+
* @returns Whether it is valid
|
|
60
|
+
*/
|
|
61
|
+
static isValidConfig(config) {
|
|
62
|
+
return (config &&
|
|
63
|
+
typeof config === 'object' &&
|
|
64
|
+
config.security &&
|
|
65
|
+
typeof config.security === 'object' &&
|
|
66
|
+
Array.isArray(config.security.allowedDirectories) &&
|
|
67
|
+
Array.isArray(config.security.deniedCommands) &&
|
|
68
|
+
typeof config.security.maxConcurrentTasks === 'number' &&
|
|
69
|
+
config.server &&
|
|
70
|
+
typeof config.server === 'object' &&
|
|
71
|
+
typeof config.server.url === 'string' &&
|
|
72
|
+
typeof config.server.reconnectInterval === 'number' &&
|
|
73
|
+
typeof config.server.heartbeatInterval === 'number');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get current configuration
|
|
77
|
+
* @returns Configuration object (deep copy)
|
|
78
|
+
*/
|
|
79
|
+
getConfig() {
|
|
80
|
+
return JSON.parse(JSON.stringify(this.config));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get configuration directory path
|
|
84
|
+
* @returns Configuration directory path
|
|
85
|
+
*/
|
|
86
|
+
getConfigDir() {
|
|
87
|
+
return this.configDir;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get configuration file path
|
|
91
|
+
* @returns Configuration file path
|
|
92
|
+
*/
|
|
93
|
+
getConfigFile() {
|
|
94
|
+
return this.configFile;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Save configuration to file
|
|
98
|
+
*/
|
|
99
|
+
async saveConfig() {
|
|
100
|
+
await promises_1.default.writeFile(this.configFile, JSON.stringify(this.config, null, 2), 'utf-8');
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Add allowed directory
|
|
104
|
+
* @param directory Directory path (supports ~ and relative paths)
|
|
105
|
+
*/
|
|
106
|
+
async addAllowedDirectory(directory) {
|
|
107
|
+
// Validate directory path
|
|
108
|
+
if (!directory || directory.trim() === '') {
|
|
109
|
+
throw new Error('Invalid directory path');
|
|
110
|
+
}
|
|
111
|
+
// Only allow ~ prefix or relative paths, not absolute paths
|
|
112
|
+
if (directory.startsWith('/') && !directory.startsWith('~/')) {
|
|
113
|
+
throw new Error('Only home directory and relative paths are allowed');
|
|
114
|
+
}
|
|
115
|
+
// Check if already exists
|
|
116
|
+
if (!this.config.security.allowedDirectories.includes(directory)) {
|
|
117
|
+
this.config.security.allowedDirectories.push(directory);
|
|
118
|
+
await this.saveConfig();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Remove allowed directory
|
|
123
|
+
* @param directory Directory path
|
|
124
|
+
*/
|
|
125
|
+
async removeAllowedDirectory(directory) {
|
|
126
|
+
this.config.security.allowedDirectories = this.config.security.allowedDirectories.filter(d => d !== directory);
|
|
127
|
+
await this.saveConfig();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Add denied command
|
|
131
|
+
* @param command Command pattern
|
|
132
|
+
*/
|
|
133
|
+
async addDeniedCommand(command) {
|
|
134
|
+
if (!this.config.security.deniedCommands.includes(command)) {
|
|
135
|
+
this.config.security.deniedCommands.push(command);
|
|
136
|
+
await this.saveConfig();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Remove denied command
|
|
141
|
+
* @param command Command pattern
|
|
142
|
+
*/
|
|
143
|
+
async removeDeniedCommand(command) {
|
|
144
|
+
this.config.security.deniedCommands = this.config.security.deniedCommands.filter(c => c !== command);
|
|
145
|
+
await this.saveConfig();
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Update server URL
|
|
149
|
+
* @param url WebSocket server URL
|
|
150
|
+
*/
|
|
151
|
+
async updateServerUrl(url) {
|
|
152
|
+
// Validate URL format
|
|
153
|
+
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
154
|
+
throw new Error('Invalid server URL: must start with ws:// or wss://');
|
|
155
|
+
}
|
|
156
|
+
this.config.server.url = url;
|
|
157
|
+
await this.saveConfig();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Update maximum concurrent tasks
|
|
161
|
+
* @param max Maximum concurrent tasks
|
|
162
|
+
*/
|
|
163
|
+
async updateMaxConcurrentTasks(max) {
|
|
164
|
+
if (max < 1) {
|
|
165
|
+
throw new Error('Max concurrent tasks must be at least 1');
|
|
166
|
+
}
|
|
167
|
+
this.config.security.maxConcurrentTasks = max;
|
|
168
|
+
await this.saveConfig();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Reset configuration to defaults
|
|
172
|
+
*/
|
|
173
|
+
async resetToDefaults() {
|
|
174
|
+
this.config = { ...config_1.DEFAULT_CONFIG };
|
|
175
|
+
await this.saveConfig();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Export configuration as JSON string
|
|
179
|
+
* @returns JSON string
|
|
180
|
+
*/
|
|
181
|
+
exportConfig() {
|
|
182
|
+
return JSON.stringify(this.config, null, 2);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Import configuration from JSON string
|
|
186
|
+
* @param json JSON string
|
|
187
|
+
*/
|
|
188
|
+
async importConfig(json) {
|
|
189
|
+
try {
|
|
190
|
+
const config = JSON.parse(json);
|
|
191
|
+
if (!ConfigManager.isValidConfig(config)) {
|
|
192
|
+
throw new Error('Invalid config structure');
|
|
193
|
+
}
|
|
194
|
+
this.config = config;
|
|
195
|
+
await this.saveConfig();
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (error instanceof SyntaxError) {
|
|
199
|
+
throw new Error('Invalid JSON format');
|
|
200
|
+
}
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Check if configuration key exists
|
|
206
|
+
* @param keyPath Key path (supports dot-separated nested paths)
|
|
207
|
+
* @returns Whether it exists
|
|
208
|
+
*/
|
|
209
|
+
has(keyPath) {
|
|
210
|
+
return this.get(keyPath) !== undefined;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get configuration value
|
|
214
|
+
* @param keyPath Key path (supports dot-separated nested paths, e.g. 'security.allowedDirectories')
|
|
215
|
+
* @returns Configuration value
|
|
216
|
+
*/
|
|
217
|
+
get(keyPath) {
|
|
218
|
+
const keys = keyPath.split('.');
|
|
219
|
+
let value = this.config;
|
|
220
|
+
for (const key of keys) {
|
|
221
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
value = value[key];
|
|
225
|
+
}
|
|
226
|
+
return value;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Set configuration value
|
|
230
|
+
* @param keyPath Key path (supports dot-separated nested paths)
|
|
231
|
+
* @param value Configuration value
|
|
232
|
+
*/
|
|
233
|
+
async set(keyPath, value) {
|
|
234
|
+
// Ensure config is initialized
|
|
235
|
+
if (!this.config || typeof this.config !== 'object') {
|
|
236
|
+
throw new Error('ConfigManager not properly initialized. Use ConfigManager.initialize()');
|
|
237
|
+
}
|
|
238
|
+
const keys = keyPath.split('.');
|
|
239
|
+
const lastKey = keys.pop();
|
|
240
|
+
let target = this.config;
|
|
241
|
+
// Navigate to target object
|
|
242
|
+
for (const key of keys) {
|
|
243
|
+
if (!(key in target) || typeof target[key] !== 'object' || target[key] === null) {
|
|
244
|
+
target[key] = {};
|
|
245
|
+
}
|
|
246
|
+
target = target[key];
|
|
247
|
+
}
|
|
248
|
+
// Set value
|
|
249
|
+
target[lastKey] = value;
|
|
250
|
+
// Save configuration
|
|
251
|
+
await this.saveConfig();
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Get all configuration (alias for getConfig)
|
|
255
|
+
* @returns Configuration object (deep copy)
|
|
256
|
+
*/
|
|
257
|
+
getAll() {
|
|
258
|
+
return this.getConfig();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.ConfigManager = ConfigManager;
|
|
262
|
+
//# sourceMappingURL=ConfigManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigManager.js","sourceRoot":"","sources":["../../src/config/ConfigManager.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AACxB,4CAAoB;AACpB,4CAAyD;AAEzD;;;GAGG;AACH,MAAa,aAAa;IAChB,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,UAAU,CAAS;IAE3B,YAAoB,MAAc,EAAE,SAAiB,EAAE,UAAkB;QACvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU;QACrB,MAAM,OAAO,GAAG,YAAE,CAAC,OAAO,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAEvD,iCAAiC;QACjC,IAAI,CAAC;YACH,MAAM,kBAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,kBAAE,CAAC,KAAK,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YAAY;QACZ,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;QAExB,qBAAqB;QACrB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AA3RD,sCA2RC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { DirectoryGuard } from '../security/DirectoryGuard';
|
|
2
|
+
/**
|
|
3
|
+
* Claude execution options
|
|
4
|
+
*/
|
|
5
|
+
export interface ClaudeExecuteOptions {
|
|
6
|
+
/** Stream output callback */
|
|
7
|
+
onStream?: (chunk: string) => void;
|
|
8
|
+
/** Execution timeout (milliseconds), default 300000 (5 minutes) */
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Claude execution result
|
|
13
|
+
*/
|
|
14
|
+
export interface ClaudeExecuteResult {
|
|
15
|
+
/** Whether execution was successful */
|
|
16
|
+
success: boolean;
|
|
17
|
+
/** Output content */
|
|
18
|
+
output?: string;
|
|
19
|
+
/** Error message */
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Claude Executor
|
|
24
|
+
* Manages session ID for continuity using --resume
|
|
25
|
+
*/
|
|
26
|
+
export declare class ClaudeExecutor {
|
|
27
|
+
private directoryGuard;
|
|
28
|
+
private currentWorkingDirectory;
|
|
29
|
+
private isExecuting;
|
|
30
|
+
private isDestroyed;
|
|
31
|
+
private defaultTimeout;
|
|
32
|
+
private sessionId;
|
|
33
|
+
private sessionFilePath;
|
|
34
|
+
constructor(directoryGuard: DirectoryGuard);
|
|
35
|
+
/**
|
|
36
|
+
* Load session ID from file if exists
|
|
37
|
+
*/
|
|
38
|
+
private loadSessionId;
|
|
39
|
+
/**
|
|
40
|
+
* Save session ID to file
|
|
41
|
+
*/
|
|
42
|
+
private saveSessionId;
|
|
43
|
+
/**
|
|
44
|
+
* Get recent session ID from Claude's sessions directory
|
|
45
|
+
* Finds the most recently modified session file
|
|
46
|
+
*/
|
|
47
|
+
private getRecentSessionId;
|
|
48
|
+
/**
|
|
49
|
+
* Get current working directory
|
|
50
|
+
*/
|
|
51
|
+
getCurrentWorkingDirectory(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Set working directory
|
|
54
|
+
* @param targetPath Target path
|
|
55
|
+
* @throws If path is not safe
|
|
56
|
+
*/
|
|
57
|
+
setWorkingDirectory(targetPath: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Execute Claude command
|
|
60
|
+
* @param prompt Command prompt
|
|
61
|
+
* @param options Execution options
|
|
62
|
+
* @returns Execution result
|
|
63
|
+
*/
|
|
64
|
+
execute(prompt: string, options?: ClaudeExecuteOptions): Promise<ClaudeExecuteResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute using local Claude Code CLI
|
|
67
|
+
*/
|
|
68
|
+
private executeWithClaudeCLI;
|
|
69
|
+
/**
|
|
70
|
+
* Format error message
|
|
71
|
+
*/
|
|
72
|
+
private formatError;
|
|
73
|
+
/**
|
|
74
|
+
* Reset execution context
|
|
75
|
+
* Clears the session ID so next command starts a new session
|
|
76
|
+
*/
|
|
77
|
+
resetContext(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Abort current command execution
|
|
80
|
+
* For ClaudeExecutor, this just resets the executing flag since
|
|
81
|
+
* each command spawns a new process and cannot be easily aborted mid-execution
|
|
82
|
+
*/
|
|
83
|
+
abort(): Promise<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Destroy executor
|
|
86
|
+
*/
|
|
87
|
+
destroy(): void;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=ClaudeExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClaudeExecutor.d.ts","sourceRoot":"","sources":["../../src/executor/ClaudeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,E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