Просмотр исходного кода

core: improve error handling for built-in plugin installation failures

Aiden Cline 1 месяц назад
Родитель
Сommit
e47f383137
1 измененных файлов с 17 добавлено и 2 удалено
  1. 17 2
      packages/opencode/src/plugin/index.ts

+ 17 - 2
packages/opencode/src/plugin/index.ts

@@ -8,6 +8,8 @@ import { BunProc } from "../bun"
 import { Instance } from "../project/instance"
 import { Flag } from "../flag/flag"
 import { CodexAuthPlugin } from "./codex"
+import { Session } from "../session"
+import { NamedError } from "@opencode-ai/util/error"
 
 export namespace Plugin {
   const log = Log.create({ service: "plugin" })
@@ -54,8 +56,21 @@ export namespace Plugin {
         const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest"
         const builtin = BUILTIN.some((x) => x.startsWith(pkg + "@"))
         plugin = await BunProc.install(pkg, version).catch((err) => {
-          if (builtin) return ""
-          throw err
+          if (!builtin) throw err
+
+          const message = err instanceof Error ? err.message : String(err)
+          log.error("failed to install builtin plugin", {
+            pkg,
+            version,
+            error: message,
+          })
+          Bus.publish(Session.Event.Error, {
+            error: new NamedError.Unknown({
+              message: `Failed to install built-in plugin ${pkg}@${version}: ${message}`,
+            }).toObject(),
+          })
+
+          return ""
         })
         if (!plugin) continue
       }