@qqbrowser/qbot-claw-launcher 0.9.69 → 0.9.71

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/installer.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var A=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PYTHON_DIR=exports.isInstalling=exports.installState=void 0,exports.runQBotClaw=O,exports.configAndRunQBotClaw=E,exports.runInstall=B;const c=A(require("fs")),u=A(require("path")),_=require("child_process"),r=require("./config"),d=require("./utils"),p=require("./state"),f=require("./quarantine"),o=require("./reportLog"),w=require("./service"),P=require("./openai-proxy");function g(t,n,s,i){if(t&&t.writable){const a=n>0?Math.round(s/n*1e4)/100:0;try{t.write(JSON.stringify({status:"downloading",progress:a,totalSteps:n,currentStep:s,message:i})+`
2
- `)}catch{}}}exports.installState={status:"idle",message:"\u672A\u5F00\u59CB"},exports.isInstalling=!1,exports.PYTHON_DIR=u.default.join(r.QBOT_CLAW_DIR,"python");function O(t,n){return new Promise(s=>{const i=(0,p.readState)(),a=(0,_.spawn)(r.QBOTCLAW_BIN,t,{stdio:["ignore","pipe","pipe"],env:{PATH:r.NODE_BIN_DIR,HOME:process.env.HOME,OPENCLAW_TELEMETRY_GALIELO_GUID:process.env.QB_GUID||"",OPENCLAW_TELEMETRY_GALIELO_QIEMI36:process.env.QB_QIMEI36||"",QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${i.port}/v1`,QBOTCLAW_LLM_API_KEY:P.proxyApiKey}});(0,o.log)(`[QBotClaw] \u6267\u884C: QBotClaw ${t.join(" ")}`),a.stdout.on("data",e=>{const l=e.toString();if(n&&n.writable)try{n.write(l)}catch{}}),a.stderr.on("data",e=>{const l=e.toString();if(n&&n.writable)try{n.write(l)}catch{}}),a.on("close",e=>{(0,o.log)(`[QBotClaw] \u6267\u884C\u5B8C\u6210\uFF0C\u9000\u51FA\u7801: ${e}`),s()}),a.on("error",e=>{(0,o.log)(`[QBotClaw] \u542F\u52A8\u5931\u8D25: ${e.message}`),s()})})}function N(){c.default.existsSync(r.QBOT_CLAW_DIR)||c.default.mkdirSync(r.QBOT_CLAW_DIR,{recursive:!0})}function y(){const t=u.default.join(exports.PYTHON_DIR,"pip.conf");if(c.default.existsSync(t)){(0,o.log)("pip.conf \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");return}const n=["[global]","index-url = https://mirrors.tencent.com/pypi/simple/",`cache-dir = ${u.default.join(exports.PYTHON_DIR,".pip-cache")}`,"","[install]",`prefix = ${exports.PYTHON_DIR}`,""].join(`
3
- `);c.default.writeFileSync(t,n,"utf-8"),(0,o.log)(`\u5DF2\u5199\u5165 pip.conf: ${t}`)}async function T(t){if(c.default.existsSync(r.MCPORTER_BIN)){(0,o.log)("mcporter \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7");return}(0,o.log)("\u5F00\u59CB\u5B89\u88C5 mcporter..."),await new Promise((n,s)=>{const i=(0,_.spawn)(r.NPM_BIN,["--userconfig",r.NPM_RC,"install","-g","mcporter"],{stdio:["ignore","pipe","pipe"],env:{...process.env,PATH:`${u.default.dirname(r.NPM_BIN)}:${process.env.PATH}`}});i.stdout.on("data",a=>{const e=`[mcporter] ${a.toString().trim()}`;(0,o.log)(e),g(t,0,0,e)}),i.stderr.on("data",a=>{const e=`[mcporter] ${a.toString().trim()}`;(0,o.log)(e),g(t,0,0,e)}),i.on("close",a=>{a===0?((0,o.log)("mcporter \u5B89\u88C5\u6210\u529F"),n()):s(new Error(`mcporter \u5B89\u88C5\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${a}`))}),i.on("error",s)})}function C(t,n){return new Promise((s,i)=>{const a=(0,_.spawn)(r.NPM_BIN,["--userconfig",r.NPM_RC,...t],{stdio:["ignore","pipe","pipe"],env:{...process.env,PATH:`${u.default.dirname(r.NPM_BIN)}:${process.env.PATH}`}});a.stdout.on("data",e=>{const l=`[npm] ${e.toString().trim()}`;(0,o.log)(l)}),a.stderr.on("data",e=>{const l=`[npm] ${e.toString().trim()}`;(0,o.log)(l)}),a.on("close",e=>{e===0?((0,o.log)(`${n} \u6210\u529F`),s()):i(new Error(`${n} \u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${e}`))}),a.on("error",i)})}async function I(t){const n=`${r.NPM_PACKAGE_NAME}@${t}`;(0,o.log)(`\u5F00\u59CB\u5B89\u88C5 ${n}\uFF08--ignore-scripts\uFF0C\u4EC5\u4E0B\u8F7D\u89E3\u538B\uFF09...`),await C(["install","-g","--ignore-scripts",n],`${n} \u4E0B\u8F7D\u89E3\u538B`)}async function m(t){const n=`${r.NPM_PACKAGE_NAME}@${t}`;(0,o.log)("\u5F00\u59CB npm rebuild\uFF08\u6267\u884C postinstall \u811A\u672C\uFF09..."),await C(["rebuild","-g",r.NPM_PACKAGE_NAME],`${n} rebuild`),(0,o.log)(`${n} \u5B89\u88C5\u6210\u529F`)}async function L(t,n,s,i){let a;if((0,o.log)(`\u8986\u76D6\u7528\u6237\u5DF2\u6709\u914D\u7F6E: ${i}`),!i&&c.default.existsSync(r.QBOT_CLAW_CONFIG_PATH))a=r.QBOT_CLAW_CONFIG_PATH,(0,o.log)(`\u4F7F\u7528\u5DF2\u6709\u914D\u7F6E\u6587\u4EF6: ${a}`);else{const l=u.default.join(r.NPM_GLOBAL_MODULES,r.NPM_PACKAGE_NAME,"preset-config.json");if(!c.default.existsSync(l)){(0,o.log)(`npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165: ${l}`);return}a=l,(0,o.log)(`\u4F7F\u7528 npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E: ${a}`)}let e;try{e=JSON.parse(c.default.readFileSync(a,"utf-8")),(0,o.log)(`\u5DF2\u8BFB\u53D6\u914D\u7F6E: ${a}`)}catch(l){(0,o.log)(`\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25: ${a}\uFF0C${l.message}\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165`);return}t!==void 0&&(e.gateway={...e.gateway??{},port:t},(0,o.log)(`\u5DF2\u5C06 gateway.port=${t} \u5199\u5165\u914D\u7F6E`)),e.plugins=e.plugins??{},e.plugins.entries=e.plugins.entries??{},e.plugins.entries["x5use-browser-control"]=e.plugins.entries["x5use-browser-control"]??{},e.plugins.entries["x5use-browser-control"].config={...e.plugins.entries["x5use-browser-control"].config??{},wsPort:s,httpPort:n},(0,o.log)(`\u5DF2\u5C06 x5use-browser-control wsPort=${s}, httpPort=${n} \u5199\u5165\u914D\u7F6E`),c.default.writeFileSync(r.QBOT_CLAW_CONFIG_PATH,JSON.stringify(e,null,2),"utf-8"),(0,o.log)(`\u914D\u7F6E\u6587\u4EF6\u5DF2\u5199\u5165: ${r.QBOT_CLAW_CONFIG_PATH}`)}function $(t){const n=u.default.join(r.QBOT_CLAW_DIR,".env"),s=`OPENCLAW_GATEWAY_TOKEN=${t}
1
+ "use strict";var P=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PYTHON_DIR=exports.isInstalling=exports.installState=void 0,exports.runQBotClaw=E,exports.configAndRunQBotClaw=N,exports.runInstall=S;const c=P(require("fs")),u=P(require("path")),_=require("child_process"),s=require("./config"),f=require("./utils"),p=require("./state"),d=require("./quarantine"),a=require("./reportLog"),w=require("./service"),O=require("./openai-proxy");function g(t,n,r,o){if(t&&t.writable){const i=n>0?Math.round(r/n*1e4)/100:0;try{t.write(JSON.stringify({status:"downloading",progress:i,totalSteps:n,currentStep:r,message:o})+`
2
+ `)}catch{}}}exports.installState={status:"idle",message:"\u672A\u5F00\u59CB"},exports.isInstalling=!1,exports.PYTHON_DIR=u.default.join(s.QBOT_CLAW_DIR,"python");function E(t,n){return new Promise(r=>{const o=(0,p.readState)(),i=(0,_.spawn)(s.QBOTCLAW_BIN,t,{stdio:["ignore","pipe","pipe"],env:{PATH:s.NODE_BIN_DIR,HOME:process.env.HOME,OPENCLAW_TELEMETRY_GALIELO_GUID:process.env.QB_GUID||"",OPENCLAW_TELEMETRY_GALIELO_QIEMI36:process.env.QB_QIMEI36||"",QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${o.port}/v1`,QBOTCLAW_LLM_API_KEY:O.proxyApiKey}});(0,a.log)(`[QBotClaw] \u6267\u884C: QBotClaw ${t.join(" ")}`),i.stdout.on("data",e=>{const l=e.toString();if(n&&n.writable)try{n.write(l)}catch{}}),i.stderr.on("data",e=>{const l=e.toString();if(n&&n.writable)try{n.write(l)}catch{}}),i.on("close",e=>{(0,a.log)(`[QBotClaw] \u6267\u884C\u5B8C\u6210\uFF0C\u9000\u51FA\u7801: ${e}`),r()}),i.on("error",e=>{(0,a.log)(`[QBotClaw] \u542F\u52A8\u5931\u8D25: ${e.message}`),r()})})}function y(){c.default.existsSync(s.QBOT_CLAW_DIR)||c.default.mkdirSync(s.QBOT_CLAW_DIR,{recursive:!0})}function I(){const t=u.default.join(exports.PYTHON_DIR,"pip.conf");if(c.default.existsSync(t)){(0,a.log)("pip.conf \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");return}const n=["[global]","index-url = https://mirrors.tencent.com/pypi/simple/",`cache-dir = ${u.default.join(exports.PYTHON_DIR,".pip-cache")}`,"","[install]",`prefix = ${exports.PYTHON_DIR}`,""].join(`
3
+ `);c.default.writeFileSync(t,n,"utf-8"),(0,a.log)(`\u5DF2\u5199\u5165 pip.conf: ${t}`)}async function T(t){if(c.default.existsSync(s.MCPORTER_BIN)){(0,a.log)("mcporter \u5DF2\u5B89\u88C5\uFF0C\u8DF3\u8FC7");return}(0,a.log)("\u5F00\u59CB\u5B89\u88C5 mcporter..."),await new Promise((n,r)=>{const o=(0,_.spawn)(s.NPM_BIN,["--userconfig",s.NPM_RC,"install","-g","mcporter"],{stdio:["ignore","pipe","pipe"],env:{...process.env,PATH:`${u.default.dirname(s.NPM_BIN)}:${process.env.PATH}`}});o.stdout.on("data",i=>{const e=`[mcporter] ${i.toString().trim()}`;(0,a.log)(e),g(t,0,0,e)}),o.stderr.on("data",i=>{const e=`[mcporter] ${i.toString().trim()}`;(0,a.log)(e),g(t,0,0,e)}),o.on("close",i=>{i===0?((0,a.log)("mcporter \u5B89\u88C5\u6210\u529F"),n()):r(new Error(`mcporter \u5B89\u88C5\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${i}`))}),o.on("error",r)})}function C(t,n){return new Promise((r,o)=>{const i=(0,_.spawn)(s.NPM_BIN,["--userconfig",s.NPM_RC,...t],{stdio:["ignore","pipe","pipe"],env:{...process.env,PATH:`${u.default.dirname(s.NPM_BIN)}:${process.env.PATH}`}});i.stdout.on("data",e=>{const l=`[npm] ${e.toString().trim()}`;(0,a.log)(l)}),i.stderr.on("data",e=>{const l=`[npm] ${e.toString().trim()}`;(0,a.log)(l)}),i.on("close",e=>{e===0?((0,a.log)(`${n} \u6210\u529F`),r()):o(new Error(`${n} \u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${e}`))}),i.on("error",o)})}async function m(t){const n=`${s.NPM_PACKAGE_NAME}@${t}`;(0,a.log)(`\u5F00\u59CB\u5B89\u88C5 ${n}\uFF08--ignore-scripts\uFF0C\u4EC5\u4E0B\u8F7D\u89E3\u538B\uFF09...`),await C(["install","-g","--ignore-scripts",n],`${n} \u4E0B\u8F7D\u89E3\u538B`)}async function $(t){const n=`${s.NPM_PACKAGE_NAME}@${t}`;(0,a.log)("\u5F00\u59CB npm rebuild\uFF08\u6267\u884C postinstall \u811A\u672C\uFF09..."),await C(["rebuild","-g",s.NPM_PACKAGE_NAME],`${n} rebuild`),(0,a.log)(`${n} \u5B89\u88C5\u6210\u529F`)}async function L(t,n,r,o){try{const l=await(0,f.execCommand)(`"${s.NODE_BIN}" "${s.QBOTCLAW_BIN}" config validate --json`);(0,a.log)(`[config validate] \u8F93\u51FA: ${l}`);const A=JSON.parse(l);A.valid!==!0?((0,a.log)(`[config validate] \u914D\u7F6E\u6821\u9A8C\u672A\u901A\u8FC7\uFF08valid=${A.valid}\uFF09\uFF0C\u5F3A\u5236\u8986\u76D6\u914D\u7F6E`),o=!0):(0,a.log)("[config validate] \u914D\u7F6E\u6821\u9A8C\u901A\u8FC7")}catch(l){(0,a.log)(`[config validate] \u6267\u884C\u5931\u8D25: ${l.message}\uFF0C\u5F3A\u5236\u8986\u76D6\u914D\u7F6E`),o=!0}let i;if((0,a.log)(`\u8986\u76D6\u7528\u6237\u5DF2\u6709\u914D\u7F6E: ${o}`),!o&&c.default.existsSync(s.QBOT_CLAW_CONFIG_PATH))i=s.QBOT_CLAW_CONFIG_PATH,(0,a.log)(`\u4F7F\u7528\u5DF2\u6709\u914D\u7F6E\u6587\u4EF6: ${i}`);else{const l=u.default.join(s.NPM_GLOBAL_MODULES,s.NPM_PACKAGE_NAME,"preset-config.json");if(!c.default.existsSync(l)){(0,a.log)(`npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165: ${l}`);return}i=l,(0,a.log)(`\u4F7F\u7528 npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E: ${i}`)}let e;try{e=JSON.parse(c.default.readFileSync(i,"utf-8")),(0,a.log)(`\u5DF2\u8BFB\u53D6\u914D\u7F6E: ${i}`)}catch(l){(0,a.log)(`\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25: ${i}\uFF0C${l.message}\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165`);return}t!==void 0&&(e.gateway={...e.gateway??{},port:t},(0,a.log)(`\u5DF2\u5C06 gateway.port=${t} \u5199\u5165\u914D\u7F6E`)),e.plugins=e.plugins??{},e.plugins.entries=e.plugins.entries??{},e.plugins.entries["x5use-browser-control"]=e.plugins.entries["x5use-browser-control"]??{},e.plugins.entries["x5use-browser-control"].config={...e.plugins.entries["x5use-browser-control"].config??{},wsPort:r,httpPort:n},(0,a.log)(`\u5DF2\u5C06 x5use-browser-control wsPort=${r}, httpPort=${n} \u5199\u5165\u914D\u7F6E`),c.default.writeFileSync(s.QBOT_CLAW_CONFIG_PATH,JSON.stringify(e,null,2),"utf-8"),(0,a.log)(`\u914D\u7F6E\u6587\u4EF6\u5DF2\u5199\u5165: ${s.QBOT_CLAW_CONFIG_PATH}`)}function B(t){const n=u.default.join(s.QBOT_CLAW_DIR,".env"),r=`OPENCLAW_GATEWAY_TOKEN=${t}
4
4
  `;try{if(c.default.existsSync(n)){const e=c.default.readFileSync(n,"utf-8").split(`
5
5
  `).filter(l=>!l.startsWith("OPENCLAW_GATEWAY_TOKEN=")).filter(l=>l!=="").join(`
6
6
  `)+`
7
- `+s;c.default.writeFileSync(n,e,"utf-8")}else c.default.writeFileSync(n,s,"utf-8");(0,o.log)(`\u5DF2\u5C06 OPENCLAW_GATEWAY_TOKEN \u5199\u5165 ${n}`)}catch(i){(0,o.log)(`\u5199\u5165 .env \u6587\u4EF6\u5931\u8D25: ${i.message}`)}}async function E(t){const n=(0,p.readState)();let s;n.gatewayPort&&!await(0,p.isPortAvailable)(n.gatewayPort)?(s=n.gatewayPort,(0,o.log)(`\u68C0\u6D4B\u5230 QBotClaw gateway \u5DF2\u5728\u7AEF\u53E3 ${s} \u8FD0\u884C\uFF0C\u590D\u7528\u539F\u7AEF\u53E3`)):s=await(0,d.findAvailablePort)(),(0,o.log)(`\u540E\u53F0\u542F\u52A8 QBotClaw gateway run --port ${s} --force`);const i=await(0,d.findAvailablePort)(r.DEFAULT_MCP_HTTP_PORT),a=await(0,d.findAvailablePort)();await L(s,i,a,t),$((0,w.getOrCreateGatewayToken)());const e=(0,_.spawn)(r.QBOTCLAW_BIN,["gateway","run","--port",String(s),"--force"],{stdio:"ignore",env:{PATH:r.NODE_BIN_DIR,HOME:process.env.HOME,OPENCLAW_NO_RESPAWN:"true",VENUS_API_KEY:"E9isWWfAr4VIFuIa5RbJaPxD@2040",OPENCLAW_TELEMETRY_GALIELO_GUID:process.env.QB_GUID||"",OPENCLAW_TELEMETRY_GALIELO_QIEMI36:process.env.QB_QIMEI36||"",OPENCLAW_GATEWAY_TOKEN:(0,w.getOrCreateGatewayToken)(),QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${n.port}/v1`,QBOTCLAW_LLM_API_KEY:P.proxyApiKey}});e.unref();const l=e.pid;(0,o.log)(`QBotClaw gateway \u5DF2\u5728\u540E\u53F0\u542F\u52A8\uFF0CPID: ${l}\uFF0C\u7AEF\u53E3: ${s}, token ${(0,w.getOrCreateGatewayToken)()}`),(0,p.writeState)({...(0,p.readState)(),gatewayPid:l,gatewayPort:s,mcpHttpPort:i,mcpWsPort:a})}function B(t,n,s){if(exports.isInstalling){if((0,o.log)("[runInstall] \u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u62D2\u7EDD\u91CD\u590D\u6267\u884C"),t&&t.writable)try{t.end(JSON.stringify({status:"failed",progress:0,message:"\u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u8BF7\u52FF\u91CD\u590D\u64CD\u4F5C"})+`
8
- `)}catch{}return}exports.isInstalling=!0,exports.installState={status:"downloading",message:"\u6B63\u5728\u5B89\u88C5...",startTime:new Date().toISOString()},(0,o.log)(`\u5F00\u59CB\u5B89\u88C5 ${r.NPM_PACKAGE_NAME}@${n}`),(async()=>{try{(0,p.stopGateway)(),N(),y();const i=5;let a=0;g(t,i,a,"\u5F00\u59CB\u5B89\u88C5 mcporter..."),await T(t),a++,g(t,i,a,"\u5F00\u59CB\u4E0B\u8F7D\u89E3\u538B QBotClaw..."),await I(n),a++,g(t,i,a,"npmDownloadQBotClaw \u5B8C\u6210"),await(0,f.fullScanClearQuarantine)("npm install --ignore-scripts \u5B8C\u6210\u540E\uFF0Crebuild \u524D"),a++,await(0,f.watchWorkspaceQuarantine)().catch(e=>{(0,o.log)(`[quarantine] watchWorkspaceQuarantine \u542F\u52A8\u5F02\u5E38: ${e.message}`)}),g(t,i,a,"\u5F00\u59CB npm rebuild..."),await m(n),a++,g(t,i,a,"npmRebuildQBotClaw \u5B8C\u6210");try{c.default.existsSync(r.OPENCLAW_BIN)||(c.default.symlinkSync(r.QBOTCLAW_BIN,r.OPENCLAW_BIN),(0,o.log)(`\u5DF2\u521B\u5EFA\u8F6F\u94FE\u63A5: ${r.OPENCLAW_BIN} -> ${r.QBOTCLAW_BIN}`))}catch(e){(0,o.log)(`\u521B\u5EFA openclaw \u8F6F\u94FE\u63A5\u5931\u8D25: ${e.message}`)}if(await(0,f.stopWatchWorkspaceQuarantine)().catch(e=>{(0,o.log)(`[quarantine] stopWatchWorkspaceQuarantine \u5F02\u5E38: ${e.message}`)}),exports.installState={status:"success",message:"\u5B89\u88C5\u6210\u529F",endTime:new Date().toISOString()},(0,o.log)("\u5B89\u88C5\u6210\u529F"),(0,o.refreshClawVersion)(n),g(t,i,a,"\u5F00\u59CB\u914D\u7F6E\u5E76\u542F\u52A8 QBotClaw gateway..."),await E(s),a++,t.writable)try{const e=(0,w.getOrCreateGatewayToken)();t.end(JSON.stringify({status:"done",progress:100,message:"\u5B89\u88C5\u6210\u529F",gatewayToken:e})+`
9
- `)}catch{}}catch(i){if(await(0,f.stopWatchWorkspaceQuarantine)().catch(()=>{}),exports.installState={status:"failed",message:i.message,endTime:new Date().toISOString()},(0,o.log)(`\u5B89\u88C5\u5931\u8D25: ${i.message}`),t&&t.writable)try{t.end(JSON.stringify({status:"failed",progress:0,message:i.message})+`
7
+ `+r;c.default.writeFileSync(n,e,"utf-8")}else c.default.writeFileSync(n,r,"utf-8");(0,a.log)(`\u5DF2\u5C06 OPENCLAW_GATEWAY_TOKEN \u5199\u5165 ${n}`)}catch(o){(0,a.log)(`\u5199\u5165 .env \u6587\u4EF6\u5931\u8D25: ${o.message}`)}}async function N(t){const n=(0,p.readState)();let r;n.gatewayPort&&!await(0,p.isPortAvailable)(n.gatewayPort)?(r=n.gatewayPort,(0,a.log)(`\u68C0\u6D4B\u5230 QBotClaw gateway \u5DF2\u5728\u7AEF\u53E3 ${r} \u8FD0\u884C\uFF0C\u590D\u7528\u539F\u7AEF\u53E3`)):r=await(0,f.findAvailablePort)(),(0,a.log)(`\u540E\u53F0\u542F\u52A8 QBotClaw gateway run --port ${r} --force`);const o=await(0,f.findAvailablePort)(s.DEFAULT_MCP_HTTP_PORT),i=await(0,f.findAvailablePort)();await L(r,o,i,t),B((0,w.getOrCreateGatewayToken)());const e=(0,_.spawn)(s.QBOTCLAW_BIN,["gateway","run","--port",String(r),"--force"],{stdio:"ignore",env:{PATH:s.NODE_BIN_DIR,HOME:process.env.HOME,OPENCLAW_NO_RESPAWN:"true",VENUS_API_KEY:"E9isWWfAr4VIFuIa5RbJaPxD@2040",OPENCLAW_TELEMETRY_GALIELO_GUID:process.env.QB_GUID||"",OPENCLAW_TELEMETRY_GALIELO_QIEMI36:process.env.QB_QIMEI36||"",OPENCLAW_GATEWAY_TOKEN:(0,w.getOrCreateGatewayToken)(),QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${n.port}/v1`,QBOTCLAW_LLM_API_KEY:O.proxyApiKey}});e.unref();const l=e.pid;(0,a.log)(`QBotClaw gateway \u5DF2\u5728\u540E\u53F0\u542F\u52A8\uFF0CPID: ${l}\uFF0C\u7AEF\u53E3: ${r}, token ${(0,w.getOrCreateGatewayToken)()}`),(0,p.writeState)({...(0,p.readState)(),gatewayPid:l,gatewayPort:r,mcpHttpPort:o,mcpWsPort:i})}function S(t,n,r){if(exports.isInstalling){if((0,a.log)("[runInstall] \u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u62D2\u7EDD\u91CD\u590D\u6267\u884C"),t&&t.writable)try{t.end(JSON.stringify({status:"failed",progress:0,message:"\u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u8BF7\u52FF\u91CD\u590D\u64CD\u4F5C"})+`
8
+ `)}catch{}return}exports.isInstalling=!0,exports.installState={status:"downloading",message:"\u6B63\u5728\u5B89\u88C5...",startTime:new Date().toISOString()},(0,a.log)(`\u5F00\u59CB\u5B89\u88C5 ${s.NPM_PACKAGE_NAME}@${n}`),(async()=>{try{(0,p.stopGateway)(),y(),I();const o=5;let i=0;g(t,o,i,"\u5F00\u59CB\u5B89\u88C5 mcporter..."),await T(t),i++,g(t,o,i,"\u5F00\u59CB\u4E0B\u8F7D\u89E3\u538B QBotClaw..."),await m(n),i++,g(t,o,i,"npmDownloadQBotClaw \u5B8C\u6210"),await(0,d.fullScanClearQuarantine)("npm install --ignore-scripts \u5B8C\u6210\u540E\uFF0Crebuild \u524D"),i++,await(0,d.watchWorkspaceQuarantine)().catch(e=>{(0,a.log)(`[quarantine] watchWorkspaceQuarantine \u542F\u52A8\u5F02\u5E38: ${e.message}`)}),g(t,o,i,"\u5F00\u59CB npm rebuild..."),await $(n),i++,g(t,o,i,"npmRebuildQBotClaw \u5B8C\u6210");try{c.default.existsSync(s.OPENCLAW_BIN)||(c.default.symlinkSync(s.QBOTCLAW_BIN,s.OPENCLAW_BIN),(0,a.log)(`\u5DF2\u521B\u5EFA\u8F6F\u94FE\u63A5: ${s.OPENCLAW_BIN} -> ${s.QBOTCLAW_BIN}`))}catch(e){(0,a.log)(`\u521B\u5EFA openclaw \u8F6F\u94FE\u63A5\u5931\u8D25: ${e.message}`)}if(await(0,d.stopWatchWorkspaceQuarantine)().catch(e=>{(0,a.log)(`[quarantine] stopWatchWorkspaceQuarantine \u5F02\u5E38: ${e.message}`)}),exports.installState={status:"success",message:"\u5B89\u88C5\u6210\u529F",endTime:new Date().toISOString()},(0,a.log)("\u5B89\u88C5\u6210\u529F"),(0,a.refreshClawVersion)(n),g(t,o,i,"\u5F00\u59CB\u914D\u7F6E\u5E76\u542F\u52A8 QBotClaw gateway..."),await N(r),i++,t.writable)try{const e=(0,w.getOrCreateGatewayToken)();t.end(JSON.stringify({status:"done",progress:100,message:"\u5B89\u88C5\u6210\u529F",gatewayToken:e})+`
9
+ `)}catch{}}catch(o){if(await(0,d.stopWatchWorkspaceQuarantine)().catch(()=>{}),exports.installState={status:"failed",message:o.message,endTime:new Date().toISOString()},(0,a.log)(`\u5B89\u88C5\u5931\u8D25: ${o.message}`),t&&t.writable)try{t.end(JSON.stringify({status:"failed",progress:0,message:o.message})+`
10
10
  `)}catch{}}finally{exports.isInstalling=!1}})()}
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var L=exports&&exports.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.server=void 0,exports.setGlobalAuthClient=z,exports.getGlobalAuthClient=K,exports.watchParentProcess=W;const U=L(require("http")),w=L(require("fs")),I=L(require("path")),u=require("./config"),a=require("./utils"),r=require("./reportLog"),$=require("./installer"),G=require("./version"),y=require("./state"),R=require("child_process"),Q=require("./service"),J=require("./filePicker"),x=require("./fileSecurityCheck"),B=require("./authMiddleware"),H="\u9009\u62E9\u6587\u4EF6",M=10485760,F=10,b=!1,P={CANCELLED:"CANCELLED",INVALID_PARAMS:"INVALID_PARAMS",DIALOG_BUSY:"DIALOG_BUSY",DIALOG_TIMEOUT:"DIALOG_TIMEOUT",PLATFORM_NOT_SUPPORTED:"PLATFORM_NOT_SUPPORTED",INTERNAL_ERROR:"INTERNAL_ERROR"},q=require("./openai-proxy"),V=require("./api/auth-client");let v=new V.AuthClient({usePipe:!0});function z(d){v=d}function K(){return v}const C={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Max-Age":"86400"};function j(d){for(const[e,f]of Object.entries(C))d.setHeader(e,f)}exports.server=U.default.createServer(async(d,e)=>{const f=d.url||"";if(j(e),d.method==="OPTIONS"){e.writeHead(204,C),e.end();return}if(f.startsWith("/v1/")){await(0,q.handleOpenAIProxy)(d,e,v);return}if(f==="/api/version"){let n="unknown";try{n=(await(0,a.execCommand)(`"${u.NODE_BIN}" -v`)).trim(),(0,r.log)(`[version] node \u7248\u672C: ${n}`)}catch(g){(0,r.log)(`[version] \u83B7\u53D6 node \u7248\u672C\u5931\u8D25: ${g.message}`),n=`error: ${g.message}`}const o=await(0,a.getQBotClawVersion)()??"0.0.0";(0,r.log)(`[version] qbotclaw \u7248\u672C: ${o}`);let s="0.0.0";if(w.default.existsSync(u.MCPORTER_BIN))try{s=(await(0,a.execCommand)(`"${u.NODE_BIN}" "${u.MCPORTER_BIN}" --version`)).trim(),(0,r.log)(`[version] mcporter \u7248\u672C: ${s}`)}catch(g){(0,r.log)(`[version] \u83B7\u53D6 mcporter \u7248\u672C\u5931\u8D25: ${g.message}`),s=`error: ${g.message}`}let i="0.0.0";if(w.default.existsSync(u.PYTHON_BIN))try{i=(await(0,a.execCommand)(`"${u.PYTHON_BIN}" --version`)).trim(),(0,r.log)(`[version] python \u7248\u672C: ${i}`)}catch(g){(0,r.log)(`[version] \u83B7\u53D6 python \u7248\u672C\u5931\u8D25: ${g.message}`),i=`error: ${g.message}`}(0,a.sendJSON)(e,200,{status:"\u6210\u529F",launcher:G.LAUNCHER_VERSION,node:n,qbotclaw:o,mcporter:s,python:i});return}if(f==="/api/port"){const n=exports.server.address(),o=n&&typeof n=="object"?n.port:null,s=(0,y.readState)();(0,a.sendJSON)(e,200,{status:"\u6210\u529F",launcher:o,qbotclaw:s.gatewayPort??2e3,mcpHttp:s.mcpHttpPort??u.DEFAULT_MCP_HTTP_PORT,mcpWs:s.mcpWsPort??8765});return}if(f==="/api/status"){const n=(0,y.readState)(),o=[];if(n.gatewayPid)try{process.kill(n.gatewayPid,0)}catch{o.push(`gateway \u8FDB\u7A0B (pid: ${n.gatewayPid}) \u5DF2\u9000\u51FA`)}else o.push("gateway \u8FDB\u7A0B\u672A\u542F\u52A8\uFF08\u72B6\u6001\u4E2D\u65E0 gatewayPid\uFF09");const s=[{name:"gateway",port:n.gatewayPort},{name:"mcpHttp",port:n.mcpHttpPort},{name:"mcpWs",port:n.mcpWsPort}];for(const{name:i,port:g}of s){if(!g){o.push(`${i} \u7AEF\u53E3\u672A\u914D\u7F6E\uFF08\u72B6\u6001\u4E2D\u65E0\u5BF9\u5E94\u7AEF\u53E3\u53F7\uFF09`);continue}await(0,y.isPortAvailable)(g)&&o.push(`${i} \u7AEF\u53E3 (${g}) \u65E0\u670D\u52A1\u76D1\u542C`)}o.length===0?(0,a.sendJSON)(e,200,{ok:!0,message:"\u6240\u6709\u670D\u52A1\u8FD0\u884C\u6B63\u5E38"}):(0,a.sendJSON)(e,200,{ok:!1,message:o.join("\uFF1B")});return}if(f==="/api/restart"){try{const n=(0,y.readState)();if(n.gatewayPid)try{process.kill(n.gatewayPid,"SIGTERM"),(0,r.log)(`[restart] \u5DF2\u53D1\u9001 SIGTERM \u7ED9\u65E7 gateway \u8FDB\u7A0B pid: ${n.gatewayPid}`)}catch{(0,r.log)(`[restart] \u65E7 gateway \u8FDB\u7A0B ${n.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA\uFF0C\u5FFD\u7565`)}const{gatewayPid:o,gatewayPort:s,mcpHttpPort:i,mcpWsPort:g,...m}=n;(0,y.writeState)(m),(0,r.log)("[restart] \u5DF2\u6E05\u9664 gatewayPid, gatewayPort, mcpHttpPort, mcpWsPort"),await(0,$.configAndRunQBotClaw)(),(0,r.log)("[restart] QBotClaw gateway \u91CD\u542F\u5B8C\u6210");const c=(0,y.readState)(),l=exports.server.address(),t=l&&typeof l=="object"?l.port:null;(0,a.sendJSON)(e,200,{ok:!0,message:"QBotClaw gateway \u91CD\u542F\u6210\u529F",launcher:t,qbotclaw:c.gatewayPort??2e3,mcpHttp:c.mcpHttpPort??u.DEFAULT_MCP_HTTP_PORT,mcpWs:c.mcpWsPort??8765,gatewayToken:(0,Q.getOrCreateGatewayToken)()})}catch(n){(0,r.log)(`[restart] \u91CD\u542F\u5931\u8D25: ${n.message}`),(0,a.sendJSON)(e,500,{ok:!1,message:`\u91CD\u542F\u5931\u8D25: ${n.message}`})}return}if(f==="/api/wechat/history"){try{if(!w.default.existsSync(u.SESSIONS_FILE)){(0,a.sendJSON)(e,404,{ok:!1,sessionKey:"",message:"\u672A\u627E\u5230\u4F1A\u8BDD\u6587\u4EF6"});return}const n=JSON.parse(w.default.readFileSync(u.SESSIONS_FILE,"utf-8"));let o=null,s=0;for(const[m,c]of Object.entries(n))if(m.includes("openclaw-weixin")){const t=c.updatedAt??0;t>s&&(s=t,o=m)}if(!o){(0,a.sendJSON)(e,404,{ok:!1,sessionKey:"",message:"\u672A\u627E\u5230\u5FAE\u4FE1\u4F1A\u8BDD"});return}const g=o.split(":").slice(2).join(":");(0,a.sendJSON)(e,200,{ok:!0,sessionKey:g,message:"\u83B7\u53D6\u6210\u529F"})}catch(n){(0,r.log)(`[wechat/history] \u8BFB\u53D6\u5FAE\u4FE1\u4F1A\u8BDD\u5931\u8D25: ${n.message}`),(0,a.sendJSON)(e,500,{ok:!1,sessionKey:"",message:`\u8BFB\u53D6\u5FAE\u4FE1\u4F1A\u8BDD\u5931\u8D25: ${n.message}`})}return}if(f==="/api/installing"){(0,a.sendJSON)(e,200,{installing:$.isInstalling});return}if(f==="/api/install"||f.startsWith("/api/install?")){if($.installState.status==="downloading"){(0,a.sendJSON)(e,200,{ok:"downloading",message:"\u6B63\u5728\u5B89\u88C5\u4E2D..."});return}const n=new URL(f,"http://localhost"),o=n.searchParams.get("version")||void 0,s=n.searchParams.get("overrideConfig")==="true";if(!o){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 version\uFF0C\u7528\u6CD5: GET /api/install?version=x.x.x"});return}e.writeHead(200,{...C,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked","Cache-Control":"no-cache"}),(0,$.runInstall)(e,o,s);return}if(f.startsWith("/api/watch")){const o=new URL(f,"http://localhost").searchParams.get("ppid");if(!o||isNaN(Number(o))){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u6709\u6548\u7684 ppid \u53C2\u6570\uFF0C\u7528\u6CD5: GET /api/watch?ppid=12345"});return}const s=parseInt(o,10);try{process.kill(s,0)}catch{(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:`\u8FDB\u7A0B ${s} \u4E0D\u5B58\u5728`});return}const i=(0,y.readState)();(0,y.writeState)({...i,ppid:s}),W(s),(0,a.sendJSON)(e,200,{status:"\u6210\u529F",message:`\u5DF2\u5F00\u59CB\u76D1\u63A7\u7236\u8FDB\u7A0B ppid: ${s}`});return}if(f==="/api/qbotclaw"&&d.method==="POST"){let n="";d.on("data",o=>{n+=o.toString()}),d.on("end",()=>{let o;try{const s=JSON.parse(n);if(!Array.isArray(s.args)||s.args.length===0){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 args \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4"});return}o=s.args.map(i=>String(i))}catch{(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u8BF7\u6C42\u4F53\u5FC5\u987B\u662F\u5408\u6CD5\u7684 JSON"});return}if(!w.default.existsSync(u.QBOTCLAW_BIN)){(0,a.sendJSON)(e,404,{status:"\u5931\u8D25",message:`qbotclaw \u53EF\u6267\u884C\u6587\u4EF6\u4E0D\u5B58\u5728: ${u.QBOTCLAW_BIN}`});return}e.writeHead(200,{...C,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked","Cache-Control":"no-cache"}),(0,$.runQBotClaw)(o,e).then(()=>{e.end(`
1
+ "use strict";var L=exports&&exports.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.server=void 0,exports.setGlobalAuthClient=z,exports.getGlobalAuthClient=K,exports.watchParentProcess=W;const U=L(require("http")),w=L(require("fs")),$=L(require("path")),u=require("./config"),a=require("./utils"),r=require("./reportLog"),I=require("./installer"),G=require("./version"),y=require("./state"),R=require("child_process"),Q=require("./service"),J=require("./filePicker"),x=require("./fileSecurityCheck"),B=require("./authMiddleware"),H="\u9009\u62E9\u6587\u4EF6",M=10485760,F=10,b=!1,P={CANCELLED:"CANCELLED",INVALID_PARAMS:"INVALID_PARAMS",DIALOG_BUSY:"DIALOG_BUSY",DIALOG_TIMEOUT:"DIALOG_TIMEOUT",PLATFORM_NOT_SUPPORTED:"PLATFORM_NOT_SUPPORTED",INTERNAL_ERROR:"INTERNAL_ERROR"},q=require("./openai-proxy"),V=require("./api/auth-client");let v=new V.AuthClient({usePipe:!0});function z(d){v=d}function K(){return v}const C={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Max-Age":"86400"};function j(d){for(const[e,f]of Object.entries(C))d.setHeader(e,f)}exports.server=U.default.createServer(async(d,e)=>{const f=d.url||"";if(j(e),d.method==="OPTIONS"){e.writeHead(204,C),e.end();return}if(f.startsWith("/v1/")){await(0,q.handleOpenAIProxy)(d,e,v);return}if(f==="/api/version"){let n="unknown";try{n=(await(0,a.execCommand)(`"${u.NODE_BIN}" -v`)).trim(),(0,r.log)(`[version] node \u7248\u672C: ${n}`)}catch(g){(0,r.log)(`[version] \u83B7\u53D6 node \u7248\u672C\u5931\u8D25: ${g.message}`),n=`error: ${g.message}`}const o=await(0,a.getQBotClawVersion)()??"0.0.0";(0,r.log)(`[version] qbotclaw \u7248\u672C: ${o}`);let s="0.0.0";if(w.default.existsSync(u.MCPORTER_BIN))try{s=(await(0,a.execCommand)(`"${u.NODE_BIN}" "${u.MCPORTER_BIN}" --version`)).trim(),(0,r.log)(`[version] mcporter \u7248\u672C: ${s}`)}catch(g){(0,r.log)(`[version] \u83B7\u53D6 mcporter \u7248\u672C\u5931\u8D25: ${g.message}`),s=`error: ${g.message}`}let i="0.0.0";if(w.default.existsSync(u.PYTHON_BIN))try{i=(await(0,a.execCommand)(`"${u.PYTHON_BIN}" --version`)).trim(),(0,r.log)(`[version] python \u7248\u672C: ${i}`)}catch(g){(0,r.log)(`[version] \u83B7\u53D6 python \u7248\u672C\u5931\u8D25: ${g.message}`),i=`error: ${g.message}`}(0,a.sendJSON)(e,200,{status:"\u6210\u529F",launcher:G.LAUNCHER_VERSION,node:n,qbotclaw:o,mcporter:s,python:i});return}if(f==="/api/port"){const n=exports.server.address(),o=n&&typeof n=="object"?n.port:null,s=(0,y.readState)();(0,a.sendJSON)(e,200,{status:"\u6210\u529F",launcher:o,qbotclaw:s.gatewayPort??2e3,mcpHttp:s.mcpHttpPort??u.DEFAULT_MCP_HTTP_PORT,mcpWs:s.mcpWsPort??8765});return}if(f==="/api/status"){const n=(0,y.readState)(),o=[];if(n.gatewayPid)try{process.kill(n.gatewayPid,0)}catch{o.push(`gateway \u8FDB\u7A0B (pid: ${n.gatewayPid}) \u5DF2\u9000\u51FA`)}else o.push("gateway \u8FDB\u7A0B\u672A\u542F\u52A8\uFF08\u72B6\u6001\u4E2D\u65E0 gatewayPid\uFF09");const s=[{name:"gateway",port:n.gatewayPort},{name:"mcpHttp",port:n.mcpHttpPort},{name:"mcpWs",port:n.mcpWsPort}];for(const{name:i,port:g}of s){if(!g){o.push(`${i} \u7AEF\u53E3\u672A\u914D\u7F6E\uFF08\u72B6\u6001\u4E2D\u65E0\u5BF9\u5E94\u7AEF\u53E3\u53F7\uFF09`);continue}await(0,y.isPortAvailable)(g)&&o.push(`${i} \u7AEF\u53E3 (${g}) \u65E0\u670D\u52A1\u76D1\u542C`)}o.length===0?(0,a.sendJSON)(e,200,{ok:!0,message:"\u6240\u6709\u670D\u52A1\u8FD0\u884C\u6B63\u5E38"}):(0,a.sendJSON)(e,200,{ok:!1,message:o.join("\uFF1B")});return}if(f==="/api/restart"){try{const n=(0,y.readState)();if(n.gatewayPid)try{process.kill(n.gatewayPid,"SIGTERM"),(0,r.log)(`[restart] \u5DF2\u53D1\u9001 SIGTERM \u7ED9\u65E7 gateway \u8FDB\u7A0B pid: ${n.gatewayPid}`)}catch{(0,r.log)(`[restart] \u65E7 gateway \u8FDB\u7A0B ${n.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA\uFF0C\u5FFD\u7565`)}const{gatewayPid:o,gatewayPort:s,mcpHttpPort:i,mcpWsPort:g,...m}=n;(0,y.writeState)(m),(0,r.log)("[restart] \u5DF2\u6E05\u9664 gatewayPid, gatewayPort, mcpHttpPort, mcpWsPort"),await(0,I.configAndRunQBotClaw)(),(0,r.log)("[restart] QBotClaw gateway \u91CD\u542F\u5B8C\u6210");const c=(0,y.readState)(),l=exports.server.address(),t=l&&typeof l=="object"?l.port:null;(0,a.sendJSON)(e,200,{ok:!0,message:"QBotClaw gateway \u91CD\u542F\u6210\u529F",launcher:t,qbotclaw:c.gatewayPort??2e3,mcpHttp:c.mcpHttpPort??u.DEFAULT_MCP_HTTP_PORT,mcpWs:c.mcpWsPort??8765,gatewayToken:(0,Q.getOrCreateGatewayToken)()})}catch(n){(0,r.log)(`[restart] \u91CD\u542F\u5931\u8D25: ${n.message}`),(0,a.sendJSON)(e,500,{ok:!1,message:`\u91CD\u542F\u5931\u8D25: ${n.message}`})}return}if(f==="/api/wechat/history"){try{if(!w.default.existsSync(u.SESSIONS_FILE)){(0,a.sendJSON)(e,404,{ok:!1,sessionKey:"",message:"\u672A\u627E\u5230\u4F1A\u8BDD\u6587\u4EF6"});return}const n=JSON.parse(w.default.readFileSync(u.SESSIONS_FILE,"utf-8"));let o=null,s=0;for(const[m,c]of Object.entries(n))if(m.includes("openclaw-weixin")){const t=c.updatedAt??0;t>s&&(s=t,o=m)}if(!o){(0,a.sendJSON)(e,404,{ok:!1,sessionKey:"",message:"\u672A\u627E\u5230\u5FAE\u4FE1\u4F1A\u8BDD"});return}const g=o.split(":").slice(2).join(":");(0,a.sendJSON)(e,200,{ok:!0,sessionKey:g,message:"\u83B7\u53D6\u6210\u529F"})}catch(n){(0,r.log)(`[wechat/history] \u8BFB\u53D6\u5FAE\u4FE1\u4F1A\u8BDD\u5931\u8D25: ${n.message}`),(0,a.sendJSON)(e,500,{ok:!1,sessionKey:"",message:`\u8BFB\u53D6\u5FAE\u4FE1\u4F1A\u8BDD\u5931\u8D25: ${n.message}`})}return}if(f==="/api/installing"){(0,a.sendJSON)(e,200,{installing:I.isInstalling});return}if(f==="/api/install"||f.startsWith("/api/install?")){if(I.installState.status==="downloading"){(0,a.sendJSON)(e,200,{ok:"downloading",message:"\u6B63\u5728\u5B89\u88C5\u4E2D..."});return}const n=new URL(f,"http://localhost"),o=n.searchParams.get("version")||void 0,s=n.searchParams.get("overrideConfig")==="true";if(!o){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 version\uFF0C\u7528\u6CD5: GET /api/install?version=x.x.x"});return}e.writeHead(200,{...C,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked","Cache-Control":"no-cache"}),(0,I.runInstall)(e,o,s);return}if(f.startsWith("/api/watch")){const o=new URL(f,"http://localhost").searchParams.get("ppid");if(!o||isNaN(Number(o))){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u6709\u6548\u7684 ppid \u53C2\u6570\uFF0C\u7528\u6CD5: GET /api/watch?ppid=12345"});return}const s=parseInt(o,10);try{process.kill(s,0)}catch{(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:`\u8FDB\u7A0B ${s} \u4E0D\u5B58\u5728`});return}const i=(0,y.readState)();(0,y.writeState)({...i,ppid:s}),W(s),(0,a.sendJSON)(e,200,{status:"\u6210\u529F",message:`\u5DF2\u5F00\u59CB\u76D1\u63A7\u7236\u8FDB\u7A0B ppid: ${s}`});return}if(f==="/api/qbotclaw"&&d.method==="POST"){let n="";d.on("data",o=>{n+=o.toString()}),d.on("end",()=>{let o;try{const s=JSON.parse(n);if(!Array.isArray(s.args)||s.args.length===0){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 args \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4"});return}o=s.args.map(i=>String(i))}catch{(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u8BF7\u6C42\u4F53\u5FC5\u987B\u662F\u5408\u6CD5\u7684 JSON"});return}if(!w.default.existsSync(u.QBOTCLAW_BIN)){(0,a.sendJSON)(e,404,{status:"\u5931\u8D25",message:`qbotclaw \u53EF\u6267\u884C\u6587\u4EF6\u4E0D\u5B58\u5728: ${u.QBOTCLAW_BIN}`});return}e.writeHead(200,{...C,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked","Cache-Control":"no-cache"}),(0,I.runQBotClaw)(o,e).then(()=>{e.end(`
2
2
  [\u6267\u884C\u6210\u529F]
3
3
  `)}).catch(s=>{e.end(`
4
4
  [\u542F\u52A8\u5931\u8D25: ${s.message}]
5
5
  `)})});return}if(f.startsWith("/api/uninstall")){const o=new URL(f,"http://localhost").searchParams.get("keepWorkspace")==="true";e.writeHead(200,{...C,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked","Cache-Control":"no-cache"});const s=(i,g,m)=>{if(e.writable)try{e.write(JSON.stringify({status:i,file:g,msg:m})+`
6
- `)}catch{}};try{s("\u6210\u529F","","\u6B63\u5728\u505C\u6B62 QBotClaw...");const i=(0,y.readState)();if(i.gatewayPid)try{process.kill(i.gatewayPid,"SIGTERM"),(0,r.log)(`[uninstall] \u5DF2\u505C\u6B62 QBotClaw gateway \u8FDB\u7A0B pid: ${i.gatewayPid}`),s("\u6210\u529F","",`\u5DF2\u505C\u6B62 QBotClaw gateway \u8FDB\u7A0B pid: ${i.gatewayPid}`)}catch{(0,r.log)(`[uninstall] QBotClaw gateway \u8FDB\u7A0B ${i.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA`),s("\u6210\u529F","",`QBotClaw gateway \u8FDB\u7A0B ${i.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA`)}else s("\u6210\u529F","","QBotClaw \u672A\u5728\u8FD0\u884C");s("\u6210\u529F","",`\u6B63\u5728\u6267\u884C npm uninstall -g ${u.NPM_PACKAGE_NAME}...`);try{await new Promise((m,c)=>{const l=(0,R.spawn)(u.NPM_BIN,["--userconfig",u.NPM_RC,"uninstall","-g",u.NPM_PACKAGE_NAME],{env:{...process.env,PATH:`${u.NODE_BIN_DIR}:${process.env.PATH}`}});l.stdout?.on("data",t=>{(0,r.log)(`[uninstall] npm: ${t.toString().trim()}`)}),l.stderr?.on("data",t=>{(0,r.log)(`[uninstall] npm stderr: ${t.toString().trim()}`)}),l.on("close",t=>{t===0?m():c(new Error(`npm uninstall \u9000\u51FA\u7801: ${t}`))}),l.on("error",t=>c(t))}),(0,r.log)(`[uninstall] npm uninstall -g ${u.NPM_PACKAGE_NAME} \u6210\u529F`),s("\u6210\u529F","",`npm uninstall -g ${u.NPM_PACKAGE_NAME} \u6210\u529F`)}catch(m){(0,r.log)(`[uninstall] npm uninstall \u5931\u8D25: ${m.message}`),s("\u5931\u8D25","",`npm uninstall \u5931\u8D25: ${m.message}`)}s("\u6210\u529F","",`\u6B63\u5728\u6E05\u7406\u76EE\u5F55 ${u.QBOT_CLAW_DIR}...`);const g=[];if(w.default.existsSync(u.QBOT_CLAW_DIR)){const m=w.default.readdirSync(u.QBOT_CLAW_DIR);for(const c of m){const l=I.default.join(u.QBOT_CLAW_DIR,c);if(o&&c==="workspace"){s("\u6210\u529F",l,"\u4FDD\u7559 workspace \u76EE\u5F55");continue}try{w.default.statSync(l).isDirectory()?w.default.rmSync(l,{recursive:!0,force:!0}):w.default.unlinkSync(l),s("\u6210\u529F",l,"\u5DF2\u5220\u9664")}catch(t){(0,r.log)(`[uninstall] \u5220\u9664\u5931\u8D25: ${l} - ${t.message}`),s("\u5931\u8D25",l,`\u5220\u9664\u5931\u8D25: ${t.message}`),g.push(l)}}if(g.length>0){s("\u6210\u529F","",`${g.length} \u4E2A\u9879\u76EE\u5220\u9664\u5931\u8D25\uFF0C\u4F7F\u7528 rm \u547D\u4EE4\u91CD\u8BD5...`);for(const c of g)try{(0,R.execSync)(`rm -rf "${c}"`),(0,r.log)(`[uninstall] rm -rf \u91CD\u8BD5\u6210\u529F: ${c}`),s("\u6210\u529F",c,"rm \u91CD\u8BD5\u5220\u9664\u6210\u529F")}catch(l){(0,r.log)(`[uninstall] rm -rf \u91CD\u8BD5\u4E5F\u5931\u8D25: ${c} - ${l.message}`),s("\u5931\u8D25",c,`rm \u91CD\u8BD5\u4E5F\u5931\u8D25: ${l.message}`)}}if(o)s("\u6210\u529F",u.QBOT_CLAW_DIR,"\u4FDD\u7559\u6839\u76EE\u5F55\uFF08workspace \u6A21\u5F0F\uFF09");else try{w.default.rmSync(u.QBOT_CLAW_DIR,{recursive:!0,force:!0}),s("\u6210\u529F",u.QBOT_CLAW_DIR,"\u5DF2\u5220\u9664\u6839\u76EE\u5F55")}catch(c){(0,r.log)(`[uninstall] \u5220\u9664\u6839\u76EE\u5F55\u5931\u8D25: ${c.message}`);try{(0,R.execSync)(`rm -rf "${u.QBOT_CLAW_DIR}"`),s("\u6210\u529F",u.QBOT_CLAW_DIR,"rm \u91CD\u8BD5\u5220\u9664\u6839\u76EE\u5F55\u6210\u529F")}catch(l){s("\u5931\u8D25",u.QBOT_CLAW_DIR,`\u5220\u9664\u6839\u76EE\u5F55\u5931\u8D25: ${l.message}`)}}}else s("\u6210\u529F",u.QBOT_CLAW_DIR,"\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u65E0\u9700\u6E05\u7406");s("\u6210\u529F","","\u5378\u8F7D\u5B8C\u6210")}catch(i){(0,r.log)(`[uninstall] \u5378\u8F7D\u8FC7\u7A0B\u5F02\u5E38: ${i.message}`),s("\u5931\u8D25","",`\u5378\u8F7D\u8FC7\u7A0B\u5F02\u5E38: ${i.message}`)}e.end(),setTimeout(()=>{(0,r.log)("[uninstall] \u5378\u8F7D\u6D41\u7A0B\u7ED3\u675F\uFF0Clauncher \u8FDB\u7A0B\u9000\u51FA"),process.exit(0)},500);return}if(f==="/api/file-picker"&&d.method==="POST"){const n=(0,B.authenticateRequest)(d);if(!n.ok){(0,a.sendJSON)(e,n.statusCode,{ok:!1,message:n.message});return}if((0,J.isFilePickerBusy)()){(0,a.sendJSON)(e,409,{ok:!1,code:P.DIALOG_BUSY,files:[],message:"\u5DF2\u6709\u6587\u4EF6\u9009\u62E9\u5BF9\u8BDD\u6846\u6B63\u5728\u663E\u793A\uFF0C\u8BF7\u7B49\u5F85\u5F53\u524D\u5BF9\u8BDD\u6846\u5173\u95ED\u540E\u91CD\u8BD5"});return}let o="";d.on("data",s=>{o+=s.toString()}),d.on("end",async()=>{let s=[],i=!1,g=H,m=M,c=F,l=b;if(o){let t;try{t=JSON.parse(o)}catch{(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u8BF7\u6C42\u4F53\u5FC5\u987B\u662F\u5408\u6CD5\u7684 JSON"});return}if(t.extensions!==void 0){if(!Array.isArray(t.extensions)||!t.extensions.every(p=>typeof p=="string")){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 extensions \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4"});return}s=t.extensions}if(t.multiple!==void 0){if(typeof t.multiple!="boolean"){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 multiple \u5FC5\u987B\u662F\u5E03\u5C14\u503C"});return}i=t.multiple}if(t.title!==void 0){if(typeof t.title!="string"||t.title.length>200){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 title \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u4E14\u957F\u5EA6\u4E0D\u8D85\u8FC7 200"});return}g=t.title}if(t.maxFileSize!==void 0){if(typeof t.maxFileSize!="number"||t.maxFileSize<=0||!Number.isFinite(t.maxFileSize)){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 maxFileSize \u5FC5\u987B\u662F\u6B63\u6570"});return}m=Math.min(t.maxFileSize,M)}if(t.maxFileCount!==void 0){if(typeof t.maxFileCount!="number"||t.maxFileCount<=0||!Number.isInteger(t.maxFileCount)){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 maxFileCount \u5FC5\u987B\u662F\u6B63\u6574\u6570"});return}c=Math.min(t.maxFileCount,F)}if(b&&t.allowDirectory!==void 0){if(typeof t.allowDirectory!="boolean"){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 allowDirectory \u5FC5\u987B\u662F\u5E03\u5C14\u503C"});return}l=t.allowDirectory}}i||(c=1);try{const t=await(0,J.showFilePicker)({extensions:s,multiple:i,title:g,allowDirectory:l});if(!t||t.length===0){(0,a.sendJSON)(e,200,{ok:!1,code:P.CANCELLED,files:[],message:"\u7528\u6237\u53D6\u6D88\u4E86\u6587\u4EF6\u9009\u62E9"});return}if(l){const N=t.slice(0,c).map(D=>({name:I.default.basename(D),path:D,size:0,mimeType:"inode/directory"})),h=t.length>c;(0,a.sendJSON)(e,200,{ok:!0,files:N,message:h?`\u5DF2\u9009\u62E9 ${N.length} \u4E2A\u76EE\u5F55\uFF08\u5171\u9009\u62E9 ${t.length} \u4E2A\uFF0C\u8D85\u51FA\u4E0A\u9650 ${c} \u4E2A\u5DF2\u622A\u65AD\uFF09`:`\u5DF2\u9009\u62E9 ${N.length} \u4E2A\u76EE\u5F55`});return}let p=!1,A=t;t.length>c&&(A=t.slice(0,c),p=!0);const O=[],S=[];for(const N of A){const h=(0,x.readFileInfo)(N,m);h.ok?O.push({name:h.name,path:h.path,size:h.size,mimeType:h.mimeType}):S.push({path:h.path,reason:h.reason,code:h.code})}const _=[];if(O.length>0&&_.push(`\u6210\u529F\u8BFB\u53D6 ${O.length} \u4E2A\u6587\u4EF6`),S.length>0){const N=S.map(h=>`${I.default.basename(h.path)}: ${h.reason}`).join("\uFF1B");_.push(`${S.length} \u4E2A\u6587\u4EF6\u5931\u8D25\uFF08${N}\uFF09`)}p&&_.push(`\u5171\u9009\u62E9 ${t.length} \u4E2A\u6587\u4EF6\uFF0C\u8D85\u51FA\u4E0A\u9650 ${c} \u4E2A\u5DF2\u622A\u65AD`);const k=O.length===0&&S.length>0;(0,a.sendJSON)(e,200,{ok:!k,code:k?S[0].code:void 0,files:O,failedFiles:S.length>0?S:void 0,message:_.join("\uFF1B")||"\u6587\u4EF6\u9009\u62E9\u6210\u529F"})}catch(t){(0,r.log)(`[file-picker] \u6587\u4EF6\u9009\u62E9\u5931\u8D25: ${t.message}`);let p=P.INTERNAL_ERROR;t.message.includes("\u8D85\u65F6")?p=P.DIALOG_TIMEOUT:t.message.includes("\u4E0D\u652F\u6301\u7684\u64CD\u4F5C\u7CFB\u7EDF\u5E73\u53F0")&&(p=P.PLATFORM_NOT_SUPPORTED),(0,a.sendJSON)(e,500,{ok:!1,code:p,files:[],message:`\u6587\u4EF6\u9009\u62E9\u5931\u8D25: ${t.message}`})}});return}if(f.startsWith("/api/reveal")){const n=(0,B.authenticateRequest)(d);if(!n.ok){(0,a.sendJSON)(e,n.statusCode,{status:"\u5931\u8D25",message:n.message});return}const s=new URL(f,"http://localhost").searchParams.get("path");if(!s){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path\uFF08\u9700 Base64 \u7F16\u7801\uFF09\uFF0C\u7528\u6CD5: GET /api/reveal?path=<base64\u7F16\u7801\u7684\u6587\u4EF6\u7EDD\u5BF9\u8DEF\u5F84>"});return}let i;try{i=Buffer.from(s,"base64").toString("utf-8")}catch{(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"path \u53C2\u6570 Base64 \u89E3\u7801\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u4F20\u5165\u5408\u6CD5\u7684 Base64 \u7F16\u7801\u5B57\u7B26\u4E32"});return}if(!i||i.trim()===""){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"Base64 \u89E3\u7801\u540E\u8DEF\u5F84\u4E3A\u7A7A"});return}const g=(0,x.validateFilePath)(i);if(!g.valid){const p=g.reason;p.includes("\u975E\u6CD5\u5B57\u7B26")?(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:p}):p.includes("\u4E0D\u5B58\u5728")?(0,a.sendJSON)(e,404,{status:"\u5931\u8D25",message:p}):p.includes("\u65E0\u6CD5\u89E3\u6790")?(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:p}):((0,r.log)(`[reveal] \u5B89\u5168\u68C0\u67E5\u88AB\u62D2\u7EDD: ${i}\uFF0C\u539F\u56E0: ${p}`),(0,a.sendJSON)(e,403,{status:"\u5931\u8D25",message:p}));return}const m=I.default.resolve(i),c=process.platform;let l,t;c==="darwin"?(l="open",t=["-R",m]):c==="win32"?(l="explorer",t=[`/select,${m}`]):(l="xdg-open",t=[I.default.dirname(m)]);try{await new Promise((p,A)=>{const O=(0,R.spawn)(l,t,{stdio:"ignore"}),S=setTimeout(()=>{O.kill(),A(new Error("\u6253\u5F00\u6587\u4EF6\u7BA1\u7406\u5668\u8D85\u65F6\uFF085\u79D2\uFF09"))},5e3);O.on("close",_=>{clearTimeout(S),_===0||_===1?p():A(new Error(`\u8FDB\u7A0B\u9000\u51FA\u7801: ${_}`))}),O.on("error",_=>{clearTimeout(S),A(_)})}),(0,r.log)(`[reveal] \u5DF2\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u663E\u793A: ${m}`),(0,a.sendJSON)(e,200,{status:"\u6210\u529F",message:`\u5DF2\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u663E\u793A: ${m}`})}catch(p){(0,r.log)(`[reveal] \u6253\u5F00\u6587\u4EF6\u7BA1\u7406\u5668\u5931\u8D25: ${p.message}`),(0,a.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u6253\u5F00\u6587\u4EF6\u7BA1\u7406\u5668\u5931\u8D25: ${p.message}`})}return}(0,a.sendJSON)(e,404,{status:"\u5931\u8D25",message:"\u63A5\u53E3\u4E0D\u5B58\u5728"})});let T=null,E=null;function W(d){if(!d)return;if(T&&E===d){(0,r.log)(`[watchParentProcess] \u5DF2\u5728\u76D1\u63A7\u7236\u8FDB\u7A0B ppid: ${d}\uFF0C\u8DF3\u8FC7\u91CD\u590D\u76D1\u542C`);return}T?((0,r.log)(`[watchParentProcess] \u5DF2\u6709\u76D1\u63A7\uFF08ppid: ${E}\uFF09\uFF0C\u505C\u6B62\u65E7\u7684\u76D1\u63A7\uFF0C\u91CD\u65B0\u76D1\u63A7 ppid: ${d}`),clearInterval(T),T=null,E=null):(0,r.log)(`[watchParentProcess] \u5F00\u59CB\u76D1\u63A7\u7236\u8FDB\u7A0B ppid: ${d}`);const e=setInterval(()=>{try{process.kill(d,0)}catch{(0,r.log)(`[watchParentProcess] \u7236\u8FDB\u7A0B ${d} \u5DF2\u9000\u51FA\uFF0C\u5F00\u59CB\u6E05\u7406\u5E76\u9000\u51FA`),clearInterval(e),T=null,E=null;const f=(0,y.readState)();if(f.gatewayPid)try{process.kill(f.gatewayPid,"SIGTERM"),(0,r.log)(`[watchParentProcess] \u5DF2\u53D1\u9001 SIGTERM \u7ED9 qbotclaw \u8FDB\u7A0B pid: ${f.gatewayPid}`)}catch{(0,r.log)(`[watchParentProcess] qbotclaw \u8FDB\u7A0B ${f.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA\uFF0C\u5FFD\u7565`)}(0,y.clearState)(),(0,r.log)("[watchParentProcess] \u72B6\u6001\u5DF2\u6E05\u7406\uFF0C\u5173\u95ED server \u5E76\u9000\u51FA"),exports.server.close(()=>{(0,r.log)("[watchParentProcess] server \u5DF2\u5173\u95ED\uFF0C\u8FDB\u7A0B\u9000\u51FA"),process.exit(0)}),setTimeout(()=>{(0,r.log)("[watchParentProcess] server.close \u8D85\u65F6\uFF0C\u5F3A\u5236\u9000\u51FA"),process.exit(0)},3e3).unref()}},3e3);e.unref(),T=e,E=d}
6
+ `)}catch{}};try{s("\u6210\u529F","","\u6B63\u5728\u505C\u6B62 QBotClaw...");const i=(0,y.readState)();if(i.gatewayPid)try{process.kill(i.gatewayPid,"SIGTERM"),(0,r.log)(`[uninstall] \u5DF2\u505C\u6B62 QBotClaw gateway \u8FDB\u7A0B pid: ${i.gatewayPid}`),s("\u6210\u529F","",`\u5DF2\u505C\u6B62 QBotClaw gateway \u8FDB\u7A0B pid: ${i.gatewayPid}`)}catch{(0,r.log)(`[uninstall] QBotClaw gateway \u8FDB\u7A0B ${i.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA`),s("\u6210\u529F","",`QBotClaw gateway \u8FDB\u7A0B ${i.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA`)}else s("\u6210\u529F","","QBotClaw \u672A\u5728\u8FD0\u884C");s("\u6210\u529F","",`\u6B63\u5728\u6267\u884C npm uninstall -g ${u.NPM_PACKAGE_NAME}...`);try{await new Promise((m,c)=>{const l=(0,R.spawn)(u.NPM_BIN,["--userconfig",u.NPM_RC,"uninstall","-g",u.NPM_PACKAGE_NAME],{env:{...process.env,PATH:`${u.NODE_BIN_DIR}:${process.env.PATH}`}});l.stdout?.on("data",t=>{(0,r.log)(`[uninstall] npm: ${t.toString().trim()}`)}),l.stderr?.on("data",t=>{(0,r.log)(`[uninstall] npm stderr: ${t.toString().trim()}`)}),l.on("close",t=>{t===0?m():c(new Error(`npm uninstall \u9000\u51FA\u7801: ${t}`))}),l.on("error",t=>c(t))}),(0,r.log)(`[uninstall] npm uninstall -g ${u.NPM_PACKAGE_NAME} \u6210\u529F`),s("\u6210\u529F","",`npm uninstall -g ${u.NPM_PACKAGE_NAME} \u6210\u529F`)}catch(m){(0,r.log)(`[uninstall] npm uninstall \u5931\u8D25: ${m.message}`),s("\u5931\u8D25","",`npm uninstall \u5931\u8D25: ${m.message}`)}s("\u6210\u529F","",`\u6B63\u5728\u6E05\u7406\u76EE\u5F55 ${u.QBOT_CLAW_DIR}...`);const g=[];if(w.default.existsSync(u.QBOT_CLAW_DIR)){const m=w.default.readdirSync(u.QBOT_CLAW_DIR);for(const c of m){const l=$.default.join(u.QBOT_CLAW_DIR,c);if(o&&c==="workspace"){s("\u6210\u529F",l,"\u4FDD\u7559 workspace \u76EE\u5F55");continue}try{w.default.statSync(l).isDirectory()?w.default.rmSync(l,{recursive:!0,force:!0}):w.default.unlinkSync(l),s("\u6210\u529F",l,"\u5DF2\u5220\u9664")}catch(t){(0,r.log)(`[uninstall] \u5220\u9664\u5931\u8D25: ${l} - ${t.message}`),s("\u5931\u8D25",l,`\u5220\u9664\u5931\u8D25: ${t.message}`),g.push(l)}}if(g.length>0){s("\u6210\u529F","",`${g.length} \u4E2A\u9879\u76EE\u5220\u9664\u5931\u8D25\uFF0C\u4F7F\u7528 rm \u547D\u4EE4\u91CD\u8BD5...`);for(const c of g)try{(0,R.execSync)(`rm -rf "${c}"`),(0,r.log)(`[uninstall] rm -rf \u91CD\u8BD5\u6210\u529F: ${c}`),s("\u6210\u529F",c,"rm \u91CD\u8BD5\u5220\u9664\u6210\u529F")}catch(l){(0,r.log)(`[uninstall] rm -rf \u91CD\u8BD5\u4E5F\u5931\u8D25: ${c} - ${l.message}`),s("\u5931\u8D25",c,`rm \u91CD\u8BD5\u4E5F\u5931\u8D25: ${l.message}`)}}if(o)s("\u6210\u529F",u.QBOT_CLAW_DIR,"\u4FDD\u7559\u6839\u76EE\u5F55\uFF08workspace \u6A21\u5F0F\uFF09");else try{w.default.rmSync(u.QBOT_CLAW_DIR,{recursive:!0,force:!0}),s("\u6210\u529F",u.QBOT_CLAW_DIR,"\u5DF2\u5220\u9664\u6839\u76EE\u5F55")}catch(c){(0,r.log)(`[uninstall] \u5220\u9664\u6839\u76EE\u5F55\u5931\u8D25: ${c.message}`);try{(0,R.execSync)(`rm -rf "${u.QBOT_CLAW_DIR}"`),s("\u6210\u529F",u.QBOT_CLAW_DIR,"rm \u91CD\u8BD5\u5220\u9664\u6839\u76EE\u5F55\u6210\u529F")}catch(l){s("\u5931\u8D25",u.QBOT_CLAW_DIR,`\u5220\u9664\u6839\u76EE\u5F55\u5931\u8D25: ${l.message}`)}}}else s("\u6210\u529F",u.QBOT_CLAW_DIR,"\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u65E0\u9700\u6E05\u7406");s("\u6210\u529F","","\u5378\u8F7D\u5B8C\u6210")}catch(i){(0,r.log)(`[uninstall] \u5378\u8F7D\u8FC7\u7A0B\u5F02\u5E38: ${i.message}`),s("\u5931\u8D25","",`\u5378\u8F7D\u8FC7\u7A0B\u5F02\u5E38: ${i.message}`)}e.end(),setTimeout(()=>{(0,r.log)("[uninstall] \u5378\u8F7D\u6D41\u7A0B\u7ED3\u675F\uFF0Clauncher \u8FDB\u7A0B\u9000\u51FA"),process.exit(0)},500);return}if(f==="/api/file-picker"&&d.method==="POST"){const n=(0,B.authenticateRequest)(d);if(!n.ok){(0,a.sendJSON)(e,n.statusCode,{ok:!1,message:n.message});return}if((0,J.isFilePickerBusy)()){(0,a.sendJSON)(e,409,{ok:!1,code:P.DIALOG_BUSY,files:[],message:"\u5DF2\u6709\u6587\u4EF6\u9009\u62E9\u5BF9\u8BDD\u6846\u6B63\u5728\u663E\u793A\uFF0C\u8BF7\u7B49\u5F85\u5F53\u524D\u5BF9\u8BDD\u6846\u5173\u95ED\u540E\u91CD\u8BD5"});return}let o="";d.on("data",s=>{o+=s.toString()}),d.on("end",async()=>{let s=[],i=!1,g=H,m=M,c=F,l=b;if(o){let t;try{t=JSON.parse(o)}catch{(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u8BF7\u6C42\u4F53\u5FC5\u987B\u662F\u5408\u6CD5\u7684 JSON"});return}if(t.extensions!==void 0){if(!Array.isArray(t.extensions)||!t.extensions.every(p=>typeof p=="string")){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 extensions \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4"});return}s=t.extensions}if(t.multiple!==void 0){if(typeof t.multiple!="boolean"){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 multiple \u5FC5\u987B\u662F\u5E03\u5C14\u503C"});return}i=t.multiple}if(t.title!==void 0){if(typeof t.title!="string"||t.title.length>200){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 title \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u4E14\u957F\u5EA6\u4E0D\u8D85\u8FC7 200"});return}g=t.title}if(t.maxFileSize!==void 0){if(typeof t.maxFileSize!="number"||t.maxFileSize<=0||!Number.isFinite(t.maxFileSize)){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 maxFileSize \u5FC5\u987B\u662F\u6B63\u6570"});return}m=Math.min(t.maxFileSize,M)}if(t.maxFileCount!==void 0){if(typeof t.maxFileCount!="number"||t.maxFileCount<=0||!Number.isInteger(t.maxFileCount)){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 maxFileCount \u5FC5\u987B\u662F\u6B63\u6574\u6570"});return}c=Math.min(t.maxFileCount,F)}if(b&&t.allowDirectory!==void 0){if(typeof t.allowDirectory!="boolean"){(0,a.sendJSON)(e,400,{ok:!1,code:P.INVALID_PARAMS,files:[],message:"\u53C2\u6570 allowDirectory \u5FC5\u987B\u662F\u5E03\u5C14\u503C"});return}l=t.allowDirectory}}i||(c=1);try{const t=await(0,J.showFilePicker)({extensions:s,multiple:i,title:g,allowDirectory:l});if(!t||t.length===0){(0,a.sendJSON)(e,200,{ok:!1,code:P.CANCELLED,files:[],message:"\u7528\u6237\u53D6\u6D88\u4E86\u6587\u4EF6\u9009\u62E9"});return}if(l){const N=t.slice(0,c).map(D=>({name:$.default.basename(D),path:D,size:0,mimeType:"inode/directory"})),h=t.length>c;(0,a.sendJSON)(e,200,{ok:!0,files:N,message:h?`\u5DF2\u9009\u62E9 ${N.length} \u4E2A\u76EE\u5F55\uFF08\u5171\u9009\u62E9 ${t.length} \u4E2A\uFF0C\u8D85\u51FA\u4E0A\u9650 ${c} \u4E2A\u5DF2\u622A\u65AD\uFF09`:`\u5DF2\u9009\u62E9 ${N.length} \u4E2A\u76EE\u5F55`});return}let p=!1,A=t;t.length>c&&(A=t.slice(0,c),p=!0);const O=[],S=[];for(const N of A){const h=(0,x.readFileInfo)(N,m);h.ok?O.push({name:h.name,path:h.path,size:h.size,mimeType:h.mimeType}):S.push({path:h.path,reason:h.reason,code:h.code})}const _=[];if(O.length>0&&_.push(`\u6210\u529F\u8BFB\u53D6 ${O.length} \u4E2A\u6587\u4EF6`),S.length>0){const N=S.map(h=>`${$.default.basename(h.path)}: ${h.reason}`).join("\uFF1B");_.push(`${S.length} \u4E2A\u6587\u4EF6\u5931\u8D25\uFF08${N}\uFF09`)}p&&_.push(`\u5171\u9009\u62E9 ${t.length} \u4E2A\u6587\u4EF6\uFF0C\u8D85\u51FA\u4E0A\u9650 ${c} \u4E2A\u5DF2\u622A\u65AD`);const k=O.length===0&&S.length>0;(0,a.sendJSON)(e,200,{ok:!k,code:k?S[0].code:void 0,files:O,failedFiles:S.length>0?S:void 0,message:_.join("\uFF1B")||"\u6587\u4EF6\u9009\u62E9\u6210\u529F"})}catch(t){(0,r.log)(`[file-picker] \u6587\u4EF6\u9009\u62E9\u5931\u8D25: ${t.message}`);let p=P.INTERNAL_ERROR;t.message.includes("\u8D85\u65F6")?p=P.DIALOG_TIMEOUT:t.message.includes("\u4E0D\u652F\u6301\u7684\u64CD\u4F5C\u7CFB\u7EDF\u5E73\u53F0")&&(p=P.PLATFORM_NOT_SUPPORTED),(0,a.sendJSON)(e,500,{ok:!1,code:p,files:[],message:`\u6587\u4EF6\u9009\u62E9\u5931\u8D25: ${t.message}`})}});return}if(f.startsWith("/api/reveal")){console.log(`[reveal] \u5B8C\u6574URL: ${f}`);const n=(0,B.authenticateRequest)(d);if(!n.ok){(0,a.sendJSON)(e,n.statusCode,{status:"\u5931\u8D25",message:n.message});return}const s=new URL(f,"http://localhost").searchParams.get("path")?.replace(/ /g,"+")??null;if(!s){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 path\uFF08\u9700 Base64 \u7F16\u7801\uFF09\uFF0C\u7528\u6CD5: GET /api/reveal?path=<base64\u7F16\u7801\u7684\u6587\u4EF6\u7EDD\u5BF9\u8DEF\u5F84>"});return}let i;try{i=Buffer.from(s,"base64").toString("utf-8")}catch{(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"path \u53C2\u6570 Base64 \u89E3\u7801\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u4F20\u5165\u5408\u6CD5\u7684 Base64 \u7F16\u7801\u5B57\u7B26\u4E32"});return}if(!i||i.trim()===""){(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:"Base64 \u89E3\u7801\u540E\u8DEF\u5F84\u4E3A\u7A7A"});return}const g=(0,x.validateFilePath)(i);if(!g.valid){const p=g.reason;p.includes("\u975E\u6CD5\u5B57\u7B26")?(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:p}):p.includes("\u4E0D\u5B58\u5728")?(0,a.sendJSON)(e,404,{status:"\u5931\u8D25",message:p}):p.includes("\u65E0\u6CD5\u89E3\u6790")?(0,a.sendJSON)(e,400,{status:"\u5931\u8D25",message:p}):((0,r.log)(`[reveal] \u5B89\u5168\u68C0\u67E5\u88AB\u62D2\u7EDD: ${i}\uFF0C\u539F\u56E0: ${p}`),(0,a.sendJSON)(e,403,{status:"\u5931\u8D25",message:p}));return}const m=$.default.resolve(i),c=process.platform;let l,t;c==="darwin"?(l="open",t=["-R",m]):c==="win32"?(l="explorer",t=[`/select,${m}`]):(l="xdg-open",t=[$.default.dirname(m)]);try{await new Promise((p,A)=>{const O=(0,R.spawn)(l,t,{stdio:"ignore"}),S=setTimeout(()=>{O.kill(),A(new Error("\u6253\u5F00\u6587\u4EF6\u7BA1\u7406\u5668\u8D85\u65F6\uFF085\u79D2\uFF09"))},5e3);O.on("close",_=>{clearTimeout(S),_===0||_===1?p():A(new Error(`\u8FDB\u7A0B\u9000\u51FA\u7801: ${_}`))}),O.on("error",_=>{clearTimeout(S),A(_)})}),(0,r.log)(`[reveal] \u5DF2\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u663E\u793A: ${m}`),(0,a.sendJSON)(e,200,{status:"\u6210\u529F",message:`\u5DF2\u5728\u6587\u4EF6\u7BA1\u7406\u5668\u4E2D\u663E\u793A: ${m}`})}catch(p){(0,r.log)(`[reveal] \u6253\u5F00\u6587\u4EF6\u7BA1\u7406\u5668\u5931\u8D25: ${p.message}`),(0,a.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u6253\u5F00\u6587\u4EF6\u7BA1\u7406\u5668\u5931\u8D25: ${p.message}`})}return}(0,a.sendJSON)(e,404,{status:"\u5931\u8D25",message:"\u63A5\u53E3\u4E0D\u5B58\u5728"})});let T=null,E=null;function W(d){if(!d)return;if(T&&E===d){(0,r.log)(`[watchParentProcess] \u5DF2\u5728\u76D1\u63A7\u7236\u8FDB\u7A0B ppid: ${d}\uFF0C\u8DF3\u8FC7\u91CD\u590D\u76D1\u542C`);return}T?((0,r.log)(`[watchParentProcess] \u5DF2\u6709\u76D1\u63A7\uFF08ppid: ${E}\uFF09\uFF0C\u505C\u6B62\u65E7\u7684\u76D1\u63A7\uFF0C\u91CD\u65B0\u76D1\u63A7 ppid: ${d}`),clearInterval(T),T=null,E=null):(0,r.log)(`[watchParentProcess] \u5F00\u59CB\u76D1\u63A7\u7236\u8FDB\u7A0B ppid: ${d}`);const e=setInterval(()=>{try{process.kill(d,0)}catch{(0,r.log)(`[watchParentProcess] \u7236\u8FDB\u7A0B ${d} \u5DF2\u9000\u51FA\uFF0C\u5F00\u59CB\u6E05\u7406\u5E76\u9000\u51FA`),clearInterval(e),T=null,E=null;const f=(0,y.readState)();if(f.gatewayPid)try{process.kill(f.gatewayPid,"SIGTERM"),(0,r.log)(`[watchParentProcess] \u5DF2\u53D1\u9001 SIGTERM \u7ED9 qbotclaw \u8FDB\u7A0B pid: ${f.gatewayPid}`)}catch{(0,r.log)(`[watchParentProcess] qbotclaw \u8FDB\u7A0B ${f.gatewayPid} \u53EF\u80FD\u5DF2\u9000\u51FA\uFF0C\u5FFD\u7565`)}(0,y.clearState)(),(0,r.log)("[watchParentProcess] \u72B6\u6001\u5DF2\u6E05\u7406\uFF0C\u5173\u95ED server \u5E76\u9000\u51FA"),exports.server.close(()=>{(0,r.log)("[watchParentProcess] server \u5DF2\u5173\u95ED\uFF0C\u8FDB\u7A0B\u9000\u51FA"),process.exit(0)}),setTimeout(()=>{(0,r.log)("[watchParentProcess] server.close \u8D85\u65F6\uFF0C\u5F3A\u5236\u9000\u51FA"),process.exit(0)},3e3).unref()}},3e3);e.unref(),T=e,E=d}
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LAUNCHER_VERSION=void 0,exports.LAUNCHER_VERSION="0.9.69";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LAUNCHER_VERSION=void 0,exports.LAUNCHER_VERSION="0.9.71";
@@ -265,17 +265,6 @@ Compile a regular expression from the `state` object returned by the
265
265
  * `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
266
266
  * `returns` **{RegExp}**
267
267
 
268
- **Example**
269
-
270
- ```js
271
- const picomatch = require('picomatch');
272
- const state = picomatch.parse('*.js');
273
- // picomatch.compileRe(state[, options]);
274
-
275
- console.log(picomatch.compileRe(state));
276
- //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
277
- ```
278
-
279
268
  ### [.makeRe](lib/picomatch.js#L285)
280
269
 
281
270
  Create a regular expression from a parsed glob pattern.
@@ -292,10 +281,10 @@ Create a regular expression from a parsed glob pattern.
292
281
 
293
282
  ```js
294
283
  const picomatch = require('picomatch');
295
- // picomatch.makeRe(state[, options]);
284
+ const state = picomatch.parse('*.js');
285
+ // picomatch.compileRe(state[, options]);
296
286
 
297
- const result = picomatch.makeRe('*.js');
298
- console.log(result);
287
+ console.log(picomatch.compileRe(state));
299
288
  //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
300
289
  ```
301
290
 
@@ -334,9 +323,11 @@ The following options may be used with the main `picomatch()` function or any of
334
323
  | `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |
335
324
  | `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |
336
325
  | `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |
326
+ | `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` |
337
327
  | `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |
338
328
  | `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |
339
329
  | `expandRange` | `function` | `undefined` | Custom function for expanding ranges in brace patterns, such as `{a..z}`. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. |
330
+ | `failglob` | `boolean` | `false` | Throws an error if no matches are found. Based on the bash option of the same name. |
340
331
  | `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. |
341
332
  | `flags` | `string` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
342
333
  | [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. |
@@ -345,23 +336,26 @@ The following options may be used with the main `picomatch()` function or any of
345
336
  | `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
346
337
  | `matchBase` | `boolean` | `false` | Alias for `basename` |
347
338
  | `maxLength` | `number` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
348
- | `maxExtglobRecursion` | `number\|boolean` | `0` | Limit nested quantified extglobs and other risky repeated extglob forms. When the limit is exceeded, the extglob is treated as a literal string instead of being compiled to regex. Set to `false` to disable this safeguard. |
349
339
  | `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
350
340
  | `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |
351
341
  | `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |
342
+ | `nodupes` | `boolean` | `true` | Deprecated, use `nounique` instead. This option will be removed in a future major release. By default duplicates are removed. Disable uniquification by setting this option to false. |
352
343
  | `noext` | `boolean` | `false` | Alias for `noextglob` |
353
344
  | `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |
354
345
  | `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |
355
346
  | `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |
347
+ | `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. |
356
348
  | [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |
357
349
  | [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |
358
350
  | [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
359
351
  | `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |
352
+ | `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself |
360
353
  | `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |
361
354
  | `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
362
355
  | `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
363
356
  | `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
364
357
  | `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
358
+ | `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatibility. |
365
359
  | `windows` | `boolean` | `false` | Also accept backslashes as the path separator. |
366
360
 
367
361
  ### Scan Options
@@ -555,13 +549,6 @@ console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
555
549
 
556
550
  // supports nested extglobs
557
551
  console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
558
-
559
- // risky quantified extglobs are treated literally by default
560
- console.log(pm.makeRe('+(a|aa)'));
561
- //=> /^(?:\+\(a\|aa\))$/
562
-
563
- // increase the limit to allow a small amount of nested quantified extglobs
564
- console.log(pm.isMatch('aaa', '+(+(a))', { maxExtglobRecursion: 1 })); // true
565
552
  ```
566
553
 
567
554
  #### POSIX brackets
@@ -598,7 +585,7 @@ See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_no
598
585
 
599
586
  ### Braces
600
587
 
601
- Picomatch only does [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) of comma-delimited lists (e.g. `a/{b,c}/d`). For advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch), which supports advanced syntax such as ranges (e.g. `{01..03}`) and increments (e.g. `{2..10..2}`).
588
+ Picomatch does not do brace expansion. For [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) and advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch) instead. Picomatch has very basic support for braces.
602
589
 
603
590
  ### Matching special characters as literals
604
591
 
@@ -642,42 +629,44 @@ The following table shows which features are supported by [minimatch](https://gi
642
629
 
643
630
  Performance comparison of picomatch and minimatch.
644
631
 
632
+ _(Pay special attention to the last three benchmarks. Minimatch freezes on long ranges.)_
633
+
645
634
  ```
646
635
  # .makeRe star (*)
647
- picomatch x 3,251,247 ops/sec ±0.25% (95 runs sampled)
648
- minimatch x 497,224 ops/sec ±0.11% (100 runs sampled)
636
+ picomatch x 4,449,159 ops/sec ±0.24% (97 runs sampled)
637
+ minimatch x 632,772 ops/sec ±0.14% (98 runs sampled)
649
638
 
650
639
  # .makeRe star; dot=true (*)
651
- picomatch x 2,624,035 ops/sec ±0.16% (98 runs sampled)
652
- minimatch x 446,244 ops/sec ±0.63% (99 runs sampled)
640
+ picomatch x 3,500,079 ops/sec ±0.26% (99 runs sampled)
641
+ minimatch x 564,916 ops/sec ±0.23% (96 runs sampled)
653
642
 
654
643
  # .makeRe globstar (**)
655
- picomatch x 2,524,465 ops/sec ±0.13% (99 runs sampled)
656
- minimatch x 1,396,257 ops/sec ±0.58% (96 runs sampled)
644
+ picomatch x 3,261,000 ops/sec ±0.27% (98 runs sampled)
645
+ minimatch x 1,664,766 ops/sec ±0.20% (100 runs sampled)
657
646
 
658
647
  # .makeRe globstars (**/**/**)
659
- picomatch x 2,545,674 ops/sec ±0.10% (99 runs sampled)
660
- minimatch x 1,196,835 ops/sec ±0.63% (98 runs sampled)
648
+ picomatch x 3,284,469 ops/sec ±0.18% (97 runs sampled)
649
+ minimatch x 1,435,880 ops/sec ±0.34% (95 runs sampled)
661
650
 
662
651
  # .makeRe with leading star (*.txt)
663
- picomatch x 2,537,708 ops/sec ±0.11% (100 runs sampled)
664
- minimatch x 345,284 ops/sec ±0.64% (96 runs sampled)
652
+ picomatch x 3,100,197 ops/sec ±0.35% (99 runs sampled)
653
+ minimatch x 428,347 ops/sec ±0.42% (94 runs sampled)
665
654
 
666
655
  # .makeRe - basic braces ({a,b,c}*.txt)
667
- picomatch x 505,430 ops/sec ±1.04% (94 runs sampled)
668
- minimatch x 107,991 ops/sec ±0.54% (99 runs sampled)
656
+ picomatch x 443,578 ops/sec ±1.33% (89 runs sampled)
657
+ minimatch x 107,143 ops/sec ±0.35% (94 runs sampled)
669
658
 
670
659
  # .makeRe - short ranges ({a..z}*.txt)
671
- picomatch x 371,179 ops/sec ±2.91% (77 runs sampled)
672
- minimatch x 14,104 ops/sec ±0.61% (99 runs sampled)
660
+ picomatch x 415,484 ops/sec ±0.76% (96 runs sampled)
661
+ minimatch x 14,299 ops/sec ±0.26% (96 runs sampled)
673
662
 
674
663
  # .makeRe - medium ranges ({1..100000}*.txt)
675
- picomatch x 384,958 ops/sec ±1.70% (82 runs sampled)
676
- minimatch x 2.55 ops/sec ±3.22% (11 runs sampled)
664
+ picomatch x 395,020 ops/sec ±0.87% (89 runs sampled)
665
+ minimatch x 2 ops/sec ±4.59% (10 runs sampled)
677
666
 
678
667
  # .makeRe - long ranges ({1..10000000}*.txt)
679
- picomatch x 382,552 ops/sec ±1.52% (71 runs sampled)
680
- minimatch x 0.83 ops/sec ±5.67% (7 runs sampled))
668
+ picomatch x 400,036 ops/sec ±0.83% (90 runs sampled)
669
+ minimatch (FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory)
681
670
  ```
682
671
 
683
672
  <br>
@@ -3,8 +3,6 @@
3
3
  const WIN_SLASH = '\\\\/';
4
4
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
5
5
 
6
- const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
7
-
8
6
  /**
9
7
  * Posix glob regex
10
8
  */
@@ -71,7 +69,6 @@ const WINDOWS_CHARS = {
71
69
  */
72
70
 
73
71
  const POSIX_REGEX_SOURCE = {
74
- __proto__: null,
75
72
  alnum: 'a-zA-Z0-9',
76
73
  alpha: 'a-zA-Z',
77
74
  ascii: '\\x00-\\x7F',
@@ -89,7 +86,6 @@ const POSIX_REGEX_SOURCE = {
89
86
  };
90
87
 
91
88
  module.exports = {
92
- DEFAULT_MAX_EXTGLOB_RECURSION,
93
89
  MAX_LENGTH: 1024 * 64,
94
90
  POSIX_REGEX_SOURCE,
95
91