opencode-immune 1.0.62 → 1.0.64

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.
@@ -1,532 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- // node_modules/isexe/windows.js
34
- var require_windows = __commonJS({
35
- "node_modules/isexe/windows.js"(exports, module) {
36
- module.exports = isexe;
37
- isexe.sync = sync;
38
- var fs = __require("fs");
39
- function checkPathExt(path, options) {
40
- var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
41
- if (!pathext) {
42
- return true;
43
- }
44
- pathext = pathext.split(";");
45
- if (pathext.indexOf("") !== -1) {
46
- return true;
47
- }
48
- for (var i = 0; i < pathext.length; i++) {
49
- var p = pathext[i].toLowerCase();
50
- if (p && path.substr(-p.length).toLowerCase() === p) {
51
- return true;
52
- }
53
- }
54
- return false;
55
- }
56
- function checkStat(stat2, path, options) {
57
- if (!stat2.isSymbolicLink() && !stat2.isFile()) {
58
- return false;
59
- }
60
- return checkPathExt(path, options);
61
- }
62
- function isexe(path, options, cb) {
63
- fs.stat(path, function(er, stat2) {
64
- cb(er, er ? false : checkStat(stat2, path, options));
65
- });
66
- }
67
- function sync(path, options) {
68
- return checkStat(fs.statSync(path), path, options);
69
- }
70
- }
71
- });
72
-
73
- // node_modules/isexe/mode.js
74
- var require_mode = __commonJS({
75
- "node_modules/isexe/mode.js"(exports, module) {
76
- module.exports = isexe;
77
- isexe.sync = sync;
78
- var fs = __require("fs");
79
- function isexe(path, options, cb) {
80
- fs.stat(path, function(er, stat2) {
81
- cb(er, er ? false : checkStat(stat2, options));
82
- });
83
- }
84
- function sync(path, options) {
85
- return checkStat(fs.statSync(path), options);
86
- }
87
- function checkStat(stat2, options) {
88
- return stat2.isFile() && checkMode(stat2, options);
89
- }
90
- function checkMode(stat2, options) {
91
- var mod = stat2.mode;
92
- var uid = stat2.uid;
93
- var gid = stat2.gid;
94
- var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
95
- var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
96
- var u = parseInt("100", 8);
97
- var g = parseInt("010", 8);
98
- var o = parseInt("001", 8);
99
- var ug = u | g;
100
- var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
101
- return ret;
102
- }
103
- }
104
- });
105
-
106
- // node_modules/isexe/index.js
107
- var require_isexe = __commonJS({
108
- "node_modules/isexe/index.js"(exports, module) {
109
- var fs = __require("fs");
110
- var core;
111
- if (process.platform === "win32" || global.TESTING_WINDOWS) {
112
- core = require_windows();
113
- } else {
114
- core = require_mode();
115
- }
116
- module.exports = isexe;
117
- isexe.sync = sync;
118
- function isexe(path, options, cb) {
119
- if (typeof options === "function") {
120
- cb = options;
121
- options = {};
122
- }
123
- if (!cb) {
124
- if (typeof Promise !== "function") {
125
- throw new TypeError("callback not provided");
126
- }
127
- return new Promise(function(resolve, reject) {
128
- isexe(path, options || {}, function(er, is) {
129
- if (er) {
130
- reject(er);
131
- } else {
132
- resolve(is);
133
- }
134
- });
135
- });
136
- }
137
- core(path, options || {}, function(er, is) {
138
- if (er) {
139
- if (er.code === "EACCES" || options && options.ignoreErrors) {
140
- er = null;
141
- is = false;
142
- }
143
- }
144
- cb(er, is);
145
- });
146
- }
147
- function sync(path, options) {
148
- try {
149
- return core.sync(path, options || {});
150
- } catch (er) {
151
- if (options && options.ignoreErrors || er.code === "EACCES") {
152
- return false;
153
- } else {
154
- throw er;
155
- }
156
- }
157
- }
158
- }
159
- });
160
-
161
- // node_modules/which/which.js
162
- var require_which = __commonJS({
163
- "node_modules/which/which.js"(exports, module) {
164
- var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
165
- var path = __require("path");
166
- var COLON = isWindows ? ";" : ":";
167
- var isexe = require_isexe();
168
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
169
- var getPathInfo = (cmd, opt) => {
170
- const colon = opt.colon || COLON;
171
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
172
- // windows always checks the cwd first
173
- ...isWindows ? [process.cwd()] : [],
174
- ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
175
- "").split(colon)
176
- ];
177
- const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
178
- const pathExt = isWindows ? pathExtExe.split(colon) : [""];
179
- if (isWindows) {
180
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
181
- pathExt.unshift("");
182
- }
183
- return {
184
- pathEnv,
185
- pathExt,
186
- pathExtExe
187
- };
188
- };
189
- var which = (cmd, opt, cb) => {
190
- if (typeof opt === "function") {
191
- cb = opt;
192
- opt = {};
193
- }
194
- if (!opt)
195
- opt = {};
196
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
197
- const found = [];
198
- const step = (i) => new Promise((resolve, reject) => {
199
- if (i === pathEnv.length)
200
- return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
201
- const ppRaw = pathEnv[i];
202
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
203
- const pCmd = path.join(pathPart, cmd);
204
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
205
- resolve(subStep(p, i, 0));
206
- });
207
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
208
- if (ii === pathExt.length)
209
- return resolve(step(i + 1));
210
- const ext = pathExt[ii];
211
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
212
- if (!er && is) {
213
- if (opt.all)
214
- found.push(p + ext);
215
- else
216
- return resolve(p + ext);
217
- }
218
- return resolve(subStep(p, i, ii + 1));
219
- });
220
- });
221
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
222
- };
223
- var whichSync = (cmd, opt) => {
224
- opt = opt || {};
225
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
226
- const found = [];
227
- for (let i = 0; i < pathEnv.length; i++) {
228
- const ppRaw = pathEnv[i];
229
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
230
- const pCmd = path.join(pathPart, cmd);
231
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
232
- for (let j = 0; j < pathExt.length; j++) {
233
- const cur = p + pathExt[j];
234
- try {
235
- const is = isexe.sync(cur, { pathExt: pathExtExe });
236
- if (is) {
237
- if (opt.all)
238
- found.push(cur);
239
- else
240
- return cur;
241
- }
242
- } catch (ex) {
243
- }
244
- }
245
- }
246
- if (opt.all && found.length)
247
- return found;
248
- if (opt.nothrow)
249
- return null;
250
- throw getNotFoundError(cmd);
251
- };
252
- module.exports = which;
253
- which.sync = whichSync;
254
- }
255
- });
256
-
257
- // node_modules/path-key/index.js
258
- var require_path_key = __commonJS({
259
- "node_modules/path-key/index.js"(exports, module) {
260
- "use strict";
261
- var pathKey = (options = {}) => {
262
- const environment = options.env || process.env;
263
- const platform = options.platform || process.platform;
264
- if (platform !== "win32") {
265
- return "PATH";
266
- }
267
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
268
- };
269
- module.exports = pathKey;
270
- module.exports.default = pathKey;
271
- }
272
- });
273
-
274
- // node_modules/cross-spawn/lib/util/resolveCommand.js
275
- var require_resolveCommand = __commonJS({
276
- "node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
277
- "use strict";
278
- var path = __require("path");
279
- var which = require_which();
280
- var getPathKey = require_path_key();
281
- function resolveCommandAttempt(parsed, withoutPathExt) {
282
- const env = parsed.options.env || process.env;
283
- const cwd = process.cwd();
284
- const hasCustomCwd = parsed.options.cwd != null;
285
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
286
- if (shouldSwitchCwd) {
287
- try {
288
- process.chdir(parsed.options.cwd);
289
- } catch (err) {
290
- }
291
- }
292
- let resolved;
293
- try {
294
- resolved = which.sync(parsed.command, {
295
- path: env[getPathKey({ env })],
296
- pathExt: withoutPathExt ? path.delimiter : void 0
297
- });
298
- } catch (e) {
299
- } finally {
300
- if (shouldSwitchCwd) {
301
- process.chdir(cwd);
302
- }
303
- }
304
- if (resolved) {
305
- resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
306
- }
307
- return resolved;
308
- }
309
- function resolveCommand(parsed) {
310
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
311
- }
312
- module.exports = resolveCommand;
313
- }
314
- });
315
-
316
- // node_modules/cross-spawn/lib/util/escape.js
317
- var require_escape = __commonJS({
318
- "node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
319
- "use strict";
320
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
321
- function escapeCommand(arg) {
322
- arg = arg.replace(metaCharsRegExp, "^$1");
323
- return arg;
324
- }
325
- function escapeArgument(arg, doubleEscapeMetaChars) {
326
- arg = `${arg}`;
327
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
328
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
329
- arg = `"${arg}"`;
330
- arg = arg.replace(metaCharsRegExp, "^$1");
331
- if (doubleEscapeMetaChars) {
332
- arg = arg.replace(metaCharsRegExp, "^$1");
333
- }
334
- return arg;
335
- }
336
- module.exports.command = escapeCommand;
337
- module.exports.argument = escapeArgument;
338
- }
339
- });
340
-
341
- // node_modules/shebang-regex/index.js
342
- var require_shebang_regex = __commonJS({
343
- "node_modules/shebang-regex/index.js"(exports, module) {
344
- "use strict";
345
- module.exports = /^#!(.*)/;
346
- }
347
- });
348
-
349
- // node_modules/shebang-command/index.js
350
- var require_shebang_command = __commonJS({
351
- "node_modules/shebang-command/index.js"(exports, module) {
352
- "use strict";
353
- var shebangRegex = require_shebang_regex();
354
- module.exports = (string = "") => {
355
- const match = string.match(shebangRegex);
356
- if (!match) {
357
- return null;
358
- }
359
- const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
360
- const binary = path.split("/").pop();
361
- if (binary === "env") {
362
- return argument;
363
- }
364
- return argument ? `${binary} ${argument}` : binary;
365
- };
366
- }
367
- });
368
-
369
- // node_modules/cross-spawn/lib/util/readShebang.js
370
- var require_readShebang = __commonJS({
371
- "node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
372
- "use strict";
373
- var fs = __require("fs");
374
- var shebangCommand = require_shebang_command();
375
- function readShebang(command) {
376
- const size = 150;
377
- const buffer = Buffer.alloc(size);
378
- let fd;
379
- try {
380
- fd = fs.openSync(command, "r");
381
- fs.readSync(fd, buffer, 0, size, 0);
382
- fs.closeSync(fd);
383
- } catch (e) {
384
- }
385
- return shebangCommand(buffer.toString());
386
- }
387
- module.exports = readShebang;
388
- }
389
- });
390
-
391
- // node_modules/cross-spawn/lib/parse.js
392
- var require_parse = __commonJS({
393
- "node_modules/cross-spawn/lib/parse.js"(exports, module) {
394
- "use strict";
395
- var path = __require("path");
396
- var resolveCommand = require_resolveCommand();
397
- var escape = require_escape();
398
- var readShebang = require_readShebang();
399
- var isWin = process.platform === "win32";
400
- var isExecutableRegExp = /\.(?:com|exe)$/i;
401
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
402
- function detectShebang(parsed) {
403
- parsed.file = resolveCommand(parsed);
404
- const shebang = parsed.file && readShebang(parsed.file);
405
- if (shebang) {
406
- parsed.args.unshift(parsed.file);
407
- parsed.command = shebang;
408
- return resolveCommand(parsed);
409
- }
410
- return parsed.file;
411
- }
412
- function parseNonShell(parsed) {
413
- if (!isWin) {
414
- return parsed;
415
- }
416
- const commandFile = detectShebang(parsed);
417
- const needsShell = !isExecutableRegExp.test(commandFile);
418
- if (parsed.options.forceShell || needsShell) {
419
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
420
- parsed.command = path.normalize(parsed.command);
421
- parsed.command = escape.command(parsed.command);
422
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
423
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
424
- parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
425
- parsed.command = process.env.comspec || "cmd.exe";
426
- parsed.options.windowsVerbatimArguments = true;
427
- }
428
- return parsed;
429
- }
430
- function parse(command, args, options) {
431
- if (args && !Array.isArray(args)) {
432
- options = args;
433
- args = null;
434
- }
435
- args = args ? args.slice(0) : [];
436
- options = Object.assign({}, options);
437
- const parsed = {
438
- command,
439
- args,
440
- options,
441
- file: void 0,
442
- original: {
443
- command,
444
- args
445
- }
446
- };
447
- return options.shell ? parsed : parseNonShell(parsed);
448
- }
449
- module.exports = parse;
450
- }
451
- });
452
-
453
- // node_modules/cross-spawn/lib/enoent.js
454
- var require_enoent = __commonJS({
455
- "node_modules/cross-spawn/lib/enoent.js"(exports, module) {
456
- "use strict";
457
- var isWin = process.platform === "win32";
458
- function notFoundError(original, syscall) {
459
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
460
- code: "ENOENT",
461
- errno: "ENOENT",
462
- syscall: `${syscall} ${original.command}`,
463
- path: original.command,
464
- spawnargs: original.args
465
- });
466
- }
467
- function hookChildProcess(cp, parsed) {
468
- if (!isWin) {
469
- return;
470
- }
471
- const originalEmit = cp.emit;
472
- cp.emit = function(name, arg1) {
473
- if (name === "exit") {
474
- const err = verifyENOENT(arg1, parsed);
475
- if (err) {
476
- return originalEmit.call(cp, "error", err);
477
- }
478
- }
479
- return originalEmit.apply(cp, arguments);
480
- };
481
- }
482
- function verifyENOENT(status, parsed) {
483
- if (isWin && status === 1 && !parsed.file) {
484
- return notFoundError(parsed.original, "spawn");
485
- }
486
- return null;
487
- }
488
- function verifyENOENTSync(status, parsed) {
489
- if (isWin && status === 1 && !parsed.file) {
490
- return notFoundError(parsed.original, "spawnSync");
491
- }
492
- return null;
493
- }
494
- module.exports = {
495
- hookChildProcess,
496
- verifyENOENT,
497
- verifyENOENTSync,
498
- notFoundError
499
- };
500
- }
501
- });
502
-
503
- // node_modules/cross-spawn/index.js
504
- var require_cross_spawn = __commonJS({
505
- "node_modules/cross-spawn/index.js"(exports, module) {
506
- "use strict";
507
- var cp = __require("child_process");
508
- var parse = require_parse();
509
- var enoent = require_enoent();
510
- function spawn(command, args, options) {
511
- const parsed = parse(command, args, options);
512
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
513
- enoent.hookChildProcess(spawned, parsed);
514
- return spawned;
515
- }
516
- function spawnSync(command, args, options) {
517
- const parsed = parse(command, args, options);
518
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
519
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
520
- return result;
521
- }
522
- module.exports = spawn;
523
- module.exports.spawn = spawn;
524
- module.exports.sync = spawnSync;
525
- module.exports._parse = parse;
526
- module.exports._enoent = enoent;
527
- }
528
- });
529
-
530
1
  // node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
531
2
  var createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
532
3
  let lastEventId;
@@ -4299,9 +3770,6 @@ function createOpencodeClient(config) {
4299
3770
  return new OpencodeClient({ client: client2 });
4300
3771
  }
4301
3772
 
4302
- // node_modules/@opencode-ai/sdk/dist/v2/server.js
4303
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
4304
-
4305
3773
  // plugin.ts
4306
3774
  import { appendFile, mkdir, readFile, unlink, writeFile, stat, rm, rename, readdir, copyFile } from "fs/promises";
4307
3775
  import { join, dirname } from "path";
@@ -4309,7 +3777,7 @@ import { fileURLToPath } from "url";
4309
3777
  import { createHash } from "crypto";
4310
3778
  import { tmpdir } from "os";
4311
3779
  import { execFile } from "child_process";
4312
- var PLUGIN_VERSION = "1.0.59";
3780
+ var PLUGIN_VERSION = "1.0.64";
4313
3781
  var PLUGIN_PACKAGE_NAME = "opencode-immune";
4314
3782
  var PLUGIN_DIRNAME = dirname(fileURLToPath(import.meta.url));
4315
3783
  function getServerAuthHeaders() {
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
6
6
  "exports": {
7
- "./server": "./dist/plugin.js"
7
+ ".": "./dist/plugin/server.js",
8
+ "./server": "./dist/plugin/server.js"
8
9
  },
10
+ "main": "./dist/plugin/server.js",
9
11
  "files": [
10
- "dist/plugin.js"
12
+ "dist/plugin/server.js"
11
13
  ],
12
14
  "scripts": {
13
- "build": "esbuild plugin.ts --bundle --platform=node --format=esm --target=node22 --outfile=dist/plugin.js",
15
+ "build": "esbuild plugin.ts --bundle --platform=node --format=esm --target=node22 --outfile=dist/plugin/server.js",
14
16
  "dev": "node ./node_modules/typescript/bin/tsc --project tsconfig.json --watch",
15
17
  "prepublishOnly": "npm run build"
16
18
  },