@aibexhq/aibex-link 0.0.0-stage → 0.0.1
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 +59 -0
- package/package.json +39 -4
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const DEFAULT_ALIVE_INTERVAL_MS = 15e3;
|
|
5
|
+
function aliveIntervalMs(env = process.env) {
|
|
6
|
+
const raw = env.AIBEX_TIMINGS;
|
|
7
|
+
if (!raw) return DEFAULT_ALIVE_INTERVAL_MS;
|
|
8
|
+
try {
|
|
9
|
+
const value = JSON.parse(raw).aliveIntervalMs;
|
|
10
|
+
return typeof value === "number" && value > 0 ? value : DEFAULT_ALIVE_INTERVAL_MS;
|
|
11
|
+
} catch {
|
|
12
|
+
return DEFAULT_ALIVE_INTERVAL_MS;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const PACKAGE_ROOT = path.resolve(
|
|
16
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
17
|
+
".."
|
|
18
|
+
);
|
|
19
|
+
function readPackageInfo() {
|
|
20
|
+
const manifest = JSON.parse(
|
|
21
|
+
readFileSync(path.join(PACKAGE_ROOT, "package.json"), "utf8")
|
|
22
|
+
);
|
|
23
|
+
if (typeof manifest.name !== "string" || typeof manifest.version !== "string") {
|
|
24
|
+
throw new TypeError(`${PACKAGE_ROOT}/package.json has no name or version`);
|
|
25
|
+
}
|
|
26
|
+
return { name: manifest.name, version: manifest.version };
|
|
27
|
+
}
|
|
28
|
+
function send(message) {
|
|
29
|
+
process.send?.(message);
|
|
30
|
+
}
|
|
31
|
+
function main() {
|
|
32
|
+
const info = readPackageInfo();
|
|
33
|
+
if (process.argv.includes("--self-test")) {
|
|
34
|
+
process.stdout.write(
|
|
35
|
+
`${JSON.stringify({ name: info.name, version: info.version })}
|
|
36
|
+
`
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const host = process.env.AIBEX_HOST;
|
|
41
|
+
const hostDirectory = process.env.AIBEX_HOST_DIR;
|
|
42
|
+
if (!host || !hostDirectory || !process.send) {
|
|
43
|
+
process.stderr.write(
|
|
44
|
+
"aibex-link is started by aibexd: it needs AIBEX_HOST, AIBEX_HOST_DIR and an IPC channel\n"
|
|
45
|
+
);
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
process.stdout.write(
|
|
50
|
+
`aibex-link ${info.version} linked to ${host} (not polling yet)
|
|
51
|
+
`
|
|
52
|
+
);
|
|
53
|
+
send({ type: "ready" });
|
|
54
|
+
setInterval(() => send({ type: "alive" }), aliveIntervalMs());
|
|
55
|
+
process.on("disconnect", () => process.exit(0));
|
|
56
|
+
process.on("SIGTERM", () => process.exit(0));
|
|
57
|
+
process.on("SIGINT", () => process.exit(0));
|
|
58
|
+
}
|
|
59
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aibexhq/aibex-link",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The process aibexd runs to link a machine to an Aibex herd",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/aibexhq/aibex.git",
|
|
9
|
+
"directory": "daemon/link"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"exports": "./dist/index.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=24"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"turbo:build": "vite build",
|
|
25
|
+
"build": "turbo run turbo:build --filter=@aibexhq/aibex-link",
|
|
26
|
+
"turbo:lint": "eslint .",
|
|
27
|
+
"lint": "turbo run turbo:lint --filter=@aibexhq/aibex-link",
|
|
28
|
+
"lint:fix": "eslint . --fix",
|
|
29
|
+
"turbo:test": "vitest run",
|
|
30
|
+
"test": "turbo run turbo:test --filter=@aibexhq/aibex-link",
|
|
31
|
+
"test:watch": "vitest",
|
|
32
|
+
"turbo:typecheck": "tsc --noEmit",
|
|
33
|
+
"typecheck": "turbo run turbo:typecheck --filter=@aibexhq/aibex-link"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^22.15.29",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"vite": "^6.4.1",
|
|
39
|
+
"vitest": "^4.0.15"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/README.md
DELETED