@vess-id/ai-identity 0.0.1
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/README.md +153 -0
- package/dist/index.js +4573 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4513 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @vesslabs/ai-identity
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for AI Identity Layer - Secure delegation system for AI agents accessing external services.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vesslabs/ai-identity
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @vesslabs/ai-identity
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { AIdentityClient } from '@vesslabs/ai-identity'
|
|
17
|
+
|
|
18
|
+
// Initialize client
|
|
19
|
+
const client = new AIdentityClient({
|
|
20
|
+
proxyApi: {
|
|
21
|
+
baseUrl: 'http://localhost:3000' // Your Identity API endpoint
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// Create agent
|
|
26
|
+
const agent = await client.setup()
|
|
27
|
+
|
|
28
|
+
// Issue permission VC
|
|
29
|
+
const vc = await client.issueToolPermission('slack', 'postMessage', {
|
|
30
|
+
subjectDid: agent.did,
|
|
31
|
+
resourceScope: { channel: 'C123456' },
|
|
32
|
+
expiresIn: '1h'
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// Use the permission
|
|
36
|
+
const result = await client.invokeTool('slack', 'postMessage', {
|
|
37
|
+
channel: 'C123456',
|
|
38
|
+
text: 'Hello from AI Agent!'
|
|
39
|
+
}, [vc])
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Core Concepts
|
|
43
|
+
|
|
44
|
+
### Agents
|
|
45
|
+
Agents are autonomous entities with their own DID (Decentralized Identifier). Each agent has:
|
|
46
|
+
- A unique `did:jwk` identifier
|
|
47
|
+
- Public/private key pair for signing
|
|
48
|
+
- Local encrypted key storage
|
|
49
|
+
|
|
50
|
+
### Verifiable Credentials (VCs)
|
|
51
|
+
VCs represent permissions or capabilities:
|
|
52
|
+
- **ToolPermissionVC**: Permission to use a specific tool/action
|
|
53
|
+
- **DataAccessVC**: Permission to access data resources
|
|
54
|
+
|
|
55
|
+
### Verifiable Presentations (VPs)
|
|
56
|
+
VPs are signed presentations of VCs that agents use to prove their permissions when accessing services.
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### AIdentityClient
|
|
61
|
+
|
|
62
|
+
#### Constructor
|
|
63
|
+
```typescript
|
|
64
|
+
new AIdentityClient(config?: AIdentityConfig, password?: string)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Methods
|
|
68
|
+
|
|
69
|
+
##### `setup(did?: string): Promise<Agent>`
|
|
70
|
+
Create or load an agent.
|
|
71
|
+
|
|
72
|
+
##### `issueToolPermission(tool, action, options): Promise<string>`
|
|
73
|
+
Issue a VC for tool permission.
|
|
74
|
+
|
|
75
|
+
##### `issueDataAccess(resource, actions, options): Promise<string>`
|
|
76
|
+
Issue a VC for data access.
|
|
77
|
+
|
|
78
|
+
##### `invokeTool<T>(tool, action, params, vcs): Promise<ConnectorResponse<T>>`
|
|
79
|
+
Invoke a tool with VC authorization.
|
|
80
|
+
|
|
81
|
+
##### `writeMemory(content, namespace, vcs, metadata?)`
|
|
82
|
+
Write to memory with VC authorization.
|
|
83
|
+
|
|
84
|
+
##### `queryMemory(query, vcs, options?)`
|
|
85
|
+
Query memory with VC authorization.
|
|
86
|
+
|
|
87
|
+
### Supported Tools
|
|
88
|
+
|
|
89
|
+
#### Slack
|
|
90
|
+
- `postMessage`: Post messages to channels
|
|
91
|
+
- `getChannels`: List available channels
|
|
92
|
+
- `getUserInfo`: Get user information
|
|
93
|
+
|
|
94
|
+
#### GitHub
|
|
95
|
+
- `createIssue`: Create repository issues
|
|
96
|
+
- `listIssues`: List repository issues
|
|
97
|
+
- `getRepo`: Get repository information
|
|
98
|
+
|
|
99
|
+
#### Gmail
|
|
100
|
+
- `readMail`: Read email messages
|
|
101
|
+
- `listMails`: List email messages
|
|
102
|
+
- `getLabels`: Get available labels
|
|
103
|
+
|
|
104
|
+
#### Google Drive
|
|
105
|
+
- `readFile`: Read file content
|
|
106
|
+
- `listFiles`: List files in folder
|
|
107
|
+
- `getFolders`: List folders
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
interface AIdentityConfig {
|
|
113
|
+
didApi?: {
|
|
114
|
+
baseUrl: string
|
|
115
|
+
apiKey?: string
|
|
116
|
+
bearerToken?: string
|
|
117
|
+
}
|
|
118
|
+
issuerApi?: {
|
|
119
|
+
baseUrl: string
|
|
120
|
+
apiKey?: string
|
|
121
|
+
bearerToken?: string
|
|
122
|
+
}
|
|
123
|
+
verifierApi?: {
|
|
124
|
+
baseUrl: string
|
|
125
|
+
apiKey?: string
|
|
126
|
+
bearerToken?: string
|
|
127
|
+
}
|
|
128
|
+
proxyApi?: {
|
|
129
|
+
baseUrl: string
|
|
130
|
+
}
|
|
131
|
+
storage?: {
|
|
132
|
+
keyStorePath?: string // Default: ~/.vess/keys
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Examples
|
|
138
|
+
|
|
139
|
+
See the `examples/` directory for complete usage examples:
|
|
140
|
+
|
|
141
|
+
- `basic-usage.ts`: Basic SDK usage
|
|
142
|
+
- `github-integration.ts`: GitHub integration example
|
|
143
|
+
|
|
144
|
+
## Security
|
|
145
|
+
|
|
146
|
+
- Private keys are stored locally and encrypted with optional password
|
|
147
|
+
- VCs have configurable expiration times
|
|
148
|
+
- VPs include nonce and domain binding to prevent replay attacks
|
|
149
|
+
- All tool invocations require proper VC authorization
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT
|