diff --git a/src/main/broker.ts b/src/main/broker.ts index 1444a8c4..99690f91 100644 --- a/src/main/broker.ts +++ b/src/main/broker.ts @@ -17,7 +17,6 @@ import { type PendingRelayMessage } from '@agent-relay/harness-driver' import { AgentRelay, RelayPlacementError, type RelayMessage } from '@agent-relay/sdk' -import { getAccessToken, getApiUrl } from './auth' import { assertDirectory } from './path-utils' import { toErrorMessage } from './errors' import { isRecord } from './guards' @@ -2008,8 +2007,7 @@ export class BrokerManager { /** * Attach to an already-provisioned cloud sandbox (used by CloudAgentManager - * which warms the box via the cloud-agents/{id}/box endpoint). connectCloud - * is the legacy ad-hoc path that creates a sandbox here. + * which warms the box via the cloud-agents/{id}/box endpoint). */ async attachCloudSandbox( projectId: string, @@ -2149,62 +2147,6 @@ export class BrokerManager { } } - /** - * Connect to a broker running in a remote Daytona sandbox. - * Creates an ad-hoc sandbox via the cloud API, then attaches through the - * same SDK path used by CloudAgentManager-provisioned sandboxes. - */ - async connectCloud(projectId: string, win: BrowserWindow): Promise { - const normalizedProjectId = projectId.trim() - if (!normalizedProjectId) { - throw new Error('Project id is required') - } - - // Provisioning errors (sandbox create / terminal fetch) are handled here; - // attachCloudSandbox handles its own error reporting (console.error + - // broker:status). Splitting the try/catch keeps the two paths from - // double-logging the same failure to the renderer. - let sandboxId: string - let httpUrl: string - let apiKey: string - try { - const token = await getAccessToken() - if (!token) throw new Error('Not logged in — sign in first') - - const apiUrl = getApiUrl() - - // 1. Create sandbox with broker - console.log('[broker] Creating cloud sandbox...') - const createRes = await fetch(`${apiUrl}/api/v1/sandboxes`, { - method: 'POST', - headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }, - body: JSON.stringify({}) - }) - if (!createRes.ok) { - const err = await createRes.json().catch(() => ({ error: createRes.statusText })) - throw new Error(`Failed to create sandbox: ${(err as { error: string }).error}`) - } - ;({ sandboxId } = await createRes.json() as { sandboxId: string }) - console.log('[broker] Sandbox created:', sandboxId) - - // 2. Get terminal connection info - const termRes = await fetch(`${apiUrl}/api/v1/sandboxes/${sandboxId}/terminal`, { - headers: { Authorization: `Bearer ${token}` } - }) - if (!termRes.ok) { - throw new Error('Failed to get terminal connection info') - } - ;({ httpUrl, apiKey } = await termRes.json() as { httpUrl: string; apiKey: string }) - } catch (err) { - console.error(`[broker] Failed to connect cloud broker for project ${normalizedProjectId}:`, err) - this.sendStatusToWindow(win, normalizedProjectId, 'error', String(err)) - throw err - } - - // attachCloudSandbox owns its own error reporting; let its errors propagate. - return this.attachCloudSandbox(normalizedProjectId, { sandboxId, execUrl: httpUrl, apiKey }, win) - } - // Local session first, then the cloud session — local stays the default // target for project-scoped operations when both brokers are running. private sessionsForProject(projectId: string): BrokerSession[] { diff --git a/src/main/ipc-handlers.test.ts b/src/main/ipc-handlers.test.ts index c46a4c2f..5ad05169 100644 --- a/src/main/ipc-handlers.test.ts +++ b/src/main/ipc-handlers.test.ts @@ -34,7 +34,6 @@ const mock = vi.hoisted(() => { shutdown: vi.fn(async () => undefined), syncChannels: vi.fn(async () => undefined), autoFixRuntime: vi.fn(), - connectCloud: vi.fn(), spawnAgent: vi.fn(), listPersonas: vi.fn(), spawnPersona: vi.fn(), diff --git a/src/main/ipc-handlers.ts b/src/main/ipc-handlers.ts index ef749b74..3f7452c7 100644 --- a/src/main/ipc-handlers.ts +++ b/src/main/ipc-handlers.ts @@ -829,12 +829,6 @@ export function registerIpcHandlers(): void { return brokerManager.attachTerminal(input.projectId, input) }) - ipcMain.handle('broker:connect-cloud', async (event) => { - const win = BrowserWindow.fromWebContents(event.sender) - if (!win) throw new Error('No window') - return brokerManager.connectCloud('cloud', win) - }) - ipcMain.handle('broker:send-input', async (_, projectId: string | undefined, name: string, data: string) => { return brokerManager.sendInput(projectId, name, data) }) diff --git a/src/preload/index.ts b/src/preload/index.ts index c8e22ce1..a07340ce 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -257,7 +257,6 @@ const api = { channels, errorMessage ), - connectCloud: () => invoke('broker:connect-cloud'), spawnAgent: (projectId: string, input: BrokerSpawnAgentInput) => invoke('broker:spawn-agent', projectId, input), placeAgent: (projectId: string, input: BrokerPlaceAgentInput) => diff --git a/src/renderer/src/lib/ipc-mock.ts b/src/renderer/src/lib/ipc-mock.ts index 7d0bda6f..650b8c84 100644 --- a/src/renderer/src/lib/ipc-mock.ts +++ b/src/renderer/src/lib/ipc-mock.ts @@ -913,7 +913,6 @@ export const pearMock: PearAPI = { id: `mock-observer-token-${projectId}` }), autoFixRuntime: async () => ({ removed: [] }), - connectCloud: async () => 'mock-cloud', spawnAgent: async (projectId: string, input: BrokerSpawnAgentInput): Promise => { const agent = upsertAgent({ ...input, projectId, runtime: 'mock', current_state: 'idle' }) handleInjectedBrokerEvent({ diff --git a/src/shared/types/ipc.ts b/src/shared/types/ipc.ts index 7fd3a2c0..aa3ba45d 100644 --- a/src/shared/types/ipc.ts +++ b/src/shared/types/ipc.ts @@ -1073,7 +1073,6 @@ export interface PearAPI { channels?: string[], errorMessage?: string ) => Promise<{ removed: string[] }> - connectCloud: () => Promise spawnAgent: (projectId: string, input: BrokerSpawnAgentInput) => Promise placeAgent: (projectId: string, input: BrokerPlaceAgentInput) => Promise listNodes: (projectId: string, capability?: string) => Promise