@whyvix/remote 0.3.7 → 0.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyvix/remote",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -11,6 +11,11 @@ function classifySshFailure(state,code){
11
11
  if(text.includes("permission denied")||text.includes("authentication failed")||text.includes("no supported authentication methods available"))return "REMOTE_AUTH_FAILED";
12
12
  return state.errorCode||"REMOTE_EXEC_FAILED";
13
13
  }
14
+ function quoteRemoteArg(value){
15
+ const text=String(value);
16
+ return "'" + text.replaceAll("'", "'\"'\"'") + "'";
17
+ }
18
+ function serializeRemoteCommand(argv){return argv.map(quoteRemoteArg).join(" ");}
14
19
  function appendBounded(state,key,chunk,maxBytes){
15
20
  const current=Buffer.from(state[key],"utf8"),incoming=Buffer.from(chunk);
16
21
  const room=Math.max(0,maxBytes-current.length);
@@ -52,7 +57,7 @@ export class RemoteExecutionManager {
52
57
  for(const state of this.jobs.values())if(state.running)runningJobs++;
53
58
  if(runningJobs>=this.maxRunningJobs)fail("REMOTE_JOB_LIMIT","Remote running job limit reached");
54
59
  const target=this.#target(alias),remoteArgv=allowDeployHelper?["whyvix-deploy",...args]:this.#argv(executable,args),timeout=Math.max(1,Math.min(Number(timeoutMs)||30000,300000)),id=String(this.nextId++);
55
- const sshArgs=["--",target.alias,...remoteArgv],child=this.spawnFn("ssh",sshArgs,{windowsHide:true,shell:false});
60
+ const sshArgs=["--",target.alias,serializeRemoteCommand(remoteArgv)],child=this.spawnFn("ssh",sshArgs,{windowsHide:true,shell:false});
56
61
  const state={id,ownerId:String(ownerId),alias:target.alias,executable,stdout:"",stderr:"",truncated:false,running:true,exitCode:null,child};this.jobs.set(id,state);this.audit({event:"remote.start",id,alias:state.alias,executable});
57
62
  child.stdout?.on("data",x=>appendBounded(state,"stdout",x,this.maxOutputBytes));child.stderr?.on("data",x=>appendBounded(state,"stderr",x,this.maxOutputBytes));
58
63
  const finish=()=>{if(state.timer){clearTimeout(state.timer);state.timer=null;}};