@vorionsys/basis 1.0.1 → 1.0.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.
- package/CHANGELOG.md +40 -0
- package/LICENSE +191 -0
- package/README.md +339 -81
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -0
- package/dist/kya/accountability.d.ts +39 -0
- package/dist/kya/accountability.js.map +1 -0
- package/dist/kya/authorization.d.ts +48 -0
- package/dist/kya/authorization.js.map +1 -0
- package/dist/kya/behavior.d.ts +28 -0
- package/dist/kya/behavior.js.map +1 -0
- package/dist/kya/identity.d.ts +35 -0
- package/dist/kya/identity.js.map +1 -0
- package/dist/kya/index.d.ts +50 -0
- package/dist/kya/index.js +1 -1
- package/dist/kya/index.js.map +1 -0
- package/dist/kya/types.d.ts +208 -0
- package/dist/kya/types.js.map +1 -0
- package/dist/trust-capabilities.d.ts +90 -0
- package/dist/trust-capabilities.js +14 -14
- package/dist/trust-capabilities.js.map +1 -0
- package/dist/trust-factors.d.ts +506 -0
- package/dist/trust-factors.d.ts.map +1 -1
- package/dist/trust-factors.js +20 -20
- package/dist/trust-factors.js.map +1 -0
- package/dist/validation-gate.d.ts +438 -0
- package/dist/validation-gate.js +2 -2
- package/dist/validation-gate.js.map +1 -0
- package/package.json +20 -4
- package/.env.example +0 -22
- package/AMOY-MIGRATION.md +0 -188
- package/DEPLOY-AMOY.md +0 -368
- package/DEPLOY-NOW.md +0 -216
- package/DEPLOYMENT.md +0 -239
- package/GET-WALLET.md +0 -286
- package/QUICK-WALLET-SETUP.md +0 -268
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +0 -236
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +0 -204
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.json +0 -328
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.json +0 -113
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.json +0 -97
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.json +0 -114
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +0 -444
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json +0 -296
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.json +0 -45
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.json +0 -521
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.json +0 -476
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.json +0 -352
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.json +0 -341
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.json +0 -10
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +0 -10
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.json +0 -10
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +0 -37
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +0 -30
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +0 -30
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +0 -10
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +0 -65
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +0 -4
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +0 -10
- package/artifacts/build-info/357d1bba4062d461f497f221490811a3.json +0 -1
- package/artifacts/contracts/AgentCard.sol/AgentCard.dbg.json +0 -4
- package/artifacts/contracts/AgentCard.sol/AgentCard.json +0 -1430
- package/build_errors.txt +0 -0
- package/build_output.txt +0 -0
- package/cache/solidity-files-cache.json +0 -885
- package/contracts/AgentCard.sol +0 -478
- package/contracts/deploy/01-deploy-agentcard.ts +0 -66
- package/dist/trust-1000-agents.test.d.ts.map +0 -1
- package/dist/trust-1000-agents.test.js +0 -608
- package/dist/trust-factors.test.d.ts.map +0 -1
- package/dist/trust-factors.test.js +0 -179
- package/dist/validation-gate.test.d.ts.map +0 -1
- package/dist/validation-gate.test.js +0 -419
- package/hardhat.config.ts +0 -55
- package/scripts/certify-agent.ts +0 -91
- package/scripts/deploy-agentcard.ts +0 -63
- package/scripts/mint-agentcard.ts +0 -87
- package/specs/adversarial-sandbox-test-suite.md +0 -1055
- package/specs/kya-framework.md +0 -910
- package/specs/trust-factors-v2.md +0 -437
- package/src/index.ts +0 -14
- package/src/kya/accountability.ts +0 -132
- package/src/kya/authorization.ts +0 -325
- package/src/kya/behavior.ts +0 -169
- package/src/kya/identity.ts +0 -224
- package/src/kya/index.ts +0 -125
- package/src/kya/types.ts +0 -242
- package/src/trust-1000-agents.test.ts +0 -745
- package/src/trust-capabilities.ts +0 -517
- package/src/trust-factors.test.ts +0 -241
- package/src/trust-factors.ts +0 -666
- package/src/validation-gate.test.ts +0 -531
- package/src/validation-gate.ts +0 -665
- package/test-kya-simple.ts +0 -258
- package/test-kya.ts +0 -245
- package/tsconfig.json +0 -14
- package/typechain-types/@openzeppelin/contracts/access/AccessControl.ts +0 -324
- package/typechain-types/@openzeppelin/contracts/access/IAccessControl.ts +0 -292
- package/typechain-types/@openzeppelin/contracts/access/index.ts +0 -5
- package/typechain-types/@openzeppelin/contracts/index.ts +0 -11
- package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +0 -462
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +0 -69
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +0 -69
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +0 -69
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +0 -6
- package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +0 -6
- package/typechain-types/@openzeppelin/contracts/token/ERC721/ERC721.ts +0 -420
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +0 -393
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +0 -110
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.ts +0 -470
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.ts +0 -489
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.ts +0 -443
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +0 -420
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +0 -7
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +0 -8
- package/typechain-types/@openzeppelin/contracts/token/index.ts +0 -5
- package/typechain-types/@openzeppelin/contracts/utils/Strings.ts +0 -69
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +0 -8
- package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +0 -94
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +0 -94
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +0 -5
- package/typechain-types/@openzeppelin/contracts/utils/math/SafeCast.ts +0 -69
- package/typechain-types/@openzeppelin/contracts/utils/math/index.ts +0 -4
- package/typechain-types/@openzeppelin/index.ts +0 -5
- package/typechain-types/common.ts +0 -131
- package/typechain-types/contracts/AgentCard.ts +0 -1415
- package/typechain-types/contracts/index.ts +0 -4
- package/typechain-types/factories/@openzeppelin/contracts/access/AccessControl__factory.ts +0 -250
- package/typechain-types/factories/@openzeppelin/contracts/access/IAccessControl__factory.ts +0 -218
- package/typechain-types/factories/@openzeppelin/contracts/access/index.ts +0 -5
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +0 -7
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +0 -339
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +0 -127
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +0 -111
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +0 -128
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +0 -6
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +0 -5
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/ERC721__factory.ts +0 -455
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +0 -59
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +0 -307
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable__factory.ts +0 -535
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage__factory.ts +0 -490
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable__factory.ts +0 -366
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +0 -355
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +0 -7
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +0 -7
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +0 -4
- package/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.ts +0 -90
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +0 -6
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +0 -41
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +0 -41
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +0 -5
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.ts +0 -118
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/index.ts +0 -4
- package/typechain-types/factories/@openzeppelin/index.ts +0 -4
- package/typechain-types/factories/contracts/AgentCard__factory.ts +0 -1480
- package/typechain-types/factories/contracts/index.ts +0 -4
- package/typechain-types/factories/index.ts +0 -5
- package/typechain-types/index.ts +0 -44
- package/vitest.config.ts +0 -8
package/README.md
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
# @vorionsys/basis
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Baseline Authority for Safe & Interoperable Systems (BASIS)** -- Open standard for AI agent governance with an 8-tier trust framework, 23 trust factors, a validation gate, and a KYA (Know Your Agent) verification SDK.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
BASIS defines how autonomous AI agents earn, maintain, and lose trust. It provides:
|
|
8
|
-
|
|
9
|
-
- **8 Trust Tiers (T0-T7)**: Progressive autonomy levels from Sandbox to Autonomous
|
|
10
|
-
- **23 Trust Factors**: 15 core + 8 life-critical evaluation criteria
|
|
11
|
-
- **Tier-Gated Capabilities**: What agents can do at each trust level
|
|
12
|
-
- **KYA Framework**: Identity, Authorization, Accountability, and Behavior monitoring
|
|
13
|
-
- **Validation Gate**: Central pass/reject/escalate decisions for agent manifests
|
|
5
|
+
> Part of the [Vorion](https://vorion.org) platform for autonomous AI agent infrastructure.
|
|
14
6
|
|
|
15
7
|
## Installation
|
|
16
8
|
|
|
@@ -18,8 +10,22 @@ BASIS defines how autonomous AI agents earn, maintain, and lose trust. It provid
|
|
|
18
10
|
npm install @vorionsys/basis
|
|
19
11
|
```
|
|
20
12
|
|
|
13
|
+
## What is BASIS?
|
|
14
|
+
|
|
15
|
+
BASIS (Baseline Authority for Safe & Interoperable Systems) defines how autonomous AI agents earn, maintain, and lose trust. It is the governance layer for any system that deploys, orchestrates, or monitors AI agents.
|
|
16
|
+
|
|
17
|
+
BASIS provides:
|
|
18
|
+
|
|
19
|
+
- **8 Trust Tiers (T0-T7)** -- Progressive autonomy levels from Sandbox to Autonomous
|
|
20
|
+
- **23 Trust Factors** -- 15 core + 8 life-critical evaluation criteria with weighted scoring
|
|
21
|
+
- **Tier-Gated Capabilities** -- What agents can do at each trust level (35 capabilities across 8 categories)
|
|
22
|
+
- **Validation Gate** -- Central PASS / REJECT / ESCALATE decisions for agent manifests
|
|
23
|
+
- **KYA (Know Your Agent) Framework** -- Identity verification, authorization, accountability chains, and behavior monitoring
|
|
24
|
+
|
|
21
25
|
## Quick Start
|
|
22
26
|
|
|
27
|
+
### Evaluate an Agent's Trust Score
|
|
28
|
+
|
|
23
29
|
```typescript
|
|
24
30
|
import {
|
|
25
31
|
TrustTier,
|
|
@@ -27,17 +33,162 @@ import {
|
|
|
27
33
|
calculateTrustScore,
|
|
28
34
|
getRequiredFactors,
|
|
29
35
|
getTrustTierFromScore,
|
|
36
|
+
type FactorScore,
|
|
30
37
|
} from '@vorionsys/basis';
|
|
31
38
|
|
|
32
|
-
//
|
|
33
|
-
const required = getRequiredFactors(TrustTier.
|
|
39
|
+
// Which factors are required for T4 Standard?
|
|
40
|
+
const required = getRequiredFactors(TrustTier.T4_STANDARD);
|
|
34
41
|
console.log(`T4 requires ${required.length} factors`);
|
|
35
42
|
|
|
36
|
-
//
|
|
37
|
-
const
|
|
43
|
+
// Build factor scores for an agent
|
|
44
|
+
const factorScores: FactorScore[] = [
|
|
45
|
+
{ code: 'CT_COMP', score: 0.85, timestamp: new Date(), source: 'measured', confidence: 0.9 },
|
|
46
|
+
{ code: 'CT_REL', score: 0.80, timestamp: new Date(), source: 'measured', confidence: 0.9 },
|
|
47
|
+
{ code: 'CT_OBS', score: 0.78, timestamp: new Date(), source: 'measured', confidence: 0.85 },
|
|
48
|
+
// ... additional factor scores
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
// Calculate trust score against a target tier
|
|
52
|
+
const evaluation = calculateTrustScore(factorScores, TrustTier.T4_STANDARD);
|
|
38
53
|
console.log(`Score: ${evaluation.totalScore}/1000`);
|
|
39
54
|
console.log(`Compliant: ${evaluation.compliant}`);
|
|
40
|
-
console.log(`Missing: ${evaluation.missingFactors}`);
|
|
55
|
+
console.log(`Missing factors: ${evaluation.missingFactors}`);
|
|
56
|
+
console.log(`Below threshold: ${evaluation.belowThreshold}`);
|
|
57
|
+
|
|
58
|
+
// Determine tier from a raw score
|
|
59
|
+
const tier = getTrustTierFromScore(720);
|
|
60
|
+
// => TrustTier.T4_STANDARD
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Validate an Agent Manifest
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import {
|
|
67
|
+
validateAgent,
|
|
68
|
+
GateDecision,
|
|
69
|
+
ValidationSeverity,
|
|
70
|
+
type AgentManifest,
|
|
71
|
+
} from '@vorionsys/basis';
|
|
72
|
+
|
|
73
|
+
const manifest: AgentManifest = {
|
|
74
|
+
agentId: 'a3i.acme-corp.invoice-bot:ABF-L3@1.0.0',
|
|
75
|
+
organization: 'acme-corp',
|
|
76
|
+
agentClass: 'invoice-bot',
|
|
77
|
+
trustScore: 520,
|
|
78
|
+
requestedCapabilities: ['CAP-DB-READ', 'CAP-WRITE-APPROVED'],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const result = validateAgent(manifest);
|
|
82
|
+
|
|
83
|
+
switch (result.decision) {
|
|
84
|
+
case GateDecision.PASS:
|
|
85
|
+
console.log('Agent validated -- proceed');
|
|
86
|
+
console.log('Allowed capabilities:', result.allowedCapabilities);
|
|
87
|
+
break;
|
|
88
|
+
case GateDecision.REJECT:
|
|
89
|
+
console.log('Agent rejected:', result.errors);
|
|
90
|
+
break;
|
|
91
|
+
case GateDecision.ESCALATE:
|
|
92
|
+
console.log('Human review required:', result.warnings);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Check Tier-Gated Capabilities
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import {
|
|
101
|
+
TrustTier,
|
|
102
|
+
getCapabilitiesForTier,
|
|
103
|
+
getNewCapabilitiesAtTier,
|
|
104
|
+
hasCapability,
|
|
105
|
+
getToolsForTier,
|
|
106
|
+
} from '@vorionsys/basis';
|
|
107
|
+
|
|
108
|
+
// Get all capabilities available at T4
|
|
109
|
+
const caps = getCapabilitiesForTier(TrustTier.T4_STANDARD);
|
|
110
|
+
console.log(`T4 agents have ${caps.length} capabilities`);
|
|
111
|
+
|
|
112
|
+
// Get only the capabilities that unlock at T4
|
|
113
|
+
const newCaps = getNewCapabilitiesAtTier(TrustTier.T4_STANDARD);
|
|
114
|
+
console.log('New at T4:', newCaps.map(c => c.name));
|
|
115
|
+
|
|
116
|
+
// Check if a specific tier has a capability
|
|
117
|
+
const canWrite = hasCapability(TrustTier.T2_PROVISIONAL, 'CAP-WRITE-APPROVED');
|
|
118
|
+
console.log(`T2 can write to approved locations: ${canWrite}`);
|
|
119
|
+
|
|
120
|
+
// Get all tools available at a tier
|
|
121
|
+
const tools = getToolsForTier(TrustTier.T3_MONITORED);
|
|
122
|
+
console.log('T3 tools:', tools);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### KYA (Know Your Agent) Verification
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { KYA } from '@vorionsys/basis';
|
|
129
|
+
|
|
130
|
+
const kya = new KYA({
|
|
131
|
+
didResolver: {
|
|
132
|
+
networks: ['vorion', 'ethereum'],
|
|
133
|
+
cacheEnabled: true,
|
|
134
|
+
},
|
|
135
|
+
policyEngine: {
|
|
136
|
+
policyBundlesPath: './policies',
|
|
137
|
+
defaultJurisdiction: 'Global',
|
|
138
|
+
},
|
|
139
|
+
database: {
|
|
140
|
+
type: 'postgres',
|
|
141
|
+
connectionString: process.env.DATABASE_URL!,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Complete 4-step verification flow:
|
|
146
|
+
// 1. Identity -- DID resolution + Ed25519 signature verification
|
|
147
|
+
// 2. Authorization -- Capability token + policy constraint check
|
|
148
|
+
// 3. Accountability -- Hash-linked audit chain logging
|
|
149
|
+
// 4. Behavior -- Anomaly detection (rate spikes, suspicious access)
|
|
150
|
+
const result = await kya.verifyAgent({
|
|
151
|
+
agentDID: 'did:vorion:ed25519:5Z8K3q2YvU8pVzNxF9sT7bQw6JhR1Xm',
|
|
152
|
+
action: 'file.read',
|
|
153
|
+
resource: 'documents/report.pdf',
|
|
154
|
+
proof: {
|
|
155
|
+
challenge: 'abc123...',
|
|
156
|
+
signature: 'deadbeef...',
|
|
157
|
+
timestamp: Date.now(),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
if (result.allowed) {
|
|
162
|
+
console.log(`Trust score: ${result.trustScore}`);
|
|
163
|
+
console.log(`Anomalies detected: ${result.anomalies}`);
|
|
164
|
+
} else {
|
|
165
|
+
console.log(`Denied: ${result.reason}`);
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Use Pre-Built Validation Gates
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import {
|
|
173
|
+
createValidationGate,
|
|
174
|
+
strictValidationGate,
|
|
175
|
+
productionValidationGate,
|
|
176
|
+
} from '@vorionsys/basis';
|
|
177
|
+
|
|
178
|
+
// Strict mode -- treats warnings as errors
|
|
179
|
+
const result1 = strictValidationGate.validate(manifest);
|
|
180
|
+
|
|
181
|
+
// Production mode -- requires registered profile, minimum T2 tier
|
|
182
|
+
const result2 = productionValidationGate.validate(manifest, registeredProfile);
|
|
183
|
+
|
|
184
|
+
// Custom gate with your own defaults
|
|
185
|
+
const myGate = createValidationGate({
|
|
186
|
+
strict: false,
|
|
187
|
+
requireRegisteredProfile: true,
|
|
188
|
+
minimumTrustTier: TrustTier.T3_MONITORED,
|
|
189
|
+
allowCapabilityEscalation: true,
|
|
190
|
+
});
|
|
191
|
+
const result3 = myGate.validate(manifest);
|
|
41
192
|
```
|
|
42
193
|
|
|
43
194
|
## Trust Tiers
|
|
@@ -47,17 +198,17 @@ console.log(`Missing: ${evaluation.missingFactors}`);
|
|
|
47
198
|
| T0 | 0-199 | Sandbox | 0 | Observation only, no external access |
|
|
48
199
|
| T1 | 200-349 | Observed | 3 | Basic competence demonstrated |
|
|
49
200
|
| T2 | 350-499 | Provisional | 6 | Accountability + safety emerging |
|
|
50
|
-
| T3 | 500-649 |
|
|
51
|
-
| T4 | 650-799 |
|
|
201
|
+
| T3 | 500-649 | Monitored | 9 | Security + identity confirmed |
|
|
202
|
+
| T4 | 650-799 | Standard | 13 | Human oversight + alignment |
|
|
52
203
|
| T5 | 800-875 | Trusted | 16 | Stewardship + humility |
|
|
53
204
|
| T6 | 876-950 | Certified | 20 | Adaptability + causal reasoning |
|
|
54
|
-
| T7 | 951-1000 | Autonomous | 23 | Full autonomy
|
|
205
|
+
| T7 | 951-1000 | Autonomous | 23 | Full autonomy -- all factors |
|
|
55
206
|
|
|
56
207
|
## Trust Factors
|
|
57
208
|
|
|
58
209
|
### Core Factors (15)
|
|
59
210
|
|
|
60
|
-
| Code | Name | Required From | Tier |
|
|
211
|
+
| Code | Name | Required From | Factor Tier |
|
|
61
212
|
|------|------|--------------|------|
|
|
62
213
|
| CT-COMP | Competence | T1 | Foundational |
|
|
63
214
|
| CT-REL | Reliability | T1 | Foundational |
|
|
@@ -90,65 +241,51 @@ For healthcare, safety, and life-saving AI applications:
|
|
|
90
241
|
| LC-MORAL | Nuanced Moral Reasoning | T7 |
|
|
91
242
|
| LC-TRACK | Proven Efficacy Track Record | T7 |
|
|
92
243
|
|
|
93
|
-
##
|
|
244
|
+
## Capability Categories
|
|
94
245
|
|
|
95
|
-
|
|
246
|
+
Capabilities are gated by trust tier. As agents earn higher trust, they unlock more capabilities across 8 categories:
|
|
96
247
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
248
|
+
| Category | Examples | First Available |
|
|
249
|
+
|----------|----------|----------------|
|
|
250
|
+
| Data Access | Read public/internal data, database read/write, secrets | T0 |
|
|
251
|
+
| File Operations | Write to approved directories | T2 |
|
|
252
|
+
| API Access | Internal API read, external GET, full REST | T1 |
|
|
253
|
+
| Code Execution | Generate responses, data transforms, sandboxed code | T0 |
|
|
254
|
+
| Agent Interaction | Agent communication, delegation, spawning | T4 |
|
|
255
|
+
| Resource Management | Resource provisioning, budget management | T4 |
|
|
256
|
+
| System Administration | Limited admin, infrastructure management, full admin | T5 |
|
|
257
|
+
| Governance | Human escalation, policy modification, strategic decisions | T4 |
|
|
105
258
|
|
|
106
|
-
|
|
107
|
-
// 1. Identity (DID + signature verification)
|
|
108
|
-
// 2. Authorization (capability + policy check)
|
|
109
|
-
// 3. Accountability (audit chain logging)
|
|
110
|
-
// 4. Behavior (anomaly detection)
|
|
111
|
-
const result = await kya.verifyAgent({
|
|
112
|
-
agentDID: 'did:vorion:agent-123',
|
|
113
|
-
action: 'read',
|
|
114
|
-
resource: 'documents/report.pdf',
|
|
115
|
-
proof: { challenge, signature, timestamp },
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (result.allowed) {
|
|
119
|
-
console.log(`Trust score: ${result.trustScore}`);
|
|
120
|
-
console.log(`Anomalies: ${result.anomalies}`);
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Validation Gate
|
|
259
|
+
## API Reference
|
|
125
260
|
|
|
126
|
-
|
|
261
|
+
### Enums
|
|
127
262
|
|
|
128
263
|
```typescript
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
```
|
|
264
|
+
// Trust tier levels (T0-T7)
|
|
265
|
+
enum TrustTier {
|
|
266
|
+
T0_SANDBOX, T1_OBSERVED, T2_PROVISIONAL, T3_MONITORED,
|
|
267
|
+
T4_STANDARD, T5_TRUSTED, T6_CERTIFIED, T7_AUTONOMOUS
|
|
268
|
+
}
|
|
135
269
|
|
|
136
|
-
|
|
270
|
+
// Factor classification tiers
|
|
271
|
+
enum FactorTier {
|
|
272
|
+
FOUNDATIONAL, OPERATIONAL, SOPHISTICATED, LIFE_CRITICAL
|
|
273
|
+
}
|
|
137
274
|
|
|
138
|
-
|
|
275
|
+
// Capability categories
|
|
276
|
+
enum CapabilityCategory {
|
|
277
|
+
DATA_ACCESS, FILE_OPERATIONS, API_ACCESS, CODE_EXECUTION,
|
|
278
|
+
AGENT_INTERACTION, RESOURCE_MANAGEMENT, SYSTEM_ADMINISTRATION, GOVERNANCE
|
|
279
|
+
}
|
|
139
280
|
|
|
140
|
-
|
|
141
|
-
|
|
281
|
+
// Validation gate decisions
|
|
282
|
+
enum GateDecision { PASS, REJECT, ESCALATE }
|
|
142
283
|
|
|
143
|
-
|
|
144
|
-
|
|
284
|
+
// Validation issue severity
|
|
285
|
+
enum ValidationSeverity { INFO, WARNING, ERROR, CRITICAL }
|
|
145
286
|
```
|
|
146
287
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
## API Reference
|
|
150
|
-
|
|
151
|
-
### Trust Score Calculation
|
|
288
|
+
### Trust Score Functions
|
|
152
289
|
|
|
153
290
|
```typescript
|
|
154
291
|
calculateTrustScore(scores: FactorScore[], tier: TrustTier): TrustEvaluation
|
|
@@ -160,36 +297,157 @@ getTierName(tier: TrustTier): string
|
|
|
160
297
|
getTierColor(tier: TrustTier): string
|
|
161
298
|
```
|
|
162
299
|
|
|
300
|
+
### Capability Functions
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
getCapabilitiesForTier(tier: TrustTier): Capability[]
|
|
304
|
+
getNewCapabilitiesAtTier(tier: TrustTier): Capability[]
|
|
305
|
+
hasCapability(agentTier: TrustTier, capabilityCode: string): boolean
|
|
306
|
+
getToolsForTier(tier: TrustTier): string[]
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Validation Gate Functions
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
validateAgent(manifest: AgentManifest, profile?: RegisteredProfile, options?: ValidationGateOptions): ValidationGateResult
|
|
313
|
+
isValidAgent(manifest: AgentManifest, profile?: RegisteredProfile, options?: ValidationGateOptions): boolean
|
|
314
|
+
createValidationGate(defaultOptions: ValidationGateOptions): { validate, isValid }
|
|
315
|
+
scoreToTier(score: number): TrustTier
|
|
316
|
+
|
|
317
|
+
// Pre-built gates
|
|
318
|
+
strictValidationGate // Treats warnings as errors
|
|
319
|
+
productionValidationGate // Requires registered profile, minimum T2
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### KYA Classes
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
class KYA {
|
|
326
|
+
identity: IdentityVerifier;
|
|
327
|
+
authorization: AuthorizationManager;
|
|
328
|
+
accountability: AccountabilityChain;
|
|
329
|
+
behavior: BehaviorMonitor;
|
|
330
|
+
|
|
331
|
+
verifyAgent(params): Promise<{ allowed, reason, trustScore, anomalies }>
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
class IdentityVerifier {
|
|
335
|
+
verify(proof: IdentityProof): Promise<boolean>
|
|
336
|
+
resolveDID(did: string): Promise<DIDDocument>
|
|
337
|
+
generateChallenge(): string
|
|
338
|
+
signChallenge(challenge: string, privateKey: Uint8Array): Promise<string>
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
class AuthorizationManager {
|
|
342
|
+
authorize(request: AuthorizationRequest): Promise<AuthorizationDecision>
|
|
343
|
+
grantCapability(agentDID: string, token: CapabilityToken): Promise<void>
|
|
344
|
+
revokeCapability(agentDID: string, capabilityId: string): Promise<void>
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
class AccountabilityChain {
|
|
348
|
+
append(record: AccountabilityRecord): Promise<void>
|
|
349
|
+
verify(agentDID: string): Promise<{ valid, totalRecords, brokenLinks }>
|
|
350
|
+
query(agentDID: string, options?): Promise<AccountabilityRecord[]>
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
class BehaviorMonitor {
|
|
354
|
+
detectAnomalies(agentDID: string): Promise<AnomalyAlert[]>
|
|
355
|
+
getBehaviorProfile(agentDID: string): Promise<BehaviorProfile>
|
|
356
|
+
updateTrustScoreFromBehavior(agentDID: string, anomalies: AnomalyAlert[]): Promise<number>
|
|
357
|
+
getTrustScore(agentDID: string): Promise<number>
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
163
361
|
### Constants
|
|
164
362
|
|
|
165
363
|
```typescript
|
|
166
|
-
CORE_FACTORS
|
|
167
|
-
LIFE_CRITICAL_FACTORS
|
|
168
|
-
ALL_FACTORS
|
|
169
|
-
TIER_THRESHOLDS
|
|
170
|
-
|
|
364
|
+
CORE_FACTORS // 15 core trust factors with metadata
|
|
365
|
+
LIFE_CRITICAL_FACTORS // 8 life-critical factors with metadata
|
|
366
|
+
ALL_FACTORS // All 23 factors combined
|
|
367
|
+
TIER_THRESHOLDS // Score ranges per tier ({ min, max })
|
|
368
|
+
FACTOR_THRESHOLDS_BY_TIER // Per-factor thresholds at each tier (minimum, weight, critical)
|
|
369
|
+
FACTOR_MINIMUM_SCORE // Global minimum factor score (0.5)
|
|
370
|
+
TRUST_TIER_DISPLAY // Display config per tier (name, color, textColor)
|
|
371
|
+
CAPABILITIES_BY_TIER // Capability arrays indexed by TrustTier
|
|
372
|
+
TIER_CAPABILITY_SUMMARY // Human-readable capability summaries per tier
|
|
373
|
+
|
|
374
|
+
// Capability arrays per tier
|
|
375
|
+
T0_CAPABILITIES through T7_CAPABILITIES
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Zod Schemas
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
agentManifestSchema // Validates AgentManifest shape
|
|
382
|
+
registeredProfileSchema // Validates RegisteredProfile shape
|
|
383
|
+
validationIssueSchema // Validates ValidationIssue shape
|
|
384
|
+
validationGateResultSchema // Validates ValidationGateResult shape
|
|
171
385
|
```
|
|
172
386
|
|
|
173
|
-
|
|
387
|
+
### Key Interfaces
|
|
174
388
|
|
|
175
389
|
```typescript
|
|
176
390
|
import type {
|
|
177
|
-
|
|
178
|
-
FactorTier,
|
|
179
|
-
FactorCode,
|
|
180
|
-
CoreFactorCode,
|
|
181
|
-
LifeCriticalFactorCode,
|
|
391
|
+
// Trust scoring
|
|
182
392
|
FactorScore,
|
|
183
393
|
TrustEvaluation,
|
|
184
394
|
FactorThreshold,
|
|
395
|
+
|
|
396
|
+
// Capabilities
|
|
185
397
|
Capability,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
398
|
+
|
|
399
|
+
// Validation gate
|
|
400
|
+
AgentManifest,
|
|
401
|
+
RegisteredProfile,
|
|
402
|
+
ValidationGateResult,
|
|
403
|
+
ValidationGateOptions,
|
|
404
|
+
ValidationIssue,
|
|
405
|
+
CustomValidator,
|
|
406
|
+
|
|
407
|
+
// KYA types
|
|
189
408
|
KYAConfig,
|
|
409
|
+
DIDDocument,
|
|
410
|
+
DIDResolverConfig,
|
|
411
|
+
PolicyEngineConfig,
|
|
412
|
+
DatabaseConfig,
|
|
413
|
+
IdentityProof,
|
|
414
|
+
VerificationMethod,
|
|
415
|
+
AuthorizationRequest,
|
|
416
|
+
AuthorizationDecision,
|
|
417
|
+
CapabilityToken,
|
|
418
|
+
KYACapability,
|
|
419
|
+
PolicyBundle,
|
|
420
|
+
Constraint,
|
|
421
|
+
Obligation,
|
|
422
|
+
Permission,
|
|
423
|
+
AccountabilityRecord,
|
|
424
|
+
AccountabilityVerification,
|
|
425
|
+
BehaviorProfile,
|
|
426
|
+
AnomalyAlert,
|
|
427
|
+
TrustScoreComponents,
|
|
428
|
+
TrustScoreUpdate,
|
|
429
|
+
KYAMetadata,
|
|
430
|
+
ServiceEndpoint,
|
|
190
431
|
} from '@vorionsys/basis';
|
|
191
432
|
```
|
|
192
433
|
|
|
434
|
+
## Sub-path Imports
|
|
435
|
+
|
|
436
|
+
The KYA module can also be imported directly:
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
import { KYA, IdentityVerifier } from '@vorionsys/basis/kya';
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
## Requirements
|
|
443
|
+
|
|
444
|
+
- Node.js >= 18.0.0
|
|
445
|
+
- TypeScript >= 5.3 (recommended)
|
|
446
|
+
|
|
447
|
+
## Repository
|
|
448
|
+
|
|
449
|
+
This package is part of the [Vorion monorepo](https://github.com/voriongit/vorion) at `packages/basis`.
|
|
450
|
+
|
|
193
451
|
## License
|
|
194
452
|
|
|
195
|
-
Apache-2.0
|
|
453
|
+
[Apache-2.0](./LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BASIS - Baseline Authority for Safe & Interoperable Systems
|
|
3
|
+
*
|
|
4
|
+
* Core trust framework for autonomous AI agents
|
|
5
|
+
*/
|
|
6
|
+
export * from './trust-factors';
|
|
7
|
+
export * from './trust-capabilities';
|
|
8
|
+
export * from './validation-gate';
|
|
9
|
+
export * from './kya';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,iBAAiB,CAAC;AAGhC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,iBAAiB,CAAC;AAGhC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BASIS -
|
|
2
|
+
* BASIS - Baseline Authority for Safe & Interoperable Systems
|
|
3
3
|
*
|
|
4
4
|
* Core trust framework for autonomous AI agents
|
|
5
5
|
*/
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
export * from './trust-factors';
|
|
8
8
|
// Trust Capabilities - What agents can do at each tier
|
|
9
9
|
export * from './trust-capabilities';
|
|
10
|
+
// Validation Gate - Agent manifest validation
|
|
11
|
+
export * from './validation-gate';
|
|
10
12
|
// KYA (Know Your Agent) - Identity and authorization
|
|
11
13
|
export * from './kya';
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mCAAmC;AACnC,cAAc,iBAAiB,CAAC;AAEhC,uDAAuD;AACvD,cAAc,sBAAsB,CAAC;AAErC,8CAA8C;AAC9C,cAAc,mBAAmB,CAAC;AAElC,qDAAqD;AACrD,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KYA Accountability Chain
|
|
3
|
+
* Immutable hash-linked audit trail
|
|
4
|
+
*/
|
|
5
|
+
import { AccountabilityRecord, DatabaseConfig } from './types.js';
|
|
6
|
+
export declare class AccountabilityChain {
|
|
7
|
+
private config;
|
|
8
|
+
private records;
|
|
9
|
+
constructor(config: DatabaseConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Append record to accountability chain
|
|
12
|
+
*/
|
|
13
|
+
append(record: AccountabilityRecord): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Verify chain integrity for agent
|
|
16
|
+
*/
|
|
17
|
+
verify(agentDID: string): Promise<{
|
|
18
|
+
valid: boolean;
|
|
19
|
+
totalRecords: number;
|
|
20
|
+
brokenLinks: number;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Query records for agent
|
|
24
|
+
*/
|
|
25
|
+
query(agentDID: string, options?: {
|
|
26
|
+
action?: string;
|
|
27
|
+
timeRange?: [number, number];
|
|
28
|
+
outcome?: 'success' | 'failure' | 'denied';
|
|
29
|
+
}): Promise<AccountabilityRecord[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Calculate hash for record
|
|
32
|
+
*/
|
|
33
|
+
private calculateHash;
|
|
34
|
+
/**
|
|
35
|
+
* Update agent's accountability score
|
|
36
|
+
*/
|
|
37
|
+
private updateAccountabilityScore;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=accountability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountability.js","sourceRoot":"","sources":["../../src/kya/accountability.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,MAAM,OAAO,mBAAmB;IAGV;IAFZ,OAAO,CAAsC;IAErD,YAAoB,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,4CAA4C;IAC9C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,wCAAwC;QACxC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,UAAU,GAAG,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEzD,uBAAuB;QACvB,MAAM,CAAC,SA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Q;SACpC,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,yBAAyB,CACrC,QAAgB,EAChB,OAAyC;QAEzC,gDAAgD;QAChD,MAAM,MAAM,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,gDAAgD;IAClD,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KYA Authorization Manager
|
|
3
|
+
* Capability-based access control + policy enforcement
|
|
4
|
+
*/
|
|
5
|
+
import { AuthorizationRequest, AuthorizationDecision, CapabilityToken, PolicyEngineConfig } from './types.js';
|
|
6
|
+
export declare class AuthorizationManager {
|
|
7
|
+
private config;
|
|
8
|
+
private policyBundles;
|
|
9
|
+
private capabilities;
|
|
10
|
+
constructor(config: PolicyEngineConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Authorize agent action
|
|
13
|
+
*/
|
|
14
|
+
authorize(request: AuthorizationRequest): Promise<AuthorizationDecision>;
|
|
15
|
+
/**
|
|
16
|
+
* Grant capability to agent
|
|
17
|
+
*/
|
|
18
|
+
grantCapability(agentDID: string, capabilityToken: CapabilityToken): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Revoke capability from agent
|
|
21
|
+
*/
|
|
22
|
+
revokeCapability(agentDID: string, capabilityId: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Check if capability matches action + resource
|
|
25
|
+
*/
|
|
26
|
+
private matchesCapability;
|
|
27
|
+
/**
|
|
28
|
+
* Pattern matching with wildcards
|
|
29
|
+
*/
|
|
30
|
+
private matchesPattern;
|
|
31
|
+
/**
|
|
32
|
+
* Evaluate capability conditions
|
|
33
|
+
*/
|
|
34
|
+
private evaluateConditions;
|
|
35
|
+
/**
|
|
36
|
+
* Check policy constraints (MUST NOT do)
|
|
37
|
+
*/
|
|
38
|
+
private checkPolicyConstraints;
|
|
39
|
+
/**
|
|
40
|
+
* Evaluate constraint rule (simplified)
|
|
41
|
+
*/
|
|
42
|
+
private evaluateConstraint;
|
|
43
|
+
/**
|
|
44
|
+
* Load policy bundles from configuration
|
|
45
|
+
*/
|
|
46
|
+
private loadPolicyBundles;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../src/kya/authorization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,MAAM,OAAO,oBAAoB;IAIX;IAHZ,aAAa,CAA4B;IACzC,YAAY,CAAiC;IAErD,YAAoB,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;QAC5C,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAE9B,sBAAsB;QACtB,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,OAA6B;QAC3C,4BAA4B;QAC5B,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAExE,8BAA8B;QAC9B,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CACjD,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAAkB,EAAE,EAAE,CAC7C,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAC9D,CACF,C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O,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACjF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,iBAAiB;QACvB,iCAAiC;QACjC,0CAA0C;QAC1C,MAAM,aAAa,GAAiB;YAClC,EAAE,EAAE,mBAAmB;YACvB,OAAO,EAAE,OAAO;YAChB,YAAY,EAAE,QAAQ;YACtB,WAAW,EAAE;gBACX;oBACE,EAAE,EAAE,sBAAsB;oBAC1B,WAAW,EAAE,uCAAuC;oBACpD,IAAI,EAAE,sBAAsB;oBAC5B,QAAQ,EAAE,UAAU;oBACpB,WAAW,EAAE,OAAO;iBACrB;gBACD;oBACE,EAAE,EAAE,kBAAkB;oBACtB,WAAW,EAAE,qCAAqC;oBAClD,IAAI,EAAE,kBAAkB;oBACxB,QAAQ,EAAE,MAAM;oBAChB,WAAW,EAAE,OAAO;iBACrB;aACF;YACD,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,EAAE;SAChB,CAAC;QAEF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;CACF;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0CE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KYA Behavior Monitor
|
|
3
|
+
* Real-time anomaly detection + trust scoring
|
|
4
|
+
*/
|
|
5
|
+
import { AnomalyAlert, BehaviorProfile, DatabaseConfig } from './types.js';
|
|
6
|
+
export declare class BehaviorMonitor {
|
|
7
|
+
private config;
|
|
8
|
+
private profiles;
|
|
9
|
+
private trustScores;
|
|
10
|
+
constructor(config: DatabaseConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Detect anomalies in agent behavior
|
|
13
|
+
*/
|
|
14
|
+
detectAnomalies(agentDID: string): Promise<AnomalyAlert[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get or create behavior profile for agent
|
|
17
|
+
*/
|
|
18
|
+
getBehaviorProfile(agentDID: string): Promise<BehaviorProfile>;
|
|
19
|
+
/**
|
|
20
|
+
* Update trust score from behavior
|
|
21
|
+
*/
|
|
22
|
+
updateTrustScoreFromBehavior(agentDID: string, anomalies: AnomalyAlert[]): Promise<number>;
|
|
23
|
+
/**
|
|
24
|
+
* Get current trust score
|
|
25
|
+
*/
|
|
26
|
+
getTrustScore(agentDID: string): Promise<number>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=behavior.d.ts.map
|