chatccc 0.2.142 → 0.2.143

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.
@@ -24,6 +24,6 @@
24
24
  POST {{stop_stuck_url}}
25
25
  Content-Type: application/json
26
26
 
27
- {"session_id": "{{session_id}}"}
27
+ {"session_id": "{{session_id}}", "final_reply": "<你给用户的最终回复,总结已完成的工作和结果>"}
28
28
 
29
29
  调用后停止所有工具调用,直接输出最终回复即可。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.142",
3
+ "version": "0.2.143",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -27,9 +27,9 @@ export async function handleAgentStopStuckRequest(
27
27
  return true;
28
28
  }
29
29
 
30
- let body: { session_id?: string };
30
+ let body: { session_id?: string; final_reply?: string };
31
31
  try {
32
- body = await readUtf8JsonBody<{ session_id?: string }>(req, MAX_REQUEST_BYTES);
32
+ body = await readUtf8JsonBody<{ session_id?: string; final_reply?: string }>(req, MAX_REQUEST_BYTES);
33
33
  } catch (err) {
34
34
  jsonReply(res, 400, { error: `Invalid request body: ${(err as Error).message}` });
35
35
  return true;
@@ -59,6 +59,8 @@ export async function handleAgentStopStuckRequest(
59
59
  // 丢弃缓存队列中的消息
60
60
  cancelQueuedMessage(sessionId);
61
61
 
62
+ const finalReply = typeof body?.final_reply === "string" ? body.final_reply.trim() : "";
63
+
62
64
  // fire-and-forget:立即把 stream-state 标为 done(而非 stopped),
63
65
  // 让 display loop 以"正常完成"而非"已停止"来渲染卡片和最终回复。
64
66
  // 不设 prompt.stopped = true,这样 runAgentSession 的 finally 也会写 "done"。
@@ -70,6 +72,7 @@ export async function handleAgentStopStuckRequest(
70
72
  await writeStreamState({
71
73
  ...current,
72
74
  status: "done",
75
+ finalReply: finalReply ? current.finalReply + "\n\n" + finalReply : current.finalReply,
73
76
  updatedAt: Date.now(),
74
77
  });
75
78
  } catch (err) {
@@ -82,7 +85,7 @@ export async function handleAgentStopStuckRequest(
82
85
  // 不设 stopped 标记 → finally block 写 "done" → 卡片正常结束
83
86
  prompt.controller.abort();
84
87
 
85
- console.log(`[${ts()}] [STUCK-LOOP] Session ${sessionId} aborted as done (agent detected stuck loop)`);
88
+ console.log(`[${ts()}] [STUCK-LOOP] Session ${sessionId} aborted as done (agent detected stuck loop, final_reply=${finalReply ? "yes" : "no"})`);
86
89
 
87
90
  jsonReply(res, 200, { ok: true });
88
91
  return true;