Răsfoiți Sursa

core: restore plugin serverUrl getter so plugins can connect to local server

Dax Raad 5 luni în urmă
părinte
comite
604ab1bde1

+ 1 - 1
packages/opencode/src/plugin/index.ts

@@ -35,7 +35,7 @@ export namespace Plugin {
       worktree: Instance.worktree,
       directory: Instance.directory,
       get serverUrl(): URL {
-        throw new Error("Server URL is no longer supported in plugins")
+        return Server.url ?? new URL("http://localhost:4096")
       },
       $: Bun.$,
     }

+ 4 - 0
packages/opencode/src/server/server.ts

@@ -585,6 +585,9 @@ export namespace Server {
     return result
   }
 
+  /** @deprecated do not use this dumb shit */
+  export let url: URL
+
   export function listen(opts: {
     port: number
     hostname: string
@@ -592,6 +595,7 @@ export namespace Server {
     mdnsDomain?: string
     cors?: string[]
   }) {
+    url = new URL(`http://${opts.hostname}:${opts.port}`)
     const app = createApp(opts)
     const args = {
       hostname: opts.hostname,