mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-21 05:10:58 +08:00
fix: resolve compiled binary crashes from circular dep and Bun CJS splitting bug
This commit is contained in:
@@ -13,7 +13,8 @@ import { Installation } from "../../installation"
|
||||
import { PushRelay } from "../../server/push-relay"
|
||||
import { Log } from "../../util"
|
||||
import { Global } from "../../global"
|
||||
import * as QRCode from "qrcode"
|
||||
// dynamic import: static `import * as` of CJS package triggers Bun bundler splitting bug
|
||||
import type * as QRCodeType from "qrcode"
|
||||
|
||||
const log = Log.create({ service: "serve" })
|
||||
|
||||
@@ -184,6 +185,7 @@ async function printPairQR(pair: PairPayload) {
|
||||
linkLength: link.length,
|
||||
qr: qrConfig,
|
||||
})
|
||||
const QRCode: typeof QRCodeType = await import("qrcode")
|
||||
const code = await QRCode.toString(link, {
|
||||
...qrConfig,
|
||||
})
|
||||
|
||||
@@ -17,7 +17,8 @@ import { errors } from "../../error"
|
||||
import { lazy } from "@/util/lazy"
|
||||
import { Effect, Option } from "effect"
|
||||
import { PushRelay } from "../../push-relay"
|
||||
import * as QRCode from "qrcode"
|
||||
// dynamic import: static `import * as` of CJS package triggers Bun bundler splitting bug
|
||||
import type * as QRCodeType from "qrcode"
|
||||
import { Agent } from "@/agent/agent"
|
||||
import { jsonRequest, runRequest } from "./trace"
|
||||
|
||||
@@ -60,6 +61,7 @@ function pushPairLink(input: { relaySecret: string; hosts: string[] }) {
|
||||
}
|
||||
|
||||
async function pushPairQRCode(input: { relaySecret: string; hosts: string[] }) {
|
||||
const QRCode: typeof QRCodeType = await import("qrcode")
|
||||
return QRCode.toDataURL(pushPairLink(input), pushPairQROptions)
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,8 @@ export const Event = {
|
||||
"session.error",
|
||||
z.object({
|
||||
sessionID: SessionID.zod.optional(),
|
||||
error: MessageV2.Assistant.shape.error,
|
||||
// z.lazy defers access to break circular dep: session → message-v2 → provider → plugin → session
|
||||
error: z.lazy(() => MessageV2.Assistant.shape.error),
|
||||
}),
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user