@paysponge/sdk 0.1.25 → 0.1.27
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 -0
- package/dist/api/generated/openapi/apis/default-api.d.ts +66 -1
- package/dist/api/generated/openapi/apis/default-api.d.ts.map +1 -1
- package/dist/api/generated/openapi/apis/default-api.js +66 -1
- package/dist/api/generated/openapi/apis/default-api.js.map +1 -1
- package/dist/api/generated/openapi/models/index.d.ts +1 -0
- package/dist/api/generated/openapi/models/index.d.ts.map +1 -1
- package/dist/api/generated/openapi/models/index.js +1 -0
- package/dist/api/generated/openapi/models/index.js.map +1 -1
- package/dist/api/generated/openapi/models/post-api-agents-by-id-enrollments-request.d.ts +6 -0
- package/dist/api/generated/openapi/models/post-api-agents-by-id-enrollments-request.d.ts.map +1 -1
- package/dist/api/generated/openapi/models/post-api-agents-by-id-enrollments-request.js +2 -0
- package/dist/api/generated/openapi/models/post-api-agents-by-id-enrollments-request.js.map +1 -1
- package/dist/api/generated/openapi/models/post-api-checkout-stream-request.d.ts +64 -0
- package/dist/api/generated/openapi/models/post-api-checkout-stream-request.d.ts.map +1 -0
- package/dist/api/generated/openapi/models/post-api-checkout-stream-request.js +55 -0
- package/dist/api/generated/openapi/models/post-api-checkout-stream-request.js.map +1 -0
- package/dist/api/generated/openapi/models/post-api-x402-fetch-request.d.ts +15 -0
- package/dist/api/generated/openapi/models/post-api-x402-fetch-request.d.ts.map +1 -1
- package/dist/api/generated/openapi/models/post-api-x402-fetch-request.js +10 -0
- package/dist/api/generated/openapi/models/post-api-x402-fetch-request.js.map +1 -1
- package/dist/api/transactions.d.ts +1 -0
- package/dist/api/transactions.d.ts.map +1 -1
- package/dist/api/transactions.js +9 -4
- package/dist/api/transactions.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +129 -97
- package/dist/cli.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -34,7 +34,10 @@ export function buildCliProgram(metadata = {}) {
|
|
|
34
34
|
.action((opts) => handleInit(opts, metadata));
|
|
35
35
|
withAuth(program
|
|
36
36
|
.command("login")
|
|
37
|
-
.description("Claim a pending agent or authenticate and cache credentials"))
|
|
37
|
+
.description("Claim a pending agent or authenticate and cache credentials"))
|
|
38
|
+
.option("--continue-claim", "open the cached claim URL for the current agent")
|
|
39
|
+
.option("--switch", "replace cached credentials with a new agent login")
|
|
40
|
+
.action((opts) => handleLogin(opts));
|
|
38
41
|
shared(program.command("logout").description("Remove stored credentials")).action((opts) => handleLogout(opts));
|
|
39
42
|
shared(program
|
|
40
43
|
.command("whoami")
|
|
@@ -62,7 +65,17 @@ export async function runCli(args, metadata = {}) {
|
|
|
62
65
|
// ---------------------------------------------------------------------------
|
|
63
66
|
async function handleLogin(opts) {
|
|
64
67
|
const creds = loadCredentials(opts.credentialsPath);
|
|
65
|
-
if (
|
|
68
|
+
if (opts.switch) {
|
|
69
|
+
deleteCredentials(opts.credentialsPath);
|
|
70
|
+
}
|
|
71
|
+
if (opts.continueClaim) {
|
|
72
|
+
if (!creds?.claimUrl) {
|
|
73
|
+
throw new Error("No pending claim URL found in cached credentials. Run `spongewallet login --switch` to authenticate a different agent.");
|
|
74
|
+
}
|
|
75
|
+
await continueClaimFlow(creds, opts);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!opts.switch && !process.env.SPONGE_API_KEY && creds?.claimUrl) {
|
|
66
79
|
await continueClaimFlow(creds, opts);
|
|
67
80
|
return;
|
|
68
81
|
}
|
|
@@ -177,6 +190,11 @@ async function handleWhoami(opts, meta) {
|
|
|
177
190
|
lines.push(`Claim Code: ${creds.claimCode}`);
|
|
178
191
|
lines.push(`Credentials: ${getCredentialsPath(opts.credentialsPath)}`);
|
|
179
192
|
p.log.info(lines.join("\n"));
|
|
193
|
+
if (creds.claimUrl) {
|
|
194
|
+
const cmd = meta.commandName ?? "spongewallet";
|
|
195
|
+
p.log.step(`Run \`${cmd} login --continue-claim\` to reopen this claim flow.`);
|
|
196
|
+
p.log.step(`Run \`${cmd} login --switch\` to replace this cached agent with a different one.`);
|
|
197
|
+
}
|
|
180
198
|
}
|
|
181
199
|
async function handleMcpPrint(opts) {
|
|
182
200
|
const wallet = await SpongeWallet.connect({
|
|
@@ -222,14 +240,18 @@ async function continueClaimFlow(creds, opts) {
|
|
|
222
240
|
p.log.step("Could not open browser automatically. Open the claim URL manually.");
|
|
223
241
|
}
|
|
224
242
|
p.log.info("After the browser claim completes, the cached API key will keep working for this agent.");
|
|
243
|
+
p.log.step("To authenticate a different agent, run `spongewallet login --switch`.");
|
|
225
244
|
p.outro("Claim flow ready");
|
|
226
245
|
}
|
|
227
|
-
function requiredInput(opts, positional, optionKey, flagName) {
|
|
246
|
+
function requiredInput(command, opts, positional, optionKey, flagName) {
|
|
228
247
|
const fromOption = opts[optionKey];
|
|
229
248
|
const value = positional
|
|
230
249
|
?? (typeof fromOption === "string" ? fromOption : undefined);
|
|
231
250
|
if (!value) {
|
|
232
|
-
|
|
251
|
+
command.error(`missing required argument or option: ${flagName}`, {
|
|
252
|
+
exitCode: 1,
|
|
253
|
+
code: "sponge.missing_required_input",
|
|
254
|
+
});
|
|
233
255
|
}
|
|
234
256
|
return value;
|
|
235
257
|
}
|
|
@@ -384,35 +406,35 @@ function registerCuratedCommands(program, shared) {
|
|
|
384
406
|
displayToolResult(getToolDefinition("get_balance"), data);
|
|
385
407
|
});
|
|
386
408
|
shared(program.command("send").description("Send assets on EVM, Solana, or Tempo"))
|
|
387
|
-
.usage("
|
|
388
|
-
.argument("
|
|
389
|
-
.argument("
|
|
390
|
-
.argument("
|
|
391
|
-
.argument("
|
|
409
|
+
.usage("[chain] [to] [asset] [amount] [options]")
|
|
410
|
+
.argument("[chain]", "destination chain")
|
|
411
|
+
.argument("[to]", "recipient address")
|
|
412
|
+
.argument("[asset]", "currency symbol or token symbol/address")
|
|
413
|
+
.argument("[amount]", "amount to send")
|
|
392
414
|
.option("--chain <chain>", "destination chain")
|
|
393
415
|
.option("--to <address>", "recipient address")
|
|
394
416
|
.option("--amount <amount>", "amount to send")
|
|
395
417
|
.option("--asset <asset>", "currency symbol or token symbol/address")
|
|
396
418
|
.addHelpText("after", "\nExamples:\n spongewallet send base 0xabc... USDC 10\n spongewallet send tempo 0xabc... usdce 1\n")
|
|
397
|
-
.action(async (chainArg, toArg, assetArg, amountArg, opts) => {
|
|
398
|
-
const
|
|
399
|
-
const chain = requiredInput(opts, chainArg, "chain", "--chain");
|
|
419
|
+
.action(async (chainArg, toArg, assetArg, amountArg, opts, command) => {
|
|
420
|
+
const chain = requiredInput(command, opts, chainArg, "chain", "--chain");
|
|
400
421
|
const asset = isTempoChain(chain)
|
|
401
|
-
? normalizeTempoTokenSymbol(requiredInput(opts, assetArg, "asset", "--asset"), chain)
|
|
402
|
-
: requiredInput(opts, assetArg, "asset", "--asset");
|
|
422
|
+
? normalizeTempoTokenSymbol(requiredInput(command, opts, assetArg, "asset", "--asset"), chain)
|
|
423
|
+
: requiredInput(command, opts, assetArg, "asset", "--asset");
|
|
403
424
|
const input = chain === "tempo" || chain === "tempo-testnet"
|
|
404
425
|
? {
|
|
405
426
|
chain,
|
|
406
|
-
to: requiredInput(opts, toArg, "to", "--to"),
|
|
407
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
427
|
+
to: requiredInput(command, opts, toArg, "to", "--to"),
|
|
428
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
408
429
|
token: asset,
|
|
409
430
|
}
|
|
410
431
|
: {
|
|
411
432
|
chain,
|
|
412
|
-
to: requiredInput(opts, toArg, "to", "--to"),
|
|
413
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
433
|
+
to: requiredInput(command, opts, toArg, "to", "--to"),
|
|
434
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
414
435
|
currency: asset,
|
|
415
436
|
};
|
|
437
|
+
const wallet = await connectWallet(opts);
|
|
416
438
|
const data = await wallet.transfer(input);
|
|
417
439
|
displayToolResult(getToolDefinition(chain.startsWith("solana") ? "solana_transfer" : "evm_transfer"), data);
|
|
418
440
|
});
|
|
@@ -445,18 +467,19 @@ function registerCuratedCommands(program, shared) {
|
|
|
445
467
|
displayToolResult(getToolDefinition("get_solana_tokens"), data);
|
|
446
468
|
});
|
|
447
469
|
shared(program.command("search-tokens").description("Search the Solana token list"))
|
|
448
|
-
.usage("
|
|
449
|
-
.argument("
|
|
470
|
+
.usage("[query] [limit] [options]")
|
|
471
|
+
.argument("[query]", "token symbol or name")
|
|
450
472
|
.argument("[limit]", "maximum results")
|
|
451
473
|
.option("--query <query>", "token symbol or name")
|
|
452
474
|
.option("--limit <n>", "maximum results", parseInt)
|
|
453
475
|
.addHelpText("after", "\nExamples:\n spongewallet search-tokens BONK\n spongewallet search-tokens BONK 5\n")
|
|
454
|
-
.action(async (queryArg, limitArg, opts) => {
|
|
455
|
-
const wallet = await connectWallet(opts);
|
|
476
|
+
.action(async (queryArg, limitArg, opts, command) => {
|
|
456
477
|
const limit = limitArg !== undefined
|
|
457
478
|
? parseInt(limitArg, 10)
|
|
458
479
|
: opts.limit;
|
|
459
|
-
const
|
|
480
|
+
const query = requiredInput(command, opts, queryArg, "query", "--query");
|
|
481
|
+
const wallet = await connectWallet(opts);
|
|
482
|
+
const data = await wallet.searchSolanaTokens(query, Number.isFinite(limit) ? limit : undefined);
|
|
460
483
|
displayToolResult(getToolDefinition("search_solana_tokens"), data);
|
|
461
484
|
});
|
|
462
485
|
shared(program.command("onramp").description("Create a fiat-to-crypto onramp link"))
|
|
@@ -490,15 +513,17 @@ function registerCuratedCommands(program, shared) {
|
|
|
490
513
|
});
|
|
491
514
|
const txCmd = program.command("tx").description("Transaction status and signing");
|
|
492
515
|
shared(txCmd.command("status").description("Check transaction status"))
|
|
493
|
-
.usage("
|
|
494
|
-
.argument("
|
|
495
|
-
.argument("
|
|
516
|
+
.usage("[chain] [txHash] [options]")
|
|
517
|
+
.argument("[chain]", "transaction chain")
|
|
518
|
+
.argument("[txHash]", "transaction hash or signature")
|
|
496
519
|
.option("--tx-hash <hash>", "transaction hash or signature")
|
|
497
520
|
.option("--chain <chain>", "transaction chain")
|
|
498
521
|
.addHelpText("after", "\nExamples:\n spongewallet tx status base 0x123...\n spongewallet tx status solana 5K2...\n")
|
|
499
|
-
.action(async (chainArg, txHashArg, opts) => {
|
|
522
|
+
.action(async (chainArg, txHashArg, opts, command) => {
|
|
523
|
+
const txHash = requiredInput(command, opts, txHashArg, "txHash", "--tx-hash");
|
|
524
|
+
const chain = requiredInput(command, opts, chainArg, "chain", "--chain");
|
|
500
525
|
const wallet = await connectWallet(opts);
|
|
501
|
-
const data = await wallet.getTransactionStatus(
|
|
526
|
+
const data = await wallet.getTransactionStatus(txHash, chain);
|
|
502
527
|
displayToolResult(getToolDefinition("get_transaction_status"), data);
|
|
503
528
|
});
|
|
504
529
|
shared(txCmd.command("sign").description("Sign a Solana transaction without submitting"))
|
|
@@ -527,13 +552,16 @@ function registerCuratedCommands(program, shared) {
|
|
|
527
552
|
.option("--amount <amount>", "amount to swap")
|
|
528
553
|
.option("--slippage-bps <bps>", "slippage in basis points", parseInt)
|
|
529
554
|
.addHelpText("after", "\nExamples:\n spongewallet swap solana SOL USDC 1\n spongewallet swap solana --chain solana --from SOL --to USDC --amount 1\n")
|
|
530
|
-
.action(async (fromArg, toArg, amountArg, opts) => {
|
|
555
|
+
.action(async (fromArg, toArg, amountArg, opts, command) => {
|
|
556
|
+
const from = requiredInput(command, opts, fromArg, "from", "--from");
|
|
557
|
+
const to = requiredInput(command, opts, toArg, "to", "--to");
|
|
558
|
+
const amount = requiredInput(command, opts, amountArg, "amount", "--amount");
|
|
531
559
|
const wallet = await connectWallet(opts);
|
|
532
560
|
const data = await wallet.swap({
|
|
533
561
|
chain: opts.chain,
|
|
534
|
-
from
|
|
535
|
-
to
|
|
536
|
-
amount
|
|
562
|
+
from,
|
|
563
|
+
to,
|
|
564
|
+
amount,
|
|
537
565
|
slippageBps: opts.slippageBps,
|
|
538
566
|
});
|
|
539
567
|
displayToolResult(getToolDefinition("solana_swap"), data);
|
|
@@ -549,23 +577,23 @@ function registerCuratedCommands(program, shared) {
|
|
|
549
577
|
.option("--amount <amount>", "amount to quote")
|
|
550
578
|
.option("--slippage-bps <bps>", "slippage in basis points", parseInt)
|
|
551
579
|
.addHelpText("after", "\nExamples:\n spongewallet swap quote SOL USDC 1\n spongewallet swap quote --chain solana --from SOL --to USDC --amount 1\n")
|
|
552
|
-
.action(async (fromArg, toArg, amountArg, opts) => {
|
|
580
|
+
.action(async (fromArg, toArg, amountArg, opts, command) => {
|
|
553
581
|
await executeToolCommand(opts, "jupiter_swap_quote", {
|
|
554
582
|
chain: opts.chain,
|
|
555
|
-
input_token: requiredInput(opts, fromArg, "from", "--from"),
|
|
556
|
-
output_token: requiredInput(opts, toArg, "to", "--to"),
|
|
557
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
583
|
+
input_token: requiredInput(command, opts, fromArg, "from", "--from"),
|
|
584
|
+
output_token: requiredInput(command, opts, toArg, "to", "--to"),
|
|
585
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
558
586
|
slippage_bps: opts.slippageBps,
|
|
559
587
|
});
|
|
560
588
|
});
|
|
561
589
|
shared(swapCmd.command("execute").description("Execute a previously quoted Jupiter swap"))
|
|
562
|
-
.usage("
|
|
563
|
-
.argument("
|
|
590
|
+
.usage("[quoteId] [options]")
|
|
591
|
+
.argument("[quoteId]", "quote ID to execute")
|
|
564
592
|
.option("--quote-id <id>", "quote ID to execute")
|
|
565
593
|
.addHelpText("after", "\nExamples:\n spongewallet swap execute quote_123\n")
|
|
566
|
-
.action(async (quoteIdArg, opts) => {
|
|
594
|
+
.action(async (quoteIdArg, opts, command) => {
|
|
567
595
|
await executeToolCommand(opts, "jupiter_swap_execute", {
|
|
568
|
-
quote_id: requiredInput(opts, quoteIdArg, "quoteId", "--quote-id"),
|
|
596
|
+
quote_id: requiredInput(command, opts, quoteIdArg, "quoteId", "--quote-id"),
|
|
569
597
|
});
|
|
570
598
|
});
|
|
571
599
|
shared(swapCmd.command("base").description("Swap on Base via 0x"))
|
|
@@ -578,11 +606,11 @@ function registerCuratedCommands(program, shared) {
|
|
|
578
606
|
.option("--amount <amount>", "amount to swap")
|
|
579
607
|
.option("--slippage-bps <bps>", "slippage in basis points", parseInt)
|
|
580
608
|
.addHelpText("after", "\nExamples:\n spongewallet swap base ETH USDC 0.1\n spongewallet swap base --from ETH --to USDC --amount 0.1\n")
|
|
581
|
-
.action(async (fromArg, toArg, amountArg, opts) => {
|
|
609
|
+
.action(async (fromArg, toArg, amountArg, opts, command) => {
|
|
582
610
|
await executeToolCommand(opts, "base_swap", {
|
|
583
|
-
input_token: requiredInput(opts, fromArg, "from", "--from"),
|
|
584
|
-
output_token: requiredInput(opts, toArg, "to", "--to"),
|
|
585
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
611
|
+
input_token: requiredInput(command, opts, fromArg, "from", "--from"),
|
|
612
|
+
output_token: requiredInput(command, opts, toArg, "to", "--to"),
|
|
613
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
586
614
|
slippage_bps: opts.slippageBps,
|
|
587
615
|
});
|
|
588
616
|
});
|
|
@@ -597,13 +625,13 @@ function registerCuratedCommands(program, shared) {
|
|
|
597
625
|
.option("--amount <amount>", "amount to swap")
|
|
598
626
|
.option("--slippage-bps <bps>", "slippage in basis points", parseInt)
|
|
599
627
|
.addHelpText("after", "\nExamples:\n spongewallet swap tempo pathUSD USDC.e 1\n spongewallet swap tempo --chain tempo --from pathUSD --to USDC.e --amount 1\n")
|
|
600
|
-
.action(async (fromArg, toArg, amountArg, opts) => {
|
|
628
|
+
.action(async (fromArg, toArg, amountArg, opts, command) => {
|
|
601
629
|
const chain = String(opts.chain ?? "tempo");
|
|
602
630
|
await executeToolCommand(opts, "tempo_swap", {
|
|
603
631
|
chain,
|
|
604
|
-
input_token: normalizeTempoTokenSymbol(requiredInput(opts, fromArg, "from", "--from"), chain),
|
|
605
|
-
output_token: normalizeTempoTokenSymbol(requiredInput(opts, toArg, "to", "--to"), chain),
|
|
606
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
632
|
+
input_token: normalizeTempoTokenSymbol(requiredInput(command, opts, fromArg, "from", "--from"), chain),
|
|
633
|
+
output_token: normalizeTempoTokenSymbol(requiredInput(command, opts, toArg, "to", "--to"), chain),
|
|
634
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
607
635
|
slippage_bps: opts.slippageBps,
|
|
608
636
|
});
|
|
609
637
|
});
|
|
@@ -620,12 +648,12 @@ function registerCuratedCommands(program, shared) {
|
|
|
620
648
|
.option("--destination-token <token>", "token to receive on destination")
|
|
621
649
|
.option("--recipient-address <address>", "recipient address on destination")
|
|
622
650
|
.addHelpText("after", "\nExamples:\n spongewallet bridge base solana USDC 25\n spongewallet bridge base hyperliquid USDC 50\n spongewallet bridge --source-chain base --destination-chain polymarket --token USDC --amount 50\n")
|
|
623
|
-
.action(async (sourceChainArg, destinationChainArg, tokenArg, amountArg, opts) => {
|
|
651
|
+
.action(async (sourceChainArg, destinationChainArg, tokenArg, amountArg, opts, command) => {
|
|
624
652
|
await executeToolCommand(opts, "bridge", {
|
|
625
|
-
source_chain: requiredInput(opts, sourceChainArg, "sourceChain", "--source-chain"),
|
|
626
|
-
destination_chain: requiredInput(opts, destinationChainArg, "destinationChain", "--destination-chain"),
|
|
627
|
-
token: requiredInput(opts, tokenArg, "token", "--token"),
|
|
628
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
653
|
+
source_chain: requiredInput(command, opts, sourceChainArg, "sourceChain", "--source-chain"),
|
|
654
|
+
destination_chain: requiredInput(command, opts, destinationChainArg, "destinationChain", "--destination-chain"),
|
|
655
|
+
token: requiredInput(command, opts, tokenArg, "token", "--token"),
|
|
656
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
629
657
|
destination_token: opts.destinationToken,
|
|
630
658
|
recipient_address: opts.recipientAddress,
|
|
631
659
|
});
|
|
@@ -686,28 +714,28 @@ function registerCuratedCommands(program, shared) {
|
|
|
686
714
|
await executeToolCommand(opts, "get_key_list", {});
|
|
687
715
|
});
|
|
688
716
|
shared(keysCmd.command("get").description("Get a stored key value"))
|
|
689
|
-
.usage("
|
|
690
|
-
.argument("
|
|
717
|
+
.usage("[service] [options]")
|
|
718
|
+
.argument("[service]", "service name")
|
|
691
719
|
.option("--service <service>", "service name")
|
|
692
720
|
.addHelpText("after", "\nExamples:\n spongewallet keys get openai\n")
|
|
693
|
-
.action(async (serviceArg, opts) => {
|
|
721
|
+
.action(async (serviceArg, opts, command) => {
|
|
694
722
|
await executeToolCommand(opts, "get_key_value", {
|
|
695
|
-
service: requiredInput(opts, serviceArg, "service", "--service"),
|
|
723
|
+
service: requiredInput(command, opts, serviceArg, "service", "--service"),
|
|
696
724
|
});
|
|
697
725
|
});
|
|
698
726
|
shared(keysCmd.command("set").description("Store a service key"))
|
|
699
|
-
.usage("
|
|
700
|
-
.argument("
|
|
701
|
-
.argument("
|
|
727
|
+
.usage("[service] [key] [options]")
|
|
728
|
+
.argument("[service]", "service name")
|
|
729
|
+
.argument("[key]", "key or secret to store")
|
|
702
730
|
.option("--service <service>", "service name")
|
|
703
731
|
.option("--key <secret>", "key or secret to store")
|
|
704
732
|
.option("--label <label>", "friendly label")
|
|
705
733
|
.option("--metadata <json>", "metadata as JSON", parseJsonObject)
|
|
706
734
|
.addHelpText("after", "\nExamples:\n spongewallet keys set openai sk-... --label primary\n")
|
|
707
|
-
.action(async (serviceArg, keyArg, opts) => {
|
|
735
|
+
.action(async (serviceArg, keyArg, opts, command) => {
|
|
708
736
|
await executeToolCommand(opts, "store_key", {
|
|
709
|
-
service: requiredInput(opts, serviceArg, "service", "--service"),
|
|
710
|
-
key: requiredInput(opts, keyArg, "key", "--key"),
|
|
737
|
+
service: requiredInput(command, opts, serviceArg, "service", "--service"),
|
|
738
|
+
key: requiredInput(command, opts, keyArg, "key", "--key"),
|
|
711
739
|
label: opts.label,
|
|
712
740
|
metadata: opts.metadata,
|
|
713
741
|
});
|
|
@@ -774,41 +802,45 @@ function registerCuratedCommands(program, shared) {
|
|
|
774
802
|
displayToolResult(getToolDefinition("submit_plan"), data);
|
|
775
803
|
});
|
|
776
804
|
shared(planCmd.command("approve").description("Approve and execute a submitted plan"))
|
|
777
|
-
.usage("
|
|
778
|
-
.argument("
|
|
805
|
+
.usage("[planId] [options]")
|
|
806
|
+
.argument("[planId]", "plan ID")
|
|
779
807
|
.option("--plan-id <id>", "plan ID")
|
|
780
808
|
.addHelpText("after", "\nExamples:\n spongewallet plan approve plan_123\n")
|
|
781
|
-
.action(async (planIdArg, opts) => {
|
|
809
|
+
.action(async (planIdArg, opts, command) => {
|
|
810
|
+
const planId = requiredInput(command, opts, planIdArg, "planId", "--plan-id");
|
|
782
811
|
const wallet = await connectWallet(opts);
|
|
783
|
-
const data = await wallet.approvePlan(
|
|
812
|
+
const data = await wallet.approvePlan(planId);
|
|
784
813
|
displayToolResult(getToolDefinition("approve_plan"), data);
|
|
785
814
|
});
|
|
786
815
|
const tradeCmd = program.command("trade").description("Single trade proposal flow");
|
|
787
816
|
shared(tradeCmd.command("propose").description("Propose a trade for approval"))
|
|
788
|
-
.usage("
|
|
789
|
-
.argument("
|
|
790
|
-
.argument("
|
|
791
|
-
.argument("
|
|
817
|
+
.usage("[from] [to] [amount] --reason <text> [options]")
|
|
818
|
+
.argument("[from]", "input token")
|
|
819
|
+
.argument("[to]", "output token")
|
|
820
|
+
.argument("[amount]", "amount to trade")
|
|
792
821
|
.option("--from <token>", "input token")
|
|
793
822
|
.option("--to <token>", "output token")
|
|
794
823
|
.option("--amount <amount>", "amount to trade")
|
|
795
824
|
.requiredOption("--reason <text>", "reason shown to the user")
|
|
796
825
|
.addHelpText("after", "\nExamples:\n spongewallet trade propose ETH USDC 0.5 --reason \"Reduce exposure\"\n")
|
|
797
|
-
.action(async (fromArg, toArg, amountArg, opts) => {
|
|
826
|
+
.action(async (fromArg, toArg, amountArg, opts, command) => {
|
|
827
|
+
const inputToken = requiredInput(command, opts, fromArg, "from", "--from");
|
|
828
|
+
const outputToken = requiredInput(command, opts, toArg, "to", "--to");
|
|
829
|
+
const amount = requiredInput(command, opts, amountArg, "amount", "--amount");
|
|
798
830
|
const wallet = await connectWallet(opts);
|
|
799
831
|
const data = await wallet.proposeTrade({
|
|
800
|
-
input_token:
|
|
801
|
-
output_token:
|
|
802
|
-
amount
|
|
832
|
+
input_token: inputToken,
|
|
833
|
+
output_token: outputToken,
|
|
834
|
+
amount,
|
|
803
835
|
reason: String(opts.reason),
|
|
804
836
|
});
|
|
805
837
|
displayToolResult(getToolDefinition("propose_trade"), data);
|
|
806
838
|
});
|
|
807
839
|
const authCmd = program.command("auth").description("Authentication helpers");
|
|
808
840
|
shared(authCmd.command("siwe").description("Generate a SIWE signature"))
|
|
809
|
-
.usage("
|
|
810
|
-
.argument("
|
|
811
|
-
.argument("
|
|
841
|
+
.usage("[domain] [uri] [options]")
|
|
842
|
+
.argument("[domain]", "requesting domain")
|
|
843
|
+
.argument("[uri]", "resource URI")
|
|
812
844
|
.option("--domain <domain>", "requesting domain")
|
|
813
845
|
.option("--uri <uri>", "resource URI")
|
|
814
846
|
.option("--statement <text>", "human-readable statement")
|
|
@@ -817,10 +849,10 @@ function registerCuratedCommands(program, shared) {
|
|
|
817
849
|
.option("--not-before <iso>", "not before time")
|
|
818
850
|
.option("--resources <json>", "resources array as JSON", parseJsonValue)
|
|
819
851
|
.addHelpText("after", "\nExamples:\n spongewallet auth siwe app.example.com https://app.example.com\n")
|
|
820
|
-
.action(async (domainArg, uriArg, opts) => {
|
|
852
|
+
.action(async (domainArg, uriArg, opts, command) => {
|
|
821
853
|
await executeToolCommand(opts, "generate_siwe", {
|
|
822
|
-
domain: requiredInput(opts, domainArg, "domain", "--domain"),
|
|
823
|
-
uri: requiredInput(opts, uriArg, "uri", "--uri"),
|
|
854
|
+
domain: requiredInput(command, opts, domainArg, "domain", "--domain"),
|
|
855
|
+
uri: requiredInput(command, opts, uriArg, "uri", "--uri"),
|
|
824
856
|
statement: opts.statement,
|
|
825
857
|
chain_id: opts.chainId,
|
|
826
858
|
expiration_time: opts.expirationTime,
|
|
@@ -881,10 +913,10 @@ function registerCuratedCommands(program, shared) {
|
|
|
881
913
|
});
|
|
882
914
|
});
|
|
883
915
|
shared(hyperliquidCmd.command("order").description("Place a Hyperliquid order"))
|
|
884
|
-
.argument("
|
|
885
|
-
.argument("
|
|
886
|
-
.argument("
|
|
887
|
-
.argument("
|
|
916
|
+
.argument("[symbol]", "market symbol")
|
|
917
|
+
.argument("[side]", "buy or sell")
|
|
918
|
+
.argument("[type]", "order type")
|
|
919
|
+
.argument("[amount]", "order amount")
|
|
888
920
|
.argument("[price]", "limit price")
|
|
889
921
|
.option("--symbol <symbol>", "market symbol")
|
|
890
922
|
.option("--side <side>", "buy or sell")
|
|
@@ -892,23 +924,23 @@ function registerCuratedCommands(program, shared) {
|
|
|
892
924
|
.option("--amount <amount>", "order amount")
|
|
893
925
|
.option("--price <price>", "limit price")
|
|
894
926
|
.addHelpText("after", "\nExamples:\n spongewallet market hyperliquid order ETH buy market 0.1\n spongewallet market hyperliquid order ETH buy limit 0.1 3000\n")
|
|
895
|
-
.action(async (symbolArg, sideArg, typeArg, amountArg, priceArg, opts) => {
|
|
927
|
+
.action(async (symbolArg, sideArg, typeArg, amountArg, priceArg, opts, command) => {
|
|
896
928
|
await executeHyperliquidAction(opts, {
|
|
897
929
|
action: "order",
|
|
898
|
-
symbol: requiredInput(opts, symbolArg, "symbol", "--symbol"),
|
|
899
|
-
side: requiredInput(opts, sideArg, "side", "--side"),
|
|
900
|
-
type: requiredInput(opts, typeArg, "type", "--type"),
|
|
901
|
-
amount: requiredInput(opts, amountArg, "amount", "--amount"),
|
|
930
|
+
symbol: requiredInput(command, opts, symbolArg, "symbol", "--symbol"),
|
|
931
|
+
side: requiredInput(command, opts, sideArg, "side", "--side"),
|
|
932
|
+
type: requiredInput(command, opts, typeArg, "type", "--type"),
|
|
933
|
+
amount: requiredInput(command, opts, amountArg, "amount", "--amount"),
|
|
902
934
|
price: priceArg ?? opts.price,
|
|
903
935
|
});
|
|
904
936
|
});
|
|
905
937
|
shared(hyperliquidCmd.command("cancel").description("Cancel a Hyperliquid order"))
|
|
906
|
-
.argument("
|
|
938
|
+
.argument("[orderId]", "order ID")
|
|
907
939
|
.option("--order-id <id>", "order ID")
|
|
908
|
-
.action(async (orderIdArg, opts) => {
|
|
940
|
+
.action(async (orderIdArg, opts, command) => {
|
|
909
941
|
await executeHyperliquidAction(opts, {
|
|
910
942
|
action: "cancel",
|
|
911
|
-
order_id: requiredInput(opts, orderIdArg, "orderId", "--order-id"),
|
|
943
|
+
order_id: requiredInput(command, opts, orderIdArg, "orderId", "--order-id"),
|
|
912
944
|
});
|
|
913
945
|
});
|
|
914
946
|
shared(hyperliquidCmd.command("cancel-all").description("Cancel all Hyperliquid orders"))
|
|
@@ -916,14 +948,14 @@ function registerCuratedCommands(program, shared) {
|
|
|
916
948
|
await executeHyperliquidAction(opts, { action: "cancel_all" });
|
|
917
949
|
});
|
|
918
950
|
shared(hyperliquidCmd.command("leverage").description("Set Hyperliquid leverage"))
|
|
919
|
-
.argument("
|
|
920
|
-
.argument("
|
|
951
|
+
.argument("[symbol]", "market symbol")
|
|
952
|
+
.argument("[leverage]", "leverage")
|
|
921
953
|
.option("--symbol <symbol>", "market symbol")
|
|
922
954
|
.option("--leverage <n>", "leverage", parseFloat)
|
|
923
|
-
.action(async (symbolArg, leverageArg, opts) => {
|
|
955
|
+
.action(async (symbolArg, leverageArg, opts, command) => {
|
|
924
956
|
await executeHyperliquidAction(opts, {
|
|
925
957
|
action: "set_leverage",
|
|
926
|
-
symbol: requiredInput(opts, symbolArg, "symbol", "--symbol"),
|
|
958
|
+
symbol: requiredInput(command, opts, symbolArg, "symbol", "--symbol"),
|
|
927
959
|
leverage: leverageArg !== undefined ? parseFloat(leverageArg) : opts.leverage,
|
|
928
960
|
});
|
|
929
961
|
});
|