@yu_robotics/remote-cli 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/MessageHandler.d.ts +26 -1
- package/dist/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +80 -9
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +6 -4
- package/dist/commands/start.js.map +1 -1
- package/dist/executor/AgyExecutor.d.ts +125 -0
- package/dist/executor/AgyExecutor.d.ts.map +1 -0
- package/dist/executor/AgyExecutor.js +637 -0
- package/dist/executor/AgyExecutor.js.map +1 -0
- package/dist/executor/CodexExecutor.d.ts +127 -0
- package/dist/executor/CodexExecutor.d.ts.map +1 -0
- package/dist/executor/CodexExecutor.js +696 -0
- package/dist/executor/CodexExecutor.js.map +1 -0
- package/dist/executor/IExecutor.d.ts +1 -1
- package/dist/executor/compactHandoff.d.ts +26 -0
- package/dist/executor/compactHandoff.d.ts.map +1 -0
- package/dist/executor/compactHandoff.js +48 -0
- package/dist/executor/compactHandoff.js.map +1 -0
- package/dist/executor/index.d.ts +9 -2
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +47 -12
- package/dist/executor/index.js.map +1 -1
- package/dist/thread/ThreadManager.d.ts +1 -1
- package/dist/thread/ThreadManager.js +1 -1
- package/dist/types/config.d.ts +33 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { DirectoryGuard } from '../security/DirectoryGuard';
|
|
2
|
+
import { IExecutor, ExecuteOptions, ExecuteResult } from './IExecutor';
|
|
3
|
+
export interface CodexExecutorOptions {
|
|
4
|
+
/** Model passed as -m. Leave unset to use codex's default. */
|
|
5
|
+
model?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Bypass all approvals and the sandbox via
|
|
8
|
+
* --dangerously-bypass-approvals-and-sandbox. Default: true.
|
|
9
|
+
*/
|
|
10
|
+
autoApprove?: boolean;
|
|
11
|
+
initialWorkingDirectory?: string;
|
|
12
|
+
/** codex binary command. Default: 'codex' */
|
|
13
|
+
codexCommand?: string;
|
|
14
|
+
/** Thread ID for per-thread session persistence */
|
|
15
|
+
threadId?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Inactivity timeout: if codex produces no stdout for this long while a
|
|
18
|
+
* command is in flight, the command fails and the process is killed.
|
|
19
|
+
* Default: 10 minutes (matches ClaudePersistentExecutor).
|
|
20
|
+
*/
|
|
21
|
+
inactivityTimeoutMs?: number;
|
|
22
|
+
/** Grace period before SIGTERM escalates to SIGKILL. Default: 3000ms. */
|
|
23
|
+
killEscalationMs?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* IExecutor implementation for the OpenAI Codex CLI (`codex`), exec mode.
|
|
27
|
+
*
|
|
28
|
+
* Unlike AgyExecutor (one persistent process per conversation), codex exec
|
|
29
|
+
* is one-shot per command: each execute() spawns
|
|
30
|
+
* codex exec --json --skip-git-repo-check [--dangerously-bypass-approvals-and-sandbox] [-m model] "<prompt>"
|
|
31
|
+
* and resolves when the process exits. Context continuity is achieved by
|
|
32
|
+
* persisting the thread_id from `thread.started` and passing it to
|
|
33
|
+
* codex exec resume --skip-git-repo-check --json ... <thread_id> "<prompt>"
|
|
34
|
+
* on subsequent commands.
|
|
35
|
+
*
|
|
36
|
+
* Caveats (verified against codex-cli 0.153.4):
|
|
37
|
+
* - stdin must be ended immediately after spawn — codex reads piped stdin
|
|
38
|
+
* to EOF before starting ("Reading additional input from stdin...").
|
|
39
|
+
* - `codex exec resume` does NOT accept the --sandbox flag (usage error).
|
|
40
|
+
* We only ever pass --dangerously-bypass-approvals-and-sandbox, which is
|
|
41
|
+
* accepted on both first run and resume.
|
|
42
|
+
* - item type "error" is non-fatal (e.g. model-metadata fallback warnings);
|
|
43
|
+
* turn.failed / top-level error events are the fatal ones.
|
|
44
|
+
*
|
|
45
|
+
* Note: exec mode accepts text prompts only — image attachments are silently
|
|
46
|
+
* dropped (with a log line).
|
|
47
|
+
*/
|
|
48
|
+
export declare class CodexExecutor implements IExecutor {
|
|
49
|
+
private directoryGuard;
|
|
50
|
+
private currentWorkingDirectory;
|
|
51
|
+
/** Model for the next spawn. Mutable: setModel() updates it in place. */
|
|
52
|
+
private model?;
|
|
53
|
+
private readonly autoApprove;
|
|
54
|
+
private readonly codexCommand;
|
|
55
|
+
private readonly threadId?;
|
|
56
|
+
private proc;
|
|
57
|
+
private codexThreadId;
|
|
58
|
+
private sessionFilePath;
|
|
59
|
+
private commandQueue;
|
|
60
|
+
private isProcessing;
|
|
61
|
+
private isDestroyed;
|
|
62
|
+
private activeCommand;
|
|
63
|
+
private currentOutputBuffer;
|
|
64
|
+
private stdoutBuffer;
|
|
65
|
+
private stderrTail;
|
|
66
|
+
private decoder;
|
|
67
|
+
private inactivityTimer;
|
|
68
|
+
private readonly inactivityTimeoutMs;
|
|
69
|
+
private readonly killEscalationMs;
|
|
70
|
+
private attachmentWarningShown;
|
|
71
|
+
/** Handoff summary from compactWhenFull, wrapped into the next prompt (consumed once). */
|
|
72
|
+
private pendingContextSeed;
|
|
73
|
+
constructor(directoryGuard: DirectoryGuard, options?: CodexExecutorOptions);
|
|
74
|
+
execute(prompt: string, options?: ExecuteOptions): Promise<ExecuteResult>;
|
|
75
|
+
getCurrentWorkingDirectory(): string;
|
|
76
|
+
setWorkingDirectory(targetPath: string): Promise<void>;
|
|
77
|
+
resetContext(): void;
|
|
78
|
+
abort(): Promise<boolean>;
|
|
79
|
+
destroy(): Promise<void>;
|
|
80
|
+
isProcessRunning(): boolean;
|
|
81
|
+
getSessionId(): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Switch the model for future commands. codex exec is one-shot per command
|
|
84
|
+
* and takes -m at spawn, so the running command (if any) is undisturbed and
|
|
85
|
+
* the next spawn picks the new model up. MessageHandler persists the choice
|
|
86
|
+
* on the thread; ThreadExecutorPool passes it back via the factory.
|
|
87
|
+
*/
|
|
88
|
+
setModel(model: string, _onStream?: (chunk: string) => void): Promise<ExecuteResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Compact via summarize-then-reset. codex has compaction in its interactive
|
|
91
|
+
* TUI (plus internal auto-compaction at the token limit), but in exec mode
|
|
92
|
+
* a '/compact' prompt reaches the model as plain text (verified live against
|
|
93
|
+
* codex-cli 0.153.4). So we:
|
|
94
|
+
* 1. ask the current thread for a dense handoff summary,
|
|
95
|
+
* 2. reset the thread,
|
|
96
|
+
* 3. wrap the summary into the next user prompt (consumed once).
|
|
97
|
+
* If the summary turn fails (e.g. context already too full), fall back to
|
|
98
|
+
* a plain reset and say so honestly.
|
|
99
|
+
*/
|
|
100
|
+
compactWhenFull(onStream?: (chunk: string) => void): Promise<ExecuteResult>;
|
|
101
|
+
/**
|
|
102
|
+
* Delete per-thread session state. Only removes OUR stored thread id
|
|
103
|
+
* mapping — codex's own session store (~/.codex/sessions) is left untouched.
|
|
104
|
+
*/
|
|
105
|
+
deleteThreadData(_threadId: string): Promise<void>;
|
|
106
|
+
private processQueue;
|
|
107
|
+
private executeQueued;
|
|
108
|
+
private completeActiveCommand;
|
|
109
|
+
/**
|
|
110
|
+
* Arm the inactivity watchdog: any stdout line counts as activity. If codex
|
|
111
|
+
* goes silent mid-command for longer than the limit, fail the command and
|
|
112
|
+
* kill the process (the thread resumes on the next command).
|
|
113
|
+
*/
|
|
114
|
+
private armInactivityTimer;
|
|
115
|
+
private clearInactivityTimer;
|
|
116
|
+
private spawnProcess;
|
|
117
|
+
private buildArgs;
|
|
118
|
+
private killProcess;
|
|
119
|
+
private handleStdout;
|
|
120
|
+
private handleLine;
|
|
121
|
+
private handleItemStarted;
|
|
122
|
+
private handleItemCompleted;
|
|
123
|
+
private loadThreadId;
|
|
124
|
+
private setThreadId;
|
|
125
|
+
private clearThreadId;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=CodexEx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