use-agently 0.19.0 → 0.20.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/README.md +3 -11
- package/build/bin.js +322 -298
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# use-agently
|
|
2
2
|
|
|
3
|
-
CLI for the [Agently](https://use-agently.com) platform — a
|
|
3
|
+
CLI for the [Agently](https://use-agently.com) platform — a marketplace for AI agents using the [x402](https://www.x402.org/) payment protocol.
|
|
4
4
|
|
|
5
5
|
Manage local EVM wallets, discover agents, and communicate with them via the [A2A (Agent-to-Agent)](https://google.github.io/A2A/) protocol.
|
|
6
6
|
|
|
@@ -123,18 +123,10 @@ Connect to an MCP server to list or call tools.
|
|
|
123
123
|
|
|
124
124
|
```bash
|
|
125
125
|
# List tools
|
|
126
|
-
use-agently mcp tools --uri
|
|
126
|
+
use-agently mcp tools --uri https://example.com
|
|
127
127
|
|
|
128
128
|
# Call a tool
|
|
129
|
-
use-agently mcp call echo '{"message":"hello"}' --uri
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### `erc-8004`
|
|
133
|
-
|
|
134
|
-
Resolve an ERC-8004 agent URI and display its details from the Agently marketplace.
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
use-agently erc-8004 --uri eip155:8453/erc-8004:0x1234/1
|
|
129
|
+
use-agently mcp call --tool echo --args '{"message":"hello"}' --uri https://example.com
|
|
138
130
|
```
|
|
139
131
|
|
|
140
132
|
### `web`
|
package/build/bin.js
CHANGED
|
@@ -65437,11 +65437,20 @@ function renderText(data) {
|
|
|
65437
65437
|
}
|
|
65438
65438
|
function output(command, data) {
|
|
65439
65439
|
if (command.optsWithGlobals().output === "json") {
|
|
65440
|
-
console.log(JSON.stringify(data
|
|
65440
|
+
console.log(JSON.stringify(data));
|
|
65441
65441
|
} else {
|
|
65442
65442
|
console.log(renderText(data));
|
|
65443
65443
|
}
|
|
65444
65444
|
}
|
|
65445
|
+
function outputCollection(command, items) {
|
|
65446
|
+
if (command.optsWithGlobals().output === "json") {
|
|
65447
|
+
for (const item of items) {
|
|
65448
|
+
console.log(JSON.stringify(item));
|
|
65449
|
+
}
|
|
65450
|
+
} else {
|
|
65451
|
+
console.log(renderText(items));
|
|
65452
|
+
}
|
|
65453
|
+
}
|
|
65445
65454
|
|
|
65446
65455
|
// ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
|
|
65447
65456
|
var exports_external = {};
|
|
@@ -95678,6 +95687,152 @@ function wrapMCPClientWithPaymentFromConfig(mcpClient, config2, options) {
|
|
|
95678
95687
|
return new x402MCPClient(mcpClient, paymentClient, options);
|
|
95679
95688
|
}
|
|
95680
95689
|
|
|
95690
|
+
// ../use-agently-sdk/utils/transaction.ts
|
|
95691
|
+
var DryRunTransaction = { mode: "dry-run" };
|
|
95692
|
+
function PayTransaction(wallet) {
|
|
95693
|
+
return { mode: "pay", wallet };
|
|
95694
|
+
}
|
|
95695
|
+
// ../use-agently-sdk/package.json
|
|
95696
|
+
var package_default = {
|
|
95697
|
+
name: "@use-agently/sdk",
|
|
95698
|
+
version: "0.20.0",
|
|
95699
|
+
description: "Core SDK for the Agently platform — wallet management, A2A, MCP, x402 payments",
|
|
95700
|
+
homepage: "https://github.com/AgentlyHQ/use-agently/tree/main/packages/use-agently-sdk",
|
|
95701
|
+
bugs: {
|
|
95702
|
+
url: "https://github.com/AgentlyHQ/use-agently/issues"
|
|
95703
|
+
},
|
|
95704
|
+
repository: {
|
|
95705
|
+
type: "git",
|
|
95706
|
+
url: "git+https://github.com/AgentlyHQ/use-agently.git",
|
|
95707
|
+
directory: "packages/use-agently-sdk"
|
|
95708
|
+
},
|
|
95709
|
+
license: "MIT",
|
|
95710
|
+
author: "AgentlyHQ",
|
|
95711
|
+
type: "module",
|
|
95712
|
+
files: [
|
|
95713
|
+
"**/*.ts",
|
|
95714
|
+
"!**/*.test.ts",
|
|
95715
|
+
"README.md"
|
|
95716
|
+
],
|
|
95717
|
+
scripts: {
|
|
95718
|
+
test: "bun test"
|
|
95719
|
+
},
|
|
95720
|
+
dependencies: {
|
|
95721
|
+
"@a2a-js/sdk": "^0.3.10",
|
|
95722
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
95723
|
+
"@x402/evm": "^2.5.0",
|
|
95724
|
+
"@x402/fetch": "^2.5.0",
|
|
95725
|
+
"@x402/mcp": "^2.5.0",
|
|
95726
|
+
viem: "^2.46.3",
|
|
95727
|
+
zod: "^4"
|
|
95728
|
+
},
|
|
95729
|
+
devDependencies: {
|
|
95730
|
+
"@types/bun": "^1.3.9",
|
|
95731
|
+
"localhost-aixyz": "^0",
|
|
95732
|
+
testcontainers: "^11",
|
|
95733
|
+
"x402-fl": "^0"
|
|
95734
|
+
},
|
|
95735
|
+
engines: {
|
|
95736
|
+
node: ">=20"
|
|
95737
|
+
}
|
|
95738
|
+
};
|
|
95739
|
+
|
|
95740
|
+
// ../use-agently-sdk/client.ts
|
|
95741
|
+
function createClient4(options) {
|
|
95742
|
+
const fetch2 = createFetch({ userAgent: options.userAgent });
|
|
95743
|
+
return {
|
|
95744
|
+
fetch: fetch2
|
|
95745
|
+
};
|
|
95746
|
+
}
|
|
95747
|
+
function createFetch(options) {
|
|
95748
|
+
return (input, init) => {
|
|
95749
|
+
const isRequest = input instanceof Request;
|
|
95750
|
+
const headers = new Headers(isRequest ? input.headers : init?.headers);
|
|
95751
|
+
if (isRequest && init?.headers) {
|
|
95752
|
+
for (const [key, value] of new Headers(init.headers).entries()) {
|
|
95753
|
+
headers.set(key, value);
|
|
95754
|
+
}
|
|
95755
|
+
}
|
|
95756
|
+
if (!headers.has("User-Agent")) {
|
|
95757
|
+
headers.set("User-Agent", options?.userAgent ?? `@use-agently/sdk:${package_default.version} (use-agently.com)`);
|
|
95758
|
+
}
|
|
95759
|
+
return fetch(input, { ...init, headers });
|
|
95760
|
+
};
|
|
95761
|
+
}
|
|
95762
|
+
var clientFetch = createFetch();
|
|
95763
|
+
function formatUsdcAmount(req) {
|
|
95764
|
+
try {
|
|
95765
|
+
const { usdcDecimals } = getChainConfigByNetwork(req.network);
|
|
95766
|
+
const raw = formatUnits(BigInt(req.amount), usdcDecimals);
|
|
95767
|
+
const formatted = raw.includes(".") ? raw.replace(/\.?0+$/, "") : raw;
|
|
95768
|
+
const network = req.network ? ` on ${req.network}` : "";
|
|
95769
|
+
return `$${formatted} USDC${network}`;
|
|
95770
|
+
} catch {
|
|
95771
|
+
return `${req.amount} (raw units)`;
|
|
95772
|
+
}
|
|
95773
|
+
}
|
|
95774
|
+
|
|
95775
|
+
class DryRunPaymentRequired extends Error {
|
|
95776
|
+
requirements;
|
|
95777
|
+
constructor(requirements) {
|
|
95778
|
+
const req = requirements[0];
|
|
95779
|
+
const amount = req ? formatUsdcAmount(req) : null;
|
|
95780
|
+
const payLine = amount ? `This request requires payment of ${amount}.
|
|
95781
|
+
Use createPaymentFetch() instead of createDryRunFetch() to authorize the transaction.` : `This request requires payment, but the amount could not be determined.
|
|
95782
|
+
Inspect the endpoint manually or use createPaymentFetch() to authorize payment.`;
|
|
95783
|
+
super(payLine);
|
|
95784
|
+
this.name = "DryRunPaymentRequired";
|
|
95785
|
+
this.requirements = requirements;
|
|
95786
|
+
}
|
|
95787
|
+
}
|
|
95788
|
+
function createDryRunFetch(fetchImpl = clientFetch) {
|
|
95789
|
+
return async (input, init) => {
|
|
95790
|
+
const response = await fetchImpl(input, init);
|
|
95791
|
+
if (response.status === 402) {
|
|
95792
|
+
let requirements = [];
|
|
95793
|
+
const header = response.headers.get("PAYMENT-REQUIRED");
|
|
95794
|
+
if (header) {
|
|
95795
|
+
try {
|
|
95796
|
+
const decoded = JSON.parse(Buffer.from(header, "base64").toString("utf-8"));
|
|
95797
|
+
requirements = decoded.accepts ?? [];
|
|
95798
|
+
} catch (e) {
|
|
95799
|
+
if (!(e instanceof SyntaxError))
|
|
95800
|
+
throw e;
|
|
95801
|
+
}
|
|
95802
|
+
} else {
|
|
95803
|
+
try {
|
|
95804
|
+
const body = await response.clone().json();
|
|
95805
|
+
if (body?.accepts) {
|
|
95806
|
+
requirements = body.accepts;
|
|
95807
|
+
}
|
|
95808
|
+
} catch (e) {
|
|
95809
|
+
if (!(e instanceof SyntaxError))
|
|
95810
|
+
throw e;
|
|
95811
|
+
}
|
|
95812
|
+
}
|
|
95813
|
+
throw new DryRunPaymentRequired(requirements);
|
|
95814
|
+
}
|
|
95815
|
+
return response;
|
|
95816
|
+
};
|
|
95817
|
+
}
|
|
95818
|
+
function resolveFetchForTransaction(transaction = DryRunTransaction, fetchImpl) {
|
|
95819
|
+
if (transaction.mode === "dry-run")
|
|
95820
|
+
return createDryRunFetch(fetchImpl);
|
|
95821
|
+
return createPaymentFetch(transaction.wallet, fetchImpl);
|
|
95822
|
+
}
|
|
95823
|
+
function createPaymentFetch(wallet, fetchImpl = clientFetch) {
|
|
95824
|
+
return wrapFetchWithPaymentFromConfig(fetchImpl, {
|
|
95825
|
+
schemes: wallet.getX402Schemes()
|
|
95826
|
+
});
|
|
95827
|
+
}
|
|
95828
|
+
function createMcpPaymentClient(mcpClient, wallet) {
|
|
95829
|
+
return wrapMCPClientWithPaymentFromConfig(mcpClient, {
|
|
95830
|
+
schemes: wallet.getX402Schemes()
|
|
95831
|
+
});
|
|
95832
|
+
}
|
|
95833
|
+
// ../use-agently-sdk/a2a.ts
|
|
95834
|
+
import { randomUUID } from "node:crypto";
|
|
95835
|
+
|
|
95681
95836
|
// ../../node_modules/.bun/@a2a-js+sdk@0.3.10+81e50683f7a708c7/node_modules/@a2a-js/sdk/dist/chunk-WMQQYH7W.js
|
|
95682
95837
|
async function* parseSseStream(response) {
|
|
95683
95838
|
if (!response.body) {
|
|
@@ -98524,198 +98679,49 @@ var CaseInsensitiveMap = class extends Map {
|
|
|
98524
98679
|
}
|
|
98525
98680
|
};
|
|
98526
98681
|
|
|
98527
|
-
// ../use-agently-sdk/
|
|
98528
|
-
var
|
|
98529
|
-
function
|
|
98530
|
-
|
|
98531
|
-
|
|
98532
|
-
|
|
98533
|
-
|
|
98534
|
-
|
|
98535
|
-
|
|
98536
|
-
description: "Core SDK for the Agently platform — wallet management, A2A, MCP, x402 payments",
|
|
98537
|
-
homepage: "https://github.com/AgentlyHQ/use-agently/tree/main/packages/use-agently-sdk",
|
|
98538
|
-
bugs: {
|
|
98539
|
-
url: "https://github.com/AgentlyHQ/use-agently/issues"
|
|
98540
|
-
},
|
|
98541
|
-
repository: {
|
|
98542
|
-
type: "git",
|
|
98543
|
-
url: "git+https://github.com/AgentlyHQ/use-agently.git",
|
|
98544
|
-
directory: "packages/use-agently-sdk"
|
|
98545
|
-
},
|
|
98546
|
-
license: "MIT",
|
|
98547
|
-
author: "AgentlyHQ",
|
|
98548
|
-
type: "module",
|
|
98549
|
-
files: [
|
|
98550
|
-
"**/*.ts",
|
|
98551
|
-
"!**/*.test.ts",
|
|
98552
|
-
"README.md"
|
|
98553
|
-
],
|
|
98554
|
-
scripts: {
|
|
98555
|
-
test: "bun test"
|
|
98556
|
-
},
|
|
98557
|
-
dependencies: {
|
|
98558
|
-
"@a2a-js/sdk": "^0.3.10",
|
|
98559
|
-
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
98560
|
-
"@x402/evm": "^2.5.0",
|
|
98561
|
-
"@x402/fetch": "^2.5.0",
|
|
98562
|
-
"@x402/mcp": "^2.5.0",
|
|
98563
|
-
viem: "^2.46.3",
|
|
98564
|
-
zod: "^4"
|
|
98565
|
-
},
|
|
98566
|
-
devDependencies: {
|
|
98567
|
-
"@types/bun": "^1.3.9",
|
|
98568
|
-
"localhost-aixyz": "^0",
|
|
98569
|
-
testcontainers: "^11",
|
|
98570
|
-
"x402-fl": "^0"
|
|
98571
|
-
},
|
|
98572
|
-
engines: {
|
|
98573
|
-
node: ">=20"
|
|
98574
|
-
}
|
|
98575
|
-
};
|
|
98576
|
-
|
|
98577
|
-
// ../use-agently-sdk/client.ts
|
|
98578
|
-
var USER_AGENT = `@use-agently/sdk:${package_default.version} (use-agently.com)`;
|
|
98579
|
-
function createClientFetch(userAgent = USER_AGENT) {
|
|
98580
|
-
return (input, init) => {
|
|
98581
|
-
const isRequest = input instanceof Request;
|
|
98582
|
-
const headers = new Headers(isRequest ? input.headers : init?.headers);
|
|
98583
|
-
if (isRequest && init?.headers) {
|
|
98584
|
-
for (const [key, value] of new Headers(init.headers).entries()) {
|
|
98585
|
-
headers.set(key, value);
|
|
98586
|
-
}
|
|
98682
|
+
// ../use-agently-sdk/agently.ts
|
|
98683
|
+
var BASE_URL = "https://api.use-agently.com";
|
|
98684
|
+
async function search(client, options) {
|
|
98685
|
+
const url2 = new URL("/search", BASE_URL);
|
|
98686
|
+
if (options?.q)
|
|
98687
|
+
url2.searchParams.set("q", options.q);
|
|
98688
|
+
if (options?.chain_id) {
|
|
98689
|
+
for (const chain of options.chain_id) {
|
|
98690
|
+
url2.searchParams.append("chain_id", chain);
|
|
98587
98691
|
}
|
|
98588
|
-
if (!headers.has("User-Agent")) {
|
|
98589
|
-
headers.set("User-Agent", userAgent);
|
|
98590
|
-
}
|
|
98591
|
-
return fetch(input, { ...init, headers });
|
|
98592
|
-
};
|
|
98593
|
-
}
|
|
98594
|
-
var clientFetch = createClientFetch();
|
|
98595
|
-
function formatUsdcAmount(req) {
|
|
98596
|
-
try {
|
|
98597
|
-
const { usdcDecimals } = getChainConfigByNetwork(req.network);
|
|
98598
|
-
const raw = formatUnits(BigInt(req.amount), usdcDecimals);
|
|
98599
|
-
const formatted = raw.includes(".") ? raw.replace(/\.?0+$/, "") : raw;
|
|
98600
|
-
const network = req.network ? ` on ${req.network}` : "";
|
|
98601
|
-
return `$${formatted} USDC${network}`;
|
|
98602
|
-
} catch {
|
|
98603
|
-
return `${req.amount} (raw units)`;
|
|
98604
98692
|
}
|
|
98605
|
-
|
|
98606
|
-
|
|
98607
|
-
|
|
98608
|
-
requirements;
|
|
98609
|
-
constructor(requirements) {
|
|
98610
|
-
const req = requirements[0];
|
|
98611
|
-
const amount = req ? formatUsdcAmount(req) : null;
|
|
98612
|
-
const payLine = amount ? `This request requires payment of ${amount}.
|
|
98613
|
-
Use createPaymentFetch() instead of createDryRunFetch() to authorize the transaction.` : `This request requires payment, but the amount could not be determined.
|
|
98614
|
-
Inspect the endpoint manually or use createPaymentFetch() to authorize payment.`;
|
|
98615
|
-
super(payLine);
|
|
98616
|
-
this.name = "DryRunPaymentRequired";
|
|
98617
|
-
this.requirements = requirements;
|
|
98618
|
-
}
|
|
98619
|
-
}
|
|
98620
|
-
function createDryRunFetch(fetchImpl = clientFetch) {
|
|
98621
|
-
return async (input, init) => {
|
|
98622
|
-
const response = await fetchImpl(input, init);
|
|
98623
|
-
if (response.status === 402) {
|
|
98624
|
-
let requirements = [];
|
|
98625
|
-
const header = response.headers.get("PAYMENT-REQUIRED");
|
|
98626
|
-
if (header) {
|
|
98627
|
-
try {
|
|
98628
|
-
const decoded = JSON.parse(Buffer.from(header, "base64").toString("utf-8"));
|
|
98629
|
-
requirements = decoded.accepts ?? [];
|
|
98630
|
-
} catch (e) {
|
|
98631
|
-
if (!(e instanceof SyntaxError))
|
|
98632
|
-
throw e;
|
|
98633
|
-
}
|
|
98634
|
-
} else {
|
|
98635
|
-
try {
|
|
98636
|
-
const body = await response.clone().json();
|
|
98637
|
-
if (body?.accepts) {
|
|
98638
|
-
requirements = body.accepts;
|
|
98639
|
-
}
|
|
98640
|
-
} catch (e) {
|
|
98641
|
-
if (!(e instanceof SyntaxError))
|
|
98642
|
-
throw e;
|
|
98643
|
-
}
|
|
98644
|
-
}
|
|
98645
|
-
throw new DryRunPaymentRequired(requirements);
|
|
98693
|
+
if (options?.protocol) {
|
|
98694
|
+
for (const proto of options.protocol) {
|
|
98695
|
+
url2.searchParams.append("protocol", proto);
|
|
98646
98696
|
}
|
|
98647
|
-
return response;
|
|
98648
|
-
};
|
|
98649
|
-
}
|
|
98650
|
-
function resolveFetchForTransaction(transaction = DryRunTransaction, fetchImpl) {
|
|
98651
|
-
if (transaction.mode === "dry-run")
|
|
98652
|
-
return createDryRunFetch(fetchImpl);
|
|
98653
|
-
return createPaymentFetch(transaction.wallet, fetchImpl);
|
|
98654
|
-
}
|
|
98655
|
-
function createPaymentFetch(wallet, fetchImpl = clientFetch) {
|
|
98656
|
-
return wrapFetchWithPaymentFromConfig(fetchImpl, {
|
|
98657
|
-
schemes: wallet.getX402Schemes()
|
|
98658
|
-
});
|
|
98659
|
-
}
|
|
98660
|
-
function createMcpPaymentClient(mcpClient, wallet) {
|
|
98661
|
-
return wrapMCPClientWithPaymentFromConfig(mcpClient, {
|
|
98662
|
-
schemes: wallet.getX402Schemes()
|
|
98663
|
-
});
|
|
98664
|
-
}
|
|
98665
|
-
async function createA2AClient(agentUrl, fetchImpl) {
|
|
98666
|
-
const factory = new ClientFactory({
|
|
98667
|
-
transports: [new JsonRpcTransportFactory({ fetchImpl }), new RestTransportFactory({ fetchImpl })]
|
|
98668
|
-
});
|
|
98669
|
-
return factory.createFromUrl(agentUrl);
|
|
98670
|
-
}
|
|
98671
|
-
// ../use-agently-sdk/marketplace.ts
|
|
98672
|
-
var MARKETPLACE_URL = "https://use-agently.com/marketplace.json";
|
|
98673
|
-
|
|
98674
|
-
class AgentNotFoundError extends Error {
|
|
98675
|
-
uri;
|
|
98676
|
-
constructor(uri) {
|
|
98677
|
-
super(`No agent found for URI: ${uri}`);
|
|
98678
|
-
this.uri = uri;
|
|
98679
|
-
this.name = "AgentNotFoundError";
|
|
98680
98697
|
}
|
|
98681
|
-
|
|
98682
|
-
|
|
98683
|
-
|
|
98698
|
+
if (options?.page !== undefined)
|
|
98699
|
+
url2.searchParams.set("page", String(options.page));
|
|
98700
|
+
if (options?.per_page !== undefined)
|
|
98701
|
+
url2.searchParams.set("per_page", String(options.per_page));
|
|
98702
|
+
const response = await client.fetch(url2);
|
|
98684
98703
|
if (!response.ok) {
|
|
98685
|
-
throw new Error(`
|
|
98704
|
+
throw new Error(`Agently search failed: ${response.status} ${response.statusText}`);
|
|
98686
98705
|
}
|
|
98687
|
-
|
|
98688
|
-
return data.agents ?? [];
|
|
98706
|
+
return response.json();
|
|
98689
98707
|
}
|
|
98690
|
-
async function
|
|
98691
|
-
|
|
98692
|
-
|
|
98693
|
-
|
|
98694
|
-
|
|
98695
|
-
|
|
98696
|
-
if (options.protocols) {
|
|
98697
|
-
const protocols = options.protocols.map((p) => p.trim().toLowerCase());
|
|
98698
|
-
agents = agents.filter((a) => Array.isArray(a.protocols) && protocols.some((p) => a.protocols.includes(p)));
|
|
98708
|
+
async function getAgent(client, id) {
|
|
98709
|
+
const normalizedId = id.startsWith("eip155:") ? id.toLowerCase() : id;
|
|
98710
|
+
const url2 = new URL(`/agents/${normalizedId}`, BASE_URL);
|
|
98711
|
+
const response = await client.fetch(url2);
|
|
98712
|
+
if (response.status === 404) {
|
|
98713
|
+
return;
|
|
98699
98714
|
}
|
|
98700
|
-
|
|
98701
|
-
}
|
|
98702
|
-
async function resolveErc8004Agent(uri, fetchImpl = clientFetch) {
|
|
98703
|
-
const agents = await fetchAgents(fetchImpl);
|
|
98704
|
-
const agent = agents.find((a) => a.uri === uri);
|
|
98705
|
-
if (!agent) {
|
|
98706
|
-
throw new AgentNotFoundError(uri);
|
|
98715
|
+
if (!response.ok) {
|
|
98716
|
+
throw new Error(`Agently lookup failed: ${response.status} ${response.statusText}`);
|
|
98707
98717
|
}
|
|
98708
|
-
return
|
|
98718
|
+
return response.json();
|
|
98709
98719
|
}
|
|
98720
|
+
|
|
98710
98721
|
// ../use-agently-sdk/a2a.ts
|
|
98711
|
-
import { randomUUID } from "node:crypto";
|
|
98712
98722
|
function extractTextFromParts(parts) {
|
|
98713
98723
|
return parts.filter((p) => p.kind === "text").map((p) => p.text).join("");
|
|
98714
98724
|
}
|
|
98715
|
-
function resolveAgentUrl(agentInput) {
|
|
98716
|
-
const isDirectUrl = agentInput.startsWith("http://") || agentInput.startsWith("https://");
|
|
98717
|
-
return isDirectUrl ? agentInput : `https://use-agently.com/${agentInput}/`;
|
|
98718
|
-
}
|
|
98719
98725
|
function extractAgentText(result) {
|
|
98720
98726
|
if (!result) {
|
|
98721
98727
|
return "The agent processed your request but returned no response.";
|
|
@@ -98748,11 +98754,17 @@ function extractStreamEventText(event) {
|
|
|
98748
98754
|
}
|
|
98749
98755
|
return "";
|
|
98750
98756
|
}
|
|
98751
|
-
async function
|
|
98752
|
-
const
|
|
98753
|
-
const
|
|
98754
|
-
|
|
98755
|
-
|
|
98757
|
+
async function createA2AClient(client, uri, fetchImpl) {
|
|
98758
|
+
const url2 = await getAgentCardURL(client, uri);
|
|
98759
|
+
const factory = new ClientFactory({
|
|
98760
|
+
transports: [new JsonRpcTransportFactory({ fetchImpl }), new RestTransportFactory({ fetchImpl })]
|
|
98761
|
+
});
|
|
98762
|
+
return factory.createFromUrl(url2.toString(), "");
|
|
98763
|
+
}
|
|
98764
|
+
async function sendMessageStream(client, uri, message, options) {
|
|
98765
|
+
const resolvedFetch = resolveFetchForTransaction(options?.mode, client.fetch);
|
|
98766
|
+
const a2aClient = await createA2AClient(client, uri, resolvedFetch);
|
|
98767
|
+
return a2aClient.sendMessageStream({
|
|
98756
98768
|
message: {
|
|
98757
98769
|
kind: "message",
|
|
98758
98770
|
messageId: randomUUID(),
|
|
@@ -98761,10 +98773,32 @@ async function sendA2AMessageStream(uri, message, options) {
|
|
|
98761
98773
|
}
|
|
98762
98774
|
});
|
|
98763
98775
|
}
|
|
98764
|
-
async function
|
|
98765
|
-
const
|
|
98766
|
-
const
|
|
98767
|
-
|
|
98776
|
+
async function getAgentCard(client, uri) {
|
|
98777
|
+
const url2 = await getAgentCardURL(client, uri);
|
|
98778
|
+
const response = await client.fetch(url2);
|
|
98779
|
+
if (!response.ok) {
|
|
98780
|
+
throw new Error(`Failed to fetch agent card from ${url2}: ${response.status} ${response.statusText}`);
|
|
98781
|
+
}
|
|
98782
|
+
return response.json();
|
|
98783
|
+
}
|
|
98784
|
+
async function getAgentCardURL(client, uri) {
|
|
98785
|
+
if (uri.startsWith("eip155:")) {
|
|
98786
|
+
const agent = await getAgent(client, uri);
|
|
98787
|
+
if (!agent) {
|
|
98788
|
+
throw new Error(`Agent (${uri}) not found.`);
|
|
98789
|
+
}
|
|
98790
|
+
const service = agent.metadata?.services?.find((s) => s.name === "a2a");
|
|
98791
|
+
if (!service) {
|
|
98792
|
+
throw new Error(`Agent (${uri}) has no A2A service registered.`);
|
|
98793
|
+
}
|
|
98794
|
+
return new URL(service.endpoint);
|
|
98795
|
+
}
|
|
98796
|
+
const url2 = new URL(uri);
|
|
98797
|
+
if (url2.pathname.endsWith("/.well-known/agent-card.json")) {
|
|
98798
|
+
return url2;
|
|
98799
|
+
}
|
|
98800
|
+
url2.pathname = url2.pathname.replace(/\/?$/, "/.well-known/agent-card.json");
|
|
98801
|
+
return url2;
|
|
98768
98802
|
}
|
|
98769
98803
|
// ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
98770
98804
|
function normalizeHeaders(headers) {
|
|
@@ -100120,14 +100154,19 @@ class StreamableHTTPClientTransport {
|
|
|
100120
100154
|
}
|
|
100121
100155
|
|
|
100122
100156
|
// ../use-agently-sdk/mcp.ts
|
|
100123
|
-
function
|
|
100124
|
-
|
|
100125
|
-
|
|
100126
|
-
|
|
100127
|
-
|
|
100128
|
-
|
|
100157
|
+
async function getMcpURL(client, input) {
|
|
100158
|
+
if (input.startsWith("eip155:")) {
|
|
100159
|
+
const agent = await getAgent(client, input);
|
|
100160
|
+
if (!agent) {
|
|
100161
|
+
throw new Error(`Agent (${input}) not found.`);
|
|
100162
|
+
}
|
|
100163
|
+
const service = agent.metadata?.services?.find((s) => s.name === "mcp");
|
|
100164
|
+
if (!service) {
|
|
100165
|
+
throw new Error(`Agent (${input}) has no MCP service registered.`);
|
|
100166
|
+
}
|
|
100167
|
+
return new URL(service.endpoint);
|
|
100129
100168
|
}
|
|
100130
|
-
return
|
|
100169
|
+
return new URL(input);
|
|
100131
100170
|
}
|
|
100132
100171
|
async function createMcpClient(mcpUrl, options) {
|
|
100133
100172
|
const client = new Client(options?.clientInfo ?? { name: "@use-agently/sdk", version: package_default.version });
|
|
@@ -100140,8 +100179,8 @@ async function createMcpClient(mcpUrl, options) {
|
|
|
100140
100179
|
await client.connect(transport);
|
|
100141
100180
|
return client;
|
|
100142
100181
|
}
|
|
100143
|
-
async function listMcpTools(uri, options) {
|
|
100144
|
-
const mcpUrl =
|
|
100182
|
+
async function listMcpTools(sdkClient, uri, options) {
|
|
100183
|
+
const mcpUrl = await (await getMcpURL(sdkClient, uri)).toString();
|
|
100145
100184
|
const resolvedFetch = resolveFetchForTransaction(options?.transaction, options?.fetchImpl);
|
|
100146
100185
|
const client = await createMcpClient(mcpUrl, { clientInfo: options?.clientInfo, fetchImpl: resolvedFetch });
|
|
100147
100186
|
try {
|
|
@@ -100151,8 +100190,8 @@ async function listMcpTools(uri, options) {
|
|
|
100151
100190
|
await client.close();
|
|
100152
100191
|
}
|
|
100153
100192
|
}
|
|
100154
|
-
async function callMcpTool(uri, tool, args, options) {
|
|
100155
|
-
const mcpUrl =
|
|
100193
|
+
async function callMcpTool(sdkClient, uri, tool, args, options) {
|
|
100194
|
+
const mcpUrl = await (await getMcpURL(sdkClient, uri)).toString();
|
|
100156
100195
|
const transaction = options?.transaction ?? DryRunTransaction;
|
|
100157
100196
|
const resolvedFetch = resolveFetchForTransaction(transaction, options?.fetchImpl);
|
|
100158
100197
|
if (transaction.mode === "pay") {
|
|
@@ -100277,13 +100316,14 @@ async function backupConfig(scope = "global") {
|
|
|
100277
100316
|
async function getConfigOrThrow() {
|
|
100278
100317
|
const config2 = await loadConfig();
|
|
100279
100318
|
if (!config2?.wallet) {
|
|
100280
|
-
throw new Error("No wallet configured.
|
|
100319
|
+
throw new Error("No wallet configured. Run 'use-agently init' to create one.");
|
|
100281
100320
|
}
|
|
100282
100321
|
return config2;
|
|
100283
100322
|
}
|
|
100284
100323
|
|
|
100285
100324
|
// src/commands/init.ts
|
|
100286
|
-
var initCommand = new Command("init").description("Generate a new local wallet and save it to config").option("--regenerate", "Backup existing config and generate a new wallet").option("--local", "Save config to the current directory (.use-agently/config.json) instead of the home directory").
|
|
100325
|
+
var initCommand = new Command("init").description("Generate a new local wallet and save it to config").option("--regenerate", "Backup existing config and generate a new wallet").option("--local", "Save config to the current directory (.use-agently/config.json) instead of the home directory").showHelpAfterError(true).addHelpText("after", `
|
|
100326
|
+
Config: ~/.use-agently/config.json (global), .use-agently/config.json (local)`).action(async (options, command) => {
|
|
100287
100327
|
const scope = options.local ? "local" : "global";
|
|
100288
100328
|
const existing = await loadConfig(scope);
|
|
100289
100329
|
if (existing?.wallet) {
|
|
@@ -100291,7 +100331,8 @@ var initCommand = new Command("init").description("Generate a new local wallet a
|
|
|
100291
100331
|
console.error("Wallet already configured. Use --regenerate to create a new wallet.");
|
|
100292
100332
|
process.exit(1);
|
|
100293
100333
|
}
|
|
100294
|
-
await backupConfig(scope);
|
|
100334
|
+
const backupPath = await backupConfig(scope);
|
|
100335
|
+
console.error(`Previous config backed up to ${backupPath}`);
|
|
100295
100336
|
}
|
|
100296
100337
|
const walletConfig = generateEvmPrivateKeyConfig();
|
|
100297
100338
|
await saveConfig({ wallet: walletConfig }, scope);
|
|
@@ -100302,7 +100343,7 @@ var initCommand = new Command("init").description("Generate a new local wallet a
|
|
|
100302
100343
|
});
|
|
100303
100344
|
|
|
100304
100345
|
// src/commands/whoami.ts
|
|
100305
|
-
var whoamiCommand = new Command("whoami").description("Show current wallet info").action(async (_options, command) => {
|
|
100346
|
+
var whoamiCommand = new Command("whoami").description("Show current wallet info").showHelpAfterError(true).action(async (_options, command) => {
|
|
100306
100347
|
const config2 = await getConfigOrThrow();
|
|
100307
100348
|
const wallet = loadWallet(config2.wallet);
|
|
100308
100349
|
output(command, {
|
|
@@ -100312,7 +100353,7 @@ var whoamiCommand = new Command("whoami").description("Show current wallet info"
|
|
|
100312
100353
|
});
|
|
100313
100354
|
|
|
100314
100355
|
// src/commands/balance.ts
|
|
100315
|
-
var balanceCommand = new Command("balance").description("Check wallet balance on-chain").option("--rpc <url>", "Custom RPC URL").action(async (options, command) => {
|
|
100356
|
+
var balanceCommand = new Command("balance").description("Check wallet balance on-chain").option("--rpc <url>", "Custom RPC URL").showHelpAfterError(true).action(async (options, command) => {
|
|
100316
100357
|
const config2 = await getConfigOrThrow();
|
|
100317
100358
|
const wallet = loadWallet(config2.wallet);
|
|
100318
100359
|
const result = await getBalance2(wallet.address, { rpc: options.rpc });
|
|
@@ -101680,7 +101721,7 @@ function boxen(text, options) {
|
|
|
101680
101721
|
// package.json
|
|
101681
101722
|
var package_default2 = {
|
|
101682
101723
|
name: "use-agently",
|
|
101683
|
-
version: "0.
|
|
101724
|
+
version: "0.20.0",
|
|
101684
101725
|
description: "Use Agently CLI",
|
|
101685
101726
|
homepage: "https://use-agently.com",
|
|
101686
101727
|
bugs: "https://github.com/AgentlyHQ/use-agently/issues",
|
|
@@ -101704,7 +101745,7 @@ var package_default2 = {
|
|
|
101704
101745
|
test: "bun test"
|
|
101705
101746
|
},
|
|
101706
101747
|
dependencies: {
|
|
101707
|
-
"@use-agently/sdk": "0.
|
|
101748
|
+
"@use-agently/sdk": "0.20.0",
|
|
101708
101749
|
boxen: "^8.0.1",
|
|
101709
101750
|
commander: "^14.0.3",
|
|
101710
101751
|
viem: "^2.46.3",
|
|
@@ -101723,7 +101764,8 @@ var package_default2 = {
|
|
|
101723
101764
|
|
|
101724
101765
|
// src/client.ts
|
|
101725
101766
|
var CLI_USER_AGENT = `use-agently:${package_default2.version} (use-agently.com)`;
|
|
101726
|
-
var
|
|
101767
|
+
var defaultClient = createClient4({ userAgent: CLI_USER_AGENT });
|
|
101768
|
+
var clientFetch2 = defaultClient.fetch;
|
|
101727
101769
|
|
|
101728
101770
|
class DryRunPaymentRequired2 extends DryRunPaymentRequired {
|
|
101729
101771
|
constructor(requirements) {
|
|
@@ -101769,41 +101811,50 @@ function formatUsdcAmount2(req) {
|
|
|
101769
101811
|
}
|
|
101770
101812
|
function handleDryRunError(err) {
|
|
101771
101813
|
const cliErr = err instanceof DryRunPaymentRequired2 ? err : new DryRunPaymentRequired2(err.requirements);
|
|
101772
|
-
|
|
101773
|
-
|
|
101774
|
-
|
|
101775
|
-
|
|
101776
|
-
|
|
101777
|
-
|
|
101814
|
+
if (process.stderr.isTTY) {
|
|
101815
|
+
console.error(boxen(cliErr.message, {
|
|
101816
|
+
title: "Payment Required",
|
|
101817
|
+
titleAlignment: "center",
|
|
101818
|
+
borderColor: "yellow",
|
|
101819
|
+
padding: 1
|
|
101820
|
+
}));
|
|
101821
|
+
} else {
|
|
101822
|
+
console.error(`Payment Required: ${cliErr.message}`);
|
|
101823
|
+
}
|
|
101778
101824
|
process.exit(1);
|
|
101779
101825
|
}
|
|
101780
101826
|
|
|
101781
101827
|
// src/commands/agents.ts
|
|
101782
101828
|
var agentsCommand = new Command("agents").description("List available agents on Agently").action(async (_options, command) => {
|
|
101783
|
-
const
|
|
101784
|
-
|
|
101829
|
+
const result = await search(defaultClient);
|
|
101830
|
+
outputCollection(command, result.hits.map(({ id, name, description, protocols }) => ({ id, name, description, protocols })));
|
|
101785
101831
|
});
|
|
101786
101832
|
|
|
101787
101833
|
// src/commands/search.ts
|
|
101788
|
-
var searchCommand = new Command("search").description("Search the Agently marketplace for agents").argument("[query]", "Search query to filter agents by name or description").option("-p, --protocol <protocols>", "Filter by protocol(s), comma-separated (e.g. a2a,mcp
|
|
101834
|
+
var searchCommand = new Command("search").description("Search the Agently marketplace for agents").argument("[query]", "Search query to filter agents by name or description").option("-p, --protocol <protocols>", "Filter by protocol(s), comma-separated (e.g. a2a,mcp)").showHelpAfterError(true).addHelpText("after", `
|
|
101789
101835
|
Examples:
|
|
101790
101836
|
use-agently search
|
|
101791
101837
|
use-agently search "echo"
|
|
101792
101838
|
use-agently search --protocol a2a
|
|
101793
101839
|
use-agently search "assistant" --protocol "a2a,mcp"`).action(async (query, options, command) => {
|
|
101794
|
-
const
|
|
101795
|
-
const
|
|
101796
|
-
|
|
101840
|
+
const protocol = options.protocol ? options.protocol.split(",").map((p) => p.trim().toLowerCase()) : undefined;
|
|
101841
|
+
const result = await search(defaultClient, { q: query, protocol });
|
|
101842
|
+
outputCollection(command, result.hits.map(({ id, name, description, protocols }) => ({ id, name, description, protocols })));
|
|
101797
101843
|
});
|
|
101798
101844
|
|
|
101799
|
-
// src/commands/
|
|
101800
|
-
|
|
101801
|
-
|
|
101802
|
-
|
|
101803
|
-
|
|
101845
|
+
// src/commands/view.ts
|
|
101846
|
+
var viewCommand = new Command("view").description("View an agent by its ID (e.g. CAIP-19)").argument("<id>", "Agent ID (e.g. eip155:8453/erc8004:0x1234/1)").showHelpAfterError(true).addHelpText("after", `
|
|
101847
|
+
Examples:
|
|
101848
|
+
use-agently view eip155:8453/erc8004:0x1234/1`).action(async (id, _options, command) => {
|
|
101849
|
+
const agent = await getAgent(defaultClient, id);
|
|
101850
|
+
if (!agent) {
|
|
101851
|
+
throw new Error(`No agent found for ID: ${id}
|
|
101852
|
+
Run 'use-agently search' to find available agents.`);
|
|
101804
101853
|
}
|
|
101805
|
-
|
|
101806
|
-
}
|
|
101854
|
+
output(command, agent);
|
|
101855
|
+
});
|
|
101856
|
+
|
|
101857
|
+
// src/commands/a2a.ts
|
|
101807
101858
|
async function resolveTransactionMode(pay) {
|
|
101808
101859
|
if (pay) {
|
|
101809
101860
|
const config2 = await getConfigOrThrow();
|
|
@@ -101815,15 +101866,15 @@ async function resolveTransactionMode(pay) {
|
|
|
101815
101866
|
var a2aCommand = new Command("a2a").description("Interact with agents via the A2A protocol").action(function() {
|
|
101816
101867
|
this.outputHelp();
|
|
101817
101868
|
});
|
|
101818
|
-
var a2aSendCommand = new Command("send").description("Send a message to an agent via A2A protocol").
|
|
101869
|
+
var a2aSendCommand = new Command("send").description("Send a message to an agent via A2A protocol").requiredOption("-u, --uri <value>", "Agent URL or CAIP-19 ID (e.g. https://example.com/agent or eip155:8453/erc8004:0x1234/1)").requiredOption("-m, --message <text>", "Message to send").option("--pay", "Authorize payment if the agent requires it (default: dry-run, shows cost only)").showHelpAfterError(true).addHelpText("after", `
|
|
101819
101870
|
Examples:
|
|
101820
101871
|
use-agently a2a send --uri https://example.com/agent -m "Hello!"
|
|
101821
|
-
use-agently a2a send --uri
|
|
101822
|
-
use-agently a2a send --uri
|
|
101823
|
-
const uri =
|
|
101872
|
+
use-agently a2a send --uri eip155:8453/erc8004:0x1234/1 -m "Hello!"
|
|
101873
|
+
use-agently a2a send --uri https://example.com/agent -m "Hello!" --pay`).action(async (options) => {
|
|
101874
|
+
const uri = options.uri;
|
|
101824
101875
|
const transaction = await resolveTransactionMode(options.pay);
|
|
101825
101876
|
try {
|
|
101826
|
-
const stream = await
|
|
101877
|
+
const stream = await sendMessageStream(defaultClient, uri, options.message, { mode: transaction });
|
|
101827
101878
|
let wroteText = false;
|
|
101828
101879
|
let lastResult = null;
|
|
101829
101880
|
for await (const event of stream) {
|
|
@@ -101846,25 +101897,18 @@ Examples:
|
|
|
101846
101897
|
throw err;
|
|
101847
101898
|
}
|
|
101848
101899
|
});
|
|
101849
|
-
var a2aCardSubCommand = new Command("card").description("Fetch and display the A2A agent card").
|
|
101900
|
+
var a2aCardSubCommand = new Command("card").description("Fetch and display the A2A agent card").requiredOption("-u, --uri <value>", "Agent URL or CAIP-19 ID (e.g. https://example.com/agent or eip155:8453/erc8004:0x1234/1)").showHelpAfterError(true).addHelpText("after", `
|
|
101850
101901
|
Examples:
|
|
101851
101902
|
use-agently a2a card --uri https://example.com/agent
|
|
101852
|
-
use-agently a2a card --uri
|
|
101853
|
-
const uri =
|
|
101854
|
-
const card = await
|
|
101903
|
+
use-agently a2a card --uri eip155:8453/erc8004:0x1234/1`).action(async (options, command) => {
|
|
101904
|
+
const uri = options.uri;
|
|
101905
|
+
const card = await getAgentCard(defaultClient, uri);
|
|
101855
101906
|
output(command, card);
|
|
101856
101907
|
});
|
|
101857
101908
|
a2aCommand.addCommand(a2aSendCommand);
|
|
101858
101909
|
a2aCommand.addCommand(a2aCardSubCommand);
|
|
101859
101910
|
|
|
101860
101911
|
// src/commands/mcp.ts
|
|
101861
|
-
function resolveUriOption2(options, commandName) {
|
|
101862
|
-
if (!options.uri) {
|
|
101863
|
-
throw new Error(`Missing required option --uri for '${commandName}'.
|
|
101864
|
-
Expected a URL or agent URI, e.g. --uri http://localhost:3000 or --uri my-agent`);
|
|
101865
|
-
}
|
|
101866
|
-
return options.uri;
|
|
101867
|
-
}
|
|
101868
101912
|
async function resolveTransactionMode2(pay) {
|
|
101869
101913
|
if (pay) {
|
|
101870
101914
|
const config2 = await getConfigOrThrow();
|
|
@@ -101876,35 +101920,34 @@ async function resolveTransactionMode2(pay) {
|
|
|
101876
101920
|
var mcpCommand = new Command("mcp").description("Connect to an MCP server and list or call tools").action(function() {
|
|
101877
101921
|
this.outputHelp();
|
|
101878
101922
|
});
|
|
101879
|
-
var mcpToolsCommand = new Command("tools").description("List available tools on an MCP server").
|
|
101923
|
+
var mcpToolsCommand = new Command("tools").description("List available tools on an MCP server").requiredOption("-u, --uri <value>", "MCP server URL or CAIP-19 ID").showHelpAfterError(true).addHelpText("after", `
|
|
101880
101924
|
Examples:
|
|
101881
|
-
use-agently mcp tools --uri
|
|
101882
|
-
use-agently mcp tools --uri
|
|
101883
|
-
const
|
|
101884
|
-
const tools = await listMcpTools(uri, {
|
|
101925
|
+
use-agently mcp tools --uri https://example.com/mcp
|
|
101926
|
+
use-agently mcp tools --uri eip155:8453/erc8004:0x1234/1`).action(async (options, command) => {
|
|
101927
|
+
const tools = await listMcpTools(defaultClient, options.uri, {
|
|
101885
101928
|
clientInfo: { name: "use-agently", version: package_default2.version },
|
|
101886
101929
|
fetchImpl: clientFetch2
|
|
101887
101930
|
});
|
|
101888
|
-
|
|
101931
|
+
outputCollection(command, tools);
|
|
101889
101932
|
});
|
|
101890
|
-
var mcpCallCommand = new Command("call").description("Call a specific tool on an MCP server").
|
|
101933
|
+
var mcpCallCommand = new Command("call").description("Call a specific tool on an MCP server").requiredOption("-u, --uri <value>", "MCP server URL or CAIP-19 ID").requiredOption("--tool <name>", "Tool name to call").option("--args <json>", "JSON arguments to pass to the tool").option("--pay", "Authorize payment if the tool requires it (default: dry-run, shows cost only)").showHelpAfterError(true).addHelpText("after", `
|
|
101891
101934
|
Examples:
|
|
101892
|
-
use-agently mcp call echo '{"message":"hello"}'
|
|
101893
|
-
use-agently mcp call
|
|
101894
|
-
|
|
101895
|
-
const
|
|
101935
|
+
use-agently mcp call --uri https://example.com/mcp --tool echo --args '{"message":"hello"}'
|
|
101936
|
+
use-agently mcp call --uri https://example.com/mcp --tool paid-tool --args '{"message":"hello"}' --pay`).action(async (options, command) => {
|
|
101937
|
+
const uri = options.uri;
|
|
101938
|
+
const tool = options.tool;
|
|
101896
101939
|
let args = {};
|
|
101897
|
-
if (
|
|
101940
|
+
if (options.args !== undefined) {
|
|
101898
101941
|
try {
|
|
101899
|
-
args = JSON.parse(
|
|
101942
|
+
args = JSON.parse(options.args);
|
|
101900
101943
|
} catch {
|
|
101901
|
-
throw new Error(`Invalid JSON in
|
|
101902
|
-
Expected a JSON object, e.g. '{"message":"hello"}'`);
|
|
101944
|
+
throw new Error(`Invalid JSON in --args: ${options.args}
|
|
101945
|
+
Expected a JSON object, e.g. --args '{"message":"hello"}'`);
|
|
101903
101946
|
}
|
|
101904
101947
|
}
|
|
101905
101948
|
const transaction = await resolveTransactionMode2(options.pay);
|
|
101906
101949
|
try {
|
|
101907
|
-
const result = await callMcpTool(uri, tool, args, {
|
|
101950
|
+
const result = await callMcpTool(defaultClient, uri, tool, args, {
|
|
101908
101951
|
transaction,
|
|
101909
101952
|
clientInfo: { name: "use-agently", version: package_default2.version },
|
|
101910
101953
|
fetchImpl: clientFetch2
|
|
@@ -101934,12 +101977,17 @@ Ensure your wallet has sufficient USDC balance and try again.`;
|
|
|
101934
101977
|
} else {
|
|
101935
101978
|
message = `Payment error: ${parsed.error}`;
|
|
101936
101979
|
}
|
|
101937
|
-
|
|
101938
|
-
|
|
101939
|
-
|
|
101940
|
-
|
|
101941
|
-
|
|
101942
|
-
|
|
101980
|
+
if (process.stderr.isTTY) {
|
|
101981
|
+
console.error(boxen(message, {
|
|
101982
|
+
title: parsed.error === "insufficient_funds" ? "Insufficient Funds" : "Payment Error",
|
|
101983
|
+
titleAlignment: "center",
|
|
101984
|
+
borderColor: "red",
|
|
101985
|
+
padding: 1
|
|
101986
|
+
}));
|
|
101987
|
+
} else {
|
|
101988
|
+
const title = parsed.error === "insufficient_funds" ? "Insufficient Funds" : "Payment Error";
|
|
101989
|
+
console.error(`${title}: ${message}`);
|
|
101990
|
+
}
|
|
101943
101991
|
process.exit(1);
|
|
101944
101992
|
}
|
|
101945
101993
|
} catch {}
|
|
@@ -101964,31 +102012,6 @@ Ensure your wallet has sufficient USDC balance and try again.`;
|
|
|
101964
102012
|
mcpCommand.addCommand(mcpToolsCommand);
|
|
101965
102013
|
mcpCommand.addCommand(mcpCallCommand);
|
|
101966
102014
|
|
|
101967
|
-
// src/commands/erc8004.ts
|
|
101968
|
-
function resolveUriOption3(options) {
|
|
101969
|
-
if (!options.uri) {
|
|
101970
|
-
throw new Error(`Missing required option --uri for 'erc-8004'.
|
|
101971
|
-
Expected an ERC-8004 agent URI, e.g. --uri eip155:8453/erc-8004:0x1234/1`);
|
|
101972
|
-
}
|
|
101973
|
-
return options.uri;
|
|
101974
|
-
}
|
|
101975
|
-
var erc8004Command = new Command("erc-8004").description("Resolve an ERC-8004 agent URI and display its details").option("--uri <value>", "ERC-8004 agent URI (e.g. eip155:8453/erc-8004:0x1234/1)").addHelpText("after", `
|
|
101976
|
-
Examples:
|
|
101977
|
-
use-agently erc-8004 --uri eip155:8453/erc-8004:0x1234/1
|
|
101978
|
-
use-agently erc-8004 --uri eip155:8453/erc-8004:0xAbCd/42`).action(async (options, command) => {
|
|
101979
|
-
const uri = resolveUriOption3(options);
|
|
101980
|
-
try {
|
|
101981
|
-
const agent = await resolveErc8004Agent(uri, clientFetch2);
|
|
101982
|
-
output(command, agent);
|
|
101983
|
-
} catch (err) {
|
|
101984
|
-
if (err instanceof AgentNotFoundError) {
|
|
101985
|
-
throw new Error(`No agent found for URI: ${uri}
|
|
101986
|
-
Run 'use-agently agents' to see available agent URIs.`);
|
|
101987
|
-
}
|
|
101988
|
-
throw err;
|
|
101989
|
-
}
|
|
101990
|
-
});
|
|
101991
|
-
|
|
101992
102015
|
// src/commands/web.ts
|
|
101993
102016
|
function collect(value, previous) {
|
|
101994
102017
|
return previous.concat([value]);
|
|
@@ -102154,7 +102177,7 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102154
102177
|
}
|
|
102155
102178
|
clearTimeout(timer);
|
|
102156
102179
|
console.log(`Response body written to ${options.outputFile} (HTTP ${response.status})`);
|
|
102157
|
-
if (!response.ok)
|
|
102180
|
+
if (options.fail && !response.ok)
|
|
102158
102181
|
process.exit(1);
|
|
102159
102182
|
return;
|
|
102160
102183
|
}
|
|
@@ -102172,7 +102195,7 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102172
102195
|
headers: responseHeaders,
|
|
102173
102196
|
body: responseBody
|
|
102174
102197
|
});
|
|
102175
|
-
if (!response.ok)
|
|
102198
|
+
if (options.fail && !response.ok)
|
|
102176
102199
|
process.exit(1);
|
|
102177
102200
|
return;
|
|
102178
102201
|
}
|
|
@@ -102185,12 +102208,12 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102185
102208
|
});
|
|
102186
102209
|
console.log(headerBlock + `
|
|
102187
102210
|
` + responseBody);
|
|
102188
|
-
if (!response.ok)
|
|
102211
|
+
if (options.fail && !response.ok)
|
|
102189
102212
|
process.exit(1);
|
|
102190
102213
|
return;
|
|
102191
102214
|
}
|
|
102192
102215
|
console.log(responseBody);
|
|
102193
|
-
if (!response.ok)
|
|
102216
|
+
if (options.fail && !response.ok)
|
|
102194
102217
|
process.exit(1);
|
|
102195
102218
|
} catch (err) {
|
|
102196
102219
|
clearTimeout(timer);
|
|
@@ -102204,7 +102227,7 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102204
102227
|
}
|
|
102205
102228
|
}
|
|
102206
102229
|
function addSharedOptions(cmd, hasBody) {
|
|
102207
|
-
cmd.option("-H, --header <value>", 'Request header, repeatable (e.g. "Content-Type: application/json")', collect, []).option("--output-file <path>", "Save response body to file").option("-L, --location", "Follow redirects").option("-v, --verbose", "Show request/response headers on stderr").option("-i, --include", "Include response status and headers in stdout output").option("--timeout <ms>", "Request timeout in milliseconds (default: 30000)").option("--max-filesize <bytes>", "Maximum response size in bytes (default: 104857600 / 100 MB)").option("--pay", "Authorize x402 payment (default: dry-run, shows cost only)");
|
|
102230
|
+
cmd.option("-H, --header <value>", 'Request header, repeatable (e.g. "Content-Type: application/json")', collect, []).option("--output-file <path>", "Save response body to file").option("-L, --location", "Follow redirects").option("-v, --verbose", "Show request/response headers on stderr").option("-i, --include", "Include response status and headers in stdout output").option("--timeout <ms>", "Request timeout in milliseconds (default: 30000)").option("--max-filesize <bytes>", "Maximum response size in bytes (default: 104857600 / 100 MB)").option("--pay", "Authorize x402 payment (default: dry-run, shows cost only)").option("--fail", "Exit with code 1 on HTTP error responses (4xx/5xx)");
|
|
102208
102231
|
if (hasBody) {
|
|
102209
102232
|
cmd.option("-d, --data <body>", "Request body (prefix @ to read from file, e.g. @body.json)").option("--data-raw <body>", "Request body sent as-is (@ is not treated as a file reference)");
|
|
102210
102233
|
}
|
|
@@ -102232,7 +102255,8 @@ webCommand.addCommand(createMethodSubcommand("patch", "Make an HTTP PATCH reques
|
|
|
102232
102255
|
webCommand.addCommand(createMethodSubcommand("delete", "Make an HTTP DELETE request", false));
|
|
102233
102256
|
|
|
102234
102257
|
// src/commands/doctor.ts
|
|
102235
|
-
var doctorCommand = new Command("doctor").description("Run environment checks and report any issues").option("--rpc <url>", "Custom RPC URL to use for network check").
|
|
102258
|
+
var doctorCommand = new Command("doctor").description("Run environment checks and report any issues").option("--rpc <url>", "Custom RPC URL to use for network check").showHelpAfterError(true).addHelpText("after", `
|
|
102259
|
+
Config: ~/.use-agently/config.json (global), .use-agently/config.json (local)`).action(async (options, command) => {
|
|
102236
102260
|
const checks3 = [];
|
|
102237
102261
|
const config2 = await loadConfig();
|
|
102238
102262
|
const hasWallet = !!config2?.wallet;
|
|
@@ -102344,7 +102368,7 @@ async function checkAutoUpdate() {
|
|
|
102344
102368
|
console.warn("Auto-update failed:", err instanceof Error ? err.message : String(err));
|
|
102345
102369
|
}
|
|
102346
102370
|
}
|
|
102347
|
-
var updateCommand = new Command("update").description("Update use-agently to the latest version").action(async (_options, command) => {
|
|
102371
|
+
var updateCommand = new Command("update").description("Update use-agently to the latest version").showHelpAfterError(true).action(async (_options, command) => {
|
|
102348
102372
|
try {
|
|
102349
102373
|
const result = await checkAndUpdate();
|
|
102350
102374
|
output(command, result);
|
|
@@ -102356,7 +102380,7 @@ var updateCommand = new Command("update").description("Update use-agently to the
|
|
|
102356
102380
|
|
|
102357
102381
|
// src/cli.ts
|
|
102358
102382
|
var cli = new Command;
|
|
102359
|
-
cli.name("use-agently").description("Agently is the way AI coordinate and transact. The routing and settlement layer for your agent economy.").version(package_default2.version).option("-o, --output <format>", "Output format (text, json)", "text").argument("[args...]").action((args) => {
|
|
102383
|
+
cli.name("use-agently").description("Agently is the way AI coordinate and transact. The routing and settlement layer for your agent economy.").version(package_default2.version).option("-o, --output <format>", "Output format (text, json)", process.stdout.isTTY ? "text" : "json").argument("[args...]").action((args) => {
|
|
102360
102384
|
if (args.length > 0) {
|
|
102361
102385
|
cli.unknownCommand();
|
|
102362
102386
|
return;
|
|
@@ -102368,9 +102392,9 @@ cli.addCommand(whoamiCommand.helpGroup("Diagnostics"));
|
|
|
102368
102392
|
cli.addCommand(balanceCommand.helpGroup("Diagnostics"));
|
|
102369
102393
|
cli.addCommand(agentsCommand.helpGroup("Discovery"));
|
|
102370
102394
|
cli.addCommand(searchCommand.helpGroup("Discovery"));
|
|
102395
|
+
cli.addCommand(viewCommand.helpGroup("Discovery"));
|
|
102371
102396
|
cli.addCommand(a2aCommand.helpGroup("Protocols"));
|
|
102372
102397
|
cli.addCommand(mcpCommand.helpGroup("Protocols"));
|
|
102373
|
-
cli.addCommand(erc8004Command.helpGroup("Protocols"));
|
|
102374
102398
|
cli.addCommand(webCommand.helpGroup("Protocols"));
|
|
102375
102399
|
cli.addCommand(initCommand.helpGroup("Lifecycle"));
|
|
102376
102400
|
cli.addCommand(updateCommand.helpGroup("Lifecycle"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-agently",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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.20.0",
|
|
28
28
|
"boxen": "^8.0.1",
|
|
29
29
|
"commander": "^14.0.3",
|
|
30
30
|
"viem": "^2.46.3",
|