Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.12.7",
"version": "0.12.8",
"type": "module",
"bin": {
"spawn": "cli.js"
Expand Down
16 changes: 7 additions & 9 deletions packages/cli/src/daytona/daytona.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,13 @@ export async function uploadFile(localPath: string, remotePath: string): Promise
const content: Buffer = readFileSync(localPath);
const b64 = content.toString("base64");

// Validate base64 only contains safe characters
if (/[^A-Za-z0-9+/=]/.test(b64)) {
logError("upload_file: base64 output contains unexpected characters");
throw new Error("Invalid base64");
}

const args = [
...sshBaseArgs(),
"-o",
"BatchMode=yes",
`${sshToken}@${sshHost}`,
"--",
`printf '%s' '${b64}' | base64 -d > '${remotePath}'`,
`base64 -d > '${remotePath}'`,
];

const proc = Bun.spawn(args, {
Expand All @@ -497,9 +491,13 @@ export async function uploadFile(localPath: string, remotePath: string): Promise
],
});
try {
proc.stdin!.end();
const stdin = proc.stdin;
if (stdin) {
stdin.write(b64 + "\n");
stdin.end();
}
} catch {
/* already closed */
/* stdin already closed */
}
const exitCode = await proc.exited;

Expand Down