opencode-chat-channel 1.2.10 → 1.2.11
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/index.d.ts.map +1 -1
- package/dist/index.js +42 -18
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAsVlD,eAAO,MAAM,iBAAiB,EAAE,MAyF/B,CAAC;AAEF,eAAe,iBAAiB,CAAC;AAMjC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -404,32 +404,56 @@ async function consumeSessionEvents(client, channel, sessionId, replyTarget, thi
|
|
|
404
404
|
await channel.updateThinkingCard(thinkingMsgId, text);
|
|
405
405
|
}
|
|
406
406
|
if (eventStream) {
|
|
407
|
+
let alreadyDone = false;
|
|
407
408
|
try {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
409
|
+
const statusRes = await client.session.status();
|
|
410
|
+
const allStatuses = statusRes.data ?? {};
|
|
411
|
+
const sessionStatus = allStatuses[sessionId];
|
|
412
|
+
if (!sessionStatus || sessionStatus.type === "idle") {
|
|
413
|
+
alreadyDone = true;
|
|
414
|
+
log("info", `[${channel.name}] session 已完成,跳过 SSE 等待`);
|
|
415
|
+
}
|
|
416
|
+
} catch {}
|
|
417
|
+
if (!alreadyDone) {
|
|
418
|
+
const SSE_TIMEOUT_MS = 3 * 60 * 1000;
|
|
419
|
+
const abortController = new AbortController;
|
|
420
|
+
const timeoutId = setTimeout(() => {
|
|
421
|
+
log("warn", `[${channel.name}] SSE 等待超时,强制结束`);
|
|
422
|
+
abortController.abort();
|
|
423
|
+
}, SSE_TIMEOUT_MS);
|
|
424
|
+
try {
|
|
425
|
+
for await (const event of eventStream.stream) {
|
|
426
|
+
if (abortController.signal.aborted)
|
|
427
|
+
break;
|
|
428
|
+
if (!isSessionEvent(event, sessionId))
|
|
414
429
|
continue;
|
|
415
|
-
if (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
430
|
+
if (event.type === "message.part.updated") {
|
|
431
|
+
const part = event.properties?.part;
|
|
432
|
+
if (!part)
|
|
433
|
+
continue;
|
|
434
|
+
if (part.type === "reasoning" && part.text) {
|
|
435
|
+
reasoningAccum = part.text;
|
|
436
|
+
const preview = stripMarkdownTables(reasoningAccum.slice(0, REASONING_PREVIEW_LEN));
|
|
437
|
+
const suffix = reasoningAccum.length > REASONING_PREVIEW_LEN ? "..." : "";
|
|
438
|
+
await throttledPatch(`\uD83D\uDCAD **正在思考...**
|
|
420
439
|
|
|
421
440
|
${preview}${suffix}`);
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
441
|
+
} else if (part.type === "tool" && part.state?.status === "running") {
|
|
442
|
+
const toolLabel = (part.tool ?? "") || "工具";
|
|
443
|
+
await throttledPatch(`\uD83D\uDD27 **正在使用工具:${toolLabel}**`);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (event.type === "session.idle" || event.type === "session.error") {
|
|
447
|
+
break;
|
|
425
448
|
}
|
|
426
449
|
}
|
|
427
|
-
|
|
428
|
-
|
|
450
|
+
} catch (err) {
|
|
451
|
+
if (!abortController.signal.aborted) {
|
|
452
|
+
log("warn", `[${channel.name}] SSE 事件流中断: ${String(err)}`);
|
|
429
453
|
}
|
|
454
|
+
} finally {
|
|
455
|
+
clearTimeout(timeoutId);
|
|
430
456
|
}
|
|
431
|
-
} catch (err) {
|
|
432
|
-
log("warn", `[${channel.name}] SSE 事件流中断: ${String(err)}`);
|
|
433
457
|
}
|
|
434
458
|
} else {
|
|
435
459
|
await pollForSessionCompletion(client, channel.name, sessionId);
|
package/package.json
CHANGED