@dev-anywhere/proxy 0.9.1 → 0.9.2

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.
Files changed (71) hide show
  1. package/README.md +25 -3
  2. package/dist/autostart-C3RNQ65S.js +292 -0
  3. package/dist/autostart-C3RNQ65S.js.map +1 -0
  4. package/dist/chunk-2YUDGRJ6.js +379 -0
  5. package/dist/chunk-2YUDGRJ6.js.map +1 -0
  6. package/dist/chunk-74HWO753.js +285 -0
  7. package/dist/chunk-74HWO753.js.map +1 -0
  8. package/dist/chunk-77QVUYU7.js +42 -0
  9. package/dist/chunk-77QVUYU7.js.map +1 -0
  10. package/dist/chunk-DAFUSBKJ.js +299 -0
  11. package/dist/chunk-DAFUSBKJ.js.map +1 -0
  12. package/dist/{chunk-HLN3NOD2.js → chunk-GFDOVLGL.js} +70 -1
  13. package/dist/chunk-GFDOVLGL.js.map +1 -0
  14. package/dist/{chunk-SEMZ7GW7.js → chunk-GYL5JKWQ.js} +3 -3
  15. package/dist/{chunk-57LA2LWY.js → chunk-HYDXGNKA.js} +2 -2
  16. package/dist/chunk-ICSO3ZIS.js +658 -0
  17. package/dist/chunk-ICSO3ZIS.js.map +1 -0
  18. package/dist/chunk-JZ7MWN24.js +22 -0
  19. package/dist/chunk-JZ7MWN24.js.map +1 -0
  20. package/dist/chunk-KINQESTO.js +145 -0
  21. package/dist/chunk-KINQESTO.js.map +1 -0
  22. package/dist/{chunk-ZNMJH7BK.js → chunk-KWODOJBK.js} +3 -3
  23. package/dist/chunk-MLE2OKCM.js +116 -0
  24. package/dist/chunk-MLE2OKCM.js.map +1 -0
  25. package/dist/{chunk-UJEZAG57.js → chunk-PCF2R2TG.js} +3 -1
  26. package/dist/{chunk-UJEZAG57.js.map → chunk-PCF2R2TG.js.map} +1 -1
  27. package/dist/{chunk-NTL4CXBA.js → chunk-V4HDLUAQ.js} +27 -42
  28. package/dist/chunk-V4HDLUAQ.js.map +1 -0
  29. package/dist/{chunk-DZ4GXMP5.js → chunk-VHMAUU72.js} +56 -68
  30. package/dist/chunk-VHMAUU72.js.map +1 -0
  31. package/dist/{chunk-OFD4UVPB.js → chunk-XADKKDUV.js} +29 -153
  32. package/dist/chunk-XADKKDUV.js.map +1 -0
  33. package/dist/{chunk-WRU3BXW6.js → chunk-YK2XKOP4.js} +26 -10
  34. package/dist/chunk-YK2XKOP4.js.map +1 -0
  35. package/dist/index.js +130 -343
  36. package/dist/index.js.map +1 -1
  37. package/dist/logger-24TGGN76.js +10 -0
  38. package/dist/logger-24TGGN76.js.map +1 -0
  39. package/dist/logger-B7B64O4P.js +14 -0
  40. package/dist/logger-B7B64O4P.js.map +1 -0
  41. package/dist/{quick-tunnel-RI62V2RH.js → quick-tunnel-ZIFTYUUD.js} +3 -3
  42. package/dist/{relay-token-ZP3PAZD2.js → relay-token-N3BSBURG.js} +5 -5
  43. package/dist/serve.js +1158 -380
  44. package/dist/serve.js.map +1 -1
  45. package/dist/session-worker.js +91 -76
  46. package/dist/session-worker.js.map +1 -1
  47. package/dist/{terminal-BEXDQ5WK.js → terminal-7JY6J3XN.js} +88 -36
  48. package/dist/terminal-7JY6J3XN.js.map +1 -0
  49. package/dist/terminal-worker.js +93 -44
  50. package/dist/terminal-worker.js.map +1 -1
  51. package/dist/update-runner.js +86 -61
  52. package/dist/update-runner.js.map +1 -1
  53. package/package.json +9 -6
  54. package/scripts/postinstall.cjs +22 -0
  55. package/dist/chunk-7SYT65DN.js +0 -155
  56. package/dist/chunk-7SYT65DN.js.map +0 -1
  57. package/dist/chunk-DZ4GXMP5.js.map +0 -1
  58. package/dist/chunk-HLN3NOD2.js.map +0 -1
  59. package/dist/chunk-KGTYU4WO.js +0 -36
  60. package/dist/chunk-KGTYU4WO.js.map +0 -1
  61. package/dist/chunk-NTL4CXBA.js.map +0 -1
  62. package/dist/chunk-OFD4UVPB.js.map +0 -1
  63. package/dist/chunk-WC3KEY7N.js +0 -158
  64. package/dist/chunk-WC3KEY7N.js.map +0 -1
  65. package/dist/chunk-WRU3BXW6.js.map +0 -1
  66. package/dist/terminal-BEXDQ5WK.js.map +0 -1
  67. /package/dist/{chunk-SEMZ7GW7.js.map → chunk-GYL5JKWQ.js.map} +0 -0
  68. /package/dist/{chunk-57LA2LWY.js.map → chunk-HYDXGNKA.js.map} +0 -0
  69. /package/dist/{chunk-ZNMJH7BK.js.map → chunk-KWODOJBK.js.map} +0 -0
  70. /package/dist/{quick-tunnel-RI62V2RH.js.map → quick-tunnel-ZIFTYUUD.js.map} +0 -0
  71. /package/dist/{relay-token-ZP3PAZD2.js.map → relay-token-N3BSBURG.js.map} +0 -0
package/README.md CHANGED
@@ -10,6 +10,8 @@ npm install -g @dev-anywhere/proxy
10
10
 
11
11
  This installs the `dev-anywhere` command globally.
12
12
 
13
+ Supported development machines: macOS, Linux, and native Windows 11. WSL is not required on Windows.
14
+
13
15
  Requires Node.js >= 20 and at least one supported local AI coding CLI installed locally: Claude Code, Codex, or Kimi Code.
14
16
 
15
17
  ## Quick start
@@ -43,6 +45,9 @@ dev-anywhere serve stop # stop daemon
43
45
  dev-anywhere serve restart # restart daemon using the selected profile's relay
44
46
  dev-anywhere serve restart --relay cloud
45
47
  dev-anywhere serve status # show daemon status
48
+ dev-anywhere serve autostart enable # start automatically at user login
49
+ dev-anywhere serve autostart disable # cancel automatic startup
50
+ dev-anywhere serve autostart status # show automatic startup setting
46
51
  dev-anywhere init # create default config at ~/.dev-anywhere/config.json
47
52
  dev-anywhere tunnel # temporary account-free Cloudflare Quick Tunnel
48
53
  dev-anywhere claude [...args] # start/attach a Claude Code terminal session
@@ -53,6 +58,8 @@ dev-anywhere --help
53
58
 
54
59
  The daemon connects to the relay server over WebSocket and manages local AI CLI sessions. A mobile/web client connected to the same relay can then see and drive those sessions.
55
60
 
61
+ Autostart is optional and applies to the selected profile. Enabling or disabling it does not start, restart, or stop the current Proxy. It is available on macOS, Linux with systemd user services, and Windows for the current user.
62
+
56
63
  Arguments after `claude`, `codex`, or `kimi` are passed through to the real CLI:
57
64
 
58
65
  ```bash
@@ -87,7 +94,7 @@ The Relay package includes the Web client. For a turnkey VPS setup with TLS and
87
94
 
88
95
  ## Configuration
89
96
 
90
- Config file: `~/.dev-anywhere/config.json`
97
+ Config file: `~/.dev-anywhere/config.json` (`%USERPROFILE%\.dev-anywhere\config.json` on Windows).
91
98
 
92
99
  ```json
93
100
  {
@@ -120,7 +127,22 @@ that value in Settings -> Relay Token so the browser client can authenticate.
120
127
 
121
128
  `dev-anywhere serve start --relay cloud` and `dev-anywhere serve restart --relay cloud` use a named relay without editing the file each time.
122
129
 
123
- `autoUpdate` defaults to `true` and runs after this machine connects to the Relay. DEV Anywhere 0.9.0 must be installed manually on every development machine after the Relay is upgraded; restart the service after installing it. Set `autoUpdate` to `false` and restart the service to keep the installed version.
130
+ `autoUpdate` defaults to `true` and runs after this machine connects to the Relay. Set `autoUpdate` to `false` and restart the service to keep the installed version.
131
+
132
+ The first upgrade from an earlier release to 0.9.2 requires a one-time manual update. Stop the Proxy with the existing CLI before upgrading the Relay or installing the new release:
133
+
134
+ ```bash
135
+ dev-anywhere serve stop
136
+ ```
137
+
138
+ After upgrading the Relay:
139
+
140
+ ```bash
141
+ npm install -g @dev-anywhere/proxy@0.9.2
142
+ dev-anywhere serve start --relay cloud
143
+ ```
144
+
145
+ This upgrade ends existing terminal sessions; restart them after updating. See the [upgrade guide](https://github.com/lichenxicatapple-blip/dev-anywhere/blob/main/README.en.md#upgrading) for the full steps.
124
146
 
125
147
  If DEV Anywhere cannot detect an agent CLI automatically, set its persistent
126
148
  path under the top-level `agentCli` object:
@@ -146,7 +168,7 @@ Environment variables are reserved for temporary overrides:
146
168
  ## How it works
147
169
 
148
170
  - Local daemon wraps Claude Code, Codex, and Kimi Code CLI sessions with `node-pty` for transparent terminal control. Claude Code and Codex also support structured chat-message mode; Kimi Code supports ACP chat with streaming output, tool calls and interactive approvals, turn cancellation, and history resume.
149
- - IPC socket at `~/.dev-anywhere/run/dev-anywhere.sock` for terminal attachment.
171
+ - Local terminal attachment uses a Unix-domain socket on macOS/Linux or a named pipe on Windows.
150
172
  - Terminal bytes + structured control messages are forwarded to relay over WebSocket.
151
173
  - Relay serves the Web client and routes live traffic; session state remains on the proxy side.
152
174
 
@@ -0,0 +1,292 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getErrorMessage,
4
+ refreshLoginShellPath
5
+ } from "./chunk-XADKKDUV.js";
6
+ import {
7
+ createProfileServiceLifecycle
8
+ } from "./chunk-2YUDGRJ6.js";
9
+ import "./chunk-DAFUSBKJ.js";
10
+ import {
11
+ IS_DEV,
12
+ resolveTopLevelScript
13
+ } from "./chunk-PCF2R2TG.js";
14
+ import "./chunk-77QVUYU7.js";
15
+ import {
16
+ quoteWindowsArgument
17
+ } from "./chunk-KINQESTO.js";
18
+ import {
19
+ PROFILE_NAME,
20
+ isInitialized
21
+ } from "./chunk-YK2XKOP4.js";
22
+
23
+ // src/autostart.ts
24
+ import { homedir, userInfo } from "os";
25
+ import { fileURLToPath } from "url";
26
+
27
+ // src/common/service-autostart.ts
28
+ import { execFile } from "child_process";
29
+ import { createHash } from "crypto";
30
+ import { mkdir, readFile, unlink, writeFile } from "fs/promises";
31
+ import { dirname, join, win32 } from "path";
32
+ import { promisify } from "util";
33
+ function checkText(value) {
34
+ if ([...value].some((char) => char.charCodeAt(0) <= 31 || char.charCodeAt(0) === 127)) {
35
+ throw new Error("Autostart paths and environment must not contain control characters");
36
+ }
37
+ return value;
38
+ }
39
+ function xml(value) {
40
+ return checkText(value).replace(
41
+ /[&<>"']/g,
42
+ (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&apos;" })[char]
43
+ );
44
+ }
45
+ function unitString(value) {
46
+ return `"${checkText(value).replaceAll("\\", "\\\\").replaceAll('"', '\\"').replaceAll("%", "%%")}"`;
47
+ }
48
+ function psString(value) {
49
+ return `'${checkText(value).replaceAll("'", "''")}'`;
50
+ }
51
+ function encodePowerShell(script) {
52
+ return Buffer.from(script, "utf16le").toString("base64");
53
+ }
54
+ async function readIfPresent(path) {
55
+ try {
56
+ return await readFile(path, "utf8");
57
+ } catch (error) {
58
+ if (error.code === "ENOENT") return null;
59
+ throw error;
60
+ }
61
+ }
62
+ async function removeIfPresent(path) {
63
+ try {
64
+ await unlink(path);
65
+ } catch (error) {
66
+ if (error.code !== "ENOENT") throw error;
67
+ }
68
+ }
69
+ var execFileAsync = promisify(execFile);
70
+ function createServiceAutostart(options) {
71
+ const { platform, home, profile, executable, env } = options;
72
+ if (!["darwin", "linux", "win32"].includes(platform)) {
73
+ throw new Error(`Proxy autostart is not supported on ${platform}`);
74
+ }
75
+ const identity = createHash("sha256").update(`${home}\0${profile}`).digest("hex").slice(0, 20);
76
+ const label = `dev-anywhere-${identity}`;
77
+ const args = [...options.args, "--profile", profile, "serve", "autostart", "run"];
78
+ const run = options.run ?? (async (command, commandArgs) => {
79
+ const result = await execFileAsync(command, commandArgs, {
80
+ timeout: 15e3,
81
+ maxBuffer: 256 * 1024,
82
+ windowsHide: true,
83
+ encoding: "utf8"
84
+ });
85
+ return result.stdout;
86
+ });
87
+ const powershell = win32.join(
88
+ env.SystemRoot ?? env.SYSTEMROOT ?? "C:\\Windows",
89
+ "System32",
90
+ "WindowsPowerShell",
91
+ "v1.0",
92
+ "powershell.exe"
93
+ );
94
+ const runPowerShell = (script) => run(powershell, [
95
+ "-NoProfile",
96
+ "-NonInteractive",
97
+ "-EncodedCommand",
98
+ encodePowerShell(`$ErrorActionPreference = 'Stop';
99
+ ${script}`)
100
+ ]);
101
+ const taskLookup = `$task = Get-ScheduledTask -ErrorAction Stop | Where-Object { $_.TaskPath -eq '\\' -and $_.TaskName -eq ${psString(label)} };`;
102
+ const unit = `${label}.service`;
103
+ const filePath = platform === "darwin" ? join(home, "Library", "LaunchAgents", `${label}.plist`) : join(env.XDG_CONFIG_HOME || join(home, ".config"), "systemd", "user", unit);
104
+ const domain = `gui/${options.uid}`;
105
+ const launchdTarget = `${domain}/${label}`;
106
+ const environment = {
107
+ HOME: checkText(home),
108
+ ...Object.fromEntries(
109
+ ["PATH", "SHELL"].flatMap((key) => env[key] ? [[key, checkText(env[key])]] : [])
110
+ )
111
+ };
112
+ function definition() {
113
+ if (platform === "darwin") {
114
+ return `<?xml version="1.0" encoding="UTF-8"?>
115
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
116
+ <plist version="1.0"><dict>
117
+ <key>Label</key><string>${xml(label)}</string>
118
+ <key>ProgramArguments</key><array>${[executable, ...args].map((arg) => `<string>${xml(arg)}</string>`).join("")}</array>
119
+ <key>WorkingDirectory</key><string>${xml(home)}</string>
120
+ <key>EnvironmentVariables</key><dict>${Object.entries(environment).map(([key, value]) => `<key>${xml(key)}</key><string>${xml(value)}</string>`).join("")}</dict>
121
+ <key>RunAtLoad</key><true/>
122
+ <key>KeepAlive</key><false/>
123
+ </dict></plist>
124
+ `;
125
+ }
126
+ return `[Unit]
127
+ Description=DEV Anywhere Proxy (${checkText(profile)})
128
+
129
+ [Service]
130
+ Type=oneshot
131
+ RemainAfterExit=yes
132
+ Restart=no
133
+ WorkingDirectory=${unitString(home)}
134
+ ${Object.entries(environment).map(([key, value]) => `Environment=${unitString(`${key}=${value}`)}`).join("\n")}
135
+ ExecStart=:${[executable, ...args, "--daemon"].map(unitString).join(" ")}
136
+ TimeoutStartSec=60
137
+
138
+ [Install]
139
+ WantedBy=default.target
140
+ `;
141
+ }
142
+ function windowsTask() {
143
+ const launcher = `$ErrorActionPreference = 'Stop';
144
+ $info = New-Object System.Diagnostics.ProcessStartInfo;
145
+ $info.FileName = ${psString(executable)};
146
+ $info.Arguments = ${psString(args.map(quoteWindowsArgument).join(" "))};
147
+ $info.WorkingDirectory = ${psString(home)};
148
+ $info.EnvironmentVariables['USERPROFILE'] = ${psString(home)};
149
+ $info.EnvironmentVariables['HOME'] = ${psString(home)};
150
+ $info.UseShellExecute = $false;
151
+ $info.CreateNoWindow = $true;
152
+ $child = [System.Diagnostics.Process]::Start($info);
153
+ $child.WaitForExit();
154
+ exit $child.ExitCode;`;
155
+ return `$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;
156
+ $action = New-ScheduledTaskAction -Execute ${psString(powershell)} -Argument ${psString(`-NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${encodePowerShell(launcher)}`)};
157
+ $trigger = New-ScheduledTaskTrigger -AtLogOn -User $user;
158
+ $principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited;
159
+ $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew -Priority 4;
160
+ Register-ScheduledTask -TaskPath '\\' -TaskName ${psString(label)} -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description 'DEV Anywhere Proxy: start at user login' -Force | Out-Null;`;
161
+ }
162
+ async function status() {
163
+ if (platform === "win32") {
164
+ const output2 = await runPowerShell(
165
+ `${taskLookup}
166
+ [bool]($task -and $task.Settings.Enabled) | ConvertTo-Json -Compress;`
167
+ );
168
+ const enabled = JSON.parse(output2.trim());
169
+ if (typeof enabled !== "boolean") throw new Error("Invalid Windows autostart status");
170
+ return enabled;
171
+ }
172
+ if (await readIfPresent(filePath) === null) return false;
173
+ if (platform === "darwin") {
174
+ if (options.uid === void 0) throw new Error("Cannot determine the current macOS user");
175
+ const output2 = await run("/bin/launchctl", ["print-disabled", domain]);
176
+ return !output2.includes(`"${label}" => true`);
177
+ }
178
+ const output = await run("systemctl", [
179
+ "--user",
180
+ "show",
181
+ unit,
182
+ "--property=UnitFileState",
183
+ "--value"
184
+ ]);
185
+ return output.trim() === "enabled";
186
+ }
187
+ async function enable() {
188
+ if (platform === "win32") {
189
+ await runPowerShell(windowsTask());
190
+ return;
191
+ }
192
+ if (platform === "darwin" && options.uid === void 0) {
193
+ throw new Error("Cannot determine the current macOS user");
194
+ }
195
+ const content = definition();
196
+ await mkdir(dirname(filePath), { recursive: true });
197
+ const previous = await readIfPresent(filePath);
198
+ await writeFile(filePath, content, { mode: 384 });
199
+ try {
200
+ if (platform === "darwin") {
201
+ await run("/bin/launchctl", ["enable", launchdTarget]);
202
+ } else {
203
+ await run("systemctl", ["--user", "daemon-reload"]);
204
+ await run("systemctl", ["--user", "enable", unit]);
205
+ }
206
+ } catch (error) {
207
+ if (previous === null) await removeIfPresent(filePath);
208
+ else await writeFile(filePath, previous, { mode: 384 });
209
+ throw error;
210
+ }
211
+ }
212
+ async function disable() {
213
+ if (platform === "win32") {
214
+ await runPowerShell(
215
+ `${taskLookup}
216
+ if ($task) { $task | Unregister-ScheduledTask -Confirm:$false; }`
217
+ );
218
+ return;
219
+ }
220
+ if (await readIfPresent(filePath) === null) return;
221
+ if (platform === "darwin") {
222
+ if (options.uid === void 0) throw new Error("Cannot determine the current macOS user");
223
+ await run("/bin/launchctl", ["disable", launchdTarget]);
224
+ } else {
225
+ await run("systemctl", ["--user", "disable", unit]);
226
+ }
227
+ await removeIfPresent(filePath);
228
+ if (platform === "linux") await run("systemctl", ["--user", "daemon-reload"]);
229
+ }
230
+ return { enable, disable, status };
231
+ }
232
+
233
+ // src/autostart.ts
234
+ async function runAutostartCommand(action) {
235
+ try {
236
+ if (action === "enable" && !isInitialized()) {
237
+ throw new Error('Dev Anywhere is not initialized. Run "dev-anywhere init" first.');
238
+ }
239
+ const entry = `${fileURLToPath(resolveTopLevelScript("index"))}${IS_DEV ? ".ts" : ".js"}`;
240
+ const autostart = createServiceAutostart({
241
+ platform: process.platform,
242
+ home: homedir(),
243
+ profile: PROFILE_NAME,
244
+ executable: process.execPath,
245
+ args: IS_DEV ? ["--import", import.meta.resolve("tsx"), entry] : [entry],
246
+ env: { ...process.env, SHELL: process.env.SHELL ?? userInfo().shell ?? void 0 },
247
+ uid: process.getuid?.()
248
+ });
249
+ if (action === "status") {
250
+ console.log(
251
+ `${PROFILE_NAME}: ${await autostart.status() ? "\u5DF2\u8BBE\u7F6E\u767B\u5F55\u540E\u81EA\u52A8\u542F\u52A8" : "\u672A\u8BBE\u7F6E\u81EA\u52A8\u542F\u52A8"}`
252
+ );
253
+ return;
254
+ }
255
+ await autostart[action]();
256
+ console.log(
257
+ action === "enable" ? `${PROFILE_NAME}: \u5DF2\u8BBE\u7F6E\u767B\u5F55\u540E\u81EA\u52A8\u542F\u52A8\uFF0C\u5F53\u524D Proxy \u4E0D\u53D7\u5F71\u54CD\u3002` : `${PROFILE_NAME}: \u5DF2\u53D6\u6D88\u81EA\u52A8\u542F\u52A8\uFF0C\u5F53\u524D Proxy \u4E0D\u53D7\u5F71\u54CD\u3002`
258
+ );
259
+ } catch (error) {
260
+ console.error(getErrorMessage(error));
261
+ process.exitCode = 1;
262
+ }
263
+ }
264
+ async function startAutostartService(daemon) {
265
+ try {
266
+ if (!isInitialized()) throw new Error("Proxy configuration is missing");
267
+ if (process.platform !== "win32") {
268
+ const refreshed = await refreshLoginShellPath({
269
+ env: { ...process.env, SHELL: process.env.SHELL ?? userInfo().shell ?? void 0 }
270
+ });
271
+ if (refreshed.path !== void 0) process.env.PATH = refreshed.path;
272
+ }
273
+ const lifecycle = createProfileServiceLifecycle();
274
+ if (daemon) await lifecycle.start("explicit");
275
+ else
276
+ await lifecycle.startForeground(async () => {
277
+ const { startService } = await import("./serve.js");
278
+ await startService();
279
+ });
280
+ } catch (error) {
281
+ const { serviceLogger } = await import("./logger-B7B64O4P.js");
282
+ const { flushLogger } = await import("./logger-24TGGN76.js");
283
+ serviceLogger.error({ err: getErrorMessage(error) }, "Proxy login startup failed");
284
+ await flushLogger(serviceLogger);
285
+ process.exit(1);
286
+ }
287
+ }
288
+ export {
289
+ runAutostartCommand,
290
+ startAutostartService
291
+ };
292
+ //# sourceMappingURL=autostart-C3RNQ65S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/autostart.ts","../src/common/service-autostart.ts"],"sourcesContent":["import { homedir, userInfo } from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\nimport { IS_DEV, resolveTopLevelScript } from \"./common/env.js\";\nimport { isInitialized, PROFILE_NAME } from \"./common/paths.js\";\nimport { createServiceAutostart } from \"./common/service-autostart.js\";\nimport { createProfileServiceLifecycle } from \"./common/profile-service.js\";\nimport { refreshLoginShellPath } from \"./common/login-shell-path.js\";\nimport { getErrorMessage } from \"./common/process-probe.js\";\n\nexport async function runAutostartCommand(action: \"enable\" | \"disable\" | \"status\"): Promise<void> {\n try {\n if (action === \"enable\" && !isInitialized()) {\n throw new Error('Dev Anywhere is not initialized. Run \"dev-anywhere init\" first.');\n }\n const entry = `${fileURLToPath(resolveTopLevelScript(\"index\"))}${IS_DEV ? \".ts\" : \".js\"}`;\n const autostart = createServiceAutostart({\n platform: process.platform,\n home: homedir(),\n profile: PROFILE_NAME,\n executable: process.execPath,\n args: IS_DEV ? [\"--import\", import.meta.resolve(\"tsx\"), entry] : [entry],\n env: { ...process.env, SHELL: process.env.SHELL ?? userInfo().shell ?? undefined },\n uid: process.getuid?.(),\n });\n if (action === \"status\") {\n console.log(\n `${PROFILE_NAME}: ${(await autostart.status()) ? \"已设置登录后自动启动\" : \"未设置自动启动\"}`,\n );\n return;\n }\n await autostart[action]();\n console.log(\n action === \"enable\"\n ? `${PROFILE_NAME}: 已设置登录后自动启动,当前 Proxy 不受影响。`\n : `${PROFILE_NAME}: 已取消自动启动,当前 Proxy 不受影响。`,\n );\n } catch (error) {\n console.error(getErrorMessage(error));\n process.exitCode = 1;\n }\n}\n\n/** System login triggers enter the same lifecycle controller as manual CLI commands. */\nexport async function startAutostartService(daemon: boolean): Promise<void> {\n try {\n if (!isInitialized()) throw new Error(\"Proxy configuration is missing\");\n if (process.platform !== \"win32\") {\n const refreshed = await refreshLoginShellPath({\n env: { ...process.env, SHELL: process.env.SHELL ?? userInfo().shell ?? undefined },\n });\n if (refreshed.path !== undefined) process.env.PATH = refreshed.path;\n }\n const lifecycle = createProfileServiceLifecycle();\n if (daemon) await lifecycle.start(\"explicit\");\n else\n await lifecycle.startForeground(async () => {\n const { startService } = await import(\"./serve.js\");\n await startService();\n });\n } catch (error) {\n const { serviceLogger } = await import(\"./common/logger.js\");\n const { flushLogger } = await import(\"@dev-anywhere/shared/logger\");\n serviceLogger.error({ err: getErrorMessage(error) }, \"Proxy login startup failed\");\n await flushLogger(serviceLogger);\n process.exit(1);\n }\n}\n","import { execFile } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { mkdir, readFile, unlink, writeFile } from \"node:fs/promises\";\nimport { dirname, join, win32 } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { quoteWindowsArgument } from \"./command-launch.js\";\n\ninterface AutostartOptions {\n platform: NodeJS.Platform;\n home: string;\n profile: string;\n executable: string;\n /** Absolute CLI entry and any runtime arguments (e.g. the source-mode TS loader). */\n args: string[];\n env: NodeJS.ProcessEnv;\n uid?: number;\n run?: (command: string, args: string[]) => Promise<string>;\n}\n\nfunction checkText(value: string): string {\n if ([...value].some((char) => char.charCodeAt(0) <= 31 || char.charCodeAt(0) === 127)) {\n throw new Error(\"Autostart paths and environment must not contain control characters\");\n }\n return value;\n}\n\nfunction xml(value: string): string {\n return checkText(value).replace(\n /[&<>\"']/g,\n (char) => ({ \"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\", '\"': \"&quot;\", \"'\": \"&apos;\" })[char]!,\n );\n}\n\nfunction unitString(value: string): string {\n return `\"${checkText(value).replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"').replaceAll(\"%\", \"%%\")}\"`;\n}\n\nfunction psString(value: string): string {\n return `'${checkText(value).replaceAll(\"'\", \"''\")}'`;\n}\n\nfunction encodePowerShell(script: string): string {\n return Buffer.from(script, \"utf16le\").toString(\"base64\");\n}\n\nasync function readIfPresent(path: string): Promise<string | null> {\n try {\n return await readFile(path, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n throw error;\n }\n}\n\nasync function removeIfPresent(path: string): Promise<void> {\n try {\n await unlink(path);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n}\n\nconst execFileAsync = promisify(execFile);\n\n/** Registers a login trigger, not another process supervisor. Enabling never restarts a Proxy. */\nexport function createServiceAutostart(options: AutostartOptions) {\n const { platform, home, profile, executable, env } = options;\n if (![\"darwin\", \"linux\", \"win32\"].includes(platform)) {\n throw new Error(`Proxy autostart is not supported on ${platform}`);\n }\n const identity = createHash(\"sha256\").update(`${home}\\0${profile}`).digest(\"hex\").slice(0, 20);\n const label = `dev-anywhere-${identity}`;\n const args = [...options.args, \"--profile\", profile, \"serve\", \"autostart\", \"run\"];\n const run =\n options.run ??\n (async (command: string, commandArgs: string[]) => {\n const result = await execFileAsync(command, commandArgs, {\n timeout: 15_000,\n maxBuffer: 256 * 1024,\n windowsHide: true,\n encoding: \"utf8\",\n });\n return result.stdout;\n });\n const powershell = win32.join(\n env.SystemRoot ?? env.SYSTEMROOT ?? \"C:\\\\Windows\",\n \"System32\",\n \"WindowsPowerShell\",\n \"v1.0\",\n \"powershell.exe\",\n );\n const runPowerShell = (script: string) =>\n run(powershell, [\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-EncodedCommand\",\n encodePowerShell(`$ErrorActionPreference = 'Stop';\\n${script}`),\n ]);\n const taskLookup = `$task = Get-ScheduledTask -ErrorAction Stop | Where-Object { $_.TaskPath -eq '\\\\' -and $_.TaskName -eq ${psString(label)} };`;\n const unit = `${label}.service`;\n const filePath =\n platform === \"darwin\"\n ? join(home, \"Library\", \"LaunchAgents\", `${label}.plist`)\n : join(env.XDG_CONFIG_HOME || join(home, \".config\"), \"systemd\", \"user\", unit);\n const domain = `gui/${options.uid}`;\n const launchdTarget = `${domain}/${label}`;\n\n const environment = {\n HOME: checkText(home),\n ...Object.fromEntries(\n [\"PATH\", \"SHELL\"].flatMap((key) => (env[key] ? [[key, checkText(env[key]!)]] : [])),\n ),\n };\n\n function definition(): string {\n if (platform === \"darwin\") {\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\"><dict>\n<key>Label</key><string>${xml(label)}</string>\n<key>ProgramArguments</key><array>${[executable, ...args].map((arg) => `<string>${xml(arg)}</string>`).join(\"\")}</array>\n<key>WorkingDirectory</key><string>${xml(home)}</string>\n<key>EnvironmentVariables</key><dict>${Object.entries(environment)\n .map(([key, value]) => `<key>${xml(key)}</key><string>${xml(value)}</string>`)\n .join(\"\")}</dict>\n<key>RunAtLoad</key><true/>\n<key>KeepAlive</key><false/>\n</dict></plist>\n`;\n }\n // Keep the unit active after the short-lived start command exits. Otherwise systemd would\n // terminate the detached Proxy (and its updater) along with that command's control group.\n return `[Unit]\nDescription=DEV Anywhere Proxy (${checkText(profile)})\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nRestart=no\nWorkingDirectory=${unitString(home)}\n${Object.entries(environment)\n .map(([key, value]) => `Environment=${unitString(`${key}=${value}`)}`)\n .join(\"\\n\")}\nExecStart=:${[executable, ...args, \"--daemon\"].map(unitString).join(\" \")}\nTimeoutStartSec=60\n\n[Install]\nWantedBy=default.target\n`;\n }\n\n function windowsTask(): string {\n const launcher = `$ErrorActionPreference = 'Stop';\n$info = New-Object System.Diagnostics.ProcessStartInfo;\n$info.FileName = ${psString(executable)};\n$info.Arguments = ${psString(args.map(quoteWindowsArgument).join(\" \"))};\n$info.WorkingDirectory = ${psString(home)};\n$info.EnvironmentVariables['USERPROFILE'] = ${psString(home)};\n$info.EnvironmentVariables['HOME'] = ${psString(home)};\n$info.UseShellExecute = $false;\n$info.CreateNoWindow = $true;\n$child = [System.Diagnostics.Process]::Start($info);\n$child.WaitForExit();\nexit $child.ExitCode;`;\n return `$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;\n$action = New-ScheduledTaskAction -Execute ${psString(powershell)} -Argument ${psString(`-NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${encodePowerShell(launcher)}`)};\n$trigger = New-ScheduledTaskTrigger -AtLogOn -User $user;\n$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited;\n$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew -Priority 4;\nRegister-ScheduledTask -TaskPath '\\\\' -TaskName ${psString(label)} -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description 'DEV Anywhere Proxy: start at user login' -Force | Out-Null;`;\n }\n\n async function status(): Promise<boolean> {\n if (platform === \"win32\") {\n const output = await runPowerShell(\n `${taskLookup}\\n[bool]($task -and $task.Settings.Enabled) | ConvertTo-Json -Compress;`,\n );\n const enabled: unknown = JSON.parse(output.trim());\n if (typeof enabled !== \"boolean\") throw new Error(\"Invalid Windows autostart status\");\n return enabled;\n }\n if ((await readIfPresent(filePath)) === null) return false;\n if (platform === \"darwin\") {\n if (options.uid === undefined) throw new Error(\"Cannot determine the current macOS user\");\n const output = await run(\"/bin/launchctl\", [\"print-disabled\", domain]);\n return !output.includes(`\"${label}\" => true`);\n }\n const output = await run(\"systemctl\", [\n \"--user\",\n \"show\",\n unit,\n \"--property=UnitFileState\",\n \"--value\",\n ]);\n return output.trim() === \"enabled\";\n }\n\n async function enable(): Promise<void> {\n if (platform === \"win32\") {\n await runPowerShell(windowsTask());\n return;\n }\n if (platform === \"darwin\" && options.uid === undefined) {\n throw new Error(\"Cannot determine the current macOS user\");\n }\n const content = definition();\n await mkdir(dirname(filePath), { recursive: true });\n const previous = await readIfPresent(filePath);\n await writeFile(filePath, content, { mode: 0o600 });\n try {\n if (platform === \"darwin\") {\n // No bootstrap/kickstart: registration takes effect at the next login, without touching\n // a running Proxy. An existing system-disabled override must not defeat re-enabling.\n await run(\"/bin/launchctl\", [\"enable\", launchdTarget]);\n } else {\n await run(\"systemctl\", [\"--user\", \"daemon-reload\"]);\n await run(\"systemctl\", [\"--user\", \"enable\", unit]);\n }\n } catch (error) {\n if (previous === null) await removeIfPresent(filePath);\n else await writeFile(filePath, previous, { mode: 0o600 });\n throw error;\n }\n }\n\n async function disable(): Promise<void> {\n if (platform === \"win32\") {\n await runPowerShell(\n `${taskLookup}\\nif ($task) { $task | Unregister-ScheduledTask -Confirm:$false; }`,\n );\n return;\n }\n if ((await readIfPresent(filePath)) === null) return;\n if (platform === \"darwin\") {\n if (options.uid === undefined) throw new Error(\"Cannot determine the current macOS user\");\n await run(\"/bin/launchctl\", [\"disable\", launchdTarget]);\n } else {\n await run(\"systemctl\", [\"--user\", \"disable\", unit]);\n }\n await removeIfPresent(filePath);\n if (platform === \"linux\") await run(\"systemctl\", [\"--user\", \"daemon-reload\"]);\n // Never bootout, stop, or unregister with process termination: disabling only affects login.\n }\n\n return { enable, disable, status };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,qBAAqB;;;ACD9B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,OAAO,UAAU,QAAQ,iBAAiB;AACnD,SAAS,SAAS,MAAM,aAAa;AACrC,SAAS,iBAAiB;AAe1B,SAAS,UAAU,OAAuB;AACxC,MAAI,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,SAAS,KAAK,WAAW,CAAC,KAAK,MAAM,KAAK,WAAW,CAAC,MAAM,GAAG,GAAG;AACrF,UAAM,IAAI,MAAM,qEAAqE;AAAA,EACvF;AACA,SAAO;AACT;AAEA,SAAS,IAAI,OAAuB;AAClC,SAAO,UAAU,KAAK,EAAE;AAAA,IACtB;AAAA,IACA,CAAC,UAAU,EAAE,KAAK,SAAS,KAAK,QAAQ,KAAK,QAAQ,KAAK,UAAU,KAAK,SAAS,GAAG,IAAI;AAAA,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