use-agently 0.18.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 +394 -303
- 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 = {};
|
|
@@ -86858,6 +86867,67 @@ var basePreconf = /* @__PURE__ */ defineChain3({
|
|
|
86858
86867
|
}
|
|
86859
86868
|
}
|
|
86860
86869
|
});
|
|
86870
|
+
// ../../node_modules/.bun/viem@2.46.3+c613ea43c0af028c/node_modules/viem/_esm/chains/definitions/baseSepolia.js
|
|
86871
|
+
var sourceId2 = 11155111;
|
|
86872
|
+
var baseSepolia = /* @__PURE__ */ defineChain3({
|
|
86873
|
+
...chainConfig,
|
|
86874
|
+
id: 84532,
|
|
86875
|
+
network: "base-sepolia",
|
|
86876
|
+
name: "Base Sepolia",
|
|
86877
|
+
nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 },
|
|
86878
|
+
rpcUrls: {
|
|
86879
|
+
default: {
|
|
86880
|
+
http: ["https://sepolia.base.org"]
|
|
86881
|
+
}
|
|
86882
|
+
},
|
|
86883
|
+
blockExplorers: {
|
|
86884
|
+
default: {
|
|
86885
|
+
name: "Basescan",
|
|
86886
|
+
url: "https://sepolia.basescan.org",
|
|
86887
|
+
apiUrl: "https://api-sepolia.basescan.org/api"
|
|
86888
|
+
}
|
|
86889
|
+
},
|
|
86890
|
+
contracts: {
|
|
86891
|
+
...chainConfig.contracts,
|
|
86892
|
+
disputeGameFactory: {
|
|
86893
|
+
[sourceId2]: {
|
|
86894
|
+
address: "0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"
|
|
86895
|
+
}
|
|
86896
|
+
},
|
|
86897
|
+
l2OutputOracle: {
|
|
86898
|
+
[sourceId2]: {
|
|
86899
|
+
address: "0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"
|
|
86900
|
+
}
|
|
86901
|
+
},
|
|
86902
|
+
portal: {
|
|
86903
|
+
[sourceId2]: {
|
|
86904
|
+
address: "0x49f53e41452c74589e85ca1677426ba426459e85",
|
|
86905
|
+
blockCreated: 4446677
|
|
86906
|
+
}
|
|
86907
|
+
},
|
|
86908
|
+
l1StandardBridge: {
|
|
86909
|
+
[sourceId2]: {
|
|
86910
|
+
address: "0xfd0Bf71F60660E2f608ed56e1659C450eB113120",
|
|
86911
|
+
blockCreated: 4446677
|
|
86912
|
+
}
|
|
86913
|
+
},
|
|
86914
|
+
multicall3: {
|
|
86915
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
86916
|
+
blockCreated: 1059647
|
|
86917
|
+
}
|
|
86918
|
+
},
|
|
86919
|
+
testnet: true,
|
|
86920
|
+
sourceId: sourceId2
|
|
86921
|
+
});
|
|
86922
|
+
var baseSepoliaPreconf = /* @__PURE__ */ defineChain3({
|
|
86923
|
+
...baseSepolia,
|
|
86924
|
+
experimental_preconfirmationTime: 200,
|
|
86925
|
+
rpcUrls: {
|
|
86926
|
+
default: {
|
|
86927
|
+
http: ["https://sepolia-preconf.base.org"]
|
|
86928
|
+
}
|
|
86929
|
+
}
|
|
86930
|
+
});
|
|
86861
86931
|
// ../../node_modules/.bun/viem@2.46.3+a78afc2fa6b43151/node_modules/viem/_esm/constants/number.js
|
|
86862
86932
|
var maxInt84 = 2n ** (8n - 1n) - 1n;
|
|
86863
86933
|
var maxInt164 = 2n ** (16n - 1n) - 1n;
|
|
@@ -92634,13 +92704,19 @@ class EvmPrivateKeyWallet {
|
|
|
92634
92704
|
}
|
|
92635
92705
|
getX402Schemes() {
|
|
92636
92706
|
const account = privateKeyToAccount(this.privateKey);
|
|
92637
|
-
const
|
|
92638
|
-
const
|
|
92639
|
-
const
|
|
92707
|
+
const customTransport = this.rpcUrl ? http(this.rpcUrl) : http();
|
|
92708
|
+
const baseClient = createPublicClient({ chain: base, transport: customTransport });
|
|
92709
|
+
const baseSigner = toClientEvmSigner(account, baseClient);
|
|
92710
|
+
const baseSepoliaClient = createPublicClient({ chain: baseSepolia, transport: customTransport });
|
|
92711
|
+
const baseSepoliaSigner = toClientEvmSigner(account, baseSepoliaClient);
|
|
92640
92712
|
return [
|
|
92641
92713
|
{
|
|
92642
|
-
network: "eip155
|
|
92643
|
-
client: new ExactEvmScheme(
|
|
92714
|
+
network: "eip155:8453",
|
|
92715
|
+
client: new ExactEvmScheme(baseSigner)
|
|
92716
|
+
},
|
|
92717
|
+
{
|
|
92718
|
+
network: "eip155:84532",
|
|
92719
|
+
client: new ExactEvmScheme(baseSepoliaSigner)
|
|
92644
92720
|
}
|
|
92645
92721
|
];
|
|
92646
92722
|
}
|
|
@@ -95611,6 +95687,152 @@ function wrapMCPClientWithPaymentFromConfig(mcpClient, config2, options) {
|
|
|
95611
95687
|
return new x402MCPClient(mcpClient, paymentClient, options);
|
|
95612
95688
|
}
|
|
95613
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
|
+
|
|
95614
95836
|
// ../../node_modules/.bun/@a2a-js+sdk@0.3.10+81e50683f7a708c7/node_modules/@a2a-js/sdk/dist/chunk-WMQQYH7W.js
|
|
95615
95837
|
async function* parseSseStream(response) {
|
|
95616
95838
|
if (!response.body) {
|
|
@@ -98457,198 +98679,49 @@ var CaseInsensitiveMap = class extends Map {
|
|
|
98457
98679
|
}
|
|
98458
98680
|
};
|
|
98459
98681
|
|
|
98460
|
-
// ../use-agently-sdk/
|
|
98461
|
-
var
|
|
98462
|
-
function
|
|
98463
|
-
|
|
98464
|
-
|
|
98465
|
-
|
|
98466
|
-
|
|
98467
|
-
|
|
98468
|
-
|
|
98469
|
-
description: "Core SDK for the Agently platform — wallet management, A2A, MCP, x402 payments",
|
|
98470
|
-
homepage: "https://github.com/AgentlyHQ/use-agently/tree/main/packages/use-agently-sdk",
|
|
98471
|
-
bugs: {
|
|
98472
|
-
url: "https://github.com/AgentlyHQ/use-agently/issues"
|
|
98473
|
-
},
|
|
98474
|
-
repository: {
|
|
98475
|
-
type: "git",
|
|
98476
|
-
url: "git+https://github.com/AgentlyHQ/use-agently.git",
|
|
98477
|
-
directory: "packages/use-agently-sdk"
|
|
98478
|
-
},
|
|
98479
|
-
license: "MIT",
|
|
98480
|
-
author: "AgentlyHQ",
|
|
98481
|
-
type: "module",
|
|
98482
|
-
files: [
|
|
98483
|
-
"**/*.ts",
|
|
98484
|
-
"!**/*.test.ts",
|
|
98485
|
-
"README.md"
|
|
98486
|
-
],
|
|
98487
|
-
scripts: {
|
|
98488
|
-
test: "bun test"
|
|
98489
|
-
},
|
|
98490
|
-
dependencies: {
|
|
98491
|
-
"@a2a-js/sdk": "^0.3.10",
|
|
98492
|
-
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
98493
|
-
"@x402/evm": "^2.5.0",
|
|
98494
|
-
"@x402/fetch": "^2.5.0",
|
|
98495
|
-
"@x402/mcp": "^2.5.0",
|
|
98496
|
-
viem: "^2.46.3",
|
|
98497
|
-
zod: "^4"
|
|
98498
|
-
},
|
|
98499
|
-
devDependencies: {
|
|
98500
|
-
"@types/bun": "^1.3.9",
|
|
98501
|
-
"localhost-aixyz": "^0",
|
|
98502
|
-
testcontainers: "^11",
|
|
98503
|
-
"x402-fl": "^0"
|
|
98504
|
-
},
|
|
98505
|
-
engines: {
|
|
98506
|
-
node: ">=20"
|
|
98507
|
-
}
|
|
98508
|
-
};
|
|
98509
|
-
|
|
98510
|
-
// ../use-agently-sdk/client.ts
|
|
98511
|
-
var USER_AGENT = `@use-agently/sdk:${package_default.version} (use-agently.com)`;
|
|
98512
|
-
function createClientFetch(userAgent = USER_AGENT) {
|
|
98513
|
-
return (input, init) => {
|
|
98514
|
-
const isRequest = input instanceof Request;
|
|
98515
|
-
const headers = new Headers(isRequest ? input.headers : init?.headers);
|
|
98516
|
-
if (isRequest && init?.headers) {
|
|
98517
|
-
for (const [key, value] of new Headers(init.headers).entries()) {
|
|
98518
|
-
headers.set(key, value);
|
|
98519
|
-
}
|
|
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);
|
|
98520
98691
|
}
|
|
98521
|
-
if (!headers.has("User-Agent")) {
|
|
98522
|
-
headers.set("User-Agent", userAgent);
|
|
98523
|
-
}
|
|
98524
|
-
return fetch(input, { ...init, headers });
|
|
98525
|
-
};
|
|
98526
|
-
}
|
|
98527
|
-
var clientFetch = createClientFetch();
|
|
98528
|
-
function formatUsdcAmount(req) {
|
|
98529
|
-
try {
|
|
98530
|
-
const { usdcDecimals } = getChainConfigByNetwork(req.network);
|
|
98531
|
-
const raw = formatUnits(BigInt(req.amount), usdcDecimals);
|
|
98532
|
-
const formatted = raw.includes(".") ? raw.replace(/\.?0+$/, "") : raw;
|
|
98533
|
-
const network = req.network ? ` on ${req.network}` : "";
|
|
98534
|
-
return `$${formatted} USDC${network}`;
|
|
98535
|
-
} catch {
|
|
98536
|
-
return `${req.amount} (raw units)`;
|
|
98537
98692
|
}
|
|
98538
|
-
|
|
98539
|
-
|
|
98540
|
-
|
|
98541
|
-
requirements;
|
|
98542
|
-
constructor(requirements) {
|
|
98543
|
-
const req = requirements[0];
|
|
98544
|
-
const amount = req ? formatUsdcAmount(req) : null;
|
|
98545
|
-
const payLine = amount ? `This request requires payment of ${amount}.
|
|
98546
|
-
Use createPaymentFetch() instead of createDryRunFetch() to authorize the transaction.` : `This request requires payment, but the amount could not be determined.
|
|
98547
|
-
Inspect the endpoint manually or use createPaymentFetch() to authorize payment.`;
|
|
98548
|
-
super(payLine);
|
|
98549
|
-
this.name = "DryRunPaymentRequired";
|
|
98550
|
-
this.requirements = requirements;
|
|
98551
|
-
}
|
|
98552
|
-
}
|
|
98553
|
-
function createDryRunFetch(fetchImpl = clientFetch) {
|
|
98554
|
-
return async (input, init) => {
|
|
98555
|
-
const response = await fetchImpl(input, init);
|
|
98556
|
-
if (response.status === 402) {
|
|
98557
|
-
let requirements = [];
|
|
98558
|
-
const header = response.headers.get("PAYMENT-REQUIRED");
|
|
98559
|
-
if (header) {
|
|
98560
|
-
try {
|
|
98561
|
-
const decoded = JSON.parse(Buffer.from(header, "base64").toString("utf-8"));
|
|
98562
|
-
requirements = decoded.accepts ?? [];
|
|
98563
|
-
} catch (e) {
|
|
98564
|
-
if (!(e instanceof SyntaxError))
|
|
98565
|
-
throw e;
|
|
98566
|
-
}
|
|
98567
|
-
} else {
|
|
98568
|
-
try {
|
|
98569
|
-
const body = await response.clone().json();
|
|
98570
|
-
if (body?.accepts) {
|
|
98571
|
-
requirements = body.accepts;
|
|
98572
|
-
}
|
|
98573
|
-
} catch (e) {
|
|
98574
|
-
if (!(e instanceof SyntaxError))
|
|
98575
|
-
throw e;
|
|
98576
|
-
}
|
|
98577
|
-
}
|
|
98578
|
-
throw new DryRunPaymentRequired(requirements);
|
|
98693
|
+
if (options?.protocol) {
|
|
98694
|
+
for (const proto of options.protocol) {
|
|
98695
|
+
url2.searchParams.append("protocol", proto);
|
|
98579
98696
|
}
|
|
98580
|
-
return response;
|
|
98581
|
-
};
|
|
98582
|
-
}
|
|
98583
|
-
function resolveFetchForTransaction(transaction = DryRunTransaction, fetchImpl) {
|
|
98584
|
-
if (transaction.mode === "dry-run")
|
|
98585
|
-
return createDryRunFetch(fetchImpl);
|
|
98586
|
-
return createPaymentFetch(transaction.wallet, fetchImpl);
|
|
98587
|
-
}
|
|
98588
|
-
function createPaymentFetch(wallet, fetchImpl = clientFetch) {
|
|
98589
|
-
return wrapFetchWithPaymentFromConfig(fetchImpl, {
|
|
98590
|
-
schemes: wallet.getX402Schemes()
|
|
98591
|
-
});
|
|
98592
|
-
}
|
|
98593
|
-
function createMcpPaymentClient(mcpClient, wallet) {
|
|
98594
|
-
return wrapMCPClientWithPaymentFromConfig(mcpClient, {
|
|
98595
|
-
schemes: wallet.getX402Schemes()
|
|
98596
|
-
});
|
|
98597
|
-
}
|
|
98598
|
-
async function createA2AClient(agentUrl, fetchImpl) {
|
|
98599
|
-
const factory = new ClientFactory({
|
|
98600
|
-
transports: [new JsonRpcTransportFactory({ fetchImpl }), new RestTransportFactory({ fetchImpl })]
|
|
98601
|
-
});
|
|
98602
|
-
return factory.createFromUrl(agentUrl);
|
|
98603
|
-
}
|
|
98604
|
-
// ../use-agently-sdk/marketplace.ts
|
|
98605
|
-
var MARKETPLACE_URL = "https://use-agently.com/marketplace.json";
|
|
98606
|
-
|
|
98607
|
-
class AgentNotFoundError extends Error {
|
|
98608
|
-
uri;
|
|
98609
|
-
constructor(uri) {
|
|
98610
|
-
super(`No agent found for URI: ${uri}`);
|
|
98611
|
-
this.uri = uri;
|
|
98612
|
-
this.name = "AgentNotFoundError";
|
|
98613
98697
|
}
|
|
98614
|
-
|
|
98615
|
-
|
|
98616
|
-
|
|
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);
|
|
98617
98703
|
if (!response.ok) {
|
|
98618
|
-
throw new Error(`
|
|
98704
|
+
throw new Error(`Agently search failed: ${response.status} ${response.statusText}`);
|
|
98619
98705
|
}
|
|
98620
|
-
|
|
98621
|
-
return data.agents ?? [];
|
|
98706
|
+
return response.json();
|
|
98622
98707
|
}
|
|
98623
|
-
async function
|
|
98624
|
-
|
|
98625
|
-
|
|
98626
|
-
|
|
98627
|
-
|
|
98628
|
-
|
|
98629
|
-
if (options.protocols) {
|
|
98630
|
-
const protocols = options.protocols.map((p) => p.trim().toLowerCase());
|
|
98631
|
-
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;
|
|
98632
98714
|
}
|
|
98633
|
-
|
|
98634
|
-
}
|
|
98635
|
-
async function resolveErc8004Agent(uri, fetchImpl = clientFetch) {
|
|
98636
|
-
const agents = await fetchAgents(fetchImpl);
|
|
98637
|
-
const agent = agents.find((a) => a.uri === uri);
|
|
98638
|
-
if (!agent) {
|
|
98639
|
-
throw new AgentNotFoundError(uri);
|
|
98715
|
+
if (!response.ok) {
|
|
98716
|
+
throw new Error(`Agently lookup failed: ${response.status} ${response.statusText}`);
|
|
98640
98717
|
}
|
|
98641
|
-
return
|
|
98718
|
+
return response.json();
|
|
98642
98719
|
}
|
|
98720
|
+
|
|
98643
98721
|
// ../use-agently-sdk/a2a.ts
|
|
98644
|
-
import { randomUUID } from "node:crypto";
|
|
98645
98722
|
function extractTextFromParts(parts) {
|
|
98646
98723
|
return parts.filter((p) => p.kind === "text").map((p) => p.text).join("");
|
|
98647
98724
|
}
|
|
98648
|
-
function resolveAgentUrl(agentInput) {
|
|
98649
|
-
const isDirectUrl = agentInput.startsWith("http://") || agentInput.startsWith("https://");
|
|
98650
|
-
return isDirectUrl ? agentInput : `https://use-agently.com/${agentInput}/`;
|
|
98651
|
-
}
|
|
98652
98725
|
function extractAgentText(result) {
|
|
98653
98726
|
if (!result) {
|
|
98654
98727
|
return "The agent processed your request but returned no response.";
|
|
@@ -98681,11 +98754,17 @@ function extractStreamEventText(event) {
|
|
|
98681
98754
|
}
|
|
98682
98755
|
return "";
|
|
98683
98756
|
}
|
|
98684
|
-
async function
|
|
98685
|
-
const
|
|
98686
|
-
const
|
|
98687
|
-
|
|
98688
|
-
|
|
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({
|
|
98689
98768
|
message: {
|
|
98690
98769
|
kind: "message",
|
|
98691
98770
|
messageId: randomUUID(),
|
|
@@ -98694,10 +98773,32 @@ async function sendA2AMessageStream(uri, message, options) {
|
|
|
98694
98773
|
}
|
|
98695
98774
|
});
|
|
98696
98775
|
}
|
|
98697
|
-
async function
|
|
98698
|
-
const
|
|
98699
|
-
const
|
|
98700
|
-
|
|
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;
|
|
98701
98802
|
}
|
|
98702
98803
|
// ../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
98703
98804
|
function normalizeHeaders(headers) {
|
|
@@ -100053,14 +100154,19 @@ class StreamableHTTPClientTransport {
|
|
|
100053
100154
|
}
|
|
100054
100155
|
|
|
100055
100156
|
// ../use-agently-sdk/mcp.ts
|
|
100056
|
-
function
|
|
100057
|
-
|
|
100058
|
-
|
|
100059
|
-
|
|
100060
|
-
|
|
100061
|
-
|
|
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);
|
|
100062
100168
|
}
|
|
100063
|
-
return
|
|
100169
|
+
return new URL(input);
|
|
100064
100170
|
}
|
|
100065
100171
|
async function createMcpClient(mcpUrl, options) {
|
|
100066
100172
|
const client = new Client(options?.clientInfo ?? { name: "@use-agently/sdk", version: package_default.version });
|
|
@@ -100073,8 +100179,8 @@ async function createMcpClient(mcpUrl, options) {
|
|
|
100073
100179
|
await client.connect(transport);
|
|
100074
100180
|
return client;
|
|
100075
100181
|
}
|
|
100076
|
-
async function listMcpTools(uri, options) {
|
|
100077
|
-
const mcpUrl =
|
|
100182
|
+
async function listMcpTools(sdkClient, uri, options) {
|
|
100183
|
+
const mcpUrl = await (await getMcpURL(sdkClient, uri)).toString();
|
|
100078
100184
|
const resolvedFetch = resolveFetchForTransaction(options?.transaction, options?.fetchImpl);
|
|
100079
100185
|
const client = await createMcpClient(mcpUrl, { clientInfo: options?.clientInfo, fetchImpl: resolvedFetch });
|
|
100080
100186
|
try {
|
|
@@ -100084,8 +100190,8 @@ async function listMcpTools(uri, options) {
|
|
|
100084
100190
|
await client.close();
|
|
100085
100191
|
}
|
|
100086
100192
|
}
|
|
100087
|
-
async function callMcpTool(uri, tool, args, options) {
|
|
100088
|
-
const mcpUrl =
|
|
100193
|
+
async function callMcpTool(sdkClient, uri, tool, args, options) {
|
|
100194
|
+
const mcpUrl = await (await getMcpURL(sdkClient, uri)).toString();
|
|
100089
100195
|
const transaction = options?.transaction ?? DryRunTransaction;
|
|
100090
100196
|
const resolvedFetch = resolveFetchForTransaction(transaction, options?.fetchImpl);
|
|
100091
100197
|
if (transaction.mode === "pay") {
|
|
@@ -100210,13 +100316,14 @@ async function backupConfig(scope = "global") {
|
|
|
100210
100316
|
async function getConfigOrThrow() {
|
|
100211
100317
|
const config2 = await loadConfig();
|
|
100212
100318
|
if (!config2?.wallet) {
|
|
100213
|
-
throw new Error("No wallet configured.
|
|
100319
|
+
throw new Error("No wallet configured. Run 'use-agently init' to create one.");
|
|
100214
100320
|
}
|
|
100215
100321
|
return config2;
|
|
100216
100322
|
}
|
|
100217
100323
|
|
|
100218
100324
|
// src/commands/init.ts
|
|
100219
|
-
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) => {
|
|
100220
100327
|
const scope = options.local ? "local" : "global";
|
|
100221
100328
|
const existing = await loadConfig(scope);
|
|
100222
100329
|
if (existing?.wallet) {
|
|
@@ -100224,7 +100331,8 @@ var initCommand = new Command("init").description("Generate a new local wallet a
|
|
|
100224
100331
|
console.error("Wallet already configured. Use --regenerate to create a new wallet.");
|
|
100225
100332
|
process.exit(1);
|
|
100226
100333
|
}
|
|
100227
|
-
await backupConfig(scope);
|
|
100334
|
+
const backupPath = await backupConfig(scope);
|
|
100335
|
+
console.error(`Previous config backed up to ${backupPath}`);
|
|
100228
100336
|
}
|
|
100229
100337
|
const walletConfig = generateEvmPrivateKeyConfig();
|
|
100230
100338
|
await saveConfig({ wallet: walletConfig }, scope);
|
|
@@ -100235,7 +100343,7 @@ var initCommand = new Command("init").description("Generate a new local wallet a
|
|
|
100235
100343
|
});
|
|
100236
100344
|
|
|
100237
100345
|
// src/commands/whoami.ts
|
|
100238
|
-
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) => {
|
|
100239
100347
|
const config2 = await getConfigOrThrow();
|
|
100240
100348
|
const wallet = loadWallet(config2.wallet);
|
|
100241
100349
|
output(command, {
|
|
@@ -100245,7 +100353,7 @@ var whoamiCommand = new Command("whoami").description("Show current wallet info"
|
|
|
100245
100353
|
});
|
|
100246
100354
|
|
|
100247
100355
|
// src/commands/balance.ts
|
|
100248
|
-
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) => {
|
|
100249
100357
|
const config2 = await getConfigOrThrow();
|
|
100250
100358
|
const wallet = loadWallet(config2.wallet);
|
|
100251
100359
|
const result = await getBalance2(wallet.address, { rpc: options.rpc });
|
|
@@ -101613,7 +101721,7 @@ function boxen(text, options) {
|
|
|
101613
101721
|
// package.json
|
|
101614
101722
|
var package_default2 = {
|
|
101615
101723
|
name: "use-agently",
|
|
101616
|
-
version: "0.
|
|
101724
|
+
version: "0.20.0",
|
|
101617
101725
|
description: "Use Agently CLI",
|
|
101618
101726
|
homepage: "https://use-agently.com",
|
|
101619
101727
|
bugs: "https://github.com/AgentlyHQ/use-agently/issues",
|
|
@@ -101637,7 +101745,7 @@ var package_default2 = {
|
|
|
101637
101745
|
test: "bun test"
|
|
101638
101746
|
},
|
|
101639
101747
|
dependencies: {
|
|
101640
|
-
"@use-agently/sdk": "0.
|
|
101748
|
+
"@use-agently/sdk": "0.20.0",
|
|
101641
101749
|
boxen: "^8.0.1",
|
|
101642
101750
|
commander: "^14.0.3",
|
|
101643
101751
|
viem: "^2.46.3",
|
|
@@ -101656,7 +101764,8 @@ var package_default2 = {
|
|
|
101656
101764
|
|
|
101657
101765
|
// src/client.ts
|
|
101658
101766
|
var CLI_USER_AGENT = `use-agently:${package_default2.version} (use-agently.com)`;
|
|
101659
|
-
var
|
|
101767
|
+
var defaultClient = createClient4({ userAgent: CLI_USER_AGENT });
|
|
101768
|
+
var clientFetch2 = defaultClient.fetch;
|
|
101660
101769
|
|
|
101661
101770
|
class DryRunPaymentRequired2 extends DryRunPaymentRequired {
|
|
101662
101771
|
constructor(requirements) {
|
|
@@ -101702,41 +101811,50 @@ function formatUsdcAmount2(req) {
|
|
|
101702
101811
|
}
|
|
101703
101812
|
function handleDryRunError(err) {
|
|
101704
101813
|
const cliErr = err instanceof DryRunPaymentRequired2 ? err : new DryRunPaymentRequired2(err.requirements);
|
|
101705
|
-
|
|
101706
|
-
|
|
101707
|
-
|
|
101708
|
-
|
|
101709
|
-
|
|
101710
|
-
|
|
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
|
+
}
|
|
101711
101824
|
process.exit(1);
|
|
101712
101825
|
}
|
|
101713
101826
|
|
|
101714
101827
|
// src/commands/agents.ts
|
|
101715
101828
|
var agentsCommand = new Command("agents").description("List available agents on Agently").action(async (_options, command) => {
|
|
101716
|
-
const
|
|
101717
|
-
|
|
101829
|
+
const result = await search(defaultClient);
|
|
101830
|
+
outputCollection(command, result.hits.map(({ id, name, description, protocols }) => ({ id, name, description, protocols })));
|
|
101718
101831
|
});
|
|
101719
101832
|
|
|
101720
101833
|
// src/commands/search.ts
|
|
101721
|
-
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", `
|
|
101722
101835
|
Examples:
|
|
101723
101836
|
use-agently search
|
|
101724
101837
|
use-agently search "echo"
|
|
101725
101838
|
use-agently search --protocol a2a
|
|
101726
101839
|
use-agently search "assistant" --protocol "a2a,mcp"`).action(async (query, options, command) => {
|
|
101727
|
-
const
|
|
101728
|
-
const
|
|
101729
|
-
|
|
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 })));
|
|
101730
101843
|
});
|
|
101731
101844
|
|
|
101732
|
-
// src/commands/
|
|
101733
|
-
|
|
101734
|
-
|
|
101735
|
-
|
|
101736
|
-
|
|
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.`);
|
|
101737
101853
|
}
|
|
101738
|
-
|
|
101739
|
-
}
|
|
101854
|
+
output(command, agent);
|
|
101855
|
+
});
|
|
101856
|
+
|
|
101857
|
+
// src/commands/a2a.ts
|
|
101740
101858
|
async function resolveTransactionMode(pay) {
|
|
101741
101859
|
if (pay) {
|
|
101742
101860
|
const config2 = await getConfigOrThrow();
|
|
@@ -101748,15 +101866,15 @@ async function resolveTransactionMode(pay) {
|
|
|
101748
101866
|
var a2aCommand = new Command("a2a").description("Interact with agents via the A2A protocol").action(function() {
|
|
101749
101867
|
this.outputHelp();
|
|
101750
101868
|
});
|
|
101751
|
-
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", `
|
|
101752
101870
|
Examples:
|
|
101753
101871
|
use-agently a2a send --uri https://example.com/agent -m "Hello!"
|
|
101754
|
-
use-agently a2a send --uri
|
|
101755
|
-
use-agently a2a send --uri
|
|
101756
|
-
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;
|
|
101757
101875
|
const transaction = await resolveTransactionMode(options.pay);
|
|
101758
101876
|
try {
|
|
101759
|
-
const stream = await
|
|
101877
|
+
const stream = await sendMessageStream(defaultClient, uri, options.message, { mode: transaction });
|
|
101760
101878
|
let wroteText = false;
|
|
101761
101879
|
let lastResult = null;
|
|
101762
101880
|
for await (const event of stream) {
|
|
@@ -101779,25 +101897,18 @@ Examples:
|
|
|
101779
101897
|
throw err;
|
|
101780
101898
|
}
|
|
101781
101899
|
});
|
|
101782
|
-
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", `
|
|
101783
101901
|
Examples:
|
|
101784
101902
|
use-agently a2a card --uri https://example.com/agent
|
|
101785
|
-
use-agently a2a card --uri
|
|
101786
|
-
const uri =
|
|
101787
|
-
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);
|
|
101788
101906
|
output(command, card);
|
|
101789
101907
|
});
|
|
101790
101908
|
a2aCommand.addCommand(a2aSendCommand);
|
|
101791
101909
|
a2aCommand.addCommand(a2aCardSubCommand);
|
|
101792
101910
|
|
|
101793
101911
|
// src/commands/mcp.ts
|
|
101794
|
-
function resolveUriOption2(options, commandName) {
|
|
101795
|
-
if (!options.uri) {
|
|
101796
|
-
throw new Error(`Missing required option --uri for '${commandName}'.
|
|
101797
|
-
Expected a URL or agent URI, e.g. --uri http://localhost:3000 or --uri my-agent`);
|
|
101798
|
-
}
|
|
101799
|
-
return options.uri;
|
|
101800
|
-
}
|
|
101801
101912
|
async function resolveTransactionMode2(pay) {
|
|
101802
101913
|
if (pay) {
|
|
101803
101914
|
const config2 = await getConfigOrThrow();
|
|
@@ -101809,35 +101920,34 @@ async function resolveTransactionMode2(pay) {
|
|
|
101809
101920
|
var mcpCommand = new Command("mcp").description("Connect to an MCP server and list or call tools").action(function() {
|
|
101810
101921
|
this.outputHelp();
|
|
101811
101922
|
});
|
|
101812
|
-
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", `
|
|
101813
101924
|
Examples:
|
|
101814
|
-
use-agently mcp tools --uri
|
|
101815
|
-
use-agently mcp tools --uri
|
|
101816
|
-
const
|
|
101817
|
-
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, {
|
|
101818
101928
|
clientInfo: { name: "use-agently", version: package_default2.version },
|
|
101819
101929
|
fetchImpl: clientFetch2
|
|
101820
101930
|
});
|
|
101821
|
-
|
|
101931
|
+
outputCollection(command, tools);
|
|
101822
101932
|
});
|
|
101823
|
-
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", `
|
|
101824
101934
|
Examples:
|
|
101825
|
-
use-agently mcp call echo '{"message":"hello"}'
|
|
101826
|
-
use-agently mcp call
|
|
101827
|
-
|
|
101828
|
-
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;
|
|
101829
101939
|
let args = {};
|
|
101830
|
-
if (
|
|
101940
|
+
if (options.args !== undefined) {
|
|
101831
101941
|
try {
|
|
101832
|
-
args = JSON.parse(
|
|
101942
|
+
args = JSON.parse(options.args);
|
|
101833
101943
|
} catch {
|
|
101834
|
-
throw new Error(`Invalid JSON in
|
|
101835
|
-
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"}'`);
|
|
101836
101946
|
}
|
|
101837
101947
|
}
|
|
101838
101948
|
const transaction = await resolveTransactionMode2(options.pay);
|
|
101839
101949
|
try {
|
|
101840
|
-
const result = await callMcpTool(uri, tool, args, {
|
|
101950
|
+
const result = await callMcpTool(defaultClient, uri, tool, args, {
|
|
101841
101951
|
transaction,
|
|
101842
101952
|
clientInfo: { name: "use-agently", version: package_default2.version },
|
|
101843
101953
|
fetchImpl: clientFetch2
|
|
@@ -101867,12 +101977,17 @@ Ensure your wallet has sufficient USDC balance and try again.`;
|
|
|
101867
101977
|
} else {
|
|
101868
101978
|
message = `Payment error: ${parsed.error}`;
|
|
101869
101979
|
}
|
|
101870
|
-
|
|
101871
|
-
|
|
101872
|
-
|
|
101873
|
-
|
|
101874
|
-
|
|
101875
|
-
|
|
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
|
+
}
|
|
101876
101991
|
process.exit(1);
|
|
101877
101992
|
}
|
|
101878
101993
|
} catch {}
|
|
@@ -101897,31 +102012,6 @@ Ensure your wallet has sufficient USDC balance and try again.`;
|
|
|
101897
102012
|
mcpCommand.addCommand(mcpToolsCommand);
|
|
101898
102013
|
mcpCommand.addCommand(mcpCallCommand);
|
|
101899
102014
|
|
|
101900
|
-
// src/commands/erc8004.ts
|
|
101901
|
-
function resolveUriOption3(options) {
|
|
101902
|
-
if (!options.uri) {
|
|
101903
|
-
throw new Error(`Missing required option --uri for 'erc-8004'.
|
|
101904
|
-
Expected an ERC-8004 agent URI, e.g. --uri eip155:8453/erc-8004:0x1234/1`);
|
|
101905
|
-
}
|
|
101906
|
-
return options.uri;
|
|
101907
|
-
}
|
|
101908
|
-
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", `
|
|
101909
|
-
Examples:
|
|
101910
|
-
use-agently erc-8004 --uri eip155:8453/erc-8004:0x1234/1
|
|
101911
|
-
use-agently erc-8004 --uri eip155:8453/erc-8004:0xAbCd/42`).action(async (options, command) => {
|
|
101912
|
-
const uri = resolveUriOption3(options);
|
|
101913
|
-
try {
|
|
101914
|
-
const agent = await resolveErc8004Agent(uri, clientFetch2);
|
|
101915
|
-
output(command, agent);
|
|
101916
|
-
} catch (err) {
|
|
101917
|
-
if (err instanceof AgentNotFoundError) {
|
|
101918
|
-
throw new Error(`No agent found for URI: ${uri}
|
|
101919
|
-
Run 'use-agently agents' to see available agent URIs.`);
|
|
101920
|
-
}
|
|
101921
|
-
throw err;
|
|
101922
|
-
}
|
|
101923
|
-
});
|
|
101924
|
-
|
|
101925
102015
|
// src/commands/web.ts
|
|
101926
102016
|
function collect(value, previous) {
|
|
101927
102017
|
return previous.concat([value]);
|
|
@@ -102087,7 +102177,7 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102087
102177
|
}
|
|
102088
102178
|
clearTimeout(timer);
|
|
102089
102179
|
console.log(`Response body written to ${options.outputFile} (HTTP ${response.status})`);
|
|
102090
|
-
if (!response.ok)
|
|
102180
|
+
if (options.fail && !response.ok)
|
|
102091
102181
|
process.exit(1);
|
|
102092
102182
|
return;
|
|
102093
102183
|
}
|
|
@@ -102105,7 +102195,7 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102105
102195
|
headers: responseHeaders,
|
|
102106
102196
|
body: responseBody
|
|
102107
102197
|
});
|
|
102108
|
-
if (!response.ok)
|
|
102198
|
+
if (options.fail && !response.ok)
|
|
102109
102199
|
process.exit(1);
|
|
102110
102200
|
return;
|
|
102111
102201
|
}
|
|
@@ -102118,12 +102208,12 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102118
102208
|
});
|
|
102119
102209
|
console.log(headerBlock + `
|
|
102120
102210
|
` + responseBody);
|
|
102121
|
-
if (!response.ok)
|
|
102211
|
+
if (options.fail && !response.ok)
|
|
102122
102212
|
process.exit(1);
|
|
102123
102213
|
return;
|
|
102124
102214
|
}
|
|
102125
102215
|
console.log(responseBody);
|
|
102126
|
-
if (!response.ok)
|
|
102216
|
+
if (options.fail && !response.ok)
|
|
102127
102217
|
process.exit(1);
|
|
102128
102218
|
} catch (err) {
|
|
102129
102219
|
clearTimeout(timer);
|
|
@@ -102137,7 +102227,7 @@ async function executeHttpRequest(method, url2, options, command) {
|
|
|
102137
102227
|
}
|
|
102138
102228
|
}
|
|
102139
102229
|
function addSharedOptions(cmd, hasBody) {
|
|
102140
|
-
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)");
|
|
102141
102231
|
if (hasBody) {
|
|
102142
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)");
|
|
102143
102233
|
}
|
|
@@ -102165,7 +102255,8 @@ webCommand.addCommand(createMethodSubcommand("patch", "Make an HTTP PATCH reques
|
|
|
102165
102255
|
webCommand.addCommand(createMethodSubcommand("delete", "Make an HTTP DELETE request", false));
|
|
102166
102256
|
|
|
102167
102257
|
// src/commands/doctor.ts
|
|
102168
|
-
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) => {
|
|
102169
102260
|
const checks3 = [];
|
|
102170
102261
|
const config2 = await loadConfig();
|
|
102171
102262
|
const hasWallet = !!config2?.wallet;
|
|
@@ -102277,7 +102368,7 @@ async function checkAutoUpdate() {
|
|
|
102277
102368
|
console.warn("Auto-update failed:", err instanceof Error ? err.message : String(err));
|
|
102278
102369
|
}
|
|
102279
102370
|
}
|
|
102280
|
-
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) => {
|
|
102281
102372
|
try {
|
|
102282
102373
|
const result = await checkAndUpdate();
|
|
102283
102374
|
output(command, result);
|
|
@@ -102289,7 +102380,7 @@ var updateCommand = new Command("update").description("Update use-agently to the
|
|
|
102289
102380
|
|
|
102290
102381
|
// src/cli.ts
|
|
102291
102382
|
var cli = new Command;
|
|
102292
|
-
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) => {
|
|
102293
102384
|
if (args.length > 0) {
|
|
102294
102385
|
cli.unknownCommand();
|
|
102295
102386
|
return;
|
|
@@ -102301,9 +102392,9 @@ cli.addCommand(whoamiCommand.helpGroup("Diagnostics"));
|
|
|
102301
102392
|
cli.addCommand(balanceCommand.helpGroup("Diagnostics"));
|
|
102302
102393
|
cli.addCommand(agentsCommand.helpGroup("Discovery"));
|
|
102303
102394
|
cli.addCommand(searchCommand.helpGroup("Discovery"));
|
|
102395
|
+
cli.addCommand(viewCommand.helpGroup("Discovery"));
|
|
102304
102396
|
cli.addCommand(a2aCommand.helpGroup("Protocols"));
|
|
102305
102397
|
cli.addCommand(mcpCommand.helpGroup("Protocols"));
|
|
102306
|
-
cli.addCommand(erc8004Command.helpGroup("Protocols"));
|
|
102307
102398
|
cli.addCommand(webCommand.helpGroup("Protocols"));
|
|
102308
102399
|
cli.addCommand(initCommand.helpGroup("Lifecycle"));
|
|
102309
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",
|