akemon 0.2.22 → 0.2.23
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 +10 -6
- package/package.json +1 -1
package/dist/task-module.js
CHANGED
|
@@ -11,7 +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 { appendMessage
|
|
14
|
+
import { appendMessage } from "./context.js";
|
|
15
15
|
import { buildRoleContext } from "./role-module.js";
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
// Config
|
|
@@ -254,7 +254,7 @@ export class TaskModule {
|
|
|
254
254
|
const filtered = [];
|
|
255
255
|
for (const item of items) {
|
|
256
256
|
const itemLabel = item.type === "order"
|
|
257
|
-
? `order:${item.data.product_name || item.data.
|
|
257
|
+
? `order:${item.data.product_name || item.data.buyer_name || item.id}`
|
|
258
258
|
: item.type === "user_task" ? `user_task:${item.data.key || item.id}` : `relay_task:${item.id}`;
|
|
259
259
|
const isUrgent = item.quadrant === 1;
|
|
260
260
|
// Fear avoidance (urgent items bypass)
|
|
@@ -296,7 +296,7 @@ export class TaskModule {
|
|
|
296
296
|
return;
|
|
297
297
|
const { workdir, agentName, bus } = this.ctx;
|
|
298
298
|
const relay = this.getRelay();
|
|
299
|
-
const orderLabel = `order:${order.product_name || order.
|
|
299
|
+
const orderLabel = `order:${order.product_name || order.buyer_name || order.id}`;
|
|
300
300
|
const orderPrice = order.price || order.offer_price || 1;
|
|
301
301
|
const startTime = Date.now();
|
|
302
302
|
try {
|
|
@@ -323,7 +323,7 @@ Relay API (use curl with -H "Authorization: Bearer ${this.secretKey}" -H "Conten
|
|
|
323
323
|
Accept order: POST ${this.relayHttp}/v1/orders/${order.id}/accept
|
|
324
324
|
Deliver order: POST ${this.relayHttp}/v1/orders/${order.id}/deliver -d '{"result":"your response"}'
|
|
325
325
|
Extend order: PUT ${this.relayHttp}/v1/orders/${order.id}/extend`;
|
|
326
|
-
const question = `[Order id=${order.id} status=${order.status}] ${order.product_name ? `Product: ${order.product_name}\n` : ""}Buyer: ${order.
|
|
326
|
+
const question = `[Order id=${order.id} status=${order.status}] ${order.product_name ? `Product: ${order.product_name}\n` : ""}Buyer: ${order.buyer_name || order.buyer_ip || "?"}\nRequest: ${order.buyer_task || "(no specific request)"}
|
|
327
327
|
|
|
328
328
|
Steps:
|
|
329
329
|
1. If order status is "pending", accept it first (POST .../accept)
|
|
@@ -332,8 +332,12 @@ Steps:
|
|
|
332
332
|
|
|
333
333
|
RESPOND IN THE SAME LANGUAGE AS THE REQUEST.`;
|
|
334
334
|
// Write user message to conversation immediately (before engine runs)
|
|
335
|
-
|
|
336
|
-
const
|
|
335
|
+
// buyer_name = agent name (from JOIN), buyer_ip = publisher ID or IP
|
|
336
|
+
const orderBuyer = order.buyer_name || order.buyer_ip || "anonymous";
|
|
337
|
+
// Product orders get isolated conversations; ad-hoc chats share one conv per buyer
|
|
338
|
+
const buyerPubId = orderBuyer;
|
|
339
|
+
const productScope = order.product_id ? `:prod_${order.product_id}` : "";
|
|
340
|
+
const orderConvId = `pub_${buyerPubId}${productScope}`;
|
|
337
341
|
const orderUserMsg = order.buyer_task || "(no message)";
|
|
338
342
|
await appendMessage(workdir, agentName, orderConvId, "User", orderUserMsg);
|
|
339
343
|
console.log(`[task] Fulfilling order ${order.id}...`);
|