@mmmbuto/nexuscrew 0.9.33 → 0.9.34

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/lib/mcp/cells.js CHANGED
@@ -75,6 +75,10 @@ function topologyOwners(payload) {
75
75
  route: [...node.route],
76
76
  label: typeof node.label === 'string' && node.label ? node.label : (node.name || node.route.join(' › ')),
77
77
  stale: node.stale === true,
78
+ // Serve alla directory per dire QUANDO un nodo stale e' stato visto
79
+ // l'ultima volta: senza, la voce in unavailable parlerebbe dello stato
80
+ // senza dire da quanto.
81
+ lastSeen: Number.isFinite(node.lastSeen) ? node.lastSeen : null,
78
82
  });
79
83
  }
80
84
  return out;
@@ -162,10 +166,26 @@ async function readCellDirectory(ctx, callerSession = null) {
162
166
  ]);
163
167
  const localId = String(config && config.instanceId || '');
164
168
  if (!NODE_ID_RE.test(localId)) throw new Error('instanceId locale non disponibile');
169
+ const candidati = topologyOwners(topology).filter((owner) => owner.instanceId !== localId);
165
170
  const owners = [{ instanceId: localId, route: [], label: 'Local', stale: false },
166
- ...topologyOwners(topology).filter((owner) => !owner.stale && owner.instanceId !== localId)];
171
+ ...candidati.filter((owner) => !owner.stale)];
167
172
  const cells = [];
168
173
  const unavailable = [];
174
+ // Un owner STALE resta nel gate (non si interroga un nodo che la topologia
175
+ // dichiara stantio) ma non SPARISCE dalla directory: chi legge `nc_cells`
176
+ // deve distinguere «questo nodo non risponde da X» da «questo nodo non
177
+ // esiste». Stesso shape di unavailableOwner, failure 'stale' + lastSeen.
178
+ for (const owner of candidati) {
179
+ if (!owner.stale) continue;
180
+ unavailable.push({
181
+ instanceId: owner.instanceId,
182
+ owner: owner.label,
183
+ route: owner.route.length ? owner.route.join('/') : 'local',
184
+ ...(owner.route.length === 0 ? { local: true } : {}),
185
+ failure: 'stale',
186
+ lastSeen: Number.isFinite(owner.lastSeen) ? owner.lastSeen : null,
187
+ });
188
+ }
169
189
  await Promise.all(owners.map(async (owner) => {
170
190
  const apiPath = owner.route.length ? routePath(owner.route, 'cells') : '/api/cells';
171
191
  if (!apiPath) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmbuto/nexuscrew",
3
- "version": "0.9.33",
3
+ "version": "0.9.34",
4
4
  "description": "Faithful browser tmux client — attach to live sessions over a real PTY, localhost-only, mobile-easy",
5
5
  "main": "lib/server.js",
6
6
  "bin": {