opencode-swarm-plugin 0.12.14 → 0.12.15

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
@@ -22729,13 +22729,18 @@ class AgentMailError extends Error {
22729
22729
  this.code = code;
22730
22730
  this.data = data;
22731
22731
  this.name = "AgentMailError";
22732
+ Object.setPrototypeOf(this, AgentMailError.prototype);
22732
22733
  }
22733
22734
  }
22735
+ function createAgentMailError(message, tool3, code, data) {
22736
+ return new AgentMailError(message, tool3, code, data);
22737
+ }
22734
22738
 
22735
22739
  class AgentMailNotInitializedError extends Error {
22736
22740
  constructor() {
22737
22741
  super("Agent Mail not initialized. Call agent-mail:init first.");
22738
22742
  this.name = "AgentMailNotInitializedError";
22743
+ Object.setPrototypeOf(this, AgentMailNotInitializedError.prototype);
22739
22744
  }
22740
22745
  }
22741
22746
 
@@ -26563,6 +26568,7 @@ export {
26563
26568
  src_default as default,
26564
26569
  createStorageWithFallback,
26565
26570
  createStorage,
26571
+ createAgentMailError,
26566
26572
  checkTool,
26567
26573
  checkAllTools,
26568
26574
  beads_update,
package/dist/plugin.js CHANGED
@@ -22703,13 +22703,14 @@ class AgentMailError extends Error {
22703
22703
  this.code = code;
22704
22704
  this.data = data;
22705
22705
  this.name = "AgentMailError";
22706
+ Object.setPrototypeOf(this, AgentMailError.prototype);
22706
22707
  }
22707
22708
  }
22708
-
22709
22709
  class AgentMailNotInitializedError extends Error {
22710
22710
  constructor() {
22711
22711
  super("Agent Mail not initialized. Call agent-mail:init first.");
22712
22712
  this.name = "AgentMailNotInitializedError";
22713
+ Object.setPrototypeOf(this, AgentMailNotInitializedError.prototype);
22713
22714
  }
22714
22715
  }
22715
22716
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm-plugin",
3
- "version": "0.12.14",
3
+ "version": "0.12.15",
4
4
  "description": "Multi-agent swarm coordination for OpenCode with learning capabilities, beads integration, and Agent Mail",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,6 +12,9 @@
12
12
  ".": {
13
13
  "import": "./dist/index.js",
14
14
  "types": "./dist/index.d.ts"
15
+ },
16
+ "./plugin": {
17
+ "import": "./dist/plugin.js"
15
18
  }
16
19
  },
17
20
  "scripts": {
package/src/agent-mail.ts CHANGED
@@ -231,22 +231,46 @@ interface ThreadSummary {
231
231
  // Errors
232
232
  // ============================================================================
233
233
 
234
+ /**
235
+ * AgentMailError - Custom error for Agent Mail operations
236
+ *
237
+ * Note: Using a factory pattern to avoid "Cannot call a class constructor without |new|"
238
+ * errors in some bundled environments (OpenCode's plugin runtime).
239
+ */
234
240
  export class AgentMailError extends Error {
235
- constructor(
236
- message: string,
237
- public readonly tool: string,
238
- public readonly code?: number,
239
- public readonly data?: unknown,
240
- ) {
241
+ public readonly tool: string;
242
+ public readonly code?: number;
243
+ public readonly data?: unknown;
244
+
245
+ constructor(message: string, tool: string, code?: number, data?: unknown) {
241
246
  super(message);
247
+ this.tool = tool;
248
+ this.code = code;
249
+ this.data = data;
242
250
  this.name = "AgentMailError";
251
+ // Fix prototype chain for instanceof checks
252
+ Object.setPrototypeOf(this, AgentMailError.prototype);
243
253
  }
244
254
  }
245
255
 
256
+ /**
257
+ * Factory function to create AgentMailError
258
+ * Use this instead of `new AgentMailError()` for compatibility
259
+ */
260
+ export function createAgentMailError(
261
+ message: string,
262
+ tool: string,
263
+ code?: number,
264
+ data?: unknown,
265
+ ): AgentMailError {
266
+ return new AgentMailError(message, tool, code, data);
267
+ }
268
+
246
269
  export class AgentMailNotInitializedError extends Error {
247
270
  constructor() {
248
271
  super("Agent Mail not initialized. Call agent-mail:init first.");
249
272
  this.name = "AgentMailNotInitializedError";
273
+ Object.setPrototypeOf(this, AgentMailNotInitializedError.prototype);
250
274
  }
251
275
  }
252
276
 
package/src/index.ts CHANGED
@@ -226,14 +226,15 @@ export * from "./beads";
226
226
  * - AgentMailError, FileReservationConflictError - Error classes
227
227
  * - AgentMailState - Session state type
228
228
  *
229
- * NOTE: We selectively export to avoid exporting constants like AGENT_MAIL_URL
230
- * which would confuse the plugin loader (it tries to call all exports as functions)
229
+ * NOTE: For OpenCode plugin usage, import from "opencode-swarm-plugin/plugin" instead
230
+ * to avoid the plugin loader trying to call these classes as functions.
231
231
  */
232
232
  export {
233
233
  agentMailTools,
234
234
  AgentMailError,
235
235
  AgentMailNotInitializedError,
236
236
  FileReservationConflictError,
237
+ createAgentMailError,
237
238
  type AgentMailState,
238
239
  } from "./agent-mail";
239
240