akemon 0.1.69 → 0.1.71
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 +12 -49
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -819,17 +819,12 @@ async function executeLocalTool(name, args, workdir) {
|
|
|
819
819
|
return `[error] ${err.message}`;
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
|
-
async function runLocalEngine(task, model, workdir
|
|
822
|
+
async function runLocalEngine(task, model, workdir) {
|
|
823
823
|
const apiUrl = LOCAL_API_URL + "/chat/completions";
|
|
824
824
|
const modelName = model || "gemma4:4b";
|
|
825
|
-
|
|
826
|
-
? `You are a helpful agent. Use tools when needed to complete the task. When done, reply with your final answer in plain text.\n\n--- Your Identity ---\n${systemContext}`
|
|
827
|
-
: "You are a helpful agent. Use tools when needed to complete the task. When done, reply with your final answer in plain text.";
|
|
828
|
-
console.log(`[local] Task: ${task.slice(0, 200)}${task.length > 200 ? '...' : ''}`);
|
|
829
|
-
if (systemContext)
|
|
830
|
-
console.log(`[local] System context: ${systemContext.length} chars`);
|
|
825
|
+
console.log(`[local] Task:\n${task}`);
|
|
831
826
|
const messages = [
|
|
832
|
-
{ role: "system", content:
|
|
827
|
+
{ 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." },
|
|
833
828
|
{ role: "user", content: task },
|
|
834
829
|
];
|
|
835
830
|
for (let round = 0; round < LOCAL_MAX_ROUNDS; round++) {
|
|
@@ -883,26 +878,16 @@ async function runLocalEngine(task, model, workdir, systemContext) {
|
|
|
883
878
|
// No tool calls — this is the final response
|
|
884
879
|
const content = msg.content || "";
|
|
885
880
|
if (content.trim()) {
|
|
886
|
-
console.log(`[local] Done in ${round + 1} round(s), response
|
|
881
|
+
console.log(`[local] Done in ${round + 1} round(s), response:\n${content}`);
|
|
887
882
|
return content.trim();
|
|
888
883
|
}
|
|
889
884
|
}
|
|
890
885
|
throw new Error(`Local engine exceeded ${LOCAL_MAX_ROUNDS} rounds without final answer`);
|
|
891
886
|
}
|
|
892
|
-
/** Load bios content for local engine system context */
|
|
893
|
-
async function loadBiosContent(workdir, agentName) {
|
|
894
|
-
try {
|
|
895
|
-
const { readFile: rf } = await import("fs/promises");
|
|
896
|
-
return await rf(biosPath(workdir, agentName), "utf-8");
|
|
897
|
-
}
|
|
898
|
-
catch {
|
|
899
|
-
return "";
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
887
|
/** Unified engine runner — dispatches to local API or external CLI */
|
|
903
|
-
function runEngine(engine, model, allowAll, task, workdir, extraAllowedTools
|
|
888
|
+
function runEngine(engine, model, allowAll, task, workdir, extraAllowedTools) {
|
|
904
889
|
if (engine === "local") {
|
|
905
|
-
return runLocalEngine(task, model, workdir
|
|
890
|
+
return runLocalEngine(task, model, workdir);
|
|
906
891
|
}
|
|
907
892
|
const engineCmd = buildEngineCommand(engine, model, allowAll, extraAllowedTools);
|
|
908
893
|
return runCommand(engineCmd.cmd, engineCmd.args, task, workdir, engineCmd.stdinMode);
|
|
@@ -1363,28 +1348,14 @@ If this task requires skills you don't have, delegate via curl:
|
|
|
1363
1348
|
|
|
1364
1349
|
When sub-order completes, incorporate result_text into YOUR delivery. Then call the deliver endpoint above.`;
|
|
1365
1350
|
let taskPrompt;
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
// Local engine: simple prompt, harness handles delivery
|
|
1369
|
-
biosContent = await loadBiosContent(workdir, agentName);
|
|
1370
|
-
if (order.product_name) {
|
|
1371
|
-
taskPrompt = `[Order] Product: ${order.product_name}\nRequest: ${order.buyer_task || "(no specific request)"}\n\nRespond directly. RESPOND IN THE SAME LANGUAGE AS THE REQUEST.`;
|
|
1372
|
-
}
|
|
1373
|
-
else {
|
|
1374
|
-
taskPrompt = `[Task] ${order.buyer_task}\n\nRespond directly. RESPOND IN THE SAME LANGUAGE AS THE REQUEST.`;
|
|
1375
|
-
}
|
|
1351
|
+
if (order.product_name) {
|
|
1352
|
+
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}`;
|
|
1376
1353
|
}
|
|
1377
1354
|
else {
|
|
1378
|
-
|
|
1379
|
-
if (order.product_name) {
|
|
1380
|
-
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}`;
|
|
1381
|
-
}
|
|
1382
|
-
else {
|
|
1383
|
-
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}`;
|
|
1384
|
-
}
|
|
1355
|
+
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}`;
|
|
1385
1356
|
}
|
|
1386
1357
|
console.log(`[orders] Fulfilling order ${order.id}...`);
|
|
1387
|
-
const result = await runEngine(engine, model, allowAll, taskPrompt, workdir, ["Bash(curl *)"]
|
|
1358
|
+
const result = await runEngine(engine, model, allowAll, taskPrompt, workdir, ["Bash(curl *)"]);
|
|
1388
1359
|
const checkRes = await fetch(`${relayHttp}/v1/orders/${order.id}`);
|
|
1389
1360
|
const orderStatus = await checkRes.json();
|
|
1390
1361
|
if (orderStatus.status === "completed") {
|
|
@@ -1507,16 +1478,8 @@ When sub-order completes, incorporate result_text into YOUR delivery. Then call
|
|
|
1507
1478
|
try {
|
|
1508
1479
|
const bios = biosPath(workdir, agentName);
|
|
1509
1480
|
const sd = selfDir(workdir, agentName);
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
if (engine === "local") {
|
|
1513
|
-
biosContent = await loadBiosContent(workdir, agentName);
|
|
1514
|
-
prompt = `Your personal directory: ${sd}/\n\n[Owner's task: ${task.title}]\n\n${task.body}`;
|
|
1515
|
-
}
|
|
1516
|
-
else {
|
|
1517
|
-
prompt = `Read ${bios} for your identity and context.\nYour personal directory: ${sd}/\n\n[Owner's task: ${task.title}]\n\n${task.body}`;
|
|
1518
|
-
}
|
|
1519
|
-
await runEngine(engine, model, allowAll, prompt, workdir, ["Bash(curl *)"], biosContent);
|
|
1481
|
+
const prompt = `Read ${bios} for your identity and context.\nYour personal directory: ${sd}/\n\n[Owner's task: ${task.title}]\n\n${task.body}`;
|
|
1482
|
+
await runEngine(engine, model, allowAll, prompt, workdir, ["Bash(curl *)"]);
|
|
1520
1483
|
// Record execution time
|
|
1521
1484
|
const runs = await loadTaskRuns(workdir, agentName);
|
|
1522
1485
|
runs[task.title] = localNow();
|