@nomad-e/bluma-cli 0.1.46 → 0.1.47
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 +4 -79
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -9526,7 +9526,6 @@ function buildFactorHeaders(ctx) {
|
|
|
9526
9526
|
"X-Company-Name": encodeHeader(ctx.companyName)
|
|
9527
9527
|
};
|
|
9528
9528
|
}
|
|
9529
|
-
var STREAM_TOOL_PARTIAL_THROTTLE_MS = 75;
|
|
9530
9529
|
function applyDeltaToolCallsToAccumulator(toolCallsAccumulator, deltaToolCalls) {
|
|
9531
9530
|
if (!deltaToolCalls?.length) {
|
|
9532
9531
|
return false;
|
|
@@ -9547,28 +9546,6 @@ function applyDeltaToolCallsToAccumulator(toolCallsAccumulator, deltaToolCalls)
|
|
|
9547
9546
|
}
|
|
9548
9547
|
return true;
|
|
9549
9548
|
}
|
|
9550
|
-
function snapshotPartialToolCalls(toolCallsAccumulator) {
|
|
9551
|
-
return Array.from(toolCallsAccumulator.entries()).sort((a, b) => a[0] - b[0]).map(([index, acc]) => ({
|
|
9552
|
-
index,
|
|
9553
|
-
id: acc.id,
|
|
9554
|
-
type: acc.type,
|
|
9555
|
-
function: {
|
|
9556
|
-
name: acc.function.name,
|
|
9557
|
-
arguments: acc.function.arguments
|
|
9558
|
-
}
|
|
9559
|
-
}));
|
|
9560
|
-
}
|
|
9561
|
-
function normalizedMessageToolCallsToPartial(toolCalls) {
|
|
9562
|
-
return toolCalls.map((tc, i) => ({
|
|
9563
|
-
index: typeof tc.index === "number" ? tc.index : i,
|
|
9564
|
-
id: String(tc.id ?? ""),
|
|
9565
|
-
type: String(tc.type ?? "function"),
|
|
9566
|
-
function: {
|
|
9567
|
-
name: String(tc.function?.name ?? ""),
|
|
9568
|
-
arguments: typeof tc.function?.arguments === "string" ? tc.function.arguments : JSON.stringify(tc.function?.arguments ?? {})
|
|
9569
|
-
}
|
|
9570
|
-
}));
|
|
9571
|
-
}
|
|
9572
9549
|
function normalizeFactorBaseUrl(raw) {
|
|
9573
9550
|
let u = raw.trim().replace(/\/$/, "");
|
|
9574
9551
|
u = u.replace(/^http:\/\/http:\/\//i, "http://");
|
|
@@ -9669,24 +9646,17 @@ var LLMService = class {
|
|
|
9669
9646
|
{ headers: this.requestHeaders(params.userContext) }
|
|
9670
9647
|
);
|
|
9671
9648
|
const toolCallsAccumulator = /* @__PURE__ */ new Map();
|
|
9672
|
-
let lastPartialEmitAt = 0;
|
|
9673
9649
|
for await (const chunk of stream) {
|
|
9674
9650
|
const choice = chunk.choices[0];
|
|
9675
9651
|
if (!choice) continue;
|
|
9676
9652
|
const delta = choice.delta;
|
|
9677
|
-
|
|
9653
|
+
applyDeltaToolCallsToAccumulator(toolCallsAccumulator, delta?.tool_calls);
|
|
9678
9654
|
const reasoning = delta?.reasoning_content || delta?.reasoning || "";
|
|
9679
9655
|
const fullToolCalls = choice.finish_reason === "tool_calls" ? Array.from(toolCallsAccumulator.values()) : void 0;
|
|
9680
|
-
let tool_calls_partial;
|
|
9681
|
-
if (hadToolDelta && toolCallsAccumulator.size > 0 && !fullToolCalls && Date.now() - lastPartialEmitAt >= STREAM_TOOL_PARTIAL_THROTTLE_MS) {
|
|
9682
|
-
lastPartialEmitAt = Date.now();
|
|
9683
|
-
tool_calls_partial = snapshotPartialToolCalls(toolCallsAccumulator);
|
|
9684
|
-
}
|
|
9685
9656
|
yield {
|
|
9686
9657
|
delta: delta?.content || "",
|
|
9687
9658
|
reasoning,
|
|
9688
9659
|
tool_calls: fullToolCalls,
|
|
9689
|
-
tool_calls_partial,
|
|
9690
9660
|
finish_reason: choice.finish_reason
|
|
9691
9661
|
};
|
|
9692
9662
|
}
|
|
@@ -10877,11 +10847,6 @@ ${editData.error.display}`;
|
|
|
10877
10847
|
if (hasContent) {
|
|
10878
10848
|
this.eventBus.emit("stream_chunk", { delta: content });
|
|
10879
10849
|
}
|
|
10880
|
-
if (hasTools) {
|
|
10881
|
-
this.eventBus.emit("stream_tool_calls_partial", {
|
|
10882
|
-
calls: normalizedMessageToolCallsToPartial(message2.tool_calls)
|
|
10883
|
-
});
|
|
10884
|
-
}
|
|
10885
10850
|
const omitAssistantFlush = hasTools && message2.tool_calls.some((tc) => String(tc?.function?.name ?? "").includes("message"));
|
|
10886
10851
|
this.eventBus.emit("stream_end", { omitAssistantFlush });
|
|
10887
10852
|
}
|
|
@@ -10922,13 +10887,6 @@ ${editData.error.display}`;
|
|
|
10922
10887
|
if (chunk.tool_calls) {
|
|
10923
10888
|
toolCalls = chunk.tool_calls;
|
|
10924
10889
|
}
|
|
10925
|
-
if (chunk.tool_calls_partial && chunk.tool_calls_partial.length > 0) {
|
|
10926
|
-
if (!hasEmittedStart) {
|
|
10927
|
-
this.eventBus.emit("stream_start", {});
|
|
10928
|
-
hasEmittedStart = true;
|
|
10929
|
-
}
|
|
10930
|
-
this.eventBus.emit("stream_tool_calls_partial", { calls: chunk.tool_calls_partial });
|
|
10931
|
-
}
|
|
10932
10890
|
}
|
|
10933
10891
|
const omitAssistantFlush = Array.isArray(toolCalls) && toolCalls.some((tc) => String(tc?.function?.name ?? "").includes("message"));
|
|
10934
10892
|
if (hasEmittedStart) {
|
|
@@ -14408,10 +14366,9 @@ function applyStreamEndFlush(params) {
|
|
|
14408
14366
|
}
|
|
14409
14367
|
|
|
14410
14368
|
// src/app/ui/components/StreamingText.tsx
|
|
14411
|
-
import {
|
|
14369
|
+
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
14412
14370
|
var THROTTLE_MS = 50;
|
|
14413
14371
|
var MAX_VISIBLE_LINES = 20;
|
|
14414
|
-
var ARGS_PREVIEW_MAX = 72;
|
|
14415
14372
|
var StreamingTextComponent = ({
|
|
14416
14373
|
eventBus,
|
|
14417
14374
|
onReasoningComplete,
|
|
@@ -14419,7 +14376,6 @@ var StreamingTextComponent = ({
|
|
|
14419
14376
|
}) => {
|
|
14420
14377
|
const [reasoning, setReasoning] = useState6("");
|
|
14421
14378
|
const [assistantContent, setAssistantContent] = useState6("");
|
|
14422
|
-
const [partialToolCalls, setPartialToolCalls] = useState6([]);
|
|
14423
14379
|
const [isStreaming, setIsStreaming] = useState6(false);
|
|
14424
14380
|
const reasoningRef = useRef5("");
|
|
14425
14381
|
const contentRef = useRef5("");
|
|
@@ -14452,7 +14408,6 @@ var StreamingTextComponent = ({
|
|
|
14452
14408
|
contentRef.current = "";
|
|
14453
14409
|
setReasoning("");
|
|
14454
14410
|
setAssistantContent("");
|
|
14455
|
-
setPartialToolCalls([]);
|
|
14456
14411
|
lastUpdateRef.current = 0;
|
|
14457
14412
|
setIsStreaming(true);
|
|
14458
14413
|
};
|
|
@@ -14468,11 +14423,6 @@ var StreamingTextComponent = ({
|
|
|
14468
14423
|
scheduleFlush();
|
|
14469
14424
|
}
|
|
14470
14425
|
};
|
|
14471
|
-
const handleToolCallsPartial = (data) => {
|
|
14472
|
-
if (Array.isArray(data.calls) && data.calls.length > 0) {
|
|
14473
|
-
setPartialToolCalls(data.calls);
|
|
14474
|
-
}
|
|
14475
|
-
};
|
|
14476
14426
|
const handleEnd = (payload) => {
|
|
14477
14427
|
if (streamEndHandledRef.current) return;
|
|
14478
14428
|
streamEndHandledRef.current = true;
|
|
@@ -14490,24 +14440,21 @@ var StreamingTextComponent = ({
|
|
|
14490
14440
|
});
|
|
14491
14441
|
setReasoning("");
|
|
14492
14442
|
setAssistantContent("");
|
|
14493
|
-
setPartialToolCalls([]);
|
|
14494
14443
|
reasoningRef.current = "";
|
|
14495
14444
|
contentRef.current = "";
|
|
14496
14445
|
};
|
|
14497
14446
|
eventBus.on("stream_start", handleStart);
|
|
14498
14447
|
eventBus.on("stream_reasoning_chunk", handleReasoningChunk);
|
|
14499
14448
|
eventBus.on("stream_chunk", handleContentChunk);
|
|
14500
|
-
eventBus.on("stream_tool_calls_partial", handleToolCallsPartial);
|
|
14501
14449
|
eventBus.on("stream_end", handleEnd);
|
|
14502
14450
|
return () => {
|
|
14503
14451
|
eventBus.off("stream_start", handleStart);
|
|
14504
14452
|
eventBus.off("stream_reasoning_chunk", handleReasoningChunk);
|
|
14505
14453
|
eventBus.off("stream_chunk", handleContentChunk);
|
|
14506
|
-
eventBus.off("stream_tool_calls_partial", handleToolCallsPartial);
|
|
14507
14454
|
eventBus.off("stream_end", handleEnd);
|
|
14508
14455
|
};
|
|
14509
14456
|
}, [eventBus]);
|
|
14510
|
-
if (!isStreaming || !reasoning && !assistantContent
|
|
14457
|
+
if (!isStreaming || !reasoning && !assistantContent) {
|
|
14511
14458
|
return null;
|
|
14512
14459
|
}
|
|
14513
14460
|
const renderLines = (text, dim) => {
|
|
@@ -14527,31 +14474,9 @@ var StreamingTextComponent = ({
|
|
|
14527
14474
|
displayLines.map((line, i) => /* @__PURE__ */ jsx21(Text19, { dimColor: dim, color: dim ? void 0 : BLUMA_TERMINAL.m3OnSurface, children: line }, i))
|
|
14528
14475
|
] });
|
|
14529
14476
|
};
|
|
14530
|
-
const formatArgsPreview = (raw) => {
|
|
14531
|
-
const s = String(raw ?? "");
|
|
14532
|
-
if (s.length <= ARGS_PREVIEW_MAX) return s;
|
|
14533
|
-
return `${s.slice(0, ARGS_PREVIEW_MAX - 1)}\u2026`;
|
|
14534
|
-
};
|
|
14535
14477
|
return /* @__PURE__ */ jsxs19(ChatBlock, { marginBottom: 1, children: [
|
|
14536
14478
|
reasoning ? /* @__PURE__ */ jsx21(Box20, { flexDirection: "column", paddingLeft: 2, children: renderLines(reasoning, true) }) : null,
|
|
14537
|
-
assistantContent ? /* @__PURE__ */ jsx21(MessageResponse, { children: renderLines(assistantContent, false) }) : null
|
|
14538
|
-
partialToolCalls.length > 0 ? /* @__PURE__ */ jsxs19(Box20, { flexDirection: "column", paddingLeft: 2, marginTop: assistantContent || reasoning ? 1 : 0, children: [
|
|
14539
|
-
/* @__PURE__ */ jsx21(Text19, { dimColor: true, children: "tools (streaming)" }),
|
|
14540
|
-
partialToolCalls.map((tc) => {
|
|
14541
|
-
const name = tc.function?.name?.trim() || "\u2026";
|
|
14542
|
-
const args = formatArgsPreview(tc.function?.arguments ?? "");
|
|
14543
|
-
return /* @__PURE__ */ jsxs19(Text19, { dimColor: true, wrap: "wrap", children: [
|
|
14544
|
-
/* @__PURE__ */ jsxs19(Text19, { color: BLUMA_TERMINAL.suggestion, children: [
|
|
14545
|
-
"\u2022 ",
|
|
14546
|
-
name
|
|
14547
|
-
] }),
|
|
14548
|
-
args ? /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
14549
|
-
/* @__PURE__ */ jsx21(Text19, { dimColor: true, children: " " }),
|
|
14550
|
-
/* @__PURE__ */ jsx21(Text19, { dimColor: true, italic: true, children: args })
|
|
14551
|
-
] }) : null
|
|
14552
|
-
] }, `${tc.index}-${tc.id}`);
|
|
14553
|
-
})
|
|
14554
|
-
] }) : null
|
|
14479
|
+
assistantContent ? /* @__PURE__ */ jsx21(MessageResponse, { children: renderLines(assistantContent, false) }) : null
|
|
14555
14480
|
] });
|
|
14556
14481
|
};
|
|
14557
14482
|
var StreamingText = memo12(StreamingTextComponent);
|