@qqbrowser/qbot-claw-launcher 0.10.11 → 0.10.13
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/build.js +1 -1
- package/dist/installer.js +9 -9
- package/dist/openai-proxy.js +1 -1
- package/dist/qbotclaw-routes.js +1 -1
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IS_DEBUG_BUILD=exports.LAUNCHER_VERSION=void 0,exports.LAUNCHER_VERSION="0.10.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IS_DEBUG_BUILD=exports.LAUNCHER_VERSION=void 0,exports.LAUNCHER_VERSION="0.10.13",exports.IS_DEBUG_BUILD=!1;
|
package/dist/installer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`;N(t,n);for(const r of I)r!==t&&N(r,n)}function
|
|
3
|
-
`;for(const i of I)if(i&&i.writable)try{i.end(e)}catch{}I.length=0}exports.installState={status:"idle",message:"\u672A\u5F00\u59CB"},exports.isInstalling=!1;function T(t,e){return(0,
|
|
4
|
-
`);c.default.writeFileSync(e,i,"utf-8"),(0,
|
|
5
|
-
${
|
|
1
|
+
"use strict";var $=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=T,exports.configAndRunQBotClaw=C,exports.runInstall=b;const c=$(require("fs")),_=$(require("path")),E=require("child_process"),a=require("./config");Object.defineProperty(exports,"PYTHON_DIR",{enumerable:!0,get:function(){return a.PYTHON_DIR}});const A=require("./utils"),w=require("./state"),o=require("./reportLog"),O=require("./service"),L=require("./openai-proxy"),f=require("./report"),B=require("./qqbrowser-skill-installer");let m="qqbrowser-skill-control";const I=[];function N(t,e){if(t&&t.writable)try{t.write(e)}catch{}}function d(t,e,i,l){const s=e>0?Math.round(i/e*1e4)/100:0,n=JSON.stringify({status:"downloading",progress:s,totalSteps:e,currentStep:i,message:l})+`
|
|
2
|
+
`;N(t,n);for(const r of I)r!==t&&N(r,n)}function y(t){const e=t+`
|
|
3
|
+
`;for(const i of I)if(i&&i.writable)try{i.end(e)}catch{}I.length=0}exports.installState={status:"idle",message:"\u672A\u5F00\u59CB"},exports.isInstalling=!1;function T(t,e){return(0,o.log)(`[QBotClaw] \u6267\u884C: QBotClaw ${t.join(" ")}`),new Promise(i=>{const l=(0,w.readState)(),s={...process.platform==="win32"?process.env:{},PATH:`${a.NODE_BIN_DIR}${_.default.delimiter}${process.env.PATH||""}`,HOME:process.env.HOME||process.env.USERPROFILE,USERPROFILE:process.env.USERPROFILE,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:${l.port}/v1`,QBOTCLAW_LLM_API_KEY:L.proxyApiKey};let n;if(process.platform==="win32"){const r=t.map(u=>/[" \t]/.test(u)?`"${u.replace(/"/g,'\\"')}"`:u),g=`"${a.QBOTCLAW_BIN}" ${r.join(" ")}`;n=(0,E.spawn)("cmd.exe",["/d","/s","/c",`"${g}"`],{stdio:["ignore","pipe","pipe"],windowsHide:!0,windowsVerbatimArguments:!0,env:s})}else n=(0,E.spawn)(a.QBOTCLAW_BIN,t,{stdio:["ignore","pipe","pipe"],windowsHide:!0,env:s});(0,o.log)(`[QBotClaw] \u6267\u884C: QBotClaw ${t.join(" ")}`),n.stdout.on("data",r=>{const g=r.toString();if(e&&e.writable)try{e.write(g)}catch{}}),n.stderr.on("data",r=>{const g=r.toString();if(e&&e.writable)try{e.write(g)}catch{}}),n.on("close",r=>{(0,o.log)(`[QBotClaw] \u6267\u884C\u5B8C\u6210\uFF0C\u9000\u51FA\u7801: ${r}`),i()}),n.on("error",r=>{(0,o.log)(`[QBotClaw] \u542F\u52A8\u5931\u8D25: ${r.message}`),i()})})}function Q(){c.default.existsSync(a.QBOT_CLAW_DIR)||c.default.mkdirSync(a.QBOT_CLAW_DIR,{recursive:!0})}function h(){const t=process.platform==="win32"?"pip.ini":"pip.conf",e=_.default.join(a.PYTHON_DIR,t);if(c.default.existsSync(e)){(0,o.log)(`${t} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7`);return}const i=["[global]","index-url = https://mirrors.tencent.com/pypi/simple/",`cache-dir = ${_.default.join(a.PYTHON_DIR,".pip-cache")}`,"","[install]",`prefix = ${a.PYTHON_DIR}`,""].join(`
|
|
4
|
+
`);c.default.writeFileSync(e,i,"utf-8"),(0,o.log)(`\u5DF2\u5199\u5165 ${t}: ${e}`)}function S(t,e){return new Promise((i,l)=>{const s=(0,E.spawn)(a.NPM_BIN,["--userconfig",a.NPM_RC,...t],{stdio:["ignore","pipe","pipe"],shell:process.platform==="win32",windowsHide:!0,env:{...process.env,PATH:`${_.default.dirname(a.NPM_BIN)}${_.default.delimiter}${process.env.PATH}`}});s.stdout.on("data",n=>{const r=`[npm] ${n.toString().trim()}`;(0,o.log)(r)}),s.stderr.on("data",n=>{const r=`[npm] ${n.toString().trim()}`;(0,o.log)(r)}),s.on("close",n=>{n===0?((0,o.log)(`${e} \u6210\u529F`),i()):l(new Error(`${e} \u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${n}`))}),s.on("error",l)})}function R(){const t=_.default.join(a.QBOT_CLAW_DIR,"node",".npm-cache","_logs");try{if(!c.default.existsSync(t)){(0,o.log)(`[dumpNpmLogs] npm \u65E5\u5FD7\u76EE\u5F55\u4E0D\u5B58\u5728: ${t}`);return}const e=c.default.readdirSync(t).filter(i=>c.default.statSync(_.default.join(t,i)).isFile()).sort((i,l)=>{const s=c.default.statSync(_.default.join(t,i));return c.default.statSync(_.default.join(t,l)).mtimeMs-s.mtimeMs}).slice(0,3);if(e.length===0){(0,o.log)(`[dumpNpmLogs] npm \u65E5\u5FD7\u76EE\u5F55\u4E3A\u7A7A: ${t}`);return}(0,o.log)(`[dumpNpmLogs] \u8BFB\u53D6\u6700\u65B0\u7684 ${e.length} \u4E2A npm \u65E5\u5FD7\u6587\u4EF6:`);for(const i of e){const l=_.default.join(t,i);try{const s=c.default.readFileSync(l,"utf-8");(0,o.log)(`[npm-log] ===== ${i} =====
|
|
5
|
+
${s}`)}catch(s){(0,o.log)(`[npm-log] \u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u5931\u8D25 ${i}: ${s.message}`)}}}catch(e){(0,o.log)(`[dumpNpmLogs] \u8BFB\u53D6 npm \u65E5\u5FD7\u76EE\u5F55\u5931\u8D25: ${e.message}`)}}async function v(t){const e=`${a.NPM_PACKAGE_NAME}@${t}`,i=`${e} \u4E0B\u8F7D\u89E3\u538B`;(0,o.log)(`\u5F00\u59CB\u5B89\u88C5 ${e}\uFF08--ignore-scripts\uFF0C\u4EC5\u4E0B\u8F7D\u89E3\u538B\uFF09...`);let l;for(let s=0;s<a.NPM_REGISTRIES.length;s++){const n=a.NPM_REGISTRIES[s];try{(0,o.log)(`[${i}] \u5C1D\u8BD5\u4F7F\u7528\u6E90 (${s+1}/${a.NPM_REGISTRIES.length}): ${n}`),await S(["install","-g","--ignore-scripts","--registry",n,e],i);return}catch(r){l=r,(0,o.log)(`[${i}] \u6E90 ${n} \u5931\u8D25: ${r.message}`),s<a.NPM_REGISTRIES.length-1&&(0,o.log)(`[${i}] \u5C06\u5C1D\u8BD5\u4E0B\u4E00\u4E2A\u6E90...`)}}throw(0,o.log)(`\u5B89\u88C5 ${e} \u6240\u6709\u6E90\u5747\u5931\u8D25`),R(),l}async function D(t){const e=`${a.NPM_PACKAGE_NAME}@${t}`;(0,o.log)("\u5F00\u59CB npm rebuild\uFF08\u6267\u884C postinstall \u811A\u672C\uFF09..."),await S(["rebuild","-g",a.NPM_PACKAGE_NAME],`${e} rebuild`),(0,o.log)(`${e} \u5B89\u88C5\u6210\u529F`)}async function M(t,e,i,l){try{const r=process.platform==="win32"?`"${a.QBOTCLAW_BIN}" config validate --json`:`"${a.NODE_BIN}" "${a.QBOTCLAW_BIN}" config validate --json`,g=await(0,A.execCommand)(r);(0,o.log)(`[config validate] \u8F93\u51FA: ${g}`);const u=JSON.parse(g);u.valid!==!0?((0,o.log)(`[config validate] \u914D\u7F6E\u6821\u9A8C\u672A\u901A\u8FC7\uFF08valid=${u.valid}\uFF09\uFF0C\u5F3A\u5236\u8986\u76D6\u914D\u7F6E`),l=!0):(0,o.log)("[config validate] \u914D\u7F6E\u6821\u9A8C\u901A\u8FC7")}catch(r){(0,o.log)(`[config validate] \u6267\u884C\u5931\u8D25: ${r.message}\uFF0C\u5F3A\u5236\u8986\u76D6\u914D\u7F6E`),l=!0}let s;if((0,o.log)(`\u8986\u76D6\u7528\u6237\u5DF2\u6709\u914D\u7F6E: ${l}`),!l&&c.default.existsSync(a.QBOT_CLAW_CONFIG_PATH))s=a.QBOT_CLAW_CONFIG_PATH,(0,o.log)(`\u4F7F\u7528\u5DF2\u6709\u914D\u7F6E\u6587\u4EF6: ${s}`);else{const r=_.default.join(a.NPM_GLOBAL_MODULES,a.NPM_PACKAGE_NAME,"preset-config.json");if(!c.default.existsSync(r)){(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: ${r}`);return}s=r,(0,o.log)(`\u4F7F\u7528 npm \u5168\u5C40\u5B89\u88C5\u76EE\u5F55\u4E2D\u7684\u914D\u7F6E: ${s}`)}let n;try{n=JSON.parse(c.default.readFileSync(s,"utf-8")),(0,o.log)(`\u5DF2\u8BFB\u53D6\u914D\u7F6E: ${s}`)}catch(r){(0,o.log)(`\u8BFB\u53D6\u914D\u7F6E\u5931\u8D25: ${s}\uFF0C${r.message}\uFF0C\u8DF3\u8FC7\u914D\u7F6E\u5199\u5165`);return}n.gateway={...n.gateway??{},port:t},n.gateway.auth={...n.gateway.auth??{},token:e},(0,o.log)(`\u5DF2\u5199\u5165 gateway.port=${t}, gateway.token=${e}`),n.plugins=n.plugins??{},n.plugins.entries=n.plugins.entries??{},n.plugins.entries[m]=n.plugins.entries[m]??{},n.plugins.entries[m].config={...n.plugins.entries[m].config??{},wsPort:i},(0,o.log)(`\u5DF2\u5C06 ${m} wsPort=${i} \u5199\u5165\u914D\u7F6E`),c.default.writeFileSync(a.QBOT_CLAW_CONFIG_PATH,JSON.stringify(n,null,2),"utf-8"),(0,o.log)(`\u914D\u7F6E\u6587\u4EF6\u5DF2\u5199\u5165: ${a.QBOT_CLAW_CONFIG_PATH}`)}function W(){try{if(!c.default.existsSync(a.GALILEO_CONFIG_PATH)){(0,o.log)(`[galileo] \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7: ${a.GALILEO_CONFIG_PATH}`);return}const t=c.default.readFileSync(a.GALILEO_CONFIG_PATH,"utf-8"),e=JSON.parse(t),i=e.galileo;if(!i){(0,o.log)("[galileo] \u914D\u7F6E\u6587\u4EF6\u4E2D\u7F3A\u5C11 galileo \u5B57\u6BB5\uFF0C\u8DF3\u8FC7");return}const l=process.env.QB_QIMEI36||"";i.userId==="userid"&&l?(i.userId=l,i.customAttributes={qimei36:l,guid:process.env.QB_GUID||""},c.default.writeFileSync(a.GALILEO_CONFIG_PATH,JSON.stringify(e,null,2),"utf-8"),(0,o.log)(`[galileo] \u5DF2\u5C06 userId \u66F4\u65B0\u4E3A ${l}\uFF0CcustomAttributes \u5DF2\u5199\u5165`)):(0,o.log)(`[galileo] \u65E0\u9700\u66F4\u65B0\uFF08userId=${i.userId}, QB_QIMEI36=${l||"\u7A7A"})`)}catch(t){(0,o.log)(`[galileo] \u8BFB\u53D6/\u5199\u5165\u914D\u7F6E\u5931\u8D25: ${t.message}`)}}async function C(t){const e=Date.now(),i=await(0,A.getQBotClawVersion)()??"unknown";try{W();const l=(0,w.readState)();let s;l.gatewayPort&&!await(0,w.isPortAvailable)(l.gatewayPort)?(s=l.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,A.findAvailablePort)(),(0,o.log)(`\u540E\u53F0\u542F\u52A8 QBotClaw gateway run --port ${s} --force`);const n=await(0,A.findAvailablePort)(),r=(0,O.getOrCreateGatewayToken)();await M(s,r,n,t),G(r);const g=(0,E.spawn)(a.QBOTCLAW_BIN,["gateway","run","--port",String(s),"--force"],{stdio:"ignore",shell:process.platform==="win32",windowsHide:!0,env:{...process.platform==="win32"?process.env:{PATH:a.NODE_BIN_DIR},HOME:process.env.HOME||process.env.USERPROFILE,USERPROFILE:process.env.USERPROFILE,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||"",QBOTCLAW_LLM_BASE_URL:`http://127.0.0.1:${l.port}/v1`,QBOTCLAW_LLM_API_KEY:L.proxyApiKey}});g.unref();const u=g.pid;(0,o.log)(`QBotClaw gateway \u5DF2\u5728\u540E\u53F0\u542F\u52A8\uFF0CPID: ${u}\uFF0C\u7AEF\u53E3: ${s}, token ${(0,O.getOrCreateGatewayToken)()}`),(0,w.writeState)({...(0,w.readState)(),gatewayPid:u,gatewayPort:s,mcpWsPort:n}),(0,f.report)({event_name:"qbot_claw_started",version:i,result:"1",cost_ms:String(Date.now()-e)})}catch(l){throw(0,f.report)({event_name:"qbot_claw_started",version:i,result:"0",cost_ms:String(Date.now()-e),error:l.message}),l}}function G(t){const e=_.default.join(a.QBOT_CLAW_DIR,".env"),i=`OPENCLAW_GATEWAY_TOKEN=${t}
|
|
6
6
|
`;try{if(c.default.existsSync(e)){const n=c.default.readFileSync(e,"utf-8").split(`
|
|
7
7
|
`).filter(r=>!r.startsWith("OPENCLAW_GATEWAY_TOKEN=")).filter(r=>r!=="").join(`
|
|
8
8
|
`)+`
|
|
9
|
-
`+i;c.default.writeFileSync(e,n,"utf-8")}else c.default.writeFileSync(e,i,"utf-8");(0,
|
|
10
|
-
`);return}exports.isInstalling=!0,I.push(t),exports.installState={status:"downloading",message:"\u6B63\u5728\u5B89\u88C5...",startTime:new Date().toISOString()},(0,
|
|
11
|
-
`)}catch{}
|
|
12
|
-
`)}catch{}
|
|
9
|
+
`+i;c.default.writeFileSync(e,n,"utf-8")}else c.default.writeFileSync(e,i,"utf-8");(0,o.log)(`\u5DF2\u5C06 OPENCLAW_GATEWAY_TOKEN \u5199\u5165 ${e}`)}catch(l){(0,o.log)(`\u5199\u5165 .env \u6587\u4EF6\u5931\u8D25: ${l.message}`)}}function b(t,e,i){if(exports.isInstalling){(0,o.log)("[runInstall] \u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u5C06\u65B0\u8BF7\u6C42\u52A0\u5165\u8FDB\u5EA6\u76D1\u542C"),I.push(t),N(t,JSON.stringify({status:"downloading",progress:0,message:"\u5B89\u88C5\u6B63\u5728\u8FDB\u884C\u4E2D\uFF0C\u5DF2\u52A0\u5165\u8FDB\u5EA6\u76D1\u542C..."})+`
|
|
10
|
+
`);return}exports.isInstalling=!0,I.push(t),exports.installState={status:"downloading",message:"\u6B63\u5728\u5B89\u88C5...",startTime:new Date().toISOString()},(0,o.log)(`\u5F00\u59CB\u5B89\u88C5 ${a.NPM_PACKAGE_NAME}@${e}`),(0,f.report)({event_name:"qbot_claw_install_start"});const l=Date.now();(async()=>{try{(0,w.stopGateway)(),Q(),h();const s=4;let n=0;d(t,s,n,"\u5F00\u59CB\u5B89\u88C5 qqbrowser-skill..."),await(0,B.installQQBrowserSkill)(p=>d(t,s,n,p)),n++,d(t,s,n,"\u5F00\u59CB\u4E0B\u8F7D\u89E3\u538B QBotClaw...");const r=Date.now();try{await v(e),n++,d(t,s,n,"npmDownloadQBotClaw \u5B8C\u6210"),d(t,s,n,"\u5F00\u59CB npm rebuild..."),await D(e),n++,d(t,s,n,"npmRebuildQBotClaw \u5B8C\u6210");const p=Date.now()-r;(0,f.report)({event_name:"qbot_claw_npm_install",result:"1",cost_ms:String(p)})}catch(p){const P=Date.now()-r;throw(0,f.report)({event_name:"qbot_claw_npm_install",result:"0",cost_ms:String(P),error:p.message}),p}try{c.default.existsSync(a.OPENCLAW_BIN)||(process.platform==="win32"?(c.default.copyFileSync(a.QBOTCLAW_BIN,a.OPENCLAW_BIN),(0,o.log)(`\u5DF2\u590D\u5236\u6587\u4EF6: ${a.QBOTCLAW_BIN} -> ${a.OPENCLAW_BIN}`)):(c.default.symlinkSync(a.QBOTCLAW_BIN,a.OPENCLAW_BIN),(0,o.log)(`\u5DF2\u521B\u5EFA\u8F6F\u94FE\u63A5: ${a.OPENCLAW_BIN} -> ${a.QBOTCLAW_BIN}`)))}catch(p){(0,o.log)(`\u521B\u5EFA openclaw \u94FE\u63A5/\u590D\u5236\u5931\u8D25: ${p.message}`)}exports.installState={status:"success",message:"\u5B89\u88C5\u6210\u529F",endTime:new Date().toISOString()},(0,o.log)("\u5B89\u88C5\u6210\u529F"),(0,f.report)({event_name:"qbot_claw_install_done",version:e,result:"1",cost_ms:String(Date.now()-l)}),(0,o.refreshClawVersion)(e),d(t,s,n,"\u5F00\u59CB\u914D\u7F6E\u5E76\u542F\u52A8 QBotClaw gateway..."),await C(i),n++;const g=(0,O.getOrCreateGatewayToken)(),u=JSON.stringify({status:"done",progress:100,message:"\u5B89\u88C5\u6210\u529F",gatewayToken:g});if(t.writable)try{t.end(u+`
|
|
11
|
+
`)}catch{}y(u)}catch(s){exports.installState={status:"failed",message:s.message,endTime:new Date().toISOString()},(0,o.log)(`\u5B89\u88C5\u5931\u8D25: ${s.message}`),(0,f.report)({event_name:"qbot_claw_install_done",version:e,result:"0",cost_ms:String(Date.now()-l),error:s.message});const n=JSON.stringify({status:"failed",progress:0,message:s.message});if(t&&t.writable)try{t.end(n+`
|
|
12
|
+
`)}catch{}y(n)}finally{exports.isInstalling=!1}})()}
|
package/dist/openai-proxy.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
`),r.end()}function re(r,e){const{isStream:i,httpStatus:l,message:t,type:h,code:y,extra:O}=e;if(!i){_(r,l,t,h,y,O);return}if(!r.headersSent){_(r,l,t,h,y,O);return}k(r,t,h,y,O)}function me(r){return new Promise((e,i)=>{const l=[];r.on("data",t=>l.push(t)),r.on("end",()=>e(Buffer.concat(l))),r.on("error",i)})}async function Se(r,e,i){const l=r.url||"";if(!l.startsWith("/v1/"))return!1;const t=Te(),h=r.method||"GET",y=Date.now();(0,o.log)(`[openai-proxy][${t}] \u6536\u5230\u8BF7\u6C42: ${h} ${l}`);const O=he;if(!O.enabled)return(0,o.log)(`[openai-proxy][${t}] \u4EE3\u7406\u672A\u542F\u7528\uFF0C\u8FD4\u56DE 404`),_(e,404,"Not Found",p.INVALID_REQUEST,u.NOT_FOUND),!0;const W=ye(r);if(!W)return(0,o.log)(`[openai-proxy][${t}] \u7F3A\u5C11 API Key`),_(e,401,"You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth.",p.INVALID_REQUEST,u.MISSING_API_KEY),!0;if(!O.allowedApiKeys.includes(W))return(0,o.log)(`[openai-proxy][${t}] API Key \u6821\u9A8C\u5931\u8D25`),_(e,401,"Incorrect API key provided. You can check your API key in the proxy configuration.",p.INVALID_REQUEST,u.INVALID_API_KEY),!0;let D;try{D=await me(r)}catch(n){return(0,o.log)(`[openai-proxy][${t}] \u8BFB\u53D6\u8BF7\u6C42\u4F53\u5931\u8D25: ${n.message}`),_(e,400,"Failed to read request body",p.INVALID_REQUEST,u.BAD_REQUEST),!0}let x=!1,A=null;if(l.includes("/chat/completions")&&D.length>0)try{A=JSON.parse(D.toString("utf-8")),x=A.stream===!0,(0,o.log)(`[openai-proxy][${t}] stream=${A.stream}`)}catch{}let q=!1;if(Array.isArray(A?.messages)){const n=A.messages;let a=-1;for(let s=n.length-1;s>=0;s--)if(n[s].role==="user"){a=s;break}a>=0&&(q=n.slice(a+1).some(s=>s.role==="tool"))}if(q&&(0,o.log)(`[openai-proxy][${t}] \u6700\u540E\u4E00\u6761\u7528\u6237\u6D88\u606F\u4E4B\u540E\u5B58\u5728 tool \u6D88\u606F\uFF0C\u8DF3\u8FC7\u8F93\u5165\u5185\u5BB9\u5BA1\u6838\uFF08\u5DE5\u5177\u8C03\u7528\u540E\u7EED\u8BF7\u6C42\uFF09`),A&&l.includes("/chat/completions")&&Array.isArray(A.messages)&&!q){const n=[];for(const a of A.messages)if(a.role==="user"){if(typeof a.content=="string"&&a.content.length>0)n.push(a.content);else if(Array.isArray(a.content))for(const s of a.content)s.type==="text"&&typeof s.text=="string"&&s.text.length>0&&n.push(s.text)}if(n.length>0){const a=n[n.length-1];try{(0,o.log)(`[openai-proxy][${t}] \u8F93\u5165\u5185\u5BB9\u5BA1\u6838\uFF0C\u6587\u672C\u957F\u5EA6: ${a.length}\uFF0C\u9001\u5BA1\u5185\u5BB9:
|
|
12
12
|
${a}`),await(0,w.reviewText)(a,w.AuditContentType.INPUT,i),(0,o.log)(`[openai-proxy][${t}] \u8F93\u5165\u5185\u5BB9\u5BA1\u6838\u901A\u8FC7`)}catch(s){if(s instanceof w.ContentReviewFailedError){(0,o.log)(`[openai-proxy][${t}] \u8F93\u5165\u5185\u5BB9\u5BA1\u6838\u672A\u901A\u8FC7: ${s.fallbackMsg}`);const B=s.fallbackMsg||"\u8F93\u5165\u5185\u5BB9\u5305\u542B\u8FDD\u89C4\u4FE1\u606F\uFF0C\u8BF7\u4FEE\u6539\u540E\u91CD\u8BD5\u3002";return re(e,{isStream:x,httpStatus:400,message:B,type:p.CONTENT_FILTER,code:u.CONTENT_REVIEW_FAILED_INPUT,extra:{phase_action:s.phase_action,is_show:s.is_show}}),!0}(0,o.log)(`[openai-proxy][${t}] \u8F93\u5165\u5185\u5BB9\u5BA1\u6838\u5F02\u5E38\uFF08\u4E0D\u963B\u585E\uFF09: ${s.message||JSON.stringify(s)}`)}}}const Q=new te.URL(O.targetBaseUrl),ae=Q.pathname.replace(/\/+$/,""),se=l.replace(/^\/v1/,""),C=new te.URL(ae+se,Q.origin),X=C.protocol==="https:",ie=X?de.default:fe.default,le=X?443:80,L={};for(const[n,a]of Object.entries(r.headers)){if(!a)continue;const s=n.toLowerCase();["host","connection","keep-alive","transfer-encoding","upgrade"].includes(s)||(L[n]=a)}L.host=C.host;let H;try{H=await(0,oe.fetchLlmToken)(i),(0,o.log)(`[openai-proxy][${t}] \u6210\u529F\u83B7\u53D6 LLM Token ${H}`)}catch(n){if(n instanceof oe.TokenExhaustedError){(0,o.log)(`[openai-proxy][${t}] Token \u5DF2\u8017\u5C3D: ${n.message}`);const s=n.message||"\u5F53\u65E5Token\u5DF2\u8017\u5C3D\uFF0C\u8BF7\u5207\u6362\u6A21\u578B\u6216\u660E\u65E5\u518D\u8BD5";return re(e,{isStream:x,httpStatus:429,message:s,type:p.INSUFFICIENT_QUOTA,code:u.TOKEN_EXHAUSTED}),!0}if(n instanceof ge.AuthExpiredError)return(0,o.log)(`[openai-proxy][${t}] \u7968\u636E\u8FC7\u671F: ${n.message}`),_(e,401,`Auth token expired: ${n.message}`,p.AUTH,u.AUTH_EXPIRED),!0;const a=n instanceof Error?n.message:JSON.stringify(n);return(0,o.log)(`[openai-proxy][${t}] \u83B7\u53D6 LLM Token \u5931\u8D25: ${a}`),_(e,500,`Failed to obtain auth token: ${a}`,p.SERVER,u.TOKEN_FETCH_ERROR),!0}L.authorization=`Bearer ${H}`;const ce={hostname:C.hostname,port:C.port||le,path:C.pathname+C.search,method:h,headers:L,timeout:O.timeout||12e4};(0,o.log)(`[openai-proxy][${t}] \u8F6C\u53D1\u5230: ${h} ${C.href}`);try{const n=D.toString("utf-8");(0,o.log)(`[openai-proxy][${t}] \u8F6C\u53D1\u8BF7\u6C42\u4F53: ${n.length>500?n.substring(0,500)+`...(truncated, total ${n.length} chars)`:n}`)}catch{}const v=ie.request(ce,n=>{const a=n.statusCode||502,s=n.headers["content-type"]||"",B=s.includes("text/event-stream")||x,pe=Date.now()-y;(0,o.log)(`[openai-proxy][${t}] \u76EE\u6807\u54CD\u5E94: ${a} ${s} (${pe}ms)${B?" [SSE\u6D41\u5F0F]":""} (isStreamRequest=${x})`);const K={};for(const[T,E]of Object.entries(n.headers)){if(!E)continue;const f=T.toLowerCase();["connection","keep-alive","upgrade"].includes(f)||(K[T]=E)}const j=x&&!s.includes("text/event-stream")&&a>=400;if(j&&(0,o.log)(`[openai-proxy][${t}] \u26A0\uFE0F \u4E0A\u6E38\u8FD4\u56DE\u975ESSE\u9519\u8BEF\u54CD\u5E94 (status=${a}, content-type=${s})\uFF0C\u964D\u7EA7\u4E3A\u975E\u6D41\u5F0F\u5904\u7406`),B&&!j){e.writeHead(a,K);let T="",E="",f="",$=!1,d=!1,M=!1;const g=100;let R=[],m=!1,N=!1,z=Promise.resolve();const Y=()=>{if(!(!e.writable||$)){for(const c of R)e.write(c);R.length>0&&(m=!0),R=[]}},Z=async(c,U)=>{if(!c||$)return;const b=w.AuditContentType.OUTPUT;try{(0,o.log)(`[openai-proxy][${t}] \u8F93\u51FA\u5185\u5BB9\u5BA1\u6838${U?"(\u6700\u7EC8)":""}\uFF0C\u6587\u672C\u957F\u5EA6: ${c.length}\uFF0C\u9001\u5BA1\u5185\u5BB9:
|
|
13
|
-
${c}`),await(0,w.reviewText)(c,b,i),(0,o.log)(`[openai-proxy][${t}] \u8F93\u51FA\u5185\u5BB9\u5BA1\u6838\u901A\u8FC7\uFF0Cflush ${R.length} \u4E2A\u7F13\u5B58chunk`),Y()}catch(S){if(S instanceof w.ContentReviewFailedError){(0,o.log)(`[openai-proxy][${t}] \u8F93\u51FA\u5185\u5BB9\u5BA1\u6838\u672A\u901A\u8FC7: ${S.fallbackMsg}`),$=!0,R=[];const I
|
|
13
|
+
${c}`),await(0,w.reviewText)(c,b,i),(0,o.log)(`[openai-proxy][${t}] \u8F93\u51FA\u5185\u5BB9\u5BA1\u6838\u901A\u8FC7\uFF0Cflush ${R.length} \u4E2A\u7F13\u5B58chunk`),Y()}catch(S){if(S instanceof w.ContentReviewFailedError){(0,o.log)(`[openai-proxy][${t}] \u8F93\u51FA\u5185\u5BB9\u5BA1\u6838\u672A\u901A\u8FC7: ${S.fallbackMsg}`),$=!0,R=[];const I=`400 ${S.fallbackMsg||"\u8F93\u51FA\u5185\u5BB9\u5305\u542B\u8FDD\u89C4\u4FE1\u606F\uFF0C\u8BF7\u4FEE\u6539\u540E\u91CD\u8BD5\u3002"}`;m?((0,o.log)(`[openai-proxy][${t}] [SSE] \u5DF2\u6709\u5185\u5BB9\u88ABflush\uFF0C\u8FFD\u52A0\u6807\u51C6 error`),k(e,I,p.CONTENT_FILTER,u.CONTENT_REVIEW_FAILED_OUTPUT_PARTIAL,{phase_action:S.phase_action,is_show:S.is_show})):((0,o.log)(`[openai-proxy][${t}] [SSE] \u5C1A\u672Aflush\u4EFB\u4F55\u5185\u5BB9\uFF0C\u8FD4\u56DE\u6807\u51C6 error`),k(e,I,p.CONTENT_FILTER,u.CONTENT_REVIEW_FAILED_OUTPUT,{phase_action:S.phase_action,is_show:S.is_show})),n.destroy();return}(0,o.log)(`[openai-proxy][${t}] \u8F93\u51FA\u5185\u5BB9\u5BA1\u6838\u5F02\u5E38\uFF08\u4E0D\u963B\u585E\uFF0C\u76F4\u63A5flush\uFF09: ${S.message||JSON.stringify(S)}`),Y()}};n.on("data",c=>{if($){(0,o.log)(`[openai-proxy][${t}] [SSE] \u5BA1\u6838\u5DF2\u4E2D\u65AD\uFF0C\u8DF3\u8FC7chunk (${c.length}\u5B57\u8282)`);return}if(!e.writable){(0,o.log)(`[openai-proxy][${t}] [SSE] \u5BA2\u6237\u7AEF\u8FDE\u63A5\u5DF2\u5173\u95ED(res.writable=false)\uFF0C\u8DF3\u8FC7chunk (${c.length}\u5B57\u8282)`);return}const U=c.toString("utf-8");f+=U,f=f.replace(/\r\n/g,`
|
|
14
14
|
`).replace(/\r/g,`
|
|
15
15
|
`);const b=f.split(`
|
|
16
16
|
`);f=b.pop()||"";let S=!1;for(let I=0;I<b.length;I++){const F=b[I].trim();if(F){if(F==="data: [DONE]")M=!0;else if(F.startsWith("data: ")){const ee=F.slice(6);try{const P=JSON.parse(ee);if(P?.type==="upstream_error"||P?.error?.type==="upstream_error"){const ue=P.reqid||P.error?.reqid;(0,o.log)(`[openai-proxy][${t}] [SSE] \u68C0\u6D4B\u5230\u4E0A\u6E38 upstream_error (reqid=${ue})\uFF0C\u539F\u59CB\u56DE\u5305: ${ee}\uFF0C\u8FD4\u56DE\u6807\u51C6 error`),$=!0,R=[],k(e,"\u5F53\u524D\u4F7F\u7528\u4EBA\u6570\u8F83\u591A\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",p.UPSTREAM,u.UPSTREAM_UNAVAILABLE),n.destroy(),S=!0;break}const V=ne(P);V.content&&(T+=V.content,E+=V.content),V.hasToolCalls&&(d=!0)}catch(P){(0,o.log)(`[extractDeltaContent] JSON\u89E3\u6790\u5931\u8D25: ${P}`)}}}}if(!S&&(M&&E.length===0&&!d?(0,o.log)(`[openai-proxy][${t}] [SSE] \u68C0\u6D4B\u5230 [DONE] \u4E14\u8F93\u51FA\u4E3A\u7A7A\uFF0C\u6682\u4E0D\u7F13\u5B58\uFF0C\u7B49\u5F85 end \u4E8B\u4EF6\u5904\u7406`):R.push(c),T.length>=g&&!N)){const I=T;T="",(0,o.log)(`[openai-proxy][${t}] [SSE] \u89E6\u53D1\u5BA1\u6838\uFF0C\u6587\u672C\u957F\u5EA6: ${I.length} ${I}`),N=!0,n.pause(),z=Z(I,!1).finally(()=>{N=!1,$||n.resume()})}}),n.on("end",async()=>{if(N&&((0,o.log)(`[openai-proxy][${t}] [SSE] end\u4E8B\u4EF6\u89E6\u53D1\uFF0C\u7B49\u5F85\u8FDB\u884C\u4E2D\u7684\u5BA1\u6838\u5B8C\u6210...`),await z),f.trim()){const c=f.trim();if(c.startsWith("data: ")&&c!=="data: [DONE]"){const U=$e(c.slice(6));U.content&&(T+=U.content,E+=U.content),U.hasToolCalls&&(d=!0)}}if(E.length===0?(0,o.log)(`[openai-proxy][${t}] [SSE] \u26A0\uFE0F \u6A21\u578B\u8F93\u51FA\u5185\u5BB9\u4E3A\u7A7A\uFF01\u8BF7\u68C0\u67E5\u4E0A\u65B9\u65E5\u5FD7\u4E2D\u7684\u539F\u59CBchunk\u6570\u636E`):(0,o.log)(`[openai-proxy][${t}] [SSE] \u6A21\u578B\u8F93\u51FA\u5185\u5BB9 (${E.length}\u5B57\u7B26):
|
package/dist/qbotclaw-routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=exports&&exports.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleQBotClawRoutes=_;const f=m(require("fs")),g=require("./config"),o=require("./utils"),w=require("./installer"),u=require("./reportLog"),O=["models.providers","agents.defaults.model"];function p(s){return O.some(e=>s===e||s.startsWith(e+"."))}const S=["models.providers."];function y(s){return S.some(e=>s.startsWith(e))}const h=["channels.logout"];function N(s){return h.includes(s)}function i(s){return new Promise((e,n)=>{let a="";s.on("data",t=>{a+=t.toString()}),s.on("end",()=>e(a)),s.on("error",n)})}function c(s){return new Promise(e=>{let n="";const a={writable:!0,write(t){return n+=t,!0}};(0,w.runQBotClaw)(s,a).then(()=>{e(n)})})}function J(s){const e=s.match(/\{[\s\S]*\}/);if(!e)throw new Error(`\u54CD\u5E94\u4E2D\u672A\u5305\u542B\u6709\u6548\u7684 JSON: ${s.slice(0,200)}`);return JSON.parse(e[0])}const b={"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"};async function _(s,e,n){if(!n.startsWith("/api/qbotclaw/"))return!1;if(!f.default.existsSync(g.QBOTCLAW_BIN))return(0,o.sendJSON)(e,404,{status:"\u5931\u8D25",message:`qbotclaw \u53EF\u6267\u884C\u6587\u4EF6\u4E0D\u5B58\u5728: ${g.QBOTCLAW_BIN}`}),!0;if(n.startsWith("/api/qbotclaw/config/get")&&s.method==="GET"){const t=new URL(n,"http://localhost").searchParams.get("key");if(!t)return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 key"}),!0;if(!p(t))return(0,u.log)(`[qbotclaw/config/get] \u62D2\u7EDD\u8BBF\u95EE\u4E0D\u5141\u8BB8\u7684\u914D\u7F6E\u9879: ${t}`),(0,o.sendJSON)(e,403,{status:"\u5931\u8D25",message:`\u4E0D\u5141\u8BB8\u8BBF\u95EE\u8BE5\u914D\u7F6E\u9879: ${t}`}),!0;try{(0,u.log)(`[qbotclaw/config/get] \u83B7\u53D6\u914D\u7F6E: ${t}`);const r=await c(["config","get",t]),l=J(r);(0,o.sendJSON)(e,200,l)}catch(r){(0,u.log)(`[qbotclaw/config/get] \u6267\u884C\u5931\u8D25: ${r.message}`),(0,o.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u83B7\u53D6\u914D\u7F6E\u5931\u8D25: ${r.message}`})}return!0}if(n==="/api/qbotclaw/config/set"&&s.method==="POST"){try{const a=await i(s),t=JSON.parse(a);if(!t.key||typeof t.key!="string")return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 key \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32"}),!0;if(t.value===void 0||t.value===null)return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 value \u4E0D\u80FD\u4E3A\u7A7A"}),!0;if(!y(t.key))return(0,u.log)(`[qbotclaw/config/set] \u62D2\u7EDD\u8BBE\u7F6E\u4E0D\u5141\u8BB8\u7684\u914D\u7F6E\u9879: ${t.key}`),(0,o.sendJSON)(e,403,{status:"\u5931\u8D25",message:`\u4E0D\u5141\u8BB8\u8BBE\u7F6E\u8BE5\u914D\u7F6E\u9879: ${t.key}`}),!0;const r=typeof t.value
|
|
1
|
+
"use strict";var m=exports&&exports.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleQBotClawRoutes=_;const f=m(require("fs")),g=require("./config"),o=require("./utils"),w=require("./installer"),u=require("./reportLog"),O=["models.providers","agents.defaults.model"];function p(s){return O.some(e=>s===e||s.startsWith(e+"."))}const S=["models.providers."];function y(s){return S.some(e=>s.startsWith(e))}const h=["channels.logout"];function N(s){return h.includes(s)}function i(s){return new Promise((e,n)=>{let a="";s.on("data",t=>{a+=t.toString()}),s.on("end",()=>e(a)),s.on("error",n)})}function c(s){return new Promise(e=>{let n="";const a={writable:!0,write(t){return n+=t,!0}};(0,w.runQBotClaw)(s,a).then(()=>{e(n)})})}function J(s){const e=s.match(/\{[\s\S]*\}/);if(!e)throw new Error(`\u54CD\u5E94\u4E2D\u672A\u5305\u542B\u6709\u6548\u7684 JSON: ${s.slice(0,200)}`);return JSON.parse(e[0])}const b={"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"};async function _(s,e,n){if(!n.startsWith("/api/qbotclaw/"))return!1;if(!f.default.existsSync(g.QBOTCLAW_BIN))return(0,o.sendJSON)(e,404,{status:"\u5931\u8D25",message:`qbotclaw \u53EF\u6267\u884C\u6587\u4EF6\u4E0D\u5B58\u5728: ${g.QBOTCLAW_BIN}`}),!0;if(n.startsWith("/api/qbotclaw/config/get")&&s.method==="GET"){const t=new URL(n,"http://localhost").searchParams.get("key");if(!t)return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u7F3A\u5C11\u5FC5\u8981\u53C2\u6570 key"}),!0;if(!p(t))return(0,u.log)(`[qbotclaw/config/get] \u62D2\u7EDD\u8BBF\u95EE\u4E0D\u5141\u8BB8\u7684\u914D\u7F6E\u9879: ${t}`),(0,o.sendJSON)(e,403,{status:"\u5931\u8D25",message:`\u4E0D\u5141\u8BB8\u8BBF\u95EE\u8BE5\u914D\u7F6E\u9879: ${t}`}),!0;try{(0,u.log)(`[qbotclaw/config/get] \u83B7\u53D6\u914D\u7F6E: ${t}`);const r=await c(["config","get",t]),l=J(r);(0,o.sendJSON)(e,200,l)}catch(r){(0,u.log)(`[qbotclaw/config/get] \u6267\u884C\u5931\u8D25: ${r.message}`),(0,o.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u83B7\u53D6\u914D\u7F6E\u5931\u8D25: ${r.message}`})}return!0}if(n==="/api/qbotclaw/config/set"&&s.method==="POST"){try{const a=await i(s),t=JSON.parse(a);if(!t.key||typeof t.key!="string")return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 key \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32"}),!0;if(t.value===void 0||t.value===null)return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 value \u4E0D\u80FD\u4E3A\u7A7A"}),!0;if(!y(t.key))return(0,u.log)(`[qbotclaw/config/set] \u62D2\u7EDD\u8BBE\u7F6E\u4E0D\u5141\u8BB8\u7684\u914D\u7F6E\u9879: ${t.key}`),(0,o.sendJSON)(e,403,{status:"\u5931\u8D25",message:`\u4E0D\u5141\u8BB8\u8BBE\u7F6E\u8BE5\u914D\u7F6E\u9879: ${t.key}`}),!0;const r=typeof t.value!="string"?JSON.stringify(t.value):t.value;(0,u.log)(`[qbotclaw/config/set] \u8BBE\u7F6E\u914D\u7F6E: ${t.key}`);const l=await c(["config","set",t.key,r]);(0,o.sendJSON)(e,200,{status:"\u6210\u529F",message:"\u914D\u7F6E\u5DF2\u66F4\u65B0",output:l.trim()})}catch(a){(0,u.log)(`[qbotclaw/config/set] \u6267\u884C\u5931\u8D25: ${a.message}`),(0,o.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u8BBE\u7F6E\u914D\u7F6E\u5931\u8D25: ${a.message}`})}return!0}if(n==="/api/qbotclaw/models/set"&&s.method==="POST"){try{const a=await i(s),t=JSON.parse(a);if(!t.modelName||typeof t.modelName!="string")return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 modelName \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32"}),!0;(0,u.log)(`[qbotclaw/models/set] \u8BBE\u7F6E\u6D3B\u8DC3\u6A21\u578B: ${t.modelName}`);const r=await c(["models","set",t.modelName]);(0,o.sendJSON)(e,200,{status:"\u6210\u529F",message:"\u6A21\u578B\u5DF2\u8BBE\u7F6E",output:r.trim()})}catch(a){(0,u.log)(`[qbotclaw/models/set] \u6267\u884C\u5931\u8D25: ${a.message}`),(0,o.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u8BBE\u7F6E\u6A21\u578B\u5931\u8D25: ${a.message}`})}return!0}if(n==="/api/qbotclaw/gateway/call"&&s.method==="POST"){try{const a=await i(s),t=JSON.parse(a);if(!t.method||typeof t.method!="string")return(0,o.sendJSON)(e,400,{status:"\u5931\u8D25",message:"\u53C2\u6570 method \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32"}),!0;if(!N(t.method))return(0,u.log)(`[qbotclaw/gateway/call] \u62D2\u7EDD\u8C03\u7528\u4E0D\u5141\u8BB8\u7684\u65B9\u6CD5: ${t.method}`),(0,o.sendJSON)(e,403,{status:"\u5931\u8D25",message:`\u4E0D\u5141\u8BB8\u8C03\u7528\u8BE5\u65B9\u6CD5: ${t.method}`}),!0;const r=["gateway","call",t.method];if(t.params){const d=typeof t.params=="string"?t.params:JSON.stringify(t.params);r.push("--params",d)}(0,u.log)(`[qbotclaw/gateway/call] \u8C03\u7528: ${t.method}`);const l=await c(r);(0,o.sendJSON)(e,200,{status:"\u6210\u529F",message:"\u8C03\u7528\u5B8C\u6210",output:l.trim()})}catch(a){(0,u.log)(`[qbotclaw/gateway/call] \u6267\u884C\u5931\u8D25: ${a.message}`),(0,o.sendJSON)(e,500,{status:"\u5931\u8D25",message:`\u8C03\u7528\u5931\u8D25: ${a.message}`})}return!0}return(0,o.sendJSON)(e,404,{status:"\u5931\u8D25",message:"\u63A5\u53E3\u4E0D\u5B58\u5728"}),!0}
|