@kenhkl/agent-moss 0.8.5 → 0.9.0

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/cli.js CHANGED
@@ -3606,7 +3606,7 @@ var require_bindings = __commonJS({
3606
3606
  init_esm_shims();
3607
3607
  var fs4 = __require("fs");
3608
3608
  var path3 = __require("path");
3609
- var fileURLToPath6 = require_file_uri_to_path();
3609
+ var fileURLToPath7 = require_file_uri_to_path();
3610
3610
  var join6 = path3.join;
3611
3611
  var dirname6 = path3.dirname;
3612
3612
  var exists = fs4.accessSync && function(path4) {
@@ -3718,7 +3718,7 @@ var require_bindings = __commonJS({
3718
3718
  Error.stackTraceLimit = origSTL;
3719
3719
  var fileSchema = "file://";
3720
3720
  if (fileName.indexOf(fileSchema) === 0) {
3721
- fileName = fileURLToPath6(fileName);
3721
+ fileName = fileURLToPath7(fileName);
3722
3722
  }
3723
3723
  return fileName;
3724
3724
  };
@@ -4749,16 +4749,17 @@ async function startServer(host = "127.0.0.1", port = 9090) {
4749
4749
  const app = createApp();
4750
4750
  return {
4751
4751
  port: actualPort,
4752
- serve: () => {
4752
+ serve: async () => {
4753
4753
  console.log(`AgentMoss HTTP server on ${host}:${actualPort}`);
4754
- import("@hono/node-server").then(({ serve: honoServe }) => {
4755
- honoServe({ fetch: app.fetch, hostname: host, port: actualPort });
4756
- });
4754
+ const { serve: honoServe } = await import("@hono/node-server");
4755
+ honoServe({ fetch: app.fetch, hostname: host, port: actualPort });
4757
4756
  }
4758
4757
  };
4759
4758
  }
4760
4759
 
4761
4760
  // src/cli.ts
4761
+ import { fileURLToPath as fileURLToPath6 } from "url";
4762
+ import { realpathSync } from "fs";
4762
4763
  function printHelp() {
4763
4764
  console.log(`AgentMoss security analysis engine (TypeScript v${version})
4764
4765
 
@@ -4840,7 +4841,7 @@ async function main() {
4840
4841
  if (port === 0) port = 9090;
4841
4842
  const server = await startServer(host, port);
4842
4843
  console.log(`Listening on http://${host}:${server.port}`);
4843
- server.serve();
4844
+ await server.serve();
4844
4845
  break;
4845
4846
  }
4846
4847
  case "install": {
@@ -4848,7 +4849,7 @@ async function main() {
4848
4849
  const { execSync } = await import("child_process");
4849
4850
  const fs4 = await import("fs");
4850
4851
  const path3 = await import("path");
4851
- const { fileURLToPath: fileURLToPath6 } = await import("url");
4852
+ const { fileURLToPath: fileURLToPath7 } = await import("url");
4852
4853
  if (process.getuid?.() !== 0) {
4853
4854
  try {
4854
4855
  execSync("sudo -n true", { stdio: "ignore", timeout: 5e3 });
@@ -4863,7 +4864,7 @@ async function main() {
4863
4864
  execSync(sudoArgs.join(" "), { stdio: "inherit" });
4864
4865
  process.exit(0);
4865
4866
  }
4866
- const __filename5 = fileURLToPath6(import.meta.url);
4867
+ const __filename5 = fileURLToPath7(import.meta.url);
4867
4868
  const __dirname6 = path3.dirname(__filename5);
4868
4869
  let srcPath = path3.join(__dirname6, "data", "agent_moss.service");
4869
4870
  if (!fs4.existsSync(srcPath)) {
@@ -5002,8 +5003,22 @@ async function main() {
5002
5003
  process.exit(1);
5003
5004
  }
5004
5005
  }
5005
- main().catch((err) => {
5006
- console.error("Fatal error:", err);
5007
- process.exit(1);
5008
- });
5006
+ var isMain = (() => {
5007
+ try {
5008
+ if (!process.argv[1]) return false;
5009
+ const thisFile = realpathSync(fileURLToPath6(import.meta.url));
5010
+ const argv1 = realpathSync(
5011
+ process.argv[1].startsWith("file://") ? fileURLToPath6(process.argv[1]) : process.argv[1]
5012
+ );
5013
+ return thisFile === argv1;
5014
+ } catch {
5015
+ return false;
5016
+ }
5017
+ })();
5018
+ if (isMain) {
5019
+ main().catch((err) => {
5020
+ console.error("Fatal error:", err);
5021
+ process.exit(1);
5022
+ });
5023
+ }
5009
5024
  //# sourceMappingURL=cli.js.map