adhdev 0.7.31 → 0.7.35

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.js CHANGED
@@ -583,16 +583,16 @@ async function detectCLIs(providerLoader) {
583
583
  const results = await Promise.all(
584
584
  cliList.map(async (cli) => {
585
585
  try {
586
- const pathResult = await execAsync(`${whichCmd} ${cli.command} 2>/dev/null`);
586
+ const pathResult = await execAsync(`${whichCmd} ${cli.command}`);
587
587
  if (!pathResult) return { ...cli, installed: false };
588
588
  const firstPath = pathResult.split("\n")[0];
589
589
  let version2;
590
590
  try {
591
591
  const versionCommands = [
592
592
  cli.versionCommand,
593
- `${cli.command} --version 2>/dev/null`,
594
- `${cli.command} -V 2>/dev/null`,
595
- `${cli.command} -v 2>/dev/null`
593
+ `${cli.command} --version`,
594
+ `${cli.command} -V`,
595
+ `${cli.command} -v`
596
596
  ].filter((v2) => !!v2);
597
597
  for (const versionCommand of versionCommands) {
598
598
  const versionResult = await execAsync(versionCommand, 3e3);
@@ -2991,10 +2991,13 @@ var init_ide_provider_instance = __esm({
2991
2991
  if (result?.found && result.x != null && result.y != null) {
2992
2992
  const x = result.x;
2993
2993
  const y = result.y;
2994
- const anyCdp = cdp;
2995
- await anyCdp.send("Input.dispatchMouseEvent", { type: "mousePressed", x, y, button: "left", clickCount: 1 });
2996
- await anyCdp.send("Input.dispatchMouseEvent", { type: "mouseReleased", x, y, button: "left", clickCount: 1 });
2997
- LOG.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: dispatched mouse event at ${x},${y}`);
2994
+ if (cdp.send) {
2995
+ await cdp.send("Input.dispatchMouseEvent", { type: "mousePressed", x, y, button: "left", clickCount: 1 });
2996
+ await cdp.send("Input.dispatchMouseEvent", { type: "mouseReleased", x, y, button: "left", clickCount: 1 });
2997
+ LOG.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: dispatched mouse event at ${x},${y}`);
2998
+ } else {
2999
+ LOG.warn("IdeInstance", `[IdeInstance:${this.type}] autoApprove: cdp.send() not available for coordinate click`);
3000
+ }
2998
3001
  }
2999
3002
  this.pushEvent({
3000
3003
  event: "agent:auto_approved",
@@ -7308,14 +7311,6 @@ var init_provider_loader = __esm({
7308
7311
  }
7309
7312
  /**
7310
7313
  * Get raw provider metadata by type (NO scripts loaded).
7311
- * Use resolve() when you need scripts (readChat, listModels, etc).
7312
- * @deprecated Use getMeta() for metadata or resolve() for scripts.
7313
- */
7314
- get(type) {
7315
- return this.providers.get(type);
7316
- }
7317
- /**
7318
- * Get raw provider metadata by type (NO scripts loaded).
7319
7314
  * Safe for: category checks, icon, displayName, targetFilter, cdpPorts.
7320
7315
  * NOT safe for: script execution (readChat, listModels, sendMessage).
7321
7316
  * Use resolve() when scripts are needed.
@@ -8338,7 +8333,7 @@ function detectCurrentWorkspace(ideId) {
8338
8333
  }
8339
8334
  } else if (plat === "win32") {
8340
8335
  try {
8341
- const fs15 = require("fs");
8336
+ const fs16 = require("fs");
8342
8337
  const appNameMap = getMacAppIdentifiers();
8343
8338
  const appName = appNameMap[ideId];
8344
8339
  if (appName) {
@@ -8347,8 +8342,8 @@ function detectCurrentWorkspace(ideId) {
8347
8342
  appName,
8348
8343
  "storage.json"
8349
8344
  );
8350
- if (fs15.existsSync(storagePath)) {
8351
- const data = JSON.parse(fs15.readFileSync(storagePath, "utf-8"));
8345
+ if (fs16.existsSync(storagePath)) {
8346
+ const data = JSON.parse(fs16.readFileSync(storagePath, "utf-8"));
8352
8347
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
8353
8348
  if (workspaces.length > 0) {
8354
8349
  const recent = workspaces[0];
@@ -8847,9 +8842,9 @@ var init_router = __esm({
8847
8842
  LOG.info("Upgrade", "Restarting daemon with new version...");
8848
8843
  try {
8849
8844
  const path18 = require("path");
8850
- const fs15 = require("fs");
8845
+ const fs16 = require("fs");
8851
8846
  const pidFile = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "daemon.pid");
8852
- if (fs15.existsSync(pidFile)) fs15.unlinkSync(pidFile);
8847
+ if (fs16.existsSync(pidFile)) fs16.unlinkSync(pidFile);
8853
8848
  } catch {
8854
8849
  }
8855
8850
  const { spawn: spawn4 } = require("child_process");
@@ -8901,7 +8896,7 @@ var init_router = __esm({
8901
8896
  }
8902
8897
  }
8903
8898
  const keysToRemove = [];
8904
- for (const key of this.deps.instanceManager.instances?.keys?.() || []) {
8899
+ for (const key of this.deps.instanceManager.listInstanceIds()) {
8905
8900
  if (key === `ide:${ideType}` || typeof key === "string" && key.startsWith(`ide:${ideType}_`)) {
8906
8901
  keysToRemove.push(key);
8907
8902
  }
@@ -18614,12 +18609,12 @@ function findBinary(name) {
18614
18609
  function isScriptBinary(binaryPath) {
18615
18610
  if (!path9.isAbsolute(binaryPath)) return false;
18616
18611
  try {
18617
- const fs15 = require("fs");
18618
- const resolved = fs15.realpathSync(binaryPath);
18612
+ const fs16 = require("fs");
18613
+ const resolved = fs16.realpathSync(binaryPath);
18619
18614
  const head = Buffer.alloc(8);
18620
- const fd = fs15.openSync(resolved, "r");
18621
- fs15.readSync(fd, head, 0, 8, 0);
18622
- fs15.closeSync(fd);
18615
+ const fd = fs16.openSync(resolved, "r");
18616
+ fs16.readSync(fd, head, 0, 8, 0);
18617
+ fs16.closeSync(fd);
18623
18618
  let i = 0;
18624
18619
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
18625
18620
  return head[i] === 35 && head[i + 1] === 33;
@@ -18630,12 +18625,12 @@ function isScriptBinary(binaryPath) {
18630
18625
  function looksLikeMachOOrElf(filePath) {
18631
18626
  if (!path9.isAbsolute(filePath)) return false;
18632
18627
  try {
18633
- const fs15 = require("fs");
18634
- const resolved = fs15.realpathSync(filePath);
18628
+ const fs16 = require("fs");
18629
+ const resolved = fs16.realpathSync(filePath);
18635
18630
  const buf = Buffer.alloc(8);
18636
- const fd = fs15.openSync(resolved, "r");
18637
- fs15.readSync(fd, buf, 0, 8, 0);
18638
- fs15.closeSync(fd);
18631
+ const fd = fs16.openSync(resolved, "r");
18632
+ fs16.readSync(fd, buf, 0, 8, 0);
18633
+ fs16.closeSync(fd);
18639
18634
  let i = 0;
18640
18635
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
18641
18636
  const b2 = buf.subarray(i);
@@ -18756,14 +18751,14 @@ var init_provider_cli_adapter = __esm({
18756
18751
  pty2 = require("node-pty");
18757
18752
  if (os13.platform() !== "win32") {
18758
18753
  try {
18759
- const fs15 = require("fs");
18754
+ const fs16 = require("fs");
18760
18755
  const ptyDir = path9.resolve(path9.dirname(require.resolve("node-pty")), "..");
18761
18756
  const platformArch = `${os13.platform()}-${os13.arch()}`;
18762
18757
  const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
18763
- if (fs15.existsSync(helper)) {
18764
- const stat4 = fs15.statSync(helper);
18758
+ if (fs16.existsSync(helper)) {
18759
+ const stat4 = fs16.statSync(helper);
18765
18760
  if (!(stat4.mode & 73)) {
18766
- fs15.chmodSync(helper, stat4.mode | 493);
18761
+ fs16.chmodSync(helper, stat4.mode | 493);
18767
18762
  LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
18768
18763
  }
18769
18764
  }
@@ -18955,8 +18950,12 @@ var init_provider_cli_adapter = __esm({
18955
18950
  LOG.info("CLI", `[${this.cliType}] Using login shell (script shim or non-native binary)`);
18956
18951
  }
18957
18952
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
18958
- const fullCmd = [binaryPath, ...allArgs].map(shSingleQuote).join(" ");
18959
- shellArgs = isWin ? ["/c", fullCmd] : ["-l", "-c", fullCmd];
18953
+ if (isWin) {
18954
+ shellArgs = ["/c", binaryPath, ...allArgs];
18955
+ } else {
18956
+ const fullCmd = [binaryPath, ...allArgs].map(shSingleQuote).join(" ");
18957
+ shellArgs = ["-l", "-c", fullCmd];
18958
+ }
18960
18959
  } else {
18961
18960
  shellCmd = binaryPath;
18962
18961
  shellArgs = allArgs;
@@ -38348,6 +38347,12 @@ var init_provider_instance_manager = __esm({
38348
38347
  get size() {
38349
38348
  return this.instances.size;
38350
38349
  }
38350
+ /**
38351
+ * All Instance IDs (for iteration without exposing the private Map)
38352
+ */
38353
+ listInstanceIds() {
38354
+ return [...this.instances.keys()];
38355
+ }
38351
38356
  // ─── State collect ────────────────────────────────
38352
38357
  /**
38353
38358
  * all Instance's current status collect
@@ -42789,7 +42794,20 @@ var init_dist = __esm({
42789
42794
  request
42790
42795
  };
42791
42796
  const response = await new Promise((resolve12, reject) => {
42792
- this.requestWaiters.set(requestId, { resolve: resolve12, reject });
42797
+ const timeout = setTimeout(() => {
42798
+ this.requestWaiters.delete(requestId);
42799
+ reject(new Error(`Session host request timed out after 30s (${request.type})`));
42800
+ }, 3e4);
42801
+ this.requestWaiters.set(requestId, {
42802
+ resolve: (value) => {
42803
+ clearTimeout(timeout);
42804
+ resolve12(value);
42805
+ },
42806
+ reject: (error48) => {
42807
+ clearTimeout(timeout);
42808
+ reject(error48);
42809
+ }
42810
+ });
42793
42811
  this.socket?.write(serializeEnvelope(envelope));
42794
42812
  });
42795
42813
  return response;
@@ -43735,10 +43753,10 @@ var init_server_connection = __esm({
43735
43753
  this.setState("disconnected");
43736
43754
  try {
43737
43755
  const path18 = require("path");
43738
- const fs15 = require("fs");
43756
+ const fs16 = require("fs");
43739
43757
  const configPath = path18.join(process.env.HOME || process.env.USERPROFILE || "", ".adhdev", "config.json");
43740
- if (fs15.existsSync(configPath)) {
43741
- fs15.unlinkSync(configPath);
43758
+ if (fs16.existsSync(configPath)) {
43759
+ fs16.unlinkSync(configPath);
43742
43760
  LOG.info("Server", `[ServerConn] Config file removed. Re-run 'adhdev setup'.`);
43743
43761
  }
43744
43762
  } catch {
@@ -44829,13 +44847,12 @@ var init_screenshot_controller = __esm({
44829
44847
 
44830
44848
  // src/session-host.ts
44831
44849
  function resolveSessionHostEntry() {
44832
- const localCandidates = [
44850
+ const packagedCandidates = [
44833
44851
  path16.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
44834
- path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js"),
44835
- path16.resolve(__dirname, "../../../oss/packages/session-host-daemon/dist/index.js")
44852
+ path16.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
44836
44853
  ];
44837
- for (const candidate of localCandidates) {
44838
- if (require("fs").existsSync(candidate)) {
44854
+ for (const candidate of packagedCandidates) {
44855
+ if (fs14.existsSync(candidate)) {
44839
44856
  return candidate;
44840
44857
  }
44841
44858
  }
@@ -44862,11 +44879,12 @@ async function ensureSessionHostReady2() {
44862
44879
  async function listHostedCliRuntimes2(endpoint) {
44863
44880
  return listHostedCliRuntimes(endpoint);
44864
44881
  }
44865
- var import_child_process8, path16, SESSION_HOST_APP_NAME;
44882
+ var import_child_process8, fs14, path16, SESSION_HOST_APP_NAME;
44866
44883
  var init_session_host = __esm({
44867
44884
  "src/session-host.ts"() {
44868
44885
  "use strict";
44869
44886
  import_child_process8 = require("child_process");
44887
+ fs14 = __toESM(require("fs"));
44870
44888
  path16 = __toESM(require("path"));
44871
44889
  init_src();
44872
44890
  SESSION_HOST_APP_NAME = process.env.ADHDEV_SESSION_HOST_NAME || "adhdev";
@@ -44882,23 +44900,23 @@ __export(adhdev_daemon_exports, {
44882
44900
  });
44883
44901
  function getDaemonPidFile() {
44884
44902
  const dir = path17.join(os19.homedir(), ".adhdev");
44885
- if (!fs14.existsSync(dir)) fs14.mkdirSync(dir, { recursive: true });
44903
+ if (!fs15.existsSync(dir)) fs15.mkdirSync(dir, { recursive: true });
44886
44904
  return path17.join(dir, "daemon.pid");
44887
44905
  }
44888
44906
  function writeDaemonPid(pid) {
44889
- fs14.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
44907
+ fs15.writeFileSync(getDaemonPidFile(), String(pid), "utf-8");
44890
44908
  }
44891
44909
  function removeDaemonPid() {
44892
44910
  try {
44893
- fs14.unlinkSync(getDaemonPidFile());
44911
+ fs15.unlinkSync(getDaemonPidFile());
44894
44912
  } catch (e) {
44895
44913
  }
44896
44914
  }
44897
44915
  function isDaemonRunning() {
44898
44916
  const pidFile = getDaemonPidFile();
44899
44917
  try {
44900
- if (!fs14.existsSync(pidFile)) return false;
44901
- const pid = parseInt(fs14.readFileSync(pidFile, "utf-8").trim());
44918
+ if (!fs15.existsSync(pidFile)) return false;
44919
+ const pid = parseInt(fs15.readFileSync(pidFile, "utf-8").trim());
44902
44920
  process.kill(pid, 0);
44903
44921
  return true;
44904
44922
  } catch {
@@ -44909,8 +44927,8 @@ function isDaemonRunning() {
44909
44927
  function stopDaemon() {
44910
44928
  const pidFile = getDaemonPidFile();
44911
44929
  try {
44912
- if (!fs14.existsSync(pidFile)) return false;
44913
- const pid = parseInt(fs14.readFileSync(pidFile, "utf-8").trim());
44930
+ if (!fs15.existsSync(pidFile)) return false;
44931
+ const pid = parseInt(fs15.readFileSync(pidFile, "utf-8").trim());
44914
44932
  process.kill(pid, "SIGTERM");
44915
44933
  removeDaemonPid();
44916
44934
  return true;
@@ -44919,7 +44937,7 @@ function stopDaemon() {
44919
44937
  return false;
44920
44938
  }
44921
44939
  }
44922
- var os19, fs14, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
44940
+ var os19, fs15, path17, import_chalk2, pkgVersion, DANGEROUS_PATTERNS, AdhdevDaemon;
44923
44941
  var init_adhdev_daemon = __esm({
44924
44942
  "src/adhdev-daemon.ts"() {
44925
44943
  "use strict";
@@ -44930,10 +44948,10 @@ var init_adhdev_daemon = __esm({
44930
44948
  init_session_host();
44931
44949
  init_dist();
44932
44950
  os19 = __toESM(require("os"));
44933
- fs14 = __toESM(require("fs"));
44951
+ fs15 = __toESM(require("fs"));
44934
44952
  path17 = __toESM(require("path"));
44935
44953
  import_chalk2 = __toESM(require("chalk"));
44936
- pkgVersion = "0.7.31";
44954
+ pkgVersion = "0.7.35";
44937
44955
  if (pkgVersion === "unknown") {
44938
44956
  try {
44939
44957
  const possiblePaths = [
@@ -44942,7 +44960,7 @@ var init_adhdev_daemon = __esm({
44942
44960
  ];
44943
44961
  for (const p of possiblePaths) {
44944
44962
  try {
44945
- const data = JSON.parse(fs14.readFileSync(p, "utf-8"));
44963
+ const data = JSON.parse(fs15.readFileSync(p, "utf-8"));
44946
44964
  if (data.version) {
44947
44965
  pkgVersion = data.version;
44948
44966
  break;