@wrongstack/providers 0.256.0 → 0.257.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/index.js CHANGED
@@ -4,8 +4,13 @@ import { randomUUID } from 'crypto';
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
+ var __esm = (fn, res, err) => function __init() {
8
+ if (err) throw err[0];
9
+ try {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
+ } catch (e) {
12
+ throw err = [e], e;
13
+ }
9
14
  };
10
15
  var __export = (target, all) => {
11
16
  for (var name in all)
@@ -149,10 +154,10 @@ async function aggregateStream(stream, onEvent) {
149
154
  case "text_delta":
150
155
  if (currentTextIndex === -1) {
151
156
  currentTextIndex = textBuffers.length;
152
- textBuffers.push("");
157
+ textBuffers.push([]);
153
158
  blockOrder.push({ kind: "text", idx: currentTextIndex });
154
159
  }
155
- textBuffers[currentTextIndex] = (textBuffers[currentTextIndex] ?? "") + ev.text;
160
+ textBuffers[currentTextIndex].push(ev.text);
156
161
  break;
157
162
  case "tool_use_start":
158
163
  currentTextIndex = -1;
@@ -185,7 +190,7 @@ async function aggregateStream(stream, onEvent) {
185
190
  currentTextIndex = -1;
186
191
  if (currentThinkingIndex === -1 || !thinkingBuffers[currentThinkingIndex]) {
187
192
  currentThinkingIndex = thinkingBuffers.length;
188
- thinkingBuffers.push({ textBuf: "" });
193
+ thinkingBuffers.push({ chunks: [] });
189
194
  }
190
195
  if (ev.providerMeta && currentThinkingIndex >= 0) {
191
196
  expectDefined(thinkingBuffers[currentThinkingIndex]).providerMeta = ev.providerMeta;
@@ -196,17 +201,17 @@ async function aggregateStream(stream, onEvent) {
196
201
  case "thinking_delta": {
197
202
  if (currentThinkingIndex === -1 || !thinkingBuffers[currentThinkingIndex]) {
198
203
  currentThinkingIndex = thinkingBuffers.length;
199
- thinkingBuffers.push({ textBuf: "" });
204
+ thinkingBuffers.push({ chunks: [] });
200
205
  blockOrder.push({ kind: "thinking", idx: currentThinkingIndex });
201
206
  }
202
207
  const t = thinkingBuffers[currentThinkingIndex];
203
- if (t) t.textBuf += ev.text;
208
+ if (t) t.chunks.push(ev.text);
204
209
  break;
205
210
  }
206
211
  case "thinking_signature": {
207
212
  if (currentThinkingIndex === -1 || !thinkingBuffers[currentThinkingIndex]) {
208
213
  currentThinkingIndex = thinkingBuffers.length;
209
- thinkingBuffers.push({ textBuf: "" });
214
+ thinkingBuffers.push({ chunks: [] });
210
215
  blockOrder.push({ kind: "thinking", idx: currentThinkingIndex });
211
216
  }
212
217
  const t = thinkingBuffers[currentThinkingIndex];
@@ -226,12 +231,13 @@ async function aggregateStream(stream, onEvent) {
226
231
  const content = [];
227
232
  for (const b of blockOrder) {
228
233
  if (b.kind === "text") {
229
- const text = textBuffers[b.idx] ?? "";
234
+ const text = textBuffers[b.idx]?.join("") ?? "";
230
235
  if (text) content.push({ type: "text", text });
231
236
  } else if (b.kind === "thinking") {
232
237
  const t = thinkingBuffers[b.idx];
233
- if (!t || !t.textBuf && !t.signature) continue;
234
- const block = { type: "thinking", thinking: t.textBuf };
238
+ const thinkingText = t?.chunks.join("") ?? "";
239
+ if (!t || !thinkingText && !t.signature) continue;
240
+ const block = { type: "thinking", thinking: thinkingText };
235
241
  if (t.signature) block.signature = t.signature;
236
242
  if (t.providerMeta && Object.keys(t.providerMeta).length > 0) {
237
243
  block.providerMeta = t.providerMeta;