opencode-mailbox 0.0.10 → 0.0.12

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 +35 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12815,9 +12815,7 @@ ${message.message}
12815
12815
  `;
12816
12816
  }
12817
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.`;
12818
+ [Instructions: ${instructions}]`;
12821
12819
  try {
12822
12820
  await client.session.prompt({
12823
12821
  path: { id: sessionId },
@@ -12828,24 +12826,17 @@ IMPORTANT: remember in order for a sender to see your response, you must send th
12828
12826
  });
12829
12827
  try {
12830
12828
  const sessionApi = client.session;
12831
- if (sessionApi.resume) {
12832
- await sessionApi.resume({
12833
- path: { id: sessionId },
12834
- body: {}
12835
- });
12836
- } else {
12837
- await client.session.prompt({
12838
- path: { id: sessionId },
12839
- body: {
12840
- parts: [
12841
- {
12842
- type: "text",
12843
- text: "You have new mail. Please review the injected message above and respond accordingly."
12844
- }
12845
- ]
12846
- }
12847
- });
12848
- }
12829
+ await client.session.prompt({
12830
+ path: { id: sessionId },
12831
+ body: {
12832
+ parts: [
12833
+ {
12834
+ type: "text",
12835
+ text: `You have new mail. Please review the injected message above and respond accordingly. 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. IMPORTANT: remember in order for a sender to see your response, you must send them a mail back using the send mail tool.`
12836
+ }
12837
+ ]
12838
+ }
12839
+ });
12849
12840
  } catch (wakeError) {
12850
12841
  console.warn(`[Mailbox] Failed to wake up session ${sessionId}:`, wakeError);
12851
12842
  }
@@ -12921,16 +12912,37 @@ var mailboxPlugin = async (ctx) => {
12921
12912
  return `Stopped watching mail for: ${stoppedWatches.join(", ")}`;
12922
12913
  }
12923
12914
  });
12915
+ const checkMailboxWatchStatusTool = tool3({
12916
+ description: "Check the watch status for a specific agent name (recipient). Returns whether the agent is being watched and how many sessions are watching it.",
12917
+ args: {
12918
+ name: z.string().describe("Name of the agent/recipient to check watch status for. Note: this does NOT have to be an email. It can just be a name (e.g. 'samus').")
12919
+ },
12920
+ async execute(args) {
12921
+ const name = args.name.toLowerCase();
12922
+ const watch = activeWatches.get(name);
12923
+ if (!watch) {
12924
+ return `No active watch found for "${args.name}"`;
12925
+ }
12926
+ let sessionCount = 0;
12927
+ for (const [, recipients] of watchesBySession) {
12928
+ if (recipients.has(name)) {
12929
+ sessionCount++;
12930
+ }
12931
+ }
12932
+ return `"${args.name}" is being watched by ${watch.refCount} session reference(s) (${sessionCount} unique session(s)) with instructions: ${watch.instructions}`;
12933
+ }
12934
+ });
12924
12935
  return {
12925
12936
  tool: {
12926
12937
  send_mail: sendMailTool,
12927
12938
  watch_unread_mail: watchUnreadMailTool,
12928
- stop_watching_mail: stopWatchingMailTool
12939
+ stop_watching_mail: stopWatchingMailTool,
12940
+ check_mailbox_watch_status: checkMailboxWatchStatusTool
12929
12941
  },
12930
12942
  config: async (input) => {
12931
12943
  input.experimental ??= {};
12932
12944
  input.experimental.primary_tools ??= [];
12933
- input.experimental.primary_tools.push("send_mail", "watch_unread_mail", "stop_watching_mail");
12945
+ input.experimental.primary_tools.push("send_mail", "watch_unread_mail", "stop_watching_mail", "check_mailbox_watch_status");
12934
12946
  },
12935
12947
  hooks: {
12936
12948
  "session.end": async (input) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-mailbox",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A simple mailbox system for sending and receiving messages between sessions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",