@tinyweb_dev/agent-framework-llm 0.3.0 → 0.4.1
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 +29 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -11
- package/dist/index.js.map +1 -1
- package/dist/protocols/openai-chat.cjs +30 -11
- package/dist/protocols/openai-chat.cjs.map +1 -1
- package/dist/protocols/openai-chat.d.ts +25 -0
- package/dist/protocols/openai-chat.d.ts.map +1 -1
- package/dist/protocols/openai-chat.js +30 -12
- package/dist/protocols/openai-chat.js.map +1 -1
- package/dist/protocols/openai-compatible-chat.cjs +28 -11
- package/dist/protocols/openai-compatible-chat.cjs.map +1 -1
- package/dist/protocols/openai-compatible-chat.js +28 -11
- package/dist/protocols/openai-compatible-chat.js.map +1 -1
- package/dist/providers/openai-compatible.cjs +28 -11
- package/dist/providers/openai-compatible.cjs.map +1 -1
- package/dist/providers/openai-compatible.js +28 -11
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/providers/openai.cjs +28 -11
- package/dist/providers/openai.cjs.map +1 -1
- package/dist/providers/openai.js +28 -11
- package/dist/providers/openai.js.map +1 -1
- package/package.json +2 -2
|
@@ -2201,6 +2201,14 @@ var OpenAIChatToolCallDelta = effect$1.Schema.Struct({
|
|
|
2201
2201
|
});
|
|
2202
2202
|
var OpenAIChatDelta = effect$1.Schema.Struct({
|
|
2203
2203
|
content: optionalNull(effect$1.Schema.String),
|
|
2204
|
+
/**
|
|
2205
|
+
* Thinking / chain-of-thought stream. DeepSeek + MiniMax native and
|
|
2206
|
+
* LiteLLM-normalized gateways use `reasoning_content`; OpenRouter (and some
|
|
2207
|
+
* Grok mirrors) use `reasoning`. Either must become `reasoning-delta` so
|
|
2208
|
+
* UIs are not stuck on a pre-text thinking spinner while the wire is live.
|
|
2209
|
+
*/
|
|
2210
|
+
reasoning_content: optionalNull(effect$1.Schema.String),
|
|
2211
|
+
reasoning: optionalNull(effect$1.Schema.String),
|
|
2204
2212
|
tool_calls: optionalNull(effect$1.Schema.Array(OpenAIChatToolCallDelta))
|
|
2205
2213
|
});
|
|
2206
2214
|
var OpenAIChatChoice = effect$1.Schema.Struct({
|
|
@@ -2357,16 +2365,17 @@ var mapUsage = (usage) => {
|
|
|
2357
2365
|
providerMetadata: { openai: usage }
|
|
2358
2366
|
});
|
|
2359
2367
|
};
|
|
2360
|
-
var normaliseTextDelta = (prev, incoming) => {
|
|
2361
|
-
if (!incoming) return { emit: "", textAcc: prev };
|
|
2362
|
-
if (
|
|
2363
|
-
|
|
2364
|
-
|
|
2368
|
+
var normaliseTextDelta = (prev, incoming, mode = "unknown") => {
|
|
2369
|
+
if (!incoming) return { emit: "", textAcc: prev, mode };
|
|
2370
|
+
if (mode === "unknown") {
|
|
2371
|
+
if (prev.length === 0) return { emit: incoming, textAcc: incoming, mode };
|
|
2372
|
+
mode = incoming.length > prev.length && incoming.startsWith(prev) ? "cumulative" : "incremental";
|
|
2365
2373
|
}
|
|
2366
|
-
if (
|
|
2367
|
-
return { emit:
|
|
2374
|
+
if (mode === "cumulative") {
|
|
2375
|
+
if (incoming.startsWith(prev)) return { emit: incoming.slice(prev.length), textAcc: incoming, mode };
|
|
2376
|
+
if (prev.startsWith(incoming)) return { emit: "", textAcc: prev, mode };
|
|
2368
2377
|
}
|
|
2369
|
-
return { emit: incoming, textAcc: prev + incoming };
|
|
2378
|
+
return { emit: incoming, textAcc: prev + incoming, mode };
|
|
2370
2379
|
};
|
|
2371
2380
|
var step = (state, event) => effect$1.Effect.gen(function* () {
|
|
2372
2381
|
const events = [];
|
|
@@ -2377,9 +2386,15 @@ var step = (state, event) => effect$1.Effect.gen(function* () {
|
|
|
2377
2386
|
const toolDeltas = delta?.tool_calls ?? [];
|
|
2378
2387
|
let tools = state.tools;
|
|
2379
2388
|
let textAcc = state.textAcc;
|
|
2389
|
+
let textMode = state.textMode;
|
|
2390
|
+
const reasoningChunk = delta?.reasoning_content ?? delta?.reasoning;
|
|
2391
|
+
if (reasoningChunk) {
|
|
2392
|
+
events.push(LLMEvent.reasoningDelta({ id: "reasoning-0", text: reasoningChunk }));
|
|
2393
|
+
}
|
|
2380
2394
|
if (delta?.content) {
|
|
2381
|
-
const normalised = normaliseTextDelta(textAcc, delta.content);
|
|
2395
|
+
const normalised = normaliseTextDelta(textAcc, delta.content, textMode);
|
|
2382
2396
|
textAcc = normalised.textAcc;
|
|
2397
|
+
textMode = normalised.mode;
|
|
2383
2398
|
if (normalised.emit) {
|
|
2384
2399
|
events.push(LLMEvent.textDelta({ id: "text-0", text: normalised.emit }));
|
|
2385
2400
|
}
|
|
@@ -2403,7 +2418,8 @@ var step = (state, event) => effect$1.Effect.gen(function* () {
|
|
|
2403
2418
|
toolCallEvents: finished?.events ?? state.toolCallEvents,
|
|
2404
2419
|
usage,
|
|
2405
2420
|
finishReason,
|
|
2406
|
-
textAcc
|
|
2421
|
+
textAcc,
|
|
2422
|
+
textMode
|
|
2407
2423
|
},
|
|
2408
2424
|
events
|
|
2409
2425
|
];
|
|
@@ -2424,7 +2440,8 @@ var protocol = protocol_exports.make({
|
|
|
2424
2440
|
initial: () => ({
|
|
2425
2441
|
tools: tool_stream_exports.empty(),
|
|
2426
2442
|
toolCallEvents: [],
|
|
2427
|
-
textAcc: ""
|
|
2443
|
+
textAcc: "",
|
|
2444
|
+
textMode: "unknown"
|
|
2428
2445
|
}),
|
|
2429
2446
|
step,
|
|
2430
2447
|
onHalt: finishEvents
|