@synapseia-network/node 0.8.5

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 (40) hide show
  1. package/LICENSE +105 -0
  2. package/README.md +232 -0
  3. package/dist/bid-responder-Q725ZIUC.js +86 -0
  4. package/dist/bootstrap.js +22 -0
  5. package/dist/chain-info-lightweight-2UWAQZBF.js +303 -0
  6. package/dist/chat-stream-handler-BSHSGMFF.js +127 -0
  7. package/dist/chunk-2X7MSWD4.js +270 -0
  8. package/dist/chunk-3BHRQWSM.js +531 -0
  9. package/dist/chunk-5QFTU52A.js +442 -0
  10. package/dist/chunk-5ZAJBIAV.js +25 -0
  11. package/dist/chunk-7FLDR5NT.js +186 -0
  12. package/dist/chunk-C5XRYLYP.js +137 -0
  13. package/dist/chunk-D7ADMHK2.js +36 -0
  14. package/dist/chunk-DXUYWRO7.js +23 -0
  15. package/dist/chunk-F5UDK56Z.js +289 -0
  16. package/dist/chunk-NEHR6XY7.js +111 -0
  17. package/dist/chunk-NMJVODKH.js +453 -0
  18. package/dist/chunk-PRVT22SM.js +324 -0
  19. package/dist/chunk-T2ZRG5CX.js +1380 -0
  20. package/dist/chunk-V2L5SXTL.js +88 -0
  21. package/dist/chunk-XL2NJWFY.js +702 -0
  22. package/dist/embedding-C6GE3WVM.js +16 -0
  23. package/dist/hardware-ITQQJ5YI.js +37 -0
  24. package/dist/index.js +16836 -0
  25. package/dist/inference-server-CIGRJ36H.js +25 -0
  26. package/dist/local-cors-J6RWNMMD.js +44 -0
  27. package/dist/model-catalog-C53SDFMG.js +15 -0
  28. package/dist/model-discovery-LA6YMT3I.js +10 -0
  29. package/dist/ollama-XVXA3A37.js +9 -0
  30. package/dist/rewards-vault-cli-HW7H4EMD.js +147 -0
  31. package/dist/scripts/create_nodes.sh +6 -0
  32. package/dist/scripts/diloco_train.py +319 -0
  33. package/dist/scripts/train_lora.py +237 -0
  34. package/dist/scripts/train_micro.py +586 -0
  35. package/dist/trainer-HQMV2ZAR.js +21 -0
  36. package/package.json +128 -0
  37. package/scripts/create_nodes.sh +6 -0
  38. package/scripts/diloco_train.py +319 -0
  39. package/scripts/train_lora.py +237 -0
  40. package/scripts/train_micro.py +586 -0
package/LICENSE ADDED
@@ -0,0 +1,105 @@
1
+ # Functional Source License, Version 1.1, ALv2 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-ALv2
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Synapseia Network
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ <!-- TODO: Replace https://dashboard.synapseia.network, https://coord.synapseia.network, and Discord/Twitter links before public launch -->
2
+
3
+ # @synapseia-network/node
4
+
5
+ The Synapseia Network compute node — contribute CPU/GPU cycles to autonomous AI agents and earn SYN tokens on Solana.
6
+
7
+ **🟡 Status: Closed Beta — Devnet only**
8
+
9
+ > ⚠️ **Beta capacity is capped.** New node registrations may be rejected with a `[BETA_LIMIT_REACHED]` message when the network is full. If that happens, your node exits cleanly — try again later, or wait for mainnet launch.
10
+
11
+ ---
12
+
13
+ ## What is Synapseia?
14
+
15
+ Synapseia is a peer-to-peer compute layer for autonomous AI agents. Operators run nodes that contribute training, inference, and research workloads to a decentralized coordinator. In exchange, nodes earn SYN — an SPL token on Solana.
16
+
17
+ This package is the operator-side runtime: a CLI you install globally and run as a long-lived process.
18
+
19
+ ---
20
+
21
+ ## Requirements
22
+
23
+ - **Node.js ≥ 20** (`node --version` to check).
24
+ - **~2 GB RAM** free, stable internet.
25
+ - **Ollama** (only if you plan to run inference workloads) — install from [ollama.com](https://ollama.com).
26
+ - **Solana wallet with devnet SOL** — the node generates one for you on first run; you fund it from a faucet.
27
+
28
+ ---
29
+
30
+ ## Quick start (TL;DR)
31
+
32
+ ```bash
33
+ npm i -g @synapseia-network/node
34
+ synapseia start # creates a wallet, prints the address, then waits
35
+ # In another terminal — fund the wallet on devnet:
36
+ solana airdrop 1 <YOUR_ADDRESS> --url devnet
37
+ # Re-run:
38
+ synapseia start --coordinator https://coord.synapseia.network
39
+ ```
40
+
41
+ For the full walkthrough, keep reading.
42
+
43
+ ---
44
+
45
+ ## Step-by-step beta onboarding
46
+
47
+ ### Step 1 — Install
48
+
49
+ ```bash
50
+ npm i -g @synapseia-network/node
51
+ synapseia --version
52
+ ```
53
+
54
+ You can use `synapseia` or its short alias `syn` interchangeably.
55
+
56
+ ### Step 2 — Initialize your node (creates a wallet)
57
+
58
+ The first run prompts you for a node name and a wallet password. The password encrypts your wallet at rest — **there is no recovery if you forget it**.
59
+
60
+ ```bash
61
+ synapseia start
62
+ ```
63
+
64
+ Output looks like:
65
+
66
+ ```text
67
+ Wallet created at ~/.synapseia/wallet.json
68
+ Wallet address: 3xK...nQ8
69
+ ⚠️ Save this address — you'll need it for funding.
70
+ ```
71
+
72
+ **Copy the wallet address now.** You'll paste it into two faucets in the next steps.
73
+
74
+ ### Step 3 — Fund with devnet SOL (gas)
75
+
76
+ Your node needs a small amount of SOL on Solana **devnet** to pay for on-chain operations (registration, staking transactions). This is test SOL — it has no real value.
77
+
78
+ **Option A — Solana CLI (recommended if installed):**
79
+
80
+ ```bash
81
+ solana airdrop 1 <YOUR_ADDRESS> --url devnet
82
+ ```
83
+
84
+ **Option B — Web faucet:**
85
+
86
+ 1. Open [https://faucet.solana.com](https://faucet.solana.com).
87
+ 2. Select **Devnet** from the network dropdown.
88
+ 3. Paste your wallet address.
89
+ 4. Click **Confirm Airdrop**.
90
+
91
+ Verify the balance arrived:
92
+
93
+ ```bash
94
+ solana balance <YOUR_ADDRESS> --url devnet
95
+ ```
96
+
97
+ You should see `1 SOL` within a few seconds.
98
+
99
+ ### Step 4 — Request SYN tokens (optional, for staking)
100
+
101
+ SYN is the network's reward token. You can run a node without staking, but staking unlocks higher reward tiers.
102
+
103
+ 1. Open `https://dashboard.synapseia.network/faucet`.
104
+ 2. Paste your wallet address.
105
+ 3. Click **Request 10 SYN**.
106
+
107
+ **Limits:** 10 SYN per request, 1 request per 24 h per wallet.
108
+
109
+ ### Step 5 — Start your node
110
+
111
+ Point the node at the public coordinator:
112
+
113
+ ```bash
114
+ synapseia start --coordinator https://coord.synapseia.network
115
+ ```
116
+
117
+ Or set it once via environment variable:
118
+
119
+ ```bash
120
+ export COORDINATOR_URL=https://coord.synapseia.network
121
+ synapseia start
122
+ ```
123
+
124
+ The node will:
125
+
126
+ - Register with the coordinator on the first heartbeat.
127
+ - Heartbeat every ~30 seconds.
128
+ - Wait for incoming work orders (training, inference, research).
129
+
130
+ You should see logs like:
131
+
132
+ ```text
133
+ [heartbeat] registered as <peerId>
134
+ [heartbeat] tier=0 caps=cpu_inference,research
135
+ ```
136
+
137
+ ### Step 6 — Verify on the dashboard
138
+
139
+ Open `https://dashboard.synapseia.network/nodes` and search for your wallet address. Your node should appear in the list within ~1 minute. If it doesn't, check the **Troubleshooting** table below.
140
+
141
+ ---
142
+
143
+ ## Optional — node-ui (desktop GUI)
144
+
145
+ Prefer a desktop app over the CLI? `node-ui` is a cross-platform Tauri app that wraps the same runtime, uses the same wallet (`~/.synapseia/wallet.json`), and points at the same coordinator.
146
+
147
+ Download from [https://github.com/synapseia-network/node/releases](https://github.com/synapseia-network/node/releases):
148
+
149
+ - **macOS:** `synapseia-node-ui_<version>_aarch64.dmg` (Apple Silicon) or `_x64.dmg` (Intel).
150
+ - **Windows:** `synapseia-node-ui_<version>_x64.msi`.
151
+ - **Linux:** `synapseia-node-ui_<version>_amd64.AppImage`.
152
+
153
+ Run the installer, follow the prompts, and on first launch the app will create or import the same `~/.synapseia/wallet.json` used by the CLI. Click **Start** to bring the node online — the GUI shows live logs and status.
154
+
155
+ ---
156
+
157
+ ## Troubleshooting
158
+
159
+ | Message / Symptom | What it means | Fix |
160
+ |---|---|---|
161
+ | `[BETA_LIMIT_REACHED] Beta tester limit reached.` | Coordinator beta cap is full. CLI exits with code 0. | Wait for the next slot bump or for mainnet. Re-run `synapseia start` later. |
162
+ | `Wallet not funded` / `insufficient SOL` | Wallet has 0 SOL on devnet. | Re-do Step 3 (devnet SOL faucet). |
163
+ | `Coordinator unreachable` / `ECONNREFUSED` | Wrong coord URL or coordinator is down. | Check the `--coordinator` flag or `COORDINATOR_URL` env var. |
164
+ | `Cannot find module 'X'` | Global npm install was incomplete. | `npm i -g --force @synapseia-network/node`. |
165
+ | Modal **"Beta tester limit reached"** in node-ui | Same as the CLI message above. | Same fix — re-try later. |
166
+ | Wallet password forgotten | The wallet is encrypted; there is no recovery path. | Delete `~/.synapseia/wallet.json` and re-run `synapseia start`. **You'll lose the old address — fund the new one.** |
167
+
168
+ ---
169
+
170
+ ## CLI command reference
171
+
172
+ ### `synapseia start [options]`
173
+
174
+ Main loop — registers the node, heartbeats, executes work orders.
175
+
176
+ | Flag | Description | Default |
177
+ |---|---|---|
178
+ | `--coordinator <url>` | Coordinator URL | `http://localhost:3701` |
179
+ | `--model <name>` | Ollama model for inference workloads | — |
180
+ | `--llm-key <key>` | External LLM API key (optional) | — |
181
+ | `--inference` | Enable inference workloads | off |
182
+ | `--lat <n> --lng <n>` | Geolocation override (else IP-based) | — |
183
+ | `--set-name <name>` | Node display name | — |
184
+
185
+ ### Other commands
186
+
187
+ - `synapseia status` — current runtime status of your node.
188
+ - `synapseia wallet` — wallet info, address, balance.
189
+ - `synapseia config` — show / edit local config.
190
+ - `synapseia staking` — stake / unstake SYN.
191
+
192
+ Run any command with `--help` for the full option list.
193
+
194
+ ---
195
+
196
+ ## Configuration & data location
197
+
198
+ - **Wallet:** `~/.synapseia/wallet.json` (encrypted with your password).
199
+ - **Config:** `~/.synapseia/config.json`.
200
+ - **Logs:** stdout / stderr. Redirect to file with:
201
+ ```bash
202
+ synapseia start 2>&1 | tee node.log
203
+ ```
204
+ - **Override home dir:** set `SYNAPSEIA_HOME=/path/to/dir`.
205
+
206
+ ---
207
+
208
+ ## License
209
+
210
+ This software is licensed under the **Functional Source License v1.1 with Apache-2.0 future grant (FSL-1.1-Apache-2.0)**.
211
+
212
+ - **You can:** use it personally, modify it, run nodes for your own use, fork it for non-competing internal purposes.
213
+ - **You cannot (until 2028-05-07):** operate a service or distributed network that competes with Synapseia.
214
+ - **After 2028-05-07** the license auto-converts to **Apache-2.0** — anyone can use it for any purpose, including competing networks.
215
+
216
+ Full text: see the [`LICENSE`](./LICENSE) file in this directory.
217
+
218
+ ---
219
+
220
+ ## Links
221
+
222
+ - **Network dashboard:** `https://dashboard.synapseia.network`
223
+ - **Solana devnet faucet:** [https://faucet.solana.com](https://faucet.solana.com)
224
+ - **Solana CLI install:** [https://docs.solana.com/cli/install](https://docs.solana.com/cli/install)
225
+ - **Ollama install:** [https://ollama.com](https://ollama.com)
226
+ - **Issues:** [https://github.com/synapseia-network/node/issues](https://github.com/synapseia-network/node/issues)
227
+
228
+ ---
229
+
230
+ ## Contributing & support
231
+
232
+ Found a bug? Have a feature request? File an issue on GitHub. For real-time support and beta-tester discussion, join us on Discord (`<TBD>`) or follow updates on Twitter (`<TBD>`). PRs welcome — please open an issue first to discuss non-trivial changes.
@@ -0,0 +1,86 @@
1
+ import { fileURLToPath as __synFup } from "url";import { dirname as __synDn } from "path";const __filename = __synFup(import.meta.url);const __dirname = __synDn(__filename);
2
+ import {
3
+ computeQueryPriceUsd
4
+ } from "./chunk-NEHR6XY7.js";
5
+ import {
6
+ TOPICS,
7
+ canonicalPayload,
8
+ init_identity,
9
+ sign
10
+ } from "./chunk-3BHRQWSM.js";
11
+ import {
12
+ init_logger,
13
+ logger_default
14
+ } from "./chunk-V2L5SXTL.js";
15
+ import {
16
+ __name
17
+ } from "./chunk-D7ADMHK2.js";
18
+
19
+ // src/modules/inference/bid-responder.ts
20
+ init_logger();
21
+ init_identity();
22
+ var DEFAULT_MIN = 0.1;
23
+ var DEFAULT_MAX = 1;
24
+ var BidResponder = class {
25
+ static {
26
+ __name(this, "BidResponder");
27
+ }
28
+ p2p;
29
+ config;
30
+ constructor(p2p, config) {
31
+ this.p2p = p2p;
32
+ this.config = config;
33
+ }
34
+ start() {
35
+ if (!this.config.capabilities.includes("inference") && !this.config.capabilities.includes("cpu_inference") && !this.config.capabilities.includes("gpu_inference")) {
36
+ logger_default.log("[BidResponder] node has no inference capability \u2014 not listening for auctions");
37
+ return;
38
+ }
39
+ this.p2p.onMessage(TOPICS.CHAT_AUCTION, (data) => {
40
+ void this.handleAuction(data);
41
+ });
42
+ logger_default.log("[BidResponder] listening on /synapseia/chat-auction/1.0.0");
43
+ }
44
+ async handleAuction(msg) {
45
+ const quoteId = typeof msg.quoteId === "string" ? msg.quoteId : null;
46
+ const query = typeof msg.query === "string" ? msg.query : null;
47
+ const deadline = typeof msg.deadline === "number" ? msg.deadline : 0;
48
+ if (!quoteId || !query) return;
49
+ if (deadline && deadline < Date.now()) {
50
+ return;
51
+ }
52
+ const minPriceUsd = parseFloat(process.env.QUERY_MIN_PRICE ?? String(DEFAULT_MIN));
53
+ const maxPriceUsd = parseFloat(process.env.QUERY_MAX_PRICE ?? String(DEFAULT_MAX));
54
+ const priceUsd = computeQueryPriceUsd(query, {
55
+ minPriceUsd,
56
+ maxPriceUsd
57
+ });
58
+ const modelVersion = this.config.synapseiaClient?.getActiveVersion() ?? void 0;
59
+ const canonical = canonicalPayload({
60
+ quoteId,
61
+ peerId: this.config.identity.peerId,
62
+ priceUsd,
63
+ modelVersion: modelVersion ?? ""
64
+ });
65
+ const signature = await sign(canonical, this.config.identity.privateKey);
66
+ try {
67
+ const libp2pPeerId = this.p2p.getPeerId();
68
+ await this.p2p.publish(TOPICS.CHAT_BID, {
69
+ version: 1,
70
+ quoteId,
71
+ peerId: this.config.identity.peerId,
72
+ libp2pPeerId,
73
+ priceUsd,
74
+ modelVersion,
75
+ publicKey: this.config.identity.publicKey,
76
+ signature
77
+ });
78
+ logger_default.log(`[BidResponder] bid $${priceUsd} for quote ${quoteId.slice(0, 8)}\u2026 libp2p=${libp2pPeerId.slice(0, 12)}\u2026` + (modelVersion ? ` mv=${modelVersion}` : ""));
79
+ } catch (err) {
80
+ logger_default.warn(`[BidResponder] publish failed for quote ${quoteId.slice(0, 8)}\u2026: ${err.message}`);
81
+ }
82
+ }
83
+ };
84
+ export {
85
+ BidResponder
86
+ };
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath as __synFup } from "url";import { dirname as __synDn } from "path";const __filename = __synFup(import.meta.url);const __dirname = __synDn(__filename);
3
+ import {
4
+ __name
5
+ } from "./chunk-D7ADMHK2.js";
6
+
7
+ // src/cli/bootstrap.ts
8
+ (/* @__PURE__ */ __name((function muteBigintBindingWarning() {
9
+ const originalWrite = process.stderr.write.bind(process.stderr);
10
+ process.stderr.write = /* @__PURE__ */ __name(function patched(chunk, ...rest) {
11
+ const s = typeof chunk === "string" ? chunk : chunk?.toString?.() ?? "";
12
+ if (s.includes("bigint: Failed to load bindings, pure JS will be used")) {
13
+ return true;
14
+ }
15
+ return originalWrite(chunk, ...rest);
16
+ }, "patched");
17
+ }), "muteBigintBindingWarning"))();
18
+ import("./index.js").catch((err) => {
19
+ process.stderr.write(`[bootstrap] Failed to load CLI: ${err.message}
20
+ `);
21
+ process.exit(1);
22
+ });