@adhdev/daemon-core 0.8.87 → 0.8.88
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 -1
- package/dist/index.js +70 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -14
- package/dist/index.mjs.map +1 -1
- package/dist/runtime-defaults.d.ts +11 -0
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/boot/daemon-lifecycle.ts +7 -3
- package/src/cdp/initializer.ts +3 -2
- package/src/cdp/scanner.ts +3 -2
- package/src/cli-adapters/provider-cli-adapter.ts +31 -3
- package/src/index.ts +14 -1
- package/src/runtime-defaults.ts +16 -0
- package/src/session-host/runtime-support.ts +2 -1
- package/src/status/reporter.ts +10 -5
package/dist/index.mjs
CHANGED
|
@@ -3133,8 +3133,25 @@ var init_provider_cli_adapter = __esm({
|
|
|
3133
3133
|
index: typeof message.index === "number" ? message.index : index,
|
|
3134
3134
|
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3135
3135
|
}));
|
|
3136
|
-
const
|
|
3137
|
-
const
|
|
3136
|
+
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
3137
|
+
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle" && parsedHydratedMessages.length > committedHydratedMessages.length && !!parsedLastAssistant;
|
|
3138
|
+
if (shouldAdoptParsedIdleReplay) {
|
|
3139
|
+
this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
|
|
3140
|
+
committedMessages: this.committedMessages,
|
|
3141
|
+
scope: this.currentTurnScope,
|
|
3142
|
+
lastOutputAt: this.lastOutputAt
|
|
3143
|
+
});
|
|
3144
|
+
this.syncMessageViews();
|
|
3145
|
+
}
|
|
3146
|
+
const effectiveCommittedHydratedMessages = shouldAdoptParsedIdleReplay ? this.committedMessages.map((message, index) => buildChatMessage({
|
|
3147
|
+
...message,
|
|
3148
|
+
id: message.id || `msg_${index}`,
|
|
3149
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
3150
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
3151
|
+
})) : committedHydratedMessages;
|
|
3152
|
+
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && effectiveCommittedHydratedMessages.length > parsedHydratedMessages.length;
|
|
3153
|
+
const shouldPreferCommittedIdleReplay = shouldPreferCommittedMessages && !shouldAdoptParsedIdleReplay;
|
|
3154
|
+
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ? effectiveCommittedHydratedMessages : parsedHydratedMessages;
|
|
3138
3155
|
result = {
|
|
3139
3156
|
id: parsed.id || "cli_session",
|
|
3140
3157
|
status: parsed.status || this.currentStatus,
|
|
@@ -8595,6 +8612,21 @@ async function probeCdpPort(port, timeoutMs = 1e3) {
|
|
|
8595
8612
|
|
|
8596
8613
|
// src/cdp/scanner.ts
|
|
8597
8614
|
init_logger();
|
|
8615
|
+
|
|
8616
|
+
// src/runtime-defaults.ts
|
|
8617
|
+
var DEFAULT_CDP_SCAN_INTERVAL_MS = 3e4;
|
|
8618
|
+
var DEFAULT_CDP_DISCOVERY_INTERVAL_MS = 3e4;
|
|
8619
|
+
var DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS = 2e3;
|
|
8620
|
+
var DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS = 3e4;
|
|
8621
|
+
var DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS = 5e3;
|
|
8622
|
+
var MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS = 5e3;
|
|
8623
|
+
var DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS = 15e3;
|
|
8624
|
+
var MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS = 5e3;
|
|
8625
|
+
var DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS = 1e4;
|
|
8626
|
+
var DEFAULT_SESSION_HOST_READY_TIMEOUT_MS = 15e3;
|
|
8627
|
+
var STANDALONE_CDP_SCAN_INTERVAL_MS = 15e3;
|
|
8628
|
+
|
|
8629
|
+
// src/cdp/scanner.ts
|
|
8598
8630
|
var DaemonCdpScanner = class {
|
|
8599
8631
|
ctx;
|
|
8600
8632
|
opts;
|
|
@@ -8628,7 +8660,7 @@ var DaemonCdpScanner = class {
|
|
|
8628
8660
|
*/
|
|
8629
8661
|
startPeriodicScan() {
|
|
8630
8662
|
if (this.scanTimer) return;
|
|
8631
|
-
const interval = this.opts.scanIntervalMs ||
|
|
8663
|
+
const interval = this.opts.scanIntervalMs || DEFAULT_CDP_SCAN_INTERVAL_MS;
|
|
8632
8664
|
this.scanTimer = setInterval(async () => {
|
|
8633
8665
|
const portMap = this.ctx.providerLoader.getCdpPortMap();
|
|
8634
8666
|
for (const [ide, ports] of Object.entries(portMap)) {
|
|
@@ -8648,7 +8680,7 @@ var DaemonCdpScanner = class {
|
|
|
8648
8680
|
/**
|
|
8649
8681
|
* Start periodic agent webview discovery on all connected CDPs.
|
|
8650
8682
|
*/
|
|
8651
|
-
startWebviewDiscovery(intervalMs =
|
|
8683
|
+
startWebviewDiscovery(intervalMs = DEFAULT_CDP_DISCOVERY_INTERVAL_MS) {
|
|
8652
8684
|
if (this.discoveryTimer) return;
|
|
8653
8685
|
this.discoveryTimer = setInterval(async () => {
|
|
8654
8686
|
for (const m of this.ctx.cdpManagers.values()) {
|
|
@@ -8870,7 +8902,7 @@ var DaemonCdpInitializer = class {
|
|
|
8870
8902
|
* Start periodic scanning for newly opened IDEs.
|
|
8871
8903
|
* Idempotent — ignored if already started.
|
|
8872
8904
|
*/
|
|
8873
|
-
startPeriodicScan(intervalMs =
|
|
8905
|
+
startPeriodicScan(intervalMs = DEFAULT_CDP_SCAN_INTERVAL_MS) {
|
|
8874
8906
|
if (this.scanTimer) return;
|
|
8875
8907
|
this.scanTimer = setInterval(async () => {
|
|
8876
8908
|
const { providerLoader, cdpManagers } = this.config;
|
|
@@ -8884,7 +8916,7 @@ var DaemonCdpInitializer = class {
|
|
|
8884
8916
|
/**
|
|
8885
8917
|
* Start periodic agent webview discovery.
|
|
8886
8918
|
*/
|
|
8887
|
-
startDiscovery(intervalMs =
|
|
8919
|
+
startDiscovery(intervalMs = DEFAULT_CDP_DISCOVERY_INTERVAL_MS) {
|
|
8888
8920
|
if (this.discoveryTimer) return;
|
|
8889
8921
|
this.discoveryTimer = setInterval(async () => {
|
|
8890
8922
|
for (const m of this.config.cdpManagers.values()) {
|
|
@@ -18089,19 +18121,19 @@ var DaemonStatusReporter = class {
|
|
|
18089
18121
|
startReporting() {
|
|
18090
18122
|
setTimeout(() => {
|
|
18091
18123
|
this.sendUnifiedStatusReport({ forceServer: true, reason: "initial" }).catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
18092
|
-
},
|
|
18124
|
+
}, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS);
|
|
18093
18125
|
const scheduleServerReport = () => {
|
|
18094
18126
|
this.statusTimer = setTimeout(() => {
|
|
18095
18127
|
this.sendUnifiedStatusReport({ forceServer: true, reason: "periodic" }).catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
18096
18128
|
scheduleServerReport();
|
|
18097
|
-
},
|
|
18129
|
+
}, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS);
|
|
18098
18130
|
};
|
|
18099
18131
|
scheduleServerReport();
|
|
18100
18132
|
this.p2pTimer = setInterval(() => {
|
|
18101
18133
|
if (this.deps.p2p?.isConnected) {
|
|
18102
18134
|
this.sendUnifiedStatusReport({ p2pOnly: true }).catch((e) => LOG.warn("Status", `P2P status send failed: ${e?.message}`));
|
|
18103
18135
|
}
|
|
18104
|
-
},
|
|
18136
|
+
}, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS);
|
|
18105
18137
|
}
|
|
18106
18138
|
stopReporting() {
|
|
18107
18139
|
if (this.statusTimer) {
|
|
@@ -18119,14 +18151,14 @@ var DaemonStatusReporter = class {
|
|
|
18119
18151
|
throttledReport() {
|
|
18120
18152
|
const now = Date.now();
|
|
18121
18153
|
const elapsed = now - this.lastStatusSentAt;
|
|
18122
|
-
if (elapsed >=
|
|
18154
|
+
if (elapsed >= DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS) {
|
|
18123
18155
|
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Throttled report failed: ${e?.message}`));
|
|
18124
18156
|
} else if (!this.statusPendingThrottle) {
|
|
18125
18157
|
this.statusPendingThrottle = true;
|
|
18126
18158
|
setTimeout(() => {
|
|
18127
18159
|
this.statusPendingThrottle = false;
|
|
18128
18160
|
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Deferred report failed: ${e?.message}`));
|
|
18129
|
-
},
|
|
18161
|
+
}, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS - elapsed);
|
|
18130
18162
|
}
|
|
18131
18163
|
}
|
|
18132
18164
|
toDaemonStatusEventName(value) {
|
|
@@ -25386,7 +25418,7 @@ import {
|
|
|
25386
25418
|
SessionHostClient as SessionHostClient2,
|
|
25387
25419
|
getDefaultSessionHostEndpoint
|
|
25388
25420
|
} from "@adhdev/session-host-core";
|
|
25389
|
-
var STARTUP_TIMEOUT_MS =
|
|
25421
|
+
var STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
|
|
25390
25422
|
var STARTUP_POLL_MS = 200;
|
|
25391
25423
|
async function canConnect(endpoint) {
|
|
25392
25424
|
const client = new SessionHostClient2({ endpoint });
|
|
@@ -25802,8 +25834,8 @@ async function initDaemonComponents(config) {
|
|
|
25802
25834
|
}
|
|
25803
25835
|
});
|
|
25804
25836
|
await cdpInitializer.connectAll(detectedIdesRef.value);
|
|
25805
|
-
cdpInitializer.startPeriodicScan(config.cdpScanIntervalMs ??
|
|
25806
|
-
cdpInitializer.startDiscovery(
|
|
25837
|
+
cdpInitializer.startPeriodicScan(config.cdpScanIntervalMs ?? DEFAULT_CDP_SCAN_INTERVAL_MS);
|
|
25838
|
+
cdpInitializer.startDiscovery(DEFAULT_CDP_DISCOVERY_INTERVAL_MS);
|
|
25807
25839
|
const commandHandler = new DaemonCommandHandler({
|
|
25808
25840
|
cdpManagers,
|
|
25809
25841
|
ideType: "unknown",
|
|
@@ -25932,10 +25964,19 @@ export {
|
|
|
25932
25964
|
CliProviderInstance,
|
|
25933
25965
|
DAEMON_WS_PATH,
|
|
25934
25966
|
DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
|
|
25967
|
+
DEFAULT_CDP_DISCOVERY_INTERVAL_MS,
|
|
25968
|
+
DEFAULT_CDP_SCAN_INTERVAL_MS,
|
|
25935
25969
|
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
|
|
25936
25970
|
DEFAULT_DAEMON_PORT,
|
|
25971
|
+
DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
25937
25972
|
DEFAULT_SESSION_HOST_APP_NAME,
|
|
25973
|
+
DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
25974
|
+
DEFAULT_SESSION_HOST_READY_TIMEOUT_MS,
|
|
25938
25975
|
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
25976
|
+
DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS,
|
|
25977
|
+
DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS,
|
|
25978
|
+
DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS,
|
|
25979
|
+
DEV_SERVER_PORT,
|
|
25939
25980
|
DaemonAgentStreamManager,
|
|
25940
25981
|
DaemonCdpInitializer,
|
|
25941
25982
|
DaemonCdpManager,
|
|
@@ -25947,10 +25988,13 @@ export {
|
|
|
25947
25988
|
DevServer,
|
|
25948
25989
|
IdeProviderInstance,
|
|
25949
25990
|
LOG,
|
|
25991
|
+
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
25992
|
+
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
25950
25993
|
NodePtyTransportFactory,
|
|
25951
25994
|
ProviderCliAdapter,
|
|
25952
25995
|
ProviderInstanceManager,
|
|
25953
25996
|
ProviderLoader,
|
|
25997
|
+
STANDALONE_CDP_SCAN_INTERVAL_MS,
|
|
25954
25998
|
SessionHostPtyTransportFactory,
|
|
25955
25999
|
VersionArchive,
|
|
25956
26000
|
appendRecentActivity,
|