@usine/executor 0.3.0 → 0.4.1-next.240.g158c84b

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 (185) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +116 -19
  3. package/dist/child-command.d.ts +1 -1
  4. package/dist/child-command.d.ts.map +1 -1
  5. package/dist/child-command.js +6 -4
  6. package/dist/child-command.js.map +1 -1
  7. package/dist/child-environment.d.ts +19 -0
  8. package/dist/child-environment.d.ts.map +1 -0
  9. package/dist/child-environment.js +18 -0
  10. package/dist/child-environment.js.map +1 -0
  11. package/dist/claude-login-lock.d.ts +3 -2
  12. package/dist/claude-login-lock.d.ts.map +1 -1
  13. package/dist/claude-login-lock.js +10 -4
  14. package/dist/claude-login-lock.js.map +1 -1
  15. package/dist/cloudflare/client.d.ts +50 -0
  16. package/dist/cloudflare/client.d.ts.map +1 -0
  17. package/dist/cloudflare/client.js +108 -0
  18. package/dist/cloudflare/client.js.map +1 -0
  19. package/dist/cloudflare/cloudflare.d.ts +17 -0
  20. package/dist/cloudflare/cloudflare.d.ts.map +1 -0
  21. package/dist/cloudflare/cloudflare.js +704 -0
  22. package/dist/cloudflare/cloudflare.js.map +1 -0
  23. package/dist/cloudflare/model.d.ts +42 -0
  24. package/dist/cloudflare/model.d.ts.map +1 -0
  25. package/dist/cloudflare/model.js +2 -0
  26. package/dist/cloudflare/model.js.map +1 -0
  27. package/dist/cloudflare/shell/environment.d.ts +12 -0
  28. package/dist/cloudflare/shell/environment.d.ts.map +1 -0
  29. package/dist/cloudflare/shell/environment.js +12 -0
  30. package/dist/cloudflare/shell/environment.js.map +1 -0
  31. package/dist/cloudflare/shell/shell.d.ts +2 -0
  32. package/dist/cloudflare/shell/shell.d.ts.map +1 -0
  33. package/dist/cloudflare/shell/shell.js +155 -0
  34. package/dist/cloudflare/shell/shell.js.map +1 -0
  35. package/dist/durable-session.d.ts +21 -3
  36. package/dist/durable-session.d.ts.map +1 -1
  37. package/dist/durable-session.js +69 -10
  38. package/dist/durable-session.js.map +1 -1
  39. package/dist/exe-dev/commands.d.ts +1 -1
  40. package/dist/exe-dev/commands.d.ts.map +1 -1
  41. package/dist/exe-dev/exe-dev.d.ts +1 -1
  42. package/dist/exe-dev/exe-dev.d.ts.map +1 -1
  43. package/dist/exe-dev/exe-dev.js +9 -1
  44. package/dist/exe-dev/exe-dev.js.map +1 -1
  45. package/dist/exe-dev/preflight.d.ts +2 -2
  46. package/dist/exe-dev/preflight.d.ts.map +1 -1
  47. package/dist/exe-dev/preflight.js +5 -4
  48. package/dist/exe-dev/preflight.js.map +1 -1
  49. package/dist/executor.d.ts +164 -15
  50. package/dist/executor.d.ts.map +1 -1
  51. package/dist/executor.js +100 -3
  52. package/dist/executor.js.map +1 -1
  53. package/dist/guard.d.ts.map +1 -1
  54. package/dist/guard.js +1 -0
  55. package/dist/guard.js.map +1 -1
  56. package/dist/harness-preflight.d.ts +9 -8
  57. package/dist/harness-preflight.d.ts.map +1 -1
  58. package/dist/harness-preflight.js +15 -10
  59. package/dist/harness-preflight.js.map +1 -1
  60. package/dist/local/local.d.ts +1 -1
  61. package/dist/local/local.d.ts.map +1 -1
  62. package/dist/local/local.js +76 -37
  63. package/dist/local/local.js.map +1 -1
  64. package/dist/memory-preflight.d.ts +3 -1
  65. package/dist/memory-preflight.d.ts.map +1 -1
  66. package/dist/memory-preflight.js +1 -1
  67. package/dist/memory-preflight.js.map +1 -1
  68. package/dist/pre-push-hook.d.ts +1 -1
  69. package/dist/pre-push-hook.js +1 -1
  70. package/dist/prepared-attempt.d.ts +8 -0
  71. package/dist/prepared-attempt.d.ts.map +1 -1
  72. package/dist/prepared-attempt.js.map +1 -1
  73. package/dist/provision.d.ts +64 -13
  74. package/dist/provision.d.ts.map +1 -1
  75. package/dist/provision.js +99 -42
  76. package/dist/provision.js.map +1 -1
  77. package/dist/remote/commands.d.ts +1 -1
  78. package/dist/remote/commands.d.ts.map +1 -1
  79. package/dist/remote/commands.js +1 -1
  80. package/dist/remote/commands.js.map +1 -1
  81. package/dist/remote/container.d.ts +90 -0
  82. package/dist/remote/container.d.ts.map +1 -0
  83. package/dist/remote/container.js +480 -0
  84. package/dist/remote/container.js.map +1 -0
  85. package/dist/remote/liveness.d.ts +1 -1
  86. package/dist/remote/liveness.d.ts.map +1 -1
  87. package/dist/remote/liveness.js +6 -4
  88. package/dist/remote/liveness.js.map +1 -1
  89. package/dist/remote/machine.d.ts +52 -6
  90. package/dist/remote/machine.d.ts.map +1 -1
  91. package/dist/remote/remote.d.ts +11 -7
  92. package/dist/remote/remote.d.ts.map +1 -1
  93. package/dist/remote/remote.js +340 -92
  94. package/dist/remote/remote.js.map +1 -1
  95. package/dist/remote/sweep.d.ts +3 -1
  96. package/dist/remote/sweep.d.ts.map +1 -1
  97. package/dist/remote/sweep.js +2 -1
  98. package/dist/remote/sweep.js.map +1 -1
  99. package/dist/salvage.d.ts +18 -10
  100. package/dist/salvage.d.ts.map +1 -1
  101. package/dist/salvage.js +123 -29
  102. package/dist/salvage.js.map +1 -1
  103. package/dist/ssh/api-keys.d.ts +36 -0
  104. package/dist/ssh/api-keys.d.ts.map +1 -0
  105. package/dist/ssh/api-keys.js +72 -0
  106. package/dist/ssh/api-keys.js.map +1 -0
  107. package/dist/ssh/codex-homes.d.ts +21 -0
  108. package/dist/ssh/codex-homes.d.ts.map +1 -0
  109. package/dist/ssh/codex-homes.js +78 -0
  110. package/dist/ssh/codex-homes.js.map +1 -0
  111. package/dist/ssh/container.d.ts +32 -0
  112. package/dist/ssh/container.d.ts.map +1 -0
  113. package/dist/ssh/container.js +282 -0
  114. package/dist/ssh/container.js.map +1 -0
  115. package/dist/ssh/credentials.d.ts +3 -0
  116. package/dist/ssh/credentials.d.ts.map +1 -1
  117. package/dist/ssh/credentials.js +3 -0
  118. package/dist/ssh/credentials.js.map +1 -1
  119. package/dist/ssh/gateway/admin.d.ts +1 -1
  120. package/dist/ssh/gateway/admin.d.ts.map +1 -1
  121. package/dist/ssh/gateway/admin.js +2 -2
  122. package/dist/ssh/gateway/admin.js.map +1 -1
  123. package/dist/ssh/gateway/attachments.d.ts +15 -6
  124. package/dist/ssh/gateway/attachments.d.ts.map +1 -1
  125. package/dist/ssh/gateway/attachments.js +39 -25
  126. package/dist/ssh/gateway/attachments.js.map +1 -1
  127. package/dist/ssh/gateway/environment.d.ts +21 -2
  128. package/dist/ssh/gateway/environment.d.ts.map +1 -1
  129. package/dist/ssh/gateway/environment.js +76 -6
  130. package/dist/ssh/gateway/environment.js.map +1 -1
  131. package/dist/ssh/gateway/forward.d.ts +1 -1
  132. package/dist/ssh/gateway/forward.d.ts.map +1 -1
  133. package/dist/ssh/gateway/forward.js +1 -1
  134. package/dist/ssh/gateway/forward.js.map +1 -1
  135. package/dist/ssh/gateway/preflight.d.ts +51 -12
  136. package/dist/ssh/gateway/preflight.d.ts.map +1 -1
  137. package/dist/ssh/gateway/preflight.js +155 -69
  138. package/dist/ssh/gateway/preflight.js.map +1 -1
  139. package/dist/ssh/limits.d.ts +60 -0
  140. package/dist/ssh/limits.d.ts.map +1 -0
  141. package/dist/ssh/limits.js +84 -0
  142. package/dist/ssh/limits.js.map +1 -0
  143. package/dist/ssh/model.d.ts +97 -9
  144. package/dist/ssh/model.d.ts.map +1 -1
  145. package/dist/ssh/preflight.d.ts +26 -7
  146. package/dist/ssh/preflight.d.ts.map +1 -1
  147. package/dist/ssh/preflight.js +50 -10
  148. package/dist/ssh/preflight.js.map +1 -1
  149. package/dist/ssh/provisioner/boat.d.ts +33 -0
  150. package/dist/ssh/provisioner/boat.d.ts.map +1 -0
  151. package/dist/ssh/provisioner/boat.js +247 -0
  152. package/dist/ssh/provisioner/boat.js.map +1 -0
  153. package/dist/ssh/provisioner/hetzner.d.ts +32 -0
  154. package/dist/ssh/provisioner/hetzner.d.ts.map +1 -0
  155. package/dist/ssh/provisioner/hetzner.js +337 -0
  156. package/dist/ssh/provisioner/hetzner.js.map +1 -0
  157. package/dist/ssh/provisioner/host-key.d.ts +11 -0
  158. package/dist/ssh/provisioner/host-key.d.ts.map +1 -0
  159. package/dist/ssh/provisioner/host-key.js +57 -0
  160. package/dist/ssh/provisioner/host-key.js.map +1 -0
  161. package/dist/ssh/provisioner/http.d.ts +45 -0
  162. package/dist/ssh/provisioner/http.d.ts.map +1 -0
  163. package/dist/ssh/provisioner/http.js +72 -0
  164. package/dist/ssh/provisioner/http.js.map +1 -0
  165. package/dist/ssh/provisioner/machines.d.ts +48 -0
  166. package/dist/ssh/provisioner/machines.d.ts.map +1 -0
  167. package/dist/ssh/provisioner/machines.js +686 -0
  168. package/dist/ssh/provisioner/machines.js.map +1 -0
  169. package/dist/ssh/provisioner/model.d.ts +92 -0
  170. package/dist/ssh/provisioner/model.d.ts.map +1 -0
  171. package/dist/ssh/provisioner/model.js +37 -0
  172. package/dist/ssh/provisioner/model.js.map +1 -0
  173. package/dist/ssh/ssh.d.ts +14 -11
  174. package/dist/ssh/ssh.d.ts.map +1 -1
  175. package/dist/ssh/ssh.js +94 -27
  176. package/dist/ssh/ssh.js.map +1 -1
  177. package/dist/ssh/worker-records.d.ts +18 -0
  178. package/dist/ssh/worker-records.d.ts.map +1 -0
  179. package/dist/ssh/worker-records.js +100 -0
  180. package/dist/ssh/worker-records.js.map +1 -0
  181. package/dist/ssh/workers.d.ts +34 -7
  182. package/dist/ssh/workers.d.ts.map +1 -1
  183. package/dist/ssh/workers.js +92 -18
  184. package/dist/ssh/workers.js.map +1 -1
  185. package/package.json +19 -11
@@ -1,3 +1,5 @@
1
+ import { SSH_FAILURE } from "@usine/agents/child-host";
2
+ import { unsupportedCodexVersion } from "@usine/agents/preflight";
1
3
  import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
2
4
  import { Effect, Option, Redacted, Ref } from "effect";
3
5
  import { ExecutorOperationError, WorkerCapabilityError } from "../../executor.js";
@@ -14,8 +16,6 @@ done
14
16
  `.trim();
15
17
  /** Matches the Gateway's refusal header for a request without a caller token. */
16
18
  const REFUSED_WITHOUT_TOKEN = /^x-usine-gateway-refusal:\s*missing-caller-token\s*$/imu;
17
- /** The exit code OpenSSH uses when it can't connect to the machine or run the command. */
18
- const SSH_FAILURE = 255;
19
19
  const gatewayGap = (worker, message, cause) => new WorkerCapabilityError({ worker, capability: "gateway", message, cause });
20
20
  /** Returns the error for an SSH transport failure, which isn't a capability gap. */
21
21
  const unreachable = (host, command, result) => new ExecutorOperationError({
@@ -30,59 +30,108 @@ const unreachable = (host, command, result) => new ExecutorOperationError({
30
30
  const warnOfUnreportedCredential = (worker, gateway) => Ref.getAndSet(gateway.warnedOfUnreportedCredential, true).pipe(Effect.flatMap((warned) => warned
31
31
  ? Effect.logDebug("SSH Worker's Gateway still does not report the kind of its Anthropic credential; already warned for this Worker", { worker, gateway: gateway.forward.gateway })
32
32
  : Effect.logWarning("SSH Worker's Gateway does not report the kind of its Anthropic credential; its Claude Code children count in the Claude plan pool until the Gateway is upgraded", { worker, gateway: gateway.forward.gateway })));
33
+ /** Each provider's display name and the Gateway variables that set its credential. */
34
+ const PROVIDER_CREDENTIALS = {
35
+ anthropic: {
36
+ label: "Anthropic",
37
+ variables: "ANTHROPIC_API_KEY or USINE_GATEWAY_ANTHROPIC_SUBSCRIPTION_TOKEN",
38
+ },
39
+ openai: { label: "OpenAI", variables: "OPENAI_API_KEY or USINE_GATEWAY_CHATGPT_AUTH_FILE" },
40
+ };
41
+ const NO_CREDENTIALS = { anthropic: Option.none(), openai: Option.none() };
33
42
  /**
34
- * Reads the Gateway's Anthropic credential kind and records it for the Worker (ADR 0013).
35
- * Fails if the Worker's `llmProviders` includes Anthropic and the Gateway has no Anthropic
36
- * credential. If the Gateway is too old to report credentials, keeps the Claude plan pool and
37
- * logs a warning.
43
+ * Reads the Gateway's credential kind for each provider in the Worker's `llmProviders` and
44
+ * records them for the Worker (ADR 0013). Fails if the Gateway has no credential for a listed
45
+ * provider. If the Gateway is too old to report credentials, keeps the Claude plan pool for
46
+ * Anthropic with a warning, and fails for OpenAI, which such a Gateway can't serve for Codex.
38
47
  */
39
- const recordAnthropicCredential = Effect.fn("SshExecutor.recordAnthropicCredential")(function* (worker, gateway) {
40
- yield* Effect.annotateCurrentSpan({ worker, gateway: gateway.forward.gateway });
41
- const reported = yield* gateway.admin.providers.pipe(Effect.mapError((error) => gatewayGap(worker, error.message, error)));
42
- const credential = yield* Option.match(reported, {
43
- onNone: () => warnOfUnreportedCredential(worker, gateway).pipe(Effect.as(Option.none())),
44
- onSome: ({ providers }) => {
45
- const anthropic = providers.find(({ provider }) => provider === "anthropic");
46
- return anthropic === undefined
47
- ? Effect.fail(gatewayGap(worker, `The gateway of SSH worker "${worker}" has no Anthropic credential, but the worker's llm_providers includes anthropic. Set ANTHROPIC_API_KEY or USINE_GATEWAY_ANTHROPIC_SUBSCRIPTION_TOKEN on the gateway, or remove anthropic from llm_providers.`, new Error(`the gateway reports ${providers.map(({ provider }) => provider).join(", ") || "no provider"}`)))
48
- : Effect.succeed(Option.some(anthropic.credential));
49
- },
48
+ const recordProviderCredentials = Effect.fn("SshExecutor.recordProviderCredentials")(function* (worker, gateway) {
49
+ const listed = gateway.settings.llmProviders;
50
+ yield* Effect.annotateCurrentSpan({
51
+ worker,
52
+ gateway: gateway.forward.gateway,
53
+ llmProviders: listed.join(","),
50
54
  });
51
- yield* Ref.set(gateway.anthropicCredential, credential);
52
- return credential;
55
+ if (listed.length === 0) {
56
+ yield* Ref.set(gateway.credentials, NO_CREDENTIALS);
57
+ return NO_CREDENTIALS;
58
+ }
59
+ const reported = yield* gateway.admin.providers.pipe(Effect.mapError((error) => gatewayGap(worker, error.message, error)));
60
+ if (Option.isNone(reported)) {
61
+ if (listed.includes("openai"))
62
+ return yield* gatewayGap(worker, `The gateway of SSH worker "${worker}" doesn't report its LLM credentials, so Codex can't use its OpenAI credential. Upgrade @usine/gateway on the gateway, or remove openai from llm_providers.`, new Error("the gateway answered 404 for GET /v1/providers"));
63
+ yield* warnOfUnreportedCredential(worker, gateway);
64
+ yield* Ref.set(gateway.credentials, NO_CREDENTIALS);
65
+ return NO_CREDENTIALS;
66
+ }
67
+ const { providers } = reported.value;
68
+ const kindOf = (provider) => Option.fromNullishOr(providers.find((held) => held.provider === provider)?.credential);
69
+ const missing = listed.find((provider) => Option.isNone(kindOf(provider)));
70
+ if (missing !== undefined)
71
+ return yield* gatewayGap(worker, `The gateway of SSH worker "${worker}" has no ${PROVIDER_CREDENTIALS[missing].label} credential, but the worker's llm_providers includes ${missing}. Set ${PROVIDER_CREDENTIALS[missing].variables} on the gateway, or remove ${missing} from llm_providers.`, new Error(`the gateway reports ${providers.map(({ provider }) => provider).join(", ") || "no provider"}`));
72
+ const credentials = {
73
+ anthropic: listed.includes("anthropic") ? kindOf("anthropic") : Option.none(),
74
+ openai: listed.includes("openai") ? kindOf("openai") : Option.none(),
75
+ };
76
+ yield* Ref.set(gateway.credentials, credentials);
77
+ return credentials;
78
+ });
79
+ /** Returns how a provider's harness authenticates on the Worker, for log lines. */
80
+ const credentialMode = (kind, listed) => Option.match(kind, {
81
+ onNone: () => (listed ? "gateway-unreported" : "worker-login"),
82
+ onSome: (credential) => `gateway-${credential}`,
53
83
  });
54
84
  /**
55
85
  * Returns the credential kind the Gateway injects for `harness`, as recorded by the last
56
- * preflight. Only Claude Code uses a Gateway credential; Codex and Pi use their own logins.
86
+ * preflight: Anthropic's for Claude Code, OpenAI's for Codex. Pi uses its own login.
57
87
  */
58
88
  export const gatewayCredentialFor = (gateway, harness) => {
59
89
  switch (harness) {
60
90
  case "claude":
61
- return Ref.get(gateway.anthropicCredential);
91
+ return Effect.map(Ref.get(gateway.credentials), ({ anthropic }) => anthropic);
62
92
  case "codex":
93
+ return Effect.map(Ref.get(gateway.credentials), ({ openai }) => openai);
63
94
  case "pi":
64
95
  return Effect.succeedNone;
65
96
  }
66
97
  };
67
98
  /**
68
- * Verifies the Gateway in front of an SSH Worker without attaching anything: the admin API
69
- * forward opens and accepts the admin token, the machine's sshd accepts the caller-token
70
- * variables, and the machine can connect to `git.<domain>`, which rejects a request without a caller
71
- * token. If the Gateway has the Anthropic credential, records its kind for the Worker.
99
+ * Verifies the Gateway's admin API for an SSH Worker without attaching anything: the forward
100
+ * opens and the admin API accepts the admin token. Records the Gateway's credential kind for
101
+ * each provider in the Worker's `llmProviders`. Needs no Worker machine.
72
102
  */
73
- export const verifyGateway = Effect.fn("SshExecutor.verifyGateway")(function* (commands, worker, machine, gateway) {
103
+ export const verifyGatewayAdmin = Effect.fn("SshExecutor.verifyGatewayAdmin")(function* (worker, gateway) {
74
104
  const { admin, forward, settings } = gateway;
75
- const gitHost = `git.${settings.domain}`;
76
105
  yield* Effect.annotateCurrentSpan({ worker, domain: settings.domain, gateway: forward.gateway });
77
106
  const open = yield* forward.current.pipe(Effect.catchTag("GatewayForwardClosed", (closed) => forward.reopen(closed.generation)), Effect.mapError((closed) => gatewayGap(worker, `Can't open the forward to the gateway admin API of SSH worker "${worker}" through ${closed.gateway}: ${closed.reason}. Run ${forward.command} to see the SSH error.`, closed)));
78
107
  const { attachments } = yield* admin.list.pipe(Effect.mapError((error) => gatewayGap(worker, error.message, error)));
79
- const anthropicCredential = settings.llmProviders.includes("anthropic")
80
- ? yield* recordAnthropicCredential(worker, gateway)
81
- : Option.none();
108
+ const credentials = yield* recordProviderCredentials(worker, gateway);
109
+ yield* Effect.logInfo("SSH Worker Gateway admin API verified", {
110
+ worker,
111
+ domain: settings.domain,
112
+ gateway: forward.gateway,
113
+ adminPort: settings.adminPort,
114
+ forwardPort: open.url.port,
115
+ llmProviders: settings.llmProviders.join(","),
116
+ anthropic: credentialMode(credentials.anthropic, settings.llmProviders.includes("anthropic")),
117
+ openai: credentialMode(credentials.openai, settings.llmProviders.includes("openai")),
118
+ attachments: attachments.filter((attachment) => attachment.worker === worker).length,
119
+ });
120
+ });
121
+ /**
122
+ * Verifies the Gateway from an SSH Worker's machine without attaching anything: the machine's
123
+ * sshd accepts the caller-token variables, and the machine can connect to `git.<domain>`, which
124
+ * rejects a request without a caller token.
125
+ */
126
+ const verifyGatewayFromMachine = Effect.fn("SshExecutor.verifyGatewayFromMachine")(function* (commands, worker, machine, gateway) {
127
+ const { forward, settings } = gateway;
128
+ const gitHost = `git.${settings.domain}`;
129
+ yield* Effect.annotateCurrentSpan({ worker, domain: settings.domain, gateway: forward.gateway });
82
130
  const { sent } = gatewayEnvironment({
83
131
  domain: settings.domain,
84
132
  llmProviders: settings.llmProviders,
85
133
  ghConfigDirectory: machine.workerDirectory,
134
+ codexHome: machine.workerDirectory,
86
135
  callerToken: PROBE_TOKEN,
87
136
  });
88
137
  const received = yield* commands.run("preflight", sendingShell(machine.shell, sent), "sh", [
@@ -112,25 +161,67 @@ export const verifyGateway = Effect.fn("SshExecutor.verifyGateway")(function* (c
112
161
  return yield* gatewayGap(worker, `SSH worker "${worker}" can't reach its gateway at ${gitHost}`, new Error(probed.stderr.trim() ||
113
162
  probed.stdout.split("\n")[0]?.trim() ||
114
163
  `curl exited with code ${String(probed.exitCode)}`));
115
- yield* Effect.logInfo("SSH Worker Gateway verified", {
164
+ yield* Effect.logInfo("SSH Worker reaches its Gateway", {
116
165
  worker,
166
+ host: machine.shell.destination,
117
167
  domain: settings.domain,
118
168
  gateway: forward.gateway,
119
- adminPort: settings.adminPort,
120
- forwardPort: open.url.port,
121
- llmProviders: settings.llmProviders.join(","),
122
- anthropicCredential: Option.getOrElse(anthropicCredential, () => "none"),
123
- attachments: attachments.filter((attachment) => attachment.worker === worker).length,
124
169
  });
125
170
  });
126
171
  /**
127
- * The harnesses that can use the operator's login on the machine, with the hosts each login
128
- * calls through the forward proxy. `infra/hetzner/gateway/egress-allowlist` lists the same
129
- * hosts.
172
+ * Verifies the Gateway in front of an SSH Worker without attaching anything: the admin API
173
+ * checks of `verifyGatewayAdmin`, then the machine checks of `verifyGatewayFromMachine`.
174
+ */
175
+ export const verifyGateway = (commands, worker, machine, gateway) => verifyGatewayAdmin(worker, gateway).pipe(Effect.andThen(verifyGatewayFromMachine(commands, worker, machine, gateway)));
176
+ /**
177
+ * Checks only the binary of a harness whose credential the machine doesn't keep, the Gateway's
178
+ * or an API key in the Attempt's environment, named by `credential` in the log. Codex's version
179
+ * must also be supported.
180
+ */
181
+ export const harnessBinaryProbe = Effect.fn("SshExecutor.probeHarnessBinary")(function* (commands, host, shell, harness, credential) {
182
+ const label = harness === "claude" ? "Claude Code" : "Codex";
183
+ yield* Effect.annotateCurrentSpan({ host, harness, credential });
184
+ const result = yield* commands.inspect("preflight", shell, harness, ["--version"]);
185
+ if (result.exitCode === SSH_FAILURE)
186
+ return yield* unreachable(host, harness, result);
187
+ if (result.exitCode !== 0)
188
+ return new HarnessUnavailableError({
189
+ harness,
190
+ capability: "binary",
191
+ message: `${harness} --version failed. Check the ${label} installation on the worker.`,
192
+ });
193
+ const version = result.stdout.trim();
194
+ const unsupported = harness === "codex" ? unsupportedCodexVersion(version) : Option.none();
195
+ if (Option.isSome(unsupported))
196
+ return unsupported.value;
197
+ yield* Effect.logInfo(`${label} uses ${credential}; checked its binary only`, {
198
+ host,
199
+ harness,
200
+ version,
201
+ });
202
+ return new HarnessReady({ harness });
203
+ });
204
+ /**
205
+ * The harnesses that can use the operator's login on the machine or the Gateway's credential
206
+ * for their provider, with the hosts each login calls through the forward proxy, which
207
+ * `infra/hetzner/gateway/egress-allowlist` lists, and the API host that an API key in the
208
+ * Attempt's environment calls.
130
209
  */
131
210
  const LOGINS = {
132
- claude: { label: "Claude Code", hosts: ["api.anthropic.com", "platform.claude.com"] },
133
- codex: { label: "Codex", hosts: ["chatgpt.com", "auth.openai.com"] },
211
+ claude: {
212
+ label: "Claude Code",
213
+ provider: "Anthropic",
214
+ gatewayProvider: "anthropic",
215
+ hosts: ["api.anthropic.com", "platform.claude.com"],
216
+ apiHost: "api.anthropic.com",
217
+ },
218
+ codex: {
219
+ label: "Codex",
220
+ provider: "OpenAI",
221
+ gatewayProvider: "openai",
222
+ hosts: ["chatgpt.com", "auth.openai.com"],
223
+ apiHost: "api.openai.com",
224
+ },
134
225
  };
135
226
  /**
136
227
  * A script that takes the forward proxy URL and host names, and prints one line per host: the
@@ -149,35 +240,31 @@ const LOGIN_HOST_ANSWER = /^(\S+) (\d+) (\d{3}) (\d{3})$/u;
149
240
  /** The CONNECT status the forward proxy returns for a host that isn't in its allowlist. */
150
241
  const PROXY_REFUSED = "403";
151
242
  /**
152
- * Probes a brain on a Worker behind a Gateway (ADR 0027). If the Gateway has the Anthropic
153
- * credential, checks only the Claude Code binary. Otherwise, Claude Code and Codex use the
154
- * operator's login (ADR 0026): `probe` checks the login, then the machine must connect to the
155
- * login's hosts through the forward proxy. Pi goes to `probe`, which rejects it on any remote
156
- * machine.
243
+ * Probes a brain on a Worker behind a Gateway (ADR 0027). If the Gateway has the credential of
244
+ * the harness's provider, checks only the harness binary. Otherwise, Claude Code and Codex use
245
+ * the operator's login (ADR 0026), or an API key in the Attempt's environment if `apiKeyed`
246
+ * returns `true` for the harness: `probe` checks the login or the binary, then the machine must
247
+ * connect to the login's hosts, or the provider's API host, through the forward proxy. Pi goes
248
+ * to `probe`, which rejects it on any remote machine. The checks run through `shell`, on the
249
+ * machine or in a container on it.
157
250
  */
158
- export const gatewayHarnessProbe = (commands, machine, gateway, probe) => {
251
+ export const gatewayHarnessProbe = (commands, machine, gateway, probe, shell, apiKeyed) => {
159
252
  const worker = machine.address.name;
160
253
  const host = machine.shell.destination;
161
254
  const { domain } = gateway.settings;
162
255
  const proxy = forwardProxyUrl(domain);
163
- const claudeBinary = Effect.fn("SshExecutor.probeClaudeBehindGateway")(function* () {
164
- yield* Effect.annotateCurrentSpan({ host, domain });
165
- const result = yield* commands.inspect("preflight", machine.shell, "claude", ["--version"]);
166
- if (result.exitCode === SSH_FAILURE)
167
- return yield* unreachable(host, "claude", result);
168
- if (result.exitCode !== 0)
169
- return new HarnessUnavailableError({
170
- harness: "claude",
171
- capability: "binary",
172
- message: "claude --version failed. Check the Claude Code installation on the worker.",
173
- });
174
- yield* Effect.logInfo("Claude Code uses the Gateway's Anthropic credential; checked its binary only", { host, version: result.stdout.trim() });
175
- return new HarnessReady({ harness: "claude" });
176
- });
256
+ /** Checks only the binary of a harness whose provider credential the Gateway holds. */
257
+ const binaryOnly = (harness) => harnessBinaryProbe(commands, host, shell, harness, `the Gateway's ${LOGINS[harness].provider} credential`);
177
258
  const loginHostsReachable = Effect.fn("SshExecutor.probeLoginHostsBehindGateway")(function* (harness) {
178
- const { label, hosts } = LOGINS[harness];
259
+ const { label } = LOGINS[harness];
260
+ const keyed = apiKeyed(harness);
261
+ const hosts = keyed ? [LOGINS[harness].apiHost] : LOGINS[harness].hosts;
262
+ const uses = keyed ? "an API key" : "its login";
263
+ const alternative = keyed
264
+ ? `, or add ${LOGINS[harness].gatewayProvider} to the worker's llm_providers with the key on the gateway`
265
+ : "";
179
266
  yield* Effect.annotateCurrentSpan({ worker, host, domain, harness });
180
- const result = yield* commands.inspect("preflight", machine.shell, "sh", [
267
+ const result = yield* commands.inspect("preflight", shell, "sh", [
181
268
  "-c",
182
269
  LOGIN_HOSTS_SCRIPT,
183
270
  "sh",
@@ -200,8 +287,8 @@ export const gatewayHarnessProbe = (commands, machine, gateway, probe) => {
200
287
  ? `no response from ${loginHost}: ${result.stderr.trim() || `sh exited with code ${String(result.exitCode)}`}`
201
288
  : `curl exited with code ${answer.exitCode}; the proxy returned ${answer.connect} for CONNECT`);
202
289
  return yield* gatewayGap(worker, answer?.connect === PROXY_REFUSED
203
- ? `${label} uses its login on SSH worker "${worker}", and the gateway's forward proxy blocks ${loginHost}. Add ${loginHost} to the gateway's egress allowlist.`
204
- : `${label} uses its login on SSH worker "${worker}", which can't reach ${loginHost} through the gateway's forward proxy at ${proxy}`, cause);
290
+ ? `${label} uses ${uses} on SSH worker "${worker}", and the gateway's forward proxy blocks ${loginHost}. Add ${loginHost} to the gateway's egress allowlist${alternative}.`
291
+ : `${label} uses ${uses} on SSH worker "${worker}", which can't reach ${loginHost} through the gateway's forward proxy at ${proxy}`, cause);
205
292
  }
206
293
  yield* Effect.logInfo("SSH Worker reaches its harness login's hosts through the Gateway", {
207
294
  worker,
@@ -221,11 +308,10 @@ export const gatewayHarnessProbe = (commands, machine, gateway, probe) => {
221
308
  return (brain) => {
222
309
  switch (brain.harness) {
223
310
  case "claude":
224
- return gateway.settings.llmProviders.includes("anthropic")
225
- ? claudeBinary()
226
- : loginOnMachine(brain, "claude");
227
311
  case "codex":
228
- return loginOnMachine(brain, "codex");
312
+ return gateway.settings.llmProviders.includes(LOGINS[brain.harness].gatewayProvider)
313
+ ? binaryOnly(brain.harness)
314
+ : loginOnMachine(brain, brain.harness);
229
315
  case "pi":
230
316
  return probe(brain);
231
317
  }
@@ -1 +1 @@
1
- {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../../src/ssh/gateway/preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAuB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/F,0GAA0G;AAC1G,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAErD,2HAA2H;AAC3H,MAAM,qBAAqB,GAAG;;;;;CAK7B,CAAC,IAAI,EAAE,CAAC;AAET,iFAAiF;AACjF,MAAM,qBAAqB,GAAG,yDAAyD,CAAC;AAExF,0FAA0F;AAC1F,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAE,OAAe,EAAE,KAAc,EAAE,EAAE,CACzE,IAAI,qBAAqB,CAAC,EAAE,MAAM,EAA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"effect";
3
+ import type { SshWorkerContainer } from "./model.ts";
4
+ declare const MachineResources_base: Schema.Class<MachineResources, Schema.Struct<{
5
+ /** The CPUs available to the SSH user, as `nproc` counts them. */
6
+ readonly cpus: Schema.Int;
7
+ readonly memoryBytes: Schema.Int;
8
+ /** The most processes and threads the kernel runs at once: the lower of `threads-max` and `pid_max`. */
9
+ readonly tasks: Schema.Int;
10
+ }>, {}>;
11
+ /** What a Linux machine's kernel reports of its CPUs, memory, and tasks. */
12
+ export declare class MachineResources extends MachineResources_base {
13
+ }
14
+ /**
15
+ * A script that prints the number of CPUs, the kernel's `threads-max` and `pid_max`, and
16
+ * `/proc/meminfo`.
17
+ */
18
+ export declare const RESOURCES_SCRIPT = "nproc && cat /proc/sys/kernel/threads-max /proc/sys/kernel/pid_max /proc/meminfo";
19
+ /** Parses the output of `RESOURCES_SCRIPT`. Returns `None` if a value is missing or not a positive integer. */
20
+ export declare const resourcesFromOutput: (output: string) => Option.Option<MachineResources>;
21
+ /** The limits of a Worker's containers and where they come from. */
22
+ export type ResolvedLimits =
23
+ /** `usine.yaml` sets every limit. */
24
+ {
25
+ readonly _tag: "Configured";
26
+ readonly limits: ContainerLimits;
27
+ }
28
+ /** `derived` come from `machine` for `slots` concurrent Attempts; `usine.yaml` sets the others. */
29
+ | {
30
+ readonly _tag: "Derived";
31
+ readonly limits: ContainerLimits;
32
+ readonly derived: ReadonlyArray<ContainerLimit>;
33
+ readonly machine: MachineResources;
34
+ readonly slots: number;
35
+ };
36
+ /** Returns the limits of `container` if `usine.yaml` sets every one, or `None`. */
37
+ export declare const configuredLimits: (container: SshWorkerContainer) => Option.Option<ResolvedLimits>;
38
+ /**
39
+ * Returns the limits of `container` when `slots` Attempts run on `machine` at once: the ones
40
+ * `usine.yaml` sets, and the others from `deriveLimits`.
41
+ */
42
+ export declare const resolveLimits: (container: SshWorkerContainer, machine: MachineResources, slots: number) => ResolvedLimits;
43
+ /** Returns the log fields of the limits of a Worker's containers. */
44
+ export declare const limitFields: (resolved: ResolvedLimits) => {
45
+ cpus: number & import("effect/Brand").Brand<"ContainerCpus">;
46
+ memoryMib: number & import("effect/Brand").Brand<"ContainerMemoryMib">;
47
+ pids: number & import("effect/Brand").Brand<"ContainerPids">;
48
+ derivedLimits: string;
49
+ } | {
50
+ cpus: number & import("effect/Brand").Brand<"ContainerCpus">;
51
+ memoryMib: number & import("effect/Brand").Brand<"ContainerMemoryMib">;
52
+ pids: number & import("effect/Brand").Brand<"ContainerPids">;
53
+ derivedLimits: string;
54
+ slots: number;
55
+ machineCpus: number;
56
+ machineMemoryMib: number;
57
+ machineTasks: number;
58
+ };
59
+ export {};
60
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/ssh/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAS,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;;IAQnD,kEAAkE;;;IAGlE,wGAAwG;;;AAP1G,4EAA4E;AAC5E,qBAAa,gBAAiB,SAAQ,qBAQpC;CAAG;AAEL;;;GAGG;AACH,eAAO,MAAM,gBAAgB,qFACuD,CAAC;AAIrF,+GAA+G;AAC/G,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CASlF,CAAC;AA6BF,oEAAoE;AACpE,MAAM,MAAM,cAAc;AACxB,qCAAqC;AACnC;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CAAE;AACnE,mGAAmG;GACjG;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,cAAe,kBAAkB,KAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAI1F,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,aAAa,cACb,kBAAkB,WACpB,gBAAgB,SAClB,MAAM,KACZ,cAkBF,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,WAAW,aAAc,cAAc;;;;;;;;;;;;;;CAclD,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { CONTAINER_LIMITS, ContainerCpus, ContainerLimits, ContainerMemoryMib, ContainerPids, } from "@usine/core/worker";
2
+ import { Match, Option, Schema } from "effect";
3
+ import { memoryFromMeminfo } from "../memory-preflight.js";
4
+ const MIB = 1024 ** 2;
5
+ /** What a Linux machine's kernel reports of its CPUs, memory, and tasks. */
6
+ export class MachineResources extends Schema.Class("@usine/executor/MachineResources")({
7
+ /** The CPUs available to the SSH user, as `nproc` counts them. */
8
+ cpus: Schema.Int.check(Schema.isGreaterThan(0)),
9
+ memoryBytes: Schema.Int.check(Schema.isGreaterThan(0)),
10
+ /** The most processes and threads the kernel runs at once: the lower of `threads-max` and `pid_max`. */
11
+ tasks: Schema.Int.check(Schema.isGreaterThan(0)),
12
+ }) {
13
+ }
14
+ /**
15
+ * A script that prints the number of CPUs, the kernel's `threads-max` and `pid_max`, and
16
+ * `/proc/meminfo`.
17
+ */
18
+ export const RESOURCES_SCRIPT = "nproc && cat /proc/sys/kernel/threads-max /proc/sys/kernel/pid_max /proc/meminfo";
19
+ const decodeResources = Schema.decodeUnknownOption(MachineResources);
20
+ /** Parses the output of `RESOURCES_SCRIPT`. Returns `None` if a value is missing or not a positive integer. */
21
+ export const resourcesFromOutput = (output) => {
22
+ const [cpus, threadsMax, pidMax, ...meminfo] = output.split("\n");
23
+ return Option.flatMap(memoryFromMeminfo(meminfo.join("\n")), ({ totalBytes }) => decodeResources({
24
+ cpus: Number(cpus),
25
+ memoryBytes: totalBytes,
26
+ tasks: Math.min(Number(threadsMax), Number(pidMax)),
27
+ }));
28
+ };
29
+ /** What the Attempt containers leave to the machine's own processes, such as sshd, Docker, and the cached clones' fetches. */
30
+ const HOST_RESERVE = { cpus: 0.5, memoryMib: 1024, tasks: 1024 };
31
+ /** The smallest limits that `usine.yaml` and Docker accept. */
32
+ const SMALLEST = { cpus: 0.01, memoryMib: 256, pids: 64 };
33
+ /**
34
+ * Returns the limits of each container when `slots` Attempts run on `machine` at once: the
35
+ * machine's total less a reserve for its own processes, divided by `slots`, rounded down to a
36
+ * hundredth of a CPU, a MiB, and a task, and no lower than the smallest limits Docker accepts.
37
+ */
38
+ const deriveLimits = (machine, slots) => new ContainerLimits({
39
+ cpus: ContainerCpus.make(Math.max(SMALLEST.cpus, Math.floor(((machine.cpus - HOST_RESERVE.cpus) / slots) * 100) / 100)),
40
+ memoryMib: ContainerMemoryMib.make(Math.max(SMALLEST.memoryMib, Math.floor((machine.memoryBytes / MIB - HOST_RESERVE.memoryMib) / slots))),
41
+ pids: ContainerPids.make(Math.max(SMALLEST.pids, Math.floor((machine.tasks - HOST_RESERVE.tasks) / slots))),
42
+ });
43
+ /** Returns the limits of `container` if `usine.yaml` sets every one, or `None`. */
44
+ export const configuredLimits = (container) => Option.map(Option.all({ cpus: container.cpus, memoryMib: container.memoryMib, pids: container.pids }), (limits) => ({ _tag: "Configured", limits: new ContainerLimits(limits) }));
45
+ /**
46
+ * Returns the limits of `container` when `slots` Attempts run on `machine` at once: the ones
47
+ * `usine.yaml` sets, and the others from `deriveLimits`.
48
+ */
49
+ export const resolveLimits = (container, machine, slots) => {
50
+ const derived = deriveLimits(machine, slots);
51
+ const unset = {
52
+ cpus: Option.isNone(container.cpus),
53
+ memoryMib: Option.isNone(container.memoryMib),
54
+ pids: Option.isNone(container.pids),
55
+ };
56
+ return {
57
+ _tag: "Derived",
58
+ limits: new ContainerLimits({
59
+ cpus: Option.getOrElse(container.cpus, () => derived.cpus),
60
+ memoryMib: Option.getOrElse(container.memoryMib, () => derived.memoryMib),
61
+ pids: Option.getOrElse(container.pids, () => derived.pids),
62
+ }),
63
+ derived: CONTAINER_LIMITS.filter((limit) => unset[limit]),
64
+ machine,
65
+ slots,
66
+ };
67
+ };
68
+ /** Returns the log fields of the limits of a Worker's containers. */
69
+ export const limitFields = (resolved) => ({
70
+ cpus: resolved.limits.cpus,
71
+ memoryMib: resolved.limits.memoryMib,
72
+ pids: resolved.limits.pids,
73
+ ...Match.valueTags(resolved, {
74
+ Configured: () => ({ derivedLimits: "none" }),
75
+ Derived: ({ derived, machine, slots }) => ({
76
+ derivedLimits: derived.join(","),
77
+ slots,
78
+ machineCpus: machine.cpus,
79
+ machineMemoryMib: Math.floor(machine.memoryBytes / MIB),
80
+ machineTasks: machine.tasks,
81
+ }),
82
+ }),
83
+ });
84
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/ssh/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,eAAe,EACf,kBAAkB,EAClB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC;AAEtB,4EAA4E;AAC5E,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,KAAK,CAChD,kCAAkC,CACnC,CAAC;IACA,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAA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