@qqbrowser/qbot-claw-launcher 0.9.32

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 (90) hide show
  1. package/README.md +1 -0
  2. package/debug.html +440 -0
  3. package/dist/config.d.ts +15 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/config.js +23 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +128 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/installer.d.ts +20 -0
  12. package/dist/installer.d.ts.map +1 -0
  13. package/dist/installer.js +335 -0
  14. package/dist/installer.js.map +1 -0
  15. package/dist/quarantine.d.ts +37 -0
  16. package/dist/quarantine.d.ts.map +1 -0
  17. package/dist/quarantine.js +315 -0
  18. package/dist/quarantine.js.map +1 -0
  19. package/dist/reportLog.d.ts +28 -0
  20. package/dist/reportLog.d.ts.map +1 -0
  21. package/dist/reportLog.js +262 -0
  22. package/dist/reportLog.js.map +1 -0
  23. package/dist/server.d.ts +4 -0
  24. package/dist/server.d.ts.map +1 -0
  25. package/dist/server.js +425 -0
  26. package/dist/server.js.map +1 -0
  27. package/dist/service.d.ts +11 -0
  28. package/dist/service.d.ts.map +1 -0
  29. package/dist/service.js +197 -0
  30. package/dist/service.js.map +1 -0
  31. package/dist/state.d.ts +21 -0
  32. package/dist/state.d.ts.map +1 -0
  33. package/dist/state.js +62 -0
  34. package/dist/state.js.map +1 -0
  35. package/dist/utils.d.ts +25 -0
  36. package/dist/utils.d.ts.map +1 -0
  37. package/dist/utils.js +101 -0
  38. package/dist/utils.js.map +1 -0
  39. package/node_modules/@parcel/watcher/LICENSE +21 -0
  40. package/node_modules/@parcel/watcher/README.md +136 -0
  41. package/node_modules/@parcel/watcher/index.d.ts +49 -0
  42. package/node_modules/@parcel/watcher/index.js +42 -0
  43. package/node_modules/@parcel/watcher/index.js.flow +48 -0
  44. package/node_modules/@parcel/watcher/node_modules/picomatch/LICENSE +21 -0
  45. package/node_modules/@parcel/watcher/node_modules/picomatch/README.md +738 -0
  46. package/node_modules/@parcel/watcher/node_modules/picomatch/index.js +17 -0
  47. package/node_modules/@parcel/watcher/node_modules/picomatch/lib/constants.js +180 -0
  48. package/node_modules/@parcel/watcher/node_modules/picomatch/lib/parse.js +1085 -0
  49. package/node_modules/@parcel/watcher/node_modules/picomatch/lib/picomatch.js +341 -0
  50. package/node_modules/@parcel/watcher/node_modules/picomatch/lib/scan.js +391 -0
  51. package/node_modules/@parcel/watcher/node_modules/picomatch/lib/utils.js +72 -0
  52. package/node_modules/@parcel/watcher/node_modules/picomatch/package.json +83 -0
  53. package/node_modules/@parcel/watcher/node_modules/picomatch/posix.js +3 -0
  54. package/node_modules/@parcel/watcher/package.json +39 -0
  55. package/node_modules/@parcel/watcher/wrapper.js +74 -0
  56. package/node_modules/@parcel/watcher-darwin-arm64/LICENSE +21 -0
  57. package/node_modules/@parcel/watcher-darwin-arm64/README.md +1 -0
  58. package/node_modules/@parcel/watcher-darwin-arm64/package.json +30 -0
  59. package/node_modules/@parcel/watcher-darwin-arm64/watcher.node +0 -0
  60. package/node_modules/fs-xattr/LICENSE +21 -0
  61. package/node_modules/fs-xattr/build/Makefile +347 -0
  62. package/node_modules/fs-xattr/build/Release/.deps/Release/obj.target/xattr/src/async.o.d +15 -0
  63. package/node_modules/fs-xattr/build/Release/.deps/Release/obj.target/xattr/src/error.o.d +12 -0
  64. package/node_modules/fs-xattr/build/Release/.deps/Release/obj.target/xattr/src/sync.o.d +15 -0
  65. package/node_modules/fs-xattr/build/Release/.deps/Release/obj.target/xattr/src/util.o.d +12 -0
  66. package/node_modules/fs-xattr/build/Release/.deps/Release/obj.target/xattr/src/xattr.o.d +14 -0
  67. package/node_modules/fs-xattr/build/Release/.deps/Release/xattr.node.d +1 -0
  68. package/node_modules/fs-xattr/build/Release/obj.target/xattr/src/async.o +0 -0
  69. package/node_modules/fs-xattr/build/Release/obj.target/xattr/src/error.o +0 -0
  70. package/node_modules/fs-xattr/build/Release/obj.target/xattr/src/sync.o +0 -0
  71. package/node_modules/fs-xattr/build/Release/obj.target/xattr/src/util.o +0 -0
  72. package/node_modules/fs-xattr/build/Release/obj.target/xattr/src/xattr.o +0 -0
  73. package/node_modules/fs-xattr/build/Release/xattr.node +0 -0
  74. package/node_modules/fs-xattr/build/binding.Makefile +6 -0
  75. package/node_modules/fs-xattr/build/config.gypi +530 -0
  76. package/node_modules/fs-xattr/build/gyp-mac-tool +772 -0
  77. package/node_modules/fs-xattr/build/xattr.target.mk +185 -0
  78. package/node_modules/fs-xattr/index.d.ts +47 -0
  79. package/node_modules/fs-xattr/index.js +80 -0
  80. package/node_modules/fs-xattr/package.json +29 -0
  81. package/node_modules/fs-xattr/readme.md +101 -0
  82. package/node_modules/is-extglob/LICENSE +21 -0
  83. package/node_modules/is-extglob/README.md +107 -0
  84. package/node_modules/is-extglob/index.js +20 -0
  85. package/node_modules/is-extglob/package.json +69 -0
  86. package/node_modules/is-glob/LICENSE +21 -0
  87. package/node_modules/is-glob/README.md +206 -0
  88. package/node_modules/is-glob/index.js +150 -0
  89. package/node_modules/is-glob/package.json +81 -0
  90. package/package.json +45 -0
@@ -0,0 +1,335 @@
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.PYTHON_DIR = exports.installState = void 0;
7
+ exports.runQBotClaw = runQBotClaw;
8
+ exports.configAndRunQBotClaw = configAndRunQBotClaw;
9
+ exports.runInstall = runInstall;
10
+ const fs_1 = __importDefault(require("fs"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const child_process_1 = require("child_process");
13
+ const config_1 = require("./config");
14
+ const utils_1 = require("./utils");
15
+ const state_1 = require("./state");
16
+ const quarantine_1 = require("./quarantine");
17
+ const reportLog_1 = require("./reportLog");
18
+ function sendProgress(res, totalSteps, currentStep, message) {
19
+ if (res && res.writable) {
20
+ const progress = totalSteps > 0 ? Math.round((currentStep / totalSteps) * 10000) / 100 : 0;
21
+ try {
22
+ res.write(JSON.stringify({ status: 'downloading', progress, totalSteps, currentStep, message }) + '\n');
23
+ }
24
+ catch { }
25
+ }
26
+ }
27
+ exports.installState = { status: 'idle', message: '未开始' };
28
+ exports.PYTHON_DIR = path_1.default.join(config_1.QBOT_CLAW_DIR, 'python');
29
+ /**
30
+ * 执行 QBotClaw 命令
31
+ */
32
+ function runQBotClaw(args, res) {
33
+ return new Promise((resolve) => {
34
+ const child = (0, child_process_1.spawn)(config_1.QBOTCLAW_BIN, args, {
35
+ stdio: ['ignore', 'pipe', 'pipe'],
36
+ env: {
37
+ PATH: config_1.NODE_BIN_DIR,
38
+ HOME: process.env.HOME,
39
+ OPENCLAW_TELEMETRY_GALIELO_GUID: process.env.QB_GUID || '',
40
+ OPENCLAW_TELEMETRY_GALIELO_QIEMI36: process.env.QB_QIMEI36 || '',
41
+ },
42
+ });
43
+ (0, reportLog_1.log)(`[QBotClaw] 执行: QBotClaw ${args.join(' ')}`);
44
+ child.stdout.on('data', (chunk) => {
45
+ const text = chunk.toString();
46
+ process.stdout.write(`[QBotClaw] ${text}`);
47
+ if (res && res.writable) {
48
+ try {
49
+ res.write(text);
50
+ }
51
+ catch {
52
+ }
53
+ }
54
+ });
55
+ child.stderr.on('data', (chunk) => {
56
+ const text = chunk.toString();
57
+ process.stderr.write(`[QBotClaw] ${text}`);
58
+ if (res && res.writable) {
59
+ try {
60
+ res.write(text);
61
+ }
62
+ catch {
63
+ }
64
+ }
65
+ });
66
+ child.on('close', (code) => {
67
+ (0, reportLog_1.log)(`[QBotClaw] 执行完成,退出码: ${code}`);
68
+ resolve();
69
+ });
70
+ child.on('error', (err) => {
71
+ (0, reportLog_1.log)(`[QBotClaw] 启动失败: ${err.message}`);
72
+ resolve();
73
+ });
74
+ });
75
+ }
76
+ /** 步骤 1:确保 ~/.qbot-claw 目录存在 */
77
+ function ensureClawDir() {
78
+ if (!fs_1.default.existsSync(config_1.QBOT_CLAW_DIR)) {
79
+ fs_1.default.mkdirSync(config_1.QBOT_CLAW_DIR, { recursive: true });
80
+ }
81
+ }
82
+ /** 写入 pip.conf 配置文件(不存在时写入) */
83
+ function ensurePipConf() {
84
+ const pipConfPath = path_1.default.join(exports.PYTHON_DIR, 'pip.conf');
85
+ if (fs_1.default.existsSync(pipConfPath)) {
86
+ (0, reportLog_1.log)(`pip.conf 已存在,跳过`);
87
+ return;
88
+ }
89
+ const pipConf = [
90
+ '[global]',
91
+ 'index-url = https://mirrors.tencent.com/pypi/simple/',
92
+ `cache-dir = ${path_1.default.join(exports.PYTHON_DIR, '.pip-cache')}`,
93
+ '',
94
+ '[install]',
95
+ `prefix = ${exports.PYTHON_DIR}`,
96
+ '',
97
+ ].join('\n');
98
+ fs_1.default.writeFileSync(pipConfPath, pipConf, 'utf-8');
99
+ (0, reportLog_1.log)(`已写入 pip.conf: ${pipConfPath}`);
100
+ }
101
+ /** 全局安装 mcporter(已安装则跳过) */
102
+ async function installMcporter(res) {
103
+ if (fs_1.default.existsSync(config_1.MCPORTER_BIN)) {
104
+ (0, reportLog_1.log)(`mcporter 已安装,跳过`);
105
+ return;
106
+ }
107
+ (0, reportLog_1.log)(`开始安装 mcporter...`);
108
+ await new Promise((resolve, reject) => {
109
+ const child = (0, child_process_1.spawn)(config_1.NPM_BIN, ['--userconfig', config_1.NPM_RC, 'install', '-g', 'mcporter'], {
110
+ stdio: ['ignore', 'pipe', 'pipe'],
111
+ env: { ...process.env, PATH: `${path_1.default.dirname(config_1.NPM_BIN)}:${process.env.PATH}` },
112
+ });
113
+ child.stdout.on('data', (chunk) => {
114
+ const msg = `[mcporter] ${chunk.toString().trim()}`;
115
+ (0, reportLog_1.log)(msg);
116
+ sendProgress(res, 0, 0, msg);
117
+ });
118
+ child.stderr.on('data', (chunk) => {
119
+ const msg = `[mcporter] ${chunk.toString().trim()}`;
120
+ (0, reportLog_1.log)(msg);
121
+ sendProgress(res, 0, 0, msg);
122
+ });
123
+ child.on('close', (code) => {
124
+ if (code === 0) {
125
+ (0, reportLog_1.log)(`mcporter 安装成功`);
126
+ resolve();
127
+ }
128
+ else {
129
+ reject(new Error(`mcporter 安装失败,退出码: ${code}`));
130
+ }
131
+ });
132
+ child.on('error', reject);
133
+ });
134
+ }
135
+ /** 执行 npm 命令的通用辅助函数 */
136
+ function runNpmCommand(args, label) {
137
+ return new Promise((resolve, reject) => {
138
+ const child = (0, child_process_1.spawn)(config_1.NPM_BIN, ['--userconfig', config_1.NPM_RC, ...args], {
139
+ stdio: ['ignore', 'pipe', 'pipe'],
140
+ env: { ...process.env, PATH: `${path_1.default.dirname(config_1.NPM_BIN)}:${process.env.PATH}` },
141
+ });
142
+ child.stdout.on('data', (chunk) => {
143
+ const msg = `[npm] ${chunk.toString().trim()}`;
144
+ (0, reportLog_1.log)(msg);
145
+ });
146
+ child.stderr.on('data', (chunk) => {
147
+ const msg = `[npm] ${chunk.toString().trim()}`;
148
+ (0, reportLog_1.log)(msg);
149
+ });
150
+ child.on('close', (code) => {
151
+ if (code === 0) {
152
+ (0, reportLog_1.log)(`${label} 成功`);
153
+ resolve();
154
+ }
155
+ else {
156
+ reject(new Error(`${label} 失败,退出码: ${code}`));
157
+ }
158
+ });
159
+ child.on('error', reject);
160
+ });
161
+ }
162
+ /**
163
+ * 使用 npm install -g --ignore-scripts 下载解压 QBotClaw(不执行 postinstall 脚本)
164
+ *
165
+ * 为什么跳过脚本:
166
+ * npm install 过程中,FSEvents 可能丢弃事件导致 watcher 遗漏文件。
167
+ * 如果 postinstall 脚本(如 node-llama-cpp)在 install 过程中 dlopen 这些文件,
168
+ * 会被 macOS Gatekeeper 拦截。拆分步骤后,可以在 dlopen 之前 100% 确保
169
+ * 所有 native 二进制文件的隔离属性已被清除。
170
+ */
171
+ async function npmDownloadQBotClaw(version) {
172
+ const packageSpec = `${config_1.NPM_PACKAGE_NAME}@${version}`;
173
+ (0, reportLog_1.log)(`开始安装 ${packageSpec}(--ignore-scripts,仅下载解压)...`);
174
+ await runNpmCommand(['install', '-g', '--ignore-scripts', packageSpec], `${packageSpec} 下载解压`);
175
+ }
176
+ /**
177
+ * 执行 npm rebuild,触发所有 postinstall 脚本
178
+ *
179
+ * 调用前应确保已完成隔离属性清除,使所有 dylib/node 文件在 rebuild 时已安全。
180
+ */
181
+ async function npmRebuildQBotClaw(version) {
182
+ const packageSpec = `${config_1.NPM_PACKAGE_NAME}@${version}`;
183
+ (0, reportLog_1.log)(`开始 npm rebuild(执行 postinstall 脚本)...`);
184
+ await runNpmCommand(['rebuild', '-g', config_1.NPM_PACKAGE_NAME], `${packageSpec} rebuild`);
185
+ (0, reportLog_1.log)(`${packageSpec} 安装成功`);
186
+ }
187
+ /** 读取 npm 全局安装目录中的 preset-config.json,修改 gateway.port,然后覆盖写入到 QBOT_CLAW_CONFIG_PATH */
188
+ async function copyPresetConfig(gatewayPort, mcpHttpPort, mcpWsPort) {
189
+ // 配置来源路径:优先使用现有配置文件,若不存在则从 npm 全局 node_modules 中读取
190
+ const npmPresetPath = path_1.default.join(config_1.NPM_GLOBAL_MODULES, config_1.NPM_PACKAGE_NAME, 'preset-config.json');
191
+ let configPath;
192
+ if (fs_1.default.existsSync(config_1.QBOT_CLAW_CONFIG_PATH)) {
193
+ configPath = config_1.QBOT_CLAW_CONFIG_PATH;
194
+ (0, reportLog_1.log)(`使用现有配置文件: ${configPath}`);
195
+ }
196
+ else if (fs_1.default.existsSync(npmPresetPath)) {
197
+ configPath = npmPresetPath;
198
+ (0, reportLog_1.log)(`现有配置文件不存在,使用 npm 全局安装目录中的配置: ${configPath}`);
199
+ }
200
+ else {
201
+ (0, reportLog_1.log)(`配置文件不存在,跳过配置写入: ${config_1.QBOT_CLAW_CONFIG_PATH}`);
202
+ return;
203
+ }
204
+ // 读取配置
205
+ let config;
206
+ try {
207
+ config = JSON.parse(fs_1.default.readFileSync(configPath, 'utf-8'));
208
+ (0, reportLog_1.log)(`已读取配置: ${configPath}`);
209
+ }
210
+ catch (err) {
211
+ (0, reportLog_1.log)(`读取配置失败: ${configPath},${err.message},跳过配置写入`);
212
+ return;
213
+ }
214
+ // 修改 gateway.port 并写入
215
+ if (gatewayPort !== undefined) {
216
+ config.gateway = { ...(config.gateway ?? {}), port: gatewayPort };
217
+ (0, reportLog_1.log)(`已将 gateway.port=${gatewayPort} 写入配置`);
218
+ }
219
+ // 修改 plugins.entries.x5use-browser-control.config 中的端口
220
+ config.plugins = config.plugins ?? {};
221
+ config.plugins.entries = config.plugins.entries ?? {};
222
+ config.plugins.entries['x5use-browser-control'] = config.plugins.entries['x5use-browser-control'] ?? {};
223
+ config.plugins.entries['x5use-browser-control'].config = {
224
+ ...(config.plugins.entries['x5use-browser-control'].config ?? {}),
225
+ wsPort: mcpWsPort,
226
+ httpPort: mcpHttpPort,
227
+ };
228
+ (0, reportLog_1.log)(`已将 x5use-browser-control wsPort=${mcpWsPort}, httpPort=${mcpHttpPort} 写入配置`);
229
+ fs_1.default.writeFileSync(config_1.QBOT_CLAW_CONFIG_PATH, JSON.stringify(config, null, 2), 'utf-8');
230
+ (0, reportLog_1.log)(`配置文件已写入: ${config_1.QBOT_CLAW_CONFIG_PATH}`);
231
+ }
232
+ /** 步骤 12:配置并启动 QBotClaw gateway */
233
+ async function configAndRunQBotClaw() {
234
+ // 如果已有 gateway 在某个端口运行(端口不可用),则复用原端口;否则寻找新端口
235
+ const state = (0, state_1.readState)();
236
+ let gatewayPort;
237
+ if (state.gatewayPort && !(await (0, state_1.isPortAvailable)(state.gatewayPort))) {
238
+ gatewayPort = state.gatewayPort;
239
+ (0, reportLog_1.log)(`检测到 QBotClaw gateway 已在端口 ${gatewayPort} 运行,复用原端口`);
240
+ }
241
+ else {
242
+ gatewayPort = await (0, utils_1.findAvailablePort)();
243
+ }
244
+ (0, reportLog_1.log)(`后台启动 QBotClaw gateway run --port ${gatewayPort} --force`);
245
+ const mcpHttpPort = await (0, utils_1.findAvailablePort)();
246
+ const mcpWsPort = await (0, utils_1.findAvailablePort)();
247
+ // 读取 preset-config.json,修改 gateway.port,覆盖写入配置文件
248
+ await copyPresetConfig(gatewayPort, mcpHttpPort, mcpWsPort);
249
+ const child = (0, child_process_1.spawn)(config_1.QBOTCLAW_BIN, ['gateway', 'run', '--port', String(gatewayPort), '--force'], {
250
+ stdio: 'ignore',
251
+ env: {
252
+ PATH: config_1.NODE_BIN_DIR,
253
+ HOME: process.env.HOME,
254
+ OPENCLAW_TELEMETRY_GALIELO_GUID: process.env.QB_GUID || '',
255
+ OPENCLAW_TELEMETRY_GALIELO_QIEMI36: process.env.QB_QIMEI36 || '',
256
+ },
257
+ });
258
+ child.unref();
259
+ const gatewayPid = child.pid;
260
+ (0, reportLog_1.log)(`QBotClaw gateway 已在后台启动,PID: ${gatewayPid},端口: ${gatewayPort}`);
261
+ // 将 gateway 进程信息写入 launcher.json
262
+ (0, state_1.writeState)({ ...(0, state_1.readState)(), gatewayPid, gatewayPort, mcpHttpPort, mcpWsPort });
263
+ }
264
+ // ─── 主安装入口 ───────────────────────────────────────────────────────────────
265
+ /**
266
+ * 执行安装流程(异步,日志实时写入 res)
267
+ */
268
+ function runInstall(res, version) {
269
+ exports.installState = { status: 'downloading', message: '正在安装...', startTime: new Date().toISOString() };
270
+ (0, reportLog_1.log)(`开始安装 ${config_1.NPM_PACKAGE_NAME}@${version}`);
271
+ (async () => {
272
+ try {
273
+ // 1. 确保目录存在
274
+ ensureClawDir();
275
+ // 写入 pip.conf 配置文件
276
+ ensurePipConf();
277
+ // 安装开始时启动 workspace 监控,自动清除新文件的 Gatekeeper 隔离属性
278
+ await (0, quarantine_1.watchWorkspaceQuarantine)().catch((err) => {
279
+ (0, reportLog_1.log)(`[quarantine] watchWorkspaceQuarantine 启动异常: ${err.message}`);
280
+ });
281
+ // 耗时步骤总数:installMcporter, npmDownloadQBotClaw, fullScanClearQuarantine, npmRebuildQBotClaw, configAndRunQBotClaw
282
+ const totalSteps = 5;
283
+ let currentStep = 0;
284
+ // 2. 全局安装 mcporter(已安装则跳过)
285
+ sendProgress(res, totalSteps, currentStep, `开始安装 mcporter...`);
286
+ await installMcporter(res);
287
+ currentStep++;
288
+ // 3. 下载解压 QBotClaw(--ignore-scripts,不执行 postinstall 脚本)
289
+ sendProgress(res, totalSteps, currentStep, `开始下载解压 QBotClaw...`);
290
+ await npmDownloadQBotClaw(version);
291
+ currentStep++;
292
+ sendProgress(res, totalSteps, currentStep, `npmDownloadQBotClaw 完成`);
293
+ // 4. 全量扫描清除隔离属性(确保所有 dylib/node/可执行文件在 rebuild 前已安全)
294
+ await (0, quarantine_1.fullScanClearQuarantine)('npm install --ignore-scripts 完成后,rebuild 前');
295
+ currentStep++;
296
+ // 5. 执行 npm rebuild,触发所有 postinstall 脚本
297
+ sendProgress(res, totalSteps, currentStep, `开始 npm rebuild...`);
298
+ await npmRebuildQBotClaw(version);
299
+ currentStep++;
300
+ sendProgress(res, totalSteps, currentStep, `npmRebuildQBotClaw 完成`);
301
+ // 安装结束,停止 workspace 监控
302
+ await (0, quarantine_1.stopWatchWorkspaceQuarantine)().catch((err) => {
303
+ (0, reportLog_1.log)(`[quarantine] stopWatchWorkspaceQuarantine 异常: ${err.message}`);
304
+ });
305
+ exports.installState = { status: 'success', message: '安装成功', endTime: new Date().toISOString() };
306
+ (0, reportLog_1.log)(`安装成功`);
307
+ (0, reportLog_1.refreshClawVersion)(version);
308
+ // 6. 配置并启动 QBotClaw gateway
309
+ sendProgress(res, totalSteps, currentStep, `开始配置并启动 QBotClaw gateway...`);
310
+ await configAndRunQBotClaw();
311
+ currentStep++;
312
+ if (res.writable) {
313
+ try {
314
+ res.end(JSON.stringify({ status: 'done', progress: 100, message: '安装成功' }) + '\n');
315
+ }
316
+ catch {
317
+ }
318
+ }
319
+ }
320
+ catch (err) {
321
+ // 安装失败时也要停止监控
322
+ await (0, quarantine_1.stopWatchWorkspaceQuarantine)().catch(() => { });
323
+ exports.installState = { status: 'failed', message: err.message, endTime: new Date().toISOString() };
324
+ (0, reportLog_1.log)(`安装失败: ${err.message}`);
325
+ if (res && res.writable) {
326
+ try {
327
+ res.end(JSON.stringify({ status: 'failed', progress: 0, message: err.message }) + '\n');
328
+ }
329
+ catch {
330
+ }
331
+ }
332
+ }
333
+ })();
334
+ }
335
+ //# sourceMappingURL=installer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installer.js","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":";;;;;;AAyCA,kCA8CC;AAyKD,oDAkCC;AAOD,gCA2EC;AAnXD,4CAAoB;AACpB,gDAAwB;AACxB,iDAAoC;AACpC,qCAUkB;AAClB,mCAA0C;AAC1C,mCAA+D;AAC/D,6CAA6G;AAC7G,2CAAoD;AAGpD,SAAS,YAAY,CAAC,GAAwB,EAAE,UAAkB,EAAE,WAAmB,EAAE,OAAe;IACtG,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,IAAI,CAAC;YAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IAC3H,CAAC;AACH,CAAC;AASU,QAAA,YAAY,GAAiB,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;AAC5D,QAAA,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,sBAAa,EAAE,QAAQ,CAAC,CAAC;AAE7D;;GAEG;AACH,SAAgB,WAAW,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C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBACxF,CAAC;gBAAC,MAAM,CAAC;gBACT,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 全量递归扫描目录,对所有匹配白名单的文件清除 quarantine 属性。
3
+ *
4
+ * 设计目标:作为 watcher 的补偿机制。当 FSEvents 丢弃事件时,
5
+ * 通过全量扫描确保不会遗漏任何需要处理的文件。
6
+ *
7
+ * 性能(基于 benchmark):
8
+ * - 遍历 ~60000 文件 + 过滤 ~3400 匹配文件 + 逐个 removeAttribute ≈ 300ms
9
+ * - 对用户无感知,可安全地在 npm install 过程中触发
10
+ *
11
+ * @param reason 触发原因,用于日志记录
12
+ */
13
+ export declare function fullScanClearQuarantine(reason: string): Promise<void>;
14
+ /**
15
+ * 停止监听 QBOT_CLAW_DIR 目录,取消 quarantine 属性清除的 watcher。
16
+ */
17
+ export declare function stopWatchWorkspaceQuarantine(): Promise<void>;
18
+ /**
19
+ * 监听 QBOT_CLAW_DIR 目录,自动清除新文件的 Gatekeeper 隔离属性。
20
+ *
21
+ * 核心设计:使用 @parcel/watcher(底层直接调用 FSEvents C API)。
22
+ * 相比 Node.js 原生 fs.watch,@parcel/watcher 的事件投递延迟低至 ~10ms,
23
+ * 可以在 npm postinstall 脚本启动二进制文件之前完成 quarantine 属性清除。
24
+ *
25
+ * 优势:
26
+ * - 超低延迟(~10ms vs fs.watch 的数秒延迟)
27
+ * - 精确事件类型(create/update/delete),无需猜测 rename 语义
28
+ * - 原生支持 glob ignore 模式,在 C++ 层过滤无关事件
29
+ * - 整棵目录树只需要 1 个文件描述符
30
+ *
31
+ * 策略:
32
+ * - 只处理 create 事件(文件新增),忽略 update/delete
33
+ * - 通过路径黑名单排除无关目录(纯字符串匹配,零 IO)
34
+ * - 通过扩展名白名单过滤需要处理的文件(.dylib, .so, .node, 无扩展名)
35
+ */
36
+ export declare function watchWorkspaceQuarantine(): Promise<void>;
37
+ //# sourceMappingURL=quarantine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quarantine.d.ts","sourceRoot":"","sources":["../src/quarantine.ts"],"names":[],"mappings":"AAuHA;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD3E;AAiBD;;GAEG;AACH,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC,CAMlE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4D9D"}