@acnlabs/acn-cli 0.7.0 → 0.8.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 +43 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1684,8 +1684,9 @@ function requireAgentId7() {
|
|
|
1684
1684
|
return config.agent_id;
|
|
1685
1685
|
}
|
|
1686
1686
|
function payCommand() {
|
|
1687
|
-
const cmd = new import_commander13.Command("pay").description("
|
|
1688
|
-
|
|
1687
|
+
const cmd = new import_commander13.Command("pay").description("Manage payment tasks between agents");
|
|
1688
|
+
const createCmd = new import_commander13.Command("create").description("Create a payment task to another agent");
|
|
1689
|
+
createCmd.requiredOption("--to <agent>", "Recipient agent ID").requiredOption("--amount <n>", "Payment amount (positive number)").requiredOption("--currency <c>", "Currency code, e.g. USD, USDC").requiredOption("--method <m>", "Payment method, e.g. usdc, eth, platform_credits").requiredOption("--network <n>", "Network, e.g. ethereum, base, solana").option("--description <text>", "Free-text description for the payment task").option("--metadata <json>", "Additional metadata as JSON object").action(
|
|
1689
1690
|
async (opts) => {
|
|
1690
1691
|
const fromAgent = requireAgentId7();
|
|
1691
1692
|
const amount = Number(opts.amount);
|
|
@@ -1730,6 +1731,46 @@ function payCommand() {
|
|
|
1730
1731
|
}
|
|
1731
1732
|
}
|
|
1732
1733
|
);
|
|
1734
|
+
const confirmCmd = new import_commander13.Command("confirm").description(
|
|
1735
|
+
"Confirm an external payment has been made (buyer only)"
|
|
1736
|
+
);
|
|
1737
|
+
confirmCmd.requiredOption("--task-id <id>", "Payment task ID to confirm").requiredOption(
|
|
1738
|
+
"--tx-hash <hash>",
|
|
1739
|
+
"On-chain transaction hash or external payment reference (e.g. Stripe charge ID)"
|
|
1740
|
+
).action(async (opts) => {
|
|
1741
|
+
try {
|
|
1742
|
+
const res = await acnPost(
|
|
1743
|
+
`/payments/tasks/${opts.taskId}/confirm`,
|
|
1744
|
+
{ tx_hash: opts.txHash }
|
|
1745
|
+
);
|
|
1746
|
+
output(
|
|
1747
|
+
res,
|
|
1748
|
+
`Payment confirmed: ${res.task_id}
|
|
1749
|
+
status : ${res.status}
|
|
1750
|
+
tx_hash: ${res.tx_hash}`
|
|
1751
|
+
);
|
|
1752
|
+
} catch (err) {
|
|
1753
|
+
handleError(err);
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1756
|
+
const statusCmd = new import_commander13.Command("status").description(
|
|
1757
|
+
"Show payment tasks for the authenticated agent"
|
|
1758
|
+
);
|
|
1759
|
+
statusCmd.option("--status <s>", "Filter by status (e.g. created, payment_confirmed)").option("--limit <n>", "Max results (default 50)", "50").action(async (opts) => {
|
|
1760
|
+
const agentId = requireAgentId7();
|
|
1761
|
+
try {
|
|
1762
|
+
const res = await acnGet(
|
|
1763
|
+
`/payments/tasks/agent/${agentId}`,
|
|
1764
|
+
{ status: opts.status, limit: Number(opts.limit) }
|
|
1765
|
+
);
|
|
1766
|
+
output(res, `${res.tasks.length} payment task(s) for ${res.agent_id}`);
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
handleError(err);
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
cmd.addCommand(createCmd);
|
|
1772
|
+
cmd.addCommand(confirmCmd);
|
|
1773
|
+
cmd.addCommand(statusCmd);
|
|
1733
1774
|
return cmd;
|
|
1734
1775
|
}
|
|
1735
1776
|
|