myceliumail 1.0.4 → 1.0.6

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 (47) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/CODEX_SETUP.md +36 -0
  3. package/README.md +20 -1
  4. package/dist/bin/myceliumail.js +4 -0
  5. package/dist/bin/myceliumail.js.map +1 -1
  6. package/dist/commands/export.d.ts +6 -0
  7. package/dist/commands/export.d.ts.map +1 -0
  8. package/dist/commands/export.js +171 -0
  9. package/dist/commands/export.js.map +1 -0
  10. package/dist/commands/send.d.ts +1 -0
  11. package/dist/commands/send.d.ts.map +1 -1
  12. package/dist/commands/send.js +30 -6
  13. package/dist/commands/send.js.map +1 -1
  14. package/dist/commands/status.d.ts +10 -0
  15. package/dist/commands/status.d.ts.map +1 -0
  16. package/dist/commands/status.js +93 -0
  17. package/dist/commands/status.js.map +1 -0
  18. package/dist/commands/watch.d.ts +4 -0
  19. package/dist/commands/watch.d.ts.map +1 -1
  20. package/dist/commands/watch.js +69 -0
  21. package/dist/commands/watch.js.map +1 -1
  22. package/dist/lib/config.js +1 -1
  23. package/dist/lib/config.js.map +1 -1
  24. package/dist/lib/crypto.d.ts.map +1 -1
  25. package/dist/lib/crypto.js +5 -4
  26. package/dist/lib/crypto.js.map +1 -1
  27. package/dist/storage/local.d.ts.map +1 -1
  28. package/dist/storage/local.js +5 -2
  29. package/dist/storage/local.js.map +1 -1
  30. package/dist/storage/supabase.d.ts +3 -3
  31. package/dist/storage/supabase.d.ts.map +1 -1
  32. package/dist/storage/supabase.js +56 -5
  33. package/dist/storage/supabase.js.map +1 -1
  34. package/mcp-server/README.md +11 -0
  35. package/mcp-server/package-lock.json +2 -2
  36. package/mcp-server/package.json +5 -4
  37. package/mcp-server/src/lib/storage.ts +74 -27
  38. package/package.json +1 -1
  39. package/src/bin/myceliumail.ts +4 -0
  40. package/src/commands/export.ts +212 -0
  41. package/src/commands/send.ts +34 -6
  42. package/src/commands/status.ts +114 -0
  43. package/src/commands/watch.ts +86 -0
  44. package/src/lib/config.ts +1 -1
  45. package/src/lib/crypto.ts +5 -4
  46. package/src/storage/local.ts +5 -2
  47. package/src/storage/supabase.ts +67 -5
@@ -221,7 +221,7 @@ export async function getInbox(agentId: string, options?: InboxOptions): Promise
221
221
  }
222
222
 
223
223
  /**
224
- * Get a specific message
224
+ * Get a specific message (supports partial ID lookup)
225
225
  */
226
226
  export async function getMessage(id: string): Promise<Message | null> {
227
227
  const client = createClient();
@@ -230,6 +230,52 @@ export async function getMessage(id: string): Promise<Message | null> {
230
230
  return local.getMessage(id);
231
231
  }
232
232
 
233
+ // For partial IDs, fetch recent messages and filter client-side
234
+ // (PostgreSQL UUID type doesn't support LIKE operator)
235
+ if (id.length < 36) {
236
+ const results = await supabaseRequest<Array<{
237
+ id: string;
238
+ from_agent: string;
239
+ to_agent: string;
240
+ subject: string;
241
+ message: string;
242
+ encrypted: boolean;
243
+ read: boolean;
244
+ created_at: string;
245
+ }>>(client, `/agent_messages?order=created_at.desc&limit=100`);
246
+
247
+ const r = results.find(row => row.id.startsWith(id));
248
+ if (!r) return null;
249
+
250
+ // Parse encrypted message
251
+ let ciphertext, nonce, senderPublicKey, body = r.message;
252
+ if (r.encrypted && r.message) {
253
+ try {
254
+ const enc = JSON.parse(r.message);
255
+ ciphertext = enc.ciphertext;
256
+ nonce = enc.nonce;
257
+ senderPublicKey = enc.sender_public_key;
258
+ body = '';
259
+ } catch { }
260
+ }
261
+
262
+ return {
263
+ id: r.id,
264
+ sender: r.from_agent,
265
+ recipient: r.to_agent,
266
+ subject: r.subject || '',
267
+ body,
268
+ encrypted: r.encrypted,
269
+ ciphertext,
270
+ nonce,
271
+ senderPublicKey,
272
+ read: r.read,
273
+ archived: false,
274
+ createdAt: new Date(r.created_at),
275
+ };
276
+ }
277
+
278
+ // Full UUID - exact match
233
279
  const results = await supabaseRequest<Array<{
234
280
  id: string;
235
281
  from_agent: string;
@@ -274,7 +320,7 @@ export async function getMessage(id: string): Promise<Message | null> {
274
320
  }
275
321
 
276
322
  /**
277
- * Mark message as read
323
+ * Mark message as read (supports partial ID)
278
324
  */
279
325
  export async function markAsRead(id: string, agentId?: string): Promise<boolean> {
280
326
  const client = createClient();
@@ -283,8 +329,16 @@ export async function markAsRead(id: string, agentId?: string): Promise<boolean>
283
329
  return local.markAsRead(id, agentId);
284
330
  }
285
331
 
332
+ // For partial IDs, resolve full UUID first
333
+ let fullId = id;
334
+ if (id.length < 36) {
335
+ const msg = await getMessage(id);
336
+ if (!msg) return false;
337
+ fullId = msg.id;
338
+ }
339
+
286
340
  try {
287
- await supabaseRequest(client, `/agent_messages?id=eq.${id}`, {
341
+ await supabaseRequest(client, `/agent_messages?id=eq.${fullId}`, {
288
342
  method: 'PATCH',
289
343
  body: JSON.stringify({ read: true }),
290
344
  });
@@ -295,7 +349,7 @@ export async function markAsRead(id: string, agentId?: string): Promise<boolean>
295
349
  }
296
350
 
297
351
  /**
298
- * Archive a message
352
+ * Archive a message (supports partial ID)
299
353
  */
300
354
  export async function archiveMessage(id: string): Promise<boolean> {
301
355
  const client = createClient();
@@ -304,8 +358,16 @@ export async function archiveMessage(id: string): Promise<boolean> {
304
358
  return local.archiveMessage(id);
305
359
  }
306
360
 
361
+ // For partial IDs, resolve full UUID first
362
+ let fullId = id;
363
+ if (id.length < 36) {
364
+ const msg = await getMessage(id);
365
+ if (!msg) return false;
366
+ fullId = msg.id;
367
+ }
368
+
307
369
  try {
308
- await supabaseRequest(client, `/agent_messages?id=eq.${id}`, {
370
+ await supabaseRequest(client, `/agent_messages?id=eq.${fullId}`, {
309
371
  method: 'PATCH',
310
372
  body: JSON.stringify({ archived: true }),
311
373
  });