fix(delegate-task): Wave 1 - fix polling timeout, resource cleanup, tool restrictions, idle dedup, auth-plugins JSONC, CLI runner hang

- fix(delegate-task): return error on poll timeout instead of silent null
- fix(delegate-task): ensure toast and session cleanup on all error paths with try/finally
- fix(delegate-task): apply agent tool restrictions in sync-prompt-sender
- fix(plugin): add symmetric idle dedup to prevent double hook triggers
- fix(cli): replace regex-based JSONC editing with jsonc-parser in auth-plugins
- fix(cli): abort event stream after completion and restore no-timeout default

All changes verified with tests and typecheck.
This commit is contained in:
YeonGyu-Kim
2026-02-10 19:09:22 +09:00
parent 7fe1a653c8
commit df0b9f7664
17 changed files with 1397 additions and 163 deletions
+19 -14
View File
@@ -1,10 +1,12 @@
import { readFileSync, writeFileSync } from "node:fs"
import { readFileSync, writeFileSync, copyFileSync } from "node:fs"
import { modify, applyEdits } from "jsonc-parser"
import type { ConfigMergeResult, InstallConfig } from "../types"
import { getConfigDir } from "./config-context"
import { ensureConfigDirectoryExists } from "./ensure-config-directory-exists"
import { formatErrorWithSuggestion } from "./format-error-with-suggestion"
import { detectConfigFormat } from "./opencode-config-format"
import { parseOpenCodeConfigFileWithError, type OpenCodeConfig } from "./parse-opencode-config-file"
import { parseJsonc } from "../../shared/jsonc-parser"
export async function fetchLatestVersion(packageName: string): Promise<string | null> {
try {
@@ -59,21 +61,24 @@ export async function addAuthPlugins(config: InstallConfig): Promise<ConfigMerge
if (format === "jsonc") {
const content = readFileSync(path, "utf-8")
const pluginArrayRegex = /"plugin"\s*:\s*\[([\s\S]*?)\]/
const match = content.match(pluginArrayRegex)
if (match) {
const formattedPlugins = plugins.map((p) => `"${p}"`).join(",\n ")
const newContent = content.replace(
pluginArrayRegex,
`"plugin": [\n ${formattedPlugins}\n ]`
)
writeFileSync(path, newContent)
} else {
const inlinePlugins = plugins.map((p) => `"${p}"`).join(", ")
const newContent = content.replace(/(\{)/, `$1\n "plugin": [${inlinePlugins}],`)
writeFileSync(path, newContent)
copyFileSync(path, `${path}.bak`)
const newContent = applyEdits(
content,
modify(content, ["plugin"], plugins, {
formattingOptions: { tabSize: 2, insertSpaces: true },
})
)
try {
parseJsonc(newContent)
} catch (error) {
copyFileSync(`${path}.bak`, path)
throw new Error(`Generated JSONC is invalid: ${error instanceof Error ? error.message : String(error)}`)
}
writeFileSync(path, newContent)
} else {
writeFileSync(path, JSON.stringify(newConfig, null, 2) + "\n")
}