MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / resolveSupervisorProgram

Function resolveSupervisorProgram

packages/server/src/svc/program.ts:32–45  ·  view source on GitHub ↗
(
  argv: readonly string[] = process.argv,
  cwd: string = process.cwd(),
  execPath: string = process.execPath,
  isSea: boolean = detectSea(),
)

Source from the content-addressed store, hash-verified

30}
31
32export function resolveSupervisorProgram(
33 argv: readonly string[] = process.argv,
34 cwd: string = process.cwd(),
35 execPath: string = process.execPath,
36 isSea: boolean = detectSea(),
37): string {
38 // In a SEA binary `argv[1]` is the invoked command name (e.g. `kimi`) or the
39 // first user argument — never a script path — so the re-exec target is always
40 // the binary itself. Resolving it against `cwd` would produce a bogus path
41 // (e.g. `<cwd>/kimi`) and crash the spawn with ENOENT.
42 if (isSea) return execPath;
43 const candidate = argv[1] === 'server' ? execPath : (argv[1] ?? execPath);
44 return isAbsolute(candidate) ? candidate : resolve(cwd, candidate);
45}

Callers 4

systemd.tsFile · 0.90
schtasks.tsFile · 0.90
launchd.tsFile · 0.90
launchd.test.tsFile · 0.85

Calls 3

cwdMethod · 0.80
detectSeaFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected