opencode-with-claude 1.1.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function d(t){return(n,e)=>t.app.log({body:{service:"opencode-with-claude",level:n,message:e}})}import{startProxyServer as l}from"opencode-claude-max-proxy";var g=process.platform==="win32",f=3456;async function u(t){let{port:n=f,log:e}=t,a=console.error;console.error=(...o)=>{let s=o.map(String).join(" ");if(s.startsWith("[PROXY]")){e("debug",s);return}a.apply(console,o)};let p=async o=>{try{return await l({port:o,host:"127.0.0.1",silent:!0})}catch(s){if(o!==0&&s instanceof Error&&"code"in s&&s.code==="EADDRINUSE")return await e("info",`Port ${o} in use, starting on a random port instead...`),l({port:0,host:"127.0.0.1",silent:!0});throw s}},i;try{i=await p(n)}catch(o){throw console.error=a,o}let r=i.server.address().port;return await e("info",`Claude Max proxy running on port ${r}`),{port:r,close:async()=>{console.error=a,await i.close()}}}function y(t){let n=!1,e=()=>{n||(n=!0,t.close())};process.on("exit",e),process.on("SIGINT",e),g||process.on("SIGTERM",e)}var w=async({client:t,$:n,directory:e})=>{let a=d(t),p=parseInt(process.env.CLAUDE_PROXY_PORT||"",10)||void 0,i=await u({port:p,log:a}),c=`http://127.0.0.1:${i.port}`;return await a("info",`proxy ready at ${c}`),y(i),{async config(r){r.provider??={},r.provider.anthropic??={},r.provider.anthropic.options??={},r.provider.anthropic.options.baseURL=c,r.provider.anthropic.options.apiKey="claude-max-proxy"},async"chat.headers"(r,o){r.model.providerID==="anthropic"&&(o.headers["x-opencode-session"]=r.sessionID,o.headers["x-opencode-request"]=r.message.id)}}};export{w as ClaudeMaxPlugin};
|
package/package.json
CHANGED