@mindstudio-ai/remy 0.1.150 → 0.1.151
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/headless.js +21 -19
- package/dist/index.js +21 -19
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -537,6 +537,12 @@ async function* streamChat(params) {
|
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
+
if (buffer.startsWith("data: ")) {
|
|
541
|
+
try {
|
|
542
|
+
yield JSON.parse(buffer.slice(6));
|
|
543
|
+
} catch {
|
|
544
|
+
}
|
|
545
|
+
}
|
|
540
546
|
if (!receivedDone) {
|
|
541
547
|
log2.warn("Stream ended without done event", {
|
|
542
548
|
requestId,
|
|
@@ -544,12 +550,10 @@ async function* streamChat(params) {
|
|
|
544
550
|
durationMs: Date.now() - startTime,
|
|
545
551
|
remainingBuffer: buffer.slice(0, 200)
|
|
546
552
|
});
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
} catch {
|
|
552
|
-
}
|
|
553
|
+
yield {
|
|
554
|
+
type: "error",
|
|
555
|
+
error: "Network error: stream ended before completion"
|
|
556
|
+
};
|
|
553
557
|
}
|
|
554
558
|
}
|
|
555
559
|
var MAX_RETRIES = 5;
|
|
@@ -2818,9 +2822,9 @@ function fixOrphanedToolCalls(messages) {
|
|
|
2818
2822
|
toolResultIds.add(msg.toolCallId);
|
|
2819
2823
|
}
|
|
2820
2824
|
}
|
|
2821
|
-
const result = [
|
|
2822
|
-
for (
|
|
2823
|
-
|
|
2825
|
+
const result = [];
|
|
2826
|
+
for (const msg of messages) {
|
|
2827
|
+
result.push(msg);
|
|
2824
2828
|
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
2825
2829
|
continue;
|
|
2826
2830
|
}
|
|
@@ -2828,17 +2832,15 @@ function fixOrphanedToolCalls(messages) {
|
|
|
2828
2832
|
(b) => b.type === "tool"
|
|
2829
2833
|
);
|
|
2830
2834
|
const orphans = toolBlocks.filter((tc) => !toolResultIds.has(tc.id));
|
|
2831
|
-
|
|
2832
|
-
|
|
2835
|
+
for (const tc of orphans) {
|
|
2836
|
+
result.push({
|
|
2837
|
+
role: "user",
|
|
2838
|
+
content: "Error: tool result lost (session recovered)",
|
|
2839
|
+
toolCallId: tc.id,
|
|
2840
|
+
isToolError: true
|
|
2841
|
+
});
|
|
2842
|
+
toolResultIds.add(tc.id);
|
|
2833
2843
|
}
|
|
2834
|
-
const synthetics = orphans.map((tc) => ({
|
|
2835
|
-
role: "user",
|
|
2836
|
-
content: "Error: tool result lost (session recovered)",
|
|
2837
|
-
toolCallId: tc.id,
|
|
2838
|
-
isToolError: true
|
|
2839
|
-
}));
|
|
2840
|
-
result.splice(i + 1, 0, ...synthetics);
|
|
2841
|
-
break;
|
|
2842
2844
|
}
|
|
2843
2845
|
return result;
|
|
2844
2846
|
}
|
package/dist/index.js
CHANGED
|
@@ -222,6 +222,12 @@ async function* streamChat(params) {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
+
if (buffer.startsWith("data: ")) {
|
|
226
|
+
try {
|
|
227
|
+
yield JSON.parse(buffer.slice(6));
|
|
228
|
+
} catch {
|
|
229
|
+
}
|
|
230
|
+
}
|
|
225
231
|
if (!receivedDone) {
|
|
226
232
|
log.warn("Stream ended without done event", {
|
|
227
233
|
requestId,
|
|
@@ -229,12 +235,10 @@ async function* streamChat(params) {
|
|
|
229
235
|
durationMs: Date.now() - startTime,
|
|
230
236
|
remainingBuffer: buffer.slice(0, 200)
|
|
231
237
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
} catch {
|
|
237
|
-
}
|
|
238
|
+
yield {
|
|
239
|
+
type: "error",
|
|
240
|
+
error: "Network error: stream ended before completion"
|
|
241
|
+
};
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
function isRetryableError(error) {
|
|
@@ -3114,9 +3118,9 @@ function fixOrphanedToolCalls(messages) {
|
|
|
3114
3118
|
toolResultIds.add(msg.toolCallId);
|
|
3115
3119
|
}
|
|
3116
3120
|
}
|
|
3117
|
-
const result = [
|
|
3118
|
-
for (
|
|
3119
|
-
|
|
3121
|
+
const result = [];
|
|
3122
|
+
for (const msg of messages) {
|
|
3123
|
+
result.push(msg);
|
|
3120
3124
|
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
3121
3125
|
continue;
|
|
3122
3126
|
}
|
|
@@ -3124,17 +3128,15 @@ function fixOrphanedToolCalls(messages) {
|
|
|
3124
3128
|
(b) => b.type === "tool"
|
|
3125
3129
|
);
|
|
3126
3130
|
const orphans = toolBlocks.filter((tc) => !toolResultIds.has(tc.id));
|
|
3127
|
-
|
|
3128
|
-
|
|
3131
|
+
for (const tc of orphans) {
|
|
3132
|
+
result.push({
|
|
3133
|
+
role: "user",
|
|
3134
|
+
content: "Error: tool result lost (session recovered)",
|
|
3135
|
+
toolCallId: tc.id,
|
|
3136
|
+
isToolError: true
|
|
3137
|
+
});
|
|
3138
|
+
toolResultIds.add(tc.id);
|
|
3129
3139
|
}
|
|
3130
|
-
const synthetics = orphans.map((tc) => ({
|
|
3131
|
-
role: "user",
|
|
3132
|
-
content: "Error: tool result lost (session recovered)",
|
|
3133
|
-
toolCallId: tc.id,
|
|
3134
|
-
isToolError: true
|
|
3135
|
-
}));
|
|
3136
|
-
result.splice(i + 1, 0, ...synthetics);
|
|
3137
|
-
break;
|
|
3138
3140
|
}
|
|
3139
3141
|
return result;
|
|
3140
3142
|
}
|