cerevox 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.
Files changed (54) hide show
  1. package/README.md +388 -0
  2. package/dist/cli/cerevox-run.d.ts +3 -0
  3. package/dist/cli/cerevox-run.d.ts.map +1 -0
  4. package/dist/cli/cerevox-run.js +275 -0
  5. package/dist/cli/cerevox-run.js.map +1 -0
  6. package/dist/core/base.d.ts +57 -0
  7. package/dist/core/base.d.ts.map +1 -0
  8. package/dist/core/base.js +77 -0
  9. package/dist/core/base.js.map +1 -0
  10. package/dist/core/browser.d.ts +30 -0
  11. package/dist/core/browser.d.ts.map +1 -0
  12. package/dist/core/browser.js +107 -0
  13. package/dist/core/browser.js.map +1 -0
  14. package/dist/core/cerevox.d.ts +34 -0
  15. package/dist/core/cerevox.d.ts.map +1 -0
  16. package/dist/core/cerevox.js +153 -0
  17. package/dist/core/cerevox.js.map +1 -0
  18. package/dist/core/code-runner.d.ts +22 -0
  19. package/dist/core/code-runner.d.ts.map +1 -0
  20. package/dist/core/code-runner.js +56 -0
  21. package/dist/core/code-runner.js.map +1 -0
  22. package/dist/core/file-system.d.ts +116 -0
  23. package/dist/core/file-system.d.ts.map +1 -0
  24. package/dist/core/file-system.js +383 -0
  25. package/dist/core/file-system.js.map +1 -0
  26. package/dist/core/session.d.ts +32 -0
  27. package/dist/core/session.d.ts.map +1 -0
  28. package/dist/core/session.js +113 -0
  29. package/dist/core/session.js.map +1 -0
  30. package/dist/core/terminal.d.ts +104 -0
  31. package/dist/core/terminal.d.ts.map +1 -0
  32. package/dist/core/terminal.js +202 -0
  33. package/dist/core/terminal.js.map +1 -0
  34. package/dist/index.d.ts +9 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +29 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/utils/auth.d.ts +4 -0
  39. package/dist/utils/auth.d.ts.map +1 -0
  40. package/dist/utils/auth.js +14 -0
  41. package/dist/utils/auth.js.map +1 -0
  42. package/dist/utils/constants.d.ts +2 -0
  43. package/dist/utils/constants.d.ts.map +1 -0
  44. package/dist/utils/constants.js +5 -0
  45. package/dist/utils/constants.js.map +1 -0
  46. package/dist/utils/detect-code.d.ts +30 -0
  47. package/dist/utils/detect-code.d.ts.map +1 -0
  48. package/dist/utils/detect-code.js +95 -0
  49. package/dist/utils/detect-code.js.map +1 -0
  50. package/dist/utils/logger.d.ts +15 -0
  51. package/dist/utils/logger.d.ts.map +1 -0
  52. package/dist/utils/logger.js +127 -0
  53. package/dist/utils/logger.js.map +1 -0
  54. package/package.json +86 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createClassLogger = exports.createChildLogger = exports.log = exports.logger = void 0;
7
+ const pino_1 = __importDefault(require("pino"));
8
+ const fs_1 = require("fs");
9
+ const path_1 = require("path");
10
+ const fs_2 = require("fs");
11
+ // 环境变量检测
12
+ const isDevelopment = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === undefined;
13
+ const isProduction = process.env.NODE_ENV === 'production';
14
+ // 日志目录配置
15
+ const LOG_DIR = process.env.LOG_DIR || (0, path_1.join)(process.cwd(), 'logs');
16
+ // 确保日志目录存在
17
+ if (isProduction && !(0, fs_2.existsSync)(LOG_DIR)) {
18
+ (0, fs_2.mkdirSync)(LOG_DIR, { recursive: true });
19
+ }
20
+ // 开发环境配置
21
+ const developmentConfig = {
22
+ level: 'debug',
23
+ transport: {
24
+ target: 'pino-pretty',
25
+ options: {
26
+ colorize: true,
27
+ translateTime: 'yyyy-mm-dd HH:MM:ss',
28
+ ignore: 'pid,hostname,module,version',
29
+ singleLine: false,
30
+ hideObject: true,
31
+ messageFormat: '[{class}] {level}: {msg}',
32
+ },
33
+ },
34
+ };
35
+ // 生产环境配置
36
+ const productionConfig = {
37
+ level: 'info',
38
+ formatters: {
39
+ level: label => {
40
+ return { level: label };
41
+ },
42
+ },
43
+ timestamp: pino_1.default.stdTimeFunctions.isoTime,
44
+ base: {
45
+ pid: process.pid,
46
+ hostname: require('os').hostname(),
47
+ },
48
+ };
49
+ // 创建日志流(仅生产环境)
50
+ const createLogStreams = () => {
51
+ if (!isProduction)
52
+ return undefined;
53
+ const today = new Date().toISOString().split('T')[0];
54
+ const logFile = (0, path_1.join)(LOG_DIR, `app-${today}.log`);
55
+ const errorLogFile = (0, path_1.join)(LOG_DIR, `error-${today}.log`);
56
+ return {
57
+ info: (0, fs_1.createWriteStream)(logFile, { flags: 'a' }),
58
+ error: (0, fs_1.createWriteStream)(errorLogFile, { flags: 'a' }),
59
+ };
60
+ };
61
+ // 创建logger实例
62
+ const createLogger = () => {
63
+ if (isDevelopment) {
64
+ return (0, pino_1.default)(developmentConfig);
65
+ }
66
+ if (isProduction) {
67
+ const streams = createLogStreams();
68
+ return (0, pino_1.default)(productionConfig, pino_1.default.multistream([
69
+ // 文件输出(不输出到控制台)
70
+ ...(streams
71
+ ? [
72
+ { stream: streams.info, level: 'info' },
73
+ { stream: streams.error, level: 'error' },
74
+ ]
75
+ : []),
76
+ ]));
77
+ }
78
+ // 默认配置
79
+ return (0, pino_1.default)(developmentConfig);
80
+ };
81
+ // 导出logger实例
82
+ exports.logger = createLogger();
83
+ // 导出便捷方法
84
+ exports.log = {
85
+ debug: (message, ...args) => exports.logger.debug(message, ...args),
86
+ info: (message, ...args) => exports.logger.info(message, ...args),
87
+ warn: (message, ...args) => exports.logger.warn(message, ...args),
88
+ error: (message, ...args) => {
89
+ if (message instanceof Error) {
90
+ exports.logger.error({ err: message }, message.message, ...args);
91
+ }
92
+ else {
93
+ exports.logger.error(message, ...args);
94
+ }
95
+ },
96
+ fatal: (message, ...args) => {
97
+ if (message instanceof Error) {
98
+ exports.logger.fatal({ err: message }, message.message, ...args);
99
+ }
100
+ else {
101
+ exports.logger.fatal(message, ...args);
102
+ }
103
+ },
104
+ };
105
+ // 导出子logger创建函数
106
+ const createChildLogger = (bindings) => {
107
+ return exports.logger.child(bindings);
108
+ };
109
+ exports.createChildLogger = createChildLogger;
110
+ // 为类创建专用logger的函数
111
+ const createClassLogger = (className, additionalBindings, logLevel) => {
112
+ const bindings = {
113
+ class: className,
114
+ module: 'core',
115
+ ...additionalBindings,
116
+ };
117
+ const childLogger = exports.logger.child(bindings);
118
+ // 如果指定了日志级别,设置该logger的级别
119
+ if (logLevel) {
120
+ childLogger.level = logLevel;
121
+ }
122
+ return childLogger;
123
+ };
124
+ exports.createClassLogger = createClassLogger;
125
+ // 默认导出
126
+ exports.default = exports.logger;
127
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2BAAuC;AACvC,+BAA4B;AAC5B,2BAA2C;AAE3C,SAAS;AACT,MAAM,aAAa,GACjB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC;AAC/E,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAE3D,SAAS;AACT,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AACnE,WAAW;AACX,IAAI,YAAY,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;IACzC,IAAA,cAAS,EAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS;AACT,MAAM,iBAAiB,GAAuB;IAC5C,KAAK,EAAE,OAAO;IACd,SAAS,EAAE;QACT,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;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N,cAAM,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC,OAAuB,EAAE,GAAG,IAAW,EAAE,EAAE;QACjD,IAAI,OAAO,YAAY,KAAK,EAAE,CAAC;YAC7B,cAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,cAAM,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF,CAAC;AAEF,gBAAgB;AACT,MAAM,iBAAiB,GAAG,CAAC,QAA6B,EAAE,EAAE;IACjE,OAAO,cAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEF,kBAAkB;AACX,MAAM,iBAAiB,GAAG,CAC/B,SAAiB,EACjB,kBAAwC,EACxC,QAAwD,EACxD,EAAE;IACF,MAAM,QAAQ,GAAG;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,MAAM;QACd,GAAG,kBAAkB;KACtB,CAAC;IACF,MAAM,WAAW,GAAG,cAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE3C,yBAAyB;IACzB,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,KAAK,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAlBW,QAAA,iBAAiB,qBAkB5B;AAMF,OAAO;AACP,kBAAe,cAAM,CAAC"}
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "cerevox",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for browser automation and secure command execution in highly available and scalable micro computer environments",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "bin": {
13
+ "cerevox-run": "dist/cli/cerevox-run.js"
14
+ },
15
+ "keywords": [
16
+ "e2b",
17
+ "sandbox",
18
+ "automation",
19
+ "command",
20
+ "execution",
21
+ "cloud"
22
+ ],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/liubei-ai/cerevox.git"
28
+ },
29
+ "homepage": "https://github.com/liubei-ai/cerevox.git#readme",
30
+ "bugs": {
31
+ "url": "https://github.com/liubei-ai/cerevox.git/issues"
32
+ },
33
+ "devDependencies": {
34
+ "@e2b/cli": "^1.5.1",
35
+ "@eslint/js": "^9.31.0",
36
+ "@logtail/node": "^0.5.5",
37
+ "@sentry/node": "^9.40.0",
38
+ "@types/express": "^5.0.3",
39
+ "@types/node": "^24.0.3",
40
+ "@types/pino": "^7.0.5",
41
+ "@types/ws": "^8.18.1",
42
+ "eslint": "^9.29.0",
43
+ "eslint-config-prettier": "^10.1.5",
44
+ "eslint-plugin-jest": "^29.0.1",
45
+ "eslint-plugin-prettier": "^5.5.0",
46
+ "express": "^5.1.0",
47
+ "globals": "^16.3.0",
48
+ "http-proxy": "^1.18.1",
49
+ "itty-router": "^5.0.21",
50
+ "pino-pretty": "^13.1.1",
51
+ "playwright": "^1.53.2",
52
+ "playwright-extra": "^4.3.6",
53
+ "prettier": "^3.5.3",
54
+ "puppeteer-extra-plugin-stealth": "^2.11.2",
55
+ "sharp": "^0.34.3",
56
+ "ts-node": "^10.9.2",
57
+ "typescript-eslint": "^8.37.0"
58
+ },
59
+ "dependencies": {
60
+ "@modelcontextprotocol/sdk": "^1.17.0",
61
+ "commander": "^14.0.0",
62
+ "dotenv": "^16.5.0",
63
+ "e2b": "^1.7.1",
64
+ "esbuild": "^0.25.8",
65
+ "open": "^8.4.2",
66
+ "pino": "^9.7.0",
67
+ "playwright-core": "^1.53.2",
68
+ "reflect-metadata": "^0.2.2",
69
+ "typescript": "^5.8.3",
70
+ "uuid": "^11.1.0",
71
+ "ws": "^8.18.3",
72
+ "zod": "^3.25.76"
73
+ },
74
+ "scripts": {
75
+ "build:sdk": "rm -rf ./dist && tsc && chmod +x dist/cli/*.js",
76
+ "build:sandbox": "esbuild sandbox/http-proxy.ts --bundle --platform=node --outfile=sandbox/http-proxy.js --external:sharp --external:playwright-extra --external:puppeteer-extra-plugin-stealth",
77
+ "build": "pnpm build:sdk && pnpm build:sandbox",
78
+ "build:worker": "esbuild worker/worker.ts --bundle --format=esm --outfile=worker/worker.js",
79
+ "dev": "ts-node src/index.ts",
80
+ "lint": "eslint src/**/*.{mjs,ts}",
81
+ "lint:fix": "eslint src/**/*.{mjs,ts} --fix",
82
+ "format": "prettier --write src/**/*.{mjs,ts}",
83
+ "deploy:chromium": "./scripts/deploy-template.sh cerevox-chromium chromium.Dockerfile ./chromium.toml",
84
+ "deploy:chrome": "./scripts/deploy-template.sh cerevox-chrome-stable chrome-stable.Dockerfile ./chrome-stable.toml"
85
+ }
86
+ }