@astrasyncai/verification-gateway 3.10.1 → 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 (77) 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 +105 -27
  20. package/dist/bin/astrasync-codex-hook.js +5151 -0
  21. package/dist/bin/astrasync-guard.js +234 -32
  22. package/dist/bin/astrasync.js +242 -32
  23. package/dist/browser/background.js +84 -17
  24. package/dist/browser/background.js.map +1 -1
  25. package/dist/browser/background.mjs +84 -17
  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/claude-code/claude-code-adapter.js +9 -1
  32. package/dist/claude-code/claude-code-adapter.js.map +1 -1
  33. package/dist/claude-code/claude-code-adapter.mjs +9 -1
  34. package/dist/claude-code/claude-code-adapter.mjs.map +1 -1
  35. package/dist/cli/index.d.mts +1 -1
  36. package/dist/cli/index.d.ts +1 -1
  37. package/dist/codex/index.d.mts +230 -0
  38. package/dist/codex/index.d.ts +230 -0
  39. package/dist/codex/index.js +5269 -0
  40. package/dist/codex/index.js.map +1 -0
  41. package/dist/codex/index.mjs +5241 -0
  42. package/dist/codex/index.mjs.map +1 -0
  43. package/dist/cursor/cursor-adapter.d.mts +1 -1
  44. package/dist/cursor/cursor-adapter.d.ts +1 -1
  45. package/dist/cursor/extension.d.mts +1 -1
  46. package/dist/cursor/extension.d.ts +1 -1
  47. package/dist/cursor/extension.js +84 -17
  48. package/dist/cursor/extension.js.map +1 -1
  49. package/dist/cursor/extension.mjs +84 -17
  50. package/dist/cursor/extension.mjs.map +1 -1
  51. package/dist/gateway/gateway.d.mts +6 -1
  52. package/dist/gateway/gateway.d.ts +6 -1
  53. package/dist/gateway/gateway.js +84 -17
  54. package/dist/gateway/gateway.js.map +1 -1
  55. package/dist/gateway/gateway.mjs +84 -17
  56. package/dist/gateway/gateway.mjs.map +1 -1
  57. package/dist/git-trigger/git-hooks.d.mts +1 -1
  58. package/dist/git-trigger/git-hooks.d.ts +1 -1
  59. package/dist/index.d.mts +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +1 -1
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/local-evaluator/evaluator.d.mts +10 -1
  66. package/dist/local-evaluator/evaluator.d.ts +10 -1
  67. package/dist/local-evaluator/evaluator.js +20 -9
  68. package/dist/local-evaluator/evaluator.js.map +1 -1
  69. package/dist/local-evaluator/evaluator.mjs +20 -9
  70. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  71. package/dist/{types-C23_uaY8.d.ts → types-DhFPiZ3t.d.ts} +6 -1
  72. package/dist/{types-BV6abBnF.d.mts → types-cQVCMeNV.d.mts} +6 -1
  73. package/dist/verify.js +1 -1
  74. package/dist/verify.js.map +1 -1
  75. package/dist/verify.mjs +1 -1
  76. package/dist/verify.mjs.map +1 -1
  77. package/package.json +8 -2
@@ -1,4 +1,4 @@
1
- import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-BV6abBnF.mjs';
1
+ import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-cQVCMeNV.mjs';
2
2
  import '../types-sy3tq8lp.mjs';
3
3
  import '../metadata-capture.mjs';
4
4
 
@@ -91,6 +91,11 @@ declare class AstraSyncGateway {
91
91
  pending: number;
92
92
  total: number;
93
93
  } | null;
94
+ /**
95
+ * Record a tool call the calling adapter saw but did not govern
96
+ * (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
97
+ */
98
+ logSkippedTool(toolName: string, reason: string): void;
94
99
  }
95
100
 
96
101
  export { AstraSyncGateway };
@@ -1,4 +1,4 @@
1
- import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-C23_uaY8.js';
1
+ import { a as AstraSyncGatewayConfig, P as PDLSSContext, V as VerificationDecision } from '../types-DhFPiZ3t.js';
2
2
  import '../types-9tns4wyl.js';
3
3
  import '../metadata-capture.js';
4
4
 
@@ -91,6 +91,11 @@ declare class AstraSyncGateway {
91
91
  pending: number;
92
92
  total: number;
93
93
  } | null;
94
+ /**
95
+ * Record a tool call the calling adapter saw but did not govern
96
+ * (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
97
+ */
98
+ logSkippedTool(toolName: string, reason: string): void;
94
99
  }
95
100
 
96
101
  export { AstraSyncGateway };
@@ -147,8 +147,9 @@ function extractBacktickSubstitutions(text, collect) {
147
147
  return kept.join(" ");
148
148
  }
149
149
  function basename(token) {
150
- const slash = token.lastIndexOf("/");
151
- return slash === -1 ? token : token.slice(slash + 1);
150
+ const slash = Math.max(token.lastIndexOf("/"), token.lastIndexOf("\\"));
151
+ const name = slash === -1 ? token : token.slice(slash + 1);
152
+ return name.replace(/\.(exe|cmd|bat|ps1)$/i, "");
152
153
  }
153
154
  function matchSegment(segment, list) {
154
155
  const tokens = segment.split(/\s+/).filter((t) => /[a-z0-9]/.test(t));
@@ -281,7 +282,9 @@ var LocalEvaluator = class {
281
282
  }
282
283
  return {
283
284
  recommendation: "ALLOW",
284
- reason: "All PDLSS checks passed",
285
+ // "evaluated": dimensions absent from the policy are skipped, not
286
+ // failed — evaluatedDimensions below records which ones ran.
287
+ reason: "All evaluated PDLSS checks passed",
285
288
  evaluatedDimensions: {
286
289
  purpose: true,
287
290
  scope: !!this.policy.scope,
@@ -380,7 +383,7 @@ var LocalEvaluator = class {
380
383
  }
381
384
  }
382
385
  if ((context.purpose === "file.read" || context.purpose === "file.write" || context.purpose === "file.delete") && context.target) {
383
- const targetLower = context.target.toLowerCase();
386
+ const targetLower = context.target.toLowerCase().replace(/\\/g, "/");
384
387
  for (const sensitivePath of SENSITIVE_PATHS) {
385
388
  if (targetLower.includes(sensitivePath.toLowerCase())) {
386
389
  score = Math.max(score, 50);
@@ -409,12 +412,20 @@ var LocalEvaluator = class {
409
412
  matchesAnyPattern(value, patterns) {
410
413
  return patterns.some((pattern) => this.matchGlob(value, pattern));
411
414
  }
412
- /**
413
- * Simple glob pattern matching.
414
- * Supports * (matches any characters including / and spaces) and ? (single char).
415
- * Uses the same approach as the backend's matchGlobPattern.
416
- */
415
+ homePrefix() {
416
+ if (this.cachedHomePrefix !== void 0) return this.cachedHomePrefix;
417
+ const env = typeof process !== "undefined" ? process.env : void 0;
418
+ const home = env?.HOME || env?.USERPROFILE;
419
+ this.cachedHomePrefix = home ? home.replace(/\\/g, "/") : null;
420
+ return this.cachedHomePrefix;
421
+ }
417
422
  matchGlob(value, pattern) {
423
+ value = value.replace(/\\/g, "/");
424
+ pattern = pattern.replace(/\\/g, "/");
425
+ if (pattern === "~" || pattern.startsWith("~/")) {
426
+ const home = this.homePrefix();
427
+ if (home) pattern = home + pattern.slice(1);
428
+ }
418
429
  if (pattern === value) return true;
419
430
  const starCount = (pattern.match(/\*/g) ?? []).length;
420
431
  if (starCount > 8) {
@@ -3687,7 +3698,7 @@ function getTrustLevel(score) {
3687
3698
  }
3688
3699
 
3689
3700
  // src/version.ts
3690
- var SDK_VERSION = "3.10.1";
3701
+ var SDK_VERSION = "3.11.1";
3691
3702
 
3692
3703
  // src/well-known.ts
3693
3704
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -4202,10 +4213,12 @@ function toGatewayConfig(config) {
4202
4213
  };
4203
4214
  }
4204
4215
  function toVerificationRequest(context, astraId) {
4216
+ const dotIndex = context.purpose.indexOf(".");
4217
+ const dotted = dotIndex > 0;
4205
4218
  return {
4206
4219
  credentials: { astraId },
4207
- purpose: context.purpose,
4208
- action: context.action,
4220
+ purpose: dotted ? context.purpose.slice(0, dotIndex) : context.purpose,
4221
+ action: dotted ? context.purpose : context.action,
4209
4222
  resourceType: context.resourceType,
4210
4223
  resource: context.target,
4211
4224
  transactionValue: context.transactionValue,
@@ -4448,13 +4461,43 @@ var TraceLogger = class {
4448
4461
  * Log an evaluation event.
4449
4462
  */
4450
4463
  logEvaluation(context, decision) {
4464
+ if (!this.enabled) return;
4465
+ let event;
4466
+ try {
4467
+ event = {
4468
+ id: this.generateId(),
4469
+ timestamp: /* @__PURE__ */ new Date(),
4470
+ type: "evaluation",
4471
+ context: redactDeep(context),
4472
+ decision: redactDeep(decision)
4473
+ };
4474
+ } catch (err) {
4475
+ event = {
4476
+ id: this.generateId(),
4477
+ timestamp: /* @__PURE__ */ new Date(),
4478
+ type: "error",
4479
+ metadata: {
4480
+ error: `trace redaction failed: ${err instanceof Error ? err.message : String(err)}`,
4481
+ recommendation: decision.recommendation,
4482
+ purpose: context.purpose,
4483
+ action: context.action
4484
+ }
4485
+ };
4486
+ }
4487
+ this.write(event);
4488
+ }
4489
+ /**
4490
+ * Log a tool call the guard saw but did not govern. One line per skip
4491
+ * keeps coverage holes (unmapped platform tools) visible in the traces
4492
+ * instead of silently indistinguishable from ALLOW.
4493
+ */
4494
+ logSkipped(toolName, reason) {
4451
4495
  if (!this.enabled) return;
4452
4496
  this.write({
4453
4497
  id: this.generateId(),
4454
4498
  timestamp: /* @__PURE__ */ new Date(),
4455
- type: "evaluation",
4456
- context: redactDeep(context),
4457
- decision: redactDeep(decision)
4499
+ type: "skipped",
4500
+ metadata: { toolName, reason }
4458
4501
  });
4459
4502
  }
4460
4503
  /**
@@ -4483,17 +4526,34 @@ var TraceLogger = class {
4483
4526
  });
4484
4527
  }
4485
4528
  write(event) {
4529
+ let line;
4530
+ try {
4531
+ line = JSON.stringify(event) + "\n";
4532
+ } catch {
4533
+ return;
4534
+ }
4486
4535
  try {
4487
4536
  const filePath = this.getCurrentFilePath();
4488
- const line = JSON.stringify(event) + "\n";
4489
4537
  if ((0, import_fs3.existsSync)(filePath)) {
4490
4538
  const stats = (0, import_fs3.statSync)(filePath);
4491
4539
  if (stats.size > MAX_FILE_SIZE) {
4492
4540
  this.rotate();
4493
4541
  }
4494
4542
  }
4495
- (0, import_fs3.appendFileSync)(filePath, line);
4543
+ for (let attempt = 0; attempt < 3; attempt++) {
4544
+ try {
4545
+ (0, import_fs3.appendFileSync)(filePath, line);
4546
+ return;
4547
+ } catch {
4548
+ }
4549
+ }
4550
+ const fallbackPath = filePath.replace(/\.jsonl$/, `-r${process.pid}.jsonl`);
4551
+ (0, import_fs3.appendFileSync)(fallbackPath, line);
4496
4552
  } catch {
4553
+ try {
4554
+ console.error(`[AstraSync TraceLogger] failed to persist trace line: ${line.trim()}`);
4555
+ } catch {
4556
+ }
4497
4557
  }
4498
4558
  }
4499
4559
  getCurrentFilePath() {
@@ -4654,6 +4714,13 @@ var AstraSyncGateway = class {
4654
4714
  getSyncStatus() {
4655
4715
  return this.syncQueue?.getStatus() || null;
4656
4716
  }
4717
+ /**
4718
+ * Record a tool call the calling adapter saw but did not govern
4719
+ * (unmapped tool, skipTools, MCP with governMcp off). Trace-only.
4720
+ */
4721
+ logSkippedTool(toolName, reason) {
4722
+ this.traceLogger?.logSkipped(toolName, reason);
4723
+ }
4657
4724
  };
4658
4725
  // Annotate the CommonJS export names for ESM import in node:
4659
4726
  0 && (module.exports = {