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 工作和同步未确认输出。
95 lines
2.4 KiB
TypeScript
95 lines
2.4 KiB
TypeScript
import { z } from 'zod'
|
|
import { assistantIdSchema, projectCreateSchema } from './assistant-contracts'
|
|
import {
|
|
REMOTE_WORKSPACE_LIMITS,
|
|
remoteAbsolutePathSchema
|
|
} from './remote-agent-contracts'
|
|
import { agentRuntimeSelectionSchema } from './runtime-selection-contracts'
|
|
import { sshHostIdSchema } from './ssh-host-contracts'
|
|
|
|
export const REMOTE_PROJECT_SAVE_LIMITS = {
|
|
maximumAbsolutePathBytes:
|
|
REMOTE_WORKSPACE_LIMITS.maximumAbsolutePathBytes
|
|
} as const
|
|
|
|
export const remoteProjectRootPathSchema = remoteAbsolutePathSchema
|
|
.refine(
|
|
(value) => !/[\p{Cc}\p{Cs}\u2028\u2029\ufffd]/u.test(value),
|
|
'Remote project root cannot contain control characters'
|
|
)
|
|
.refine(
|
|
(value) =>
|
|
!value.includes('//') &&
|
|
!value
|
|
.split('/')
|
|
.some((segment) => segment === '.' || segment === '..'),
|
|
'Remote project root cannot contain empty, dot, or parent segments'
|
|
)
|
|
|
|
const commonDraftFields = {
|
|
name: projectCreateSchema.shape.name,
|
|
description: projectCreateSchema.shape.description,
|
|
defaultWorkMode: projectCreateSchema.shape.defaultWorkMode,
|
|
runtimeSelection: agentRuntimeSelectionSchema,
|
|
hostId: sshHostIdSchema,
|
|
remoteRootPath: remoteProjectRootPathSchema
|
|
} as const
|
|
|
|
export const remoteProjectCreateDraftSchema =
|
|
z.object(commonDraftFields).strict()
|
|
|
|
export const remoteProjectUpdateDraftSchema = z
|
|
.object({
|
|
projectId: assistantIdSchema,
|
|
...commonDraftFields
|
|
})
|
|
.strict()
|
|
|
|
export const remoteProjectSaveRequestSchema = z.discriminatedUnion(
|
|
'intent',
|
|
[
|
|
z
|
|
.object({
|
|
intent: z.literal('create'),
|
|
draft: remoteProjectCreateDraftSchema
|
|
})
|
|
.strict(),
|
|
z
|
|
.object({
|
|
intent: z.literal('update'),
|
|
draft: remoteProjectUpdateDraftSchema
|
|
})
|
|
.strict()
|
|
]
|
|
)
|
|
|
|
export const remoteProjectSavePhaseSchema = z.enum([
|
|
'host',
|
|
'agent',
|
|
'workspace',
|
|
'runtime',
|
|
'saving'
|
|
])
|
|
|
|
export const remoteProjectSaveProgressSchema = z
|
|
.object({
|
|
phase: remoteProjectSavePhaseSchema
|
|
})
|
|
.strict()
|
|
|
|
export type RemoteProjectCreateDraft = z.infer<
|
|
typeof remoteProjectCreateDraftSchema
|
|
>
|
|
export type RemoteProjectUpdateDraft = z.infer<
|
|
typeof remoteProjectUpdateDraftSchema
|
|
>
|
|
export type RemoteProjectSaveRequest = z.infer<
|
|
typeof remoteProjectSaveRequestSchema
|
|
>
|
|
export type RemoteProjectSavePhase = z.infer<
|
|
typeof remoteProjectSavePhaseSchema
|
|
>
|
|
export type RemoteProjectSaveProgress = z.infer<
|
|
typeof remoteProjectSaveProgressSchema
|
|
>
|