@dev-anywhere/proxy 0.9.15 → 0.9.16

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.
@@ -15,7 +15,7 @@ import {
15
15
  isPreviewControlRequest,
16
16
  readPreviewWorkerMessages,
17
17
  writePreviewWorkerMessage
18
- } from "./chunk-J7XFB5AQ.js";
18
+ } from "./chunk-5QXG76IO.js";
19
19
  import {
20
20
  acceptCurrentWorkerSocketMessage,
21
21
  readWorkerConnection,
@@ -45,7 +45,7 @@ import {
45
45
  encodeDevicePreviewFrame,
46
46
  encodeDevicePreviewH264ProxyPacket,
47
47
  serializeControl
48
- } from "./chunk-6I5YPQPN.js";
48
+ } from "./chunk-FPNOC7HY.js";
49
49
  import {
50
50
  prepareLocalIpcEndpoint,
51
51
  removeLocalIpcEndpoint,
package/dist/serve.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  sessionRuntimeIpcVersionMatches,
13
13
  stripProxyProfileArgs,
14
14
  writeSessionRuntimeIpcVersions
15
- } from "./chunk-WLLKRNXA.js";
15
+ } from "./chunk-X76ZR6GL.js";
16
16
  import {
17
17
  processExistsOrIsInaccessible
18
18
  } from "./chunk-5OARBB2B.js";
@@ -21,7 +21,7 @@ import {
21
21
  isPreviewControlRequest,
22
22
  readPreviewWorkerMessages,
23
23
  writePreviewWorkerMessage
24
- } from "./chunk-J7XFB5AQ.js";
24
+ } from "./chunk-5QXG76IO.js";
25
25
  import {
26
26
  ContentBlockDeltaSchema,
27
27
  IGNORED_EVENT_TYPES,
@@ -40,7 +40,7 @@ import {
40
40
  import {
41
41
  buildHostedPtyArgs,
42
42
  parseTerminalWorkerCliArgs
43
- } from "./chunk-7UICNI4Q.js";
43
+ } from "./chunk-PTQG7YRY.js";
44
44
  import {
45
45
  ReconnectSupervisor,
46
46
  TERMINAL_ADMISSION_FRAME_MAX_BYTES,
@@ -77,7 +77,7 @@ import {
77
77
  createWorkerReader,
78
78
  serializeIpc,
79
79
  serializeWorkerMsg
80
- } from "./chunk-U4CHGJJM.js";
80
+ } from "./chunk-N4DATVNM.js";
81
81
  import "./chunk-5RESCDN4.js";
82
82
  import {
83
83
  ControlErrorCode,
@@ -105,7 +105,7 @@ import {
105
105
  isProxyProtocolRejectDirection,
106
106
  serializeControl,
107
107
  summarizeToolActivity
108
- } from "./chunk-6I5YPQPN.js";
108
+ } from "./chunk-FPNOC7HY.js";
109
109
  import {
110
110
  localIpcEndpointMayExist,
111
111
  removeLocalIpcEndpoint,
@@ -1116,8 +1116,8 @@ var MemoryMessageQueue = class {
1116
1116
 
1117
1117
  // src/serve/relay-connection.ts
1118
1118
  var DEFAULT_PROXY_ID_PATH = join2(homedir(), ".dev-anywhere", "proxy-id");
1119
- function proxyOsName(platform = process.platform) {
1120
- return { darwin: "macOS", win32: "Windows", linux: "Linux" }[platform];
1119
+ function proxyOsName(platform2 = process.platform) {
1120
+ return { darwin: "macOS", win32: "Windows", linux: "Linux" }[platform2];
1121
1121
  }
1122
1122
  var MAX_BACKOFF_MS = 3e4;
1123
1123
  var BASE_BACKOFF_MS = 1e3;
@@ -5603,10 +5603,10 @@ function listTerminalShells(env = process.env, options = {}) {
5603
5603
  return windowsTerminalShells(env, options).map(({ id, label }) => ({ id, label }));
5604
5604
  }
5605
5605
  function resolveTerminalShell(shell, env = process.env, options = {}) {
5606
- const platform = options.platform ?? process.platform;
5607
- if (platform !== "win32") {
5606
+ const platform2 = options.platform ?? process.platform;
5607
+ if (platform2 !== "win32") {
5608
5608
  if (shell !== void 0) throw new Error("CMD \u548C PowerShell \u9009\u9879\u4EC5\u652F\u6301 Windows \u5F00\u53D1\u673A");
5609
- return { command: defaultShell(env, platform) };
5609
+ return { command: defaultShell(env, platform2) };
5610
5610
  }
5611
5611
  const available = windowsTerminalShells(env, options);
5612
5612
  const resolved = shell === void 0 ? available[0] : available.find(({ id }) => id === shell);
@@ -5617,6 +5617,72 @@ function resolveTerminalShell(shell, env = process.env, options = {}) {
5617
5617
  return { command: resolved.command, label: resolved.label };
5618
5618
  }
5619
5619
 
5620
+ // src/common/filesystem-roots.ts
5621
+ import { execFile } from "child_process";
5622
+ import { readdir as readdir5, readFile as readFile3 } from "fs/promises";
5623
+ import { platform } from "os";
5624
+ import { basename as basename3 } from "path";
5625
+ import { promisify } from "util";
5626
+ var execFileAsync = promisify(execFile);
5627
+ function uniqueRoots(roots) {
5628
+ return [...new Map(roots.map((root) => [root.path, root])).values()];
5629
+ }
5630
+ function decodeMountPath(path) {
5631
+ return path.replace(
5632
+ /\\([0-7]{3})/g,
5633
+ (_, octal) => String.fromCharCode(Number.parseInt(octal, 8))
5634
+ );
5635
+ }
5636
+ function linuxMountRoots(mountinfo) {
5637
+ const roots = [{ name: "/", path: "/" }];
5638
+ for (const line of mountinfo.split("\n")) {
5639
+ const [mount, filesystem] = line.split(" - ");
5640
+ if (!mount || !filesystem) continue;
5641
+ const fields = mount.split(" ");
5642
+ const [type, source] = filesystem.split(" ");
5643
+ const path = decodeMountPath(fields[4] ?? "");
5644
+ const mountRoot = decodeMountPath(fields[3] ?? "");
5645
+ if (!path.startsWith("/") || path === "/") continue;
5646
+ const userMount = /^\/(?:mnt|media|run\/media)(?:\/|$)/.test(path);
5647
+ const volume = source?.startsWith("/dev/") && mountRoot === "/";
5648
+ const network = /^(?:nfs\d*|cifs|smb3?|fuse\..+)$/.test(type ?? "");
5649
+ if (userMount || volume || network) roots.push({ name: basename3(path), path });
5650
+ }
5651
+ return uniqueRoots(roots);
5652
+ }
5653
+ async function listFileSystemRoots() {
5654
+ if (platform() === "win32") {
5655
+ const { stdout } = await execFileAsync(
5656
+ "powershell.exe",
5657
+ [
5658
+ "-NoProfile",
5659
+ "-NonInteractive",
5660
+ "-Command",
5661
+ "$ErrorActionPreference='Stop'; [Console]::OutputEncoding=[Text.UTF8Encoding]::new($false); ConvertTo-Json -InputObject @([System.IO.Directory]::GetLogicalDrives()) -Compress"
5662
+ ],
5663
+ { encoding: "utf8", windowsHide: true, timeout: 5e3, maxBuffer: 64 * 1024 }
5664
+ );
5665
+ const paths = JSON.parse(stdout.replace(/^\uFEFF/, "").trim());
5666
+ if (!Array.isArray(paths) || paths.some((path) => typeof path !== "string" || !/^[a-z]:\\$/i.test(path))) {
5667
+ throw new Error("Invalid logical drive list");
5668
+ }
5669
+ return uniqueRoots(paths.sort().map((path) => ({ name: path, path })));
5670
+ }
5671
+ if (platform() === "darwin") {
5672
+ const volumes = await readdir5("/Volumes", { withFileTypes: true });
5673
+ return [
5674
+ { name: "/", path: "/" },
5675
+ ...volumes.filter(
5676
+ (volume) => !volume.name.startsWith(".") && (volume.isDirectory() || volume.isSymbolicLink())
5677
+ ).map((volume) => ({ name: volume.name, path: `/Volumes/${volume.name}` }))
5678
+ ];
5679
+ }
5680
+ if (platform() === "linux") {
5681
+ return linuxMountRoots(await readFile3("/proc/self/mountinfo", "utf8"));
5682
+ }
5683
+ return [{ name: "/", path: "/" }];
5684
+ }
5685
+
5620
5686
  // src/serve/relay-resource-handlers.ts
5621
5687
  function errorMessage(err) {
5622
5688
  return err instanceof Error ? err.message : String(err);
@@ -5694,6 +5760,30 @@ var RelayResourceHandlers = class {
5694
5760
  serviceLogger.warn({ provider, path: rawPath, error }, "Agent CLI path update rejected");
5695
5761
  }
5696
5762
  }
5763
+ async onFileSystemRootsRequest(msg) {
5764
+ try {
5765
+ const roots = await listFileSystemRoots();
5766
+ this.deps.relaySend(
5767
+ serializeControl({
5768
+ type: "filesystem_roots_response",
5769
+ requestId: msg.requestId,
5770
+ roots
5771
+ })
5772
+ );
5773
+ } catch (err) {
5774
+ const error = errorMessage(err);
5775
+ serviceLogger.warn({ error }, "Filesystem root listing failed");
5776
+ this.deps.relaySend(
5777
+ serializeControl({
5778
+ type: "filesystem_roots_response",
5779
+ requestId: msg.requestId,
5780
+ roots: [],
5781
+ errorCode: ControlErrorCode.UNKNOWN,
5782
+ error: "\u65E0\u6CD5\u8BFB\u53D6\u78C1\u76D8\u4F4D\u7F6E"
5783
+ })
5784
+ );
5785
+ }
5786
+ }
5697
5787
  onDirListRequest(msg) {
5698
5788
  this.deps.controlHandlers.handleDirListRequest({
5699
5789
  path: msg.path ?? "",
@@ -6872,6 +6962,9 @@ var RelayRouter = class {
6872
6962
  case "dir_list_request":
6873
6963
  this.resourceHandlers.onDirListRequest(msg);
6874
6964
  return;
6965
+ case "filesystem_roots_request":
6966
+ void this.resourceHandlers.onFileSystemRootsRequest(msg);
6967
+ return;
6875
6968
  case "dir_create_request":
6876
6969
  this.resourceHandlers.onDirCreateRequest(msg);
6877
6970
  return;
@@ -8885,7 +8978,7 @@ var RemoteFileUploadManager = class {
8885
8978
 
8886
8979
  // src/serve/remote-file-stream.ts
8887
8980
  import { createReadStream as createReadStream3, statSync as statSync3 } from "fs";
8888
- import { basename as basename3 } from "path";
8981
+ import { basename as basename4 } from "path";
8889
8982
 
8890
8983
  // src/serve/remote-file-path.ts
8891
8984
  import { realpathSync as realpathSync2 } from "fs";
@@ -8983,7 +9076,7 @@ var RemoteFileStreamManager = class {
8983
9076
  path,
8984
9077
  mimeType: guessMimeType(resolvedPath),
8985
9078
  size: stat2.size,
8986
- fileName: basename3(resolvedPath) || "download"
9079
+ fileName: basename4(resolvedPath) || "download"
8987
9080
  });
8988
9081
  serviceLogger.info(
8989
9082
  { sessionId, requestId, path, size: stat2.size },
@@ -9058,7 +9151,7 @@ var RemoteFileStreamManager = class {
9058
9151
  path,
9059
9152
  mimeType: guessMimeType(resolvedPath),
9060
9153
  size: stat2.size,
9061
- fileName: basename3(resolvedPath) || "download"
9154
+ fileName: basename4(resolvedPath) || "download"
9062
9155
  });
9063
9156
  stream.on("data", (chunk) => {
9064
9157
  if (active.canceled) return;