@rynfar/meridian 1.24.1 → 1.25.1
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 +128 -184
- package/dist/cli-a05ws7rb.js +18 -0
- package/dist/cli-m9pfb7h9.js +203 -0
- package/dist/cli-rtab0qa6.js +67 -0
- package/dist/{cli-bjpad5x9.js → cli-s6f9jefk.js} +177 -124
- package/dist/cli.js +56 -3
- package/dist/proxy/adapter.d.ts +1 -1
- package/dist/proxy/errors.d.ts +16 -0
- package/dist/proxy/errors.d.ts.map +1 -1
- package/dist/proxy/fileChanges.d.ts.map +1 -1
- package/dist/proxy/models.d.ts +17 -1
- package/dist/proxy/models.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/setup.d.ts +42 -0
- package/dist/proxy/setup.d.ts.map +1 -0
- package/dist/proxy/tokenRefresh.d.ts +51 -0
- package/dist/proxy/tokenRefresh.d.ts.map +1 -0
- package/dist/server.js +4 -1
- package/dist/setup-5x116vbs.js +13 -0
- package/dist/telemetry/dashboard.d.ts +1 -1
- package/dist/telemetry/dashboard.d.ts.map +1 -1
- package/dist/telemetry/routes.d.ts.map +1 -1
- package/dist/tokenRefresh-ywwpe8k2.js +11 -0
- package/package.json +76 -75
- package/plugin/meridian.ts +54 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meridian OpenCode plugin.
|
|
3
|
+
*
|
|
4
|
+
* Injects headers into every Anthropic API request so the proxy can:
|
|
5
|
+
* 1. Track sessions reliably (x-opencode-session / x-opencode-request)
|
|
6
|
+
* 2. Select the right model tier per agent (x-opencode-agent-mode)
|
|
7
|
+
* — primary agents get sonnet[1m] / opus[1m] (full 1M context)
|
|
8
|
+
* — subagents get sonnet / opus (200k, preserves rate-limit budget)
|
|
9
|
+
*
|
|
10
|
+
* Install once globally:
|
|
11
|
+
* meridian setup
|
|
12
|
+
*
|
|
13
|
+
* Or manually add to ~/.config/opencode/opencode.json:
|
|
14
|
+
* { "plugin": ["/absolute/path/to/plugin/meridian.ts"] }
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
type Plugin = (input: any) => Promise<{
|
|
18
|
+
"chat.headers"?: (
|
|
19
|
+
input: {
|
|
20
|
+
sessionID: string
|
|
21
|
+
// Typed as string in the SDK types but is actually the full agent
|
|
22
|
+
// object at runtime: { name: string; mode: "primary" | "subagent" | "all" }
|
|
23
|
+
agent: string | { name?: string; mode?: string }
|
|
24
|
+
model: { providerID: string }
|
|
25
|
+
message: { id: string }
|
|
26
|
+
},
|
|
27
|
+
output: { headers: Record<string, string> }
|
|
28
|
+
) => Promise<void>
|
|
29
|
+
}>
|
|
30
|
+
|
|
31
|
+
const MeridianPlugin: Plugin = async () => {
|
|
32
|
+
return {
|
|
33
|
+
"chat.headers": async (incoming, output) => {
|
|
34
|
+
// Only inject headers for Anthropic provider requests
|
|
35
|
+
if (incoming.model.providerID !== "anthropic") return
|
|
36
|
+
|
|
37
|
+
// Session tracking
|
|
38
|
+
output.headers["x-opencode-session"] = incoming.sessionID
|
|
39
|
+
output.headers["x-opencode-request"] = incoming.message.id
|
|
40
|
+
|
|
41
|
+
// Agent mode — runtime value is the full agent object even though
|
|
42
|
+
// the TypeScript type says string. Read .mode directly.
|
|
43
|
+
const agent = incoming.agent as { name?: string; mode?: string } | string
|
|
44
|
+
output.headers["x-opencode-agent-mode"] = typeof agent === "object"
|
|
45
|
+
? (agent.mode ?? "primary")
|
|
46
|
+
: "primary"
|
|
47
|
+
output.headers["x-opencode-agent-name"] = typeof agent === "object"
|
|
48
|
+
? (agent.name ?? "unknown")
|
|
49
|
+
: String(agent)
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default MeridianPlugin
|