chatccc 0.2.166 → 0.2.168
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/package.json +1 -1
- package/src/agent-stop-stuck.ts +12 -0
- package/src/session.ts +7 -0
package/package.json
CHANGED
package/src/agent-stop-stuck.ts
CHANGED
|
@@ -107,6 +107,18 @@ export async function handleAgentStopStuckRequest(
|
|
|
107
107
|
|
|
108
108
|
// 先关闭底层 SDK session,终止 CLI 子进程,然后再 abort 清理 adapter 层
|
|
109
109
|
prompt.closeSession?.();
|
|
110
|
+
|
|
111
|
+
// 强制杀死 CLI 子进程。controller.abort() 只在 for-await 收到下一条
|
|
112
|
+
// stream 消息时才被检测到——如果 agent 陷入无输出的计算循环,abort 信号
|
|
113
|
+
// 永远不会生效;SDK 的 session.close() 也不保证立即终止子进程。
|
|
114
|
+
if (prompt.processPid !== undefined) {
|
|
115
|
+
try {
|
|
116
|
+
process.kill(prompt.processPid);
|
|
117
|
+
} catch {
|
|
118
|
+
// 进程可能已退出,忽略错误
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
110
122
|
// 不设 stopped 标记 → finally block 写 "done" → 卡片正常结束
|
|
111
123
|
prompt.controller.abort();
|
|
112
124
|
|
package/src/session.ts
CHANGED
|
@@ -1605,6 +1605,13 @@ export function stopSession(sessionId: string): boolean {
|
|
|
1605
1605
|
clearPromptProcessMonitor(sessionId);
|
|
1606
1606
|
cancelQueuedMessage(sessionId);
|
|
1607
1607
|
prompt.controller.abort();
|
|
1608
|
+
|
|
1609
|
+
// 强制杀死 CLI 子进程。controller.abort() 只在 for-await 收到下一条
|
|
1610
|
+
// stream 消息时才被检测到——如果 agent 陷入无输出的计算循环,abort 信号
|
|
1611
|
+
// 永远不会生效。直接 process.kill 让 stdout/stderr 管道关闭,stream 立即结束。
|
|
1612
|
+
if (prompt.processPid !== undefined) {
|
|
1613
|
+
try { process.kill(prompt.processPid); } catch { /* 进程可能已退出 */ }
|
|
1614
|
+
}
|
|
1608
1615
|
console.log(`[${ts()}] [STOP] Session ${sessionId} aborted`);
|
|
1609
1616
|
|
|
1610
1617
|
// fire-and-forget:立刻把 stream-state.status 改成 stopped,
|