|
|
@@ -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
|
|
|
}
|