fix: prevent runtime permission stalls and Agent reconnect failures

Execute could stall on workspace-external access or native child-session
permissions, while structured questions could be lost or answered incorrectly.
Route owned OpenCode descendant interactions, correct Continue question and
custom-answer handling, and resolve DSH Execute ACP permissions without a
second approval. Ask remains read-only and unrelated sessions stay isolated.

Restore the required DSH session projection service. Reuse offline OpenCode
configuration by plugin version, remove unused npm shims from remote payloads,
normalize dependency modes, and accept real compound descriptors up to 4 MiB.
Fix intermittent Agent attach rejection and closed-handshake waits.

Add focused and real-Runtime regressions, document interaction boundaries and
validation evidence, and include the existing application/tool navigation
design drafts. Those navigation changes are design-only, not implemented UI.

Validation: full suite 3597 passed, 0 failed, 61 skipped across 338 files;
typecheck, lint, release-note verification, whitespace and relative-link checks
passed. Current-source Linux x64 installation, Ask/Execute, native subagent
external writes, reconnect and stop/bootstrap passed with 10 completed real
model calls, 13 native endpoint tests and 20 consecutive handshakes.
System sleep/wake and release CI packaging remain unverified.

Release note: 修复 Execute 访问工作区外目录或运行原生子代理时卡在权限等待的问题,并恢复 OpenCode 与 Continue 结构化问答的正确转交。修复远程 Agent 安装与重连失败;Ask 仍保持只读,任意终端密码或业务确认不会自动代答。
This commit is contained in:
mesalogo
2026-09-08 11:34:45 +08:00
parent 9aed926cda
commit c8db340cc7
48 changed files with 1858 additions and 200 deletions
@@ -60,6 +60,7 @@ const MAXIMUM_ARCHIVE_BYTES = 512 * 1024 * 1024
const MAXIMUM_EXPANDED_BYTES = 1024 * 1024 * 1024
const MAXIMUM_FILE_BYTES = 384 * 1024 * 1024
const MAXIMUM_METADATA_BYTES = 1024 * 1024
const MAXIMUM_DESCRIPTOR_BYTES = 4 * 1024 * 1024
const MAXIMUM_ENTRIES = 50_002
const PRIVATE_DIRECTORY_MODE = 0o700
const SIGNATURE_DOMAIN = Buffer.from(
@@ -115,7 +116,7 @@ export async function verifyExtractedAgentPackage(options: {
await Promise.all([
readBoundedFile(
join(rootDirectory, DESCRIPTOR_NAME),
MAXIMUM_METADATA_BYTES
MAXIMUM_DESCRIPTOR_BYTES
),
readBoundedFile(
join(rootDirectory, SIGNATURE_NAME),
@@ -321,9 +322,11 @@ async function extractArchive(
}
seen.add(name)
const maximum =
name === DESCRIPTOR_NAME || name === SIGNATURE_NAME
? MAXIMUM_METADATA_BYTES
: MAXIMUM_FILE_BYTES
name === DESCRIPTOR_NAME
? MAXIMUM_DESCRIPTOR_BYTES
: name === SIGNATURE_NAME
? MAXIMUM_METADATA_BYTES
: MAXIMUM_FILE_BYTES
if (
file.originalSize !== undefined &&
(
@@ -37,6 +37,7 @@ const MAXIMUM_ARCHIVE_BYTES = 512 * 1024 * 1024
const MAXIMUM_EXPANDED_BYTES = 1024 * 1024 * 1024
const MAXIMUM_ENTRY_BYTES = 384 * 1024 * 1024
const MAXIMUM_METADATA_BYTES = 1024 * 1024
const MAXIMUM_DESCRIPTOR_BYTES = 4 * 1024 * 1024
const MAXIMUM_ENTRIES = 50_002
const MAXIMUM_CENTRAL_BYTES = 32 * 1024 * 1024
const ZIP_LOCAL = 0x04034b50
@@ -480,7 +481,9 @@ function streamEntry(
destination?: string
): { sha256: string; crc32: number; bytes?: Buffer } {
const wantedBytes =
destination === undefined && entry.size <= MAXIMUM_METADATA_BYTES
destination === undefined && entry.size <= (
entry.name === PACKAGE_DESCRIPTOR ? MAXIMUM_DESCRIPTOR_BYTES : MAXIMUM_METADATA_BYTES
)
? Buffer.allocUnsafe(entry.size)
: undefined
let output: number | undefined
@@ -549,7 +552,10 @@ function writeFileChunk(handle: number, bytes: Buffer, offset: number): number {
function readEntry(handle: number, entries: Map<string, ZipEntry>, name: string): Buffer {
const entry = entries.get(name)
if (entry === undefined || entry.size > MAXIMUM_METADATA_BYTES) {
const maximumBytes = name === PACKAGE_DESCRIPTOR
? MAXIMUM_DESCRIPTOR_BYTES
: MAXIMUM_METADATA_BYTES
if (entry === undefined || entry.size > maximumBytes) {
throw new Error(`Agent package metadata is missing or too large: ${name}`)
}
const actual = streamEntry(handle, entry)
@@ -1656,7 +1662,9 @@ function writePreparedFile(
): void {
if (
bytes.byteLength <= 0 ||
bytes.byteLength > MAXIMUM_METADATA_BYTES
bytes.byteLength > (
name === PACKAGE_DESCRIPTOR ? MAXIMUM_DESCRIPTOR_BYTES : MAXIMUM_METADATA_BYTES
)
) {
throw new Error(`Prepared package metadata is invalid: ${name}`)
}
@@ -2392,7 +2400,7 @@ export function commitPackage(options: InstallerOptions): PackageInstallerResult
)
const descriptorBytes = readBoundedRegularFile(
join(preparedRoot, PACKAGE_DESCRIPTOR),
MAXIMUM_METADATA_BYTES,
MAXIMUM_DESCRIPTOR_BYTES,
'Prepared Agent package descriptor',
'0600'
)