opencode-with-claude 1.6.6 → 1.6.8
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/README.md +5 -4
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -108,14 +108,15 @@ without restarting the proxy. The plugin does not need to do anything special
|
|
|
108
108
|
for it to work — just edit the file and the next request picks it up. See
|
|
109
109
|
Meridian's documentation for the full list of adapter keys.
|
|
110
110
|
|
|
111
|
-
This plugin
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
This plugin does not edit Meridian's SDK feature file. When Meridian's default
|
|
112
|
+
client prompt pass-through is enabled, the plugin scrubs OpenCode-identifying
|
|
113
|
+
prompt fingerprints with `@rynfar/meridian-plugin-opencode-scrub` before
|
|
114
|
+
forwarding. User context such as `AGENTS.md` and configured instructions is
|
|
115
|
+
preserved, while cwd is forwarded to Meridian through the process environment.
|
|
114
116
|
|
|
115
117
|
```json
|
|
116
118
|
{
|
|
117
119
|
"opencode": {
|
|
118
|
-
"clientSystemPrompt": false,
|
|
119
120
|
"memory": true,
|
|
120
121
|
"thinking": "enabled",
|
|
121
122
|
"maxBudgetUsd": 0.5
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
import{scrubOpencodeFingerprints as z}from"@rynfar/meridian-plugin-opencode-scrub";var N=/authenticat|credentials|expired|not logged in|exit(?:ed)? with code|crash|unhealthy|401|402|billing|subscription/i,T=/rate.limit|429|overloaded|503|stale.session|timeout|timed out/i;function h(e){return(r,n)=>e.app.log({body:{service:"opencode-with-claude",level:r,message:n}})}function R(e){return N.test(e)?"error":T.test(e)?"warn":"debug"}import{existsSync as M,readFileSync as U}from"fs";import{homedir as H}from"os";import{join as P}from"path";var S=()=>P(H(),".config","meridian"),I=()=>P(S(),"profiles.json"),L=()=>P(S(),"settings.json");function m(e,r){e?.("warn","[opencode-with-claude] ".concat(r))}function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function D(e,r,n){if(!Array.isArray(e))return m(n,"".concat(r," must be a JSON array of profile objects; got ").concat(typeof e,". Ignoring.")),[];let t=[];for(let o of e){if(!E(o)||typeof o.id!="string"||!o.id){m(n,"".concat(r,': dropping profile without a string "id" field.'));continue}let i={id:o.id};(o.type==="claude-max"||o.type==="api")&&(i.type=o.type),typeof o.claudeConfigDir=="string"&&(i.claudeConfigDir=o.claudeConfigDir),typeof o.apiKey=="string"&&(i.apiKey=o.apiKey),typeof o.baseUrl=="string"&&(i.baseUrl=o.baseUrl),t.push(i)}return t}function w(e,r){if(M(e))try{return JSON.parse(U(e,"utf8"))}catch(n){let t=n instanceof Error?n.message:String(n);m(r,"failed to parse ".concat(e,": ").concat(t));return}}function W(e){let r=process.env.MERIDIAN_PROFILES;if(r)try{return D(JSON.parse(r),"MERIDIAN_PROFILES",e)}catch(n){let t=n instanceof Error?n.message:String(n);m(e,"failed to parse MERIDIAN_PROFILES env var: ".concat(t));return}}function j(e){let r=w(I(),e);return r===void 0?[]:D(r,I(),e)}function K(e){let r=w(L(),e);if(!E(r))return;let n=r.activeProfile;if(n!==void 0){if(typeof n!="string"||!n){m(e,"".concat(L(),': "activeProfile" must be a non-empty string; ignoring.'));return}return n}}function C(e){let r=[],n="none",t=W(e);if(t)r=t,n="env";else{let a=j(e);a.length>0&&(r=a,n="disk")}let o,i="none",l=process.env.MERIDIAN_DEFAULT_PROFILE?.trim();if(l)o=l,i="env";else{let a=K(e);a&&(o=a,i="disk")}return o&&r.length>0&&!r.some(a=>a.id===o)&&(m(e,'default profile "'.concat(o,'" (from ').concat(i,") not found among configured profiles; ignoring.")),o=void 0,i="none"),{profiles:r,defaultProfile:o,sources:{profiles:n,defaultProfile:i}}}function A(e){if(e.profiles.length===0)return;let r=e.profiles.map(i=>i.id).join(", "),n=e.defaultProfile??e.profiles[0]?.id,t=e.sources.profiles,o=e.sources.defaultProfile==="none"?"first":e.sources.defaultProfile;return"loaded ".concat(e.profiles.length," meridian profile(s) from ").concat(t,": ").concat(r," (active: ").concat(n," [").concat(o,"])")}import{startProxyServer as J}from"@rynfar/meridian";process.env.MERIDIAN_PASSTHROUGH??="true";var G=process.platform==="win32",F=3456,b="127.0.0.1";function X(e){return e.includes(":")&&!e.startsWith("[")?"[".concat(e,"]"):e}function v(){let e=process.env.MERIDIAN_HOST?.trim()||process.env.CLAUDE_PROXY_HOST?.trim()||b;return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function Y(e=v()){return e==="0.0.0.0"?b:e==="::"||e==="[::]"?"::1":e}function k(e,r=v()){return"http://".concat(X(Y(r)),":").concat(e)}async function O(e){let{port:r=F,log:n,profiles:t,defaultProfile:o}=e,i=v(),l=console.error;console.error=(...d)=>{let f=d.map(String).join(" ");if(f.startsWith("[PROXY]")){n?.(R(f),f);return}l.apply(console,d)};let a=d=>new Promise((f,x)=>{J({port:d,host:i,silent:!0,profiles:t,defaultProfile:o}).then(g=>{let y=_=>{x(_)};g.server.once("error",y),g.server.listening?(g.server.removeListener("error",y),f(g)):g.server.once("listening",()=>{g.server.removeListener("error",y),f(g)})},x)}),c=async d=>{try{return await a(d)}catch(f){if(d!==0&&f instanceof Error&&"code"in f&&f.code==="EADDRINUSE")return n?.("info","Port ".concat(d," in use, starting on a random port instead...")),a(0);throw f}},s;try{s=await c(typeof r=="string"?parseInt(r,10):r)}catch(d){throw console.error=l,d}let p=s.server.address()?.port??s.config?.port??F;return n?.("info","Claude Max proxy running on port ".concat(p)),{port:p,close:async()=>{console.error=l,await s.close()}}}function $(e){let r=!1,n=()=>{r||(r=!0,e.close())};process.on("exit",n),process.on("SIGINT",n),G||process.on("SIGTERM",n)}var ae=async({client:e,directory:r})=>{let n=h(e);r&&!process.env.MERIDIAN_WORKDIR&&!process.env.CLAUDE_PROXY_WORKDIR&&(process.env.MERIDIAN_WORKDIR=r);let t=C(n),o=A(t);o&&n("info",o);let i=process.env.CLAUDE_PROXY_PORT||3456,l=await O({port:i,log:n,profiles:t.profiles,defaultProfile:t.defaultProfile}),a=k(l.port);return n("info","proxy ready at ".concat(a)),$(l),{async config(c){let s=c.provider?.anthropic;s&&((s.options??={}).baseURL=a)},async"experimental.chat.system.transform"(c,s){if(c.model.providerID!=="anthropic")return;let u=s.system.join("\n\n"),p=z(u);p!==u&&s.system.splice(0,s.system.length,p)},async"chat.headers"(c,s){if(c.model.providerID!=="anthropic")return;delete s.headers["anthropic-beta"];let u=c.agent,p=typeof u=="object"&&u!==null?u:void 0,d=p?.name??String(u??"unknown"),f=p?.mode??"primary";s.headers["x-opencode-session"]=c.sessionID,s.headers["x-opencode-request"]=c.message.id,s.headers["x-opencode-agent-mode"]=f,s.headers["x-opencode-agent-name"]=d.replace(/[^\x20-\x7E]/g,"").trim()||"unknown"}}};export{ae as ClaudeMaxPlugin};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-with-claude",
|
|
3
3
|
"description": "OpenCode plugin to use your Claude Max subscription via Meridian proxy",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@rynfar/meridian": "^1.42.0"
|
|
9
|
+
"@rynfar/meridian": "^1.42.0",
|
|
10
|
+
"@rynfar/meridian-plugin-opencode-scrub": "^0.2.0"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@opencode-ai/plugin": "^1.14.22",
|