π OpenHands: AI-Driven Development
fix: route cloud runtime bash/file calls through cloud proxy (#507)
Rohit Malhotra60e103eec507
diff --git a/__tests__/api/runtime-service/agent-server-runtime-service.test.ts b/__tests__/api/runtime-service/agent-server-runtime-service.test.tsnew file mode 100644index 0000000000..8fd0941fef--- /dev/null+++ b/__tests__/api/runtime-service/agent-server-runtime-service.test.ts@@ -0,0 +1,308 @@+import { FileClient } from "@openhands/typescript-client/clients";+import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import {+ __resetActiveStoreForTests,+ setActiveSelection,+ setRegisteredBackends,+} from "#/api/backend-registry/active-store";+import AgentServerRuntimeService from "#/api/runtime-service/agent-server-runtime-service";+import { callCloudProxy } from "#/api/cloud/proxy";+import type { Backend } from "#/api/backend-registry/types";++// βββ SDK client mocks βββββββββββββββββββββββββββββββββββββββββββββββββββββββ++const { executeCommandMock, downloadFileMock } = vi.hoisted(() => ({+ executeCommandMock: vi.fn(),+ downloadFileMock: vi.fn(),+}));++vi.mock("@openhands/typescript-client/workspace/remote-workspace", () => ({+ RemoteWorkspace: vi.fn(function RemoteWorkspaceMock() {+ return { executeCommand: executeCommandMock };+ }),+}));++vi.mock("@openhands/typescript-client/clients", () => ({+ FileClient: vi.fn(function FileClientMock() {+ return { downloadFile: downloadFileMock };+ }),+}));++vi.mock("#/api/agent-server-client-options", () => ({+ getAgentServerClientOptions: vi.fn(() => ({+ host: "http://local-agent.example.com",+ apiKey: "local-key",+ workingDir: "/workspace/project",+ })),+}));++vi.mock("#/api/cloud/proxy", () => ({+ callCloudProxy: vi.fn(),+}));++// βββ Backend fixtures ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++const cloudBackend: Backend = {+ id: "cloud-1",+ name: "Production",+ host: "https://app.all-hands.dev",+ apiKey: "cloud-api-key",+ kind: "cloud",+};++const CLOUD_CONVERSATION_URL =+ "https://runtime.example.com/api/conversations/conv-1";+const SESSION_KEY = "session-key-abc";++// βββ Helpers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++function activateCloud() {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id, orgId: null });+}++// βββ Setup βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++beforeEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ vi.mocked(RemoteWorkspace).mockClear();+ vi.mocked(FileClient).mockClear();+ executeCommandMock.mockReset();+ downloadFileMock.mockReset();+ vi.mocked(callCloudProxy).mockReset();+});++afterEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+});++// βββ executeCommand ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++describe("AgentServerRuntimeService.executeCommand", () => {+ describe("local backend", () => {+ it("creates RemoteWorkspace with resolved options and delegates", async () => {+ executeCommandMock.mockResolvedValue({+ exit_code: 0,+ stdout: "main\n",+ stderr: "",+ });++ const result = await AgentServerRuntimeService.executeCommand(+ "http://local-agent.example.com/api/conversations/conv-1",+ SESSION_KEY,+ "git rev-parse --abbrev-ref HEAD",+ "/workspace/project",+ 10,+ );++ expect(RemoteWorkspace).toHaveBeenCalledTimes(1);+ expect(executeCommandMock).toHaveBeenCalledWith(+ "git rev-parse --abbrev-ref HEAD",+ "/workspace/project",+ 10,+ );+ expect(result).toEqual({ exit_code: 0, stdout: "main\n", stderr: "" });+ });++ it("does not call callCloudProxy for local backends", async () => {+ executeCommandMock.mockResolvedValue({+ exit_code: 0,+ stdout: "",+ stderr: "",+ });++ await AgentServerRuntimeService.executeCommand(null, null, "ls", "/", 5);++ expect(callCloudProxy).not.toHaveBeenCalled();+ });+ });++ describe("cloud backend", () => {+ beforeEach(activateCloud);++ it("routes through callCloudProxy with correct path, body, and auth", async () => {+ vi.mocked(callCloudProxy).mockResolvedValue({+ exit_code: 0,+ stdout: "src/index.ts\n",+ stderr: "",+ });++ const result = await AgentServerRuntimeService.executeCommand(+ CLOUD_CONVERSATION_URL,+ SESSION_KEY,+ "find . -type f",+ "/workspace/project",+ 30,+ );++ const proxyCall = vi.mocked(callCloudProxy).mock.calls[0][0];+ expect(proxyCall.method).toBe("POST");+ expect(proxyCall.path).toBe("/api/bash/execute_bash_command");+ // hostOverride resolves to http:// because JSDOM's window.location.protocol is http:+ expect(proxyCall.hostOverride).toBe("http://runtime.example.com");+ expect(proxyCall.body).toEqual({+ command: "find . -type f",+ cwd: "/workspace/project",+ timeout: 30,+ });+ expect(proxyCall.authMode).toBe("session-api-key");+ expect(proxyCall.sessionApiKey).toBe(SESSION_KEY);+ expect(proxyCall.timeoutSeconds).toBe(40);+ expect(result).toEqual({+ exit_code: 0,+ stdout: "src/index.ts\n",+ stderr: "",+ });+ });++ it("omits cwd from proxy body when not provided", async () => {+ vi.mocked(callCloudProxy).mockResolvedValue({ exit_code: 0 });++ await AgentServerRuntimeService.executeCommand(+ CLOUD_CONVERSATION_URL,+ SESSION_KEY,+ "echo hi",+ undefined,+ 10,+ );++ const proxyBody = vi.mocked(callCloudProxy).mock.calls[0][0].body as Record<string, unknown>;+ expect(proxyBody).not.toHaveProperty("cwd");+ expect(proxyBody.command).toBe("echo hi");+ });++ it("normalises missing stdout/stderr fields to empty strings", async () => {+ vi.mocked(callCloudProxy).mockResolvedValue({ exit_code: 1 });++ const result = await AgentServerRuntimeService.executeCommand(+ CLOUD_CONVERSATION_URL,+ SESSION_KEY,+ "false",+ undefined,+ 5,+ );++ expect(result).toEqual({ exit_code: 1, stdout: "", stderr: "" });+ });++ it("does not create a RemoteWorkspace for cloud calls", async () => {+ vi.mocked(callCloudProxy).mockResolvedValue({ exit_code: 0 });++ await AgentServerRuntimeService.executeCommand(+ CLOUD_CONVERSATION_URL,+ SESSION_KEY,+ "echo ok",+ );++ expect(RemoteWorkspace).not.toHaveBeenCalled();+ });++ it("falls back to local path when conversationUrl is null", async () => {+ executeCommandMock.mockResolvedValue({+ exit_code: 0,+ stdout: "",+ stderr: "",+ });++ await AgentServerRuntimeService.executeCommand(+ null,+ SESSION_KEY,+ "echo ok",+ );++ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(RemoteWorkspace).toHaveBeenCalledTimes(1);+ });+ });+});++// βββ downloadFile βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++describe("AgentServerRuntimeService.downloadFile", () => {+ describe("local backend", () => {+ it("creates FileClient with resolved options and returns the ArrayBuffer", async () => {+ const fileBytes = new TextEncoder().encode("# README");+ downloadFileMock.mockResolvedValue(fileBytes.buffer);++ const result = await AgentServerRuntimeService.downloadFile(+ "http://local-agent.example.com/api/conversations/conv-1",+ SESSION_KEY,+ "/workspace/project/README.md",+ );++ expect(FileClient).toHaveBeenCalledTimes(1);+ expect(downloadFileMock).toHaveBeenCalledWith(+ "/workspace/project/README.md",+ );+ expect(result).toBe(fileBytes.buffer);+ });++ it("does not call callCloudProxy for local backends", async () => {+ downloadFileMock.mockResolvedValue(new ArrayBuffer(0));++ await AgentServerRuntimeService.downloadFile(+ null,+ null,+ "/workspace/file.txt",+ );++ expect(callCloudProxy).not.toHaveBeenCalled();+ });+ });++ describe("cloud backend", () => {+ beforeEach(activateCloud);++ it("routes through callCloudProxy with GET and URL-encoded path", async () => {+ const blob = new Blob([new TextEncoder().encode("file content")]);+ vi.mocked(callCloudProxy).mockResolvedValue(blob);++ const result = await AgentServerRuntimeService.downloadFile(+ CLOUD_CONVERSATION_URL,+ SESSION_KEY,+ "/workspace/project/src/main.ts",+ );++ const proxyCall = vi.mocked(callCloudProxy).mock.calls[0][0];+ expect(proxyCall.method).toBe("GET");+ expect(proxyCall.path).toBe(+ "/api/file/download?path=%2Fworkspace%2Fproject%2Fsrc%2Fmain.ts",+ );+ expect(proxyCall.hostOverride).toBe("http://runtime.example.com");+ expect(proxyCall.authMode).toBe("session-api-key");+ expect(proxyCall.sessionApiKey).toBe(SESSION_KEY);+ expect(proxyCall.responseType).toBe("blob");++ // Blob.arrayBuffer() round-trip: decoded text should match the original.+ expect(new TextDecoder().decode(result)).toBe("file content");+ });++ it("does not create a FileClient for cloud calls", async () => {+ vi.mocked(callCloudProxy).mockResolvedValue(new Blob());++ await AgentServerRuntimeService.downloadFile(+ CLOUD_CONVERSATION_URL,+ SESSION_KEY,+ "/workspace/file.txt",+ );++ expect(FileClient).not.toHaveBeenCalled();+ });++ it("falls back to local path when conversationUrl is null", async () => {+ downloadFileMock.mockResolvedValue(new ArrayBuffer(0));++ await AgentServerRuntimeService.downloadFile(+ null,+ SESSION_KEY,+ "/workspace/file.txt",+ );++ expect(callCloudProxy).not.toHaveBeenCalled();+ expect(FileClient).toHaveBeenCalledTimes(1);+ });+ });+});diff --git a/__tests__/hooks/query/use-workspace-file-content.test.tsx b/__tests__/hooks/query/use-workspace-file-content.test.tsxindex a731403a85..12786f8cbb 100644--- a/__tests__/hooks/query/use-workspace-file-content.test.tsx+++ b/__tests__/hooks/query/use-workspace-file-content.test.tsx@@ -1,8 +1,15 @@import React from "react";import { act, renderHook, waitFor } from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { beforeEach, describe, expect, it, vi } from "vitest";-+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import {+ __resetActiveStoreForTests,+ setActiveSelection,+ setRegisteredBackends,+} from "#/api/backend-registry/active-store";+import { callCloudProxy } from "#/api/cloud/proxy";+import type { Backend } from "#/api/backend-registry/types";import { useWorkspaceFileContent } from "#/hooks/query/use-workspace-file-content";import { useWorkspaceMutationCounter } from "#/stores/use-workspace-mutation-counter";@@ -28,6 +35,18 @@ vi.mock("#/api/agent-server-client-options", () => ({})),}));+vi.mock("#/api/cloud/proxy", () => ({+ callCloudProxy: vi.fn(),+}));++const cloudBackend: Backend = {+ id: "cloud-1",+ name: "Production",+ host: "https://app.all-hands.dev",+ apiKey: "cloud-api-key",+ kind: "cloud",+};+const useActiveConversationMock = vi.fn();vi.mock("#/hooks/query/use-active-conversation", () => ({useActiveConversation: () => useActiveConversationMock(),@@ -60,9 +79,12 @@ describe("useWorkspaceFileContent", () => {configurable: true,value: vi.fn(() => "blob:preview-url"),});+ window.localStorage.clear();+ __resetActiveStoreForTests();useWorkspaceMutationCounter.setState({ count: 0 });fileClientMock.mockClear();downloadFileMock.mockReset();+ vi.mocked(callCloudProxy).mockReset();useActiveConversationMock.mockReset();useRuntimeIsReadyMock.mockReset();useRuntimeIsReadyMock.mockReturnValue(true);@@ -76,6 +98,11 @@ describe("useWorkspaceFileContent", () => {});});+ afterEach(() => {+ window.localStorage.clear();+ __resetActiveStoreForTests();+ });+it("downloads selected files through the typed file API", async () => {downloadFileMock.mockResolvedValue(new TextEncoder().encode("# Hello").buffer,@@ -144,4 +171,49 @@ describe("useWorkspaceFileContent", () => {}),);});++ describe("cloud backend", () => {+ beforeEach(() => {+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id, orgId: null });+ useActiveConversationMock.mockReturnValue({+ data: {+ id: "conv-cloud",+ conversation_url:+ "https://runtime.example.com/api/conversations/conv-cloud",+ session_api_key: "cloud-session-key",+ workspace: { working_dir: "/workspace/project" },+ },+ });+ });++ it("fetches file content through callCloudProxy instead of FileClient", async () => {+ vi.mocked(callCloudProxy).mockResolvedValue(+ new Blob([new TextEncoder().encode("cloud file content")]),+ );++ const { result } = renderHook(+ () => useWorkspaceFileContent("src/app.ts"),+ { wrapper: makeWrapper() },+ );++ await waitFor(() => expect(result.current.isSuccess).toBe(true));++ // FileClient must never be called directly for cloud conversations.+ expect(fileClientMock).not.toHaveBeenCalled();+ expect(downloadFileMock).not.toHaveBeenCalled();++ const proxyCall = vi.mocked(callCloudProxy).mock.calls[0][0];+ expect(proxyCall.method).toBe("GET");+ expect(proxyCall.path).toContain("/api/file/download");+ expect(proxyCall.path).toContain(+ encodeURIComponent("/workspace/project/src/app.ts"),+ );+ expect(proxyCall.authMode).toBe("session-api-key");+ expect(proxyCall.sessionApiKey).toBe("cloud-session-key");+ expect(proxyCall.responseType).toBe("blob");++ expect(result.current.data?.text).toBe("cloud file content");+ });+ });});diff --git a/src/api/runtime-service/agent-server-runtime-service.ts b/src/api/runtime-service/agent-server-runtime-service.tsnew file mode 100644index 0000000000..83d45845c5--- /dev/null+++ b/src/api/runtime-service/agent-server-runtime-service.ts@@ -0,0 +1,96 @@+import { FileClient } from "@openhands/typescript-client/clients";+import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";+import { getAgentServerClientOptions } from "#/api/agent-server-client-options";+import { getActiveBackend } from "#/api/backend-registry/active-store";+import { callCloudProxy } from "#/api/cloud/proxy";+import { buildHttpBaseUrl } from "#/utils/websocket-url";++export interface CommandResult {+ exit_code: number;+ stdout: string;+ stderr: string;+}++/**+ * Cloud-aware runtime operations for agent-server conversations.+ *+ * In **local** mode the runtime is reachable directly from the browser+ * (e.g. `127.0.0.1:18000`) so the SDK's typed clients work fine.+ * In **cloud** mode the runtime lives at `*.prod-runtime.all-hands.dev`,+ * which doesn't allow CORS from `localhost`, so all calls go through+ * `callCloudProxy` with the runtime URL as `hostOverride` and the+ * conversation's `session_api_key` as auth β server-side hop, no CORS.+ */+class AgentServerRuntimeService {+ static async executeCommand(+ conversationUrl: string | null | undefined,+ sessionApiKey: string | null | undefined,+ command: string,+ cwd?: string,+ timeout = 30,+ ): Promise<CommandResult> {+ const active = getActiveBackend().backend;++ if (active.kind === "cloud" && conversationUrl) {+ const output = await callCloudProxy<{+ exit_code?: number;+ stdout?: string;+ stderr?: string;+ }>({+ backend: active,+ method: "POST",+ hostOverride: buildHttpBaseUrl(conversationUrl),+ path: "/api/bash/execute_bash_command",+ body: {+ command,+ ...(cwd ? { cwd } : {}),+ timeout: Math.floor(timeout),+ },+ authMode: "session-api-key",+ sessionApiKey,+ timeoutSeconds: timeout + 10,+ });+ return {+ exit_code: output.exit_code ?? -1,+ stdout: output.stdout ?? "",+ stderr: output.stderr ?? "",+ };+ }++ const result = await new RemoteWorkspace(+ getAgentServerClientOptions({ conversationUrl, sessionApiKey }),+ ).executeCommand(command, cwd, timeout);+ return {+ exit_code: result.exit_code,+ stdout: result.stdout,+ stderr: result.stderr,+ };+ }++ static async downloadFile(+ conversationUrl: string | null | undefined,+ sessionApiKey: string | null | undefined,+ path: string,+ ): Promise<ArrayBuffer> {+ const active = getActiveBackend().backend;++ if (active.kind === "cloud" && conversationUrl) {+ const blob = await callCloudProxy<Blob>({+ backend: active,+ method: "GET",+ hostOverride: buildHttpBaseUrl(conversationUrl),+ path: `/api/file/download?path=${encodeURIComponent(path)}`,+ authMode: "session-api-key",+ sessionApiKey,+ responseType: "blob",+ });+ return blob.arrayBuffer();+ }++ return new FileClient(+ getAgentServerClientOptions({ conversationUrl, sessionApiKey }),+ ).downloadFile(path);+ }+}++export default AgentServerRuntimeService;diff --git a/src/hooks/query/use-has-git-commits.ts b/src/hooks/query/use-has-git-commits.tsindex 575f8b464a..6a42e2a044 100644--- a/src/hooks/query/use-has-git-commits.ts+++ b/src/hooks/query/use-has-git-commits.ts@@ -1,7 +1,6 @@-import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";import { useQuery } from "@tanstack/react-query";-import { getAgentServerClientOptions } from "#/api/agent-server-client-options";+import AgentServerRuntimeService from "#/api/runtime-service/agent-server-runtime-service";import { useActiveConversation } from "#/hooks/query/use-active-conversation";import { useRuntimeIsReady } from "#/hooks/use-runtime-is-ready";@@ -45,13 +44,6 @@ export function useHasGitCommits(options?: { enabled?: boolean }): {workingDir,],queryFn: async () => {- const workspace = new RemoteWorkspace(- getAgentServerClientOptions({- conversationUrl,- sessionApiKey,- }),- );-// `git rev-parse --verify HEAD` exits 0 iff HEAD resolves to a// real commit. Returns non-zero in three cases that all collapse// to "no diff base, show files view":@@ -61,7 +53,9 @@ export function useHasGitCommits(options?: { enabled?: boolean }): {// Callers gate this hook on the user having attached a source// (see `useHasAttachedSource`) so we don't shell out for the// unattached-conversation case where the answer is moot.- const result = await workspace.executeCommand(+ const result = await AgentServerRuntimeService.executeCommand(+ conversationUrl,+ sessionApiKey,"git rev-parse --verify HEAD",workingDir,10,diff --git a/src/hooks/query/use-local-git-info.ts b/src/hooks/query/use-local-git-info.tsindex 2aa105cdb2..01d02863af 100644--- a/src/hooks/query/use-local-git-info.ts+++ b/src/hooks/query/use-local-git-info.ts@@ -1,7 +1,8 @@import { useQuery } from "@tanstack/react-query";-import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";-import { getAgentServerClientOptions } from "#/api/agent-server-client-options";+import AgentServerRuntimeService, {+ CommandResult,+} from "#/api/runtime-service/agent-server-runtime-service";import { getAgentServerWorkingDir } from "#/api/agent-server-config";import { useActiveConversation } from "#/hooks/query/use-active-conversation";import { useRuntimeIsReady } from "#/hooks/use-runtime-is-ready";@@ -22,13 +23,19 @@ const EMPTY_LOCAL_GIT_INFO: LocalGitInfo = {remoteUrl: null,};+type RunCommand = (+ command: string,+ cwd: string,+ timeout: number,+) => Promise<CommandResult>;+async function probeGitInfoAtDir(- workspace: RemoteWorkspace,+ run: RunCommand,directory: string,): Promise<LocalGitInfo> {const [remoteResult, branchResult] = await Promise.all([- workspace.executeCommand("git remote get-url origin", directory, 10),- workspace.executeCommand("git rev-parse --abbrev-ref HEAD", directory, 10),+ run("git remote get-url origin", directory, 10),+ run("git rev-parse --abbrev-ref HEAD", directory, 10),]);const remoteUrl =@@ -49,10 +56,10 @@ async function probeGitInfoAtDir(}async function probeNestedRepoInDir(- workspace: RemoteWorkspace,+ run: RunCommand,directory: string,): Promise<LocalGitInfo> {- const nestedReposResult = await workspace.executeCommand(+ const nestedReposResult = await run("find . -mindepth 2 -maxdepth 4 -name .git 2>/dev/null | sed 's#^\\./##' | sed 's#/.git$##'",directory,10,@@ -72,7 +79,7 @@ async function probeNestedRepoInDir(if (nestedRepos.length !== 1) return EMPTY_LOCAL_GIT_INFO;const nestedDir = `${directory}/${nestedRepos[0]}`.replace(/\/+/g, "/");- return probeGitInfoAtDir(workspace, nestedDir);+ return probeGitInfoAtDir(run, nestedDir);}/**@@ -109,23 +116,25 @@ export const useLocalGitInfo = () => {workingDir,],queryFn: async () => {- const workspace = new RemoteWorkspace(- getAgentServerClientOptions({+ const run: RunCommand = (command, cwd, timeout) =>+ AgentServerRuntimeService.executeCommand(conversationUrl,sessionApiKey,- }),- );+ command,+ cwd,+ timeout,+ );const candidateDirs = Array.from(new Set([workingDir, "/workspace/project", "workspace/project"]),);for (const candidateDir of candidateDirs) {- const directInfo = await probeGitInfoAtDir(workspace, candidateDir);+ const directInfo = await probeGitInfoAtDir(run, candidateDir);if (directInfo.repository || directInfo.branch) return directInfo;// Common local flow: user starts in a non-git parent workspace and// clones a single repository into a child directory.- const nestedInfo = await probeNestedRepoInDir(workspace, candidateDir);+ const nestedInfo = await probeNestedRepoInDir(run, candidateDir);if (nestedInfo.repository || nestedInfo.branch) return nestedInfo;}diff --git a/src/hooks/query/use-workspace-file-content.ts b/src/hooks/query/use-workspace-file-content.tsindex 32018e7ef6..f1ef457d30 100644--- a/src/hooks/query/use-workspace-file-content.ts+++ b/src/hooks/query/use-workspace-file-content.ts@@ -1,7 +1,6 @@import { useQuery } from "@tanstack/react-query";-import { FileClient } from "@openhands/typescript-client/clients";-import { getAgentServerClientOptions } from "#/api/agent-server-client-options";+import AgentServerRuntimeService from "#/api/runtime-service/agent-server-runtime-service";import { useActiveConversation } from "#/hooks/query/use-active-conversation";import { useRuntimeIsReady } from "#/hooks/use-runtime-is-ready";import { useWorkspaceMutationCounter } from "#/stores/use-workspace-mutation-counter";@@ -167,10 +166,11 @@ export function useWorkspaceFileContent(relativePath: string | null) {const kind = classifyKind(relativePath);const mimeType = guessMimeType(relativePath);const filePath = resolveWorkspacePath(workingDir, relativePath);- const fileClient = new FileClient(- getAgentServerClientOptions({ conversationUrl, sessionApiKey }),+ const buffer = await AgentServerRuntimeService.downloadFile(+ conversationUrl,+ sessionApiKey,+ filePath,);- const buffer = await fileClient.downloadFile(filePath);if (kind !== "text") {return {diff --git a/src/hooks/query/use-workspace-files.ts b/src/hooks/query/use-workspace-files.tsindex d4b1759001..92dc200ac0 100644--- a/src/hooks/query/use-workspace-files.ts+++ b/src/hooks/query/use-workspace-files.ts@@ -1,7 +1,6 @@-import { RemoteWorkspace } from "@openhands/typescript-client/workspace/remote-workspace";import { useQuery } from "@tanstack/react-query";-import { getAgentServerClientOptions } from "#/api/agent-server-client-options";+import AgentServerRuntimeService from "#/api/runtime-service/agent-server-runtime-service";import { useActiveConversation } from "#/hooks/query/use-active-conversation";import { useRuntimeIsReady } from "#/hooks/use-runtime-is-ready";@@ -62,14 +61,9 @@ export function useWorkspaceFiles() {workingDir,],queryFn: async () => {- const workspace = new RemoteWorkspace(- getAgentServerClientOptions({- conversationUrl,- sessionApiKey,- }),- );-- const result = await workspace.executeCommand(+ const result = await AgentServerRuntimeService.executeCommand(+ conversationUrl,+ sessionApiKey,buildListCommand(),workingDir,30,