@adhdev/daemon-core 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/index.d.ts +2 -0
- package/dist/index.js +59 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/cdp/manager.ts +7 -1
- package/src/config/config.ts +19 -0
- package/src/daemon/dev-server.ts +5 -1
- package/src/providers/extension-provider-instance.ts +3 -1
- package/src/providers/ide-provider-instance.ts +4 -3
- package/src/providers/provider-loader.ts +26 -2
- package/src/status/reporter.ts +9 -1
package/dist/index.d.ts
CHANGED
|
@@ -161,6 +161,7 @@ interface ADHDevConfig {
|
|
|
161
161
|
/** Recently used workspaces (IDE / CLI / ACP / default) for quick resume */
|
|
162
162
|
recentWorkspaceActivity?: WorkspaceActivityEntry[];
|
|
163
163
|
machineNickname: string | null;
|
|
164
|
+
machineId?: string;
|
|
164
165
|
cliHistory: CliHistoryEntry[];
|
|
165
166
|
providerSettings: Record<string, Record<string, any>>;
|
|
166
167
|
ideSettings: Record<string, {
|
|
@@ -2187,6 +2188,7 @@ interface StatusReporterDeps {
|
|
|
2187
2188
|
connectedPeerCount: number;
|
|
2188
2189
|
screenshotActive: boolean;
|
|
2189
2190
|
sendStatus(data: any): void;
|
|
2191
|
+
sendStatusEvent?(event: Record<string, unknown>): boolean;
|
|
2190
2192
|
} | null;
|
|
2191
2193
|
providerLoader: {
|
|
2192
2194
|
resolve(type: string): any;
|
package/dist/index.js
CHANGED
|
@@ -250,7 +250,19 @@ function loadConfig() {
|
|
|
250
250
|
delete merged.activeWorkspaceId;
|
|
251
251
|
const hadStoredWorkspaces = Array.isArray(parsed.workspaces) && parsed.workspaces.length > 0;
|
|
252
252
|
migrateWorkspacesFromRecent(merged);
|
|
253
|
+
let configChanged = false;
|
|
254
|
+
if (!merged.machineId) {
|
|
255
|
+
const os15 = require("os");
|
|
256
|
+
const crypto5 = require("crypto");
|
|
257
|
+
const safeHostname = os15.hostname().replace(/[^a-zA-Z0-9]/g, "_");
|
|
258
|
+
const machineHash = crypto5.createHash("md5").update(os15.hostname() + os15.homedir()).digest("hex").slice(0, 8);
|
|
259
|
+
merged.machineId = `${safeHostname}_${machineHash}`;
|
|
260
|
+
configChanged = true;
|
|
261
|
+
}
|
|
253
262
|
if (!hadStoredWorkspaces && (merged.workspaces?.length || 0) > 0) {
|
|
263
|
+
configChanged = true;
|
|
264
|
+
}
|
|
265
|
+
if (configChanged) {
|
|
254
266
|
try {
|
|
255
267
|
saveConfig(merged);
|
|
256
268
|
} catch {
|
|
@@ -348,6 +360,7 @@ var init_config = __esm({
|
|
|
348
360
|
defaultWorkspaceId: null,
|
|
349
361
|
recentWorkspaceActivity: [],
|
|
350
362
|
machineNickname: null,
|
|
363
|
+
machineId: void 0,
|
|
351
364
|
cliHistory: [],
|
|
352
365
|
providerSettings: {},
|
|
353
366
|
ideSettings: {}
|
|
@@ -1498,8 +1511,13 @@ var DaemonCdpManager = class {
|
|
|
1498
1511
|
});
|
|
1499
1512
|
const value = result?.result?.value;
|
|
1500
1513
|
if (value != null) {
|
|
1514
|
+
const strValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
1515
|
+
if (strValue.includes("__adhdev_skip_iframe")) {
|
|
1516
|
+
this.log(`[CDP] evaluateInWebviewFrame: script requested skip in ${iframe.targetId.substring(0, 12)}`);
|
|
1517
|
+
continue;
|
|
1518
|
+
}
|
|
1501
1519
|
this.log(`[CDP] evaluateInWebviewFrame: success in ${iframe.targetId.substring(0, 12)}`);
|
|
1502
|
-
return
|
|
1520
|
+
return strValue;
|
|
1503
1521
|
}
|
|
1504
1522
|
} catch (e) {
|
|
1505
1523
|
if (sessionId) {
|
|
@@ -2192,6 +2210,7 @@ var ExtensionProviderInstance = class {
|
|
|
2192
2210
|
if (event === "stream_update") {
|
|
2193
2211
|
if (data?.streams) this.agentStreams = data.streams;
|
|
2194
2212
|
if (data?.messages) this.messages = data.messages;
|
|
2213
|
+
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
2195
2214
|
if (data?.status) {
|
|
2196
2215
|
const newStatus = data.status;
|
|
2197
2216
|
this.detectTransition(newStatus, data);
|
|
@@ -2221,13 +2240,14 @@ var ExtensionProviderInstance = class {
|
|
|
2221
2240
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
2222
2241
|
} else if (agentStatus === "waiting_approval") {
|
|
2223
2242
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
2243
|
+
const msg = data?.activeModal?.message || data?.modalMessage;
|
|
2224
2244
|
this.pushEvent({
|
|
2225
2245
|
event: "agent:waiting_approval",
|
|
2226
2246
|
chatTitle,
|
|
2227
2247
|
timestamp: now,
|
|
2228
2248
|
ideType: this.ideType,
|
|
2229
2249
|
agentType: this.type,
|
|
2230
|
-
modalMessage:
|
|
2250
|
+
modalMessage: msg,
|
|
2231
2251
|
modalButtons: data?.activeModal?.buttons || data?.modalButtons
|
|
2232
2252
|
});
|
|
2233
2253
|
} else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
|
|
@@ -2591,8 +2611,8 @@ var IdeProviderInstance = class {
|
|
|
2591
2611
|
activeModal = void 0;
|
|
2592
2612
|
} else {
|
|
2593
2613
|
activeModal = {
|
|
2594
|
-
message: activeModal.message?.slice(0,
|
|
2595
|
-
buttons: (activeModal.buttons ?? []).filter((t) => t.length <
|
|
2614
|
+
message: activeModal.message?.slice(0, 5e3) ?? "",
|
|
2615
|
+
buttons: (activeModal.buttons ?? []).filter((t) => t.length < 200)
|
|
2596
2616
|
};
|
|
2597
2617
|
}
|
|
2598
2618
|
}
|
|
@@ -2663,12 +2683,13 @@ var IdeProviderInstance = class {
|
|
|
2663
2683
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now, ideType: this.type });
|
|
2664
2684
|
} else if (agentStatus === "waiting_approval") {
|
|
2665
2685
|
if (!this.generatingStartedAt.has(agentKey)) this.generatingStartedAt.set(agentKey, now);
|
|
2686
|
+
const msg = chatData.activeModal?.message;
|
|
2666
2687
|
this.pushEvent({
|
|
2667
2688
|
event: "agent:waiting_approval",
|
|
2668
2689
|
chatTitle,
|
|
2669
2690
|
timestamp: now,
|
|
2670
2691
|
ideType: this.type,
|
|
2671
|
-
modalMessage:
|
|
2692
|
+
modalMessage: msg,
|
|
2672
2693
|
modalButtons: chatData.activeModal?.buttons
|
|
2673
2694
|
});
|
|
2674
2695
|
} else if (agentStatus === "idle" && (lastStatus === "generating" || lastStatus === "waiting_approval")) {
|
|
@@ -5614,9 +5635,29 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
5614
5635
|
if (!file.endsWith(".js")) continue;
|
|
5615
5636
|
const scriptName = toCamel(file.replace(".js", ""));
|
|
5616
5637
|
const filePath = path6.join(dir, file);
|
|
5617
|
-
result[scriptName] = (...
|
|
5638
|
+
result[scriptName] = (...args) => {
|
|
5618
5639
|
try {
|
|
5619
|
-
|
|
5640
|
+
let content = fs5.readFileSync(filePath, "utf-8");
|
|
5641
|
+
if (args[0] && typeof args[0] === "object") {
|
|
5642
|
+
for (const [key, val] of Object.entries(args[0])) {
|
|
5643
|
+
let v = val;
|
|
5644
|
+
if (typeof v === "string") {
|
|
5645
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
5646
|
+
v = JSON.stringify(v);
|
|
5647
|
+
}
|
|
5648
|
+
} else {
|
|
5649
|
+
v = JSON.stringify(v);
|
|
5650
|
+
}
|
|
5651
|
+
content = content.replace(new RegExp(`\\$\\{${key}\\}`, "g"), String(v));
|
|
5652
|
+
}
|
|
5653
|
+
} else if (args[0] !== void 0) {
|
|
5654
|
+
let v = String(args[0]);
|
|
5655
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
5656
|
+
v = JSON.stringify(v);
|
|
5657
|
+
}
|
|
5658
|
+
content = content.replace(/\$\{MESSAGE\}/g, v);
|
|
5659
|
+
}
|
|
5660
|
+
return content;
|
|
5620
5661
|
} catch {
|
|
5621
5662
|
return "";
|
|
5622
5663
|
}
|
|
@@ -6574,6 +6615,12 @@ var DaemonStatusReporter = class {
|
|
|
6574
6615
|
emitStatusEvent(event) {
|
|
6575
6616
|
LOG.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
6576
6617
|
this.deps.serverConn?.sendMessage("status_event", event);
|
|
6618
|
+
if (this.deps.p2p?.isConnected) {
|
|
6619
|
+
try {
|
|
6620
|
+
this.deps.p2p.sendStatusEvent?.(event);
|
|
6621
|
+
} catch {
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6577
6624
|
}
|
|
6578
6625
|
removeAgentTracking(_key) {
|
|
6579
6626
|
}
|
|
@@ -10201,11 +10248,15 @@ var DevServer = class _DevServer {
|
|
|
10201
10248
|
this.json(res, 500, { error: "Script function returned null" });
|
|
10202
10249
|
return;
|
|
10203
10250
|
}
|
|
10204
|
-
|
|
10251
|
+
this.log(`Exec script length: ${scriptCode.length}, first 50 chars: ${scriptCode.slice(0, 50)}...`);
|
|
10252
|
+
const isWebviewScript = provider.category === "extension" || scriptName.toLowerCase().includes("webview");
|
|
10205
10253
|
let raw;
|
|
10206
10254
|
if (isWebviewScript) {
|
|
10207
10255
|
const matchText = provider.webviewMatchText;
|
|
10208
10256
|
const matchFn = matchText ? (body2) => body2.includes(matchText) : void 0;
|
|
10257
|
+
if (!cdp.evaluateInWebviewFrame) {
|
|
10258
|
+
throw new Error(`CDP manager does not support evaluateInWebviewFrame`);
|
|
10259
|
+
}
|
|
10209
10260
|
raw = await cdp.evaluateInWebviewFrame(scriptCode, matchFn);
|
|
10210
10261
|
} else {
|
|
10211
10262
|
raw = await cdp.evaluate(scriptCode, 3e4);
|