@tool-bridge/server 0.1.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/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import {
2
+ DEVICE_WS_PATH,
3
+ DeviceHub,
4
+ SqliteSearchIndex,
5
+ SqliteStateStore,
6
+ configFromEnv,
7
+ createDataObjectStore,
8
+ createTbServer
9
+ } from "./chunk-6SMIQ6QU.js";
10
+ import "./chunk-MLKGABMK.js";
11
+ export {
12
+ DEVICE_WS_PATH,
13
+ DeviceHub,
14
+ SqliteSearchIndex,
15
+ SqliteStateStore,
16
+ configFromEnv,
17
+ createDataObjectStore,
18
+ createTbServer
19
+ };
package/dist/main.js ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ configFromEnv,
4
+ createTbServer
5
+ } from "./chunk-6SMIQ6QU.js";
6
+ import "./chunk-MLKGABMK.js";
7
+
8
+ // src/main.ts
9
+ var config = configFromEnv(process.env);
10
+ var server = createTbServer(config);
11
+ var port;
12
+ try {
13
+ ;
14
+ ({ port } = await server.start());
15
+ } catch (err) {
16
+ const detail = err instanceof Error ? err.message : String(err);
17
+ console.error(`[tool-bridge] refusing to start: ${detail}`);
18
+ console.error(
19
+ "[tool-bridge] set TB_BOOTSTRAP_ADMIN_SK to a secret Admin SK before first boot, or set TB_ALLOW_INSECURE_BOOTSTRAP=true for local/dev (generates a random Admin SK and prints it once)."
20
+ );
21
+ await server.close().catch(() => {
22
+ });
23
+ process.exit(1);
24
+ }
25
+ console.log(`[tool-bridge] listening on http://${config.host}:${port} (data: ${config.dataDir})`);
26
+ var shuttingDown = false;
27
+ var shutdown = (signal) => {
28
+ if (shuttingDown) return;
29
+ shuttingDown = true;
30
+ console.log(`[tool-bridge] ${signal} received, shutting down`);
31
+ server.close().then(() => process.exit(0)).catch((err) => {
32
+ console.error("[tool-bridge] shutdown error", err);
33
+ process.exit(1);
34
+ });
35
+ };
36
+ process.on("SIGINT", () => shutdown("SIGINT"));
37
+ process.on("SIGTERM", () => shutdown("SIGTERM"));