ellm-proxy 0.0.10 → 0.0.11

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 (3) hide show
  1. package/dist/cli.js +43 -13
  2. package/dist/server.js +41 -11
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -35167,6 +35167,7 @@ import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as rea
35167
35167
  import { spawn as spawn3 } from "node:child_process";
35168
35168
  import { homedir as homedir2, platform as platform8 } from "node:os";
35169
35169
  import { join as join6 } from "node:path";
35170
+ var AUTOSTART_VBS = "ellm-proxy-autostart.vbs";
35170
35171
  var AUTOSTART_CMD = "ellm-proxy-autostart.cmd";
35171
35172
  var PLIST_LABEL = "com.ellm-proxy.autostart";
35172
35173
  var LINUX_UNIT = "ellm-proxy.service";
@@ -35200,7 +35201,7 @@ function runExit(cmd, args) {
35200
35201
  function platformItemPath() {
35201
35202
  switch (platform8()) {
35202
35203
  case "win32":
35203
- return join6(windowsStartupDir(), AUTOSTART_CMD);
35204
+ return join6(windowsStartupDir(), AUTOSTART_VBS);
35204
35205
  case "darwin":
35205
35206
  return join6(homedir2(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
35206
35207
  case "linux":
@@ -35210,15 +35211,24 @@ function platformItemPath() {
35210
35211
  }
35211
35212
  }
35212
35213
  function windowsBody(nodePath, target) {
35214
+ const logPath = join6(target.appDir, "logs", "autostart.log");
35213
35215
  const lines = [
35214
35216
  "@echo off",
35215
35217
  `rem Auto-generated by "ellm-proxy autostart on" (${MARKER}). Disable with "ellm-proxy autostart off".`,
35216
35218
  ...Object.entries(target.env).map(([k, v]) => `set "${k}=${v}"`),
35217
- `"${nodePath}" "${target.serverJs}" >nul 2>&1`,
35219
+ `>> "${logPath}" echo [%date% %time%] autostart launching.`,
35220
+ `"${nodePath}" "${target.serverJs}" >> "${logPath}" 2>&1`,
35218
35221
  ""
35219
35222
  ];
35220
35223
  return lines.join("\r\n");
35221
35224
  }
35225
+ function windowsVbsBody(cmdPath) {
35226
+ return [
35227
+ `' Auto-generated by "ellm-proxy autostart on" (${MARKER}). Disable with "ellm-proxy autostart off".`,
35228
+ `CreateObject("WScript.Shell").Run """${cmdPath}""", 0, False`,
35229
+ ""
35230
+ ].join("\r\n");
35231
+ }
35222
35232
  function darwinBody(nodePath, target) {
35223
35233
  const logPath = join6(target.appDir, "logs", "autostart.log");
35224
35234
  const envEntries = Object.entries(target.env).map(([k, v]) => ` <string>${k}</string>
@@ -35267,9 +35277,13 @@ function linuxBody(nodePath, target) {
35267
35277
  ].join("\n");
35268
35278
  }
35269
35279
  async function windowsOn(nodePath, target) {
35270
- const itemPath = join6(windowsStartupDir(), AUTOSTART_CMD);
35271
- writeFileSync3(itemPath, windowsBody(nodePath, target), "utf-8");
35272
- return itemPath;
35280
+ const startupDir = windowsStartupDir();
35281
+ mkdirSync3(join6(target.appDir, "logs"), { recursive: true });
35282
+ const cmdPath = join6(target.appDir, AUTOSTART_CMD);
35283
+ writeFileSync3(cmdPath, windowsBody(nodePath, target), "utf-8");
35284
+ writeFileSync3(join6(startupDir, AUTOSTART_VBS), `\uFEFF${windowsVbsBody(cmdPath)}`, "utf16le");
35285
+ rmSync2(join6(startupDir, AUTOSTART_CMD), { force: true });
35286
+ return join6(startupDir, AUTOSTART_VBS);
35273
35287
  }
35274
35288
  async function darwinOn(nodePath, target) {
35275
35289
  const itemPath = join6(homedir2(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
@@ -35301,10 +35315,13 @@ async function linuxOn(nodePath, target) {
35301
35315
  return itemPath;
35302
35316
  }
35303
35317
  async function windowsOff() {
35304
- const itemPath = join6(windowsStartupDir(), AUTOSTART_CMD);
35305
- if (!existsSync2(itemPath)) return false;
35306
- rmSync2(itemPath, { force: true });
35307
- return true;
35318
+ const startupDir = windowsStartupDir();
35319
+ const vbsPath = join6(startupDir, AUTOSTART_VBS);
35320
+ const legacyCmd = join6(startupDir, AUTOSTART_CMD);
35321
+ const existed = existsSync2(vbsPath) || existsSync2(legacyCmd);
35322
+ rmSync2(vbsPath, { force: true });
35323
+ rmSync2(legacyCmd, { force: true });
35324
+ return existed;
35308
35325
  }
35309
35326
  async function darwinOff() {
35310
35327
  const itemPath = join6(homedir2(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
@@ -35321,18 +35338,31 @@ async function linuxOff() {
35321
35338
  await runExit("systemctl", ["--user", "daemon-reload"]);
35322
35339
  return true;
35323
35340
  }
35341
+ function readTextDetectingBom(path7) {
35342
+ const buf = readFileSync5(path7);
35343
+ if (buf.length >= 2 && buf[0] === 255 && buf[1] === 254) return buf.toString("utf16le").slice(1);
35344
+ return buf.toString("utf-8");
35345
+ }
35324
35346
  function autostartStatus(appDir) {
35325
35347
  const itemPath = platformItemPath();
35326
35348
  let enabled = false;
35327
35349
  let outdated = false;
35328
35350
  if (itemPath && existsSync2(itemPath)) {
35329
35351
  try {
35330
- const content = readFileSync5(itemPath, "utf-8");
35331
- if (content.includes(MARKER)) enabled = true;
35352
+ if (readTextDetectingBom(itemPath).includes(MARKER)) enabled = true;
35332
35353
  else outdated = true;
35333
35354
  } catch {
35334
35355
  }
35335
35356
  }
35357
+ if (platform8() === "win32" && !enabled) {
35358
+ const legacyCmd = join6(windowsStartupDir(), AUTOSTART_CMD);
35359
+ if (existsSync2(legacyCmd)) {
35360
+ try {
35361
+ if (readTextDetectingBom(legacyCmd).includes(MARKER)) outdated = true;
35362
+ } catch {
35363
+ }
35364
+ }
35365
+ }
35336
35366
  return {
35337
35367
  platform: platform8(),
35338
35368
  enabled,
@@ -35370,7 +35400,7 @@ async function ensureAutostartOnStart(target) {
35370
35400
  if (status.enabled) return;
35371
35401
  if (status.optOut) return;
35372
35402
  const { itemPath } = await enableAutostart(target);
35373
- console.log(status.outdated ? `\u5DF2\u5C06\u5F00\u673A\u81EA\u542F\u9879\u8FC1\u79FB\u4E3A\u76F4\u542F\u6A21\u5F0F: ${itemPath}` : `\u5DF2\u81EA\u52A8\u6CE8\u518C\u5F00\u673A\u81EA\u542F: ${itemPath}`);
35403
+ console.log(status.outdated ? `\u5DF2\u5C06\u5F00\u673A\u81EA\u542F\u9879\u8FC1\u79FB\u4E3A\u65E0\u7A97\u53E3\u6A21\u5F0F: ${itemPath}` : `\u5DF2\u81EA\u52A8\u6CE8\u518C\u5F00\u673A\u81EA\u542F: ${itemPath}`);
35374
35404
  console.log("\u7981\u7528\u65B9\u5F0F: ellm-proxy autostart off \u6216\u7BA1\u7406\u53F0\u8BBE\u7F6E\u9875\u3002");
35375
35405
  } catch (err) {
35376
35406
  console.warn(`\u5F00\u673A\u81EA\u542F\u6CE8\u518C\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u672C\u6B21\u542F\u52A8\uFF09: ${err instanceof Error ? err.message : String(err)}`);
@@ -35678,7 +35708,7 @@ cli.command(
35678
35708
  nodePath: await resolveInterpreter()
35679
35709
  });
35680
35710
  console.log("\u5F00\u673A\u81EA\u542F\u5DF2\u5F00\u542F\uFF08\u767B\u5F55\u65F6\u89E6\u53D1\uFF09\uFF1A");
35681
- console.log(` \u81EA\u542F\u9879 : ${itemPath}\uFF08\u76F4\u63A5\u542F\u52A8\u670D\u52A1\uFF09`);
35711
+ console.log(` \u81EA\u542F\u9879 : ${itemPath}\uFF08\u767B\u5F55\u65F6\u65E0\u7A97\u53E3\u540E\u53F0\u542F\u52A8\uFF09`);
35682
35712
  console.log(" \u7981\u7528\u65B9\u5F0F : ellm-proxy autostart off");
35683
35713
  } else {
35684
35714
  const { removed } = await disableAutostart({ appDir });
package/dist/server.js CHANGED
@@ -20586,6 +20586,7 @@ import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as rea
20586
20586
  import { spawn as spawn2 } from "node:child_process";
20587
20587
  import { homedir, platform } from "node:os";
20588
20588
  import { join as join5 } from "node:path";
20589
+ var AUTOSTART_VBS = "ellm-proxy-autostart.vbs";
20589
20590
  var AUTOSTART_CMD = "ellm-proxy-autostart.cmd";
20590
20591
  var PLIST_LABEL = "com.ellm-proxy.autostart";
20591
20592
  var LINUX_UNIT = "ellm-proxy.service";
@@ -20619,7 +20620,7 @@ function runExit(cmd, args) {
20619
20620
  function platformItemPath() {
20620
20621
  switch (platform()) {
20621
20622
  case "win32":
20622
- return join5(windowsStartupDir(), AUTOSTART_CMD);
20623
+ return join5(windowsStartupDir(), AUTOSTART_VBS);
20623
20624
  case "darwin":
20624
20625
  return join5(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
20625
20626
  case "linux":
@@ -20629,15 +20630,24 @@ function platformItemPath() {
20629
20630
  }
20630
20631
  }
20631
20632
  function windowsBody(nodePath, target) {
20633
+ const logPath = join5(target.appDir, "logs", "autostart.log");
20632
20634
  const lines = [
20633
20635
  "@echo off",
20634
20636
  `rem Auto-generated by "ellm-proxy autostart on" (${MARKER}). Disable with "ellm-proxy autostart off".`,
20635
20637
  ...Object.entries(target.env).map(([k, v]) => `set "${k}=${v}"`),
20636
- `"${nodePath}" "${target.serverJs}" >nul 2>&1`,
20638
+ `>> "${logPath}" echo [%date% %time%] autostart launching.`,
20639
+ `"${nodePath}" "${target.serverJs}" >> "${logPath}" 2>&1`,
20637
20640
  ""
20638
20641
  ];
20639
20642
  return lines.join("\r\n");
20640
20643
  }
20644
+ function windowsVbsBody(cmdPath) {
20645
+ return [
20646
+ `' Auto-generated by "ellm-proxy autostart on" (${MARKER}). Disable with "ellm-proxy autostart off".`,
20647
+ `CreateObject("WScript.Shell").Run """${cmdPath}""", 0, False`,
20648
+ ""
20649
+ ].join("\r\n");
20650
+ }
20641
20651
  function darwinBody(nodePath, target) {
20642
20652
  const logPath = join5(target.appDir, "logs", "autostart.log");
20643
20653
  const envEntries = Object.entries(target.env).map(([k, v]) => ` <string>${k}</string>
@@ -20686,9 +20696,13 @@ function linuxBody(nodePath, target) {
20686
20696
  ].join("\n");
20687
20697
  }
20688
20698
  async function windowsOn(nodePath, target) {
20689
- const itemPath = join5(windowsStartupDir(), AUTOSTART_CMD);
20690
- writeFileSync5(itemPath, windowsBody(nodePath, target), "utf-8");
20691
- return itemPath;
20699
+ const startupDir = windowsStartupDir();
20700
+ mkdirSync4(join5(target.appDir, "logs"), { recursive: true });
20701
+ const cmdPath = join5(target.appDir, AUTOSTART_CMD);
20702
+ writeFileSync5(cmdPath, windowsBody(nodePath, target), "utf-8");
20703
+ writeFileSync5(join5(startupDir, AUTOSTART_VBS), `\uFEFF${windowsVbsBody(cmdPath)}`, "utf16le");
20704
+ rmSync2(join5(startupDir, AUTOSTART_CMD), { force: true });
20705
+ return join5(startupDir, AUTOSTART_VBS);
20692
20706
  }
20693
20707
  async function darwinOn(nodePath, target) {
20694
20708
  const itemPath = join5(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
@@ -20720,10 +20734,13 @@ async function linuxOn(nodePath, target) {
20720
20734
  return itemPath;
20721
20735
  }
20722
20736
  async function windowsOff() {
20723
- const itemPath = join5(windowsStartupDir(), AUTOSTART_CMD);
20724
- if (!existsSync7(itemPath)) return false;
20725
- rmSync2(itemPath, { force: true });
20726
- return true;
20737
+ const startupDir = windowsStartupDir();
20738
+ const vbsPath = join5(startupDir, AUTOSTART_VBS);
20739
+ const legacyCmd = join5(startupDir, AUTOSTART_CMD);
20740
+ const existed = existsSync7(vbsPath) || existsSync7(legacyCmd);
20741
+ rmSync2(vbsPath, { force: true });
20742
+ rmSync2(legacyCmd, { force: true });
20743
+ return existed;
20727
20744
  }
20728
20745
  async function darwinOff() {
20729
20746
  const itemPath = join5(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
@@ -20740,18 +20757,31 @@ async function linuxOff() {
20740
20757
  await runExit("systemctl", ["--user", "daemon-reload"]);
20741
20758
  return true;
20742
20759
  }
20760
+ function readTextDetectingBom(path) {
20761
+ const buf = readFileSync6(path);
20762
+ if (buf.length >= 2 && buf[0] === 255 && buf[1] === 254) return buf.toString("utf16le").slice(1);
20763
+ return buf.toString("utf-8");
20764
+ }
20743
20765
  function autostartStatus(appDir) {
20744
20766
  const itemPath = platformItemPath();
20745
20767
  let enabled = false;
20746
20768
  let outdated = false;
20747
20769
  if (itemPath && existsSync7(itemPath)) {
20748
20770
  try {
20749
- const content = readFileSync6(itemPath, "utf-8");
20750
- if (content.includes(MARKER)) enabled = true;
20771
+ if (readTextDetectingBom(itemPath).includes(MARKER)) enabled = true;
20751
20772
  else outdated = true;
20752
20773
  } catch {
20753
20774
  }
20754
20775
  }
20776
+ if (platform() === "win32" && !enabled) {
20777
+ const legacyCmd = join5(windowsStartupDir(), AUTOSTART_CMD);
20778
+ if (existsSync7(legacyCmd)) {
20779
+ try {
20780
+ if (readTextDetectingBom(legacyCmd).includes(MARKER)) outdated = true;
20781
+ } catch {
20782
+ }
20783
+ }
20784
+ }
20755
20785
  return {
20756
20786
  platform: platform(),
20757
20787
  enabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ellm-proxy",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Self-hosted LLM gateway with admin web UI (single process, built-in process management)",
5
5
  "license": "MIT",
6
6
  "type": "module",