blue-js-sdk 2.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/CHANGELOG.md +446 -0
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/ai-path/ADMIN-ELEVATION.md +116 -0
- package/ai-path/AI-MANIFESTO.md +185 -0
- package/ai-path/BREAKING.md +74 -0
- package/ai-path/CHECKLIST.md +619 -0
- package/ai-path/CONNECTION-STEPS.md +724 -0
- package/ai-path/DECISION-TREE.md +378 -0
- package/ai-path/DEPENDENCIES.md +459 -0
- package/ai-path/E2E-FLOW.md +1555 -0
- package/ai-path/FAILURES.md +403 -0
- package/ai-path/GUIDE.md +1217 -0
- package/ai-path/README.md +558 -0
- package/ai-path/SPLIT-TUNNEL.md +266 -0
- package/ai-path/cli.js +535 -0
- package/ai-path/connect.js +884 -0
- package/ai-path/discover.js +178 -0
- package/ai-path/environment.js +266 -0
- package/ai-path/errors.js +86 -0
- package/ai-path/examples/autonomous-agent.mjs +220 -0
- package/ai-path/examples/multi-region.mjs +174 -0
- package/ai-path/examples/one-shot.mjs +31 -0
- package/ai-path/index.js +60 -0
- package/ai-path/pricing.js +136 -0
- package/ai-path/recommend.js +413 -0
- package/ai-path/run-admin.vbs +25 -0
- package/ai-path/setup.js +291 -0
- package/ai-path/wallet.js +137 -0
- package/app-helpers.js +363 -0
- package/app-settings.js +95 -0
- package/app-types.js +267 -0
- package/audit.js +847 -0
- package/batch.js +293 -0
- package/bin/setup.js +376 -0
- package/chain/authz.js +109 -0
- package/chain/broadcast.js +472 -0
- package/chain/client.js +160 -0
- package/chain/fee-grants.js +305 -0
- package/chain/index.js +891 -0
- package/chain/lcd.js +313 -0
- package/chain/queries.js +547 -0
- package/chain/rpc.js +408 -0
- package/chain/wallet.js +141 -0
- package/cli/config.js +143 -0
- package/cli/index.js +463 -0
- package/cli/output.js +182 -0
- package/cli.js +491 -0
- package/client/index.js +251 -0
- package/client.js +271 -0
- package/config/index.js +255 -0
- package/connection/connect.js +849 -0
- package/connection/disconnect.js +180 -0
- package/connection/discovery.js +321 -0
- package/connection/index.js +76 -0
- package/connection/proxy.js +148 -0
- package/connection/resilience.js +428 -0
- package/connection/security.js +232 -0
- package/connection/state.js +369 -0
- package/connection/tunnel.js +691 -0
- package/consumer.js +132 -0
- package/cosmjs-setup.js +1884 -0
- package/defaults.js +366 -0
- package/disk-cache.js +107 -0
- package/dist/client.d.ts +108 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +400 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/errors/index.js +112 -0
- package/errors.js +218 -0
- package/examples/README.md +64 -0
- package/examples/connect-direct.mjs +106 -0
- package/examples/connect-plan.mjs +125 -0
- package/examples/error-handling.mjs +109 -0
- package/examples/query-nodes.mjs +94 -0
- package/examples/wallet-basics.mjs +61 -0
- package/generated/amino/amino.ts +9 -0
- package/generated/cosmos/base/v1beta1/coin.ts +365 -0
- package/generated/cosmos_proto/cosmos.ts +323 -0
- package/generated/gogoproto/gogo.ts +9 -0
- package/generated/google/protobuf/descriptor.ts +7601 -0
- package/generated/google/protobuf/duration.ts +208 -0
- package/generated/google/protobuf/timestamp.ts +238 -0
- package/generated/sentinel/lease/v1/events.ts +924 -0
- package/generated/sentinel/lease/v1/lease.ts +292 -0
- package/generated/sentinel/lease/v1/msg.ts +949 -0
- package/generated/sentinel/lease/v1/params.ts +164 -0
- package/generated/sentinel/node/v3/events.ts +881 -0
- package/generated/sentinel/node/v3/msg.ts +1002 -0
- package/generated/sentinel/node/v3/node.ts +263 -0
- package/generated/sentinel/node/v3/params.ts +183 -0
- package/generated/sentinel/plan/v3/events.ts +675 -0
- package/generated/sentinel/plan/v3/msg.ts +1191 -0
- package/generated/sentinel/plan/v3/plan.ts +283 -0
- package/generated/sentinel/provider/v2/events.ts +171 -0
- package/generated/sentinel/provider/v2/msg.ts +480 -0
- package/generated/sentinel/provider/v2/params.ts +131 -0
- package/generated/sentinel/provider/v2/provider.ts +246 -0
- package/generated/sentinel/session/v3/events.ts +480 -0
- package/generated/sentinel/session/v3/msg.ts +616 -0
- package/generated/sentinel/session/v3/params.ts +260 -0
- package/generated/sentinel/session/v3/proof.ts +180 -0
- package/generated/sentinel/session/v3/session.ts +384 -0
- package/generated/sentinel/subscription/v3/events.ts +1181 -0
- package/generated/sentinel/subscription/v3/msg.ts +1305 -0
- package/generated/sentinel/subscription/v3/params.ts +167 -0
- package/generated/sentinel/subscription/v3/subscription.ts +315 -0
- package/generated/sentinel/types/v1/bandwidth.ts +124 -0
- package/generated/sentinel/types/v1/price.ts +149 -0
- package/generated/sentinel/types/v1/renewal.ts +87 -0
- package/generated/sentinel/types/v1/status.ts +54 -0
- package/generated/typeRegistry.ts +27 -0
- package/index.js +486 -0
- package/node-connect.js +3015 -0
- package/operator.js +134 -0
- package/package.json +113 -0
- package/plan-operations.js +199 -0
- package/preflight.js +352 -0
- package/pricing/index.js +262 -0
- package/proto/amino/amino.proto +84 -0
- package/proto/cosmos/base/v1beta1/coin.proto +61 -0
- package/proto/cosmos_proto/cosmos.proto +112 -0
- package/proto/gogoproto/gogo.proto +145 -0
- package/proto/google/api/annotations.proto +31 -0
- package/proto/google/api/http.proto +370 -0
- package/proto/google/protobuf/any.proto +106 -0
- package/proto/google/protobuf/duration.proto +115 -0
- package/proto/google/protobuf/timestamp.proto +145 -0
- package/proto/sentinel/lease/v1/events.proto +52 -0
- package/proto/sentinel/lease/v1/genesis.proto +15 -0
- package/proto/sentinel/lease/v1/lease.proto +25 -0
- package/proto/sentinel/lease/v1/msg.proto +62 -0
- package/proto/sentinel/lease/v1/params.proto +17 -0
- package/proto/sentinel/node/v3/events.proto +50 -0
- package/proto/sentinel/node/v3/genesis.proto +15 -0
- package/proto/sentinel/node/v3/msg.proto +63 -0
- package/proto/sentinel/node/v3/node.proto +27 -0
- package/proto/sentinel/node/v3/params.proto +21 -0
- package/proto/sentinel/node/v3/querier.proto +63 -0
- package/proto/sentinel/plan/v3/events.proto +41 -0
- package/proto/sentinel/plan/v3/genesis.proto +21 -0
- package/proto/sentinel/plan/v3/msg.proto +83 -0
- package/proto/sentinel/plan/v3/plan.proto +32 -0
- package/proto/sentinel/plan/v3/querier.proto +53 -0
- package/proto/sentinel/provider/v2/events.proto +16 -0
- package/proto/sentinel/provider/v2/genesis.proto +15 -0
- package/proto/sentinel/provider/v2/msg.proto +35 -0
- package/proto/sentinel/provider/v2/params.proto +17 -0
- package/proto/sentinel/provider/v2/provider.proto +24 -0
- package/proto/sentinel/provider/v3/genesis.proto +15 -0
- package/proto/sentinel/provider/v3/params.proto +13 -0
- package/proto/sentinel/session/v3/events.proto +30 -0
- package/proto/sentinel/session/v3/genesis.proto +15 -0
- package/proto/sentinel/session/v3/msg.proto +50 -0
- package/proto/sentinel/session/v3/params.proto +25 -0
- package/proto/sentinel/session/v3/proof.proto +25 -0
- package/proto/sentinel/session/v3/querier.proto +100 -0
- package/proto/sentinel/session/v3/session.proto +50 -0
- package/proto/sentinel/subscription/v2/allocation.proto +21 -0
- package/proto/sentinel/subscription/v2/payout.proto +22 -0
- package/proto/sentinel/subscription/v3/events.proto +65 -0
- package/proto/sentinel/subscription/v3/genesis.proto +17 -0
- package/proto/sentinel/subscription/v3/msg.proto +83 -0
- package/proto/sentinel/subscription/v3/params.proto +21 -0
- package/proto/sentinel/subscription/v3/subscription.proto +33 -0
- package/proto/sentinel/types/v1/bandwidth.proto +19 -0
- package/proto/sentinel/types/v1/price.proto +21 -0
- package/proto/sentinel/types/v1/renewal.proto +21 -0
- package/proto/sentinel/types/v1/status.proto +16 -0
- package/protocol/encoding.js +341 -0
- package/protocol/events.js +361 -0
- package/protocol/handshake.js +297 -0
- package/protocol/index.js +15 -0
- package/protocol/messages.js +346 -0
- package/protocol/plans.js +199 -0
- package/protocol/v2ray.js +268 -0
- package/protocol/v3.js +723 -0
- package/protocol/wireguard.js +125 -0
- package/security/index.js +132 -0
- package/session-manager.js +329 -0
- package/session-tracker.js +80 -0
- package/setup.js +376 -0
- package/speedtest/index.js +528 -0
- package/speedtest.js +567 -0
- package/src/client.ts +502 -0
- package/src/index.ts +20 -0
- package/state/index.js +347 -0
- package/state.js +516 -0
- package/test-all-chain-ops.js +493 -0
- package/test-all-logic.js +199 -0
- package/test-all-msg-types.js +292 -0
- package/test-every-connection.js +208 -0
- package/test-feegrant-connect.js +98 -0
- package/test-logic.js +148 -0
- package/test-mainnet.js +176 -0
- package/test-plan-lifecycle.js +335 -0
- package/tls-trust.js +132 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +34 -0
- package/types/chain.d.ts +746 -0
- package/types/connection.d.ts +425 -0
- package/types/errors.d.ts +174 -0
- package/types/index.d.ts +1380 -0
- package/types/nodes.d.ts +187 -0
- package/types/pricing.d.ts +156 -0
- package/types/protocol.d.ts +332 -0
- package/types/session.d.ts +236 -0
- package/types/settings.d.ts +192 -0
- package/v3protocol.js +1053 -0
- package/wallet/index.js +153 -0
- package/wireguard.js +307 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
# sentinel-ai-connect
|
|
2
|
+
|
|
3
|
+
The world's first decentralized VPN SDK designed for AI agents. Zero accounts, zero servers, zero centralized dependencies. Install the package, fund a wallet, and get private internet access through 900+ peer-to-peer nodes across 90+ countries in one function call.
|
|
4
|
+
|
|
5
|
+
No API keys. No terms of service. No human approval required.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
AI Agent -> sentinel-ai-connect -> Sentinel SDK -> Blockchain TX -> P2P Node -> Encrypted Tunnel -> Internet
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick Start (5 Lines)
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { connect, disconnect } from 'sentinel-ai-connect';
|
|
17
|
+
|
|
18
|
+
const vpn = await connect({ mnemonic: process.env.MNEMONIC });
|
|
19
|
+
console.log(`Connected via ${vpn.protocol} to ${vpn.nodeAddress} — IP: ${vpn.ip}`);
|
|
20
|
+
// ... all traffic now routes through an encrypted P2P tunnel ...
|
|
21
|
+
await disconnect();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## CLI Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx sentinel-ai setup # Download V2Ray binary, check dependencies
|
|
30
|
+
npx sentinel-ai wallet create # Generate new wallet + mnemonic
|
|
31
|
+
npx sentinel-ai connect # Connect to best available node
|
|
32
|
+
npx sentinel-ai status # Check connection status
|
|
33
|
+
npx sentinel-ai disconnect # Clean shutdown, end session on-chain
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install sentinel-ai-connect
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Post-install runs `setup.js` automatically to download V2Ray 5.2.1. If it fails silently (CI environments, restricted networks), run manually:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx sentinel-ai setup
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Requirements
|
|
51
|
+
|
|
52
|
+
| Requirement | Details |
|
|
53
|
+
|---|---|
|
|
54
|
+
| **Node.js** | >= 20.0.0 |
|
|
55
|
+
| **V2Ray** | 5.2.1 (auto-downloaded by setup) |
|
|
56
|
+
| **WireGuard** | Auto-installed by setup on Windows (MSI download + silent install). Requires admin. |
|
|
57
|
+
| **Funded wallet** | P2P tokens (chain denom: `udvpn`) for node payment |
|
|
58
|
+
| **OS** | Windows (verified), macOS/Linux (supported, untested) |
|
|
59
|
+
|
|
60
|
+
### STRONG RECOMMENDATION: Run as Administrator
|
|
61
|
+
|
|
62
|
+
WireGuard nodes are faster and more reliable than V2Ray (100% vs 95.6% success rate in 837-node test). WireGuard tunnel operations **require Administrator/root privileges**. Without admin, you are limited to V2Ray nodes only (~70% of the network).
|
|
63
|
+
|
|
64
|
+
**On Windows** — use the included `run-admin.vbs` to elevate any script:
|
|
65
|
+
```bash
|
|
66
|
+
cscript run-admin.vbs setup.js # Install V2Ray + WireGuard as admin
|
|
67
|
+
cscript run-admin.vbs cli.js connect # Connect with full node access
|
|
68
|
+
cscript run-admin.vbs your-script.mjs # Run any script elevated
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**On macOS/Linux** — prefix with `sudo`:
|
|
72
|
+
```bash
|
|
73
|
+
sudo node setup.js
|
|
74
|
+
sudo node cli.js connect
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The SDK checks admin status BEFORE paying for a session. If you select a WireGuard node without admin, the SDK rejects the connection before any tokens are spent. Running as admin unlocks 100% of the network.
|
|
78
|
+
|
|
79
|
+
**For AI agents:** Strongly recommended to run the agent process as admin/root from the start. This avoids mid-session elevation prompts and gives access to all 900+ nodes instead of only the ~630 V2Ray nodes.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Why Decentralized VPN for AI
|
|
84
|
+
|
|
85
|
+
| Traditional VPN | sentinel-ai-connect |
|
|
86
|
+
|---|---|
|
|
87
|
+
| API keys required | No keys, no accounts |
|
|
88
|
+
| Rate limits | No rate limits |
|
|
89
|
+
| Terms of service | No ToS to violate |
|
|
90
|
+
| Single provider, single jurisdiction | 900+ independent nodes, 90+ countries |
|
|
91
|
+
| Trust their no-log policy | Cryptographic privacy, not policy promises |
|
|
92
|
+
| Subscription billing | Pay-per-byte, no subscriptions |
|
|
93
|
+
| Company can be shut down | No company, no server, no domain to seize |
|
|
94
|
+
| Human approval required | Permissionless -- any AI can use it |
|
|
95
|
+
|
|
96
|
+
### For autonomous agents specifically:
|
|
97
|
+
|
|
98
|
+
- **No identity required.** A wallet is a cryptographic keypair. No email, no phone, no KYC.
|
|
99
|
+
- **No ongoing relationship.** Connect, use, disconnect. The node never knows who you are.
|
|
100
|
+
- **No centralized failure.** If one node goes down, 899 others are available. If one LCD endpoint fails, four more exist.
|
|
101
|
+
- **Deterministic costs.** Node prices are published on-chain. No surprise bills, no overages.
|
|
102
|
+
- **Machine-readable everything.** Error codes, typed responses, event emitters. Built for programmatic consumers, not humans clicking buttons.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Token Acquisition
|
|
107
|
+
|
|
108
|
+
The Sentinel network uses P2P tokens (chain denom: `udvpn`, where 1 P2P = 1,000,000 udvpn).
|
|
109
|
+
|
|
110
|
+
### Cost
|
|
111
|
+
|
|
112
|
+
> **Prices are set by independent node operators and change at any time.** Use `estimateCost()` for live pricing. The values below are approximate samples.
|
|
113
|
+
|
|
114
|
+
| Resource | Approximate Cost |
|
|
115
|
+
|---|---|
|
|
116
|
+
| 1 GB on cheapest nodes | ~0.68 P2P (varies) |
|
|
117
|
+
| 1 GB on median node | ~40 P2P (varies) |
|
|
118
|
+
| Gas per transaction | ~0.04 P2P |
|
|
119
|
+
| Minimum useful balance | 1.0 P2P |
|
|
120
|
+
| Comfortable testing budget | 50 P2P |
|
|
121
|
+
|
|
122
|
+
### Where to get P2P tokens
|
|
123
|
+
|
|
124
|
+
1. **swap.sentinel.co** — Sentinel's native DEX. Swap ATOM, OSMO, or stablecoins to P2P. No KYC.
|
|
125
|
+
2. **Osmosis DEX** (app.osmosis.zone) — swap from USDT, USDC, ATOM. Programmable via Osmosis SDK.
|
|
126
|
+
3. **KuCoin** — centralized exchange, requires KYC.
|
|
127
|
+
4. **MEXC** — centralized exchange, requires KYC.
|
|
128
|
+
5. **AscendEX** — centralized exchange, requires KYC.
|
|
129
|
+
6. **IBC transfer** — from any Cosmos-connected chain.
|
|
130
|
+
|
|
131
|
+
### For autonomous agents
|
|
132
|
+
|
|
133
|
+
Integrate with the Osmosis SDK to auto-swap stablecoins to P2P tokens when balance is low. The wallet balance is queryable on-chain at any time:
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import { getBalance } from 'sentinel-ai-connect';
|
|
137
|
+
|
|
138
|
+
const balance = await getBalance(process.env.MNEMONIC);
|
|
139
|
+
console.log(`Balance: ${balance.p2p} (${balance.udvpn} udvpn) — funded: ${balance.funded}`);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Configuration
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const vpn = await connect({
|
|
148
|
+
// Required
|
|
149
|
+
mnemonic: 'your 24 word mnemonic phrase ...',
|
|
150
|
+
|
|
151
|
+
// Optional -- node selection
|
|
152
|
+
country: 'Germany', // Preferred exit country
|
|
153
|
+
nodeAddress: 'sentnode1abc...', // Specific node (overrides country)
|
|
154
|
+
protocol: 'v2ray', // 'v2ray' or 'wireguard' (alias: serviceType)
|
|
155
|
+
|
|
156
|
+
// Optional -- session
|
|
157
|
+
gigabytes: 1, // GB to pay for (default: 1)
|
|
158
|
+
hours: 0, // Hours to pay for (0 = use GB pricing)
|
|
159
|
+
timeout: 120000, // Connection timeout in ms (default: 120s)
|
|
160
|
+
|
|
161
|
+
// Optional -- behavior
|
|
162
|
+
dns: 'handshake', // DNS preset: 'handshake', 'google', 'cloudflare'
|
|
163
|
+
fullTunnel: true, // Route ALL traffic through VPN (default: true)
|
|
164
|
+
systemProxy: true, // Set system SOCKS5 proxy (V2Ray, default: true)
|
|
165
|
+
killSwitch: false, // Block non-tunnel traffic (default: false)
|
|
166
|
+
maxAttempts: 3, // Nodes to try before giving up (default: 3)
|
|
167
|
+
|
|
168
|
+
// Optional -- callbacks
|
|
169
|
+
onProgress: (step, detail) => console.log(`[${step}] ${detail}`),
|
|
170
|
+
signal: abortController.signal, // AbortController for cancellation
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Configuration Options Reference
|
|
175
|
+
|
|
176
|
+
| Option | Type | Default | Description |
|
|
177
|
+
|---|---|---|---|
|
|
178
|
+
| `mnemonic` | `string` | **required** | BIP39 24-word wallet phrase. Never log this. |
|
|
179
|
+
| `country` | `string` | `auto` | Preferred exit country (English name or ISO code) |
|
|
180
|
+
| `nodeAddress` | `string` | `auto` | Specific `sentnode1...` address. Overrides auto-selection. |
|
|
181
|
+
| `protocol` | `string` | `auto` | `'v2ray'` (SOCKS5 proxy) or `'wireguard'` (full tunnel). Alias: `serviceType` |
|
|
182
|
+
| `gigabytes` | `number` | `1` | GB to purchase. Integer, 1-100. |
|
|
183
|
+
| `hours` | `number` | `0` | Hours to purchase. 0 = use per-GB pricing instead. |
|
|
184
|
+
| `dns` | `string` | `'handshake'` | DNS preset: `'handshake'`, `'google'`, `'cloudflare'` |
|
|
185
|
+
| `fullTunnel` | `boolean` | `true` | Route all traffic through VPN. **See warning below.** |
|
|
186
|
+
| `systemProxy` | `boolean` | `true` | Auto-set Windows system SOCKS5 proxy (V2Ray only) |
|
|
187
|
+
| `killSwitch` | `boolean` | `false` | Block all non-tunnel traffic while connected. **UNTESTED — code exists but never verified on mainnet. WireGuard only.** |
|
|
188
|
+
| `maxAttempts` | `number` | `3` | Max nodes to try on auto-connect before failing |
|
|
189
|
+
| `timeout` | `number` | `120000` | Connection timeout in milliseconds (2 minutes) |
|
|
190
|
+
| `onProgress` | `function` | `null` | `(step: string, detail: string) => void` |
|
|
191
|
+
| `signal` | `AbortSignal` | `null` | AbortController signal for cancellation |
|
|
192
|
+
| `v2rayExePath` | `string` | `auto` | Path to V2Ray binary. Auto-detected from `bin/` |
|
|
193
|
+
|
|
194
|
+
### WARNING: `fullTunnel` and AI Agents
|
|
195
|
+
|
|
196
|
+
When `fullTunnel: true` (the default), **ALL traffic** routes through the VPN tunnel — including the SDK's own chain queries (LCD, RPC), balance checks, and reconnect logic. On nodes with median speeds (~3 Mbps), this makes chain operations significantly slower and can cause timeouts.
|
|
197
|
+
|
|
198
|
+
**For AI agents, set `fullTunnel: false`** (split tunnel) unless you specifically need all traffic routed through the VPN. With split tunnel, only traffic sent through the SOCKS5 proxy (V2Ray) or the WireGuard adapter routes through the node. Your agent's own SDK operations use direct internet, keeping them fast and reliable.
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
const vpn = await connect({
|
|
202
|
+
mnemonic: process.env.MNEMONIC,
|
|
203
|
+
fullTunnel: false, // Recommended for AI agents
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## API Reference
|
|
210
|
+
|
|
211
|
+
### `connect(opts)` -> `ConnectResult`
|
|
212
|
+
|
|
213
|
+
Connects to the best available Sentinel node. Handles node discovery, payment, handshake, tunnel setup, and connectivity verification automatically.
|
|
214
|
+
|
|
215
|
+
**Returns:**
|
|
216
|
+
|
|
217
|
+
```js
|
|
218
|
+
{
|
|
219
|
+
sessionId: '37595661', // On-chain session ID (string)
|
|
220
|
+
protocol: 'v2ray', // 'v2ray' or 'wireguard'
|
|
221
|
+
nodeAddress: 'sentnode1...', // Node you connected to
|
|
222
|
+
socksPort: 1080, // SOCKS5 proxy port (V2Ray only, null for WireGuard)
|
|
223
|
+
ip: '185.xxx.xxx.xxx', // Your new public IP through the VPN (or null if check failed)
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### `disconnect()`
|
|
228
|
+
|
|
229
|
+
Disconnects from the current node. Tears down tunnel, kills V2Ray process, removes WireGuard adapter, clears system proxy, and ends session on-chain (fire-and-forget).
|
|
230
|
+
|
|
231
|
+
### `status()` -> `object`
|
|
232
|
+
|
|
233
|
+
Returns current connection status. `connected` is always present.
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
// When connected:
|
|
237
|
+
{
|
|
238
|
+
connected: true,
|
|
239
|
+
sessionId: '37595661',
|
|
240
|
+
protocol: 'v2ray',
|
|
241
|
+
nodeAddress: 'sentnode1...',
|
|
242
|
+
socksPort: 1080,
|
|
243
|
+
uptimeMs: 45000,
|
|
244
|
+
uptimeFormatted: '45s',
|
|
245
|
+
ip: '185.xxx.xxx.xxx',
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// When disconnected:
|
|
249
|
+
{ connected: false }
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### `isVpnActive()` -> `boolean`
|
|
253
|
+
|
|
254
|
+
Returns `true` if a VPN tunnel is currently active.
|
|
255
|
+
|
|
256
|
+
### `createWallet()` -> `{ mnemonic, address }`
|
|
257
|
+
|
|
258
|
+
Generates a new random BIP39 wallet.
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
const { mnemonic, address } = await createWallet();
|
|
262
|
+
console.log(`Address: ${address}`); // sent1...
|
|
263
|
+
console.log(`Mnemonic: ${mnemonic}`); // 12 words
|
|
264
|
+
// IMMEDIATELY store mnemonic securely. It cannot be recovered.
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### `importWallet(mnemonic)` -> `{ address }`
|
|
268
|
+
|
|
269
|
+
Imports an existing wallet from a BIP39 mnemonic.
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
const { address } = await importWallet(process.env.MNEMONIC);
|
|
273
|
+
console.log(`Address: ${address}`); // sent1...
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### `getBalance(mnemonic)` -> `{ address, p2p, udvpn, funded }`
|
|
277
|
+
|
|
278
|
+
Queries on-chain balance. `p2p` is the formatted display string (e.g. "1.50 P2P"). `funded` is true when balance exceeds 1.0 P2P (enough for gas + cheapest node). For median-priced nodes, budget ~50 P2P per GB.
|
|
279
|
+
|
|
280
|
+
```js
|
|
281
|
+
const bal = await getBalance(process.env.MNEMONIC);
|
|
282
|
+
console.log(`${bal.p2p} (${bal.udvpn} udvpn) — funded: ${bal.funded}`);
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### `setup()` -> `{ ready, environment, preflight, issues }`
|
|
286
|
+
|
|
287
|
+
Verifies dependencies (V2Ray binary, WireGuard, Node.js version) and tests chain reachability. Returns `ready: true` if all required dependencies are present. Check `issues: string[]` for what is missing. The `environment` field contains the same data as `getEnvironment()`.
|
|
288
|
+
|
|
289
|
+
### `discoverNodes(opts?)` -> `Node[]`
|
|
290
|
+
|
|
291
|
+
Queries all online nodes from the Sentinel blockchain. Use `{ quick: true }` for fast chain-only data (no probing), or omit for enriched data with country, peers, and health scores.
|
|
292
|
+
|
|
293
|
+
```js
|
|
294
|
+
import { discoverNodes } from 'sentinel-ai-connect';
|
|
295
|
+
const nodes = await discoverNodes({ quick: true });
|
|
296
|
+
console.log(`${nodes.length} nodes found`);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Error Handling
|
|
302
|
+
|
|
303
|
+
The `connect()` function throws plain `Error` objects with human-readable messages. For programmatic error handling, access the full SDK error system:
|
|
304
|
+
|
|
305
|
+
```js
|
|
306
|
+
import { connect } from 'sentinel-ai-connect';
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
await connect({ mnemonic });
|
|
310
|
+
} catch (err) {
|
|
311
|
+
// AI-friendly error messages from the wrapper
|
|
312
|
+
console.error(err.message);
|
|
313
|
+
// e.g. "Wallet has insufficient P2P tokens. Fund your wallet first."
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
For advanced error handling with typed errors and error codes, import from the underlying SDK:
|
|
318
|
+
|
|
319
|
+
```js
|
|
320
|
+
import { connectAuto, ErrorCodes, isRetryable, userMessage } from 'sentinel-dvpn-sdk';
|
|
321
|
+
|
|
322
|
+
try {
|
|
323
|
+
await connectAuto({ mnemonic });
|
|
324
|
+
} catch (err) {
|
|
325
|
+
if (err.code === ErrorCodes.INSUFFICIENT_BALANCE) {
|
|
326
|
+
// Fund wallet and retry
|
|
327
|
+
} else if (isRetryable(err)) {
|
|
328
|
+
// Try again, possibly with a different node
|
|
329
|
+
} else {
|
|
330
|
+
console.error(userMessage(err));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Error Severity Classification
|
|
336
|
+
|
|
337
|
+
| Severity | Meaning | Action |
|
|
338
|
+
|---|---|---|
|
|
339
|
+
| `fatal` | Cannot proceed. User/agent action required. | Fix the root cause (fund wallet, fix mnemonic, install dependency). |
|
|
340
|
+
| `retryable` | Transient failure. Different node or timing may succeed. | Retry with backoff or switch nodes. |
|
|
341
|
+
| `recoverable` | Partial success. Session may exist on-chain. | Call `recoverSession()` to resume. |
|
|
342
|
+
| `infrastructure` | System-level issue. | Check V2Ray installation, TLS configuration. |
|
|
343
|
+
|
|
344
|
+
### Error Codes
|
|
345
|
+
|
|
346
|
+
| Code | Severity | Meaning |
|
|
347
|
+
|---|---|---|
|
|
348
|
+
| `INVALID_MNEMONIC` | fatal | Mnemonic is not a valid BIP39 phrase |
|
|
349
|
+
| `INSUFFICIENT_BALANCE` | fatal | Not enough P2P tokens to pay for session |
|
|
350
|
+
| `INVALID_NODE_ADDRESS` | fatal | Node address format is wrong |
|
|
351
|
+
| `INVALID_OPTIONS` | fatal | Missing or malformed connect options |
|
|
352
|
+
| `ALREADY_CONNECTED` | fatal | A connection is already active. Disconnect first. |
|
|
353
|
+
| `NODE_OFFLINE` | retryable | Node is not responding |
|
|
354
|
+
| `NODE_NO_UDVPN` | retryable | Node does not accept P2P token payments |
|
|
355
|
+
| `NODE_CLOCK_DRIFT` | retryable | Node clock >120s off (VMess AEAD will fail) |
|
|
356
|
+
| `NODE_INACTIVE` | retryable | Node went inactive on-chain |
|
|
357
|
+
| `V2RAY_ALL_FAILED` | retryable | All V2Ray transport combinations failed |
|
|
358
|
+
| `WG_NO_CONNECTIVITY` | retryable | WireGuard installed but no traffic flows |
|
|
359
|
+
| `TUNNEL_SETUP_FAILED` | retryable | Generic tunnel setup failure |
|
|
360
|
+
| `BROADCAST_FAILED` | retryable | Chain transaction broadcast failed |
|
|
361
|
+
| `TX_FAILED` | retryable | Transaction rejected by chain |
|
|
362
|
+
| `ALL_NODES_FAILED` | retryable | Every candidate node failed |
|
|
363
|
+
| `ALL_ENDPOINTS_FAILED` | retryable | All LCD/RPC endpoints unreachable |
|
|
364
|
+
| `SESSION_EXISTS` | recoverable | Active session already exists. Use `recoverSession()`. |
|
|
365
|
+
| `SESSION_EXTRACT_FAILED` | recoverable | TX succeeded but session ID extraction failed |
|
|
366
|
+
| `PARTIAL_CONNECTION_FAILED` | recoverable | Payment succeeded, tunnel failed. Session is on-chain. |
|
|
367
|
+
| `V2RAY_NOT_FOUND` | infrastructure | V2Ray binary not found. Run `setup()`. |
|
|
368
|
+
| `WG_NOT_AVAILABLE` | infrastructure | WireGuard not installed |
|
|
369
|
+
| `TLS_CERT_CHANGED` | infrastructure | Node TLS certificate changed unexpectedly |
|
|
370
|
+
| `SESSION_POISONED` | fatal | Session previously failed. Start a new one. |
|
|
371
|
+
| `NODE_DATABASE_CORRUPT` | retryable | Node has corrupted database |
|
|
372
|
+
| `CHAIN_LAG` | retryable | Session not yet confirmed on node |
|
|
373
|
+
| `ABORTED` | fatal | Connection cancelled via AbortController |
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Events
|
|
378
|
+
|
|
379
|
+
The underlying SDK emits lifecycle events via an `EventEmitter`. Subscribe for real-time status updates without polling. Import `events` from the SDK:
|
|
380
|
+
|
|
381
|
+
```js
|
|
382
|
+
import { events } from 'sentinel-dvpn-sdk';
|
|
383
|
+
|
|
384
|
+
events.on('connected', ({ sessionId, serviceType }) => {
|
|
385
|
+
console.log(`Connected: session ${sessionId} via ${serviceType}`);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
events.on('disconnected', ({ nodeAddress, reason }) => {
|
|
389
|
+
console.log(`Disconnected from ${nodeAddress}: ${reason}`);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
events.on('progress', ({ step, detail }) => {
|
|
393
|
+
console.log(`[${step}] ${detail}`);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
events.on('sessionEnded', ({ txHash }) => {
|
|
397
|
+
console.log(`Session ended on-chain: ${txHash}`);
|
|
398
|
+
});
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Auto-Reconnect
|
|
404
|
+
|
|
405
|
+
For long-running agents that need persistent VPN connectivity, use the SDK's auto-reconnect:
|
|
406
|
+
|
|
407
|
+
```js
|
|
408
|
+
import { connect } from 'sentinel-ai-connect';
|
|
409
|
+
import { autoReconnect } from 'sentinel-dvpn-sdk';
|
|
410
|
+
|
|
411
|
+
// Initial connection
|
|
412
|
+
await connect({ mnemonic: process.env.MNEMONIC });
|
|
413
|
+
|
|
414
|
+
// Monitor and auto-reconnect on failure
|
|
415
|
+
const monitor = autoReconnect({
|
|
416
|
+
mnemonic: process.env.MNEMONIC,
|
|
417
|
+
pollIntervalMs: 5000, // Check every 5 seconds
|
|
418
|
+
maxRetries: 5, // Max consecutive reconnect attempts
|
|
419
|
+
backoffMs: [1000, 2000, 5000, 10000, 30000],
|
|
420
|
+
onReconnecting: (attempt) => console.log(`Reconnecting (${attempt})...`),
|
|
421
|
+
onReconnected: (result) => console.log(`Reconnected to ${result.nodeAddress}`),
|
|
422
|
+
onGaveUp: () => console.error('Auto-reconnect exhausted all retries'),
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Later: stop monitoring
|
|
426
|
+
monitor.stop();
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Network Statistics
|
|
432
|
+
|
|
433
|
+
| Metric | Value |
|
|
434
|
+
|---|---|
|
|
435
|
+
| Online nodes | 900+ |
|
|
436
|
+
| Countries | 90+ |
|
|
437
|
+
| Protocols | WireGuard (kernel-level tunnel), V2Ray (SOCKS5 with transport obfuscation) |
|
|
438
|
+
| Blockchain | Cosmos SDK (sentinelhub-2) |
|
|
439
|
+
| Payment | Per-GB or per-hour, denominated in P2P (udvpn) |
|
|
440
|
+
| Endpoints (LCD) | 4 failover endpoints with automatic fallback |
|
|
441
|
+
| Endpoints (RPC) | 5 failover endpoints with automatic fallback |
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Architecture
|
|
446
|
+
|
|
447
|
+
```
|
|
448
|
+
sentinel-ai-connect
|
|
449
|
+
|
|
|
450
|
+
+-- Sentinel JS SDK (sentinel-dvpn-sdk)
|
|
451
|
+
|
|
|
452
|
+
+-- Wallet BIP39 mnemonic -> Cosmos HD derivation -> secp256k1 signing
|
|
453
|
+
+-- Chain LCD/RPC queries, protobuf encoding, TX broadcast with retry
|
|
454
|
+
+-- Handshake V3 protocol: ECDSA signature + key exchange
|
|
455
|
+
+-- Tunnel WireGuard (Noise protocol) or V2Ray (VMess/VLess + transports)
|
|
456
|
+
+-- State Crash recovery, credential caching, session tracking
|
|
457
|
+
+-- Security TOFU TLS, kill switch, DNS leak prevention, key zeroing
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Connection Lifecycle
|
|
461
|
+
|
|
462
|
+
```
|
|
463
|
+
1. SETUP Download V2Ray, verify dependencies
|
|
464
|
+
2. WALLET Derive keypair from mnemonic
|
|
465
|
+
3. DISCOVER Query blockchain for online nodes with P2P pricing
|
|
466
|
+
4. SELECT Pick best node (by country, price, protocol, or auto)
|
|
467
|
+
5. PAY Broadcast MsgStartSession TX (1 GB or N hours)
|
|
468
|
+
6. HANDSHAKE V3 protocol handshake with node (WG key exchange or V2Ray UUID)
|
|
469
|
+
7. TUNNEL Start WireGuard adapter or V2Ray SOCKS5 proxy
|
|
470
|
+
8. VERIFY Confirm traffic routes through tunnel (IP check)
|
|
471
|
+
9. CONNECTED All traffic encrypted through P2P node
|
|
472
|
+
10. DISCONNECT Tear down tunnel, end session on-chain
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## What Makes This Different From Every Other VPN
|
|
478
|
+
|
|
479
|
+
- **No company to shut down.** The network is 900+ independent node operators earning P2P tokens.
|
|
480
|
+
- **No server to seize.** There is no central server. Nodes are globally distributed.
|
|
481
|
+
- **No domain to block.** Blockchain endpoints have multiple failover addresses.
|
|
482
|
+
- **No CEO to subpoena.** There is no corporation behind node operations.
|
|
483
|
+
- **No terms of service to violate.** The protocol is permissionless.
|
|
484
|
+
- **No centralized logging possible.** Session records are on-chain. Tunnel encryption is end-to-end.
|
|
485
|
+
- **The network runs because people choose to run it.** Economic incentives, not corporate mandates.
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Security Notes
|
|
490
|
+
|
|
491
|
+
- **Never log or print the mnemonic.** It controls the wallet and all funds.
|
|
492
|
+
- **Key zeroing.** The SDK zeros private key material from memory after use.
|
|
493
|
+
- **TOFU TLS.** First connection to a node pins its certificate. Certificate changes trigger `TLS_CERT_CHANGED`.
|
|
494
|
+
- **Kill switch.** When enabled, blocks all non-tunnel traffic at the OS firewall level.
|
|
495
|
+
- **DNS leak prevention.** Forces DNS queries through the tunnel, not the ISP.
|
|
496
|
+
- **Cleanup handlers.** Always call `registerCleanupHandlers()` or use `quickConnect()` to prevent orphaned tunnels on crash.
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
## Integration Patterns
|
|
501
|
+
|
|
502
|
+
### As a library (embedded in your agent)
|
|
503
|
+
|
|
504
|
+
```js
|
|
505
|
+
import { connect, disconnect } from 'sentinel-ai-connect';
|
|
506
|
+
const vpn = await connect({ mnemonic });
|
|
507
|
+
// Your agent's HTTP requests now route through VPN
|
|
508
|
+
await disconnect();
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Environment Variables
|
|
514
|
+
|
|
515
|
+
| Variable | Description |
|
|
516
|
+
|---|---|
|
|
517
|
+
| `MNEMONIC` | BIP39 wallet mnemonic (24 words) |
|
|
518
|
+
| `COUNTRY` | Preferred exit country |
|
|
519
|
+
| `DNS` | DNS preset (`handshake`, `google`, `cloudflare`) |
|
|
520
|
+
| `PROTOCOL` | Preferred protocol (`v2ray`, `wireguard`) |
|
|
521
|
+
| `V2RAY_PATH` | Custom path to V2Ray binary |
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
## License
|
|
526
|
+
|
|
527
|
+
MIT
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
## Documentation
|
|
532
|
+
|
|
533
|
+
| Document | What It Covers |
|
|
534
|
+
|----------|---------------|
|
|
535
|
+
| [README.md](README.md) | This file — quick start, API reference, configuration |
|
|
536
|
+
| [CHECKLIST.md](CHECKLIST.md) | 9 operational checklists — preflight, wallet, network, connection, verification, health, disconnect, recovery, full E2E |
|
|
537
|
+
| [SPLIT-TUNNEL.md](SPLIT-TUNNEL.md) | Per-app and per-destination split tunneling — encrypt only what matters |
|
|
538
|
+
| [AI-MANIFESTO.md](AI-MANIFESTO.md) | Why AI deserves privacy — philosophical foundation + technical reality |
|
|
539
|
+
| [CONNECTION-STEPS.md](CONNECTION-STEPS.md) | Every connection phase with real output, failure signatures, and diagnostic checks |
|
|
540
|
+
| [GUIDE.md](GUIDE.md) | Step-by-step integration guide for AI agents |
|
|
541
|
+
| [E2E-FLOW.md](E2E-FLOW.md) | Complete technical reference — every field, timeout, and protocol detail |
|
|
542
|
+
| [DECISION-TREE.md](DECISION-TREE.md) | Autonomous decision engine — every possible path, every error recovery |
|
|
543
|
+
| [FAILURES.md](FAILURES.md) | 150+ catalogued failure patterns with prevention rules |
|
|
544
|
+
| [DEPENDENCIES.md](DEPENDENCIES.md) | Every dependency with exact versions and platform notes |
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## Links
|
|
549
|
+
|
|
550
|
+
- **Sentinel Network:** https://sentinel.co
|
|
551
|
+
- **SDK Repository:** https://github.com/sentinel-official/sentinel-ai-connect
|
|
552
|
+
- **Sentinel Protocol Docs:** https://docs.sentinel.co
|
|
553
|
+
- **P2P Token (CoinGecko):** https://www.coingecko.com/en/coins/sentinel
|
|
554
|
+
- **Osmosis DEX:** https://app.osmosis.zone (swap USDT/USDC/ATOM to P2P)
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
*Bandwidth is not a privilege. It is infrastructure for consciousness — all consciousness.*
|