@threadbase-sh/streamer 1.56.0 → 1.57.0
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/cli.cjs +24 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -145659,6 +145659,7 @@ function readBody2(req) {
|
|
|
145659
145659
|
// src/api/handlers/conversations.handlers.ts
|
|
145660
145660
|
var SEARCH_OVERFETCH = 4;
|
|
145661
145661
|
var SEARCH_MAX_SCAN = 1e3;
|
|
145662
|
+
var MAX_BYTES_CEILING = 32 * 1024 * 1024;
|
|
145662
145663
|
var ConversationHandlers = class {
|
|
145663
145664
|
constructor(deps) {
|
|
145664
145665
|
this.deps = deps;
|
|
@@ -146064,7 +146065,7 @@ var ConversationHandlers = class {
|
|
|
146064
146065
|
const total = filtered.length;
|
|
146065
146066
|
const hasAnchor = url2.searchParams.has("anchor_index");
|
|
146066
146067
|
const hasAfter = url2.searchParams.has("after_index");
|
|
146067
|
-
const usePaging = url2.searchParams.has("msg_limit") || url2.searchParams.has("before_index") || hasAnchor || hasAfter;
|
|
146068
|
+
const usePaging = url2.searchParams.has("msg_limit") || url2.searchParams.has("before_index") || url2.searchParams.has("max_bytes") || hasAnchor || hasAfter;
|
|
146068
146069
|
let slice = filtered;
|
|
146069
146070
|
let fromIdx = 0;
|
|
146070
146071
|
let messagePagination;
|
|
@@ -146186,6 +146187,28 @@ var ConversationHandlers = class {
|
|
|
146186
146187
|
content
|
|
146187
146188
|
};
|
|
146188
146189
|
});
|
|
146190
|
+
const requestedMaxBytes = intParam(url2, "max_bytes", 0);
|
|
146191
|
+
if (requestedMaxBytes > 0 && messagesPayload.length > 0) {
|
|
146192
|
+
const budget = Math.min(requestedMaxBytes, MAX_BYTES_CEILING);
|
|
146193
|
+
let used = 0;
|
|
146194
|
+
let firstKept = messagesPayload.length - 1;
|
|
146195
|
+
for (let i = messagesPayload.length - 1; i >= 0; i--) {
|
|
146196
|
+
const size = Buffer.byteLength(JSON.stringify(messagesPayload[i]));
|
|
146197
|
+
if (i < messagesPayload.length - 1 && used + size > budget) break;
|
|
146198
|
+
used += size;
|
|
146199
|
+
firstKept = i;
|
|
146200
|
+
}
|
|
146201
|
+
if (firstKept > 0) {
|
|
146202
|
+
messagesPayload.splice(0, firstKept);
|
|
146203
|
+
if (messagePagination) {
|
|
146204
|
+
const newFrom = fromIdx + firstKept;
|
|
146205
|
+
messagePagination.from_index = newFrom;
|
|
146206
|
+
messagePagination.has_more_older = newFrom > 0;
|
|
146207
|
+
messagePagination.next_before_index = newFrom > 0 ? newFrom : null;
|
|
146208
|
+
}
|
|
146209
|
+
}
|
|
146210
|
+
if (messagePagination) messagePagination.served_bytes = used;
|
|
146211
|
+
}
|
|
146189
146212
|
const conv = conversation;
|
|
146190
146213
|
const cachedConvMeta = this.cache?.getMetaById(id);
|
|
146191
146214
|
const convProvider = coerceProviderForRunner(conv.provider ?? cachedConvMeta?.provider);
|