@rynfar/meridian 1.62.7 → 1.64.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 +3 -2
- package/bin/meridian-launchd.sh +128 -0
- package/dist/{cli-21w6xm0d.js → cli-4ghkaajs.js} +27332 -12903
- package/dist/{cli-xmweegb1.js → cli-8yp89fan.js} +52 -0
- package/dist/cli-pbvm9kc2.js +760 -0
- package/dist/cli.js +71 -12
- package/dist/meridian-v2.js +139 -0
- package/dist/{pluginPage-03q5j753.js → pluginPage-n3gdtbmj.js} +1 -1
- package/dist/{profileCli-39vshwdn.js → profileCli-ap7eg985.js} +2 -2
- package/dist/{profilePage-gtazq15d.js → profilePage-vfj2dbhn.js} +1 -1
- package/dist/proxy/adapter.d.ts +13 -0
- package/dist/proxy/adapter.d.ts.map +1 -1
- package/dist/proxy/adapters/opencode.d.ts +7 -0
- package/dist/proxy/adapters/opencode.d.ts.map +1 -1
- package/dist/proxy/buildInfo.d.ts +94 -0
- package/dist/proxy/buildInfo.d.ts.map +1 -0
- package/dist/proxy/cwd.d.ts.map +1 -1
- package/dist/proxy/errors.d.ts.map +1 -1
- package/dist/proxy/passthroughDenial.d.ts +17 -0
- package/dist/proxy/passthroughDenial.d.ts.map +1 -0
- package/dist/proxy/passthroughEarlyStop.d.ts +52 -7
- package/dist/proxy/passthroughEarlyStop.d.ts.map +1 -1
- package/dist/proxy/passthroughTools.d.ts.map +1 -1
- package/dist/proxy/query.d.ts +8 -0
- package/dist/proxy/query.d.ts.map +1 -1
- package/dist/proxy/server.d.ts.map +1 -1
- package/dist/proxy/session/cache.d.ts +11 -2
- package/dist/proxy/session/cache.d.ts.map +1 -1
- package/dist/proxy/session/crossProcessTurnCoordinator.d.ts +40 -0
- package/dist/proxy/session/crossProcessTurnCoordinator.d.ts.map +1 -0
- package/dist/proxy/session/durableFileSystem.d.ts +21 -0
- package/dist/proxy/session/durableFileSystem.d.ts.map +1 -0
- package/dist/proxy/session/lineage.d.ts +20 -0
- package/dist/proxy/session/lineage.d.ts.map +1 -1
- package/dist/proxy/session/processIncarnation.d.ts +46 -0
- package/dist/proxy/session/processIncarnation.d.ts.map +1 -0
- package/dist/proxy/session/recoveryClaim.d.ts +19 -0
- package/dist/proxy/session/recoveryClaim.d.ts.map +1 -0
- package/dist/proxy/session/sdkProcessGate.d.ts +19 -0
- package/dist/proxy/session/sdkProcessGate.d.ts.map +1 -0
- package/dist/proxy/sessionLifecycle.d.ts +105 -0
- package/dist/proxy/sessionLifecycle.d.ts.map +1 -0
- package/dist/proxy/sessionStore.d.ts +53 -7
- package/dist/proxy/sessionStore.d.ts.map +1 -1
- package/dist/proxy/setup.d.ts +35 -10
- package/dist/proxy/setup.d.ts.map +1 -1
- package/dist/proxy/types.d.ts +4 -0
- package/dist/proxy/types.d.ts.map +1 -1
- package/dist/proxy/updateCheck.d.ts +31 -0
- package/dist/proxy/updateCheck.d.ts.map +1 -0
- package/dist/server.js +5 -5
- package/dist/setup-4v3zg3c0.js +33 -0
- package/dist/telemetry/profileBar.d.ts +3 -3
- package/dist/telemetry/profileBar.d.ts.map +1 -1
- package/dist/telemetry/settingsPage.d.ts +1 -1
- package/dist/telemetry/settingsPage.d.ts.map +1 -1
- package/package.json +10 -5
- package/plugin/meridian-v2.ts +190 -0
- package/dist/cli-pc0mtjjv.js +0 -167
- package/dist/setup-0x573t61.js +0 -19
- package/dist/{cli-xfbhn15a.js → cli-0ed6j0vk.js} +3 -3
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require,
|
|
4
|
+
__toESM
|
|
5
|
+
} from "./cli-p9swy5t3.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/isexe/windows.js
|
|
8
|
+
var require_windows = __commonJS((exports, module) => {
|
|
9
|
+
module.exports = isexe;
|
|
10
|
+
isexe.sync = sync;
|
|
11
|
+
var fs = __require("fs");
|
|
12
|
+
function checkPathExt(path, options) {
|
|
13
|
+
var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
|
|
14
|
+
if (!pathext) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
pathext = pathext.split(";");
|
|
18
|
+
if (pathext.indexOf("") !== -1) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
for (var i = 0;i < pathext.length; i++) {
|
|
22
|
+
var p = pathext[i].toLowerCase();
|
|
23
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
function checkStat(stat, path, options) {
|
|
30
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return checkPathExt(path, options);
|
|
34
|
+
}
|
|
35
|
+
function isexe(path, options, cb) {
|
|
36
|
+
fs.stat(path, function(er, stat) {
|
|
37
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function sync(path, options) {
|
|
41
|
+
return checkStat(fs.statSync(path), path, options);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// node_modules/isexe/mode.js
|
|
46
|
+
var require_mode = __commonJS((exports, module) => {
|
|
47
|
+
module.exports = isexe;
|
|
48
|
+
isexe.sync = sync;
|
|
49
|
+
var fs = __require("fs");
|
|
50
|
+
function isexe(path, options, cb) {
|
|
51
|
+
fs.stat(path, function(er, stat) {
|
|
52
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function sync(path, options) {
|
|
56
|
+
return checkStat(fs.statSync(path), options);
|
|
57
|
+
}
|
|
58
|
+
function checkStat(stat, options) {
|
|
59
|
+
return stat.isFile() && checkMode(stat, options);
|
|
60
|
+
}
|
|
61
|
+
function checkMode(stat, options) {
|
|
62
|
+
var mod = stat.mode;
|
|
63
|
+
var uid = stat.uid;
|
|
64
|
+
var gid = stat.gid;
|
|
65
|
+
var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
|
|
66
|
+
var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
|
|
67
|
+
var u = parseInt("100", 8);
|
|
68
|
+
var g = parseInt("010", 8);
|
|
69
|
+
var o = parseInt("001", 8);
|
|
70
|
+
var ug = u | g;
|
|
71
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
72
|
+
return ret;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// node_modules/isexe/index.js
|
|
77
|
+
var require_isexe = __commonJS((exports, module) => {
|
|
78
|
+
var fs = __require("fs");
|
|
79
|
+
var core;
|
|
80
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
81
|
+
core = require_windows();
|
|
82
|
+
} else {
|
|
83
|
+
core = require_mode();
|
|
84
|
+
}
|
|
85
|
+
module.exports = isexe;
|
|
86
|
+
isexe.sync = sync;
|
|
87
|
+
function isexe(path, options, cb) {
|
|
88
|
+
if (typeof options === "function") {
|
|
89
|
+
cb = options;
|
|
90
|
+
options = {};
|
|
91
|
+
}
|
|
92
|
+
if (!cb) {
|
|
93
|
+
if (typeof Promise !== "function") {
|
|
94
|
+
throw new TypeError("callback not provided");
|
|
95
|
+
}
|
|
96
|
+
return new Promise(function(resolve, reject) {
|
|
97
|
+
isexe(path, options || {}, function(er, is) {
|
|
98
|
+
if (er) {
|
|
99
|
+
reject(er);
|
|
100
|
+
} else {
|
|
101
|
+
resolve(is);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
core(path, options || {}, function(er, is) {
|
|
107
|
+
if (er) {
|
|
108
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
109
|
+
er = null;
|
|
110
|
+
is = false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
cb(er, is);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function sync(path, options) {
|
|
117
|
+
try {
|
|
118
|
+
return core.sync(path, options || {});
|
|
119
|
+
} catch (er) {
|
|
120
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
121
|
+
return false;
|
|
122
|
+
} else {
|
|
123
|
+
throw er;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// node_modules/which/which.js
|
|
130
|
+
var require_which = __commonJS((exports, module) => {
|
|
131
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
132
|
+
var path = __require("path");
|
|
133
|
+
var COLON = isWindows ? ";" : ":";
|
|
134
|
+
var isexe = require_isexe();
|
|
135
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
136
|
+
var getPathInfo = (cmd, opt) => {
|
|
137
|
+
const colon = opt.colon || COLON;
|
|
138
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
139
|
+
...isWindows ? [process.cwd()] : [],
|
|
140
|
+
...(opt.path || process.env.PATH || "").split(colon)
|
|
141
|
+
];
|
|
142
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
143
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
144
|
+
if (isWindows) {
|
|
145
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
146
|
+
pathExt.unshift("");
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
pathEnv,
|
|
150
|
+
pathExt,
|
|
151
|
+
pathExtExe
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
var which = (cmd, opt, cb) => {
|
|
155
|
+
if (typeof opt === "function") {
|
|
156
|
+
cb = opt;
|
|
157
|
+
opt = {};
|
|
158
|
+
}
|
|
159
|
+
if (!opt)
|
|
160
|
+
opt = {};
|
|
161
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
162
|
+
const found = [];
|
|
163
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
164
|
+
if (i === pathEnv.length)
|
|
165
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
166
|
+
const ppRaw = pathEnv[i];
|
|
167
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
168
|
+
const pCmd = path.join(pathPart, cmd);
|
|
169
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
170
|
+
resolve(subStep(p, i, 0));
|
|
171
|
+
});
|
|
172
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
173
|
+
if (ii === pathExt.length)
|
|
174
|
+
return resolve(step(i + 1));
|
|
175
|
+
const ext = pathExt[ii];
|
|
176
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
177
|
+
if (!er && is) {
|
|
178
|
+
if (opt.all)
|
|
179
|
+
found.push(p + ext);
|
|
180
|
+
else
|
|
181
|
+
return resolve(p + ext);
|
|
182
|
+
}
|
|
183
|
+
return resolve(subStep(p, i, ii + 1));
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
187
|
+
};
|
|
188
|
+
var whichSync = (cmd, opt) => {
|
|
189
|
+
opt = opt || {};
|
|
190
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
191
|
+
const found = [];
|
|
192
|
+
for (let i = 0;i < pathEnv.length; i++) {
|
|
193
|
+
const ppRaw = pathEnv[i];
|
|
194
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
195
|
+
const pCmd = path.join(pathPart, cmd);
|
|
196
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
197
|
+
for (let j = 0;j < pathExt.length; j++) {
|
|
198
|
+
const cur = p + pathExt[j];
|
|
199
|
+
try {
|
|
200
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
201
|
+
if (is) {
|
|
202
|
+
if (opt.all)
|
|
203
|
+
found.push(cur);
|
|
204
|
+
else
|
|
205
|
+
return cur;
|
|
206
|
+
}
|
|
207
|
+
} catch (ex) {}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (opt.all && found.length)
|
|
211
|
+
return found;
|
|
212
|
+
if (opt.nothrow)
|
|
213
|
+
return null;
|
|
214
|
+
throw getNotFoundError(cmd);
|
|
215
|
+
};
|
|
216
|
+
module.exports = which;
|
|
217
|
+
which.sync = whichSync;
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// node_modules/path-key/index.js
|
|
221
|
+
var require_path_key = __commonJS((exports, module) => {
|
|
222
|
+
var pathKey = (options = {}) => {
|
|
223
|
+
const environment = options.env || process.env;
|
|
224
|
+
const platform = options.platform || process.platform;
|
|
225
|
+
if (platform !== "win32") {
|
|
226
|
+
return "PATH";
|
|
227
|
+
}
|
|
228
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
229
|
+
};
|
|
230
|
+
module.exports = pathKey;
|
|
231
|
+
module.exports.default = pathKey;
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
235
|
+
var require_resolveCommand = __commonJS((exports, module) => {
|
|
236
|
+
var path = __require("path");
|
|
237
|
+
var which = require_which();
|
|
238
|
+
var getPathKey = require_path_key();
|
|
239
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
240
|
+
const env = parsed.options.env || process.env;
|
|
241
|
+
const cwd = process.cwd();
|
|
242
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
243
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|
244
|
+
if (shouldSwitchCwd) {
|
|
245
|
+
try {
|
|
246
|
+
process.chdir(parsed.options.cwd);
|
|
247
|
+
} catch (err) {}
|
|
248
|
+
}
|
|
249
|
+
let resolved;
|
|
250
|
+
try {
|
|
251
|
+
resolved = which.sync(parsed.command, {
|
|
252
|
+
path: env[getPathKey({ env })],
|
|
253
|
+
pathExt: withoutPathExt ? path.delimiter : undefined
|
|
254
|
+
});
|
|
255
|
+
} catch (e) {} finally {
|
|
256
|
+
if (shouldSwitchCwd) {
|
|
257
|
+
process.chdir(cwd);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (resolved) {
|
|
261
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
262
|
+
}
|
|
263
|
+
return resolved;
|
|
264
|
+
}
|
|
265
|
+
function resolveCommand(parsed) {
|
|
266
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
267
|
+
}
|
|
268
|
+
module.exports = resolveCommand;
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// node_modules/cross-spawn/lib/util/escape.js
|
|
272
|
+
var require_escape = __commonJS((exports, module) => {
|
|
273
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
274
|
+
function escapeCommand(arg) {
|
|
275
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
276
|
+
return arg;
|
|
277
|
+
}
|
|
278
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
279
|
+
arg = `${arg}`;
|
|
280
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
281
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
282
|
+
arg = `"${arg}"`;
|
|
283
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
284
|
+
if (doubleEscapeMetaChars) {
|
|
285
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
286
|
+
}
|
|
287
|
+
return arg;
|
|
288
|
+
}
|
|
289
|
+
exports.command = escapeCommand;
|
|
290
|
+
exports.argument = escapeArgument;
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// node_modules/shebang-regex/index.js
|
|
294
|
+
var require_shebang_regex = __commonJS((exports, module) => {
|
|
295
|
+
module.exports = /^#!(.*)/;
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// node_modules/shebang-command/index.js
|
|
299
|
+
var require_shebang_command = __commonJS((exports, module) => {
|
|
300
|
+
var shebangRegex = require_shebang_regex();
|
|
301
|
+
module.exports = (string = "") => {
|
|
302
|
+
const match = string.match(shebangRegex);
|
|
303
|
+
if (!match) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
307
|
+
const binary = path.split("/").pop();
|
|
308
|
+
if (binary === "env") {
|
|
309
|
+
return argument;
|
|
310
|
+
}
|
|
311
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
312
|
+
};
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// node_modules/cross-spawn/lib/util/readShebang.js
|
|
316
|
+
var require_readShebang = __commonJS((exports, module) => {
|
|
317
|
+
var fs = __require("fs");
|
|
318
|
+
var shebangCommand = require_shebang_command();
|
|
319
|
+
function readShebang(command) {
|
|
320
|
+
const size = 150;
|
|
321
|
+
const buffer = Buffer.alloc(size);
|
|
322
|
+
let fd;
|
|
323
|
+
try {
|
|
324
|
+
fd = fs.openSync(command, "r");
|
|
325
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
326
|
+
fs.closeSync(fd);
|
|
327
|
+
} catch (e) {}
|
|
328
|
+
return shebangCommand(buffer.toString());
|
|
329
|
+
}
|
|
330
|
+
module.exports = readShebang;
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
// node_modules/cross-spawn/lib/parse.js
|
|
334
|
+
var require_parse = __commonJS((exports, module) => {
|
|
335
|
+
var path = __require("path");
|
|
336
|
+
var resolveCommand = require_resolveCommand();
|
|
337
|
+
var escape = require_escape();
|
|
338
|
+
var readShebang = require_readShebang();
|
|
339
|
+
var isWin = process.platform === "win32";
|
|
340
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
341
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
342
|
+
function detectShebang(parsed) {
|
|
343
|
+
parsed.file = resolveCommand(parsed);
|
|
344
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
345
|
+
if (shebang) {
|
|
346
|
+
parsed.args.unshift(parsed.file);
|
|
347
|
+
parsed.command = shebang;
|
|
348
|
+
return resolveCommand(parsed);
|
|
349
|
+
}
|
|
350
|
+
return parsed.file;
|
|
351
|
+
}
|
|
352
|
+
function parseNonShell(parsed) {
|
|
353
|
+
if (!isWin) {
|
|
354
|
+
return parsed;
|
|
355
|
+
}
|
|
356
|
+
const commandFile = detectShebang(parsed);
|
|
357
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
358
|
+
if (parsed.options.forceShell || needsShell) {
|
|
359
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
360
|
+
parsed.command = path.normalize(parsed.command);
|
|
361
|
+
parsed.command = escape.command(parsed.command);
|
|
362
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
363
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
364
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
365
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
366
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
367
|
+
}
|
|
368
|
+
return parsed;
|
|
369
|
+
}
|
|
370
|
+
function parse(command, args, options) {
|
|
371
|
+
if (args && !Array.isArray(args)) {
|
|
372
|
+
options = args;
|
|
373
|
+
args = null;
|
|
374
|
+
}
|
|
375
|
+
args = args ? args.slice(0) : [];
|
|
376
|
+
options = Object.assign({}, options);
|
|
377
|
+
const parsed = {
|
|
378
|
+
command,
|
|
379
|
+
args,
|
|
380
|
+
options,
|
|
381
|
+
file: undefined,
|
|
382
|
+
original: {
|
|
383
|
+
command,
|
|
384
|
+
args
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
388
|
+
}
|
|
389
|
+
module.exports = parse;
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// node_modules/cross-spawn/lib/enoent.js
|
|
393
|
+
var require_enoent = __commonJS((exports, module) => {
|
|
394
|
+
var isWin = process.platform === "win32";
|
|
395
|
+
function notFoundError(original, syscall) {
|
|
396
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
397
|
+
code: "ENOENT",
|
|
398
|
+
errno: "ENOENT",
|
|
399
|
+
syscall: `${syscall} ${original.command}`,
|
|
400
|
+
path: original.command,
|
|
401
|
+
spawnargs: original.args
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
function hookChildProcess(cp, parsed) {
|
|
405
|
+
if (!isWin) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const originalEmit = cp.emit;
|
|
409
|
+
cp.emit = function(name, arg1) {
|
|
410
|
+
if (name === "exit") {
|
|
411
|
+
const err = verifyENOENT(arg1, parsed);
|
|
412
|
+
if (err) {
|
|
413
|
+
return originalEmit.call(cp, "error", err);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return originalEmit.apply(cp, arguments);
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function verifyENOENT(status, parsed) {
|
|
420
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
421
|
+
return notFoundError(parsed.original, "spawn");
|
|
422
|
+
}
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
function verifyENOENTSync(status, parsed) {
|
|
426
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
427
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
428
|
+
}
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
module.exports = {
|
|
432
|
+
hookChildProcess,
|
|
433
|
+
verifyENOENT,
|
|
434
|
+
verifyENOENTSync,
|
|
435
|
+
notFoundError
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
// node_modules/cross-spawn/index.js
|
|
440
|
+
var require_cross_spawn = __commonJS((exports, module) => {
|
|
441
|
+
var cp = __require("child_process");
|
|
442
|
+
var parse = require_parse();
|
|
443
|
+
var enoent = require_enoent();
|
|
444
|
+
function spawn(command, args, options) {
|
|
445
|
+
const parsed = parse(command, args, options);
|
|
446
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
447
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
448
|
+
return spawned;
|
|
449
|
+
}
|
|
450
|
+
function spawnSync(command, args, options) {
|
|
451
|
+
const parsed = parse(command, args, options);
|
|
452
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
453
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
454
|
+
return result;
|
|
455
|
+
}
|
|
456
|
+
module.exports = spawn;
|
|
457
|
+
module.exports.spawn = spawn;
|
|
458
|
+
module.exports.sync = spawnSync;
|
|
459
|
+
module.exports._parse = parse;
|
|
460
|
+
module.exports._enoent = enoent;
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// src/proxy/setup.ts
|
|
464
|
+
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
465
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
466
|
+
import { homedir, platform } from "os";
|
|
467
|
+
import { basename, dirname, join } from "path";
|
|
468
|
+
import { fileURLToPath } from "url";
|
|
469
|
+
import { applyEdits, modify, parse as parseJsonc } from "jsonc-parser";
|
|
470
|
+
|
|
471
|
+
// src/utils/lruMap.ts
|
|
472
|
+
class LRUMap {
|
|
473
|
+
maxSize;
|
|
474
|
+
onEvict;
|
|
475
|
+
map = new Map;
|
|
476
|
+
constructor(maxSize, onEvict) {
|
|
477
|
+
this.maxSize = maxSize;
|
|
478
|
+
this.onEvict = onEvict;
|
|
479
|
+
}
|
|
480
|
+
get size() {
|
|
481
|
+
return this.map.size;
|
|
482
|
+
}
|
|
483
|
+
get(key) {
|
|
484
|
+
const value = this.map.get(key);
|
|
485
|
+
if (value === undefined)
|
|
486
|
+
return;
|
|
487
|
+
this.map.delete(key);
|
|
488
|
+
this.map.set(key, value);
|
|
489
|
+
return value;
|
|
490
|
+
}
|
|
491
|
+
set(key, value) {
|
|
492
|
+
if (this.map.has(key)) {
|
|
493
|
+
this.map.delete(key);
|
|
494
|
+
} else if (this.map.size >= this.maxSize) {
|
|
495
|
+
this.evictOldest();
|
|
496
|
+
}
|
|
497
|
+
this.map.set(key, value);
|
|
498
|
+
return this;
|
|
499
|
+
}
|
|
500
|
+
has(key) {
|
|
501
|
+
return this.map.has(key);
|
|
502
|
+
}
|
|
503
|
+
delete(key) {
|
|
504
|
+
return this.map.delete(key);
|
|
505
|
+
}
|
|
506
|
+
clear() {
|
|
507
|
+
this.map.clear();
|
|
508
|
+
}
|
|
509
|
+
entries() {
|
|
510
|
+
return this.map.entries();
|
|
511
|
+
}
|
|
512
|
+
keys() {
|
|
513
|
+
return this.map.keys();
|
|
514
|
+
}
|
|
515
|
+
values() {
|
|
516
|
+
return this.map.values();
|
|
517
|
+
}
|
|
518
|
+
forEach(callbackfn) {
|
|
519
|
+
this.map.forEach((value, key) => callbackfn(value, key, this));
|
|
520
|
+
}
|
|
521
|
+
[Symbol.iterator]() {
|
|
522
|
+
return this.map[Symbol.iterator]();
|
|
523
|
+
}
|
|
524
|
+
evictOldest() {
|
|
525
|
+
const oldestKey = this.map.keys().next().value;
|
|
526
|
+
if (oldestKey === undefined)
|
|
527
|
+
return;
|
|
528
|
+
const oldestValue = this.map.get(oldestKey);
|
|
529
|
+
if (oldestValue === undefined)
|
|
530
|
+
return;
|
|
531
|
+
this.map.delete(oldestKey);
|
|
532
|
+
this.onEvict?.(oldestKey, oldestValue);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// src/proxy/setup.ts
|
|
537
|
+
class UnparseableConfigError extends Error {
|
|
538
|
+
configPath;
|
|
539
|
+
constructor(configPath) {
|
|
540
|
+
super(`Could not parse ${configPath} — it may contain a syntax error.`);
|
|
541
|
+
this.configPath = configPath;
|
|
542
|
+
this.name = "UnparseableConfigError";
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
class MissingV2PluginError extends Error {
|
|
547
|
+
expectedPath;
|
|
548
|
+
constructor(expectedPath) {
|
|
549
|
+
super(`OpenCode V2 plugin bundle not found at ${expectedPath}`);
|
|
550
|
+
this.expectedPath = expectedPath;
|
|
551
|
+
this.name = "MissingV2PluginError";
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
class DuplicateMeridianConfigError extends Error {
|
|
556
|
+
configPath;
|
|
557
|
+
siblingPath;
|
|
558
|
+
constructor(configPath, siblingPath) {
|
|
559
|
+
super(`A Meridian entry in ${siblingPath} conflicts with setup target ${configPath}`);
|
|
560
|
+
this.configPath = configPath;
|
|
561
|
+
this.siblingPath = siblingPath;
|
|
562
|
+
this.name = "DuplicateMeridianConfigError";
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
function parseOpencodeConfig(text) {
|
|
566
|
+
const errors = [];
|
|
567
|
+
const parsed = parseJsonc(text, errors, { allowTrailingComma: true });
|
|
568
|
+
if (errors.length > 0 || parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
569
|
+
return null;
|
|
570
|
+
}
|
|
571
|
+
return parsed;
|
|
572
|
+
}
|
|
573
|
+
function opencodeConfigDirectory() {
|
|
574
|
+
if (process.env.OPENCODE_CONFIG_DIR)
|
|
575
|
+
return process.env.OPENCODE_CONFIG_DIR;
|
|
576
|
+
if (process.env.XDG_CONFIG_HOME)
|
|
577
|
+
return join(process.env.XDG_CONFIG_HOME, "opencode");
|
|
578
|
+
if (platform() === "win32" && process.env.APPDATA)
|
|
579
|
+
return join(process.env.APPDATA, "opencode");
|
|
580
|
+
return join(homedir(), ".config", "opencode");
|
|
581
|
+
}
|
|
582
|
+
function findOpencodeConfigPath() {
|
|
583
|
+
const dir = opencodeConfigDirectory();
|
|
584
|
+
const jsonPath = join(dir, "opencode.json");
|
|
585
|
+
const jsoncPath = join(dir, "opencode.jsonc");
|
|
586
|
+
return !existsSync(jsonPath) && existsSync(jsoncPath) ? jsoncPath : jsonPath;
|
|
587
|
+
}
|
|
588
|
+
function siblingOpencodeConfigPath(configPath) {
|
|
589
|
+
const name = basename(configPath);
|
|
590
|
+
if (name === "opencode.json")
|
|
591
|
+
return join(dirname(configPath), "opencode.jsonc");
|
|
592
|
+
if (name === "opencode.jsonc")
|
|
593
|
+
return join(dirname(configPath), "opencode.json");
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
function findPluginPath(fromUrl) {
|
|
597
|
+
const dir = dirname(fileURLToPath(fromUrl));
|
|
598
|
+
return join(dir, "..", "plugin", "meridian.ts");
|
|
599
|
+
}
|
|
600
|
+
var SUPPORTED_OPENCODE_V2_VERSION = "0.0.0-beta-18314";
|
|
601
|
+
function findV2PluginPath(fromUrl) {
|
|
602
|
+
const entryPath = fileURLToPath(fromUrl);
|
|
603
|
+
const dir = dirname(entryPath);
|
|
604
|
+
if (entryPath.endsWith(".ts")) {
|
|
605
|
+
const sourcePlugin = join(dir, "..", "plugin", "meridian-v2.ts");
|
|
606
|
+
if (existsSync(sourcePlugin))
|
|
607
|
+
return sourcePlugin;
|
|
608
|
+
throw new MissingV2PluginError(sourcePlugin);
|
|
609
|
+
}
|
|
610
|
+
const bundledPlugin = join(dir, "meridian-v2.js");
|
|
611
|
+
if (existsSync(bundledPlugin))
|
|
612
|
+
return bundledPlugin;
|
|
613
|
+
throw new MissingV2PluginError(bundledPlugin);
|
|
614
|
+
}
|
|
615
|
+
function classifyOpenCodeVersion(output) {
|
|
616
|
+
const match = output.trim().match(/^(?:opencode2?\s+)?v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/i);
|
|
617
|
+
const version = match?.[1];
|
|
618
|
+
if (!version)
|
|
619
|
+
return;
|
|
620
|
+
const major = Number(version.split(".", 1)[0]);
|
|
621
|
+
return {
|
|
622
|
+
generation: major === 1 ? "v1" : "v2",
|
|
623
|
+
version
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function detectOpenCodeGeneration(commands = process.env.OPENCODE_BIN ? [process.env.OPENCODE_BIN] : ["opencode", "opencode2"], probe = (command) => {
|
|
627
|
+
const result = import_cross_spawn.default.sync(command, ["--version"], {
|
|
628
|
+
encoding: "utf8",
|
|
629
|
+
timeout: 3000,
|
|
630
|
+
windowsHide: true
|
|
631
|
+
});
|
|
632
|
+
if (result.error || result.status !== 0)
|
|
633
|
+
return;
|
|
634
|
+
return String(result.stdout ?? "");
|
|
635
|
+
}) {
|
|
636
|
+
for (const command of commands) {
|
|
637
|
+
const output = probe(command);
|
|
638
|
+
if (!output)
|
|
639
|
+
continue;
|
|
640
|
+
const detected = classifyOpenCodeVersion(output);
|
|
641
|
+
if (detected)
|
|
642
|
+
return { ...detected, command };
|
|
643
|
+
}
|
|
644
|
+
return { generation: "v1" };
|
|
645
|
+
}
|
|
646
|
+
function pluginPathForGeneration(fromUrl, generation) {
|
|
647
|
+
return generation === "v2" ? findV2PluginPath(fromUrl) : findPluginPath(fromUrl);
|
|
648
|
+
}
|
|
649
|
+
var STALE_PATTERNS = [
|
|
650
|
+
"opencode-claude-max-proxy",
|
|
651
|
+
"claude-max-headers",
|
|
652
|
+
"meridian-agent-mode"
|
|
653
|
+
];
|
|
654
|
+
function pluginEntryPackage(entry) {
|
|
655
|
+
if (typeof entry === "string")
|
|
656
|
+
return entry;
|
|
657
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry))
|
|
658
|
+
return;
|
|
659
|
+
const packageName = Reflect.get(entry, "package");
|
|
660
|
+
return typeof packageName === "string" ? packageName : undefined;
|
|
661
|
+
}
|
|
662
|
+
function isMeridianEntry(entry) {
|
|
663
|
+
const packageName = pluginEntryPackage(entry);
|
|
664
|
+
if (!packageName)
|
|
665
|
+
return false;
|
|
666
|
+
return STALE_PATTERNS.some((pattern) => packageName.includes(pattern)) || packageName.includes("meridian.ts") || packageName.includes("meridian-v2.") || packageName.includes("@rynfar/meridian");
|
|
667
|
+
}
|
|
668
|
+
function checkPluginConfigured(configPath, expectedPluginPath) {
|
|
669
|
+
const selectedPath = configPath ?? findOpencodeConfigPath();
|
|
670
|
+
const siblingPath = configPath ? undefined : siblingOpencodeConfigPath(selectedPath);
|
|
671
|
+
const paths = siblingPath ? [selectedPath, siblingPath] : [selectedPath];
|
|
672
|
+
return paths.some((path) => {
|
|
673
|
+
if (!existsSync(path))
|
|
674
|
+
return false;
|
|
675
|
+
const config = parseOpencodeConfig(readFileSync(path, "utf-8"));
|
|
676
|
+
if (config === null)
|
|
677
|
+
return false;
|
|
678
|
+
const plugins = [
|
|
679
|
+
...Array.isArray(config.plugin) ? config.plugin : [],
|
|
680
|
+
...Array.isArray(config.plugins) ? config.plugins : []
|
|
681
|
+
];
|
|
682
|
+
if (expectedPluginPath)
|
|
683
|
+
return plugins.some((entry) => pluginEntryPackage(entry) === expectedPluginPath);
|
|
684
|
+
return plugins.some(isMeridianEntry);
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
var pluginlessWarned = new LRUMap(256);
|
|
688
|
+
function clearPluginlessWarnings() {
|
|
689
|
+
pluginlessWarned.clear();
|
|
690
|
+
}
|
|
691
|
+
function notePluginlessOpenCodeRequest(input) {
|
|
692
|
+
if (!input.userAgent?.toLowerCase().startsWith("opencode/"))
|
|
693
|
+
return;
|
|
694
|
+
if (input.agentModeHeader)
|
|
695
|
+
return;
|
|
696
|
+
const key = input.sessionId || "(keyless)";
|
|
697
|
+
if (pluginlessWarned.get(key))
|
|
698
|
+
return;
|
|
699
|
+
pluginlessWarned.set(key, true);
|
|
700
|
+
const shortId = input.sessionId ? `${input.sessionId.slice(0, 12)}…` : "(no session header)";
|
|
701
|
+
return `OpenCode request without the Meridian plugin's agent headers (session ${shortId}). ` + `OpenCode runs its internal title/summary agents under your session id, so Meridian ` + `cannot tell them apart from your conversation: the first turn of each session can fail ` + `with a 400 or replay against a cold cache. Fix: meridian setup (or update the plugin).`;
|
|
702
|
+
}
|
|
703
|
+
function runSetup(pluginPath, configPath, generation = "v1") {
|
|
704
|
+
const path = configPath ?? findOpencodeConfigPath();
|
|
705
|
+
const dir = dirname(path);
|
|
706
|
+
const targetField = generation === "v2" ? "plugins" : "plugin";
|
|
707
|
+
const otherField = generation === "v2" ? "plugin" : "plugins";
|
|
708
|
+
const siblingPath = siblingOpencodeConfigPath(path);
|
|
709
|
+
if (siblingPath && existsSync(siblingPath)) {
|
|
710
|
+
const siblingConfig = parseOpencodeConfig(readFileSync(siblingPath, "utf-8"));
|
|
711
|
+
if (siblingConfig === null)
|
|
712
|
+
throw new UnparseableConfigError(siblingPath);
|
|
713
|
+
const siblingPlugins = [
|
|
714
|
+
...Array.isArray(siblingConfig.plugin) ? siblingConfig.plugin : [],
|
|
715
|
+
...Array.isArray(siblingConfig.plugins) ? siblingConfig.plugins : []
|
|
716
|
+
];
|
|
717
|
+
if (siblingPlugins.some(isMeridianEntry)) {
|
|
718
|
+
throw new DuplicateMeridianConfigError(path, siblingPath);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (!existsSync(path)) {
|
|
722
|
+
if (!existsSync(dir))
|
|
723
|
+
mkdirSync(dir, { recursive: true });
|
|
724
|
+
writeFileSync(path, `${JSON.stringify({ [targetField]: [pluginPath] }, null, 2)}
|
|
725
|
+
`, "utf-8");
|
|
726
|
+
return { configPath: path, pluginPath, alreadyConfigured: false, removedStale: [], created: true };
|
|
727
|
+
}
|
|
728
|
+
const text = readFileSync(path, "utf-8");
|
|
729
|
+
const config = parseOpencodeConfig(text);
|
|
730
|
+
if (config === null) {
|
|
731
|
+
throw new UnparseableConfigError(path);
|
|
732
|
+
}
|
|
733
|
+
const entries = (field) => Array.isArray(config[field]) ? config[field] : [];
|
|
734
|
+
const targetEntries = entries(targetField);
|
|
735
|
+
const otherEntries = entries(otherField);
|
|
736
|
+
const targetMeridian = targetEntries.filter(isMeridianEntry);
|
|
737
|
+
const otherMeridian = otherEntries.filter(isMeridianEntry);
|
|
738
|
+
const targetExact = targetMeridian.filter((entry) => pluginEntryPackage(entry) === pluginPath);
|
|
739
|
+
const removedStale = [...targetMeridian, ...otherMeridian].flatMap((entry) => {
|
|
740
|
+
const packageName = pluginEntryPackage(entry);
|
|
741
|
+
return packageName ? [packageName] : [];
|
|
742
|
+
});
|
|
743
|
+
const alreadyConfigured = targetMeridian.length === 1 && targetExact.length === 1 && otherMeridian.length === 0;
|
|
744
|
+
const targetPlugin = targetExact.length === 1 && targetMeridian.length === 1 ? targetExact[0] : pluginPath;
|
|
745
|
+
const targetPlugins = [
|
|
746
|
+
...targetEntries.filter((entry) => !isMeridianEntry(entry)),
|
|
747
|
+
targetPlugin
|
|
748
|
+
];
|
|
749
|
+
const otherPlugins = otherEntries.filter((entry) => !isMeridianEntry(entry));
|
|
750
|
+
let updated = text;
|
|
751
|
+
const formattingOptions = { insertSpaces: true, tabSize: 2 };
|
|
752
|
+
updated = applyEdits(updated, modify(updated, [targetField], targetPlugins, { formattingOptions }));
|
|
753
|
+
if (Array.isArray(config[otherField]) && otherMeridian.length > 0) {
|
|
754
|
+
updated = applyEdits(updated, modify(updated, [otherField], otherPlugins, { formattingOptions }));
|
|
755
|
+
}
|
|
756
|
+
writeFileSync(path, updated, "utf-8");
|
|
757
|
+
return { configPath: path, pluginPath, alreadyConfigured, removedStale, created: false };
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export { LRUMap, UnparseableConfigError, MissingV2PluginError, DuplicateMeridianConfigError, findOpencodeConfigPath, findPluginPath, SUPPORTED_OPENCODE_V2_VERSION, findV2PluginPath, classifyOpenCodeVersion, detectOpenCodeGeneration, pluginPathForGeneration, checkPluginConfigured, clearPluginlessWarnings, notePluginlessOpenCodeRequest, runSetup };
|