Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(cli,platform): support WSL credential mounts, utf8 secret input, and resilient worker startup

alexqem60e79efd6552
diff --git a/packages/credential-store-file/src/store.ts b/packages/credential-store-file/src/store.ts
index 73f82de7..f504b3b6 100644
--- a/packages/credential-store-file/src/store.ts
+++ b/packages/credential-store-file/src/store.ts
@@ -1,10 +1,17 @@
import { replaceFile } from "@hypit/file-io-node";
import { randomUUID } from "node:crypto";
import { mkdir, open, rm, stat, unlink } from "node:fs/promises";
+import { release } from "node:os";
import { join } from "node:path";
import { verifyCredentialRef } from "@hypit/runtime";
import type { CredentialRef, CredentialValue, WritableCredentialStore } from "@hypit/runtime";
+function isWslOrPermissiveMount(targetPath: string): boolean {
+ if (process.platform === "win32") return true;
+ const isWsl = process.env.WSL_DISTRO_NAME !== undefined || release().toLowerCase().includes("microsoft");
+ return isWsl && (targetPath.startsWith("/mnt/") || targetPath.startsWith("/media/"));
+}
+
function missing(error: unknown): boolean {
return error instanceof Error && "code" in error && error.code === "ENOENT";
}
@@ -37,7 +44,7 @@ export class FileCredentialStore implements WritableCredentialStore {
if (create) await mkdir(this.directory, { recursive: true, mode: 0o700 });
const info = await stat(this.directory);
if (!info.isDirectory()) throw new Error(`Credential path is not a directory: ${this.directory}`);
- if (process.platform !== "win32" && (info.mode & 0o077) !== 0) {
+ if (process.platform !== "win32" && !isWslOrPermissiveMount(this.directory) && (info.mode & 0o077) !== 0) {
throw new Error(`Credential directory must be owner-private: ${this.directory}`);
}
}
@@ -56,7 +63,7 @@ export class FileCredentialStore implements WritableCredentialStore {
}
try {
const info = await file.stat();
- if (process.platform !== "win32" && (info.mode & 0o077) !== 0) {
+ if (process.platform !== "win32" && !isWslOrPermissiveMount(path) && (info.mode & 0o077) !== 0) {
throw new Error(`Credential file must be owner-private: ${path}`);
}
const text = await file.readFile("utf8");
diff --git a/packages/runtime-local/src/supervisor.ts b/packages/runtime-local/src/supervisor.ts
index c2cf0929..a3890bef 100644
--- a/packages/runtime-local/src/supervisor.ts
+++ b/packages/runtime-local/src/supervisor.ts
@@ -119,7 +119,13 @@ export async function superviseBuilds(options: {
if (options.signal.aborted) break;
accepting ??= launch();
const carrier = accepting;
- await carrier.ready;
+ try {
+ await carrier.ready;
+ } catch (error) {
+ if (accepting === carrier) accepting = undefined;
+ await finishInterrupted(build, `Build executor startup failed: ${error instanceof Error ? error.message : String(error)}; create a new Build to continue`);
+ continue;
+ }
if (carrier.exited) break;
if (accepting !== carrier) continue;
await state.execution.start(build);
diff --git a/packages/video-cli/src/cli.ts b/packages/video-cli/src/cli.ts
index 094c94d2..92f52c72 100644
--- a/packages/video-cli/src/cli.ts
+++ b/packages/video-cli/src/cli.ts
@@ -26,21 +26,27 @@ async function readSecret(prompt: string): Promise<string> {
}
process.stderr.write(prompt);
return await new Promise<string>((resolve, reject) => {
- let value = "";
+ const rawBytes: number[] = [];
const finish = (error?: Error): void => {
process.stdin.off("data", input);
process.stdin.setRawMode(false);
process.stdin.pause();
process.stderr.write("\n");
- if (error === undefined) resolve(value);
+ if (error === undefined) resolve(Buffer.from(rawBytes).toString("utf8"));
else reject(error);
};
const input = (chunk: Buffer): void => {
for (const byte of chunk) {
if (byte === 3) { finish(new Error("credential input cancelled")); return; }
if (byte === 10 || byte === 13) { finish(); return; }
- if (byte === 8 || byte === 127) { value = value.slice(0, -1); continue; }
- value += String.fromCharCode(byte);
+ if (byte === 8 || byte === 127) {
+ while (rawBytes.length > 0 && (rawBytes.at(-1)! & 0xc0) === 0x80) {
+ rawBytes.pop();
+ }
+ rawBytes.pop();
+ continue;
+ }
+ rawBytes.push(byte);
}
};
process.stdin.setRawMode(true);