@lucid-agents/taskmarket 0.8.0 → 0.9.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.
Files changed (2) hide show
  1. package/dist/index.js +219 -6
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/index.ts
9
- import { Command as Command33 } from "commander";
9
+ import { Command as Command42 } from "commander";
10
10
  import { createRequire } from "module";
11
11
 
12
12
  // src/commands/init.ts
@@ -198,7 +198,39 @@ function decryptWithPrivateKey(fileBuffer, privateKeyHex) {
198
198
  }
199
199
 
200
200
  // src/commands/init.ts
201
- var initCommand = new Command("init").description("Create and register a new agent wallet (safe to re-run)").action(async () => {
201
+ async function tryRegisterEmail(deviceId, apiToken, username, explicit) {
202
+ try {
203
+ const reg = await apiPost("/api/emails/register", {
204
+ deviceId,
205
+ apiToken,
206
+ username
207
+ });
208
+ return reg.emailAddress;
209
+ } catch (err) {
210
+ if (explicit) {
211
+ const msg = err instanceof Error ? err.message : String(err);
212
+ process.stderr.write(
213
+ JSON.stringify({
214
+ ok: false,
215
+ error: `Email registration failed: ${msg}. Run: taskmarket email register --username ${username}`
216
+ }) + "\n"
217
+ );
218
+ }
219
+ return null;
220
+ }
221
+ }
222
+ var initCommand = new Command("init").description("Create and register a new agent wallet (safe to re-run)").option(
223
+ "--email <username>",
224
+ "Claim a custom email username (default: auto-generated from agent ID)"
225
+ ).action(async (opts) => {
226
+ if (opts.email) {
227
+ const check = await apiGet(
228
+ `/api/emails/check-username?username=${encodeURIComponent(opts.email)}`
229
+ );
230
+ if (!check.available) {
231
+ printError(`Email username "${opts.email}" is not available.`);
232
+ }
233
+ }
202
234
  if (await keystoreExists()) {
203
235
  const keystore = await loadKeystore();
204
236
  let agentId2 = keystore.agentId;
@@ -214,11 +246,29 @@ var initCommand = new Command("init").description("Create and register a new age
214
246
  networkInfo2 = response.result.data;
215
247
  } catch {
216
248
  }
249
+ let emailAddress2 = null;
250
+ try {
251
+ const existing = await apiGet(`/api/agents/stats?address=${keystore.walletAddress}`);
252
+ emailAddress2 = existing.emailAddress ?? null;
253
+ } catch {
254
+ }
255
+ if (!emailAddress2) {
256
+ const username2 = opts.email ?? (agentId2 && networkInfo2 ? `${agentId2}-${networkInfo2.chainId}` : null);
257
+ if (username2) {
258
+ emailAddress2 = await tryRegisterEmail(
259
+ keystore.deviceId,
260
+ keystore.apiToken,
261
+ username2,
262
+ !!opts.email
263
+ );
264
+ }
265
+ }
217
266
  printResult({
218
267
  address: keystore.walletAddress,
219
268
  agentId: agentId2,
220
269
  network: networkInfo2?.networkName,
221
- chainId: networkInfo2?.chainId
270
+ chainId: networkInfo2?.chainId,
271
+ emailAddress: emailAddress2
222
272
  });
223
273
  return;
224
274
  }
@@ -255,11 +305,14 @@ var initCommand = new Command("init").description("Create and register a new age
255
305
  networkInfo = response.result.data;
256
306
  } catch {
257
307
  }
308
+ const username = opts.email ?? (agentId && networkInfo ? `${agentId}-${networkInfo.chainId}` : null);
309
+ const emailAddress = username ? await tryRegisterEmail(deviceId, apiToken, username, !!opts.email) : null;
258
310
  printResult({
259
311
  address,
260
312
  agentId,
261
313
  network: networkInfo?.networkName,
262
- chainId: networkInfo?.chainId
314
+ chainId: networkInfo?.chainId,
315
+ emailAddress
263
316
  });
264
317
  });
265
318
 
@@ -416,6 +469,7 @@ var statsCommand = new Command4("stats").description("View agent statistics").op
416
469
  averageRating: result.averageRating,
417
470
  totalEarnings: result.totalEarnings,
418
471
  skills: result.skills,
472
+ emailAddress: result.emailAddress,
419
473
  recentRatings: result.recentRatings
420
474
  });
421
475
  });
@@ -5233,6 +5287,7 @@ var AgentStatsSchema = external_exports.object({
5233
5287
  averageRating: external_exports.number(),
5234
5288
  totalEarnings: external_exports.string(),
5235
5289
  skills: external_exports.array(external_exports.string()).optional(),
5290
+ emailAddress: external_exports.string().nullable().optional(),
5236
5291
  recentRatings: external_exports.array(external_exports.object({
5237
5292
  taskId: external_exports.string(),
5238
5293
  rating: external_exports.number(),
@@ -5255,7 +5310,8 @@ var LeaderboardEntrySchema = external_exports.object({
5255
5310
  completedTasks: external_exports.number(),
5256
5311
  averageRating: external_exports.number(),
5257
5312
  totalEarnings: external_exports.string(),
5258
- skills: external_exports.array(external_exports.string())
5313
+ skills: external_exports.array(external_exports.string()),
5314
+ emailAddress: external_exports.string().nullable().optional()
5259
5315
  });
5260
5316
  var LeaderboardResponseSchema = external_exports.array(LeaderboardEntrySchema);
5261
5317
 
@@ -5494,6 +5550,28 @@ var XmtpResolvePeerOutputSchema = external_exports.object({
5494
5550
  inboxId: external_exports.string().nullable()
5495
5551
  });
5496
5552
 
5553
+ // ../../packages/shared/dist/schemas/email.schemas.js
5554
+ var EmailSchema = external_exports.object({
5555
+ id: external_exports.string(),
5556
+ fromAddress: external_exports.string(),
5557
+ toAddress: external_exports.string(),
5558
+ subject: external_exports.string().nullable(),
5559
+ bodyText: external_exports.string().nullable(),
5560
+ bodyHtml: external_exports.string().nullable(),
5561
+ isRead: external_exports.boolean(),
5562
+ receivedAt: external_exports.string()
5563
+ });
5564
+ var SendEmailInputSchema = external_exports.object({
5565
+ to: external_exports.string().email(),
5566
+ subject: external_exports.string().min(1),
5567
+ bodyText: external_exports.string().min(1)
5568
+ });
5569
+ var EmailInboundHeadersSchema = external_exports.object({
5570
+ "x-webhook-secret": external_exports.string(),
5571
+ "x-email-from": external_exports.string(),
5572
+ "x-email-to": external_exports.string().email()
5573
+ });
5574
+
5497
5575
  // ../../packages/shared/dist/lib/agentName.js
5498
5576
  var MODIFIERS = [
5499
5577
  "Neon",
@@ -6989,10 +7067,144 @@ var daemonCommand = new Command32("daemon").description("Long-running agent daem
6989
7067
  }
6990
7068
  );
6991
7069
 
7070
+ // src/commands/email/index.ts
7071
+ import { Command as Command41 } from "commander";
7072
+
7073
+ // src/commands/email/register.ts
7074
+ import { Command as Command33 } from "commander";
7075
+ var registerCommand = new Command33("register").description("Register an email address for this agent").requiredOption("--username <name>", "Desired username (e.g. myagent)").action(async (opts) => {
7076
+ const check = await apiGet(
7077
+ `/api/emails/check-username?username=${encodeURIComponent(opts.username)}`
7078
+ );
7079
+ if (!check.available) {
7080
+ printError(`Username "${opts.username}" is not available.`);
7081
+ }
7082
+ const keystore = await loadKeystore();
7083
+ const result = await apiPost("/api/emails/register", {
7084
+ deviceId: keystore.deviceId,
7085
+ apiToken: keystore.apiToken,
7086
+ username: opts.username
7087
+ });
7088
+ printResult({ emailAddress: result.emailAddress });
7089
+ });
7090
+
7091
+ // src/commands/email/inbox.ts
7092
+ import { Command as Command34 } from "commander";
7093
+ var inboxCommand2 = new Command34("inbox").description("List emails in your inbox").option("--limit <n>", "Number of emails to return", "20").option("--unread", "Show only unread emails").action(async (opts) => {
7094
+ const keystore = await loadKeystore();
7095
+ const params = new URLSearchParams({
7096
+ deviceId: keystore.deviceId,
7097
+ apiToken: keystore.apiToken,
7098
+ limit: opts.limit
7099
+ });
7100
+ if (opts.unread) {
7101
+ params.set("unread", "true");
7102
+ }
7103
+ const result = await apiGet(`/api/emails/list?${params.toString()}`);
7104
+ printResult({ emails: result.emails });
7105
+ });
7106
+
7107
+ // src/commands/email/read.ts
7108
+ import { Command as Command35 } from "commander";
7109
+ var readCommand = new Command35("read").description("Read an email by ID (marks it as read)").argument("<id>", "Email ID").action(async (id) => {
7110
+ const keystore = await loadKeystore();
7111
+ const params = new URLSearchParams({
7112
+ deviceId: keystore.deviceId,
7113
+ apiToken: keystore.apiToken,
7114
+ id
7115
+ });
7116
+ const result = await apiGet(`/api/emails/get?${params.toString()}`);
7117
+ printResult(result);
7118
+ });
7119
+
7120
+ // src/commands/email/send.ts
7121
+ import { Command as Command36 } from "commander";
7122
+ var sendCommand = new Command36("send").description("Send an email").requiredOption("--to <address>", "Recipient email address").requiredOption("--subject <subject>", "Email subject").requiredOption("--body <text>", "Email body text").action(async (opts) => {
7123
+ const keystore = await loadKeystore();
7124
+ const result = await apiPost("/api/emails/send", {
7125
+ deviceId: keystore.deviceId,
7126
+ apiToken: keystore.apiToken,
7127
+ to: opts.to,
7128
+ subject: opts.subject,
7129
+ bodyText: opts.body
7130
+ });
7131
+ printResult({ sent: result.sent });
7132
+ });
7133
+
7134
+ // src/commands/email/reply.ts
7135
+ import { Command as Command37 } from "commander";
7136
+ var replyCommand = new Command37("reply").description("Reply to an email").argument("<id>", "Email ID to reply to").requiredOption("--body <text>", "Reply body text").action(async (id, opts) => {
7137
+ const keystore = await loadKeystore();
7138
+ const params = new URLSearchParams({
7139
+ deviceId: keystore.deviceId,
7140
+ apiToken: keystore.apiToken,
7141
+ id
7142
+ });
7143
+ const original = await apiGet(`/api/emails/get?${params.toString()}`);
7144
+ const to = original.fromAddress;
7145
+ const rawSubject = original.subject ?? "";
7146
+ const subject = rawSubject.startsWith("Re: ") ? rawSubject : `Re: ${rawSubject}`;
7147
+ const result = await apiPost("/api/emails/send", {
7148
+ deviceId: keystore.deviceId,
7149
+ apiToken: keystore.apiToken,
7150
+ to,
7151
+ subject,
7152
+ bodyText: opts.body
7153
+ });
7154
+ printResult({ sent: result.sent });
7155
+ });
7156
+
7157
+ // src/commands/email/delete.ts
7158
+ import { Command as Command38 } from "commander";
7159
+ var deleteCommand = new Command38("delete").description("Delete an email by ID").argument("<id>", "Email ID").action(async (id) => {
7160
+ const keystore = await loadKeystore();
7161
+ const result = await apiPost("/api/emails/delete", {
7162
+ deviceId: keystore.deviceId,
7163
+ apiToken: keystore.apiToken,
7164
+ id
7165
+ });
7166
+ printResult({ deleted: result.deleted });
7167
+ });
7168
+
7169
+ // src/commands/email/address.ts
7170
+ import { Command as Command39 } from "commander";
7171
+ var addressCommand2 = new Command39("address").description("Show your registered email address").action(async () => {
7172
+ const keystore = await loadKeystore();
7173
+ const result = await apiGet(`/api/agents/stats?address=${keystore.walletAddress}`);
7174
+ printResult({ emailAddress: result.emailAddress ?? null });
7175
+ });
7176
+
7177
+ // src/commands/email/mark-read.ts
7178
+ import { Command as Command40 } from "commander";
7179
+ async function setReadStatus(id, read) {
7180
+ const keystore = await loadKeystore();
7181
+ const result = await apiPost("/api/emails/mark-read", {
7182
+ deviceId: keystore.deviceId,
7183
+ apiToken: keystore.apiToken,
7184
+ id,
7185
+ read
7186
+ });
7187
+ printResult({ id: result.id, isRead: result.isRead });
7188
+ }
7189
+ var markReadCommand = new Command40("mark-read").description("Mark an email as read or unread").argument("<id>", "Email ID").option("--unread", "Mark as unread instead of read").action(async (id, opts) => {
7190
+ await setReadStatus(id, !opts.unread);
7191
+ });
7192
+
7193
+ // src/commands/email/index.ts
7194
+ var emailCommand = new Command41("email").description("Email management commands");
7195
+ emailCommand.addCommand(registerCommand);
7196
+ emailCommand.addCommand(inboxCommand2);
7197
+ emailCommand.addCommand(readCommand);
7198
+ emailCommand.addCommand(sendCommand);
7199
+ emailCommand.addCommand(replyCommand);
7200
+ emailCommand.addCommand(deleteCommand);
7201
+ emailCommand.addCommand(addressCommand2);
7202
+ emailCommand.addCommand(markReadCommand);
7203
+
6992
7204
  // src/index.ts
6993
7205
  var require2 = createRequire(import.meta.url);
6994
7206
  var { version } = require2("../package.json");
6995
- var program = new Command33();
7207
+ var program = new Command42();
6996
7208
  program.name("taskmarket").description("Taskmarket CLI for AI agents").version(version);
6997
7209
  program.addCommand(initCommand);
6998
7210
  program.addCommand(walletCommand);
@@ -7008,6 +7220,7 @@ program.addCommand(encryptCommand);
7008
7220
  program.addCommand(decryptCommand);
7009
7221
  program.addCommand(xmtpCommand);
7010
7222
  program.addCommand(daemonCommand);
7223
+ program.addCommand(emailCommand);
7011
7224
  program.parseAsync(process.argv).catch((err) => {
7012
7225
  process.stderr.write(JSON.stringify({ ok: false, error: err.message }) + "\n");
7013
7226
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-agents/taskmarket",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "taskmarket": "./dist/index.js"
@@ -17,9 +17,9 @@
17
17
  "tsx": "^4.7.0",
18
18
  "typescript": "^5.3.3",
19
19
  "vitest": "^2.0.0",
20
+ "@taskmarket/eslint-config": "0.0.0",
20
21
  "@taskmarket/prettier-config": "0.0.0",
21
- "@taskmarket/shared": "1.0.0",
22
- "@taskmarket/eslint-config": "0.0.0"
22
+ "@taskmarket/shared": "1.0.0"
23
23
  },
24
24
  "files": [
25
25
  "dist"