opencode-mailbox 0.0.8 → 0.0.10

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 +15 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12776,8 +12776,8 @@ function startMailWatch(client, recipient, sessionId, instructions) {
12776
12776
  }
12777
12777
  for (const message of unreadMessages) {
12778
12778
  await markMessageAsRead(client, recipient, message.timestamp);
12779
- await injectMailMessage(client, sessionId, recipient, message, instructions);
12780
12779
  }
12780
+ await injectMailMessages(client, sessionId, recipient, unreadMessages, instructions);
12781
12781
  } catch (error45) {
12782
12782
  if (isDatabaseFileError(error45)) {
12783
12783
  console.error(`[Mailbox] Database file error for ${recipient}, resetting connection...`);
@@ -12799,15 +12799,25 @@ function stopMailWatch(recipient) {
12799
12799
  activeWatches.delete(recipient);
12800
12800
  }
12801
12801
  }
12802
- async function injectMailMessage(client, sessionId, recipient, message, instructions) {
12803
- const timestamp = new Date(message.timestamp).toISOString();
12804
- const injectedText = `[MAIL] From: ${message.from}
12802
+ async function injectMailMessages(client, sessionId, recipient, messages, instructions) {
12803
+ let injectedText = `[MAIL BATCH] You have ${messages.length} new message(s) for ${recipient}
12804
+
12805
+ `;
12806
+ for (const message of messages) {
12807
+ const timestamp = new Date(message.timestamp).toISOString();
12808
+ injectedText += `---
12809
+ From: ${message.from}
12805
12810
  To: ${recipient}
12806
12811
  Time: ${timestamp}
12807
12812
 
12808
12813
  ${message.message}
12809
12814
 
12810
- [Instructions: ${instructions}]`;
12815
+ `;
12816
+ }
12817
+ injectedText += `---
12818
+ [Instructions: ${instructions}]
12819
+
12820
+ IMPORTANT: remember in order for a sender to see your response, you must send them a mail back. Respond using markdown. Your markdown front-matter can contain a property "choices" which is an array of choices for the mail sender to choose from. These choices are optional and shouldn't alter your authentic personality in your responses.`;
12811
12821
  try {
12812
12822
  await client.session.prompt({
12813
12823
  path: { id: sessionId },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mailbox",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "A simple mailbox system for sending and receiving messages between sessions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",