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

Function install

packages/server/src/svc/launchd.ts:62–97  ·  view source on GitHub ↗
(args: InstallArgs)

Source from the content-addressed store, hash-verified

60 const deps: LaunchdManagerDeps = { ...DEFAULT_DEPS, ...overrides };
61
62 async function install(args: InstallArgs): Promise<InstallResult> {
63 const plistPath = deps.plistPath();
64 const logPath = deps.logPath();
65 const program = deps.resolveProgram();
66 const plan = buildInstallPlan({ ...args, program, logPath });
67
68 const alreadyInstalled = existsSync(plistPath);
69 if (alreadyInstalled && args.force !== true) {
70 return {
71 status: 'already-installed',
72 message: `LaunchAgent already installed at ${plistPath}. Rerun with --force to replace it.`,
73 plistPath,
74 };
75 }
76
77 if (alreadyInstalled) {
78
79 await bestEffortBootout(deps);
80 }
81
82 writePlist(plistPath, plan, logPath);
83 writeInstallPlan(plan);
84
85 const bootstrap = await deps.execLaunchctl(['bootstrap', deps.guiDomain(), plistPath]);
86 if (bootstrap.code !== 0 && !isAlreadyLoaded(bootstrap)) {
87 throw new Error(
88 `launchctl bootstrap failed (code ${bootstrap.code}): ${detail(bootstrap) ?? 'unknown error'}`,
89 );
90 }
91
92 return {
93 status: alreadyInstalled ? 'replaced' : 'installed',
94 message: `Kimi server LaunchAgent ${alreadyInstalled ? 'replaced' : 'installed'} at ${plistPath} (port ${plan.port}).`,
95 plistPath,
96 };
97 }
98
99 async function uninstall(): Promise<LifecycleResult> {
100 const plistPath = deps.plistPath();

Callers

nothing calls this directly

Calls 11

buildInstallPlanFunction · 0.90
writeInstallPlanFunction · 0.90
bestEffortBootoutFunction · 0.85
writePlistFunction · 0.85
isAlreadyLoadedFunction · 0.85
plistPathMethod · 0.80
execLaunchctlMethod · 0.80
guiDomainMethod · 0.80
detailFunction · 0.70
logPathMethod · 0.65
resolveProgramMethod · 0.65

Tested by

no test coverage detected