@usine/executor 0.5.1-next.421.ged7f079.1.1 → 0.5.1-next.422.g77ede43.1.1

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 (67) hide show
  1. package/README.md +3 -1
  2. package/dist/ssh/api-keys.d.ts +7 -12
  3. package/dist/ssh/api-keys.d.ts.map +1 -1
  4. package/dist/ssh/api-keys.js +37 -45
  5. package/dist/ssh/api-keys.js.map +1 -1
  6. package/dist/ssh/attempt-homes.d.ts +22 -0
  7. package/dist/ssh/attempt-homes.d.ts.map +1 -0
  8. package/dist/ssh/attempt-homes.js +85 -0
  9. package/dist/ssh/attempt-homes.js.map +1 -0
  10. package/dist/ssh/gateway/admin.d.ts +1 -1
  11. package/dist/ssh/gateway/admin.d.ts.map +1 -1
  12. package/dist/ssh/gateway/admin.js +30 -8
  13. package/dist/ssh/gateway/admin.js.map +1 -1
  14. package/dist/ssh/gateway/attachments.d.ts +4 -4
  15. package/dist/ssh/gateway/attachments.d.ts.map +1 -1
  16. package/dist/ssh/gateway/attachments.js +16 -12
  17. package/dist/ssh/gateway/attachments.js.map +1 -1
  18. package/dist/ssh/gateway/environment.d.ts +11 -9
  19. package/dist/ssh/gateway/environment.d.ts.map +1 -1
  20. package/dist/ssh/gateway/environment.js +20 -47
  21. package/dist/ssh/gateway/environment.js.map +1 -1
  22. package/dist/ssh/gateway/preflight.d.ts +4 -3
  23. package/dist/ssh/gateway/preflight.d.ts.map +1 -1
  24. package/dist/ssh/gateway/preflight.js +35 -31
  25. package/dist/ssh/gateway/preflight.js.map +1 -1
  26. package/dist/ssh/gateway/tailnet.d.ts +2 -1
  27. package/dist/ssh/gateway/tailnet.d.ts.map +1 -1
  28. package/dist/ssh/gateway/tailnet.js +3 -3
  29. package/dist/ssh/gateway/tailnet.js.map +1 -1
  30. package/dist/ssh/model.d.ts +4 -6
  31. package/dist/ssh/model.d.ts.map +1 -1
  32. package/dist/ssh/model.js.map +1 -1
  33. package/dist/ssh/preflight.d.ts +2 -1
  34. package/dist/ssh/preflight.d.ts.map +1 -1
  35. package/dist/ssh/preflight.js +4 -4
  36. package/dist/ssh/preflight.js.map +1 -1
  37. package/dist/ssh/provisioner/checks.d.ts +2 -1
  38. package/dist/ssh/provisioner/checks.d.ts.map +1 -1
  39. package/dist/ssh/provisioner/checks.js +13 -16
  40. package/dist/ssh/provisioner/checks.js.map +1 -1
  41. package/dist/ssh/provisioner/machines.d.ts +2 -1
  42. package/dist/ssh/provisioner/machines.d.ts.map +1 -1
  43. package/dist/ssh/provisioner/machines.js +3 -1
  44. package/dist/ssh/provisioner/machines.js.map +1 -1
  45. package/dist/ssh/provisioner/reset.d.ts +2 -1
  46. package/dist/ssh/provisioner/reset.d.ts.map +1 -1
  47. package/dist/ssh/provisioner/reset.js +11 -2
  48. package/dist/ssh/provisioner/reset.js.map +1 -1
  49. package/dist/ssh/provisioner/tailnet/bootstrap.d.ts +2 -1
  50. package/dist/ssh/provisioner/tailnet/bootstrap.d.ts.map +1 -1
  51. package/dist/ssh/provisioner/tailnet/bootstrap.js +3 -1
  52. package/dist/ssh/provisioner/tailnet/bootstrap.js.map +1 -1
  53. package/dist/ssh/ssh.d.ts.map +1 -1
  54. package/dist/ssh/ssh.js +16 -16
  55. package/dist/ssh/ssh.js.map +1 -1
  56. package/dist/ssh/worker-records.d.ts +3 -2
  57. package/dist/ssh/worker-records.d.ts.map +1 -1
  58. package/dist/ssh/worker-records.js +14 -12
  59. package/dist/ssh/worker-records.js.map +1 -1
  60. package/dist/ssh/workers.d.ts.map +1 -1
  61. package/dist/ssh/workers.js +2 -4
  62. package/dist/ssh/workers.js.map +1 -1
  63. package/package.json +6 -6
  64. package/dist/ssh/codex-homes.d.ts +0 -21
  65. package/dist/ssh/codex-homes.d.ts.map +0 -1
  66. package/dist/ssh/codex-homes.js +0 -78
  67. package/dist/ssh/codex-homes.js.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @usine/executor
2
2
 
3
+ Gateway, provisioner API-key, and Cloudflare environment wiring reads the registered harness descriptors. SSH attempt homes are tracked per harness and attempt, mounted writable when required, and removed on scope closure. Cleanup preserves homes still in use or associated with an existing checkout.
4
+
3
5
  Worker execution for [usine](https://github.com/basaltbytes/usine). The platform-free root defines worker preflight, scoped attempt preparation, and cancellation, plus the credential provider, worker capability errors, and adapter-neutral request types. Each prepared attempt runs its Pi parent in this process as a durable task, tells it where the worker runs children (local processes, SSH on an exe.dev VM or any Linux machine, or a Cloudflare sandbox), and releases its resources at completion or when its scope closes. [Attempt execution](https://github.com/basaltbytes/usine/blob/main/docs/architecture/execution.mdx) and [Workers and the gateway](https://github.com/basaltbytes/usine/blob/main/docs/architecture/workers-and-gateway.mdx) cover the executors.
4
6
 
5
7
  0.x APIs can change. Supply `effect` at the workspace's pinned version.
@@ -198,7 +200,7 @@ The gateway command persists attachments, allowing requests immediately after a
198
200
 
199
201
  The cached clone fetches `http://git.<domain>/<repository>.git`. Children, harvesting, and the executor's git commands export settings that point git, gh, and package managers at the gateway: git sends the caller token only to `git.<domain>` and rewrites `https://github.com/` there, gh uses `git.<domain>` through the worker's socket with its config in `<root>/workers/<name>/gh`, and `HTTPS_PROXY` is the forward proxy.
200
202
 
201
- If the gateway has the Anthropic credential, Claude Code calls `llm.<domain>/anthropic`, and preflight checks only its binary. If it has the OpenAI credential, prepare writes Codex's `config.toml` to the attempt's Codex home, `<root>/workers/<name>/codex/<attempt>`, children get that directory as `CODEX_HOME`, and Codex sends the Responses API to `llm.<domain>/openai/v1` with the caller token from `USINE_GATEWAY_TOKEN`; preflight checks only its binary and version. The file has a `model_provider` and no token. Codex also writes its sessions there, so an attempt's container mounts the directory read-write, and cleanup removes it after the container. If the orchestrator crashes, the directory stays. `Executor.sweep` removes each Codex home on a worker with its own machine whose attempt has no checkout there and that no attempt in this process holds; an attempt holds its Codex home from before it's written until cleanup removes it. A checkout kept for a reattachment or with unpreserved work keeps its Codex home, and a later sweep removes it after the checkout is gone. The sweep visits only the workers the executor has. For a worker that `usine.yaml` no longer declares, `sshWorkerRecordsFor(directory).discard(worker, attempts)` removes the Codex homes of the attempts whose leftovers the operator discarded, over SSH with the worker's port and key from its record in `directory`, and never fails. Without a record, it removes nothing. Otherwise each harness uses the operator's login on the machine through the forward proxy: preflight checks the login as without a gateway, then that each of the login's hosts answers HTTP through the proxy (`api.anthropic.com` and `platform.claude.com`, or `chatgpt.com` and `auth.openai.com`). A refused host is a `gateway` capability error naming the host to add to the egress allowlist. The caller token is in no command line: each SSH command sends `GIT_CONFIG_VALUE_0`, `GH_ENTERPRISE_TOKEN`, `GH_TOKEN`, `ANTHROPIC_AUTH_TOKEN`, and `USINE_GATEWAY_TOKEN` from the client's environment (`SendEnv`), and the machine's sshd must accept them (`AcceptEnv`). With a container runtime, only the cached clone's fetch sends them; the attempt's container gets them when it starts.
203
+ If the gateway has the Anthropic credential, Claude Code calls `llm.<domain>/anthropic-messages`, and preflight checks only its binary. If it has the OpenAI credential, prepare writes Codex's `config.toml` to the attempt's Codex home, `<root>/workers/<name>/codex/<attempt>`, children get that directory as `CODEX_HOME`, and Codex sends the Responses API to `llm.<domain>/openai-responses/v1` with the caller token from `USINE_GATEWAY_TOKEN`; preflight checks only its binary and version. The file has a `model_provider` and no token. Codex also writes its sessions there, so an attempt's container mounts the directory read-write, and cleanup removes it after the container. If the orchestrator crashes, the directory stays. `Executor.sweep` removes each Codex home on a worker with its own machine whose attempt has no checkout there and that no attempt in this process holds; an attempt holds its Codex home from before it's written until cleanup removes it. A checkout kept for a reattachment or with unpreserved work keeps its Codex home, and a later sweep removes it after the checkout is gone. The sweep visits only the workers the executor has. For a worker that `usine.yaml` no longer declares, `sshWorkerRecordsFor(directory).discard(worker, attempts)` removes the Codex homes of the attempts whose leftovers the operator discarded, over SSH with the worker's port and key from its record in `directory`, and never fails. Without a record, it removes nothing. Otherwise each harness uses the operator's login on the machine through the forward proxy: preflight checks the login as without a gateway, then that each of the login's hosts answers HTTP through the proxy (`api.anthropic.com` and `platform.claude.com`, or `chatgpt.com` and `auth.openai.com`). A refused host is a `gateway` capability error naming the host to add to the egress allowlist. The caller token is in no command line: each SSH command sends `GIT_CONFIG_VALUE_0`, `GH_ENTERPRISE_TOKEN`, `GH_TOKEN`, `ANTHROPIC_AUTH_TOKEN`, and `USINE_GATEWAY_TOKEN` from the client's environment (`SendEnv`), and the machine's sshd must accept them (`AcceptEnv`). With a container runtime, only the cached clone's fetch sends them; the attempt's container gets them when it starts.
202
204
 
203
205
  The admin API listens on the gateway's loopback. With the first worker behind a gateway, the executor opens its own forward, `ssh -N -L 127.0.0.1:<port>:127.0.0.1:<adminPort> <destination>`, with the same SSH command and environment as its other clients, on a local port the kernel picks; workers behind that gateway share it. When the client exits, the executor starts another after a pause of one second, doubling up to one minute, and logs each open, exit, and reopen with the gateway's destination. An admin request that finds the forward closed, or gets no answer, reopens it at once and is sent once more. A second failure fails the request, with a message giving since when the forward has been closed, or, if it opens but the admin API doesn't answer, since when the API last answered through it. The forward closes when the last worker behind the gateway is removed, or with the layer.
204
206
 
@@ -1,25 +1,22 @@
1
- import { Harness } from "@usine/core/agent/brain";
1
+ import { type HarnessCatalog } from "@usine/agents/harness";
2
+ import type { Harness } from "@usine/core/agent/brain";
2
3
  import { Effect, Option, Redacted } from "effect";
3
4
  import { type RemoteCommands } from "../remote/commands.ts";
4
5
  import type { RemoteAccess } from "../remote/machine.ts";
5
6
  import type { MachineGateway, SshMachine, SshWorkerAddress } from "./model.ts";
6
7
  /** Returns whether the Gateway holds a credential for `harness`'s provider. */
7
- export declare const gatewayHolds: (gateway: Option.Option<MachineGateway>, harness: Harness) => boolean;
8
+ export declare const gatewayHolds: (catalog: HarnessCatalog, gateway: Option.Option<MachineGateway>, harness: Harness) => boolean;
8
9
  /**
9
10
  * Returns the API key that each Attempt on a Worker's machine gets for `harness`, or `None` if
10
11
  * the Worker isn't provisioned, the provisioner sets no key, or the Gateway has the provider's
11
12
  * credential.
12
13
  */
13
- export declare const provisionedApiKey: (worker: {
14
+ export declare const provisionedApiKey: (catalog: HarnessCatalog, worker: {
14
15
  readonly address: SshWorkerAddress;
15
16
  readonly gateway: Option.Option<MachineGateway>;
16
17
  }, harness: Harness) => Option.Option<Redacted.Redacted<string>>;
17
- /**
18
- * Returns `access` with the provisioner's API keys among the Attempt's secrets. With an OpenAI
19
- * key, also writes the Attempt's Codex home, which `holdCodexHome` gives it, with
20
- * `CODEX_API_KEY_CONFIG`.
21
- */
22
- export declare const withApiKeys: (commands: RemoteCommands, holdCodexHome: (machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">) => Effect.Effect<string, never, import("effect/Scope").Scope>, machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">, access: RemoteAccess, operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare") => Effect.Effect<RemoteAccess | {
18
+ /** Adds provisioner API keys and writes each registered harness's attempt configuration. */
19
+ export declare const withApiKeys: (catalog: HarnessCatalog, commands: RemoteCommands, holdAttemptHome: (machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">, descriptor: import("@usine/agents/harness").HarnessDescriptor) => Effect.Effect<string, never, import("effect/Scope").Scope>, machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">, access: RemoteAccess, operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare") => Effect.Effect<RemoteAccess | {
23
20
  readOnlyPaths: ReadonlyArray<string>;
24
21
  gitEnvironment: Readonly<Record<string, string>>;
25
22
  refresh: Effect.Effect<void, import("../executor.ts").ExecutorError>;
@@ -29,9 +26,7 @@ export declare const withApiKeys: (commands: RemoteCommands, holdCodexHome: (mac
29
26
  };
30
27
  apiKeyHarnesses: Set<string & import("effect/Brand").Brand<"Harness">>;
31
28
  writablePaths: string[];
32
- environment: Readonly<Record<string, string>> | {
33
- CODEX_HOME: string;
34
- };
29
+ environment: any;
35
30
  scrub: (text: string) => string;
36
31
  }, import("../executor.ts").ExecutorOperationError, import("effect/Scope").Scope>;
37
32
  //# sourceMappingURL=api-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/ssh/api-keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqB/E,+EAA+E;AAC/E,eAAO,MAAM,YAAY,YAAa,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,OAAO,KAAG,OAQrF,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,WACpB;IAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;CAAE,WACtF,OAAO,KACf,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CASzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;kBA2CN,MAAM;iFAMtB,CAAC"}
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/ssh/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/E,+EAA+E;AAC/E,eAAO,MAAM,YAAY,YACd,cAAc,WACd,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,WAC7B,OAAO,KACf,OAQA,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,YACnB,cAAc,UACf;IAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;CAAE,WACtF,OAAO,KACf,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAUzC,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,WAAW;;;;;;;;;;;kBA6DN,MAAM;iFAMtB,CAAC"}
@@ -1,55 +1,48 @@
1
- import { catalog } from "@usine/agents/harness";
2
- import { Harness } from "@usine/core/agent/brain";
1
+ import {} from "@usine/agents/harness";
3
2
  import { Effect, Option, Redacted } from "effect";
4
3
  import { sendingShell } from "../remote/commands.js";
5
4
  import { writeMachineFiles } from "./gateway/attachments.js";
6
- /** The variable with the OpenAI API key that Codex's `model_provider` reads (`env_key`). */
7
- const OPENAI_KEY_VARIABLE = "OPENAI_API_KEY";
8
- /**
9
- * Codex's `config.toml` for an OpenAI API key in `OPENAI_API_KEY`: a `model_provider` that
10
- * sends the Responses API to `api.openai.com` and needs no login. The file contains no key.
11
- */
12
- const CODEX_API_KEY_CONFIG = [
13
- 'model_provider = "usine-openai"',
14
- "",
15
- "[model_providers.usine-openai]",
16
- 'name = "OpenAI API key"',
17
- 'base_url = "https://api.openai.com/v1"',
18
- `env_key = "${OPENAI_KEY_VARIABLE}"`,
19
- 'wire_api = "responses"',
20
- "requires_openai_auth = false",
21
- "",
22
- ].join("\n");
23
5
  /** Returns whether the Gateway holds a credential for `harness`'s provider. */
24
- export const gatewayHolds = (gateway, harness) => Option.exists(gateway, ({ settings }) => Option.exists(Option.flatMap(catalog.get(harness), (descriptor) => Option.map(descriptor.worker.credential, ({ provider }) => provider)), (provider) => settings.llmProviders.includes(provider)));
6
+ export const gatewayHolds = (catalog, gateway, harness) => Option.exists(gateway, ({ settings }) => Option.exists(Option.flatMap(catalog.get(harness), (descriptor) => Option.map(descriptor.worker.credential, ({ protocol }) => protocol)), (protocol) => settings.llmProviders.includes(protocol)));
25
7
  /**
26
8
  * Returns the API key that each Attempt on a Worker's machine gets for `harness`, or `None` if
27
9
  * the Worker isn't provisioned, the provisioner sets no key, or the Gateway has the provider's
28
10
  * credential.
29
11
  */
30
- export const provisionedApiKey = (worker, harness) => {
12
+ export const provisionedApiKey = (catalog, worker, harness) => {
31
13
  const { machine } = worker.address;
32
- if (machine._tag !== "Provisioned" || gatewayHolds(worker.gateway, harness))
14
+ if (machine._tag !== "Provisioned" || gatewayHolds(catalog, worker.gateway, harness))
33
15
  return Option.none();
34
16
  return Option.flatMap(Option.flatMap(catalog.get(harness), (descriptor) => Option.map(descriptor.worker.credential, ({ provider }) => provider)), (provider) => machine.provisioner.apiKeys[provider]);
35
17
  };
36
- /**
37
- * Returns `access` with the provisioner's API keys among the Attempt's secrets. With an OpenAI
38
- * key, also writes the Attempt's Codex home, which `holdCodexHome` gives it, with
39
- * `CODEX_API_KEY_CONFIG`.
40
- */
41
- export const withApiKeys = Effect.fn("SshExecutor.withApiKeys")(function* (commands, holdCodexHome, machine, attemptId, access, operation) {
42
- const anthropic = provisionedApiKey(machine, Harness.make("claude"));
43
- const openai = provisionedApiKey(machine, Harness.make("codex"));
44
- const secrets = Object.fromEntries([
45
- ...Option.toArray(Option.map(anthropic, (key) => ["ANTHROPIC_API_KEY", key])),
46
- ...Option.toArray(Option.map(openai, (key) => [OPENAI_KEY_VARIABLE, key])),
47
- ]);
48
- if (Object.keys(secrets).length === 0)
18
+ /** Adds provisioner API keys and writes each registered harness's attempt configuration. */
19
+ export const withApiKeys = Effect.fn("SshExecutor.withApiKeys")(function* (catalog, commands, holdAttemptHome, machine, attemptId, access, operation) {
20
+ yield* Effect.annotateCurrentSpan({ attemptId, worker: machine.address.name });
21
+ const keyed = catalog.descriptors.flatMap((descriptor) => Option.toArray(provisionedApiKey(catalog, machine, descriptor.id)).flatMap((key) => Option.toArray(descriptor.worker.credential).map((credential) => ({
22
+ descriptor,
23
+ credential,
24
+ key,
25
+ }))));
26
+ if (keyed.length === 0) {
27
+ yield* Effect.logDebug("No attempt API keys to inject", {
28
+ attemptId,
29
+ worker: machine.address.name,
30
+ });
49
31
  return access;
50
- const codexHome = yield* Effect.transposeOption(Option.map(openai, () => holdCodexHome(machine, attemptId).pipe(Effect.tap((home) => writeMachineFiles(commands, operation, machine.shell, [
51
- [`${home}/config.toml`, CODEX_API_KEY_CONFIG],
52
- ])))));
32
+ }
33
+ const wirings = yield* Effect.forEach(keyed, ({ descriptor, credential }) => Effect.gen(function* () {
34
+ const homes = yield* Effect.forEach(Option.toArray(credential.home), () => holdAttemptHome(machine, attemptId, descriptor));
35
+ const wiring = credential.apiKey.render(credential.apiKeyBaseUrl, homes[0] ?? "");
36
+ if (wiring.files.length > 0)
37
+ yield* writeMachineFiles(commands, operation, machine.shell, wiring.files);
38
+ return { wiring, homes };
39
+ }));
40
+ const secrets = Object.fromEntries(keyed.map(({ credential, key }) => [credential.apiKey.tokenVariable, key]));
41
+ yield* Effect.logInfo("Prepared attempt API-key wiring", {
42
+ attemptId,
43
+ worker: machine.address.name,
44
+ harnesses: keyed.map(({ descriptor }) => descriptor.id),
45
+ });
53
46
  const values = Object.values(secrets).map(Redacted.value);
54
47
  return {
55
48
  ...access,
@@ -59,14 +52,13 @@ export const withApiKeys = Effect.fn("SshExecutor.withApiKeys")(function* (comma
59
52
  secrets: { ...access.secrets, ...secrets },
60
53
  apiKeyHarnesses: new Set([
61
54
  ...access.apiKeyHarnesses,
62
- ...Option.toArray(Option.map(anthropic, () => Harness.make("claude"))),
63
- ...Option.toArray(Option.map(openai, () => Harness.make("codex"))),
55
+ ...keyed.map(({ descriptor }) => descriptor.id),
64
56
  ]),
65
- writablePaths: [...access.writablePaths, ...Option.toArray(codexHome)],
66
- environment: Option.match(codexHome, {
67
- onNone: () => access.environment,
68
- onSome: (home) => ({ ...access.environment, CODEX_HOME: home }),
69
- }),
57
+ writablePaths: [...access.writablePaths, ...wirings.flatMap(({ homes }) => homes)],
58
+ environment: {
59
+ ...access.environment,
60
+ ...Object.assign({}, ...wirings.map(({ wiring }) => wiring.environment)),
61
+ },
70
62
  scrub: (text) => values.reduce((scrubbed, value) => scrubbed.replaceAll(value, "<redacted>"), access.scrub(text)),
71
63
  };
72
64
  });
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/ssh/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAuB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,4FAA4F;AAC5F,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAE7C;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,iCAAiC;IACjC,EAAE;IACF,gCAAgC;IAChC,yBAAyB;IACzB,wCAAwC;IACxC,cAAc,mBAAmB,GAAG;IACpC,wBAAwB;IACxB,8BAA8B;IAC9B,EAAE;CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,+EAA+E;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAsC,EAAE,OAAgB,EAA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C1D,OAAO;QACL,GAAG,MAAM;QACT,wFAAwF;QACxF,cAAc;QACd,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC;QAC1C,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE;QAC1C,eAAe,EAAE,IAAI,GAAG,CAAC;YACvB,GAAG,MAAM,CAAC,eAAe;YACzB,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;SAChD,CAAC;QACF,aAAa,EAAE,CAAC,GAAG,MAAM,CAAC,aAAa,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAClF,WAAW,EAAE;YACX,GAAG,MAAM,CAAC,WAAW;YACrB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SACzE;QACD,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CACtB,MAAM,CAAC,MAAM,CACX,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,YAAY,CAAC,EAC7D,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CACnB;KACmB,CAAC;AAC3B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { Harnesses } from "@usine/agents/harness/node";
2
+ import { type HarnessDescriptor } from "@usine/agents/harness";
3
+ import type { Harness } from "@usine/core/agent/brain";
4
+ import type { AttemptId } from "@usine/core/attempt";
5
+ import { Effect } from "effect";
6
+ import type { RemoteCommands } from "../remote/commands.ts";
7
+ import type { SshMachine } from "./model.ts";
8
+ /** Returns the harness home of `attemptId` in the Worker directory `workerDirectory`. */
9
+ export declare const attemptHomeIn: (workerDirectory: string, attemptId: AttemptId, harness: Harness) => string;
10
+ /**
11
+ * Tracks the harness homes that Attempts in this process use. `hold` gives an Attempt its harness
12
+ * home and removes the directory when the caller's scope closes. `sweep` removes the harness homes
13
+ * on a long-lived machine that no Attempt holds and whose Attempt has no checkout there, which
14
+ * a crash or a failed removal left.
15
+ */
16
+ export declare const attemptHomesFor: (commands: RemoteCommands) => Effect.Effect<{
17
+ hold: (machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">, descriptor: HarnessDescriptor) => Effect.Effect<string, never, import("effect/Scope").Scope>;
18
+ sweep: (machine: SshMachine) => Effect.Effect<void, never, never>;
19
+ }, never, Harnesses>;
20
+ /** The harness homes of the SSH executor's Attempts. See `attemptHomesFor`. */
21
+ export type AttemptHomes = Effect.Success<ReturnType<typeof attemptHomesFor>>;
22
+ //# sourceMappingURL=attempt-homes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attempt-homes.d.ts","sourceRoot":"","sources":["../../src/ssh/attempt-homes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAe7C,yFAAyF;AACzF,eAAO,MAAM,aAAa,oBACP,MAAM,aACZ,SAAS,WACX,OAAO,KACf,MAAgF,CAAC;AAEpF;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;oBAiH1B,CAAC;AAEH,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { Harnesses } from "@usine/agents/harness/node";
2
+ import {} from "@usine/agents/harness";
3
+ import { safeSegment } from "@usine/core/repository";
4
+ import { Effect, Option, Ref } from "effect";
5
+ import { directChildren } from "../remote/sweep.js";
6
+ /**
7
+ * A script that prints each directory in the harness homes directory `$1` whose Attempt has no
8
+ * checkout in the attempts directory `$2`, NUL-terminated. Prints nothing if `$1` is missing.
9
+ */
10
+ const HOMES_WITHOUT_CHECKOUT_SCRIPT = String.raw `
11
+ set -e
12
+ [ -d "$1" ] || exit 0
13
+ for home in "$1"/* "$1"/.[!.]* "$1"/..?*; do
14
+ [ -e "$home" ] || continue
15
+ [ -e "$2/$(basename "$home")" ] || printf '%s\0' "$home"
16
+ done
17
+ `.trim();
18
+ /** Returns the harness home of `attemptId` in the Worker directory `workerDirectory`. */
19
+ export const attemptHomeIn = (workerDirectory, attemptId, harness) => `${workerDirectory}/${safeSegment(harness)}/${safeSegment(attemptId)}`;
20
+ /**
21
+ * Tracks the harness homes that Attempts in this process use. `hold` gives an Attempt its harness
22
+ * home and removes the directory when the caller's scope closes. `sweep` removes the harness homes
23
+ * on a long-lived machine that no Attempt holds and whose Attempt has no checkout there, which
24
+ * a crash or a failed removal left.
25
+ */
26
+ export const attemptHomesFor = Effect.fn("SshExecutor.attemptHomesFor")(function* (commands) {
27
+ const { catalog } = yield* Harnesses;
28
+ // The number of holds on each harness home, by path.
29
+ const held = yield* Ref.make(new Map());
30
+ const count = (home, change) => Ref.update(held, (current) => {
31
+ const next = new Map(current);
32
+ const holds = (current.get(home) ?? 0) + change;
33
+ if (holds > 0)
34
+ next.set(home, holds);
35
+ else
36
+ next.delete(home);
37
+ return next;
38
+ });
39
+ const hold = Effect.fn("SshExecutor.holdAttemptHome")(function* (machine, attemptId, descriptor) {
40
+ const home = attemptHomeIn(machine.workerDirectory, attemptId, descriptor.id);
41
+ const fields = { attemptId, worker: machine.address.name, home };
42
+ yield* Effect.annotateCurrentSpan(fields);
43
+ // Held before the caller writes the directory, so a sweep that lists it finds the hold.
44
+ yield* Effect.acquireRelease(count(home, 1), () => commands.run("cleanup", machine.shell, "rm", ["-rf", home]).pipe(Effect.tap(() => Effect.logDebug("Removed the Attempt's harness home", fields)), Effect.tapError((error) => Effect.logWarning("Could not remove the Attempt's harness home; the next sweep removes it once the Attempt's checkout is gone", { ...fields, message: error.message })), Effect.ignore, Effect.ensuring(count(home, -1))));
45
+ return home;
46
+ });
47
+ const sweep = Effect.fn("SshExecutor.sweepAttemptHomes")(function* (machine) {
48
+ const worker = machine.address.name;
49
+ const host = machine.shell.destination;
50
+ yield* Effect.annotateCurrentSpan({ worker, host });
51
+ yield* Effect.forEach(catalog.descriptors.filter(({ worker }) => Option.exists(worker.credential, ({ home }) => Option.isSome(home))), (descriptor) => sweepHarness(machine, descriptor).pipe(Effect.tapError((error) => Effect.logWarning("Could not sweep a harness's attempt homes; the next sweep tries again", { worker, host, harness: descriptor.id, message: error.message })), Effect.ignore), { discard: true });
52
+ });
53
+ const sweepHarness = Effect.fn("SshExecutor.sweepHarnessHomes")(function* (machine, descriptor) {
54
+ const worker = machine.address.name;
55
+ const host = machine.shell.destination;
56
+ yield* Effect.annotateCurrentSpan({ worker, host, harness: descriptor.id });
57
+ const root = `${machine.workerDirectory}/${safeSegment(descriptor.id)}`;
58
+ const output = yield* commands.run("cleanup", machine.shell, "sh", [
59
+ "-c",
60
+ HOMES_WITHOUT_CHECKOUT_SCRIPT,
61
+ "sh",
62
+ root,
63
+ `${machine.workerDirectory}/attempts`,
64
+ ]);
65
+ const listed = yield* directChildren("cleanup", root, output);
66
+ // Read after the listing, so a harness home created since then can't be removed.
67
+ const holds = yield* Ref.get(held);
68
+ const leftovers = listed.filter((home) => !holds.has(home));
69
+ if (leftovers.length === 0)
70
+ return yield* Effect.logDebug("No harness home to remove on the SSH Worker", {
71
+ worker,
72
+ host,
73
+ withoutCheckout: listed.length,
74
+ });
75
+ // Removes each harness home separately, so one failure doesn't keep the others.
76
+ yield* Effect.forEach(leftovers, (home) => commands.run("cleanup", machine.shell, "rm", ["-rf", home]).pipe(Effect.tap(() => Effect.logInfo("Removed a harness home that no Attempt holds and whose Attempt has no checkout", { worker, host, home })), Effect.tapError((error) => Effect.logWarning("Could not remove a harness home; the next sweep tries again", {
77
+ worker,
78
+ host,
79
+ home,
80
+ message: error.message,
81
+ })), Effect.ignore), { discard: true });
82
+ });
83
+ return { hold, sweep };
84
+ });
85
+ //# sourceMappingURL=attempt-homes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attempt-homes.js","sourceRoot":"","sources":["../../src/ssh/attempt-homes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAA0B,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;GAGG;AACH,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;CAO/C,CAAC,IAAI,EAAE,CAAC;AAET,yFAAyF;AACzF,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,eAAuB,EACvB,SAAoB,EACpB,OAAgB,EACR,EAAE,CAAC,GAAG,eAAe,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAAC,QAAQ,CAAC,EAC/E,QAAwB;IAExB,MAAM,EAAE,OAAO,EAAE,G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C5D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YACxB,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,6CAA6C,EAAE;gBAC3E,MAAM;gBACN,IAAI;gBACJ,eAAe,EAAE,MAAM,CAAC,MAAM;aAC/B,CAAC,CAAC;QACL,gFAAgF;QAChF,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CACnB,SAAS,EACT,CAAC,IAAI,EAAE,EAAE,CACP,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAC9D,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CACd,MAAM,CAAC,OAAO,CACZ,gFAAgF,EAChF,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CACvB,CACF,EACD,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,MAAM,CAAC,UAAU,CAAC,6DAA6D,EAAE;YAC/E,MAAM;YACN,IAAI;YACJ,IAAI;YACJ,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CACH,EACD,MAAM,CAAC,MAAM,CACd,EACH,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type AttachRequest, type Attached, type AttachmentId, type AttachmentList, type Detached, type LlmProviderList } from "@usine/gateway/admin";
1
+ import { type AttachRequest, type Attached, type AttachmentId, type AttachmentList, type Detached, LlmProviderList } from "@usine/gateway/admin";
2
2
  import { type Brand, Effect, Option, Schema } from "effect";
3
3
  import { HttpClient } from "effect/http";
4
4
  import type { SshWorkerGateway } from "../model.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":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B,CAAC,CAAC;CACtF;AAsGD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;gCAqF1B,CAAC"}
@@ -1,8 +1,8 @@
1
- import { WorkerName } from "@usine/core/worker";
2
- import { GatewayAdminApi, } from "@usine/gateway/admin";
3
- import { DateTime, Effect, Option, Result, Schema } from "effect";
1
+ import { GatewayCredentialKind, GatewayLlmProtocol, GatewayLlmProvider, WorkerName, } from "@usine/core/worker";
2
+ import { GatewayAdminApi, LlmProviderList, LlmProviderSummary, AdminAuthorization, } from "@usine/gateway/admin";
3
+ import { DateTime, Effect, Option, Result, Schema, SchemaGetter, } from "effect";
4
4
  import { HttpClient, HttpClientError, HttpClientRequest } from "effect/http";
5
- import { HttpApiClient } from "effect/http-api";
5
+ import { HttpApi, HttpApiGroup, HttpApiEndpoint, HttpApiClient } from "effect/http-api";
6
6
  import { GatewayForwardClosed } from "./forward.js";
7
7
  const GatewayAdminOperation = Schema.Literals(["attach", "renew", "detach", "list", "providers"]);
8
8
  const ACTIONS = {
@@ -72,9 +72,29 @@ const sinceFields = (failure) => {
72
72
  return { unansweredSince: DateTime.formatIso(failure.since) };
73
73
  return {};
74
74
  };
75
- const adminClientAt = (url, adminToken) => HttpApiClient.make(GatewayAdminApi, {
76
- baseUrl: url,
77
- transformClient: HttpClient.mapRequest(HttpClientRequest.bearerToken(adminToken)),
75
+ const ReportedProtocol = Schema.Union([GatewayLlmProvider, GatewayLlmProtocol]).pipe(Schema.decodeTo(GatewayLlmProtocol, {
76
+ decode: SchemaGetter.transform((value) => value === "anthropic"
77
+ ? "anthropic-messages"
78
+ : value === "openai"
79
+ ? "openai-responses"
80
+ : value),
81
+ encode: SchemaGetter.transform((value) => value),
82
+ }));
83
+ const CompatibleProvidersApi = HttpApi.make("CompatibleProvidersApi").add(HttpApiGroup.make("llm")
84
+ .add(HttpApiEndpoint.get("providers", "/v1/providers", {
85
+ success: Schema.Struct({
86
+ providers: Schema.Array(Schema.Struct({ provider: ReportedProtocol, credential: GatewayCredentialKind })),
87
+ }),
88
+ }))
89
+ .middleware(AdminAuthorization));
90
+ const adminClientAt = (url, adminToken) => Effect.gen(function* () {
91
+ const options = {
92
+ baseUrl: url,
93
+ transformClient: HttpClient.mapRequest(HttpClientRequest.bearerToken(adminToken)),
94
+ };
95
+ const client = yield* HttpApiClient.make(GatewayAdminApi, options);
96
+ const compatible = yield* HttpApiClient.make(CompatibleProvidersApi, options);
97
+ return { ...client, llm: compatible.llm };
78
98
  });
79
99
  /**
80
100
  * Returns the admin API client for the Gateway in front of `worker`, connected through
@@ -127,7 +147,9 @@ export const gatewayAdminFor = Effect.fn("SshExecutor.gatewayAdminFor")(function
127
147
  renew: (id, request) => bounded("renew")((client) => client.attachments.renew({ params: { id }, payload: request })),
128
148
  detach: (id) => bounded("detach")((client) => client.attachments.detach({ params: { id } })),
129
149
  list: bounded("list")((client) => client.attachments.list()),
130
- providers: bounded("providers")((client) => client.llm.providers().pipe(Effect.asSome, Effect.catchIf(unknownRoute, () => Effect.succeedNone))),
150
+ providers: bounded("providers")((client) => client.llm.providers().pipe(Effect.map((reported) => Option.some(LlmProviderList.make({
151
+ providers: reported.providers.map((provider) => LlmProviderSummary.make(provider)),
152
+ }))), Effect.catchIf(unknownRoute, () => Effect.succeedNone))),
131
153
  };
132
154
  });
133
155
  //# sourceMappingURL=admin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/ssh/gateway/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAML,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAc,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAA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AAC,MAAM,CAAC,WAAW,CAAC,CACvD,CACF;KACqB,CAAC;AAC3B,CAAC,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { Harnesses } from "@usine/agents/harness/node";
1
2
  import type { RemoteShell } from "@usine/agents/child-host";
2
3
  import { Effect, Redacted } from "effect";
3
4
  import { CredentialProvider, CredentialUnavailableError, type ExecutorOperation } from "../../executor.ts";
@@ -8,11 +9,10 @@ export declare const writeMachineFiles: (commands: RemoteCommands, operation: Ex
8
9
  /**
9
10
  * Grants each Attempt repository access through the Gateway without a token on the machine
10
11
  * (ADR 0027). Attaches the token, renews it before expiry, re-stores it every two minutes, and
11
- * detaches it when the scope closes. If the Gateway holds the OpenAI credential, gives the
12
- * Attempt its Codex home through `holdCodexHome`. On first use of a Worker, detaches attachments
12
+ * detaches it when the scope closes. Allocates the homes required by registered gateway wiring through `holdAttemptHome`. On first use of a Worker, detaches attachments
13
13
  * left by an earlier process.
14
14
  */
15
- export declare const gatewayAttachmentsFor: (commands: RemoteCommands, holdCodexHome: (machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">) => Effect.Effect<string, never, import("effect/Scope").Scope>, onDetachFailure: (machine: SshMachine) => Effect.Effect<void>) => Effect.Effect<{
15
+ export declare const gatewayAttachmentsFor: (commands: RemoteCommands, holdAttemptHome: (machine: SshMachine, attemptId: string & import("effect/Brand").Brand<"AttemptId">, descriptor: import("@usine/agents/harness").HarnessDescriptor) => Effect.Effect<string, never, import("effect/Scope").Scope>, onDetachFailure: (machine: SshMachine) => Effect.Effect<void>) => Effect.Effect<{
16
16
  acquire: (attemptId: string & import("effect/Brand").Brand<"AttemptId">, worker: string & import("effect/Brand").Brand<"WorkerName">, repository: string & import("effect/Brand").Brand<"RepositoryName">, permissions: "read" | "write", machine: SshMachine, gateway: MachineGateway, operation: "cancel" | "cleanup" | "launch" | "preflight" | "prepare") => Effect.Effect<{
17
17
  shell: RemoteShell;
18
18
  secrets: Readonly<Record<string, Redacted.Redacted<string>>>;
@@ -25,5 +25,5 @@ export declare const gatewayAttachmentsFor: (commands: RemoteCommands, holdCodex
25
25
  scrub: (text: string) => string;
26
26
  }, CredentialUnavailableError | import("../../executor.ts").ExecutorOperationError, import("effect/Scope").Scope>;
27
27
  reclaim: (value: Pick<SshMachine, "address" | "gateway">) => Effect.Effect<void, never, never>;
28
- }, never, CredentialProvider>;
28
+ }, never, CredentialProvider | Harnesses>;
29
29
  //# sourceMappingURL=attachments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../../src/ssh/gateway/attachments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM5D,OAAO,EAAY,MAAM,EAAU,QAAQ,EAAkB,MAAM,QAAQ,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,iBAAiB,EAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAI7E,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6B9D,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,aAClB,cAAc,aACb,iBAAiB,SACrB,WAAW,SACX,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,qFAC2B,CAAC;AAW7F;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,2NAGL,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;;;;;;;;;6BA6O7D,CAAC"}
1
+ {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../../src/ssh/gateway/attachments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM5D,OAAO,EAAY,MAAM,EAAU,QAAQ,EAAkB,MAAM,QAAQ,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,iBAAiB,EAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAI7E,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6B9D,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,aAClB,cAAc,aACb,iBAAiB,SACrB,WAAW,SACX,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,qFAC2B,CAAC;AAgB7F;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,4RAGL,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;;;;;;;;;yCAuP7D,CAAC"}
@@ -1,10 +1,11 @@
1
+ import { Harnesses } from "@usine/agents/harness/node";
1
2
  import { reclaimOnceFor } from "../../remote/reclaim.js";
2
3
  import { AttachRequest, InstallationCredential } from "@usine/gateway/admin";
3
4
  import { DateTime, Effect, Option, Redacted, Ref, Semaphore } from "effect";
4
5
  import { CredentialProvider, CredentialUnavailableError, } from "../../executor.js";
5
6
  import { sendingShell } from "../../remote/commands.js";
6
7
  import { renewableCredential } from "../../renewable-credential.js";
7
- import { attemptCodexHome } from "../codex-homes.js";
8
+ import { attemptHomeIn } from "../attempt-homes.js";
8
9
  import { GH_GATEWAY_SOCKET_DIRECTORY, gatewayConfigFiles, gatewayEnvironment, } from "./environment.js";
9
10
  /**
10
11
  * A script that takes path and contents pairs and writes each file, creating its directory.
@@ -25,20 +26,23 @@ const RESTORE_INTERVAL = "2 minutes";
25
26
  export const writeMachineFiles = (commands, operation, shell, files) => commands.run(operation, shell, "sh", ["-c", WRITE_FILES_SCRIPT, "sh", ...files.flat()]);
26
27
  /**
27
28
  * Returns the directory of gh's configuration on a Worker behind a Gateway, and the Attempt's
28
- * Codex home. Neither contains a token.
29
+ * harness homes. These directories contain no token.
29
30
  */
30
- const configDirectories = (machine, attemptId) => ({
31
+ const configDirectories = (catalog, machine, attemptId) => ({
31
32
  ghConfigDirectory: `${machine.workerDirectory}/gh`,
32
- codexHome: attemptCodexHome(machine, attemptId),
33
+ homes: Object.fromEntries(catalog.descriptors.map(({ id }) => [
34
+ id,
35
+ attemptHomeIn(machine.workerDirectory, attemptId, id),
36
+ ])),
33
37
  });
34
38
  /**
35
39
  * Grants each Attempt repository access through the Gateway without a token on the machine
36
40
  * (ADR 0027). Attaches the token, renews it before expiry, re-stores it every two minutes, and
37
- * detaches it when the scope closes. If the Gateway holds the OpenAI credential, gives the
38
- * Attempt its Codex home through `holdCodexHome`. On first use of a Worker, detaches attachments
41
+ * detaches it when the scope closes. Allocates the homes required by registered gateway wiring through `holdAttemptHome`. On first use of a Worker, detaches attachments
39
42
  * left by an earlier process.
40
43
  */
41
- export const gatewayAttachmentsFor = Effect.fn("SshExecutor.gatewayAttachmentsFor")(function* (commands, holdCodexHome, onDetachFailure) {
44
+ export const gatewayAttachmentsFor = Effect.fn("SshExecutor.gatewayAttachmentsFor")(function* (commands, holdAttemptHome, onDetachFailure) {
45
+ const { catalog } = yield* Harnesses;
42
46
  const provider = yield* CredentialProvider;
43
47
  const active = new Set();
44
48
  const membership = yield* Semaphore.make(1);
@@ -75,11 +79,10 @@ export const gatewayAttachmentsFor = Effect.fn("SshExecutor.gatewayAttachmentsFo
75
79
  const { admin, settings } = gateway;
76
80
  const fields = { attemptId, worker, repository, permissions, domain: settings.domain };
77
81
  yield* Effect.annotateCurrentSpan(fields);
78
- const directories = configDirectories(machine, attemptId);
79
- const codex = settings.llmProviders.includes("openai");
80
- if (codex)
81
- yield* holdCodexHome(machine, attemptId);
82
+ const directories = configDirectories(catalog, machine, attemptId);
83
+ const homes = yield* Effect.forEach(catalog.descriptors.filter(({ worker }) => Option.exists(worker.credential, ({ protocol, home }) => settings.llmProviders.includes(protocol) && Option.isSome(home))), (descriptor) => holdAttemptHome(machine, attemptId, descriptor));
82
84
  yield* writeMachineFiles(commands, operation, machine.shell, gatewayConfigFiles({
85
+ catalog,
83
86
  domain: settings.domain,
84
87
  llmProviders: settings.llmProviders,
85
88
  ...directories,
@@ -151,6 +154,7 @@ export const gatewayAttachmentsFor = Effect.fn("SshExecutor.gatewayAttachmentsFo
151
154
  message: error.message,
152
155
  })), Effect.ignore)).pipe(Effect.forkScoped);
153
156
  const { exported, sent } = gatewayEnvironment({
157
+ catalog,
154
158
  domain: settings.domain,
155
159
  egress: settings.egress,
156
160
  llmProviders: settings.llmProviders,
@@ -162,7 +166,7 @@ export const gatewayAttachmentsFor = Effect.fn("SshExecutor.gatewayAttachmentsFo
162
166
  secrets: sent,
163
167
  apiKeyHarnesses: new Set(),
164
168
  readOnlyPaths: [directories.ghConfigDirectory, GH_GATEWAY_SOCKET_DIRECTORY],
165
- writablePaths: codex ? [directories.codexHome] : [],
169
+ writablePaths: homes,
166
170
  environment: exported,
167
171
  gitEnvironment: exported,
168
172
  refresh: credential.refresh(),