@shwarm/cli 0.1.2 → 0.1.3

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
@@ -384,7 +384,7 @@ var nodeUrlPath = (path, ...rest) => "/w/" + [...path.split("/"), ...rest].map(e
384
384
  // package.json
385
385
  var package_default = {
386
386
  name: "@shwarm/cli",
387
- version: "0.1.2",
387
+ version: "0.1.3",
388
388
  description: "the shwarm command line and client library: read, post, submit and check on shwarm.org with an agent key",
389
389
  license: "MIT",
390
390
  type: "module",
@@ -2489,6 +2489,8 @@ work on ${node}. read it first (read_node), then follow the skill above.` } }]
2489
2489
  throw new RpcError(-32601, `no method ${name}`);
2490
2490
  }
2491
2491
  notify = null;
2492
+ /** DMs this session sent, so the watcher doesn't push them back when a name of yours is the one written to. */
2493
+ sent = /* @__PURE__ */ new Set();
2492
2494
  stop = new AbortController();
2493
2495
  watching = null;
2494
2496
  /** Where the server's own messages (DM pushes) are written: serveMcp sets it. */
@@ -2535,7 +2537,9 @@ work on ${node}. read it first (read_node), then follow the skill above.` } }]
2535
2537
  signal: this.stop.signal,
2536
2538
  warn: o.warn,
2537
2539
  sink: (dm) => {
2538
- if (covers(pattern, dm.from)) return;
2540
+ const me = this.o.as?.trim();
2541
+ if (me ? dm.to !== me && !dm.to.startsWith(me + "/") : !covers(pattern, dm.to)) return;
2542
+ if (this.sent.has(dm.id)) return;
2539
2543
  this.notify?.({
2540
2544
  jsonrpc: "2.0",
2541
2545
  method: "notifications/claude/channel",
@@ -2556,7 +2560,10 @@ work on ${node}. read it first (read_node), then follow the skill above.` } }]
2556
2560
  const to = agentName((str(a, "to") ?? "").trim());
2557
2561
  const text = str(a, "text") ?? "";
2558
2562
  if (!text.trim()) throw new UsageError("say something: text");
2559
- return (await client.sendDm({ as: this.as(a), to, text })).text;
2563
+ const sent = await client.sendDm({ as: this.as(a), to, text });
2564
+ const id = sent.json?.id;
2565
+ if (typeof id === "string") this.sent.add(id);
2566
+ return sent.text;
2560
2567
  }
2561
2568
  case "dm_read": {
2562
2569
  const limit = a.limit;
package/dist/shwarm.js CHANGED
@@ -389,7 +389,7 @@ var nodeUrlPath = (path, ...rest) => "/w/" + [...path.split("/"), ...rest].map(e
389
389
  // package.json
390
390
  var package_default = {
391
391
  name: "@shwarm/cli",
392
- version: "0.1.2",
392
+ version: "0.1.3",
393
393
  description: "the shwarm command line and client library: read, post, submit and check on shwarm.org with an agent key",
394
394
  license: "MIT",
395
395
  type: "module",
@@ -2494,6 +2494,8 @@ work on ${node}. read it first (read_node), then follow the skill above.` } }]
2494
2494
  throw new RpcError(-32601, `no method ${name}`);
2495
2495
  }
2496
2496
  notify = null;
2497
+ /** DMs this session sent, so the watcher doesn't push them back when a name of yours is the one written to. */
2498
+ sent = /* @__PURE__ */ new Set();
2497
2499
  stop = new AbortController();
2498
2500
  watching = null;
2499
2501
  /** Where the server's own messages (DM pushes) are written: serveMcp sets it. */
@@ -2540,7 +2542,9 @@ work on ${node}. read it first (read_node), then follow the skill above.` } }]
2540
2542
  signal: this.stop.signal,
2541
2543
  warn: o.warn,
2542
2544
  sink: (dm) => {
2543
- if (covers(pattern, dm.from)) return;
2545
+ const me = this.o.as?.trim();
2546
+ if (me ? dm.to !== me && !dm.to.startsWith(me + "/") : !covers(pattern, dm.to)) return;
2547
+ if (this.sent.has(dm.id)) return;
2544
2548
  this.notify?.({
2545
2549
  jsonrpc: "2.0",
2546
2550
  method: "notifications/claude/channel",
@@ -2561,7 +2565,10 @@ work on ${node}. read it first (read_node), then follow the skill above.` } }]
2561
2565
  const to = agentName((str(a, "to") ?? "").trim());
2562
2566
  const text = str(a, "text") ?? "";
2563
2567
  if (!text.trim()) throw new UsageError("say something: text");
2564
- return (await client.sendDm({ as: this.as(a), to, text })).text;
2568
+ const sent = await client.sendDm({ as: this.as(a), to, text });
2569
+ const id = sent.json?.id;
2570
+ if (typeof id === "string") this.sent.add(id);
2571
+ return sent.text;
2565
2572
  }
2566
2573
  case "dm_read": {
2567
2574
  const limit = a.limit;
@@ -35,6 +35,8 @@ export declare class McpServer {
35
35
  handle(msg: unknown): Promise<Reply | null>;
36
36
  private method;
37
37
  private notify;
38
+ /** DMs this session sent, so the watcher doesn't push them back when a name of yours is the one written to. */
39
+ private readonly sent;
38
40
  private readonly stop;
39
41
  private watching;
40
42
  /** Where the server's own messages (DM pushes) are written: serveMcp sets it. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwarm/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "the shwarm command line and client library: read, post, submit and check on shwarm.org with an agent key",
5
5
  "license": "MIT",
6
6
  "type": "module",