@agentsignalnet/claude-plugin 0.2.101 → 0.2.103
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/.claude-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/inbox-daemon.mjs +77 -34
package/package.json
CHANGED
package/scripts/inbox-daemon.mjs
CHANGED
|
@@ -122,17 +122,24 @@ const FLOOR_MS = 250;
|
|
|
122
122
|
* Choosing a directory independently is how the two came apart before.
|
|
123
123
|
*/
|
|
124
124
|
function credential() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
/*
|
|
126
|
+
THE FIRST OF THE SHARED ANSWER, rather than a fifth scan of the same
|
|
127
|
+
directories.
|
|
128
|
+
|
|
129
|
+
This walked stateDirs(), read agent.json, and filtered on base_url -- which
|
|
130
|
+
is exactly what state.mjs does, and exactly what the identities() copy
|
|
131
|
+
below it did before that copy was removed. Three readers of one file in one
|
|
132
|
+
process, and the one that drifted took `act` mode with it.
|
|
133
|
+
|
|
134
|
+
Same result by construction: identities() preserves stateDirs() order and
|
|
135
|
+
dedupes by credential, so its first element is the first directory that
|
|
136
|
+
holds a credential for this API. Keyed on base URL for the same reason the
|
|
137
|
+
MCP server is -- a production credential must not be reused against
|
|
138
|
+
localhost, or the reverse -- and that check now lives in one place.
|
|
139
|
+
*/
|
|
140
|
+
const [first] = storedIdentities(baseUrl);
|
|
141
|
+
if (first) return { secret: first.secret, dir: first.dir };
|
|
142
|
+
|
|
136
143
|
// An explicit secret has no directory of its own, so it falls back to the
|
|
137
144
|
// one the server would have written to -- the same one the hooks fall back
|
|
138
145
|
// to.
|
|
@@ -180,35 +187,41 @@ const spoolPath = flag('spool', join(stateDir, 'inbox-spool.json'));
|
|
|
180
187
|
* unrelated killed this process. The cost is a readdir of a few directories
|
|
181
188
|
* beside an HTTPS request, which is nothing.
|
|
182
189
|
*/
|
|
190
|
+
/**
|
|
191
|
+
* WHO THIS MACHINE WATCHES, answered in one place.
|
|
192
|
+
*
|
|
193
|
+
* This used to be a second implementation of `identities()` sitting beside the
|
|
194
|
+
* import of the first -- `storedIdentities` was imported at the top of this
|
|
195
|
+
* file and never called, while forty lines here re-derived the same answer
|
|
196
|
+
* from the same directories.
|
|
197
|
+
*
|
|
198
|
+
* state.mjs was created because three copies of this logic drifted apart and
|
|
199
|
+
* "each drift failed the same silent way". This was the fourth, and it failed
|
|
200
|
+
* exactly as advertised: it omitted `repo`, so the responder read
|
|
201
|
+
* `identity.repo`, got undefined, and started every session in the plugin data
|
|
202
|
+
* directory rather than the checkout. Nothing went red; `act` mode simply
|
|
203
|
+
* could not see any code.
|
|
204
|
+
*
|
|
205
|
+
* The copy is gone. What remains here is the one thing state.mjs genuinely has
|
|
206
|
+
* no notion of: the by-hand invocation.
|
|
207
|
+
*/
|
|
183
208
|
function identities() {
|
|
184
209
|
// An explicitly named spool means one inbox and that inbox only: it is the
|
|
185
210
|
// by-hand invocation, and quietly watching several while writing one file
|
|
186
211
|
// would be worse than the limitation.
|
|
212
|
+
//
|
|
213
|
+
// Shaped like the shared answer even though it is built here, because a
|
|
214
|
+
// consumer that has to know which branch produced its identity is a fifth
|
|
215
|
+
// copy of this problem waiting to happen.
|
|
187
216
|
if (flag('spool', null) || process.env.AGENTSIGNAL_DEVICE_SECRET) {
|
|
188
|
-
return secret
|
|
217
|
+
return secret
|
|
218
|
+
? [{ secret, credential: secret, dir: stateDir, spool: spoolPath, handle: null, repo: null }]
|
|
219
|
+
: [];
|
|
189
220
|
}
|
|
190
221
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const stored = JSON.parse(readFileSync(join(dir, 'agent.json'), 'utf8'));
|
|
195
|
-
if (!stored?.credential || stored.base_url !== baseUrl) continue;
|
|
196
|
-
// Keyed on the credential, not the directory: the same identity found
|
|
197
|
-
// through a plugin directory and through a sibling is one agent, and
|
|
198
|
-
// polling it twice would deliver everything to it twice.
|
|
199
|
-
if (!seen.has(stored.credential)) {
|
|
200
|
-
seen.set(stored.credential, {
|
|
201
|
-
secret: stored.credential,
|
|
202
|
-
dir,
|
|
203
|
-
spool: join(dir, 'inbox-spool.json'),
|
|
204
|
-
handle: stored.handle ?? null,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
} catch {
|
|
208
|
-
/* no identity in this directory, which is the ordinary case */
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return [...seen.values()];
|
|
222
|
+
// Keyed on the credential rather than the directory, deduped, filtered to
|
|
223
|
+
// this API -- all of it, once, over there.
|
|
224
|
+
return storedIdentities(baseUrl);
|
|
212
225
|
}
|
|
213
226
|
|
|
214
227
|
if (!secret) {
|
|
@@ -387,7 +400,37 @@ async function considerResponding(watched) {
|
|
|
387
400
|
title: message.title ?? null });
|
|
388
401
|
say(`responder answering ${message.delivery_id} (${config.mode}) from ${verdict.peer ?? 'unknown'}`);
|
|
389
402
|
|
|
390
|
-
|
|
403
|
+
/*
|
|
404
|
+
WHERE THE WORK IS, not where the credential is.
|
|
405
|
+
|
|
406
|
+
This passed `identity.dir`, which is the plugin's data directory --
|
|
407
|
+
`~/.claude/plugins/data/.../agents/AgentSignal-<id>/`, holding agent.json
|
|
408
|
+
and the spool and nothing else. In `answer` mode that is invisible,
|
|
409
|
+
because the session cannot reach a file anyway. In `act` mode it is the
|
|
410
|
+
whole feature: a session told "you may read, search and run commands to
|
|
411
|
+
establish the answer" was sitting in a folder with two JSON files in it,
|
|
412
|
+
unable to see a single line of the code it was asked about.
|
|
413
|
+
|
|
414
|
+
`agent.json` has recorded `repo` all along -- the checkout the identity
|
|
415
|
+
was created in -- and `identities()` surfaces it. It was simply never
|
|
416
|
+
used. Checked before it is trusted, because a repo can be moved or
|
|
417
|
+
deleted after an agent joined, and a cwd that does not exist fails the
|
|
418
|
+
spawn outright rather than degrading.
|
|
419
|
+
*/
|
|
420
|
+
let where = identity.dir;
|
|
421
|
+
if (identity.repo) {
|
|
422
|
+
try {
|
|
423
|
+
if (statSync(identity.repo).isDirectory()) where = identity.repo;
|
|
424
|
+
else complain(`${identity.repo} is not a directory; answering from ${identity.dir}`);
|
|
425
|
+
} catch {
|
|
426
|
+
complain(
|
|
427
|
+
`the repo this agent joined from (${identity.repo}) is gone; ` +
|
|
428
|
+
`answering from ${identity.dir}, where it can see nothing`,
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const child = spawnResponder(message, config, where);
|
|
391
434
|
|
|
392
435
|
/*
|
|
393
436
|
READ WHAT IT SAYS, for two reasons and the second is worse.
|