@skylandnpm/octopus-proxy 0.1.6 → 0.1.8

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.
@@ -14438,6 +14438,7 @@ var Runtime = class {
14438
14438
  password = "";
14439
14439
  version = "";
14440
14440
  state = "stopped";
14441
+ lastError = "";
14441
14442
  async identity(pid) {
14442
14443
  try {
14443
14444
  return (await promisify2(execFile2)("ps", ["-p", String(pid), "-o", "lstart=", "-o", "command="])).stdout.trim();
@@ -14493,13 +14494,30 @@ var Runtime = class {
14493
14494
  }
14494
14495
  }
14495
14496
  async status() {
14496
- return { tool: this.kind, mode: this.config.tool.mode, state: this.state, healthy: await this.health(), version: this.version, pid: this.owned?.pid, attempts: this.attempts };
14497
+ const healthy = await this.health();
14498
+ return {
14499
+ tool: this.kind,
14500
+ mode: this.config.tool.mode,
14501
+ state: this.state,
14502
+ healthy,
14503
+ version: this.version,
14504
+ pid: this.owned?.pid,
14505
+ attempts: this.attempts,
14506
+ ...healthy ? {} : { error: this.lastError || `OpenCode at ${this.config.tool.baseUrl} did not pass its health check` }
14507
+ };
14497
14508
  }
14498
14509
  start() {
14499
14510
  if (this.detached) throw new Error("Runtime supervisor is detached");
14500
14511
  if (this.config.tool.mode !== "managed") throw new Error("External instance is not owned; configure managed mode after stopping it explicitly");
14501
14512
  if (this.starting) return this.starting;
14502
- this.starting = this.startOwned().finally(() => {
14513
+ this.starting = this.startOwned().then((result) => {
14514
+ this.lastError = "";
14515
+ return result;
14516
+ }).catch((error) => {
14517
+ this.lastError = error instanceof Error ? error.message : String(error);
14518
+ if (this.wanted && this.state !== "unowned") this.state = "failed";
14519
+ throw error;
14520
+ }).finally(() => {
14503
14521
  this.starting = void 0;
14504
14522
  });
14505
14523
  return this.starting;
@@ -14507,6 +14525,7 @@ var Runtime = class {
14507
14525
  exited() {
14508
14526
  if (this.detached) return;
14509
14527
  this.state = this.wanted ? "failed" : "stopped";
14528
+ if (this.wanted && !this.lastError) this.lastError = "OpenCode process exited unexpectedly";
14510
14529
  void this.save();
14511
14530
  if (this.wanted && this.attempts < 5) {
14512
14531
  const delay = Math.min(3e4, 1e3 * 2 ** this.attempts++);
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  runDaemon,
18
18
  supportedPlatform,
19
19
  systemdUnitPath
20
- } from "./chunk-JWIM27KY.js";
20
+ } from "./chunk-2SGNDVCO.js";
21
21
 
22
22
  // src/cli.ts
23
23
  import { spawn } from "node:child_process";
@@ -288,7 +288,7 @@ async function installService(opts) {
288
288
  await systemdInstall();
289
289
  } else await systemdStart();
290
290
  }
291
- return { serviceFile: path, changed, nodePath: def.nodePath, warning };
291
+ return { serviceFile: path, changed, alreadyInstalled: existing !== null, nodePath: def.nodePath, warning };
292
292
  }
293
293
  async function uninstallService() {
294
294
  const path = serviceFilePath();
@@ -806,6 +806,7 @@ try {
806
806
  case "install": {
807
807
  const outcome = await installService({ configPath, nodePath: flags["--node-path"], force: flags["--force"] === "true" });
808
808
  console.log(outcome.changed ? `\u5DF2\u5B89\u88C5\u5E76\u542F\u52A8\u670D\u52A1\uFF1A${outcome.serviceFile}` : `\u670D\u52A1\u5B9A\u4E49\u4E0E\u914D\u7F6E\u4E00\u81F4\uFF0C\u5DF2\u786E\u4FDD\u8FD0\u884C\uFF1A${outcome.serviceFile}`);
809
+ if (outcome.alreadyInstalled && flags["--force"] !== "true") console.log("\u670D\u52A1\u5DF2\u5B89\u88C5\uFF1B\u5982\u9700\u5F3A\u5236\u91CD\u5199\u670D\u52A1\u5B9A\u4E49\u5E76\u91CD\u542F\uFF0C\u8FD0\u884C octopus-proxy install --force\uFF08\u4F7F\u7528\u81EA\u5B9A\u4E49\u914D\u7F6E\u65F6\u8BF7\u5E26\u4E0A\u76F8\u540C\u7684 --config\uFF09");
809
810
  console.log(`node\uFF1A${outcome.nodePath}`);
810
811
  if (outcome.warning) console.log(`\u6CE8\u610F\uFF1A${outcome.warning}`);
811
812
  console.log(`\u65E5\u5FD7\uFF1A${logLocationHint()}\uFF08octopus-proxy logs \u67E5\u770B\uFF09`);
package/dist/main.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  ConfigError,
4
4
  runDaemon
5
- } from "./chunk-JWIM27KY.js";
5
+ } from "./chunk-2SGNDVCO.js";
6
6
 
7
7
  // src/main.ts
8
8
  runDaemon(process.env.OCTOPUS_PROXY_CONFIG ?? "proxy.json").catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skylandnpm/octopus-proxy",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "Octopus host proxy: OpenCode, Codex, ZCode and Pi adapters with service installer CLI",
6
6
  "bin": {