@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 57 lines 2.05 KB
Raw
1 import * as Alchemy from "alchemy";
2 import * as Effect from "effect/Effect";
3 import * as FileSystem from "effect/FileSystem";
4 import * as Path from "effect/Path";
5 import * as ChildProcess from "effect/process/ChildProcess";
6 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
7 import * as Stream from "effect/Stream";
8
9 const run = Effect.fn(function* (bin: string, args: string[], cwd?: string) {
10 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
11 const result = yield* ChildProcess.make(bin, args, {
12 cwd,
13 stdin: "ignore",
14 stdout: "pipe",
15 stderr: "pipe",
16 detached: false,
17 extendEnv: true,
18 }).pipe(
19 spawner.spawn,
20 Effect.flatMap((child) =>
21 Effect.all(
22 {
23 exitCode: child.exitCode,
24 stderr: child.stderr.pipe(Stream.decodeText, Stream.mkString),
25 },
26 { concurrency: "unbounded" },
27 ),
28 ),
29 );
30 if (result.exitCode !== 0) {
31 return yield* Effect.fail(
32 new Error(`${bin} ${args.join(" ")} exited ${result.exitCode}: ${result.stderr}`),
33 );
34 }
35 });
36
37 /**
38 * Deploy-time Action that fetches the AWS HyperPod Helm chart (the
39 * MANDATORY dependencies — health-monitoring agent, training operators,
40 * device plugins, RBAC — that SageMaker validates before an EKS-orchestrated
41 * cluster will attach) and vendors its subcharts. Returns the local chart
42 * path for `Kubernetes.HelmChart` to render.
43 */
44 export const FetchHyperPodChart = Alchemy.Action("FetchHyperPodChart", (input: { repo: string }) =>
45 Effect.gen(function* () {
46 const fs = yield* FileSystem.FileSystem;
47 const path = yield* Path.Path;
48 const cwd = yield* Effect.sync(() => process.cwd());
49 const cloneDir = path.join(cwd, ".alchemy", "cache", "hyperpod-cli");
50 if (!(yield* fs.exists(path.join(cloneDir, "helm_chart")))) {
51 yield* run("git", ["clone", "--depth", "1", input.repo, cloneDir]);
52 }
53 const chartPath = path.join(cloneDir, "helm_chart", "HyperPodHelmChart");
54 yield* run("helm", ["dependency", "update", chartPath]);
55 return { chartPath };
56 }),
57 );