@adhdev/daemon-core 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/index.d.ts +5 -0
- package/dist/index.js +66 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/providers/_builtin/cli/claude-cli/provider.json +1 -1
- package/providers/_builtin/extension/codex/scripts/1.0/explore_dom.js +8 -2
- package/providers/_builtin/extension/codex/scripts/1.0/list_modes.js +138 -0
- package/providers/_builtin/extension/codex/scripts/1.0/read_chat.js +183 -34
- package/providers/_builtin/extension/codex/scripts/1.0/resolve_action.js +55 -15
- package/providers/_builtin/extension/codex/scripts/1.0/send_message.js +5 -25
- package/providers/_builtin/extension/codex/scripts/1.0/set_mode.js +165 -0
- package/src/agent-stream/provider-adapter.ts +1 -0
- package/src/agent-stream/types.ts +1 -0
- 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 +9 -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, {
|
|
@@ -1457,6 +1458,7 @@ interface AgentStreamState {
|
|
|
1457
1458
|
messages: AgentChatMessage[];
|
|
1458
1459
|
inputContent: string;
|
|
1459
1460
|
model?: string;
|
|
1461
|
+
mode?: string;
|
|
1460
1462
|
activeModal?: {
|
|
1461
1463
|
message: string;
|
|
1462
1464
|
buttons: string[];
|
|
@@ -1782,6 +1784,8 @@ declare class ExtensionProviderInstance implements ProviderInstance {
|
|
|
1782
1784
|
private agentStreams;
|
|
1783
1785
|
private messages;
|
|
1784
1786
|
private activeModal;
|
|
1787
|
+
private currentModel;
|
|
1788
|
+
private currentMode;
|
|
1785
1789
|
private lastAgentStatus;
|
|
1786
1790
|
private generatingStartedAt;
|
|
1787
1791
|
private monitor;
|
|
@@ -2187,6 +2191,7 @@ interface StatusReporterDeps {
|
|
|
2187
2191
|
connectedPeerCount: number;
|
|
2188
2192
|
screenshotActive: boolean;
|
|
2189
2193
|
sendStatus(data: any): void;
|
|
2194
|
+
sendStatusEvent?(event: Record<string, unknown>): boolean;
|
|
2190
2195
|
} | null;
|
|
2191
2196
|
providerLoader: {
|
|
2192
2197
|
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) {
|
|
@@ -2142,6 +2160,8 @@ var ExtensionProviderInstance = class {
|
|
|
2142
2160
|
agentStreams = [];
|
|
2143
2161
|
messages = [];
|
|
2144
2162
|
activeModal = null;
|
|
2163
|
+
currentModel = "";
|
|
2164
|
+
currentMode = "";
|
|
2145
2165
|
lastAgentStatus = "idle";
|
|
2146
2166
|
generatingStartedAt = 0;
|
|
2147
2167
|
monitor;
|
|
@@ -2181,6 +2201,8 @@ var ExtensionProviderInstance = class {
|
|
|
2181
2201
|
activeModal: this.activeModal,
|
|
2182
2202
|
inputContent: ""
|
|
2183
2203
|
} : null,
|
|
2204
|
+
currentModel: this.currentModel || void 0,
|
|
2205
|
+
currentPlan: this.currentMode || void 0,
|
|
2184
2206
|
agentStreams: this.agentStreams,
|
|
2185
2207
|
instanceId: this.instanceId,
|
|
2186
2208
|
lastUpdated: Date.now(),
|
|
@@ -2192,6 +2214,9 @@ var ExtensionProviderInstance = class {
|
|
|
2192
2214
|
if (event === "stream_update") {
|
|
2193
2215
|
if (data?.streams) this.agentStreams = data.streams;
|
|
2194
2216
|
if (data?.messages) this.messages = data.messages;
|
|
2217
|
+
if (data?.activeModal !== void 0) this.activeModal = data.activeModal;
|
|
2218
|
+
if (data?.model) this.currentModel = data.model;
|
|
2219
|
+
if (data?.mode) this.currentMode = data.mode;
|
|
2195
2220
|
if (data?.status) {
|
|
2196
2221
|
const newStatus = data.status;
|
|
2197
2222
|
this.detectTransition(newStatus, data);
|
|
@@ -2221,13 +2246,14 @@ var ExtensionProviderInstance = class {
|
|
|
2221
2246
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now });
|
|
2222
2247
|
} else if (agentStatus === "waiting_approval") {
|
|
2223
2248
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
2249
|
+
const msg = data?.activeModal?.message || data?.modalMessage;
|
|
2224
2250
|
this.pushEvent({
|
|
2225
2251
|
event: "agent:waiting_approval",
|
|
2226
2252
|
chatTitle,
|
|
2227
2253
|
timestamp: now,
|
|
2228
2254
|
ideType: this.ideType,
|
|
2229
2255
|
agentType: this.type,
|
|
2230
|
-
modalMessage:
|
|
2256
|
+
modalMessage: msg,
|
|
2231
2257
|
modalButtons: data?.activeModal?.buttons || data?.modalButtons
|
|
2232
2258
|
});
|
|
2233
2259
|
} else if (agentStatus === "idle" && (this.lastAgentStatus === "generating" || this.lastAgentStatus === "waiting_approval")) {
|
|
@@ -2591,8 +2617,8 @@ var IdeProviderInstance = class {
|
|
|
2591
2617
|
activeModal = void 0;
|
|
2592
2618
|
} else {
|
|
2593
2619
|
activeModal = {
|
|
2594
|
-
message: activeModal.message?.slice(0,
|
|
2595
|
-
buttons: (activeModal.buttons ?? []).filter((t) => t.length <
|
|
2620
|
+
message: activeModal.message?.slice(0, 5e3) ?? "",
|
|
2621
|
+
buttons: (activeModal.buttons ?? []).filter((t) => t.length < 200)
|
|
2596
2622
|
};
|
|
2597
2623
|
}
|
|
2598
2624
|
}
|
|
@@ -2663,12 +2689,13 @@ var IdeProviderInstance = class {
|
|
|
2663
2689
|
this.pushEvent({ event: "agent:generating_started", chatTitle, timestamp: now, ideType: this.type });
|
|
2664
2690
|
} else if (agentStatus === "waiting_approval") {
|
|
2665
2691
|
if (!this.generatingStartedAt.has(agentKey)) this.generatingStartedAt.set(agentKey, now);
|
|
2692
|
+
const msg = chatData.activeModal?.message;
|
|
2666
2693
|
this.pushEvent({
|
|
2667
2694
|
event: "agent:waiting_approval",
|
|
2668
2695
|
chatTitle,
|
|
2669
2696
|
timestamp: now,
|
|
2670
2697
|
ideType: this.type,
|
|
2671
|
-
modalMessage:
|
|
2698
|
+
modalMessage: msg,
|
|
2672
2699
|
modalButtons: chatData.activeModal?.buttons
|
|
2673
2700
|
});
|
|
2674
2701
|
} else if (agentStatus === "idle" && (lastStatus === "generating" || lastStatus === "waiting_approval")) {
|
|
@@ -5614,9 +5641,29 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
5614
5641
|
if (!file.endsWith(".js")) continue;
|
|
5615
5642
|
const scriptName = toCamel(file.replace(".js", ""));
|
|
5616
5643
|
const filePath = path6.join(dir, file);
|
|
5617
|
-
result[scriptName] = (...
|
|
5644
|
+
result[scriptName] = (...args) => {
|
|
5618
5645
|
try {
|
|
5619
|
-
|
|
5646
|
+
let content = fs5.readFileSync(filePath, "utf-8");
|
|
5647
|
+
if (args[0] && typeof args[0] === "object") {
|
|
5648
|
+
for (const [key, val] of Object.entries(args[0])) {
|
|
5649
|
+
let v = val;
|
|
5650
|
+
if (typeof v === "string") {
|
|
5651
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
5652
|
+
v = JSON.stringify(v);
|
|
5653
|
+
}
|
|
5654
|
+
} else {
|
|
5655
|
+
v = JSON.stringify(v);
|
|
5656
|
+
}
|
|
5657
|
+
content = content.replace(new RegExp(`\\$\\{${key}\\}`, "g"), String(v));
|
|
5658
|
+
}
|
|
5659
|
+
} else if (args[0] !== void 0) {
|
|
5660
|
+
let v = String(args[0]);
|
|
5661
|
+
if (!v.startsWith('"') && !v.startsWith("'") && !v.startsWith("`")) {
|
|
5662
|
+
v = JSON.stringify(v);
|
|
5663
|
+
}
|
|
5664
|
+
content = content.replace(/\$\{MESSAGE\}/g, v);
|
|
5665
|
+
}
|
|
5666
|
+
return content;
|
|
5620
5667
|
} catch {
|
|
5621
5668
|
return "";
|
|
5622
5669
|
}
|
|
@@ -6574,6 +6621,12 @@ var DaemonStatusReporter = class {
|
|
|
6574
6621
|
emitStatusEvent(event) {
|
|
6575
6622
|
LOG.info("StatusEvent", `${event.event} (${event.providerType || event.ideType || ""})`);
|
|
6576
6623
|
this.deps.serverConn?.sendMessage("status_event", event);
|
|
6624
|
+
if (this.deps.p2p?.isConnected) {
|
|
6625
|
+
try {
|
|
6626
|
+
this.deps.p2p.sendStatusEvent?.(event);
|
|
6627
|
+
} catch {
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6577
6630
|
}
|
|
6578
6631
|
removeAgentTracking(_key) {
|
|
6579
6632
|
}
|
|
@@ -8853,6 +8906,7 @@ var ProviderStreamAdapter = class {
|
|
|
8853
8906
|
messages: data.messages || [],
|
|
8854
8907
|
inputContent: data.inputContent || "",
|
|
8855
8908
|
model: data.model,
|
|
8909
|
+
mode: data.mode,
|
|
8856
8910
|
activeModal: data.activeModal
|
|
8857
8911
|
};
|
|
8858
8912
|
if (state.messages.length > 0) {
|
|
@@ -10201,11 +10255,15 @@ var DevServer = class _DevServer {
|
|
|
10201
10255
|
this.json(res, 500, { error: "Script function returned null" });
|
|
10202
10256
|
return;
|
|
10203
10257
|
}
|
|
10204
|
-
|
|
10258
|
+
this.log(`Exec script length: ${scriptCode.length}, first 50 chars: ${scriptCode.slice(0, 50)}...`);
|
|
10259
|
+
const isWebviewScript = provider.category === "extension" || scriptName.toLowerCase().includes("webview");
|
|
10205
10260
|
let raw;
|
|
10206
10261
|
if (isWebviewScript) {
|
|
10207
10262
|
const matchText = provider.webviewMatchText;
|
|
10208
10263
|
const matchFn = matchText ? (body2) => body2.includes(matchText) : void 0;
|
|
10264
|
+
if (!cdp.evaluateInWebviewFrame) {
|
|
10265
|
+
throw new Error(`CDP manager does not support evaluateInWebviewFrame`);
|
|
10266
|
+
}
|
|
10209
10267
|
raw = await cdp.evaluateInWebviewFrame(scriptCode, matchFn);
|
|
10210
10268
|
} else {
|
|
10211
10269
|
raw = await cdp.evaluate(scriptCode, 3e4);
|