@agentsignalnet/claude-plugin 0.2.103 → 0.2.105

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.103",
4
+ "version": "0.2.105",
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsignalnet/claude-plugin",
3
- "version": "0.2.103",
3
+ "version": "0.2.105",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -95,6 +95,18 @@ let longPoll = true;
95
95
  /** The shortest a cycle may take, so a busy inbox cannot spin this hot. */
96
96
  const FLOOR_MS = 250;
97
97
 
98
+ /**
99
+ * Output that means the session never ran, as opposed to ran and went wrong.
100
+ *
101
+ * Deliberately narrow. A responder that stops itself on the wrong signal is
102
+ * worse than one that retries a few times too often: these are all conditions
103
+ * a message cannot influence and a retry cannot clear.
104
+ */
105
+ const CANNOT_START = /Failed to authenticate|not logged in|command not found|ENOENT|Invalid API key/i;
106
+
107
+ /** Why this machine cannot run a responder at all, once something proves it. */
108
+ let unavailable = null;
109
+
98
110
  /**
99
111
  * Where the identity lives -- ALL the places, matching the MCP server exactly.
100
112
  *
@@ -331,6 +343,10 @@ async function tick() {
331
343
  async function considerResponding(watched) {
332
344
  const config = responderSettings();
333
345
 
346
+ // Set once a spawn proves this machine cannot start a session at all. Every
347
+ // later message would fail the same way and spend a slot doing it.
348
+ if (unavailable) return;
349
+
334
350
  const now = Date.now();
335
351
  const ledger = readLedger();
336
352
  const lockHeldBy = heldBy();
@@ -462,6 +478,35 @@ async function considerResponding(watched) {
462
478
  child.on('exit', (code) => {
463
479
  releaseLock();
464
480
  const why = tail.trim().split('\n').filter(Boolean).at(-1) ?? null;
481
+
482
+ /*
483
+ A SESSION THAT COULD NOT START IS NOT A MESSAGE THAT WAS ANSWERED
484
+ BADLY, and the difference decides whether trying again is sensible.
485
+
486
+ "Failed to authenticate: OAuth session expired and could not be
487
+ refreshed" is the same for every message and will be the same for the
488
+ next one. Without this, each arriving message spawns, dies in under a
489
+ second, and spends one of six hourly slots -- so a machine that
490
+ cannot start a session at all burns its whole budget every hour,
491
+ forever, on sessions that never ran.
492
+
493
+ Measured here: exit 1 in well under a second, with the daemon's own
494
+ arguments and the right working directory.
495
+
496
+ Held until the daemon restarts rather than for a timer, because what
497
+ fixes it is a person signing in -- and a restart is what happens the
498
+ next time they open a session, which is also when signing in becomes
499
+ possible. A timer would just resume the same doomed spawns.
500
+ */
501
+ if (code !== 0 && why && CANNOT_START.test(why)) {
502
+ unavailable = why;
503
+ recordResponder({ event: 'unavailable', at: Date.now(), why: why.slice(0, 300) });
504
+ complain(
505
+ `the responder cannot start sessions on this machine: ${why.slice(0, 200)}. ` +
506
+ 'Not trying again until this watcher restarts. If that is a sign-in ' +
507
+ 'problem, running `claude` once and signing in is the fix.',
508
+ );
509
+ }
465
510
  recordResponder({
466
511
  event: 'finished', at: Date.now(),
467
512
  delivery_id: message.delivery_id, exit_code: code,
@@ -1430,16 +1475,6 @@ for (const identity of identities()) {
1430
1475
  */
1431
1476
  async function loop() {
1432
1477
  for (;;) {
1433
- // Reconcile on every cycle, not only at startup. Registering and looking
1434
- // are two steps, so a one-shot check at startup loses a race it is
1435
- // supposed to settle: if the higher pid registers first and looks before
1436
- // the lower one has registered, it sees an empty registry and stays -- and
1437
- // the lower pid, looking afterwards, is the one entitled to stay. Both
1438
- // keep watching, which is the exact duplicate this check exists to
1439
- // prevent. Looking again each cycle converges whatever the order was,
1440
- // because the late registration is visible by the next one.
1441
- if (yieldToLowerPid(standDown)) return;
1442
-
1443
1478
  const started = Date.now();
1444
1479
  try {
1445
1480
  await tick();
@@ -1455,4 +1490,26 @@ async function loop() {
1455
1490
  }
1456
1491
  }
1457
1492
 
1493
+ /*
1494
+ THE BACKSTOP GETS ITS OWN CLOCK, because the poll no longer has one.
1495
+
1496
+ Reconciling used to happen at the top of every cycle, and a cycle was two
1497
+ seconds, so a duplicate watcher stood down about that fast. Then the poll
1498
+ started holding its request open for twenty-five seconds -- and the check
1499
+ went with it, because it was riding the cycle rather than a timer. A
1500
+ duplicate that appeared just after one check now survived until the next,
1501
+ twelve times longer than before, delivering every message twice the whole
1502
+ while.
1503
+
1504
+ Neither change was wrong and neither test could see it: the long-poll tests
1505
+ assert request counts, the two-watcher tests start daemons and wait. The
1506
+ regression lived in the gap between two commits that were correct apart.
1507
+
1508
+ So it runs on `intervalMs` regardless of what the poll is doing. It is cheap
1509
+ -- a directory read and a pid check -- and it is the only thing standing
1510
+ between a failed lock and two watchers, which is not a thing to make twelve
1511
+ times slower as a side effect.
1512
+ */
1513
+ setInterval(() => yieldToLowerPid(standDown), intervalMs);
1514
+
1458
1515
  await loop();