@metamynd/agentsafe-guard 0.4.2 → 0.4.5
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/agentsafe-guard.mjs +1 -1
- package/package.json +7 -2
- package/policy-core.mjs +13 -4
package/agentsafe-guard.mjs
CHANGED
|
@@ -491,7 +491,7 @@ export function createGuard(opts = {}) {
|
|
|
491
491
|
return {
|
|
492
492
|
hello() {
|
|
493
493
|
const nonceA = crypto.randomUUID();
|
|
494
|
-
return { nonceA, message: { fromDid: agentDid, nonceA, protoVersion: '0
|
|
494
|
+
return { nonceA, message: { fromDid: agentDid, nonceA, protoVersion: '1.0' } };
|
|
495
495
|
},
|
|
496
496
|
prove({ nonceA, challenge } = {}) {
|
|
497
497
|
const { toDid, nonceB, sigB, handshakeId } = challenge ?? {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamynd/agentsafe-guard",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Zero-dependency runtime governance for any Node AI agent \u2014 gate tool calls through MetaMynd/AgentSafe (allow / block / escalate) against the agent's mandate, enforced Standards, and SOPs. Ed25519-signed, deterministic, fail-closed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./agentsafe-guard.mjs",
|
|
@@ -48,8 +48,13 @@
|
|
|
48
48
|
"author": "MetaMynd",
|
|
49
49
|
"license": "MIT",
|
|
50
50
|
"homepage": "https://metamynd.ai",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/Metamynd/agentsafe-guard.git",
|
|
54
|
+
"directory": "packages/agentsafe-guard"
|
|
55
|
+
},
|
|
51
56
|
"bugs": {
|
|
52
|
-
"url": "https://
|
|
57
|
+
"url": "https://github.com/Metamynd/agentsafe-guard/issues"
|
|
53
58
|
},
|
|
54
59
|
"publishConfig": {
|
|
55
60
|
"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 (
|
|
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,
|