| 15 | const DOCKER_HINT = 'Install Docker Desktop (macOS) from https://www.docker.com/products/docker-desktop/ and ensure the daemon is running.'; |
| 16 | |
| 17 | async function docker(args: string[], timeoutMs = 120_000): Promise<ToolResult> { |
| 18 | const r = await runProcess('docker', args, { timeoutMs }); |
| 19 | if (r.notFound) return { content: notInstalledMessage('docker', DOCKER_HINT), isError: true }; |
| 20 | if (r.timedOut) return { content: `docker ${args[0]} timed out after ${Math.round(timeoutMs / 1000)}s.`, isError: true }; |
| 21 | const out = [r.stdout.trim(), r.stderr.trim()].filter(Boolean).join('\n'); |
| 22 | return { content: out || '(no output)', isError: !r.ok }; |
| 23 | } |
| 24 | |
| 25 | // ---- docker_ps ---- |
| 26 | const PsArgs = z.object({ all: z.boolean().optional().describe('Include stopped containers (docker ps -a). Default false.') }); |