lunel-cli 0.1.97 → 0.1.98
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/ai/codex.js +19 -1
- package/package.json +1 -1
package/dist/ai/codex.js
CHANGED
|
@@ -7,6 +7,21 @@ import { spawn } from "child_process";
|
|
|
7
7
|
import { createInterface } from "readline";
|
|
8
8
|
const THREAD_LIST_SOURCE_KINDS = ["cli", "vscode", "appServer", "exec", "unknown"];
|
|
9
9
|
const DEBUG_MODE = process.env.LUNEL_DEBUG === "1" || process.env.LUNEL_DEBUG_AI === "1";
|
|
10
|
+
function joinStreamingText(previousText, nextChunk) {
|
|
11
|
+
if (!previousText) {
|
|
12
|
+
return nextChunk;
|
|
13
|
+
}
|
|
14
|
+
if (/[\s]$/.test(previousText) || /^[\s]/.test(nextChunk)) {
|
|
15
|
+
return `${previousText}${nextChunk}`;
|
|
16
|
+
}
|
|
17
|
+
if (/^[.,!?;:)\]%}"'`]/.test(nextChunk)) {
|
|
18
|
+
return `${previousText}${nextChunk}`;
|
|
19
|
+
}
|
|
20
|
+
if (/[(\[{/"'`]$/.test(previousText)) {
|
|
21
|
+
return `${previousText}${nextChunk}`;
|
|
22
|
+
}
|
|
23
|
+
return `${previousText} ${nextChunk}`;
|
|
24
|
+
}
|
|
10
25
|
export class CodexProvider {
|
|
11
26
|
proc = null;
|
|
12
27
|
shuttingDown = false;
|
|
@@ -557,7 +572,10 @@ export class CodexProvider {
|
|
|
557
572
|
const nextChunk = this.extractTextPayload(params);
|
|
558
573
|
if (!nextChunk)
|
|
559
574
|
return;
|
|
560
|
-
const
|
|
575
|
+
const previousText = this.partTextById.get(partKey) ?? "";
|
|
576
|
+
const nextText = preferWholeText
|
|
577
|
+
? nextChunk
|
|
578
|
+
: joinStreamingText(previousText, nextChunk);
|
|
561
579
|
this.partTextById.set(partKey, nextText);
|
|
562
580
|
session.updatedAt = Date.now();
|
|
563
581
|
this.upsertLocalMessagePart(session, messageId, {
|