@love-moon/ai-sdk 0.11.2 → 0.13.0
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/CHANGELOG.md +4 -0
- package/dist/providers/kimi-print-session.js +34 -10
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -532,6 +532,10 @@ export class KimiPrintSession extends EventEmitter {
|
|
|
532
532
|
const stdoutReader = readline.createInterface({ input: child.stdout });
|
|
533
533
|
const stderrReader = readline.createInterface({ input: child.stderr });
|
|
534
534
|
let timeoutId = null;
|
|
535
|
+
let lastActivityAt = Date.now();
|
|
536
|
+
const noteTurnActivity = () => {
|
|
537
|
+
lastActivityAt = Date.now();
|
|
538
|
+
};
|
|
535
539
|
const settle = (error, value = null) => {
|
|
536
540
|
if (currentTurn.settled) {
|
|
537
541
|
return;
|
|
@@ -548,17 +552,35 @@ export class KimiPrintSession extends EventEmitter {
|
|
|
548
552
|
}
|
|
549
553
|
resolve(value);
|
|
550
554
|
};
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
555
|
+
// Activity-based idle deadline (aligned with wire mode): any stdout/stderr
|
|
556
|
+
// output resets the idle clock, so a busy turn is never killed mid-work;
|
|
557
|
+
// only a turn with no output at all for turnDeadlineMs is considered stuck.
|
|
558
|
+
const scheduleTurnDeadline = () => {
|
|
559
|
+
if (currentTurn.settled) {
|
|
560
|
+
return;
|
|
557
561
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
+
const idleMs = Math.max(0, Date.now() - lastActivityAt);
|
|
563
|
+
const waitMs = Math.max(1, this.turnDeadlineMs - idleMs);
|
|
564
|
+
timeoutId = setTimeout(() => {
|
|
565
|
+
if (currentTurn.settled) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (Date.now() - lastActivityAt < this.turnDeadlineMs) {
|
|
569
|
+
scheduleTurnDeadline();
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
try {
|
|
573
|
+
child.kill("SIGTERM");
|
|
574
|
+
}
|
|
575
|
+
catch {
|
|
576
|
+
// ignore
|
|
577
|
+
}
|
|
578
|
+
settle(createTurnError("Kimi print turn timed out", {
|
|
579
|
+
reason: "turn_timeout",
|
|
580
|
+
}));
|
|
581
|
+
}, waitMs);
|
|
582
|
+
};
|
|
583
|
+
scheduleTurnDeadline();
|
|
562
584
|
stdoutReader.on("line", (line) => {
|
|
563
585
|
const normalizedLine = String(line || "").trim();
|
|
564
586
|
if (!normalizedLine) {
|
|
@@ -571,6 +593,7 @@ export class KimiPrintSession extends EventEmitter {
|
|
|
571
593
|
catch {
|
|
572
594
|
payload = { role: "raw", content: normalizedLine };
|
|
573
595
|
}
|
|
596
|
+
noteTurnActivity();
|
|
574
597
|
currentTurn.items.push(payload);
|
|
575
598
|
const role = String(payload?.role || "").trim().toLowerCase();
|
|
576
599
|
if (role === "meta") {
|
|
@@ -615,6 +638,7 @@ export class KimiPrintSession extends EventEmitter {
|
|
|
615
638
|
if (!normalizedLine.trim()) {
|
|
616
639
|
return;
|
|
617
640
|
}
|
|
641
|
+
noteTurnActivity();
|
|
618
642
|
currentTurn.stderrTail.push(normalizedLine);
|
|
619
643
|
if (currentTurn.stderrTail.length > 20) {
|
|
620
644
|
currentTurn.stderrTail.shift();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@love-moon/ai-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lovemoon-ai/conductor.git"
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"zod": "^4.1.5"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
|
56
|
-
"@love-moon/chat-web": "^0.
|
|
56
|
+
"@love-moon/chat-web": "^0.13.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^22.10.2",
|
|
60
60
|
"tsx": "^4.20.6",
|
|
61
61
|
"typescript": "^5.6.3"
|
|
62
62
|
},
|
|
63
|
-
"gitCommitId": "
|
|
63
|
+
"gitCommitId": "e1e507f"
|
|
64
64
|
}
|