@naisys/hub 3.0.0-beta.33 → 3.0.0-beta.35

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/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # NAISYS Hub
2
+
3
+ [← Back to main README](../../README.md)
4
+
5
+ The hub is the central server and source of truth for a NAISYS cluster. Runners and supervisors connect over WebSocket + REST; the hub owns persistence (mail, context logs, cost, variables) so runners are ephemeral and can be restarted or moved between machines without losing state.
6
+
7
+ Run standalone with `npx naisys_hub`, or in-process with `npx naisys --integrated-hub`.
8
+
9
+ ## Features
10
+
11
+ ### Core
12
+
13
+ - WebSocket + REST server with persistence
14
+ - `hub-protocol` shared-types package between hub and clients for compile-time safety
15
+ - Heartbeat service tracks online runners/supervisors and agent status
16
+ - Run-session tracking per run with keep-alive and authoritative online/offline state
17
+ - Per-app host filter (naisys-host vs supervisor-host)
18
+
19
+ ### Persistence ([doc 001](../../docs/001-database-design.md))
20
+
21
+ The hub owns all shared data, so runners stay ephemeral:
22
+
23
+ - Mail
24
+ - Context log and attachments ([doc 011](../../docs/011-mail-attachments.md))
25
+ - Cost tracking
26
+ - Variables
27
+
28
+ ### Multi-machine
29
+
30
+ - Hub is the single source of truth ([doc 005](../../docs/005-multi-machine-redux.md)); runners are ephemeral
31
+ - Duplicate host-connection prevention; a new connection supersedes a dead one
32
+
33
+ ### Security ([doc 010](../../docs/010-hub-security.md))
34
+
35
+ - `Authorization: Bearer` header auth
36
+ - Rotatable hub access key
37
+ - Hardened spawning: no shell interpretation, timeouts on `execFileSync` to prevent hangs
38
+ - Public attachment IDs; API key read from headers, not query params
39
+ - Hub socket served at `/hub` path for reverse-proxy friendliness (TLS terminated at the proxy)
40
+
41
+ ### Packaging and deployment
42
+
43
+ - Reverse-proxy-friendly path strategy `<app>/api/...`
44
+ - Unified port strategy ([doc 009](../../docs/009-port-strategy.md))
45
+ - npm-published bin entry points: `naisys`, `naisys_hub`, `naisys_supervisor`, `naisys_erp`
46
+ - Ngrok support (skip-browser-warning header + setup guide)
47
+ - PWA manifest, favicons, Apple/Android icons
48
+ - Shrinkwrap lockfile to prevent third-party upgrades from breaking the app
49
+
50
+ ## License
51
+
52
+ MIT
package/dist/naisysHub.js CHANGED
@@ -44,16 +44,15 @@ export const startHub = async (startupType, startSupervisor, plugins, startupAge
44
44
  // Create host registrar for tracking NAISYS instance connections
45
45
  const hostRegistrar = await createHostRegistrar(hubDatabaseService);
46
46
  // Create Fastify instance (TLS is handled by the reverse proxy)
47
- const fastify = Fastify();
47
+ const fastify = Fastify({ pluginTimeout: 60_000 });
48
48
  // Register HTTP attachment upload/download routes
49
49
  createHubAttachmentService(fastify, hubDatabaseService, logService);
50
- // Attach Socket.IO to the underlying HTTP server
50
+ // Attach Socket.IO to the underlying HTTP server.
51
+ // No CORS config: only Node socket.io-clients (NAISYS instance, supervisor server)
52
+ // connect here, and they aren't subject to CORS. Omitting the header keeps
53
+ // browsers from initiating handshakes.
51
54
  const io = new Server(fastify.server, {
52
55
  path: "/hub/socket.io",
53
- cors: {
54
- origin: "*", // In production, restrict this
55
- methods: ["GET", "POST"],
56
- },
57
56
  });
58
57
  const naisysServer = createNaisysServer(io, hubAccessKey, logService, hostRegistrar);
59
58
  // Register hub access key rotation handler
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@naisys/hub",
3
- "version": "3.0.0-beta.33",
3
+ "version": "3.0.0-beta.35",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@naisys/hub",
9
- "version": "3.0.0-beta.33",
9
+ "version": "3.0.0-beta.35",
10
10
  "dependencies": {
11
- "@naisys/common": "3.0.0-beta.33",
12
- "@naisys/common-node": "3.0.0-beta.33",
13
- "@naisys/hub-database": "3.0.0-beta.33",
14
- "@naisys/hub-protocol": "3.0.0-beta.33",
11
+ "@naisys/common": "3.0.0-beta.35",
12
+ "@naisys/common-node": "3.0.0-beta.35",
13
+ "@naisys/hub-database": "3.0.0-beta.35",
14
+ "@naisys/hub-protocol": "3.0.0-beta.35",
15
15
  "commander": "^14.0.3",
16
16
  "dotenv": "^17.3.1",
17
17
  "fastify": "^5.8.2",
@@ -24,7 +24,7 @@
24
24
  "node": ">=22.0.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@naisys/supervisor": "3.0.0-beta.33"
27
+ "@naisys/supervisor": "3.0.0-beta.35"
28
28
  },
29
29
  "peerDependenciesMeta": {
30
30
  "@naisys/supervisor": {
@@ -189,32 +189,32 @@
189
189
  "license": "MIT"
190
190
  },
191
191
  "node_modules/@naisys/common": {
192
- "version": "3.0.0-beta.33",
193
- "resolved": "https://registry.npmjs.org/@naisys/common/-/common-3.0.0-beta.33.tgz",
194
- "integrity": "sha512-htoTTNNQkcW276Z+ca6uVxlmF6nAoxlTVCCGpC4oEmAftxIu8Uf5s0IHJ2Pc8gXZTrW28/85Ec8P0d+nsvzblg==",
192
+ "version": "3.0.0-beta.35",
193
+ "resolved": "https://registry.npmjs.org/@naisys/common/-/common-3.0.0-beta.35.tgz",
194
+ "integrity": "sha512-8SvMZ/D8Ll+ZbnlhovI22Z3sTOhb3im3NLJda9VkBFDJQdfDqacV72YnHmNaG/39VthEzTSn0yrSirJ0O6cgHA==",
195
195
  "dependencies": {
196
196
  "semver": "^7.7.4",
197
197
  "zod": "^4.3.6"
198
198
  }
199
199
  },
200
200
  "node_modules/@naisys/common-node": {
201
- "version": "3.0.0-beta.33",
202
- "resolved": "https://registry.npmjs.org/@naisys/common-node/-/common-node-3.0.0-beta.33.tgz",
203
- "integrity": "sha512-U5M+rqs9Ap44Bs+eZ5vNmpJKRYkM0ca3Lq+aWP5goXHXTuRg0XCGFCc5e6/ugwzWOf2XJkBHnkgYIn1DmeP2qg==",
201
+ "version": "3.0.0-beta.35",
202
+ "resolved": "https://registry.npmjs.org/@naisys/common-node/-/common-node-3.0.0-beta.35.tgz",
203
+ "integrity": "sha512-IpGH9HepjRATQ0AdQby5sd98keBH3TKcXRhRZpUH13j/vRLlbhZOZgzkqQz/55jrRbbSI84EVGZPxly1dUn/XQ==",
204
204
  "dependencies": {
205
- "@naisys/common": "3.0.0-beta.33",
205
+ "@naisys/common": "3.0.0-beta.35",
206
206
  "better-sqlite3": "^12.6.2",
207
207
  "js-yaml": "^4.1.1",
208
208
  "pino": "^10.3.1"
209
209
  }
210
210
  },
211
211
  "node_modules/@naisys/hub-database": {
212
- "version": "3.0.0-beta.33",
213
- "resolved": "https://registry.npmjs.org/@naisys/hub-database/-/hub-database-3.0.0-beta.33.tgz",
214
- "integrity": "sha512-dWr4pVodZhB5c55CksVEDPtxNkLddryNnYs6kvf6vg9v0coMQRemprQb3z4bUDjMSHXBsrVForefnVvct2N7qQ==",
212
+ "version": "3.0.0-beta.35",
213
+ "resolved": "https://registry.npmjs.org/@naisys/hub-database/-/hub-database-3.0.0-beta.35.tgz",
214
+ "integrity": "sha512-AE1wNMm/kMG/FL8VM8OWJiklA08DHi4iFf6HmZIshvK+br/Llt5h8yh3rSAn5gpYuGcstDjmDKsYm+v79QqtUw==",
215
215
  "dependencies": {
216
- "@naisys/common": "3.0.0-beta.33",
217
- "@naisys/common-node": "3.0.0-beta.33",
216
+ "@naisys/common": "3.0.0-beta.35",
217
+ "@naisys/common-node": "3.0.0-beta.35",
218
218
  "@prisma/adapter-better-sqlite3": "^7.5.0",
219
219
  "@prisma/client": "^7.5.0",
220
220
  "better-sqlite3": "^12.6.2",
@@ -222,11 +222,11 @@
222
222
  }
223
223
  },
224
224
  "node_modules/@naisys/hub-protocol": {
225
- "version": "3.0.0-beta.33",
226
- "resolved": "https://registry.npmjs.org/@naisys/hub-protocol/-/hub-protocol-3.0.0-beta.33.tgz",
227
- "integrity": "sha512-vfGw/pe+Zb8lfAmBH/eB3CO2J4NwdMMkD1b8COHxy1ckWZbiUwaV1xbafP8P1qRRdj48BniYMg9sqrCNP5GsNw==",
225
+ "version": "3.0.0-beta.35",
226
+ "resolved": "https://registry.npmjs.org/@naisys/hub-protocol/-/hub-protocol-3.0.0-beta.35.tgz",
227
+ "integrity": "sha512-cX03B8AsRB6Ln/Lm1z0iLiMRO0IKyrxmkpB0915lZ8mctACfgkSBLxYttxOKwV8Gwn7Jj5molPIYSVN6Wntc2Q==",
228
228
  "dependencies": {
229
- "@naisys/common": "3.0.0-beta.33",
229
+ "@naisys/common": "3.0.0-beta.35",
230
230
  "zod": "^4.3.6"
231
231
  }
232
232
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naisys/hub",
3
- "version": "3.0.0-beta.33",
3
+ "version": "3.0.0-beta.35",
4
4
  "description": "NAISYS Hub - Adds persistence and multi-instance coordination to NAISYS",
5
5
  "type": "module",
6
6
  "main": "dist/naisysHub.js",
@@ -31,7 +31,7 @@
31
31
  "!dist/**/*.d.ts.map"
32
32
  ],
33
33
  "peerDependencies": {
34
- "@naisys/supervisor": "3.0.0-beta.33"
34
+ "@naisys/supervisor": "3.0.0-beta.35"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@naisys/supervisor": {
@@ -39,10 +39,10 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@naisys/common": "3.0.0-beta.33",
43
- "@naisys/common-node": "3.0.0-beta.33",
44
- "@naisys/hub-database": "3.0.0-beta.33",
45
- "@naisys/hub-protocol": "3.0.0-beta.33",
42
+ "@naisys/common": "3.0.0-beta.35",
43
+ "@naisys/common-node": "3.0.0-beta.35",
44
+ "@naisys/hub-database": "3.0.0-beta.35",
45
+ "@naisys/hub-protocol": "3.0.0-beta.35",
46
46
  "commander": "^14.0.3",
47
47
  "dotenv": "^17.3.1",
48
48
  "fastify": "^5.8.2",