scai 0.1.148 → 0.1.149
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/agents/MainAgent.js
CHANGED
|
@@ -265,7 +265,6 @@ export function logFolderCapsulesSummary(context) {
|
|
|
265
265
|
}).join("\n\n"); // extra newline for readability
|
|
266
266
|
logInputOutput('FolderCapsule summarized', 'output', context.analysis.folderCapsulesHuman = humanReadable);
|
|
267
267
|
}
|
|
268
|
-
/* ───────────── HELPERS ───────────── */
|
|
269
268
|
/**
|
|
270
269
|
* Persist updated task data for the current run.
|
|
271
270
|
* Only writes fields that exist in the tasks table.
|
|
@@ -276,8 +275,9 @@ export function persistTaskData(context, taskId, db, logLine) {
|
|
|
276
275
|
const now = new Date().toISOString();
|
|
277
276
|
const fieldsToUpdate = {};
|
|
278
277
|
// Persist initial query
|
|
279
|
-
if (context.initContext?.userQuery)
|
|
278
|
+
if (context.initContext?.userQuery) {
|
|
280
279
|
fieldsToUpdate.initial_query = context.initContext.userQuery;
|
|
280
|
+
}
|
|
281
281
|
// Persist intent data
|
|
282
282
|
const intent = context.analysis?.intent;
|
|
283
283
|
if (intent) {
|
|
@@ -293,21 +293,21 @@ export function persistTaskData(context, taskId, db, logLine) {
|
|
|
293
293
|
if (context.analysis?.focus?.missingFiles?.length) {
|
|
294
294
|
fieldsToUpdate.missing_files_json = JSON.stringify(context.analysis.focus.missingFiles);
|
|
295
295
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
// Persist routing decision
|
|
296
|
+
// ❌ focus_rationale intentionally removed
|
|
297
|
+
// Persist routing decision (meta / audit)
|
|
300
298
|
if (context.analysis?.routingDecision) {
|
|
301
299
|
fieldsToUpdate.routing_decision_json = JSON.stringify(context.analysis.routingDecision);
|
|
302
300
|
}
|
|
301
|
+
// ✅ Persist final answer → tasks.summary
|
|
302
|
+
if (context.analysis?.finalAnswer) {
|
|
303
|
+
fieldsToUpdate.summary = context.analysis.finalAnswer;
|
|
304
|
+
}
|
|
303
305
|
const setClause = Object.keys(fieldsToUpdate)
|
|
304
306
|
.map(key => `${key} = ?`)
|
|
305
307
|
.join(", ");
|
|
306
|
-
const values = Object.values(fieldsToUpdate);
|
|
307
308
|
if (!setClause)
|
|
308
309
|
return;
|
|
309
|
-
db.prepare(`UPDATE tasks SET ${setClause}, updated_at = ? WHERE id = ?`)
|
|
310
|
-
.run(...values, now, taskId);
|
|
310
|
+
db.prepare(`UPDATE tasks SET ${setClause}, updated_at = ? WHERE id = ?`).run(...Object.values(fieldsToUpdate), now, taskId);
|
|
311
311
|
logLine("TASK", "persistTaskData", undefined, `task ${taskId} updated with run data`);
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
@@ -82,8 +82,14 @@ export function showTaskDetails(taskId) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
// Lifecycle
|
|
85
|
+
// Lifecycle
|
|
85
86
|
print("Initial query", task.initial_query);
|
|
86
|
-
|
|
87
|
+
// Final answer (canonical)
|
|
88
|
+
if (task.summary) {
|
|
89
|
+
console.log(chalk.green.bold("\nFinal answer:\n"));
|
|
90
|
+
console.log(chalk.white(task.summary));
|
|
91
|
+
console.log(); // spacing
|
|
92
|
+
}
|
|
87
93
|
// Intent
|
|
88
94
|
print("Agreed intent", task.agreed_intent);
|
|
89
95
|
print("Intent category", task.intent_category);
|
|
@@ -106,7 +112,6 @@ export function showTaskDetails(taskId) {
|
|
|
106
112
|
print("Missing files", "[invalid JSON]");
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
|
-
print("Focus rationale", task.focus_rationale);
|
|
110
115
|
// Routing decision
|
|
111
116
|
if (task.routing_decision_json) {
|
|
112
117
|
try {
|
package/dist/db/schema.js
CHANGED
|
@@ -103,13 +103,22 @@ ${instructions}
|
|
|
103
103
|
query,
|
|
104
104
|
content: promptText,
|
|
105
105
|
});
|
|
106
|
+
// -----------------------------
|
|
107
|
+
// Persist authoritative final answer
|
|
108
|
+
// -----------------------------
|
|
109
|
+
if (!context.analysis) {
|
|
110
|
+
context.analysis = {};
|
|
111
|
+
}
|
|
112
|
+
context.analysis.finalAnswer = typeof aiResponse.data === "string"
|
|
113
|
+
? aiResponse.data
|
|
114
|
+
: JSON.stringify(aiResponse.data, null, 2);
|
|
106
115
|
const output = {
|
|
107
116
|
query,
|
|
108
117
|
content: "",
|
|
109
118
|
data: aiResponse.data,
|
|
110
119
|
};
|
|
111
120
|
logInputOutput("finalAnswer", "output", output.data);
|
|
112
|
-
console.log("\n\n\n\n--> Answer:\n", chalk.blue(
|
|
121
|
+
console.log("\n\n\n\n--> Answer:\n", chalk.blue(context.analysis.finalAnswer));
|
|
113
122
|
return output;
|
|
114
123
|
},
|
|
115
124
|
};
|