feat(coding-agent): add startup profiling scripts for tui/rpc (#2497)
This commit is contained in:
@@ -596,9 +596,7 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
||||
*/
|
||||
let detachInput = () => {};
|
||||
|
||||
async function checkShutdownRequested(): Promise<void> {
|
||||
if (!shutdownRequested) return;
|
||||
|
||||
async function shutdown(): Promise<never> {
|
||||
const currentRunner = session.extensionRunner;
|
||||
if (currentRunner?.hasHandlers("session_shutdown")) {
|
||||
await currentRunner.emit({ type: "session_shutdown" });
|
||||
@@ -609,6 +607,11 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
async function checkShutdownRequested(): Promise<void> {
|
||||
if (!shutdownRequested) return;
|
||||
await shutdown();
|
||||
}
|
||||
|
||||
const handleInputLine = async (line: string) => {
|
||||
try {
|
||||
const parsed = JSON.parse(line);
|
||||
@@ -636,9 +639,20 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
||||
}
|
||||
};
|
||||
|
||||
detachInput = attachJsonlLineReader(process.stdin, (line) => {
|
||||
void handleInputLine(line);
|
||||
});
|
||||
const onInputEnd = () => {
|
||||
void shutdown();
|
||||
};
|
||||
process.stdin.on("end", onInputEnd);
|
||||
|
||||
detachInput = (() => {
|
||||
const detachJsonl = attachJsonlLineReader(process.stdin, (line) => {
|
||||
void handleInputLine(line);
|
||||
});
|
||||
return () => {
|
||||
detachJsonl();
|
||||
process.stdin.off("end", onInputEnd);
|
||||
};
|
||||
})();
|
||||
|
||||
// Keep process alive forever
|
||||
return new Promise(() => {});
|
||||
|
||||
Reference in New Issue
Block a user