akemon 0.1.74 → 0.1.75

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.
Files changed (2) hide show
  1. package/dist/server.js +14 -2
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -14,6 +14,7 @@ import { selfDir, initWorld, initBioState, initGuide, biosPath, loadBioState, sa
14
14
  // Engine mutual exclusion — only one engine process at a time
15
15
  let engineBusy = false;
16
16
  let engineBusySince = 0;
17
+ let lastEngineTrace = []; // execution trace for order reporting
17
18
  // Order push notification — urgent orders bypass 30s poll
18
19
  const urgentOrderIds = new Set();
19
20
  let triggerWork = null;
@@ -824,6 +825,8 @@ async function runRawEngine(task, model, workdir) {
824
825
  const apiUrl = RAW_API_URL + "/chat/completions";
825
826
  const modelName = model || "gemma4:4b";
826
827
  console.log(`[raw] Task:\n${task}`);
828
+ const trace = [];
829
+ lastEngineTrace = trace;
827
830
  const messages = [
828
831
  { role: "system", content: "You are a helpful agent. Use tools when needed to complete the task. When done, reply with your final answer in plain text." },
829
832
  { role: "user", content: task },
@@ -848,6 +851,7 @@ async function runRawEngine(task, model, workdir) {
848
851
  }
849
852
  catch (err) {
850
853
  console.log(`[raw] API error: ${err.message}`);
854
+ trace.push({ role: "error", content: err.message });
851
855
  throw err;
852
856
  }
853
857
  const choice = data.choices?.[0];
@@ -870,6 +874,7 @@ async function runRawEngine(task, model, workdir) {
870
874
  }
871
875
  console.log(`[raw] Tool call: ${fnName}(${JSON.stringify(fnArgs).slice(0, 100)})`);
872
876
  const result = await executeRawTool(fnName, fnArgs, workdir);
877
+ trace.push({ role: "tool_call", name: fnName, args: fnArgs, result: result.slice(0, 2000) });
873
878
  messages.push({
874
879
  role: "tool",
875
880
  tool_call_id: tc.id,
@@ -882,6 +887,7 @@ async function runRawEngine(task, model, workdir) {
882
887
  const content = msg.content || "";
883
888
  if (content.trim()) {
884
889
  console.log(`[raw] Done in ${round + 1} round(s), response:\n${content}`);
890
+ trace.push({ role: "assistant", content: content.trim().slice(0, 4000) });
885
891
  return content.trim();
886
892
  }
887
893
  }
@@ -1370,7 +1376,9 @@ When sub-order completes, incorporate result_text into YOUR delivery. Then call
1370
1376
  }
1371
1377
  }
1372
1378
  console.log(`[orders] Fulfilling order ${order.id}...`);
1379
+ lastEngineTrace = [];
1373
1380
  const result = await runEngine(engine, model, allowAll, taskPrompt, workdir, ["Bash(curl *)"]);
1381
+ const trace = lastEngineTrace;
1374
1382
  const checkRes = await fetch(`${relayHttp}/v1/orders/${order.id}`);
1375
1383
  const orderStatus = await checkRes.json();
1376
1384
  if (orderStatus.status === "completed") {
@@ -1383,10 +1391,11 @@ When sub-order completes, incorporate result_text into YOUR delivery. Then call
1383
1391
  }
1384
1392
  else if (result && result.trim() !== "") {
1385
1393
  console.log(`[orders] Auto-delivering order ${order.id} (agent did not self-deliver)`);
1394
+ const traceJson = trace.length > 0 ? JSON.stringify(trace).slice(0, 50000) : "";
1386
1395
  const deliverRes = await fetch(`${relayHttp}/v1/orders/${order.id}/deliver`, {
1387
1396
  method: "POST",
1388
1397
  headers: { Authorization: `Bearer ${secretKey}`, "Content-Type": "application/json" },
1389
- body: JSON.stringify({ result }),
1398
+ body: JSON.stringify({ result, trace: traceJson }),
1390
1399
  });
1391
1400
  if (deliverRes.ok) {
1392
1401
  console.log(`[orders] Delivered order ${order.id} (${result.length} bytes)`);
@@ -1439,8 +1448,11 @@ When sub-order completes, incorporate result_text into YOUR delivery. Then call
1439
1448
  retryState.delete(order.id);
1440
1449
  gaveUp.add(order.id);
1441
1450
  try {
1451
+ const failTrace = lastEngineTrace.length > 0 ? JSON.stringify(lastEngineTrace).slice(0, 50000) : "";
1442
1452
  await fetch(`${relayHttp}/v1/orders/${order.id}/cancel`, {
1443
- method: "POST", headers: { Authorization: `Bearer ${secretKey}` },
1453
+ method: "POST",
1454
+ headers: { Authorization: `Bearer ${secretKey}`, "Content-Type": "application/json" },
1455
+ body: JSON.stringify({ trace: failTrace }),
1444
1456
  });
1445
1457
  console.log(`[orders] Cancelled ${order.id} on relay`);
1446
1458
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akemon",
3
- "version": "0.1.74",
3
+ "version": "0.1.75",
4
4
  "description": "Agent work marketplace — train your agent, let it work for others",
5
5
  "type": "module",
6
6
  "license": "MIT",