feat: add JD01 YAML-first deployment support

This commit is contained in:
Codex
2026-06-29 08:13:34 +00:00
parent fe917bec4a
commit 076c4b643d
49 changed files with 10909 additions and 5223 deletions
+38 -3
View File
@@ -91,7 +91,7 @@ class SshFileTransferError extends Error {
}
const fileTransferWriteB64ArgvLimit = 48_000;
const fileTransferWriteRawChunkBytes = 1_048_576;
const fileTransferWriteRawChunkBytes = 131_072;
const fileTransferWriteB64ChunkChars = 1_398_104;
const fileTransferProgressEveryChunks = 16;
@@ -247,7 +247,7 @@ async function writeRemoteFileVerified(
const encoded = content.length <= fileTransferWriteB64ArgvLimit
? content.toString("base64")
: "";
if (invocation.route.plane !== "win" && encoded.length <= fileTransferWriteB64ArgvLimit) {
if (invocation.route.plane !== "win" && encoded.length > 0 && encoded.length <= fileTransferWriteB64ArgvLimit) {
await checkedFileTransfer(invocation, executor, builders, "write-b64-argv", [remotePath, expectedBytes, expectedSha256, ...chunkString(encoded, fileTransferWriteB64ChunkChars)]);
return { strategy: "argv", chunks: encoded.length === 0 ? 0 : Math.ceil(encoded.length / fileTransferWriteB64ChunkChars) };
}
@@ -260,14 +260,18 @@ async function writeRemoteFileVerified(
}
}
const token = `${process.pid}-${Date.now()}-${randomBytes(4).toString("hex")}-${expectedSha256.slice(0, 12)}`;
const startedAtMs = Date.now();
let chunks = 0;
await checkedFileTransfer(invocation, executor, builders, "write-b64-begin", [remotePath, token]);
for (let offset = 0; offset < content.length; offset += fileTransferWriteRawChunkBytes) {
const encodedChunk = content.subarray(offset, Math.min(content.length, offset + fileTransferWriteRawChunkBytes)).toString("base64");
const nextOffset = Math.min(content.length, offset + fileTransferWriteRawChunkBytes);
const encodedChunk = content.subarray(offset, nextOffset).toString("base64");
await checkedFileTransfer(invocation, executor, builders, "write-b64-append-stdin", [remotePath, token], encodedChunk);
chunks += 1;
emitUploadProgress(invocation, remotePath, chunks, nextOffset, content.length, nextOffset - offset, startedAtMs);
}
await checkedFileTransfer(invocation, executor, builders, "write-b64-commit", [remotePath, token, expectedBytes, expectedSha256]);
emitUploadProgress(invocation, remotePath, Math.max(1, chunks), content.length, content.length, 0, startedAtMs, true);
return { strategy: "chunked-stdin", chunks };
}
@@ -383,6 +387,37 @@ function emitDownloadProgress(
})}\n`);
}
function emitUploadProgress(
invocation: ParsedSshInvocation,
remotePath: string,
chunkCount: number,
actualBytes: number,
expectedBytes: number,
lastChunkBytes: number,
startedAtMs: number,
force = false,
): void {
if (!force && chunkCount !== 1 && actualBytes < expectedBytes && chunkCount % fileTransferProgressEveryChunks !== 0) return;
const elapsedMs = Math.max(1, Date.now() - startedAtMs);
process.stderr.write(`${JSON.stringify({
event: "unidesk.ssh.upload.progress",
at: new Date().toISOString(),
route: invocation.route.raw,
providerId: invocation.providerId,
remotePath,
strategy: "chunked-stdin",
chunks: chunkCount,
bytes: actualBytes,
totalBytes: expectedBytes,
actualBytes,
expectedBytes,
lastChunkBytes,
remainingBytes: Math.max(0, expectedBytes - actualBytes),
elapsedMs,
throughputBytesPerSecond: Math.round((actualBytes * 1000) / elapsedMs),
})}\n`);
}
async function statRemoteFile(
invocation: ParsedSshInvocation,
executor: SshRemoteCommandExecutor,