adhdev 0.5.19 → 0.5.21
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 +238 -111
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +238 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16721,10 +16721,15 @@ var require_dist = __commonJS({
|
|
|
16721
16721
|
ProviderLoader: () => ProviderLoader,
|
|
16722
16722
|
VersionArchive: () => VersionArchive2,
|
|
16723
16723
|
addCliHistory: () => addCliHistory,
|
|
16724
|
+
buildAllManagedEntries: () => buildAllManagedEntries,
|
|
16725
|
+
buildManagedAcps: () => buildManagedAcps,
|
|
16726
|
+
buildManagedClis: () => buildManagedClis,
|
|
16727
|
+
buildManagedIdes: () => buildManagedIdes,
|
|
16724
16728
|
connectCdpManager: () => connectCdpManager,
|
|
16725
16729
|
detectAllVersions: () => detectAllVersions2,
|
|
16726
16730
|
detectCLIs: () => detectCLIs,
|
|
16727
16731
|
detectIDEs: () => detectIDEs,
|
|
16732
|
+
findCdpManager: () => findCdpManager,
|
|
16728
16733
|
getAIExtensions: () => getAIExtensions,
|
|
16729
16734
|
getAvailableIdeIds: () => getAvailableIdeIds,
|
|
16730
16735
|
getHostMemorySnapshot: () => getHostMemorySnapshot,
|
|
@@ -16733,9 +16738,11 @@ var require_dist = __commonJS({
|
|
|
16733
16738
|
getRecentLogs: () => getRecentLogs,
|
|
16734
16739
|
getWorkspaceActivity: () => getWorkspaceActivity,
|
|
16735
16740
|
getWorkspaceState: () => getWorkspaceState,
|
|
16741
|
+
hasCdpManager: () => hasCdpManager,
|
|
16736
16742
|
initDaemonComponents: () => initDaemonComponents2,
|
|
16737
16743
|
installExtensions: () => installExtensions,
|
|
16738
16744
|
installGlobalInterceptor: () => installGlobalInterceptor,
|
|
16745
|
+
isCdpConnected: () => isCdpConnected,
|
|
16739
16746
|
isExtensionInstalled: () => isExtensionInstalled,
|
|
16740
16747
|
isIdeRunning: () => isIdeRunning,
|
|
16741
16748
|
isSetupComplete: () => isSetupComplete2,
|
|
@@ -19276,6 +19283,117 @@ var require_dist = __commonJS({
|
|
|
19276
19283
|
}
|
|
19277
19284
|
}
|
|
19278
19285
|
};
|
|
19286
|
+
function findCdpManager(cdpManagers, key) {
|
|
19287
|
+
const exact = cdpManagers.get(key);
|
|
19288
|
+
if (exact) return exact;
|
|
19289
|
+
const prefix = key + "_";
|
|
19290
|
+
for (const [k, m] of cdpManagers.entries()) {
|
|
19291
|
+
if (k.startsWith(prefix) && m.isConnected) return m;
|
|
19292
|
+
}
|
|
19293
|
+
return null;
|
|
19294
|
+
}
|
|
19295
|
+
function hasCdpManager(cdpManagers, key) {
|
|
19296
|
+
if (cdpManagers.has(key)) return true;
|
|
19297
|
+
const prefix = key + "_";
|
|
19298
|
+
for (const k of cdpManagers.keys()) {
|
|
19299
|
+
if (k.startsWith(prefix)) return true;
|
|
19300
|
+
}
|
|
19301
|
+
return false;
|
|
19302
|
+
}
|
|
19303
|
+
function isCdpConnected(cdpManagers, key) {
|
|
19304
|
+
const m = findCdpManager(cdpManagers, key);
|
|
19305
|
+
return m?.isConnected ?? false;
|
|
19306
|
+
}
|
|
19307
|
+
function buildManagedIdes(ideStates, cdpManagers, opts) {
|
|
19308
|
+
const result = [];
|
|
19309
|
+
for (const state of ideStates) {
|
|
19310
|
+
const cdpConnected = state.cdpConnected ?? isCdpConnected(cdpManagers, state.type);
|
|
19311
|
+
result.push({
|
|
19312
|
+
ideType: state.type,
|
|
19313
|
+
ideVersion: "",
|
|
19314
|
+
instanceId: state.instanceId || state.type,
|
|
19315
|
+
workspace: state.workspace || null,
|
|
19316
|
+
terminals: 0,
|
|
19317
|
+
aiAgents: [],
|
|
19318
|
+
activeChat: state.activeChat,
|
|
19319
|
+
chats: [],
|
|
19320
|
+
agentStreams: state.extensions.map((ext) => ({
|
|
19321
|
+
agentType: ext.type,
|
|
19322
|
+
agentName: ext.name,
|
|
19323
|
+
extensionId: ext.type,
|
|
19324
|
+
status: ext.status || "idle",
|
|
19325
|
+
messages: ext.activeChat?.messages || [],
|
|
19326
|
+
inputContent: ext.activeChat?.inputContent || "",
|
|
19327
|
+
activeModal: ext.activeChat?.activeModal || null
|
|
19328
|
+
})),
|
|
19329
|
+
cdpConnected,
|
|
19330
|
+
currentModel: state.currentModel,
|
|
19331
|
+
currentPlan: state.currentPlan,
|
|
19332
|
+
currentAutoApprove: state.currentAutoApprove
|
|
19333
|
+
});
|
|
19334
|
+
}
|
|
19335
|
+
if (opts?.detectedIdes) {
|
|
19336
|
+
const coveredTypes = new Set(ideStates.map((s) => s.type));
|
|
19337
|
+
for (const ide of opts.detectedIdes) {
|
|
19338
|
+
if (!ide.installed || coveredTypes.has(ide.id)) continue;
|
|
19339
|
+
if (!isCdpConnected(cdpManagers, ide.id)) continue;
|
|
19340
|
+
result.push({
|
|
19341
|
+
ideType: ide.id,
|
|
19342
|
+
ideVersion: "",
|
|
19343
|
+
instanceId: ide.id,
|
|
19344
|
+
workspace: null,
|
|
19345
|
+
terminals: 0,
|
|
19346
|
+
aiAgents: [],
|
|
19347
|
+
activeChat: null,
|
|
19348
|
+
chats: [],
|
|
19349
|
+
agentStreams: [],
|
|
19350
|
+
cdpConnected: true,
|
|
19351
|
+
currentModel: void 0,
|
|
19352
|
+
currentPlan: void 0
|
|
19353
|
+
});
|
|
19354
|
+
}
|
|
19355
|
+
}
|
|
19356
|
+
return result;
|
|
19357
|
+
}
|
|
19358
|
+
function buildManagedClis(cliStates) {
|
|
19359
|
+
return cliStates.map((s) => ({
|
|
19360
|
+
id: s.instanceId,
|
|
19361
|
+
instanceId: s.instanceId,
|
|
19362
|
+
cliType: s.type,
|
|
19363
|
+
cliName: s.name,
|
|
19364
|
+
status: s.status,
|
|
19365
|
+
mode: s.mode,
|
|
19366
|
+
workspace: s.workspace || "",
|
|
19367
|
+
activeChat: s.activeChat
|
|
19368
|
+
}));
|
|
19369
|
+
}
|
|
19370
|
+
function buildManagedAcps(acpStates) {
|
|
19371
|
+
return acpStates.map((s) => ({
|
|
19372
|
+
id: s.instanceId,
|
|
19373
|
+
acpType: s.type,
|
|
19374
|
+
acpName: s.name,
|
|
19375
|
+
status: s.status,
|
|
19376
|
+
mode: "chat",
|
|
19377
|
+
workspace: s.workspace || "",
|
|
19378
|
+
activeChat: s.activeChat,
|
|
19379
|
+
currentModel: s.currentModel,
|
|
19380
|
+
currentPlan: s.currentPlan,
|
|
19381
|
+
acpConfigOptions: s.acpConfigOptions,
|
|
19382
|
+
acpModes: s.acpModes,
|
|
19383
|
+
errorMessage: s.errorMessage,
|
|
19384
|
+
errorReason: s.errorReason
|
|
19385
|
+
}));
|
|
19386
|
+
}
|
|
19387
|
+
function buildAllManagedEntries(allStates, cdpManagers, opts) {
|
|
19388
|
+
const ideStates = allStates.filter((s) => s.category === "ide");
|
|
19389
|
+
const cliStates = allStates.filter((s) => s.category === "cli");
|
|
19390
|
+
const acpStates = allStates.filter((s) => s.category === "acp");
|
|
19391
|
+
return {
|
|
19392
|
+
managedIdes: buildManagedIdes(ideStates, cdpManagers, opts),
|
|
19393
|
+
managedClis: buildManagedClis(cliStates),
|
|
19394
|
+
managedAcps: buildManagedAcps(acpStates)
|
|
19395
|
+
};
|
|
19396
|
+
}
|
|
19279
19397
|
init_config();
|
|
19280
19398
|
async function handleChatHistory(h, args) {
|
|
19281
19399
|
const { agentType, offset, limit, instanceId } = args;
|
|
@@ -20581,12 +20699,14 @@ var require_dist = __commonJS({
|
|
|
20581
20699
|
get currentProviderType() {
|
|
20582
20700
|
return this._currentProviderType;
|
|
20583
20701
|
}
|
|
20584
|
-
/** Get CDP manager for a specific ideType.
|
|
20702
|
+
/** Get CDP manager for a specific ideType or managerKey.
|
|
20703
|
+
* Supports exact match, multi-window prefix match, and instanceIdMap UUID lookup.
|
|
20585
20704
|
* Returns null if no match — never falls back to another IDE. */
|
|
20586
20705
|
getCdp(ideType) {
|
|
20587
20706
|
const key = ideType || this._currentIdeType;
|
|
20588
20707
|
if (!key) return null;
|
|
20589
|
-
const
|
|
20708
|
+
const resolved = this._ctx.instanceIdMap?.get(key) || key;
|
|
20709
|
+
const m = findCdpManager(this._ctx.cdpManagers, resolved.toLowerCase());
|
|
20590
20710
|
if (m?.isConnected) return m;
|
|
20591
20711
|
return null;
|
|
20592
20712
|
}
|
|
@@ -20657,10 +20777,18 @@ var require_dist = __commonJS({
|
|
|
20657
20777
|
const managed = this._agentStream.getManagedAgent(provider.type);
|
|
20658
20778
|
return managed?.sessionId || null;
|
|
20659
20779
|
}
|
|
20660
|
-
/** Extract ideType from _targetInstance */
|
|
20780
|
+
/** Extract ideType from _targetInstance or explicit ideType */
|
|
20661
20781
|
extractIdeType(args) {
|
|
20662
|
-
if (args?.ideType
|
|
20663
|
-
|
|
20782
|
+
if (args?.ideType) {
|
|
20783
|
+
if (this._ctx.cdpManagers.has(args.ideType)) {
|
|
20784
|
+
return args.ideType;
|
|
20785
|
+
}
|
|
20786
|
+
const found = findCdpManager(this._ctx.cdpManagers, args.ideType);
|
|
20787
|
+
if (found) {
|
|
20788
|
+
for (const [k, m] of this._ctx.cdpManagers.entries()) {
|
|
20789
|
+
if (m === found) return k;
|
|
20790
|
+
}
|
|
20791
|
+
}
|
|
20664
20792
|
}
|
|
20665
20793
|
if (args?._targetInstance) {
|
|
20666
20794
|
let raw = args._targetInstance;
|
|
@@ -20676,9 +20804,10 @@ var require_dist = __commonJS({
|
|
|
20676
20804
|
if (this._ctx.cdpManagers.has(raw)) {
|
|
20677
20805
|
return raw;
|
|
20678
20806
|
}
|
|
20679
|
-
|
|
20680
|
-
|
|
20681
|
-
|
|
20807
|
+
const found = findCdpManager(this._ctx.cdpManagers, raw);
|
|
20808
|
+
if (found) {
|
|
20809
|
+
for (const [k, m] of this._ctx.cdpManagers.entries()) {
|
|
20810
|
+
if (m === found) return k;
|
|
20682
20811
|
}
|
|
20683
20812
|
}
|
|
20684
20813
|
const lastUnderscore = raw.lastIndexOf("_");
|
|
@@ -22398,9 +22527,11 @@ var require_dist = __commonJS({
|
|
|
22398
22527
|
LOG5.info("Upgrade", "Remote upgrade requested from dashboard");
|
|
22399
22528
|
try {
|
|
22400
22529
|
const { execSync: execSync7 } = await import("child_process");
|
|
22401
|
-
const
|
|
22402
|
-
|
|
22403
|
-
execSync7(
|
|
22530
|
+
const isStandalone = this.deps.packageName === "@adhdev/daemon-standalone" || process.argv[1]?.includes("daemon-standalone");
|
|
22531
|
+
const pkgName = isStandalone ? "@adhdev/daemon-standalone" : "adhdev";
|
|
22532
|
+
const latest = execSync7(`npm view ${pkgName} version`, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
22533
|
+
LOG5.info("Upgrade", `Latest ${pkgName}: v${latest}`);
|
|
22534
|
+
execSync7(`npm install -g ${pkgName}@latest`, {
|
|
22404
22535
|
encoding: "utf-8",
|
|
22405
22536
|
timeout: 6e4,
|
|
22406
22537
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -22408,8 +22539,15 @@ var require_dist = __commonJS({
|
|
|
22408
22539
|
LOG5.info("Upgrade", `\u2705 Upgraded to v${latest}`);
|
|
22409
22540
|
setTimeout(() => {
|
|
22410
22541
|
LOG5.info("Upgrade", "Restarting daemon with new version...");
|
|
22542
|
+
try {
|
|
22543
|
+
const path13 = require("path");
|
|
22544
|
+
const fs10 = require("fs");
|
|
22545
|
+
const pidFile = path13.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
|
|
22546
|
+
if (fs10.existsSync(pidFile)) fs10.unlinkSync(pidFile);
|
|
22547
|
+
} catch {
|
|
22548
|
+
}
|
|
22411
22549
|
const { spawn: spawn3 } = require("child_process");
|
|
22412
|
-
const child = spawn3(process.execPath,
|
|
22550
|
+
const child = spawn3(process.execPath, process.argv.slice(1), {
|
|
22413
22551
|
detached: true,
|
|
22414
22552
|
stdio: "ignore",
|
|
22415
22553
|
env: { ...process.env }
|
|
@@ -22615,54 +22753,10 @@ var require_dist = __commonJS({
|
|
|
22615
22753
|
LOG5.info("StatusReport", summary);
|
|
22616
22754
|
}
|
|
22617
22755
|
}
|
|
22618
|
-
const managedIdes
|
|
22619
|
-
|
|
22620
|
-
|
|
22621
|
-
|
|
22622
|
-
workspace: s.workspace || null,
|
|
22623
|
-
terminals: 0,
|
|
22624
|
-
aiAgents: [],
|
|
22625
|
-
activeChat: s.activeChat,
|
|
22626
|
-
chats: [],
|
|
22627
|
-
agentStreams: s.extensions.map((ext) => ({
|
|
22628
|
-
agentType: ext.type,
|
|
22629
|
-
agentName: ext.name,
|
|
22630
|
-
extensionId: ext.type,
|
|
22631
|
-
status: ext.status || "idle",
|
|
22632
|
-
messages: ext.activeChat?.messages || [],
|
|
22633
|
-
inputContent: ext.activeChat?.inputContent || "",
|
|
22634
|
-
activeModal: ext.activeChat?.activeModal || null
|
|
22635
|
-
})),
|
|
22636
|
-
cdpConnected: s.cdpConnected,
|
|
22637
|
-
currentModel: s.currentModel,
|
|
22638
|
-
currentPlan: s.currentPlan,
|
|
22639
|
-
currentAutoApprove: s.currentAutoApprove
|
|
22640
|
-
}));
|
|
22641
|
-
const managedClis = cliStates.map((s) => ({
|
|
22642
|
-
id: s.instanceId,
|
|
22643
|
-
instanceId: s.instanceId,
|
|
22644
|
-
cliType: s.type,
|
|
22645
|
-
cliName: s.name,
|
|
22646
|
-
status: s.status,
|
|
22647
|
-
mode: s.mode,
|
|
22648
|
-
workspace: s.workspace || "",
|
|
22649
|
-
activeChat: s.activeChat
|
|
22650
|
-
}));
|
|
22651
|
-
const managedAcps = acpStates.map((s) => ({
|
|
22652
|
-
id: s.instanceId,
|
|
22653
|
-
acpType: s.type,
|
|
22654
|
-
acpName: s.name,
|
|
22655
|
-
status: s.status,
|
|
22656
|
-
mode: s.mode,
|
|
22657
|
-
workspace: s.workspace || "",
|
|
22658
|
-
activeChat: s.activeChat,
|
|
22659
|
-
currentModel: s.currentModel,
|
|
22660
|
-
currentPlan: s.currentPlan,
|
|
22661
|
-
acpConfigOptions: s.acpConfigOptions,
|
|
22662
|
-
acpModes: s.acpModes,
|
|
22663
|
-
errorMessage: s.errorMessage,
|
|
22664
|
-
errorReason: s.errorReason
|
|
22665
|
-
}));
|
|
22756
|
+
const { managedIdes, managedClis, managedAcps } = buildAllManagedEntries(
|
|
22757
|
+
allStates,
|
|
22758
|
+
this.deps.cdpManagers
|
|
22759
|
+
);
|
|
22666
22760
|
const cfg = loadConfig3();
|
|
22667
22761
|
const wsState = getWorkspaceState(cfg);
|
|
22668
22762
|
const memSnap = getHostMemorySnapshot();
|
|
@@ -22709,37 +22803,34 @@ var require_dist = __commonJS({
|
|
|
22709
22803
|
LOG5.debug("P2P", `sent (${JSON.stringify(payload).length} bytes)`);
|
|
22710
22804
|
}
|
|
22711
22805
|
if (opts?.p2pOnly) return;
|
|
22712
|
-
const
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
|
|
22720
|
-
|
|
22721
|
-
|
|
22722
|
-
|
|
22723
|
-
|
|
22724
|
-
|
|
22725
|
-
|
|
22726
|
-
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
|
|
22730
|
-
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
|
|
22740
|
-
serverConn.sendMessage("status_report", wsPayload);
|
|
22741
|
-
LOG5.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
22742
|
-
}
|
|
22806
|
+
const wsPayload = {
|
|
22807
|
+
daemonMode: true,
|
|
22808
|
+
machineNickname: payload.machineNickname,
|
|
22809
|
+
defaultWorkspaceId: wsState.defaultWorkspaceId,
|
|
22810
|
+
workspaceCount: (wsState.workspaces || []).length,
|
|
22811
|
+
// managedIdes: server only saves id, type, cdpConnected
|
|
22812
|
+
managedIdes: managedIdes.map((ide) => ({
|
|
22813
|
+
ideType: ide.ideType,
|
|
22814
|
+
instanceId: ide.instanceId,
|
|
22815
|
+
cdpConnected: ide.cdpConnected
|
|
22816
|
+
})),
|
|
22817
|
+
// managedClis: server only saves id, type, name
|
|
22818
|
+
managedClis: managedClis.map((c) => ({
|
|
22819
|
+
id: c.id,
|
|
22820
|
+
cliType: c.cliType,
|
|
22821
|
+
cliName: c.cliName
|
|
22822
|
+
})),
|
|
22823
|
+
// managedAcps: server only saves id, type, name
|
|
22824
|
+
managedAcps: managedAcps?.map((a) => ({
|
|
22825
|
+
id: a.id,
|
|
22826
|
+
acpType: a.acpType,
|
|
22827
|
+
acpName: a.acpName
|
|
22828
|
+
})),
|
|
22829
|
+
p2p: payload.p2p,
|
|
22830
|
+
timestamp: now
|
|
22831
|
+
};
|
|
22832
|
+
serverConn.sendMessage("status_report", wsPayload);
|
|
22833
|
+
LOG5.debug("Server", `sent status_report (${JSON.stringify(wsPayload).length} bytes)`);
|
|
22743
22834
|
}
|
|
22744
22835
|
// ─── P2P ─────────────────────────────────────────
|
|
22745
22836
|
sendP2PPayload(payload) {
|
|
@@ -26184,7 +26275,10 @@ async (params) => {
|
|
|
26184
26275
|
this.json(res, 400, { error: "expression required" });
|
|
26185
26276
|
return;
|
|
26186
26277
|
}
|
|
26187
|
-
const cdp =
|
|
26278
|
+
const cdp = this.getCdp(ideType);
|
|
26279
|
+
if (!cdp && !ideType) {
|
|
26280
|
+
LOG5.warn("DevServer", "CDP evaluate without ideType \u2014 picked first connected manager");
|
|
26281
|
+
}
|
|
26188
26282
|
if (!cdp?.isConnected) {
|
|
26189
26283
|
this.json(res, 503, { error: "No CDP connection available" });
|
|
26190
26284
|
return;
|
|
@@ -26424,7 +26518,7 @@ async (params) => {
|
|
|
26424
26518
|
this.sendSSE({ type: "watch_error", error: `Script '${this.watchScriptName}' not found` });
|
|
26425
26519
|
return;
|
|
26426
26520
|
}
|
|
26427
|
-
const cdp = this.
|
|
26521
|
+
const cdp = this.getCdp();
|
|
26428
26522
|
if (!cdp) {
|
|
26429
26523
|
this.sendSSE({ type: "watch_error", error: "No CDP connection" });
|
|
26430
26524
|
return;
|
|
@@ -28177,20 +28271,24 @@ data: ${JSON.stringify(msg.data)}
|
|
|
28177
28271
|
}
|
|
28178
28272
|
}
|
|
28179
28273
|
}
|
|
28180
|
-
/** Get CDP manager — matching IDE when ideType specified, first connected one otherwise
|
|
28274
|
+
/** Get CDP manager — matching IDE when ideType specified, first connected one otherwise.
|
|
28275
|
+
* DevServer is a debugging tool so first-connected fallback is acceptable,
|
|
28276
|
+
* but callers should pass ideType when possible. */
|
|
28181
28277
|
getCdp(ideType) {
|
|
28182
28278
|
if (ideType) {
|
|
28183
28279
|
const cdp = this.cdpManagers.get(ideType);
|
|
28184
28280
|
if (cdp?.isConnected) return cdp;
|
|
28281
|
+
for (const [k, m] of this.cdpManagers.entries()) {
|
|
28282
|
+
if (k.startsWith(ideType + "_") && m.isConnected) return m;
|
|
28283
|
+
}
|
|
28284
|
+
LOG5.warn("DevServer", `getCdp: no manager found for ideType '${ideType}', available: [${[...this.cdpManagers.keys()].join(", ")}]`);
|
|
28285
|
+
return null;
|
|
28185
28286
|
}
|
|
28186
28287
|
for (const cdp of this.cdpManagers.values()) {
|
|
28187
28288
|
if (cdp.isConnected) return cdp;
|
|
28188
28289
|
}
|
|
28189
28290
|
return null;
|
|
28190
28291
|
}
|
|
28191
|
-
getAnyCdp() {
|
|
28192
|
-
return this.getCdp();
|
|
28193
|
-
}
|
|
28194
28292
|
json(res, status, data) {
|
|
28195
28293
|
res.writeHead(status, { "Content-Type": "application/json" });
|
|
28196
28294
|
res.end(JSON.stringify(data, null, 2));
|
|
@@ -28930,6 +29028,28 @@ var init_server_connection = __esm({
|
|
|
28930
29028
|
this.setState("disconnected");
|
|
28931
29029
|
return;
|
|
28932
29030
|
}
|
|
29031
|
+
if (code === 4012) {
|
|
29032
|
+
import_daemon_core.LOG.info("Server", `[ServerConn] \u26A0 Force disconnected by user from dashboard.`);
|
|
29033
|
+
import_daemon_core.LOG.info("Server", `[ServerConn] Run 'adhdev daemon' to reconnect.`);
|
|
29034
|
+
this.setState("disconnected");
|
|
29035
|
+
return;
|
|
29036
|
+
}
|
|
29037
|
+
if (code === 4013) {
|
|
29038
|
+
import_daemon_core.LOG.info("Server", `[ServerConn] \u26A0 Connection token was revoked.`);
|
|
29039
|
+
import_daemon_core.LOG.info("Server", `[ServerConn] Run 'adhdev setup' to re-authenticate.`);
|
|
29040
|
+
this.setState("disconnected");
|
|
29041
|
+
try {
|
|
29042
|
+
const path3 = require("path");
|
|
29043
|
+
const fs3 = require("fs");
|
|
29044
|
+
const configPath = path3.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
|
|
29045
|
+
if (fs3.existsSync(configPath)) {
|
|
29046
|
+
fs3.unlinkSync(configPath);
|
|
29047
|
+
import_daemon_core.LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
|
|
29048
|
+
}
|
|
29049
|
+
} catch {
|
|
29050
|
+
}
|
|
29051
|
+
return;
|
|
29052
|
+
}
|
|
28933
29053
|
if (code !== 1e3 && this.reconnectAttempts < 50) {
|
|
28934
29054
|
this.setState("disconnected");
|
|
28935
29055
|
this.scheduleReconnect();
|
|
@@ -29415,11 +29535,15 @@ ${e?.stack || ""}`);
|
|
|
29415
29535
|
if (parsed.type === "pong") return;
|
|
29416
29536
|
if (parsed.type === "screenshot_start") {
|
|
29417
29537
|
const peer = this.peers.get(peerId);
|
|
29538
|
+
if (!parsed.ideType) {
|
|
29539
|
+
log(`screenshot_start: REJECTED \u2014 no ideType from peer ${peerId}`);
|
|
29540
|
+
return;
|
|
29541
|
+
}
|
|
29418
29542
|
if (peer) {
|
|
29419
29543
|
peer.screenshotActive = true;
|
|
29420
|
-
peer.screenshotIdeType = parsed.ideType
|
|
29544
|
+
peer.screenshotIdeType = parsed.ideType;
|
|
29421
29545
|
peer.needsFirstFrame = true;
|
|
29422
|
-
log(`screenshot_start: peer=${peerId}, ideType=${parsed.ideType
|
|
29546
|
+
log(`screenshot_start: peer=${peerId}, ideType=${parsed.ideType}, channelOpen=${!!peer.screenshotChannel}, state=${peer.state}`);
|
|
29423
29547
|
} else {
|
|
29424
29548
|
log(`screenshot_start: peer ${peerId} NOT FOUND in peers map!`);
|
|
29425
29549
|
}
|
|
@@ -29612,7 +29736,10 @@ ${e?.stack || ""}`);
|
|
|
29612
29736
|
try {
|
|
29613
29737
|
const peer = this.peers.get(peerId);
|
|
29614
29738
|
const ideType = peer?.screenshotIdeType;
|
|
29615
|
-
|
|
29739
|
+
if (!ideType) {
|
|
29740
|
+
log(`[Input] WARNING: No screenshotIdeType for peer ${peerId} \u2014 input may route to wrong IDE`);
|
|
29741
|
+
}
|
|
29742
|
+
const result = await this.inputHandler({ action, params, ideType });
|
|
29616
29743
|
this.sendToPeer(peerId, { id, type: "response", success: true, result });
|
|
29617
29744
|
} catch (e) {
|
|
29618
29745
|
this.sendToPeer(peerId, { id, type: "response", success: false, error: e?.message });
|
|
@@ -29830,7 +29957,11 @@ var init_screenshot_controller = __esm({
|
|
|
29830
29957
|
if (!this.deps.isRunning()) return;
|
|
29831
29958
|
const active = this.deps.isScreenshotActive();
|
|
29832
29959
|
const ssIdeType = this.deps.getScreenshotIdeType();
|
|
29833
|
-
|
|
29960
|
+
if (active && !ssIdeType) {
|
|
29961
|
+
this.timer = setTimeout(() => this.tick(), 500);
|
|
29962
|
+
return;
|
|
29963
|
+
}
|
|
29964
|
+
const cdp = ssIdeType ? this.deps.getCdp(ssIdeType) : null;
|
|
29834
29965
|
const isRelay = this.deps.isUsingRelay();
|
|
29835
29966
|
const profile = isRelay ? this.profileRelay : this.profileDirect;
|
|
29836
29967
|
this.checkBudgetReset();
|
|
@@ -29978,7 +30109,7 @@ var init_adhdev_daemon = __esm({
|
|
|
29978
30109
|
path2 = __toESM(require("path"));
|
|
29979
30110
|
crypto2 = __toESM(require("crypto"));
|
|
29980
30111
|
import_chalk = __toESM(require("chalk"));
|
|
29981
|
-
pkgVersion = "0.5.
|
|
30112
|
+
pkgVersion = "0.5.21";
|
|
29982
30113
|
if (pkgVersion === "unknown") {
|
|
29983
30114
|
try {
|
|
29984
30115
|
const possiblePaths = [
|
|
@@ -30148,7 +30279,11 @@ var init_adhdev_daemon = __esm({
|
|
|
30148
30279
|
getScreenshotIdeType: () => this.p2p?.screenshotIdeType,
|
|
30149
30280
|
isUsingRelay: () => this.p2p?.isUsingRelay ?? false,
|
|
30150
30281
|
hasAnyNeedingFirstFrame: () => this.p2p?.hasAnyNeedingFirstFrame() ?? false,
|
|
30151
|
-
getCdp: (ideType) =>
|
|
30282
|
+
getCdp: (ideType) => {
|
|
30283
|
+
if (ideType) return this.getCdpFor(ideType);
|
|
30284
|
+
import_daemon_core4.LOG.warn("P2P", "Screenshot requested without ideType \u2014 cannot determine target IDE. Skipping frame.");
|
|
30285
|
+
return null;
|
|
30286
|
+
},
|
|
30152
30287
|
sendScreenshotBuffer: (buf) => this.p2p.sendScreenshotBuffer(buf)
|
|
30153
30288
|
}, planLimits ?? void 0);
|
|
30154
30289
|
this.screenshotController.start();
|
|
@@ -30417,14 +30552,6 @@ var init_adhdev_daemon = __esm({
|
|
|
30417
30552
|
}
|
|
30418
30553
|
}
|
|
30419
30554
|
// ─── CDP helpers ─────────────────────────────
|
|
30420
|
-
/** Return first connected CDP manager */
|
|
30421
|
-
getAnyCdp() {
|
|
30422
|
-
if (!this.components) return null;
|
|
30423
|
-
for (const m of this.components.cdpManagers.values()) {
|
|
30424
|
-
if (m.isConnected) return m;
|
|
30425
|
-
}
|
|
30426
|
-
return null;
|
|
30427
|
-
}
|
|
30428
30555
|
/** Return CDP manager for specific IDE (exact match first, then prefix match for multi-window keys) */
|
|
30429
30556
|
getCdpFor(ideType) {
|
|
30430
30557
|
if (!this.components) return null;
|