@adhdev/daemon-core 0.5.40 → 0.5.42
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 +8 -0
- package/dist/index.js +41 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/config/config.ts +6 -0
- package/src/providers/ide-provider-instance.ts +42 -0
- package/src/providers/status-monitor.ts +15 -15
package/dist/index.d.ts
CHANGED
|
@@ -146,6 +146,12 @@ interface ADHDevConfig {
|
|
|
146
146
|
configuredIdes: string[];
|
|
147
147
|
installedExtensions: string[];
|
|
148
148
|
autoConnect: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated Not read at runtime. Notification preferences are now managed by:
|
|
151
|
+
* - Web UI layer: useNotificationPrefs (localStorage)
|
|
152
|
+
* - Daemon layer: per-provider settings (approvalAlert, longGeneratingAlert)
|
|
153
|
+
* Kept for backward config compat — will be removed in v0.7+.
|
|
154
|
+
*/
|
|
149
155
|
notifications: boolean;
|
|
150
156
|
userEmail: string | null;
|
|
151
157
|
userName: string | null;
|
|
@@ -1830,6 +1836,7 @@ declare class IdeProviderInstance implements ProviderInstance {
|
|
|
1830
1836
|
private tickBusy;
|
|
1831
1837
|
private monitor;
|
|
1832
1838
|
private historyWriter;
|
|
1839
|
+
private autoApproveBusy;
|
|
1833
1840
|
private ideVersion;
|
|
1834
1841
|
private instanceId;
|
|
1835
1842
|
private workspace;
|
|
@@ -1860,6 +1867,7 @@ declare class IdeProviderInstance implements ProviderInstance {
|
|
|
1860
1867
|
private pushEvent;
|
|
1861
1868
|
private flushEvents;
|
|
1862
1869
|
updateCdp(cdp: InstanceContext['cdp']): void;
|
|
1870
|
+
private autoApproveViaScript;
|
|
1863
1871
|
}
|
|
1864
1872
|
|
|
1865
1873
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2065,9 +2065,9 @@ var DEFAULT_MONITOR_CONFIG = {
|
|
|
2065
2065
|
approvalAlert: true,
|
|
2066
2066
|
longGeneratingAlert: true,
|
|
2067
2067
|
longGeneratingThresholdSec: 180,
|
|
2068
|
-
//
|
|
2068
|
+
// 3 minutes
|
|
2069
2069
|
alertCooldownSec: 60
|
|
2070
|
-
//
|
|
2070
|
+
// 1 minute cooldown
|
|
2071
2071
|
};
|
|
2072
2072
|
var StatusMonitor = class {
|
|
2073
2073
|
config;
|
|
@@ -2076,18 +2076,18 @@ var StatusMonitor = class {
|
|
|
2076
2076
|
constructor(config) {
|
|
2077
2077
|
this.config = { ...DEFAULT_MONITOR_CONFIG, ...config };
|
|
2078
2078
|
}
|
|
2079
|
-
/**
|
|
2079
|
+
/** Update config (called from Provider Settings) */
|
|
2080
2080
|
updateConfig(partial) {
|
|
2081
2081
|
Object.assign(this.config, partial);
|
|
2082
2082
|
}
|
|
2083
|
-
/** current config
|
|
2083
|
+
/** Return current config */
|
|
2084
2084
|
getConfig() {
|
|
2085
2085
|
return { ...this.config };
|
|
2086
2086
|
}
|
|
2087
2087
|
/**
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2088
|
+
* Check status transition → return notification event array.
|
|
2089
|
+
* Called from each onTick() or detectStatusTransition().
|
|
2090
|
+
*/
|
|
2091
2091
|
check(agentKey, status, now) {
|
|
2092
2092
|
const events = [];
|
|
2093
2093
|
if (this.config.approvalAlert && status === "waiting_approval") {
|
|
@@ -2432,6 +2432,7 @@ var IdeProviderInstance = class {
|
|
|
2432
2432
|
tickBusy = false;
|
|
2433
2433
|
monitor;
|
|
2434
2434
|
historyWriter;
|
|
2435
|
+
autoApproveBusy = false;
|
|
2435
2436
|
// IDE meta
|
|
2436
2437
|
ideVersion = "";
|
|
2437
2438
|
instanceId;
|
|
@@ -2706,6 +2707,9 @@ var IdeProviderInstance = class {
|
|
|
2706
2707
|
}
|
|
2707
2708
|
this.lastAgentStatuses.set(agentKey, agentStatus);
|
|
2708
2709
|
}
|
|
2710
|
+
if (agentStatus === "waiting_approval" && this.settings.autoApprove && !this.autoApproveBusy) {
|
|
2711
|
+
this.autoApproveViaScript(chatData);
|
|
2712
|
+
}
|
|
2709
2713
|
const monitorEvents = this.monitor.check(agentKey, agentStatus, now);
|
|
2710
2714
|
for (const me of monitorEvents) {
|
|
2711
2715
|
this.pushEvent({ event: me.type, agentKey: me.agentKey, message: me.message, elapsedSec: me.elapsedSec, timestamp: me.timestamp });
|
|
@@ -2724,6 +2728,36 @@ var IdeProviderInstance = class {
|
|
|
2724
2728
|
updateCdp(cdp) {
|
|
2725
2729
|
if (this.context) this.context.cdp = cdp;
|
|
2726
2730
|
}
|
|
2731
|
+
// ─── Auto-approve via CDP script ────────────────────
|
|
2732
|
+
async autoApproveViaScript(_chatData) {
|
|
2733
|
+
const cdp = this.context?.cdp;
|
|
2734
|
+
if (!cdp?.isConnected) return;
|
|
2735
|
+
const scriptFn = this.provider.scripts?.resolveAction;
|
|
2736
|
+
if (typeof scriptFn !== "function") {
|
|
2737
|
+
LOG.debug("IdeInstance", `[IdeInstance:${this.type}] autoApprove: no resolveAction script available`);
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
this.autoApproveBusy = true;
|
|
2741
|
+
try {
|
|
2742
|
+
const script = scriptFn({ action: "approve", button: "", buttonText: "" });
|
|
2743
|
+
if (!script) return;
|
|
2744
|
+
LOG.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: executing resolveAction`);
|
|
2745
|
+
const result = await cdp.evaluate(script, 1e4);
|
|
2746
|
+
LOG.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove result: ${JSON.stringify(result)?.slice(0, 200)}`);
|
|
2747
|
+
this.pushEvent({
|
|
2748
|
+
event: "agent:auto_approved",
|
|
2749
|
+
chatTitle: _chatData?.title || this.provider.name,
|
|
2750
|
+
timestamp: Date.now(),
|
|
2751
|
+
ideType: this.type
|
|
2752
|
+
});
|
|
2753
|
+
} catch (e) {
|
|
2754
|
+
LOG.warn("IdeInstance", `[IdeInstance:${this.type}] autoApprove error: ${e?.message}`);
|
|
2755
|
+
} finally {
|
|
2756
|
+
setTimeout(() => {
|
|
2757
|
+
this.autoApproveBusy = false;
|
|
2758
|
+
}, 500);
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2727
2761
|
};
|
|
2728
2762
|
|
|
2729
2763
|
// src/cdp/setup.ts
|