@metamynd/agentsafe-mcp-guard 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +8 -3
  2. package/policy-core.mjs +13 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metamynd/agentsafe-mcp-guard",
3
- "version": "0.1.0",
4
- "description": "Zero-dependency trustless governance for the SERVICE side. An MCP server or API re-verifies a calling agent's signed request against the agent's own published policy so an agent that ignores its own guard still cannot make your service act.",
3
+ "version": "0.1.2",
4
+ "description": "Zero-dependency trustless governance for the SERVICE side. An MCP server or API re-verifies a calling agent's signed request against the agent's own published policy \u00e2\u20ac\u201d so an agent that ignores its own guard still cannot make your service act.",
5
5
  "type": "module",
6
6
  "main": "./agentsafe-mcp-guard.mjs",
7
7
  "module": "./agentsafe-mcp-guard.mjs",
@@ -49,8 +49,13 @@
49
49
  "author": "MetaMynd",
50
50
  "license": "MIT",
51
51
  "homepage": "https://metamynd.ai/en/developers/spec",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/Metamynd/agentsafe-guard.git",
55
+ "directory": "packages/agentsafe-mcp-guard"
56
+ },
52
57
  "bugs": {
53
- "url": "https://metamynd.ai/en/support/contact"
58
+ "url": "https://github.com/Metamynd/agentsafe-guard/issues"
54
59
  },
55
60
  "publishConfig": {
56
61
  "access": "public"
package/policy-core.mjs CHANGED
@@ -334,6 +334,13 @@ function constraintSatisfied(c, req) {
334
334
  function targetOf(rule, mandate) {
335
335
  return rule.target ?? mandate.target;
336
336
  }
337
+ function isAuthorityFailure(result) {
338
+ return result.matched?.kind === "expiry" || result.matched?.kind === "no-permission";
339
+ }
340
+ function authorityFailure(mandate, target, now) {
341
+ const result = evaluateMandate(mandate, { target, now, values: {} });
342
+ return isAuthorityFailure(result) ? { ...result, decision: "block" } : null;
343
+ }
337
344
  function evaluateMandate(mandate, req) {
338
345
  const now = toTime(req.now);
339
346
  if (mandate.validFrom && now < toTime(mandate.validFrom)) {
@@ -402,14 +409,14 @@ function evaluate(input) {
402
409
  reasonCode = code;
403
410
  }
404
411
  };
412
+ const m = input.mandate && input.mandateRequest ? evaluateMandate(input.mandate, input.mandateRequest) : null;
413
+ const authority = m !== null && isAuthorityFailure(m);
414
+ if (m && authority) consider(m.decision, m.reasonCode);
405
415
  const std = evaluateBoundStandards(input.standards ?? [], input.context);
406
416
  if (std.decision !== "allow") consider(std.decision, std.reasonCode ?? "STANDARD_RULE");
407
417
  const sop = evaluateBoundStandards(input.sops ?? [], input.context);
408
418
  if (sop.decision !== "allow") consider(sop.decision, sop.reasonCode ?? "SOP_RULE");
409
- if (input.mandate && input.mandateRequest) {
410
- const m = evaluateMandate(input.mandate, input.mandateRequest);
411
- if (m.decision !== "allow") consider(m.decision, m.reasonCode);
412
- }
419
+ if (m && !authority && m.decision !== "allow") consider(m.decision, m.reasonCode);
413
420
  return { decision, reasonCode, authorizationId: null, remaining: null, proofRef: null };
414
421
  }
415
422
 
@@ -472,12 +479,14 @@ export {
472
479
  applyHold,
473
480
  applySignedLast,
474
481
  asOperatingMode,
482
+ authorityFailure,
475
483
  buildAuthMessage,
476
484
  canAuthorize,
477
485
  evaluate,
478
486
  evaluateBoundStandards,
479
487
  evaluateMandate,
480
488
  evaluateStandardRules,
489
+ isAuthorityFailure,
481
490
  isOperatingMode,
482
491
  moleculeFires,
483
492
  moreRestrictive,