MCPcopy Create free account
hub / github.com/Wirasm/kild / onMessage

Function onMessage

engine/src/server.ts:201–218  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

199
200const worktreesInUse = (): Set<string> =>
201 new Set(
202 agentManager
203 .list()
204 .map((s) => s.worktree)
205 .filter((w): w is string => typeof w === 'string'),
206 );
207
208// ── Open in OS ────────────────────────────────────────────────────────────────
209// Reveal a worktree path in the OS file browser. Only paths under the worktree root
210// are allowed — the engine is loopback-only but must never shell `open` on an
211// arbitrary path. Keeps UI clients pure-web (no Tauri opener API needed).
212app.post('/api/open', async (c) => {
213 const { path: target } = (await jsonBody(c)) as { path?: string };
214 const root = worktreesRoot();
215 const resolved = path.resolve(target ?? '');
216 if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`)) {
217 return c.json({ error: 'path is not under the worktree root' }, 403);
218 }
219 try {
220 const opener = process.platform === 'darwin' ? 'open' : 'xdg-open';
221 await execFile(opener, [resolved]);

Callers

nothing calls this directly

Calls 5

parseClientMessageFunction · 0.85
openMethod · 0.80
postFromHumanMethod · 0.80
addParticipantMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected