@flutchai/flutch-sdk 0.7.11 → 0.7.12
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.cjs +54 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +54 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1675,6 +1675,12 @@ interface TraceApiCallResult<TResult> {
|
|
|
1675
1675
|
declare function traceApiCall<TResult>(execute: () => Promise<TResult>, options?: ApiCallTracerOptions): Promise<TraceApiCallResult<TResult>>;
|
|
1676
1676
|
declare function sanitizeTraceData(value: unknown, depth?: number, seen?: WeakSet<object>, options?: ApiCallTracerOptions): unknown;
|
|
1677
1677
|
|
|
1678
|
+
interface ThinkingStream {
|
|
1679
|
+
runId: string | null;
|
|
1680
|
+
index: unknown;
|
|
1681
|
+
shown: boolean;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1678
1684
|
interface LLMCallRecord {
|
|
1679
1685
|
modelId: string;
|
|
1680
1686
|
promptTokens: number;
|
|
@@ -1697,6 +1703,7 @@ interface StreamAccumulator {
|
|
|
1697
1703
|
traceMessages: TraceMessageStore;
|
|
1698
1704
|
traceStartedAt: number | null;
|
|
1699
1705
|
traceCompletedAt: number | null;
|
|
1706
|
+
thinking?: ThinkingStream;
|
|
1700
1707
|
}
|
|
1701
1708
|
declare function joinTextSteps(parts: string[]): string;
|
|
1702
1709
|
declare class EventProcessor {
|
package/dist/index.d.ts
CHANGED
|
@@ -1675,6 +1675,12 @@ interface TraceApiCallResult<TResult> {
|
|
|
1675
1675
|
declare function traceApiCall<TResult>(execute: () => Promise<TResult>, options?: ApiCallTracerOptions): Promise<TraceApiCallResult<TResult>>;
|
|
1676
1676
|
declare function sanitizeTraceData(value: unknown, depth?: number, seen?: WeakSet<object>, options?: ApiCallTracerOptions): unknown;
|
|
1677
1677
|
|
|
1678
|
+
interface ThinkingStream {
|
|
1679
|
+
runId: string | null;
|
|
1680
|
+
index: unknown;
|
|
1681
|
+
shown: boolean;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1678
1684
|
interface LLMCallRecord {
|
|
1679
1685
|
modelId: string;
|
|
1680
1686
|
promptTokens: number;
|
|
@@ -1697,6 +1703,7 @@ interface StreamAccumulator {
|
|
|
1697
1703
|
traceMessages: TraceMessageStore;
|
|
1698
1704
|
traceStartedAt: number | null;
|
|
1699
1705
|
traceCompletedAt: number | null;
|
|
1706
|
+
thinking?: ThinkingStream;
|
|
1700
1707
|
}
|
|
1701
1708
|
declare function joinTextSteps(parts: string[]): string;
|
|
1702
1709
|
declare class EventProcessor {
|
package/dist/index.js
CHANGED
|
@@ -5172,6 +5172,45 @@ function sanitizeTraceError(error, options) {
|
|
|
5172
5172
|
};
|
|
5173
5173
|
}
|
|
5174
5174
|
__name(sanitizeTraceError, "sanitizeTraceError");
|
|
5175
|
+
|
|
5176
|
+
// src/engines/langgraph/stream-thinking.ts
|
|
5177
|
+
function splitThinking(blocks) {
|
|
5178
|
+
const thoughts = [];
|
|
5179
|
+
const rest = [];
|
|
5180
|
+
for (const block of blocks) {
|
|
5181
|
+
const part = block;
|
|
5182
|
+
if (part?.type === "thinking" || part?.type === "reasoning") {
|
|
5183
|
+
const text = part.type === "thinking" ? part.thinking : part.reasoning;
|
|
5184
|
+
if (typeof text === "string" && text) thoughts.push({
|
|
5185
|
+
text,
|
|
5186
|
+
index: part.index
|
|
5187
|
+
});
|
|
5188
|
+
continue;
|
|
5189
|
+
}
|
|
5190
|
+
rest.push(block);
|
|
5191
|
+
}
|
|
5192
|
+
return {
|
|
5193
|
+
thoughts,
|
|
5194
|
+
rest
|
|
5195
|
+
};
|
|
5196
|
+
}
|
|
5197
|
+
__name(splitThinking, "splitThinking");
|
|
5198
|
+
function thinkingTexts(state, runId, deltas) {
|
|
5199
|
+
const out = [];
|
|
5200
|
+
for (const delta of deltas) {
|
|
5201
|
+
const another = runId !== state.runId || state.index !== void 0 && delta.index !== state.index;
|
|
5202
|
+
out.push(state.shown && another ? `
|
|
5203
|
+
|
|
5204
|
+
${delta.text}` : delta.text);
|
|
5205
|
+
state.runId = runId;
|
|
5206
|
+
state.index = delta.index;
|
|
5207
|
+
state.shown = true;
|
|
5208
|
+
}
|
|
5209
|
+
return out;
|
|
5210
|
+
}
|
|
5211
|
+
__name(thinkingTexts, "thinkingTexts");
|
|
5212
|
+
|
|
5213
|
+
// src/engines/langgraph/event-processor.utils.ts
|
|
5175
5214
|
function _ts_decorate21(decorators, target, key, desc) {
|
|
5176
5215
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5177
5216
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5479,7 +5518,21 @@ var EventProcessor = class _EventProcessor {
|
|
|
5479
5518
|
const chunk = event.data.chunk;
|
|
5480
5519
|
const blocks = [];
|
|
5481
5520
|
if (chunk.content) {
|
|
5482
|
-
|
|
5521
|
+
const { thoughts, rest } = splitThinking(this.normalizeContentBlocks(chunk.content));
|
|
5522
|
+
blocks.push(...rest);
|
|
5523
|
+
if (thoughts.length && event.metadata?.stream_thinking === true) {
|
|
5524
|
+
acc.thinking ??= {
|
|
5525
|
+
runId: null,
|
|
5526
|
+
index: void 0,
|
|
5527
|
+
shown: false
|
|
5528
|
+
};
|
|
5529
|
+
for (const text of thinkingTexts(acc.thinking, event.run_id ?? null, thoughts)) this.processContentStream(acc, StreamChannel.PROCESSING, [
|
|
5530
|
+
{
|
|
5531
|
+
type: "text",
|
|
5532
|
+
text
|
|
5533
|
+
}
|
|
5534
|
+
], onPartial);
|
|
5535
|
+
}
|
|
5483
5536
|
}
|
|
5484
5537
|
const contentHasToolBlocks = blocks.some((block) => block?.type === "tool_use" || block?.type === "tool_call" || block?.type === "input_json_delta");
|
|
5485
5538
|
if (!contentHasToolBlocks && Array.isArray(chunk.tool_call_chunks) && chunk.tool_call_chunks.length > 0) {
|