@vorionsys/sdk 0.1.1 → 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.
- package/CHANGELOG.md +40 -0
- package/LICENSE +190 -0
- package/README.md +250 -75
- package/package.json +19 -8
- package/dist/__tests__/sdk.test.d.ts +0 -5
- package/dist/__tests__/sdk.test.d.ts.map +0 -1
- package/dist/__tests__/sdk.test.js +0 -164
- package/dist/__tests__/sdk.test.js.map +0 -1
- package/src/__tests__/sdk.test.ts +0 -201
- package/src/index.ts +0 -559
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@vorionsys/sdk` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.2] - 2026-02-17
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Removed raw `src` from published tarball (dist-only)
|
|
12
|
+
- Standardized package metadata for npm publish
|
|
13
|
+
|
|
14
|
+
## [0.1.1] - 2026-02-11
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Corrected default observation tier assignment during agent registration
|
|
19
|
+
- Improved error messages for missing capabilities in local mode
|
|
20
|
+
|
|
21
|
+
## [0.1.0] - 2026-02-08
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Initial release of `@vorionsys/sdk`
|
|
26
|
+
- `Vorion` client class with local and remote mode support
|
|
27
|
+
- `Agent` class with governance request lifecycle (register, request, report)
|
|
28
|
+
- `createVorion()` factory function
|
|
29
|
+
- Local mode with in-memory trust scoring and capability-based authorization
|
|
30
|
+
- Remote mode connecting to Cognigate API (`/api/v1/intents`, `/api/v1/trust`)
|
|
31
|
+
- Trust tier system (T0-T7) with asymmetric score adjustments
|
|
32
|
+
- Constraint application based on trust tier (rate limits, audit levels, sandboxing)
|
|
33
|
+
- Proof commitment IDs on every action decision for audit compliance
|
|
34
|
+
- Action history tracking per agent
|
|
35
|
+
- Health check endpoint support
|
|
36
|
+
- Full TypeScript type definitions (`VorionConfig`, `AgentOptions`, `ActionResult`, `TrustInfo`)
|
|
37
|
+
- Re-exported runtime types (`TrustTier`, `DecisionTier`, `AgentCredentials`, `Action`, `TrustSignal`)
|
|
38
|
+
|
|
39
|
+
[0.1.1]: https://github.com/vorionsys/vorion/compare/@vorionsys/sdk@0.1.0...@vorionsys/sdk@0.1.1
|
|
40
|
+
[0.1.0]: https://github.com/vorionsys/vorion/releases/tag/@vorionsys/sdk@0.1.0
|
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 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 those 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
|
|
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
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# @vorionsys/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Simple, developer-friendly SDK for AI agent governance powered by the Vorion platform and the BASIS (Baseline Authority for Safe & Interoperable Systems) framework.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@vorionsys/sdk)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
7
|
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
@@ -8,149 +11,302 @@ Developer-friendly SDK for AI agent governance. Register agents, request action
|
|
|
8
11
|
npm install @vorionsys/sdk
|
|
9
12
|
```
|
|
10
13
|
|
|
14
|
+
The SDK requires `@vorionsys/runtime` as a peer dependency:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @vorionsys/sdk @vorionsys/runtime
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## What It Provides
|
|
21
|
+
|
|
22
|
+
`@vorionsys/sdk` provides a simple interface for AI agent governance. It lets you:
|
|
23
|
+
|
|
24
|
+
- **Register agents** with declared capabilities and observation tiers
|
|
25
|
+
- **Submit governance requests** to check whether an agent is permitted to perform an action
|
|
26
|
+
- **Report outcomes** (success or failure) that dynamically adjust an agent's trust score
|
|
27
|
+
- **Query trust scores** to understand an agent's current standing in the trust tier system
|
|
28
|
+
|
|
29
|
+
The SDK operates in two modes: **local mode** for development and testing (in-memory, no external dependencies) and **remote mode** for production (connects to a Cognigate API instance).
|
|
30
|
+
|
|
11
31
|
## Quick Start
|
|
12
32
|
|
|
13
33
|
```typescript
|
|
14
34
|
import { Vorion } from '@vorionsys/sdk';
|
|
15
35
|
|
|
16
|
-
// Local mode
|
|
36
|
+
// Local mode -- in-memory governance for development and testing
|
|
17
37
|
const vorion = new Vorion({ localMode: true });
|
|
18
38
|
|
|
39
|
+
// 1. Register an agent with its capabilities
|
|
19
40
|
const agent = await vorion.registerAgent({
|
|
20
|
-
agentId: '
|
|
21
|
-
name: '
|
|
41
|
+
agentId: 'research-assistant',
|
|
42
|
+
name: 'Research Assistant',
|
|
22
43
|
capabilities: ['read:*', 'write:documents'],
|
|
23
44
|
});
|
|
24
45
|
|
|
46
|
+
// 2. Request permission before performing an action
|
|
25
47
|
const result = await agent.requestAction({
|
|
26
48
|
type: 'read',
|
|
27
|
-
resource: 'documents/report.pdf',
|
|
49
|
+
resource: 'documents/quarterly-report.pdf',
|
|
28
50
|
});
|
|
29
51
|
|
|
30
52
|
if (result.allowed) {
|
|
31
|
-
//
|
|
53
|
+
// Action is permitted -- perform it
|
|
54
|
+
console.log('Proof ID:', result.proofId); // audit trail
|
|
55
|
+
console.log('Constraints:', result.constraints); // e.g. ['rate_limit:100/min']
|
|
56
|
+
|
|
57
|
+
// 3. Report the outcome to update trust
|
|
32
58
|
await agent.reportSuccess('read');
|
|
33
59
|
} else {
|
|
34
60
|
console.log('Denied:', result.reason);
|
|
35
61
|
}
|
|
62
|
+
|
|
63
|
+
// 4. Check the agent's current trust score
|
|
64
|
+
const trust = await agent.getTrustInfo();
|
|
65
|
+
console.log(`Trust: ${trust.score}/1000 (${trust.tierName})`);
|
|
36
66
|
```
|
|
37
67
|
|
|
38
|
-
##
|
|
68
|
+
## Usage Examples
|
|
39
69
|
|
|
40
|
-
|
|
41
|
-
- **Local Mode**: In-memory governance for development and testing
|
|
42
|
-
- **Remote Mode**: Connect to a hosted Cognigate API for production
|
|
43
|
-
- **Trust Signals**: Report success/failure to dynamically update agent trust scores
|
|
44
|
-
- **Capability Checks**: Permission-based action authorization
|
|
45
|
-
- **Audit Trail**: Every action request returns a proof ID for compliance
|
|
46
|
-
- **Full TypeScript**: Complete type definitions for all APIs
|
|
70
|
+
### Registering an Agent
|
|
47
71
|
|
|
48
|
-
|
|
72
|
+
```typescript
|
|
73
|
+
import { Vorion } from '@vorionsys/sdk';
|
|
49
74
|
|
|
50
|
-
|
|
75
|
+
const vorion = new Vorion({ localMode: true });
|
|
51
76
|
|
|
52
|
-
|
|
77
|
+
const agent = await vorion.registerAgent({
|
|
78
|
+
agentId: 'data-analyst-01',
|
|
79
|
+
name: 'Data Analyst',
|
|
80
|
+
capabilities: ['read:*', 'write:reports', 'execute:queries'],
|
|
81
|
+
observationTier: 'GRAY_BOX', // BLACK_BOX | GRAY_BOX | WHITE_BOX
|
|
82
|
+
metadata: { version: '2.1', team: 'analytics' },
|
|
83
|
+
});
|
|
53
84
|
|
|
54
|
-
|
|
55
|
-
|
|
85
|
+
console.log(agent.getId()); // 'data-analyst-01'
|
|
86
|
+
console.log(agent.getName()); // 'Data Analyst'
|
|
87
|
+
console.log(agent.getCapabilities()); // ['read:*', 'write:reports', 'execute:queries']
|
|
56
88
|
```
|
|
57
89
|
|
|
58
|
-
###
|
|
90
|
+
### Submitting a Governance Request
|
|
59
91
|
|
|
60
|
-
|
|
92
|
+
Every action an agent wants to perform goes through the governance pipeline. The SDK checks capabilities and trust score, then returns a decision with an audit-grade proof ID.
|
|
61
93
|
|
|
62
94
|
```typescript
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
95
|
+
const result = await agent.requestAction({
|
|
96
|
+
type: 'write',
|
|
97
|
+
resource: 'reports/summary.md',
|
|
98
|
+
parameters: { format: 'markdown', overwrite: false },
|
|
66
99
|
});
|
|
100
|
+
|
|
101
|
+
// result structure:
|
|
102
|
+
// {
|
|
103
|
+
// allowed: true,
|
|
104
|
+
// tier: 'GREEN', // GREEN = approved, YELLOW = conditional, RED = denied
|
|
105
|
+
// reason: 'Action permitted',
|
|
106
|
+
// proofId: 'a1b2c3d4-...', // unique proof commitment ID for audit
|
|
107
|
+
// constraints: ['rate_limit:100/min', 'audit:standard'],
|
|
108
|
+
// }
|
|
67
109
|
```
|
|
68
110
|
|
|
69
|
-
|
|
111
|
+
### Checking Trust Scores
|
|
70
112
|
|
|
71
|
-
|
|
113
|
+
Trust scores range from 0 to 1000. Agents start at 500 (T3 -- Monitored) and move up or down based on reported outcomes. Trust adjustment is asymmetric: failures cost more than successes gain.
|
|
72
114
|
|
|
73
115
|
```typescript
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
116
|
+
const trust = await agent.getTrustInfo();
|
|
117
|
+
console.log(trust.score); // 500
|
|
118
|
+
console.log(trust.tierName); // 'Monitored'
|
|
119
|
+
console.log(trust.tierNumber); // 3
|
|
120
|
+
console.log(trust.observationTier); // 'GRAY_BOX'
|
|
121
|
+
|
|
122
|
+
// Report successes to build trust
|
|
123
|
+
await agent.reportSuccess('read');
|
|
124
|
+
await agent.reportSuccess('read');
|
|
125
|
+
|
|
126
|
+
const updated = await agent.getTrustInfo();
|
|
127
|
+
console.log(updated.score); // 504 (each success adds +2)
|
|
128
|
+
|
|
129
|
+
// Failures decrease trust more aggressively
|
|
130
|
+
await agent.reportFailure('write', 'Upstream permission denied');
|
|
81
131
|
|
|
82
|
-
|
|
132
|
+
const afterFailure = await agent.getTrustInfo();
|
|
133
|
+
console.log(afterFailure.score); // 484 (failure subtracts -20)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Using the Factory Function
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
83
139
|
import { createVorion } from '@vorionsys/sdk';
|
|
140
|
+
|
|
84
141
|
const vorion = createVorion({ localMode: true });
|
|
85
142
|
```
|
|
86
143
|
|
|
87
|
-
###
|
|
144
|
+
### Remote Mode (Production)
|
|
145
|
+
|
|
146
|
+
Connect to a Cognigate API instance for production-grade governance with persistent trust state, distributed coordination, and full audit logging.
|
|
88
147
|
|
|
89
148
|
```typescript
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
observationTier: 'GRAY_BOX', // Optional
|
|
95
|
-
metadata: { version: '1.0' }, // Optional
|
|
149
|
+
const vorion = new Vorion({
|
|
150
|
+
apiEndpoint: 'https://cognigate.example.com',
|
|
151
|
+
apiKey: process.env.VORION_API_KEY,
|
|
152
|
+
timeout: 15000, // request timeout in ms (default: 30000)
|
|
96
153
|
});
|
|
97
|
-
```
|
|
98
154
|
|
|
99
|
-
|
|
155
|
+
// API works identically -- the SDK handles remote calls transparently
|
|
156
|
+
const agent = await vorion.registerAgent({
|
|
157
|
+
agentId: 'prod-agent',
|
|
158
|
+
name: 'Production Agent',
|
|
159
|
+
capabilities: ['read:*'],
|
|
160
|
+
});
|
|
100
161
|
|
|
101
|
-
```typescript
|
|
102
162
|
const result = await agent.requestAction({
|
|
103
163
|
type: 'read',
|
|
104
|
-
resource: '
|
|
105
|
-
parameters: { format: 'json' }, // Optional
|
|
164
|
+
resource: 'data/users.json',
|
|
106
165
|
});
|
|
107
166
|
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
// tier: 'GREEN' | 'YELLOW' | 'RED',
|
|
111
|
-
// reason: string,
|
|
112
|
-
// proofId: string,
|
|
113
|
-
// constraints?: string[],
|
|
114
|
-
// processingTimeMs?: number, // Remote mode only
|
|
115
|
-
// }
|
|
167
|
+
// Remote mode includes server-side processing time
|
|
168
|
+
console.log(result.processingTimeMs); // e.g. 12
|
|
116
169
|
```
|
|
117
170
|
|
|
118
|
-
###
|
|
171
|
+
### Health Check
|
|
119
172
|
|
|
120
173
|
```typescript
|
|
121
|
-
|
|
122
|
-
|
|
174
|
+
const health = await vorion.healthCheck();
|
|
175
|
+
// Local: { status: 'healthy', version: 'local' }
|
|
176
|
+
// Remote: { status: 'healthy', version: '1.2.0' }
|
|
177
|
+
```
|
|
123
178
|
|
|
124
|
-
|
|
125
|
-
await agent.reportFailure('write', 'Permission denied by upstream service');
|
|
179
|
+
### Managing Multiple Agents
|
|
126
180
|
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
181
|
+
```typescript
|
|
182
|
+
const vorion = new Vorion({ localMode: true });
|
|
183
|
+
|
|
184
|
+
await vorion.registerAgent({ agentId: 'agent-a', name: 'Agent A', capabilities: ['read:*'] });
|
|
185
|
+
await vorion.registerAgent({ agentId: 'agent-b', name: 'Agent B', capabilities: ['write:*'] });
|
|
186
|
+
|
|
187
|
+
const agentA = vorion.getAgent('agent-a'); // Agent | undefined
|
|
188
|
+
const all = vorion.getAllAgents(); // Agent[]
|
|
189
|
+
console.log(all.length); // 2
|
|
190
|
+
console.log(vorion.isLocalMode()); // true
|
|
130
191
|
```
|
|
131
192
|
|
|
132
|
-
|
|
193
|
+
## API Reference
|
|
194
|
+
|
|
195
|
+
### Exports
|
|
196
|
+
|
|
197
|
+
| Export | Type | Description |
|
|
198
|
+
|--------|------|-------------|
|
|
199
|
+
| `Vorion` | Class | Main SDK client for agent governance |
|
|
200
|
+
| `Agent` | Class | Agent wrapper returned by `registerAgent()` |
|
|
201
|
+
| `createVorion` | Function | Factory function to create a `Vorion` instance |
|
|
202
|
+
| `VorionConfig` | Interface | Configuration options for `Vorion` |
|
|
203
|
+
| `AgentOptions` | Interface | Options for registering an agent |
|
|
204
|
+
| `ActionResult` | Interface | Result returned by `requestAction()` |
|
|
205
|
+
| `TrustInfo` | Interface | Trust score information from `getTrustInfo()` |
|
|
206
|
+
| `TrustTier` | Type | Re-exported from `@vorionsys/runtime` |
|
|
207
|
+
| `DecisionTier` | Type | Re-exported from `@vorionsys/runtime` |
|
|
208
|
+
| `AgentCredentials` | Type | Re-exported from `@vorionsys/runtime` |
|
|
209
|
+
| `Action` | Type | Re-exported from `@vorionsys/runtime` |
|
|
210
|
+
| `TrustSignal` | Type | Re-exported from `@vorionsys/runtime` |
|
|
211
|
+
|
|
212
|
+
### `Vorion` Class
|
|
133
213
|
|
|
134
214
|
```typescript
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
215
|
+
new Vorion(config?: VorionConfig)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Config options:**
|
|
219
|
+
|
|
220
|
+
| Property | Type | Default | Description |
|
|
221
|
+
|----------|------|---------|-------------|
|
|
222
|
+
| `apiEndpoint` | `string` | -- | Cognigate API URL. Enables remote mode when set. |
|
|
223
|
+
| `apiKey` | `string` | -- | API key. Required when `apiEndpoint` is set. |
|
|
224
|
+
| `localMode` | `boolean` | `true` | Force local (in-memory) mode. Defaults to `true` when no endpoint is provided. |
|
|
225
|
+
| `defaultObservationTier` | `'BLACK_BOX' \| 'GRAY_BOX' \| 'WHITE_BOX'` | `'GRAY_BOX'` | Default observation tier for registered agents. |
|
|
226
|
+
| `timeout` | `number` | `30000` | Request timeout in milliseconds (remote mode). |
|
|
227
|
+
|
|
228
|
+
**Methods:**
|
|
229
|
+
|
|
230
|
+
| Method | Returns | Description |
|
|
231
|
+
|--------|---------|-------------|
|
|
232
|
+
| `registerAgent(options)` | `Promise<Agent>` | Register an agent with the governance system |
|
|
233
|
+
| `getAgent(agentId)` | `Agent \| undefined` | Retrieve a registered agent by ID |
|
|
234
|
+
| `getAllAgents()` | `Agent[]` | List all registered agents |
|
|
235
|
+
| `getConfig()` | `VorionConfig` | Get the current SDK configuration |
|
|
236
|
+
| `isLocalMode()` | `boolean` | Check if the SDK is running in local mode |
|
|
237
|
+
| `healthCheck()` | `Promise<{ status, version }>` | Check API health (returns local status in local mode) |
|
|
238
|
+
|
|
239
|
+
### `Agent` Class
|
|
240
|
+
|
|
241
|
+
Returned by `vorion.registerAgent()`. Do not instantiate directly.
|
|
242
|
+
|
|
243
|
+
**Methods:**
|
|
244
|
+
|
|
245
|
+
| Method | Returns | Description |
|
|
246
|
+
|--------|---------|-------------|
|
|
247
|
+
| `requestAction(action)` | `Promise<ActionResult>` | Request permission to perform an action |
|
|
248
|
+
| `reportSuccess(actionType)` | `Promise<void>` | Report a successful action (positive trust signal, +2 score in local mode) |
|
|
249
|
+
| `reportFailure(actionType, reason?)` | `Promise<void>` | Report a failed action (negative trust signal, -20 score in local mode) |
|
|
250
|
+
| `getTrustInfo()` | `Promise<TrustInfo>` | Get current trust score and tier information |
|
|
251
|
+
| `getId()` | `string` | Get the agent's unique identifier |
|
|
252
|
+
| `getName()` | `string` | Get the agent's human-readable name |
|
|
253
|
+
| `getCapabilities()` | `string[]` | Get the agent's declared capabilities |
|
|
254
|
+
| `getActionHistory()` | `Array<{ action, allowed, timestamp }>` | Get the agent's action request history |
|
|
255
|
+
|
|
256
|
+
### `ActionResult` Interface
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
interface ActionResult {
|
|
260
|
+
allowed: boolean; // Whether the action was permitted
|
|
261
|
+
tier: 'GREEN' | 'YELLOW' | 'RED'; // Decision tier
|
|
262
|
+
reason: string; // Human-readable explanation
|
|
263
|
+
proofId: string; // Unique proof commitment ID for audit
|
|
264
|
+
constraints?: string[]; // Applied constraints (e.g. rate limits)
|
|
265
|
+
processingTimeMs?: number; // Server processing time (remote mode only)
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### `TrustInfo` Interface
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
interface TrustInfo {
|
|
273
|
+
score: number; // Current trust score (0-1000)
|
|
274
|
+
tierName: string; // Human-readable tier name (e.g. 'Monitored')
|
|
275
|
+
tierNumber: number; // Tier number (0-7)
|
|
276
|
+
observationTier: string; // Observation tier (BLACK_BOX, GRAY_BOX, WHITE_BOX)
|
|
277
|
+
}
|
|
139
278
|
```
|
|
140
279
|
|
|
141
280
|
## Trust Tiers
|
|
142
281
|
|
|
143
|
-
Agents start at T3 (Monitored, score 500) in local mode. Trust adjusts based on signals
|
|
282
|
+
Agents start at T3 (Monitored, score 500) in local mode. Trust adjusts asymmetrically based on reported signals -- successes increase score gradually while failures decrease it more aggressively.
|
|
283
|
+
|
|
284
|
+
| Tier | Score Range | Name | Constraints |
|
|
285
|
+
|------|-------------|------|-------------|
|
|
286
|
+
| T0 | 0--199 | Sandbox | `rate_limit:10/min`, `audit:full`, `sandbox:true` |
|
|
287
|
+
| T1 | 200--349 | Observed | `rate_limit:10/min`, `audit:full`, `sandbox:true` |
|
|
288
|
+
| T2 | 350--499 | Provisional | `rate_limit:100/min`, `audit:standard` |
|
|
289
|
+
| T3 | 500--649 | Monitored | `rate_limit:100/min`, `audit:standard` |
|
|
290
|
+
| T4 | 650--799 | Standard | `rate_limit:1000/min`, `audit:light` |
|
|
291
|
+
| T5 | 800--875 | Trusted | `rate_limit:1000/min`, `audit:light` |
|
|
292
|
+
| T6 | 876--950 | Certified | No constraints |
|
|
293
|
+
| T7 | 951--1000 | Autonomous | No constraints |
|
|
294
|
+
|
|
295
|
+
## Capability Patterns
|
|
144
296
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
|
148
|
-
|
|
149
|
-
|
|
|
150
|
-
|
|
|
297
|
+
Capabilities use a `type:resource` pattern with glob support:
|
|
298
|
+
|
|
299
|
+
| Pattern | Matches |
|
|
300
|
+
|---------|---------|
|
|
301
|
+
| `read` | Exact match on `read` action type |
|
|
302
|
+
| `read:*` | Any `read` action regardless of resource |
|
|
303
|
+
| `read:documents` | `read` actions on resources starting with `documents/` |
|
|
304
|
+
| `*` | All actions (unrestricted) |
|
|
151
305
|
|
|
152
306
|
## TypeScript
|
|
153
307
|
|
|
308
|
+
The SDK ships with full TypeScript type definitions. All interfaces and types are exported for direct use:
|
|
309
|
+
|
|
154
310
|
```typescript
|
|
155
311
|
import type {
|
|
156
312
|
VorionConfig,
|
|
@@ -165,6 +321,25 @@ import type {
|
|
|
165
321
|
} from '@vorionsys/sdk';
|
|
166
322
|
```
|
|
167
323
|
|
|
324
|
+
## Requirements
|
|
325
|
+
|
|
326
|
+
- Node.js >= 18.0.0
|
|
327
|
+
- `@vorionsys/runtime` >= 0.1.0 (peer dependency)
|
|
328
|
+
|
|
329
|
+
## Related Packages
|
|
330
|
+
|
|
331
|
+
| Package | Description |
|
|
332
|
+
|---------|-------------|
|
|
333
|
+
| [`@vorionsys/runtime`](https://www.npmjs.com/package/@vorionsys/runtime) | Core orchestration layer (trust facade, proof committer, intent pipeline) |
|
|
334
|
+
|
|
335
|
+
## Contributing
|
|
336
|
+
|
|
337
|
+
See the [main repository](https://github.com/vorionsys/vorion) for contribution guidelines.
|
|
338
|
+
|
|
168
339
|
## License
|
|
169
340
|
|
|
170
|
-
|
|
341
|
+
Apache-2.0 -- see [LICENSE](./LICENSE) for details.
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
Part of the [Vorion](https://github.com/vorionsys/vorion) project.
|