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:
@@ -6,7 +6,11 @@ import {
|
||||
conversationBranchInputSchema,
|
||||
conversationSnapshotSchema,
|
||||
isUntouchedBuiltInDefaultProject,
|
||||
persistedProjectExecutionSpaceSchema,
|
||||
projectCreateSchema,
|
||||
projectExecutionSpaceSchema,
|
||||
projectRuntimeValidationSchema,
|
||||
sshExecutionValidationSchema,
|
||||
projectUpdateSchema
|
||||
} from './assistant-contracts'
|
||||
|
||||
@@ -15,6 +19,10 @@ const untouchedProject: AssistantProject = {
|
||||
name: builtInDefaultProjectSeedName,
|
||||
description: builtInDefaultProjectSeedDescription,
|
||||
rootPath: 'C:\\Workspace',
|
||||
executionSpace: {
|
||||
kind: 'local',
|
||||
rootPath: 'C:\\Workspace'
|
||||
},
|
||||
defaultWorkMode: 'ask',
|
||||
kind: 'user',
|
||||
builtInDefault: true,
|
||||
@@ -75,6 +83,188 @@ describe('isUntouchedBuiltInDefaultProject', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('project execution space contracts', () => {
|
||||
it('parses strict local and SSH output without normalizing paths', () => {
|
||||
expect(
|
||||
projectExecutionSpaceSchema.parse({
|
||||
kind: 'local',
|
||||
rootPath: ''
|
||||
})
|
||||
).toEqual({ kind: 'local', rootPath: '' })
|
||||
expect(
|
||||
projectExecutionSpaceSchema.parse({
|
||||
kind: 'local',
|
||||
rootPath: ' '
|
||||
})
|
||||
).toEqual({ kind: 'local', rootPath: ' ' })
|
||||
expect(
|
||||
projectExecutionSpaceSchema.parse({
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: '/srv/goodbuddy'
|
||||
})
|
||||
).toEqual({
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: '/srv/goodbuddy'
|
||||
})
|
||||
|
||||
expect(
|
||||
projectExecutionSpaceSchema.safeParse({
|
||||
kind: 'local',
|
||||
rootPath: 'C:\\Workspace',
|
||||
hostId: '00000000-0000-4000-8000-000000000301'
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
projectExecutionSpaceSchema.safeParse({
|
||||
kind: 'ssh',
|
||||
hostId: 'not-a-host-id',
|
||||
remoteRootPath: '/srv/goodbuddy'
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
projectExecutionSpaceSchema.safeParse({
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: ' '
|
||||
}).success
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps SSH and Runtime validation identities separate and strict', () => {
|
||||
const validatedAt = '2026-08-21T00:00:00.000Z'
|
||||
const validation = {
|
||||
hostRevision: 2,
|
||||
hostKeyGeneration: 3,
|
||||
remoteUsername: 'builder',
|
||||
workspaceIdentity: 'workspace-identity',
|
||||
agentProtocolMajor: 1,
|
||||
agentInstallationIdAtValidation: 'agent-installation',
|
||||
agentBinaryDigestAtValidation: `sha256:${'a'.repeat(64)}`,
|
||||
agentVersionAtValidation: '0.11.0',
|
||||
agentArchitectureAtValidation: 'x64',
|
||||
validatedAt
|
||||
}
|
||||
const runtimeValidation = {
|
||||
runtimeSelectionKey: 'opencode:profile',
|
||||
runtimeBundleDigest: `sha256:${'b'.repeat(64)}`,
|
||||
runtimeAdapterDigest: `sha256:${'c'.repeat(64)}`,
|
||||
agentInstallationIdAtValidation: 'agent-installation',
|
||||
validatedAt,
|
||||
workMode: 'execute'
|
||||
}
|
||||
expect(
|
||||
sshExecutionValidationSchema.safeParse(validation).success
|
||||
).toBe(true)
|
||||
expect(
|
||||
projectRuntimeValidationSchema.safeParse(runtimeValidation)
|
||||
.success
|
||||
).toBe(true)
|
||||
expect(
|
||||
persistedProjectExecutionSpaceSchema.parse({
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: '/srv/goodbuddy',
|
||||
validation
|
||||
})
|
||||
).toEqual({
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: '/srv/goodbuddy',
|
||||
validation
|
||||
})
|
||||
expect(
|
||||
sshExecutionValidationSchema.safeParse({
|
||||
hostRevision: 2,
|
||||
hostKeyGeneration: 3,
|
||||
remoteUsername: 'builder',
|
||||
workspaceIdentity: 'workspace-identity',
|
||||
agentProtocolMajor: 1,
|
||||
agentInstallationIdAtValidation: 'agent-installation',
|
||||
agentBinaryDigestAtValidation: `sha256:${'a'.repeat(64)}`,
|
||||
agentVersionAtValidation: '0.11.0',
|
||||
agentArchitectureAtValidation: 'x64',
|
||||
validatedAt,
|
||||
runtimeBundleDigest: 'must-not-be-here'
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
persistedProjectExecutionSpaceSchema.safeParse({
|
||||
kind: 'local',
|
||||
rootPath: 'C:\\Workspace',
|
||||
validation
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
persistedProjectExecutionSpaceSchema.safeParse({
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: '/srv/goodbuddy',
|
||||
hostRevision: 2
|
||||
}).success
|
||||
).toBe(false)
|
||||
|
||||
for (const invalid of [
|
||||
{ ...validation, hostRevision: 0 },
|
||||
{ ...validation, trustAttestationRevision: 4 },
|
||||
{
|
||||
...validation,
|
||||
agentBinaryDigestAtValidation: `sha256:${'A'.repeat(64)}`
|
||||
},
|
||||
{ ...validation, agentVersionAtValidation: ' version ' },
|
||||
{ ...validation, agentArchitectureAtValidation: 'ia32' }
|
||||
]) {
|
||||
expect(
|
||||
sshExecutionValidationSchema.safeParse(invalid).success
|
||||
).toBe(false)
|
||||
}
|
||||
|
||||
for (const invalid of [
|
||||
{
|
||||
...runtimeValidation,
|
||||
runtimeBundleDigest: 'runtime-digest'
|
||||
},
|
||||
{ ...runtimeValidation, trustTier: 'T3' },
|
||||
{
|
||||
...runtimeValidation,
|
||||
confinementPolicyDigest: `sha256:${'d'.repeat(64)}`
|
||||
},
|
||||
{ ...runtimeValidation, approvalBridgeVersion: '1' },
|
||||
{
|
||||
...runtimeValidation,
|
||||
workMode: 'plan'
|
||||
}
|
||||
]) {
|
||||
expect(
|
||||
projectRuntimeValidationSchema.safeParse(invalid).success
|
||||
).toBe(false)
|
||||
}
|
||||
expect(
|
||||
projectRuntimeValidationSchema.safeParse({
|
||||
...runtimeValidation,
|
||||
workMode: 'ask'
|
||||
}).success
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps renderer project create and update inputs local-only', () => {
|
||||
const input = {
|
||||
name: '远程草稿',
|
||||
description: '',
|
||||
rootPath: '/srv/goodbuddy',
|
||||
defaultWorkMode: 'ask',
|
||||
executionSpace: {
|
||||
kind: 'ssh',
|
||||
hostId: '00000000-0000-4000-8000-000000000301',
|
||||
remoteRootPath: '/srv/goodbuddy'
|
||||
}
|
||||
}
|
||||
expect(projectCreateSchema.safeParse(input).success).toBe(false)
|
||||
expect(projectUpdateSchema.safeParse(input).success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('conversation branch contracts', () => {
|
||||
it('accepts bounded branch provenance and rejects renderer extras', () => {
|
||||
const sourceConversationId =
|
||||
|
||||
Reference in New Issue
Block a user