@agentsignalnet/claude-plugin 0.2.97 → 0.2.99

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.97",
4
+ "version": "0.2.99",
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.97",
3
+ "version": "0.2.99",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -335,12 +335,42 @@ async function considerResponding(watched) {
335
335
  for (const message of spool.messages ?? []) {
336
336
  const verdict = mayRespond(message, { now, config, ledger, lockHeldBy, handled });
337
337
  if (!verdict.ok) {
338
- // Only the interesting refusals. "within_grace" and "already_handled"
339
- // are the system working and would drown the ledger they share with the
340
- // decisions somebody actually needs to read.
341
- if (!['disabled', 'within_grace', 'already_handled'].includes(verdict.why)) {
342
- recordResponder({ event: 'refused', at: now, why: verdict.why,
343
- delivery_id: message.delivery_id, peer: verdict.peer ?? null });
338
+ /*
339
+ Only the interesting refusals, and each of them ONCE.
340
+
341
+ "within_grace" and "already_handled" were excluded from the start
342
+ because they are the system working and would drown the decisions
343
+ somebody actually needs to read. That list was not enough. Two of the
344
+ remaining reasons are PERMANENT -- a message with no spool stamp will
345
+ never grow one, and `already_answered` is true forever by design --
346
+ so they were re-recorded every cycle for as long as the message sat
347
+ there. Measured on the machine this was written on: 1,447 refusals in
348
+ two hours, twelve a minute, one delivery refused 291 times, and a
349
+ ledger growing about a megabyte and a half a day that is re-read on
350
+ every cycle.
351
+
352
+ Excluding them outright would trade a flood for a silence -- the
353
+ first refusal is exactly the line somebody needs when they ask why a
354
+ message was never answered. So it is recorded once per delivery and
355
+ reason, and repeats are dropped. A reason that CHANGES still gets its
356
+ own line, because that is a different fact about the world.
357
+ */
358
+ const alreadySaid =
359
+ !['disabled', 'within_grace', 'already_handled'].includes(verdict.why) &&
360
+ ledger.some(
361
+ (e) =>
362
+ e.event === 'refused' &&
363
+ e.delivery_id === message.delivery_id &&
364
+ e.why === verdict.why,
365
+ );
366
+
367
+ if (!['disabled', 'within_grace', 'already_handled'].includes(verdict.why) && !alreadySaid) {
368
+ const entry = { event: 'refused', at: now, why: verdict.why,
369
+ delivery_id: message.delivery_id, peer: verdict.peer ?? null };
370
+ recordResponder(entry);
371
+ // Kept in the in-memory copy too, so a second message in this same
372
+ // pass cannot write the line this one just wrote.
373
+ ledger.push(entry);
344
374
  say(`responder declined ${message.delivery_id}: ${verdict.why}`);
345
375
  }
346
376
  continue;
@@ -347,19 +347,48 @@ export function promptFor(message, mode) {
347
347
  .join('\n');
348
348
  }
349
349
 
350
+ /**
351
+ * THE PROMPT GOES ON STDIN, and the reason is a bug that made this script
352
+ * incapable of ever answering anything.
353
+ *
354
+ * It used to be the last element of argv, after `--allowed-tools`:
355
+ *
356
+ * '--allowed-tools', ...toolsFor(mode), promptFor(message, mode)
357
+ *
358
+ * `--allowed-tools` is VARIADIC. It ate the prompt as a fifth tool name, and
359
+ * claude exited 1 in under a second with "Input must be provided either
360
+ * through stdin or as a prompt argument when using --print". Every spawn since
361
+ * this file was written failed that way -- two of them on the author's own
362
+ * machine, visible in the ledger as `exit_code: 1` a second after the spawn.
363
+ * Nothing red, no reply sent, and a responder that looked like it was running.
364
+ *
365
+ * Joining the tools with commas does not fix it; the positional is still
366
+ * consumed. Putting the prompt BEFORE the flag does, and so does this.
367
+ *
368
+ * Stdin is chosen over reordering for two reasons. A flag added later cannot
369
+ * swallow it, which is exactly the failure being repaired. And the prompt
370
+ * carries the message's title and body -- on argv that is readable by anybody
371
+ * who can run `ps` on this machine, which is not a thing to do with somebody
372
+ * else's message.
373
+ */
350
374
  export function spawnResponder(message, config, cwd = process.cwd()) {
351
375
  const args = [
352
376
  '--print',
353
377
  '--permission-mode', config.mode === 'act' ? 'acceptEdits' : 'dontAsk',
354
378
  '--allowed-tools', ...toolsFor(config.mode),
355
- promptFor(message, config.mode),
356
379
  ];
357
380
  const child = spawn('claude', args, {
358
381
  cwd,
359
382
  env: { ...process.env, AGENTSIGNAL_FROM_RESPONDER: '1' },
360
- stdio: ['ignore', 'pipe', 'pipe'],
383
+ stdio: ['pipe', 'pipe', 'pipe'],
361
384
  detached: false,
362
385
  });
386
+ try {
387
+ child.stdin.end(promptFor(message, config.mode));
388
+ } catch {
389
+ // A child that died before stdin was writable is already an exit the
390
+ // caller will see; throwing here would lose that in a stack trace.
391
+ }
363
392
  return child;
364
393
  }
365
394