@bman654/clodex 2.6.2 → 2.6.3

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/dist/cli.js CHANGED
@@ -374,7 +374,7 @@ import { join } from "path";
374
374
  // package.json
375
375
  var package_default = {
376
376
  name: "@bman654/clodex",
377
- version: "2.6.2",
377
+ version: "2.6.3",
378
378
  publishConfig: {
379
379
  access: "public"
380
380
  },
@@ -17061,7 +17061,7 @@ function collectPristineFacts(args) {
17061
17061
  }
17062
17062
 
17063
17063
  // src/patch-transforms.ts
17064
- var PATCH_TRANSFORMS_VERSION = 7;
17064
+ var PATCH_TRANSFORMS_VERSION = 8;
17065
17065
  var NATIVE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
17066
17066
  var BASE_EFFORT_LEVELS = ["low", "medium", "high"];
17067
17067
  function projectNativeEffort(effort) {
@@ -17374,11 +17374,87 @@ function applyClodexPatches(source, config) {
17374
17374
  '"OTEL_"',
17375
17375
  "CLAUDE_CODE_OTEL_DIAG_STDERR"
17376
17376
  ];
17377
+ const blockEndIndex = (text5, open2) => {
17378
+ const depths = [0];
17379
+ const templates = [false];
17380
+ for (let i = open2; i < text5.length; i++) {
17381
+ const ch = text5[i];
17382
+ const inTemplate = templates[templates.length - 1];
17383
+ if (inTemplate) {
17384
+ if (ch === "\\") {
17385
+ i++;
17386
+ continue;
17387
+ }
17388
+ if (ch === "`") {
17389
+ templates.pop();
17390
+ depths.pop();
17391
+ continue;
17392
+ }
17393
+ if (ch === "$" && text5[i + 1] === "{") {
17394
+ templates.push(false);
17395
+ depths.push(0);
17396
+ i++;
17397
+ }
17398
+ continue;
17399
+ }
17400
+ if (ch === "\\") {
17401
+ i++;
17402
+ continue;
17403
+ }
17404
+ if (ch === '"' || ch === "'") {
17405
+ const quote = ch;
17406
+ for (i++; i < text5.length; i++) {
17407
+ if (text5[i] === "\\") {
17408
+ i++;
17409
+ continue;
17410
+ }
17411
+ if (text5[i] === quote) break;
17412
+ }
17413
+ continue;
17414
+ }
17415
+ if (ch === "`") {
17416
+ templates.push(true);
17417
+ depths.push(0);
17418
+ continue;
17419
+ }
17420
+ if (ch === "/" && text5[i + 1] === "/") {
17421
+ while (i < text5.length && text5[i] !== "\n") i++;
17422
+ continue;
17423
+ }
17424
+ if (ch === "/" && text5[i + 1] === "*") {
17425
+ i = text5.indexOf("*/", i + 2);
17426
+ if (i < 0) return -1;
17427
+ i++;
17428
+ continue;
17429
+ }
17430
+ if (ch === "{") {
17431
+ depths[depths.length - 1]++;
17432
+ continue;
17433
+ }
17434
+ if (ch === "}") {
17435
+ if (depths[depths.length - 1] === 0 && templates.length > 1) {
17436
+ templates.pop();
17437
+ depths.pop();
17438
+ continue;
17439
+ }
17440
+ depths[depths.length - 1]--;
17441
+ if (depths.length === 1 && depths[0] === 0) return i;
17442
+ }
17443
+ }
17444
+ return -1;
17445
+ };
17446
+ const passthroughSites = source.includes(marker) ? 1 : (source.match(/\)return process\.env;let [\w$]+=\{/g) ?? []).length;
17447
+ if (passthroughSites !== 1) {
17448
+ log12("FAIL", patchName, "child env passthrough appears " + passthroughSites + " times (expected 1)");
17449
+ fail("clodex patch: required patch failed: " + patchName);
17450
+ }
17377
17451
  applyOnce(
17378
17452
  patchName,
17379
- /(function [\w$]+\(\)\{)(let [\w$]+=[\w$]+\(\),[\w$]+=Object\.keys\([\w$]+\)\.length>0,[^;{}]*?[\w$]+=[\w$]+\(process\.env\.CLAUDE_CODE_REMOTE\)\?(?:(?!\}\s*function )[\s\S])*?for\(let [\w$]+ of [\w$]+\)delete [\w$]+\[[\w$]+\],delete [\w$]+\[`INPUT_\$\{[\w$]+\}`\];return [\w$]+)(\})/,
17380
- (_match, head, body, tail) => {
17381
- const targetIsValid = requiredBodyLiterals.every((literal) => body.includes(literal)) && !/\bfunction\s*[\w$]*\(/.test(body);
17453
+ /(function [\w$]+\(\)\{)(let (?:[^;{}]|\{[^;{}]*\})*?[\w$]+\(process\.env\.CLAUDE_CODE_REMOTE\)\?(?:(?!\}\s*function )[\s\S])*?\)return process\.env;let ([\w$]+)=\{(?:(?!\}\s*function )[\s\S])*?return \3)(\})/,
17454
+ (match, head, body, _copyVar, tail) => {
17455
+ const at = js.indexOf(match);
17456
+ const bound = at < 0 ? -1 : blockEndIndex(js, at + head.length - 1) - at - (match.length - 1);
17457
+ const targetIsValid = requiredBodyLiterals.every((literal) => body.includes(literal)) && !/\bfunction\s*[\w$]*\(/.test(body) && bound === 0;
17382
17458
  if (!targetIsValid) {
17383
17459
  log12("FAIL", patchName, "target validation failed");
17384
17460
  fail("clodex patch: child network environment target validation failed");