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

Function resolveDaemonProgram

apps/kimi-code/src/cli/sub/server/daemon.ts:183–195  ·  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

181 * must re-exec `process.execPath` itself.
182 */
183export function resolveDaemonProgram(
184 argv: readonly string[] = process.argv,
185 cwd: string = process.cwd(),
186 execPath: string = process.execPath,
187 isSea: boolean = detectSea(),
188): string {
189 // In a SEA binary `argv[1]` is not a script path, so resolving it against
190 // `cwd` would produce a bogus path (e.g. `<cwd>/kimi`) and crash the spawn
191 // with ENOENT. Always re-exec the binary itself.
192 if (isSea) return execPath;
193 const candidate = argv[1] === 'server' ? execPath : (argv[1] ?? execPath);
194 return isAbsolute(candidate) ? candidate : resolve(cwd, candidate);
195}
196
197interface SpawnDaemonChildOptions {
198 host?: string;

Callers 2

server.test.tsFile · 0.85
spawnDaemonChildFunction · 0.85

Calls 3

cwdMethod · 0.80
detectSeaFunction · 0.70
resolveFunction · 0.50

Tested by

no test coverage detected