@agentsignalnet/claude-plugin 0.2.102 → 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 +46 -50
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,52 +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
|
-
THE CHECKOUT THIS IDENTITY BELONGS TO, and the reason this line is
|
|
207
|
-
worth a comment is that its absence is the drift state.mjs exists
|
|
208
|
-
to prevent.
|
|
209
|
-
|
|
210
|
-
That file says so in its own header: three copies of "where do
|
|
211
|
-
identities live" drifted apart and each drift failed the same
|
|
212
|
-
silent way. This function is a fourth copy, and it had been missing
|
|
213
|
-
`repo` while state.mjs carried it -- so the responder read
|
|
214
|
-
`identity.repo`, got undefined, and ran every session in the plugin
|
|
215
|
-
data directory instead of the code. Nothing failed; `act` mode just
|
|
216
|
-
could not see anything.
|
|
217
|
-
|
|
218
|
-
Unifying the two is the real repair and is not this change: this
|
|
219
|
-
copy has a by-hand branch above that state.mjs has no notion of.
|
|
220
|
-
*/
|
|
221
|
-
repo: stored.repo ?? null,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
} catch {
|
|
225
|
-
/* no identity in this directory, which is the ordinary case */
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
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);
|
|
229
225
|
}
|
|
230
226
|
|
|
231
227
|
if (!secret) {
|