| 216 | |
| 217 | async function engineRunning(): Promise<boolean> { |
| 218 | return fetch(`${ENGINE}/api/health`) |
| 219 | .then((r) => r.ok) |
| 220 | .catch(() => false); |
| 221 | } |
| 222 | |
| 223 | async function run(prompt: string): Promise<void> { |
| 224 | if (!prompt) throw new Error('usage: kild run <prompt…>'); |
| 225 | // If the engine is up, run THROUGH it so the session shows up in UI clients; |
| 226 | // otherwise run the agent in-process so the CLI works standalone. |
| 227 | return (await engineRunning()) ? runViaEngine(prompt) : runViaAgent(prompt); |
| 228 | } |
| 229 | |
| 230 | /** `kild agents` — list live agents. */ |
| 231 | async function agentsList(): Promise<void> { |