adhdev 0.9.82-rc.32 → 0.9.82-rc.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/dist/cli/index.js +116 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +116 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -97986,6 +97986,13 @@ var init_daemon_mesh_manager = __esm({
|
|
|
97986
97986
|
p2pFailure(message, command, targetDaemonId) {
|
|
97987
97987
|
return new P2pRelayFailureError(message, { command, targetDaemonId });
|
|
97988
97988
|
}
|
|
97989
|
+
logMeshCommandEvent(event, fields) {
|
|
97990
|
+
try {
|
|
97991
|
+
LOG.info("Mesh", `[MeshCommand] ${JSON.stringify({ event, ...fields })}`);
|
|
97992
|
+
} catch {
|
|
97993
|
+
LOG.info("Mesh", `[MeshCommand] ${event}`);
|
|
97994
|
+
}
|
|
97995
|
+
}
|
|
97989
97996
|
updatePeerSnapshot(targetDaemonId, state, patch = {}) {
|
|
97990
97997
|
const previous = this.peerSnapshots.get(targetDaemonId);
|
|
97991
97998
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -98116,6 +98123,13 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98116
98123
|
const peer = this.peers.get(targetDaemonId);
|
|
98117
98124
|
if (!peer || peer.state !== "connected" || !peer.dataChannel?.isOpen()) {
|
|
98118
98125
|
LOG.warn("Mesh", `[Mesh] Cannot send result for ${requestId}, P2P not open with ${targetDaemonId.slice(0, 12)}`);
|
|
98126
|
+
this.logMeshCommandEvent("response_send_failed", {
|
|
98127
|
+
requestId,
|
|
98128
|
+
targetDaemonId,
|
|
98129
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98130
|
+
peerState: peer?.state ?? "missing",
|
|
98131
|
+
error: "P2P not open"
|
|
98132
|
+
});
|
|
98119
98133
|
return;
|
|
98120
98134
|
}
|
|
98121
98135
|
try {
|
|
@@ -98126,8 +98140,22 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98126
98140
|
result,
|
|
98127
98141
|
error: error48
|
|
98128
98142
|
}));
|
|
98143
|
+
this.logMeshCommandEvent("response_sent", {
|
|
98144
|
+
requestId,
|
|
98145
|
+
targetDaemonId,
|
|
98146
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98147
|
+
peerState: peer.state,
|
|
98148
|
+
success: !error48
|
|
98149
|
+
});
|
|
98129
98150
|
} catch (err) {
|
|
98130
98151
|
LOG.warn("Mesh", `[Mesh] Failed to send command result: ${err.message}`);
|
|
98152
|
+
this.logMeshCommandEvent("response_send_failed", {
|
|
98153
|
+
requestId,
|
|
98154
|
+
targetDaemonId,
|
|
98155
|
+
sentAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98156
|
+
peerState: peer.state,
|
|
98157
|
+
error: err?.message || "Failed to send command result"
|
|
98158
|
+
});
|
|
98131
98159
|
}
|
|
98132
98160
|
}
|
|
98133
98161
|
/** Convenience: send a one-off mesh command without a rule. */
|
|
@@ -98159,9 +98187,21 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98159
98187
|
}
|
|
98160
98188
|
return new Promise((resolve23, reject) => {
|
|
98161
98189
|
const requestId = `req_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
98190
|
+
const queuedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
98162
98191
|
const timer = setTimeout(() => {
|
|
98192
|
+
const pending = this.pendingRequests.get(requestId);
|
|
98163
98193
|
this.pendingRequests.delete(requestId);
|
|
98194
|
+
const timedOutAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
98164
98195
|
const message = `P2P DataChannel command '${command}' to ${targetDaemonId.slice(0, 12)} timed out after 30s`;
|
|
98196
|
+
this.logMeshCommandEvent("timeout", {
|
|
98197
|
+
requestId,
|
|
98198
|
+
command,
|
|
98199
|
+
targetDaemonId,
|
|
98200
|
+
queuedAt: pending?.queuedAt ?? queuedAt,
|
|
98201
|
+
sentAt: pending?.sentAt,
|
|
98202
|
+
timedOutAt,
|
|
98203
|
+
peerState: peer?.state
|
|
98204
|
+
});
|
|
98165
98205
|
this.invalidatePeer(targetDaemonId, message, { rejectPending: true, excludeRequestId: requestId });
|
|
98166
98206
|
reject(this.p2pFailure(message, command, targetDaemonId));
|
|
98167
98207
|
}, 3e4);
|
|
@@ -98178,7 +98218,8 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98178
98218
|
},
|
|
98179
98219
|
timer,
|
|
98180
98220
|
targetDaemonId,
|
|
98181
|
-
command
|
|
98221
|
+
command,
|
|
98222
|
+
queuedAt
|
|
98182
98223
|
});
|
|
98183
98224
|
const payload = {
|
|
98184
98225
|
type: "mesh_command",
|
|
@@ -98187,18 +98228,47 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98187
98228
|
args
|
|
98188
98229
|
};
|
|
98189
98230
|
if (peer.state === "connected" && peer.dataChannel?.isOpen()) {
|
|
98231
|
+
const sentAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
98232
|
+
const pending = this.pendingRequests.get(requestId);
|
|
98233
|
+
if (pending) pending.sentAt = sentAt;
|
|
98190
98234
|
LOG.info("Mesh", `[Mesh] Sending '${command}' via P2P DataChannel to ${targetDaemonId.slice(0, 12)}`);
|
|
98235
|
+
this.logMeshCommandEvent("sent", {
|
|
98236
|
+
requestId,
|
|
98237
|
+
command,
|
|
98238
|
+
targetDaemonId,
|
|
98239
|
+
queuedAt,
|
|
98240
|
+
sentAt,
|
|
98241
|
+
peerState: peer.state,
|
|
98242
|
+
transport: peer.isRelay === true ? "relay" : peer.isRelay === false ? "direct" : "unknown"
|
|
98243
|
+
});
|
|
98191
98244
|
try {
|
|
98192
98245
|
peer.dataChannel.sendMessage(JSON.stringify(payload));
|
|
98193
98246
|
} catch (err) {
|
|
98194
98247
|
const req = this.pendingRequests.get(requestId);
|
|
98195
98248
|
const message = err?.message || "P2P DataChannel send failed";
|
|
98249
|
+
this.logMeshCommandEvent("send_failed", {
|
|
98250
|
+
requestId,
|
|
98251
|
+
command,
|
|
98252
|
+
targetDaemonId,
|
|
98253
|
+
queuedAt,
|
|
98254
|
+
sentAt,
|
|
98255
|
+
failedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98256
|
+
error: message
|
|
98257
|
+
});
|
|
98196
98258
|
this.invalidatePeer(targetDaemonId, message, { rejectPending: true, excludeRequestId: requestId });
|
|
98197
98259
|
if (req) req.reject(this.p2pFailure(message, command, targetDaemonId));
|
|
98198
98260
|
}
|
|
98199
98261
|
return;
|
|
98200
98262
|
}
|
|
98201
98263
|
LOG.info("Mesh", `[Mesh] Queuing '${command}' for ${targetDaemonId.slice(0, 12)} (state: ${peer.state})`);
|
|
98264
|
+
this.logMeshCommandEvent("queued", {
|
|
98265
|
+
requestId,
|
|
98266
|
+
command,
|
|
98267
|
+
targetDaemonId,
|
|
98268
|
+
queuedAt,
|
|
98269
|
+
peerState: peer.state,
|
|
98270
|
+
transport: peer.isRelay === true ? "relay" : peer.isRelay === false ? "direct" : "unknown"
|
|
98271
|
+
});
|
|
98202
98272
|
if (!peer.commandQueue) {
|
|
98203
98273
|
peer.commandQueue = [];
|
|
98204
98274
|
}
|
|
@@ -98206,6 +98276,7 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98206
98276
|
command,
|
|
98207
98277
|
args,
|
|
98208
98278
|
requestId,
|
|
98279
|
+
queuedAt,
|
|
98209
98280
|
reject: (err) => {
|
|
98210
98281
|
const req = this.pendingRequests.get(requestId);
|
|
98211
98282
|
if (req) req.reject(err);
|
|
@@ -98360,7 +98431,20 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98360
98431
|
entry.commandQueue = [];
|
|
98361
98432
|
for (const item of queue) {
|
|
98362
98433
|
try {
|
|
98434
|
+
const sentAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
98435
|
+
const pending = this.pendingRequests.get(item.requestId);
|
|
98436
|
+
if (pending) pending.sentAt = sentAt;
|
|
98363
98437
|
LOG.info("Mesh", `[Mesh] Flushing queued '${item.command}' to ${targetDaemonId.slice(0, 12)}`);
|
|
98438
|
+
this.logMeshCommandEvent("sent", {
|
|
98439
|
+
requestId: item.requestId,
|
|
98440
|
+
command: item.command,
|
|
98441
|
+
targetDaemonId,
|
|
98442
|
+
queuedAt: item.queuedAt,
|
|
98443
|
+
sentAt,
|
|
98444
|
+
peerState: entry.state,
|
|
98445
|
+
transport: entry.isRelay === true ? "relay" : entry.isRelay === false ? "direct" : "unknown",
|
|
98446
|
+
flushed: true
|
|
98447
|
+
});
|
|
98364
98448
|
dc.sendMessage(JSON.stringify({
|
|
98365
98449
|
type: "mesh_command",
|
|
98366
98450
|
requestId: item.requestId,
|
|
@@ -98368,6 +98452,14 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98368
98452
|
args: item.args
|
|
98369
98453
|
}));
|
|
98370
98454
|
} catch (err) {
|
|
98455
|
+
this.logMeshCommandEvent("send_failed", {
|
|
98456
|
+
requestId: item.requestId,
|
|
98457
|
+
command: item.command,
|
|
98458
|
+
targetDaemonId,
|
|
98459
|
+
queuedAt: item.queuedAt,
|
|
98460
|
+
failedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98461
|
+
error: err?.message || "P2P DataChannel send failed while flushing command queue"
|
|
98462
|
+
});
|
|
98371
98463
|
item.reject(this.p2pFailure(err?.message || "P2P DataChannel send failed while flushing command queue", item.command, targetDaemonId));
|
|
98372
98464
|
}
|
|
98373
98465
|
}
|
|
@@ -98382,6 +98474,12 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98382
98474
|
const str2 = typeof msg === "string" ? msg : msg.toString("utf8");
|
|
98383
98475
|
const data = JSON.parse(str2);
|
|
98384
98476
|
if (data.type === "mesh_command" && data.command) {
|
|
98477
|
+
this.logMeshCommandEvent("incoming", {
|
|
98478
|
+
requestId: data.requestId,
|
|
98479
|
+
command: data.command,
|
|
98480
|
+
senderDaemonId: targetDaemonId,
|
|
98481
|
+
receivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
98482
|
+
});
|
|
98385
98483
|
if (this.commandCallback) {
|
|
98386
98484
|
this.commandCallback(targetDaemonId, data.command, data.args, data.requestId).catch((e) => {
|
|
98387
98485
|
LOG.warn("Mesh", `[Mesh] Error handling incoming P2P command: ${e.message}`);
|
|
@@ -98390,11 +98488,27 @@ var init_daemon_mesh_manager = __esm({
|
|
|
98390
98488
|
} else if (data.type === "mesh_command_result" && data.requestId) {
|
|
98391
98489
|
const pending = this.pendingRequests.get(data.requestId);
|
|
98392
98490
|
if (pending) {
|
|
98491
|
+
this.logMeshCommandEvent("response_received", {
|
|
98492
|
+
requestId: data.requestId,
|
|
98493
|
+
command: pending.command,
|
|
98494
|
+
targetDaemonId: pending.targetDaemonId,
|
|
98495
|
+
queuedAt: pending.queuedAt,
|
|
98496
|
+
sentAt: pending.sentAt,
|
|
98497
|
+
receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98498
|
+
success: data.success === true
|
|
98499
|
+
});
|
|
98393
98500
|
if (data.success) {
|
|
98394
98501
|
pending.resolve(data.result);
|
|
98395
98502
|
} else {
|
|
98396
98503
|
pending.reject(new Error(data.error || "P2P Command failed"));
|
|
98397
98504
|
}
|
|
98505
|
+
} else {
|
|
98506
|
+
this.logMeshCommandEvent("response_orphan", {
|
|
98507
|
+
requestId: data.requestId,
|
|
98508
|
+
targetDaemonId,
|
|
98509
|
+
receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98510
|
+
success: data.success === true
|
|
98511
|
+
});
|
|
98398
98512
|
}
|
|
98399
98513
|
}
|
|
98400
98514
|
} catch (e) {
|
|
@@ -98651,7 +98765,7 @@ var init_adhdev_daemon = __esm({
|
|
|
98651
98765
|
init_version();
|
|
98652
98766
|
init_src();
|
|
98653
98767
|
init_runtime_defaults();
|
|
98654
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
98768
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.34" });
|
|
98655
98769
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
98656
98770
|
localHttpServer = null;
|
|
98657
98771
|
localWss = null;
|