@hera-al/standardnode 1.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/LICENSE +21 -0
- package/README.md +241 -0
- package/config.stdnode.example.yaml +44 -0
- package/dist/commands/browser-proxy.d.ts +22 -0
- package/dist/commands/browser-proxy.js +164 -0
- package/dist/commands/shell.d.ts +25 -0
- package/dist/commands/shell.js +62 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.js +141 -0
- package/dist/gateway-link.d.ts +30 -0
- package/dist/gateway-link.js +315 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +170 -0
- package/dist/logger.d.ts +12 -0
- package/dist/logger.js +64 -0
- package/package.json +64 -0
package/dist/logger.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, appendFileSync, renameSync, statSync } from "node:fs";
|
|
2
|
+
import { resolve, join } from "node:path";
|
|
3
|
+
const MAX_SIZE = 10 * 1024 * 1024; // 10 MB
|
|
4
|
+
const MAX_FILES = 9;
|
|
5
|
+
export class Logger {
|
|
6
|
+
dir;
|
|
7
|
+
filePath;
|
|
8
|
+
constructor(logsDir) {
|
|
9
|
+
this.dir = resolve(logsDir);
|
|
10
|
+
if (!existsSync(this.dir)) {
|
|
11
|
+
mkdirSync(this.dir, { recursive: true });
|
|
12
|
+
}
|
|
13
|
+
this.filePath = join(this.dir, "stdnode.log");
|
|
14
|
+
}
|
|
15
|
+
info(tag, msg) {
|
|
16
|
+
this.write("INFO", tag, msg);
|
|
17
|
+
}
|
|
18
|
+
warn(tag, msg) {
|
|
19
|
+
this.write("WARN", tag, msg);
|
|
20
|
+
}
|
|
21
|
+
error(tag, msg) {
|
|
22
|
+
this.write("ERROR", tag, msg);
|
|
23
|
+
}
|
|
24
|
+
debug(tag, msg) {
|
|
25
|
+
this.write("DEBUG", tag, msg);
|
|
26
|
+
}
|
|
27
|
+
write(level, tag, msg) {
|
|
28
|
+
const ts = new Date().toISOString();
|
|
29
|
+
const line = `${ts} [${level}] [${tag}] ${msg}\n`;
|
|
30
|
+
try {
|
|
31
|
+
this.rotate();
|
|
32
|
+
appendFileSync(this.filePath, line, "utf-8");
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Silently ignore write errors
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
rotate() {
|
|
39
|
+
try {
|
|
40
|
+
if (!existsSync(this.filePath))
|
|
41
|
+
return;
|
|
42
|
+
const stat = statSync(this.filePath);
|
|
43
|
+
if (stat.size < MAX_SIZE)
|
|
44
|
+
return;
|
|
45
|
+
// Shift existing rotated files: stdnode.9.log -> delete, 8->9, ... 1->2
|
|
46
|
+
for (let i = MAX_FILES; i >= 1; i--) {
|
|
47
|
+
const src = join(this.dir, `stdnode.${i}.log`);
|
|
48
|
+
if (!existsSync(src))
|
|
49
|
+
continue;
|
|
50
|
+
if (i === MAX_FILES) {
|
|
51
|
+
// oldest file — just let it be overwritten
|
|
52
|
+
}
|
|
53
|
+
const dst = join(this.dir, `stdnode.${i + 1}.log`);
|
|
54
|
+
renameSync(src, dst);
|
|
55
|
+
}
|
|
56
|
+
// Current -> .1
|
|
57
|
+
renameSync(this.filePath, join(this.dir, "stdnode.1.log"));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Ignore rotation errors
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=logger.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hera-al/standardnode",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Hera StandardNode — remote execution node for Hera gateway",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "TGP <heralife.dev@gmail.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/hera-artificial-life/hera-al.git",
|
|
10
|
+
"directory": "packages/standardnode"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/hera-artificial-life/hera-al",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"remote-execution",
|
|
15
|
+
"websocket",
|
|
16
|
+
"shell",
|
|
17
|
+
"browser-automation",
|
|
18
|
+
"ai-agent",
|
|
19
|
+
"hera"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"bin": {
|
|
25
|
+
"hera-stdnode": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"!dist/**/*.map",
|
|
30
|
+
"!src",
|
|
31
|
+
"!tsconfig.json",
|
|
32
|
+
"config.stdnode.example.yaml"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"start": "tsx src/index.ts",
|
|
39
|
+
"dev": "tsx watch src/index.ts",
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"node": "node dist/index.js",
|
|
42
|
+
"help": "tsx src/index.ts --help",
|
|
43
|
+
"prepublishOnly": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"ws": "^8.18.0",
|
|
47
|
+
"yaml": "^2.7.0",
|
|
48
|
+
"zod": "^4.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@hera-al/browser-server": "*"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@hera-al/browser-server": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^22.13.4",
|
|
60
|
+
"@types/ws": "^8.5.13",
|
|
61
|
+
"tsx": "^4.19.3",
|
|
62
|
+
"typescript": "^5.7.3"
|
|
63
|
+
}
|
|
64
|
+
}
|