@rynfar/meridian 1.52.0 → 1.54.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/README.md +84 -16
- package/dist/{profileCli-s1h4vh8w.js → cli-jhm27q0x.js} +346 -31
- package/dist/{cli-tq3vtp0q.js → cli-mqht6rs9.js} +905 -61
- package/dist/cli.js +3 -3
- package/dist/grepTool.d.ts +23 -0
- package/dist/grepTool.d.ts.map +1 -0
- package/dist/mcpTools.d.ts.map +1 -1
- package/dist/profileCli-d9tcp916.js +35 -0
- package/dist/proxy/adapters/codex.d.ts +22 -0
- package/dist/proxy/adapters/codex.d.ts.map +1 -0
- package/dist/proxy/adapters/detect.d.ts.map +1 -1
- package/dist/proxy/design.d.ts +82 -0
- package/dist/proxy/design.d.ts.map +1 -0
- package/dist/proxy/openai.d.ts +5 -0
- package/dist/proxy/openai.d.ts.map +1 -1
- package/dist/proxy/openaiResponses.d.ts +137 -0
- package/dist/proxy/openaiResponses.d.ts.map +1 -0
- package/dist/proxy/profileCli.d.ts +48 -0
- package/dist/proxy/profileCli.d.ts.map +1 -0
- package/dist/proxy/sdkFeatures.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/transforms/codex.d.ts +12 -0
- package/dist/proxy/transforms/codex.d.ts.map +1 -0
- package/dist/proxy/transforms/opencode.d.ts.map +1 -1
- package/dist/proxy/transforms/registry.d.ts.map +1 -1
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/plugin/meridian.ts +58 -13
- package/dist/cli-vjeftz4z.js +0 -329
package/dist/cli-vjeftz4z.js
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__esm
|
|
3
|
-
} from "./cli-p9swy5t3.js";
|
|
4
|
-
|
|
5
|
-
// src/env.ts
|
|
6
|
-
function env(suffix) {
|
|
7
|
-
return process.env[`MERIDIAN_${suffix}`] ?? process.env[`CLAUDE_PROXY_${suffix}`];
|
|
8
|
-
}
|
|
9
|
-
function envBool(suffix) {
|
|
10
|
-
const val = env(suffix);
|
|
11
|
-
return val === "1" || val === "true" || val === "yes";
|
|
12
|
-
}
|
|
13
|
-
function resolvePassthrough(defaultValue) {
|
|
14
|
-
const val = env("PASSTHROUGH");
|
|
15
|
-
if (val === "1" || val === "true" || val === "yes")
|
|
16
|
-
return true;
|
|
17
|
-
if (val === "0" || val === "false" || val === "no")
|
|
18
|
-
return false;
|
|
19
|
-
return defaultValue;
|
|
20
|
-
}
|
|
21
|
-
function envInt(suffix, defaultValue) {
|
|
22
|
-
const val = env(suffix);
|
|
23
|
-
if (!val)
|
|
24
|
-
return defaultValue;
|
|
25
|
-
const parsed = parseInt(val, 10);
|
|
26
|
-
return Number.isFinite(parsed) ? parsed : defaultValue;
|
|
27
|
-
}
|
|
28
|
-
var init_env = () => {};
|
|
29
|
-
|
|
30
|
-
// src/proxy/models.ts
|
|
31
|
-
init_env();
|
|
32
|
-
import { exec as execCallback, execFile as execFileCallback } from "child_process";
|
|
33
|
-
import { existsSync, statSync } from "fs";
|
|
34
|
-
import { fileURLToPath } from "url";
|
|
35
|
-
import { join, dirname } from "path";
|
|
36
|
-
import { promisify } from "util";
|
|
37
|
-
var exec = promisify(execCallback);
|
|
38
|
-
var execFile = promisify(execFileCallback);
|
|
39
|
-
var STUB_SIZE_THRESHOLD = 4096;
|
|
40
|
-
var CANONICAL_FABLE_MODEL = "claude-fable-5";
|
|
41
|
-
var CANONICAL_OPUS_MODEL = "claude-opus-4-8";
|
|
42
|
-
var CANONICAL_SONNET_MODEL = "claude-sonnet-5";
|
|
43
|
-
var CANONICAL_HAIKU_MODEL = "claude-haiku-4-5";
|
|
44
|
-
function resolveSdkModelDefaults(env2 = process.env) {
|
|
45
|
-
return {
|
|
46
|
-
ANTHROPIC_DEFAULT_FABLE_MODEL: env2.MERIDIAN_DEFAULT_FABLE_MODEL ?? CANONICAL_FABLE_MODEL,
|
|
47
|
-
ANTHROPIC_DEFAULT_OPUS_MODEL: env2.MERIDIAN_DEFAULT_OPUS_MODEL ?? CANONICAL_OPUS_MODEL,
|
|
48
|
-
ANTHROPIC_DEFAULT_SONNET_MODEL: env2.MERIDIAN_DEFAULT_SONNET_MODEL ?? CANONICAL_SONNET_MODEL,
|
|
49
|
-
ANTHROPIC_DEFAULT_HAIKU_MODEL: env2.MERIDIAN_DEFAULT_HAIKU_MODEL ?? CANONICAL_HAIKU_MODEL
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function explicitModelPin(requestedModel) {
|
|
53
|
-
const base = requestedModel.trim().toLowerCase().replace(/\[1m\]$/, "");
|
|
54
|
-
const match = /^claude-(sonnet|opus|haiku|fable|mythos)-\d[\w.-]*$/.exec(base);
|
|
55
|
-
if (!match)
|
|
56
|
-
return;
|
|
57
|
-
const tier = match[1] === "mythos" ? "FABLE" : match[1].toUpperCase();
|
|
58
|
-
return { [`ANTHROPIC_DEFAULT_${tier}_MODEL`]: base };
|
|
59
|
-
}
|
|
60
|
-
var AUTH_STATUS_CACHE_TTL_MS = 60000;
|
|
61
|
-
var AUTH_STATUS_FAILURE_TTL_MS = 5000;
|
|
62
|
-
var cachedAuthStatus = null;
|
|
63
|
-
var lastKnownGoodAuthStatus = null;
|
|
64
|
-
var cachedAuthStatusAt = 0;
|
|
65
|
-
var cachedAuthStatusIsFailure = false;
|
|
66
|
-
var cachedAuthStatusPromise = null;
|
|
67
|
-
function supports1mContext(model) {
|
|
68
|
-
const override = env("1M_CONTEXT_SUPPORT");
|
|
69
|
-
if (override === "0" || override === "false" || override === "no")
|
|
70
|
-
return false;
|
|
71
|
-
if (model.includes("4-5") || model.includes("4.5"))
|
|
72
|
-
return false;
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
function mapModelToClaudeModel(model, subscriptionType, agentMode) {
|
|
76
|
-
if (model.includes("haiku"))
|
|
77
|
-
return "haiku";
|
|
78
|
-
const use1m = supports1mContext(model);
|
|
79
|
-
const isSubagent = agentMode === "subagent";
|
|
80
|
-
if (model.includes("fable") || model.includes("mythos")) {
|
|
81
|
-
if (use1m && !isSubagent && !isExtendedContextKnownUnavailable())
|
|
82
|
-
return "fable[1m]";
|
|
83
|
-
return "fable";
|
|
84
|
-
}
|
|
85
|
-
if (model.includes("opus")) {
|
|
86
|
-
if (use1m && !isSubagent && !isExtendedContextKnownUnavailable())
|
|
87
|
-
return "opus[1m]";
|
|
88
|
-
return "opus";
|
|
89
|
-
}
|
|
90
|
-
const sonnetOverride = process.env.MERIDIAN_SONNET_MODEL ?? process.env.CLAUDE_PROXY_SONNET_MODEL;
|
|
91
|
-
if (sonnetOverride === "sonnet[1m]") {
|
|
92
|
-
if (!use1m || isSubagent || isExtendedContextKnownUnavailable())
|
|
93
|
-
return "sonnet";
|
|
94
|
-
return "sonnet[1m]";
|
|
95
|
-
}
|
|
96
|
-
return "sonnet";
|
|
97
|
-
}
|
|
98
|
-
var EXTRA_USAGE_RETRY_MS = 60 * 60 * 1000;
|
|
99
|
-
var extraUsageUnavailableAt = 0;
|
|
100
|
-
function recordExtendedContextUnavailable() {
|
|
101
|
-
extraUsageUnavailableAt = Date.now();
|
|
102
|
-
}
|
|
103
|
-
function isExtendedContextKnownUnavailable() {
|
|
104
|
-
return extraUsageUnavailableAt > 0 && Date.now() - extraUsageUnavailableAt < EXTRA_USAGE_RETRY_MS;
|
|
105
|
-
}
|
|
106
|
-
function stripExtendedContext(model) {
|
|
107
|
-
if (model === "opus[1m]")
|
|
108
|
-
return "opus";
|
|
109
|
-
if (model === "sonnet[1m]")
|
|
110
|
-
return "sonnet";
|
|
111
|
-
if (model === "fable[1m]")
|
|
112
|
-
return "fable";
|
|
113
|
-
return model;
|
|
114
|
-
}
|
|
115
|
-
function hasExtendedContext(model) {
|
|
116
|
-
return model.endsWith("[1m]");
|
|
117
|
-
}
|
|
118
|
-
var profileAuthCaches = new Map;
|
|
119
|
-
function getAuthCacheInfo(profileId) {
|
|
120
|
-
if (!profileId) {
|
|
121
|
-
return { lastCheckedAt: cachedAuthStatusAt, lastSuccessAt: cachedAuthStatusIsFailure ? 0 : cachedAuthStatusAt, isFailure: cachedAuthStatusIsFailure };
|
|
122
|
-
}
|
|
123
|
-
const cache = profileAuthCaches.get(profileId);
|
|
124
|
-
if (!cache)
|
|
125
|
-
return { lastCheckedAt: 0, lastSuccessAt: 0, isFailure: false };
|
|
126
|
-
return { lastCheckedAt: cache.at, lastSuccessAt: cache.lastSuccessAt, isFailure: cache.isFailure };
|
|
127
|
-
}
|
|
128
|
-
function getAuthCache(key) {
|
|
129
|
-
let cache = profileAuthCaches.get(key);
|
|
130
|
-
if (!cache) {
|
|
131
|
-
cache = { status: null, lastKnownGood: null, at: 0, isFailure: false, promise: null, lastSuccessAt: 0 };
|
|
132
|
-
profileAuthCaches.set(key, cache);
|
|
133
|
-
}
|
|
134
|
-
return cache;
|
|
135
|
-
}
|
|
136
|
-
async function getClaudeAuthStatusAsync(profileId, envOverrides) {
|
|
137
|
-
const isDefault = !profileId;
|
|
138
|
-
const cache = isDefault ? null : getAuthCache(profileId);
|
|
139
|
-
const c_status = cache ? cache.status : cachedAuthStatus;
|
|
140
|
-
const c_lastKnownGood = cache ? cache.lastKnownGood : lastKnownGoodAuthStatus;
|
|
141
|
-
const c_at = cache ? cache.at : cachedAuthStatusAt;
|
|
142
|
-
const c_isFailure = cache ? cache.isFailure : cachedAuthStatusIsFailure;
|
|
143
|
-
let c_promise = cache ? cache.promise : cachedAuthStatusPromise;
|
|
144
|
-
const ttl = c_isFailure ? AUTH_STATUS_FAILURE_TTL_MS : AUTH_STATUS_CACHE_TTL_MS;
|
|
145
|
-
if (c_at > 0 && Date.now() - c_at < ttl) {
|
|
146
|
-
return c_status ?? c_lastKnownGood;
|
|
147
|
-
}
|
|
148
|
-
if (c_promise)
|
|
149
|
-
return c_promise;
|
|
150
|
-
c_promise = (async () => {
|
|
151
|
-
try {
|
|
152
|
-
const claudePath = await resolveClaudeExecutableAsync();
|
|
153
|
-
const { stdout } = await execFile(claudePath, ["auth", "status"], {
|
|
154
|
-
timeout: 5000,
|
|
155
|
-
...envOverrides ? { env: { ...process.env, ...envOverrides } } : {}
|
|
156
|
-
});
|
|
157
|
-
const parsed = JSON.parse(stdout);
|
|
158
|
-
if (cache) {
|
|
159
|
-
cache.status = parsed;
|
|
160
|
-
cache.lastKnownGood = parsed;
|
|
161
|
-
cache.at = Date.now();
|
|
162
|
-
cache.isFailure = false;
|
|
163
|
-
cache.lastSuccessAt = Date.now();
|
|
164
|
-
} else {
|
|
165
|
-
cachedAuthStatus = parsed;
|
|
166
|
-
lastKnownGoodAuthStatus = parsed;
|
|
167
|
-
cachedAuthStatusAt = Date.now();
|
|
168
|
-
cachedAuthStatusIsFailure = false;
|
|
169
|
-
}
|
|
170
|
-
return parsed;
|
|
171
|
-
} catch {
|
|
172
|
-
if (cache) {
|
|
173
|
-
cache.isFailure = true;
|
|
174
|
-
cache.at = Date.now();
|
|
175
|
-
cache.status = null;
|
|
176
|
-
return cache.lastKnownGood;
|
|
177
|
-
} else {
|
|
178
|
-
cachedAuthStatusIsFailure = true;
|
|
179
|
-
cachedAuthStatusAt = Date.now();
|
|
180
|
-
cachedAuthStatus = null;
|
|
181
|
-
return lastKnownGoodAuthStatus;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
})();
|
|
185
|
-
if (cache)
|
|
186
|
-
cache.promise = c_promise;
|
|
187
|
-
else
|
|
188
|
-
cachedAuthStatusPromise = c_promise;
|
|
189
|
-
try {
|
|
190
|
-
return await c_promise;
|
|
191
|
-
} finally {
|
|
192
|
-
if (cache)
|
|
193
|
-
cache.promise = null;
|
|
194
|
-
else
|
|
195
|
-
cachedAuthStatusPromise = null;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
var cachedClaudeInfo = null;
|
|
199
|
-
var cachedClaudePathPromise = null;
|
|
200
|
-
var DEFAULT_DEPS = {
|
|
201
|
-
existsSync,
|
|
202
|
-
statSync: (p) => statSync(p),
|
|
203
|
-
exec,
|
|
204
|
-
resolvePackage: (specifier) => fileURLToPath(import.meta.resolve(specifier)),
|
|
205
|
-
envGet: (name) => process.env[name],
|
|
206
|
-
platform: process.platform,
|
|
207
|
-
arch: process.arch,
|
|
208
|
-
isBun: typeof process.versions.bun !== "undefined"
|
|
209
|
-
};
|
|
210
|
-
function tryEnvOverride(deps) {
|
|
211
|
-
const explicit = deps.envGet("MERIDIAN_CLAUDE_PATH");
|
|
212
|
-
if (!explicit)
|
|
213
|
-
return null;
|
|
214
|
-
return deps.existsSync(explicit) ? explicit : null;
|
|
215
|
-
}
|
|
216
|
-
function tryBundledBinary(deps) {
|
|
217
|
-
try {
|
|
218
|
-
const pkgPath = deps.resolvePackage("@anthropic-ai/claude-code/package.json");
|
|
219
|
-
const bundled = join(dirname(pkgPath), "bin", "claude.exe");
|
|
220
|
-
if (!deps.existsSync(bundled))
|
|
221
|
-
return null;
|
|
222
|
-
const size = deps.statSync(bundled).size;
|
|
223
|
-
if (size <= STUB_SIZE_THRESHOLD)
|
|
224
|
-
return null;
|
|
225
|
-
return bundled;
|
|
226
|
-
} catch {
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function tryPlatformPackage(deps) {
|
|
231
|
-
const binName = deps.platform === "win32" ? "claude.exe" : "claude";
|
|
232
|
-
const candidates = [`@anthropic-ai/claude-code-${deps.platform}-${deps.arch}`];
|
|
233
|
-
if (deps.platform === "linux") {
|
|
234
|
-
candidates.push(`@anthropic-ai/claude-code-${deps.platform}-${deps.arch}-musl`);
|
|
235
|
-
}
|
|
236
|
-
for (const pkg of candidates) {
|
|
237
|
-
try {
|
|
238
|
-
const pkgJson = deps.resolvePackage(`${pkg}/package.json`);
|
|
239
|
-
const candidate = join(dirname(pkgJson), binName);
|
|
240
|
-
if (deps.existsSync(candidate))
|
|
241
|
-
return candidate;
|
|
242
|
-
} catch {}
|
|
243
|
-
}
|
|
244
|
-
return null;
|
|
245
|
-
}
|
|
246
|
-
async function tryPathLookup(deps) {
|
|
247
|
-
const cmd = deps.platform === "win32" ? "where claude" : "which claude";
|
|
248
|
-
try {
|
|
249
|
-
const { stdout } = await deps.exec(cmd);
|
|
250
|
-
const candidates = stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
251
|
-
for (const candidate of candidates) {
|
|
252
|
-
if (deps.platform === "win32" && candidate.startsWith("/"))
|
|
253
|
-
continue;
|
|
254
|
-
if (deps.existsSync(candidate))
|
|
255
|
-
return candidate;
|
|
256
|
-
}
|
|
257
|
-
} catch {}
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
function tryLegacySdkCliJs(deps) {
|
|
261
|
-
if (!deps.isBun)
|
|
262
|
-
return null;
|
|
263
|
-
try {
|
|
264
|
-
const sdkPath = deps.resolvePackage("@anthropic-ai/claude-agent-sdk");
|
|
265
|
-
const cliJs = join(dirname(sdkPath), "cli.js");
|
|
266
|
-
return deps.existsSync(cliJs) ? cliJs : null;
|
|
267
|
-
} catch {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
async function resolveClaudeExecutableWithSource(deps = DEFAULT_DEPS) {
|
|
272
|
-
const env2 = tryEnvOverride(deps);
|
|
273
|
-
if (env2)
|
|
274
|
-
return { path: env2, source: "env" };
|
|
275
|
-
const bundled = tryBundledBinary(deps);
|
|
276
|
-
if (bundled)
|
|
277
|
-
return { path: bundled, source: "bundled" };
|
|
278
|
-
const platformPkg = tryPlatformPackage(deps);
|
|
279
|
-
if (platformPkg)
|
|
280
|
-
return { path: platformPkg, source: "platform-package" };
|
|
281
|
-
const pathLookup = await tryPathLookup(deps);
|
|
282
|
-
if (pathLookup)
|
|
283
|
-
return { path: pathLookup, source: "path-lookup" };
|
|
284
|
-
const legacy = tryLegacySdkCliJs(deps);
|
|
285
|
-
if (legacy)
|
|
286
|
-
return { path: legacy, source: "legacy-cli-js" };
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
function resolveClaudeExecutableSync(deps = DEFAULT_DEPS) {
|
|
290
|
-
const env2 = tryEnvOverride(deps);
|
|
291
|
-
if (env2)
|
|
292
|
-
return { path: env2, source: "env" };
|
|
293
|
-
const bundled = tryBundledBinary(deps);
|
|
294
|
-
if (bundled)
|
|
295
|
-
return { path: bundled, source: "bundled" };
|
|
296
|
-
const platformPkg = tryPlatformPackage(deps);
|
|
297
|
-
if (platformPkg)
|
|
298
|
-
return { path: platformPkg, source: "platform-package" };
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
function getResolvedClaudeExecutableInfo() {
|
|
302
|
-
return cachedClaudeInfo;
|
|
303
|
-
}
|
|
304
|
-
async function resolveClaudeExecutableAsync() {
|
|
305
|
-
if (cachedClaudeInfo)
|
|
306
|
-
return cachedClaudeInfo.path;
|
|
307
|
-
if (cachedClaudePathPromise)
|
|
308
|
-
return cachedClaudePathPromise;
|
|
309
|
-
cachedClaudePathPromise = (async () => {
|
|
310
|
-
const resolved = await resolveClaudeExecutableWithSource();
|
|
311
|
-
if (resolved) {
|
|
312
|
-
cachedClaudeInfo = resolved;
|
|
313
|
-
return resolved.path;
|
|
314
|
-
}
|
|
315
|
-
throw new Error("Could not find Claude Code executable. Install via: npm install -g @anthropic-ai/claude-code, " + "or set MERIDIAN_CLAUDE_PATH=/path/to/claude to point at an existing binary.");
|
|
316
|
-
})();
|
|
317
|
-
try {
|
|
318
|
-
return await cachedClaudePathPromise;
|
|
319
|
-
} finally {
|
|
320
|
-
cachedClaudePathPromise = null;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function isClosedControllerError(error) {
|
|
324
|
-
if (!(error instanceof Error))
|
|
325
|
-
return false;
|
|
326
|
-
return error.message.includes("Controller is already closed");
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
export { env, envBool, resolvePassthrough, envInt, init_env, CANONICAL_SONNET_MODEL, resolveSdkModelDefaults, explicitModelPin, mapModelToClaudeModel, recordExtendedContextUnavailable, stripExtendedContext, hasExtendedContext, getAuthCacheInfo, getClaudeAuthStatusAsync, resolveClaudeExecutableSync, getResolvedClaudeExecutableInfo, resolveClaudeExecutableAsync, isClosedControllerError };
|