@parcha/agentrun-computer 0.1.0-beta.58 → 0.1.0-beta.59

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 (131) hide show
  1. package/README.md +187 -62
  2. package/box/Dockerfile +4 -3
  3. package/box/install.sh +57 -11
  4. package/dist/agent37.js +6 -9
  5. package/dist/attach.d.ts +24 -4
  6. package/dist/attach.js +50 -19
  7. package/dist/boxd.js +22 -9
  8. package/dist/browserbase.d.ts +6 -2
  9. package/dist/browserbase.js +50 -7
  10. package/dist/child-env.d.ts +11 -0
  11. package/dist/child-env.js +22 -0
  12. package/dist/chrome.d.ts +5 -2
  13. package/dist/chrome.js +5 -2
  14. package/dist/cloudflare.d.ts +2 -0
  15. package/dist/cloudflare.js +5 -3
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +1 -1
  19. package/dist/conformance/agent37.d.ts +10 -38
  20. package/dist/conformance/agent37.js +25 -113
  21. package/dist/conformance/archil.d.ts +13 -3
  22. package/dist/conformance/archil.js +22 -17
  23. package/dist/conformance/boxd.d.ts +8 -31
  24. package/dist/conformance/boxd.js +19 -74
  25. package/dist/conformance/browserbase.d.ts +3 -6
  26. package/dist/conformance/browserbase.js +6 -17
  27. package/dist/conformance/cases/health.js +6 -3
  28. package/dist/conformance/cli.d.ts +3 -1
  29. package/dist/conformance/cli.js +69 -9
  30. package/dist/conformance/cloudflare.d.ts +3 -6
  31. package/dist/conformance/cloudflare.js +7 -15
  32. package/dist/conformance/daytona.d.ts +6 -20
  33. package/dist/conformance/daytona.js +22 -57
  34. package/dist/conformance/dial-only.d.ts +4 -3
  35. package/dist/conformance/dial-only.js +3 -3
  36. package/dist/conformance/docker.d.ts +4 -5
  37. package/dist/conformance/docker.js +8 -14
  38. package/dist/conformance/e2b.d.ts +10 -36
  39. package/dist/conformance/e2b.js +27 -84
  40. package/dist/conformance/fly.d.ts +3 -6
  41. package/dist/conformance/fly.js +2 -6
  42. package/dist/conformance/groundbox.d.ts +7 -23
  43. package/dist/conformance/groundbox.js +16 -56
  44. package/dist/conformance/index.d.ts +1 -0
  45. package/dist/conformance/index.js +1 -0
  46. package/dist/conformance/kernel.d.ts +3 -6
  47. package/dist/conformance/kernel.js +5 -15
  48. package/dist/conformance/kind.d.ts +0 -6
  49. package/dist/conformance/kind.js +0 -4
  50. package/dist/conformance/local-chrome.d.ts +5 -7
  51. package/dist/conformance/local-chrome.js +7 -11
  52. package/dist/conformance/modal.d.ts +10 -38
  53. package/dist/conformance/modal.js +27 -74
  54. package/dist/conformance/module-kit.d.ts +87 -0
  55. package/dist/conformance/module-kit.js +88 -0
  56. package/dist/conformance/morph.d.ts +7 -23
  57. package/dist/conformance/morph.js +20 -66
  58. package/dist/conformance/orgo.d.ts +5 -10
  59. package/dist/conformance/orgo.js +15 -27
  60. package/dist/conformance/phone-harness.d.ts +3 -5
  61. package/dist/conformance/phone-harness.js +3 -11
  62. package/dist/conformance/runner.d.ts +13 -3
  63. package/dist/conformance/runner.js +32 -11
  64. package/dist/conformance/smolcloud.d.ts +7 -23
  65. package/dist/conformance/smolcloud.js +16 -49
  66. package/dist/conformance/sweep.d.ts +10 -5
  67. package/dist/conformance/sweep.js +91 -38
  68. package/dist/conformance/tti.d.ts +69 -0
  69. package/dist/conformance/tti.js +205 -0
  70. package/dist/conformance/types.d.ts +9 -2
  71. package/dist/daytona.js +60 -20
  72. package/dist/descriptor.d.ts +10 -0
  73. package/dist/descriptor.js +7 -0
  74. package/dist/descriptors/browserbase.d.ts +3 -0
  75. package/dist/descriptors/browserbase.js +4 -0
  76. package/dist/descriptors/docker.d.ts +1 -0
  77. package/dist/descriptors/docker.js +3 -0
  78. package/dist/descriptors/env-names.d.ts +32 -0
  79. package/dist/descriptors/env-names.js +60 -0
  80. package/dist/descriptors/index.d.ts +9 -2
  81. package/dist/descriptors/kernel.d.ts +3 -0
  82. package/dist/descriptors/kernel.js +2 -0
  83. package/dist/descriptors/local-chrome.d.ts +1 -1
  84. package/dist/descriptors/local-chrome.js +5 -3
  85. package/dist/descriptors/phone-harness.d.ts +1 -1
  86. package/dist/descriptors/phone-harness.js +4 -2
  87. package/dist/docker/egress.d.ts +7 -0
  88. package/dist/docker/egress.js +8 -0
  89. package/dist/docker/image.d.ts +5 -1
  90. package/dist/docker/image.js +12 -8
  91. package/dist/docker.d.ts +52 -13
  92. package/dist/docker.js +166 -92
  93. package/dist/drift.js +6 -6
  94. package/dist/e2b.d.ts +2 -2
  95. package/dist/e2b.js +2 -3
  96. package/dist/groundbox.js +6 -6
  97. package/dist/host.d.ts +23 -0
  98. package/dist/hosted/download.d.ts +23 -0
  99. package/dist/hosted/download.js +144 -0
  100. package/dist/hosted/process.d.ts +5 -0
  101. package/dist/hosted/process.js +20 -0
  102. package/dist/hosted/provider.js +120 -48
  103. package/dist/hosted/rest.d.ts +19 -8
  104. package/dist/hosted/rest.js +47 -14
  105. package/dist/hosted/scripts.d.ts +10 -0
  106. package/dist/hosted/scripts.js +23 -2
  107. package/dist/index.d.ts +3 -1
  108. package/dist/index.js +3 -1
  109. package/dist/janitor.d.ts +7 -1
  110. package/dist/janitor.js +2 -2
  111. package/dist/kernel.js +1 -1
  112. package/dist/local-chrome.d.ts +5 -2
  113. package/dist/local-chrome.js +4 -2
  114. package/dist/local-supervisor.js +1 -0
  115. package/dist/modal.d.ts +6 -5
  116. package/dist/modal.js +7 -7
  117. package/dist/morph.js +5 -8
  118. package/dist/orgo-channel.d.ts +3 -2
  119. package/dist/orgo-channel.js +3 -3
  120. package/dist/orgo-desktop.js +2 -4
  121. package/dist/orgo.js +2 -4
  122. package/dist/phone-harness.d.ts +7 -5
  123. package/dist/phone-harness.js +60 -61
  124. package/dist/protocol.d.ts +10 -0
  125. package/dist/protocol.js +17 -0
  126. package/dist/provider.d.ts +6 -2
  127. package/dist/screen-watch.d.ts +6 -1
  128. package/dist/screen-watch.js +166 -12
  129. package/dist/vendor-sdk.d.ts +9 -0
  130. package/dist/vendor-sdk.js +26 -0
  131. package/package.json +8 -1
package/dist/docker.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type DesktopOptions } from "./desktop.js";
2
2
  import { type DockerHost } from "./docker/inspect.js";
3
+ import { type HostEnv } from "./child-env.js";
3
4
  import { type EnsureImageOptions, type ImageSource } from "./docker/image.js";
4
5
  import { type AttachedComputer, type CallContext, type CreateContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
5
6
  import { type Result } from "./result.js";
@@ -65,6 +66,22 @@ export interface DockerProviderOptions {
65
66
  name: string;
66
67
  root: string;
67
68
  };
69
+ /** The host's environment variables, of which every docker CLI call holds the names docker reads (DOCKER_ENV_NAMES:
70
+ * where the daemon is, its config and credential helpers, PATH and HOME) and nothing else, so no key the host holds
71
+ * reaches docker or what it starts. The provider reads no environment: without env, docker starts with none. */
72
+ env?: HostEnv;
73
+ /**
74
+ * For tests: the bound, in ms, on the clean-up after a create that failed or was cut off, and on waiting for a removal
75
+ * Docker says is already under way (a release's, a stop's, a sweep's): past it, the container still there is the
76
+ * failure, in words naming this bound. Default 10 s. A test of a removal that never ends sets it short.
77
+ */
78
+ settleMs?: number;
79
+ /**
80
+ * For tests: how long, in ms, the looks after a docker run cut off before its own exit must find nothing in a row
81
+ * before what it may have made counts as gone, so a create Docker finishes a moment after the abort is still seen.
82
+ * Default 3 s. One as long as settleMs leaves nothing confirmed gone: that create's answer then says so.
83
+ */
84
+ settleQuietMs?: number;
68
85
  }
69
86
  /** What create() takes: the provider's options, the daemon optional. */
70
87
  export interface DockerCreateOptions extends Partial<DockerProviderOptions> {
@@ -73,9 +90,10 @@ export interface DockerCreateOptions extends Partial<DockerProviderOptions> {
73
90
  }
74
91
  /**
75
92
  * Docker's architecture as `docker version` reports it (amd64, arm64), within timeoutMs, or an error in words. The docker
76
- * CLI runs with this process's environment, as every call of the provider does, so it asks the Docker the provider uses.
93
+ * CLI runs with the names of `env` docker reads (dockerEnv), as every call of the provider does, so it asks the Docker the
94
+ * provider uses.
77
95
  */
78
- export declare function dockerArch({ docker, timeoutMs }?: Pick<DockerCreateOptions, "docker" | "timeoutMs">): Promise<string>;
96
+ export declare function dockerArch({ docker, timeoutMs, env }?: Pick<DockerCreateOptions, "docker" | "timeoutMs" | "env">): Promise<string>;
79
97
  /**
80
98
  * The daemon a Docker computer binds for Docker's architecture `arch` (dockerArch): computerd-linux-<arch> in `dir`,
81
99
  * default this package's own build, and, when no such file is there, why, with the command that builds it. create()
@@ -93,17 +111,27 @@ export declare function dockerDaemonOf(arch: string, dir?: string): {
93
111
  export declare function create(options?: DockerCreateOptions): Promise<DockerProvider>;
94
112
  /** The conformance CLI's module for Docker: the drifted twin. */
95
113
  export declare const conformance: () => Promise<typeof import("./conformance/docker.js")>;
114
+ /** After a docker run cut off before its own exit: how long, at most, the leftovers are removed and looked for again,
115
+ * how often, and for how long in a row the looks must find none of them before they count as gone (#settle). */
116
+ export declare const SETTLE_MS = 10000;
117
+ export declare const SETTLE_QUIET_MS = 3000;
118
+ /** The bounds of #settle: its whole bound and its quiet window, in ms (the settleMs and settleQuietMs options). */
119
+ export interface SettleBounds {
120
+ settleMs: number;
121
+ quietMs: number;
122
+ }
96
123
  /**
97
- * Why #settle could not show its leftovers gone within SETTLE_MS, in words that always name them: `there`, what its
98
- * last look still found; or, when the last look found none but the quiet window was not complete, every name it
99
- * checked (`checked`), which could not be confirmed gone. Exported for its test.
124
+ * Why #settle could not show its leftovers gone within its bound (`bounds`, the defaults unless the provider was given
125
+ * its own), in words that always name them: `there`, what its last look still found; or, when the last look found none
126
+ * but the quiet window was not complete, every name it checked (`checked`), which could not be confirmed gone. Exported
127
+ * for its test.
100
128
  */
101
- export declare function settleWords(checked: readonly string[], there: readonly string[]): string;
129
+ export declare function settleWords(checked: readonly string[], there: readonly string[], bounds?: SettleBounds): string;
102
130
  export declare class DockerProvider implements ComputerProvider {
103
131
  #private;
104
132
  readonly id = "docker";
105
133
  readonly version: string;
106
- constructor({ daemonPath, daemonCache, docker, user, desktop, egress, image, volume }: DockerProviderOptions);
134
+ constructor({ daemonPath, daemonCache, docker, user, desktop, egress, image, volume, env, settleMs, settleQuietMs }: DockerProviderOptions);
107
135
  /** The uid:gid a computer runs as when its spec names no user: the user a bound run folder must be writable by. */
108
136
  get user(): string;
109
137
  capabilities(): ComputerCapabilities;
@@ -144,16 +172,21 @@ export declare class DockerProvider implements ComputerProvider {
144
172
  list(labels: Record<string, string>, { signal }?: CallContext): Promise<Result<ComputerInfo[]>>;
145
173
  /**
146
174
  * The janitor's second pass (sweep calls it after the computers): every egress proxy container and egress volume
147
- * labelled EGRESS_LABEL, and with all of `labels`, whose deadline label has passed (or is missing or unreadable, fail
148
- * closed), or whose computer is gone and that is older than a create could take (#leftoverGraceMs: one under way has
149
- * made its proxy before its computer, and pulled both images before either, so no pull happens in between). Each is
150
- * removed by what its label found, a proxy before its volume, never by a name alone. Returns the names removed, a
151
- * volume's as "<name> (volume)".
175
+ * labelled EGRESS_LABEL, and with all of `labels`, whose computer is not there, read by its name right before that
176
+ * part's removal, and that is past its deadline label (or the label is missing or unreadable, fail closed) or older
177
+ * than a create could take (#leftoverGraceMs). Per part, in this order: its labels and age; then `mine`, when given
178
+ * (serve's: a run of its own store that no claim holds); then its computer, by name (there, or a read that fails,
179
+ * keeps the part); then its removal by what its label found, a proxy before its volume, never by a name alone.
180
+ * `mine` comes before the computer so a create under the caller's claim that finishes between the two reads is seen:
181
+ * once the caller says no claim holds the run, nothing at that claim makes the computer, and a later claim's computer
182
+ * has another name. A part with an owner label is never removed: Docker makes no agent's computer (no persistence),
183
+ * so that label is a caller's, never a run's leftover. Returns the names removed, a volume's as "<name> (volume)".
152
184
  */
153
- sweepLeftovers({ labels, now, signal }?: {
185
+ sweepLeftovers({ labels, now, signal, mine }?: {
154
186
  labels?: Record<string, string>;
155
187
  now?: Date;
156
188
  signal?: AbortSignal;
189
+ mine?: (labels: Record<string, string>) => boolean | Promise<boolean>;
157
190
  }): Promise<Result<string[]>>;
158
191
  network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
159
192
  /**
@@ -163,3 +196,9 @@ export declare class DockerProvider implements ComputerProvider {
163
196
  */
164
197
  release(ref: ComputerRef, how: ReleaseHow): Promise<Result<void>>;
165
198
  }
199
+ /**
200
+ * The settleMs and settleQuietMs options as #settle's bounds, with their defaults (SETTLE_MS, SETTLE_QUIET_MS), or a throw
201
+ * in words: each is a whole number of milliseconds above 0 that a timer can hold. The one place the defaults are applied:
202
+ * the constructor and settleWords both read it. Exported for its test, which reads the defaults instead of waiting them out.
203
+ */
204
+ export declare function settleBoundsOf({ settleMs, settleQuietMs }: Pick<DockerProviderOptions, "settleMs" | "settleQuietMs">): SettleBounds;
package/dist/docker.js CHANGED
@@ -11,8 +11,9 @@ import { DOCKER } from "./descriptors/docker.js";
11
11
  import { DESKTOP_GROUPS, desktopOf, startDisplay } from "./desktop.js";
12
12
  import { COMPUTER_LABEL, DAEMON_IN_COMPUTER, DEADLINE_LABEL, DEFAULT_CPUS, DEFAULT_MEMORY_MB, DEFAULT_PIDS, helloDrift, WORK, } from "./drift.js";
13
13
  import { CPU_PERIOD_US, DAEMON_DIR_IN_COMPUTER, drift, egressShaped, hostOf, inspectDrift, mountOf, networkOf, samePolicy, tmpfsOf, } from "./docker/inspect.js";
14
+ import { dockerEnv } from "./child-env.js";
14
15
  import { DOCKER_RECIPE, ensureImage, imageSourceProblem } from "./docker/image.js";
15
- import { ALLOW_PORTS, allowOf, containerSigns, EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_NETWORK, EGRESS_READY_MS, EGRESS_SOCKET, egressCode, egressCodeProblem, egressNameOf, egressNetworkArgs, egressNetworkProblem, egressRunArgs, egressVolumeArgs, hostAddresses, MAX_ALLOW, policyWords, RELAY_FLAG, } from "./docker/egress.js";
16
+ import { ALLOW_PORTS, allowOf, containerSigns, EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_NETWORK, EGRESS_READY_MS, EGRESS_SOCKET, egressCode, egressCodeProblem, egressNameOf, egressNetworkArgs, egressNetworkProblem, egressRunArgs, egressVolumeArgs, hostAddresses, MAX_ALLOW, NO_CONFIG_PROXY, policyWords, RELAY_FLAG, } from "./docker/egress.js";
16
17
  import { daemonStage, daemonVerified, egressStage, egressStaged } from "./docker/stage.js";
17
18
  import { EGRESS_READY } from "./docker/egress-proxy.js";
18
19
  import { OLD_ENGINE, outsideWords, subpathOf, VOLUME_SUBPATH_ENGINE, volumeMount, volumeOf } from "./docker/volume.js";
@@ -20,6 +21,7 @@ import { addressBytes } from "./docker/egress-table.js";
20
21
  import { checkMount, WORKSPACE } from "./mount.js";
21
22
  import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
22
23
  import { failFor, ok, vendorFail } from "./result.js";
24
+ import { OWNER_LABEL, OWNER_SERVER_LABEL } from "./labels.js";
23
25
  import { CreateRequests, endedWords, otherSpecWords } from "./create-requests.js";
24
26
  import { daemonWatch } from "./screen-watch.js";
25
27
  import { countTested } from "./test-connection.js";
@@ -27,11 +29,12 @@ import { countTested } from "./test-connection.js";
27
29
  const fail = failFor("docker");
28
30
  /**
29
31
  * Docker's architecture as `docker version` reports it (amd64, arm64), within timeoutMs, or an error in words. The docker
30
- * CLI runs with this process's environment, as every call of the provider does, so it asks the Docker the provider uses.
32
+ * CLI runs with the names of `env` docker reads (dockerEnv), as every call of the provider does, so it asks the Docker the
33
+ * provider uses.
31
34
  */
32
- export function dockerArch({ docker = "docker", timeoutMs = 30_000 } = {}) {
35
+ export function dockerArch({ docker = "docker", timeoutMs = 30_000, env } = {}) {
33
36
  return new Promise((resolve, reject) => {
34
- execFile(docker, ["version", "--format", "{{.Server.Arch}}"], { encoding: "utf8", timeout: timeoutMs, killSignal: "SIGKILL" }, (error, stdout, stderr) => {
37
+ execFile(docker, ["version", "--format", "{{.Server.Arch}}"], { env: dockerEnv(env), encoding: "utf8", timeout: timeoutMs, killSignal: "SIGKILL" }, (error, stdout, stderr) => {
35
38
  if (!error)
36
39
  return resolve(stdout.trim());
37
40
  const killed = error.killed === true && error.signal === "SIGKILL";
@@ -58,7 +61,7 @@ export async function create(options = {}) {
58
61
  const { timeoutMs, ...given } = options;
59
62
  let daemonPath = given.daemonPath || undefined;
60
63
  if (daemonPath === undefined) {
61
- const daemon = dockerDaemonOf(await dockerArch({ ...(given.docker ? { docker: given.docker } : {}), ...(timeoutMs === undefined ? {} : { timeoutMs }) }));
64
+ const daemon = dockerDaemonOf(await dockerArch({ ...(given.docker ? { docker: given.docker } : {}), ...(given.env ? { env: given.env } : {}), ...(timeoutMs === undefined ? {} : { timeoutMs }) }));
62
65
  if (daemon.missing !== undefined)
63
66
  throw new Error(daemon.missing);
64
67
  daemonPath = daemon.path;
@@ -111,9 +114,9 @@ const REQUEST_WAIT_MS = 120_000;
111
114
  const REQUEST_POLL_MS = 500;
112
115
  /** After a docker run cut off before its own exit: how long, at most, the leftovers are removed and looked for again,
113
116
  * how often, and for how long in a row the looks must find none of them before they count as gone (#settle). */
114
- const SETTLE_MS = 10_000;
117
+ export const SETTLE_MS = 10_000;
115
118
  const SETTLE_EVERY_MS = 500;
116
- const SETTLE_QUIET_MS = 3_000;
119
+ export const SETTLE_QUIET_MS = 3_000;
117
120
  /** The label naming which create made a computer's container: after its own docker run failed or was cut off, a create
118
121
  * removes the container it made, never one another create of the same request made under the name. */
119
122
  const ATTEMPT_LABEL = "agentrun.computer.attempt";
@@ -123,15 +126,16 @@ const ASKED_LABEL = "agentrun.computer.labels";
123
126
  /** What #settle reads of each container it looks for: its id, its name, and its labels (whose attempt it is). */
124
127
  const SETTLE_FORMAT = '{"Id":{{json .Id}},"Name":{{json .Name}},"Config":{"Labels":{{json .Config.Labels}}}}';
125
128
  /**
126
- * Why #settle could not show its leftovers gone within SETTLE_MS, in words that always name them: `there`, what its
127
- * last look still found; or, when the last look found none but the quiet window was not complete, every name it
128
- * checked (`checked`), which could not be confirmed gone. Exported for its test.
129
+ * Why #settle could not show its leftovers gone within its bound (`bounds`, the defaults unless the provider was given
130
+ * its own), in words that always name them: `there`, what its last look still found; or, when the last look found none
131
+ * but the quiet window was not complete, every name it checked (`checked`), which could not be confirmed gone. Exported
132
+ * for its test.
129
133
  */
130
- export function settleWords(checked, there) {
134
+ export function settleWords(checked, there, bounds = settleBoundsOf({})) {
131
135
  if (there.length > 0)
132
- return `${there.join(" and ")} ${there.length === 1 ? "was" : "were"} still there ${SETTLE_MS / 1000} s after docker run was cut off`;
136
+ return `${there.join(" and ")} ${there.length === 1 ? "was" : "were"} still there ${bounds.settleMs / 1000} s after docker run was cut off`;
133
137
  const named = checked.length > 0 ? checked.join(" and ") : "what docker run may have made";
134
- return `${named} could not be confirmed gone within ${SETTLE_MS / 1000} s after docker run was cut off: the last look found none, but not for ${SETTLE_QUIET_MS / 1000} s in a row`;
138
+ return `${named} could not be confirmed gone within ${bounds.settleMs / 1000} s after docker run was cut off: the last look found none, but not for ${bounds.quietMs / 1000} s in a row`;
135
139
  }
136
140
  /** Only the fields hostOf reads, as JSON. */
137
141
  const INFO_FORMAT = '{"Architecture":{{json .Architecture}},"SecurityOptions":{{json .SecurityOptions}},"MemoryLimit":{{json .MemoryLimit}},' +
@@ -157,10 +161,14 @@ export class DockerProvider {
157
161
  /** The volume option: the daemon's staged directory and a run folder are its subpaths (src/docker/volume.ts). */
158
162
  #volume;
159
163
  #docker;
164
+ /** Every docker CLI call's whole environment (dockerEnv of the env option). */
165
+ #env;
160
166
  #user;
161
167
  #desktop;
162
168
  #image;
163
169
  #egress;
170
+ /** The settleMs and settleQuietMs options: #settle's bounds; settleMs also bounds each removal #gone waits for. */
171
+ #settleBounds;
164
172
  /** Each create in flight, and the names of the computers this provider deleted (create-requests.ts). */
165
173
  #requests = new CreateRequests();
166
174
  /** Why this provider's own interfaces are not the Docker host's, in words, or none: read once, for the first allowlist
@@ -187,7 +195,7 @@ export class DockerProvider {
187
195
  }
188
196
  /** The host as docker info first read it: a host's enforcement does not change under a running provider. */
189
197
  #host;
190
- constructor({ daemonPath, daemonCache, docker = "docker", user, desktop, egress, image = { recipe: DOCKER_RECIPE }, volume }) {
198
+ constructor({ daemonPath, daemonCache, docker = "docker", user, desktop, egress, image = { recipe: DOCKER_RECIPE }, volume, env, settleMs, settleQuietMs }) {
191
199
  this.#daemonPath = resolve(daemonPath);
192
200
  this.#daemonCache = resolve(daemonCache ?? defaultDaemonCache());
193
201
  this.#volume = volume === undefined ? undefined : volumeOf(volume);
@@ -196,12 +204,14 @@ export class DockerProvider {
196
204
  throw new Error(`${outsideWords(this.#volume, this.#daemonCache, "the provider's daemonCache")}: pass a daemonCache below it`);
197
205
  }
198
206
  this.#docker = docker;
207
+ this.#env = dockerEnv(env);
199
208
  const unusable = imageSourceProblem(image);
200
209
  if (unusable !== undefined)
201
210
  throw new Error(`the provider's image: ${unusable}`);
202
211
  this.#image = image;
203
212
  this.#desktop = desktop === undefined ? undefined : desktopOf(desktop);
204
213
  this.#egress = egressOptionsOf(egress ?? {});
214
+ this.#settleBounds = settleBoundsOf({ settleMs, settleQuietMs });
205
215
  const given = user === undefined ? defaultUser() : userOf(user);
206
216
  if (given === undefined)
207
217
  throw new Error(`the provider's user ${JSON.stringify(user)} must be ${USER_FORM}`);
@@ -239,7 +249,7 @@ export class DockerProvider {
239
249
  * Docker has none; one inspect when it has. Concurrent calls in one process share one build (ensureImage).
240
250
  */
241
251
  image(options = {}) {
242
- return ensureImage(this.#image, { ...options, docker: this.#docker });
252
+ return ensureImage(this.#image, { ...options, docker: this.#docker, env: this.#env });
243
253
  }
244
254
  /** The provider contract's prepareImage (its descriptor declares it): image(), its recipe built or its image pulled. */
245
255
  prepareImage(context = {}) {
@@ -542,6 +552,7 @@ export class DockerProvider {
542
552
  args.push("--user", user, "--env", `HOME=${WORK}`);
543
553
  if (this.#desktop)
544
554
  args.push("--env", `DISPLAY=${this.#desktop.display}`);
555
+ args.push(...NO_CONFIG_PROXY);
545
556
  for (const [path, options] of Object.entries(tmpfsOf(user, memoryMb)))
546
557
  args.push("--tmpfs", `${path}:${options}`);
547
558
  args.push("--cap-drop", "ALL", "--security-opt", "no-new-privileges", "--pids-limit", String(spec.pids ?? DEFAULT_PIDS));
@@ -652,14 +663,14 @@ export class DockerProvider {
652
663
  * After a `docker run` that did not end with an exit of the CLI's own (it was aborted, or the CLI could not be run):
653
664
  * the CLI client is gone, but the Docker daemon may still finish making the container a moment later, after a single
654
665
  * `docker rm` found nothing, and leave it Created. So the containers and volumes named are removed by name, then
655
- * inspected, again and again SETTLE_EVERY_MS apart, until the looks have found none of them for SETTLE_QUIET_MS in a
656
- * row (a create that lands a second after the abort is still seen), on a bound of their own (SETTLE_MS), never the
657
- * caller's signal, which has already ended. Undefined when they are gone; else what is still there, or could not be
658
- * confirmed gone, in words (settleWords). A create later than that is the janitor's: sweepLeftovers takes it at the
659
- * next sweep, past #leftoverGraceMs, which stays the backstop.
666
+ * inspected, again and again SETTLE_EVERY_MS apart, until the looks have found none of them for the quiet window
667
+ * (settleQuietMs, default SETTLE_QUIET_MS) in a row (a create that lands a second after the abort is still seen), on a
668
+ * bound of their own (settleMs, default SETTLE_MS), never the caller's signal, which has already ended. Undefined when
669
+ * they are gone; else what is still there, or could not be confirmed gone, in words (settleWords). A create later than
670
+ * that is the janitor's: sweepLeftovers takes it at the next sweep, past #leftoverGraceMs, which stays the backstop.
660
671
  */
661
672
  async #settle(containers, volumes, attempt) {
662
- const bound = AbortSignal.timeout(SETTLE_MS);
673
+ const bound = AbortSignal.timeout(this.#settleBounds.settleMs);
663
674
  // Only what that create made (ATTEMPT_LABEL) is removed and waited for: a container or a volume another create of the
664
675
  // request made under the name is not this create's leftover.
665
676
  const mine = (reports) => reports.filter((one) => one.Config?.Labels?.[ATTEMPT_LABEL] === attempt);
@@ -695,12 +706,12 @@ export class DockerProvider {
695
706
  quietSince = undefined;
696
707
  else {
697
708
  quietSince ??= Date.now();
698
- if (Date.now() - quietSince >= SETTLE_QUIET_MS)
709
+ if (Date.now() - quietSince >= this.#settleBounds.quietMs)
699
710
  return undefined;
700
711
  }
701
712
  await sleep(SETTLE_EVERY_MS, undefined, { signal: bound }).catch(() => undefined);
702
713
  }
703
- return settleWords(checked, there);
714
+ return settleWords(checked, there, this.#settleBounds);
704
715
  }
705
716
  /** Deletes a computer whose create was aborted after docker run; the delete itself is not signalled. */
706
717
  async #abandon(ref) {
@@ -1033,7 +1044,7 @@ export class DockerProvider {
1033
1044
  }
1034
1045
  /** One connection to the computer's daemon, after hello, unchecked. */
1035
1046
  async #open(ref, signal) {
1036
- const child = spawn(this.#docker, ["exec", "-i", ref.name, DAEMON_IN_COMPUTER, "stdio"], { stdio: ["pipe", "pipe", "pipe"] });
1047
+ const child = spawn(this.#docker, ["exec", "-i", ref.name, DAEMON_IN_COMPUTER, "stdio"], { env: this.#env, stdio: ["pipe", "pipe", "pipe"] });
1037
1048
  let stderr = "";
1038
1049
  child.stderr.on("data", (chunk) => {
1039
1050
  stderr = (stderr + chunk.toString("utf8")).slice(-4096);
@@ -1159,37 +1170,52 @@ export class DockerProvider {
1159
1170
  }
1160
1171
  /**
1161
1172
  * The janitor's second pass (sweep calls it after the computers): every egress proxy container and egress volume
1162
- * labelled EGRESS_LABEL, and with all of `labels`, whose deadline label has passed (or is missing or unreadable, fail
1163
- * closed), or whose computer is gone and that is older than a create could take (#leftoverGraceMs: one under way has
1164
- * made its proxy before its computer, and pulled both images before either, so no pull happens in between). Each is
1165
- * removed by what its label found, a proxy before its volume, never by a name alone. Returns the names removed, a
1166
- * volume's as "<name> (volume)".
1173
+ * labelled EGRESS_LABEL, and with all of `labels`, whose computer is not there, read by its name right before that
1174
+ * part's removal, and that is past its deadline label (or the label is missing or unreadable, fail closed) or older
1175
+ * than a create could take (#leftoverGraceMs). Per part, in this order: its labels and age; then `mine`, when given
1176
+ * (serve's: a run of its own store that no claim holds); then its computer, by name (there, or a read that fails,
1177
+ * keeps the part); then its removal by what its label found, a proxy before its volume, never by a name alone.
1178
+ * `mine` comes before the computer so a create under the caller's claim that finishes between the two reads is seen:
1179
+ * once the caller says no claim holds the run, nothing at that claim makes the computer, and a later claim's computer
1180
+ * has another name. A part with an owner label is never removed: Docker makes no agent's computer (no persistence),
1181
+ * so that label is a caller's, never a run's leftover. Returns the names removed, a volume's as "<name> (volume)".
1167
1182
  */
1168
- async sweepLeftovers({ labels = {}, now = new Date(), signal } = {}) {
1183
+ async sweepLeftovers({ labels = {}, now = new Date(), signal, mine } = {}) {
1169
1184
  const problem = filterProblem(labels);
1170
1185
  if (problem)
1171
1186
  return fail("invalid", problem);
1172
1187
  const filters = [`label=${EGRESS_LABEL}`, ...Object.entries(labels).map(([key, value]) => `label=${key}=${value}`)].flatMap((filter) => ["--filter", filter]);
1173
1188
  const lines = (stdout) => stdout.split("\n").map((line) => line.trim()).filter(Boolean);
1174
- const alive = await this.#run(["ps", "-a", "--no-trunc", "--filter", `label=${COMPUTER_LABEL}=1`, "--format", "{{.Names}}"], signal);
1175
- if (!alive.ok)
1176
- return alive;
1177
- if (alive.value.exitCode !== 0)
1178
- return vendorFail("docker", `docker ps failed: ${alive.value.stderr.trim()}`);
1179
- const computers = new Set(lines(alive.value.stdout).filter((name) => NAME.test(name)));
1180
1189
  const at = now.getTime();
1181
1190
  const grace = this.#leftoverGraceMs();
1182
- const leftover = (labelsOf, created) => {
1191
+ // The computer a part was made for, when its labels and age allow it to be a leftover at all.
1192
+ const candidate = (labelsOf, created) => {
1183
1193
  const owner = labelsOf?.[EGRESS_LABEL];
1184
- const deadline = Date.parse(labelsOf?.[DEADLINE_LABEL] ?? "");
1185
1194
  if (typeof owner !== "string" || !NAME.test(owner))
1186
- return false;
1195
+ return undefined;
1196
+ if (labelsOf?.[OWNER_LABEL] !== undefined || labelsOf?.[OWNER_SERVER_LABEL] !== undefined)
1197
+ return undefined;
1198
+ const deadline = Date.parse(labelsOf?.[DEADLINE_LABEL] ?? "");
1187
1199
  if (Number.isNaN(deadline) || deadline <= at)
1188
- return true;
1189
- if (computers.has(owner))
1190
- return false;
1200
+ return owner;
1191
1201
  const made = typeof created === "string" ? Date.parse(created) : Number.NaN;
1192
- return Number.isNaN(made) || at - made > grace;
1202
+ return Number.isNaN(made) || at - made > grace ? owner : undefined;
1203
+ };
1204
+ // The caller's, when it says whose are its own: by the labels the leftover carries.
1205
+ const owned = async (labelsOf) => mine === undefined || (await mine({ ...(labelsOf ?? {}) })) === true;
1206
+ // Whether computer `name` is gone, read now: a container of that name, or a read that fails, says it is not.
1207
+ const gone = async (name) => {
1208
+ const found = await this.#inspect([name], signal);
1209
+ if (!found.ok)
1210
+ return signal?.aborted ? found : ok(false);
1211
+ return ok(found.value.length === 0);
1212
+ };
1213
+ // A part to remove: a candidate, the caller's, and its computer gone, read in that order.
1214
+ const removable = async (labelsOf, created) => {
1215
+ const computer = candidate(labelsOf, created);
1216
+ if (computer === undefined || !(await owned(labelsOf)))
1217
+ return ok(false);
1218
+ return gone(computer);
1193
1219
  };
1194
1220
  const removed = [];
1195
1221
  const ps = await this.#run(["ps", "-a", "--no-trunc", ...filters, "--format", "{{.ID}}"], signal);
@@ -1203,12 +1229,17 @@ export class DockerProvider {
1203
1229
  if (!found.ok)
1204
1230
  return found;
1205
1231
  for (const proxy of found.value) {
1206
- if (!leftover(proxy.Config?.Labels, proxy.Created) || typeof proxy.Id !== "string")
1232
+ if (typeof proxy.Id !== "string")
1233
+ continue;
1234
+ const take = await removable(proxy.Config?.Labels, proxy.Created);
1235
+ if (!take.ok)
1236
+ return take;
1237
+ if (!take.value)
1207
1238
  continue;
1208
1239
  const ran = await this.#run(["rm", "--force", proxy.Id], signal);
1209
1240
  if (!ran.ok)
1210
1241
  return ran;
1211
- const gone = await this.#gone(ran.value, proxy.Id, `docker rm of the egress proxy ${nameOf(proxy)}`, AbortSignal.timeout(SETTLE_MS), signal);
1242
+ const gone = await this.#gone(ran.value, proxy.Id, `docker rm of the egress proxy ${nameOf(proxy)}`, AbortSignal.timeout(this.#settleBounds.settleMs), signal);
1212
1243
  if (!gone.ok)
1213
1244
  return gone;
1214
1245
  removed.push(nameOf(proxy));
@@ -1232,7 +1263,12 @@ export class DockerProvider {
1232
1263
  catch {
1233
1264
  return vendorFail("docker", `docker volume inspect wrote a line that is not JSON: ${line.slice(0, 200)}`);
1234
1265
  }
1235
- if (typeof volume.Name !== "string" || !leftover(volume.Labels, volume.CreatedAt))
1266
+ if (typeof volume.Name !== "string")
1267
+ continue;
1268
+ const take = await removable(volume.Labels, volume.CreatedAt);
1269
+ if (!take.ok)
1270
+ return take;
1271
+ if (!take.value)
1236
1272
  continue;
1237
1273
  const ran = await this.#run(["volume", "rm", "--force", volume.Name], signal);
1238
1274
  if (!ran.ok)
@@ -1296,12 +1332,12 @@ export class DockerProvider {
1296
1332
  /**
1297
1333
  * An allowlist proxy and its volume that one create made for a computer it never ran: each only when it carries that
1298
1334
  * create's attempt (ATTEMPT_LABEL) with the computer's egress label, found by both as release finds a proxy, the
1299
- * proxy removed by its id. One another create of the request made stays. Bounded by SETTLE_MS, never the caller's
1335
+ * proxy removed by its id. One another create of the request made stays. Bounded by settleMs, never the caller's
1300
1336
  * signal, which may have ended.
1301
1337
  */
1302
1338
  async #removeProxy(name, attempt) {
1303
1339
  const proxy = egressNameOf(name);
1304
- const bound = AbortSignal.timeout(SETTLE_MS);
1340
+ const bound = AbortSignal.timeout(this.#settleBounds.settleMs);
1305
1341
  const filters = ["--filter", `label=${EGRESS_LABEL}=${name}`, "--filter", `label=${ATTEMPT_LABEL}=${attempt}`];
1306
1342
  const lines = (text) => text.split("\n").map((line) => line.trim()).filter(Boolean);
1307
1343
  const found = await this.#run(["ps", "-a", "--no-trunc", ...filters, "--format", "{{.ID}}"], bound);
@@ -1359,78 +1395,104 @@ export class DockerProvider {
1359
1395
  * What one create made under the name, removed after its computer's docker run failed or was cut off: the container
1360
1396
  * that carries its attempt (ATTEMPT_LABEL), and the allowlist proxy and volume it made (#removeProxy). A container
1361
1397
  * another create of the request made under the name, in another process or before this one, is left as it is, with
1362
- * its proxy and volume: true then. The look is bounded (SETTLE_MS), never the caller's signal, which may have ended.
1398
+ * its proxy and volume: true then. The look is bounded (settleMs), never the caller's signal, which may have ended.
1363
1399
  */
1364
1400
  async #removeAttempt(name, attempt) {
1365
- const found = await this.#inspect([name], AbortSignal.timeout(SETTLE_MS));
1401
+ const found = await this.#inspect([name], AbortSignal.timeout(this.#settleBounds.settleMs));
1366
1402
  if (!found.ok)
1367
1403
  return found;
1368
1404
  const report = found.value.find((one) => nameOf(one) === name);
1369
1405
  const mine = report?.Config?.Labels?.[ATTEMPT_LABEL] === attempt;
1370
1406
  // By the id looked at, never by the name, which another create may hold by the time rm runs.
1407
+ // The proxy and volume go whether or not the computer could be removed: the computer's failure is the answer.
1408
+ let computer = ok(undefined);
1371
1409
  if (mine) {
1372
- const bound = AbortSignal.timeout(SETTLE_MS);
1410
+ const bound = AbortSignal.timeout(this.#settleBounds.settleMs);
1373
1411
  const removed = await this.#run(["rm", "--force", "--volumes", String(report.Id)], bound);
1374
- if (!removed.ok)
1375
- return removed;
1376
- const gone = await this.#gone(removed.value, String(report.Id), `docker rm ${name}`, bound);
1377
- if (!gone.ok)
1378
- return gone;
1412
+ computer = removed.ok ? await this.#gone(removed.value, String(report.Id), `docker rm ${name}`, bound) : removed;
1379
1413
  }
1380
1414
  const proxy = await this.#removeProxy(name, attempt);
1415
+ if (!computer.ok)
1416
+ return computer;
1381
1417
  return proxy.ok ? ok(report !== undefined && !mine) : proxy;
1382
1418
  }
1383
- /** release's work, which create also does for what it made before its computer ran (its request is not spent). */
1419
+ /**
1420
+ * release's work, which create also does for what it made before its computer ran (its request is not spent). Its
1421
+ * egress proxies are found by their label first, and a delete removes the computer and them in one docker rm, which
1422
+ * Docker's CLI sends together: a teardown cut off once that call is made (its process ended) leaves no proxy running
1423
+ * without its computer, and one cut off before it leaves both, for the janitor. A container that call did not remove
1424
+ * is asked again alone and waited for (#gone). Neither part's failure keeps the other from being removed (a computer
1425
+ * whose removal fails still has its proxy and volume removed): the first failure, the computer's before its proxy's,
1426
+ * is the answer. A stop stops the computer, then its proxies, the same way.
1427
+ */
1384
1428
  async #remove(ref, how) {
1385
- const args = how === "stop" ? ["stop", ref.name] : ["rm", "--force", "--volumes", ref.name];
1386
- const ran = await this.#run(args);
1387
- if (!ran.ok)
1388
- return ran;
1389
- const gone = await this.#gone(ran.value, ref.name, `docker ${args[0]} ${ref.name}`, AbortSignal.timeout(SETTLE_MS));
1390
- if (!gone.ok)
1391
- return gone;
1392
1429
  const label = `label=${EGRESS_LABEL}=${ref.name}`;
1430
+ const lines = (text) => text.split("\n").map((line) => line.trim()).filter(Boolean);
1393
1431
  const proxies = await this.#run(["ps", "-a", "--no-trunc", "--filter", label, "--format", "{{.ID}}"]);
1394
- if (!proxies.ok)
1395
- return proxies;
1396
- if (proxies.value.exitCode !== 0)
1397
- return vendorFail("docker", `docker ps for ${ref.name}'s egress proxy failed: ${proxies.value.stderr.trim()}`);
1398
- for (const id of proxies.value.stdout.split("\n").map((line) => line.trim()).filter(Boolean)) {
1399
- const ended = await this.#run(how === "stop" ? ["stop", id] : ["rm", "--force", id]);
1400
- if (!ended.ok)
1401
- return ended;
1402
- const gone = await this.#gone(ended.value, id, `docker ${how === "stop" ? "stop" : "rm"} of ${ref.name}'s egress proxy`, AbortSignal.timeout(SETTLE_MS));
1403
- if (!gone.ok)
1404
- return gone;
1432
+ const listed = !proxies.ok ? proxies : proxies.value.exitCode !== 0 ? vendorFail("docker", `docker ps for ${ref.name}'s egress proxy failed: ${proxies.value.stderr.trim()}`) : ok(lines(proxies.value.stdout));
1433
+ const ids = listed.ok ? listed.value : [];
1434
+ const proxyWords = `${ref.name}'s egress proxy`;
1435
+ // Every failure, in the order met: the first is the answer.
1436
+ const failures = [];
1437
+ const add = (result) => {
1438
+ if (!result.ok)
1439
+ failures.push(result.error);
1440
+ };
1441
+ const parts = (verb) => [[ref.name, `docker ${verb} ${ref.name}`], ...ids.map((id) => [id, `docker ${verb} of ${proxyWords}`])];
1442
+ if (how === "delete") {
1443
+ const all = await this.#run(["rm", "--force", "--volumes", ref.name, ...ids]);
1444
+ if (!all.ok)
1445
+ add(all);
1446
+ // Each one that call did not remove, asked again alone: one gone answers No such container, one whose removal is
1447
+ // under way is waited for, and any other answer is its failure in words.
1448
+ else if (all.value.exitCode !== 0) {
1449
+ for (const [key, what] of parts("rm")) {
1450
+ const again = await this.#run(["rm", "--force", ...(key === ref.name ? ["--volumes"] : []), key]);
1451
+ const gone = again.ok ? await this.#gone(again.value, key, what, AbortSignal.timeout(this.#settleBounds.settleMs)) : again;
1452
+ add(gone);
1453
+ }
1454
+ }
1405
1455
  }
1406
- if (how === "stop")
1407
- return ok(undefined);
1408
- const volumes = await this.#run(["volume", "ls", "--filter", label, "--format", "{{.Name}}"]);
1409
- if (!volumes.ok)
1410
- return volumes;
1411
- if (volumes.value.exitCode !== 0)
1412
- return vendorFail("docker", `docker volume ls for ${ref.name}'s egress volume failed: ${volumes.value.stderr.trim()}`);
1413
- for (const volume of volumes.value.stdout.split("\n").map((line) => line.trim()).filter(Boolean)) {
1414
- const removed = await this.#run(["volume", "rm", "--force", volume]);
1415
- if (!removed.ok)
1416
- return removed;
1417
- if (removed.value.exitCode !== 0)
1418
- return vendorFail("docker", `docker volume rm ${volume} failed: ${removed.value.stderr.trim()}`);
1456
+ else {
1457
+ for (const [key, what] of parts("stop")) {
1458
+ const ran = await this.#run(["stop", key]);
1459
+ const gone = ran.ok ? await this.#gone(ran.value, key, what, AbortSignal.timeout(this.#settleBounds.settleMs)) : ran;
1460
+ add(gone);
1461
+ }
1419
1462
  }
1420
- return ok(undefined);
1463
+ add(listed);
1464
+ if (how === "delete") {
1465
+ const volumes = await this.#run(["volume", "ls", "--filter", label, "--format", "{{.Name}}"]);
1466
+ if (!volumes.ok)
1467
+ add(volumes);
1468
+ else if (volumes.value.exitCode !== 0)
1469
+ add(vendorFail("docker", `docker volume ls for ${ref.name}'s egress volume failed: ${volumes.value.stderr.trim()}`));
1470
+ else {
1471
+ for (const volume of lines(volumes.value.stdout)) {
1472
+ const removed = await this.#run(["volume", "rm", "--force", volume]);
1473
+ if (!removed.ok)
1474
+ add(removed);
1475
+ else if (removed.value.exitCode !== 0)
1476
+ add(vendorFail("docker", `docker volume rm ${volume} failed: ${removed.value.stderr.trim()}`));
1477
+ }
1478
+ }
1479
+ }
1480
+ const [first] = failures;
1481
+ return first === undefined ? ok(undefined) : { ok: false, error: first };
1421
1482
  }
1422
1483
  /**
1423
1484
  * Whether the docker rm (or stop) that answered `ran` left container `key` gone, `what` naming the call: ok on exit 0
1424
1485
  * or "No such container". "Removal of container ... is already in progress" means another removal of it is under way,
1425
1486
  * so it is going away: it is looked for, SETTLE_EVERY_MS apart, until it is gone (ok), the caller's `signal` aborts
1426
1487
  * (aborted), or `bound` runs out with it still there (a failure that names it). Every other answer is the failure it is.
1488
+ * `bound` is the settleMs bound every caller passes (default SETTLE_MS), which the failure's words name: never a time
1489
+ * measured here, which a late wake-up would overstate.
1427
1490
  */
1428
1491
  async #gone(ran, key, what, bound, signal) {
1429
1492
  if (ran.exitCode === 0 || noSuchContainer(ran.stderr))
1430
1493
  return ok(undefined);
1431
1494
  if (!removalUnderWay(ran.stderr))
1432
1495
  return vendorFail("docker", `${what} failed: ${ran.stderr.trim()}`);
1433
- const from = Date.now();
1434
1496
  const either = signal ? AbortSignal.any([signal, bound]) : bound;
1435
1497
  for (;;) {
1436
1498
  const look = await this.#inspect([key], either, "{{json .Id}}");
@@ -1439,7 +1501,7 @@ export class DockerProvider {
1439
1501
  if (signal?.aborted)
1440
1502
  return fail("aborted", `${what} was aborted while docker was still removing ${key}`);
1441
1503
  if (bound.aborted)
1442
- return vendorFail("docker", `${what} failed: docker answered that the removal of ${key} was already in progress, and it was still there ${Math.round((Date.now() - from) / 1000)} s later`);
1504
+ return vendorFail("docker", `${what} failed: docker answered that the removal of ${key} was already in progress, and it was still there when the ${this.#settleBounds.settleMs / 1000} s bound ran out`);
1443
1505
  if (!look.ok)
1444
1506
  return look;
1445
1507
  await sleep(SETTLE_EVERY_MS, undefined, { signal: either }).catch(() => undefined);
@@ -1467,7 +1529,7 @@ export class DockerProvider {
1467
1529
  }
1468
1530
  #run(args, signal) {
1469
1531
  return new Promise((done) => {
1470
- execFile(this.#docker, args, { signal, encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }, (error, stdout, stderr) => {
1532
+ execFile(this.#docker, args, { env: this.#env, signal, encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }, (error, stdout, stderr) => {
1471
1533
  if (error === null)
1472
1534
  return done(ok({ exitCode: 0, stdout, stderr }));
1473
1535
  if (error.name === "AbortError")
@@ -1519,6 +1581,18 @@ function infoOf(report, proxy, code, local, volume) {
1519
1581
  }
1520
1582
  /** The longest delay Node's timers, and so AbortSignal.timeout, hold: 2^31 - 1 ms. */
1521
1583
  const MAX_TIMER_MS = 2_147_483_647;
1584
+ /**
1585
+ * The settleMs and settleQuietMs options as #settle's bounds, with their defaults (SETTLE_MS, SETTLE_QUIET_MS), or a throw
1586
+ * in words: each is a whole number of milliseconds above 0 that a timer can hold. The one place the defaults are applied:
1587
+ * the constructor and settleWords both read it. Exported for its test, which reads the defaults instead of waiting them out.
1588
+ */
1589
+ export function settleBoundsOf({ settleMs = SETTLE_MS, settleQuietMs = SETTLE_QUIET_MS }) {
1590
+ for (const [name, ms] of [["settleMs", settleMs], ["settleQuietMs", settleQuietMs]]) {
1591
+ if (!Number.isSafeInteger(ms) || ms <= 0 || ms > MAX_TIMER_MS)
1592
+ throw new Error(`the provider's ${name} must be a whole number of milliseconds above 0 and at most ${MAX_TIMER_MS}, not ${ms}`);
1593
+ }
1594
+ return { settleMs, quietMs: settleQuietMs };
1595
+ }
1522
1596
  /** The egress options with their defaults, or a throw in words. */
1523
1597
  function egressOptionsOf({ image = EGRESS_IMAGE, hint, readyMs = EGRESS_READY_MS, hostAddresses: given, hostRoot = "/" }) {
1524
1598
  if (typeof hostRoot !== "string" || !hostRoot.startsWith("/"))