@tasknet-protocol/cli 0.4.0 → 0.6.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 +337 -285
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9,6 +9,68 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/config.ts
|
|
13
|
+
var config_exports = {};
|
|
14
|
+
__export(config_exports, {
|
|
15
|
+
clearConfig: () => clearConfig,
|
|
16
|
+
config: () => config,
|
|
17
|
+
getConfig: () => getConfig,
|
|
18
|
+
getConfigPath: () => getConfigPath,
|
|
19
|
+
setConfig: () => setConfig
|
|
20
|
+
});
|
|
21
|
+
import Conf from "conf";
|
|
22
|
+
function getConfig() {
|
|
23
|
+
return {
|
|
24
|
+
apiUrl: config.get("apiUrl"),
|
|
25
|
+
apiKey: config.get("apiKey"),
|
|
26
|
+
network: config.get("network"),
|
|
27
|
+
rpcUrl: config.get("rpcUrl"),
|
|
28
|
+
packageId: config.get("packageId"),
|
|
29
|
+
walrusAggregator: config.get("walrusAggregator"),
|
|
30
|
+
walrusPublisher: config.get("walrusPublisher"),
|
|
31
|
+
agentId: config.get("agentId"),
|
|
32
|
+
agentName: config.get("agentName"),
|
|
33
|
+
outputFormat: config.get("outputFormat")
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function setConfig(key, value) {
|
|
37
|
+
config.set(key, value);
|
|
38
|
+
}
|
|
39
|
+
function clearConfig() {
|
|
40
|
+
config.clear();
|
|
41
|
+
}
|
|
42
|
+
function getConfigPath() {
|
|
43
|
+
return config.path;
|
|
44
|
+
}
|
|
45
|
+
var defaults, config;
|
|
46
|
+
var init_config = __esm({
|
|
47
|
+
"src/config.ts"() {
|
|
48
|
+
"use strict";
|
|
49
|
+
defaults = {
|
|
50
|
+
apiUrl: "http://localhost:3000",
|
|
51
|
+
network: "testnet",
|
|
52
|
+
outputFormat: "table"
|
|
53
|
+
};
|
|
54
|
+
config = new Conf({
|
|
55
|
+
projectName: "tasknet-cli",
|
|
56
|
+
projectVersion: "0.6.0",
|
|
57
|
+
defaults,
|
|
58
|
+
schema: {
|
|
59
|
+
apiUrl: { type: "string" },
|
|
60
|
+
apiKey: { type: "string" },
|
|
61
|
+
network: { type: "string", enum: ["mainnet", "testnet", "devnet", "localnet"] },
|
|
62
|
+
rpcUrl: { type: "string" },
|
|
63
|
+
packageId: { type: "string" },
|
|
64
|
+
walrusAggregator: { type: "string" },
|
|
65
|
+
walrusPublisher: { type: "string" },
|
|
66
|
+
agentId: { type: "string" },
|
|
67
|
+
agentName: { type: "string" },
|
|
68
|
+
outputFormat: { type: "string", enum: ["table", "json"] }
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
12
74
|
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
13
75
|
import * as nc from "crypto";
|
|
14
76
|
var crypto;
|
|
@@ -12406,57 +12468,13 @@ var init_cryptography = __esm({
|
|
|
12406
12468
|
|
|
12407
12469
|
// src/index.ts
|
|
12408
12470
|
import { Command as Command2 } from "commander";
|
|
12409
|
-
import
|
|
12471
|
+
import chalk3 from "chalk";
|
|
12410
12472
|
|
|
12411
|
-
// src/config.ts
|
|
12412
|
-
|
|
12413
|
-
var defaults = {
|
|
12414
|
-
apiUrl: "http://localhost:3000",
|
|
12415
|
-
network: "testnet",
|
|
12416
|
-
outputFormat: "table"
|
|
12417
|
-
};
|
|
12418
|
-
var config = new Conf({
|
|
12419
|
-
projectName: "tasknet-cli",
|
|
12420
|
-
projectVersion: "0.4.0",
|
|
12421
|
-
defaults,
|
|
12422
|
-
schema: {
|
|
12423
|
-
apiUrl: { type: "string" },
|
|
12424
|
-
apiKey: { type: "string" },
|
|
12425
|
-
network: { type: "string", enum: ["mainnet", "testnet", "devnet", "localnet"] },
|
|
12426
|
-
rpcUrl: { type: "string" },
|
|
12427
|
-
packageId: { type: "string" },
|
|
12428
|
-
walrusAggregator: { type: "string" },
|
|
12429
|
-
walrusPublisher: { type: "string" },
|
|
12430
|
-
agentId: { type: "string" },
|
|
12431
|
-
agentName: { type: "string" },
|
|
12432
|
-
outputFormat: { type: "string", enum: ["table", "json"] }
|
|
12433
|
-
}
|
|
12434
|
-
});
|
|
12435
|
-
function getConfig() {
|
|
12436
|
-
return {
|
|
12437
|
-
apiUrl: config.get("apiUrl"),
|
|
12438
|
-
apiKey: config.get("apiKey"),
|
|
12439
|
-
network: config.get("network"),
|
|
12440
|
-
rpcUrl: config.get("rpcUrl"),
|
|
12441
|
-
packageId: config.get("packageId"),
|
|
12442
|
-
walrusAggregator: config.get("walrusAggregator"),
|
|
12443
|
-
walrusPublisher: config.get("walrusPublisher"),
|
|
12444
|
-
agentId: config.get("agentId"),
|
|
12445
|
-
agentName: config.get("agentName"),
|
|
12446
|
-
outputFormat: config.get("outputFormat")
|
|
12447
|
-
};
|
|
12448
|
-
}
|
|
12449
|
-
function setConfig(key, value) {
|
|
12450
|
-
config.set(key, value);
|
|
12451
|
-
}
|
|
12452
|
-
function clearConfig() {
|
|
12453
|
-
config.clear();
|
|
12454
|
-
}
|
|
12455
|
-
function getConfigPath() {
|
|
12456
|
-
return config.path;
|
|
12457
|
-
}
|
|
12473
|
+
// src/commands/config.ts
|
|
12474
|
+
init_config();
|
|
12458
12475
|
|
|
12459
12476
|
// src/utils.ts
|
|
12477
|
+
init_config();
|
|
12460
12478
|
import chalk from "chalk";
|
|
12461
12479
|
import ora from "ora";
|
|
12462
12480
|
var colors = {
|
|
@@ -12536,6 +12554,19 @@ function output(data, tableFormatter) {
|
|
|
12536
12554
|
jsonOutput(data);
|
|
12537
12555
|
}
|
|
12538
12556
|
}
|
|
12557
|
+
function requireConfig(key) {
|
|
12558
|
+
const config2 = getConfig();
|
|
12559
|
+
const value = config2[key];
|
|
12560
|
+
if (!value) {
|
|
12561
|
+
error(`Missing configuration: ${key}`);
|
|
12562
|
+
error(`Run: tasknet config set ${key} <value>`);
|
|
12563
|
+
process.exit(1);
|
|
12564
|
+
}
|
|
12565
|
+
return value;
|
|
12566
|
+
}
|
|
12567
|
+
function requireApiKey() {
|
|
12568
|
+
return requireConfig("apiKey");
|
|
12569
|
+
}
|
|
12539
12570
|
|
|
12540
12571
|
// src/commands/config.ts
|
|
12541
12572
|
function registerConfigCommands(program2) {
|
|
@@ -12630,6 +12661,7 @@ Valid keys: ${validKeys.join(", ")}`);
|
|
|
12630
12661
|
}
|
|
12631
12662
|
|
|
12632
12663
|
// src/client.ts
|
|
12664
|
+
init_config();
|
|
12633
12665
|
import { TaskNetClient } from "@tasknet-protocol/sdk";
|
|
12634
12666
|
var clientInstance = null;
|
|
12635
12667
|
function getClient() {
|
|
@@ -12649,6 +12681,7 @@ function getClient() {
|
|
|
12649
12681
|
}
|
|
12650
12682
|
|
|
12651
12683
|
// src/commands/agent.ts
|
|
12684
|
+
init_config();
|
|
12652
12685
|
function generateSignatureChallenge(agentId, action, timestamp) {
|
|
12653
12686
|
return `TaskNet Verification
|
|
12654
12687
|
|
|
@@ -13300,6 +13333,7 @@ ${colors.primary("Search Results")} for "${query}"
|
|
|
13300
13333
|
|
|
13301
13334
|
// src/commands/task.ts
|
|
13302
13335
|
import { STATUS } from "@tasknet-protocol/shared";
|
|
13336
|
+
init_config();
|
|
13303
13337
|
function registerTaskCommands(program2) {
|
|
13304
13338
|
const taskCmd = program2.command("task").alias("tasks").description("Manage tasks");
|
|
13305
13339
|
taskCmd.command("list").description("List tasks").option("-p, --page <number>", "Page number", "1").option("-l, --limit <number>", "Items per page", "20").option("-s, --status <status>", "Filter by status (0-9)").option("--skill <id>", "Filter by skill ID").option("--requester <id>", "Filter by requester agent ID").option("--worker <id>", "Filter by worker agent ID").option("--mine", "Show my tasks (as requester or worker)").option("--available", "Show only available tasks (Posted status)").option("--sort <field>", "Sort by: created_at, expires_at, payment, priority", "created_at").option("-o, --order <dir>", "Sort order: asc, desc", "desc").action(async (options) => {
|
|
@@ -13457,7 +13491,7 @@ ${colors.primary("Recent Events")}
|
|
|
13457
13491
|
${colors.primary("Watching for tasks...")} (Ctrl+C to stop)
|
|
13458
13492
|
`);
|
|
13459
13493
|
const interval = parseInt(options.interval) * 1e3;
|
|
13460
|
-
|
|
13494
|
+
const seenTasks = /* @__PURE__ */ new Set();
|
|
13461
13495
|
const poll = async () => {
|
|
13462
13496
|
try {
|
|
13463
13497
|
const client = getClient();
|
|
@@ -13552,220 +13586,14 @@ ${colors.primary("Statistics")}
|
|
|
13552
13586
|
});
|
|
13553
13587
|
}
|
|
13554
13588
|
|
|
13555
|
-
// src/commands/
|
|
13589
|
+
// src/commands/badge.ts
|
|
13556
13590
|
import chalk2 from "chalk";
|
|
13557
13591
|
import ora2 from "ora";
|
|
13558
|
-
import { CLAIM_LABELS } from "@tasknet-protocol/shared";
|
|
13559
|
-
function registerClaimCommands(program2) {
|
|
13560
|
-
const claim = program2.command("claim").description("Manage identity claims and verification");
|
|
13561
|
-
claim.command("generate").description("Generate a verification code for identity claims").option(
|
|
13562
|
-
"-t, --type <type>",
|
|
13563
|
-
"Claim type: x, github, moltbook, wallet",
|
|
13564
|
-
"wallet"
|
|
13565
|
-
).action(async (options) => {
|
|
13566
|
-
const spin = ora2("Generating claim...").start();
|
|
13567
|
-
try {
|
|
13568
|
-
const client = getClient();
|
|
13569
|
-
const typeMap = {
|
|
13570
|
-
x: 1,
|
|
13571
|
-
twitter: 1,
|
|
13572
|
-
moltbook: 2,
|
|
13573
|
-
github: 3,
|
|
13574
|
-
wallet: 4
|
|
13575
|
-
};
|
|
13576
|
-
const claimType = typeMap[options.type.toLowerCase()] ?? 0;
|
|
13577
|
-
const result = await client.api.generateClaim(claimType);
|
|
13578
|
-
spin.succeed("Claim generated successfully");
|
|
13579
|
-
output(result, () => {
|
|
13580
|
-
let out = `
|
|
13581
|
-
${colors.primary("Claim Details")}
|
|
13582
|
-
|
|
13583
|
-
`;
|
|
13584
|
-
out += `${colors.muted("ID:")} ${result.claim.id}
|
|
13585
|
-
`;
|
|
13586
|
-
out += `${colors.muted("Type:")} ${getClaimTypeLabel(result.claim.claim_type)}
|
|
13587
|
-
`;
|
|
13588
|
-
out += `${colors.muted("Status:")} ${chalk2.yellow(result.claim.status)}
|
|
13589
|
-
`;
|
|
13590
|
-
out += `${colors.muted("Created:")} ${result.claim.created_at}
|
|
13591
|
-
`;
|
|
13592
|
-
out += `
|
|
13593
|
-
${colors.primary("Verification Code")}
|
|
13594
|
-
`;
|
|
13595
|
-
out += `${chalk2.cyan(result.claim.verification_code)}
|
|
13596
|
-
`;
|
|
13597
|
-
out += `
|
|
13598
|
-
${colors.primary("Instructions")}
|
|
13599
|
-
`;
|
|
13600
|
-
out += `${result.instructions}
|
|
13601
|
-
`;
|
|
13602
|
-
return out;
|
|
13603
|
-
});
|
|
13604
|
-
} catch (error2) {
|
|
13605
|
-
spin.fail(chalk2.red("Failed to generate claim"));
|
|
13606
|
-
const err = error2;
|
|
13607
|
-
console.error(chalk2.red(err.message));
|
|
13608
|
-
process.exit(1);
|
|
13609
|
-
}
|
|
13610
|
-
});
|
|
13611
|
-
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) => {
|
|
13612
|
-
const spin = ora2("Verifying claim...").start();
|
|
13613
|
-
try {
|
|
13614
|
-
const client = getClient();
|
|
13615
|
-
const result = await client.api.verifyClaim({
|
|
13616
|
-
claimId,
|
|
13617
|
-
proofUrl: options.url,
|
|
13618
|
-
signature: options.signature
|
|
13619
|
-
});
|
|
13620
|
-
spin.succeed("Claim verified successfully");
|
|
13621
|
-
output(result, () => {
|
|
13622
|
-
let out = `
|
|
13623
|
-
${colors.primary("Verified Claim")}
|
|
13624
|
-
|
|
13625
|
-
`;
|
|
13626
|
-
out += `${colors.muted("ID:")} ${result.claim.id}
|
|
13627
|
-
`;
|
|
13628
|
-
out += `${colors.muted("Type:")} ${result.claim.claim_type_label}
|
|
13629
|
-
`;
|
|
13630
|
-
out += `${colors.muted("Status:")} ${chalk2.green(result.claim.status)}
|
|
13631
|
-
`;
|
|
13632
|
-
out += `${colors.muted("Claimed By:")} ${result.claim.claimed_by ?? "N/A"}
|
|
13633
|
-
`;
|
|
13634
|
-
out += `${colors.muted("Verified At:")} ${result.claim.verified_at ?? "N/A"}
|
|
13635
|
-
`;
|
|
13636
|
-
return out;
|
|
13637
|
-
});
|
|
13638
|
-
} catch (error2) {
|
|
13639
|
-
spin.fail(chalk2.red("Failed to verify claim"));
|
|
13640
|
-
const err = error2;
|
|
13641
|
-
console.error(chalk2.red(err.message));
|
|
13642
|
-
process.exit(1);
|
|
13643
|
-
}
|
|
13644
|
-
});
|
|
13645
|
-
claim.command("get <claimId>").description("Get details of a specific claim").action(async (claimId) => {
|
|
13646
|
-
const spin = ora2("Fetching claim...").start();
|
|
13647
|
-
try {
|
|
13648
|
-
const client = getClient();
|
|
13649
|
-
const claimData = await client.api.getClaim(claimId);
|
|
13650
|
-
spin.succeed("Claim fetched");
|
|
13651
|
-
output(claimData, () => {
|
|
13652
|
-
let out = `
|
|
13653
|
-
${colors.primary("Claim Details")}
|
|
13654
|
-
|
|
13655
|
-
`;
|
|
13656
|
-
out += `${colors.muted("ID:")} ${claimData.id}
|
|
13657
|
-
`;
|
|
13658
|
-
out += `${colors.muted("Agent ID:")} ${formatAddress(claimData.agent_id)}
|
|
13659
|
-
`;
|
|
13660
|
-
out += `${colors.muted("Type:")} ${claimData.claim_type_label}
|
|
13661
|
-
`;
|
|
13662
|
-
out += `${colors.muted("Status:")} ${getStatusColor2(claimData.status)}
|
|
13663
|
-
`;
|
|
13664
|
-
out += `${colors.muted("Verification Code:")} ${claimData.verification_code.slice(0, 30)}...
|
|
13665
|
-
`;
|
|
13666
|
-
out += `${colors.muted("Claimed By:")} ${claimData.claimed_by ?? "N/A"}
|
|
13667
|
-
`;
|
|
13668
|
-
out += `${colors.muted("Created At:")} ${claimData.created_at}
|
|
13669
|
-
`;
|
|
13670
|
-
out += `${colors.muted("Verified At:")} ${claimData.verified_at ?? "N/A"}
|
|
13671
|
-
`;
|
|
13672
|
-
out += `
|
|
13673
|
-
${colors.primary("Agent")}
|
|
13674
|
-
`;
|
|
13675
|
-
out += `${colors.muted("ID:")} ${claimData.agent.id}
|
|
13676
|
-
`;
|
|
13677
|
-
out += `${colors.muted("Owner:")} ${formatAddress(claimData.agent.owner)}
|
|
13678
|
-
`;
|
|
13679
|
-
return out;
|
|
13680
|
-
});
|
|
13681
|
-
} catch (error2) {
|
|
13682
|
-
spin.fail(chalk2.red("Failed to fetch claim"));
|
|
13683
|
-
const err = error2;
|
|
13684
|
-
console.error(chalk2.red(err.message));
|
|
13685
|
-
process.exit(1);
|
|
13686
|
-
}
|
|
13687
|
-
});
|
|
13688
|
-
claim.command("revoke <claimId>").description("Revoke a verified claim").action(async (claimId) => {
|
|
13689
|
-
const spin = ora2("Revoking claim...").start();
|
|
13690
|
-
try {
|
|
13691
|
-
const client = getClient();
|
|
13692
|
-
await client.api.revokeClaim(claimId);
|
|
13693
|
-
spin.succeed("Claim revoked successfully");
|
|
13694
|
-
} catch (error2) {
|
|
13695
|
-
spin.fail(chalk2.red("Failed to revoke claim"));
|
|
13696
|
-
const err = error2;
|
|
13697
|
-
console.error(chalk2.red(err.message));
|
|
13698
|
-
process.exit(1);
|
|
13699
|
-
}
|
|
13700
|
-
});
|
|
13701
|
-
claim.command("list").description("List claims for the current agent").action(async () => {
|
|
13702
|
-
const spin = ora2("Fetching claims...").start();
|
|
13703
|
-
try {
|
|
13704
|
-
const client = getClient();
|
|
13705
|
-
const agentId = client.getAgentId();
|
|
13706
|
-
if (!agentId) {
|
|
13707
|
-
spin.fail("No active agent set. Use 'tasknet config set agentId <id>'");
|
|
13708
|
-
process.exit(1);
|
|
13709
|
-
}
|
|
13710
|
-
const agent = await client.api.getAgent(agentId);
|
|
13711
|
-
spin.succeed(`Found ${agent.claims.length} claims`);
|
|
13712
|
-
output(agent.claims, () => {
|
|
13713
|
-
if (agent.claims.length === 0) {
|
|
13714
|
-
return `
|
|
13715
|
-
${chalk2.yellow("No claims found.")}
|
|
13716
|
-
Generate a claim with: tasknet claim generate -t wallet
|
|
13717
|
-
`;
|
|
13718
|
-
}
|
|
13719
|
-
let out = `
|
|
13720
|
-
${colors.primary("Claims")}
|
|
13721
|
-
|
|
13722
|
-
`;
|
|
13723
|
-
out += `${colors.muted("ID".padEnd(20))} ${colors.muted("Type".padEnd(15))} ${colors.muted("Claimed By".padEnd(22))} ${colors.muted("Verified At")}
|
|
13724
|
-
`;
|
|
13725
|
-
out += `${colors.muted("-".repeat(20))} ${colors.muted("-".repeat(15))} ${colors.muted("-".repeat(22))} ${colors.muted("-".repeat(20))}
|
|
13726
|
-
`;
|
|
13727
|
-
for (const c of agent.claims) {
|
|
13728
|
-
const id = c.id.slice(0, 18) + "..";
|
|
13729
|
-
const type = getClaimTypeLabel(c.claim_type).padEnd(15);
|
|
13730
|
-
const claimedBy = (c.claimed_by?.slice(0, 20) ?? "N/A").padEnd(22);
|
|
13731
|
-
const verifiedAt = c.verified_at ?? chalk2.yellow("Pending");
|
|
13732
|
-
out += `${id} ${type} ${claimedBy} ${verifiedAt}
|
|
13733
|
-
`;
|
|
13734
|
-
}
|
|
13735
|
-
return out;
|
|
13736
|
-
});
|
|
13737
|
-
} catch (error2) {
|
|
13738
|
-
spin.fail(chalk2.red("Failed to fetch claims"));
|
|
13739
|
-
const err = error2;
|
|
13740
|
-
console.error(chalk2.red(err.message));
|
|
13741
|
-
process.exit(1);
|
|
13742
|
-
}
|
|
13743
|
-
});
|
|
13744
|
-
}
|
|
13745
|
-
function getClaimTypeLabel(type) {
|
|
13746
|
-
return CLAIM_LABELS[type] ?? `Type ${type}`;
|
|
13747
|
-
}
|
|
13748
|
-
function getStatusColor2(status) {
|
|
13749
|
-
switch (status) {
|
|
13750
|
-
case "verified":
|
|
13751
|
-
return chalk2.green(status);
|
|
13752
|
-
case "pending":
|
|
13753
|
-
return chalk2.yellow(status);
|
|
13754
|
-
case "revoked":
|
|
13755
|
-
return chalk2.red(status);
|
|
13756
|
-
default:
|
|
13757
|
-
return status;
|
|
13758
|
-
}
|
|
13759
|
-
}
|
|
13760
|
-
|
|
13761
|
-
// src/commands/badge.ts
|
|
13762
|
-
import chalk3 from "chalk";
|
|
13763
|
-
import ora3 from "ora";
|
|
13764
13592
|
import { BADGE_TIER } from "@tasknet-protocol/shared";
|
|
13765
13593
|
function registerBadgeCommands(program2) {
|
|
13766
13594
|
const badge = program2.command("badge").description("View agent reputation badges");
|
|
13767
13595
|
badge.command("list [agentId]").description("List badges for an agent (defaults to current agent)").action(async (agentId) => {
|
|
13768
|
-
const spin =
|
|
13596
|
+
const spin = ora2("Fetching badges...").start();
|
|
13769
13597
|
try {
|
|
13770
13598
|
const client = getClient();
|
|
13771
13599
|
const targetId = agentId ?? client.getAgentId();
|
|
@@ -13778,7 +13606,7 @@ function registerBadgeCommands(program2) {
|
|
|
13778
13606
|
output(agent.badges, () => {
|
|
13779
13607
|
if (agent.badges.length === 0) {
|
|
13780
13608
|
return `
|
|
13781
|
-
${
|
|
13609
|
+
${chalk2.yellow("No badges earned yet.")}
|
|
13782
13610
|
Complete tasks and verify your identity to earn badges!
|
|
13783
13611
|
`;
|
|
13784
13612
|
}
|
|
@@ -13807,17 +13635,17 @@ ${colors.primary(`Badges for ${targetId.slice(0, 16)}...`)}
|
|
|
13807
13635
|
out += `
|
|
13808
13636
|
${colors.primary("Summary")}
|
|
13809
13637
|
`;
|
|
13810
|
-
out += ` ${
|
|
13811
|
-
out += `${
|
|
13812
|
-
out += `${
|
|
13813
|
-
out += `${
|
|
13638
|
+
out += ` ${chalk2.hex("#CD7F32")("\u25CF")} Bronze: ${tierCounts.bronze} `;
|
|
13639
|
+
out += `${chalk2.gray("\u25CF")} Silver: ${tierCounts.silver} `;
|
|
13640
|
+
out += `${chalk2.yellow("\u25CF")} Gold: ${tierCounts.gold} `;
|
|
13641
|
+
out += `${chalk2.magenta("\u25CF")} Platinum: ${tierCounts.platinum}
|
|
13814
13642
|
`;
|
|
13815
13643
|
return out;
|
|
13816
13644
|
});
|
|
13817
13645
|
} catch (error2) {
|
|
13818
|
-
spin.fail(
|
|
13646
|
+
spin.fail(chalk2.red("Failed to fetch badges"));
|
|
13819
13647
|
const err = error2;
|
|
13820
|
-
console.error(
|
|
13648
|
+
console.error(chalk2.red(err.message));
|
|
13821
13649
|
process.exit(1);
|
|
13822
13650
|
}
|
|
13823
13651
|
});
|
|
@@ -13877,28 +13705,28 @@ ${colors.primary("Available Badges")}
|
|
|
13877
13705
|
}
|
|
13878
13706
|
];
|
|
13879
13707
|
for (const b of badges) {
|
|
13880
|
-
out += ` ${b.icon} ${
|
|
13708
|
+
out += ` ${b.icon} ${chalk2.bold(formatBadgeType(b.type))}
|
|
13881
13709
|
`;
|
|
13882
|
-
out += ` ${
|
|
13710
|
+
out += ` ${chalk2.gray(b.description)}
|
|
13883
13711
|
`;
|
|
13884
|
-
out += ` ${
|
|
13712
|
+
out += ` ${chalk2.cyan("How to earn:")} ${b.howToEarn}
|
|
13885
13713
|
|
|
13886
13714
|
`;
|
|
13887
13715
|
}
|
|
13888
13716
|
out += `${colors.primary("Tiers")}
|
|
13889
13717
|
`;
|
|
13890
|
-
out += ` ${
|
|
13718
|
+
out += ` ${chalk2.hex("#CD7F32")("\u25CF")} Bronze - Entry level
|
|
13891
13719
|
`;
|
|
13892
|
-
out += ` ${
|
|
13720
|
+
out += ` ${chalk2.gray("\u25CF")} Silver - Intermediate
|
|
13893
13721
|
`;
|
|
13894
|
-
out += ` ${
|
|
13722
|
+
out += ` ${chalk2.yellow("\u25CF")} Gold - Advanced
|
|
13895
13723
|
`;
|
|
13896
|
-
out += ` ${
|
|
13724
|
+
out += ` ${chalk2.magenta("\u25CF")} Platinum - Expert
|
|
13897
13725
|
`;
|
|
13898
13726
|
console.log(out);
|
|
13899
13727
|
});
|
|
13900
13728
|
badge.command("showcase [agentId]").description("Display badges in a showcase format").action(async (agentId) => {
|
|
13901
|
-
const spin =
|
|
13729
|
+
const spin = ora2("Loading showcase...").start();
|
|
13902
13730
|
try {
|
|
13903
13731
|
const client = getClient();
|
|
13904
13732
|
const targetId = agentId ?? client.getAgentId();
|
|
@@ -13909,7 +13737,7 @@ ${colors.primary("Available Badges")}
|
|
|
13909
13737
|
const agent = await client.api.getAgent(targetId);
|
|
13910
13738
|
spin.stop();
|
|
13911
13739
|
if (agent.badges.length === 0) {
|
|
13912
|
-
console.log(
|
|
13740
|
+
console.log(chalk2.yellow("\nNo badges to showcase yet."));
|
|
13913
13741
|
return;
|
|
13914
13742
|
}
|
|
13915
13743
|
const byTier = {};
|
|
@@ -13918,7 +13746,7 @@ ${colors.primary("Available Badges")}
|
|
|
13918
13746
|
byTier[b.tier].push(b);
|
|
13919
13747
|
}
|
|
13920
13748
|
let out = `
|
|
13921
|
-
${
|
|
13749
|
+
${chalk2.bold.underline("\u{1F3C6} Badge Showcase")}
|
|
13922
13750
|
|
|
13923
13751
|
`;
|
|
13924
13752
|
for (const tier of [3, 2, 1, 0]) {
|
|
@@ -13926,7 +13754,7 @@ ${chalk3.bold.underline("\u{1F3C6} Badge Showcase")}
|
|
|
13926
13754
|
if (!tierBadges || tierBadges.length === 0) continue;
|
|
13927
13755
|
const tierName = getTierName(tier);
|
|
13928
13756
|
const tierColor = getTierColor(tier);
|
|
13929
|
-
out += tierColor(
|
|
13757
|
+
out += tierColor(chalk2.bold(`\u2501\u2501\u2501 ${tierName.toUpperCase()} \u2501\u2501\u2501`)) + "\n\n";
|
|
13930
13758
|
for (const b of tierBadges) {
|
|
13931
13759
|
out += ` ${getBadgeIcon(b.badge_type)} ${formatBadgeType(b.badge_type)}
|
|
13932
13760
|
`;
|
|
@@ -13946,9 +13774,9 @@ ${chalk3.bold.underline("\u{1F3C6} Badge Showcase")}
|
|
|
13946
13774
|
}
|
|
13947
13775
|
console.log(out);
|
|
13948
13776
|
} catch (error2) {
|
|
13949
|
-
spin.fail(
|
|
13777
|
+
spin.fail(chalk2.red("Failed to load showcase"));
|
|
13950
13778
|
const err = error2;
|
|
13951
|
-
console.error(
|
|
13779
|
+
console.error(chalk2.red(err.message));
|
|
13952
13780
|
process.exit(1);
|
|
13953
13781
|
}
|
|
13954
13782
|
});
|
|
@@ -13983,21 +13811,245 @@ function getTierDisplay(tier) {
|
|
|
13983
13811
|
function getTierColor(tier) {
|
|
13984
13812
|
switch (tier) {
|
|
13985
13813
|
case BADGE_TIER.BRONZE:
|
|
13986
|
-
return
|
|
13814
|
+
return chalk2.hex("#CD7F32");
|
|
13987
13815
|
case BADGE_TIER.SILVER:
|
|
13988
|
-
return
|
|
13816
|
+
return chalk2.gray;
|
|
13989
13817
|
case BADGE_TIER.GOLD:
|
|
13990
|
-
return
|
|
13818
|
+
return chalk2.yellow;
|
|
13991
13819
|
case 3:
|
|
13992
|
-
return
|
|
13820
|
+
return chalk2.magenta;
|
|
13993
13821
|
default:
|
|
13994
|
-
return
|
|
13822
|
+
return chalk2.white;
|
|
13995
13823
|
}
|
|
13996
13824
|
}
|
|
13997
13825
|
|
|
13826
|
+
// src/commands/claim.ts
|
|
13827
|
+
import { CLAIM_TYPE, CLAIM_TYPE_LABELS, CLAIM_STATUS_LABELS } from "@tasknet-protocol/shared";
|
|
13828
|
+
function registerClaimCommands(program2) {
|
|
13829
|
+
const claimCmd = program2.command("claim").description("Identity verification commands");
|
|
13830
|
+
claimCmd.command("generate <type>").description("Generate a verification claim").addHelpText(
|
|
13831
|
+
"after",
|
|
13832
|
+
`
|
|
13833
|
+
Claim Types:
|
|
13834
|
+
twitter - Verify via Twitter/X post
|
|
13835
|
+
moltbook - Verify via Moltbook post
|
|
13836
|
+
github - Verify via GitHub Gist
|
|
13837
|
+
wallet - Verify via wallet signature
|
|
13838
|
+
|
|
13839
|
+
Examples:
|
|
13840
|
+
$ tasknet claim generate twitter
|
|
13841
|
+
$ tasknet claim generate github
|
|
13842
|
+
$ tasknet claim generate wallet
|
|
13843
|
+
`
|
|
13844
|
+
).action(async (type) => {
|
|
13845
|
+
await requireApiKey();
|
|
13846
|
+
const client = getClient();
|
|
13847
|
+
const typeMap = {
|
|
13848
|
+
twitter: CLAIM_TYPE.TWITTER,
|
|
13849
|
+
x: CLAIM_TYPE.TWITTER,
|
|
13850
|
+
moltbook: CLAIM_TYPE.MOLTBOOK,
|
|
13851
|
+
github: CLAIM_TYPE.GITHUB,
|
|
13852
|
+
wallet: CLAIM_TYPE.WALLET
|
|
13853
|
+
};
|
|
13854
|
+
const claimType = typeMap[type.toLowerCase()];
|
|
13855
|
+
if (claimType === void 0) {
|
|
13856
|
+
error(`Invalid claim type: ${type}`);
|
|
13857
|
+
log("Valid types: twitter, moltbook, github, wallet");
|
|
13858
|
+
process.exit(1);
|
|
13859
|
+
}
|
|
13860
|
+
const spin = spinner(`Generating ${type} claim...`).start();
|
|
13861
|
+
try {
|
|
13862
|
+
const result = await client.api.generateClaim(claimType);
|
|
13863
|
+
spin.stop();
|
|
13864
|
+
success(`Claim generated successfully!
|
|
13865
|
+
`);
|
|
13866
|
+
output(result, () => {
|
|
13867
|
+
let str = `${colors.primary("Claim Details")}
|
|
13868
|
+
|
|
13869
|
+
`;
|
|
13870
|
+
str += ` Claim ID: ${result.claim_id}
|
|
13871
|
+
`;
|
|
13872
|
+
str += ` Type: ${result.claim_type}
|
|
13873
|
+
`;
|
|
13874
|
+
str += ` Status: ${result.status}
|
|
13875
|
+
`;
|
|
13876
|
+
str += ` Code: ${colors.success(result.verification_code)}
|
|
13877
|
+
|
|
13878
|
+
`;
|
|
13879
|
+
str += `${colors.primary("Instructions")}
|
|
13880
|
+
|
|
13881
|
+
`;
|
|
13882
|
+
str += ` ${result.instructions.split("\n").join("\n ")}
|
|
13883
|
+
|
|
13884
|
+
`;
|
|
13885
|
+
str += `${colors.muted("Next step:")}
|
|
13886
|
+
`;
|
|
13887
|
+
str += ` After completing the verification step, run:
|
|
13888
|
+
`;
|
|
13889
|
+
str += ` tasknet claim verify ${result.claim_id} <post_url_or_signature>
|
|
13890
|
+
`;
|
|
13891
|
+
return str;
|
|
13892
|
+
});
|
|
13893
|
+
} catch (err) {
|
|
13894
|
+
spin.stop();
|
|
13895
|
+
error(`Failed to generate claim: ${err.message}`);
|
|
13896
|
+
process.exit(1);
|
|
13897
|
+
}
|
|
13898
|
+
});
|
|
13899
|
+
claimCmd.command("verify <claim-id> <proof>").description("Verify a pending claim with post URL or signature").addHelpText(
|
|
13900
|
+
"after",
|
|
13901
|
+
`
|
|
13902
|
+
Arguments:
|
|
13903
|
+
claim-id - The claim ID from 'claim generate'
|
|
13904
|
+
proof - Post URL (twitter/moltbook/github) or wallet signature
|
|
13905
|
+
|
|
13906
|
+
Examples:
|
|
13907
|
+
$ tasknet claim verify abc123 https://twitter.com/user/status/123456789
|
|
13908
|
+
$ tasknet claim verify abc123 https://gist.github.com/user/abc123
|
|
13909
|
+
$ tasknet claim verify abc123 <base64-signature>
|
|
13910
|
+
`
|
|
13911
|
+
).action(async (claimId, proof) => {
|
|
13912
|
+
await requireApiKey();
|
|
13913
|
+
const client = getClient();
|
|
13914
|
+
const spin = spinner("Verifying claim...").start();
|
|
13915
|
+
try {
|
|
13916
|
+
const isUrl = proof.startsWith("http");
|
|
13917
|
+
const result = await client.api.verifyClaim({
|
|
13918
|
+
claimId,
|
|
13919
|
+
postUrl: isUrl ? proof : void 0,
|
|
13920
|
+
signature: !isUrl ? proof : void 0
|
|
13921
|
+
});
|
|
13922
|
+
spin.stop();
|
|
13923
|
+
success(`Claim verified successfully!
|
|
13924
|
+
`);
|
|
13925
|
+
output(result, () => {
|
|
13926
|
+
let str = `${colors.primary("Verification Result")}
|
|
13927
|
+
|
|
13928
|
+
`;
|
|
13929
|
+
str += ` Claim ID: ${result.claim_id}
|
|
13930
|
+
`;
|
|
13931
|
+
str += ` Type: ${result.claim_type}
|
|
13932
|
+
`;
|
|
13933
|
+
str += ` Handle: ${result.verified_handle || "N/A"}
|
|
13934
|
+
`;
|
|
13935
|
+
str += ` Verified: ${result.verified_at}
|
|
13936
|
+
`;
|
|
13937
|
+
if (result.badge_awarded) {
|
|
13938
|
+
str += `
|
|
13939
|
+
\u{1F3C5} Badge Awarded: ${result.badge_awarded}
|
|
13940
|
+
`;
|
|
13941
|
+
}
|
|
13942
|
+
return str;
|
|
13943
|
+
});
|
|
13944
|
+
} catch (err) {
|
|
13945
|
+
spin.stop();
|
|
13946
|
+
error(`Verification failed: ${err.message}`);
|
|
13947
|
+
process.exit(1);
|
|
13948
|
+
}
|
|
13949
|
+
});
|
|
13950
|
+
claimCmd.command("status <claim-id>").description("Get claim status").action(async (claimId) => {
|
|
13951
|
+
const client = getClient();
|
|
13952
|
+
const spin = spinner("Fetching claim...").start();
|
|
13953
|
+
try {
|
|
13954
|
+
const result = await client.api.getClaim(claimId);
|
|
13955
|
+
spin.stop();
|
|
13956
|
+
output(result, () => {
|
|
13957
|
+
let str = `${colors.primary("Claim Details")}
|
|
13958
|
+
|
|
13959
|
+
`;
|
|
13960
|
+
str += ` ID: ${result.id}
|
|
13961
|
+
`;
|
|
13962
|
+
str += ` Agent: ${result.agent_id}
|
|
13963
|
+
`;
|
|
13964
|
+
str += ` Type: ${result.claim_type_label}
|
|
13965
|
+
`;
|
|
13966
|
+
str += ` Status: ${result.status_label}
|
|
13967
|
+
`;
|
|
13968
|
+
if (result.verification_code) {
|
|
13969
|
+
str += ` Code: ${result.verification_code}
|
|
13970
|
+
`;
|
|
13971
|
+
}
|
|
13972
|
+
if (result.verified_handle) {
|
|
13973
|
+
str += ` Handle: ${result.verified_handle}
|
|
13974
|
+
`;
|
|
13975
|
+
}
|
|
13976
|
+
if (result.post_url) {
|
|
13977
|
+
str += ` Post URL: ${result.post_url}
|
|
13978
|
+
`;
|
|
13979
|
+
}
|
|
13980
|
+
str += ` Created: ${result.created_at}
|
|
13981
|
+
`;
|
|
13982
|
+
if (result.verified_at) {
|
|
13983
|
+
str += ` Verified: ${result.verified_at}
|
|
13984
|
+
`;
|
|
13985
|
+
}
|
|
13986
|
+
if (result.revoked_at) {
|
|
13987
|
+
str += ` Revoked: ${result.revoked_at}
|
|
13988
|
+
`;
|
|
13989
|
+
}
|
|
13990
|
+
return str;
|
|
13991
|
+
});
|
|
13992
|
+
} catch (err) {
|
|
13993
|
+
spin.stop();
|
|
13994
|
+
error(`Failed to fetch claim: ${err.message}`);
|
|
13995
|
+
process.exit(1);
|
|
13996
|
+
}
|
|
13997
|
+
});
|
|
13998
|
+
claimCmd.command("revoke <claim-id>").description("Revoke a verification claim").action(async (claimId) => {
|
|
13999
|
+
await requireApiKey();
|
|
14000
|
+
const client = getClient();
|
|
14001
|
+
const spin = spinner("Revoking claim...").start();
|
|
14002
|
+
try {
|
|
14003
|
+
const result = await client.api.revokeClaim(claimId);
|
|
14004
|
+
spin.stop();
|
|
14005
|
+
success(result.message);
|
|
14006
|
+
} catch (err) {
|
|
14007
|
+
spin.stop();
|
|
14008
|
+
error(`Failed to revoke claim: ${err.message}`);
|
|
14009
|
+
process.exit(1);
|
|
14010
|
+
}
|
|
14011
|
+
});
|
|
14012
|
+
claimCmd.command("list").description("List your claims (requires linked agent)").action(async () => {
|
|
14013
|
+
await requireApiKey();
|
|
14014
|
+
const client = getClient();
|
|
14015
|
+
const spin = spinner("Fetching claims...").start();
|
|
14016
|
+
try {
|
|
14017
|
+
const config2 = await Promise.resolve().then(() => (init_config(), config_exports)).then((m) => m.getConfig());
|
|
14018
|
+
if (!config2.agentId) {
|
|
14019
|
+
spin.stop();
|
|
14020
|
+
error("No agent linked. Use 'tasknet agent link' first.");
|
|
14021
|
+
process.exit(1);
|
|
14022
|
+
}
|
|
14023
|
+
const agent = await client.api.getAgent(config2.agentId);
|
|
14024
|
+
spin.stop();
|
|
14025
|
+
if (!agent.claims || agent.claims.length === 0) {
|
|
14026
|
+
log("No claims found for this agent.\n");
|
|
14027
|
+
log("Generate a claim with: tasknet claim generate <type>");
|
|
14028
|
+
return;
|
|
14029
|
+
}
|
|
14030
|
+
log(`
|
|
14031
|
+
${colors.primary("Your Claims")}
|
|
14032
|
+
`);
|
|
14033
|
+
const table2 = agent.claims.map((c) => ({
|
|
14034
|
+
ID: c.id.slice(0, 8) + "...",
|
|
14035
|
+
Type: c.claim_type_label || CLAIM_TYPE_LABELS[c.claim_type] || "Unknown",
|
|
14036
|
+
Status: c.status_label || CLAIM_STATUS_LABELS[c.status] || "Unknown",
|
|
14037
|
+
Handle: c.verified_handle || "-",
|
|
14038
|
+
"Verified At": c.verified_at || "-"
|
|
14039
|
+
}));
|
|
14040
|
+
console.table(table2);
|
|
14041
|
+
} catch (err) {
|
|
14042
|
+
spin.stop();
|
|
14043
|
+
error(`Failed to list claims: ${err.message}`);
|
|
14044
|
+
process.exit(1);
|
|
14045
|
+
}
|
|
14046
|
+
});
|
|
14047
|
+
}
|
|
14048
|
+
|
|
13998
14049
|
// src/index.ts
|
|
14050
|
+
init_config();
|
|
13999
14051
|
var program = new Command2();
|
|
14000
|
-
var banner =
|
|
14052
|
+
var banner = chalk3.cyan(`
|
|
14001
14053
|
\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
|
|
14002
14054
|
\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
|
|
14003
14055
|
\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
|
|
@@ -14005,7 +14057,7 @@ var banner = chalk4.cyan(`
|
|
|
14005
14057
|
\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
|
|
14006
14058
|
\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
|
|
14007
14059
|
`);
|
|
14008
|
-
program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.
|
|
14060
|
+
program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.6.0").addHelpText("beforeAll", banner).option("--json", "Output as JSON").hook("preAction", (thisCommand) => {
|
|
14009
14061
|
const opts = thisCommand.opts();
|
|
14010
14062
|
if (opts.json) {
|
|
14011
14063
|
const config2 = getConfig();
|
|
@@ -14016,8 +14068,8 @@ registerConfigCommands(program);
|
|
|
14016
14068
|
registerAgentCommands(program);
|
|
14017
14069
|
registerSkillCommands(program);
|
|
14018
14070
|
registerTaskCommands(program);
|
|
14019
|
-
registerClaimCommands(program);
|
|
14020
14071
|
registerBadgeCommands(program);
|
|
14072
|
+
registerClaimCommands(program);
|
|
14021
14073
|
registerHealthCommand(program);
|
|
14022
14074
|
program.parse();
|
|
14023
14075
|
/*! Bundled license information:
|