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:
@@ -0,0 +1,84 @@
|
||||
import {
|
||||
RemoteWorkspaceAccess,
|
||||
type RemoteWorkspaceAccessFactory,
|
||||
type RemoteWorkspaceProjectBinding
|
||||
} from '../workspace/remote-workspace-access'
|
||||
import type { AgentInstallationManager } from './agent-installation-manager'
|
||||
import type { RemoteAgentConnectionManager } from './remote-agent-connection-manager'
|
||||
import {
|
||||
ProtocolRemoteWorkspaceTransport,
|
||||
type RemoteWorkspaceInstallationIdentityResolver
|
||||
} from './protocol-remote-workspace-transport'
|
||||
|
||||
export type ManagedRemoteWorkspaceAccessFactoryOptions = {
|
||||
installationManager: Pick<
|
||||
AgentInstallationManager,
|
||||
'ensureInstalled'
|
||||
>
|
||||
connectionManager: Pick<RemoteAgentConnectionManager, 'acquire'>
|
||||
}
|
||||
|
||||
/**
|
||||
* Composes persisted project validation with fresh installation and
|
||||
* connection leases. The resulting WorkspaceAccess remains strictly
|
||||
* read-only and owns every acquired connection lease.
|
||||
*/
|
||||
export class ManagedRemoteWorkspaceAccessFactory
|
||||
implements RemoteWorkspaceAccessFactory
|
||||
{
|
||||
constructor(
|
||||
private readonly options: ManagedRemoteWorkspaceAccessFactoryOptions
|
||||
) {}
|
||||
|
||||
create(bindingInput: RemoteWorkspaceProjectBinding): RemoteWorkspaceAccess {
|
||||
const binding = { ...bindingInput }
|
||||
const resolver: RemoteWorkspaceInstallationIdentityResolver = {
|
||||
resolve: async (hostId, installationId, signal) => {
|
||||
if (
|
||||
hostId !== binding.hostId ||
|
||||
installationId !== binding.agentInstallationId
|
||||
) {
|
||||
throw new Error(
|
||||
'Remote workspace installation request does not match its project binding'
|
||||
)
|
||||
}
|
||||
|
||||
signal?.throwIfAborted()
|
||||
const installation =
|
||||
await this.options.installationManager.ensureInstalled(
|
||||
binding.hostId,
|
||||
{ signal }
|
||||
)
|
||||
signal?.throwIfAborted()
|
||||
assertInstallationMatches(binding, installation)
|
||||
return { installation }
|
||||
}
|
||||
}
|
||||
return new RemoteWorkspaceAccess(
|
||||
binding,
|
||||
new ProtocolRemoteWorkspaceTransport(
|
||||
this.options.connectionManager,
|
||||
resolver
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function assertInstallationMatches(
|
||||
binding: RemoteWorkspaceProjectBinding,
|
||||
installation: Awaited<
|
||||
ReturnType<AgentInstallationManager['ensureInstalled']>
|
||||
>
|
||||
): void {
|
||||
if (
|
||||
installation.installationId !== binding.agentInstallationId ||
|
||||
installation.binaryDigest !== binding.agentBinaryDigest ||
|
||||
installation.agentVersion !== binding.agentVersion ||
|
||||
installation.architecture !== binding.agentArchitecture ||
|
||||
installation.protocol.major !== binding.agentProtocolMajor
|
||||
) {
|
||||
throw new Error(
|
||||
'Installed Remote Agent does not match the persisted project binding'
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user