adhdev 0.5.35 → 0.5.37
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 +88 -26
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +88 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -16590,7 +16590,19 @@ var require_dist = __commonJS({
|
|
|
16590
16590
|
delete merged.activeWorkspaceId;
|
|
16591
16591
|
const hadStoredWorkspaces = Array.isArray(parsed.workspaces) && parsed.workspaces.length > 0;
|
|
16592
16592
|
migrateWorkspacesFromRecent(merged);
|
|
16593
|
+
let configChanged = false;
|
|
16594
|
+
if (!merged.machineId) {
|
|
16595
|
+
const os15 = require("os");
|
|
16596
|
+
const crypto5 = require("crypto");
|
|
16597
|
+
const safeHostname = os15.hostname().replace(/[^a-zA-Z0-9]/g, "_");
|
|
16598
|
+
const machineHash = crypto5.createHash("md5").update(os15.hostname() + os15.homedir()).digest("hex").slice(0, 8);
|
|
16599
|
+
merged.machineId = `${safeHostname}_${machineHash}`;
|
|
16600
|
+
configChanged = true;
|
|
16601
|
+
}
|
|
16593
16602
|
if (!hadStoredWorkspaces && (merged.workspaces?.length || 0) > 0) {
|
|
16603
|
+
configChanged = true;
|
|
16604
|
+
}
|
|
16605
|
+
if (configChanged) {
|
|
16594
16606
|
try {
|
|
16595
16607
|
saveConfig2(merged);
|
|
16596
16608
|
} catch {
|
|
@@ -16691,6 +16703,7 @@ var require_dist = __commonJS({
|
|
|
16691
16703
|
defaultWorkspaceId: null,
|
|
16692
16704
|
recentWorkspaceActivity: [],
|
|
16693
16705
|
machineNickname: null,
|
|
16706
|
+
machineId: void 0,
|
|
16694
16707
|
cliHistory: [],
|
|
16695
16708
|
providerSettings: {},
|
|
16696
16709
|
ideSettings: {}
|
|
@@ -17825,8 +17838,13 @@ var require_dist = __commonJS({
|
|
|
17825
17838
|
});
|
|
17826
17839
|
const value = result?.result?.value;
|
|
17827
17840
|
if (value != null) {
|
|
17841
|
+
const strValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
17842
|
+
if (strValue.includes("__adhdev_skip_iframe")) {
|
|
17843
|
+
this.log(`[CDP] evaluateInWebviewFrame: script requested skip in ${iframe.targetId.substring(0, 12)}`);
|
|
17844
|
+
continue;
|
|
17845
|
+
}
|
|
17828
17846
|
this.log(`[CDP] evaluateInWebviewFrame: success in ${iframe.targetId.substring(0, 12)}`);
|
|
17829
|
-
return
|
|
17847
|
+
return strValue;
|
|
17830
17848
|
}
|
|
17831
17849
|
} catch (e) {
|
|
17832
17850
|
if (sessionId) {
|
|
@@ -18363,7 +18381,7 @@ var require_dist = __commonJS({
|
|
|
18363
18381
|
}
|
|
18364
18382
|
}
|
|
18365
18383
|
};
|
|
18366
|
-
var
|
|
18384
|
+
var crypto2 = __toESM2(require("crypto"));
|
|
18367
18385
|
var DEFAULT_MONITOR_CONFIG = {
|
|
18368
18386
|
approvalAlert: true,
|
|
18369
18387
|
longGeneratingAlert: true,
|
|
@@ -18511,6 +18529,7 @@ var require_dist = __commonJS({
|
|
|
18511
18529
|
if (event === "stream_update") {
|
|
18512
18530
|
if (data?.streams) this.agentStreams = data.streams;
|
|
18513
18531
|
if (data?.messages) this.messages = data.messages;
|
|
18532
|
+
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
18514
18533
|
if (data?.status) {
|
|
18515
18534
|
const newStatus = data.status;
|
|
18516
18535
|
this.detectTransition(newStatus, data);
|
|
@@ -18540,13 +18559,14 @@ var require_dist = __commonJS({
|
|
|
18540
18559
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
18541
18560
|
} else if (agentStatus === "waiting_approval") {
|
|
18542
18561
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
18562
|
+
const msg = data?.activeModal?.message || data?.modalMessage;
|
|
18543
18563
|
this.pushEvent({
|
|
18544
18564
|
event: "agent:waiting_approval",
|
|
18545
18565
|
chatTitle,
|
|
18546
18566
|
timestamp: now,
|
|
18547
18567
|
ideType: this.ideType,
|
|
18548
18568
|
agentType: this.type,
|
|
18549
|
-
modalMessage:
|
|
18569
|
+
modalMessage: msg,
|
|
18550
18570
|
modalButtons: data?.activeModal?.buttons || data?.modalButtons
|
|
18551
18571
|
});
|
|
18552
18572
|
} else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
|
|
@@ -18730,7 +18750,7 @@ var require_dist = __commonJS({
|
|
|
18730
18750
|
constructor(provider, instanceKey) {
|
|
18731
18751
|
this.type = provider.type;
|
|
18732
18752
|
this.provider = provider;
|
|
18733
|
-
this.instanceId =
|
|
18753
|
+
this.instanceId = crypto2.randomUUID();
|
|
18734
18754
|
this.monitor = new StatusMonitor();
|
|
18735
18755
|
this.historyWriter = new ChatHistoryWriter();
|
|
18736
18756
|
}
|
|
@@ -18906,8 +18926,8 @@ var require_dist = __commonJS({
|
|
|
18906
18926
|
activeModal = void 0;
|
|
18907
18927
|
} else {
|
|
18908
18928
|
activeModal = {
|
|
18909
|
-
message: activeModal.message?.slice(0,
|
|
18910
|
-
buttons: (activeModal.buttons ?? []).filter((t) => t.length <
|
|
18929
|
+
message: activeModal.message?.slice(0, 5e3) ?? "",
|
|
18930
|
+
buttons: (activeModal.buttons ?? []).filter((t) => t.length < 200)
|
|
18911
18931
|
};
|
|
18912
18932
|
}
|
|
18913
18933
|
}
|
|
@@ -18978,12 +18998,13 @@ var require_dist = __commonJS({
|
|
|
18978
18998
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now, ideType: this.type });
|
|
18979
18999
|
} else if (agentStatus === "waiting_approval") {
|
|
18980
19000
|
if (!this.generatingStartedAt.has(agentKey)) this.generatingStartedAt.set(agentKey, now);
|
|
19001
|
+
const msg = chatData.activeModal?.message;
|
|
18981
19002
|
this.pushEvent({
|
|
18982
19003
|
event: "agent:waiting_approval",
|
|
18983
19004
|
chatTitle,
|
|
18984
19005
|
timestamp: now,
|
|
18985
19006
|
ideType: this.type,
|
|
18986
|
-
modalMessage:
|
|
19007
|
+
modalMessage: msg,
|
|
18987
19008
|
modalButtons: chatData.activeModal?.buttons
|
|
18988
19009
|
});
|
|
18989
19010
|
} else if (agentStatus === "idle" && (lastStatus === "generating" || lastStatus === "waiting_approval")) {
|
|
@@ -21905,9 +21926,29 @@ var require_dist = __commonJS({
|
|
|
21905
21926
|
if (!file2.endsWith(".js")) continue;
|
|
21906
21927
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
21907
21928
|
const filePath = path6.join(dir, file2);
|
|
21908
|
-
result[scriptName] = (...
|
|
21929
|
+
result[scriptName] = (...args) => {
|
|
21909
21930
|
try {
|
|
21910
|
-
|
|
21931
|
+
let content = fs5.readFileSync(filePath, "utf-8");
|
|
21932
|
+
if (args[0] && typeof args[0] === "object") {
|
|
21933
|
+
for (const [key, val] of Object.entries(args[0])) {
|
|
21934
|
+
let v = val;
|
|
21935
|
+
if (typeof v === "string") {
|
|
21936
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
21937
|
+
v = JSON.stringify(v);
|
|
21938
|
+
}
|
|
21939
|
+
} else {
|
|
21940
|
+
v = JSON.stringify(v);
|
|
21941
|
+
}
|
|
21942
|
+
content = content.replace(new RegExp(`\\$\\{${key}\\}`, "g"), String(v));
|
|
21943
|
+
}
|
|
21944
|
+
} else if (args[0] !== void 0) {
|
|
21945
|
+
let v = String(args[0]);
|
|
21946
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
21947
|
+
v = JSON.stringify(v);
|
|
21948
|
+
}
|
|
21949
|
+
content = content.replace(/\$\{MESSAGE\}/g, v);
|
|
21950
|
+
}
|
|
21951
|
+
return content;
|
|
21911
21952
|
} catch {
|
|
21912
21953
|
return "";
|
|
21913
21954
|
}
|
|
@@ -22855,6 +22896,12 @@ var require_dist = __commonJS({
|
|
|
22855
22896
|
emitStatusEvent(event) {
|
|
22856
22897
|
LOG5.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
22857
22898
|
this.deps.serverConn?.sendMessage("status_event", event);
|
|
22899
|
+
if (this.deps.p2p?.isConnected) {
|
|
22900
|
+
try {
|
|
22901
|
+
this.deps.p2p.sendStatusEvent?.(event);
|
|
22902
|
+
} catch {
|
|
22903
|
+
}
|
|
22904
|
+
}
|
|
22858
22905
|
}
|
|
22859
22906
|
removeAgentTracking(_key) {
|
|
22860
22907
|
}
|
|
@@ -26448,11 +26495,15 @@ async (params) => {
|
|
|
26448
26495
|
this.json(res, 500, { error: "Script function returned null" });
|
|
26449
26496
|
return;
|
|
26450
26497
|
}
|
|
26451
|
-
|
|
26498
|
+
this.log(`Exec script length: ${scriptCode.length}, first 50 chars: ${scriptCode.slice(0, 50)}...`);
|
|
26499
|
+
const isWebviewScript = provider.category === "extension" || scriptName.toLowerCase().includes("webview");
|
|
26452
26500
|
let raw;
|
|
26453
26501
|
if (isWebviewScript) {
|
|
26454
26502
|
const matchText = provider.webviewMatchText;
|
|
26455
26503
|
const matchFn = matchText ? (body2) => body2.includes(matchText) : void 0;
|
|
26504
|
+
if (!cdp.evaluateInWebviewFrame) {
|
|
26505
|
+
throw new Error(`CDP manager does not support evaluateInWebviewFrame`);
|
|
26506
|
+
}
|
|
26456
26507
|
raw = await cdp.evaluateInWebviewFrame(scriptCode, matchFn);
|
|
26457
26508
|
} else {
|
|
26458
26509
|
raw = await cdp.evaluate(scriptCode, 3e4);
|
|
@@ -29601,13 +29652,13 @@ ${e?.stack || ""}`);
|
|
|
29601
29652
|
const transport = url2.includes("transport=tcp") ? "tcp" : "udp";
|
|
29602
29653
|
const isTls = url2.startsWith("turns:");
|
|
29603
29654
|
const parts = cleanUrl.replace(/^turns?:/, "").split(":");
|
|
29604
|
-
const
|
|
29655
|
+
const hostname3 = parts[0];
|
|
29605
29656
|
const port = parseInt(parts[1]) || (isTls ? 5349 : 3478);
|
|
29606
29657
|
let relayType = "TurnUdp";
|
|
29607
29658
|
if (isTls) relayType = "TurnTls";
|
|
29608
29659
|
else if (transport === "tcp") relayType = "TurnTcp";
|
|
29609
29660
|
converted.push({
|
|
29610
|
-
hostname:
|
|
29661
|
+
hostname: hostname3,
|
|
29611
29662
|
port,
|
|
29612
29663
|
username: server.username,
|
|
29613
29664
|
password: server.credential,
|
|
@@ -29635,16 +29686,16 @@ ${e?.stack || ""}`);
|
|
|
29635
29686
|
connectedAt: Date.now(),
|
|
29636
29687
|
pendingCandidates: [],
|
|
29637
29688
|
remoteDescriptionSet: false,
|
|
29638
|
-
isRelay: false
|
|
29689
|
+
isRelay: false,
|
|
29690
|
+
lastPongAt: Date.now()
|
|
29639
29691
|
};
|
|
29640
29692
|
this.peers.set(pid, entry);
|
|
29641
29693
|
this.notifyStateChange();
|
|
29642
|
-
|
|
29694
|
+
entry.connectionTimeout = setTimeout(() => {
|
|
29643
29695
|
const peer = this.peers.get(pid);
|
|
29644
29696
|
if (peer?.state === "connecting") {
|
|
29645
|
-
log(`connection timeout (30s) for peer ${pid}`);
|
|
29646
|
-
|
|
29647
|
-
this.notifyStateChange();
|
|
29697
|
+
log(`connection timeout (30s) for peer ${pid} \u2014 full cleanup`);
|
|
29698
|
+
this.disconnectPeer(pid);
|
|
29648
29699
|
}
|
|
29649
29700
|
}, 3e4);
|
|
29650
29701
|
try {
|
|
@@ -29729,9 +29780,11 @@ ${e?.stack || ""}`);
|
|
|
29729
29780
|
filesCh.onMessage((msg) => this.handleCommandMessage(pid, msg));
|
|
29730
29781
|
} catch (e) {
|
|
29731
29782
|
log(`connection failed for peer ${pid}: ${e?.message}`);
|
|
29732
|
-
clearTimeout(timeout);
|
|
29733
29783
|
const peer = this.peers.get(pid);
|
|
29734
|
-
if (peer)
|
|
29784
|
+
if (peer) {
|
|
29785
|
+
if (peer.connectionTimeout) clearTimeout(peer.connectionTimeout);
|
|
29786
|
+
peer.state = "failed";
|
|
29787
|
+
}
|
|
29735
29788
|
this.notifyStateChange();
|
|
29736
29789
|
}
|
|
29737
29790
|
}
|
|
@@ -29753,7 +29806,11 @@ ${e?.stack || ""}`);
|
|
|
29753
29806
|
}
|
|
29754
29807
|
return;
|
|
29755
29808
|
}
|
|
29756
|
-
if (parsed.type === "pong")
|
|
29809
|
+
if (parsed.type === "pong") {
|
|
29810
|
+
const peer = this.peers.get(peerId);
|
|
29811
|
+
if (peer) peer.lastPongAt = Date.now();
|
|
29812
|
+
return;
|
|
29813
|
+
}
|
|
29757
29814
|
if (parsed.type === "screenshot_start") {
|
|
29758
29815
|
const peer = this.peers.get(peerId);
|
|
29759
29816
|
if (!parsed.ideType) {
|
|
@@ -30068,6 +30125,7 @@ ${e?.stack || ""}`);
|
|
|
30068
30125
|
if (!peer) return;
|
|
30069
30126
|
if (peer.failedCleanupTimer) clearTimeout(peer.failedCleanupTimer);
|
|
30070
30127
|
if (peer.heartbeatTimer) clearInterval(peer.heartbeatTimer);
|
|
30128
|
+
if (peer.connectionTimeout) clearTimeout(peer.connectionTimeout);
|
|
30071
30129
|
if (peer.screenshotChannel) try {
|
|
30072
30130
|
peer.screenshotChannel.close();
|
|
30073
30131
|
} catch {
|
|
@@ -30089,12 +30147,19 @@ ${e?.stack || ""}`);
|
|
|
30089
30147
|
const peer = this.peers.get(peerId);
|
|
30090
30148
|
if (!peer) return;
|
|
30091
30149
|
if (peer.heartbeatTimer) clearInterval(peer.heartbeatTimer);
|
|
30150
|
+
peer.lastPongAt = Date.now();
|
|
30092
30151
|
peer.heartbeatTimer = setInterval(() => {
|
|
30093
30152
|
const p = this.peers.get(peerId);
|
|
30094
30153
|
if (!p || p.state !== "connected") {
|
|
30095
30154
|
if (p?.heartbeatTimer) clearInterval(p.heartbeatTimer);
|
|
30096
30155
|
return;
|
|
30097
30156
|
}
|
|
30157
|
+
const sincePong = Date.now() - p.lastPongAt;
|
|
30158
|
+
if (sincePong > 45e3) {
|
|
30159
|
+
log(`Peer ${peerId} pong timeout (${Math.round(sincePong / 1e3)}s) \u2014 disconnecting dead peer`);
|
|
30160
|
+
this.disconnectPeer(peerId);
|
|
30161
|
+
return;
|
|
30162
|
+
}
|
|
30098
30163
|
try {
|
|
30099
30164
|
if (p.commandChannel?.isOpen()) {
|
|
30100
30165
|
p.commandChannel.sendMessage(JSON.stringify({ type: "ping", ts: Date.now() }));
|
|
@@ -30317,7 +30382,7 @@ function stopDaemon() {
|
|
|
30317
30382
|
return false;
|
|
30318
30383
|
}
|
|
30319
30384
|
}
|
|
30320
|
-
var import_daemon_core4, os2, fs2, path2,
|
|
30385
|
+
var import_daemon_core4, os2, fs2, path2, import_chalk, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
30321
30386
|
var init_adhdev_daemon = __esm({
|
|
30322
30387
|
"src/adhdev-daemon.ts"() {
|
|
30323
30388
|
"use strict";
|
|
@@ -30328,9 +30393,8 @@ var init_adhdev_daemon = __esm({
|
|
|
30328
30393
|
os2 = __toESM(require("os"));
|
|
30329
30394
|
fs2 = __toESM(require("fs"));
|
|
30330
30395
|
path2 = __toESM(require("path"));
|
|
30331
|
-
crypto2 = __toESM(require("crypto"));
|
|
30332
30396
|
import_chalk = __toESM(require("chalk"));
|
|
30333
|
-
pkgVersion = "0.5.
|
|
30397
|
+
pkgVersion = "0.5.37";
|
|
30334
30398
|
if (pkgVersion === "unknown") {
|
|
30335
30399
|
try {
|
|
30336
30400
|
const possiblePaths = [
|
|
@@ -30444,9 +30508,7 @@ var init_adhdev_daemon = __esm({
|
|
|
30444
30508
|
}
|
|
30445
30509
|
}).catch(() => {
|
|
30446
30510
|
});
|
|
30447
|
-
const
|
|
30448
|
-
const machineHash = crypto2.createHash("md5").update(os2.hostname() + os2.homedir()).digest("hex").slice(0, 8);
|
|
30449
|
-
const instanceId = `daemon_${machineId}_${machineHash}`;
|
|
30511
|
+
const instanceId = `daemon_${config2.machineId}`;
|
|
30450
30512
|
this.serverConn = new ServerConnection({
|
|
30451
30513
|
serverUrl: options.serverUrl || config2.serverUrl,
|
|
30452
30514
|
token: config2.connectionToken,
|