| 137 | description = 'Drive docker compose: up (-d), down, ps, logs, build, restart. ps/logs are read-only; up/down/build/restart mutate and are permission-gated. Uses the modern `docker compose` subcommand.'; |
| 138 | isReadOnly = false; isDestructive = true; argsSchema = ComposeArgs; |
| 139 | async execute(a: z.infer<typeof ComposeArgs>): Promise<ToolResult> { |
| 140 | const args = ['compose']; |
| 141 | if (a.file) args.push('-f', a.file); |
| 142 | switch (a.action) { |
| 143 | case 'up': args.push('up', '-d'); if (a.service) args.push(a.service); break; |
| 144 | case 'down': args.push('down'); break; |
| 145 | case 'ps': args.push('ps'); break; |
| 146 | case 'logs': args.push('logs', '--tail', String(a.tail ?? 200)); if (a.service) args.push(a.service); break; |
| 147 | case 'build': args.push('build'); if (a.service) args.push(a.service); break; |
| 148 | case 'restart': args.push('restart'); if (a.service) args.push(a.service); break; |
| 149 | } |
| 150 | return docker(args, (a.timeout_seconds ?? 300) * 1000); |
| 151 | } |
| 152 | } |