@cloud411716/fancy-webnovel 1.0.8 → 1.0.9
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/infra.js +6 -1
- package/package.json +1 -1
package/infra.js
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
// notify — append a text message as a session event (no LLM round-trip)
|
|
15
15
|
// --------------------------------------------------------------------------
|
|
16
16
|
|
|
17
|
+
/** Strip ANSI escape sequences from a string (defensive, prevents TTY leak). */
|
|
18
|
+
function stripAnsi(str) {
|
|
19
|
+
return String(str).replace(/\x1b[\s\S]*?([a-zA-Z]|$)|\x1b[()][AB012]|\x1b\][^\x07]*(?:\x07|$)/g, '$1');
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
/**
|
|
18
23
|
* @param {object} session - DSH Session object
|
|
19
24
|
* @param {string} text
|
|
@@ -21,7 +26,7 @@
|
|
|
21
26
|
export function notify(session, text) {
|
|
22
27
|
session.append(
|
|
23
28
|
'user/message',
|
|
24
|
-
{ content: [{ type: 'text', text:
|
|
29
|
+
{ content: [{ type: 'text', text: stripAnsi(text) }], source: { kind: 'user' } },
|
|
25
30
|
{ surfaceOp: 'append' }
|
|
26
31
|
);
|
|
27
32
|
}
|