cerevox 0.4.12 → 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/dist/cli/cerevox-run.d.ts.map +1 -1
- package/dist/cli/cerevox-run.js +6 -25
- package/dist/cli/cerevox-run.js.map +1 -1
- package/dist/core/ai.d.ts +0 -1
- package/dist/core/ai.d.ts.map +1 -1
- package/dist/core/ai.js +14 -18
- package/dist/core/ai.js.map +1 -1
- package/dist/core/base.d.ts +1 -3
- package/dist/core/base.d.ts.map +1 -1
- package/dist/core/base.js +1 -2
- package/dist/core/base.js.map +1 -1
- package/dist/core/browser.d.ts +1 -6
- package/dist/core/browser.d.ts.map +1 -1
- package/dist/core/browser.js +34 -50
- package/dist/core/browser.js.map +1 -1
- package/dist/core/cerevox.d.ts +3 -11
- package/dist/core/cerevox.d.ts.map +1 -1
- package/dist/core/cerevox.js +10 -155
- package/dist/core/cerevox.js.map +1 -1
- package/dist/core/code-runner.d.ts +1 -1
- package/dist/core/code-runner.d.ts.map +1 -1
- package/dist/core/code-runner.js +4 -4
- package/dist/core/code-runner.js.map +1 -1
- package/dist/core/file-system.d.ts +12 -33
- package/dist/core/file-system.d.ts.map +1 -1
- package/dist/core/file-system.js +111 -93
- package/dist/core/file-system.js.map +1 -1
- package/dist/core/sandbox.d.ts +20 -0
- package/dist/core/sandbox.d.ts.map +1 -0
- package/dist/core/sandbox.js +120 -0
- package/dist/core/sandbox.js.map +1 -0
- package/dist/core/session.d.ts +5 -8
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +29 -64
- package/dist/core/session.js.map +1 -1
- package/dist/core/terminal.d.ts +6 -5
- package/dist/core/terminal.d.ts.map +1 -1
- package/dist/core/terminal.js +175 -58
- package/dist/core/terminal.js.map +1 -1
- package/dist/core/types.d.ts +23 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/mcp/servers/browser-use.d.ts.map +1 -1
- package/dist/mcp/servers/browser-use.js +3 -7
- package/dist/mcp/servers/browser-use.js.map +1 -1
- package/dist/mcp/servers/zerocut.d.ts.map +1 -1
- package/dist/mcp/servers/zerocut.js +12 -71
- package/dist/mcp/servers/zerocut.js.map +1 -1
- package/package.json +7 -3
- package/dist/utils/auth.d.ts +0 -4
- package/dist/utils/auth.d.ts.map +0 -1
- package/dist/utils/auth.js +0 -14
- package/dist/utils/auth.js.map +0 -1
package/dist/core/session.js
CHANGED
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Session = exports.sessions = void 0;
|
|
16
|
-
const e2b_1 = __importDefault(require("e2b"));
|
|
17
16
|
const base_1 = require("./base");
|
|
18
17
|
const terminal_1 = require("./terminal");
|
|
19
18
|
const code_runner_1 = require("./code-runner");
|
|
@@ -22,27 +21,43 @@ const ws_1 = __importDefault(require("ws"));
|
|
|
22
21
|
const browser_1 = require("./browser");
|
|
23
22
|
const ai_1 = require("./ai");
|
|
24
23
|
const constants_1 = require("../utils/constants");
|
|
24
|
+
const sandbox_1 = require("./sandbox");
|
|
25
25
|
exports.sessions = {};
|
|
26
26
|
let Session = class Session extends base_1.BaseClass {
|
|
27
27
|
constructor(sandbox, options = {}) {
|
|
28
|
-
super(
|
|
29
|
-
this.
|
|
30
|
-
this.connectionMetaData = {};
|
|
28
|
+
super(options.logLevel);
|
|
29
|
+
this.sandbox = sandbox;
|
|
31
30
|
this.ws = null;
|
|
32
|
-
this.isClosed = false;
|
|
33
31
|
this.keepAliveTimer = null;
|
|
32
|
+
this.isClosed = false;
|
|
34
33
|
this.workspace = options.workspace || 'unknown';
|
|
35
|
-
this.terminal = new terminal_1.Terminal(
|
|
36
|
-
this.files = new file_system_1.FileSystem(
|
|
37
|
-
logLevel: options.logLevel,
|
|
38
|
-
});
|
|
34
|
+
this.terminal = new terminal_1.Terminal(this, options);
|
|
35
|
+
this.files = new file_system_1.FileSystem(this);
|
|
39
36
|
this.browser = new browser_1.Browser(this);
|
|
40
37
|
this.ai = new ai_1.AI(this);
|
|
41
38
|
this.codeRunner = new code_runner_1.CodeRunner(this);
|
|
42
39
|
exports.sessions[sandbox.sandboxId] = this;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
async connect() {
|
|
42
|
+
const wsUrl = await this.browser.getCDPEndpoint();
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
this.ws = new ws_1.default(wsUrl);
|
|
45
|
+
this.ws.on('open', () => {
|
|
46
|
+
if (!this.isClosed) {
|
|
47
|
+
this.keepAliveTimer = setTimeout(() => {
|
|
48
|
+
this.keepAlive();
|
|
49
|
+
}, 10000);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.ws.close();
|
|
53
|
+
}
|
|
54
|
+
resolve(this.ws);
|
|
55
|
+
});
|
|
56
|
+
this.ws.on('close', async () => {
|
|
57
|
+
this.logger.debug('WebSocket disconnected');
|
|
58
|
+
clearInterval(this.keepAliveTimer);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
46
61
|
}
|
|
47
62
|
keepAlive() {
|
|
48
63
|
// 因为走的是 cloudflare,还不能用空的 ping/pong
|
|
@@ -58,38 +73,6 @@ let Session = class Session extends base_1.BaseClass {
|
|
|
58
73
|
}, 10000);
|
|
59
74
|
});
|
|
60
75
|
}
|
|
61
|
-
_setConnectionMetaData(metaData) {
|
|
62
|
-
this.connectionMetaData = metaData;
|
|
63
|
-
this.browser._setReady(metaData);
|
|
64
|
-
const wsUrl = this.connectionMetaData.wsUrl;
|
|
65
|
-
this.ws = new ws_1.default(wsUrl);
|
|
66
|
-
this.ws.on('open', () => {
|
|
67
|
-
if (!this.isClosed) {
|
|
68
|
-
this.keepAliveTimer = setTimeout(() => {
|
|
69
|
-
this.keepAlive();
|
|
70
|
-
}, 10000);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.ws.close();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
this.ws.on('close', async () => {
|
|
77
|
-
this.logger.debug('WebSocket disconnected');
|
|
78
|
-
clearInterval(this.keepAliveTimer);
|
|
79
|
-
if (this.process) {
|
|
80
|
-
// 主进程,关掉 sandbox
|
|
81
|
-
try {
|
|
82
|
-
this.process.kill();
|
|
83
|
-
if (await this.sandbox.isRunning()) {
|
|
84
|
-
await this.sandbox.kill();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
/* empty */
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
76
|
async isRunning() {
|
|
94
77
|
return this.sandbox.isRunning();
|
|
95
78
|
}
|
|
@@ -99,19 +82,13 @@ let Session = class Session extends base_1.BaseClass {
|
|
|
99
82
|
getLogger() {
|
|
100
83
|
return this.logger;
|
|
101
84
|
}
|
|
102
|
-
getHost(port = 9223) {
|
|
103
|
-
return this.sandbox
|
|
104
|
-
.getHost(port)
|
|
105
|
-
.replace('sandbox.novita.ai', 'cerevox.io');
|
|
106
|
-
}
|
|
107
85
|
track(event, context) {
|
|
108
86
|
context = {
|
|
109
87
|
...context,
|
|
110
88
|
distinct_id: this.workspace,
|
|
111
89
|
};
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
return fetch(logUrl, {
|
|
90
|
+
const logUrl = `/api/track?event=${event}&context=${encodeURIComponent(JSON.stringify(context))}`;
|
|
91
|
+
return this.sandbox.request(logUrl, {
|
|
115
92
|
method: 'GET',
|
|
116
93
|
headers: {
|
|
117
94
|
'Content-Type': 'application/json',
|
|
@@ -125,18 +102,6 @@ let Session = class Session extends base_1.BaseClass {
|
|
|
125
102
|
if (this.ws?.readyState === ws_1.default.OPEN) {
|
|
126
103
|
this.ws?.close();
|
|
127
104
|
clearInterval(this.keepAliveTimer);
|
|
128
|
-
if (this.process) {
|
|
129
|
-
// 主进程,关掉 sandbox
|
|
130
|
-
try {
|
|
131
|
-
this.process.kill();
|
|
132
|
-
if (await this.sandbox.isRunning()) {
|
|
133
|
-
await this.sandbox.kill();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
/* empty */
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
105
|
}
|
|
141
106
|
this.isClosed = true;
|
|
142
107
|
if (forceToKill) {
|
|
@@ -158,6 +123,6 @@ let Session = class Session extends base_1.BaseClass {
|
|
|
158
123
|
exports.Session = Session;
|
|
159
124
|
exports.Session = Session = __decorate([
|
|
160
125
|
(0, base_1.Logger)({ VERSION: constants_1.VERSION }),
|
|
161
|
-
__metadata("design:paramtypes", [
|
|
126
|
+
__metadata("design:paramtypes", [sandbox_1.Sandbox, Object])
|
|
162
127
|
], Session);
|
|
163
128
|
//# sourceMappingURL=session.js.map
|
package/dist/core/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAA2C;AAC3C,yCAAsC;AACtC,+CAA2C;AAC3C,+CAA2C;AAC3C,4CAA2B;AAC3B,uCAAoC;AACpC,6BAA0B;AAC1B,kDAA6C;AAC7C,uCAAoC;AAEvB,QAAA,QAAQ,GAA4B,EAAE,CAAC;AAG7C,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,gBAAS;IAWpC,YACW,OAAgB,EACzB,UAII,EAAE;QAEN,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAPf,YAAO,GAAP,OAAO,CAAS;QAPnB,OAAE,GAAqB,IAAI,CAAC;QAC5B,mBAAc,GAA0B,IAAI,CAAC;QAE7C,aAAQ,GAAG,KAAK,CAAC;QAY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AC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,KAAK;QAC7B,IAAI,IAAI,CAAC,EAAE,EAAE,UAAU,KAAK,YAAS,CAAC,IAAI,EAAE,CAAC;YAC3C,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC;YACjB,aAAa,CAAC,IAAI,CAAC,cAAe,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM;YACN,8BAA8B;YAC9B,IAAI,CAAC;gBACH,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;oBACnC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBAC5B,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,WAAW;YACb,CAAC;QACH,CAAC;QACD,OAAO,gBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;CACF,CAAA;AArHY,0BAAO;kBAAP,OAAO;IADnB,IAAA,aAAM,EAAC,EAAE,OAAO,EAAP,mBAAO,EAAE,CAAC;qCAaE,iBAAO;GAZhB,OAAO,CAqHnB"}
|
package/dist/core/terminal.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CommandResult } from 'e2b';
|
|
2
2
|
import { BaseClass } from './base';
|
|
3
3
|
import { Readable } from 'node:stream';
|
|
4
|
+
import { Session } from './session';
|
|
4
5
|
/**
|
|
5
6
|
* 流式命令响应接口
|
|
6
7
|
* 提供命令执行的标准输出、错误输出和控制方法
|
|
@@ -57,6 +58,7 @@ type CommandOpts = {
|
|
|
57
58
|
* ```
|
|
58
59
|
*/
|
|
59
60
|
export declare class Terminal extends BaseClass {
|
|
61
|
+
private session;
|
|
60
62
|
/** 当前工作目录 */
|
|
61
63
|
private cwd;
|
|
62
64
|
/** 环境变量 */
|
|
@@ -70,10 +72,9 @@ export declare class Terminal extends BaseClass {
|
|
|
70
72
|
* @param id - 终端唯一标识符
|
|
71
73
|
* @param logLevel - 日志级别
|
|
72
74
|
*/
|
|
73
|
-
constructor(
|
|
75
|
+
constructor(session: Session, options?: {
|
|
74
76
|
envs?: Record<string, string>;
|
|
75
77
|
id?: string;
|
|
76
|
-
logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
77
78
|
});
|
|
78
79
|
/**
|
|
79
80
|
* 获取当前工作目录
|
|
@@ -92,10 +93,10 @@ export declare class Terminal extends BaseClass {
|
|
|
92
93
|
*/
|
|
93
94
|
create(): Terminal;
|
|
94
95
|
/**
|
|
95
|
-
*
|
|
96
|
+
* 通过 API 执行命令
|
|
96
97
|
* @param command - 要执行的命令
|
|
97
98
|
* @param opts - 命令执行选项
|
|
98
|
-
* @returns
|
|
99
|
+
* @returns 命令响应对象
|
|
99
100
|
*/
|
|
100
101
|
run(command: string, opts?: CommandOpts): Promise<StreamableCommandResponse>;
|
|
101
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/core/terminal.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/core/terminal.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC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.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
var Terminal_1;
|
|
15
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
13
|
exports.Terminal = void 0;
|
|
17
|
-
const e2b_1 = __importDefault(require("e2b"));
|
|
18
14
|
const base_1 = require("./base");
|
|
19
15
|
const constants_1 = require("../utils/constants");
|
|
20
16
|
const node_stream_1 = require("node:stream");
|
|
21
17
|
const uuid_1 = require("uuid");
|
|
18
|
+
const session_1 = require("./session");
|
|
22
19
|
/**
|
|
23
20
|
* Terminal 类 - 提供沙箱环境中的终端命令执行功能
|
|
24
21
|
*
|
|
@@ -55,8 +52,9 @@ let Terminal = Terminal_1 = class Terminal extends base_1.BaseClass {
|
|
|
55
52
|
* @param id - 终端唯一标识符
|
|
56
53
|
* @param logLevel - 日志级别
|
|
57
54
|
*/
|
|
58
|
-
constructor(
|
|
59
|
-
super(
|
|
55
|
+
constructor(session, options = {}) {
|
|
56
|
+
super(session.getLogger().level);
|
|
57
|
+
this.session = session;
|
|
60
58
|
/** 当前工作目录 */
|
|
61
59
|
this.cwd = '';
|
|
62
60
|
/** 环境变量 */
|
|
@@ -84,7 +82,7 @@ let Terminal = Terminal_1 = class Terminal extends base_1.BaseClass {
|
|
|
84
82
|
*/
|
|
85
83
|
async updateCwd() {
|
|
86
84
|
try {
|
|
87
|
-
this.cwd = (await this.
|
|
85
|
+
this.cwd = (await this.session.files.read(`/home/user/.pwd.${this.id}`)).trim();
|
|
88
86
|
this.logger.debug('工作目录已更新', { cwd: this.cwd, id: this.id });
|
|
89
87
|
}
|
|
90
88
|
catch (ex) {
|
|
@@ -103,30 +101,24 @@ let Terminal = Terminal_1 = class Terminal extends base_1.BaseClass {
|
|
|
103
101
|
create() {
|
|
104
102
|
const newId = (0, uuid_1.v4)();
|
|
105
103
|
this.logger.debug('创建新的 Terminal 实例', { newId, parentId: this.id });
|
|
106
|
-
return new Terminal_1(this.
|
|
104
|
+
return new Terminal_1(this.session, {
|
|
107
105
|
envs: this.envs,
|
|
108
106
|
id: newId,
|
|
109
|
-
logLevel: this.logger.level,
|
|
110
107
|
});
|
|
111
108
|
}
|
|
112
109
|
/**
|
|
113
|
-
*
|
|
110
|
+
* 通过 API 执行命令
|
|
114
111
|
* @param command - 要执行的命令
|
|
115
112
|
* @param opts - 命令执行选项
|
|
116
|
-
* @returns
|
|
113
|
+
* @returns 命令响应对象
|
|
117
114
|
*/
|
|
118
115
|
async run(command, opts) {
|
|
119
|
-
const envs = {
|
|
120
|
-
...this.envs,
|
|
121
|
-
...opts?.envs,
|
|
122
|
-
};
|
|
123
116
|
try {
|
|
124
|
-
this.logger.debug('
|
|
117
|
+
this.logger.debug('通过 API 执行命令', {
|
|
125
118
|
command,
|
|
126
119
|
terminalId: this.id,
|
|
127
120
|
options: opts,
|
|
128
121
|
});
|
|
129
|
-
command = `${command} && pwd > ~/.pwd.${this.id}`;
|
|
130
122
|
const cwd = await this.getCwd();
|
|
131
123
|
const stdoutStream = new node_stream_1.Readable({
|
|
132
124
|
read() { },
|
|
@@ -134,66 +126,191 @@ let Terminal = Terminal_1 = class Terminal extends base_1.BaseClass {
|
|
|
134
126
|
const stderrStream = new node_stream_1.Readable({
|
|
135
127
|
read() { },
|
|
136
128
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
const res = await this.sandbox.commands.run(command, {
|
|
146
|
-
cwd,
|
|
147
|
-
...opts,
|
|
148
|
-
timeoutMs: opts?.timeoutMs || 0,
|
|
149
|
-
envs,
|
|
150
|
-
background: true,
|
|
151
|
-
onStderr,
|
|
152
|
-
onStdout,
|
|
129
|
+
let commandResult = null;
|
|
130
|
+
let isFinished = false;
|
|
131
|
+
let isKilled = false;
|
|
132
|
+
let finishResolve = null;
|
|
133
|
+
let error = '';
|
|
134
|
+
const finishPromise = new Promise(resolve => {
|
|
135
|
+
finishResolve = resolve;
|
|
153
136
|
});
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
137
|
+
// 用于终止请求的 AbortController
|
|
138
|
+
const abortController = new AbortController();
|
|
139
|
+
// 先发送 POST 请求启动命令
|
|
140
|
+
const response = await this.session.sandbox.request(`/api/terminal/run`, {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: {
|
|
143
|
+
'Content-Type': 'application/json',
|
|
144
|
+
},
|
|
145
|
+
body: JSON.stringify({
|
|
146
|
+
command: `${command} && pwd > ~/.pwd.${this.id}`,
|
|
147
|
+
cwd: opts?.cwd || cwd,
|
|
148
|
+
timeout: opts?.timeoutMs,
|
|
149
|
+
}),
|
|
150
|
+
signal: abortController.signal,
|
|
165
151
|
});
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
154
|
+
}
|
|
155
|
+
// 处理 SSE 流
|
|
156
|
+
if (!response.body) {
|
|
157
|
+
throw new Error('无法获取响应流');
|
|
158
|
+
}
|
|
159
|
+
const processStream = async () => {
|
|
160
|
+
try {
|
|
161
|
+
let buffer = '';
|
|
162
|
+
const reader = response.body.getReader();
|
|
163
|
+
const decoder = new TextDecoder();
|
|
164
|
+
while (true) {
|
|
165
|
+
const { done, value } = await reader.read();
|
|
166
|
+
if (done)
|
|
167
|
+
break;
|
|
168
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
169
|
+
buffer += chunk;
|
|
170
|
+
const messages = buffer.split('\n\n');
|
|
171
|
+
// 保留最后一个消息(可能不完整)
|
|
172
|
+
buffer = messages.pop() || '';
|
|
173
|
+
for (const message of messages) {
|
|
174
|
+
if (!message.trim())
|
|
175
|
+
continue;
|
|
176
|
+
const lines = message.split('\n');
|
|
177
|
+
let eventType = '';
|
|
178
|
+
let eventData = '';
|
|
179
|
+
for (const line of lines) {
|
|
180
|
+
const trimmedLine = line.trim();
|
|
181
|
+
if (trimmedLine.startsWith('event:')) {
|
|
182
|
+
eventType = trimmedLine.substring(6).trim();
|
|
183
|
+
}
|
|
184
|
+
else if (trimmedLine.startsWith('data:')) {
|
|
185
|
+
eventData = trimmedLine.substring(5).trim();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (eventType && eventData) {
|
|
189
|
+
try {
|
|
190
|
+
const data = JSON.parse(eventData);
|
|
191
|
+
switch (eventType) {
|
|
192
|
+
case 'start':
|
|
193
|
+
this.logger.debug('命令开始执行', {
|
|
194
|
+
terminalId: this.id,
|
|
195
|
+
data,
|
|
196
|
+
});
|
|
197
|
+
break;
|
|
198
|
+
case 'stdout':
|
|
199
|
+
stdoutStream.push(data.output);
|
|
200
|
+
break;
|
|
201
|
+
case 'stderr':
|
|
202
|
+
stderrStream.push(data.output);
|
|
203
|
+
break;
|
|
204
|
+
case 'finish':
|
|
205
|
+
commandResult = {
|
|
206
|
+
exitCode: data.exitCode,
|
|
207
|
+
stdout: data.stdout,
|
|
208
|
+
stderr: data.stderr,
|
|
209
|
+
error,
|
|
210
|
+
};
|
|
211
|
+
isFinished = true;
|
|
212
|
+
stdoutStream.push(null);
|
|
213
|
+
stderrStream.push(null);
|
|
214
|
+
if (finishResolve) {
|
|
215
|
+
finishResolve();
|
|
216
|
+
}
|
|
217
|
+
this.logger.debug('命令执行完成', {
|
|
218
|
+
terminalId: this.id,
|
|
219
|
+
exitCode: data.exitCode,
|
|
220
|
+
success: data.success,
|
|
221
|
+
});
|
|
222
|
+
return; // 结束流处理
|
|
223
|
+
case 'timeout':
|
|
224
|
+
this.logger.warn('命令执行超时', {
|
|
225
|
+
terminalId: this.id,
|
|
226
|
+
data,
|
|
227
|
+
});
|
|
228
|
+
error = 'timeout';
|
|
229
|
+
break;
|
|
230
|
+
case 'error':
|
|
231
|
+
this.logger.error('命令执行错误', {
|
|
232
|
+
terminalId: this.id,
|
|
233
|
+
error: data.error,
|
|
234
|
+
});
|
|
235
|
+
error = data.error;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (parseError) {
|
|
240
|
+
this.logger.error('解析 SSE 数据失败', {
|
|
241
|
+
terminalId: this.id,
|
|
242
|
+
error: parseError,
|
|
243
|
+
rawData: eventData,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// 流结束处理
|
|
250
|
+
if (!isFinished && !isKilled) {
|
|
251
|
+
stdoutStream.push(null);
|
|
252
|
+
stderrStream.push(null);
|
|
253
|
+
if (finishResolve) {
|
|
254
|
+
finishResolve();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (!isKilled) {
|
|
260
|
+
this.logger.error('SSE 流处理错误', {
|
|
261
|
+
terminalId: this.id,
|
|
262
|
+
error,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
if (!isFinished && !isKilled) {
|
|
266
|
+
stdoutStream.push(null);
|
|
267
|
+
stderrStream.push(null);
|
|
268
|
+
if (finishResolve) {
|
|
269
|
+
finishResolve();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
// 开始处理流
|
|
275
|
+
processStream();
|
|
166
276
|
return {
|
|
167
277
|
stdout: stdoutStream,
|
|
168
278
|
stderr: stderrStream,
|
|
169
279
|
end: async () => {
|
|
170
280
|
this.logger.debug('等待命令完成', { terminalId: this.id });
|
|
171
|
-
await
|
|
281
|
+
await finishPromise;
|
|
172
282
|
await this.updateCwd();
|
|
173
283
|
this.logger.debug('命令执行完成', { terminalId: this.id });
|
|
174
284
|
},
|
|
285
|
+
kill: async () => {
|
|
286
|
+
this.logger.debug('终止命令执行', { terminalId: this.id });
|
|
287
|
+
isKilled = true;
|
|
288
|
+
abortController.abort();
|
|
289
|
+
stdoutStream.push(null);
|
|
290
|
+
stderrStream.push(null);
|
|
291
|
+
if (finishResolve) {
|
|
292
|
+
finishResolve();
|
|
293
|
+
}
|
|
294
|
+
this.logger.debug('命令已被终止', { terminalId: this.id });
|
|
295
|
+
},
|
|
175
296
|
json: async () => {
|
|
176
297
|
this.logger.debug('获取命令执行结果', { terminalId: this.id });
|
|
177
|
-
|
|
298
|
+
await finishPromise;
|
|
178
299
|
await this.updateCwd();
|
|
300
|
+
if (!commandResult) {
|
|
301
|
+
throw new Error('命令执行结果不可用');
|
|
302
|
+
}
|
|
179
303
|
this.logger.debug('命令执行结果', {
|
|
180
304
|
terminalId: this.id,
|
|
181
|
-
exitCode:
|
|
182
|
-
success:
|
|
305
|
+
exitCode: commandResult.exitCode,
|
|
306
|
+
success: commandResult.exitCode === 0,
|
|
183
307
|
});
|
|
184
|
-
return
|
|
185
|
-
},
|
|
186
|
-
kill: async () => {
|
|
187
|
-
this.logger.debug('终止命令执行', { terminalId: this.id });
|
|
188
|
-
await res.kill().catch(ex => ex.result);
|
|
189
|
-
stdoutStream.push(null);
|
|
190
|
-
stderrStream.push(null);
|
|
191
|
-
this.logger.debug('命令已被终止', { terminalId: this.id });
|
|
308
|
+
return commandResult;
|
|
192
309
|
},
|
|
193
310
|
};
|
|
194
311
|
}
|
|
195
312
|
catch (ex) {
|
|
196
|
-
this.logger.error('
|
|
313
|
+
this.logger.error('exec 方法执行失败', {
|
|
197
314
|
command,
|
|
198
315
|
terminalId: this.id,
|
|
199
316
|
error: ex,
|
|
@@ -205,6 +322,6 @@ let Terminal = Terminal_1 = class Terminal extends base_1.BaseClass {
|
|
|
205
322
|
exports.Terminal = Terminal;
|
|
206
323
|
exports.Terminal = Terminal = Terminal_1 = __decorate([
|
|
207
324
|
(0, base_1.Logger)({ VERSION: constants_1.VERSION }),
|
|
208
|
-
__metadata("design:paramtypes", [
|
|
325
|
+
__metadata("design:paramtypes", [session_1.Session, Object])
|
|
209
326
|
], Terminal);
|
|
210
327
|
//# sourceMappingURL=terminal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../src/core/terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../src/core/terminal.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,iCAA2C;AAC3C,kDAA6C;AAC7C,6CAAuC;AACvC,+BAAoC;AACpC,uCAAoC;AA8BpC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEI,IAAM,QAAQ,gBAAd,MAAM,QAAS,SAAQ,gBAAS;IAQrC;;;;;;OAMG;IACH,YACU,OAAgB,EACxB,UAGI,EAAE;QAEN,KAAK,CACH,OAAO,CAAC,SAAS,EAAE,CAAC,KAAsD,CAC3E,CAAC;QARM,YAAO,GAAP,OAAO,CAAS;QAf1B,aAAa;QACL,QAAG,GAAW,EAAE,CAAC;QACzB,WAAW;QACH,SAAI,GAA2B,EAAE,CAAC;QAqBxC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,UAAU,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAClC,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM;SACxC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,GAAG,GAAG,I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I,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvD,CAAC;gBACD,IAAI,EAAE,KAAK,IAAI,EAAE;oBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;oBACvD,MAAM,aAAa,CAAC;oBACpB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;oBAEvB,IAAI,CAAC,aAAa,EAAE,CAAC;wBACnB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;oBAC/B,CAAC;oBAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE;wBAC1B,UAAU,EAAE,IAAI,CAAC,EAAE;wBACnB,QAAQ,EAAE,aAAa,CAAC,QAAQ;wBAChC,OAAO,EAAE,aAAa,CAAC,QAAQ,KAAK,CAAC;qBACtC,CAAC,CAAC;oBAEH,OAAO,aAAa,CAAC;gBACvB,CAAC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE;gBAC/B,OAAO;gBACP,UAAU,EAAE,IAAI,CAAC,EAAE;gBACnB,KAAK,EAAE,EAAE;aACV,CAAC,CAAC;YACH,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;CACF,CAAA;AA1TY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,aAAM,EAAC,EAAE,OAAO,EAAP,mBAAO,EAAE,CAAC;qCAiBC,iBAAO;GAhBf,QAAQ,CA0TpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command execution result.
|
|
3
|
+
*/
|
|
4
|
+
export interface CommandResult {
|
|
5
|
+
/**
|
|
6
|
+
* Command execution exit code.
|
|
7
|
+
* `0` if the command finished successfully.
|
|
8
|
+
*/
|
|
9
|
+
exitCode: number;
|
|
10
|
+
/**
|
|
11
|
+
* Error message from command execution if it failed.
|
|
12
|
+
*/
|
|
13
|
+
error?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Command stdout output.
|
|
16
|
+
*/
|
|
17
|
+
stdout: string;
|
|
18
|
+
/**
|
|
19
|
+
* Command stderr output.
|
|
20
|
+
*/
|
|
21
|
+
stderr: string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-use.d.ts","sourceRoot":"","sources":["../../../src/mcp/servers/browser-use.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"browser-use.d.ts","sourceRoot":"","sources":["../../../src/mcp/servers/browser-use.ts"],"names":[],"mappings":";AA+aA,wBAAsB,GAAG,kBAKxB"}
|