use-agently 0.17.0 → 0.18.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/build/bin.js +61 -8
- package/package.json +2 -2
package/build/bin.js
CHANGED
|
@@ -98465,7 +98465,7 @@ function PayTransaction(wallet) {
|
|
|
98465
98465
|
// ../use-agently-sdk/package.json
|
|
98466
98466
|
var package_default = {
|
|
98467
98467
|
name: "@use-agently/sdk",
|
|
98468
|
-
version: "0.
|
|
98468
|
+
version: "0.18.0",
|
|
98469
98469
|
description: "Core SDK for the Agently platform — wallet management, A2A, MCP, x402 payments",
|
|
98470
98470
|
homepage: "https://github.com/AgentlyHQ/use-agently/tree/main/packages/use-agently-sdk",
|
|
98471
98471
|
bugs: {
|
|
@@ -100065,6 +100065,11 @@ function resolveMcpUrl(input) {
|
|
|
100065
100065
|
async function createMcpClient(mcpUrl, options) {
|
|
100066
100066
|
const client = new Client(options?.clientInfo ?? { name: "@use-agently/sdk", version: package_default.version });
|
|
100067
100067
|
const transport = new StreamableHTTPClientTransport(new URL(mcpUrl), options?.fetchImpl ? { fetch: options.fetchImpl } : undefined);
|
|
100068
|
+
if (options?.wallet) {
|
|
100069
|
+
const x402Client2 = createMcpPaymentClient(client, options.wallet);
|
|
100070
|
+
await x402Client2.connect(transport);
|
|
100071
|
+
return x402Client2;
|
|
100072
|
+
}
|
|
100068
100073
|
await client.connect(transport);
|
|
100069
100074
|
return client;
|
|
100070
100075
|
}
|
|
@@ -100084,12 +100089,15 @@ async function callMcpTool(uri, tool, args, options) {
|
|
|
100084
100089
|
const transaction = options?.transaction ?? DryRunTransaction;
|
|
100085
100090
|
const resolvedFetch = resolveFetchForTransaction(transaction, options?.fetchImpl);
|
|
100086
100091
|
if (transaction.mode === "pay") {
|
|
100087
|
-
const
|
|
100092
|
+
const x402Client2 = await createMcpClient(mcpUrl, {
|
|
100093
|
+
clientInfo: options?.clientInfo,
|
|
100094
|
+
fetchImpl: options?.fetchImpl ?? clientFetch,
|
|
100095
|
+
wallet: transaction.wallet
|
|
100096
|
+
});
|
|
100088
100097
|
try {
|
|
100089
|
-
const x402Client2 = createMcpPaymentClient(client2, transaction.wallet);
|
|
100090
100098
|
return await x402Client2.callTool(tool, args ?? {});
|
|
100091
100099
|
} finally {
|
|
100092
|
-
await
|
|
100100
|
+
await x402Client2.close();
|
|
100093
100101
|
}
|
|
100094
100102
|
}
|
|
100095
100103
|
const client = await createMcpClient(mcpUrl, { clientInfo: options?.clientInfo, fetchImpl: resolvedFetch });
|
|
@@ -100100,7 +100108,7 @@ async function callMcpTool(uri, tool, args, options) {
|
|
|
100100
100108
|
if (content?.length > 0 && content[0].type === "text" && content[0].text) {
|
|
100101
100109
|
try {
|
|
100102
100110
|
const parsed = JSON.parse(content[0].text);
|
|
100103
|
-
if (parsed?.accepts) {
|
|
100111
|
+
if (Array.isArray(parsed?.accepts) && parsed.accepts.length > 0) {
|
|
100104
100112
|
throw new DryRunPaymentRequired(parsed.accepts);
|
|
100105
100113
|
}
|
|
100106
100114
|
} catch (e) {
|
|
@@ -101605,7 +101613,7 @@ function boxen(text, options) {
|
|
|
101605
101613
|
// package.json
|
|
101606
101614
|
var package_default2 = {
|
|
101607
101615
|
name: "use-agently",
|
|
101608
|
-
version: "0.
|
|
101616
|
+
version: "0.18.0",
|
|
101609
101617
|
description: "Use Agently CLI",
|
|
101610
101618
|
homepage: "https://use-agently.com",
|
|
101611
101619
|
bugs: "https://github.com/AgentlyHQ/use-agently/issues",
|
|
@@ -101629,7 +101637,7 @@ var package_default2 = {
|
|
|
101629
101637
|
test: "bun test"
|
|
101630
101638
|
},
|
|
101631
101639
|
dependencies: {
|
|
101632
|
-
"@use-agently/sdk": "0.
|
|
101640
|
+
"@use-agently/sdk": "0.18.0",
|
|
101633
101641
|
boxen: "^8.0.1",
|
|
101634
101642
|
commander: "^14.0.3",
|
|
101635
101643
|
viem: "^2.46.3",
|
|
@@ -101834,7 +101842,52 @@ Expected a JSON object, e.g. '{"message":"hello"}'`);
|
|
|
101834
101842
|
clientInfo: { name: "use-agently", version: package_default2.version },
|
|
101835
101843
|
fetchImpl: clientFetch2
|
|
101836
101844
|
});
|
|
101837
|
-
|
|
101845
|
+
const content = result.content;
|
|
101846
|
+
if (result.isError) {
|
|
101847
|
+
const text = content?.find((c) => c.type === "text")?.text;
|
|
101848
|
+
if (text) {
|
|
101849
|
+
try {
|
|
101850
|
+
const parsed = JSON.parse(text);
|
|
101851
|
+
if (parsed?.error && Array.isArray(parsed?.accepts) && parsed.accepts.length > 0) {
|
|
101852
|
+
let message;
|
|
101853
|
+
if (parsed.error === "insufficient_funds") {
|
|
101854
|
+
const req = parsed.accepts[0];
|
|
101855
|
+
let amountStr = "unknown amount";
|
|
101856
|
+
try {
|
|
101857
|
+
const { usdcDecimals } = getChainConfigByNetwork(req.network);
|
|
101858
|
+
const raw = formatUnits(BigInt(req.amount), usdcDecimals);
|
|
101859
|
+
const formatted = raw.includes(".") ? raw.replace(/\.?0+$/, "") : raw;
|
|
101860
|
+
amountStr = `$${formatted} USDC on ${req.network}`;
|
|
101861
|
+
} catch {
|
|
101862
|
+
amountStr = `${req.amount} (raw units)`;
|
|
101863
|
+
}
|
|
101864
|
+
message = `Insufficient funds to pay for this tool.
|
|
101865
|
+
Required: ${amountStr}
|
|
101866
|
+
Ensure your wallet has sufficient USDC balance and try again.`;
|
|
101867
|
+
} else {
|
|
101868
|
+
message = `Payment error: ${parsed.error}`;
|
|
101869
|
+
}
|
|
101870
|
+
console.error(boxen(message, {
|
|
101871
|
+
title: parsed.error === "insufficient_funds" ? "Insufficient Funds" : "Payment Error",
|
|
101872
|
+
titleAlignment: "center",
|
|
101873
|
+
borderColor: "red",
|
|
101874
|
+
padding: 1
|
|
101875
|
+
}));
|
|
101876
|
+
process.exit(1);
|
|
101877
|
+
}
|
|
101878
|
+
} catch {}
|
|
101879
|
+
console.error(text);
|
|
101880
|
+
} else {
|
|
101881
|
+
console.error("Tool call returned an error with no text content.");
|
|
101882
|
+
}
|
|
101883
|
+
process.exit(1);
|
|
101884
|
+
}
|
|
101885
|
+
if (content?.every((c) => c.type === "text" && c.text)) {
|
|
101886
|
+
const texts = content.map((c) => c.text);
|
|
101887
|
+
output(command, texts.length === 1 ? texts[0] : texts);
|
|
101888
|
+
} else {
|
|
101889
|
+
output(command, result);
|
|
101890
|
+
}
|
|
101838
101891
|
} catch (err) {
|
|
101839
101892
|
if (err instanceof DryRunPaymentRequired)
|
|
101840
101893
|
handleDryRunError(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-agently",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Use Agently CLI",
|
|
5
5
|
"homepage": "https://use-agently.com",
|
|
6
6
|
"bugs": "https://github.com/AgentlyHQ/use-agently/issues",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test": "bun test"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@use-agently/sdk": "0.
|
|
27
|
+
"@use-agently/sdk": "0.18.0",
|
|
28
28
|
"boxen": "^8.0.1",
|
|
29
29
|
"commander": "^14.0.3",
|
|
30
30
|
"viem": "^2.46.3",
|