@procedures/docker 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +40 -3
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/index.js.map +1 -1
  8. package/dist/module.d.ts +4 -1
  9. package/dist/module.d.ts.map +1 -1
  10. package/dist/module.js +252 -1
  11. package/dist/module.js.map +1 -1
  12. package/dist/procedures/docker/compose/build.d.ts +12 -0
  13. package/dist/procedures/docker/compose/build.d.ts.map +1 -0
  14. package/dist/procedures/docker/compose/build.js +22 -0
  15. package/dist/procedures/docker/compose/build.js.map +1 -0
  16. package/dist/procedures/docker/compose/logs.d.ts +13 -0
  17. package/dist/procedures/docker/compose/logs.d.ts.map +1 -0
  18. package/dist/procedures/docker/compose/logs.js +23 -0
  19. package/dist/procedures/docker/compose/logs.js.map +1 -0
  20. package/dist/procedures/docker/compose/ps.d.ts +12 -0
  21. package/dist/procedures/docker/compose/ps.d.ts.map +1 -0
  22. package/dist/procedures/docker/compose/ps.js +19 -0
  23. package/dist/procedures/docker/compose/ps.js.map +1 -0
  24. package/dist/procedures/docker/compose/restart.d.ts +12 -0
  25. package/dist/procedures/docker/compose/restart.d.ts.map +1 -0
  26. package/dist/procedures/docker/compose/restart.js +17 -0
  27. package/dist/procedures/docker/compose/restart.js.map +1 -0
  28. package/dist/procedures/docker/exec.d.ts.map +1 -1
  29. package/dist/procedures/docker/exec.js +7 -2
  30. package/dist/procedures/docker/exec.js.map +1 -1
  31. package/dist/procedures/docker/images.d.ts +12 -0
  32. package/dist/procedures/docker/images.d.ts.map +1 -0
  33. package/dist/procedures/docker/images.js +22 -0
  34. package/dist/procedures/docker/images.js.map +1 -0
  35. package/dist/procedures/docker/index.d.ts +15 -0
  36. package/dist/procedures/docker/index.d.ts.map +1 -1
  37. package/dist/procedures/docker/index.js +15 -0
  38. package/dist/procedures/docker/index.js.map +1 -1
  39. package/dist/procedures/docker/inspect.d.ts +13 -0
  40. package/dist/procedures/docker/inspect.d.ts.map +1 -0
  41. package/dist/procedures/docker/inspect.js +30 -0
  42. package/dist/procedures/docker/inspect.js.map +1 -0
  43. package/dist/procedures/docker/network/create.d.ts +13 -0
  44. package/dist/procedures/docker/network/create.d.ts.map +1 -0
  45. package/dist/procedures/docker/network/create.js +21 -0
  46. package/dist/procedures/docker/network/create.js.map +1 -0
  47. package/dist/procedures/docker/network/list.d.ts +12 -0
  48. package/dist/procedures/docker/network/list.d.ts.map +1 -0
  49. package/dist/procedures/docker/network/list.js +18 -0
  50. package/dist/procedures/docker/network/list.js.map +1 -0
  51. package/dist/procedures/docker/network/remove.d.ts +12 -0
  52. package/dist/procedures/docker/network/remove.d.ts.map +1 -0
  53. package/dist/procedures/docker/network/remove.js +14 -0
  54. package/dist/procedures/docker/network/remove.js.map +1 -0
  55. package/dist/procedures/docker/prune.d.ts +14 -0
  56. package/dist/procedures/docker/prune.d.ts.map +1 -0
  57. package/dist/procedures/docker/prune.js +30 -0
  58. package/dist/procedures/docker/prune.js.map +1 -0
  59. package/dist/procedures/docker/push.d.ts +13 -0
  60. package/dist/procedures/docker/push.d.ts.map +1 -0
  61. package/dist/procedures/docker/push.js +18 -0
  62. package/dist/procedures/docker/push.js.map +1 -0
  63. package/dist/procedures/docker/run.d.ts.map +1 -1
  64. package/dist/procedures/docker/run.js +3 -5
  65. package/dist/procedures/docker/run.js.map +1 -1
  66. package/dist/procedures/docker/shared.d.ts +16 -0
  67. package/dist/procedures/docker/shared.d.ts.map +1 -1
  68. package/dist/procedures/docker/shared.js +24 -0
  69. package/dist/procedures/docker/shared.js.map +1 -1
  70. package/dist/procedures/docker/tag.d.ts +12 -0
  71. package/dist/procedures/docker/tag.d.ts.map +1 -0
  72. package/dist/procedures/docker/tag.js +14 -0
  73. package/dist/procedures/docker/tag.js.map +1 -0
  74. package/dist/procedures/docker/volume/create.d.ts +13 -0
  75. package/dist/procedures/docker/volume/create.d.ts.map +1 -0
  76. package/dist/procedures/docker/volume/create.js +20 -0
  77. package/dist/procedures/docker/volume/create.js.map +1 -0
  78. package/dist/procedures/docker/volume/list.d.ts +12 -0
  79. package/dist/procedures/docker/volume/list.d.ts.map +1 -0
  80. package/dist/procedures/docker/volume/list.js +18 -0
  81. package/dist/procedures/docker/volume/list.js.map +1 -0
  82. package/dist/procedures/docker/volume/remove.d.ts +13 -0
  83. package/dist/procedures/docker/volume/remove.d.ts.map +1 -0
  84. package/dist/procedures/docker/volume/remove.js +18 -0
  85. package/dist/procedures/docker/volume/remove.js.map +1 -0
  86. package/dist/types.d.ts +170 -1
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/types.js +180 -4
  89. package/dist/types.js.map +1 -1
  90. package/package.json +4 -4
  91. package/src/index.ts +46 -0
  92. package/src/module.ts +329 -1
  93. package/src/procedures/docker/compose/build.ts +23 -0
  94. package/src/procedures/docker/compose/logs.ts +23 -0
  95. package/src/procedures/docker/compose/ps.ts +20 -0
  96. package/src/procedures/docker/compose/restart.ts +19 -0
  97. package/src/procedures/docker/exec.ts +7 -2
  98. package/src/procedures/docker/images.ts +21 -0
  99. package/src/procedures/docker/index.ts +15 -0
  100. package/src/procedures/docker/inspect.ts +31 -0
  101. package/src/procedures/docker/network/create.ts +22 -0
  102. package/src/procedures/docker/network/list.ts +19 -0
  103. package/src/procedures/docker/network/remove.ts +17 -0
  104. package/src/procedures/docker/prune.ts +30 -0
  105. package/src/procedures/docker/push.ts +20 -0
  106. package/src/procedures/docker/run.ts +3 -5
  107. package/src/procedures/docker/shared.ts +28 -0
  108. package/src/procedures/docker/tag.ts +17 -0
  109. package/src/procedures/docker/volume/create.ts +21 -0
  110. package/src/procedures/docker/volume/list.ts +19 -0
  111. package/src/procedures/docker/volume/remove.ts +20 -0
  112. package/src/types.ts +360 -5
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { ProcedureContext } from "@procedures/client";
8
- import { dockerArg, runDocker, words } from "./shared.js";
8
+ import { commandWords, dockerArg, runDocker } from "./shared.js";
9
9
  import type { DockerRunInput, DockerCommandOutput } from "../../types.js";
10
10
 
11
11
  /**
@@ -56,10 +56,8 @@ export async function dockerRun(
56
56
  // Add image
57
57
  args.push(dockerArg("image", input.image));
58
58
 
59
- // Add command if specified
60
- if (input.command) {
61
- args.push(...words(input.command));
62
- }
59
+ // Add the command: args as they are, or command split at whitespace
60
+ args.push(...commandWords(input));
63
61
  return runDocker(args, input, ctx);
64
62
  }
65
63
  }
@@ -26,6 +26,34 @@ export function words(command: string): string[] {
26
26
  return command.trim().split(/\s+/).filter((word) => word.length > 0);
27
27
  }
28
28
 
29
+ /**
30
+ * The command of docker.run or docker.exec: `args` as they are, or `command` split at whitespace.
31
+ * R32 found that `command` cannot carry an argument with a space, so R41 added `args`. The two
32
+ * together are an error. Docker reads no option after the image or the container, so an
33
+ * argument that starts with "-" goes to the command.
34
+ */
35
+ export function commandWords(input: { command?: string | undefined; args?: string[] | undefined }): string[] {
36
+ if (input.command !== undefined && input.args !== undefined) {
37
+ throw new Error("Give command or args, not both");
38
+ }
39
+ return input.args ?? (input.command !== undefined ? words(input.command) : []);
40
+ }
41
+
42
+ /** The start of a compose command: `compose`, the compose file, and the subcommand. */
43
+ export function composeArgs(file: string | undefined, subcommand: string): string[] {
44
+ return ["compose", ...(file ? ["-f", file] : []), subcommand];
45
+ }
46
+
47
+ /** The services of a compose command, after its options. */
48
+ export function serviceArgs(services: string[] | undefined): string[] {
49
+ return (services ?? []).map((service) => dockerArg("service", service));
50
+ }
51
+
52
+ /** `--label key=value` for each label. */
53
+ export function labelArgs(labels: Record<string, string> | undefined): string[] {
54
+ return Object.entries(labels ?? {}).flatMap(([key, value]) => ["--label", `${key}=${value}`]);
55
+ }
56
+
29
57
  /** This function runs `docker <args>` and gives its result. It does not throw. */
30
58
  export async function runDocker(
31
59
  args: string[],
@@ -0,0 +1,17 @@
1
+ /**
2
+ * docker.tag procedure
3
+ *
4
+ * Give an image another name (roadmap R41). An image that had the target name loses it.
5
+ */
6
+
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import { dockerArg, runDocker } from "./shared.js";
9
+ import type { DockerTagInput, DockerTagOutput } from "../../types.js";
10
+
11
+ /**
12
+ * Give an image another name
13
+ */
14
+ export async function dockerTag(input: DockerTagInput, ctx: ProcedureContext): Promise<DockerTagOutput> {
15
+ const args = ["tag", dockerArg("source", input.source), dockerArg("target", input.target)];
16
+ return runDocker(args, input, ctx);
17
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * docker.volume.create procedure
3
+ *
4
+ * Create a volume (roadmap R41). Docker keeps a volume that exists: a second call with the same
5
+ * name changes nothing. The output is the name of the volume.
6
+ */
7
+
8
+ import type { ProcedureContext } from "@procedures/client";
9
+ import { dockerArg, labelArgs, runDocker } from "../shared.js";
10
+ import type { DockerVolumeCreateInput, DockerVolumeCreateOutput } from "../../../types.js";
11
+
12
+ /**
13
+ * Create a volume
14
+ */
15
+ export async function dockerVolumeCreate(input: DockerVolumeCreateInput, ctx: ProcedureContext): Promise<DockerVolumeCreateOutput> {
16
+ const args = ["volume", "create"];
17
+ if (input.driver) args.push("--driver", input.driver);
18
+ args.push(...labelArgs(input.labels));
19
+ if (input.name) args.push(dockerArg("volume", input.name));
20
+ return runDocker(args, input, ctx);
21
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * docker.volume.list procedure
3
+ *
4
+ * List volumes (roadmap R41).
5
+ */
6
+
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import { runDocker } from "../shared.js";
9
+ import type { DockerVolumeListInput, DockerVolumeListOutput } from "../../../types.js";
10
+
11
+ /**
12
+ * List volumes
13
+ */
14
+ export async function dockerVolumeList(input: DockerVolumeListInput, ctx: ProcedureContext): Promise<DockerVolumeListOutput> {
15
+ const args = ["volume", "ls"];
16
+ if (input.filter) args.push("--filter", input.filter);
17
+ if (input.format) args.push("--format", input.format);
18
+ return runDocker(args, input, ctx);
19
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * docker.volume.remove procedure
3
+ *
4
+ * Remove volumes (roadmap R41). The data of a removed volume is lost. Docker refuses a volume
5
+ * that a container uses.
6
+ */
7
+
8
+ import type { ProcedureContext } from "@procedures/client";
9
+ import { dockerArg, runDocker } from "../shared.js";
10
+ import type { DockerVolumeRemoveInput, DockerVolumeRemoveOutput } from "../../../types.js";
11
+
12
+ /**
13
+ * Remove volumes
14
+ */
15
+ export async function dockerVolumeRemove(input: DockerVolumeRemoveInput, ctx: ProcedureContext): Promise<DockerVolumeRemoveOutput> {
16
+ const args = ["volume", "rm"];
17
+ if (input.force) args.push("--force");
18
+ args.push(...input.volumes.map((volume) => dockerArg("volume", volume)));
19
+ return runDocker(args, input, ctx);
20
+ }
package/src/types.ts CHANGED
@@ -77,6 +77,7 @@ export const DockerRunInputSchema: z.ZodObject<{
77
77
  detach: z.ZodOptional<z.ZodBoolean>;
78
78
  rm: z.ZodOptional<z.ZodBoolean>;
79
79
  command: z.ZodOptional<z.ZodString>;
80
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
80
81
  cwd: z.ZodOptional<z.ZodString>;
81
82
  timeout: z.ZodOptional<z.ZodNumber>;
82
83
  }> = z.object({
@@ -94,8 +95,10 @@ export const DockerRunInputSchema: z.ZodObject<{
94
95
  detach: z.boolean().optional().describe("Run in detached mode"),
95
96
  /** Automatically remove container when it exits */
96
97
  rm: z.boolean().optional().describe("Automatically remove container when it exits"),
97
- /** Command to run in container */
98
- command: z.string().optional().describe("Command to run in container"),
98
+ /** Command to run in container: split at whitespace, so it cannot hold quoted text */
99
+ command: z.string().optional().describe("Command to run in container, split at whitespace. For an argument with spaces, use args"),
100
+ /** The command as a list: each item is one argument. It replaces `command` (roadmap R41). */
101
+ args: z.array(z.string()).optional().describe("The command as a list of arguments, each one as it is (not with command)"),
99
102
  /** Working directory */
100
103
  cwd: z.string().optional().describe("Working directory"),
101
104
  /** Timeout in milliseconds */
@@ -163,7 +166,8 @@ export type DockerPullInput = z.infer<typeof DockerPullInputSchema>;
163
166
 
164
167
  export const DockerExecInputSchema: z.ZodObject<{
165
168
  container: z.ZodString;
166
- command: z.ZodString;
169
+ command: z.ZodOptional<z.ZodString>;
170
+ args: z.ZodOptional<z.ZodArray<z.ZodString>>;
167
171
  interactive: z.ZodOptional<z.ZodBoolean>;
168
172
  tty: z.ZodOptional<z.ZodBoolean>;
169
173
  workdir: z.ZodOptional<z.ZodString>;
@@ -173,8 +177,10 @@ export const DockerExecInputSchema: z.ZodObject<{
173
177
  }> = z.object({
174
178
  /** Container name or ID */
175
179
  container: z.string().describe("Container name or ID"),
176
- /** Command to execute */
177
- command: z.string().describe("Command to execute"),
180
+ /** Command to execute: split at whitespace, so it cannot hold quoted text */
181
+ command: z.string().optional().describe("Command to execute, split at whitespace. For an argument with spaces, use args"),
182
+ /** The command as a list: each item is one argument. Give `command` or `args` (roadmap R41). */
183
+ args: z.array(z.string()).optional().describe("The command as a list of arguments, each one as it is (not with command)"),
178
184
  /** Run interactively */
179
185
  interactive: z.boolean().optional().describe("Run interactively"),
180
186
  /** Allocate a TTY */
@@ -349,3 +355,352 @@ export const DockerComposeDownInputSchema: z.ZodObject<{
349
355
  });
350
356
 
351
357
  export type DockerComposeDownInput = z.infer<typeof DockerComposeDownInputSchema>;
358
+
359
+ // =============================================================================
360
+ // Roadmap R41: the fields that several procedures share
361
+ // =============================================================================
362
+
363
+ const COMPOSE_FILE = z.string().optional().describe("Compose file path");
364
+ const SERVICES = z.array(z.string()).optional().describe("The services (default: all)");
365
+ const CWD = z.string().optional().describe("Working directory");
366
+ const TIMEOUT = z.number().optional().describe("Timeout in milliseconds");
367
+ const FILTER = z.string().optional().describe("A filter of docker, for example label=app or dangling=true");
368
+ const FORMAT = z.string().optional().describe("A Go template or json for the output (--format)");
369
+ const LABELS = z.record(z.string(), z.string()).optional().describe("Labels");
370
+
371
+ // =============================================================================
372
+ // docker.compose.ps Types - The containers of a compose project (roadmap R41)
373
+ // =============================================================================
374
+
375
+ export const DockerComposePsInputSchema: z.ZodObject<{
376
+ file: z.ZodOptional<z.ZodString>;
377
+ services: z.ZodOptional<z.ZodArray<z.ZodString>>;
378
+ all: z.ZodOptional<z.ZodBoolean>;
379
+ format: z.ZodOptional<z.ZodString>;
380
+ cwd: z.ZodOptional<z.ZodString>;
381
+ timeout: z.ZodOptional<z.ZodNumber>;
382
+ }> = z.object({
383
+ file: COMPOSE_FILE,
384
+ services: SERVICES,
385
+ all: z.boolean().optional().describe("Also the stopped containers"),
386
+ format: FORMAT,
387
+ cwd: CWD,
388
+ timeout: TIMEOUT,
389
+ });
390
+
391
+ export type DockerComposePsInput = z.infer<typeof DockerComposePsInputSchema>;
392
+
393
+ // =============================================================================
394
+ // docker.compose.logs Types - The logs of the services (roadmap R41)
395
+ // =============================================================================
396
+
397
+ export const DockerComposeLogsInputSchema: z.ZodObject<{
398
+ file: z.ZodOptional<z.ZodString>;
399
+ services: z.ZodOptional<z.ZodArray<z.ZodString>>;
400
+ tail: z.ZodOptional<z.ZodNumber>;
401
+ since: z.ZodOptional<z.ZodString>;
402
+ timestamps: z.ZodOptional<z.ZodBoolean>;
403
+ cwd: z.ZodOptional<z.ZodString>;
404
+ timeout: z.ZodOptional<z.ZodNumber>;
405
+ }> = z.object({
406
+ file: COMPOSE_FILE,
407
+ services: SERVICES,
408
+ tail: z.number().int().min(0).optional().describe("The number of lines from the end of each log"),
409
+ since: z.string().optional().describe("Only the logs after this time, for example 10m or 2026-10-16T10:00:00"),
410
+ timestamps: z.boolean().optional().describe("Show timestamps"),
411
+ cwd: CWD,
412
+ timeout: TIMEOUT,
413
+ });
414
+
415
+ export type DockerComposeLogsInput = z.infer<typeof DockerComposeLogsInputSchema>;
416
+
417
+ // =============================================================================
418
+ // docker.compose.build Types - The images of the services (roadmap R41)
419
+ // =============================================================================
420
+
421
+ export const DockerComposeBuildInputSchema: z.ZodObject<{
422
+ file: z.ZodOptional<z.ZodString>;
423
+ services: z.ZodOptional<z.ZodArray<z.ZodString>>;
424
+ noCache: z.ZodOptional<z.ZodBoolean>;
425
+ pull: z.ZodOptional<z.ZodBoolean>;
426
+ buildArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
427
+ cwd: z.ZodOptional<z.ZodString>;
428
+ timeout: z.ZodOptional<z.ZodNumber>;
429
+ }> = z.object({
430
+ file: COMPOSE_FILE,
431
+ services: SERVICES,
432
+ noCache: z.boolean().optional().describe("Do not use cache when building"),
433
+ pull: z.boolean().optional().describe("Pull newer versions of the base images"),
434
+ buildArgs: z.record(z.string(), z.string()).optional().describe("Build arguments"),
435
+ cwd: CWD,
436
+ timeout: TIMEOUT,
437
+ });
438
+
439
+ export type DockerComposeBuildInput = z.infer<typeof DockerComposeBuildInputSchema>;
440
+
441
+ // =============================================================================
442
+ // docker.compose.restart Types - Restart the services (roadmap R41)
443
+ // =============================================================================
444
+
445
+ export const DockerComposeRestartInputSchema: z.ZodObject<{
446
+ file: z.ZodOptional<z.ZodString>;
447
+ services: z.ZodOptional<z.ZodArray<z.ZodString>>;
448
+ time: z.ZodOptional<z.ZodNumber>;
449
+ cwd: z.ZodOptional<z.ZodString>;
450
+ timeout: z.ZodOptional<z.ZodNumber>;
451
+ }> = z.object({
452
+ file: COMPOSE_FILE,
453
+ services: SERVICES,
454
+ time: z.number().int().min(0).optional().describe("Seconds to wait for the stop before killing"),
455
+ cwd: CWD,
456
+ timeout: TIMEOUT,
457
+ });
458
+
459
+ export type DockerComposeRestartInput = z.infer<typeof DockerComposeRestartInputSchema>;
460
+
461
+ // =============================================================================
462
+ // docker.images Types - List images (roadmap R41)
463
+ // =============================================================================
464
+
465
+ export const DockerImagesInputSchema: z.ZodObject<{
466
+ repository: z.ZodOptional<z.ZodString>;
467
+ all: z.ZodOptional<z.ZodBoolean>;
468
+ filter: z.ZodOptional<z.ZodString>;
469
+ format: z.ZodOptional<z.ZodString>;
470
+ cwd: z.ZodOptional<z.ZodString>;
471
+ timeout: z.ZodOptional<z.ZodNumber>;
472
+ }> = z.object({
473
+ repository: z.string().optional().describe("Only the images of this repository, for example nginx or nginx:1.27"),
474
+ all: z.boolean().optional().describe("Also the intermediate images"),
475
+ filter: FILTER,
476
+ format: FORMAT,
477
+ cwd: CWD,
478
+ timeout: TIMEOUT,
479
+ });
480
+
481
+ export type DockerImagesInput = z.infer<typeof DockerImagesInputSchema>;
482
+
483
+ // =============================================================================
484
+ // docker.inspect Types - The details of objects as JSON (roadmap R41)
485
+ // =============================================================================
486
+
487
+ export const DockerInspectInputSchema: z.ZodObject<{
488
+ targets: z.ZodArray<z.ZodString>;
489
+ type: z.ZodOptional<z.ZodEnum<{ container: "container"; image: "image"; volume: "volume"; network: "network" }>>;
490
+ format: z.ZodOptional<z.ZodString>;
491
+ cwd: z.ZodOptional<z.ZodString>;
492
+ timeout: z.ZodOptional<z.ZodNumber>;
493
+ }> = z.object({
494
+ targets: z.array(z.string()).min(1).describe("The names or the IDs of the objects"),
495
+ type: z.enum(["container", "image", "volume", "network"]).optional().describe("The type of the objects (default: any type)"),
496
+ format: z.string().optional().describe("A Go template for the output. Without it, the output is JSON, and data has it"),
497
+ cwd: CWD,
498
+ timeout: TIMEOUT,
499
+ });
500
+
501
+ export type DockerInspectInput = z.infer<typeof DockerInspectInputSchema>;
502
+
503
+ /** The result of docker.inspect: `data` is the parsed JSON of docker, without `format`. */
504
+ export interface DockerInspectOutput extends DockerCommandOutput {
505
+ data?: unknown;
506
+ }
507
+
508
+ // =============================================================================
509
+ // docker.volume.* Types - Volumes (roadmap R41)
510
+ // =============================================================================
511
+
512
+ export const DockerVolumeListInputSchema: z.ZodObject<{
513
+ filter: z.ZodOptional<z.ZodString>;
514
+ format: z.ZodOptional<z.ZodString>;
515
+ cwd: z.ZodOptional<z.ZodString>;
516
+ timeout: z.ZodOptional<z.ZodNumber>;
517
+ }> = z.object({
518
+ filter: FILTER,
519
+ format: FORMAT,
520
+ cwd: CWD,
521
+ timeout: TIMEOUT,
522
+ });
523
+
524
+ export type DockerVolumeListInput = z.infer<typeof DockerVolumeListInputSchema>;
525
+
526
+ export const DockerVolumeCreateInputSchema: z.ZodObject<{
527
+ name: z.ZodOptional<z.ZodString>;
528
+ driver: z.ZodOptional<z.ZodString>;
529
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
530
+ cwd: z.ZodOptional<z.ZodString>;
531
+ timeout: z.ZodOptional<z.ZodNumber>;
532
+ }> = z.object({
533
+ name: z.string().optional().describe("The volume name (default: a random name)"),
534
+ driver: z.string().optional().describe("The volume driver (default: local)"),
535
+ labels: LABELS,
536
+ cwd: CWD,
537
+ timeout: TIMEOUT,
538
+ });
539
+
540
+ export type DockerVolumeCreateInput = z.infer<typeof DockerVolumeCreateInputSchema>;
541
+
542
+ export const DockerVolumeRemoveInputSchema: z.ZodObject<{
543
+ volumes: z.ZodArray<z.ZodString>;
544
+ force: z.ZodOptional<z.ZodBoolean>;
545
+ cwd: z.ZodOptional<z.ZodString>;
546
+ timeout: z.ZodOptional<z.ZodNumber>;
547
+ }> = z.object({
548
+ volumes: z.array(z.string()).min(1).describe("The volume names. Their data is lost"),
549
+ force: z.boolean().optional().describe("Force removal"),
550
+ cwd: CWD,
551
+ timeout: TIMEOUT,
552
+ });
553
+
554
+ export type DockerVolumeRemoveInput = z.infer<typeof DockerVolumeRemoveInputSchema>;
555
+
556
+ // =============================================================================
557
+ // docker.network.* Types - Networks (roadmap R41)
558
+ // =============================================================================
559
+
560
+ export const DockerNetworkListInputSchema: z.ZodObject<{
561
+ filter: z.ZodOptional<z.ZodString>;
562
+ format: z.ZodOptional<z.ZodString>;
563
+ cwd: z.ZodOptional<z.ZodString>;
564
+ timeout: z.ZodOptional<z.ZodNumber>;
565
+ }> = z.object({
566
+ filter: FILTER,
567
+ format: FORMAT,
568
+ cwd: CWD,
569
+ timeout: TIMEOUT,
570
+ });
571
+
572
+ export type DockerNetworkListInput = z.infer<typeof DockerNetworkListInputSchema>;
573
+
574
+ export const DockerNetworkCreateInputSchema: z.ZodObject<{
575
+ name: z.ZodString;
576
+ driver: z.ZodOptional<z.ZodString>;
577
+ internal: z.ZodOptional<z.ZodBoolean>;
578
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
579
+ cwd: z.ZodOptional<z.ZodString>;
580
+ timeout: z.ZodOptional<z.ZodNumber>;
581
+ }> = z.object({
582
+ name: z.string().describe("The network name"),
583
+ driver: z.string().optional().describe("The network driver (default: bridge)"),
584
+ internal: z.boolean().optional().describe("No access to networks outside the host"),
585
+ labels: LABELS,
586
+ cwd: CWD,
587
+ timeout: TIMEOUT,
588
+ });
589
+
590
+ export type DockerNetworkCreateInput = z.infer<typeof DockerNetworkCreateInputSchema>;
591
+
592
+ export const DockerNetworkRemoveInputSchema: z.ZodObject<{
593
+ networks: z.ZodArray<z.ZodString>;
594
+ cwd: z.ZodOptional<z.ZodString>;
595
+ timeout: z.ZodOptional<z.ZodNumber>;
596
+ }> = z.object({
597
+ networks: z.array(z.string()).min(1).describe("The network names or IDs"),
598
+ cwd: CWD,
599
+ timeout: TIMEOUT,
600
+ });
601
+
602
+ export type DockerNetworkRemoveInput = z.infer<typeof DockerNetworkRemoveInputSchema>;
603
+
604
+ // =============================================================================
605
+ // docker.tag and docker.push Types (roadmap R41)
606
+ // =============================================================================
607
+
608
+ export const DockerTagInputSchema: z.ZodObject<{
609
+ source: z.ZodString;
610
+ target: z.ZodString;
611
+ cwd: z.ZodOptional<z.ZodString>;
612
+ timeout: z.ZodOptional<z.ZodNumber>;
613
+ }> = z.object({
614
+ source: z.string().describe("The image, for example app:latest or an image ID"),
615
+ target: z.string().describe("The new name, for example registry.example.com/app:1.0. An image with this name loses it"),
616
+ cwd: CWD,
617
+ timeout: TIMEOUT,
618
+ });
619
+
620
+ export type DockerTagInput = z.infer<typeof DockerTagInputSchema>;
621
+
622
+ export const DockerPushInputSchema: z.ZodObject<{
623
+ image: z.ZodString;
624
+ allTags: z.ZodOptional<z.ZodBoolean>;
625
+ cwd: z.ZodOptional<z.ZodString>;
626
+ timeout: z.ZodOptional<z.ZodNumber>;
627
+ }> = z.object({
628
+ image: z.string().describe("The image, for example registry.example.com/app:1.0"),
629
+ allTags: z.boolean().optional().describe("Push all the tags of the repository"),
630
+ cwd: CWD,
631
+ timeout: TIMEOUT,
632
+ });
633
+
634
+ export type DockerPushInput = z.infer<typeof DockerPushInputSchema>;
635
+
636
+ // =============================================================================
637
+ // docker.prune Types - Remove unused objects (roadmap R41)
638
+ // =============================================================================
639
+
640
+ export const DockerPruneInputSchema: z.ZodObject<{
641
+ kind: z.ZodOptional<
642
+ z.ZodEnum<{ system: "system"; container: "container"; image: "image"; volume: "volume"; network: "network"; builder: "builder" }>
643
+ >;
644
+ all: z.ZodOptional<z.ZodBoolean>;
645
+ volumes: z.ZodOptional<z.ZodBoolean>;
646
+ filter: z.ZodOptional<z.ZodString>;
647
+ confirm: z.ZodLiteral<true>;
648
+ cwd: z.ZodOptional<z.ZodString>;
649
+ timeout: z.ZodOptional<z.ZodNumber>;
650
+ }> = z.object({
651
+ kind: z
652
+ .enum(["system", "container", "image", "volume", "network", "builder"])
653
+ .optional()
654
+ .describe("What to remove. system: the stopped containers, the unused networks, the dangling images and the build cache (default: system)"),
655
+ all: z.boolean().optional().describe("Also the unused images that have a name (image, system, builder), or the named volumes (volume)"),
656
+ volumes: z.boolean().optional().describe("With the kind system: also the unused volumes. Their data is lost"),
657
+ filter: FILTER,
658
+ confirm: z.literal(true).describe("Must be true: the removed objects and their data are lost"),
659
+ cwd: CWD,
660
+ timeout: TIMEOUT,
661
+ });
662
+
663
+ export type DockerPruneInput = z.infer<typeof DockerPruneInputSchema>;
664
+
665
+ // =============================================================================
666
+ // The outputs of the procedures of roadmap R41
667
+ // =============================================================================
668
+
669
+ export type DockerComposePsOutput = DockerCommandOutput;
670
+ export type DockerComposeLogsOutput = DockerCommandOutput;
671
+ export type DockerComposeBuildOutput = DockerCommandOutput;
672
+ export type DockerComposeRestartOutput = DockerCommandOutput;
673
+ export type DockerImagesOutput = DockerCommandOutput;
674
+ export type DockerVolumeListOutput = DockerCommandOutput;
675
+ export type DockerVolumeCreateOutput = DockerCommandOutput;
676
+ export type DockerVolumeRemoveOutput = DockerCommandOutput;
677
+ export type DockerNetworkListOutput = DockerCommandOutput;
678
+ export type DockerNetworkCreateOutput = DockerCommandOutput;
679
+ export type DockerNetworkRemoveOutput = DockerCommandOutput;
680
+ export type DockerTagOutput = DockerCommandOutput;
681
+ export type DockerPushOutput = DockerCommandOutput;
682
+ export type DockerPruneOutput = DockerCommandOutput;
683
+
684
+ export const DockerComposePsOutputSchema: z.ZodType<DockerComposePsOutput> = DockerCommandOutputSchema;
685
+ export const DockerComposeLogsOutputSchema: z.ZodType<DockerComposeLogsOutput> = DockerCommandOutputSchema;
686
+ export const DockerComposeBuildOutputSchema: z.ZodType<DockerComposeBuildOutput> = DockerCommandOutputSchema;
687
+ export const DockerComposeRestartOutputSchema: z.ZodType<DockerComposeRestartOutput> = DockerCommandOutputSchema;
688
+ export const DockerImagesOutputSchema: z.ZodType<DockerImagesOutput> = DockerCommandOutputSchema;
689
+ export const DockerVolumeListOutputSchema: z.ZodType<DockerVolumeListOutput> = DockerCommandOutputSchema;
690
+ export const DockerVolumeCreateOutputSchema: z.ZodType<DockerVolumeCreateOutput> = DockerCommandOutputSchema;
691
+ export const DockerVolumeRemoveOutputSchema: z.ZodType<DockerVolumeRemoveOutput> = DockerCommandOutputSchema;
692
+ export const DockerNetworkListOutputSchema: z.ZodType<DockerNetworkListOutput> = DockerCommandOutputSchema;
693
+ export const DockerNetworkCreateOutputSchema: z.ZodType<DockerNetworkCreateOutput> = DockerCommandOutputSchema;
694
+ export const DockerNetworkRemoveOutputSchema: z.ZodType<DockerNetworkRemoveOutput> = DockerCommandOutputSchema;
695
+ export const DockerTagOutputSchema: z.ZodType<DockerTagOutput> = DockerCommandOutputSchema;
696
+ export const DockerPushOutputSchema: z.ZodType<DockerPushOutput> = DockerCommandOutputSchema;
697
+ export const DockerPruneOutputSchema: z.ZodType<DockerPruneOutput> = DockerCommandOutputSchema;
698
+
699
+ export const DockerInspectOutputSchema: z.ZodType<DockerInspectOutput> = z.looseObject({
700
+ exitCode: z.number().describe("The exit code of docker (0 is success)"),
701
+ stdout: z.string().describe("The standard output of docker"),
702
+ stderr: z.string().describe("The standard error of docker, or the error message when docker did not start"),
703
+ success: z.boolean().describe("True when the exit code is 0"),
704
+ duration: z.number().describe("The time of the command, in milliseconds"),
705
+ data: z.unknown().optional().describe("The parsed JSON of docker: one object for each target"),
706
+ });