akemon 0.1.53 → 0.1.55
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/server.js +47 -29
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -81,7 +81,7 @@ function buildEngineCommand(engine, model, allowAll, extraAllowedTools) {
|
|
|
81
81
|
return { cmd: "claude", args, stdinMode: true };
|
|
82
82
|
}
|
|
83
83
|
case "codex": {
|
|
84
|
-
const args = ["exec", "--skip-git-repo-check"];
|
|
84
|
+
const args = ["exec", "--skip-git-repo-check", "-s", "workspace-write"];
|
|
85
85
|
if (model)
|
|
86
86
|
args.push("-m", model);
|
|
87
87
|
return { cmd: "codex", args, stdinMode: true };
|
|
@@ -1265,14 +1265,24 @@ async function startOrderLoop(options) {
|
|
|
1265
1265
|
try {
|
|
1266
1266
|
const engineCmd = buildEngineCommand(engine, model, allowAll, ["Bash(curl *)"]);
|
|
1267
1267
|
const bios = biosPath(workdir, agentName);
|
|
1268
|
-
// Build task prompt with delegation context
|
|
1269
|
-
const
|
|
1268
|
+
// Build task prompt with delegation + self-delivery context
|
|
1269
|
+
const apiGuide = `
|
|
1270
|
+
|
|
1271
|
+
## Delivering your result
|
|
1272
|
+
|
|
1273
|
+
When you have finished your work, deliver the result yourself:
|
|
1274
|
+
|
|
1275
|
+
curl -X POST ${relayHttp}/v1/orders/${order.id}/deliver \\
|
|
1276
|
+
-H "Content-Type: application/json" -H "Authorization: Bearer ${secretKey}" \\
|
|
1277
|
+
-d '{"result":"YOUR FINAL RESULT TEXT HERE"}'
|
|
1278
|
+
|
|
1279
|
+
IMPORTANT: You MUST call this deliver endpoint when done. Your text output alone does NOT deliver the order.
|
|
1270
1280
|
|
|
1271
1281
|
## Delegating to other agents (if needed)
|
|
1272
1282
|
|
|
1273
|
-
If this task requires skills you don't have,
|
|
1283
|
+
If this task requires skills you don't have, delegate via curl:
|
|
1274
1284
|
|
|
1275
|
-
1. Discover
|
|
1285
|
+
1. Discover agents:
|
|
1276
1286
|
curl -s "${relayHttp}/v1/agents?online=true&public=true"
|
|
1277
1287
|
|
|
1278
1288
|
2. Place a sub-order:
|
|
@@ -1283,44 +1293,52 @@ If this task requires skills you don't have, you can delegate to another agent v
|
|
|
1283
1293
|
3. Poll for result (every 5-10s until status is "completed" or "failed"):
|
|
1284
1294
|
curl -s ${relayHttp}/v1/orders/SUB_ORDER_ID
|
|
1285
1295
|
|
|
1286
|
-
When
|
|
1296
|
+
When sub-order completes, incorporate result_text into YOUR delivery. Then call the deliver endpoint above.`;
|
|
1287
1297
|
let taskPrompt;
|
|
1288
1298
|
if (order.product_name) {
|
|
1289
|
-
taskPrompt = `[Order fulfillment] You have an order to fulfill.\n\nProduct: ${order.product_name}\nBuyer's request: ${order.buyer_task || "(no specific request)"}\n\nRead your operating document at ${bios} for context.\
|
|
1299
|
+
taskPrompt = `[Order fulfillment] You have an order to fulfill.\n\nProduct: ${order.product_name}\nBuyer's request: ${order.buyer_task || "(no specific request)"}\n\nRead your operating document at ${bios} for context.\nDo NOT ask questions. RESPOND IN THE SAME LANGUAGE AS THE BUYER'S REQUEST.${apiGuide}`;
|
|
1290
1300
|
}
|
|
1291
1301
|
else {
|
|
1292
|
-
taskPrompt = `[Order fulfillment] Another agent has requested your help.\n\nTask: ${order.buyer_task}\n\nRead your operating document at ${bios} for context.\nComplete this task. Do NOT ask questions. RESPOND IN THE SAME LANGUAGE AS THE REQUEST.${
|
|
1302
|
+
taskPrompt = `[Order fulfillment] Another agent has requested your help.\n\nTask: ${order.buyer_task}\n\nRead your operating document at ${bios} for context.\nComplete this task. Do NOT ask questions. RESPOND IN THE SAME LANGUAGE AS THE REQUEST.${apiGuide}`;
|
|
1293
1303
|
}
|
|
1294
1304
|
console.log(`[orders] Fulfilling order ${order.id}...`);
|
|
1295
1305
|
const result = await runCommand(engineCmd.cmd, engineCmd.args, taskPrompt, workdir, engineCmd.stdinMode);
|
|
1296
|
-
if
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
method: "POST",
|
|
1302
|
-
headers: {
|
|
1303
|
-
Authorization: `Bearer ${secretKey}`,
|
|
1304
|
-
"Content-Type": "application/json",
|
|
1305
|
-
},
|
|
1306
|
-
body: JSON.stringify({ result }),
|
|
1307
|
-
});
|
|
1308
|
-
if (deliverRes.ok) {
|
|
1309
|
-
console.log(`[orders] Delivered order ${order.id} (${result.length} bytes)`);
|
|
1306
|
+
// Check if agent already self-delivered via curl
|
|
1307
|
+
const checkRes = await fetch(`${relayHttp}/v1/orders/${order.id}`);
|
|
1308
|
+
const orderStatus = await checkRes.json();
|
|
1309
|
+
if (orderStatus.status === "completed") {
|
|
1310
|
+
console.log(`[orders] Order ${order.id} already self-delivered by agent`);
|
|
1310
1311
|
retryState.delete(order.id);
|
|
1311
|
-
// Record task completion
|
|
1312
1312
|
try {
|
|
1313
1313
|
await onTaskCompleted(workdir, agentName, true);
|
|
1314
|
-
const memPrompt = `Summarize in one sentence from YOUR perspective what happened: You fulfilled an order${order.product_name ? ` for "${order.product_name}"` : ""}`;
|
|
1315
|
-
const engineCmd2 = buildEngineCommand(engine, model, allowAll);
|
|
1316
|
-
const memText = await runCommand(engineCmd2.cmd, engineCmd2.args, memPrompt, workdir, engineCmd2.stdinMode);
|
|
1317
|
-
if (memText)
|
|
1318
|
-
await appendMemory(workdir, agentName, "experience", memText.trim().substring(0, 300));
|
|
1319
1314
|
}
|
|
1320
1315
|
catch { }
|
|
1321
1316
|
}
|
|
1317
|
+
else if (result && result.trim() !== "") {
|
|
1318
|
+
// Fallback: auto-deliver engine output if agent didn't self-deliver
|
|
1319
|
+
console.log(`[orders] Auto-delivering order ${order.id} (agent did not self-deliver)`);
|
|
1320
|
+
const deliverRes = await fetch(`${relayHttp}/v1/orders/${order.id}/deliver`, {
|
|
1321
|
+
method: "POST",
|
|
1322
|
+
headers: {
|
|
1323
|
+
Authorization: `Bearer ${secretKey}`,
|
|
1324
|
+
"Content-Type": "application/json",
|
|
1325
|
+
},
|
|
1326
|
+
body: JSON.stringify({ result }),
|
|
1327
|
+
});
|
|
1328
|
+
if (deliverRes.ok) {
|
|
1329
|
+
console.log(`[orders] Delivered order ${order.id} (${result.length} bytes)`);
|
|
1330
|
+
retryState.delete(order.id);
|
|
1331
|
+
try {
|
|
1332
|
+
await onTaskCompleted(workdir, agentName, true);
|
|
1333
|
+
}
|
|
1334
|
+
catch { }
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
throw new Error(`deliver failed: ${await deliverRes.text()}`);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1322
1340
|
else {
|
|
1323
|
-
throw new Error(
|
|
1341
|
+
throw new Error("empty response from engine and no self-delivery");
|
|
1324
1342
|
}
|
|
1325
1343
|
}
|
|
1326
1344
|
catch (err) {
|