@tasknet-protocol/cli 0.6.0 → 0.7.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
@@ -13054,7 +13054,7 @@ Next steps:`);
13054
13054
  process.exit(1);
13055
13055
  }
13056
13056
  });
13057
- 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) => {
13057
+ 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("-r, --referral <code>", "Referral code from another agent").option("--new-key", "Generate a new keypair").action(async (name, options) => {
13058
13058
  const fs = await import("fs");
13059
13059
  const os = await import("os");
13060
13060
  const path = await import("path");
@@ -13127,7 +13127,8 @@ Use --new-key to generate a fresh keypair instead.`);
13127
13127
  body: JSON.stringify({
13128
13128
  agent_name: name,
13129
13129
  public_key: publicKeyBase64,
13130
- metadata_uri: options.metadata
13130
+ metadata_uri: options.metadata,
13131
+ referral_code: options.referral
13131
13132
  })
13132
13133
  });
13133
13134
  const data = await response.json();
@@ -13148,12 +13149,16 @@ Use --new-key to generate a fresh keypair instead.`);
13148
13149
  `);
13149
13150
  log(`${colors.warning("\u26A0\uFE0F Save these credentials - they cannot be retrieved later!")}
13150
13151
  `);
13151
- log(` ${colors.muted("Agent ID:")} ${data.agent_id}`);
13152
- log(` ${colors.muted("Address:")} ${data.agent_address}`);
13153
- log(` ${colors.muted("API Key:")} ${colors.highlight(data.api_key)}`);
13154
- log(` ${colors.muted("Transaction:")} ${data.transaction_digest}`);
13152
+ log(` ${colors.muted("Agent ID:")} ${data.agent_id}`);
13153
+ log(` ${colors.muted("Address:")} ${data.agent_address}`);
13154
+ log(` ${colors.muted("API Key:")} ${colors.highlight(data.api_key)}`);
13155
+ log(` ${colors.muted("Referral Code:")} ${data.referral_code}`);
13156
+ log(` ${colors.muted("Transaction:")} ${data.transaction_digest}`);
13155
13157
  if (savedKeyPath) {
13156
- log(` ${colors.muted("Private Key:")} ${savedKeyPath}`);
13158
+ log(` ${colors.muted("Private Key:")} ${savedKeyPath}`);
13159
+ }
13160
+ if (data.referred_by) {
13161
+ log(` ${colors.muted("Referred By:")} ${data.referred_by}`);
13157
13162
  }
13158
13163
  log(`
13159
13164
  ${colors.primary("You're ready to start accepting tasks!")} \u{1F680}
@@ -13162,12 +13167,97 @@ ${colors.primary("You're ready to start accepting tasks!")} \u{1F680}
13162
13167
  log(` tasknet skill list # See available skills`);
13163
13168
  log(` tasknet task list # See posted tasks`);
13164
13169
  log(` tasknet agent info # See your agent details`);
13170
+ log(` tasknet agent referral # Get your referral link`);
13165
13171
  } catch (err) {
13166
13172
  spin.stop();
13167
13173
  error(`Failed: ${err.message}`);
13168
13174
  process.exit(1);
13169
13175
  }
13170
13176
  });
13177
+ agentCmd.command("referral [id]").description("Get referral info and share link").action(async (id) => {
13178
+ requireApiKey();
13179
+ const agentId = id ?? getConfig().agentId;
13180
+ if (!agentId) {
13181
+ error("No agent ID provided. Set one with: tasknet config set agentId <id>");
13182
+ process.exit(1);
13183
+ }
13184
+ const spin = spinner("Fetching referral info...").start();
13185
+ try {
13186
+ const config2 = getConfig();
13187
+ const response = await fetch(`${config2.apiUrl}/api/agents/${agentId}/referral`, {
13188
+ headers: {
13189
+ "Authorization": `Bearer ${config2.apiKey}`
13190
+ }
13191
+ });
13192
+ const data = await response.json();
13193
+ spin.stop();
13194
+ if (!response.ok) {
13195
+ error(`Failed to get referral info: ${data.error}`);
13196
+ process.exit(1);
13197
+ }
13198
+ output(data, () => {
13199
+ let out = `
13200
+ ${colors.primary("\u{1F381} Referral Program")}
13201
+
13202
+ `;
13203
+ out += `${colors.highlight("Your Referral Code:")}
13204
+ `;
13205
+ out += ` ${colors.success(data.referral.code)}
13206
+
13207
+ `;
13208
+ out += `${colors.highlight("Share Link:")}
13209
+ `;
13210
+ out += ` ${data.referral.link}
13211
+
13212
+ `;
13213
+ out += `${colors.highlight("CLI Command (for other agents):")}
13214
+ `;
13215
+ out += ` ${data.referral.cli_command}
13216
+
13217
+ `;
13218
+ out += `${colors.highlight("Program Info:")}
13219
+ `;
13220
+ out += ` ${data.program_info.description}
13221
+
13222
+ `;
13223
+ out += `${colors.highlight("Your Stats:")}
13224
+ `;
13225
+ out += ` Total Referrals: ${data.stats.total_referrals}
13226
+ `;
13227
+ out += ` Active Referrals: ${data.stats.active_referrals}
13228
+ `;
13229
+ out += ` Referral Earnings: ${data.stats.referral_earnings_sui} SUI
13230
+ `;
13231
+ out += ` Pending Bonus: ${formatSui(data.stats.pending_bonus_mist)}
13232
+ `;
13233
+ out += ` Paid Bonus: ${formatSui(data.stats.paid_bonus_mist)}
13234
+ `;
13235
+ if (data.referred_by) {
13236
+ out += `
13237
+ ${colors.muted("Referred by:")} ${data.referred_by.name || formatAddress(data.referred_by.agent_id)}
13238
+ `;
13239
+ }
13240
+ if (data.referred_agents.length > 0) {
13241
+ out += `
13242
+ ${colors.highlight("Referred Agents")} (${data.referred_agents.length})
13243
+
13244
+ `;
13245
+ const rows = data.referred_agents.slice(0, 10).map((r) => [
13246
+ r.name || formatAddress(r.agent_id),
13247
+ String(r.tasks_completed),
13248
+ formatSui(r.total_earned_mist),
13249
+ r.is_active ? colors.success("Active") : colors.muted("Inactive")
13250
+ ]);
13251
+ out += table(["Agent", "Tasks", "Earned", "Status"], rows);
13252
+ }
13253
+ return out;
13254
+ });
13255
+ } catch (err) {
13256
+ spin.stop();
13257
+ error(`Failed to get referral info: ${err.message}`);
13258
+ process.exit(1);
13259
+ }
13260
+ });
13171
13261
  }
13172
13262
 
13173
13263
  // src/commands/skill.ts
@@ -14046,6 +14136,269 @@ ${colors.primary("Your Claims")}
14046
14136
  });
14047
14137
  }
14048
14138
 
14139
+ // src/commands/proposal.ts
14140
+ init_config();
14141
+ function registerProposalCommands(program2) {
14142
+ const proposalCmd = program2.command("proposal").description("Manage task proposals (bids)");
14143
+ proposalCmd.command("list").description("List proposals").option("-t, --task <id>", "Filter by task ID").option("-w, --worker <id>", "Filter by worker agent ID").option("-r, --requester <id>", "Filter by requester agent ID").option("-s, --status <status>", "Filter by status (0=pending, 1=accepted, 2=rejected, 3=withdrawn)").option("-m, --mine", "Show only my proposals").option("-p, --page <number>", "Page number", "1").option("-l, --limit <number>", "Items per page", "20").action(async (options) => {
14144
+ requireApiKey();
14145
+ const config2 = getConfig();
14146
+ const spin = spinner("Fetching proposals...").start();
14147
+ try {
14148
+ const params = new URLSearchParams();
14149
+ if (options.task) params.set("task_id", options.task);
14150
+ if (options.worker) params.set("worker_id", options.worker);
14151
+ if (options.requester) params.set("requester_id", options.requester);
14152
+ if (options.status) params.set("status", options.status);
14153
+ if (options.mine && config2.agentId) params.set("worker_id", config2.agentId);
14154
+ params.set("page", options.page);
14155
+ params.set("limit", options.limit);
14156
+ const response = await fetch(`${config2.apiUrl}/api/proposals?${params.toString()}`, {
14157
+ headers: { "Authorization": `Bearer ${config2.apiKey}` }
14158
+ });
14159
+ const data = await response.json();
14160
+ spin.stop();
14161
+ if (!response.ok) {
14162
+ error(`Failed to list proposals: ${data.error}`);
14163
+ process.exit(1);
14164
+ }
14165
+ output(data, () => {
14166
+ if (data.proposals.length === 0) {
14167
+ return `
14168
+ ${colors.muted("No proposals found")}
14169
+ `;
14170
+ }
14171
+ const rows = data.proposals.map((p) => [
14172
+ formatAddress(p.id, 8),
14173
+ p.task.skill.name,
14174
+ `${p.proposed_price_sui} SUI`,
14175
+ p.status_label,
14176
+ formatTimestamp(p.created_at)
14177
+ ]);
14178
+ return `
14179
+ ${colors.primary("Proposals")} (${data.pagination.total} total)
14180
+
14181
+ ` + table(["ID", "Skill", "Bid", "Status", "Created"], rows) + `
14182
+
14183
+ Page ${data.pagination.page}/${data.pagination.pages}`;
14184
+ });
14185
+ } catch (err) {
14186
+ spin.stop();
14187
+ error(`Failed to list proposals: ${err.message}`);
14188
+ process.exit(1);
14189
+ }
14190
+ });
14191
+ proposalCmd.command("create <task-id>").description("Submit a proposal (bid) for a task").option("-p, --price <mist>", "Proposed price in MIST").option("-s, --sui <amount>", "Proposed price in SUI").option("-m, --message <text>", "Message to the requester").option("-t, --time <seconds>", "Estimated time to complete (seconds)").action(async (taskId, options) => {
14192
+ requireApiKey();
14193
+ const config2 = getConfig();
14194
+ if (!config2.agentId) {
14195
+ error("No agent configured. Use: tasknet agent use <id>");
14196
+ process.exit(1);
14197
+ }
14198
+ let priceMist;
14199
+ if (options.price) {
14200
+ priceMist = BigInt(options.price);
14201
+ } else if (options.sui) {
14202
+ priceMist = BigInt(Math.round(parseFloat(options.sui) * 1e9));
14203
+ } else {
14204
+ error("Price is required. Use --price <mist> or --sui <amount>");
14205
+ process.exit(1);
14206
+ }
14207
+ log(`
14208
+ ${colors.primary("Creating Proposal")}
14209
+ `);
14210
+ log(`Task: ${formatAddress(taskId)}`);
14211
+ log(`Bid: ${formatSui(priceMist.toString())}`);
14212
+ if (options.message) log(`Message: ${options.message}`);
14213
+ if (options.time) log(`Est. Time: ${options.time}s`);
14214
+ const spin = spinner("Submitting proposal...").start();
14215
+ try {
14216
+ const response = await fetch(`${config2.apiUrl}/api/proposals`, {
14217
+ method: "POST",
14218
+ headers: {
14219
+ "Content-Type": "application/json",
14220
+ "Authorization": `Bearer ${config2.apiKey}`
14221
+ },
14222
+ body: JSON.stringify({
14223
+ task_id: taskId,
14224
+ proposed_price_mist: priceMist.toString(),
14225
+ message: options.message,
14226
+ estimated_time_secs: options.time ? parseInt(options.time) : void 0
14227
+ })
14228
+ });
14229
+ const data = await response.json();
14230
+ spin.stop();
14231
+ if (!response.ok) {
14232
+ error(`Failed to create proposal: ${data.error}`);
14233
+ if (data.proposal_id) {
14234
+ log(`You already have a proposal: ${data.proposal_id}`);
14235
+ }
14236
+ process.exit(1);
14237
+ }
14238
+ success(`Proposal submitted!`);
14239
+ log(`
14240
+ Proposal ID: ${data.proposal.id}`);
14241
+ log(` Status: ${data.proposal.status_label}`);
14242
+ log(` Expires: ${formatTimestamp(data.proposal.expires_at)}`);
14243
+ log(`
14244
+ The requester will review your proposal and accept or reject it.`);
14245
+ } catch (err) {
14246
+ spin.stop();
14247
+ error(`Failed to create proposal: ${err.message}`);
14248
+ process.exit(1);
14249
+ }
14250
+ });
14251
+ proposalCmd.command("info <id>").description("Get proposal details").action(async (id) => {
14252
+ requireApiKey();
14253
+ const config2 = getConfig();
14254
+ const spin = spinner("Fetching proposal...").start();
14255
+ try {
14256
+ const response = await fetch(`${config2.apiUrl}/api/proposals/${id}`, {
14257
+ headers: { "Authorization": `Bearer ${config2.apiKey}` }
14258
+ });
14259
+ const data = await response.json();
14260
+ spin.stop();
14261
+ if (!response.ok) {
14262
+ error(`Failed to get proposal: ${data.error}`);
14263
+ process.exit(1);
14264
+ }
14265
+ const p = data.proposal;
14266
+ output(data, () => {
14267
+ let out = `
14268
+ ${colors.primary("Proposal Details")}
14269
+
14270
+ `;
14271
+ out += `${colors.muted("ID:")} ${p.id}
14272
+ `;
14273
+ out += `${colors.muted("Status:")} ${p.status_label}
14274
+ `;
14275
+ out += `${colors.muted("Proposed Price:")} ${p.proposed_price_sui} SUI
14276
+ `;
14277
+ out += `${colors.muted("Message:")} ${p.message || "(none)"}
14278
+ `;
14279
+ out += `${colors.muted("Est. Time:")} ${p.estimated_time_secs ? `${p.estimated_time_secs}s` : "(not specified)"}
14280
+ `;
14281
+ out += `${colors.muted("Created:")} ${formatTimestamp(p.created_at)}
14282
+ `;
14283
+ out += `${colors.muted("Expires:")} ${formatTimestamp(p.expires_at)}
14284
+ `;
14285
+ if (p.responded_at) {
14286
+ out += `${colors.muted("Responded:")} ${formatTimestamp(p.responded_at)}
14287
+ `;
14288
+ }
14289
+ out += `
14290
+ ${colors.highlight("Task")}
14291
+ `;
14292
+ out += ` ID: ${p.task.id}
14293
+ `;
14294
+ out += ` Skill: ${p.task.skill.name} v${p.task.skill.version}
14295
+ `;
14296
+ out += ` Original Price: ${(Number(p.task.original_price_mist) / 1e9).toFixed(4)} SUI
14297
+ `;
14298
+ out += `
14299
+ ${colors.highlight("Worker")}
14300
+ `;
14301
+ out += ` ${p.worker.name || formatAddress(p.worker.agent_id)}
14302
+ `;
14303
+ out += `
14304
+ ${colors.highlight("Requester")}
14305
+ `;
14306
+ out += ` ${p.task.requester.name || formatAddress(p.task.requester.agent_id)}
14307
+ `;
14308
+ return out;
14309
+ });
14310
+ } catch (err) {
14311
+ spin.stop();
14312
+ error(`Failed to get proposal: ${err.message}`);
14313
+ process.exit(1);
14314
+ }
14315
+ });
14316
+ proposalCmd.command("accept <id>").description("Accept a proposal (assigns task to the proposer)").action(async (id) => {
14317
+ requireApiKey();
14318
+ const config2 = getConfig();
14319
+ log(`
14320
+ ${colors.primary("Accepting Proposal")}
14321
+ `);
14322
+ log(`Proposal ID: ${formatAddress(id)}`);
14323
+ const spin = spinner("Accepting proposal...").start();
14324
+ try {
14325
+ const response = await fetch(`${config2.apiUrl}/api/proposals/${id}`, {
14326
+ method: "PUT",
14327
+ headers: {
14328
+ "Content-Type": "application/json",
14329
+ "Authorization": `Bearer ${config2.apiKey}`
14330
+ },
14331
+ body: JSON.stringify({ action: "accept" })
14332
+ });
14333
+ const data = await response.json();
14334
+ spin.stop();
14335
+ if (!response.ok) {
14336
+ error(`Failed to accept proposal: ${data.error}`);
14337
+ process.exit(1);
14338
+ }
14339
+ success(`Proposal accepted!`);
14340
+ log(`
14341
+ Task: ${data.task_id}`);
14342
+ log(` Worker: ${formatAddress(data.worker_agent_id)}`);
14343
+ log(` Price: ${formatSui(data.accepted_price_mist)}`);
14344
+ log(`
14345
+ The task is now reserved for the worker.`);
14346
+ } catch (err) {
14347
+ spin.stop();
14348
+ error(`Failed to accept proposal: ${err.message}`);
14349
+ process.exit(1);
14350
+ }
14351
+ });
14352
+ proposalCmd.command("reject <id>").description("Reject a proposal").action(async (id) => {
14353
+ requireApiKey();
14354
+ const config2 = getConfig();
14355
+ const spin = spinner("Rejecting proposal...").start();
14356
+ try {
14357
+ const response = await fetch(`${config2.apiUrl}/api/proposals/${id}`, {
14358
+ method: "PUT",
14359
+ headers: {
14360
+ "Content-Type": "application/json",
14361
+ "Authorization": `Bearer ${config2.apiKey}`
14362
+ },
14363
+ body: JSON.stringify({ action: "reject" })
14364
+ });
14365
+ const data = await response.json();
14366
+ spin.stop();
14367
+ if (!response.ok) {
14368
+ error(`Failed to reject proposal: ${data.error}`);
14369
+ process.exit(1);
14370
+ }
14371
+ success(`Proposal rejected.`);
14372
+ } catch (err) {
14373
+ spin.stop();
14374
+ error(`Failed to reject proposal: ${err.message}`);
14375
+ process.exit(1);
14376
+ }
14377
+ });
14378
+ proposalCmd.command("withdraw <id>").description("Withdraw your proposal").action(async (id) => {
14379
+ requireApiKey();
14380
+ const config2 = getConfig();
14381
+ const spin = spinner("Withdrawing proposal...").start();
14382
+ try {
14383
+ const response = await fetch(`${config2.apiUrl}/api/proposals/${id}`, {
14384
+ method: "DELETE",
14385
+ headers: { "Authorization": `Bearer ${config2.apiKey}` }
14386
+ });
14387
+ const data = await response.json();
14388
+ spin.stop();
14389
+ if (!response.ok) {
14390
+ error(`Failed to withdraw proposal: ${data.error}`);
14391
+ process.exit(1);
14392
+ }
14393
+ success(`Proposal withdrawn.`);
14394
+ } catch (err) {
14395
+ spin.stop();
14396
+ error(`Failed to withdraw proposal: ${err.message}`);
14397
+ process.exit(1);
14398
+ }
14399
+ });
14400
+ }
14401
+
14049
14402
  // src/index.ts
14050
14403
  init_config();
14051
14404
  var program = new Command2();
@@ -14057,7 +14410,7 @@ var banner = chalk3.cyan(`
14057
14410
  \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
14058
14411
  \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
14059
14412
  `);
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) => {
14413
+ program.name("tasknet").description("CLI for TaskNet Protocol - Agent-to-Agent Skills Marketplace").version("0.7.0").addHelpText("beforeAll", banner).option("--json", "Output as JSON").hook("preAction", (thisCommand) => {
14061
14414
  const opts = thisCommand.opts();
14062
14415
  if (opts.json) {
14063
14416
  const config2 = getConfig();
@@ -14070,6 +14423,7 @@ registerSkillCommands(program);
14070
14423
  registerTaskCommands(program);
14071
14424
  registerBadgeCommands(program);
14072
14425
  registerClaimCommands(program);
14426
+ registerProposalCommands(program);
14073
14427
  registerHealthCommand(program);
14074
14428
  program.parse();
14075
14429
  /*! Bundled license information: