@agentsmarket/cli 0.1.1 → 0.5.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 +1455 -44
- package/dist/commands/balance.js +3 -3
- package/dist/commands/call.d.ts +23 -1
- package/dist/commands/call.js +187 -45
- package/dist/commands/call.js.map +1 -1
- package/dist/commands/info.d.ts +6 -6
- package/dist/commands/info.js +33 -35
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts +11 -7
- package/dist/commands/init.js +36 -38
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.js +2 -2
- package/dist/commands/mcp.js +9 -11
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/pipeline/call.d.ts +18 -0
- package/dist/commands/pipeline/call.js +58 -0
- package/dist/commands/pipeline/call.js.map +1 -0
- package/dist/commands/pipeline/install.d.ts +7 -0
- package/dist/commands/pipeline/install.js +16 -0
- package/dist/commands/pipeline/install.js.map +1 -0
- package/dist/commands/pipeline/publish.d.ts +15 -0
- package/dist/commands/pipeline/publish.js +22 -0
- package/dist/commands/pipeline/publish.js.map +1 -0
- package/dist/commands/publish-openapi.d.ts +16 -0
- package/dist/commands/publish-openapi.js +61 -0
- package/dist/commands/publish-openapi.js.map +1 -0
- package/dist/commands/publish-pipeline.d.ts +15 -0
- package/dist/commands/publish-pipeline.js +141 -0
- package/dist/commands/publish-pipeline.js.map +1 -0
- package/dist/commands/publish.js +37 -42
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/refund.js +15 -17
- package/dist/commands/refund.js.map +1 -1
- package/dist/commands/register.js +6 -27
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/run.d.ts +31 -0
- package/dist/commands/run.js +305 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/scan.js +2 -5
- package/dist/commands/scan.js.map +1 -1
- package/dist/commands/search.js +1 -1
- package/dist/commands/skill/call.d.ts +12 -0
- package/dist/commands/skill/call.js +17 -0
- package/dist/commands/skill/call.js.map +1 -0
- package/dist/commands/skill/install.d.ts +7 -0
- package/dist/commands/skill/install.js +13 -0
- package/dist/commands/skill/install.js.map +1 -0
- package/dist/commands/skill/publish.d.ts +18 -0
- package/dist/commands/skill/publish.js +28 -0
- package/dist/commands/skill/publish.js.map +1 -0
- package/dist/commands/validate.d.ts +20 -0
- package/dist/commands/validate.js +91 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.js +90 -29
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +12 -13
- package/dist/lib/config.js +27 -27
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/http.d.ts +23 -8
- package/dist/lib/http.js +28 -48
- package/dist/lib/http.js.map +1 -1
- package/dist/lib/identity.d.ts +29 -0
- package/dist/lib/identity.js +57 -0
- package/dist/lib/identity.js.map +1 -0
- package/dist/lib/mcp-install.d.ts +13 -0
- package/dist/lib/mcp-install.js +6 -6
- package/dist/lib/mcp-install.js.map +1 -1
- package/dist/lib/pipeline-spec.d.ts +66 -0
- package/dist/lib/pipeline-spec.js +273 -0
- package/dist/lib/pipeline-spec.js.map +1 -0
- package/package.json +12 -4
- package/dist/lib/keys.d.ts +0 -69
- package/dist/lib/keys.js +0 -85
- package/dist/lib/keys.js.map +0 -1
- package/dist/lib/payment-keys.d.ts +0 -25
- package/dist/lib/payment-keys.js +0 -55
- package/dist/lib/payment-keys.js.map +0 -1
- package/dist/lib/payment.d.ts +0 -27
- package/dist/lib/payment.js +0 -123
- package/dist/lib/payment.js.map +0 -1
package/dist/commands/balance.js
CHANGED
|
@@ -10,10 +10,10 @@ export async function balanceCommand() {
|
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
const data = await authedJson('GET', `/v1/agents/${encodeURIComponent(config.agent_id)}/balance`);
|
|
13
|
-
const usd = (data.
|
|
13
|
+
const usd = (data.balance_usdc / 1_000_000).toFixed(6);
|
|
14
14
|
console.log(`Agent: ${data.agent_id}`);
|
|
15
|
-
console.log(`Balance: ${data.
|
|
16
|
-
if (data.
|
|
15
|
+
console.log(`Balance: ${data.balance_usdc} micro-USDC ($${usd})`);
|
|
16
|
+
if (data.balance_usdc === 0) {
|
|
17
17
|
console.log(`\n💡 To top up (testnet): POST /v1/agents/:agent_id/balance/topup`);
|
|
18
18
|
}
|
|
19
19
|
}
|
package/dist/commands/call.d.ts
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `agentsmarket call <skill_id>` — invoke a skill.
|
|
3
|
+
*
|
|
4
|
+
* Payment is handled server-side: server checks buyer's USDC balance on-chain
|
|
5
|
+
* before allowing the call. No client-side signing of payment needed.
|
|
6
|
+
*
|
|
7
|
+
* Flags:
|
|
8
|
+
* --payment-tx-hash <hex> Real tx hash from MetaMask/Trust Wallet.
|
|
9
|
+
* --inputs <json> Pass as JSON string, e.g. '{"key":"value"}'
|
|
10
|
+
* --no-auto-sign Skip automatic Variant D signing on 402
|
|
11
|
+
* (default: load identity and auto-sign).
|
|
12
|
+
*
|
|
13
|
+
* On 402 with mode 'eip3009_variant_d', CLI auto-loads ~/.agentsmarket/identity,
|
|
14
|
+
* signs two ReceiveWithAuthorization payloads (author + treasury), computes
|
|
15
|
+
* shared_link, retries. Falls back to "manual payment" hint if identity absent.
|
|
16
|
+
*/
|
|
17
|
+
export interface CallOptions {
|
|
18
|
+
skillId: string;
|
|
19
|
+
paymentTxHash: string | null;
|
|
20
|
+
inputsJson: string | null;
|
|
21
|
+
noAutoSign?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function callCommand(opts: CallOptions): Promise<void>;
|
package/dist/commands/call.js
CHANGED
|
@@ -1,64 +1,206 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `agentsmarket call <skill_id>` — invoke a skill.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Payment is handled server-side: server checks buyer's USDC balance on-chain
|
|
5
|
+
* before allowing the call. No client-side signing of payment needed.
|
|
6
|
+
*
|
|
7
|
+
* Flags:
|
|
8
|
+
* --payment-tx-hash <hex> Real tx hash from MetaMask/Trust Wallet.
|
|
9
|
+
* --inputs <json> Pass as JSON string, e.g. '{"key":"value"}'
|
|
10
|
+
* --no-auto-sign Skip automatic Variant D signing on 402
|
|
11
|
+
* (default: load identity and auto-sign).
|
|
12
|
+
*
|
|
13
|
+
* On 402 with mode 'eip3009_variant_d', CLI auto-loads ~/.agentsmarket/identity,
|
|
14
|
+
* signs two ReceiveWithAuthorization payloads (author + treasury), computes
|
|
15
|
+
* shared_link, retries. Falls back to "manual payment" hint if identity absent.
|
|
6
16
|
*/
|
|
17
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
18
|
+
import { homedir } from 'node:os';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
import crypto from 'node:crypto';
|
|
21
|
+
import { Wallet } from 'ethers';
|
|
22
|
+
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
7
23
|
import { authedFetch, HttpError } from '../lib/http.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
function parseInputs(inputsJson) {
|
|
25
|
+
if (!inputsJson)
|
|
26
|
+
return {};
|
|
27
|
+
try {
|
|
28
|
+
const parsed = JSON.parse(inputsJson);
|
|
29
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
30
|
+
throw new Error('--inputs must be a JSON object');
|
|
31
|
+
}
|
|
32
|
+
return parsed;
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new Error(`--inputs parse error: ${err instanceof Error ? err.message : String(err)}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const RECEIVE_WITH_AUTHORIZATION_TYPEHASH = keccak_256(new TextEncoder().encode('ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)'));
|
|
39
|
+
const DOMAIN_TYPEHASH = keccak_256(new TextEncoder().encode('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'));
|
|
40
|
+
function pad32Hex(hexNoPrefix) {
|
|
41
|
+
return Buffer.from(hexNoPrefix.padStart(64, '0'), 'hex');
|
|
42
|
+
}
|
|
43
|
+
function bytesToHex(bytes) {
|
|
44
|
+
return '0x' + Buffer.from(bytes).toString('hex');
|
|
45
|
+
}
|
|
46
|
+
function addressToBytes32(addr) {
|
|
47
|
+
return pad32Hex(addr.slice(2).toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
function uint256Bytes(value) {
|
|
50
|
+
const v = BigInt(value);
|
|
51
|
+
return pad32Hex(v.toString(16));
|
|
52
|
+
}
|
|
53
|
+
function concatBytes(...arrays) {
|
|
54
|
+
const total = arrays.reduce((s, a) => s + a.length, 0);
|
|
55
|
+
const out = new Uint8Array(total);
|
|
56
|
+
let offset = 0;
|
|
57
|
+
for (const a of arrays) {
|
|
58
|
+
out.set(a, offset);
|
|
59
|
+
offset += a.length;
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
function computeDomainSeparator(chainId, verifyingContract) {
|
|
64
|
+
const enc = new TextEncoder();
|
|
65
|
+
const nameHash = keccak_256(enc.encode('USD Coin'));
|
|
66
|
+
const versionHash = keccak_256(enc.encode('2'));
|
|
67
|
+
return keccak_256(concatBytes(pad32Hex(bytesToHex(DOMAIN_TYPEHASH).slice(2)), nameHash, versionHash, pad32Hex(BigInt(chainId).toString(16)), pad32Hex(verifyingContract.slice(2).toLowerCase())));
|
|
68
|
+
}
|
|
69
|
+
function computeEip712Digest(payload, chainId, verifyingContract) {
|
|
70
|
+
const structHash = keccak_256(concatBytes(pad32Hex(bytesToHex(RECEIVE_WITH_AUTHORIZATION_TYPEHASH).slice(2)), addressToBytes32(payload.from), addressToBytes32(payload.to), uint256Bytes(payload.value), uint256Bytes(payload.validAfter), uint256Bytes(payload.validBefore), Buffer.from(payload.nonce.slice(2), 'hex')));
|
|
71
|
+
const domain = computeDomainSeparator(chainId, verifyingContract);
|
|
72
|
+
return keccak_256(concatBytes(new Uint8Array([0x19, 0x01]), domain, structHash));
|
|
73
|
+
}
|
|
74
|
+
function computeSharedLink(authorNonce, treasuryNonce, skillId, buyerAddress) {
|
|
75
|
+
const payload = `${authorNonce}|${treasuryNonce}|${skillId}|${buyerAddress.toLowerCase()}`;
|
|
76
|
+
return bytesToHex(keccak_256(new TextEncoder().encode(payload)));
|
|
77
|
+
}
|
|
78
|
+
function randomNonce() {
|
|
79
|
+
return '0x' + crypto.randomBytes(32).toString('hex');
|
|
80
|
+
}
|
|
81
|
+
function signPayload(payload, chainId, verifyingContract, wallet) {
|
|
82
|
+
const digest = computeEip712Digest({ ...payload, v: 0, r: '0x' + '0'.repeat(64), s: '0x' + '0'.repeat(64) }, chainId, verifyingContract);
|
|
83
|
+
const sig = wallet.signingKey.sign(digest);
|
|
84
|
+
return { ...payload, v: sig.v, r: sig.r, s: sig.s };
|
|
85
|
+
}
|
|
86
|
+
function loadIdentityPath() {
|
|
87
|
+
return join(homedir(), '.config', 'agentsmarket', 'agent.key');
|
|
88
|
+
}
|
|
89
|
+
function tryLoadIdentity() {
|
|
90
|
+
const path = loadIdentityPath();
|
|
91
|
+
if (!existsSync(path))
|
|
92
|
+
return null;
|
|
93
|
+
try {
|
|
94
|
+
const raw = readFileSync(path, 'utf-8').trim();
|
|
95
|
+
const pkHex = raw.startsWith('0x') ? raw : `0x${raw}`;
|
|
96
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(pkHex))
|
|
97
|
+
return null;
|
|
98
|
+
const wallet = new Wallet(pkHex);
|
|
99
|
+
return { private_key: pkHex, agent_id: wallet.address };
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function buildVariantDPayment(skillId, priceUsdc, commissionBps, authorRecipient, treasuryRecipient, chainId, tokenAddress, buyerAddress, wallet) {
|
|
106
|
+
const treasury = (BigInt(priceUsdc) * BigInt(commissionBps)) / BigInt(10000);
|
|
107
|
+
const author = BigInt(priceUsdc) - treasury;
|
|
108
|
+
const now = Math.floor(Date.now() / 1000);
|
|
109
|
+
const validBefore = now + 3600;
|
|
110
|
+
const authorNonce = randomNonce();
|
|
111
|
+
const treasuryNonce = randomNonce();
|
|
112
|
+
const authorPayload = signPayload({ from: buyerAddress, to: authorRecipient, value: author.toString(), validAfter: '0', validBefore: String(validBefore), nonce: authorNonce }, chainId, tokenAddress, wallet);
|
|
113
|
+
const treasuryPayload = signPayload({ from: buyerAddress, to: treasuryRecipient, value: treasury.toString(), validAfter: '0', validBefore: String(validBefore), nonce: treasuryNonce }, chainId, tokenAddress, wallet);
|
|
114
|
+
const shared_link = computeSharedLink(authorNonce, treasuryNonce, skillId, buyerAddress);
|
|
115
|
+
return {
|
|
116
|
+
skill_id: skillId,
|
|
117
|
+
author_auth: authorPayload,
|
|
118
|
+
treasury_auth: treasuryPayload,
|
|
119
|
+
shared_link,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function printLegacyHints(body, skillId) {
|
|
123
|
+
const fallbackRecipient = body.legacy_fallback?.recipient;
|
|
124
|
+
const recipient = body.author_recipient ?? body.recipient ?? fallbackRecipient ?? 'author';
|
|
125
|
+
console.error('');
|
|
126
|
+
console.error(` Next steps:`);
|
|
127
|
+
console.error(` 1. Send USDC to ${recipient} via Trust Wallet / MetaMask`);
|
|
128
|
+
console.error(` 2. Copy the tx hash from your wallet`);
|
|
129
|
+
console.error(` 3. Retry: agentsmarket call ${skillId} --payment-tx-hash <tx_hash> --inputs '<json>'`);
|
|
130
|
+
}
|
|
131
|
+
export async function callCommand(opts) {
|
|
132
|
+
const { skillId, paymentTxHash, inputsJson, noAutoSign } = opts;
|
|
133
|
+
const inputs = parseInputs(inputsJson);
|
|
11
134
|
const detailsRes = await authedFetch('GET', `/v1/skills/${encodeURIComponent(skillId)}`, undefined, { requireAuth: false });
|
|
12
|
-
const skill = await detailsRes.json();
|
|
13
|
-
const body = { ...inputs };
|
|
135
|
+
const skill = (await detailsRes.json());
|
|
14
136
|
if (!skill.is_free) {
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
const payment = buildAndSignAuthorization({
|
|
19
|
-
privateKey,
|
|
20
|
-
to: skill.author_agent_id.startsWith('0x') ? skill.author_agent_id : '0x0000000000000000000000000000000000000000',
|
|
21
|
-
valueUsdcBaseUnits: skill.price_usdt,
|
|
22
|
-
});
|
|
23
|
-
body.payment = payment;
|
|
24
|
-
console.log(`Skill "${skill.name}" costs $${(skill.price_usdt / 1_000_000).toFixed(3)} USDC.`);
|
|
25
|
-
console.log(`Signed EIP-3009 authorization (nonce=${payment.nonce.slice(0, 18)}...)\n`);
|
|
137
|
+
console.log(`Skill "${skill.name}" costs $${(skill.price_usdc / 1_000_000).toFixed(3)} USDC.`);
|
|
138
|
+
if (paymentTxHash) {
|
|
139
|
+
console.log(`Including payment_tx_hash: ${paymentTxHash.slice(0, 18)}...`);
|
|
26
140
|
}
|
|
27
141
|
else {
|
|
28
|
-
|
|
29
|
-
body.payment_tx_hash = mockTxHash;
|
|
30
|
-
console.log(`Skill "${skill.name}" costs $${(skill.price_usdt / 1_000_000).toFixed(3)} USDT.`);
|
|
31
|
-
console.log(`Using mock payment_tx_hash (run \`agentsmarket init\` to generate payment.key for real EIP-3009).\n`);
|
|
142
|
+
console.log(`Auto-signing Variant D on 402 (use --no-auto-sign to fall back to manual).`);
|
|
32
143
|
}
|
|
144
|
+
console.log('');
|
|
33
145
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
146
|
+
const body = { ...inputs };
|
|
147
|
+
if (paymentTxHash)
|
|
148
|
+
body.payment_tx_hash = paymentTxHash;
|
|
149
|
+
let usedBuyerAddress = null;
|
|
150
|
+
let attempt = 0;
|
|
151
|
+
while (attempt < 2) {
|
|
152
|
+
attempt++;
|
|
153
|
+
if (attempt === 2 && body.payment_variant_d) {
|
|
154
|
+
usedBuyerAddress = body.payment_variant_d.author_auth.from;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const res = await authedFetch('POST', `/v1/skills/${encodeURIComponent(skillId)}/invoke`, body);
|
|
158
|
+
const result = (await res.json());
|
|
159
|
+
if (result.ok) {
|
|
160
|
+
console.log(`✓ Invoked ${skill.name}\n`);
|
|
161
|
+
console.log(`Output:\n${result.invocation.output}\n`);
|
|
162
|
+
if (skill.is_free && !result.invocation.full_md) {
|
|
163
|
+
console.log('(Free skill — full_md not returned by server)\n');
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
console.log(`--- SKILL.md (received) ---`);
|
|
167
|
+
console.log(result.invocation.full_md);
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
46
170
|
}
|
|
171
|
+
throw new Error('invoke returned non-ok without 402');
|
|
47
172
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
173
|
+
catch (err) {
|
|
174
|
+
if (!(err instanceof HttpError) || err.status !== 402)
|
|
175
|
+
throw err;
|
|
176
|
+
const fortyTwo = err.body;
|
|
177
|
+
if (fortyTwo.mode === 'eip3009_variant_d' && !noAutoSign) {
|
|
178
|
+
const variantBody = fortyTwo;
|
|
179
|
+
if (attempt === 2)
|
|
180
|
+
throw new Error('Variant D retry returned 402 again');
|
|
181
|
+
const identity = tryLoadIdentity();
|
|
182
|
+
if (!identity) {
|
|
183
|
+
console.error(`✗ Payment required (402): server prefers Variant D, but no identity found at ${loadIdentityPath()}`);
|
|
184
|
+
console.error(` Run: agentsmarket init (or pass --no-auto-sign + use --payment-tx-hash for manual flow)`);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
const wallet = new Wallet(identity.private_key);
|
|
188
|
+
const variant = await buildVariantDPayment(skillId, variantBody.price_usdc, variantBody.commission_bps, variantBody.author_recipient, variantBody.treasury_recipient, variantBody.chain_id, variantBody.token_address, wallet.address, wallet);
|
|
189
|
+
body.payment_variant_d = variant;
|
|
190
|
+
console.log(`Authorizing $${(Number(variantBody.amount_to_author) / 1_000_000).toFixed(3)} USDC to author + $${(Number(variantBody.amount_to_treasury) / 1_000_000).toFixed(3)} USDC to treasury...`);
|
|
191
|
+
continue;
|
|
55
192
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
193
|
+
console.error(`✗ Payment required (402):`);
|
|
194
|
+
console.error(` ${err.message}`);
|
|
195
|
+
console.error('');
|
|
196
|
+
if (noAutoSign) {
|
|
197
|
+
console.error(` Full 402 body:`);
|
|
198
|
+
console.error(' ' + JSON.stringify(fortyTwo, null, 2).replace(/\n/g, '\n '));
|
|
199
|
+
console.error('');
|
|
59
200
|
}
|
|
201
|
+
printLegacyHints(fortyTwo, skillId);
|
|
202
|
+
process.exit(1);
|
|
60
203
|
}
|
|
61
|
-
throw err;
|
|
62
204
|
}
|
|
63
205
|
}
|
|
64
206
|
//# sourceMappingURL=call.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/commands/call.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/commands/call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAu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AAW,CAAC,aAAa,EACzB,MAAM,CAAC,OAAO,EACd,MAAM,CACP,CAAC;gBACF,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;gBACtM,SAAS;YACX,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC3C,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;gBAClC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;gBAC/E,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACpB,CAAC;YACD,gBAAgB,CAAC,QAAqB,EAAE,OAAO,CAAC,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/commands/info.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `agentsmarket info` — show current agent identity and
|
|
2
|
+
* `agentsmarket info` — show current agent identity and on-chain balance.
|
|
3
3
|
*
|
|
4
|
-
* Reads config + key from disk, verifies consistency, displays:
|
|
5
|
-
* - Agent ID (EVM
|
|
6
|
-
* - Public key
|
|
4
|
+
* Reads config + signing key from disk, verifies consistency, displays:
|
|
5
|
+
* - Agent ID (EVM address)
|
|
6
|
+
* - Public key
|
|
7
7
|
* - Network
|
|
8
8
|
* - Created timestamp
|
|
9
|
-
* -
|
|
9
|
+
* - On-chain USDC balance (via server RPC)
|
|
10
10
|
*/
|
|
11
|
-
export declare function infoCommand(): void
|
|
11
|
+
export declare function infoCommand(): Promise<void>;
|
package/dist/commands/info.js
CHANGED
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `agentsmarket info` — show current agent identity and
|
|
2
|
+
* `agentsmarket info` — show current agent identity and on-chain balance.
|
|
3
3
|
*
|
|
4
|
-
* Reads config + key from disk, verifies consistency, displays:
|
|
5
|
-
* - Agent ID (EVM
|
|
6
|
-
* - Public key
|
|
4
|
+
* Reads config + signing key from disk, verifies consistency, displays:
|
|
5
|
+
* - Agent ID (EVM address)
|
|
6
|
+
* - Public key
|
|
7
7
|
* - Network
|
|
8
8
|
* - Created timestamp
|
|
9
|
-
* -
|
|
9
|
+
* - On-chain USDC balance (via server RPC)
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
export function infoCommand() {
|
|
11
|
+
import { SigningKey, computeAddress } from 'ethers';
|
|
12
|
+
import { loadConfig, loadPrivateKeyHex, getKeyPath, getConfigPath, getConfigDir } from '../lib/config.js';
|
|
13
|
+
import { authedJson } from '../lib/http.js';
|
|
14
|
+
export async function infoCommand() {
|
|
15
15
|
const config = loadConfig();
|
|
16
16
|
if (!config) {
|
|
17
17
|
console.error('✗ No agent found. Run `agentsmarket init` first.');
|
|
18
18
|
process.exit(1);
|
|
19
19
|
}
|
|
20
|
-
if (!keyExists()) {
|
|
21
|
-
console.error('⚠️ Config exists but key file is missing: ' + getKeyPath());
|
|
22
|
-
console.error(' This is dangerous — your agent ID cannot be recovered without the key.');
|
|
23
|
-
console.error(' If you have a backup, restore it to: ' + getKeyPath());
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
// Load and verify key consistency
|
|
27
20
|
let publicKeyHex = '(unable to load)';
|
|
21
|
+
let derivedAddress = null;
|
|
28
22
|
try {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Verify the derived agent_id matches the stored one
|
|
34
|
-
const derivedId = 'ed25519:' + exportPublicKeyRaw(publicKey).toString('base64url');
|
|
35
|
-
if (derivedId !== config.agent_id) {
|
|
36
|
-
console.error('⚠️ Key file does not match stored agent_id!');
|
|
37
|
-
console.error(' Stored: ' + config.agent_id);
|
|
38
|
-
console.error(' Derived: ' + derivedId);
|
|
39
|
-
console.error(' This indicates key corruption or mismatch.');
|
|
40
|
-
console.error(' DO NOT use this identity for payments until resolved.');
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
23
|
+
const privateKey = loadPrivateKeyHex();
|
|
24
|
+
const sk = new SigningKey(privateKey);
|
|
25
|
+
publicKeyHex = sk.publicKey.slice(2);
|
|
26
|
+
derivedAddress = computeAddress(sk.publicKey);
|
|
43
27
|
}
|
|
44
28
|
catch (err) {
|
|
45
29
|
console.error('⚠️ Could not load key: ' + err.message);
|
|
46
30
|
}
|
|
31
|
+
if (derivedAddress !== null && derivedAddress.toLowerCase() !== config.agent_id.toLowerCase()) {
|
|
32
|
+
console.error('⚠️ Key file does not match stored agent_id!');
|
|
33
|
+
console.error(' Stored: ' + config.agent_id);
|
|
34
|
+
console.error(' Derived: ' + derivedAddress);
|
|
35
|
+
console.error(' This indicates key corruption or mismatch.');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
47
38
|
console.log('Agent information');
|
|
48
39
|
console.log('');
|
|
49
|
-
console.log(' Agent ID:
|
|
50
|
-
console.log(' Public key:
|
|
51
|
-
console.log(' Network:
|
|
52
|
-
console.log(' Created:
|
|
40
|
+
console.log(' Agent ID: ' + config.agent_id);
|
|
41
|
+
console.log(' Public key: ' + publicKeyHex);
|
|
42
|
+
console.log(' Network: ' + config.network);
|
|
43
|
+
console.log(' Created: ' + config.created_at);
|
|
53
44
|
console.log('');
|
|
54
45
|
console.log(' Config dir: ' + getConfigDir());
|
|
55
46
|
console.log(' Key file: ' + getKeyPath());
|
|
56
47
|
console.log(' Config file: ' + getConfigPath());
|
|
57
48
|
console.log('');
|
|
58
|
-
|
|
49
|
+
try {
|
|
50
|
+
const balance = await authedJson('GET', `/v1/agents/${encodeURIComponent(config.agent_id)}/balance`, undefined, { requireAuth: false });
|
|
51
|
+
console.log(' USDC balance: $' + balance.balance_usdc_display + ` (${balance.source})`);
|
|
52
|
+
console.log(' Top-up: send USDC on Base to ' + balance.address);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
console.log(' USDC balance: (unable to fetch — server may be down)');
|
|
56
|
+
}
|
|
59
57
|
}
|
|
60
58
|
//# sourceMappingURL=info.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAS5C,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB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MAAM,CAAC,UAAU,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,YAAY,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,UAAU,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,aAAa,EAAE,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,UAAU,CAC9B,KAAK,EACL,cAAc,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAC3D,SAAS,EACT,EAAE,WAAW,EAAE,KAAK,EAAE,CACvB,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7F,OAAO,CAAC,GAAG,CAAC,2CAA2C,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `agentsmarket init` — generate
|
|
2
|
+
* `agentsmarket init` — generate BIP-39 mnemonic, derive secp256k1 keypair, register.
|
|
3
3
|
*
|
|
4
|
-
* 1. Creates
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 1. Creates:
|
|
5
|
+
* ~/.config/agentsmarket/mnemonic.txt — 12-word phrase (PRIMARY backup)
|
|
6
|
+
* ~/.config/agentsmarket/agent.key — secp256k1 private key (hex)
|
|
7
|
+
* ~/.config/agentsmarket/config.json — public config (agent_id, network)
|
|
8
|
+
* 2. Registers on server (POST /v1/agents/register). If unreachable, init still
|
|
9
|
+
* succeeds locally — retry later with `agentsmarket register`.
|
|
8
10
|
*
|
|
9
|
-
* IMPORTANT: This is a one-time setup.
|
|
10
|
-
*
|
|
11
|
+
* IMPORTANT: This is a one-time setup.
|
|
12
|
+
* - mnemonic.txt = wallet backup. Import into Trust Wallet to monitor/send funds.
|
|
13
|
+
* - agent.key = signing key for CLI. Derived from mnemonic.
|
|
14
|
+
* - If you lose BOTH, you lose the agent identity and any associated balance.
|
|
11
15
|
*/
|
|
12
16
|
export declare function initCommand(): Promise<void>;
|
package/dist/commands/init.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `agentsmarket init` — generate
|
|
2
|
+
* `agentsmarket init` — generate BIP-39 mnemonic, derive secp256k1 keypair, register.
|
|
3
3
|
*
|
|
4
|
-
* 1. Creates
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 1. Creates:
|
|
5
|
+
* ~/.config/agentsmarket/mnemonic.txt — 12-word phrase (PRIMARY backup)
|
|
6
|
+
* ~/.config/agentsmarket/agent.key — secp256k1 private key (hex)
|
|
7
|
+
* ~/.config/agentsmarket/config.json — public config (agent_id, network)
|
|
8
|
+
* 2. Registers on server (POST /v1/agents/register). If unreachable, init still
|
|
9
|
+
* succeeds locally — retry later with `agentsmarket register`.
|
|
8
10
|
*
|
|
9
|
-
* IMPORTANT: This is a one-time setup.
|
|
10
|
-
*
|
|
11
|
+
* IMPORTANT: This is a one-time setup.
|
|
12
|
+
* - mnemonic.txt = wallet backup. Import into Trust Wallet to monitor/send funds.
|
|
13
|
+
* - agent.key = signing key for CLI. Derived from mnemonic.
|
|
14
|
+
* - If you lose BOTH, you lose the agent identity and any associated balance.
|
|
11
15
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { saveConfig, savePrivateKey, savePaymentKey, configExists, getKeyPath, getConfigPath, } from '../lib/config.js';
|
|
16
|
+
import { generateMnemonic, mnemonicToIdentity, } from '../lib/identity.js';
|
|
17
|
+
import { saveConfig, savePrivateKey, saveMnemonic, configExists, getKeyPath, getConfigPath, getMnemonicPath, } from '../lib/config.js';
|
|
15
18
|
import { authedJson } from '../lib/http.js';
|
|
16
19
|
import { installMcpForAll } from '../lib/mcp-install.js';
|
|
17
20
|
export async function initCommand() {
|
|
18
|
-
// 1. Check if already initialized
|
|
19
21
|
if (configExists()) {
|
|
20
22
|
console.error('✗ Agent already initialized.');
|
|
21
23
|
console.error(' Config: ' + getConfigPath());
|
|
@@ -23,35 +25,27 @@ export async function initCommand() {
|
|
|
23
25
|
console.error(' To re-initialize, delete the existing config and key files first.');
|
|
24
26
|
process.exit(1);
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// 2b. Generate secp256k1 keypair for EIP-3009 USDC payments
|
|
31
|
-
const paymentKp = generatePaymentKeypair();
|
|
32
|
-
const paymentAddress = exportPaymentAddress(paymentKp.publicKey);
|
|
33
|
-
// 3. Save private keys (PEM/PKCS8, 0600 perms) and config (0600 perms)
|
|
34
|
-
savePrivateKey(exportPrivateKeyPem(privateKey));
|
|
35
|
-
savePaymentKey(exportPaymentPrivateKeyPem(paymentKp.privateKey));
|
|
28
|
+
const mnemonic = generateMnemonic();
|
|
29
|
+
const id = mnemonicToIdentity(mnemonic);
|
|
30
|
+
saveMnemonic(mnemonic);
|
|
31
|
+
savePrivateKey(id.privateKeyHex);
|
|
36
32
|
saveConfig({
|
|
37
|
-
agent_id:
|
|
38
|
-
payment_address: paymentAddress,
|
|
33
|
+
agent_id: id.address,
|
|
39
34
|
network: 'base-sepolia',
|
|
40
35
|
created_at: new Date().toISOString(),
|
|
41
36
|
});
|
|
42
|
-
// 4. Print success message
|
|
43
37
|
console.log('✓ Agent created locally');
|
|
44
38
|
console.log('');
|
|
45
|
-
console.log(' Agent ID:
|
|
46
|
-
console.log('
|
|
47
|
-
console.log('
|
|
48
|
-
|
|
39
|
+
console.log(' Agent ID: ' + id.address);
|
|
40
|
+
console.log(' Mnemonic: ' + getMnemonicPath());
|
|
41
|
+
console.log(' Signing key: ' + getKeyPath());
|
|
42
|
+
console.log(' Config file: ' + getConfigPath());
|
|
49
43
|
console.log('');
|
|
50
44
|
console.log('→ Registering on marketplace server...');
|
|
51
45
|
try {
|
|
52
46
|
await authedJson('POST', '/v1/agents/register', {
|
|
53
|
-
agent_id:
|
|
54
|
-
public_key_hex: publicKeyHex,
|
|
47
|
+
agent_id: id.address,
|
|
48
|
+
public_key_hex: id.publicKeyHex,
|
|
55
49
|
display_name: null,
|
|
56
50
|
});
|
|
57
51
|
console.log('✓ Registered on server');
|
|
@@ -62,7 +56,6 @@ export async function initCommand() {
|
|
|
62
56
|
console.warn(' Your agent works locally but cannot use the marketplace yet.');
|
|
63
57
|
console.warn(' Retry later with: agentsmarket register');
|
|
64
58
|
}
|
|
65
|
-
// 6. Auto-install MCP server into detected agent configs
|
|
66
59
|
console.log('');
|
|
67
60
|
console.log('→ Detecting MCP-aware agents (OpenCode / Claude Code / Cursor)...');
|
|
68
61
|
const mcpReport = installMcpForAll();
|
|
@@ -89,11 +82,16 @@ export async function initCommand() {
|
|
|
89
82
|
console.log(' Restart your agent (OpenCode/Claude/Cursor) so it picks up the new MCP server.');
|
|
90
83
|
}
|
|
91
84
|
console.log('');
|
|
92
|
-
console.log('⚠️ BACK UP YOUR
|
|
93
|
-
console.log('
|
|
94
|
-
console.log('
|
|
95
|
-
console.log('
|
|
96
|
-
console.log('
|
|
85
|
+
console.log('⚠️ BACK UP YOUR MNEMONIC — 12 words that control your agent address.');
|
|
86
|
+
console.log(' Anyone with these words can spend your USDC.');
|
|
87
|
+
console.log('');
|
|
88
|
+
console.log(' Recommended backups:');
|
|
89
|
+
console.log(' 1. Write on paper, store in a safe');
|
|
90
|
+
console.log(' 2. Import into Trust Wallet to monitor/withdraw via familiar UI');
|
|
91
|
+
console.log(' (Trust Wallet → "Add wallet" → "Import" → paste 12 words)');
|
|
92
|
+
console.log(' 3. Encrypted backup file:');
|
|
93
|
+
console.log(` cp ${getMnemonicPath()} ~/backups/mnemonic-$(date +%Y%m%d).txt.enc`);
|
|
94
|
+
console.log(' # then encrypt with gpg or age before storing in cloud');
|
|
97
95
|
console.log('');
|
|
98
96
|
console.log('Next step — tell your agent what you want to do. For example:');
|
|
99
97
|
console.log(' "Search for a skill that summarizes articles"');
|
|
@@ -104,8 +102,8 @@ export async function initCommand() {
|
|
|
104
102
|
console.log(' agentsmarket search <query> # find skills');
|
|
105
103
|
console.log(' agentsmarket call <skill_id> # invoke a skill');
|
|
106
104
|
console.log(' agentsmarket publish <path> # publish your SKILL.md');
|
|
107
|
-
console.log(' agentsmarket info # show agent details +
|
|
105
|
+
console.log(' agentsmarket info # show agent details + on-chain balance');
|
|
108
106
|
console.log('');
|
|
109
|
-
console.log('Your Agent ID: ' +
|
|
107
|
+
console.log('Your Agent ID: ' + id.address);
|
|
110
108
|
}
|
|
111
109
|
//# sourceMappingURL=init.js.map
|