fix: route AgentRun bridge from runners
This commit is contained in:
@@ -535,6 +535,28 @@ function scopedSshFrontendSession(host: string, config: UniDeskConfig, token: st
|
||||
return { baseUrl: frontendBaseUrl(host, config), cookie: "", sshClientToken: token };
|
||||
}
|
||||
|
||||
export async function runRemoteSshCommandCapture(
|
||||
config: UniDeskConfig,
|
||||
host: string,
|
||||
target: string,
|
||||
args: string[],
|
||||
input?: string,
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
): Promise<SshCaptureResult> {
|
||||
const token = sshClientTokenFromEnv(env);
|
||||
const session = token === null
|
||||
? await loginFrontend(host, config)
|
||||
: scopedSshFrontendSession(host, config, token);
|
||||
const normalizedArgs = normalizeSshOperationArgs(args);
|
||||
const invocation = parseSshInvocation(target, normalizedArgs);
|
||||
const parsed = invocation.parsed;
|
||||
if (parsed.remoteCommand === null) throw new Error(`remote ssh ${target} capture requires a non-interactive operation`);
|
||||
const stdin = parsed.stdinPrefix !== undefined || parsed.stdinSuffix !== undefined
|
||||
? `${parsed.stdinPrefix ?? ""}${input ?? ""}${parsed.stdinSuffix ?? ""}`
|
||||
: input;
|
||||
return await runRemoteSshWebSocketCaptureRemoteCommand(session, invocation, parsed.remoteCommand, stdin);
|
||||
}
|
||||
|
||||
async function frontendJson(session: FrontendSession, path: string, init?: RequestInit, timeoutMs = 8000, maxResponseBytes = 5_000_000): Promise<FetchJsonResult> {
|
||||
const headers = new Headers(init?.headers);
|
||||
headers.set("cookie", session.cookie);
|
||||
|
||||
Reference in New Issue
Block a user