@nomad-e/bluma-cli 0.24.0 → 0.24.2
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.js +74 -10
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2275,6 +2275,23 @@ function messageExtraForTokens(msg) {
|
|
|
2275
2275
|
}
|
|
2276
2276
|
return parts.join("\0");
|
|
2277
2277
|
}
|
|
2278
|
+
function tokensForString(s) {
|
|
2279
|
+
if (s.length === 0) return 0;
|
|
2280
|
+
let cached = tokenStringCache.get(s);
|
|
2281
|
+
if (cached !== void 0) return cached;
|
|
2282
|
+
cached = getO200kEncoding().encode(s).length;
|
|
2283
|
+
if (tokenStringCache.size >= TOKEN_STRING_CACHE_MAX) {
|
|
2284
|
+
const first = tokenStringCache.keys().next().value;
|
|
2285
|
+
if (first !== void 0) tokenStringCache.delete(first);
|
|
2286
|
+
}
|
|
2287
|
+
tokenStringCache.set(s, cached);
|
|
2288
|
+
return cached;
|
|
2289
|
+
}
|
|
2290
|
+
function tokensForMessage(msg) {
|
|
2291
|
+
const body = messageBodyForTokens(msg);
|
|
2292
|
+
const extra = messageExtraForTokens(msg);
|
|
2293
|
+
return tokensForString(body) + tokensForString(extra) + MESSAGE_OVERHEAD_TOKENS;
|
|
2294
|
+
}
|
|
2278
2295
|
function countTokens(messages, useCache = true) {
|
|
2279
2296
|
if (messages.length === 0) {
|
|
2280
2297
|
return CONVERSATION_BASE_OVERHEAD;
|
|
@@ -2282,14 +2299,9 @@ function countTokens(messages, useCache = true) {
|
|
|
2282
2299
|
if (useCache && cacheVersion === cachedVersion) {
|
|
2283
2300
|
return cachedCount;
|
|
2284
2301
|
}
|
|
2285
|
-
const enc = getO200kEncoding();
|
|
2286
2302
|
let total = CONVERSATION_BASE_OVERHEAD;
|
|
2287
2303
|
for (const msg of messages) {
|
|
2288
|
-
|
|
2289
|
-
const extra = messageExtraForTokens(msg);
|
|
2290
|
-
const nBody = body ? enc.encode(body).length : 0;
|
|
2291
|
-
const nExtra = extra ? enc.encode(extra).length : 0;
|
|
2292
|
-
total += nBody + nExtra + MESSAGE_OVERHEAD_TOKENS;
|
|
2304
|
+
total += tokensForMessage(msg);
|
|
2293
2305
|
}
|
|
2294
2306
|
if (useCache) {
|
|
2295
2307
|
cachedVersion = cacheVersion;
|
|
@@ -2321,7 +2333,7 @@ function computeEffectiveInputBudget(rawBudget, toolDefinitions = [], options) {
|
|
|
2321
2333
|
effectiveBudget
|
|
2322
2334
|
};
|
|
2323
2335
|
}
|
|
2324
|
-
var MESSAGE_OVERHEAD_TOKENS, CONVERSATION_BASE_OVERHEAD, cachedEncoding, cacheVersion, cachedVersion, cachedCount, DEFAULT_OUTPUT_TOKEN_RESERVE, DEFAULT_PROTOCOL_OVERHEAD_TOKENS;
|
|
2336
|
+
var MESSAGE_OVERHEAD_TOKENS, CONVERSATION_BASE_OVERHEAD, cachedEncoding, cacheVersion, cachedVersion, cachedCount, tokenStringCache, TOKEN_STRING_CACHE_MAX, DEFAULT_OUTPUT_TOKEN_RESERVE, DEFAULT_PROTOCOL_OVERHEAD_TOKENS;
|
|
2325
2337
|
var init_token_counter = __esm({
|
|
2326
2338
|
"src/app/agent/core/context-api/token_counter.ts"() {
|
|
2327
2339
|
"use strict";
|
|
@@ -2331,6 +2343,8 @@ var init_token_counter = __esm({
|
|
|
2331
2343
|
cacheVersion = 0;
|
|
2332
2344
|
cachedVersion = -1;
|
|
2333
2345
|
cachedCount = 0;
|
|
2346
|
+
tokenStringCache = /* @__PURE__ */ new Map();
|
|
2347
|
+
TOKEN_STRING_CACHE_MAX = 4096;
|
|
2334
2348
|
DEFAULT_OUTPUT_TOKEN_RESERVE = 8192;
|
|
2335
2349
|
DEFAULT_PROTOCOL_OVERHEAD_TOKENS = 512;
|
|
2336
2350
|
}
|
|
@@ -26414,7 +26428,14 @@ function cleanupOldEntries() {
|
|
|
26414
26428
|
}
|
|
26415
26429
|
function setToolResultStatus(toolCallId, status, result) {
|
|
26416
26430
|
if (!toolCallId) return;
|
|
26417
|
-
|
|
26431
|
+
let parsedResult = result;
|
|
26432
|
+
if (typeof result === "string") {
|
|
26433
|
+
try {
|
|
26434
|
+
parsedResult = JSON.parse(result);
|
|
26435
|
+
} catch {
|
|
26436
|
+
parsedResult = result;
|
|
26437
|
+
}
|
|
26438
|
+
}
|
|
26418
26439
|
store.set(toolCallId, { status, timestamp: Date.now(), result: parsedResult });
|
|
26419
26440
|
cleanupOldEntries();
|
|
26420
26441
|
changed.emit();
|
|
@@ -31752,8 +31773,37 @@ function ToolUseLoader({ state: state2 }) {
|
|
|
31752
31773
|
}
|
|
31753
31774
|
|
|
31754
31775
|
// src/app/agent/tools/shared/toolResultUtils.ts
|
|
31776
|
+
function sanitizeJsonString(s) {
|
|
31777
|
+
return s.replace(/[\x00-\x1f]/g, (ch) => {
|
|
31778
|
+
switch (ch) {
|
|
31779
|
+
case "\n":
|
|
31780
|
+
return "\\n";
|
|
31781
|
+
case "\r":
|
|
31782
|
+
return "\\r";
|
|
31783
|
+
case " ":
|
|
31784
|
+
return "\\t";
|
|
31785
|
+
case "\b":
|
|
31786
|
+
return "\\b";
|
|
31787
|
+
case "\f":
|
|
31788
|
+
return "\\f";
|
|
31789
|
+
default:
|
|
31790
|
+
return `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
31791
|
+
}
|
|
31792
|
+
});
|
|
31793
|
+
}
|
|
31755
31794
|
function resolveToolPayload(result) {
|
|
31756
|
-
|
|
31795
|
+
let raw = result;
|
|
31796
|
+
if (typeof result === "string") {
|
|
31797
|
+
try {
|
|
31798
|
+
raw = JSON.parse(result);
|
|
31799
|
+
} catch {
|
|
31800
|
+
try {
|
|
31801
|
+
raw = JSON.parse(sanitizeJsonString(result));
|
|
31802
|
+
} catch {
|
|
31803
|
+
return result;
|
|
31804
|
+
}
|
|
31805
|
+
}
|
|
31806
|
+
}
|
|
31757
31807
|
if (!raw) return null;
|
|
31758
31808
|
if (raw?.status === "error") return { error: raw.error };
|
|
31759
31809
|
if (raw?.status === "success" && "data" in raw) {
|
|
@@ -45419,7 +45469,17 @@ function useVirtualScroll(scrollRef, itemKeys, columns) {
|
|
|
45419
45469
|
}, [scrollRef, SCROLL_QUANTUM]);
|
|
45420
45470
|
const getServerSnapshot = useCallback10(() => NaN, []);
|
|
45421
45471
|
const scrollTop = useSyncExternalStore5(subscribe, getSnapshot, getServerSnapshot);
|
|
45422
|
-
const viewportHeight =
|
|
45472
|
+
const [viewportHeight, setViewportHeight] = useState24(
|
|
45473
|
+
() => scrollRef.current?.getViewportHeight() ?? 0
|
|
45474
|
+
);
|
|
45475
|
+
const prevVpRef = useRef12(viewportHeight);
|
|
45476
|
+
useLayoutEffect3(() => {
|
|
45477
|
+
const next = scrollRef.current?.getViewportHeight() ?? 0;
|
|
45478
|
+
if (next !== prevVpRef.current) {
|
|
45479
|
+
prevVpRef.current = next;
|
|
45480
|
+
setViewportHeight(next);
|
|
45481
|
+
}
|
|
45482
|
+
});
|
|
45423
45483
|
const isSticky = scrollRef.current?.isSticky() ?? true;
|
|
45424
45484
|
const n = itemKeys.length;
|
|
45425
45485
|
const computeOffsets = useCallback10(() => {
|
|
@@ -45440,6 +45500,10 @@ function useVirtualScroll(scrollRef, itemKeys, columns) {
|
|
|
45440
45500
|
const range = useMemo7(() => {
|
|
45441
45501
|
if (n === 0) return [0, 0];
|
|
45442
45502
|
if (viewportHeight <= 0) {
|
|
45503
|
+
if (isSticky) {
|
|
45504
|
+
const lo3 = Math.max(0, n - COLD_START_COUNT);
|
|
45505
|
+
return [lo3, n];
|
|
45506
|
+
}
|
|
45443
45507
|
return [0, Math.min(n, COLD_START_COUNT)];
|
|
45444
45508
|
}
|
|
45445
45509
|
const absScrollTop = Math.abs(scrollTop);
|