mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
refactor: extract local agent spawn helper and unify process tree cleanup (#410)
This commit is contained in:
+14
-21
@@ -1,6 +1,5 @@
|
||||
import { logger } from '@/ui/logger';
|
||||
import { restoreTerminalState } from '@/ui/terminalState';
|
||||
import { spawnWithAbort } from '@/utils/spawnWithAbort';
|
||||
import { spawnWithTerminalGuard } from '@/utils/spawnWithTerminalGuard';
|
||||
import { buildMcpServerConfigArgs, buildDeveloperInstructionsArg } from './utils/codexMcpConfig';
|
||||
import { codexSystemPrompt } from './utils/systemPrompt';
|
||||
|
||||
@@ -68,23 +67,17 @@ export async function codexLocal(opts: {
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdin.pause();
|
||||
try {
|
||||
await spawnWithAbort({
|
||||
command: 'codex',
|
||||
args,
|
||||
cwd: opts.path,
|
||||
env: process.env,
|
||||
signal: opts.abort,
|
||||
logLabel: 'CodexLocal',
|
||||
spawnName: 'codex',
|
||||
installHint: 'Codex CLI',
|
||||
includeCause: true,
|
||||
logExit: true,
|
||||
shell: process.platform === 'win32'
|
||||
});
|
||||
} finally {
|
||||
process.stdin.resume();
|
||||
restoreTerminalState();
|
||||
}
|
||||
await spawnWithTerminalGuard({
|
||||
command: 'codex',
|
||||
args,
|
||||
cwd: opts.path,
|
||||
env: process.env,
|
||||
signal: opts.abort,
|
||||
logLabel: 'CodexLocal',
|
||||
spawnName: 'codex',
|
||||
installHint: 'Codex CLI',
|
||||
includeCause: true,
|
||||
logExit: true,
|
||||
shell: process.platform === 'win32'
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user