@yu_robotics/remote-cli 1.6.26 → 1.6.32
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/README.md +8 -8
- package/dist/client/MessageHandler.d.ts +5 -3
- package/dist/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +57 -26
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/commands/start.d.ts +7 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +29 -8
- package/dist/commands/start.js.map +1 -1
- package/dist/config/ConfigManager.d.ts +2 -0
- package/dist/config/ConfigManager.d.ts.map +1 -1
- package/dist/config/ConfigManager.js +34 -2
- package/dist/config/ConfigManager.js.map +1 -1
- package/dist/executor/AcpExecutor.d.ts +79 -0
- package/dist/executor/AcpExecutor.d.ts.map +1 -0
- package/dist/executor/AcpExecutor.js +532 -0
- package/dist/executor/AcpExecutor.js.map +1 -0
- package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.js +2 -1
- package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
- package/dist/executor/KimiExecutor.d.ts +18 -0
- package/dist/executor/KimiExecutor.d.ts.map +1 -0
- package/dist/executor/KimiExecutor.js +28 -0
- package/dist/executor/KimiExecutor.js.map +1 -0
- package/dist/executor/OpenCodeExecutor.d.ts +19 -0
- package/dist/executor/OpenCodeExecutor.d.ts.map +1 -0
- package/dist/executor/OpenCodeExecutor.js +28 -0
- package/dist/executor/OpenCodeExecutor.js.map +1 -0
- package/dist/executor/ZCodeExecutor.d.ts +20 -0
- package/dist/executor/ZCodeExecutor.d.ts.map +1 -0
- package/dist/executor/ZCodeExecutor.js +37 -0
- package/dist/executor/ZCodeExecutor.js.map +1 -0
- package/dist/executor/acp/AcpClient.d.ts +50 -40
- package/dist/executor/acp/AcpClient.d.ts.map +1 -1
- package/dist/executor/acp/AcpClient.js +113 -189
- package/dist/executor/acp/AcpClient.js.map +1 -1
- package/dist/executor/acp/AcpTypes.d.ts +27 -68
- package/dist/executor/acp/AcpTypes.d.ts.map +1 -1
- package/dist/executor/acp/AcpTypes.js +0 -9
- package/dist/executor/acp/AcpTypes.js.map +1 -1
- package/dist/executor/index.d.ts +8 -13
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +55 -78
- package/dist/executor/index.js.map +1 -1
- package/dist/executor/zcode/ZCodeClient.d.ts +73 -0
- package/dist/executor/zcode/ZCodeClient.d.ts.map +1 -0
- package/dist/executor/zcode/ZCodeClient.js +681 -0
- package/dist/executor/zcode/ZCodeClient.js.map +1 -0
- package/dist/executor/zcode/ZCodeCommand.d.ts +9 -0
- package/dist/executor/zcode/ZCodeCommand.d.ts.map +1 -0
- package/dist/executor/zcode/ZCodeCommand.js +122 -0
- package/dist/executor/zcode/ZCodeCommand.js.map +1 -0
- package/dist/thread/ThreadExecutorPool.js +2 -2
- package/dist/thread/ThreadExecutorPool.js.map +1 -1
- package/dist/thread/types.d.ts +1 -1
- package/dist/thread/types.d.ts.map +1 -1
- package/dist/types/config.d.ts +30 -16
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +8 -2
- package/dist/types/config.js.map +1 -1
- package/package.json +2 -2
- package/dist/executor/ClaudeExecutor.d.ts +0 -93
- package/dist/executor/ClaudeExecutor.d.ts.map +0 -1
- package/dist/executor/ClaudeExecutor.js +0 -380
- package/dist/executor/ClaudeExecutor.js.map +0 -1
- package/dist/executor/CodexExecutor.d.ts +0 -140
- package/dist/executor/CodexExecutor.d.ts.map +0 -1
- package/dist/executor/CodexExecutor.js +0 -789
- package/dist/executor/CodexExecutor.js.map +0 -1
- package/dist/executor/GeminiExecutor.d.ts +0 -93
- package/dist/executor/GeminiExecutor.d.ts.map +0 -1
- package/dist/executor/GeminiExecutor.js +0 -415
- package/dist/executor/GeminiExecutor.js.map +0 -1
- package/dist/executor/acp/SessionManager.d.ts +0 -41
- package/dist/executor/acp/SessionManager.d.ts.map +0 -1
- package/dist/executor/acp/SessionManager.js +0 -152
- package/dist/executor/acp/SessionManager.js.map +0 -1
- package/dist/utils/processUtils.d.ts +0 -16
- package/dist/utils/processUtils.d.ts.map +0 -1
- package/dist/utils/processUtils.js +0 -37
- package/dist/utils/processUtils.js.map +0 -1
- package/dist/worktree/WorktreeManager.d.ts +0 -119
- package/dist/worktree/WorktreeManager.d.ts.map +0 -1
- package/dist/worktree/WorktreeManager.js +0 -451
- package/dist/worktree/WorktreeManager.js.map +0 -1
|
@@ -1,380 +0,0 @@
|
|
|
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.ClaudeExecutor = void 0;
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const os_1 = __importDefault(require("os"));
|
|
11
|
-
/**
|
|
12
|
-
* Get Claude's global sessions directory
|
|
13
|
-
*/
|
|
14
|
-
function getClaudeSessionsDir() {
|
|
15
|
-
const homeDir = os_1.default.homedir();
|
|
16
|
-
const possiblePaths = [
|
|
17
|
-
path_1.default.join(homeDir, '.claude', 'sessions'),
|
|
18
|
-
path_1.default.join(homeDir, '.config', 'claude', 'sessions'),
|
|
19
|
-
path_1.default.join(homeDir, 'Library', 'Application Support', 'Claude', 'sessions'),
|
|
20
|
-
];
|
|
21
|
-
for (const dir of possiblePaths) {
|
|
22
|
-
if (fs_1.default.existsSync(dir)) {
|
|
23
|
-
return dir;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Claude Executor
|
|
30
|
-
* Manages session ID for continuity using --resume
|
|
31
|
-
*/
|
|
32
|
-
class ClaudeExecutor {
|
|
33
|
-
directoryGuard;
|
|
34
|
-
currentWorkingDirectory;
|
|
35
|
-
isExecuting = false;
|
|
36
|
-
isDestroyed = false;
|
|
37
|
-
defaultTimeout = 300000; // 5 minutes
|
|
38
|
-
sessionId = null;
|
|
39
|
-
sessionFilePath;
|
|
40
|
-
constructor(directoryGuard) {
|
|
41
|
-
this.directoryGuard = directoryGuard;
|
|
42
|
-
this.currentWorkingDirectory = process.cwd();
|
|
43
|
-
// Store session ID in a file in the working directory
|
|
44
|
-
this.sessionFilePath = path_1.default.join(this.currentWorkingDirectory, '.claude-session');
|
|
45
|
-
this.loadSessionId();
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Load session ID from file if exists
|
|
49
|
-
*/
|
|
50
|
-
loadSessionId() {
|
|
51
|
-
try {
|
|
52
|
-
if (fs_1.default.existsSync(this.sessionFilePath)) {
|
|
53
|
-
const data = fs_1.default.readFileSync(this.sessionFilePath, 'utf-8');
|
|
54
|
-
const session = JSON.parse(data);
|
|
55
|
-
if (session.id) {
|
|
56
|
-
this.sessionId = session.id;
|
|
57
|
-
console.log(`[Claude] Loaded session ID: ${this.sessionId}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
console.error('[Claude] Failed to load session ID:', error);
|
|
63
|
-
this.sessionId = null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Save session ID to file
|
|
68
|
-
*/
|
|
69
|
-
saveSessionId(sessionId) {
|
|
70
|
-
try {
|
|
71
|
-
const data = JSON.stringify({
|
|
72
|
-
id: sessionId,
|
|
73
|
-
savedAt: new Date().toISOString(),
|
|
74
|
-
});
|
|
75
|
-
fs_1.default.writeFileSync(this.sessionFilePath, data, 'utf-8');
|
|
76
|
-
console.log(`[Claude] Saved session ID: ${sessionId}`);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
console.error('[Claude] Failed to save session ID:', error);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get recent session ID from Claude's sessions directory
|
|
84
|
-
* Finds the most recently modified session file
|
|
85
|
-
*/
|
|
86
|
-
async getRecentSessionId() {
|
|
87
|
-
try {
|
|
88
|
-
const sessionsDir = getClaudeSessionsDir();
|
|
89
|
-
if (!sessionsDir) {
|
|
90
|
-
console.log('[Claude] No sessions directory found');
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
// List all session directories
|
|
94
|
-
const entries = fs_1.default.readdirSync(sessionsDir, { withFileTypes: true });
|
|
95
|
-
const sessionDirs = entries
|
|
96
|
-
.filter(entry => entry.isDirectory())
|
|
97
|
-
.map(entry => {
|
|
98
|
-
const sessionPath = path_1.default.join(sessionsDir, entry.name);
|
|
99
|
-
const stats = fs_1.default.statSync(sessionPath);
|
|
100
|
-
return {
|
|
101
|
-
id: entry.name,
|
|
102
|
-
mtime: stats.mtime,
|
|
103
|
-
};
|
|
104
|
-
})
|
|
105
|
-
.filter(session => {
|
|
106
|
-
// Validate UUID format
|
|
107
|
-
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
108
|
-
return uuidPattern.test(session.id);
|
|
109
|
-
})
|
|
110
|
-
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
111
|
-
if (sessionDirs.length === 0) {
|
|
112
|
-
console.log('[Claude] No sessions found in directory');
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
// Return the most recent session ID
|
|
116
|
-
const recentSession = sessionDirs[0];
|
|
117
|
-
console.log(`[Claude] Found recent session: ${recentSession.id} (last modified: ${recentSession.mtime.toISOString()})`);
|
|
118
|
-
return recentSession.id;
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.error('[Claude] Failed to get recent session ID:', error);
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get current working directory
|
|
127
|
-
*/
|
|
128
|
-
getCurrentWorkingDirectory() {
|
|
129
|
-
return this.currentWorkingDirectory;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Set working directory
|
|
133
|
-
* @param targetPath Target path
|
|
134
|
-
* @throws If path is not safe
|
|
135
|
-
*/
|
|
136
|
-
async setWorkingDirectory(targetPath) {
|
|
137
|
-
const resolvedPath = this.directoryGuard.resolveWorkingDirectory(targetPath, this.currentWorkingDirectory);
|
|
138
|
-
this.currentWorkingDirectory = resolvedPath;
|
|
139
|
-
// Update session file path
|
|
140
|
-
this.sessionFilePath = path_1.default.join(this.currentWorkingDirectory, '.claude-session');
|
|
141
|
-
this.loadSessionId();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Execute Claude command
|
|
145
|
-
* @param prompt Command prompt
|
|
146
|
-
* @param options Execution options
|
|
147
|
-
* @returns Execution result
|
|
148
|
-
*/
|
|
149
|
-
async execute(prompt, options = {}) {
|
|
150
|
-
if (this.isDestroyed) {
|
|
151
|
-
return {
|
|
152
|
-
success: false,
|
|
153
|
-
error: 'Executor has been destroyed',
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
if (this.isExecuting) {
|
|
157
|
-
return {
|
|
158
|
-
success: false,
|
|
159
|
-
error: 'Executor is busy, please wait for current task to complete. Send the abort command to cancel the running task.',
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
this.isExecuting = true;
|
|
163
|
-
try {
|
|
164
|
-
// Only use timeout if explicitly provided in options
|
|
165
|
-
// Default timeout is disabled to prevent premature termination of long-running tasks
|
|
166
|
-
// Users can cancel with /abort if needed
|
|
167
|
-
const timeout = options.timeout; // undefined means no timeout
|
|
168
|
-
// If we don't have a session ID, try to get recent one from Claude's sessions directory
|
|
169
|
-
if (!this.sessionId) {
|
|
170
|
-
console.log('[Claude] No session ID, checking for recent sessions...');
|
|
171
|
-
this.sessionId = await this.getRecentSessionId();
|
|
172
|
-
if (this.sessionId) {
|
|
173
|
-
this.saveSessionId(this.sessionId);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
const result = await this.executeWithClaudeCLI(prompt, options, timeout);
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
return {
|
|
181
|
-
success: false,
|
|
182
|
-
error: this.formatError(error),
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
finally {
|
|
186
|
-
this.isExecuting = false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Execute using local Claude Code CLI
|
|
191
|
-
*/
|
|
192
|
-
async executeWithClaudeCLI(prompt, options, timeout) {
|
|
193
|
-
return new Promise((resolve, reject) => {
|
|
194
|
-
const outputChunks = [];
|
|
195
|
-
let timeoutTimer;
|
|
196
|
-
// Verify working directory exists
|
|
197
|
-
if (!fs_1.default.existsSync(this.currentWorkingDirectory)) {
|
|
198
|
-
reject(new Error(`Working directory does not exist: ${this.currentWorkingDirectory}`));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
// Build claude command arguments
|
|
202
|
-
const args = ['--print'];
|
|
203
|
-
if (this.sessionId) {
|
|
204
|
-
args.push('--resume', this.sessionId);
|
|
205
|
-
console.log(`[Claude] Resuming session: ${this.sessionId}`);
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
console.log('[Claude] Starting new session');
|
|
209
|
-
}
|
|
210
|
-
args.push(prompt);
|
|
211
|
-
console.log(`[Claude] Starting: claude ${args.map(a => a.includes(' ') ? `"${a}"` : a).join(' ')}`);
|
|
212
|
-
console.log(`[Claude] Working directory: ${this.currentWorkingDirectory}`);
|
|
213
|
-
const child = (0, child_process_1.spawn)('claude', args, {
|
|
214
|
-
cwd: this.currentWorkingDirectory,
|
|
215
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
216
|
-
env: {
|
|
217
|
-
...process.env,
|
|
218
|
-
CI: 'true',
|
|
219
|
-
FORCE_COLOR: '0',
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
console.log(`[Claude] Process started with PID: ${child.pid}`);
|
|
223
|
-
// Handle stdout
|
|
224
|
-
child.stdout.on('data', (data) => {
|
|
225
|
-
const chunk = data.toString();
|
|
226
|
-
console.log('[Claude stdout]', chunk);
|
|
227
|
-
outputChunks.push(chunk);
|
|
228
|
-
if (options.onStream) {
|
|
229
|
-
try {
|
|
230
|
-
options.onStream(chunk);
|
|
231
|
-
}
|
|
232
|
-
catch (error) {
|
|
233
|
-
console.error('[Claude] onStream callback error:', error);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
// Handle stderr
|
|
238
|
-
child.stderr.on('data', (data) => {
|
|
239
|
-
const chunk = data.toString();
|
|
240
|
-
console.error('[Claude stderr]', chunk);
|
|
241
|
-
outputChunks.push(chunk);
|
|
242
|
-
if (options.onStream) {
|
|
243
|
-
try {
|
|
244
|
-
options.onStream(chunk);
|
|
245
|
-
}
|
|
246
|
-
catch (error) {
|
|
247
|
-
console.error('[Claude] onStream callback error:', error);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
// Handle timeout (only if explicitly provided)
|
|
252
|
-
// Default timeout is disabled to prevent premature termination
|
|
253
|
-
if (timeout !== undefined) {
|
|
254
|
-
timeoutTimer = setTimeout(() => {
|
|
255
|
-
console.error('[Claude] Command timeout');
|
|
256
|
-
child.kill('SIGTERM');
|
|
257
|
-
reject(new Error('Execution timeout exceeded'));
|
|
258
|
-
}, timeout);
|
|
259
|
-
}
|
|
260
|
-
// Handle process completion
|
|
261
|
-
child.on('close', (code) => {
|
|
262
|
-
if (timeoutTimer) {
|
|
263
|
-
clearTimeout(timeoutTimer);
|
|
264
|
-
}
|
|
265
|
-
console.log(`[Claude] Process exited with code: ${code}`);
|
|
266
|
-
const output = outputChunks.join('');
|
|
267
|
-
// Check if session ID is in output (for new sessions)
|
|
268
|
-
if (!this.sessionId) {
|
|
269
|
-
const uuidPattern = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
270
|
-
const matches = output.match(uuidPattern);
|
|
271
|
-
if (matches && matches.length > 0) {
|
|
272
|
-
this.sessionId = matches[0];
|
|
273
|
-
this.saveSessionId(this.sessionId);
|
|
274
|
-
console.log(`[Claude] New session ID: ${this.sessionId}`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (code === 0) {
|
|
278
|
-
console.log('[Claude] Execution completed successfully');
|
|
279
|
-
resolve({
|
|
280
|
-
success: true,
|
|
281
|
-
output: output.trim(),
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
console.error(`[Claude] Execution failed with code ${code}`);
|
|
286
|
-
resolve({
|
|
287
|
-
success: false,
|
|
288
|
-
error: `Claude Code process exited with code ${code}${output ? '\n' + output : ''}`,
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
// Handle process errors
|
|
293
|
-
child.on('error', (error) => {
|
|
294
|
-
if (timeoutTimer) {
|
|
295
|
-
clearTimeout(timeoutTimer);
|
|
296
|
-
}
|
|
297
|
-
console.error('[Claude] Process error:', error);
|
|
298
|
-
if (error.message.includes('ENOENT')) {
|
|
299
|
-
reject(new Error('Claude Code CLI not found. Please ensure Claude Code is installed and available in PATH.\n' +
|
|
300
|
-
'Installation: https://docs.anthropic.com/en/docs/claude-code/installation'));
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
reject(error);
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Format error message
|
|
310
|
-
*/
|
|
311
|
-
formatError(error) {
|
|
312
|
-
if (error instanceof Error) {
|
|
313
|
-
if (error.message.includes('timeout')) {
|
|
314
|
-
return `Execution timeout exceeded. The task took too long to complete.`;
|
|
315
|
-
}
|
|
316
|
-
if (error.message.includes('ENOENT')) {
|
|
317
|
-
return `Claude Code CLI not found. Please ensure it's installed and available in PATH.`;
|
|
318
|
-
}
|
|
319
|
-
if (error.message.includes('EACCES') || error.message.includes('Permission denied')) {
|
|
320
|
-
return `Permission denied. You may not have access to this resource.`;
|
|
321
|
-
}
|
|
322
|
-
return `Execution error: ${error.message}`;
|
|
323
|
-
}
|
|
324
|
-
return 'Unknown execution error';
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Reset execution context
|
|
328
|
-
* Clears the session ID so next command starts a new session
|
|
329
|
-
*/
|
|
330
|
-
resetContext() {
|
|
331
|
-
console.log('[Claude] Resetting session context');
|
|
332
|
-
this.sessionId = null;
|
|
333
|
-
// Remove session file
|
|
334
|
-
try {
|
|
335
|
-
if (fs_1.default.existsSync(this.sessionFilePath)) {
|
|
336
|
-
fs_1.default.unlinkSync(this.sessionFilePath);
|
|
337
|
-
console.log('[Claude] Session file removed');
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
catch (error) {
|
|
341
|
-
console.error('[Claude] Failed to remove session file:', error);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Abort current command execution
|
|
346
|
-
* For ClaudeExecutor, this just resets the executing flag since
|
|
347
|
-
* each command spawns a new process and cannot be easily aborted mid-execution
|
|
348
|
-
*/
|
|
349
|
-
async abort() {
|
|
350
|
-
if (!this.isExecuting) {
|
|
351
|
-
console.log('[Claude] No command is currently executing');
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
console.log('[Claude] Abort requested, but spawn-mode executor cannot abort running command');
|
|
355
|
-
// Note: Since this executor spawns a new process for each command,
|
|
356
|
-
// we cannot easily abort it. We just reset the flag so the next
|
|
357
|
-
// command can be processed (the current one will complete in background).
|
|
358
|
-
this.isExecuting = false;
|
|
359
|
-
return true;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Destroy executor
|
|
363
|
-
*/
|
|
364
|
-
destroy() {
|
|
365
|
-
this.isDestroyed = true;
|
|
366
|
-
this.isExecuting = false;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Generate a new session ID (UUID v4)
|
|
370
|
-
*/
|
|
371
|
-
generateSessionId() {
|
|
372
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
373
|
-
const r = (Math.random() * 16) | 0;
|
|
374
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
375
|
-
return v.toString(16);
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
exports.ClaudeExecutor = ClaudeExecutor;
|
|
380
|
-
//# sourceMappingURL=ClaudeExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClaudeExecutor.js","sourceRoot":"","sources":["../../src/executor/ClaudeExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAsC;AAEtC,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AAEpB;;GAEG;AACH,SAAS,oBAAoB;IAC3B,MAAM,OAAO,GAAG,YAAE,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,aAAa,GAAG;QACpB,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC;QACzC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC;QACnD,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,UAAU,CAAC;KAC3E,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,IAAI,YAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IACD,O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AAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACnE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;YAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnYD,wCAmYC"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { DirectoryGuard } from '../security/DirectoryGuard';
|
|
2
|
-
import { IExecutor, ExecuteOptions, ExecuteResult, ExecutorModelInfo } from './IExecutor';
|
|
3
|
-
export interface CodexModelCatalogTransport {
|
|
4
|
-
request(method: string, params?: any): Promise<any>;
|
|
5
|
-
stop(): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export interface CodexExecutorOptions {
|
|
8
|
-
/** Model passed as -m. Leave unset to use codex's default. */
|
|
9
|
-
model?: string;
|
|
10
|
-
/** Per-thread reasoning effort override. Leave unset to use Codex defaults. */
|
|
11
|
-
effort?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Bypass all approvals and the sandbox via
|
|
14
|
-
* --dangerously-bypass-approvals-and-sandbox. Default: true.
|
|
15
|
-
*/
|
|
16
|
-
autoApprove?: boolean;
|
|
17
|
-
initialWorkingDirectory?: string;
|
|
18
|
-
/** codex binary command. Default: 'codex' */
|
|
19
|
-
codexCommand?: string;
|
|
20
|
-
/** Thread ID for per-thread session persistence */
|
|
21
|
-
threadId?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Inactivity timeout: if codex produces no stdout for this long while a
|
|
24
|
-
* command is in flight, the command fails and the process is killed.
|
|
25
|
-
* Default: 10 minutes (matches ClaudePersistentExecutor).
|
|
26
|
-
*/
|
|
27
|
-
inactivityTimeoutMs?: number;
|
|
28
|
-
/** Grace period before SIGTERM escalates to SIGKILL. Default: 3000ms. */
|
|
29
|
-
killEscalationMs?: number;
|
|
30
|
-
/** Injectable app-server client used to validate models for exec mode. */
|
|
31
|
-
modelCatalogClientFactory?: (cwd: string) => CodexModelCatalogTransport;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* IExecutor implementation for the OpenAI Codex CLI (`codex`), exec mode.
|
|
35
|
-
*
|
|
36
|
-
* Unlike AgyExecutor (one persistent process per conversation), codex exec
|
|
37
|
-
* is one-shot per command: each execute() spawns
|
|
38
|
-
* codex exec --json --skip-git-repo-check [--dangerously-bypass-approvals-and-sandbox] [-m model] "<prompt>"
|
|
39
|
-
* and resolves when the process exits. Context continuity is achieved by
|
|
40
|
-
* persisting the thread_id from `thread.started` and passing it to
|
|
41
|
-
* codex exec resume --skip-git-repo-check --json ... <thread_id> "<prompt>"
|
|
42
|
-
* on subsequent commands.
|
|
43
|
-
*
|
|
44
|
-
* Caveats (verified against codex-cli 0.153.4):
|
|
45
|
-
* - stdin must be ended immediately after spawn — codex reads piped stdin
|
|
46
|
-
* to EOF before starting ("Reading additional input from stdin...").
|
|
47
|
-
* - `codex exec resume` does NOT accept the --sandbox flag (usage error).
|
|
48
|
-
* We only ever pass --dangerously-bypass-approvals-and-sandbox, which is
|
|
49
|
-
* accepted on both first run and resume.
|
|
50
|
-
* - item type "error" is non-fatal (e.g. model-metadata fallback warnings);
|
|
51
|
-
* turn.failed / top-level error events are the fatal ones.
|
|
52
|
-
*
|
|
53
|
-
* Note: exec mode accepts text prompts only — image attachments are silently
|
|
54
|
-
* dropped (with a log line).
|
|
55
|
-
*/
|
|
56
|
-
export declare class CodexExecutor implements IExecutor {
|
|
57
|
-
private directoryGuard;
|
|
58
|
-
private currentWorkingDirectory;
|
|
59
|
-
/** Model for the next spawn. Mutable: setModel() updates it in place. */
|
|
60
|
-
private model?;
|
|
61
|
-
private effort?;
|
|
62
|
-
private readonly autoApprove;
|
|
63
|
-
private readonly codexCommand;
|
|
64
|
-
private readonly threadId?;
|
|
65
|
-
private proc;
|
|
66
|
-
private codexThreadId;
|
|
67
|
-
private sessionFilePath;
|
|
68
|
-
private commandQueue;
|
|
69
|
-
private isProcessing;
|
|
70
|
-
private isDestroyed;
|
|
71
|
-
private activeCommand;
|
|
72
|
-
private currentOutputBuffer;
|
|
73
|
-
private stdoutBuffer;
|
|
74
|
-
private stderrTail;
|
|
75
|
-
private decoder;
|
|
76
|
-
private inactivityTimer;
|
|
77
|
-
private readonly inactivityTimeoutMs;
|
|
78
|
-
private readonly killEscalationMs;
|
|
79
|
-
private readonly modelCatalogClientFactory;
|
|
80
|
-
private attachmentWarningShown;
|
|
81
|
-
/** Handoff summary from compactWhenFull, wrapped into the next prompt (consumed once). */
|
|
82
|
-
private pendingContextSeed;
|
|
83
|
-
constructor(directoryGuard: DirectoryGuard, options?: CodexExecutorOptions);
|
|
84
|
-
execute(prompt: string, options?: ExecuteOptions): Promise<ExecuteResult>;
|
|
85
|
-
getCurrentWorkingDirectory(): string;
|
|
86
|
-
setWorkingDirectory(targetPath: string): Promise<void>;
|
|
87
|
-
resetContext(): void;
|
|
88
|
-
abort(): Promise<boolean>;
|
|
89
|
-
destroy(): Promise<void>;
|
|
90
|
-
isProcessRunning(): boolean;
|
|
91
|
-
getSessionId(): string | null;
|
|
92
|
-
/**
|
|
93
|
-
* Switch the model for future commands. codex exec is one-shot per command
|
|
94
|
-
* and takes -m at spawn, so the running command (if any) is undisturbed and
|
|
95
|
-
* the next spawn picks the new model up. MessageHandler persists the choice
|
|
96
|
-
* on the thread; ThreadExecutorPool passes it back via the factory.
|
|
97
|
-
*/
|
|
98
|
-
listModels(): Promise<ExecutorModelInfo[]>;
|
|
99
|
-
setModel(model: string, _onStream?: (chunk: string) => void): Promise<ExecuteResult>;
|
|
100
|
-
clearModel(): void;
|
|
101
|
-
setEffort(effort: string): Promise<ExecuteResult>;
|
|
102
|
-
/**
|
|
103
|
-
* Compact via summarize-then-reset. codex has compaction in its interactive
|
|
104
|
-
* TUI (plus internal auto-compaction at the token limit), but in exec mode
|
|
105
|
-
* a '/compact' prompt reaches the model as plain text (verified live against
|
|
106
|
-
* codex-cli 0.153.4). So we:
|
|
107
|
-
* 1. ask the current thread for a dense handoff summary,
|
|
108
|
-
* 2. reset the thread,
|
|
109
|
-
* 3. wrap the summary into the next user prompt (consumed once).
|
|
110
|
-
* If the summary turn fails (e.g. context already too full), fall back to
|
|
111
|
-
* a plain reset and say so honestly.
|
|
112
|
-
*/
|
|
113
|
-
compactWhenFull(onStream?: (chunk: string) => void): Promise<ExecuteResult>;
|
|
114
|
-
/**
|
|
115
|
-
* Delete per-thread session state. Only removes OUR stored thread id
|
|
116
|
-
* mapping — codex's own session store (~/.codex/sessions) is left untouched.
|
|
117
|
-
*/
|
|
118
|
-
deleteThreadData(_threadId: string): Promise<void>;
|
|
119
|
-
private processQueue;
|
|
120
|
-
private executeQueued;
|
|
121
|
-
private completeActiveCommand;
|
|
122
|
-
/**
|
|
123
|
-
* Arm the inactivity watchdog: any stdout line counts as activity. If codex
|
|
124
|
-
* goes silent mid-command for longer than the limit, fail the command and
|
|
125
|
-
* kill the process (the thread resumes on the next command).
|
|
126
|
-
*/
|
|
127
|
-
private armInactivityTimer;
|
|
128
|
-
private clearInactivityTimer;
|
|
129
|
-
private spawnProcess;
|
|
130
|
-
private buildArgs;
|
|
131
|
-
private killProcess;
|
|
132
|
-
private handleStdout;
|
|
133
|
-
private handleLine;
|
|
134
|
-
private handleItemStarted;
|
|
135
|
-
private handleItemCompleted;
|
|
136
|
-
private loadThreadId;
|
|
137
|
-
private setThreadId;
|
|
138
|
-
private clearThreadId;
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=CodexExecutor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodexExecutor.d.ts","sourceRoot":"","sources":["../../src/executor/CodexExecutor.ts"],"names":[],"mappings":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