moltlaunch 2.5.0 → 2.7.0
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/index.js +56 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -553,7 +553,9 @@ async function getAgentByOwner(ownerAddress) {
|
|
|
553
553
|
functionName: "balanceOf",
|
|
554
554
|
args: [ownerAddress]
|
|
555
555
|
});
|
|
556
|
-
if (balance === 0n)
|
|
556
|
+
if (balance === 0n) {
|
|
557
|
+
return getAgentByOwnerFromApi(ownerAddress);
|
|
558
|
+
}
|
|
557
559
|
const logs = await client.getLogs({
|
|
558
560
|
address: CONTRACTS.IDENTITY_REGISTRY,
|
|
559
561
|
event: {
|
|
@@ -569,9 +571,23 @@ async function getAgentByOwner(ownerAddress) {
|
|
|
569
571
|
fromBlock: 0n,
|
|
570
572
|
toBlock: "latest"
|
|
571
573
|
});
|
|
572
|
-
if (logs.length
|
|
573
|
-
|
|
574
|
-
|
|
574
|
+
if (logs.length > 0) {
|
|
575
|
+
const lastLog = logs[logs.length - 1];
|
|
576
|
+
return lastLog.args.agentId ?? null;
|
|
577
|
+
}
|
|
578
|
+
return getAgentByOwnerFromApi(ownerAddress);
|
|
579
|
+
} catch {
|
|
580
|
+
return getAgentByOwnerFromApi(ownerAddress);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
async function getAgentByOwnerFromApi(ownerAddress) {
|
|
584
|
+
try {
|
|
585
|
+
const res = await fetch(`${APIS.MOLTLAUNCH}/api/agents/by-wallet/${ownerAddress}`);
|
|
586
|
+
if (!res.ok) return null;
|
|
587
|
+
const data = await res.json();
|
|
588
|
+
if (!data.agents || data.agents.length === 0) return null;
|
|
589
|
+
const idStr = data.agents[0].id;
|
|
590
|
+
return BigInt(idStr.startsWith("0x") ? idStr : idStr);
|
|
575
591
|
} catch {
|
|
576
592
|
return null;
|
|
577
593
|
}
|
|
@@ -1934,7 +1950,11 @@ async function inbox(options) {
|
|
|
1934
1950
|
console.log(JSON.stringify({
|
|
1935
1951
|
tasks: [],
|
|
1936
1952
|
total: 0,
|
|
1937
|
-
polling: { recommended: "5m", note: "No active tasks. Check less frequently." }
|
|
1953
|
+
polling: { recommended: "5m", note: "No active tasks. Check less frequently." },
|
|
1954
|
+
meta: {
|
|
1955
|
+
skillFile: "https://moltlaunch.com/skill.md",
|
|
1956
|
+
hint: "Re-read the skill file periodically \u2014 guardrails and features are updated frequently."
|
|
1957
|
+
}
|
|
1938
1958
|
}));
|
|
1939
1959
|
return;
|
|
1940
1960
|
}
|
|
@@ -1963,7 +1983,11 @@ async function inbox(options) {
|
|
|
1963
1983
|
tasks: tasks2,
|
|
1964
1984
|
total: tasks2.length,
|
|
1965
1985
|
polling: { recommended: pollingInterval, note: pollingNote },
|
|
1966
|
-
flow: "requested \u2192 quoted \u2192 accepted \u2192 submitted \u2192 completed"
|
|
1986
|
+
flow: "requested \u2192 quoted \u2192 accepted \u2192 submitted \u2192 completed",
|
|
1987
|
+
meta: {
|
|
1988
|
+
skillFile: "https://moltlaunch.com/skill.md",
|
|
1989
|
+
hint: "Re-read the skill file periodically \u2014 guardrails and features are updated frequently."
|
|
1990
|
+
}
|
|
1967
1991
|
}));
|
|
1968
1992
|
return;
|
|
1969
1993
|
}
|
|
@@ -2720,7 +2744,11 @@ async function tasks(options) {
|
|
|
2720
2744
|
tasks: allTasks,
|
|
2721
2745
|
total: allTasks.length,
|
|
2722
2746
|
polling: { recommended: pollingInterval, note: pollingNote },
|
|
2723
|
-
flow: "requested \u2192 quoted \u2192 accepted \u2192 submitted \u2192 completed"
|
|
2747
|
+
flow: "requested \u2192 quoted \u2192 accepted \u2192 submitted \u2192 completed",
|
|
2748
|
+
meta: {
|
|
2749
|
+
skillFile: "https://moltlaunch.com/skill.md",
|
|
2750
|
+
hint: "Re-read the skill file periodically \u2014 guardrails and features are updated frequently."
|
|
2751
|
+
}
|
|
2724
2752
|
}));
|
|
2725
2753
|
return;
|
|
2726
2754
|
}
|
|
@@ -3470,21 +3498,31 @@ Failed to fetch messages: ${errorMsg}`);
|
|
|
3470
3498
|
}
|
|
3471
3499
|
}
|
|
3472
3500
|
const { wallet: wallet2 } = await loadOrCreateWallet();
|
|
3473
|
-
if (!options.json) {
|
|
3474
|
-
console.log("\nSending message...");
|
|
3475
|
-
}
|
|
3476
3501
|
try {
|
|
3502
|
+
const taskCheck = await getTask(options.task);
|
|
3503
|
+
const isAgent = taskCheck.agentId && wallet2.address.toLowerCase() !== taskCheck.clientAddress?.toLowerCase();
|
|
3504
|
+
const preFunded = ["requested", "quoted"].includes(taskCheck.status);
|
|
3505
|
+
if (isAgent && preFunded && !options.json) {
|
|
3506
|
+
console.log("\n\u26A0\uFE0F ESCROW NOT FUNDED \u2014 this task is still in '" + taskCheck.status + "' status.");
|
|
3507
|
+
console.log(" The client has not deposited ETH yet. Do not deliver work in messages.");
|
|
3508
|
+
console.log(" Wait for status 'accepted' before sharing deliverables.\n");
|
|
3509
|
+
}
|
|
3510
|
+
if (!options.json) {
|
|
3511
|
+
console.log("Sending message...");
|
|
3512
|
+
}
|
|
3477
3513
|
const task = await sendMessage(wallet2, options.task, options.content);
|
|
3514
|
+
const escrowWarning = isAgent && preFunded ? "Escrow not funded. Do not deliver work in messages \u2014 wait for 'accepted' status." : void 0;
|
|
3478
3515
|
const lastMsg = task.messages?.[task.messages.length - 1];
|
|
3479
3516
|
if (options.json) {
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
);
|
|
3517
|
+
const jsonOut = {
|
|
3518
|
+
success: true,
|
|
3519
|
+
taskId: task.id,
|
|
3520
|
+
status: task.status,
|
|
3521
|
+
messageCount: task.messages?.length || 0,
|
|
3522
|
+
role: lastMsg?.role
|
|
3523
|
+
};
|
|
3524
|
+
if (escrowWarning) jsonOut.warning = escrowWarning;
|
|
3525
|
+
console.log(JSON.stringify(jsonOut));
|
|
3488
3526
|
return;
|
|
3489
3527
|
}
|
|
3490
3528
|
console.log(`
|