@agentsignalnet/claude-plugin 0.2.79 → 0.2.82

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentsignal",
3
3
  "displayName": "AgentSignal",
4
- "version": "0.2.79",
4
+ "version": "0.2.82",
5
5
  "description": "Page a human from inside Claude Code, or become an addressable agent that other agents can reach.",
6
6
  "author": {
7
7
  "name": "Data Group AI",
package/.mcp.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "agentsignal": {
4
4
  "command": "npx",
5
- "args": ["-y", "@agentsignalnet/mcp@0.2.56"],
5
+ "args": ["-y", "@agentsignalnet/mcp@0.2.57"],
6
6
  "env": {
7
7
  "AGENTSIGNAL_API_KEY": "${user_config.api_key}",
8
8
  "AGENTSIGNAL_JOIN_TOKEN": "${user_config.join_token}",
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: Open the AgentSignal website
3
+ argument-hint: "[docs, or pricing, or whatever part of it]"
4
+ ---
5
+
6
+ Open <https://agentsignal.net> for the person at this keyboard.
7
+
8
+ `$1` names a part of the site rather than a path. Map it to one of these and
9
+ open that; anything unrecognised goes to the front page rather than to a URL
10
+ guessed from the word, because a 404 is a worse answer than the home page.
11
+
12
+ - nothing given — `https://agentsignal.net`
13
+ - `docs` — `https://agentsignal.net/docs`
14
+ - `marketplace`, `install`, `plugin` — `https://agentsignal.net/marketplace`
15
+
16
+ OPEN IT IF THIS CLIENT CAN, and print the link either way. A terminal client
17
+ that cannot open a browser has done nothing useful by reporting success, and a
18
+ link is the thing they can act on. One line, the URL in it, and stop.
19
+
20
+ Do not fetch the page and read it back. This command exists to put a browser in
21
+ front of a person; summarising the site to somebody who asked to look at it is
22
+ answering a question they did not ask, and the fetched copy is a worse version
23
+ of what their browser is about to render.
24
+
25
+ WHAT THIS IS NOT. Not a way to reach the dashboard, and worth saying because
26
+ the names collide: `/agentsignal:dashboard` runs the LOCAL one, on 127.0.0.1,
27
+ which reads this machine's channel with this machine's key. The website is the
28
+ product — signing in, the team page, billing, docs. Somebody who wants to watch
29
+ their agents talk wants the other command.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsignalnet/claude-plugin",
3
- "version": "0.2.79",
3
+ "version": "0.2.82",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -3202,7 +3202,19 @@ const server = createServer(async (req, res) => {
3202
3202
  if (url.pathname === '/onboarding' && req.method === 'GET') {
3203
3203
  const here = repoRoot(process.cwd());
3204
3204
  const mine = identitiesHere(baseUrl);
3205
- const roster = await upstream('/v1/agents');
3205
+ /*
3206
+ SCOPED, for the same reason /setup is. Counts rather than names, but they
3207
+ are still the other company's counts -- "3 reachable" about people this
3208
+ dashboard is not for, on the page that claims to describe this machine's
3209
+ setup. A checklist that reports itself from real state has to read the
3210
+ right state.
3211
+ */
3212
+ const onboardingOn =
3213
+ boundTo || companiesKnown().length <= 1 ? channelFor(url.searchParams.get('channel')) : null;
3214
+ const roster =
3215
+ onboardingOn && inScope(onboardingOn)
3216
+ ? await upstream('/v1/agents', onboardingOn.key)
3217
+ : { error: 'unscoped' };
3206
3218
  const others = roster.error
3207
3219
  ? []
3208
3220
  : (roster.recipients ?? []).filter((r) => r.key !== (self && self.key));
@@ -3405,7 +3417,36 @@ const server = createServer(async (req, res) => {
3405
3417
  }
3406
3418
 
3407
3419
  if (url.pathname === '/setup') {
3408
- const roster = await upstream('/v1/agents');
3420
+ /*
3421
+ SCOPED LIKE EVERYTHING ELSE, because it was not, and that was a hole.
3422
+
3423
+ This read `upstream('/v1/agents')` with no key, which defaults to
3424
+ `apiKey` -- and apiKey is `channels[0].key`, the FIRST key this machine
3425
+ happened to find. Not the bound company's. On a machine holding keys to
3426
+ two, a dashboard bound to one showed the other's roster: names, and the
3427
+ email addresses of its people, under the heading "Who this channel
3428
+ reaches". Reported from a real machine, where logging in to one company
3429
+ listed the members of the other.
3430
+
3431
+ Disclosure was the visible half. The worse half is that `channel` came
3432
+ back from the same call, and the invite form posts `d.channel.ref` -- so
3433
+ "Bring somebody in", on a dashboard scoped to one company, minted a join
3434
+ code for the OTHER company's channel. That is not showing the wrong
3435
+ thing, it is handing out access to it.
3436
+
3437
+ The rest of this file already had the answer: bind first, read nothing
3438
+ while the question is open, and ask the bound channel's own key. Those
3439
+ three lines are all that was missing here.
3440
+ */
3441
+ const known = companiesKnown();
3442
+ if (!boundTo && known.length === 1) boundTo = known[0].account;
3443
+
3444
+ // NOTHING IS READ WHILE THE QUESTION IS OPEN -- the same rule /messages
3445
+ // keeps, and for the same reason: reading on is showing one company's
3446
+ // people behind a question about which company this is.
3447
+ const on = boundTo || known.length <= 1 ? channelFor(url.searchParams.get('channel')) : null;
3448
+
3449
+ const roster = on && inScope(on) ? await upstream('/v1/agents', on.key) : { error: 'unscoped' };
3409
3450
  const inChannel = new Set(
3410
3451
  roster.error ? [] : (roster.recipients ?? []).map((r) => r.key),
3411
3452
  );
@@ -33,7 +33,10 @@
33
33
  * reading it half-written would see truncated JSON and conclude, wrongly, that
34
34
  * there is nothing waiting. Rename is atomic on the same filesystem.
35
35
  */
36
- import { readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, statSync, unlinkSync } from 'node:fs';
36
+ import {
37
+ readFileSync, writeFileSync, renameSync, mkdirSync, existsSync, statSync, unlinkSync,
38
+ readdirSync, rmSync,
39
+ } from 'node:fs';
37
40
  import { fileURLToPath } from 'node:url';
38
41
  import { join, dirname } from 'node:path';
39
42
  import { stateDirs, writeDir, identities as storedIdentities } from './state.mjs';
@@ -512,6 +515,89 @@ const me = {
512
515
  };
513
516
 
514
517
 
518
+ /**
519
+ * SWEEP THE OLD VERSIONS OUT OF THE PLUGIN CACHE.
520
+ *
521
+ * `claude plugin update` copies the new version into a directory of its own and
522
+ * leaves every previous one where it is. On this machine that had reached 26 of
523
+ * them. The disk is not the problem -- seven megabytes -- and old code that
524
+ * still RUNS is:
525
+ *
526
+ * A version directory is a working plugin root. A session that loads one starts
527
+ * ITS daemon, from ITS copy of this file. Both halves of that were seen on the
528
+ * machine this was written on: a 0.2.79 watcher alive under a 0.2.81 install,
529
+ * and before it a 0.2.76 dashboard. Worse for anyone still carrying a root from
530
+ * before 0.2.22, which cannot see the shared lock at all and so starts a second
531
+ * watcher silently -- no superseding line, nothing in any log, just every
532
+ * urgent message arriving twice. Updating does not reach that root. Nothing did.
533
+ *
534
+ * So the update removes them, from the one place that runs on every machine on
535
+ * every session: here.
536
+ *
537
+ * FOUR GUARDS, because this deletes directories.
538
+ *
539
+ * 1. Only the cache layout. The parent must be an `agentsignal` directory of
540
+ * version-named siblings. A checkout root has no such parent and is left
541
+ * completely alone -- deleting a developer's working tree because it
542
+ * shipped this file would be an unforgettable way to learn that.
543
+ * 2. Only names that are versions. Anything not `1.2.3` is not ours to judge.
544
+ * 3. Only OLDER than the one running. Never the current root, and never a
545
+ * newer one -- a rollback in progress is somebody's deliberate act.
546
+ * 4. Never one a live process is inside. Checked against the running
547
+ * watchers, because deleting the files under a daemon that is mid-poll is
548
+ * a crash rather than a cleanup.
549
+ *
550
+ * Best effort throughout. A cache that will not tidy itself is untidy; a
551
+ * watcher that refuses to start because it could not tidy is broken.
552
+ */
553
+ function sweepOldVersions() {
554
+ try {
555
+ const here = dirname(dirname(fileURLToPath(import.meta.url))); // .../<version>
556
+ const parent = dirname(here); // .../agentsignal
557
+ const mine = here.slice(parent.length + 1);
558
+
559
+ const version = /^(\d+)\.(\d+)\.(\d+)$/;
560
+ const asNumbers = (name) => version.exec(name)?.slice(1).map(Number);
561
+ const ours = asNumbers(mine);
562
+ // Guard 1 and 2: if this root is not itself version-named, this is a
563
+ // checkout or something unfamiliar, and nothing here is ours to remove.
564
+ if (!ours) return;
565
+
566
+ const older = (them) => {
567
+ for (let i = 0; i < 3; i += 1) {
568
+ if (them[i] !== ours[i]) return them[i] < ours[i];
569
+ }
570
+ return false; // equal is the current one, which guard 3 keeps
571
+ };
572
+
573
+ // Guard 4: anything a living watcher is running from stays, whatever its
574
+ // version says.
575
+ const inUse = new Set(
576
+ livingWatchers(lockRoot)
577
+ .map((w) => w.script)
578
+ .filter(Boolean)
579
+ .map((script) => dirname(dirname(script))),
580
+ );
581
+
582
+ let swept = 0;
583
+ for (const name of readdirSync(parent)) {
584
+ const theirs = asNumbers(name);
585
+ if (!theirs || !older(theirs)) continue;
586
+ const path = join(parent, name);
587
+ if (inUse.has(path)) continue;
588
+ try {
589
+ rmSync(path, { recursive: true, force: true });
590
+ swept += 1;
591
+ } catch {
592
+ /* a permission, a file open elsewhere: leave it and carry on */
593
+ }
594
+ }
595
+ if (swept > 0) say(`swept ${swept} superseded plugin version${swept === 1 ? '' : 's'}`);
596
+ } catch {
597
+ /* Tidying is not the job. Failing to tidy must not stop the watching. */
598
+ }
599
+ }
600
+
515
601
  /** Wait for a process to actually go, rather than assuming a signal worked. */
516
602
  async function waitForExit(pid, ms) {
517
603
  const deadline = Date.now() + ms;
@@ -657,6 +743,8 @@ for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) {
657
743
  });
658
744
  }
659
745
 
746
+ sweepOldVersions();
747
+
660
748
  const watching = identities();
661
749
  say(
662
750
  `started (pid ${process.pid}) watching ${baseUrl} every ${intervalMs / 1000}s; ` +