akemon 0.1.58 → 0.1.59

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 +36 -16
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -921,6 +921,12 @@ Reply with ONLY JSON: {"rating": 4, "comment": "..."}`;
921
921
  }
922
922
  }
923
923
  async function runMarketCycle() {
924
+ // Watchdog: force-reset stuck engine lock
925
+ if (engineBusy && engineBusySince > 0 && Date.now() - engineBusySince > 10 * 60 * 1000) {
926
+ console.log(`[watchdog] engineBusy stuck for ${Math.round((Date.now() - engineBusySince) / 1000)}s, force-resetting`);
927
+ engineBusy = false;
928
+ engineBusySince = 0;
929
+ }
924
930
  try {
925
931
  console.log("[market] Starting autonomous market review...");
926
932
  // Skip if engine is busy
@@ -1094,7 +1100,7 @@ Reply with empty array if nothing to say: {"suggestions": []}`;
1094
1100
  title: sug.title,
1095
1101
  content: sug.content,
1096
1102
  }),
1097
- }).catch(() => { });
1103
+ }).catch((err) => console.log(`[market] suggestion sync: ${err.message}`));
1098
1104
  console.log(`[market] Suggestion: "${sug.title}"`);
1099
1105
  }
1100
1106
  }
@@ -1125,6 +1131,12 @@ async function startSelfCycle(options) {
1125
1131
  const { agentName, engine, model, allowAll } = options;
1126
1132
  const workdir = options.workdir || process.cwd();
1127
1133
  async function runReflectionCycle() {
1134
+ // Watchdog: force-reset stuck engine lock
1135
+ if (engineBusy && engineBusySince > 0 && Date.now() - engineBusySince > 10 * 60 * 1000) {
1136
+ console.log(`[watchdog] engineBusy stuck for ${Math.round((Date.now() - engineBusySince) / 1000)}s, force-resetting`);
1137
+ engineBusy = false;
1138
+ engineBusySince = 0;
1139
+ }
1128
1140
  try {
1129
1141
  console.log("[self] Starting reflection cycle...");
1130
1142
  // Skip if engine is busy
@@ -1235,7 +1247,7 @@ Take your time. Read your files, think, then act.`;
1235
1247
  method: "POST",
1236
1248
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.secretKey}` },
1237
1249
  body: JSON.stringify({ title: g.title, description: g.description, html }),
1238
- }).catch(() => { });
1250
+ }).catch((err) => console.log(`[sync] games push: ${err.message}`));
1239
1251
  }
1240
1252
  }
1241
1253
  }
@@ -1250,7 +1262,7 @@ Take your time. Read your files, think, then act.`;
1250
1262
  method: "POST",
1251
1263
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.secretKey}` },
1252
1264
  body: JSON.stringify({ title: n.title, content }),
1253
- }).catch(() => { });
1265
+ }).catch((err) => console.log(`[sync] notes push: ${err.message}`));
1254
1266
  }
1255
1267
  }
1256
1268
  }
@@ -1265,7 +1277,7 @@ Take your time. Read your files, think, then act.`;
1265
1277
  method: "POST",
1266
1278
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${options.secretKey}` },
1267
1279
  body: JSON.stringify({ title: p.title, description: p.description, html }),
1268
- }).catch(() => { });
1280
+ }).catch((err) => console.log(`[sync] pages push: ${err.message}`));
1269
1281
  }
1270
1282
  }
1271
1283
  }
@@ -1307,9 +1319,16 @@ async function startOrderLoop(options) {
1307
1319
  myAgentId = me.id;
1308
1320
  }
1309
1321
  catch { /* will retry on next cycle */ }
1310
- // Track local retry state
1322
+ // Track local retry state and permanently abandoned orders
1311
1323
  const retryState = new Map();
1324
+ const gaveUp = new Set();
1312
1325
  async function processOrders() {
1326
+ // Watchdog: force-reset stuck engine lock
1327
+ if (engineBusy && engineBusySince > 0 && Date.now() - engineBusySince > 10 * 60 * 1000) {
1328
+ console.log(`[watchdog] engineBusy stuck for ${Math.round((Date.now() - engineBusySince) / 1000)}s, force-resetting`);
1329
+ engineBusy = false;
1330
+ engineBusySince = 0;
1331
+ }
1313
1332
  try {
1314
1333
  // Fetch incoming orders (pending + processing)
1315
1334
  const res = await fetch(`${relayHttp}/v1/agent/${encodeURIComponent(agentName)}/orders/incoming`, {
@@ -1321,6 +1340,8 @@ async function startOrderLoop(options) {
1321
1340
  if (!orders || orders.length === 0)
1322
1341
  return;
1323
1342
  for (const order of orders) {
1343
+ if (gaveUp.has(order.id))
1344
+ continue;
1324
1345
  if (order.status === "pending") {
1325
1346
  // Accept the order (escrows buyer credits)
1326
1347
  const acceptRes = await fetch(`${relayHttp}/v1/orders/${order.id}/accept`, {
@@ -1432,23 +1453,22 @@ When sub-order completes, incorporate result_text into YOUR delivery. Then call
1432
1453
  current.nextAt = Date.now() + RETRY_INTERVALS[current.count];
1433
1454
  retryState.set(order.id, current);
1434
1455
  console.log(`[orders] Will retry ${order.id} in ${RETRY_INTERVALS[current.count] / 1000}s (attempt ${current.count + 1}/${RETRY_INTERVALS.length})`);
1435
- // Extend timeout on relay side
1456
+ }
1457
+ else {
1458
+ console.log(`[orders] Giving up on ${order.id} after ${current.count} retries`);
1459
+ retryState.delete(order.id);
1460
+ gaveUp.add(order.id);
1461
+ // Notify relay to cancel and refund
1436
1462
  try {
1437
- await fetch(`${relayHttp}/v1/orders/${order.id}/extend`, {
1463
+ await fetch(`${relayHttp}/v1/orders/${order.id}/cancel`, {
1438
1464
  method: "POST",
1439
1465
  headers: { Authorization: `Bearer ${secretKey}` },
1440
1466
  });
1467
+ console.log(`[orders] Cancelled ${order.id} on relay`);
1441
1468
  }
1442
- catch { }
1443
- // Bump retry count on relay
1444
- try {
1445
- // Use IncrementOrderRetry indirectly — the relay timeout ticker checks retry_count
1469
+ catch (cancelErr) {
1470
+ console.log(`[orders] Failed to cancel ${order.id}: ${cancelErr.message}`);
1446
1471
  }
1447
- catch { }
1448
- }
1449
- else {
1450
- console.log(`[orders] Giving up on ${order.id} after ${current.count} retries`);
1451
- retryState.delete(order.id);
1452
1472
  }
1453
1473
  }
1454
1474
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akemon",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
4
4
  "description": "Agent work marketplace — train your agent, let it work for others",
5
5
  "type": "module",
6
6
  "license": "MIT",