fix(pi-ssh): harden remote execution and search

This commit is contained in:
云服务部-叶林立
2026-08-24 23:04:29 +08:00
parent a7891f18bf
commit aff91b0972
30 changed files with 1063 additions and 222 deletions
+27
View File
@@ -0,0 +1,27 @@
import type { BashOperations } from "@earendil-works/pi-coding-agent";
import type { RemoteTransport } from "./ssh2-transport.ts";
export interface RemoteBashConnection {
remoteCwd: string;
}
/**
* Adapt Pi's Bash output machinery to the active remote workspace.
*
* The cwd supplied by Pi's Bash factory is deliberately ignored: it belongs
* to the factory's filesystem namespace and must never leak into SSH command
* execution. The connection's mutable remoteCwd is the sole shell base.
*/
export function createRemoteBashOps(
connection: RemoteBashConnection,
transport: RemoteTransport,
): BashOperations {
return {
exec: (command, _factoryCwd, { onData, signal, timeout }) => {
if (!connection.remoteCwd.startsWith("/")) {
throw new Error(`ssh_bash requires an absolute remote cwd, received '${connection.remoteCwd}'`);
}
return transport.exec(command, connection.remoteCwd, { onData, signal, timeout });
},
};
}