@astrasyncai/verification-gateway 3.11.0 → 3.11.1

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.
Files changed (73) hide show
  1. package/dist/adapter-interface/interface.d.mts +1 -1
  2. package/dist/adapter-interface/interface.d.ts +1 -1
  3. package/dist/adapters/express.js +1 -1
  4. package/dist/adapters/express.js.map +1 -1
  5. package/dist/adapters/express.mjs +1 -1
  6. package/dist/adapters/express.mjs.map +1 -1
  7. package/dist/adapters/mcp.js +1 -1
  8. package/dist/adapters/mcp.js.map +1 -1
  9. package/dist/adapters/mcp.mjs +1 -1
  10. package/dist/adapters/mcp.mjs.map +1 -1
  11. package/dist/adapters/nextjs.js +1 -1
  12. package/dist/adapters/nextjs.js.map +1 -1
  13. package/dist/adapters/nextjs.mjs +1 -1
  14. package/dist/adapters/nextjs.mjs.map +1 -1
  15. package/dist/adapters/sdk.js +1 -1
  16. package/dist/adapters/sdk.js.map +1 -1
  17. package/dist/adapters/sdk.mjs +1 -1
  18. package/dist/adapters/sdk.mjs.map +1 -1
  19. package/dist/bin/astrasync-claude-hook.js +63 -19
  20. package/dist/bin/astrasync-codex-hook.js +63 -19
  21. package/dist/bin/astrasync-guard.js +63 -19
  22. package/dist/bin/astrasync.js +63 -19
  23. package/dist/browser/background.js +63 -19
  24. package/dist/browser/background.js.map +1 -1
  25. package/dist/browser/background.mjs +63 -19
  26. package/dist/browser/background.mjs.map +1 -1
  27. package/dist/browser/browser-adapter.d.mts +1 -1
  28. package/dist/browser/browser-adapter.d.ts +1 -1
  29. package/dist/claude-code/claude-code-adapter.d.mts +1 -1
  30. package/dist/claude-code/claude-code-adapter.d.ts +1 -1
  31. package/dist/cli/index.d.mts +1 -1
  32. package/dist/cli/index.d.ts +1 -1
  33. package/dist/codex/index.d.mts +1 -1
  34. package/dist/codex/index.d.ts +1 -1
  35. package/dist/codex/index.js +63 -19
  36. package/dist/codex/index.js.map +1 -1
  37. package/dist/codex/index.mjs +63 -19
  38. package/dist/codex/index.mjs.map +1 -1
  39. package/dist/cursor/cursor-adapter.d.mts +1 -1
  40. package/dist/cursor/cursor-adapter.d.ts +1 -1
  41. package/dist/cursor/extension.d.mts +1 -1
  42. package/dist/cursor/extension.d.ts +1 -1
  43. package/dist/cursor/extension.js +63 -19
  44. package/dist/cursor/extension.js.map +1 -1
  45. package/dist/cursor/extension.mjs +63 -19
  46. package/dist/cursor/extension.mjs.map +1 -1
  47. package/dist/gateway/gateway.d.mts +1 -1
  48. package/dist/gateway/gateway.d.ts +1 -1
  49. package/dist/gateway/gateway.js +63 -19
  50. package/dist/gateway/gateway.js.map +1 -1
  51. package/dist/gateway/gateway.mjs +63 -19
  52. package/dist/gateway/gateway.mjs.map +1 -1
  53. package/dist/git-trigger/git-hooks.d.mts +1 -1
  54. package/dist/git-trigger/git-hooks.d.ts +1 -1
  55. package/dist/index.d.mts +1 -1
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +1 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.mjs +1 -1
  60. package/dist/index.mjs.map +1 -1
  61. package/dist/local-evaluator/evaluator.d.mts +10 -1
  62. package/dist/local-evaluator/evaluator.d.ts +10 -1
  63. package/dist/local-evaluator/evaluator.js +20 -9
  64. package/dist/local-evaluator/evaluator.js.map +1 -1
  65. package/dist/local-evaluator/evaluator.mjs +20 -9
  66. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  67. package/dist/{types-C23_uaY8.d.ts → types-DhFPiZ3t.d.ts} +6 -1
  68. package/dist/{types-BV6abBnF.d.mts → types-cQVCMeNV.d.mts} +6 -1
  69. package/dist/verify.js +1 -1
  70. package/dist/verify.js.map +1 -1
  71. package/dist/verify.mjs +1 -1
  72. package/dist/verify.mjs.map +1 -1
  73. package/package.json +1 -1
@@ -404,8 +404,9 @@ function extractBacktickSubstitutions(text, collect) {
404
404
  return kept.join(" ");
405
405
  }
406
406
  function basename(token) {
407
- const slash = token.lastIndexOf("/");
408
- return slash === -1 ? token : token.slice(slash + 1);
407
+ const slash = Math.max(token.lastIndexOf("/"), token.lastIndexOf("\\"));
408
+ const name = slash === -1 ? token : token.slice(slash + 1);
409
+ return name.replace(/\.(exe|cmd|bat|ps1)$/i, "");
409
410
  }
410
411
  function matchSegment(segment, list) {
411
412
  const tokens = segment.split(/\s+/).filter((t) => /[a-z0-9]/.test(t));
@@ -538,7 +539,9 @@ var LocalEvaluator = class {
538
539
  }
539
540
  return {
540
541
  recommendation: "ALLOW",
541
- reason: "All PDLSS checks passed",
542
+ // "evaluated": dimensions absent from the policy are skipped, not
543
+ // failed — evaluatedDimensions below records which ones ran.
544
+ reason: "All evaluated PDLSS checks passed",
542
545
  evaluatedDimensions: {
543
546
  purpose: true,
544
547
  scope: !!this.policy.scope,
@@ -637,7 +640,7 @@ var LocalEvaluator = class {
637
640
  }
638
641
  }
639
642
  if ((context.purpose === "file.read" || context.purpose === "file.write" || context.purpose === "file.delete") && context.target) {
640
- const targetLower = context.target.toLowerCase();
643
+ const targetLower = context.target.toLowerCase().replace(/\\/g, "/");
641
644
  for (const sensitivePath of SENSITIVE_PATHS) {
642
645
  if (targetLower.includes(sensitivePath.toLowerCase())) {
643
646
  score = Math.max(score, 50);
@@ -666,12 +669,20 @@ var LocalEvaluator = class {
666
669
  matchesAnyPattern(value, patterns) {
667
670
  return patterns.some((pattern) => this.matchGlob(value, pattern));
668
671
  }
669
- /**
670
- * Simple glob pattern matching.
671
- * Supports * (matches any characters including / and spaces) and ? (single char).
672
- * Uses the same approach as the backend's matchGlobPattern.
673
- */
672
+ homePrefix() {
673
+ if (this.cachedHomePrefix !== void 0) return this.cachedHomePrefix;
674
+ const env = typeof process !== "undefined" ? process.env : void 0;
675
+ const home = env?.HOME || env?.USERPROFILE;
676
+ this.cachedHomePrefix = home ? home.replace(/\\/g, "/") : null;
677
+ return this.cachedHomePrefix;
678
+ }
674
679
  matchGlob(value, pattern) {
680
+ value = value.replace(/\\/g, "/");
681
+ pattern = pattern.replace(/\\/g, "/");
682
+ if (pattern === "~" || pattern.startsWith("~/")) {
683
+ const home = this.homePrefix();
684
+ if (home) pattern = home + pattern.slice(1);
685
+ }
675
686
  if (pattern === value) return true;
676
687
  const starCount = (pattern.match(/\*/g) ?? []).length;
677
688
  if (starCount > 8) {
@@ -3944,7 +3955,7 @@ function getTrustLevel(score) {
3944
3955
  }
3945
3956
 
3946
3957
  // src/version.ts
3947
- var SDK_VERSION = "3.11.0";
3958
+ var SDK_VERSION = "3.11.1";
3948
3959
 
3949
3960
  // src/well-known.ts
3950
3961
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4711,13 +4722,29 @@ var TraceLogger = class {
4711
4722
  */
4712
4723
  logEvaluation(context, decision) {
4713
4724
  if (!this.enabled) return;
4714
- this.write({
4715
- id: this.generateId(),
4716
- timestamp: /* @__PURE__ */ new Date(),
4717
- type: "evaluation",
4718
- context: redactDeep(context),
4719
- decision: redactDeep(decision)
4720
- });
4725
+ let event;
4726
+ try {
4727
+ event = {
4728
+ id: this.generateId(),
4729
+ timestamp: /* @__PURE__ */ new Date(),
4730
+ type: "evaluation",
4731
+ context: redactDeep(context),
4732
+ decision: redactDeep(decision)
4733
+ };
4734
+ } catch (err) {
4735
+ event = {
4736
+ id: this.generateId(),
4737
+ timestamp: /* @__PURE__ */ new Date(),
4738
+ type: "error",
4739
+ metadata: {
4740
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4741
+ recommendation: decision.recommendation,
4742
+ purpose: context.purpose,
4743
+ action: context.action
4744
+ }
4745
+ };
4746
+ }
4747
+ this.write(event);
4721
4748
  }
4722
4749
  /**
4723
4750
  * Log a tool call the guard saw but did not govern. One line per skip
@@ -4759,17 +4786,34 @@ var TraceLogger = class {
4759
4786
  });
4760
4787
  }
4761
4788
  write(event) {
4789
+ let line;
4790
+ try {
4791
+ line = JSON.stringify(event) + "\n";
4792
+ } catch {
4793
+ return;
4794
+ }
4762
4795
  try {
4763
4796
  const filePath = this.getCurrentFilePath();
4764
- const line = JSON.stringify(event) + "\n";
4765
4797
  if (existsSync2(filePath)) {
4766
4798
  const stats = statSync(filePath);
4767
4799
  if (stats.size > MAX_FILE_SIZE) {
4768
4800
  this.rotate();
4769
4801
  }
4770
4802
  }
4771
- appendFileSync(filePath, line);
4803
+ for (let attempt = 0; attempt < 3; attempt++) {
4804
+ try {
4805
+ appendFileSync(filePath, line);
4806
+ return;
4807
+ } catch {
4808
+ }
4809
+ }
4810
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4811
+ appendFileSync(fallbackPath, line);
4772
4812
  } catch {
4813
+ try {
4814
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4815
+ } catch {
4816
+ }
4773
4817
  }
4774
4818
  }
4775
4819
  getCurrentFilePath() {