open-agents-ai 0.187.180 → 0.187.181
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 +55 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -284371,6 +284371,7 @@ var oa_directory_exports = {};
|
|
|
284371
284371
|
__export(oa_directory_exports, {
|
|
284372
284372
|
OA_DIR: () => OA_DIR,
|
|
284373
284373
|
buildContextRestorePrompt: () => buildContextRestorePrompt,
|
|
284374
|
+
cleanPromptForDiary: () => cleanPromptForDiary,
|
|
284374
284375
|
deleteSession: () => deleteSession,
|
|
284375
284376
|
deleteUsageRecord: () => deleteUsageRecord,
|
|
284376
284377
|
discoverContextFiles: () => discoverContextFiles,
|
|
@@ -284389,6 +284390,7 @@ __export(oa_directory_exports, {
|
|
|
284389
284390
|
readIndexData: () => readIndexData,
|
|
284390
284391
|
readIndexMeta: () => readIndexMeta,
|
|
284391
284392
|
recordUsage: () => recordUsage,
|
|
284393
|
+
renderSessionDiary: () => renderSessionDiary,
|
|
284392
284394
|
resolveSettings: () => resolveSettings,
|
|
284393
284395
|
saveGlobalSettings: () => saveGlobalSettings,
|
|
284394
284396
|
savePendingTask: () => savePendingTask,
|
|
@@ -284671,22 +284673,59 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
284671
284673
|
ctx3.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
284672
284674
|
writeFileSync26(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
|
|
284673
284675
|
try {
|
|
284674
|
-
|
|
284675
|
-
|
|
284676
|
-
|
|
284677
|
-
|
|
284678
|
-
|
|
284679
|
-
diaryLines.push(`## ${date} \u2014 ${task} ${status}`);
|
|
284680
|
-
if (e2.filesModified?.length) {
|
|
284681
|
-
diaryLines.push(`Files: ${e2.filesModified.slice(0, 5).join(", ")}${e2.filesModified.length > 5 ? ` (+${e2.filesModified.length - 5} more)` : ""}`);
|
|
284682
|
-
}
|
|
284683
|
-
if (e2.summary) diaryLines.push(`Summary: ${e2.summary.slice(0, 200)}`);
|
|
284684
|
-
diaryLines.push("");
|
|
284685
|
-
}
|
|
284686
|
-
writeFileSync26(join71(contextDir, "session-diary.md"), diaryLines.join("\n"), "utf-8");
|
|
284676
|
+
writeFileSync26(
|
|
284677
|
+
join71(contextDir, "session-diary.md"),
|
|
284678
|
+
renderSessionDiary(ctx3.entries.slice(-10)),
|
|
284679
|
+
"utf-8"
|
|
284680
|
+
);
|
|
284687
284681
|
} catch {
|
|
284688
284682
|
}
|
|
284689
284683
|
}
|
|
284684
|
+
function cleanPromptForDiary(raw) {
|
|
284685
|
+
if (!raw) return "";
|
|
284686
|
+
let text = String(raw);
|
|
284687
|
+
text = text.replace(/^\[Previous sessions exist[^\]]*\]\s*\n*/m, "");
|
|
284688
|
+
text = text.replace(/^[\s\S]*?\n---\s*\n\s*NEW TASK:\s*/m, "");
|
|
284689
|
+
text = text.replace(/^NEW TASK:\s*/m, "");
|
|
284690
|
+
text = text.replace(/^<system>[\s\S]*?<\/system>\s*\n*/m, "");
|
|
284691
|
+
text = text.replace(/\s+/g, " ").trim();
|
|
284692
|
+
return text || "(empty prompt)";
|
|
284693
|
+
}
|
|
284694
|
+
function renderSessionDiary(entries) {
|
|
284695
|
+
const lines = ["# Session Diary", ""];
|
|
284696
|
+
if (entries.length === 0) {
|
|
284697
|
+
lines.push("_(no sessions recorded yet)_", "");
|
|
284698
|
+
return lines.join("\n");
|
|
284699
|
+
}
|
|
284700
|
+
for (const e2 of entries) {
|
|
284701
|
+
const date = e2.savedAt ? new Date(e2.savedAt).toISOString().slice(0, 16).replace("T", " ") : "unknown time";
|
|
284702
|
+
const status = e2.completed ? "\u2713" : "\u25CB";
|
|
284703
|
+
const cleanPrompt = cleanPromptForDiary(e2.task);
|
|
284704
|
+
const slug = cleanPrompt.length > 80 ? cleanPrompt.slice(0, 77) + "..." : cleanPrompt;
|
|
284705
|
+
lines.push(`## ${date} ${status} ${slug || "untitled"}`);
|
|
284706
|
+
lines.push("");
|
|
284707
|
+
lines.push(`- **Prompt:** ${cleanPrompt || "(empty prompt)"}`);
|
|
284708
|
+
if (e2.model) {
|
|
284709
|
+
lines.push(`- **Model:** ${e2.model}`);
|
|
284710
|
+
}
|
|
284711
|
+
if (e2.filesModified && e2.filesModified.length > 0) {
|
|
284712
|
+
const shown = e2.filesModified.slice(0, 5).join(", ");
|
|
284713
|
+
const more = e2.filesModified.length > 5 ? ` (+${e2.filesModified.length - 5} more)` : "";
|
|
284714
|
+
lines.push(`- **Files:** ${shown}${more}`);
|
|
284715
|
+
}
|
|
284716
|
+
if (typeof e2.toolCalls === "number" && e2.toolCalls > 0) {
|
|
284717
|
+
lines.push(`- **Tools:** ${e2.toolCalls} call${e2.toolCalls === 1 ? "" : "s"}`);
|
|
284718
|
+
}
|
|
284719
|
+
if (e2.summary) {
|
|
284720
|
+
const summary = e2.summary.replace(/\s+/g, " ").trim().slice(0, 280);
|
|
284721
|
+
lines.push(`- **Summary:** ${summary}`);
|
|
284722
|
+
}
|
|
284723
|
+
lines.push("");
|
|
284724
|
+
}
|
|
284725
|
+
while (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
|
|
284726
|
+
lines.push("");
|
|
284727
|
+
return lines.join("\n");
|
|
284728
|
+
}
|
|
284690
284729
|
function loadSessionContext(repoRoot) {
|
|
284691
284730
|
const filePath = join71(repoRoot, OA_DIR, "context", CONTEXT_SAVE_FILE);
|
|
284692
284731
|
try {
|
|
@@ -316646,7 +316685,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
316646
316685
|
try {
|
|
316647
316686
|
saveSessionContext(repoRoot, {
|
|
316648
316687
|
savedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
316649
|
-
task: task.slice(0, 500),
|
|
316688
|
+
task: cleanPromptForDiary(task).slice(0, 500),
|
|
316650
316689
|
summary: result.summary.slice(0, 500),
|
|
316651
316690
|
filesModified: Array.from(filesTouched).slice(0, 30),
|
|
316652
316691
|
toolCalls: result.toolCalls,
|
|
@@ -319363,9 +319402,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
319363
319402
|
},
|
|
319364
319403
|
contextSave() {
|
|
319365
319404
|
try {
|
|
319405
|
+
const cleaned = (lastSubmittedPrompt || "(manual save)").replace(/^\[Previous sessions exist[^\]]*\]\s*/m, "").replace(/^NEW TASK:\s*/m, "").trim() || "(manual save)";
|
|
319366
319406
|
const entry = {
|
|
319367
319407
|
savedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
319368
|
-
task:
|
|
319408
|
+
task: cleaned,
|
|
319369
319409
|
summary: `Manual context save. ${sessionToolCallCount} tool calls, ${sessionFilesTouched.length} files modified.`,
|
|
319370
319410
|
filesModified: [...sessionFilesTouched],
|
|
319371
319411
|
toolCalls: sessionToolCallCount,
|
package/package.json
CHANGED