@vibe-lark/larkpal 0.1.39 → 0.1.41
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/main.mjs +24 -3
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -6280,7 +6280,7 @@ const CC_INTERNAL_PLACEHOLDER = "No response requested.";
|
|
|
6280
6280
|
*
|
|
6281
6281
|
* 内部维护文本累积状态,将增量事件转换为控制器需要的累积文本回调。
|
|
6282
6282
|
*/
|
|
6283
|
-
var CCStreamBridge = class {
|
|
6283
|
+
var CCStreamBridge = class CCStreamBridge {
|
|
6284
6284
|
/** 累积的文本输出(textDelta 逐步拼接) */
|
|
6285
6285
|
accumulatedText = "";
|
|
6286
6286
|
/** 累积的思考输出(thinkingDelta 逐步拼接) */
|
|
@@ -6303,14 +6303,35 @@ var CCStreamBridge = class {
|
|
|
6303
6303
|
sessionKey: this.options.sessionKey ?? "(none)"
|
|
6304
6304
|
});
|
|
6305
6305
|
}
|
|
6306
|
-
/**
|
|
6306
|
+
/** 交互式标记前缀 — 用于流式过滤 */
|
|
6307
|
+
static INTERACTIVE_MARKER_PREFIXES = ["[ASK_USER]", "[PERMISSION_REQUEST]"];
|
|
6308
|
+
/** 检查文本末尾是否可能是标记的不完整前缀 */
|
|
6309
|
+
static getPartialMarkerCutoff(text) {
|
|
6310
|
+
for (const marker of CCStreamBridge.INTERACTIVE_MARKER_PREFIXES) for (let len = marker.length - 1; len >= 2; len--) {
|
|
6311
|
+
const partial = marker.substring(0, len);
|
|
6312
|
+
if (text.endsWith(partial)) return text.length - len;
|
|
6313
|
+
}
|
|
6314
|
+
return -1;
|
|
6315
|
+
}
|
|
6316
|
+
/** 文本增量 → 累积后调用 controller.onPartialReply(实时过滤交互式标记) */
|
|
6307
6317
|
onTextDelta(text) {
|
|
6308
6318
|
this.accumulatedText += text;
|
|
6309
6319
|
log$18.debug("textDelta 事件", {
|
|
6310
6320
|
deltaLen: text.length,
|
|
6311
6321
|
totalLen: this.accumulatedText.length
|
|
6312
6322
|
});
|
|
6313
|
-
|
|
6323
|
+
let displayText = this.accumulatedText;
|
|
6324
|
+
for (const prefix of CCStreamBridge.INTERACTIVE_MARKER_PREFIXES) {
|
|
6325
|
+
const idx = displayText.indexOf(prefix);
|
|
6326
|
+
if (idx !== -1) {
|
|
6327
|
+
displayText = displayText.substring(0, idx).trimEnd();
|
|
6328
|
+
this.controller.onPartialReply({ text: displayText });
|
|
6329
|
+
return;
|
|
6330
|
+
}
|
|
6331
|
+
}
|
|
6332
|
+
const cutoff = CCStreamBridge.getPartialMarkerCutoff(displayText);
|
|
6333
|
+
if (cutoff !== -1) displayText = displayText.substring(0, cutoff);
|
|
6334
|
+
this.controller.onPartialReply({ text: displayText });
|
|
6314
6335
|
}
|
|
6315
6336
|
/** 思考增量 → 累积后调用 controller.onReasoningStream */
|
|
6316
6337
|
onThinkingDelta(text) {
|