feat: keep managed SSH prompts running on Hosts

Managed SSH prompts previously depended on Desktop-owned provider and transcript state, so accepted work could stop or become uncertain when the Desktop, network, or power disappeared. The Agent now owns accepted OpenCode prompt execution, model and tool rounds, cancellation, and the durable semantic transcript, while Desktop remains authoritative for permanent projects, conversations, tasks, and messages.

Recovered work attaches to the original conversation without replay. The project switcher also groups managed SSH projects by saved Host and shows live Agent connectivity beside each group without opening a connection merely to read status. Remote project subtitles now show only the path, and the Agent lock advances to 0.11.14 with Runtime ACP v4.

Release note: 托管 SSH 任务在桌面端、网络或电源中断后可继续在主机上运行,并能回到原会话精确恢复;项目菜单现按主机分组并显示实时连接状态。
This commit is contained in:
mesalogo
2026-08-31 11:04:41 +08:00
parent f6f8d5e053
commit 561de29f00
75 changed files with 13439 additions and 1327 deletions
+1 -102
View File
@@ -1,102 +1 @@
export type BoundedResponseTextOptions = {
maxBytes: number
missingBodyMessage?: string
tooLargeMessage: string
truncatedMessage?: string
}
export class BoundedResponseTooLargeError extends Error {
constructor(message: string) {
super(message)
this.name = 'BoundedResponseTooLargeError'
}
}
export class BoundedResponseTruncatedError extends Error {
constructor(message: string) {
super(message)
this.name = 'BoundedResponseTruncatedError'
}
}
export async function readBoundedResponseBytes(
response: Response,
options: BoundedResponseTextOptions
): Promise<Uint8Array> {
const declaredLength = response.headers.get('content-length')
let parsedLength: number | undefined
if (declaredLength !== null) {
parsedLength = Number(declaredLength)
if (
!Number.isSafeInteger(parsedLength) ||
parsedLength < 0 ||
parsedLength > options.maxBytes
) {
await response.body?.cancel().catch(() => undefined)
throw new BoundedResponseTooLargeError(
options.tooLargeMessage
)
}
}
if (!response.body) {
if (options.missingBodyMessage) {
throw new Error(options.missingBodyMessage)
}
if (
options.truncatedMessage !== undefined &&
parsedLength !== undefined &&
parsedLength !== 0
) {
throw new BoundedResponseTruncatedError(
options.truncatedMessage
)
}
return new Uint8Array()
}
const reader = response.body.getReader()
const chunks: Uint8Array[] = []
let completed = false
let total = 0
try {
while (true) {
const { done, value } = await reader.read()
if (done) {
completed = true
break
}
total += value.byteLength
if (total > options.maxBytes) {
throw new BoundedResponseTooLargeError(
options.tooLargeMessage
)
}
chunks.push(value)
}
} finally {
if (!completed) {
await reader.cancel().catch(() => undefined)
}
reader.releaseLock()
}
if (
options.truncatedMessage !== undefined &&
parsedLength !== undefined &&
response.headers.get('content-encoding') === null &&
total !== parsedLength
) {
throw new BoundedResponseTruncatedError(
options.truncatedMessage
)
}
return Buffer.concat(chunks, total)
}
export async function readBoundedResponseText(
response: Response,
options: BoundedResponseTextOptions
): Promise<string> {
return Buffer.from(
await readBoundedResponseBytes(response, options)
).toString('utf8')
}
export * from '../../shared/node/bounded-response'