deepccc 0.2.11 → 0.2.12
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/README.md +2 -0
- package/dist/index.js +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -478,16 +478,25 @@ export class ChatSession {
|
|
|
478
478
|
messages: attemptMessages,
|
|
479
479
|
};
|
|
480
480
|
let stream;
|
|
481
|
+
let requiresFinish = false;
|
|
482
|
+
let receivedFinish = false;
|
|
483
|
+
let finishReason;
|
|
481
484
|
if (this.streaming) {
|
|
482
485
|
const result = streamText(generationOptions);
|
|
486
|
+
requiresFinish = result.fullStream != null;
|
|
483
487
|
stream = result.fullStream ?? textStreamToFullStream(result.textStream);
|
|
484
488
|
}
|
|
485
489
|
else {
|
|
486
490
|
const result = await generateText(generationOptions);
|
|
491
|
+
finishReason = result.finishReason;
|
|
487
492
|
stream = generateResultToFullStream(result);
|
|
488
493
|
}
|
|
489
494
|
for await (const part of stream) {
|
|
490
495
|
rawLog?.writeLine(safeRawStreamJson(part));
|
|
496
|
+
if (part.type === "finish") {
|
|
497
|
+
receivedFinish = true;
|
|
498
|
+
finishReason = part.finishReason;
|
|
499
|
+
}
|
|
491
500
|
if (part.type === "reasoning-start" || part.type === "reasoning-delta") {
|
|
492
501
|
// Reasoning content remains private. A throttled heartbeat is enough
|
|
493
502
|
// for ChatCCC to distinguish active inference from a stalled stream.
|
|
@@ -561,6 +570,14 @@ export class ChatSession {
|
|
|
561
570
|
throw new Error(message);
|
|
562
571
|
}
|
|
563
572
|
}
|
|
573
|
+
if (!signal?.aborted) {
|
|
574
|
+
if (requiresFinish && !receivedFinish)
|
|
575
|
+
throw new Error("DeepCCC 输出流中断:未收到模型完成事件,回复可能不完整");
|
|
576
|
+
if (finishReason === "error" || finishReason === "length")
|
|
577
|
+
throw new Error(`DeepCCC 未正常完成:finishReason=${finishReason},回复可能不完整`);
|
|
578
|
+
if (!fullText.trim() && toolCallOrder.length === 0)
|
|
579
|
+
throw new Error("DeepCCC 本轮未产生有效回复");
|
|
580
|
+
}
|
|
564
581
|
if (hasMalformedToolProtocolText(fullText)) {
|
|
565
582
|
console.warn(`[DeepCCC] malformed tool protocol text detected for ${this.context.sessionId} `
|
|
566
583
|
+ `(attempt ${attempt + 1}/2, structuredToolCalls=${toolCallOrder.length})`);
|