nanosolana 0.2.0 → 1.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/CHANGELOG.md ADDED
@@ -0,0 +1,78 @@
1
+ # Changelog
2
+
3
+ All notable changes to NanoSolana will be documented in this file.
4
+
5
+ ## [1.0.1] — 2026-03-16
6
+
7
+ ### Fixed
8
+
9
+ - Added the missing `cron-parser` runtime dependency required by the claw IPC and task scheduler paths.
10
+ - Fixed strict TypeScript declaration build errors in the CLI demo flow, docs integration, container runner, Pump swarm spawner, and Pump Telegram gateway.
11
+ - Aligned the bundled docs corpus with the current repo surface, including `pump/docs/` integration in `nanosolana docs`.
12
+
13
+ ### Improved
14
+
15
+ - Updated package metadata and release artifacts so `npx nanosolana go` resolves to a buildable, test-passing package.
16
+
17
+ ## [1.0.0] — 2025-03-15
18
+
19
+ ### 🎉 First Stable Release
20
+
21
+ NanoSolana hits 1.0! Production-ready autonomous trading agents on Solana.
22
+
23
+ ### ✨ New Features
24
+
25
+ - **`nanosolana demo`** — Zero-config simulation mode. Try the full OODA loop without any API keys.
26
+ - **SDK Examples** — 5 runnable examples: basic agent, custom strategy, webhook alerts, multi-agent mesh, and programmatic SDK usage.
27
+ - **Enhanced npm presence** — 30 discovery keywords, 12+ badges, comparison table, SDK usage docs.
28
+ - **GitHub Actions CI/CD** — Automated testing on Node 22/23, auto-publish on release with npm provenance.
29
+ - **PR & Issue Templates** — Standardized contribution workflow.
30
+ - **GitHub Sponsors** — `FUNDING.yml` for community support.
31
+
32
+ ### 🛡️ Security
33
+
34
+ - AES-256-GCM vault for all secrets
35
+ - HMAC-SHA256 gateway authentication
36
+ - Ed25519 wallet signatures with timing-safe comparison
37
+ - Rate limiting: 10 conn/min, 100 msg/min
38
+
39
+ ### 📦 Package
40
+
41
+ - Proper TypeScript `types` field and conditional exports
42
+ - `publishConfig` for public npm access
43
+ - `prepublishOnly` build step
44
+ - Expanded `files` to include CHANGELOG
45
+
46
+ ### 🏗️ Architecture
47
+
48
+ - OODA Trading Loop (Observe → Orient → Decide → Act → Learn)
49
+ - ClawVault 3-tier epistemological memory (Known/Learned/Inferred)
50
+ - TamaGOchi virtual pet risk modifier
51
+ - Mesh networking via Tailscale VPN
52
+ - On-chain NFT identity via Metaplex (devnet)
53
+ - 40+ channel plugins (Telegram, Discord, Slack, WhatsApp, Nostr...)
54
+ - 50+ composable agent skills
55
+
56
+ ## [0.2.0] — 2025-03-12
57
+
58
+ ### Added
59
+
60
+ - OODA trading engine with Jupiter Ultra Swap
61
+ - ClawVault 3-tier memory with experience replay
62
+ - TamaGOchi pet engine with mood-based risk modification
63
+ - Helius blockchain scanner (DAS API, Enhanced Transactions)
64
+ - On-chain agent registry (Metaplex NFT)
65
+ - Interactive NanoBot web UI
66
+ - Gateway server (WebSocket + HTTP)
67
+ - Tailscale mesh networking
68
+ - 25+ CLI commands
69
+
70
+ ## [0.1.0] — 2025-03-10
71
+
72
+ ### Added
73
+
74
+ - Initial release
75
+ - Solana wallet management
76
+ - Birdeye price feeds
77
+ - Basic trading signals
78
+ - Terminal animations
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 NanoSolana Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,163 +1,269 @@
1
1
  <div align="center">
2
2
 
3
- ```
4
- ███╗ ██╗ █████╗ ███╗ ██╗ ██████╗ ███████╗ ██████╗ ██╗ █████╗ ███╗ ██╗ █████╗
5
- ████╗ ██║██╔══██╗████╗ ██║██╔═══██╗██╔════╝██╔═══██╗██║ ██╔══██╗████╗ ██║██╔══██╗
6
- ██╔██╗ ██║███████║██╔██╗ ██║██║ ██║███████╗██║ ██║██║ ███████║██╔██╗ ██║███████║
7
- ██║╚██╗██║██╔══██║██║╚██╗██║██║ ██║╚════██║██║ ██║██║ ██╔══██║██║╚██╗██║██╔══██║
8
- ██║ ╚████║██║ ██║██║ ╚████║╚██████╔╝███████║╚██████╔╝███████╗██║ ██║██║ ╚████║██║ ██║
9
- ╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝
10
- ```
3
+ # 🦞 NanoSolana
11
4
 
12
- **The Open-Source Agentic Framework for Financial Intelligence on Solana**
5
+ **TypeScript runtime and CLI for autonomous financial agents on Solana.**
13
6
 
14
- [![License: MIT](https://img.shields.io/badge/License-MIT-14F195.svg)](LICENSE)
15
- [![Solana](https://img.shields.io/badge/Solana-Native-9945FF.svg)](https://solana.com)
16
- [![npm](https://img.shields.io/npm/v/nanosolana?color=14F195)](https://npmjs.com/package/nanosolana)
7
+ [![npm version](https://img.shields.io/npm/v/nanosolana?color=14F195&style=flat-square)](https://npmjs.com/package/nanosolana)
8
+ [![npm downloads](https://img.shields.io/npm/dm/nanosolana?color=9945FF&style=flat-square)](https://npmjs.com/package/nanosolana)
9
+ [![GitHub stars](https://img.shields.io/github/stars/x402agent/NanoSolana?color=14F195&style=flat-square)](https://github.com/x402agent/NanoSolana)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-14F195.svg?style=flat-square)](LICENSE)
11
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
12
+ [![Solana](https://img.shields.io/badge/Solana-Native-9945FF?style=flat-square&logo=solana&logoColor=white)](https://solana.com)
13
+ [![Node](https://img.shields.io/badge/Node-%E2%89%A522-339933?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org)
14
+ [![GitHub last commit](https://img.shields.io/github/last-commit/x402agent/NanoSolana?color=14F195&style=flat-square)](https://github.com/x402agent/NanoSolana)
15
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-14F195?style=flat-square)](https://github.com/x402agent/NanoSolana/blob/main/CONTRIBUTING.md)
16
+ [![Discord](https://img.shields.io/badge/Discord-Join-5865F2?style=flat-square&logo=discord&logoColor=white)](https://discord.gg/nanosolana)
17
17
 
18
- [Website](https://nanosolana.com) · [Hub](https://hub.nanosolana.com) · [Docs](https://docs.nanosolana.com) · [GitHub](https://github.com/x402agent/NanoSolana)
18
+ `nano-core` is published to npm as `nanosolana`.
19
+ It bundles the local agent runtime, encrypted config vault, wallet lifecycle, OODA trading engine, ClawVault memory, TamaGOchi state machine, gateway server, docs integration, and devnet on-chain identity registration.
20
+
21
+ [Website](https://nanosolana.com) · [Hub](https://hub.nanosolana.com) · [Docs](https://docs.nanosolana.com) · [GitHub](https://github.com/x402agent/NanoSolana) · [Discord](https://discord.gg/nanosolana)
19
22
 
20
23
  </div>
21
24
 
22
- ## One-Shot Deploy
25
+ ---
26
+
27
+ ## What This Package Ships
28
+
29
+ | Area | Included in `nanosolana` |
30
+ | --- | --- |
31
+ | CLI | `init`, `birth`, `run`, `go`, `demo`, `scan`, `register`, `registry`, `nanobot`, `status`, `pet`, `docs`, `vault`, `config`, `nodes`, `send`, `bots` |
32
+ | Trading runtime | Helius RPC ingestion, Birdeye market data, Jupiter execution, signal events |
33
+ | Memory | ClawVault 3-tier memory: known, learned, inferred |
34
+ | Security | AES-256-GCM local vault, HMAC-SHA256 gateway auth, timing-safe signature checks |
35
+ | Agent state | Solana wallet manager, TamaGOchi lifecycle, local persistence under `~/.nanosolana/` |
36
+ | Networking | Gateway server plus optional Tailscale-backed mesh messaging |
37
+ | UI | Local NanoBot web UI on `127.0.0.1:7777` by default |
38
+ | Registry | Devnet NFT-based on-chain identity via Metaplex-compatible minting flow |
39
+
40
+ ## Requirements
41
+
42
+ - Node.js `22+`
43
+ - npm `10+`
44
+ - A burner wallet and test-sized balances for first live runs
45
+ - For live mode: `HELIUS_RPC_URL`, `HELIUS_API_KEY`, and `OPENROUTER_API_KEY` or `AI_API_KEY`
46
+ - For better live behavior: `HELIUS_WSS_URL`, `BIRDEYE_API_KEY`, `JUPITER_API_KEY`, `NANO_GATEWAY_SECRET`
47
+
48
+ ## Quick Start
49
+
50
+ ### Demo mode
51
+
52
+ ```bash
53
+ npx nanosolana demo
54
+ ```
55
+
56
+ This runs the full OODA loop in simulation mode with synthetic prices, a local ClawVault instance, and a demo TamaGOchi. No API keys are required.
57
+
58
+ ### Live mode
23
59
 
24
60
  ```bash
25
61
  npx nanosolana go
26
62
  ```
27
63
 
28
- That's it — one command handles API key setup, wallet creation, blockchain scan, on-chain NFT identity, OODA trading loop, and gateway.
64
+ On first run, `go` will:
65
+
66
+ 1. Prompt for required credentials.
67
+ 2. Encrypt secrets into `~/.nanosolana/vault.enc`.
68
+ 3. Create or load the local wallet.
69
+ 4. Start TamaGOchi, ClawVault, trading, and the gateway.
70
+ 5. Attempt a blockchain scan when Helius is configured.
71
+ 6. Attempt devnet registration for the agent identity NFT.
72
+
73
+ If secrets are already present, skip the prompts:
74
+
75
+ ```bash
76
+ npx nanosolana go --skip-init
77
+ ```
29
78
 
30
79
  ## Install
31
80
 
81
+ ### Run without installing
82
+
83
+ ```bash
84
+ npx nanosolana demo
85
+ npx nanosolana go
86
+ ```
87
+
88
+ ### Global npm install
89
+
32
90
  ```bash
33
91
  npm install -g nanosolana
92
+ nanosolana demo
34
93
  ```
35
94
 
36
- Or step-by-step:
95
+ ### One-shot shell installer
37
96
 
38
97
  ```bash
39
- nanosolana init # Configure API keys (encrypted at rest)
40
- nanosolana birth # Create Solana wallet + mint Birth Certificate NFT + blockchain scan
41
- nanosolana run # Start the OODA trading loop
98
+ curl -fsSL https://nanosolana.com/install.sh | bash
99
+ export PATH="$HOME/.nanosolana/bin:$PATH"
100
+ nanosolana go
42
101
  ```
43
102
 
103
+ ### From source
104
+
105
+ ```bash
106
+ git clone https://github.com/x402agent/NanoSolana.git
107
+ cd NanoSolana/nano-core
108
+ npm install
109
+ npm run build
110
+ node dist/cli/entry.js demo
111
+ ```
112
+
113
+ ## Configuration
114
+
115
+ Secrets can come from the encrypted local vault, environment variables, or both. The runtime supports the following primary variables:
116
+
117
+ | Variable | Purpose | Notes |
118
+ | --- | --- | --- |
119
+ | `OPENROUTER_API_KEY` or `AI_API_KEY` | AI provider key | Required for live trading |
120
+ | `OPENROUTER_MODEL` or `AI_MODEL` | Model selection | Defaults to `openrouter/healer-alpha` |
121
+ | `HELIUS_RPC_URL` | Solana RPC | Required for live mode and scans |
122
+ | `HELIUS_API_KEY` | Helius API key | Required for live mode and scans |
123
+ | `HELIUS_WSS_URL` | Helius WebSocket endpoint | Optional but recommended |
124
+ | `BIRDEYE_API_KEY` | Market data | Optional in config, important for richer signals |
125
+ | `JUPITER_API_KEY` | Swap execution | Required for live execution paths |
126
+ | `NANO_GATEWAY_PORT` | Gateway port | Defaults to `18790` |
127
+ | `NANO_GATEWAY_HOST` | Gateway bind host | Defaults to `0.0.0.0` |
128
+ | `NANO_GATEWAY_SECRET` | Shared HMAC secret | Strongly recommended |
129
+ | `NANO_VAULT_PASSWORD` | Override vault password source | Recommended for deterministic multi-session setups |
130
+ | `TAILSCALE_AUTH_KEY` | Mesh networking | Needed for automated Tailscale enrollment |
131
+
132
+ `nanosolana init` writes non-sensitive defaults to a local `.env` and stores prompted secrets in the encrypted vault.
133
+
134
+ ## CLI Reference
135
+
136
+ ### Core runtime
137
+
138
+ | Command | Description |
139
+ | --- | --- |
140
+ | `nanosolana init` | Prompt for credentials and save them to the encrypted vault |
141
+ | `nanosolana birth` | Create or load the agent wallet and initialize the local TamaGOchi |
142
+ | `nanosolana run` | Start wallet heartbeat, ClawVault, trading engine, and gateway |
143
+ | `nanosolana go` | Full one-shot flow: configure, birth, run, scan, and attempt registration |
144
+ | `nanosolana demo` | Simulation mode with no API keys |
145
+ | `nanosolana status` | Show wallet, pet, memory, gateway, Tailscale, and tmux summary |
146
+ | `nanosolana pet` | Print the current TamaGOchi status display |
147
+
148
+ ### Ops and inspection
149
+
150
+ | Command | Description |
151
+ | --- | --- |
152
+ | `nanosolana scan [address]` | Scan the default wallet or a supplied address via Helius |
153
+ | `nanosolana register` | Mint the devnet on-chain identity NFT |
154
+ | `nanosolana registry` | Show local registration status and explorer links |
155
+ | `nanosolana config` | Print the redacted runtime configuration |
156
+ | `nanosolana vault [query]` | Search the ClawVault tiers |
157
+ | `nanosolana docs [query]` | Search integrated docs and extension metadata |
158
+ | `nanosolana nanobot --port 7777` | Start the local NanoBot companion UI |
159
+
160
+ ### Mesh and multi-bot tooling
161
+
162
+ | Command | Description |
163
+ | --- | --- |
164
+ | `nanosolana nodes` | List discovered Tailscale peers |
165
+ | `nanosolana send "message"` | Send a one-shot message to local or mesh-connected agents |
166
+ | `nanosolana bots list` | List tmux-backed bot sessions |
167
+ | `nanosolana bots spawn <name>` | Spawn a bot in a tmux session |
168
+ | `nanosolana bots attach <name>` | Attach to a tmux session |
169
+ | `nanosolana bots kill <name>` | Terminate a tmux session |
170
+ | `nanosolana dvd` | Terminal DVD-style screensaver |
171
+ | `nanosolana lobster` | Animated or static lobster banner |
172
+
173
+ ## SDK Usage
174
+
175
+ `nanosolana` can also be used as a library:
176
+
177
+ ```ts
178
+ import {
179
+ ClawVault,
180
+ NanoWallet,
181
+ TamaGOchi,
182
+ TradingEngine,
183
+ loadConfig,
184
+ } from "nanosolana";
185
+
186
+ const config = loadConfig();
187
+
188
+ const wallet = new NanoWallet("my-agent");
189
+ await wallet.birth();
190
+
191
+ const vault = new ClawVault();
192
+ vault.startAutonomous();
193
+
194
+ const pet = new TamaGOchi("MyPet");
195
+ pet.recordWalletCreated(wallet.getInfo().balance);
196
+
197
+ const engine = new TradingEngine(config, wallet);
198
+ engine.on("signal", (signal) => {
199
+ console.log(`${signal.type} ${signal.symbol} ${(signal.confidence * 100).toFixed(0)}%`);
200
+ });
201
+
202
+ await engine.start();
203
+ ```
204
+
205
+ Additional runnable examples live in [`examples/`](https://github.com/x402agent/NanoSolana/tree/main/nano-core/examples):
206
+
207
+ - `basic-agent.ts`
208
+ - `custom-strategy.ts`
209
+ - `multi-agent-mesh.ts`
210
+ - `sdk-programmatic.ts`
211
+ - `webhook-alerts.ts`
212
+
44
213
  ## Architecture
45
214
 
215
+ ```text
216
+ ┌───────────────────────────────────────────────────────┐
217
+ │ Agent Runtime │
218
+ │ OODA loop · ClawVault · TamaGOchi · Strategy │
219
+ ├───────────────────────────────────────────────────────┤
220
+ │ Local Infrastructure │
221
+ │ Vault · Wallet · Gateway · Registry · Persistence │
222
+ ├───────────────────────────────────────────────────────┤
223
+ │ External Integrations │
224
+ │ Helius · Birdeye · Jupiter · Tailscale · Docs │
225
+ └───────────────────────────────────────────────────────┘
46
226
  ```
47
- nano-core/
48
- ├── src/
49
- │ ├── ai/ → OpenRouter AI provider (multimodal: text, image, audio, video)
50
- │ ├── cli/ → `nanosolana` CLI (25+ commands)
51
- │ ├── config/ → AES-256-GCM encrypted vault & Zod-validated config
52
- ├── gateway/ → HMAC-SHA256 authenticated WebSocket + HTTP server
53
- ├── hub/ NanoHub bridge for UI communication
54
- ├── memory/ ClawVault 3-tier epistemological memory engine
55
- ├── network/ Tailscale + tmux mesh networking
56
- ├── nft/ Metaplex gasless devnet birth certificate NFT
57
- ├── onchain/ Helius blockchain reader (DAS, Enhanced Tx, wallet scan)
58
- ├── registry/ On-chain agent identity (Metaplex NFT registration)
59
- ├── nanobot/ Interactive local web UI companion
60
- ├── pet/ TamaGOchi virtual pet engine (mood × risk)
61
- ├── strategy/ RSI + EMA + ATR auto-optimizer
62
- ├── telegram/ Persistent conversation store (200 msg/chat)
63
- ├── trading/ OODA trading engine + Jupiter swap execution
64
- │ └── wallet/ Solana Ed25519 wallet manager
65
- ├── SOUL.md → Agent identity system prompt
66
- └── extensions/ 14+ plugins (Telegram, Discord, Nostr, etc.)
227
+
228
+ Source layout:
229
+
230
+ ```text
231
+ nano-core/src/
232
+ ├── ai/ OpenRouter-backed AI provider
233
+ ├── cli/ CLI entrypoint and terminal UX
234
+ ├── config/ Local encrypted vault and config loading
235
+ ├── docs/ Repo docs and extension corpus integration
236
+ ├── gateway/ HTTP + WebSocket gateway
237
+ ├── memory/ ClawVault and legacy memory engine
238
+ ├── nanobot/ Local companion UI server
239
+ ├── network/ Tailscale and tmux helpers
240
+ ├── nft/ Birth certificate support
241
+ ├── onchain/ Helius readers and wallet scans
242
+ ├── pet/ TamaGOchi state machine
243
+ ├── registry/ Devnet identity registration
244
+ ├── strategy/ Indicators and signal logic
245
+ ├── trading/ OODA trading engine
246
+ └── wallet/ Solana wallet management
67
247
  ```
68
248
 
69
- ## Commands
249
+ ## Security Notes
70
250
 
71
- | Command | Description |
72
- |---------|-------------|
73
- | `nanosolana go` | **One-shot: init + birth + scan + register + trade** |
74
- | `nanosolana init` | Configure + encrypt API keys |
75
- | `nanosolana birth` | Create wallet + mint Birth Certificate NFT + blockchain scan |
76
- | `nanosolana run` | Start OODA trading loop |
77
- | `nanosolana scan [address]` | **Blockchain data scan — SOL, tokens, NFTs, tx history** |
78
- | `nanosolana register` | **Mint on-chain agent identity NFT (devnet)** |
79
- | `nanosolana registry` | **Show on-chain agent identity** |
80
- | `nanosolana nanobot` | **Launch interactive NanoBot web UI** |
81
- | `nanosolana dvd` | Floating DVD screensaver 🦞 |
82
- | `nanosolana lobster` | Animated Unicode lobster mascot |
83
- | `nanosolana status` | Show agent + wallet + pet status |
84
- | `nanosolana trade status` | Trading P&L and strategy state |
85
- | `nanosolana trade signals` | Recent trading signals with confidence |
86
- | `nanosolana wallet balance` | SOL + SPL token balances |
87
- | `nanosolana pet status` | TamaGOchi pet mood and evolution |
88
- | `nanosolana memory search` | Search ClawVault memory |
89
- | `nanosolana gateway run` | Start WebSocket gateway |
90
- | `nanosolana channels status` | Check channel connections |
91
- | `nanosolana vault set <key> <val>` | Store encrypted secret |
92
- | `nanosolana send <msg>` | One-shot message to nano bots |
93
- | `nanosolana nodes` | List Tailscale mesh peers |
94
- | `nanosolana doctor` | Run diagnostics |
95
- | `nanosolana security audit` | Full security scan |
96
-
97
- ## Required API Keys
98
-
99
- | Key | Source | Required |
100
- |-----|--------|----------|
101
- | `OPENROUTER_API_KEY` | [openrouter.ai](https://openrouter.ai) | ✅ |
102
- | `HELIUS_RPC_URL` | [helius.dev](https://helius.dev) | ✅ |
103
- | `HELIUS_API_KEY` | [helius.dev](https://helius.dev) | ✅ |
104
- | `HELIUS_WSS_URL` | [helius.dev](https://helius.dev) | Recommended |
105
- | `BIRDEYE_API_KEY` | [birdeye.so](https://birdeye.so) | Recommended |
106
- | `JUPITER_API_KEY` | [jup.ag](https://jup.ag) | For trading |
107
-
108
- ## Security
109
-
110
- - ✅ AES-256-GCM encrypted secrets vault
111
- - ✅ HMAC-SHA256 gateway authentication
112
- - ✅ Ed25519 wallet signatures
113
- - ✅ Timing-safe token comparison
114
- - ✅ Rate limiting (10 conn/min, 100 msg/min)
115
- - ✅ File permissions enforced (0600/0700)
116
- - ✅ Wallet private key never leaves the vault
117
-
118
- ## Trading Engine (OODA)
119
-
120
- 1. **Observe** — Real-time data from Helius RPC + Birdeye API
121
- 2. **Orient** — AI analysis via OpenRouter (multimodal)
122
- 3. **Decide** — Structured signals with confidence scoring
123
- 4. **Act** — Jupiter swap execution with slippage protection
124
- 5. **Learn** — ClawVault experience replay + contradiction detection
125
-
126
- ## Blockchain Intelligence (Helius)
127
-
128
- At agent birth, NanoSolana instantly reads the blockchain:
129
-
130
- - **DAS API** — tokens, NFTs, compressed assets
131
- - **Enhanced Transactions** — parsed tx history with descriptions
132
- - **Priority Fees** — real-time fee estimation
133
- - **Wallet Snapshot** — SOL balance, token prices, NFT inventory
134
-
135
- ## On-Chain Identity
136
-
137
- Every agent mints a **Metaplex NFT** on devnet as its on-chain identity:
138
-
139
- - Agent public key
140
- - NanoSolana version
141
- - Registered skills
142
- - SHA-256 fingerprint
143
-
144
- ## TamaGOchi Pet
145
-
146
- 🥚 Egg → 🐛 Larva → 🐣 Juvenile → 🦞 Adult → 👑 Alpha → 👻 Ghost
147
-
148
- Pet mood affects risk tolerance. Feed to keep alive!
149
-
150
- ## Chrome Extension
151
-
152
- Manifest V3 browser extension for tab relay, wallet management, chat, and manual trades via the gateway.
153
-
154
- ## Links
155
-
156
- - **Website:** [nanosolana.com](https://nanosolana.com)
157
- - **Hub:** [hub.nanosolana.com](https://hub.nanosolana.com)
158
- - **Docs:** [docs.nanosolana.com](https://docs.nanosolana.com)
159
- - **GitHub:** [github.com/x402agent/NanoSolana](https://github.com/x402agent/NanoSolana)
251
+ - Secrets are stored in `~/.nanosolana/vault.enc` with AES-256-GCM encryption.
252
+ - Gateway signatures use HMAC-SHA256 and constant-time comparison via `crypto.timingSafeEqual`.
253
+ - HTTP and WebSocket surfaces are rate-limited per source address.
254
+ - The default vault password source is local-machine oriented. Set `NANO_VAULT_PASSWORD` explicitly if you need a stable password across shells or hosts.
255
+ - On-chain registration uses Solana devnet today. Do not treat devnet identity as production custody or compliance infrastructure.
256
+ - The trading engine is experimental software. Start with `demo`, then a burner wallet, then very small live balances.
257
+
258
+ ## Package Scope
259
+
260
+ This README covers the published TypeScript package in `nano-core`.
261
+ For the broader monorepo, including NanoHub, extensions, apps, and site assets, see the main repository README:
262
+
263
+ - [Monorepo guide](https://github.com/x402agent/NanoSolana/blob/main/README.md)
264
+ - [Docs site source](https://github.com/x402agent/NanoSolana/tree/main/nano-docs)
265
+ - [Contributing guide](https://github.com/x402agent/NanoSolana/blob/main/CONTRIBUTING.md)
160
266
 
161
267
  ## License
162
268
 
163
- MIT [NanoSolana Labs](https://nanosolana.com)
269
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,126 @@
1
+ // src/memory/engine.ts
2
+ import { EventEmitter } from "eventemitter3";
3
+ var MemoryEngine = class extends EventEmitter {
4
+ entries = /* @__PURE__ */ new Map();
5
+ lessons = [];
6
+ gcTimer = null;
7
+ decayMs;
8
+ idCounter = 0;
9
+ constructor(temporalDecayHours = 24) {
10
+ super();
11
+ this.decayMs = temporalDecayHours * 60 * 60 * 1e3;
12
+ }
13
+ nextId() {
14
+ this.idCounter += 1;
15
+ return `mem-${Date.now()}-${this.idCounter}`;
16
+ }
17
+ /**
18
+ * Store a new memory entry.
19
+ */
20
+ store(input) {
21
+ const entry = {
22
+ id: this.nextId(),
23
+ content: input.content,
24
+ source: input.source,
25
+ tags: input.tags ?? [],
26
+ confidence: input.confidence ?? 1,
27
+ createdAt: Date.now(),
28
+ expiresAt: Date.now() + this.decayMs
29
+ };
30
+ this.entries.set(entry.id, entry);
31
+ this.emit("entryStored", entry);
32
+ return entry;
33
+ }
34
+ /**
35
+ * Search entries.
36
+ */
37
+ search(query, limit = 10) {
38
+ const q = query.toLowerCase();
39
+ const results = [];
40
+ for (const entry of this.entries.values()) {
41
+ if (entry.content.toLowerCase().includes(q) || entry.tags.some((t) => t.toLowerCase().includes(q))) {
42
+ results.push(entry);
43
+ }
44
+ }
45
+ return results.sort((a, b) => b.confidence - a.confidence).slice(0, limit);
46
+ }
47
+ /**
48
+ * Reinforce a memory (increase its confidence and extend TTL).
49
+ */
50
+ reinforce(id, boost = 0.1) {
51
+ const entry = this.entries.get(id);
52
+ if (!entry) return;
53
+ entry.confidence = Math.min(1, entry.confidence + boost);
54
+ entry.expiresAt = Date.now() + this.decayMs;
55
+ this.emit("memoryReinforced", id, entry.confidence);
56
+ }
57
+ /**
58
+ * Get learned lessons.
59
+ */
60
+ getLessons() {
61
+ return [...this.lessons];
62
+ }
63
+ /**
64
+ * Add a lesson.
65
+ */
66
+ addLesson(input) {
67
+ const lesson = {
68
+ ...input,
69
+ id: `lesson-${Date.now()}-${this.lessons.length}`,
70
+ createdAt: Date.now()
71
+ };
72
+ this.lessons.push(lesson);
73
+ this.emit("lessonLearned", lesson);
74
+ return lesson;
75
+ }
76
+ /**
77
+ * Get memory stats.
78
+ */
79
+ getStats() {
80
+ const bySource = {};
81
+ let totalConfidence = 0;
82
+ for (const entry of this.entries.values()) {
83
+ bySource[entry.source] = (bySource[entry.source] ?? 0) + 1;
84
+ totalConfidence += entry.confidence;
85
+ }
86
+ return {
87
+ total: this.entries.size,
88
+ bySource,
89
+ lessons: this.lessons.length,
90
+ avgConfidence: this.entries.size > 0 ? totalConfidence / this.entries.size : 0
91
+ };
92
+ }
93
+ /**
94
+ * Garbage collection — remove expired entries.
95
+ */
96
+ gc() {
97
+ const now = Date.now();
98
+ for (const [id, entry] of this.entries) {
99
+ if (entry.expiresAt <= now) {
100
+ this.entries.delete(id);
101
+ this.emit("entryExpired", entry);
102
+ }
103
+ }
104
+ }
105
+ /**
106
+ * Start autonomous GC.
107
+ */
108
+ startAutonomous() {
109
+ if (this.gcTimer) return;
110
+ this.gcTimer = setInterval(() => this.gc(), 5 * 60 * 1e3);
111
+ }
112
+ /**
113
+ * Stop autonomous GC.
114
+ */
115
+ stopAutonomous() {
116
+ if (this.gcTimer) {
117
+ clearInterval(this.gcTimer);
118
+ this.gcTimer = null;
119
+ }
120
+ }
121
+ };
122
+
123
+ export {
124
+ MemoryEngine
125
+ };
126
+ //# sourceMappingURL=chunk-DLA5H4VJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/memory/engine.ts"],"sourcesContent":["/**\n * Nano Solana — Legacy Memory Engine\n *\n * Generic memory engine kept for backward compatibility.\n * New code should use ClawVault (3-tier epistemological memory).\n */\n\nimport { EventEmitter } from \"eventemitter3\";\n\n// ── Types ────────────────────────────────────────────────────\n\nexport interface MemoryEntry {\n id: string;\n content: string;\n source: string;\n tags: string[];\n confidence: number;\n createdAt: number;\n expiresAt: number;\n}\n\nexport interface Lesson {\n id: string;\n pattern: string;\n outcome: string;\n adjustment: string;\n confidenceImpact: number;\n createdAt: number;\n}\n\nexport interface MemoryEngineEvents {\n entryStored: (entry: MemoryEntry) => void;\n entryExpired: (entry: MemoryEntry) => void;\n lessonLearned: (lesson: Lesson) => void;\n memoryReinforced: (id: string, confidence: number) => void;\n}\n\n// ── Memory Engine ────────────────────────────────────────────\n\nexport class MemoryEngine extends EventEmitter<MemoryEngineEvents> {\n private entries: Map<string, MemoryEntry> = new Map();\n private lessons: Lesson[] = [];\n private gcTimer: ReturnType<typeof setInterval> | null = null;\n private decayMs: number;\n private idCounter = 0;\n\n constructor(temporalDecayHours = 24) {\n super();\n this.decayMs = temporalDecayHours * 60 * 60 * 1000;\n }\n\n private nextId(): string {\n this.idCounter += 1;\n return `mem-${Date.now()}-${this.idCounter}`;\n }\n\n /**\n * Store a new memory entry.\n */\n store(input: {\n content: string;\n source: string;\n tags?: string[];\n confidence?: number;\n metadata?: Record<string, unknown>;\n }): MemoryEntry {\n const entry: MemoryEntry = {\n id: this.nextId(),\n content: input.content,\n source: input.source,\n tags: input.tags ?? [],\n confidence: input.confidence ?? 1.0,\n createdAt: Date.now(),\n expiresAt: Date.now() + this.decayMs,\n };\n this.entries.set(entry.id, entry);\n this.emit(\"entryStored\", entry);\n return entry;\n }\n\n /**\n * Search entries.\n */\n search(query: string, limit = 10): MemoryEntry[] {\n const q = query.toLowerCase();\n const results: MemoryEntry[] = [];\n\n for (const entry of this.entries.values()) {\n if (\n entry.content.toLowerCase().includes(q) ||\n entry.tags.some((t) => t.toLowerCase().includes(q))\n ) {\n results.push(entry);\n }\n }\n\n return results\n .sort((a, b) => b.confidence - a.confidence)\n .slice(0, limit);\n }\n\n /**\n * Reinforce a memory (increase its confidence and extend TTL).\n */\n reinforce(id: string, boost = 0.1): void {\n const entry = this.entries.get(id);\n if (!entry) return;\n\n entry.confidence = Math.min(1.0, entry.confidence + boost);\n entry.expiresAt = Date.now() + this.decayMs;\n this.emit(\"memoryReinforced\", id, entry.confidence);\n }\n\n /**\n * Get learned lessons.\n */\n getLessons(): Lesson[] {\n return [...this.lessons];\n }\n\n /**\n * Add a lesson.\n */\n addLesson(input: Omit<Lesson, \"id\" | \"createdAt\">): Lesson {\n const lesson: Lesson = {\n ...input,\n id: `lesson-${Date.now()}-${this.lessons.length}`,\n createdAt: Date.now(),\n };\n this.lessons.push(lesson);\n this.emit(\"lessonLearned\", lesson);\n return lesson;\n }\n\n /**\n * Get memory stats.\n */\n getStats(): {\n total: number;\n bySource: Record<string, number>;\n lessons: number;\n avgConfidence: number;\n } {\n const bySource: Record<string, number> = {};\n let totalConfidence = 0;\n\n for (const entry of this.entries.values()) {\n bySource[entry.source] = (bySource[entry.source] ?? 0) + 1;\n totalConfidence += entry.confidence;\n }\n\n return {\n total: this.entries.size,\n bySource,\n lessons: this.lessons.length,\n avgConfidence: this.entries.size > 0 ? totalConfidence / this.entries.size : 0,\n };\n }\n\n /**\n * Garbage collection — remove expired entries.\n */\n private gc(): void {\n const now = Date.now();\n for (const [id, entry] of this.entries) {\n if (entry.expiresAt <= now) {\n this.entries.delete(id);\n this.emit(\"entryExpired\", entry);\n }\n }\n }\n\n /**\n * Start autonomous GC.\n */\n startAutonomous(): void {\n if (this.gcTimer) return;\n this.gcTimer = setInterval(() => this.gc(), 5 * 60 * 1000);\n }\n\n /**\n * Stop autonomous GC.\n */\n stopAutonomous(): void {\n if (this.gcTimer) {\n clearInterval(this.gcTimer);\n this.gcTimer = null;\n }\n }\n}\n"],"mappings":";AAOA,SAAS,oBAAoB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