adhdev 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/cli/index.js +168 -55
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +122 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6367,6 +6367,25 @@ var init_setup = __esm({
|
|
|
6367
6367
|
}
|
|
6368
6368
|
});
|
|
6369
6369
|
|
|
6370
|
+
// ../../oss/packages/daemon-core/src/runtime-defaults.ts
|
|
6371
|
+
var DEFAULT_CDP_SCAN_INTERVAL_MS, DEFAULT_CDP_DISCOVERY_INTERVAL_MS, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS, MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS, MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS, DEFAULT_SESSION_HOST_READY_TIMEOUT_MS, STANDALONE_CDP_SCAN_INTERVAL_MS;
|
|
6372
|
+
var init_runtime_defaults = __esm({
|
|
6373
|
+
"../../oss/packages/daemon-core/src/runtime-defaults.ts"() {
|
|
6374
|
+
"use strict";
|
|
6375
|
+
DEFAULT_CDP_SCAN_INTERVAL_MS = 3e4;
|
|
6376
|
+
DEFAULT_CDP_DISCOVERY_INTERVAL_MS = 3e4;
|
|
6377
|
+
DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS = 2e3;
|
|
6378
|
+
DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS = 3e4;
|
|
6379
|
+
DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS = 5e3;
|
|
6380
|
+
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS = 5e3;
|
|
6381
|
+
DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS = 15e3;
|
|
6382
|
+
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS = 5e3;
|
|
6383
|
+
DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS = 1e4;
|
|
6384
|
+
DEFAULT_SESSION_HOST_READY_TIMEOUT_MS = 15e3;
|
|
6385
|
+
STANDALONE_CDP_SCAN_INTERVAL_MS = 15e3;
|
|
6386
|
+
}
|
|
6387
|
+
});
|
|
6388
|
+
|
|
6370
6389
|
// ../../oss/packages/daemon-core/src/cdp/scanner.ts
|
|
6371
6390
|
var DaemonCdpScanner;
|
|
6372
6391
|
var init_scanner = __esm({
|
|
@@ -6375,6 +6394,7 @@ var init_scanner = __esm({
|
|
|
6375
6394
|
init_manager();
|
|
6376
6395
|
init_setup();
|
|
6377
6396
|
init_logger();
|
|
6397
|
+
init_runtime_defaults();
|
|
6378
6398
|
DaemonCdpScanner = class {
|
|
6379
6399
|
ctx;
|
|
6380
6400
|
opts;
|
|
@@ -6408,7 +6428,7 @@ var init_scanner = __esm({
|
|
|
6408
6428
|
*/
|
|
6409
6429
|
startPeriodicScan() {
|
|
6410
6430
|
if (this.scanTimer) return;
|
|
6411
|
-
const interval = this.opts.scanIntervalMs ||
|
|
6431
|
+
const interval = this.opts.scanIntervalMs || DEFAULT_CDP_SCAN_INTERVAL_MS;
|
|
6412
6432
|
this.scanTimer = setInterval(async () => {
|
|
6413
6433
|
const portMap = this.ctx.providerLoader.getCdpPortMap();
|
|
6414
6434
|
for (const [ide, ports] of Object.entries(portMap)) {
|
|
@@ -6428,7 +6448,7 @@ var init_scanner = __esm({
|
|
|
6428
6448
|
/**
|
|
6429
6449
|
* Start periodic agent webview discovery on all connected CDPs.
|
|
6430
6450
|
*/
|
|
6431
|
-
startWebviewDiscovery(intervalMs =
|
|
6451
|
+
startWebviewDiscovery(intervalMs = DEFAULT_CDP_DISCOVERY_INTERVAL_MS) {
|
|
6432
6452
|
if (this.discoveryTimer) return;
|
|
6433
6453
|
this.discoveryTimer = setInterval(async () => {
|
|
6434
6454
|
for (const m of this.ctx.cdpManagers.values()) {
|
|
@@ -6528,6 +6548,7 @@ var init_initializer = __esm({
|
|
|
6528
6548
|
init_setup();
|
|
6529
6549
|
init_setup();
|
|
6530
6550
|
init_logger();
|
|
6551
|
+
init_runtime_defaults();
|
|
6531
6552
|
DaemonCdpInitializer = class {
|
|
6532
6553
|
config;
|
|
6533
6554
|
scanTimer = null;
|
|
@@ -6659,7 +6680,7 @@ var init_initializer = __esm({
|
|
|
6659
6680
|
* Start periodic scanning for newly opened IDEs.
|
|
6660
6681
|
* Idempotent — ignored if already started.
|
|
6661
6682
|
*/
|
|
6662
|
-
startPeriodicScan(intervalMs =
|
|
6683
|
+
startPeriodicScan(intervalMs = DEFAULT_CDP_SCAN_INTERVAL_MS) {
|
|
6663
6684
|
if (this.scanTimer) return;
|
|
6664
6685
|
this.scanTimer = setInterval(async () => {
|
|
6665
6686
|
const { providerLoader, cdpManagers } = this.config;
|
|
@@ -6673,7 +6694,7 @@ var init_initializer = __esm({
|
|
|
6673
6694
|
/**
|
|
6674
6695
|
* Start periodic agent webview discovery.
|
|
6675
6696
|
*/
|
|
6676
|
-
startDiscovery(intervalMs =
|
|
6697
|
+
startDiscovery(intervalMs = DEFAULT_CDP_DISCOVERY_INTERVAL_MS) {
|
|
6677
6698
|
if (this.discoveryTimer) return;
|
|
6678
6699
|
this.discoveryTimer = setInterval(async () => {
|
|
6679
6700
|
for (const m of this.config.cdpManagers.values()) {
|
|
@@ -13391,8 +13412,25 @@ var init_provider_cli_adapter = __esm({
|
|
|
13391
13412
|
index: typeof message.index === "number" ? message.index : index,
|
|
13392
13413
|
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
13393
13414
|
}));
|
|
13394
|
-
const
|
|
13395
|
-
const
|
|
13415
|
+
const parsedLastAssistant = [...parsedHydratedMessages].reverse().find((message) => message.role === "assistant" && typeof message.content === "string" && message.content.trim());
|
|
13416
|
+
const shouldAdoptParsedIdleReplay = !this.currentTurnScope && !this.activeModal && this.currentStatus === "idle" && parsedHydratedMessages.length > committedHydratedMessages.length && !!parsedLastAssistant;
|
|
13417
|
+
if (shouldAdoptParsedIdleReplay) {
|
|
13418
|
+
this.committedMessages = normalizeCliParsedMessages(parsed.messages, {
|
|
13419
|
+
committedMessages: this.committedMessages,
|
|
13420
|
+
scope: this.currentTurnScope,
|
|
13421
|
+
lastOutputAt: this.lastOutputAt
|
|
13422
|
+
});
|
|
13423
|
+
this.syncMessageViews();
|
|
13424
|
+
}
|
|
13425
|
+
const effectiveCommittedHydratedMessages = shouldAdoptParsedIdleReplay ? this.committedMessages.map((message, index) => buildChatMessage({
|
|
13426
|
+
...message,
|
|
13427
|
+
id: message.id || `msg_${index}`,
|
|
13428
|
+
index: typeof message.index === "number" ? message.index : index,
|
|
13429
|
+
receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
|
|
13430
|
+
})) : committedHydratedMessages;
|
|
13431
|
+
const shouldPreferCommittedHistoryReplay = !this.currentTurnScope && !this.activeModal && effectiveCommittedHydratedMessages.length > parsedHydratedMessages.length;
|
|
13432
|
+
const shouldPreferCommittedIdleReplay = shouldPreferCommittedMessages && !shouldAdoptParsedIdleReplay;
|
|
13433
|
+
const hydratedMessages = shouldPreferCommittedIdleReplay || shouldPreferCommittedHistoryReplay ? effectiveCommittedHydratedMessages : parsedHydratedMessages;
|
|
13396
13434
|
result = {
|
|
13397
13435
|
id: parsed.id || "cli_session",
|
|
13398
13436
|
status: parsed.status || this.currentStatus,
|
|
@@ -38134,6 +38172,7 @@ var init_reporter = __esm({
|
|
|
38134
38172
|
"../../oss/packages/daemon-core/src/status/reporter.ts"() {
|
|
38135
38173
|
"use strict";
|
|
38136
38174
|
init_logger();
|
|
38175
|
+
init_runtime_defaults();
|
|
38137
38176
|
init_builders();
|
|
38138
38177
|
init_snapshot();
|
|
38139
38178
|
DaemonStatusReporter = class {
|
|
@@ -38154,19 +38193,19 @@ var init_reporter = __esm({
|
|
|
38154
38193
|
startReporting() {
|
|
38155
38194
|
setTimeout(() => {
|
|
38156
38195
|
this.sendUnifiedStatusReport({ forceServer: true, reason: "initial" }).catch((e) => LOG.warn("Status", `Initial report failed: ${e?.message}`));
|
|
38157
|
-
},
|
|
38196
|
+
}, DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS);
|
|
38158
38197
|
const scheduleServerReport = () => {
|
|
38159
38198
|
this.statusTimer = setTimeout(() => {
|
|
38160
38199
|
this.sendUnifiedStatusReport({ forceServer: true, reason: "periodic" }).catch((e) => LOG.warn("Status", `Periodic report failed: ${e?.message}`));
|
|
38161
38200
|
scheduleServerReport();
|
|
38162
|
-
},
|
|
38201
|
+
}, DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS);
|
|
38163
38202
|
};
|
|
38164
38203
|
scheduleServerReport();
|
|
38165
38204
|
this.p2pTimer = setInterval(() => {
|
|
38166
38205
|
if (this.deps.p2p?.isConnected) {
|
|
38167
38206
|
this.sendUnifiedStatusReport({ p2pOnly: true }).catch((e) => LOG.warn("Status", `P2P status send failed: ${e?.message}`));
|
|
38168
38207
|
}
|
|
38169
|
-
},
|
|
38208
|
+
}, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS);
|
|
38170
38209
|
}
|
|
38171
38210
|
stopReporting() {
|
|
38172
38211
|
if (this.statusTimer) {
|
|
@@ -38184,14 +38223,14 @@ var init_reporter = __esm({
|
|
|
38184
38223
|
throttledReport() {
|
|
38185
38224
|
const now = Date.now();
|
|
38186
38225
|
const elapsed = now - this.lastStatusSentAt;
|
|
38187
|
-
if (elapsed >=
|
|
38226
|
+
if (elapsed >= DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS) {
|
|
38188
38227
|
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Throttled report failed: ${e?.message}`));
|
|
38189
38228
|
} else if (!this.statusPendingThrottle) {
|
|
38190
38229
|
this.statusPendingThrottle = true;
|
|
38191
38230
|
setTimeout(() => {
|
|
38192
38231
|
this.statusPendingThrottle = false;
|
|
38193
38232
|
this.sendUnifiedStatusReport().catch((e) => LOG.warn("Status", `Deferred report failed: ${e?.message}`));
|
|
38194
|
-
},
|
|
38233
|
+
}, DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS - elapsed);
|
|
38195
38234
|
}
|
|
38196
38235
|
}
|
|
38197
38236
|
toDaemonStatusEventName(value) {
|
|
@@ -45617,7 +45656,8 @@ var init_runtime_support = __esm({
|
|
|
45617
45656
|
"../../oss/packages/daemon-core/src/session-host/runtime-support.ts"() {
|
|
45618
45657
|
"use strict";
|
|
45619
45658
|
init_dist();
|
|
45620
|
-
|
|
45659
|
+
init_runtime_defaults();
|
|
45660
|
+
STARTUP_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
|
|
45621
45661
|
STARTUP_POLL_MS = 200;
|
|
45622
45662
|
}
|
|
45623
45663
|
});
|
|
@@ -45997,8 +46037,8 @@ async function initDaemonComponents(config2) {
|
|
|
45997
46037
|
}
|
|
45998
46038
|
});
|
|
45999
46039
|
await cdpInitializer.connectAll(detectedIdesRef.value);
|
|
46000
|
-
cdpInitializer.startPeriodicScan(config2.cdpScanIntervalMs ??
|
|
46001
|
-
cdpInitializer.startDiscovery(
|
|
46040
|
+
cdpInitializer.startPeriodicScan(config2.cdpScanIntervalMs ?? DEFAULT_CDP_SCAN_INTERVAL_MS);
|
|
46041
|
+
cdpInitializer.startDiscovery(DEFAULT_CDP_DISCOVERY_INTERVAL_MS);
|
|
46002
46042
|
const commandHandler = new DaemonCommandHandler({
|
|
46003
46043
|
cdpManagers,
|
|
46004
46044
|
ideType: "unknown",
|
|
@@ -46137,6 +46177,7 @@ var init_daemon_lifecycle = __esm({
|
|
|
46137
46177
|
init_cli_detector();
|
|
46138
46178
|
init_registry();
|
|
46139
46179
|
init_logger();
|
|
46180
|
+
init_runtime_defaults();
|
|
46140
46181
|
init_config();
|
|
46141
46182
|
}
|
|
46142
46183
|
});
|
|
@@ -46151,10 +46192,19 @@ __export(src_exports, {
|
|
|
46151
46192
|
CliProviderInstance: () => CliProviderInstance,
|
|
46152
46193
|
DAEMON_WS_PATH: () => DAEMON_WS_PATH,
|
|
46153
46194
|
DEFAULT_ACTIVE_CHAT_POLL_STATUSES: () => DEFAULT_ACTIVE_CHAT_POLL_STATUSES,
|
|
46195
|
+
DEFAULT_CDP_DISCOVERY_INTERVAL_MS: () => DEFAULT_CDP_DISCOVERY_INTERVAL_MS,
|
|
46196
|
+
DEFAULT_CDP_SCAN_INTERVAL_MS: () => DEFAULT_CDP_SCAN_INTERVAL_MS,
|
|
46154
46197
|
DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS: () => DEFAULT_CHAT_TAIL_RECENT_MESSAGE_GRACE_MS,
|
|
46155
46198
|
DEFAULT_DAEMON_PORT: () => DEFAULT_DAEMON_PORT,
|
|
46199
|
+
DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
46156
46200
|
DEFAULT_SESSION_HOST_APP_NAME: () => DEFAULT_SESSION_HOST_APP_NAME,
|
|
46201
|
+
DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS: () => DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
46202
|
+
DEFAULT_SESSION_HOST_READY_TIMEOUT_MS: () => DEFAULT_SESSION_HOST_READY_TIMEOUT_MS,
|
|
46157
46203
|
DEFAULT_STANDALONE_SESSION_HOST_APP_NAME: () => DEFAULT_STANDALONE_SESSION_HOST_APP_NAME,
|
|
46204
|
+
DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS: () => DEFAULT_STATUS_INITIAL_REPORT_DELAY_MS,
|
|
46205
|
+
DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS: () => DEFAULT_STATUS_P2P_REPORT_INTERVAL_MS,
|
|
46206
|
+
DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS: () => DEFAULT_STATUS_SERVER_REPORT_INTERVAL_MS,
|
|
46207
|
+
DEV_SERVER_PORT: () => DEV_SERVER_PORT,
|
|
46158
46208
|
DaemonAgentStreamManager: () => DaemonAgentStreamManager,
|
|
46159
46209
|
DaemonCdpInitializer: () => DaemonCdpInitializer,
|
|
46160
46210
|
DaemonCdpManager: () => DaemonCdpManager,
|
|
@@ -46166,10 +46216,13 @@ __export(src_exports, {
|
|
|
46166
46216
|
DevServer: () => DevServer,
|
|
46167
46217
|
IdeProviderInstance: () => IdeProviderInstance,
|
|
46168
46218
|
LOG: () => LOG,
|
|
46219
|
+
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
46220
|
+
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS: () => MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
46169
46221
|
NodePtyTransportFactory: () => NodePtyTransportFactory,
|
|
46170
46222
|
ProviderCliAdapter: () => ProviderCliAdapter,
|
|
46171
46223
|
ProviderInstanceManager: () => ProviderInstanceManager,
|
|
46172
46224
|
ProviderLoader: () => ProviderLoader,
|
|
46225
|
+
STANDALONE_CDP_SCAN_INTERVAL_MS: () => STANDALONE_CDP_SCAN_INTERVAL_MS,
|
|
46173
46226
|
SessionHostPtyTransportFactory: () => SessionHostPtyTransportFactory,
|
|
46174
46227
|
VersionArchive: () => VersionArchive,
|
|
46175
46228
|
appendRecentActivity: () => appendRecentActivity,
|
|
@@ -46308,6 +46361,7 @@ var init_src = __esm({
|
|
|
46308
46361
|
init_cli_manager();
|
|
46309
46362
|
init_launch();
|
|
46310
46363
|
init_ipc_protocol();
|
|
46364
|
+
init_runtime_defaults();
|
|
46311
46365
|
init_chat_history();
|
|
46312
46366
|
init_chat_signatures();
|
|
46313
46367
|
init_subscription_updates();
|
|
@@ -46350,7 +46404,7 @@ function resolveDaemonCommandPort(port, env3 = process.env) {
|
|
|
46350
46404
|
return explicitPort;
|
|
46351
46405
|
}
|
|
46352
46406
|
const envPort = parseInt(env3.ADHDEV_DAEMON_PORT || "", 10);
|
|
46353
|
-
return Number.isFinite(envPort) && envPort > 0 ? envPort :
|
|
46407
|
+
return Number.isFinite(envPort) && envPort > 0 ? envPort : DEFAULT_DAEMON_PORT;
|
|
46354
46408
|
}
|
|
46355
46409
|
async function sendDaemonCommand(cmd, args = {}, port) {
|
|
46356
46410
|
const resolvedPort = resolveDaemonCommandPort(port);
|
|
@@ -46474,6 +46528,7 @@ async function directCdpEval(expression, port = 9222) {
|
|
|
46474
46528
|
var init_cdp_utils = __esm({
|
|
46475
46529
|
"src/cli/cdp-utils.ts"() {
|
|
46476
46530
|
"use strict";
|
|
46531
|
+
init_src();
|
|
46477
46532
|
}
|
|
46478
46533
|
});
|
|
46479
46534
|
|
|
@@ -77797,6 +77852,10 @@ var init_server_connection = __esm({
|
|
|
77797
77852
|
}
|
|
77798
77853
|
}
|
|
77799
77854
|
scheduleReconnect() {
|
|
77855
|
+
if (this.reconnectTimer) {
|
|
77856
|
+
clearTimeout(this.reconnectTimer);
|
|
77857
|
+
this.reconnectTimer = null;
|
|
77858
|
+
}
|
|
77800
77859
|
const delay = Math.min(2e3 * Math.pow(1.5, this.reconnectAttempts), 6e4);
|
|
77801
77860
|
this.reconnectAttempts++;
|
|
77802
77861
|
LOG.info("Server", `[ServerConn] Reconnecting in ${(delay / 1e3).toFixed(1)}s (attempt ${this.reconnectAttempts})...`);
|
|
@@ -78444,9 +78503,44 @@ async function initiateConnection(deps, peerId, sharePermission) {
|
|
|
78444
78503
|
clearTimeout(peer.failedCleanupTimer);
|
|
78445
78504
|
peer.failedCleanupTimer = void 0;
|
|
78446
78505
|
}
|
|
78506
|
+
if (peer.disconnectTimer) {
|
|
78507
|
+
clearTimeout(peer.disconnectTimer);
|
|
78508
|
+
peer.disconnectTimer = void 0;
|
|
78509
|
+
}
|
|
78447
78510
|
deps.notifyStateChange();
|
|
78511
|
+
} else if (pcState === "disconnected") {
|
|
78512
|
+
log(`Peer ${pid} ICE disconnected \u2014 waiting 3s for recovery`);
|
|
78513
|
+
if (peer.disconnectTimer) clearTimeout(peer.disconnectTimer);
|
|
78514
|
+
peer.disconnectTimer = setTimeout(() => {
|
|
78515
|
+
const p = deps.peers.get(pid);
|
|
78516
|
+
if (!p) return;
|
|
78517
|
+
p.disconnectTimer = void 0;
|
|
78518
|
+
let currentState;
|
|
78519
|
+
try {
|
|
78520
|
+
currentState = pc.state?.();
|
|
78521
|
+
} catch {
|
|
78522
|
+
}
|
|
78523
|
+
if (currentState !== "connected") {
|
|
78524
|
+
log(`Peer ${pid} ICE recovery timeout (state=${currentState ?? "unknown"}) \u2014 marking failed`);
|
|
78525
|
+
p.state = "failed";
|
|
78526
|
+
deps.notifyStateChange();
|
|
78527
|
+
if (!p.failedCleanupTimer) {
|
|
78528
|
+
p.failedCleanupTimer = setTimeout(() => {
|
|
78529
|
+
const pp = deps.peers.get(pid);
|
|
78530
|
+
if (pp?.state === "failed") {
|
|
78531
|
+
log(`Auto-cleanup stale failed peer ${pid}`);
|
|
78532
|
+
disconnectPeer(deps.peers, pid, deps.notifyStateChange);
|
|
78533
|
+
}
|
|
78534
|
+
}, 3e4);
|
|
78535
|
+
}
|
|
78536
|
+
}
|
|
78537
|
+
}, 3e3);
|
|
78448
78538
|
} else if (pcState === "failed" || pcState === "closed") {
|
|
78449
78539
|
peer.state = "failed";
|
|
78540
|
+
if (peer.disconnectTimer) {
|
|
78541
|
+
clearTimeout(peer.disconnectTimer);
|
|
78542
|
+
peer.disconnectTimer = void 0;
|
|
78543
|
+
}
|
|
78450
78544
|
deps.notifyStateChange();
|
|
78451
78545
|
if (!peer.failedCleanupTimer) {
|
|
78452
78546
|
peer.failedCleanupTimer = setTimeout(() => {
|
|
@@ -78604,6 +78698,7 @@ function disconnectPeer(peers, peerId, notifyStateChange) {
|
|
|
78604
78698
|
if (peer.failedCleanupTimer) clearTimeout(peer.failedCleanupTimer);
|
|
78605
78699
|
if (peer.heartbeatTimer) clearInterval(peer.heartbeatTimer);
|
|
78606
78700
|
if (peer.connectionTimeout) clearTimeout(peer.connectionTimeout);
|
|
78701
|
+
if (peer.disconnectTimer) clearTimeout(peer.disconnectTimer);
|
|
78607
78702
|
if (peer.dataChannel) try {
|
|
78608
78703
|
peer.dataChannel.close();
|
|
78609
78704
|
} catch {
|
|
@@ -86058,8 +86153,9 @@ var init_session_host = __esm({
|
|
|
86058
86153
|
init_src();
|
|
86059
86154
|
init_dist();
|
|
86060
86155
|
init_session_host_hygiene();
|
|
86156
|
+
init_runtime_defaults();
|
|
86061
86157
|
SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || DEFAULT_SESSION_HOST_APP_NAME;
|
|
86062
|
-
SESSION_HOST_START_TIMEOUT_MS =
|
|
86158
|
+
SESSION_HOST_START_TIMEOUT_MS = DEFAULT_SESSION_HOST_READY_TIMEOUT_MS;
|
|
86063
86159
|
}
|
|
86064
86160
|
});
|
|
86065
86161
|
|
|
@@ -86381,7 +86477,8 @@ var init_adhdev_daemon = __esm({
|
|
|
86381
86477
|
init_source();
|
|
86382
86478
|
init_version();
|
|
86383
86479
|
init_src();
|
|
86384
|
-
|
|
86480
|
+
init_runtime_defaults();
|
|
86481
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.88" });
|
|
86385
86482
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
86386
86483
|
localHttpServer = null;
|
|
86387
86484
|
localWss = null;
|
|
@@ -86413,7 +86510,7 @@ var init_adhdev_daemon = __esm({
|
|
|
86413
86510
|
"session_host_restart_session"
|
|
86414
86511
|
]);
|
|
86415
86512
|
constructor() {
|
|
86416
|
-
this.localPort =
|
|
86513
|
+
this.localPort = DEFAULT_DAEMON_PORT;
|
|
86417
86514
|
}
|
|
86418
86515
|
applyDebugRuntime(options) {
|
|
86419
86516
|
this.debugConfig = resolveDebugRuntimeConfig({
|
|
@@ -86604,7 +86701,10 @@ var init_adhdev_daemon = __esm({
|
|
|
86604
86701
|
}
|
|
86605
86702
|
}
|
|
86606
86703
|
buildMachineRuntimeUpdateForSubscription(subscription) {
|
|
86607
|
-
const intervalMs = Math.max(
|
|
86704
|
+
const intervalMs = Math.max(
|
|
86705
|
+
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
86706
|
+
Number(subscription.params.intervalMs || DEFAULT_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS)
|
|
86707
|
+
);
|
|
86608
86708
|
const now = Date.now();
|
|
86609
86709
|
if (subscription.lastSentAt > 0 && now - subscription.lastSentAt < intervalMs) {
|
|
86610
86710
|
return null;
|
|
@@ -86625,7 +86725,10 @@ var init_adhdev_daemon = __esm({
|
|
|
86625
86725
|
}
|
|
86626
86726
|
async buildSessionHostDiagnosticsUpdateForSubscription(subscription) {
|
|
86627
86727
|
if (!this.sessionHostController) return null;
|
|
86628
|
-
const intervalMs = Math.max(
|
|
86728
|
+
const intervalMs = Math.max(
|
|
86729
|
+
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
86730
|
+
Number(subscription.params.intervalMs || DEFAULT_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS)
|
|
86731
|
+
);
|
|
86629
86732
|
const now = Date.now();
|
|
86630
86733
|
if (subscription.lastSentAt > 0 && now - subscription.lastSentAt < intervalMs) {
|
|
86631
86734
|
return null;
|
|
@@ -87696,7 +87799,7 @@ async function startDaemonFlow() {
|
|
|
87696
87799
|
});
|
|
87697
87800
|
}
|
|
87698
87801
|
} catch {
|
|
87699
|
-
daemon.start({ localPort:
|
|
87802
|
+
daemon.start({ localPort: DEFAULT_DAEMON_PORT, foreground: false }).catch(() => {
|
|
87700
87803
|
});
|
|
87701
87804
|
}
|
|
87702
87805
|
let started = false;
|
|
@@ -88843,6 +88946,7 @@ init_src();
|
|
|
88843
88946
|
|
|
88844
88947
|
// src/cli/setup-commands.ts
|
|
88845
88948
|
init_source();
|
|
88949
|
+
init_src();
|
|
88846
88950
|
|
|
88847
88951
|
// src/cli/provider-source-status.ts
|
|
88848
88952
|
function buildProviderSourceStatusLines(config2) {
|
|
@@ -88857,6 +88961,7 @@ function buildProviderSourceStatusLines(config2) {
|
|
|
88857
88961
|
|
|
88858
88962
|
// src/cli/setup-commands.ts
|
|
88859
88963
|
init_cdp_utils();
|
|
88964
|
+
var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS = 1500;
|
|
88860
88965
|
function resolveLaunchableProviderTarget(providerLoader, targetArg) {
|
|
88861
88966
|
if (!targetArg) return null;
|
|
88862
88967
|
const resolvedType = providerLoader.resolveAlias(targetArg.toLowerCase());
|
|
@@ -89093,7 +89198,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
89093
89198
|
if (!isDaemonRunning2({ port: daemonPort })) {
|
|
89094
89199
|
spinner2.stop();
|
|
89095
89200
|
console.log(source_default.yellow(`
|
|
89096
|
-
\u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort ===
|
|
89201
|
+
\u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort === DEFAULT_DAEMON_PORT ? "" : ` -p ${daemonPort}`}' first.
|
|
89097
89202
|
`));
|
|
89098
89203
|
console.log(source_default.gray(" Then run: adhdev launch " + targetArg));
|
|
89099
89204
|
process.exit(1);
|
|
@@ -89229,7 +89334,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
89229
89334
|
const daemonPort = resolveDaemonCommandPort();
|
|
89230
89335
|
if (!isDaemonRunning2({ port: daemonPort })) {
|
|
89231
89336
|
console.log(source_default.yellow(`
|
|
89232
|
-
\u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort ===
|
|
89337
|
+
\u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort === DEFAULT_DAEMON_PORT ? "" : ` -p ${daemonPort}`}' first.
|
|
89233
89338
|
`));
|
|
89234
89339
|
console.log(source_default.gray(` Then run: adhdev history list ${providerArg}`));
|
|
89235
89340
|
process.exit(1);
|
|
@@ -89301,7 +89406,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
89301
89406
|
const daemonPort = resolveDaemonCommandPort();
|
|
89302
89407
|
if (!isDaemonRunning2({ port: daemonPort })) {
|
|
89303
89408
|
console.log(source_default.yellow(`
|
|
89304
|
-
\u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort ===
|
|
89409
|
+
\u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort === DEFAULT_DAEMON_PORT ? "" : ` -p ${daemonPort}`}' first.
|
|
89305
89410
|
`));
|
|
89306
89411
|
console.log(source_default.gray(` Then run: adhdev history resume ${providerArg} ${historySessionId}`));
|
|
89307
89412
|
process.exit(1);
|
|
@@ -89436,8 +89541,8 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
89436
89541
|
if (daemonRunning) {
|
|
89437
89542
|
try {
|
|
89438
89543
|
const controller = new AbortController();
|
|
89439
|
-
const timer = setTimeout(() => controller.abort(),
|
|
89440
|
-
const res = await fetch(
|
|
89544
|
+
const timer = setTimeout(() => controller.abort(), DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS);
|
|
89545
|
+
const res = await fetch(`http://127.0.0.1:${DEFAULT_DAEMON_PORT}/health`, { signal: controller.signal });
|
|
89441
89546
|
clearTimeout(timer);
|
|
89442
89547
|
if (res.ok) {
|
|
89443
89548
|
const data = await res.json();
|
|
@@ -89613,6 +89718,7 @@ function registerSetupCommands(program2, providerLoader) {
|
|
|
89613
89718
|
|
|
89614
89719
|
// src/cli/daemon-commands.ts
|
|
89615
89720
|
init_source();
|
|
89721
|
+
init_src();
|
|
89616
89722
|
|
|
89617
89723
|
// src/cli/runtime-tools.ts
|
|
89618
89724
|
var fs24 = __toESM(require("fs"));
|
|
@@ -89776,6 +89882,11 @@ function formatDebugTraceEntryLine(entry) {
|
|
|
89776
89882
|
}
|
|
89777
89883
|
|
|
89778
89884
|
// src/cli/daemon-commands.ts
|
|
89885
|
+
var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS2 = 1500;
|
|
89886
|
+
var DEFAULT_TRACE_FOLLOW_INTERVAL_MS = 1500;
|
|
89887
|
+
var DEFAULT_DAEMON_PORT_TEXT = String(DEFAULT_DAEMON_PORT);
|
|
89888
|
+
var DEV_SERVER_PORT2 = 19280;
|
|
89889
|
+
var DEV_SERVER_BASE_URL = `http://127.0.0.1:${DEV_SERVER_PORT2}`;
|
|
89779
89890
|
function hideCommand(command) {
|
|
89780
89891
|
if (typeof command.hideHelp === "function") {
|
|
89781
89892
|
command.hideHelp();
|
|
@@ -89785,7 +89896,7 @@ function hideCommand(command) {
|
|
|
89785
89896
|
}
|
|
89786
89897
|
async function fetchLocalDaemonHealth(port) {
|
|
89787
89898
|
const controller = new AbortController();
|
|
89788
|
-
const timer = setTimeout(() => controller.abort(),
|
|
89899
|
+
const timer = setTimeout(() => controller.abort(), DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS2);
|
|
89789
89900
|
try {
|
|
89790
89901
|
const res = await fetch(`http://127.0.0.1:${port}/health`, { signal: controller.signal });
|
|
89791
89902
|
if (!res.ok) return null;
|
|
@@ -89977,9 +90088,9 @@ async function printRuntimeGroups(records, options) {
|
|
|
89977
90088
|
}
|
|
89978
90089
|
}
|
|
89979
90090
|
async function handleTraceCommand(options) {
|
|
89980
|
-
const port = parseInt(String(options.port ??
|
|
90091
|
+
const port = parseInt(String(options.port ?? DEFAULT_DAEMON_PORT_TEXT), 10) || DEFAULT_DAEMON_PORT;
|
|
89981
90092
|
const count = Math.max(1, Math.min(500, parseInt(String(options.count ?? "40"), 10) || 40));
|
|
89982
|
-
const intervalMs = Math.max(250, Math.min(3e4, parseInt(String(options.interval ??
|
|
90093
|
+
const intervalMs = Math.max(250, Math.min(3e4, parseInt(String(options.interval ?? String(DEFAULT_TRACE_FOLLOW_INTERVAL_MS)), 10) || DEFAULT_TRACE_FOLLOW_INTERVAL_MS));
|
|
89983
90094
|
const baseArgs = {
|
|
89984
90095
|
count,
|
|
89985
90096
|
category: options.category,
|
|
@@ -90083,11 +90194,11 @@ async function handleTraceCommand(options) {
|
|
|
90083
90194
|
}
|
|
90084
90195
|
}
|
|
90085
90196
|
function registerDaemonCommands(program2, pkgVersion3) {
|
|
90086
|
-
program2.command("daemon").description("\u{1F680} Start ADHDev Daemon \u2014 unified hub for IDE monitoring, agent management, and remote control").option("-p, --port <port>", "Local WS server port",
|
|
90197
|
+
program2.command("daemon").description("\u{1F680} Start ADHDev Daemon \u2014 unified hub for IDE monitoring, agent management, and remote control").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).option("--server <url>", "Override server URL for testing").option("--dev", "Enable Dev Mode \u2014 HTTP API on :19280 for script debugging + structured trace collection").option("--log-level <level>", "Console log level (debug|info|warn|error)").option("--trace", "Enable structured debug trace collection").option("--trace-content", "Include richer content snapshots in debug traces").option("--trace-buffer-size <count>", "Structured trace ring buffer size").action(async (options) => {
|
|
90087
90198
|
const { AdhdevDaemon: AdhdevDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
90088
90199
|
const daemon = new AdhdevDaemon2();
|
|
90089
90200
|
await daemon.start({
|
|
90090
|
-
localPort: parseInt(options.port) ||
|
|
90201
|
+
localPort: parseInt(options.port) || DEFAULT_DAEMON_PORT,
|
|
90091
90202
|
serverUrl: options.server,
|
|
90092
90203
|
foreground: true,
|
|
90093
90204
|
dev: options.dev || false,
|
|
@@ -90097,7 +90208,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90097
90208
|
traceBufferSize: options.traceBufferSize ? parseInt(options.traceBufferSize, 10) || void 0 : void 0
|
|
90098
90209
|
});
|
|
90099
90210
|
});
|
|
90100
|
-
program2.command("trace").description("Inspect structured daemon trace from the running local daemon (for example: --category session_host)").option("-p, --port <port>", "Local daemon IPC port",
|
|
90211
|
+
program2.command("trace").description("Inspect structured daemon trace from the running local daemon (for example: --category session_host)").option("-p, --port <port>", "Local daemon IPC port", DEFAULT_DAEMON_PORT_TEXT).option("--category <category>", "Filter by trace category (for example: session_host)").option("--interaction <id>", "Filter by interaction id").option("--count <count>", "Maximum number of trace entries to fetch", "40").option("--follow", "Keep polling and print new trace entries as they arrive").option("--interval <ms>", "Polling interval for --follow mode", String(DEFAULT_TRACE_FOLLOW_INTERVAL_MS)).option("--json", "Print raw trace JSON output").action(async (options) => {
|
|
90101
90212
|
try {
|
|
90102
90213
|
await handleTraceCommand(options);
|
|
90103
90214
|
} catch (error48) {
|
|
@@ -90177,11 +90288,11 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90177
90288
|
console.log(source_default.gray(` Set with: adhdev daemon:api ${enabled ? "disable" : "enable"}
|
|
90178
90289
|
`));
|
|
90179
90290
|
}));
|
|
90180
|
-
hideCommand(program2.command("daemon:status").description("Check ADHDev Daemon status").option("-p, --port <port>", "Local WS server port",
|
|
90291
|
+
hideCommand(program2.command("daemon:status").description("Check ADHDev Daemon status").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).action(async (options) => {
|
|
90181
90292
|
const { isDaemonRunning: isDaemonRunning2, getDaemonPid: getDaemonPid2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
90182
90293
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
90183
90294
|
const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
90184
|
-
const port = parseInt(options.port, 10) ||
|
|
90295
|
+
const port = parseInt(options.port, 10) || DEFAULT_DAEMON_PORT;
|
|
90185
90296
|
const { loadConfig: loadConfig2, ProviderLoader: ProviderLoader2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
90186
90297
|
const config2 = loadConfig2();
|
|
90187
90298
|
const providerLoader = new ProviderLoader2({
|
|
@@ -90254,8 +90365,8 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90254
90365
|
}
|
|
90255
90366
|
try {
|
|
90256
90367
|
const controller = new AbortController();
|
|
90257
|
-
const timer = setTimeout(() => controller.abort(),
|
|
90258
|
-
const res = await fetch(
|
|
90368
|
+
const timer = setTimeout(() => controller.abort(), DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS2);
|
|
90369
|
+
const res = await fetch(`${DEV_SERVER_BASE_URL}/api/status`, { signal: controller.signal });
|
|
90259
90370
|
clearTimeout(timer);
|
|
90260
90371
|
if (res.ok) {
|
|
90261
90372
|
const data = await res.json();
|
|
@@ -90279,10 +90390,10 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90279
90390
|
`));
|
|
90280
90391
|
}
|
|
90281
90392
|
}));
|
|
90282
|
-
hideCommand(program2.command("daemon:session-host").description("Advanced operator diagnostics and control for the raw session-host surface").option("-p, --port <port>", "Local WS server port",
|
|
90393
|
+
hideCommand(program2.command("daemon:session-host").description("Advanced operator diagnostics and control for the raw session-host surface").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).option("--json", "Print raw JSON diagnostics/result").option("--limit <count>", "Number of diagnostics entries to include", "20").option("--session <sessionId>", "Target session ID").option("--restart", "Restart the target session").option("--resume", "Resume the target session").option("--stop", "Stop the target session").option("--signal <signal>", "Send a signal to the target session").option("--detach-client <clientId>", "Force-detach a client from the target session").option("--prune-duplicates", "Stop and remove duplicate hosted runtimes that share the same provider session binding").option("--acquire-write <clientId>", "Force-acquire write ownership for a client").option("--release-write <clientId>", "Release write ownership for a client").option("--owner-type <type>", "ownerType for --acquire-write (user|agent)", "user").action(async (options) => {
|
|
90283
90394
|
const sessionId = typeof options.session === "string" ? options.session.trim() : "";
|
|
90284
90395
|
const limit = Math.max(1, Math.min(200, parseInt(options.limit, 10) || 20));
|
|
90285
|
-
const port = parseInt(options.port, 10) ||
|
|
90396
|
+
const port = parseInt(options.port, 10) || DEFAULT_DAEMON_PORT;
|
|
90286
90397
|
const requireSessionId = () => {
|
|
90287
90398
|
if (!sessionId) {
|
|
90288
90399
|
throw new Error("--session is required for this action");
|
|
@@ -90601,9 +90712,9 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90601
90712
|
process.exit(1);
|
|
90602
90713
|
}
|
|
90603
90714
|
});
|
|
90604
|
-
hideCommand(program2.command("daemon:stop").description("Stop ADHDev Daemon").option("-p, --port <port>", "Local WS server port",
|
|
90715
|
+
hideCommand(program2.command("daemon:stop").description("Stop ADHDev Daemon").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).action(async (options) => {
|
|
90605
90716
|
const { stopDaemon: stopDaemon2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
90606
|
-
const port = parseInt(options.port, 10) ||
|
|
90717
|
+
const port = parseInt(options.port, 10) || DEFAULT_DAEMON_PORT;
|
|
90607
90718
|
if (stopDaemon2({ port })) {
|
|
90608
90719
|
console.log(source_default.green(`
|
|
90609
90720
|
\u2713 ADHDev Daemon stopped.
|
|
@@ -90614,19 +90725,19 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90614
90725
|
`));
|
|
90615
90726
|
}
|
|
90616
90727
|
}));
|
|
90617
|
-
hideCommand(program2.command("daemon:restart").description("Restart ADHDev Daemon (stop \u2192 start)").option("-p, --port <port>", "Local WS server port",
|
|
90728
|
+
hideCommand(program2.command("daemon:restart").description("Restart ADHDev Daemon (stop \u2192 start)").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).option("--server <url>", "Override server URL").option("--dev", "Enable Dev Mode").action(async (options) => {
|
|
90618
90729
|
const { stopDaemon: stopDaemon2, isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
|
|
90619
90730
|
const { stopManagedSessionHostProcess: stopManagedSessionHostProcess2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
|
|
90620
90731
|
const { spawn: spawn6 } = await import("child_process");
|
|
90621
|
-
if (isDaemonRunning2({ port: parseInt(options.port, 10) ||
|
|
90732
|
+
if (isDaemonRunning2({ port: parseInt(options.port, 10) || DEFAULT_DAEMON_PORT })) {
|
|
90622
90733
|
console.log(source_default.yellow("\n Stopping existing daemon..."));
|
|
90623
|
-
stopDaemon2({ port: parseInt(options.port, 10) ||
|
|
90734
|
+
stopDaemon2({ port: parseInt(options.port, 10) || DEFAULT_DAEMON_PORT });
|
|
90624
90735
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
90625
90736
|
}
|
|
90626
90737
|
stopManagedSessionHostProcess2();
|
|
90627
90738
|
await new Promise((r) => setTimeout(r, 500));
|
|
90628
90739
|
console.log(source_default.cyan(" Starting new daemon..."));
|
|
90629
|
-
const args = ["daemon", "-p", options.port ||
|
|
90740
|
+
const args = ["daemon", "-p", options.port || DEFAULT_DAEMON_PORT_TEXT];
|
|
90630
90741
|
if (options.server) args.push("--server", options.server);
|
|
90631
90742
|
if (options.dev) args.push("--dev");
|
|
90632
90743
|
const child = spawn6(process.execPath, [process.argv[1], ...args], {
|
|
@@ -90637,7 +90748,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90637
90748
|
});
|
|
90638
90749
|
child.unref();
|
|
90639
90750
|
await new Promise((r) => setTimeout(r, 3e3));
|
|
90640
|
-
if (isDaemonRunning2({ port: parseInt(options.port, 10) ||
|
|
90751
|
+
if (isDaemonRunning2({ port: parseInt(options.port, 10) || DEFAULT_DAEMON_PORT })) {
|
|
90641
90752
|
console.log(source_default.green(` \u2713 ADHDev Daemon restarted (PID: ${child.pid})
|
|
90642
90753
|
`));
|
|
90643
90754
|
} else {
|
|
@@ -90711,7 +90822,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90711
90822
|
packageName: "adhdev",
|
|
90712
90823
|
targetVersion: latest,
|
|
90713
90824
|
parentPid: process.pid,
|
|
90714
|
-
restartArgv: daemonWasRunning ? [process.argv[1], "daemon", "-p",
|
|
90825
|
+
restartArgv: daemonWasRunning ? [process.argv[1], "daemon", "-p", DEFAULT_DAEMON_PORT_TEXT] : [],
|
|
90715
90826
|
cwd: process.cwd()
|
|
90716
90827
|
});
|
|
90717
90828
|
if (daemonWasRunning) {
|
|
@@ -90732,7 +90843,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
90732
90843
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
90733
90844
|
stopManagedSessionHostProcess2();
|
|
90734
90845
|
await new Promise((r) => setTimeout(r, 500));
|
|
90735
|
-
const child = spawn6(process.execPath, [process.argv[1], "daemon", "-p",
|
|
90846
|
+
const child = spawn6(process.execPath, [process.argv[1], "daemon", "-p", DEFAULT_DAEMON_PORT_TEXT], {
|
|
90736
90847
|
detached: true,
|
|
90737
90848
|
stdio: "ignore",
|
|
90738
90849
|
windowsHide: true,
|
|
@@ -91272,6 +91383,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
91272
91383
|
init_source();
|
|
91273
91384
|
var path33 = __toESM(require("path"));
|
|
91274
91385
|
init_cdp_utils();
|
|
91386
|
+
var DEV_SERVER_PORT3 = 19280;
|
|
91275
91387
|
var IDE_AUTO_FIX_FUNCTIONS = [
|
|
91276
91388
|
"openPanel",
|
|
91277
91389
|
"sendMessage",
|
|
@@ -91504,7 +91616,7 @@ function registerProviderCommands(program2) {
|
|
|
91504
91616
|
const result = await new Promise((resolve17, reject) => {
|
|
91505
91617
|
const req = http3.request({
|
|
91506
91618
|
hostname: "127.0.0.1",
|
|
91507
|
-
port:
|
|
91619
|
+
port: DEV_SERVER_PORT3,
|
|
91508
91620
|
path: "/api/providers/reload",
|
|
91509
91621
|
method: "POST",
|
|
91510
91622
|
headers: { "Content-Type": "application/json", "Content-Length": "2" }
|
|
@@ -91641,7 +91753,7 @@ function registerProviderCommands(program2) {
|
|
|
91641
91753
|
const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
|
|
91642
91754
|
const req = http3.request({
|
|
91643
91755
|
hostname: "127.0.0.1",
|
|
91644
|
-
port:
|
|
91756
|
+
port: DEV_SERVER_PORT3,
|
|
91645
91757
|
path: "/api/scaffold",
|
|
91646
91758
|
method: "POST",
|
|
91647
91759
|
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
|
|
@@ -91849,7 +91961,7 @@ function registerProviderCommands(program2) {
|
|
|
91849
91961
|
const startResult = await new Promise((resolve17, reject) => {
|
|
91850
91962
|
const req = http3.request({
|
|
91851
91963
|
hostname: "127.0.0.1",
|
|
91852
|
-
port:
|
|
91964
|
+
port: DEV_SERVER_PORT3,
|
|
91853
91965
|
path: `/api/providers/${type}/auto-implement`,
|
|
91854
91966
|
method: "POST",
|
|
91855
91967
|
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
|
|
@@ -91895,7 +92007,7 @@ function registerProviderCommands(program2) {
|
|
|
91895
92007
|
`);
|
|
91896
92008
|
console.log(source_default.gray(` Agent logs: ${logFile}`));
|
|
91897
92009
|
await new Promise((resolve17, reject) => {
|
|
91898
|
-
http3.get(`http://127.0.0.1
|
|
92010
|
+
http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}${startResult.sseUrl}`, (res) => {
|
|
91899
92011
|
let buffer = "";
|
|
91900
92012
|
res.on("data", (chunk) => {
|
|
91901
92013
|
const rawStr = chunk.toString();
|
|
@@ -92004,7 +92116,7 @@ function registerProviderCommands(program2) {
|
|
|
92004
92116
|
const result = await new Promise((resolve17, reject) => {
|
|
92005
92117
|
const req = http3.request({
|
|
92006
92118
|
hostname: "127.0.0.1",
|
|
92007
|
-
port:
|
|
92119
|
+
port: DEV_SERVER_PORT3,
|
|
92008
92120
|
path: `/api/providers/${type}/script`,
|
|
92009
92121
|
method: "POST",
|
|
92010
92122
|
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
|
|
@@ -92052,7 +92164,7 @@ function registerProviderCommands(program2) {
|
|
|
92052
92164
|
try {
|
|
92053
92165
|
const http3 = await import("http");
|
|
92054
92166
|
const result = await new Promise((resolve17, reject) => {
|
|
92055
|
-
http3.get(`http://127.0.0.1
|
|
92167
|
+
http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}/api/providers/${type}/source`, (res) => {
|
|
92056
92168
|
let data = "";
|
|
92057
92169
|
res.on("data", (c) => data += c);
|
|
92058
92170
|
res.on("end", () => {
|
|
@@ -92110,7 +92222,7 @@ function registerProviderCommands(program2) {
|
|
|
92110
92222
|
const result = await new Promise((resolve17, reject) => {
|
|
92111
92223
|
const req = http3.request({
|
|
92112
92224
|
hostname: "127.0.0.1",
|
|
92113
|
-
port:
|
|
92225
|
+
port: DEV_SERVER_PORT3,
|
|
92114
92226
|
path: `/api/providers/${type}/script`,
|
|
92115
92227
|
method: "POST",
|
|
92116
92228
|
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(postData) }
|
|
@@ -92416,6 +92528,7 @@ var import_node_os6 = __toESM(require("os"));
|
|
|
92416
92528
|
var import_node_child_process6 = require("child_process");
|
|
92417
92529
|
init_source();
|
|
92418
92530
|
init_src();
|
|
92531
|
+
var DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3 = 1500;
|
|
92419
92532
|
var LAUNCHD_LABEL = "dev.adhf.daemon";
|
|
92420
92533
|
var ADHDEV_DIR = import_node_path4.default.join(import_node_os6.default.homedir(), ".adhdev");
|
|
92421
92534
|
var LOG_OUT = import_node_path4.default.join(ADHDEV_DIR, "daemon-launchd.out");
|
|
@@ -92439,7 +92552,7 @@ function ensureDir(dir) {
|
|
|
92439
92552
|
}
|
|
92440
92553
|
async function fetchHealth() {
|
|
92441
92554
|
const controller = new AbortController();
|
|
92442
|
-
const timer = setTimeout(() => controller.abort(),
|
|
92555
|
+
const timer = setTimeout(() => controller.abort(), DEFAULT_LOCAL_DAEMON_HEALTH_TIMEOUT_MS3);
|
|
92443
92556
|
try {
|
|
92444
92557
|
const res = await fetch(`http://127.0.0.1:${DEFAULT_DAEMON_PORT}/health`, { signal: controller.signal });
|
|
92445
92558
|
if (!res.ok) return null;
|