adhdev 0.5.36 → 0.5.38
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 +98 -27
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +98 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/cli/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,
|
|
@@ -18461,6 +18479,8 @@ var require_dist = __commonJS({
|
|
|
18461
18479
|
agentStreams = [];
|
|
18462
18480
|
messages = [];
|
|
18463
18481
|
activeModal = null;
|
|
18482
|
+
currentModel = "";
|
|
18483
|
+
currentMode = "";
|
|
18464
18484
|
lastAgentStatus = "idle";
|
|
18465
18485
|
generatingStartedAt = 0;
|
|
18466
18486
|
monitor;
|
|
@@ -18500,6 +18520,8 @@ var require_dist = __commonJS({
|
|
|
18500
18520
|
activeModal: this.activeModal,
|
|
18501
18521
|
inputContent: ""
|
|
18502
18522
|
} : null,
|
|
18523
|
+
currentModel: this.currentModel || void 0,
|
|
18524
|
+
currentPlan: this.currentMode || void 0,
|
|
18503
18525
|
agentStreams: this.agentStreams,
|
|
18504
18526
|
instanceId: this.instanceId,
|
|
18505
18527
|
lastUpdated: Date.now(),
|
|
@@ -18511,6 +18533,9 @@ var require_dist = __commonJS({
|
|
|
18511
18533
|
if (event === "stream_update") {
|
|
18512
18534
|
if (data?.streams) this.agentStreams = data.streams;
|
|
18513
18535
|
if (data?.messages) this.messages = data.messages;
|
|
18536
|
+
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
18537
|
+
if (data?.model) this.currentModel = data.model;
|
|
18538
|
+
if (data?.mode) this.currentMode = data.mode;
|
|
18514
18539
|
if (data?.status) {
|
|
18515
18540
|
const newStatus = data.status;
|
|
18516
18541
|
this.detectTransition(newStatus, data);
|
|
@@ -18540,13 +18565,14 @@ var require_dist = __commonJS({
|
|
|
18540
18565
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
18541
18566
|
} else if (agentStatus === "waiting_approval") {
|
|
18542
18567
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
18568
|
+
const msg = data?.activeModal?.message || data?.modalMessage;
|
|
18543
18569
|
this.pushEvent({
|
|
18544
18570
|
event: "agent:waiting_approval",
|
|
18545
18571
|
chatTitle,
|
|
18546
18572
|
timestamp: now,
|
|
18547
18573
|
ideType: this.ideType,
|
|
18548
18574
|
agentType: this.type,
|
|
18549
|
-
modalMessage:
|
|
18575
|
+
modalMessage: msg,
|
|
18550
18576
|
modalButtons: data?.activeModal?.buttons || data?.modalButtons
|
|
18551
18577
|
});
|
|
18552
18578
|
} else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
|
|
@@ -18730,7 +18756,7 @@ var require_dist = __commonJS({
|
|
|
18730
18756
|
constructor(provider, instanceKey) {
|
|
18731
18757
|
this.type = provider.type;
|
|
18732
18758
|
this.provider = provider;
|
|
18733
|
-
this.instanceId =
|
|
18759
|
+
this.instanceId = crypto2.randomUUID();
|
|
18734
18760
|
this.monitor = new StatusMonitor();
|
|
18735
18761
|
this.historyWriter = new ChatHistoryWriter();
|
|
18736
18762
|
}
|
|
@@ -18906,8 +18932,8 @@ var require_dist = __commonJS({
|
|
|
18906
18932
|
activeModal = void 0;
|
|
18907
18933
|
} else {
|
|
18908
18934
|
activeModal = {
|
|
18909
|
-
message: activeModal.message?.slice(0,
|
|
18910
|
-
buttons: (activeModal.buttons ?? []).filter((t) => t.length <
|
|
18935
|
+
message: activeModal.message?.slice(0, 5e3) ?? "",
|
|
18936
|
+
buttons: (activeModal.buttons ?? []).filter((t) => t.length < 200)
|
|
18911
18937
|
};
|
|
18912
18938
|
}
|
|
18913
18939
|
}
|
|
@@ -18978,12 +19004,13 @@ var require_dist = __commonJS({
|
|
|
18978
19004
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now, ideType: this.type });
|
|
18979
19005
|
} else if (agentStatus === "waiting_approval") {
|
|
18980
19006
|
if (!this.generatingStartedAt.has(agentKey)) this.generatingStartedAt.set(agentKey, now);
|
|
19007
|
+
const msg = chatData.activeModal?.message;
|
|
18981
19008
|
this.pushEvent({
|
|
18982
19009
|
event: "agent:waiting_approval",
|
|
18983
19010
|
chatTitle,
|
|
18984
19011
|
timestamp: now,
|
|
18985
19012
|
ideType: this.type,
|
|
18986
|
-
modalMessage:
|
|
19013
|
+
modalMessage: msg,
|
|
18987
19014
|
modalButtons: chatData.activeModal?.buttons
|
|
18988
19015
|
});
|
|
18989
19016
|
} else if (agentStatus === "idle" && (lastStatus === "generating" || lastStatus === "waiting_approval")) {
|
|
@@ -21905,9 +21932,29 @@ var require_dist = __commonJS({
|
|
|
21905
21932
|
if (!file2.endsWith(".js")) continue;
|
|
21906
21933
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
21907
21934
|
const filePath = path6.join(dir, file2);
|
|
21908
|
-
result[scriptName] = (...
|
|
21935
|
+
result[scriptName] = (...args) => {
|
|
21909
21936
|
try {
|
|
21910
|
-
|
|
21937
|
+
let content = fs5.readFileSync(filePath, "utf-8");
|
|
21938
|
+
if (args[0] && typeof args[0] === "object") {
|
|
21939
|
+
for (const [key, val] of Object.entries(args[0])) {
|
|
21940
|
+
let v = val;
|
|
21941
|
+
if (typeof v === "string") {
|
|
21942
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
21943
|
+
v = JSON.stringify(v);
|
|
21944
|
+
}
|
|
21945
|
+
} else {
|
|
21946
|
+
v = JSON.stringify(v);
|
|
21947
|
+
}
|
|
21948
|
+
content = content.replace(new RegExp(`\\$\\{${key}\\}`, "g"), String(v));
|
|
21949
|
+
}
|
|
21950
|
+
} else if (args[0] !== void 0) {
|
|
21951
|
+
let v = String(args[0]);
|
|
21952
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
21953
|
+
v = JSON.stringify(v);
|
|
21954
|
+
}
|
|
21955
|
+
content = content.replace(/\$\{MESSAGE\}/g, v);
|
|
21956
|
+
}
|
|
21957
|
+
return content;
|
|
21911
21958
|
} catch {
|
|
21912
21959
|
return "";
|
|
21913
21960
|
}
|
|
@@ -22855,6 +22902,12 @@ var require_dist = __commonJS({
|
|
|
22855
22902
|
emitStatusEvent(event) {
|
|
22856
22903
|
LOG5.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
22857
22904
|
this.deps.serverConn?.sendMessage("status_event", event);
|
|
22905
|
+
if (this.deps.p2p?.isConnected) {
|
|
22906
|
+
try {
|
|
22907
|
+
this.deps.p2p.sendStatusEvent?.(event);
|
|
22908
|
+
} catch {
|
|
22909
|
+
}
|
|
22910
|
+
}
|
|
22858
22911
|
}
|
|
22859
22912
|
removeAgentTracking(_key) {
|
|
22860
22913
|
}
|
|
@@ -25114,6 +25167,7 @@ ${installInfo}`
|
|
|
25114
25167
|
messages: data.messages || [],
|
|
25115
25168
|
inputContent: data.inputContent || "",
|
|
25116
25169
|
model: data.model,
|
|
25170
|
+
mode: data.mode,
|
|
25117
25171
|
activeModal: data.activeModal
|
|
25118
25172
|
};
|
|
25119
25173
|
if (state.messages.length > 0) {
|
|
@@ -26448,11 +26502,15 @@ async (params) => {
|
|
|
26448
26502
|
this.json(res, 500, { error: "Script function returned null" });
|
|
26449
26503
|
return;
|
|
26450
26504
|
}
|
|
26451
|
-
|
|
26505
|
+
this.log(`Exec script length: ${scriptCode.length}, first 50 chars: ${scriptCode.slice(0, 50)}...`);
|
|
26506
|
+
const isWebviewScript = provider.category === "extension" || scriptName.toLowerCase().includes("webview");
|
|
26452
26507
|
let raw;
|
|
26453
26508
|
if (isWebviewScript) {
|
|
26454
26509
|
const matchText = provider.webviewMatchText;
|
|
26455
26510
|
const matchFn = matchText ? (body2) => body2.includes(matchText) : void 0;
|
|
26511
|
+
if (!cdp.evaluateInWebviewFrame) {
|
|
26512
|
+
throw new Error(`CDP manager does not support evaluateInWebviewFrame`);
|
|
26513
|
+
}
|
|
26456
26514
|
raw = await cdp.evaluateInWebviewFrame(scriptCode, matchFn);
|
|
26457
26515
|
} else {
|
|
26458
26516
|
raw = await cdp.evaluate(scriptCode, 3e4);
|
|
@@ -29601,13 +29659,13 @@ ${e?.stack || ""}`);
|
|
|
29601
29659
|
const transport = url2.includes("transport=tcp") ? "tcp" : "udp";
|
|
29602
29660
|
const isTls = url2.startsWith("turns:");
|
|
29603
29661
|
const parts = cleanUrl.replace(/^turns?:/, "").split(":");
|
|
29604
|
-
const
|
|
29662
|
+
const hostname3 = parts[0];
|
|
29605
29663
|
const port = parseInt(parts[1]) || (isTls ? 5349 : 3478);
|
|
29606
29664
|
let relayType = "TurnUdp";
|
|
29607
29665
|
if (isTls) relayType = "TurnTls";
|
|
29608
29666
|
else if (transport === "tcp") relayType = "TurnTcp";
|
|
29609
29667
|
converted.push({
|
|
29610
|
-
hostname:
|
|
29668
|
+
hostname: hostname3,
|
|
29611
29669
|
port,
|
|
29612
29670
|
username: server.username,
|
|
29613
29671
|
password: server.credential,
|
|
@@ -29635,16 +29693,16 @@ ${e?.stack || ""}`);
|
|
|
29635
29693
|
connectedAt: Date.now(),
|
|
29636
29694
|
pendingCandidates: [],
|
|
29637
29695
|
remoteDescriptionSet: false,
|
|
29638
|
-
isRelay: false
|
|
29696
|
+
isRelay: false,
|
|
29697
|
+
lastPongAt: Date.now()
|
|
29639
29698
|
};
|
|
29640
29699
|
this.peers.set(pid, entry);
|
|
29641
29700
|
this.notifyStateChange();
|
|
29642
|
-
|
|
29701
|
+
entry.connectionTimeout = setTimeout(() => {
|
|
29643
29702
|
const peer = this.peers.get(pid);
|
|
29644
29703
|
if (peer?.state === "connecting") {
|
|
29645
|
-
log(`connection timeout (30s) for peer ${pid}`);
|
|
29646
|
-
|
|
29647
|
-
this.notifyStateChange();
|
|
29704
|
+
log(`connection timeout (30s) for peer ${pid} \u2014 full cleanup`);
|
|
29705
|
+
this.disconnectPeer(pid);
|
|
29648
29706
|
}
|
|
29649
29707
|
}, 3e4);
|
|
29650
29708
|
try {
|
|
@@ -29729,9 +29787,11 @@ ${e?.stack || ""}`);
|
|
|
29729
29787
|
filesCh.onMessage((msg) => this.handleCommandMessage(pid, msg));
|
|
29730
29788
|
} catch (e) {
|
|
29731
29789
|
log(`connection failed for peer ${pid}: ${e?.message}`);
|
|
29732
|
-
clearTimeout(timeout);
|
|
29733
29790
|
const peer = this.peers.get(pid);
|
|
29734
|
-
if (peer)
|
|
29791
|
+
if (peer) {
|
|
29792
|
+
if (peer.connectionTimeout) clearTimeout(peer.connectionTimeout);
|
|
29793
|
+
peer.state = "failed";
|
|
29794
|
+
}
|
|
29735
29795
|
this.notifyStateChange();
|
|
29736
29796
|
}
|
|
29737
29797
|
}
|
|
@@ -29753,7 +29813,11 @@ ${e?.stack || ""}`);
|
|
|
29753
29813
|
}
|
|
29754
29814
|
return;
|
|
29755
29815
|
}
|
|
29756
|
-
if (parsed.type === "pong")
|
|
29816
|
+
if (parsed.type === "pong") {
|
|
29817
|
+
const peer = this.peers.get(peerId);
|
|
29818
|
+
if (peer) peer.lastPongAt = Date.now();
|
|
29819
|
+
return;
|
|
29820
|
+
}
|
|
29757
29821
|
if (parsed.type === "screenshot_start") {
|
|
29758
29822
|
const peer = this.peers.get(peerId);
|
|
29759
29823
|
if (!parsed.ideType) {
|
|
@@ -30068,6 +30132,7 @@ ${e?.stack || ""}`);
|
|
|
30068
30132
|
if (!peer) return;
|
|
30069
30133
|
if (peer.failedCleanupTimer) clearTimeout(peer.failedCleanupTimer);
|
|
30070
30134
|
if (peer.heartbeatTimer) clearInterval(peer.heartbeatTimer);
|
|
30135
|
+
if (peer.connectionTimeout) clearTimeout(peer.connectionTimeout);
|
|
30071
30136
|
if (peer.screenshotChannel) try {
|
|
30072
30137
|
peer.screenshotChannel.close();
|
|
30073
30138
|
} catch {
|
|
@@ -30089,12 +30154,19 @@ ${e?.stack || ""}`);
|
|
|
30089
30154
|
const peer = this.peers.get(peerId);
|
|
30090
30155
|
if (!peer) return;
|
|
30091
30156
|
if (peer.heartbeatTimer) clearInterval(peer.heartbeatTimer);
|
|
30157
|
+
peer.lastPongAt = Date.now();
|
|
30092
30158
|
peer.heartbeatTimer = setInterval(() => {
|
|
30093
30159
|
const p = this.peers.get(peerId);
|
|
30094
30160
|
if (!p || p.state !== "connected") {
|
|
30095
30161
|
if (p?.heartbeatTimer) clearInterval(p.heartbeatTimer);
|
|
30096
30162
|
return;
|
|
30097
30163
|
}
|
|
30164
|
+
const sincePong = Date.now() - p.lastPongAt;
|
|
30165
|
+
if (sincePong > 45e3) {
|
|
30166
|
+
log(`Peer ${peerId} pong timeout (${Math.round(sincePong / 1e3)}s) \u2014 disconnecting dead peer`);
|
|
30167
|
+
this.disconnectPeer(peerId);
|
|
30168
|
+
return;
|
|
30169
|
+
}
|
|
30098
30170
|
try {
|
|
30099
30171
|
if (p.commandChannel?.isOpen()) {
|
|
30100
30172
|
p.commandChannel.sendMessage(JSON.stringify({ type: "ping", ts: Date.now() }));
|
|
@@ -30317,7 +30389,7 @@ function stopDaemon() {
|
|
|
30317
30389
|
return false;
|
|
30318
30390
|
}
|
|
30319
30391
|
}
|
|
30320
|
-
var import_daemon_core4, os2, fs2, path2,
|
|
30392
|
+
var import_daemon_core4, os2, fs2, path2, import_chalk, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
|
|
30321
30393
|
var init_adhdev_daemon = __esm({
|
|
30322
30394
|
"src/adhdev-daemon.ts"() {
|
|
30323
30395
|
"use strict";
|
|
@@ -30328,9 +30400,8 @@ var init_adhdev_daemon = __esm({
|
|
|
30328
30400
|
os2 = __toESM(require("os"));
|
|
30329
30401
|
fs2 = __toESM(require("fs"));
|
|
30330
30402
|
path2 = __toESM(require("path"));
|
|
30331
|
-
crypto2 = __toESM(require("crypto"));
|
|
30332
30403
|
import_chalk = __toESM(require("chalk"));
|
|
30333
|
-
pkgVersion = "0.5.
|
|
30404
|
+
pkgVersion = "0.5.38";
|
|
30334
30405
|
if (pkgVersion === "unknown") {
|
|
30335
30406
|
try {
|
|
30336
30407
|
const possiblePaths = [
|
|
@@ -30422,7 +30493,9 @@ var init_adhdev_daemon = __esm({
|
|
|
30422
30493
|
streams: [stream],
|
|
30423
30494
|
messages: stream.messages || [],
|
|
30424
30495
|
status: stream.status || "idle",
|
|
30425
|
-
activeModal: stream.activeModal || null
|
|
30496
|
+
activeModal: stream.activeModal || null,
|
|
30497
|
+
model: stream.model || void 0,
|
|
30498
|
+
mode: stream.mode || void 0
|
|
30426
30499
|
});
|
|
30427
30500
|
}
|
|
30428
30501
|
}
|
|
@@ -30444,9 +30517,7 @@ var init_adhdev_daemon = __esm({
|
|
|
30444
30517
|
}
|
|
30445
30518
|
}).catch(() => {
|
|
30446
30519
|
});
|
|
30447
|
-
const
|
|
30448
|
-
const machineHash = crypto2.createHash("md5").update(os2.hostname() + os2.homedir()).digest("hex").slice(0, 8);
|
|
30449
|
-
const instanceId = `daemon_${machineId}_${machineHash}`;
|
|
30520
|
+
const instanceId = `daemon_${config2.machineId}`;
|
|
30450
30521
|
this.serverConn = new ServerConnection({
|
|
30451
30522
|
serverUrl: options.serverUrl || config2.serverUrl,
|
|
30452
30523
|
token: config2.connectionToken,
|