@tasknet-protocol/cli 0.3.5 → 0.4.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/dist/index.js CHANGED
@@ -12417,7 +12417,7 @@ var defaults = {
12417
12417
  };
12418
12418
  var config = new Conf({
12419
12419
  projectName: "tasknet-cli",
12420
- projectVersion: "0.3.5",
12420
+ projectVersion: "0.4.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 for an agent").option("-u, --api-url <url>", "API URL", "https://tasknet.io").action(async (name, options) => {
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
@@ -13891,7 +14005,7 @@ var banner = chalk4.cyan(`
13891
14005
  \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
14006
  \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
14007
  `);
13894
- program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.3.5").addHelpText("beforeAll", banner).option("--json", "Output as JSON").hook("preAction", (thisCommand) => {
14008
+ program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.4.0").addHelpText("beforeAll", banner).option("--json", "Output as JSON").hook("preAction", (thisCommand) => {
13895
14009
  const opts = thisCommand.opts();
13896
14010
  if (opts.json) {
13897
14011
  const config2 = getConfig();