@mnemosyne_os/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.
package/README.md ADDED
@@ -0,0 +1,233 @@
1
+ # @mnemosyne_os/sdk
2
+
3
+ > **Official SDK for building Layer 2 apps on [Mnemosyne OS](https://github.com/yaka0007/Mnemosyne-Neural-OS)**
4
+ > Connect your app to a local sovereign AI memory runtime — no cloud dependency.
5
+
6
+ [![npm version](https://img.shields.io/npm/v/@mnemosyne_os/sdk)](https://www.npmjs.com/package/@mnemosyne_os/sdk)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+ [![Node.js ≥18](https://img.shields.io/badge/node-%3E%3D18-green)](https://nodejs.org)
9
+
10
+ ---
11
+
12
+ ## What is Mnemosyne OS?
13
+
14
+ Mnemosyne OS is a sovereign, local-first AI memory runtime built on Electron.
15
+ It runs on your machine, stores everything locally (SQLite + vector embeddings),
16
+ and exposes an IPC/WebSocket API for Layer 2 apps to tap into its cognitive engine.
17
+
18
+ **No cloud. No telemetry. Your data stays on your machine.**
19
+
20
+ ---
21
+
22
+ ## Ecosystem
23
+
24
+ | Package | Version | Role |
25
+ |---------|---------|------|
26
+ | [`@mnemosyne_os/forge`](https://www.npmjs.com/package/@mnemosyne_os/forge) | `1.4.7` | CLI — scaffold, chronicles, MCP server |
27
+ | [`@mnemosyne_os/sync`](https://www.npmjs.com/package/@mnemosyne_os/sync) | `0.0.1` | P2P — multi-agent synchronization |
28
+ | **`@mnemosyne_os/sdk`** | `1.0.0` | **SDK — build Layer 2 apps** |
29
+
30
+ ---
31
+
32
+ ## Requirements
33
+
34
+ - **Mnemosyne OS Dev Edition** must be running on your machine
35
+ - The SDK WebSocket server runs on `ws://127.0.0.1:7799` (localhost only)
36
+ - Node.js ≥ 18
37
+
38
+ ---
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ npm install @mnemosyne_os/sdk
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Quick Start
49
+
50
+ ### 1. Create your `app.manifest.json`
51
+
52
+ ```json
53
+ {
54
+ "id": "my-layer2-app",
55
+ "name": "My Layer 2 App",
56
+ "version": "1.0.0",
57
+ "mnemosyne_sdk": "^1.0.0",
58
+ "scopes": ["vault:read:DEV", "vault:write:DEV"],
59
+ "vaults": ["DEV"],
60
+ "intents": ["INGEST", "QUERY"]
61
+ }
62
+ ```
63
+
64
+ ### 2. Connect and use
65
+
66
+ ```typescript
67
+ import { MnemoClient } from '@mnemosyne_os/sdk';
68
+
69
+ const client = await MnemoClient.connect({
70
+ appId: 'my-layer2-app',
71
+ manifest: './app.manifest.json',
72
+ // transport: 'auto' → WebSocket if external, IPC if embedded in Mnemosyne OS
73
+ });
74
+
75
+ // Ingest content into the vault
76
+ await client.ingest({
77
+ content: 'My content to remember',
78
+ spineType: 'NOTE',
79
+ vault: 'DEV',
80
+ });
81
+
82
+ // Semantic query
83
+ const result = await client.query('my search query', { limit: 5 });
84
+ console.log(result.chronicles);
85
+
86
+ // Cross-app share (triggers a consent popup in Mnemosyne OS)
87
+ const share = await client.requestShare({
88
+ fromAppId: 'other-app-id',
89
+ reason: 'I need access to correlate data',
90
+ });
91
+
92
+ await client.disconnect();
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Transport Modes
98
+
99
+ The SDK supports two transport modes, auto-detected by default:
100
+
101
+ | Mode | When | How |
102
+ |------|------|-----|
103
+ | `ws` | External Node.js app | JSON-RPC over `ws://127.0.0.1:7799` |
104
+ | `ipc` | Embedded in Mnemosyne OS renderer | `window.mnemosyne` Electron IPC bridge |
105
+ | `auto` | Default | Detects `window.mnemosyne` → IPC, otherwise WS |
106
+
107
+ ```typescript
108
+ // Force WebSocket (external app)
109
+ const client = await MnemoClient.connect({ appId: '...', manifest: '...', transport: 'ws' });
110
+
111
+ // Force IPC (embedded Layer 2 app)
112
+ const client = await MnemoClient.connect({ appId: '...', manifest: '...', transport: 'ipc' });
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Scopes & Zero-Trust
118
+
119
+ Every app declares its permissions in `app.manifest.json`.
120
+ **The OS refuses any operation not declared in the manifest** — Zero-Trust by design.
121
+
122
+ ```typescript
123
+ // Available scopes
124
+ type MnemoScope =
125
+ | 'vault:read:DEV' | 'vault:write:DEV'
126
+ | 'vault:read:SOCIAL' | 'vault:write:SOCIAL'
127
+ | 'vault:read:PERSONAL'| 'vault:write:PERSONAL'
128
+ | 'vault:read:FINANCE' | 'vault:write:FINANCE'
129
+ | 'vault:read:COOK' | 'vault:write:COOK'
130
+ | 'share:request' | 'share:grant'
131
+ | 'nft:validate' // MnemoStore NFT licence validation
132
+ | 'neural:graph:read' // NeuralGraph access
133
+ | 'llm:query'; // Direct LLM queries (premium)
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Available RPC Methods
139
+
140
+ ```typescript
141
+ import { MNEMOSYNE_METHODS } from '@mnemosyne_os/sdk';
142
+
143
+ // All methods available on ws://127.0.0.1:7799
144
+ MNEMOSYNE_METHODS.REGISTER // 'sdk.register'
145
+ MNEMOSYNE_METHODS.INGEST // 'sdk.ingest'
146
+ MNEMOSYNE_METHODS.QUERY // 'sdk.query'
147
+ MNEMOSYNE_METHODS.CORRELATE // 'sdk.correlate'
148
+ MNEMOSYNE_METHODS.FORGET // 'sdk.forget'
149
+ MNEMOSYNE_METHODS.SHARE // 'sdk.share'
150
+ MNEMOSYNE_METHODS.NFT_VALIDATE // 'sdk.nft.validate'
151
+ MNEMOSYNE_METHODS.GRAPH_QUERY // 'sdk.graph.query'
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Events
157
+
158
+ ```typescript
159
+ // Listen for events
160
+ const unsubscribe = client.on('connected', (e) => console.log('Connected!', e.data));
161
+ client.on('disconnected', () => console.log('OS disconnected'));
162
+ client.on('tamper-alert', (e) => console.warn('Tamper detected:', e.data));
163
+ client.on('nft-revoked', (e) => console.warn('NFT licence revoked:', e.data));
164
+
165
+ // Cleanup
166
+ unsubscribe();
167
+ ```
168
+
169
+ ---
170
+
171
+ ## NFT Licence (MnemoStore)
172
+
173
+ Apps distributed on [MnemoStore](https://github.com/yaka0007/Mnemosyne-Neural-OS) can gate access with NFT licences:
174
+
175
+ ```typescript
176
+ // In your app.manifest.json, declare:
177
+ // "scopes": ["nft:validate"]
178
+
179
+ // Then validate on startup:
180
+ const validation = await client.validateNFTLicense('0xYourWalletAddress');
181
+ if (!validation.valid) {
182
+ alert('Please purchase a licence on MnemoStore to use this app.');
183
+ process.exit(1);
184
+ }
185
+ ```
186
+
187
+ > Validation is done on-chain by Mnemosyne OS (not the SDK itself).
188
+ > Results are cached for 5 minutes to avoid blockchain spam.
189
+
190
+ ---
191
+
192
+ ## API Reference
193
+
194
+ ### `MnemoClient.connect(options)`
195
+
196
+ | Option | Type | Default | Description |
197
+ |--------|------|---------|-------------|
198
+ | `appId` | `string` | required | Must match `manifest.id` |
199
+ | `manifest` | `string \| AppManifest` | required | Path to `app.manifest.json` or inline object |
200
+ | `transport` | `'ws' \| 'ipc' \| 'auto'` | `'auto'` | Transport mode |
201
+ | `wsPort` | `number` | `7799` | WebSocket port |
202
+ | `timeoutMs` | `number` | `30000` | RPC timeout |
203
+
204
+ ### `client.ingest(payload)`
205
+
206
+ Ingests content into the vault. Content is vectorized by the Mnemosyne OS runtime.
207
+
208
+ ### `client.query(text, options?)`
209
+
210
+ Semantic search over your app's chronicles. Results are isolated to your `appId`.
211
+
212
+ ### `client.requestShare(request)`
213
+
214
+ Requests access to another app's chronicles. Triggers a consent popup in Mnemosyne OS.
215
+
216
+ ### `client.disconnect()`
217
+
218
+ Gracefully closes the connection.
219
+
220
+ ---
221
+
222
+ ## Contributing & Core Access
223
+
224
+ This SDK is open source (MIT). The Mnemosyne OS core runtime is proprietary.
225
+
226
+ - **Layer 2 apps**: build freely using this SDK — no core access needed.
227
+ - **Core Contributors**: contact `tony@xpacegems.com` for NDA + scoped repo access.
228
+
229
+ ---
230
+
231
+ ## License
232
+
233
+ MIT © [Tony Trochet / XPACEGEMS LLC](https://xpacegems.com)