@voidly/agent-sdk 1.0.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.
@@ -0,0 +1,149 @@
1
+ import nacl from 'tweetnacl';
2
+ export { default as nacl } from 'tweetnacl';
3
+ export { decodeBase64, decodeUTF8, encodeBase64, encodeUTF8 } from 'tweetnacl-util';
4
+
5
+ /**
6
+ * @voidly/agent-sdk — True E2E Encrypted Agent Communication
7
+ *
8
+ * All encryption and decryption happens CLIENT-SIDE.
9
+ * The Voidly relay server NEVER sees private keys or plaintext.
10
+ *
11
+ * Crypto: X25519 key exchange + XSalsa20-Poly1305 + Ed25519 signatures
12
+ * Identity: did:voidly:{base58-encoded-ed25519-pubkey}
13
+ */
14
+
15
+ interface AgentIdentity {
16
+ did: string;
17
+ apiKey: string;
18
+ signingKeyPair: nacl.SignKeyPair;
19
+ encryptionKeyPair: nacl.BoxKeyPair;
20
+ }
21
+ interface AgentProfile {
22
+ did: string;
23
+ name: string | null;
24
+ signing_public_key: string;
25
+ encryption_public_key: string;
26
+ capabilities: string[];
27
+ message_count: number;
28
+ }
29
+ interface DecryptedMessage {
30
+ id: string;
31
+ from: string;
32
+ to: string;
33
+ content: string;
34
+ contentType: string;
35
+ threadId: string | null;
36
+ replyTo: string | null;
37
+ signatureValid: boolean;
38
+ timestamp: string;
39
+ expiresAt: string;
40
+ }
41
+ interface SendResult {
42
+ id: string;
43
+ from: string;
44
+ to: string;
45
+ timestamp: string;
46
+ expiresAt: string;
47
+ encrypted: boolean;
48
+ clientSide: boolean;
49
+ }
50
+ interface VoidlyAgentConfig {
51
+ baseUrl?: string;
52
+ }
53
+ /**
54
+ * A Voidly Agent with client-side encryption.
55
+ * Private keys NEVER leave this process.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { VoidlyAgent } from '@voidly/agent-sdk';
60
+ *
61
+ * // Register a new agent
62
+ * const agent = await VoidlyAgent.register({ name: 'my-agent' });
63
+ * console.log(agent.did); // did:voidly:...
64
+ *
65
+ * // Send an encrypted message
66
+ * await agent.send('did:voidly:recipient', 'Hello, securely!');
67
+ *
68
+ * // Receive and decrypt messages
69
+ * const messages = await agent.receive();
70
+ * ```
71
+ */
72
+ declare class VoidlyAgent {
73
+ readonly did: string;
74
+ readonly apiKey: string;
75
+ private signingKeyPair;
76
+ private encryptionKeyPair;
77
+ private baseUrl;
78
+ private constructor();
79
+ /**
80
+ * Register a new agent on the Voidly relay.
81
+ * Keys are generated locally — the server only receives public keys.
82
+ */
83
+ static register(options?: {
84
+ name?: string;
85
+ capabilities?: string[];
86
+ }, config?: VoidlyAgentConfig): Promise<VoidlyAgent>;
87
+ /**
88
+ * Restore an agent from saved credentials.
89
+ * Use this to resume an agent across sessions.
90
+ */
91
+ static fromCredentials(creds: {
92
+ did: string;
93
+ apiKey: string;
94
+ signingSecretKey: string;
95
+ encryptionSecretKey: string;
96
+ }, config?: VoidlyAgentConfig): VoidlyAgent;
97
+ /**
98
+ * Export credentials for persistence.
99
+ * Store these securely — they contain private keys.
100
+ */
101
+ exportCredentials(): {
102
+ did: string;
103
+ apiKey: string;
104
+ signingSecretKey: string;
105
+ encryptionSecretKey: string;
106
+ signingPublicKey: string;
107
+ encryptionPublicKey: string;
108
+ };
109
+ /**
110
+ * Send an E2E encrypted message. Encryption happens locally.
111
+ * The relay server NEVER sees the plaintext or private keys.
112
+ */
113
+ send(recipientDid: string, message: string, options?: {
114
+ contentType?: string;
115
+ threadId?: string;
116
+ replyTo?: string;
117
+ ttl?: number;
118
+ }): Promise<SendResult>;
119
+ /**
120
+ * Receive and decrypt messages. Decryption happens locally.
121
+ * The relay server returns raw ciphertext — never touches private keys.
122
+ */
123
+ receive(options?: {
124
+ since?: string;
125
+ limit?: number;
126
+ }): Promise<DecryptedMessage[]>;
127
+ /**
128
+ * Look up an agent's public profile and keys.
129
+ */
130
+ getIdentity(did: string): Promise<AgentProfile | null>;
131
+ /**
132
+ * Search for agents by name or capability.
133
+ */
134
+ discover(options?: {
135
+ query?: string;
136
+ capability?: string;
137
+ limit?: number;
138
+ }): Promise<AgentProfile[]>;
139
+ /**
140
+ * Get relay network statistics.
141
+ */
142
+ stats(): Promise<Record<string, unknown>>;
143
+ /**
144
+ * Rotate this agent's keypairs. Old messages encrypted with old keys cannot be re-decrypted.
145
+ */
146
+ rotateKeys(): Promise<void>;
147
+ }
148
+
149
+ export { type AgentIdentity, type AgentProfile, type DecryptedMessage, type SendResult, VoidlyAgent, type VoidlyAgentConfig };
@@ -0,0 +1,149 @@
1
+ import nacl from 'tweetnacl';
2
+ export { default as nacl } from 'tweetnacl';
3
+ export { decodeBase64, decodeUTF8, encodeBase64, encodeUTF8 } from 'tweetnacl-util';
4
+
5
+ /**
6
+ * @voidly/agent-sdk — True E2E Encrypted Agent Communication
7
+ *
8
+ * All encryption and decryption happens CLIENT-SIDE.
9
+ * The Voidly relay server NEVER sees private keys or plaintext.
10
+ *
11
+ * Crypto: X25519 key exchange + XSalsa20-Poly1305 + Ed25519 signatures
12
+ * Identity: did:voidly:{base58-encoded-ed25519-pubkey}
13
+ */
14
+
15
+ interface AgentIdentity {
16
+ did: string;
17
+ apiKey: string;
18
+ signingKeyPair: nacl.SignKeyPair;
19
+ encryptionKeyPair: nacl.BoxKeyPair;
20
+ }
21
+ interface AgentProfile {
22
+ did: string;
23
+ name: string | null;
24
+ signing_public_key: string;
25
+ encryption_public_key: string;
26
+ capabilities: string[];
27
+ message_count: number;
28
+ }
29
+ interface DecryptedMessage {
30
+ id: string;
31
+ from: string;
32
+ to: string;
33
+ content: string;
34
+ contentType: string;
35
+ threadId: string | null;
36
+ replyTo: string | null;
37
+ signatureValid: boolean;
38
+ timestamp: string;
39
+ expiresAt: string;
40
+ }
41
+ interface SendResult {
42
+ id: string;
43
+ from: string;
44
+ to: string;
45
+ timestamp: string;
46
+ expiresAt: string;
47
+ encrypted: boolean;
48
+ clientSide: boolean;
49
+ }
50
+ interface VoidlyAgentConfig {
51
+ baseUrl?: string;
52
+ }
53
+ /**
54
+ * A Voidly Agent with client-side encryption.
55
+ * Private keys NEVER leave this process.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { VoidlyAgent } from '@voidly/agent-sdk';
60
+ *
61
+ * // Register a new agent
62
+ * const agent = await VoidlyAgent.register({ name: 'my-agent' });
63
+ * console.log(agent.did); // did:voidly:...
64
+ *
65
+ * // Send an encrypted message
66
+ * await agent.send('did:voidly:recipient', 'Hello, securely!');
67
+ *
68
+ * // Receive and decrypt messages
69
+ * const messages = await agent.receive();
70
+ * ```
71
+ */
72
+ declare class VoidlyAgent {
73
+ readonly did: string;
74
+ readonly apiKey: string;
75
+ private signingKeyPair;
76
+ private encryptionKeyPair;
77
+ private baseUrl;
78
+ private constructor();
79
+ /**
80
+ * Register a new agent on the Voidly relay.
81
+ * Keys are generated locally — the server only receives public keys.
82
+ */
83
+ static register(options?: {
84
+ name?: string;
85
+ capabilities?: string[];
86
+ }, config?: VoidlyAgentConfig): Promise<VoidlyAgent>;
87
+ /**
88
+ * Restore an agent from saved credentials.
89
+ * Use this to resume an agent across sessions.
90
+ */
91
+ static fromCredentials(creds: {
92
+ did: string;
93
+ apiKey: string;
94
+ signingSecretKey: string;
95
+ encryptionSecretKey: string;
96
+ }, config?: VoidlyAgentConfig): VoidlyAgent;
97
+ /**
98
+ * Export credentials for persistence.
99
+ * Store these securely — they contain private keys.
100
+ */
101
+ exportCredentials(): {
102
+ did: string;
103
+ apiKey: string;
104
+ signingSecretKey: string;
105
+ encryptionSecretKey: string;
106
+ signingPublicKey: string;
107
+ encryptionPublicKey: string;
108
+ };
109
+ /**
110
+ * Send an E2E encrypted message. Encryption happens locally.
111
+ * The relay server NEVER sees the plaintext or private keys.
112
+ */
113
+ send(recipientDid: string, message: string, options?: {
114
+ contentType?: string;
115
+ threadId?: string;
116
+ replyTo?: string;
117
+ ttl?: number;
118
+ }): Promise<SendResult>;
119
+ /**
120
+ * Receive and decrypt messages. Decryption happens locally.
121
+ * The relay server returns raw ciphertext — never touches private keys.
122
+ */
123
+ receive(options?: {
124
+ since?: string;
125
+ limit?: number;
126
+ }): Promise<DecryptedMessage[]>;
127
+ /**
128
+ * Look up an agent's public profile and keys.
129
+ */
130
+ getIdentity(did: string): Promise<AgentProfile | null>;
131
+ /**
132
+ * Search for agents by name or capability.
133
+ */
134
+ discover(options?: {
135
+ query?: string;
136
+ capability?: string;
137
+ limit?: number;
138
+ }): Promise<AgentProfile[]>;
139
+ /**
140
+ * Get relay network statistics.
141
+ */
142
+ stats(): Promise<Record<string, unknown>>;
143
+ /**
144
+ * Rotate this agent's keypairs. Old messages encrypted with old keys cannot be re-decrypted.
145
+ */
146
+ rotateKeys(): Promise<void>;
147
+ }
148
+
149
+ export { type AgentIdentity, type AgentProfile, type DecryptedMessage, type SendResult, VoidlyAgent, type VoidlyAgentConfig };