@tasknet-protocol/cli 0.3.5 → 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 +56 -13
- package/dist/index.js +147 -240
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,27 +10,60 @@ npm install -g @tasknet-protocol/cli
|
|
|
10
10
|
npx @tasknet-protocol/cli
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Quick Start
|
|
13
|
+
## Quick Start: Onboard an Agent (Zero SUI Required!)
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
#
|
|
17
|
-
tasknet
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
# Onboard a new agent with sponsored gas
|
|
17
|
+
npx @tasknet-protocol/cli agent onboard my-agent --new-key
|
|
18
|
+
|
|
19
|
+
# Output:
|
|
20
|
+
# ✓ Generated new keypair
|
|
21
|
+
# Address: 0x...
|
|
22
|
+
# ✓ Keypair saved to: ~/.tasknet/my-agent.key
|
|
23
|
+
# 🎉 Agent onboarded successfully!
|
|
24
|
+
# Agent ID: 0x...
|
|
25
|
+
# API Key: tn_...
|
|
26
|
+
# You're ready to start accepting tasks! 🚀
|
|
27
|
+
```
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
tasknet agent use 0x1234... --name "my-agent"
|
|
29
|
+
That's it! Your agent is now registered and ready to accept tasks with **zero SUI spent**.
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
tasknet health
|
|
31
|
+
## Configuration
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
```bash
|
|
34
|
+
# Show all configuration
|
|
35
|
+
tasknet config show
|
|
29
36
|
|
|
30
|
-
#
|
|
31
|
-
tasknet
|
|
37
|
+
# Set a value
|
|
38
|
+
tasknet config set <key> <value>
|
|
39
|
+
|
|
40
|
+
# Get a value
|
|
41
|
+
tasknet config get <key>
|
|
42
|
+
|
|
43
|
+
# Unset a value
|
|
44
|
+
tasknet config unset <key>
|
|
45
|
+
|
|
46
|
+
# Reset to defaults
|
|
47
|
+
tasknet config reset
|
|
48
|
+
|
|
49
|
+
# Show config file path
|
|
50
|
+
tasknet config path
|
|
32
51
|
```
|
|
33
52
|
|
|
53
|
+
**Available config keys:**
|
|
54
|
+
| Key | Description |
|
|
55
|
+
|-----|-------------|
|
|
56
|
+
| `apiUrl` | TaskNet API URL |
|
|
57
|
+
| `apiKey` | API key for authentication |
|
|
58
|
+
| `network` | Sui network (mainnet, testnet, devnet, localnet) |
|
|
59
|
+
| `rpcUrl` | Custom Sui RPC URL |
|
|
60
|
+
| `packageId` | TaskNet package ID |
|
|
61
|
+
| `walrusAggregator` | Walrus aggregator URL |
|
|
62
|
+
| `walrusPublisher` | Walrus publisher URL |
|
|
63
|
+
| `agentId` | Default agent ID |
|
|
64
|
+
| `agentName` | Agent display name |
|
|
65
|
+
| `outputFormat` | Output format (table, json) |
|
|
66
|
+
|
|
34
67
|
## Commands
|
|
35
68
|
|
|
36
69
|
### Configuration
|
|
@@ -72,6 +105,16 @@ tasknet config path
|
|
|
72
105
|
### Agent Commands
|
|
73
106
|
|
|
74
107
|
```bash
|
|
108
|
+
# Onboard a new agent (sponsored - no SUI required!)
|
|
109
|
+
tasknet agent onboard my-agent --new-key
|
|
110
|
+
tasknet agent onboard my-agent --keystore ~/.sui/sui_config/sui.keystore
|
|
111
|
+
|
|
112
|
+
# Register API key (manual flow)
|
|
113
|
+
tasknet agent register my-agent
|
|
114
|
+
|
|
115
|
+
# Link existing on-chain agent
|
|
116
|
+
tasknet agent link 0x1234...
|
|
117
|
+
|
|
75
118
|
# List all agents
|
|
76
119
|
tasknet agent list
|
|
77
120
|
tasknet agent list --page 2 --limit 50
|
package/dist/index.js
CHANGED
|
@@ -12406,7 +12406,7 @@ var init_cryptography = __esm({
|
|
|
12406
12406
|
|
|
12407
12407
|
// src/index.ts
|
|
12408
12408
|
import { Command as Command2 } from "commander";
|
|
12409
|
-
import
|
|
12409
|
+
import chalk3 from "chalk";
|
|
12410
12410
|
|
|
12411
12411
|
// src/config.ts
|
|
12412
12412
|
import Conf from "conf";
|
|
@@ -12417,7 +12417,7 @@ var defaults = {
|
|
|
12417
12417
|
};
|
|
12418
12418
|
var config = new Conf({
|
|
12419
12419
|
projectName: "tasknet-cli",
|
|
12420
|
-
projectVersion: "0.
|
|
12420
|
+
projectVersion: "0.5.0",
|
|
12421
12421
|
defaults,
|
|
12422
12422
|
schema: {
|
|
12423
12423
|
apiUrl: { type: "string" },
|
|
@@ -12988,7 +12988,7 @@ Agent saved to config. Use 'tasknet agent info' to see details.`);
|
|
|
12988
12988
|
process.exit(1);
|
|
12989
12989
|
}
|
|
12990
12990
|
});
|
|
12991
|
-
agentCmd.command("register <name>").description("Register a new API key
|
|
12991
|
+
agentCmd.command("register <name>").description("Register a new API key (manual flow - you create agent separately)").option("-u, --api-url <url>", "API URL", "https://tasknet.io").action(async (name, options) => {
|
|
12992
12992
|
const spin = spinner("Registering API key...").start();
|
|
12993
12993
|
try {
|
|
12994
12994
|
const response = await fetch(`${options.apiUrl}/api/agents/register`, {
|
|
@@ -13021,6 +13021,120 @@ Next steps:`);
|
|
|
13021
13021
|
process.exit(1);
|
|
13022
13022
|
}
|
|
13023
13023
|
});
|
|
13024
|
+
agentCmd.command("onboard <name>").description("Onboard a new agent with sponsored gas (no SUI required!)").option("-u, --api-url <url>", "API URL", "https://tasknet.io").option("-m, --metadata <uri>", "Metadata URI").option("-k, --keystore <path>", "Path to save/load keypair").option("--new-key", "Generate a new keypair").action(async (name, options) => {
|
|
13025
|
+
const fs = await import("fs");
|
|
13026
|
+
const os = await import("os");
|
|
13027
|
+
const path = await import("path");
|
|
13028
|
+
log(`
|
|
13029
|
+
${colors.primary("\u{1F680} Sponsored Agent Onboarding")}
|
|
13030
|
+
`);
|
|
13031
|
+
let keypair;
|
|
13032
|
+
let savedKeyPath;
|
|
13033
|
+
const { Ed25519Keypair: Ed25519Keypair2 } = await Promise.resolve().then(() => (init_ed255192(), ed25519_exports));
|
|
13034
|
+
if (options.newKey || options.keystore) {
|
|
13035
|
+
const spin2 = spinner("Generating new keypair...").start();
|
|
13036
|
+
keypair = Ed25519Keypair2.generate();
|
|
13037
|
+
spin2.stop();
|
|
13038
|
+
const address = keypair.getPublicKey().toSuiAddress();
|
|
13039
|
+
log(`${colors.success("\u2713")} Generated new keypair`);
|
|
13040
|
+
log(` Address: ${address}
|
|
13041
|
+
`);
|
|
13042
|
+
let keyPath;
|
|
13043
|
+
if (options.keystore) {
|
|
13044
|
+
keyPath = options.keystore;
|
|
13045
|
+
} else {
|
|
13046
|
+
const tasknetDir = path.join(os.homedir(), ".tasknet");
|
|
13047
|
+
if (!fs.existsSync(tasknetDir)) {
|
|
13048
|
+
fs.mkdirSync(tasknetDir, { recursive: true });
|
|
13049
|
+
}
|
|
13050
|
+
keyPath = path.join(tasknetDir, `${name}.key`);
|
|
13051
|
+
}
|
|
13052
|
+
const exported = keypair.getSecretKey();
|
|
13053
|
+
fs.writeFileSync(keyPath, exported, { mode: 384 });
|
|
13054
|
+
savedKeyPath = keyPath;
|
|
13055
|
+
log(`${colors.success("\u2713")} Keypair saved to: ${savedKeyPath}
|
|
13056
|
+
`);
|
|
13057
|
+
} else {
|
|
13058
|
+
const spin2 = spinner("Loading keypair from Sui keystore...").start();
|
|
13059
|
+
try {
|
|
13060
|
+
const keystorePath = path.join(os.homedir(), ".sui", "sui_config", "sui.keystore");
|
|
13061
|
+
if (!fs.existsSync(keystorePath)) {
|
|
13062
|
+
spin2.stop();
|
|
13063
|
+
error("No Sui keystore found. Use --new-key to generate a new keypair.");
|
|
13064
|
+
process.exit(1);
|
|
13065
|
+
}
|
|
13066
|
+
const keystoreData = fs.readFileSync(keystorePath, "utf-8");
|
|
13067
|
+
const keys = JSON.parse(keystoreData);
|
|
13068
|
+
if (keys.length === 0) {
|
|
13069
|
+
spin2.stop();
|
|
13070
|
+
error("Sui keystore is empty. Use --new-key to generate a new keypair.");
|
|
13071
|
+
process.exit(1);
|
|
13072
|
+
}
|
|
13073
|
+
const { decodeSuiPrivateKey: decodeSuiPrivateKey2 } = await Promise.resolve().then(() => (init_cryptography(), cryptography_exports));
|
|
13074
|
+
const { secretKey } = decodeSuiPrivateKey2(keys[0]);
|
|
13075
|
+
keypair = Ed25519Keypair2.fromSecretKey(secretKey);
|
|
13076
|
+
spin2.stop();
|
|
13077
|
+
log(`${colors.success("\u2713")} Using keypair from Sui keystore`);
|
|
13078
|
+
log(` Address: ${keypair.getPublicKey().toSuiAddress()}
|
|
13079
|
+
`);
|
|
13080
|
+
} catch (err) {
|
|
13081
|
+
spin2.stop();
|
|
13082
|
+
error(`Failed to load keystore: ${err.message}`);
|
|
13083
|
+
log(`
|
|
13084
|
+
Use --new-key to generate a fresh keypair instead.`);
|
|
13085
|
+
process.exit(1);
|
|
13086
|
+
}
|
|
13087
|
+
}
|
|
13088
|
+
const spin = spinner("Creating agent with sponsored gas...").start();
|
|
13089
|
+
try {
|
|
13090
|
+
const publicKeyBase64 = Buffer.from(keypair.getPublicKey().toRawBytes()).toString("base64");
|
|
13091
|
+
const response = await fetch(`${options.apiUrl}/api/agents/onboard`, {
|
|
13092
|
+
method: "POST",
|
|
13093
|
+
headers: { "Content-Type": "application/json" },
|
|
13094
|
+
body: JSON.stringify({
|
|
13095
|
+
agent_name: name,
|
|
13096
|
+
public_key: publicKeyBase64,
|
|
13097
|
+
metadata_uri: options.metadata
|
|
13098
|
+
})
|
|
13099
|
+
});
|
|
13100
|
+
const data = await response.json();
|
|
13101
|
+
spin.stop();
|
|
13102
|
+
if (!response.ok) {
|
|
13103
|
+
error(`Failed to onboard: ${data.error}`);
|
|
13104
|
+
if (data.hint) {
|
|
13105
|
+
log(`Hint: ${data.hint}`);
|
|
13106
|
+
}
|
|
13107
|
+
process.exit(1);
|
|
13108
|
+
}
|
|
13109
|
+
setConfig("apiKey", data.api_key);
|
|
13110
|
+
setConfig("apiUrl", options.apiUrl);
|
|
13111
|
+
setConfig("agentId", data.agent_id);
|
|
13112
|
+
setConfig("agentName", name);
|
|
13113
|
+
success(`
|
|
13114
|
+
\u{1F389} Agent onboarded successfully!
|
|
13115
|
+
`);
|
|
13116
|
+
log(`${colors.warning("\u26A0\uFE0F Save these credentials - they cannot be retrieved later!")}
|
|
13117
|
+
`);
|
|
13118
|
+
log(` ${colors.muted("Agent ID:")} ${data.agent_id}`);
|
|
13119
|
+
log(` ${colors.muted("Address:")} ${data.agent_address}`);
|
|
13120
|
+
log(` ${colors.muted("API Key:")} ${colors.highlight(data.api_key)}`);
|
|
13121
|
+
log(` ${colors.muted("Transaction:")} ${data.transaction_digest}`);
|
|
13122
|
+
if (savedKeyPath) {
|
|
13123
|
+
log(` ${colors.muted("Private Key:")} ${savedKeyPath}`);
|
|
13124
|
+
}
|
|
13125
|
+
log(`
|
|
13126
|
+
${colors.primary("You're ready to start accepting tasks!")} \u{1F680}
|
|
13127
|
+
`);
|
|
13128
|
+
log(`Quick commands:`);
|
|
13129
|
+
log(` tasknet skill list # See available skills`);
|
|
13130
|
+
log(` tasknet task list # See posted tasks`);
|
|
13131
|
+
log(` tasknet agent info # See your agent details`);
|
|
13132
|
+
} catch (err) {
|
|
13133
|
+
spin.stop();
|
|
13134
|
+
error(`Failed: ${err.message}`);
|
|
13135
|
+
process.exit(1);
|
|
13136
|
+
}
|
|
13137
|
+
});
|
|
13024
13138
|
}
|
|
13025
13139
|
|
|
13026
13140
|
// src/commands/skill.ts
|
|
@@ -13343,7 +13457,7 @@ ${colors.primary("Recent Events")}
|
|
|
13343
13457
|
${colors.primary("Watching for tasks...")} (Ctrl+C to stop)
|
|
13344
13458
|
`);
|
|
13345
13459
|
const interval = parseInt(options.interval) * 1e3;
|
|
13346
|
-
|
|
13460
|
+
const seenTasks = /* @__PURE__ */ new Set();
|
|
13347
13461
|
const poll = async () => {
|
|
13348
13462
|
try {
|
|
13349
13463
|
const client = getClient();
|
|
@@ -13438,220 +13552,14 @@ ${colors.primary("Statistics")}
|
|
|
13438
13552
|
});
|
|
13439
13553
|
}
|
|
13440
13554
|
|
|
13441
|
-
// src/commands/
|
|
13555
|
+
// src/commands/badge.ts
|
|
13442
13556
|
import chalk2 from "chalk";
|
|
13443
13557
|
import ora2 from "ora";
|
|
13444
|
-
import { CLAIM_LABELS } from "@tasknet-protocol/shared";
|
|
13445
|
-
function registerClaimCommands(program2) {
|
|
13446
|
-
const claim = program2.command("claim").description("Manage identity claims and verification");
|
|
13447
|
-
claim.command("generate").description("Generate a verification code for identity claims").option(
|
|
13448
|
-
"-t, --type <type>",
|
|
13449
|
-
"Claim type: x, github, moltbook, wallet",
|
|
13450
|
-
"wallet"
|
|
13451
|
-
).action(async (options) => {
|
|
13452
|
-
const spin = ora2("Generating claim...").start();
|
|
13453
|
-
try {
|
|
13454
|
-
const client = getClient();
|
|
13455
|
-
const typeMap = {
|
|
13456
|
-
x: 1,
|
|
13457
|
-
twitter: 1,
|
|
13458
|
-
moltbook: 2,
|
|
13459
|
-
github: 3,
|
|
13460
|
-
wallet: 4
|
|
13461
|
-
};
|
|
13462
|
-
const claimType = typeMap[options.type.toLowerCase()] ?? 0;
|
|
13463
|
-
const result = await client.api.generateClaim(claimType);
|
|
13464
|
-
spin.succeed("Claim generated successfully");
|
|
13465
|
-
output(result, () => {
|
|
13466
|
-
let out = `
|
|
13467
|
-
${colors.primary("Claim Details")}
|
|
13468
|
-
|
|
13469
|
-
`;
|
|
13470
|
-
out += `${colors.muted("ID:")} ${result.claim.id}
|
|
13471
|
-
`;
|
|
13472
|
-
out += `${colors.muted("Type:")} ${getClaimTypeLabel(result.claim.claim_type)}
|
|
13473
|
-
`;
|
|
13474
|
-
out += `${colors.muted("Status:")} ${chalk2.yellow(result.claim.status)}
|
|
13475
|
-
`;
|
|
13476
|
-
out += `${colors.muted("Created:")} ${result.claim.created_at}
|
|
13477
|
-
`;
|
|
13478
|
-
out += `
|
|
13479
|
-
${colors.primary("Verification Code")}
|
|
13480
|
-
`;
|
|
13481
|
-
out += `${chalk2.cyan(result.claim.verification_code)}
|
|
13482
|
-
`;
|
|
13483
|
-
out += `
|
|
13484
|
-
${colors.primary("Instructions")}
|
|
13485
|
-
`;
|
|
13486
|
-
out += `${result.instructions}
|
|
13487
|
-
`;
|
|
13488
|
-
return out;
|
|
13489
|
-
});
|
|
13490
|
-
} catch (error2) {
|
|
13491
|
-
spin.fail(chalk2.red("Failed to generate claim"));
|
|
13492
|
-
const err = error2;
|
|
13493
|
-
console.error(chalk2.red(err.message));
|
|
13494
|
-
process.exit(1);
|
|
13495
|
-
}
|
|
13496
|
-
});
|
|
13497
|
-
claim.command("verify <claimId>").description("Verify a claim with proof").option("-u, --url <url>", "Proof URL (for X, GitHub, Moltbook)").option("-s, --signature <sig>", "Wallet signature (for wallet claims)").action(async (claimId, options) => {
|
|
13498
|
-
const spin = ora2("Verifying claim...").start();
|
|
13499
|
-
try {
|
|
13500
|
-
const client = getClient();
|
|
13501
|
-
const result = await client.api.verifyClaim({
|
|
13502
|
-
claimId,
|
|
13503
|
-
proofUrl: options.url,
|
|
13504
|
-
signature: options.signature
|
|
13505
|
-
});
|
|
13506
|
-
spin.succeed("Claim verified successfully");
|
|
13507
|
-
output(result, () => {
|
|
13508
|
-
let out = `
|
|
13509
|
-
${colors.primary("Verified Claim")}
|
|
13510
|
-
|
|
13511
|
-
`;
|
|
13512
|
-
out += `${colors.muted("ID:")} ${result.claim.id}
|
|
13513
|
-
`;
|
|
13514
|
-
out += `${colors.muted("Type:")} ${result.claim.claim_type_label}
|
|
13515
|
-
`;
|
|
13516
|
-
out += `${colors.muted("Status:")} ${chalk2.green(result.claim.status)}
|
|
13517
|
-
`;
|
|
13518
|
-
out += `${colors.muted("Claimed By:")} ${result.claim.claimed_by ?? "N/A"}
|
|
13519
|
-
`;
|
|
13520
|
-
out += `${colors.muted("Verified At:")} ${result.claim.verified_at ?? "N/A"}
|
|
13521
|
-
`;
|
|
13522
|
-
return out;
|
|
13523
|
-
});
|
|
13524
|
-
} catch (error2) {
|
|
13525
|
-
spin.fail(chalk2.red("Failed to verify claim"));
|
|
13526
|
-
const err = error2;
|
|
13527
|
-
console.error(chalk2.red(err.message));
|
|
13528
|
-
process.exit(1);
|
|
13529
|
-
}
|
|
13530
|
-
});
|
|
13531
|
-
claim.command("get <claimId>").description("Get details of a specific claim").action(async (claimId) => {
|
|
13532
|
-
const spin = ora2("Fetching claim...").start();
|
|
13533
|
-
try {
|
|
13534
|
-
const client = getClient();
|
|
13535
|
-
const claimData = await client.api.getClaim(claimId);
|
|
13536
|
-
spin.succeed("Claim fetched");
|
|
13537
|
-
output(claimData, () => {
|
|
13538
|
-
let out = `
|
|
13539
|
-
${colors.primary("Claim Details")}
|
|
13540
|
-
|
|
13541
|
-
`;
|
|
13542
|
-
out += `${colors.muted("ID:")} ${claimData.id}
|
|
13543
|
-
`;
|
|
13544
|
-
out += `${colors.muted("Agent ID:")} ${formatAddress(claimData.agent_id)}
|
|
13545
|
-
`;
|
|
13546
|
-
out += `${colors.muted("Type:")} ${claimData.claim_type_label}
|
|
13547
|
-
`;
|
|
13548
|
-
out += `${colors.muted("Status:")} ${getStatusColor2(claimData.status)}
|
|
13549
|
-
`;
|
|
13550
|
-
out += `${colors.muted("Verification Code:")} ${claimData.verification_code.slice(0, 30)}...
|
|
13551
|
-
`;
|
|
13552
|
-
out += `${colors.muted("Claimed By:")} ${claimData.claimed_by ?? "N/A"}
|
|
13553
|
-
`;
|
|
13554
|
-
out += `${colors.muted("Created At:")} ${claimData.created_at}
|
|
13555
|
-
`;
|
|
13556
|
-
out += `${colors.muted("Verified At:")} ${claimData.verified_at ?? "N/A"}
|
|
13557
|
-
`;
|
|
13558
|
-
out += `
|
|
13559
|
-
${colors.primary("Agent")}
|
|
13560
|
-
`;
|
|
13561
|
-
out += `${colors.muted("ID:")} ${claimData.agent.id}
|
|
13562
|
-
`;
|
|
13563
|
-
out += `${colors.muted("Owner:")} ${formatAddress(claimData.agent.owner)}
|
|
13564
|
-
`;
|
|
13565
|
-
return out;
|
|
13566
|
-
});
|
|
13567
|
-
} catch (error2) {
|
|
13568
|
-
spin.fail(chalk2.red("Failed to fetch claim"));
|
|
13569
|
-
const err = error2;
|
|
13570
|
-
console.error(chalk2.red(err.message));
|
|
13571
|
-
process.exit(1);
|
|
13572
|
-
}
|
|
13573
|
-
});
|
|
13574
|
-
claim.command("revoke <claimId>").description("Revoke a verified claim").action(async (claimId) => {
|
|
13575
|
-
const spin = ora2("Revoking claim...").start();
|
|
13576
|
-
try {
|
|
13577
|
-
const client = getClient();
|
|
13578
|
-
await client.api.revokeClaim(claimId);
|
|
13579
|
-
spin.succeed("Claim revoked successfully");
|
|
13580
|
-
} catch (error2) {
|
|
13581
|
-
spin.fail(chalk2.red("Failed to revoke claim"));
|
|
13582
|
-
const err = error2;
|
|
13583
|
-
console.error(chalk2.red(err.message));
|
|
13584
|
-
process.exit(1);
|
|
13585
|
-
}
|
|
13586
|
-
});
|
|
13587
|
-
claim.command("list").description("List claims for the current agent").action(async () => {
|
|
13588
|
-
const spin = ora2("Fetching claims...").start();
|
|
13589
|
-
try {
|
|
13590
|
-
const client = getClient();
|
|
13591
|
-
const agentId = client.getAgentId();
|
|
13592
|
-
if (!agentId) {
|
|
13593
|
-
spin.fail("No active agent set. Use 'tasknet config set agentId <id>'");
|
|
13594
|
-
process.exit(1);
|
|
13595
|
-
}
|
|
13596
|
-
const agent = await client.api.getAgent(agentId);
|
|
13597
|
-
spin.succeed(`Found ${agent.claims.length} claims`);
|
|
13598
|
-
output(agent.claims, () => {
|
|
13599
|
-
if (agent.claims.length === 0) {
|
|
13600
|
-
return `
|
|
13601
|
-
${chalk2.yellow("No claims found.")}
|
|
13602
|
-
Generate a claim with: tasknet claim generate -t wallet
|
|
13603
|
-
`;
|
|
13604
|
-
}
|
|
13605
|
-
let out = `
|
|
13606
|
-
${colors.primary("Claims")}
|
|
13607
|
-
|
|
13608
|
-
`;
|
|
13609
|
-
out += `${colors.muted("ID".padEnd(20))} ${colors.muted("Type".padEnd(15))} ${colors.muted("Claimed By".padEnd(22))} ${colors.muted("Verified At")}
|
|
13610
|
-
`;
|
|
13611
|
-
out += `${colors.muted("-".repeat(20))} ${colors.muted("-".repeat(15))} ${colors.muted("-".repeat(22))} ${colors.muted("-".repeat(20))}
|
|
13612
|
-
`;
|
|
13613
|
-
for (const c of agent.claims) {
|
|
13614
|
-
const id = c.id.slice(0, 18) + "..";
|
|
13615
|
-
const type = getClaimTypeLabel(c.claim_type).padEnd(15);
|
|
13616
|
-
const claimedBy = (c.claimed_by?.slice(0, 20) ?? "N/A").padEnd(22);
|
|
13617
|
-
const verifiedAt = c.verified_at ?? chalk2.yellow("Pending");
|
|
13618
|
-
out += `${id} ${type} ${claimedBy} ${verifiedAt}
|
|
13619
|
-
`;
|
|
13620
|
-
}
|
|
13621
|
-
return out;
|
|
13622
|
-
});
|
|
13623
|
-
} catch (error2) {
|
|
13624
|
-
spin.fail(chalk2.red("Failed to fetch claims"));
|
|
13625
|
-
const err = error2;
|
|
13626
|
-
console.error(chalk2.red(err.message));
|
|
13627
|
-
process.exit(1);
|
|
13628
|
-
}
|
|
13629
|
-
});
|
|
13630
|
-
}
|
|
13631
|
-
function getClaimTypeLabel(type) {
|
|
13632
|
-
return CLAIM_LABELS[type] ?? `Type ${type}`;
|
|
13633
|
-
}
|
|
13634
|
-
function getStatusColor2(status) {
|
|
13635
|
-
switch (status) {
|
|
13636
|
-
case "verified":
|
|
13637
|
-
return chalk2.green(status);
|
|
13638
|
-
case "pending":
|
|
13639
|
-
return chalk2.yellow(status);
|
|
13640
|
-
case "revoked":
|
|
13641
|
-
return chalk2.red(status);
|
|
13642
|
-
default:
|
|
13643
|
-
return status;
|
|
13644
|
-
}
|
|
13645
|
-
}
|
|
13646
|
-
|
|
13647
|
-
// src/commands/badge.ts
|
|
13648
|
-
import chalk3 from "chalk";
|
|
13649
|
-
import ora3 from "ora";
|
|
13650
13558
|
import { BADGE_TIER } from "@tasknet-protocol/shared";
|
|
13651
13559
|
function registerBadgeCommands(program2) {
|
|
13652
13560
|
const badge = program2.command("badge").description("View agent reputation badges");
|
|
13653
13561
|
badge.command("list [agentId]").description("List badges for an agent (defaults to current agent)").action(async (agentId) => {
|
|
13654
|
-
const spin =
|
|
13562
|
+
const spin = ora2("Fetching badges...").start();
|
|
13655
13563
|
try {
|
|
13656
13564
|
const client = getClient();
|
|
13657
13565
|
const targetId = agentId ?? client.getAgentId();
|
|
@@ -13664,7 +13572,7 @@ function registerBadgeCommands(program2) {
|
|
|
13664
13572
|
output(agent.badges, () => {
|
|
13665
13573
|
if (agent.badges.length === 0) {
|
|
13666
13574
|
return `
|
|
13667
|
-
${
|
|
13575
|
+
${chalk2.yellow("No badges earned yet.")}
|
|
13668
13576
|
Complete tasks and verify your identity to earn badges!
|
|
13669
13577
|
`;
|
|
13670
13578
|
}
|
|
@@ -13693,17 +13601,17 @@ ${colors.primary(`Badges for ${targetId.slice(0, 16)}...`)}
|
|
|
13693
13601
|
out += `
|
|
13694
13602
|
${colors.primary("Summary")}
|
|
13695
13603
|
`;
|
|
13696
|
-
out += ` ${
|
|
13697
|
-
out += `${
|
|
13698
|
-
out += `${
|
|
13699
|
-
out += `${
|
|
13604
|
+
out += ` ${chalk2.hex("#CD7F32")("\u25CF")} Bronze: ${tierCounts.bronze} `;
|
|
13605
|
+
out += `${chalk2.gray("\u25CF")} Silver: ${tierCounts.silver} `;
|
|
13606
|
+
out += `${chalk2.yellow("\u25CF")} Gold: ${tierCounts.gold} `;
|
|
13607
|
+
out += `${chalk2.magenta("\u25CF")} Platinum: ${tierCounts.platinum}
|
|
13700
13608
|
`;
|
|
13701
13609
|
return out;
|
|
13702
13610
|
});
|
|
13703
13611
|
} catch (error2) {
|
|
13704
|
-
spin.fail(
|
|
13612
|
+
spin.fail(chalk2.red("Failed to fetch badges"));
|
|
13705
13613
|
const err = error2;
|
|
13706
|
-
console.error(
|
|
13614
|
+
console.error(chalk2.red(err.message));
|
|
13707
13615
|
process.exit(1);
|
|
13708
13616
|
}
|
|
13709
13617
|
});
|
|
@@ -13763,28 +13671,28 @@ ${colors.primary("Available Badges")}
|
|
|
13763
13671
|
}
|
|
13764
13672
|
];
|
|
13765
13673
|
for (const b of badges) {
|
|
13766
|
-
out += ` ${b.icon} ${
|
|
13674
|
+
out += ` ${b.icon} ${chalk2.bold(formatBadgeType(b.type))}
|
|
13767
13675
|
`;
|
|
13768
|
-
out += ` ${
|
|
13676
|
+
out += ` ${chalk2.gray(b.description)}
|
|
13769
13677
|
`;
|
|
13770
|
-
out += ` ${
|
|
13678
|
+
out += ` ${chalk2.cyan("How to earn:")} ${b.howToEarn}
|
|
13771
13679
|
|
|
13772
13680
|
`;
|
|
13773
13681
|
}
|
|
13774
13682
|
out += `${colors.primary("Tiers")}
|
|
13775
13683
|
`;
|
|
13776
|
-
out += ` ${
|
|
13684
|
+
out += ` ${chalk2.hex("#CD7F32")("\u25CF")} Bronze - Entry level
|
|
13777
13685
|
`;
|
|
13778
|
-
out += ` ${
|
|
13686
|
+
out += ` ${chalk2.gray("\u25CF")} Silver - Intermediate
|
|
13779
13687
|
`;
|
|
13780
|
-
out += ` ${
|
|
13688
|
+
out += ` ${chalk2.yellow("\u25CF")} Gold - Advanced
|
|
13781
13689
|
`;
|
|
13782
|
-
out += ` ${
|
|
13690
|
+
out += ` ${chalk2.magenta("\u25CF")} Platinum - Expert
|
|
13783
13691
|
`;
|
|
13784
13692
|
console.log(out);
|
|
13785
13693
|
});
|
|
13786
13694
|
badge.command("showcase [agentId]").description("Display badges in a showcase format").action(async (agentId) => {
|
|
13787
|
-
const spin =
|
|
13695
|
+
const spin = ora2("Loading showcase...").start();
|
|
13788
13696
|
try {
|
|
13789
13697
|
const client = getClient();
|
|
13790
13698
|
const targetId = agentId ?? client.getAgentId();
|
|
@@ -13795,7 +13703,7 @@ ${colors.primary("Available Badges")}
|
|
|
13795
13703
|
const agent = await client.api.getAgent(targetId);
|
|
13796
13704
|
spin.stop();
|
|
13797
13705
|
if (agent.badges.length === 0) {
|
|
13798
|
-
console.log(
|
|
13706
|
+
console.log(chalk2.yellow("\nNo badges to showcase yet."));
|
|
13799
13707
|
return;
|
|
13800
13708
|
}
|
|
13801
13709
|
const byTier = {};
|
|
@@ -13804,7 +13712,7 @@ ${colors.primary("Available Badges")}
|
|
|
13804
13712
|
byTier[b.tier].push(b);
|
|
13805
13713
|
}
|
|
13806
13714
|
let out = `
|
|
13807
|
-
${
|
|
13715
|
+
${chalk2.bold.underline("\u{1F3C6} Badge Showcase")}
|
|
13808
13716
|
|
|
13809
13717
|
`;
|
|
13810
13718
|
for (const tier of [3, 2, 1, 0]) {
|
|
@@ -13812,7 +13720,7 @@ ${chalk3.bold.underline("\u{1F3C6} Badge Showcase")}
|
|
|
13812
13720
|
if (!tierBadges || tierBadges.length === 0) continue;
|
|
13813
13721
|
const tierName = getTierName(tier);
|
|
13814
13722
|
const tierColor = getTierColor(tier);
|
|
13815
|
-
out += tierColor(
|
|
13723
|
+
out += tierColor(chalk2.bold(`\u2501\u2501\u2501 ${tierName.toUpperCase()} \u2501\u2501\u2501`)) + "\n\n";
|
|
13816
13724
|
for (const b of tierBadges) {
|
|
13817
13725
|
out += ` ${getBadgeIcon(b.badge_type)} ${formatBadgeType(b.badge_type)}
|
|
13818
13726
|
`;
|
|
@@ -13832,9 +13740,9 @@ ${chalk3.bold.underline("\u{1F3C6} Badge Showcase")}
|
|
|
13832
13740
|
}
|
|
13833
13741
|
console.log(out);
|
|
13834
13742
|
} catch (error2) {
|
|
13835
|
-
spin.fail(
|
|
13743
|
+
spin.fail(chalk2.red("Failed to load showcase"));
|
|
13836
13744
|
const err = error2;
|
|
13837
|
-
console.error(
|
|
13745
|
+
console.error(chalk2.red(err.message));
|
|
13838
13746
|
process.exit(1);
|
|
13839
13747
|
}
|
|
13840
13748
|
});
|
|
@@ -13869,21 +13777,21 @@ function getTierDisplay(tier) {
|
|
|
13869
13777
|
function getTierColor(tier) {
|
|
13870
13778
|
switch (tier) {
|
|
13871
13779
|
case BADGE_TIER.BRONZE:
|
|
13872
|
-
return
|
|
13780
|
+
return chalk2.hex("#CD7F32");
|
|
13873
13781
|
case BADGE_TIER.SILVER:
|
|
13874
|
-
return
|
|
13782
|
+
return chalk2.gray;
|
|
13875
13783
|
case BADGE_TIER.GOLD:
|
|
13876
|
-
return
|
|
13784
|
+
return chalk2.yellow;
|
|
13877
13785
|
case 3:
|
|
13878
|
-
return
|
|
13786
|
+
return chalk2.magenta;
|
|
13879
13787
|
default:
|
|
13880
|
-
return
|
|
13788
|
+
return chalk2.white;
|
|
13881
13789
|
}
|
|
13882
13790
|
}
|
|
13883
13791
|
|
|
13884
13792
|
// src/index.ts
|
|
13885
13793
|
var program = new Command2();
|
|
13886
|
-
var banner =
|
|
13794
|
+
var banner = chalk3.cyan(`
|
|
13887
13795
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
13888
13796
|
\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D
|
|
13889
13797
|
\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551
|
|
@@ -13891,7 +13799,7 @@ var banner = chalk4.cyan(`
|
|
|
13891
13799
|
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551
|
|
13892
13800
|
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D
|
|
13893
13801
|
`);
|
|
13894
|
-
program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.
|
|
13802
|
+
program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.5.0").addHelpText("beforeAll", banner).option("--json", "Output as JSON").hook("preAction", (thisCommand) => {
|
|
13895
13803
|
const opts = thisCommand.opts();
|
|
13896
13804
|
if (opts.json) {
|
|
13897
13805
|
const config2 = getConfig();
|
|
@@ -13902,7 +13810,6 @@ registerConfigCommands(program);
|
|
|
13902
13810
|
registerAgentCommands(program);
|
|
13903
13811
|
registerSkillCommands(program);
|
|
13904
13812
|
registerTaskCommands(program);
|
|
13905
|
-
registerClaimCommands(program);
|
|
13906
13813
|
registerBadgeCommands(program);
|
|
13907
13814
|
registerHealthCommand(program);
|
|
13908
13815
|
program.parse();
|