@mindstudio-ai/remy 0.1.65 → 0.1.67
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 +46 -6
- package/dist/index.js +46 -6
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -324,11 +324,15 @@ function buildSystemPrompt(onboardingState, viewContext) {
|
|
|
324
324
|
loadSpecFileMetadata(),
|
|
325
325
|
loadProjectFileListing()
|
|
326
326
|
].filter(Boolean).join("\n");
|
|
327
|
-
const now = (/* @__PURE__ */ new Date()).
|
|
327
|
+
const now = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
328
|
+
month: "long",
|
|
329
|
+
day: "numeric",
|
|
330
|
+
year: "numeric"
|
|
331
|
+
});
|
|
328
332
|
const template = `
|
|
329
333
|
{{static/identity.md}}
|
|
330
334
|
|
|
331
|
-
Current date
|
|
335
|
+
Current date: ${now}
|
|
332
336
|
|
|
333
337
|
<platform_docs>
|
|
334
338
|
<platform>
|
|
@@ -2501,6 +2505,37 @@ function findLastSummaryCheckpoint(messages, name) {
|
|
|
2501
2505
|
}
|
|
2502
2506
|
return -1;
|
|
2503
2507
|
}
|
|
2508
|
+
function fixOrphanedToolCalls(messages) {
|
|
2509
|
+
const toolResultIds = /* @__PURE__ */ new Set();
|
|
2510
|
+
for (const msg of messages) {
|
|
2511
|
+
if (msg.role === "user" && msg.toolCallId) {
|
|
2512
|
+
toolResultIds.add(msg.toolCallId);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
const result = [...messages];
|
|
2516
|
+
for (let i = result.length - 1; i >= 0; i--) {
|
|
2517
|
+
const msg = result[i];
|
|
2518
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
2519
|
+
continue;
|
|
2520
|
+
}
|
|
2521
|
+
const toolBlocks = msg.content.filter(
|
|
2522
|
+
(b) => b.type === "tool"
|
|
2523
|
+
);
|
|
2524
|
+
const orphans = toolBlocks.filter((tc) => !toolResultIds.has(tc.id));
|
|
2525
|
+
if (orphans.length === 0) {
|
|
2526
|
+
continue;
|
|
2527
|
+
}
|
|
2528
|
+
const synthetics = orphans.map((tc) => ({
|
|
2529
|
+
role: "user",
|
|
2530
|
+
content: "Error: tool result lost (session recovered)",
|
|
2531
|
+
toolCallId: tc.id,
|
|
2532
|
+
isToolError: true
|
|
2533
|
+
}));
|
|
2534
|
+
result.splice(i + 1, 0, ...synthetics);
|
|
2535
|
+
break;
|
|
2536
|
+
}
|
|
2537
|
+
return result;
|
|
2538
|
+
}
|
|
2504
2539
|
function cleanMessagesForApi(messages) {
|
|
2505
2540
|
const checkpointIdx = findLastSummaryCheckpoint(messages, "conversation");
|
|
2506
2541
|
let startIdx = 0;
|
|
@@ -2522,7 +2557,7 @@ ${summaryBlock.text}
|
|
|
2522
2557
|
}
|
|
2523
2558
|
startIdx = checkpointIdx + 1;
|
|
2524
2559
|
}
|
|
2525
|
-
const messagesToProcess = messages.slice(startIdx);
|
|
2560
|
+
const messagesToProcess = fixOrphanedToolCalls(messages.slice(startIdx));
|
|
2526
2561
|
const toolUseIds = /* @__PURE__ */ new Set();
|
|
2527
2562
|
for (const msg of messagesToProcess) {
|
|
2528
2563
|
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
@@ -2608,6 +2643,14 @@ async function runSubAgent(config) {
|
|
|
2608
2643
|
const emit2 = (e) => {
|
|
2609
2644
|
onEvent({ ...e, parentToolId });
|
|
2610
2645
|
};
|
|
2646
|
+
const dateStr = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
2647
|
+
month: "long",
|
|
2648
|
+
day: "numeric",
|
|
2649
|
+
year: "numeric"
|
|
2650
|
+
});
|
|
2651
|
+
const fullSystem = `${system}
|
|
2652
|
+
|
|
2653
|
+
Current date: ${dateStr}`;
|
|
2611
2654
|
let turns = 0;
|
|
2612
2655
|
const run = async () => {
|
|
2613
2656
|
const messages = [
|
|
@@ -2661,9 +2704,6 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
2661
2704
|
onStatus: (label) => emit2({ type: "status", message: label }),
|
|
2662
2705
|
signal
|
|
2663
2706
|
});
|
|
2664
|
-
const fullSystem = `${system}
|
|
2665
|
-
|
|
2666
|
-
Current date/time: ${(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace(/\.\d+Z$/, " UTC")}`;
|
|
2667
2707
|
try {
|
|
2668
2708
|
for await (const event of streamChatWithRetry(
|
|
2669
2709
|
{
|
package/dist/index.js
CHANGED
|
@@ -2228,6 +2228,37 @@ function findLastSummaryCheckpoint(messages, name) {
|
|
|
2228
2228
|
}
|
|
2229
2229
|
return -1;
|
|
2230
2230
|
}
|
|
2231
|
+
function fixOrphanedToolCalls(messages) {
|
|
2232
|
+
const toolResultIds = /* @__PURE__ */ new Set();
|
|
2233
|
+
for (const msg of messages) {
|
|
2234
|
+
if (msg.role === "user" && msg.toolCallId) {
|
|
2235
|
+
toolResultIds.add(msg.toolCallId);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
const result = [...messages];
|
|
2239
|
+
for (let i = result.length - 1; i >= 0; i--) {
|
|
2240
|
+
const msg = result[i];
|
|
2241
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
2242
|
+
continue;
|
|
2243
|
+
}
|
|
2244
|
+
const toolBlocks = msg.content.filter(
|
|
2245
|
+
(b) => b.type === "tool"
|
|
2246
|
+
);
|
|
2247
|
+
const orphans = toolBlocks.filter((tc) => !toolResultIds.has(tc.id));
|
|
2248
|
+
if (orphans.length === 0) {
|
|
2249
|
+
continue;
|
|
2250
|
+
}
|
|
2251
|
+
const synthetics = orphans.map((tc) => ({
|
|
2252
|
+
role: "user",
|
|
2253
|
+
content: "Error: tool result lost (session recovered)",
|
|
2254
|
+
toolCallId: tc.id,
|
|
2255
|
+
isToolError: true
|
|
2256
|
+
}));
|
|
2257
|
+
result.splice(i + 1, 0, ...synthetics);
|
|
2258
|
+
break;
|
|
2259
|
+
}
|
|
2260
|
+
return result;
|
|
2261
|
+
}
|
|
2231
2262
|
function cleanMessagesForApi(messages) {
|
|
2232
2263
|
const checkpointIdx = findLastSummaryCheckpoint(messages, "conversation");
|
|
2233
2264
|
let startIdx = 0;
|
|
@@ -2249,7 +2280,7 @@ ${summaryBlock.text}
|
|
|
2249
2280
|
}
|
|
2250
2281
|
startIdx = checkpointIdx + 1;
|
|
2251
2282
|
}
|
|
2252
|
-
const messagesToProcess = messages.slice(startIdx);
|
|
2283
|
+
const messagesToProcess = fixOrphanedToolCalls(messages.slice(startIdx));
|
|
2253
2284
|
const toolUseIds = /* @__PURE__ */ new Set();
|
|
2254
2285
|
for (const msg of messagesToProcess) {
|
|
2255
2286
|
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
@@ -2339,6 +2370,14 @@ async function runSubAgent(config) {
|
|
|
2339
2370
|
const emit2 = (e) => {
|
|
2340
2371
|
onEvent({ ...e, parentToolId });
|
|
2341
2372
|
};
|
|
2373
|
+
const dateStr = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
2374
|
+
month: "long",
|
|
2375
|
+
day: "numeric",
|
|
2376
|
+
year: "numeric"
|
|
2377
|
+
});
|
|
2378
|
+
const fullSystem = `${system}
|
|
2379
|
+
|
|
2380
|
+
Current date: ${dateStr}`;
|
|
2342
2381
|
let turns = 0;
|
|
2343
2382
|
const run = async () => {
|
|
2344
2383
|
const messages = [
|
|
@@ -2392,9 +2431,6 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
2392
2431
|
onStatus: (label) => emit2({ type: "status", message: label }),
|
|
2393
2432
|
signal
|
|
2394
2433
|
});
|
|
2395
|
-
const fullSystem = `${system}
|
|
2396
|
-
|
|
2397
|
-
Current date/time: ${(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace(/\.\d+Z$/, " UTC")}`;
|
|
2398
2434
|
try {
|
|
2399
2435
|
for await (const event of streamChatWithRetry(
|
|
2400
2436
|
{
|
|
@@ -5514,11 +5550,15 @@ function buildSystemPrompt(onboardingState, viewContext) {
|
|
|
5514
5550
|
loadSpecFileMetadata(),
|
|
5515
5551
|
loadProjectFileListing()
|
|
5516
5552
|
].filter(Boolean).join("\n");
|
|
5517
|
-
const now = (/* @__PURE__ */ new Date()).
|
|
5553
|
+
const now = (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", {
|
|
5554
|
+
month: "long",
|
|
5555
|
+
day: "numeric",
|
|
5556
|
+
year: "numeric"
|
|
5557
|
+
});
|
|
5518
5558
|
const template = `
|
|
5519
5559
|
{{static/identity.md}}
|
|
5520
5560
|
|
|
5521
|
-
Current date
|
|
5561
|
+
Current date: ${now}
|
|
5522
5562
|
|
|
5523
5563
|
<platform_docs>
|
|
5524
5564
|
<platform>
|