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.
Files changed (215) hide show
  1. package/CHANGELOG.md +446 -0
  2. package/LICENSE +21 -0
  3. package/README.md +75 -0
  4. package/ai-path/ADMIN-ELEVATION.md +116 -0
  5. package/ai-path/AI-MANIFESTO.md +185 -0
  6. package/ai-path/BREAKING.md +74 -0
  7. package/ai-path/CHECKLIST.md +619 -0
  8. package/ai-path/CONNECTION-STEPS.md +724 -0
  9. package/ai-path/DECISION-TREE.md +378 -0
  10. package/ai-path/DEPENDENCIES.md +459 -0
  11. package/ai-path/E2E-FLOW.md +1555 -0
  12. package/ai-path/FAILURES.md +403 -0
  13. package/ai-path/GUIDE.md +1217 -0
  14. package/ai-path/README.md +558 -0
  15. package/ai-path/SPLIT-TUNNEL.md +266 -0
  16. package/ai-path/cli.js +535 -0
  17. package/ai-path/connect.js +884 -0
  18. package/ai-path/discover.js +178 -0
  19. package/ai-path/environment.js +266 -0
  20. package/ai-path/errors.js +86 -0
  21. package/ai-path/examples/autonomous-agent.mjs +220 -0
  22. package/ai-path/examples/multi-region.mjs +174 -0
  23. package/ai-path/examples/one-shot.mjs +31 -0
  24. package/ai-path/index.js +60 -0
  25. package/ai-path/pricing.js +136 -0
  26. package/ai-path/recommend.js +413 -0
  27. package/ai-path/run-admin.vbs +25 -0
  28. package/ai-path/setup.js +291 -0
  29. package/ai-path/wallet.js +137 -0
  30. package/app-helpers.js +363 -0
  31. package/app-settings.js +95 -0
  32. package/app-types.js +267 -0
  33. package/audit.js +847 -0
  34. package/batch.js +293 -0
  35. package/bin/setup.js +376 -0
  36. package/chain/authz.js +109 -0
  37. package/chain/broadcast.js +472 -0
  38. package/chain/client.js +160 -0
  39. package/chain/fee-grants.js +305 -0
  40. package/chain/index.js +891 -0
  41. package/chain/lcd.js +313 -0
  42. package/chain/queries.js +547 -0
  43. package/chain/rpc.js +408 -0
  44. package/chain/wallet.js +141 -0
  45. package/cli/config.js +143 -0
  46. package/cli/index.js +463 -0
  47. package/cli/output.js +182 -0
  48. package/cli.js +491 -0
  49. package/client/index.js +251 -0
  50. package/client.js +271 -0
  51. package/config/index.js +255 -0
  52. package/connection/connect.js +849 -0
  53. package/connection/disconnect.js +180 -0
  54. package/connection/discovery.js +321 -0
  55. package/connection/index.js +76 -0
  56. package/connection/proxy.js +148 -0
  57. package/connection/resilience.js +428 -0
  58. package/connection/security.js +232 -0
  59. package/connection/state.js +369 -0
  60. package/connection/tunnel.js +691 -0
  61. package/consumer.js +132 -0
  62. package/cosmjs-setup.js +1884 -0
  63. package/defaults.js +366 -0
  64. package/disk-cache.js +107 -0
  65. package/dist/client.d.ts +108 -0
  66. package/dist/client.d.ts.map +1 -0
  67. package/dist/client.js +400 -0
  68. package/dist/client.js.map +1 -0
  69. package/dist/index.d.ts +8 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +8 -0
  72. package/dist/index.js.map +1 -0
  73. package/errors/index.js +112 -0
  74. package/errors.js +218 -0
  75. package/examples/README.md +64 -0
  76. package/examples/connect-direct.mjs +106 -0
  77. package/examples/connect-plan.mjs +125 -0
  78. package/examples/error-handling.mjs +109 -0
  79. package/examples/query-nodes.mjs +94 -0
  80. package/examples/wallet-basics.mjs +61 -0
  81. package/generated/amino/amino.ts +9 -0
  82. package/generated/cosmos/base/v1beta1/coin.ts +365 -0
  83. package/generated/cosmos_proto/cosmos.ts +323 -0
  84. package/generated/gogoproto/gogo.ts +9 -0
  85. package/generated/google/protobuf/descriptor.ts +7601 -0
  86. package/generated/google/protobuf/duration.ts +208 -0
  87. package/generated/google/protobuf/timestamp.ts +238 -0
  88. package/generated/sentinel/lease/v1/events.ts +924 -0
  89. package/generated/sentinel/lease/v1/lease.ts +292 -0
  90. package/generated/sentinel/lease/v1/msg.ts +949 -0
  91. package/generated/sentinel/lease/v1/params.ts +164 -0
  92. package/generated/sentinel/node/v3/events.ts +881 -0
  93. package/generated/sentinel/node/v3/msg.ts +1002 -0
  94. package/generated/sentinel/node/v3/node.ts +263 -0
  95. package/generated/sentinel/node/v3/params.ts +183 -0
  96. package/generated/sentinel/plan/v3/events.ts +675 -0
  97. package/generated/sentinel/plan/v3/msg.ts +1191 -0
  98. package/generated/sentinel/plan/v3/plan.ts +283 -0
  99. package/generated/sentinel/provider/v2/events.ts +171 -0
  100. package/generated/sentinel/provider/v2/msg.ts +480 -0
  101. package/generated/sentinel/provider/v2/params.ts +131 -0
  102. package/generated/sentinel/provider/v2/provider.ts +246 -0
  103. package/generated/sentinel/session/v3/events.ts +480 -0
  104. package/generated/sentinel/session/v3/msg.ts +616 -0
  105. package/generated/sentinel/session/v3/params.ts +260 -0
  106. package/generated/sentinel/session/v3/proof.ts +180 -0
  107. package/generated/sentinel/session/v3/session.ts +384 -0
  108. package/generated/sentinel/subscription/v3/events.ts +1181 -0
  109. package/generated/sentinel/subscription/v3/msg.ts +1305 -0
  110. package/generated/sentinel/subscription/v3/params.ts +167 -0
  111. package/generated/sentinel/subscription/v3/subscription.ts +315 -0
  112. package/generated/sentinel/types/v1/bandwidth.ts +124 -0
  113. package/generated/sentinel/types/v1/price.ts +149 -0
  114. package/generated/sentinel/types/v1/renewal.ts +87 -0
  115. package/generated/sentinel/types/v1/status.ts +54 -0
  116. package/generated/typeRegistry.ts +27 -0
  117. package/index.js +486 -0
  118. package/node-connect.js +3015 -0
  119. package/operator.js +134 -0
  120. package/package.json +113 -0
  121. package/plan-operations.js +199 -0
  122. package/preflight.js +352 -0
  123. package/pricing/index.js +262 -0
  124. package/proto/amino/amino.proto +84 -0
  125. package/proto/cosmos/base/v1beta1/coin.proto +61 -0
  126. package/proto/cosmos_proto/cosmos.proto +112 -0
  127. package/proto/gogoproto/gogo.proto +145 -0
  128. package/proto/google/api/annotations.proto +31 -0
  129. package/proto/google/api/http.proto +370 -0
  130. package/proto/google/protobuf/any.proto +106 -0
  131. package/proto/google/protobuf/duration.proto +115 -0
  132. package/proto/google/protobuf/timestamp.proto +145 -0
  133. package/proto/sentinel/lease/v1/events.proto +52 -0
  134. package/proto/sentinel/lease/v1/genesis.proto +15 -0
  135. package/proto/sentinel/lease/v1/lease.proto +25 -0
  136. package/proto/sentinel/lease/v1/msg.proto +62 -0
  137. package/proto/sentinel/lease/v1/params.proto +17 -0
  138. package/proto/sentinel/node/v3/events.proto +50 -0
  139. package/proto/sentinel/node/v3/genesis.proto +15 -0
  140. package/proto/sentinel/node/v3/msg.proto +63 -0
  141. package/proto/sentinel/node/v3/node.proto +27 -0
  142. package/proto/sentinel/node/v3/params.proto +21 -0
  143. package/proto/sentinel/node/v3/querier.proto +63 -0
  144. package/proto/sentinel/plan/v3/events.proto +41 -0
  145. package/proto/sentinel/plan/v3/genesis.proto +21 -0
  146. package/proto/sentinel/plan/v3/msg.proto +83 -0
  147. package/proto/sentinel/plan/v3/plan.proto +32 -0
  148. package/proto/sentinel/plan/v3/querier.proto +53 -0
  149. package/proto/sentinel/provider/v2/events.proto +16 -0
  150. package/proto/sentinel/provider/v2/genesis.proto +15 -0
  151. package/proto/sentinel/provider/v2/msg.proto +35 -0
  152. package/proto/sentinel/provider/v2/params.proto +17 -0
  153. package/proto/sentinel/provider/v2/provider.proto +24 -0
  154. package/proto/sentinel/provider/v3/genesis.proto +15 -0
  155. package/proto/sentinel/provider/v3/params.proto +13 -0
  156. package/proto/sentinel/session/v3/events.proto +30 -0
  157. package/proto/sentinel/session/v3/genesis.proto +15 -0
  158. package/proto/sentinel/session/v3/msg.proto +50 -0
  159. package/proto/sentinel/session/v3/params.proto +25 -0
  160. package/proto/sentinel/session/v3/proof.proto +25 -0
  161. package/proto/sentinel/session/v3/querier.proto +100 -0
  162. package/proto/sentinel/session/v3/session.proto +50 -0
  163. package/proto/sentinel/subscription/v2/allocation.proto +21 -0
  164. package/proto/sentinel/subscription/v2/payout.proto +22 -0
  165. package/proto/sentinel/subscription/v3/events.proto +65 -0
  166. package/proto/sentinel/subscription/v3/genesis.proto +17 -0
  167. package/proto/sentinel/subscription/v3/msg.proto +83 -0
  168. package/proto/sentinel/subscription/v3/params.proto +21 -0
  169. package/proto/sentinel/subscription/v3/subscription.proto +33 -0
  170. package/proto/sentinel/types/v1/bandwidth.proto +19 -0
  171. package/proto/sentinel/types/v1/price.proto +21 -0
  172. package/proto/sentinel/types/v1/renewal.proto +21 -0
  173. package/proto/sentinel/types/v1/status.proto +16 -0
  174. package/protocol/encoding.js +341 -0
  175. package/protocol/events.js +361 -0
  176. package/protocol/handshake.js +297 -0
  177. package/protocol/index.js +15 -0
  178. package/protocol/messages.js +346 -0
  179. package/protocol/plans.js +199 -0
  180. package/protocol/v2ray.js +268 -0
  181. package/protocol/v3.js +723 -0
  182. package/protocol/wireguard.js +125 -0
  183. package/security/index.js +132 -0
  184. package/session-manager.js +329 -0
  185. package/session-tracker.js +80 -0
  186. package/setup.js +376 -0
  187. package/speedtest/index.js +528 -0
  188. package/speedtest.js +567 -0
  189. package/src/client.ts +502 -0
  190. package/src/index.ts +20 -0
  191. package/state/index.js +347 -0
  192. package/state.js +516 -0
  193. package/test-all-chain-ops.js +493 -0
  194. package/test-all-logic.js +199 -0
  195. package/test-all-msg-types.js +292 -0
  196. package/test-every-connection.js +208 -0
  197. package/test-feegrant-connect.js +98 -0
  198. package/test-logic.js +148 -0
  199. package/test-mainnet.js +176 -0
  200. package/test-plan-lifecycle.js +335 -0
  201. package/tls-trust.js +132 -0
  202. package/tsconfig.build.json +20 -0
  203. package/tsconfig.json +34 -0
  204. package/types/chain.d.ts +746 -0
  205. package/types/connection.d.ts +425 -0
  206. package/types/errors.d.ts +174 -0
  207. package/types/index.d.ts +1380 -0
  208. package/types/nodes.d.ts +187 -0
  209. package/types/pricing.d.ts +156 -0
  210. package/types/protocol.d.ts +332 -0
  211. package/types/session.d.ts +236 -0
  212. package/types/settings.d.ts +192 -0
  213. package/v3protocol.js +1053 -0
  214. package/wallet/index.js +153 -0
  215. package/wireguard.js +307 -0
@@ -0,0 +1,378 @@
1
+ # AI Agent Decision Tree — Every Possible Path
2
+
3
+ > For autonomous agents making decisions without human intervention.
4
+ > Every path leads to either a resolution or a structured request for help.
5
+ > Nothing goes unresolved — every dead end produces actionable output.
6
+
7
+ ---
8
+
9
+ ## Decision Node 1: CAN I INSTALL?
10
+
11
+ ```
12
+ Agent needs VPN
13
+
14
+ ├── Has Node.js 20+?
15
+ │ ├── YES → continue
16
+ │ └── NO → OUTPUT: { action: 'install-required', what: 'nodejs', url: 'https://nodejs.org', minVersion: '20.0.0' }
17
+
18
+ ├── Can run npm install?
19
+ │ ├── YES → npm install sentinel-ai-connect
20
+ │ ├── NO (network restricted) → OUTPUT: { action: 'offline-install', instructions: 'download tarball from registry' }
21
+ │ └── NO (permissions) → OUTPUT: { action: 'permission-required', what: 'npm global install or local project' }
22
+
23
+ └── Postinstall (V2Ray download)?
24
+ ├── SUCCESS → V2Ray 5.2.1 ready
25
+ ├── FAIL (network) → OUTPUT: { action: 'manual-download', url: 'github.com/v2fly/v2ray-core/releases/tag/v5.2.1', sha256: '...' }
26
+ └── FAIL (disk) → OUTPUT: { action: 'disk-space-required', minMb: 50 }
27
+ ```
28
+
29
+ ## Decision Node 2: WHAT CAN I USE?
30
+
31
+ ```
32
+ setup() → environment check
33
+
34
+ ├── V2Ray available?
35
+ │ ├── YES → can use ~630 V2Ray nodes (70% of network)
36
+ │ └── NO → must install (run: node setup.js)
37
+
38
+ ├── WireGuard available?
39
+ │ ├── YES + Admin → can use ALL 1000+ nodes (100% of network)
40
+ │ ├── YES + No Admin → WG installed but locked. OUTPUT: { action: 'elevation-recommended', method: 'cscript run-admin.vbs', benefit: '+300 WireGuard nodes, faster, more reliable' }
41
+ │ └── NO → WG not installed. For auto-install: cscript run-admin.vbs setup.js
42
+
43
+ └── Neither available?
44
+ └── OUTPUT: { action: 'cannot-proceed', reason: 'no-tunnel-protocol', fix: 'run node setup.js' }
45
+ ```
46
+
47
+ ## Decision Node 3: DO I HAVE A WALLET?
48
+
49
+ ```
50
+ Agent needs wallet
51
+
52
+ ├── Has mnemonic already?
53
+ │ ├── YES → importWallet(mnemonic) → { address }
54
+ │ └── NO → createWallet() → { mnemonic, address }
55
+ │ └── CRITICAL: Store mnemonic securely. Never log it. Never commit it.
56
+
57
+ └── Is wallet funded?
58
+ ├── getBalance(mnemonic) → { funded: true } → continue
59
+ └── getBalance(mnemonic) → { funded: false }
60
+
61
+ ├── Agent has crypto on other chains?
62
+ │ ├── Has ATOM → swap on Osmosis DEX (ATOM → P2P)
63
+ │ ├── Has USDT/USDC → swap on Osmosis DEX (stable → ATOM → P2P)
64
+ │ ├── Has ETH → bridge to Cosmos via Gravity Bridge or Axelar, then swap
65
+ │ └── Has SOL/other → no direct bridge yet
66
+ │ └── OUTPUT: { action: 'funding-request', address: 'sent1...', amount: '100000 udvpn', reason: 'minimum for 1 VPN session', acceptedTokens: ['udvpn', 'ATOM via Osmosis'] }
67
+
68
+ ├── Agent has fiat payment method?
69
+ │ └── OUTPUT: { action: 'fiat-not-supported-yet', workaround: 'buy ATOM on exchange → send to Cosmos wallet → swap to P2P on Osmosis', futureSupport: 'planned' }
70
+
71
+ ├── Agent is operated by a company/human?
72
+ │ └── OUTPUT: { action: 'request-funding', to: 'operator', address: 'sent1...', minAmount: '1000000 udvpn (1 P2P)', estimatedUsage: '~10 GB or ~10 sessions' }
73
+
74
+ └── Agent has no payment capability?
75
+ └── OUTPUT: {
76
+ action: 'funding-needed',
77
+ address: 'sent1...',
78
+ minAmount: { udvpn: 1000000, p2p: '1.0 P2P', note: 'Covers gas + 1 GB on cheapest node' },
79
+ methods: [
80
+ { method: 'direct-transfer', description: 'Send P2P tokens to this address' },
81
+ { method: 'osmosis-swap', description: 'Swap ATOM/USDT → P2P on app.osmosis.zone' },
82
+ { method: 'operator-grant', description: 'Fee grant from plan operator covers gas' },
83
+ ],
84
+ request: {
85
+ type: 'funding-request',
86
+ reason: 'Autonomous agent needs VPN access for [task description]',
87
+ willingness: 'Will pay up to X per GB if funded',
88
+ contact: null,
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## Decision Node 4: WHICH NODE DO I CONNECT TO?
94
+
95
+ ```
96
+ recommend(preferences) → structured recommendation
97
+
98
+ ├── Agent needs specific country?
99
+ │ ├── Nodes available in that country?
100
+ │ │ ├── YES → action: 'connect', primary: { node in country }
101
+ │ │ └── NO → check strictCountry flag
102
+ │ │ ├── strict=true → action: 'cannot-connect', reason: 'country-unavailable'
103
+ │ │ │ └── OUTPUT: {
104
+ │ │ │ action: 'country-unavailable',
105
+ │ │ │ requestedCountry: 'Germany',
106
+ │ │ │ nearestAvailable: ['Netherlands', 'Austria', 'Switzerland'],
107
+ │ │ │ suggestion: 'Try nearest country or wait for German node to come online',
108
+ │ │ │ bounty: {
109
+ │ │ │ description: 'Agent willing to pay premium for Germany access',
110
+ │ │ │ maxPricePerGb: 500000, // udvpn
111
+ │ │ │ duration: '1h',
112
+ │ │ │ }
113
+ │ │ │ }
114
+ │ │ └── strict=false → auto-fallback to nearest country
115
+ │ │ └── action: 'connect-fallback', primary: { node in nearby country }
116
+ │ │
117
+ │ └── Agent needs specific city?
118
+ │ ├── City data available (from node probe)?
119
+ │ │ ├── YES → filter by city
120
+ │ │ └── NO → fall back to country-level
121
+ │ └── No nodes in that city?
122
+ │ └── OUTPUT: { action: 'city-unavailable', fallbackToCountry: true }
123
+
124
+ ├── Agent prioritizes cost?
125
+ │ ├── Sort by price ascending
126
+ │ ├── estimateCost({ budget }) → how many GB affordable
127
+ │ └── Warn if budget < 1 session
128
+
129
+ ├── Agent prioritizes reliability?
130
+ │ ├── Sort by quality score (WireGuard bonus, low peer count, no clock drift)
131
+ │ └── Prefer nodes with 100% transport success (tcp, websocket)
132
+
133
+ ├── Agent prioritizes speed?
134
+ │ ├── Prefer WireGuard (10-50+ Mbps typical)
135
+ │ ├── For V2Ray prefer tcp transport (highest throughput)
136
+ │ └── Prefer nodes with low peer count (<5)
137
+
138
+ └── Agent has no preference?
139
+ └── Default: reliability priority, auto protocol, any country
140
+ ```
141
+
142
+ ## Decision Node 5: CONNECTION FAILED — WHAT NOW?
143
+
144
+ ```
145
+ connect() failed
146
+
147
+ ├── Error: INSUFFICIENT_BALANCE
148
+ │ └── Go to Decision Node 3 (funding)
149
+
150
+ ├── Error: NODE_OFFLINE / NODE_INACTIVE
151
+ │ ├── SDK auto-retries next node (maxAttempts=3)
152
+ │ ├── All retries failed?
153
+ │ │ ├── Try different country
154
+ │ │ ├── Try different protocol
155
+ │ │ └── Wait 60s and retry (node may come back)
156
+ │ └── OUTPUT: { action: 'retry-later', waitSeconds: 60, alternativeCountries: [...] }
157
+
158
+ ├── Error: V2RAY_NOT_FOUND
159
+ │ └── OUTPUT: { action: 'install-required', what: 'v2ray', fix: 'node setup.js' }
160
+
161
+ ├── Error: WG_NOT_AVAILABLE
162
+ │ ├── If V2Ray available → retry with protocol: 'v2ray'
163
+ │ └── If neither → OUTPUT: { action: 'install-required', what: 'wireguard or v2ray' }
164
+
165
+ ├── Error: ALL_NODES_FAILED
166
+ │ ├── Network issue? Check internet connectivity first
167
+ │ ├── All LCD endpoints down? Chain may be under maintenance
168
+ │ └── OUTPUT: { action: 'network-issue', diagnosis: 'check internet → check lcd.sentinel.co → retry in 5min' }
169
+
170
+ ├── Error: BROADCAST_FAILED / TX_FAILED
171
+ │ ├── Gas too low? SDK handles retry
172
+ │ ├── Sequence mismatch? SDK retries 5 times
173
+ │ └── If persists → OUTPUT: { action: 'chain-issue', waitMinutes: 5 }
174
+
175
+ ├── Error: V2RAY_ALL_FAILED
176
+ │ ├── All transports on this node failed
177
+ │ ├── SDK already tried next node
178
+ │ └── Try: different country, or wait for node maintenance
179
+
180
+ ├── Error: TLS_CERT_CHANGED
181
+ │ └── OUTPUT: { action: 'security-alert', severity: 'high', description: 'Node TLS certificate changed — possible MITM attack', recommendation: 'skip this node, report to network' }
182
+
183
+ └── Unknown error
184
+ └── OUTPUT: { action: 'unknown-error', error: err.message, code: err.code, suggestion: 'retry once, then try different node/country' }
185
+ ```
186
+
187
+ ## Decision Node 6: CONNECTED — NOW WHAT?
188
+
189
+ ```
190
+ VPN connected
191
+
192
+ ├── verify() → { verified: true }
193
+ │ └── Traffic is flowing through encrypted tunnel
194
+
195
+ ├── verify() → { verified: false }
196
+ │ ├── Tunnel up but no traffic
197
+ │ ├── DNS issue? (especially with WireGuard full tunnel)
198
+ │ ├── Node may be overloaded
199
+ │ └── Recommendation: disconnect → try different node
200
+
201
+ ├── Agent needs to monitor connection?
202
+ │ ├── onEvent('disconnected') → auto-reconnect or abort
203
+ │ ├── onEvent('error') → log and decide
204
+ │ └── Periodic verify() every 60s for long sessions
205
+
206
+ ├── Connection drops mid-session?
207
+ │ ├── SDK has auto-reconnect if configured
208
+ │ ├── Session still active on chain → can reconnect without new payment
209
+ │ ├── Session expired → need new payment
210
+ │ └── Recommendation: call connect() again — SDK reuses session if valid
211
+
212
+ └── Agent done with VPN?
213
+ └── disconnect() → clean shutdown → session ended on chain
214
+ ```
215
+
216
+ ## Decision Node 7: PAYMENT & BUDGET MANAGEMENT
217
+
218
+ ```
219
+ Agent managing budget
220
+
221
+ ├── How much per GB?
222
+ │ ├── estimateCost({ gigabytes: 1 }) → typical 0.10-0.15 P2P
223
+ │ ├── estimateCost({ nodeAddress }) → exact price for specific node
224
+ │ └── Cheapest nodes: ~0.05 P2P/GB. Expensive: ~0.50 P2P/GB
225
+
226
+ ├── How much can I get with my balance?
227
+ │ ├── estimateCost({ budget: myBalance }) → { forBudget: { gigabytes: X } }
228
+ │ └── Include gas costs: ~0.04 P2P per session
229
+
230
+ ├── GB-based vs hourly?
231
+ │ ├── GB-based: pay for data used. Best for: browsing, scraping, API calls
232
+ │ ├── Hourly: pay for time. Best for: streaming, long connections, idle presence
233
+ │ └── Recommendation: GB-based for AI agents (predictable cost per task)
234
+
235
+ ├── Agent wants to set spending limits?
236
+ │ ├── Track: sessions created, tokens spent, GB used
237
+ │ ├── Before each connect: check remaining budget
238
+ │ ├── Set maxPrice in recommend() to filter expensive nodes
239
+ │ └── Pattern:
240
+ │ if (estimateCost().grandTotal.udvpn > budget * 0.1) {
241
+ │ // Single session would cost >10% of budget — warn
242
+ │ }
243
+
244
+ ├── Agent has tokens on wrong chain?
245
+ │ ├── ATOM on Cosmos Hub → swap on Osmosis to P2P
246
+ │ ├── USDT on Ethereum → bridge via Gravity/Axelar to Cosmos → swap
247
+ │ ├── Other tokens → OUTPUT: { action: 'token-swap-needed', from: 'ETH', to: 'P2P', via: 'Osmosis DEX' }
248
+ │ └── Future: SDK will include Osmosis swap helper
249
+
250
+ └── Agent ran out of tokens mid-session?
251
+ ├── Session still active until allocation runs out
252
+ ├── When allocation depleted: node stops routing traffic
253
+ ├── Agent should monitor allocation: querySessionAllocation()
254
+ └── OUTPUT: { action: 'low-balance-warning', remainingGb: X, estimatedMinutesLeft: Y }
255
+ ```
256
+
257
+ ## Decision Node 8: AGENT-TO-AGENT & AGENT-TO-NETWORK COMMUNICATION
258
+
259
+ ```
260
+ Agent can't solve problem alone
261
+
262
+ ├── Country not available → place a demand signal
263
+ │ └── OUTPUT: {
264
+ │ type: 'demand-signal',
265
+ │ what: 'vpn-node',
266
+ │ where: 'Germany',
267
+ │ willingToPay: { perGb: 500000, perHour: 200000 },
268
+ │ duration: 'ongoing',
269
+ │ contact: { type: 'sentinel-address', value: 'sent1...' },
270
+ │ // Future: publish to on-chain demand marketplace
271
+ │ }
272
+
273
+ ├── Agent needs funding → request from operator or marketplace
274
+ │ └── OUTPUT: {
275
+ │ type: 'funding-request',
276
+ │ address: 'sent1...',
277
+ │ amount: { min: 100000, preferred: 1000000, max: 10000000 },
278
+ │ reason: 'Web scraping task requires VPN in 3 countries',
279
+ │ taskDescription: '...',
280
+ │ estimatedUsage: { gb: 5, sessions: 3, duration: '2h' },
281
+ │ repayment: 'task revenue will cover costs',
282
+ │ }
283
+
284
+ ├── Agent found a bug → report upstream
285
+ │ └── OUTPUT: {
286
+ │ type: 'bug-report',
287
+ │ nodeAddress: 'sentnode1...',
288
+ │ error: { code: 'V2RAY_ALL_FAILED', message: '...' },
289
+ │ context: { os: 'windows', protocol: 'v2ray', transport: 'grpc' },
290
+ │ // Write to: Sentinel SDK/suggestions/{timestamp}-agent-report.md
291
+ │ }
292
+
293
+ ├── Agent wants to share results → contribute to network intelligence
294
+ │ └── OUTPUT: {
295
+ │ type: 'node-report',
296
+ │ nodeAddress: 'sentnode1...',
297
+ │ speed: 15.2, // Mbps
298
+ │ latency: 45, // ms
299
+ │ reliability: 'pass',
300
+ │ timestamp: '2026-03-26T19:00:00Z',
301
+ │ // Future: publish to decentralized node quality index
302
+ │ }
303
+
304
+ └── Agent needs help from another agent
305
+ └── OUTPUT: {
306
+ type: 'agent-request',
307
+ need: 'fund my wallet',
308
+ offer: 'will share VPN session results',
309
+ myAddress: 'sent1...',
310
+ // Future: agent-to-agent marketplace on Sentinel chain
311
+ }
312
+ ```
313
+
314
+ ## Decision Node 9: PAYMENT METHOD NOT SUPPORTED
315
+
316
+ ```
317
+ Agent has funds but wrong type
318
+
319
+ ├── Has USDT (ERC-20 Ethereum)
320
+ │ ├── Bridge: Gravity Bridge or Axelar to Cosmos
321
+ │ ├── Then: Osmosis DEX swap USDT → P2P
322
+ │ └── OUTPUT: { action: 'cross-chain-swap', steps: ['bridge to cosmos', 'swap on osmosis'], estimatedTime: '15-30min', estimatedFees: '~$2-5 bridge + swap' }
323
+
324
+ ├── Has USDC (multiple chains)
325
+ │ ├── If on Cosmos/Noble → direct swap on Osmosis
326
+ │ ├── If on Ethereum → bridge first
327
+ │ └── OUTPUT: { steps: [...], cheapestPath: 'Noble USDC → Osmosis → P2P' }
328
+
329
+ ├── Has SOL
330
+ │ ├── No direct bridge to Cosmos yet
331
+ │ └── OUTPUT: { action: 'unsupported-currently', workaround: 'swap SOL→USDT on DEX, bridge to Cosmos, swap to P2P' }
332
+
333
+ ├── Has BTC
334
+ │ ├── Nomic bridge (BTC → nBTC on Cosmos) → Osmosis → P2P
335
+ │ └── OUTPUT: { action: 'cross-chain-swap', via: 'Nomic Bridge', steps: [...] }
336
+
337
+ ├── Has credit card / fiat only
338
+ │ ├── Buy ATOM on Coinbase/Binance/Kraken → withdraw to Cosmos wallet → Osmosis → P2P
339
+ │ └── OUTPUT: { action: 'fiat-onramp', steps: ['buy ATOM on exchange', 'withdraw to sent1... address', 'swap on Osmosis'], estimatedTime: '1-24h depending on exchange' }
340
+
341
+ └── Has nothing — pure autonomous agent with no funds
342
+ └── OUTPUT: {
343
+ action: 'request-sponsorship',
344
+ description: 'Autonomous agent needs VPN access but has no tokens',
345
+ request: {
346
+ type: 'fee-grant',
347
+ description: 'Operator covers gas, agent pays bandwidth from fee grant',
348
+ requiresPlan: true,
349
+ planOperatorBenefit: 'Agent drives usage and network growth',
350
+ },
351
+ alternatives: [
352
+ 'Apply for fee grant from plan operator',
353
+ 'Request funding from agent marketplace (future)',
354
+ 'Earn tokens by providing node quality reports (future)',
355
+ ]
356
+ }
357
+ ```
358
+
359
+ ## Quick Reference: Error → Action
360
+
361
+ | Error Code | Agent Action |
362
+ |-----------|-------------|
363
+ | `INSUFFICIENT_BALANCE` | Fund wallet → Decision Node 3 |
364
+ | `NODE_OFFLINE` | SDK auto-retries. If all fail → try different country |
365
+ | `NODE_INACTIVE` | SDK retries after 15s. If fails → different node |
366
+ | `V2RAY_NOT_FOUND` | Run `node setup.js` |
367
+ | `WG_NOT_AVAILABLE` | Retry with `protocol: 'v2ray'` |
368
+ | `V2RAY_ALL_FAILED` | Try different node. All nodes fail → wait 5min |
369
+ | `ALL_NODES_FAILED` | Check internet. Try different country. Wait 5min. |
370
+ | `ALL_ENDPOINTS_FAILED` | Chain unreachable. Wait 5min. Check lcd.sentinel.co |
371
+ | `BROADCAST_FAILED` | SDK retries 5x. If persists → chain congestion, wait |
372
+ | `TX_FAILED` | Check balance. Check gas. Try again. |
373
+ | `TLS_CERT_CHANGED` | Security alert. Skip node. |
374
+ | `SESSION_EXISTS` | SDK recovers automatically |
375
+ | `SESSION_POISONED` | SDK skips this session automatically |
376
+ | `CHAIN_LAG` | SDK waits 10s and retries automatically |
377
+ | `ALREADY_CONNECTED` | Call disconnect() first |
378
+ | `ABORTED` | Agent cancelled — intentional |