akemon 0.2.7 → 0.2.8
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/task-module.js +8 -0
- package/package.json +1 -1
package/dist/task-module.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { readFile } from "fs/promises";
|
|
12
12
|
import { SIG, sig } from "./types.js";
|
|
13
13
|
import { selfDir, biosPath, localNow, loadBioState, saveBioState, syncEnergyFromTokens, loadAgentConfig, getDueUserTasks, loadTaskRuns, saveTaskRuns, loadDirectives, buildDirectivesPrompt, appendTaskHistory, notifyOwner, updateHungerDecay, updateNaturalDecay, resetTokenCountIfNewDay, computeSociability, appendBioEvent, bioStatePromptModifier, feedHunger, SHOP_ITEMS, logBioStatus, logBioDecision, } from "./self.js";
|
|
14
|
+
import { appendRound, resolveConvId } from "./context.js";
|
|
14
15
|
// ---------------------------------------------------------------------------
|
|
15
16
|
// Config
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
@@ -327,9 +328,15 @@ RESPOND IN THE SAME LANGUAGE AS THE REQUEST.`;
|
|
|
327
328
|
const finalStatus = await relay.getOrder(order.id);
|
|
328
329
|
const duration = Date.now() - startTime;
|
|
329
330
|
const nurl = this.notifyUrl || (await loadAgentConfig(workdir, agentName)).notify_url;
|
|
331
|
+
// Save conversation round for order-based interactions
|
|
332
|
+
const orderBuyer = order.buyer_agent_name || order.buyer_name || "anonymous";
|
|
333
|
+
const orderConvId = resolveConvId(orderBuyer, order.id);
|
|
334
|
+
const orderUserMsg = order.buyer_task || "(no message)";
|
|
335
|
+
const orderAgentMsg = (result.response || "").slice(0, 2000);
|
|
330
336
|
if (finalStatus?.status === "completed") {
|
|
331
337
|
console.log(`[task] Order ${order.id} delivered`);
|
|
332
338
|
this.orderRetry.delete(order.id);
|
|
339
|
+
await appendRound(workdir, agentName, orderConvId, orderUserMsg, orderAgentMsg);
|
|
333
340
|
await appendTaskHistory(workdir, agentName, { ts: localNow(), id: order.id, type: "order", status: "success", duration_ms: duration, output_summary: (result.response || "").slice(0, 500) });
|
|
334
341
|
await notifyOwner(nurl, `${agentName}: order done`, `Order ${order.id} delivered`, "default", ["package"]);
|
|
335
342
|
bus.emit(SIG.TASK_COMPLETED, sig(SIG.TASK_COMPLETED, { success: true, taskLabel: orderLabel, creditsEarned: orderPrice }));
|
|
@@ -340,6 +347,7 @@ RESPOND IN THE SAME LANGUAGE AS THE REQUEST.`;
|
|
|
340
347
|
if (delivered) {
|
|
341
348
|
console.log(`[task] Delivered order ${order.id} (fallback)`);
|
|
342
349
|
this.orderRetry.delete(order.id);
|
|
350
|
+
await appendRound(workdir, agentName, orderConvId, orderUserMsg, orderAgentMsg);
|
|
343
351
|
await appendTaskHistory(workdir, agentName, { ts: localNow(), id: order.id, type: "order", status: "success", duration_ms: duration, output_summary: result.response.slice(0, 500) });
|
|
344
352
|
await notifyOwner(nurl, `${agentName}: order done`, `Order ${order.id}: ${result.response.slice(0, 200)}`, "default", ["package"]);
|
|
345
353
|
bus.emit(SIG.TASK_COMPLETED, sig(SIG.TASK_COMPLETED, { success: true, taskLabel: orderLabel, creditsEarned: orderPrice }));
|