@owloops/browserbird 1.8.4 → 1.8.5
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/index.mjs +18 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -193,8 +193,8 @@ function unknownSubcommand(subcommand, command, validCommands) {
|
|
|
193
193
|
/** @fileoverview ASCII banner displayed on daemon startup and in help text. */
|
|
194
194
|
const pkg = createRequire(import.meta.url)("../package.json");
|
|
195
195
|
const buildInfo = [];
|
|
196
|
-
buildInfo.push(`commit: ${"
|
|
197
|
-
buildInfo.push(`built: 2026-03-22T17:
|
|
196
|
+
buildInfo.push(`commit: ${"258f644d7838a281ab32e4095dd9a9fc43e603d4".substring(0, 7)}`);
|
|
197
|
+
buildInfo.push(`built: 2026-03-22T17:47:18+04:00`);
|
|
198
198
|
const buildString = buildInfo.length > 0 ? ` (${buildInfo.join(", ")})` : "";
|
|
199
199
|
const VERSION = `browserbird ${pkg.version}${buildString}`;
|
|
200
200
|
const BIRD = [
|
|
@@ -4475,13 +4475,15 @@ function createHandler(client, getConfig, signal, getTeamId, getChannelNameToId)
|
|
|
4475
4475
|
}).join("\n");
|
|
4476
4476
|
}
|
|
4477
4477
|
async function streamToChannel(events, channelId, threadTs, sessionUid, teamId, userId, meta) {
|
|
4478
|
-
const
|
|
4478
|
+
const streamOpts = {
|
|
4479
4479
|
channelId,
|
|
4480
4480
|
threadTs,
|
|
4481
4481
|
teamId,
|
|
4482
4482
|
userId
|
|
4483
|
-
}
|
|
4483
|
+
};
|
|
4484
|
+
let streamer = client.startStream(streamOpts);
|
|
4484
4485
|
let streamDead = false;
|
|
4486
|
+
let streamedChars = 0;
|
|
4485
4487
|
let fullText = "";
|
|
4486
4488
|
let completion;
|
|
4487
4489
|
let hasError = false;
|
|
@@ -4491,17 +4493,29 @@ function createHandler(client, getConfig, signal, getTeamId, getChannelNameToId)
|
|
|
4491
4493
|
let toolCount = 0;
|
|
4492
4494
|
let toolErrors = 0;
|
|
4493
4495
|
let toolSuccesses = 0;
|
|
4496
|
+
const STREAM_CHAR_LIMIT = 3e4;
|
|
4494
4497
|
function isStreamExpired(err) {
|
|
4495
4498
|
const msg = err instanceof Error ? err.message : String(err);
|
|
4496
4499
|
return msg.includes("not_in_streaming_state") || msg.includes("streaming") || msg.includes("msg_too_long");
|
|
4497
4500
|
}
|
|
4501
|
+
async function resetStream() {
|
|
4502
|
+
try {
|
|
4503
|
+
await streamer.stop();
|
|
4504
|
+
} catch {}
|
|
4505
|
+
streamer = client.startStream(streamOpts);
|
|
4506
|
+
streamedChars = 0;
|
|
4507
|
+
logger.debug("stream reset: started new streaming message");
|
|
4508
|
+
}
|
|
4498
4509
|
async function safeAppend(content) {
|
|
4499
4510
|
if (streamDead) {
|
|
4500
4511
|
if (content.markdown_text) await client.postMessage(channelId, threadTs, content.markdown_text).catch(() => {});
|
|
4501
4512
|
return;
|
|
4502
4513
|
}
|
|
4514
|
+
const textLen = content.markdown_text?.length ?? 0;
|
|
4515
|
+
if (textLen > 0 && streamedChars + textLen > STREAM_CHAR_LIMIT) await resetStream();
|
|
4503
4516
|
try {
|
|
4504
4517
|
await streamer.append(content);
|
|
4518
|
+
streamedChars += textLen;
|
|
4505
4519
|
} catch (err) {
|
|
4506
4520
|
if (isStreamExpired(err)) {
|
|
4507
4521
|
streamDead = true;
|