ton-mesh-harness 0.13.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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +444 -0
  3. package/dist/cli.js +38739 -0
  4. package/dist/daemon/installer-utils.d.ts +103 -0
  5. package/dist/daemon/installer.d.ts +30 -0
  6. package/dist/daemon/linger.d.ts +10 -0
  7. package/dist/daemon/platform.d.ts +47 -0
  8. package/dist/daemon/ports.d.ts +14 -0
  9. package/dist/daemon/rldp-http-proxy-installer.d.ts +10 -0
  10. package/dist/daemon/service.d.ts +36 -0
  11. package/dist/daemon/tonutils-installer.d.ts +10 -0
  12. package/dist/daemon/tonutils-process.d.ts +90 -0
  13. package/dist/deeplink.d.ts +25 -0
  14. package/dist/dns.d.ts +39 -0
  15. package/dist/mcp.js +38097 -0
  16. package/dist/network.d.ts +5 -0
  17. package/dist/sdk/abort.d.ts +25 -0
  18. package/dist/sdk/agentic-config.d.ts +199 -0
  19. package/dist/sdk/agentic-sign.d.ts +48 -0
  20. package/dist/sdk/check.d.ts +24 -0
  21. package/dist/sdk/deploy.d.ts +96 -0
  22. package/dist/sdk/dns-helpers.d.ts +158 -0
  23. package/dist/sdk/dns-onchain.d.ts +39 -0
  24. package/dist/sdk/dns.d.ts +125 -0
  25. package/dist/sdk/endpoints.d.ts +58 -0
  26. package/dist/sdk/json-schemas.d.ts +38 -0
  27. package/dist/sdk/log.d.ts +43 -0
  28. package/dist/sdk/provenance.d.ts +87 -0
  29. package/dist/sdk/resolve-tx.d.ts +70 -0
  30. package/dist/sdk/schemas.d.ts +885 -0
  31. package/dist/sdk/site-record.d.ts +25 -0
  32. package/dist/sdk/status.d.ts +23 -0
  33. package/dist/sdk/walletkit-network.d.ts +30 -0
  34. package/dist/sdk.d.ts +46 -0
  35. package/dist/sdk.js +37789 -0
  36. package/dist/utils/http.d.ts +25 -0
  37. package/dist/utils/tunnel-config.d.ts +20 -0
  38. package/dist/version.d.ts +13 -0
  39. package/dist/wallet/FSStorage.d.ts +12 -0
  40. package/dist/wallet/SendProvider.d.ts +17 -0
  41. package/dist/wallet/Storage.d.ts +5 -0
  42. package/dist/wallet/TonConnectProvider.d.ts +48 -0
  43. package/dist/wallet/constants.d.ts +12 -0
  44. package/dist/wallet/ui.d.ts +13 -0
  45. package/package.json +105 -0
  46. package/skills/mesh-deploy.md +283 -0
  47. package/templates/.well-known/mcp.json +44 -0
  48. package/templates/github-workflow-agentic.yml +94 -0
  49. package/templates/github-workflow.yml +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Masashi Ono
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 ADDED
@@ -0,0 +1,444 @@
1
+ # TON Mesh Harness
2
+
3
+ > One-command CLI to publish a static site to the TON Storage + TON DNS stack โ€” self-host first, agent-callable.
4
+
5
+ Aligned with TON Foundation's [digital-resistance stack](https://telegra.ph/TON-Proxy-Introducing-optional-traffic-micro-payments-and-privacy-via-garlic-routing-03-08). This kit uploads a static site to TON Storage as a bag, points a `.ton` domain at it via TON DNS, and seeds it from your own daemon. The minimal toolkit for builders who need a **web that governments, Cloudflare, and hosting providers cannot take down** โ€” like Tornado Cash / Uniswap UI.
6
+
7
+ ```bash
8
+ npx ton-mesh-harness ./build/ --watch
9
+ ```
10
+
11
+ ```
12
+ ๐Ÿ“ฆ Uploading 47 files...
13
+ โœ“ index.html
14
+ โœ“ assets/main.js (1.2 MB)
15
+ โœ“ assets/style.css
16
+ ... 44 more files
17
+
18
+ โœ… TON Storage (ADNL): ton://bag-a3f9c82e1b4d...
19
+ ๐Ÿ“ฆ Bag ID: a3f9c82e1b4d...
20
+
21
+ watching ./build/ โ€” daemon stays alive to seed your bag.
22
+ Press Ctrl+C to stop seeding.
23
+ ```
24
+
25
+ > **`--watch` is first-class.** Your site is alive on the network for as long as your machine runs the daemon. The 24/7 "via-provider" path (`--provider`) is implemented but **experimental** โ€” the mainnet provider economy is currently dormant. This mirrors TON Foundation's own approach: they self-host `foundation.ton`.
26
+
27
+ ---
28
+
29
+ ## Why this exists
30
+
31
+ DeFi front-ends have repeatedly been forced offline:
32
+
33
+ - **Tornado Cash** โ€” US OFAC sanctions removed the front-end entirely.
34
+ - **Uniswap** โ€” restricted front-end access for specific tokens.
35
+ - **1inch, Balancer, etc.** โ€” geo-blocking, domain takedowns.
36
+
37
+ The shape is always the same: **the smart contract is alive but the website is dead.** The cause is simple: they're served from ordinary servers with ordinary domains.
38
+
39
+ TON already has the infrastructure to fix this. Using it required specialist knowledge and complex setup. This tool reduces that to zero.
40
+
41
+ ---
42
+
43
+ ## Status
44
+
45
+ **Latest: v0.13.0** โ€” renamed to `ton-mesh-harness` (formerly `ton-sovereign-deploy`): the package, both bins, the MCP tool names (`mesh_*`), env vars (`MESH_ANNOUNCE_*`), daemon service labels (`ton-mesh.*`), the on-disk session dir (`~/.ton-mesh/`), and the debug namespace (`mesh:*`) all moved off the `sovereign` brand. Pure rebrand โ€” no runtime behaviour changed. See [CHANGELOG](CHANGELOG.md) for the full migration map and prior releases.
46
+
47
+ **Not yet shipped (upstream-blocked):** NAT traversal [#29](https://github.com/Masashi-Ono0611/ton-mesh-harness/issues/29), Payment Network real client [#30](https://github.com/Masashi-Ono0611/ton-mesh-harness/issues/30).
48
+
49
+ ### Install
50
+
51
+ ```bash
52
+ # CLI
53
+ npm install -g ton-mesh-harness
54
+
55
+ # MCP server (add to your MCP client config โ€” see "Agents & MCP" below)
56
+ npx -y --package ton-mesh-harness ton-mesh-harness-mcp
57
+
58
+ # SDK
59
+ import { deploy, checkEnv, status } from 'ton-mesh-harness'
60
+ ```
61
+
62
+ ---
63
+
64
+ ## How it works
65
+
66
+ ### TON Storage (decentralized file storage)
67
+
68
+ - Stores files distributed across the blockchain network.
69
+ - Identified by content address (Bag ID) โ€” the URL never changes unless the content does.
70
+ - No central host that can delete it. The content address is immutable, but the site stays reachable **only while at least one publicly-reachable node seeds the bag**.
71
+
72
+ **Important hosting realities:**
73
+ - Public HTTP gateways resolve `.ton` domains (the on-chain DNS storage record), **not** raw bag ids โ€” `ton.run/<bag_id>` returns 404. To open the site in a browser you need a `.ton` domain pointing at it.
74
+ - Self-hosting means the bag is unreachable while your machine is offline, or while it sits behind NAT with no public IP, since downloaders cannot reach it.
75
+
76
+ **Realistic hosting options:**
77
+
78
+ - **Run your own daemon continuously** (`--watch`, or `--daemon-mode service` to hand it to launchd/systemd). This is exactly how TON Foundation operates `foundation.ton`.
79
+ - **On a cloud VM with a public IP:** run the kit as a publicly-reachable seeder. Pass `--announce-ip <vm public ip> --announce-port <udp port>` (or the `MESH_ANNOUNCE_IP` / `MESH_ANNOUNCE_PORT` env vars), open that UDP port in the firewall, and deploy with `--daemon-mode service`. The daemon advertises a reachable address to the DHT. On deploy the CLI reports whether the node is actually reachable (`โœ“ Publicly reachable` vs `โš  Download-only`). A free GCP `e2-micro` is enough.
80
+ - **Behind NAT / no public IP:** `--tunnel-config` routes the daemon through an ADNL Tunnel pool (v0.6+; bring-your-own โ€” see [`docs/v0.6/byo-rldp-http-proxy.md`](docs/v0.6/byo-rldp-http-proxy.md)).
81
+ - **Storage-provider contract** (`--provider`) is implemented but the mainnet provider economy is currently dormant and gated off pending the payment-network real client ([#30](https://github.com/Masashi-Ono0611/ton-mesh-harness/issues/30)). Treat it as experimental.
82
+
83
+ ### TON DNS (.ton domains)
84
+
85
+ - Register a human-readable domain like `myprotocol.ton` directly on chain.
86
+ - Cannot be seized; updates only with your signature.
87
+ - Accessible via TON Proxy.
88
+
89
+ ### Data flow
90
+
91
+ ```
92
+ npx ton-mesh-harness ./build/
93
+ โ”‚
94
+ โ”œโ”€โ†’ Validate ./build/ (auto-detects dist/ | build/ | out/ | public/)
95
+ โ”‚
96
+ โ”œโ”€โ†’ Check ~/.ton-mesh/bin/storage-daemon
97
+ โ”‚ If missing, auto-download from official TON release (first run only, ~30s)
98
+ โ”‚
99
+ โ”œโ”€โ†’ Send distributed via storage-daemon to the TON network
100
+ โ”‚ BitTorrent-style chunking + Merkle-tree hashing
101
+ โ”‚
102
+ โ””โ”€โ†’ Receive Bag ID โ†’ display result
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Comparison
108
+
109
+ | Tool | Decentralized? | One command? | .ton DNS? | CI/CD? | Windows? |
110
+ |------|---------------|-------------|----------|--------|---------|
111
+ | Vercel / Netlify | No (centralized) | Yes | No | Yes | Yes |
112
+ | IPFS / Fleek | Yes | Yes | No (.eth only) | Yes | Yes |
113
+ | TON CLI (manual) | Yes | No | Manual config | No | No |
114
+ | **TON Mesh Harness** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
115
+
116
+ Direct competitors: none.
117
+
118
+ ---
119
+
120
+ ## Target users
121
+
122
+ 1. **DeFi protocol developers** โ€” eliminate front-end takedown risk.
123
+ 2. **TON ecosystem developers** โ€” easily stand up a .ton site.
124
+ 3. **Censorship-exposed apps in general** โ€” journalism, privacy tools, DAO front-ends.
125
+
126
+ ---
127
+
128
+ ## Agents & MCP
129
+
130
+ The kit is designed to be invoked directly by AI agents via three paths:
131
+
132
+ ```bash
133
+ # 1. CLI โ€” human approves via QR + phone wallet (TonConnect):
134
+ npx -y ton-mesh-harness ./dist --domain myprotocol.ton --json-output
135
+ ```
136
+
137
+ ```bash
138
+ # 2. CLI โ€” autonomous, signs locally from ~/.config/ton/config.json (agentic):
139
+ npx -y ton-mesh-harness ./dist --domain myprotocol.ton \
140
+ --wallet-mode agentic --wallet-label main-mainnet --json-output
141
+ ```
142
+
143
+ ```jsonc
144
+ // 3. MCP server โ€” add to your MCP client config:
145
+ {
146
+ "mcpServers": {
147
+ "ton-mesh-harness": {
148
+ "command": "npx",
149
+ "args": ["-y", "--package", "ton-mesh-harness", "ton-mesh-harness-mcp"]
150
+ }
151
+ // Optional: load @ton/mcp alongside for agentic wallet management:
152
+ // "ton": { "command": "npx", "args": ["-y", "@ton/mcp@alpha"] }
153
+ }
154
+ }
155
+ // โ†’ tools/call mesh_check_env โ†’ mesh_deploy
156
+ ```
157
+
158
+ `--json-output` emits one JSON line per event for agent parsing.
159
+
160
+ ### MCP tools
161
+
162
+ | Tool | What |
163
+ |---|---|
164
+ | `mesh_check_env` | Check environment: daemon binaries, wallet config, connectivity |
165
+ | `mesh_deploy` | Full deploy: bag upload + optional `.ton` DNS write |
166
+ | `mesh_status` | One-shot bag propagation snapshot (use after a `--no-watch` deploy) |
167
+ | `mesh_site_record` | Build a Tonkeeper sign link that sets ONLY the `site` (ADNL) record โ€” point a domain at an rldp-http-proxy without re-deploying. Returns a `tonkeeper_deeplink`; nothing is broadcast until the human signs it. |
168
+
169
+ The agent calls `mesh_check_env` โ†’ `mesh_deploy`. `mesh_deploy` runs the SDK end-to-end through `awaiting_signature โ†’ dns_signing โ†’ dns_confirmed โ†’ verifying`. `mesh_site_record` is a side path: it only builds the deeplink (no daemon, no broadcast), so the agent surfaces `tonkeeper_deeplink` to whoever holds the domain.
170
+
171
+ ### Wallet modes
172
+
173
+ - **`wallet: {kind: "tonconnect"}`** (default) โ€” human approves via QR + phone wallet.
174
+ - **`wallet: {kind: "agentic", config_path?, wallet_label?}`** โ€” autonomous, signs with a key in `~/.config/ton/config.json` (the file `@ton/mcp@alpha` manages). Broadcasts via `@ton/walletkit` โ†’ Toncenter v3. Supports two wallet types:
175
+ - **`type: "standard"`** โ€” mnemonic / private-key direct sign. No extra install.
176
+ - **`type: "agentic"`** โ€” NFT-delegated operator key; signs via the agentic collection contract on behalf of `owner_address`. Requires the optional peer dependency `@ton/mcp@alpha`. The SDK lazy-loads it only when a `type: "agentic"` entry is selected, so TonConnect-only users don't pay the install cost.
177
+
178
+ **`dns_tx_hash`:** both paths resolve the real on-chain tx hash via Toncenter v3's `transactionsByMessage` lookup, in parallel with DNS propagation polling โ€” zero added latency on the happy path.
179
+
180
+ > **Note for agents:** `--watch` mode leaves the agent's host responsible for keeping the daemon alive. Short-lived agent sessions should pass `--no-watch` and use `mesh_status` to poll propagation later. **The MCP server rejects `keep_alive: true`** โ€” use the CLI if you need a keep-alive flow.
181
+
182
+ ---
183
+
184
+ ## CI/CD integration
185
+
186
+ `git push` is the only step; the rest deploys to TON Storage automatically.
187
+
188
+ **Two templates:**
189
+
190
+ | Template | Scope | DNS write |
191
+ |---|---|---|
192
+ | `templates/github-workflow.yml` | bag upload only | no |
193
+ | `templates/github-workflow-agentic.yml` | bag + `.ton` DNS write (autonomous signing) | yes |
194
+
195
+ **Setup (bag only):**
196
+
197
+ ```bash
198
+ mkdir -p .github/workflows
199
+ cp node_modules/ton-mesh-harness/templates/github-workflow.yml \
200
+ .github/workflows/deploy.yml
201
+ git add .github/workflows/deploy.yml && git commit -m "Add TON Storage deployment" && git push
202
+ ```
203
+
204
+ **Setup (agentic โ€” bag + DNS):** full walkthrough at [`docs/v0.8/agentic-cli-usage.md`](docs/v0.8/agentic-cli-usage.md). Prerequisites:
205
+
206
+ 1. Create a wallet: `npx -y @ton/mcp@alpha agentic_import_wallet`.
207
+ 2. Add GH secret `TON_AGENTIC_CONFIG` = contents of `~/.config/ton/config.json` (treat like a plaintext private key).
208
+ 3. Add GH variable `TON_DOMAIN` = your domain.
209
+ 4. Copy `templates/github-workflow-agentic.yml` to `.github/workflows/deploy.yml` and push.
210
+
211
+ **Both templates:** auto-deploy on `main` push ยท `--ci-mode` for clean logs ยท `--json-output` exposes `bag_id` ยท agentic template writes the real on-chain `dns_tx_hash` + tonviewer link into the GH Step Summary.
212
+
213
+ ```
214
+ ๐Ÿš€ Deployed to TON Storage
215
+ Bag ID: a3f9c82e1b4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1
216
+ ton://a3f9c82e...
217
+ Bag may take minutes-hours to propagate through network
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Using ton:// URLs
223
+
224
+ `ton://` URLs are content addresses on TON's ADNL protocol. A bag is immutable once created and persists on the network as long as a reachable node seeds it.
225
+
226
+ ### Access methods
227
+
228
+ **1. Via Ton HTTP Proxy (recommended for browser access)**
229
+
230
+ ```bash
231
+ npm install -g @ton-community/http-proxy
232
+ ton-http-proxy
233
+ open http://localhost:8080/ton://bag-a3f9c82e1b4d...
234
+ ```
235
+
236
+ **2. Any TON Storage client**
237
+
238
+ Any TON Storage client can fetch the bag by id once it has propagated (minutes to hours) โ€” provided a reachable node is seeding it. **Opening it in an ordinary browser is a separate path:** public HTTP gateways resolve a `.ton` domain's **`site` record** (an ADNL identity), not raw bag ids (`ton.run/<bag_id>` 404s) and not the storage record on its own. So browser access needs a `site` record (`--site-auto` / `--site-adnl`) backed by a reachable `rldp-http-proxy` โ€” see [Hosting a site](#hosting-a-site---site-auto).
239
+
240
+ ### Propagation expectations
241
+
242
+ - **Fastest:** a few minutes (when active nodes are available).
243
+ - **Typical:** 30 minutes โ€“ 2 hours.
244
+ - **Worst:** several hours (network-state dependent).
245
+
246
+ The `verify` step waits 60 s โ€” that's "minimum viable verification." Real propagation often takes longer.
247
+
248
+ ---
249
+
250
+ ## CLI reference
251
+
252
+ ```bash
253
+ ton-mesh-harness [build-dir] [options]
254
+ ```
255
+
256
+ ### Common options
257
+
258
+ | Option | Description |
259
+ |--------|-------------|
260
+ | `[build-dir]` | Build directory (auto-detects `dist/` / `build/` / `out/` / `public/` if omitted). |
261
+ | `--domain <domain>` | Register under a `.ton` domain. |
262
+ | `--testnet` | Use TON testnet. |
263
+ | `--desc <text>` | Bag description. |
264
+ | `--watch` | Watch for file changes and auto-redeploy (default in interactive runs). |
265
+ | `--no-watch` | Exit after upload โ€” use in CI or one-shot deploys. |
266
+ | `--debounce <ms>` | Watch-mode debounce delay (default 2000 ms). |
267
+ | `--wallet-mode <mode>` | Signing mode: `tonconnect` (default, QR + phone) or `agentic` (reads `~/.config/ton/config.json`). |
268
+ | `--wallet-label <label>` | Selector for agentic mode (id / name / address). Defaults to `active_wallet_id`. |
269
+ | `--wallet-config <path>` | Override path for the agentic config file. |
270
+ | `--announce-ip <ipv4>` | Set the public IP the daemon advertises to the DHT (cloud VM use). Also `MESH_ANNOUNCE_IP`. |
271
+ | `--announce-port <port>` | Set the UDP port the daemon advertises (cloud VM use). Also `MESH_ANNOUNCE_PORT`. |
272
+ | `--daemon-mode <mode>` | Daemon ownership: `detached` (default) / `embedded` (one-shot) / `service` (hand to launchd/systemd). |
273
+ | `--daemon-backend <name>` | `tonutils` (default) or `ton-core` (C++ legacy; needed only for `--provider`). |
274
+ | `--tunnel-config <path>` | Path to `nodes-pool.json` for ADNL Tunnel NAT traversal (bring-your-own pool). |
275
+ | `--site-auto` | Spawn + manage an `rldp-http-proxy` and write the `site` record automatically (see [Hosting a site](#hosting-a-site---site-auto)). `--site-public-ip` / `--site-udp-port` pin the announced address/port. |
276
+ | `--site-adnl <hex>` | 64-hex ADNL identity to publish as the `site` record under `--domain` (bring-your-own proxy). |
277
+ | `--site-keyring <path>` | Persist the `--site-auto` proxy identity so its ADNL is stable across restarts (default: `~/.ton-mesh/site-keyring/<domain>.hex`). |
278
+ | `--provider [address]` | Storage-provider contract โ€” **disabled** (mainnet provider economy is dormant; [#30](https://github.com/Masashi-Ono0611/ton-mesh-harness/issues/30)). |
279
+ | `--no-provenance` | Skip emitting `.well-known/ton-deploy.json` into the bag. |
280
+ | `--ci-mode` | Disable spinners for CI environments. |
281
+ | `--json-output` | Emit one JSON line per event. Automatically disables `--watch`. |
282
+ | `--skip-verify` | Skip bag-access verification (propagation can be slow). |
283
+ | `--wallet <name>` | Preferred wallet for TonConnect sign requests (default "Tonkeeper"). |
284
+
285
+ Run `ton-mesh-harness doctor` for an environment check before deploying (daemon binaries, TONAPI / TonConnect manifest reachability, wallet pairing state).
286
+
287
+ ### Setting a `site` record (browser hosting)
288
+
289
+ A `.ton` domain can carry two records:
290
+
291
+ - **`storage`** โ†’ a TON Storage bag id. Written by every deploy with `--domain`. Serves files through storage gateways.
292
+ - **`site`** โ†’ an ADNL identity (your rldp-http-proxy). Required for `<domain>.ton` to open in TON Browser. `--site-adnl <hex>` adds it during a deploy.
293
+
294
+ When the domain is already deployed and you only need to point it at (or re-point it at) a proxy identity, use the standalone `site-record` subcommand. It writes **only** the site record โ€” no bag, no storage write, no daemon, no TonConnect:
295
+
296
+ ```bash
297
+ ton-mesh-harness site-record mysite.ton <64-hex-adnl>
298
+ ```
299
+
300
+ It prints a Tonkeeper transfer deeplink. Open it on the phone holding the domain and approve once โ€” that single transaction sets the record. Add `--json-output` to get the deeplink (and the raw message BOC) as a JSON object for agents / CI.
301
+
302
+ ### Hosting a site (`--site-auto`)
303
+
304
+ `--site-auto` spawns a bundled `rldp-http-proxy` that serves the build directory over RLDP and writes the `site` record automatically:
305
+
306
+ ```bash
307
+ ton-mesh-harness ./build/ --domain mysite.ton --site-auto
308
+ ```
309
+
310
+ The proxy identity (a 32-byte seed) is **persisted and reused across restarts** (default `~/.ton-mesh/site-keyring/<domain>.hex`, `--site-keyring <path>` to relocate). This matters because the on-chain `site` record points at this ADNL โ€” a fresh identity every run would take the site down on restart. Re-running the same command keeps the same identity, so the record stays valid.
311
+
312
+ **On a cloud VM with 1:1 NAT (GCP / AWS):** the public IP isn't assigned to a local interface, so the proxy can't bind its outbound socket to it and can't sync the network. Bind it first:
313
+
314
+ ```bash
315
+ sudo ip addr add <public-ip>/32 dev <iface> # find <iface> with: ip -o link
316
+ ```
317
+
318
+ `--site-auto` detects this and prints the exact command if the announced IP isn't local. It also needs the chosen UDP port open inbound (`--site-udp-port` to pin it for a firewall rule). On a plain VPS where the public IP is already on the NIC, none of this applies.
319
+
320
+ **Keep the site up across reboots** with `--daemon-mode service` โ€” the proxy + static server are handed to `launchd` (macOS) / `systemd --user` (Linux) instead of staying tied to the CLI:
321
+
322
+ ```bash
323
+ ton-mesh-harness ./build/ --domain mysite.ton --site-auto \
324
+ --daemon-mode service --site-udp-port 17655 --site-public-ip <public-ip>
325
+ ```
326
+
327
+ The service re-derives the same ADNL from the persisted seed on every restart, so the on-chain `site` record stays valid. Manage it with:
328
+
329
+ ```bash
330
+ ton-mesh-harness service list # bag seeders + site gateways
331
+ ton-mesh-harness service stop-site mysite.ton # stop (add --purge to drop metadata)
332
+ ```
333
+
334
+ > **On Linux, enable lingering once** so the `systemd --user` unit starts after an unattended reboot (it otherwise only runs while you're logged in): `sudo loginctl enable-linger "$USER"`. macOS launchd survives reboots without this.
335
+
336
+ `ton-mesh-harness site-serve --build-dir ./build --domain mysite.ton` runs the same gateway in the foreground (what the service unit executes) โ€” useful for a quick test or under your own supervisor.
337
+
338
+ **Open it.** In TON Browser: `tonsite://mysite.ton`. In an ordinary browser: `https://mysite.ton.run` โ€” the ton.run **site** gateway resolves the `site` ADNL over RLDP once the record is on chain and the proxy is reachable (a storage-only domain, with no `site` record, 404s there). A deploy that writes a `site` record prints this URL as its **Gateway URL** once the record is signed. Full verification recipe: [docs/v0.10/site-hosting.md](docs/v0.10/site-hosting.md).
339
+
340
+ ### Backend choice
341
+
342
+ From v0.6, the bundled daemon is `tonutils-storage` (Go, default). The legacy TON Core C++ daemon is opt-in:
343
+
344
+ ```bash
345
+ # Default: tonutils (Go)
346
+ ton-mesh-harness ./build/
347
+
348
+ # Legacy C++ daemon (needed only for --provider)
349
+ ton-mesh-harness ./build/ --daemon-backend=ton-core
350
+ ```
351
+
352
+ | Feature | tonutils (default) | ton-core (legacy) |
353
+ |---|---|---|
354
+ | Bag upload + seed | โœ… | โœ… |
355
+ | `--watch` | โœ… | โœ… |
356
+ | `--tunnel-config` | โœ… | โŒ |
357
+ | `--testnet` | โœ… | โœ… |
358
+ | `--provider` | โŒ | โš  experimental |
359
+
360
+ ### Watch mode
361
+
362
+ Since v0.6, `--watch` is the default for interactive runs. The daemon stays resident, watches for file changes, and auto-redeploys. When new content is identical the bag id is unchanged โ€” the watch loop logs a `โ†ป no-op` line. With `--domain`, the DNS record continues to point at the initial bag id; stop watch mode and re-run with `--domain` when you want to publish an updated bag.
363
+
364
+ ```bash
365
+ # Default: watch mode
366
+ ton-mesh-harness ./build/
367
+
368
+ # One-shot (for CI)
369
+ ton-mesh-harness ./build/ --no-watch
370
+
371
+ # 3-second debounce for large projects
372
+ ton-mesh-harness ./build/ --debounce 3000
373
+ ```
374
+
375
+ For continuous hosting:
376
+ - `--daemon-mode service` hands the daemon to launchd/systemd so it keeps seeding across reboots.
377
+ - Behind NAT / no public IP: `--tunnel-config` routes through an ADNL Tunnel pool.
378
+ - On a cloud VM: `--announce-ip` + `--announce-port` make the daemon publicly reachable.
379
+
380
+ ### Debug logging
381
+
382
+ ```bash
383
+ # All namespaces
384
+ DEBUG="*" ton-mesh-harness ./build/ --domain x.ton
385
+
386
+ # SDK only
387
+ DEBUG="mesh:*" ton-mesh-harness ./build/ --domain x.ton
388
+
389
+ # Specific namespaces (deploy, agentic-sign, resolve-tx)
390
+ DEBUG="mesh:deploy,mesh:resolve-tx" ton-mesh-harness ./build/
391
+ ```
392
+
393
+ Output is always on **stderr** so `--json-output` stdout stays parseable.
394
+
395
+ ---
396
+
397
+ ## System requirements
398
+
399
+ - **Node.js** 18+ (CI matrix covers 18/20/22).
400
+ - **macOS** 10.15+, **Linux** x86_64/ARM64, **Windows** 10/11 (x64, ARM64).
401
+ - **PowerShell** 3.0+ (Windows only; ships with the OS).
402
+ - Network access to TON nodes.
403
+
404
+ **Windows first run:** PowerShell downloads `storage-daemon.exe` from the official TON GitHub release. Windows Defender may flag it โ€” choose "Allow" or add an exclusion. WSL2 uses the Linux binaries.
405
+
406
+ ---
407
+
408
+ ## Fund recovery
409
+
410
+ If you signed with `--provider` and the provider never issued `accept_storage_contract`, the funds parked in the storage contract are recoverable by sending `op::close_contract` (0x79f937ea). A mainnet-proven script ships with the kit:
411
+
412
+ ```bash
413
+ node scripts/close-storage-contract.cjs <storage-contract-address>
414
+ ```
415
+
416
+ [Field-verified logs and details](docs/archive/v0.5/round-postmortem.md).
417
+
418
+ ---
419
+
420
+ ## Security
421
+
422
+ The kit signs transactions on your behalf (`--wallet-mode agentic`, MCP `mesh_deploy` with `wallet.kind: "agentic"`). Threat model and the private vulnerability disclosure address are in [`SECURITY.md`](SECURITY.md).
423
+
424
+ Notable hardening in v0.9.0: SHA-256 supply-chain integrity on all daemon binary downloads (20 hashes pinned), wallet-payload exfiltration closed (`@tonconnect/sdk` debug log suppression), wallet-key symlink redirect closed, daemon orphan-on-signal closed, MCP contract enforcement.
425
+
426
+ ---
427
+
428
+ ## Docs
429
+
430
+ Full index with Current/Reference/Historical classification: [`docs/README.md`](docs/README.md).
431
+
432
+ - **MCP server spec:** [`docs/v0.8/mcp-core-requirements.md`](docs/v0.8/mcp-core-requirements.md) โ€” the authoritative F1โ€“F5/NF contract.
433
+ - **Agentic CLI usage:** [`docs/v0.8/agentic-cli-usage.md`](docs/v0.8/agentic-cli-usage.md) โ€” `--wallet-mode agentic` prerequisites / selectors / CI.
434
+ - **Agent stack compose:** [`docs/v0.8/agent-stack-compose.md`](docs/v0.8/agent-stack-compose.md) โ€” wiring `ton-mesh-harness-mcp` + `@ton/mcp` for full agentic flows.
435
+ - **v0.9 features:** [MCP HTTP transport](docs/v0.9/mcp-http-transport.md) ยท [provenance](docs/v0.9/provenance.md) ยท [service-mode daemons](docs/v0.9/daemon-service-mode.md) ยท [cross-agent compat](docs/v0.9/agent-compat.md).
436
+ - **Release checklist:** [`docs/v0.9/release-checklist.md`](docs/v0.9/release-checklist.md).
437
+
438
+ **GitHub:** https://github.com/Masashi-Ono0611/ton-mesh-harness
439
+
440
+ ---
441
+
442
+ ## License
443
+
444
+ MIT