@vorionsys/agentanchor-sdk 0.1.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/CHANGELOG.md +9 -0
- package/LICENSE +190 -0
- package/README.md +249 -0
- package/dist/car/index.d.ts +247 -0
- package/dist/car/index.d.ts.map +1 -0
- package/dist/car/index.js +372 -0
- package/dist/car/index.js.map +1 -0
- package/dist/client.d.ts +233 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +408 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +515 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +147 -0
- package/dist/types.js.map +1 -0
- package/package.json +75 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Vorion, Inc.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# @vorionsys/agentanchor-sdk
|
|
2
|
+
|
|
3
|
+
Official SDK for [Agent Anchor](https://agentanchor.io) - the AI agent registry, trust scoring, and attestation platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vorionsys/agentanchor-sdk
|
|
9
|
+
# or
|
|
10
|
+
yarn add @vorionsys/agentanchor-sdk
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @vorionsys/agentanchor-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { AgentAnchor, CapabilityLevel, AttestationType } from '@vorionsys/agentanchor-sdk';
|
|
19
|
+
|
|
20
|
+
// Initialize the client
|
|
21
|
+
const anchor = new AgentAnchor({
|
|
22
|
+
apiKey: 'your-api-key',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Register an agent
|
|
26
|
+
const agent = await anchor.registerAgent({
|
|
27
|
+
organization: 'acme',
|
|
28
|
+
agentClass: 'invoice-bot',
|
|
29
|
+
domains: ['A', 'B', 'F'], // Administration, Business, Finance
|
|
30
|
+
level: CapabilityLevel.L3_EXECUTE,
|
|
31
|
+
version: '1.0.0',
|
|
32
|
+
description: 'Processes invoices and payments',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log(`Registered agent: ${agent.aci}`);
|
|
36
|
+
// Output: Registered agent: a3i.acme.invoice-bot:ABF-L3@1.0.0
|
|
37
|
+
|
|
38
|
+
// Get trust score
|
|
39
|
+
const score = await anchor.getTrustScore(agent.aci);
|
|
40
|
+
console.log(`Trust: ${score.score}/1000 (Tier T${score.tier})`);
|
|
41
|
+
|
|
42
|
+
// Submit attestation
|
|
43
|
+
await anchor.submitAttestation({
|
|
44
|
+
aci: agent.aci,
|
|
45
|
+
type: AttestationType.BEHAVIORAL,
|
|
46
|
+
outcome: 'success',
|
|
47
|
+
action: 'process_invoice',
|
|
48
|
+
evidence: {
|
|
49
|
+
invoiceId: 'INV-001',
|
|
50
|
+
processingTime: 1250,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
### Agent Registration
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const agent = await anchor.registerAgent({
|
|
61
|
+
organization: 'your-org',
|
|
62
|
+
agentClass: 'your-agent',
|
|
63
|
+
domains: ['A', 'B'],
|
|
64
|
+
level: CapabilityLevel.L2_DRAFT,
|
|
65
|
+
version: '1.0.0',
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Trust Scoring
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// Get current trust score
|
|
73
|
+
const score = await anchor.getTrustScore(aci);
|
|
74
|
+
|
|
75
|
+
// Force refresh (bypass cache)
|
|
76
|
+
const freshScore = await anchor.getTrustScore(aci, true);
|
|
77
|
+
|
|
78
|
+
console.log(score.score); // 0-1000
|
|
79
|
+
console.log(score.tier); // TrustTier.T3_MONITORED
|
|
80
|
+
console.log(score.factors); // { behavioral, credential, temporal, audit, volume }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Attestations
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Submit attestation
|
|
87
|
+
await anchor.submitAttestation({
|
|
88
|
+
aci: agent.aci,
|
|
89
|
+
type: AttestationType.BEHAVIORAL,
|
|
90
|
+
outcome: 'success',
|
|
91
|
+
action: 'complete_task',
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Get attestations
|
|
95
|
+
const attestations = await anchor.getAttestations(agent.aci, 50);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Lifecycle Management
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { StateAction } from '@vorionsys/agentanchor-sdk';
|
|
102
|
+
|
|
103
|
+
// Request tier promotion
|
|
104
|
+
const result = await anchor.transitionState({
|
|
105
|
+
aci: agent.aci,
|
|
106
|
+
action: StateAction.REQUEST_APPROVAL,
|
|
107
|
+
reason: 'Agent has demonstrated consistent performance',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (result.pendingApproval) {
|
|
111
|
+
console.log('Awaiting human approval...');
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### ACI Utilities
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { parseACI, validateACI, generateACI } from '@vorionsys/agentanchor-sdk';
|
|
119
|
+
|
|
120
|
+
// Parse ACI string
|
|
121
|
+
const parsed = parseACI('a3i.acme.bot:ABF-L3@1.0.0');
|
|
122
|
+
console.log(parsed.domains); // ['A', 'B', 'F']
|
|
123
|
+
console.log(parsed.level); // 3
|
|
124
|
+
console.log(parsed.organization); // 'acme'
|
|
125
|
+
|
|
126
|
+
// Validate ACI
|
|
127
|
+
const result = validateACI('a3i.acme.bot:ABF-L3@1.0.0');
|
|
128
|
+
if (!result.valid) {
|
|
129
|
+
console.error(result.errors);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Generate ACI
|
|
133
|
+
const aci = generateACI({
|
|
134
|
+
registry: 'a3i',
|
|
135
|
+
organization: 'acme',
|
|
136
|
+
agentClass: 'bot',
|
|
137
|
+
domains: ['A', 'B', 'F'],
|
|
138
|
+
level: CapabilityLevel.L3_EXECUTE,
|
|
139
|
+
version: '1.0.0',
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Domain Codes
|
|
144
|
+
|
|
145
|
+
| Code | Domain | Description |
|
|
146
|
+
|------|--------|-------------|
|
|
147
|
+
| A | Administration | System admin, user management |
|
|
148
|
+
| B | Business | Business logic, workflows |
|
|
149
|
+
| C | Communications | Messaging, notifications |
|
|
150
|
+
| D | Data | Data processing, analytics |
|
|
151
|
+
| E | External | Third-party integrations |
|
|
152
|
+
| F | Finance | Payments, accounting |
|
|
153
|
+
| G | Governance | Policy, compliance |
|
|
154
|
+
| H | Hospitality | Venue, events, catering |
|
|
155
|
+
| I | Infrastructure | Compute, storage, network |
|
|
156
|
+
| S | Security | Auth, encryption, audit |
|
|
157
|
+
|
|
158
|
+
## Capability Levels
|
|
159
|
+
|
|
160
|
+
| Level | Name | Description |
|
|
161
|
+
|-------|------|-------------|
|
|
162
|
+
| L0 | Observe | Read-only access |
|
|
163
|
+
| L1 | Advise | Suggest/recommend |
|
|
164
|
+
| L2 | Draft | Prepare changes |
|
|
165
|
+
| L3 | Execute | Act with approval |
|
|
166
|
+
| L4 | Standard | External API access |
|
|
167
|
+
| L5 | Trusted | Cross-agent communication |
|
|
168
|
+
| L6 | Certified | Admin capabilities |
|
|
169
|
+
| L7 | Autonomous | Full autonomy |
|
|
170
|
+
|
|
171
|
+
## Trust Tiers
|
|
172
|
+
|
|
173
|
+
| Tier | Name | Score Range |
|
|
174
|
+
|------|------|-------------|
|
|
175
|
+
| T0 | Sandbox | 0-199 |
|
|
176
|
+
| T1 | Observed | 200-349 |
|
|
177
|
+
| T2 | Provisional | 350-499 |
|
|
178
|
+
| T3 | Monitored | 500-649 |
|
|
179
|
+
| T4 | Standard | 650-799 |
|
|
180
|
+
| T5 | Trusted | 800-875 |
|
|
181
|
+
| T6 | Certified | 876-950 |
|
|
182
|
+
| T7 | Autonomous | 951-1000 |
|
|
183
|
+
|
|
184
|
+
## Error Handling
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { AgentAnchorError, SDKErrorCode } from '@vorionsys/agentanchor-sdk';
|
|
188
|
+
|
|
189
|
+
try {
|
|
190
|
+
await anchor.getAgent('invalid-aci');
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error instanceof AgentAnchorError) {
|
|
193
|
+
switch (error.code) {
|
|
194
|
+
case SDKErrorCode.AGENT_NOT_FOUND:
|
|
195
|
+
console.log('Agent does not exist');
|
|
196
|
+
break;
|
|
197
|
+
case SDKErrorCode.INVALID_ACI:
|
|
198
|
+
console.log('Invalid ACI format');
|
|
199
|
+
break;
|
|
200
|
+
case SDKErrorCode.TRUST_INSUFFICIENT:
|
|
201
|
+
console.log('Agent trust level too low');
|
|
202
|
+
break;
|
|
203
|
+
default:
|
|
204
|
+
console.error(error.message);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Configuration
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
const anchor = new AgentAnchor({
|
|
214
|
+
apiKey: 'your-api-key',
|
|
215
|
+
baseUrl: 'https://api.agentanchor.io', // Custom API URL
|
|
216
|
+
timeout: 30000, // Request timeout (ms)
|
|
217
|
+
retries: 3, // Retry attempts
|
|
218
|
+
debug: false, // Enable debug logging
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## TypeScript Support
|
|
223
|
+
|
|
224
|
+
This SDK is written in TypeScript and provides full type definitions.
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
import type {
|
|
228
|
+
Agent,
|
|
229
|
+
TrustScore,
|
|
230
|
+
Attestation,
|
|
231
|
+
ParsedACI,
|
|
232
|
+
} from '@vorionsys/agentanchor-sdk';
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Related Packages
|
|
236
|
+
|
|
237
|
+
- `@vorion/kaizen-sdk` - Governance engine SDK
|
|
238
|
+
- `@vorion/cognigate-sdk` - Full platform SDK
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT
|
|
243
|
+
|
|
244
|
+
## Links
|
|
245
|
+
|
|
246
|
+
- [Documentation](https://docs.agentanchor.io)
|
|
247
|
+
- [API Reference](https://api.agentanchor.io/docs)
|
|
248
|
+
- [GitHub](https://github.com/agentanchor/sdk)
|
|
249
|
+
- [Agent Anchor](https://agentanchor.io)
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview CAR (Categorical Agentic Registry) parsing and validation
|
|
3
|
+
* @module @vorionsys/agentanchor-sdk/car
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { type DomainCode, CapabilityLevel } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Valid domain codes
|
|
9
|
+
*/
|
|
10
|
+
export declare const DOMAIN_CODES: readonly ["A", "B", "C", "D", "E", "F", "G", "H", "I", "S"];
|
|
11
|
+
/**
|
|
12
|
+
* Domain code descriptions
|
|
13
|
+
*/
|
|
14
|
+
export declare const DOMAIN_NAMES: Record<DomainCode, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Domain bitmask values
|
|
17
|
+
*/
|
|
18
|
+
export declare const DOMAIN_BITS: Record<DomainCode, number>;
|
|
19
|
+
/**
|
|
20
|
+
* CAR regex pattern
|
|
21
|
+
*
|
|
22
|
+
* Format: {registry}.{org}.{class}:{domains}-L{level}@{version}[#extensions]
|
|
23
|
+
*
|
|
24
|
+
* Examples:
|
|
25
|
+
* - a3i.vorion.banquet-advisor:FHC-L3@1.2.0
|
|
26
|
+
* - a3i.acme.support-agent:CD-L2@1.0.0#policy=strict
|
|
27
|
+
*/
|
|
28
|
+
export declare const CAR_REGEX: RegExp;
|
|
29
|
+
/**
|
|
30
|
+
* Semver regex pattern
|
|
31
|
+
*/
|
|
32
|
+
export declare const SEMVER_REGEX: RegExp;
|
|
33
|
+
/**
|
|
34
|
+
* Parsed CAR components
|
|
35
|
+
*/
|
|
36
|
+
export interface ParsedCAR {
|
|
37
|
+
/** Registry identifier (e.g., 'a3i') */
|
|
38
|
+
registry: string;
|
|
39
|
+
/** Organization slug */
|
|
40
|
+
organization: string;
|
|
41
|
+
/** Agent class name */
|
|
42
|
+
agentClass: string;
|
|
43
|
+
/** Capability domains as array */
|
|
44
|
+
domains: DomainCode[];
|
|
45
|
+
/** Domains as bitmask */
|
|
46
|
+
domainsBitmask: number;
|
|
47
|
+
/** Capability level */
|
|
48
|
+
level: CapabilityLevel;
|
|
49
|
+
/** Agent version (semver) */
|
|
50
|
+
version: string;
|
|
51
|
+
/** Optional extensions string */
|
|
52
|
+
extensions?: string;
|
|
53
|
+
/** Parsed extensions as key-value pairs */
|
|
54
|
+
parsedExtensions?: Record<string, string>;
|
|
55
|
+
/** Original CAR string */
|
|
56
|
+
raw: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* CAR validation error
|
|
60
|
+
*/
|
|
61
|
+
export interface CARValidationError {
|
|
62
|
+
/** Error code */
|
|
63
|
+
code: string;
|
|
64
|
+
/** Human-readable message */
|
|
65
|
+
message: string;
|
|
66
|
+
/** Position in string (if applicable) */
|
|
67
|
+
position?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* CAR validation warning
|
|
71
|
+
*/
|
|
72
|
+
export interface CARValidationWarning {
|
|
73
|
+
/** Warning code */
|
|
74
|
+
code: string;
|
|
75
|
+
/** Human-readable message */
|
|
76
|
+
message: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* CAR validation result
|
|
80
|
+
*/
|
|
81
|
+
export interface CARValidationResult {
|
|
82
|
+
/** Whether the CAR is valid */
|
|
83
|
+
valid: boolean;
|
|
84
|
+
/** Validation errors */
|
|
85
|
+
errors: CARValidationError[];
|
|
86
|
+
/** Validation warnings */
|
|
87
|
+
warnings: CARValidationWarning[];
|
|
88
|
+
/** Parsed CAR (if valid) */
|
|
89
|
+
parsed?: ParsedCAR;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Options for generating a CAR ID string
|
|
93
|
+
*/
|
|
94
|
+
export interface GenerateCAROptions {
|
|
95
|
+
/** Registry identifier */
|
|
96
|
+
registry: string;
|
|
97
|
+
/** Organization slug */
|
|
98
|
+
organization: string;
|
|
99
|
+
/** Agent class name */
|
|
100
|
+
agentClass: string;
|
|
101
|
+
/** Capability domains */
|
|
102
|
+
domains: DomainCode[];
|
|
103
|
+
/** Capability level */
|
|
104
|
+
level: CapabilityLevel;
|
|
105
|
+
/** Version string */
|
|
106
|
+
version: string;
|
|
107
|
+
/** Optional extensions */
|
|
108
|
+
extensions?: Record<string, string>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Parse a CAR ID string into components
|
|
112
|
+
*
|
|
113
|
+
* @param carId - CAR ID string to parse
|
|
114
|
+
* @returns Parsed CAR ID components
|
|
115
|
+
* @throws Error if CAR ID is invalid
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const parsed = parseCAR('a3i.vorion.banquet-advisor:FHC-L3@1.2.0');
|
|
120
|
+
* console.log(parsed.domains); // ['F', 'H', 'C']
|
|
121
|
+
* console.log(parsed.level); // 3
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare function parseCAR(carId: string): ParsedCAR;
|
|
125
|
+
/**
|
|
126
|
+
* Try to parse a CAR ID string, returning undefined if invalid
|
|
127
|
+
*
|
|
128
|
+
* @param carId - CAR ID string to parse
|
|
129
|
+
* @returns Parsed CAR ID or undefined
|
|
130
|
+
*/
|
|
131
|
+
export declare function tryParseCAR(carId: string): ParsedCAR | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Parse a domain string into array of domain codes
|
|
134
|
+
*
|
|
135
|
+
* @param domainString - Domain string (e.g., 'FHC')
|
|
136
|
+
* @returns Array of domain codes or undefined if invalid
|
|
137
|
+
*/
|
|
138
|
+
export declare function parseDomainString(domainString: string): DomainCode[] | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Validate a CAR ID string
|
|
141
|
+
*
|
|
142
|
+
* @param carId - CAR ID string to validate
|
|
143
|
+
* @returns Validation result with errors and warnings
|
|
144
|
+
*/
|
|
145
|
+
export declare function validateCAR(carId: string): CARValidationResult;
|
|
146
|
+
/**
|
|
147
|
+
* Check if a CAR ID string is valid
|
|
148
|
+
*
|
|
149
|
+
* @param carId - CAR ID string to check
|
|
150
|
+
* @returns Whether the CAR ID is valid
|
|
151
|
+
*/
|
|
152
|
+
export declare function isValidCAR(carId: string): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Generate a CAR ID string from components
|
|
155
|
+
*
|
|
156
|
+
* @param options - CAR ID components
|
|
157
|
+
* @returns Generated CAR ID string
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const carId = generateCAR({
|
|
162
|
+
* registry: 'a3i',
|
|
163
|
+
* organization: 'vorion',
|
|
164
|
+
* agentClass: 'banquet-advisor',
|
|
165
|
+
* domains: ['F', 'H', 'C'],
|
|
166
|
+
* level: CapabilityLevel.L3_EXECUTE,
|
|
167
|
+
* version: '1.2.0',
|
|
168
|
+
* });
|
|
169
|
+
* // Result: 'a3i.vorion.banquet-advisor:FHC-L3@1.2.0'
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function generateCAR(options: GenerateCAROptions): string;
|
|
173
|
+
/**
|
|
174
|
+
* Check if a string is a valid domain code
|
|
175
|
+
*/
|
|
176
|
+
export declare function isDomainCode(code: string): code is DomainCode;
|
|
177
|
+
/**
|
|
178
|
+
* Encode domain codes to bitmask
|
|
179
|
+
*
|
|
180
|
+
* @param domains - Array of domain codes
|
|
181
|
+
* @returns Bitmask representation
|
|
182
|
+
*/
|
|
183
|
+
export declare function encodeDomains(domains: DomainCode[]): number;
|
|
184
|
+
/**
|
|
185
|
+
* Decode bitmask to domain codes
|
|
186
|
+
*
|
|
187
|
+
* @param bitmask - Domain bitmask
|
|
188
|
+
* @returns Array of domain codes
|
|
189
|
+
*/
|
|
190
|
+
export declare function decodeDomains(bitmask: number): DomainCode[];
|
|
191
|
+
/**
|
|
192
|
+
* Check if domains satisfy required domains
|
|
193
|
+
*
|
|
194
|
+
* @param agentDomains - Agent's domains
|
|
195
|
+
* @param requiredDomains - Required domains
|
|
196
|
+
* @returns Whether agent has all required domains
|
|
197
|
+
*/
|
|
198
|
+
export declare function satisfiesDomainRequirements(agentDomains: DomainCode[], requiredDomains: DomainCode[]): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Get domain name from code
|
|
201
|
+
*/
|
|
202
|
+
export declare function getDomainName(code: DomainCode): string;
|
|
203
|
+
/**
|
|
204
|
+
* Level names
|
|
205
|
+
*/
|
|
206
|
+
export declare const LEVEL_NAMES: Record<CapabilityLevel, string>;
|
|
207
|
+
/**
|
|
208
|
+
* Check if agent level meets required level
|
|
209
|
+
*
|
|
210
|
+
* @param agentLevel - Agent's capability level
|
|
211
|
+
* @param requiredLevel - Required level
|
|
212
|
+
* @returns Whether agent meets requirement
|
|
213
|
+
*/
|
|
214
|
+
export declare function meetsLevelRequirement(agentLevel: CapabilityLevel, requiredLevel: CapabilityLevel): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Get level name from enum value
|
|
217
|
+
*/
|
|
218
|
+
export declare function getLevelName(level: CapabilityLevel): string;
|
|
219
|
+
export declare const domainCodeSchema: z.ZodEnum<["A", "B", "C", "D", "E", "F", "G", "H", "I", "S"]>;
|
|
220
|
+
export declare const capabilityLevelSchema: z.ZodNativeEnum<typeof CapabilityLevel>;
|
|
221
|
+
export declare const carIdStringSchema: z.ZodString;
|
|
222
|
+
export declare const generateCAROptionsSchema: z.ZodObject<{
|
|
223
|
+
registry: z.ZodString;
|
|
224
|
+
organization: z.ZodString;
|
|
225
|
+
agentClass: z.ZodString;
|
|
226
|
+
domains: z.ZodArray<z.ZodEnum<["A", "B", "C", "D", "E", "F", "G", "H", "I", "S"]>, "many">;
|
|
227
|
+
level: z.ZodNativeEnum<typeof CapabilityLevel>;
|
|
228
|
+
version: z.ZodString;
|
|
229
|
+
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
230
|
+
}, "strip", z.ZodTypeAny, {
|
|
231
|
+
registry: string;
|
|
232
|
+
organization: string;
|
|
233
|
+
agentClass: string;
|
|
234
|
+
version: string;
|
|
235
|
+
domains: ("A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "S")[];
|
|
236
|
+
level: CapabilityLevel;
|
|
237
|
+
extensions?: Record<string, string> | undefined;
|
|
238
|
+
}, {
|
|
239
|
+
registry: string;
|
|
240
|
+
organization: string;
|
|
241
|
+
agentClass: string;
|
|
242
|
+
version: string;
|
|
243
|
+
domains: ("A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "S")[];
|
|
244
|
+
level: CapabilityLevel;
|
|
245
|
+
extensions?: Record<string, string> | undefined;
|
|
246
|
+
}>;
|
|
247
|
+
//# sourceMappingURL=index.d.ts.map
|