@node9/proxy 2.47.0 → 2.47.2

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/index.mjs CHANGED
@@ -13,6 +13,15 @@ var __export = (target, all) => {
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
15
 
16
+ // node_modules/tsup/assets/esm_shims.js
17
+ import path from "path";
18
+ import { fileURLToPath } from "url";
19
+ var init_esm_shims = __esm({
20
+ "node_modules/tsup/assets/esm_shims.js"() {
21
+ "use strict";
22
+ }
23
+ });
24
+
16
25
  // src/audit/hasher.ts
17
26
  import { createHash } from "crypto";
18
27
  function canonicalise(value) {
@@ -44,6 +53,7 @@ function hashArgs(args) {
44
53
  var init_hasher = __esm({
45
54
  "src/audit/hasher.ts"() {
46
55
  "use strict";
56
+ init_esm_shims();
47
57
  }
48
58
  });
49
59
 
@@ -59,17 +69,17 @@ var als;
59
69
  var init_forecast_context = __esm({
60
70
  "src/auth/forecast-context.ts"() {
61
71
  "use strict";
72
+ init_esm_shims();
62
73
  als = new AsyncLocalStorage();
63
74
  }
64
75
  });
65
76
 
66
77
  // packages/policy-engine/dist/index.mjs
78
+ import { fileURLToPath as fileURLToPath2 } from "url";
67
79
  import picomatch from "picomatch";
68
80
  import safeRegex from "safe-regex2";
69
81
  import pm from "picomatch";
70
- import mvdanSh2 from "mvdan-sh";
71
- import mvdanSh from "mvdan-sh";
72
- import mvdanSh3 from "mvdan-sh";
82
+ import { createRequire } from "module";
73
83
  import safeRegex2 from "safe-regex2";
74
84
  import { createHash as createHash2 } from "crypto";
75
85
  import { createHash as createHash22 } from "crypto";
@@ -655,11 +665,29 @@ function resolveCheckMap(settings) {
655
665
  for (const c of CHECKS) out[c.id] = checkValue(settings, c.id);
656
666
  return out;
657
667
  }
668
+ function getSyntax() {
669
+ if (syntax === null) {
670
+ const req = createRequire(__filename2);
671
+ syntax = req("mvdan-sh").syntax;
672
+ }
673
+ return syntax;
674
+ }
675
+ function lazy(compute) {
676
+ let done = false;
677
+ let value;
678
+ return () => {
679
+ if (!done) {
680
+ value = compute();
681
+ done = true;
682
+ }
683
+ return value;
684
+ };
685
+ }
658
686
  function isGoNode(v) {
659
687
  return v !== null && typeof v === "object" && typeof v.Pos === "function";
660
688
  }
661
689
  function toPlainTree(goNode) {
662
- const kind = syntax.NodeType(goNode);
690
+ const kind = getSyntax().NodeType(goNode);
663
691
  const out = { kind, pos: goNode.Pos().Offset(), end: goNode.End().Offset() };
664
692
  const spec = KINDS[kind];
665
693
  if (!spec) {
@@ -849,12 +877,12 @@ function judgeInlineCode(language, code, isProtected) {
849
877
  category
850
878
  };
851
879
  }
852
- const path31 = protectedLiteral(text, isProtected);
853
- if (path31) {
880
+ const path210 = protectedLiteral(text, isProtected);
881
+ if (path210) {
854
882
  return {
855
883
  outcome: "dangerous",
856
884
  what: WHAT["reads-protected"],
857
- evidence: path31.slice(0, 60),
885
+ evidence: path210.slice(0, 60),
858
886
  category: "reads-protected"
859
887
  };
860
888
  }
@@ -890,7 +918,7 @@ function parseShared(command) {
890
918
  }
891
919
  let parsed;
892
920
  try {
893
- parsed = toPlainTree(sharedParser.Parse(command, "cmd"));
921
+ parsed = toPlainTree(sharedParser().Parse(command, "cmd"));
894
922
  } catch {
895
923
  parsed = PARSE_FAIL;
896
924
  }
@@ -1438,7 +1466,7 @@ function redirStdinOps() {
1438
1466
  }
1439
1467
  function deriveBinaryOp(sample) {
1440
1468
  try {
1441
- const f = toPlainTree(sharedParser.Parse(sample, "cmd"));
1469
+ const f = toPlainTree(sharedParser().Parse(sample, "cmd"));
1442
1470
  let op = -1;
1443
1471
  walk(f, (node) => {
1444
1472
  const n = node;
@@ -1882,7 +1910,7 @@ function recordTopLevelAssignments(f) {
1882
1910
  }
1883
1911
  function probeBinOp(src) {
1884
1912
  try {
1885
- const cmd = toPlainTree(syntax2.NewParser().Parse(src, "probe"))?.Stmts?.[0]?.Cmd;
1913
+ const cmd = toPlainTree(getSyntax().NewParser().Parse(src, "probe"))?.Stmts?.[0]?.Cmd;
1886
1914
  if (cmd && cmd.kind === "BinaryCmd") return cmd.Op;
1887
1915
  } catch {
1888
1916
  }
@@ -1892,9 +1920,9 @@ function recordTopLevelStmt(stmt) {
1892
1920
  if (!stmt || !stmt.Cmd) return false;
1893
1921
  const t = stmt.Cmd.kind;
1894
1922
  if (t === "BinaryCmd") {
1895
- if (!AND_OR_OPS.has(stmt.Cmd.Op)) return false;
1923
+ if (!andOrOps().AND_OR_OPS.has(stmt.Cmd.Op)) return false;
1896
1924
  if (!recordTopLevelStmt(stmt.Cmd.X)) return false;
1897
- if (stmt.Cmd.Op === AND_OP) return recordTopLevelStmt(stmt.Cmd.Y);
1925
+ if (stmt.Cmd.Op === andOrOps().AND_OP) return recordTopLevelStmt(stmt.Cmd.Y);
1898
1926
  return true;
1899
1927
  }
1900
1928
  if (t !== "CallExpr" && t !== "DeclClause") return false;
@@ -2345,7 +2373,7 @@ function isWaivableCleanupTarget(p) {
2345
2373
  }
2346
2374
  function deriveRedirOp(sample) {
2347
2375
  try {
2348
- const f = toPlainTree(sharedParser.Parse(sample, "cmd"));
2376
+ const f = toPlainTree(sharedParser().Parse(sample, "cmd"));
2349
2377
  let op = -1;
2350
2378
  walk(f, (node) => {
2351
2379
  const n = node;
@@ -2364,9 +2392,9 @@ function collectSameCommandCreations(f) {
2364
2392
  for (const stmt of stmts) {
2365
2393
  if (!stmt || !stmt.Cmd || stmt.Cmd.kind !== "CallExpr") continue;
2366
2394
  const redirs = stmt.Redirs || [];
2367
- if (!redirs.some((r) => r && REDIR_HEREDOC_OPS.has(r.Op))) continue;
2395
+ if (!redirs.some((r) => r && REDIR_HEREDOC_OPS().has(r.Op))) continue;
2368
2396
  for (const r of redirs) {
2369
- if (r && REDIR_TRUNCATE_OPS.has(r.Op) && r.N == null) {
2397
+ if (r && REDIR_TRUNCATE_OPS().has(r.Op) && r.N == null) {
2370
2398
  const w = resolveWordLiteral(r.Word);
2371
2399
  if (w) created.add(stripDotSlash(w));
2372
2400
  }
@@ -2936,7 +2964,7 @@ function literalShellPayload(words, name) {
2936
2964
  function jailedRedirectRead(stmt) {
2937
2965
  const redirs = stmt.Redirs || [];
2938
2966
  for (const r of redirs) {
2939
- if (!r || !REDIR_FILE_IN_OPS.has(r.Op)) continue;
2967
+ if (!r || !REDIR_FILE_IN_OPS().has(r.Op)) continue;
2940
2968
  const p = resolveWordLiteral(r.Word);
2941
2969
  if (p === null || p === "") continue;
2942
2970
  const hit = matchSensitivePath(p);
@@ -3018,9 +3046,9 @@ function ruleServerMatches(rule, serverLabel) {
3018
3046
  if (rule.notServer && label2 && matchesPattern(label2, rule.notServer)) return false;
3019
3047
  return true;
3020
3048
  }
3021
- function getNestedValue(obj, path31) {
3049
+ function getNestedValue(obj, path210) {
3022
3050
  if (!obj || typeof obj !== "object") return null;
3023
- const segments2 = path31.split(".");
3051
+ const segments2 = path210.split(".");
3024
3052
  for (const seg of segments2) {
3025
3053
  if (FORBIDDEN_PATH_SEGMENTS.has(seg)) return null;
3026
3054
  }
@@ -3232,7 +3260,7 @@ function runnablePrefix(command) {
3232
3260
  let text = command;
3233
3261
  for (let attempt = 0; attempt < 32; attempt++) {
3234
3262
  try {
3235
- return toPlainTree(syntax3.NewParser().Parse(text, ""));
3263
+ return toPlainTree(getSyntax().NewParser().Parse(text, ""));
3236
3264
  } catch (error) {
3237
3265
  const message = String(typeof error?.Error === "function" ? error.Error() : error?.message);
3238
3266
  const line = Number(/^(\d+):/.exec(message)?.[1]);
@@ -3277,7 +3305,7 @@ function wordValues(word, state) {
3277
3305
  const name = node.Param?.Value;
3278
3306
  const known = name === "PWD" ? state.cwd : state.vars.get(name);
3279
3307
  if (node.Exp) {
3280
- if (!DEFAULT_OPS.has(node.Exp.Op)) return null;
3308
+ if (!ops().DEFAULT_OPS.has(node.Exp.Op)) return null;
3281
3309
  if (known && known.length) return toWords(known, quoted);
3282
3310
  const fallback = expand(node.Exp.Word?.Parts ?? [], quoted);
3283
3311
  return fallback.dynamic ? null : fallback.out.map(asWord);
@@ -3802,7 +3830,7 @@ function collectShellFileAccesses(command, context = {}) {
3802
3830
  function stdinText(stmt) {
3803
3831
  for (const redir of stmt?.Redirs ?? []) {
3804
3832
  if (redir.Hdoc) return resolveWordLiteral(redir.Hdoc);
3805
- if (redir.Op === HERE_STRING) return resolveWordLiteral(redir.Word);
3833
+ if (redir.Op === ops().HERE_STRING) return resolveWordLiteral(redir.Word);
3806
3834
  }
3807
3835
  return null;
3808
3836
  }
@@ -3832,10 +3860,10 @@ function collectShellFileAccesses(command, context = {}) {
3832
3860
  for (const redir of stmt.Redirs ?? []) {
3833
3861
  substitutions(redir.Word, state, depth);
3834
3862
  for (const word of wordValues(redir.Word, state)) {
3835
- if (WRITES.has(redir.Op))
3836
- add("write", word, state, APPENDS.has(redir.Op) ? { append: true } : {});
3837
- if (READS.has(redir.Op)) add("read", word, state, sends ? { upload: true } : {});
3838
- if (redir.Op === DUP_OUT && word.value && !/^\d+$/.test(word.value))
3863
+ if (ops().WRITES.has(redir.Op))
3864
+ add("write", word, state, ops().APPENDS.has(redir.Op) ? { append: true } : {});
3865
+ if (ops().READS.has(redir.Op)) add("read", word, state, sends ? { upload: true } : {});
3866
+ if (redir.Op === ops().DUP_OUT && word.value && !/^\d+$/.test(word.value))
3839
3867
  add("write", word, state);
3840
3868
  }
3841
3869
  substitutions(redir.Hdoc, state, depth);
@@ -3867,16 +3895,17 @@ function collectShellFileAccesses(command, context = {}) {
3867
3895
  const seen = clone(state);
3868
3896
  let pureAnd = true;
3869
3897
  segments2.forEach(({ op, part }, i) => {
3870
- if (op === AND || op === OR) {
3871
- if (i > 0 && op === AND && pureAnd && state.onSuccess) state.cwd = state.onSuccess;
3872
- if (i > 0 && op === OR) merge(state, seen);
3898
+ if (op === ops().AND || op === ops().OR) {
3899
+ if (i > 0 && op === ops().AND && pureAnd && state.onSuccess)
3900
+ state.cwd = state.onSuccess;
3901
+ if (i > 0 && op === ops().OR) merge(state, seen);
3873
3902
  statement(part, state, depth + 1);
3874
3903
  } else {
3875
3904
  statement(part, clone(state), depth + 1);
3876
3905
  if (i > 0 && readsScriptFromStdin(part))
3877
3906
  nestedPayload(producedText(segments2[i - 1].part), clone(state), depth);
3878
3907
  }
3879
- if (i > 0 && op !== AND) pureAnd = false;
3908
+ if (i > 0 && op !== ops().AND) pureAnd = false;
3880
3909
  merge(seen, state);
3881
3910
  });
3882
3911
  merge(state, seen);
@@ -4000,8 +4029,8 @@ function collectFileAccesses(tool, args, context = {}, inspection = {}) {
4000
4029
  }
4001
4030
  return out;
4002
4031
  }
4003
- function within(path31, root) {
4004
- return path31 === root || path31.startsWith(root === "/" ? "/" : root + "/");
4032
+ function within(path210, root) {
4033
+ return path210 === root || path210.startsWith(root === "/" ? "/" : root + "/");
4005
4034
  }
4006
4035
  function hits(access, paths, directories, context) {
4007
4036
  const home = context.homeDirs?.[0] ?? "~";
@@ -5204,7 +5233,7 @@ function shellWriteUnseen(command, target) {
5204
5233
  );
5205
5234
  const redirs = n.Redirs || [];
5206
5235
  const redirectsTo = redirs.some((r) => r.Word && resolveWordLiteral(r.Word) === target);
5207
- const readsFromFile = redirs.some((r) => r.Op === RDR_IN && r.Word && !r.Hdoc);
5236
+ const readsFromFile = redirs.some((r) => r.Op === RDR_IN() && r.Word && !r.Hdoc);
5208
5237
  const named = words.includes(target);
5209
5238
  if (!redirectsTo && !named) return true;
5210
5239
  const head = unwrapCommandHead(words);
@@ -6320,14 +6349,14 @@ function mavenGet(words, from, out) {
6320
6349
  push(out, "Maven", "mvn dependency:get", coord, exact, artifact ?? coord);
6321
6350
  }
6322
6351
  function composerPackages(words, from, manager, out) {
6323
- const ops = operands(words, from, COMPOSER_VALUE_FLAGS);
6324
- const specs = manager === "composer create-project" ? ops.slice(0, 1) : ops;
6352
+ const ops2 = operands(words, from, COMPOSER_VALUE_FLAGS);
6353
+ const specs = manager === "composer create-project" ? ops2.slice(0, 1) : ops2;
6325
6354
  for (const raw of specs) {
6326
6355
  const sep = raw.search(/[:=]/);
6327
6356
  const name = sep < 0 ? raw : raw.slice(0, sep);
6328
6357
  if (!COMPOSER_NAME_RE.test(name)) continue;
6329
6358
  let ver = sep < 0 ? void 0 : raw.slice(sep + 1);
6330
- if (manager === "composer create-project" && ver === void 0) ver = ops[2] ?? void 0;
6359
+ if (manager === "composer create-project" && ver === void 0) ver = ops2[2] ?? void 0;
6331
6360
  push(out, "Packagist", manager, name.toLowerCase(), exactVersion(ver), raw);
6332
6361
  }
6333
6362
  }
@@ -7258,9 +7287,9 @@ function bareToolName(toolName) {
7258
7287
  const parts = toolName.split("__");
7259
7288
  return (parts.length >= 3 ? parts.slice(2).join("__") : toolName).toLowerCase();
7260
7289
  }
7261
- function valuesAt(args, path31) {
7290
+ function valuesAt(args, path210) {
7262
7291
  let cursors = [args];
7263
- for (const rawSegment of path31.split(".")) {
7292
+ for (const rawSegment of path210.split(".")) {
7264
7293
  const isArray = rawSegment.endsWith("[]");
7265
7294
  const key = isArray ? rawSegment.slice(0, -2) : rawSegment;
7266
7295
  const next = [];
@@ -7291,8 +7320,8 @@ function extractToolDestinations(toolName, args) {
7291
7320
  try {
7292
7321
  const out = [];
7293
7322
  const paths = DESTINATION_ARGS.get(bareToolName(toolName)) ?? [];
7294
- for (const path31 of paths) {
7295
- for (const value of valuesAt(args, path31)) {
7323
+ for (const path210 of paths) {
7324
+ for (const value of valuesAt(args, path210)) {
7296
7325
  const host2 = hostOf(value);
7297
7326
  if (host2) out.push({ host: host2, binary: toolName, raw: value });
7298
7327
  }
@@ -7318,8 +7347,8 @@ function ssrfDestinationFloor(toolName, args, opts = {}) {
7318
7347
  try {
7319
7348
  const paths = DESTINATION_ARGS.get(bareToolName(toolName));
7320
7349
  if (!paths) return null;
7321
- for (const path31 of paths) {
7322
- for (const value of valuesAt(args, path31)) {
7350
+ for (const path210 of paths) {
7351
+ for (const value of valuesAt(args, path210)) {
7323
7352
  const host2 = hostOf(value);
7324
7353
  if (!host2) continue;
7325
7354
  const m = classifySsrf(host2);
@@ -7328,7 +7357,7 @@ function ssrfDestinationFloor(toolName, args, opts = {}) {
7328
7357
  const decision = ssrfFloorDecision(m, written, opts);
7329
7358
  if (decision === null) continue;
7330
7359
  const reason = decision === "review" ? ssrfDisguisedReason(m, written) : ssrfReason(m, host2);
7331
- return { ...m, argPath: path31, host: host2, reason, decision };
7360
+ return { ...m, argPath: path210, host: host2, reason, decision };
7332
7361
  }
7333
7362
  }
7334
7363
  return null;
@@ -8982,10 +9011,13 @@ function matchCanaryArgs(args, values) {
8982
9011
  return null;
8983
9012
  }
8984
9013
  }
8985
- var MAX_REGEX_LENGTH, REGEX_CACHE_MAX, regexCache, aws_default, bash_safe_default, docker_default, filesystem_default, github_default, k8s_default, mongodb_default, postgres_default, project_jail_default, redis_default, finance_default, identity_default, publishing_default, settings_default, branches_default, ACTION_TEMPLATES, ACTION_CHECKS, GAP, prog, httpTo, httpWrite, HTTP_WRITE, HTTP_WRITE_ANY, NOT_STRIPE_TEST, postTo, STRIPE_OBJECTS, APP_SHIELD_SPECS, APP_SHIELDS, APP_SHIELD_NAMES, APP_SERVER_GLOB, GENERAL_ACTION_RULES, BUILTIN_SHIELDS, SSRF_MAX_HOST, METADATA_ADDRESSES, STRICT_TIERS, METADATA_HOSTNAMES, v4Octets, TIER_REASON, CHECK_TEXT, LEVELS, MODE_VALUES, SOFT, STRICT, BLOCK_ALL, LEVEL_CHECKS, VERDICTS, CHECK_VERDICT_RANK, ALL, BUILTIN_DANGEROUS_WORDS, PRODUCT_CHECKS, SHIELD_RULE_NAME, SHIELD_RULES_FOLDED_INTO_PRODUCT, CHECKS, CHECK_BY_ID, LEGACY_TO_ID, PROJECT_JAIL_BLOCK_READ, OVERRIDE_PREFIX, LABEL_WRAPPERS, LEGACY_READERS, syntax, KINDS, STRUCTS, unknownKinds, INVISIBLE_RE, INVISIBLE_ONE, HOMOGLYPHS, HOMOGLYPH_RE, MAX_BLOBS, MIN_DECODED, BASE64_RUN_RE, HEX_RUN_RE, HEX_ESCAPE_RUN_RE, SYSTEM_AUTH_FILES, SYSTEM_AUTH_DIRS, PASSWORD_HASH_FILES, STARTUP_NAMES, SYSTEM_DIRS, SYSTEM_DIRS_EXEMPT, UPLOAD_SYSTEM_DIRS, AGENT_INSTRUCTION_FILES, AGENT_INSTRUCTION_DIRS, LEGACY_SYSTEM_PATH_RE, MAX_INLINE_CODE, WHAT, OUTSIDE, pyImport, either, PYTHON, NODE, PERL, RUBY, PHP, TABLES, STRING_LITERAL, syntax2, sharedParser, MESSAGE_FLAGS, SHELL_INTERPRETERS, DOWNLOAD_CMDS, NORMALIZE_CACHE_MAX, normalizeCache, codeBodiesCache, AST_CACHE_MAX, astCache, PARSE_FAIL, INTERPRETER_LINE, PROGRAM_DIR, ACCESS_VIEW_CACHE_MAX, accessViewCache, MAX_READING_PAYLOADS, STDIN_CODE_INTERPRETERS, RUNS_TEXT_ELSEWHERE, defaultExpansionOps, VARIABLE_READERS, FS_READ_TOOLS, GREP_SHAPE, PATTERN_VERBS, PATTERN_VERB_NAMES, GREP_FILE_OPERANDS, READER_VALUE_LETTERS, FILE_OPERAND_FLAGS, SCP_VALUE_FLAGS, CURL_SOURCE_FLAGS, CURL_VALUE_LETTERS, WGET_VALUE_LETTERS, TAR_VALUE_LETTERS, ZIP_VALUE_LETTERS, RSYNC_VALUE_LETTERS, RSYNC_SKIP, CP_VALUE_LETTERS, INSTALL_VALUE_LETTERS, COPY_VERBS, TAR_MODE_WORD, COPY_VERB_HEADS, FS_OP_PRESCREEN_RE, HOME_CACHE_ALLOWLIST, SENSITIVE_PATH_RULES, AST_FS_REGEX_RULES, SQL_DB_CLIS, SQL_DDL_RE, CHMOD_OPEN_PERM_TOKENS, COMMAND_WRAPPERS, INLINE_INTERPRETER, RUNNER_WRAPPERS, _redirStdinOps, _listOps, WRAPPER_TAKES_TARGET, FIND_EXEC_FLAGS, FS_MUTATION_TOOLS, INTERP_LEADING_TARGET, MAX_PAYLOAD_NESTING, payloadNesting, MAX_INLINE_CALLS, INLINE_EXEC_FALLBACK, UNREADABLE_SOURCE, SCRIPT_RUNNERS, SCRIPT_RUNNER_VALUE_FLAGS, MAX_SCRIPT_OPERANDS, NET_BINARIES, VALUE_FLAGS, HOME_VARIABLES, assignmentTable, currentStmtOffset, PAYLOAD_BUDGET, payloadBudget, seenPayloads, UNANALYSABLE_NESTING, ASSIGNMENT_HEADS, AND_OP, OR_OP, AND_OR_OPS, MAX_CALL_DEPTH, MAX_CALL_WALKS, callDepth, callWalks, FS_OP_CACHE_MAX, fsOpCache, stripDotSlash, REDIR_TRUNCATE_OPS, REDIR_FILE_IN_OPS, REDIR_HEREDOC_OPS, FIND_OPTIONS, COPY_RULE_OF, isReaderWord, positionalAfter, NONE, UNKNOWN, FORBIDDEN_PATH_SEGMENTS, BASH_TOOL_NAMES, MCP_EXECUTORS, BUILTIN_FIELDS, ARGV_FIELDS, BARE_WORD, MAX_ARGV_CHARACTERS, syntax3, MAX_ALTERNATIVES, MAX_CALL_DEPTH2, MAX_CALL_WALKS2, POSITIONAL, MAX_DEPTH, MAX_PAYLOAD_DEPTH, unique, clone, SENDING_STDIN, DOWNLOAD_SHORT_VALUE, DOWNLOAD_LONG_VALUE, DOWNLOAD_OUTPUT_FLAGS, DOWNLOAD_DIR_FLAGS, base, quoteGlob, asWord, WRITES, APPENDS, READS, DUP_OUT, HERE_STRING, AND, OR, DEFAULT_OPS, exempt, RANK, SEQUENCE_OPS, BIP39_ENGLISH, BIP39_PUBLIC_VECTORS, indices, lengths, hash, MAX_MNEMONIC_HASHES, SECRET_VIEW_LIMITS, IBAN_LENGTH, IBAN_BBAN_SHAPE, B58, B58_INDEX, XPRV_VERSIONS, B62, CRC32_TABLE, GITHUB_TOKEN_RE, B64URL, B64URL_INDEX, CASK_TWO_ZERO_SUFFIX, CASK_FOUR_ZERO_SUFFIX, CF_ODD, CF_EVEN, SPANISH_LETTERS, HETU_CHARS, VERHOEFF_D, VERHOEFF_P, MAX, UNTRUSTED_TOOLS, INJECTION_SIGNALS, MENTION_QUOTE_RE, MENTION_WORD_RE, ASSIGNMENT_CONTEXT_RE, DLP_STOPWORDS, REFERENCE_VALUE_RE, IDENTIFIER_VALUE_RE, PATH_VALUE_RE, DOTTED_REFERENCE_RE, CONCATENATION_RE, EMAIL_VALUE_RE, FIXTURE_NAME_RE, DERIVATIVE_NAME_RE, QUERY_CREDENTIAL_VALUE_RE, OTP_SECRET_RE, OTP_DOC_SECRETS, ASSIGNED_SECRET_VALUE_RE, ASSIGNED_SECRET_NAME_RE, NAME_KEYWORD_RE, ARN_CONTEXT_RE, CIPHER_KEY_NAME_RE, CIPHER_NAME_PARTS, CIPHER_KEY_VALUE_RE, LARAVEL_KEY_VALUE_RE, SQL_PASSWORD_VALUE_RE, GRAFANA_KEY_VALUE_RE, BASIC_VALUE_RE, BASIC_PAIR_RE, BASIC_HEADER_RE, BASIC_HEADER_PAIR_RE, BASIC_PLACEHOLDER_RE, BASIC_TEMPLATE_MARKERS, DROPBOX_SECRET_RE, OTP_CAPTURE_RE, DB_URL_PASSWORD_RE, DLP_PATTERNS, DLP_PATTERNS_GLOBAL, SENSITIVE_PATH_PATTERNS, SENSITIVE_PATH_REGEXES, MAX_DEPTH2, MAX_STRING_BYTES, MAX_JSON_PARSE_BYTES, BATCH_SEPARATOR, IMPERATIVE, SECRET_TARGET, GUARD, SIGNALS, DESTINATION_RE, REUSED_SIGNALS, NEVER_NEGATED, NEGATION_BEFORE, RDR_IN, COPY_VERBS2, LITERAL_VERBS, GIT_PRESCREEN_RE, MAX_PAYLOAD_DEPTH2, MAX_ALIAS_DEPTH, CACHE_MAX, cache, PAYLOAD_SHELLS, CONFIG_SCOPE_FLAGS, CONFIG_VALUE_FLAGS, GLOBAL_VALUE_OPTIONS, GLOBAL_FLAG_OPTIONS, MAX_LOOP_ITEMS, GitWalk, POSITIONAL2, FORCE_PUSH, DESTRUCTIVE, UNREADABLE, PUSH_LONG_VALUE, BRANCH_LONG_VALUE, TAG_LONG_VALUE, CLEAN_LONG_VALUE, HOOKS_BYPASS, NO_VERIFY_SUBS, HOOK_KILL_SWITCHES, COMMIT_LONG_VALUE, CHMOD_OPTION_RE, STAGE_ALL, ADD_LONG_VALUE, CHECK_ID, RULE_NAME, INERT_LINE_RE, CHECK_ID2, INSTRUCTION_NAMES, SETTINGS_RE, HOOK_WORDS_RE, SHELLS, NETCATS, NET_CLIENTS, SENDERS, NETCAT_EXEC_LONG, DECL_DUMPS, PROC_ENVIRON_RE, DEV_NET_RE, SOCAT_PROGRAM_RE, SOCAT_NET_RE, PRESCREEN_RE, MAX_PAYLOAD_DEPTH3, CACHE_MAX2, cache2, dupInOp, REVERSE_SHELL_DESCRIPTION, ENV_EXFIL_DESCRIPTION, DYNAMIC_WORD, MULTICALL, SHELL_VALUE_OPTIONS, INTERPRETERS, OutboundWalk, NPM_INSTALL_VERBS, NPM_EXEC_VERBS, PNPM_INSTALL_VERBS, YARN_INSTALL_VERBS, BUN_INSTALL_VERBS, DLX_VERBS, NON_REGISTRY_RE, NPM_NAME_RE, EXACT_SEMVER_RE, NPM_VALUE_FLAGS, PNPM_VALUE_FLAGS, YARN_VALUE_FLAGS, BUN_VALUE_FLAGS, PIP_VALUE_FLAGS, UV_VALUE_FLAGS, POETRY_VALUE_FLAGS, PIPENV_VALUE_FLAGS, PIPX_VALUE_FLAGS, PY_SPEC_RE, PY_EXACT_RE, EXACT_VERSION_RE, GEM_NAME_RE, GEM_VALUE_FLAGS, BUNDLE_VALUE_FLAGS, CRATE_NAME_RE, CARGO_ADD_VALUE_FLAGS, CARGO_INSTALL_VALUE_FLAGS, GO_VALUE_FLAGS, GO_PATH_RE, NUGET_NAME_RE, DOTNET_ADD_VALUE_FLAGS, DOTNET_TOOL_VALUE_FLAGS, NUGET_VALUE_FLAGS, MAVEN_COORD_RE, COMPOSER_NAME_RE, COMPOSER_VALUE_FLAGS, EDITOR_HEADS, EXTENSION_ID_RE, MANAGER_HEADS, SHELLS2, MAX_NESTING, SHELL_VALUE_FLAGS, NPM_FAMILY, PIP_FAMILY, NPM_FETCH_VERBS, PIP_FETCH_VERBS, NPM_FLAGS, PIP_FLAGS, NPM_VARS, PIP_VARS, PRESCREEN_RE2, PIP_ATTACHED_RE, MAX_PAYLOAD_DEPTH4, PUBLIC_REGISTRY_HOSTS, TUNING_FIELDS, MAP_GOVERNED, KNOB_GOVERNED, CONFIGURABLE_CHECK_IDS, DEFAULT_EGRESS_ALLOWLIST, PRIVATE_HOST_SUFFIXES, SOURCE_COMMANDS, SINK_COMMANDS, OBFUSCATORS, SENSITIVE_PATTERNS, FLAGS_WITH_VALUES, DESTINATION_ARGS, MCP_DESTINATION_KEYS, ARGUMENT_SCAN_LIMITS, RUN_CHAR, runChar, VERDICT_RANK, SQL_DML_KEYWORDS, MAX_DESTINATIONS, MAX_SCAN_CHARS, EMAIL_RE, URL_RE, IBAN_RE, RECIPIENT_KEYS, DESTRUCTIVE_VERB_RE, PII_EMAIL_RE, PII_SSN_RE, PII_PHONE_RE, PII_CC16_RE, PII_CC15_RE, PII_CC14_RE, PII_CC13_RE, PII_CC19_RE, CARD_PATTERNS, PII_ROUTING_RE, ROUTING_LABEL_RE, ROUTING_LABEL_WINDOW, NATIONAL_ID_SHAPES, NATIONAL_ID_LABEL_RE, NATIONAL_ID_LABEL_CS_RE, idLabelIn, NATIONAL_ID_LABEL_WINDOW, NATIONAL_ID_GUARD_RE, PII_IBAN_RE, REALTIME_PII_PATTERNS, MAX_PII_SCAN_BYTES, IBAN_DESTINATION_KEYS, WHOLE_IBAN_RE, JSON_ESCAPE_RE, JSON_ESCAPES, MASKED_KINDS, ENTRY_RE, IBAN_TEXT_RE, EMAIL_TEXT_RE, ACCOUNT_KEY_RE, ACCOUNT_VALUE_RE, MAX_MASK_DEPTH, EMPTY, CURL_SEND_FLAGS, WGET_SEND_FLAGS, IWR_SEND_FLAGS, WRITE_METHODS, GH_READ, GH_WRITE, GH_HOSTNAME_FLAGS, GH_REPO_VALUE_FLAGS, GH_API_VALUE_FLAGS, GIT_FETCH, PUBLISH, SHELLS3, OWN_HEADS, MAX_DEPTH3, CWD_CHANGERS, TERMINAL_ESCAPE_RE, LOOP_MAX_RECORDS, CANARY_MIN_LENGTH, MAX_TEXT, MAX_DEPTH4, MAX_JSON_PARSE, URL_DEPTH, B64_DEPTH, MIN_SEGMENT, SEPARATORS, stripSeparators, looksText, CANARY_DECODERS, VIEWS, LONG_OUTPUT_THRESHOLD_BYTES;
9014
+ var getFilename, __filename2, MAX_REGEX_LENGTH, REGEX_CACHE_MAX, regexCache, aws_default, bash_safe_default, docker_default, filesystem_default, github_default, k8s_default, mongodb_default, postgres_default, project_jail_default, redis_default, finance_default, identity_default, publishing_default, settings_default, branches_default, ACTION_TEMPLATES, ACTION_CHECKS, GAP, prog, httpTo, httpWrite, HTTP_WRITE, HTTP_WRITE_ANY, NOT_STRIPE_TEST, postTo, STRIPE_OBJECTS, APP_SHIELD_SPECS, APP_SHIELDS, APP_SHIELD_NAMES, APP_SERVER_GLOB, GENERAL_ACTION_RULES, BUILTIN_SHIELDS, SSRF_MAX_HOST, METADATA_ADDRESSES, STRICT_TIERS, METADATA_HOSTNAMES, v4Octets, TIER_REASON, CHECK_TEXT, LEVELS, MODE_VALUES, SOFT, STRICT, BLOCK_ALL, LEVEL_CHECKS, VERDICTS, CHECK_VERDICT_RANK, ALL, BUILTIN_DANGEROUS_WORDS, PRODUCT_CHECKS, SHIELD_RULE_NAME, SHIELD_RULES_FOLDED_INTO_PRODUCT, CHECKS, CHECK_BY_ID, LEGACY_TO_ID, PROJECT_JAIL_BLOCK_READ, OVERRIDE_PREFIX, LABEL_WRAPPERS, LEGACY_READERS, syntax, KINDS, STRUCTS, unknownKinds, INVISIBLE_RE, INVISIBLE_ONE, HOMOGLYPHS, HOMOGLYPH_RE, MAX_BLOBS, MIN_DECODED, BASE64_RUN_RE, HEX_RUN_RE, HEX_ESCAPE_RUN_RE, SYSTEM_AUTH_FILES, SYSTEM_AUTH_DIRS, PASSWORD_HASH_FILES, STARTUP_NAMES, SYSTEM_DIRS, SYSTEM_DIRS_EXEMPT, UPLOAD_SYSTEM_DIRS, AGENT_INSTRUCTION_FILES, AGENT_INSTRUCTION_DIRS, LEGACY_SYSTEM_PATH_RE, MAX_INLINE_CODE, WHAT, OUTSIDE, pyImport, either, PYTHON, NODE, PERL, RUBY, PHP, TABLES, STRING_LITERAL, sharedParser, MESSAGE_FLAGS, SHELL_INTERPRETERS, DOWNLOAD_CMDS, NORMALIZE_CACHE_MAX, normalizeCache, codeBodiesCache, AST_CACHE_MAX, astCache, PARSE_FAIL, INTERPRETER_LINE, PROGRAM_DIR, ACCESS_VIEW_CACHE_MAX, accessViewCache, MAX_READING_PAYLOADS, STDIN_CODE_INTERPRETERS, RUNS_TEXT_ELSEWHERE, defaultExpansionOps, VARIABLE_READERS, FS_READ_TOOLS, GREP_SHAPE, PATTERN_VERBS, PATTERN_VERB_NAMES, GREP_FILE_OPERANDS, READER_VALUE_LETTERS, FILE_OPERAND_FLAGS, SCP_VALUE_FLAGS, CURL_SOURCE_FLAGS, CURL_VALUE_LETTERS, WGET_VALUE_LETTERS, TAR_VALUE_LETTERS, ZIP_VALUE_LETTERS, RSYNC_VALUE_LETTERS, RSYNC_SKIP, CP_VALUE_LETTERS, INSTALL_VALUE_LETTERS, COPY_VERBS, TAR_MODE_WORD, COPY_VERB_HEADS, FS_OP_PRESCREEN_RE, HOME_CACHE_ALLOWLIST, SENSITIVE_PATH_RULES, AST_FS_REGEX_RULES, SQL_DB_CLIS, SQL_DDL_RE, CHMOD_OPEN_PERM_TOKENS, COMMAND_WRAPPERS, INLINE_INTERPRETER, RUNNER_WRAPPERS, _redirStdinOps, _listOps, WRAPPER_TAKES_TARGET, FIND_EXEC_FLAGS, FS_MUTATION_TOOLS, INTERP_LEADING_TARGET, MAX_PAYLOAD_NESTING, payloadNesting, MAX_INLINE_CALLS, INLINE_EXEC_FALLBACK, UNREADABLE_SOURCE, SCRIPT_RUNNERS, SCRIPT_RUNNER_VALUE_FLAGS, MAX_SCRIPT_OPERANDS, NET_BINARIES, VALUE_FLAGS, HOME_VARIABLES, assignmentTable, currentStmtOffset, PAYLOAD_BUDGET, payloadBudget, seenPayloads, UNANALYSABLE_NESTING, ASSIGNMENT_HEADS, andOrOps, MAX_CALL_DEPTH, MAX_CALL_WALKS, callDepth, callWalks, FS_OP_CACHE_MAX, fsOpCache, stripDotSlash, REDIR_TRUNCATE_OPS, REDIR_FILE_IN_OPS, REDIR_HEREDOC_OPS, FIND_OPTIONS, COPY_RULE_OF, isReaderWord, positionalAfter, NONE, UNKNOWN, FORBIDDEN_PATH_SEGMENTS, BASH_TOOL_NAMES, MCP_EXECUTORS, BUILTIN_FIELDS, ARGV_FIELDS, BARE_WORD, MAX_ARGV_CHARACTERS, MAX_ALTERNATIVES, MAX_CALL_DEPTH2, MAX_CALL_WALKS2, POSITIONAL, MAX_DEPTH, MAX_PAYLOAD_DEPTH, unique, clone, SENDING_STDIN, DOWNLOAD_SHORT_VALUE, DOWNLOAD_LONG_VALUE, DOWNLOAD_OUTPUT_FLAGS, DOWNLOAD_DIR_FLAGS, base, quoteGlob, asWord, ops, exempt, RANK, SEQUENCE_OPS, BIP39_ENGLISH, BIP39_PUBLIC_VECTORS, indices, lengths, hash, MAX_MNEMONIC_HASHES, SECRET_VIEW_LIMITS, IBAN_LENGTH, IBAN_BBAN_SHAPE, B58, B58_INDEX, XPRV_VERSIONS, B62, CRC32_TABLE, GITHUB_TOKEN_RE, B64URL, B64URL_INDEX, CASK_TWO_ZERO_SUFFIX, CASK_FOUR_ZERO_SUFFIX, CF_ODD, CF_EVEN, SPANISH_LETTERS, HETU_CHARS, VERHOEFF_D, VERHOEFF_P, MAX, UNTRUSTED_TOOLS, INJECTION_SIGNALS, MENTION_QUOTE_RE, MENTION_WORD_RE, ASSIGNMENT_CONTEXT_RE, DLP_STOPWORDS, REFERENCE_VALUE_RE, IDENTIFIER_VALUE_RE, PATH_VALUE_RE, DOTTED_REFERENCE_RE, CONCATENATION_RE, EMAIL_VALUE_RE, FIXTURE_NAME_RE, DERIVATIVE_NAME_RE, QUERY_CREDENTIAL_VALUE_RE, OTP_SECRET_RE, OTP_DOC_SECRETS, ASSIGNED_SECRET_VALUE_RE, ASSIGNED_SECRET_NAME_RE, NAME_KEYWORD_RE, ARN_CONTEXT_RE, CIPHER_KEY_NAME_RE, CIPHER_NAME_PARTS, CIPHER_KEY_VALUE_RE, LARAVEL_KEY_VALUE_RE, SQL_PASSWORD_VALUE_RE, GRAFANA_KEY_VALUE_RE, BASIC_VALUE_RE, BASIC_PAIR_RE, BASIC_HEADER_RE, BASIC_HEADER_PAIR_RE, BASIC_PLACEHOLDER_RE, BASIC_TEMPLATE_MARKERS, DROPBOX_SECRET_RE, OTP_CAPTURE_RE, DB_URL_PASSWORD_RE, DLP_PATTERNS, DLP_PATTERNS_GLOBAL, SENSITIVE_PATH_PATTERNS, SENSITIVE_PATH_REGEXES, MAX_DEPTH2, MAX_STRING_BYTES, MAX_JSON_PARSE_BYTES, BATCH_SEPARATOR, IMPERATIVE, SECRET_TARGET, GUARD, SIGNALS, DESTINATION_RE, REUSED_SIGNALS, NEVER_NEGATED, NEGATION_BEFORE, RDR_IN, COPY_VERBS2, LITERAL_VERBS, GIT_PRESCREEN_RE, MAX_PAYLOAD_DEPTH2, MAX_ALIAS_DEPTH, CACHE_MAX, cache, PAYLOAD_SHELLS, CONFIG_SCOPE_FLAGS, CONFIG_VALUE_FLAGS, GLOBAL_VALUE_OPTIONS, GLOBAL_FLAG_OPTIONS, MAX_LOOP_ITEMS, GitWalk, POSITIONAL2, FORCE_PUSH, DESTRUCTIVE, UNREADABLE, PUSH_LONG_VALUE, BRANCH_LONG_VALUE, TAG_LONG_VALUE, CLEAN_LONG_VALUE, HOOKS_BYPASS, NO_VERIFY_SUBS, HOOK_KILL_SWITCHES, COMMIT_LONG_VALUE, CHMOD_OPTION_RE, STAGE_ALL, ADD_LONG_VALUE, CHECK_ID, RULE_NAME, INERT_LINE_RE, CHECK_ID2, INSTRUCTION_NAMES, SETTINGS_RE, HOOK_WORDS_RE, SHELLS, NETCATS, NET_CLIENTS, SENDERS, NETCAT_EXEC_LONG, DECL_DUMPS, PROC_ENVIRON_RE, DEV_NET_RE, SOCAT_PROGRAM_RE, SOCAT_NET_RE, PRESCREEN_RE, MAX_PAYLOAD_DEPTH3, CACHE_MAX2, cache2, dupInOp, REVERSE_SHELL_DESCRIPTION, ENV_EXFIL_DESCRIPTION, DYNAMIC_WORD, MULTICALL, SHELL_VALUE_OPTIONS, INTERPRETERS, OutboundWalk, NPM_INSTALL_VERBS, NPM_EXEC_VERBS, PNPM_INSTALL_VERBS, YARN_INSTALL_VERBS, BUN_INSTALL_VERBS, DLX_VERBS, NON_REGISTRY_RE, NPM_NAME_RE, EXACT_SEMVER_RE, NPM_VALUE_FLAGS, PNPM_VALUE_FLAGS, YARN_VALUE_FLAGS, BUN_VALUE_FLAGS, PIP_VALUE_FLAGS, UV_VALUE_FLAGS, POETRY_VALUE_FLAGS, PIPENV_VALUE_FLAGS, PIPX_VALUE_FLAGS, PY_SPEC_RE, PY_EXACT_RE, EXACT_VERSION_RE, GEM_NAME_RE, GEM_VALUE_FLAGS, BUNDLE_VALUE_FLAGS, CRATE_NAME_RE, CARGO_ADD_VALUE_FLAGS, CARGO_INSTALL_VALUE_FLAGS, GO_VALUE_FLAGS, GO_PATH_RE, NUGET_NAME_RE, DOTNET_ADD_VALUE_FLAGS, DOTNET_TOOL_VALUE_FLAGS, NUGET_VALUE_FLAGS, MAVEN_COORD_RE, COMPOSER_NAME_RE, COMPOSER_VALUE_FLAGS, EDITOR_HEADS, EXTENSION_ID_RE, MANAGER_HEADS, SHELLS2, MAX_NESTING, SHELL_VALUE_FLAGS, NPM_FAMILY, PIP_FAMILY, NPM_FETCH_VERBS, PIP_FETCH_VERBS, NPM_FLAGS, PIP_FLAGS, NPM_VARS, PIP_VARS, PRESCREEN_RE2, PIP_ATTACHED_RE, MAX_PAYLOAD_DEPTH4, PUBLIC_REGISTRY_HOSTS, TUNING_FIELDS, MAP_GOVERNED, KNOB_GOVERNED, CONFIGURABLE_CHECK_IDS, DEFAULT_EGRESS_ALLOWLIST, PRIVATE_HOST_SUFFIXES, SOURCE_COMMANDS, SINK_COMMANDS, OBFUSCATORS, SENSITIVE_PATTERNS, FLAGS_WITH_VALUES, DESTINATION_ARGS, MCP_DESTINATION_KEYS, ARGUMENT_SCAN_LIMITS, RUN_CHAR, runChar, VERDICT_RANK, SQL_DML_KEYWORDS, MAX_DESTINATIONS, MAX_SCAN_CHARS, EMAIL_RE, URL_RE, IBAN_RE, RECIPIENT_KEYS, DESTRUCTIVE_VERB_RE, PII_EMAIL_RE, PII_SSN_RE, PII_PHONE_RE, PII_CC16_RE, PII_CC15_RE, PII_CC14_RE, PII_CC13_RE, PII_CC19_RE, CARD_PATTERNS, PII_ROUTING_RE, ROUTING_LABEL_RE, ROUTING_LABEL_WINDOW, NATIONAL_ID_SHAPES, NATIONAL_ID_LABEL_RE, NATIONAL_ID_LABEL_CS_RE, idLabelIn, NATIONAL_ID_LABEL_WINDOW, NATIONAL_ID_GUARD_RE, PII_IBAN_RE, REALTIME_PII_PATTERNS, MAX_PII_SCAN_BYTES, IBAN_DESTINATION_KEYS, WHOLE_IBAN_RE, JSON_ESCAPE_RE, JSON_ESCAPES, MASKED_KINDS, ENTRY_RE, IBAN_TEXT_RE, EMAIL_TEXT_RE, ACCOUNT_KEY_RE, ACCOUNT_VALUE_RE, MAX_MASK_DEPTH, EMPTY, CURL_SEND_FLAGS, WGET_SEND_FLAGS, IWR_SEND_FLAGS, WRITE_METHODS, GH_READ, GH_WRITE, GH_HOSTNAME_FLAGS, GH_REPO_VALUE_FLAGS, GH_API_VALUE_FLAGS, GIT_FETCH, PUBLISH, SHELLS3, OWN_HEADS, MAX_DEPTH3, CWD_CHANGERS, TERMINAL_ESCAPE_RE, LOOP_MAX_RECORDS, CANARY_MIN_LENGTH, MAX_TEXT, MAX_DEPTH4, MAX_JSON_PARSE, URL_DEPTH, B64_DEPTH, MIN_SEGMENT, SEPARATORS, stripSeparators, looksText, CANARY_DECODERS, VIEWS, LONG_OUTPUT_THRESHOLD_BYTES;
8986
9015
  var init_dist = __esm({
8987
9016
  "packages/policy-engine/dist/index.mjs"() {
8988
9017
  "use strict";
9018
+ init_esm_shims();
9019
+ getFilename = () => fileURLToPath2(import.meta.url);
9020
+ __filename2 = /* @__PURE__ */ getFilename();
8989
9021
  MAX_REGEX_LENGTH = 256;
8990
9022
  REGEX_CACHE_MAX = 500;
8991
9023
  regexCache = /* @__PURE__ */ new Map();
@@ -11630,7 +11662,7 @@ var init_dist = __esm({
11630
11662
  return s.untrustedContent.afterExposure === "log-only" ? "log" : "review";
11631
11663
  }
11632
11664
  };
11633
- ({ syntax } = mvdanSh);
11665
+ syntax = null;
11634
11666
  KINDS = {
11635
11667
  File: { nodes: ["Stmts"] },
11636
11668
  Stmt: { nodes: ["Cmd", "Redirs"], scalars: ["Negated", "Background", "Coprocess"] },
@@ -11970,8 +12002,7 @@ var init_dist = __esm({
11970
12002
  php: PHP
11971
12003
  };
11972
12004
  STRING_LITERAL = /(['"`])((?:\\.|(?!\1)[^\\\n]){1,4096})\1/g;
11973
- ({ syntax: syntax2 } = mvdanSh2);
11974
- sharedParser = syntax2.NewParser();
12005
+ sharedParser = lazy(() => getSyntax().NewParser());
11975
12006
  MESSAGE_FLAGS = /* @__PURE__ */ new Set([
11976
12007
  "-m",
11977
12008
  "--message",
@@ -12936,9 +12967,14 @@ var init_dist = __esm({
12936
12967
  path: ""
12937
12968
  };
12938
12969
  ASSIGNMENT_HEADS = /* @__PURE__ */ new Set(["export", "declare", "local", "readonly", "typeset"]);
12939
- AND_OP = probeBinOp("a && b");
12940
- OR_OP = probeBinOp("a || b");
12941
- AND_OR_OPS = new Set([AND_OP, OR_OP].filter((o) => o !== null));
12970
+ andOrOps = lazy(() => {
12971
+ const and = probeBinOp("a && b");
12972
+ const or = probeBinOp("a || b");
12973
+ return {
12974
+ AND_OP: and,
12975
+ AND_OR_OPS: new Set([and, or].filter((o) => o !== null))
12976
+ };
12977
+ });
12942
12978
  MAX_CALL_DEPTH = 4;
12943
12979
  MAX_CALL_WALKS = 256;
12944
12980
  callDepth = 0;
@@ -12946,14 +12982,13 @@ var init_dist = __esm({
12946
12982
  FS_OP_CACHE_MAX = 5e3;
12947
12983
  fsOpCache = /* @__PURE__ */ new Map();
12948
12984
  stripDotSlash = (p) => p.replace(/^\.\//, "");
12949
- REDIR_TRUNCATE_OPS = /* @__PURE__ */ new Set([deriveRedirOp(">_f")]);
12950
- REDIR_FILE_IN_OPS = new Set(
12951
- [deriveRedirOp("cat < f"), deriveRedirOp("cat <> f")].filter((op) => op >= 0)
12985
+ REDIR_TRUNCATE_OPS = lazy(() => /* @__PURE__ */ new Set([deriveRedirOp(">_f")]));
12986
+ REDIR_FILE_IN_OPS = lazy(
12987
+ () => new Set([deriveRedirOp("cat < f"), deriveRedirOp("cat <> f")].filter((op) => op >= 0))
12988
+ );
12989
+ REDIR_HEREDOC_OPS = lazy(
12990
+ () => /* @__PURE__ */ new Set([deriveRedirOp("cat <<X\nX"), deriveRedirOp("cat <<-X\nX")])
12952
12991
  );
12953
- REDIR_HEREDOC_OPS = /* @__PURE__ */ new Set([
12954
- deriveRedirOp("cat <<X\nX"),
12955
- deriveRedirOp("cat <<-X\nX")
12956
- ]);
12957
12992
  FIND_OPTIONS = /* @__PURE__ */ new Set(["-H", "-L", "-P"]);
12958
12993
  COPY_RULE_OF = {
12959
12994
  "shield:project-jail:block-read-ssh": "shield:project-jail:review-copy-ssh",
@@ -12990,7 +13025,6 @@ var init_dist = __esm({
12990
13025
  ARGV_FIELDS = ["args", "argv"];
12991
13026
  BARE_WORD = /^[A-Za-z0-9_./+:@%,-]+$/;
12992
13027
  MAX_ARGV_CHARACTERS = 262144;
12993
- ({ syntax: syntax3 } = mvdanSh3);
12994
13028
  MAX_ALTERNATIVES = 64;
12995
13029
  MAX_CALL_DEPTH2 = 4;
12996
13030
  MAX_CALL_WALKS2 = 256;
@@ -13068,31 +13102,35 @@ var init_dist = __esm({
13068
13102
  base = (s) => (s ?? "").replace(/\/+$/, "").split("/").pop() ?? "";
13069
13103
  quoteGlob = (s) => s.replace(/[\\*?\[\]{}()!+@]/g, "\\$&");
13070
13104
  asWord = (p) => ({ value: p.value, ...p.glob ? { pattern: p.pattern } : {} });
13071
- WRITES = new Set([">x", ">>x", ">|x", "&>x", "&>>x", "<>x"].map(opOf));
13072
- APPENDS = new Set([">>x", "&>>x"].map(opOf));
13073
- READS = new Set(["<x", "<>x"].map(opOf));
13074
- DUP_OUT = opOf(">&x");
13075
- HERE_STRING = opOf("<<<x");
13076
- AND = parseShared("a && b").Stmts[0].Cmd.Op;
13077
- OR = parseShared("a || b").Stmts[0].Cmd.Op;
13078
- DEFAULT_OPS = new Set(
13079
- ["${x:-y}", "${x-y}", "${x:=y}", "${x=y}"].map(
13080
- (s) => parseShared(`echo ${s}`).Stmts[0].Cmd.Args[1].Parts[0].Exp.Op
13105
+ ops = lazy(() => ({
13106
+ WRITES: new Set([">x", ">>x", ">|x", "&>x", "&>>x", "<>x"].map(opOf)),
13107
+ APPENDS: new Set([">>x", "&>>x"].map(opOf)),
13108
+ READS: new Set(["<x", "<>x"].map(opOf)),
13109
+ /** `>&word` with a non-numeric word is `&>word` in bash. */
13110
+ DUP_OUT: opOf(">&x"),
13111
+ HERE_STRING: opOf("<<<x"),
13112
+ AND: parseShared("a && b").Stmts[0].Cmd.Op,
13113
+ OR: parseShared("a || b").Stmts[0].Cmd.Op,
13114
+ /** `${x:-d}` `${x-d}` `${x:=d}` `${x=d}`: the default is the value when x is unset. */
13115
+ DEFAULT_OPS: new Set(
13116
+ ["${x:-y}", "${x-y}", "${x:=y}", "${x=y}"].map(
13117
+ (s) => parseShared(`echo ${s}`).Stmts[0].Cmd.Args[1].Parts[0].Exp.Op
13118
+ )
13081
13119
  )
13082
- );
13120
+ }));
13083
13121
  exempt = (p) => SYSTEM_DIRS_EXEMPT.some((d) => within(p, d));
13084
13122
  RANK = { allow: 0, review: 1, block: 2 };
13085
- SEQUENCE_OPS = (() => {
13086
- const ops = /* @__PURE__ */ new Set();
13123
+ SEQUENCE_OPS = lazy(() => {
13124
+ const ops2 = /* @__PURE__ */ new Set();
13087
13125
  for (const text of ["x && y", "x || y"]) {
13088
13126
  try {
13089
13127
  const f = parseShared(text);
13090
- if (typeof f !== "symbol") ops.add(f.Stmts[0].Cmd.Op);
13128
+ if (typeof f !== "symbol") ops2.add(f.Stmts[0].Cmd.Op);
13091
13129
  } catch {
13092
13130
  }
13093
13131
  }
13094
- return ops;
13095
- })();
13132
+ return ops2;
13133
+ });
13096
13134
  BIP39_ENGLISH = `abandon
13097
13135
  ability
13098
13136
  able
@@ -16242,13 +16280,13 @@ zoo`.split("\n");
16242
16280
  );
16243
16281
  NEVER_NEGATED = /* @__PURE__ */ new Set([SIGNALS[1].any[0]]);
16244
16282
  NEGATION_BEFORE = /\b(never|do not|don'?t|must not|mustn'?t|should not|shouldn'?t|not allowed to|forbidden to|avoid|without|no|not)\b[^.!?;:\n]{0,24}$/i;
16245
- RDR_IN = (() => {
16283
+ RDR_IN = lazy(() => {
16246
16284
  try {
16247
16285
  return parseShared("x <y").Stmts[0].Redirs[0].Op;
16248
16286
  } catch {
16249
16287
  return null;
16250
16288
  }
16251
- })();
16289
+ });
16252
16290
  COPY_VERBS2 = /* @__PURE__ */ new Set([
16253
16291
  "cp",
16254
16292
  "mv",
@@ -18076,7 +18114,7 @@ __export(audit_exports, {
18076
18114
  truncateAuditPreview: () => truncateAuditPreview
18077
18115
  });
18078
18116
  import fs from "fs";
18079
- import path from "path";
18117
+ import path2 from "path";
18080
18118
  import os from "os";
18081
18119
  import crypto2 from "crypto";
18082
18120
  function generateEventId() {
@@ -18123,7 +18161,7 @@ function truncateAuditPreview(text) {
18123
18161
  function appendToLog(logPath, entry) {
18124
18162
  if (forecastRun()) return;
18125
18163
  try {
18126
- const dir2 = path.dirname(logPath);
18164
+ const dir2 = path2.dirname(logPath);
18127
18165
  if (!fs.existsSync(dir2)) fs.mkdirSync(dir2, { recursive: true });
18128
18166
  fs.appendFileSync(logPath, JSON.stringify(entry) + "\n");
18129
18167
  } catch {
@@ -18202,7 +18240,7 @@ function appendLocalAudit(toolName, args, decision, checkedBy, meta, auditHashAr
18202
18240
  } : {};
18203
18241
  const cloudLinkField = meta?.cloudRequestId ? { cloudRequestId: meta.cloudRequestId } : {};
18204
18242
  const workingDirField = meta?.workingDir ? { workingDir: meta.workingDir } : {};
18205
- const shell = process.env.SHELL ? path.basename(process.env.SHELL) : void 0;
18243
+ const shell = process.env.SHELL ? path2.basename(process.env.SHELL) : void 0;
18206
18244
  const shellTypeField = shell ? { shellType: shell } : {};
18207
18245
  const editFilePath = filePathFromArgs(args);
18208
18246
  const editFilePathField = editFilePath ? { editFilePath } : {};
@@ -18262,24 +18300,31 @@ var LOCAL_AUDIT_LOG, HOOK_DEBUG_LOG, TEST_COMMAND_RE;
18262
18300
  var init_audit = __esm({
18263
18301
  "src/audit/index.ts"() {
18264
18302
  "use strict";
18303
+ init_esm_shims();
18265
18304
  init_hasher();
18266
18305
  init_forecast_context();
18267
18306
  init_dist();
18268
- LOCAL_AUDIT_LOG = path.join(os.homedir(), ".node9", "audit.log");
18269
- HOOK_DEBUG_LOG = path.join(os.homedir(), ".node9", "hook-debug.log");
18307
+ LOCAL_AUDIT_LOG = path2.join(os.homedir(), ".node9", "audit.log");
18308
+ HOOK_DEBUG_LOG = path2.join(os.homedir(), ".node9", "hook-debug.log");
18270
18309
  TEST_COMMAND_RE = /(?:^|\s)(npm\s+(?:run\s+)?test|npx\s+(?:vitest|jest|mocha)|yarn\s+(?:run\s+)?test|pnpm\s+(?:run\s+)?test|vitest|jest|mocha|pytest|py\.test|cargo\s+test|go\s+test|bundle\s+exec\s+rspec|rspec|phpunit|dotnet\s+test)\b/i;
18271
18310
  }
18272
18311
  });
18273
18312
 
18313
+ // src/index.ts
18314
+ init_esm_shims();
18315
+
18274
18316
  // src/core.ts
18317
+ init_esm_shims();
18275
18318
  init_audit();
18276
18319
 
18277
18320
  // src/config/index.ts
18321
+ init_esm_shims();
18278
18322
  import fs4 from "fs";
18279
- import path4 from "path";
18323
+ import path5 from "path";
18280
18324
  import os4 from "os";
18281
18325
 
18282
18326
  // src/config-schema.ts
18327
+ init_esm_shims();
18283
18328
  import { z } from "zod";
18284
18329
  var noNewlines = z.string().refine((s) => !s.includes("\n") && !s.includes("\r"), {
18285
18330
  message: "Value must not contain literal newline characters (use \\n instead)"
@@ -18469,8 +18514,8 @@ var ConfigFileSchema = z.object({
18469
18514
  }).strict();
18470
18515
  function formatIssues(issues) {
18471
18516
  const lines = issues.map((issue) => {
18472
- const path31 = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
18473
- return ` \u2022 ${path31}: ${issue.message}`;
18517
+ const path32 = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
18518
+ return ` \u2022 ${path32}: ${issue.message}`;
18474
18519
  });
18475
18520
  return `Invalid config:
18476
18521
  ${lines.join("\n")}`;
@@ -18483,9 +18528,9 @@ function prunePaths(root, paths) {
18483
18528
  const yi = y[y.length - 1];
18484
18529
  return typeof xi === "number" && typeof yi === "number" ? yi - xi : 0;
18485
18530
  });
18486
- for (const path31 of ordered) {
18531
+ for (const path32 of ordered) {
18487
18532
  let cur = root;
18488
- for (const key of path31.slice(0, -1)) {
18533
+ for (const key of path32.slice(0, -1)) {
18489
18534
  if (cur === null || typeof cur !== "object") {
18490
18535
  cur = void 0;
18491
18536
  break;
@@ -18493,7 +18538,7 @@ function prunePaths(root, paths) {
18493
18538
  cur = cur[key];
18494
18539
  }
18495
18540
  if (cur === null || typeof cur !== "object") continue;
18496
- const last = path31[path31.length - 1];
18541
+ const last = path32[path32.length - 1];
18497
18542
  if (Array.isArray(cur)) {
18498
18543
  const i = Number(last);
18499
18544
  if (Number.isInteger(i) && i >= 0 && i < cur.length) {
@@ -18529,7 +18574,7 @@ function sanitizeConfig(raw) {
18529
18574
  return issue.keys.map((k) => [...at, k]);
18530
18575
  }
18531
18576
  return [at.slice(0, -level || void 0)];
18532
- }).filter((path31) => path31.length > 0);
18577
+ }).filter((path32) => path32.length > 0);
18533
18578
  if (paths.length === 0 || !prunePaths(working, paths)) break;
18534
18579
  }
18535
18580
  if (ConfigFileSchema.safeParse(working).success) break;
@@ -18551,12 +18596,14 @@ function sanitizeConfig(raw) {
18551
18596
  }
18552
18597
 
18553
18598
  // src/shields.ts
18599
+ init_esm_shims();
18554
18600
  import fs2 from "fs";
18555
- import path2 from "path";
18601
+ import path3 from "path";
18556
18602
  import os2 from "os";
18557
18603
  init_dist();
18558
18604
 
18559
18605
  // src/shields/build.ts
18606
+ init_esm_shims();
18560
18607
  init_dist();
18561
18608
  function escapeRegex(s) {
18562
18609
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -18635,7 +18682,7 @@ function withAccessReading(def) {
18635
18682
 
18636
18683
  // src/shields.ts
18637
18684
  init_dist();
18638
- var USER_SHIELDS_DIR = path2.join(os2.homedir(), ".node9", "shields");
18685
+ var USER_SHIELDS_DIR = path3.join(os2.homedir(), ".node9", "shields");
18639
18686
  function loadUserShields() {
18640
18687
  const result = {};
18641
18688
  let entries;
@@ -18651,7 +18698,7 @@ function loadUserShields() {
18651
18698
  return result;
18652
18699
  }
18653
18700
  for (const file2 of entries) {
18654
- const filePath = path2.join(USER_SHIELDS_DIR, file2);
18701
+ const filePath = path3.join(USER_SHIELDS_DIR, file2);
18655
18702
  try {
18656
18703
  const raw = JSON.parse(fs2.readFileSync(filePath, "utf-8"));
18657
18704
  const v = validateShieldDefinition(raw);
@@ -18684,7 +18731,7 @@ function getShield(name) {
18684
18731
  const resolved = resolveShieldName(name);
18685
18732
  return resolved ? SHIELDS[resolved] : null;
18686
18733
  }
18687
- var SHIELDS_STATE_FILE = path2.join(os2.homedir(), ".node9", "shields.json");
18734
+ var SHIELDS_STATE_FILE = path3.join(os2.homedir(), ".node9", "shields.json");
18688
18735
  function readShieldsFile() {
18689
18736
  try {
18690
18737
  const raw = fs2.readFileSync(SHIELDS_STATE_FILE, "utf-8");
@@ -18715,6 +18762,7 @@ function readShieldOverrides() {
18715
18762
  }
18716
18763
 
18717
18764
  // src/config/managed.ts
18765
+ init_esm_shims();
18718
18766
  var MODE_ORDER = ["observe", "audit", "soft", "standard", "strict", "block-all"];
18719
18767
  var EGRESS_MODE_ORDER = ["off", "review", "block"];
18720
18768
  function rankIn(order, value) {
@@ -18837,11 +18885,12 @@ function applyManagedApprovers(local, managed) {
18837
18885
  }
18838
18886
 
18839
18887
  // src/auth/trusted-hosts.ts
18888
+ init_esm_shims();
18840
18889
  import fs3 from "fs";
18841
- import path3 from "path";
18890
+ import path4 from "path";
18842
18891
  import os3 from "os";
18843
18892
  function getTrustedHostsPath() {
18844
- return path3.join(os3.homedir(), ".node9", "trusted-hosts.json");
18893
+ return path4.join(os3.homedir(), ".node9", "trusted-hosts.json");
18845
18894
  }
18846
18895
  function readTrustedHosts() {
18847
18896
  try {
@@ -18897,6 +18946,7 @@ init_dist();
18897
18946
  init_dist();
18898
18947
 
18899
18948
  // src/config/v2.ts
18949
+ init_esm_shims();
18900
18950
  init_dist();
18901
18951
  init_dist();
18902
18952
  var CONFIG_FILE_VERSION_2 = "2";
@@ -19023,6 +19073,7 @@ init_dist();
19023
19073
  init_dist();
19024
19074
 
19025
19075
  // src/auth/api-url.ts
19076
+ init_esm_shims();
19026
19077
  var DEFAULT_API_URL = "https://api.node9.ai/api/v1/intercept";
19027
19078
  var LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "::1", "[::1]", "0.0.0.0"]);
19028
19079
  var HOST_ALLOW_ENV = "NODE9_API_HOST_ALLOW";
@@ -19409,7 +19460,7 @@ function noteRejectedApiUrl(raw) {
19409
19460
  rejectedApiUrlsSeen.add(key);
19410
19461
  try {
19411
19462
  fs4.appendFileSync(
19412
- path4.join(os4.homedir(), ".node9", "hook-debug.log"),
19463
+ path5.join(os4.homedir(), ".node9", "hook-debug.log"),
19413
19464
  `[${(/* @__PURE__ */ new Date()).toISOString()}] REFUSED apiUrl, using the default instead: ${String(raw).slice(0, 200).replace(/[\r\n]+/g, " ")}
19414
19465
  `
19415
19466
  );
@@ -19426,7 +19477,7 @@ function getCredentials() {
19426
19477
  };
19427
19478
  }
19428
19479
  try {
19429
- const credPath = path4.join(os4.homedir(), ".node9", "credentials.json");
19480
+ const credPath = path5.join(os4.homedir(), ".node9", "credentials.json");
19430
19481
  if (fs4.existsSync(credPath)) {
19431
19482
  const creds = JSON.parse(fs4.readFileSync(credPath, "utf-8"));
19432
19483
  const profileName = process.env.NODE9_PROFILE || "default";
@@ -19475,7 +19526,7 @@ function readRulesCacheResilient(cacheFile) {
19475
19526
  }
19476
19527
  }
19477
19528
  if (existed || sawReadError) {
19478
- const backup = path4.join(path4.dirname(cacheFile), "rules-cache.last-good.json");
19529
+ const backup = path5.join(path5.dirname(cacheFile), "rules-cache.last-good.json");
19479
19530
  if (backup !== cacheFile) {
19480
19531
  try {
19481
19532
  const raw = JSON.parse(fs4.readFileSync(backup, "utf-8"));
@@ -19502,7 +19553,7 @@ function logCacheReadIssue(cacheFile, kind) {
19502
19553
  cacheReadLastLoggedAt = now;
19503
19554
  try {
19504
19555
  fs4.appendFileSync(
19505
- path4.join(os4.homedir(), ".node9", "hook-debug.log"),
19556
+ path5.join(os4.homedir(), ".node9", "hook-debug.log"),
19506
19557
  `[${(/* @__PURE__ */ new Date()).toISOString()}] ${kind} ${cacheFile}
19507
19558
  `
19508
19559
  );
@@ -19528,8 +19579,8 @@ function catalogSettingsFrom(settings, policy) {
19528
19579
  }
19529
19580
  function getConfig(cwd) {
19530
19581
  if (!cwd && cachedConfig) return cachedConfig;
19531
- const globalPath = path4.join(os4.homedir(), ".node9", "config.json");
19532
- const projectPath = path4.join(cwd ?? process.cwd(), "node9.config.json");
19582
+ const globalPath = path5.join(os4.homedir(), ".node9", "config.json");
19583
+ const projectPath = path5.join(cwd ?? process.cwd(), "node9.config.json");
19533
19584
  const globalConfig = tryLoadConfig(globalPath);
19534
19585
  const projectConfig = tryLoadConfig(projectPath, { project: true });
19535
19586
  const mergedSettings = {
@@ -19774,7 +19825,7 @@ function getConfig(cwd) {
19774
19825
  let cloudMandatesEnforcement = false;
19775
19826
  let cloudMandatesAppPerm = false;
19776
19827
  {
19777
- const cacheFile = path4.join(os4.homedir(), ".node9", "rules-cache.json");
19828
+ const cacheFile = path5.join(os4.homedir(), ".node9", "rules-cache.json");
19778
19829
  try {
19779
19830
  const raw = readRulesCacheResilient(cacheFile);
19780
19831
  if (Array.isArray(raw.rules) && raw.rules.length > 0) {
@@ -19967,13 +20018,13 @@ function getConfig(cwd) {
19967
20018
  }
19968
20019
  if (Array.isArray(mc.jailPaths)) {
19969
20020
  for (const jp of mc.jailPaths) {
19970
- const path31 = typeof jp?.path === "string" ? jp.path.trim() : "";
19971
- if (!path31) continue;
20021
+ const path32 = typeof jp?.path === "string" ? jp.path.trim() : "";
20022
+ if (!path32) continue;
19972
20023
  const verdict = jp?.verdict === "review" ? "review" : "block";
19973
- for (const r of pathRules(path31, verdict, "org-managed jail")) {
20024
+ for (const r of pathRules(path32, verdict, "org-managed jail")) {
19974
20025
  mergedPolicy.smartRules.push({ ...r, name: `org:${r.name}` });
19975
20026
  }
19976
- mergedPolicy.managedJailPaths.push({ path: path31, verdict });
20027
+ mergedPolicy.managedJailPaths.push({ path: path32, verdict });
19977
20028
  }
19978
20029
  }
19979
20030
  if (Array.isArray(mc.trustedHosts)) {
@@ -20309,13 +20360,16 @@ function applyUntrustedContent(cur, raw, replaceLists = false, isProject = false
20309
20360
  }
20310
20361
 
20311
20362
  // src/utils/regex.ts
20363
+ init_esm_shims();
20312
20364
  init_dist();
20313
20365
 
20314
20366
  // src/policy/index.ts
20367
+ init_esm_shims();
20315
20368
  init_dist();
20316
20369
  import fs13 from "fs";
20317
20370
 
20318
20371
  // src/utils/read-capped.ts
20372
+ init_esm_shims();
20319
20373
  import fs5 from "fs";
20320
20374
  function readCapped(file2, maxBytes, openFlags = "r") {
20321
20375
  if (maxBytes < 0) return null;
@@ -20355,23 +20409,24 @@ function readCappedText(file2, maxBytes, openFlags = "r") {
20355
20409
  }
20356
20410
 
20357
20411
  // src/policy/index.ts
20358
- import path13 from "path";
20412
+ import path14 from "path";
20359
20413
 
20360
20414
  // src/dlp.ts
20415
+ init_esm_shims();
20361
20416
  init_dist();
20362
20417
  init_dist();
20363
20418
  import fs6 from "fs";
20364
- import path5 from "path";
20419
+ import path6 from "path";
20365
20420
  function scanFilePath(filePath, cwd = process.cwd(), options = {}) {
20366
20421
  if (!filePath) return null;
20367
20422
  let resolved;
20368
20423
  try {
20369
- const absolute2 = path5.resolve(cwd, filePath);
20424
+ const absolute2 = path6.resolve(cwd, filePath);
20370
20425
  resolved = fs6.realpathSync.native(absolute2);
20371
20426
  } catch (err) {
20372
20427
  const code = err.code;
20373
20428
  if (code === "ENOENT" || code === "ENOTDIR") {
20374
- resolved = path5.resolve(cwd, filePath);
20429
+ resolved = path6.resolve(cwd, filePath);
20375
20430
  } else {
20376
20431
  return sensitivePathMatch(filePath);
20377
20432
  }
@@ -20380,6 +20435,7 @@ function scanFilePath(filePath, cwd = process.cwd(), options = {}) {
20380
20435
  }
20381
20436
 
20382
20437
  // src/policy/gate-order.ts
20438
+ init_esm_shims();
20383
20439
  var PRE_ENGINE_GATES = ["file", "dlp", "pii", "package"];
20384
20440
  var GATE_LABELS = {
20385
20441
  dlpBlock: "\u{1F6A8} Node9 DLP (Secret Detected)",
@@ -20591,19 +20647,20 @@ function combineWithEngine(gates, engine, opts = { panicMode: false }) {
20591
20647
  }
20592
20648
 
20593
20649
  // src/policy/file-access.ts
20650
+ init_esm_shims();
20594
20651
  init_dist();
20595
20652
  import fs7 from "fs";
20596
20653
  import os5 from "os";
20597
- import path6 from "path";
20654
+ import path7 from "path";
20598
20655
  function absoluteSpelling(p, cwd, home) {
20599
20656
  if (p === "~" || p.startsWith("~/")) p = home + p.slice(1);
20600
- return path6.isAbsolute(p) ? p : `${cwd}/${p}`;
20657
+ return path7.isAbsolute(p) ? p : `${cwd}/${p}`;
20601
20658
  }
20602
20659
  function physical(p, followFinal, links = 0) {
20603
20660
  if (links > 40) throw new Error("Too many symbolic links");
20604
20661
  if (!followFinal) {
20605
- const parent = physical(path6.dirname(p), true, links);
20606
- return { path: `${parent.path}/${path6.basename(p)}`, missing: parent.missing };
20662
+ const parent = physical(path7.dirname(p), true, links);
20663
+ return { path: `${parent.path}/${path7.basename(p)}`, missing: parent.missing };
20607
20664
  }
20608
20665
  try {
20609
20666
  return { path: fs7.realpathSync.native(p), missing: false };
@@ -20614,7 +20671,7 @@ function physical(p, followFinal, links = 0) {
20614
20671
  if (fs7.lstatSync(p).isSymbolicLink()) {
20615
20672
  const target = fs7.readlinkSync(p);
20616
20673
  return physical(
20617
- path6.isAbsolute(target) ? target : `${path6.dirname(p)}/${target}`,
20674
+ path7.isAbsolute(target) ? target : `${path7.dirname(p)}/${target}`,
20618
20675
  true,
20619
20676
  links + 1
20620
20677
  );
@@ -20623,10 +20680,10 @@ function physical(p, followFinal, links = 0) {
20623
20680
  if (!["ENOENT", "ENOTDIR"].includes(linkError.code ?? ""))
20624
20681
  throw linkError;
20625
20682
  }
20626
- const parent = path6.dirname(p);
20683
+ const parent = path7.dirname(p);
20627
20684
  if (parent === p) return { path: p, missing: true };
20628
20685
  const resolved = physical(parent, true, links);
20629
- return { path: `${resolved.path}/${path6.basename(p)}`, missing: true };
20686
+ return { path: `${resolved.path}/${path7.basename(p)}`, missing: true };
20630
20687
  }
20631
20688
  }
20632
20689
  function prepareFileAccesses(tool, args, cwd = process.cwd(), inspection = {}, home = os5.homedir()) {
@@ -20708,23 +20765,26 @@ function prepareFileAccesses(tool, args, cwd = process.cwd(), inspection = {}, h
20708
20765
  }
20709
20766
 
20710
20767
  // src/supply-chain/check.ts
20768
+ init_esm_shims();
20711
20769
  init_dist();
20712
20770
  import picomatch2 from "picomatch";
20713
- import path10 from "path";
20771
+ import path11 from "path";
20714
20772
 
20715
20773
  // src/supply-chain/osv-index.ts
20774
+ init_esm_shims();
20716
20775
  init_dist();
20717
20776
  import fs9 from "fs";
20718
20777
  import os6 from "os";
20719
- import path8 from "path";
20778
+ import path9 from "path";
20720
20779
  import { createHash as createHash4 } from "crypto";
20721
20780
 
20722
20781
  // src/utils/atomic-write.ts
20782
+ init_esm_shims();
20723
20783
  import fs8 from "fs";
20724
- import path7 from "path";
20784
+ import path8 from "path";
20725
20785
  import { randomUUID } from "crypto";
20726
20786
  function atomicWriteSync(filePath, data, options) {
20727
- const dir2 = path7.dirname(filePath);
20787
+ const dir2 = path8.dirname(filePath);
20728
20788
  if (!fs8.existsSync(dir2)) fs8.mkdirSync(dir2, { recursive: true });
20729
20789
  const tmpPath = `${filePath}.${randomUUID()}.tmp`;
20730
20790
  try {
@@ -20750,10 +20810,10 @@ function atomicWriteSync(filePath, data, options) {
20750
20810
  // src/supply-chain/osv-index.ts
20751
20811
  var INDEX_FRESH_MS = 72 * 60 * 60 * 1e3;
20752
20812
  function osvRoot() {
20753
- return path8.join(os6.homedir(), ".node9", "osv");
20813
+ return path9.join(os6.homedir(), ".node9", "osv");
20754
20814
  }
20755
20815
  function ecoDir(eco) {
20756
- return path8.join(osvRoot(), eco);
20816
+ return path9.join(osvRoot(), eco);
20757
20817
  }
20758
20818
  function indexKey(eco, name) {
20759
20819
  switch (eco) {
@@ -20772,11 +20832,11 @@ function shardOf(key) {
20772
20832
  return createHash4("sha1").update(key).digest("hex").slice(0, 2);
20773
20833
  }
20774
20834
  function shardPath(eco, shard) {
20775
- return path8.join(ecoDir(eco), "shards", `${shard}.json`);
20835
+ return path9.join(ecoDir(eco), "shards", `${shard}.json`);
20776
20836
  }
20777
20837
  function readMeta(eco) {
20778
20838
  try {
20779
- const m = JSON.parse(fs9.readFileSync(path8.join(ecoDir(eco), "meta.json"), "utf8"));
20839
+ const m = JSON.parse(fs9.readFileSync(path9.join(ecoDir(eco), "meta.json"), "utf8"));
20780
20840
  if (typeof m?.syncedAt !== "string" || typeof m?.lastModifiedMs !== "number") return null;
20781
20841
  return m;
20782
20842
  } catch {
@@ -20829,7 +20889,11 @@ function entryCovers(entry, version) {
20829
20889
  return (entry.ranges ?? []).some((r) => inRange(version, r));
20830
20890
  }
20831
20891
 
20892
+ // src/supply-chain/osv-online.ts
20893
+ init_esm_shims();
20894
+
20832
20895
  // src/supply-chain/net.ts
20896
+ init_esm_shims();
20833
20897
  var DEFAULTS = {
20834
20898
  osvBucket: "https://osv-vulnerabilities.storage.googleapis.com",
20835
20899
  osvApi: "https://api.osv.dev",
@@ -20911,9 +20975,11 @@ async function queryOsvMalicious(queries) {
20911
20975
  }
20912
20976
 
20913
20977
  // src/supply-chain/registry.ts
20978
+ init_esm_shims();
20914
20979
  import { maxSatisfying, satisfies, validRange } from "semver";
20915
20980
 
20916
20981
  // src/supply-chain/provenance.ts
20982
+ init_esm_shims();
20917
20983
  import { prerelease, rcompare, valid } from "semver";
20918
20984
  var TIMEOUT_MS2 = 1500;
20919
20985
  var MAX_BYTES = 256 * 1024;
@@ -21132,17 +21198,18 @@ async function registryInfo(eco, name, version, freshWindowMs, raw) {
21132
21198
  }
21133
21199
 
21134
21200
  // src/supply-chain/local-resolve.ts
21201
+ init_esm_shims();
21135
21202
  import fs10 from "fs";
21136
- import path9 from "path";
21203
+ import path10 from "path";
21137
21204
  var MAX_LEVELS = 32;
21138
21205
  var LOCAL_FIRST_MANAGERS = /* @__PURE__ */ new Set(["npx", "bunx", "npm exec"]);
21139
21206
  function resolveInstalled(name, cwd) {
21140
- if (!cwd || !path9.isAbsolute(cwd)) return null;
21207
+ if (!cwd || !path10.isAbsolute(cwd)) return null;
21141
21208
  if (!/^(?:@[^/\\]+\/)?[^/\\]+$/.test(name)) return null;
21142
- let dir2 = path9.resolve(cwd);
21209
+ let dir2 = path10.resolve(cwd);
21143
21210
  for (let i = 0; i < MAX_LEVELS; i++) {
21144
- const pkgDir = path9.join(dir2, "node_modules", ...name.split("/"));
21145
- const manifest = path9.join(pkgDir, "package.json");
21211
+ const pkgDir = path10.join(dir2, "node_modules", ...name.split("/"));
21212
+ const manifest = path10.join(pkgDir, "package.json");
21146
21213
  try {
21147
21214
  const raw = fs10.readFileSync(manifest, "utf8");
21148
21215
  const parsed = JSON.parse(raw);
@@ -21152,7 +21219,7 @@ function resolveInstalled(name, cwd) {
21152
21219
  return null;
21153
21220
  } catch {
21154
21221
  }
21155
- const parent = path9.dirname(dir2);
21222
+ const parent = path10.dirname(dir2);
21156
21223
  if (parent === dir2) break;
21157
21224
  dir2 = parent;
21158
21225
  }
@@ -21274,7 +21341,7 @@ function checkInstalled(p, version, misses) {
21274
21341
  }
21275
21342
  async function checkOne(p, cfg, misses, networkCapped, cwd) {
21276
21343
  if (p.ecosystem === "npm" && LOCAL_FIRST_MANAGERS.has(p.manager) && p.localCwd !== null && (p.raw === p.name || p.version)) {
21277
- const localCwd = cwd && path10.isAbsolute(cwd) ? (p.localCwd ?? []).reduce((dir2, step) => path10.resolve(dir2, step), cwd) : void 0;
21344
+ const localCwd = cwd && path11.isAbsolute(cwd) ? (p.localCwd ?? []).reduce((dir2, step) => path11.resolve(dir2, step), cwd) : void 0;
21278
21345
  const installed = resolveInstalled(p.name, localCwd);
21279
21346
  if (installed && (!p.version || p.version === installed.version))
21280
21347
  return checkInstalled(p, installed.version, misses);
@@ -21418,9 +21485,10 @@ async function runPackageCheck(toolName, args, cfg, cwd, opts = {}) {
21418
21485
  }
21419
21486
 
21420
21487
  // src/supply-chain/registries.ts
21488
+ init_esm_shims();
21421
21489
  init_dist();
21422
21490
  import os7 from "os";
21423
- import path11 from "path";
21491
+ import path12 from "path";
21424
21492
  import fs11 from "fs";
21425
21493
  var MAX_CONFIG_BYTES = 256 * 1024;
21426
21494
  var MAX_PARENT_DIRS = 12;
@@ -21462,29 +21530,29 @@ var REGISTRY_KEY_RE = /registry|index|find-links|mirror/i;
21462
21530
  var REGISTRY_SECTION_RE = /index|source|registr|scopes|mirror/i;
21463
21531
  var URL_RE2 = /https?:\/\/[^\s"'<>,;]+/gi;
21464
21532
  function userFiles(home, env) {
21465
- const xdg = env.XDG_CONFIG_HOME || path11.join(home, ".config");
21533
+ const xdg = env.XDG_CONFIG_HOME || path12.join(home, ".config");
21466
21534
  return [
21467
- env.NPM_CONFIG_USERCONFIG || env.npm_config_userconfig || path11.join(home, ".npmrc"),
21468
- path11.join(home, ".yarnrc"),
21469
- path11.join(home, ".yarnrc.yml"),
21470
- path11.join(home, ".bunfig.toml"),
21535
+ env.NPM_CONFIG_USERCONFIG || env.npm_config_userconfig || path12.join(home, ".npmrc"),
21536
+ path12.join(home, ".yarnrc"),
21537
+ path12.join(home, ".yarnrc.yml"),
21538
+ path12.join(home, ".bunfig.toml"),
21471
21539
  env.PIP_CONFIG_FILE || "",
21472
- path11.join(xdg, "pip", "pip.conf"),
21473
- path11.join(home, ".pip", "pip.conf"),
21540
+ path12.join(xdg, "pip", "pip.conf"),
21541
+ path12.join(home, ".pip", "pip.conf"),
21474
21542
  "/etc/pip.conf",
21475
- env.VIRTUAL_ENV ? path11.join(env.VIRTUAL_ENV, "pip.conf") : "",
21543
+ env.VIRTUAL_ENV ? path12.join(env.VIRTUAL_ENV, "pip.conf") : "",
21476
21544
  env.UV_CONFIG_FILE || "",
21477
- path11.join(xdg, "uv", "uv.toml"),
21545
+ path12.join(xdg, "uv", "uv.toml"),
21478
21546
  "/etc/uv/uv.toml"
21479
21547
  ].filter(Boolean);
21480
21548
  }
21481
21549
  function projectFiles(cwd) {
21482
- if (!cwd || !path11.isAbsolute(cwd)) return [];
21550
+ if (!cwd || !path12.isAbsolute(cwd)) return [];
21483
21551
  const out = [];
21484
21552
  let dir2 = cwd;
21485
21553
  for (let i = 0; i < MAX_PARENT_DIRS; i++) {
21486
- for (const f of PROJECT_FILES) out.push(path11.join(dir2, f));
21487
- const parent = path11.dirname(dir2);
21554
+ for (const f of PROJECT_FILES) out.push(path12.join(dir2, f));
21555
+ const parent = path12.dirname(dir2);
21488
21556
  if (parent === dir2) break;
21489
21557
  dir2 = parent;
21490
21558
  }
@@ -21555,25 +21623,26 @@ function configuredRegistryHosts(cwd, env = process.env, home = os7.homedir()) {
21555
21623
  }
21556
21624
 
21557
21625
  // src/utils/provenance.ts
21626
+ init_esm_shims();
21558
21627
  import fs12 from "fs";
21559
- import path12 from "path";
21628
+ import path13 from "path";
21560
21629
  import os8 from "os";
21561
21630
  var SYSTEM_PREFIXES = ["/usr/bin", "/usr/sbin", "/bin", "/sbin"];
21562
21631
  var MANAGED_PREFIXES = ["/usr/local/bin", "/opt/homebrew", "/home/linuxbrew", "/nix/store"];
21563
21632
  var USER_PREFIXES = [
21564
- path12.join(os8.homedir(), "bin"),
21565
- path12.join(os8.homedir(), ".local", "bin"),
21566
- path12.join(os8.homedir(), ".cargo", "bin"),
21567
- path12.join(os8.homedir(), ".npm-global", "bin"),
21568
- path12.join(os8.homedir(), ".volta", "bin")
21633
+ path13.join(os8.homedir(), "bin"),
21634
+ path13.join(os8.homedir(), ".local", "bin"),
21635
+ path13.join(os8.homedir(), ".cargo", "bin"),
21636
+ path13.join(os8.homedir(), ".npm-global", "bin"),
21637
+ path13.join(os8.homedir(), ".volta", "bin")
21569
21638
  ];
21570
21639
  var SUSPECT_PREFIXES = ["/tmp", "/var/tmp", "/dev/shm"];
21571
21640
  function findInPath(cmd) {
21572
- if (path12.posix.isAbsolute(cmd)) return cmd;
21641
+ if (path13.posix.isAbsolute(cmd)) return cmd;
21573
21642
  const pathEnv = process.env.PATH ?? "";
21574
- for (const dir2 of pathEnv.split(path12.delimiter)) {
21643
+ for (const dir2 of pathEnv.split(path13.delimiter)) {
21575
21644
  if (!dir2) continue;
21576
- const full = path12.join(dir2, cmd);
21645
+ const full = path13.join(dir2, cmd);
21577
21646
  try {
21578
21647
  fs12.accessSync(full, fs12.constants.X_OK);
21579
21648
  return full;
@@ -21604,7 +21673,7 @@ function _classifyPath(resolved, cwd) {
21604
21673
  }
21605
21674
  function checkProvenance(cmd, cwd) {
21606
21675
  const bare = cmd.startsWith("./") ? cmd.slice(2) : cmd;
21607
- if (path12.posix.isAbsolute(bare)) {
21676
+ if (path13.posix.isAbsolute(bare)) {
21608
21677
  const early = _classifyPath(bare, cwd);
21609
21678
  if (early.trustLevel === "suspect") {
21610
21679
  return { resolvedPath: bare, ...early };
@@ -21683,9 +21752,9 @@ async function evaluatePolicy2(toolName, args, agent, cwd, opts) {
21683
21752
  );
21684
21753
  }
21685
21754
  function isGitWorkTreeTop(dir2, cwd) {
21686
- if (!path13.isAbsolute(cwd)) return true;
21755
+ if (!path14.isAbsolute(cwd)) return true;
21687
21756
  try {
21688
- return fs13.existsSync(path13.join(path13.resolve(cwd, dir2), ".git"));
21757
+ return fs13.existsSync(path14.join(path14.resolve(cwd, dir2), ".git"));
21689
21758
  } catch {
21690
21759
  return true;
21691
21760
  }
@@ -21704,12 +21773,13 @@ function isIgnoredTool2(toolName) {
21704
21773
  }
21705
21774
 
21706
21775
  // src/auth/state.ts
21776
+ init_esm_shims();
21707
21777
  import fs14 from "fs";
21708
- import path14 from "path";
21778
+ import path15 from "path";
21709
21779
  import os9 from "os";
21710
21780
  init_forecast_context();
21711
- var PAUSED_FILE = path14.join(os9.homedir(), ".node9", "PAUSED");
21712
- var TRUST_FILE = path14.join(os9.homedir(), ".node9", "trust.json");
21781
+ var PAUSED_FILE = path15.join(os9.homedir(), ".node9", "PAUSED");
21782
+ var TRUST_FILE = path15.join(os9.homedir(), ".node9", "trust.json");
21713
21783
  function extractCommandPattern(toolName, args) {
21714
21784
  const lower2 = toolName.toLowerCase();
21715
21785
  if (lower2 !== "bash" && lower2 !== "execute_bash" && lower2 !== "shell") return void 0;
@@ -21786,7 +21856,7 @@ function writeTrustSession(toolName, durationMs, args) {
21786
21856
  }
21787
21857
  function getPersistentDecision(toolName) {
21788
21858
  try {
21789
- const file2 = path14.join(os9.homedir(), ".node9", "decisions.json");
21859
+ const file2 = path15.join(os9.homedir(), ".node9", "decisions.json");
21790
21860
  if (!fs14.existsSync(file2)) return null;
21791
21861
  const decisions = JSON.parse(fs14.readFileSync(file2, "utf-8"));
21792
21862
  const d = decisions[toolName];
@@ -21797,14 +21867,16 @@ function getPersistentDecision(toolName) {
21797
21867
  }
21798
21868
 
21799
21869
  // src/auth/daemon.ts
21870
+ init_esm_shims();
21800
21871
  init_forecast_context();
21801
21872
  import fs15 from "fs";
21802
21873
  import http from "http";
21803
21874
  import net from "net";
21804
- import path15 from "path";
21875
+ import path16 from "path";
21805
21876
  import os10 from "os";
21806
21877
 
21807
21878
  // src/auth/decision-record.ts
21879
+ init_esm_shims();
21808
21880
  var CHANNELS = ["terminal", "monitor", "native", "cloud"];
21809
21881
  var PERSON_CHANNELS = /* @__PURE__ */ new Set([
21810
21882
  "terminal",
@@ -21952,20 +22024,31 @@ function recordFromLegacyWait(body, now = Date.now()) {
21952
22024
  }
21953
22025
 
21954
22026
  // src/auth/daemon.ts
21955
- var ACTIVITY_SOCKET_PATH = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : path15.join(os10.tmpdir(), "node9-activity.sock");
21956
- function notifyActivitySocket(data) {
22027
+ var ACTIVITY_SOCKET_PATH = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : path16.join(os10.tmpdir(), "node9-activity.sock");
22028
+ var ACTIVITY_SOCKET_TIMEOUT_MS = 500;
22029
+ function notifyActivitySocket(data, opts = {}) {
21957
22030
  if (forecastRun()) return Promise.resolve(false);
21958
22031
  return new Promise((resolve) => {
22032
+ let settled = false;
22033
+ let sock = null;
22034
+ const finish = (ok) => {
22035
+ if (settled) return;
22036
+ settled = true;
22037
+ clearTimeout(timer);
22038
+ if (!ok) sock?.destroy();
22039
+ resolve(ok);
22040
+ };
22041
+ const timer = setTimeout(() => finish(false), opts.timeoutMs ?? ACTIVITY_SOCKET_TIMEOUT_MS);
21959
22042
  try {
21960
22043
  const payload = JSON.stringify(data);
21961
- const sock = net.createConnection(ACTIVITY_SOCKET_PATH);
22044
+ sock = net.createConnection(opts.socketPath ?? ACTIVITY_SOCKET_PATH);
21962
22045
  sock.on("connect", () => {
21963
- sock.on("close", () => resolve(true));
22046
+ sock.on("close", () => finish(true));
21964
22047
  sock.end(payload);
21965
22048
  });
21966
- sock.on("error", () => resolve(false));
22049
+ sock.on("error", () => finish(false));
21967
22050
  } catch {
21968
- resolve(false);
22051
+ finish(false);
21969
22052
  }
21970
22053
  });
21971
22054
  }
@@ -21997,7 +22080,7 @@ var DAEMON_HOST = "127.0.0.1";
21997
22080
  function getInternalToken() {
21998
22081
  if (forecastRun()) return null;
21999
22082
  try {
22000
- const pidFile = path15.join(os10.homedir(), ".node9", "daemon.pid");
22083
+ const pidFile = path16.join(os10.homedir(), ".node9", "daemon.pid");
22001
22084
  if (!fs15.existsSync(pidFile)) return null;
22002
22085
  const data = JSON.parse(fs15.readFileSync(pidFile, "utf-8"));
22003
22086
  process.kill(data.pid, 0);
@@ -22008,7 +22091,7 @@ function getInternalToken() {
22008
22091
  }
22009
22092
  function isDaemonRunning() {
22010
22093
  if (forecastRun()) return false;
22011
- const pidFile = path15.join(os10.homedir(), ".node9", "daemon.pid");
22094
+ const pidFile = path16.join(os10.homedir(), ".node9", "daemon.pid");
22012
22095
  if (fs15.existsSync(pidFile)) {
22013
22096
  let pid;
22014
22097
  let port;
@@ -22366,14 +22449,17 @@ async function resolveViaDaemon(id, decision, internalToken, source, record) {
22366
22449
  }
22367
22450
 
22368
22451
  // src/auth/orchestrator.ts
22452
+ init_esm_shims();
22369
22453
  import { randomUUID as randomUUID2 } from "crypto";
22370
22454
 
22371
22455
  // src/apps/state.ts
22456
+ init_esm_shims();
22372
22457
  import fs17 from "fs";
22373
22458
  import os12 from "os";
22374
- import path17 from "path";
22459
+ import path18 from "path";
22375
22460
 
22376
22461
  // src/apps/catalog.ts
22462
+ init_esm_shims();
22377
22463
  var APP_CATALOG = [
22378
22464
  {
22379
22465
  slug: "redis",
@@ -22503,11 +22589,17 @@ var APP_BY_SLUG = new Map(
22503
22589
  init_audit();
22504
22590
 
22505
22591
  // src/daemon/mcp-tools.ts
22592
+ init_esm_shims();
22506
22593
  import fs16 from "fs";
22507
- import path16 from "path";
22594
+ import path17 from "path";
22508
22595
  import os11 from "os";
22596
+
22597
+ // src/mcp-cmd.ts
22598
+ init_esm_shims();
22599
+
22600
+ // src/daemon/mcp-tools.ts
22509
22601
  function getMcpToolsFile() {
22510
- return path16.join(os11.homedir(), ".node9", "mcp-tools.json");
22602
+ return path17.join(os11.homedir(), ".node9", "mcp-tools.json");
22511
22603
  }
22512
22604
  function readMcpToolsConfig() {
22513
22605
  try {
@@ -22522,7 +22614,7 @@ function readMcpToolsConfig() {
22522
22614
 
22523
22615
  // src/apps/state.ts
22524
22616
  function appsFilePath(home = os12.homedir()) {
22525
- return path17.join(home, ".node9", "apps.json");
22617
+ return path18.join(home, ".node9", "apps.json");
22526
22618
  }
22527
22619
  var SIGNAL_KINDS = /* @__PURE__ */ new Set(["mcp-server", "command", "package", "env-name"]);
22528
22620
  function emptyFile() {
@@ -22626,14 +22718,16 @@ function resolveLinkedServer(label2, opts = {}) {
22626
22718
 
22627
22719
  // src/auth/orchestrator.ts
22628
22720
  import os21 from "os";
22629
- import path30 from "path";
22721
+ import path31 from "path";
22630
22722
 
22631
22723
  // src/ui/native.ts
22724
+ init_esm_shims();
22632
22725
  import { spawn } from "child_process";
22633
- import path19 from "path";
22726
+ import path20 from "path";
22634
22727
 
22635
22728
  // src/context-sniper.ts
22636
- import path18 from "path";
22729
+ init_esm_shims();
22730
+ import path19 from "path";
22637
22731
  function smartTruncate(str, maxLen = 500) {
22638
22732
  if (str.length <= maxLen) return str;
22639
22733
  const edge = Math.floor(maxLen / 2) - 3;
@@ -22701,7 +22795,7 @@ function computeRiskMetadata(args, tier, blockedByLabel, matchedField, matchedWo
22701
22795
  intent = "EDIT";
22702
22796
  if (obj.file_path) {
22703
22797
  editFilePath = String(obj.file_path);
22704
- editFileName = path18.basename(editFilePath);
22798
+ editFileName = path19.basename(editFilePath);
22705
22799
  }
22706
22800
  const result = extractContext(String(obj.new_string), matchedWord);
22707
22801
  contextSnippet = result.snippet;
@@ -22735,6 +22829,7 @@ function computeRiskMetadata(args, tier, blockedByLabel, matchedField, matchedWo
22735
22829
  }
22736
22830
 
22737
22831
  // src/utils/safe-text.ts
22832
+ init_esm_shims();
22738
22833
  init_dist();
22739
22834
 
22740
22835
  // src/ui/native.ts
@@ -22769,7 +22864,7 @@ function formatArgs(args, matchedField, matchedWord) {
22769
22864
  if (typeof parsed === "object" && !Array.isArray(parsed)) {
22770
22865
  const obj = parsed;
22771
22866
  if (obj.old_string !== void 0 && obj.new_string !== void 0) {
22772
- const file2 = obj.file_path ? path19.basename(String(obj.file_path)) : "file";
22867
+ const file2 = obj.file_path ? path20.basename(String(obj.file_path)) : "file";
22773
22868
  const oldPreview = smartTruncate(String(obj.old_string), 120);
22774
22869
  const newPreview = extractContext(String(obj.new_string), matchedWord).snippet;
22775
22870
  return {
@@ -22972,19 +23067,21 @@ end run`;
22972
23067
  }
22973
23068
 
22974
23069
  // src/canary/registry.ts
23070
+ init_esm_shims();
22975
23071
  import fs19 from "fs";
22976
23072
  import os14 from "os";
22977
- import path21 from "path";
23073
+ import path22 from "path";
22978
23074
  init_dist();
22979
23075
 
22980
23076
  // src/shields/jail.ts
23077
+ init_esm_shims();
22981
23078
  import fs18 from "fs";
22982
23079
  import os13 from "os";
22983
- import path20 from "path";
23080
+ import path21 from "path";
22984
23081
  init_dist();
22985
23082
  var USER_JAIL_SHIELD = "user-jail";
22986
23083
  function jailStorePath() {
22987
- return path20.join(os13.homedir(), ".node9", "jail-paths.json");
23084
+ return path21.join(os13.homedir(), ".node9", "jail-paths.json");
22988
23085
  }
22989
23086
  function readJailPaths() {
22990
23087
  let text;
@@ -23018,7 +23115,7 @@ function findJailedPathIn(candidate, paths) {
23018
23115
 
23019
23116
  // src/canary/registry.ts
23020
23117
  function canaryStorePath() {
23021
- return path21.join(os14.homedir(), ".node9", "canaries.json");
23118
+ return path22.join(os14.homedir(), ".node9", "canaries.json");
23022
23119
  }
23023
23120
  function isRecord(x) {
23024
23121
  if (!x || typeof x !== "object") return false;
@@ -23055,10 +23152,11 @@ function canaryValues() {
23055
23152
  init_dist();
23056
23153
 
23057
23154
  // src/auth/session-script.ts
23155
+ init_esm_shims();
23058
23156
  init_dist();
23059
23157
  import fs20 from "fs";
23060
23158
  import os15 from "os";
23061
- import path22 from "path";
23159
+ import path23 from "path";
23062
23160
  var MAX_SCRIPT_BYTES = 64 * 1024;
23063
23161
  var MAX_RECORDED_WRITES = 32;
23064
23162
  function readScriptFile(resolved) {
@@ -23089,7 +23187,7 @@ function readScriptFile(resolved) {
23089
23187
  }
23090
23188
  function absolute(p, cwd, home) {
23091
23189
  const spelled = p === "~" || p.startsWith("~/") ? home + p.slice(1) : p;
23092
- return path22.resolve(cwd, spelled);
23190
+ return path23.resolve(cwd, spelled);
23093
23191
  }
23094
23192
  async function resolveSessionScript(toolName, args, cwd, layers, deps, home = os15.homedir()) {
23095
23193
  try {
@@ -23150,13 +23248,15 @@ init_audit();
23150
23248
  init_dist();
23151
23249
 
23152
23250
  // src/exposure/known-hosts.ts
23251
+ init_esm_shims();
23153
23252
  import fs22 from "fs";
23154
- import path24 from "path";
23253
+ import path25 from "path";
23155
23254
 
23156
23255
  // src/utils/git-remotes.ts
23256
+ init_esm_shims();
23157
23257
  init_dist();
23158
23258
  import fs21 from "fs";
23159
- import path23 from "path";
23259
+ import path24 from "path";
23160
23260
  function readSmallFile(p, max) {
23161
23261
  let fd;
23162
23262
  try {
@@ -23188,20 +23288,20 @@ function gitRemoteHost(url) {
23188
23288
  return null;
23189
23289
  }
23190
23290
  function findGitConfig(dir2, walkUp = true) {
23191
- let cur = path23.resolve(dir2);
23291
+ let cur = path24.resolve(dir2);
23192
23292
  for (let i = 0; i < (walkUp ? 64 : 1); i++) {
23193
- const dotGit = path23.join(cur, ".git");
23194
- const direct = readSmallFile(path23.join(dotGit, "config"), 1e6);
23293
+ const dotGit = path24.join(cur, ".git");
23294
+ const direct = readSmallFile(path24.join(dotGit, "config"), 1e6);
23195
23295
  if (direct !== null) return direct;
23196
23296
  const pointer = readSmallFile(dotGit, 4096);
23197
23297
  const m = pointer && /^gitdir:\s*(.+?)\s*$/m.exec(pointer);
23198
23298
  if (m) {
23199
- let gitDir = path23.resolve(cur, m[1]);
23200
- const common = readSmallFile(path23.join(gitDir, "commondir"), 4096);
23201
- if (common !== null) gitDir = path23.resolve(gitDir, common.trim());
23202
- return readSmallFile(path23.join(gitDir, "config"), 1e6);
23299
+ let gitDir = path24.resolve(cur, m[1]);
23300
+ const common = readSmallFile(path24.join(gitDir, "commondir"), 4096);
23301
+ if (common !== null) gitDir = path24.resolve(gitDir, common.trim());
23302
+ return readSmallFile(path24.join(gitDir, "config"), 1e6);
23203
23303
  }
23204
- const parent = path23.dirname(cur);
23304
+ const parent = path24.dirname(cur);
23205
23305
  if (parent === cur) return null;
23206
23306
  cur = parent;
23207
23307
  }
@@ -23211,12 +23311,12 @@ var cache4 = /* @__PURE__ */ new Map();
23211
23311
  function readGitRemotes(dir2, opts = {}) {
23212
23312
  if (!dir2) return [];
23213
23313
  const walkUp = opts.walkUp !== false;
23214
- const key = `${walkUp ? "up" : "at"}:${path23.resolve(dir2)}`;
23314
+ const key = `${walkUp ? "up" : "at"}:${path24.resolve(dir2)}`;
23215
23315
  const hit = cache4.get(key);
23216
23316
  if (hit) return hit;
23217
23317
  const out = [];
23218
23318
  try {
23219
- const cfg = findGitConfig(path23.resolve(dir2), walkUp);
23319
+ const cfg = findGitConfig(path24.resolve(dir2), walkUp);
23220
23320
  if (cfg !== null) {
23221
23321
  let current = null;
23222
23322
  for (const line of cfg.split(/\r?\n/)) {
@@ -23252,15 +23352,15 @@ var ECOSYSTEMS = [
23252
23352
  ];
23253
23353
  var cache5 = /* @__PURE__ */ new Map();
23254
23354
  function manifestRoot(dir2) {
23255
- let cur = path24.resolve(dir2);
23355
+ let cur = path25.resolve(dir2);
23256
23356
  for (let i = 0; i < 64; i++) {
23257
23357
  for (const [m] of ECOSYSTEMS) {
23258
23358
  try {
23259
- if (fs22.existsSync(path24.join(cur, m))) return cur;
23359
+ if (fs22.existsSync(path25.join(cur, m))) return cur;
23260
23360
  } catch {
23261
23361
  }
23262
23362
  }
23263
- const parent = path24.dirname(cur);
23363
+ const parent = path25.dirname(cur);
23264
23364
  if (parent === cur) return null;
23265
23365
  cur = parent;
23266
23366
  }
@@ -23269,7 +23369,7 @@ function manifestRoot(dir2) {
23269
23369
  function knownProjectHosts(dir2) {
23270
23370
  const empty = { hosts: /* @__PURE__ */ new Set(), repos: /* @__PURE__ */ new Set(), remotes: /* @__PURE__ */ new Map() };
23271
23371
  if (!dir2) return empty;
23272
- const key = path24.resolve(dir2);
23372
+ const key = path25.resolve(dir2);
23273
23373
  const hit = cache5.get(key);
23274
23374
  if (hit) return hit;
23275
23375
  const out = { hosts: /* @__PURE__ */ new Set(), repos: /* @__PURE__ */ new Set(), remotes: /* @__PURE__ */ new Map() };
@@ -23282,7 +23382,7 @@ function knownProjectHosts(dir2) {
23282
23382
  const root = manifestRoot(key);
23283
23383
  if (root !== null) {
23284
23384
  for (const [m, registry] of ECOSYSTEMS) {
23285
- if (fs22.existsSync(path24.join(root, m))) out.hosts.add(registry);
23385
+ if (fs22.existsSync(path25.join(root, m))) out.hosts.add(registry);
23286
23386
  }
23287
23387
  try {
23288
23388
  if (fs22.readdirSync(root).some((f) => f.endsWith(".gemspec")))
@@ -23297,10 +23397,11 @@ function knownProjectHosts(dir2) {
23297
23397
  }
23298
23398
 
23299
23399
  // src/exposure/writes.ts
23400
+ init_esm_shims();
23300
23401
  init_dist();
23301
23402
  import fs23 from "fs";
23302
23403
  import os16 from "os";
23303
- import path25 from "path";
23404
+ import path26 from "path";
23304
23405
  var WRITE_OPS = /* @__PURE__ */ new Set(["write", "create", "remove"]);
23305
23406
  var LIFECYCLE_RE = /"(scripts|preinstall|install|postinstall|prepare|prepublish|prepublishOnly|prepack|postpack|publish|postpublish)"\s*:/;
23306
23407
  function writtenContent(args) {
@@ -23350,7 +23451,7 @@ function judgeWritesAfterExposure(opts) {
23350
23451
  seen.add(p);
23351
23452
  if (p === "/dev" || p.startsWith("/dev/")) continue;
23352
23453
  if (root !== null && isInside(root, p)) {
23353
- if (isAgentInstructionPath(p, root) && (path25.basename(p) !== "package.json" || packageScriptsTouched(opts.args, p, opts.shellCommand)))
23454
+ if (isAgentInstructionPath(p, root) && (path26.basename(p) !== "package.json" || packageScriptsTouched(opts.args, p, opts.shellCommand)))
23354
23455
  holds.push({ path: p, why: "agent-instruction" });
23355
23456
  continue;
23356
23457
  }
@@ -23371,22 +23472,24 @@ function judgeWritesAfterExposure(opts) {
23371
23472
  }
23372
23473
 
23373
23474
  // src/exposure/marker.ts
23475
+ init_esm_shims();
23374
23476
  import crypto3 from "crypto";
23375
23477
  import fs24 from "fs";
23376
23478
  import os17 from "os";
23377
- import path26 from "path";
23479
+ import path27 from "path";
23378
23480
 
23379
23481
  // src/daemon/exposure-store.ts
23482
+ init_esm_shims();
23380
23483
  var SESSION_EXPOSURE_TTL_MS = 4 * 60 * 60 * 1e3;
23381
23484
 
23382
23485
  // src/exposure/marker.ts
23383
23486
  init_forecast_context();
23384
23487
  function dir() {
23385
- return path26.join(os17.homedir(), ".node9", "exposure-sessions");
23488
+ return path27.join(os17.homedir(), ".node9", "exposure-sessions");
23386
23489
  }
23387
23490
  function file(sessionId) {
23388
23491
  const id = crypto3.createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
23389
- return path26.join(dir(), id);
23492
+ return path27.join(dir(), id);
23390
23493
  }
23391
23494
  function maybeSessionExposed(sessionId) {
23392
23495
  if (!sessionId) return false;
@@ -23401,6 +23504,7 @@ function maybeSessionExposed(sessionId) {
23401
23504
  }
23402
23505
 
23403
23506
  // src/exposure/roles.ts
23507
+ init_esm_shims();
23404
23508
  import fs25 from "fs";
23405
23509
  var EXPOSURE_LABEL = "\u{1F6E1}\uFE0F Node9 Exposure";
23406
23510
  var AGENT_INTERNAL_PREFIXES = ["ccd_", "visualize"];
@@ -23495,12 +23599,13 @@ function sourceWord(toolName) {
23495
23599
  }
23496
23600
 
23497
23601
  // src/auth/trusted-recipients.ts
23602
+ init_esm_shims();
23498
23603
  init_dist();
23499
23604
  import fs26 from "fs";
23500
- import path27 from "path";
23605
+ import path28 from "path";
23501
23606
  import os18 from "os";
23502
23607
  function getTrustedRecipientsPath() {
23503
- return path27.join(os18.homedir(), ".node9", "trusted-recipients.json");
23608
+ return path28.join(os18.homedir(), ".node9", "trusted-recipients.json");
23504
23609
  }
23505
23610
  function readTrustedRecipients() {
23506
23611
  try {
@@ -23513,7 +23618,7 @@ function readTrustedRecipients() {
23513
23618
  }
23514
23619
  function writeTrustedRecipients(entries) {
23515
23620
  const filePath = getTrustedRecipientsPath();
23516
- fs26.mkdirSync(path27.dirname(filePath), { recursive: true });
23621
+ fs26.mkdirSync(path28.dirname(filePath), { recursive: true });
23517
23622
  const tmp = filePath + ".node9-tmp";
23518
23623
  fs26.writeFileSync(tmp, JSON.stringify({ entries }, null, 2), { mode: 384 });
23519
23624
  fs26.renameSync(tmp, filePath);
@@ -23548,10 +23653,11 @@ function isTrustedRecipient(value) {
23548
23653
  init_forecast_context();
23549
23654
 
23550
23655
  // src/auth/cloud.ts
23656
+ init_esm_shims();
23551
23657
  init_audit();
23552
23658
  import fs27 from "fs";
23553
23659
  import os19 from "os";
23554
- import path28 from "path";
23660
+ import path29 from "path";
23555
23661
  init_dist();
23556
23662
  var CLOUD_ARRAY_KEYS = /* @__PURE__ */ new Set(["exposureDestinations", "exposureDestinationHashes"]);
23557
23663
  function maskArgsForCloud(args) {
@@ -23586,7 +23692,7 @@ async function initNode9SaaS(toolName, args, creds, meta, riskMetadata, agentPol
23586
23692
  let ciContext;
23587
23693
  if (process.env.CI) {
23588
23694
  try {
23589
- const ciContextPath = path28.join(os19.homedir(), ".node9", "ci-context.json");
23695
+ const ciContextPath = path29.join(os19.homedir(), ".node9", "ci-context.json");
23590
23696
  const ci = readCappedText(ciContextPath, 1e4);
23591
23697
  if (!ci) throw new Error("ci-context.json unreadable");
23592
23698
  if (ci.truncated) throw new Error("ci-context.json exceeds 10 KB");
@@ -23720,14 +23826,15 @@ async function resolveNode9SaaS(requestId, creds, approved, decidedBy) {
23720
23826
  }
23721
23827
 
23722
23828
  // src/loop-detector.ts
23829
+ init_esm_shims();
23723
23830
  init_dist();
23724
23831
  init_forecast_context();
23725
23832
  init_dist();
23726
23833
  import fs28 from "fs";
23727
- import path29 from "path";
23834
+ import path30 from "path";
23728
23835
  import os20 from "os";
23729
23836
  function loopStateFile() {
23730
- return path29.join(os20.homedir(), ".node9", "loop-state.json");
23837
+ return path30.join(os20.homedir(), ".node9", "loop-state.json");
23731
23838
  }
23732
23839
  function readState() {
23733
23840
  try {
@@ -23741,7 +23848,7 @@ function readState() {
23741
23848
  }
23742
23849
  }
23743
23850
  function writeState(records) {
23744
- const dir2 = path29.dirname(loopStateFile());
23851
+ const dir2 = path30.dirname(loopStateFile());
23745
23852
  if (!fs28.existsSync(dir2)) fs28.mkdirSync(dir2, { recursive: true });
23746
23853
  const tmpPath = `${loopStateFile()}.${os20.hostname()}.${process.pid}.tmp`;
23747
23854
  fs28.writeFileSync(tmpPath, JSON.stringify(records));
@@ -23771,6 +23878,7 @@ function recordAndCheck(tool, args, threshold = 3, windowMs = 12e4) {
23771
23878
  }
23772
23879
 
23773
23880
  // src/policy/negotiation.ts
23881
+ init_esm_shims();
23774
23882
  var BLOCKED_BY = " is blocked by ";
23775
23883
  var DASH_BLOCKED_BY = " \u2014 blocked by ";
23776
23884
  var SHIELD = " shield";
@@ -23789,6 +23897,7 @@ function asApprovalRequest(description) {
23789
23897
  }
23790
23898
 
23791
23899
  // src/auth/card-result.ts
23900
+ init_esm_shims();
23792
23901
  var CHANNEL_NAMES = {
23793
23902
  terminal: "Terminal (node9 tail)",
23794
23903
  monitor: "node9 monitor",
@@ -23941,9 +24050,9 @@ function isMcpToolName(toolName) {
23941
24050
  return /^mcp__[^_](?:[^_]|_(?!_))*?__/i.test(toolName);
23942
24051
  }
23943
24052
  function absoluteUploadPath(spelled, cwd) {
23944
- const expanded = spelled === "~" || spelled.startsWith("~/") ? path30.join(os21.homedir(), spelled.slice(1)) : spelled;
23945
- if (path30.isAbsolute(expanded)) return expanded;
23946
- return cwd && path30.isAbsolute(cwd) ? path30.resolve(cwd, expanded) : expanded;
24053
+ const expanded = spelled === "~" || spelled.startsWith("~/") ? path31.join(os21.homedir(), spelled.slice(1)) : spelled;
24054
+ if (path31.isAbsolute(expanded)) return expanded;
24055
+ return cwd && path31.isAbsolute(cwd) ? path31.resolve(cwd, expanded) : expanded;
23947
24056
  }
23948
24057
  function extractFilePaths(toolName, args, shellCommand) {
23949
24058
  const paths = [];