@metamynd/agentsafe-guard 0.3.0 → 0.4.0

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/package.json CHANGED
@@ -1,59 +1,60 @@
1
- {
2
- "name": "@metamynd/agentsafe-guard",
3
- "version": "0.3.0",
4
- "description": "Zero-dependency runtime governance for any Node AI agent gate tool calls through MetaMynd/AgentSafe (allow / block / escalate) against the agent's mandate, enforced Standards, and SOPs. Ed25519-signed, deterministic, fail-closed.",
5
- "type": "module",
6
- "main": "./agentsafe-guard.mjs",
7
- "module": "./agentsafe-guard.mjs",
8
- "exports": {
9
- ".": "./agentsafe-guard.mjs",
10
- "./policy-core": "./policy-core.mjs",
11
- "./package.json": "./package.json"
12
- },
13
- "files": [
14
- "agentsafe-guard.mjs",
15
- "policy-core.mjs",
16
- "magp-did.mjs",
17
- "x402.mjs",
18
- "example-openclaw-agent.mjs",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "scripts": {
23
- "test": "node local-eval.smoke.mjs && node execution-adapter.smoke.mjs"
24
- },
25
- "engines": {
26
- "node": ">=18"
27
- },
28
- "sideEffects": false,
29
- "keywords": [
30
- "ai",
31
- "agent",
32
- "agents",
33
- "governance",
34
- "ai-safety",
35
- "guardrails",
36
- "policy",
37
- "mandate",
38
- "authorization",
39
- "ed25519",
40
- "magp",
41
- "metamynd",
42
- "agentsafe",
43
- "compliance"
44
- ],
45
- "author": "MetaMynd",
46
- "license": "MIT",
47
- "homepage": "https://github.com/jasimp18/AgentSafe/tree/main/integrations/agentsafe-guard#readme",
48
- "repository": {
49
- "type": "git",
50
- "url": "git+https://github.com/jasimp18/AgentSafe.git",
51
- "directory": "integrations/agentsafe-guard"
52
- },
53
- "bugs": {
54
- "url": "https://github.com/jasimp18/AgentSafe/issues"
55
- },
56
- "publishConfig": {
57
- "access": "public"
58
- }
59
- }
1
+ {
2
+ "name": "@metamynd/agentsafe-guard",
3
+ "version": "0.4.0",
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
+ "type": "module",
6
+ "main": "./agentsafe-guard.mjs",
7
+ "module": "./agentsafe-guard.mjs",
8
+ "exports": {
9
+ ".": "./agentsafe-guard.mjs",
10
+ "./policy-core": "./policy-core.mjs",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "files": [
14
+ "demo.mjs",
15
+ "cli.mjs",
16
+ "agentsafe-guard.mjs",
17
+ "policy-core.mjs",
18
+ "magp-did.mjs",
19
+ "x402.mjs",
20
+ "example-openclaw-agent.mjs",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "test": "node demo.mjs && node local-eval.smoke.mjs && node execution-adapter.smoke.mjs",
26
+ "demo": "node demo.mjs"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "sideEffects": false,
32
+ "keywords": [
33
+ "ai",
34
+ "agent",
35
+ "agents",
36
+ "governance",
37
+ "ai-safety",
38
+ "guardrails",
39
+ "policy",
40
+ "mandate",
41
+ "authorization",
42
+ "ed25519",
43
+ "magp",
44
+ "metamynd",
45
+ "agentsafe",
46
+ "compliance"
47
+ ],
48
+ "author": "MetaMynd",
49
+ "license": "MIT",
50
+ "homepage": "https://metamynd.ai",
51
+ "bugs": {
52
+ "url": "https://metamynd.ai/en/support/contact"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "bin": {
58
+ "agentsafe-guard": "./cli.mjs"
59
+ }
60
+ }
package/x402.mjs CHANGED
@@ -1,43 +1,43 @@
1
- // GENERATED from backend/src/features/magp/x402-binding.ts — do not edit. Regenerate: npm run build:guard-core
2
-
3
- // src/features/magp/x402-binding.ts
4
- function toMinorUnits(amount, decimals) {
5
- if (!Number.isFinite(amount) || amount < 0) throw new Error("amount must be a non-negative number");
6
- const factor = 10 ** decimals;
7
- return String(Math.round(amount * factor));
8
- }
9
- function buildPaymentRequirements(input) {
10
- if (!input.authorizationId) throw new Error("buildPaymentRequirements requires an authorizationId");
11
- const decimals = input.decimals ?? 6;
12
- return {
13
- x402Version: 1,
14
- accepts: [
15
- {
16
- scheme: "exact",
17
- network: input.network ?? "hedera-testnet",
18
- maxAmountRequired: toMinorUnits(input.amount, decimals),
19
- payTo: input.payTo,
20
- asset: input.asset,
21
- resource: input.resource,
22
- extra: { magpAuthorizationId: input.authorizationId, magpAgentDid: input.agentDid }
23
- }
24
- ]
25
- };
26
- }
27
- function checkSettlementBinding(requirements, claim) {
28
- const accept = requirements?.accepts?.[0];
29
- if (!accept?.extra?.magpAuthorizationId) return { ok: false, reasonCode: "MISSING_BINDING" };
30
- if (accept.extra.magpAuthorizationId !== claim.authorizationId) {
31
- return { ok: false, reasonCode: "AUTHORIZATION_MISMATCH" };
32
- }
33
- const authorizedMinor = Number(accept.maxAmountRequired);
34
- const paidMinor = Number(claim.paidAmountMinor);
35
- if (!Number.isFinite(paidMinor) || paidMinor < 0) return { ok: false, reasonCode: "AMOUNT_INVALID" };
36
- if (paidMinor > authorizedMinor) return { ok: false, reasonCode: "AMOUNT_MISMATCH" };
37
- return { ok: true, reasonCode: "BINDING_OK" };
38
- }
39
- export {
40
- buildPaymentRequirements,
41
- checkSettlementBinding,
42
- toMinorUnits
43
- };
1
+ // GENERATED from backend/src/features/magp/x402-binding.ts — do not edit. Regenerate: npm run build:guard-core
2
+
3
+ // src/features/magp/x402-binding.ts
4
+ function toMinorUnits(amount, decimals) {
5
+ if (!Number.isFinite(amount) || amount < 0) throw new Error("amount must be a non-negative number");
6
+ const factor = 10 ** decimals;
7
+ return String(Math.round(amount * factor));
8
+ }
9
+ function buildPaymentRequirements(input) {
10
+ if (!input.authorizationId) throw new Error("buildPaymentRequirements requires an authorizationId");
11
+ const decimals = input.decimals ?? 6;
12
+ return {
13
+ x402Version: 1,
14
+ accepts: [
15
+ {
16
+ scheme: "exact",
17
+ network: input.network ?? "hedera-testnet",
18
+ maxAmountRequired: toMinorUnits(input.amount, decimals),
19
+ payTo: input.payTo,
20
+ asset: input.asset,
21
+ resource: input.resource,
22
+ extra: { magpAuthorizationId: input.authorizationId, magpAgentDid: input.agentDid }
23
+ }
24
+ ]
25
+ };
26
+ }
27
+ function checkSettlementBinding(requirements, claim) {
28
+ const accept = requirements?.accepts?.[0];
29
+ if (!accept?.extra?.magpAuthorizationId) return { ok: false, reasonCode: "MISSING_BINDING" };
30
+ if (accept.extra.magpAuthorizationId !== claim.authorizationId) {
31
+ return { ok: false, reasonCode: "AUTHORIZATION_MISMATCH" };
32
+ }
33
+ const authorizedMinor = Number(accept.maxAmountRequired);
34
+ const paidMinor = Number(claim.paidAmountMinor);
35
+ if (!Number.isFinite(paidMinor) || paidMinor < 0) return { ok: false, reasonCode: "AMOUNT_INVALID" };
36
+ if (paidMinor > authorizedMinor) return { ok: false, reasonCode: "AMOUNT_MISMATCH" };
37
+ return { ok: true, reasonCode: "BINDING_OK" };
38
+ }
39
+ export {
40
+ buildPaymentRequirements,
41
+ checkSettlementBinding,
42
+ toMinorUnits
43
+ };