feat: add managed SSH execution spaces

Add managed SSH Hosts and projects with signed side-by-side GoodBuddy Agent and OpenCode Runtime installation, Ask and Execute workspace access, a Main-owned model bridge, detached Agent lifecycle, durable ACP output recovery, and project activation UI.

Use protocol v2 with bounded FIFO frames over SSH instead of custom credit, priority, batching, or model-message chunking. Mismatched Host Agents now upgrade automatically, an exactly verified Node runtime is reused on-host, and local Portable builds can embed strictly verified Agent artifacts.

Release note: 新增托管 SSH 远程项目,可自动安装或升级签名 Agent/OpenCode Runtime,并在 SSH 断线后继续 Agent 工作和同步未确认输出。
This commit is contained in:
mesalogo
2026-08-24 23:02:18 +08:00
parent 3829a871f5
commit 607bb33249
258 changed files with 99449 additions and 2427 deletions
+83
View File
@@ -24,6 +24,8 @@ import {
type RuntimeSettingsInput,
type RuntimeConfigActionInput,
type RuntimeFileSelectionKind,
type RemoteProjectSaveProgress,
type RemoteProjectSaveRequest,
type WindowCaptureOption
} from '../shared/contracts'
import { ipcChannels } from '../shared/ipc-channels'
@@ -102,6 +104,15 @@ import type {
import type { AgentRuntimeSelection } from '../shared/runtime-selection-contracts'
import type { WeixinBindingSnapshot } from '../shared/weixin-channel-contracts'
import type { RemoteChannelActivity } from '../shared/remote-channel-contracts'
import type {
SshHostDraftInspectionRequest,
SshDirectoryBrowseResult,
SshHostKeyInspection,
SshHostRemoteEnvironment,
SshHostsSnapshot,
SshHostValidationRequest,
SshHostValidationResult
} from '../shared/ssh-host-contracts'
import type {
MagicNoteAnalysisStreamEvent,
MagicNoteDraftAnalysis,
@@ -311,6 +322,48 @@ const desktopApi: DesktopApi = {
selection
) as Promise<AgentRuntimeStatus>
},
sshHosts: {
getSnapshot: () =>
ipcRenderer.invoke(
ipcChannels.sshHostsGet
) as Promise<SshHostsSnapshot>,
remove: async (hostId: string) => {
await ipcRenderer.invoke(ipcChannels.sshHostsRemove, {
hostId
})
},
inspectDraftHostKey: (input: SshHostDraftInspectionRequest) =>
ipcRenderer.invoke(
ipcChannels.sshHostsInspectDraftKey,
input
) as Promise<SshHostKeyInspection>,
discardCandidate: async (candidateId: string) => {
await ipcRenderer.invoke(
ipcChannels.sshHostsDiscardCandidate,
{ candidateId }
)
},
validateAndSave: (input: SshHostValidationRequest) =>
ipcRenderer.invoke(
ipcChannels.sshHostsValidateAndSave,
input
) as Promise<SshHostValidationResult>,
getRemoteEnvironment: (hostId: string) =>
ipcRenderer.invoke(
ipcChannels.sshHostsRemoteEnvironment,
{ hostId }
) as Promise<SshHostRemoteEnvironment>,
browseDirectories: (hostId: string, path?: string) =>
ipcRenderer.invoke(ipcChannels.sshHostsBrowseDirectories, {
hostId,
...(path === undefined ? {} : { path })
}) as Promise<SshDirectoryBrowseResult>,
cancelDirectoryBrowse: async () => {
await ipcRenderer.invoke(
ipcChannels.sshHostsCancelDirectoryBrowse
)
}
},
channels: {
getSnapshot: () =>
ipcRenderer.invoke(
@@ -643,6 +696,36 @@ const desktopApi: DesktopApi = {
projectId,
confirmation
})
},
remote: {
activate: (projectId: string) =>
ipcRenderer.invoke(
ipcChannels.remoteProjectActivate,
projectId
) as Promise<AssistantProject>,
save: (input: RemoteProjectSaveRequest) =>
ipcRenderer.invoke(
ipcChannels.remoteProjectSave,
input
) as Promise<AssistantProject>,
cancelCurrent: async () => {
await ipcRenderer.invoke(ipcChannels.remoteProjectCancelCurrent)
},
onSaveProgress: (listener) => {
const handler = (
_event: Electron.IpcRendererEvent,
progress: RemoteProjectSaveProgress
): void => listener(progress)
ipcRenderer.on(
ipcChannels.remoteProjectSaveProgress,
handler
)
return () =>
ipcRenderer.removeListener(
ipcChannels.remoteProjectSaveProgress,
handler
)
}
}
},
conversations: {
+51
View File
@@ -128,6 +128,57 @@ describe('sandboxed preload', () => {
expect(source).not.toContain('globalShortcut.')
})
it('exposes only explicit SSH host-management methods', () => {
const source = readFileSync(
join(process.cwd(), 'src', 'preload', 'index.ts'),
'utf8'
)
expect(source).toContain('sshHosts: {')
expect(source).toContain('getSnapshot:')
expect(source).toContain('inspectDraftHostKey:')
expect(source).toContain('discardCandidate:')
expect(source).toContain('validateAndSave:')
expect(source).toContain(
'browseDirectories: (hostId: string, path?: string)'
)
expect(source).toContain('cancelDirectoryBrowse: async ()')
expect(source).toContain('getRemoteEnvironment: (hostId: string)')
expect(source).toContain(
'ipcChannels.sshHostsRemoteEnvironment'
)
expect(source).toContain('ipcChannels.sshHostsBrowseDirectories')
expect(source).toContain(
'ipcChannels.sshHostsCancelDirectoryBrowse'
)
expect(source).not.toContain('sshHostsCreate')
expect(source).not.toContain('sshHostsAcceptKey')
expect(source).not.toContain('privateKey:')
expect(source).not.toContain('agentForward: true')
const sshHostsSource =
source.match(
/sshHosts: \{(?<body>[\s\S]*?)\n {2}\},\n {2}channels:/u
)
?.groups?.body ?? ''
expect(sshHostsSource).not.toMatch(
/\b(?:credential|password|revision|sftp|shell|command)\b/iu
)
})
it('exposes narrow awaited remote project activation and save operations', () => {
const source = readFileSync(
join(process.cwd(), 'src', 'preload', 'index.ts'),
'utf8'
)
expect(source).toContain('remote: {')
expect(source).toContain('remoteProjectActivate')
expect(source).toContain('remoteProjectSave')
expect(source).toContain('remoteProjectCancelCurrent')
expect(source).toContain('remoteProjectSaveProgress')
expect(source).toContain('RemoteProjectSaveRequest')
expect(source).not.toContain('commitToken')
expect(source).toContain('ipcRenderer.removeListener(')
})
it('exposes bounded knowledge task actions', () => {
const source = readFileSync(
join(process.cwd(), 'src', 'preload', 'index.ts'),