@usine/executor 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/README.md +212 -37
- package/dist/child-command.d.ts +5 -8
- package/dist/child-command.d.ts.map +1 -1
- package/dist/child-command.js +10 -14
- package/dist/child-command.js.map +1 -1
- package/dist/child-environment.d.ts +19 -0
- package/dist/child-environment.d.ts.map +1 -0
- package/dist/child-environment.js +18 -0
- package/dist/child-environment.js.map +1 -0
- package/dist/claude-login-lock.d.ts +9 -0
- package/dist/claude-login-lock.d.ts.map +1 -0
- package/dist/claude-login-lock.js +15 -0
- package/dist/claude-login-lock.js.map +1 -0
- package/dist/cloudflare/client.d.ts +50 -0
- package/dist/cloudflare/client.d.ts.map +1 -0
- package/dist/cloudflare/client.js +108 -0
- package/dist/cloudflare/client.js.map +1 -0
- package/dist/cloudflare/cloudflare.d.ts +17 -0
- package/dist/cloudflare/cloudflare.d.ts.map +1 -0
- package/dist/cloudflare/cloudflare.js +704 -0
- package/dist/cloudflare/cloudflare.js.map +1 -0
- package/dist/cloudflare/model.d.ts +42 -0
- package/dist/cloudflare/model.d.ts.map +1 -0
- package/dist/cloudflare/model.js +2 -0
- package/dist/cloudflare/model.js.map +1 -0
- package/dist/cloudflare/shell/environment.d.ts +12 -0
- package/dist/cloudflare/shell/environment.d.ts.map +1 -0
- package/dist/cloudflare/shell/environment.js +12 -0
- package/dist/cloudflare/shell/environment.js.map +1 -0
- package/dist/cloudflare/shell/shell.d.ts +2 -0
- package/dist/cloudflare/shell/shell.d.ts.map +1 -0
- package/dist/cloudflare/shell/shell.js +155 -0
- package/dist/cloudflare/shell/shell.js.map +1 -0
- package/dist/credential-environment.d.ts +20 -0
- package/dist/credential-environment.d.ts.map +1 -0
- package/dist/credential-environment.js +20 -0
- package/dist/credential-environment.js.map +1 -0
- package/dist/durable-session.d.ts +81 -0
- package/dist/durable-session.d.ts.map +1 -0
- package/dist/durable-session.js +550 -0
- package/dist/durable-session.js.map +1 -0
- package/dist/exe-dev/commands.d.ts +23 -13
- package/dist/exe-dev/commands.d.ts.map +1 -1
- package/dist/exe-dev/commands.js +11 -57
- package/dist/exe-dev/commands.js.map +1 -1
- package/dist/exe-dev/exe-dev.d.ts +9 -3
- package/dist/exe-dev/exe-dev.d.ts.map +1 -1
- package/dist/exe-dev/exe-dev.js +61 -128
- package/dist/exe-dev/exe-dev.js.map +1 -1
- package/dist/exe-dev/grants.d.ts.map +1 -1
- package/dist/exe-dev/grants.js +35 -15
- package/dist/exe-dev/grants.js.map +1 -1
- package/dist/exe-dev/model.d.ts +15 -19
- package/dist/exe-dev/model.d.ts.map +1 -1
- package/dist/exe-dev/model.js +9 -12
- package/dist/exe-dev/model.js.map +1 -1
- package/dist/exe-dev/preflight.d.ts +8 -4
- package/dist/exe-dev/preflight.d.ts.map +1 -1
- package/dist/exe-dev/preflight.js +26 -35
- package/dist/exe-dev/preflight.js.map +1 -1
- package/dist/executor.d.ts +292 -44
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +187 -19
- package/dist/executor.js.map +1 -1
- package/dist/guard.d.ts +57 -7
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +274 -59
- package/dist/guard.js.map +1 -1
- package/dist/harness-preflight.d.ts +27 -5
- package/dist/harness-preflight.d.ts.map +1 -1
- package/dist/harness-preflight.js +32 -31
- package/dist/harness-preflight.js.map +1 -1
- package/dist/keyed-lock.d.ts +2 -3
- package/dist/keyed-lock.d.ts.map +1 -1
- package/dist/keyed-lock.js +2 -3
- package/dist/keyed-lock.js.map +1 -1
- package/dist/leftovers.d.ts +9 -0
- package/dist/leftovers.d.ts.map +1 -0
- package/dist/leftovers.js +14 -0
- package/dist/leftovers.js.map +1 -0
- package/dist/local/credentials.d.ts +21 -0
- package/dist/local/credentials.d.ts.map +1 -0
- package/dist/local/credentials.js +39 -0
- package/dist/local/credentials.js.map +1 -0
- package/dist/local/leftovers.d.ts +8 -0
- package/dist/local/leftovers.d.ts.map +1 -0
- package/dist/local/leftovers.js +23 -0
- package/dist/local/leftovers.js.map +1 -0
- package/dist/local/local.d.ts +17 -11
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +205 -132
- package/dist/local/local.js.map +1 -1
- package/dist/memory-preflight.d.ts +27 -0
- package/dist/memory-preflight.d.ts.map +1 -0
- package/dist/memory-preflight.js +83 -0
- package/dist/memory-preflight.js.map +1 -0
- package/dist/pre-push-hook.d.ts +20 -0
- package/dist/pre-push-hook.d.ts.map +1 -0
- package/dist/pre-push-hook.js +33 -0
- package/dist/pre-push-hook.js.map +1 -0
- package/dist/prepared-attempt.d.ts +41 -3
- package/dist/prepared-attempt.d.ts.map +1 -1
- package/dist/prepared-attempt.js +109 -31
- package/dist/prepared-attempt.js.map +1 -1
- package/dist/provision.d.ts +129 -15
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +428 -69
- package/dist/provision.js.map +1 -1
- package/dist/remote/commands.d.ts +51 -0
- package/dist/remote/commands.d.ts.map +1 -0
- package/dist/remote/commands.js +94 -0
- package/dist/remote/commands.js.map +1 -0
- package/dist/remote/container.d.ts +90 -0
- package/dist/remote/container.d.ts.map +1 -0
- package/dist/remote/container.js +480 -0
- package/dist/remote/container.js.map +1 -0
- package/dist/remote/leftovers.d.ts +14 -0
- package/dist/remote/leftovers.d.ts.map +1 -0
- package/dist/remote/leftovers.js +22 -0
- package/dist/remote/leftovers.js.map +1 -0
- package/dist/remote/liveness.d.ts +33 -0
- package/dist/remote/liveness.d.ts.map +1 -0
- package/dist/remote/liveness.js +196 -0
- package/dist/remote/liveness.js.map +1 -0
- package/dist/remote/machine.d.ts +110 -0
- package/dist/remote/machine.d.ts.map +1 -0
- package/dist/remote/machine.js +2 -0
- package/dist/remote/machine.js.map +1 -0
- package/dist/remote/remote.d.ts +28 -0
- package/dist/remote/remote.d.ts.map +1 -0
- package/dist/remote/remote.js +556 -0
- package/dist/remote/remote.js.map +1 -0
- package/dist/remote/sweep.d.ts +17 -0
- package/dist/remote/sweep.d.ts.map +1 -0
- package/dist/remote/sweep.js +117 -0
- package/dist/remote/sweep.js.map +1 -0
- package/dist/renewable-credential.d.ts +17 -0
- package/dist/renewable-credential.d.ts.map +1 -0
- package/dist/renewable-credential.js +58 -0
- package/dist/renewable-credential.js.map +1 -0
- package/dist/salvage.d.ts +38 -0
- package/dist/salvage.d.ts.map +1 -0
- package/dist/salvage.js +198 -0
- package/dist/salvage.js.map +1 -0
- package/dist/ssh/api-keys.d.ts +36 -0
- package/dist/ssh/api-keys.d.ts.map +1 -0
- package/dist/ssh/api-keys.js +72 -0
- package/dist/ssh/api-keys.js.map +1 -0
- package/dist/ssh/codex-homes.d.ts +21 -0
- package/dist/ssh/codex-homes.d.ts.map +1 -0
- package/dist/ssh/codex-homes.js +78 -0
- package/dist/ssh/codex-homes.js.map +1 -0
- package/dist/ssh/container.d.ts +32 -0
- package/dist/ssh/container.d.ts.map +1 -0
- package/dist/ssh/container.js +282 -0
- package/dist/ssh/container.js.map +1 -0
- package/dist/ssh/credentials.d.ts +43 -0
- package/dist/ssh/credentials.d.ts.map +1 -0
- package/dist/ssh/credentials.js +86 -0
- package/dist/ssh/credentials.js.map +1 -0
- package/dist/ssh/gateway/admin.d.ts +45 -0
- package/dist/ssh/gateway/admin.d.ts.map +1 -0
- package/dist/ssh/gateway/admin.js +129 -0
- package/dist/ssh/gateway/admin.js.map +1 -0
- package/dist/ssh/gateway/attachments.d.ts +31 -0
- package/dist/ssh/gateway/attachments.d.ts.map +1 -0
- package/dist/ssh/gateway/attachments.js +168 -0
- package/dist/ssh/gateway/attachments.js.map +1 -0
- package/dist/ssh/gateway/environment.d.ts +71 -0
- package/dist/ssh/gateway/environment.d.ts.map +1 -0
- package/dist/ssh/gateway/environment.js +148 -0
- package/dist/ssh/gateway/environment.js.map +1 -0
- package/dist/ssh/gateway/forward.d.ts +74 -0
- package/dist/ssh/gateway/forward.d.ts.map +1 -0
- package/dist/ssh/gateway/forward.js +247 -0
- package/dist/ssh/gateway/forward.js.map +1 -0
- package/dist/ssh/gateway/preflight.d.ts +67 -0
- package/dist/ssh/gateway/preflight.d.ts.map +1 -0
- package/dist/ssh/gateway/preflight.js +320 -0
- package/dist/ssh/gateway/preflight.js.map +1 -0
- package/dist/ssh/limits.d.ts +60 -0
- package/dist/ssh/limits.d.ts.map +1 -0
- package/dist/ssh/limits.js +84 -0
- package/dist/ssh/limits.js.map +1 -0
- package/dist/ssh/model.d.ts +153 -0
- package/dist/ssh/model.d.ts.map +1 -0
- package/dist/ssh/model.js +2 -0
- package/dist/ssh/model.js.map +1 -0
- package/dist/ssh/preflight.d.ts +35 -0
- package/dist/ssh/preflight.d.ts.map +1 -0
- package/dist/ssh/preflight.js +87 -0
- package/dist/ssh/preflight.js.map +1 -0
- package/dist/ssh/provisioner/boat.d.ts +33 -0
- package/dist/ssh/provisioner/boat.d.ts.map +1 -0
- package/dist/ssh/provisioner/boat.js +247 -0
- package/dist/ssh/provisioner/boat.js.map +1 -0
- package/dist/ssh/provisioner/hetzner.d.ts +32 -0
- package/dist/ssh/provisioner/hetzner.d.ts.map +1 -0
- package/dist/ssh/provisioner/hetzner.js +337 -0
- package/dist/ssh/provisioner/hetzner.js.map +1 -0
- package/dist/ssh/provisioner/host-key.d.ts +11 -0
- package/dist/ssh/provisioner/host-key.d.ts.map +1 -0
- package/dist/ssh/provisioner/host-key.js +57 -0
- package/dist/ssh/provisioner/host-key.js.map +1 -0
- package/dist/ssh/provisioner/http.d.ts +45 -0
- package/dist/ssh/provisioner/http.d.ts.map +1 -0
- package/dist/ssh/provisioner/http.js +72 -0
- package/dist/ssh/provisioner/http.js.map +1 -0
- package/dist/ssh/provisioner/machines.d.ts +48 -0
- package/dist/ssh/provisioner/machines.d.ts.map +1 -0
- package/dist/ssh/provisioner/machines.js +686 -0
- package/dist/ssh/provisioner/machines.js.map +1 -0
- package/dist/ssh/provisioner/model.d.ts +92 -0
- package/dist/ssh/provisioner/model.d.ts.map +1 -0
- package/dist/ssh/provisioner/model.js +37 -0
- package/dist/ssh/provisioner/model.js.map +1 -0
- package/dist/ssh/ssh.d.ts +23 -0
- package/dist/ssh/ssh.d.ts.map +1 -0
- package/dist/ssh/ssh.js +145 -0
- package/dist/ssh/ssh.js.map +1 -0
- package/dist/ssh/worker-records.d.ts +18 -0
- package/dist/ssh/worker-records.d.ts.map +1 -0
- package/dist/ssh/worker-records.js +100 -0
- package/dist/ssh/worker-records.js.map +1 -0
- package/dist/ssh/workers.d.ts +80 -0
- package/dist/ssh/workers.d.ts.map +1 -0
- package/dist/ssh/workers.js +247 -0
- package/dist/ssh/workers.js.map +1 -0
- package/package.json +25 -9
- package/dist/exe-dev/channel.d.ts +0 -12
- package/dist/exe-dev/channel.d.ts.map +0 -1
- package/dist/exe-dev/channel.js +0 -42
- package/dist/exe-dev/channel.js.map +0 -1
- package/dist/exe-dev/shell.d.ts +0 -12
- package/dist/exe-dev/shell.d.ts.map +0 -1
- package/dist/exe-dev/shell.js +0 -31
- package/dist/exe-dev/shell.js.map +0 -1
- package/dist/exe-dev/sweep.d.ts +0 -10
- package/dist/exe-dev/sweep.d.ts.map +0 -1
- package/dist/exe-dev/sweep.js +0 -117
- package/dist/exe-dev/sweep.js.map +0 -1
- package/dist/invalid-frame.d.ts +0 -17
- package/dist/invalid-frame.d.ts.map +0 -1
- package/dist/invalid-frame.js +0 -111
- package/dist/invalid-frame.js.map +0 -1
- package/dist/run-host-session.d.ts +0 -27
- package/dist/run-host-session.d.ts.map +0 -1
- package/dist/run-host-session.js +0 -303
- package/dist/run-host-session.js.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { SshCommand } from "@usine/agents/child-host";
|
|
2
|
+
import type { MachineId, MachineProvider, WorkerName } from "@usine/core/worker";
|
|
3
|
+
import { Context, Effect, Option, Scope } from "effect";
|
|
4
|
+
import { HttpClient } from "effect/http";
|
|
5
|
+
import { ChildProcessSpawner } from "effect/process";
|
|
6
|
+
import { WorkerCapabilityError } from "../executor.ts";
|
|
7
|
+
import type { RemoteCommands } from "../remote/commands.ts";
|
|
8
|
+
import type { MachineGateway, SshMachine, SshWorkerAddress } from "./model.ts";
|
|
9
|
+
import type { MachineEndpoint } from "./provisioner/model.ts";
|
|
10
|
+
declare const SshWorkers_base: Context.ServiceClass<SshWorkers, "@usine/executor/SshWorkers", {
|
|
11
|
+
/**
|
|
12
|
+
* Adds the machine at `address` for preflight and Attempts. Behind a Gateway, shares the admin
|
|
13
|
+
* API forward with other Workers that have the same `destination` and `adminPort`, or opens it.
|
|
14
|
+
* Adding a Worker again with the same address does nothing; with a different address, fails
|
|
15
|
+
* with a `machine` capability error. The SSH executor's `addWorker` also records how to reach
|
|
16
|
+
* a long-lived Worker's machine in `SshExecutorOptions.workerRecordsDirectory`.
|
|
17
|
+
*/
|
|
18
|
+
readonly addWorker: (address: SshWorkerAddress) => Effect.Effect<void, WorkerCapabilityError>;
|
|
19
|
+
/**
|
|
20
|
+
* Removes `worker`'s machine, so later requests for it fail with a `machine` capability error.
|
|
21
|
+
* Call only when no Attempt runs on the Worker. If it was the last Worker behind its Gateway,
|
|
22
|
+
* closes the admin API forward. Removing an unknown Worker does nothing.
|
|
23
|
+
*/
|
|
24
|
+
readonly removeWorker: (worker: WorkerName) => Effect.Effect<void>;
|
|
25
|
+
}>;
|
|
26
|
+
/** The Workers of the SSH executor, starting with `SshExecutorOptions.workers`. A reload adds and removes Workers at runtime. */
|
|
27
|
+
export declare class SshWorkers extends SshWorkers_base {
|
|
28
|
+
}
|
|
29
|
+
/** A Worker the executor has: its address and Gateway, and its machine if it's long-lived. */
|
|
30
|
+
export interface SshWorkerEntry {
|
|
31
|
+
readonly address: SshWorkerAddress;
|
|
32
|
+
readonly gateway: Option.Option<MachineGateway>;
|
|
33
|
+
/** `None` for a provisioned Worker, whose machines exist one per Attempt. */
|
|
34
|
+
readonly machine: Option.Option<SshMachine>;
|
|
35
|
+
}
|
|
36
|
+
/** Returns the directory of a Worker's state on its machine, `<root>/workers/<name>`. */
|
|
37
|
+
export declare const workerDirectoryOf: (address: Pick<SshWorkerAddress, "root" | "name">) => string;
|
|
38
|
+
/** Returns the SSH command for one Worker: the shared options, then its port and key. */
|
|
39
|
+
export declare const sshCommandFor: (base: SshCommand, address: Pick<SshWorkerAddress, "port" | "identityFile">) => SshCommand;
|
|
40
|
+
/** A provisioned machine's pinned SSH host key: its `known_hosts` file and the name the key is recorded under. */
|
|
41
|
+
export interface PinnedHostKey {
|
|
42
|
+
readonly file: string;
|
|
43
|
+
readonly alias: string;
|
|
44
|
+
}
|
|
45
|
+
/** Returns the name that a provisioned machine's host key is recorded under. */
|
|
46
|
+
export declare const hostKeyAlias: (provider: MachineProvider, id: MachineId) => string;
|
|
47
|
+
/** Returns the `known_hosts` line that pins `key` for the machine recorded under `alias`. */
|
|
48
|
+
export declare const knownHostsLine: (alias: string, key: string) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the SSH Workers' machines, which `addWorker` and `removeWorker` change at runtime and
|
|
51
|
+
* `machineFor` reads on each call. Each admin API forward runs in its own child scope and
|
|
52
|
+
* closes with its last Worker or the caller's scope.
|
|
53
|
+
*/
|
|
54
|
+
export declare const sshMachinesFor: (base: {
|
|
55
|
+
readonly command: string;
|
|
56
|
+
readonly args: readonly string[];
|
|
57
|
+
}, commands: RemoteCommands) => Effect.Effect<{
|
|
58
|
+
machineFor: (worker: string & import("effect/Brand").Brand<"WorkerName">) => Effect.Effect<SshMachine, WorkerCapabilityError, never>;
|
|
59
|
+
workerFor: (worker: string & import("effect/Brand").Brand<"WorkerName">) => Effect.Effect<SshWorkerEntry, WorkerCapabilityError, never>;
|
|
60
|
+
machineAt: (entry: SshWorkerEntry, id: MachineId, endpoint: MachineEndpoint, hostKey: PinnedHostKey) => SshMachine;
|
|
61
|
+
entries: Effect.Effect<SshWorkerEntry[], never, never>;
|
|
62
|
+
workers: {
|
|
63
|
+
/**
|
|
64
|
+
* Adds the machine at `address` for preflight and Attempts. Behind a Gateway, shares the admin
|
|
65
|
+
* API forward with other Workers that have the same `destination` and `adminPort`, or opens it.
|
|
66
|
+
* Adding a Worker again with the same address does nothing; with a different address, fails
|
|
67
|
+
* with a `machine` capability error. The SSH executor's `addWorker` also records how to reach
|
|
68
|
+
* a long-lived Worker's machine in `SshExecutorOptions.workerRecordsDirectory`.
|
|
69
|
+
*/
|
|
70
|
+
readonly addWorker: (address: SshWorkerAddress) => Effect.Effect<void, WorkerCapabilityError>;
|
|
71
|
+
/**
|
|
72
|
+
* Removes `worker`'s machine, so later requests for it fail with a `machine` capability error.
|
|
73
|
+
* Call only when no Attempt runs on the Worker. If it was the last Worker behind its Gateway,
|
|
74
|
+
* closes the admin API forward. Removing an unknown Worker does nothing.
|
|
75
|
+
*/
|
|
76
|
+
readonly removeWorker: (worker: WorkerName) => Effect.Effect<void>;
|
|
77
|
+
};
|
|
78
|
+
}, never, ChildProcessSpawner.ChildProcessSpawner | HttpClient.HttpClient | Scope.Scope>;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=workers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/ssh/workers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAe,MAAM,EAAO,KAAK,EAAmB,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,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cAAc,MACjB,SAAS,YACH,eAAe,WAChB,aAAa,KACrB,UAAU;;;QArUX;;;;;;WAMG;4BACiB,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAAC;QAC7F;;;;WAIG;+BACoB,CAAC,MAAM,EAAE,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;wFA4UpE,CAAC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { safeSegment } from "@usine/core/repository";
|
|
2
|
+
import { Context, Effect, Equal, Exit, Option, Ref, Scope, SynchronizedRef } from "effect";
|
|
3
|
+
import { HttpClient } from "effect/http";
|
|
4
|
+
import { ChildProcessSpawner } from "effect/process";
|
|
5
|
+
import { WorkerCapabilityError } from "../executor.js";
|
|
6
|
+
import { gatewayAdminFor } from "./gateway/admin.js";
|
|
7
|
+
import { gatewayForwardFor } from "./gateway/forward.js";
|
|
8
|
+
/** The Workers of the SSH executor, starting with `SshExecutorOptions.workers`. A reload adds and removes Workers at runtime. */
|
|
9
|
+
export class SshWorkers extends Context.Service()("@usine/executor/SshWorkers") {
|
|
10
|
+
}
|
|
11
|
+
const forwardKey = ({ destination, adminPort }) => `${destination} ${String(adminPort)}`;
|
|
12
|
+
/** Returns where a Worker's machines are, for logs: its destination, or its provider. */
|
|
13
|
+
const placeOf = (address) => address.machine._tag === "Fixed"
|
|
14
|
+
? address.machine.destination
|
|
15
|
+
: `a ${address.machine.provisioner.provider} machine per attempt`;
|
|
16
|
+
/** Returns the directory of a Worker's state on its machine, `<root>/workers/<name>`. */
|
|
17
|
+
export const workerDirectoryOf = (address) => `${address.root}/workers/${safeSegment(address.name)}`;
|
|
18
|
+
/** Returns the SSH command for one Worker: the shared options, then its port and key. */
|
|
19
|
+
export const sshCommandFor = (base, address) => ({
|
|
20
|
+
command: base.command,
|
|
21
|
+
args: [
|
|
22
|
+
...base.args,
|
|
23
|
+
...Option.match(address.port, { onNone: () => [], onSome: (port) => ["-p", String(port)] }),
|
|
24
|
+
...Option.match(address.identityFile, {
|
|
25
|
+
onNone: () => [],
|
|
26
|
+
onSome: (file) => ["-i", file, "-o", "IdentitiesOnly=yes"],
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Returns the SSH command for a machine created for one Attempt: the shared options, its pinned
|
|
32
|
+
* host key, the Gateway as jump host if the Worker has one, and its port and the Worker's key.
|
|
33
|
+
* The key is recorded under an alias rather than the address, so it holds for the machine
|
|
34
|
+
* whatever address it reports, and the client accepts no other key.
|
|
35
|
+
*/
|
|
36
|
+
const provisionedSshCommandFor = (base, entry, endpoint, hostKey) => ({
|
|
37
|
+
command: base.command,
|
|
38
|
+
args: [
|
|
39
|
+
...base.args,
|
|
40
|
+
"-o",
|
|
41
|
+
`UserKnownHostsFile=${hostKey.file}`,
|
|
42
|
+
"-o",
|
|
43
|
+
`HostKeyAlias=${hostKey.alias}`,
|
|
44
|
+
"-o",
|
|
45
|
+
"StrictHostKeyChecking=yes",
|
|
46
|
+
...Option.match(entry.gateway, {
|
|
47
|
+
onNone: () => [],
|
|
48
|
+
onSome: ({ settings }) => ["-J", settings.destination],
|
|
49
|
+
}),
|
|
50
|
+
...Option.match(endpoint.port, { onNone: () => [], onSome: (port) => ["-p", String(port)] }),
|
|
51
|
+
...Option.match(entry.address.identityFile, {
|
|
52
|
+
onNone: () => [],
|
|
53
|
+
onSome: (file) => ["-i", file, "-o", "IdentitiesOnly=yes"],
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
/** Returns the name that a provisioned machine's host key is recorded under. */
|
|
58
|
+
export const hostKeyAlias = (provider, id) => `usine-${provider}-${id}`;
|
|
59
|
+
/** Returns the `known_hosts` line that pins `key` for the machine recorded under `alias`. */
|
|
60
|
+
export const knownHostsLine = (alias, key) => `${alias} ${key}\n`;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the SSH Workers' machines, which `addWorker` and `removeWorker` change at runtime and
|
|
63
|
+
* `machineFor` reads on each call. Each admin API forward runs in its own child scope and
|
|
64
|
+
* closes with its last Worker or the caller's scope.
|
|
65
|
+
*/
|
|
66
|
+
export const sshMachinesFor = Effect.fnUntraced(function* (base, commands) {
|
|
67
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
68
|
+
const http = yield* HttpClient.HttpClient;
|
|
69
|
+
const scope = yield* Scope.Scope;
|
|
70
|
+
const machines = yield* SynchronizedRef.make({
|
|
71
|
+
byWorker: new Map(),
|
|
72
|
+
forwards: new Map(),
|
|
73
|
+
});
|
|
74
|
+
const openForward = Effect.fnUntraced(function* (settings) {
|
|
75
|
+
const forwardScope = yield* Scope.fork(scope);
|
|
76
|
+
const forward = yield* gatewayForwardFor(spawner, commands.shellFor(base, settings.destination), settings.destination, settings.adminPort).pipe(Scope.provide(forwardScope));
|
|
77
|
+
return { forward, scope: forwardScope };
|
|
78
|
+
});
|
|
79
|
+
/** Returns the Gateway for `address`'s machine with the forward it shares or opens, and the updated forwards. */
|
|
80
|
+
const gatewayFor = Effect.fnUntraced(function* (current, address, settings) {
|
|
81
|
+
const key = forwardKey(settings);
|
|
82
|
+
const shared = Option.fromNullishOr(current.forwards.get(key));
|
|
83
|
+
const { forward, scope: forwardScope } = Option.isSome(shared)
|
|
84
|
+
? shared.value
|
|
85
|
+
: yield* openForward(settings);
|
|
86
|
+
const admin = yield* gatewayAdminFor(address.name, settings, forward).pipe(Effect.provideService(HttpClient.HttpClient, http));
|
|
87
|
+
const workers = Option.match(shared, {
|
|
88
|
+
onNone: () => new Set([address.name]),
|
|
89
|
+
onSome: (held) => new Set([...held.workers, address.name]),
|
|
90
|
+
});
|
|
91
|
+
const credentials = yield* Ref.make({
|
|
92
|
+
anthropic: Option.none(),
|
|
93
|
+
openai: Option.none(),
|
|
94
|
+
});
|
|
95
|
+
const warnedOfUnreportedCredential = yield* Ref.make(false);
|
|
96
|
+
return {
|
|
97
|
+
gateway: {
|
|
98
|
+
settings,
|
|
99
|
+
forward,
|
|
100
|
+
admin,
|
|
101
|
+
credentials,
|
|
102
|
+
warnedOfUnreportedCredential,
|
|
103
|
+
},
|
|
104
|
+
forwards: new Map(current.forwards).set(key, { forward, scope: forwardScope, workers }),
|
|
105
|
+
opened: Option.isNone(shared),
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
const addWorker = Effect.fn("SshExecutor.addWorker")(function* (address) {
|
|
109
|
+
const fields = {
|
|
110
|
+
worker: address.name,
|
|
111
|
+
host: placeOf(address),
|
|
112
|
+
...Option.match(address.gateway, {
|
|
113
|
+
onNone: () => ({}),
|
|
114
|
+
onSome: ({ destination }) => ({ gateway: destination }),
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
117
|
+
yield* Effect.annotateCurrentSpan(fields);
|
|
118
|
+
const added = yield* SynchronizedRef.modifyEffect(machines, (current) => Effect.gen(function* () {
|
|
119
|
+
const existing = current.byWorker.get(address.name);
|
|
120
|
+
if (existing !== undefined) {
|
|
121
|
+
if (Equal.equals(existing.address, address))
|
|
122
|
+
return [Option.none(), current];
|
|
123
|
+
return yield* new WorkerCapabilityError({
|
|
124
|
+
worker: address.name,
|
|
125
|
+
capability: "machine",
|
|
126
|
+
message: `Can't change the settings of SSH worker "${address.name}" while its attempts run. Reload again after they end.`,
|
|
127
|
+
cause: new Error(`SSH worker "${address.name}" is in use at ${placeOf(existing.address)}`),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const behind = yield* Effect.transposeOption(Option.map(address.gateway, (settings) => gatewayFor(current, address, settings)));
|
|
131
|
+
const gateway = Option.map(behind, ({ gateway }) => gateway);
|
|
132
|
+
const entry = {
|
|
133
|
+
address,
|
|
134
|
+
gateway,
|
|
135
|
+
machine: address.machine._tag === "Fixed"
|
|
136
|
+
? Option.some({
|
|
137
|
+
address,
|
|
138
|
+
gateway,
|
|
139
|
+
shell: commands.shellFor(sshCommandFor(base, address), address.machine.destination),
|
|
140
|
+
workerDirectory: workerDirectoryOf(address),
|
|
141
|
+
provisioned: Option.none(),
|
|
142
|
+
})
|
|
143
|
+
: Option.none(),
|
|
144
|
+
};
|
|
145
|
+
return [
|
|
146
|
+
Option.some(Option.exists(behind, ({ opened }) => opened)),
|
|
147
|
+
{
|
|
148
|
+
byWorker: new Map(current.byWorker).set(address.name, entry),
|
|
149
|
+
forwards: Option.match(behind, {
|
|
150
|
+
onNone: () => current.forwards,
|
|
151
|
+
onSome: ({ forwards }) => forwards,
|
|
152
|
+
}),
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
}).pipe(Effect.uninterruptible));
|
|
156
|
+
yield* Option.match(added, {
|
|
157
|
+
onNone: () => Effect.logDebug("The SSH executor has this Worker with the same settings already", fields),
|
|
158
|
+
onSome: (opened) => Effect.logInfo(Option.isNone(address.gateway)
|
|
159
|
+
? "SSH Worker added to the executor"
|
|
160
|
+
: opened
|
|
161
|
+
? "SSH Worker added to the executor; it is the first behind its Gateway, so the forward to the Gateway's admin API opens"
|
|
162
|
+
: "SSH Worker added to the executor; it shares the forward to its Gateway's admin API", fields),
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
const removeWorker = Effect.fn("SshExecutor.removeWorker")(function* (worker) {
|
|
166
|
+
yield* Effect.annotateCurrentSpan({ worker });
|
|
167
|
+
const removed = yield* SynchronizedRef.modify(machines, (current) => {
|
|
168
|
+
const machine = current.byWorker.get(worker);
|
|
169
|
+
if (machine === undefined)
|
|
170
|
+
return [Option.none(), current];
|
|
171
|
+
const byWorker = new Map(current.byWorker);
|
|
172
|
+
byWorker.delete(worker);
|
|
173
|
+
const forwards = new Map(current.forwards);
|
|
174
|
+
const left = Option.flatMap(machine.gateway, ({ settings }) => {
|
|
175
|
+
const key = forwardKey(settings);
|
|
176
|
+
const held = forwards.get(key);
|
|
177
|
+
if (held === undefined)
|
|
178
|
+
return Option.none();
|
|
179
|
+
const workers = new Set(held.workers);
|
|
180
|
+
workers.delete(worker);
|
|
181
|
+
if (workers.size === 0)
|
|
182
|
+
forwards.delete(key);
|
|
183
|
+
else
|
|
184
|
+
forwards.set(key, { ...held, workers });
|
|
185
|
+
return Option.some({ held, others: workers.size });
|
|
186
|
+
});
|
|
187
|
+
return [Option.some({ machine, left }), { byWorker, forwards }];
|
|
188
|
+
});
|
|
189
|
+
if (Option.isNone(removed)) {
|
|
190
|
+
yield* Effect.logDebug("The SSH executor has no Worker by this name to remove", { worker });
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const { machine, left } = removed.value;
|
|
194
|
+
const fields = { worker, host: placeOf(machine.address) };
|
|
195
|
+
if (Option.isNone(left)) {
|
|
196
|
+
yield* Effect.logInfo("SSH Worker removed from the executor", fields);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const { held, others } = left.value;
|
|
200
|
+
const gatewayFields = { ...fields, gateway: held.forward.gateway };
|
|
201
|
+
if (others > 0) {
|
|
202
|
+
yield* Effect.logInfo("SSH Worker removed from the executor; the forward to its Gateway's admin API stays open for the other Workers behind it", { ...gatewayFields, others });
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
yield* Scope.close(held.scope, Exit.void);
|
|
206
|
+
yield* Effect.logInfo("SSH Worker removed from the executor; it was the last behind its Gateway, so the forward to the Gateway's admin API closed", gatewayFields);
|
|
207
|
+
});
|
|
208
|
+
const workerFor = Effect.fn("SshExecutor.workerFor")(function* (worker) {
|
|
209
|
+
const entry = (yield* SynchronizedRef.get(machines)).byWorker.get(worker);
|
|
210
|
+
if (entry === undefined)
|
|
211
|
+
return yield* new WorkerCapabilityError({
|
|
212
|
+
worker,
|
|
213
|
+
capability: "machine",
|
|
214
|
+
message: `No SSH worker named "${worker}" is configured`,
|
|
215
|
+
cause: new Error("SSH worker address missing"),
|
|
216
|
+
});
|
|
217
|
+
return entry;
|
|
218
|
+
});
|
|
219
|
+
/** Returns a long-lived Worker's machine. Fails for a provisioned Worker, which has none. */
|
|
220
|
+
const machineFor = Effect.fn("SshExecutor.machineFor")(function* (worker) {
|
|
221
|
+
const entry = yield* workerFor(worker);
|
|
222
|
+
if (Option.isNone(entry.machine))
|
|
223
|
+
return yield* new WorkerCapabilityError({
|
|
224
|
+
worker,
|
|
225
|
+
capability: "machine",
|
|
226
|
+
message: `SSH worker "${worker}" creates a machine for each attempt, so it has no machine of its own`,
|
|
227
|
+
cause: new Error("provisioned SSH worker"),
|
|
228
|
+
});
|
|
229
|
+
return entry.machine.value;
|
|
230
|
+
});
|
|
231
|
+
/** Returns the machine at `endpoint` that a provider created for one Attempt on `entry`'s Worker. */
|
|
232
|
+
const machineAt = (entry, id, endpoint, hostKey) => ({
|
|
233
|
+
address: entry.address,
|
|
234
|
+
gateway: entry.gateway,
|
|
235
|
+
shell: commands.shellFor(provisionedSshCommandFor(base, entry, endpoint, hostKey), endpoint.destination),
|
|
236
|
+
workerDirectory: workerDirectoryOf(entry.address),
|
|
237
|
+
provisioned: Option.some(id),
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
machineFor,
|
|
241
|
+
workerFor,
|
|
242
|
+
machineAt,
|
|
243
|
+
entries: SynchronizedRef.get(machines).pipe(Effect.map(({ byWorker }) => [...byWorker.values()])),
|
|
244
|
+
workers: SshWorkers.of({ addWorker, removeWorker }),
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
//# sourceMappingURL=workers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workers.js","sourceRoot":"","sources":["../../src/ssh/workers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,E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AAW,CACrB;QACD,eAAe,EAAE,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC;QACjD,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;KAC7B,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;QACV,SAAS;QACT,SAAS;QACT,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CACzC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CACrD;QACD,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/executor",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The usine scoped Worker contract with local
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "The usine scoped Worker contract with local, exe.dev, SSH, and Cloudflare adapters.",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/basaltbytes/usine.git",
|
|
9
9
|
"directory": "packages/executor"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
13
14
|
],
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": false,
|
|
@@ -18,6 +19,10 @@
|
|
|
18
19
|
"types": "./dist/executor.d.ts",
|
|
19
20
|
"default": "./dist/executor.js"
|
|
20
21
|
},
|
|
22
|
+
"./cloudflare": {
|
|
23
|
+
"types": "./dist/cloudflare/cloudflare.d.ts",
|
|
24
|
+
"default": "./dist/cloudflare/cloudflare.js"
|
|
25
|
+
},
|
|
21
26
|
"./exe-dev": {
|
|
22
27
|
"types": "./dist/exe-dev/exe-dev.d.ts",
|
|
23
28
|
"default": "./dist/exe-dev/exe-dev.js"
|
|
@@ -25,23 +30,34 @@
|
|
|
25
30
|
"./local": {
|
|
26
31
|
"types": "./dist/local/local.d.ts",
|
|
27
32
|
"default": "./dist/local/local.js"
|
|
33
|
+
},
|
|
34
|
+
"./ssh": {
|
|
35
|
+
"types": "./dist/ssh/ssh.d.ts",
|
|
36
|
+
"default": "./dist/ssh/ssh.js"
|
|
28
37
|
}
|
|
29
38
|
},
|
|
30
39
|
"publishConfig": {
|
|
31
40
|
"access": "public"
|
|
32
41
|
},
|
|
33
42
|
"dependencies": {
|
|
34
|
-
"@usine/
|
|
43
|
+
"@usine/cloudflare": "0.1.0",
|
|
44
|
+
"@usine/core": "0.5.0",
|
|
45
|
+
"@usine/agents": "0.5.0",
|
|
46
|
+
"@usine/durable": "0.2.0",
|
|
47
|
+
"@usine/gateway": "0.2.0"
|
|
35
48
|
},
|
|
36
49
|
"devDependencies": {
|
|
37
|
-
"@effect/
|
|
38
|
-
"effect": "4.0.
|
|
50
|
+
"@effect/platform-node": "4.0.6",
|
|
51
|
+
"@effect/vitest": "4.0.6",
|
|
52
|
+
"@types/ws": "8.18.2",
|
|
53
|
+
"effect": "4.0.6",
|
|
39
54
|
"typescript": "7.0.2",
|
|
40
|
-
"vitest": "
|
|
55
|
+
"vitest": "5.0.5",
|
|
56
|
+
"ws": "8.22.0",
|
|
41
57
|
"@usine/tsconfig": "0.0.0"
|
|
42
58
|
},
|
|
43
59
|
"peerDependencies": {
|
|
44
|
-
"effect": "4.0.
|
|
60
|
+
"effect": "4.0.6"
|
|
45
61
|
},
|
|
46
62
|
"engines": {
|
|
47
63
|
"node": ">=22"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type * as AttemptChannel from "@usine/core/attempt/channel";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
4
|
-
import type { AttemptWorkspace, RunHostCommand } from "../executor.ts";
|
|
5
|
-
import type { ExeDevCommands } from "./commands.ts";
|
|
6
|
-
import type { VmState } from "./model.ts";
|
|
7
|
-
export declare const attemptChannelFor: (commands: ExeDevCommands, runHost: RunHostCommand, interruptGrace: import("effect/Duration").Input) => Effect.Effect<{
|
|
8
|
-
cancel: (attemptId: import("@usine/core/attempt").AttemptId) => Effect.Effect<void, import("../executor.ts").ExecutorError>;
|
|
9
|
-
intervene: (attemptId: import("@usine/core/attempt").AttemptId, intervention: AttemptChannel.Intervention) => Effect.Effect<void, import("@usine/core/attempt/failure").AttemptFailure>;
|
|
10
|
-
launch: (prepared: AttemptWorkspace, vm: VmState, io: AttemptChannel.Sink) => Effect.Effect<import("@usine/core/step/result").StepResult, import("@usine/core/attempt/failure").AgentFailure | import("@usine/core/attempt/failure").ChildSessionBudgetFailure | import("@usine/core/attempt/failure").DefectFailure | import("@usine/core/attempt/failure").InfraFailure | import("@usine/core/attempt/failure").RunawayFailure, never>;
|
|
11
|
-
}, never, ChildProcessSpawner.ChildProcessSpawner>;
|
|
12
|
-
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/exe-dev/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,eAAO,MAAM,iBAAiB;;;uBAkDP,gBAAgB,MAAM,OAAO,MAAM,cAAc,CAAC,IAAI;kDAG3E,CAAC"}
|
package/dist/exe-dev/channel.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Effect, Stream } from "effect";
|
|
2
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
3
|
-
import { runHostSessionFor } from "../run-host-session.js";
|
|
4
|
-
import { runHostShellCommand } from "./shell.js";
|
|
5
|
-
export const attemptChannelFor = Effect.fn("ExeDevExecutor.attemptChannelFor")(function* (commands, runHost, interruptGrace) {
|
|
6
|
-
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
7
|
-
const spawn = Effect.fn("ExeDevExecutor.spawnRunHost")(function* (prepared, vm, input) {
|
|
8
|
-
const attemptId = prepared.spec.attemptId;
|
|
9
|
-
yield* Effect.annotateCurrentSpan({
|
|
10
|
-
attemptId,
|
|
11
|
-
worker: prepared.worker,
|
|
12
|
-
host: vm.sshDest,
|
|
13
|
-
});
|
|
14
|
-
yield* Effect.logInfo("Launching the run host over SSH", {
|
|
15
|
-
attemptId,
|
|
16
|
-
worker: prepared.worker,
|
|
17
|
-
host: vm.sshDest,
|
|
18
|
-
worktree: prepared.worktree,
|
|
19
|
-
});
|
|
20
|
-
const handle = yield* spawner.spawn(ChildProcess.make(commands.ssh.command, [
|
|
21
|
-
...commands.ssh.args,
|
|
22
|
-
vm.sshDest,
|
|
23
|
-
"--",
|
|
24
|
-
runHostShellCommand(prepared.worktree, runHost.command, runHost.args),
|
|
25
|
-
], {
|
|
26
|
-
env: commands.environment,
|
|
27
|
-
extendEnv: false,
|
|
28
|
-
stdin: { stream: Stream.fromQueue(input), endOnDone: true },
|
|
29
|
-
}));
|
|
30
|
-
// Nothing to scrub: this process never has a secret the run host could echo,
|
|
31
|
-
// because the exe.dev integration injects credentials on the VM. If a
|
|
32
|
-
// credential ever passes through this process, scrub it here.
|
|
33
|
-
return { handle, host: vm.sshDest, scrub: (text) => text };
|
|
34
|
-
});
|
|
35
|
-
const session = yield* runHostSessionFor({ interruptGrace });
|
|
36
|
-
return {
|
|
37
|
-
cancel: session.cancel,
|
|
38
|
-
intervene: session.intervene,
|
|
39
|
-
launch: (prepared, vm, io) => session.launch(prepared, io, (input) => spawn(prepared, vm, input)),
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=channel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/exe-dev/channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAqB,MAAM,wBAAwB,CAAC;AAG9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,kCAAkC,CAAC,CAAC,QAAQ,CAAC,EACtF,QAAwB,EACxB,OAAuB,EACvB,cAA0D;IAE1D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,mBAAmB,CAAC;IAE/D,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAAC,QAAQ,CAAC,EAC9D,QAA0B,EAC1B,EAAW,EACX,KAAmB;QAEnB,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1C,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAChC,SAAS;YACT,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,IAAI,EAAE,EAAE,CAAC,OAAO;SACjB,CAAC,CAAC;QACH,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iCAAiC,EAAE;YACvD,SAAS;YACT,MAAM,EAAE,QAAQ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dev/shell.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Quotes a command and its arguments into one string safe for OpenSSH's remote-command boundary. */
|
|
2
|
-
export declare const shellCommand: (command: string, args: ReadonlyArray<string>) => string;
|
|
3
|
-
/** The pid file sits beside the worktree so the sweep reclaims both together. */
|
|
4
|
-
export declare const runHostPidFile: (worktree: string) => string;
|
|
5
|
-
/** The remote command that starts the run host in its worktree with the edge GitHub host selected. */
|
|
6
|
-
export declare const runHostShellCommand: (worktree: string, command: string, args: ReadonlyArray<string>) => string;
|
|
7
|
-
/**
|
|
8
|
-
* Confirms a recorded run host is dead before workspace removal: TERM, a
|
|
9
|
-
* bounded wait, then KILL. `$1` is the pid file; stdout reports the outcome.
|
|
10
|
-
*/
|
|
11
|
-
export declare const RUN_HOST_KILL_SCRIPT: string;
|
|
12
|
-
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/exe-dev/shell.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,eAAO,MAAM,YAAY,YAAa,MAAM,QAAQ,aAAa,CAAC,MAAM,CAAC,KAAG,MACzB,CAAC;AAEpD,iFAAiF;AACjF,eAAO,MAAM,cAAc,aAAc,MAAM,KAAG,MAA2B,CAAC;AAE9E,sGAAsG;AACtG,eAAO,MAAM,mBAAmB,aACpB,MAAM,WACP,MAAM,QACT,aAAa,CAAC,MAAM,CAAC,KAC1B,MAIsJ,CAAC;AAE1J;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAczB,CAAC"}
|
package/dist/exe-dev/shell.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const quote = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
2
|
-
/** Quotes a command and its arguments into one string safe for OpenSSH's remote-command boundary. */
|
|
3
|
-
export const shellCommand = (command, args) => `exec ${[command, ...args].map(quote).join(" ")}`;
|
|
4
|
-
/** The pid file sits beside the worktree so the sweep reclaims both together. */
|
|
5
|
-
export const runHostPidFile = (worktree) => `${worktree}.pid`;
|
|
6
|
-
/** The remote command that starts the run host in its worktree with the edge GitHub host selected. */
|
|
7
|
-
export const runHostShellCommand = (worktree, command, args) =>
|
|
8
|
-
// `$$` names the remote shell that `exec` replaces with the run host, so the
|
|
9
|
-
// pid file identifies the run host itself. Cleanup uses it to confirm the
|
|
10
|
-
// process is gone before removing the worktree.
|
|
11
|
-
`cd ${quote(worktree)} && export GH_HOST=github.int.exe.xyz && printf '%s' "$$" > ${quote(runHostPidFile(worktree))} && ${shellCommand(command, args)}`;
|
|
12
|
-
/**
|
|
13
|
-
* Confirms a recorded run host is dead before workspace removal: TERM, a
|
|
14
|
-
* bounded wait, then KILL. `$1` is the pid file; stdout reports the outcome.
|
|
15
|
-
*/
|
|
16
|
-
export const RUN_HOST_KILL_SCRIPT = `
|
|
17
|
-
if test -f "$1"; then
|
|
18
|
-
pid=$(cat "$1")
|
|
19
|
-
if kill -TERM "$pid" 2>/dev/null; then
|
|
20
|
-
n=0
|
|
21
|
-
while kill -0 "$pid" 2>/dev/null && [ "$n" -lt 10 ]; do sleep 0.5; n=$((n+1)); done
|
|
22
|
-
if kill -0 "$pid" 2>/dev/null; then kill -KILL "$pid" 2>/dev/null; echo killed; else echo stopped; fi
|
|
23
|
-
else
|
|
24
|
-
echo absent
|
|
25
|
-
fi
|
|
26
|
-
rm -f "$1"
|
|
27
|
-
else
|
|
28
|
-
echo no-pidfile
|
|
29
|
-
fi
|
|
30
|
-
`.trim();
|
|
31
|
-
//# sourceMappingURL=shell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/exe-dev/shell.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AAE/E,qGAAqG;AACrG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,IAA2B,EAAU,EAAE,CACnF,QAAQ,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEpD,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,GAAG,QAAQ,MAAM,CAAC;AAE9E,sGAAsG;AACtG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAAgB,EAChB,OAAe,EACf,IAA2B,EACnB,EAAE;AACV,6EAA6E;AAC7E,0EAA0E;AAC1E,gDAAgD;AAChD,MAAM,KAAK,CAAC,QAAQ,CAAC,+DAA+D,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,OAAO,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;AAE1J;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;CAcnC,CAAC,IAAI,EAAE,CAAC"}
|
package/dist/exe-dev/sweep.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import type { ExeDevCommands } from "./commands.ts";
|
|
3
|
-
import type { VmState } from "./model.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Reclaims crash leftovers once per Worker before this process starts work on
|
|
6
|
-
* its VM. Each removal is isolated and each failure is logged, so one immovable
|
|
7
|
-
* leftover never blocks the sweep's siblings or a future prepare.
|
|
8
|
-
*/
|
|
9
|
-
export declare const abandonedWorktreeSweepFor: (commands: ExeDevCommands) => Effect.Effect<(attemptId: string & import("effect/Brand").Brand<"AttemptId">, worker: string & import("effect/Brand").Brand<"WorkerName">, vm: VmState, root: string) => Effect.Effect<void, never, never>, never, never>;
|
|
10
|
-
//# sourceMappingURL=sweep.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sweep.d.ts","sourceRoot":"","sources":["../../src/exe-dev/sweep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAG7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAwC1C;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,yPAiIrC,CAAC"}
|