@tencent-weixin/openclaw-weixin 2.4.1 → 2.4.3
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 +45 -0
- package/CHANGELOG.zh_CN.md +45 -0
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/src/api/api.js +41 -7
- package/dist/src/api/api.js.map +1 -1
- package/dist/src/auth/accounts.js.map +1 -1
- package/dist/src/auth/login-qr.js +1 -0
- package/dist/src/auth/login-qr.js.map +1 -1
- package/dist/src/channel.js +19 -0
- package/dist/src/channel.js.map +1 -1
- package/dist/src/media/voice-outbound.js +177 -0
- package/dist/src/media/voice-outbound.js.map +1 -0
- package/dist/src/messaging/abort-fence.js +70 -0
- package/dist/src/messaging/abort-fence.js.map +1 -0
- package/dist/src/messaging/buttons.js +117 -0
- package/dist/src/messaging/buttons.js.map +1 -0
- package/dist/src/messaging/lane-key.js +66 -0
- package/dist/src/messaging/lane-key.js.map +1 -0
- package/dist/src/messaging/merged-record.js +149 -0
- package/dist/src/messaging/merged-record.js.map +1 -0
- package/dist/src/messaging/model-buttons.js +182 -0
- package/dist/src/messaging/model-buttons.js.map +1 -0
- package/dist/src/messaging/model-callback-handler.js +133 -0
- package/dist/src/messaging/model-callback-handler.js.map +1 -0
- package/dist/src/monitor/lane-scheduler.js +46 -0
- package/dist/src/monitor/lane-scheduler.js.map +1 -0
- package/dist/src/monitor/monitor.js +5 -12
- package/dist/src/monitor/monitor.js.map +1 -1
- package/dist/src/streaming/stream-pipeline.js +431 -0
- package/dist/src/streaming/stream-pipeline.js.map +1 -0
- package/dist/src/streaming/stream-session.js +260 -0
- package/dist/src/streaming/stream-session.js.map +1 -0
- package/dist/src/streaming/stream.js +239 -0
- package/dist/src/streaming/stream.js.map +1 -0
- package/dist/src/util/markdown-fences.js +54 -0
- package/dist/src/util/markdown-fences.js.map +1 -0
- package/index.ts +0 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/api/api.ts +42 -8
- package/src/auth/accounts.ts +0 -1
- package/src/auth/login-qr.ts +8 -0
- package/src/channel.ts +22 -1
- package/src/monitor/monitor.ts +11 -10
- package/src/runtime.ts +0 -70
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { StreamAction, StreamType } from "../api/types.js";
|
|
3
|
+
import { sendStreamSignalWeixin } from "../messaging/send.js";
|
|
4
|
+
import { logger } from "../util/logger.js";
|
|
5
|
+
import { WeixinStreamSender } from "./stream.js";
|
|
6
|
+
const DEFAULT_THROTTLE_MS = 1000;
|
|
7
|
+
const DEFAULT_MIN_INITIAL_CHARS = 10;
|
|
8
|
+
const DEFAULT_MAX_PIECE_BYTES = 16 * 1024;
|
|
9
|
+
function unicodeLength(str) {
|
|
10
|
+
let n = 0;
|
|
11
|
+
for (const _ of str)
|
|
12
|
+
n++;
|
|
13
|
+
return n;
|
|
14
|
+
}
|
|
15
|
+
function unicodeSlice(str, start, end) {
|
|
16
|
+
let result = "";
|
|
17
|
+
let i = 0;
|
|
18
|
+
for (const ch of str) {
|
|
19
|
+
if (i >= end)
|
|
20
|
+
break;
|
|
21
|
+
if (i >= start)
|
|
22
|
+
result += ch;
|
|
23
|
+
i++;
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
function escapeNewlines(text) {
|
|
28
|
+
return text.includes("\n") ? text.replaceAll("\n", "\\n") : text;
|
|
29
|
+
}
|
|
30
|
+
function splitUtf8Chunks(encoded, maxBytes) {
|
|
31
|
+
if (encoded.length <= maxBytes)
|
|
32
|
+
return [encoded.toString("utf-8")];
|
|
33
|
+
const result = [];
|
|
34
|
+
let offset = 0;
|
|
35
|
+
while (offset < encoded.length) {
|
|
36
|
+
let end = Math.min(offset + maxBytes, encoded.length);
|
|
37
|
+
if (end < encoded.length) {
|
|
38
|
+
while (end > offset && (encoded[end] & 0xC0) === 0x80)
|
|
39
|
+
end--;
|
|
40
|
+
if (end === offset) {
|
|
41
|
+
end = offset + maxBytes;
|
|
42
|
+
while (end < encoded.length && (encoded[end] & 0xC0) === 0x80)
|
|
43
|
+
end++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
result.push(encoded.subarray(offset, end).toString("utf-8"));
|
|
47
|
+
offset = end;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
export class StreamPipeline {
|
|
52
|
+
// -- config --
|
|
53
|
+
opts;
|
|
54
|
+
throttleMs;
|
|
55
|
+
minInitialChars;
|
|
56
|
+
maxPieceBytes;
|
|
57
|
+
log;
|
|
58
|
+
// -- phase state (single variable) --
|
|
59
|
+
phase = "idle";
|
|
60
|
+
msgStreamId;
|
|
61
|
+
stream;
|
|
62
|
+
_resultStreamId;
|
|
63
|
+
// True once any streaming phase (thinking or result) has actually been started.
|
|
64
|
+
_hadStreaming = false;
|
|
65
|
+
// Set to true when initStream fails for a given phase. Once set, the
|
|
66
|
+
// pipeline stops attempting to open new streams for that phase so subsequent
|
|
67
|
+
// pieces are silently dropped. Thinking and result are tracked independently.
|
|
68
|
+
thinkingInitFailed = false;
|
|
69
|
+
resultInitFailed = false;
|
|
70
|
+
// True while we have buffered result text but haven't yet successfully started
|
|
71
|
+
// the result phase. Used to preserve text across startPhase("result") failures
|
|
72
|
+
// so subsequent result cmds append instead of overwrite.
|
|
73
|
+
resultStartPending = false;
|
|
74
|
+
// -- text buffer + throttle --
|
|
75
|
+
textBuf = "";
|
|
76
|
+
lastSendAt = 0;
|
|
77
|
+
// -- serial queue --
|
|
78
|
+
queue = [];
|
|
79
|
+
running = false;
|
|
80
|
+
aborted = false;
|
|
81
|
+
wakeResolve;
|
|
82
|
+
drainResolvers = [];
|
|
83
|
+
constructor(opts) {
|
|
84
|
+
this.opts = opts;
|
|
85
|
+
this.throttleMs = opts.throttleMs ?? DEFAULT_THROTTLE_MS;
|
|
86
|
+
this.minInitialChars = opts.minInitialChars ?? DEFAULT_MIN_INITIAL_CHARS;
|
|
87
|
+
this.maxPieceBytes = opts.maxPieceBytes ?? DEFAULT_MAX_PIECE_BYTES;
|
|
88
|
+
this.log = opts.log ?? logger;
|
|
89
|
+
this.msgStreamId = `${opts.accountId}:${Date.now()}-${crypto.randomBytes(4).toString("hex")}`;
|
|
90
|
+
this._resultStreamId = this.msgStreamId;
|
|
91
|
+
}
|
|
92
|
+
/** Push a command. Starts the run loop if it isn't already running. */
|
|
93
|
+
push(cmd) {
|
|
94
|
+
if (this.aborted)
|
|
95
|
+
return;
|
|
96
|
+
this.queue.push(cmd);
|
|
97
|
+
if (cmd.kind !== "thinking" && cmd.kind !== "result") {
|
|
98
|
+
this.wakeResolve?.();
|
|
99
|
+
}
|
|
100
|
+
if (!this.running) {
|
|
101
|
+
this.running = true;
|
|
102
|
+
void this.run();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Wait until the queue is fully drained and the run loop exits. */
|
|
106
|
+
async drain() {
|
|
107
|
+
if (!this.running && this.queue.length === 0)
|
|
108
|
+
return;
|
|
109
|
+
return new Promise((resolve) => this.drainResolvers.push(resolve));
|
|
110
|
+
}
|
|
111
|
+
/** Immediately cancel all pending work and abort active streams. */
|
|
112
|
+
async abort(errorMsg) {
|
|
113
|
+
this.aborted = true;
|
|
114
|
+
this.queue.length = 0;
|
|
115
|
+
this.textBuf = "";
|
|
116
|
+
this.wakeResolve?.();
|
|
117
|
+
const stream = this.stream;
|
|
118
|
+
this.stream = undefined;
|
|
119
|
+
if (stream && !stream.isEnded) {
|
|
120
|
+
try {
|
|
121
|
+
await stream.abort(errorMsg);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
this.log.warn(`pipeline: abort failed err=${String(err)}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const r of this.drainResolvers)
|
|
128
|
+
r();
|
|
129
|
+
this.drainResolvers = [];
|
|
130
|
+
}
|
|
131
|
+
get resultStreamId() {
|
|
132
|
+
return this._resultStreamId;
|
|
133
|
+
}
|
|
134
|
+
/** True once any streaming phase (thinking or result) has actually been started. */
|
|
135
|
+
get hadStreaming() {
|
|
136
|
+
return this._hadStreaming;
|
|
137
|
+
}
|
|
138
|
+
// ======================================================================
|
|
139
|
+
// Run loop — the single serial executor
|
|
140
|
+
// ======================================================================
|
|
141
|
+
async run() {
|
|
142
|
+
try {
|
|
143
|
+
while (true) {
|
|
144
|
+
while (this.queue.length > 0 && !this.aborted) {
|
|
145
|
+
await this.process(this.queue.shift());
|
|
146
|
+
}
|
|
147
|
+
if (this.textBuf && !this.aborted && this.phase !== "idle") {
|
|
148
|
+
const wait = this.throttleMs - (Date.now() - this.lastSendAt);
|
|
149
|
+
if (wait > 0) {
|
|
150
|
+
await this.sleep(wait);
|
|
151
|
+
this.coalesceQueuedText();
|
|
152
|
+
}
|
|
153
|
+
if (this.textBuf && !this.aborted) {
|
|
154
|
+
try {
|
|
155
|
+
await this.flushText();
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
this.log.warn(`pipeline: throttle flush failed: ${String(err)}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
this.log.warn(`pipeline: run loop error: ${String(err)}`);
|
|
168
|
+
}
|
|
169
|
+
finally {
|
|
170
|
+
this.running = false;
|
|
171
|
+
for (const r of this.drainResolvers)
|
|
172
|
+
r();
|
|
173
|
+
this.drainResolvers = [];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ======================================================================
|
|
177
|
+
// Command processing — all logic in one switch
|
|
178
|
+
// ======================================================================
|
|
179
|
+
async process(cmd) {
|
|
180
|
+
try {
|
|
181
|
+
switch (cmd.kind) {
|
|
182
|
+
case "thinking":
|
|
183
|
+
this.textBuf += cmd.text;
|
|
184
|
+
this.coalesceQueuedTextOfKind("thinking");
|
|
185
|
+
if (this.phase === "idle") {
|
|
186
|
+
if (unicodeLength(this.textBuf) < this.minInitialChars)
|
|
187
|
+
return;
|
|
188
|
+
await this.startPhase("thinking");
|
|
189
|
+
}
|
|
190
|
+
await this.throttledFlush();
|
|
191
|
+
break;
|
|
192
|
+
case "thinking_refresh":
|
|
193
|
+
this.textBuf = cmd.text;
|
|
194
|
+
if (this.phase === "thinking" && this.stream && !this.stream.isEnded) {
|
|
195
|
+
this.log.debug(`STREAM THINKING REWIND ${escapeNewlines(cmd.text)}`);
|
|
196
|
+
await this.stream.sendPiece({ type: "text", text: cmd.text, rewind: true, stream_type: "thinking" });
|
|
197
|
+
this.lastSendAt = Date.now();
|
|
198
|
+
this.textBuf = "";
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case "tool_call":
|
|
202
|
+
if (this.phase === "idle")
|
|
203
|
+
await this.startPhase("thinking");
|
|
204
|
+
await this.flushText();
|
|
205
|
+
if (this.stream && !this.stream.isEnded) {
|
|
206
|
+
this.log.debug(`STREAM THINKING TOOL ${JSON.stringify({ name: cmd.name, phase: cmd.phase })}`);
|
|
207
|
+
await this.stream.sendPiece({
|
|
208
|
+
type: "tool_calling",
|
|
209
|
+
name: cmd.name,
|
|
210
|
+
phase: cmd.phase,
|
|
211
|
+
stream_type: "thinking",
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case "result": {
|
|
216
|
+
let resultText = cmd.text;
|
|
217
|
+
while (this.queue.length > 0 && this.queue[0].kind === "result") {
|
|
218
|
+
resultText += this.queue.shift().text;
|
|
219
|
+
}
|
|
220
|
+
if (this.phase !== "result") {
|
|
221
|
+
await this.endCurrentPhase();
|
|
222
|
+
const isResultStartRetry = this.resultStartPending;
|
|
223
|
+
if (isResultStartRetry) {
|
|
224
|
+
// A previous attempt to start the result phase failed (or was below
|
|
225
|
+
// minInitialChars): preserve the pending text so it isn't lost.
|
|
226
|
+
this.textBuf += resultText;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
// First transition into result: drop any leftover thinking residue.
|
|
230
|
+
this.textBuf = resultText;
|
|
231
|
+
this.resultStartPending = true;
|
|
232
|
+
}
|
|
233
|
+
const tooShort = unicodeLength(this.textBuf) < this.minInitialChars;
|
|
234
|
+
// Avoid stalling the result stream when the last buffered chunk is short
|
|
235
|
+
// (e.g. markdown tail) but `finalize` is already queued — otherwise the
|
|
236
|
+
// client keeps thinking/placeholder UI and never gets a FINISH + stream_id.
|
|
237
|
+
const finalizeQueued = this.queue.some((c) => c.kind === "finalize");
|
|
238
|
+
if (tooShort && !finalizeQueued)
|
|
239
|
+
return;
|
|
240
|
+
if (isResultStartRetry) {
|
|
241
|
+
this.log.info(`pipeline: retrying startPhase(result) bufBytes=${Buffer.byteLength(this.textBuf, "utf-8")}`);
|
|
242
|
+
}
|
|
243
|
+
await this.startPhase("result");
|
|
244
|
+
this.resultStartPending = false;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.textBuf += resultText;
|
|
248
|
+
}
|
|
249
|
+
await this.throttledFlush();
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
case "finalize":
|
|
253
|
+
await this.doFinalize(cmd.deliverText);
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
this.log.warn(`pipeline: ${cmd.kind} failed phase=${this.phase} queueLen=${this.queue.length} bufBytes=${Buffer.byteLength(this.textBuf, "utf-8")} resultStartPending=${this.resultStartPending} err=${String(err)}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// ======================================================================
|
|
262
|
+
// Phase transitions — the only place phase changes
|
|
263
|
+
// ======================================================================
|
|
264
|
+
async startPhase(target) {
|
|
265
|
+
const failed = target === "thinking" ? this.thinkingInitFailed : this.resultInitFailed;
|
|
266
|
+
if (failed)
|
|
267
|
+
return;
|
|
268
|
+
const stream = new WeixinStreamSender(this.opts);
|
|
269
|
+
try {
|
|
270
|
+
await stream.init();
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
if (target === "thinking")
|
|
274
|
+
this.thinkingInitFailed = true;
|
|
275
|
+
else
|
|
276
|
+
this.resultInitFailed = true;
|
|
277
|
+
this.log.warn(`pipeline: startPhase(${target}) init failed, disabling ${target} streaming msgStreamId=${this.msgStreamId} bufBytes=${Buffer.byteLength(this.textBuf, "utf-8")} err=${String(err)}`);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
this.stream = stream;
|
|
281
|
+
const action = target === "thinking" ? StreamAction.THINKING : StreamAction.RESULT;
|
|
282
|
+
const digest = this.textBuf ? unicodeSlice(this.textBuf, 0, 30) : undefined;
|
|
283
|
+
try {
|
|
284
|
+
await sendStreamSignalWeixin({
|
|
285
|
+
to: this.opts.to,
|
|
286
|
+
streamItem: {
|
|
287
|
+
stream_type: StreamType.TEXT,
|
|
288
|
+
stream_id: this.msgStreamId,
|
|
289
|
+
ilink_stream_ticket: stream.ticket,
|
|
290
|
+
digest,
|
|
291
|
+
action,
|
|
292
|
+
},
|
|
293
|
+
opts: {
|
|
294
|
+
baseUrl: this.opts.baseUrl,
|
|
295
|
+
token: this.opts.token,
|
|
296
|
+
accountId: this.opts.accountId,
|
|
297
|
+
contextToken: this.opts.contextToken,
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
this.log.warn(`pipeline: sendStreamSignal failed target=${target} msgStreamId=${this.msgStreamId} streamId=${stream.streamId} err=${String(err)}`);
|
|
303
|
+
this.stream = undefined;
|
|
304
|
+
try {
|
|
305
|
+
await stream.abort("signal failed");
|
|
306
|
+
}
|
|
307
|
+
catch (abortErr) {
|
|
308
|
+
this.log.debug(`pipeline: best-effort abort after signal failure failed streamId=${stream.streamId} err=${String(abortErr)}`);
|
|
309
|
+
}
|
|
310
|
+
throw err;
|
|
311
|
+
}
|
|
312
|
+
this.phase = target;
|
|
313
|
+
this._hadStreaming = true;
|
|
314
|
+
this.log.info(`pipeline: phase → ${target} streamId=${stream.streamId}`);
|
|
315
|
+
}
|
|
316
|
+
async endCurrentPhase() {
|
|
317
|
+
if (this.phase === "idle" || this.phase === "ended")
|
|
318
|
+
return;
|
|
319
|
+
try {
|
|
320
|
+
await this.flushText();
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
this.log.warn(`pipeline: flushText in end-${this.phase} failed: ${String(err)}`);
|
|
324
|
+
}
|
|
325
|
+
const prev = this.phase;
|
|
326
|
+
this.phase = "idle";
|
|
327
|
+
const s = this.stream;
|
|
328
|
+
this.stream = undefined;
|
|
329
|
+
if (s && !s.isEnded) {
|
|
330
|
+
try {
|
|
331
|
+
if (s.currentPieceSeq === 0) {
|
|
332
|
+
await s.abort("no pieces");
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
await s.end();
|
|
336
|
+
}
|
|
337
|
+
this.log.info(`pipeline: ended ${prev} stream seq=${s.currentPieceSeq}`);
|
|
338
|
+
}
|
|
339
|
+
catch (err) {
|
|
340
|
+
this.log.warn(`pipeline: end-${prev} stream failed: ${String(err)}`);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async doFinalize(deliverText) {
|
|
345
|
+
if (this.phase === "ended")
|
|
346
|
+
return;
|
|
347
|
+
if (this.phase !== "result" && this._hadStreaming && deliverText) {
|
|
348
|
+
await this.endCurrentPhase();
|
|
349
|
+
this.textBuf = deliverText;
|
|
350
|
+
try {
|
|
351
|
+
await this.startPhase("result");
|
|
352
|
+
await this.flushText();
|
|
353
|
+
}
|
|
354
|
+
catch (err) {
|
|
355
|
+
this.log.warn(`pipeline: late startResult failed: ${String(err)}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
await this.endCurrentPhase();
|
|
359
|
+
this.phase = "ended";
|
|
360
|
+
}
|
|
361
|
+
// ======================================================================
|
|
362
|
+
// Text buffer management
|
|
363
|
+
// ======================================================================
|
|
364
|
+
async throttledFlush() {
|
|
365
|
+
if (!this.textBuf)
|
|
366
|
+
return;
|
|
367
|
+
if (Date.now() - this.lastSendAt >= this.throttleMs) {
|
|
368
|
+
await this.flushText();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async flushText() {
|
|
372
|
+
if (!this.textBuf)
|
|
373
|
+
return;
|
|
374
|
+
if (!this.stream || this.stream.isEnded) {
|
|
375
|
+
const droppedBytes = Buffer.byteLength(this.textBuf, "utf-8");
|
|
376
|
+
this.log.warn(`pipeline: flushText dropping ${droppedBytes} bytes — stream ${this.stream ? "already ended" : "missing"} phase=${this.phase}`);
|
|
377
|
+
this.textBuf = "";
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const text = this.textBuf;
|
|
381
|
+
this.textBuf = "";
|
|
382
|
+
const logLabel = this.phase === "thinking" ? "THINKING" : "RESULT";
|
|
383
|
+
const streamType = this.phase === "thinking" ? "thinking" : "result";
|
|
384
|
+
const chunks = splitUtf8Chunks(Buffer.from(text, "utf-8"), this.maxPieceBytes);
|
|
385
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
386
|
+
if (this.aborted)
|
|
387
|
+
break;
|
|
388
|
+
const chunk = chunks[i];
|
|
389
|
+
this.log.debug(`STREAM ${logLabel} PIECE ${escapeNewlines(chunk)}`);
|
|
390
|
+
try {
|
|
391
|
+
await this.stream.sendPiece({ type: "text", text: chunk, stream_type: streamType });
|
|
392
|
+
}
|
|
393
|
+
catch (err) {
|
|
394
|
+
// The failed chunk is now tracked inside the stream's pendingPieces and
|
|
395
|
+
// will be retried automatically on the next sendPiece call. We only
|
|
396
|
+
// need to preserve the *remaining unsent* chunks (i+1 onwards) so the
|
|
397
|
+
// next flush picks them up. Skip if the pipeline has been aborted
|
|
398
|
+
// (abort() already cleared textBuf; restoring would undo that).
|
|
399
|
+
const remaining = chunks.slice(i + 1).join("");
|
|
400
|
+
if (!this.aborted) {
|
|
401
|
+
this.textBuf = remaining;
|
|
402
|
+
}
|
|
403
|
+
this.log.warn(`pipeline: flushText chunk ${i + 1}/${chunks.length} failed phase=${this.phase} requeuedBytes=${Buffer.byteLength(remaining, "utf-8")} pendingOnSender=yes err=${String(err)}`);
|
|
404
|
+
throw err;
|
|
405
|
+
}
|
|
406
|
+
this.lastSendAt = Date.now();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/** Absorb consecutive text commands of a specific kind from the front of the queue. */
|
|
410
|
+
coalesceQueuedTextOfKind(kind) {
|
|
411
|
+
while (this.queue.length > 0 && this.queue[0].kind === kind) {
|
|
412
|
+
this.textBuf += this.queue.shift().text;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/** Absorb consecutive text commands matching the current phase from the queue. */
|
|
416
|
+
coalesceQueuedText() {
|
|
417
|
+
const kind = this.phase === "result" ? "result" : "thinking";
|
|
418
|
+
this.coalesceQueuedTextOfKind(kind);
|
|
419
|
+
}
|
|
420
|
+
sleep(ms) {
|
|
421
|
+
return new Promise((resolve) => {
|
|
422
|
+
const timer = setTimeout(resolve, ms);
|
|
423
|
+
this.wakeResolve = () => {
|
|
424
|
+
clearTimeout(timer);
|
|
425
|
+
this.wakeResolve = undefined;
|
|
426
|
+
resolve();
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=stream-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-pipeline.js","sourceRoot":"","sources":["../../../src/streaming/stream-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MA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