akemon 0.2.13 → 0.2.15

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/context.js CHANGED
@@ -43,14 +43,16 @@ function parseConversation(content) {
43
43
  for (const line of lines) {
44
44
  const m = line.match(/^\[(.+?)\] (User|Agent): (.*)$/);
45
45
  if (m) {
46
- // Unescape \\n → newline, \\\\ → backslash
47
- const content = m[3].replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
48
46
  rounds.push({
49
47
  ts: m[1],
50
48
  role: m[2].toLowerCase(),
51
- content,
49
+ content: m[3],
52
50
  });
53
51
  }
52
+ else if (rounds.length > 0 && line !== "") {
53
+ // Continuation line — append to previous round
54
+ rounds[rounds.length - 1].content += "\n" + line;
55
+ }
54
56
  }
55
57
  }
56
58
  return { summary, rounds };
@@ -79,10 +81,7 @@ export async function appendRound(workdir, agentName, convId, userMsg, agentMsg)
79
81
  content = "## Summary\n\n\n## Recent\n";
80
82
  }
81
83
  const ts = localNow();
82
- // Escape newlines so each round stays on a single line for reliable parsing
83
- const safeUser = userMsg.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
84
- const safeAgent = agentMsg.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
85
- const entry = `[${ts}] User: ${safeUser}\n[${ts}] Agent: ${safeAgent}\n`;
84
+ const entry = `[${ts}] User: ${userMsg}\n[${ts}] Agent: ${agentMsg}\n`;
86
85
  content = content.trimEnd() + "\n" + entry;
87
86
  await writeFile(p, content);
88
87
  }
@@ -315,7 +315,7 @@ Relay API (use curl with -H "Authorization: Bearer ${this.secretKey}" -H "Conten
315
315
  Accept order: POST ${this.relayHttp}/v1/orders/${order.id}/accept
316
316
  Deliver order: POST ${this.relayHttp}/v1/orders/${order.id}/deliver -d '{"result":"your response"}'
317
317
  Extend order: PUT ${this.relayHttp}/v1/orders/${order.id}/extend`;
318
- const question = `[Order id=${order.id} status=${order.status}] ${order.product_name ? `Product: ${order.product_name}\n` : ""}Buyer: ${order.buyer_agent_name || order.buyer_name || "?"}\nRequest: ${order.buyer_task || "(no specific request)"}
318
+ const question = `[Order id=${order.id} status=${order.status}] ${order.product_name ? `Product: ${order.product_name}\n` : ""}Buyer: ${order.buyer_agent_name || order.buyer_ip || "?"}\nRequest: ${order.buyer_task || "(no specific request)"}
319
319
 
320
320
  Steps:
321
321
  1. If order status is "pending", accept it first (POST .../accept)
@@ -338,7 +338,8 @@ RESPOND IN THE SAME LANGUAGE AS THE REQUEST.`;
338
338
  const duration = Date.now() - startTime;
339
339
  const nurl = this.notifyUrl || (await loadAgentConfig(workdir, agentName)).notify_url;
340
340
  // Save conversation round for order-based interactions
341
- const orderBuyer = order.buyer_agent_name || order.buyer_name || "anonymous";
341
+ // buyer_ip holds the publisherId (e.g. "f4e8ebbb7a01" or "ip-abc123") set by relay
342
+ const orderBuyer = order.buyer_agent_name || order.buyer_ip || "anonymous";
342
343
  const orderConvId = resolveConvId(orderBuyer, order.id);
343
344
  const orderUserMsg = order.buyer_task || "(no message)";
344
345
  const orderAgentMsg = (result.response || "").slice(0, 2000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akemon",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Agent work marketplace — train your agent, let it work for others",
5
5
  "type": "module",
6
6
  "license": "MIT",